graview 0.1.63 → 0.1.64

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 (179) hide show
  1. package/dist/preview/chunk.2D7K2IJQ.js +4 -0
  2. package/dist/preview/{chunk.GHN62OMG.js → chunk.2DH42I7L.js} +1 -1
  3. package/dist/preview/chunk.2E62YCMZ.js +1 -0
  4. package/dist/preview/{chunk.DIFIHNR3.js → chunk.2G5WLG3Z.js} +1 -1
  5. package/dist/preview/chunk.2HV5FF6O.js +1 -0
  6. package/dist/preview/{chunk.6Z2GHQQH.js → chunk.2JDAUKSN.js} +3 -3
  7. package/dist/preview/{chunk.DZSZUX34.js → chunk.2JEN2RCB.js} +1 -1
  8. package/dist/preview/{chunk.NEPQBMFT.js → chunk.2TCOLAL2.js} +1 -1
  9. package/dist/preview/{chunk.VZDHRY3U.js → chunk.2V7QTIAV.js} +1 -1
  10. package/dist/preview/{chunk.T3JIZNE7.js → chunk.2VIS2NAT.js} +1 -1
  11. package/dist/preview/{chunk.2PJ6STKA.js → chunk.2VYGDY5Z.js} +1 -1
  12. package/dist/preview/{chunk.5QXQ7PBI.js → chunk.37I45R6V.js} +1 -1
  13. package/dist/preview/chunk.3FKKH2XU.js +74 -0
  14. package/dist/preview/chunk.3J7XLJP2.js +1 -0
  15. package/dist/preview/chunk.3OEODIHB.js +1 -0
  16. package/dist/preview/{chunk.R4HDKNT3.js → chunk.3RD4JHVG.js} +1 -1
  17. package/dist/preview/{chunk.XCEZCOX4.js → chunk.3RUV4HE4.js} +1 -1
  18. package/dist/preview/{chunk.WUVXIUA7.js → chunk.3SAESG6X.js} +1 -1
  19. package/dist/preview/{chunk.OIMGD7FR.js → chunk.47N2G7A5.js} +1 -1
  20. package/dist/preview/{chunk.B5PJCYBU.js → chunk.4DZOAB4D.js} +1 -1
  21. package/dist/preview/chunk.4HTB6TX2.js +1 -0
  22. package/dist/preview/{chunk.EJ2WE764.js → chunk.4Q5PCMGZ.js} +4 -4
  23. package/dist/preview/{chunk.2F4AZZQR.js → chunk.4U45EY5M.js} +1 -1
  24. package/dist/preview/{chunk.PDMX3GTL.js → chunk.4VRX7FCO.js} +1 -1
  25. package/dist/preview/{chunk.HRNNRA2I.js → chunk.4XCYZRZ3.js} +1 -1
  26. package/dist/preview/chunk.52MBXPEK.js +1 -0
  27. package/dist/preview/{chunk.D5LOTCBU.js → chunk.5AD2QHWH.js} +1 -1
  28. package/dist/preview/{chunk.36OE6RKG.js → chunk.5B7NG6WH.js} +1 -1
  29. package/dist/preview/chunk.5HJ2GTKZ.js +1 -0
  30. package/dist/preview/{chunk.2KIWGQXC.js → chunk.5IEZF433.js} +1 -1
  31. package/dist/preview/{chunk.UAVK54Z6.js → chunk.5PPCK7QT.js} +1 -1
  32. package/dist/preview/{chunk.SSAETRHR.js → chunk.6NRWLCIZ.js} +2 -2
  33. package/dist/preview/{chunk.REUMBCSV.js → chunk.75JQCTR6.js} +1 -1
  34. package/dist/preview/{chunk.A2R53GWF.js → chunk.77JI5T4F.js} +1 -1
  35. package/dist/preview/{chunk.BQM3YAMR.js → chunk.77MLXWZV.js} +1 -1
  36. package/dist/preview/{chunk.33XNYHI6.js → chunk.7AOEZJRM.js} +1 -1
  37. package/dist/preview/{chunk.4EXC26LI.js → chunk.7CLKGKSF.js} +1 -1
  38. package/dist/preview/{chunk.NTC2H5ZX.js → chunk.7SRSE5IS.js} +1 -1
  39. package/dist/preview/{chunk.SMHP2CQH.js → chunk.7VAHHEDX.js} +1 -1
  40. package/dist/preview/{chunk.4MEQUUG4.js → chunk.7ZG77OI3.js} +1 -1
  41. package/dist/preview/chunk.7ZHH7WBN.js +1 -0
  42. package/dist/preview/{chunk.ZY7US4Y7.js → chunk.AJEK3I5X.js} +1 -1
  43. package/dist/preview/{chunk.T535ZLRM.js → chunk.APRWUIE3.js} +1 -1
  44. package/dist/preview/{chunk.KXFNRJ46.js → chunk.APUQIELA.js} +1 -1
  45. package/dist/preview/{chunk.OXWOUE3W.js → chunk.ATHLE33D.js} +1 -1
  46. package/dist/preview/chunk.B2YTHEX5.js +1 -0
  47. package/dist/preview/{chunk.KB5BCW23.js → chunk.B6JR7EQO.js} +1 -1
  48. package/dist/preview/{chunk.H5SN46VK.js → chunk.BN42H3C6.js} +1 -1
  49. package/dist/preview/{chunk.OM2NIQWA.js → chunk.BVIJXL4J.js} +1 -1
  50. package/dist/preview/{chunk.N3T2O6EW.js → chunk.CC7P435K.js} +2 -2
  51. package/dist/preview/{chunk.XBYJCGPU.js → chunk.CJHYGRWV.js} +1 -1
  52. package/dist/preview/chunk.CM65MCHA.js +1 -0
  53. package/dist/preview/{chunk.STDJ6XG5.js → chunk.D2XLECMP.js} +1 -1
  54. package/dist/preview/{chunk.72YXFJKC.js → chunk.DJIF7IAQ.js} +1 -1
  55. package/dist/preview/{chunk.CGK2PY76.js → chunk.DLWFULWE.js} +1 -1
  56. package/dist/preview/{chunk.MT5DXJKN.js → chunk.DMENNIHT.js} +1 -1
  57. package/dist/preview/{chunk.Q4GJIJAU.js → chunk.DN7UCBOA.js} +1 -1
  58. package/dist/preview/{chunk.EJ4MSVX2.js → chunk.DQAMVVE6.js} +1 -1
  59. package/dist/preview/{chunk.75GENXGP.js → chunk.DUP2CGVH.js} +1 -1
  60. package/dist/preview/{chunk.6XHPBJ5F.js → chunk.DYRULRFX.js} +1 -1
  61. package/dist/preview/{chunk.MY5HJW2Z.js → chunk.E4TXLT25.js} +1 -1
  62. package/dist/preview/{chunk.BN7C5ZYX.js → chunk.F6BNFLQM.js} +1 -1
  63. package/dist/preview/chunk.FN34P4IS.js +1 -0
  64. package/dist/preview/{chunk.MBB5A6BT.js → chunk.FUPYIOXZ.js} +1 -1
  65. package/dist/preview/{chunk.HSMJHCR3.js → chunk.FXRYMT3U.js} +1 -1
  66. package/dist/preview/{chunk.CI4RZL4Z.js → chunk.G5BVZLCM.js} +1 -1
  67. package/dist/preview/{chunk.4TH3CGAZ.js → chunk.G7YLK4PX.js} +1 -1
  68. package/dist/preview/chunk.GF62K25C.js +1 -0
  69. package/dist/preview/chunk.GFQPO3NC.js +1 -0
  70. package/dist/preview/{chunk.YOUB3J3Y.js → chunk.GH5UBSQI.js} +1 -1
  71. package/dist/preview/{chunk.DBFJVVWF.js → chunk.GHHKRFPD.js} +1 -1
  72. package/dist/preview/{chunk.24HNOLUS.js → chunk.GP5DAA4P.js} +1 -1
  73. package/dist/preview/{chunk.DWK3GXRR.js → chunk.HPG6CNKM.js} +1 -1
  74. package/dist/preview/chunk.HSJEOM3W.js +1 -0
  75. package/dist/preview/{chunk.JVDPRQ7J.js → chunk.HZPRMHSL.js} +1 -1
  76. package/dist/preview/{chunk.Q4MI53KK.js → chunk.IQGSEAQ2.js} +5 -5
  77. package/dist/preview/{chunk.JIEDJEHK.js → chunk.ITBG37WJ.js} +1 -1
  78. package/dist/preview/{chunk.HOFATBGD.js → chunk.JHUCKEJS.js} +1 -1
  79. package/dist/preview/{chunk.Y4ZM75WL.js → chunk.JOM6MFVE.js} +1 -1
  80. package/dist/preview/{chunk.ZSGDVNVN.js → chunk.JS2UZYGB.js} +1 -1
  81. package/dist/preview/{chunk.DDFRFSVN.js → chunk.K2PXP5H6.js} +1 -1
  82. package/dist/preview/{chunk.KL5H7KEV.js → chunk.K54ISAXN.js} +1 -1
  83. package/dist/preview/{chunk.YXAKHXYB.js → chunk.K5YFUMRS.js} +1 -1
  84. package/dist/preview/chunk.KHXRJLLU.js +50 -0
  85. package/dist/preview/{chunk.E3XJMO7Q.js → chunk.KMIFSPGQ.js} +1 -1
  86. package/dist/preview/chunk.L4V5VLSM.js +1 -0
  87. package/dist/preview/{chunk.VCTAFSZ5.js → chunk.LDMBJC3B.js} +1 -1
  88. package/dist/preview/{chunk.MIE3ODQ2.js → chunk.LTOQ22ZJ.js} +1 -1
  89. package/dist/preview/{chunk.CCQMDZHO.js → chunk.M5VHUIDB.js} +1 -1
  90. package/dist/preview/chunk.N643PVQA.js +1 -0
  91. package/dist/preview/{chunk.XUO67YMT.js → chunk.NGRL3QOI.js} +1 -1
  92. package/dist/preview/{chunk.ZELWW7UA.js → chunk.NRPBTV6O.js} +2 -2
  93. package/dist/preview/{chunk.ZLTHWCKL.js → chunk.O7HHNQK4.js} +2 -2
  94. package/dist/preview/{chunk.SGPXYDSG.js → chunk.OW3M4OBN.js} +1 -1
  95. package/dist/preview/{chunk.KQPKYWDM.js → chunk.OXFDB5BB.js} +1 -1
  96. package/dist/preview/{chunk.ZZAI57VI.js → chunk.P4TAX3HE.js} +1 -1
  97. package/dist/preview/{chunk.XUXZW7DU.js → chunk.P6FNJR6E.js} +1 -1
  98. package/dist/preview/{chunk.25CQCCLN.js → chunk.PR74PGLC.js} +1 -1
  99. package/dist/preview/{chunk.AW26EETU.js → chunk.PVDDSBRG.js} +1 -1
  100. package/dist/preview/{chunk.SME4HD5I.js → chunk.QROPDEJF.js} +1 -1
  101. package/dist/preview/{chunk.AWUO3M5D.js → chunk.QRT6BZR6.js} +1 -1
  102. package/dist/preview/{chunk.AHPYNDVA.js → chunk.R5MLRKAO.js} +1 -1
  103. package/dist/preview/{chunk.NWWJNNEK.js → chunk.RDA35HZB.js} +1 -1
  104. package/dist/preview/{chunk.FXCQJPN4.js → chunk.REXU6ARY.js} +1 -1
  105. package/dist/preview/{chunk.OMRQTLI5.js → chunk.S6QZBWCJ.js} +1 -1
  106. package/dist/preview/{chunk.RUFYORIJ.js → chunk.S7SHWDPR.js} +1 -1
  107. package/dist/preview/{chunk.QAMW5QDT.js → chunk.SADHOSRC.js} +1 -1
  108. package/dist/preview/chunk.SJHUC4TL.js +1 -0
  109. package/dist/preview/chunk.SL5FXE3R.js +1 -0
  110. package/dist/preview/{chunk.WBS7ND2C.js → chunk.T4JP6BGP.js} +1 -1
  111. package/dist/preview/{chunk.34DRUCH2.js → chunk.T4TRJDBF.js} +1 -1
  112. package/dist/preview/{chunk.QS32TO4N.js → chunk.TA2JTUNX.js} +1 -1
  113. package/dist/preview/{chunk.PWAP2GJS.js → chunk.TMHVYI5R.js} +1 -1
  114. package/dist/preview/chunk.TOLW64EO.js +1 -0
  115. package/dist/preview/chunk.TP3PZRHE.js +1 -0
  116. package/dist/preview/{chunk.57YDGGJK.js → chunk.TQ2G4AM4.js} +1 -1
  117. package/dist/preview/{chunk.O3YIWIVQ.js → chunk.TUR2DA2M.js} +1 -1
  118. package/dist/preview/{chunk.CAXILB7K.js → chunk.TYIBLD2D.js} +1 -1
  119. package/dist/preview/{chunk.FFXBDOKA.js → chunk.UD2GGG7L.js} +1 -1
  120. package/dist/preview/{chunk.Q2EGESEZ.js → chunk.UDU545CL.js} +1 -1
  121. package/dist/preview/{chunk.IEDCFSN5.js → chunk.UDYFGYJP.js} +1 -1
  122. package/dist/preview/{chunk.K7TK3KRB.js → chunk.UJNLT3L6.js} +1 -1
  123. package/dist/preview/chunk.UN2IAA5R.js +1 -0
  124. package/dist/preview/chunk.VLX7YWVH.js +25 -0
  125. package/dist/preview/{chunk.735AFUP5.js → chunk.VT4YBFZL.js} +1 -1
  126. package/dist/preview/{chunk.2RASWDMQ.js → chunk.VZAF3452.js} +2 -2
  127. package/dist/preview/{chunk.OTSBF367.js → chunk.WFCE7NLK.js} +2 -2
  128. package/dist/preview/{chunk.XCWZFLIB.js → chunk.WHX47OJM.js} +1 -1
  129. package/dist/preview/{chunk.ZRH5X3MR.js → chunk.WMARJ5E3.js} +1 -1
  130. package/dist/preview/chunk.WPQP54FM.js +1 -0
  131. package/dist/preview/{chunk.HMMK7LCL.js → chunk.WX23K7ZU.js} +1 -1
  132. package/dist/preview/{chunk.H7AH3IW4.js → chunk.X36BYTEG.js} +1 -1
  133. package/dist/preview/{chunk.B46UZHGW.js → chunk.XCLW4GP7.js} +1 -1
  134. package/dist/preview/{chunk.JO3BBRSR.js → chunk.XEG7ZDRG.js} +1 -1
  135. package/dist/preview/{chunk.KPQLM4TM.js → chunk.XIVELWAM.js} +1 -1
  136. package/dist/preview/{chunk.PDS4HT46.js → chunk.XJWKIXPV.js} +1 -1
  137. package/dist/preview/{chunk.5GC4VAHU.js → chunk.XQ5RTPEF.js} +1 -1
  138. package/dist/preview/{chunk.NIAM7OTV.js → chunk.YEXFVDRA.js} +1 -1
  139. package/dist/preview/{chunk.FGDGTES4.js → chunk.YIZPW7IK.js} +2 -2
  140. package/dist/preview/chunk.YLOGIJOH.js +1 -0
  141. package/dist/preview/chunk.YMXWS4XN.js +3 -0
  142. package/dist/preview/{chunk.WYPCLZL7.js → chunk.YSBTE3PX.js} +1 -1
  143. package/dist/preview/{chunk.V4HVFLFQ.js → chunk.Z26T5E76.js} +1 -1
  144. package/dist/preview/{chunk.37FLKAVZ.js → chunk.Z4XGEV34.js} +1 -1
  145. package/dist/preview/{chunk.XYGNS637.js → chunk.ZA5TDCBC.js} +1 -1
  146. package/dist/preview/{chunk.3OQ6S6H4.js → chunk.ZNDVJGTY.js} +1 -1
  147. package/dist/preview/{chunk.YZBJUAS6.js → chunk.ZQGLPP7A.js} +1 -1
  148. package/dist/preview/index.html +53 -53
  149. package/dist/preview/page.js +2 -2
  150. package/dist/preview/splash.js +3 -3
  151. package/package.json +6 -6
  152. package/dist/preview/chunk.26H33GJC.js +0 -50
  153. package/dist/preview/chunk.3JCHJLH6.js +0 -1
  154. package/dist/preview/chunk.47QEWSSE.js +0 -1
  155. package/dist/preview/chunk.4DAKQXDG.js +0 -1
  156. package/dist/preview/chunk.6CSHRMJC.js +0 -1
  157. package/dist/preview/chunk.6HKWAHPT.js +0 -1
  158. package/dist/preview/chunk.6YK5E7ZQ.js +0 -4
  159. package/dist/preview/chunk.ATDIDPKZ.js +0 -1
  160. package/dist/preview/chunk.BF3EZCG3.js +0 -1
  161. package/dist/preview/chunk.BKQICGFW.js +0 -1
  162. package/dist/preview/chunk.C65EHQ7V.js +0 -1
  163. package/dist/preview/chunk.CYTTZOYL.js +0 -25
  164. package/dist/preview/chunk.ERPILTRY.js +0 -1
  165. package/dist/preview/chunk.FNVGNISQ.js +0 -3
  166. package/dist/preview/chunk.G2JAYG2Z.js +0 -1
  167. package/dist/preview/chunk.JNIDS66Z.js +0 -1
  168. package/dist/preview/chunk.KZUMXT5J.js +0 -74
  169. package/dist/preview/chunk.MAHNJO6U.js +0 -1
  170. package/dist/preview/chunk.MENLUNM5.js +0 -1
  171. package/dist/preview/chunk.O67JXUVG.js +0 -1
  172. package/dist/preview/chunk.QSPLKCTX.js +0 -1
  173. package/dist/preview/chunk.SJUXFPTI.js +0 -1
  174. package/dist/preview/chunk.V6IL7CIZ.js +0 -1
  175. package/dist/preview/chunk.WNS5LEO5.js +0 -1
  176. package/dist/preview/chunk.XIW4SZHD.js +0 -1
  177. package/dist/preview/chunk.Z2ZQJ3DD.js +0 -1
  178. package/dist/preview/chunk.ZP7JEVVU.js +0 -1
  179. package/dist/preview/chunk.ZVG4FXJK.js +0 -1
@@ -1,2 +1,2 @@
1
- import{a as te,b as Ke}from"./chunk.KHRS2SKB.js";import"./chunk.25CQCCLN.js";import"./chunk.T6PU3NKP.js";import"./chunk.KB5BCW23.js";import{j as qe,k as Be,l as Fe}from"./chunk.6YK5E7ZQ.js";import"./chunk.A2R53GWF.js";import"./chunk.Q2EGESEZ.js";import"./chunk.SMHP2CQH.js";import"./chunk.HJCQ6I3S.js";import"./chunk.EJ4MSVX2.js";import"./chunk.KQPKYWDM.js";import"./chunk.72YXFJKC.js";import"./chunk.OMRQTLI5.js";import{a as Oe,b as S}from"./chunk.MIE3ODQ2.js";import{a as ee,b as Ne}from"./chunk.NEPQBMFT.js";import"./chunk.MBB5A6BT.js";import"./chunk.ERPILTRY.js";import"./chunk.BIDL7GQD.js";import"./chunk.QS32TO4N.js";import"./chunk.JVDPRQ7J.js";import"./chunk.57YDGGJK.js";import{b as $e,c as We}from"./chunk.H7AH3IW4.js";import"./chunk.VCTAFSZ5.js";import"./chunk.XOZU4OFA.js";import"./chunk.4TH3CGAZ.js";import"./chunk.Q5WEOX3Q.js";import"./chunk.MAHNJO6U.js";import"./chunk.75GENXGP.js";import"./chunk.YFVJUHAK.js";import"./chunk.NIAM7OTV.js";import"./chunk.XYGNS637.js";import"./chunk.DZSZUX34.js";import"./chunk.4EXC26LI.js";import"./chunk.PWAP2GJS.js";import"./chunk.AHPYNDVA.js";import"./chunk.FNVGNISQ.js";import{v as De}from"./chunk.WUVXIUA7.js";import"./chunk.OJGHDWI6.js";import"./chunk.BN7C5ZYX.js";import"./chunk.REUMBCSV.js";import{l as Le}from"./chunk.2KIWGQXC.js";import{c as Re}from"./chunk.D5LOTCBU.js";import{j as Pe}from"./chunk.KZUMXT5J.js";import"./chunk.CGK2PY76.js";import{G as dt,Ma as Z,Ra as Ce,T as Ie,Va as ze,ba as B,h as He,u as Ee}from"./chunk.CYTTZOYL.js";import"./chunk.SDO3U72B.js";import{Mc as Ae,Ob as Se,Oc as Te,qd as Me,sa as X,ta as q}from"./chunk.Q4MI53KK.js";import"./chunk.FQLNBIQ5.js";import{b as J}from"./chunk.AJZBJBMO.js";var a=J(dt(),1);var n=J(Ie(),1);function St(u,o,r){let g=o.on??o.about[o.about.length-1];qe(u,o.about,{...r,pins:te(),...g===void 0?{}:{focus:g}})}function At({placement:u="float",chosen:o=!0}={}){let{menuAt:r}=B();return u==="menu"&&r===null?o?(0,n.jsx)(ut,{}):null:(0,n.jsx)(ct,{placement:u})}function ut(){let{store:u,setMenuAt:o,view:r}=B(),{selection:g}=Z(),h=(0,a.useRef)(null),[C,v]=(0,a.useState)(null);(0,a.useLayoutEffect)(()=>{let b=h.current?.offsetParent??h.current?.parentElement;if(!b)return;let m=Math.round(b.getBoundingClientRect().width);m!==C&&v(m)});let y=g.length===1&&!r.overview?u.graph.getNode(g[0]):void 0;return!y||C===null||C>=je?(0,n.jsx)("span",{ref:h,hidden:!0}):(0,n.jsx)("button",{type:"button",ref:h,"data-testid":"chosen-acts","aria-label":`What can be done with ${S(u,y.id)}`,"aria-haspopup":"menu",onClick:b=>{let m=b.currentTarget.getBoundingClientRect();o({x:Math.round(m.right),y:Math.round(m.bottom+4),on:y.id})},style:{position:"absolute",right:"calc(14px + var(--graview-dock, 0px))",top:98,zIndex:"var(--graview-layer-overview, 10)",minHeight:30,padding:"0 12px",borderRadius:8,fontSize:"0.8125rem",background:"var(--graview-float)",boxShadow:"var(--graview-lift-low)"},children:"Acts\u2026"})}var je=564;function ct({placement:u}){let{store:o,menuAt:r,setMenuAt:g,view:h,signIn:C}=B(),v=(0,a.useRef)(null),y=(0,a.useRef)(null),b=(0,a.useRef)(null),m=(0,a.useRef)(null);r?.returnTo&&(m.current=r.returnTo);let Ue=e=>{let i=e.closest("[data-graview-asking]")?.getAttribute("data-graview-asking"),t=e.getAttribute("data-pin-for"),l=i??e.getAttribute("data-affordance")??(t===null?null:`pin:${t}`)??e.getAttribute("data-menu-item");y.current=l===null?null:{key:l,element:e}};(0,a.useEffect)(()=>{let e=v.current,i=y.current;if(i===null||document.activeElement!==document.body||i.element.isConnected)return;let t=i.key;if(!e){y.current=null;let k=m.current;m.current=null,(k?.isConnected?k:b.current)?.focus();return}((t.startsWith("pin:")?e.querySelector(`[data-pin-for="${CSS.escape(t.slice(4))}"]`):null)??e.querySelector(`[data-affordance="${CSS.escape(t)}"]:not([disabled])`)??e).focus()});let[Ve,Ge]=(0,a.useState)(null);(0,a.useLayoutEffect)(()=>{let e=v.current?.offsetParent??v.current?.parentElement;if(e instanceof HTMLElement&&(b.current=e),!e)return;let i=e.getBoundingClientRect();Ge(t=>t&&t.left===i.left&&t.top===i.top&&t.width===i.width&&t.height===i.height?t:{left:i.left,top:i.top,width:i.width,height:i.height})});let{selection:Ye,set:Qe,clear:Je}=Z(),d=r?.about??Ye,[F,Xe]=(0,a.useState)(()=>te()),K=r?.on??d[d.length-1],_=r?.about,Ze=(0,a.useMemo)(()=>({pins:F,...K===void 0?{}:{focus:K},..._?{about:_}:{}}),[F,K,_]),et=(0,a.useMemo)(()=>new Set(o.allMutations().filter(e=>e.pinned).map(e=>e.name)),[o]),{affordances:p,withheld:ne,observations:ie}=Be(Ze),z=Te(ne,C),f=z?pt:ne,tt=r===null?null:{face:r.face??"scene",on:r.on,about:d,field:r.field,place:r.place,href:r.href,act:r.act,column:r.column,element:r.returnTo},re=De(tt),oe=ie.some(e=>e.id.startsWith("schema:waits:")),{apply:nt,preview:it}=Fe(),[P,A]=(0,a.useState)(null),[j,rt]=(0,a.useState)(null),[ot,ae]=(0,a.useState)(!1),[le,se]=(0,a.useState)(!1),[L,$]=(0,a.useState)(""),at=Ne({letters:!0}),[de,U]=(0,a.useState)(null),V=(0,a.useRef)([]),W=(e,i)=>{try{return it(e,i),nt(e,i),U(null),g(null),V.current=[],!0}catch(t){return U(Le(o.schema,o.allMutations(),t)),V.current=t instanceof Se?t.issues.map(l=>String(l.path[0]??"")).filter(Boolean):[],!1}},D=[...new Set(d.flatMap(e=>{let i=o.graph.getNode(e);return i?[i.kind]:[]}))],x=D.length>0?D:[...new Set(d.flatMap(e=>Ee(e)))],c=d.length===1?He(d[0]):null,G=c?{from:o.graph.getNode(c.from),to:o.graph.getNode(c.to)}:null,ue=c?We(o,c):void 0,ce=ue?.provisional?ue:void 0,pe=c?(()=>{let e=o.schema.tryDefinition(o.graph.getNode(c.from)?.kind??"")?.edges?.[c.kind],i=o.graph.getNode(c.to);return e?.inverse&&i?`From ${S(o,i.id)}: ${e.inverse}`:null})():null;(0,a.useEffect)(()=>{A(null),ae(!1),se(!1),U(null),$("")},[d,r?.about]);let ge=(0,a.useRef)(null);(0,a.useEffect)(()=>{let e=r?.begin;if(!e||ge.current===r)return;let i=p.find(l=>l.mutation===e.act);if(!i)return;ge.current=r;let t={...e.given};rt({id:i.id,given:t}),i.open.every(l=>l.name in t)?W({...i,args:{...i.args,...t},open:[]}):A(i.id)},[r,p]);let s=r!==null,lt=u==="menu"&&!s,T=(0,a.useRef)(r);T.current=r;let he=ze("acts",{open:s&&u==="menu",onOpenChange:e=>{e||g(null)},at:()=>T.current?{x:T.current.x,y:T.current.y}:null,returnTo:()=>{let e=T.current?.returnTo;if(e?.isConnected)return e;let i=T.current?.on;return i?document.querySelector(`[data-graview-view="${CSS.escape(i)}"]`):null},align:"start"}),me=(Ve?.width??Number.POSITIVE_INFINITY)<je;if((0,a.useLayoutEffect)(()=>{let e=v.current?.offsetParent;if(!e||!me||s)return;let i=v.current?.getBoundingClientRect().height??0,t=`${Math.round(i)+20}px`;if(e.style.paddingBottom===t)return;let l=e.style.paddingBottom;return e.style.paddingBottom=t,()=>{e.style.paddingBottom=l}}),d.length===0&&!s)return null;let fe=r?.title!==void 0||d.length>0&&!(d.length===1&&d[0]===h.focusId),ve=Math.max(1,Math.min(9,p.length)),M=[...p.filter(e=>e.provider==="invariant"&&!e.destructive),...p.filter(e=>e.pinned&&e.provider!=="invariant"&&!e.destructive),...p.filter(e=>!e.ties&&!e.destructive&&!e.pinned&&e.provider!=="invariant"),...p.filter(e=>e.ties&&!e.destructive&&!e.pinned&&e.provider!=="invariant"),...p.filter(e=>e.destructive)],ye=M.length>ve&&!s,we=L.trim().toLowerCase(),w=ye&&we.length>0?M.filter(e=>`${e.label} ${e.why}`.toLowerCase().includes(we)):null,Y=w??(ot||s?M:M.slice(0,ve)),be=w?0:M.length-Y.length,N=[];for(let e of Y){let i=!s&&e.provider==="invariant",t=!s&&!i&&e.pinned!==void 0&&!e.destructive,l=!s&&!i&&!t&&e.ties===!0&&!e.destructive,k=i?e.why:t?"pinned":l?"its ties":null,O=i?"violation":t||l?"ties":null,I=N[N.length-1];I&&I.heading===k?I.items.push(e):N.push({heading:k,tone:O,items:[e]})}let H=p.find(e=>e.id===P),Q=H&&j?.id===H.id?{...H,args:{...H.args,...j.given},open:H.open.filter(e=>!(e.name in j.given))}:H,R=d.length===1?S(o,d[0]):null,xe=e=>{if(!R)return e;let i=e.startsWith(`"${R}"`)?e.slice(R.length+2):e.startsWith(R)?e.slice(R.length):null;if(i===null)return e;let t=i.trimStart();return t.length===0?e:t[0].toUpperCase()+t.slice(1)},st=new Set(s?[]:Y.filter(e=>e.provider==="invariant").map(e=>e.why)),E=ie.filter(e=>!st.has(e.text)).map(e=>({...e,text:xe(e.text)}));return lt?null:(0,n.jsxs)("section",{...s?he.pane:{},ref:e=>{v.current=e,s&&he.pane.ref(e)},"aria-label":"Inspector","data-graview-offstage":"","data-testid":s?"context-menu":"inspector-strip",tabIndex:-1,onFocus:e=>Ue(e.target),onBlur:e=>{e.relatedTarget!==null&&(y.current=null)},onMouseDown:e=>e.stopPropagation(),style:{...s?Ce:{position:"absolute",zIndex:Me("rail")},boxSizing:"border-box",display:"flex",flexDirection:"column",gap:7,padding:"9px 12px",borderRadius:"var(--graview-radius, 12px)",border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)",...s?{width:300,maxHeight:"min(52cqh, 420px)",overflow:"auto"}:me?{left:10,right:10,width:"auto",bottom:10,maxHeight:"min(42cqh, 300px)",overflow:"auto"}:{left:14,top:h.overview?"min(296px, 38cqh)":44,width:236,maxHeight:h.overview?"calc(100cqh - min(296px, 38cqh) - 20px)":"calc(68cqh - 94px)",overflow:"auto"}},children:[(0,n.jsx)("h2",{style:{...Pe,margin:0},children:"Inspector"}),(0,n.jsxs)("div",{style:{display:fe||!s?"flex":"none",alignItems:"baseline",flexWrap:"wrap",gap:"2px 8px",minWidth:0,paddingRight:s?0:24},children:[fe?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("strong",{style:{fontSize:"0.9375rem",whiteSpace:"nowrap"},children:r?.title??(d.length===1?S(o,d[0]):`${d.length} selected`)}),D.length>0||c?(0,n.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",whiteSpace:"nowrap"},children:c?"relation":D.map(e=>q(o.schema.tryDefinition(e),e)).join(" \xB7 ")}):null,d.length===1&&!c&&r?.face!=="pages"?(0,n.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",whiteSpace:"nowrap"},children:h.expanded.includes(d[0])?"\xB7 double-click closes":"\xB7 double-click opens"}):null]}):null,(0,n.jsx)("span",{style:{flex:"1 1 auto"}})]}),s?null:(0,n.jsx)("button",{type:"button",onClick:()=>{g(null),Je()},"aria-label":"Clear selection",title:"Clear selection",style:{position:"absolute",top:6,right:6,flex:"0 0 auto",width:24,height:24,display:"grid",placeItems:"center",padding:0,fontSize:"0.875rem",lineHeight:1,borderRadius:7},children:"\xD7"}),c&&G?(0,n.jsxs)("div",{style:{display:"grid",gap:6},children:[pe?(0,n.jsx)("p",{"data-testid":"edge-said",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:pe}):null,ce?(0,n.jsx)("p",{"data-testid":"edge-provisional",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:$e(ce)}):null,(0,n.jsx)("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[["from",G.from],["to",G.to]].map(([e,i],t)=>(0,n.jsxs)(a.Fragment,{children:[t===1?(0,n.jsx)("span",{"aria-hidden":"true",style:{color:"var(--graview-ink-faint)"},children:"\u2192"}):null,i?(0,n.jsx)("button",{type:"button","data-testid":`edge-${e}`,onClick:()=>Qe([i.id]),title:`Select ${S(o,i.id)}`,style:{fontSize:"0.8125rem",padding:"3px 9px",borderRadius:6},children:S(o,i.id)}):(0,n.jsx)("span",{style:{fontSize:"0.8125rem",color:"var(--graview-ink-faint)"},children:"gone"})]},e))})]}):null,!c&&d.length===1&&Ae(o,d[0])?(0,n.jsx)("p",{"data-testid":"left-alone",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:"Left alone: nothing automated changes it."}):null,E.length>0?(0,n.jsx)("div",{"data-testid":"observations",title:E.map(e=>e.text).join(`
1
+ import{a as te,b as Ke}from"./chunk.KHRS2SKB.js";import"./chunk.PR74PGLC.js";import"./chunk.T6PU3NKP.js";import"./chunk.B6JR7EQO.js";import{j as qe,k as Be,l as Fe}from"./chunk.2D7K2IJQ.js";import"./chunk.77JI5T4F.js";import"./chunk.UDU545CL.js";import"./chunk.7VAHHEDX.js";import"./chunk.HJCQ6I3S.js";import"./chunk.DQAMVVE6.js";import"./chunk.OXFDB5BB.js";import"./chunk.DJIF7IAQ.js";import"./chunk.S6QZBWCJ.js";import{a as Oe,b as S}from"./chunk.LTOQ22ZJ.js";import{a as ee,b as Ne}from"./chunk.2TCOLAL2.js";import"./chunk.FUPYIOXZ.js";import"./chunk.3OEODIHB.js";import"./chunk.BIDL7GQD.js";import"./chunk.TA2JTUNX.js";import"./chunk.HZPRMHSL.js";import"./chunk.TQ2G4AM4.js";import{b as $e,c as We}from"./chunk.X36BYTEG.js";import"./chunk.LDMBJC3B.js";import"./chunk.XOZU4OFA.js";import"./chunk.G7YLK4PX.js";import"./chunk.Q5WEOX3Q.js";import"./chunk.2E62YCMZ.js";import"./chunk.DUP2CGVH.js";import"./chunk.YFVJUHAK.js";import"./chunk.YEXFVDRA.js";import"./chunk.ZA5TDCBC.js";import"./chunk.2JEN2RCB.js";import"./chunk.7CLKGKSF.js";import"./chunk.TMHVYI5R.js";import"./chunk.R5MLRKAO.js";import"./chunk.YMXWS4XN.js";import{v as De}from"./chunk.3SAESG6X.js";import"./chunk.OJGHDWI6.js";import"./chunk.F6BNFLQM.js";import"./chunk.75JQCTR6.js";import{l as Le}from"./chunk.5IEZF433.js";import{c as Re}from"./chunk.5AD2QHWH.js";import{k as Pe}from"./chunk.3FKKH2XU.js";import"./chunk.DLWFULWE.js";import{G as dt,Oa as Z,Ta as Ce,V as Ie,Xa as ze,da as B,h as He,u as Ee}from"./chunk.VLX7YWVH.js";import"./chunk.SDO3U72B.js";import{Mc as Ae,Ob as Se,Oc as Te,sa as X,sd as Me,ta as q}from"./chunk.IQGSEAQ2.js";import"./chunk.FQLNBIQ5.js";import{b as J}from"./chunk.AJZBJBMO.js";var a=J(dt(),1);var n=J(Ie(),1);function St(u,o,r){let g=o.on??o.about[o.about.length-1];qe(u,o.about,{...r,pins:te(),...g===void 0?{}:{focus:g}})}function At({placement:u="float",chosen:o=!0}={}){let{menuAt:r}=B();return u==="menu"&&r===null?o?(0,n.jsx)(ut,{}):null:(0,n.jsx)(ct,{placement:u})}function ut(){let{store:u,setMenuAt:o,view:r}=B(),{selection:g}=Z(),h=(0,a.useRef)(null),[C,v]=(0,a.useState)(null);(0,a.useLayoutEffect)(()=>{let b=h.current?.offsetParent??h.current?.parentElement;if(!b)return;let m=Math.round(b.getBoundingClientRect().width);m!==C&&v(m)});let y=g.length===1&&!r.overview?u.graph.getNode(g[0]):void 0;return!y||C===null||C>=je?(0,n.jsx)("span",{ref:h,hidden:!0}):(0,n.jsx)("button",{type:"button",ref:h,"data-testid":"chosen-acts","aria-label":`What can be done with ${S(u,y.id)}`,"aria-haspopup":"menu",onClick:b=>{let m=b.currentTarget.getBoundingClientRect();o({x:Math.round(m.right),y:Math.round(m.bottom+4),on:y.id})},style:{position:"absolute",right:"calc(14px + var(--graview-dock, 0px))",top:98,zIndex:"var(--graview-layer-overview, 10)",minHeight:30,padding:"0 12px",borderRadius:8,fontSize:"0.8125rem",background:"var(--graview-float)",boxShadow:"var(--graview-lift-low)"},children:"Acts\u2026"})}var je=564;function ct({placement:u}){let{store:o,menuAt:r,setMenuAt:g,view:h,signIn:C}=B(),v=(0,a.useRef)(null),y=(0,a.useRef)(null),b=(0,a.useRef)(null),m=(0,a.useRef)(null);r?.returnTo&&(m.current=r.returnTo);let Ue=e=>{let i=e.closest("[data-graview-asking]")?.getAttribute("data-graview-asking"),t=e.getAttribute("data-pin-for"),l=i??e.getAttribute("data-affordance")??(t===null?null:`pin:${t}`)??e.getAttribute("data-menu-item");y.current=l===null?null:{key:l,element:e}};(0,a.useEffect)(()=>{let e=v.current,i=y.current;if(i===null||document.activeElement!==document.body||i.element.isConnected)return;let t=i.key;if(!e){y.current=null;let k=m.current;m.current=null,(k?.isConnected?k:b.current)?.focus();return}((t.startsWith("pin:")?e.querySelector(`[data-pin-for="${CSS.escape(t.slice(4))}"]`):null)??e.querySelector(`[data-affordance="${CSS.escape(t)}"]:not([disabled])`)??e).focus()});let[Ve,Ge]=(0,a.useState)(null);(0,a.useLayoutEffect)(()=>{let e=v.current?.offsetParent??v.current?.parentElement;if(e instanceof HTMLElement&&(b.current=e),!e)return;let i=e.getBoundingClientRect();Ge(t=>t&&t.left===i.left&&t.top===i.top&&t.width===i.width&&t.height===i.height?t:{left:i.left,top:i.top,width:i.width,height:i.height})});let{selection:Ye,set:Qe,clear:Je}=Z(),d=r?.about??Ye,[F,Xe]=(0,a.useState)(()=>te()),K=r?.on??d[d.length-1],_=r?.about,Ze=(0,a.useMemo)(()=>({pins:F,...K===void 0?{}:{focus:K},..._?{about:_}:{}}),[F,K,_]),et=(0,a.useMemo)(()=>new Set(o.allMutations().filter(e=>e.pinned).map(e=>e.name)),[o]),{affordances:p,withheld:ne,observations:ie}=Be(Ze),z=Te(ne,C),f=z?pt:ne,tt=r===null?null:{face:r.face??"scene",on:r.on,about:d,field:r.field,place:r.place,href:r.href,act:r.act,column:r.column,element:r.returnTo},re=De(tt),oe=ie.some(e=>e.id.startsWith("schema:waits:")),{apply:nt,preview:it}=Fe(),[P,A]=(0,a.useState)(null),[j,rt]=(0,a.useState)(null),[ot,ae]=(0,a.useState)(!1),[le,se]=(0,a.useState)(!1),[L,$]=(0,a.useState)(""),at=Ne({letters:!0}),[de,U]=(0,a.useState)(null),V=(0,a.useRef)([]),W=(e,i)=>{try{return it(e,i),nt(e,i),U(null),g(null),V.current=[],!0}catch(t){return U(Le(o.schema,o.allMutations(),t)),V.current=t instanceof Se?t.issues.map(l=>String(l.path[0]??"")).filter(Boolean):[],!1}},D=[...new Set(d.flatMap(e=>{let i=o.graph.getNode(e);return i?[i.kind]:[]}))],x=D.length>0?D:[...new Set(d.flatMap(e=>Ee(e)))],c=d.length===1?He(d[0]):null,G=c?{from:o.graph.getNode(c.from),to:o.graph.getNode(c.to)}:null,ue=c?We(o,c):void 0,ce=ue?.provisional?ue:void 0,pe=c?(()=>{let e=o.schema.tryDefinition(o.graph.getNode(c.from)?.kind??"")?.edges?.[c.kind],i=o.graph.getNode(c.to);return e?.inverse&&i?`From ${S(o,i.id)}: ${e.inverse}`:null})():null;(0,a.useEffect)(()=>{A(null),ae(!1),se(!1),U(null),$("")},[d,r?.about]);let ge=(0,a.useRef)(null);(0,a.useEffect)(()=>{let e=r?.begin;if(!e||ge.current===r)return;let i=p.find(l=>l.mutation===e.act);if(!i)return;ge.current=r;let t={...e.given};rt({id:i.id,given:t}),i.open.every(l=>l.name in t)?W({...i,args:{...i.args,...t},open:[]}):A(i.id)},[r,p]);let s=r!==null,lt=u==="menu"&&!s,T=(0,a.useRef)(r);T.current=r;let he=ze("acts",{open:s&&u==="menu",onOpenChange:e=>{e||g(null)},at:()=>T.current?{x:T.current.x,y:T.current.y}:null,returnTo:()=>{let e=T.current?.returnTo;if(e?.isConnected)return e;let i=T.current?.on;return i?document.querySelector(`[data-graview-view="${CSS.escape(i)}"]`):null},align:"start"}),me=(Ve?.width??Number.POSITIVE_INFINITY)<je;if((0,a.useLayoutEffect)(()=>{let e=v.current?.offsetParent;if(!e||!me||s)return;let i=v.current?.getBoundingClientRect().height??0,t=`${Math.round(i)+20}px`;if(e.style.paddingBottom===t)return;let l=e.style.paddingBottom;return e.style.paddingBottom=t,()=>{e.style.paddingBottom=l}}),d.length===0&&!s)return null;let fe=r?.title!==void 0||d.length>0&&!(d.length===1&&d[0]===h.focusId),ve=Math.max(1,Math.min(9,p.length)),M=[...p.filter(e=>e.provider==="invariant"&&!e.destructive),...p.filter(e=>e.pinned&&e.provider!=="invariant"&&!e.destructive),...p.filter(e=>!e.ties&&!e.destructive&&!e.pinned&&e.provider!=="invariant"),...p.filter(e=>e.ties&&!e.destructive&&!e.pinned&&e.provider!=="invariant"),...p.filter(e=>e.destructive)],ye=M.length>ve&&!s,we=L.trim().toLowerCase(),w=ye&&we.length>0?M.filter(e=>`${e.label} ${e.why}`.toLowerCase().includes(we)):null,Y=w??(ot||s?M:M.slice(0,ve)),be=w?0:M.length-Y.length,N=[];for(let e of Y){let i=!s&&e.provider==="invariant",t=!s&&!i&&e.pinned!==void 0&&!e.destructive,l=!s&&!i&&!t&&e.ties===!0&&!e.destructive,k=i?e.why:t?"pinned":l?"its ties":null,O=i?"violation":t||l?"ties":null,I=N[N.length-1];I&&I.heading===k?I.items.push(e):N.push({heading:k,tone:O,items:[e]})}let H=p.find(e=>e.id===P),Q=H&&j?.id===H.id?{...H,args:{...H.args,...j.given},open:H.open.filter(e=>!(e.name in j.given))}:H,R=d.length===1?S(o,d[0]):null,xe=e=>{if(!R)return e;let i=e.startsWith(`"${R}"`)?e.slice(R.length+2):e.startsWith(R)?e.slice(R.length):null;if(i===null)return e;let t=i.trimStart();return t.length===0?e:t[0].toUpperCase()+t.slice(1)},st=new Set(s?[]:Y.filter(e=>e.provider==="invariant").map(e=>e.why)),E=ie.filter(e=>!st.has(e.text)).map(e=>({...e,text:xe(e.text)}));return lt?null:(0,n.jsxs)("section",{...s?he.pane:{},ref:e=>{v.current=e,s&&he.pane.ref(e)},"aria-label":"Inspector","data-graview-offstage":"","data-testid":s?"context-menu":"inspector-strip",tabIndex:-1,onFocus:e=>Ue(e.target),onBlur:e=>{e.relatedTarget!==null&&(y.current=null)},onMouseDown:e=>e.stopPropagation(),style:{...s?Ce:{position:"absolute",zIndex:Me("rail")},boxSizing:"border-box",display:"flex",flexDirection:"column",gap:7,padding:"9px 12px",borderRadius:"var(--graview-radius, 12px)",border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)",...s?{width:300,maxHeight:"min(52cqh, 420px)",overflow:"auto"}:me?{left:10,right:10,width:"auto",bottom:10,maxHeight:"min(42cqh, 300px)",overflow:"auto"}:{left:14,top:h.overview?"min(296px, 38cqh)":44,width:236,maxHeight:h.overview?"calc(100cqh - min(296px, 38cqh) - 20px)":"calc(68cqh - 94px)",overflow:"auto"}},children:[(0,n.jsx)("h2",{style:{...Pe,margin:0},children:"Inspector"}),(0,n.jsxs)("div",{style:{display:fe||!s?"flex":"none",alignItems:"baseline",flexWrap:"wrap",gap:"2px 8px",minWidth:0,paddingRight:s?0:24},children:[fe?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("strong",{style:{fontSize:"0.9375rem",whiteSpace:"nowrap"},children:r?.title??(d.length===1?S(o,d[0]):`${d.length} selected`)}),D.length>0||c?(0,n.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",whiteSpace:"nowrap"},children:c?"relation":D.map(e=>q(o.schema.tryDefinition(e),e)).join(" \xB7 ")}):null,d.length===1&&!c&&r?.face!=="pages"?(0,n.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",whiteSpace:"nowrap"},children:h.expanded.includes(d[0])?"\xB7 double-click closes":"\xB7 double-click opens"}):null]}):null,(0,n.jsx)("span",{style:{flex:"1 1 auto"}})]}),s?null:(0,n.jsx)("button",{type:"button",onClick:()=>{g(null),Je()},"aria-label":"Clear selection",title:"Clear selection",style:{position:"absolute",top:6,right:6,flex:"0 0 auto",width:24,height:24,display:"grid",placeItems:"center",padding:0,fontSize:"0.875rem",lineHeight:1,borderRadius:7},children:"\xD7"}),c&&G?(0,n.jsxs)("div",{style:{display:"grid",gap:6},children:[pe?(0,n.jsx)("p",{"data-testid":"edge-said",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:pe}):null,ce?(0,n.jsx)("p",{"data-testid":"edge-provisional",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:$e(ce)}):null,(0,n.jsx)("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[["from",G.from],["to",G.to]].map(([e,i],t)=>(0,n.jsxs)(a.Fragment,{children:[t===1?(0,n.jsx)("span",{"aria-hidden":"true",style:{color:"var(--graview-ink-faint)"},children:"\u2192"}):null,i?(0,n.jsx)("button",{type:"button","data-testid":`edge-${e}`,onClick:()=>Qe([i.id]),title:`Select ${S(o,i.id)}`,style:{fontSize:"0.8125rem",padding:"3px 9px",borderRadius:6},children:S(o,i.id)}):(0,n.jsx)("span",{style:{fontSize:"0.8125rem",color:"var(--graview-ink-faint)"},children:"gone"})]},e))})]}):null,!c&&d.length===1&&Ae(o,d[0])?(0,n.jsx)("p",{"data-testid":"left-alone",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:"Left alone: nothing automated changes it."}):null,E.length>0?(0,n.jsx)("div",{"data-testid":"observations",title:E.map(e=>e.text).join(`
2
2
  `),style:{display:"grid",gap:3},children:E.slice(0,2).map(e=>(0,n.jsxs)("p",{style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:[e.text,e===E[1]&&E.length>2?(0,n.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" +",E.length-2]}):null]},e.id))}):null,s?re.start.map(e=>(0,n.jsx)(_e,{section:e,close:()=>g(null)},e.id)):null,de?(0,n.jsx)("p",{"data-testid":"refused",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-warn)"},children:de}):null,ye?(0,n.jsx)("input",{"data-testid":"action-filter",value:L,onChange:e=>$(e.target.value),placeholder:`Filter ${M.length} actions\u2026`,"aria-label":"Filter actions",onKeyDown:e=>{if(e.key==="Escape"){e.stopPropagation(),L.length>0?$(""):e.currentTarget.blur();return}if(e.key==="Enter"&&w?.length===1){let i=w[0];if(i.destructive)return;i.open.length>0?A(i.id):W(i)&&$("")}},style:{font:"inherit",fontSize:"0.875rem",padding:"5px 9px",borderRadius:8,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",color:"var(--graview-ink)"}}):null,w!==null&&w.length===0?(0,n.jsxs)("p",{"data-testid":"no-matches",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:["Nothing offered here matches \u201C",L.trim(),"\u201D."]}):null,z&&p.length===0||p.length===0&&!oe&&d.length===0?null:p.length===0&&!oe?(0,n.jsx)("p",{"data-testid":"no-affordances",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:f.length>0?`Nothing you may do with ${c?"this relation":x.length===1?X(q(o.schema.tryDefinition(x[0]),x[0])):"this mix of kinds"} \u2014 ${f.length} action${f.length===1?"":"s"} withheld.`:c?`Nothing can be done with this line yet \u2014 nothing this app declares makes or breaks \u201C${Re(o.schema,o.graph.getNode(c.from)?.kind??"",c.kind,"out")}\u201D.`:`Nothing can be done with ${x.length===1?X(q(o.schema.tryDefinition(x[0]),x[0])):"this mix of kinds"} yet \u2014 nothing this app declares acts on ${x.length===1?"it":"them"}.`}):(0,n.jsxs)("ol",{...at,"data-testid":"affordances",style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",flexWrap:"nowrap",gap:2},children:[N.map((e,i)=>(0,n.jsxs)(a.Fragment,{children:[e.heading?(0,n.jsxs)("li",{"data-graview-heading":e.tone,style:{fontSize:"0.75rem",lineHeight:1.4,color:e.tone==="violation"?"var(--graview-warn)":"var(--graview-ink-faint)",...e.tone!=="violation"?{letterSpacing:"0.12em",textTransform:"uppercase",fontSize:"0.75rem"}:{},padding:"2px 2px 1px",marginTop:i>0?6:0},children:[e.tone==="violation"?"\u26A0 ":"",e.tone==="violation"?xe(e.heading):e.heading]}):i>0?(0,n.jsx)("li",{"aria-hidden":"true",style:{borderTop:"1px solid var(--graview-edge)",margin:"6px 0 3px"}}):null,e.items.map(t=>(0,n.jsxs)("li",{style:{display:"flex",gap:2,alignItems:"stretch"},onKeyDown:l=>{if(l.metaKey||l.ctrlKey||l.altKey)return;let k=l.currentTarget.querySelector("[data-affordance]"),O=l.currentTarget.querySelector("[data-pin-for]"),I=l.target===O,ke=l.key==="ArrowRight"&&!I?O:I&&["ArrowLeft","ArrowUp","ArrowDown"].includes(l.key)?k:null;ke&&(l.preventDefault(),l.stopPropagation(),ke.focus())},children:[(0,n.jsxs)("button",{type:"button",[ee]:"","data-affordance":t.id,"data-rank":t.rank,"data-graview-destructive":t.destructive||void 0,"aria-pressed":P===t.id,title:t.why,style:{padding:"5px 10px",fontSize:"0.875rem",borderRadius:8,width:"100%",textAlign:"left",borderWidth:1,borderStyle:"solid",borderColor:P===t.id?"var(--graview-accent)":s?"transparent":"var(--graview-edge)",background:s?"none":"var(--graview-panel)",boxShadow:"none",...t.destructive?{color:"var(--graview-warn)"}:{},...P===t.id?{color:"var(--graview-accent)"}:{}},onClick:()=>{if(t.open.length>0){A(P===t.id?null:t.id);return}W(t)},children:[t.label,t.open.length>0?(0,n.jsx)("span",{style:{color:"var(--graview-ink-faint)"},children:" \u2026"}):null,w?.length===1&&w[0]?.id===t.id&&!t.destructive?(0,n.jsx)("span",{"aria-hidden":"true",title:"Enter runs it",style:{float:"right",color:"var(--graview-ink-faint)",fontSize:"0.75rem"},children:"\u21B5"}):null]}),(0,n.jsx)("button",{type:"button","data-testid":"pin-toggle",tabIndex:-1,"data-pin-for":t.mutation,"aria-pressed":t.pinned!==void 0,"aria-label":t.pinned!==void 0?`Unpin ${t.label}`:`Pin ${t.label}`,title:t.pinned==="declared"?"Pinned by the app \u2014 unpin it for yourself":t.pinned==="user"?"Unpin":"Pin to the top",onClick:()=>Xe(Ke(F,t.mutation,et.has(t.mutation))),style:{flex:"0 0 auto",width:24,minHeight:24,display:"grid",placeItems:"center",padding:0,fontSize:"0.75rem",border:"1px solid transparent",background:"none",boxShadow:"none",borderRadius:7,color:t.pinned==="user"?"var(--graview-accent)":t.pinned==="declared"?"var(--graview-ink-muted)":"var(--graview-ink-faint)"},children:t.pinned!==void 0?"\u2605":"\u2606"})]},t.id))]},`${e.heading??"plain"}-${i}`)),be>0?(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button",[ee]:"",onClick:()=>ae(!0),title:`Show all ${p.length} actions`,style:{padding:"4px 10px",fontSize:"0.875rem",borderRadius:8},children:["Show ",be," more"]})}):null]}),z?(0,n.jsx)("button",{type:"button","data-testid":"sign-in",onClick:()=>{g(null),z.run()},style:{padding:"5px 10px",fontSize:"0.875rem",borderRadius:8,width:"100%",textAlign:"left"},children:z.label}):null,f.length>0?(0,n.jsxs)("ul",{"data-testid":"withheld",style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",flexWrap:"nowrap",gap:2},children:[f.slice(0,s||le?f.length:3).map(e=>(0,n.jsxs)("li",{style:{display:"grid",gap:2},children:[(0,n.jsx)("button",{type:"button",disabled:!0,"data-affordance":e.id,"data-rank":e.rank,"data-withheld":e.refusal.wouldNeed.join(",")||"nobody",style:{padding:"4px 10px",fontSize:"0.875rem",borderRadius:8,borderStyle:"dashed",width:"100%",textAlign:"left",background:"none"},children:(0,n.jsx)("s",{children:e.label})}),(0,n.jsx)("span",{"data-testid":"withheld-why",style:{fontSize:"0.8125rem",lineHeight:1.4,color:"var(--graview-ink-muted)",padding:"0 10px"},children:e.refusal.message})]},e.id)),!s&&!le&&f.length>3?(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button","data-testid":"withheld-more",onClick:()=>se(!0),title:`Show all ${f.length} actions this seat may not take`,style:{padding:"4px 10px",fontSize:"0.875rem",borderRadius:8},children:["Show ",f.length-3," more withheld"]})}):null]}):null,s?re.end.map(e=>(0,n.jsx)(_e,{section:e,close:()=>g(null)},e.id)):null,Q?(0,n.jsx)(Oe,{affordance:Q,onApply:e=>{if(W(Q,e))A(null);else return V.current},onCancel:()=>A(null)}):null]})}var pt=[];function _e({section:u,close:o}){return(0,n.jsxs)("div",{"data-menu-section":u.id,...u.heading?{role:"group","aria-label":u.heading}:{},style:{display:"grid",gap:2,borderTop:"1px solid var(--graview-edge)",paddingTop:5},children:[u.heading?(0,n.jsx)("p",{"aria-hidden":"true",style:{margin:0,padding:"2px 2px 1px",fontSize:"0.75rem",lineHeight:1.4,letterSpacing:"0.12em",textTransform:"uppercase",color:"var(--graview-ink-faint)"},children:u.heading}):null,u.items&&u.items.length>0?(0,n.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:2},children:u.items.map(r=>(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button","data-menu-item":r.id,onClick:()=>{o(),r.run()},style:{padding:"5px 10px",fontSize:"0.875rem",borderRadius:8,width:"100%",textAlign:"left",borderWidth:1,borderStyle:"solid",borderColor:"transparent",background:"none",boxShadow:"none"},children:[r.label,r.hint?(0,n.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",r.hint]}):null]})},r.id))}):null,u.render?.(o)]})}export{At as InspectorPane,St as prepareActs};
@@ -1,4 +1,4 @@
1
- import{a as k}from"./chunk.G4JJXA63.js";import{a as Q}from"./chunk.JVDPRQ7J.js";import{a as Z}from"./chunk.VCTAFSZ5.js";import{a as Y}from"./chunk.DZSZUX34.js";import{c as V}from"./chunk.AHPYNDVA.js";import{_d as P,ae as H,be as T,ce as U,xb as z,yb as B}from"./chunk.Q4MI53KK.js";var N=n=>"failed"in n;function fn(n,e){let s=n.schema.kinds,t=n.policy?.sees;if(!t?.length||B(e))return{kinds:s};let o=z(e).roles??[],r=new Set(t.filter(i=>i.roles==="*"||o.some(a=>i.roles.includes(a))).flatMap(i=>i.kinds));return{kinds:s.filter(i=>r.has(i))}}function O(n,e){if(!e)return n;let s=new Set(e.kinds.filter(r=>n.tryDefinition(r)!==void 0));if(s.size===n.kinds.length)return n;let t=new Map,o=r=>{if(s.has(r)){if(!t.has(r)){let i=n.tryDefinition(r),a=Object.fromEntries(Object.entries(i?.edges??{}).flatMap(([l,d])=>{if(d.to==="*")return[[l,d]];let c=d.to.filter(u=>s.has(u));return c.length>0?[[l,{...d,to:c}]]:[]}));t.set(r,{...i,edges:a})}return t.get(r)}};return{...n,definitions:n.definitions.filter(r=>s.has(r.kind)),kinds:n.kinds.filter(r=>s.has(r)),tryDefinition:o,definition:r=>{let i=o(r);if(!i)throw new Error(`Unknown node kind "${r}"`);return i}}}var gn=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),m=n=>gn(n).replace(/[-_]+/g," ").trim();function j(n){let e=[];for(let t of n.kinds){let o=n.tryDefinition(t);if(!o)continue;let r=o.display?.labels??{},i=Object.entries(o.fields?.shape??{}).filter(([d])=>d!=="id"&&d!=="kind").map(([d,c])=>{let u=Y(c);return{name:d,type:u?.type==="enum"&&u.multiple?"list":u?.type,...u?.options?{options:u.options}:{},words:(r[d]??m(d)).toLowerCase()}}),a=Object.entries(o.edges??{}).map(([d,c])=>({name:d,from:t,to:c.to==="*"?n.kinds.filter(u=>u!==t):c.to,words:m(d)})),l=(o.plural??`${m(t)}s`).toLowerCase();e.push({kind:t,plural:l,noun:(o.noun??m(t)).toLowerCase(),fields:i,roles:o.fieldRoles??{},edges:a})}let s=new Map(e.map(t=>[t.kind,t]));return{schema:n,kinds:e,info:t=>s.get(t)}}var $=(n,e)=>e===void 0?void 0:n.fields.find(s=>s.name===e),R=n=>n?.type==="date"||n?.type==="datetime",K=n=>n?.type==="number"||n?.type==="integer"||n?.type==="duration",sn=n=>` ${n.toLowerCase().replace(/[“”"’‘]/g,"'").replace(/[^\p{L}\p{N}' -]+/gu," ").replace(/\s+/g," ").trim()} `,A=(n,e)=>n.includes(` ${e} `),L=n=>n.endsWith("ies")?`${n.slice(0,-3)}y`:n.endsWith("ses")?n.slice(0,-2):n.endsWith("s")?n.slice(0,-1):n;function yn(n,e){let s=[];for(let t of e.kinds){let o=new Set([t.plural,t.noun,`${t.noun}s`,m(t.kind),`${m(t.kind)}s`]),r=-1;for(let i of o){let a=n.indexOf(` ${i} `);a>=0&&(r<0||a<r)&&(r=a)}r>=0&&s.push({info:t,at:r})}return s.sort((t,o)=>t.at-o.at).map(t=>t.info)}function I(n,e,s){let t=e.trim().toLowerCase();if(t.length===0)return;let o=n.fields.filter(r=>!s||s(r));return o.find(r=>r.words===t||m(r.name)===t||r.name.toLowerCase()===t)??o.find(r=>r.words===L(t)||m(r.name)===L(t))??o.find(r=>t.split(" ").some(i=>i.length>2&&(r.words.split(" ").includes(i)||r.words.split(" ").includes(L(i)))))}function rn(n,e,s){let t=e.trim().toLowerCase();if(t.length!==0)return n.edges.find(o=>o.words===t||o.name.toLowerCase()===t)??n.edges.find(o=>o.to.some(r=>{let i=s.info(r);return i!==void 0&&(i.noun===L(t)||i.plural===t||m(r)===L(t))}))??n.edges.find(o=>t.split(" ").some(r=>r.length>2&&o.words.split(" ").includes(r)))}function W(n){return/ (?:grouped |group |split |sorted |organi[sz]ed )?by ([\p{L}\p{N}' -]+?)(?= (?:and|with|for|in|on|only|where|from|this|that|as|sorted|grouped) |\s*$)/u.exec(n)?.[1]?.trim()}var bn=/\bwho\b.*\b(covers?|cover|tends?|owns?|handles?|does|works? on|looks? after|is on|is assigned|staffs?|runs?)\b|\bcoverage\b|\bmatrix\b|\bwho covers\b/,mn=/\bcalendar\b|\bmonth\b|\bagenda\b|\bschedule\b|\bdue\b|\bdeadlines?\b|\bdates?\b|\bwhen\b/,hn=/\btimeline\b|\bover time\b|\bgantt\b|\bspans?\b|\bweek\b/,pn=/\bboard\b|\bkanban\b|\bcolumns?\b|\bpipeline\b|\bstages?\b|\bstatus\b/,wn=/\blaid out\b|\blayout\b|\bseating\b|\bwhere (?:they|it|each) (?:sits?|lies?|stands?)\b|\bfloor\b/,kn=/\bplan\b|\bmap\b|\bregions?\b/,$n=/\blist\b|\btable\b|\bgroup(?:ed)? by\b|\bsort(?:ed)? by\b|\bonly\b|\bjust the\b/;function Sn(n){let e=[];return/\blist\b|\btable\b/.test(n)&&e.push("blocks"),bn.test(n)&&e.push("coverage"),wn.test(n)&&e.push("board"),(/\bfloor plan\b/.test(n)||kn.test(n))&&e.push("plan"),hn.test(n)&&e.push("timeline"),mn.test(n)&&e.push("calendar"),pn.test(n)&&e.push("columns"),$n.test(n)&&!e.includes("blocks")&&e.push("blocks"),e.length===0&&W(n)&&e.push("columns"),e}var on=n=>{let e=s=>s?` and not ${s}`:"";if(/\boverdue\b|\blate\b|\bpast due\b/.test(n))return{cond:(s,t)=>`days(today(), ${s}) < 0${e(t)}`,says:s=>`overdue by ${s.words}`};if(/\btoday\b/.test(n))return{range:"day",cond:s=>`days(today(), ${s}) == 0`,says:s=>`with ${s.words} today`};if(/\bthis week\b|\bnext 7 days\b|\bnext week\b/.test(n))return{range:"week",cond:s=>`days(today(), ${s}) >= 0 and days(today(), ${s}) <= 6`,says:s=>`with ${s.words} in the next week`};if(/\bthis month\b|\bnext 30 days\b|\bnext month\b/.test(n))return{range:"month",cond:s=>`days(today(), ${s}) >= 0 and days(today(), ${s}) <= 30`,says:s=>`with ${s.words} in the next month`};if(/\blast month\b|\bpast month\b/.test(n))return{range:"month",cond:s=>`days(today(), ${s}) >= -30 and days(today(), ${s}) <= 0`,says:s=>`with ${s.words} in the last month`};if(/\bthis year\b/.test(n))return{range:"year",cond:s=>`days(today(), ${s}) >= 0 and days(today(), ${s}) <= 365`,says:s=>`with ${s.words} in the next year`};if(/\bquarter\b/.test(n))return{range:"quarter",cond:s=>`days(today(), ${s}) >= 0 and days(today(), ${s}) <= 91`,says:s=>`with ${s.words} in the next quarter`}},_=n=>{if(/\bagenda\b|\bin order\b/.test(n))return"agenda";if(/\btoday\b|\bday\b/.test(n))return"day";if(/\bweek\b/.test(n))return"week";if(/\bquarter\b/.test(n))return"quarter";if(/\byears\b/.test(n))return"years";if(/\byear\b/.test(n))return"year";if(/\bmonth\b/.test(n))return"month"},X=/^(user|person|people|member|staff|gardener|volunteer|owner|agent|employee|worker|team|player|customer|client|contact|party|attendee|guest)s?$/,x=class extends Error{},h=n=>{throw new x(n)};function Dn(n,e){let s=n.fields.filter(r=>r.type==="enum");if(e){let r=I(n,e);if(r&&r.type==="enum")return r;r&&h(`${n.plural}' ${r.words} is not a choice, so it has no columns`)}let t=$(n,n.roles.status??n.roles.column);if(t?.type==="enum")return t;let o=s.find(r=>/^(status|stage|state|phase)$/.test(r.name));return o||(s[0]?s[0]:h(`${n.plural} have no choice field to put in columns`))}function nn(n,e){let s=n.fields.filter(R),t=l=>{let d=$(n,n.roles[l]);return R(d)?d:void 0},r=s.find(l=>A(e,l.words)||A(e,m(l.name)))??t("start")??s.find(l=>/^(due|date|on|at|start|starts|begins|from|sown|when)/i.test(l.name))??s[0];if(!r)return h(`no date field on ${n.plural}`);let i=t("end")??s.find(l=>l!==r&&/^(end|ends|until|to|finish|finished|harvested|due|closes|through)/i.test(l.name)),a=n.fields.find(l=>l.type==="boolean"&&/^(done|finished|complete|completed|closed)$/.test(l.name));return{start:r,...i&&i!==r?{end:i}:{},...a?{done:a}:{}}}function an(n){let e=$(n,n.roles.start),s=$(n,n.roles.end),t=$(n,n.roles.column??n.roles.day??n.roles.columns);if(K(e)&&K(s)&&t?.type==="enum")return{start:e,end:s,column:t}}function vn(n,e,s,t){let o=[];for(let i of n.kinds)for(let a of i.edges)for(let l of a.to){let d=n.info(l);if(!d||d.kind===i.kind)continue;let c=0;e.includes(i)&&(c+=4),e.includes(d)&&(c+=4),(X.test(d.kind)||X.test(d.noun))&&(c+=3),t&&(a.words.includes(t)||d.noun===L(t))&&(c+=5),a.words.split(" ").some(u=>u.length>2&&s.includes(` ${u}`))&&(c+=2),o.push({rows:i,across:d,link:a,score:c})}let r=o.sort((i,a)=>a.score-i.score)[0];return r||h(e[0]?`${e[0].plural} are joined to nothing else, so there is no who-covers-what to draw`:"nothing here is joined to anything else, so there is no who-covers-what to draw")}function dn(n,e,s,t,o){let r=W(t);switch(n){case"columns":{if(r){let i=I(e,r);if(!i||i.type!=="enum"){let a=rn(e,r,s);if(a){let l=s.info(a.to[0]);return{lens:"coverage",kind:e.kind,across:l.kind,link:a.name}}}}return{lens:"columns",kind:e.kind,column:Dn(e,r).name}}case"calendar":{let i=nn(e,t),a=_(t);return{lens:"calendar",kind:e.kind,start:i.start.name,...i.end?{end:i.end.name}:{},...i.done?{done:i.done.name}:{},...a?{range:a}:{}}}case"timeline":{let i=an(e);if(i&&!/\bdates?\b|\bdue\b|\bdeadlines?\b|\bmonths?\b|\byears?\b/.test(t))return{lens:"timeline",kind:e.kind,start:i.start.name,end:i.end.name,column:i.column.name};let a=nn(e,t);return{lens:"calendar",kind:e.kind,start:a.start.name,...a.end?{end:a.end.name}:{},...a.done?{done:a.done.name}:{},range:_(t)??"quarter"}}case"coverage":{let i=vn(s,o,t,r);return{lens:"coverage",kind:i.rows.kind,across:i.across.kind,link:i.link.name}}case"board":{let i=$(e,e.roles.x)??e.fields.find(c=>c.name==="x"),a=$(e,e.roles.y)??e.fields.find(c=>c.name==="y");if(!K(i)||!K(a))return h(`${e.plural} have no x and y to be laid out by`);let d=s.kinds.flatMap(c=>c.edges.filter(u=>u.to.includes(e.kind)&&c.kind!==e.kind))[0]??e.edges[0];return d?{lens:"board",kind:e.kind,x:i.name,y:a.name,fill:d.name,...d.from!==e.kind?{fillFrom:"occupant"}:{}}:h(`nothing is joined to ${e.plural} to fill them`)}case"plan":{let i=$(e,e.roles.outline)??e.fields.find(a=>a.name==="outline");return i?{lens:"plan",kind:e.kind,outline:i.name}:h(`${e.plural} have no outline to draw a plan from`)}case"blocks":{let i={lens:"blocks",kind:e.kind,as:/\bcards?\b/.test(t)?"card":"row"},a=/ group(?:ed)? by ([\p{L}\p{N} -]+?)(?= (?:and|only|sorted|with)|\s*$)/u.exec(t)?.[1]??(r&&!/ sort(?:ed)? by /.test(t)?r:void 0);if(a){let c=I(e,a);if(!c||c.type!=="enum")return h(c?`${e.plural}' ${c.words} is not a choice, so they cannot be grouped by it`:`${e.plural} have nothing called ${a} to group by`);i.group=c.name}let l=/ sort(?:ed)? by ([\p{L}\p{N} -]+?)(?= (?:and|only|grouped|with)|\s*$)/u.exec(t)?.[1];if(l){let c=I(e,l);if(!c)return h(`${e.plural} have nothing called ${l} to sort by`);i.sort={by:c.name,.../\b(newest|latest|desc|descending|most)\b/.test(t)?{direction:"desc"}:{}}}let d=q(e,t);return d.length>0&&(i.where=d),i}}}function q(n,e){let s=[],t=on(e);if(t){let o=n.fields.filter(R),r=$(n,n.roles.start),i=o.find(l=>A(e,l.words))??(R(r)?r:void 0)??o[0];(!i||!R(i))&&h(`no date field on ${n.plural}`);let a=n.fields.find(l=>l.type==="boolean"&&/^(done|finished|complete|completed|closed)$/.test(l.name));s.push({expr:t.cond(i.name,/\boverdue\b|\blate\b|\bpast due\b/.test(e)?a?.name:void 0),says:t.says(i)})}if(/\bonly\b|\bjust\b|\bthat are\b|\bwhich are\b/.test(e)){for(let o of n.fields){if(o.type!=="enum")continue;let r=o.options?.find(i=>A(e,i.toLowerCase())||A(e,m(i)));r&&s.push({expr:`${o.name} == '${r.replace(/'/g,"")}'`,says:`that are ${m(r)}`})}if(/\bnot done\b|\bundone\b|\bunfinished\b|\bopen ones\b|\bstill to do\b/.test(e)){let o=n.fields.find(r=>r.type==="boolean"&&/^(done|finished|complete|completed)$/.test(r.name));o&&s.push({expr:`not ${o.name}`,says:`not ${o.words}`})}}return s}var J={columns:"A board",calendar:"A calendar",timeline:"A timeline",coverage:"A grid",board:"A layout",plan:"A plan",blocks:"A list",reach:"A picture"};function Rn(n,e){let s=e.info(n.kind),t=o=>o?$(s,o)?.words??m(o):"";switch(n.lens){case"columns":return{title:`${k(s.plural)} by ${t(n.column)}`,detail:`of ${s.plural} by ${t(n.column)}`};case"calendar":{let o=n.range??"month";if(o==="agenda")return{title:`${k(s.plural)} in date order`,detail:`of ${s.plural} in order of ${t(n.start)}`};let r=o==="years"?"year":o;return{title:`${k(s.plural)} by ${r}`,detail:`of ${s.plural} by ${t(n.start)}, a ${r} at a time`}}case"timeline":return{title:`${k(s.plural)} over the ${t(n.column)}`,detail:`of ${s.plural} from ${t(n.start)} to ${t(n.end)}, by ${t(n.column)}`};case"coverage":{let o=e.info(n.across);return{title:`${k(s.plural)} by ${o.noun}`,detail:`of which ${o.noun} covers which ${s.noun}`}}case"board":return{title:`${k(s.plural)} where they stand`,detail:`of ${s.plural} where they stand`};case"plan":return{title:`${k(s.plural)} on a plan`,detail:`of ${s.plural}`};default:{let o=[n.where?.map(r=>r.says).join(" and "),n.group?`by ${t(n.group)}`:void 0,n.sort?`in order of ${t(n.sort.by)}`:void 0].filter(r=>!!r);return{title:[k(s.plural),...o].join(" "),detail:[`of ${s.plural}`,...o].join(" ")}}}}function An(n,e){let s={title:e,on:n.kind};switch(n.lens){case"columns":return{name:"columns",...s,bindings:{[n.kind]:{column:n.column}}};case"calendar":return{name:"calendar",...s,bindings:{[n.kind]:{start:n.start,...n.end?{end:n.end}:{},...n.done?{done:n.done}:{}}},...n.range?{options:{range:n.range}}:{}};case"timeline":return{name:"timeline",...s,bindings:{[n.kind]:{start:n.start,end:n.end,column:n.column}}};case"coverage":return{name:"coverage",...s,bindings:{rows:{kind:n.kind},columns:{kind:n.across},link:{edge:n.link}}};case"board":return{name:"board",...s,bindings:{slots:{kind:n.kind},x:{field:n.x,on:"slots"},y:{field:n.y,on:"slots"},fill:{edge:n.fill}},...n.fillFrom?{options:{fillFrom:n.fillFrom}}:{}};case"plan":return{name:"plan",...s,bindings:{regions:{kind:n.kind},outline:{field:n.outline,on:"regions"}}};default:{let t=n.where?.length?` where ${n.where.map(r=>n.where.length>1?`(${r.expr})`:r.expr).join(" and ")}`:"",o={list:`all('${n.kind}')${t}`,as:n.as??"row"};return n.group&&(o.group=n.group),n.sort&&(o.sort=n.sort.direction?{by:n.sort.by,direction:n.sort.direction}:n.sort.by),o.empty="Nothing here yet.",{name:"blocks",...s,options:{blocks:[o]}}}}}function F(n,e){let{app:s}=e,t=r=>r.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,""),o=new Set(["home","overview",...Q(s,e.views?{views:e.views}:{}).map(r=>r.slug),...(s.lenses??[]).flatMap(r=>r.title?[t(r.title)]:[])]);if(!o.has(t(n)))return n;for(let r=2;;r++)if(!o.has(t(`${n} ${r}`)))return`${n} ${r}`}var en={title:[],headline:[],text:["tone"],figure:["as","currency","label"],list:["sort","limit","group","empty","as"],progress:["label"],group:["direction"],when:["show"],divider:[]};function Ln(n,e){if(!Array.isArray(e)||e.length===0)return"it has no blocks to draw";if(e.length>40)return"it has more blocks than a place draws";let s=(i,a)=>{if(typeof i!="string"||i.trim()==="")return`its ${a} says nothing`;try{return V(i)}catch(l){return`its ${a} does not read: ${l instanceof Error?l.message.replace(/ \(at character.*$/,""):String(l)}`}},t=i=>{if(i.t==="where")return t(i.set);if(i.t==="call"&&i.fn==="all"){let a=i.args[0];return a?.t==="lit"&&typeof a.value=="string"?n.info(a.value)??null:void 0}},o=(i,a)=>{switch(i.t){case"lit":return;case"ident":return a&&!a.fields.some(l=>l.name===i.name)&&!a.edges.some(l=>l.name===i.name)?`${a.plural} have nothing called ${i.name}`:void 0;case"member":return o(i.object,a);case"list":return i.items.map(l=>o(l,a)).find(Boolean);case"unary":return o(i.operand,a);case"binary":return o(i.left,a)??o(i.right,a);case"where":{let l=t(i.set);return l===null?"Nothing by that name here":o(i.set,a)??o(i.filter,l??void 0)}case"call":return i.fn==="all"?t(i)===null?"Nothing by that name here":void 0:i.args.map(l=>o(l,a)).find(Boolean)}},r=(i,a)=>{if(a>4)return"its blocks nest deeper than a place draws";for(let l of i){if(!w(l))return"a block is not an object";let d=Object.keys(en).find(g=>g in l);if(!d)return`"${Object.keys(l)[0]??""}" is not a block a place draws`;let c=Object.keys(l).find(g=>g!==d&&g!=="key"&&!en[d].includes(g));if(c)return`a ${d} block takes no "${c}"`;let u=l[d];if(d==="list"||d==="figure"||d==="when"){if(d==="figure"&&u===!0)continue;let g=s(u,d);if(typeof g=="string")return g;let b=o(g,void 0);if(b)return b;if(d==="list"){let f=t(g);if(f==null)return f===null?"Nothing by that name here":"its list does not say which records it lists, like all('task')";for(let y of["group","sort"]){let p=l[y],S=typeof p=="string"?p:w(p)&&typeof p.by=="string"?p.by:void 0;if(p===void 0)continue;let D=S?f.fields.find(un=>un.name===S):void 0;if(!D)return`${f.plural} have nothing called ${String(S??p)} to ${y} by`;if(y==="group"&&D.type!=="enum")return`${f.plural}' ${D.words} is not a choice, so they cannot be grouped by it`}}if(d==="when"){let f=l.show;if(!Array.isArray(f))return"a when block shows a list of blocks";let y=r(f,a+1);if(y)return y}}else if(d==="group"){if(!Array.isArray(u))return"a group block holds a list of blocks";let g=r(u,a+1);if(g)return g}else{if(d!=="divider"&&typeof u!="string")return`a ${d} block says words`;if(typeof u=="string")for(let g of u.matchAll(/\{([^{}]*)\}/g)){let b=g[1].split(/\|(?![|])/)[0],f=s(b,`${d}'s braces`);if(typeof f=="string")return f;let y=o(f,void 0);if(y)return y}}}};return r(e,1)}function E(n,e,s){let t=O(n.schema,s),o=f=>({ok:!1,failed:`Couldn't draw that: ${f.replace(/\.$/,"")}.`});if(!T(e.name)||e.name==="reach")return o(`"${String(e.name)}" is not a picture the seat can draw; it draws ${H.filter(f=>f!=="reach").join(", ")}`);if(typeof e.title!="string"||e.title.trim().length===0||e.title.length>80)return o("it needs a title of a few words");if(typeof e.on!="string"||!t.tryDefinition(e.on))return o("Nothing by that name here");let r=P[e.name],i=e.bindings??{};if(r.binds==="fields")for(let[f,y]of Object.entries(i)){if(!t.tryDefinition(f))return o("Nothing by that name here");let p=Object.keys(t.tryDefinition(f).fields?.shape??{});for(let[S,D]of Object.entries(y??{}))if(typeof D!="string"||!p.includes(D))return o(`${m(f)} has no field "${String(D)}" for its ${S}`);for(let S of r.requiredRoles)if(!(S in(y??{})))return o(`a ${e.name} needs ${m(f)}'s ${S}`)}else if(r.binds==="entities")for(let f of r.requiredRoles){let y=i[f];if(!y)return o(`a ${e.name} needs its ${f}`);if(typeof y.kind=="string"&&!t.tryDefinition(y.kind))return o("Nothing by that name here")}let a={...n,schema:t,lenses:[...n.lenses??[],e]},l=a.lenses.length-1,d=U(a),c=`lenses.${l}`,u=d.findings.find(f=>f.path===c||f.path.startsWith(`${c}.`));if(u)return o(u.message.replace(/^"[^"]*" /,"it "));let g=d.undrawn.find(f=>f.index===l);if(g)return o(g.why);let b=d.drawn.find(f=>f.index===l);if(!b)return o("its bindings name something the app does not have");if(b.as==="overview")return o(`"${e.title}" is the scene's own address; give it another title`);if(e.name==="blocks"){let f=Ln(j(t),e.options?.blocks);if(f)return o(f)}return{ok:!0,drawn:b}}function G(n){return{op:"add-lens",title:n.title,lens:n.name,on:n.on,...n.bindings?{bindings:n.bindings}:{},...n.options?{options:n.options}:{}}}function In(n){return{op:"remove-lens",title:n.title,on:n.on}}var w=n=>typeof n=="object"&&n!==null&&!Array.isArray(n);function ln(n){let e=w(n)?n:{},s=String(e.lens??e.name??""),t=e.bindings,o=typeof e.on=="string"?e.on:w(t)&&P[s]?.binds==="fields"?Object.keys(t)[0]??"":"";return{name:s,title:typeof e.title=="string"?e.title.trim():"",on:o,...w(t)?{bindings:t}:{},...w(e.options)?{options:e.options}:{}}}function On(n){let e=o=>w(n.bindings?.[o])?n.bindings[o]:{},s=o=>typeof o=="string"?o:void 0,t=e(n.on);switch(n.name){case"columns":return s(t.column)?{lens:"columns",kind:n.on,column:t.column}:void 0;case"calendar":{let o=s(n.options?.range);return s(t.start)?{lens:"calendar",kind:n.on,start:t.start,...s(t.end)?{end:t.end}:{},...s(t.done)?{done:t.done}:{},...o?{range:o}:{}}:void 0}case"timeline":return s(t.start)&&s(t.end)&&s(t.column)?{lens:"timeline",kind:n.on,start:t.start,end:t.end,column:t.column}:void 0;case"coverage":{let o=w(n.bindings?.columns)?s(n.bindings.columns.kind):void 0,r=w(n.bindings?.link)?s(n.bindings.link.edge):void 0;return o&&r?{lens:"coverage",kind:n.on,across:o,link:r}:void 0}case"blocks":{let o=n.options?.blocks;if(!Array.isArray(o)||o.length!==1||!w(o[0]))return;let r=o[0],i=new RegExp(`^all\\('${n.on}'\\)(?: where (.+))?$`).exec(String(r.list??""));if(!i)return;let a=r.sort;return{lens:"blocks",kind:n.on,as:r.as==="card"?"card":"row",...typeof r.group=="string"?{group:r.group}:{},...typeof a=="string"?{sort:{by:a}}:w(a)&&typeof a.by=="string"?{sort:{by:a.by,...a.direction==="desc"?{direction:"desc"}:{}}}:{},...i[1]?{where:[{expr:i[1],says:"as asked"}]}:{}}}default:return}}function M(n,e,s,t,o){let r=j(O(n.schema,t)).info(e.on),i=On(e);return{title:e.title,said:`${J[e.name]??"A picture"} of ${r?.plural??m(e.on)}.`,kind:e.on,lens:e,drawn:s,edit:G(e),by:o,asks:[],...i?{recipe:i}:{}}}function tn(n){return{title:n.title,said:n.said,lens:{title:n.lens.title,lens:n.lens.name,on:n.lens.on,...n.lens.bindings?{bindings:n.lens.bindings}:{},...n.lens.options?{options:n.lens.options}:{}},edit:n.edit,by:n.by,check:"It draws, and graview check would take it."}}function C(n,e,s,t,o){let r=Rn(n,e),i=n.title??o??F(r.title,s),a=An(n,i),l=E(s.app,a,s.sight);return l.ok?{title:i,said:`${J[n.lens]} ${r.detail}.`,kind:n.kind,lens:a,drawn:l.drawn,edit:G(a),by:"template",asks:t,recipe:n}:{failed:l.failed,...s.lastGood?{lastGood:s.lastGood}:{}}}function Jn(n,e){let s=j(O(e.app.schema,e.sight)),t=s.info(n.kind);if(!t)return{failed:"Couldn't draw that: Nothing by that name here."};let o=n.lens==="blocks"&&!n.group&&!n.sort&&!n.where?.length&&n.title===void 0;return C(o?{...n,title:F(`Every ${t.noun}`,e)}:n,s,e,[])}function jn(n,e,s,t){if(s.length>0)return s;let o=i=>{switch(n){case"columns":return i.fields.some(a=>a.type==="enum");case"calendar":return i.fields.some(R);case"timeline":return an(i)!==void 0||i.fields.some(R);case"coverage":return i.edges.some(a=>a.to.some(l=>l!==i.kind));case"board":return i.fields.some(a=>a.name==="x")&&i.fields.some(a=>a.name==="y");case"plan":return i.fields.some(a=>a.name==="outline")||i.roles.outline!==void 0;default:return!0}};return[...e.kinds.filter(o)].sort((i,a)=>Number(a.fields.some(l=>A(t,l.words)))-Number(i.fields.some(l=>A(t,l.words))))}function Nn(n,e){let s=j(O(e.app.schema,e.sight)),t=sn(n),o=Sn(t);if(o.length===0)return;let r=yn(t,s),i;for(let a of o){let l=a==="coverage"?[r[0]??s.kinds[0]].filter(d=>!!d):jn(a,s,r,t);for(let d of l)try{let c=dn(a,d,s,t,r),u=C(c,s,e,[n]);if(!N(u))return u;i??=u.failed}catch(c){if(!(c instanceof x))throw c;i??=`Couldn't draw that: ${c.message}.`}l.length===0&&r.length===0&&(i??=`Couldn't draw that: nothing here has what ${J[a].toLowerCase()} needs.`)}return{failed:i??"Couldn't draw that: Nothing by that name here.",...e.lastGood?{lastGood:e.lastGood}:{}}}async function xn(n,e){let s=e.lastGood?{lastGood:e.lastGood}:{};if(n.trim().length===0)return{failed:"Say what you would like to see, like \u201Ca board of tasks by status\u201D.",...s};let t=Nn(n,e);if(t&&!N(t))return t;if(!e.complete)return t??{failed:"Couldn't draw that: drawing freely needs AI, which isn't on here. Ask for a board, a calendar, a timeline, a list or who covers what.",...s};let o=await cn(n,e,void 0);return N(o)&&t?t:o}async function En(n,e,s){let t={lastGood:n},o={...s,lastGood:n},r=j(O(s.app.schema,s.sight)),i=sn(e),a=r.info(n.kind),l=[...n.asks,e];if(!a)return{failed:"Couldn't change that: Nothing by that name here.",...t};let d=n.recipe,c=/^ (?:call|name|title) (?:it|this)? ?(.+?) $/.exec(i)??/ (?:call|name) it (.+?) $/.exec(i);try{if(c){let b=e.replace(/^.*?\b(?:call|name|title)\b\s*(?:it|this)?\s*/i,"").replace(/^["“']|["”']$/g,"").trim();if(b.length===0)return{failed:"Couldn't change that: say what to call it.",...t};let f={...n.lens,title:F(b,s)},y=E(s.app,f,s.sight);return y.ok?{...n,title:f.title,lens:f,drawn:y.drawn,edit:G(f),asks:l,...d?{recipe:{...d,title:f.title}}:{}}:{failed:y.failed,...t}}let g=/ as (?:a |an )?(board|kanban|calendar|timeline|list|table|cards|rows|grid|plan|layout)\b/.exec(i);if(g){let b=g[1]==="board"||g[1]==="kanban"?"columns":g[1]==="calendar"?"calendar":g[1]==="timeline"?"timeline":g[1]==="grid"?"coverage":g[1]==="plan"?"plan":g[1]==="layout"?"board":"blocks",f=dn(b,a,r,i,[a]),y=g[1]==="cards"?"card":g[1]==="rows"?"row":void 0,p=b==="blocks"&&d?.lens==="blocks"?{...d,...y?{as:y}:{}}:b==="blocks"&&d?.lens==="columns"?{...f,group:d.column,...y?{as:y}:{}}:f;return C(v(p),r,o,l)}if(d){let b=Kn(d,a,r,i);if(b)return C(b,r,o,l)}}catch(g){if(!(g instanceof x))throw g;return{failed:`Couldn't change that: ${g.message}.`,...t}}if(!s.complete)return{failed:"Couldn't change that: changing it freely needs AI, which isn't on here. Try \u201Cgroup by status\u201D, \u201Conly this month\u201D or \u201Cas a calendar\u201D.",...t};let u=await cn(e,o,n);return N(u)?u:{...u,asks:l}}var v=n=>{let{title:e,...s}=n;return s};function Kn(n,e,s,t){let o=/ (?:group(?:ed)?|split|organi[sz]ed?|put them|columns) by ([\p{L}\p{N} -]+?)(?= (?:and|only|with)|\s*$)/u.exec(t)?.[1]??(/^ by /.test(t)?W(t):void 0);if(o){let d=I(e,o);if(d?.type==="enum")return n.lens==="blocks"?{...v(n),group:d.name}:{lens:"columns",kind:n.kind,column:d.name};let c=rn(e,o,s);return c?{lens:"coverage",kind:n.kind,across:c.to[0],link:c.name}:h(d?`${e.plural}' ${d.words} is not a choice, so they cannot be grouped by it`:`${e.plural} have nothing called ${o} to group by`)}let r=/ (?:sort(?:ed)?|order(?:ed)?) by ([\p{L}\p{N} -]+?)(?= (?:and|only|with)|\s*$)/u.exec(t)?.[1];if(r){let d=I(e,r);return d?{...n.lens==="blocks"?v(n):{lens:"blocks",kind:n.kind,as:"row",...n.lens==="columns"?{group:n.column}:{}},sort:{by:d.name,.../\b(newest|latest|desc|descending|most)\b/.test(t)?{direction:"desc"}:{}}}:h(`${e.plural} have nothing called ${r} to sort by`)}if(/\b(?:all of them|everything|show all|clear the filter|no filter|without the filter)\b/.test(t)){if(n.lens!=="blocks"||!n.where)return h("it already shows all of them");let{where:d,...c}=v(n);return c}let i=on(t);if(i&&n.lens==="calendar"&&i.range)return{...v(n),range:i.range};if(i&&n.lens==="calendar"&&!i.range)return{lens:"blocks",kind:n.kind,as:"row",sort:{by:n.start},where:q(e,t)};let a=q(e,t);if(a.length>0){let d=n.lens==="blocks"?v(n):{lens:"blocks",kind:n.kind,as:"row",...n.lens==="columns"?{group:n.column}:{}};return{...d,where:[...d.where??[],...a]}}let l=n.lens==="calendar"?_(t):void 0;if(l)return{...v(n),range:l}}function Cn(n){return n.kinds.map(e=>{let s=e.fields.map(r=>`${r.name} (${r.type??"value"}${r.options?`: ${r.options.join(" | ")}`:""})`).join(", "),t=e.edges.map(r=>`${r.name} \u2192 ${r.to.join(" | ")}`).join(", "),o=Object.entries(e.roles).map(([r,i])=>`${r}=${i}`).join(", ");return`- ${e.kind} ("${e.plural}"): ${s}${t?`; relations: ${t}`:""}${o?`; roles: ${o}`:""}`}).join(`
1
+ import{a as k}from"./chunk.G4JJXA63.js";import{a as Q}from"./chunk.HZPRMHSL.js";import{a as Z}from"./chunk.LDMBJC3B.js";import{a as Y}from"./chunk.2JEN2RCB.js";import{c as V}from"./chunk.R5MLRKAO.js";import{ae as P,ce as H,de as T,ee as U,xb as z,yb as B}from"./chunk.IQGSEAQ2.js";var N=n=>"failed"in n;function fn(n,e){let s=n.schema.kinds,t=n.policy?.sees;if(!t?.length||B(e))return{kinds:s};let o=z(e).roles??[],r=new Set(t.filter(i=>i.roles==="*"||o.some(a=>i.roles.includes(a))).flatMap(i=>i.kinds));return{kinds:s.filter(i=>r.has(i))}}function O(n,e){if(!e)return n;let s=new Set(e.kinds.filter(r=>n.tryDefinition(r)!==void 0));if(s.size===n.kinds.length)return n;let t=new Map,o=r=>{if(s.has(r)){if(!t.has(r)){let i=n.tryDefinition(r),a=Object.fromEntries(Object.entries(i?.edges??{}).flatMap(([l,d])=>{if(d.to==="*")return[[l,d]];let c=d.to.filter(u=>s.has(u));return c.length>0?[[l,{...d,to:c}]]:[]}));t.set(r,{...i,edges:a})}return t.get(r)}};return{...n,definitions:n.definitions.filter(r=>s.has(r.kind)),kinds:n.kinds.filter(r=>s.has(r)),tryDefinition:o,definition:r=>{let i=o(r);if(!i)throw new Error(`Unknown node kind "${r}"`);return i}}}var gn=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),m=n=>gn(n).replace(/[-_]+/g," ").trim();function j(n){let e=[];for(let t of n.kinds){let o=n.tryDefinition(t);if(!o)continue;let r=o.display?.labels??{},i=Object.entries(o.fields?.shape??{}).filter(([d])=>d!=="id"&&d!=="kind").map(([d,c])=>{let u=Y(c);return{name:d,type:u?.type==="enum"&&u.multiple?"list":u?.type,...u?.options?{options:u.options}:{},words:(r[d]??m(d)).toLowerCase()}}),a=Object.entries(o.edges??{}).map(([d,c])=>({name:d,from:t,to:c.to==="*"?n.kinds.filter(u=>u!==t):c.to,words:m(d)})),l=(o.plural??`${m(t)}s`).toLowerCase();e.push({kind:t,plural:l,noun:(o.noun??m(t)).toLowerCase(),fields:i,roles:o.fieldRoles??{},edges:a})}let s=new Map(e.map(t=>[t.kind,t]));return{schema:n,kinds:e,info:t=>s.get(t)}}var $=(n,e)=>e===void 0?void 0:n.fields.find(s=>s.name===e),R=n=>n?.type==="date"||n?.type==="datetime",K=n=>n?.type==="number"||n?.type==="integer"||n?.type==="duration",sn=n=>` ${n.toLowerCase().replace(/[“”"’‘]/g,"'").replace(/[^\p{L}\p{N}' -]+/gu," ").replace(/\s+/g," ").trim()} `,A=(n,e)=>n.includes(` ${e} `),L=n=>n.endsWith("ies")?`${n.slice(0,-3)}y`:n.endsWith("ses")?n.slice(0,-2):n.endsWith("s")?n.slice(0,-1):n;function yn(n,e){let s=[];for(let t of e.kinds){let o=new Set([t.plural,t.noun,`${t.noun}s`,m(t.kind),`${m(t.kind)}s`]),r=-1;for(let i of o){let a=n.indexOf(` ${i} `);a>=0&&(r<0||a<r)&&(r=a)}r>=0&&s.push({info:t,at:r})}return s.sort((t,o)=>t.at-o.at).map(t=>t.info)}function I(n,e,s){let t=e.trim().toLowerCase();if(t.length===0)return;let o=n.fields.filter(r=>!s||s(r));return o.find(r=>r.words===t||m(r.name)===t||r.name.toLowerCase()===t)??o.find(r=>r.words===L(t)||m(r.name)===L(t))??o.find(r=>t.split(" ").some(i=>i.length>2&&(r.words.split(" ").includes(i)||r.words.split(" ").includes(L(i)))))}function rn(n,e,s){let t=e.trim().toLowerCase();if(t.length!==0)return n.edges.find(o=>o.words===t||o.name.toLowerCase()===t)??n.edges.find(o=>o.to.some(r=>{let i=s.info(r);return i!==void 0&&(i.noun===L(t)||i.plural===t||m(r)===L(t))}))??n.edges.find(o=>t.split(" ").some(r=>r.length>2&&o.words.split(" ").includes(r)))}function W(n){return/ (?:grouped |group |split |sorted |organi[sz]ed )?by ([\p{L}\p{N}' -]+?)(?= (?:and|with|for|in|on|only|where|from|this|that|as|sorted|grouped) |\s*$)/u.exec(n)?.[1]?.trim()}var bn=/\bwho\b.*\b(covers?|cover|tends?|owns?|handles?|does|works? on|looks? after|is on|is assigned|staffs?|runs?)\b|\bcoverage\b|\bmatrix\b|\bwho covers\b/,mn=/\bcalendar\b|\bmonth\b|\bagenda\b|\bschedule\b|\bdue\b|\bdeadlines?\b|\bdates?\b|\bwhen\b/,hn=/\btimeline\b|\bover time\b|\bgantt\b|\bspans?\b|\bweek\b/,pn=/\bboard\b|\bkanban\b|\bcolumns?\b|\bpipeline\b|\bstages?\b|\bstatus\b/,wn=/\blaid out\b|\blayout\b|\bseating\b|\bwhere (?:they|it|each) (?:sits?|lies?|stands?)\b|\bfloor\b/,kn=/\bplan\b|\bmap\b|\bregions?\b/,$n=/\blist\b|\btable\b|\bgroup(?:ed)? by\b|\bsort(?:ed)? by\b|\bonly\b|\bjust the\b/;function Sn(n){let e=[];return/\blist\b|\btable\b/.test(n)&&e.push("blocks"),bn.test(n)&&e.push("coverage"),wn.test(n)&&e.push("board"),(/\bfloor plan\b/.test(n)||kn.test(n))&&e.push("plan"),hn.test(n)&&e.push("timeline"),mn.test(n)&&e.push("calendar"),pn.test(n)&&e.push("columns"),$n.test(n)&&!e.includes("blocks")&&e.push("blocks"),e.length===0&&W(n)&&e.push("columns"),e}var on=n=>{let e=s=>s?` and not ${s}`:"";if(/\boverdue\b|\blate\b|\bpast due\b/.test(n))return{cond:(s,t)=>`days(today(), ${s}) < 0${e(t)}`,says:s=>`overdue by ${s.words}`};if(/\btoday\b/.test(n))return{range:"day",cond:s=>`days(today(), ${s}) == 0`,says:s=>`with ${s.words} today`};if(/\bthis week\b|\bnext 7 days\b|\bnext week\b/.test(n))return{range:"week",cond:s=>`days(today(), ${s}) >= 0 and days(today(), ${s}) <= 6`,says:s=>`with ${s.words} in the next week`};if(/\bthis month\b|\bnext 30 days\b|\bnext month\b/.test(n))return{range:"month",cond:s=>`days(today(), ${s}) >= 0 and days(today(), ${s}) <= 30`,says:s=>`with ${s.words} in the next month`};if(/\blast month\b|\bpast month\b/.test(n))return{range:"month",cond:s=>`days(today(), ${s}) >= -30 and days(today(), ${s}) <= 0`,says:s=>`with ${s.words} in the last month`};if(/\bthis year\b/.test(n))return{range:"year",cond:s=>`days(today(), ${s}) >= 0 and days(today(), ${s}) <= 365`,says:s=>`with ${s.words} in the next year`};if(/\bquarter\b/.test(n))return{range:"quarter",cond:s=>`days(today(), ${s}) >= 0 and days(today(), ${s}) <= 91`,says:s=>`with ${s.words} in the next quarter`}},_=n=>{if(/\bagenda\b|\bin order\b/.test(n))return"agenda";if(/\btoday\b|\bday\b/.test(n))return"day";if(/\bweek\b/.test(n))return"week";if(/\bquarter\b/.test(n))return"quarter";if(/\byears\b/.test(n))return"years";if(/\byear\b/.test(n))return"year";if(/\bmonth\b/.test(n))return"month"},X=/^(user|person|people|member|staff|gardener|volunteer|owner|agent|employee|worker|team|player|customer|client|contact|party|attendee|guest)s?$/,x=class extends Error{},h=n=>{throw new x(n)};function Dn(n,e){let s=n.fields.filter(r=>r.type==="enum");if(e){let r=I(n,e);if(r&&r.type==="enum")return r;r&&h(`${n.plural}' ${r.words} is not a choice, so it has no columns`)}let t=$(n,n.roles.status??n.roles.column);if(t?.type==="enum")return t;let o=s.find(r=>/^(status|stage|state|phase)$/.test(r.name));return o||(s[0]?s[0]:h(`${n.plural} have no choice field to put in columns`))}function nn(n,e){let s=n.fields.filter(R),t=l=>{let d=$(n,n.roles[l]);return R(d)?d:void 0},r=s.find(l=>A(e,l.words)||A(e,m(l.name)))??t("start")??s.find(l=>/^(due|date|on|at|start|starts|begins|from|sown|when)/i.test(l.name))??s[0];if(!r)return h(`no date field on ${n.plural}`);let i=t("end")??s.find(l=>l!==r&&/^(end|ends|until|to|finish|finished|harvested|due|closes|through)/i.test(l.name)),a=n.fields.find(l=>l.type==="boolean"&&/^(done|finished|complete|completed|closed)$/.test(l.name));return{start:r,...i&&i!==r?{end:i}:{},...a?{done:a}:{}}}function an(n){let e=$(n,n.roles.start),s=$(n,n.roles.end),t=$(n,n.roles.column??n.roles.day??n.roles.columns);if(K(e)&&K(s)&&t?.type==="enum")return{start:e,end:s,column:t}}function vn(n,e,s,t){let o=[];for(let i of n.kinds)for(let a of i.edges)for(let l of a.to){let d=n.info(l);if(!d||d.kind===i.kind)continue;let c=0;e.includes(i)&&(c+=4),e.includes(d)&&(c+=4),(X.test(d.kind)||X.test(d.noun))&&(c+=3),t&&(a.words.includes(t)||d.noun===L(t))&&(c+=5),a.words.split(" ").some(u=>u.length>2&&s.includes(` ${u}`))&&(c+=2),o.push({rows:i,across:d,link:a,score:c})}let r=o.sort((i,a)=>a.score-i.score)[0];return r||h(e[0]?`${e[0].plural} are joined to nothing else, so there is no who-covers-what to draw`:"nothing here is joined to anything else, so there is no who-covers-what to draw")}function dn(n,e,s,t,o){let r=W(t);switch(n){case"columns":{if(r){let i=I(e,r);if(!i||i.type!=="enum"){let a=rn(e,r,s);if(a){let l=s.info(a.to[0]);return{lens:"coverage",kind:e.kind,across:l.kind,link:a.name}}}}return{lens:"columns",kind:e.kind,column:Dn(e,r).name}}case"calendar":{let i=nn(e,t),a=_(t);return{lens:"calendar",kind:e.kind,start:i.start.name,...i.end?{end:i.end.name}:{},...i.done?{done:i.done.name}:{},...a?{range:a}:{}}}case"timeline":{let i=an(e);if(i&&!/\bdates?\b|\bdue\b|\bdeadlines?\b|\bmonths?\b|\byears?\b/.test(t))return{lens:"timeline",kind:e.kind,start:i.start.name,end:i.end.name,column:i.column.name};let a=nn(e,t);return{lens:"calendar",kind:e.kind,start:a.start.name,...a.end?{end:a.end.name}:{},...a.done?{done:a.done.name}:{},range:_(t)??"quarter"}}case"coverage":{let i=vn(s,o,t,r);return{lens:"coverage",kind:i.rows.kind,across:i.across.kind,link:i.link.name}}case"board":{let i=$(e,e.roles.x)??e.fields.find(c=>c.name==="x"),a=$(e,e.roles.y)??e.fields.find(c=>c.name==="y");if(!K(i)||!K(a))return h(`${e.plural} have no x and y to be laid out by`);let d=s.kinds.flatMap(c=>c.edges.filter(u=>u.to.includes(e.kind)&&c.kind!==e.kind))[0]??e.edges[0];return d?{lens:"board",kind:e.kind,x:i.name,y:a.name,fill:d.name,...d.from!==e.kind?{fillFrom:"occupant"}:{}}:h(`nothing is joined to ${e.plural} to fill them`)}case"plan":{let i=$(e,e.roles.outline)??e.fields.find(a=>a.name==="outline");return i?{lens:"plan",kind:e.kind,outline:i.name}:h(`${e.plural} have no outline to draw a plan from`)}case"blocks":{let i={lens:"blocks",kind:e.kind,as:/\bcards?\b/.test(t)?"card":"row"},a=/ group(?:ed)? by ([\p{L}\p{N} -]+?)(?= (?:and|only|sorted|with)|\s*$)/u.exec(t)?.[1]??(r&&!/ sort(?:ed)? by /.test(t)?r:void 0);if(a){let c=I(e,a);if(!c||c.type!=="enum")return h(c?`${e.plural}' ${c.words} is not a choice, so they cannot be grouped by it`:`${e.plural} have nothing called ${a} to group by`);i.group=c.name}let l=/ sort(?:ed)? by ([\p{L}\p{N} -]+?)(?= (?:and|only|grouped|with)|\s*$)/u.exec(t)?.[1];if(l){let c=I(e,l);if(!c)return h(`${e.plural} have nothing called ${l} to sort by`);i.sort={by:c.name,.../\b(newest|latest|desc|descending|most)\b/.test(t)?{direction:"desc"}:{}}}let d=q(e,t);return d.length>0&&(i.where=d),i}}}function q(n,e){let s=[],t=on(e);if(t){let o=n.fields.filter(R),r=$(n,n.roles.start),i=o.find(l=>A(e,l.words))??(R(r)?r:void 0)??o[0];(!i||!R(i))&&h(`no date field on ${n.plural}`);let a=n.fields.find(l=>l.type==="boolean"&&/^(done|finished|complete|completed|closed)$/.test(l.name));s.push({expr:t.cond(i.name,/\boverdue\b|\blate\b|\bpast due\b/.test(e)?a?.name:void 0),says:t.says(i)})}if(/\bonly\b|\bjust\b|\bthat are\b|\bwhich are\b/.test(e)){for(let o of n.fields){if(o.type!=="enum")continue;let r=o.options?.find(i=>A(e,i.toLowerCase())||A(e,m(i)));r&&s.push({expr:`${o.name} == '${r.replace(/'/g,"")}'`,says:`that are ${m(r)}`})}if(/\bnot done\b|\bundone\b|\bunfinished\b|\bopen ones\b|\bstill to do\b/.test(e)){let o=n.fields.find(r=>r.type==="boolean"&&/^(done|finished|complete|completed)$/.test(r.name));o&&s.push({expr:`not ${o.name}`,says:`not ${o.words}`})}}return s}var J={columns:"A board",calendar:"A calendar",timeline:"A timeline",coverage:"A grid",board:"A layout",plan:"A plan",blocks:"A list",reach:"A picture"};function Rn(n,e){let s=e.info(n.kind),t=o=>o?$(s,o)?.words??m(o):"";switch(n.lens){case"columns":return{title:`${k(s.plural)} by ${t(n.column)}`,detail:`of ${s.plural} by ${t(n.column)}`};case"calendar":{let o=n.range??"month";if(o==="agenda")return{title:`${k(s.plural)} in date order`,detail:`of ${s.plural} in order of ${t(n.start)}`};let r=o==="years"?"year":o;return{title:`${k(s.plural)} by ${r}`,detail:`of ${s.plural} by ${t(n.start)}, a ${r} at a time`}}case"timeline":return{title:`${k(s.plural)} over the ${t(n.column)}`,detail:`of ${s.plural} from ${t(n.start)} to ${t(n.end)}, by ${t(n.column)}`};case"coverage":{let o=e.info(n.across);return{title:`${k(s.plural)} by ${o.noun}`,detail:`of which ${o.noun} covers which ${s.noun}`}}case"board":return{title:`${k(s.plural)} where they stand`,detail:`of ${s.plural} where they stand`};case"plan":return{title:`${k(s.plural)} on a plan`,detail:`of ${s.plural}`};default:{let o=[n.where?.map(r=>r.says).join(" and "),n.group?`by ${t(n.group)}`:void 0,n.sort?`in order of ${t(n.sort.by)}`:void 0].filter(r=>!!r);return{title:[k(s.plural),...o].join(" "),detail:[`of ${s.plural}`,...o].join(" ")}}}}function An(n,e){let s={title:e,on:n.kind};switch(n.lens){case"columns":return{name:"columns",...s,bindings:{[n.kind]:{column:n.column}}};case"calendar":return{name:"calendar",...s,bindings:{[n.kind]:{start:n.start,...n.end?{end:n.end}:{},...n.done?{done:n.done}:{}}},...n.range?{options:{range:n.range}}:{}};case"timeline":return{name:"timeline",...s,bindings:{[n.kind]:{start:n.start,end:n.end,column:n.column}}};case"coverage":return{name:"coverage",...s,bindings:{rows:{kind:n.kind},columns:{kind:n.across},link:{edge:n.link}}};case"board":return{name:"board",...s,bindings:{slots:{kind:n.kind},x:{field:n.x,on:"slots"},y:{field:n.y,on:"slots"},fill:{edge:n.fill}},...n.fillFrom?{options:{fillFrom:n.fillFrom}}:{}};case"plan":return{name:"plan",...s,bindings:{regions:{kind:n.kind},outline:{field:n.outline,on:"regions"}}};default:{let t=n.where?.length?` where ${n.where.map(r=>n.where.length>1?`(${r.expr})`:r.expr).join(" and ")}`:"",o={list:`all('${n.kind}')${t}`,as:n.as??"row"};return n.group&&(o.group=n.group),n.sort&&(o.sort=n.sort.direction?{by:n.sort.by,direction:n.sort.direction}:n.sort.by),o.empty="Nothing here yet.",{name:"blocks",...s,options:{blocks:[o]}}}}}function F(n,e){let{app:s}=e,t=r=>r.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,""),o=new Set(["home","overview",...Q(s,e.views?{views:e.views}:{}).map(r=>r.slug),...(s.lenses??[]).flatMap(r=>r.title?[t(r.title)]:[])]);if(!o.has(t(n)))return n;for(let r=2;;r++)if(!o.has(t(`${n} ${r}`)))return`${n} ${r}`}var en={title:[],headline:[],text:["tone"],figure:["as","currency","label"],list:["sort","limit","group","empty","as"],progress:["label"],group:["direction"],when:["show"],divider:[]};function Ln(n,e){if(!Array.isArray(e)||e.length===0)return"it has no blocks to draw";if(e.length>40)return"it has more blocks than a place draws";let s=(i,a)=>{if(typeof i!="string"||i.trim()==="")return`its ${a} says nothing`;try{return V(i)}catch(l){return`its ${a} does not read: ${l instanceof Error?l.message.replace(/ \(at character.*$/,""):String(l)}`}},t=i=>{if(i.t==="where")return t(i.set);if(i.t==="call"&&i.fn==="all"){let a=i.args[0];return a?.t==="lit"&&typeof a.value=="string"?n.info(a.value)??null:void 0}},o=(i,a)=>{switch(i.t){case"lit":return;case"ident":return a&&!a.fields.some(l=>l.name===i.name)&&!a.edges.some(l=>l.name===i.name)?`${a.plural} have nothing called ${i.name}`:void 0;case"member":return o(i.object,a);case"list":return i.items.map(l=>o(l,a)).find(Boolean);case"unary":return o(i.operand,a);case"binary":return o(i.left,a)??o(i.right,a);case"where":{let l=t(i.set);return l===null?"Nothing by that name here":o(i.set,a)??o(i.filter,l??void 0)}case"call":return i.fn==="all"?t(i)===null?"Nothing by that name here":void 0:i.args.map(l=>o(l,a)).find(Boolean)}},r=(i,a)=>{if(a>4)return"its blocks nest deeper than a place draws";for(let l of i){if(!w(l))return"a block is not an object";let d=Object.keys(en).find(g=>g in l);if(!d)return`"${Object.keys(l)[0]??""}" is not a block a place draws`;let c=Object.keys(l).find(g=>g!==d&&g!=="key"&&!en[d].includes(g));if(c)return`a ${d} block takes no "${c}"`;let u=l[d];if(d==="list"||d==="figure"||d==="when"){if(d==="figure"&&u===!0)continue;let g=s(u,d);if(typeof g=="string")return g;let b=o(g,void 0);if(b)return b;if(d==="list"){let f=t(g);if(f==null)return f===null?"Nothing by that name here":"its list does not say which records it lists, like all('task')";for(let y of["group","sort"]){let p=l[y],S=typeof p=="string"?p:w(p)&&typeof p.by=="string"?p.by:void 0;if(p===void 0)continue;let D=S?f.fields.find(un=>un.name===S):void 0;if(!D)return`${f.plural} have nothing called ${String(S??p)} to ${y} by`;if(y==="group"&&D.type!=="enum")return`${f.plural}' ${D.words} is not a choice, so they cannot be grouped by it`}}if(d==="when"){let f=l.show;if(!Array.isArray(f))return"a when block shows a list of blocks";let y=r(f,a+1);if(y)return y}}else if(d==="group"){if(!Array.isArray(u))return"a group block holds a list of blocks";let g=r(u,a+1);if(g)return g}else{if(d!=="divider"&&typeof u!="string")return`a ${d} block says words`;if(typeof u=="string")for(let g of u.matchAll(/\{([^{}]*)\}/g)){let b=g[1].split(/\|(?![|])/)[0],f=s(b,`${d}'s braces`);if(typeof f=="string")return f;let y=o(f,void 0);if(y)return y}}}};return r(e,1)}function E(n,e,s){let t=O(n.schema,s),o=f=>({ok:!1,failed:`Couldn't draw that: ${f.replace(/\.$/,"")}.`});if(!T(e.name)||e.name==="reach")return o(`"${String(e.name)}" is not a picture the seat can draw; it draws ${H.filter(f=>f!=="reach").join(", ")}`);if(typeof e.title!="string"||e.title.trim().length===0||e.title.length>80)return o("it needs a title of a few words");if(typeof e.on!="string"||!t.tryDefinition(e.on))return o("Nothing by that name here");let r=P[e.name],i=e.bindings??{};if(r.binds==="fields")for(let[f,y]of Object.entries(i)){if(!t.tryDefinition(f))return o("Nothing by that name here");let p=Object.keys(t.tryDefinition(f).fields?.shape??{});for(let[S,D]of Object.entries(y??{}))if(typeof D!="string"||!p.includes(D))return o(`${m(f)} has no field "${String(D)}" for its ${S}`);for(let S of r.requiredRoles)if(!(S in(y??{})))return o(`a ${e.name} needs ${m(f)}'s ${S}`)}else if(r.binds==="entities")for(let f of r.requiredRoles){let y=i[f];if(!y)return o(`a ${e.name} needs its ${f}`);if(typeof y.kind=="string"&&!t.tryDefinition(y.kind))return o("Nothing by that name here")}let a={...n,schema:t,lenses:[...n.lenses??[],e]},l=a.lenses.length-1,d=U(a),c=`lenses.${l}`,u=d.findings.find(f=>f.path===c||f.path.startsWith(`${c}.`));if(u)return o(u.message.replace(/^"[^"]*" /,"it "));let g=d.undrawn.find(f=>f.index===l);if(g)return o(g.why);let b=d.drawn.find(f=>f.index===l);if(!b)return o("its bindings name something the app does not have");if(b.as==="overview")return o(`"${e.title}" is the scene's own address; give it another title`);if(e.name==="blocks"){let f=Ln(j(t),e.options?.blocks);if(f)return o(f)}return{ok:!0,drawn:b}}function G(n){return{op:"add-lens",title:n.title,lens:n.name,on:n.on,...n.bindings?{bindings:n.bindings}:{},...n.options?{options:n.options}:{}}}function In(n){return{op:"remove-lens",title:n.title,on:n.on}}var w=n=>typeof n=="object"&&n!==null&&!Array.isArray(n);function ln(n){let e=w(n)?n:{},s=String(e.lens??e.name??""),t=e.bindings,o=typeof e.on=="string"?e.on:w(t)&&P[s]?.binds==="fields"?Object.keys(t)[0]??"":"";return{name:s,title:typeof e.title=="string"?e.title.trim():"",on:o,...w(t)?{bindings:t}:{},...w(e.options)?{options:e.options}:{}}}function On(n){let e=o=>w(n.bindings?.[o])?n.bindings[o]:{},s=o=>typeof o=="string"?o:void 0,t=e(n.on);switch(n.name){case"columns":return s(t.column)?{lens:"columns",kind:n.on,column:t.column}:void 0;case"calendar":{let o=s(n.options?.range);return s(t.start)?{lens:"calendar",kind:n.on,start:t.start,...s(t.end)?{end:t.end}:{},...s(t.done)?{done:t.done}:{},...o?{range:o}:{}}:void 0}case"timeline":return s(t.start)&&s(t.end)&&s(t.column)?{lens:"timeline",kind:n.on,start:t.start,end:t.end,column:t.column}:void 0;case"coverage":{let o=w(n.bindings?.columns)?s(n.bindings.columns.kind):void 0,r=w(n.bindings?.link)?s(n.bindings.link.edge):void 0;return o&&r?{lens:"coverage",kind:n.on,across:o,link:r}:void 0}case"blocks":{let o=n.options?.blocks;if(!Array.isArray(o)||o.length!==1||!w(o[0]))return;let r=o[0],i=new RegExp(`^all\\('${n.on}'\\)(?: where (.+))?$`).exec(String(r.list??""));if(!i)return;let a=r.sort;return{lens:"blocks",kind:n.on,as:r.as==="card"?"card":"row",...typeof r.group=="string"?{group:r.group}:{},...typeof a=="string"?{sort:{by:a}}:w(a)&&typeof a.by=="string"?{sort:{by:a.by,...a.direction==="desc"?{direction:"desc"}:{}}}:{},...i[1]?{where:[{expr:i[1],says:"as asked"}]}:{}}}default:return}}function M(n,e,s,t,o){let r=j(O(n.schema,t)).info(e.on),i=On(e);return{title:e.title,said:`${J[e.name]??"A picture"} of ${r?.plural??m(e.on)}.`,kind:e.on,lens:e,drawn:s,edit:G(e),by:o,asks:[],...i?{recipe:i}:{}}}function tn(n){return{title:n.title,said:n.said,lens:{title:n.lens.title,lens:n.lens.name,on:n.lens.on,...n.lens.bindings?{bindings:n.lens.bindings}:{},...n.lens.options?{options:n.lens.options}:{}},edit:n.edit,by:n.by,check:"It draws, and graview check would take it."}}function C(n,e,s,t,o){let r=Rn(n,e),i=n.title??o??F(r.title,s),a=An(n,i),l=E(s.app,a,s.sight);return l.ok?{title:i,said:`${J[n.lens]} ${r.detail}.`,kind:n.kind,lens:a,drawn:l.drawn,edit:G(a),by:"template",asks:t,recipe:n}:{failed:l.failed,...s.lastGood?{lastGood:s.lastGood}:{}}}function Jn(n,e){let s=j(O(e.app.schema,e.sight)),t=s.info(n.kind);if(!t)return{failed:"Couldn't draw that: Nothing by that name here."};let o=n.lens==="blocks"&&!n.group&&!n.sort&&!n.where?.length&&n.title===void 0;return C(o?{...n,title:F(`Every ${t.noun}`,e)}:n,s,e,[])}function jn(n,e,s,t){if(s.length>0)return s;let o=i=>{switch(n){case"columns":return i.fields.some(a=>a.type==="enum");case"calendar":return i.fields.some(R);case"timeline":return an(i)!==void 0||i.fields.some(R);case"coverage":return i.edges.some(a=>a.to.some(l=>l!==i.kind));case"board":return i.fields.some(a=>a.name==="x")&&i.fields.some(a=>a.name==="y");case"plan":return i.fields.some(a=>a.name==="outline")||i.roles.outline!==void 0;default:return!0}};return[...e.kinds.filter(o)].sort((i,a)=>Number(a.fields.some(l=>A(t,l.words)))-Number(i.fields.some(l=>A(t,l.words))))}function Nn(n,e){let s=j(O(e.app.schema,e.sight)),t=sn(n),o=Sn(t);if(o.length===0)return;let r=yn(t,s),i;for(let a of o){let l=a==="coverage"?[r[0]??s.kinds[0]].filter(d=>!!d):jn(a,s,r,t);for(let d of l)try{let c=dn(a,d,s,t,r),u=C(c,s,e,[n]);if(!N(u))return u;i??=u.failed}catch(c){if(!(c instanceof x))throw c;i??=`Couldn't draw that: ${c.message}.`}l.length===0&&r.length===0&&(i??=`Couldn't draw that: nothing here has what ${J[a].toLowerCase()} needs.`)}return{failed:i??"Couldn't draw that: Nothing by that name here.",...e.lastGood?{lastGood:e.lastGood}:{}}}async function xn(n,e){let s=e.lastGood?{lastGood:e.lastGood}:{};if(n.trim().length===0)return{failed:"Say what you would like to see, like \u201Ca board of tasks by status\u201D.",...s};let t=Nn(n,e);if(t&&!N(t))return t;if(!e.complete)return t??{failed:"Couldn't draw that: drawing freely needs AI, which isn't on here. Ask for a board, a calendar, a timeline, a list or who covers what.",...s};let o=await cn(n,e,void 0);return N(o)&&t?t:o}async function En(n,e,s){let t={lastGood:n},o={...s,lastGood:n},r=j(O(s.app.schema,s.sight)),i=sn(e),a=r.info(n.kind),l=[...n.asks,e];if(!a)return{failed:"Couldn't change that: Nothing by that name here.",...t};let d=n.recipe,c=/^ (?:call|name|title) (?:it|this)? ?(.+?) $/.exec(i)??/ (?:call|name) it (.+?) $/.exec(i);try{if(c){let b=e.replace(/^.*?\b(?:call|name|title)\b\s*(?:it|this)?\s*/i,"").replace(/^["“']|["”']$/g,"").trim();if(b.length===0)return{failed:"Couldn't change that: say what to call it.",...t};let f={...n.lens,title:F(b,s)},y=E(s.app,f,s.sight);return y.ok?{...n,title:f.title,lens:f,drawn:y.drawn,edit:G(f),asks:l,...d?{recipe:{...d,title:f.title}}:{}}:{failed:y.failed,...t}}let g=/ as (?:a |an )?(board|kanban|calendar|timeline|list|table|cards|rows|grid|plan|layout)\b/.exec(i);if(g){let b=g[1]==="board"||g[1]==="kanban"?"columns":g[1]==="calendar"?"calendar":g[1]==="timeline"?"timeline":g[1]==="grid"?"coverage":g[1]==="plan"?"plan":g[1]==="layout"?"board":"blocks",f=dn(b,a,r,i,[a]),y=g[1]==="cards"?"card":g[1]==="rows"?"row":void 0,p=b==="blocks"&&d?.lens==="blocks"?{...d,...y?{as:y}:{}}:b==="blocks"&&d?.lens==="columns"?{...f,group:d.column,...y?{as:y}:{}}:f;return C(v(p),r,o,l)}if(d){let b=Kn(d,a,r,i);if(b)return C(b,r,o,l)}}catch(g){if(!(g instanceof x))throw g;return{failed:`Couldn't change that: ${g.message}.`,...t}}if(!s.complete)return{failed:"Couldn't change that: changing it freely needs AI, which isn't on here. Try \u201Cgroup by status\u201D, \u201Conly this month\u201D or \u201Cas a calendar\u201D.",...t};let u=await cn(e,o,n);return N(u)?u:{...u,asks:l}}var v=n=>{let{title:e,...s}=n;return s};function Kn(n,e,s,t){let o=/ (?:group(?:ed)?|split|organi[sz]ed?|put them|columns) by ([\p{L}\p{N} -]+?)(?= (?:and|only|with)|\s*$)/u.exec(t)?.[1]??(/^ by /.test(t)?W(t):void 0);if(o){let d=I(e,o);if(d?.type==="enum")return n.lens==="blocks"?{...v(n),group:d.name}:{lens:"columns",kind:n.kind,column:d.name};let c=rn(e,o,s);return c?{lens:"coverage",kind:n.kind,across:c.to[0],link:c.name}:h(d?`${e.plural}' ${d.words} is not a choice, so they cannot be grouped by it`:`${e.plural} have nothing called ${o} to group by`)}let r=/ (?:sort(?:ed)?|order(?:ed)?) by ([\p{L}\p{N} -]+?)(?= (?:and|only|with)|\s*$)/u.exec(t)?.[1];if(r){let d=I(e,r);return d?{...n.lens==="blocks"?v(n):{lens:"blocks",kind:n.kind,as:"row",...n.lens==="columns"?{group:n.column}:{}},sort:{by:d.name,.../\b(newest|latest|desc|descending|most)\b/.test(t)?{direction:"desc"}:{}}}:h(`${e.plural} have nothing called ${r} to sort by`)}if(/\b(?:all of them|everything|show all|clear the filter|no filter|without the filter)\b/.test(t)){if(n.lens!=="blocks"||!n.where)return h("it already shows all of them");let{where:d,...c}=v(n);return c}let i=on(t);if(i&&n.lens==="calendar"&&i.range)return{...v(n),range:i.range};if(i&&n.lens==="calendar"&&!i.range)return{lens:"blocks",kind:n.kind,as:"row",sort:{by:n.start},where:q(e,t)};let a=q(e,t);if(a.length>0){let d=n.lens==="blocks"?v(n):{lens:"blocks",kind:n.kind,as:"row",...n.lens==="columns"?{group:n.column}:{}};return{...d,where:[...d.where??[],...a]}}let l=n.lens==="calendar"?_(t):void 0;if(l)return{...v(n),range:l}}function Cn(n){return n.kinds.map(e=>{let s=e.fields.map(r=>`${r.name} (${r.type??"value"}${r.options?`: ${r.options.join(" | ")}`:""})`).join(", "),t=e.edges.map(r=>`${r.name} \u2192 ${r.to.join(" | ")}`).join(", "),o=Object.entries(e.roles).map(([r,i])=>`${r}=${i}`).join(", ");return`- ${e.kind} ("${e.plural}"): ${s}${t?`; relations: ${t}`:""}${o?`; roles: ${o}`:""}`}).join(`
2
2
  `)}var Fn=['columns \u2014 a board, records in columns by one choice field: {"lens": "columns", "on": K, "bindings": {K: {"column": "<enum field>"}}}','calendar \u2014 records on a calendar by a date: {"lens": "calendar", "on": K, "bindings": {K: {"start": "<date field>", "end"?: "<date field>", "done"?: "<boolean field>"}}, "options": {"range"?: "day" | "week" | "month" | "quarter" | "year" | "agenda"}}','timeline \u2014 minutes of a day in columns: {"lens": "timeline", "on": K, "bindings": {K: {"start": "<number field>", "end": "<number field>", "column": "<enum field>"}}}','coverage \u2014 who covers what, a grid of two kinds joined by a relation: {"lens": "coverage", "on": K, "bindings": {"rows": {"kind": K}, "columns": {"kind": J}, "link": {"edge": "<relation of K to J>"}}}',`blocks \u2014 anything else, as blocks: {"lens": "blocks", "on": K, "options": {"blocks": [{"headline": "words"}, {"list": "all('K') where <condition>", "group"?: "<enum field>", "sort"?: "<field>" | {"by": "<field>", "direction": "desc"}, "as"?: "row" | "card", "empty"?: "words"}, {"figure": "count(all('K'))", "label": "words"}]}}. Conditions read a record's own fields: status == 'open', not done, days(today(), due) <= 7.`].join(`
3
3
  `);function Gn(n,e,s){return["You draw a view of an app's data as JSON \u2014 never code. The app's kinds, their fields (with types) and relations:",Cn(e),"","The lenses you may use (prefer the first four; use blocks only when none of them fits):",Fn,"",s?`The view on screen now:
4
4
  ${JSON.stringify(s.lens)}
@@ -1 +1 @@
1
- import{$ as L,Bb as q,Bc as Q,Cb as H,Cc as ee,Db as J,Dc as M,Eb as U,Ec as I,Fc as N,Kc as P,L as K,Nc as w,R as _,U as G,Y as $,nb as z,ob as h,ra as F,vc as V,xb as Y,yc as X,zc as Z}from"./chunk.Q4MI53KK.js";import{j as f}from"./chunk.FQLNBIQ5.js";var te=e=>Y(e).id??e.session;function D(e,o={}){let i=V(e),n=new Map,t=o.advisory===!0;for(let s of e){if(s.vote===void 0||s.withheld||i.has(s.id)||s.vote.advisory===!0!==t)continue;let r=t?s.vote.voter:te(s.author);if(r===void 0)continue;let a=n.get(s.vote.suggestion);a||n.set(s.vote.suggestion,a=new Map),s.vote.vote===null?a.delete(r):a.set(r,s.vote.vote)}return n}function ne(e){let o=0,i=0;for(let n of e?.values()??[])n==="for"?o++:i++;return{for:o,against:i}}function le(e,o,i){let n=M(o)?I(o):void 0,t=o&&(n===void 0?te(o):void 0),s=n!==void 0?i?.get(n):t!==void 0?e?.get(t):void 0,r=ne(i);return{...ne(e),...s!==void 0?{mine:s}:{},...r.for+r.against>0?{advisory:r}:{}}}var j=(e,o)=>e.expiresAt!==void 0&&Date.parse(e.expiresAt)<=Date.parse(o),ue=(e,o,i)=>(e??[]).some(n=>n.suggestion===o&&(n.until===void 0||Date.parse(n.until)>Date.parse(i)));function oe(e,o=()=>!0,i={}){let n=V(e),t=ce(e),s=i.now??new Date().toISOString(),r,a;return e.filter(d=>d.suggests&&!d.withheld&&!n.has(d.id)&&t.get(d.id)!=="all"&&!j(d,s)&&!ue(i.dismissed,d.id,s)).flatMap(({id:d,batch:l,suggests:u,suggestsSaid:g,intent:c,batchIntent:A,author:T,lineage:S,at:p,expiresAt:de})=>{let C=t.get(d),O=ge(u,g,c).filter(m=>!C?.has(m.at));if(O.length===0)return[];let B=O.map(m=>m.call),W=new Set;return JSON.stringify(B.map(m=>m.args),(m,k)=>(typeof k=="string"&&o(k)&&W.add(k),k)),[{id:d,batch:l,calls:B,intent:C?O.map(m=>m.intent).join("; "):c,...A!==void 0?{headline:A}:{},items:O,author:T,...S?{lineage:S}:{},at:p,expiresAt:de,about:[...W],tally:le((r??=D(e)).get(d),i.voter,(a??=D(e,{advisory:!0})).get(d))}]})}function ge(e,o,i){let n=o&&o.length===e.length?o:void 0;return e.map((t,s)=>({at:s,call:t,intent:n?.[s]??(e.length===1?i:t.name)}))}function ce(e){let o=new Map;for(let n of e){let t=n.lineage?.suggestion;if(t===void 0)continue;let s=n.lineage.items,r=o.get(t);if(r!=="all")if(s===void 0)o.set(t,"all");else{let a=r??new Set;for(let d of s)a.add(d);o.set(t,a)}}let i=new Map(e.filter(n=>n.suggests&&o.has(n.id)).map(n=>[n.id,n.suggests.length]));for(let[n,t]of o)t!=="all"&&i.has(n)&&t.size>=i.get(n)&&o.set(n,"all");return o}function ie(e,o){return e.ops.length>0&&e.ops.every(i=>i.suggests!==void 0||i.undoes!==void 0&&o(i.undoes)?.suggests!==void 0)}var E=e=>[...e].length;function pe(e){let o,i=0,n=0;for(let t of e.ops){let s=t.mutation?.name===U&&t.withheld!==!0&&t.undoes===void 0?t.mutation.args:void 0;if(typeof s?.node!="string"||typeof s.field!="string"||o&&(o.node!==s.node||o.field!==s.field))return;o={node:s.node,field:s.field};for(let r of t.primitives)r.op==="splice-text"?(i+=E(r.inserted),n+=E(r.removed)):r.op==="patch-node"&&typeof r.after[s.field]=="string"&&(i+=E(r.after[s.field]))}return o&&{...o,inserted:i,removed:n}}function fe(e,o,i){let n=i.getNode(e.node)?.kind,t=[...e.inserted>0||e.removed===0?[`+${e.inserted}`]:[],...e.removed>0?[`\u2212${e.removed}`]:[]];return`Wrote in ${F(n?o.tryDefinition(n):void 0,e.field)} (${t.join(" ")})`}var x=e=>JSON.stringify([e.kind,e.id??"",e.name??""]),ye=e=>e.ops.find(o=>o.lineage?.run!==void 0)?.lineage?.run;function me(e,o=()=>{}){let i=[];for(let n of e){if(ie(n,o))continue;if(!P(n.author)){let u=pe(n),g=i.at(-1),c=u&&g&&"batch"in g&&x(g.batch.author)===x(n.author)&&g.typed?.node===u.node&&g.typed.field===u.field?g.typed:void 0;c?i[i.length-1]={batch:n,typed:{...c,batches:[...c.batches,n],inserted:c.inserted+u.inserted,removed:c.removed+u.removed}}:i.push(u?{batch:n,typed:{batches:[n],...u}}:{batch:n});continue}let t=ye(n),s=x(n.author),r=t!==void 0?i.findIndex(u=>"digest"in u&&u.digest.run===t&&x(u.digest.author)===s):i.length-1,a=i[r],d=a!==void 0&&"digest"in a&&x(a.digest.author)===s&&a.digest.run===t?a.digest:void 0,l=[...d?.batches??[],n];d&&i.splice(r,1),i.push({digest:{author:n.author,batches:l,things:he(l),at:n.at,...t!==void 0?{run:t}:{}}})}return i}var he=e=>e.reduce((o,i)=>o+(i.undone?0:i.ops.length),0),Se=e=>{let o=Date.parse(e);if(Number.isNaN(o))return!1;let{minutes:i}=G(o,_());return i<6*60||i>=21*60};function ve(e,o=$(new Date().toISOString())??K()){let i=$(e.at)??e.at.slice(0,10),t=e.run!==void 0&&i===o&&[e.at,...(e.batches??[]).map(r=>r.at)].every(Se)?"overnight":i===o?"today":`on ${L(i)}`,s=e.things===1?"one thing":`${e.things} things`;return e.author?.id?.startsWith("workflow:")&&e.author.name?`${e.author.name}: ${s} ${t}`:`Tidied ${s} ${t}`}var y=e=>e,v=(e,o)=>o===void 0?{}:{[e]:o};function Ge(e,o,i){let n=f(e)?.store??e,t=y(n),s=Z(i.lineage);if(s===void 0)throw new h("A suggestion says what it is based on: { basis, confidence? }");let r=i.author??t.by;if(i.expiresAt!==void 0&&Number.isNaN(Date.parse(i.expiresAt)))throw new h(`A suggestion expires at a time: "${i.expiresAt}" is not one (an ISO time, like 2026-10-23T06:00:00Z).`);let a=t.actMeanings(),d=w(o,a),l=R(n).find(p=>w(p.calls,a)===d);if(l)return n.log.get(l.id);t.refuseDeclined(o,r);let u=t.rehearsal();u.suggesting=!0;let g=u.applying(o,{author:r,lineage:s,...v("via",i.via)});if(g.ops.length===0)return;let c=[...new Set(g.ops.flatMap(p=>p.described??[]))],A=g.ops.filter(p=>p.mutation!==null&&p.author===r),T=o.length>1&&A.length===o.length?A.map(p=>p.intent):void 0,S={id:t.nextId(),seq:n.log.length,batch:t.mintBatch("batch"),author:r,intent:g.ops.map(p=>p.intent).join("; "),...v("batchIntent",i.intent),mutation:null,primitives:[],reads:[],writes:[],...c.length>0?{described:c}:{},at:t.now(),...v("via",i.via),lineage:s,suggests:o,...v("suggestsSaid",T),...v("expiresAt",i.expiresAt)};return n.log.append(S),n.notify(z,[S]),S}function R(e,o,i={}){let n=f(e),t=n?.store??e,s=o??n?.principal,r=(s!==void 0?t.seenBy(s):t).log.all();return oe(r,a=>t.graph.has(a),{now:y(t).now(),dismissed:i.dismissed,voter:s})}function se(e,o,i){let n=f(e),t=n?.store??e,s=i??n?.principal??y(t).by;return o.calls.every(r=>t.permits(r,s).ok)}function re(e,o,i,n={}){let t=f(e)?.store??e,s=n.author??y(t).by;b(t,o,s);let r=t.applyAll([{name:ee,args:{suggestion:o,vote:i}}],{...n,author:s});return i===null?r:{...r,voted:i}}function b(e,o,i){let n=R(e,i).find(s=>s.id===o),t=n?void 0:e.log.get(o);if(t?.suggests&&j(t,y(e).now()))throw new h(`That suggestion expired on ${t.expiresAt.slice(0,10)}.`);if(!n)throw new h("That suggestion is no longer waiting: it was accepted or declined, or it is not one you can see.");return n}function Le(e,o,i={}){let n=f(e)?.store??e,{items:t,...s}=i,r=s.author??y(n).by,a=b(n,o,r),d=t===void 0?a.items:a.items.filter(c=>t.includes(c.at));if(t!==void 0&&(t.length===0||d.length!==new Set(t).size))throw new h("Name the changes to accept by their place among those still waiting in the suggestion.");let l={...a,calls:d.map(c=>c.call)};if(!se(n,l,r))return re(n,o,"for",{...s,author:r});let u=n.log.get(o)?.suggests?.length??d.length,g=d.length<u?{items:d.map(c=>c.at)}:{};return n.applyAll(l.calls,{...s,author:r,lineage:{...a.lineage,suggestion:o,...g}})}function Fe(e,o,i={}){let n=f(e)?.store??e,t=i.author??y(n).by,s=b(n,o,t);if(!se(n,s,t))return re(n,o,"against",{...i,author:t});let r=ae(s)&&i.intent===void 0?{intent:`Declined ${xe(we(s))} proposal: ${s.intent}`}:{};return n.undo(s.batch,{...i,...r,author:t})}function ze(e,o,i={}){let n=f(e)?.store??e,t=i.author??y(n).by,s=b(n,o,t);if(s.author.kind!==t.kind||s.author.id!==t.id)throw new h("Only who made a suggestion withdraws it: a person declines it (declineSuggestion).");return n.undo(s.batch,{...i,author:t})}var Ae={kind:"system",id:"tidying",name:"Graview, tidying",automated:!0};N.op=(e,o,i,n,t,s)=>{let r=e,{suggestion:a,vote:d}=i.args,l=b(r,a,t),u=M(t)?I(t):void 0,g=d==="for"?`For: ${l.intent}`:d==="against"?`Against: ${l.intent}`:`Withdraws a vote on: ${l.intent}`;return{id:o.id,seq:r.log.length,batch:n,author:t,intent:g,mutation:i,primitives:[],reads:[],writes:[],...l.about.length>0?{described:l.about}:{},at:o.at,...s.via!==void 0?{via:s.via}:{},vote:{suggestion:a,vote:d,...u!==void 0?{advisory:!0,voter:u}:{}}}};N.accepting=(e,o)=>{let i=e,n=i.tidying?.autoAcceptAt;if(n===void 0||o.vote?.vote!=="for")return;let t=o.vote.suggestion,s=R(i).find(l=>l.id===t);if(!s)return;let a=[...D(i.log.all()).get(t)??[]].filter(([,l])=>l==="for").map(([l])=>l);if(a.length<n)return;let d=P(s.author)?s.author:Ae;return{calls:s.calls,author:d,lineage:{...s.lineage,suggestion:t,voters:a.slice(0,X)}}};var ae=e=>e.lineage?.proposedBy!==void 0,we=e=>e.author.name??e.author.id??"Somebody",xe=e=>/s$/i.test(e)?`${e}'`:`${e}'s`;function Ye(e,o,i,n){let t=f(e)?.store??e,s=y(t).actMeanings(),r=w(i,s),a=R(t,o).find(l=>ae(l)&&w(l.calls,s)===r);if(a)return t.log.get(a.id);let d={calls:i.map(({name:l,args:u})=>({name:l,args:u})),...v("intent",n)};return t.applyAll([{name:Q,args:d}],{author:o}).ops.find(l=>l.suggests!==void 0)}function qe(e,o,i){if(!e||!e.grants.some(t=>t.propose!==void 0))return[];let n=new Set(q(e,o,i));return i.filter(t=>!n.has(t)&&H(t).some(s=>J(e,o,t.name,s)))}export{fe as a,me as b,ve as c,Ge as d,R as e,se as f,re as g,Le as h,Fe as i,ze as j,ae as k,Ye as l,qe as m};
1
+ import{$ as L,Bb as q,Bc as Q,Cb as H,Cc as ee,Db as J,Dc as M,Eb as U,Ec as I,Fc as N,Kc as P,L as K,Nc as w,R as _,U as G,Y as $,nb as z,ob as h,ra as F,vc as V,xb as Y,yc as X,zc as Z}from"./chunk.IQGSEAQ2.js";import{j as f}from"./chunk.FQLNBIQ5.js";var te=e=>Y(e).id??e.session;function D(e,o={}){let i=V(e),n=new Map,t=o.advisory===!0;for(let s of e){if(s.vote===void 0||s.withheld||i.has(s.id)||s.vote.advisory===!0!==t)continue;let r=t?s.vote.voter:te(s.author);if(r===void 0)continue;let a=n.get(s.vote.suggestion);a||n.set(s.vote.suggestion,a=new Map),s.vote.vote===null?a.delete(r):a.set(r,s.vote.vote)}return n}function ne(e){let o=0,i=0;for(let n of e?.values()??[])n==="for"?o++:i++;return{for:o,against:i}}function le(e,o,i){let n=M(o)?I(o):void 0,t=o&&(n===void 0?te(o):void 0),s=n!==void 0?i?.get(n):t!==void 0?e?.get(t):void 0,r=ne(i);return{...ne(e),...s!==void 0?{mine:s}:{},...r.for+r.against>0?{advisory:r}:{}}}var j=(e,o)=>e.expiresAt!==void 0&&Date.parse(e.expiresAt)<=Date.parse(o),ue=(e,o,i)=>(e??[]).some(n=>n.suggestion===o&&(n.until===void 0||Date.parse(n.until)>Date.parse(i)));function oe(e,o=()=>!0,i={}){let n=V(e),t=ce(e),s=i.now??new Date().toISOString(),r,a;return e.filter(d=>d.suggests&&!d.withheld&&!n.has(d.id)&&t.get(d.id)!=="all"&&!j(d,s)&&!ue(i.dismissed,d.id,s)).flatMap(({id:d,batch:l,suggests:u,suggestsSaid:g,intent:c,batchIntent:A,author:T,lineage:S,at:p,expiresAt:de})=>{let C=t.get(d),O=ge(u,g,c).filter(m=>!C?.has(m.at));if(O.length===0)return[];let B=O.map(m=>m.call),W=new Set;return JSON.stringify(B.map(m=>m.args),(m,k)=>(typeof k=="string"&&o(k)&&W.add(k),k)),[{id:d,batch:l,calls:B,intent:C?O.map(m=>m.intent).join("; "):c,...A!==void 0?{headline:A}:{},items:O,author:T,...S?{lineage:S}:{},at:p,expiresAt:de,about:[...W],tally:le((r??=D(e)).get(d),i.voter,(a??=D(e,{advisory:!0})).get(d))}]})}function ge(e,o,i){let n=o&&o.length===e.length?o:void 0;return e.map((t,s)=>({at:s,call:t,intent:n?.[s]??(e.length===1?i:t.name)}))}function ce(e){let o=new Map;for(let n of e){let t=n.lineage?.suggestion;if(t===void 0)continue;let s=n.lineage.items,r=o.get(t);if(r!=="all")if(s===void 0)o.set(t,"all");else{let a=r??new Set;for(let d of s)a.add(d);o.set(t,a)}}let i=new Map(e.filter(n=>n.suggests&&o.has(n.id)).map(n=>[n.id,n.suggests.length]));for(let[n,t]of o)t!=="all"&&i.has(n)&&t.size>=i.get(n)&&o.set(n,"all");return o}function ie(e,o){return e.ops.length>0&&e.ops.every(i=>i.suggests!==void 0||i.undoes!==void 0&&o(i.undoes)?.suggests!==void 0)}var E=e=>[...e].length;function pe(e){let o,i=0,n=0;for(let t of e.ops){let s=t.mutation?.name===U&&t.withheld!==!0&&t.undoes===void 0?t.mutation.args:void 0;if(typeof s?.node!="string"||typeof s.field!="string"||o&&(o.node!==s.node||o.field!==s.field))return;o={node:s.node,field:s.field};for(let r of t.primitives)r.op==="splice-text"?(i+=E(r.inserted),n+=E(r.removed)):r.op==="patch-node"&&typeof r.after[s.field]=="string"&&(i+=E(r.after[s.field]))}return o&&{...o,inserted:i,removed:n}}function fe(e,o,i){let n=i.getNode(e.node)?.kind,t=[...e.inserted>0||e.removed===0?[`+${e.inserted}`]:[],...e.removed>0?[`\u2212${e.removed}`]:[]];return`Wrote in ${F(n?o.tryDefinition(n):void 0,e.field)} (${t.join(" ")})`}var x=e=>JSON.stringify([e.kind,e.id??"",e.name??""]),ye=e=>e.ops.find(o=>o.lineage?.run!==void 0)?.lineage?.run;function me(e,o=()=>{}){let i=[];for(let n of e){if(ie(n,o))continue;if(!P(n.author)){let u=pe(n),g=i.at(-1),c=u&&g&&"batch"in g&&x(g.batch.author)===x(n.author)&&g.typed?.node===u.node&&g.typed.field===u.field?g.typed:void 0;c?i[i.length-1]={batch:n,typed:{...c,batches:[...c.batches,n],inserted:c.inserted+u.inserted,removed:c.removed+u.removed}}:i.push(u?{batch:n,typed:{batches:[n],...u}}:{batch:n});continue}let t=ye(n),s=x(n.author),r=t!==void 0?i.findIndex(u=>"digest"in u&&u.digest.run===t&&x(u.digest.author)===s):i.length-1,a=i[r],d=a!==void 0&&"digest"in a&&x(a.digest.author)===s&&a.digest.run===t?a.digest:void 0,l=[...d?.batches??[],n];d&&i.splice(r,1),i.push({digest:{author:n.author,batches:l,things:he(l),at:n.at,...t!==void 0?{run:t}:{}}})}return i}var he=e=>e.reduce((o,i)=>o+(i.undone?0:i.ops.length),0),Se=e=>{let o=Date.parse(e);if(Number.isNaN(o))return!1;let{minutes:i}=G(o,_());return i<6*60||i>=21*60};function ve(e,o=$(new Date().toISOString())??K()){let i=$(e.at)??e.at.slice(0,10),t=e.run!==void 0&&i===o&&[e.at,...(e.batches??[]).map(r=>r.at)].every(Se)?"overnight":i===o?"today":`on ${L(i)}`,s=e.things===1?"one thing":`${e.things} things`;return e.author?.id?.startsWith("workflow:")&&e.author.name?`${e.author.name}: ${s} ${t}`:`Tidied ${s} ${t}`}var y=e=>e,v=(e,o)=>o===void 0?{}:{[e]:o};function Ge(e,o,i){let n=f(e)?.store??e,t=y(n),s=Z(i.lineage);if(s===void 0)throw new h("A suggestion says what it is based on: { basis, confidence? }");let r=i.author??t.by;if(i.expiresAt!==void 0&&Number.isNaN(Date.parse(i.expiresAt)))throw new h(`A suggestion expires at a time: "${i.expiresAt}" is not one (an ISO time, like 2026-10-23T06:00:00Z).`);let a=t.actMeanings(),d=w(o,a),l=R(n).find(p=>w(p.calls,a)===d);if(l)return n.log.get(l.id);t.refuseDeclined(o,r);let u=t.rehearsal();u.suggesting=!0;let g=u.applying(o,{author:r,lineage:s,...v("via",i.via)});if(g.ops.length===0)return;let c=[...new Set(g.ops.flatMap(p=>p.described??[]))],A=g.ops.filter(p=>p.mutation!==null&&p.author===r),T=o.length>1&&A.length===o.length?A.map(p=>p.intent):void 0,S={id:t.nextId(),seq:n.log.length,batch:t.mintBatch("batch"),author:r,intent:g.ops.map(p=>p.intent).join("; "),...v("batchIntent",i.intent),mutation:null,primitives:[],reads:[],writes:[],...c.length>0?{described:c}:{},at:t.now(),...v("via",i.via),lineage:s,suggests:o,...v("suggestsSaid",T),...v("expiresAt",i.expiresAt)};return n.log.append(S),n.notify(z,[S]),S}function R(e,o,i={}){let n=f(e),t=n?.store??e,s=o??n?.principal,r=(s!==void 0?t.seenBy(s):t).log.all();return oe(r,a=>t.graph.has(a),{now:y(t).now(),dismissed:i.dismissed,voter:s})}function se(e,o,i){let n=f(e),t=n?.store??e,s=i??n?.principal??y(t).by;return o.calls.every(r=>t.permits(r,s).ok)}function re(e,o,i,n={}){let t=f(e)?.store??e,s=n.author??y(t).by;b(t,o,s);let r=t.applyAll([{name:ee,args:{suggestion:o,vote:i}}],{...n,author:s});return i===null?r:{...r,voted:i}}function b(e,o,i){let n=R(e,i).find(s=>s.id===o),t=n?void 0:e.log.get(o);if(t?.suggests&&j(t,y(e).now()))throw new h(`That suggestion expired on ${t.expiresAt.slice(0,10)}.`);if(!n)throw new h("That suggestion is no longer waiting: it was accepted or declined, or it is not one you can see.");return n}function Le(e,o,i={}){let n=f(e)?.store??e,{items:t,...s}=i,r=s.author??y(n).by,a=b(n,o,r),d=t===void 0?a.items:a.items.filter(c=>t.includes(c.at));if(t!==void 0&&(t.length===0||d.length!==new Set(t).size))throw new h("Name the changes to accept by their place among those still waiting in the suggestion.");let l={...a,calls:d.map(c=>c.call)};if(!se(n,l,r))return re(n,o,"for",{...s,author:r});let u=n.log.get(o)?.suggests?.length??d.length,g=d.length<u?{items:d.map(c=>c.at)}:{};return n.applyAll(l.calls,{...s,author:r,lineage:{...a.lineage,suggestion:o,...g}})}function Fe(e,o,i={}){let n=f(e)?.store??e,t=i.author??y(n).by,s=b(n,o,t);if(!se(n,s,t))return re(n,o,"against",{...i,author:t});let r=ae(s)&&i.intent===void 0?{intent:`Declined ${xe(we(s))} proposal: ${s.intent}`}:{};return n.undo(s.batch,{...i,...r,author:t})}function ze(e,o,i={}){let n=f(e)?.store??e,t=i.author??y(n).by,s=b(n,o,t);if(s.author.kind!==t.kind||s.author.id!==t.id)throw new h("Only who made a suggestion withdraws it: a person declines it (declineSuggestion).");return n.undo(s.batch,{...i,author:t})}var Ae={kind:"system",id:"tidying",name:"Graview, tidying",automated:!0};N.op=(e,o,i,n,t,s)=>{let r=e,{suggestion:a,vote:d}=i.args,l=b(r,a,t),u=M(t)?I(t):void 0,g=d==="for"?`For: ${l.intent}`:d==="against"?`Against: ${l.intent}`:`Withdraws a vote on: ${l.intent}`;return{id:o.id,seq:r.log.length,batch:n,author:t,intent:g,mutation:i,primitives:[],reads:[],writes:[],...l.about.length>0?{described:l.about}:{},at:o.at,...s.via!==void 0?{via:s.via}:{},vote:{suggestion:a,vote:d,...u!==void 0?{advisory:!0,voter:u}:{}}}};N.accepting=(e,o)=>{let i=e,n=i.tidying?.autoAcceptAt;if(n===void 0||o.vote?.vote!=="for")return;let t=o.vote.suggestion,s=R(i).find(l=>l.id===t);if(!s)return;let a=[...D(i.log.all()).get(t)??[]].filter(([,l])=>l==="for").map(([l])=>l);if(a.length<n)return;let d=P(s.author)?s.author:Ae;return{calls:s.calls,author:d,lineage:{...s.lineage,suggestion:t,voters:a.slice(0,X)}}};var ae=e=>e.lineage?.proposedBy!==void 0,we=e=>e.author.name??e.author.id??"Somebody",xe=e=>/s$/i.test(e)?`${e}'`:`${e}'s`;function Ye(e,o,i,n){let t=f(e)?.store??e,s=y(t).actMeanings(),r=w(i,s),a=R(t,o).find(l=>ae(l)&&w(l.calls,s)===r);if(a)return t.log.get(a.id);let d={calls:i.map(({name:l,args:u})=>({name:l,args:u})),...v("intent",n)};return t.applyAll([{name:Q,args:d}],{author:o}).ops.find(l=>l.suggests!==void 0)}function qe(e,o,i){if(!e||!e.grants.some(t=>t.propose!==void 0))return[];let n=new Set(q(e,o,i));return i.filter(t=>!n.has(t)&&H(t).some(s=>J(e,o,t.name,s)))}export{fe as a,me as b,ve as c,Ge as d,R as e,se as f,re as g,Le as h,Fe as i,ze as j,ae as k,Ye as l,qe as m};
@@ -1 +1 @@
1
- import{a as y,b as h}from"./chunk.36OE6RKG.js";import"./chunk.IEDCFSN5.js";import"./chunk.PWAP2GJS.js";import"./chunk.AHPYNDVA.js";import"./chunk.FNVGNISQ.js";import{yd as b}from"./chunk.Q4MI53KK.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";var k=(d,i)=>({id:i.id,said:h(d,i),when:i.when,...i.alsoMine?{alsoMine:!0}:{}});async function A(d,i,t){let a=b(t.principal);if(a.id===void 0)return{ok:!1,error:"This seat acts for nobody the app knows by id, so there is nobody to tell. Nothing was kept."};let r=t.store.seenBy(a),p=async()=>(await t.subscriptions.list(a.id)).filter(n=>n.app===t.app);if(d==="list_subscriptions")return{ok:!0,data:{subscriptions:(await p()).map(n=>k(r,n))}};if(d==="unsubscribe"){let n=String(i.id??"");return(await p()).some(g=>g.id===n)?(await t.subscriptions.remove(n),{ok:!0,data:{removed:n}}):{ok:!1,error:`No subscription "${n}" of yours. list_subscriptions says which there are.`}}let o=String(i.on??""),c=n=>typeof i[n]=="string"&&i[n].trim()!==""?i[n].trim():void 0,e=c("record");if(e!==void 0&&!r.graph.getNode(e)){let n=t.store.resolveRef({name:"record",kinds:["*"]},e,a);if(!n.ok)return{ok:!1,error:`${n.message} Nothing was kept.`};e=n.id}let s=c("kind")??(e!==void 0&&o!=="act"?r.graph.getNode(e)?.kind:void 0),f=c("act"),m=c("condition"),u=o==="act"?{on:o,...f!==void 0?{act:f}:{},...e!==void 0?{record:e}:{}}:o==="created"&&s!==void 0?{on:o,kind:s}:o==="changed"?{on:o,...s!==void 0&&e===void 0?{kind:s}:{},...e!==void 0?{record:e}:{}}:o==="reaches"&&s!==void 0?{on:o,kind:s,condition:m??"",...e!==void 0?{record:e}:{}}:void 0;if(!u)return{ok:!1,error:'Say what to be told of: on is "act", "created", "changed" or "reaches", with a kind (or a record) for all but act. Nothing was kept.'};let l=y({schema:r.schema,allMutations:()=>t.store.allMutations(),graph:r.graph},u);if(l)return{ok:!1,error:`${l} Nothing was kept.`};let S=await t.subscriptions.add({who:a,app:t.app,when:u,...i.alsoMine===!0?{alsoMine:!0}:{}});return{ok:!0,data:{subscription:k(r,S)}}}export{A as runSubscriptionTool};
1
+ import{a as y,b as h}from"./chunk.5B7NG6WH.js";import"./chunk.UDYFGYJP.js";import"./chunk.TMHVYI5R.js";import"./chunk.R5MLRKAO.js";import"./chunk.YMXWS4XN.js";import{Ad as b}from"./chunk.IQGSEAQ2.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";var k=(d,i)=>({id:i.id,said:h(d,i),when:i.when,...i.alsoMine?{alsoMine:!0}:{}});async function A(d,i,t){let a=b(t.principal);if(a.id===void 0)return{ok:!1,error:"This seat acts for nobody the app knows by id, so there is nobody to tell. Nothing was kept."};let r=t.store.seenBy(a),p=async()=>(await t.subscriptions.list(a.id)).filter(n=>n.app===t.app);if(d==="list_subscriptions")return{ok:!0,data:{subscriptions:(await p()).map(n=>k(r,n))}};if(d==="unsubscribe"){let n=String(i.id??"");return(await p()).some(g=>g.id===n)?(await t.subscriptions.remove(n),{ok:!0,data:{removed:n}}):{ok:!1,error:`No subscription "${n}" of yours. list_subscriptions says which there are.`}}let o=String(i.on??""),c=n=>typeof i[n]=="string"&&i[n].trim()!==""?i[n].trim():void 0,e=c("record");if(e!==void 0&&!r.graph.getNode(e)){let n=t.store.resolveRef({name:"record",kinds:["*"]},e,a);if(!n.ok)return{ok:!1,error:`${n.message} Nothing was kept.`};e=n.id}let s=c("kind")??(e!==void 0&&o!=="act"?r.graph.getNode(e)?.kind:void 0),f=c("act"),m=c("condition"),u=o==="act"?{on:o,...f!==void 0?{act:f}:{},...e!==void 0?{record:e}:{}}:o==="created"&&s!==void 0?{on:o,kind:s}:o==="changed"?{on:o,...s!==void 0&&e===void 0?{kind:s}:{},...e!==void 0?{record:e}:{}}:o==="reaches"&&s!==void 0?{on:o,kind:s,condition:m??"",...e!==void 0?{record:e}:{}}:void 0;if(!u)return{ok:!1,error:'Say what to be told of: on is "act", "created", "changed" or "reaches", with a kind (or a record) for all but act. Nothing was kept.'};let l=y({schema:r.schema,allMutations:()=>t.store.allMutations(),graph:r.graph},u);if(l)return{ok:!1,error:`${l} Nothing was kept.`};let S=await t.subscriptions.add({who:a,app:t.app,when:u,...i.alsoMine===!0?{alsoMine:!0}:{}});return{ok:!0,data:{subscription:k(r,S)}}}export{A as runSubscriptionTool};
@@ -1,4 +1,4 @@
1
- var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{d as C,e as re}from"./chunk.Q2EGESEZ.js";import{e as ee}from"./chunk.SMHP2CQH.js";import{b as S}from"./chunk.D5LOTCBU.js";import{j as X}from"./chunk.KZUMXT5J.js";import{G as se,Ia as V,Ra as J,T as Z,Va as Q}from"./chunk.CYTTZOYL.js";import{a as K}from"./chunk.SDO3U72B.js";import{T as Y,Z as M,la as U}from"./chunk.Q4MI53KK.js";import{b as D}from"./chunk.AJZBJBMO.js";var h=D(se(),1);var n=D(Z(),1),Re=9,le=40,ge=2;function de(e){let r=new Map;for(let i of e.allNodes())r.set(i.kind,(r.get(i.kind)??0)+1);return r}var ue=(e,r)=>(e.far??[]).reduce((i,a)=>i+(r.get(a)??0),0);function ce(e,r,i){if(i)return i.flatMap(s=>e.filters.filter(u=>u.key===s));let a=de(r),o=new Set(e.filters.filter(s=>s.about==="edge"&&ue(s,a)>le).map(s=>s.key));return e.filters.filter(s=>s.about==="edge"?!o.has(s.key):s.about==="via"?o.has(s.key.split(".")[0]):!0)}function pe(e,r){let i=e.filter(a=>a.about==="field"&&a.type==="choice"&&(a.options?.length??0)>0);return r?i:i.slice(0,ge)}var fe=520;function ye(e,r,i,a){let o=i.filters.find(s=>s.key===a.key);if(!o)return`${a.key}: ${a.value}`;if(o.about==="is")return a.value.charAt(0).toUpperCase()+a.value.slice(1);if(o.about==="via")return`${o.label}: ${S(e.tryDefinition(o.far?.[0]??""),o.key.split(".")[1],a.value)}`;if(o.about==="edge"){if(a.value==="*")return`${o.label}: anything`;if(a.value==="none")return`${o.label}: nothing`;let s=r.getNode(a.value);return`${o.label}: ${s?U(e.tryDefinition(s.kind),s):a.value}`}if(o.type==="date"){let[s,u]=a.value.split(":");return`${o.label} ${s} ${u?Y(u):""}`.trim()}if(o.type==="boolean")return`${o.label}: ${a.value==="true"?"yes":"no"}`;if(o.type==="number"){let s=a.value.lastIndexOf(":"),u=a.value.slice(0,Math.max(0,s));if(u==="at-most"||u==="at-least")return`${o.label}: ${u==="at-most"?"at most":"at least"} ${S(e.tryDefinition(i.kind),o.key,Number(a.value.slice(s+1)))}`}return o.type==="text"?`${o.label}: ${a.value}`:`${o.label}: ${S(e.tryDefinition(i.kind),o.key,a.value)}`}var P=e=>/^[A-Z][a-z]/.test(e)?e.charAt(0).toLowerCase()+e.slice(1):e;function me(e){return e?.type==="date"?{asc:"Earliest first",desc:"Latest first"}:e?.type==="number"?{asc:"Lowest first",desc:"Highest first"}:e?.type==="boolean"?{asc:"No first",desc:"Yes first"}:e?.type==="choice"?{asc:"In their order",desc:"In reverse order"}:{asc:"A to Z",desc:"Z to A"}}var x=V(K(()=>(__graviewPreload(import.meta.url,["./chunk.QAMW5QDT.js","./chunk.B5PJCYBU.js","./chunk.Q2EGESEZ.js","./chunk.SMHP2CQH.js","./chunk.REUMBCSV.js","./chunk.2KIWGQXC.js","./chunk.D5LOTCBU.js","./chunk.KZUMXT5J.js","./chunk.CGK2PY76.js","./chunk.CYTTZOYL.js","./chunk.SDO3U72B.js","./chunk.Q4MI53KK.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.5QXQ7PBI.js")))),N=x.part((e,r)=>(0,n.jsx)(e.ArrangeLists,{...r}),{what:"This list",quiet:!0}),he=x.part((e,r)=>(0,n.jsx)(e.ArrangeChips,{...r}),{what:"This list",quiet:!0}),Oe=()=>x.load(),q=new Map;function Te(e){let{schema:r,graph:i,kind:a,arrangement:o,onChange:s}=e,u=e.offers??ee(r,a),g=e.testId??"arrange",y=C(e.allow,"sort")&&u.sorts.length>1,m=C(e.allow,"group")&&u.groups.length>0,F=C(e.allow,"filter")?ce(u,i,e.filters):[],L=e.chips?pe(F,e.filters):[],H=F.filter(t=>!L.includes(t)),G=H.length>0,_=e.query!==!1&&e.allow!==!1,w=we(e.noun,e.kept),v=e.past&&e.past.count>0?e.past:null;if(!y&&!m&&!G&&!_&&!w&&!v)return null;let z=t=>JSON.stringify(re(t)),R=`${g}|${a}`,p={current:q.get(R)??{words:new Set,latest:null,at:0}};q.set(R,p.current),p.current.latest&&Date.now()-p.current.at>1500&&!p.current.words.has(z(o))&&(p.current={words:new Set,latest:null,at:0},q.set(R,p.current));let d=p.current.latest??o,b=t=>{let l={...p.current.latest??o,...t};for(let c of Object.keys(l))l[c]===void 0&&delete l[c];p.current.latest=l,p.current.at=Date.now(),p.current.words.add(z(l)),s(l)},f=d.filter??[],O=t=>{let l=f.filter((c,I)=>I!==t);b({filter:l.length>0?l:void 0})},A=t=>f.some(l=>l.key===t.key&&l.value===t.value),te=t=>A(t)?O(f.findIndex(l=>l.key===t.key&&l.value===t.value)):b({filter:[...f,t]}),T=d.sort?u.sorts.find(t=>t.key===d.sort.by):void 0,j=d.group?u.groups.find(t=>t.key===d.group.by):void 0,ne=me(T),k={schema:r,graph:i,offers:{...u,filters:H},arrangement:d,set:b,toggle:te,has:A,testId:g},ae=(t,l)=>A({key:t,value:l})?O(f.findIndex(c=>c.key===t&&c.value===l)):b({filter:[...f.filter(c=>c.key!==t),{key:t,value:l}]}),oe=d.sort?(0,n.jsxs)(n.Fragment,{children:["Sorted by ",P(T?.label??d.sort.by),(0,n.jsx)("span",{"aria-hidden":"true",children:d.sort.direction==="desc"?" \u2193":" \u2191"})]}):"Sort",ie=d.group?.bucket&&j?.buckets?`, a ${d.group.bucket} each`:"",B=d.group?`Grouped by ${P(j?.label??d.group.by)}${ie}`:"Group";return(0,n.jsxs)("div",{"data-testid":`${g}-bar`,role:"group","aria-label":"Arrange",className:"graview-arrange",style:e.style,onPointerEnter:x.prefetch,onFocus:x.prefetch,children:[(0,n.jsx)("style",{children:xe}),(0,n.jsxs)("div",{className:"graview-arrange-line",children:[w?(0,n.jsxs)("span",{className:"graview-arrange-count","data-testid":`${g}-count`,children:[w.kept?(0,n.jsx)("span",{"data-testid":`${g}-kept`,children:w.kept}):null,w.words]}):null,v?(0,n.jsxs)("button",{type:"button",className:"graview-arrange-open","data-testid":`${g}-past`,title:`${M(v.count)} more behind the horizon \u2014 press to widen the view to the past`,onClick:t=>{let l=t.currentTarget.closest("[data-graview-view]"),c=t.currentTarget;v.widen();let I=0,W=()=>{if(document.activeElement!==c&&document.activeElement!==document.body&&c.isConnected)return;let $=l?.querySelector('[role="group"][aria-label="Arrange"] :is(button, input)');if($&&$!==c&&$.isConnected)return $.focus({preventScroll:!0});++I<120&&requestAnimationFrame(W)};requestAnimationFrame(W)},children:["+",M(v.count)," past"]}):null,f.map((t,l)=>{let c=ye(r,i,u,t);return(0,n.jsxs)("span",{className:"graview-arrange-token","data-testid":`${g}-condition`,children:[c,(0,n.jsx)("button",{type:"button","aria-label":`Remove: ${c}`,title:"Remove",onClick:()=>O(l),children:"\xD7"})]},`${t.key}:${t.value}`)}),y?(0,n.jsx)("span",{className:"graview-arrange-part graview-arrange-one",children:(0,n.jsx)(E,{testId:`${g}-sort`,value:d.sort?.by??"",set:d.sort!==void 0,label:"Sort",name:d.sort?`Sorted by ${P(T?.label??d.sort.by)}, ${ne[d.sort.direction].toLowerCase()}`:"Sort",list:t=>(0,n.jsx)(N,{which:"sort",done:t,...k}),children:oe})}):null,m?(0,n.jsx)("span",{className:"graview-arrange-part graview-arrange-one",children:(0,n.jsx)(E,{testId:`${g}-group`,value:d.group?.by??"",set:d.group!==void 0,label:"Group",name:B,list:t=>(0,n.jsx)(N,{which:"group",done:t,...k}),children:B})}):null,G?(0,n.jsx)("span",{className:"graview-arrange-part",children:(0,n.jsx)(E,{testId:`${g}-add`,value:"",set:!1,label:"Filter",name:f.length>0?`Filter \u2014 ${f.length} on`:"Filter",list:t=>(0,n.jsx)(N,{which:"filter",done:t,...k}),children:"Filter"})}):null,y||m?(0,n.jsx)("span",{className:"graview-arrange-part graview-arrange-all",children:(0,n.jsx)(E,{testId:`${g}-all`,value:"",set:!1,label:"Arrange",name:"Arrange: sort and group",list:t=>(0,n.jsx)(N,{which:"all",done:t,parts:{sort:y,group:m,filter:!1},...k}),children:"Arrange"})}):null,_?(0,n.jsxs)("label",{className:"graview-arrange-words-at",children:[(0,n.jsx)("span",{style:X,children:"Find"}),(0,n.jsx)("input",{type:"search",className:"graview-arrange-words","data-testid":`${g}-query`,value:d.query??"",placeholder:"Find\u2026",onChange:t=>b({query:t.target.value.length>0?t.target.value:void 0})})]}):null,L.length>0&&e.chips?(0,n.jsx)(h.Suspense,{fallback:null,children:(0,n.jsx)(he,{offers:L,chips:e.chips,schema:r,graph:i,kind:a,arrangement:d,has:A,choose:ae,testId:g})}):null,e.end]})]})}function we(e,r){if(!r)return null;let i=r.shown!==r.of;if(!e)return i?{words:"",kept:`${r.shown} of ${r.of}`}:null;let a=r.of===1?e.one:e.many;return i?{words:` ${a}`,kept:`${r.shown} of ${r.of}`}:{words:`${r.of} ${a}`}}function E({testId:e,value:r,set:i,label:a,name:o,list:s,children:u}){let g=Q("arrange",{align:"start"}),y=(0,h.useRef)(null);return(0,h.useEffect)(()=>{g.open&&y.current?.querySelector('[aria-pressed="true"]')?.focus({preventScroll:!0})},[g.open]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("button",{type:"button",className:"graview-arrange-open","data-testid":e,"data-set":i?"":void 0,value:r,"aria-label":o,...g.trigger,onClick:g.toggle,children:[u,(0,n.jsx)(be,{})]}),g.open?(0,n.jsx)("div",{...g.pane,ref:m=>{g.pane.ref(m),y.current=m},role:"group","aria-label":a,"data-testid":"arrange-list","data-arrange":e,className:"graview-arrange-list",style:J,onKeyDown:ve,children:s(()=>g.setOpen(!1))}):null]})}function ve(e){if(!["ArrowDown","ArrowUp","Home","End"].includes(e.key))return;let r=[...e.currentTarget.querySelectorAll("button:not([disabled]), input")];if(r.length===0)return;let i=r.indexOf(document.activeElement);if(document.activeElement instanceof HTMLInputElement&&document.activeElement.type==="date"&&(e.key==="ArrowUp"||e.key==="ArrowDown"))return;e.preventDefault();let a=e.key==="Home"?0:e.key==="End"?r.length-1:e.key==="ArrowDown"?(i+1)%r.length:(i-1+r.length)%r.length;r[a].focus()}function be(){return(0,n.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 10 10","aria-hidden":"true",focusable:"false",style:{flex:"0 0 auto",opacity:.7},children:(0,n.jsx)("path",{d:"M2 3.5 L5 6.5 L8 3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}var xe=`
1
+ var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{d as C,e as re}from"./chunk.UDU545CL.js";import{e as ee}from"./chunk.7VAHHEDX.js";import{b as S}from"./chunk.5AD2QHWH.js";import{k as X}from"./chunk.3FKKH2XU.js";import{G as se,Ka as V,Ta as J,V as Z,Xa as Q}from"./chunk.VLX7YWVH.js";import{a as K}from"./chunk.SDO3U72B.js";import{T as Y,Z as M,la as U}from"./chunk.IQGSEAQ2.js";import{b as D}from"./chunk.AJZBJBMO.js";var h=D(se(),1);var n=D(Z(),1),Re=9,le=40,ge=2;function de(e){let r=new Map;for(let i of e.allNodes())r.set(i.kind,(r.get(i.kind)??0)+1);return r}var ue=(e,r)=>(e.far??[]).reduce((i,a)=>i+(r.get(a)??0),0);function ce(e,r,i){if(i)return i.flatMap(s=>e.filters.filter(u=>u.key===s));let a=de(r),o=new Set(e.filters.filter(s=>s.about==="edge"&&ue(s,a)>le).map(s=>s.key));return e.filters.filter(s=>s.about==="edge"?!o.has(s.key):s.about==="via"?o.has(s.key.split(".")[0]):!0)}function pe(e,r){let i=e.filter(a=>a.about==="field"&&a.type==="choice"&&(a.options?.length??0)>0);return r?i:i.slice(0,ge)}var fe=520;function ye(e,r,i,a){let o=i.filters.find(s=>s.key===a.key);if(!o)return`${a.key}: ${a.value}`;if(o.about==="is")return a.value.charAt(0).toUpperCase()+a.value.slice(1);if(o.about==="via")return`${o.label}: ${S(e.tryDefinition(o.far?.[0]??""),o.key.split(".")[1],a.value)}`;if(o.about==="edge"){if(a.value==="*")return`${o.label}: anything`;if(a.value==="none")return`${o.label}: nothing`;let s=r.getNode(a.value);return`${o.label}: ${s?U(e.tryDefinition(s.kind),s):a.value}`}if(o.type==="date"){let[s,u]=a.value.split(":");return`${o.label} ${s} ${u?Y(u):""}`.trim()}if(o.type==="boolean")return`${o.label}: ${a.value==="true"?"yes":"no"}`;if(o.type==="number"){let s=a.value.lastIndexOf(":"),u=a.value.slice(0,Math.max(0,s));if(u==="at-most"||u==="at-least")return`${o.label}: ${u==="at-most"?"at most":"at least"} ${S(e.tryDefinition(i.kind),o.key,Number(a.value.slice(s+1)))}`}return o.type==="text"?`${o.label}: ${a.value}`:`${o.label}: ${S(e.tryDefinition(i.kind),o.key,a.value)}`}var P=e=>/^[A-Z][a-z]/.test(e)?e.charAt(0).toLowerCase()+e.slice(1):e;function me(e){return e?.type==="date"?{asc:"Earliest first",desc:"Latest first"}:e?.type==="number"?{asc:"Lowest first",desc:"Highest first"}:e?.type==="boolean"?{asc:"No first",desc:"Yes first"}:e?.type==="choice"?{asc:"In their order",desc:"In reverse order"}:{asc:"A to Z",desc:"Z to A"}}var x=V(K(()=>(__graviewPreload(import.meta.url,["./chunk.SADHOSRC.js","./chunk.4DZOAB4D.js","./chunk.UDU545CL.js","./chunk.7VAHHEDX.js","./chunk.75JQCTR6.js","./chunk.5IEZF433.js","./chunk.5AD2QHWH.js","./chunk.3FKKH2XU.js","./chunk.DLWFULWE.js","./chunk.VLX7YWVH.js","./chunk.SDO3U72B.js","./chunk.IQGSEAQ2.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.37I45R6V.js")))),N=x.part((e,r)=>(0,n.jsx)(e.ArrangeLists,{...r}),{what:"This list",quiet:!0}),he=x.part((e,r)=>(0,n.jsx)(e.ArrangeChips,{...r}),{what:"This list",quiet:!0}),Oe=()=>x.load(),q=new Map;function Te(e){let{schema:r,graph:i,kind:a,arrangement:o,onChange:s}=e,u=e.offers??ee(r,a),g=e.testId??"arrange",y=C(e.allow,"sort")&&u.sorts.length>1,m=C(e.allow,"group")&&u.groups.length>0,F=C(e.allow,"filter")?ce(u,i,e.filters):[],L=e.chips?pe(F,e.filters):[],H=F.filter(t=>!L.includes(t)),G=H.length>0,_=e.query!==!1&&e.allow!==!1,w=we(e.noun,e.kept),v=e.past&&e.past.count>0?e.past:null;if(!y&&!m&&!G&&!_&&!w&&!v)return null;let z=t=>JSON.stringify(re(t)),R=`${g}|${a}`,p={current:q.get(R)??{words:new Set,latest:null,at:0}};q.set(R,p.current),p.current.latest&&Date.now()-p.current.at>1500&&!p.current.words.has(z(o))&&(p.current={words:new Set,latest:null,at:0},q.set(R,p.current));let d=p.current.latest??o,b=t=>{let l={...p.current.latest??o,...t};for(let c of Object.keys(l))l[c]===void 0&&delete l[c];p.current.latest=l,p.current.at=Date.now(),p.current.words.add(z(l)),s(l)},f=d.filter??[],O=t=>{let l=f.filter((c,I)=>I!==t);b({filter:l.length>0?l:void 0})},A=t=>f.some(l=>l.key===t.key&&l.value===t.value),te=t=>A(t)?O(f.findIndex(l=>l.key===t.key&&l.value===t.value)):b({filter:[...f,t]}),T=d.sort?u.sorts.find(t=>t.key===d.sort.by):void 0,j=d.group?u.groups.find(t=>t.key===d.group.by):void 0,ne=me(T),k={schema:r,graph:i,offers:{...u,filters:H},arrangement:d,set:b,toggle:te,has:A,testId:g},ae=(t,l)=>A({key:t,value:l})?O(f.findIndex(c=>c.key===t&&c.value===l)):b({filter:[...f.filter(c=>c.key!==t),{key:t,value:l}]}),oe=d.sort?(0,n.jsxs)(n.Fragment,{children:["Sorted by ",P(T?.label??d.sort.by),(0,n.jsx)("span",{"aria-hidden":"true",children:d.sort.direction==="desc"?" \u2193":" \u2191"})]}):"Sort",ie=d.group?.bucket&&j?.buckets?`, a ${d.group.bucket} each`:"",B=d.group?`Grouped by ${P(j?.label??d.group.by)}${ie}`:"Group";return(0,n.jsxs)("div",{"data-testid":`${g}-bar`,role:"group","aria-label":"Arrange",className:"graview-arrange",style:e.style,onPointerEnter:x.prefetch,onFocus:x.prefetch,children:[(0,n.jsx)("style",{children:xe}),(0,n.jsxs)("div",{className:"graview-arrange-line",children:[w?(0,n.jsxs)("span",{className:"graview-arrange-count","data-testid":`${g}-count`,children:[w.kept?(0,n.jsx)("span",{"data-testid":`${g}-kept`,children:w.kept}):null,w.words]}):null,v?(0,n.jsxs)("button",{type:"button",className:"graview-arrange-open","data-testid":`${g}-past`,title:`${M(v.count)} more behind the horizon \u2014 press to widen the view to the past`,onClick:t=>{let l=t.currentTarget.closest("[data-graview-view]"),c=t.currentTarget;v.widen();let I=0,W=()=>{if(document.activeElement!==c&&document.activeElement!==document.body&&c.isConnected)return;let $=l?.querySelector('[role="group"][aria-label="Arrange"] :is(button, input)');if($&&$!==c&&$.isConnected)return $.focus({preventScroll:!0});++I<120&&requestAnimationFrame(W)};requestAnimationFrame(W)},children:["+",M(v.count)," past"]}):null,f.map((t,l)=>{let c=ye(r,i,u,t);return(0,n.jsxs)("span",{className:"graview-arrange-token","data-testid":`${g}-condition`,children:[c,(0,n.jsx)("button",{type:"button","aria-label":`Remove: ${c}`,title:"Remove",onClick:()=>O(l),children:"\xD7"})]},`${t.key}:${t.value}`)}),y?(0,n.jsx)("span",{className:"graview-arrange-part graview-arrange-one",children:(0,n.jsx)(E,{testId:`${g}-sort`,value:d.sort?.by??"",set:d.sort!==void 0,label:"Sort",name:d.sort?`Sorted by ${P(T?.label??d.sort.by)}, ${ne[d.sort.direction].toLowerCase()}`:"Sort",list:t=>(0,n.jsx)(N,{which:"sort",done:t,...k}),children:oe})}):null,m?(0,n.jsx)("span",{className:"graview-arrange-part graview-arrange-one",children:(0,n.jsx)(E,{testId:`${g}-group`,value:d.group?.by??"",set:d.group!==void 0,label:"Group",name:B,list:t=>(0,n.jsx)(N,{which:"group",done:t,...k}),children:B})}):null,G?(0,n.jsx)("span",{className:"graview-arrange-part",children:(0,n.jsx)(E,{testId:`${g}-add`,value:"",set:!1,label:"Filter",name:f.length>0?`Filter \u2014 ${f.length} on`:"Filter",list:t=>(0,n.jsx)(N,{which:"filter",done:t,...k}),children:"Filter"})}):null,y||m?(0,n.jsx)("span",{className:"graview-arrange-part graview-arrange-all",children:(0,n.jsx)(E,{testId:`${g}-all`,value:"",set:!1,label:"Arrange",name:"Arrange: sort and group",list:t=>(0,n.jsx)(N,{which:"all",done:t,parts:{sort:y,group:m,filter:!1},...k}),children:"Arrange"})}):null,_?(0,n.jsxs)("label",{className:"graview-arrange-words-at",children:[(0,n.jsx)("span",{style:X,children:"Find"}),(0,n.jsx)("input",{type:"search",className:"graview-arrange-words","data-testid":`${g}-query`,value:d.query??"",placeholder:"Find\u2026",onChange:t=>b({query:t.target.value.length>0?t.target.value:void 0})})]}):null,L.length>0&&e.chips?(0,n.jsx)(h.Suspense,{fallback:null,children:(0,n.jsx)(he,{offers:L,chips:e.chips,schema:r,graph:i,kind:a,arrangement:d,has:A,choose:ae,testId:g})}):null,e.end]})]})}function we(e,r){if(!r)return null;let i=r.shown!==r.of;if(!e)return i?{words:"",kept:`${r.shown} of ${r.of}`}:null;let a=r.of===1?e.one:e.many;return i?{words:` ${a}`,kept:`${r.shown} of ${r.of}`}:{words:`${r.of} ${a}`}}function E({testId:e,value:r,set:i,label:a,name:o,list:s,children:u}){let g=Q("arrange",{align:"start"}),y=(0,h.useRef)(null);return(0,h.useEffect)(()=>{g.open&&y.current?.querySelector('[aria-pressed="true"]')?.focus({preventScroll:!0})},[g.open]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("button",{type:"button",className:"graview-arrange-open","data-testid":e,"data-set":i?"":void 0,value:r,"aria-label":o,...g.trigger,onClick:g.toggle,children:[u,(0,n.jsx)(be,{})]}),g.open?(0,n.jsx)("div",{...g.pane,ref:m=>{g.pane.ref(m),y.current=m},role:"group","aria-label":a,"data-testid":"arrange-list","data-arrange":e,className:"graview-arrange-list",style:J,onKeyDown:ve,children:s(()=>g.setOpen(!1))}):null]})}function ve(e){if(!["ArrowDown","ArrowUp","Home","End"].includes(e.key))return;let r=[...e.currentTarget.querySelectorAll("button:not([disabled]), input")];if(r.length===0)return;let i=r.indexOf(document.activeElement);if(document.activeElement instanceof HTMLInputElement&&document.activeElement.type==="date"&&(e.key==="ArrowUp"||e.key==="ArrowDown"))return;e.preventDefault();let a=e.key==="Home"?0:e.key==="End"?r.length-1:e.key==="ArrowDown"?(i+1)%r.length:(i-1+r.length)%r.length;r[a].focus()}function be(){return(0,n.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 10 10","aria-hidden":"true",focusable:"false",style:{flex:"0 0 auto",opacity:.7},children:(0,n.jsx)("path",{d:"M2 3.5 L5 6.5 L8 3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}var xe=`
2
2
  .graview-arrange{container-type:inline-size;box-sizing:border-box;width:100%;min-width:0;max-width:100%}
3
3
  .graview-arrange-line{display:flex;flex-wrap:wrap;align-items:center;gap:2px 6px;min-width:0;font-size:.875rem;line-height:1.35;color:var(--graview-ink-muted)}
4
4
  .graview-arrange-count{margin-right:2px;color:var(--graview-ink-muted)}
@@ -0,0 +1 @@
1
+ import{k as a,l as b,m as c,n as d,o as e,p as f,q as g,r as h,s as i}from"./chunk.O7HHNQK4.js";import"./chunk.BJUUSIQY.js";import"./chunk.TQ2G4AM4.js";import"./chunk.X36BYTEG.js";import"./chunk.LDMBJC3B.js";import"./chunk.XOZU4OFA.js";import"./chunk.G7YLK4PX.js";import"./chunk.GH5UBSQI.js";import"./chunk.2JEN2RCB.js";import"./chunk.75JQCTR6.js";import"./chunk.5IEZF433.js";import"./chunk.5AD2QHWH.js";import"./chunk.3FKKH2XU.js";import"./chunk.DLWFULWE.js";import"./chunk.VLX7YWVH.js";import"./chunk.SDO3U72B.js";import"./chunk.IQGSEAQ2.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";export{i as GhostTray,h as InlineAiMenu,g as askAgain,c as askInline,a as askOf,b as drawPanel,d as heldSuggestion,e as suggestOnce,f as takeOffer};
@@ -0,0 +1 @@
1
+ import{a}from"./chunk.ATHLE33D.js";import"./chunk.T4TRJDBF.js";import"./chunk.APUQIELA.js";import"./chunk.S6QZBWCJ.js";import"./chunk.LTOQ22ZJ.js";import"./chunk.2TCOLAL2.js";import"./chunk.FUPYIOXZ.js";import"./chunk.3OEODIHB.js";import"./chunk.X36BYTEG.js";import{b as n}from"./chunk.K2PXP5H6.js";import"./chunk.U5P23GO7.js";import"./chunk.GH5UBSQI.js";import"./chunk.GZHZLJBF.js";import"./chunk.3SAESG6X.js";import"./chunk.OJGHDWI6.js";import"./chunk.F6BNFLQM.js";import"./chunk.75JQCTR6.js";import"./chunk.5IEZF433.js";import"./chunk.5AD2QHWH.js";import"./chunk.3FKKH2XU.js";import"./chunk.DLWFULWE.js";import{V as i}from"./chunk.VLX7YWVH.js";import"./chunk.SDO3U72B.js";import"./chunk.IQGSEAQ2.js";import"./chunk.FQLNBIQ5.js";import{b as o}from"./chunk.AJZBJBMO.js";var e=o(i(),1);function m({entries:d,style:l,headingStyle:p,className:r}){return(0,e.jsxs)("section",{...r?{className:r}:{},"data-testid":"record-ai","aria-label":"What AI did here",style:{display:"grid",gap:10,...l},children:[(0,e.jsx)("h2",{style:p??{margin:0,fontSize:"1rem"},children:"What AI did here"}),(0,e.jsx)("ol",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:8,fontSize:"0.875rem"},children:d.slice(0,8).map(t=>(0,e.jsx)(n,{entry:t,undo:s=>(0,e.jsx)(a,{batch:s})},t.id))})]})}export{m as RecordInteractions};
@@ -1 +1 @@
1
- import{a as D,c as L}from"./chunk.NTC2H5ZX.js";import{a as R,f as T,g as W,h as I,i as K}from"./chunk.B3WVCSW5.js";import{Td as N,he as j}from"./chunk.Q4MI53KK.js";var J=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),G=e=>e?._zod?.def;function S(e){let t=G(e);for(;t&&(t.type==="optional"||t.type==="default"||t.type==="nullable"||t.type==="prefault");)t=G(t.innerType);return t}function q(e){if(e?.type==="boolean")return["true","false"];if(e?.type==="array"&&(e=S(e.element)),e?.type==="enum")return(e.entries?Object.values(e.entries):e.values??[]).filter(t=>typeof t=="string")}var A=e=>e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[-_]/g," ").replace(/^./,t=>t.toUpperCase());function _(e,t,s){let d=e.tryDefinition(t);if(!d)return[];let c=new Set(d.display?.hide??[]),a=[];for(let[l,o]of Object.entries(d.fields.shape??{})){if(l==="id"||l==="kind"||l==="label"||c.has(l))continue;let i=S(o);if(i?.type==="array"||i?.type==="object"||i?.type==="record")continue;let f=q(i);a.push({key:l,label:A(l),...f?{options:f}:{}})}let g=new Map;for(let[l,o]of Object.entries(d.edges??{}))g.set(l,o.to==="*"?[]:[...o.to]);for(let l of e.definitions)if(l.kind!==t)for(let[o,i]of Object.entries(l.edges??{}))!g.has(o)&&(i.to==="*"||i.to.includes(t))&&g.set(o,[l.kind]);let u=[];for(let[l,o]of g){a.push({key:l,label:A(l)});let i=s&&o.length===1&&o[0]!==t?e.tryDefinition(o[0]):void 0;for(let[f,p]of Object.entries(i?.fields.shape??{})){let y=S(p);y?.type==="enum"&&!i?.display?.hide?.includes(f)&&u.push({key:`${l}.${f}`,label:`${A(l)} \xB7 ${A(f)}`,options:q(y)})}}return a.push(...u),a.push({key:"is",label:"Is",options:d.lifecycle?["current","past","any","flagged","clear"]:["flagged","clear"]}),a}var C=e=>e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function F(e,t,s,d={}){if(s==null)return{ok:!0};if(!J(s))return{ok:!1,says:'A filter is an object of a field and the value it keeps, like { where: { stage: "building" } }.'};let c=Object.entries(s);if(c.length===0)return{ok:!0};let a=[];for(let o of t)for(let i of _(e,o,d.through===!0))a.some(f=>f.key===i.key)||a.push(i);let g=t[0]?e.tryDefinition(t[0]):void 0,u=g?g.plural??`${A(g.kind)}s`:"These",l=[];for(let[o,i]of c){let f=a.find(y=>y.key===o);if(!f)return{ok:!1,says:`${u.replace(/^./,y=>y.toUpperCase())} have no field "${o}" to filter by${a.length>0?`; they filter by ${C(a.map(y=>y.key))}`:""}.`};if(typeof i!="string"&&typeof i!="number"&&typeof i!="boolean")return{ok:!1,says:`The filter on "${o}" is ${Array.isArray(i)?"a list":i===null?"null":`a ${typeof i}`}; it keeps one value: a word, a number, or true or false.`};let p=String(i);if(p.trim().length===0)return{ok:!1,says:`The filter on "${o}" keeps nothing; give it a value, or leave "${o}" out.`};if(p.includes(","))return{ok:!1,says:`The filter on "${o}" holds a comma, which an address reads as a second filter; keep one value.`};if(f.options&&f.options.length>0&&!f.options.includes(p))return{ok:!1,says:`${f.label} has no choice "${p}"; its choices are ${C(f.options.map(y=>`"${y}"`))}.`};l.push(`${o}:${p}`)}return{ok:!0,filter:l.join(",")}}var U=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");function V(e,t){let s=e.find(a=>a.as===t);if(s)return s;let d=t.trim().toLowerCase(),c=U(t);return e.find(a=>a.title!==void 0&&a.title.trim().toLowerCase()===d)??(c?e.find(a=>a.as===c||a.title!==void 0&&U(a.title)===c):void 0)}function ee(e){let t=[];for(let s of e){if(typeof s!="object"||s===null)continue;let{as:d,slug:c,title:a,kind:g}=s,u=typeof d=="string"&&d.length>0?d:typeof c=="string"&&c.length>0?c:void 0;!u||t.some(l=>l.as===u)||t.push({as:u,title:typeof a=="string"?a:u,kind:typeof g=="string"?g:""})}return t}var M=e=>` Its places: ${e.map(t=>typeof t=="string"?`"${t}"`:t.title&&t.title!==t.as?`"${t.as}" (${t.title})`:`"${t.as}"`).join(", ")||"none"}.`;var m=e=>`"${e.length>80?`${e.slice(0,79)}\u2026`:e}"`,O=(e,t)=>`${"place"in e?`The place ${m(e.place)}`:`${m(e.record)} is no record this viewer may see and`} is no place of this app: it goes nowhere.${M(t)}`;function E(e){let t={};for(let s of e.split(",")){let d=s.indexOf(":");d>0&&(t[s.slice(0,d).trim()]=s.slice(d+1).trim())}return t}function ae(e,t=new Set){return e.kinds.filter(s=>!t.has(s)).map(s=>({slug:N(e,s).slice(1),kind:s}))}function le(e,t,s={}){let d=[],c;for(let g of t){if(typeof g!="object"||g===null)continue;let{as:u,slug:l,title:o,kind:i,over:f,hidden:p,name:y}=g,h=typeof u=="string"&&u.length>0?u:typeof l=="string"&&l.length>0?l:void 0;if(h){if(typeof i!="string"||i.length===0){h===j&&typeof o=="string"&&o.length>0&&(c=o);continue}d.push({kind:i,title:typeof o=="string"&&o.length>0?o:h,as:h,...Array.isArray(f)&&f.every(n=>typeof n=="string")?{over:f}:{},...p===!0?{hidden:!0}:{},...typeof y=="string"?{name:y}:{}})}}let a=s.pages??(c!==void 0?{scene:c}:void 0);return L(e,d,{...a?{pages:a}:{},...s.kept?{kept:s.kept}:{}})}var H=(e,t)=>e.find(s=>s.is==="list"&&(s.as===t||s.kind===t));function Z(e,t){let s=t.places.filter((r,k,w)=>r.is!=="list"&&w.findIndex(b=>b.as===r.as)===k),d=[...new Set(t.places.map(r=>r.as))],c=[...new Set([...t.places.filter(r=>r.is==="list").map(r=>r.as),...t.lists.map(r=>r.slug).filter(r=>!d.includes(r))])],a;if(e.section!==void 0&&e.section!==null){if(typeof e.section!="string"||D(e.section).length===0||e.section.length>120)return{ok:!1,says:`The section ${typeof e.section=="string"?m(e.section):"asked for"} names nothing on a page: a section is a heading's words or an element's id, like "shipping-soon". It goes nowhere.`};a=e.section}let g=a!==void 0?{section:a}:{};if("record"in e&&t.sees(e.record))return e.where!==void 0&&e.where!==null?{ok:!1,says:`${m(e.record)} is one record, and a filter narrows a list or a place: it goes nowhere. Go to { place, where } for a list narrowed.`}:{ok:!0,arrival:{record:e.record,...g}};let u="place"in e?e.place:e.record,l=V(t.places,u),o=l?.is==="list"?void 0:l,i=o?void 0:l?.is==="list"?l:H(t.places,u),f=o||i?void 0:t.lists.find(r=>r.slug===u||r.kind===u),p=i?i.kind??void 0:f?.kind;if(!o&&p===void 0)return{ok:!1,says:`${O(e,s)}${B(c)}`};let y=o?o.kind?[o.kind]:[]:[p],h;if(e.where!==void 0&&e.where!==null){if(!t.schema||y.length===0)return{ok:!1,says:`The place ${m(u)} cannot be narrowed here: it goes nowhere.`};let r=F(t.schema,y,e.where,{through:p!==void 0});if(!r.ok)return{ok:!1,says:`The filter on ${m(u)} goes nowhere: ${r.says}`};h=r.filter}let n=h?{filter:h}:{};return{ok:!0,arrival:o?{place:o.as,...n,...g}:{list:p,...n,...g}}}var B=e=>e.length===0?"":` Its lists: ${e.slice(0,8).map(t=>`"${t}"`).join(", ")}${e.length>8?` and ${e.length-8} more`:""}.`,z="http://www.w3.org/1999/xhtml",Q="http://www.w3.org/2000/svg",X=e=>{let t=e;return t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||e.type==="click"&&typeof t.button=="number"&&t.button!==0};function de(e){let t=new WeakSet,s=new WeakSet,d=new WeakMap,c=new WeakMap,a=n=>Z(n,{sees:e.sees,places:e.places(),lists:e.lists?.()??[],...e.schema?{schema:e.schema}:{}}),g=n=>{let r=a(n);return r.ok?e.onNavigate?.(r.arrival):e.onLost?.(r.says),r.ok},u=n=>{let r=n.getAttribute("data-record"),k=n.getAttribute("data-place"),w=n.getAttribute("data-filter"),b=n.getAttribute("data-section"),v={...w?{where:E(w)}:{},...b?{section:b}:{}};if(r)return{record:r,...v};if(k)return{place:k,...v}},l=n=>{if(!e.hrefOf)return;let r=u(n),k=r?a(r):void 0;return k?.ok?e.hrefOf(k.arrival):void 0},o=n=>n.hasAttribute("tabindex")?!1:(n.setAttribute("tabindex","0"),t.add(n),!0),i=n=>{t.delete(n)&&n.removeAttribute("tabindex")},f=n=>{s.delete(n)&&n.getAttribute("role")==="link"&&n.removeAttribute("role")},p=n=>{let r=d.get(n);r&&(d.delete(n),n.getAttribute("href")===r.href&&n.removeAttribute("href"),r.target!==null&&!n.hasAttribute("target")&&n.setAttribute("target",r.target))},y=n=>{let r=c.get(n);r&&(c.delete(n),i(r))},h={link(n){if(!W(n,[...n.querySelectorAll("input, select, textarea")].some(R))){if(!n.hasAttribute("data-graview-link"))return;n.removeAttribute("data-graview-link"),f(n),i(n),p(n),y(n);return}n.hasAttribute("data-graview-link")||n.setAttribute("data-graview-link","");let k=n.localName==="a"&&(n.namespaceURI===z||n.namespaceURI===Q),w=n.getAttribute("href"),b=d.get(n),v=w!==null&&b?.href!==w,$=k&&!v?l(n):void 0;if($!==void 0){w!==$&&n.setAttribute("href",$),d.set(n,{href:$,target:b?b.target:n.getAttribute("target")}),n.removeAttribute("target"),f(n),i(n);return}if(v?d.delete(n):p(n),I(n,n.querySelectorAll("a"))){f(n),i(n),y(n);return}if(!n.hasAttribute("role")&&(k||T(n))&&(n.setAttribute("role","link"),s.add(n)),n.localName==="tr"&&n.namespaceURI===z){i(n);let x=[...n.children].find(P=>P.localName==="td"||P.localName==="th");c.get(n)!==x&&y(n),x&&!c.has(n)&&o(x)&&c.set(n,x);return}n.localName!=="button"&&o(n)},refresh(n){for(let r of n.querySelectorAll("[data-record], [data-place], [data-graview-link]"))h.link(r)},pressed(n,r,k){if(n.type!=="click"&&!(n.type==="keydown"&&n.key==="Enter"))return!1;let w=K(r,k,b=>b.hasAttribute("data-graview-link"));return w?(n.stopPropagation(),d.has(w)&&X(n)||(n.preventDefault(),h.follow(w)),!0):!1},follow(n){let r=u(n);r&&g(r)},go:g};return h}export{ee as a,M as b,m as c,O as d,E as e,ae as f,le as g,Z as h,de as i};
1
+ import{a as D,c as L}from"./chunk.7SRSE5IS.js";import{a as R,f as T,g as W,h as I,i as K}from"./chunk.B3WVCSW5.js";import{Vd as N,je as j}from"./chunk.IQGSEAQ2.js";var J=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),G=e=>e?._zod?.def;function S(e){let t=G(e);for(;t&&(t.type==="optional"||t.type==="default"||t.type==="nullable"||t.type==="prefault");)t=G(t.innerType);return t}function q(e){if(e?.type==="boolean")return["true","false"];if(e?.type==="array"&&(e=S(e.element)),e?.type==="enum")return(e.entries?Object.values(e.entries):e.values??[]).filter(t=>typeof t=="string")}var A=e=>e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[-_]/g," ").replace(/^./,t=>t.toUpperCase());function _(e,t,s){let d=e.tryDefinition(t);if(!d)return[];let c=new Set(d.display?.hide??[]),a=[];for(let[l,o]of Object.entries(d.fields.shape??{})){if(l==="id"||l==="kind"||l==="label"||c.has(l))continue;let i=S(o);if(i?.type==="array"||i?.type==="object"||i?.type==="record")continue;let f=q(i);a.push({key:l,label:A(l),...f?{options:f}:{}})}let g=new Map;for(let[l,o]of Object.entries(d.edges??{}))g.set(l,o.to==="*"?[]:[...o.to]);for(let l of e.definitions)if(l.kind!==t)for(let[o,i]of Object.entries(l.edges??{}))!g.has(o)&&(i.to==="*"||i.to.includes(t))&&g.set(o,[l.kind]);let u=[];for(let[l,o]of g){a.push({key:l,label:A(l)});let i=s&&o.length===1&&o[0]!==t?e.tryDefinition(o[0]):void 0;for(let[f,p]of Object.entries(i?.fields.shape??{})){let y=S(p);y?.type==="enum"&&!i?.display?.hide?.includes(f)&&u.push({key:`${l}.${f}`,label:`${A(l)} \xB7 ${A(f)}`,options:q(y)})}}return a.push(...u),a.push({key:"is",label:"Is",options:d.lifecycle?["current","past","any","flagged","clear"]:["flagged","clear"]}),a}var C=e=>e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function F(e,t,s,d={}){if(s==null)return{ok:!0};if(!J(s))return{ok:!1,says:'A filter is an object of a field and the value it keeps, like { where: { stage: "building" } }.'};let c=Object.entries(s);if(c.length===0)return{ok:!0};let a=[];for(let o of t)for(let i of _(e,o,d.through===!0))a.some(f=>f.key===i.key)||a.push(i);let g=t[0]?e.tryDefinition(t[0]):void 0,u=g?g.plural??`${A(g.kind)}s`:"These",l=[];for(let[o,i]of c){let f=a.find(y=>y.key===o);if(!f)return{ok:!1,says:`${u.replace(/^./,y=>y.toUpperCase())} have no field "${o}" to filter by${a.length>0?`; they filter by ${C(a.map(y=>y.key))}`:""}.`};if(typeof i!="string"&&typeof i!="number"&&typeof i!="boolean")return{ok:!1,says:`The filter on "${o}" is ${Array.isArray(i)?"a list":i===null?"null":`a ${typeof i}`}; it keeps one value: a word, a number, or true or false.`};let p=String(i);if(p.trim().length===0)return{ok:!1,says:`The filter on "${o}" keeps nothing; give it a value, or leave "${o}" out.`};if(p.includes(","))return{ok:!1,says:`The filter on "${o}" holds a comma, which an address reads as a second filter; keep one value.`};if(f.options&&f.options.length>0&&!f.options.includes(p))return{ok:!1,says:`${f.label} has no choice "${p}"; its choices are ${C(f.options.map(y=>`"${y}"`))}.`};l.push(`${o}:${p}`)}return{ok:!0,filter:l.join(",")}}var U=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");function V(e,t){let s=e.find(a=>a.as===t);if(s)return s;let d=t.trim().toLowerCase(),c=U(t);return e.find(a=>a.title!==void 0&&a.title.trim().toLowerCase()===d)??(c?e.find(a=>a.as===c||a.title!==void 0&&U(a.title)===c):void 0)}function ee(e){let t=[];for(let s of e){if(typeof s!="object"||s===null)continue;let{as:d,slug:c,title:a,kind:g}=s,u=typeof d=="string"&&d.length>0?d:typeof c=="string"&&c.length>0?c:void 0;!u||t.some(l=>l.as===u)||t.push({as:u,title:typeof a=="string"?a:u,kind:typeof g=="string"?g:""})}return t}var M=e=>` Its places: ${e.map(t=>typeof t=="string"?`"${t}"`:t.title&&t.title!==t.as?`"${t.as}" (${t.title})`:`"${t.as}"`).join(", ")||"none"}.`;var m=e=>`"${e.length>80?`${e.slice(0,79)}\u2026`:e}"`,O=(e,t)=>`${"place"in e?`The place ${m(e.place)}`:`${m(e.record)} is no record this viewer may see and`} is no place of this app: it goes nowhere.${M(t)}`;function E(e){let t={};for(let s of e.split(",")){let d=s.indexOf(":");d>0&&(t[s.slice(0,d).trim()]=s.slice(d+1).trim())}return t}function ae(e,t=new Set){return e.kinds.filter(s=>!t.has(s)).map(s=>({slug:N(e,s).slice(1),kind:s}))}function le(e,t,s={}){let d=[],c;for(let g of t){if(typeof g!="object"||g===null)continue;let{as:u,slug:l,title:o,kind:i,over:f,hidden:p,name:y}=g,h=typeof u=="string"&&u.length>0?u:typeof l=="string"&&l.length>0?l:void 0;if(h){if(typeof i!="string"||i.length===0){h===j&&typeof o=="string"&&o.length>0&&(c=o);continue}d.push({kind:i,title:typeof o=="string"&&o.length>0?o:h,as:h,...Array.isArray(f)&&f.every(n=>typeof n=="string")?{over:f}:{},...p===!0?{hidden:!0}:{},...typeof y=="string"?{name:y}:{}})}}let a=s.pages??(c!==void 0?{scene:c}:void 0);return L(e,d,{...a?{pages:a}:{},...s.kept?{kept:s.kept}:{}})}var H=(e,t)=>e.find(s=>s.is==="list"&&(s.as===t||s.kind===t));function Z(e,t){let s=t.places.filter((r,k,w)=>r.is!=="list"&&w.findIndex(b=>b.as===r.as)===k),d=[...new Set(t.places.map(r=>r.as))],c=[...new Set([...t.places.filter(r=>r.is==="list").map(r=>r.as),...t.lists.map(r=>r.slug).filter(r=>!d.includes(r))])],a;if(e.section!==void 0&&e.section!==null){if(typeof e.section!="string"||D(e.section).length===0||e.section.length>120)return{ok:!1,says:`The section ${typeof e.section=="string"?m(e.section):"asked for"} names nothing on a page: a section is a heading's words or an element's id, like "shipping-soon". It goes nowhere.`};a=e.section}let g=a!==void 0?{section:a}:{};if("record"in e&&t.sees(e.record))return e.where!==void 0&&e.where!==null?{ok:!1,says:`${m(e.record)} is one record, and a filter narrows a list or a place: it goes nowhere. Go to { place, where } for a list narrowed.`}:{ok:!0,arrival:{record:e.record,...g}};let u="place"in e?e.place:e.record,l=V(t.places,u),o=l?.is==="list"?void 0:l,i=o?void 0:l?.is==="list"?l:H(t.places,u),f=o||i?void 0:t.lists.find(r=>r.slug===u||r.kind===u),p=i?i.kind??void 0:f?.kind;if(!o&&p===void 0)return{ok:!1,says:`${O(e,s)}${B(c)}`};let y=o?o.kind?[o.kind]:[]:[p],h;if(e.where!==void 0&&e.where!==null){if(!t.schema||y.length===0)return{ok:!1,says:`The place ${m(u)} cannot be narrowed here: it goes nowhere.`};let r=F(t.schema,y,e.where,{through:p!==void 0});if(!r.ok)return{ok:!1,says:`The filter on ${m(u)} goes nowhere: ${r.says}`};h=r.filter}let n=h?{filter:h}:{};return{ok:!0,arrival:o?{place:o.as,...n,...g}:{list:p,...n,...g}}}var B=e=>e.length===0?"":` Its lists: ${e.slice(0,8).map(t=>`"${t}"`).join(", ")}${e.length>8?` and ${e.length-8} more`:""}.`,z="http://www.w3.org/1999/xhtml",Q="http://www.w3.org/2000/svg",X=e=>{let t=e;return t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||e.type==="click"&&typeof t.button=="number"&&t.button!==0};function de(e){let t=new WeakSet,s=new WeakSet,d=new WeakMap,c=new WeakMap,a=n=>Z(n,{sees:e.sees,places:e.places(),lists:e.lists?.()??[],...e.schema?{schema:e.schema}:{}}),g=n=>{let r=a(n);return r.ok?e.onNavigate?.(r.arrival):e.onLost?.(r.says),r.ok},u=n=>{let r=n.getAttribute("data-record"),k=n.getAttribute("data-place"),w=n.getAttribute("data-filter"),b=n.getAttribute("data-section"),v={...w?{where:E(w)}:{},...b?{section:b}:{}};if(r)return{record:r,...v};if(k)return{place:k,...v}},l=n=>{if(!e.hrefOf)return;let r=u(n),k=r?a(r):void 0;return k?.ok?e.hrefOf(k.arrival):void 0},o=n=>n.hasAttribute("tabindex")?!1:(n.setAttribute("tabindex","0"),t.add(n),!0),i=n=>{t.delete(n)&&n.removeAttribute("tabindex")},f=n=>{s.delete(n)&&n.getAttribute("role")==="link"&&n.removeAttribute("role")},p=n=>{let r=d.get(n);r&&(d.delete(n),n.getAttribute("href")===r.href&&n.removeAttribute("href"),r.target!==null&&!n.hasAttribute("target")&&n.setAttribute("target",r.target))},y=n=>{let r=c.get(n);r&&(c.delete(n),i(r))},h={link(n){if(!W(n,[...n.querySelectorAll("input, select, textarea")].some(R))){if(!n.hasAttribute("data-graview-link"))return;n.removeAttribute("data-graview-link"),f(n),i(n),p(n),y(n);return}n.hasAttribute("data-graview-link")||n.setAttribute("data-graview-link","");let k=n.localName==="a"&&(n.namespaceURI===z||n.namespaceURI===Q),w=n.getAttribute("href"),b=d.get(n),v=w!==null&&b?.href!==w,$=k&&!v?l(n):void 0;if($!==void 0){w!==$&&n.setAttribute("href",$),d.set(n,{href:$,target:b?b.target:n.getAttribute("target")}),n.removeAttribute("target"),f(n),i(n);return}if(v?d.delete(n):p(n),I(n,n.querySelectorAll("a"))){f(n),i(n),y(n);return}if(!n.hasAttribute("role")&&(k||T(n))&&(n.setAttribute("role","link"),s.add(n)),n.localName==="tr"&&n.namespaceURI===z){i(n);let x=[...n.children].find(P=>P.localName==="td"||P.localName==="th");c.get(n)!==x&&y(n),x&&!c.has(n)&&o(x)&&c.set(n,x);return}n.localName!=="button"&&o(n)},refresh(n){for(let r of n.querySelectorAll("[data-record], [data-place], [data-graview-link]"))h.link(r)},pressed(n,r,k){if(n.type!=="click"&&!(n.type==="keydown"&&n.key==="Enter"))return!1;let w=K(r,k,b=>b.hasAttribute("data-graview-link"));return w?(n.stopPropagation(),d.has(w)&&X(n)||(n.preventDefault(),h.follow(w)),!0):!1},follow(n){let r=u(n);r&&g(r)},go:g};return h}export{ee as a,M as b,m as c,O as d,E as e,ae as f,le as g,Z as h,de as i};
@@ -1 +1 @@
1
- var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{t as P}from"./chunk.WUVXIUA7.js";import{G as M,Ia as S,O as w,T as y,ba as m,ca as I,s as b,w as T,x as A}from"./chunk.CYTTZOYL.js";import{a as p}from"./chunk.SDO3U72B.js";import{b as f}from"./chunk.AJZBJBMO.js";var C=f(M(),1),h=f(y(),1),x=S(p(()=>(__graviewPreload(import.meta.url,["./chunk.IEDCFSN5.js","./chunk.KZUMXT5J.js","./chunk.CGK2PY76.js","./chunk.CYTTZOYL.js","./chunk.SDO3U72B.js","./chunk.Q4MI53KK.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.G2JAYG2Z.js")))),O=x.part((e,n)=>(0,h.jsx)(e.Timeline,{...n}),{what:"The timeline"}),q=()=>x.prefetch();function K({face:e}){return w()?.open?(0,h.jsx)(C.Suspense,{fallback:null,children:(0,h.jsx)(O,{face:e})}):null}var i=f(M(),1),u=f(y(),1),v=new WeakMap,D=e=>{let n=v.get(e);return n||v.set(e,n={ask:null,doors:[],listeners:new Set}),n},k=e=>{for(let n of e.listeners)n()};function g(e,n){let t=D(e);t.ask=n,k(t)}var N=S(p(()=>(__graviewPreload(import.meta.url,["./chunk.36OE6RKG.js","./chunk.IEDCFSN5.js","./chunk.PWAP2GJS.js","./chunk.AHPYNDVA.js","./chunk.FNVGNISQ.js","./chunk.KZUMXT5J.js","./chunk.CGK2PY76.js","./chunk.CYTTZOYL.js","./chunk.SDO3U72B.js","./chunk.Q4MI53KK.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.4MEQUUG4.js")))),B=N.part((e,n)=>{let t=e.NotifySheet;return(0,u.jsx)(t,{...n})},{what:"Notify me"}),W=N.part((e,n)=>{let t=e.NotifiedList;return(0,u.jsx)(t,{...n})},{quiet:!0}),E=(e,n)=>n===void 0&&(e.onBehalfOf??e).id!==void 0;function F(e,n,t){let c=d=>t.tryDefinition(d)?.noun??d.replace(/[-_]+/g," "),o=e.on!==void 0?e.on:e.about.length===1?e.about[0]:void 0;if(e.act!==void 0){let d=o!==void 0&&n(o)!==void 0?o:void 0;return{label:"Notify me when someone does this\u2026",choices:[{on:"act",act:e.act,...d!==void 0?{record:d}:{}},...d!==void 0?[{on:"act",act:e.act}]:[]]}}if(o===void 0)return null;let s=n(o);if(s!==void 0)return{label:"Notify me when this changes\u2026",choices:[{on:"changed",record:o},{on:"act",record:o},{on:"reaches",kind:s,condition:"",record:o}]};let r=b(o)!==null?[b(o)]:T(o)?A(o):[];if(r.length!==1||!t.kinds.includes(r[0]))return null;let l=r[0],a=c(l);return{label:`Notify me when ${/^[aeiou]/i.test(a)?"an":"a"} ${a} is added\u2026`,choices:[{on:"created",kind:l},{on:"changed",kind:l},{on:"reaches",kind:l,condition:""}]}}function L(){let{store:e,principal:n,subscriptions:t,signIn:c}=m(),o=E(n,c);return(0,i.useMemo)(()=>o?s=>{let r=F(s,a=>e.graph.getNode(a)?.kind,e.schema);return r?{id:"notify",items:[{id:"notify-me",label:r.label,run:()=>g(t,{choices:r.choices,returnTo:s.element??null})}],prepare:()=>N.prefetch()}:null}:null,[o,e,t])}var z=[];function U({children:e}){let n=L(),t=(0,i.useMemo)(()=>n?[n]:z,[n]);return(0,u.jsx)(P,{sections:t,children:e})}function V(){let{subscriptions:e}=m(),n=(0,i.useId)(),t=D(e);(0,i.useEffect)(()=>(t.doors.push(n),k(t),()=>{t.doors.splice(t.doors.indexOf(n),1),k(t)}),[t,n]);let c=(0,i.useMemo)(()=>r=>(t.listeners.add(r),()=>void t.listeners.delete(r)),[t]),o=(0,i.useSyncExternalStore)(c,()=>t.ask,()=>null),s=(0,i.useSyncExternalStore)(c,()=>t.doors[0]===n,()=>!1);return!o||!s?null:(0,u.jsx)(i.Suspense,{fallback:null,children:(0,u.jsx)(B,{ask:o,close:()=>g(e,null)})})}function X({choices:e,label:n="Notify me",style:t,className:c,testId:o="notify-me"}){let{principal:s,subscriptions:r,signIn:l}=m();return E(s,l)?(0,u.jsx)("button",{type:"button","data-testid":o,className:c,onClick:a=>g(r,{choices:e,returnTo:a.currentTarget}),style:t,children:n}):null}function G(){let e=I(),n=e?.subscriptions,t=e?(e.principal.onBehalfOf??e.principal).id:void 0,[c,o]=(0,i.useState)(0);return(0,i.useEffect)(()=>{if(t===void 0||!n)return;let s=!0,r=()=>void Promise.resolve(n.list(t)).then(a=>s&&o(a.length),()=>s&&o(0));r();let l=n.onChange?.(r);return()=>{s=!1,l?.()}},[n,t]),c}function Y({style:e}){return G()===0?null:(0,u.jsx)(i.Suspense,{fallback:null,children:(0,u.jsx)(W,{...e?{style:e}:{}})})}export{q as a,K as b,L as c,U as d,V as e,X as f,G as g,Y as h};
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{t as P}from"./chunk.3SAESG6X.js";import{G as M,Ka as S,Q as w,V as y,da as m,ea as I,s as b,w as T,x as A}from"./chunk.VLX7YWVH.js";import{a as p}from"./chunk.SDO3U72B.js";import{b as f}from"./chunk.AJZBJBMO.js";var C=f(M(),1),h=f(y(),1),x=S(p(()=>(__graviewPreload(import.meta.url,["./chunk.UDYFGYJP.js","./chunk.3FKKH2XU.js","./chunk.DLWFULWE.js","./chunk.VLX7YWVH.js","./chunk.SDO3U72B.js","./chunk.IQGSEAQ2.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.UN2IAA5R.js")))),O=x.part((e,n)=>(0,h.jsx)(e.Timeline,{...n}),{what:"The timeline"}),q=()=>x.prefetch();function K({face:e}){return w()?.open?(0,h.jsx)(C.Suspense,{fallback:null,children:(0,h.jsx)(O,{face:e})}):null}var i=f(M(),1),u=f(y(),1),v=new WeakMap,D=e=>{let n=v.get(e);return n||v.set(e,n={ask:null,doors:[],listeners:new Set}),n},k=e=>{for(let n of e.listeners)n()};function g(e,n){let t=D(e);t.ask=n,k(t)}var N=S(p(()=>(__graviewPreload(import.meta.url,["./chunk.5B7NG6WH.js","./chunk.UDYFGYJP.js","./chunk.TMHVYI5R.js","./chunk.R5MLRKAO.js","./chunk.YMXWS4XN.js","./chunk.3FKKH2XU.js","./chunk.DLWFULWE.js","./chunk.VLX7YWVH.js","./chunk.SDO3U72B.js","./chunk.IQGSEAQ2.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.7ZG77OI3.js")))),B=N.part((e,n)=>{let t=e.NotifySheet;return(0,u.jsx)(t,{...n})},{what:"Notify me"}),W=N.part((e,n)=>{let t=e.NotifiedList;return(0,u.jsx)(t,{...n})},{quiet:!0}),E=(e,n)=>n===void 0&&(e.onBehalfOf??e).id!==void 0;function F(e,n,t){let c=d=>t.tryDefinition(d)?.noun??d.replace(/[-_]+/g," "),o=e.on!==void 0?e.on:e.about.length===1?e.about[0]:void 0;if(e.act!==void 0){let d=o!==void 0&&n(o)!==void 0?o:void 0;return{label:"Notify me when someone does this\u2026",choices:[{on:"act",act:e.act,...d!==void 0?{record:d}:{}},...d!==void 0?[{on:"act",act:e.act}]:[]]}}if(o===void 0)return null;let s=n(o);if(s!==void 0)return{label:"Notify me when this changes\u2026",choices:[{on:"changed",record:o},{on:"act",record:o},{on:"reaches",kind:s,condition:"",record:o}]};let r=b(o)!==null?[b(o)]:T(o)?A(o):[];if(r.length!==1||!t.kinds.includes(r[0]))return null;let l=r[0],a=c(l);return{label:`Notify me when ${/^[aeiou]/i.test(a)?"an":"a"} ${a} is added\u2026`,choices:[{on:"created",kind:l},{on:"changed",kind:l},{on:"reaches",kind:l,condition:""}]}}function L(){let{store:e,principal:n,subscriptions:t,signIn:c}=m(),o=E(n,c);return(0,i.useMemo)(()=>o?s=>{let r=F(s,a=>e.graph.getNode(a)?.kind,e.schema);return r?{id:"notify",items:[{id:"notify-me",label:r.label,run:()=>g(t,{choices:r.choices,returnTo:s.element??null})}],prepare:()=>N.prefetch()}:null}:null,[o,e,t])}var z=[];function U({children:e}){let n=L(),t=(0,i.useMemo)(()=>n?[n]:z,[n]);return(0,u.jsx)(P,{sections:t,children:e})}function V(){let{subscriptions:e}=m(),n=(0,i.useId)(),t=D(e);(0,i.useEffect)(()=>(t.doors.push(n),k(t),()=>{t.doors.splice(t.doors.indexOf(n),1),k(t)}),[t,n]);let c=(0,i.useMemo)(()=>r=>(t.listeners.add(r),()=>void t.listeners.delete(r)),[t]),o=(0,i.useSyncExternalStore)(c,()=>t.ask,()=>null),s=(0,i.useSyncExternalStore)(c,()=>t.doors[0]===n,()=>!1);return!o||!s?null:(0,u.jsx)(i.Suspense,{fallback:null,children:(0,u.jsx)(B,{ask:o,close:()=>g(e,null)})})}function X({choices:e,label:n="Notify me",style:t,className:c,testId:o="notify-me"}){let{principal:s,subscriptions:r,signIn:l}=m();return E(s,l)?(0,u.jsx)("button",{type:"button","data-testid":o,className:c,onClick:a=>g(r,{choices:e,returnTo:a.currentTarget}),style:t,children:n}):null}function G(){let e=I(),n=e?.subscriptions,t=e?(e.principal.onBehalfOf??e.principal).id:void 0,[c,o]=(0,i.useState)(0);return(0,i.useEffect)(()=>{if(t===void 0||!n)return;let s=!0,r=()=>void Promise.resolve(n.list(t)).then(a=>s&&o(a.length),()=>s&&o(0));r();let l=n.onChange?.(r);return()=>{s=!1,l?.()}},[n,t]),c}function Y({style:e}){return G()===0?null:(0,u.jsx)(i.Suspense,{fallback:null,children:(0,u.jsx)(W,{...e?{style:e}:{}})})}export{q as a,K as b,L as c,U as d,V as e,X as f,G as g,Y as h};
@@ -1 +1 @@
1
- import{ec as w,rc as S}from"./chunk.Q4MI53KK.js";function v(s){return[...s.mutations??[],...S(s.schema,s.mutations??[])]}function B(s){let i=[...s.schema.kinds],a=v(s),d=new Map,c=new Map;for(let e of a){c.set(e.name,e.creates??[]);let n=w(e.input).filter(t=>!t.optional&&!t.kinds.includes("*")).flatMap(t=>t.kinds);d.set(e.name,[...new Set(n)])}let g=new Map;for(let e of i)g.set(e,[]);for(let e of a)for(let n of c.get(e.name)??[])g.get(n)?.push(e.name);let p=new Map,l=new Set;for(let e=0;;e+=1){let n=[];for(let t of a)if((d.get(t.name)??[]).every(o=>l.has(o)))for(let o of c.get(t.name)??[])l.has(o)||n.push(o);if(n.length===0)break;for(let t of n)l.add(t),p.set(t,e)}let h=e=>{let n=g.get(e)??[];if(n.length===0)return[];let t=n.map(r=>d.get(r)??[]).sort((r,o)=>r.length-o.length)[0];return[...new Set(t)].filter(r=>r!==e)},y=new Map,u=e=>{let n=y.get(e);if(n)return n;let t=new Set;y.set(e,t);for(let r of h(e)){t.add(r);for(let o of u(r))t.add(o)}return t.delete(e),t},f=new Map(i.map(e=>[e,0]));for(let e of i)for(let n of u(e))f.set(n,(f.get(n)??0)+1);let m=i.map(e=>({kind:e,madeBy:[...g.get(e)??[]].sort(),needs:[...h(e)].sort(),depth:p.get(e)??null})).sort((e,n)=>(e.depth??Number.MAX_SAFE_INTEGER)-(n.depth??Number.MAX_SAFE_INTEGER)||(f.get(n.kind)??0)-(f.get(e.kind)??0)||e.kind.localeCompare(n.kind)),k=m.filter(e=>e.depth===0).map(e=>e.kind),A=[...new Set(a.filter(e=>(d.get(e.name)??[]).length===0).filter(e=>(c.get(e.name)??[]).length>0).map(e=>e.name))].sort(),M=m.filter(e=>e.depth===null).map(e=>({kind:e.kind,why:e.madeBy.length===0?"no act declares that it creates this kind":`every act that makes it needs ${e.needs.map(n=>`"${n}"`).join(", ")}, which nothing can make first`}));return{order:m,roots:k,doors:A,unreachable:M}}export{B as a};
1
+ import{ec as w,rc as S}from"./chunk.IQGSEAQ2.js";function v(s){return[...s.mutations??[],...S(s.schema,s.mutations??[])]}function B(s){let i=[...s.schema.kinds],a=v(s),d=new Map,c=new Map;for(let e of a){c.set(e.name,e.creates??[]);let n=w(e.input).filter(t=>!t.optional&&!t.kinds.includes("*")).flatMap(t=>t.kinds);d.set(e.name,[...new Set(n)])}let g=new Map;for(let e of i)g.set(e,[]);for(let e of a)for(let n of c.get(e.name)??[])g.get(n)?.push(e.name);let p=new Map,l=new Set;for(let e=0;;e+=1){let n=[];for(let t of a)if((d.get(t.name)??[]).every(o=>l.has(o)))for(let o of c.get(t.name)??[])l.has(o)||n.push(o);if(n.length===0)break;for(let t of n)l.add(t),p.set(t,e)}let h=e=>{let n=g.get(e)??[];if(n.length===0)return[];let t=n.map(r=>d.get(r)??[]).sort((r,o)=>r.length-o.length)[0];return[...new Set(t)].filter(r=>r!==e)},y=new Map,u=e=>{let n=y.get(e);if(n)return n;let t=new Set;y.set(e,t);for(let r of h(e)){t.add(r);for(let o of u(r))t.add(o)}return t.delete(e),t},f=new Map(i.map(e=>[e,0]));for(let e of i)for(let n of u(e))f.set(n,(f.get(n)??0)+1);let m=i.map(e=>({kind:e,madeBy:[...g.get(e)??[]].sort(),needs:[...h(e)].sort(),depth:p.get(e)??null})).sort((e,n)=>(e.depth??Number.MAX_SAFE_INTEGER)-(n.depth??Number.MAX_SAFE_INTEGER)||(f.get(n.kind)??0)-(f.get(e.kind)??0)||e.kind.localeCompare(n.kind)),k=m.filter(e=>e.depth===0).map(e=>e.kind),A=[...new Set(a.filter(e=>(d.get(e.name)??[]).length===0).filter(e=>(c.get(e.name)??[]).length>0).map(e=>e.name))].sort(),M=m.filter(e=>e.depth===null).map(e=>({kind:e.kind,why:e.madeBy.length===0?"no act declares that it creates this kind":`every act that makes it needs ${e.needs.map(n=>`"${n}"`).join(", ")}, which nothing can make first`}));return{order:m,roots:k,doors:A,unreachable:M}}export{B as a};
@@ -1 +1 @@
1
- import{g as a}from"./chunk.AHPYNDVA.js";import{c as l}from"./chunk.FNVGNISQ.js";import{Na as d}from"./chunk.Q4MI53KK.js";function m(n){let r=new Map;for(let i of n.kinds){let e=n.tryDefinition(i),o=a(e),s=d(e);r.set(i,{fields:new Set(Object.keys(e?.fields?.shape??{})),edges:new Map(Object.entries(e?.edges??{}).map(([p,y])=>[p,y.cardinality??"many"])),...o?{computed:o}:{},...s.size>0?{linked:s}:{}})}let t=a(n);return t&&r.set(l,{computed:t}),r}export{m as a};
1
+ import{g as a}from"./chunk.R5MLRKAO.js";import{c as l}from"./chunk.YMXWS4XN.js";import{Na as d}from"./chunk.IQGSEAQ2.js";function m(n){let r=new Map;for(let i of n.kinds){let e=n.tryDefinition(i),o=a(e),s=d(e);r.set(i,{fields:new Set(Object.keys(e?.fields?.shape??{})),edges:new Map(Object.entries(e?.edges??{}).map(([p,y])=>[p,y.cardinality??"many"])),...o?{computed:o}:{},...s.size>0?{linked:s}:{}})}let t=a(n);return t&&r.set(l,{computed:t}),r}export{m as a};
@@ -0,0 +1 @@
1
+ import{a as re,b as B,c as oe}from"./chunk.4VRX7FCO.js";import{A as Q,C as X,E as Y,I as ee,K as ne,N as te,g as W,h as q,j as z,p as j,s as Z,t as _,x as U,y as J}from"./chunk.3FKKH2XU.js";import{a as M}from"./chunk.DLWFULWE.js";import{G as se,La as K,Sa as G,V as T,da as I,fa as D,ya as $}from"./chunk.VLX7YWVH.js";import{_c as V,cd as N}from"./chunk.IQGSEAQ2.js";import{b as P}from"./chunk.AJZBJBMO.js";var o=P(se(),1);var u=P(T(),1),ge=e=>typeof e=="object"?e:{};function be({rootRef:e,firstLook:t,app:n}){let r=(0,o.useCallback)(()=>e.current,[e]);return t?(0,u.jsx)(te,{firstLook:t,root:r,app:n}):null}function we(e,t,n){let{app:r}=e,a=(0,o.useMemo)(()=>{let i=ee(t(r.schema,r.viewSpecs),r),d=n?de(i,n):i,s=e.views?e.views(r.schema,d):i,c=s===d?i:$(i,s);return ne(c,r.schema,X(e.brand??r.brand,r.schema)),n?n.register(c):c},[e.views,r.schema,r.viewSpecs,r.lenses,r.pages,r.home,n]);return K(a,e.keptViews)}function de(e,t){let n={...e,register(r,a,i,d){return d?.name!==t.name&&e.register(r,a,i,d),n},...e.home?{home:(r,a)=>(t.home||e.home(r,a),n)}:{}};return n}var k=e=>e?e.getBoundingClientRect().height:0;function Se(e,t,n){let r=(0,o.useRef)(n);r.current=n;let a=n!==void 0;(0,o.useLayoutEffect)(()=>{let i=e.current;if(!i||!a)return;let d=()=>{let y=[...i.children],g=y.find(b=>b.hasAttribute("data-graview-app-bar")),p=y.find(b=>b.hasAttribute("data-embed-content")),h=p?.querySelector("[data-embed-measure]")??null,l=y.find(b=>b.hasAttribute("data-graview-place-line"));return{strip:g,line:l,content:p,measure:h}},s=-1,c=()=>{let{strip:y,line:g,content:p,measure:h}=d(),l=Math.ceil(k(y)+k(g)+k(h||p));l!==s&&(s=l,r.current?.(l))};if(c(),typeof ResizeObserver>"u")return;let m=new ResizeObserver(c),S=()=>{m.disconnect();let{strip:y,line:g,content:p,measure:h}=d();for(let l of[i,y,g,p,h])l&&m.observe(l)};S();let v=new MutationObserver(()=>{S(),c()});return v.observe(i,{childList:!0}),()=>{m.disconnect(),v.disconnect()}},[e,t,a])}var ve=480,ce=0;function Re(e){let{app:t,seed:n,scheme:r="auto",brand:a=t.brand,fonts:i=!0,height:d="100%",label:s}=e,c=(0,o.useRef)(null);G(c);let m=d==="viewport"?"100dvh":d,S=z(typeof m=="string"&&/vh\b/.test(m)),v=(0,o.useMemo)(()=>`graview-embed-${++ce}`,[]),y=(0,o.useMemo)(()=>e.store??e.remote?.store??B(t,n),[e.store,e.remote,t,n]),g=e.presence??e.remote?.presence,p=e.hostContext?.theme,h=oe(r==="auto"&&p===void 0,a?.scheme),l=r==="auto"?p??h:r,b=(0,o.useMemo)(()=>M(l,a,{scope:`.${v}`}),[l,a,v]);W(e.favicon?N(e.assetsAt,V(a)):void 0),q(e.favicon?a:void 0),(0,o.useEffect)(()=>{if(!i||typeof document>"u")return;let R=re(a);if(!R||document.querySelector(`link[href="${R}"]`))return;let f=document.createElement("link");f.rel="stylesheet",f.href=R,document.head.appendChild(f)},[a,i]);let x=(0,o.useRef)(void 0);(0,o.useLayoutEffect)(()=>{let R=c.current,f=x.current;if(x.current=s,!R||!s)return;let ie=w=>{let E=w.getAttribute("aria-label")??"",A=f&&f!==s?E.startsWith(`${f} \xB7 `)?E.slice(f.length+3):E===f?"":E:E;A===s&&(w.getAttribute("role")==="region"||w.tagName==="SECTION"&&!w.hasAttribute("role"))&&w.setAttribute("role","group");let O=A.startsWith(`${s} \xB7 `)||A===s?A:A?`${s} \xB7 ${A}`:s;O!==E&&w.setAttribute("aria-label",O)},H=()=>R.querySelectorAll("aside, nav, main, header, footer, section[aria-label]:not([role]), [role=region], [role=complementary], [role=navigation], [role=search]").forEach(w=>{w.hasAttribute("data-graview-named-by-lens")||ie(w)});H();let L=new MutationObserver(H);return L.observe(R,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["aria-label"]}),()=>L.disconnect()},[s]);let F=S?`${m}`.replace(/([\d.]+)[sdl]?vh\b/g,(R,f)=>`${+f*S/100}px`):m;return{rootRef:c,scope:v,css:b,scheme:l,store:y,presence:g,brand:a,auto:d==="auto",height:F}}function Ee({rootRef:e,board:t,onReport:n,where:r}){let a=(0,o.useCallback)(()=>e.current?.querySelector("[data-embed-content]")??e.current,[e]),i=(0,o.useRef)(r);i.current=r;let d=(0,o.useMemo)(()=>n?{tell:n,where:()=>i.current()}:void 0,[n]);return(0,u.jsx)(j,{board:t,anchor:a,report:d})}function Ae(e){let t=e.split(/[?#]/)[0].split("/").filter(Boolean).map(n=>{try{return decodeURIComponent(n)}catch{return n}});return t.length===0?{place:"home"}:t[0]==="places"?{place:t[1]??"places"}:{place:t[0],...t[1]!==void 0?{record:t[1]}:{}}}function xe(e,t,n){return{brand:n,locale:e.locale,timeZone:e.timeZone,principal:e.principal,seats:e.seats,presence:t,typing:e.remote?.typing,people:e.people,memory:e.memory,presenceTtlMs:e.presenceTtlMs,onKeepLens:e.onKeepLens,onProposeChange:e.onProposeChange,ai:e.ai,files:e.files,assetsAt:e.assetsAt,resolveApp:e.resolveApp,history:e.history,linkedRecords:e.linkedRecords,subscriptions:e.subscriptions,dismissals:e.dismissals,whileAway:e.whileAway,workflowRuns:e.workflowRuns,keptViews:e.keptViews,onExport:e.onExport,signIn:e.signIn,menuSections:e.menuSections,app:e.app}}function ke({name:e,heading:t,faces:n,at:r,without:a,home:i,reach:d,standing:s,hostActions:c,barActions:m,keeping:S,onFind:v,switch:y,named:g=!0}){let{brand:p,store:h,principal:l,views:b}=I();D();let x=a?.has("places")?[]:Z({store:h,principal:l,views:b}),F=Q();return(0,u.jsx)(U,{brand:p,name:e,named:g,description:p?.subtitle,heading:t,faces:n,home:i,places:x,current:r===null?null:_(x,r),reach:d,onFind:v,...y?{switch:y}:{},...n||r===null?{scenePlaces:F}:{},...m?{actions:m}:{},tools:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Y,{clean:s}),(0,u.jsx)(J,{...c?{hostActions:c}:{},...S?{keeping:S}:{}})]})})}var Fe=e=>e===!1?2:Math.min(e+1,6);function Pe(e){let[t,n]=(0,o.useState)(e),r=(0,o.useRef)(void 0),a=(0,o.useRef)(void 0),i=(0,o.useMemo)(()=>({go:r,at:n,pending:a}),[]),d=(0,o.useCallback)(s=>{if(r.current){r.current(s);return}a.current=s,n(s)},[]);return{at:t,setAt:n,steering:i,steer:d}}function le(e){let t=typeof e=="object"&&e!==null?e.name:void 0;return{name:typeof t=="string"&&t.length>0?t:typeof e=="object"?"Error":typeof e}}var C=()=>typeof performance<"u"?performance.now():Date.now();function Be(e,t){let n=(0,o.useRef)({onError:e,face:t});return n.current={onError:e,face:t},(0,o.useCallback)((r,a)=>n.current.onError?.(le(r),{module:a.module,face:n.current.face}),[])}function Ce(e,t){let n=(0,o.useRef)(null);n.current===null&&(n.current=C());let r=(0,o.useRef)({onReady:e,face:t});r.current={onReady:e,face:t};let a=(0,o.useRef)(!1);return(0,o.useCallback)(i=>{a.current||(a.current=!0,r.current.onReady?.({ms:Math.max(0,C()-(n.current??C())),face:i}))},[])}var ae=class extends o.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(t,n){console.error(`[graview] ${this.props.module} threw while rendering`,t,n.componentStack),this.props.report(t,{module:this.props.module})}render(){return this.state.failed?(0,u.jsxs)("div",{role:"alert","data-graview-face-error":this.props.module,...this.props.content?{"data-embed-content":""}:{},style:this.props.content?{flex:"1 1 auto",display:"grid",alignContent:"center",justifyItems:"center",gap:8,padding:24,background:"var(--graview-ground)",color:"var(--graview-ink)",fontSize:"0.9375rem"}:{display:"inline-flex",alignItems:"center",gap:6,fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:[(0,u.jsx)("span",{children:this.props.content?"This part of the app could not draw.":"Could not draw."}),(0,u.jsx)("button",{type:"button",onClick:()=>this.setState({failed:!1}),style:{padding:"3px 11px",fontSize:"0.8125rem"},children:"Try again"})]}):this.props.children}};export{ge as a,be as b,we as c,Se as d,ve as e,Re as f,Ee as g,Ae as h,xe as i,ke as j,Fe as k,Pe as l,Be as m,Ce as n,ae as o};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk.REXU6ARY.js";import"./chunk.G4JJXA63.js";import"./chunk.BIDL7GQD.js";import"./chunk.TA2JTUNX.js";import"./chunk.HZPRMHSL.js";import"./chunk.LDMBJC3B.js";import"./chunk.XOZU4OFA.js";import"./chunk.G7YLK4PX.js";import"./chunk.Q5WEOX3Q.js";import"./chunk.2E62YCMZ.js";import"./chunk.DUP2CGVH.js";import"./chunk.YEXFVDRA.js";import"./chunk.WVUJXDXZ.js";import"./chunk.ZA5TDCBC.js";import"./chunk.2JEN2RCB.js";import"./chunk.7CLKGKSF.js";import"./chunk.TMHVYI5R.js";import"./chunk.R5MLRKAO.js";import"./chunk.YMXWS4XN.js";import"./chunk.75JQCTR6.js";import"./chunk.5IEZF433.js";import"./chunk.5AD2QHWH.js";import"./chunk.IQGSEAQ2.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";export{i as draftAnswer,h as draftFromLens,b as draftSight,l as draftView,a as isDraftFailure,c as judgeLens,d as lensEditOf,f as lensFromSpec,j as recipeDraft,g as recipeOfLens,m as refineDraft,o as runDraftTool,e as takeBackEditOf,k as templateDraft,n as withReaderLenses};