graview 0.1.60 → 0.1.62

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 (228) hide show
  1. package/dist/index.d.ts.map +1 -1
  2. package/dist/index.js +5 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/preview/{chunk.QDSEVPF3.js → chunk.22BZU7ME.js} +1 -1
  5. package/dist/preview/chunk.2AT3GRXM.js +1 -0
  6. package/dist/preview/chunk.2B6P4GPS.js +1 -0
  7. package/dist/preview/chunk.2GEJNG2U.js +1 -0
  8. package/dist/preview/{chunk.7N32AVIJ.js → chunk.2N4Z5K5S.js} +1 -1
  9. package/dist/preview/{chunk.NHUQ2N6J.js → chunk.3FON2Y72.js} +1 -1
  10. package/dist/preview/chunk.3L37FY3G.js +4 -0
  11. package/dist/preview/{chunk.ZYM2SSGW.js → chunk.4HEFUOLV.js} +1 -1
  12. package/dist/preview/chunk.4HRYB7HF.js +1 -0
  13. package/dist/preview/{chunk.YZ7FUKAL.js → chunk.4TX6VCBT.js} +1 -1
  14. package/dist/preview/{chunk.IGJZ4UH3.js → chunk.5HGD6OWL.js} +2 -2
  15. package/dist/preview/{chunk.2USDHXB4.js → chunk.5J3O2FVG.js} +1 -1
  16. package/dist/preview/{chunk.H45Q3O4F.js → chunk.5MZYCELA.js} +1 -1
  17. package/dist/preview/{chunk.SRVQJZRT.js → chunk.5ODHHH35.js} +1 -1
  18. package/dist/preview/{chunk.HDUO2USQ.js → chunk.5STU3KYG.js} +1 -1
  19. package/dist/preview/{chunk.TFWIG6LL.js → chunk.5YAOKOGV.js} +1 -1
  20. package/dist/preview/{chunk.BQIHNT7C.js → chunk.66P5IDTH.js} +1 -1
  21. package/dist/preview/{chunk.M4UD4ARP.js → chunk.6AKW7TXM.js} +1 -1
  22. package/dist/preview/{chunk.URWAFZHF.js → chunk.6JO5HQDR.js} +1 -1
  23. package/dist/preview/{chunk.HUJ6YTWE.js → chunk.75GVFX7L.js} +1 -1
  24. package/dist/preview/{chunk.A3ZXDG6V.js → chunk.7KVUUEZA.js} +1 -1
  25. package/dist/preview/{chunk.FFTYMBBT.js → chunk.7M4HNKDR.js} +1 -1
  26. package/dist/preview/chunk.7OBIBPYH.js +1 -0
  27. package/dist/preview/chunk.7V56P2A7.js +1 -0
  28. package/dist/preview/chunk.7XLS6XTY.js +1 -0
  29. package/dist/preview/chunk.7YOAW7ED.js +1 -0
  30. package/dist/preview/{chunk.FBJARKDT.js → chunk.A3OL2BI2.js} +1 -1
  31. package/dist/preview/{chunk.NGTRL5U4.js → chunk.A3ZC2JBO.js} +1 -1
  32. package/dist/preview/{chunk.A5PDXNY6.js → chunk.ACTXR2MI.js} +1 -1
  33. package/dist/preview/chunk.AFNSAQEQ.js +1 -0
  34. package/dist/preview/chunk.AI34V6WV.js +74 -0
  35. package/dist/preview/{chunk.3XGA65Y3.js → chunk.AJSUHPBE.js} +1 -1
  36. package/dist/preview/chunk.AQRB7LDA.js +1 -0
  37. package/dist/preview/{chunk.GNBIVVL3.js → chunk.B23WZQXQ.js} +1 -1
  38. package/dist/preview/chunk.BIDL7GQD.js +0 -0
  39. package/dist/preview/chunk.BLUKSGI4.js +1 -0
  40. package/dist/preview/chunk.BZMQDEIY.js +1 -0
  41. package/dist/preview/chunk.CAKFNKN5.js +1 -0
  42. package/dist/preview/chunk.CGALLZ54.js +1 -0
  43. package/dist/preview/{chunk.LSY256J4.js → chunk.CHHYIMB7.js} +1 -1
  44. package/dist/preview/chunk.CXDGE5ZS.js +1 -0
  45. package/dist/preview/{chunk.CC5BJH5A.js → chunk.CY3ELWCM.js} +1 -1
  46. package/dist/preview/chunk.DC35FJAB.js +1 -0
  47. package/dist/preview/{chunk.AVBTPSQF.js → chunk.DD2NKFDX.js} +1 -1
  48. package/dist/preview/{chunk.6HF6POIX.js → chunk.DDO3GLEJ.js} +1 -1
  49. package/dist/preview/{chunk.TLJOZSDD.js → chunk.DDUCIUVW.js} +1 -1
  50. package/dist/preview/chunk.DEAP3H2L.js +1 -0
  51. package/dist/preview/chunk.DHJ3FQTR.js +1 -0
  52. package/dist/preview/{chunk.P6RORYOT.js → chunk.DNVWSWL2.js} +1 -1
  53. package/dist/preview/chunk.DPEIT3TW.js +1 -0
  54. package/dist/preview/chunk.DVSTLVIH.js +15 -0
  55. package/dist/preview/chunk.DZZL5IDD.js +5 -0
  56. package/dist/preview/{chunk.IGVASEZU.js → chunk.ELOFPE25.js} +1 -1
  57. package/dist/preview/{chunk.MVWC3VR3.js → chunk.ELTV44HU.js} +2 -2
  58. package/dist/preview/chunk.EVBCEEQ4.js +1 -0
  59. package/dist/preview/{chunk.TKVLNBRD.js → chunk.F7YXLYLX.js} +1 -1
  60. package/dist/preview/{chunk.DCHQHKSA.js → chunk.FULEUL34.js} +1 -1
  61. package/dist/preview/{chunk.VNDKKTED.js → chunk.G4ULQK64.js} +14 -14
  62. package/dist/preview/{chunk.Y7G3OGDE.js → chunk.GX4G4BX3.js} +1 -1
  63. package/dist/preview/chunk.H24OC6OE.js +1 -0
  64. package/dist/preview/chunk.H5S7OL2U.js +1 -0
  65. package/dist/preview/chunk.H73ZPYUX.js +1 -0
  66. package/dist/preview/{chunk.GTKJJYQH.js → chunk.H7N7WN4U.js} +1 -1
  67. package/dist/preview/chunk.HANJZ6FA.js +1 -0
  68. package/dist/preview/chunk.HIMQ65QT.js +1 -0
  69. package/dist/preview/chunk.I77ZGIFE.js +1 -0
  70. package/dist/preview/{chunk.MJVYWLQQ.js → chunk.ILIIBSGA.js} +1 -1
  71. package/dist/preview/chunk.IQ3PRWGO.js +104 -0
  72. package/dist/preview/{chunk.NC7FXY2H.js → chunk.IQMD7DG3.js} +1 -1
  73. package/dist/preview/chunk.IQPILSV3.js +18 -0
  74. package/dist/preview/chunk.IYBEXENQ.js +1 -0
  75. package/dist/preview/{chunk.ULL6ZIJJ.js → chunk.J7Q2WAF4.js} +1 -1
  76. package/dist/preview/{chunk.TLWT67ON.js → chunk.JT3MFPRD.js} +1 -1
  77. package/dist/preview/chunk.JYFZCJ4N.js +2 -0
  78. package/dist/preview/chunk.K2HDEL7I.js +1 -0
  79. package/dist/preview/chunk.KDXU5DT3.js +1 -0
  80. package/dist/preview/chunk.KL7E4YHJ.js +1 -0
  81. package/dist/preview/{chunk.FRYBMS3W.js → chunk.KMV6PJFL.js} +1 -1
  82. package/dist/preview/{chunk.RXYNW5QB.js → chunk.L3WTKQQL.js} +1 -1
  83. package/dist/preview/chunk.LAYQ5PFS.js +1 -0
  84. package/dist/preview/{chunk.KBVTLNS5.js → chunk.LGRLVJGS.js} +3 -3
  85. package/dist/preview/chunk.LTZUF5VG.js +1 -0
  86. package/dist/preview/{chunk.OLFJH4RK.js → chunk.M4AYA2PL.js} +1 -1
  87. package/dist/preview/chunk.M7RESZB6.js +25 -0
  88. package/dist/preview/{chunk.WXUFATY5.js → chunk.MAKODQO3.js} +1 -1
  89. package/dist/preview/{chunk.F6V7RWDK.js → chunk.MDEX6ZVE.js} +1 -1
  90. package/dist/preview/chunk.MGALQLRW.js +1 -0
  91. package/dist/preview/{chunk.7OPM55I2.js → chunk.MYNMBOLD.js} +1 -1
  92. package/dist/preview/chunk.N6EJXXQK.js +2 -0
  93. package/dist/preview/chunk.NAD7ZXYP.js +1 -0
  94. package/dist/preview/chunk.NHTGAP3G.js +3 -0
  95. package/dist/preview/{chunk.5IEFTFKQ.js → chunk.NJSK3UO2.js} +1 -1
  96. package/dist/preview/{chunk.VFOON3Z3.js → chunk.NOGGSLVG.js} +1 -1
  97. package/dist/preview/chunk.NUWDMH47.js +1 -0
  98. package/dist/preview/chunk.NUYA4BWI.js +1 -0
  99. package/dist/preview/{chunk.VUBNBTJP.js → chunk.O2BHPYA4.js} +2 -2
  100. package/dist/preview/chunk.O75HWF3F.js +1 -0
  101. package/dist/preview/chunk.OFWNMTGB.js +21 -0
  102. package/dist/preview/chunk.OKZT2QBM.js +2 -0
  103. package/dist/preview/{chunk.EL5ICOOM.js → chunk.OUDATENL.js} +1 -1
  104. package/dist/preview/chunk.OUPURRDE.js +1 -0
  105. package/dist/preview/{chunk.Y5C4RXG7.js → chunk.OWOOKLIU.js} +2 -1
  106. package/dist/preview/{chunk.PI44XMY2.js → chunk.OWT3VVOT.js} +1 -1
  107. package/dist/preview/{chunk.VDMDPZ6U.js → chunk.PCDUV3WP.js} +1 -1
  108. package/dist/preview/chunk.PD2DECOP.js +1 -0
  109. package/dist/preview/{chunk.ZXOT3IXJ.js → chunk.PKWQKFPE.js} +1 -1
  110. package/dist/preview/{chunk.ENL2JJ47.js → chunk.PLTH2LW5.js} +1 -1
  111. package/dist/preview/{chunk.ZP5RT2EK.js → chunk.PZQNR4KZ.js} +1 -1
  112. package/dist/preview/chunk.Q5WEOX3Q.js +1 -0
  113. package/dist/preview/chunk.QDWSU47A.js +1 -0
  114. package/dist/preview/{chunk.VADQ7ZGA.js → chunk.QGU5QTR6.js} +1 -1
  115. package/dist/preview/chunk.QHY5NVYH.js +1 -0
  116. package/dist/preview/{chunk.6ZQAR5ZA.js → chunk.QIPASE42.js} +1 -1
  117. package/dist/preview/{chunk.7MHCGVGM.js → chunk.RD2X25XB.js} +1 -1
  118. package/dist/preview/chunk.RMR24LFJ.js +4 -0
  119. package/dist/preview/chunk.ROZTJ6IY.js +6 -0
  120. package/dist/preview/{chunk.RQOX5YDW.js → chunk.RPDH32XV.js} +1 -1
  121. package/dist/preview/chunk.RRKI24WY.js +1 -0
  122. package/dist/preview/{chunk.HDP3PS7N.js → chunk.RYRQ66JN.js} +1 -1
  123. package/dist/preview/chunk.SEHRPTNA.js +7 -0
  124. package/dist/preview/chunk.SGCW2XRC.js +1 -0
  125. package/dist/preview/{chunk.JPONLMU7.js → chunk.SS7234R6.js} +1 -1
  126. package/dist/preview/{chunk.BXDM3UMN.js → chunk.SVPKUWZU.js} +1 -1
  127. package/dist/preview/{chunk.LQVAABPS.js → chunk.SWMDFXUX.js} +1 -1
  128. package/dist/preview/{chunk.6WHAWOO7.js → chunk.T3UQ7ZQK.js} +1 -1
  129. package/dist/preview/chunk.T6PU3NKP.js +1 -0
  130. package/dist/preview/{chunk.6C2MHWSX.js → chunk.T6WHGKWR.js} +1 -1
  131. package/dist/preview/{chunk.QBLKTFF4.js → chunk.THVC2BEC.js} +1 -1
  132. package/dist/preview/{chunk.KDRLUBVF.js → chunk.TIALD6SC.js} +1 -1
  133. package/dist/preview/{chunk.Z2ERZ4S6.js → chunk.TM4EPUNO.js} +1 -1
  134. package/dist/preview/chunk.U5P23GO7.js +1 -0
  135. package/dist/preview/chunk.U6ZRJKVM.js +1 -0
  136. package/dist/preview/chunk.UFDJXQQQ.js +32 -0
  137. package/dist/preview/{chunk.IOK4GVJC.js → chunk.UKQUUPKE.js} +1 -1
  138. package/dist/preview/{chunk.TAT2IQUR.js → chunk.UQQKDBIH.js} +1 -1
  139. package/dist/preview/{chunk.QHDCTAD7.js → chunk.UVA7AALY.js} +1 -1
  140. package/dist/preview/chunk.UXMPFPFH.js +20 -0
  141. package/dist/preview/chunk.VACKSKGJ.js +1 -0
  142. package/dist/preview/{chunk.3UOKUF5Z.js → chunk.VC3V7HLL.js} +1 -1
  143. package/dist/preview/chunk.VIH5AX7S.js +5 -0
  144. package/dist/preview/{chunk.4LR64TPU.js → chunk.VJBBVLGZ.js} +1 -1
  145. package/dist/preview/chunk.VN23AGIY.js +1 -0
  146. package/dist/preview/{chunk.VZJWJ5XM.js → chunk.W4BKYSZX.js} +1 -1
  147. package/dist/preview/{chunk.CQT3W2SF.js → chunk.WEOVK2T4.js} +1 -1
  148. package/dist/preview/chunk.WKI5INH7.js +1 -0
  149. package/dist/preview/chunk.WPXPVD33.js +88 -0
  150. package/dist/preview/chunk.X6KYRBL6.js +1 -0
  151. package/dist/preview/chunk.Y2YYH3JN.js +1 -0
  152. package/dist/preview/chunk.Y4FZKUOK.js +1 -0
  153. package/dist/preview/chunk.Y4S7CDRB.js +1 -0
  154. package/dist/preview/{chunk.YFSBVZTG.js → chunk.YP2QSPXU.js} +1 -1
  155. package/dist/preview/{chunk.VWJGQDCE.js → chunk.Z2TDZSMN.js} +1 -1
  156. package/dist/preview/chunk.ZN3PUM2I.js +1 -0
  157. package/dist/preview/index.html +53 -51
  158. package/dist/preview/page.js +2 -2
  159. package/dist/preview/splash.js +57 -0
  160. package/package.json +6 -6
  161. package/dist/preview/chunk.2K4TT2BV.js +0 -1
  162. package/dist/preview/chunk.37TVS7CA.js +0 -1
  163. package/dist/preview/chunk.3IZ3ABII.js +0 -1
  164. package/dist/preview/chunk.3MOJF7BA.js +0 -1
  165. package/dist/preview/chunk.3V4WP7RY.js +0 -18
  166. package/dist/preview/chunk.3ZT5WQYL.js +0 -1
  167. package/dist/preview/chunk.4MP72LPR.js +0 -25
  168. package/dist/preview/chunk.4TCKEG6I.js +0 -1
  169. package/dist/preview/chunk.5DD62IOW.js +0 -21
  170. package/dist/preview/chunk.5YOLUDVO.js +0 -1
  171. package/dist/preview/chunk.644FUGSX.js +0 -1
  172. package/dist/preview/chunk.67U6M7OV.js +0 -1
  173. package/dist/preview/chunk.7TFLRR7D.js +0 -1
  174. package/dist/preview/chunk.7VKSXGTX.js +0 -1
  175. package/dist/preview/chunk.BF6S5UE4.js +0 -1
  176. package/dist/preview/chunk.BLPYNNR4.js +0 -1
  177. package/dist/preview/chunk.BRT27WON.js +0 -1
  178. package/dist/preview/chunk.BYKD5RLA.js +0 -1
  179. package/dist/preview/chunk.C7OLSEWK.js +0 -1
  180. package/dist/preview/chunk.CFKZXLXS.js +0 -1
  181. package/dist/preview/chunk.CMN6BBAD.js +0 -1
  182. package/dist/preview/chunk.D7YSL3NK.js +0 -2
  183. package/dist/preview/chunk.EQXB7LKI.js +0 -1
  184. package/dist/preview/chunk.ERFT54HT.js +0 -1
  185. package/dist/preview/chunk.FLUK3UXF.js +0 -1
  186. package/dist/preview/chunk.G3R4BTI7.js +0 -1
  187. package/dist/preview/chunk.G4YJPKRG.js +0 -5
  188. package/dist/preview/chunk.GLWSVSQL.js +0 -1
  189. package/dist/preview/chunk.I4XQBQRC.js +0 -1
  190. package/dist/preview/chunk.IBOKXVWN.js +0 -1
  191. package/dist/preview/chunk.IHBUBZQT.js +0 -2
  192. package/dist/preview/chunk.JEYQBH33.js +0 -32
  193. package/dist/preview/chunk.JJGCTGWA.js +0 -1
  194. package/dist/preview/chunk.KGW75Z5L.js +0 -3
  195. package/dist/preview/chunk.KI37ZEV3.js +0 -1
  196. package/dist/preview/chunk.KNYLY7MH.js +0 -1
  197. package/dist/preview/chunk.L6AWE76F.js +0 -1
  198. package/dist/preview/chunk.LGEA5257.js +0 -6
  199. package/dist/preview/chunk.LLYRFVIN.js +0 -104
  200. package/dist/preview/chunk.LZIBQ3VX.js +0 -1
  201. package/dist/preview/chunk.MDJWK5W2.js +0 -1
  202. package/dist/preview/chunk.MSWWWLEA.js +0 -1
  203. package/dist/preview/chunk.PFSYXD6Q.js +0 -1
  204. package/dist/preview/chunk.PHC2MI4C.js +0 -1
  205. package/dist/preview/chunk.PHJ6WPWH.js +0 -1
  206. package/dist/preview/chunk.PNW5K7BW.js +0 -1
  207. package/dist/preview/chunk.PXQVXBNG.js +0 -1
  208. package/dist/preview/chunk.QFUMFQJU.js +0 -1
  209. package/dist/preview/chunk.QI4SLPQ4.js +0 -4
  210. package/dist/preview/chunk.QUJS63OJ.js +0 -13
  211. package/dist/preview/chunk.SB2PZKN5.js +0 -88
  212. package/dist/preview/chunk.T7LQD67N.js +0 -20
  213. package/dist/preview/chunk.TY4GQJKC.js +0 -1
  214. package/dist/preview/chunk.UDCDK7XJ.js +0 -4
  215. package/dist/preview/chunk.UITT6JWW.js +0 -2
  216. package/dist/preview/chunk.UJTE7UAP.js +0 -1
  217. package/dist/preview/chunk.UQWTZJBV.js +0 -1
  218. package/dist/preview/chunk.VMV464JK.js +0 -1
  219. package/dist/preview/chunk.VSCIXAHN.js +0 -5
  220. package/dist/preview/chunk.W3W54DSX.js +0 -1
  221. package/dist/preview/chunk.WC3DENU4.js +0 -67
  222. package/dist/preview/chunk.WQ6RCEUQ.js +0 -1
  223. package/dist/preview/chunk.X6A4VSSD.js +0 -1
  224. package/dist/preview/chunk.XGASJAV2.js +0 -7
  225. package/dist/preview/chunk.XR6YR6RV.js +0 -1
  226. package/dist/preview/chunk.XZPKBHJT.js +0 -1
  227. package/dist/preview/chunk.YEBGI6ED.js +0 -1
  228. package/dist/preview/chunk.YH63KQ2G.js +0 -1
@@ -1 +1 @@
1
- import{a as B,b as ve}from"./chunk.BQIHNT7C.js";import{a as ye,c as he,d as be,f as we}from"./chunk.2K4TT2BV.js";import{b as S,c as fe,d as me,j as ce,k as ge}from"./chunk.MSWWWLEA.js";import{b as pe,k as q}from"./chunk.UITT6JWW.js";import{c as de,f as ue}from"./chunk.A5PDXNY6.js";import{G as Re,T as se,ca as le,h as ae,u as ie}from"./chunk.4MP72LPR.js";import{Ha as te,Sa as re,Ta as oe,da as Z,ga as ee,oa as ne}from"./chunk.VSCIXAHN.js";import{b as W}from"./chunk.AJZBJBMO.js";var l=W(Re(),1);var i=W(se(),1);function qe({affordance:n,onApply:a,onCancel:u,store:w}){let y=le(),s=w??y?.store,[x,_]=(0,l.useState)({}),[p,D]=(0,l.useState)(""),[I,F]=(0,l.useState)(G),[J,V]=(0,l.useState)(void 0),U=(0,l.useId)(),L=(0,l.useRef)(null),A=n.open.filter(e=>!(e.name in x)),o=A[0],v=s.allMutations().find(e=>e.name===n.mutation),P=(0,l.useMemo)(()=>De(v,s,n.args??{}),[v,s,n.args]),d=o?P[o.name]:void 0,E=ge(n.open.filter(e=>e.shape?.type==="date").map(e=>e.name)),Se=(()=>{if(!E||o?.name!==E.end||o.shape?.type!=="date")return;let e=x[E.start];if(typeof e!="string")return;let r=P[E.start];return ce(typeof r=="string"?r:void 0,e,typeof d=="string"?d:void 0,{time:o.shape.time===!0,instant:o.shape.instant===!0})})();(0,l.useEffect)(()=>{D(Se??ke(d,o?.shape)),F(Array.isArray(d)?d:G),V(d)},[o?.name]),(0,l.useEffect)(()=>{L.current?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[o?.name]),(0,l.useLayoutEffect)(()=>{let e=L.current,r=typeof document>"u"?null:document.activeElement,f=r instanceof HTMLElement&&r.getAttribute("data-affordance")===n.id;if(!e||r&&r!==document.body&&!e.contains(r)&&!f)return;let b=e.querySelector('[data-testid="ask-filter"], form input, [role=group] button:not([disabled])');b&&b!==r&&b.focus()},[o?.name]);let Y=ve({flow:"both",letters:!0});if(!o)return null;let h=e=>{let r=d!==void 0&&JSON.stringify(e)===JSON.stringify(d)?void 0:e,f={...x,[o.name]:r};if(n.open.filter(R=>!(R.name in f)).length===0){let R=a(Object.fromEntries(Object.entries(f).filter(([,M])=>M!==void 0)));R&&R.length>0&&_(Object.fromEntries(Object.entries(f).filter(([M])=>!R.includes(M))))}else _(f)},O=o.optional?(0,i.jsx)("button",{type:"button",onClick:()=>h(void 0),style:{fontSize:"0.8125rem"},children:"Skip"}):null,t=o.shape??{type:"unknown"},c=t.type==="number"?t.amount:void 0,g=Ee(o,t),m=q(s.schema,v,o.name),Q=te((v?.input?.shape??{})[o.name]),xe=oe((v?.input?.shape??{})[o.name]),N=re(o.name),Ae=typeof d=="boolean"?d?"yes":"no":d,[T,Oe]=(0,l.useState)(""),X=(0,l.useMemo)(()=>{let e=g.map(r=>s.graph.getNode(r)).filter(r=>r!==void 0);return pe(e,r=>s.schema.tryDefinition(r))},[g,s]),j=e=>{let r=Ce(s,t,e),f=t.type==="choice"||t.type==="several"&&t.of.type==="choice"?m.option(e):r,b=X.get(e);return b?`${f} \xB7 ${b}`:f},$=(0,l.useMemo)(()=>{let e=T.trim().toLowerCase();return e===""?g:g.filter(r=>j(r).toLowerCase().includes(e))},[g,T,s,t,X]),k=t.type==="several",H=t.type==="file"?t:t.type==="several"&&t.of.type==="file"?t.of:void 0,K=k&&g.length===0,C=o.kinds&&o.kinds.length>0&&!o.kinds.includes("*")?o.kinds.map(e=>Z(ne(s.schema.tryDefinition(e),e))).join(" or "):m.label,Ne=n.open.length>1?`${C} \xB7 ${n.open.length-A.length+1} of ${n.open.length}`:C;return(0,i.jsxs)("div",{ref:L,"data-graview-asking":n.id,style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:4,padding:"5px 0 2px"},children:[n.open.length>1||g.length>0?(0,i.jsx)("span",{id:U,style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:Ne}):null,g.length>z?(0,i.jsx)("input",{type:"search",value:T,onChange:e=>Oe(e.target.value),placeholder:`Filter ${g.length}\u2026`,"aria-label":`Filter ${C}`,"data-testid":"ask-filter",onKeyDown:e=>{if(e.key!=="ArrowDown"||e.metaKey||e.ctrlKey||e.altKey)return;let r=Y.ref.current?.querySelector(`[${B}][tabindex="0"]`);r&&(e.preventDefault(),r.focus())},style:{font:"inherit",fontSize:"0.8125rem",minWidth:0,padding:"3px 7px"}}):null,xe?(0,i.jsxs)("form",{style:{display:"grid",gap:4},onSubmit:e=>{e.preventDefault(),h(J??(d===void 0?void 0:null))},children:[(0,i.jsx)(be,{value:J,onChange:V,start:N?x[N]??P[N]:void 0,label:`${N?q(s.schema,v,N).label:m.label} repeats`,name:o.name}),(0,i.jsxs)("span",{style:{display:"flex",gap:4},children:[(0,i.jsx)("button",{type:"submit",style:{fontSize:"0.8125rem"},children:A.length>1?"Next":"Apply"}),O]})]}):Q?(0,i.jsxs)("div",{style:{display:"grid",gap:4},children:[(0,i.jsx)(he,{relation:Q,value:d,onChange:h,label:m.label}),O]}):H?(0,i.jsxs)("div",{style:{display:"grid",gap:4},children:[(0,i.jsx)(ye,{as:"control",value:d,onChange:h,several:k,image:H.image===!0,video:H.video===!0,label:m.label}),O]}):g.length>0?(0,i.jsxs)("div",{...Y,role:"group","aria-labelledby":U,style:{display:"flex",flexWrap:"wrap",gap:4},children:[$.slice(0,z).map(e=>{let r=k?I.includes(e):e===Ae;return(0,i.jsx)("button",{type:"button",[B]:"","aria-label":`${C}: ${j(e)}`,...k?{"aria-pressed":r}:r?{"aria-current":!0}:{},style:{padding:"3px 9px",fontSize:"0.8125rem",...r?{borderColor:"var(--graview-accent)",color:"var(--graview-accent)"}:{}},onClick:()=>k?F(f=>f.includes(e)?f.filter(b=>b!==e):[...f,e]):h(t.type==="boolean"?e==="yes":e),children:j(e)},e)}),$.length>z?(0,i.jsxs)("span",{"data-testid":"ask-more",style:{alignSelf:"center",fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:[$.length-z," more \u2014 type to narrow"]}):null,$.length===0?(0,i.jsxs)("span",{"data-testid":"ask-none",style:{alignSelf:"center",fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:["None of the ",g.length," match that."]}):null,k?(0,i.jsx)("button",{type:"button",disabled:I.length===0,style:{fontSize:"0.8125rem"},onClick:()=>{let e=I;F(G),h(e)},children:A.length>1?"Next":"Apply"}):null,O]}):(0,i.jsxs)("form",{style:{display:"flex",flexWrap:"wrap",gap:4},onSubmit:e=>{if(e.preventDefault(),d!==void 0&&p===ke(d,t)){h(void 0);return}if(K){h(p.split(/[,\n]/).map(r=>r.trim()).filter(Boolean));return}if(p.trim().length!==0){if(c){let r=me(p,c);r!==void 0&&h(r);return}h(t.type==="number"?t.duration?ue(p)??p:Number(p):p)}},children:[t.type==="text"&&t.long?(0,i.jsx)("textarea",{autoFocus:!0,name:o.name,"aria-label":m.label,placeholder:m.label,value:p,rows:4,onChange:e=>D(e.target.value),onKeyDown:e=>{e.key==="Escape"?u():e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},style:{flex:"1 1 100%",minWidth:0,font:"inherit",fontSize:"0.875rem",lineHeight:1.45,padding:"5px 8px",borderRadius:7,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",color:"var(--graview-ink)",resize:"vertical",fieldSizing:"content",minHeight:"5.5em",maxHeight:"40vh"}}):t.type==="date"?(0,i.jsx)(we,{autoFocus:!0,name:o.name,label:m.label,value:p===""?void 0:p,time:t.time===!0,instant:t.instant===!0,partial:t.partial===!0,onChange:e=>D(e??""),onCancel:u,boxStyle:{fontSize:"0.875rem",padding:"5px 8px",borderRadius:7,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",color:"var(--graview-ink)"}}):(0,i.jsx)("input",{autoFocus:!0,type:t.type==="number"&&!t.duration&&!c?"number":t.type==="text"&&t.holds==="phone"?"tel":"text",...c?{inputMode:"decimal","data-graview-amount":c.format??"unit"}:{},name:o.name,"aria-label":m.label,placeholder:K?`${m.label}, separated by commas`:c?`${m.label}, ${S(c).hint} \u2014 ${S(c).prefix??""}${S(c).placeholder}${S(c).suffix?` ${S(c).suffix}`:""}`:m.label,value:p,...t.type==="number"&&t.min!==void 0?{min:t.min}:{},...t.type==="number"&&t.max!==void 0?{max:t.max}:{},...t.type==="number"&&t.step!==void 0?{step:t.step}:{},onChange:e=>D(e.target.value),onKeyDown:e=>{e.key==="Escape"&&u()},style:{flex:1,minWidth:0,font:"inherit",fontSize:"0.875rem",padding:"5px 8px",borderRadius:7,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",color:"var(--graview-ink)"}}),(0,i.jsx)("button",{type:"submit",disabled:!K&&p.trim().length===0,style:{fontSize:"0.8125rem"},children:A.length>1?"Next":"Apply"}),O]})]})}var G=[];function De(n,a,u){let w=n?.derived?.act==="edit"&&n.subject?u[n.subject.arg]:void 0,y=typeof w=="string"?a.graph.getNode(w):void 0;return y?Object.fromEntries((n.writes??[]).filter(s=>y[s]!==void 0&&y[s]!==null).map(s=>[s,y[s]])):{}}function ke(n,a){return typeof n=="number"?a?.type==="number"&&a.amount?fe(n,a.amount):String(n):Array.isArray(n)?n.every(u=>typeof u=="string")?n.join(", "):"":typeof n!="string"?"":n}var z=10;function Ee(n,a){return n.candidates&&n.candidates.length>0?n.candidates:a.type==="choice"?a.options:a.type==="several"&&a.of.type==="choice"?a.of.options:a.type==="boolean"?$e:[]}var $e=["yes","no"];function Ce(n,a,u){return a.type==="boolean"||a.type==="choice"||a.type==="several"&&a.of.type==="choice"?u:ze(n,u)}function ze(n,a){let u=ae(a);if(u){let s=de(n.schema,n.graph.getNode(u.from)?.kind??"",u.kind,"out");return s.charAt(0).toUpperCase()+s.slice(1)}let w=ie(a);if(w.length>0)return w.map(s=>n.schema.tryDefinition(s)?.plural??`${s}s`).join(" + ");let y=n.graph.getNode(a);return y?ee(n.schema.tryDefinition(y.kind),y):a}export{qe as a,ze as b};
1
+ import{a as B,b as ve}from"./chunk.66P5IDTH.js";import{a as ye,c as he,d as be,f as we}from"./chunk.KDXU5DT3.js";import{b as S,c as fe,d as me,j as ce,k as ge}from"./chunk.NUYA4BWI.js";import{b as pe,k as q}from"./chunk.OKZT2QBM.js";import{c as de,f as ue}from"./chunk.ACTXR2MI.js";import{G as Re,T as se,ca as le,h as ae,u as ie}from"./chunk.M7RESZB6.js";import{Ka as te,Va as re,Wa as oe,ga as Z,ja as ee,ra as ne}from"./chunk.DZZL5IDD.js";import{b as W}from"./chunk.AJZBJBMO.js";var l=W(Re(),1);var i=W(se(),1);function qe({affordance:n,onApply:a,onCancel:u,store:w}){let y=le(),s=w??y?.store,[x,_]=(0,l.useState)({}),[p,D]=(0,l.useState)(""),[I,F]=(0,l.useState)(G),[J,V]=(0,l.useState)(void 0),U=(0,l.useId)(),L=(0,l.useRef)(null),A=n.open.filter(e=>!(e.name in x)),o=A[0],v=s.allMutations().find(e=>e.name===n.mutation),P=(0,l.useMemo)(()=>De(v,s,n.args??{}),[v,s,n.args]),d=o?P[o.name]:void 0,E=ge(n.open.filter(e=>e.shape?.type==="date").map(e=>e.name)),Se=(()=>{if(!E||o?.name!==E.end||o.shape?.type!=="date")return;let e=x[E.start];if(typeof e!="string")return;let r=P[E.start];return ce(typeof r=="string"?r:void 0,e,typeof d=="string"?d:void 0,{time:o.shape.time===!0,instant:o.shape.instant===!0})})();(0,l.useEffect)(()=>{D(Se??ke(d,o?.shape)),F(Array.isArray(d)?d:G),V(d)},[o?.name]),(0,l.useEffect)(()=>{L.current?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[o?.name]),(0,l.useLayoutEffect)(()=>{let e=L.current,r=typeof document>"u"?null:document.activeElement,f=r instanceof HTMLElement&&r.getAttribute("data-affordance")===n.id;if(!e||r&&r!==document.body&&!e.contains(r)&&!f)return;let b=e.querySelector('[data-testid="ask-filter"], form input, [role=group] button:not([disabled])');b&&b!==r&&b.focus()},[o?.name]);let Y=ve({flow:"both",letters:!0});if(!o)return null;let h=e=>{let r=d!==void 0&&JSON.stringify(e)===JSON.stringify(d)?void 0:e,f={...x,[o.name]:r};if(n.open.filter(R=>!(R.name in f)).length===0){let R=a(Object.fromEntries(Object.entries(f).filter(([,M])=>M!==void 0)));R&&R.length>0&&_(Object.fromEntries(Object.entries(f).filter(([M])=>!R.includes(M))))}else _(f)},O=o.optional?(0,i.jsx)("button",{type:"button",onClick:()=>h(void 0),style:{fontSize:"0.8125rem"},children:"Skip"}):null,t=o.shape??{type:"unknown"},c=t.type==="number"?t.amount:void 0,g=Ee(o,t),m=q(s.schema,v,o.name),Q=te((v?.input?.shape??{})[o.name]),xe=oe((v?.input?.shape??{})[o.name]),N=re(o.name),Ae=typeof d=="boolean"?d?"yes":"no":d,[T,Oe]=(0,l.useState)(""),X=(0,l.useMemo)(()=>{let e=g.map(r=>s.graph.getNode(r)).filter(r=>r!==void 0);return pe(e,r=>s.schema.tryDefinition(r))},[g,s]),j=e=>{let r=Ce(s,t,e),f=t.type==="choice"||t.type==="several"&&t.of.type==="choice"?m.option(e):r,b=X.get(e);return b?`${f} \xB7 ${b}`:f},$=(0,l.useMemo)(()=>{let e=T.trim().toLowerCase();return e===""?g:g.filter(r=>j(r).toLowerCase().includes(e))},[g,T,s,t,X]),k=t.type==="several",H=t.type==="file"?t:t.type==="several"&&t.of.type==="file"?t.of:void 0,K=k&&g.length===0,C=o.kinds&&o.kinds.length>0&&!o.kinds.includes("*")?o.kinds.map(e=>Z(ne(s.schema.tryDefinition(e),e))).join(" or "):m.label,Ne=n.open.length>1?`${C} \xB7 ${n.open.length-A.length+1} of ${n.open.length}`:C;return(0,i.jsxs)("div",{ref:L,"data-graview-asking":n.id,style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:4,padding:"5px 0 2px"},children:[n.open.length>1||g.length>0?(0,i.jsx)("span",{id:U,style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:Ne}):null,g.length>z?(0,i.jsx)("input",{type:"search",value:T,onChange:e=>Oe(e.target.value),placeholder:`Filter ${g.length}\u2026`,"aria-label":`Filter ${C}`,"data-testid":"ask-filter",onKeyDown:e=>{if(e.key!=="ArrowDown"||e.metaKey||e.ctrlKey||e.altKey)return;let r=Y.ref.current?.querySelector(`[${B}][tabindex="0"]`);r&&(e.preventDefault(),r.focus())},style:{font:"inherit",fontSize:"0.8125rem",minWidth:0,padding:"3px 7px"}}):null,xe?(0,i.jsxs)("form",{style:{display:"grid",gap:4},onSubmit:e=>{e.preventDefault(),h(J??(d===void 0?void 0:null))},children:[(0,i.jsx)(be,{value:J,onChange:V,start:N?x[N]??P[N]:void 0,label:`${N?q(s.schema,v,N).label:m.label} repeats`,name:o.name}),(0,i.jsxs)("span",{style:{display:"flex",gap:4},children:[(0,i.jsx)("button",{type:"submit",style:{fontSize:"0.8125rem"},children:A.length>1?"Next":"Apply"}),O]})]}):Q?(0,i.jsxs)("div",{style:{display:"grid",gap:4},children:[(0,i.jsx)(he,{relation:Q,value:d,onChange:h,label:m.label}),O]}):H?(0,i.jsxs)("div",{style:{display:"grid",gap:4},children:[(0,i.jsx)(ye,{as:"control",value:d,onChange:h,several:k,image:H.image===!0,video:H.video===!0,label:m.label}),O]}):g.length>0?(0,i.jsxs)("div",{...Y,role:"group","aria-labelledby":U,style:{display:"flex",flexWrap:"wrap",gap:4},children:[$.slice(0,z).map(e=>{let r=k?I.includes(e):e===Ae;return(0,i.jsx)("button",{type:"button",[B]:"","aria-label":`${C}: ${j(e)}`,...k?{"aria-pressed":r}:r?{"aria-current":!0}:{},style:{padding:"3px 9px",fontSize:"0.8125rem",...r?{borderColor:"var(--graview-accent)",color:"var(--graview-accent)"}:{}},onClick:()=>k?F(f=>f.includes(e)?f.filter(b=>b!==e):[...f,e]):h(t.type==="boolean"?e==="yes":e),children:j(e)},e)}),$.length>z?(0,i.jsxs)("span",{"data-testid":"ask-more",style:{alignSelf:"center",fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:[$.length-z," more \u2014 type to narrow"]}):null,$.length===0?(0,i.jsxs)("span",{"data-testid":"ask-none",style:{alignSelf:"center",fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:["None of the ",g.length," match that."]}):null,k?(0,i.jsx)("button",{type:"button",disabled:I.length===0,style:{fontSize:"0.8125rem"},onClick:()=>{let e=I;F(G),h(e)},children:A.length>1?"Next":"Apply"}):null,O]}):(0,i.jsxs)("form",{style:{display:"flex",flexWrap:"wrap",gap:4},onSubmit:e=>{if(e.preventDefault(),d!==void 0&&p===ke(d,t)){h(void 0);return}if(K){h(p.split(/[,\n]/).map(r=>r.trim()).filter(Boolean));return}if(p.trim().length!==0){if(c){let r=me(p,c);r!==void 0&&h(r);return}h(t.type==="number"?t.duration?ue(p)??p:Number(p):p)}},children:[t.type==="text"&&t.long?(0,i.jsx)("textarea",{autoFocus:!0,name:o.name,"aria-label":m.label,placeholder:m.label,value:p,rows:4,onChange:e=>D(e.target.value),onKeyDown:e=>{e.key==="Escape"?u():e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},style:{flex:"1 1 100%",minWidth:0,font:"inherit",fontSize:"0.875rem",lineHeight:1.45,padding:"5px 8px",borderRadius:7,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",color:"var(--graview-ink)",resize:"vertical",fieldSizing:"content",minHeight:"5.5em",maxHeight:"40vh"}}):t.type==="date"?(0,i.jsx)(we,{autoFocus:!0,name:o.name,label:m.label,value:p===""?void 0:p,time:t.time===!0,instant:t.instant===!0,partial:t.partial===!0,onChange:e=>D(e??""),onCancel:u,boxStyle:{fontSize:"0.875rem",padding:"5px 8px",borderRadius:7,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",color:"var(--graview-ink)"}}):(0,i.jsx)("input",{autoFocus:!0,type:t.type==="number"&&!t.duration&&!c?"number":t.type==="text"&&t.holds==="phone"?"tel":"text",...c?{inputMode:"decimal","data-graview-amount":c.format??"unit"}:{},name:o.name,"aria-label":m.label,placeholder:K?`${m.label}, separated by commas`:c?`${m.label}, ${S(c).hint} \u2014 ${S(c).prefix??""}${S(c).placeholder}${S(c).suffix?` ${S(c).suffix}`:""}`:m.label,value:p,...t.type==="number"&&t.min!==void 0?{min:t.min}:{},...t.type==="number"&&t.max!==void 0?{max:t.max}:{},...t.type==="number"&&t.step!==void 0?{step:t.step}:{},onChange:e=>D(e.target.value),onKeyDown:e=>{e.key==="Escape"&&u()},style:{flex:1,minWidth:0,font:"inherit",fontSize:"0.875rem",padding:"5px 8px",borderRadius:7,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",color:"var(--graview-ink)"}}),(0,i.jsx)("button",{type:"submit",disabled:!K&&p.trim().length===0,style:{fontSize:"0.8125rem"},children:A.length>1?"Next":"Apply"}),O]})]})}var G=[];function De(n,a,u){let w=n?.derived?.act==="edit"&&n.subject?u[n.subject.arg]:void 0,y=typeof w=="string"?a.graph.getNode(w):void 0;return y?Object.fromEntries((n.writes??[]).filter(s=>y[s]!==void 0&&y[s]!==null).map(s=>[s,y[s]])):{}}function ke(n,a){return typeof n=="number"?a?.type==="number"&&a.amount?fe(n,a.amount):String(n):Array.isArray(n)?n.every(u=>typeof u=="string")?n.join(", "):"":typeof n!="string"?"":n}var z=10;function Ee(n,a){return n.candidates&&n.candidates.length>0?n.candidates:a.type==="choice"?a.options:a.type==="several"&&a.of.type==="choice"?a.of.options:a.type==="boolean"?$e:[]}var $e=["yes","no"];function Ce(n,a,u){return a.type==="boolean"||a.type==="choice"||a.type==="several"&&a.of.type==="choice"?u:ze(n,u)}function ze(n,a){let u=ae(a);if(u){let s=de(n.schema,n.graph.getNode(u.from)?.kind??"",u.kind,"out");return s.charAt(0).toUpperCase()+s.slice(1)}let w=ie(a);if(w.length>0)return w.map(s=>n.schema.tryDefinition(s)?.plural??`${s}s`).join(" + ");let y=n.graph.getNode(a);return y?ee(n.schema.tryDefinition(y.kind),y):a}export{qe as a,ze as b};
@@ -1 +1 @@
1
- import{b as cn,c as un}from"./chunk.VZJWJ5XM.js";import{j as x}from"./chunk.UITT6JWW.js";import{c as Z}from"./chunk.A5PDXNY6.js";import{Wb as on,Xb as E,ab as V,da as H,dc as rn,ec as an,ga as T,ha as K,ia as en,ja as tn,ma as sn,na as J,oa as G,od as dn,qc as Q,xc as U}from"./chunk.VSCIXAHN.js";function fn(){return{name:"insight",derive({store:n,nodes:d,kindSelection:t}){let f=[],v=l=>T(n.schema.tryDefinition(l.kind),l);for(let l of d){if([...n.schema.edgeKinds].reduce((c,w)=>c+n.graph.out(l.id,w).length+n.graph.in(l.id,w).length,0)===0){f.push({id:`insight:island:${l.id}`,text:`${v(l)} is connected to nothing yet`,nodeIds:[l.id]});continue}for(let c of n.schema.edgeKinds){let w=n.graph.in(l.id,c).length;if(w<3)continue;let s=[...n.graph.allEdges()].filter(a=>a.kind===c),e=s.length;e>=4&&w/e>.6&&f.push({id:`insight:load:${l.id}:${c}`,text:`${v(l)} ${vn(n,s,c,w)}`,nodeIds:[l.id]})}}for(let l of t){if(n.graph.nodesOfKind(l).length>0)continue;let A=n.schema.definitions.filter(c=>c.kind!==l).filter(c=>Object.values(c.edges).some(w=>w.to!=="*"&&w.to.includes(l))).map(c=>c.plural??`${c.kind}s`);A.length>0&&f.push({id:`insight:gap:${l}`,text:`Nothing here yet, though ${A.join(" and ")} expect to connect to these`,nodeIds:[]})}return{observations:f}}}}function vn(n,d,t,f){let v=new Set(d.map(s=>n.graph.getNode(s.from)?.kind).filter(s=>s!==void 0)),l=v.size===1?[...v][0]:void 0,A=d.length,c=Z(n.schema,l??[...v][0]??"",t,"in"),w=s=>l?en(n.schema,l,s):String(s);return f===A?`${c}: all ${w(f)}`:`${c}: ${f} of the ${w(A)}`}function ln(n){let d=new Map;if(n.length===0)return d;let t=n.slice(-512),f=new Set;for(let l of t)l.undoes&&f.add(l.undoes);let v=n[n.length-1].seq;for(let l of t){if(!l.mutation||f.has(l.id))continue;let A=Math.pow(.5,(v-l.seq)/64);d.set(l.mutation.name,(d.get(l.mutation.name)??0)+A)}return d}function hn(n){return 8*(n/(n+1))}var bn=100;function gn(){return{name:"invariant",derive({store:n,selection:d,nodes:t,violations:f}){let v=s=>T(n.schema.tryDefinition(s.kind),s),l=new Set(d),A=f.filter(s=>s.nodeIds.some(e=>l.has(e))||s.subjectId!==void 0&&l.has(s.subjectId)),c=[],w=[];A.forEach((s,e)=>{w.push({id:`violation:${s.invariant}:${e}`,text:s.message,nodeIds:s.nodeIds}),s.repairs.forEach((a,h)=>{c.push({id:`invariant:${s.invariant}:${e}:${h}`,label:a.label,provider:"invariant",mutation:a.mutation,args:a.args??{},open:(a.missing??[]).map(m=>{let r=n.allMutations().find(g=>g.name===a.mutation);if(!r)return{name:m};let o=E(r.input).find(g=>g.name===m),k=o?o.kinds.includes("*")?n.graph.allNodes().map(g=>g.id):o.kinds.flatMap(g=>n.graph.nodesOfKind(g).map($=>$.id)):void 0;return{name:m,shape:x(r.input,m),...o?{kinds:o.kinds}:{},...k?{candidates:k}:{}}}),score:bn-h-(a.missing?.length??0),why:s.message,nodeIds:s.nodeIds,...s.subjectId===void 0?{}:{subjectId:s.subjectId}})})});for(let s of t){let e=n.allInvariants().filter(a=>{if(a.scope==="graph")return!1;let h=a.scope;return h.kind!==s.kind?!1:h.match?h.match(s):!0});e.length!==0&&(A.some(a=>a.subjectId===s.id||a.nodeIds.includes(s.id))||w.push({id:`holds:${s.id}`,text:`${v(s)} holds \u2014 nothing currently breaks ${e.length===1?"it":`any of its ${e.length} rules`}`,nodeIds:[s.id]}))}return{affordances:c,observations:w}}}}var X=40;function pn(){return{name:"schema",derive({store:n,selection:d,nodes:t,kindSelection:f,edgeSelection:v,principal:l}){let A=(e,a)=>l!==void 0&&!n.permits({name:e,args:a},l).ok,c=[];if(t.length===0&&v.length>0){for(let e of v){let a=n.graph.getNode(e.from),h=n.graph.getNode(e.to);if(!a||!h)continue;let m=un(n,e);m?.provisional&&c.push({id:`schema:edge:${Q}:${e.kind}:${e.from}:${e.to}`,label:"Keep this link",provider:"schema",mutation:Q,args:{kind:e.kind,from:e.from,to:e.to},open:[],score:64,why:cn(m),nodeIds:[e.from,e.to]});for(let r of n.allMutations()){let o=(r.connects??[]).includes(e.kind),k=(r.severs??[]).includes(e.kind);if(!o&&!k||r.derived?.relation!==void 0&&r.derived.kind!==a.kind)continue;let g={},$=[],j=E(r.input);for(let p of j){let S=p.kinds.includes("*")||p.kinds.includes(a.kind),P=p.kinds.includes("*")||p.kinds.includes(h.kind),y=S&&!j.some(I=>I!==p&&(I.kinds.includes(a.kind)||I.kinds.includes("*")));S&&!P?g[p.name]=e.from:P&&!S?g[p.name]=e.to:S&&P&&y?g[p.name]=e.from:$.push({name:p.name,kinds:p.kinds,candidates:[e.from,e.to],shape:x(r.input,p.name)})}for(let p of q(r.input,""))p in g||$.some(S=>S.name===p)||$.push({name:p,shape:x(r.input,p)});$.every(p=>p.optional===!0?!0:p.kinds!==void 0?(p.candidates?.length??0)>0:(p.candidates?.length??0)>0||p.shape!==void 0&&p.shape.type!=="unknown")&&(o&&!k&&$.length===0||c.push({id:`schema:edge:${r.name}:${e.kind}:${e.from}:${e.to}`,label:K(r),provider:"schema",mutation:r.name,args:g,open:$,...r.destructive?{destructive:!0}:{},score:(k?62:58)-$.length,why:`this line is "${Z(n.schema,n.graph.getNode(e.from)?.kind??"",e.kind,"out")}"`,nodeIds:[e.from,e.to]}))}}return{affordances:c}}if(t.length===0&&f.length>0){let e=new Set(f),a=[];for(let h of n.allMutations()){if(!(h.creates??[]).some(o=>e.has(o)))continue;let m=[];for(let o of E(h.input)){let k=o.kinds.includes("*")?n.graph.allNodes().map(g=>g.id):o.kinds.flatMap(g=>n.graph.nodesOfKind(g).map($=>$.id));m.push({name:o.name,kinds:o.kinds,candidates:k,shape:x(h.input,o.name),...o.optional?{optional:!0}:{}})}for(let o of q(h.input,""))m.some(k=>k.name===o)||m.push({name:o,shape:x(h.input,o)});if(!m.every(o=>o.optional===!0?!0:o.kinds!==void 0?(o.candidates?.length??0)>0:(o.candidates?.length??0)>0||o.shape!==void 0&&o.shape.type!=="unknown")&&!A(h.name,{})){let o=m.filter(k=>k.optional!==!0&&k.kinds!==void 0&&!k.kinds.includes("*")&&(k.candidates?.length??0)===0);if(o.length>0){let k=[...new Set(o.flatMap(g=>g.kinds??[]))].map(g=>J(G(n.schema.tryDefinition(g),g)));a.push({id:`schema:waits:${h.name}`,text:`"${h.title??h.name}" cannot begin until there is ${k.length===1?k[0]:`${k.slice(0,-1).join(", ")} and ${k[k.length-1]}`}.`,nodeIds:[]})}continue}c.push({id:`schema:add:${h.name}`,label:K(h),provider:"schema",mutation:h.name,args:{},open:m,score:X-m.length,why:`this makes ${(h.creates??[]).filter(o=>e.has(o)).map(o=>J(G(n.schema.tryDefinition(o),o))).join(", ")}`,nodeIds:[]})}return{affordances:c,observations:a}}if(t.length===0)return{};let w=new Set(t.map(e=>e.kind)),s=(e,a,h)=>{let m=[];for(let r of n.graph.allEdges()){if(!a.includes(r.kind))continue;let o=r.from===e?r.to:r.to===e?r.from:null;if(!o)continue;let k=n.graph.getNode(o);k&&(!h.includes("*")&&!h.includes(k.kind)||m.includes(o)||m.push(o))}return m};for(let e of n.allMutations()){let a=e.subject;if(!a||!(a.kinds==="*"?!0:[...w].every(u=>a.kinds.includes(u))))continue;let m=e.derived?.act;if((m==="archive"||m==="merge")&&t.some(u=>V(u))||m==="unarchive"&&!t.some(u=>V(u))||m==="leave-alone"&&t.every(u=>U(n,u.id))||m==="allow-tidying"&&!t.some(u=>U(n,u.id)))continue;let r=t.length===1?t[0].id:null,o=e.severs??[],k=e.connects??[];if(r&&o.length>0&&k.length===0&&s(r,o,["*"]).length===0)continue;let g=[];for(let u of E(e.input)){if(u.name===a.arg)continue;let p=u.kinds.includes("*")?n.graph.allNodes().map(S=>S.id):u.kinds.flatMap(S=>n.graph.nodesOfKind(S).map(P=>P.id));if(r&&k.length>0){let S=new Set(s(r,k,u.kinds));p=p.filter(P=>!S.has(P))}else r&&o.length>0&&(p=s(r,o,u.kinds));g.push({name:u.name,kinds:u.kinds,candidates:p.filter(S=>!d.includes(S)),shape:x(e.input,u.name),...u.optional?{optional:!0}:{}})}for(let u of q(e.input,a.arg))g.some(p=>p.name===u)||g.push({name:u,shape:x(e.input,u)});if(g.length===0&&r){let u=Sn(e.input,a.arg);if(u.length>0&&!wn(n,e.name,{[a.arg]:r}))for(let p of u){let S=E(e.input).find(P=>P.name===p);g.push({name:p,optional:!0,...S?{kinds:S.kinds}:{},shape:x(e.input,p)})}}if(!g.every(u=>u.optional===!0?!0:u.kinds!==void 0?(u.candidates?.length??0)>0:(u.candidates?.length??0)>0||u.shape!==void 0&&u.shape.type!=="unknown")&&!A(e.name,r?{[a.arg]:r}:{}))continue;let j=t.map(u=>({[a.arg]:u.id}));g.length===0&&!j.some(u=>n.wouldChange({name:e.name,args:u}))||c.push({id:`schema:${e.name}`,label:t.length>1?`${K(e)} (${t.length})`:K(e),provider:"schema",mutation:e.name,args:j[0]??{},open:g,...e.destructive?{destructive:!0}:{},...e.derived?.act==="archive"||e.derived?.act==="merge"||e.derived?.act==="leave-alone"||e.derived?.act==="allow-tidying"?{setsAside:!0}:{},...o.length>0||k.length>0?{ties:!0}:{},...t.length>1?{batch:j}:{},score:X-g.length,why:t.length>1?`all ${t.length} selected nodes are ${[...w].map(u=>tn(n.schema,u).toLowerCase()).join(" or ")}`:`this is ${J(G(n.schema.tryDefinition(t[0].kind),t[0].kind))}`,nodeIds:t.map(u=>u.id)})}if(t.length===1){let e=t[0];for(let a of n.allMutations()){let h=a.subject,m=a.severs??[],r=a.connects??[];if(!h||m.length===0&&r.length===0)continue;let o=h.kinds==="*"?"*":h.kinds;if(o==="*"||o.includes(e.kind))continue;let k=E(a.input),g=k.find(y=>y.name!==h.arg&&(y.kinds.includes("*")||y.kinds.includes(e.kind)));if(!g)continue;let $=o,j=$.includes("*")?n.graph.allNodes().map(y=>y.id):$.flatMap(y=>n.graph.nodesOfKind(y).map(I=>I.id)),u=new Set(s(e.id,r.length>0?r:m,$)),p=r.length>0?j.filter(y=>!u.has(y)):j.filter(y=>u.has(y));if(p.length===0)continue;let S=[{name:h.arg,kinds:$,candidates:p,shape:x(a.input,h.arg)}];for(let y of k){if(y.name===g.name||y.name===h.arg)continue;let I=y.kinds.includes("*")?n.graph.allNodes().map(L=>L.id):y.kinds.flatMap(L=>n.graph.nodesOfKind(L).map(O=>O.id));S.push({name:y.name,kinds:y.kinds,candidates:I,shape:x(a.input,y.name),...y.optional?{optional:!0}:{}})}for(let y of q(a.input,g.name))y===h.arg||S.some(I=>I.name===y)||S.push({name:y,shape:x(a.input,y)});S.every(y=>y.optional===!0?!0:y.kinds!==void 0?(y.candidates?.length??0)>0:(y.candidates?.length??0)>0||y.shape!==void 0&&y.shape.type!=="unknown")&&c.push({id:`schema:tie:${a.name}:${e.id}`,label:a.fromTheOtherEnd??K(a),provider:"schema",mutation:a.name,args:{[g.name]:e.id},open:S,ties:!0,...a.destructive?{destructive:!0}:{},score:X-S.length+2,why:`${m.length>0?"this one is on":"this one could join"} ${S[0].candidates.length===1?"it":"one of these"}`,nodeIds:[e.id]})}}return{affordances:c}}}}function Sn(n,d){let t=n.shape;return t?Object.entries(t).filter(([f,v])=>f!==d&&v.safeParse(void 0).success).map(([f])=>f):[]}function wn(n,d,t){try{return n.preview({name:d,args:t}),!0}catch{return!1}}function q(n,d){let t=n.shape;return t?Object.entries(t).filter(([f,v])=>f!==d&&!v.safeParse(void 0).success).map(([f])=>f):[]}var An=70,$n=80,On=new Set(["id","kind"]);function mn(){return{name:"structure",derive({store:n,nodes:d}){let t=c=>T(n.schema.tryDefinition(c.kind),c);if(d.length<2)return{};let f=[],v=[],l=d.map(c=>c.id);for(let c of n.schema.edgeKinds){let w=In(d.map(e=>new Set([...n.graph.out(e.id,c).map(a=>a.id),...n.graph.in(e.id,c).map(a=>a.id)])));for(let e of w){let a=n.graph.getNode(e);a&&f.push({id:`shared:${c}:${e}`,text:`all ${d.length} share "${t(a)}" (${H(c).toLowerCase()})`,nodeIds:[...l,e]})}let s=new Map;for(let e of d)for(let a of[...n.graph.out(e.id,c),...n.graph.in(e.id,c)])s.set(a.id,(s.get(a.id)??0)+1);for(let[e,a]of s){if(a!==d.length-1||d.length<3||l.includes(e))continue;let h=n.graph.getNode(e);if(!h)continue;let m=d.find(r=>![...n.graph.out(r.id,c),...n.graph.in(r.id,c)].some(o=>o.id===e));if(m&&(f.push({id:`near-shared:${c}:${e}`,text:`all but "${t(m)}" share "${t(h)}" (${H(c).toLowerCase()})`,nodeIds:[...l,e]}),!(!n.schema.edgeAllowed(c,m.kind,h.kind)&&!n.schema.edgeAllowed(c,h.kind,m.kind))))for(let r of n.allMutations()){let o=r.subject;if(!o||o.kinds!=="*"&&!o.kinds.includes(m.kind)||(r.connects!==void 0||r.severs!==void 0)&&!(r.connects??[]).includes(c))continue;let g=Pn(r.input,h.kind);g&&v.push({id:`structure:join:${r.name}:${m.id}:${e}`,label:`${K(r)}: bring "${t(m)}" in line with the others`,provider:"structure",mutation:r.name,args:{[o.arg]:m.id,[g]:e},open:[],score:An,why:`every other selected node is connected to "${t(h)}"`,nodeIds:[m.id,e]})}}}let A=new Map;for(let c of d)A.set(c.kind,[...A.get(c.kind)??[],c]);for(let[c,w]of A){if(w.length<2)continue;let s=w,e=w.map(r=>r.id),a=A.size>1?`${c}:`:"",h=new Set;for(let r of s)for(let o of Object.keys(r))On.has(o)||h.add(o);let m=r=>n.schema.definitions.find(o=>o.kind===r);for(let r of[...h].sort()){let o=m(s[0].kind),k=sn(o,r).toLowerCase(),g=o?.display?.format?.[r],$=O=>{if(!g)return O;try{return String(g(JSON.parse(O)))}catch{return O}},j=s.map(O=>O[r]),u=new Map;if(j.forEach((O,R)=>{let D=JSON.stringify(O??null),M=u.get(D);M?M.push(s[R]):u.set(D,[s[R]])}),u.size===1){let O=[...u.keys()][0];if(O==="null")continue;f.push({id:`agree:${a}${r}`,text:`all ${s.length} share the ${k} ${$(O)}`,nodeIds:e});continue}if(s.length<3||u.size!==2)continue;let p=[...u.entries()].sort((O,R)=>R[1].length-O[1].length),[S,P]=p[0],[,y]=p[1];if(y.length!==1||S==="null")continue;let I=y[0],L=JSON.parse(S);f.push({id:`odd-one-out:${a}${r}`,text:`${P.length} share the ${k} ${$(S)}; "${t(I)}" does not`,nodeIds:e});for(let O of n.allMutations()){let R=O.subject;if(!R||R.kinds!=="*"&&!R.kinds.includes(I.kind))continue;let D=kn(O.input);if(!D||!(r in D))continue;let M={[R.arg]:I.id,[r]:L},C=!0;for(let[W,z]of Object.entries(D)){if(W in M||z.safeParse(void 0).success)continue;let B=I[W];if(B===void 0){C=!1;break}M[W]=B}!C||!O.input.safeParse(M).success||v.push({id:`structure:align:${O.name}:${r}:${I.id}`,label:`Align the ${k} of "${t(I)}" with the other ${P.length}`,provider:"structure",mutation:O.name,args:M,open:[],score:$n,why:`${P.length} of ${s.length} share the ${k} ${$(S)}`,nodeIds:e})}}}return{affordances:v,observations:f}}}}function In(n){if(n.length===0)return[];let[d,...t]=n;return[...d].filter(f=>t.every(v=>v.has(f))).sort()}function kn(n){return n.shape??null}function Pn(n,d){let t=kn(n);if(!t)return null;for(let[f]of Object.entries(t)){let v=on(t[f]);if(v&&(v.includes("*")||v.includes(d)))return f}return null}function jn(){return[gn(),mn(),pn(),fn()]}function Xn(n,d,t={}){let f=yn(),v=t.providers??jn(),l=d.map(i=>n.graph.getNode(i)).filter(i=>i!==void 0),A={store:n,selection:d,nodes:l,kindSelection:t.kindSelection??[],edgeSelection:t.edgeSelection??[],violations:n.violations(t.context),context:t.context??{},principal:t.principal??{kind:"human"}},c=[],w=[];for(let i of v){let b=i.derive(A);c.push(...b.affordances??[]),w.push(...b.observations??[])}let s=new Map(n.allMutations().map(i=>[i.name,i]));c.forEach((i,b)=>{let N=i.open.length>1?s.get(i.mutation):void 0;N&&(c[b]={...i,open:an(i.open,rn(n.schema,N))})});let e=new Set(n.allMutations().filter(i=>i.pinned).map(i=>i.name)),a=new Set(t.pins?.pinned??[]),h=new Set(t.pins?.unpinned??[]),m=i=>a.has(i.mutation)?"user":e.has(i.mutation)&&!h.has(i.mutation)?"declared":void 0,r=i=>{let b=m(i);return b?{...i,pinned:b}:i},o=new Map;for(let[i,b]of ln(n.log.all()))o.set(i,hn(b));let k=i=>i.pinned==="user"?0:i.pinned==="declared"?1:2,g=i=>i.score+(o.get(i.mutation)??0),$=new Map(n.allMutations().map(i=>[i.name,i])),j=new Map,u=i=>{let b=$.get(i.mutation);if(!b)return[];let N=j.get(i.mutation);N||(N=E(b.input).map(F=>F.name),j.set(i.mutation,N));let _=[];for(let F of i.batch??[i.args])for(let Y of N){let nn=F[Y]??i.args[Y];typeof nn=="string"&&_.push(nn)}return _},p=t.focus,S=4,P=i=>i.open.length>0?1:0,y=i=>{if(p===void 0)return S;let b=u(i);return b.length>0?b.includes(p)?I(i,0):S:i.nodeIds.includes(p)||i.subjectId===p?I(i,1):S},I=(i,b)=>i.provider==="invariant"?b:2+P(i),L=i=>i.setsAside?1:0,O=Nn(c).map(r),R=new Map(O.map((i,b)=>[i,b])),D=O.sort((i,b)=>{let N=Number(i.destructive??!1)-Number(b.destructive??!1);if(N!==0)return N;let _=L(i)-L(b);if(_!==0)return _;let F=y(i)-y(b);return F!==0?F:y(i)<2?R.get(i)-R.get(b):+(b.provider==="invariant")-+(i.provider==="invariant")||k(i)-k(b)||g(b)-g(i)||i.id.localeCompare(b.id)}),M=t.principal??{kind:"human"},C=[],W=[];for(let i of D){let b=n.permits({name:i.mutation,args:{...i.args,...i.batch?.[0]??{}}},M);if(b.ok)C.push(i);else{let N=Rn(n,i,M);if(N==="done")continue;N?C.push(N):W.push({...i,refusal:b.refusal})}}let z=C.map((i,b)=>({...i,rank:b})),B=W.map((i,b)=>({...i,rank:C.length+b}));return{affordances:t.limit===void 0?z:z.slice(0,t.limit),withheld:B,observations:xn(w),ms:yn()-f}}function Nn(n){let d=new Map;for(let t of n){let f=[t.mutation,JSON.stringify(t.args),JSON.stringify(t.batch??null)].join("|"),v=d.get(f);(!v||t.score>v.score)&&d.set(f,t)}return[...d.values()]}function xn(n){let d=new Map;for(let t of n)d.set(t.text,t);return[...d.values()]}function yn(){return typeof performance<"u"?performance.now():Date.now()}function Yn(n,d,t={},f={}){let v=(d.batch??[d.args]).map(A=>({name:d.mutation,args:{...d.args,...A,...t}})),l=n.allMutations().find(A=>A.name===d.mutation);return n.applyAll(v,{...l?.describe?{}:{intent:d.label},...f.author?{author:f.author}:{}})}function ne(n,d,t={},f={}){try{return n.preview({name:d.mutation,args:{...d.args,...t}})}catch(v){throw f.pressed&&dn(v,f.pressed.author?.id),v}}function Rn(n,d,t){let f=n.allMutations().find(s=>s.name===d.mutation)?.subject,v=f!==void 0&&d.args[f.arg]===void 0,l=v?d.open.find(s=>s.name===f.arg):d.open.find(s=>s.name!==f?.arg&&s.candidates);if(!l?.candidates)return;let A=s=>n.permits({name:d.mutation,args:{...d.args,...d.batch?.[0]??{},[l.name]:s}},t).ok,c=l.candidates.filter(A),w=t.id===void 0?void 0:n.graph.getNode(t.id);if(c.length===0){let s=v?f.kinds:"*";return w!==void 0&&(s==="*"||s.includes(w.kind))&&A(w.id)?"done":void 0}return c.length===1&&c[0]===t.id?{...d,args:{...d.args,[l.name]:t.id},open:d.open.filter(s=>s!==l)}:{...d,open:d.open.map(s=>s===l?{...s,candidates:c}:s)}}export{Xn as a,Yn as b,ne as c};
1
+ import{b as cn,c as un}from"./chunk.W4BKYSZX.js";import{j as x}from"./chunk.OKZT2QBM.js";import{c as Z}from"./chunk.ACTXR2MI.js";import{$b as E,Ec as U,_b as on,db as V,ga as H,hc as rn,ic as an,ja as T,ka as K,la as en,ma as tn,pa as sn,qa as J,ra as G,vc as Q,wd as dn}from"./chunk.DZZL5IDD.js";function fn(){return{name:"insight",derive({store:n,nodes:d,kindSelection:t}){let f=[],v=l=>T(n.schema.tryDefinition(l.kind),l);for(let l of d){if([...n.schema.edgeKinds].reduce((c,w)=>c+n.graph.out(l.id,w).length+n.graph.in(l.id,w).length,0)===0){f.push({id:`insight:island:${l.id}`,text:`${v(l)} is connected to nothing yet`,nodeIds:[l.id]});continue}for(let c of n.schema.edgeKinds){let w=n.graph.in(l.id,c).length;if(w<3)continue;let s=[...n.graph.allEdges()].filter(a=>a.kind===c),e=s.length;e>=4&&w/e>.6&&f.push({id:`insight:load:${l.id}:${c}`,text:`${v(l)} ${vn(n,s,c,w)}`,nodeIds:[l.id]})}}for(let l of t){if(n.graph.nodesOfKind(l).length>0)continue;let A=n.schema.definitions.filter(c=>c.kind!==l).filter(c=>Object.values(c.edges).some(w=>w.to!=="*"&&w.to.includes(l))).map(c=>c.plural??`${c.kind}s`);A.length>0&&f.push({id:`insight:gap:${l}`,text:`Nothing here yet, though ${A.join(" and ")} expect to connect to these`,nodeIds:[]})}return{observations:f}}}}function vn(n,d,t,f){let v=new Set(d.map(s=>n.graph.getNode(s.from)?.kind).filter(s=>s!==void 0)),l=v.size===1?[...v][0]:void 0,A=d.length,c=Z(n.schema,l??[...v][0]??"",t,"in"),w=s=>l?en(n.schema,l,s):String(s);return f===A?`${c}: all ${w(f)}`:`${c}: ${f} of the ${w(A)}`}function ln(n){let d=new Map;if(n.length===0)return d;let t=n.slice(-512),f=new Set;for(let l of t)l.undoes&&f.add(l.undoes);let v=n[n.length-1].seq;for(let l of t){if(!l.mutation||f.has(l.id))continue;let A=Math.pow(.5,(v-l.seq)/64);d.set(l.mutation.name,(d.get(l.mutation.name)??0)+A)}return d}function hn(n){return 8*(n/(n+1))}var bn=100;function gn(){return{name:"invariant",derive({store:n,selection:d,nodes:t,violations:f}){let v=s=>T(n.schema.tryDefinition(s.kind),s),l=new Set(d),A=f.filter(s=>s.nodeIds.some(e=>l.has(e))||s.subjectId!==void 0&&l.has(s.subjectId)),c=[],w=[];A.forEach((s,e)=>{w.push({id:`violation:${s.invariant}:${e}`,text:s.message,nodeIds:s.nodeIds}),s.repairs.forEach((a,h)=>{c.push({id:`invariant:${s.invariant}:${e}:${h}`,label:a.label,provider:"invariant",mutation:a.mutation,args:a.args??{},open:(a.missing??[]).map(m=>{let r=n.allMutations().find(g=>g.name===a.mutation);if(!r)return{name:m};let o=E(r.input).find(g=>g.name===m),k=o?o.kinds.includes("*")?n.graph.allNodes().map(g=>g.id):o.kinds.flatMap(g=>n.graph.nodesOfKind(g).map($=>$.id)):void 0;return{name:m,shape:x(r.input,m),...o?{kinds:o.kinds}:{},...k?{candidates:k}:{}}}),score:bn-h-(a.missing?.length??0),why:s.message,nodeIds:s.nodeIds,...s.subjectId===void 0?{}:{subjectId:s.subjectId}})})});for(let s of t){let e=n.allInvariants().filter(a=>{if(a.scope==="graph")return!1;let h=a.scope;return h.kind!==s.kind?!1:h.match?h.match(s):!0});e.length!==0&&(A.some(a=>a.subjectId===s.id||a.nodeIds.includes(s.id))||w.push({id:`holds:${s.id}`,text:`${v(s)} holds \u2014 nothing currently breaks ${e.length===1?"it":`any of its ${e.length} rules`}`,nodeIds:[s.id]}))}return{affordances:c,observations:w}}}}var X=40;function pn(){return{name:"schema",derive({store:n,selection:d,nodes:t,kindSelection:f,edgeSelection:v,principal:l}){let A=(e,a)=>l!==void 0&&!n.permits({name:e,args:a},l).ok,c=[];if(t.length===0&&v.length>0){for(let e of v){let a=n.graph.getNode(e.from),h=n.graph.getNode(e.to);if(!a||!h)continue;let m=un(n,e);m?.provisional&&c.push({id:`schema:edge:${Q}:${e.kind}:${e.from}:${e.to}`,label:"Keep this link",provider:"schema",mutation:Q,args:{kind:e.kind,from:e.from,to:e.to},open:[],score:64,why:cn(m),nodeIds:[e.from,e.to]});for(let r of n.allMutations()){let o=(r.connects??[]).includes(e.kind),k=(r.severs??[]).includes(e.kind);if(!o&&!k||r.derived?.relation!==void 0&&r.derived.kind!==a.kind)continue;let g={},$=[],j=E(r.input);for(let p of j){let S=p.kinds.includes("*")||p.kinds.includes(a.kind),P=p.kinds.includes("*")||p.kinds.includes(h.kind),y=S&&!j.some(I=>I!==p&&(I.kinds.includes(a.kind)||I.kinds.includes("*")));S&&!P?g[p.name]=e.from:P&&!S?g[p.name]=e.to:S&&P&&y?g[p.name]=e.from:$.push({name:p.name,kinds:p.kinds,candidates:[e.from,e.to],shape:x(r.input,p.name)})}for(let p of q(r.input,""))p in g||$.some(S=>S.name===p)||$.push({name:p,shape:x(r.input,p)});$.every(p=>p.optional===!0?!0:p.kinds!==void 0?(p.candidates?.length??0)>0:(p.candidates?.length??0)>0||p.shape!==void 0&&p.shape.type!=="unknown")&&(o&&!k&&$.length===0||c.push({id:`schema:edge:${r.name}:${e.kind}:${e.from}:${e.to}`,label:K(r),provider:"schema",mutation:r.name,args:g,open:$,...r.destructive?{destructive:!0}:{},score:(k?62:58)-$.length,why:`this line is "${Z(n.schema,n.graph.getNode(e.from)?.kind??"",e.kind,"out")}"`,nodeIds:[e.from,e.to]}))}}return{affordances:c}}if(t.length===0&&f.length>0){let e=new Set(f),a=[];for(let h of n.allMutations()){if(!(h.creates??[]).some(o=>e.has(o)))continue;let m=[];for(let o of E(h.input)){let k=o.kinds.includes("*")?n.graph.allNodes().map(g=>g.id):o.kinds.flatMap(g=>n.graph.nodesOfKind(g).map($=>$.id));m.push({name:o.name,kinds:o.kinds,candidates:k,shape:x(h.input,o.name),...o.optional?{optional:!0}:{}})}for(let o of q(h.input,""))m.some(k=>k.name===o)||m.push({name:o,shape:x(h.input,o)});if(!m.every(o=>o.optional===!0?!0:o.kinds!==void 0?(o.candidates?.length??0)>0:(o.candidates?.length??0)>0||o.shape!==void 0&&o.shape.type!=="unknown")&&!A(h.name,{})){let o=m.filter(k=>k.optional!==!0&&k.kinds!==void 0&&!k.kinds.includes("*")&&(k.candidates?.length??0)===0);if(o.length>0){let k=[...new Set(o.flatMap(g=>g.kinds??[]))].map(g=>J(G(n.schema.tryDefinition(g),g)));a.push({id:`schema:waits:${h.name}`,text:`"${h.title??h.name}" cannot begin until there is ${k.length===1?k[0]:`${k.slice(0,-1).join(", ")} and ${k[k.length-1]}`}.`,nodeIds:[]})}continue}c.push({id:`schema:add:${h.name}`,label:K(h),provider:"schema",mutation:h.name,args:{},open:m,score:X-m.length,why:`this makes ${(h.creates??[]).filter(o=>e.has(o)).map(o=>J(G(n.schema.tryDefinition(o),o))).join(", ")}`,nodeIds:[]})}return{affordances:c,observations:a}}if(t.length===0)return{};let w=new Set(t.map(e=>e.kind)),s=(e,a,h)=>{let m=[];for(let r of n.graph.allEdges()){if(!a.includes(r.kind))continue;let o=r.from===e?r.to:r.to===e?r.from:null;if(!o)continue;let k=n.graph.getNode(o);k&&(!h.includes("*")&&!h.includes(k.kind)||m.includes(o)||m.push(o))}return m};for(let e of n.allMutations()){let a=e.subject;if(!a||!(a.kinds==="*"?!0:[...w].every(u=>a.kinds.includes(u))))continue;let m=e.derived?.act;if((m==="archive"||m==="merge")&&t.some(u=>V(u))||m==="unarchive"&&!t.some(u=>V(u))||m==="leave-alone"&&t.every(u=>U(n,u.id))||m==="allow-tidying"&&!t.some(u=>U(n,u.id)))continue;let r=t.length===1?t[0].id:null,o=e.severs??[],k=e.connects??[];if(r&&o.length>0&&k.length===0&&s(r,o,["*"]).length===0)continue;let g=[];for(let u of E(e.input)){if(u.name===a.arg)continue;let p=u.kinds.includes("*")?n.graph.allNodes().map(S=>S.id):u.kinds.flatMap(S=>n.graph.nodesOfKind(S).map(P=>P.id));if(r&&k.length>0){let S=new Set(s(r,k,u.kinds));p=p.filter(P=>!S.has(P))}else r&&o.length>0&&(p=s(r,o,u.kinds));g.push({name:u.name,kinds:u.kinds,candidates:p.filter(S=>!d.includes(S)),shape:x(e.input,u.name),...u.optional?{optional:!0}:{}})}for(let u of q(e.input,a.arg))g.some(p=>p.name===u)||g.push({name:u,shape:x(e.input,u)});if(g.length===0&&r){let u=Sn(e.input,a.arg);if(u.length>0&&!wn(n,e.name,{[a.arg]:r}))for(let p of u){let S=E(e.input).find(P=>P.name===p);g.push({name:p,optional:!0,...S?{kinds:S.kinds}:{},shape:x(e.input,p)})}}if(!g.every(u=>u.optional===!0?!0:u.kinds!==void 0?(u.candidates?.length??0)>0:(u.candidates?.length??0)>0||u.shape!==void 0&&u.shape.type!=="unknown")&&!A(e.name,r?{[a.arg]:r}:{}))continue;let j=t.map(u=>({[a.arg]:u.id}));g.length===0&&!j.some(u=>n.wouldChange({name:e.name,args:u}))||c.push({id:`schema:${e.name}`,label:t.length>1?`${K(e)} (${t.length})`:K(e),provider:"schema",mutation:e.name,args:j[0]??{},open:g,...e.destructive?{destructive:!0}:{},...e.derived?.act==="archive"||e.derived?.act==="merge"||e.derived?.act==="leave-alone"||e.derived?.act==="allow-tidying"?{setsAside:!0}:{},...o.length>0||k.length>0?{ties:!0}:{},...t.length>1?{batch:j}:{},score:X-g.length,why:t.length>1?`all ${t.length} selected nodes are ${[...w].map(u=>tn(n.schema,u).toLowerCase()).join(" or ")}`:`this is ${J(G(n.schema.tryDefinition(t[0].kind),t[0].kind))}`,nodeIds:t.map(u=>u.id)})}if(t.length===1){let e=t[0];for(let a of n.allMutations()){let h=a.subject,m=a.severs??[],r=a.connects??[];if(!h||m.length===0&&r.length===0)continue;let o=h.kinds==="*"?"*":h.kinds;if(o==="*"||o.includes(e.kind))continue;let k=E(a.input),g=k.find(y=>y.name!==h.arg&&(y.kinds.includes("*")||y.kinds.includes(e.kind)));if(!g)continue;let $=o,j=$.includes("*")?n.graph.allNodes().map(y=>y.id):$.flatMap(y=>n.graph.nodesOfKind(y).map(I=>I.id)),u=new Set(s(e.id,r.length>0?r:m,$)),p=r.length>0?j.filter(y=>!u.has(y)):j.filter(y=>u.has(y));if(p.length===0)continue;let S=[{name:h.arg,kinds:$,candidates:p,shape:x(a.input,h.arg)}];for(let y of k){if(y.name===g.name||y.name===h.arg)continue;let I=y.kinds.includes("*")?n.graph.allNodes().map(L=>L.id):y.kinds.flatMap(L=>n.graph.nodesOfKind(L).map(O=>O.id));S.push({name:y.name,kinds:y.kinds,candidates:I,shape:x(a.input,y.name),...y.optional?{optional:!0}:{}})}for(let y of q(a.input,g.name))y===h.arg||S.some(I=>I.name===y)||S.push({name:y,shape:x(a.input,y)});S.every(y=>y.optional===!0?!0:y.kinds!==void 0?(y.candidates?.length??0)>0:(y.candidates?.length??0)>0||y.shape!==void 0&&y.shape.type!=="unknown")&&c.push({id:`schema:tie:${a.name}:${e.id}`,label:a.fromTheOtherEnd??K(a),provider:"schema",mutation:a.name,args:{[g.name]:e.id},open:S,ties:!0,...a.destructive?{destructive:!0}:{},score:X-S.length+2,why:`${m.length>0?"this one is on":"this one could join"} ${S[0].candidates.length===1?"it":"one of these"}`,nodeIds:[e.id]})}}return{affordances:c}}}}function Sn(n,d){let t=n.shape;return t?Object.entries(t).filter(([f,v])=>f!==d&&v.safeParse(void 0).success).map(([f])=>f):[]}function wn(n,d,t){try{return n.preview({name:d,args:t}),!0}catch{return!1}}function q(n,d){let t=n.shape;return t?Object.entries(t).filter(([f,v])=>f!==d&&!v.safeParse(void 0).success).map(([f])=>f):[]}var An=70,$n=80,On=new Set(["id","kind"]);function mn(){return{name:"structure",derive({store:n,nodes:d}){let t=c=>T(n.schema.tryDefinition(c.kind),c);if(d.length<2)return{};let f=[],v=[],l=d.map(c=>c.id);for(let c of n.schema.edgeKinds){let w=In(d.map(e=>new Set([...n.graph.out(e.id,c).map(a=>a.id),...n.graph.in(e.id,c).map(a=>a.id)])));for(let e of w){let a=n.graph.getNode(e);a&&f.push({id:`shared:${c}:${e}`,text:`all ${d.length} share "${t(a)}" (${H(c).toLowerCase()})`,nodeIds:[...l,e]})}let s=new Map;for(let e of d)for(let a of[...n.graph.out(e.id,c),...n.graph.in(e.id,c)])s.set(a.id,(s.get(a.id)??0)+1);for(let[e,a]of s){if(a!==d.length-1||d.length<3||l.includes(e))continue;let h=n.graph.getNode(e);if(!h)continue;let m=d.find(r=>![...n.graph.out(r.id,c),...n.graph.in(r.id,c)].some(o=>o.id===e));if(m&&(f.push({id:`near-shared:${c}:${e}`,text:`all but "${t(m)}" share "${t(h)}" (${H(c).toLowerCase()})`,nodeIds:[...l,e]}),!(!n.schema.edgeAllowed(c,m.kind,h.kind)&&!n.schema.edgeAllowed(c,h.kind,m.kind))))for(let r of n.allMutations()){let o=r.subject;if(!o||o.kinds!=="*"&&!o.kinds.includes(m.kind)||(r.connects!==void 0||r.severs!==void 0)&&!(r.connects??[]).includes(c))continue;let g=Pn(r.input,h.kind);g&&v.push({id:`structure:join:${r.name}:${m.id}:${e}`,label:`${K(r)}: bring "${t(m)}" in line with the others`,provider:"structure",mutation:r.name,args:{[o.arg]:m.id,[g]:e},open:[],score:An,why:`every other selected node is connected to "${t(h)}"`,nodeIds:[m.id,e]})}}}let A=new Map;for(let c of d)A.set(c.kind,[...A.get(c.kind)??[],c]);for(let[c,w]of A){if(w.length<2)continue;let s=w,e=w.map(r=>r.id),a=A.size>1?`${c}:`:"",h=new Set;for(let r of s)for(let o of Object.keys(r))On.has(o)||h.add(o);let m=r=>n.schema.definitions.find(o=>o.kind===r);for(let r of[...h].sort()){let o=m(s[0].kind),k=sn(o,r).toLowerCase(),g=o?.display?.format?.[r],$=O=>{if(!g)return O;try{return String(g(JSON.parse(O)))}catch{return O}},j=s.map(O=>O[r]),u=new Map;if(j.forEach((O,R)=>{let D=JSON.stringify(O??null),M=u.get(D);M?M.push(s[R]):u.set(D,[s[R]])}),u.size===1){let O=[...u.keys()][0];if(O==="null")continue;f.push({id:`agree:${a}${r}`,text:`all ${s.length} share the ${k} ${$(O)}`,nodeIds:e});continue}if(s.length<3||u.size!==2)continue;let p=[...u.entries()].sort((O,R)=>R[1].length-O[1].length),[S,P]=p[0],[,y]=p[1];if(y.length!==1||S==="null")continue;let I=y[0],L=JSON.parse(S);f.push({id:`odd-one-out:${a}${r}`,text:`${P.length} share the ${k} ${$(S)}; "${t(I)}" does not`,nodeIds:e});for(let O of n.allMutations()){let R=O.subject;if(!R||R.kinds!=="*"&&!R.kinds.includes(I.kind))continue;let D=kn(O.input);if(!D||!(r in D))continue;let M={[R.arg]:I.id,[r]:L},C=!0;for(let[W,z]of Object.entries(D)){if(W in M||z.safeParse(void 0).success)continue;let B=I[W];if(B===void 0){C=!1;break}M[W]=B}!C||!O.input.safeParse(M).success||v.push({id:`structure:align:${O.name}:${r}:${I.id}`,label:`Align the ${k} of "${t(I)}" with the other ${P.length}`,provider:"structure",mutation:O.name,args:M,open:[],score:$n,why:`${P.length} of ${s.length} share the ${k} ${$(S)}`,nodeIds:e})}}}return{affordances:v,observations:f}}}}function In(n){if(n.length===0)return[];let[d,...t]=n;return[...d].filter(f=>t.every(v=>v.has(f))).sort()}function kn(n){return n.shape??null}function Pn(n,d){let t=kn(n);if(!t)return null;for(let[f]of Object.entries(t)){let v=on(t[f]);if(v&&(v.includes("*")||v.includes(d)))return f}return null}function jn(){return[gn(),mn(),pn(),fn()]}function Xn(n,d,t={}){let f=yn(),v=t.providers??jn(),l=d.map(i=>n.graph.getNode(i)).filter(i=>i!==void 0),A={store:n,selection:d,nodes:l,kindSelection:t.kindSelection??[],edgeSelection:t.edgeSelection??[],violations:n.violations(t.context),context:t.context??{},principal:t.principal??{kind:"human"}},c=[],w=[];for(let i of v){let b=i.derive(A);c.push(...b.affordances??[]),w.push(...b.observations??[])}let s=new Map(n.allMutations().map(i=>[i.name,i]));c.forEach((i,b)=>{let N=i.open.length>1?s.get(i.mutation):void 0;N&&(c[b]={...i,open:an(i.open,rn(n.schema,N))})});let e=new Set(n.allMutations().filter(i=>i.pinned).map(i=>i.name)),a=new Set(t.pins?.pinned??[]),h=new Set(t.pins?.unpinned??[]),m=i=>a.has(i.mutation)?"user":e.has(i.mutation)&&!h.has(i.mutation)?"declared":void 0,r=i=>{let b=m(i);return b?{...i,pinned:b}:i},o=new Map;for(let[i,b]of ln(n.log.all()))o.set(i,hn(b));let k=i=>i.pinned==="user"?0:i.pinned==="declared"?1:2,g=i=>i.score+(o.get(i.mutation)??0),$=new Map(n.allMutations().map(i=>[i.name,i])),j=new Map,u=i=>{let b=$.get(i.mutation);if(!b)return[];let N=j.get(i.mutation);N||(N=E(b.input).map(F=>F.name),j.set(i.mutation,N));let _=[];for(let F of i.batch??[i.args])for(let Y of N){let nn=F[Y]??i.args[Y];typeof nn=="string"&&_.push(nn)}return _},p=t.focus,S=4,P=i=>i.open.length>0?1:0,y=i=>{if(p===void 0)return S;let b=u(i);return b.length>0?b.includes(p)?I(i,0):S:i.nodeIds.includes(p)||i.subjectId===p?I(i,1):S},I=(i,b)=>i.provider==="invariant"?b:2+P(i),L=i=>i.setsAside?1:0,O=Nn(c).map(r),R=new Map(O.map((i,b)=>[i,b])),D=O.sort((i,b)=>{let N=Number(i.destructive??!1)-Number(b.destructive??!1);if(N!==0)return N;let _=L(i)-L(b);if(_!==0)return _;let F=y(i)-y(b);return F!==0?F:y(i)<2?R.get(i)-R.get(b):+(b.provider==="invariant")-+(i.provider==="invariant")||k(i)-k(b)||g(b)-g(i)||i.id.localeCompare(b.id)}),M=t.principal??{kind:"human"},C=[],W=[];for(let i of D){let b=n.permits({name:i.mutation,args:{...i.args,...i.batch?.[0]??{}}},M);if(b.ok)C.push(i);else{let N=Rn(n,i,M);if(N==="done")continue;N?C.push(N):W.push({...i,refusal:b.refusal})}}let z=C.map((i,b)=>({...i,rank:b})),B=W.map((i,b)=>({...i,rank:C.length+b}));return{affordances:t.limit===void 0?z:z.slice(0,t.limit),withheld:B,observations:xn(w),ms:yn()-f}}function Nn(n){let d=new Map;for(let t of n){let f=[t.mutation,JSON.stringify(t.args),JSON.stringify(t.batch??null)].join("|"),v=d.get(f);(!v||t.score>v.score)&&d.set(f,t)}return[...d.values()]}function xn(n){let d=new Map;for(let t of n)d.set(t.text,t);return[...d.values()]}function yn(){return typeof performance<"u"?performance.now():Date.now()}function Yn(n,d,t={},f={}){let v=(d.batch??[d.args]).map(A=>({name:d.mutation,args:{...d.args,...A,...t}})),l=n.allMutations().find(A=>A.name===d.mutation);return n.applyAll(v,{...l?.describe?{}:{intent:d.label},...f.author?{author:f.author}:{}})}function ne(n,d,t={},f={}){try{return n.preview({name:d.mutation,args:{...d.args,...t}})}catch(v){throw f.pressed&&dn(v,f.pressed.author?.id),v}}function Rn(n,d,t){let f=n.allMutations().find(s=>s.name===d.mutation)?.subject,v=f!==void 0&&d.args[f.arg]===void 0,l=v?d.open.find(s=>s.name===f.arg):d.open.find(s=>s.name!==f?.arg&&s.candidates);if(!l?.candidates)return;let A=s=>n.permits({name:d.mutation,args:{...d.args,...d.batch?.[0]??{},[l.name]:s}},t).ok,c=l.candidates.filter(A),w=t.id===void 0?void 0:n.graph.getNode(t.id);if(c.length===0){let s=v?f.kinds:"*";return w!==void 0&&(s==="*"||s.includes(w.kind))&&A(w.id)?"done":void 0}return c.length===1&&c[0]===t.id?{...d,args:{...d.args,[l.name]:t.id},open:d.open.filter(s=>s!==l)}:{...d,open:d.open.map(s=>s===l?{...s,candidates:c}:s)}}export{Xn as a,Yn as b,ne as c};
@@ -0,0 +1 @@
1
+ function t(n){if(Array.isArray(n))return n.map(t);if(n&&typeof n=="object"){let r={};for(let o of Object.keys(n).sort()){let e=n[o];e!==void 0&&(r[o]=t(e))}return r}return n}function i(n){return JSON.stringify(t(n))??"undefined"}export{i as a};
@@ -0,0 +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{Gb as L,P as H,S as N,cd as j}from"./chunk.DZZL5IDD.js";var D=()=>(__graviewPreload(import.meta.url,["./chunk.X6KYRBL6.js","./chunk.BZMQDEIY.js","./chunk.B3WVCSW5.js","./chunk.H5S7OL2U.js","./chunk.DZZL5IDD.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.VN23AGIY.js"));function W(n,l,c){let i=new Map;for(let u of c?.kinds??[])for(let o of n.nodesOfKind(u))l.has(o.id)||i.set(o.id,o);let t=new Set([...l,...i.keys()]),p=new Set(c?.edges??[]),k=new Set;if(p.size>0&&l.size>0){for(let u of l)for(let o of n.outEdges(u))p.has(o.kind)&&i.has(o.to)&&k.add(o.to);for(let u of i.keys())n.outEdges(u).some(o=>p.has(o.kind)&&l.has(o.to))&&k.add(u)}let R=new Map([...[...i].filter(([u])=>k.has(u)),...[...i].filter(([u])=>!k.has(u))]),h=[];if(p.size>0)for(let u of t)for(let o of n.outEdges(u))p.has(o.kind)&&t.has(o.to)&&h.push({kind:o.kind,from:o.from,to:o.to});return{nodes:[...R.values()],edges:h}}function E(n,l,c){let i=[];return()=>{let t=c();for(;i.length>0&&i[0]<=t-l;)i.shift();return i.length>=n?!1:(i.push(t),!0)}}function C(n={},l=Date.now){return{act:E(n.acts??30,n.actWindowMs??6e4,l),message:E(n.messages??120,n.messageWindowMs??1e3,l)}}var v=n=>typeof n=="object"&&n!==null&&!Array.isArray(n);function K(n,l){let c=l.flatMap(t=>v(t)&&typeof t.kind=="string"?[t.kind]:[]),i=j(n,c);return Object.keys(i).length>0?{choices:i}:{}}function J(n,l){let c=structuredClone(l),i=n.schema.tryDefinition(c.kind),t=c.label;return{...c,label:i?.label?i.label(c):typeof t=="string"&&t.length>0?t:c.id}}function I(n){let l=n.limiter??C(n.limits,n.now),c=n.limits?.maxHeight??4e3,i=`view:${n.view}`,t={applied:0,refused:0,dropped:0},p=()=>n.store.seenBy(n.principal),k=e=>J(n.store,e),R=()=>{if(n.props)return n.props();let e=p(),d=e.graph,r=n.input?.()??{},y=r.node?d.getNode(r.node.id):void 0,a=r.nodes?.flatMap(s=>{let m=d.getNode(s.id);return m?[m]:[]}),g=new Set([...y?[y.id]:[],...(a??[]).map(s=>s.id)]),f=[];for(let s of g)for(let m of d.outEdges(s))g.has(m.to)&&f.push({kind:m.kind,from:m.from,to:m.to});let b=W(d,g,n.reads),A=new Set(f.map(s=>`${s.kind} ${s.from} ${s.to}`));for(let s of b.edges)A.has(`${s.kind} ${s.from} ${s.to}`)||f.push(s);let w=b.nodes.length>0?[...a??[],...b.nodes]:a,S=s=>s?.filter(m=>d.has(m)),$=e.permittedMutations(n.principal).map(s=>({name:s.name,title:s.title??s.name,...s.description!==void 0?{description:s.description}:{},...s.subject?{subject:{kinds:s.subject.kinds,arg:s.subject.arg}}:{}}));return{view:n.view,...y?{node:k(y)}:{},...w?{nodes:w.map(k)}:{},edges:f,...r.label!==void 0?{label:r.label}:{},...r.fidelity!==void 0?{fidelity:r.fidelity}:{},...r.cardinality!==void 0?{cardinality:r.cardinality}:{},...r.mode!==void 0?{mode:r.mode}:{},...r.selected!==void 0?{selected:r.selected}:{},...r.implicated?{implicated:S(r.implicated)}:{},...r.flagged?{flagged:S(r.flagged)}:{},acts:$,...n.theme?{theme:n.theme()}:{},locale:H(),timeZone:N(),...K(n.store.schema,[...y?[y]:[],...w??[]]),...n.placesShown?{places:n.placesShown().map(({as:s,title:m,kind:F})=>({as:s,title:m,kind:F}))}:{}}},h=!1,u=0,o=new Set,M=()=>{if(h)return;u+=1,o.add(u),o.size>100&&o.delete(o.values().next().value);let e=R();n.send({type:"props",props:n.hand?n.hand(e):e,push:u})},P=!1,O=n.store.subscribe(()=>{P||(P=!0,queueMicrotask(()=>{P=!1,M()}))}),G=(e,d)=>(t.refused+=1,{ok:!1,reason:e,message:d}),z=(e,d,r)=>x([{name:e,args:d}],r),x=(e,d,r)=>{if(!l.act())return G("rate-limited","Too many acts asked for at once; this one was not applied.");let y=[];for(let{name:a,args:g}of e){if(d){let f=d(a,g);if(!f.ok)return G(f.reason,f.message);a=f.name,g=f.args}if(!n.store.allMutations().some(f=>f.name===a))return G("unknown-act","There is no act by that name here.");y.push({name:a,args:g})}try{let a=n.store.applyAll(y,{author:n.principal,via:i,...r?{intent:r}:{}});return t.applied+=1,{ok:!0,intent:a.intent}}catch(a){return a instanceof L?G("refused",a.refusal.message):G("failed","The act could not be applied.")}},T=(e,d,r)=>{let y=Array.isArray(r);if(typeof d!="string"||(y?r.length===0||r.length>100||!r.every(v):!v(r)))return t.refused+=1,n.send({type:"answer",id:e,ok:!1,reason:"malformed",message:"An act is asked for by name, with its arguments as an object, or a list of 1 to 100 of them for several as one change."});let a=x((y?r:[r]).map(g=>({name:d,args:g})),n.judgeAct);n.send(a.ok?{type:"answer",id:e,ok:!0,intent:a.intent}:{type:"answer",id:e,ok:!1,reason:a.reason,message:a.message})};return{receive(e){if(h)return;if(!(v(e)&&e.nonce===n.nonce&&e.type==="pushed"&&typeof e.push=="number"&&o.delete(e.push))&&!l.message()){t.dropped+=1,n.onFlood?.();return}if(!v(e)||e.nonce!==n.nonce){t.dropped+=1;return}if(e.type==="act"&&(typeof e.id=="string"||typeof e.id=="number"))return T(e.id,e.name,e.args);if(e.type==="navigate"&&n.onArrive&&(typeof e.place=="string"||typeof e.to=="string")){let r={...e.where!==void 0?{where:e.where}:{},...e.section!==void 0?{section:e.section}:{}},y=typeof e.place=="string"?{place:e.place,...r}:{record:e.to,...r},a=n.onArrive;D().then(({judgeDestination:g,listsOf:f,placeVocabulary:b})=>{if(h)return;let A=new Set([...n.store.kindsKeptFrom(n.principal),...n.store.modules.disabledKinds]),w=g(y,{sees:S=>p().graph.has(S),places:b(n.store.schema,n.placesShown?.()??[],{kept:A}),lists:f(n.store.schema,A),schema:n.store.schema});w.ok?a(w.arrival):(t.dropped+=1,n.onLost?.(w.says))});return}if(e.type==="navigate"&&typeof e.place=="string"){n.places?.().includes(e.place)?n.onNavigatePlace?.(e.place):t.dropped+=1;return}if(e.type==="navigate"&&typeof e.to=="string"){p().graph.has(e.to)?n.onNavigate?.(e.to):t.dropped+=1;return}if(e.type==="render"&&Array.isArray(e.records)&&n.onRender){n.onRender(e.records);return}if(e.type==="style"&&Array.isArray(e.sheets)&&e.sheets.every(r=>typeof r=="string")&&n.onStyle){n.onStyle(e.sheets);return}if(e.type==="hears"&&Array.isArray(e.events)&&n.onHears){n.onHears(e.events.filter(r=>typeof r=="string").slice(0,20));return}if(e.type==="clicks"&&Array.isArray(e.selectors)){n.onClicks?.(e.selectors.filter(r=>typeof r=="string"&&r.length<=500).slice(0,200));return}if(e.type==="gestures"&&Array.isArray(e.bound)&&n.onGestures){n.onGestures(e.bound.slice(0,32));return}if(e.type==="pushed"&&typeof e.push=="number"&&typeof e.ms=="number"&&n.onPushed){n.onPushed(e.push,e.ms);return}if(e.type==="size"&&typeof e.height=="number"&&Number.isFinite(e.height)){n.onSize?.(Math.max(0,Math.min(c,Math.round(e.height))));return}t.dropped+=1},push:M,pressed(e){return h?{ok:!1,reason:"refused",message:"The view has gone."}:e.ok?z(e.name,e.args):(t.refused+=1,e)},change(e,d){return h?{ok:!1,reason:"refused",message:"The view has gone."}:x(e,void 0,d)},get stats(){return t},dispose(){h=!0,O()}}}export{W as a,C as b,K as c,J as d,I as e};
@@ -1 +1 @@
1
- import{G as C,Ra as H,T as F,Ta as A}from"./chunk.4MP72LPR.js";import"./chunk.SDO3U72B.js";import"./chunk.VSCIXAHN.js";import"./chunk.FQLNBIQ5.js";import{b as x}from"./chunk.AJZBJBMO.js";var t=x(C(),1),f=x(F(),1),q={faces:'[data-testid="app-faces"]',problems:'[data-testid="standing"], [data-testid="standing-link"]',activity:'[data-testid="activity-button"]',ask:'[data-testid="app-find"], [data-testid="app-find-open"]',find:'[data-testid="app-find"], [data-testid="app-find-open"]',profile:'[data-testid="profile-button"]',home:'[data-testid="app-home"]'};function D(e){if(!e.isConnected||e.closest("[hidden], [inert], [aria-hidden='true']"))return!1;if(typeof e.checkVisibility!="function")return!0;if(!e.checkVisibility({visibilityProperty:!0}))return!1;let a=e.getBoundingClientRect();return a.width>1&&a.height>1}function E(e,a){if(!e||a==="ask"&&!e.querySelector("[data-graview-quick-ask]"))return null;for(let d of e.querySelectorAll(q[a]))if(D(d))return d;return null}function W(e){let a=(u,h,c)=>e.querySelector(u)?.getAttribute(h)?.trim()||c,d=a('[data-testid="app-face-scene"]',"title","Scene"),n=a('[data-testid="app-face-pages"]',"title","Pages");return[{anchor:"faces",title:`${d} or ${n}`,words:`One app, two ways to see it: ${d} draws every record as one picture, ${n} as lists and pages to read and change.`},{anchor:"problems",title:"Whether all is in order",words:"The dot is green while every rule holds. When one is broken it counts what is wrong, and pressing it shows each one and where."},{anchor:"activity",title:"Activity",words:"What has happened here and who did it, each change with its way back."},{anchor:"ask",title:"Ask",words:"Press \u2318K (Ctrl+K) to ask about what you have selected, or right-click it and choose Ask about this\u2026. The answer stands beside it, and a change it proposes waits for you to accept it."}]}var R=300,O=1200,$=15e3;function _({root:e,steps:a,onEnd:d}){let[n,u]=(0,t.useState)(null),h=(0,t.useRef)(null),c=(0,t.useRef)(!1),p=(0,t.useRef)(d);p.current=d,(0,t.useEffect)(()=>{let r=Date.now(),o=Date.now(),s=null,i,v=new MutationObserver(()=>o=Date.now());v.observe(document.body,{childList:!0,subtree:!0});let k=()=>{let L=e(),S=Date.now();if(L?.querySelector('[data-testid="app-bar"]')){if(s??=S,S-o>=R||S-s>=O){let T=[...W(L),...a].filter(P=>E(L,P.anchor)!==null);if(T.length===0){c.current=!0,p.current(null);return}h.current=document.activeElement,u({list:T,at:0});return}}else if(S-r>=$){c.current=!0,p.current(null);return}i=setTimeout(k,100)};return i=setTimeout(k,100),()=>{clearTimeout(i),v.disconnect()}},[]);let y=(0,t.useCallback)(()=>{let r=h.current;(r instanceof HTMLElement&&r!==document.body&&r.isConnected?r:e()?.querySelector('[data-testid="app-home"]'))?.focus({preventScroll:!0})},[e]),m=(0,t.useCallback)((r,o)=>{if(c.current)return;c.current=!0;let s=document.querySelector("[data-testid='first-look']"),i=document.activeElement,v=i===null||i===document.body||s!==null&&s.contains(i);u(null),p.current(r),!(!o&&!v)&&(y(),requestAnimationFrame(()=>{let k=document.activeElement;(k===null||k===document.body)&&y()}))},[y]),b=(0,t.useCallback)((r,o)=>{let s=e();for(let i=o;i<r.length;i++)if(E(s,r[i].anchor))return i;return-1},[e]),g=(0,t.useCallback)(()=>{if(!n)return;let r=b(n.list,n.at+1);r<0?m("finished",!0):u({list:n.list,at:r})},[n,b,m]);if((0,t.useEffect)(()=>{if(!n)return;let r=e();if(!r)return;let o=0,s=()=>{cancelAnimationFrame(o),o=requestAnimationFrame(()=>{E(e(),n.list[n.at].anchor)||g()})},i=new MutationObserver(s);return i.observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["hidden","class","data-switch-drawn"]}),()=>{cancelAnimationFrame(o),i.disconnect()}},[n,e,g]),!n)return null;let w=n.list[n.at],l=b(n.list,n.at+1)<0;return(0,f.jsx)(I,{root:e,step:w,position:n.at+1,total:n.list.length,last:l,onNext:g,onEnd:m},n.at)}var N={...H,width:"min(320px, calc(100vw - 24px))",maxHeight:"min(70vh, 420px)",overflow:"auto",padding:"12px 14px",borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)",color:"var(--graview-ink)",fontFamily:"var(--graview-font-body, system-ui)",fontSize:"0.875rem",lineHeight:1.45,overflowWrap:"anywhere"},M={minHeight:32,padding:"0 12px",borderRadius:8,font:"inherit",fontWeight:600,cursor:"pointer"};function I({root:e,step:a,position:d,total:n,last:u,onNext:h,onEnd:c}){let p=(0,t.useRef)(null),y=(0,t.useRef)(null),m=(0,t.useId)().replace(/:/g,""),b=(0,t.useMemo)(()=>({get current(){return E(e(),a.anchor)}}),[e,a.anchor]),[g]=(0,t.useState)(()=>{let l=b.current?.getBoundingClientRect(),r=typeof document>"u"?0:document.documentElement.clientWidth||innerWidth;return l&&l.left+l.width/2<r/2?"start":"end"});A(p,!0,b,{align:g}),(0,t.useLayoutEffect)(()=>{y.current?.focus({preventScroll:!0})},[]);let w=(0,t.useRef)(c);return w.current=c,(0,t.useEffect)(()=>{let l=o=>{o.target instanceof Node&&p.current?.contains(o.target)||w.current("dismissed",!1)},r=o=>{if(o.key!=="Escape"||o.defaultPrevented)return;let s=o.target;s instanceof Node&&p.current?.contains(s)||s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement||[...document.querySelectorAll("[data-graview-overlay]:not([hidden])")].some(i=>i!==p.current)||w.current("dismissed",!0)};return document.addEventListener("pointerdown",l,!0),document.addEventListener("keydown",r),()=>{document.removeEventListener("pointerdown",l,!0),document.removeEventListener("keydown",r)}},[]),(0,f.jsxs)("div",{ref:p,popover:"manual",role:"dialog","aria-modal":"false","aria-labelledby":`${m}-title`,"aria-describedby":`${m}-words`,tabIndex:-1,"data-testid":"first-look","data-first-look-anchor":a.anchor,"data-graview-overlay":"",onKeyDown:l=>{l.key==="Escape"&&(l.preventDefault(),l.stopPropagation(),c("dismissed",!0))},style:N,children:[(0,f.jsxs)("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--graview-ink-muted)"},"data-testid":"first-look-count",children:[d," of ",n]}),(0,f.jsx)("p",{id:`${m}-title`,style:{margin:"2px 0 4px",fontWeight:600,fontSize:"0.9375rem"},"data-testid":"first-look-title",children:a.title}),(0,f.jsx)("p",{id:`${m}-words`,style:{margin:0},"data-testid":"first-look-words",children:a.words}),(0,f.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"flex-end",gap:8,marginTop:12},children:[u?null:(0,f.jsx)("button",{type:"button","data-testid":"first-look-skip",onClick:()=>c("dismissed",!0),style:{...M,fontWeight:500,border:"1px solid transparent",background:"none",color:"var(--graview-ink-muted)"},children:"Skip"}),(0,f.jsx)("button",{ref:y,type:"button","data-testid":u?"first-look-done":"first-look-next",onClick:()=>u?c("finished",!0):h(),style:{...M,border:"1px solid var(--graview-accent)",background:"var(--graview-accent)",color:"var(--graview-accent-ink)"},children:u?"Done":"Next"})]})]})}export{_ as FirstLookHints,E as firstLookAnchor};
1
+ import{G as C,Ra as H,T as F,Ta as A}from"./chunk.M7RESZB6.js";import"./chunk.SDO3U72B.js";import"./chunk.DZZL5IDD.js";import"./chunk.FQLNBIQ5.js";import{b as x}from"./chunk.AJZBJBMO.js";var t=x(C(),1),f=x(F(),1),q={faces:'[data-testid="app-faces"]',problems:'[data-testid="standing"], [data-testid="standing-link"]',activity:'[data-testid="activity-button"]',ask:'[data-testid="app-find"], [data-testid="app-find-open"]',find:'[data-testid="app-find"], [data-testid="app-find-open"]',profile:'[data-testid="profile-button"]',home:'[data-testid="app-home"]'};function D(e){if(!e.isConnected||e.closest("[hidden], [inert], [aria-hidden='true']"))return!1;if(typeof e.checkVisibility!="function")return!0;if(!e.checkVisibility({visibilityProperty:!0}))return!1;let a=e.getBoundingClientRect();return a.width>1&&a.height>1}function E(e,a){if(!e||a==="ask"&&!e.querySelector("[data-graview-quick-ask]"))return null;for(let d of e.querySelectorAll(q[a]))if(D(d))return d;return null}function W(e){let a=(u,h,c)=>e.querySelector(u)?.getAttribute(h)?.trim()||c,d=a('[data-testid="app-face-scene"]',"title","Scene"),n=a('[data-testid="app-face-pages"]',"title","Pages");return[{anchor:"faces",title:`${d} or ${n}`,words:`One app, two ways to see it: ${d} draws every record as one picture, ${n} as lists and pages to read and change.`},{anchor:"problems",title:"Whether all is in order",words:"The dot is green while every rule holds. When one is broken it counts what is wrong, and pressing it shows each one and where."},{anchor:"activity",title:"Activity",words:"What has happened here and who did it, each change with its way back."},{anchor:"ask",title:"Ask",words:"Press \u2318K (Ctrl+K) to ask about what you have selected, or right-click it and choose Ask about this\u2026. The answer stands beside it, and a change it proposes waits for you to accept it."}]}var R=300,O=1200,$=15e3;function _({root:e,steps:a,onEnd:d}){let[n,u]=(0,t.useState)(null),h=(0,t.useRef)(null),c=(0,t.useRef)(!1),p=(0,t.useRef)(d);p.current=d,(0,t.useEffect)(()=>{let r=Date.now(),o=Date.now(),s=null,i,v=new MutationObserver(()=>o=Date.now());v.observe(document.body,{childList:!0,subtree:!0});let k=()=>{let L=e(),S=Date.now();if(L?.querySelector('[data-testid="app-bar"]')){if(s??=S,S-o>=R||S-s>=O){let T=[...W(L),...a].filter(P=>E(L,P.anchor)!==null);if(T.length===0){c.current=!0,p.current(null);return}h.current=document.activeElement,u({list:T,at:0});return}}else if(S-r>=$){c.current=!0,p.current(null);return}i=setTimeout(k,100)};return i=setTimeout(k,100),()=>{clearTimeout(i),v.disconnect()}},[]);let y=(0,t.useCallback)(()=>{let r=h.current;(r instanceof HTMLElement&&r!==document.body&&r.isConnected?r:e()?.querySelector('[data-testid="app-home"]'))?.focus({preventScroll:!0})},[e]),m=(0,t.useCallback)((r,o)=>{if(c.current)return;c.current=!0;let s=document.querySelector("[data-testid='first-look']"),i=document.activeElement,v=i===null||i===document.body||s!==null&&s.contains(i);u(null),p.current(r),!(!o&&!v)&&(y(),requestAnimationFrame(()=>{let k=document.activeElement;(k===null||k===document.body)&&y()}))},[y]),b=(0,t.useCallback)((r,o)=>{let s=e();for(let i=o;i<r.length;i++)if(E(s,r[i].anchor))return i;return-1},[e]),g=(0,t.useCallback)(()=>{if(!n)return;let r=b(n.list,n.at+1);r<0?m("finished",!0):u({list:n.list,at:r})},[n,b,m]);if((0,t.useEffect)(()=>{if(!n)return;let r=e();if(!r)return;let o=0,s=()=>{cancelAnimationFrame(o),o=requestAnimationFrame(()=>{E(e(),n.list[n.at].anchor)||g()})},i=new MutationObserver(s);return i.observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["hidden","class","data-switch-drawn"]}),()=>{cancelAnimationFrame(o),i.disconnect()}},[n,e,g]),!n)return null;let w=n.list[n.at],l=b(n.list,n.at+1)<0;return(0,f.jsx)(I,{root:e,step:w,position:n.at+1,total:n.list.length,last:l,onNext:g,onEnd:m},n.at)}var N={...H,width:"min(320px, calc(100vw - 24px))",maxHeight:"min(70vh, 420px)",overflow:"auto",padding:"12px 14px",borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)",color:"var(--graview-ink)",fontFamily:"var(--graview-font-body, system-ui)",fontSize:"0.875rem",lineHeight:1.45,overflowWrap:"anywhere"},M={minHeight:32,padding:"0 12px",borderRadius:8,font:"inherit",fontWeight:600,cursor:"pointer"};function I({root:e,step:a,position:d,total:n,last:u,onNext:h,onEnd:c}){let p=(0,t.useRef)(null),y=(0,t.useRef)(null),m=(0,t.useId)().replace(/:/g,""),b=(0,t.useMemo)(()=>({get current(){return E(e(),a.anchor)}}),[e,a.anchor]),[g]=(0,t.useState)(()=>{let l=b.current?.getBoundingClientRect(),r=typeof document>"u"?0:document.documentElement.clientWidth||innerWidth;return l&&l.left+l.width/2<r/2?"start":"end"});A(p,!0,b,{align:g}),(0,t.useLayoutEffect)(()=>{y.current?.focus({preventScroll:!0})},[]);let w=(0,t.useRef)(c);return w.current=c,(0,t.useEffect)(()=>{let l=o=>{o.target instanceof Node&&p.current?.contains(o.target)||w.current("dismissed",!1)},r=o=>{if(o.key!=="Escape"||o.defaultPrevented)return;let s=o.target;s instanceof Node&&p.current?.contains(s)||s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement||[...document.querySelectorAll("[data-graview-overlay]:not([hidden])")].some(i=>i!==p.current)||w.current("dismissed",!0)};return document.addEventListener("pointerdown",l,!0),document.addEventListener("keydown",r),()=>{document.removeEventListener("pointerdown",l,!0),document.removeEventListener("keydown",r)}},[]),(0,f.jsxs)("div",{ref:p,popover:"manual",role:"dialog","aria-modal":"false","aria-labelledby":`${m}-title`,"aria-describedby":`${m}-words`,tabIndex:-1,"data-testid":"first-look","data-first-look-anchor":a.anchor,"data-graview-overlay":"",onKeyDown:l=>{l.key==="Escape"&&(l.preventDefault(),l.stopPropagation(),c("dismissed",!0))},style:N,children:[(0,f.jsxs)("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--graview-ink-muted)"},"data-testid":"first-look-count",children:[d," of ",n]}),(0,f.jsx)("p",{id:`${m}-title`,style:{margin:"2px 0 4px",fontWeight:600,fontSize:"0.9375rem"},"data-testid":"first-look-title",children:a.title}),(0,f.jsx)("p",{id:`${m}-words`,style:{margin:0},"data-testid":"first-look-words",children:a.words}),(0,f.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"flex-end",gap:8,marginTop:12},children:[u?null:(0,f.jsx)("button",{type:"button","data-testid":"first-look-skip",onClick:()=>c("dismissed",!0),style:{...M,fontWeight:500,border:"1px solid transparent",background:"none",color:"var(--graview-ink-muted)"},children:"Skip"}),(0,f.jsx)("button",{ref:y,type:"button","data-testid":u?"first-look-done":"first-look-next",onClick:()=>u?c("finished",!0):h(),style:{...M,border:"1px solid var(--graview-accent)",background:"var(--graview-accent)",color:"var(--graview-accent-ink)"},children:u?"Done":"Next"})]})]})}export{_ as FirstLookHints,E as firstLookAnchor};
@@ -0,0 +1 @@
1
+ import{d as i}from"./chunk.AJSUHPBE.js";import{T as o}from"./chunk.M7RESZB6.js";import{b as a}from"./chunk.AJZBJBMO.js";var t=a(o(),1);function s({id:r,label:e,go:n,testId:d}){return n?(0,t.jsx)("button",{type:"button","data-testid":d,"data-record":r,title:`Go to ${e}`,onClick:()=>n(r),style:{all:"unset",display:"inline-flex",maxWidth:"100%",minWidth:0,cursor:"pointer",borderRadius:7},className:"graview-activity-record",children:(0,t.jsx)(i,{label:e})}):(0,t.jsx)(i,{label:e})}export{s as a};
@@ -1 +1 @@
1
- import{a as O,b,c as w,d as R,e as V}from"./chunk.PI44XMY2.js";import{h as d,i as S}from"./chunk.KGW75Z5L.js";import{Ka as $,La as F}from"./chunk.VSCIXAHN.js";var E=["card","row","page"],j=["good","warn","bad","neutral","accent"],U=["money","percent","date","time","datetime","relative","count"],_=4,T=40,I=120,L=["number","money","percent"],B=["large"],C=["card","row"],M=1e3,ce=100;function X(e){let n=/^\s*(out|in)\(\s*['"]([A-Za-z][A-Za-z0-9_-]*)['"]\s*\)\s*$/.exec(e);return n?{edge:n[2],way:n[1]}:/^[A-Za-z][A-Za-z0-9_-]*$/.test(e)?{edge:e}:void 0}var v={title:[],headline:[],list:["sort","limit","group","empty","as"],text:["tone","lines"],badge:["tone"],field:["as","currency","label"],image:["as","label"],progress:["label"],group:["direction"],when:["show"],divider:[],figure:["as","currency","label","emphasis"]},Z=Object.keys(v),G=`{"title": "{name}"}, {"headline": "{count(all('offer'))} offers"}, {"figure": expr, "as"?: "number"|"money"|"percent", "currency"?, "label"?, "emphasis"?: "large"}, {"list": expr, "sort"?, "limit"?, "group"?, "empty"?, "as"?: "card"|"row"}, {"text": "\u2026", "tone"?, "lines"?: 0-12}, {"badge": "{status}", "tone"?}, {"field": "quote", "as"?, "currency"?, "label"?}, {"image": "photos", "as"?: "thumb"|"gallery"}, {"progress": {"value": expr, "max": expr}, "label"?}, {"group": [blocks], "direction"?: "row"|"column"}, {"when": expr, "show": [blocks]}, {"divider": true}, {"figure": true}`,Y=e=>/^(image|video|file)$/.test(e?.of??e?.type??"");function ge(e){return Object.fromEntries(Object.entries(e.views??{}).filter(([,n])=>!Array.isArray(n)))}function ye(e){let n=e.views?.home;return Array.isArray(n)?n:void 0}var q={field:()=>!1,relation:()=>!1,figure:!1},z=e=>e.kind??"the home",m=(e,n)=>e!==void 0&&Object.hasOwn(e,n),g=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function W(e,n,t){let s=O(e);for(let a of s.unknownFunctions)t.findings.push(d("unknown-function",n,`"${a}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let a of s.names){if(t.kind===null){t.findings.push(d("view-name",n,`"${a}" names nothing here: these blocks are about no one record`,"reach records with all('<kind>'), like count(all('offer')) or first(all('party') where role == 'client').name"));continue}a==="id"||t.spec.field(a)||t.spec.relation(a)||t.findings.push(d("view-name",n,`${t.kind} has no field or relation called "${a}"`))}for(let a of s.edges)t.edges.has(a)||t.findings.push(d("view-edge",n,`"${a}" is not a relation any kind declares`));for(let a of s.sweeps)t.kinds.has(a)||t.findings.push(d("view-kind",n,`"${a}" is not a kind this document declares`))}function k(e,n,t){if(typeof e!="string"||e.length===0||e.length>2e3){t.findings.push(d("view-expression",n,`an expression is a line of the rule language, like "status == 'booked'"`));return}try{W(w(e),n,t)}catch(s){if(!(s instanceof b))throw s;t.findings.push(d("expression",n,`${s.sentence} (at character ${s.at+1})`))}}function A(e,n,t,s,a=!1){let l=s==="text";if(typeof e!="string"||e.length===0||e.length>300){t.findings.push(d("view-template",n,'a template is words with {field} in braces, like "{name}" or "{quote|money}", at most 300 characters'));return}let r;try{r=V(e)}catch(i){if(i instanceof R||i instanceof b){t.findings.push(d("template",n,i.sentence));return}throw i}for(let i of r)if(i.expr){if(W(i.expr,n,t),l&&!a&&!i.format&&i.expr.t==="ident"&&(t.slot==="card"||t.slot==="row")&&t.spec.prose?.(i.expr.name)){let o=i.expr.name;t.findings.push(S("view-whole-text",n,`${t.kind} ${t.slot} shows ${o} whole; it will be clamped. Use {${o}|excerpt} or move it to the page.`,`write {${o}|excerpt}, or {${o}|excerpt: 80} for fewer characters`))}if(s==="headline"&&!i.format&&i.expr.t==="ident"&&t.spec.prose?.(i.expr.name)){let o=i.expr.name;t.findings.push(S("view-headline-long",n,`${z(t)}${t.slot?` ${t.slot}`:""} heads it with ${o}, a long text, drawn at a headline's size; a headline is a few words.`,`say it in a text block, {"text": "{${o}}"}, or head it with {${o}|excerpt: 60}`))}}}var K=12;function J(e,n,t){typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=K||t.findings.push(d("view-lines",n,`lines is ${JSON.stringify(e)}, and a text block's lines is a whole number from 1 to ${K}, or 0 to show it whole`,'{"text": "{awards}", "lines": 6}, or "lines": 0 for no cut at all'))}function Q(e,n,t){if(typeof e=="string"){j.includes(e)||t.findings.push(d("view-tone",n,`"${e}" is not a tone`,`use one of ${j.join(", ")}, or {"expr": "if(status == 'booked', 'good', 'neutral')"}`));return}if(g(e)&&Object.keys(e).length===1&&"expr"in e){k(e.expr,`${n}.expr`,t);return}t.findings.push(d("view-tone",n,'a tone is a word or {"expr": \u2026}',`one of ${j.join(", ")}`))}function x(e,n,t,s){if(!Array.isArray(e)){s.findings.push(d("view-shape",n,"a view is a list of blocks"));return}if(t>_){s.findings.push(d("view-depth",n,`blocks nest at most ${_} deep`,"flatten a group or a condition"));return}e.forEach((a,l)=>ee(a,`${n}.${l}`,t,s))}function ee(e,n,t,s){if(t===1&&s.count++,s.all++,!g(e)){s.findings.push(d("view-block",n,"a block is an object naming what it shows",`one of ${G}`));return}let a=Object.keys(e),l=a.filter(o=>Z.includes(o)&&!(o==="group"&&a.includes("list")));if(l.length===0){s.findings.push(d("view-block",n,`${a.length>0?a.map(o=>`"${o}"`).join(", "):"an empty object"} is not a block Graview knows`,`one of ${G}`));return}if(l.length>1){s.findings.push(d("view-block",n,`a block is one thing, and this says ${l.map(o=>`"${o}"`).join(" and ")}`,"split it into two blocks"));return}let r=l[0];for(let o of a)o!==r&&o!="key"&&!v[r].includes(o)&&s.findings.push(d("unknown-key",`${n}.${o}`,`"${o}" is not part of a ${r} block`,v[r].length>0?`a ${r} block may also say ${v[r].map(f=>`"${f}"`).join(", ")}`:`a ${r} block says nothing else`));let i=e[r];switch(r){case"title":case"headline":case"text":case"badge":A(i,`${n}.${r}`,s,r==="text"||r==="headline"?r:void 0,r==="text"&&"lines"in e),"tone"in e&&Q(e.tone,`${n}.tone`,s),r==="text"&&"lines"in e&&J(e.lines,`${n}.lines`,s);return;case"image":case"field":{let o=r==="image";if(typeof i!="string"||!(o?s.spec.files?.(i):s.spec.field(i))){let u=typeof i=="string"&&s.spec.relation(i);s.findings.push(d(`view-${r}`,`${n}.${r}`,`${s.kind} has no ${o?"image, video or file ":""}field ${typeof i=="string"?`"${i}"`:"by that name"}`,u?`"${i}" is a relation; show it with {"text": "{${i}.name}"}`:void 0))}let f=o?["thumb","gallery"]:U;"as"in e&&!f.includes(e.as)&&s.findings.push(d("view-format",`${n}.as`,`"${String(e.as)}" is not a way to show ${o?"pictures":"a field"}`,`use one of ${f.join(", ")}`)),o||D(e,n,s,"field"),"label"in e&&oe(e.label,`${n}.label`,s);return}case"progress":{!g(i)||Object.keys(i).some(o=>o!=="value"&&o!=="max")||!("value"in i)||!("max"in i)?s.findings.push(d("view-progress",`${n}.progress`,'progress is {"value": expression, "max": expression}')):(k(i.value,`${n}.progress.value`,s),k(i.max,`${n}.progress.max`,s)),"label"in e&&A(e.label,`${n}.label`,s);return}case"group":"direction"in e&&e.direction!=="row"&&e.direction!=="column"&&s.findings.push(d("view-direction",`${n}.direction`,`a group runs "row" or "column", not "${String(e.direction)}"`)),x(i,`${n}.group`,t+1,s);return;case"when":k(i,`${n}.when`,s),"show"in e?x(e.show,`${n}.show`,t+1,s):s.findings.push(d("view-when",n,'a condition says what it shows: {"when": expr, "show": [blocks]}'));return;case"figure":if(typeof i=="string")return ne(e,n,s);for(let o of["as","currency","label","emphasis"])o in e&&s.findings.push(d("unknown-key",`${n}.${o}`,`"${o}" belongs to a figure that works a number out; {"figure": true} is the kind's picture`,`write {"figure": "count(all('offer'))", "as": "number"}`));i!==!0?s.findings.push(d("view-block",`${n}.figure`,`a figure is a number worked out, {"figure": "sum(all('offer'), net)", "as": "money"}, or the kind's picture, {"figure": true}`)):s.spec.figure||s.findings.push(d("view-figure",`${n}.figure`,`${z(s)} has no figure to show`,s.kind===null?`work a number out: {"figure": "count(all('offer'))"}`:'give the kind a "figure", or leave this block out'));return;case"list":return te(e,n,s);case"divider":i!==!0&&s.findings.push(d("view-block",`${n}.${r}`,`write {"${r}": true}`));return}}function ne(e,n,t){k(e.figure,`${n}.figure`,t),"as"in e&&!L.includes(e.as)&&t.findings.push(d("view-format",`${n}.as`,`"${String(e.as)}" is not a way to say a figure`,`use one of ${L.join(", ")}`)),D(e,n,t,"figure"),"label"in e&&A(e.label,`${n}.label`,t),"emphasis"in e&&!B.includes(e.emphasis)&&t.findings.push(d("view-emphasis",`${n}.emphasis`,`"${String(e.emphasis)}" is not how loudly a figure is said`,`use ${B.map(s=>`"${s}"`).join(", ")}, or leave it out for the figure's own size`))}function D(e,n,t,s){"currency"in e&&(typeof e.currency!="string"||!/^[A-Z]{3}$/.test(e.currency)?t.findings.push(d("view-currency",`${n}.currency`,'a currency is its three-letter code, like "USD" or "EUR"')):e.as!=="money"&&t.findings.push(d("view-currency",`${n}.currency`,`a currency belongs on a ${s} shown as money`,'add "as": "money"')))}function ie(e,n){let t=[...n.kinds],s=(l,r)=>{let i=new Set;for(let o of l){let f=n.vocabulary.namesOf(o)?.targets?.(r);if(f==="*")return t;for(let u of f??[])i.add(u)}return i.size>0?[...i]:void 0},a=l=>{switch(l.t){case"ident":return n.kind!==null&&n.spec.relation(l.name)?s([n.kind],l.name):void 0;case"member":{let r=a(l.object);return r?s(r,l.name):void 0}case"where":return a(l.set);case"call":{let r=l.args[0],i=r?.t==="lit"&&typeof r.value=="string"?r.value:void 0;if(l.fn==="all")return i!==void 0&&n.kinds.has(i)?[i]:void 0;let o=l.args.length===2&&l.args[1]?.t==="lit"&&typeof l.args[1].value=="string"?l.args[1].value:void 0;if(l.fn==="out"&&o!==void 0){let f=a(r);return f?s(f,o):void 0}if(l.fn==="out")return i!==void 0&&n.kind!==null?s([n.kind],i):void 0;if(l.fn==="in"){let f=o??i,u=o!==void 0?a(r):n.kind!==null?[n.kind]:void 0,c=f!==void 0?n.vocabulary.sources(f).filter(p=>{let y=n.vocabulary.namesOf(p)?.targets?.(f);return!u||y==="*"||u.some(h=>y?.includes(h))}):[];return c.length>0?c:void 0}if((l.fn==="sort"||l.fn==="first")&&r)return a(r);if(l.fn==="either"){let f=l.args.map(a);return f.every(u=>u!==void 0)?[...new Set(f.flatMap(u=>u??[]))]:void 0}return}default:return}};return a(e)}function N(e,n,t,s){let a;try{a=w(e)}catch(r){if(!(r instanceof b))throw r;s.findings.push(d("expression",n,`${r.sentence} (at character ${r.at+1})`));return}let l=O(a);for(let r of l.unknownFunctions)s.findings.push(d("unknown-function",n,`"${r}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let r of l.edges)s.edges.has(r)||s.findings.push(d("view-edge",n,`"${r}" is not a relation any kind declares`));if(t)for(let r of l.names)r==="id"||t.some(i=>s.vocabulary.namesOf(i)?.field(r)||s.vocabulary.namesOf(i)?.relation(r))||s.findings.push(d("view-name",n,`${t.join(" and ")} ${t.length===1?"has":"have"} no field or relation called "${r}"`))}function te(e,n,t){let s=e.list;k(s,`${n}.list`,t);let a;if(typeof s=="string")try{a=ie(w(s),t)}catch{a=void 0}let l=i=>{if(!a)return[...t.kinds].map(f=>t.vocabulary.namesOf(f)?.choices?.(i)).find(f=>f!==void 0);let o=a.map(f=>t.vocabulary.namesOf(f)?.choices?.(i));return o.every(f=>f!==void 0)?[...new Set(o.flatMap(f=>f??[]))]:void 0},r=a?a.join(" and "):"any kind";if("sort"in e){let i=e.sort;if(typeof i=="string")N(i,`${n}.sort`,a,t);else if(g(i)&&typeof i.by=="string"&&Object.keys(i).every(o=>o==="by"||o==="direction")){let o=i.direction;o!==void 0&&o!=="asc"&&o!=="desc"&&o!=="choices"?t.findings.push(d("list-sort",`${n}.sort.direction`,`a list is sorted "asc", "desc" or "choices", not "${String(o)}"`,'"choices" puts a choice field in the order its choices are declared')):o==="choices"?l(i.by)===void 0&&t.findings.push(d("list-sort",`${n}.sort.by`,`"${i.by}" is not a choice field of ${r}, so it has no declared order`,'sort by a choice field, or say "asc" or "desc"')):N(i.by,`${n}.sort.by`,a,t)}else t.findings.push(d("list-sort",`${n}.sort`,'a sort is a key, like "net", or {"by": key, "direction": "asc" | "desc" | "choices"}'))}if("limit"in e){let i=e.limit;(typeof i!="number"||!Number.isInteger(i)||i<1||i>M)&&t.findings.push(d("list-limit",`${n}.limit`,`a limit is a whole number from 1 to ${M}`))}if("group"in e){let i=e.group,o=typeof i=="string"?i:g(i)&&typeof i.by=="string"?i.by:void 0;if(!(typeof i=="string"||g(i)&&Object.keys(i).every(u=>u==="by"||u==="headings"))||o===void 0)t.findings.push(d("list-group",`${n}.group`,'a group is a choice field, like "type", or {"by": "type", "headings": {"pain": "What hurts"}} \u2014 or a relation, like "inGenre", a heading per linked record'));else{let u=l(o),c=u===void 0?X(o):void 0,p=c!==void 0&&(c.way!==void 0?t.edges.has(c.edge):a?a.every(y=>t.vocabulary.namesOf(y)?.relation(c.edge)):t.edges.has(c.edge));if(u===void 0&&!p&&t.findings.push(d("list-group",`${n}.group`,`"${o}" is not a choice field or a relation of ${r}, so it has nothing to group by`,'group by a field whose type is enum, or by a relation of the kind listed, like "inGenre"')),g(i)&&"headings"in i){let y=i.headings;if(!g(y)||Object.values(y).some(h=>typeof h!="string"||h.length===0||h.length>80))t.findings.push(d("list-group",`${n}.group.headings`,'headings are words per choice, like {"pain": "What hurts"}, at most 80 characters each'));else if(u)for(let h of Object.keys(y))u.includes(h)||t.findings.push(d("list-group",`${n}.group.headings.${h}`,`"${h}" is not one of ${o}'s choices`,`use ${u.join(", ")}`))}}}"empty"in e&&(typeof e.empty!="string"||e.empty.length===0||e.empty.length>200)&&t.findings.push(d("list-empty",`${n}.empty`,"what an empty list says is a sentence, at most 200 characters")),"as"in e&&!C.includes(e.as)&&t.findings.push(d("list-as",`${n}.as`,`a list draws each record as its "card" or its "row", not "${String(e.as)}"`))}function oe(e,n,t){(typeof e!="string"||e.length===0||e.length>60)&&t.findings.push(d("view-label",n,"a label is a few words, at most 60 characters"))}function P(e,n,t,s,a,l,r){let i={kind:null,spec:q,kinds:s,edges:a,vocabulary:t,findings:l,count:0,all:0};Array.isArray(e)&&e.length===0&&l.push(d("view-shape",n,`${r} has no blocks`,'give it one: {"headline": "\u2026"}')),x(e,n,1,i),H(i,n,r,"show less")}function H(e,n,t,s){e.count>T?e.findings.push(d("view-size",n,`${t} has ${e.count} blocks at its top; a view has at most ${T} there, a group or a condition counting as one`,`${s}, or gather some into a group`)):e.all>I&&e.findings.push(d("view-size",n,`${t} has ${e.all} blocks counting the ones inside its groups and conditions; a view has at most ${I} in all`,s))}function se(e,n,t,s,a){Array.isArray(e)&&e.forEach((l,r)=>{if(!g(l)||l.name!=="blocks"||!g(l.options)||!("blocks"in l.options))return;let i=[];P(l.options.blocks,`lenses.${r}.options.blocks`,n,t,s,i,`the lens "${String(l.title??r)}"`);for(let o of i)a.push({...o,severity:"warning"})})}function re(e,n,t,s,a,l,r){let i=[];if(e===void 0)return i;if(!g(e))return i.push(d("view-shape",n,'views are an object of kinds, each with a "card", a "row" or a "page"')),i;for(let[o,f]of Object.entries(e)){if(o==="home"&&Array.isArray(f)){P(f,`${n}.home`,r,s,a,i,"the home");continue}let u=t(o);if(!u){i.push(d("view-kind",`${n}.${o}`,`"${o}" is not a kind this ${l} declares`));continue}if(!g(f)){i.push(d("view-shape",`${n}.${o}`,`a kind's views are {"card": [blocks], "row": [blocks], "page": [blocks]}`));continue}for(let c of Object.keys(f))E.includes(c)||i.push(d("view-slot",`${n}.${o}.${c}`,`"${c}" is not a place a view is drawn`,`use ${E.map(p=>`"${p}"`).join(", ")}`));for(let c of E){let p=f[c];if(p===void 0)continue;let y={kind:o,spec:u,kinds:s,edges:a,vocabulary:r,findings:i,count:0,all:0,slot:c};x(p,`${n}.${o}.${c}`,1,y),H(y,`${n}.${o}.${c}`,`this ${c}`,"show less, or move detail to the page")}}return i}function he(e){let n=new Set(Object.keys(e.kinds)),t=new Set(Object.values(e.kinds).flatMap(r=>Object.keys($(r.edges)))),s=r=>{let i=m(e.kinds,r)?e.kinds[r]:void 0;return i?{field:o=>m(i.fields,o)||m(i.computed,o)||F(i.edges).has(o),relation:o=>m($(i.edges),o),figure:i.figure!==void 0,files:o=>m(i.fields,o)&&Y(i.fields[o]),choices:o=>m(i.fields,o)&&i.fields[o].type==="enum"?i.fields[o].options:void 0,targets:o=>m($(i.edges),o)?i.edges[o].to:void 0,prose:o=>m(i.fields,o)&&i.fields[o].type==="text"}:void 0},a={namesOf:s,sources:r=>Object.keys(e.kinds).filter(i=>m(e.kinds[i].edges,r))},l=re(e.views,"views",s,n,t,"document",a);return se(e.lenses,a,n,t,l),l}export{j as a,U as b,L as c,B as d,M as e,ce as f,X as g,ge as h,ye as i,he as j};
1
+ import{a as O,b,c as w,d as R,e as V}from"./chunk.OWT3VVOT.js";import{h as d,i as S}from"./chunk.NHTGAP3G.js";import{Na as $,Oa as F}from"./chunk.DZZL5IDD.js";var E=["card","row","page"],j=["good","warn","bad","neutral","accent"],U=["money","percent","date","time","datetime","relative","count"],_=4,T=40,I=120,L=["number","money","percent"],B=["large"],C=["card","row"],M=1e3,ce=100;function X(e){let n=/^\s*(out|in)\(\s*['"]([A-Za-z][A-Za-z0-9_-]*)['"]\s*\)\s*$/.exec(e);return n?{edge:n[2],way:n[1]}:/^[A-Za-z][A-Za-z0-9_-]*$/.test(e)?{edge:e}:void 0}var v={title:[],headline:[],list:["sort","limit","group","empty","as"],text:["tone","lines"],badge:["tone"],field:["as","currency","label"],image:["as","label"],progress:["label"],group:["direction"],when:["show"],divider:[],figure:["as","currency","label","emphasis"]},Z=Object.keys(v),G=`{"title": "{name}"}, {"headline": "{count(all('offer'))} offers"}, {"figure": expr, "as"?: "number"|"money"|"percent", "currency"?, "label"?, "emphasis"?: "large"}, {"list": expr, "sort"?, "limit"?, "group"?, "empty"?, "as"?: "card"|"row"}, {"text": "\u2026", "tone"?, "lines"?: 0-12}, {"badge": "{status}", "tone"?}, {"field": "quote", "as"?, "currency"?, "label"?}, {"image": "photos", "as"?: "thumb"|"gallery"}, {"progress": {"value": expr, "max": expr}, "label"?}, {"group": [blocks], "direction"?: "row"|"column"}, {"when": expr, "show": [blocks]}, {"divider": true}, {"figure": true}`,Y=e=>/^(image|video|file)$/.test(e?.of??e?.type??"");function ge(e){return Object.fromEntries(Object.entries(e.views??{}).filter(([,n])=>!Array.isArray(n)))}function ye(e){let n=e.views?.home;return Array.isArray(n)?n:void 0}var q={field:()=>!1,relation:()=>!1,figure:!1},z=e=>e.kind??"the home",m=(e,n)=>e!==void 0&&Object.hasOwn(e,n),g=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function W(e,n,t){let s=O(e);for(let a of s.unknownFunctions)t.findings.push(d("unknown-function",n,`"${a}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let a of s.names){if(t.kind===null){t.findings.push(d("view-name",n,`"${a}" names nothing here: these blocks are about no one record`,"reach records with all('<kind>'), like count(all('offer')) or first(all('party') where role == 'client').name"));continue}a==="id"||t.spec.field(a)||t.spec.relation(a)||t.findings.push(d("view-name",n,`${t.kind} has no field or relation called "${a}"`))}for(let a of s.edges)t.edges.has(a)||t.findings.push(d("view-edge",n,`"${a}" is not a relation any kind declares`));for(let a of s.sweeps)t.kinds.has(a)||t.findings.push(d("view-kind",n,`"${a}" is not a kind this document declares`))}function k(e,n,t){if(typeof e!="string"||e.length===0||e.length>2e3){t.findings.push(d("view-expression",n,`an expression is a line of the rule language, like "status == 'booked'"`));return}try{W(w(e),n,t)}catch(s){if(!(s instanceof b))throw s;t.findings.push(d("expression",n,`${s.sentence} (at character ${s.at+1})`))}}function A(e,n,t,s,a=!1){let l=s==="text";if(typeof e!="string"||e.length===0||e.length>300){t.findings.push(d("view-template",n,'a template is words with {field} in braces, like "{name}" or "{quote|money}", at most 300 characters'));return}let r;try{r=V(e)}catch(i){if(i instanceof R||i instanceof b){t.findings.push(d("template",n,i.sentence));return}throw i}for(let i of r)if(i.expr){if(W(i.expr,n,t),l&&!a&&!i.format&&i.expr.t==="ident"&&(t.slot==="card"||t.slot==="row")&&t.spec.prose?.(i.expr.name)){let o=i.expr.name;t.findings.push(S("view-whole-text",n,`${t.kind} ${t.slot} shows ${o} whole; it will be clamped. Use {${o}|excerpt} or move it to the page.`,`write {${o}|excerpt}, or {${o}|excerpt: 80} for fewer characters`))}if(s==="headline"&&!i.format&&i.expr.t==="ident"&&t.spec.prose?.(i.expr.name)){let o=i.expr.name;t.findings.push(S("view-headline-long",n,`${z(t)}${t.slot?` ${t.slot}`:""} heads it with ${o}, a long text, drawn at a headline's size; a headline is a few words.`,`say it in a text block, {"text": "{${o}}"}, or head it with {${o}|excerpt: 60}`))}}}var K=12;function J(e,n,t){typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=K||t.findings.push(d("view-lines",n,`lines is ${JSON.stringify(e)}, and a text block's lines is a whole number from 1 to ${K}, or 0 to show it whole`,'{"text": "{awards}", "lines": 6}, or "lines": 0 for no cut at all'))}function Q(e,n,t){if(typeof e=="string"){j.includes(e)||t.findings.push(d("view-tone",n,`"${e}" is not a tone`,`use one of ${j.join(", ")}, or {"expr": "if(status == 'booked', 'good', 'neutral')"}`));return}if(g(e)&&Object.keys(e).length===1&&"expr"in e){k(e.expr,`${n}.expr`,t);return}t.findings.push(d("view-tone",n,'a tone is a word or {"expr": \u2026}',`one of ${j.join(", ")}`))}function x(e,n,t,s){if(!Array.isArray(e)){s.findings.push(d("view-shape",n,"a view is a list of blocks"));return}if(t>_){s.findings.push(d("view-depth",n,`blocks nest at most ${_} deep`,"flatten a group or a condition"));return}e.forEach((a,l)=>ee(a,`${n}.${l}`,t,s))}function ee(e,n,t,s){if(t===1&&s.count++,s.all++,!g(e)){s.findings.push(d("view-block",n,"a block is an object naming what it shows",`one of ${G}`));return}let a=Object.keys(e),l=a.filter(o=>Z.includes(o)&&!(o==="group"&&a.includes("list")));if(l.length===0){s.findings.push(d("view-block",n,`${a.length>0?a.map(o=>`"${o}"`).join(", "):"an empty object"} is not a block Graview knows`,`one of ${G}`));return}if(l.length>1){s.findings.push(d("view-block",n,`a block is one thing, and this says ${l.map(o=>`"${o}"`).join(" and ")}`,"split it into two blocks"));return}let r=l[0];for(let o of a)o!==r&&o!="key"&&!v[r].includes(o)&&s.findings.push(d("unknown-key",`${n}.${o}`,`"${o}" is not part of a ${r} block`,v[r].length>0?`a ${r} block may also say ${v[r].map(f=>`"${f}"`).join(", ")}`:`a ${r} block says nothing else`));let i=e[r];switch(r){case"title":case"headline":case"text":case"badge":A(i,`${n}.${r}`,s,r==="text"||r==="headline"?r:void 0,r==="text"&&"lines"in e),"tone"in e&&Q(e.tone,`${n}.tone`,s),r==="text"&&"lines"in e&&J(e.lines,`${n}.lines`,s);return;case"image":case"field":{let o=r==="image";if(typeof i!="string"||!(o?s.spec.files?.(i):s.spec.field(i))){let u=typeof i=="string"&&s.spec.relation(i);s.findings.push(d(`view-${r}`,`${n}.${r}`,`${s.kind} has no ${o?"image, video or file ":""}field ${typeof i=="string"?`"${i}"`:"by that name"}`,u?`"${i}" is a relation; show it with {"text": "{${i}.name}"}`:void 0))}let f=o?["thumb","gallery"]:U;"as"in e&&!f.includes(e.as)&&s.findings.push(d("view-format",`${n}.as`,`"${String(e.as)}" is not a way to show ${o?"pictures":"a field"}`,`use one of ${f.join(", ")}`)),o||D(e,n,s,"field"),"label"in e&&oe(e.label,`${n}.label`,s);return}case"progress":{!g(i)||Object.keys(i).some(o=>o!=="value"&&o!=="max")||!("value"in i)||!("max"in i)?s.findings.push(d("view-progress",`${n}.progress`,'progress is {"value": expression, "max": expression}')):(k(i.value,`${n}.progress.value`,s),k(i.max,`${n}.progress.max`,s)),"label"in e&&A(e.label,`${n}.label`,s);return}case"group":"direction"in e&&e.direction!=="row"&&e.direction!=="column"&&s.findings.push(d("view-direction",`${n}.direction`,`a group runs "row" or "column", not "${String(e.direction)}"`)),x(i,`${n}.group`,t+1,s);return;case"when":k(i,`${n}.when`,s),"show"in e?x(e.show,`${n}.show`,t+1,s):s.findings.push(d("view-when",n,'a condition says what it shows: {"when": expr, "show": [blocks]}'));return;case"figure":if(typeof i=="string")return ne(e,n,s);for(let o of["as","currency","label","emphasis"])o in e&&s.findings.push(d("unknown-key",`${n}.${o}`,`"${o}" belongs to a figure that works a number out; {"figure": true} is the kind's picture`,`write {"figure": "count(all('offer'))", "as": "number"}`));i!==!0?s.findings.push(d("view-block",`${n}.figure`,`a figure is a number worked out, {"figure": "sum(all('offer'), net)", "as": "money"}, or the kind's picture, {"figure": true}`)):s.spec.figure||s.findings.push(d("view-figure",`${n}.figure`,`${z(s)} has no figure to show`,s.kind===null?`work a number out: {"figure": "count(all('offer'))"}`:'give the kind a "figure", or leave this block out'));return;case"list":return te(e,n,s);case"divider":i!==!0&&s.findings.push(d("view-block",`${n}.${r}`,`write {"${r}": true}`));return}}function ne(e,n,t){k(e.figure,`${n}.figure`,t),"as"in e&&!L.includes(e.as)&&t.findings.push(d("view-format",`${n}.as`,`"${String(e.as)}" is not a way to say a figure`,`use one of ${L.join(", ")}`)),D(e,n,t,"figure"),"label"in e&&A(e.label,`${n}.label`,t),"emphasis"in e&&!B.includes(e.emphasis)&&t.findings.push(d("view-emphasis",`${n}.emphasis`,`"${String(e.emphasis)}" is not how loudly a figure is said`,`use ${B.map(s=>`"${s}"`).join(", ")}, or leave it out for the figure's own size`))}function D(e,n,t,s){"currency"in e&&(typeof e.currency!="string"||!/^[A-Z]{3}$/.test(e.currency)?t.findings.push(d("view-currency",`${n}.currency`,'a currency is its three-letter code, like "USD" or "EUR"')):e.as!=="money"&&t.findings.push(d("view-currency",`${n}.currency`,`a currency belongs on a ${s} shown as money`,'add "as": "money"')))}function ie(e,n){let t=[...n.kinds],s=(l,r)=>{let i=new Set;for(let o of l){let f=n.vocabulary.namesOf(o)?.targets?.(r);if(f==="*")return t;for(let u of f??[])i.add(u)}return i.size>0?[...i]:void 0},a=l=>{switch(l.t){case"ident":return n.kind!==null&&n.spec.relation(l.name)?s([n.kind],l.name):void 0;case"member":{let r=a(l.object);return r?s(r,l.name):void 0}case"where":return a(l.set);case"call":{let r=l.args[0],i=r?.t==="lit"&&typeof r.value=="string"?r.value:void 0;if(l.fn==="all")return i!==void 0&&n.kinds.has(i)?[i]:void 0;let o=l.args.length===2&&l.args[1]?.t==="lit"&&typeof l.args[1].value=="string"?l.args[1].value:void 0;if(l.fn==="out"&&o!==void 0){let f=a(r);return f?s(f,o):void 0}if(l.fn==="out")return i!==void 0&&n.kind!==null?s([n.kind],i):void 0;if(l.fn==="in"){let f=o??i,u=o!==void 0?a(r):n.kind!==null?[n.kind]:void 0,c=f!==void 0?n.vocabulary.sources(f).filter(p=>{let y=n.vocabulary.namesOf(p)?.targets?.(f);return!u||y==="*"||u.some(h=>y?.includes(h))}):[];return c.length>0?c:void 0}if((l.fn==="sort"||l.fn==="first")&&r)return a(r);if(l.fn==="either"){let f=l.args.map(a);return f.every(u=>u!==void 0)?[...new Set(f.flatMap(u=>u??[]))]:void 0}return}default:return}};return a(e)}function N(e,n,t,s){let a;try{a=w(e)}catch(r){if(!(r instanceof b))throw r;s.findings.push(d("expression",n,`${r.sentence} (at character ${r.at+1})`));return}let l=O(a);for(let r of l.unknownFunctions)s.findings.push(d("unknown-function",n,`"${r}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let r of l.edges)s.edges.has(r)||s.findings.push(d("view-edge",n,`"${r}" is not a relation any kind declares`));if(t)for(let r of l.names)r==="id"||t.some(i=>s.vocabulary.namesOf(i)?.field(r)||s.vocabulary.namesOf(i)?.relation(r))||s.findings.push(d("view-name",n,`${t.join(" and ")} ${t.length===1?"has":"have"} no field or relation called "${r}"`))}function te(e,n,t){let s=e.list;k(s,`${n}.list`,t);let a;if(typeof s=="string")try{a=ie(w(s),t)}catch{a=void 0}let l=i=>{if(!a)return[...t.kinds].map(f=>t.vocabulary.namesOf(f)?.choices?.(i)).find(f=>f!==void 0);let o=a.map(f=>t.vocabulary.namesOf(f)?.choices?.(i));return o.every(f=>f!==void 0)?[...new Set(o.flatMap(f=>f??[]))]:void 0},r=a?a.join(" and "):"any kind";if("sort"in e){let i=e.sort;if(typeof i=="string")N(i,`${n}.sort`,a,t);else if(g(i)&&typeof i.by=="string"&&Object.keys(i).every(o=>o==="by"||o==="direction")){let o=i.direction;o!==void 0&&o!=="asc"&&o!=="desc"&&o!=="choices"?t.findings.push(d("list-sort",`${n}.sort.direction`,`a list is sorted "asc", "desc" or "choices", not "${String(o)}"`,'"choices" puts a choice field in the order its choices are declared')):o==="choices"?l(i.by)===void 0&&t.findings.push(d("list-sort",`${n}.sort.by`,`"${i.by}" is not a choice field of ${r}, so it has no declared order`,'sort by a choice field, or say "asc" or "desc"')):N(i.by,`${n}.sort.by`,a,t)}else t.findings.push(d("list-sort",`${n}.sort`,'a sort is a key, like "net", or {"by": key, "direction": "asc" | "desc" | "choices"}'))}if("limit"in e){let i=e.limit;(typeof i!="number"||!Number.isInteger(i)||i<1||i>M)&&t.findings.push(d("list-limit",`${n}.limit`,`a limit is a whole number from 1 to ${M}`))}if("group"in e){let i=e.group,o=typeof i=="string"?i:g(i)&&typeof i.by=="string"?i.by:void 0;if(!(typeof i=="string"||g(i)&&Object.keys(i).every(u=>u==="by"||u==="headings"))||o===void 0)t.findings.push(d("list-group",`${n}.group`,'a group is a choice field, like "type", or {"by": "type", "headings": {"pain": "What hurts"}} \u2014 or a relation, like "inGenre", a heading per linked record'));else{let u=l(o),c=u===void 0?X(o):void 0,p=c!==void 0&&(c.way!==void 0?t.edges.has(c.edge):a?a.every(y=>t.vocabulary.namesOf(y)?.relation(c.edge)):t.edges.has(c.edge));if(u===void 0&&!p&&t.findings.push(d("list-group",`${n}.group`,`"${o}" is not a choice field or a relation of ${r}, so it has nothing to group by`,'group by a field whose type is enum, or by a relation of the kind listed, like "inGenre"')),g(i)&&"headings"in i){let y=i.headings;if(!g(y)||Object.values(y).some(h=>typeof h!="string"||h.length===0||h.length>80))t.findings.push(d("list-group",`${n}.group.headings`,'headings are words per choice, like {"pain": "What hurts"}, at most 80 characters each'));else if(u)for(let h of Object.keys(y))u.includes(h)||t.findings.push(d("list-group",`${n}.group.headings.${h}`,`"${h}" is not one of ${o}'s choices`,`use ${u.join(", ")}`))}}}"empty"in e&&(typeof e.empty!="string"||e.empty.length===0||e.empty.length>200)&&t.findings.push(d("list-empty",`${n}.empty`,"what an empty list says is a sentence, at most 200 characters")),"as"in e&&!C.includes(e.as)&&t.findings.push(d("list-as",`${n}.as`,`a list draws each record as its "card" or its "row", not "${String(e.as)}"`))}function oe(e,n,t){(typeof e!="string"||e.length===0||e.length>60)&&t.findings.push(d("view-label",n,"a label is a few words, at most 60 characters"))}function P(e,n,t,s,a,l,r){let i={kind:null,spec:q,kinds:s,edges:a,vocabulary:t,findings:l,count:0,all:0};Array.isArray(e)&&e.length===0&&l.push(d("view-shape",n,`${r} has no blocks`,'give it one: {"headline": "\u2026"}')),x(e,n,1,i),H(i,n,r,"show less")}function H(e,n,t,s){e.count>T?e.findings.push(d("view-size",n,`${t} has ${e.count} blocks at its top; a view has at most ${T} there, a group or a condition counting as one`,`${s}, or gather some into a group`)):e.all>I&&e.findings.push(d("view-size",n,`${t} has ${e.all} blocks counting the ones inside its groups and conditions; a view has at most ${I} in all`,s))}function se(e,n,t,s,a){Array.isArray(e)&&e.forEach((l,r)=>{if(!g(l)||l.name!=="blocks"||!g(l.options)||!("blocks"in l.options))return;let i=[];P(l.options.blocks,`lenses.${r}.options.blocks`,n,t,s,i,`the lens "${String(l.title??r)}"`);for(let o of i)a.push({...o,severity:"warning"})})}function re(e,n,t,s,a,l,r){let i=[];if(e===void 0)return i;if(!g(e))return i.push(d("view-shape",n,'views are an object of kinds, each with a "card", a "row" or a "page"')),i;for(let[o,f]of Object.entries(e)){if(o==="home"&&Array.isArray(f)){P(f,`${n}.home`,r,s,a,i,"the home");continue}let u=t(o);if(!u){i.push(d("view-kind",`${n}.${o}`,`"${o}" is not a kind this ${l} declares`));continue}if(!g(f)){i.push(d("view-shape",`${n}.${o}`,`a kind's views are {"card": [blocks], "row": [blocks], "page": [blocks]}`));continue}for(let c of Object.keys(f))E.includes(c)||i.push(d("view-slot",`${n}.${o}.${c}`,`"${c}" is not a place a view is drawn`,`use ${E.map(p=>`"${p}"`).join(", ")}`));for(let c of E){let p=f[c];if(p===void 0)continue;let y={kind:o,spec:u,kinds:s,edges:a,vocabulary:r,findings:i,count:0,all:0,slot:c};x(p,`${n}.${o}.${c}`,1,y),H(y,`${n}.${o}.${c}`,`this ${c}`,"show less, or move detail to the page")}}return i}function he(e){let n=new Set(Object.keys(e.kinds)),t=new Set(Object.values(e.kinds).flatMap(r=>Object.keys($(r.edges)))),s=r=>{let i=m(e.kinds,r)?e.kinds[r]:void 0;return i?{field:o=>m(i.fields,o)||m(i.computed,o)||F(i.edges).has(o),relation:o=>m($(i.edges),o),figure:i.figure!==void 0,files:o=>m(i.fields,o)&&Y(i.fields[o]),choices:o=>m(i.fields,o)&&i.fields[o].type==="enum"?i.fields[o].options:void 0,targets:o=>m($(i.edges),o)?i.edges[o].to:void 0,prose:o=>m(i.fields,o)&&i.fields[o].type==="text"}:void 0},a={namesOf:s,sources:r=>Object.keys(e.kinds).filter(i=>m(e.kinds[i].edges,r))},l=re(e.views,"views",s,n,t,"document",a);return se(e.lenses,a,n,t,l),l}export{j as a,U as b,L as c,B as d,M as e,ce as f,X as g,ge as h,ye as i,he as j};
@@ -1 +1 @@
1
- import{Ma as y,Oa as k,T as w,j as c,l as h,m as b,r as f}from"./chunk.4MP72LPR.js";import{W as i}from"./chunk.VSCIXAHN.js";import{b as g}from"./chunk.AJZBJBMO.js";var s=null,a=new Set,v=e=>{s={kind:e,n:(s?.n??0)+1};for(let t of a)t()},A=()=>s,C=e=>(a.add(e),()=>a.delete(e)),V=()=>{s=null};var d=g(w(),1);function T(e,t){if(e.length===0||t.length===0)return[];let o=new Set(t.map(n=>n.id));return e.filter(n=>n.nodeIds.some(l=>o.has(l)))}var x=(e,t)=>`${i(e)} ${e===1?"problem":"problems"} in ${t}`;function q({kind:e,plural:t,problems:o,flag:n,listed:l=!1}){let{view:p,go:P}=k(),{set:$}=y();if(o.length===0)return null;let u=x(o.length,t),m=o.length===1?"it":"them";return(0,d.jsx)("button",{type:"button",className:"graview-district-problems","data-testid":`district-problems-${e}`,"data-graview-problems":o.length,"aria-expanded":l,"aria-label":u,title:`${u} \u2014 ${o[0].message}${o.length>1?` (and ${i(o.length-1)} more)`:""}. Press to see ${m} and how to fix ${m}.`,onClick:r=>{r.stopPropagation(),p.overview||P(h(c(b(p,!0),null),"view",null)),$([f(e)]),v(e)},onDoubleClick:r=>r.stopPropagation(),onPointerDown:r=>r.stopPropagation(),children:(0,d.jsx)("span",{"aria-hidden":"true",children:`${n} ${i(o.length)}`})})}export{A as a,C as b,V as c,T as d,x as e,q as f};
1
+ import{Ma as y,Oa as k,T as w,j as c,l as h,m as b,r as f}from"./chunk.M7RESZB6.js";import{Z as i}from"./chunk.DZZL5IDD.js";import{b as g}from"./chunk.AJZBJBMO.js";var s=null,a=new Set,v=e=>{s={kind:e,n:(s?.n??0)+1};for(let t of a)t()},A=()=>s,C=e=>(a.add(e),()=>a.delete(e)),V=()=>{s=null};var d=g(w(),1);function T(e,t){if(e.length===0||t.length===0)return[];let o=new Set(t.map(n=>n.id));return e.filter(n=>n.nodeIds.some(l=>o.has(l)))}var x=(e,t)=>`${i(e)} ${e===1?"problem":"problems"} in ${t}`;function q({kind:e,plural:t,problems:o,flag:n,listed:l=!1}){let{view:p,go:P}=k(),{set:$}=y();if(o.length===0)return null;let u=x(o.length,t),m=o.length===1?"it":"them";return(0,d.jsx)("button",{type:"button",className:"graview-district-problems","data-testid":`district-problems-${e}`,"data-graview-problems":o.length,"aria-expanded":l,"aria-label":u,title:`${u} \u2014 ${o[0].message}${o.length>1?` (and ${i(o.length-1)} more)`:""}. Press to see ${m} and how to fix ${m}.`,onClick:r=>{r.stopPropagation(),p.overview||P(h(c(b(p,!0),null),"view",null)),$([f(e)]),v(e)},onDoubleClick:r=>r.stopPropagation(),onPointerDown:r=>r.stopPropagation(),children:(0,d.jsx)("span",{"aria-hidden":"true",children:`${n} ${i(o.length)}`})})}export{A as a,C as b,V as c,T as d,x as e,q as f};