graview 0.1.39 → 0.1.41

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 (174) hide show
  1. package/dist/preview/{chunk.WQPNGBR7.js → chunk.242EUAPE.js} +1 -1
  2. package/dist/preview/chunk.2FGYWAID.js +1 -0
  3. package/dist/preview/{chunk.NSNGPQGT.js → chunk.2FLPDPEL.js} +1 -1
  4. package/dist/preview/{chunk.RXSHFG6S.js → chunk.2GQPLTV3.js} +1 -1
  5. package/dist/preview/chunk.2NB7U4EW.js +88 -0
  6. package/dist/preview/{chunk.Z7JRBKA7.js → chunk.2RVUDRRY.js} +1 -1
  7. package/dist/preview/{chunk.I7CU2E3C.js → chunk.33KXSD6F.js} +1 -1
  8. package/dist/preview/{chunk.WJQY4E45.js → chunk.3Q75TIGL.js} +1 -1
  9. package/dist/preview/{chunk.7WSXVXP3.js → chunk.3ZILIZZ6.js} +1 -1
  10. package/dist/preview/{chunk.HHUCPVG5.js → chunk.42XSBKPO.js} +1 -1
  11. package/dist/preview/chunk.4EEWBCT2.js +1 -0
  12. package/dist/preview/{chunk.23WYWIAJ.js → chunk.4Q7XJJZY.js} +1 -1
  13. package/dist/preview/{chunk.U7QMA4H7.js → chunk.4QPVS2ZM.js} +1 -1
  14. package/dist/preview/chunk.53CDFJNM.js +1 -0
  15. package/dist/preview/{chunk.CAMQ7MYJ.js → chunk.57R2GXXN.js} +1 -1
  16. package/dist/preview/chunk.5P556A7W.js +1 -0
  17. package/dist/preview/{chunk.5R4E5C76.js → chunk.5QXWMC6C.js} +1 -1
  18. package/dist/preview/{chunk.6XU2CXRZ.js → chunk.5RABSIF7.js} +1 -1
  19. package/dist/preview/{chunk.7EFNLMKU.js → chunk.67WWRC6Y.js} +1 -1
  20. package/dist/preview/{chunk.C2OAKTZX.js → chunk.6CRRPXKP.js} +1 -1
  21. package/dist/preview/{chunk.WXYUWBKX.js → chunk.6FNMDAX5.js} +1 -1
  22. package/dist/preview/chunk.6RID3OWK.js +1 -0
  23. package/dist/preview/{chunk.GXKECZ4S.js → chunk.6YPLZNVT.js} +1 -1
  24. package/dist/preview/{chunk.VC4JPG7O.js → chunk.7LIKEE5Z.js} +1 -1
  25. package/dist/preview/{chunk.LCYMYLOP.js → chunk.7YIFF6BF.js} +1 -1
  26. package/dist/preview/chunk.A4UIM35E.js +1 -0
  27. package/dist/preview/{chunk.2GGDOFTF.js → chunk.AIZQBPGU.js} +1 -1
  28. package/dist/preview/{chunk.EWWJMS6G.js → chunk.AKQXF7GW.js} +1 -1
  29. package/dist/preview/{chunk.N2SV3KX7.js → chunk.B5724ULM.js} +1 -1
  30. package/dist/preview/{chunk.CTK2P4JV.js → chunk.BELCPW66.js} +2 -2
  31. package/dist/preview/chunk.BFNVG5JE.js +1 -0
  32. package/dist/preview/{chunk.LP3QUPCE.js → chunk.BK6RWVRE.js} +1 -1
  33. package/dist/preview/{chunk.6CFP5UYP.js → chunk.BQRAIU5R.js} +1 -1
  34. package/dist/preview/{chunk.B7TB6YRZ.js → chunk.BXT6FDT4.js} +1 -1
  35. package/dist/preview/{chunk.FCXBCKED.js → chunk.C2PECN4C.js} +1 -1
  36. package/dist/preview/{chunk.QEXXLWEU.js → chunk.C4TSM4W5.js} +2 -2
  37. package/dist/preview/chunk.C7JKMOFC.js +1 -0
  38. package/dist/preview/{chunk.M5QFUGGG.js → chunk.D25XEVKO.js} +1 -1
  39. package/dist/preview/{chunk.EDC4EMIX.js → chunk.DGCMEDQA.js} +1 -1
  40. package/dist/preview/{chunk.P3JYH6HO.js → chunk.DL26BKT7.js} +1 -1
  41. package/dist/preview/{chunk.UB3O3QJQ.js → chunk.DMF35E7D.js} +1 -1
  42. package/dist/preview/{chunk.XLI44BBI.js → chunk.EAH47SCN.js} +1 -1
  43. package/dist/preview/{chunk.U4E5GQTK.js → chunk.EQ4UAWRB.js} +1 -1
  44. package/dist/preview/chunk.F2MQJH6Y.js +1 -0
  45. package/dist/preview/{chunk.37ASLBGE.js → chunk.FFZBOP65.js} +1 -1
  46. package/dist/preview/chunk.FOQZADMA.js +25 -0
  47. package/dist/preview/{chunk.OM5CDW2S.js → chunk.GT2BITLW.js} +1 -1
  48. package/dist/preview/{chunk.UIUHGA6W.js → chunk.H5ADMSE7.js} +1 -1
  49. package/dist/preview/{chunk.XBOZTQQA.js → chunk.H5HWN7A2.js} +1 -1
  50. package/dist/preview/{chunk.OYMM2UWE.js → chunk.H7POIT3V.js} +1 -1
  51. package/dist/preview/{chunk.CMN6VVK2.js → chunk.HB7ELBVK.js} +1 -1
  52. package/dist/preview/{chunk.WTZOOAIW.js → chunk.HEVC6HHP.js} +1 -1
  53. package/dist/preview/{chunk.CF7DHTKL.js → chunk.HI7X6PLZ.js} +2 -2
  54. package/dist/preview/{chunk.IXYBIDAN.js → chunk.HKCK3JI4.js} +1 -1
  55. package/dist/preview/{chunk.IAZRY42B.js → chunk.HPAGOEZG.js} +1 -1
  56. package/dist/preview/chunk.HPUN5DKZ.js +117 -0
  57. package/dist/preview/chunk.I4JBWTZM.js +2 -0
  58. package/dist/preview/{chunk.4BBJ62ZO.js → chunk.I7XSDXQ3.js} +1 -1
  59. package/dist/preview/{chunk.FMN5XDLE.js → chunk.ISXFH3CK.js} +1 -1
  60. package/dist/preview/chunk.J4IULZFD.js +1 -0
  61. package/dist/preview/chunk.JACGQ2PR.js +4 -0
  62. package/dist/preview/{chunk.YXGI7H4Y.js → chunk.JDRLSVOI.js} +1 -1
  63. package/dist/preview/chunk.JHEVGLKB.js +345 -0
  64. package/dist/preview/chunk.JLBGJSCZ.js +1 -0
  65. package/dist/preview/chunk.JYJ4LZJJ.js +5 -0
  66. package/dist/preview/{chunk.ZR5KVYWZ.js → chunk.L3A6YLMT.js} +2 -2
  67. package/dist/preview/{chunk.5JPRFXYQ.js → chunk.L4STJLUV.js} +1 -1
  68. package/dist/preview/{chunk.JEZTPXEB.js → chunk.LOCSF3BR.js} +1 -1
  69. package/dist/preview/{chunk.XLZ2QRRS.js → chunk.LOSMUESM.js} +1 -1
  70. package/dist/preview/chunk.LOZJQ5ZX.js +1 -0
  71. package/dist/preview/{chunk.TU4KG22J.js → chunk.LPNIEPYI.js} +2 -2
  72. package/dist/preview/{chunk.OJKS3UQS.js → chunk.LPYVOBWB.js} +1 -1
  73. package/dist/preview/{chunk.2NSTEREJ.js → chunk.M4T377LG.js} +1 -1
  74. package/dist/preview/{chunk.G46WGK5E.js → chunk.MSP73H5Z.js} +1 -1
  75. package/dist/preview/chunk.MUKDKVVC.js +1 -0
  76. package/dist/preview/chunk.MUPO5S2A.js +47 -0
  77. package/dist/preview/{chunk.P4WYBSYA.js → chunk.N2K25KH3.js} +1 -1
  78. package/dist/preview/{chunk.KJNUZYXS.js → chunk.N6MVK3KD.js} +1 -1
  79. package/dist/preview/{chunk.3ZNQ5YKX.js → chunk.NGDXH66B.js} +1 -1
  80. package/dist/preview/chunk.O6F3K6CU.js +1 -0
  81. package/dist/preview/chunk.O75JKQPF.js +1 -0
  82. package/dist/preview/{chunk.KSXB4LDF.js → chunk.OF34OZ4V.js} +1 -1
  83. package/dist/preview/chunk.OVTCW3AI.js +1 -0
  84. package/dist/preview/{chunk.HA3PPIEQ.js → chunk.OW7NSJ4H.js} +1 -1
  85. package/dist/preview/{chunk.ROKRQRID.js → chunk.PMDNFN7Z.js} +1 -1
  86. package/dist/preview/chunk.PMGXASFI.js +32 -0
  87. package/dist/preview/{chunk.JBTU2PJ4.js → chunk.Q4TZHWQX.js} +1 -1
  88. package/dist/preview/chunk.QHYXXZRD.js +1 -0
  89. package/dist/preview/chunk.QIV65FWE.js +1 -0
  90. package/dist/preview/{chunk.GP2F7TIN.js → chunk.RCM7NOPF.js} +2 -1
  91. package/dist/preview/{chunk.NG3YMQ36.js → chunk.RQGTHRRJ.js} +1 -1
  92. package/dist/preview/{chunk.F5UVEF2R.js → chunk.S2U5CEP4.js} +1 -1
  93. package/dist/preview/chunk.SADG5RMV.js +1 -0
  94. package/dist/preview/chunk.SCYQSXW4.js +1 -0
  95. package/dist/preview/{chunk.W4OX4BMP.js → chunk.SIGC3G7S.js} +1 -1
  96. package/dist/preview/chunk.T3BWINOF.js +1 -0
  97. package/dist/preview/{chunk.2BJRS3YJ.js → chunk.TGVUIFKD.js} +1 -1
  98. package/dist/preview/{chunk.AYHCQWSU.js → chunk.TIH2PDFH.js} +1 -1
  99. package/dist/preview/chunk.TKUNRFDE.js +1 -0
  100. package/dist/preview/{chunk.5XNVN4HE.js → chunk.TN5PYGU7.js} +1 -1
  101. package/dist/preview/{chunk.6DHHUBSC.js → chunk.TNESS3LQ.js} +1 -1
  102. package/dist/preview/{chunk.QMFUPTR4.js → chunk.UEXIKCLF.js} +1 -1
  103. package/dist/preview/chunk.UHI3D7JC.js +1 -0
  104. package/dist/preview/chunk.USZPOOLZ.js +1 -0
  105. package/dist/preview/chunk.UTWPZULC.js +1 -0
  106. package/dist/preview/{chunk.H5CZZZLX.js → chunk.UUBYFBPN.js} +1 -1
  107. package/dist/preview/{chunk.ROINZMNO.js → chunk.UWW6ZEPY.js} +2 -2
  108. package/dist/preview/{chunk.ZTMDU3OH.js → chunk.V3V47QRE.js} +1 -1
  109. package/dist/preview/{chunk.BYKR7NEE.js → chunk.V4KLBSC4.js} +1 -1
  110. package/dist/preview/chunk.V5MYKNL7.js +5 -0
  111. package/dist/preview/{chunk.C4CFYTCW.js → chunk.VCX3HEIE.js} +1 -1
  112. package/dist/preview/{chunk.DYNBWIPF.js → chunk.VDAMCTNL.js} +1 -1
  113. package/dist/preview/chunk.VIYECFKZ.js +6 -0
  114. package/dist/preview/{chunk.ITEF3U2E.js → chunk.VJXXCUKS.js} +1 -1
  115. package/dist/preview/{chunk.EBHKKOPO.js → chunk.VNUHESMZ.js} +1 -1
  116. package/dist/preview/{chunk.67USHK26.js → chunk.W3FTEJH5.js} +1 -1
  117. package/dist/preview/chunk.W4HBRXMY.js +1 -0
  118. package/dist/preview/{chunk.5OJJ2TKZ.js → chunk.WUKHYLQT.js} +2 -2
  119. package/dist/preview/{chunk.CC47O2DW.js → chunk.WVDKYUF3.js} +1 -1
  120. package/dist/preview/{chunk.BEC5ZH2L.js → chunk.XEKLEHC3.js} +1 -1
  121. package/dist/preview/{chunk.FILCNVGH.js → chunk.XFZKP4IF.js} +1 -1
  122. package/dist/preview/chunk.XOYJ26YB.js +1 -0
  123. package/dist/preview/{chunk.4PNFX3TX.js → chunk.YWNHCZQ5.js} +1 -1
  124. package/dist/preview/{chunk.4ECICQ2S.js → chunk.YYFLTMNN.js} +1 -1
  125. package/dist/preview/{chunk.B2IRADR2.js → chunk.Z5AB2DBF.js} +1 -1
  126. package/dist/preview/chunk.Z7BCIYDW.js +1 -0
  127. package/dist/preview/{chunk.C6X7CKU6.js → chunk.Z7LDT55A.js} +1 -1
  128. package/dist/preview/{chunk.2IX3CZNP.js → chunk.ZHLQWMV5.js} +1 -1
  129. package/dist/preview/{chunk.JCR3ECUM.js → chunk.ZOR6FKNI.js} +1 -1
  130. package/dist/preview/{chunk.STBJV6HJ.js → chunk.ZRLXVYPG.js} +1 -1
  131. package/dist/preview/{chunk.RM7NVN7B.js → chunk.ZRYSVOLA.js} +2 -2
  132. package/dist/preview/chunk.ZTMEESII.js +1 -0
  133. package/dist/preview/index.html +45 -43
  134. package/dist/preview/page.js +8 -8
  135. package/package.json +6 -6
  136. package/dist/preview/chunk.2HF54MYG.js +0 -1
  137. package/dist/preview/chunk.2RCNSHXK.js +0 -1
  138. package/dist/preview/chunk.546WEHEX.js +0 -47
  139. package/dist/preview/chunk.57OPL5WD.js +0 -1
  140. package/dist/preview/chunk.5ZMENPY4.js +0 -5
  141. package/dist/preview/chunk.6HBEYRJU.js +0 -1
  142. package/dist/preview/chunk.6L7IDF3J.js +0 -1
  143. package/dist/preview/chunk.ALDLAQ7V.js +0 -1
  144. package/dist/preview/chunk.BCHHBGM6.js +0 -1
  145. package/dist/preview/chunk.BL4S3I2N.js +0 -1
  146. package/dist/preview/chunk.BS3FX4PX.js +0 -1
  147. package/dist/preview/chunk.BTSXYZ6Z.js +0 -25
  148. package/dist/preview/chunk.BZSU4HH2.js +0 -1
  149. package/dist/preview/chunk.DAA7IDQ4.js +0 -1
  150. package/dist/preview/chunk.E3HXXUKY.js +0 -1
  151. package/dist/preview/chunk.EM4Y4YAD.js +0 -2
  152. package/dist/preview/chunk.FGDHEVH4.js +0 -1
  153. package/dist/preview/chunk.FJBQ4UP3.js +0 -32
  154. package/dist/preview/chunk.G23VFYGF.js +0 -88
  155. package/dist/preview/chunk.HFDYFPMJ.js +0 -1
  156. package/dist/preview/chunk.HGS32FT2.js +0 -1
  157. package/dist/preview/chunk.J3M2MZHG.js +0 -1
  158. package/dist/preview/chunk.KIJCOW25.js +0 -1
  159. package/dist/preview/chunk.L7DQKPJV.js +0 -117
  160. package/dist/preview/chunk.LP2DJ5ZB.js +0 -6
  161. package/dist/preview/chunk.N7N5OFPL.js +0 -1
  162. package/dist/preview/chunk.ORXFUK6F.js +0 -344
  163. package/dist/preview/chunk.OXTUXWMU.js +0 -1
  164. package/dist/preview/chunk.P5325GYR.js +0 -1
  165. package/dist/preview/chunk.PMER4LVT.js +0 -1
  166. package/dist/preview/chunk.PONWLTTB.js +0 -1
  167. package/dist/preview/chunk.QCF6Z2AZ.js +0 -1
  168. package/dist/preview/chunk.RWB4235L.js +0 -1
  169. package/dist/preview/chunk.SK33IHL2.js +0 -4
  170. package/dist/preview/chunk.TCUB6IDY.js +0 -1
  171. package/dist/preview/chunk.TJCTTJWE.js +0 -1
  172. package/dist/preview/chunk.UCZR33MK.js +0 -1
  173. package/dist/preview/chunk.UGCNMAPC.js +0 -1
  174. package/dist/preview/chunk.XDYAG276.js +0 -1
@@ -1 +1 @@
1
- import{a as Se,b as Pe,c as Ge,d as ge,e as F,f as Ce,h as Ne}from"./chunk.DYNBWIPF.js";import{h as Ie,i as qe,j as Ve}from"./chunk.UCZR33MK.js";import{a as se,b as re,c as Z,d as _e,e as Y,g as ne,h as Be}from"./chunk.2IX3CZNP.js";import{c as Me,h as g,i as Te,j as me}from"./chunk.6DHHUBSC.js";import{Ea as De,Fa as ee,Ga as fe,Jb as ue,Kb as Ke,b as L,c as q,e as xe,f as Ee,g as C,h as j,k as T,l as X,m as G,n as Ae,o as V,p as K,r as k,s as Q,t as E,u as R,v as I,w as P,x as n,xa as Fe,y as U,z as Re}from"./chunk.5ZMENPY4.js";var ln=e=>Object.entries(e).map(([o,s])=>[o,Object.keys(ee(s?.edges))]),ze=(e,o)=>Ke(e,ln(o));var ye="graview-document",be=1,ke=256*1024,he=64*1024,$e=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,we=/^[a-z][A-Za-z0-9]*$/,pn=new Set(["id","kind"]),fn=e=>e in Object.prototype,Ze=U(e=>!fn(e),"every object already has this name \u2014 choose another"),Ye=(e,o)=>[...e===void 0?[]:[Ee(e)],...o===void 0?[]:[xe(o)]],h=(e,o)=>j().check(...Ye(e,o)),v=(e,o,s)=>K(e).check(...Ye(o,s)),D=e=>j().check(C($e,`${e} names are kebab-case, lower-case words joined by hyphens like "tool-note" (field and relation names are camelCase, like "supersededBy")`)),un=/^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|[a-z][A-Za-z0-9]*)$/,W=j().check(C(un,'relation names are one camelCase word, like "supersededBy" (kind names are kebab-case, like "tool-note")'),Ze),N=j().check(C(we,'field names are one word or camelCase, like "dueDate", so rules say them bare (kind names are kebab-case, like "tool-note")'),U(e=>!pn.has(e),'a field cannot be called "id" or "kind" \u2014 the framework keeps those; try "type" or "category"'),Ze),B=h(1,500),H=h(1,2e3),ae=h(1,300),mn=["string","text","number","integer","boolean","date","datetime","enum","list","url","email","image","video","file","app-link","phone","place","duration"],Je=k({type:I(mn),required:n(G()),description:n(B),label:n(h(1,60)),options:n(v(h(1,80),1,100)),of:n(I(["string","number","date","image","video","file"])),default:n(V()),unit:n(h(void 0,12)),format:n(I(["money","percent","duration","markdown"])),min:n(T()),max:n(T()),step:n(T()),renamedFrom:n(j().check(C(we))),repeats:n(G())}).check(Re((e,o)=>{e.type==="enum"&&!e.options&&o.addIssue({code:"custom",message:'an enum field lists its "options"',path:["options"]}),e.type!=="enum"&&e.options&&o.addIssue({code:"custom",message:'"options" belongs only on an enum field',path:["options"]}),e.type!=="list"&&e.of&&o.addIssue({code:"custom",message:'"of" belongs only on a list field',path:["of"]}),e.repeats&&e.type!=="date"&&e.type!=="datetime"&&o.addIssue({code:"custom",message:'"repeats" belongs only on a date or datetime field',path:["repeats"]})})),gn=j().check(C(new RegExp(`${$e.source}|${Fe.source}`),'a relation goes to a kind of this document, like "house", or of another app, like "@nick/house/house"')),zn=k({to:E([v(gn,1),P("*")]),cardinality:n(I(["one","many"])),description:n(B),inverse:n(h(1,80)),appendOnly:n(G()),renamedFrom:n(j()),tidying:n(P("never"))}),He=E([H,k({expr:H,label:n(h(1,60)),description:n(B)})]),hn=k({noun:n(h(1,40)),plural:n(h(1,40)),description:n(B),fields:R(N,Je).check(U(e=>Object.keys(e).length>0,"a kind has at least one field")),label:n(ae),describe:n(ae),lifecycle:n(k({field:N,retired:v(E([j(),T(),G()]),1)})),figure:n(h(void 0,2e4)),glance:n(v(N,1,20)),page:n(k({fields:n(v(N,1,40)),groups:n(v(k({title:h(1,60),fields:v(N,1,40)}),1,12))})),edges:n(R(W,zn)),computed:n(R(j(),He).check(U(e=>Object.keys(e).length<=20,"a kind works out at most 20 computed fields"))),fieldRoles:n(R(j(),j())),renamedFrom:n(j().check(C($e))),people:n(G()),archives:n(P(!1)),tidying:n(I(["never","no-links"]))}),te=E([j(),T(),G(),Ae(),K(V()),k({expr:H})]),J=j().check(C(/^\$[A-Za-z][A-Za-z0-9]*$/,'a reference is "$" and a name, like "$subject" or "$new"')),yn=E([k({create:D("kind"),as:n(j().check(C(we))),set:n(R(N,te))}),k({set:R(N,te),target:n(J)}),k({connect:W,from:J,to:J}),k({sever:W,from:J,to:J}),k({remove:J})]),bn=k({title:n(h(1,80)),description:n(B),fromTheOtherEnd:n(h(1,80)),on:n(E([D("kind"),v(D("kind"),1)])),creates:n(D("kind")),sets:n(R(N,te)),writes:n(v(N,1)),connects:n(W),severs:n(W),setsOther:n(R(N,te)),replaces:n(E([P(!0),v(W,1,10)])),removes:n(P(!0)),args:n(R(N,Je)),effects:n(v(yn,1,20)),allowedWhen:n(H),refusal:n(ae),destructive:n(G())}),kn=k({act:D("act"),label:n(h(1,80)),args:n(R(j(),te))}),$n=k({title:n(h(1,120)),description:n(B),over:E([P("graph"),D("kind")]),when:n(H),require:H,says:n(ae),repairs:n(v(kn,void 0,10))}),wn=k({roles:E([v(D("role"),1),P("*")]),mutations:E([v(D("act"),1),P("*")]),kinds:n(E([K(D("kind")),P("*")])),describe:n(B),self:n(G()),ownEnd:n(G())}),Le=n(v(D("field"),1)),jn=k({roles:E([v(D("role"),1),P("*")]),kinds:v(D("kind"),1),own:n(G()),via:n(W),fields:Le,hide:Le}),On=k({grants:K(wn),sees:n(K(jn))}),vn=k({accent:n(j().check(C(/^#[0-9a-fA-F]{6}$/,'an accent is a color like "#c2577a"'))),name:n(h(1,60)),currency:n(j().check(C(/^[A-Z]{3}$/,'a currency is its three-letter code, like "USD" or "EUR"'))),locale:n(h(2,35)),timeZone:n(h(1,64)),logo:n(E([h(1,he),k({src:h(1,he),alt:n(h(1,120))})])),favicon:n(E([h(1,he),k({emoji:j()})])),typography:n(k({display:n(h(1,200)),body:n(h(1,200)),mono:n(h(1,200))})),shape:n(k({radius:n(T().check(q(0),L(32))),density:n(T().check(q(.75),L(1.5)))})),accents:n(R(j(),T().check(q(0),L(360)))),scheme:n(I(["light","dark","auto"]))}),ie=R(j(),V()),Ue=E([h(1,120),k({by:h(1,120),direction:n(I(["asc","desc"]))})]),We=T().check(X(),q(1),L(9999)),Sn=Q({create:n(G()),options:n(Q({sort:n(Ue),columnSort:n(Ue),search:n(v(h(1,120),void 0,40)),filters:n(v(h(1,120),void 0,40)),horizon:n(E([T().check(X(),q(1),L(200)),Q({years:T().check(X(),q(1),L(200)),title:h(1,80),from:n(We),to:n(We)})]))}))}),xn=k({card:n(K(V())),row:n(K(V())),page:n(K(V()))}),En=()=>{let e=n(I(["asc","desc"]));return E([h(1,120),k({by:h(1,120),direction:e,then:n(E([h(1,120),k({by:h(1,120),direction:e})]))})])},An=()=>E([h(1,120),k({by:h(1,120),order:n(v(h(1,80),void 0,40)),closed:n(v(h(1,80),void 0,40))})]),Rn=Q({order:n(K(j())),hide:n(K(j())),first:n(j()),primary:n(v(h(1,80),void 0,40)),scene:n(h(1,40)),pages:n(h(1,40)),lists:n(R(j(),k({filters:n(v(h(1,120),void 0,40)),sort:n(En()),group:n(An())})))}),Xe=k({$schema:n(j()),format:P(ye),formatVersion:P(be),name:h(1,80),description:n(B),version:n(T().check(X(),q(1))),kinds:R(D("kind"),hn).check(U(e=>Object.keys(e).length>0,"a document declares at least one kind"),U(e=>Object.keys(e).length<=40,"a document declares at most 40 kinds")),computed:n(R(j(),He)),acts:n(R(D("act"),bn)),rules:n(R(D("rule"),$n)),roles:n(K(D("role"))),policy:n(On),modules:n(ie),lenses:n(K(Sn)),pages:n(Rn),views:n(R(j(),E([xn,K(V())]))),brand:n(vn),settings:n(K(ie)),migrations:n(K(ie)),connections:n(R(D("connection"),ie))});var Fn={};function Qe(e,o=Fn,s=be){let{document:a,respelled:l}=Se(e),p=l.length>0?{respelled:l}:{};if(!a||typeof a!="object"||Array.isArray(a))return{document:a};let u=a;if(u.format!==ye||typeof u.formatVersion!="number"||u.formatVersion>=s)return{document:a,...p};let z=u.formatVersion,$=structuredClone(u);for(let r=z;r<s;r++){let t=o[r];if(!t)throw new Error(`there is no upgrade from format ${r} to ${r+1}`);$={...t($),formatVersion:r+1}}return{document:$,from:z,...p}}function en(e,o,s){let a=Object.keys(e).filter(z=>e[z].edges?.[o]!==void 0);if(a.length===0)return;let l=a.map(z=>e[z].edges[o].to),p=l.some(z=>z==="*")?"*":[...new Set(l.flatMap(z=>z))];if(s.length===0||s.some(z=>a.includes(z)))return{reversed:!1,kinds:p};let u=a.filter(z=>{let $=e[z].edges[o].to;return $==="*"||s.every(r=>$.includes(r))});return u.length>0?{reversed:!0,kinds:u}:{reversed:!1,kinds:p}}var on=(e,o)=>{let s=e?.fields[o];return s!==void 0&&(s.type==="duration"||(s.type==="number"||s.type==="integer")&&s.format==="duration")};function nn(e,o,s,a){if(a==="out"){let l=e[o]?.edges?.[s]?.to;return l===void 0?[]:l==="*"?Object.keys(e):l}return Object.entries(e).filter(([,l])=>{let p=l.edges?.[s]?.to;return p!==void 0&&(p==="*"||p.includes(o))}).map(([l])=>l)}function je(e,o,s){if(s.t==="ident")return e[o]?.edges?.[s.name]?nn(e,o,s.name,"out"):void 0;if(s.t==="where")return je(e,o,s.set);if(s.t==="call"&&(s.fn==="out"||s.fn==="in")&&s.args[0]?.t==="lit"&&typeof s.args[0].value=="string")return nn(e,o,s.args[0].value,s.fn)}var tn=(e,o,s)=>{let a=o.filter(l=>e[l]?.fields[s]!==void 0);return a.length>0&&a.every(l=>on(e[l],s))};function sn(e,o,s){let a=e.kinds,l=a[o],p=new Map(s),u=new Map,z=(r,t)=>{if(t>8)return!1;switch(r.t){case"ident":return on(l,r.name)||$(r.name,t+1);case"member":{let d=je(a,o,r.object);return d!==void 0&&tn(a,d,r.name)}case"call":{if(r.fn!=="sum"&&r.fn!=="min"&&r.fn!=="max")return!1;let[d,w]=r.args,f=d&&je(a,o,d);return f!==void 0&&w?.t==="ident"&&tn(a,f,w.name)}case"binary":return(r.op==="+"||r.op==="-")&&z(r.left,t)&&z(r.right,t);case"unary":return r.op==="-"&&z(r.operand,t);default:return!1}},$=(r,t)=>{if(l?.computed?.[r]===void 0)return!1;if(u.has(r))return u.get(r);u.set(r,!1);let d=p.get(r),w=d!==void 0&&z(d,t);return u.set(r,w),w};return s.map(([r])=>r).filter(r=>$(r,0))}function rn(e,o,s=`kinds.${e}.page`){let a=o.page;if(!a)return[];let l=[],p=[...Object.keys(o.fields),...Object.keys(o.computed??{})],u=new Set,z=(r,t)=>{p.includes(r)?u.has(r)&&l.push(g("page-field-twice",t,`"${r}" is on ${e}'s page twice; name each field once`)):l.push(g("page-field",t,`${e}'s page is to show "${r}", and ${e} has no field or computed field called that`,`use one of: ${p.join(", ")}`)),u.add(r)};(a.fields??[]).forEach((r,t)=>z(r,`${s}.fields.${t}`));let $=new Set;return(a.groups??[]).forEach((r,t)=>{let d=r.title.trim().toLowerCase();$.has(d)&&l.push(g("page-group-twice",`${s}.groups.${t}.title`,`${e}'s page has two groups called "${r.title}"; give each its own title`)),$.add(d),r.fields.forEach((w,f)=>z(w,`${s}.groups.${t}.fields.${f}`))}),l}var Dn=new Set(["subject","now","today","me"]);function Kn(e){if((typeof e=="string"?e:JSON.stringify(e??null)).length>ke)return{findings:[g("too-large","",`a document may be at most ${ke/1024} KB`)]};if(typeof e=="string")try{e=JSON.parse(e)}catch(a){return{findings:[g("not-json","",`this is not JSON: ${a.message}`)]}}try{e=Qe(e).document}catch(a){return{findings:[g("format","formatVersion",a.message)]}}let o=Xe.safeParse(e);if(!o.success)return{findings:o.error.issues.map(a=>{let l=a.path.map(String).join(".");if(a.code==="unrecognized_keys")return g("unknown-key",l,`${a.keys.map(p=>`"${p}"`).join(", ")} ${a.keys.length===1?"is":"are"} not part of a Graview document here`,"check the spelling against docs/declaration-document.md");if(a.code==="invalid_union"&&/\.effects\.\d+$/.test(l))return g("effect-shape",l,"this effect is not one Graview knows",'an effect is one of {"create": kind, "as"?: name, "set"?: {field: value}}, {"set": {field: value, \u2026}, "target"?: "$ref"}, {"connect"|"sever": relation, "from": "$ref", "to": "$ref"}, {"remove": "$ref"}');if(a.code==="invalid_key"){let p=a.issues?.[0]?.message;return g("shape",l,`the name "${String(a.path.at(-1))}" is not allowed here${p?`: ${p}`:""}`)}return g("shape",l,a.message)})};let s=o.data;return{document:s,findings:Mn(s)}}var de=e=>[e??[]].flat();function an(e){let o=new Map;for(let[s,a]of Object.entries(e.kinds))for(let[l,p]of Object.entries(ee(a.edges))){let u=o.get(l);o.set(l,{name:l,from:[...u?.from??[],s],to:p.to==="*"||u?.to==="*"?"*":[...new Set([...u?.to??[],...p.to])],cardinality:p.cardinality??"many"})}return o}function ht(e){let o=new Map;for(let[a,l]of Object.entries(e.kinds)){let p=ne(l),u=fe(l.edges);o.set(a,{fields:new Set([...Object.keys(l.fields),...u.keys()]),edges:new Map(Object.entries(ee(l.edges)).map(([z,$])=>[z,$.cardinality??"many"])),...p?{computed:p}:{},...u.size>0?{linked:u}:{}})}let s=ne(e);return s&&o.set(Me,{computed:s}),o}function cn(e,o){let s=[],a=de(e.on),l=(p,u)=>{let z=en(o.kinds,p,a)?.reversed===!0,[$,r]=z?["$to","$subject"]:["$subject","$to"];return u==="connect"?{connect:p,from:$,to:r}:{sever:p,from:$,to:r}};if(e.creates){let p=o.kinds[e.creates],u={};for(let z of Object.keys(p?.fields??{}))u[z]=`$${z}`;for(let z of e.effects??[])"set"in z&&!("create"in z)&&F(z.target)==="new"&&Object.assign(u,z.set);s.push({create:e.creates,as:"new",set:u})}return e.sets&&s.push({set:e.sets}),e.writes&&!(e.creates&&e.on===void 0)&&s.push({set:Object.fromEntries(e.writes.map(p=>[p,`$${p}`]))}),e.connects&&(e.replaces&&s.push({replace:e.replaces===!0?[e.connects]:[...e.replaces],keep:e.connects}),s.push(l(e.connects,"connect"))),e.severs&&s.push(l(e.severs,"sever")),e.setsOther&&(e.connects||e.severs)&&s.push({set:e.setsOther,target:"$to"}),e.removes&&s.push({remove:"$subject"}),e.effects&&s.push(...e.effects.filter(p=>!(e.creates&&"set"in p&&!("create"in p)&&F(p.target)==="new"))),s}function Oe(e,o,s){try{let a=Z(e),l=se(a);for(let p of l.unknownFunctions)s.push(g("unknown-function",o,`"${p}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));return a}catch(a){if(a instanceof re){s.push(g("expression",o,a.sentence+` (at character ${a.at+1})`));return}throw a}}function ve(e,o,s){try{return Y(e)}catch(a){if(a instanceof _e||a instanceof re){s.push(g("template",o,(a instanceof re,a.sentence)));return}throw a}}function Mn(e){let o=[],s=new Set(Object.keys(e.kinds)),a=an(e),l=e.acts??{},p=new Set(e.roles??[]),u=(r,t)=>fe(e.kinds[r]?.edges).has(t),z=r=>Object.keys(e.kinds).some(t=>u(t,r));for(let[r,t]of Object.entries(e.kinds)){let d=`kinds.${r}`;for(let[f,c]of Object.entries(t.edges??{})){if(!De(c)&&c.to!=="*")for(let i of c.to)s.has(i)||o.push(g("edge-target",`${d}.edges.${f}.to`,`"${i}" is not a kind this document declares`));t.fields[f]&&o.push(g("edge-field-clash",`${d}.edges.${f}`,`"${f}" is both a field and a relation of ${r}`,"rename one of them"))}t.lifecycle&&!t.fields[t.lifecycle.field]&&o.push(g("lifecycle-field",`${d}.lifecycle.field`,`${r} has no field "${t.lifecycle.field}"`));let w=f=>t.computed!==void 0&&Object.hasOwn(t.computed,f);for(let f of t.glance??[])!t.fields[f]&&!w(f)&&o.push(g("glance-field",`${d}.glance`,`a glance at ${r} is to say "${f}", and ${r} has no field or computed field called that`,`use one of: ${[...Object.keys(t.fields),...Object.keys(t.computed??{})].join(", ")}`));o.push(...rn(r,t));for(let f of["label","describe"]){let c=t[f];if(!c)continue;let i=ve(c,`${d}.${f}`,o);for(let A of i??[])if(A.expr){for(let y of se(A.expr).names)if(!t.fields[y]){if(w(y)){Be(t,y)||o.push(g("template-field",`${d}.${f}`,`${r}'s ${y} is worked out from beyond the record, and a ${f} is said with no graph to read`,`show it in a view instead, or name a computed field worked out from ${r}'s own fields`));continue}o.push(g("template-field",`${d}.${f}`,`${r} has no field "${y}" for its ${f} to show`,f==="label"?"a label can only show the record's own fields and what they work out":void 0))}}}for(let[f,c]of Object.entries(t.fields)){c.default!==void 0&&c.type==="enum"&&!c.options?.includes(String(c.default))&&o.push(g("default-option",`${d}.fields.${f}.default`,`"${String(c.default)}" is not one of ${f}'s options`));let i=`${f}Repeat`;c.repeats&&(t.fields[i]||t.edges?.[i]||t.computed?.[i])&&o.push(g("repeat-clash",`${d}.fields.${f}.repeats`,`${r} already has "${i}", where how ${f} repeats is kept`))}}for(let[r,t]of Object.entries(l)){let d=`acts.${r}`;for(let i of de(t.on))s.has(i)||o.push(g("act-kind",`${d}.on`,`"${i}" is not a kind this document declares`));let w=de(t.on),f=cn(t,e);if(t.creates&&t.on===void 0&&t.writes&&s.has(t.creates)){for(let i of t.writes)if(!e.kinds[t.creates].fields[i])if(e.kinds[t.creates].computed?.[i]!==void 0)o.push(g("computed-written",`${d}.writes`,`${t.creates}'s ${i} is worked out, not written: no act can set it`,"write the stored fields it is worked out from"));else{if(u(t.creates,i))continue;o.push(g("act-field",`${d}.writes`,`${t.creates} has no field "${i}"`))}}f.length===0&&o.push(g("act-empty",d,`"${r}" does nothing`,"give it effects or a shorthand such as sets or creates"));let c=new Map;f.forEach((i,A)=>{let y=f.length-(t.effects?.length??0),O=t.effects&&A>=y?`${d}.effects.${A-y}`:d;if("create"in i){if(!s.has(i.create))o.push(g("act-kind",`${O}.create`,`"${i.create}" is not a kind this document declares`));else for(let b of Object.keys(i.set??{}))e.kinds[i.create].fields[b]||(e.kinds[i.create].computed?.[b]!==void 0?o.push(g("computed-written",`${O}.set.${b}`,`${i.create}'s ${b} is worked out, not written: no act can set it`,"set the stored fields it is worked out from")):o.push(g("act-field",`${O}.set.${b}`,`${i.create} has no field "${b}"`)));i.as&&c.set(i.as,i.create)}else if("connect"in i||"sever"in i){let b="connect"in i?i.connect:i.sever;!a.has(b)&&!z(b)&&o.push(g("act-edge",`${O}.${"connect"in i?"connect":"sever"}`,`"${b}" is not a relation any kind declares`)),F(i.from)==="subject"&&w.length===0&&o.push(g("act-subject",`${d}.on`,`"${r}" acts on "$subject" but does not say which kinds it is "on"`))}else if("set"in i){let b=F(i.target??"$subject"),le=b==="subject"?w:c.has(b??"")?[c.get(b)]:[];b==="subject"&&w.length===0&&o.push(g("act-subject",`${d}.on`,`"${r}" changes "$subject" but does not say which kinds it is "on"`));for(let _ of Object.keys(i.set))for(let m of le)if(!(!s.has(m)||e.kinds[m].fields[_]))if(e.kinds[m].computed?.[_]!==void 0)o.push(g("computed-written",`${O}.set.${_}`,`${m}'s ${_} is worked out, not written: no act can set it`,"set the stored fields it is worked out from"));else{if(u(m,_))continue;o.push(g("act-field",`${O}.set.${_}`,`${m} has no field "${_}"`))}}else"remove"in i&&F(i.remove)==="subject"&&w.length===0&&o.push(g("act-subject",`${d}.on`,`"${r}" removes "$subject" but does not say which kinds it is "on"`));("set"in i&&i.set?Object.values(i.set):[]).forEach(b=>{b&&typeof b=="object"&&!Array.isArray(b)&&"expr"in b&&Oe(b.expr,`${O}.set`,o)})}),t.allowedWhen&&Oe(t.allowedWhen,`${d}.allowedWhen`,o),t.refusal&&ve(t.refusal,`${d}.refusal`,o)}for(let[r,t]of Object.entries(e.rules??{})){let d=`rules.${r}`;t.over!=="graph"&&!s.has(t.over)&&o.push(g("rule-kind",`${d}.over`,`"${t.over}" is not a kind this document declares`));let w=t.over==="graph"?void 0:e.kinds[t.over];for(let f of["when","require"]){let c=t[f];if(!c)continue;let i=Oe(c,`${d}.${f}`,o);if(!i)continue;let A=se(i);for(let y of A.names)if(t.over==="graph")o.push(g("rule-name",`${d}.${f}`,`"${y}" means nothing in a rule over the whole graph`,`name a kind in "over", or use all('kind')`));else if(w&&!w.fields[y]&&!w.edges?.[y]&&w.computed?.[y]===void 0){let O=Object.keys(w.edges??{}).find(S=>S.includes("-")&&S.split("-").includes(y));o.push(g("rule-name",`${d}.${f}`,`${t.over} has no field or relation called "${y}"`,O?`"${O}" reads as a subtraction in a rule; rename the relation to one camelCase word, like "${O.replace(/-([a-z0-9])/g,(S,b)=>b.toUpperCase())}"`:void 0))}for(let y of A.edges)!a.has(y)&&!z(y)&&o.push(g("rule-edge",`${d}.${f}`,`"${y}" is not a relation any kind declares`));for(let y of A.sweeps)s.has(y)?t.over!=="graph"&&o.push(Te("rule-cost",`${d}.${f}`,`this rule looks at every ${y} for every ${t.over}, which grows slowly as the app grows`,"walk a relation with out()/in() instead of all() where you can")):o.push(g("rule-kind",`${d}.${f}`,`"${y}" is not a kind this document declares`))}t.says&&ve(t.says,`${d}.says`,o),(t.repairs??[]).forEach((f,c)=>{!l[f.act]&&!ue(f.act)&&!ze(f.act,e.kinds)&&o.push(g("repair-act",`${d}.repairs.${c}.act`,`"${f.act}" is not an act this document declares`))})}let $=e.policy;return $&&($.grants.forEach((r,t)=>{if(r.roles!=="*"&&p.size>0)for(let d of r.roles)p.has(d)||o.push(g("grant-role",`policy.grants.${t}.roles`,`"${d}" is not one of the document's roles`));if(r.mutations!=="*")for(let d of r.mutations)!l[d]&&!ue(d)&&!ze(d,e.kinds)&&o.push(g("grant-act",`policy.grants.${t}.mutations`,`"${d}" is not an act this document declares`))}),($.sees??[]).forEach((r,t)=>{for(let d of r.kinds)s.has(d)||o.push(g("sight-kind",`policy.sees.${t}.kinds`,`"${d}" is not a kind this document declares`));if(r.roles!=="*"&&p.size>0)for(let d of r.roles)p.has(d)||o.push(g("sight-role",`policy.sees.${t}.roles`,`"${d}" is not one of the document's roles`))})),o.push(...Ve(e)),o}function Tn(e,o,s,a){let l=new Map,p=de(e.on),u=new Map,z=new Map;(p.length>0||o.some(c=>"remove"in c&&F(c.remove)==="subject"||"from"in c&&(F(c.from)==="subject"||F(c.to)==="subject")||"set"in c&&!("create"in c)&&F(c.target??"$subject")==="subject"))&&l.set(ge,{ref:p.length>0?p:"*",required:!0});let r=e.args??{},t=e.writes?.length===1,d=(c,i)=>i&&c.type===i.type&&c.min===void 0&&c.max===void 0&&c.step===void 0?{...c,...i.min===void 0?{}:{min:i.min},...i.max===void 0?{}:{max:i.max},...i.step===void 0?{}:{step:i.step}}:c,w=(c,i)=>i&&c.type===i.type&&c.format===void 0&&c.unit===void 0?{...d(c,i),...i.format?{format:i.format}:{},...i.unit?{unit:i.unit}:{}}:d(c,i),f=(c,i,A)=>{if(c===ge||Dn.has(c)||u.has(c)||l.has(c))return;let y=r[c]?w(r[c],A):void 0;l.set(c,y?{field:y,optional:!y.required,required:!!y.required}:i())};for(let c of o)if("create"in c){let i=s.kinds[c.create];for(let[A,y]of Object.entries(c.set??{})){let O=F(y),S=i?.fields[A];if(O&&S){let b=!!S.required&&S.default===void 0;f(O,()=>({field:S,optional:!b,required:b}),S)}}c.as&&u.set(c.as,c.create)}else if("connect"in c||"sever"in c){let i=a.get("connect"in c?c.connect:c.sever);for(let[A,y]of[["from",c.from],["to",c.to]]){let O=F(y);if(!O)continue;let S=A==="to"?i?.to??"*":i?.from??"*";S!=="*"&&!z.has(O)&&z.set(O,S),f(O,()=>({ref:S,required:!0}))}}else if("set"in c){let i=F(c.target??"$subject"),A=i==="subject"?p[0]:u.get(i??"")??z.get(i??"")?.[0];i&&i!=="subject"&&!u.has(i)&&f(i,()=>({ref:"*",required:!0}));for(let[y,O]of Object.entries(c.set)){let S=F(O);if(!S)continue;let b=A?s.kinds[A]?.fields[y]:void 0;f(S,()=>b?{field:b,optional:!t,required:t}:{any:!0,required:!1},b)}}else if("remove"in c){let i=F(c.remove);i&&f(i,()=>({ref:"*",required:!0}))}for(let[c,i]of Object.entries(r))l.has(c)||l.set(c,{field:i,optional:!i.required,required:!!i.required});return l}function yt(e,o={}){let s=Kn(e);if(!s.document||me(s.findings))return{ok:!1,findings:s.findings};let a=s.document,l=[...s.findings];o.previous&&l.push(...Gn(a,o.previous));let p=Pn(a,l);return me(p.findings)?{ok:!1,findings:p.findings}:Ne(p,o)}function ce(e,o){return e.map(s=>{let a=!s.format&&s.expr?.t==="ident"?o?.[s.expr.name]?.format:void 0;return a==="money"||a==="percent"?{...s,format:a}:s})}function Pn(e,o){let s=an(e),a={};for(let[r,t]of Object.entries(e.kinds)){let d=Ce(t),w=t.label??(d?`{${d}}`:void 0),f=ne(t),c=f?sn(e,r,[...f]):[];a[r]={...w?{label:ce(Y(w),t.fields)}:{},...t.describe?{describe:ce(Y(t.describe),t.fields)}:{},...f?{computed:[...f]}:{},...c.length>0?{durations:c}:{}}}let l={};for(let[r,t]of Object.entries(e.acts??{})){let d=cn(t,e),w=Tn(t,d,e,s),f=t.destructive??d.some(m=>"remove"in m||"sever"in m||"replace"in m),c=[...new Set(d.flatMap(m=>"create"in m?[m.create]:[]))],i=[...new Set(d.flatMap(m=>"connect"in m?[m.connect]:[]))],A=[...new Set(d.flatMap(m=>"sever"in m?[m.sever]:"replace"in m?m.replace:[]))],y=[...new Set(d.flatMap(m=>"set"in m&&!("create"in m)&&F(m.target??"$subject")==="subject"?Object.keys(m.set):[]))],O=new Map;for(let m of d){if(!("connect"in m)&&!("sever"in m))continue;let x=s.get("connect"in m?m.connect:m.sever);for(let[M,dn]of[["from",m.from],["to",m.to]]){let oe=F(dn),pe=M==="to"?x?.to:x?.from;oe&&oe!=="subject"&&pe&&pe!=="*"&&O.set(oe,[...new Set([...O.get(oe)??[],...pe])])}}let S={};for(let m of d){if(!("set"in m)||"create"in m)continue;let x=F(m.target??"$subject");for(let M of x&&x!=="subject"&&O.get(x)||[])S[M]=[...new Set([...S[M]??[],...Object.keys(m.set)])]}let b={};for(let m of d)if(!(!("set"in m)||"create"in m||F(m.target??"$subject")!=="subject"))for(let[x,M]of Object.entries(m.set??{}))typeof M=="string"&&F(M)===void 0||typeof M=="number"||typeof M=="boolean"?b[x]=typeof M=="string"&&M.startsWith("$$")?M.slice(1):M:delete b[x];let le=c.length===0&&d.every(m=>!("set"in m)||!m.set||Object.values(m.set).every(x=>!(x&&typeof x=="object"&&!Array.isArray(x)&&"expr"in x))),_=new Map;for(let m of d)if(!(!("set"in m)||!m.set))for(let x of Object.values(m.set))x&&typeof x=="object"&&!Array.isArray(x)&&"expr"in x&&_.set(x.expr,Z(x.expr));l[r]={title:t.title??r.replace(/-/g," "),effects:d,args:[...w],...t.allowedWhen?{guard:Z(t.allowedWhen)}:{},...t.refusal?{refusal:ce(Y(t.refusal),e.kinds[[t.on??[]].flat()[0]??""]?.fields)}:{},exprs:[..._],destructive:f,idempotent:le,creates:c,connects:i,severs:A,writes:y,writesOther:S,sets:b}}let p={};for(let[r,t]of Object.entries(e.rules??{}))p[r]={title:t.title??r.replace(/-/g," "),require:Z(t.require),...t.when?{when:Z(t.when)}:{},...t.says?{says:ce(Y(t.says),e.kinds[t.over]?.fields)}:{}};let u=Pe(e,o),z=Ie(e),$=qe(e);return{format:Ge,document:e,findings:o,kinds:a,...e.computed?{facts:[...ne(e)??[]]}:{},edges:[...s].map(([r,{from:t,to:d,cardinality:w}])=>[r,{from:t,to:d,cardinality:w}]),acts:l,rules:p,brand:u,...Object.keys(z).length>0?{viewSpecs:z}:{},...$?{home:$}:{}}}function bt(e,o,s){let a=/^defineNode\("([^"]+)"\)/.exec(o)?.[1],l=a?s.kinds[a]:void 0;if(!a||!l)return e;let p=Object.keys(l.fields).filter(u=>u!=="label").slice(0,3);return{...e,path:`kinds.${a}.glance`,fix:`Say which: "glance": [${p.map(u=>`"${u}"`).join(", ")}] on kinds.${a} \u2014 the facts a person compares one by, at a glance.`}}function Gn(e,o){let s=[],a=new Set(Object.values(o.kinds).flatMap(l=>Object.keys(l.edges??{})));for(let[l,p]of Object.entries(e.kinds)){let u=p.renamedFrom;u&&!o.kinds[u]&&s.push(g("renamed-from-nothing",`kinds.${l}.renamedFrom`,`${l} says it was ${u}, and the previous version has no kind called ${u}`,"name the kind it was, or drop renamedFrom"));let z=o.kinds[u??l];for(let[$,r]of Object.entries(p.fields)){let t=r.renamedFrom;t&&!z?.fields[t]&&s.push(g("renamed-from-nothing",`kinds.${l}.fields.${$}.renamedFrom`,`${$} says it was ${t}, and the previous ${u??l} has no field called ${t}`,"name the field it was, or drop renamedFrom"))}for(let[$,r]of Object.entries(p.edges??{})){let t=r.renamedFrom;t&&!a.has(t)&&s.push(g("renamed-from-nothing",`kinds.${l}.edges.${$}.renamedFrom`,`${$} says it was ${t}, and the previous version has no relation called ${t}`,"name the relation it was, or drop renamedFrom"))}}return s}export{Kn as a,ht as b,cn as c,yt as d,bt as e};
1
+ import{a as Se,b as Pe,c as Ge,d as ge,e as F,f as Ce,h as Ne}from"./chunk.VDAMCTNL.js";import{h as Ie,i as qe,j as Ve}from"./chunk.UHI3D7JC.js";import{a as se,b as re,c as Z,d as _e,e as Y,g as ne,h as Be}from"./chunk.ZHLQWMV5.js";import{c as Me,h as g,i as Te,j as me}from"./chunk.TNESS3LQ.js";import{Fa as De,Ga as ee,Ha as fe,Kb as ue,Lb as Ke,b as L,c as q,e as xe,f as Ee,g as C,h as j,k as T,l as X,m as G,n as Ae,o as V,p as K,r as k,s as Q,t as E,u as R,v as I,w as P,x as n,y as U,ya as Fe,z as Re}from"./chunk.V5MYKNL7.js";var ln=e=>Object.entries(e).map(([o,s])=>[o,Object.keys(ee(s?.edges))]),ze=(e,o)=>Ke(e,ln(o));var ye="graview-document",be=1,ke=256*1024,he=64*1024,$e=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,we=/^[a-z][A-Za-z0-9]*$/,pn=new Set(["id","kind"]),fn=e=>e in Object.prototype,Ze=U(e=>!fn(e),"every object already has this name \u2014 choose another"),Ye=(e,o)=>[...e===void 0?[]:[Ee(e)],...o===void 0?[]:[xe(o)]],h=(e,o)=>j().check(...Ye(e,o)),v=(e,o,s)=>K(e).check(...Ye(o,s)),D=e=>j().check(C($e,`${e} names are kebab-case, lower-case words joined by hyphens like "tool-note" (field and relation names are camelCase, like "supersededBy")`)),un=/^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|[a-z][A-Za-z0-9]*)$/,W=j().check(C(un,'relation names are one camelCase word, like "supersededBy" (kind names are kebab-case, like "tool-note")'),Ze),N=j().check(C(we,'field names are one word or camelCase, like "dueDate", so rules say them bare (kind names are kebab-case, like "tool-note")'),U(e=>!pn.has(e),'a field cannot be called "id" or "kind" \u2014 the framework keeps those; try "type" or "category"'),Ze),B=h(1,500),H=h(1,2e3),ae=h(1,300),mn=["string","text","number","integer","boolean","date","datetime","enum","list","url","email","image","video","file","app-link","phone","place","duration"],Je=k({type:I(mn),required:n(G()),description:n(B),label:n(h(1,60)),options:n(v(h(1,80),1,100)),of:n(I(["string","number","date","image","video","file"])),default:n(V()),unit:n(h(void 0,12)),format:n(I(["money","percent","duration","markdown"])),min:n(T()),max:n(T()),step:n(T()),renamedFrom:n(j().check(C(we))),repeats:n(G())}).check(Re((e,o)=>{e.type==="enum"&&!e.options&&o.addIssue({code:"custom",message:'an enum field lists its "options"',path:["options"]}),e.type!=="enum"&&e.options&&o.addIssue({code:"custom",message:'"options" belongs only on an enum field',path:["options"]}),e.type!=="list"&&e.of&&o.addIssue({code:"custom",message:'"of" belongs only on a list field',path:["of"]}),e.repeats&&e.type!=="date"&&e.type!=="datetime"&&o.addIssue({code:"custom",message:'"repeats" belongs only on a date or datetime field',path:["repeats"]})})),gn=j().check(C(new RegExp(`${$e.source}|${Fe.source}`),'a relation goes to a kind of this document, like "house", or of another app, like "@nick/house/house"')),zn=k({to:E([v(gn,1),P("*")]),cardinality:n(I(["one","many"])),description:n(B),inverse:n(h(1,80)),appendOnly:n(G()),renamedFrom:n(j()),tidying:n(P("never"))}),He=E([H,k({expr:H,label:n(h(1,60)),description:n(B)})]),hn=k({noun:n(h(1,40)),plural:n(h(1,40)),description:n(B),fields:R(N,Je).check(U(e=>Object.keys(e).length>0,"a kind has at least one field")),label:n(ae),describe:n(ae),lifecycle:n(k({field:N,retired:v(E([j(),T(),G()]),1)})),figure:n(h(void 0,2e4)),glance:n(v(N,1,20)),page:n(k({fields:n(v(N,1,40)),groups:n(v(k({title:h(1,60),fields:v(N,1,40)}),1,12))})),edges:n(R(W,zn)),computed:n(R(j(),He).check(U(e=>Object.keys(e).length<=20,"a kind works out at most 20 computed fields"))),fieldRoles:n(R(j(),j())),renamedFrom:n(j().check(C($e))),people:n(G()),archives:n(P(!1)),tidying:n(I(["never","no-links"]))}),te=E([j(),T(),G(),Ae(),K(V()),k({expr:H})]),J=j().check(C(/^\$[A-Za-z][A-Za-z0-9]*$/,'a reference is "$" and a name, like "$subject" or "$new"')),yn=E([k({create:D("kind"),as:n(j().check(C(we))),set:n(R(N,te))}),k({set:R(N,te),target:n(J)}),k({connect:W,from:J,to:J}),k({sever:W,from:J,to:J}),k({remove:J})]),bn=k({title:n(h(1,80)),description:n(B),fromTheOtherEnd:n(h(1,80)),on:n(E([D("kind"),v(D("kind"),1)])),creates:n(D("kind")),sets:n(R(N,te)),writes:n(v(N,1)),connects:n(W),severs:n(W),setsOther:n(R(N,te)),replaces:n(E([P(!0),v(W,1,10)])),removes:n(P(!0)),args:n(R(N,Je)),effects:n(v(yn,1,20)),allowedWhen:n(H),refusal:n(ae),destructive:n(G())}),kn=k({act:D("act"),label:n(h(1,80)),args:n(R(j(),te))}),$n=k({title:n(h(1,120)),description:n(B),over:E([P("graph"),D("kind")]),when:n(H),require:H,says:n(ae),repairs:n(v(kn,void 0,10))}),wn=k({roles:E([v(D("role"),1),P("*")]),mutations:E([v(D("act"),1),P("*")]),kinds:n(E([K(D("kind")),P("*")])),describe:n(B),self:n(G()),ownEnd:n(G())}),Le=n(v(D("field"),1)),jn=k({roles:E([v(D("role"),1),P("*")]),kinds:v(D("kind"),1),own:n(G()),via:n(W),fields:Le,hide:Le}),On=k({grants:K(wn),sees:n(K(jn))}),vn=k({accent:n(j().check(C(/^#[0-9a-fA-F]{6}$/,'an accent is a color like "#c2577a"'))),name:n(h(1,60)),currency:n(j().check(C(/^[A-Z]{3}$/,'a currency is its three-letter code, like "USD" or "EUR"'))),locale:n(h(2,35)),timeZone:n(h(1,64)),logo:n(E([h(1,he),k({src:h(1,he),alt:n(h(1,120))})])),favicon:n(E([h(1,he),k({emoji:j()})])),typography:n(k({display:n(h(1,200)),body:n(h(1,200)),mono:n(h(1,200))})),shape:n(k({radius:n(T().check(q(0),L(32))),density:n(T().check(q(.75),L(1.5)))})),accents:n(R(j(),T().check(q(0),L(360)))),scheme:n(I(["light","dark","auto"]))}),ie=R(j(),V()),Ue=E([h(1,120),k({by:h(1,120),direction:n(I(["asc","desc"]))})]),We=T().check(X(),q(1),L(9999)),Sn=Q({create:n(G()),options:n(Q({sort:n(Ue),columnSort:n(Ue),search:n(v(h(1,120),void 0,40)),filters:n(v(h(1,120),void 0,40)),horizon:n(E([T().check(X(),q(1),L(200)),Q({years:T().check(X(),q(1),L(200)),title:h(1,80),from:n(We),to:n(We)})]))}))}),xn=k({card:n(K(V())),row:n(K(V())),page:n(K(V()))}),En=()=>{let e=n(I(["asc","desc"]));return E([h(1,120),k({by:h(1,120),direction:e,then:n(E([h(1,120),k({by:h(1,120),direction:e})]))})])},An=()=>E([h(1,120),k({by:h(1,120),order:n(v(h(1,80),void 0,40)),closed:n(v(h(1,80),void 0,40))})]),Rn=Q({order:n(K(j())),hide:n(K(j())),first:n(j()),primary:n(v(h(1,80),void 0,40)),scene:n(h(1,40)),pages:n(h(1,40)),lists:n(R(j(),k({filters:n(v(h(1,120),void 0,40)),sort:n(En()),group:n(An())})))}),Xe=k({$schema:n(j()),format:P(ye),formatVersion:P(be),name:h(1,80),description:n(B),version:n(T().check(X(),q(1))),kinds:R(D("kind"),hn).check(U(e=>Object.keys(e).length>0,"a document declares at least one kind"),U(e=>Object.keys(e).length<=40,"a document declares at most 40 kinds")),computed:n(R(j(),He)),acts:n(R(D("act"),bn)),rules:n(R(D("rule"),$n)),roles:n(K(D("role"))),policy:n(On),modules:n(ie),lenses:n(K(Sn)),pages:n(Rn),views:n(R(j(),E([xn,K(V())]))),brand:n(vn),settings:n(K(ie)),migrations:n(K(ie)),connections:n(R(D("connection"),ie))});var Fn={};function Qe(e,o=Fn,s=be){let{document:a,respelled:l}=Se(e),p=l.length>0?{respelled:l}:{};if(!a||typeof a!="object"||Array.isArray(a))return{document:a};let u=a;if(u.format!==ye||typeof u.formatVersion!="number"||u.formatVersion>=s)return{document:a,...p};let z=u.formatVersion,$=structuredClone(u);for(let r=z;r<s;r++){let t=o[r];if(!t)throw new Error(`there is no upgrade from format ${r} to ${r+1}`);$={...t($),formatVersion:r+1}}return{document:$,from:z,...p}}function en(e,o,s){let a=Object.keys(e).filter(z=>e[z].edges?.[o]!==void 0);if(a.length===0)return;let l=a.map(z=>e[z].edges[o].to),p=l.some(z=>z==="*")?"*":[...new Set(l.flatMap(z=>z))];if(s.length===0||s.some(z=>a.includes(z)))return{reversed:!1,kinds:p};let u=a.filter(z=>{let $=e[z].edges[o].to;return $==="*"||s.every(r=>$.includes(r))});return u.length>0?{reversed:!0,kinds:u}:{reversed:!1,kinds:p}}var on=(e,o)=>{let s=e?.fields[o];return s!==void 0&&(s.type==="duration"||(s.type==="number"||s.type==="integer")&&s.format==="duration")};function nn(e,o,s,a){if(a==="out"){let l=e[o]?.edges?.[s]?.to;return l===void 0?[]:l==="*"?Object.keys(e):l}return Object.entries(e).filter(([,l])=>{let p=l.edges?.[s]?.to;return p!==void 0&&(p==="*"||p.includes(o))}).map(([l])=>l)}function je(e,o,s){if(s.t==="ident")return e[o]?.edges?.[s.name]?nn(e,o,s.name,"out"):void 0;if(s.t==="where")return je(e,o,s.set);if(s.t==="call"&&(s.fn==="out"||s.fn==="in")&&s.args[0]?.t==="lit"&&typeof s.args[0].value=="string")return nn(e,o,s.args[0].value,s.fn)}var tn=(e,o,s)=>{let a=o.filter(l=>e[l]?.fields[s]!==void 0);return a.length>0&&a.every(l=>on(e[l],s))};function sn(e,o,s){let a=e.kinds,l=a[o],p=new Map(s),u=new Map,z=(r,t)=>{if(t>8)return!1;switch(r.t){case"ident":return on(l,r.name)||$(r.name,t+1);case"member":{let d=je(a,o,r.object);return d!==void 0&&tn(a,d,r.name)}case"call":{if(r.fn!=="sum"&&r.fn!=="min"&&r.fn!=="max")return!1;let[d,w]=r.args,f=d&&je(a,o,d);return f!==void 0&&w?.t==="ident"&&tn(a,f,w.name)}case"binary":return(r.op==="+"||r.op==="-")&&z(r.left,t)&&z(r.right,t);case"unary":return r.op==="-"&&z(r.operand,t);default:return!1}},$=(r,t)=>{if(l?.computed?.[r]===void 0)return!1;if(u.has(r))return u.get(r);u.set(r,!1);let d=p.get(r),w=d!==void 0&&z(d,t);return u.set(r,w),w};return s.map(([r])=>r).filter(r=>$(r,0))}function rn(e,o,s=`kinds.${e}.page`){let a=o.page;if(!a)return[];let l=[],p=[...Object.keys(o.fields),...Object.keys(o.computed??{})],u=new Set,z=(r,t)=>{p.includes(r)?u.has(r)&&l.push(g("page-field-twice",t,`"${r}" is on ${e}'s page twice; name each field once`)):l.push(g("page-field",t,`${e}'s page is to show "${r}", and ${e} has no field or computed field called that`,`use one of: ${p.join(", ")}`)),u.add(r)};(a.fields??[]).forEach((r,t)=>z(r,`${s}.fields.${t}`));let $=new Set;return(a.groups??[]).forEach((r,t)=>{let d=r.title.trim().toLowerCase();$.has(d)&&l.push(g("page-group-twice",`${s}.groups.${t}.title`,`${e}'s page has two groups called "${r.title}"; give each its own title`)),$.add(d),r.fields.forEach((w,f)=>z(w,`${s}.groups.${t}.fields.${f}`))}),l}var Dn=new Set(["subject","now","today","me"]);function Kn(e){if((typeof e=="string"?e:JSON.stringify(e??null)).length>ke)return{findings:[g("too-large","",`a document may be at most ${ke/1024} KB`)]};if(typeof e=="string")try{e=JSON.parse(e)}catch(a){return{findings:[g("not-json","",`this is not JSON: ${a.message}`)]}}try{e=Qe(e).document}catch(a){return{findings:[g("format","formatVersion",a.message)]}}let o=Xe.safeParse(e);if(!o.success)return{findings:o.error.issues.map(a=>{let l=a.path.map(String).join(".");if(a.code==="unrecognized_keys")return g("unknown-key",l,`${a.keys.map(p=>`"${p}"`).join(", ")} ${a.keys.length===1?"is":"are"} not part of a Graview document here`,"check the spelling against docs/declaration-document.md");if(a.code==="invalid_union"&&/\.effects\.\d+$/.test(l))return g("effect-shape",l,"this effect is not one Graview knows",'an effect is one of {"create": kind, "as"?: name, "set"?: {field: value}}, {"set": {field: value, \u2026}, "target"?: "$ref"}, {"connect"|"sever": relation, "from": "$ref", "to": "$ref"}, {"remove": "$ref"}');if(a.code==="invalid_key"){let p=a.issues?.[0]?.message;return g("shape",l,`the name "${String(a.path.at(-1))}" is not allowed here${p?`: ${p}`:""}`)}return g("shape",l,a.message)})};let s=o.data;return{document:s,findings:Mn(s)}}var de=e=>[e??[]].flat();function an(e){let o=new Map;for(let[s,a]of Object.entries(e.kinds))for(let[l,p]of Object.entries(ee(a.edges))){let u=o.get(l);o.set(l,{name:l,from:[...u?.from??[],s],to:p.to==="*"||u?.to==="*"?"*":[...new Set([...u?.to??[],...p.to])],cardinality:p.cardinality??"many"})}return o}function ht(e){let o=new Map;for(let[a,l]of Object.entries(e.kinds)){let p=ne(l),u=fe(l.edges);o.set(a,{fields:new Set([...Object.keys(l.fields),...u.keys()]),edges:new Map(Object.entries(ee(l.edges)).map(([z,$])=>[z,$.cardinality??"many"])),...p?{computed:p}:{},...u.size>0?{linked:u}:{}})}let s=ne(e);return s&&o.set(Me,{computed:s}),o}function cn(e,o){let s=[],a=de(e.on),l=(p,u)=>{let z=en(o.kinds,p,a)?.reversed===!0,[$,r]=z?["$to","$subject"]:["$subject","$to"];return u==="connect"?{connect:p,from:$,to:r}:{sever:p,from:$,to:r}};if(e.creates){let p=o.kinds[e.creates],u={};for(let z of Object.keys(p?.fields??{}))u[z]=`$${z}`;for(let z of e.effects??[])"set"in z&&!("create"in z)&&F(z.target)==="new"&&Object.assign(u,z.set);s.push({create:e.creates,as:"new",set:u})}return e.sets&&s.push({set:e.sets}),e.writes&&!(e.creates&&e.on===void 0)&&s.push({set:Object.fromEntries(e.writes.map(p=>[p,`$${p}`]))}),e.connects&&(e.replaces&&s.push({replace:e.replaces===!0?[e.connects]:[...e.replaces],keep:e.connects}),s.push(l(e.connects,"connect"))),e.severs&&s.push(l(e.severs,"sever")),e.setsOther&&(e.connects||e.severs)&&s.push({set:e.setsOther,target:"$to"}),e.removes&&s.push({remove:"$subject"}),e.effects&&s.push(...e.effects.filter(p=>!(e.creates&&"set"in p&&!("create"in p)&&F(p.target)==="new"))),s}function Oe(e,o,s){try{let a=Z(e),l=se(a);for(let p of l.unknownFunctions)s.push(g("unknown-function",o,`"${p}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));return a}catch(a){if(a instanceof re){s.push(g("expression",o,a.sentence+` (at character ${a.at+1})`));return}throw a}}function ve(e,o,s){try{return Y(e)}catch(a){if(a instanceof _e||a instanceof re){s.push(g("template",o,(a instanceof re,a.sentence)));return}throw a}}function Mn(e){let o=[],s=new Set(Object.keys(e.kinds)),a=an(e),l=e.acts??{},p=new Set(e.roles??[]),u=(r,t)=>fe(e.kinds[r]?.edges).has(t),z=r=>Object.keys(e.kinds).some(t=>u(t,r));for(let[r,t]of Object.entries(e.kinds)){let d=`kinds.${r}`;for(let[f,c]of Object.entries(t.edges??{})){if(!De(c)&&c.to!=="*")for(let i of c.to)s.has(i)||o.push(g("edge-target",`${d}.edges.${f}.to`,`"${i}" is not a kind this document declares`));t.fields[f]&&o.push(g("edge-field-clash",`${d}.edges.${f}`,`"${f}" is both a field and a relation of ${r}`,"rename one of them"))}t.lifecycle&&!t.fields[t.lifecycle.field]&&o.push(g("lifecycle-field",`${d}.lifecycle.field`,`${r} has no field "${t.lifecycle.field}"`));let w=f=>t.computed!==void 0&&Object.hasOwn(t.computed,f);for(let f of t.glance??[])!t.fields[f]&&!w(f)&&o.push(g("glance-field",`${d}.glance`,`a glance at ${r} is to say "${f}", and ${r} has no field or computed field called that`,`use one of: ${[...Object.keys(t.fields),...Object.keys(t.computed??{})].join(", ")}`));o.push(...rn(r,t));for(let f of["label","describe"]){let c=t[f];if(!c)continue;let i=ve(c,`${d}.${f}`,o);for(let A of i??[])if(A.expr){for(let y of se(A.expr).names)if(!t.fields[y]){if(w(y)){Be(t,y)||o.push(g("template-field",`${d}.${f}`,`${r}'s ${y} is worked out from beyond the record, and a ${f} is said with no graph to read`,`show it in a view instead, or name a computed field worked out from ${r}'s own fields`));continue}o.push(g("template-field",`${d}.${f}`,`${r} has no field "${y}" for its ${f} to show`,f==="label"?"a label can only show the record's own fields and what they work out":void 0))}}}for(let[f,c]of Object.entries(t.fields)){c.default!==void 0&&c.type==="enum"&&!c.options?.includes(String(c.default))&&o.push(g("default-option",`${d}.fields.${f}.default`,`"${String(c.default)}" is not one of ${f}'s options`));let i=`${f}Repeat`;c.repeats&&(t.fields[i]||t.edges?.[i]||t.computed?.[i])&&o.push(g("repeat-clash",`${d}.fields.${f}.repeats`,`${r} already has "${i}", where how ${f} repeats is kept`))}}for(let[r,t]of Object.entries(l)){let d=`acts.${r}`;for(let i of de(t.on))s.has(i)||o.push(g("act-kind",`${d}.on`,`"${i}" is not a kind this document declares`));let w=de(t.on),f=cn(t,e);if(t.creates&&t.on===void 0&&t.writes&&s.has(t.creates)){for(let i of t.writes)if(!e.kinds[t.creates].fields[i])if(e.kinds[t.creates].computed?.[i]!==void 0)o.push(g("computed-written",`${d}.writes`,`${t.creates}'s ${i} is worked out, not written: no act can set it`,"write the stored fields it is worked out from"));else{if(u(t.creates,i))continue;o.push(g("act-field",`${d}.writes`,`${t.creates} has no field "${i}"`))}}f.length===0&&o.push(g("act-empty",d,`"${r}" does nothing`,"give it effects or a shorthand such as sets or creates"));let c=new Map;f.forEach((i,A)=>{let y=f.length-(t.effects?.length??0),O=t.effects&&A>=y?`${d}.effects.${A-y}`:d;if("create"in i){if(!s.has(i.create))o.push(g("act-kind",`${O}.create`,`"${i.create}" is not a kind this document declares`));else for(let b of Object.keys(i.set??{}))e.kinds[i.create].fields[b]||(e.kinds[i.create].computed?.[b]!==void 0?o.push(g("computed-written",`${O}.set.${b}`,`${i.create}'s ${b} is worked out, not written: no act can set it`,"set the stored fields it is worked out from")):o.push(g("act-field",`${O}.set.${b}`,`${i.create} has no field "${b}"`)));i.as&&c.set(i.as,i.create)}else if("connect"in i||"sever"in i){let b="connect"in i?i.connect:i.sever;!a.has(b)&&!z(b)&&o.push(g("act-edge",`${O}.${"connect"in i?"connect":"sever"}`,`"${b}" is not a relation any kind declares`)),F(i.from)==="subject"&&w.length===0&&o.push(g("act-subject",`${d}.on`,`"${r}" acts on "$subject" but does not say which kinds it is "on"`))}else if("set"in i){let b=F(i.target??"$subject"),le=b==="subject"?w:c.has(b??"")?[c.get(b)]:[];b==="subject"&&w.length===0&&o.push(g("act-subject",`${d}.on`,`"${r}" changes "$subject" but does not say which kinds it is "on"`));for(let _ of Object.keys(i.set))for(let m of le)if(!(!s.has(m)||e.kinds[m].fields[_]))if(e.kinds[m].computed?.[_]!==void 0)o.push(g("computed-written",`${O}.set.${_}`,`${m}'s ${_} is worked out, not written: no act can set it`,"set the stored fields it is worked out from"));else{if(u(m,_))continue;o.push(g("act-field",`${O}.set.${_}`,`${m} has no field "${_}"`))}}else"remove"in i&&F(i.remove)==="subject"&&w.length===0&&o.push(g("act-subject",`${d}.on`,`"${r}" removes "$subject" but does not say which kinds it is "on"`));("set"in i&&i.set?Object.values(i.set):[]).forEach(b=>{b&&typeof b=="object"&&!Array.isArray(b)&&"expr"in b&&Oe(b.expr,`${O}.set`,o)})}),t.allowedWhen&&Oe(t.allowedWhen,`${d}.allowedWhen`,o),t.refusal&&ve(t.refusal,`${d}.refusal`,o)}for(let[r,t]of Object.entries(e.rules??{})){let d=`rules.${r}`;t.over!=="graph"&&!s.has(t.over)&&o.push(g("rule-kind",`${d}.over`,`"${t.over}" is not a kind this document declares`));let w=t.over==="graph"?void 0:e.kinds[t.over];for(let f of["when","require"]){let c=t[f];if(!c)continue;let i=Oe(c,`${d}.${f}`,o);if(!i)continue;let A=se(i);for(let y of A.names)if(t.over==="graph")o.push(g("rule-name",`${d}.${f}`,`"${y}" means nothing in a rule over the whole graph`,`name a kind in "over", or use all('kind')`));else if(w&&!w.fields[y]&&!w.edges?.[y]&&w.computed?.[y]===void 0){let O=Object.keys(w.edges??{}).find(S=>S.includes("-")&&S.split("-").includes(y));o.push(g("rule-name",`${d}.${f}`,`${t.over} has no field or relation called "${y}"`,O?`"${O}" reads as a subtraction in a rule; rename the relation to one camelCase word, like "${O.replace(/-([a-z0-9])/g,(S,b)=>b.toUpperCase())}"`:void 0))}for(let y of A.edges)!a.has(y)&&!z(y)&&o.push(g("rule-edge",`${d}.${f}`,`"${y}" is not a relation any kind declares`));for(let y of A.sweeps)s.has(y)?t.over!=="graph"&&o.push(Te("rule-cost",`${d}.${f}`,`this rule looks at every ${y} for every ${t.over}, which grows slowly as the app grows`,"walk a relation with out()/in() instead of all() where you can")):o.push(g("rule-kind",`${d}.${f}`,`"${y}" is not a kind this document declares`))}t.says&&ve(t.says,`${d}.says`,o),(t.repairs??[]).forEach((f,c)=>{!l[f.act]&&!ue(f.act)&&!ze(f.act,e.kinds)&&o.push(g("repair-act",`${d}.repairs.${c}.act`,`"${f.act}" is not an act this document declares`))})}let $=e.policy;return $&&($.grants.forEach((r,t)=>{if(r.roles!=="*"&&p.size>0)for(let d of r.roles)p.has(d)||o.push(g("grant-role",`policy.grants.${t}.roles`,`"${d}" is not one of the document's roles`));if(r.mutations!=="*")for(let d of r.mutations)!l[d]&&!ue(d)&&!ze(d,e.kinds)&&o.push(g("grant-act",`policy.grants.${t}.mutations`,`"${d}" is not an act this document declares`))}),($.sees??[]).forEach((r,t)=>{for(let d of r.kinds)s.has(d)||o.push(g("sight-kind",`policy.sees.${t}.kinds`,`"${d}" is not a kind this document declares`));if(r.roles!=="*"&&p.size>0)for(let d of r.roles)p.has(d)||o.push(g("sight-role",`policy.sees.${t}.roles`,`"${d}" is not one of the document's roles`))})),o.push(...Ve(e)),o}function Tn(e,o,s,a){let l=new Map,p=de(e.on),u=new Map,z=new Map;(p.length>0||o.some(c=>"remove"in c&&F(c.remove)==="subject"||"from"in c&&(F(c.from)==="subject"||F(c.to)==="subject")||"set"in c&&!("create"in c)&&F(c.target??"$subject")==="subject"))&&l.set(ge,{ref:p.length>0?p:"*",required:!0});let r=e.args??{},t=e.writes?.length===1,d=(c,i)=>i&&c.type===i.type&&c.min===void 0&&c.max===void 0&&c.step===void 0?{...c,...i.min===void 0?{}:{min:i.min},...i.max===void 0?{}:{max:i.max},...i.step===void 0?{}:{step:i.step}}:c,w=(c,i)=>i&&c.type===i.type&&c.format===void 0&&c.unit===void 0?{...d(c,i),...i.format?{format:i.format}:{},...i.unit?{unit:i.unit}:{}}:d(c,i),f=(c,i,A)=>{if(c===ge||Dn.has(c)||u.has(c)||l.has(c))return;let y=r[c]?w(r[c],A):void 0;l.set(c,y?{field:y,optional:!y.required,required:!!y.required}:i())};for(let c of o)if("create"in c){let i=s.kinds[c.create];for(let[A,y]of Object.entries(c.set??{})){let O=F(y),S=i?.fields[A];if(O&&S){let b=!!S.required&&S.default===void 0;f(O,()=>({field:S,optional:!b,required:b}),S)}}c.as&&u.set(c.as,c.create)}else if("connect"in c||"sever"in c){let i=a.get("connect"in c?c.connect:c.sever);for(let[A,y]of[["from",c.from],["to",c.to]]){let O=F(y);if(!O)continue;let S=A==="to"?i?.to??"*":i?.from??"*";S!=="*"&&!z.has(O)&&z.set(O,S),f(O,()=>({ref:S,required:!0}))}}else if("set"in c){let i=F(c.target??"$subject"),A=i==="subject"?p[0]:u.get(i??"")??z.get(i??"")?.[0];i&&i!=="subject"&&!u.has(i)&&f(i,()=>({ref:"*",required:!0}));for(let[y,O]of Object.entries(c.set)){let S=F(O);if(!S)continue;let b=A?s.kinds[A]?.fields[y]:void 0;f(S,()=>b?{field:b,optional:!t,required:t}:{any:!0,required:!1},b)}}else if("remove"in c){let i=F(c.remove);i&&f(i,()=>({ref:"*",required:!0}))}for(let[c,i]of Object.entries(r))l.has(c)||l.set(c,{field:i,optional:!i.required,required:!!i.required});return l}function yt(e,o={}){let s=Kn(e);if(!s.document||me(s.findings))return{ok:!1,findings:s.findings};let a=s.document,l=[...s.findings];o.previous&&l.push(...Gn(a,o.previous));let p=Pn(a,l);return me(p.findings)?{ok:!1,findings:p.findings}:Ne(p,o)}function ce(e,o){return e.map(s=>{let a=!s.format&&s.expr?.t==="ident"?o?.[s.expr.name]?.format:void 0;return a==="money"||a==="percent"?{...s,format:a}:s})}function Pn(e,o){let s=an(e),a={};for(let[r,t]of Object.entries(e.kinds)){let d=Ce(t),w=t.label??(d?`{${d}}`:void 0),f=ne(t),c=f?sn(e,r,[...f]):[];a[r]={...w?{label:ce(Y(w),t.fields)}:{},...t.describe?{describe:ce(Y(t.describe),t.fields)}:{},...f?{computed:[...f]}:{},...c.length>0?{durations:c}:{}}}let l={};for(let[r,t]of Object.entries(e.acts??{})){let d=cn(t,e),w=Tn(t,d,e,s),f=t.destructive??d.some(m=>"remove"in m||"sever"in m||"replace"in m),c=[...new Set(d.flatMap(m=>"create"in m?[m.create]:[]))],i=[...new Set(d.flatMap(m=>"connect"in m?[m.connect]:[]))],A=[...new Set(d.flatMap(m=>"sever"in m?[m.sever]:"replace"in m?m.replace:[]))],y=[...new Set(d.flatMap(m=>"set"in m&&!("create"in m)&&F(m.target??"$subject")==="subject"?Object.keys(m.set):[]))],O=new Map;for(let m of d){if(!("connect"in m)&&!("sever"in m))continue;let x=s.get("connect"in m?m.connect:m.sever);for(let[M,dn]of[["from",m.from],["to",m.to]]){let oe=F(dn),pe=M==="to"?x?.to:x?.from;oe&&oe!=="subject"&&pe&&pe!=="*"&&O.set(oe,[...new Set([...O.get(oe)??[],...pe])])}}let S={};for(let m of d){if(!("set"in m)||"create"in m)continue;let x=F(m.target??"$subject");for(let M of x&&x!=="subject"&&O.get(x)||[])S[M]=[...new Set([...S[M]??[],...Object.keys(m.set)])]}let b={};for(let m of d)if(!(!("set"in m)||"create"in m||F(m.target??"$subject")!=="subject"))for(let[x,M]of Object.entries(m.set??{}))typeof M=="string"&&F(M)===void 0||typeof M=="number"||typeof M=="boolean"?b[x]=typeof M=="string"&&M.startsWith("$$")?M.slice(1):M:delete b[x];let le=c.length===0&&d.every(m=>!("set"in m)||!m.set||Object.values(m.set).every(x=>!(x&&typeof x=="object"&&!Array.isArray(x)&&"expr"in x))),_=new Map;for(let m of d)if(!(!("set"in m)||!m.set))for(let x of Object.values(m.set))x&&typeof x=="object"&&!Array.isArray(x)&&"expr"in x&&_.set(x.expr,Z(x.expr));l[r]={title:t.title??r.replace(/-/g," "),effects:d,args:[...w],...t.allowedWhen?{guard:Z(t.allowedWhen)}:{},...t.refusal?{refusal:ce(Y(t.refusal),e.kinds[[t.on??[]].flat()[0]??""]?.fields)}:{},exprs:[..._],destructive:f,idempotent:le,creates:c,connects:i,severs:A,writes:y,writesOther:S,sets:b}}let p={};for(let[r,t]of Object.entries(e.rules??{}))p[r]={title:t.title??r.replace(/-/g," "),require:Z(t.require),...t.when?{when:Z(t.when)}:{},...t.says?{says:ce(Y(t.says),e.kinds[t.over]?.fields)}:{}};let u=Pe(e,o),z=Ie(e),$=qe(e);return{format:Ge,document:e,findings:o,kinds:a,...e.computed?{facts:[...ne(e)??[]]}:{},edges:[...s].map(([r,{from:t,to:d,cardinality:w}])=>[r,{from:t,to:d,cardinality:w}]),acts:l,rules:p,brand:u,...Object.keys(z).length>0?{viewSpecs:z}:{},...$?{home:$}:{}}}function bt(e,o,s){let a=/^defineNode\("([^"]+)"\)/.exec(o)?.[1],l=a?s.kinds[a]:void 0;if(!a||!l)return e;let p=Object.keys(l.fields).filter(u=>u!=="label").slice(0,3);return{...e,path:`kinds.${a}.glance`,fix:`Say which: "glance": [${p.map(u=>`"${u}"`).join(", ")}] on kinds.${a} \u2014 the facts a person compares one by, at a glance.`}}function Gn(e,o){let s=[],a=new Set(Object.values(o.kinds).flatMap(l=>Object.keys(l.edges??{})));for(let[l,p]of Object.entries(e.kinds)){let u=p.renamedFrom;u&&!o.kinds[u]&&s.push(g("renamed-from-nothing",`kinds.${l}.renamedFrom`,`${l} says it was ${u}, and the previous version has no kind called ${u}`,"name the kind it was, or drop renamedFrom"));let z=o.kinds[u??l];for(let[$,r]of Object.entries(p.fields)){let t=r.renamedFrom;t&&!z?.fields[t]&&s.push(g("renamed-from-nothing",`kinds.${l}.fields.${$}.renamedFrom`,`${$} says it was ${t}, and the previous ${u??l} has no field called ${t}`,"name the field it was, or drop renamedFrom"))}for(let[$,r]of Object.entries(p.edges??{})){let t=r.renamedFrom;t&&!a.has(t)&&s.push(g("renamed-from-nothing",`kinds.${l}.edges.${$}.renamedFrom`,`${$} says it was ${t}, and the previous version has no relation called ${t}`,"name the relation it was, or drop renamedFrom"))}}return s}export{Kn as a,ht as b,cn as c,yt as d,bt as e};
@@ -0,0 +1 @@
1
+ import{a as b,b as c,c as d,d as e,e as f}from"./chunk.242EUAPE.js";import"./chunk.VDAMCTNL.js";import"./chunk.UHI3D7JC.js";import"./chunk.ZHLQWMV5.js";import"./chunk.TNESS3LQ.js";import{tb as a}from"./chunk.V5MYKNL7.js";import"./chunk.AJZBJBMO.js";export{a as ActRefusal,e as compileDocumentWithoutCheck,d as effectsOf,f as inDocumentWords,c as kindShapes,b as readDocument};
@@ -1 +1 @@
1
- import{Ab as O,B as $,D as h,Db as M,G as E,K as N,L as S,M as W,O as R,P as I,T as p,da as D,ia as T,sa as j,ub as v}from"./chunk.5ZMENPY4.js";function z(e,n,t){let o=[...n?.creates??[],...n?.subject&&n.subject.kinds!=="*"?n.subject.kinds:[]];for(let r of o){let i=e.tryDefinition(r),u=i?.fields?.shape??{};if(!i||!(t in u))continue;let a=i.display?.format?.[t];return{label:i.display?.labels?.[t]??T(i,t),option:d=>a?a(d):D(d)}}return{label:T(void 0,t),option:r=>D(r)}}function K(e,n,t){if(t instanceof v){let o=n.find(i=>i.name===t.mutation);return`Not yet: ${t.issues.map(i=>{let u=i.path.length>0?z(e,o,String(i.path[0])).label:void 0;return u?`${u} \u2014 ${i.message.replace(/^./,a=>a.toLowerCase())}`:i.message}).join("; ")}.`}return t instanceof Error?t.message:String(t)}var x=864e5,X=/^(\d{4})-(\d{2})-(\d{2})/,g=e=>String(e).padStart(2,"0"),_=e=>new Date(e).toISOString().slice(0,10),m=e=>Date.UTC(+e.slice(0,4),+e.slice(5,7)-1,+e.slice(8,10)),b=(e,n)=>_(m(e)+n*x),C=e=>new Date(m(e)).getUTCDay();function l(e,n,t){if(!(n>=1&&n<=12&&t>=1&&t<=31))return;let o=`${String(e).padStart(4,"0")}-${g(n)}-${g(t)}`;return _(m(o))===o?o:void 0}function L(e=new Date){let n=S();return n?R(e.getTime(),n):{day:`${e.getFullYear()}-${g(e.getMonth()+1)}-${g(e.getDate())}`,minutes:e.getHours()*60+e.getMinutes()}}var w=e=>/T\d\d:\d\d(:[\d.]+)?(Z|[+-]\d\d:?\d\d)$/.test(e);function y(e){if(typeof e!="string")return;if(w(e)){let o=new Date(e);return Number.isNaN(o.getTime())?void 0:L(o)}let n=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2}))?/.exec(e);if(!n||!l(Number(n[1]),Number(n[2]),Number(n[3])))return;let t=e.slice(0,10);return n[4]===void 0?{day:t}:{day:t,minutes:Number(n[4])*60+Number(n[5])}}function F(e,n){if(!n.time)return e.day;let t=e.minutes??9*60;if(!n.instant)return`${e.day}T${g(Math.floor(t/60))}:${g(t%60)}`;let o=S(),[,r,i,u]=X.exec(e.day);return(o?new Date(I(e.day,t,o)):new Date(Number(r),Number(i)-1,Number(u),Math.floor(t/60),t%60)).toISOString().replace(/\.\d{3}Z$/,"Z")}function V(e,n=new Date){let t=W(),o=t;try{o=new Intl.DateTimeFormat(e??h,{timeZoneName:"short",timeZone:t}).formatToParts(n).find(r=>r.type==="timeZoneName")?.value??t}catch{o=t}return{zone:t,short:o}}function q(e,n,t,o){let r=y(n);if(!r)return t;let i=e===void 0?void 0:y(e),u=t===void 0?void 0:y(t),a=d=>m(d.day)+(d.minutes??0)*6e4,c=(d,s)=>{let f=a(d)+s;return{day:_(f),...o.time?{minutes:Math.round(f%x/6e4)}:{}}};return i&&u?F(c(u,a(r)-a(i)),o):u&&a(u)>=a(r)?t:o.time?F(c(r,36e5),o):t}var J=/^(start|starts|startsAt|startsOn|startAt|begins|from|opens|checkIn)$/i,Q=/^(end|ends|endsAt|endsOn|endAt|until|to|finish|finishes|closes|through|checkOut)$/i;function ee(e,n={}){let t=(n.start&&e.includes(n.start)?n.start:void 0)??e.find(r=>J.test(r)),o=(n.end&&e.includes(n.end)?n.end:void 0)??e.find(r=>r!==t&&Q.test(r));return t&&o?{start:t,end:o}:void 0}var ne=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],te=["sun","mon","tue","wed","thu","fri","sat"],B="(jan(?:uary)?|feb(?:ruary)?|mar(?:ch)?|apr(?:il)?|may|june?|july?|aug(?:ust)?|sept?(?:ember)?|oct(?:ober)?|nov(?:ember)?|dec(?:ember)?)",U="(sun(?:day)?|mon(?:day)?|tue(?:s|sday)?|wed(?:nesday)?|thu(?:r|rs|rsday)?|fri(?:day)?|sat(?:urday)?)",re=e=>ne.indexOf(e.slice(0,3))+1,Y=e=>e===void 0?void 0:e.length===2?2e3+Number(e):Number(e);function oe(e){try{let n=new Intl.DateTimeFormat(e,{month:"numeric",day:"numeric"}).formatToParts(0).map(t=>t.type);return n.indexOf("month")<n.indexOf("day")}catch{return!0}}function ie(e){let n=(r,i)=>({minutes:i,rest:`${e.slice(0,r.index)} ${e.slice(r.index+r[0].length)}`}),t=/\b(noon|midday)\b/.exec(e);if(t)return n(t,12*60);if(t=/\bmidnight\b/.exec(e),t)return n(t,0);if(t=/\b(\d{1,2})(?::(\d{2}))?\s*([ap])\.?m?\.?(?=\s|$)/.exec(e),t){let r=Number(t[1]),i=Number(t[2]??0);return r<1||r>12||i>59?{rest:e,bad:!0}:n(t,(r%12+(t[3]==="p"?12:0))*60+i)}if(t=/\b(\d{1,2}):(\d{2})\b/.exec(e),t){let r=Number(t[1]),i=Number(t[2]);return r>23||i>59?{rest:e,bad:!0}:n(t,r*60+i)}if(t=/\bat\s+(\d{1,2})\b/.exec(e),t){let r=Number(t[1]);return r>23?{rest:e,bad:!0}:n(t,(r>=1&&r<=7?r+12:r)*60)}let o=/\b(morning|afternoon|evening|tonight)\b/.exec(e);return o?{minutes:{morning:9,afternoon:15,evening:18,tonight:20}[o[1]]*60,rest:o[1]==="tonight"?`${e.slice(0,o.index)} today ${e.slice(o.index+o[0].length)}`:`${e.slice(0,o.index)} ${e.slice(o.index+o[0].length)}`}:{rest:e}}function ue(e,n,t){let o=e.replace(/\b(on|at|the|of|this)\b/g," ").replace(/\s+/g," ").trim();if(o==="")return null;if(o==="today"||o==="now")return n;if(o==="tomorrow"||o==="tmrw"||o==="tmr")return b(n,1);if(o==="yesterday")return b(n,-1);if(o==="next week")return b(n,7);let r=/^in (\d{1,3}) (day|days|week|weeks)$/.exec(o);if(r)return b(n,Number(r[1])*(r[2].startsWith("week")?7:1));if(r=new RegExp(`^(next )?${U}$`).exec(o),r){let d=(te.indexOf(r[2].slice(0,3))-C(n)+7)%7;return b(n,r[1]&&d===0?7:d)}if(r=/^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(o),r)return l(Number(r[1]),Number(r[2]),Number(r[3]));let i=o.replace(new RegExp(`^${U} `),"");r=new RegExp(`^(\\d{1,2})(?:st|nd|rd|th)? ${B}(?: (\\d{4}))?$`).exec(i);let u=r?{date:r[1],month:r[2],year:r[3]}:void 0;r=new RegExp(`^${B} (\\d{1,2})(?:st|nd|rd|th)?(?: (\\d{4}))?$`).exec(i);let a=u??(r?{date:r[2],month:r[1],year:r[3]}:void 0);if(a)return Z(n,Y(a.year),re(a.month),Number(a.date));if(r=/^(\d{1,2})[/.-](\d{1,2})(?:[/.-](\d{2}|\d{4}))?$/.exec(i),r){let[c,d]=[Number(r[1]),Number(r[2])],[s,f]=oe(t)?[c,d]:[d,c];return Z(n,Y(r[3]),s,f)}}function Z(e,n,t,o){if(n!==void 0)return l(n,t,o);let r=Number(e.slice(0,4)),i=l(r,t,o);return i===void 0?l(r+1,t,o):m(e)-m(i)>183*x?l(r+1,t,o):i}function de(e,n){let t=e.trim();if(w(t)){let a=y(t);if(a)return n.time?a:{day:a.day}}let o=e.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(o==="")return;let r=ie(o);if(r.bad)return;let i=ue(r.rest,n.today,n.locale??h);if(i===void 0||i===null&&r.minutes===void 0)return;let u=i??n.base?.day??n.today;return n.time?{day:u,minutes:r.minutes??n.base?.minutes??9*60}:{day:u}}var ae=e=>/^[A-Z]{3}$/.test(e??"");function P(e){let{format:n,unit:t,currency:o,locale:r}=e,i=ae(t),u=n==="money"||!n&&i,a=u?i?t:o:void 0;return{...u?{format:"money"}:n?{format:n}:{},...t&&!(u&&i)?{unit:t}:{},...a?{currency:a}:{},...r?{locale:r}:{}}}function Te(e){switch(e.format){case"money":return e.currency?`An amount of money in ${e.currency}: a plain number, 1250.5 for 1,250.50 ${e.currency}.`:"An amount of money, in no named currency: a plain number.";case"percent":return"A fraction said as a percent: 0.15 is 15%.";default:return e.unit?`A number of ${e.unit}.`:"A number."}}function H(e){let n=$(e)?.innerType;return n===void 0?e:H(n)}var se={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ce=e=>(e?._zod?.def?.checks??[]).map(n=>n._zod?.def).filter(n=>n!==void 0);function k(e){let n=H(e),t=$(n),o=t?.type,r=ce(n);if(o==="enum")return{type:"choice",options:Object.keys(t?.entries??{})};let i=j(n);if(i)return i==="image"?{type:"file",image:!0}:i==="video"?{type:"file",video:!0}:{type:"file"};if(o==="boolean")return{type:"boolean"};if(o==="array"){let u=k(t?.element);return u.type==="unknown"?{type:"unknown"}:{type:"several",of:u}}if(o==="number"){let u,a,c;for(let d of r){d.check==="multiple_of"&&typeof d.value=="number"?c=d.value:d.check==="number_format"&&(d.format==="safeint"||d.format==="int32"||d.format==="uint32")&&(c??=1);let s=d.check==="number_format"&&d.format?se[d.format]:void 0,f=s?s[0]:d.check==="greater_than"&&d.inclusive&&typeof d.value=="number"?d.value:void 0,A=s?s[1]:d.check==="less_than"&&d.inclusive&&typeof d.value=="number"?d.value:void 0;f!==void 0&&(u=u===void 0?f:Math.max(u,f)),A!==void 0&&(a=a===void 0?A:Math.min(a,A))}return{type:"number",...u===void 0?{}:{min:u},...a===void 0?{}:{max:a},...c===void 0?{}:{step:c},...M(n)==="duration"?{duration:!0}:{},...O(e)?{amount:P(O(e))}:{}}}if(o==="string"){if(r.some(s=>s.fn===E||s.format==="datetime")||t?.format==="datetime")return{type:"date",time:!0,instant:!0};let a=[t?.pattern,...r.map(s=>s.pattern)].filter(s=>s instanceof RegExp).map(s=>s.source);if(a.some(s=>s.includes("\\d{4}")))return a.some(s=>s.includes("\\d{2}:\\d{2}"))?{type:"date",time:!0}:{type:"date"};let c=r.some(s=>s.check==="max_length"&&typeof s.maximum=="number"&&s.maximum>500),d=M(n);return c?{type:"text",long:!0}:d==="phone"||d==="place"?{type:"text",holds:d}:{type:"text"}}return{type:"unknown"}}function fe(e,n){let t=e?.shape;return!t||!(n in t)?{type:"unknown"}:k(t[n])}function me(e){if(e===void 0||e==="web"||e.startsWith("ai:")||e.startsWith("app:"))return;if(e==="api")return"via the API";if(e==="cli")return"via the command line";let[n,...t]=e.split(":"),o=t.join(":");return(n==="mcp"||n==="view")&&o?`via ${o}`:n==="mcp"?"via an agent's tools":`via ${e}`}var G=e=>{if(!e.currency)return{before:!0};try{let n=N(e.locale),t=new Intl.NumberFormat(n,{style:"currency",currency:e.currency}).formatToParts(1),o=t.findIndex(u=>u.type==="currency"),r=t.findIndex(u=>u.type==="integer"),i;try{i=new Intl.DisplayNames([n],{type:"currency"}).of(e.currency)}catch{}return{...o>=0?{symbol:t[o].value}:{},before:o<r,...i?{name:i}:{}}}catch{return{symbol:e.currency,before:!0}}};function le(e){let n=e.locale;if(e.format==="money"){let{symbol:t,before:o,name:r}=G(e),i=p(1250,n,{minimumFractionDigits:2,maximumFractionDigits:2});return{...t?o?{prefix:t}:{suffix:t}:{},placeholder:i,hint:r?`in ${r}`:e.currency?`in ${e.currency}`:"an amount of money"}}return e.format==="percent"?{suffix:"%",placeholder:p(15,n),hint:"as a percent"}:{...e.unit?{suffix:e.unit}:{},placeholder:"",hint:e.unit?`in ${e.unit}`:"a number"}}function pe(e,n){return e===void 0||!Number.isFinite(e)?"":n.format==="money"?p(e,n.locale,Number.isInteger(e)?{maximumFractionDigits:0}:{minimumFractionDigits:2,maximumFractionDigits:2}):n.format==="percent"?p(e*100,n.locale,{maximumFractionDigits:4}):p(e,n.locale,{maximumFractionDigits:6})}function ye(e){try{let n=new Intl.NumberFormat(N(e)).formatToParts(12345.6);return{group:n.find(t=>t.type==="group")?.value??",",decimal:n.find(t=>t.type==="decimal")?.value??"."}}catch{return{group:",",decimal:"."}}}function ge(e,n){let{group:t,decimal:o}=ye(n),r=e.replace(/[\s  ']/g,"").replace(/[−–]/g,"-");if(o!=="."&&!r.includes(o)&&/^-?\d+\.\d{1,2}$/.test(r))return Number(r);if(t&&(r=r.split(t).join("")),o!=="."&&(r=r.replace(o,".")),!/^-?(\d+\.?\d*|\.\d+)$/.test(r))return;let i=Number(r);return Number.isFinite(i)?i:void 0}function be(e,n){let t=e.trim();if(t==="")return;let o=n?.format==="money"&&n.currency?G(n).symbol:void 0,r=t;o&&(r=r.split(o).join("")),n?.currency&&(r=r.replace(new RegExp(n.currency,"gi"),"")),r=r.replace(/^[$€£¥₹]|[$€£¥₹]$/g,""),/%\s*$/.test(r)&&(r=r.replace(/%\s*$/,"")),n?.unit&&n.format!=="money"&&(r=r.replace(new RegExp(`\\s*${n.unit.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*$`),""));let u=ge(r,n?.locale);if(u!==void 0)return n?.format==="percent"?u/100:u}export{P as a,Te as b,H as c,k as d,fe as e,z as f,K as g,me as h,le as i,pe as j,be as k,L as l,w as m,y as n,F as o,V as p,q,ee as r,de as s};
1
+ import{B as $,Bb as O,D as h,Eb as M,G as E,K as N,L as S,M as W,O as R,P as I,T as p,da as D,ia as T,ta as j,vb as v}from"./chunk.V5MYKNL7.js";function z(e,n,t){let o=[...n?.creates??[],...n?.subject&&n.subject.kinds!=="*"?n.subject.kinds:[]];for(let r of o){let i=e.tryDefinition(r),u=i?.fields?.shape??{};if(!i||!(t in u))continue;let a=i.display?.format?.[t];return{label:i.display?.labels?.[t]??T(i,t),option:d=>a?a(d):D(d)}}return{label:T(void 0,t),option:r=>D(r)}}function K(e,n,t){if(t instanceof v){let o=n.find(i=>i.name===t.mutation);return`Not yet: ${t.issues.map(i=>{let u=i.path.length>0?z(e,o,String(i.path[0])).label:void 0;return u?`${u} \u2014 ${i.message.replace(/^./,a=>a.toLowerCase())}`:i.message}).join("; ")}.`}return t instanceof Error?t.message:String(t)}var x=864e5,X=/^(\d{4})-(\d{2})-(\d{2})/,g=e=>String(e).padStart(2,"0"),_=e=>new Date(e).toISOString().slice(0,10),m=e=>Date.UTC(+e.slice(0,4),+e.slice(5,7)-1,+e.slice(8,10)),b=(e,n)=>_(m(e)+n*x),C=e=>new Date(m(e)).getUTCDay();function l(e,n,t){if(!(n>=1&&n<=12&&t>=1&&t<=31))return;let o=`${String(e).padStart(4,"0")}-${g(n)}-${g(t)}`;return _(m(o))===o?o:void 0}function L(e=new Date){let n=S();return n?R(e.getTime(),n):{day:`${e.getFullYear()}-${g(e.getMonth()+1)}-${g(e.getDate())}`,minutes:e.getHours()*60+e.getMinutes()}}var w=e=>/T\d\d:\d\d(:[\d.]+)?(Z|[+-]\d\d:?\d\d)$/.test(e);function y(e){if(typeof e!="string")return;if(w(e)){let o=new Date(e);return Number.isNaN(o.getTime())?void 0:L(o)}let n=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2}))?/.exec(e);if(!n||!l(Number(n[1]),Number(n[2]),Number(n[3])))return;let t=e.slice(0,10);return n[4]===void 0?{day:t}:{day:t,minutes:Number(n[4])*60+Number(n[5])}}function F(e,n){if(!n.time)return e.day;let t=e.minutes??9*60;if(!n.instant)return`${e.day}T${g(Math.floor(t/60))}:${g(t%60)}`;let o=S(),[,r,i,u]=X.exec(e.day);return(o?new Date(I(e.day,t,o)):new Date(Number(r),Number(i)-1,Number(u),Math.floor(t/60),t%60)).toISOString().replace(/\.\d{3}Z$/,"Z")}function V(e,n=new Date){let t=W(),o=t;try{o=new Intl.DateTimeFormat(e??h,{timeZoneName:"short",timeZone:t}).formatToParts(n).find(r=>r.type==="timeZoneName")?.value??t}catch{o=t}return{zone:t,short:o}}function q(e,n,t,o){let r=y(n);if(!r)return t;let i=e===void 0?void 0:y(e),u=t===void 0?void 0:y(t),a=d=>m(d.day)+(d.minutes??0)*6e4,c=(d,s)=>{let f=a(d)+s;return{day:_(f),...o.time?{minutes:Math.round(f%x/6e4)}:{}}};return i&&u?F(c(u,a(r)-a(i)),o):u&&a(u)>=a(r)?t:o.time?F(c(r,36e5),o):t}var J=/^(start|starts|startsAt|startsOn|startAt|begins|from|opens|checkIn)$/i,Q=/^(end|ends|endsAt|endsOn|endAt|until|to|finish|finishes|closes|through|checkOut)$/i;function ee(e,n={}){let t=(n.start&&e.includes(n.start)?n.start:void 0)??e.find(r=>J.test(r)),o=(n.end&&e.includes(n.end)?n.end:void 0)??e.find(r=>r!==t&&Q.test(r));return t&&o?{start:t,end:o}:void 0}var ne=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],te=["sun","mon","tue","wed","thu","fri","sat"],B="(jan(?:uary)?|feb(?:ruary)?|mar(?:ch)?|apr(?:il)?|may|june?|july?|aug(?:ust)?|sept?(?:ember)?|oct(?:ober)?|nov(?:ember)?|dec(?:ember)?)",U="(sun(?:day)?|mon(?:day)?|tue(?:s|sday)?|wed(?:nesday)?|thu(?:r|rs|rsday)?|fri(?:day)?|sat(?:urday)?)",re=e=>ne.indexOf(e.slice(0,3))+1,Y=e=>e===void 0?void 0:e.length===2?2e3+Number(e):Number(e);function oe(e){try{let n=new Intl.DateTimeFormat(e,{month:"numeric",day:"numeric"}).formatToParts(0).map(t=>t.type);return n.indexOf("month")<n.indexOf("day")}catch{return!0}}function ie(e){let n=(r,i)=>({minutes:i,rest:`${e.slice(0,r.index)} ${e.slice(r.index+r[0].length)}`}),t=/\b(noon|midday)\b/.exec(e);if(t)return n(t,12*60);if(t=/\bmidnight\b/.exec(e),t)return n(t,0);if(t=/\b(\d{1,2})(?::(\d{2}))?\s*([ap])\.?m?\.?(?=\s|$)/.exec(e),t){let r=Number(t[1]),i=Number(t[2]??0);return r<1||r>12||i>59?{rest:e,bad:!0}:n(t,(r%12+(t[3]==="p"?12:0))*60+i)}if(t=/\b(\d{1,2}):(\d{2})\b/.exec(e),t){let r=Number(t[1]),i=Number(t[2]);return r>23||i>59?{rest:e,bad:!0}:n(t,r*60+i)}if(t=/\bat\s+(\d{1,2})\b/.exec(e),t){let r=Number(t[1]);return r>23?{rest:e,bad:!0}:n(t,(r>=1&&r<=7?r+12:r)*60)}let o=/\b(morning|afternoon|evening|tonight)\b/.exec(e);return o?{minutes:{morning:9,afternoon:15,evening:18,tonight:20}[o[1]]*60,rest:o[1]==="tonight"?`${e.slice(0,o.index)} today ${e.slice(o.index+o[0].length)}`:`${e.slice(0,o.index)} ${e.slice(o.index+o[0].length)}`}:{rest:e}}function ue(e,n,t){let o=e.replace(/\b(on|at|the|of|this)\b/g," ").replace(/\s+/g," ").trim();if(o==="")return null;if(o==="today"||o==="now")return n;if(o==="tomorrow"||o==="tmrw"||o==="tmr")return b(n,1);if(o==="yesterday")return b(n,-1);if(o==="next week")return b(n,7);let r=/^in (\d{1,3}) (day|days|week|weeks)$/.exec(o);if(r)return b(n,Number(r[1])*(r[2].startsWith("week")?7:1));if(r=new RegExp(`^(next )?${U}$`).exec(o),r){let d=(te.indexOf(r[2].slice(0,3))-C(n)+7)%7;return b(n,r[1]&&d===0?7:d)}if(r=/^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(o),r)return l(Number(r[1]),Number(r[2]),Number(r[3]));let i=o.replace(new RegExp(`^${U} `),"");r=new RegExp(`^(\\d{1,2})(?:st|nd|rd|th)? ${B}(?: (\\d{4}))?$`).exec(i);let u=r?{date:r[1],month:r[2],year:r[3]}:void 0;r=new RegExp(`^${B} (\\d{1,2})(?:st|nd|rd|th)?(?: (\\d{4}))?$`).exec(i);let a=u??(r?{date:r[2],month:r[1],year:r[3]}:void 0);if(a)return Z(n,Y(a.year),re(a.month),Number(a.date));if(r=/^(\d{1,2})[/.-](\d{1,2})(?:[/.-](\d{2}|\d{4}))?$/.exec(i),r){let[c,d]=[Number(r[1]),Number(r[2])],[s,f]=oe(t)?[c,d]:[d,c];return Z(n,Y(r[3]),s,f)}}function Z(e,n,t,o){if(n!==void 0)return l(n,t,o);let r=Number(e.slice(0,4)),i=l(r,t,o);return i===void 0?l(r+1,t,o):m(e)-m(i)>183*x?l(r+1,t,o):i}function de(e,n){let t=e.trim();if(w(t)){let a=y(t);if(a)return n.time?a:{day:a.day}}let o=e.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(o==="")return;let r=ie(o);if(r.bad)return;let i=ue(r.rest,n.today,n.locale??h);if(i===void 0||i===null&&r.minutes===void 0)return;let u=i??n.base?.day??n.today;return n.time?{day:u,minutes:r.minutes??n.base?.minutes??9*60}:{day:u}}var ae=e=>/^[A-Z]{3}$/.test(e??"");function P(e){let{format:n,unit:t,currency:o,locale:r}=e,i=ae(t),u=n==="money"||!n&&i,a=u?i?t:o:void 0;return{...u?{format:"money"}:n?{format:n}:{},...t&&!(u&&i)?{unit:t}:{},...a?{currency:a}:{},...r?{locale:r}:{}}}function Te(e){switch(e.format){case"money":return e.currency?`An amount of money in ${e.currency}: a plain number, 1250.5 for 1,250.50 ${e.currency}.`:"An amount of money, in no named currency: a plain number.";case"percent":return"A fraction said as a percent: 0.15 is 15%.";default:return e.unit?`A number of ${e.unit}.`:"A number."}}function H(e){let n=$(e)?.innerType;return n===void 0?e:H(n)}var se={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ce=e=>(e?._zod?.def?.checks??[]).map(n=>n._zod?.def).filter(n=>n!==void 0);function k(e){let n=H(e),t=$(n),o=t?.type,r=ce(n);if(o==="enum")return{type:"choice",options:Object.keys(t?.entries??{})};let i=j(n);if(i)return i==="image"?{type:"file",image:!0}:i==="video"?{type:"file",video:!0}:{type:"file"};if(o==="boolean")return{type:"boolean"};if(o==="array"){let u=k(t?.element);return u.type==="unknown"?{type:"unknown"}:{type:"several",of:u}}if(o==="number"){let u,a,c;for(let d of r){d.check==="multiple_of"&&typeof d.value=="number"?c=d.value:d.check==="number_format"&&(d.format==="safeint"||d.format==="int32"||d.format==="uint32")&&(c??=1);let s=d.check==="number_format"&&d.format?se[d.format]:void 0,f=s?s[0]:d.check==="greater_than"&&d.inclusive&&typeof d.value=="number"?d.value:void 0,A=s?s[1]:d.check==="less_than"&&d.inclusive&&typeof d.value=="number"?d.value:void 0;f!==void 0&&(u=u===void 0?f:Math.max(u,f)),A!==void 0&&(a=a===void 0?A:Math.min(a,A))}return{type:"number",...u===void 0?{}:{min:u},...a===void 0?{}:{max:a},...c===void 0?{}:{step:c},...M(n)==="duration"?{duration:!0}:{},...O(e)?{amount:P(O(e))}:{}}}if(o==="string"){if(r.some(s=>s.fn===E||s.format==="datetime")||t?.format==="datetime")return{type:"date",time:!0,instant:!0};let a=[t?.pattern,...r.map(s=>s.pattern)].filter(s=>s instanceof RegExp).map(s=>s.source);if(a.some(s=>s.includes("\\d{4}")))return a.some(s=>s.includes("\\d{2}:\\d{2}"))?{type:"date",time:!0}:{type:"date"};let c=r.some(s=>s.check==="max_length"&&typeof s.maximum=="number"&&s.maximum>500),d=M(n);return c?{type:"text",long:!0}:d==="phone"||d==="place"?{type:"text",holds:d}:{type:"text"}}return{type:"unknown"}}function fe(e,n){let t=e?.shape;return!t||!(n in t)?{type:"unknown"}:k(t[n])}function me(e){if(e===void 0||e==="web"||e.startsWith("ai:")||e.startsWith("app:"))return;if(e==="api")return"via the API";if(e==="cli")return"via the command line";let[n,...t]=e.split(":"),o=t.join(":");return(n==="mcp"||n==="view")&&o?`via ${o}`:n==="mcp"?"via an agent's tools":`via ${e}`}var G=e=>{if(!e.currency)return{before:!0};try{let n=N(e.locale),t=new Intl.NumberFormat(n,{style:"currency",currency:e.currency}).formatToParts(1),o=t.findIndex(u=>u.type==="currency"),r=t.findIndex(u=>u.type==="integer"),i;try{i=new Intl.DisplayNames([n],{type:"currency"}).of(e.currency)}catch{}return{...o>=0?{symbol:t[o].value}:{},before:o<r,...i?{name:i}:{}}}catch{return{symbol:e.currency,before:!0}}};function le(e){let n=e.locale;if(e.format==="money"){let{symbol:t,before:o,name:r}=G(e),i=p(1250,n,{minimumFractionDigits:2,maximumFractionDigits:2});return{...t?o?{prefix:t}:{suffix:t}:{},placeholder:i,hint:r?`in ${r}`:e.currency?`in ${e.currency}`:"an amount of money"}}return e.format==="percent"?{suffix:"%",placeholder:p(15,n),hint:"as a percent"}:{...e.unit?{suffix:e.unit}:{},placeholder:"",hint:e.unit?`in ${e.unit}`:"a number"}}function pe(e,n){return e===void 0||!Number.isFinite(e)?"":n.format==="money"?p(e,n.locale,Number.isInteger(e)?{maximumFractionDigits:0}:{minimumFractionDigits:2,maximumFractionDigits:2}):n.format==="percent"?p(e*100,n.locale,{maximumFractionDigits:4}):p(e,n.locale,{maximumFractionDigits:6})}function ye(e){try{let n=new Intl.NumberFormat(N(e)).formatToParts(12345.6);return{group:n.find(t=>t.type==="group")?.value??",",decimal:n.find(t=>t.type==="decimal")?.value??"."}}catch{return{group:",",decimal:"."}}}function ge(e,n){let{group:t,decimal:o}=ye(n),r=e.replace(/[\s  ']/g,"").replace(/[−–]/g,"-");if(o!=="."&&!r.includes(o)&&/^-?\d+\.\d{1,2}$/.test(r))return Number(r);if(t&&(r=r.split(t).join("")),o!=="."&&(r=r.replace(o,".")),!/^-?(\d+\.?\d*|\.\d+)$/.test(r))return;let i=Number(r);return Number.isFinite(i)?i:void 0}function be(e,n){let t=e.trim();if(t==="")return;let o=n?.format==="money"&&n.currency?G(n).symbol:void 0,r=t;o&&(r=r.split(o).join("")),n?.currency&&(r=r.replace(new RegExp(n.currency,"gi"),"")),r=r.replace(/^[$€£¥₹]|[$€£¥₹]$/g,""),/%\s*$/.test(r)&&(r=r.replace(/%\s*$/,"")),n?.unit&&n.format!=="money"&&(r=r.replace(new RegExp(`\\s*${n.unit.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*$`),""));let u=ge(r,n?.locale);if(u!==void 0)return n?.format==="percent"?u/100:u}export{P as a,Te as b,H as c,k as d,fe as e,z as f,K as g,me as h,le as i,pe as j,be as k,L as l,w as m,y as n,F as o,V as p,q,ee as r,de as s};
@@ -1 +1 @@
1
- import{a as C,e as L,n as H,o as R,p as k}from"./chunk.RM7NVN7B.js";import"./chunk.J3M2MZHG.js";import"./chunk.UT6642FC.js";import"./chunk.IAZRY42B.js";import"./chunk.FMN5XDLE.js";import{a as S}from"./chunk.UIUHGA6W.js";import"./chunk.TI4OSTQV.js";import"./chunk.4BBJ62ZO.js";import"./chunk.NSNGPQGT.js";import"./chunk.H5CZZZLX.js";import"./chunk.Z7JRBKA7.js";import"./chunk.ORXFUK6F.js";import{Aa as E,G as T,R as b}from"./chunk.BTSXYZ6Z.js";import"./chunk.SDO3U72B.js";import{tc as x}from"./chunk.5ZMENPY4.js";import{b as g}from"./chunk.AJZBJBMO.js";var t=g(T(),1);var c=g(b(),1);function N(n){if(!n||n.interaction.outcome==="failed")return null;let s=n.offers[0],o=s?n.interaction.offered.find(i=>i.id===s.id)?.confidence:void 0;return s&&o!==void 0&&o>=.6?{offer:s,confidence:o}:null}function j({rest:n,hold:s,leave:o}){let i=S(),u=(0,t.useMemo)(()=>C(n.target,e=>i.store.graph.has(e)),[n.target,i.store]),l=u.on==="record"&&L(i.ai)!==void 0,m=l?H(i,u):void 0,p=JSON.stringify(u),[y,I]=(0,t.useState)(null);(0,t.useEffect)(()=>{if(!l||m!==void 0)return;let e=!0;return R(i,u).then(r=>{e&&I({key:p,result:r})}),()=>{e=!1}},[p,l]);let w=m??(y?.key===p?y.result:void 0),f=l?N(w):null,v=f?.offer.id??null,h=(0,t.useRef)(null);if((0,t.useEffect)(()=>{if(v===null)return;let e=r=>{r.target instanceof Node&&h.current?.contains(r.target)||o(!0)};return document.addEventListener("pointerdown",e,{capture:!0,passive:!0}),document.addEventListener("contextmenu",e,{capture:!0,passive:!0}),addEventListener("scroll",e,{capture:!0,passive:!0}),addEventListener("resize",e,{passive:!0}),()=>{document.removeEventListener("pointerdown",e,{capture:!0}),document.removeEventListener("contextmenu",e,{capture:!0}),removeEventListener("scroll",e,{capture:!0}),removeEventListener("resize",e)}},[v,o]),(0,t.useLayoutEffect)(()=>{let e=h.current;if(!e)return;if(typeof e.showPopover=="function"&&!E(e))try{e.showPopover()}catch{}let r=n.element.getBoundingClientRect(),d=e.getBoundingClientRect(),O=r.top-d.height-4>=4?r.top-d.height-4:Math.min(innerHeight-d.height-4,r.top+4),A=Math.max(4,Math.min(innerWidth-d.width-4,r.right-d.width));e.style.top=`${Math.round(O)}px`,e.style.left=`${Math.round(A)}px`},[v,n.element]),!f)return null;let{offer:a,confidence:P}=f,M=a.type==="panel"?"a panel":a.type==="place"?"go there":a.type==="record"?"open it":"suggested";return(0,c.jsxs)("button",{ref:h,type:"button",popover:"manual","data-testid":"hover-chip","data-ai-offer":a.id,"data-ai-offer-type":a.type,"data-graview-overlay":"","data-graview-popover":"","aria-label":`Suggested by AI: ${a.label}`,title:`Suggested by AI, ${Math.round(P*100)}% sure`,onPointerEnter:s,onPointerLeave:()=>o(),onClick:()=>{n.element.closest("[tabindex], a[href], button")?.focus({preventScroll:!0}),o(!0),k(i,w,a)},style:$,children:[(0,c.jsxs)("span",{"aria-hidden":"true",style:{color:"var(--graview-accent)"},children:["\u2726"," "]}),a.label,(0,c.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",M]})]})}var $={position:"fixed",inset:"auto",top:0,left:0,margin:0,zIndex:x("toast"),boxSizing:"border-box",width:"max-content",maxWidth:"min(320px, calc(100vw - 8px))",height:"auto",minHeight:24,padding:"2px 10px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",borderRadius:999,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",color:"var(--graview-ink)",boxShadow:"var(--graview-lift-high)",font:"inherit",fontSize:"0.75rem",cursor:"pointer"};export{j as HoverChip};
1
+ import{a as C,e as L,n as H,o as R,p as k}from"./chunk.ZRYSVOLA.js";import"./chunk.QIV65FWE.js";import"./chunk.UT6642FC.js";import"./chunk.HPAGOEZG.js";import"./chunk.ISXFH3CK.js";import{a as S}from"./chunk.H5ADMSE7.js";import"./chunk.TI4OSTQV.js";import"./chunk.I7XSDXQ3.js";import"./chunk.2FLPDPEL.js";import"./chunk.UUBYFBPN.js";import"./chunk.2RVUDRRY.js";import"./chunk.JHEVGLKB.js";import{Ea as E,G as T,R as b}from"./chunk.FOQZADMA.js";import"./chunk.SDO3U72B.js";import{uc as x}from"./chunk.V5MYKNL7.js";import{b as g}from"./chunk.AJZBJBMO.js";var t=g(T(),1);var c=g(b(),1);function N(n){if(!n||n.interaction.outcome==="failed")return null;let s=n.offers[0],o=s?n.interaction.offered.find(i=>i.id===s.id)?.confidence:void 0;return s&&o!==void 0&&o>=.6?{offer:s,confidence:o}:null}function j({rest:n,hold:s,leave:o}){let i=S(),u=(0,t.useMemo)(()=>C(n.target,e=>i.store.graph.has(e)),[n.target,i.store]),l=u.on==="record"&&L(i.ai)!==void 0,m=l?H(i,u):void 0,p=JSON.stringify(u),[y,I]=(0,t.useState)(null);(0,t.useEffect)(()=>{if(!l||m!==void 0)return;let e=!0;return R(i,u).then(r=>{e&&I({key:p,result:r})}),()=>{e=!1}},[p,l]);let w=m??(y?.key===p?y.result:void 0),f=l?N(w):null,v=f?.offer.id??null,h=(0,t.useRef)(null);if((0,t.useEffect)(()=>{if(v===null)return;let e=r=>{r.target instanceof Node&&h.current?.contains(r.target)||o(!0)};return document.addEventListener("pointerdown",e,{capture:!0,passive:!0}),document.addEventListener("contextmenu",e,{capture:!0,passive:!0}),addEventListener("scroll",e,{capture:!0,passive:!0}),addEventListener("resize",e,{passive:!0}),()=>{document.removeEventListener("pointerdown",e,{capture:!0}),document.removeEventListener("contextmenu",e,{capture:!0}),removeEventListener("scroll",e,{capture:!0}),removeEventListener("resize",e)}},[v,o]),(0,t.useLayoutEffect)(()=>{let e=h.current;if(!e)return;if(typeof e.showPopover=="function"&&!E(e))try{e.showPopover()}catch{}let r=n.element.getBoundingClientRect(),d=e.getBoundingClientRect(),O=r.top-d.height-4>=4?r.top-d.height-4:Math.min(innerHeight-d.height-4,r.top+4),A=Math.max(4,Math.min(innerWidth-d.width-4,r.right-d.width));e.style.top=`${Math.round(O)}px`,e.style.left=`${Math.round(A)}px`},[v,n.element]),!f)return null;let{offer:a,confidence:P}=f,M=a.type==="panel"?"a panel":a.type==="place"?"go there":a.type==="record"?"open it":"suggested";return(0,c.jsxs)("button",{ref:h,type:"button",popover:"manual","data-testid":"hover-chip","data-ai-offer":a.id,"data-ai-offer-type":a.type,"data-graview-overlay":"","data-graview-popover":"","aria-label":`Suggested by AI: ${a.label}`,title:`Suggested by AI, ${Math.round(P*100)}% sure`,onPointerEnter:s,onPointerLeave:()=>o(),onClick:()=>{n.element.closest("[tabindex], a[href], button")?.focus({preventScroll:!0}),o(!0),k(i,w,a)},style:$,children:[(0,c.jsxs)("span",{"aria-hidden":"true",style:{color:"var(--graview-accent)"},children:["\u2726"," "]}),a.label,(0,c.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",M]})]})}var $={position:"fixed",inset:"auto",top:0,left:0,margin:0,zIndex:x("toast"),boxSizing:"border-box",width:"max-content",maxWidth:"min(320px, calc(100vw - 8px))",height:"auto",minHeight:24,padding:"2px 10px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",borderRadius:999,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",color:"var(--graview-ink)",boxShadow:"var(--graview-lift-high)",font:"inherit",fontSize:"0.75rem",cursor:"pointer"};export{j as HoverChip};
@@ -0,0 +1,88 @@
1
+ import{a as qe,c as Be}from"./chunk.HKCK3JI4.js";import{b as Ve}from"./chunk.PMGXASFI.js";import{a as Ie,b as Ke,c as Fe,d as j}from"./chunk.C4TSM4W5.js";import"./chunk.XEKLEHC3.js";import{j as Me,k as Le}from"./chunk.JACGQ2PR.js";import"./chunk.53CDFJNM.js";import"./chunk.4QPVS2ZM.js";import"./chunk.RCM7NOPF.js";import{e as Ee}from"./chunk.Z7LDT55A.js";import"./chunk.HJCQ6I3S.js";import"./chunk.VNUHESMZ.js";import{e as ne}from"./chunk.N2K25KH3.js";import"./chunk.XFZKP4IF.js";import{a as xe}from"./chunk.C7JKMOFC.js";import"./chunk.BFNVG5JE.js";import"./chunk.AIZQBPGU.js";import"./chunk.V3V47QRE.js";import"./chunk.5P556A7W.js";import"./chunk.QHYXXZRD.js";import"./chunk.BELCPW66.js";import{m as Pe}from"./chunk.6YPLZNVT.js";import{a as Te,b as Oe}from"./chunk.5RABSIF7.js";import{h as $e}from"./chunk.NGDXH66B.js";import{e as Re,f as De}from"./chunk.67WWRC6Y.js";import{a as Se,b as Ne,j as Ae}from"./chunk.JDRLSVOI.js";import"./chunk.G4JJXA63.js";import"./chunk.VJXXCUKS.js";import"./chunk.Z5AB2DBF.js";import"./chunk.QIV65FWE.js";import"./chunk.UT6642FC.js";import"./chunk.HPAGOEZG.js";import"./chunk.ISXFH3CK.js";import"./chunk.Q5WEOX3Q.js";import"./chunk.242EUAPE.js";import"./chunk.VDAMCTNL.js";import"./chunk.BXT6FDT4.js";import"./chunk.WVUJXDXZ.js";import"./chunk.N6MVK3KD.js";import{a as ye}from"./chunk.I7XSDXQ3.js";import"./chunk.UHI3D7JC.js";import"./chunk.WVDKYUF3.js";import"./chunk.ZHLQWMV5.js";import"./chunk.TNESS3LQ.js";import"./chunk.GZHZLJBF.js";import{r as ke}from"./chunk.42XSBKPO.js";import"./chunk.OJGHDWI6.js";import"./chunk.6FNMDAX5.js";import{g as be}from"./chunk.2FLPDPEL.js";import{d as te}from"./chunk.UUBYFBPN.js";import{c as me}from"./chunk.2RVUDRRY.js";import{C as Ce,r as J}from"./chunk.JHEVGLKB.js";import{Aa as Y,G as tt,R as we,T as ve,_ as V,aa as X,j as ge,ja as he,l as ue,m as fe,r as U,za as ee}from"./chunk.FOQZADMA.js";import"./chunk.SDO3U72B.js";import{H as se,N as de,T as D,Ua as Z,ba as G,ea as le,ga as pe,ia as ce}from"./chunk.V5MYKNL7.js";import{b as Q}from"./chunk.AJZBJBMO.js";var f=Q(tt(),1);var nt=300,it=14,z=50,at=3,ot=2;function _e(e,n,o){let p=e.tryDefinition(n)?.fields?.shape;return(p?.[o]===void 0?void 0:ye(p[o]))?.type}var rt=(e,n)=>Object.keys(e.tryDefinition(n)?.fields?.shape??{}),st=e=>e==="date"||e==="datetime",Ge=/^(due|dueOn|dueAt|dueDate|deadline|by)$/i,dt=/^(date|on|day|when|at|start|starts|startsOn|startsAt|begins|from|sown|scheduled|scheduledFor|planned|plannedFor)$/i,lt=/^(done|finished|complete|completed|closed)$/i;function ae(e,n){let o=e.tryDefinition(n),p=rt(e,n),a=p.filter(u=>st(_e(e,n,u)));if(a.length===0)return;let i=o?.fieldRoles??{},s=u=>i[u]!==void 0&&a.includes(i[u])?i[u]:void 0,c=s("start")??s("when")??a.find(u=>Ge.test(u))??a.find(u=>dt.test(u));if(!c)return;let S=s("end")??a.find(u=>u!==c&&/^(end|ends|until|to|finish|finished|harvested|through)$/i.test(u)),g=p.find(u=>lt.test(u)&&_e(e,n,u)==="boolean");return{field:c,due:Ge.test(c),...S?{end:S}:{},...g?{done:g}:{}}}function ie(e,n){return Math.round((Date.parse(`${n.slice(0,10)}T00:00:00Z`)-Date.parse(`${e.slice(0,10)}T00:00:00Z`))/864e5)}var q=e=>typeof e=="string"&&/^\d{4}-\d{2}-\d{2}/.test(e)?e.slice(0,10):void 0;function je(e,n,o,p){let a=ne(e,n);if(a&&o.length>0&&o.length<=nt)return{shape:"board",field:a.field};let i=ae(e,n);if(i&&!i.due){let s=r=>{let y=q(r[i.field]),h=q(Z(r,i.field,p));return y&&h?ie(y,h):0},c=o.map(r=>({from:q(Z(r,i.field,p)),to:i.end&&q(r[i.end])?L(q(r[i.end]),s(r)):void 0})).filter(r=>r.from!==void 0).map(r=>({from:r.from,to:r.to&&r.to>r.from?r.to:r.from})),S=`${p.slice(0,7)}-01`,g=L(`${L(S,31).slice(0,7)}-01`,-1),u=c.filter(r=>r.from<=g&&r.to>=S),w=c.map(r=>ie(r.from,r.to)).sort((r,y)=>r-y),l=w[Math.floor(w.length/2)]??0;if(u.length>0&&l<=it){let r=L(p,-((new Date(`${p}T00:00:00Z`).getUTCDay()+6)%7)),y=L(r,6),h=u.every(m=>m.from>=r&&m.to<=y);return{shape:"calendar",start:i.field,...i.end?{end:i.end}:{},...i.done?{done:i.done}:{},range:h?"week":"month"}}}return{shape:"table"}}function ze(e,n){let o=ae(e,n);return o?{by:o.field,direction:o.due?"asc":"desc"}:void 0}function He(e,n,o={}){switch(n.shape){case"board":return{lens:"columns",kind:e,column:n.field};case"calendar":return{lens:"calendar",kind:e,start:n.start,...n.end?{end:n.end}:{},...n.done?{done:n.done}:{},range:n.range};case"table":return{lens:"blocks",kind:e,as:"row",...o.group?.by?{group:o.group.by}:{},...o.sort?{sort:{by:o.sort.by,...o.sort.direction==="desc"?{direction:"desc"}:{}}}:{}}}}var pt=60;function We(e,n,o,p){let a=e.tryDefinition(n),i=o.slice(0,pt),s=new Map;i.forEach(w=>{let l=G(a,w);te(w,a,{glance:!0,said:[l]}).forEach((r,y)=>{if(r.long||r.files||r.app)return;let h=s.get(r.key);h?h.count++:s.set(r.key,{label:r.label,count:1,at:y})})});let c=Math.max(1,Math.ceil(i.length/3)),S=[...s.entries()].filter(([,w])=>w.count>=c).sort((w,l)=>w[1].at-l[1].at).slice(0,at).map(([w,l])=>({about:"field",key:w,label:l.label})),g=new Map;for(let w of i){let l=new Set;for(let[r,y]of[["out",p.outEdges(w.id)],["in",p.inEdges(w.id)]])for(let h of y){let m=p.getNode(r==="out"?h.to:h.from);if(!m||m.id===w.id)continue;let b=`${h.kind}|${r}`;if(l.has(b))continue;l.add(b);let A=g.get(b);A?A.count++:g.set(b,{edge:h.kind,direction:r,far:m.kind,count:1})}}let u=[...g.entries()].sort((w,l)=>l[1].count-w[1].count).slice(0,ot).map(([w,l])=>{let r=me(e,l.direction==="out"?n:l.far,l.edge,l.direction);return{about:"edge",key:w,label:r.charAt(0).toUpperCase()+r.slice(1),edge:l.edge,direction:l.direction}});return[...S,...u]}function Ze(e,n,o,p){if(o.about==="field"){let s=e.tryDefinition(n.kind);return{text:te(n,s,{excerpt:!0}).find(S=>S.key===o.key)?.value??""}}let i=(o.direction==="out"?p.outEdges(n.id):p.inEdges(n.id)).filter(s=>s.kind===o.edge).map(s=>p.getNode(o.direction==="out"?s.to:s.from)).filter(s=>s!==void 0).map(s=>G(e.tryDefinition(s.kind),s));return i.length===0?{text:""}:i.length===1?{text:i[0]}:{text:`${i[0]} +${i.length-1}`,title:i.join(", ")}}function Ue(e,n,o=()=>{}){let p=new Map;for(let a of e){let i=a.nodeIds.filter(c=>n.has(c));if(i.length===0&&!(a.subjectId!==void 0&&n.has(a.subjectId)))continue;let s=p.get(a.invariant)??{invariant:a.invariant,label:o(a.invariant)||a.label||a.message,violations:[],records:new Set};s.violations.push(a);for(let c of i)s.records.add(c);a.subjectId!==void 0&&n.has(a.subjectId)&&s.records.add(a.subjectId),p.set(a.invariant,s)}return[...p.values()].sort((a,i)=>i.violations.length-a.violations.length).map(a=>({invariant:a.invariant,label:a.label,violations:a.violations,records:[...a.records]}))}var Ye=6;function Je(e,n,o,p){let a=ae(e,n);if(!a)return;let i=ne(e,n),s=g=>{if(a.done!==void 0&&g[a.done]===!0)return!0;if(!i)return!1;let u=i.values.indexOf(String(g[i.field]));return u>=0&&i.tiers[u]==="done"},c=0,S=0;for(let g of o){let u=q(Z(g,a.field,p));if(!u||s(g))continue;let w=ie(p,u);a.due&&w<0?c++:w>=0&&w<=Ye&&S++}if(!(c===0&&S===0))return{field:a.field,due:a.due,overdue:c,soon:S}}function L(e,n){return new Date(Date.parse(`${e.slice(0,10)}T00:00:00Z`)+n*864e5).toISOString().slice(0,10)}function oe(e,n,o){return n==="overdue"?[{key:e.field,value:`before:${o}`}]:[{key:e.field,value:`after:${L(o,-1)}`},{key:e.field,value:`before:${L(o,Ye+1)}`}]}function Qe(e,n,o,p){let a=new Set,i=new Set;for(let s of e)if(!(s.at<=o))for(let c of s.primitives)c.op==="add-node"&&c.node?.kind===n?a.add(c.node.id):c.op==="patch-node"&&c.id!==void 0&&p(c.id)===n&&i.add(c.id);for(let s of a)i.delete(s);return{added:[...a].filter(s=>p(s)===n).length,changed:[...i].filter(s=>p(s)===n).length}}var t=Q(we(),1),Xe="as",ct=(e,n)=>`graview:kind-seen:${e}:${n}`;function gt(e){try{return localStorage.getItem(e)}catch{return null}}function ut(e,n){try{localStorage.setItem(e,n)}catch{}}var ft=(e,n)=>({...ge(fe(e,!1),n),relation:null});function Jt({kind:e,members:n,flagged:o=[],label:p,retired:a=0}){let{store:i,brand:s,principal:c,views:S,view:g}=V(),{go:u}=Y(),w=X(),l=i.schema,r=l.tryDefinition(e),y=p??pe(l,e),h=i.today()??se(),m=n,b=(0,f.useId)(),A=(0,f.useMemo)(()=>je(l,e,m,h),[l,e,m,h]),x=g.within?.[Xe]==="table"?{shape:"table"}:A,k=Te(g),C=x.shape==="table"&&!k.sort?ze(l,e):void 0,v=C?{...k,sort:C}:k,R=(0,f.useMemo)(()=>new Set(o),[o]),T=(0,f.useMemo)(()=>$e(m,v,{schema:l,graph:i.graph,flagged:R,today:h}),[m,v,l,i,R,h,w]),I=(0,f.useMemo)(()=>De(l,Re(l,e)),[l,e]),M=S.arrangement?.()?.lists?.[e]?.filters,K=$=>u(Oe(g,$)),B=(0,f.useMemo)(()=>({name:s?.name??"app",schema:l,...i.policy?{policy:i.policy}:{}}),[s,l,i]),H=JSON.stringify(He(e,x,v)),P=(0,f.useMemo)(()=>{let $=Ae(JSON.parse(H),{app:B,sight:Ne(B,c)});return Se($)?void 0:$},[H,B,c]),W=x.shape!=="table"&&P!==void 0;return(0,t.jsxs)("section",{"aria-labelledby":b,className:"graview-kind-stop","data-testid":"kind-stop","data-graview-kind-stop":e,"data-graview-shape":x.shape,children:[(0,t.jsx)("style",{children:St}),(0,t.jsx)(wt,{kind:e,plural:y,count:m.length,headingId:b,description:r?.description}),(0,t.jsx)(ht,{kind:e,plural:y,members:m,today:h,arrangement:v,onArrange:K}),(m.length>1||a>0)&&!W?(0,t.jsx)(Pe,{schema:l,graph:i.graph,kind:e,arrangement:v,onChange:K,offers:I,...M?{filters:M}:{},kept:{shown:T.nodes.length,of:m.length},testId:"kind-arrange",chips:{nodes:m,flagged:R,today:h},...a>0?{past:{count:a,widen:()=>u(Ee(g,!0))}}:{}}):null,m.length>0?(0,t.jsx)(yt,{derived:A,shape:x,draft:P}):null,(0,t.jsx)("div",{className:"graview-kind-stop-body","data-testid":"kind-stop-body",children:m.length===0?(0,t.jsx)("p",{className:"graview-kind-stop-empty","data-testid":"kind-stop-empty",children:"Nothing here yet."}):W?(0,t.jsx)(kt,{draft:P,nodes:m}):T.nodes.length===0?(0,t.jsxs)("p",{className:"graview-kind-stop-empty","data-testid":"kind-stop-none-kept",children:["None of the ",D(m.length)," ",y.toLowerCase()," ",v.query?`says \u201C${v.query}\u201D`:"is kept by these filters","."," ",(0,t.jsx)("button",{type:"button",className:"graview-kind-stop-link",onClick:()=>K({}),children:"Show them all"})]}):(0,t.jsx)(xt,{kind:e,nodes:T.nodes,groups:T.grouped?T.groups.map($=>({key:$.key,label:$.label,nodes:$.nodes})):void 0,flagged:R,plural:y,arrangement:v})})]})}function wt({kind:e,plural:n,count:o,headingId:p,description:a}){let{store:i,setSelection:s,setMenuAt:c}=V(),S=(0,f.useMemo)(()=>({about:[U(e)]}),[e]),{affordances:g}=Me(S),{apply:u,preview:w}=Le(),l=(0,f.useMemo)(()=>{let x=k=>i.allMutations().find(C=>C.name===k.mutation)?.creates?.includes(e)??!1;return g.find(k=>!k.destructive&&!k.setsAside&&x(k))},[g,i,e]),[r,y]=(0,f.useState)(!1),[h,m]=(0,f.useState)(null),b=(0,f.useRef)(null),A=(0,f.useRef)(null);(0,f.useEffect)(()=>{let x=A.current;!x||x.closest('[data-testid="kind-stop"]')?.contains(document.activeElement)||x.focus({preventScroll:!0})},[e]);let O=(x,k)=>{try{w(x,k),u(x,k),m(null),y(!1),requestAnimationFrame(()=>b.current?.focus())}catch(C){return m(be(i.schema,i.allMutations(),C)),[]}};return(0,t.jsxs)("header",{className:"graview-kind-stop-head",children:[(0,t.jsxs)("div",{className:"graview-kind-stop-title",children:[(0,t.jsx)("h2",{id:p,ref:A,tabIndex:-1,"data-testid":"kind-stop-title",children:n}),(0,t.jsxs)("p",{"data-testid":"kind-stop-count",children:[le(i.schema,e,o),a?` \xB7 ${a}`:""]})]}),(0,t.jsxs)("div",{className:"graview-kind-stop-acts",children:[l?(0,t.jsx)("button",{ref:b,type:"button",className:"graview-kind-stop-primary","data-testid":"kind-stop-primary","data-affordance":l.id,"aria-expanded":l.open.length>0?r:void 0,onClick:()=>{m(null),l.open.length===0?O(l):y(x=>!x)},children:l.label}):null,(0,t.jsx)("button",{type:"button",className:"graview-kind-stop-quiet","data-testid":"kind-stop-acts","aria-haspopup":"menu","aria-label":`What can be done with the ${n.toLowerCase()}`,onClick:x=>{let k=x.currentTarget.getBoundingClientRect();s([U(e)]),c({x:Math.round(k.left),y:Math.round(k.bottom+4),on:U(e)})},children:"Acts\u2026"})]}),r&&l?(0,t.jsx)("div",{className:"graview-kind-stop-ask","data-testid":"kind-stop-ask","aria-label":l.label,role:"group",children:(0,t.jsx)(xe,{affordance:l,onApply:x=>O(l,x),onCancel:()=>{y(!1),b.current?.focus()}})}):null,h?(0,t.jsx)("p",{role:"alert",className:"graview-kind-stop-failed","data-testid":"kind-stop-failed",children:h}):null]})}var vt=J.part((e,n)=>(0,t.jsx)(e.ProblemRows,{...n}),{what:"The problems",as:"li"});function ht({kind:e,plural:n,members:o,today:p,arrangement:a,onArrange:i}){let{store:s,brand:c,setSelection:S}=V(),g=s.schema,u=ee(),w=(0,f.useMemo)(()=>new Set(o.map(v=>v.id)),[o]),l=(0,f.useMemo)(()=>Ue(u,w,v=>s.allInvariants().find(R=>R.name===v)?.label),[u,w,s]),r=(0,f.useMemo)(()=>Je(g,e,o,p),[g,e,o,p]),y=ct(Ce(c,g),e),[h]=(0,f.useState)(()=>gt(y));(0,f.useEffect)(()=>()=>ut(y,new Date().toISOString()),[y]);let m=X(),b=(0,f.useMemo)(()=>h?Qe(s.log.all(),e,h,v=>s.graph.getNode(v)?.kind):null,[h,s,e,m]),[A,O]=(0,f.useState)(null),x=v=>i({...a,filter:[...(a.filter??[]).filter(R=>!v?.some(T=>T.key===R.key)),...v??[]]}),k=l.reduce((v,R)=>v+R.violations.length,0),C=[];if(r&&(r.overdue>0||r.soon>0)){let v=r.field;C.push((0,t.jsxs)("li",{"data-testid":"kind-stop-dates",children:[r.overdue>0?(0,t.jsxs)("button",{type:"button",className:"graview-kind-stop-fact","data-tone":"warn",onClick:()=>x(oe(r,"overdue",p)),"aria-label":`${D(r.overdue)} overdue \u2014 show only these`,children:[D(r.overdue)," overdue"]}):null,r.soon>0?(0,t.jsxs)("button",{type:"button",className:"graview-kind-stop-fact",onClick:()=>x(oe(r,"soon",p)),"aria-label":`${D(r.soon)} in the next 7 days \u2014 show only these`,children:[D(r.soon)," ",r.due?"due":""," in the next 7 days"]}):null,(0,t.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:[" by ",ce(g.tryDefinition(e),v).toLowerCase()]})]},"dates"))}if(l.length>0&&C.push((0,t.jsxs)("li",{"data-testid":"kind-stop-problems","data-graview-problems":k,children:[(0,t.jsxs)("span",{className:"graview-kind-stop-warn",children:[(0,t.jsx)("span",{"aria-hidden":"true",children:"\u26A0 "}),k===1?"1 problem":`${D(k)} problems`]}),(0,t.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:[" in ",n.toLowerCase(),":"]}),(0,t.jsx)("ul",{className:"graview-kind-stop-rules",children:l.map(v=>(0,t.jsx)(mt,{group:v,open:A===v.invariant,onToggle:()=>O(R=>R===v.invariant?null:v.invariant),onPick:R=>S([R])},v.invariant))}),(0,t.jsxs)("button",{type:"button",className:"graview-kind-stop-link","data-testid":"kind-stop-only-problems",onClick:()=>x([{key:"is",value:"flagged"}]),children:["Show only the ",n.toLowerCase()," with a problem"]})]},"problems")),b&&(b.added>0||b.changed>0)){let v=[b.added>0?`${D(b.added)} added`:"",b.changed>0?`${D(b.changed)} changed`:""].filter(Boolean);C.push((0,t.jsxs)("li",{"data-testid":"kind-stop-since",children:[(0,t.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:["Since you last looked (",de(h.slice(0,10)),"):"]})," ",v.join(", ")]},"since"))}return C.length===0?null:(0,t.jsx)("ul",{className:"graview-kind-stop-going-on","aria-label":`What is going on in the ${n.toLowerCase()}`,"data-testid":"kind-stop-going-on",children:C})}function mt({group:e,open:n,onToggle:o,onPick:p}){let a=(0,f.useId)();return(0,t.jsxs)("li",{"data-graview-rule":e.invariant,children:[(0,t.jsxs)("button",{type:"button",className:"graview-kind-stop-rule","aria-expanded":n,"aria-controls":a,onClick:o,onPointerEnter:J.prefetch,onFocus:J.prefetch,children:[(0,t.jsx)("span",{"aria-hidden":"true",className:"graview-kind-stop-chevron","data-open":n||void 0,children:"\u203A"}),e.label," ",(0,t.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:["\xB7 ",D(e.violations.length)]})]}),n?(0,t.jsx)("ol",{id:a,className:"graview-kind-stop-problem-rows","data-testid":"kind-stop-problem-rows",children:(0,t.jsx)(f.Suspense,{fallback:null,children:(0,t.jsx)(vt,{violations:e.violations,pick:i=>{let s=i.subjectId??e.records[0]??i.nodeIds[0];s!==void 0&&p(s)}})})}):null]})}var bt={board:"Board",calendar:"Calendar",table:"Table"};function yt({derived:e,shape:n,draft:o}){let{view:p}=V(),{go:a}=Y(),{keep:i}=qe(Be()),[s,c]=(0,f.useState)(!1),S=e.shape==="table"?[]:[e.shape,"table"];return(0,t.jsxs)("div",{className:"graview-kind-stop-shape","data-testid":"kind-stop-shape",children:[S.length>0?(0,t.jsx)("span",{role:"group","aria-label":"Show as",className:"graview-kind-stop-switch",children:S.map(g=>(0,t.jsx)("button",{type:"button","aria-pressed":n.shape===g,"data-testid":`kind-stop-as-${g}`,onClick:()=>a(ue(p,Xe,g===e.shape?null:g)),children:bt[g]},g))}):null,(0,t.jsx)("span",{className:"graview-kind-stop-quiet-text","data-testid":"kind-stop-derived",children:o?`${o.said.replace(/\.$/,"")}, derived from the declaration`:"Derived from the declaration"}),o?(0,t.jsx)("button",{type:"button",className:"graview-kind-stop-link","data-testid":"kind-stop-keep",disabled:s,title:`Keep \u201C${o.title}\u201D as a lens: a place of its own`,onClick:()=>{c(!0),i(o).finally(()=>c(!1))},children:"Keep as a lens"}):null]})}function kt({draft:e,nodes:n}){let o=Ve(e.drawn);return(0,t.jsx)("div",{className:"graview-kind-stop-lens","data-graview-draft":e.lens.name,children:(0,t.jsx)(ve,{mode:"scene",children:(0,t.jsx)(ke,{kind:e.kind,view:e.title,children:(0,t.jsx)(o,{nodes:n,label:e.title,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1})})})})}function xt({kind:e,nodes:n,groups:o,flagged:p,plural:a,arrangement:i}){let{store:s,views:c,view:S,selection:g,setSelection:u,setMenuAt:w,principal:l}=V(),{go:r}=Y(),y=s.schema,h=s.graph,m=(0,f.useMemo)(()=>(o?o.flatMap(d=>d.nodes):n).map(d=>d.id),[n,o]),b=Ie(m),A=(0,f.useMemo)(()=>s.permittedMutations(l).some(d=>{let N=d.subject?.kinds;return N!==void 0&&(N==="*"||N.includes(e))}),[s,l,e]),O=(0,f.useRef)(null),x=d=>{b.choose(d),requestAnimationFrame(()=>{let N=b.list.current;((d[0]===void 0?null:N?.querySelector(`[data-graview-choose-box="${CSS.escape(d[0])}"]`))??N)?.focus({preventScroll:!0})})},k=b.chosen.length,C=c.lookup(e,{cardinality:"one",fidelity:"glyph"}),v=C!==void 0&&!he(C)?C:void 0,R=d=>g.includes(d),T=ee(),I=(0,f.useMemo)(()=>We(y,e,n,h),[y,e,n,h]),[M,K]=(0,f.useState)(z);(0,f.useEffect)(()=>K(z),[i.query,i.filter?.length,i.sort?.by,i.group?.by]);let B=y.tryDefinition(e),H=d=>T.filter(N=>N.nodeIds.includes(d)||N.subjectId===d).map(N=>N.message),P=i.sort?.by,W=`${a}${i.sort?`, in order of ${I.find(d=>d.key===P)?.label.toLowerCase()??P}`:""}`,$=M,et=d=>{let N=G(B,d),F=p.has(d.id)?H(d.id):[];return(0,t.jsxs)("tr",{"data-graview-pick":d.id,tabIndex:-1,"data-graview-record":d.id,"data-flagged":F.length>0||void 0,...A?{"data-graview-choose":d.id}:{},children:[A?(0,t.jsx)("td",{className:"graview-choose-at",children:(0,t.jsx)("input",{...b.boxProps(d.id,N),onPointerEnter:j,onFocus:j})}):null,(0,t.jsxs)("th",{scope:"row",className:"graview-kind-stop-name",children:[v?(0,t.jsx)("div",{"data-graview-pick":d.id,className:"graview-kind-stop-own-row",children:(0,t.jsx)(v,{node:d,cardinality:"one",fidelity:"glyph",mode:"scene",selected:R(d.id),...F.length>0?{flagged:[d.id]}:{}})}):(0,t.jsx)("button",{type:"button","data-testid":"kind-stop-row-go",title:`Go to ${N}`,onClick:()=>r(ft(S,d.id)),children:N}),F.length>0?(0,t.jsxs)("span",{className:"graview-kind-stop-flag",title:F.join(" \xB7 "),children:[(0,t.jsx)("span",{"aria-hidden":"true",children:"\u26A0"}),(0,t.jsx)("span",{className:"graview-kind-stop-hidden",children:`Problem: ${F.join(". ")}`})]}):null]}),I.map(_=>{let E=Ze(y,d,_,h);return(0,t.jsx)("td",{"data-label":_.label,"data-short":E.text.length>0&&E.text.length<=14||void 0,"data-empty":E.text?void 0:"",...E.title?{title:E.title}:{},children:E.text?(0,t.jsx)("span",{children:E.text}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{"aria-hidden":"true",children:"\u2014"}),(0,t.jsx)("i",{className:"graview-kind-stop-hidden",children:"none"})]})},_.key)}),(0,t.jsx)("td",{className:"graview-kind-stop-row-acts",children:(0,t.jsx)("button",{type:"button","data-testid":"kind-stop-row-acts","aria-haspopup":"menu","aria-label":`What can be done with ${N}`,onClick:_=>{let E=_.currentTarget.getBoundingClientRect();u([d.id]),w({x:Math.round(E.left),y:Math.round(E.bottom+4),on:d.id})},children:(0,t.jsx)("span",{"aria-hidden":"true",children:"\u22EF"})})})]},d.id)},re=d=>{let N=d.slice(0,Math.max(0,$));return $-=N.length,N.map(et)};return(0,t.jsxs)("div",{className:"graview-kind-stop-table-at",...A?{...b.listProps,ref:d=>{O.current=d,b.list.current=d},tabIndex:-1,role:"group","aria-label":k>0?`${a}, ${k} chosen`:a,"data-graview-choosable":""}:{},children:[A?(0,t.jsx)("style",{children:Ke}):null,(0,t.jsxs)("table",{className:"graview-kind-stop-table","data-testid":"kind-stop-table",children:[(0,t.jsx)("caption",{className:"graview-kind-stop-hidden",children:W}),(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{children:[A?(0,t.jsx)("td",{className:"graview-choose-at graview-choose-all",children:(0,t.jsx)("input",{type:"checkbox",className:"graview-choose-box","data-testid":"kind-stop-choose-all","aria-label":`Choose all ${D(n.length)} ${a.toLowerCase()}`,checked:k>0&&k===n.length,ref:d=>{d&&(d.indeterminate=k>0&&k<n.length)},onPointerEnter:j,onFocus:j,onChange:()=>k===n.length?b.clear():b.choose(m)})}):null,(0,t.jsx)("th",{scope:"col","aria-sort":P==="label"?i.sort?.direction==="desc"?"descending":"ascending":void 0,children:"Name"}),I.map(d=>(0,t.jsx)("th",{scope:"col","aria-sort":d.about==="field"&&d.key===P?i.sort?.direction==="desc"?"descending":"ascending":void 0,children:d.label},d.key)),(0,t.jsx)("th",{scope:"col",children:(0,t.jsx)("span",{className:"graview-kind-stop-hidden",children:"Acts"})})]})}),o?o.map(d=>$<=0?null:(0,t.jsxs)("tbody",{"data-graview-group":d.key,children:[(0,t.jsx)("tr",{className:"graview-kind-stop-group",children:(0,t.jsxs)("th",{scope:"rowgroup",colSpan:I.length+(A?3:2),children:[d.label," ",(0,t.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:["\xB7 ",D(d.nodes.length)]})]})}),re(d.nodes)]},d.key||"-")):(0,t.jsx)("tbody",{children:re(n)})]}),A?(0,t.jsx)(Fe,{store:s,chosen:b.chosen,principal:l,anchor:()=>O.current?.closest('[data-testid="kind-stop"]')??null,of:m.length,onChooseAll:()=>b.choose(m),onClear:b.clear,onActed:x}):null,n.length>M?(0,t.jsxs)("p",{className:"graview-kind-stop-more",children:[(0,t.jsxs)("span",{className:"graview-kind-stop-quiet-text","data-testid":"kind-stop-shown",children:[D(M)," of ",D(n.length)," shown"]})," ",(0,t.jsxs)("button",{type:"button",className:"graview-kind-stop-link","data-testid":"kind-stop-more",onClick:()=>K(d=>d+z),children:["Show ",D(Math.min(z,n.length-M))," more"]})]}):null]})}var St=`
2
+ .graview-kind-stop{container-type:inline-size;box-sizing:border-box;height:100%;min-height:0;display:flex;flex-direction:column;gap:10px;padding:16px 18px 12px;border:1px solid var(--graview-edge);border-radius:var(--graview-radius,12px);background:var(--graview-panel);color:var(--graview-ink);box-shadow:var(--graview-lift-low);overflow:auto;overscroll-behavior:contain}
3
+ [data-graview-map-panel] .graview-kind-stop{height:auto;padding:4px 6px 12px;border:0;box-shadow:none;background:none;overflow:visible}
4
+ .graview-kind-stop :focus-visible{outline:2px solid var(--graview-accent);outline-offset:2px}
5
+ .graview-kind-stop button{font:inherit;cursor:pointer}
6
+ .graview-kind-stop :is(.graview-kind-stop-link,.graview-kind-stop-rule,.graview-kind-stop-name button,.graview-kind-stop-row-acts button,.graview-kind-stop-fact,.graview-kind-stop-switch button){box-shadow:none}
7
+ .graview-kind-stop-head{display:flex;flex-wrap:wrap;align-items:flex-start;gap:8px 16px}
8
+ .graview-kind-stop-title{flex:1 1 16rem;min-width:0}
9
+ .graview-kind-stop-title h2{margin:0;outline-offset:2px;font-size:var(--graview-text-heading);line-height:1.3;overflow-wrap:anywhere}
10
+ .graview-kind-stop-title p{margin:2px 0 0;font-size:.875rem;color:var(--graview-ink-muted);overflow-wrap:anywhere}
11
+ .graview-kind-stop-acts{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
12
+ .graview-kind-stop-primary,.graview-kind-stop-quiet{min-height:32px;padding:0 14px;border-radius:8px;font-size:.875rem}
13
+ .graview-kind-stop-primary{border:1px solid var(--graview-accent);background:var(--graview-accent);color:var(--graview-accent-ink);font-weight:600}
14
+ .graview-kind-stop-quiet{border:1px solid var(--graview-edge);background:transparent;color:var(--graview-ink)}
15
+ .graview-kind-stop-ask{flex:1 1 100%;min-width:0;padding:10px 12px;border:1px solid var(--graview-edge);border-radius:10px}
16
+ .graview-kind-stop-failed{flex:1 1 100%;margin:0;font-size:var(--graview-text-small);color:var(--graview-warn)}
17
+ .graview-kind-stop-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
18
+ .graview-kind-stop-going-on{list-style:none;margin:0;padding:0;display:grid;gap:6px;font-size:.875rem}
19
+ .graview-kind-stop-going-on>li{display:flex;flex-wrap:wrap;align-items:center;gap:4px 8px;min-width:0}
20
+ .graview-kind-stop-fact{min-height:28px;padding:0 10px;border:1px solid var(--graview-edge);border-radius:999px;background:transparent;color:var(--graview-ink)}
21
+ .graview-kind-stop-fact[data-tone=warn],.graview-kind-stop-warn{color:var(--graview-warn);font-weight:600}
22
+ .graview-kind-stop-quiet-text{color:var(--graview-ink-muted)}
23
+ .graview-kind-stop-rules{list-style:none;margin:0;padding:0;flex:1 1 100%;display:grid;gap:2px}
24
+ .graview-kind-stop-rule{display:inline-flex;align-items:center;gap:6px;min-height:28px;max-width:100%;padding:0 6px;border:1px solid transparent;border-radius:7px;background:none;color:var(--graview-ink);text-align:left;overflow-wrap:anywhere}
25
+ .graview-kind-stop-rule:hover{border-color:var(--graview-edge)}
26
+ .graview-kind-stop-chevron{display:inline-block;width:.8em}
27
+ .graview-kind-stop-chevron[data-open]{transform:rotate(90deg)}
28
+ .graview-kind-stop-problem-rows{list-style:none;margin:2px 0 6px 18px;padding:0;max-width:44rem}
29
+ .graview-kind-stop-link{min-height:28px;padding:0 4px;border:0;background:none;color:var(--graview-accent);text-decoration:underline;text-underline-offset:2px}
30
+ .graview-kind-stop-link:disabled{opacity:.6;cursor:default}
31
+ .graview-kind-stop-shape{display:flex;flex-wrap:wrap;align-items:center;gap:4px 10px;font-size:var(--graview-text-small)}
32
+ .graview-kind-stop-switch{display:inline-flex;border:1px solid var(--graview-edge);border-radius:8px;overflow:hidden}
33
+ .graview-kind-stop-switch button{min-height:28px;padding:0 12px;border:0;background:transparent;color:var(--graview-ink-muted)}
34
+ .graview-kind-stop-switch button+button{border-left:1px solid var(--graview-edge)}
35
+ .graview-kind-stop-switch button[aria-pressed=true]{background:color-mix(in srgb,var(--graview-accent) 16%,transparent);color:var(--graview-ink);font-weight:600}
36
+ .graview-kind-stop-body{flex:1 0 auto;min-width:0}
37
+ .graview-kind-stop-empty{margin:24px 0;color:var(--graview-ink-muted)}
38
+ .graview-kind-stop-lens{min-width:0}
39
+
40
+ .graview-kind-stop-table-at{min-width:0}
41
+ .graview-kind-stop-table{width:100%;border-collapse:collapse;font-size:.875rem}
42
+ .graview-kind-stop-table th,.graview-kind-stop-table td{padding:7px 8px;text-align:left;vertical-align:top;border-top:1px solid var(--graview-edge);overflow-wrap:break-word}
43
+ .graview-kind-stop-table td{color:var(--graview-ink)}
44
+ .graview-kind-stop-table td>span{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
45
+ .graview-kind-stop-table td[data-short]{white-space:nowrap;font-variant-numeric:tabular-nums}
46
+ .graview-kind-stop-table thead th{border-top:0;font-size:var(--graview-text-small);font-weight:600;letter-spacing:.04em;color:var(--graview-ink-muted)}
47
+ .graview-kind-stop-name{font-weight:500;min-width:8rem;max-width:22rem}
48
+ .graview-kind-stop-name button{display:inline-block;min-width:24px;min-height:24px;padding:0;border:0;background:none;color:var(--graview-ink);font-weight:500;text-align:left;text-decoration:underline;text-decoration-color:var(--graview-edge);text-underline-offset:3px}
49
+ .graview-kind-stop-name button:hover{text-decoration-color:currentColor}
50
+ .graview-kind-stop-own-row{display:inline-block;max-width:100%;cursor:pointer}
51
+ .graview-kind-stop-flag{margin-left:6px;color:var(--graview-warn)}
52
+ .graview-kind-stop-group th{padding-top:12px;font-weight:600;color:var(--graview-ink)}
53
+ .graview-kind-stop-row-acts{width:1%;white-space:nowrap;text-align:right}
54
+ .graview-kind-stop-row-acts button{min-width:32px;min-height:28px;border:1px solid var(--graview-edge-bright,var(--graview-edge));border-radius:7px;background:none;color:var(--graview-ink);font-size:1.125rem;font-weight:700;line-height:1}
55
+ .graview-kind-stop-row-acts button:hover{background:color-mix(in srgb,var(--graview-ink) 8%,transparent)}
56
+ .graview-kind-stop-table td[data-empty] b{font-weight:400;color:var(--graview-ink-faint)}
57
+ .graview-kind-stop-table tr[data-graview-pick]{cursor:default}
58
+ .graview-kind-stop-more{margin:10px 0 0;font-size:.875rem}
59
+ .graview-kind-stop-table-at[data-graview-choosable]{outline:none}
60
+ [data-graview-choosable]:hover .graview-choose-all .graview-choose-box{opacity:1}
61
+ .graview-kind-stop-table .graview-choose-at{width:1%;padding-right:0;vertical-align:middle}
62
+ @container (max-width: 559px){
63
+ .graview-kind-stop{padding:12px}
64
+ .graview-kind-stop-acts{flex:1 1 100%}
65
+ .graview-kind-stop-primary{flex:1 1 auto}
66
+ .graview-kind-stop-table thead{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
67
+ .graview-kind-stop-table,.graview-kind-stop-table tbody,.graview-kind-stop-table tr{display:block}
68
+ .graview-kind-stop-table tr{position:relative;padding:8px 40px 8px 0;border-top:1px solid var(--graview-edge)}
69
+ .graview-kind-stop-table th,.graview-kind-stop-table td{display:block;padding:1px 0;border:0}
70
+ .graview-kind-stop-table td>span{display:inline}
71
+ .graview-kind-stop-table td[data-short]{white-space:normal}
72
+ .graview-kind-stop-table td[data-label]::before{content:attr(data-label) " \xB7 ";color:var(--graview-ink-muted)}
73
+ .graview-kind-stop-row-acts{position:absolute;top:6px;right:0;width:auto}
74
+ .graview-kind-stop-table [data-graview-choose]{padding-left:34px}
75
+ .graview-kind-stop-table td.graview-choose-at{position:absolute;left:0;top:8px;width:auto;padding:0}
76
+ .graview-kind-stop-table thead .graview-choose-at{position:static}
77
+ }
78
+ @media (pointer: coarse){
79
+ .graview-kind-stop-table-at:not([data-graview-choosing]) .graview-choose-at{display:none}
80
+ .graview-kind-stop-table-at:not([data-graview-choosing]) [data-graview-choose]{padding-left:0}
81
+ }
82
+ @media (pointer: coarse){
83
+ .graview-kind-stop-primary,.graview-kind-stop-quiet,.graview-kind-stop-fact,.graview-kind-stop-rule,.graview-kind-stop-link,.graview-kind-stop-switch button,.graview-kind-stop-row-acts button{min-height:44px}
84
+ .graview-kind-stop-row-acts button{min-width:44px}
85
+ .graview-kind-stop-name button{min-height:44px}
86
+ }
87
+ @media (prefers-reduced-motion: reduce){.graview-kind-stop *{transition:none!important;animation:none!important}}
88
+ `;export{Jt as KindStop};
@@ -1,3 +1,3 @@
1
- import{B as y,Db as $,Hb as x,K as h,T as g,da as m}from"./chunk.5ZMENPY4.js";function B(n,e,t){let o=n?.display?.format?.[e];return o?o(t):typeof t=="string"?m(t):String(t)}function G(n,e,t,o){let s=n.tryDefinition(e)?.edges,i=s&&Object.hasOwn(s,t)?s[t]:void 0;return(o==="out"?i?.description:i?.inverse)??m(t).toLowerCase()}var O=Symbol.for("@graview/core:markdown");function S(n){let e=y(n);return!!e&&(e[O]===1||S(e.innerType))}var w=/^ {0,3}#{1,6}(?:[ \t]+|$)/,b=/^[ \t]*(?:[-*+•]|\d{1,9}[.)])[ \t]+(?:\[[ xX]\][ \t]+)?/,k=/^ {0,3}(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})$/,R=/^ {0,3}(?:`{3,}|~{3,})/,F=/^ {0,3}(?:>[ \t]?)+/,A=/^\|?\s*:?-{2,}:?\s*(?:\|\s*:?-{2,}:?\s*)*\|?$/,_={amp:"&",lt:"<",gt:">",quot:'"',"#39":"'",nbsp:" "};function E(n){return n.replace(/!?\[([^\]\n]{0,500})\]\([^)\n]{0,500}\)/g,"$1").replace(/<((?:https?:|mailto:)[^>\s]*)>/gi,"$1").replace(/<\/?[A-Za-z][^<>\n]*>/g,"").replace(/`+([^`\n]*)`+/g,"$1").replace(/(\*\*|__|~~)(?=\S)([^\n]{0,500}?\S)\1/g,"$2").replace(/(^|[^\w*])\*(?=\S)([^*\n]{0,500}?\S)\*(?![\w*])/g,"$1$2").replace(/(^|\W)_(?=\S)([^_\n]{0,500}?\S)_(?!\w)/g,"$1$2").replace(/\\([\\`*_{}[\]()#+\-.!>|~])/g,"$1").replace(/&(amp|lt|gt|quot|#39|nbsp);/g,(e,t)=>_[t]??"")}function N(n,e,t){let o=n.replace(/\r\n?/g,`
1
+ import{B as y,Eb as $,Ib as x,K as h,T as g,da as m}from"./chunk.V5MYKNL7.js";function B(n,e,t){let o=n?.display?.format?.[e];return o?o(t):typeof t=="string"?m(t):String(t)}function G(n,e,t,o){let s=n.tryDefinition(e)?.edges,i=s&&Object.hasOwn(s,t)?s[t]:void 0;return(o==="out"?i?.description:i?.inverse)??m(t).toLowerCase()}var O=Symbol.for("@graview/core:markdown");function S(n){let e=y(n);return!!e&&(e[O]===1||S(e.innerType))}var w=/^ {0,3}#{1,6}(?:[ \t]+|$)/,b=/^[ \t]*(?:[-*+•]|\d{1,9}[.)])[ \t]+(?:\[[ xX]\][ \t]+)?/,k=/^ {0,3}(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})$/,R=/^ {0,3}(?:`{3,}|~{3,})/,F=/^ {0,3}(?:>[ \t]?)+/,A=/^\|?\s*:?-{2,}:?\s*(?:\|\s*:?-{2,}:?\s*)*\|?$/,_={amp:"&",lt:"<",gt:">",quot:'"',"#39":"'",nbsp:" "};function E(n){return n.replace(/!?\[([^\]\n]{0,500})\]\([^)\n]{0,500}\)/g,"$1").replace(/<((?:https?:|mailto:)[^>\s]*)>/gi,"$1").replace(/<\/?[A-Za-z][^<>\n]*>/g,"").replace(/`+([^`\n]*)`+/g,"$1").replace(/(\*\*|__|~~)(?=\S)([^\n]{0,500}?\S)\1/g,"$2").replace(/(^|[^\w*])\*(?=\S)([^*\n]{0,500}?\S)\*(?![\w*])/g,"$1$2").replace(/(^|\W)_(?=\S)([^_\n]{0,500}?\S)_(?!\w)/g,"$1$2").replace(/\\([\\`*_{}[\]()#+\-.!>|~])/g,"$1").replace(/&(amp|lt|gt|quot|#39|nbsp);/g,(e,t)=>_[t]??"")}function N(n,e,t){let o=n.replace(/\r\n?/g,`
2
2
  `).split(`
3
3
  `),s=[],i=[],c=0,d=!1,u=()=>{let r=i.join(" ").replace(/\s+/g," ").trim();r&&(s.push(r),c+=r.length),i=[]},a=0;for(;a<o.length&&c<=t;){let r=o[a++];if(e&&R.test(r)){d=!d,d||u();continue}if(!d&&(r.trim().length===0||e&&(k.test(r)||A.test(r.trim())))){u();continue}let f=!d&&e&&w.test(r),l=!d&&b.test(r);if((f||l)&&u(),e&&!d?(r=r.replace(F,""),f&&(r=r.replace(w,"").replace(/[ \t]+#+[ \t]*$/,"")),l&&(r=r.replace(b,"")),r.includes("|")&&(r=r.replace(/^[ \t]*\||\|[ \t]*$/g,"").split("|").map(p=>p.trim()).filter(Boolean).join(" \xB7 ")),r=E(Number.isFinite(t)?r.slice(0,t*2+200):r)):l&&(r=r.replace(b,"")),i.push(r),f&&u(),i.reduce((p,T)=>p+T.length,0)>t)break}return u(),{blocks:s,more:o.slice(a).some(r=>r.trim().length>0&&!(e&&(R.test(r)||k.test(r))))}}function M(n,e){return`${(n.slice(0,e+1).replace(/\s+\S*$/,"")||n.slice(0,e)).replace(/[\s,;:.—-]+$/,"")}\u2026`}function Z(n,e={}){let t=e.most??160,{blocks:o,more:s}=N(n,e.markdown===!0,t),i=o[0]??"";if(i.length<=t)return(s||o.length>1)&&i.length>0&&!/[.!?…:]$/.test(i)?`${i}\u2026`:i;let c=x(i);return c&&c.length<=t?c:M(i,t)}var J=n=>N(n,!0,Number.POSITIVE_INFINITY).blocks.join(" ");var j={d:1440,h:60,m:1};function ne(n){if(typeof n=="number")return Number.isFinite(n)&&n>=0?Math.round(n):void 0;if(typeof n!="string")return;let e=n.trim().toLowerCase();if(/^\d+$/.test(e))return Number(e);let t=/^(\d+):([0-5]\d)(?::([0-5]\d))?$/.exec(e);if(t)return Number(t[1])*60+Number(t[2])+Math.round(Number(t[3]??0)/60);let o=0,s=!1,i=e.replace(/(\d*[.,]?\d+) *(days?|d|hours?|hrs?|hr|h|minutes?|mins?|min|m)(?![a-z])/g,(c,d,u)=>(s=!0,o+=Number(d.replace(",","."))*j[u[0]]," "));return s&&/^[\s,+]*(?:and[\s,+]*)*$/.test(i)?Math.round(o):void 0}function I(n,e){if(!Number.isFinite(n))return String(n);let t=Math.round(Math.abs(n)),o=Math.floor(t/60),s=t%60,i=[o?`${g(o,e)} h`:"",s||!o?`${g(s,e)} min`:""].filter(Boolean).join(" ");return n<0?`\u2212${i}`:i}var D=/^(\+?1[ .-]?)?\(?([2-9]\d\d)\)?[ .-]?(\d{3})[ .-]?(\d{4})(?: *(?:ext\.?|x|#) *(\d+))?$/i;function W(n,e){let t=n.trim(),o=/[-_](US|CA)\b/i.test(h(e))?D.exec(t):null;if(!o)return t;let[,s,i,c,d,u]=o;return`${s?.startsWith("+")?"+1 ":""}(${i}) ${c}-${d}${u?` ext. ${u}`:""}`}function P(n){let[,e="",t]=/^(.*?)(?: *(?:ext\.?|x|#) *(\d+))?$/i.exec(n.trim())??[],o=e.replace(/\D/g,"");return o.length<3?void 0:`tel:${e.startsWith("+")?"+":""}${o}${t?`;ext=${t}`:""}`}var L=()=>/Mac|iPhone|iPad|iPod/.test(globalThis.navigator?.userAgent??"");function q(n,e=L()){let t=encodeURIComponent(n.trim());return e?`https://maps.apple.com/?q=${t}`:`https://www.google.com/maps/search/?api=1&query=${t}`}var C=n=>n?.fields?.shape??{},U=(n,e)=>{let t=C(n);return Object.hasOwn(t,e)?$(t[e]):void 0},H=(n,e)=>{let t=n.computed,o=t&&Object.hasOwn(t,e)?t[e]:void 0;return typeof o=="object"?o.as:void 0};function te(n,e){return U(n,e)??(n&&H(n,e)==="duration"?"duration":void 0)}function re(n,e,t){return n==="duration"?typeof e=="number"?I(e,t):void 0:n==="phone"?typeof e=="string"?W(e,t):void 0:n==="place"&&typeof e=="string"?e.trim():void 0}function oe(n,e){if(!(typeof e!="string"||!e.trim()))return n==="phone"?P(e):n==="place"?q(e):void 0}export{S as a,B as b,G as c,Z as d,J as e,ne as f,te as g,re as h,oe as i};
@@ -1,4 +1,4 @@
1
- import{o as N}from"./chunk.ORXFUK6F.js";import{$ as x,G as $,R as f,_ as h}from"./chunk.BTSXYZ6Z.js";import"./chunk.SDO3U72B.js";import{Mc as w,Nc as p,Oc as g,Vc as b}from"./chunk.5ZMENPY4.js";import{b as c}from"./chunk.AJZBJBMO.js";var s=c($(),1);var i=c(f(),1),P=()=>()=>{};function S(e){let n=(0,s.useMemo)(()=>e?.onChange?o=>e.onChange(o):P,[e]),t=()=>e?.current()??p;return(0,s.useSyncExternalStore)(n,t,t)}var R=(e,n)=>e.lens?n.may.lenses:n.may.views;async function v(e,n,t){try{return await n(),!0}catch(o){return e?.notify({kind:"toast",tone:"bad",sentence:o instanceof Error&&o.message?o.message:t}),!1}}function B(e,n,t,o,d){let a=e.name;return v(d,()=>n==="view"&&a!==void 0?o?t.hide(a):t.show(a):t.lens?.({op:"set-lens-hidden",title:e.title,on:e.kind,hidden:o}),o?`\u201C${e.title}\u201D could not be hidden.`:`\u201C${e.title}\u201D could not be shown.`)}function k(e,n,t){return v(t,()=>n.restore(e.name),`\u201C${e.title}\u201D could not be restored.`)}async function H(e,n,t,o){let d=n==="view"&&e.name!==void 0?e.name:w(e.title),a=await v(o,()=>n==="view"&&e.name!==void 0?t.remove(e.name,{title:e.title,kind:e.kind}):t.lens?.({op:"remove-lens",title:e.title,on:e.kind}),`\u201C${e.title}\u201D could not be deleted.`);return a&&o?.notify({kind:"toast",id:`deleted-view-${d}`,sentence:`Deleted \u201C${e.title}\u201D. It is under Recently deleted in the places for ${30} days.`,action:{label:"Restore",onSelect:()=>void k({name:d,title:e.title},t,o)}}),a}function E(){let e=x(),n=e?.keptViews,t=S(n),o=e?.views;return(0,s.useMemo)(()=>{if(!n||!o)return null;let d=r=>g(r,t,n),a=new Set,u=o.places().filter(r=>{if(!r.hidden||d(r)===null)return!1;let m=`${r.name??""}|${r.title}`;return a.has(m)?!1:(a.add(m),!0)});return{keeper:n,hidden:u,removed:t.removed.filter(r=>R(r,t)),how:d}},[n,t,o])}function C(e,n){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(n??"en-US",{month:"short",day:"numeric"})}var D=`.graview-bar-list li.graview-bar-tidied{display:flex;align-items:flex-start;gap:8px;padding:0 0 0 2px}
1
+ import{o as N}from"./chunk.JHEVGLKB.js";import{$ as x,G as $,R as f,_ as h}from"./chunk.FOQZADMA.js";import"./chunk.SDO3U72B.js";import{Oc as w,Pc as p,Qc as g,Xc as b}from"./chunk.V5MYKNL7.js";import{b as c}from"./chunk.AJZBJBMO.js";var s=c($(),1);var i=c(f(),1),P=()=>()=>{};function S(e){let n=(0,s.useMemo)(()=>e?.onChange?o=>e.onChange(o):P,[e]),t=()=>e?.current()??p;return(0,s.useSyncExternalStore)(n,t,t)}var R=(e,n)=>e.lens?n.may.lenses:n.may.views;async function v(e,n,t){try{return await n(),!0}catch(o){return e?.notify({kind:"toast",tone:"bad",sentence:o instanceof Error&&o.message?o.message:t}),!1}}function B(e,n,t,o,d){let a=e.name;return v(d,()=>n==="view"&&a!==void 0?o?t.hide(a):t.show(a):t.lens?.({op:"set-lens-hidden",title:e.title,on:e.kind,hidden:o}),o?`\u201C${e.title}\u201D could not be hidden.`:`\u201C${e.title}\u201D could not be shown.`)}function k(e,n,t){return v(t,()=>n.restore(e.name),`\u201C${e.title}\u201D could not be restored.`)}async function H(e,n,t,o){let d=n==="view"&&e.name!==void 0?e.name:w(e.title),a=await v(o,()=>n==="view"&&e.name!==void 0?t.remove(e.name,{title:e.title,kind:e.kind}):t.lens?.({op:"remove-lens",title:e.title,on:e.kind}),`\u201C${e.title}\u201D could not be deleted.`);return a&&o?.notify({kind:"toast",id:`deleted-view-${d}`,sentence:`Deleted \u201C${e.title}\u201D. It is under Recently deleted in the places for ${30} days.`,action:{label:"Restore",onSelect:()=>void k({name:d,title:e.title},t,o)}}),a}function E(){let e=x(),n=e?.keptViews,t=S(n),o=e?.views;return(0,s.useMemo)(()=>{if(!n||!o)return null;let d=r=>g(r,t,n),a=new Set,u=o.places().filter(r=>{if(!r.hidden||d(r)===null)return!1;let m=`${r.name??""}|${r.title}`;return a.has(m)?!1:(a.add(m),!0)});return{keeper:n,hidden:u,removed:t.removed.filter(r=>R(r,t)),how:d}},[n,t,o])}function C(e,n){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(n??"en-US",{month:"short",day:"numeric"})}var D=`.graview-bar-list li.graview-bar-tidied{display:flex;align-items:flex-start;gap:8px;padding:0 0 0 2px}
2
2
  .graview-bar-tidied>.graview-bar-item,.graview-bar-gone{flex:1 1 auto;min-width:0}
3
3
  .graview-bar-gone{display:grid;gap:1px;padding:7px 8px;font-size:.875rem;line-height:1.3;overflow-wrap:anywhere;color:var(--graview-ink-muted)}
4
4
  .graview-bar-gone small{font-size:.75rem}
@@ -1 +1 @@
1
- import"./chunk.WVUJXDXZ.js";import{b as C}from"./chunk.KJNUZYXS.js";import"./chunk.4BBJ62ZO.js";import"./chunk.UCZR33MK.js";import"./chunk.CC47O2DW.js";import"./chunk.2IX3CZNP.js";import"./chunk.6DHHUBSC.js";import"./chunk.Z7JRBKA7.js";import{na as $,oa as E,pa as b,qa as k}from"./chunk.5ZMENPY4.js";import"./chunk.AJZBJBMO.js";function M(r,l,t){let p=r.getAttribute("data-record")??"",g=r.getAttribute("data-field")??"",e=Number(r.getAttribute("data-index")??"0"),c=[...l?.node?[l.node]:[],...l?.nodes??[]].find(a=>a.id===p);if(!p||!c)return{why:p?`names a record it was not shown ("${p.slice(0,80)}")`:"names no record (data-record)"};let s=g&&Object.hasOwn(c,g)?c[g]:void 0,o=(Array.isArray(s)?s:[s]).filter($),u=Number.isInteger(e)&&e>=0?o[e]:void 0,n=c.label?`"${c.label}"`:"a record";return g?u?(t==="video"?!b(u):!b(u)&&!E(u))?{why:`names "${u.name}" on ${n}, which is not ${t==="video"?"a video":"a picture or a video"}`}:{file:u,on:c}:{why:o.length===0?`names "${g}" on ${n}, which holds no file it was shown`:`names file ${r.getAttribute("data-index")} of "${g}" on ${n}, which holds ${o.length}`}:{why:`names no field of ${n} (data-field)`}}var A=r=>`${r.caption?.trim()||r.name}, ${k(r)}`;function T(r,l,t,p,g){let e=r.createElement("video");e.setAttribute("data-graview-video",""),e.setAttribute("controls",""),e.setAttribute("preload","metadata"),e.setAttribute("playsinline",""),e.setAttribute("aria-label",A(t));let c=t.poster?p(t.poster):void 0;c&&e.setAttribute("poster",c),t.width&&t.height?(e.setAttribute("width",String(t.width)),e.setAttribute("height",String(t.height)),e.style.aspectRatio=`${t.width} / ${t.height}`):e.style.aspectRatio="16 / 9",e.style.cssText+=";display:block;width:100%;height:auto;max-height:80vh;background:#000;border-radius:var(--graview-radius, 8px)";let s=t.captions?p(t.captions):void 0;if(s){let o=r.createElement("track");o.setAttribute("kind","captions"),o.setAttribute("src",s),o.setAttribute("srclang","en"),o.setAttribute("label","Captions"),o.setAttribute("default",""),e.appendChild(o)}return t.duration===void 0&&e.addEventListener("loadedmetadata",()=>Number.isFinite(e.duration)&&e.duration>0&&e.setAttribute("aria-label",A({...t,duration:e.duration}))),e.setAttribute("src",g),l.appendChild(e),e}function N(r,l){let t=r.document,p=new Set,g=n=>{p.has(n)||(p.add(n),l.onProblem?.(n))},e=n=>{let a=l.file?l.file(n):n;if(a!==void 0)try{let h=new r.URL(a,t.baseURI);return h.origin===r.location.origin&&/^https?:$/.test(h.protocol)?a:void 0}catch{return}},c=new WeakMap,s,o=n=>{if(typeof n.close=="function")return n.close();n.removeAttribute("open"),n.dispatchEvent(new r.Event("close"))},u=(n,a)=>g(`The ${n} in the view ${l.view} was not drawn: it ${a}.`);return{refresh(n){let a=l.shown();for(let h of Array.from(n.querySelectorAll("graview-video"))){let d=h.shadowRoot??h.attachShadow({mode:"open"});if(!l.pictures){c.delete(h),d.replaceChildren(),u("video",`asks for no pictures: a view places a record's video where its manifest says "pictures": true`);continue}let f=M(h,a,"video"),i="file"in f?JSON.stringify(f.file):"";if(c.get(h)===i&&d.childNodes.length>0)continue;if(c.set(h,i),d.replaceChildren(),"why"in f){u("video",f.why);continue}let m=e(f.file.href);if(!m){u("video",`names "${f.file.name}", which this host does not say it serves on this page`);continue}let w=t.createElement("style");w.textContent=":host { display: block; min-width: 0; }",d.appendChild(w),T(t,d,f.file,e,m)}},open(n){if(!l.pictures)return u("full-screen viewer",`asks for no pictures: a view opens a record's picture or video full screen where its manifest says "pictures": true`),!1;let a=M(n,l.shown(),"any");if("why"in a)return u("full-screen viewer",a.why),!1;let h=e(a.file.href);if(!h)return u("full-screen viewer",`names "${a.file.name}", which this host does not say it serves on this page`),!1;s&&o(s);let d=a.file,f=d.caption?.trim()||d.name,i=t.createElement("dialog");i.setAttribute("data-graview-lightbox",""),i.setAttribute("aria-label",b(d)?A(d):f),i.style.cssText="padding:0;border:0;border-radius:var(--graview-radius, 8px);max-width:min(96vw, 1600px);max-height:94vh;background:var(--graview-panel, Canvas);color:var(--graview-ink, CanvasText)";let m=t.createElement("figure");if(m.style.cssText="margin:0;display:grid;gap:8px;padding:10px",b(d))T(t,m,d,e,h);else{let v=t.createElement("img");v.setAttribute("src",h),v.setAttribute("alt",f),v.style.cssText="max-width:100%;max-height:80vh;object-fit:contain;display:block;margin:0 auto",m.appendChild(v)}let w=t.createElement("figcaption");w.style.cssText="display:flex;gap:12px;align-items:center;justify-content:space-between";let x=t.createElement("span");x.textContent=b(d)&&d.duration!==void 0?`${f} \xB7 ${C(d.duration)}`:f;let y=t.createElement("button");return y.type="button",y.textContent="Close",y.addEventListener("click",()=>o(i)),w.append(x,y),m.appendChild(w),i.appendChild(m),i.addEventListener("click",v=>v.target===i&&o(i)),i.addEventListener("close",()=>{i.remove(),s===i&&(s=void 0),n.focus?.()}),t.body.appendChild(i),s=i,typeof i.showModal=="function"?i.showModal():i.setAttribute("open",""),y.focus(),!0},dispose(){s&&o(s),s?.remove(),s=void 0}}}export{N as createGuestMedia,M as namedFile};
1
+ import"./chunk.WVUJXDXZ.js";import{b as C}from"./chunk.N6MVK3KD.js";import"./chunk.I7XSDXQ3.js";import"./chunk.UHI3D7JC.js";import"./chunk.WVDKYUF3.js";import"./chunk.ZHLQWMV5.js";import"./chunk.TNESS3LQ.js";import"./chunk.2RVUDRRY.js";import{na as $,pa as E,qa as b,ra as k}from"./chunk.V5MYKNL7.js";import"./chunk.AJZBJBMO.js";function M(r,l,t){let p=r.getAttribute("data-record")??"",g=r.getAttribute("data-field")??"",e=Number(r.getAttribute("data-index")??"0"),c=[...l?.node?[l.node]:[],...l?.nodes??[]].find(a=>a.id===p);if(!p||!c)return{why:p?`names a record it was not shown ("${p.slice(0,80)}")`:"names no record (data-record)"};let s=g&&Object.hasOwn(c,g)?c[g]:void 0,o=(Array.isArray(s)?s:[s]).filter($),u=Number.isInteger(e)&&e>=0?o[e]:void 0,n=c.label?`"${c.label}"`:"a record";return g?u?(t==="video"?!b(u):!b(u)&&!E(u))?{why:`names "${u.name}" on ${n}, which is not ${t==="video"?"a video":"a picture or a video"}`}:{file:u,on:c}:{why:o.length===0?`names "${g}" on ${n}, which holds no file it was shown`:`names file ${r.getAttribute("data-index")} of "${g}" on ${n}, which holds ${o.length}`}:{why:`names no field of ${n} (data-field)`}}var A=r=>`${r.caption?.trim()||r.name}, ${k(r)}`;function T(r,l,t,p,g){let e=r.createElement("video");e.setAttribute("data-graview-video",""),e.setAttribute("controls",""),e.setAttribute("preload","metadata"),e.setAttribute("playsinline",""),e.setAttribute("aria-label",A(t));let c=t.poster?p(t.poster):void 0;c&&e.setAttribute("poster",c),t.width&&t.height?(e.setAttribute("width",String(t.width)),e.setAttribute("height",String(t.height)),e.style.aspectRatio=`${t.width} / ${t.height}`):e.style.aspectRatio="16 / 9",e.style.cssText+=";display:block;width:100%;height:auto;max-height:80vh;background:#000;border-radius:var(--graview-radius, 8px)";let s=t.captions?p(t.captions):void 0;if(s){let o=r.createElement("track");o.setAttribute("kind","captions"),o.setAttribute("src",s),o.setAttribute("srclang","en"),o.setAttribute("label","Captions"),o.setAttribute("default",""),e.appendChild(o)}return t.duration===void 0&&e.addEventListener("loadedmetadata",()=>Number.isFinite(e.duration)&&e.duration>0&&e.setAttribute("aria-label",A({...t,duration:e.duration}))),e.setAttribute("src",g),l.appendChild(e),e}function N(r,l){let t=r.document,p=new Set,g=n=>{p.has(n)||(p.add(n),l.onProblem?.(n))},e=n=>{let a=l.file?l.file(n):n;if(a!==void 0)try{let h=new r.URL(a,t.baseURI);return h.origin===r.location.origin&&/^https?:$/.test(h.protocol)?a:void 0}catch{return}},c=new WeakMap,s,o=n=>{if(typeof n.close=="function")return n.close();n.removeAttribute("open"),n.dispatchEvent(new r.Event("close"))},u=(n,a)=>g(`The ${n} in the view ${l.view} was not drawn: it ${a}.`);return{refresh(n){let a=l.shown();for(let h of Array.from(n.querySelectorAll("graview-video"))){let d=h.shadowRoot??h.attachShadow({mode:"open"});if(!l.pictures){c.delete(h),d.replaceChildren(),u("video",`asks for no pictures: a view places a record's video where its manifest says "pictures": true`);continue}let f=M(h,a,"video"),i="file"in f?JSON.stringify(f.file):"";if(c.get(h)===i&&d.childNodes.length>0)continue;if(c.set(h,i),d.replaceChildren(),"why"in f){u("video",f.why);continue}let m=e(f.file.href);if(!m){u("video",`names "${f.file.name}", which this host does not say it serves on this page`);continue}let w=t.createElement("style");w.textContent=":host { display: block; min-width: 0; }",d.appendChild(w),T(t,d,f.file,e,m)}},open(n){if(!l.pictures)return u("full-screen viewer",`asks for no pictures: a view opens a record's picture or video full screen where its manifest says "pictures": true`),!1;let a=M(n,l.shown(),"any");if("why"in a)return u("full-screen viewer",a.why),!1;let h=e(a.file.href);if(!h)return u("full-screen viewer",`names "${a.file.name}", which this host does not say it serves on this page`),!1;s&&o(s);let d=a.file,f=d.caption?.trim()||d.name,i=t.createElement("dialog");i.setAttribute("data-graview-lightbox",""),i.setAttribute("aria-label",b(d)?A(d):f),i.style.cssText="padding:0;border:0;border-radius:var(--graview-radius, 8px);max-width:min(96vw, 1600px);max-height:94vh;background:var(--graview-panel, Canvas);color:var(--graview-ink, CanvasText)";let m=t.createElement("figure");if(m.style.cssText="margin:0;display:grid;gap:8px;padding:10px",b(d))T(t,m,d,e,h);else{let v=t.createElement("img");v.setAttribute("src",h),v.setAttribute("alt",f),v.style.cssText="max-width:100%;max-height:80vh;object-fit:contain;display:block;margin:0 auto",m.appendChild(v)}let w=t.createElement("figcaption");w.style.cssText="display:flex;gap:12px;align-items:center;justify-content:space-between";let x=t.createElement("span");x.textContent=b(d)&&d.duration!==void 0?`${f} \xB7 ${C(d.duration)}`:f;let y=t.createElement("button");return y.type="button",y.textContent="Close",y.addEventListener("click",()=>o(i)),w.append(x,y),m.appendChild(w),i.appendChild(m),i.addEventListener("click",v=>v.target===i&&o(i)),i.addEventListener("close",()=>{i.remove(),s===i&&(s=void 0),n.focus?.()}),t.body.appendChild(i),s=i,typeof i.showModal=="function"?i.showModal():i.setAttribute("open",""),y.focus(),!0},dispose(){s&&o(s),s?.remove(),s=void 0}}}export{N as createGuestMedia,M as namedFile};
@@ -1 +1 @@
1
- import"./chunk.GZHZLJBF.js";import{n as D}from"./chunk.HHUCPVG5.js";import"./chunk.OJGHDWI6.js";import"./chunk.WXYUWBKX.js";import"./chunk.NSNGPQGT.js";import{a as $}from"./chunk.H5CZZZLX.js";import"./chunk.Z7JRBKA7.js";import"./chunk.ORXFUK6F.js";import{G as P,R as C}from"./chunk.BTSXYZ6Z.js";import"./chunk.SDO3U72B.js";import{Ka as w,Ma as R,Qa as c,X as S}from"./chunk.5ZMENPY4.js";import{b as k}from"./chunk.AJZBJBMO.js";var m=k(P(),1);var e=k(C(),1),W=[["","Does not repeat"],["day","Daily"],["week","Weekly"],["month","Monthly"],["year","Yearly"]],E=r=>`${r}${r%100>=11&&r%100<=13?"th":["th","st","nd","rd"][r%10]??"th"}`,v={display:"flex",flexWrap:"wrap",gap:"6px 12px",alignItems:"center"};function N({value:r,onChange:d,start:p,label:s,name:l="repeat"}){let f=(0,m.useId)(),a=c(r)?r:void 0,i=typeof p=="string"&&/^\d{4}-\d{2}-\d{2}/.test(p)?p:void 0,u=i?w[new Date(`${i.slice(0,10)}T00:00:00Z`).getUTCDay()]:void 0,o=t=>{let n={...a??{every:"week"},...t};for(let b of Object.keys(n))n[b]===void 0&&delete n[b];d(n)},y=a?.every??"week",g=a?.on??(u?[u]:[]);return(0,e.jsxs)("fieldset",{"data-graview-part":"field","data-graview-field":"repeat","data-graview-repeat":l,style:{display:"grid",gap:8,border:"1px solid var(--graview-edge)",borderRadius:8,padding:"8px 12px",margin:0,minWidth:0},children:[(0,e.jsx)("legend",{"data-graview-part":"label",style:{padding:"0 4px"},children:s}),(0,e.jsxs)("div",{style:v,children:[(0,e.jsx)("label",{htmlFor:`${f}-every`,children:"Repeats"}),(0,e.jsx)("select",{id:`${f}-every`,name:`${l}.every`,value:a?.every??"",onChange:t=>{let n=t.target.value;d(n===""?void 0:{...a?.interval?{interval:a.interval}:{},...a?.until?{until:a.until}:{},every:n})},"data-graview-part":"control",children:W.map(([t,n])=>(0,e.jsx)("option",{value:t,children:n},t))}),a?(0,e.jsxs)("label",{style:v,children:["every",(0,e.jsx)("input",{type:"number",min:1,max:99,name:`${l}.interval`,"aria-label":`Every how many ${y}s`,value:a.interval??1,onChange:t=>o({interval:Number(t.target.value)>1?Math.min(99,Math.round(Number(t.target.value))):void 0}),style:{width:"4.5em"},"data-graview-part":"control"}),y,(a.interval??1)>1?"s":""]}):null]}),a?.every==="week"?(0,e.jsxs)("div",{role:"group","aria-label":"On",style:v,children:[(0,e.jsx)("span",{"aria-hidden":"true",children:"On"}),w.map((t,n)=>(0,e.jsxs)("label",{style:{display:"inline-flex",gap:4,alignItems:"center",minHeight:24},children:[(0,e.jsx)("input",{type:"checkbox",name:`${l}.on`,value:t,checked:g.includes(t),onChange:b=>{let h=w.filter(x=>x===t?b.target.checked:g.includes(x));o({on:h.length===0||h.length===1&&h[0]===u?void 0:h})}}),S(n,"short")]},t))]}):null,a?.every==="month"?(0,e.jsxs)("label",{style:v,children:["On",(0,e.jsxs)("select",{name:`${l}.on`,value:a.on?.[0]===-1?"last":"",onChange:t=>o({on:t.target.value==="last"?[-1]:void 0}),"data-graview-part":"control",children:[(0,e.jsx)("option",{value:"",children:i?`the ${E(Number(i.slice(8,10)))}`:"the same day"}),(0,e.jsx)("option",{value:"last",children:"the last day"})]})]}):null,a?(0,e.jsxs)("label",{style:v,children:["Until",(0,e.jsx)("input",{type:"date",name:`${l}.until`,value:a.until??"",onChange:t=>o({until:t.target.value||void 0}),"data-graview-part":"control"})]}):null,(0,e.jsx)("p",{"aria-live":"polite","data-graview-repeat-said":"",style:{margin:0,color:"var(--graview-ink-dim)",fontSize:"0.8125rem"},children:a?$(i??"",a):"Does not repeat"})]})}function M({nodeId:r,field:d,start:p,value:s,label:l}){let{fields:f,commit:a}=D(r),i=f.find(t=>t.field===R(d)&&t.takesValue&&t.open.length===0),[u,o]=(0,m.useState)(!1),[y,g]=(0,m.useState)(c(s)?s:void 0);return i?u?(0,e.jsxs)("form",{onSubmit:t=>{t.preventDefault(),o(!1),a(i,y??null)},style:{display:"grid",gap:6,marginTop:6},children:[(0,e.jsx)(N,{value:y,onChange:g,start:p,label:l,name:R(d)}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("button",{type:"submit","data-graview-repeat-keep":d,children:"Keep"}),(0,e.jsx)("button",{type:"button",onClick:()=>o(!1),children:"Cancel"})]})]}):(0,e.jsx)("button",{type:"button","data-graview-repeat-open":d,onClick:()=>(g(c(s)?s:void 0),o(!0)),style:{marginInlineStart:8,fontSize:"0.75rem",padding:"1px 8px",borderRadius:999,minHeight:24},children:c(s)?"Change how it repeats":"Repeat\u2026"}):null}export{M as RepeatEditor,N as RepeatPicker};
1
+ import"./chunk.GZHZLJBF.js";import{n as D}from"./chunk.42XSBKPO.js";import"./chunk.OJGHDWI6.js";import"./chunk.6FNMDAX5.js";import"./chunk.2FLPDPEL.js";import{a as $}from"./chunk.UUBYFBPN.js";import"./chunk.2RVUDRRY.js";import"./chunk.JHEVGLKB.js";import{G as P,R as C}from"./chunk.FOQZADMA.js";import"./chunk.SDO3U72B.js";import{La as w,Na as R,Ra as c,X as S}from"./chunk.V5MYKNL7.js";import{b as k}from"./chunk.AJZBJBMO.js";var m=k(P(),1);var e=k(C(),1),W=[["","Does not repeat"],["day","Daily"],["week","Weekly"],["month","Monthly"],["year","Yearly"]],E=r=>`${r}${r%100>=11&&r%100<=13?"th":["th","st","nd","rd"][r%10]??"th"}`,v={display:"flex",flexWrap:"wrap",gap:"6px 12px",alignItems:"center"};function N({value:r,onChange:d,start:p,label:s,name:l="repeat"}){let f=(0,m.useId)(),a=c(r)?r:void 0,i=typeof p=="string"&&/^\d{4}-\d{2}-\d{2}/.test(p)?p:void 0,u=i?w[new Date(`${i.slice(0,10)}T00:00:00Z`).getUTCDay()]:void 0,o=t=>{let n={...a??{every:"week"},...t};for(let b of Object.keys(n))n[b]===void 0&&delete n[b];d(n)},y=a?.every??"week",g=a?.on??(u?[u]:[]);return(0,e.jsxs)("fieldset",{"data-graview-part":"field","data-graview-field":"repeat","data-graview-repeat":l,style:{display:"grid",gap:8,border:"1px solid var(--graview-edge)",borderRadius:8,padding:"8px 12px",margin:0,minWidth:0},children:[(0,e.jsx)("legend",{"data-graview-part":"label",style:{padding:"0 4px"},children:s}),(0,e.jsxs)("div",{style:v,children:[(0,e.jsx)("label",{htmlFor:`${f}-every`,children:"Repeats"}),(0,e.jsx)("select",{id:`${f}-every`,name:`${l}.every`,value:a?.every??"",onChange:t=>{let n=t.target.value;d(n===""?void 0:{...a?.interval?{interval:a.interval}:{},...a?.until?{until:a.until}:{},every:n})},"data-graview-part":"control",children:W.map(([t,n])=>(0,e.jsx)("option",{value:t,children:n},t))}),a?(0,e.jsxs)("label",{style:v,children:["every",(0,e.jsx)("input",{type:"number",min:1,max:99,name:`${l}.interval`,"aria-label":`Every how many ${y}s`,value:a.interval??1,onChange:t=>o({interval:Number(t.target.value)>1?Math.min(99,Math.round(Number(t.target.value))):void 0}),style:{width:"4.5em"},"data-graview-part":"control"}),y,(a.interval??1)>1?"s":""]}):null]}),a?.every==="week"?(0,e.jsxs)("div",{role:"group","aria-label":"On",style:v,children:[(0,e.jsx)("span",{"aria-hidden":"true",children:"On"}),w.map((t,n)=>(0,e.jsxs)("label",{style:{display:"inline-flex",gap:4,alignItems:"center",minHeight:24},children:[(0,e.jsx)("input",{type:"checkbox",name:`${l}.on`,value:t,checked:g.includes(t),onChange:b=>{let h=w.filter(x=>x===t?b.target.checked:g.includes(x));o({on:h.length===0||h.length===1&&h[0]===u?void 0:h})}}),S(n,"short")]},t))]}):null,a?.every==="month"?(0,e.jsxs)("label",{style:v,children:["On",(0,e.jsxs)("select",{name:`${l}.on`,value:a.on?.[0]===-1?"last":"",onChange:t=>o({on:t.target.value==="last"?[-1]:void 0}),"data-graview-part":"control",children:[(0,e.jsx)("option",{value:"",children:i?`the ${E(Number(i.slice(8,10)))}`:"the same day"}),(0,e.jsx)("option",{value:"last",children:"the last day"})]})]}):null,a?(0,e.jsxs)("label",{style:v,children:["Until",(0,e.jsx)("input",{type:"date",name:`${l}.until`,value:a.until??"",onChange:t=>o({until:t.target.value||void 0}),"data-graview-part":"control"})]}):null,(0,e.jsx)("p",{"aria-live":"polite","data-graview-repeat-said":"",style:{margin:0,color:"var(--graview-ink-dim)",fontSize:"0.8125rem"},children:a?$(i??"",a):"Does not repeat"})]})}function M({nodeId:r,field:d,start:p,value:s,label:l}){let{fields:f,commit:a}=D(r),i=f.find(t=>t.field===R(d)&&t.takesValue&&t.open.length===0),[u,o]=(0,m.useState)(!1),[y,g]=(0,m.useState)(c(s)?s:void 0);return i?u?(0,e.jsxs)("form",{onSubmit:t=>{t.preventDefault(),o(!1),a(i,y??null)},style:{display:"grid",gap:6,marginTop:6},children:[(0,e.jsx)(N,{value:y,onChange:g,start:p,label:l,name:R(d)}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("button",{type:"submit","data-graview-repeat-keep":d,children:"Keep"}),(0,e.jsx)("button",{type:"button",onClick:()=>o(!1),children:"Cancel"})]})]}):(0,e.jsx)("button",{type:"button","data-graview-repeat-open":d,onClick:()=>(g(c(s)?s:void 0),o(!0)),style:{marginInlineStart:8,fontSize:"0.75rem",padding:"1px 8px",borderRadius:999,minHeight:24},children:c(s)?"Change how it repeats":"Repeat\u2026"}):null}export{M as RepeatEditor,N as RepeatPicker};
@@ -1 +1 @@
1
- import{l as O}from"./chunk.OJGHDWI6.js";import{e as C}from"./chunk.NSNGPQGT.js";import{$ as I,G as x,R as M,_ as w,aa as W,c as V,ta as G,x as B}from"./chunk.BTSXYZ6Z.js";import{B as D,Gb as F,Mb as N,oc as _,pc as L,vc as j}from"./chunk.5ZMENPY4.js";import{b as m}from"./chunk.AJZBJBMO.js";function H(t,e){let n=t.graph.getNode(e);if(!n)return[];let i=n.kind,a=t.schema.tryDefinition(i);if(!a)return[];let c=t.seenFor,u=c?j.keptFrom?.(t,c)?.(n):void 0,o=new Map;for(let r of t.allMutations()){let s=r.subject;if(!s||!(s.kinds==="*"||s.kinds.includes(i)))continue;let l=r.input.shape??{};for(let d of N(r,a)){if(u?.(d))continue;let b=d in l,k=[];for(let h of Object.keys(l)){if(h===s.arg||h===d||X(l[h]))continue;let v=F(r.input).find(S=>S.name===h);k.push({name:h,...v?{kinds:v.kinds}:{},...v?{candidates:v.kinds.includes("*")?t.graph.allNodes().map(S=>S.id):v.kinds.flatMap(S=>t.graph.nodesOfKind(S).map(J=>J.id))}:{},shape:C(r.input,h)})}let Q={field:d,mutation:r.name,title:r.title??r.name,shape:b?C(r.input,d):{type:"unknown"},takesValue:b,alternatives:[],open:k,call:h=>({name:r.name,args:b?{[s.arg]:e,[d]:h}:{[s.arg]:e}})};o.set(d,[...o.get(d)??[],Q])}}return[...o.values()].map(r=>{let s=[...r.filter(d=>d.takesValue),...r.filter(d=>!d.takesValue)],[f,...l]=s;return{...f,alternatives:l}})}function X(t){let e=D(t)?.type;return e==="optional"||e==="default"||e==="nullable"}var R=m(x(),1);function be(t){let{store:e,principal:n}=w(),i=W(),a=(0,R.useMemo)(()=>t===null?[]:H(e,t),[e,t,i]),c=(0,R.useCallback)((u,o,r={})=>{let s=u.call(o);e.apply({name:s.name,args:{...s.args,...r}},{author:n})},[e,n]);return{fields:a,commit:c}}var K=m(x(),1);function Qe(){let{brand:t}=w(),e=t?.kit;return(0,K.useMemo)(()=>_(e),[e])}function Je(t,e){let n=L(t,e),i={...n.color!==void 0?{color:n.color}:{},...n.pattern!==void 0?{pattern:n.pattern}:{},...n.width!==void 0?{width:n.width}:{},...n.cap!==void 0?{cap:n.cap}:{},...n.opacity!==void 0?{opacity:n.opacity}:{}};return{connector:n,style:O(e,{[e]:i})}}var $=m(x(),1);var g=m(M(),1);function Z(t){let e=t?.hint;return typeof e=="string"&&e.length>0?e:void 0}function ee(t){if(t instanceof Error&&t.message)return t.message;let e=String(t);return e==="[object Object]"?"The view threw without a message.":e}var U=class extends $.Component{static contextType=G;state={};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,n){console.error(`[graview] the ${this.props.view??"view"} of ${this.props.kind} threw while rendering`,e,n.componentStack),this.context?.(e,{module:"@graview/react"})}render(){let{error:e}=this.state;if(!e)return this.props.children;let n=Z(e);return(0,g.jsxs)("div",{role:"alert","data-graview-view-error":this.props.kind,style:{display:"flex",flexDirection:"column",gap:"0.375rem",padding:"var(--graview-pad, 12px)",height:"100%",overflow:"auto",boxSizing:"border-box",borderRadius:"var(--graview-radius-sm, 6px)",background:"var(--graview-panel-warning, #fdf3ec)",color:"var(--graview-ink, #1a1a1a)",font:"var(--graview-font-body, 13px/1.45 system-ui)",fontSize:"0.875rem",lineHeight:1.45},children:[(0,g.jsx)("strong",{style:{color:"var(--graview-warn, #b4462a)"},children:this.props.view?`${this.props.view} could not draw`:"This view could not draw"}),(0,g.jsx)("span",{style:{color:"var(--graview-ink-muted, #555)"},children:this.props.kind}),(0,g.jsx)("span",{children:ee(e)}),n?(0,g.jsx)("span",{style:{color:"var(--graview-ink-muted, #555)"},children:n}):null]})}};var y=m(x(),1);var q=m(M(),1),A=(0,y.createContext)([]);function nt({sections:t,children:e}){let n=(0,y.useContext)(A),i=(0,y.useMemo)(()=>[...n,...t.filter(a=>!n.includes(a))],[n,t]);return(0,q.jsx)(A.Provider,{value:i,children:e})}function z(){let t=(0,y.useContext)(A),e=I()?.menuSections;return(0,y.useMemo)(()=>e?[...t,...e.filter(n=>!t.includes(n))]:t,[t,e])}function rt(){let t=z();return(0,y.useCallback)(e=>{for(let n of t)try{n(e)?.prepare?.()}catch{}},[t])}function ot(t){let e=z();if(t===null||e.length===0)return{start:[],end:[]};let n=e.flatMap(i=>{try{let a=i(t);return a&&((a.items?.length??0)>0||a.render)?[a]:[]}catch{return[]}});return{start:n.filter(i=>i.at==="start"),end:n.filter(i=>i.at!=="start")}}var te=m(x(),1);function st(){return w().activity}var P=(t,e)=>t.length*e*.58;var ne=156,re=2,E=ne-18,oe=7.1,ie=16;function ae(t,e){let n=0,i=E;for(let a of t.split(" ")){let c=e(a),u=i+e(" ")+c;if(u<=E)i=u;else{let o=Math.ceil(c/E)||1;n+=o,i=c-(o-1)*E}}return n}var se=16.25,Y=27,ce=(t,e)=>{let n=Math.ceil(t.length*oe/E);return e?Math.max(Y,Math.ceil(Math.max(n,ae(t,e))*se)+6):Math.max(Y,n*ie+6)};function ut(t,e,n){return t.length===0?0:10+t.reduce((i,a)=>i+ce(a,n),0)+(t.length-1)*re}var de=27,ue=8,lt=4,le=64,pt=t=>Math.max(1,Math.min(ue,t)),ft=t=>t*de+le;var p=m(x(),1);function gt(t,{units:e,target:n=0,legibleAt:i=260}){let[a,c]=(0,p.useState)(e);(0,p.useEffect)(()=>{let o=t.current;if(o===null||typeof ResizeObserver>"u")return;let r=new ResizeObserver(([s])=>{let f=s?.contentRect.width??0;f>0&&c(f)});return r.observe(o),()=>r.disconnect()},[t]);let u=a/e;return{scale:u,width:a,touchable:u*n>=24,legible:a>=i}}function xt(t="--graview-font-body",e="sans-serif"){let n=(0,p.useRef)(void 0),i=(0,p.useMemo)(()=>{if(typeof getComputedStyle!="function"||typeof document>"u")return e;let a=getComputedStyle(document.documentElement).getPropertyValue(t).trim();return a.length>0?a:e},[t,e]);return(0,p.useMemo)(()=>{n.current===void 0&&(n.current=typeof document>"u"?null:document.createElement("canvas").getContext("2d")??null);let a=n.current;return a===null?P:(c,u)=>{a.font=`${u}px ${i}`;let o=a.measureText(c).width;return o>0?o:P(c,u)}},[i])}var wt=(0,p.createContext)(void 0);var T=3;function pe(t){let e=V(t),n=e.focusId;if(!n)return null;if(e.within?.view){let[a]=B(n);if(a)return{at:`screen:${a}`,audience:!0}}return{at:n,audience:!1}}var fe=102,me=32;function St(t,e,n){let i=[],a=new Map,c=new Map,u=0;for(let o of t){let r=pe(o.stop),s=r?e(r.at):null;if(!r||!s){o.name&&i.push({kind:"edge",presence:o,point:{x:n-8,y:fe+u++*me}});continue}if(!o.name){let k=c.get(r.at);c.set(r.at,{n:(k?.n??0)+1,box:s});continue}let f=a.get(r.at)??[];if(f.push(o),a.set(r.at,f),f.length>T)continue;let l=s,d=f.length-1,b=r.audience?{x:l.x+l.width*.5+(d-1)*26,y:l.y+Math.min(l.height,24)}:{x:l.x+l.width*.5-26-d*26,y:l.y+l.height-4};i.push({kind:"person",presence:o,point:b,at:r.at,index:d,of:f.length,audience:r.audience})}for(let[o,r]of a){if(r.length<=T)continue;let s=e(o);s&&i.push({kind:"count",at:o,point:{x:s.x+s.width*.5+2*26+18,y:s.y+s.height-4},n:r.length-T})}for(let[o,{n:r,box:s}]of c)i.push({kind:"count",at:o,point:{x:s.x+s.width*.5+40,y:s.y+s.height-4},n:r});for(let o of t)if(o.name){if(o.robot?.at&&o.robot.mode!=="docked"){let r=e(o.robot.at);r&&i.push({kind:"robot",presence:o,point:{x:r.x+r.width/2+22,y:r.y+r.height-4},mode:o.robot.mode})}if(o.over){let r=e(o.over);r&&i.push({kind:"over",presence:o,box:r})}}return i}export{st as a,P as b,ne as c,re as d,Y as e,ut as f,de as g,lt as h,le as i,pt as j,ft as k,gt as l,xt as m,be as n,Qe as o,Je as p,St as q,U as r,nt as s,rt as t,ot as u};
1
+ import{l as O}from"./chunk.OJGHDWI6.js";import{e as C}from"./chunk.2FLPDPEL.js";import{$ as I,G as x,R as M,_ as w,aa as W,c as V,x as B,xa as G}from"./chunk.FOQZADMA.js";import{B as D,Hb as F,Nb as N,pc as _,qc as L,wc as j}from"./chunk.V5MYKNL7.js";import{b as m}from"./chunk.AJZBJBMO.js";function H(t,e){let n=t.graph.getNode(e);if(!n)return[];let i=n.kind,a=t.schema.tryDefinition(i);if(!a)return[];let c=t.seenFor,u=c?j.keptFrom?.(t,c)?.(n):void 0,o=new Map;for(let r of t.allMutations()){let s=r.subject;if(!s||!(s.kinds==="*"||s.kinds.includes(i)))continue;let l=r.input.shape??{};for(let d of N(r,a)){if(u?.(d))continue;let b=d in l,k=[];for(let h of Object.keys(l)){if(h===s.arg||h===d||X(l[h]))continue;let v=F(r.input).find(S=>S.name===h);k.push({name:h,...v?{kinds:v.kinds}:{},...v?{candidates:v.kinds.includes("*")?t.graph.allNodes().map(S=>S.id):v.kinds.flatMap(S=>t.graph.nodesOfKind(S).map(J=>J.id))}:{},shape:C(r.input,h)})}let Q={field:d,mutation:r.name,title:r.title??r.name,shape:b?C(r.input,d):{type:"unknown"},takesValue:b,alternatives:[],open:k,call:h=>({name:r.name,args:b?{[s.arg]:e,[d]:h}:{[s.arg]:e}})};o.set(d,[...o.get(d)??[],Q])}}return[...o.values()].map(r=>{let s=[...r.filter(d=>d.takesValue),...r.filter(d=>!d.takesValue)],[f,...l]=s;return{...f,alternatives:l}})}function X(t){let e=D(t)?.type;return e==="optional"||e==="default"||e==="nullable"}var R=m(x(),1);function be(t){let{store:e,principal:n}=w(),i=W(),a=(0,R.useMemo)(()=>t===null?[]:H(e,t),[e,t,i]),c=(0,R.useCallback)((u,o,r={})=>{let s=u.call(o);e.apply({name:s.name,args:{...s.args,...r}},{author:n})},[e,n]);return{fields:a,commit:c}}var K=m(x(),1);function Qe(){let{brand:t}=w(),e=t?.kit;return(0,K.useMemo)(()=>_(e),[e])}function Je(t,e){let n=L(t,e),i={...n.color!==void 0?{color:n.color}:{},...n.pattern!==void 0?{pattern:n.pattern}:{},...n.width!==void 0?{width:n.width}:{},...n.cap!==void 0?{cap:n.cap}:{},...n.opacity!==void 0?{opacity:n.opacity}:{}};return{connector:n,style:O(e,{[e]:i})}}var $=m(x(),1);var g=m(M(),1);function Z(t){let e=t?.hint;return typeof e=="string"&&e.length>0?e:void 0}function ee(t){if(t instanceof Error&&t.message)return t.message;let e=String(t);return e==="[object Object]"?"The view threw without a message.":e}var U=class extends $.Component{static contextType=G;state={};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,n){console.error(`[graview] the ${this.props.view??"view"} of ${this.props.kind} threw while rendering`,e,n.componentStack),this.context?.(e,{module:"@graview/react"})}render(){let{error:e}=this.state;if(!e)return this.props.children;let n=Z(e);return(0,g.jsxs)("div",{role:"alert","data-graview-view-error":this.props.kind,style:{display:"flex",flexDirection:"column",gap:"0.375rem",padding:"var(--graview-pad, 12px)",height:"100%",overflow:"auto",boxSizing:"border-box",borderRadius:"var(--graview-radius-sm, 6px)",background:"var(--graview-panel-warning, #fdf3ec)",color:"var(--graview-ink, #1a1a1a)",font:"var(--graview-font-body, 13px/1.45 system-ui)",fontSize:"0.875rem",lineHeight:1.45},children:[(0,g.jsx)("strong",{style:{color:"var(--graview-warn, #b4462a)"},children:this.props.view?`${this.props.view} could not draw`:"This view could not draw"}),(0,g.jsx)("span",{style:{color:"var(--graview-ink-muted, #555)"},children:this.props.kind}),(0,g.jsx)("span",{children:ee(e)}),n?(0,g.jsx)("span",{style:{color:"var(--graview-ink-muted, #555)"},children:n}):null]})}};var y=m(x(),1);var q=m(M(),1),A=(0,y.createContext)([]);function nt({sections:t,children:e}){let n=(0,y.useContext)(A),i=(0,y.useMemo)(()=>[...n,...t.filter(a=>!n.includes(a))],[n,t]);return(0,q.jsx)(A.Provider,{value:i,children:e})}function z(){let t=(0,y.useContext)(A),e=I()?.menuSections;return(0,y.useMemo)(()=>e?[...t,...e.filter(n=>!t.includes(n))]:t,[t,e])}function rt(){let t=z();return(0,y.useCallback)(e=>{for(let n of t)try{n(e)?.prepare?.()}catch{}},[t])}function ot(t){let e=z();if(t===null||e.length===0)return{start:[],end:[]};let n=e.flatMap(i=>{try{let a=i(t);return a&&((a.items?.length??0)>0||a.render)?[a]:[]}catch{return[]}});return{start:n.filter(i=>i.at==="start"),end:n.filter(i=>i.at!=="start")}}var te=m(x(),1);function st(){return w().activity}var P=(t,e)=>t.length*e*.58;var ne=156,re=2,E=ne-18,oe=7.1,ie=16;function ae(t,e){let n=0,i=E;for(let a of t.split(" ")){let c=e(a),u=i+e(" ")+c;if(u<=E)i=u;else{let o=Math.ceil(c/E)||1;n+=o,i=c-(o-1)*E}}return n}var se=16.25,Y=27,ce=(t,e)=>{let n=Math.ceil(t.length*oe/E);return e?Math.max(Y,Math.ceil(Math.max(n,ae(t,e))*se)+6):Math.max(Y,n*ie+6)};function ut(t,e,n){return t.length===0?0:10+t.reduce((i,a)=>i+ce(a,n),0)+(t.length-1)*re}var de=27,ue=8,lt=4,le=64,pt=t=>Math.max(1,Math.min(ue,t)),ft=t=>t*de+le;var p=m(x(),1);function gt(t,{units:e,target:n=0,legibleAt:i=260}){let[a,c]=(0,p.useState)(e);(0,p.useEffect)(()=>{let o=t.current;if(o===null||typeof ResizeObserver>"u")return;let r=new ResizeObserver(([s])=>{let f=s?.contentRect.width??0;f>0&&c(f)});return r.observe(o),()=>r.disconnect()},[t]);let u=a/e;return{scale:u,width:a,touchable:u*n>=24,legible:a>=i}}function xt(t="--graview-font-body",e="sans-serif"){let n=(0,p.useRef)(void 0),i=(0,p.useMemo)(()=>{if(typeof getComputedStyle!="function"||typeof document>"u")return e;let a=getComputedStyle(document.documentElement).getPropertyValue(t).trim();return a.length>0?a:e},[t,e]);return(0,p.useMemo)(()=>{n.current===void 0&&(n.current=typeof document>"u"?null:document.createElement("canvas").getContext("2d")??null);let a=n.current;return a===null?P:(c,u)=>{a.font=`${u}px ${i}`;let o=a.measureText(c).width;return o>0?o:P(c,u)}},[i])}var wt=(0,p.createContext)(void 0);var T=3;function pe(t){let e=V(t),n=e.focusId;if(!n)return null;if(e.within?.view){let[a]=B(n);if(a)return{at:`screen:${a}`,audience:!0}}return{at:n,audience:!1}}var fe=102,me=32;function St(t,e,n){let i=[],a=new Map,c=new Map,u=0;for(let o of t){let r=pe(o.stop),s=r?e(r.at):null;if(!r||!s){o.name&&i.push({kind:"edge",presence:o,point:{x:n-8,y:fe+u++*me}});continue}if(!o.name){let k=c.get(r.at);c.set(r.at,{n:(k?.n??0)+1,box:s});continue}let f=a.get(r.at)??[];if(f.push(o),a.set(r.at,f),f.length>T)continue;let l=s,d=f.length-1,b=r.audience?{x:l.x+l.width*.5+(d-1)*26,y:l.y+Math.min(l.height,24)}:{x:l.x+l.width*.5-26-d*26,y:l.y+l.height-4};i.push({kind:"person",presence:o,point:b,at:r.at,index:d,of:f.length,audience:r.audience})}for(let[o,r]of a){if(r.length<=T)continue;let s=e(o);s&&i.push({kind:"count",at:o,point:{x:s.x+s.width*.5+2*26+18,y:s.y+s.height-4},n:r.length-T})}for(let[o,{n:r,box:s}]of c)i.push({kind:"count",at:o,point:{x:s.x+s.width*.5+40,y:s.y+s.height-4},n:r});for(let o of t)if(o.name){if(o.robot?.at&&o.robot.mode!=="docked"){let r=e(o.robot.at);r&&i.push({kind:"robot",presence:o,point:{x:r.x+r.width/2+22,y:r.y+r.height-4},mode:o.robot.mode})}if(o.over){let r=e(o.over);r&&i.push({kind:"over",presence:o,box:r})}}return i}export{st as a,P as b,ne as c,re as d,Y as e,ut as f,de as g,lt as h,le as i,pt as j,ft as k,gt as l,xt as m,be as n,Qe as o,Je as p,St as q,U as r,nt as s,rt as t,ot as u};
@@ -0,0 +1 @@
1
+ import{D as l,K as p,R as k,S as y,c}from"./chunk.MUPO5S2A.js";import"./chunk.JYJ4LZJJ.js";import"./chunk.UGFDSE37.js";import{b as m}from"./chunk.USZPOOLZ.js";import"./chunk.C4TSM4W5.js";import"./chunk.XEKLEHC3.js";import"./chunk.53CDFJNM.js";import"./chunk.4QPVS2ZM.js";import"./chunk.RCM7NOPF.js";import"./chunk.Z7LDT55A.js";import"./chunk.BQRAIU5R.js";import"./chunk.57R2GXXN.js";import"./chunk.BFNVG5JE.js";import"./chunk.AIZQBPGU.js";import"./chunk.V3V47QRE.js";import"./chunk.5P556A7W.js";import"./chunk.QHYXXZRD.js";import"./chunk.BELCPW66.js";import"./chunk.6YPLZNVT.js";import"./chunk.5RABSIF7.js";import"./chunk.NGDXH66B.js";import"./chunk.67WWRC6Y.js";import"./chunk.MB7LKKUD.js";import"./chunk.WVUJXDXZ.js";import"./chunk.N6MVK3KD.js";import"./chunk.I7XSDXQ3.js";import"./chunk.UHI3D7JC.js";import"./chunk.WVDKYUF3.js";import"./chunk.ZHLQWMV5.js";import"./chunk.TNESS3LQ.js";import"./chunk.GZHZLJBF.js";import"./chunk.42XSBKPO.js";import"./chunk.OJGHDWI6.js";import"./chunk.6FNMDAX5.js";import"./chunk.2FLPDPEL.js";import"./chunk.UUBYFBPN.js";import"./chunk.2RVUDRRY.js";import"./chunk.JHEVGLKB.js";import{$ as g,G as S,H as s,I as d,R as f}from"./chunk.FOQZADMA.js";import"./chunk.SDO3U72B.js";import"./chunk.V5MYKNL7.js";import{b as n}from"./chunk.AJZBJBMO.js";var u=n(S(),1);var t=n(f(),1);function D({context:a}){let r=l(),h=g(),[w]=(0,u.useState)(()=>s(null)),o=d(h?.seatTalk??w),P=()=>{(window.history.state?.idx??0)>0?r(-1):r("/")};return(0,t.jsxs)(k,{context:a,"data-testid":"draft-page",children:[(0,t.jsx)(y,{context:a,...o.draft?{"data-testid":"draft-title"}:{},children:o.draft?o.draft.title:"Nothing drawn"}),o.draft?(0,t.jsx)(m,{page:!0,go:e=>r(e.address),onPick:e=>{let i=a.store.graph.getNode(e);i&&r(c(a.store.schema,i.kind,e))},onDiscard:P}):(0,t.jsxs)("p",{style:{margin:0,color:"var(--graview-ink-muted)"},children:["Ask for a way of seeing \u2014 \u201Ca board of tasks by status\u201D \u2014 and it is drawn here."," ",(0,t.jsx)(p,{to:"/",style:{color:"var(--graview-accent)"},children:"Home \u2192"})]})]})}export{D as DraftPage};
@@ -1 +1 @@
1
- import{a as I,c as x}from"./chunk.5JPRFXYQ.js";import"./chunk.ORXFUK6F.js";import{b,c as A,j as v,q as w,s as O,v as G}from"./chunk.BTSXYZ6Z.js";import"./chunk.SDO3U72B.js";import{Tc as k,hd as E,nd as S,od as W}from"./chunk.5ZMENPY4.js";import"./chunk.AJZBJBMO.js";var F=(e,i)=>k(e,i).slice(1);function j(e,i){let l=e.split("/").filter(Boolean);return l.length===i.length&&l.every((s,h)=>s.startsWith(":")||s==="*"||s===i[h])}var $=["problems","search","map","places"];function R(e,i,l,s,h=[]){let{schema:r}=i,o=r.kinds,f=t=>{if(t.startsWith(w))return(t.slice(w.length).split("|")[0]??"").split("+").every(V=>o.includes(V));let y=O(t);return y!==null?o.includes(y):t.startsWith("edge:")||l.graph.getNode(t)!==void 0},[p="/",u]=e.path.split("?"),n=p.split("/").filter(Boolean),m=u?`?${u}`:"",d=n.length>0&&!$.includes(n[0])?o.find(t=>F(r,t)===n[0]):void 0,c=e.path;if(n[0]==="places"&&n.length===2)`/places/${n[1]}`!==E&&!s.some(t=>t.as===decodeURIComponent(n[1]))&&(c="/");else if(d){let t=n[1]===void 0?void 0:decodeURIComponent(n[1]);c=`/${F(r,d)}${t!==void 0&&l.graph.getNode(t)?.kind===d?`/${n[1]}`:""}${m}`}else n.length>0&&n.length<=2&&!$.includes(n[0])&&!h.some(t=>j(t.path,n))&&(c="/");let g=A(e.stop),P=g.within?.view,U=P!==void 0&&!s.some(t=>t.as===P),a=g;if(U){let{view:t,...y}=g.within??{};a={...a,within:y}}if(g.focusId&&!f(g.focusId)){let t=e.kind&&o.includes(e.kind)?G(e.kind):null;a={...v(a,t),zoom:!1}}return a={...a,relation:a.relation&&(o.includes(a.relation)||r.edgeKinds.includes(a.relation))?a.relation:null,expanded:a.expanded.filter(f),pins:Object.fromEntries(Object.entries(a.pins).filter(([t])=>f(t))),...a.selection?{selection:a.selection.filter(f)}:{}},{face:e.face,path:c,stop:b(a),...e.kind?{kind:e.kind}:{}}}function B(e,i,l){let s=e.at,h=e.pages?.routes()??[];if(e.routing!=="address"||typeof window>"u")return R(s,e.app,i,l,h);let{pathname:r,search:o,hash:f}=window.location,p=W(r,e.basePath),u=I({routing:"address",...e.basePath===void 0?{}:{basePath:e.basePath},face:s.face}),n=u==="pages",m={...s,face:u,...p===null?{}:n?{path:p+o}:{stop:x(e.basePath)??s.stop}},d=R(m,e.app,i,l,h),c=n?d.path===m.path?null:S(d.path,e.basePath===void 0?{}:{basePath:e.basePath}):d.stop===b(A(m.stop))?null:r+o+d.stop;return p!==null&&c!==null&&c!==r+o+f&&window.history.replaceState(window.history.state,"",c),d}export{R as settle,B as settleAt};
1
+ import{a as I,c as x}from"./chunk.L4STJLUV.js";import"./chunk.JHEVGLKB.js";import{b,c as A,j as v,q as w,s as O,v as G}from"./chunk.FOQZADMA.js";import"./chunk.SDO3U72B.js";import{Vc as k,jd as E,pd as S,qd as W}from"./chunk.V5MYKNL7.js";import"./chunk.AJZBJBMO.js";var F=(e,i)=>k(e,i).slice(1);function j(e,i){let l=e.split("/").filter(Boolean);return l.length===i.length&&l.every((s,h)=>s.startsWith(":")||s==="*"||s===i[h])}var $=["problems","search","map","places"];function R(e,i,l,s,h=[]){let{schema:r}=i,o=r.kinds,f=t=>{if(t.startsWith(w))return(t.slice(w.length).split("|")[0]??"").split("+").every(V=>o.includes(V));let y=O(t);return y!==null?o.includes(y):t.startsWith("edge:")||l.graph.getNode(t)!==void 0},[p="/",u]=e.path.split("?"),n=p.split("/").filter(Boolean),m=u?`?${u}`:"",d=n.length>0&&!$.includes(n[0])?o.find(t=>F(r,t)===n[0]):void 0,c=e.path;if(n[0]==="places"&&n.length===2)`/places/${n[1]}`!==E&&!s.some(t=>t.as===decodeURIComponent(n[1]))&&(c="/");else if(d){let t=n[1]===void 0?void 0:decodeURIComponent(n[1]);c=`/${F(r,d)}${t!==void 0&&l.graph.getNode(t)?.kind===d?`/${n[1]}`:""}${m}`}else n.length>0&&n.length<=2&&!$.includes(n[0])&&!h.some(t=>j(t.path,n))&&(c="/");let g=A(e.stop),P=g.within?.view,U=P!==void 0&&!s.some(t=>t.as===P),a=g;if(U){let{view:t,...y}=g.within??{};a={...a,within:y}}if(g.focusId&&!f(g.focusId)){let t=e.kind&&o.includes(e.kind)?G(e.kind):null;a={...v(a,t),zoom:!1}}return a={...a,relation:a.relation&&(o.includes(a.relation)||r.edgeKinds.includes(a.relation))?a.relation:null,expanded:a.expanded.filter(f),pins:Object.fromEntries(Object.entries(a.pins).filter(([t])=>f(t))),...a.selection?{selection:a.selection.filter(f)}:{}},{face:e.face,path:c,stop:b(a),...e.kind?{kind:e.kind}:{}}}function B(e,i,l){let s=e.at,h=e.pages?.routes()??[];if(e.routing!=="address"||typeof window>"u")return R(s,e.app,i,l,h);let{pathname:r,search:o,hash:f}=window.location,p=W(r,e.basePath),u=I({routing:"address",...e.basePath===void 0?{}:{basePath:e.basePath},face:s.face}),n=u==="pages",m={...s,face:u,...p===null?{}:n?{path:p+o}:{stop:x(e.basePath)??s.stop}},d=R(m,e.app,i,l,h),c=n?d.path===m.path?null:S(d.path,e.basePath===void 0?{}:{basePath:e.basePath}):d.stop===b(A(m.stop))?null:r+o+d.stop;return p!==null&&c!==null&&c!==r+o+f&&window.history.replaceState(window.history.state,"",c),d}export{R as settle,B as settleAt};
@@ -1 +1 @@
1
- import{R as w,j as c,l as h,m as b,r as f,ua as y,wa as k}from"./chunk.BTSXYZ6Z.js";import{T as i}from"./chunk.5ZMENPY4.js";import{b as g}from"./chunk.AJZBJBMO.js";var s=null,a=new Set,v=e=>{s={kind:e,n:(s?.n??0)+1};for(let t of a)t()},A=()=>s,C=e=>(a.add(e),()=>a.delete(e)),V=()=>{s=null};var d=g(w(),1);function T(e,t){if(e.length===0||t.length===0)return[];let o=new Set(t.map(n=>n.id));return e.filter(n=>n.nodeIds.some(l=>o.has(l)))}var x=(e,t)=>`${i(e)} ${e===1?"problem":"problems"} in ${t}`;function q({kind:e,plural:t,problems:o,flag:n,listed:l=!1}){let{view:p,go:P}=k(),{set:$}=y();if(o.length===0)return null;let u=x(o.length,t),m=o.length===1?"it":"them";return(0,d.jsx)("button",{type:"button",className:"graview-district-problems","data-testid":`district-problems-${e}`,"data-graview-problems":o.length,"aria-expanded":l,"aria-label":u,title:`${u} \u2014 ${o[0].message}${o.length>1?` (and ${i(o.length-1)} more)`:""}. Press to see ${m} and how to fix ${m}.`,onClick:r=>{r.stopPropagation(),p.overview||P(h(c(b(p,!0),null),"view",null)),$([f(e)]),v(e)},onDoubleClick:r=>r.stopPropagation(),onPointerDown:r=>r.stopPropagation(),children:(0,d.jsx)("span",{"aria-hidden":"true",children:`${n} ${i(o.length)}`})})}export{A as a,C as b,V as c,T as d,x as e,q as f};
1
+ import{Aa as k,R as w,j as c,l as h,m as b,r as f,ya as y}from"./chunk.FOQZADMA.js";import{T as i}from"./chunk.V5MYKNL7.js";import{b as g}from"./chunk.AJZBJBMO.js";var s=null,a=new Set,v=e=>{s={kind:e,n:(s?.n??0)+1};for(let t of a)t()},A=()=>s,C=e=>(a.add(e),()=>a.delete(e)),V=()=>{s=null};var d=g(w(),1);function T(e,t){if(e.length===0||t.length===0)return[];let o=new Set(t.map(n=>n.id));return e.filter(n=>n.nodeIds.some(l=>o.has(l)))}var x=(e,t)=>`${i(e)} ${e===1?"problem":"problems"} in ${t}`;function q({kind:e,plural:t,problems:o,flag:n,listed:l=!1}){let{view:p,go:P}=k(),{set:$}=y();if(o.length===0)return null;let u=x(o.length,t),m=o.length===1?"it":"them";return(0,d.jsx)("button",{type:"button",className:"graview-district-problems","data-testid":`district-problems-${e}`,"data-graview-problems":o.length,"aria-expanded":l,"aria-label":u,title:`${u} \u2014 ${o[0].message}${o.length>1?` (and ${i(o.length-1)} more)`:""}. Press to see ${m} and how to fix ${m}.`,onClick:r=>{r.stopPropagation(),p.overview||P(h(c(b(p,!0),null),"view",null)),$([f(e)]),v(e)},onDoubleClick:r=>r.stopPropagation(),onPointerDown:r=>r.stopPropagation(),children:(0,d.jsx)("span",{"aria-hidden":"true",children:`${n} ${i(o.length)}`})})}export{A as a,C as b,V as c,T as d,x as e,q as f};