graview 0.1.67 → 0.1.68

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 (189) hide show
  1. package/dist/preview/{chunk.YCD4JSXD.js → chunk.2BMZPALF.js} +1 -1
  2. package/dist/preview/{chunk.SNHKYH72.js → chunk.2KCDLCB2.js} +1 -1
  3. package/dist/preview/{chunk.O2OL6RQQ.js → chunk.2ME4DVBI.js} +1 -1
  4. package/dist/preview/chunk.2TUEBU7X.js +8 -0
  5. package/dist/preview/{chunk.LYEGRY77.js → chunk.2U6HB4XU.js} +1 -1
  6. package/dist/preview/{chunk.7S6ZRMW4.js → chunk.32JE2WS7.js} +1 -1
  7. package/dist/preview/{chunk.RG5G6YQD.js → chunk.3DEWQDP7.js} +1 -1
  8. package/dist/preview/{chunk.GVT4UUQA.js → chunk.3JMQKANL.js} +1 -1
  9. package/dist/preview/{chunk.A5PSEU3W.js → chunk.3VEZ5MOC.js} +1 -1
  10. package/dist/preview/chunk.3WPCS6KP.js +1 -0
  11. package/dist/preview/{chunk.5R744JGZ.js → chunk.42C3FIKK.js} +1 -1
  12. package/dist/preview/{chunk.IAEGJDF3.js → chunk.42KHFGN6.js} +1 -1
  13. package/dist/preview/{chunk.DZMIYEHQ.js → chunk.4DXPPM6T.js} +1 -1
  14. package/dist/preview/chunk.4GVKKBQL.js +1 -0
  15. package/dist/preview/{chunk.KX5ZBHMA.js → chunk.4TT3ZHSJ.js} +1 -1
  16. package/dist/preview/{chunk.QXLJGHMC.js → chunk.4YAO3A5Q.js} +3 -3
  17. package/dist/preview/{chunk.Z4TY44CD.js → chunk.5JKUT2OM.js} +1 -1
  18. package/dist/preview/chunk.5L4ADKTW.js +1 -0
  19. package/dist/preview/{chunk.BKYZSV2Y.js → chunk.64LCHHZB.js} +1 -1
  20. package/dist/preview/{chunk.ZEZUKRC6.js → chunk.6AANHELP.js} +1 -1
  21. package/dist/preview/{chunk.ZAQ4IDX6.js → chunk.6DMCEBSO.js} +1 -1
  22. package/dist/preview/{chunk.NKLPL7QD.js → chunk.6IR5LBJU.js} +1 -1
  23. package/dist/preview/{chunk.X226YATK.js → chunk.6WB2TYK7.js} +1 -1
  24. package/dist/preview/chunk.6ZENHSTQ.js +1 -0
  25. package/dist/preview/{chunk.EJ2EZL2G.js → chunk.7K2V5FUB.js} +1 -1
  26. package/dist/preview/chunk.7OL6H4LF.js +1 -0
  27. package/dist/preview/{chunk.4W57E7AX.js → chunk.7TDML5YU.js} +1 -1
  28. package/dist/preview/{chunk.AJMVRFYX.js → chunk.7WPVLEX2.js} +2 -2
  29. package/dist/preview/{chunk.XSWSBTUO.js → chunk.7ZTGB4O7.js} +1 -1
  30. package/dist/preview/{chunk.FRQSLWP4.js → chunk.ACNOP2IU.js} +1 -1
  31. package/dist/preview/{chunk.N4ZKZ4GM.js → chunk.AENP662H.js} +1 -1
  32. package/dist/preview/{chunk.SFBHPYRD.js → chunk.AQ2PI6MR.js} +1 -1
  33. package/dist/preview/chunk.ARS4HJD2.js +1 -0
  34. package/dist/preview/{chunk.STPA7HBK.js → chunk.AWV57UBJ.js} +1 -1
  35. package/dist/preview/{chunk.D7NWMXSX.js → chunk.AYZL3LCR.js} +3 -3
  36. package/dist/preview/{chunk.URQTF5SY.js → chunk.BHJRT57H.js} +1 -1
  37. package/dist/preview/{chunk.7UHPHEH5.js → chunk.BPNW5KCP.js} +1 -1
  38. package/dist/preview/{chunk.TTSGCNPT.js → chunk.BQAFFEOA.js} +1 -1
  39. package/dist/preview/chunk.C2QKA6XY.js +1 -0
  40. package/dist/preview/{chunk.6KJGRM7A.js → chunk.CE3NKAF7.js} +1 -1
  41. package/dist/preview/{chunk.QRQ5WPZI.js → chunk.CFE3MHWZ.js} +1 -1
  42. package/dist/preview/{chunk.H6KIEDZN.js → chunk.CGBOPPNL.js} +1 -1
  43. package/dist/preview/{chunk.LP2ZMAT2.js → chunk.CNN32262.js} +1 -1
  44. package/dist/preview/{chunk.HJUZMOW2.js → chunk.DCLF4WWZ.js} +1 -1
  45. package/dist/preview/{chunk.GMLONS5L.js → chunk.DGDW54KE.js} +1 -1
  46. package/dist/preview/{chunk.3GNT5MKP.js → chunk.DLSS56EU.js} +1 -1
  47. package/dist/preview/{chunk.QAM76AXV.js → chunk.DMZRFXH7.js} +1 -1
  48. package/dist/preview/{chunk.Z2XUVJAL.js → chunk.DPHH5ZVL.js} +1 -1
  49. package/dist/preview/{chunk.Z27NSSYL.js → chunk.DZ6UDZOB.js} +2 -2
  50. package/dist/preview/{chunk.6W6XMLSF.js → chunk.E423JCOS.js} +1 -1
  51. package/dist/preview/{chunk.35KMZHB7.js → chunk.EB7PZJEO.js} +1 -1
  52. package/dist/preview/{chunk.V7H4BUEB.js → chunk.ECNGVD25.js} +1 -1
  53. package/dist/preview/{chunk.B7KZBT27.js → chunk.EGSOHTZZ.js} +1 -1
  54. package/dist/preview/{chunk.OCXY5DCD.js → chunk.EGVM24ND.js} +1 -1
  55. package/dist/preview/{chunk.UDHPMVC4.js → chunk.ENLIIZF2.js} +1 -1
  56. package/dist/preview/{chunk.H3EGBDW2.js → chunk.EP5JS7ZH.js} +1 -1
  57. package/dist/preview/{chunk.TI5FR2QQ.js → chunk.F5GNNVSQ.js} +1 -1
  58. package/dist/preview/chunk.FHQ25SWY.js +1 -0
  59. package/dist/preview/{chunk.F464JKHZ.js → chunk.FSW535EA.js} +1 -1
  60. package/dist/preview/{chunk.G5GVT6JY.js → chunk.FZELUSK5.js} +1 -1
  61. package/dist/preview/{chunk.UWS4RMM3.js → chunk.G2BDEWJC.js} +1 -1
  62. package/dist/preview/chunk.GF3ZCX46.js +2 -0
  63. package/dist/preview/{chunk.UW52CMGJ.js → chunk.GJTEV6CK.js} +1 -1
  64. package/dist/preview/{chunk.A7GVTE5Y.js → chunk.GKTQ5CZA.js} +2 -2
  65. package/dist/preview/{chunk.ZG5VGP5U.js → chunk.GONZB3J3.js} +1 -1
  66. package/dist/preview/{chunk.FLJXYESX.js → chunk.GRBWXTST.js} +1 -1
  67. package/dist/preview/{chunk.Z3O2VZAJ.js → chunk.GRTBEA7O.js} +1 -1
  68. package/dist/preview/{chunk.QNP5OR3P.js → chunk.H3IGXHZR.js} +2 -2
  69. package/dist/preview/{chunk.ILJDLBPJ.js → chunk.H3W5C3XQ.js} +1 -1
  70. package/dist/preview/{chunk.O5VFKVZS.js → chunk.H4VNIAHN.js} +1 -1
  71. package/dist/preview/{chunk.7ARRVNUR.js → chunk.HH4D3JEI.js} +1 -1
  72. package/dist/preview/{chunk.MUSMNKE4.js → chunk.HWFJQ42Y.js} +1 -1
  73. package/dist/preview/{chunk.37RFCHSS.js → chunk.HXTKBISQ.js} +1 -1
  74. package/dist/preview/{chunk.J2OPIS3H.js → chunk.I34BWUB4.js} +1 -1
  75. package/dist/preview/{chunk.ZAPS4J6G.js → chunk.I63462I3.js} +1 -1
  76. package/dist/preview/{chunk.6UQFV53C.js → chunk.IKKKHHRN.js} +1 -1
  77. package/dist/preview/{chunk.GRFD42WM.js → chunk.IPGLITWA.js} +1 -1
  78. package/dist/preview/{chunk.3NSV3WKM.js → chunk.IT5DVKXY.js} +2 -2
  79. package/dist/preview/{chunk.JQ2WNKDW.js → chunk.IXMIU4D4.js} +1 -1
  80. package/dist/preview/{chunk.JVB5KDSG.js → chunk.JCETQQ7J.js} +1 -1
  81. package/dist/preview/{chunk.M7KXQGQL.js → chunk.JGRSUTPJ.js} +1 -1
  82. package/dist/preview/{chunk.KFT7JIEH.js → chunk.JLDJZET2.js} +1 -1
  83. package/dist/preview/{chunk.JQ63N4MZ.js → chunk.JULD4XFB.js} +1 -1
  84. package/dist/preview/{chunk.LVOTLGJB.js → chunk.JV432T4Q.js} +1 -1
  85. package/dist/preview/{chunk.6SJEZWH3.js → chunk.KAM73WVF.js} +1 -1
  86. package/dist/preview/{chunk.AKJS2NUM.js → chunk.KUCBNMIY.js} +1 -1
  87. package/dist/preview/{chunk.DWM7AR5Y.js → chunk.L7XKYGV7.js} +1 -1
  88. package/dist/preview/{chunk.EP6Q32WT.js → chunk.LFFJB6D3.js} +1 -1
  89. package/dist/preview/{chunk.264PB572.js → chunk.LMTG5NPG.js} +1 -1
  90. package/dist/preview/{chunk.EGPCVMDU.js → chunk.LOKGUALC.js} +1 -1
  91. package/dist/preview/{chunk.FPHRAO3R.js → chunk.LZ6MSQ5O.js} +1 -1
  92. package/dist/preview/chunk.MBTEOF4R.js +1 -0
  93. package/dist/preview/{chunk.RJY7VJBH.js → chunk.MIOLBZBS.js} +1 -1
  94. package/dist/preview/{chunk.G3GFDVO2.js → chunk.MK5RPEB2.js} +1 -1
  95. package/dist/preview/{chunk.NSOPYIT4.js → chunk.MKL4THIV.js} +1 -1
  96. package/dist/preview/{chunk.FVQKSN33.js → chunk.MPWLDQOG.js} +1 -1
  97. package/dist/preview/chunk.MSUZAJ2K.js +4 -0
  98. package/dist/preview/{chunk.MSAYU25L.js → chunk.N5Z34V7U.js} +1 -1
  99. package/dist/preview/chunk.N64RVSH3.js +1 -0
  100. package/dist/preview/{chunk.HAOB6O72.js → chunk.ND3DEDWB.js} +1 -1
  101. package/dist/preview/{chunk.GFLH7RCI.js → chunk.NFTPJAMJ.js} +1 -1
  102. package/dist/preview/{chunk.QZQCQWQG.js → chunk.NRCWMYLH.js} +1 -1
  103. package/dist/preview/{chunk.47XEJZ3O.js → chunk.O2VXTYUJ.js} +1 -1
  104. package/dist/preview/{chunk.6N4PE3U5.js → chunk.O32F6LGK.js} +1 -1
  105. package/dist/preview/{chunk.PZ7KY6XH.js → chunk.O5FTWXA2.js} +1 -1
  106. package/dist/preview/{chunk.T2OUHRAA.js → chunk.ODYJEDIW.js} +1 -1
  107. package/dist/preview/{chunk.DKEIEH2D.js → chunk.OQ4ZO3YY.js} +1 -1
  108. package/dist/preview/chunk.PI4RFOBU.js +1 -0
  109. package/dist/preview/{chunk.E5PYNAYT.js → chunk.PIMAG4WT.js} +2 -2
  110. package/dist/preview/{chunk.EFVSZKB5.js → chunk.PLIV3IQK.js} +1 -1
  111. package/dist/preview/{chunk.77C556NM.js → chunk.PPCDPYYU.js} +1 -1
  112. package/dist/preview/{chunk.MW7R5G3C.js → chunk.PZQ5P6WK.js} +1 -1
  113. package/dist/preview/chunk.Q42R2KW4.js +1 -0
  114. package/dist/preview/{chunk.WEMUKZKH.js → chunk.Q4VFLLUT.js} +1 -1
  115. package/dist/preview/{chunk.SY5ID44D.js → chunk.Q6H5HESF.js} +1 -1
  116. package/dist/preview/chunk.QM54TGU6.js +3 -0
  117. package/dist/preview/{chunk.HN4ZJ4B4.js → chunk.QOQ26NXM.js} +1 -1
  118. package/dist/preview/{chunk.SJQPTDAT.js → chunk.QUETLFBJ.js} +1 -1
  119. package/dist/preview/{chunk.P2EKKKK2.js → chunk.QWLK3GKG.js} +1 -1
  120. package/dist/preview/{chunk.JEC5FDKX.js → chunk.QYPU444Y.js} +1 -1
  121. package/dist/preview/{chunk.TXZQEJ5T.js → chunk.QZP3ARLH.js} +1 -1
  122. package/dist/preview/{chunk.WALVW3KJ.js → chunk.R3GE37OI.js} +1 -1
  123. package/dist/preview/chunk.R66ZVMWB.js +1 -0
  124. package/dist/preview/{chunk.YZPESGCP.js → chunk.RQG672MJ.js} +1 -1
  125. package/dist/preview/chunk.RYA7A4NA.js +1 -0
  126. package/dist/preview/{chunk.LRNFE3UK.js → chunk.SADR3MQI.js} +1 -1
  127. package/dist/preview/{chunk.MJY4SLWA.js → chunk.SS6KL5NT.js} +1 -1
  128. package/dist/preview/chunk.SUG6LIOX.js +1 -0
  129. package/dist/preview/{chunk.SO6NT5K7.js → chunk.TFJA4QV4.js} +1 -1
  130. package/dist/preview/{chunk.D4WJ7OM5.js → chunk.TOUSIUJF.js} +1 -1
  131. package/dist/preview/{chunk.ARWO4WOV.js → chunk.TR4YFVZN.js} +1 -1
  132. package/dist/preview/{chunk.XFLGSUYO.js → chunk.TRNJKHIA.js} +1 -1
  133. package/dist/preview/{chunk.5AKZROMR.js → chunk.TVWK3SGD.js} +1 -1
  134. package/dist/preview/chunk.U7PAFLUM.js +1 -0
  135. package/dist/preview/{chunk.NKYWIGC7.js → chunk.UAMPR4MD.js} +1 -1
  136. package/dist/preview/{chunk.UGQYMN4J.js → chunk.UD7VLXPM.js} +1 -1
  137. package/dist/preview/{chunk.UQIPEMJ5.js → chunk.UFURYU4R.js} +1 -1
  138. package/dist/preview/{chunk.R6JBA7UK.js → chunk.UODTUBQ7.js} +1 -1
  139. package/dist/preview/{chunk.NRURQGXV.js → chunk.VES4XMZX.js} +1 -1
  140. package/dist/preview/{chunk.QWGWOEBZ.js → chunk.VLXLBGMY.js} +1 -1
  141. package/dist/preview/{chunk.IDALEKIW.js → chunk.VTDOWXCP.js} +1 -1
  142. package/dist/preview/{chunk.4EMKCKDB.js → chunk.VV5JAM5W.js} +1 -1
  143. package/dist/preview/{chunk.JU6UFWS3.js → chunk.VW632VNJ.js} +1 -1
  144. package/dist/preview/{chunk.25QFDTCU.js → chunk.WC5WE34A.js} +1 -1
  145. package/dist/preview/chunk.WN7SAAH6.js +1 -0
  146. package/dist/preview/{chunk.4UUJHLHR.js → chunk.WV45KLXC.js} +1 -1
  147. package/dist/preview/{chunk.NAXOXBOF.js → chunk.XDZDNZ7B.js} +1 -1
  148. package/dist/preview/{chunk.MAKCZ6B6.js → chunk.XFH6GHBQ.js} +1 -1
  149. package/dist/preview/{chunk.2VUX54XH.js → chunk.XRE7SHLD.js} +1 -1
  150. package/dist/preview/{chunk.J6HF7IRQ.js → chunk.XXCHO2A5.js} +1 -1
  151. package/dist/preview/{chunk.A4EZAGG7.js → chunk.Y7OGJOPA.js} +1 -1
  152. package/dist/preview/{chunk.6NG76MDA.js → chunk.YBQ5GVAX.js} +2 -2
  153. package/dist/preview/{chunk.QF5QB5YR.js → chunk.YL2RBZFE.js} +1 -1
  154. package/dist/preview/{chunk.RSQ432QN.js → chunk.YM6SWEUI.js} +1 -1
  155. package/dist/preview/{chunk.7BJRHPE3.js → chunk.Z2X7BFCB.js} +2 -2
  156. package/dist/preview/{chunk.VBLQJVQ5.js → chunk.Z67LBSQO.js} +1 -1
  157. package/dist/preview/{chunk.OHAO6KKH.js → chunk.ZKXIZBCN.js} +1 -1
  158. package/dist/preview/{chunk.BDNQMKDG.js → chunk.ZLEBOR5T.js} +1 -1
  159. package/dist/preview/{chunk.CKDCTFLU.js → chunk.ZLNUZ6LR.js} +1 -1
  160. package/dist/preview/chunk.ZMADWPJO.js +1 -0
  161. package/dist/preview/chunk.ZO6VMEPP.js +1 -0
  162. package/dist/preview/chunk.ZUG7U7AT.js +1 -0
  163. package/dist/preview/index.html +55 -55
  164. package/dist/preview/page.js +2 -2
  165. package/package.json +6 -6
  166. package/dist/preview/chunk.2FHIINXG.js +0 -2
  167. package/dist/preview/chunk.3ENPWZBG.js +0 -1
  168. package/dist/preview/chunk.3ZODN6BW.js +0 -1
  169. package/dist/preview/chunk.55G4IPOO.js +0 -1
  170. package/dist/preview/chunk.5J6DVR7S.js +0 -1
  171. package/dist/preview/chunk.7WHQWLL6.js +0 -1
  172. package/dist/preview/chunk.B5SJMCTT.js +0 -7
  173. package/dist/preview/chunk.CTUJZ3IV.js +0 -1
  174. package/dist/preview/chunk.CY7FFKEZ.js +0 -1
  175. package/dist/preview/chunk.DEKRFTRN.js +0 -4
  176. package/dist/preview/chunk.EBKH3ILT.js +0 -1
  177. package/dist/preview/chunk.FOUBDGL3.js +0 -1
  178. package/dist/preview/chunk.HB5NWHFP.js +0 -3
  179. package/dist/preview/chunk.HVBKI5ZO.js +0 -1
  180. package/dist/preview/chunk.I3SDKMQS.js +0 -1
  181. package/dist/preview/chunk.J5OLYVZ4.js +0 -1
  182. package/dist/preview/chunk.JKFVNQY7.js +0 -1
  183. package/dist/preview/chunk.KGMSSXZL.js +0 -1
  184. package/dist/preview/chunk.NXZL5CA2.js +0 -1
  185. package/dist/preview/chunk.PSNMZBVS.js +0 -1
  186. package/dist/preview/chunk.R7CRBRD4.js +0 -1
  187. package/dist/preview/chunk.RR25BGWP.js +0 -1
  188. package/dist/preview/chunk.T27QKVKP.js +0 -1
  189. package/dist/preview/chunk.T3WCRS6M.js +0 -1
@@ -1 +1 @@
1
- import{b as Ce,d as $e,i as U}from"./chunk.SJQPTDAT.js";import{d as Te}from"./chunk.JQ63N4MZ.js";import{$d as We,Kc as se,L as ke,Qb as ae,Wd as Re,Zd as De,ae as Me,cb as Se,da as M,fa as xe,ga as W,gb as G,ka as _,la as z,ma as Ae,oa as we,pa as Ne,ve as je,wd as ve,xd as Oe}from"./chunk.ZEZUKRC6.js";function V(n,e){return n.display?.labels?.[e]??W(e)}function de(n){let e=U(n);switch(e.type){case"text":case"date":case"number":case"boolean":case"choice":return e.type;default:return}}function Je(n,e){let t=new Map,i=n.tryDefinition(e);for(let[r,a]of Object.entries(i?.edges??{}))t.set(r,{key:r,label:a.description?M(a.description):W(r),about:"edge",far:a.to==="*"?[...n.kinds]:[...a.to]});for(let r of n.definitions)if(r.kind!==e)for(let[a,s]of Object.entries(r.edges??{}))t.has(a)||s.to!=="*"&&!s.to.includes(e)||t.set(a,{key:a,label:s.inverse?M(s.inverse):W(a),about:"edge",far:[r.kind]});return[...t.values()]}var Ze=["current","past","any","flagged","clear"];function Fe(n,e){let t=n?.lifecycle;if(!t||t.retired==="date")return!1;let i=t.retired.map(String);return e.some(r=>r.key===t.field&&i.includes(r.value))}function Be(n,e){let t=n.tryDefinition(e);if(!t)return{kind:e,sorts:[],filters:[],groups:[]};let i=new Set(t.display?.hide??[]),r=t.fields.shape??{},a=[{key:"label",label:"Name",about:"label",type:"text"}],s=[],u=[];for(let[g,k]of Object.entries(r)){if(g==="id"||g==="kind"||g==="label"||i.has(g))continue;let A=en(k);if(A){s.push({key:g,label:V(t,g),about:"field",type:"choice",options:A});continue}let w=de(k);if(!w)continue;let N=V(t,g),O=w==="choice"?Le(k):w==="boolean"?["true","false"]:void 0,S={key:g,label:N,about:"field",type:w,...O?{options:O}:{}};a.push(S),s.push(S),(w==="boolean"||w==="choice")&&u.push(S),w==="date"&&u.push({...S,buckets:["day","week","month","year","decade"]})}for(let g of Je(n,e))a.push(g),s.push(g),u.push(g);let l={key:"is",label:t.lifecycle?"Standing and currency":"Standing",about:"is",type:"choice",options:t.lifecycle?[...Ze]:["flagged","clear"]};s.push(l);let y=t.fieldRoles?.order,f=y&&(y in r||y==="label")?{by:y,direction:"asc"}:void 0;return{kind:e,sorts:a,filters:s,groups:u,...f?{natural:f}:{}}}function On(n,e){let t=[];for(let r of e.filters){let a=r.about==="edge"&&r.far?.length===1?n.tryDefinition(r.far[0]):void 0;if(!(!a||a.kind===e.kind))for(let[s,u]of Object.entries(a.fields.shape??{}))de(u)!=="choice"||a.display?.hide?.includes(s)||t.push({key:`${r.key}.${s}`,label:`${r.label} \xB7 ${V(a,s)}`,about:"via",type:"choice",options:Le(u),far:[a.kind]})}if(t.length===0)return e;let i=e.filters.filter(r=>r.about!=="is");return{...e,filters:[...i,...t,...e.filters.filter(r=>r.about==="is")]}}function Rn(n,e){let t=n.tryDefinition(e.kind),i=Object.entries(t?.computed??{});if(!t||i.length===0)return e;let r=i.filter(([a])=>!e.sorts.some(s=>s.key===a)).map(([a,s])=>({key:a,label:(typeof s=="object"?s.label:void 0)??V(t,a),about:"field",type:"number"}));return{...e,sorts:[...e.sorts,...r]}}function Le(n){let e=U(n);return e.type==="choice"?e.options:[]}function en(n){let e=U(n);return e.type==="several"&&e.of.type==="choice"?e.of.options:void 0}var Ie=n=>n,Pe=n=>n;function nn(n,e,t){let i=new Map;for(let r of[...n.out(e,t),...n.in(e,t)])i.set(r.id,r);return[...i.values()]}function le(n,e,t){let i=n.schema.tryDefinition(e.kind);if(t.key==="is")switch(t.value){case"current":return _(i,Pe(e),n.today);case"past":return!_(i,Pe(e),n.today);case"any":return!0;case"flagged":return n.flagged?.has(e.id)??!1;case"clear":return!(n.flagged?.has(e.id)??!1);default:return!0}let r=i?.fields.shape??{};if(t.key in r){let l=Se(Ie(e),t.key,n.today??ke()),y=de(r[t.key]);if(y==="date"){let[f,g]=t.value.split(":");if(typeof l!="string"||!g)return!1;let k=l.slice(0,10);return f==="before"?k<g:f==="after"?k>g:k===g}if(y==="boolean")return String(l)===t.value;if(Array.isArray(l))return l.some(f=>String(f)===t.value);if(y==="number"){let f=t.value.lastIndexOf(":"),g=f>0?t.value.slice(0,f):"",k=Number(t.value.slice(f+1));if(g==="at-most"||g==="at-least")return typeof l!="number"||!Number.isFinite(k)?!1:g==="at-most"?l<=k:l>=k}return String(l)===t.value}let[a,s]=t.key.split("."),u=nn(n.graph,e.id,a);return s?u.some(l=>String(Ie(l)[s])===t.value):t.value==="*"?u.length>0:t.value==="none"?u.length===0:u.some(l=>l.id===t.value)}var tn=5;function ze(n){return n.normalize("NFD").replace(/\p{M}+/gu,"").toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").trim()}function ce(n){return ze(n).replace(/ /g,"")}var X=new Map,rn=5e4;function $(n){let e=X.get(n);if(e===void 0){X.size>=rn&&X.clear();let t=ze(n);e={tokens:t.split(" ").filter(Boolean),whole:t.replace(/ /g,"")},X.set(n,e)}return e}var T=n=>[...$(n).tokens];function j(n,e){if(e.length===0)return;let{whole:t,tokens:i}=$(n),r=e.join("");if(t.length===0)return;if(t===r)return"exact";if(e.every(s=>i.some(u=>u.startsWith(s))))return t.startsWith(r)?"prefix":e.every(s=>i.includes(s))?"word":"part"}function q(n,e,t=48){let i=n.replace(/\s+/g," ").trim();if(i.length<=t)return i;let r=e[0],a=i.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase(),s=r?a.search(new RegExp(`(^|[^\\p{L}\\p{N}])${on(r)}`,"u")):-1,u=s<0?0:s+(a[s]&&/[\p{L}\p{N}]/u.test(a[s])?0:1),l=Math.max(0,u-Math.floor(t/3));if(l>0){let f=i.lastIndexOf(" ",l);l=f<0?0:f+1}let y=Math.min(i.length,l+t);if(y<i.length){let f=i.indexOf(" ",y);y=f<0||f-y>16?y:f}return`${l>0?"\u2026":""}${i.slice(l,y).trim()}${y<i.length?"\u2026":""}`}var on=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),an=/^([\p{L}][\p{L}\p{N}_-]*):(\S+)$/u;function sn(n){let e=[],t=[];for(let i of n.trim().split(/\s+/).filter(Boolean)){let r=an.exec(i);r?t.push({key:r[1],value:r[2]}):e.push(i)}return{words:e.join(" "),conditions:t}}var Ee=new WeakMap;function Q(n,e){let t=Ee.get(e);if(t&&t.definition===n)return t.texts;let i=dn(n,e);return Ee.set(e,{definition:n,texts:i}),i}function dn(n,e){let t=z(n,e),i=[{field:"label",reading:"Name",text:t}];for(let r of $e(e,n,{limit:Number.POSITIVE_INFINITY}))r.key==="label"||r.value===t||typeof e[r.key]!="boolean"&&i.push({field:r.key,reading:r.label,text:r.markdown?Te(r.value):r.value});return i}var I={exact:0,prefix:1,word:2,part:3,field:4,near:5},Ge=new Set(["a","an","the","of","and","or","for","to","in","on","at","by","with","my","our","is"]);function Ke(n){let e=n;e.length>4&&e.endsWith("ies")?e=`${e.slice(0,-3)}y`:e.length>4&&/(ss|x|ch|sh|z)es$/.test(e)?e=e.slice(0,-2):e.length>3&&e.endsWith("s")&&!/(ss|us|is)$/.test(e)&&(e=e.slice(0,-1));for(let t of["ing","ed"])if(e.length>t.length+2&&e.endsWith(t)){e=e.slice(0,-t.length),/([b-df-hj-km-np-rtv-z])\1$/.test(e)&&(e=e.slice(0,-1));break}return e.length>3&&e.endsWith("e")?e.slice(0,-1):e}function He(n,e,t){if(Math.abs(n.length-e.length)>t)return t+1;let i=[],r=Array.from({length:e.length+1},(a,s)=>s);for(let a=1;a<=n.length;a++){let s=[a],u=a;for(let l=1;l<=e.length;l++){let y=Math.min(r[l]+1,s[l-1]+1,r[l-1]+(n[a-1]===e[l-1]?0:1));a>1&&l>1&&n[a-1]===e[l-2]&&n[a-2]===e[l-1]&&(y=Math.min(y,i[l-2]+1)),s[l]=y,y<u&&(u=y)}if(u>t)return t+1;i=r,r=s}return r[e.length]}var Y=new Map;function ln(n,e){let t=Y.get(n);t||(Y.size>=64&&Y.clear(),Y.set(n,t=new Map));let i=t.get(e);return i===void 0&&(i=cn(n,e)??null,t.set(e,i)),i??void 0}function cn(n,e){if(/\d/.test(n))return;let t=Ke(n);if(t.length>=3&&(Ke(e)===t||t.length>=4&&e.startsWith(t)))return"stem";let i=n.length<4?0:n.length<=7?1:2;if(i!==0){if(He(n,e,i)<=i)return"spelling";if(n.length>=5){for(let r=n.length-i;r<=n.length+i;r++)if(r<e.length&&He(n,e.slice(0,r),i)<=i)return"spelling"}}}function fn(n,e){let t=e.length>1?e.filter(r=>!Ge.has(r)):e;if(t.length===0)return;let i;for(let r of t){let a;for(let s of n){for(let u of $(s.text).tokens){if(u.startsWith(r)){a={text:s,matched:u};break}let l=a?void 0:ln(r,u);l&&(a={text:s,matched:u,by:l})}if(a&&!a.by)break}if(!a)return;a.by&&!i&&(i={text:a.text,asked:r,matched:a.matched,by:a.by})}if(i)return{field:i.text.field,reading:i.text.reading,fragment:q(i.text.text,[i.matched]),strength:"near",asked:i.asked,matched:i.matched,by:i.by}}var un=80;function gn(n,e,t){let i=T(e).filter(s=>!Ge.has(s)).join(" ")||e,r=t===void 0?[]:T(t),a=r.length>0&&n.find(s=>r.every(u=>$(s.text).tokens.some(l=>l.startsWith(u))))||n[0];return{field:a.field,reading:a.reading,fragment:q(a.text,r),strength:"near",asked:i,matched:(t??a.text).slice(0,un),by:"meaning"}}function _e(n,e,t,i){let r=T(t);if(r.length===0)return;if(i){let A=Q(n,e),w=i.includes("label")||i.some(v=>typeof e[v]=="string"&&e[v]===A[0].text),N=A.filter((v,D)=>D===0?w:i.includes(v.field)),O=v=>D=>$(D.text).tokens.some(P=>P.startsWith(v));if(!r.every(v=>N.some(O(v))))return;let S=N.find(O(r[0]));return{field:S.field,reading:S.reading,fragment:q(S.text,r),strength:S.field==="label"?j(S.text,r)??"field":"field"}}let a=Q(n,e),[s,...u]=a,l=j(s.text,r);if(l)return{field:"label",reading:s.reading,fragment:q(s.text,r),strength:l};let y=A=>w=>$(w.text).tokens.some(N=>N.startsWith(A));if(!r.every(A=>a.some(y(A))))return;let f=T(s.text),g=r.find(A=>!f.some(w=>w.startsWith(A)))??r[0],k=u.find(y(g));return{field:k.field,reading:k.reading,fragment:q(k.text,[g]),strength:"field"}}var yn=512,hn=64;function pn(n){let e=new Map;if(n.length===0)return e;let t=n.slice(-yn),i=n[n.length-1].seq;for(let r of t){let a=Math.pow(.5,(i-r.seq)/hn);for(let s of r.writes)e.set(s,(e.get(s)??0)+a)}return e}var ue=(n,e)=>we({tryDefinition:()=>n},e),fe=(n,e)=>De({tryDefinition:()=>n},e);function mn(n,e,t){let i=n.tryDefinition(e),r=[{field:"plural",text:ue(i,e)},{field:"kind",text:W(e)},...i?.noun?[{field:"noun",text:i.noun}]:[],...(i?.aliases??[]).map(s=>({field:"alias",text:s}))],a;for(let s of r){let u=j(s.text,t);u&&(!a||I[u]<I[a.strength])&&(a={strength:u,...s})}return a}var bn,kn=(n,e)=>(bn??=new Intl.Collator(void 0,{sensitivity:"base",numeric:!0})).compare(n,e),qe=(n,e)=>(n.nearly??0)-(e.nearly??0)||(n.archived??0)-(e.archived??0)||n.tier-e.tier||n.inKind-e.inKind||n.near-e.near||n.past-e.past||n.touched-e.touched||n.flagged-e.flagged||kn(n.name,e.name)||(n.id<e.id?-1:n.id>e.id?1:0);function En(n,e,t={}){let i=n.schema,r=sn(e),a=T(r.words),s=t.principal??{kind:"human"},u=n.kindsKeptFrom(s),l=n.modules.disabledKinds,y=r.conditions.filter(o=>o.key==="kind").map(o=>o.value),f=r.conditions.filter(o=>o.key==="is").map(o=>o.value),g=f.includes("any")||f.includes("past"),k=f.includes("past")&&!f.includes("any")&&!f.includes("current"),A=f.includes("archived")?!0:t.archived??"all",w=(o,d)=>{let c=ce(d),h=i.tryDefinition(o);return ce(o)===c||ce(ue(h,o))===c},N=i.kinds.filter(o=>!u.has(o)&&!l.has(o)&&(t.kinds===void 0||t.kinds.includes(o))&&(y.length===0||y.some(d=>w(o,d)))),S=r.conditions.filter(o=>o.key!=="kind").map(o=>({...o,admittedBy:N.filter(d=>Be(i,d).filters.some(c=>c.key===o.key))})),v=S.filter(o=>o.key!=="is"),D=f.filter(o=>o==="flagged"||o==="clear"||o==="past"||o==="archived"),P={kinds:N,past:g},Qe={hits:[],words:r.words,conditions:S,searched:P,byKind:{},total:0,matched:[]};if(a.length===0&&v.length===0&&D.length===0)return Qe;let J=t.today,F=t.flagged??new Set(n.violations().flatMap(o=>o.nodeIds)),Ue=t.touched??pn(n.log.all()),Z=new Set;for(let o of t.from??[]){Z.add(o);for(let d of n.graph.neighbors(o))Z.add(d.id)}let ge=ve(n,s)?Oe(n,s):void 0,ee=ae.keptFrom?.(n,s)&&n.seenBy(s).graph,ne=o=>je(o,t.basePath===void 0?{}:{basePath:t.basePath}),ye={schema:i,graph:n.graph,flagged:F,...J?{today:J}:{}},R=[],B={},L=[],E=[],K=(o,d,c,h,p,m)=>{let x=z(c,o);B[d]=(B[d]??0)+1,R.push({hit:{about:"node",id:o.id,kind:d,label:x,why:p,current:h,flagged:F.has(o.id),address:ne(`${fe(c,d)}/${encodeURIComponent(o.id)}`),...m===void 0?{}:{near:!0},...G(o)?{archived:!0}:{}},...m===void 0?{}:{nearly:2-m},tier:I[p.strength],inKind:d===t.inKind?0:1,near:Z.has(o.id)?0:1,past:h?0:1,archived:G(o)?1:0,touched:-(Ue.get(o.id)??0),flagged:F.has(o.id)?0:1,name:x,id:o.id})};for(let o of N){let d=i.tryDefinition(o),c=S.filter(p=>p.key!=="is"&&p.admittedBy.includes(o));if(a.length===0&&c.length===0&&D.length===0)continue;let h=Fe(d,c);for(let p of n.graph.nodesOfKind(o,{archived:A})){if(ge&&!ge(p.id))continue;let m=ee?ee.getNode(p.id):p;if(!m)continue;let x=_(d,m,J);if(!g&&!h&&!x){if(a.length>0&&f.length===0&&c.every(b=>le(ye,m,b))){let b=_e(d,m,r.words);b&&E.push({node:m,kind:o,definition:d,why:b})}continue}if(k&&x||!c.every(b=>le(ye,m,b))||f.includes("flagged")&&!F.has(m.id)||f.includes("clear")&&F.has(m.id))continue;let C=a.length>0?_e(d,m,r.words):c[0]?{field:c[0].key,reading:W(c[0].key),fragment:`${c[0].key}:${c[0].value}`,strength:"field"}:{field:"is",reading:"Is",fragment:`is:${D[0]}`,strength:"field"};C?K(m,o,d,x,C):a.length>0&&L.push({node:m,kind:o,definition:d,current:x})}}let te=o=>o.strength!=="field",re=!1;if(E.length>0&&R.length===0){re=!0;for(let o of E)K(o.node,o.kind,o.definition,!1,o.why)}else if(E.some(o=>te(o.why))&&!R.some(o=>te(o.hit.why))){re=!0;for(let o of E)te(o.why)&&K(o.node,o.kind,o.definition,!1,o.why)}let he=t.near!==!1&&a.length>0&&R.length<tn&&L.length>0,ie=new Set;if(he)for(let o of L){let d=fn(Q(o.definition,o.node),a);d&&(ie.add(o.node.id),K(o.node,o.kind,o.definition,o.current,d,d.by==="stem"?.9:.8))}let Ve=o=>o==="exact"||o==="prefix"?-1:I[o],oe=(o,d,c,h)=>({hit:o,tier:Ve(d),inKind:1,near:1,past:0,touched:0,flagged:1,name:c,id:h});if(a.length>0){for(let d of N){let c=mn(i,d,a);if(!c)continue;let h=Ne(i,d),p={field:c.field,reading:c.field==="plural"?"Plural":"Kind",fragment:c.text,strength:c.strength};R.push(oe({about:"kind",kind:d,label:h,why:p,count:B[d]??0,address:ne(fe(i.tryDefinition(d),d))},c.strength,h,`kind:${d}`))}let o=t.places??[];for(let d of Re(o.filter(c=>N.includes(c.kind)))){if(d.across&&u.has(d.across))continue;let c=j(d.title,a);if(!c)continue;let h={field:"title",reading:"Title",fragment:d.title,strength:c},p=Me(d,o)?fe(i.tryDefinition(d.kind),d.kind).slice(1):void 0,m=ne(We(d.as,p));R.push(oe({about:"place",kind:d.kind,title:d.title,as:d.as,why:h,address:m},c,d.title,`place:${d.kind}:${d.as}`))}for(let d of n.allInvariants()){let c=d.scope==="graph"?void 0:d.scope.kind;if(c&&!N.includes(c))continue;let h=d.label??W(d.name),p=j(h,a),m=p?void 0:j(W(d.name),a),x=p??m;if(!x)continue;let C={field:p?"label":"name",reading:p?"Rule":"Name",fragment:p?h:d.name,strength:x};R.push(oe({about:"rule",name:d.name,label:h,...c?{kind:c}:{},why:C},x,h,`rule:${d.name}`))}}let pe=()=>{R.sort(qe);let o=t.limit??50,d=R.slice(0,o).map(b=>b.hit),c=d.flatMap(b=>b.about==="node"?[(ee||n.graph).getNode(b.id)]:[]).filter(Boolean),h=Ce(c,b=>i.tryDefinition(b)),p=d.map(b=>b.about==="node"&&h.has(b.id)?{...b,apart:h.get(b.id)}:b),m=Object.values(B).reduce((b,Ye)=>b+Ye,0),x=R.flatMap(b=>b.hit.about==="node"?[b.hit.id]:[]),C=t.subject&&N.includes(String(n.graph.getNode(t.subject)?.kind))?xn(n,t.subject,r.words,{principal:s}):[];return{hits:[...p,...C],words:r.words,conditions:S,searched:re?{...P,past:!0}:P,byKind:{...B},total:m,matched:x}},H=pe(),me=t.rank;if(!he||!me)return H;let be=L.filter(o=>!ie.has(o.node.id)).map(({node:o,kind:d,definition:c})=>({id:o.id,kind:d,label:z(c,o),texts:Q(c,o)}));if(be.length===0)return H;let Xe=(async()=>{let o;try{o=await me(r.words,be)}catch{return H}let d=new Map(L.filter(h=>!ie.has(h.node.id)).map(h=>[h.node.id,h])),c=!1;for(let{id:h,score:p,matched:m}of Array.isArray(o)?o:[]){let x=d.get(h);!x||!(p>0)||(d.delete(h),c=!0,K(x.node,x.kind,x.definition,x.current,gn(Q(x.definition,x.node),r.words,typeof m=="string"?m:void 0),Math.min(1,p)))}return c?pe():H})();return{...H,later:Xe}}function xn(n,e,t,i={}){let r=i.principal??{kind:"human"},a=(ae.keptFrom?.(n,r)?n.seenBy(r):n).graph.getNode(e);if(!a)return[];if(n.kindsKeptFrom(r).has(a.kind))return[];let s=T(t),u=z(n.schema.tryDefinition(a.kind),a),l=[];for(let f of n.allMutations()){let g=f.subject;if(!g||g.kinds!=="*"&&!g.kinds.includes(a.kind))continue;let k=f.derived?.act;if((k==="archive"||k==="merge")&&G(a)||k==="unarchive"&&!G(a)||k==="leave-alone"&&se(a)||k==="allow-tidying"&&!se(a)||!n.permits({name:f.name,args:{[g.arg]:a.id}},r).ok)continue;let A=Ae(f),w=T(A),N=s.filter(v=>w.some(D=>D.startsWith(v))),O=N.length>0?j(A,N):void 0,S=O?{field:"title",reading:"Act",fragment:A,strength:O}:{field:"subject",reading:"On",fragment:u,strength:"field"};l.push({hit:{about:"act",name:f.name,title:A,subject:a.id,why:S,destructive:f.destructive===!0},tier:O?I[O]:I.field+1,inKind:0,near:0,past:f.destructive?1:0,touched:0,flagged:f.pinned?0:1,name:A,id:`act:${f.name}`})}l.sort(qe);let y=l.map(f=>f.hit);return i.limit===void 0?y:y.slice(0,i.limit)}function Kn(n,e){let t=e.kinds.map((a,s)=>{let u=ue(n.tryDefinition(a),a);return s===0?u:u.toLowerCase()}),i=xe(t)||"Nothing";return e.kinds.some(a=>n.tryDefinition(a)?.lifecycle)?e.past?`${M(i)}, past ones included.`:`${M(i)}, current ones; add is:any for past ones.`:`${M(i)}.`}export{V as a,de as b,Je as c,Fe as d,Be as e,On as f,Rn as g,Le as h,Ie as i,Pe as j,nn as k,le as l,ze as m,ce as n,sn as o,_e as p,pn as q,En as r,xn as s,Kn as t};
1
+ import{b as Ce,d as $e,i as U}from"./chunk.QUETLFBJ.js";import{d as Te}from"./chunk.JULD4XFB.js";import{$d as We,Kc as se,L as ke,Qb as ae,Wd as Re,Zd as De,ae as Me,cb as Se,da as M,fa as xe,ga as W,gb as G,ka as _,la as z,ma as Ae,oa as we,pa as Ne,ve as je,wd as ve,xd as Oe}from"./chunk.6AANHELP.js";function V(n,e){return n.display?.labels?.[e]??W(e)}function de(n){let e=U(n);switch(e.type){case"text":case"date":case"number":case"boolean":case"choice":return e.type;default:return}}function Je(n,e){let t=new Map,i=n.tryDefinition(e);for(let[r,a]of Object.entries(i?.edges??{}))t.set(r,{key:r,label:a.description?M(a.description):W(r),about:"edge",far:a.to==="*"?[...n.kinds]:[...a.to]});for(let r of n.definitions)if(r.kind!==e)for(let[a,s]of Object.entries(r.edges??{}))t.has(a)||s.to!=="*"&&!s.to.includes(e)||t.set(a,{key:a,label:s.inverse?M(s.inverse):W(a),about:"edge",far:[r.kind]});return[...t.values()]}var Ze=["current","past","any","flagged","clear"];function Fe(n,e){let t=n?.lifecycle;if(!t||t.retired==="date")return!1;let i=t.retired.map(String);return e.some(r=>r.key===t.field&&i.includes(r.value))}function Be(n,e){let t=n.tryDefinition(e);if(!t)return{kind:e,sorts:[],filters:[],groups:[]};let i=new Set(t.display?.hide??[]),r=t.fields.shape??{},a=[{key:"label",label:"Name",about:"label",type:"text"}],s=[],u=[];for(let[g,k]of Object.entries(r)){if(g==="id"||g==="kind"||g==="label"||i.has(g))continue;let A=en(k);if(A){s.push({key:g,label:V(t,g),about:"field",type:"choice",options:A});continue}let w=de(k);if(!w)continue;let N=V(t,g),O=w==="choice"?Le(k):w==="boolean"?["true","false"]:void 0,S={key:g,label:N,about:"field",type:w,...O?{options:O}:{}};a.push(S),s.push(S),(w==="boolean"||w==="choice")&&u.push(S),w==="date"&&u.push({...S,buckets:["day","week","month","year","decade"]})}for(let g of Je(n,e))a.push(g),s.push(g),u.push(g);let l={key:"is",label:t.lifecycle?"Standing and currency":"Standing",about:"is",type:"choice",options:t.lifecycle?[...Ze]:["flagged","clear"]};s.push(l);let y=t.fieldRoles?.order,f=y&&(y in r||y==="label")?{by:y,direction:"asc"}:void 0;return{kind:e,sorts:a,filters:s,groups:u,...f?{natural:f}:{}}}function On(n,e){let t=[];for(let r of e.filters){let a=r.about==="edge"&&r.far?.length===1?n.tryDefinition(r.far[0]):void 0;if(!(!a||a.kind===e.kind))for(let[s,u]of Object.entries(a.fields.shape??{}))de(u)!=="choice"||a.display?.hide?.includes(s)||t.push({key:`${r.key}.${s}`,label:`${r.label} \xB7 ${V(a,s)}`,about:"via",type:"choice",options:Le(u),far:[a.kind]})}if(t.length===0)return e;let i=e.filters.filter(r=>r.about!=="is");return{...e,filters:[...i,...t,...e.filters.filter(r=>r.about==="is")]}}function Rn(n,e){let t=n.tryDefinition(e.kind),i=Object.entries(t?.computed??{});if(!t||i.length===0)return e;let r=i.filter(([a])=>!e.sorts.some(s=>s.key===a)).map(([a,s])=>({key:a,label:(typeof s=="object"?s.label:void 0)??V(t,a),about:"field",type:"number"}));return{...e,sorts:[...e.sorts,...r]}}function Le(n){let e=U(n);return e.type==="choice"?e.options:[]}function en(n){let e=U(n);return e.type==="several"&&e.of.type==="choice"?e.of.options:void 0}var Ie=n=>n,Pe=n=>n;function nn(n,e,t){let i=new Map;for(let r of[...n.out(e,t),...n.in(e,t)])i.set(r.id,r);return[...i.values()]}function le(n,e,t){let i=n.schema.tryDefinition(e.kind);if(t.key==="is")switch(t.value){case"current":return _(i,Pe(e),n.today);case"past":return!_(i,Pe(e),n.today);case"any":return!0;case"flagged":return n.flagged?.has(e.id)??!1;case"clear":return!(n.flagged?.has(e.id)??!1);default:return!0}let r=i?.fields.shape??{};if(t.key in r){let l=Se(Ie(e),t.key,n.today??ke()),y=de(r[t.key]);if(y==="date"){let[f,g]=t.value.split(":");if(typeof l!="string"||!g)return!1;let k=l.slice(0,10);return f==="before"?k<g:f==="after"?k>g:k===g}if(y==="boolean")return String(l)===t.value;if(Array.isArray(l))return l.some(f=>String(f)===t.value);if(y==="number"){let f=t.value.lastIndexOf(":"),g=f>0?t.value.slice(0,f):"",k=Number(t.value.slice(f+1));if(g==="at-most"||g==="at-least")return typeof l!="number"||!Number.isFinite(k)?!1:g==="at-most"?l<=k:l>=k}return String(l)===t.value}let[a,s]=t.key.split("."),u=nn(n.graph,e.id,a);return s?u.some(l=>String(Ie(l)[s])===t.value):t.value==="*"?u.length>0:t.value==="none"?u.length===0:u.some(l=>l.id===t.value)}var tn=5;function ze(n){return n.normalize("NFD").replace(/\p{M}+/gu,"").toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").trim()}function ce(n){return ze(n).replace(/ /g,"")}var X=new Map,rn=5e4;function $(n){let e=X.get(n);if(e===void 0){X.size>=rn&&X.clear();let t=ze(n);e={tokens:t.split(" ").filter(Boolean),whole:t.replace(/ /g,"")},X.set(n,e)}return e}var T=n=>[...$(n).tokens];function j(n,e){if(e.length===0)return;let{whole:t,tokens:i}=$(n),r=e.join("");if(t.length===0)return;if(t===r)return"exact";if(e.every(s=>i.some(u=>u.startsWith(s))))return t.startsWith(r)?"prefix":e.every(s=>i.includes(s))?"word":"part"}function q(n,e,t=48){let i=n.replace(/\s+/g," ").trim();if(i.length<=t)return i;let r=e[0],a=i.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase(),s=r?a.search(new RegExp(`(^|[^\\p{L}\\p{N}])${on(r)}`,"u")):-1,u=s<0?0:s+(a[s]&&/[\p{L}\p{N}]/u.test(a[s])?0:1),l=Math.max(0,u-Math.floor(t/3));if(l>0){let f=i.lastIndexOf(" ",l);l=f<0?0:f+1}let y=Math.min(i.length,l+t);if(y<i.length){let f=i.indexOf(" ",y);y=f<0||f-y>16?y:f}return`${l>0?"\u2026":""}${i.slice(l,y).trim()}${y<i.length?"\u2026":""}`}var on=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),an=/^([\p{L}][\p{L}\p{N}_-]*):(\S+)$/u;function sn(n){let e=[],t=[];for(let i of n.trim().split(/\s+/).filter(Boolean)){let r=an.exec(i);r?t.push({key:r[1],value:r[2]}):e.push(i)}return{words:e.join(" "),conditions:t}}var Ee=new WeakMap;function Q(n,e){let t=Ee.get(e);if(t&&t.definition===n)return t.texts;let i=dn(n,e);return Ee.set(e,{definition:n,texts:i}),i}function dn(n,e){let t=z(n,e),i=[{field:"label",reading:"Name",text:t}];for(let r of $e(e,n,{limit:Number.POSITIVE_INFINITY}))r.key==="label"||r.value===t||typeof e[r.key]!="boolean"&&i.push({field:r.key,reading:r.label,text:r.markdown?Te(r.value):r.value});return i}var I={exact:0,prefix:1,word:2,part:3,field:4,near:5},Ge=new Set(["a","an","the","of","and","or","for","to","in","on","at","by","with","my","our","is"]);function Ke(n){let e=n;e.length>4&&e.endsWith("ies")?e=`${e.slice(0,-3)}y`:e.length>4&&/(ss|x|ch|sh|z)es$/.test(e)?e=e.slice(0,-2):e.length>3&&e.endsWith("s")&&!/(ss|us|is)$/.test(e)&&(e=e.slice(0,-1));for(let t of["ing","ed"])if(e.length>t.length+2&&e.endsWith(t)){e=e.slice(0,-t.length),/([b-df-hj-km-np-rtv-z])\1$/.test(e)&&(e=e.slice(0,-1));break}return e.length>3&&e.endsWith("e")?e.slice(0,-1):e}function He(n,e,t){if(Math.abs(n.length-e.length)>t)return t+1;let i=[],r=Array.from({length:e.length+1},(a,s)=>s);for(let a=1;a<=n.length;a++){let s=[a],u=a;for(let l=1;l<=e.length;l++){let y=Math.min(r[l]+1,s[l-1]+1,r[l-1]+(n[a-1]===e[l-1]?0:1));a>1&&l>1&&n[a-1]===e[l-2]&&n[a-2]===e[l-1]&&(y=Math.min(y,i[l-2]+1)),s[l]=y,y<u&&(u=y)}if(u>t)return t+1;i=r,r=s}return r[e.length]}var Y=new Map;function ln(n,e){let t=Y.get(n);t||(Y.size>=64&&Y.clear(),Y.set(n,t=new Map));let i=t.get(e);return i===void 0&&(i=cn(n,e)??null,t.set(e,i)),i??void 0}function cn(n,e){if(/\d/.test(n))return;let t=Ke(n);if(t.length>=3&&(Ke(e)===t||t.length>=4&&e.startsWith(t)))return"stem";let i=n.length<4?0:n.length<=7?1:2;if(i!==0){if(He(n,e,i)<=i)return"spelling";if(n.length>=5){for(let r=n.length-i;r<=n.length+i;r++)if(r<e.length&&He(n,e.slice(0,r),i)<=i)return"spelling"}}}function fn(n,e){let t=e.length>1?e.filter(r=>!Ge.has(r)):e;if(t.length===0)return;let i;for(let r of t){let a;for(let s of n){for(let u of $(s.text).tokens){if(u.startsWith(r)){a={text:s,matched:u};break}let l=a?void 0:ln(r,u);l&&(a={text:s,matched:u,by:l})}if(a&&!a.by)break}if(!a)return;a.by&&!i&&(i={text:a.text,asked:r,matched:a.matched,by:a.by})}if(i)return{field:i.text.field,reading:i.text.reading,fragment:q(i.text.text,[i.matched]),strength:"near",asked:i.asked,matched:i.matched,by:i.by}}var un=80;function gn(n,e,t){let i=T(e).filter(s=>!Ge.has(s)).join(" ")||e,r=t===void 0?[]:T(t),a=r.length>0&&n.find(s=>r.every(u=>$(s.text).tokens.some(l=>l.startsWith(u))))||n[0];return{field:a.field,reading:a.reading,fragment:q(a.text,r),strength:"near",asked:i,matched:(t??a.text).slice(0,un),by:"meaning"}}function _e(n,e,t,i){let r=T(t);if(r.length===0)return;if(i){let A=Q(n,e),w=i.includes("label")||i.some(v=>typeof e[v]=="string"&&e[v]===A[0].text),N=A.filter((v,D)=>D===0?w:i.includes(v.field)),O=v=>D=>$(D.text).tokens.some(P=>P.startsWith(v));if(!r.every(v=>N.some(O(v))))return;let S=N.find(O(r[0]));return{field:S.field,reading:S.reading,fragment:q(S.text,r),strength:S.field==="label"?j(S.text,r)??"field":"field"}}let a=Q(n,e),[s,...u]=a,l=j(s.text,r);if(l)return{field:"label",reading:s.reading,fragment:q(s.text,r),strength:l};let y=A=>w=>$(w.text).tokens.some(N=>N.startsWith(A));if(!r.every(A=>a.some(y(A))))return;let f=T(s.text),g=r.find(A=>!f.some(w=>w.startsWith(A)))??r[0],k=u.find(y(g));return{field:k.field,reading:k.reading,fragment:q(k.text,[g]),strength:"field"}}var yn=512,hn=64;function pn(n){let e=new Map;if(n.length===0)return e;let t=n.slice(-yn),i=n[n.length-1].seq;for(let r of t){let a=Math.pow(.5,(i-r.seq)/hn);for(let s of r.writes)e.set(s,(e.get(s)??0)+a)}return e}var ue=(n,e)=>we({tryDefinition:()=>n},e),fe=(n,e)=>De({tryDefinition:()=>n},e);function mn(n,e,t){let i=n.tryDefinition(e),r=[{field:"plural",text:ue(i,e)},{field:"kind",text:W(e)},...i?.noun?[{field:"noun",text:i.noun}]:[],...(i?.aliases??[]).map(s=>({field:"alias",text:s}))],a;for(let s of r){let u=j(s.text,t);u&&(!a||I[u]<I[a.strength])&&(a={strength:u,...s})}return a}var bn,kn=(n,e)=>(bn??=new Intl.Collator(void 0,{sensitivity:"base",numeric:!0})).compare(n,e),qe=(n,e)=>(n.nearly??0)-(e.nearly??0)||(n.archived??0)-(e.archived??0)||n.tier-e.tier||n.inKind-e.inKind||n.near-e.near||n.past-e.past||n.touched-e.touched||n.flagged-e.flagged||kn(n.name,e.name)||(n.id<e.id?-1:n.id>e.id?1:0);function En(n,e,t={}){let i=n.schema,r=sn(e),a=T(r.words),s=t.principal??{kind:"human"},u=n.kindsKeptFrom(s),l=n.modules.disabledKinds,y=r.conditions.filter(o=>o.key==="kind").map(o=>o.value),f=r.conditions.filter(o=>o.key==="is").map(o=>o.value),g=f.includes("any")||f.includes("past"),k=f.includes("past")&&!f.includes("any")&&!f.includes("current"),A=f.includes("archived")?!0:t.archived??"all",w=(o,d)=>{let c=ce(d),h=i.tryDefinition(o);return ce(o)===c||ce(ue(h,o))===c},N=i.kinds.filter(o=>!u.has(o)&&!l.has(o)&&(t.kinds===void 0||t.kinds.includes(o))&&(y.length===0||y.some(d=>w(o,d)))),S=r.conditions.filter(o=>o.key!=="kind").map(o=>({...o,admittedBy:N.filter(d=>Be(i,d).filters.some(c=>c.key===o.key))})),v=S.filter(o=>o.key!=="is"),D=f.filter(o=>o==="flagged"||o==="clear"||o==="past"||o==="archived"),P={kinds:N,past:g},Qe={hits:[],words:r.words,conditions:S,searched:P,byKind:{},total:0,matched:[]};if(a.length===0&&v.length===0&&D.length===0)return Qe;let J=t.today,F=t.flagged??new Set(n.violations().flatMap(o=>o.nodeIds)),Ue=t.touched??pn(n.log.all()),Z=new Set;for(let o of t.from??[]){Z.add(o);for(let d of n.graph.neighbors(o))Z.add(d.id)}let ge=ve(n,s)?Oe(n,s):void 0,ee=ae.keptFrom?.(n,s)&&n.seenBy(s).graph,ne=o=>je(o,t.basePath===void 0?{}:{basePath:t.basePath}),ye={schema:i,graph:n.graph,flagged:F,...J?{today:J}:{}},R=[],B={},L=[],E=[],K=(o,d,c,h,p,m)=>{let x=z(c,o);B[d]=(B[d]??0)+1,R.push({hit:{about:"node",id:o.id,kind:d,label:x,why:p,current:h,flagged:F.has(o.id),address:ne(`${fe(c,d)}/${encodeURIComponent(o.id)}`),...m===void 0?{}:{near:!0},...G(o)?{archived:!0}:{}},...m===void 0?{}:{nearly:2-m},tier:I[p.strength],inKind:d===t.inKind?0:1,near:Z.has(o.id)?0:1,past:h?0:1,archived:G(o)?1:0,touched:-(Ue.get(o.id)??0),flagged:F.has(o.id)?0:1,name:x,id:o.id})};for(let o of N){let d=i.tryDefinition(o),c=S.filter(p=>p.key!=="is"&&p.admittedBy.includes(o));if(a.length===0&&c.length===0&&D.length===0)continue;let h=Fe(d,c);for(let p of n.graph.nodesOfKind(o,{archived:A})){if(ge&&!ge(p.id))continue;let m=ee?ee.getNode(p.id):p;if(!m)continue;let x=_(d,m,J);if(!g&&!h&&!x){if(a.length>0&&f.length===0&&c.every(b=>le(ye,m,b))){let b=_e(d,m,r.words);b&&E.push({node:m,kind:o,definition:d,why:b})}continue}if(k&&x||!c.every(b=>le(ye,m,b))||f.includes("flagged")&&!F.has(m.id)||f.includes("clear")&&F.has(m.id))continue;let C=a.length>0?_e(d,m,r.words):c[0]?{field:c[0].key,reading:W(c[0].key),fragment:`${c[0].key}:${c[0].value}`,strength:"field"}:{field:"is",reading:"Is",fragment:`is:${D[0]}`,strength:"field"};C?K(m,o,d,x,C):a.length>0&&L.push({node:m,kind:o,definition:d,current:x})}}let te=o=>o.strength!=="field",re=!1;if(E.length>0&&R.length===0){re=!0;for(let o of E)K(o.node,o.kind,o.definition,!1,o.why)}else if(E.some(o=>te(o.why))&&!R.some(o=>te(o.hit.why))){re=!0;for(let o of E)te(o.why)&&K(o.node,o.kind,o.definition,!1,o.why)}let he=t.near!==!1&&a.length>0&&R.length<tn&&L.length>0,ie=new Set;if(he)for(let o of L){let d=fn(Q(o.definition,o.node),a);d&&(ie.add(o.node.id),K(o.node,o.kind,o.definition,o.current,d,d.by==="stem"?.9:.8))}let Ve=o=>o==="exact"||o==="prefix"?-1:I[o],oe=(o,d,c,h)=>({hit:o,tier:Ve(d),inKind:1,near:1,past:0,touched:0,flagged:1,name:c,id:h});if(a.length>0){for(let d of N){let c=mn(i,d,a);if(!c)continue;let h=Ne(i,d),p={field:c.field,reading:c.field==="plural"?"Plural":"Kind",fragment:c.text,strength:c.strength};R.push(oe({about:"kind",kind:d,label:h,why:p,count:B[d]??0,address:ne(fe(i.tryDefinition(d),d))},c.strength,h,`kind:${d}`))}let o=t.places??[];for(let d of Re(o.filter(c=>N.includes(c.kind)))){if(d.across&&u.has(d.across))continue;let c=j(d.title,a);if(!c)continue;let h={field:"title",reading:"Title",fragment:d.title,strength:c},p=Me(d,o)?fe(i.tryDefinition(d.kind),d.kind).slice(1):void 0,m=ne(We(d.as,p));R.push(oe({about:"place",kind:d.kind,title:d.title,as:d.as,why:h,address:m},c,d.title,`place:${d.kind}:${d.as}`))}for(let d of n.allInvariants()){let c=d.scope==="graph"?void 0:d.scope.kind;if(c&&!N.includes(c))continue;let h=d.label??W(d.name),p=j(h,a),m=p?void 0:j(W(d.name),a),x=p??m;if(!x)continue;let C={field:p?"label":"name",reading:p?"Rule":"Name",fragment:p?h:d.name,strength:x};R.push(oe({about:"rule",name:d.name,label:h,...c?{kind:c}:{},why:C},x,h,`rule:${d.name}`))}}let pe=()=>{R.sort(qe);let o=t.limit??50,d=R.slice(0,o).map(b=>b.hit),c=d.flatMap(b=>b.about==="node"?[(ee||n.graph).getNode(b.id)]:[]).filter(Boolean),h=Ce(c,b=>i.tryDefinition(b)),p=d.map(b=>b.about==="node"&&h.has(b.id)?{...b,apart:h.get(b.id)}:b),m=Object.values(B).reduce((b,Ye)=>b+Ye,0),x=R.flatMap(b=>b.hit.about==="node"?[b.hit.id]:[]),C=t.subject&&N.includes(String(n.graph.getNode(t.subject)?.kind))?xn(n,t.subject,r.words,{principal:s}):[];return{hits:[...p,...C],words:r.words,conditions:S,searched:re?{...P,past:!0}:P,byKind:{...B},total:m,matched:x}},H=pe(),me=t.rank;if(!he||!me)return H;let be=L.filter(o=>!ie.has(o.node.id)).map(({node:o,kind:d,definition:c})=>({id:o.id,kind:d,label:z(c,o),texts:Q(c,o)}));if(be.length===0)return H;let Xe=(async()=>{let o;try{o=await me(r.words,be)}catch{return H}let d=new Map(L.filter(h=>!ie.has(h.node.id)).map(h=>[h.node.id,h])),c=!1;for(let{id:h,score:p,matched:m}of Array.isArray(o)?o:[]){let x=d.get(h);!x||!(p>0)||(d.delete(h),c=!0,K(x.node,x.kind,x.definition,x.current,gn(Q(x.definition,x.node),r.words,typeof m=="string"?m:void 0),Math.min(1,p)))}return c?pe():H})();return{...H,later:Xe}}function xn(n,e,t,i={}){let r=i.principal??{kind:"human"},a=(ae.keptFrom?.(n,r)?n.seenBy(r):n).graph.getNode(e);if(!a)return[];if(n.kindsKeptFrom(r).has(a.kind))return[];let s=T(t),u=z(n.schema.tryDefinition(a.kind),a),l=[];for(let f of n.allMutations()){let g=f.subject;if(!g||g.kinds!=="*"&&!g.kinds.includes(a.kind))continue;let k=f.derived?.act;if((k==="archive"||k==="merge")&&G(a)||k==="unarchive"&&!G(a)||k==="leave-alone"&&se(a)||k==="allow-tidying"&&!se(a)||!n.permits({name:f.name,args:{[g.arg]:a.id}},r).ok)continue;let A=Ae(f),w=T(A),N=s.filter(v=>w.some(D=>D.startsWith(v))),O=N.length>0?j(A,N):void 0,S=O?{field:"title",reading:"Act",fragment:A,strength:O}:{field:"subject",reading:"On",fragment:u,strength:"field"};l.push({hit:{about:"act",name:f.name,title:A,subject:a.id,why:S,destructive:f.destructive===!0},tier:O?I[O]:I.field+1,inKind:0,near:0,past:f.destructive?1:0,touched:0,flagged:f.pinned?0:1,name:A,id:`act:${f.name}`})}l.sort(qe);let y=l.map(f=>f.hit);return i.limit===void 0?y:y.slice(0,i.limit)}function Kn(n,e){let t=e.kinds.map((a,s)=>{let u=ue(n.tryDefinition(a),a);return s===0?u:u.toLowerCase()}),i=xe(t)||"Nothing";return e.kinds.some(a=>n.tryDefinition(a)?.lifecycle)?e.past?`${M(i)}, past ones included.`:`${M(i)}, current ones; add is:any for past ones.`:`${M(i)}.`}export{V as a,de as b,Je as c,Fe as d,Be as e,On as f,Rn as g,Le as h,Ie as i,Pe as j,nn as k,le as l,ze as m,ce as n,sn as o,_e as p,pn as q,En as r,xn as s,Kn as t};
@@ -1 +1 @@
1
- import{c as m}from"./chunk.UGQYMN4J.js";import{ga as c,la as u,ma as p,oa as f,ta as h,ua as l}from"./chunk.ZEZUKRC6.js";function M(t,e){let n=t.schema.kinds,r="kind"in e?e.kind:void 0;if(r!==void 0&&!n.includes(r))return`There is no kind "${r}" in this app. Its kinds are: ${n.join(", ")}.`;if(e.on==="act"&&e.act!==void 0&&t.allMutations&&!t.allMutations().some(i=>i.name===e.act))return`There is no act "${e.act}" in this app.`;let o="record"in e?e.record:void 0;if(o!==void 0&&t.graph&&!t.graph.getNode(o))return`No record "${o}" is here to be told about.`;if(o!==void 0&&r!==void 0&&t.graph&&t.graph.getNode(o)?.kind!==r)return`\u201C${o}\u201D is not ${h(r)}.`;if(e.on==="changed"&&e.kind===void 0&&e.record===void 0)return"Say which kind, or which record, to be told about.";if(e.on==="reaches"){if(e.condition.trim()==="")return"Say what it should reach: a condition like done == true.";try{m(e.condition)}catch(i){return`The condition does not read: ${i instanceof Error?i.message:String(i)}.`}}}function d(t,e){let n=t.graph?.getNode(e);return n?u(t.schema.tryDefinition(n.kind),n):e}function g(t,e){let n=t.allMutations?.().find(r=>r.name===e);return n?p(n):c(e)}function v(t,e){let{when:n}=e,r=e.alsoMine?"anyone":"someone else",o=s=>l(t.schema.tryDefinition(s),s),i=s=>{let a=o(s);return`${/^[aeiou]/i.test(a)?"an":"a"} ${a}`};switch(n.on){case"act":{let s=n.act!==void 0?`\u201C${g(t,n.act)}\u201D`:"an act";return`When ${r} runs ${s}${n.record!==void 0?` on \u201C${d(t,n.record)}\u201D`:""}`}case"created":return`When ${r} adds ${i(n.kind)}`;case"changed":return n.record!==void 0?`When ${r} changes \u201C${d(t,n.record)}\u201D`:`When ${r} changes any of the ${f(t.schema,n.kind)}`;case"reaches":return`When ${n.record!==void 0?`\u201C${d(t,n.record)}\u201D`:i(n.kind)} reaches ${n.condition}${e.alsoMine?"":" (by someone else)"}`}}export{M as a,v as b};
1
+ import{c as m}from"./chunk.UD7VLXPM.js";import{ga as c,la as u,ma as p,oa as f,ta as h,ua as l}from"./chunk.6AANHELP.js";function M(t,e){let n=t.schema.kinds,r="kind"in e?e.kind:void 0;if(r!==void 0&&!n.includes(r))return`There is no kind "${r}" in this app. Its kinds are: ${n.join(", ")}.`;if(e.on==="act"&&e.act!==void 0&&t.allMutations&&!t.allMutations().some(i=>i.name===e.act))return`There is no act "${e.act}" in this app.`;let o="record"in e?e.record:void 0;if(o!==void 0&&t.graph&&!t.graph.getNode(o))return`No record "${o}" is here to be told about.`;if(o!==void 0&&r!==void 0&&t.graph&&t.graph.getNode(o)?.kind!==r)return`\u201C${o}\u201D is not ${h(r)}.`;if(e.on==="changed"&&e.kind===void 0&&e.record===void 0)return"Say which kind, or which record, to be told about.";if(e.on==="reaches"){if(e.condition.trim()==="")return"Say what it should reach: a condition like done == true.";try{m(e.condition)}catch(i){return`The condition does not read: ${i instanceof Error?i.message:String(i)}.`}}}function d(t,e){let n=t.graph?.getNode(e);return n?u(t.schema.tryDefinition(n.kind),n):e}function g(t,e){let n=t.allMutations?.().find(r=>r.name===e);return n?p(n):c(e)}function v(t,e){let{when:n}=e,r=e.alsoMine?"anyone":"someone else",o=s=>l(t.schema.tryDefinition(s),s),i=s=>{let a=o(s);return`${/^[aeiou]/i.test(a)?"an":"a"} ${a}`};switch(n.on){case"act":{let s=n.act!==void 0?`\u201C${g(t,n.act)}\u201D`:"an act";return`When ${r} runs ${s}${n.record!==void 0?` on \u201C${d(t,n.record)}\u201D`:""}`}case"created":return`When ${r} adds ${i(n.kind)}`;case"changed":return n.record!==void 0?`When ${r} changes \u201C${d(t,n.record)}\u201D`:`When ${r} changes any of the ${f(t.schema,n.kind)}`;case"reaches":return`When ${n.record!==void 0?`\u201C${d(t,n.record)}\u201D`:i(n.kind)} reaches ${n.condition}${e.alsoMine?"":" (by someone else)"}`}}export{M as a,v as b};
@@ -0,0 +1 @@
1
+ import{a,b}from"./chunk.BPNW5KCP.js";import"./chunk.U5P23GO7.js";import"./chunk.YL2RBZFE.js";import"./chunk.H3IGXHZR.js";import"./chunk.7TDML5YU.js";import"./chunk.3VEZ5MOC.js";import"./chunk.SDO3U72B.js";import"./chunk.6AANHELP.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";export{a as ActivityFilter,b as InteractionRow};
@@ -1 +1 @@
1
- import{a as N,b as g,c as f,d as A,e as m,g as b,h as x}from"./chunk.MUSMNKE4.js";import{E as $,P as y,Z as c}from"./chunk.ZEZUKRC6.js";var E=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],j=["sun","mon","tue","wed","thu","fri","sat"],h="(jan(?:uary)?|feb(?:ruary)?|mar(?:ch)?|apr(?:il)?|may|june?|july?|aug(?:ust)?|sept?(?:ember)?|oct(?:ober)?|nov(?:ember)?|dec(?:ember)?)",W="(sun(?:day)?|mon(?:day)?|tue(?:s|sday)?|wed(?:nesday)?|thu(?:r|rs|rsday)?|fri(?:day)?|sat(?:urday)?)",O=n=>E.indexOf(n.slice(0,3))+1,D=n=>n===void 0?void 0:n.length===2?2e3+Number(n):Number(n);function T(n){try{let r=new Intl.DateTimeFormat(n,{month:"numeric",day:"numeric"}).formatToParts(0).map(o=>o.type);return r.indexOf("month")<r.indexOf("day")}catch{return!0}}function R(n){let r=(e,i)=>({minutes:i,rest:`${n.slice(0,e.index)} ${n.slice(e.index+e[0].length)}`}),o=/\b(noon|midday)\b/.exec(n);if(o)return r(o,12*60);if(o=/\bmidnight\b/.exec(n),o)return r(o,0);if(o=/\b(\d{1,2})(?::(\d{2}))?\s*([ap])\.?m?\.?(?=\s|$)/.exec(n),o){let e=Number(o[1]),i=Number(o[2]??0);return e<1||e>12||i>59?{rest:n,bad:!0}:r(o,(e%12+(o[3]==="p"?12:0))*60+i)}if(o=/\b(\d{1,2}):(\d{2})\b/.exec(n),o){let e=Number(o[1]),i=Number(o[2]);return e>23||i>59?{rest:n,bad:!0}:r(o,e*60+i)}if(o=/\bat\s+(\d{1,2})\b/.exec(n),o){let e=Number(o[1]);return e>23?{rest:n,bad:!0}:r(o,(e>=1&&e<=7?e+12:e)*60)}let t=/\b(morning|afternoon|evening|tonight)\b/.exec(n);return t?{minutes:{morning:9,afternoon:15,evening:18,tonight:20}[t[1]]*60,rest:t[1]==="tonight"?`${n.slice(0,t.index)} today ${n.slice(t.index+t[0].length)}`:`${n.slice(0,t.index)} ${n.slice(t.index+t[0].length)}`}:{rest:n}}function M(n,r,o){let t=n.replace(/\b(on|at|the|of|this)\b/g," ").replace(/\s+/g," ").trim();if(t==="")return null;if(t==="today"||t==="now")return r;if(t==="tomorrow"||t==="tmrw"||t==="tmr")return f(r,1);if(t==="yesterday")return f(r,-1);if(t==="next week")return f(r,7);let e=/^in (\d{1,3}) (day|days|week|weeks)$/.exec(t);if(e)return f(r,Number(e[1])*(e[2].startsWith("week")?7:1));if(e=new RegExp(`^(next )?${W}$`).exec(t),e){let d=(j.indexOf(e[2].slice(0,3))-A(r)+7)%7;return f(r,e[1]&&d===0?7:d)}if(e=/^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(t),e)return m(Number(e[1]),Number(e[2]),Number(e[3]));let i=t.replace(new RegExp(`^${W} `),"");e=new RegExp(`^(\\d{1,2})(?:st|nd|rd|th)? ${h}(?: (\\d{4}))?$`).exec(i);let s=e?{date:e[1],month:e[2],year:e[3]}:void 0;e=new RegExp(`^${h} (\\d{1,2})(?:st|nd|rd|th)?(?: (\\d{4}))?$`).exec(i);let u=s??(e?{date:e[2],month:e[1],year:e[3]}:void 0);if(u)return I(r,D(u.year),O(u.month),Number(u.date));if(e=/^(\d{1,2})[/.-](\d{1,2})(?:[/.-](\d{2}|\d{4}))?$/.exec(i),e){let[a,d]=[Number(e[1]),Number(e[2])],[l,p]=T(o)?[a,d]:[d,a];return I(r,D(e[3]),l,p)}}function I(n,r,o,t){if(r!==void 0)return m(r,o,t);let e=Number(n.slice(0,4)),i=m(e,o,t);return i===void 0?m(e+1,o,t):g(n)-g(i)>183*N?m(e+1,o,t):i}function L(n){if(typeof n=="number")return Number.isInteger(n)&&n>=1e3&&n<=9999?String(n):void 0;let r=String(n).trim().toLowerCase().replace(/,/g," ").replace(/\s+/g," ");if(/^\d{4}$/.test(r))return Number(r)>=1e3?r:void 0;let o=(e,i)=>i>=1&&i<=12&&Number(e)>=1e3?`${e}-${String(i).padStart(2,"0")}`:void 0,t=/^(\d{4})[-/](\d{1,2})$/.exec(r);if(t)return o(t[1],Number(t[2]));if(t=/^(\d{1,2})\/(\d{4})$/.exec(r),t)return o(t[2],Number(t[1]));if(t=new RegExp(`^${h}\\.? (\\d{4})$`).exec(r),t)return o(t[2],O(t[1]))}function P(n,r){let o=n.trim();if(b(o)){let u=x(o);if(u)return r.time?u:{day:u.day}}let t=n.toLowerCase().replace(/,/g," ").replace(/(\d{4}-\d{2}-\d{2})t(\d\d:\d\d)(:\d\d(\.\d+)?)?/,"$1 $2").replace(/\s+/g," ").trim();if(t==="")return;let e=R(t);if(e.bad)return;let i=M(e.rest,r.today,r.locale??$);if(i===void 0||i===null&&e.minutes===void 0)return;let s=i??r.base?.day??r.today;return r.time?{day:s,minutes:e.minutes??r.base?.minutes??9*60}:{day:s}}function B(n){if(n===void 0||n==="web"||n.startsWith("ai:")||n.startsWith("app:"))return;if(n==="api")return"via the API";if(n==="cli")return"via the command line";let[r,...o]=n.split(":"),t=o.join(":");return(r==="mcp"||r==="view")&&t?`via ${t}`:r==="mcp"?"via an agent's tools":`via ${n}`}var S=n=>{if(!n.currency)return{before:!0};try{let r=y(n.locale),o=new Intl.NumberFormat(r,{style:"currency",currency:n.currency}).formatToParts(1),t=o.findIndex(s=>s.type==="currency"),e=o.findIndex(s=>s.type==="integer"),i;try{i=new Intl.DisplayNames([r],{type:"currency"}).of(n.currency)}catch{}return{...t>=0?{symbol:o[t].value}:{},before:t<e,...i?{name:i}:{}}}catch{return{symbol:n.currency,before:!0}}};function H(n){let r=n.locale;if(n.format==="money"){let{symbol:o,before:t,name:e}=S(n),i=c(1250,r,{minimumFractionDigits:2,maximumFractionDigits:2});return{...o?t?{prefix:o}:{suffix:o}:{},placeholder:i,hint:e?`in ${e}`:n.currency?`in ${n.currency}`:"an amount of money"}}return n.format==="percent"?{suffix:"%",placeholder:c(15,r),hint:"as a percent"}:{...n.unit?{suffix:n.unit}:{},placeholder:"",hint:n.unit?`in ${n.unit}`:"a number"}}function v(n,r){return n===void 0||!Number.isFinite(n)?"":r.format==="money"?c(n,r.locale,Number.isInteger(n)?{maximumFractionDigits:0}:{minimumFractionDigits:2,maximumFractionDigits:2}):r.format==="percent"?c(n*100,r.locale,{maximumFractionDigits:4}):c(n,r.locale,{maximumFractionDigits:6})}function C(n){try{let r=new Intl.NumberFormat(y(n)).formatToParts(12345.6);return{group:r.find(o=>o.type==="group")?.value??",",decimal:r.find(o=>o.type==="decimal")?.value??"."}}catch{return{group:",",decimal:"."}}}function K(n,r){let{group:o,decimal:t}=C(r),e=n.replace(/[\s  ']/g,"").replace(/[−–]/g,"-");if(t!=="."&&!e.includes(t)&&/^-?\d+\.\d{1,2}$/.test(e))return Number(e);if(o&&(e=e.split(o).join("")),t!=="."&&(e=e.replace(t,".")),!/^-?(\d+\.?\d*|\.\d+)$/.test(e))return;let i=Number(e);return Number.isFinite(i)?i:void 0}function Y(n,r){let o=n.trim();if(o==="")return;let t=r?.format==="money"&&r.currency?S(r).symbol:void 0,e=o;t&&(e=e.split(t).join("")),r?.currency&&(e=e.replace(new RegExp(r.currency,"gi"),"")),e=e.replace(/^[$€£¥₹]|[$€£¥₹]$/g,""),/%\s*$/.test(e)&&(e=e.replace(/%\s*$/,"")),r?.unit&&r.format!=="money"&&(e=e.replace(new RegExp(`\\s*${r.unit.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*$`),""));let s=K(e,r?.locale);if(s!==void 0)return r?.format==="percent"?s/100:s}var w=/^[0-9a-f]{32}$/,F=n=>n.replace(/-/g,"").toLowerCase();function _(n,r,o){if(!(!n||typeof n!="object"))for(let[t,e]of Object.entries(n)){if(!e||typeof e!="object")continue;if(e.system==="google-calendar"&&e.kind===r)return{connection:t,system:"google-calendar",words:"Google Calendar"};if(e.system!=="notion")continue;let s=(Array.isArray(e.sources)?e.sources:[{kind:e.kind,source:e.source}]).find(p=>p&&p.kind===r);if(!s)continue;let u=typeof s.source=="string"&&!w.test(F(s.source))?s.source:void 0,a=o.startsWith(`${r}:${t}-`)?o.slice(`${r}:${t}-`.length):void 0,d=typeof e.database=="string"?F(e.database):void 0,l=a&&w.test(a)?a:d&&w.test(d)?d:void 0;return{connection:t,system:"notion",words:u?`Notion \xB7 ${u}`:"Notion",...l?{href:`https://www.notion.so/${l}`}:{}}}}export{B as a,H as b,v as c,Y as d,L as e,P as f,_ as g};
1
+ import{a as N,b as g,c as f,d as A,e as m,g as b,h as x}from"./chunk.HWFJQ42Y.js";import{E as $,P as y,Z as c}from"./chunk.6AANHELP.js";var E=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],j=["sun","mon","tue","wed","thu","fri","sat"],h="(jan(?:uary)?|feb(?:ruary)?|mar(?:ch)?|apr(?:il)?|may|june?|july?|aug(?:ust)?|sept?(?:ember)?|oct(?:ober)?|nov(?:ember)?|dec(?:ember)?)",W="(sun(?:day)?|mon(?:day)?|tue(?:s|sday)?|wed(?:nesday)?|thu(?:r|rs|rsday)?|fri(?:day)?|sat(?:urday)?)",O=n=>E.indexOf(n.slice(0,3))+1,D=n=>n===void 0?void 0:n.length===2?2e3+Number(n):Number(n);function T(n){try{let r=new Intl.DateTimeFormat(n,{month:"numeric",day:"numeric"}).formatToParts(0).map(o=>o.type);return r.indexOf("month")<r.indexOf("day")}catch{return!0}}function R(n){let r=(e,i)=>({minutes:i,rest:`${n.slice(0,e.index)} ${n.slice(e.index+e[0].length)}`}),o=/\b(noon|midday)\b/.exec(n);if(o)return r(o,12*60);if(o=/\bmidnight\b/.exec(n),o)return r(o,0);if(o=/\b(\d{1,2})(?::(\d{2}))?\s*([ap])\.?m?\.?(?=\s|$)/.exec(n),o){let e=Number(o[1]),i=Number(o[2]??0);return e<1||e>12||i>59?{rest:n,bad:!0}:r(o,(e%12+(o[3]==="p"?12:0))*60+i)}if(o=/\b(\d{1,2}):(\d{2})\b/.exec(n),o){let e=Number(o[1]),i=Number(o[2]);return e>23||i>59?{rest:n,bad:!0}:r(o,e*60+i)}if(o=/\bat\s+(\d{1,2})\b/.exec(n),o){let e=Number(o[1]);return e>23?{rest:n,bad:!0}:r(o,(e>=1&&e<=7?e+12:e)*60)}let t=/\b(morning|afternoon|evening|tonight)\b/.exec(n);return t?{minutes:{morning:9,afternoon:15,evening:18,tonight:20}[t[1]]*60,rest:t[1]==="tonight"?`${n.slice(0,t.index)} today ${n.slice(t.index+t[0].length)}`:`${n.slice(0,t.index)} ${n.slice(t.index+t[0].length)}`}:{rest:n}}function M(n,r,o){let t=n.replace(/\b(on|at|the|of|this)\b/g," ").replace(/\s+/g," ").trim();if(t==="")return null;if(t==="today"||t==="now")return r;if(t==="tomorrow"||t==="tmrw"||t==="tmr")return f(r,1);if(t==="yesterday")return f(r,-1);if(t==="next week")return f(r,7);let e=/^in (\d{1,3}) (day|days|week|weeks)$/.exec(t);if(e)return f(r,Number(e[1])*(e[2].startsWith("week")?7:1));if(e=new RegExp(`^(next )?${W}$`).exec(t),e){let d=(j.indexOf(e[2].slice(0,3))-A(r)+7)%7;return f(r,e[1]&&d===0?7:d)}if(e=/^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(t),e)return m(Number(e[1]),Number(e[2]),Number(e[3]));let i=t.replace(new RegExp(`^${W} `),"");e=new RegExp(`^(\\d{1,2})(?:st|nd|rd|th)? ${h}(?: (\\d{4}))?$`).exec(i);let s=e?{date:e[1],month:e[2],year:e[3]}:void 0;e=new RegExp(`^${h} (\\d{1,2})(?:st|nd|rd|th)?(?: (\\d{4}))?$`).exec(i);let u=s??(e?{date:e[2],month:e[1],year:e[3]}:void 0);if(u)return I(r,D(u.year),O(u.month),Number(u.date));if(e=/^(\d{1,2})[/.-](\d{1,2})(?:[/.-](\d{2}|\d{4}))?$/.exec(i),e){let[a,d]=[Number(e[1]),Number(e[2])],[l,p]=T(o)?[a,d]:[d,a];return I(r,D(e[3]),l,p)}}function I(n,r,o,t){if(r!==void 0)return m(r,o,t);let e=Number(n.slice(0,4)),i=m(e,o,t);return i===void 0?m(e+1,o,t):g(n)-g(i)>183*N?m(e+1,o,t):i}function L(n){if(typeof n=="number")return Number.isInteger(n)&&n>=1e3&&n<=9999?String(n):void 0;let r=String(n).trim().toLowerCase().replace(/,/g," ").replace(/\s+/g," ");if(/^\d{4}$/.test(r))return Number(r)>=1e3?r:void 0;let o=(e,i)=>i>=1&&i<=12&&Number(e)>=1e3?`${e}-${String(i).padStart(2,"0")}`:void 0,t=/^(\d{4})[-/](\d{1,2})$/.exec(r);if(t)return o(t[1],Number(t[2]));if(t=/^(\d{1,2})\/(\d{4})$/.exec(r),t)return o(t[2],Number(t[1]));if(t=new RegExp(`^${h}\\.? (\\d{4})$`).exec(r),t)return o(t[2],O(t[1]))}function P(n,r){let o=n.trim();if(b(o)){let u=x(o);if(u)return r.time?u:{day:u.day}}let t=n.toLowerCase().replace(/,/g," ").replace(/(\d{4}-\d{2}-\d{2})t(\d\d:\d\d)(:\d\d(\.\d+)?)?/,"$1 $2").replace(/\s+/g," ").trim();if(t==="")return;let e=R(t);if(e.bad)return;let i=M(e.rest,r.today,r.locale??$);if(i===void 0||i===null&&e.minutes===void 0)return;let s=i??r.base?.day??r.today;return r.time?{day:s,minutes:e.minutes??r.base?.minutes??9*60}:{day:s}}function B(n){if(n===void 0||n==="web"||n.startsWith("ai:")||n.startsWith("app:"))return;if(n==="api")return"via the API";if(n==="cli")return"via the command line";let[r,...o]=n.split(":"),t=o.join(":");return(r==="mcp"||r==="view")&&t?`via ${t}`:r==="mcp"?"via an agent's tools":`via ${n}`}var S=n=>{if(!n.currency)return{before:!0};try{let r=y(n.locale),o=new Intl.NumberFormat(r,{style:"currency",currency:n.currency}).formatToParts(1),t=o.findIndex(s=>s.type==="currency"),e=o.findIndex(s=>s.type==="integer"),i;try{i=new Intl.DisplayNames([r],{type:"currency"}).of(n.currency)}catch{}return{...t>=0?{symbol:o[t].value}:{},before:t<e,...i?{name:i}:{}}}catch{return{symbol:n.currency,before:!0}}};function H(n){let r=n.locale;if(n.format==="money"){let{symbol:o,before:t,name:e}=S(n),i=c(1250,r,{minimumFractionDigits:2,maximumFractionDigits:2});return{...o?t?{prefix:o}:{suffix:o}:{},placeholder:i,hint:e?`in ${e}`:n.currency?`in ${n.currency}`:"an amount of money"}}return n.format==="percent"?{suffix:"%",placeholder:c(15,r),hint:"as a percent"}:{...n.unit?{suffix:n.unit}:{},placeholder:"",hint:n.unit?`in ${n.unit}`:"a number"}}function v(n,r){return n===void 0||!Number.isFinite(n)?"":r.format==="money"?c(n,r.locale,Number.isInteger(n)?{maximumFractionDigits:0}:{minimumFractionDigits:2,maximumFractionDigits:2}):r.format==="percent"?c(n*100,r.locale,{maximumFractionDigits:4}):c(n,r.locale,{maximumFractionDigits:6})}function C(n){try{let r=new Intl.NumberFormat(y(n)).formatToParts(12345.6);return{group:r.find(o=>o.type==="group")?.value??",",decimal:r.find(o=>o.type==="decimal")?.value??"."}}catch{return{group:",",decimal:"."}}}function K(n,r){let{group:o,decimal:t}=C(r),e=n.replace(/[\s  ']/g,"").replace(/[−–]/g,"-");if(t!=="."&&!e.includes(t)&&/^-?\d+\.\d{1,2}$/.test(e))return Number(e);if(o&&(e=e.split(o).join("")),t!=="."&&(e=e.replace(t,".")),!/^-?(\d+\.?\d*|\.\d+)$/.test(e))return;let i=Number(e);return Number.isFinite(i)?i:void 0}function Y(n,r){let o=n.trim();if(o==="")return;let t=r?.format==="money"&&r.currency?S(r).symbol:void 0,e=o;t&&(e=e.split(t).join("")),r?.currency&&(e=e.replace(new RegExp(r.currency,"gi"),"")),e=e.replace(/^[$€£¥₹]|[$€£¥₹]$/g,""),/%\s*$/.test(e)&&(e=e.replace(/%\s*$/,"")),r?.unit&&r.format!=="money"&&(e=e.replace(new RegExp(`\\s*${r.unit.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*$`),""));let s=K(e,r?.locale);if(s!==void 0)return r?.format==="percent"?s/100:s}var w=/^[0-9a-f]{32}$/,F=n=>n.replace(/-/g,"").toLowerCase();function _(n,r,o){if(!(!n||typeof n!="object"))for(let[t,e]of Object.entries(n)){if(!e||typeof e!="object")continue;if(e.system==="google-calendar"&&e.kind===r)return{connection:t,system:"google-calendar",words:"Google Calendar"};if(e.system!=="notion")continue;let s=(Array.isArray(e.sources)?e.sources:[{kind:e.kind,source:e.source}]).find(p=>p&&p.kind===r);if(!s)continue;let u=typeof s.source=="string"&&!w.test(F(s.source))?s.source:void 0,a=o.startsWith(`${r}:${t}-`)?o.slice(`${r}:${t}-`.length):void 0,d=typeof e.database=="string"?F(e.database):void 0,l=a&&w.test(a)?a:d&&w.test(d)?d:void 0;return{connection:t,system:"notion",words:u?`Notion \xB7 ${u}`:"Notion",...l?{href:`https://www.notion.so/${l}`}:{}}}}export{B as a,H as b,v as c,Y as d,L as e,P as f,_ as g};
@@ -1 +1 @@
1
- import{a as A}from"./chunk.QDVGHI7R.js";import{a as x,c as T,d as w}from"./chunk.AKJS2NUM.js";import{L as S,P as v,S as $}from"./chunk.ZEZUKRC6.js";function M(e,t,n){let r=e.schema.tryDefinition(t)?.fields?.shape?.[n];return r===void 0?void 0:A(r)}function I(e,t){if(e===void 0)return[];if(!Array.isArray(e))return[`The view's accepts is a list of { "kind": <a kind>, "field": <its image, video or file field> }.`];let n=[],i=new Set(t.schema.kinds);for(let r of e){let{kind:c,field:o}=r??{};typeof c!="string"||typeof o!="string"?n.push(`Each of the view's accepts is { "kind": <a kind>, "field": <its image, video or file field> }.`):i.has(c)?M(t,c,o)?t.allMutations().some(a=>(a.creates??[]).includes(c)&&Object.hasOwn(a.input?.shape??{},o))||n.push(`No act of this app makes a "${c}" with its "${o}", so a file dropped could become nothing.`):n.push(`The view accepts files into ${c}'s "${o}", which holds no picture, video or file.`):n.push(`The view accepts files for "${c}", which is no kind of this app.`)}return n}function E(e,t,n){if(e===void 0||e===!0)return[];let i=`The view's pictures is true; the kinds whose pictures it draws, ["circuit"]; or { "width": <the widest it draws a picture, in pixels> } with the fields it draws them from, by kind, { "circuit": "photo" }.`;if(typeof e!="object"||e===null)return[i];let r=new Set([...n.attach==="home"?[]:[n.attach],...n.reads?.kinds??[]]),c=new Set(t.schema.kinds),o=[],a=d=>{if(!c.has(d))return void o.push(`The view's pictures chooses "${d}", which is no kind of this app.`);r.has(d)||o.push(`The view's pictures chooses "${d}", whose records it is not handed: add "${d}" to its reads.kinds.`)};if(Array.isArray(e)){if(e.length===0||!e.every(d=>typeof d=="string"))return[i];for(let d of e)a(d);return o}for(let[d,l]of Object.entries(e)){if(d==="width"&&typeof l!="string"&&!Array.isArray(l)){Number.isInteger(l)&&l>=16&&l<=4096||o.push("The view's pictures width is a whole number of pixels from 16 to 4096.");continue}let f=typeof l=="string"?[l]:Array.isArray(l)&&l.length>0&&l.every(u=>typeof u=="string")?l:void 0;if(!f){o.push(`The view's pictures says "${d}": beside "width", it names a kind and the field it draws pictures from, "circuit": "photo", or its fields, "circuit": ["photo", "map"].`);continue}let y=o.length;if(a(d),!(o.length>y))for(let u of f){let p=M(t,d,u);p?p.as==="video"&&o.push(`The view's pictures chooses ${d}'s "${u}", which holds videos: the host plays a video where the view places it, and hands no picture of it.`):o.push(`The view's pictures chooses ${d}'s "${u}", which holds no picture.`)}}return o}function F(e){if(e===void 0)return[];if(typeof e!="object"||e===null||Array.isArray(e))return[`The view's scene is { "maxHeight": <the tallest its preview on the Scene is drawn, in pixels> }.`];let{maxHeight:t,...n}=e,i=[];return Object.keys(n).length>0&&i.push(`The view's scene says ${Object.keys(n).map(r=>`"${r}"`).join(", ")}: only "maxHeight" is read.`),t!==void 0&&!(Number.isInteger(t)&&t>=80&&t<=4e3)&&i.push("The view's scene maxHeight is a whole number of pixels from 80 to 4000."),i}function j(e){return(e.acts??[]).map(t=>typeof t=="string"?{act:t}:t)}function C(e,t){let n=[],i=new Set(t.schema.kinds),r=new Set(t.schema.edgeKinds),c=new Set(t.allMutations().map(a=>a.name));(typeof e.name!="string"||!/^[a-z0-9][a-z0-9-]{0,62}$/.test(e.name))&&n.push(`The view's name "${String(e.name)}" is not lower-case letters, digits and hyphens.`),e.title!==void 0&&(typeof e.title!="string"||e.title.trim()===""||e.title.length>80)&&n.push("The view's title is empty or longer than 80 characters."),e.attach!=="home"&&!i.has(e.attach)&&n.push(`The view attaches to "${e.attach}", which is no kind of this app.`),e.cardinality!=="one"&&e.cardinality!=="many"&&n.push(`The view's cardinality is "${String(e.cardinality)}", not one or many.`),e.attach==="home"&&e.cardinality!=="many"&&n.push("A view of the home draws many records: its cardinality is many."),e.replaces!==void 0&&e.replaces!=="page"?n.push(`The view's replaces is "${String(e.replaces)}": the one thing a view replaces is "page", or leave it out to draw the view above the record's own fields.`):e.replaces==="page"&&e.attach==="home"&&n.push(`The home's view is the home already: replaces "page" is for a view of a kind, of one record (its page) or of many (its list).`),e.gestures!==void 0&&typeof e.gestures!="boolean"&&n.push(`The view's gestures is "${String(e.gestures)}": it is true, or left out.`),e.bleed!==void 0&&typeof e.bleed!="boolean"&&n.push(`The view's bleed is "${String(e.bleed)}": it is true, or left out.`),e.heading!==void 0&&(e.heading!=="own"||e.attach==="home"||e.cardinality!=="many"||e.title===void 0)&&n.push(`The view's heading is "${String(e.heading)}": it is "own" on a view that is a place (a title, cardinality many), or left out.`),e.flows!==void 0&&typeof e.flows!="boolean"?n.push(`The view's flows is "${String(e.flows)}": it is false for a view that keeps its place's frame, or left out.`):e.flows===!1&&(e.attach==="home"||e.cardinality!=="many"||e.title===void 0)&&n.push("Only a view that is a place keeps a frame: flows false needs a title and cardinality many on a kind."),n.push(...F(e.scene)),e.scene!==void 0&&(e.attach==="home"||e.cardinality!=="many")&&n.push("Only a view of a kind's members is drawn on the Scene as a card: scene needs cardinality many on a kind."),n.push(...E(e.pictures,t,e)),n.push(...I(e.accepts,t));for(let a of e.reads?.kinds??[])i.has(a)||n.push(`The view reads "${a}", which is no kind of this app.`);for(let a of e.reads?.edges??[])r.has(a)||n.push(`The view reads the edge "${a}", which no kind of this app declares.`);let o=new Set;for(let a of j(e)){c.has(a.act)||n.push(`The view asks for the act "${a.act}", which this app does not declare.`);let d=a.as??a.act;o.has(d)&&n.push(`Two of the view's acts are called "${d}".`),o.add(d)}return n}function H(e,t,n){let i=[...new Set([...t.attach==="home"?[]:[t.attach],...t.reads?.kinds??[]])];if(i.length<2)return[];let r=new Set(t.reads?.edges??[]),c=o=>new RegExp(`(["'\`])${o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\1`).test(n);return e.schema.edgeKinds.filter(o=>{let a=e.schema.edge(o);return!r.has(o)&&a!==void 0&&a.from.some(d=>i.includes(d))&&(a.to==="*"||a.to.some(d=>i.includes(d)))&&c(o)})}function z(e,t,n){let i=H(e,t,n);if(i.length===0)return;let r=(c,o)=>c.length<2?c[0]??"":`${c.slice(0,-1).join(", ")} ${o} ${c[c.length-1]}`;return`"${t.name}" names ${r(i,"and")} but does not read ${i.length>1?"them":"it"}, so the view is handed no such links: add ${r(i.map(c=>`"${c}"`),"and")} to its manifest's reads.edges.`}function D(e,t){return[...t.attach==="home"?[]:[t.attach],...t.reads?.kinds??[]].some(i=>Object.keys(e.schema.tryDefinition(i)?.computed??{}).length>0)}function Z(e,t,n){let{manifest:i}=n,r=n.input??{},o=e.seenBy(t).graph,a=i.attach==="home"?void 0:i.attach,d=a&&i.cardinality==="one"&&r.node?o.getNode(r.node.id):void 0,l=d&&d.kind===a?[d]:[],f=a&&i.cardinality==="many"?r.nodes?r.nodes.flatMap(s=>{let h=o.getNode(s.id);return h&&h.kind===a?[h]:[]}):o.nodesOfKind(a):[],y=new Set([...l,...f].map(s=>s.id)),u=x(o,y,{kinds:(i.reads?.kinds??[]).filter(s=>s!==a||i.cardinality==="one"),edges:i.reads?.edges??[]}),p=new Map;for(let s of[...f,...u.nodes])l.some(h=>h.id===s.id)||p.set(s.id,s);let P=new Set([...l.map(s=>s.id),...p.keys()]),G=[...u.edges],O=new Set(j(i).map(s=>s.act)),V=e.permittedMutations(t).filter(s=>O.has(s.name)).map(s=>({name:s.name,title:s.title??s.name,...s.description!==void 0?{description:s.description}:{},...s.subject?{subject:{kinds:s.subject.kinds,arg:s.subject.arg}}:{}})),m=s=>s?.filter(h=>P.has(h)),k=n.computed,b=s=>k?{...w(e,s),...k(o,s)}:w(e,s);return{view:i.name,...l[0]?{node:b(l[0])}:{},nodes:[...p.values()].map(b),edges:G,...i.title!==void 0?{label:i.title}:r.label!==void 0?{label:r.label}:{},cardinality:i.cardinality,...r.fidelity!==void 0?{fidelity:r.fidelity}:{},...r.mode!==void 0?{mode:r.mode}:{},...r.selected!==void 0?{selected:r.selected}:{},...r.implicated?{implicated:m(r.implicated)}:{},...r.flagged?{flagged:m(r.flagged)}:{},acts:V,...n.theme?{theme:n.theme}:{},locale:v(),timeZone:$(),today:e.today()??S(),...T(e.schema,[...l,...p.values()]),...n.places?{places:n.places.filter((s,h,g)=>g.findIndex(W=>W.as===s.as)===h).map(({as:s,title:h,kind:g})=>({as:s,title:h,kind:g}))}:{}}}export{M as a,j as b,C as c,H as d,z as e,D as f,Z as g};
1
+ import{a as A}from"./chunk.QDVGHI7R.js";import{a as x,c as T,d as w}from"./chunk.KUCBNMIY.js";import{L as S,P as v,S as $}from"./chunk.6AANHELP.js";function M(e,t,n){let r=e.schema.tryDefinition(t)?.fields?.shape?.[n];return r===void 0?void 0:A(r)}function I(e,t){if(e===void 0)return[];if(!Array.isArray(e))return[`The view's accepts is a list of { "kind": <a kind>, "field": <its image, video or file field> }.`];let n=[],i=new Set(t.schema.kinds);for(let r of e){let{kind:c,field:o}=r??{};typeof c!="string"||typeof o!="string"?n.push(`Each of the view's accepts is { "kind": <a kind>, "field": <its image, video or file field> }.`):i.has(c)?M(t,c,o)?t.allMutations().some(a=>(a.creates??[]).includes(c)&&Object.hasOwn(a.input?.shape??{},o))||n.push(`No act of this app makes a "${c}" with its "${o}", so a file dropped could become nothing.`):n.push(`The view accepts files into ${c}'s "${o}", which holds no picture, video or file.`):n.push(`The view accepts files for "${c}", which is no kind of this app.`)}return n}function E(e,t,n){if(e===void 0||e===!0)return[];let i=`The view's pictures is true; the kinds whose pictures it draws, ["circuit"]; or { "width": <the widest it draws a picture, in pixels> } with the fields it draws them from, by kind, { "circuit": "photo" }.`;if(typeof e!="object"||e===null)return[i];let r=new Set([...n.attach==="home"?[]:[n.attach],...n.reads?.kinds??[]]),c=new Set(t.schema.kinds),o=[],a=d=>{if(!c.has(d))return void o.push(`The view's pictures chooses "${d}", which is no kind of this app.`);r.has(d)||o.push(`The view's pictures chooses "${d}", whose records it is not handed: add "${d}" to its reads.kinds.`)};if(Array.isArray(e)){if(e.length===0||!e.every(d=>typeof d=="string"))return[i];for(let d of e)a(d);return o}for(let[d,l]of Object.entries(e)){if(d==="width"&&typeof l!="string"&&!Array.isArray(l)){Number.isInteger(l)&&l>=16&&l<=4096||o.push("The view's pictures width is a whole number of pixels from 16 to 4096.");continue}let f=typeof l=="string"?[l]:Array.isArray(l)&&l.length>0&&l.every(u=>typeof u=="string")?l:void 0;if(!f){o.push(`The view's pictures says "${d}": beside "width", it names a kind and the field it draws pictures from, "circuit": "photo", or its fields, "circuit": ["photo", "map"].`);continue}let y=o.length;if(a(d),!(o.length>y))for(let u of f){let p=M(t,d,u);p?p.as==="video"&&o.push(`The view's pictures chooses ${d}'s "${u}", which holds videos: the host plays a video where the view places it, and hands no picture of it.`):o.push(`The view's pictures chooses ${d}'s "${u}", which holds no picture.`)}}return o}function F(e){if(e===void 0)return[];if(typeof e!="object"||e===null||Array.isArray(e))return[`The view's scene is { "maxHeight": <the tallest its preview on the Scene is drawn, in pixels> }.`];let{maxHeight:t,...n}=e,i=[];return Object.keys(n).length>0&&i.push(`The view's scene says ${Object.keys(n).map(r=>`"${r}"`).join(", ")}: only "maxHeight" is read.`),t!==void 0&&!(Number.isInteger(t)&&t>=80&&t<=4e3)&&i.push("The view's scene maxHeight is a whole number of pixels from 80 to 4000."),i}function j(e){return(e.acts??[]).map(t=>typeof t=="string"?{act:t}:t)}function C(e,t){let n=[],i=new Set(t.schema.kinds),r=new Set(t.schema.edgeKinds),c=new Set(t.allMutations().map(a=>a.name));(typeof e.name!="string"||!/^[a-z0-9][a-z0-9-]{0,62}$/.test(e.name))&&n.push(`The view's name "${String(e.name)}" is not lower-case letters, digits and hyphens.`),e.title!==void 0&&(typeof e.title!="string"||e.title.trim()===""||e.title.length>80)&&n.push("The view's title is empty or longer than 80 characters."),e.attach!=="home"&&!i.has(e.attach)&&n.push(`The view attaches to "${e.attach}", which is no kind of this app.`),e.cardinality!=="one"&&e.cardinality!=="many"&&n.push(`The view's cardinality is "${String(e.cardinality)}", not one or many.`),e.attach==="home"&&e.cardinality!=="many"&&n.push("A view of the home draws many records: its cardinality is many."),e.replaces!==void 0&&e.replaces!=="page"?n.push(`The view's replaces is "${String(e.replaces)}": the one thing a view replaces is "page", or leave it out to draw the view above the record's own fields.`):e.replaces==="page"&&e.attach==="home"&&n.push(`The home's view is the home already: replaces "page" is for a view of a kind, of one record (its page) or of many (its list).`),e.gestures!==void 0&&typeof e.gestures!="boolean"&&n.push(`The view's gestures is "${String(e.gestures)}": it is true, or left out.`),e.bleed!==void 0&&typeof e.bleed!="boolean"&&n.push(`The view's bleed is "${String(e.bleed)}": it is true, or left out.`),e.heading!==void 0&&(e.heading!=="own"||e.attach==="home"||e.cardinality!=="many"||e.title===void 0)&&n.push(`The view's heading is "${String(e.heading)}": it is "own" on a view that is a place (a title, cardinality many), or left out.`),e.flows!==void 0&&typeof e.flows!="boolean"?n.push(`The view's flows is "${String(e.flows)}": it is false for a view that keeps its place's frame, or left out.`):e.flows===!1&&(e.attach==="home"||e.cardinality!=="many"||e.title===void 0)&&n.push("Only a view that is a place keeps a frame: flows false needs a title and cardinality many on a kind."),n.push(...F(e.scene)),e.scene!==void 0&&(e.attach==="home"||e.cardinality!=="many")&&n.push("Only a view of a kind's members is drawn on the Scene as a card: scene needs cardinality many on a kind."),n.push(...E(e.pictures,t,e)),n.push(...I(e.accepts,t));for(let a of e.reads?.kinds??[])i.has(a)||n.push(`The view reads "${a}", which is no kind of this app.`);for(let a of e.reads?.edges??[])r.has(a)||n.push(`The view reads the edge "${a}", which no kind of this app declares.`);let o=new Set;for(let a of j(e)){c.has(a.act)||n.push(`The view asks for the act "${a.act}", which this app does not declare.`);let d=a.as??a.act;o.has(d)&&n.push(`Two of the view's acts are called "${d}".`),o.add(d)}return n}function H(e,t,n){let i=[...new Set([...t.attach==="home"?[]:[t.attach],...t.reads?.kinds??[]])];if(i.length<2)return[];let r=new Set(t.reads?.edges??[]),c=o=>new RegExp(`(["'\`])${o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\1`).test(n);return e.schema.edgeKinds.filter(o=>{let a=e.schema.edge(o);return!r.has(o)&&a!==void 0&&a.from.some(d=>i.includes(d))&&(a.to==="*"||a.to.some(d=>i.includes(d)))&&c(o)})}function z(e,t,n){let i=H(e,t,n);if(i.length===0)return;let r=(c,o)=>c.length<2?c[0]??"":`${c.slice(0,-1).join(", ")} ${o} ${c[c.length-1]}`;return`"${t.name}" names ${r(i,"and")} but does not read ${i.length>1?"them":"it"}, so the view is handed no such links: add ${r(i.map(c=>`"${c}"`),"and")} to its manifest's reads.edges.`}function D(e,t){return[...t.attach==="home"?[]:[t.attach],...t.reads?.kinds??[]].some(i=>Object.keys(e.schema.tryDefinition(i)?.computed??{}).length>0)}function Z(e,t,n){let{manifest:i}=n,r=n.input??{},o=e.seenBy(t).graph,a=i.attach==="home"?void 0:i.attach,d=a&&i.cardinality==="one"&&r.node?o.getNode(r.node.id):void 0,l=d&&d.kind===a?[d]:[],f=a&&i.cardinality==="many"?r.nodes?r.nodes.flatMap(s=>{let h=o.getNode(s.id);return h&&h.kind===a?[h]:[]}):o.nodesOfKind(a):[],y=new Set([...l,...f].map(s=>s.id)),u=x(o,y,{kinds:(i.reads?.kinds??[]).filter(s=>s!==a||i.cardinality==="one"),edges:i.reads?.edges??[]}),p=new Map;for(let s of[...f,...u.nodes])l.some(h=>h.id===s.id)||p.set(s.id,s);let P=new Set([...l.map(s=>s.id),...p.keys()]),G=[...u.edges],O=new Set(j(i).map(s=>s.act)),V=e.permittedMutations(t).filter(s=>O.has(s.name)).map(s=>({name:s.name,title:s.title??s.name,...s.description!==void 0?{description:s.description}:{},...s.subject?{subject:{kinds:s.subject.kinds,arg:s.subject.arg}}:{}})),m=s=>s?.filter(h=>P.has(h)),k=n.computed,b=s=>k?{...w(e,s),...k(o,s)}:w(e,s);return{view:i.name,...l[0]?{node:b(l[0])}:{},nodes:[...p.values()].map(b),edges:G,...i.title!==void 0?{label:i.title}:r.label!==void 0?{label:r.label}:{},cardinality:i.cardinality,...r.fidelity!==void 0?{fidelity:r.fidelity}:{},...r.mode!==void 0?{mode:r.mode}:{},...r.selected!==void 0?{selected:r.selected}:{},...r.implicated?{implicated:m(r.implicated)}:{},...r.flagged?{flagged:m(r.flagged)}:{},acts:V,...n.theme?{theme:n.theme}:{},locale:v(),timeZone:$(),today:e.today()??S(),...T(e.schema,[...l,...p.values()]),...n.places?{places:n.places.filter((s,h,g)=>g.findIndex(W=>W.as===s.as)===h).map(({as:s,title:h,kind:g})=>({as:s,title:h,kind:g}))}:{}}}export{M as a,j as b,C as c,H as d,z as e,D as f,Z as g};
@@ -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{e as K,f as H}from"./chunk.SO6NT5K7.js";import{f as $,h as F,i as P,j as B}from"./chunk.MUSMNKE4.js";import"./chunk.SJQPTDAT.js";import"./chunk.JQ63N4MZ.js";import"./chunk.Z3O2VZAJ.js";import"./chunk.QNP5OR3P.js";import"./chunk.4W57E7AX.js";import{G as se,La as A,W as S}from"./chunk.A5PSEU3W.js";import{a as q}from"./chunk.SDO3U72B.js";import"./chunk.ZEZUKRC6.js";import"./chunk.FQLNBIQ5.js";import{b as T}from"./chunk.AJZBJBMO.js";var r=T(se(),1);var j=T(S(),1),Z=A(q(()=>(__graviewPreload(import.meta.url,["./chunk.QNP5OR3P.js","./chunk.4W57E7AX.js","./chunk.A5PSEU3W.js","./chunk.SDO3U72B.js","./chunk.ZEZUKRC6.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.G5GVT6JY.js")))),U={Part:Z.part((n,t)=>(0,j.jsx)(n.WhenMonth,{...t}),{quiet:!0}),prefetch:()=>Z.prefetch()};var o=T(S(),1),E="try \u201Ctomorrow 3pm\u201D, \u201CFri 10:30\u201D or \u201C17 Oct\u201D";function _(n,t,i,b=!1){let y=Date.UTC(+n.day.slice(0,4),+n.day.slice(5,7)-1,+n.day.slice(8,10),0,t?n.minutes??0:0),x={weekday:b?"long":"short",year:"numeric",month:b?"long":"short",day:"numeric",...t?{hour:"numeric",minute:"2-digit"}:{},timeZone:"UTC"},h;try{h=new Intl.DateTimeFormat(i??"en-US",x)}catch{h=new Intl.DateTimeFormat("en-US",x)}return h.format(y).replace(/ /g," ")}function V(n,t){if(n.length===4)return n;let i=Date.UTC(+n.slice(0,4),+n.slice(5,7)-1,1);try{return new Intl.DateTimeFormat(t??"en-US",{month:"long",year:"numeric",timeZone:"UTC"}).format(i)}catch{return new Intl.DateTimeFormat("en-US",{month:"long",year:"numeric",timeZone:"UTC"}).format(i)}}function me({value:n,time:t,instant:i=!1,partial:b=!1,label:y,name:x,required:h,autoFocus:G,autoSelect:N,locale:s,onChange:J,onLeave:Q,onCancel:X,inputRef:W,boxStyle:Y}){let k=(0,r.useId)(),p=(0,r.useRef)(null),O=(0,r.useRef)(null),I=e=>b&&!t&&e!==void 0?K(e):void 0,C=e=>{let a=I(e);if(a!==void 0)return V(a,s);let l=F(e);return l?_(l,t,s):e??""},[g,D]=(0,r.useState)(()=>C(n)),[R,w]=(0,r.useState)(!1),[ee,L]=(0,r.useState)(n),[ne,te]=(0,r.useState)(n);n!==ne&&(te(n),n!==ee&&(L(n),D(C(n)))),(0,r.useEffect)(()=>{N&&(p.current?.focus(),p.current?.select())},[N]);let d=t&&i?B(s):void 0,M=g===C(n),u=F(n),c=I(M?n:g),f=c!==void 0?void 0:M?u:H(g,{today:$().day,time:t,...u?{base:u}:{},...s?{locale:s}:{}}),re=M?n:c!==void 0?c:f?P(f,{time:t,instant:i}):void 0,v=g.trim()==="",m=!v&&f===void 0&&c===void 0;(0,r.useEffect)(()=>{p.current?.setCustomValidity(m?`Not a date this reads \u2014 ${E}`:"")},[m]);let z=e=>{L(e),J(e)},oe=e=>{D(e);let a=I(e);if(a!==void 0)return z(a);let l=e.trim()===""?void 0:H(e,{today:$().day,time:t,...u?{base:u}:{},...s?{locale:s}:{}});z(l?P(l,{time:t,instant:i}):void 0)},ae=e=>{let a=t?{day:e,minutes:f?.minutes??u?.minutes??540}:{day:e},l=P(a,{time:t,instant:i});D(C(l)),z(l),w(!1),requestAnimationFrame(()=>{p.current?.focus(),p.current?.select()})},ie=v?`Type a date, or pick one \u2014 ${E}`:m?`Not a date this reads \u2014 ${E}`:c!==void 0?`${V(c,s)} (${c.length===4?"a year":"a month"} alone)`:f?`${_(f,t,s,!0)}${d?` ${d.short}`:""}`:"";return(0,o.jsxs)("span",{"data-graview-when":t?i?"instant":"moment":"day",style:{display:"inline-flex",flex:"1 1 14rem",flexWrap:"wrap",alignItems:"center",gap:"4px 6px",maxWidth:"100%",minWidth:0},onBlur:e=>{let a=e.relatedTarget;a&&e.currentTarget.contains(a)||!a&&typeof document<"u"&&!document.hasFocus()||(w(!1),Q?.(re))},children:[(0,o.jsx)("input",{ref:e=>{p.current=e,typeof W=="function"?W(e):W&&(W.current=e)},type:"text",name:x,required:h,autoFocus:G,"aria-label":y,"aria-describedby":`${k}-said`,"aria-invalid":m||void 0,autoComplete:"off",spellCheck:!1,enterKeyHint:"done",placeholder:t?"tomorrow 3pm":"17 Oct",value:g,"data-graview-part":"control",onChange:e=>oe(e.target.value),onKeyDown:e=>{e.key==="Escape"?(e.preventDefault(),X?.()):e.key==="ArrowDown"&&e.altKey&&(e.preventDefault(),w(!0))},style:{flex:"1 1 12ch",minWidth:"10ch",maxWidth:"100%",boxSizing:"border-box",font:"inherit",...Y}}),(0,o.jsx)("button",{ref:O,type:"button","aria-label":`Pick a date for ${y}`,"aria-expanded":R,"aria-controls":`${k}-month`,"data-graview-part":"when-pick",onClick:()=>w(e=>!e),onPointerEnter:()=>U.prefetch(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:32,minHeight:32,padding:0,borderRadius:6},children:(0,o.jsxs)("svg",{"aria-hidden":"true",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",children:[(0,o.jsx)("rect",{x:"2",y:"3",width:"12",height:"11",rx:"1.5"}),(0,o.jsx)("path",{d:"M2 6.5h12M5.5 1.5v3M10.5 1.5v3"})]})}),(0,o.jsxs)("span",{id:`${k}-said`,"aria-live":"polite","data-graview-part":"when-said",...d?{"data-graview-zone":d.zone,title:`Times are in ${d.zone.replace(/_/g," ")} (${d.short})`}:{},style:{flexBasis:"100%",fontSize:"0.75rem",color:m?"var(--graview-bad)":"var(--graview-ink-faint)"},children:[ie,d&&!m&&!v?(0,o.jsx)("span",{"data-graview-part":"when-zone",children:` \xB7 ${(d.zone.split("/").at(-1)??d.zone).replace(/_/g," ")} time`}):null]}),R?(0,o.jsx)(r.Suspense,{fallback:null,children:(0,o.jsx)(U.Part,{id:`${k}-month`,label:y,selected:f?.day??u?.day,today:$().day,locale:s,onPick:ae,onClose:()=>{w(!1),O.current?.focus()}})}):null]})}export{me as WhenInput,_ as wallAsRead};
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{e as K,f as H}from"./chunk.TFJA4QV4.js";import{f as $,h as F,i as P,j as B}from"./chunk.HWFJQ42Y.js";import"./chunk.QUETLFBJ.js";import"./chunk.JULD4XFB.js";import"./chunk.GRTBEA7O.js";import"./chunk.H3IGXHZR.js";import"./chunk.7TDML5YU.js";import{G as se,La as A,W as S}from"./chunk.3VEZ5MOC.js";import{a as q}from"./chunk.SDO3U72B.js";import"./chunk.6AANHELP.js";import"./chunk.FQLNBIQ5.js";import{b as T}from"./chunk.AJZBJBMO.js";var r=T(se(),1);var j=T(S(),1),Z=A(q(()=>(__graviewPreload(import.meta.url,["./chunk.H3IGXHZR.js","./chunk.7TDML5YU.js","./chunk.3VEZ5MOC.js","./chunk.SDO3U72B.js","./chunk.6AANHELP.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.FZELUSK5.js")))),U={Part:Z.part((n,t)=>(0,j.jsx)(n.WhenMonth,{...t}),{quiet:!0}),prefetch:()=>Z.prefetch()};var o=T(S(),1),E="try \u201Ctomorrow 3pm\u201D, \u201CFri 10:30\u201D or \u201C17 Oct\u201D";function _(n,t,i,b=!1){let y=Date.UTC(+n.day.slice(0,4),+n.day.slice(5,7)-1,+n.day.slice(8,10),0,t?n.minutes??0:0),x={weekday:b?"long":"short",year:"numeric",month:b?"long":"short",day:"numeric",...t?{hour:"numeric",minute:"2-digit"}:{},timeZone:"UTC"},h;try{h=new Intl.DateTimeFormat(i??"en-US",x)}catch{h=new Intl.DateTimeFormat("en-US",x)}return h.format(y).replace(/ /g," ")}function V(n,t){if(n.length===4)return n;let i=Date.UTC(+n.slice(0,4),+n.slice(5,7)-1,1);try{return new Intl.DateTimeFormat(t??"en-US",{month:"long",year:"numeric",timeZone:"UTC"}).format(i)}catch{return new Intl.DateTimeFormat("en-US",{month:"long",year:"numeric",timeZone:"UTC"}).format(i)}}function me({value:n,time:t,instant:i=!1,partial:b=!1,label:y,name:x,required:h,autoFocus:G,autoSelect:N,locale:s,onChange:J,onLeave:Q,onCancel:X,inputRef:W,boxStyle:Y}){let k=(0,r.useId)(),p=(0,r.useRef)(null),O=(0,r.useRef)(null),I=e=>b&&!t&&e!==void 0?K(e):void 0,C=e=>{let a=I(e);if(a!==void 0)return V(a,s);let l=F(e);return l?_(l,t,s):e??""},[g,D]=(0,r.useState)(()=>C(n)),[R,w]=(0,r.useState)(!1),[ee,L]=(0,r.useState)(n),[ne,te]=(0,r.useState)(n);n!==ne&&(te(n),n!==ee&&(L(n),D(C(n)))),(0,r.useEffect)(()=>{N&&(p.current?.focus(),p.current?.select())},[N]);let d=t&&i?B(s):void 0,M=g===C(n),u=F(n),c=I(M?n:g),f=c!==void 0?void 0:M?u:H(g,{today:$().day,time:t,...u?{base:u}:{},...s?{locale:s}:{}}),re=M?n:c!==void 0?c:f?P(f,{time:t,instant:i}):void 0,v=g.trim()==="",m=!v&&f===void 0&&c===void 0;(0,r.useEffect)(()=>{p.current?.setCustomValidity(m?`Not a date this reads \u2014 ${E}`:"")},[m]);let z=e=>{L(e),J(e)},oe=e=>{D(e);let a=I(e);if(a!==void 0)return z(a);let l=e.trim()===""?void 0:H(e,{today:$().day,time:t,...u?{base:u}:{},...s?{locale:s}:{}});z(l?P(l,{time:t,instant:i}):void 0)},ae=e=>{let a=t?{day:e,minutes:f?.minutes??u?.minutes??540}:{day:e},l=P(a,{time:t,instant:i});D(C(l)),z(l),w(!1),requestAnimationFrame(()=>{p.current?.focus(),p.current?.select()})},ie=v?`Type a date, or pick one \u2014 ${E}`:m?`Not a date this reads \u2014 ${E}`:c!==void 0?`${V(c,s)} (${c.length===4?"a year":"a month"} alone)`:f?`${_(f,t,s,!0)}${d?` ${d.short}`:""}`:"";return(0,o.jsxs)("span",{"data-graview-when":t?i?"instant":"moment":"day",style:{display:"inline-flex",flex:"1 1 14rem",flexWrap:"wrap",alignItems:"center",gap:"4px 6px",maxWidth:"100%",minWidth:0},onBlur:e=>{let a=e.relatedTarget;a&&e.currentTarget.contains(a)||!a&&typeof document<"u"&&!document.hasFocus()||(w(!1),Q?.(re))},children:[(0,o.jsx)("input",{ref:e=>{p.current=e,typeof W=="function"?W(e):W&&(W.current=e)},type:"text",name:x,required:h,autoFocus:G,"aria-label":y,"aria-describedby":`${k}-said`,"aria-invalid":m||void 0,autoComplete:"off",spellCheck:!1,enterKeyHint:"done",placeholder:t?"tomorrow 3pm":"17 Oct",value:g,"data-graview-part":"control",onChange:e=>oe(e.target.value),onKeyDown:e=>{e.key==="Escape"?(e.preventDefault(),X?.()):e.key==="ArrowDown"&&e.altKey&&(e.preventDefault(),w(!0))},style:{flex:"1 1 12ch",minWidth:"10ch",maxWidth:"100%",boxSizing:"border-box",font:"inherit",...Y}}),(0,o.jsx)("button",{ref:O,type:"button","aria-label":`Pick a date for ${y}`,"aria-expanded":R,"aria-controls":`${k}-month`,"data-graview-part":"when-pick",onClick:()=>w(e=>!e),onPointerEnter:()=>U.prefetch(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:32,minHeight:32,padding:0,borderRadius:6},children:(0,o.jsxs)("svg",{"aria-hidden":"true",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",children:[(0,o.jsx)("rect",{x:"2",y:"3",width:"12",height:"11",rx:"1.5"}),(0,o.jsx)("path",{d:"M2 6.5h12M5.5 1.5v3M10.5 1.5v3"})]})}),(0,o.jsxs)("span",{id:`${k}-said`,"aria-live":"polite","data-graview-part":"when-said",...d?{"data-graview-zone":d.zone,title:`Times are in ${d.zone.replace(/_/g," ")} (${d.short})`}:{},style:{flexBasis:"100%",fontSize:"0.75rem",color:m?"var(--graview-bad)":"var(--graview-ink-faint)"},children:[ie,d&&!m&&!v?(0,o.jsx)("span",{"data-graview-part":"when-zone",children:` \xB7 ${(d.zone.split("/").at(-1)??d.zone).replace(/_/g," ")} time`}):null]}),R?(0,o.jsx)(r.Suspense,{fallback:null,children:(0,o.jsx)(U.Part,{id:`${k}-month`,label:y,selected:f?.day??u?.day,today:$().day,locale:s,onPick:ae,onClose:()=>{w(!1),O.current?.focus()}})}):null]})}export{me as WhenInput,_ as wallAsRead};
@@ -1 +1 @@
1
- import{a as r,b as m,d as k,e as y}from"./chunk.Q355UPFG.js";import"./chunk.QNP5OR3P.js";import"./chunk.4W57E7AX.js";import"./chunk.A5PSEU3W.js";import"./chunk.SDO3U72B.js";import"./chunk.ZEZUKRC6.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";var i="way-back",b='[data-testid="notices-toasts"]';function g(t){let o=document.activeElement;o!==null&&o!==document.body&&!o.closest(b)||(t??document).querySelector('[data-graview-app-bar] [data-testid="app-home"]')?.focus({preventScroll:!0})}function E(t,o,a,d,h){if(t.past)return a?.dismiss(i),()=>{};let c=h?.closest("[data-graview-embed]"),s,f=e=>{if(e!==void 0&&r(t,o)?.batch!==e)return!1;try{let n=k(t,o);return n&&a?.notify({kind:"toast",id:i,sentence:`Took back \u201C${n.intent}\u201D`}),n!==void 0}catch(n){return a?.notify({kind:"toast",id:i,tone:"warn",sentence:n instanceof Error?n.message:String(n)}),!0}},u=()=>{let e=m(t,o,d);if(d=t.batches().length,e){let n=s=e.batch;a?.notify({kind:"toast",id:i,sentence:e.intent,timeout:1e4,action:{label:"Take back",keys:"Meta+Z Control+Z",onSelect:()=>(g(c),f(n))}})}else s&&r(t,o)?.batch!==s&&(s=void 0,a?.dismiss(i))},l=e=>{y(e)&&(!c||c.contains(e.target))&&f()&&e.preventDefault()};u();let p=t.subscribe(u);return document.addEventListener("keydown",l),(e=!1)=>{p(),document.removeEventListener("keydown",l),e&&s&&a?.dismiss(i)}}export{E as sceneWay};
1
+ import{a as r,b as m,d as k,e as y}from"./chunk.Q355UPFG.js";import"./chunk.H3IGXHZR.js";import"./chunk.7TDML5YU.js";import"./chunk.3VEZ5MOC.js";import"./chunk.SDO3U72B.js";import"./chunk.6AANHELP.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";var i="way-back",b='[data-testid="notices-toasts"]';function g(t){let o=document.activeElement;o!==null&&o!==document.body&&!o.closest(b)||(t??document).querySelector('[data-graview-app-bar] [data-testid="app-home"]')?.focus({preventScroll:!0})}function E(t,o,a,d,h){if(t.past)return a?.dismiss(i),()=>{};let c=h?.closest("[data-graview-embed]"),s,f=e=>{if(e!==void 0&&r(t,o)?.batch!==e)return!1;try{let n=k(t,o);return n&&a?.notify({kind:"toast",id:i,sentence:`Took back \u201C${n.intent}\u201D`}),n!==void 0}catch(n){return a?.notify({kind:"toast",id:i,tone:"warn",sentence:n instanceof Error?n.message:String(n)}),!0}},u=()=>{let e=m(t,o,d);if(d=t.batches().length,e){let n=s=e.batch;a?.notify({kind:"toast",id:i,sentence:e.intent,timeout:1e4,action:{label:"Take back",keys:"Meta+Z Control+Z",onSelect:()=>(g(c),f(n))}})}else s&&r(t,o)?.batch!==s&&(s=void 0,a?.dismiss(i))},l=e=>{y(e)&&(!c||c.contains(e.target))&&f()&&e.preventDefault()};u();let p=t.subscribe(u);return document.addEventListener("keydown",l),(e=!1)=>{p(),document.removeEventListener("keydown",l),e&&s&&a?.dismiss(i)}}export{E as sceneWay};
@@ -1 +1 @@
1
- var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as i}from"./chunk.SDO3U72B.js";var m=i(()=>(__graviewPreload(import.meta.url,["./chunk.JO2X52D4.js","./chunk.ZRBGYXAO.js","./chunk.CEQQIW7Z.js","./chunk.NRURQGXV.js","./chunk.BBLIT7S7.js","./chunk.H6KIEDZN.js","./chunk.264PB572.js","./chunk.GG47EIKO.js","./chunk.NYLKG25K.js","./chunk.G3GFDVO2.js","./chunk.D4WJ7OM5.js","./chunk.QDVGHI7R.js","./chunk.AKJS2NUM.js","./chunk.M5FP4Y4Q.js","./chunk.LP2ZMAT2.js","./chunk.SDO3U72B.js","./chunk.ZEZUKRC6.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.E5PYNAYT.js")));function f(r,s){let e=!1,n=()=>{window.removeEventListener("online",n),e||o()},o=()=>void r().then(d=>{e||s(d)},()=>{e||window.addEventListener("online",n)});return o(),()=>{e=!0,window.removeEventListener("online",n)}}var t;function l(r){t=r}function u(){return t}export{m as a,f as b,l as c,u as d};
1
+ var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as i}from"./chunk.SDO3U72B.js";var m=i(()=>(__graviewPreload(import.meta.url,["./chunk.JO2X52D4.js","./chunk.ZRBGYXAO.js","./chunk.CEQQIW7Z.js","./chunk.VES4XMZX.js","./chunk.BBLIT7S7.js","./chunk.CGBOPPNL.js","./chunk.LMTG5NPG.js","./chunk.GG47EIKO.js","./chunk.NYLKG25K.js","./chunk.MK5RPEB2.js","./chunk.TOUSIUJF.js","./chunk.QDVGHI7R.js","./chunk.KUCBNMIY.js","./chunk.M5FP4Y4Q.js","./chunk.CNN32262.js","./chunk.SDO3U72B.js","./chunk.6AANHELP.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.PIMAG4WT.js")));function f(r,s){let e=!1,n=()=>{window.removeEventListener("online",n),e||o()},o=()=>void r().then(d=>{e||s(d)},()=>{e||window.addEventListener("online",n)});return o(),()=>{e=!0,window.removeEventListener("online",n)}}var t;function l(r){t=r}function u(){return t}export{m as a,f as b,l as c,u as d};
@@ -0,0 +1 @@
1
+ import{a,b}from"./chunk.O2VXTYUJ.js";import"./chunk.64LCHHZB.js";import"./chunk.CNN32262.js";import"./chunk.N5Z34V7U.js";import"./chunk.LOKGUALC.js";import"./chunk.EP5JS7ZH.js";import"./chunk.L7XKYGV7.js";import"./chunk.CE3NKAF7.js";import"./chunk.R3GE37OI.js";import"./chunk.2KCDLCB2.js";import"./chunk.UD7VLXPM.js";import"./chunk.3DEWQDP7.js";import"./chunk.TFJA4QV4.js";import"./chunk.HWFJQ42Y.js";import"./chunk.QUETLFBJ.js";import"./chunk.JULD4XFB.js";import"./chunk.GRTBEA7O.js";import"./chunk.6AANHELP.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";export{b as actOnSeveral,a as actsForSeveral};
@@ -1,3 +1,3 @@
1
- var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as j,e as B}from"./chunk.6UQFV53C.js";import{t as I}from"./chunk.QNP5OR3P.js";import{G as J,La as M,Ua as R,W as b,Ya as $,ea as A,ga as H}from"./chunk.A5PSEU3W.js";import{a as L}from"./chunk.SDO3U72B.js";import{b as c}from"./chunk.AJZBJBMO.js";var t=c(J(),1);var S=c(b(),1),E=M(L(()=>(__graviewPreload(import.meta.url,["./chunk.25VJPUDH.js","./chunk.HJUZMOW2.js","./chunk.NAXOXBOF.js","./chunk.6W6XMLSF.js","./chunk.PZ7KY6XH.js","./chunk.WEMUKZKH.js","./chunk.T27QKVKP.js","./chunk.SO6NT5K7.js","./chunk.MUSMNKE4.js","./chunk.SJQPTDAT.js","./chunk.JQ63N4MZ.js","./chunk.Z3O2VZAJ.js","./chunk.QNP5OR3P.js","./chunk.4W57E7AX.js","./chunk.A5PSEU3W.js","./chunk.SDO3U72B.js","./chunk.ZEZUKRC6.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.CY7FFKEZ.js")))),W=E.part((a,n)=>(0,S.jsx)(a.SuggestedCount,{...n}),{quiet:!0}),ro=E.part((a,n)=>(0,S.jsx)(a.SuggestedList,{...n}),{quiet:!0,as:"div"});var o=c(b(),1),K=I.part((a,n)=>(0,o.jsx)(a.InboxPane,{...n}),{what:"The inbox"}),Q=[],U=[],oo=a=>a>99?"99+":String(a);function to(a,n){let d=[a>0?`${a} waiting for you`:"",n>0?`${n===1?"1 change":`${n} changes`}`:""].filter(Boolean);return d.length>0?`Inbox \u2014 ${d.join(", ")}`:"Inbox"}function po({calls:a=Q,seat:n,remembers:d=!1}){let{store:C,principal:f,whileAway:V,notifications:m=U,onNotificationsSeen:y,ai:Y}=A(),_=H(),r=B({calls:a,seat:n,remembers:d}),N=j(),q=Y.off!==!0,p=(0,t.useMemo)(()=>f.id===void 0?[]:N.filter(e=>e.by.id===f.id||e.by.onBehalfOf?.id===f.id),[N,f.id]),F=(0,t.useMemo)(()=>C.log.all().some(e=>e.suggests!==void 0&&!e.withheld),[C,_]),h=(V?.tidied??0)>0,v=F||h,[G,z]=(0,t.useState)(0),g=m.filter(e=>!e.read),u=G+g.length,x=u+r.recent,i=$("inbox"),s=i.open,[l,P]=(0,t.useState)("activity"),w=(0,t.useRef)(!1);if(s&&!w.current){w.current=!0;let e=u>0||h?"for-you":r.has?"activity":p.length>0?"asks":"for-you";e!==l&&P(e)}s||(w.current=!1);let T=(0,t.useRef)("");(0,t.useEffect)(()=>{if(!s||l!=="for-you"||g.length===0||!y)return;let e=g.map(Z=>Z.id);T.current!==e.join(`
1
+ var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as j,e as B}from"./chunk.IKKKHHRN.js";import{t as I}from"./chunk.H3IGXHZR.js";import{G as J,La as M,Ua as R,W as b,Ya as $,ea as A,ga as H}from"./chunk.3VEZ5MOC.js";import{a as L}from"./chunk.SDO3U72B.js";import{b as c}from"./chunk.AJZBJBMO.js";var t=c(J(),1);var S=c(b(),1),E=M(L(()=>(__graviewPreload(import.meta.url,["./chunk.25VJPUDH.js","./chunk.DCLF4WWZ.js","./chunk.XDZDNZ7B.js","./chunk.E423JCOS.js","./chunk.O5FTWXA2.js","./chunk.Q4VFLLUT.js","./chunk.6ZENHSTQ.js","./chunk.TFJA4QV4.js","./chunk.HWFJQ42Y.js","./chunk.QUETLFBJ.js","./chunk.JULD4XFB.js","./chunk.GRTBEA7O.js","./chunk.H3IGXHZR.js","./chunk.7TDML5YU.js","./chunk.3VEZ5MOC.js","./chunk.SDO3U72B.js","./chunk.6AANHELP.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.4GVKKBQL.js")))),W=E.part((a,n)=>(0,S.jsx)(a.SuggestedCount,{...n}),{quiet:!0}),ro=E.part((a,n)=>(0,S.jsx)(a.SuggestedList,{...n}),{quiet:!0,as:"div"});var o=c(b(),1),K=I.part((a,n)=>(0,o.jsx)(a.InboxPane,{...n}),{what:"The inbox"}),Q=[],U=[],oo=a=>a>99?"99+":String(a);function to(a,n){let d=[a>0?`${a} waiting for you`:"",n>0?`${n===1?"1 change":`${n} changes`}`:""].filter(Boolean);return d.length>0?`Inbox \u2014 ${d.join(", ")}`:"Inbox"}function po({calls:a=Q,seat:n,remembers:d=!1}){let{store:C,principal:f,whileAway:V,notifications:m=U,onNotificationsSeen:y,ai:Y}=A(),_=H(),r=B({calls:a,seat:n,remembers:d}),N=j(),q=Y.off!==!0,p=(0,t.useMemo)(()=>f.id===void 0?[]:N.filter(e=>e.by.id===f.id||e.by.onBehalfOf?.id===f.id),[N,f.id]),F=(0,t.useMemo)(()=>C.log.all().some(e=>e.suggests!==void 0&&!e.withheld),[C,_]),h=(V?.tidied??0)>0,v=F||h,[G,z]=(0,t.useState)(0),g=m.filter(e=>!e.read),u=G+g.length,x=u+r.recent,i=$("inbox"),s=i.open,[l,P]=(0,t.useState)("activity"),w=(0,t.useRef)(!1);if(s&&!w.current){w.current=!0;let e=u>0||h?"for-you":r.has?"activity":p.length>0?"asks":"for-you";e!==l&&P(e)}s||(w.current=!1);let T=(0,t.useRef)("");(0,t.useEffect)(()=>{if(!s||l!=="for-you"||g.length===0||!y)return;let e=g.map(Z=>Z.id);T.current!==e.join(`
2
2
  `)&&(T.current=e.join(`
3
3
  `),y(e))},[s,l,g,y]);let D=(0,t.useCallback)(()=>i.setOpen(!1),[i]),X=(0,t.useCallback)(e=>z(e),[]);if(!(r.has||v||m.length>0||p.length>0))return null;let k=to(u,r.recent),O=()=>I.prefetch();return(0,o.jsxs)("div",{className:"graview-bar-inbox",style:{position:"relative"},children:[v?(0,o.jsx)(t.Suspense,{fallback:null,children:(0,o.jsx)(W,{onCount:X})}):null,(0,o.jsxs)("button",{type:"button",className:"graview-bar-tool","data-testid":"inbox-button","data-count":x,...i.trigger,onClick:i.toggle,onPointerEnter:O,onFocus:O,"aria-label":r.running?`${k} \u2014 an agent is working`:k,title:r.running?"Inbox \u2014 an agent is working":k,...r.running?{"data-running":""}:{},children:[(0,o.jsx)(eo,{}),x>0?(0,o.jsx)("span",{className:"graview-bar-badge","data-testid":"inbox-count","aria-hidden":"true",children:oo(x)}):r.running?(0,o.jsx)("span",{className:"graview-bar-badge","data-dot":"","aria-hidden":"true"}):null]}),(!s||l!=="activity")&&n!==void 0?(0,o.jsx)("div",{hidden:!0,"data-testid":"agent-seat-seated",children:n}):null,s?(0,o.jsx)("section",{...i.pane,"aria-label":"Inbox","data-testid":"inbox","data-graview-offstage":"","data-tab":l,tabIndex:-1,style:{...R,width:"min(360px, calc(100vw - 16px))",maxHeight:"min(70vh, 520px)",overflowX:"hidden",overflowY:"auto",display:"flex",flexDirection:"column",padding:0,borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)",outline:"none"},children:(0,o.jsx)(t.Suspense,{fallback:null,children:(0,o.jsx)(K,{tab:l,choose:P,asksOn:q,counts:{"for-you":u,activity:r.recent,asks:p.length},notifications:m,asks:p,tray:v,waits:u>0||h,activityHas:r.has,calls:a,remembers:d,close:D,...n!==void 0?{seat:n}:{}})})}):null]})}function eo(){return(0,o.jsxs)("svg",{width:16,height:16,viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",style:{flex:"0 0 auto"},children:[(0,o.jsx)("path",{d:"M4 11.25 V7.25 a4 4 0 0 1 8 0 V11.25 L13.25 12.5 H2.75 Z",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round"}),(0,o.jsx)("path",{d:"M6.5 14 h3",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})]})}export{ro as a,po as b};
@@ -1,2 +1,2 @@
1
- import{g as F,l as b}from"./chunk.RG5G6YQD.js";function L(t,o){return o===1&&["every","some","sum","min","max","sort"].includes(t.fn)}function M(t){let o=new Set,e=new Set,r=[],s=[],a=new Set(F),i=(l,f)=>{switch(l.t){case"lit":return;case"ident":f||o.add(l.name);return;case"list":l.items.forEach(c=>i(c,f));return;case"member":i(l.object,f);return;case"unary":i(l.operand,f);return;case"binary":i(l.left,f),i(l.right,f);return;case"where":i(l.set,f),i(l.filter,!0);return;case"call":{e.add(l.fn);let c=(l.fn==="out"||l.fn==="in")&&l.args.length===2?l.args[1]:l.args[0],g=c?.t==="lit"&&typeof c.value=="string"?c.value:void 0;l.fn==="all"&&g&&r.push(g),(l.fn==="out"||l.fn==="in")&&g&&s.push(g),l.args.forEach((v,k)=>i(v,f||L(l,k)));return}}};return i(t,!1),{names:o,functions:e,unknownFunctions:[...e].filter(l=>!a.has(l)),sweeps:r,edges:s}}var p=class extends Error{constructor(e,r,s){super(`${e} (at character ${r+1} of "${s}")`);this.sentence=e;this.at=r;this.source=s}},D=["||","&&","==","!=","<=",">=","<",">","!","|","&","+","-","*","/","%","(",")","[","]",",","."],j={and:"&&",or:"||",not:"!"},T=2e3;function H(t){let o=[],e=0;for(;e<t.length;){let r=t[e];if(r===" "||r===" "||r===`
1
+ import{g as F,l as b}from"./chunk.3DEWQDP7.js";function L(t,o){return o===1&&["every","some","sum","min","max","sort"].includes(t.fn)}function M(t){let o=new Set,e=new Set,r=[],s=[],a=new Set(F),i=(l,f)=>{switch(l.t){case"lit":return;case"ident":f||o.add(l.name);return;case"list":l.items.forEach(c=>i(c,f));return;case"member":i(l.object,f);return;case"unary":i(l.operand,f);return;case"binary":i(l.left,f),i(l.right,f);return;case"where":i(l.set,f),i(l.filter,!0);return;case"call":{e.add(l.fn);let c=(l.fn==="out"||l.fn==="in")&&l.args.length===2?l.args[1]:l.args[0],g=c?.t==="lit"&&typeof c.value=="string"?c.value:void 0;l.fn==="all"&&g&&r.push(g),(l.fn==="out"||l.fn==="in")&&g&&s.push(g),l.args.forEach((v,k)=>i(v,f||L(l,k)));return}}};return i(t,!1),{names:o,functions:e,unknownFunctions:[...e].filter(l=>!a.has(l)),sweeps:r,edges:s}}var p=class extends Error{constructor(e,r,s){super(`${e} (at character ${r+1} of "${s}")`);this.sentence=e;this.at=r;this.source=s}},D=["||","&&","==","!=","<=",">=","<",">","!","|","&","+","-","*","/","%","(",")","[","]",",","."],j={and:"&&",or:"||",not:"!"},T=2e3;function H(t){let o=[],e=0;for(;e<t.length;){let r=t[e];if(r===" "||r===" "||r===`
2
2
  `||r==="\r"){e++;continue}if(r>="0"&&r<="9"){let a=e;for(;e<t.length&&/[0-9.]/.test(t[e]);)e++;let i=t.slice(a,e),l=Number(i);if(!Number.isFinite(l)||i.split(".").length>2)throw new p(`"${i}" is not a number`,a,t);o.push({k:"num",v:l,at:a});continue}if(r==="'"||r==='"'){let a=e++,i="";for(;e<t.length&&t[e]!==r;)t[e]==="\\"&&e+1<t.length&&e++,i+=t[e++];if(e>=t.length)throw new p("a quoted word is never closed",a,t);e++,o.push({k:"str",v:i,at:a});continue}if(/[A-Za-z_]/.test(r)){let a=e;for(;e<t.length&&/[A-Za-z0-9_]/.test(t[e]);)e++;let i=t.slice(a,e),l=Object.hasOwn(j,i)?j[i]:void 0;o.push(l?{k:"op",v:l,at:a}:{k:"id",v:i,at:a});continue}let s=D.find(a=>t.startsWith(a,e));if(!s)throw new p(`"${r}" is not part of the rule language`,e,t);o.push({k:"op",v:s,at:e}),e+=s.length}return o.push({k:"end",at:t.length}),o}function w(t){if(t.length>T)throw new p(`an expression may be at most ${T} characters`,0,t.slice(0,40));let o=H(t),e=0,r=()=>o[e],s=n=>{let d=r();return d.k==="op"&&d.v===n},a=n=>{let d=r();return d.k==="id"&&d.v===n},i=(n,d)=>{if(!s(n))throw new p(`expected ${d}`,r().at,t);e++},l=0,f=(n,d)=>{if(++l>64)throw new p("the expression nests too deeply",n,t);try{return d()}finally{l--}},c=(n,d)=>()=>{let m=d();for(;;){let y=r(),S=y.k==="op"?n.find(q=>q===y.v):y.k==="id"&&y.v==="in"&&n.includes("in")?"in":void 0;if(!S)return m;e++,m={t:"binary",op:S,left:m,right:d(),at:y.at}}},g=()=>{let n=r();if(n.k==="num")return e++,{t:"lit",value:n.v,at:n.at};if(n.k==="str")return e++,{t:"lit",value:n.v,at:n.at};if(n.k==="id"){if(e++,n.v==="true"||n.v==="false")return{t:"lit",value:n.v==="true",at:n.at};if(n.v==="null")return{t:"lit",value:null,at:n.at};if(s("(")){e++;let d=[];if(!s(")"))for(;;){if(d.push(h()),s(",")){e++;continue}break}return i(")",`")" to close ${n.v}(\u2026)`),{t:"call",fn:n.v,args:d,at:n.at}}return{t:"ident",name:n.v,at:n.at}}if(n.k==="op"&&n.v==="("){e++;let d=f(n.at,h);return i(")",'a ")"'),d}if(n.k==="op"&&n.v==="["){e++;let d=[];if(!s("]"))for(;;){if(d.push(h()),s(",")){e++;continue}break}return i("]",'a "]" to close the list'),{t:"list",items:d,at:n.at}}throw n.k==="end"?new p("the expression ends too soon",n.at,t):new p(`"${n.k==="op"?n.v:""}" cannot start a value here`,n.at,t)},v=()=>{let n=g();for(;;){if(s(".")){let d=r();e++;let m=r();if(m.k!=="id")throw new p('expected a field name after "."',m.at,t);e++,n={t:"member",object:n,name:m.v,at:d.at};continue}if(a("where")){let d=r().at;e++,n={t:"where",set:n,filter:f(d,h),at:d};continue}return n}},k=()=>{let n=r();return n.k==="op"&&(n.v==="!"||n.v==="-")?(e++,{t:"unary",op:n.v,operand:f(n.at,k),at:n.at}):v()},P=c(["*","/","%"],k),z=c(["+","-"],P),N=c(["&"],z),R=c(["|"],N),_=()=>{let n=R(),d=r(),m=d.k==="op"&&["==","!=","<","<=",">",">="].includes(d.v)?d.v:d.k==="id"&&d.v==="in"?"in":void 0;return m?(e++,{t:"binary",op:m,left:n,right:R(),at:d.at}):n},O=()=>{let n=r();return n.k==="op"&&n.v==="!"?(e++,{t:"unary",op:"!",operand:f(n.at,O),at:n.at}):_()},B=c(["&&"],O),I=c(["||"],B);function h(){return I()}let K=h();if(r().k!=="end")throw new p("there is more after the end of the expression",r().at,t);return K}function E(t){let o,e=-1,r=0;for(let s=0;s<t.length;s++){let a=t[s];if(o){a==="\\"?s++:a===o&&(o=void 0);continue}a==="'"||a==='"'?o=a:a==="("||a==="["?r++:a===")"||a==="]"?r--:a==="|"&&r===0&&(t[s+1]==="|"?s++:e=s)}if(e>0&&t.slice(e+1).trim()===x){let s=E(t.slice(0,e));if(s>=0)return s}return e}var x="capital",$=/\s*(?:'((?:[^'\\]|\\.)*)'|"((?:[^"\\]|\\.)*)")\s*(,|$)/y;function U(t){let o=E(t);if(o>=0){if(t.slice(o+1).trim()!==x)throw new u('only "capital" may follow another formatter, like {n | words | capital}');let e=t.slice(0,o);if(e.trim()===x)throw new u('"capital" is said once');return{...C(e),capital:!0}}return t.trim()===x?{args:[],capital:!0}:C(t)}function C(t){let o=t.indexOf(":"),e=(o>=0?t.slice(0,o):t).trim();if(!b.includes(e))throw new u(`"${e}" is not a formatter; use one of ${[...b,x].join(", ")}`);let r=[];if(o>=0&&e==="excerpt"){let s=t.slice(o+1).trim();if(!/^\d+$/.test(s)||Number(s)<20||Number(s)>1e3)throw new u("excerpt is told at most how many characters, 20 to 1000: {summary | excerpt: 80}");r.push(s)}else if(o>=0&&e==="money"){if(t.slice(o+1).trim()!=="0")throw new u("money is told 0 for whole units, rounded \u2014 {total | money: 0} \u2014 or nothing, for cents only where a sum has them");r.push("0")}else if(o>=0){let s=t.slice(o+1),a=0;for(;a<s.length;){$.lastIndex=a;let i=$.exec(s);if(!i)throw new u(`"${e}" is told quoted words, like ${e}: 'offer'`);if(r.push((i[1]??i[2]??"").replace(/\\(.)/g,"$1")),a=$.lastIndex,i[3]==="")break}}if(e==="plural"&&(r.length<1||r.length>2))throw new u("plural is told its noun, like {count | plural: 'offer'}, and its plural where English does not make it: plural: 'person', 'people'");if(e!=="plural"&&e!=="excerpt"&&e!=="money"&&r.length>0)throw new u(`"${e}" takes nothing after it`);return{format:e,args:r}}var u=class extends Error{constructor(e){super(e);this.sentence=e}};function Y(t){let o=[],e=0;for(;e<t.length;){let r=t.indexOf("{",e);if(r<0){o.push({text:t.slice(e)});break}r>e&&o.push({text:t.slice(e,r)});let s=t.indexOf("}",r);if(s<0)throw new u(`a "{" at character ${r+1} is never closed`);let a=t.slice(r+1,s),i=E(a),l=(i>=0?a.slice(0,i):a).trim(),f=i>=0?U(a.slice(i+1)):void 0,c=E(l);if(c>=0&&b.includes(l.slice(c+1).split(":")[0].trim()))throw new u('only "capital" may follow another formatter, like {n | words | capital}');o.push({expr:w(l),source:l,...f?.format?{format:f.format}:{},...f&&f.args.length>0?{formatArgs:f.args}:{},...f?.capital?{capital:!0}:{}}),e=s+1}return o}function A(t){let o=new Map;for(let[e,r]of Object.entries(t?.computed??{}))o.set(e,typeof r=="string"?{expr:r}:r);return o}function re(t){let o=A(t);if(o.size===0)return;let e=new Map;for(let[r,s]of o)try{e.set(r,w(s.expr))}catch(a){if(!(a instanceof p))throw a}return e}function Z(t,o,e=new Set){let r=A(t).get(o);if(!r||e.has(o))return!1;let s;try{s=w(r.expr)}catch{return!1}let a=M(s);if(a.edges.length>0||a.sweeps.length>0||[...a.functions].some(c=>c==="out"||c==="in"||c==="all"))return!1;let i=t.fields,l=c=>i instanceof Set?i.has(c):Object.hasOwn(i,c),f=new Set([...e,o]);return[...a.names].every(c=>l(c)||Z(t,c,f))}export{M as a,p as b,w as c,u as d,Y as e,A as f,re as g,Z as h};
@@ -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{F as g,G as T,La as C,W as v,fa as S}from"./chunk.A5PSEU3W.js";import{a as m}from"./chunk.SDO3U72B.js";import"./chunk.ZEZUKRC6.js";import"./chunk.FQLNBIQ5.js";import{b as c}from"./chunk.AJZBJBMO.js";var n=c(T(),1),r=c(v(),1),s=null,u=null,f=new Set,a=()=>{for(let e of f)e()},y=e=>(f.add(e),()=>void f.delete(e)),E=300,d=()=>{u!==null&&clearTimeout(u),u=null};function q(e,t){d(),x.prefetch(),!(s?.element===t&&s.target.on===e.on)&&(s={target:e,element:t},a())}function M(e=!1){if(d(),s!==null){if(e){s=null,a();return}u=setTimeout(()=>{u=null,s=null,a()},E)}}var R=()=>d(),P=()=>s,b="graview:hover-chips",h;function A(e){if(h!==void 0)return h;try{return(e??localStorage).getItem(b)!=="off"}catch{return!0}}function I(e,t){h=e;try{(t??localStorage).setItem(b,e?"on":"off")}catch{}e||(s=null),a()}function w(){let e=S(),t=g(e?.ai),o=e?.memory,l=(0,n.useSyncExternalStore)(y,()=>A(o),()=>!1),i=(0,n.useCallback)(H=>I(H,o),[o]);return{offered:t,on:t&&l,set:i}}function z({legend:e,style:t,choice:o}){let l=w();return l.offered?(0,r.jsxs)("fieldset",{"data-testid":"setting-hover-chips",style:{border:0,margin:0,padding:0,display:"grid",gap:5,...t},children:[(0,r.jsx)("legend",{style:{...e,padding:0},children:"AI suggestions on hover"}),(0,r.jsx)("span",{style:{fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:"A quiet suggestion beside a record the pointer rests on, when the AI is sure of one."}),(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[!0,!1].map(i=>(0,r.jsx)("button",{type:"button","aria-pressed":l.on===i,"data-testid":`setting-hover-chips-${i?"on":"off"}`,onClick:()=>l.set(i),style:o(l.on===i),children:i?"On":"Off"},String(i)))})]}):null}var x=C(m(()=>(__graviewPreload(import.meta.url,["./chunk.SFBHPYRD.js","./chunk.ILJDLBPJ.js","./chunk.X226YATK.js","./chunk.BJUUSIQY.js","./chunk.MSAYU25L.js","./chunk.QF5QB5YR.js","./chunk.EGPCVMDU.js","./chunk.M7KXQGQL.js","./chunk.XOZU4OFA.js","./chunk.H3EGBDW2.js","./chunk.6KJGRM7A.js","./chunk.SO6NT5K7.js","./chunk.MUSMNKE4.js","./chunk.SJQPTDAT.js","./chunk.JQ63N4MZ.js","./chunk.Z3O2VZAJ.js","./chunk.QNP5OR3P.js","./chunk.4W57E7AX.js","./chunk.A5PSEU3W.js","./chunk.SDO3U72B.js","./chunk.ZEZUKRC6.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.JVB5KDSG.js")))),k=x.part((e,t)=>{let o=e.HoverChip;return(0,r.jsx)(o,{...t})},{quiet:!0}),p=null,O=()=>p;function L(){let{on:e}=w(),t=(0,n.useSyncExternalStore)(y,P,()=>null),[o]=(0,n.useState)(()=>Symbol("hover-chip")),l=(0,n.useSyncExternalStore)(y,O,()=>null);return(0,n.useEffect)(()=>{if(e)return p===null&&(p=o,a()),()=>{p===o&&(p=null,s=null,d(),a())}},[e,o,l]),!e||t===null||l!==o||!t.element.isConnected?null:(0,r.jsx)(n.Suspense,{fallback:null,children:(0,r.jsx)(k,{rest:t,hold:R,leave:M})})}export{L as HoverChipDoor,z as HoverChipsSwitch,R as holdRest,A as hoverChipsWanted,M as leaveRest,q as restOn,I as setHoverChipsWanted,w as useHoverChipsSetting};
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{F as g,G as T,La as C,W as v,fa as S}from"./chunk.3VEZ5MOC.js";import{a as m}from"./chunk.SDO3U72B.js";import"./chunk.6AANHELP.js";import"./chunk.FQLNBIQ5.js";import{b as c}from"./chunk.AJZBJBMO.js";var n=c(T(),1),r=c(v(),1),s=null,u=null,f=new Set,a=()=>{for(let e of f)e()},y=e=>(f.add(e),()=>void f.delete(e)),E=300,d=()=>{u!==null&&clearTimeout(u),u=null};function q(e,t){d(),x.prefetch(),!(s?.element===t&&s.target.on===e.on)&&(s={target:e,element:t},a())}function M(e=!1){if(d(),s!==null){if(e){s=null,a();return}u=setTimeout(()=>{u=null,s=null,a()},E)}}var R=()=>d(),P=()=>s,b="graview:hover-chips",h;function A(e){if(h!==void 0)return h;try{return(e??localStorage).getItem(b)!=="off"}catch{return!0}}function I(e,t){h=e;try{(t??localStorage).setItem(b,e?"on":"off")}catch{}e||(s=null),a()}function w(){let e=S(),t=g(e?.ai),o=e?.memory,l=(0,n.useSyncExternalStore)(y,()=>A(o),()=>!1),i=(0,n.useCallback)(H=>I(H,o),[o]);return{offered:t,on:t&&l,set:i}}function z({legend:e,style:t,choice:o}){let l=w();return l.offered?(0,r.jsxs)("fieldset",{"data-testid":"setting-hover-chips",style:{border:0,margin:0,padding:0,display:"grid",gap:5,...t},children:[(0,r.jsx)("legend",{style:{...e,padding:0},children:"AI suggestions on hover"}),(0,r.jsx)("span",{style:{fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:"A quiet suggestion beside a record the pointer rests on, when the AI is sure of one."}),(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[!0,!1].map(i=>(0,r.jsx)("button",{type:"button","aria-pressed":l.on===i,"data-testid":`setting-hover-chips-${i?"on":"off"}`,onClick:()=>l.set(i),style:o(l.on===i),children:i?"On":"Off"},String(i)))})]}):null}var x=C(m(()=>(__graviewPreload(import.meta.url,["./chunk.AQ2PI6MR.js","./chunk.H3W5C3XQ.js","./chunk.6WB2TYK7.js","./chunk.BJUUSIQY.js","./chunk.N5Z34V7U.js","./chunk.YL2RBZFE.js","./chunk.LOKGUALC.js","./chunk.JGRSUTPJ.js","./chunk.XOZU4OFA.js","./chunk.EP5JS7ZH.js","./chunk.CE3NKAF7.js","./chunk.TFJA4QV4.js","./chunk.HWFJQ42Y.js","./chunk.QUETLFBJ.js","./chunk.JULD4XFB.js","./chunk.GRTBEA7O.js","./chunk.H3IGXHZR.js","./chunk.7TDML5YU.js","./chunk.3VEZ5MOC.js","./chunk.SDO3U72B.js","./chunk.6AANHELP.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.JCETQQ7J.js")))),k=x.part((e,t)=>{let o=e.HoverChip;return(0,r.jsx)(o,{...t})},{quiet:!0}),p=null,O=()=>p;function L(){let{on:e}=w(),t=(0,n.useSyncExternalStore)(y,P,()=>null),[o]=(0,n.useState)(()=>Symbol("hover-chip")),l=(0,n.useSyncExternalStore)(y,O,()=>null);return(0,n.useEffect)(()=>{if(e)return p===null&&(p=o,a()),()=>{p===o&&(p=null,s=null,d(),a())}},[e,o,l]),!e||t===null||l!==o||!t.element.isConnected?null:(0,r.jsx)(n.Suspense,{fallback:null,children:(0,r.jsx)(k,{rest:t,hold:R,leave:M})})}export{L as HoverChipDoor,z as HoverChipsSwitch,R as holdRest,A as hoverChipsWanted,M as leaveRest,q as restOn,I as setHoverChipsWanted,w as useHoverChipsSetting};
@@ -1 +1 @@
1
- import"./chunk.SO6NT5K7.js";import"./chunk.MUSMNKE4.js";import"./chunk.SJQPTDAT.js";import{a as m}from"./chunk.JQ63N4MZ.js";import"./chunk.Z3O2VZAJ.js";import"./chunk.QNP5OR3P.js";import"./chunk.4W57E7AX.js";import{W as p}from"./chunk.A5PSEU3W.js";import"./chunk.SDO3U72B.js";import{Z as l}from"./chunk.ZEZUKRC6.js";import"./chunk.FQLNBIQ5.js";import{b as f}from"./chunk.AJZBJBMO.js";var a=f(p(),1);function A({states:e,definition:v}){let s=e.values.reduce((t,n)=>t+n.count,0),u=t=>t===null?"with none":m(v,e.field,t).toLowerCase(),c=e.values.filter(t=>t.count>0).map(t=>`${l(t.count)} ${u(t.value)}`).join(", ");return s===0?null:(0,a.jsx)("div",{className:"graview-district-states",role:"img","aria-label":c,title:c,children:e.values.map((t,n)=>{if(t.count===0)return null;let y=e.values.filter(r=>r.count>0).length,w=t.count/s*(168-(y-1)),o=l(t.count),i=`${o} ${u(t.value)}`,d=r=>r.length*6.2+8<=w;return(0,a.jsx)("span",{"data-graview-tier":t.tier,style:{flexGrow:t.count},title:i,children:d(i)?i:d(o)?o:""},n)})})}export{A as StatesBar};
1
+ import"./chunk.TFJA4QV4.js";import"./chunk.HWFJQ42Y.js";import"./chunk.QUETLFBJ.js";import{a as m}from"./chunk.JULD4XFB.js";import"./chunk.GRTBEA7O.js";import"./chunk.H3IGXHZR.js";import"./chunk.7TDML5YU.js";import{W as p}from"./chunk.3VEZ5MOC.js";import"./chunk.SDO3U72B.js";import{Z as l}from"./chunk.6AANHELP.js";import"./chunk.FQLNBIQ5.js";import{b as f}from"./chunk.AJZBJBMO.js";var a=f(p(),1);function A({states:e,definition:v}){let s=e.values.reduce((t,n)=>t+n.count,0),u=t=>t===null?"with none":m(v,e.field,t).toLowerCase(),c=e.values.filter(t=>t.count>0).map(t=>`${l(t.count)} ${u(t.value)}`).join(", ");return s===0?null:(0,a.jsx)("div",{className:"graview-district-states",role:"img","aria-label":c,title:c,children:e.values.map((t,n)=>{if(t.count===0)return null;let y=e.values.filter(r=>r.count>0).length,w=t.count/s*(168-(y-1)),o=l(t.count),i=`${o} ${u(t.value)}`,d=r=>r.length*6.2+8<=w;return(0,a.jsx)("span",{"data-graview-tier":t.tier,style:{flexGrow:t.count},title:i,children:d(i)?i:d(o)?o:""},n)})})}export{A as StatesBar};
@@ -1 +1 @@
1
- import{Zc as g}from"./chunk.ZEZUKRC6.js";function b(){let t=new Uint8Array(16);return globalThis.crypto.getRandomValues(t),Array.from(t,e=>e.toString(16).padStart(2,"0")).join("")}function k(t,e){if(!t)return;let i={..."filter"in e&&e.filter?{filter:e.filter}:{},...e.section?{section:e.section}:{}};"record"in e?t.record(e.record,i):"list"in e?t.list(e.list,i):t.place(e.place,i)}function w(t,e){if(!t?.href)return;let i={..."filter"in e&&e.filter?{filter:e.filter}:{},...e.section?{section:e.section}:{}};return t.href("record"in e?{record:e.record}:"list"in e?{list:e.list}:{place:e.place},i)}var v=[["accent","--graview-accent"],["ground","--graview-ground"],["panel","--graview-panel"],["ink","--graview-ink"],["inkMuted","--graview-ink-muted"],["edge","--graview-edge"],["fontBody","--graview-font-body"],["fontDisplay","--graview-font-display"],["fontMono","--graview-font-mono"],["radius","--graview-radius"]];function B(t){let e=t.ownerDocument.defaultView,i=e.getComputedStyle(t),s=t.closest("[data-graview-scheme]")?.getAttribute("data-graview-scheme"),d={scheme:s==="dark"||s==="light"?s:/\bdark\b/.test(i.colorScheme??"")?"dark":/\blight\b/.test(i.colorScheme??"")?"light":e.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"};for(let[l,u]of v)d[l]=i.getPropertyValue(u).trim();return d}function R(t,e){let i=t.defaultView;if(!i||typeof i.MutationObserver!="function")return()=>{};let s=new i.MutationObserver(e);s.observe(t.documentElement,{attributes:!0,subtree:!0,attributeFilter:["data-graview-scheme","data-theme"]});let o=i.matchMedia?.("(prefers-color-scheme: dark)");return o?.addEventListener?.("change",e),()=>{s.disconnect(),o?.removeEventListener?.("change",e)}}function T(t,e,i){let s=e?.(),o=t(),d=s?.logo,l=i.url(typeof d=="string"||d===void 0?d:o.scheme==="dark"&&d.dark?d.dark:d.light);return{...o,...s?.name?{name:s.name}:{},...l?{logo:l}:{}}}function x(t,e,i){let s,o,d=n=>{n?.startsWith("blob:")&&t.URL.revokeObjectURL(n)},l=async n=>{if(n.startsWith("<"))return g(n)===null?new t.Blob([n],{type:"image/svg+xml"}):void 0;if(/\\|%2e/i.test(n)||n.split(/[?#]/)[0].split("/").some(m=>m==="."||m===".."))return;let r=new t.URL(n,t.document.baseURI);if(r.origin!==t.location.origin||!/^https?:$/.test(r.protocol))return;let a=await t.fetch(r.href,{credentials:"same-origin"}),c=(a.headers.get("content-type")??"").split(";")[0].trim();return a.ok&&c.startsWith("image/")?new t.Blob([await a.arrayBuffer()],{type:c}):void 0},u=n=>new Promise(r=>{let a=new t.Image;a.onload=()=>r(!0),a.onerror=()=>r(!1),t.setTimeout(()=>r(!1),2e3),a.src=n}),p=n=>new Promise((r,a)=>{let c=new t.FileReader;c.onload=()=>r(String(c.result)),c.onerror=a,c.readAsDataURL(n)}),h=async n=>{if(/^data:image\//i.test(n))return n;let r=await l(n);if(!(!r||s!==n)){if(i==="blob"){let a=t.URL.createObjectURL(r);if(await u(a))return a;t.URL.revokeObjectURL(a)}return p(r)}},f=(n,r)=>{if(s!==n)return d(r);r!==o&&(d(o),o=r,e())};return{url(n){let r=n?.trim()||void 0;return r!==s&&(s=r,r?h(r).then(a=>f(r,a),()=>f(r,void 0)):(d(o),o=void 0)),o},dispose(){s=void 0,d(o),o=void 0}}}export{b as a,k as b,w as c,B as d,R as e,T as f,x as g};
1
+ import{Zc as g}from"./chunk.6AANHELP.js";function b(){let t=new Uint8Array(16);return globalThis.crypto.getRandomValues(t),Array.from(t,e=>e.toString(16).padStart(2,"0")).join("")}function k(t,e){if(!t)return;let i={..."filter"in e&&e.filter?{filter:e.filter}:{},...e.section?{section:e.section}:{}};"record"in e?t.record(e.record,i):"list"in e?t.list(e.list,i):t.place(e.place,i)}function w(t,e){if(!t?.href)return;let i={..."filter"in e&&e.filter?{filter:e.filter}:{},...e.section?{section:e.section}:{}};return t.href("record"in e?{record:e.record}:"list"in e?{list:e.list}:{place:e.place},i)}var v=[["accent","--graview-accent"],["ground","--graview-ground"],["panel","--graview-panel"],["ink","--graview-ink"],["inkMuted","--graview-ink-muted"],["edge","--graview-edge"],["fontBody","--graview-font-body"],["fontDisplay","--graview-font-display"],["fontMono","--graview-font-mono"],["radius","--graview-radius"]];function B(t){let e=t.ownerDocument.defaultView,i=e.getComputedStyle(t),s=t.closest("[data-graview-scheme]")?.getAttribute("data-graview-scheme"),d={scheme:s==="dark"||s==="light"?s:/\bdark\b/.test(i.colorScheme??"")?"dark":/\blight\b/.test(i.colorScheme??"")?"light":e.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"};for(let[l,u]of v)d[l]=i.getPropertyValue(u).trim();return d}function R(t,e){let i=t.defaultView;if(!i||typeof i.MutationObserver!="function")return()=>{};let s=new i.MutationObserver(e);s.observe(t.documentElement,{attributes:!0,subtree:!0,attributeFilter:["data-graview-scheme","data-theme"]});let o=i.matchMedia?.("(prefers-color-scheme: dark)");return o?.addEventListener?.("change",e),()=>{s.disconnect(),o?.removeEventListener?.("change",e)}}function T(t,e,i){let s=e?.(),o=t(),d=s?.logo,l=i.url(typeof d=="string"||d===void 0?d:o.scheme==="dark"&&d.dark?d.dark:d.light);return{...o,...s?.name?{name:s.name}:{},...l?{logo:l}:{}}}function x(t,e,i){let s,o,d=n=>{n?.startsWith("blob:")&&t.URL.revokeObjectURL(n)},l=async n=>{if(n.startsWith("<"))return g(n)===null?new t.Blob([n],{type:"image/svg+xml"}):void 0;if(/\\|%2e/i.test(n)||n.split(/[?#]/)[0].split("/").some(m=>m==="."||m===".."))return;let r=new t.URL(n,t.document.baseURI);if(r.origin!==t.location.origin||!/^https?:$/.test(r.protocol))return;let a=await t.fetch(r.href,{credentials:"same-origin"}),c=(a.headers.get("content-type")??"").split(";")[0].trim();return a.ok&&c.startsWith("image/")?new t.Blob([await a.arrayBuffer()],{type:c}):void 0},u=n=>new Promise(r=>{let a=new t.Image;a.onload=()=>r(!0),a.onerror=()=>r(!1),t.setTimeout(()=>r(!1),2e3),a.src=n}),p=n=>new Promise((r,a)=>{let c=new t.FileReader;c.onload=()=>r(String(c.result)),c.onerror=a,c.readAsDataURL(n)}),h=async n=>{if(/^data:image\//i.test(n))return n;let r=await l(n);if(!(!r||s!==n)){if(i==="blob"){let a=t.URL.createObjectURL(r);if(await u(a))return a;t.URL.revokeObjectURL(a)}return p(r)}},f=(n,r)=>{if(s!==n)return d(r);r!==o&&(d(o),o=r,e())};return{url(n){let r=n?.trim()||void 0;return r!==s&&(s=r,r?h(r).then(a=>f(r,a),()=>f(r,void 0)):(d(o),o=void 0)),o},dispose(){s=void 0,d(o),o=void 0}}}export{b as a,k as b,w as c,B as d,R as e,T as f,x as g};
@@ -1,4 +1,4 @@
1
- import{a as L,b as _,c as B,d as V,e as E,r as G,t as H,u as S,v as N,w as q,x as W,y as z,z as Q}from"./chunk.RD2FSSLV.js";import"./chunk.ZEZUKRC6.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";var j=["drawElementImageToTexture","copyElementImageToTexture"],T=null,M=(r,e)=>r==="texture"?{texture:e}:{destination:{texture:e}};function ne(){return typeof globalThis>"u"?void 0:globalThis}function v(r,e){let t=[],n=ne(),s=!!(n?.navigator&&"gpu"in n.navigator);s||t.push("navigator.gpu is absent \u2014 WebGPU is unavailable.");let o=r??n?.GPUQueue?.prototype??void 0,i=null;if(o){for(let d of j)if(typeof o[d]=="function"){i=d;break}}i||t.push("No element-capture method on GPUQueue. Run Chromium 147+ with --enable-blink-features=CanvasDrawElement.");let c=e??n?.HTMLCanvasElement?.prototype??void 0,l=typeof c?.updateElementGeometry=="function";l||t.push("canvas.updateElementGeometry is absent \u2014 geometry cannot be reported.");let p=typeof c?.requestPaint=="function";p||t.push("canvas.requestPaint is absent \u2014 there is no capture-safe moment to hook.");let y=!1,h="unknown";if(typeof document<"u"){let d=document.createElement("canvas");y="layoutSubtree"in d||typeof d.captureElementImage=="function","layoutSubtree"in d?h="no":typeof d.captureElementImage=="function"&&(h="yes")}return{available:i!==null,captureMethod:i,geometrySync:l,hitTestFollowsGeometry:l?h:"no",layoutSubtree:y,paintEvents:p,webgpu:s,usable:s&&i!==null,notes:t}}var w=class extends Error{constructor(t){super(`HTML-in-Canvas is unavailable:
1
+ import{a as L,b as _,c as B,d as V,e as E,r as G,t as H,u as S,v as N,w as q,x as W,y as z,z as Q}from"./chunk.RD2FSSLV.js";import"./chunk.6AANHELP.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";var j=["drawElementImageToTexture","copyElementImageToTexture"],T=null,M=(r,e)=>r==="texture"?{texture:e}:{destination:{texture:e}};function ne(){return typeof globalThis>"u"?void 0:globalThis}function v(r,e){let t=[],n=ne(),s=!!(n?.navigator&&"gpu"in n.navigator);s||t.push("navigator.gpu is absent \u2014 WebGPU is unavailable.");let o=r??n?.GPUQueue?.prototype??void 0,i=null;if(o){for(let d of j)if(typeof o[d]=="function"){i=d;break}}i||t.push("No element-capture method on GPUQueue. Run Chromium 147+ with --enable-blink-features=CanvasDrawElement.");let c=e??n?.HTMLCanvasElement?.prototype??void 0,l=typeof c?.updateElementGeometry=="function";l||t.push("canvas.updateElementGeometry is absent \u2014 geometry cannot be reported.");let p=typeof c?.requestPaint=="function";p||t.push("canvas.requestPaint is absent \u2014 there is no capture-safe moment to hook.");let y=!1,h="unknown";if(typeof document<"u"){let d=document.createElement("canvas");y="layoutSubtree"in d||typeof d.captureElementImage=="function","layoutSubtree"in d?h="no":typeof d.captureElementImage=="function"&&(h="yes")}return{available:i!==null,captureMethod:i,geometrySync:l,hitTestFollowsGeometry:l?h:"no",layoutSubtree:y,paintEvents:p,webgpu:s,usable:s&&i!==null,notes:t}}var w=class extends Error{constructor(t){super(`HTML-in-Canvas is unavailable:
2
2
  ${t.notes.join(`
3
3
  `)}`);this.capabilities=t;this.name="PlatformUnavailableError"}};function O(r,e,t){let n=r;for(let s of j){let o=n[s];if(typeof o=="function"){if(T){o.call(n,{source:e},M(T,t));return}try{o.call(n,{source:e},M("texture",t)),T="texture"}catch(i){if(!(i instanceof TypeError)||!/texture/i.test(i.message))throw i;o.call(n,{source:e},M("destination",t)),T="destination"}return}}throw new w(v(r))}function F(r,e=!0){e?r.setAttribute("drawable",""):r.removeAttribute("drawable")}function D(r){let e=r.changedElements;return e?new Set(Array.from(e)):null}function re(r,e){let t=r;if(typeof t.captureElementImage!="function")throw new w(v(void 0,r));return t.captureElementImage(e)}function U(r,e,t){let n=r;if(typeof n.updateElementGeometry!="function")throw new w(v(void 0,r));n.updateElementGeometry(e,t)}function ie(r,e){r.clearElementGeometry?.(e)}function m(r){r.requestPaint?.()}function I(r,e=!0){let t=r;e?t.setAttribute("content","drawable"):t.removeAttribute("content"),"layoutSubtree"in t?t.layoutSubtree=e:e?t.setAttribute("layoutsubtree",""):t.removeAttribute("layoutsubtree")}var R=`
4
4
  struct Plane {
@@ -1,4 +1,4 @@
1
- import{a as k}from"./chunk.G4JJXA63.js";import{b as Q}from"./chunk.LP2ZMAT2.js";import{a as Z}from"./chunk.M7KXQGQL.js";import{a as Y}from"./chunk.6KJGRM7A.js";import{c as V}from"./chunk.UGQYMN4J.js";import{ee as P,ge as H,he as T,ie as U,yb as z,zb as B}from"./chunk.ZEZUKRC6.js";var x=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(),b=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]??b(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:b(d)})),l=(o.plural??`${b(t)}s`).toLowerCase();e.push({kind:t,plural:l,noun:(o.noun??b(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`,b(t.kind),`${b(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||b(r.name)===t||r.name.toLowerCase()===t)??o.find(r=>r.words===L(t)||b(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||b(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 mn=/\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/,bn=/\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"),mn.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"),bn.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?$/,N=class extends Error{},h=n=>{throw new N(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,b(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,b(i)));r&&s.push({expr:`${o.name} == '${r.replace(/'/g,"")}'`,says:`that are ${b(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??b(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 m=o(g,void 0);if(m)return m;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 m=g[1].split(/\|(?![|])/)[0],f=s(m,`${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(`${b(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 ${b(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 m=d.drawn.find(f=>f.index===l);if(!m)return o("its bindings name something the app does not have");if(m.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:m}}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??b(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 zn(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 xn(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(!x(u))return u;i??=u.failed}catch(c){if(!(c instanceof N))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 Nn(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=xn(n,e);if(t&&!x(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 x(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 m=e.replace(/^.*?\b(?:call|name|title)\b\s*(?:it|this)?\s*/i,"").replace(/^["“']|["”']$/g,"").trim();if(m.length===0)return{failed:"Couldn't change that: say what to call it.",...t};let f={...n.lens,title:F(m,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 m=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(m,a,r,i,[a]),y=g[1]==="cards"?"card":g[1]==="rows"?"row":void 0,p=m==="blocks"&&d?.lens==="blocks"?{...d,...y?{as:y}:{}}:m==="blocks"&&d?.lens==="columns"?{...f,group:d.column,...y?{as:y}:{}}:f;return C(v(p),r,o,l)}if(d){let m=Kn(d,a,r,i);if(m)return C(m,r,o,l)}}catch(g){if(!(g instanceof N))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 x(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{b as Q}from"./chunk.CNN32262.js";import{a as Z}from"./chunk.JGRSUTPJ.js";import{a as Y}from"./chunk.CE3NKAF7.js";import{c as V}from"./chunk.UD7VLXPM.js";import{ee as P,ge as H,he as T,ie as U,yb as z,zb as B}from"./chunk.6AANHELP.js";var x=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(),b=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]??b(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:b(d)})),l=(o.plural??`${b(t)}s`).toLowerCase();e.push({kind:t,plural:l,noun:(o.noun??b(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`,b(t.kind),`${b(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||b(r.name)===t||r.name.toLowerCase()===t)??o.find(r=>r.words===L(t)||b(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||b(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 mn=/\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/,bn=/\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"),mn.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"),bn.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?$/,N=class extends Error{},h=n=>{throw new N(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,b(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,b(i)));r&&s.push({expr:`${o.name} == '${r.replace(/'/g,"")}'`,says:`that are ${b(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??b(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 m=o(g,void 0);if(m)return m;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 m=g[1].split(/\|(?![|])/)[0],f=s(m,`${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(`${b(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 ${b(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 m=d.drawn.find(f=>f.index===l);if(!m)return o("its bindings name something the app does not have");if(m.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:m}}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??b(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 zn(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 xn(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(!x(u))return u;i??=u.failed}catch(c){if(!(c instanceof N))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 Nn(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=xn(n,e);if(t&&!x(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 x(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 m=e.replace(/^.*?\b(?:call|name|title)\b\s*(?:it|this)?\s*/i,"").replace(/^["“']|["”']$/g,"").trim();if(m.length===0)return{failed:"Couldn't change that: say what to call it.",...t};let f={...n.lens,title:F(m,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 m=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(m,a,r,i,[a]),y=g[1]==="cards"?"card":g[1]==="rows"?"row":void 0,p=m==="blocks"&&d?.lens==="blocks"?{...d,...y?{as:y}:{}}:m==="blocks"&&d?.lens==="columns"?{...f,group:d.column,...y?{as:y}:{}}:f;return C(v(p),r,o,l)}if(d){let m=Kn(d,a,r,i);if(m)return C(m,r,o,l)}}catch(g){if(!(g instanceof N))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 x(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,3 +1,3 @@
1
- import{b as te}from"./chunk.YCD4JSXD.js";import"./chunk.SO6NT5K7.js";import"./chunk.MUSMNKE4.js";import"./chunk.SJQPTDAT.js";import{b as ne}from"./chunk.JQ63N4MZ.js";import"./chunk.Z3O2VZAJ.js";import{G as ge,W as ee}from"./chunk.A5PSEU3W.js";import"./chunk.SDO3U72B.js";import{la as X,na as Z,rd as q}from"./chunk.ZEZUKRC6.js";import"./chunk.FQLNBIQ5.js";import{b as T}from"./chunk.AJZBJBMO.js";var M=T(ge(),1);var ye=6;function re($,S,m,x,E){let t=new Set($),o=new Map;for(let i of S)for(let[h,l,b]of[[i.from,i.to,"out"],[i.to,i.from,"in"]]){if(!t.has(h)||t.has(l))continue;let f=m(l);if(f===void 0)continue;let p=`${h}|${i.kind}|${b}|${f}`,v=o.get(p);v?v.others.includes(l)||v.others.push(l):o.set(p,{self:h,edge:i.kind,direction:b,kind:f,others:[l]})}let d=[];for(let i of o.values()){let h=m(i.self)??"",l=ne(E,i.direction==="out"?h:i.kind,i.edge,i.direction);if(i.others.length>ye){d.push({...i,others:i.others,lands:"district",words:l});continue}let b=[],f=[];for(let p of i.others)(x(p)?b:f).push(p);for(let p of b)d.push({...i,others:[p],lands:"record",words:l});f.length>0&&d.push({...i,others:f,lands:"district",words:l})}return d}function ie($,S=[]){let m=[...S],x=new Map,E=t=>m.some(o=>t.x<o.x+o.width&&o.x<t.x+t.width&&t.y<o.y+o.height&&o.y<t.y+t.height);for(let t of[...$].sort((o,d)=>o.y-d.y||o.x-d.x)){let o={x:t.x-t.width/2,y:t.y-t.height,width:t.width,height:t.height};for(let d=0;d<12&&E(o);d++)o.y+=t.height+2;m.push(o),x.set(t.key,{x:o.x,y:o.y})}return x}var s=T(ee(),1),he=4;function xe({frame:$,width:S,height:m,stageRef:x,tick:E,store:t,graphVersion:o,selection:d,view:i,rulers:{visibleRect:h,clipQuadratic:l,unsureOf:b,unsureDash:f,unsureOpacity:p}}){let v=n=>t.graph.getNode(n)?.kind,C=te(d,i,v),R=C.lens===null&&C.records.length<=he?C.records:[],oe=R.join(`
1
+ import{b as te}from"./chunk.2BMZPALF.js";import"./chunk.TFJA4QV4.js";import"./chunk.HWFJQ42Y.js";import"./chunk.QUETLFBJ.js";import{b as ne}from"./chunk.JULD4XFB.js";import"./chunk.GRTBEA7O.js";import{G as ge,W as ee}from"./chunk.3VEZ5MOC.js";import"./chunk.SDO3U72B.js";import{la as X,na as Z,rd as q}from"./chunk.6AANHELP.js";import"./chunk.FQLNBIQ5.js";import{b as T}from"./chunk.AJZBJBMO.js";var M=T(ge(),1);var ye=6;function re($,S,m,x,E){let t=new Set($),o=new Map;for(let i of S)for(let[h,l,b]of[[i.from,i.to,"out"],[i.to,i.from,"in"]]){if(!t.has(h)||t.has(l))continue;let f=m(l);if(f===void 0)continue;let p=`${h}|${i.kind}|${b}|${f}`,v=o.get(p);v?v.others.includes(l)||v.others.push(l):o.set(p,{self:h,edge:i.kind,direction:b,kind:f,others:[l]})}let d=[];for(let i of o.values()){let h=m(i.self)??"",l=ne(E,i.direction==="out"?h:i.kind,i.edge,i.direction);if(i.others.length>ye){d.push({...i,others:i.others,lands:"district",words:l});continue}let b=[],f=[];for(let p of i.others)(x(p)?b:f).push(p);for(let p of b)d.push({...i,others:[p],lands:"record",words:l});f.length>0&&d.push({...i,others:f,lands:"district",words:l})}return d}function ie($,S=[]){let m=[...S],x=new Map,E=t=>m.some(o=>t.x<o.x+o.width&&o.x<t.x+t.width&&t.y<o.y+o.height&&o.y<t.y+t.height);for(let t of[...$].sort((o,d)=>o.y-d.y||o.x-d.x)){let o={x:t.x-t.width/2,y:t.y-t.height,width:t.width,height:t.height};for(let d=0;d<12&&E(o);d++)o.y+=t.height+2;m.push(o),x.set(t.key,{x:o.x,y:o.y})}return x}var s=T(ee(),1),he=4;function xe({frame:$,width:S,height:m,stageRef:x,tick:E,store:t,graphVersion:o,selection:d,view:i,rulers:{visibleRect:h,clipQuadratic:l,unsureOf:b,unsureDash:f,unsureOpacity:p}}){let v=n=>t.graph.getNode(n)?.kind,C=te(d,i,v),R=C.lens===null&&C.records.length<=he?C.records:[],oe=R.join(`
2
2
  `),[y,K]=(0,M.useState)(null);(0,M.useLayoutEffect)(()=>{let n=x.current;if(!i.overview||R.length===0||!n||typeof document>"u"||$.t<1){K(null);return}let w=n.getBoundingClientRect(),B=e=>({x:e.left-w.left,y:e.top-w.top,width:e.width,height:e.height}),D=new Map,se=R.map(e=>`[data-graview-view="${CSS.escape(e)}"]`).join(","),k=null,H=()=>{if(k)return k;k={drawn:new Map,buildings:new Map};for(let e of n.querySelectorAll("[data-graview-pick], [data-graview-view], [data-graview-building]")){let r=e.getAttribute("data-graview-pick"),a=e.getAttribute("data-graview-view");for(let c of r!==null&&r===a?[r]:[r,a]){if(c===null)continue;let u=k.drawn.get(c);u?u.push(e):k.drawn.set(c,[e])}let L=e.getAttribute("data-graview-building");L!==null&&!k.buildings.has(L)&&k.buildings.set(L,e)}return k},P=e=>{if(D.has(e))return D.get(e);let r=null;for(let a of H().drawn.get(e)??[])if(!a.closest("[data-graview-offstage], [data-graview-screen]")&&!(!R.includes(e)&&a.closest(se))&&(r=h(a,n),r))break;if(!r){let a=H().buildings.get(e);a&&(r=B(a.getBoundingClientRect()))}return D.set(e,r),r},W=e=>{let r=n.querySelector(`[data-graview-plot="kind:${CSS.escape(e)}"] .graview-plot-tile`);return r?B(r.getBoundingClientRect()):null},de=re(R,t.graph.allEdges(),v,e=>P(e)!==null,t.schema),z=[];for(let e of n.querySelectorAll('[data-graview-view^="kind:"] .graview-kind-face')){let r=h(e,n);r&&z.push(r)}let Q=e=>({x:e.x+e.width/2,y:e.y+e.height/2}),O=[],V=new Set(R),I=new Set;for(let e of de){let r=v(e.self),a=P(e.self)??(r?W(r):null),L=e.lands==="record"?P(e.others[0]):W(e.kind);if(!a||!L)continue;for(let g of e.others)V.add(g);I.add(e.kind),r&&I.add(r);let c=Q(a),u=Q(L),A=Math.hypot(u.x-c.x,u.y-c.y);if(A<6)continue;let G=Math.min(40,A*.12)*(O.length%2===0?1:-1),le={x:(c.x+u.x)/2-(u.y-c.y)/A*G,y:(c.y+u.y)/2+(u.x-c.x)/A*G},J=l({p0:c,c:le,p1:u},z);if(J.length===0)continue;let ce=J.map(g=>`M ${g.p0.x.toFixed(1)} ${g.p0.y.toFixed(1)} Q ${g.c.x.toFixed(1)} ${g.c.y.toFixed(1)} ${g.p1.x.toFixed(1)} ${g.p1.y.toFixed(1)}`).join(" "),ue=g=>{let j=t.graph.getNode(g);return j?X(t.schema.tryDefinition(j.kind),j):g},U=e.lands==="record"?`${e.words}: ${ue(e.others[0])}`:`${e.words}: ${Z(t.schema,e.kind,e.others.length)}`,F=e.others[0],_=e.lands==="record"?b?.(e.edge,e.direction==="out"?e.self:F,e.direction==="out"?F:e.self):void 0;O.push({key:`${e.self}|${e.edge}|${e.direction}|${e.lands}|${F}`,link:e,d:ce,end:u,said:_!==void 0?`${U} \xB7 unsure`:U,..._!==void 0?{unsure:_}:{}})}let Y=[];for(let e of n.querySelectorAll(".graview-kind-face[data-graview-nameplate]")){let r=h(e,n);r&&Y.push(r)}let ae=ie(O.map(e=>({key:e.key,x:e.end.x,y:e.end.y-6,width:Math.min(260,14+e.said.length*6.6),height:20})),Y);K({lines:O,labels:ae,reached:[...V],districts:[...I]})},[oe,i.overview,$,o,E,S,m,x,t]);let N=(0,M.useMemo)(()=>{if(!y)return"";let n=y.reached.map(B=>`[data-graview-building="${CSS.escape(B)}"]`).join(","),w=y.districts.map(B=>`[data-graview-plot="kind:${CSS.escape(B)}"]`).join(",");return[".graview-ground[data-graview-altitude] .graview-building { opacity: 0.22; }",n?`.graview-ground[data-graview-altitude] .graview-building:is(${n}) { opacity: 1; }`:"",w?`.graview-ground[data-graview-altitude] .graview-plot:not(:is(${w})) .graview-plot-tile { opacity: 0.4; }`:""].join(`
3
3
  `)},[y]);return!y||y.lines.length===0?N?(0,s.jsx)("style",{children:N}):null:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("style",{children:N}),(0,s.jsx)("svg",{className:"graview-record-links","data-graview-world":"","data-graview-record-links":y.lines.length,"aria-hidden":"true",width:S,height:m,style:{position:"absolute",left:0,top:0,pointerEvents:"none",zIndex:q.lines},children:y.lines.map(n=>(0,s.jsxs)("g",{className:"graview-record-link","data-graview-link":n.link.edge,"data-graview-lands":n.link.lands,"data-graview-direction":n.link.direction,"data-graview-provisional":n.unsure!==void 0||void 0,children:[(0,s.jsx)("path",{className:"graview-record-link-line",d:n.d,...n.unsure!==void 0?{strokeDasharray:f,strokeOpacity:p}:{}}),n.link.lands==="record"?(0,s.jsx)("circle",{className:"graview-record-link-end",cx:n.end.x,cy:n.end.y,r:3}):null]},n.key))}),(0,s.jsx)("div",{"aria-hidden":"true","data-graview-world":"",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:q.tieLabels},children:y.lines.map(n=>{let w=y.labels.get(n.key);return w?(0,s.jsx)("span",{className:"graview-record-link-said","data-graview-link-said":n.link.edge,"data-graview-lands":n.link.lands,...n.unsure!==void 0?{title:n.unsure}:{},style:{position:"absolute",left:w.x,top:w.y,...n.unsure!==void 0?{pointerEvents:"auto"}:{}},children:n.said},n.key):null})})]})}export{xe as RecordLinks};