graview 0.1.66 → 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 (197) hide show
  1. package/dist/preview/{chunk.LSN2IPAI.js → chunk.25QFDTCU.js} +1 -1
  2. package/dist/preview/{chunk.BFAFCVL4.js → chunk.264PB572.js} +1 -1
  3. package/dist/preview/chunk.2FHIINXG.js +2 -0
  4. package/dist/preview/{chunk.HSSIMVVM.js → chunk.2VUX54XH.js} +1 -1
  5. package/dist/preview/{chunk.CTASTRQN.js → chunk.35KMZHB7.js} +1 -1
  6. package/dist/preview/{chunk.OWFS2YDQ.js → chunk.37RFCHSS.js} +1 -1
  7. package/dist/preview/chunk.3ENPWZBG.js +1 -0
  8. package/dist/preview/{chunk.XMQG2PSM.js → chunk.3GNT5MKP.js} +1 -1
  9. package/dist/preview/{chunk.BXBEGMPO.js → chunk.3NSV3WKM.js} +2 -2
  10. package/dist/preview/chunk.3ZODN6BW.js +1 -0
  11. package/dist/preview/{chunk.OPTYYIGC.js → chunk.47XEJZ3O.js} +1 -1
  12. package/dist/preview/{chunk.5FNFRVTL.js → chunk.4EMKCKDB.js} +1 -1
  13. package/dist/preview/{chunk.B6JRTW3A.js → chunk.4UUJHLHR.js} +1 -1
  14. package/dist/preview/{chunk.FBILPNGH.js → chunk.4W57E7AX.js} +1 -1
  15. package/dist/preview/chunk.55G4IPOO.js +1 -0
  16. package/dist/preview/{chunk.72XP2ARZ.js → chunk.5AKZROMR.js} +1 -1
  17. package/dist/preview/chunk.5J6DVR7S.js +1 -0
  18. package/dist/preview/{chunk.FXT5CN32.js → chunk.5R744JGZ.js} +1 -1
  19. package/dist/preview/{chunk.NJRLJEJY.js → chunk.6KJGRM7A.js} +1 -1
  20. package/dist/preview/{chunk.4AC2QM7T.js → chunk.6N4PE3U5.js} +1 -1
  21. package/dist/preview/{chunk.LGRVEHXT.js → chunk.6NG76MDA.js} +2 -2
  22. package/dist/preview/{chunk.4FCFNAA4.js → chunk.6SJEZWH3.js} +1 -1
  23. package/dist/preview/{chunk.7VADSNPZ.js → chunk.6UQFV53C.js} +1 -1
  24. package/dist/preview/{chunk.WAB3L3ZI.js → chunk.6W6XMLSF.js} +1 -1
  25. package/dist/preview/{chunk.4JULYKGD.js → chunk.77C556NM.js} +1 -1
  26. package/dist/preview/{chunk.IGK7EZCX.js → chunk.7ARRVNUR.js} +1 -1
  27. package/dist/preview/{chunk.CBXS23YH.js → chunk.7BJRHPE3.js} +2 -2
  28. package/dist/preview/{chunk.ZQR2SN65.js → chunk.7S6ZRMW4.js} +1 -1
  29. package/dist/preview/{chunk.IAEHUSQQ.js → chunk.7UHPHEH5.js} +1 -1
  30. package/dist/preview/chunk.7WHQWLL6.js +1 -0
  31. package/dist/preview/{chunk.KACSYPEV.js → chunk.A4EZAGG7.js} +1 -1
  32. package/dist/preview/chunk.A5PSEU3W.js +25 -0
  33. package/dist/preview/{chunk.VKZIEZ5C.js → chunk.A7GVTE5Y.js} +2 -2
  34. package/dist/preview/{chunk.45JP6VGJ.js → chunk.AJMVRFYX.js} +2 -2
  35. package/dist/preview/{chunk.6P6NGZ6D.js → chunk.AKJS2NUM.js} +1 -1
  36. package/dist/preview/{chunk.CU2WCYMK.js → chunk.ARWO4WOV.js} +1 -1
  37. package/dist/preview/chunk.B5SJMCTT.js +7 -0
  38. package/dist/preview/{chunk.JXNVNFV4.js → chunk.B7KZBT27.js} +1 -1
  39. package/dist/preview/{chunk.E3UL4MCD.js → chunk.BDNQMKDG.js} +1 -1
  40. package/dist/preview/{chunk.YNEHJWJV.js → chunk.BKYZSV2Y.js} +1 -1
  41. package/dist/preview/{chunk.5BX66FBP.js → chunk.CKDCTFLU.js} +1 -1
  42. package/dist/preview/chunk.CTUJZ3IV.js +1 -0
  43. package/dist/preview/chunk.CY7FFKEZ.js +1 -0
  44. package/dist/preview/{chunk.3PBTN7RO.js → chunk.D4WJ7OM5.js} +1 -1
  45. package/dist/preview/{chunk.C2C3AXGI.js → chunk.D7NWMXSX.js} +3 -3
  46. package/dist/preview/chunk.DEKRFTRN.js +4 -0
  47. package/dist/preview/{chunk.E7EWNWAN.js → chunk.DKEIEH2D.js} +1 -1
  48. package/dist/preview/{chunk.I2737CPF.js → chunk.DWM7AR5Y.js} +1 -1
  49. package/dist/preview/{chunk.ANS2IEEV.js → chunk.DZMIYEHQ.js} +1 -1
  50. package/dist/preview/{chunk.BMENTGDC.js → chunk.E5PYNAYT.js} +2 -2
  51. package/dist/preview/chunk.EBKH3ILT.js +1 -0
  52. package/dist/preview/{chunk.DTCAUPLC.js → chunk.EFVSZKB5.js} +1 -1
  53. package/dist/preview/{chunk.QOS5T46W.js → chunk.EGPCVMDU.js} +1 -1
  54. package/dist/preview/{chunk.7ZKBYXUM.js → chunk.EJ2EZL2G.js} +1 -1
  55. package/dist/preview/{chunk.7VP6Y6D2.js → chunk.EP6Q32WT.js} +1 -1
  56. package/dist/preview/{chunk.OOSIKCOS.js → chunk.F464JKHZ.js} +1 -1
  57. package/dist/preview/{chunk.VGHO3VCB.js → chunk.FLJXYESX.js} +1 -1
  58. package/dist/preview/chunk.FOUBDGL3.js +1 -0
  59. package/dist/preview/chunk.FPHRAO3R.js +1 -0
  60. package/dist/preview/{chunk.4FDVINRJ.js → chunk.FRQSLWP4.js} +1 -1
  61. package/dist/preview/{chunk.2MHNPBHC.js → chunk.FVQKSN33.js} +1 -1
  62. package/dist/preview/{chunk.PDDIQ6PK.js → chunk.G3GFDVO2.js} +1 -1
  63. package/dist/preview/{chunk.ZD7T234N.js → chunk.G5GVT6JY.js} +1 -1
  64. package/dist/preview/{chunk.3L4JMM3P.js → chunk.GFLH7RCI.js} +1 -1
  65. package/dist/preview/{chunk.OO2OP76C.js → chunk.GMLONS5L.js} +1 -1
  66. package/dist/preview/{chunk.FK722SHI.js → chunk.GRFD42WM.js} +1 -1
  67. package/dist/preview/{chunk.2VR7YEJ6.js → chunk.GVT4UUQA.js} +1 -1
  68. package/dist/preview/{chunk.GME63ZHI.js → chunk.H3EGBDW2.js} +1 -1
  69. package/dist/preview/{chunk.DQFHIJFN.js → chunk.H6KIEDZN.js} +1 -1
  70. package/dist/preview/{chunk.5B5SRTUK.js → chunk.HAOB6O72.js} +1 -1
  71. package/dist/preview/chunk.HB5NWHFP.js +3 -0
  72. package/dist/preview/{chunk.6EHHMWPP.js → chunk.HJUZMOW2.js} +1 -1
  73. package/dist/preview/{chunk.6MQ5NT7S.js → chunk.HN4ZJ4B4.js} +1 -1
  74. package/dist/preview/chunk.HVBKI5ZO.js +1 -0
  75. package/dist/preview/chunk.I3SDKMQS.js +1 -0
  76. package/dist/preview/{chunk.QQAZQDRW.js → chunk.IAEGJDF3.js} +1 -1
  77. package/dist/preview/{chunk.QWNSHISU.js → chunk.IDALEKIW.js} +1 -1
  78. package/dist/preview/{chunk.QFHWG4LN.js → chunk.ILJDLBPJ.js} +1 -1
  79. package/dist/preview/{chunk.ZR2TP3BF.js → chunk.J2OPIS3H.js} +1 -1
  80. package/dist/preview/chunk.J5OLYVZ4.js +1 -0
  81. package/dist/preview/{chunk.LETAQTLJ.js → chunk.J6HF7IRQ.js} +1 -1
  82. package/dist/preview/{chunk.RWIN3POV.js → chunk.JEC5FDKX.js} +1 -1
  83. package/dist/preview/chunk.JKFVNQY7.js +1 -0
  84. package/dist/preview/{chunk.LLIURXFP.js → chunk.JQ2WNKDW.js} +1 -1
  85. package/dist/preview/{chunk.Z7Y3R3YR.js → chunk.JQ63N4MZ.js} +1 -1
  86. package/dist/preview/{chunk.DZFM6GSY.js → chunk.JU6UFWS3.js} +1 -1
  87. package/dist/preview/{chunk.INHS3KTK.js → chunk.JVB5KDSG.js} +1 -1
  88. package/dist/preview/{chunk.4U4D7WOI.js → chunk.KFT7JIEH.js} +1 -1
  89. package/dist/preview/chunk.KGMSSXZL.js +1 -0
  90. package/dist/preview/{chunk.5CXIEYHY.js → chunk.KX5ZBHMA.js} +2 -2
  91. package/dist/preview/{chunk.V7W5AQKL.js → chunk.LP2ZMAT2.js} +1 -1
  92. package/dist/preview/{chunk.BUVTUAB5.js → chunk.LRNFE3UK.js} +1 -1
  93. package/dist/preview/{chunk.PAGEGBUD.js → chunk.LVOTLGJB.js} +1 -1
  94. package/dist/preview/{chunk.QHMHUL6B.js → chunk.LYEGRY77.js} +1 -1
  95. package/dist/preview/{chunk.PPSYUOH7.js → chunk.M7KXQGQL.js} +1 -1
  96. package/dist/preview/{chunk.7BIPZTJB.js → chunk.MAKCZ6B6.js} +1 -1
  97. package/dist/preview/{chunk.EQ4OODGO.js → chunk.MJY4SLWA.js} +1 -1
  98. package/dist/preview/{chunk.EMFOMSMI.js → chunk.MSAYU25L.js} +1 -1
  99. package/dist/preview/{chunk.F4VB6Q2W.js → chunk.MUSMNKE4.js} +1 -1
  100. package/dist/preview/{chunk.BGAC3B7X.js → chunk.MW7R5G3C.js} +1 -1
  101. package/dist/preview/{chunk.AK7NGFEX.js → chunk.N4ZKZ4GM.js} +1 -1
  102. package/dist/preview/{chunk.TXHYGFIZ.js → chunk.NAXOXBOF.js} +1 -1
  103. package/dist/preview/{chunk.IWYMKGZZ.js → chunk.NKLPL7QD.js} +1 -1
  104. package/dist/preview/{chunk.QU52E5RG.js → chunk.NKYWIGC7.js} +1 -1
  105. package/dist/preview/{chunk.KSIEO5W7.js → chunk.NRURQGXV.js} +1 -1
  106. package/dist/preview/{chunk.FV72U33M.js → chunk.NSOPYIT4.js} +1 -1
  107. package/dist/preview/chunk.NXZL5CA2.js +1 -0
  108. package/dist/preview/{chunk.WVLEGCRI.js → chunk.O2OL6RQQ.js} +1 -1
  109. package/dist/preview/{chunk.TGEL6EUA.js → chunk.O5VFKVZS.js} +1 -1
  110. package/dist/preview/{chunk.CEVGND3Y.js → chunk.OCXY5DCD.js} +3 -3
  111. package/dist/preview/chunk.OHAO6KKH.js +1 -0
  112. package/dist/preview/{chunk.DSYP43NN.js → chunk.P2EKKKK2.js} +1 -1
  113. package/dist/preview/chunk.PSNMZBVS.js +1 -0
  114. package/dist/preview/{chunk.W53YNBSM.js → chunk.PZ7KY6XH.js} +1 -1
  115. package/dist/preview/{chunk.WSO7JOW5.js → chunk.QAM76AXV.js} +1 -1
  116. package/dist/preview/{chunk.PSQYDCVM.js → chunk.QF5QB5YR.js} +1 -1
  117. package/dist/preview/chunk.QNP5OR3P.js +93 -0
  118. package/dist/preview/{chunk.5LJVOLKR.js → chunk.QRQ5WPZI.js} +1 -1
  119. package/dist/preview/chunk.QWGWOEBZ.js +90 -0
  120. package/dist/preview/{chunk.OMT4QUZY.js → chunk.QXLJGHMC.js} +4 -4
  121. package/dist/preview/{chunk.J2MM6BUW.js → chunk.QZQCQWQG.js} +1 -1
  122. package/dist/preview/{chunk.6FQW6FNL.js → chunk.R6JBA7UK.js} +1 -1
  123. package/dist/preview/chunk.R7CRBRD4.js +1 -0
  124. package/dist/preview/chunk.RD2FSSLV.js +1 -0
  125. package/dist/preview/{chunk.OEIWIZCP.js → chunk.RG5G6YQD.js} +1 -1
  126. package/dist/preview/{chunk.PFQBCHQA.js → chunk.RJY7VJBH.js} +1 -1
  127. package/dist/preview/chunk.RR25BGWP.js +1 -0
  128. package/dist/preview/{chunk.BZ7QWHAE.js → chunk.RSQ432QN.js} +1 -1
  129. package/dist/preview/{chunk.MWGZKZD6.js → chunk.SFBHPYRD.js} +1 -1
  130. package/dist/preview/{chunk.FFOD5B4B.js → chunk.SJQPTDAT.js} +1 -1
  131. package/dist/preview/{chunk.OTV5XTBB.js → chunk.SNHKYH72.js} +1 -1
  132. package/dist/preview/{chunk.WSDJPXJD.js → chunk.SO6NT5K7.js} +1 -1
  133. package/dist/preview/{chunk.FDZE5LTJ.js → chunk.STPA7HBK.js} +2 -2
  134. package/dist/preview/{chunk.ONYBW45K.js → chunk.SY5ID44D.js} +1 -1
  135. package/dist/preview/chunk.T27QKVKP.js +1 -0
  136. package/dist/preview/{chunk.U6TEW6YD.js → chunk.T2OUHRAA.js} +1 -1
  137. package/dist/preview/chunk.T3WCRS6M.js +1 -0
  138. package/dist/preview/{chunk.QGIM2WAY.js → chunk.TI5FR2QQ.js} +1 -1
  139. package/dist/preview/{chunk.HOCD7KIR.js → chunk.TTSGCNPT.js} +1 -1
  140. package/dist/preview/{chunk.ES63XSIM.js → chunk.TXZQEJ5T.js} +1 -1
  141. package/dist/preview/{chunk.6LXIEM6B.js → chunk.UDHPMVC4.js} +1 -1
  142. package/dist/preview/{chunk.KBPJ7X7W.js → chunk.UGQYMN4J.js} +1 -1
  143. package/dist/preview/{chunk.M6ZN2KUO.js → chunk.UQIPEMJ5.js} +1 -1
  144. package/dist/preview/{chunk.FIFUMX5X.js → chunk.URQTF5SY.js} +1 -1
  145. package/dist/preview/{chunk.J7W2OFHY.js → chunk.UW52CMGJ.js} +1 -1
  146. package/dist/preview/{chunk.LINSO5PN.js → chunk.UWS4RMM3.js} +1 -1
  147. package/dist/preview/{chunk.QPF4KSAW.js → chunk.V7H4BUEB.js} +1 -1
  148. package/dist/preview/{chunk.KHRS2SKB.js → chunk.VBHV4TLG.js} +1 -1
  149. package/dist/preview/{chunk.U3ED7W2U.js → chunk.VBLQJVQ5.js} +1 -1
  150. package/dist/preview/{chunk.CVPMSPCH.js → chunk.WALVW3KJ.js} +1 -1
  151. package/dist/preview/{chunk.2KFZHUAC.js → chunk.WEMUKZKH.js} +1 -1
  152. package/dist/preview/{chunk.YIPXZUTT.js → chunk.X226YATK.js} +1 -1
  153. package/dist/preview/{chunk.GNEOSHQ6.js → chunk.XFLGSUYO.js} +1 -1
  154. package/dist/preview/{chunk.W4YDPHCQ.js → chunk.XSWSBTUO.js} +1 -1
  155. package/dist/preview/{chunk.OJY7VJ7D.js → chunk.YCD4JSXD.js} +1 -1
  156. package/dist/preview/{chunk.72ZCLEQC.js → chunk.YZPESGCP.js} +1 -1
  157. package/dist/preview/{chunk.XOE4KNP2.js → chunk.Z27NSSYL.js} +2 -2
  158. package/dist/preview/{chunk.DEHIR4EG.js → chunk.Z2XUVJAL.js} +1 -1
  159. package/dist/preview/{chunk.YXEO3Y65.js → chunk.Z3O2VZAJ.js} +1 -1
  160. package/dist/preview/{chunk.M2JCFNHJ.js → chunk.Z4TY44CD.js} +1 -1
  161. package/dist/preview/{chunk.EXYCN4WI.js → chunk.ZAPS4J6G.js} +1 -1
  162. package/dist/preview/{chunk.6TLXFMX2.js → chunk.ZAQ4IDX6.js} +1 -1
  163. package/dist/preview/{chunk.6HY6ZGEE.js → chunk.ZEZUKRC6.js} +1 -1
  164. package/dist/preview/{chunk.GEFXU4VO.js → chunk.ZG5VGP5U.js} +1 -1
  165. package/dist/preview/index.html +56 -56
  166. package/dist/preview/page.js +2 -2
  167. package/package.json +6 -6
  168. package/dist/preview/chunk.4WGYUYWU.js +0 -2
  169. package/dist/preview/chunk.5EMIWORS.js +0 -1
  170. package/dist/preview/chunk.6EVMXBNB.js +0 -1
  171. package/dist/preview/chunk.BCQWAFGD.js +0 -1
  172. package/dist/preview/chunk.BOCVLC7X.js +0 -1
  173. package/dist/preview/chunk.DPJNGFEZ.js +0 -4
  174. package/dist/preview/chunk.E4VRRWFP.js +0 -1
  175. package/dist/preview/chunk.EUAO4QNV.js +0 -1
  176. package/dist/preview/chunk.F7672TKJ.js +0 -1
  177. package/dist/preview/chunk.FA42HCPW.js +0 -1
  178. package/dist/preview/chunk.FBJAQPZ6.js +0 -1
  179. package/dist/preview/chunk.GAFMWOME.js +0 -1
  180. package/dist/preview/chunk.I4Z7HVRT.js +0 -1
  181. package/dist/preview/chunk.JMXXA4YG.js +0 -1
  182. package/dist/preview/chunk.JMYUQNXN.js +0 -6
  183. package/dist/preview/chunk.K6DFXDPZ.js +0 -1
  184. package/dist/preview/chunk.KF27ME27.js +0 -1
  185. package/dist/preview/chunk.L25DCT5S.js +0 -1
  186. package/dist/preview/chunk.MODLZJD4.js +0 -25
  187. package/dist/preview/chunk.OJGHDWI6.js +0 -1
  188. package/dist/preview/chunk.SSF47GUY.js +0 -1
  189. package/dist/preview/chunk.T6DPWW2K.js +0 -3
  190. package/dist/preview/chunk.TA36WBHK.js +0 -1
  191. package/dist/preview/chunk.TTGKX7LT.js +0 -1
  192. package/dist/preview/chunk.U3HERHAI.js +0 -88
  193. package/dist/preview/chunk.V5I4GZEY.js +0 -1
  194. package/dist/preview/chunk.VT2YGDK2.js +0 -1
  195. package/dist/preview/chunk.XK65Y2KX.js +0 -1
  196. package/dist/preview/chunk.Z274CL7J.js +0 -1
  197. package/dist/preview/chunk.ZBVYD4OX.js +0 -90
@@ -1,4 +1,4 @@
1
- import{G as I}from"./chunk.MODLZJD4.js";import{Tc as $,Uc as k,Vc as y,Wc as _,Xc as O,bd as x,od as S,qd as T,td as E,ud as R}from"./chunk.6HY6ZGEE.js";import{a as b}from"./chunk.AJZBJBMO.js";var N=b(l=>{"use strict";var V=I();function D(r){var e="https://react.dev/errors/"+r;if(1<arguments.length){e+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)e+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+r+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function d(){}var s={d:{f:d,r:function(){throw Error(D(522))},D:d,C:d,L:d,m:d,X:d,S:d,M:d},p:0,findDOMNode:null},j=Symbol.for("react.portal");function W(r,e,a){var t=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:j,key:t==null?null:""+t,children:r,containerInfo:e,implementation:a}}var u=V.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(r,e){if(r==="font")return"";if(typeof e=="string")return e==="use-credentials"?e:""}l.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s;l.createPortal=function(r,e){var a=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)throw Error(D(299));return W(r,e,null,a)};l.flushSync=function(r){var e=u.T,a=s.p;try{if(u.T=null,s.p=2,r)return r()}finally{u.T=e,s.p=a,s.d.f()}};l.preconnect=function(r,e){typeof r=="string"&&(e?(e=e.crossOrigin,e=typeof e=="string"?e==="use-credentials"?e:"":void 0):e=null,s.d.C(r,e))};l.prefetchDNS=function(r){typeof r=="string"&&s.d.D(r)};l.preinit=function(r,e){if(typeof r=="string"&&e&&typeof e.as=="string"){var a=e.as,t=h(a,e.crossOrigin),n=typeof e.integrity=="string"?e.integrity:void 0,i=typeof e.fetchPriority=="string"?e.fetchPriority:void 0;a==="style"?s.d.S(r,typeof e.precedence=="string"?e.precedence:void 0,{crossOrigin:t,integrity:n,fetchPriority:i}):a==="script"&&s.d.X(r,{crossOrigin:t,integrity:n,fetchPriority:i,nonce:typeof e.nonce=="string"?e.nonce:void 0})}};l.preinitModule=function(r,e){if(typeof r=="string")if(typeof e=="object"&&e!==null){if(e.as==null||e.as==="script"){var a=h(e.as,e.crossOrigin);s.d.M(r,{crossOrigin:a,integrity:typeof e.integrity=="string"?e.integrity:void 0,nonce:typeof e.nonce=="string"?e.nonce:void 0})}}else e==null&&s.d.M(r)};l.preload=function(r,e){if(typeof r=="string"&&typeof e=="object"&&e!==null&&typeof e.as=="string"){var a=e.as,t=h(a,e.crossOrigin);s.d.L(r,a,{crossOrigin:t,integrity:typeof e.integrity=="string"?e.integrity:void 0,nonce:typeof e.nonce=="string"?e.nonce:void 0,type:typeof e.type=="string"?e.type:void 0,fetchPriority:typeof e.fetchPriority=="string"?e.fetchPriority:void 0,referrerPolicy:typeof e.referrerPolicy=="string"?e.referrerPolicy:void 0,imageSrcSet:typeof e.imageSrcSet=="string"?e.imageSrcSet:void 0,imageSizes:typeof e.imageSizes=="string"?e.imageSizes:void 0,media:typeof e.media=="string"?e.media:void 0})}};l.preloadModule=function(r,e){if(typeof r=="string")if(e){var a=h(e.as,e.crossOrigin);s.d.m(r,{as:typeof e.as=="string"&&e.as!=="script"?e.as:void 0,crossOrigin:a,integrity:typeof e.integrity=="string"?e.integrity:void 0})}else s.d.m(r)};l.requestFormReset=function(r){s.d.r(r)};l.unstable_batchedUpdates=function(r,e){return r(e)};l.useFormState=function(r,e,a){return u.H.useFormState(r,e,a)};l.useFormStatus=function(){return u.H.useHostTransitionStatus()};l.version="19.2.8"});var Y=b((J,P)=>{"use strict";function L(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(L)}catch(r){console.error(r)}}L(),P.exports=N()});var B={name:"Graview",typography:{body:y.body,mono:y.mono},schemes:k},A={ground:"--graview-ground",groundDeep:"--graview-ground-deep",wash:"--graview-wash",panel:"--graview-panel",panelMuted:"--graview-panel-muted",panelWarning:"--graview-panel-warning",edge:"--graview-edge",edgeBright:"--graview-edge-bright",ink:"--graview-ink",inkMuted:"--graview-ink-muted",inkFaint:"--graview-ink-faint",accent:"--graview-accent",accentDim:"--graview-accent-dim",accentInk:"--graview-accent-ink",warn:"--graview-warn",good:"--graview-good",bad:"--graview-bad",glow:"--graview-glow",bar:"--graview-bar",float:"--graview-float",liftLow:"--graview-lift-low",liftHigh:"--graview-lift-high",tintAlpha:"--graview-tint-alpha",tintLightness:"--graview-tint-lightness",gridAlpha:"--graview-grid-alpha"};function H(r){return Object.keys(A).map(e=>` ${A[e]}: ${r[e]};`).join(`
1
+ import{G as I}from"./chunk.A5PSEU3W.js";import{Tc as $,Uc as k,Vc as y,Wc as _,Xc as O,bd as x,od as S,qd as T,td as E,ud as R}from"./chunk.ZEZUKRC6.js";import{a as b}from"./chunk.AJZBJBMO.js";var N=b(l=>{"use strict";var V=I();function D(r){var e="https://react.dev/errors/"+r;if(1<arguments.length){e+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)e+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+r+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function d(){}var s={d:{f:d,r:function(){throw Error(D(522))},D:d,C:d,L:d,m:d,X:d,S:d,M:d},p:0,findDOMNode:null},j=Symbol.for("react.portal");function W(r,e,a){var t=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:j,key:t==null?null:""+t,children:r,containerInfo:e,implementation:a}}var u=V.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(r,e){if(r==="font")return"";if(typeof e=="string")return e==="use-credentials"?e:""}l.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s;l.createPortal=function(r,e){var a=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)throw Error(D(299));return W(r,e,null,a)};l.flushSync=function(r){var e=u.T,a=s.p;try{if(u.T=null,s.p=2,r)return r()}finally{u.T=e,s.p=a,s.d.f()}};l.preconnect=function(r,e){typeof r=="string"&&(e?(e=e.crossOrigin,e=typeof e=="string"?e==="use-credentials"?e:"":void 0):e=null,s.d.C(r,e))};l.prefetchDNS=function(r){typeof r=="string"&&s.d.D(r)};l.preinit=function(r,e){if(typeof r=="string"&&e&&typeof e.as=="string"){var a=e.as,t=h(a,e.crossOrigin),n=typeof e.integrity=="string"?e.integrity:void 0,i=typeof e.fetchPriority=="string"?e.fetchPriority:void 0;a==="style"?s.d.S(r,typeof e.precedence=="string"?e.precedence:void 0,{crossOrigin:t,integrity:n,fetchPriority:i}):a==="script"&&s.d.X(r,{crossOrigin:t,integrity:n,fetchPriority:i,nonce:typeof e.nonce=="string"?e.nonce:void 0})}};l.preinitModule=function(r,e){if(typeof r=="string")if(typeof e=="object"&&e!==null){if(e.as==null||e.as==="script"){var a=h(e.as,e.crossOrigin);s.d.M(r,{crossOrigin:a,integrity:typeof e.integrity=="string"?e.integrity:void 0,nonce:typeof e.nonce=="string"?e.nonce:void 0})}}else e==null&&s.d.M(r)};l.preload=function(r,e){if(typeof r=="string"&&typeof e=="object"&&e!==null&&typeof e.as=="string"){var a=e.as,t=h(a,e.crossOrigin);s.d.L(r,a,{crossOrigin:t,integrity:typeof e.integrity=="string"?e.integrity:void 0,nonce:typeof e.nonce=="string"?e.nonce:void 0,type:typeof e.type=="string"?e.type:void 0,fetchPriority:typeof e.fetchPriority=="string"?e.fetchPriority:void 0,referrerPolicy:typeof e.referrerPolicy=="string"?e.referrerPolicy:void 0,imageSrcSet:typeof e.imageSrcSet=="string"?e.imageSrcSet:void 0,imageSizes:typeof e.imageSizes=="string"?e.imageSizes:void 0,media:typeof e.media=="string"?e.media:void 0})}};l.preloadModule=function(r,e){if(typeof r=="string")if(e){var a=h(e.as,e.crossOrigin);s.d.m(r,{as:typeof e.as=="string"&&e.as!=="script"?e.as:void 0,crossOrigin:a,integrity:typeof e.integrity=="string"?e.integrity:void 0})}else s.d.m(r)};l.requestFormReset=function(r){s.d.r(r)};l.unstable_batchedUpdates=function(r,e){return r(e)};l.useFormState=function(r,e,a){return u.H.useFormState(r,e,a)};l.useFormStatus=function(){return u.H.useHostTransitionStatus()};l.version="19.2.8"});var Y=b((J,P)=>{"use strict";function L(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(L)}catch(r){console.error(r)}}L(),P.exports=N()});var B={name:"Graview",typography:{body:y.body,mono:y.mono},schemes:k},A={ground:"--graview-ground",groundDeep:"--graview-ground-deep",wash:"--graview-wash",panel:"--graview-panel",panelMuted:"--graview-panel-muted",panelWarning:"--graview-panel-warning",edge:"--graview-edge",edgeBright:"--graview-edge-bright",ink:"--graview-ink",inkMuted:"--graview-ink-muted",inkFaint:"--graview-ink-faint",accent:"--graview-accent",accentDim:"--graview-accent-dim",accentInk:"--graview-accent-ink",warn:"--graview-warn",good:"--graview-good",bad:"--graview-bad",glow:"--graview-glow",bar:"--graview-bar",float:"--graview-float",liftLow:"--graview-lift-low",liftHigh:"--graview-lift-high",tintAlpha:"--graview-tint-alpha",tintLightness:"--graview-tint-lightness",gridAlpha:"--graview-grid-alpha"};function H(r){return Object.keys(A).map(e=>` ${A[e]}: ${r[e]};`).join(`
2
2
  `)}function C(r,e){let a=r===e?r:`${r} ${e}`;return` ${a} [data-graview-view] { transition: none; }
3
3
  ${a} [data-graview-touched] > * { animation: none; }
4
4
  ${a} [data-graview-view][data-graview-wrote] > *,
@@ -0,0 +1 @@
1
+ import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m,m as n,n as o,o as p}from"./chunk.IDALEKIW.js";import"./chunk.G4JJXA63.js";import{a}from"./chunk.TBY5IR7C.js";import"./chunk.URQTF5SY.js";import"./chunk.BIDL7GQD.js";import"./chunk.LP2ZMAT2.js";import"./chunk.M7KXQGQL.js";import"./chunk.XOZU4OFA.js";import"./chunk.H3EGBDW2.js";import"./chunk.Q5WEOX3Q.js";import"./chunk.6SJEZWH3.js";import"./chunk.6N4PE3U5.js";import"./chunk.B7KZBT27.js";import"./chunk.WVUJXDXZ.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.SO6NT5K7.js";import"./chunk.MUSMNKE4.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{j as draftAnswer,i as draftFromLens,c as draftSight,m as draftView,b as isDraftFailure,d as judgeLens,e as lensEditOf,g as lensFromSpec,a as mayChangeDeclaration,k as recipeDraft,h as recipeOfLens,n as refineDraft,p as runDraftTool,f as takeBackEditOf,l as templateDraft,o as withReaderLenses};
@@ -1 +1 @@
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 i}from"./chunk.SDO3U72B.js";var m=i(()=>(__graviewPreload(import.meta.url,["./chunk.JO2X52D4.js","./chunk.ZRBGYXAO.js","./chunk.CEQQIW7Z.js","./chunk.KSIEO5W7.js","./chunk.BBLIT7S7.js","./chunk.DQFHIJFN.js","./chunk.BFAFCVL4.js","./chunk.GG47EIKO.js","./chunk.NYLKG25K.js","./chunk.PDDIQ6PK.js","./chunk.3PBTN7RO.js","./chunk.QDVGHI7R.js","./chunk.6P6NGZ6D.js","./chunk.M5FP4Y4Q.js","./chunk.V7W5AQKL.js","./chunk.SDO3U72B.js","./chunk.6HY6ZGEE.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.BMENTGDC.js")));function f(r,s){let e=!1,n=()=>{window.removeEventListener("online",n),e||o()},o=()=>void r().then(d=>{e||s(d)},()=>{e||window.addEventListener("online",n)});return o(),()=>{e=!0,window.removeEventListener("online",n)}}var t;function l(r){t=r}function u(){return t}export{m as a,f as b,l as c,u as d};
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 i}from"./chunk.SDO3U72B.js";var m=i(()=>(__graviewPreload(import.meta.url,["./chunk.JO2X52D4.js","./chunk.ZRBGYXAO.js","./chunk.CEQQIW7Z.js","./chunk.NRURQGXV.js","./chunk.BBLIT7S7.js","./chunk.H6KIEDZN.js","./chunk.264PB572.js","./chunk.GG47EIKO.js","./chunk.NYLKG25K.js","./chunk.G3GFDVO2.js","./chunk.D4WJ7OM5.js","./chunk.QDVGHI7R.js","./chunk.AKJS2NUM.js","./chunk.M5FP4Y4Q.js","./chunk.LP2ZMAT2.js","./chunk.SDO3U72B.js","./chunk.ZEZUKRC6.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.E5PYNAYT.js")));function f(r,s){let e=!1,n=()=>{window.removeEventListener("online",n),e||o()},o=()=>void r().then(d=>{e||s(d)},()=>{e||window.addEventListener("online",n)});return o(),()=>{e=!0,window.removeEventListener("online",n)}}var t;function l(r){t=r}function u(){return t}export{m as a,f as b,l as c,u as d};
@@ -0,0 +1 @@
1
+ import{b as n}from"./chunk.7UHPHEH5.js";import{c as a}from"./chunk.6UQFV53C.js";import"./chunk.GRFD42WM.js";import"./chunk.U5P23GO7.js";import"./chunk.HJUZMOW2.js";import"./chunk.NAXOXBOF.js";import"./chunk.6W6XMLSF.js";import"./chunk.PZ7KY6XH.js";import"./chunk.WEMUKZKH.js";import"./chunk.T27QKVKP.js";import"./chunk.QF5QB5YR.js";import"./chunk.EGPCVMDU.js";import"./chunk.MIE4TJRW.js";import"./chunk.QRQ5WPZI.js";import"./chunk.RD2FSSLV.js";import"./chunk.37RFCHSS.js";import"./chunk.SO6NT5K7.js";import"./chunk.MUSMNKE4.js";import"./chunk.SJQPTDAT.js";import"./chunk.JQ63N4MZ.js";import"./chunk.Z3O2VZAJ.js";import"./chunk.QNP5OR3P.js";import"./chunk.4W57E7AX.js";import{W as i}from"./chunk.A5PSEU3W.js";import"./chunk.SDO3U72B.js";import"./chunk.ZEZUKRC6.js";import"./chunk.FQLNBIQ5.js";import{b as o}from"./chunk.AJZBJBMO.js";var e=o(i(),1);function m({entries:d,style:l,headingStyle:p,className:r}){return(0,e.jsxs)("section",{...r?{className:r}:{},"data-testid":"record-ai","aria-label":"What AI did here",style:{display:"grid",gap:10,...l},children:[(0,e.jsx)("h2",{style:p??{margin:0,fontSize:"1rem"},children:"What AI did here"}),(0,e.jsx)("ol",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:8,fontSize:"0.875rem"},children:d.slice(0,8).map(t=>(0,e.jsx)(n,{entry:t,undo:s=>(0,e.jsx)(a,{batch:s})},t.id))})]})}export{m as RecordInteractions};
@@ -1,4 +1,4 @@
1
- var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{d as C,e as re}from"./chunk.LETAQTLJ.js";import{e as ee}from"./chunk.BUVTUAB5.js";import{a as S}from"./chunk.Z7Y3R3YR.js";import{m as X}from"./chunk.U3HERHAI.js";import{G as se,La as V,Ua as J,W as Z,Ya as Q}from"./chunk.MODLZJD4.js";import{a as K}from"./chunk.SDO3U72B.js";import{T as Y,Z as M,la as U}from"./chunk.6HY6ZGEE.js";import{b as D}from"./chunk.AJZBJBMO.js";var h=D(se(),1);var n=D(Z(),1),Re=9,le=40,ge=2;function de(e){let r=new Map;for(let i of e.allNodes())r.set(i.kind,(r.get(i.kind)??0)+1);return r}var ue=(e,r)=>(e.far??[]).reduce((i,a)=>i+(r.get(a)??0),0);function ce(e,r,i){if(i)return i.flatMap(s=>e.filters.filter(u=>u.key===s));let a=de(r),o=new Set(e.filters.filter(s=>s.about==="edge"&&ue(s,a)>le).map(s=>s.key));return e.filters.filter(s=>s.about==="edge"?!o.has(s.key):s.about==="via"?o.has(s.key.split(".")[0]):!0)}function pe(e,r){let i=e.filter(a=>a.about==="field"&&a.type==="choice"&&(a.options?.length??0)>0);return r?i:i.slice(0,ge)}var fe=520;function ye(e,r,i,a){let o=i.filters.find(s=>s.key===a.key);if(!o)return`${a.key}: ${a.value}`;if(o.about==="is")return a.value.charAt(0).toUpperCase()+a.value.slice(1);if(o.about==="via")return`${o.label}: ${S(e.tryDefinition(o.far?.[0]??""),o.key.split(".")[1],a.value)}`;if(o.about==="edge"){if(a.value==="*")return`${o.label}: anything`;if(a.value==="none")return`${o.label}: nothing`;let s=r.getNode(a.value);return`${o.label}: ${s?U(e.tryDefinition(s.kind),s):a.value}`}if(o.type==="date"){let[s,u]=a.value.split(":");return`${o.label} ${s} ${u?Y(u):""}`.trim()}if(o.type==="boolean")return`${o.label}: ${a.value==="true"?"yes":"no"}`;if(o.type==="number"){let s=a.value.lastIndexOf(":"),u=a.value.slice(0,Math.max(0,s));if(u==="at-most"||u==="at-least")return`${o.label}: ${u==="at-most"?"at most":"at least"} ${S(e.tryDefinition(i.kind),o.key,Number(a.value.slice(s+1)))}`}return o.type==="text"?`${o.label}: ${a.value}`:`${o.label}: ${S(e.tryDefinition(i.kind),o.key,a.value)}`}var P=e=>/^[A-Z][a-z]/.test(e)?e.charAt(0).toLowerCase()+e.slice(1):e;function me(e){return e?.type==="date"?{asc:"Earliest first",desc:"Latest first"}:e?.type==="number"?{asc:"Lowest first",desc:"Highest first"}:e?.type==="boolean"?{asc:"No first",desc:"Yes first"}:e?.type==="choice"?{asc:"In their order",desc:"In reverse order"}:{asc:"A to Z",desc:"Z to A"}}var x=V(K(()=>(__graviewPreload(import.meta.url,["./chunk.FXT5CN32.js","./chunk.WVLEGCRI.js","./chunk.LETAQTLJ.js","./chunk.BUVTUAB5.js","./chunk.WSDJPXJD.js","./chunk.F4VB6Q2W.js","./chunk.FFOD5B4B.js","./chunk.Z7Y3R3YR.js","./chunk.YXEO3Y65.js","./chunk.U3HERHAI.js","./chunk.FBILPNGH.js","./chunk.MODLZJD4.js","./chunk.SDO3U72B.js","./chunk.6HY6ZGEE.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.E3UL4MCD.js")))),N=x.part((e,r)=>(0,n.jsx)(e.ArrangeLists,{...r}),{what:"This list",quiet:!0}),he=x.part((e,r)=>(0,n.jsx)(e.ArrangeChips,{...r}),{what:"This list",quiet:!0}),Oe=()=>x.load(),q=new Map;function Te(e){let{schema:r,graph:i,kind:a,arrangement:o,onChange:s}=e,u=e.offers??ee(r,a),g=e.testId??"arrange",y=C(e.allow,"sort")&&u.sorts.length>1,m=C(e.allow,"group")&&u.groups.length>0,F=C(e.allow,"filter")?ce(u,i,e.filters):[],L=e.chips?pe(F,e.filters):[],H=F.filter(t=>!L.includes(t)),G=H.length>0,_=e.query!==!1&&e.allow!==!1,w=we(e.noun,e.kept),v=e.past&&e.past.count>0?e.past:null;if(!y&&!m&&!G&&!_&&!w&&!v)return null;let z=t=>JSON.stringify(re(t)),R=`${g}|${a}`,p={current:q.get(R)??{words:new Set,latest:null,at:0}};q.set(R,p.current),p.current.latest&&Date.now()-p.current.at>1500&&!p.current.words.has(z(o))&&(p.current={words:new Set,latest:null,at:0},q.set(R,p.current));let d=p.current.latest??o,b=t=>{let l={...p.current.latest??o,...t};for(let c of Object.keys(l))l[c]===void 0&&delete l[c];p.current.latest=l,p.current.at=Date.now(),p.current.words.add(z(l)),s(l)},f=d.filter??[],O=t=>{let l=f.filter((c,I)=>I!==t);b({filter:l.length>0?l:void 0})},A=t=>f.some(l=>l.key===t.key&&l.value===t.value),te=t=>A(t)?O(f.findIndex(l=>l.key===t.key&&l.value===t.value)):b({filter:[...f,t]}),T=d.sort?u.sorts.find(t=>t.key===d.sort.by):void 0,j=d.group?u.groups.find(t=>t.key===d.group.by):void 0,ne=me(T),k={schema:r,graph:i,offers:{...u,filters:H},arrangement:d,set:b,toggle:te,has:A,testId:g},ae=(t,l)=>A({key:t,value:l})?O(f.findIndex(c=>c.key===t&&c.value===l)):b({filter:[...f.filter(c=>c.key!==t),{key:t,value:l}]}),oe=d.sort?(0,n.jsxs)(n.Fragment,{children:["Sorted by ",P(T?.label??d.sort.by),(0,n.jsx)("span",{"aria-hidden":"true",children:d.sort.direction==="desc"?" \u2193":" \u2191"})]}):"Sort",ie=d.group?.bucket&&j?.buckets?`, a ${d.group.bucket} each`:"",B=d.group?`Grouped by ${P(j?.label??d.group.by)}${ie}`:"Group";return(0,n.jsxs)("div",{"data-testid":`${g}-bar`,role:"group","aria-label":"Arrange",className:"graview-arrange",style:e.style,onPointerEnter:x.prefetch,onFocus:x.prefetch,children:[(0,n.jsx)("style",{children:xe}),(0,n.jsxs)("div",{className:"graview-arrange-line",children:[w?(0,n.jsxs)("span",{className:"graview-arrange-count","data-testid":`${g}-count`,children:[w.kept?(0,n.jsx)("span",{"data-testid":`${g}-kept`,children:w.kept}):null,w.words]}):null,v?(0,n.jsxs)("button",{type:"button",className:"graview-arrange-open","data-testid":`${g}-past`,title:`${M(v.count)} more behind the horizon \u2014 press to widen the view to the past`,onClick:t=>{let l=t.currentTarget.closest("[data-graview-view]"),c=t.currentTarget;v.widen();let I=0,W=()=>{if(document.activeElement!==c&&document.activeElement!==document.body&&c.isConnected)return;let $=l?.querySelector('[role="group"][aria-label="Arrange"] :is(button, input)');if($&&$!==c&&$.isConnected)return $.focus({preventScroll:!0});++I<120&&requestAnimationFrame(W)};requestAnimationFrame(W)},children:["+",M(v.count)," past"]}):null,f.map((t,l)=>{let c=ye(r,i,u,t);return(0,n.jsxs)("span",{className:"graview-arrange-token","data-testid":`${g}-condition`,children:[c,(0,n.jsx)("button",{type:"button","aria-label":`Remove: ${c}`,title:"Remove",onClick:()=>O(l),children:"\xD7"})]},`${t.key}:${t.value}`)}),y?(0,n.jsx)("span",{className:"graview-arrange-part graview-arrange-one",children:(0,n.jsx)(E,{testId:`${g}-sort`,value:d.sort?.by??"",set:d.sort!==void 0,label:"Sort",name:d.sort?`Sorted by ${P(T?.label??d.sort.by)}, ${ne[d.sort.direction].toLowerCase()}`:"Sort",list:t=>(0,n.jsx)(N,{which:"sort",done:t,...k}),children:oe})}):null,m?(0,n.jsx)("span",{className:"graview-arrange-part graview-arrange-one",children:(0,n.jsx)(E,{testId:`${g}-group`,value:d.group?.by??"",set:d.group!==void 0,label:"Group",name:B,list:t=>(0,n.jsx)(N,{which:"group",done:t,...k}),children:B})}):null,G?(0,n.jsx)("span",{className:"graview-arrange-part",children:(0,n.jsx)(E,{testId:`${g}-add`,value:"",set:!1,label:"Filter",name:f.length>0?`Filter \u2014 ${f.length} on`:"Filter",list:t=>(0,n.jsx)(N,{which:"filter",done:t,...k}),children:"Filter"})}):null,y||m?(0,n.jsx)("span",{className:"graview-arrange-part graview-arrange-all",children:(0,n.jsx)(E,{testId:`${g}-all`,value:"",set:!1,label:"Arrange",name:"Arrange: sort and group",list:t=>(0,n.jsx)(N,{which:"all",done:t,parts:{sort:y,group:m,filter:!1},...k}),children:"Arrange"})}):null,_?(0,n.jsxs)("label",{className:"graview-arrange-words-at",children:[(0,n.jsx)("span",{style:X,children:"Find"}),(0,n.jsx)("input",{type:"search",className:"graview-arrange-words","data-testid":`${g}-query`,value:d.query??"",placeholder:"Find\u2026",onChange:t=>b({query:t.target.value.length>0?t.target.value:void 0})})]}):null,L.length>0&&e.chips?(0,n.jsx)(h.Suspense,{fallback:null,children:(0,n.jsx)(he,{offers:L,chips:e.chips,schema:r,graph:i,kind:a,arrangement:d,has:A,choose:ae,testId:g})}):null,e.end]})]})}function we(e,r){if(!r)return null;let i=r.shown!==r.of;if(!e)return i?{words:"",kept:`${r.shown} of ${r.of}`}:null;let a=r.of===1?e.one:e.many;return i?{words:` ${a}`,kept:`${r.shown} of ${r.of}`}:{words:`${r.of} ${a}`}}function E({testId:e,value:r,set:i,label:a,name:o,list:s,children:u}){let g=Q("arrange",{align:"start"}),y=(0,h.useRef)(null);return(0,h.useEffect)(()=>{g.open&&y.current?.querySelector('[aria-pressed="true"]')?.focus({preventScroll:!0})},[g.open]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("button",{type:"button",className:"graview-arrange-open","data-testid":e,"data-set":i?"":void 0,value:r,"aria-label":o,...g.trigger,onClick:g.toggle,children:[u,(0,n.jsx)(be,{})]}),g.open?(0,n.jsx)("div",{...g.pane,ref:m=>{g.pane.ref(m),y.current=m},role:"group","aria-label":a,"data-testid":"arrange-list","data-arrange":e,className:"graview-arrange-list",style:J,onKeyDown:ve,children:s(()=>g.setOpen(!1))}):null]})}function ve(e){if(!["ArrowDown","ArrowUp","Home","End"].includes(e.key))return;let r=[...e.currentTarget.querySelectorAll("button:not([disabled]), input")];if(r.length===0)return;let i=r.indexOf(document.activeElement);if(document.activeElement instanceof HTMLInputElement&&document.activeElement.type==="date"&&(e.key==="ArrowUp"||e.key==="ArrowDown"))return;e.preventDefault();let a=e.key==="Home"?0:e.key==="End"?r.length-1:e.key==="ArrowDown"?(i+1)%r.length:(i-1+r.length)%r.length;r[a].focus()}function be(){return(0,n.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 10 10","aria-hidden":"true",focusable:"false",style:{flex:"0 0 auto",opacity:.7},children:(0,n.jsx)("path",{d:"M2 3.5 L5 6.5 L8 3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}var xe=`
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{d as C,e as re}from"./chunk.J6HF7IRQ.js";import{e as ee}from"./chunk.LRNFE3UK.js";import{a as S}from"./chunk.JQ63N4MZ.js";import{m as X}from"./chunk.QNP5OR3P.js";import{G as se,La as V,Ua as J,W as Z,Ya as Q}from"./chunk.A5PSEU3W.js";import{a as K}from"./chunk.SDO3U72B.js";import{T as Y,Z as M,la as U}from"./chunk.ZEZUKRC6.js";import{b as D}from"./chunk.AJZBJBMO.js";var h=D(se(),1);var n=D(Z(),1),Re=9,le=40,ge=2;function de(e){let r=new Map;for(let i of e.allNodes())r.set(i.kind,(r.get(i.kind)??0)+1);return r}var ue=(e,r)=>(e.far??[]).reduce((i,a)=>i+(r.get(a)??0),0);function ce(e,r,i){if(i)return i.flatMap(s=>e.filters.filter(u=>u.key===s));let a=de(r),o=new Set(e.filters.filter(s=>s.about==="edge"&&ue(s,a)>le).map(s=>s.key));return e.filters.filter(s=>s.about==="edge"?!o.has(s.key):s.about==="via"?o.has(s.key.split(".")[0]):!0)}function pe(e,r){let i=e.filter(a=>a.about==="field"&&a.type==="choice"&&(a.options?.length??0)>0);return r?i:i.slice(0,ge)}var fe=520;function ye(e,r,i,a){let o=i.filters.find(s=>s.key===a.key);if(!o)return`${a.key}: ${a.value}`;if(o.about==="is")return a.value.charAt(0).toUpperCase()+a.value.slice(1);if(o.about==="via")return`${o.label}: ${S(e.tryDefinition(o.far?.[0]??""),o.key.split(".")[1],a.value)}`;if(o.about==="edge"){if(a.value==="*")return`${o.label}: anything`;if(a.value==="none")return`${o.label}: nothing`;let s=r.getNode(a.value);return`${o.label}: ${s?U(e.tryDefinition(s.kind),s):a.value}`}if(o.type==="date"){let[s,u]=a.value.split(":");return`${o.label} ${s} ${u?Y(u):""}`.trim()}if(o.type==="boolean")return`${o.label}: ${a.value==="true"?"yes":"no"}`;if(o.type==="number"){let s=a.value.lastIndexOf(":"),u=a.value.slice(0,Math.max(0,s));if(u==="at-most"||u==="at-least")return`${o.label}: ${u==="at-most"?"at most":"at least"} ${S(e.tryDefinition(i.kind),o.key,Number(a.value.slice(s+1)))}`}return o.type==="text"?`${o.label}: ${a.value}`:`${o.label}: ${S(e.tryDefinition(i.kind),o.key,a.value)}`}var P=e=>/^[A-Z][a-z]/.test(e)?e.charAt(0).toLowerCase()+e.slice(1):e;function me(e){return e?.type==="date"?{asc:"Earliest first",desc:"Latest first"}:e?.type==="number"?{asc:"Lowest first",desc:"Highest first"}:e?.type==="boolean"?{asc:"No first",desc:"Yes first"}:e?.type==="choice"?{asc:"In their order",desc:"In reverse order"}:{asc:"A to Z",desc:"Z to A"}}var x=V(K(()=>(__graviewPreload(import.meta.url,["./chunk.5R744JGZ.js","./chunk.O2OL6RQQ.js","./chunk.J6HF7IRQ.js","./chunk.LRNFE3UK.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.BDNQMKDG.js")))),N=x.part((e,r)=>(0,n.jsx)(e.ArrangeLists,{...r}),{what:"This list",quiet:!0}),he=x.part((e,r)=>(0,n.jsx)(e.ArrangeChips,{...r}),{what:"This list",quiet:!0}),Oe=()=>x.load(),q=new Map;function Te(e){let{schema:r,graph:i,kind:a,arrangement:o,onChange:s}=e,u=e.offers??ee(r,a),g=e.testId??"arrange",y=C(e.allow,"sort")&&u.sorts.length>1,m=C(e.allow,"group")&&u.groups.length>0,F=C(e.allow,"filter")?ce(u,i,e.filters):[],L=e.chips?pe(F,e.filters):[],H=F.filter(t=>!L.includes(t)),G=H.length>0,_=e.query!==!1&&e.allow!==!1,w=we(e.noun,e.kept),v=e.past&&e.past.count>0?e.past:null;if(!y&&!m&&!G&&!_&&!w&&!v)return null;let z=t=>JSON.stringify(re(t)),R=`${g}|${a}`,p={current:q.get(R)??{words:new Set,latest:null,at:0}};q.set(R,p.current),p.current.latest&&Date.now()-p.current.at>1500&&!p.current.words.has(z(o))&&(p.current={words:new Set,latest:null,at:0},q.set(R,p.current));let d=p.current.latest??o,b=t=>{let l={...p.current.latest??o,...t};for(let c of Object.keys(l))l[c]===void 0&&delete l[c];p.current.latest=l,p.current.at=Date.now(),p.current.words.add(z(l)),s(l)},f=d.filter??[],O=t=>{let l=f.filter((c,I)=>I!==t);b({filter:l.length>0?l:void 0})},A=t=>f.some(l=>l.key===t.key&&l.value===t.value),te=t=>A(t)?O(f.findIndex(l=>l.key===t.key&&l.value===t.value)):b({filter:[...f,t]}),T=d.sort?u.sorts.find(t=>t.key===d.sort.by):void 0,j=d.group?u.groups.find(t=>t.key===d.group.by):void 0,ne=me(T),k={schema:r,graph:i,offers:{...u,filters:H},arrangement:d,set:b,toggle:te,has:A,testId:g},ae=(t,l)=>A({key:t,value:l})?O(f.findIndex(c=>c.key===t&&c.value===l)):b({filter:[...f.filter(c=>c.key!==t),{key:t,value:l}]}),oe=d.sort?(0,n.jsxs)(n.Fragment,{children:["Sorted by ",P(T?.label??d.sort.by),(0,n.jsx)("span",{"aria-hidden":"true",children:d.sort.direction==="desc"?" \u2193":" \u2191"})]}):"Sort",ie=d.group?.bucket&&j?.buckets?`, a ${d.group.bucket} each`:"",B=d.group?`Grouped by ${P(j?.label??d.group.by)}${ie}`:"Group";return(0,n.jsxs)("div",{"data-testid":`${g}-bar`,role:"group","aria-label":"Arrange",className:"graview-arrange",style:e.style,onPointerEnter:x.prefetch,onFocus:x.prefetch,children:[(0,n.jsx)("style",{children:xe}),(0,n.jsxs)("div",{className:"graview-arrange-line",children:[w?(0,n.jsxs)("span",{className:"graview-arrange-count","data-testid":`${g}-count`,children:[w.kept?(0,n.jsx)("span",{"data-testid":`${g}-kept`,children:w.kept}):null,w.words]}):null,v?(0,n.jsxs)("button",{type:"button",className:"graview-arrange-open","data-testid":`${g}-past`,title:`${M(v.count)} more behind the horizon \u2014 press to widen the view to the past`,onClick:t=>{let l=t.currentTarget.closest("[data-graview-view]"),c=t.currentTarget;v.widen();let I=0,W=()=>{if(document.activeElement!==c&&document.activeElement!==document.body&&c.isConnected)return;let $=l?.querySelector('[role="group"][aria-label="Arrange"] :is(button, input)');if($&&$!==c&&$.isConnected)return $.focus({preventScroll:!0});++I<120&&requestAnimationFrame(W)};requestAnimationFrame(W)},children:["+",M(v.count)," past"]}):null,f.map((t,l)=>{let c=ye(r,i,u,t);return(0,n.jsxs)("span",{className:"graview-arrange-token","data-testid":`${g}-condition`,children:[c,(0,n.jsx)("button",{type:"button","aria-label":`Remove: ${c}`,title:"Remove",onClick:()=>O(l),children:"\xD7"})]},`${t.key}:${t.value}`)}),y?(0,n.jsx)("span",{className:"graview-arrange-part graview-arrange-one",children:(0,n.jsx)(E,{testId:`${g}-sort`,value:d.sort?.by??"",set:d.sort!==void 0,label:"Sort",name:d.sort?`Sorted by ${P(T?.label??d.sort.by)}, ${ne[d.sort.direction].toLowerCase()}`:"Sort",list:t=>(0,n.jsx)(N,{which:"sort",done:t,...k}),children:oe})}):null,m?(0,n.jsx)("span",{className:"graview-arrange-part graview-arrange-one",children:(0,n.jsx)(E,{testId:`${g}-group`,value:d.group?.by??"",set:d.group!==void 0,label:"Group",name:B,list:t=>(0,n.jsx)(N,{which:"group",done:t,...k}),children:B})}):null,G?(0,n.jsx)("span",{className:"graview-arrange-part",children:(0,n.jsx)(E,{testId:`${g}-add`,value:"",set:!1,label:"Filter",name:f.length>0?`Filter \u2014 ${f.length} on`:"Filter",list:t=>(0,n.jsx)(N,{which:"filter",done:t,...k}),children:"Filter"})}):null,y||m?(0,n.jsx)("span",{className:"graview-arrange-part graview-arrange-all",children:(0,n.jsx)(E,{testId:`${g}-all`,value:"",set:!1,label:"Arrange",name:"Arrange: sort and group",list:t=>(0,n.jsx)(N,{which:"all",done:t,parts:{sort:y,group:m,filter:!1},...k}),children:"Arrange"})}):null,_?(0,n.jsxs)("label",{className:"graview-arrange-words-at",children:[(0,n.jsx)("span",{style:X,children:"Find"}),(0,n.jsx)("input",{type:"search",className:"graview-arrange-words","data-testid":`${g}-query`,value:d.query??"",placeholder:"Find\u2026",onChange:t=>b({query:t.target.value.length>0?t.target.value:void 0})})]}):null,L.length>0&&e.chips?(0,n.jsx)(h.Suspense,{fallback:null,children:(0,n.jsx)(he,{offers:L,chips:e.chips,schema:r,graph:i,kind:a,arrangement:d,has:A,choose:ae,testId:g})}):null,e.end]})]})}function we(e,r){if(!r)return null;let i=r.shown!==r.of;if(!e)return i?{words:"",kept:`${r.shown} of ${r.of}`}:null;let a=r.of===1?e.one:e.many;return i?{words:` ${a}`,kept:`${r.shown} of ${r.of}`}:{words:`${r.of} ${a}`}}function E({testId:e,value:r,set:i,label:a,name:o,list:s,children:u}){let g=Q("arrange",{align:"start"}),y=(0,h.useRef)(null);return(0,h.useEffect)(()=>{g.open&&y.current?.querySelector('[aria-pressed="true"]')?.focus({preventScroll:!0})},[g.open]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("button",{type:"button",className:"graview-arrange-open","data-testid":e,"data-set":i?"":void 0,value:r,"aria-label":o,...g.trigger,onClick:g.toggle,children:[u,(0,n.jsx)(be,{})]}),g.open?(0,n.jsx)("div",{...g.pane,ref:m=>{g.pane.ref(m),y.current=m},role:"group","aria-label":a,"data-testid":"arrange-list","data-arrange":e,className:"graview-arrange-list",style:J,onKeyDown:ve,children:s(()=>g.setOpen(!1))}):null]})}function ve(e){if(!["ArrowDown","ArrowUp","Home","End"].includes(e.key))return;let r=[...e.currentTarget.querySelectorAll("button:not([disabled]), input")];if(r.length===0)return;let i=r.indexOf(document.activeElement);if(document.activeElement instanceof HTMLInputElement&&document.activeElement.type==="date"&&(e.key==="ArrowUp"||e.key==="ArrowDown"))return;e.preventDefault();let a=e.key==="Home"?0:e.key==="End"?r.length-1:e.key==="ArrowDown"?(i+1)%r.length:(i-1+r.length)%r.length;r[a].focus()}function be(){return(0,n.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 10 10","aria-hidden":"true",focusable:"false",style:{flex:"0 0 auto",opacity:.7},children:(0,n.jsx)("path",{d:"M2 3.5 L5 6.5 L8 3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}var xe=`
2
2
  .graview-arrange{container-type:inline-size;box-sizing:border-box;width:100%;min-width:0;max-width:100%}
3
3
  .graview-arrange-line{display:flex;flex-wrap:wrap;align-items:center;gap:2px 6px;min-width:0;font-size:.875rem;line-height:1.35;color:var(--graview-ink-muted)}
4
4
  .graview-arrange-count{margin-right:2px;color:var(--graview-ink-muted)}
@@ -1 +1 @@
1
- import{a as h}from"./chunk.YXEO3Y65.js";import{D as g,Da as a,Ga as b,H as k,K as w,cc as x}from"./chunk.6HY6ZGEE.js";var s=i=>i?._zod?.def,O=Symbol.for("@graview/core:collaborative"),v=/^\^\\d\{4\}-\\d\{2\}-\\d\{2\}\$$/;function R(i){let t=s(i),u=!0,f;for(let e=0;t&&e<4;e++){if(t.type==="optional"||t.type==="nullable")u=!1;else if(t.type==="default")u=!1,f=t.defaultValue;else break;t=s(t.innerType)}if(!t)return{why:"it is not a zod field"};let l=g(i),r={...u?{required:!0}:{},...f!==void 0?{default:f}:{},...l?{description:l}:{}},p=(t.checks??[]).map(e=>s(e)),c=a(i);if(c)return{spec:{type:c,...r}};if(b(i))return{spec:{type:"app-link",...r}};let d;for(let e=s(i),n=0;e&&d===void 0&&n<4;e=s(e.innerType),n++)d=e[O];let m=e=>d!==void 0&&d===1!=(e==="text")?{collaborative:d===1}:{};if(h(i))return{spec:{type:"text",format:"markdown",...r,...m("text")}};let y=x(i);if(y)return{spec:{type:y,...r}};switch(t.type){case"string":{let e=t.format;return e==="email"?{spec:{type:"email",...r}}:e==="url"?{spec:{type:"url",...r}}:e==="date"?{spec:{type:"date",...r}}:e==="datetime"||p.some(n=>n?.fn===w)?{spec:{type:"datetime",...r}}:p.some(n=>n?.format==="regex"&&(v.test(String(n?.pattern?.source??""))||n?.pattern?.source===k.source))?{spec:{type:"date",...r}}:{spec:{type:"string",...r,...m("string")}}}case"number":{let e={};for(let n of p){let o=n?.value;typeof o=="number"&&(n?.check==="greater_than"&&n.inclusive?e.min=Math.max(e.min??o,o):n?.check==="less_than"&&n.inclusive?e.max=Math.min(e.max??o,o):n?.check==="multiple_of"&&(e.step=o))}return{spec:{type:p.some(n=>n?.format==="safeint"||n?.format==="int")?"integer":"number",...e,...r}}}case"boolean":return{spec:{type:"boolean",...r}};case"enum":{let e=Object.keys(t.entries??{});return e.length>0?{spec:{type:"enum",options:e,...r}}:{why:"it is an enum with no options"}}case"array":{let e=s(t.element);if(e?.type==="enum"){let o=Object.keys(e.entries??{});return o.length>0?{spec:{type:"enum",multiple:!0,options:o,...r}}:{why:"it is a list of an enum with no options"}}let n=a(t.element)??(e?.type==="number"?"number":e?.type==="string"?"string":void 0);return n?{spec:{type:"list",of:n,...r}}:{why:`it is a list of ${String(e?.type??"something")}, and a document lists words, numbers, dates, images, videos or files`}}default:return{why:`it is a ${String(t.type)}, which a document has no field type for`}}}function T(i){let t=R(i);return"spec"in t?t.spec:void 0}export{T as a};
1
+ import{a as h}from"./chunk.Z3O2VZAJ.js";import{D as g,Da as a,Ga as b,H as k,K as w,cc as x}from"./chunk.ZEZUKRC6.js";var s=i=>i?._zod?.def,O=Symbol.for("@graview/core:collaborative"),v=/^\^\\d\{4\}-\\d\{2\}-\\d\{2\}\$$/;function R(i){let t=s(i),u=!0,f;for(let e=0;t&&e<4;e++){if(t.type==="optional"||t.type==="nullable")u=!1;else if(t.type==="default")u=!1,f=t.defaultValue;else break;t=s(t.innerType)}if(!t)return{why:"it is not a zod field"};let l=g(i),r={...u?{required:!0}:{},...f!==void 0?{default:f}:{},...l?{description:l}:{}},p=(t.checks??[]).map(e=>s(e)),c=a(i);if(c)return{spec:{type:c,...r}};if(b(i))return{spec:{type:"app-link",...r}};let d;for(let e=s(i),n=0;e&&d===void 0&&n<4;e=s(e.innerType),n++)d=e[O];let m=e=>d!==void 0&&d===1!=(e==="text")?{collaborative:d===1}:{};if(h(i))return{spec:{type:"text",format:"markdown",...r,...m("text")}};let y=x(i);if(y)return{spec:{type:y,...r}};switch(t.type){case"string":{let e=t.format;return e==="email"?{spec:{type:"email",...r}}:e==="url"?{spec:{type:"url",...r}}:e==="date"?{spec:{type:"date",...r}}:e==="datetime"||p.some(n=>n?.fn===w)?{spec:{type:"datetime",...r}}:p.some(n=>n?.format==="regex"&&(v.test(String(n?.pattern?.source??""))||n?.pattern?.source===k.source))?{spec:{type:"date",...r}}:{spec:{type:"string",...r,...m("string")}}}case"number":{let e={};for(let n of p){let o=n?.value;typeof o=="number"&&(n?.check==="greater_than"&&n.inclusive?e.min=Math.max(e.min??o,o):n?.check==="less_than"&&n.inclusive?e.max=Math.min(e.max??o,o):n?.check==="multiple_of"&&(e.step=o))}return{spec:{type:p.some(n=>n?.format==="safeint"||n?.format==="int")?"integer":"number",...e,...r}}}case"boolean":return{spec:{type:"boolean",...r}};case"enum":{let e=Object.keys(t.entries??{});return e.length>0?{spec:{type:"enum",options:e,...r}}:{why:"it is an enum with no options"}}case"array":{let e=s(t.element);if(e?.type==="enum"){let o=Object.keys(e.entries??{});return o.length>0?{spec:{type:"enum",multiple:!0,options:o,...r}}:{why:"it is a list of an enum with no options"}}let n=a(t.element)??(e?.type==="number"?"number":e?.type==="string"?"string":void 0);return n?{spec:{type:"list",of:n,...r}}:{why:`it is a list of ${String(e?.type??"something")}, and a document lists words, numbers, dates, images, videos or files`}}default:return{why:`it is a ${String(t.type)}, which a document has no field type for`}}}function T(i){let t=R(i);return"spec"in t?t.spec:void 0}export{T as a};
@@ -1 +1 @@
1
- import{b as kn,c as bn,d as oe,e as wn,f as Y,h as Ee,i as je,n as vn,s as se,u as On}from"./chunk.OEIWIZCP.js";import{B as be,C as ue,Ea as Oe,F as _e,H as He,Ha as en,K as Ue,Ka as nn,L as We,Ma as tn,Nb as U,Qa as xe,Ra as Re,Sb as cn,Tb as ln,Uc as mn,Vb as fn,Xa as rn,_a as on,_b as pn,b as Fe,c as Ne,d as Ce,dc as un,e as K,fd as gn,g as ye,ga as Je,gd as yn,h as Z,ha as Ye,hd as Ae,i as Ie,id as hn,j as Ve,ja as Qe,jd as ze,k as he,kb as an,l as Ke,m as Ze,nb as sn,o as qe,p as fe,q as ve,sb as Se,ta as Xe,tb as dn,v as Be,x as pe,z as ke}from"./chunk.6HY6ZGEE.js";var Tn=[{where:"settings[]",was:"honoured",now:"honored",since:"0.1.16"},{where:"pages",was:"overview",now:"scene",since:"0.1.17"}],q=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function xn(e,d=Tn){if(!q(e))return{document:e,respelled:[]};let n=[],t=e;for(let a of d)t=De(t,a.where.split("."),a,"",n);return{document:t,respelled:n}}function De(e,d,n,t,a){if(d.length===0){if(!q(e)||!Object.hasOwn(e,n.was))return e;a.push(`${t}${n.was}`);let{[n.was]:ie,...B}=e;return Object.hasOwn(e,n.now)?B:{...B,[n.now]:ie}}if(!q(e))return e;let[f,...E]=d,k=f.endsWith("[]"),O=k?f.slice(0,-2):f,G=e[O],X=G;if(!k)X=De(G,E,n,`${t}${O}.`,a);else if(Array.isArray(G)){let ie=G.map((B,T)=>De(B,E,n,`${t}${O}.${T}.`,a));X=ie.some((B,T)=>B!==G[T])?ie:G}return X===G?e:{...e,[O]:X}}var Rn=new WeakMap;function Sn(e,d){Rn.set(e,d)}function Zn(e){return Rn.get(e)}function An(e){if(typeof e=="string")return{form:"string",light:e};if(typeof e!="object"||e===null)return;let d=e,n=k=>typeof d[k]=="string"?d[k]:void 0,t=n("light")??n("src");if(t===void 0)return;let[a,f,E]=[n("dark"),n("alt"),n("darkFallback")];return{form:n("light")!==void 0?"light":"src",light:t,...a!==void 0?{dark:a}:{},...f!==void 0?{alt:f}:{},...E!==void 0?{darkFallback:E}:{}}}function Qn(e,d){let n=e.brand??{},t=n.ground,a=n.accent?ze(n.accent,t):void 0;t&&hn(a?.ok?a.schemes:Ae(t),n.accent)&&(d.push(je("brand","brand.ground","words would not read on that page background, so the app keeps Graview's","pick a lighter ground for the light scheme, a darker one for the dark")),t=void 0,a=n.accent?ze(n.accent):void 0),a&&!a.ok&&d.push(je("brand","brand.accent",`that accent cannot make a readable brand, so the app keeps Graview's colors: ${a.why}`,"pick a color further from orange-red, or a darker one"));let f=An(n.logo),E=n.name??e.name,k=n.typography?Object.fromEntries(Object.entries(n.typography).filter(([,O])=>typeof O=="string"&&yn(O)===null).map(([O,G])=>[O,gn(G)])):void 0;return{name:E,schemes:a?.ok?a.schemes:t?Ae(t):mn,...n.currency?{currency:n.currency}:{},...n.locale?{locale:n.locale}:{},...n.timeZone?{timeZone:n.timeZone}:{},...f?{logo:f.dark||f.darkFallback==="invert"?{light:f.light,...f.dark?{dark:f.dark}:{darkFallback:"invert"}}:f.light,logoAlt:f.alt??E}:{},...n.favicon?{favicon:n.favicon}:{},...e.description?{subtitle:e.description}:{},...n.subtitle===!1?{subtitleDrawn:!1}:{},...k?{typography:k}:{},...n.shape?{shape:n.shape}:{},...n.accents?{accents:n.accents}:{},...n.scheme?{scheme:n.scheme}:{},...n.views&&(n.views.css||n.views.motion)?{views:{...n.views.css?{css:n.views.css}:{},...n.views.motion?{motion:n.views.motion}:{}}}:{}}}function zn(e){let{currency:d,locale:n,timeZone:t}=e.brand??{};return{...d?{currency:d}:{},...n?{locale:n}:{},...t?{timeZone:t}:{}}}var Gn=Symbol.for("@graview/core:typed-field"),En=(e,d)=>(/^(phone|place|duration)$/.test(d)&&(ue(e)[Gn]=d),e),jn=/^(?=(?:\D*\d){3})\+?[\d ()./-]+(?: *(?:ext\.?|x|#) *\d+)?$/i;function Dn(e){let d=Z().check(K(300),ke(t=>nn(t,e)!==void 0,`a record of ${e.kinds.join(" or ")} in ${e.address}, as "<kind>:<id>"`)),n=e.cardinality==="one"?d:fe(d).check(K(200));return tn(e.description?n.check(be(e.description)):n,e)}var Ln="graview-compiled@1";function Fn(e,d){return e.find(([n,t])=>n!==Q&&"ref"in t&&(t.ref==="*"||t.ref.includes(d)))?.[0]}var Q="id",me=e=>typeof e=="string"&&/^\$[A-Za-z][A-Za-z0-9]*$/.test(e)?e.slice(1):void 0;function $n(e){let d=Object.entries(e.fields),n=t=>["name","title","label"].find(a=>t.some(([f])=>f===a))??t[0]?.[0];return n(d.filter(([,t])=>t.required&&(t.type==="string"||t.type==="text")))??n(d.filter(([,t])=>t.type==="string"))}function Pn(e,d,n){let t;switch(e.type){case"string":case"place":t=Z().check(K(500));break;case"phone":t=Z().check(K(40),ye(jn,"a phone number"));break;case"text":t=Z().check(K(2e4)),e.format&&(ue(t)[Symbol.for("@graview/core:markdown")]=1);break;case"number":case"integer":case"duration":{let f=e.min??(e.type==="duration"?0:void 0),E=[...e.type==="number"?[]:[Ke()],...f===void 0?[]:[Ne(f)],...e.max===void 0?[]:[Fe(e.max)],...e.step===void 0?[]:[Ce(e.step)]];t=E.length>0?he().check(...E):he();break}case"boolean":t=Ze();break;case"date":t=Z().check(ye(He,"a date like 2026-10-02, or a month (2016-05) or a year (2006) alone"));break;case"datetime":t=Z().check(ke(Ue,"a date and time like 2026-10-02T14:30:00Z"));break;case"enum":t=Be(e.options),e.multiple&&(t=fe(t).check(K(e.options.length)));break;case"list":t=fe(e.of==="number"?he():e.of==="date"?Z().check(ye(_e)):e.of==="image"||e.of==="video"||e.of==="file"?Oe(e.of):Z().check(K(500))).check(K(200));break;case"image":case"video":case"file":t=Oe(e.type);break;case"app-link":t=en();break;case"url":t=Ve();break;case"email":t=Ie();break}let a=e.type==="number"||e.type==="integer";return En(t,a&&e.format==="duration"?"duration":e.type),e.collaborative!==void 0&&(e.type==="text"||e.type==="string")&&(ue(t)[Symbol.for("@graview/core:collaborative")]=e.collaborative?1:0),e.description&&(t=t.check(be(e.description))),a&&(e.format==="money"||e.format==="percent"||!e.format&&e.unit)&&pn(t,{...n,...e.format?{format:e.format}:{},...e.unit?{unit:e.unit}:{},...e.places===0?{places:0}:{}}),d?pe(t):t}var ge=e=>{throw new U(`there is no record "${e}"`,"invalid")},Nn=(e,d)=>"field"in e?Pn(e.field,e.optional,d):"ref"in e?un(e.ref):pe(qe()),Cn=new WeakMap;var Le=(e,d)=>q(d)&&Object.keys(e??{}).length===Object.keys(d).length&&Object.keys(e??{}).every(n=>Object.hasOwn(d,n));function xt(e,d={}){let n=q(e)?e.format:void 0;if(n!==Ln)return{ok:!1,findings:[Ee("compiled-format","format",n===void 0?"this is not a compiled Graview app":`this compiled app is ${JSON.stringify(n)}, and this build reads ${Ln}`,"compile the document instead")]};let t=e,a=xn(t.document).document,f=a===t.document?t:{...t,document:a},E=q(a)&&typeof a.name=="string"&&q(a.kinds)&&Le(a.kinds,f.kinds)&&Le(a.acts,f.acts)&&Le(a.rules,f.rules)&&Array.isArray(f.edges)&&Array.isArray(f.findings),k={ok:!1,findings:[Ee("compiled-shape","","this compiled app's parts do not match its document","compile the document instead")]};if(!E)return k;try{return In(f,d)}catch{return k}}function In(e,d={}){let{document:n}=e,t=n.brand?.timeZone,a=d.today??(()=>We(t)),f={...n.brand?.locale?{locale:n.brand.locale}:{},...t?{timeZone:t}:{}},E=new Map(e.edges.map(([p,i])=>[p,i])),k=new Map;for(let[p,i]of Object.entries(n.kinds)){let x=e.kinds[p]?.computed,w=Re(i.edges),j=new Map(Object.entries(i.fields).flatMap(([S,v])=>v.type==="enum"?[[S,v.optionLabels??{}]]:[]));k.set(p,{fields:new Set([...Object.keys(i.fields),...w.keys()]),edges:new Map(Object.entries(xe(i.edges)).map(([S,v])=>[S,v.cardinality??"many"])),...x?{computed:new Map(x)}:{},...w.size>0?{linked:w}:{},...j.size>0?{choices:j}:{}})}e.facts&&k.set(bn,{computed:new Map(e.facts)});let O=zn(n),G=p=>({from:p.from,via:p.via,sourceEnd:p.sourceEnd,back:p.back,values(i,x,w){let j={};for(let[S,v]of p.set)if("value"in v)j[S]=v.value;else try{let $=Y(v.expr,{graph:i,subject:x,kinds:k,bindings:{to:w},today:a(),...f});($===null||typeof $!="object"||Array.isArray($))&&(j[S]=$)}catch($){if(!($ instanceof oe))throw $}return j}}),X=new Map,ie=Object.entries(n.kinds).map(([p,i])=>{let x={};for(let[r,o]of Object.entries(i.fields))x[r]=Pn(o,!o.required,O),o.repeats&&(x[rn(r)]=pe(on()));for(let[r,o]of Re(i.edges))x[r]=pe(Dn(o));let{label:w,describe:j,durations:S}=e.kinds[p]??{},v=Object.entries(i.computed??{}).map(([r,o])=>[r,typeof o=="string"?{expr:o}:o]),$=Object.hasOwn(i.fields,"label")&&!i.fields.label.label&&!/\{\s*label\b/.test(i.label??`{${$n(i)??""}}`),ee=Object.fromEntries([...$?[["label","Label"]]:[],...Object.entries(i.fields).filter(([,r])=>r.label).map(([r,o])=>[r,o.label]),...v.filter(([,r])=>r.label).map(([r,o])=>[r,o.label])]),W=Object.keys(ee).length>0,L=Object.entries(i.fields).filter(([,r])=>r.type==="enum"&&(r.optionLabels&&Object.keys(r.optionLabels).length>0||r.multiple)),l=r=>o=>typeof o=="string"&&r.optionLabels&&Object.hasOwn(r.optionLabels,o)?r.optionLabels[o]:Ye(String(o)),M=Object.fromEntries(L.map(([r,o])=>[r,o.multiple?z=>Array.isArray(z)?z.map(l(o)).join(", "):l(o)(z):l(o)])),N=L.length>0,C=Object.fromEntries(Object.entries(i.fields).filter(([,r])=>r.default!==void 0).map(([r,o])=>[r,o.default]));X.set(p,C);let _=Object.fromEntries(Object.entries(xe(i.edges)).map(([r,{renamedFrom:o,...z}])=>[r,z])),I=Object.entries(i.fields).flatMap(([r,o])=>o.aliases?[[r,o.aliases]]:[]),P=r=>i[r]?{[r]:i[r]}:{};return Qe(p,{fields:ve(x),edges:_,...P("plural"),...P("noun"),...P("aliases"),...I.length>0?{fieldAliases:Object.fromEntries(I)}:{},...P("description"),...w?{label:r=>se(w,{node:r,kinds:k,today:a(),money:O})||r.id}:{},...j?{describe:r=>se(j,{node:r,kinds:k,today:a(),money:O})}:{},...P("lifecycle"),...P("figure"),...P("fieldRoles"),...P("people"),archives:i.archives,...i.tidying?{tidying:i.tidying}:{},...v.length>0?{computed:Object.fromEntries(v.map(([r,o])=>[r,Vn(o,S?.includes(r)??!1,O)??i.computed[r]]))}:{},...W||N||i.glance||i.page?{display:{...W?{labels:ee}:{},...N?{format:M}:{},...i.glance?{glance:[...i.glance]}:{},...i.page?{page:i.page}:{}}}:{},...Object.keys(C).length>0?{defaults:C}:{},...e.kinds[p]?.keptInStep?{keptInStep:e.kinds[p].keptInStep}:{},...e.kinds[p]?.derives?{derives:G(e.kinds[p].derives)}:{}})}),B=an(ie,n.computed);function T(p){return B.tryDefinition(p.kind)?.label?.(p)??p.id}let $e=p=>({id:"",kind:p,...X.get(p)}),Pe=[];for(let[p,i]of Object.entries(n.acts??{})){let x=e.acts[p],{title:w,effects:j,guard:S,refusal:v,destructive:$,idempotent:ee,creates:W,connects:L,severs:l,writes:M,writesOther:N,sets:C}=x,_={};for(let c of j)"through"in c&&(_[c.through]=[...new Set([..._[c.through]??[],...Object.keys(c.set)])]);let I=new Map(x.args),P={};for(let[c,A]of I)P[c]=Nn(A,O);let r=[i.on??[]].flat(),o=new Map(x.exprs),z=j.find(c=>"create"in c),J=(c,A,u,b=null)=>{if(q(c)&&"expr"in c)return Y(o.get(c.expr),{graph:u,subject:b,kinds:k,bindings:A,today:a(),...f});let h=me(c);return h===void 0?typeof c=="string"&&c.startsWith("$$")?c.slice(1):c:h==="now"?new Date().toISOString():h==="today"?a():A[h]},de=(c,A)=>{if(!z)return"";let u=n.kinds[z.create].fields,b=$e(z.create),h=[];for(let[R,ce]of Object.entries(z.set??{})){try{b[R]=J(ce,c,A)??b[R]}catch{}let ae=me(ce);ae&&c[ae]!==void 0&&h.push(R)}let V=T(b).trim(),ne=h.filter(R=>b[R]!==!1&&u[R].type!=="text"&&!(/[^]{41}/.test(b[R])||/ .*[.!?]$/.test(b[R])&&!/[ .][A-Z]\w{0,3}\.$/.test(b[R]))&&T({...b,[R]:void 0}).trim()===V).map(R=>b[R]===!0?u[R].label??Je(R):vn(b[R],u[R].format,a(),[],O));return V&&ne.length>0?`${V} (${ne.join(", ")})`:V};Pe.push(fn(p,{input:ve(P),title:w,...i.description?{description:i.description}:{},...i.fromTheOtherEnd?{fromTheOtherEnd:i.fromTheOtherEnd}:{},...I.has(Q)?{subject:{kinds:r.length>0?r:"*",arg:Q}}:{},...$?{destructive:!0}:{},...ee?{idempotent:!0}:{},...W.length>0?{creates:W}:{},...L.length>0?{connects:L}:{},...l.length>0?{severs:l}:{},writes:M,...Object.keys(N).length>0?{writesOther:N}:{},...Object.keys(_).length>0?{writesLinked:_}:{},...Object.keys(C).length>0?{sets:C}:{},...S?{allowedOn:(c,A)=>{let u=c.getNode(A);if(!u||r.length>0&&!r.includes(u.kind))return!1;try{return Y(S,{graph:c,subject:u,kinds:k,bindings:{},today:a(),...f})===!0}catch{return!1}}}:{},describe:(c,A)=>{let u=typeof c[Q]=="string"?A.getNode(c[Q]):void 0,b=u?T(u):de(c,A);return b?`${w}: ${b}`:w},apply(c,A){let u=c.graph,b=typeof A[Q]=="string"?A[Q]:void 0,h=b?u.getNode(b):void 0;if(b&&!h&&ge(b),h&&r.length>0&&!r.includes(h.kind))throw new U(`"${w}" acts on ${r.join(" or ")}, not on ${Xe(h.kind)}`,"invalid");let V={};for(let[s,m]of Object.entries(A))m!==void 0&&(V[s]=m);if(S&&h){let s;try{s=Y(S,{graph:u,subject:h,kinds:k,bindings:V,today:a(),...f})}catch(m){throw m instanceof oe?new U(`"${w}" could not be judged: ${m.sentence}`):m}if(s!==!0)throw new U(v?se(v,{node:h,kinds:k,graph:u,bindings:V,today:a(),money:O}):`"${w}" is not allowed for ${T(h)} right now`)}let ne=new Map,R=s=>u.has(s)||[...ne.values()].includes(s),ce=new Set,ae=s=>{let m=sn(s);ce.has(m)||(ce.add(m),c.removeEdge(s))},te=(s,m)=>{let g=me(s);if(g==="subject")return b;if(g==="me"){let y=c.me;if(y&&n.kinds[u.getNode(y)?.kind]?.people)return y;throw new U(`"${w}" is done as you, and you have no record here`)}if(ne.has(g))return ne.get(g);try{return J(s,V,u,m??h??null)}catch(y){throw y instanceof oe?new U(`"${w}" could not work out a value: ${y.sentence}`):y}};for(let s of j)if("create"in s){let m=n.kinds[s.create],g=$e(s.create);for(let[H,re]of Object.entries(s.set??{})){let Me=te(re,void 0);Me!==void 0&&(g[H]=Me)}let y=$n(m),D=String((y&&g[y])??s.create),le=ln(D,s.create,g,(H,re)=>cn(n.policy?.sees,H,re)),F=c.freshId(le?s.create:D,s.create,g);c.addNode({...g,id:F}),s.as&&ne.set(s.as,F)}else if("connect"in s||"sever"in s){let m="connect"in s?s.connect:s.sever,g=String(te(s.from,void 0)??""),y=String(te(s.to,void 0)??"");if(R(g)||ge(g),R(y)||ge(y),"connect"in s){if(E.get(m)?.cardinality==="one")for(let D of u.out(g,m))D.id!==y&&ae({kind:m,from:g,to:D.id});u.out(g,m).some(D=>D.id===y)||c.addEdge({kind:m,from:g,to:y})}else ae({kind:m,from:g,to:y})}else if("through"in s){if(!h)throw new U(`"${w}" carries a change to linked records, and has no record to start from`,"invalid");let g=E.get(s.through)?.from.includes(h.kind)??!0?u.out(h.id,s.through):u.in(h.id,s.through);for(let y of g){let D={};for(let[le,F]of Object.entries(s.set)){let H;if(me(F)==="to")H=y.id;else if(q(F)&&"expr"in F)try{H=Y(o.get(F.expr),{graph:u,subject:h,kinds:k,bindings:{...V,to:y},today:a(),...f})}catch(re){throw re instanceof oe?new U(`"${w}" could not work out a value for ${T(y)}: ${re.sentence}`):re}else H=te(F,void 0);H!==void 0&&(D[le]=H)}Object.keys(D).length>0&&c.patchNode(y.id,D)}}else if("set"in s){let m=String(te(s.target??"$subject",void 0)??""),g=u.getNode(m);!g&&!R(m)&&ge(m);let y={};for(let[D,le]of Object.entries(s.set)){let F=te(le,g);F!==void 0&&(y[D]=F)}Object.keys(y).length>0&&c.patchNode(m,y)}else if("remove"in s){let m=String(te(s.remove,void 0)??"");u.has(m)||ge(m),c.removeNode(m)}else if("replace"in s&&h){let m=A.to;for(let g of s.replace){let y=E.get(g)?.from.includes(h.kind)??!0;for(let D of y?u.out(h.id,g):u.in(h.id,g))g===s.keep&&D.id===m||ae(y?{kind:g,from:h.id,to:D.id}:{kind:g,from:D.id,to:h.id})}}}}))}let Te=[];for(let[p,i]of Object.entries(n.rules??{})){let{title:x,require:w,when:j,says:S,covers:v}=e.rules[p],$=i.repairs??[],ee=(L,l,M=a(),N)=>{let C=[],_={graph:L,subject:l,kinds:k,today:M,...f,...N?{linked:N}:{},onUnread:o=>C.push(o)},I,P=[];try{if(j&&Y(j,_)!==!0)return[];if(v&&l?(P=On(L,l,v),I=P.length===0):I=Y(w,_)===!0,!I&&C.length>0)throw new oe(`it reads ${kn(C[0])}`,0)}catch(o){throw o instanceof wn?new dn(o.sentence):o instanceof oe?new Error(o.sentence):o}if(I)return[];let r=$.flatMap(o=>{let z=n.acts?.[o.act],J={},de=l&&z?.on&&z.fromTheOtherEnd&&![z.on].flat().includes(l.kind)?Fn(e.acts[o.act].args,l.kind):void 0;de?J[de]=l.id:l&&(z?.on||/^(edit|remove|archive|unarchive|merge|skip|detach|split)-/.test(o.act))&&(J[Q]=l.id);for(let[u,b]of Object.entries(o.args??{}))J[u]=me(b)==="subject"?l?.id:b;let A=(z?e.acts[o.act].args:[]).filter(([u,b])=>b.required&&J[u]===void 0).map(([u])=>u);return[{mutation:o.act,label:o.label??(de?z.fromTheOtherEnd:z?.title)??o.act.replace(/-/g," "),args:J,...A.length>0?{missing:A}:{}}]});return v&&l?P.map(o=>({invariant:p,subjectId:l.id,label:x,message:S?se(S,{node:l,kinds:k,graph:L,today:M,money:O,bindings:{[l.kind]:l,[o.kind]:o}}):`${T(l)}: ${x} \u2014 ${T(o)}`,nodeIds:[l.id,o.id],repairs:r})):[{invariant:p,...l?{subjectId:l.id}:{},label:x,message:S?se(S,{node:l,kinds:k,graph:L,today:M,money:O}):l?`${T(l)}: ${x}`:x,nodeIds:l?[l.id]:[],repairs:r}]},W={label:x,shape:{over:i.over,require:w,...v?{covers:v}:{},when:j,says:S,declared:n.kinds,money:O,kinds:k,today:a},judgment:{...i.require?{require:i.require}:{},...i.covers?{covers:i.covers}:{},...i.when?{when:i.when}:{},...i.says?{says:i.says}:{}},...i.description?{description:i.description}:{},...$.length>0?{repairs:$.map(L=>L.act)}:{}};Te.push(i.over==="graph"?Se(p,{scope:"graph",...W,evaluate:({graph:L,today:l,context:M})=>ee(L,null,l,M?.linked)}):Se(p,{scope:{kind:i.over},...W,evaluate:({graph:L,subject:l,today:M,context:N})=>ee(L,l,M,N?.linked)}))}let Ge=n.policy&&{...n.policy,...n.roles?{roles:n.roles}:{}},we={name:n.name,schema:B,mutations:Pe,invariants:Te,...Ge?{policy:Ge}:{},...e.brand?{brand:e.brand}:{},...n.modules?{modules:n.modules}:{},...n.lenses?{lenses:n.lenses}:{},...n.pages?{pages:n.pages}:{},...n.settings?{settings:n.settings}:{},...n.connections?{connections:n.connections}:{},...n.forms?{forms:n.forms}:{},...n.publishing?{publishing:n.publishing}:{},...n.tidying?{tidying:n.tidying}:{},...n.purpose?{purpose:n.purpose}:{},...e.viewSpecs?{viewSpecs:e.viewSpecs}:{},...e.home?{home:e.home}:{},version:n.version??1};return Sn(we,n),Cn.set(we,e),{ok:!0,app:we,document:n,findings:e.findings,sights:n.policy?.sees,kinds:k}}function Vn(e,d,n){let t=d||e.format==="duration",a=e.format==="money"||e.format==="percent"||!e.format&&e.unit!==void 0;if(!(!t&&!a))return{...e,...t?{as:"duration"}:{},...a?{amount:{...n,...e.format?{format:e.format}:{},...e.unit?{unit:e.unit}:{},...e.places===0?{places:0}:{}}}:{}}}export{q as a,xn as b,Zn as c,Qn as d,Ln as e,Q as f,me as g,$n as h,xt as i,In as j};
1
+ import{b as kn,c as bn,d as oe,e as wn,f as Y,h as Ee,i as je,n as vn,s as se,u as On}from"./chunk.RG5G6YQD.js";import{B as be,C as ue,Ea as Oe,F as _e,H as He,Ha as en,K as Ue,Ka as nn,L as We,Ma as tn,Nb as U,Qa as xe,Ra as Re,Sb as cn,Tb as ln,Uc as mn,Vb as fn,Xa as rn,_a as on,_b as pn,b as Fe,c as Ne,d as Ce,dc as un,e as K,fd as gn,g as ye,ga as Je,gd as yn,h as Z,ha as Ye,hd as Ae,i as Ie,id as hn,j as Ve,ja as Qe,jd as ze,k as he,kb as an,l as Ke,m as Ze,nb as sn,o as qe,p as fe,q as ve,sb as Se,ta as Xe,tb as dn,v as Be,x as pe,z as ke}from"./chunk.ZEZUKRC6.js";var Tn=[{where:"settings[]",was:"honoured",now:"honored",since:"0.1.16"},{where:"pages",was:"overview",now:"scene",since:"0.1.17"}],q=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function xn(e,d=Tn){if(!q(e))return{document:e,respelled:[]};let n=[],t=e;for(let a of d)t=De(t,a.where.split("."),a,"",n);return{document:t,respelled:n}}function De(e,d,n,t,a){if(d.length===0){if(!q(e)||!Object.hasOwn(e,n.was))return e;a.push(`${t}${n.was}`);let{[n.was]:ie,...B}=e;return Object.hasOwn(e,n.now)?B:{...B,[n.now]:ie}}if(!q(e))return e;let[f,...E]=d,k=f.endsWith("[]"),O=k?f.slice(0,-2):f,G=e[O],X=G;if(!k)X=De(G,E,n,`${t}${O}.`,a);else if(Array.isArray(G)){let ie=G.map((B,T)=>De(B,E,n,`${t}${O}.${T}.`,a));X=ie.some((B,T)=>B!==G[T])?ie:G}return X===G?e:{...e,[O]:X}}var Rn=new WeakMap;function Sn(e,d){Rn.set(e,d)}function Zn(e){return Rn.get(e)}function An(e){if(typeof e=="string")return{form:"string",light:e};if(typeof e!="object"||e===null)return;let d=e,n=k=>typeof d[k]=="string"?d[k]:void 0,t=n("light")??n("src");if(t===void 0)return;let[a,f,E]=[n("dark"),n("alt"),n("darkFallback")];return{form:n("light")!==void 0?"light":"src",light:t,...a!==void 0?{dark:a}:{},...f!==void 0?{alt:f}:{},...E!==void 0?{darkFallback:E}:{}}}function Qn(e,d){let n=e.brand??{},t=n.ground,a=n.accent?ze(n.accent,t):void 0;t&&hn(a?.ok?a.schemes:Ae(t),n.accent)&&(d.push(je("brand","brand.ground","words would not read on that page background, so the app keeps Graview's","pick a lighter ground for the light scheme, a darker one for the dark")),t=void 0,a=n.accent?ze(n.accent):void 0),a&&!a.ok&&d.push(je("brand","brand.accent",`that accent cannot make a readable brand, so the app keeps Graview's colors: ${a.why}`,"pick a color further from orange-red, or a darker one"));let f=An(n.logo),E=n.name??e.name,k=n.typography?Object.fromEntries(Object.entries(n.typography).filter(([,O])=>typeof O=="string"&&yn(O)===null).map(([O,G])=>[O,gn(G)])):void 0;return{name:E,schemes:a?.ok?a.schemes:t?Ae(t):mn,...n.currency?{currency:n.currency}:{},...n.locale?{locale:n.locale}:{},...n.timeZone?{timeZone:n.timeZone}:{},...f?{logo:f.dark||f.darkFallback==="invert"?{light:f.light,...f.dark?{dark:f.dark}:{darkFallback:"invert"}}:f.light,logoAlt:f.alt??E}:{},...n.favicon?{favicon:n.favicon}:{},...e.description?{subtitle:e.description}:{},...n.subtitle===!1?{subtitleDrawn:!1}:{},...k?{typography:k}:{},...n.shape?{shape:n.shape}:{},...n.accents?{accents:n.accents}:{},...n.scheme?{scheme:n.scheme}:{},...n.views&&(n.views.css||n.views.motion)?{views:{...n.views.css?{css:n.views.css}:{},...n.views.motion?{motion:n.views.motion}:{}}}:{}}}function zn(e){let{currency:d,locale:n,timeZone:t}=e.brand??{};return{...d?{currency:d}:{},...n?{locale:n}:{},...t?{timeZone:t}:{}}}var Gn=Symbol.for("@graview/core:typed-field"),En=(e,d)=>(/^(phone|place|duration)$/.test(d)&&(ue(e)[Gn]=d),e),jn=/^(?=(?:\D*\d){3})\+?[\d ()./-]+(?: *(?:ext\.?|x|#) *\d+)?$/i;function Dn(e){let d=Z().check(K(300),ke(t=>nn(t,e)!==void 0,`a record of ${e.kinds.join(" or ")} in ${e.address}, as "<kind>:<id>"`)),n=e.cardinality==="one"?d:fe(d).check(K(200));return tn(e.description?n.check(be(e.description)):n,e)}var Ln="graview-compiled@1";function Fn(e,d){return e.find(([n,t])=>n!==Q&&"ref"in t&&(t.ref==="*"||t.ref.includes(d)))?.[0]}var Q="id",me=e=>typeof e=="string"&&/^\$[A-Za-z][A-Za-z0-9]*$/.test(e)?e.slice(1):void 0;function $n(e){let d=Object.entries(e.fields),n=t=>["name","title","label"].find(a=>t.some(([f])=>f===a))??t[0]?.[0];return n(d.filter(([,t])=>t.required&&(t.type==="string"||t.type==="text")))??n(d.filter(([,t])=>t.type==="string"))}function Pn(e,d,n){let t;switch(e.type){case"string":case"place":t=Z().check(K(500));break;case"phone":t=Z().check(K(40),ye(jn,"a phone number"));break;case"text":t=Z().check(K(2e4)),e.format&&(ue(t)[Symbol.for("@graview/core:markdown")]=1);break;case"number":case"integer":case"duration":{let f=e.min??(e.type==="duration"?0:void 0),E=[...e.type==="number"?[]:[Ke()],...f===void 0?[]:[Ne(f)],...e.max===void 0?[]:[Fe(e.max)],...e.step===void 0?[]:[Ce(e.step)]];t=E.length>0?he().check(...E):he();break}case"boolean":t=Ze();break;case"date":t=Z().check(ye(He,"a date like 2026-10-02, or a month (2016-05) or a year (2006) alone"));break;case"datetime":t=Z().check(ke(Ue,"a date and time like 2026-10-02T14:30:00Z"));break;case"enum":t=Be(e.options),e.multiple&&(t=fe(t).check(K(e.options.length)));break;case"list":t=fe(e.of==="number"?he():e.of==="date"?Z().check(ye(_e)):e.of==="image"||e.of==="video"||e.of==="file"?Oe(e.of):Z().check(K(500))).check(K(200));break;case"image":case"video":case"file":t=Oe(e.type);break;case"app-link":t=en();break;case"url":t=Ve();break;case"email":t=Ie();break}let a=e.type==="number"||e.type==="integer";return En(t,a&&e.format==="duration"?"duration":e.type),e.collaborative!==void 0&&(e.type==="text"||e.type==="string")&&(ue(t)[Symbol.for("@graview/core:collaborative")]=e.collaborative?1:0),e.description&&(t=t.check(be(e.description))),a&&(e.format==="money"||e.format==="percent"||!e.format&&e.unit)&&pn(t,{...n,...e.format?{format:e.format}:{},...e.unit?{unit:e.unit}:{},...e.places===0?{places:0}:{}}),d?pe(t):t}var ge=e=>{throw new U(`there is no record "${e}"`,"invalid")},Nn=(e,d)=>"field"in e?Pn(e.field,e.optional,d):"ref"in e?un(e.ref):pe(qe()),Cn=new WeakMap;var Le=(e,d)=>q(d)&&Object.keys(e??{}).length===Object.keys(d).length&&Object.keys(e??{}).every(n=>Object.hasOwn(d,n));function xt(e,d={}){let n=q(e)?e.format:void 0;if(n!==Ln)return{ok:!1,findings:[Ee("compiled-format","format",n===void 0?"this is not a compiled Graview app":`this compiled app is ${JSON.stringify(n)}, and this build reads ${Ln}`,"compile the document instead")]};let t=e,a=xn(t.document).document,f=a===t.document?t:{...t,document:a},E=q(a)&&typeof a.name=="string"&&q(a.kinds)&&Le(a.kinds,f.kinds)&&Le(a.acts,f.acts)&&Le(a.rules,f.rules)&&Array.isArray(f.edges)&&Array.isArray(f.findings),k={ok:!1,findings:[Ee("compiled-shape","","this compiled app's parts do not match its document","compile the document instead")]};if(!E)return k;try{return In(f,d)}catch{return k}}function In(e,d={}){let{document:n}=e,t=n.brand?.timeZone,a=d.today??(()=>We(t)),f={...n.brand?.locale?{locale:n.brand.locale}:{},...t?{timeZone:t}:{}},E=new Map(e.edges.map(([p,i])=>[p,i])),k=new Map;for(let[p,i]of Object.entries(n.kinds)){let x=e.kinds[p]?.computed,w=Re(i.edges),j=new Map(Object.entries(i.fields).flatMap(([S,v])=>v.type==="enum"?[[S,v.optionLabels??{}]]:[]));k.set(p,{fields:new Set([...Object.keys(i.fields),...w.keys()]),edges:new Map(Object.entries(xe(i.edges)).map(([S,v])=>[S,v.cardinality??"many"])),...x?{computed:new Map(x)}:{},...w.size>0?{linked:w}:{},...j.size>0?{choices:j}:{}})}e.facts&&k.set(bn,{computed:new Map(e.facts)});let O=zn(n),G=p=>({from:p.from,via:p.via,sourceEnd:p.sourceEnd,back:p.back,values(i,x,w){let j={};for(let[S,v]of p.set)if("value"in v)j[S]=v.value;else try{let $=Y(v.expr,{graph:i,subject:x,kinds:k,bindings:{to:w},today:a(),...f});($===null||typeof $!="object"||Array.isArray($))&&(j[S]=$)}catch($){if(!($ instanceof oe))throw $}return j}}),X=new Map,ie=Object.entries(n.kinds).map(([p,i])=>{let x={};for(let[r,o]of Object.entries(i.fields))x[r]=Pn(o,!o.required,O),o.repeats&&(x[rn(r)]=pe(on()));for(let[r,o]of Re(i.edges))x[r]=pe(Dn(o));let{label:w,describe:j,durations:S}=e.kinds[p]??{},v=Object.entries(i.computed??{}).map(([r,o])=>[r,typeof o=="string"?{expr:o}:o]),$=Object.hasOwn(i.fields,"label")&&!i.fields.label.label&&!/\{\s*label\b/.test(i.label??`{${$n(i)??""}}`),ee=Object.fromEntries([...$?[["label","Label"]]:[],...Object.entries(i.fields).filter(([,r])=>r.label).map(([r,o])=>[r,o.label]),...v.filter(([,r])=>r.label).map(([r,o])=>[r,o.label])]),W=Object.keys(ee).length>0,L=Object.entries(i.fields).filter(([,r])=>r.type==="enum"&&(r.optionLabels&&Object.keys(r.optionLabels).length>0||r.multiple)),l=r=>o=>typeof o=="string"&&r.optionLabels&&Object.hasOwn(r.optionLabels,o)?r.optionLabels[o]:Ye(String(o)),M=Object.fromEntries(L.map(([r,o])=>[r,o.multiple?z=>Array.isArray(z)?z.map(l(o)).join(", "):l(o)(z):l(o)])),N=L.length>0,C=Object.fromEntries(Object.entries(i.fields).filter(([,r])=>r.default!==void 0).map(([r,o])=>[r,o.default]));X.set(p,C);let _=Object.fromEntries(Object.entries(xe(i.edges)).map(([r,{renamedFrom:o,...z}])=>[r,z])),I=Object.entries(i.fields).flatMap(([r,o])=>o.aliases?[[r,o.aliases]]:[]),P=r=>i[r]?{[r]:i[r]}:{};return Qe(p,{fields:ve(x),edges:_,...P("plural"),...P("noun"),...P("aliases"),...I.length>0?{fieldAliases:Object.fromEntries(I)}:{},...P("description"),...w?{label:r=>se(w,{node:r,kinds:k,today:a(),money:O})||r.id}:{},...j?{describe:r=>se(j,{node:r,kinds:k,today:a(),money:O})}:{},...P("lifecycle"),...P("figure"),...P("fieldRoles"),...P("people"),archives:i.archives,...i.tidying?{tidying:i.tidying}:{},...v.length>0?{computed:Object.fromEntries(v.map(([r,o])=>[r,Vn(o,S?.includes(r)??!1,O)??i.computed[r]]))}:{},...W||N||i.glance||i.page?{display:{...W?{labels:ee}:{},...N?{format:M}:{},...i.glance?{glance:[...i.glance]}:{},...i.page?{page:i.page}:{}}}:{},...Object.keys(C).length>0?{defaults:C}:{},...e.kinds[p]?.keptInStep?{keptInStep:e.kinds[p].keptInStep}:{},...e.kinds[p]?.derives?{derives:G(e.kinds[p].derives)}:{}})}),B=an(ie,n.computed);function T(p){return B.tryDefinition(p.kind)?.label?.(p)??p.id}let $e=p=>({id:"",kind:p,...X.get(p)}),Pe=[];for(let[p,i]of Object.entries(n.acts??{})){let x=e.acts[p],{title:w,effects:j,guard:S,refusal:v,destructive:$,idempotent:ee,creates:W,connects:L,severs:l,writes:M,writesOther:N,sets:C}=x,_={};for(let c of j)"through"in c&&(_[c.through]=[...new Set([..._[c.through]??[],...Object.keys(c.set)])]);let I=new Map(x.args),P={};for(let[c,A]of I)P[c]=Nn(A,O);let r=[i.on??[]].flat(),o=new Map(x.exprs),z=j.find(c=>"create"in c),J=(c,A,u,b=null)=>{if(q(c)&&"expr"in c)return Y(o.get(c.expr),{graph:u,subject:b,kinds:k,bindings:A,today:a(),...f});let h=me(c);return h===void 0?typeof c=="string"&&c.startsWith("$$")?c.slice(1):c:h==="now"?new Date().toISOString():h==="today"?a():A[h]},de=(c,A)=>{if(!z)return"";let u=n.kinds[z.create].fields,b=$e(z.create),h=[];for(let[R,ce]of Object.entries(z.set??{})){try{b[R]=J(ce,c,A)??b[R]}catch{}let ae=me(ce);ae&&c[ae]!==void 0&&h.push(R)}let V=T(b).trim(),ne=h.filter(R=>b[R]!==!1&&u[R].type!=="text"&&!(/[^]{41}/.test(b[R])||/ .*[.!?]$/.test(b[R])&&!/[ .][A-Z]\w{0,3}\.$/.test(b[R]))&&T({...b,[R]:void 0}).trim()===V).map(R=>b[R]===!0?u[R].label??Je(R):vn(b[R],u[R].format,a(),[],O));return V&&ne.length>0?`${V} (${ne.join(", ")})`:V};Pe.push(fn(p,{input:ve(P),title:w,...i.description?{description:i.description}:{},...i.fromTheOtherEnd?{fromTheOtherEnd:i.fromTheOtherEnd}:{},...I.has(Q)?{subject:{kinds:r.length>0?r:"*",arg:Q}}:{},...$?{destructive:!0}:{},...ee?{idempotent:!0}:{},...W.length>0?{creates:W}:{},...L.length>0?{connects:L}:{},...l.length>0?{severs:l}:{},writes:M,...Object.keys(N).length>0?{writesOther:N}:{},...Object.keys(_).length>0?{writesLinked:_}:{},...Object.keys(C).length>0?{sets:C}:{},...S?{allowedOn:(c,A)=>{let u=c.getNode(A);if(!u||r.length>0&&!r.includes(u.kind))return!1;try{return Y(S,{graph:c,subject:u,kinds:k,bindings:{},today:a(),...f})===!0}catch{return!1}}}:{},describe:(c,A)=>{let u=typeof c[Q]=="string"?A.getNode(c[Q]):void 0,b=u?T(u):de(c,A);return b?`${w}: ${b}`:w},apply(c,A){let u=c.graph,b=typeof A[Q]=="string"?A[Q]:void 0,h=b?u.getNode(b):void 0;if(b&&!h&&ge(b),h&&r.length>0&&!r.includes(h.kind))throw new U(`"${w}" acts on ${r.join(" or ")}, not on ${Xe(h.kind)}`,"invalid");let V={};for(let[s,m]of Object.entries(A))m!==void 0&&(V[s]=m);if(S&&h){let s;try{s=Y(S,{graph:u,subject:h,kinds:k,bindings:V,today:a(),...f})}catch(m){throw m instanceof oe?new U(`"${w}" could not be judged: ${m.sentence}`):m}if(s!==!0)throw new U(v?se(v,{node:h,kinds:k,graph:u,bindings:V,today:a(),money:O}):`"${w}" is not allowed for ${T(h)} right now`)}let ne=new Map,R=s=>u.has(s)||[...ne.values()].includes(s),ce=new Set,ae=s=>{let m=sn(s);ce.has(m)||(ce.add(m),c.removeEdge(s))},te=(s,m)=>{let g=me(s);if(g==="subject")return b;if(g==="me"){let y=c.me;if(y&&n.kinds[u.getNode(y)?.kind]?.people)return y;throw new U(`"${w}" is done as you, and you have no record here`)}if(ne.has(g))return ne.get(g);try{return J(s,V,u,m??h??null)}catch(y){throw y instanceof oe?new U(`"${w}" could not work out a value: ${y.sentence}`):y}};for(let s of j)if("create"in s){let m=n.kinds[s.create],g=$e(s.create);for(let[H,re]of Object.entries(s.set??{})){let Me=te(re,void 0);Me!==void 0&&(g[H]=Me)}let y=$n(m),D=String((y&&g[y])??s.create),le=ln(D,s.create,g,(H,re)=>cn(n.policy?.sees,H,re)),F=c.freshId(le?s.create:D,s.create,g);c.addNode({...g,id:F}),s.as&&ne.set(s.as,F)}else if("connect"in s||"sever"in s){let m="connect"in s?s.connect:s.sever,g=String(te(s.from,void 0)??""),y=String(te(s.to,void 0)??"");if(R(g)||ge(g),R(y)||ge(y),"connect"in s){if(E.get(m)?.cardinality==="one")for(let D of u.out(g,m))D.id!==y&&ae({kind:m,from:g,to:D.id});u.out(g,m).some(D=>D.id===y)||c.addEdge({kind:m,from:g,to:y})}else ae({kind:m,from:g,to:y})}else if("through"in s){if(!h)throw new U(`"${w}" carries a change to linked records, and has no record to start from`,"invalid");let g=E.get(s.through)?.from.includes(h.kind)??!0?u.out(h.id,s.through):u.in(h.id,s.through);for(let y of g){let D={};for(let[le,F]of Object.entries(s.set)){let H;if(me(F)==="to")H=y.id;else if(q(F)&&"expr"in F)try{H=Y(o.get(F.expr),{graph:u,subject:h,kinds:k,bindings:{...V,to:y},today:a(),...f})}catch(re){throw re instanceof oe?new U(`"${w}" could not work out a value for ${T(y)}: ${re.sentence}`):re}else H=te(F,void 0);H!==void 0&&(D[le]=H)}Object.keys(D).length>0&&c.patchNode(y.id,D)}}else if("set"in s){let m=String(te(s.target??"$subject",void 0)??""),g=u.getNode(m);!g&&!R(m)&&ge(m);let y={};for(let[D,le]of Object.entries(s.set)){let F=te(le,g);F!==void 0&&(y[D]=F)}Object.keys(y).length>0&&c.patchNode(m,y)}else if("remove"in s){let m=String(te(s.remove,void 0)??"");u.has(m)||ge(m),c.removeNode(m)}else if("replace"in s&&h){let m=A.to;for(let g of s.replace){let y=E.get(g)?.from.includes(h.kind)??!0;for(let D of y?u.out(h.id,g):u.in(h.id,g))g===s.keep&&D.id===m||ae(y?{kind:g,from:h.id,to:D.id}:{kind:g,from:D.id,to:h.id})}}}}))}let Te=[];for(let[p,i]of Object.entries(n.rules??{})){let{title:x,require:w,when:j,says:S,covers:v}=e.rules[p],$=i.repairs??[],ee=(L,l,M=a(),N)=>{let C=[],_={graph:L,subject:l,kinds:k,today:M,...f,...N?{linked:N}:{},onUnread:o=>C.push(o)},I,P=[];try{if(j&&Y(j,_)!==!0)return[];if(v&&l?(P=On(L,l,v),I=P.length===0):I=Y(w,_)===!0,!I&&C.length>0)throw new oe(`it reads ${kn(C[0])}`,0)}catch(o){throw o instanceof wn?new dn(o.sentence):o instanceof oe?new Error(o.sentence):o}if(I)return[];let r=$.flatMap(o=>{let z=n.acts?.[o.act],J={},de=l&&z?.on&&z.fromTheOtherEnd&&![z.on].flat().includes(l.kind)?Fn(e.acts[o.act].args,l.kind):void 0;de?J[de]=l.id:l&&(z?.on||/^(edit|remove|archive|unarchive|merge|skip|detach|split)-/.test(o.act))&&(J[Q]=l.id);for(let[u,b]of Object.entries(o.args??{}))J[u]=me(b)==="subject"?l?.id:b;let A=(z?e.acts[o.act].args:[]).filter(([u,b])=>b.required&&J[u]===void 0).map(([u])=>u);return[{mutation:o.act,label:o.label??(de?z.fromTheOtherEnd:z?.title)??o.act.replace(/-/g," "),args:J,...A.length>0?{missing:A}:{}}]});return v&&l?P.map(o=>({invariant:p,subjectId:l.id,label:x,message:S?se(S,{node:l,kinds:k,graph:L,today:M,money:O,bindings:{[l.kind]:l,[o.kind]:o}}):`${T(l)}: ${x} \u2014 ${T(o)}`,nodeIds:[l.id,o.id],repairs:r})):[{invariant:p,...l?{subjectId:l.id}:{},label:x,message:S?se(S,{node:l,kinds:k,graph:L,today:M,money:O}):l?`${T(l)}: ${x}`:x,nodeIds:l?[l.id]:[],repairs:r}]},W={label:x,shape:{over:i.over,require:w,...v?{covers:v}:{},when:j,says:S,declared:n.kinds,money:O,kinds:k,today:a},judgment:{...i.require?{require:i.require}:{},...i.covers?{covers:i.covers}:{},...i.when?{when:i.when}:{},...i.says?{says:i.says}:{}},...i.description?{description:i.description}:{},...$.length>0?{repairs:$.map(L=>L.act)}:{}};Te.push(i.over==="graph"?Se(p,{scope:"graph",...W,evaluate:({graph:L,today:l,context:M})=>ee(L,null,l,M?.linked)}):Se(p,{scope:{kind:i.over},...W,evaluate:({graph:L,subject:l,today:M,context:N})=>ee(L,l,M,N?.linked)}))}let Ge=n.policy&&{...n.policy,...n.roles?{roles:n.roles}:{}},we={name:n.name,schema:B,mutations:Pe,invariants:Te,...Ge?{policy:Ge}:{},...e.brand?{brand:e.brand}:{},...n.modules?{modules:n.modules}:{},...n.lenses?{lenses:n.lenses}:{},...n.pages?{pages:n.pages}:{},...n.settings?{settings:n.settings}:{},...n.connections?{connections:n.connections}:{},...n.forms?{forms:n.forms}:{},...n.publishing?{publishing:n.publishing}:{},...n.tidying?{tidying:n.tidying}:{},...n.purpose?{purpose:n.purpose}:{},...e.viewSpecs?{viewSpecs:e.viewSpecs}:{},...e.home?{home:e.home}:{},version:n.version??1};return Sn(we,n),Cn.set(we,e),{ok:!0,app:we,document:n,findings:e.findings,sights:n.policy?.sees,kinds:k}}function Vn(e,d,n){let t=d||e.format==="duration",a=e.format==="money"||e.format==="percent"||!e.format&&e.unit!==void 0;if(!(!t&&!a))return{...e,...t?{as:"duration"}:{},...a?{amount:{...n,...e.format?{format:e.format}:{},...e.unit?{unit:e.unit}:{},...e.places===0?{places:0}:{}}}:{}}}export{q as a,xn as b,Zn as c,Qn as d,Ln as e,Q as f,me as g,$n as h,xt as i,In as j};
@@ -1,6 +1,6 @@
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{G as C,La as K,W as k}from"./chunk.MODLZJD4.js";import{a as H}from"./chunk.SDO3U72B.js";import{b}from"./chunk.AJZBJBMO.js";var n=b(C(),1),N=450,_=10,O=t=>t instanceof HTMLInputElement?t.dataset.graviewChooseBox??void 0:void 0,q={ArrowDown:1,ArrowRight:1,ArrowUp:-1,ArrowLeft:-1,Home:-1/0,End:1/0},S=t=>t instanceof Element?t.closest("[data-graview-choose]"):null,G=t=>t instanceof HTMLElement&&(t.isContentEditable||t instanceof HTMLInputElement&&t.type!=="checkbox"||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement);function Y(t){let[i,d]=(0,n.useState)(()=>new Set),l=(0,n.useRef)(null),x=(0,n.useRef)(null),[E,P]=(0,n.useState)(null),R=E!==null&&t.includes(E)?E:t[0],L=(0,n.useMemo)(()=>t.filter(e=>i.has(e)),[t,i]),M=(0,n.useMemo)(()=>new Set(t),[t]);(0,n.useEffect)(()=>{[...i].some(e=>!M.has(e))&&d(e=>new Set([...e].filter(o=>M.has(o))))},[M,i]);let u=(0,n.useCallback)((e,o=!1)=>{let a=l.current;d(s=>{let r=new Set(s),f=a===null?-1:t.indexOf(a),y=t.indexOf(e);if(o&&f>=0&&y>=0){let T=s.has(a);for(let p of t.slice(Math.min(f,y),Math.max(f,y)+1))T?r.add(p):r.delete(p)}else r.has(e)?r.delete(e):r.add(e);return r}),l.current=e},[t]),v=(0,n.useCallback)(e=>d(new Set(e)),[]),A=(0,n.useCallback)(()=>{l.current=null,d(new Set)},[]),c=(0,n.useRef)(null),g=(0,n.useRef)(!1),m=L.length>0,h=()=>{c.current&&clearTimeout(c.current.timer),c.current=null};(0,n.useEffect)(()=>h,[]);let B={ref:x,onKeyDown:e=>{if(G(e.target))return;let o=O(e.target);if(e.key==="Tab"&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&o!==void 0&&m){let s=document.querySelector('[data-testid="several-bar"]'),r=s?.querySelector("[data-mutation]:not([disabled])")??s?.querySelector("button:not([disabled])");if(r){e.preventDefault(),e.stopPropagation(),r.focus();return}}let a=q[e.key];if(o!==void 0&&a!==void 0&&!e.metaKey&&!e.ctrlKey&&!e.altKey){let s=t.indexOf(o),r=t[Math.max(0,Math.min(t.length-1,s+(Number.isFinite(a)?a:a>0?t.length:-t.length)))];if(e.preventDefault(),e.stopPropagation(),r===void 0||r===o)return;if(e.shiftKey){let f=l.current!==null&&t.includes(l.current)?l.current:o,[y,T]=[t.indexOf(f),t.indexOf(r)].sort((p,F)=>p-F);d(p=>new Set([...p,...t.slice(y,T+1)])),l.current=f}P(r),x.current?.querySelector(`[data-graview-choose-box="${CSS.escape(r)}"]`)?.focus();return}if((e.metaKey||e.ctrlKey)&&!e.altKey&&e.key.toLowerCase()==="a"){e.preventDefault(),e.stopPropagation(),v(t);return}if(e.key===" "&&!e.metaKey&&!e.ctrlKey){let s=S(e.target),r=e.target instanceof HTMLButtonElement||e.target instanceof HTMLInputElement&&e.target.type==="checkbox";if(!s||r)return;e.preventDefault(),u(s.dataset.graviewChoose,e.shiftKey)}},onFocus:e=>{let o=O(e.target);o!==void 0&&P(o)},onPointerDown:e=>{if(g.current=!1,e.pointerType==="mouse"||e.button>0)return;let o=S(e.target);if(!o||e.target instanceof HTMLInputElement&&e.target.type==="checkbox")return;let a=o.dataset.graviewChoose;h(),c.current={id:a,x:e.clientX,y:e.clientY,timer:setTimeout(()=>{c.current=null,g.current=!0,u(a)},N)}},onPointerMove:e=>{let o=c.current;o&&Math.hypot(e.clientX-o.x,e.clientY-o.y)>_&&h()},onPointerUp:h,onPointerCancel:h,onClickCapture:e=>{let o=S(e.target);if(!o||e.target instanceof HTMLInputElement&&e.target.type==="checkbox"&&e.target.hasAttribute("data-graview-choose-box"))return;if(g.current){g.current=!1,e.preventDefault(),e.stopPropagation();return}let s=o.dataset.graviewChoose;if(e.shiftKey&&(m||l.current!==null)){e.preventDefault(),e.stopPropagation(),u(s,!0);return}m&&matchMedia?.("(pointer: coarse)").matches&&(e.preventDefault(),e.stopPropagation(),u(s))},onContextMenu:e=>{(g.current||c.current)&&(e.preventDefault(),e.stopPropagation())},...m?{"data-graview-choosing":""}:{}},j=(0,n.useCallback)(e=>i.has(e),[i]);return{chosen:L,has:j,toggle:u,choose:v,clear:A,listProps:B,boxProps:(e,o)=>({type:"checkbox",className:"graview-choose-box","data-graview-choose-box":e,"aria-label":`Choose ${o}`,tabIndex:e===R?0:-1,checked:i.has(e),onChange:()=>{},onClick:a=>{a.stopPropagation(),u(e,a.shiftKey)}}),list:x}}var $=`
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{G as C,La as K,W as k}from"./chunk.A5PSEU3W.js";import{a as H}from"./chunk.SDO3U72B.js";import{b}from"./chunk.AJZBJBMO.js";var n=b(C(),1),N=450,_=10,O=t=>t instanceof HTMLInputElement?t.dataset.graviewChooseBox??void 0:void 0,q={ArrowDown:1,ArrowRight:1,ArrowUp:-1,ArrowLeft:-1,Home:-1/0,End:1/0},S=t=>t instanceof Element?t.closest("[data-graview-choose]"):null,G=t=>t instanceof HTMLElement&&(t.isContentEditable||t instanceof HTMLInputElement&&t.type!=="checkbox"||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement);function Y(t){let[i,d]=(0,n.useState)(()=>new Set),l=(0,n.useRef)(null),x=(0,n.useRef)(null),[E,P]=(0,n.useState)(null),R=E!==null&&t.includes(E)?E:t[0],L=(0,n.useMemo)(()=>t.filter(e=>i.has(e)),[t,i]),M=(0,n.useMemo)(()=>new Set(t),[t]);(0,n.useEffect)(()=>{[...i].some(e=>!M.has(e))&&d(e=>new Set([...e].filter(o=>M.has(o))))},[M,i]);let u=(0,n.useCallback)((e,o=!1)=>{let a=l.current;d(s=>{let r=new Set(s),f=a===null?-1:t.indexOf(a),y=t.indexOf(e);if(o&&f>=0&&y>=0){let T=s.has(a);for(let p of t.slice(Math.min(f,y),Math.max(f,y)+1))T?r.add(p):r.delete(p)}else r.has(e)?r.delete(e):r.add(e);return r}),l.current=e},[t]),v=(0,n.useCallback)(e=>d(new Set(e)),[]),A=(0,n.useCallback)(()=>{l.current=null,d(new Set)},[]),c=(0,n.useRef)(null),g=(0,n.useRef)(!1),m=L.length>0,h=()=>{c.current&&clearTimeout(c.current.timer),c.current=null};(0,n.useEffect)(()=>h,[]);let B={ref:x,onKeyDown:e=>{if(G(e.target))return;let o=O(e.target);if(e.key==="Tab"&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&o!==void 0&&m){let s=document.querySelector('[data-testid="several-bar"]'),r=s?.querySelector("[data-mutation]:not([disabled])")??s?.querySelector("button:not([disabled])");if(r){e.preventDefault(),e.stopPropagation(),r.focus();return}}let a=q[e.key];if(o!==void 0&&a!==void 0&&!e.metaKey&&!e.ctrlKey&&!e.altKey){let s=t.indexOf(o),r=t[Math.max(0,Math.min(t.length-1,s+(Number.isFinite(a)?a:a>0?t.length:-t.length)))];if(e.preventDefault(),e.stopPropagation(),r===void 0||r===o)return;if(e.shiftKey){let f=l.current!==null&&t.includes(l.current)?l.current:o,[y,T]=[t.indexOf(f),t.indexOf(r)].sort((p,F)=>p-F);d(p=>new Set([...p,...t.slice(y,T+1)])),l.current=f}P(r),x.current?.querySelector(`[data-graview-choose-box="${CSS.escape(r)}"]`)?.focus();return}if((e.metaKey||e.ctrlKey)&&!e.altKey&&e.key.toLowerCase()==="a"){e.preventDefault(),e.stopPropagation(),v(t);return}if(e.key===" "&&!e.metaKey&&!e.ctrlKey){let s=S(e.target),r=e.target instanceof HTMLButtonElement||e.target instanceof HTMLInputElement&&e.target.type==="checkbox";if(!s||r)return;e.preventDefault(),u(s.dataset.graviewChoose,e.shiftKey)}},onFocus:e=>{let o=O(e.target);o!==void 0&&P(o)},onPointerDown:e=>{if(g.current=!1,e.pointerType==="mouse"||e.button>0)return;let o=S(e.target);if(!o||e.target instanceof HTMLInputElement&&e.target.type==="checkbox")return;let a=o.dataset.graviewChoose;h(),c.current={id:a,x:e.clientX,y:e.clientY,timer:setTimeout(()=>{c.current=null,g.current=!0,u(a)},N)}},onPointerMove:e=>{let o=c.current;o&&Math.hypot(e.clientX-o.x,e.clientY-o.y)>_&&h()},onPointerUp:h,onPointerCancel:h,onClickCapture:e=>{let o=S(e.target);if(!o||e.target instanceof HTMLInputElement&&e.target.type==="checkbox"&&e.target.hasAttribute("data-graview-choose-box"))return;if(g.current){g.current=!1,e.preventDefault(),e.stopPropagation();return}let s=o.dataset.graviewChoose;if(e.shiftKey&&(m||l.current!==null)){e.preventDefault(),e.stopPropagation(),u(s,!0);return}m&&matchMedia?.("(pointer: coarse)").matches&&(e.preventDefault(),e.stopPropagation(),u(s))},onContextMenu:e=>{(g.current||c.current)&&(e.preventDefault(),e.stopPropagation())},...m?{"data-graview-choosing":""}:{}},j=(0,n.useCallback)(e=>i.has(e),[i]);return{chosen:L,has:j,toggle:u,choose:v,clear:A,listProps:B,boxProps:(e,o)=>({type:"checkbox",className:"graview-choose-box","data-graview-choose-box":e,"aria-label":`Choose ${o}`,tabIndex:e===R?0:-1,checked:i.has(e),onChange:()=>{},onClick:a=>{a.stopPropagation(),u(e,a.shiftKey)}}),list:x}}var $=`
2
2
  .graview-choose-box{width:24px;height:24px;margin:0;accent-color:var(--graview-accent);cursor:pointer;opacity:0}
3
3
  [data-graview-choose]:hover .graview-choose-box,[data-graview-choose]:focus-within .graview-choose-box,.graview-choose-box:focus-visible,.graview-choose-box:checked,[data-graview-choosing] .graview-choose-box{opacity:1}
4
4
  [data-graview-choose]{-webkit-touch-callout:none}
5
5
  [data-graview-choosing] [data-graview-choose]{-webkit-user-select:none;user-select:none}
6
- `;var D=b(C(),1),w=b(k(),1),I=K(H(()=>(__graviewPreload(import.meta.url,["./chunk.OPTYYIGC.js","./chunk.YNEHJWJV.js","./chunk.MB7LKKUD.js","./chunk.WAB3L3ZI.js","./chunk.W53YNBSM.js","./chunk.V5I4GZEY.js","./chunk.V7W5AQKL.js","./chunk.EMFOMSMI.js","./chunk.QOS5T46W.js","./chunk.GME63ZHI.js","./chunk.I2737CPF.js","./chunk.NJRLJEJY.js","./chunk.CVPMSPCH.js","./chunk.OTV5XTBB.js","./chunk.KBPJ7X7W.js","./chunk.OEIWIZCP.js","./chunk.WSDJPXJD.js","./chunk.F4VB6Q2W.js","./chunk.FFOD5B4B.js","./chunk.Z7Y3R3YR.js","./chunk.YXEO3Y65.js","./chunk.U3HERHAI.js","./chunk.FBILPNGH.js","./chunk.MODLZJD4.js","./chunk.SDO3U72B.js","./chunk.6HY6ZGEE.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.ZQR2SN65.js")))),U=I.part((t,i)=>(0,w.jsx)(t.SeveralBar,{...i}),{what:"The selection bar"});function Q(t){return t.chosen.length===0?null:(0,w.jsx)(D.Suspense,{fallback:null,children:(0,w.jsx)(U,{...t})})}var W=()=>I.prefetch();export{Y as a,$ as b,Q as c,W as d};
6
+ `;var D=b(C(),1),w=b(k(),1),I=K(H(()=>(__graviewPreload(import.meta.url,["./chunk.47XEJZ3O.js","./chunk.BKYZSV2Y.js","./chunk.MB7LKKUD.js","./chunk.6W6XMLSF.js","./chunk.PZ7KY6XH.js","./chunk.T27QKVKP.js","./chunk.LP2ZMAT2.js","./chunk.MSAYU25L.js","./chunk.EGPCVMDU.js","./chunk.H3EGBDW2.js","./chunk.DWM7AR5Y.js","./chunk.6KJGRM7A.js","./chunk.WALVW3KJ.js","./chunk.SNHKYH72.js","./chunk.UGQYMN4J.js","./chunk.RG5G6YQD.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.7S6ZRMW4.js")))),U=I.part((t,i)=>(0,w.jsx)(t.SeveralBar,{...i}),{what:"The selection bar"});function Q(t){return t.chosen.length===0?null:(0,w.jsx)(D.Suspense,{fallback:null,children:(0,w.jsx)(U,{...t})})}var W=()=>I.prefetch();export{Y as a,$ as b,Q as c,W as d};
@@ -1 +1 @@
1
- import{a as fe,b as Ne,d as Ze,e as He,f as he,g as F,h as ke,j as We}from"./chunk.4AC2QM7T.js";import{h as Je,i as Xe,j as Qe}from"./chunk.CVPMSPCH.js";import{a as ae,b as ce,c as J,d as Ye,e as ee,g as se,h as en}from"./chunk.KBPJ7X7W.js";import{c as Be,h as k,i as Ue,j as ze,t as ye}from"./chunk.OEIWIZCP.js";import{A as re,Ia as Ie,Ld as qe,Md as Ve,Pa as Ke,Qa as Q,Ra as me,b as Z,c as U,e as ue,f as Me,g as P,h as O,ic as Pe,jc as ge,k as L,kc as Le,l as X,lc as Ge,m as _,mc as Ce,n as _e,o as H,p as I,r as w,s as oe,t as R,u as j,v as G,w as T,x as n,y as N,z as Y}from"./chunk.6HY6ZGEE.js";var be=e=>Object.entries(e).map(([s,i])=>[s,Object.keys(Q(i?.edges))]),$e=(e,s)=>Le(e,be(s));function nn(e){return[...Object.keys(e.acts??{}),...Object.keys(e.kinds).flatMap(s=>Pe(s)),...Ge(be(e.kinds))]}var B=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function tn(e){if(!B(e)||!B(e.kinds))return e;let s;try{let f=Object.fromEntries(Object.entries(e.kinds).map(([g,l])=>[g,B(l)&&B(l.edges)?{edges:l.edges}:{}]));s=nn({acts:B(e.acts)?e.acts:{},kinds:f})}catch{return e}let i=new Set(s),t=!1,o=f=>{if(typeof f!="string"||i.has(f))return f;let g=qe(f,s);return g===void 0?f:(t=!0,g)},a=B(e.policy)&&Array.isArray(e.policy.grants)?{...e.policy,grants:e.policy.grants.map(f=>B(f)&&Array.isArray(f.mutations)?{...f,mutations:f.mutations.map(o)}:f)}:void 0,u=B(e.rules)?Object.fromEntries(Object.entries(e.rules).map(([f,g])=>[f,B(g)&&Array.isArray(g.repairs)?{...g,repairs:g.repairs.map(l=>B(l)?{...l,act:o(l.act)}:l)}:g])):void 0;return t?{...e,...a?{policy:a}:{},...u?{rules:u}:{}}:e}function we(e,s){let i=Ve(e,nn(s));return i&&i!==e?`did you mean "${i}"?`:void 0}var Oe="graview-document",je=1,xe=256*1024,ne=64*1024,vn=["plain","editorial","shader","ascii"];var Se=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,ve=/^[a-z][A-Za-z0-9]*$/,On=/^[a-z0-9\u00df-\u00ff'-]+( [a-z0-9\u00df-\u00ff'-]+){0,2}$/,on=12,sn=60,jn=new Set(["id","kind"]),xn=/^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|[a-z][A-Za-z0-9]*)$/,An=["string","text","number","integer","boolean","date","datetime","enum","list","url","email","image","video","file","app-link","phone","place","duration"];function En(){let e=h=>h in Object.prototype,s=Y(h=>!e(h),"every object already has this name \u2014 choose another"),i=(h,D)=>[...h===void 0?[]:[Me(h)],...D===void 0?[]:[ue(D)]],t=(h,D)=>O().check(...i(h,D)),o=(h,D,te)=>I(h).check(...i(D,te)),a=h=>O().check(P(Se,`${h} names are kebab-case, lower-case words joined by hyphens like "tool-note" (field and relation names are camelCase, like "supersededBy")`)),u=O().check(P(xn,'relation names are one camelCase word, like "supersededBy" (kind names are kebab-case, like "tool-note")'),s),f=O().check(P(ve,'field names are one word or camelCase, like "dueDate", so rules say them bare (kind names are kebab-case, like "tool-note")'),Y(h=>!jn.has(h),'a field cannot be called "id" or "kind" \u2014 the framework keeps those; try "type" or "category"'),s),g=t(1,500),l=O().check(ue(40),P(On,'an alias is up to three lower-case words, like "supplier"')),r=t(1,2e3),p=t(1,300),y=w({type:G(An),required:n(_()),description:n(g),label:n(t(1,60)),aliases:n(o(l,1,on)),options:n(o(t(1,80),1,100)),multiple:n(_()),optionLabels:n(j(t(1,80),t(1,80))),of:n(G(["string","number","date","image","video","file"])),default:n(H()),unit:n(t(void 0,12)),format:n(G(["money","percent","duration","markdown"])),places:n(T(0)),min:n(L()),max:n(L()),step:n(L()),renamedFrom:n(O().check(P(ve))),repeats:n(_()),collaborative:n(_())}).check(re((h,D)=>{h.type==="enum"&&!h.options&&D.addIssue({code:"custom",message:'an enum field lists its "options"',path:["options"]}),h.type!=="enum"&&h.options&&D.addIssue({code:"custom",message:'"options" belongs only on an enum field',path:["options"]}),h.type!=="enum"&&h.multiple!==void 0&&D.addIssue({code:"custom",message:'"multiple" belongs only on an enum field: a choice that takes several of its options',path:["multiple"]});for(let te of Object.keys(h.optionLabels??{}))h.options?.includes(te)||D.addIssue({code:"custom",message:`"${te}" is labeled, and is none of the field's options`,path:["optionLabels",te]});h.type!=="list"&&h.of&&D.addIssue({code:"custom",message:'"of" belongs only on a list field',path:["of"]}),h.places!==void 0&&!(h.format==="money"||!h.format&&/^[A-Z]{3}$/.test(h.unit??""))&&D.addIssue({code:"custom",message:'"places" belongs only on money: a number field with "format": "money"',path:["places"]}),h.repeats&&h.type!=="date"&&h.type!=="datetime"&&D.addIssue({code:"custom",message:'"repeats" belongs only on a date or datetime field',path:["repeats"]})})),m=O().check(P(new RegExp(`${Se.source}|${Ie.source}`),'a relation goes to a kind of this document, like "house", or of another app, like "@nick/house/house"')),d=w({to:R([o(m,1),T("*")]),cardinality:n(G(["one","many"])),description:n(g),inverse:n(t(1,80)),appendOnly:n(_()),renamedFrom:n(O()),tidying:n(T("never"))}),c=R([r,w({expr:r,label:n(t(1,60)),description:n(g),format:n(G(["money","percent","duration"])),unit:n(t(1,12)),places:n(T(0)),hidden:n(_())})]),S=R([O(),L(),_(),_e(),I(H()),w({expr:r})]),b=w({noun:n(t(1,40)),plural:n(t(1,40)),aliases:n(o(l,1,on)),description:n(g),fields:j(f,y).check(Y(h=>Object.keys(h).length>0,"a kind has at least one field")),label:n(p),describe:n(p),lifecycle:n(w({field:f,retired:o(R([O(),L(),_()]),1)})),figure:n(t(void 0,2e4)),glance:n(o(f,1,20)),page:n(w({fields:n(o(f,1,40)),groups:n(o(w({title:t(1,60),fields:o(f,1,40)}),1,12))})),edges:n(j(u,d)),computed:n(j(O(),c).check(Y(h=>Object.keys(h).length<=sn,`a kind works out at most ${sn} computed fields`))),fieldRoles:n(j(O(),O())),renamedFrom:n(O().check(P(Se))),people:n(_()),archives:n(T(!1)),tidying:n(G(["never","no-links"])),derives:n(w({from:a("kind"),via:u,set:j(f,S)}))}),v=O().check(P(/^\$[A-Za-z][A-Za-z0-9]*$/,'a reference is "$" and a name, like "$subject" or "$new"')),x=R([w({create:a("kind"),as:n(O().check(P(ve))),set:n(j(f,S))}),w({set:j(f,S),target:n(v)}),w({connect:u,from:v,to:v}),w({sever:u,from:v,to:v}),w({remove:v})]),A=w({title:n(t(1,80)),description:n(g),fromTheOtherEnd:n(t(1,80)),on:n(R([a("kind"),o(a("kind"),1)])),creates:n(a("kind")),sets:n(j(f,S)),writes:n(o(f,1)),connects:n(u),severs:n(u),setsOther:n(j(f,S)),setsLinked:n(j(u,j(f,S))),replaces:n(R([T(!0),o(u,1,10)])),removes:n(T(!0)),args:n(j(f,y)),effects:n(o(x,1,20)),allowedWhen:n(r),refusal:n(p),destructive:n(_())}),$=w({act:a("act"),label:n(t(1,80)),args:n(j(O(),S))}),C=w({every:a("kind"),through:u,via:n(u)}),q=w({title:n(t(1,120)),description:n(g),over:R([T("graph"),a("kind")]),when:n(r),require:n(r),covers:n(C),says:n(p),repairs:n(o($,void 0,10))}).check(re((h,D)=>{!h.require&&!h.covers&&D.addIssue({code:"custom",message:'a rule says what must hold in "require", or what each record must be linked to in "covers"',path:["require"]}),h.require&&h.covers&&D.addIssue({code:"custom",message:'a rule is judged by "require" or by "covers", not both',path:["covers"]}),h.covers&&h.over==="graph"&&D.addIssue({code:"custom",message:'a coverage rule is over a kind, whose records it follows through their links; name the kind in "over"',path:["over"]})})),z=w({roles:R([o(a("role"),1),T("*")]),mutations:R([o(a("act")),T("*")]),kinds:n(R([I(a("kind")),T("*")])),describe:n(g),self:n(_()),ownEnd:n(_()),propose:n(R([o(a("act"),1),T("*")]))}).check(re((h,D)=>{Array.isArray(h.mutations)&&h.mutations.length===0&&h.propose===void 0&&D.addIssue({code:"custom",message:'a grant names at least one act in "mutations", or the acts it lets these roles propose in "propose"',path:["mutations"]})})),E=n(o(f,1)),M=w({roles:R([o(a("role"),1),T("*")]),kinds:o(a("kind"),1),own:n(_()),via:n(u),fields:E,hide:E}),ie=w({grants:I(z),sees:n(I(M))}),W=w({accent:n(O().check(P(/^#[0-9a-fA-F]{6}$/,'an accent is a color like "#c2577a"'))),ground:n(R([O().check(P(/^#[0-9a-fA-F]{6}$/,'a ground is a color like "#eef3f8"')),w({light:n(O().check(P(/^#[0-9a-fA-F]{6}$/,'a ground is a color like "#eef3f8"'))),dark:n(O().check(P(/^#[0-9a-fA-F]{6}$/,'a ground is a color like "#101826"')))})])),name:n(t(1,60)),currency:n(O().check(P(/^[A-Z]{3}$/,'a currency is its three-letter code, like "USD" or "EUR"'))),locale:n(t(2,35)),timeZone:n(t(1,64)),logo:n(R([t(1,ne),w({src:t(1,ne),alt:n(t(1,120))}),w({light:t(1,ne),dark:n(t(1,ne)),alt:n(t(1,120)),darkFallback:n(T("invert"))})])),favicon:n(R([t(1,ne),w({emoji:O()})])),typography:n(w({display:n(t(1,200)),body:n(t(1,200)),mono:n(t(1,200))})),shape:n(w({radius:n(L().check(U(0),Z(32))),density:n(L().check(U(.75),Z(1.5)))})),accents:n(j(O(),L().check(U(0),Z(360)))),scheme:n(G(["light","dark","auto"])),subtitle:n(T(!1)),splash:n(w({style:G(vn),image:n(t(1,ne)),title:n(t(1,80)),kicker:n(t(1,80)),shader:n(t(1,40)),scheme:n(G(["light","dark","device"]))})),views:n(w({css:n(t(1)),motion:n(G(["none","fade"]))}))}),V=j(O(),H()),Fe=R([t(1,120),w({by:t(1,120),direction:n(G(["asc","desc"]))})]),De=L().check(X(),U(1),Z(9999)),hn=oe({create:n(_()),options:n(oe({sort:n(Fe),columnSort:n(Fe),search:n(o(t(1,120),void 0,40)),filters:n(o(t(1,120),void 0,40)),horizon:n(R([L().check(X(),U(1),Z(200)),oe({years:L().check(X(),U(1),Z(200)),title:t(1,80),from:n(De),to:n(De)})]))}))}),kn=w({card:n(I(H())),row:n(I(H())),page:n(I(H()))}),bn=()=>{let h=n(G(["asc","desc"]));return R([t(1,120),w({by:t(1,120),direction:h,then:n(R([t(1,120),w({by:t(1,120),direction:h})]))})])},$n=()=>R([t(1,120),w({by:t(1,120),order:n(o(t(1,80),void 0,40)),closed:n(o(t(1,80),void 0,40))})]),Te=oe({order:n(I(O())),hide:n(I(O())),first:n(O()),primary:n(o(t(1,80),void 0,40)),scene:n(t(1,40)),pages:n(t(1,40)),lists:n(j(O(),w({filters:n(o(t(1,120),void 0,40)),sort:n(bn()),group:n($n()),export:n(_())})))}),wn=w({act:a("act"),title:n(t(1,80)),intro:n(g),fields:n(o(f,1,40)),say:n(g),submit:n(t(1,80)),role:n(a("role"))}),Sn=w({$schema:n(O()),format:T(Oe),formatVersion:T(je),name:t(1,80),description:n(g),version:n(L().check(X(),U(1))),kinds:j(a("kind"),b).check(Y(h=>Object.keys(h).length>0,"a document declares at least one kind"),Y(h=>Object.keys(h).length<=40,"a document declares at most 40 kinds")),computed:n(j(O(),c)),acts:n(j(a("act"),A)),rules:n(j(a("rule"),q)),roles:n(I(a("role"))),policy:n(ie),modules:n(V),lenses:n(I(hn)),pages:n(Te),views:n(j(O(),R([kn,I(H())]))),brand:n(W),settings:n(I(V)),migrations:n(I(V)),connections:n(j(a("connection"),V)),purpose:n(V),workflows:n(j(a("workflow"),V)),forms:n(j(a("form"),wn)),publishing:n(w({mode:G(["live","on-publish"]),working:o(a("role"),void 0,40),publishers:n(o(a("role"),1,40))})),tidying:n(w({autoAcceptAt:n(L().check(X(),U(1),Z(1e4)))}))});return{FieldSpec:y,EdgeSpec:d,ComputedSpec:c,KindSpec:b,ValueSpec:S,EffectSpec:x,ActSpec:A,RepairSpec:$,CoverSpec:C,RuleSpec:q,GrantSpec:z,SightSpec:M,PolicySpec:ie,BrandSpec:W,PagesSpec:Te,DocumentSpec:Sn}}var Rn,K=()=>Rn??=En(),Xn=N(()=>K().FieldSpec),Qn=N(()=>K().EdgeSpec),et=N(()=>K().ComputedSpec),nt=N(()=>K().KindSpec),tt=N(()=>K().ValueSpec),ot=N(()=>K().EffectSpec),st=N(()=>K().ActSpec),it=N(()=>K().RepairSpec),rt=N(()=>K().CoverSpec),at=N(()=>K().RuleSpec),ct=N(()=>K().GrantSpec),lt=N(()=>K().SightSpec),dt=N(()=>K().PolicySpec),pt=N(()=>K().BrandSpec),ft=N(()=>K().PagesSpec),rn=N(()=>K().DocumentSpec);var Fn={};function an(e,s=Fn,i=je){let{document:t,respelled:o}=Ne(e),a=o.length>0?{respelled:o}:{};if(!t||typeof t!="object"||Array.isArray(t))return{document:t};let u=t;if(u.format!==Oe||typeof u.formatVersion!="number"||u.formatVersion>=i)return{document:t,...a};let f=u.formatVersion,g=structuredClone(u);for(let l=f;l<i;l++){let r=s[l];if(!r)throw new Error(`there is no upgrade from format ${l} to ${l+1}`);g={...r(g),formatVersion:l+1}}return{document:g,from:f,...a}}function Ae(e,s,i){let t=Object.keys(e).filter(f=>e[f].edges?.[s]!==void 0);if(t.length===0)return;let o=t.map(f=>e[f].edges[s].to),a=o.some(f=>f==="*")?"*":[...new Set(o.flatMap(f=>f))];if(i.length===0||i.some(f=>t.includes(f)))return{reversed:!1,kinds:a};let u=t.filter(f=>{let g=e[f].edges[s].to;return g==="*"||i.every(l=>g.includes(l))});return u.length>0?{reversed:!0,kinds:u}:{reversed:!1,kinds:a}}var dn=(e,s)=>{let i=e?.fields[s];return i!==void 0&&(i.type==="duration"||(i.type==="number"||i.type==="integer")&&i.format==="duration")};function cn(e,s,i,t){if(t==="out"){let o=e[s]?.edges?.[i]?.to;return o===void 0?[]:o==="*"?Object.keys(e):o}return Object.entries(e).filter(([,o])=>{let a=o.edges?.[i]?.to;return a!==void 0&&(a==="*"||a.includes(s))}).map(([o])=>o)}function Ee(e,s,i){if(i.t==="ident")return e[s]?.edges?.[i.name]?cn(e,s,i.name,"out"):void 0;if(i.t==="where")return Ee(e,s,i.set);if(i.t==="call"&&(i.fn==="out"||i.fn==="in")&&i.args[0]?.t==="lit"&&typeof i.args[0].value=="string")return cn(e,s,i.args[0].value,i.fn)}var ln=(e,s,i)=>{let t=s.filter(o=>e[o]?.fields[i]!==void 0);return t.length>0&&t.every(o=>dn(e[o],i))};function pn(e,s,i){let t=e.kinds,o=t[s],a=new Map(i),u=new Map,f=(l,r)=>{if(r>8)return!1;switch(l.t){case"ident":return dn(o,l.name)||g(l.name,r+1);case"member":{let p=Ee(t,s,l.object);return p!==void 0&&ln(t,p,l.name)}case"call":{if(l.fn!=="sum"&&l.fn!=="min"&&l.fn!=="max")return!1;let[p,y]=l.args,m=p&&Ee(t,s,p);return m!==void 0&&y?.t==="ident"&&ln(t,m,y.name)}case"binary":return(l.op==="+"||l.op==="-")&&f(l.left,r)&&f(l.right,r);case"unary":return l.op==="-"&&f(l.operand,r);default:return!1}},g=(l,r)=>{if(o?.computed?.[l]===void 0)return!1;if(u.has(l))return u.get(l);u.set(l,!1);let p=a.get(l),y=p!==void 0&&f(p,r);return u.set(l,y),y};return i.map(([l])=>l).filter(l=>g(l,0))}var Dn="several choices";var Tn={title:["string","text"],rich_text:["string","text"],number:["number","integer"],select:["enum","string"],status:["enum","string"],multi_select:["list",Dn],date:["date","datetime"],checkbox:["boolean"],url:["url","string"],email:["email","string"],phone_number:["phone","string"],people:["string","text","list"]};var fn=new Set(Object.values(Tn).flat());function un(e,s){let i=new Map;if(!e||typeof e!="object")return new Map;let t=Object.values(e).flatMap(o=>o&&typeof o=="object"&&o.system==="notion"&&Array.isArray(o.sources)?o.sources.filter(a=>a&&typeof a=="object").map(a=>({system:"notion",kind:a.kind,properties:a.properties})):[o]);for(let o of t){if(!o||typeof o!="object"||typeof o.kind!="string")continue;let a=s[o.kind]?.fields;if(!a)continue;let u=[];o.system==="google-calendar"&&o.fields&&typeof o.fields=="object"?u=Object.values(o.fields).filter(g=>typeof g=="string"):o.system==="notion"&&(u=o.properties&&typeof o.properties=="object"?Object.keys(o.properties):Object.keys(a).filter(g=>fn.has(a[g].type)));let f=i.get(o.kind)??new Set;for(let g of u)Object.hasOwn(a,g)&&f.add(g);i.set(o.kind,f)}return new Map([...i].filter(([,o])=>o.size>0).map(([o,a])=>[o,Object.keys(s[o].fields).filter(u=>a.has(u))]))}function mn(e,s,i=`kinds.${e}.page`){let t=s.page;if(!t)return[];let o=[],a=[...Object.keys(s.fields),...Object.keys(s.computed??{})],u=new Set,f=(l,r)=>{a.includes(l)?u.has(l)&&o.push(k("page-field-twice",r,`"${l}" is on ${e}'s page twice; name each field once`)):o.push(k("page-field",r,`${e}'s page is to show "${l}", and ${e} has no field or computed field called that`,`use one of: ${a.join(", ")}`)),u.add(l)};(t.fields??[]).forEach((l,r)=>f(l,`${i}.fields.${r}`));let g=new Set;return(t.groups??[]).forEach((l,r)=>{let p=l.title.trim().toLowerCase();g.has(p)&&o.push(k("page-group-twice",`${i}.groups.${r}.title`,`${e}'s page has two groups called "${l.title}"; give each its own title`)),g.add(p),l.fields.forEach((y,m)=>f(y,`${i}.groups.${r}.fields.${m}`))}),o}function gn(e,s=[]){return Ce({declared:Object.keys(e.fields),paged:[...e.page?.fields??[],...(e.page?.groups??[]).flatMap(i=>i.fields)],must:i=>!!e.fields[i].required&&e.fields[i].default===void 0,naming:s})}var Nn=new Set(["subject","now","today","me"]);function Mn(e){if((typeof e=="string"?e:JSON.stringify(e??null)).length>xe)return{findings:[k("too-large","",`a document may be at most ${xe/1024} KB`)]};if(typeof e=="string")try{e=JSON.parse(e)}catch(t){return{findings:[k("not-json","",`this is not JSON: ${t.message}`)]}}try{e=an(e).document}catch(t){return{findings:[k("format","formatVersion",t.message)]}}e=tn(e);let s=rn.safeParse(e);if(!s.success)return{findings:s.error.issues.map(t=>{let o=t.path.map(String).join(".");if(t.code==="unrecognized_keys")return k("unknown-key",o,`${t.keys.map(a=>`"${a}"`).join(", ")} ${t.keys.length===1?"is":"are"} not part of a Graview document here`,"check the spelling against docs/declaration-document.md");if(t.code==="invalid_union"&&/\.effects\.\d+$/.test(o))return k("effect-shape",o,"this effect is not one Graview knows",'an effect is one of {"create": kind, "as"?: name, "set"?: {field: value}}, {"set": {field: value, \u2026}, "target"?: "$ref"}, {"connect"|"sever": relation, "from": "$ref", "to": "$ref"}, {"remove": "$ref"}');if(t.code==="invalid_key"){let a=t.issues?.[0]?.message;return k("shape",o,`the name "${String(t.path.at(-1))}" is not allowed here${a?`: ${a}`:""}`)}return k("shape",o,t.message)})};let i=s.data;return{document:i,findings:_n(i)}}var pe=e=>[e??[]].flat();function zn(e){let s=new Map;for(let[i,t]of Object.entries(e.kinds))for(let[o,a]of Object.entries(Q(t.edges))){let u=s.get(o);s.set(o,{name:o,from:[...u?.from??[],i],to:a.to==="*"||u?.to==="*"?"*":[...new Set([...u?.to??[],...a.to])],cardinality:a.cardinality??"many"})}return s}function Ht(e){let s=new Map;for(let[t,o]of Object.entries(e.kinds)){let a=se(o),u=me(o.edges);s.set(t,{fields:new Set([...Object.keys(o.fields),...u.keys()]),edges:new Map(Object.entries(Q(o.edges)).map(([f,g])=>[f,g.cardinality??"many"])),...a?{computed:a}:{},...u.size>0?{linked:u}:{}})}let i=se(e);return i&&s.set(Be,{computed:i}),s}function yn(e,s){let i=[],t=pe(e.on),o=(a,u)=>{let f=Ae(s.kinds,a,t)?.reversed===!0,[g,l]=f?["$to","$subject"]:["$subject","$to"];return u==="connect"?{connect:a,from:g,to:l}:{sever:a,from:g,to:l}};if(e.creates){let a=s.kinds[e.creates],u={};for(let f of Object.keys(a?.fields??{}))u[f]=`$${f}`;for(let f of e.effects??[])"set"in f&&!("create"in f)&&F(f.target)==="new"&&Object.assign(u,f.set);i.push({create:e.creates,as:"new",set:u})}if(e.sets&&i.push({set:e.sets}),e.writes&&!(e.creates&&e.on===void 0)&&i.push({set:Object.fromEntries(e.writes.map(a=>[a,`$${a}`]))}),e.connects&&(e.replaces&&i.push({replace:e.replaces===!0?[e.connects]:[...e.replaces],keep:e.connects}),i.push(o(e.connects,"connect"))),e.severs&&i.push(o(e.severs,"sever")),e.setsOther&&(e.connects||e.severs)&&i.push({set:e.setsOther,target:"$to"}),e.setsLinked&&t.length>0)for(let[a,u]of Object.entries(e.setsLinked))i.push({set:u,through:a});return e.removes&&i.push({remove:"$subject"}),e.effects&&i.push(...e.effects.filter(a=>!(e.creates&&"set"in a&&!("create"in a)&&F(a.target)==="new"))),i}function le(e,s,i){try{let t=J(e),o=ae(t);for(let a of o.unknownFunctions)i.push(k("unknown-function",s,`"${a}" is not a function the rule language knows`,"see the rule language in the graview-invariant skill"));return t}catch(t){if(t instanceof ce){i.push(k("expression",s,t.sentence+` (at character ${t.at+1})`));return}throw t}}function Re(e,s,i){try{return ee(e)}catch(t){if(t instanceof Ye||t instanceof ce){i.push(k("template",s,(t instanceof ce,t.sentence)));return}throw t}}function _n(e){let s=[],i=new Set(Object.keys(e.kinds)),t=zn(e),o=e.acts??{},a=new Set(e.roles??[]),u=(l,r)=>me(e.kinds[l]?.edges).has(r),f=l=>Object.keys(e.kinds).some(r=>u(r,l));for(let[l,r]of Object.entries(e.kinds)){let p=`kinds.${l}`;for(let[m,d]of Object.entries(r.edges??{})){if(!Ke(d)&&d.to!=="*")for(let c of d.to)i.has(c)||s.push(k("edge-target",`${p}.edges.${m}.to`,`"${c}" is not a kind this document declares`));r.fields[m]&&s.push(k("edge-field-clash",`${p}.edges.${m}`,`"${m}" is both a field and a relation of ${l}`,"rename one of them"))}r.lifecycle&&!r.fields[r.lifecycle.field]&&s.push(k("lifecycle-field",`${p}.lifecycle.field`,`${l} has no field "${r.lifecycle.field}"`));let y=m=>r.computed!==void 0&&Object.hasOwn(r.computed,m);for(let m of r.glance??[])!r.fields[m]&&!y(m)&&s.push(k("glance-field",`${p}.glance`,`a glance at ${l} is to say "${m}", and ${l} has no field or computed field called that`,`use one of: ${[...Object.keys(r.fields),...Object.keys(r.computed??{})].join(", ")}`));s.push(...mn(l,r));for(let m of["label","describe"]){let d=r[m];if(!d)continue;let c=Re(d,`${p}.${m}`,s);for(let S of c??[])if(S.expr){for(let b of ae(S.expr).names)if(!r.fields[b]){if(y(b)){en(r,b)||s.push(k("template-field",`${p}.${m}`,`${l}'s ${b} is worked out from beyond the record, and a ${m} is said with no graph to read`,`show it in a view instead, or name a computed field worked out from ${l}'s own fields`));continue}s.push(k("template-field",`${p}.${m}`,`${l} has no field "${b}" for its ${m} to show`,m==="label"?"a label can only show the record's own fields and what they work out":void 0))}}}for(let[m,d]of Object.entries(r.derives?.set??{}))fe(d)&&"expr"in d&&le(String(d.expr),`${p}.derives.set.${m}`,s);for(let[m,d]of Object.entries(r.fields)){if(d.default!==void 0&&d.type==="enum"){let b=(d.multiple?Array.isArray(d.default)?d.default:[d.default]:[d.default]).find(v=>!d.options?.includes(String(v)));(b!==void 0||!d.multiple&&Array.isArray(d.default))&&s.push(k("default-option",`${p}.fields.${m}.default`,`"${String(b??d.default)}" is not one of ${m}'s options`))}let c=`${m}Repeat`;d.repeats&&(r.fields[c]||r.edges?.[c]||r.computed?.[c])&&s.push(k("repeat-clash",`${p}.fields.${m}.repeats`,`${l} already has "${c}", where how ${m} repeats is kept`))}}for(let[l,r]of Object.entries(o)){let p=`acts.${l}`;for(let c of pe(r.on))i.has(c)||s.push(k("act-kind",`${p}.on`,`"${c}" is not a kind this document declares`));let y=pe(r.on),m=yn(r,e);if(r.creates&&r.on===void 0&&r.writes&&i.has(r.creates)){for(let c of r.writes)if(!e.kinds[r.creates].fields[c])if(e.kinds[r.creates].computed?.[c]!==void 0)s.push(k("computed-written",`${p}.writes`,`${r.creates}'s ${c} is worked out, not written: no act can set it`,"write the stored fields it is worked out from"));else{if(u(r.creates,c))continue;s.push(k("act-field",`${p}.writes`,`${r.creates} has no field "${c}"`))}}m.length===0&&s.push(k("act-empty",p,`"${l}" does nothing`,"give it effects or a shorthand such as sets or creates"));let d=new Map;m.forEach((c,S)=>{let b=m.length-(r.effects?.length??0),v=r.effects&&S>=b?`${p}.effects.${S-b}`:p;if("create"in c){if(!i.has(c.create))s.push(k("act-kind",`${v}.create`,`"${c.create}" is not a kind this document declares`));else for(let $ of Object.keys(c.set??{}))e.kinds[c.create].fields[$]||(e.kinds[c.create].computed?.[$]!==void 0?s.push(k("computed-written",`${v}.set.${$}`,`${c.create}'s ${$} is worked out, not written: no act can set it`,"set the stored fields it is worked out from")):s.push(k("act-field",`${v}.set.${$}`,`${c.create} has no field "${$}"`)));c.as&&d.set(c.as,c.create)}else if("connect"in c||"sever"in c){let $="connect"in c?c.connect:c.sever;!t.has($)&&!f($)&&s.push(k("act-edge",`${v}.${"connect"in c?"connect":"sever"}`,`"${$}" is not a relation any kind declares`)),F(c.from)==="subject"&&y.length===0&&s.push(k("act-subject",`${p}.on`,`"${l}" acts on "$subject" but does not say which kinds it is "on"`))}else if(!("through"in c))if("set"in c){let $=F(c.target??"$subject"),C=$==="subject"?y:d.has($??"")?[d.get($)]:[];$==="subject"&&y.length===0&&s.push(k("act-subject",`${p}.on`,`"${l}" changes "$subject" but does not say which kinds it is "on"`));for(let q of Object.keys(c.set))for(let z of C)if(!(!i.has(z)||e.kinds[z].fields[q]))if(e.kinds[z].computed?.[q]!==void 0)s.push(k("computed-written",`${v}.set.${q}`,`${z}'s ${q} is worked out, not written: no act can set it`,"set the stored fields it is worked out from"));else{if(u(z,q))continue;s.push(k("act-field",`${v}.set.${q}`,`${z} has no field "${q}"`))}}else"remove"in c&&F(c.remove)==="subject"&&y.length===0&&s.push(k("act-subject",`${p}.on`,`"${l}" removes "$subject" but does not say which kinds it is "on"`));let x="set"in c&&c.set?Object.values(c.set):[],A="through"in c?`${p}.setsLinked.${c.through}`:`${v}.set`;x.forEach($=>{$&&typeof $=="object"&&!Array.isArray($)&&"expr"in $&&le($.expr,A,s)})}),r.allowedWhen&&le(r.allowedWhen,`${p}.allowedWhen`,s),r.refusal&&Re(r.refusal,`${p}.refusal`,s)}for(let[l,r]of Object.entries(e.rules??{})){let p=`rules.${l}`;r.over!=="graph"&&!i.has(r.over)&&s.push(k("rule-kind",`${p}.over`,`"${r.over}" is not a kind this document declares`));let y=r.over==="graph"?void 0:e.kinds[r.over];if(r.covers&&y){let m=ye(r.over,r.covers,d=>t.get(d),d=>i.has(d));if("problem"in m){let{key:d,message:c,fix:S}=m.problem;d==="every"?s.push(k("rule-kind",`${p}.covers.every`,c,S)):s.push(k("rule-covers-relation",`${p}.covers.${d}`,c,S))}}for(let m of["when","require"]){let d=r[m];if(!d)continue;let c=le(d,`${p}.${m}`,s);if(!c)continue;let S=ae(c);for(let b of S.names)if(r.over==="graph")s.push(k("rule-name",`${p}.${m}`,`"${b}" means nothing in a rule over the whole graph`,`name a kind in "over", or use all('kind')`));else if(y&&!y.fields[b]&&!y.edges?.[b]&&y.computed?.[b]===void 0){let v=Object.keys(y.edges??{}).find(x=>x.includes("-")&&x.split("-").includes(b));s.push(k("rule-name",`${p}.${m}`,`${r.over} has no field or relation called "${b}"`,v?`"${v}" reads as a subtraction in a rule; rename the relation to one camelCase word, like "${v.replace(/-([a-z0-9])/g,(x,A)=>A.toUpperCase())}"`:void 0))}for(let b of S.edges)!t.has(b)&&!f(b)&&s.push(k("rule-edge",`${p}.${m}`,`"${b}" is not a relation any kind declares`));for(let b of S.sweeps)i.has(b)?r.over!=="graph"&&s.push(Ue("rule-cost",`${p}.${m}`,`this rule looks at every ${b} for every ${r.over}, which grows slowly as the app grows`,"walk a relation with out()/in() instead of all() where you can")):s.push(k("rule-kind",`${p}.${m}`,`"${b}" is not a kind this document declares`))}r.says&&Re(r.says,`${p}.says`,s),(r.repairs??[]).forEach((m,d)=>{!o[m.act]&&!ge(m.act)&&!$e(m.act,e.kinds)&&s.push(k("repair-act",`${p}.repairs.${d}.act`,`"${m.act}" is not an act this document declares`,we(m.act,e)))})}let g=e.policy;return g&&(g.grants.forEach((l,r)=>{if(l.roles!=="*"&&a.size>0)for(let p of l.roles)a.has(p)||s.push(k("grant-role",`policy.grants.${r}.roles`,`"${p}" is not one of the document's roles`));for(let p of["mutations","propose"]){let y=l[p];if(y!==void 0&&y!=="*")for(let m of y)!o[m]&&!ge(m)&&!$e(m,e.kinds)&&s.push(k("grant-act",`policy.grants.${r}.${p}`,`"${m}" is not an act this document declares`,we(m,e)))}}),(g.sees??[]).forEach((l,r)=>{for(let p of l.kinds)i.has(p)||s.push(k("sight-kind",`policy.sees.${r}.kinds`,`"${p}" is not a kind this document declares`));if(l.roles!=="*"&&a.size>0)for(let p of l.roles)a.has(p)||s.push(k("sight-role",`policy.sees.${r}.roles`,`"${p}" is not one of the document's roles`))})),s.push(...Qe(e)),s}function In(e){return e.label?[...e.label.matchAll(/\{\s*([A-Za-z_][A-Za-z0-9_]*)/g)].map(s=>s[1]):[ke(e)??[]].flat()}function Kn(e,s,i,t){let o=new Map,a=pe(e.on),u=new Map,f=new Map;(a.length>0||s.some(d=>"remove"in d&&F(d.remove)==="subject"||"from"in d&&(F(d.from)==="subject"||F(d.to)==="subject")||"set"in d&&!("create"in d)&&!("through"in d)&&F(d.target??"$subject")==="subject"||"through"in d))&&o.set(he,{ref:a.length>0?a:"*",required:!0});let l=e.args??{},r=e.writes?.length===1,p=(d,c)=>c&&d.type===c.type&&d.min===void 0&&d.max===void 0&&d.step===void 0?{...d,...c.min===void 0?{}:{min:c.min},...c.max===void 0?{}:{max:c.max},...c.step===void 0?{}:{step:c.step}}:d,y=(d,c)=>c&&d.type===c.type&&d.format===void 0&&d.unit===void 0?{...p(d,c),...c.format?{format:c.format}:{},...c.unit?{unit:c.unit}:{}}:p(d,c),m=(d,c,S)=>{if(d===he||Nn.has(d)||u.has(d)||o.has(d))return;let b=l[d]?y(l[d],S):void 0;o.set(d,b?{field:b,optional:!b.required,required:!!b.required}:c())};for(let d of s)if("create"in d){let c=i.kinds[d.create],S=c?gn(c,In(c)):[],b=v=>S.includes(v)?S.indexOf(v):S.length;for(let[v,x]of Object.entries(d.set??{}).sort(([A],[$])=>b(A)-b($))){let A=F(x),$=c?.fields[v];if(A&&$){let C=!!$.required&&$.default===void 0;m(A,()=>({field:$,optional:!C,required:C}),$)}}d.as&&u.set(d.as,d.create)}else if("connect"in d||"sever"in d){let c="connect"in d?d.connect:d.sever,S=t.get(c),b=F(d.from)==="subject"&&a.length>0?a.map(x=>Q(i.kinds[x]?.edges)[c]?.to):[],v=b.length>0&&b.every(Boolean)?b.includes("*")?"*":[...new Set(b.flat())]:void 0;for(let[x,A]of[["from",d.from],["to",d.to]]){let $=F(A);if(!$)continue;let C=x==="to"?v??S?.to??"*":S?.from??"*";C!=="*"&&!f.has($)&&f.set($,C),m($,()=>({ref:C,required:!0}))}}else if("through"in d){let c=Ae(i.kinds,d.through,a),S=c&&c.kinds!=="*"?c.kinds[0]:void 0;for(let[b,v]of Object.entries(d.set)){let x=F(v);if(!x||x==="to")continue;let A=S?i.kinds[S]?.fields[b]:void 0;m(x,()=>A?{field:A,optional:!0,required:!1}:{any:!0,required:!1},A)}}else if("set"in d){let c=F(d.target??"$subject"),S=c==="subject"?a[0]:u.get(c??"")??f.get(c??"")?.[0];c&&c!=="subject"&&!u.has(c)&&m(c,()=>({ref:"*",required:!0}));for(let[b,v]of Object.entries(d.set)){let x=F(v);if(!x)continue;let A=S?i.kinds[S]?.fields[b]:void 0;m(x,()=>A?{field:A,optional:!r,required:r}:{any:!0,required:!1},A)}}else if("remove"in d){let c=F(d.remove);c&&m(c,()=>({ref:"*",required:!0}))}for(let[d,c]of Object.entries(l))o.has(d)||o.set(d,{field:c,optional:!c.required,required:!!c.required});return o}function Wt(e,s={}){let i=Mn(e);if(!i.document||ze(i.findings))return{ok:!1,findings:i.findings};let t=i.document,o=[...i.findings];s.previous&&o.push(...Gn(t,s.previous));let a=Ln(t,o);return ze(a.findings)?{ok:!1,findings:a.findings}:We(a,s)}function de(e,s,i){return e.map(t=>{if(t.format||t.expr?.t!=="ident")return t;let o=t.expr.name,a=i?.[o],u=s?.[o]??(typeof a=="object"?a:void 0),f=u?.format;return f==="money"||f==="percent"?{...t,format:f,...f==="money"&&u?.places===0?{formatArgs:["0"]}:{}}:t})}function Pn(e,s,i){let t=i.kinds[e]?.edges?.[s.via]!==void 0?"to":"from",o=i.kinds[s.from],a=[],u={};for(let[f,g]of Object.entries(s.set))if(fe(g)&&"expr"in g){let l=J(g.expr);a.push([f,{expr:l}]),l.t==="ident"&&o?.fields[l.name]&&(u[f]=l.name)}else a.push([f,{value:typeof g=="string"&&g.startsWith("$$")?g.slice(1):g}]);return{from:s.from,via:s.via,sourceEnd:t,set:a,back:u}}function Ln(e,s){let i=zn(e),t={},o=un(e.connections,e.kinds);for(let[r,p]of Object.entries(e.kinds)){let y=ke(p),m=p.label??(y?`{${y}}`:void 0),d=se(p),c=d?pn(e,r,[...d]):[];t[r]={...m?{label:de(ee(m),p.fields,p.computed)}:{},...p.describe?{describe:de(ee(p.describe),p.fields,p.computed)}:{},...d?{computed:[...d]}:{},...c.length>0?{durations:c}:{},...o.has(r)?{keptInStep:o.get(r)}:{},...p.derives?{derives:Pn(r,p.derives,e)}:{}}}let a={};for(let[r,p]of Object.entries(e.acts??{})){let y=yn(p,e),m=Kn(p,y,e,i),d=p.destructive??y.some(z=>"remove"in z||"sever"in z||"replace"in z),c=[...new Set(y.flatMap(z=>"create"in z?[z.create]:[]))],S=[...new Set(y.flatMap(z=>"connect"in z?[z.connect]:[]))],b=[...new Set(y.flatMap(z=>"sever"in z?[z.sever]:"replace"in z?z.replace:[]))],v=[...new Set(y.flatMap(z=>"set"in z&&!("create"in z)&&!("through"in z)&&F(z.target??"$subject")==="subject"?Object.keys(z.set):[]))],x=new Map;for(let z of y){if(!("connect"in z)&&!("sever"in z))continue;let E=i.get("connect"in z?z.connect:z.sever);for(let[M,ie]of[["from",z.from],["to",z.to]]){let W=F(ie),V=M==="to"?E?.to:E?.from;W&&W!=="subject"&&V&&V!=="*"&&x.set(W,[...new Set([...x.get(W)??[],...V])])}}let A={};for(let z of y){if(!("set"in z)||"create"in z||"through"in z)continue;let E=F(z.target??"$subject");for(let M of E&&E!=="subject"&&x.get(E)||[])A[M]=[...new Set([...A[M]??[],...Object.keys(z.set)])]}let $={};for(let z of y)if(!(!("set"in z)||"create"in z||"through"in z||F(z.target??"$subject")!=="subject"))for(let[E,M]of Object.entries(z.set??{}))typeof M=="string"&&F(M)===void 0||typeof M=="number"||typeof M=="boolean"?$[E]=typeof M=="string"&&M.startsWith("$$")?M.slice(1):M:delete $[E];let C=c.length===0&&y.every(z=>!("set"in z)||!z.set||Object.values(z.set).every(E=>!(E&&typeof E=="object"&&!Array.isArray(E)&&"expr"in E))),q=new Map;for(let z of y)if(!(!("set"in z)||!z.set))for(let E of Object.values(z.set))E&&typeof E=="object"&&!Array.isArray(E)&&"expr"in E&&q.set(E.expr,J(E.expr));a[r]={title:p.title??r.replace(/-/g," "),effects:y,args:[...m],...p.allowedWhen?{guard:J(p.allowedWhen)}:{},...p.refusal?{refusal:de(ee(p.refusal),e.kinds[[p.on??[]].flat()[0]??""]?.fields)}:{},exprs:[...q],destructive:d,idempotent:C,creates:c,connects:S,severs:b,writes:v,writesOther:A,sets:$}}let u={};for(let[r,p]of Object.entries(e.rules??{})){let y=p.covers&&p.over!=="graph"?ye(p.over,p.covers,m=>i.get(m),m=>m in e.kinds):void 0;u[r]={title:p.title??r.replace(/-/g," "),...p.require?{require:J(p.require)}:{},...y&&"plan"in y?{covers:y.plan}:{},...p.when?{when:J(p.when)}:{},...p.says?{says:de(ee(p.says),e.kinds[p.over]?.fields)}:{}}}let f=Ze(e,s),g=Je(e),l=Xe(e);return{format:He,document:e,findings:s,kinds:t,...e.computed?{facts:[...se(e)??[]]}:{},edges:[...i].map(([r,{from:p,to:y,cardinality:m}])=>[r,{from:p,to:y,cardinality:m}]),acts:a,rules:u,brand:f,...Object.keys(g).length>0?{viewSpecs:g}:{},...l?{home:l}:{}}}function Yt(e,s,i){let t=/^defineNode\("([^"]+)"\)/.exec(s)?.[1],o=t?i.kinds[t]:void 0;if(!t||!o)return e;let a=Object.keys(o.fields).filter(u=>u!=="label").slice(0,3);return{...e,path:`kinds.${t}.glance`,fix:`Say which: "glance": [${a.map(u=>`"${u}"`).join(", ")}] on kinds.${t} \u2014 the facts a person compares one by, at a glance.`}}function Gn(e,s){let i=[],t=new Set(Object.values(s.kinds).flatMap(o=>Object.keys(o.edges??{})));for(let[o,a]of Object.entries(e.kinds)){let u=a.renamedFrom;u&&!s.kinds[u]&&i.push(k("renamed-from-nothing",`kinds.${o}.renamedFrom`,`${o} says it was ${u}, and the previous version has no kind called ${u}`,"name the kind it was, or drop renamedFrom"));let f=s.kinds[u??o];for(let[g,l]of Object.entries(a.fields)){let r=l.renamedFrom;r&&!f?.fields[r]&&i.push(k("renamed-from-nothing",`kinds.${o}.fields.${g}.renamedFrom`,`${g} says it was ${r}, and the previous ${u??o} has no field called ${r}`,"name the field it was, or drop renamedFrom"))}for(let[g,l]of Object.entries(a.edges??{})){let r=l.renamedFrom;r&&!t.has(r)&&i.push(k("renamed-from-nothing",`kinds.${o}.edges.${g}.renamedFrom`,`${g} says it was ${r}, and the previous version has no relation called ${r}`,"name the relation it was, or drop renamedFrom"))}}return i}export{Mn as a,Ht as b,yn as c,Wt as d,Yt as e};
1
+ import{a as fe,b as Ne,d as Ze,e as He,f as he,g as F,h as ke,j as We}from"./chunk.6N4PE3U5.js";import{h as Je,i as Xe,j as Qe}from"./chunk.WALVW3KJ.js";import{a as ae,b as ce,c as J,d as Ye,e as ee,g as se,h as en}from"./chunk.UGQYMN4J.js";import{c as Be,h as k,i as Ue,j as ze,t as ye}from"./chunk.RG5G6YQD.js";import{A as re,Ia as Ie,Ld as qe,Md as Ve,Pa as Ke,Qa as Q,Ra as me,b as Z,c as U,e as ue,f as Me,g as P,h as O,ic as Pe,jc as ge,k as L,kc as Le,l as X,lc as Ge,m as _,mc as Ce,n as _e,o as H,p as I,r as $,s as oe,t as R,u as j,v as G,w as T,x as n,y as N,z as Y}from"./chunk.ZEZUKRC6.js";var be=e=>Object.entries(e).map(([s,i])=>[s,Object.keys(Q(i?.edges))]),we=(e,s)=>Le(e,be(s));function nn(e){return[...Object.keys(e.acts??{}),...Object.keys(e.kinds).flatMap(s=>Pe(s)),...Ge(be(e.kinds))]}var B=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function tn(e){if(!B(e)||!B(e.kinds))return e;let s;try{let f=Object.fromEntries(Object.entries(e.kinds).map(([g,l])=>[g,B(l)&&B(l.edges)?{edges:l.edges}:{}]));s=nn({acts:B(e.acts)?e.acts:{},kinds:f})}catch{return e}let i=new Set(s),t=!1,o=f=>{if(typeof f!="string"||i.has(f))return f;let g=qe(f,s);return g===void 0?f:(t=!0,g)},a=B(e.policy)&&Array.isArray(e.policy.grants)?{...e.policy,grants:e.policy.grants.map(f=>B(f)&&Array.isArray(f.mutations)?{...f,mutations:f.mutations.map(o)}:f)}:void 0,u=B(e.rules)?Object.fromEntries(Object.entries(e.rules).map(([f,g])=>[f,B(g)&&Array.isArray(g.repairs)?{...g,repairs:g.repairs.map(l=>B(l)?{...l,act:o(l.act)}:l)}:g])):void 0;return t?{...e,...a?{policy:a}:{},...u?{rules:u}:{}}:e}function $e(e,s){let i=Ve(e,nn(s));return i&&i!==e?`did you mean "${i}"?`:void 0}var Oe="graview-document",je=1,xe=256*1024,ne=64*1024,vn=["plain","editorial","shader","ascii"];var Se=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,ve=/^[a-z][A-Za-z0-9]*$/,On=/^[a-z0-9\u00df-\u00ff'-]+( [a-z0-9\u00df-\u00ff'-]+){0,2}$/,on=12,sn=60,jn=new Set(["id","kind"]),xn=/^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|[a-z][A-Za-z0-9]*)$/,An=["string","text","number","integer","boolean","date","datetime","enum","list","url","email","image","video","file","app-link","phone","place","duration"];function En(){let e=h=>h in Object.prototype,s=Y(h=>!e(h),"every object already has this name \u2014 choose another"),i=(h,D)=>[...h===void 0?[]:[Me(h)],...D===void 0?[]:[ue(D)]],t=(h,D)=>O().check(...i(h,D)),o=(h,D,te)=>I(h).check(...i(D,te)),a=h=>O().check(P(Se,`${h} names are kebab-case, lower-case words joined by hyphens like "tool-note" (field and relation names are camelCase, like "supersededBy")`)),u=O().check(P(xn,'relation names are one camelCase word, like "supersededBy" (kind names are kebab-case, like "tool-note")'),s),f=O().check(P(ve,'field names are one word or camelCase, like "dueDate", so rules say them bare (kind names are kebab-case, like "tool-note")'),Y(h=>!jn.has(h),'a field cannot be called "id" or "kind" \u2014 the framework keeps those; try "type" or "category"'),s),g=t(1,500),l=O().check(ue(40),P(On,'an alias is up to three lower-case words, like "supplier"')),r=t(1,2e3),p=t(1,300),y=$({type:G(An),required:n(_()),description:n(g),label:n(t(1,60)),aliases:n(o(l,1,on)),options:n(o(t(1,80),1,100)),multiple:n(_()),optionLabels:n(j(t(1,80),t(1,80))),of:n(G(["string","number","date","image","video","file"])),default:n(H()),unit:n(t(void 0,12)),format:n(G(["money","percent","duration","markdown"])),places:n(T(0)),min:n(L()),max:n(L()),step:n(L()),renamedFrom:n(O().check(P(ve))),repeats:n(_()),collaborative:n(_())}).check(re((h,D)=>{h.type==="enum"&&!h.options&&D.addIssue({code:"custom",message:'an enum field lists its "options"',path:["options"]}),h.type!=="enum"&&h.options&&D.addIssue({code:"custom",message:'"options" belongs only on an enum field',path:["options"]}),h.type!=="enum"&&h.multiple!==void 0&&D.addIssue({code:"custom",message:'"multiple" belongs only on an enum field: a choice that takes several of its options',path:["multiple"]});for(let te of Object.keys(h.optionLabels??{}))h.options?.includes(te)||D.addIssue({code:"custom",message:`"${te}" is labeled, and is none of the field's options`,path:["optionLabels",te]});h.type!=="list"&&h.of&&D.addIssue({code:"custom",message:'"of" belongs only on a list field',path:["of"]}),h.places!==void 0&&!(h.format==="money"||!h.format&&/^[A-Z]{3}$/.test(h.unit??""))&&D.addIssue({code:"custom",message:'"places" belongs only on money: a number field with "format": "money"',path:["places"]}),h.repeats&&h.type!=="date"&&h.type!=="datetime"&&D.addIssue({code:"custom",message:'"repeats" belongs only on a date or datetime field',path:["repeats"]})})),m=O().check(P(new RegExp(`${Se.source}|${Ie.source}`),'a relation goes to a kind of this document, like "house", or of another app, like "@nick/house/house"')),d=$({to:R([o(m,1),T("*")]),cardinality:n(G(["one","many"])),description:n(g),inverse:n(t(1,80)),appendOnly:n(_()),renamedFrom:n(O()),tidying:n(T("never"))}),c=R([r,$({expr:r,label:n(t(1,60)),description:n(g),format:n(G(["money","percent","duration"])),unit:n(t(1,12)),places:n(T(0)),hidden:n(_())})]),S=R([O(),L(),_(),_e(),I(H()),$({expr:r})]),b=$({noun:n(t(1,40)),plural:n(t(1,40)),aliases:n(o(l,1,on)),description:n(g),fields:j(f,y).check(Y(h=>Object.keys(h).length>0,"a kind has at least one field")),label:n(p),describe:n(p),lifecycle:n($({field:f,retired:o(R([O(),L(),_()]),1)})),figure:n(t(void 0,2e4)),glance:n(o(f,1,20)),page:n($({fields:n(o(f,1,40)),groups:n(o($({title:t(1,60),fields:o(f,1,40)}),1,12))})),edges:n(j(u,d)),computed:n(j(O(),c).check(Y(h=>Object.keys(h).length<=sn,`a kind works out at most ${sn} computed fields`))),fieldRoles:n(j(O(),O())),renamedFrom:n(O().check(P(Se))),people:n(_()),archives:n(T(!1)),tidying:n(G(["never","no-links"])),derives:n($({from:a("kind"),via:u,set:j(f,S)}))}),v=O().check(P(/^\$[A-Za-z][A-Za-z0-9]*$/,'a reference is "$" and a name, like "$subject" or "$new"')),x=R([$({create:a("kind"),as:n(O().check(P(ve))),set:n(j(f,S))}),$({set:j(f,S),target:n(v)}),$({connect:u,from:v,to:v}),$({sever:u,from:v,to:v}),$({remove:v})]),A=$({title:n(t(1,80)),description:n(g),fromTheOtherEnd:n(t(1,80)),on:n(R([a("kind"),o(a("kind"),1)])),creates:n(a("kind")),sets:n(j(f,S)),writes:n(o(f,1)),connects:n(u),severs:n(u),setsOther:n(j(f,S)),setsLinked:n(j(u,j(f,S))),replaces:n(R([T(!0),o(u,1,10)])),removes:n(T(!0)),args:n(j(f,y)),effects:n(o(x,1,20)),allowedWhen:n(r),refusal:n(p),destructive:n(_())}),w=$({act:a("act"),label:n(t(1,80)),args:n(j(O(),S))}),C=$({every:a("kind"),through:u,via:n(u)}),q=$({title:n(t(1,120)),description:n(g),over:R([T("graph"),a("kind")]),when:n(r),require:n(r),covers:n(C),says:n(p),repairs:n(o(w,void 0,10))}).check(re((h,D)=>{!h.require&&!h.covers&&D.addIssue({code:"custom",message:'a rule says what must hold in "require", or what each record must be linked to in "covers"',path:["require"]}),h.require&&h.covers&&D.addIssue({code:"custom",message:'a rule is judged by "require" or by "covers", not both',path:["covers"]}),h.covers&&h.over==="graph"&&D.addIssue({code:"custom",message:'a coverage rule is over a kind, whose records it follows through their links; name the kind in "over"',path:["over"]})})),z=$({roles:R([o(a("role"),1),T("*")]),mutations:R([o(a("act")),T("*")]),kinds:n(R([I(a("kind")),T("*")])),describe:n(g),self:n(_()),ownEnd:n(_()),propose:n(R([o(a("act"),1),T("*")]))}).check(re((h,D)=>{Array.isArray(h.mutations)&&h.mutations.length===0&&h.propose===void 0&&D.addIssue({code:"custom",message:'a grant names at least one act in "mutations", or the acts it lets these roles propose in "propose"',path:["mutations"]})})),E=n(o(f,1)),M=$({roles:R([o(a("role"),1),T("*")]),kinds:o(a("kind"),1),own:n(_()),via:n(u),fields:E,hide:E}),ie=$({grants:I(z),sees:n(I(M))}),W=$({accent:n(O().check(P(/^#[0-9a-fA-F]{6}$/,'an accent is a color like "#c2577a"'))),ground:n(R([O().check(P(/^#[0-9a-fA-F]{6}$/,'a ground is a color like "#eef3f8"')),$({light:n(O().check(P(/^#[0-9a-fA-F]{6}$/,'a ground is a color like "#eef3f8"'))),dark:n(O().check(P(/^#[0-9a-fA-F]{6}$/,'a ground is a color like "#101826"')))})])),name:n(t(1,60)),currency:n(O().check(P(/^[A-Z]{3}$/,'a currency is its three-letter code, like "USD" or "EUR"'))),locale:n(t(2,35)),timeZone:n(t(1,64)),logo:n(R([t(1,ne),$({src:t(1,ne),alt:n(t(1,120))}),$({light:t(1,ne),dark:n(t(1,ne)),alt:n(t(1,120)),darkFallback:n(T("invert"))})])),favicon:n(R([t(1,ne),$({emoji:O()})])),typography:n($({display:n(t(1,200)),body:n(t(1,200)),mono:n(t(1,200))})),shape:n($({radius:n(L().check(U(0),Z(32))),density:n(L().check(U(.75),Z(1.5)))})),accents:n(j(O(),L().check(U(0),Z(360)))),scheme:n(G(["light","dark","auto"])),subtitle:n(T(!1)),splash:n($({style:G(vn),image:n(t(1,ne)),title:n(t(1,80)),kicker:n(t(1,80)),shader:n(t(1,40)),scheme:n(G(["light","dark","device"]))})),views:n($({css:n(t(1)),motion:n(G(["none","fade"]))}))}),V=j(O(),H()),Fe=R([t(1,120),$({by:t(1,120),direction:n(G(["asc","desc"]))})]),De=L().check(X(),U(1),Z(9999)),hn=oe({create:n(_()),options:n(oe({sort:n(Fe),columnSort:n(Fe),search:n(o(t(1,120),void 0,40)),filters:n(o(t(1,120),void 0,40)),horizon:n(R([L().check(X(),U(1),Z(200)),oe({years:L().check(X(),U(1),Z(200)),title:t(1,80),from:n(De),to:n(De)})]))}))}),kn=$({card:n(I(H())),row:n(I(H())),page:n(I(H()))}),bn=()=>{let h=n(G(["asc","desc"]));return R([t(1,120),$({by:t(1,120),direction:h,then:n(R([t(1,120),$({by:t(1,120),direction:h})]))})])},wn=()=>R([t(1,120),$({by:t(1,120),order:n(o(t(1,80),void 0,40)),closed:n(o(t(1,80),void 0,40))})]),Te=oe({order:n(I(O())),hide:n(I(O())),first:n(O()),primary:n(o(t(1,80),void 0,40)),scene:n(t(1,40)),pages:n(t(1,40)),lists:n(j(O(),$({filters:n(o(t(1,120),void 0,40)),sort:n(bn()),group:n(wn()),export:n(_())})))}),$n=$({act:a("act"),title:n(t(1,80)),intro:n(g),fields:n(o(f,1,40)),say:n(g),submit:n(t(1,80)),role:n(a("role"))}),Sn=$({$schema:n(O()),format:T(Oe),formatVersion:T(je),name:t(1,80),description:n(g),version:n(L().check(X(),U(1))),kinds:j(a("kind"),b).check(Y(h=>Object.keys(h).length>0,"a document declares at least one kind"),Y(h=>Object.keys(h).length<=40,"a document declares at most 40 kinds")),computed:n(j(O(),c)),acts:n(j(a("act"),A)),rules:n(j(a("rule"),q)),roles:n(I(a("role"))),policy:n(ie),modules:n(V),lenses:n(I(hn)),pages:n(Te),views:n(j(O(),R([kn,I(H())]))),brand:n(W),settings:n(I(V)),migrations:n(I(V)),connections:n(j(a("connection"),V)),purpose:n(V),workflows:n(j(a("workflow"),V)),forms:n(j(a("form"),$n)),publishing:n($({mode:G(["live","on-publish"]),working:o(a("role"),void 0,40),publishers:n(o(a("role"),1,40))})),tidying:n($({autoAcceptAt:n(L().check(X(),U(1),Z(1e4)))}))});return{FieldSpec:y,EdgeSpec:d,ComputedSpec:c,KindSpec:b,ValueSpec:S,EffectSpec:x,ActSpec:A,RepairSpec:w,CoverSpec:C,RuleSpec:q,GrantSpec:z,SightSpec:M,PolicySpec:ie,BrandSpec:W,PagesSpec:Te,DocumentSpec:Sn}}var Rn,K=()=>Rn??=En(),Xn=N(()=>K().FieldSpec),Qn=N(()=>K().EdgeSpec),et=N(()=>K().ComputedSpec),nt=N(()=>K().KindSpec),tt=N(()=>K().ValueSpec),ot=N(()=>K().EffectSpec),st=N(()=>K().ActSpec),it=N(()=>K().RepairSpec),rt=N(()=>K().CoverSpec),at=N(()=>K().RuleSpec),ct=N(()=>K().GrantSpec),lt=N(()=>K().SightSpec),dt=N(()=>K().PolicySpec),pt=N(()=>K().BrandSpec),ft=N(()=>K().PagesSpec),rn=N(()=>K().DocumentSpec);var Fn={};function an(e,s=Fn,i=je){let{document:t,respelled:o}=Ne(e),a=o.length>0?{respelled:o}:{};if(!t||typeof t!="object"||Array.isArray(t))return{document:t};let u=t;if(u.format!==Oe||typeof u.formatVersion!="number"||u.formatVersion>=i)return{document:t,...a};let f=u.formatVersion,g=structuredClone(u);for(let l=f;l<i;l++){let r=s[l];if(!r)throw new Error(`there is no upgrade from format ${l} to ${l+1}`);g={...r(g),formatVersion:l+1}}return{document:g,from:f,...a}}function Ae(e,s,i){let t=Object.keys(e).filter(f=>e[f].edges?.[s]!==void 0);if(t.length===0)return;let o=t.map(f=>e[f].edges[s].to),a=o.some(f=>f==="*")?"*":[...new Set(o.flatMap(f=>f))];if(i.length===0||i.some(f=>t.includes(f)))return{reversed:!1,kinds:a};let u=t.filter(f=>{let g=e[f].edges[s].to;return g==="*"||i.every(l=>g.includes(l))});return u.length>0?{reversed:!0,kinds:u}:{reversed:!1,kinds:a}}var dn=(e,s)=>{let i=e?.fields[s];return i!==void 0&&(i.type==="duration"||(i.type==="number"||i.type==="integer")&&i.format==="duration")};function cn(e,s,i,t){if(t==="out"){let o=e[s]?.edges?.[i]?.to;return o===void 0?[]:o==="*"?Object.keys(e):o}return Object.entries(e).filter(([,o])=>{let a=o.edges?.[i]?.to;return a!==void 0&&(a==="*"||a.includes(s))}).map(([o])=>o)}function Ee(e,s,i){if(i.t==="ident")return e[s]?.edges?.[i.name]?cn(e,s,i.name,"out"):void 0;if(i.t==="where")return Ee(e,s,i.set);if(i.t==="call"&&(i.fn==="out"||i.fn==="in")&&i.args[0]?.t==="lit"&&typeof i.args[0].value=="string")return cn(e,s,i.args[0].value,i.fn)}var ln=(e,s,i)=>{let t=s.filter(o=>e[o]?.fields[i]!==void 0);return t.length>0&&t.every(o=>dn(e[o],i))};function pn(e,s,i){let t=e.kinds,o=t[s],a=new Map(i),u=new Map,f=(l,r)=>{if(r>8)return!1;switch(l.t){case"ident":return dn(o,l.name)||g(l.name,r+1);case"member":{let p=Ee(t,s,l.object);return p!==void 0&&ln(t,p,l.name)}case"call":{if(l.fn!=="sum"&&l.fn!=="min"&&l.fn!=="max")return!1;let[p,y]=l.args,m=p&&Ee(t,s,p);return m!==void 0&&y?.t==="ident"&&ln(t,m,y.name)}case"binary":return(l.op==="+"||l.op==="-")&&f(l.left,r)&&f(l.right,r);case"unary":return l.op==="-"&&f(l.operand,r);default:return!1}},g=(l,r)=>{if(o?.computed?.[l]===void 0)return!1;if(u.has(l))return u.get(l);u.set(l,!1);let p=a.get(l),y=p!==void 0&&f(p,r);return u.set(l,y),y};return i.map(([l])=>l).filter(l=>g(l,0))}var Dn="several choices";var Tn={title:["string","text"],rich_text:["string","text"],number:["number","integer"],select:["enum","string"],status:["enum","string"],multi_select:["list",Dn],date:["date","datetime"],checkbox:["boolean"],url:["url","string"],email:["email","string"],phone_number:["phone","string"],people:["string","text","list"]};var fn=new Set(Object.values(Tn).flat());function un(e,s){let i=new Map;if(!e||typeof e!="object")return new Map;let t=Object.values(e).flatMap(o=>o&&typeof o=="object"&&o.system==="notion"&&Array.isArray(o.sources)?o.sources.filter(a=>a&&typeof a=="object").map(a=>({system:"notion",kind:a.kind,properties:a.properties})):[o]);for(let o of t){if(!o||typeof o!="object"||typeof o.kind!="string")continue;let a=s[o.kind]?.fields;if(!a)continue;let u=[];o.system==="google-calendar"&&o.fields&&typeof o.fields=="object"?u=Object.values(o.fields).filter(g=>typeof g=="string"):o.system==="notion"&&(u=o.properties&&typeof o.properties=="object"?Object.keys(o.properties):Object.keys(a).filter(g=>fn.has(a[g].type)));let f=i.get(o.kind)??new Set;for(let g of u)Object.hasOwn(a,g)&&f.add(g);i.set(o.kind,f)}return new Map([...i].filter(([,o])=>o.size>0).map(([o,a])=>[o,Object.keys(s[o].fields).filter(u=>a.has(u))]))}function mn(e,s,i=`kinds.${e}.page`){let t=s.page;if(!t)return[];let o=[],a=[...Object.keys(s.fields),...Object.keys(s.computed??{})],u=new Set,f=(l,r)=>{a.includes(l)?u.has(l)&&o.push(k("page-field-twice",r,`"${l}" is on ${e}'s page twice; name each field once`)):o.push(k("page-field",r,`${e}'s page is to show "${l}", and ${e} has no field or computed field called that`,`use one of: ${a.join(", ")}`)),u.add(l)};(t.fields??[]).forEach((l,r)=>f(l,`${i}.fields.${r}`));let g=new Set;return(t.groups??[]).forEach((l,r)=>{let p=l.title.trim().toLowerCase();g.has(p)&&o.push(k("page-group-twice",`${i}.groups.${r}.title`,`${e}'s page has two groups called "${l.title}"; give each its own title`)),g.add(p),l.fields.forEach((y,m)=>f(y,`${i}.groups.${r}.fields.${m}`))}),o}function gn(e,s=[]){return Ce({declared:Object.keys(e.fields),paged:[...e.page?.fields??[],...(e.page?.groups??[]).flatMap(i=>i.fields)],must:i=>!!e.fields[i].required&&e.fields[i].default===void 0,naming:s})}var Nn=new Set(["subject","now","today","me"]);function Mn(e){if((typeof e=="string"?e:JSON.stringify(e??null)).length>xe)return{findings:[k("too-large","",`a document may be at most ${xe/1024} KB`)]};if(typeof e=="string")try{e=JSON.parse(e)}catch(t){return{findings:[k("not-json","",`this is not JSON: ${t.message}`)]}}try{e=an(e).document}catch(t){return{findings:[k("format","formatVersion",t.message)]}}e=tn(e);let s=rn.safeParse(e);if(!s.success)return{findings:s.error.issues.map(t=>{let o=t.path.map(String).join(".");if(t.code==="unrecognized_keys")return k("unknown-key",o,`${t.keys.map(a=>`"${a}"`).join(", ")} ${t.keys.length===1?"is":"are"} not part of a Graview document here`,"check the spelling against docs/declaration-document.md");if(t.code==="invalid_union"&&/\.effects\.\d+$/.test(o))return k("effect-shape",o,"this effect is not one Graview knows",'an effect is one of {"create": kind, "as"?: name, "set"?: {field: value}}, {"set": {field: value, \u2026}, "target"?: "$ref"}, {"connect"|"sever": relation, "from": "$ref", "to": "$ref"}, {"remove": "$ref"}');if(t.code==="invalid_key"){let a=t.issues?.[0]?.message;return k("shape",o,`the name "${String(t.path.at(-1))}" is not allowed here${a?`: ${a}`:""}`)}return k("shape",o,t.message)})};let i=s.data;return{document:i,findings:_n(i)}}var pe=e=>[e??[]].flat();function zn(e){let s=new Map;for(let[i,t]of Object.entries(e.kinds))for(let[o,a]of Object.entries(Q(t.edges))){let u=s.get(o);s.set(o,{name:o,from:[...u?.from??[],i],to:a.to==="*"||u?.to==="*"?"*":[...new Set([...u?.to??[],...a.to])],cardinality:a.cardinality??"many"})}return s}function Ht(e){let s=new Map;for(let[t,o]of Object.entries(e.kinds)){let a=se(o),u=me(o.edges);s.set(t,{fields:new Set([...Object.keys(o.fields),...u.keys()]),edges:new Map(Object.entries(Q(o.edges)).map(([f,g])=>[f,g.cardinality??"many"])),...a?{computed:a}:{},...u.size>0?{linked:u}:{}})}let i=se(e);return i&&s.set(Be,{computed:i}),s}function yn(e,s){let i=[],t=pe(e.on),o=(a,u)=>{let f=Ae(s.kinds,a,t)?.reversed===!0,[g,l]=f?["$to","$subject"]:["$subject","$to"];return u==="connect"?{connect:a,from:g,to:l}:{sever:a,from:g,to:l}};if(e.creates){let a=s.kinds[e.creates],u={};for(let f of Object.keys(a?.fields??{}))u[f]=`$${f}`;for(let f of e.effects??[])"set"in f&&!("create"in f)&&F(f.target)==="new"&&Object.assign(u,f.set);i.push({create:e.creates,as:"new",set:u})}if(e.sets&&i.push({set:e.sets}),e.writes&&!(e.creates&&e.on===void 0)&&i.push({set:Object.fromEntries(e.writes.map(a=>[a,`$${a}`]))}),e.connects&&(e.replaces&&i.push({replace:e.replaces===!0?[e.connects]:[...e.replaces],keep:e.connects}),i.push(o(e.connects,"connect"))),e.severs&&i.push(o(e.severs,"sever")),e.setsOther&&(e.connects||e.severs)&&i.push({set:e.setsOther,target:"$to"}),e.setsLinked&&t.length>0)for(let[a,u]of Object.entries(e.setsLinked))i.push({set:u,through:a});return e.removes&&i.push({remove:"$subject"}),e.effects&&i.push(...e.effects.filter(a=>!(e.creates&&"set"in a&&!("create"in a)&&F(a.target)==="new"))),i}function le(e,s,i){try{let t=J(e),o=ae(t);for(let a of o.unknownFunctions)i.push(k("unknown-function",s,`"${a}" is not a function the rule language knows`,"see the rule language in the graview-invariant skill"));return t}catch(t){if(t instanceof ce){i.push(k("expression",s,t.sentence+` (at character ${t.at+1})`));return}throw t}}function Re(e,s,i){try{return ee(e)}catch(t){if(t instanceof Ye||t instanceof ce){i.push(k("template",s,(t instanceof ce,t.sentence)));return}throw t}}function _n(e){let s=[],i=new Set(Object.keys(e.kinds)),t=zn(e),o=e.acts??{},a=new Set(e.roles??[]),u=(l,r)=>me(e.kinds[l]?.edges).has(r),f=l=>Object.keys(e.kinds).some(r=>u(r,l));for(let[l,r]of Object.entries(e.kinds)){let p=`kinds.${l}`;for(let[m,d]of Object.entries(r.edges??{})){if(!Ke(d)&&d.to!=="*")for(let c of d.to)i.has(c)||s.push(k("edge-target",`${p}.edges.${m}.to`,`"${c}" is not a kind this document declares`));r.fields[m]&&s.push(k("edge-field-clash",`${p}.edges.${m}`,`"${m}" is both a field and a relation of ${l}`,"rename one of them"))}r.lifecycle&&!r.fields[r.lifecycle.field]&&s.push(k("lifecycle-field",`${p}.lifecycle.field`,`${l} has no field "${r.lifecycle.field}"`));let y=m=>r.computed!==void 0&&Object.hasOwn(r.computed,m);for(let m of r.glance??[])!r.fields[m]&&!y(m)&&s.push(k("glance-field",`${p}.glance`,`a glance at ${l} is to say "${m}", and ${l} has no field or computed field called that`,`use one of: ${[...Object.keys(r.fields),...Object.keys(r.computed??{})].join(", ")}`));s.push(...mn(l,r));for(let m of["label","describe"]){let d=r[m];if(!d)continue;let c=Re(d,`${p}.${m}`,s);for(let S of c??[])if(S.expr){for(let b of ae(S.expr).names)if(!r.fields[b]){if(y(b)){en(r,b)||s.push(k("template-field",`${p}.${m}`,`${l}'s ${b} is worked out from beyond the record, and a ${m} is said with no graph to read`,`show it in a view instead, or name a computed field worked out from ${l}'s own fields`));continue}s.push(k("template-field",`${p}.${m}`,`${l} has no field "${b}" for its ${m} to show`,m==="label"?"a label can only show the record's own fields and what they work out":void 0))}}}for(let[m,d]of Object.entries(r.derives?.set??{}))fe(d)&&"expr"in d&&le(String(d.expr),`${p}.derives.set.${m}`,s);for(let[m,d]of Object.entries(r.fields)){if(d.default!==void 0&&d.type==="enum"){let b=(d.multiple?Array.isArray(d.default)?d.default:[d.default]:[d.default]).find(v=>!d.options?.includes(String(v)));(b!==void 0||!d.multiple&&Array.isArray(d.default))&&s.push(k("default-option",`${p}.fields.${m}.default`,`"${String(b??d.default)}" is not one of ${m}'s options`))}let c=`${m}Repeat`;d.repeats&&(r.fields[c]||r.edges?.[c]||r.computed?.[c])&&s.push(k("repeat-clash",`${p}.fields.${m}.repeats`,`${l} already has "${c}", where how ${m} repeats is kept`))}}for(let[l,r]of Object.entries(o)){let p=`acts.${l}`;for(let c of pe(r.on))i.has(c)||s.push(k("act-kind",`${p}.on`,`"${c}" is not a kind this document declares`));let y=pe(r.on),m=yn(r,e);if(r.creates&&r.on===void 0&&r.writes&&i.has(r.creates)){for(let c of r.writes)if(!e.kinds[r.creates].fields[c])if(e.kinds[r.creates].computed?.[c]!==void 0)s.push(k("computed-written",`${p}.writes`,`${r.creates}'s ${c} is worked out, not written: no act can set it`,"write the stored fields it is worked out from"));else{if(u(r.creates,c))continue;s.push(k("act-field",`${p}.writes`,`${r.creates} has no field "${c}"`))}}m.length===0&&s.push(k("act-empty",p,`"${l}" does nothing`,"give it effects or a shorthand such as sets or creates"));let d=new Map;m.forEach((c,S)=>{let b=m.length-(r.effects?.length??0),v=r.effects&&S>=b?`${p}.effects.${S-b}`:p;if("create"in c){if(!i.has(c.create))s.push(k("act-kind",`${v}.create`,`"${c.create}" is not a kind this document declares`));else for(let w of Object.keys(c.set??{}))e.kinds[c.create].fields[w]||(e.kinds[c.create].computed?.[w]!==void 0?s.push(k("computed-written",`${v}.set.${w}`,`${c.create}'s ${w} is worked out, not written: no act can set it`,"set the stored fields it is worked out from")):s.push(k("act-field",`${v}.set.${w}`,`${c.create} has no field "${w}"`)));c.as&&d.set(c.as,c.create)}else if("connect"in c||"sever"in c){let w="connect"in c?c.connect:c.sever;!t.has(w)&&!f(w)&&s.push(k("act-edge",`${v}.${"connect"in c?"connect":"sever"}`,`"${w}" is not a relation any kind declares`)),F(c.from)==="subject"&&y.length===0&&s.push(k("act-subject",`${p}.on`,`"${l}" acts on "$subject" but does not say which kinds it is "on"`))}else if(!("through"in c))if("set"in c){let w=F(c.target??"$subject"),C=w==="subject"?y:d.has(w??"")?[d.get(w)]:[];w==="subject"&&y.length===0&&s.push(k("act-subject",`${p}.on`,`"${l}" changes "$subject" but does not say which kinds it is "on"`));for(let q of Object.keys(c.set))for(let z of C)if(!(!i.has(z)||e.kinds[z].fields[q]))if(e.kinds[z].computed?.[q]!==void 0)s.push(k("computed-written",`${v}.set.${q}`,`${z}'s ${q} is worked out, not written: no act can set it`,"set the stored fields it is worked out from"));else{if(u(z,q))continue;s.push(k("act-field",`${v}.set.${q}`,`${z} has no field "${q}"`))}}else"remove"in c&&F(c.remove)==="subject"&&y.length===0&&s.push(k("act-subject",`${p}.on`,`"${l}" removes "$subject" but does not say which kinds it is "on"`));let x="set"in c&&c.set?Object.values(c.set):[],A="through"in c?`${p}.setsLinked.${c.through}`:`${v}.set`;x.forEach(w=>{w&&typeof w=="object"&&!Array.isArray(w)&&"expr"in w&&le(w.expr,A,s)})}),r.allowedWhen&&le(r.allowedWhen,`${p}.allowedWhen`,s),r.refusal&&Re(r.refusal,`${p}.refusal`,s)}for(let[l,r]of Object.entries(e.rules??{})){let p=`rules.${l}`;r.over!=="graph"&&!i.has(r.over)&&s.push(k("rule-kind",`${p}.over`,`"${r.over}" is not a kind this document declares`));let y=r.over==="graph"?void 0:e.kinds[r.over];if(r.covers&&y){let m=ye(r.over,r.covers,d=>t.get(d),d=>i.has(d));if("problem"in m){let{key:d,message:c,fix:S}=m.problem;d==="every"?s.push(k("rule-kind",`${p}.covers.every`,c,S)):s.push(k("rule-covers-relation",`${p}.covers.${d}`,c,S))}}for(let m of["when","require"]){let d=r[m];if(!d)continue;let c=le(d,`${p}.${m}`,s);if(!c)continue;let S=ae(c);for(let b of S.names)if(r.over==="graph")s.push(k("rule-name",`${p}.${m}`,`"${b}" means nothing in a rule over the whole graph`,`name a kind in "over", or use all('kind')`));else if(y&&!y.fields[b]&&!y.edges?.[b]&&y.computed?.[b]===void 0){let v=Object.keys(y.edges??{}).find(x=>x.includes("-")&&x.split("-").includes(b));s.push(k("rule-name",`${p}.${m}`,`${r.over} has no field or relation called "${b}"`,v?`"${v}" reads as a subtraction in a rule; rename the relation to one camelCase word, like "${v.replace(/-([a-z0-9])/g,(x,A)=>A.toUpperCase())}"`:void 0))}for(let b of S.edges)!t.has(b)&&!f(b)&&s.push(k("rule-edge",`${p}.${m}`,`"${b}" is not a relation any kind declares`));for(let b of S.sweeps)i.has(b)?r.over!=="graph"&&s.push(Ue("rule-cost",`${p}.${m}`,`this rule looks at every ${b} for every ${r.over}, which grows slowly as the app grows`,"walk a relation with out()/in() instead of all() where you can")):s.push(k("rule-kind",`${p}.${m}`,`"${b}" is not a kind this document declares`))}r.says&&Re(r.says,`${p}.says`,s),(r.repairs??[]).forEach((m,d)=>{!o[m.act]&&!ge(m.act)&&!we(m.act,e.kinds)&&s.push(k("repair-act",`${p}.repairs.${d}.act`,`"${m.act}" is not an act this document declares`,$e(m.act,e)))})}let g=e.policy;return g&&(g.grants.forEach((l,r)=>{if(l.roles!=="*"&&a.size>0)for(let p of l.roles)a.has(p)||s.push(k("grant-role",`policy.grants.${r}.roles`,`"${p}" is not one of the document's roles`));for(let p of["mutations","propose"]){let y=l[p];if(y!==void 0&&y!=="*")for(let m of y)!o[m]&&!ge(m)&&!we(m,e.kinds)&&s.push(k("grant-act",`policy.grants.${r}.${p}`,`"${m}" is not an act this document declares`,$e(m,e)))}}),(g.sees??[]).forEach((l,r)=>{for(let p of l.kinds)i.has(p)||s.push(k("sight-kind",`policy.sees.${r}.kinds`,`"${p}" is not a kind this document declares`));if(l.roles!=="*"&&a.size>0)for(let p of l.roles)a.has(p)||s.push(k("sight-role",`policy.sees.${r}.roles`,`"${p}" is not one of the document's roles`))})),s.push(...Qe(e)),s}function In(e){return e.label?[...e.label.matchAll(/\{\s*([A-Za-z_][A-Za-z0-9_]*)/g)].map(s=>s[1]):[ke(e)??[]].flat()}function Kn(e,s,i,t){let o=new Map,a=pe(e.on),u=new Map,f=new Map;(a.length>0||s.some(d=>"remove"in d&&F(d.remove)==="subject"||"from"in d&&(F(d.from)==="subject"||F(d.to)==="subject")||"set"in d&&!("create"in d)&&!("through"in d)&&F(d.target??"$subject")==="subject"||"through"in d))&&o.set(he,{ref:a.length>0?a:"*",required:!0});let l=e.args??{},r=e.writes?.length===1,p=(d,c)=>c&&d.type===c.type&&d.min===void 0&&d.max===void 0&&d.step===void 0?{...d,...c.min===void 0?{}:{min:c.min},...c.max===void 0?{}:{max:c.max},...c.step===void 0?{}:{step:c.step}}:d,y=(d,c)=>c&&d.type===c.type&&d.format===void 0&&d.unit===void 0?{...p(d,c),...c.format?{format:c.format}:{},...c.unit?{unit:c.unit}:{}}:p(d,c),m=(d,c,S)=>{if(d===he||Nn.has(d)||u.has(d)||o.has(d))return;let b=l[d]?y(l[d],S):void 0;o.set(d,b?{field:b,optional:!b.required,required:!!b.required}:c())};for(let d of s)if("create"in d){let c=i.kinds[d.create],S=c?gn(c,In(c)):[],b=v=>S.includes(v)?S.indexOf(v):S.length;for(let[v,x]of Object.entries(d.set??{}).sort(([A],[w])=>b(A)-b(w))){let A=F(x),w=c?.fields[v];if(A&&w){let C=!!w.required&&w.default===void 0;m(A,()=>({field:w,optional:!C,required:C}),w)}}d.as&&u.set(d.as,d.create)}else if("connect"in d||"sever"in d){let c="connect"in d?d.connect:d.sever,S=t.get(c),b=F(d.from)==="subject"&&a.length>0?a.map(x=>Q(i.kinds[x]?.edges)[c]?.to):[],v=b.length>0&&b.every(Boolean)?b.includes("*")?"*":[...new Set(b.flat())]:void 0;for(let[x,A]of[["from",d.from],["to",d.to]]){let w=F(A);if(!w)continue;let C=x==="to"?v??S?.to??"*":S?.from??"*";C!=="*"&&!f.has(w)&&f.set(w,C),m(w,()=>({ref:C,required:!0}))}}else if("through"in d){let c=Ae(i.kinds,d.through,a),S=c&&c.kinds!=="*"?c.kinds[0]:void 0;for(let[b,v]of Object.entries(d.set)){let x=F(v);if(!x||x==="to")continue;let A=S?i.kinds[S]?.fields[b]:void 0;m(x,()=>A?{field:A,optional:!0,required:!1}:{any:!0,required:!1},A)}}else if("set"in d){let c=F(d.target??"$subject"),S=c==="subject"?a[0]:u.get(c??"")??f.get(c??"")?.[0];c&&c!=="subject"&&!u.has(c)&&m(c,()=>({ref:"*",required:!0}));for(let[b,v]of Object.entries(d.set)){let x=F(v);if(!x)continue;let A=S?i.kinds[S]?.fields[b]:void 0;m(x,()=>A?{field:A,optional:!r,required:r}:{any:!0,required:!1},A)}}else if("remove"in d){let c=F(d.remove);c&&m(c,()=>({ref:"*",required:!0}))}for(let[d,c]of Object.entries(l))o.has(d)||o.set(d,{field:c,optional:!c.required,required:!!c.required});return o}function Wt(e,s={}){let i=Mn(e);if(!i.document||ze(i.findings))return{ok:!1,findings:i.findings};let t=i.document,o=[...i.findings];s.previous&&o.push(...Gn(t,s.previous));let a=Ln(t,o);return ze(a.findings)?{ok:!1,findings:a.findings}:We(a,s)}function de(e,s,i){return e.map(t=>{if(t.format||t.expr?.t!=="ident")return t;let o=t.expr.name,a=i?.[o],u=s?.[o]??(typeof a=="object"?a:void 0),f=u?.format;return f==="money"||f==="percent"?{...t,format:f,...f==="money"&&u?.places===0?{formatArgs:["0"]}:{}}:t})}function Pn(e,s,i){let t=i.kinds[e]?.edges?.[s.via]!==void 0?"to":"from",o=i.kinds[s.from],a=[],u={};for(let[f,g]of Object.entries(s.set))if(fe(g)&&"expr"in g){let l=J(g.expr);a.push([f,{expr:l}]),l.t==="ident"&&o?.fields[l.name]&&(u[f]=l.name)}else a.push([f,{value:typeof g=="string"&&g.startsWith("$$")?g.slice(1):g}]);return{from:s.from,via:s.via,sourceEnd:t,set:a,back:u}}function Ln(e,s){let i=zn(e),t={},o=un(e.connections,e.kinds);for(let[r,p]of Object.entries(e.kinds)){let y=ke(p),m=p.label??(y?`{${y}}`:void 0),d=se(p),c=d?pn(e,r,[...d]):[];t[r]={...m?{label:de(ee(m),p.fields,p.computed)}:{},...p.describe?{describe:de(ee(p.describe),p.fields,p.computed)}:{},...d?{computed:[...d]}:{},...c.length>0?{durations:c}:{},...o.has(r)?{keptInStep:o.get(r)}:{},...p.derives?{derives:Pn(r,p.derives,e)}:{}}}let a={};for(let[r,p]of Object.entries(e.acts??{})){let y=yn(p,e),m=Kn(p,y,e,i),d=p.destructive??y.some(z=>"remove"in z||"sever"in z||"replace"in z),c=[...new Set(y.flatMap(z=>"create"in z?[z.create]:[]))],S=[...new Set(y.flatMap(z=>"connect"in z?[z.connect]:[]))],b=[...new Set(y.flatMap(z=>"sever"in z?[z.sever]:"replace"in z?z.replace:[]))],v=[...new Set(y.flatMap(z=>"set"in z&&!("create"in z)&&!("through"in z)&&F(z.target??"$subject")==="subject"?Object.keys(z.set):[]))],x=new Map;for(let z of y){if(!("connect"in z)&&!("sever"in z))continue;let E=i.get("connect"in z?z.connect:z.sever);for(let[M,ie]of[["from",z.from],["to",z.to]]){let W=F(ie),V=M==="to"?E?.to:E?.from;W&&W!=="subject"&&V&&V!=="*"&&x.set(W,[...new Set([...x.get(W)??[],...V])])}}let A={};for(let z of y){if(!("set"in z)||"create"in z||"through"in z)continue;let E=F(z.target??"$subject");for(let M of E&&E!=="subject"&&x.get(E)||[])A[M]=[...new Set([...A[M]??[],...Object.keys(z.set)])]}let w={};for(let z of y)if(!(!("set"in z)||"create"in z||"through"in z||F(z.target??"$subject")!=="subject"))for(let[E,M]of Object.entries(z.set??{}))typeof M=="string"&&F(M)===void 0||typeof M=="number"||typeof M=="boolean"?w[E]=typeof M=="string"&&M.startsWith("$$")?M.slice(1):M:delete w[E];let C=c.length===0&&y.every(z=>!("set"in z)||!z.set||Object.values(z.set).every(E=>!(E&&typeof E=="object"&&!Array.isArray(E)&&"expr"in E))),q=new Map;for(let z of y)if(!(!("set"in z)||!z.set))for(let E of Object.values(z.set))E&&typeof E=="object"&&!Array.isArray(E)&&"expr"in E&&q.set(E.expr,J(E.expr));a[r]={title:p.title??r.replace(/-/g," "),effects:y,args:[...m],...p.allowedWhen?{guard:J(p.allowedWhen)}:{},...p.refusal?{refusal:de(ee(p.refusal),e.kinds[[p.on??[]].flat()[0]??""]?.fields)}:{},exprs:[...q],destructive:d,idempotent:C,creates:c,connects:S,severs:b,writes:v,writesOther:A,sets:w}}let u={};for(let[r,p]of Object.entries(e.rules??{})){let y=p.covers&&p.over!=="graph"?ye(p.over,p.covers,m=>i.get(m),m=>m in e.kinds):void 0;u[r]={title:p.title??r.replace(/-/g," "),...p.require?{require:J(p.require)}:{},...y&&"plan"in y?{covers:y.plan}:{},...p.when?{when:J(p.when)}:{},...p.says?{says:de(ee(p.says),e.kinds[p.over]?.fields)}:{}}}let f=Ze(e,s),g=Je(e),l=Xe(e);return{format:He,document:e,findings:s,kinds:t,...e.computed?{facts:[...se(e)??[]]}:{},edges:[...i].map(([r,{from:p,to:y,cardinality:m}])=>[r,{from:p,to:y,cardinality:m}]),acts:a,rules:u,brand:f,...Object.keys(g).length>0?{viewSpecs:g}:{},...l?{home:l}:{}}}function Yt(e,s,i){let t=/^defineNode\("([^"]+)"\)/.exec(s)?.[1],o=t?i.kinds[t]:void 0;if(!t||!o)return e;let a=Object.keys(o.fields).filter(u=>u!=="label").slice(0,3);return{...e,path:`kinds.${t}.glance`,fix:`Say which: "glance": [${a.map(u=>`"${u}"`).join(", ")}] on kinds.${t} \u2014 the facts a person compares one by, at a glance.`}}function Gn(e,s){let i=[],t=new Set(Object.values(s.kinds).flatMap(o=>Object.keys(o.edges??{})));for(let[o,a]of Object.entries(e.kinds)){let u=a.renamedFrom;u&&!s.kinds[u]&&i.push(k("renamed-from-nothing",`kinds.${o}.renamedFrom`,`${o} says it was ${u}, and the previous version has no kind called ${u}`,"name the kind it was, or drop renamedFrom"));let f=s.kinds[u??o];for(let[g,l]of Object.entries(a.fields)){let r=l.renamedFrom;r&&!f?.fields[r]&&i.push(k("renamed-from-nothing",`kinds.${o}.fields.${g}.renamedFrom`,`${g} says it was ${r}, and the previous ${u??o} has no field called ${r}`,"name the field it was, or drop renamedFrom"))}for(let[g,l]of Object.entries(a.edges??{})){let r=l.renamedFrom;r&&!t.has(r)&&i.push(k("renamed-from-nothing",`kinds.${o}.edges.${g}.renamedFrom`,`${g} says it was ${r}, and the previous version has no relation called ${r}`,"name the relation it was, or drop renamedFrom"))}}return i}export{Mn as a,Ht as b,yn as c,Wt as d,Yt as e};
@@ -1 +1 @@
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 N,g as ae,h as ie}from"./chunk.FK722SHI.js";import{a as S,b as T,c as A,d as j}from"./chunk.U5P23GO7.js";import{a as R}from"./chunk.6EHHMWPP.js";import{a as ee,b as te,c as ne}from"./chunk.TXHYGFIZ.js";import{b as k}from"./chunk.WAB3L3ZI.js";import{a as Z}from"./chunk.QOS5T46W.js";import{a as C}from"./chunk.WSDJPXJD.js";import{m as Q}from"./chunk.U3HERHAI.js";import{G,J as _,La as K,R as H,S as z,W as X,ea as b,oa as J}from"./chunk.MODLZJD4.js";import{a as Y}from"./chunk.SDO3U72B.js";import{Ce as U,Jb as x,eb as q,fb as B,ga as V,la as P}from"./chunk.6HY6ZGEE.js";import{b as D}from"./chunk.AJZBJBMO.js";var u=D(G(),1);var oe=D(G(),1);function E(){let{ai:n,aiDesk:a}=b(),{entries:o}=_(a),i=n.off===!0;return(0,oe.useEffect)(()=>{i||a.load()},[a,i]),i?[]:o}var t=D(X(),1),se=K(Y(()=>(__graviewPreload(import.meta.url,["./chunk.IAEHUSQQ.js","./chunk.U5P23GO7.js","./chunk.PSQYDCVM.js","./chunk.U3HERHAI.js","./chunk.FBILPNGH.js","./chunk.MODLZJD4.js","./chunk.SDO3U72B.js","./chunk.6HY6ZGEE.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.JMXXA4YG.js")))),he=se.part((n,a)=>(0,t.jsx)(n.InteractionRow,{...a}),{quiet:!0,as:"li"}),ye=se.part((n,a)=>(0,t.jsx)(n.ActivityFilter,{...a}),{quiet:!0,as:"div"}),fe=n=>n.undoes===void 0&&n.primitives.some(a=>a.op==="remove-node"||a.op==="patch-node"&&a.after[B]===!0&&a.before[B]!==!0);function ve(n){let a=[...new Set(n.ops.filter(o=>!x(o)&&fe(o)).map(o=>o.intent))].filter(o=>o!==n.intent);return a.length===0?n.intent:`${n.intent} \u2014 ${a.join("; ")}`}var re=(n,a,o=le(n,[a]))=>({intent:ve(a),author:a.author.kind,...a.author.id?{authorId:a.author.id}:{},by:a.author,...a.ops[0]?.via?{via:a.ops[0].via}:{},...a.lineage?{basis:Z(a.lineage)}:{},touched:[...new Set(a.ops.filter(i=>!x(i)).flatMap(i=>i.writes))],...me(a.ops.filter(i=>!x(i)).flatMap(i=>i.writes),o),batch:a.id,at:a.at,...a.lineage?.interaction?{interaction:a.lineage.interaction}:{},seq:a.ops.at(-1).seq+1,...a.ops.every(x)?{withheld:!0}:{}});function de(n=4){let{store:a,principal:o}=b(),i=z(a,o),s=i.log.length;return(0,u.useMemo)(()=>{let l=i.batches(),d=le(i,l);return te(l,r=>i.log.get(r)).reverse().slice(0,n).map(r=>{if("batch"in r){let p=re(i,r.batch,d);return r.typed?{...p,intent:ee(r.typed,i.schema,i.graph),batches:r.typed.batches.filter(v=>!v.undone).map(v=>v.id)}:p}let h=[...r.digest.batches].reverse().map(p=>re(i,p,d));return{intent:ne(r.digest),author:r.digest.author.kind,...r.digest.author.id?{authorId:r.digest.author.id}:{},by:r.digest.author,touched:[...new Set(h.flatMap(p=>p.touched))],batch:"",...h[0]?.at?{at:h[0].at}:{},seq:h[0]?.seq??0,digest:h}})},[i,s,n])}function le(n,a){let o=new Map;for(let i of a)for(let s of i.ops)if(!x(s))for(let l of s.primitives)(l.op==="add-node"||l.op==="remove-node")&&l.node&&o.set(l.node.id,P(n.schema.tryDefinition(l.node.kind),l.node));return o}function me(n,a){let o={};for(let i of n){let s=a.get(i);s!==void 0&&(o[i]=s)}return Object.keys(o).length>0?{named:o}:{}}function we({change:n}){let{store:a,principal:o,seats:i,people:s}=b();return(0,t.jsxs)("strong",{style:{fontWeight:600},children:[n.author==="human"&&n.by?.onBehalfOf===void 0&&(n.authorId===void 0||o.id===void 0||n.authorId===o.id)?"you":q(n.by??{kind:n.author,id:n.authorId},{graph:a.graph,schema:a.schema,seats:i,people:s}),C(n.via)?(0,t.jsxs)("span",{style:{fontWeight:400,color:"var(--graview-ink-muted)"},children:[", ",C(n.via)]}):null]})}function be({change:n,goes:a}){let{store:o}=b(),[i,s]=(0,u.useState)(!1),l=n.digest??[];return(0,t.jsxs)("li",{"data-testid":"activity-digest",style:{...S,gap:5},children:[(0,t.jsxs)("div",{"data-graview-activity-head":"",style:T,children:[(0,t.jsxs)("span",{"data-graview-activity-words":"",style:A,children:[(0,t.jsx)(we,{change:n})," ",(0,t.jsx)("span",{style:{color:"var(--graview-ink-muted)"},children:n.intent})]}),(0,t.jsx)("button",{type:"button","data-testid":"digest-toggle","aria-expanded":i,onClick:()=>s(d=>!d),style:{marginLeft:"auto",flex:"0 0 auto",display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24,padding:"1px 8px",fontSize:"0.75rem"},children:i?"Hide":"Show each"})]}),i?(0,t.jsx)("ol",{"data-testid":"digest-changes",style:{margin:0,padding:"0 0 0 10px",listStyle:"none",display:"grid",gap:6,borderLeft:"1px solid var(--graview-edge)"},children:l.map(d=>(0,t.jsxs)("li",{"data-testid":"digest-change",style:S,children:[(0,t.jsxs)("div",{"data-graview-activity-head":"",style:T,children:[(0,t.jsxs)("span",{"data-graview-activity-words":"",style:A,children:[(0,t.jsx)("span",{style:{color:"var(--graview-ink-muted)"},children:d.intent}),d.basis?(0,t.jsxs)("span",{"data-graview-lineage":"",style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",d.basis]}):null]}),d.withheld?null:(0,t.jsx)($,{batch:d.batch})]}),d.touched.length>0?(0,t.jsx)("div",{"data-touched":d.touched.join(" "),style:j,children:d.touched.slice(0,4).map(r=>(0,t.jsx)(R,{id:r,label:o.graph.has(r)?k(o,r):d.named?.[r]??k(o,r),go:a(r),testId:"activity-record"},r))}):null]},d.batch))}):null]})}function $({batch:n}){let{store:a,principal:o,noteSeat:i}=b(),s=z(a,o),l=H()?.open??!1,d=s.log.length,[r,h]=(0,u.useState)(null),p=(0,u.useMemo)(()=>s.canUndo(n),[s,n,d]),v=(0,u.useMemo)(()=>p.ok?s.mayUndo(n,o):{ok:!0},[s,n,d,o,p]);if(l||!p.ok&&p.ops.length===0||!v.ok)return null;let m=!p.ok,W=m?p.includeBatches:[];return(0,t.jsxs)("span",{style:{marginLeft:"auto",flex:"0 0 auto",display:"grid",justifyItems:"end",gap:2},children:[(0,t.jsx)("button",{type:"button","data-testid":"undo-turn",title:m?`${p.message} \u2014 undo those too`:"Take this back, keeping everything since",onClick:()=>{h(null);try{let y=typeof n=="string"?[n]:n,L=s.log.all().find(I=>y.includes(I.batch)&&I.author.kind==="agent");s.undo(m?[...y,...W]:typeof n=="string"?n:[...n],{author:o}),L&&i({type:"home",author:L.author})}catch(y){h(y instanceof Error?y.message:String(y))}},style:{display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24,padding:"1px 8px",fontSize:"0.75rem",...m?{borderColor:"var(--graview-warn)",color:"var(--graview-warn)"}:{}},children:m?`undo +${W.length}`:"undo"}),r?(0,t.jsx)("span",{"data-testid":"undo-refused",role:"alert",style:{fontSize:"0.75rem",lineHeight:1.4,color:"var(--graview-warn)",maxWidth:260,textAlign:"right"},children:r}):null]})}function ke({seq:n,intent:a}){let o=H();if(!o)return null;let i=o.past?.seq===n;return(0,t.jsx)("button",{type:"button","data-testid":"show-past","aria-label":`Show the app as it was after \u201C${a}\u201D`,title:"Show the app as it was here","aria-pressed":i,onPointerEnter:N,onFocus:N,onClick:()=>o.show(n),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",minHeight:24,minWidth:24,padding:"1px 6px",fontSize:"0.75rem",flex:"0 0 auto"},children:(0,t.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",children:[(0,t.jsx)("path",{d:"M2.5 8 a5.5 5.5 0 1 0 1.6-3.9",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M2 2.5 V5.5 H5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8 5 V8 L10 9.25",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})})}function xe(){let n=()=>U(window.location.href);return(0,t.jsx)("a",{href:"#fresh","data-testid":"start-fresh",title:"Forget every edit made in this browser and return to the example",onClick:a=>{a.preventDefault(),window.location.assign(n())},style:{display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24,fontSize:"0.8125rem",color:"var(--graview-ink-muted)",textDecoration:"underline",textDecorationColor:"var(--graview-edge-bright)",textUnderlineOffset:3},children:"Start fresh"})}function Ee({calls:n,seat:a,remembers:o=!1,close:i,headed:s=!0}){let l=de(),{store:d,principal:r,seats:h,people:p}=b(),v=E(),[m,W]=(0,u.useState)("all"),[y,L]=(0,u.useState)(!1),I=e=>e!==void 0&&(e.id===r.id||e.onBehalfOf?.id===r.id)&&r.id!==void 0,pe=new Set(v.map(e=>e.id)),ge=l.filter(e=>!(e.interaction!==void 0&&pe.has(e.interaction))&&(!y||I(e.by))),ce=v.filter(e=>!y||I(e.by)).slice(0,4),O=[...m==="ai"?[]:ge.map(e=>({at:e.at??"",change:e})),...m==="changes"?[]:ce.map(e=>({at:e.at,entry:e}))].sort((e,f)=>e.at<f.at?1:e.at>f.at?-1:0),w=z(d,r),ue=J(),F=H(),M=e=>w.graph.has(e)?f=>{i(),F?.past&&F.show(null),ue.record(f)}:null;return(0,t.jsxs)(t.Fragment,{children:[s?(0,t.jsx)("h2",{style:{...Q,margin:0},children:"Activity"}):null,a!==void 0?(0,t.jsxs)("div",{"data-testid":"agent-seat-row",style:{display:"grid",gap:5,paddingBottom:n.length>0||O.length>0?9:0,...n.length>0||O.length>0?{borderBottom:"1px solid var(--graview-edge)"}:{}},children:[(0,t.jsx)("span",{style:{fontSize:"0.75rem",letterSpacing:"0.14em",textTransform:"uppercase",color:"var(--graview-ink-faint)"},children:"The agent's seat"}),a]}):null,n.length>0?(0,t.jsx)("ol",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:7},children:n.slice(0,6).map((e,f)=>(0,t.jsxs)("li",{style:{...S,gap:2,fontSize:"0.8125rem"},children:[(0,t.jsxs)("div",{"data-graview-activity-head":"",style:T,children:[(0,t.jsx)("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:999,flex:"0 0 auto",background:e.phase==="running"?"var(--graview-accent)":e.phase==="failed"?"var(--graview-warn)":"var(--graview-edge-bright)"}}),(0,t.jsxs)("span",{"data-graview-activity-words":"",style:{...A,color:"var(--graview-ink)"},children:[e.mutating?"changed":"read"," \xB7"," ",w.allMutations().find(g=>g.name===e.name)?.title??V(e.name)]})]}),!e.mutating&&e.reads&&e.reads.length>0?(0,t.jsxs)("div",{"data-testid":"activity-reads",style:{display:"flex",flexWrap:"wrap",gap:4,paddingLeft:12},children:[[...new Set(e.reads)].slice(0,3).map(g=>(0,t.jsx)(R,{id:g,label:k(w,g),go:M(g),testId:"activity-record"},g)),new Set(e.reads).size>3?(0,t.jsxs)("span",{style:{color:"var(--graview-ink-muted)"},children:["+",new Set(e.reads).size-3]}):null]}):Object.values(e.args).some(g=>typeof g=="string")?(0,t.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4,paddingLeft:12},children:Object.entries(e.args).filter(g=>typeof g[1]=="string").slice(0,3).map(([g,c])=>(0,t.jsx)(R,{id:c,label:k(w,c),go:M(c),testId:"activity-record"},g))}):null,e.error?(0,t.jsx)("div",{style:{paddingLeft:12,color:"var(--graview-warn)"},children:e.error}):null]},`${e.at}:${f}`))}):null,v.length>0?(0,t.jsx)(u.Suspense,{fallback:null,children:(0,t.jsx)(ye,{shows:m,onShows:W,mine:y,onMine:L})}):null,O.length>0?(0,t.jsx)("ol",{"data-testid":"diff-log",style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6,fontSize:"0.8125rem"},children:O.map(({change:e,entry:f},g)=>f!==void 0?(0,t.jsx)(u.Suspense,{fallback:null,children:(0,t.jsx)(he,{entry:f,undo:c=>(0,t.jsx)($,{batch:c})})},`ai:${f.id}`):e.digest?(0,t.jsx)(be,{change:e,goes:M},`digest:${e.digest[0]?.batch??g}`):e.withheld?(0,t.jsx)("li",{"data-testid":"withheld-change",style:S,children:(0,t.jsx)("span",{"data-touched":"",style:{...A,color:"var(--graview-ink-muted)",fontStyle:"italic"},children:e.intent})},`change:${g}`):(0,t.jsxs)("li",{"data-batch":e.batch,style:S,children:[(0,t.jsxs)("div",{"data-graview-activity-head":"",style:T,children:[(0,t.jsxs)("span",{"data-graview-activity-words":"",style:A,children:[(0,t.jsxs)("strong",{style:{fontWeight:600},children:[e.author==="human"&&e.by?.onBehalfOf===void 0&&(e.authorId===void 0||r.id===void 0||e.authorId===r.id)?"you":q(e.by??{kind:e.author,id:e.authorId},{graph:w.graph,schema:w.schema,seats:h,people:p}),C(e.via)?(0,t.jsxs)("span",{style:{fontWeight:400,color:"var(--graview-ink-muted)"},children:[", ",C(e.via)]}):null]})," ",(0,t.jsx)("span",{style:{color:"var(--graview-ink-muted)"},children:e.intent}),e.basis?(0,t.jsxs)("span",{"data-graview-lineage":"",style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",e.basis]}):null]}),e.batch?(0,t.jsx)(ke,{seq:e.seq,intent:e.intent}):null,e.batch?(0,t.jsx)($,{batch:e.batches&&e.batches.length>0?e.batches.length===1?e.batches[0]:e.batches:e.batch}):null]}),(0,t.jsx)("div",{"data-touched":e.touched.join(" "),style:j,children:e.touched.slice(0,4).map(c=>(0,t.jsx)(R,{id:c,label:w.graph.has(c)?k(w,c):e.named?.[c]??k(w,c),go:M(c),testId:"activity-record"},c))})]},`change:${g}`))}):null,(0,t.jsx)(ie,{style:{paddingTop:8,borderTop:"1px solid var(--graview-edge)"}}),o?(0,t.jsxs)("div",{"data-testid":"remembered",style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:10,paddingTop:8,borderTop:"1px solid var(--graview-edge)",fontSize:"0.8125rem",color:"var(--graview-ink-faint)"},children:[(0,t.jsx)("span",{children:"Remembered in this browser"}),(0,t.jsx)(xe,{})]}):null]})}function $e({calls:n,seat:a,remembers:o=!1}){let i=de(),s=E(),l=ae();return{has:!(a===void 0&&n.length===0&&i.length===0&&s.length===0&&!o&&l===0),recent:i.length,running:n.some(d=>d.phase==="running")}}export{E as a,he as b,$ as c,Ee as d,$e as e};
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 N,g as ae,h as ie}from"./chunk.GRFD42WM.js";import{a as S,b as T,c as A,d as j}from"./chunk.U5P23GO7.js";import{a as R}from"./chunk.HJUZMOW2.js";import{a as Z,b as ee,c as te}from"./chunk.NAXOXBOF.js";import{b as k}from"./chunk.6W6XMLSF.js";import{a as ne}from"./chunk.EGPCVMDU.js";import{a as C}from"./chunk.SO6NT5K7.js";import{m as Q}from"./chunk.QNP5OR3P.js";import{G,J as _,La as K,R as H,S as z,W as X,ea as b,oa as J}from"./chunk.A5PSEU3W.js";import{a as Y}from"./chunk.SDO3U72B.js";import{Ce as U,Jb as x,eb as q,fb as B,ga as V,la as P}from"./chunk.ZEZUKRC6.js";import{b as D}from"./chunk.AJZBJBMO.js";var u=D(G(),1);var oe=D(G(),1);function E(){let{ai:n,aiDesk:a}=b(),{entries:o}=_(a),i=n.off===!0;return(0,oe.useEffect)(()=>{i||a.load()},[a,i]),i?[]:o}var t=D(X(),1),se=K(Y(()=>(__graviewPreload(import.meta.url,["./chunk.7UHPHEH5.js","./chunk.U5P23GO7.js","./chunk.QF5QB5YR.js","./chunk.QNP5OR3P.js","./chunk.4W57E7AX.js","./chunk.A5PSEU3W.js","./chunk.SDO3U72B.js","./chunk.ZEZUKRC6.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.3ENPWZBG.js")))),he=se.part((n,a)=>(0,t.jsx)(n.InteractionRow,{...a}),{quiet:!0,as:"li"}),ye=se.part((n,a)=>(0,t.jsx)(n.ActivityFilter,{...a}),{quiet:!0,as:"div"}),fe=n=>n.undoes===void 0&&n.primitives.some(a=>a.op==="remove-node"||a.op==="patch-node"&&a.after[B]===!0&&a.before[B]!==!0);function ve(n){let a=[...new Set(n.ops.filter(o=>!x(o)&&fe(o)).map(o=>o.intent))].filter(o=>o!==n.intent);return a.length===0?n.intent:`${n.intent} \u2014 ${a.join("; ")}`}var re=(n,a,o=le(n,[a]))=>({intent:ve(a),author:a.author.kind,...a.author.id?{authorId:a.author.id}:{},by:a.author,...a.ops[0]?.via?{via:a.ops[0].via}:{},...a.lineage?{basis:ne(a.lineage)}:{},touched:[...new Set(a.ops.filter(i=>!x(i)).flatMap(i=>i.writes))],...me(a.ops.filter(i=>!x(i)).flatMap(i=>i.writes),o),batch:a.id,at:a.at,...a.lineage?.interaction?{interaction:a.lineage.interaction}:{},seq:a.ops.at(-1).seq+1,...a.ops.every(x)?{withheld:!0}:{}});function de(n=4){let{store:a,principal:o}=b(),i=z(a,o),s=i.log.length;return(0,u.useMemo)(()=>{let l=i.batches(),d=le(i,l);return ee(l,r=>i.log.get(r)).reverse().slice(0,n).map(r=>{if("batch"in r){let p=re(i,r.batch,d);return r.typed?{...p,intent:Z(r.typed,i.schema,i.graph),batches:r.typed.batches.filter(v=>!v.undone).map(v=>v.id)}:p}let h=[...r.digest.batches].reverse().map(p=>re(i,p,d));return{intent:te(r.digest),author:r.digest.author.kind,...r.digest.author.id?{authorId:r.digest.author.id}:{},by:r.digest.author,touched:[...new Set(h.flatMap(p=>p.touched))],batch:"",...h[0]?.at?{at:h[0].at}:{},seq:h[0]?.seq??0,digest:h}})},[i,s,n])}function le(n,a){let o=new Map;for(let i of a)for(let s of i.ops)if(!x(s))for(let l of s.primitives)(l.op==="add-node"||l.op==="remove-node")&&l.node&&o.set(l.node.id,P(n.schema.tryDefinition(l.node.kind),l.node));return o}function me(n,a){let o={};for(let i of n){let s=a.get(i);s!==void 0&&(o[i]=s)}return Object.keys(o).length>0?{named:o}:{}}function we({change:n}){let{store:a,principal:o,seats:i,people:s}=b();return(0,t.jsxs)("strong",{style:{fontWeight:600},children:[n.author==="human"&&n.by?.onBehalfOf===void 0&&(n.authorId===void 0||o.id===void 0||n.authorId===o.id)?"you":q(n.by??{kind:n.author,id:n.authorId},{graph:a.graph,schema:a.schema,seats:i,people:s}),C(n.via)?(0,t.jsxs)("span",{style:{fontWeight:400,color:"var(--graview-ink-muted)"},children:[", ",C(n.via)]}):null]})}function be({change:n,goes:a}){let{store:o}=b(),[i,s]=(0,u.useState)(!1),l=n.digest??[];return(0,t.jsxs)("li",{"data-testid":"activity-digest",style:{...S,gap:5},children:[(0,t.jsxs)("div",{"data-graview-activity-head":"",style:T,children:[(0,t.jsxs)("span",{"data-graview-activity-words":"",style:A,children:[(0,t.jsx)(we,{change:n})," ",(0,t.jsx)("span",{style:{color:"var(--graview-ink-muted)"},children:n.intent})]}),(0,t.jsx)("button",{type:"button","data-testid":"digest-toggle","aria-expanded":i,onClick:()=>s(d=>!d),style:{marginLeft:"auto",flex:"0 0 auto",display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24,padding:"1px 8px",fontSize:"0.75rem"},children:i?"Hide":"Show each"})]}),i?(0,t.jsx)("ol",{"data-testid":"digest-changes",style:{margin:0,padding:"0 0 0 10px",listStyle:"none",display:"grid",gap:6,borderLeft:"1px solid var(--graview-edge)"},children:l.map(d=>(0,t.jsxs)("li",{"data-testid":"digest-change",style:S,children:[(0,t.jsxs)("div",{"data-graview-activity-head":"",style:T,children:[(0,t.jsxs)("span",{"data-graview-activity-words":"",style:A,children:[(0,t.jsx)("span",{style:{color:"var(--graview-ink-muted)"},children:d.intent}),d.basis?(0,t.jsxs)("span",{"data-graview-lineage":"",style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",d.basis]}):null]}),d.withheld?null:(0,t.jsx)($,{batch:d.batch})]}),d.touched.length>0?(0,t.jsx)("div",{"data-touched":d.touched.join(" "),style:j,children:d.touched.slice(0,4).map(r=>(0,t.jsx)(R,{id:r,label:o.graph.has(r)?k(o,r):d.named?.[r]??k(o,r),go:a(r),testId:"activity-record"},r))}):null]},d.batch))}):null]})}function $({batch:n}){let{store:a,principal:o,noteSeat:i}=b(),s=z(a,o),l=H()?.open??!1,d=s.log.length,[r,h]=(0,u.useState)(null),p=(0,u.useMemo)(()=>s.canUndo(n),[s,n,d]),v=(0,u.useMemo)(()=>p.ok?s.mayUndo(n,o):{ok:!0},[s,n,d,o,p]);if(l||!p.ok&&p.ops.length===0||!v.ok)return null;let m=!p.ok,W=m?p.includeBatches:[];return(0,t.jsxs)("span",{style:{marginLeft:"auto",flex:"0 0 auto",display:"grid",justifyItems:"end",gap:2},children:[(0,t.jsx)("button",{type:"button","data-testid":"undo-turn",title:m?`${p.message} \u2014 undo those too`:"Take this back, keeping everything since",onClick:()=>{h(null);try{let y=typeof n=="string"?[n]:n,L=s.log.all().find(I=>y.includes(I.batch)&&I.author.kind==="agent");s.undo(m?[...y,...W]:typeof n=="string"?n:[...n],{author:o}),L&&i({type:"home",author:L.author})}catch(y){h(y instanceof Error?y.message:String(y))}},style:{display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24,padding:"1px 8px",fontSize:"0.75rem",...m?{borderColor:"var(--graview-warn)",color:"var(--graview-warn)"}:{}},children:m?`undo +${W.length}`:"undo"}),r?(0,t.jsx)("span",{"data-testid":"undo-refused",role:"alert",style:{fontSize:"0.75rem",lineHeight:1.4,color:"var(--graview-warn)",maxWidth:260,textAlign:"right"},children:r}):null]})}function ke({seq:n,intent:a}){let o=H();if(!o)return null;let i=o.past?.seq===n;return(0,t.jsx)("button",{type:"button","data-testid":"show-past","aria-label":`Show the app as it was after \u201C${a}\u201D`,title:"Show the app as it was here","aria-pressed":i,onPointerEnter:N,onFocus:N,onClick:()=>o.show(n),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",minHeight:24,minWidth:24,padding:"1px 6px",fontSize:"0.75rem",flex:"0 0 auto"},children:(0,t.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",children:[(0,t.jsx)("path",{d:"M2.5 8 a5.5 5.5 0 1 0 1.6-3.9",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M2 2.5 V5.5 H5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8 5 V8 L10 9.25",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})})}function xe(){let n=()=>U(window.location.href);return(0,t.jsx)("a",{href:"#fresh","data-testid":"start-fresh",title:"Forget every edit made in this browser and return to the example",onClick:a=>{a.preventDefault(),window.location.assign(n())},style:{display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24,fontSize:"0.8125rem",color:"var(--graview-ink-muted)",textDecoration:"underline",textDecorationColor:"var(--graview-edge-bright)",textUnderlineOffset:3},children:"Start fresh"})}function Ee({calls:n,seat:a,remembers:o=!1,close:i,headed:s=!0}){let l=de(),{store:d,principal:r,seats:h,people:p}=b(),v=E(),[m,W]=(0,u.useState)("all"),[y,L]=(0,u.useState)(!1),I=e=>e!==void 0&&(e.id===r.id||e.onBehalfOf?.id===r.id)&&r.id!==void 0,pe=new Set(v.map(e=>e.id)),ge=l.filter(e=>!(e.interaction!==void 0&&pe.has(e.interaction))&&(!y||I(e.by))),ce=v.filter(e=>!y||I(e.by)).slice(0,4),O=[...m==="ai"?[]:ge.map(e=>({at:e.at??"",change:e})),...m==="changes"?[]:ce.map(e=>({at:e.at,entry:e}))].sort((e,f)=>e.at<f.at?1:e.at>f.at?-1:0),w=z(d,r),ue=J(),F=H(),M=e=>w.graph.has(e)?f=>{i(),F?.past&&F.show(null),ue.record(f)}:null;return(0,t.jsxs)(t.Fragment,{children:[s?(0,t.jsx)("h2",{style:{...Q,margin:0},children:"Activity"}):null,a!==void 0?(0,t.jsxs)("div",{"data-testid":"agent-seat-row",style:{display:"grid",gap:5,paddingBottom:n.length>0||O.length>0?9:0,...n.length>0||O.length>0?{borderBottom:"1px solid var(--graview-edge)"}:{}},children:[(0,t.jsx)("span",{style:{fontSize:"0.75rem",letterSpacing:"0.14em",textTransform:"uppercase",color:"var(--graview-ink-faint)"},children:"The agent's seat"}),a]}):null,n.length>0?(0,t.jsx)("ol",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:7},children:n.slice(0,6).map((e,f)=>(0,t.jsxs)("li",{style:{...S,gap:2,fontSize:"0.8125rem"},children:[(0,t.jsxs)("div",{"data-graview-activity-head":"",style:T,children:[(0,t.jsx)("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:999,flex:"0 0 auto",background:e.phase==="running"?"var(--graview-accent)":e.phase==="failed"?"var(--graview-warn)":"var(--graview-edge-bright)"}}),(0,t.jsxs)("span",{"data-graview-activity-words":"",style:{...A,color:"var(--graview-ink)"},children:[e.mutating?"changed":"read"," \xB7"," ",w.allMutations().find(g=>g.name===e.name)?.title??V(e.name)]})]}),!e.mutating&&e.reads&&e.reads.length>0?(0,t.jsxs)("div",{"data-testid":"activity-reads",style:{display:"flex",flexWrap:"wrap",gap:4,paddingLeft:12},children:[[...new Set(e.reads)].slice(0,3).map(g=>(0,t.jsx)(R,{id:g,label:k(w,g),go:M(g),testId:"activity-record"},g)),new Set(e.reads).size>3?(0,t.jsxs)("span",{style:{color:"var(--graview-ink-muted)"},children:["+",new Set(e.reads).size-3]}):null]}):Object.values(e.args).some(g=>typeof g=="string")?(0,t.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4,paddingLeft:12},children:Object.entries(e.args).filter(g=>typeof g[1]=="string").slice(0,3).map(([g,c])=>(0,t.jsx)(R,{id:c,label:k(w,c),go:M(c),testId:"activity-record"},g))}):null,e.error?(0,t.jsx)("div",{style:{paddingLeft:12,color:"var(--graview-warn)"},children:e.error}):null]},`${e.at}:${f}`))}):null,v.length>0?(0,t.jsx)(u.Suspense,{fallback:null,children:(0,t.jsx)(ye,{shows:m,onShows:W,mine:y,onMine:L})}):null,O.length>0?(0,t.jsx)("ol",{"data-testid":"diff-log",style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6,fontSize:"0.8125rem"},children:O.map(({change:e,entry:f},g)=>f!==void 0?(0,t.jsx)(u.Suspense,{fallback:null,children:(0,t.jsx)(he,{entry:f,undo:c=>(0,t.jsx)($,{batch:c})})},`ai:${f.id}`):e.digest?(0,t.jsx)(be,{change:e,goes:M},`digest:${e.digest[0]?.batch??g}`):e.withheld?(0,t.jsx)("li",{"data-testid":"withheld-change",style:S,children:(0,t.jsx)("span",{"data-touched":"",style:{...A,color:"var(--graview-ink-muted)",fontStyle:"italic"},children:e.intent})},`change:${g}`):(0,t.jsxs)("li",{"data-batch":e.batch,style:S,children:[(0,t.jsxs)("div",{"data-graview-activity-head":"",style:T,children:[(0,t.jsxs)("span",{"data-graview-activity-words":"",style:A,children:[(0,t.jsxs)("strong",{style:{fontWeight:600},children:[e.author==="human"&&e.by?.onBehalfOf===void 0&&(e.authorId===void 0||r.id===void 0||e.authorId===r.id)?"you":q(e.by??{kind:e.author,id:e.authorId},{graph:w.graph,schema:w.schema,seats:h,people:p}),C(e.via)?(0,t.jsxs)("span",{style:{fontWeight:400,color:"var(--graview-ink-muted)"},children:[", ",C(e.via)]}):null]})," ",(0,t.jsx)("span",{style:{color:"var(--graview-ink-muted)"},children:e.intent}),e.basis?(0,t.jsxs)("span",{"data-graview-lineage":"",style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",e.basis]}):null]}),e.batch?(0,t.jsx)(ke,{seq:e.seq,intent:e.intent}):null,e.batch?(0,t.jsx)($,{batch:e.batches&&e.batches.length>0?e.batches.length===1?e.batches[0]:e.batches:e.batch}):null]}),(0,t.jsx)("div",{"data-touched":e.touched.join(" "),style:j,children:e.touched.slice(0,4).map(c=>(0,t.jsx)(R,{id:c,label:w.graph.has(c)?k(w,c):e.named?.[c]??k(w,c),go:M(c),testId:"activity-record"},c))})]},`change:${g}`))}):null,(0,t.jsx)(ie,{style:{paddingTop:8,borderTop:"1px solid var(--graview-edge)"}}),o?(0,t.jsxs)("div",{"data-testid":"remembered",style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:10,paddingTop:8,borderTop:"1px solid var(--graview-edge)",fontSize:"0.8125rem",color:"var(--graview-ink-faint)"},children:[(0,t.jsx)("span",{children:"Remembered in this browser"}),(0,t.jsx)(xe,{})]}):null]})}function $e({calls:n,seat:a,remembers:o=!1}){let i=de(),s=E(),l=ae();return{has:!(a===void 0&&n.length===0&&i.length===0&&s.length===0&&!o&&l===0),recent:i.length,running:n.some(d=>d.phase==="running")}}export{E as a,he as b,$ as c,Ee as d,$e as e};