graview 0.1.46 → 0.1.48

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 (193) hide show
  1. package/dist/preview/{chunk.OHSJQYJN.js → chunk.2GLJH253.js} +1 -1
  2. package/dist/preview/{chunk.UR3XYOQ6.js → chunk.2QNGGF55.js} +1 -1
  3. package/dist/preview/{chunk.XSNAG4JT.js → chunk.2UIUMG23.js} +3 -3
  4. package/dist/preview/{chunk.R4OU7O6C.js → chunk.2VTMTW7K.js} +1 -1
  5. package/dist/preview/chunk.37CJSWLL.js +1 -0
  6. package/dist/preview/{chunk.RZXPBOGT.js → chunk.3BAHAK6W.js} +1 -1
  7. package/dist/preview/{chunk.RTI3FEDD.js → chunk.3RP3N2JP.js} +1 -1
  8. package/dist/preview/{chunk.IJABD7SI.js → chunk.3UD7GG5B.js} +1 -1
  9. package/dist/preview/{chunk.BFKV4GKP.js → chunk.44G5A53D.js} +1 -1
  10. package/dist/preview/chunk.4GQA3AJU.js +1 -0
  11. package/dist/preview/{chunk.F5PBK4TF.js → chunk.4KX53HCV.js} +2 -2
  12. package/dist/preview/chunk.4TJOS4C7.js +5 -0
  13. package/dist/preview/{chunk.EPUBSKKL.js → chunk.4VW6THJF.js} +1 -1
  14. package/dist/preview/{chunk.3OSGN463.js → chunk.5IM645XQ.js} +1 -1
  15. package/dist/preview/{chunk.NGIPVTTE.js → chunk.5IPH2SCE.js} +1 -1
  16. package/dist/preview/{chunk.TBQOSI4J.js → chunk.5Y3Q7ONN.js} +1 -1
  17. package/dist/preview/chunk.664PBQAQ.js +1 -0
  18. package/dist/preview/chunk.6TKILWRM.js +1 -0
  19. package/dist/preview/{chunk.JLEC3USG.js → chunk.6VAFNCR4.js} +1 -1
  20. package/dist/preview/chunk.72OZLWJL.js +1 -0
  21. package/dist/preview/chunk.72W6S746.js +1 -0
  22. package/dist/preview/{chunk.VDVJCLGS.js → chunk.76W2FXEC.js} +1 -1
  23. package/dist/preview/{chunk.64WM4IBI.js → chunk.7FRPNQU4.js} +1 -1
  24. package/dist/preview/chunk.7LL7OSBY.js +6 -0
  25. package/dist/preview/chunk.7QZYFLBS.js +1 -0
  26. package/dist/preview/{chunk.6RY6OSE6.js → chunk.7VT3TRHR.js} +1 -1
  27. package/dist/preview/chunk.B2IIEVBF.js +21 -0
  28. package/dist/preview/{chunk.5ESCD57M.js → chunk.BDHKWVNX.js} +1 -1
  29. package/dist/preview/{chunk.X25KXCWI.js → chunk.CH5ROV7N.js} +1 -1
  30. package/dist/preview/{chunk.EAJB2PJZ.js → chunk.CJ23XTSW.js} +1 -1
  31. package/dist/preview/{chunk.VAFSSSSI.js → chunk.D5ETRTAF.js} +1 -1
  32. package/dist/preview/{chunk.6OPI4WWO.js → chunk.DAUC2DFY.js} +1 -1
  33. package/dist/preview/{chunk.63JLXGYX.js → chunk.DFK2NA6L.js} +1 -1
  34. package/dist/preview/chunk.DHAK6PPX.js +3 -0
  35. package/dist/preview/{chunk.NMIXBH37.js → chunk.DOBQ4LO4.js} +1 -1
  36. package/dist/preview/{chunk.H7KCWCB4.js → chunk.DPHTUTOS.js} +1 -1
  37. package/dist/preview/chunk.DQ7M3LFV.js +1 -0
  38. package/dist/preview/{chunk.Y5ARSVH4.js → chunk.DUWYF7BO.js} +1 -1
  39. package/dist/preview/{chunk.3MMLRSRC.js → chunk.DWPU56S5.js} +1 -1
  40. package/dist/preview/{chunk.WBHM5I3I.js → chunk.E5GM2SMO.js} +1 -1
  41. package/dist/preview/{chunk.UOXFALRL.js → chunk.EMQ5POGB.js} +1 -1
  42. package/dist/preview/{chunk.TOZJZXWQ.js → chunk.ENPCLMP2.js} +1 -1
  43. package/dist/preview/{chunk.XXEYRHRG.js → chunk.ETR6AV47.js} +1 -1
  44. package/dist/preview/chunk.EXEZBZGW.js +1 -0
  45. package/dist/preview/{chunk.O24DD2VF.js → chunk.EZJNUFNQ.js} +1 -1
  46. package/dist/preview/{chunk.S5MQVPLF.js → chunk.FOP5RBGF.js} +1 -1
  47. package/dist/preview/chunk.FPYL6REZ.js +1 -0
  48. package/dist/preview/chunk.FQYOTK34.js +1 -0
  49. package/dist/preview/chunk.G446PWV6.js +1 -0
  50. package/dist/preview/chunk.G7WDMUDV.js +1 -0
  51. package/dist/preview/{chunk.NIVTK2W5.js → chunk.GACKGEUY.js} +1 -1
  52. package/dist/preview/chunk.GH2SWMCW.js +1 -0
  53. package/dist/preview/chunk.GNBN3BK7.js +1 -0
  54. package/dist/preview/{chunk.4KNEBLB7.js → chunk.GT3F6FQ6.js} +1 -1
  55. package/dist/preview/chunk.GTPC6JOW.js +2 -0
  56. package/dist/preview/{chunk.DEUTHHGI.js → chunk.GUMJEVVP.js} +1 -1
  57. package/dist/preview/chunk.GVNYPFIM.js +1 -0
  58. package/dist/preview/{chunk.I3GP5JW7.js → chunk.HC5N3CT2.js} +1 -1
  59. package/dist/preview/{chunk.RNBPDB37.js → chunk.HDE2MGGU.js} +1 -1
  60. package/dist/preview/{chunk.6YD2DLIC.js → chunk.HG4DDNPG.js} +1 -1
  61. package/dist/preview/{chunk.A5VGTO3E.js → chunk.HKA5T7DL.js} +1 -1
  62. package/dist/preview/{chunk.55D33E5A.js → chunk.I5TOMBIF.js} +1 -1
  63. package/dist/preview/{chunk.JF3GD4H5.js → chunk.I7QIHN66.js} +1 -1
  64. package/dist/preview/chunk.ILZYRJDS.js +1 -0
  65. package/dist/preview/{chunk.LETJC5TD.js → chunk.IRHSTUZM.js} +1 -1
  66. package/dist/preview/{chunk.JLYNMAME.js → chunk.J2V76Z6G.js} +1 -1
  67. package/dist/preview/{chunk.3VFYSXMQ.js → chunk.J6ANRF6E.js} +1 -1
  68. package/dist/preview/chunk.KA44WNB4.js +25 -0
  69. package/dist/preview/chunk.KTFUVR4V.js +2 -0
  70. package/dist/preview/{chunk.BNPQUI3F.js → chunk.KVEDIBXS.js} +1 -1
  71. package/dist/preview/chunk.KVJFY7N5.js +2 -0
  72. package/dist/preview/{chunk.SS27NH5O.js → chunk.KW65F4WA.js} +1 -1
  73. package/dist/preview/chunk.LGSFGNWE.js +1 -0
  74. package/dist/preview/{chunk.UVNVDLV5.js → chunk.LNON6P7K.js} +1 -1
  75. package/dist/preview/{chunk.R2AG4NHQ.js → chunk.LPD74WBI.js} +1 -1
  76. package/dist/preview/chunk.LXCJVZF3.js +1 -0
  77. package/dist/preview/{chunk.Q7RQC3F7.js → chunk.MAFFUPCR.js} +1 -1
  78. package/dist/preview/chunk.MTXEURFE.js +1 -0
  79. package/dist/preview/{chunk.PLWVLW22.js → chunk.MVRG75ZD.js} +1 -1
  80. package/dist/preview/{chunk.GEPNIMXW.js → chunk.MVSV7T6E.js} +1 -1
  81. package/dist/preview/{chunk.W45NKVSV.js → chunk.MZLWLIKR.js} +1 -1
  82. package/dist/preview/chunk.N4M54YK6.js +1 -0
  83. package/dist/preview/{chunk.KSXB4LDF.js → chunk.NB6WN4DO.js} +1 -1
  84. package/dist/preview/{chunk.UHX4WTM7.js → chunk.NFDLCUCC.js} +1 -1
  85. package/dist/preview/{chunk.AGIO2GRV.js → chunk.NLBIX7LH.js} +1 -1
  86. package/dist/preview/{chunk.VC3BX2ZF.js → chunk.NQZ73QV7.js} +1 -1
  87. package/dist/preview/chunk.NR5ODXMO.js +1 -0
  88. package/dist/preview/{chunk.M5GJHVWZ.js → chunk.NTLHEHOM.js} +1 -1
  89. package/dist/preview/{chunk.TFVFJFXC.js → chunk.NWT5FPEK.js} +3 -3
  90. package/dist/preview/chunk.NX7IIZLO.js +1 -0
  91. package/dist/preview/{chunk.UKAPFIPJ.js → chunk.O45VO36H.js} +1 -1
  92. package/dist/preview/{chunk.LUNATPAB.js → chunk.OAIWGWGU.js} +2 -2
  93. package/dist/preview/{chunk.PC6PID5X.js → chunk.ODRL5OWR.js} +1 -1
  94. package/dist/preview/{chunk.L2PI7V4R.js → chunk.OFRGDJYX.js} +1 -1
  95. package/dist/preview/chunk.OVO6L5IP.js +88 -0
  96. package/dist/preview/{chunk.LKN734RR.js → chunk.OZGETOTK.js} +1 -1
  97. package/dist/preview/{chunk.4HYJHGI4.js → chunk.P6FQAILU.js} +1 -1
  98. package/dist/preview/chunk.PCEYZQAW.js +1 -0
  99. package/dist/preview/{chunk.ONEYVLC2.js → chunk.PMJUGHW4.js} +1 -1
  100. package/dist/preview/{chunk.RNEJYIQ7.js → chunk.PPRSGM64.js} +1 -1
  101. package/dist/preview/chunk.PQVUQVRL.js +1 -0
  102. package/dist/preview/{chunk.LVEFQLGQ.js → chunk.PTXLOFQW.js} +1 -1
  103. package/dist/preview/{chunk.VBPK6ARF.js → chunk.PVEPU6EA.js} +1 -1
  104. package/dist/preview/chunk.QGE6YKSU.js +1 -0
  105. package/dist/preview/{chunk.Z6TMIAAB.js → chunk.QII2C5OV.js} +1 -1
  106. package/dist/preview/chunk.QO7MDWID.js +1 -0
  107. package/dist/preview/{chunk.S6WHA4CW.js → chunk.QPICKSSM.js} +1 -1
  108. package/dist/preview/{chunk.KRGM25HF.js → chunk.QQCDCRR2.js} +1 -1
  109. package/dist/preview/chunk.QQTRAY5W.js +1 -0
  110. package/dist/preview/{chunk.SL2FZ54V.js → chunk.RLXKDXPB.js} +1 -1
  111. package/dist/preview/{chunk.6MADC6DM.js → chunk.RQBEQYB2.js} +1 -1
  112. package/dist/preview/chunk.SA34Y3X5.js +2 -0
  113. package/dist/preview/chunk.SAHNXAV3.js +1 -0
  114. package/dist/preview/{chunk.UNCS63AM.js → chunk.SFAAM4KE.js} +1 -1
  115. package/dist/preview/{chunk.N7VNEUJR.js → chunk.SKJJBLXF.js} +1 -1
  116. package/dist/preview/chunk.SUPWMV2F.js +1 -0
  117. package/dist/preview/{chunk.ITYQUSZI.js → chunk.TBRJOKIK.js} +1 -1
  118. package/dist/preview/{chunk.JLIUUFK2.js → chunk.TKMQROXF.js} +1 -1
  119. package/dist/preview/chunk.TMDI7KRS.js +18 -0
  120. package/dist/preview/chunk.TPG6IY4M.js +1 -0
  121. package/dist/preview/{chunk.PKUDIWIF.js → chunk.UGJSMNVO.js} +1 -1
  122. package/dist/preview/{chunk.6QYJ2K6K.js → chunk.UJRBOUGC.js} +1 -1
  123. package/dist/preview/chunk.V2GSBYDK.js +4 -0
  124. package/dist/preview/chunk.V3N34DSU.js +1 -0
  125. package/dist/preview/{chunk.JT3IZIU5.js → chunk.V4BCB7N2.js} +1 -1
  126. package/dist/preview/{chunk.6SOUQNXR.js → chunk.VQAQQW4Q.js} +1 -1
  127. package/dist/preview/{chunk.CICGAEBW.js → chunk.W72TTRLX.js} +2 -2
  128. package/dist/preview/chunk.X5G7FOPY.js +12 -0
  129. package/dist/preview/{chunk.IKX4VDTW.js → chunk.X7JMJSLU.js} +1 -1
  130. package/dist/preview/{chunk.WP5W44Y4.js → chunk.X7N3JUO4.js} +2 -2
  131. package/dist/preview/chunk.XOZU4OFA.js +1 -0
  132. package/dist/preview/{chunk.JBW3DI7E.js → chunk.XTMOFRHL.js} +1 -1
  133. package/dist/preview/{chunk.WQONZBA3.js → chunk.Y4MQGEUS.js} +2 -2
  134. package/dist/preview/{chunk.BCWPV4WR.js → chunk.YDL5BSTG.js} +1 -1
  135. package/dist/preview/chunk.YEVA72L2.js +1 -0
  136. package/dist/preview/chunk.YLWON7X3.js +1 -0
  137. package/dist/preview/chunk.YUH43J2K.js +1 -0
  138. package/dist/preview/{chunk.Z5IGHCZX.js → chunk.YVOABA2U.js} +1 -1
  139. package/dist/preview/{chunk.5R2R364Q.js → chunk.Z4UM4CMT.js} +1 -1
  140. package/dist/preview/{chunk.DQOCBKC3.js → chunk.ZH4NWRWB.js} +1 -1
  141. package/dist/preview/chunk.ZXZNAG35.js +1 -0
  142. package/dist/preview/index.html +50 -49
  143. package/dist/preview/page.js +2 -2
  144. package/package.json +6 -6
  145. package/dist/preview/chunk.2JJYGYT2.js +0 -1
  146. package/dist/preview/chunk.4OGOTHRD.js +0 -1
  147. package/dist/preview/chunk.4RJZVTW7.js +0 -6
  148. package/dist/preview/chunk.4Y6VGQVQ.js +0 -1
  149. package/dist/preview/chunk.5K6KX3UC.js +0 -1
  150. package/dist/preview/chunk.6BDM2XRX.js +0 -1
  151. package/dist/preview/chunk.6UIW664O.js +0 -6
  152. package/dist/preview/chunk.6WA6ASQB.js +0 -1
  153. package/dist/preview/chunk.AQQZY6OY.js +0 -3
  154. package/dist/preview/chunk.AS4CQBOQ.js +0 -5
  155. package/dist/preview/chunk.ATDU5Y7V.js +0 -1
  156. package/dist/preview/chunk.AYA7SYIU.js +0 -1
  157. package/dist/preview/chunk.BAMPYMUE.js +0 -88
  158. package/dist/preview/chunk.DX357TZ3.js +0 -2
  159. package/dist/preview/chunk.F37DHXA2.js +0 -1
  160. package/dist/preview/chunk.FGR7KCI6.js +0 -1
  161. package/dist/preview/chunk.FO5BOBYV.js +0 -1
  162. package/dist/preview/chunk.FVOJCVRX.js +0 -1
  163. package/dist/preview/chunk.FXTBMW3S.js +0 -1
  164. package/dist/preview/chunk.GVY5UQTJ.js +0 -1
  165. package/dist/preview/chunk.HBD7FBZS.js +0 -1
  166. package/dist/preview/chunk.HDRD33II.js +0 -1
  167. package/dist/preview/chunk.HZCA3UWJ.js +0 -1
  168. package/dist/preview/chunk.IW7YFPGG.js +0 -1
  169. package/dist/preview/chunk.JHIUG25Q.js +0 -1
  170. package/dist/preview/chunk.JNIGZEOF.js +0 -1
  171. package/dist/preview/chunk.JQLR6KO2.js +0 -1
  172. package/dist/preview/chunk.KWQ7QOHD.js +0 -2
  173. package/dist/preview/chunk.LKVXSC5O.js +0 -2
  174. package/dist/preview/chunk.MWONSI3P.js +0 -1
  175. package/dist/preview/chunk.NITU5H4J.js +0 -1
  176. package/dist/preview/chunk.NWA7Q6CI.js +0 -1
  177. package/dist/preview/chunk.P4O5DGLN.js +0 -1
  178. package/dist/preview/chunk.QGVLJTZS.js +0 -1
  179. package/dist/preview/chunk.T7O6K3IN.js +0 -1
  180. package/dist/preview/chunk.UPQZU7UO.js +0 -21
  181. package/dist/preview/chunk.URO2EGY7.js +0 -1
  182. package/dist/preview/chunk.V3QUTJR2.js +0 -2
  183. package/dist/preview/chunk.V5Z2OED6.js +0 -1
  184. package/dist/preview/chunk.VW2VCPJX.js +0 -1
  185. package/dist/preview/chunk.WAB7UDHU.js +0 -1
  186. package/dist/preview/chunk.WM2LWHTJ.js +0 -1
  187. package/dist/preview/chunk.WO3DDFFY.js +0 -1
  188. package/dist/preview/chunk.WSTBCWW7.js +0 -4
  189. package/dist/preview/chunk.X233NILF.js +0 -1
  190. package/dist/preview/chunk.XWAMQPUM.js +0 -25
  191. package/dist/preview/chunk.XXDBZQNY.js +0 -18
  192. package/dist/preview/chunk.ZIEHF67C.js +0 -1
  193. package/dist/preview/chunk.ZTIF23VF.js +0 -1
@@ -1,2 +1,2 @@
1
- var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as Ct,b as _n,c as Wn,d as jn,e as qn,f as Lt,g as zn,h as Mt}from"./chunk.3VFYSXMQ.js";import{a as Ir}from"./chunk.JT3IZIU5.js";import{a as Vt,b as Un,c as Kn,d as Jn,e as Bt,f as Yn,g as Qn,h as Zn,i as Xn,j as er,k as tr,l as nr,m as rr,n as We}from"./chunk.5K6KX3UC.js";import{b as Gn}from"./chunk.S5MQVPLF.js";import{a as kt}from"./chunk.Q5WEOX3Q.js";import{a as Et,g as bn}from"./chunk.6YD2DLIC.js";import{k as tt}from"./chunk.KWQ7QOHD.js";import{C as Dn,H as Nn,L as $n,M as In,j as $r,k as Mn,n as ot,o as Vn,q as Bn,u as Hn,z as at}from"./chunk.XSNAG4JT.js";import{Ca as rt,G as Ft,R as En,W as Pn,a as Sn,b as Tt,c as nt,da as An,ea as Rn,j as kn,m as xt,qa as Tn,ra as xn,sa as Fn,ta as On,va as Cn,wa as Ot,za as Ln}from"./chunk.XWAMQPUM.js";import{a as be}from"./chunk.SDO3U72B.js";import{Mc as pn,Oc as mn,Pc as hn,Rc as et,Ub as Pt,Vb as un,ib as _e,jb as Xe,ld as ve,md as yn,nd as gn,sd as wn,td as At,vb as ln,wd as vn,xd as Rt,yc as fn}from"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import{b as Te}from"./chunk.AJZBJBMO.js";async function it(e,n={}){let o=e.compiled===void 0||!Wr(e.compiled,e.document)?void 0:bn(e.compiled,n);if(o?.ok)return o;let{compileDocumentWithoutCheck:a}=await _r();return a(e.document,n)}var or,_r=()=>or??=(__graviewPreload(import.meta.url,["./chunk.4OGOTHRD.js","./chunk.6YD2DLIC.js","./chunk.IKX4VDTW.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.AYA7SYIU.js")).catch(e=>{throw or=void 0,e});function Wr(e,n){let o=typeof e=="object"&&e!==null?e.document:void 0,a=n;if(typeof a=="string")try{a=JSON.parse(a)}catch{return!1}return o!==void 0&&kt(Et(o).document)===kt(Et(a).document)}var c=Te(Ft(),1);var dt=Te(Ft(),1),Ht="data-graview-drawn",jr=200,ar=50,qr=1e4,st=()=>typeof performance<"u"?performance.now():Date.now();function zr(e){let n=[...e.querySelectorAll("img")];for(let o of e.querySelectorAll("[data-worker-view]"))o.shadowRoot&&n.push(...o.shadowRoot.querySelectorAll("img"));return n}function Gr(e){if(e.ownerDocument.fonts?.status==="loading"||xn()>0||e.querySelector('[aria-busy="true"]')||zr(e).some(o=>!o.complete&&o.loading!=="lazy"))return!1;for(let o of e.querySelectorAll("[data-worker-view-place]"))if(!o.querySelector("[data-worker-view][data-worker-view-drawn], [data-worker-view][data-worker-view-failed]"))return!1;return!0}function ir(e){let n=e.querySelector("[data-embed-content]"),o=[...e.querySelectorAll("[data-worker-view]")].map(a=>`${a.offsetWidth}x${a.offsetHeight}`);return`${e.scrollWidth}x${e.scrollHeight}|${n?`${n.scrollWidth}x${n.scrollHeight}`:""}|${o.join(",")}`}function Ur(e,n,o){e.removeAttribute(Ht);let a=e.ownerDocument.defaultView;if(!a)return()=>{};let d=st(),l=d,b=ir(e),p=!1,g,P=typeof MutationObserver>"u"?void 0:new MutationObserver(R=>{R.some(v=>!(v.target===e&&v.attributeName===Ht))&&(l=st())});P?.observe(e,{childList:!0,subtree:!0,characterData:!0,attributes:!0});let A=()=>{p=!0,P?.disconnect(),g!==void 0&&clearTimeout(g)},k=R=>{let v=!1,ne=()=>{v||(v=!0,R())};typeof a.requestAnimationFrame=="function"&&a.requestAnimationFrame(()=>setTimeout(ne,0)),setTimeout(ne,100)},S=()=>{if(p)return;let R=ir(e);R!==b&&(b=R,l=st());let v=st();if(Gr(e)&&v-l>=jr||v-d>=qr){k(()=>{p||(A(),e.setAttribute(Ht,n),On(),o())});return}g=setTimeout(S,ar)};return g=setTimeout(S,ar),A}function sr(e,n,o,a){Fn();let d=(0,dt.useRef)({place:o,onDrawn:a});d.current={place:o,onDrawn:a},(0,dt.useLayoutEffect)(()=>{let l=g=>Ur(g,d.current.place.path,()=>d.current.onDrawn?.(d.current.place));if(e.current)return l(e.current);let b,p=!1;return queueMicrotask(()=>{!p&&e.current&&(b=l(e.current))}),()=>{p=!0,b?.()}},[n,e])}var pe=Te(Ft(),1),je,Kr=be(()=>(__graviewPreload(import.meta.url,["./chunk.R4OU7O6C.js","./chunk.XXEYRHRG.js","./chunk.55D33E5A.js","./chunk.2JJYGYT2.js","./chunk.NMIXBH37.js","./chunk.XWAMQPUM.js","./chunk.SDO3U72B.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.NITU5H4J.js"))),dr=()=>Kr().then(e=>void(je=e),()=>new Promise(e=>setTimeout(e,2e3)).then(dr)),Dt=Tn(dr),cr=e=>!!e&&je===void 0;function Nt({onReady:e,fetch:n}){return(0,pe.useLayoutEffect)(()=>void n().then(e),[e,n]),null}var Jr=0;function lr(e){let[n,o]=(0,pe.useState)(()=>je);(0,pe.useEffect)(()=>{if(!e||n)return;let l=!1;return Dt().then(()=>{l||o(je)}),()=>{l=!0}},[e,n]);let a=(0,pe.useMemo)(()=>Jr+=1,[e]);return{over:(0,pe.useMemo)(()=>{let l=n??je;if(!e||!l)return;let{source:b,worker:p,...g}=e,P={...g,worker:p??{source:b},draft:!0};return{name:e.manifest.name,home:e.manifest.attach==="home",register:A=>l.registerWorkerView(A,P)}},[e,n]),n:a}}var pr=Te(Ir(),1),W=Te($r(),1);var y=Te(En(),1);function ct(e,n={}){let o=Ot(e);return{Face:o.part((d,l)=>(0,c.createElement)(d,l),n),fetch:()=>o.load().then(()=>{}),here:()=>o.current!==void 0||o.failed}}var _t=e=>Promise.all([e,$n()]).then(([n])=>n),mr=be(()=>(__graviewPreload(import.meta.url,["./chunk.NWA7Q6CI.js","./chunk.M5GJHVWZ.js","./chunk.WSTBCWW7.js","./chunk.AGIO2GRV.js","./chunk.NIVTK2W5.js","./chunk.HJCQ6I3S.js","./chunk.BNPQUI3F.js","./chunk.6RY6OSE6.js","./chunk.6SOUQNXR.js","./chunk.3MMLRSRC.js","./chunk.64WM4IBI.js","./chunk.5ESCD57M.js","./chunk.DQOCBKC3.js","./chunk.DEUTHHGI.js","./chunk.ATDU5Y7V.js","./chunk.PKUDIWIF.js","./chunk.VW2VCPJX.js","./chunk.WBHM5I3I.js","./chunk.VC3BX2ZF.js","./chunk.UKAPFIPJ.js","./chunk.UT6642FC.js","./chunk.5K6KX3UC.js","./chunk.S5MQVPLF.js","./chunk.TI4OSTQV.js","./chunk.Q7RQC3F7.js","./chunk.GZHZLJBF.js","./chunk.6MADC6DM.js","./chunk.OJGHDWI6.js","./chunk.JLEC3USG.js","./chunk.HDRD33II.js","./chunk.DX357TZ3.js","./chunk.H7KCWCB4.js","./chunk.XSNAG4JT.js","./chunk.XWAMQPUM.js","./chunk.SDO3U72B.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.TFVFJFXC.js"))),Yr=be(()=>(__graviewPreload(import.meta.url,["./chunk.XXDBZQNY.js","./chunk.JF3GD4H5.js","./chunk.UR3XYOQ6.js","./chunk.ONEYVLC2.js","./chunk.WQONZBA3.js","./chunk.UGFDSE37.js","./chunk.NWA7Q6CI.js","./chunk.WP5W44Y4.js","./chunk.M5GJHVWZ.js","./chunk.HZCA3UWJ.js","./chunk.JBW3DI7E.js","./chunk.AGIO2GRV.js","./chunk.NIVTK2W5.js","./chunk.PXQVXBNG.js","./chunk.6QYJ2K6K.js","./chunk.3MMLRSRC.js","./chunk.DQOCBKC3.js","./chunk.OHSJQYJN.js","./chunk.DEUTHHGI.js","./chunk.EPUBSKKL.js","./chunk.ATDU5Y7V.js","./chunk.AQQZY6OY.js","./chunk.BCWPV4WR.js","./chunk.Y5ARSVH4.js","./chunk.PKUDIWIF.js","./chunk.VW2VCPJX.js","./chunk.UKAPFIPJ.js","./chunk.UT6642FC.js","./chunk.IW7YFPGG.js","./chunk.MB7LKKUD.js","./chunk.WVUJXDXZ.js","./chunk.ZIEHF67C.js","./chunk.UHX4WTM7.js","./chunk.IKX4VDTW.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.GZHZLJBF.js","./chunk.6MADC6DM.js","./chunk.OJGHDWI6.js","./chunk.JLEC3USG.js","./chunk.HDRD33II.js","./chunk.DX357TZ3.js","./chunk.H7KCWCB4.js","./chunk.XSNAG4JT.js","./chunk.XWAMQPUM.js","./chunk.SDO3U72B.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.JQLR6KO2.js"))),Qr=be(()=>(__graviewPreload(import.meta.url,["./chunk.XXDBZQNY.js","./chunk.JF3GD4H5.js","./chunk.UR3XYOQ6.js","./chunk.ONEYVLC2.js","./chunk.WQONZBA3.js","./chunk.UGFDSE37.js","./chunk.NWA7Q6CI.js","./chunk.WP5W44Y4.js","./chunk.M5GJHVWZ.js","./chunk.HZCA3UWJ.js","./chunk.JBW3DI7E.js","./chunk.AGIO2GRV.js","./chunk.NIVTK2W5.js","./chunk.PXQVXBNG.js","./chunk.6QYJ2K6K.js","./chunk.3MMLRSRC.js","./chunk.DQOCBKC3.js","./chunk.OHSJQYJN.js","./chunk.DEUTHHGI.js","./chunk.EPUBSKKL.js","./chunk.ATDU5Y7V.js","./chunk.AQQZY6OY.js","./chunk.BCWPV4WR.js","./chunk.Y5ARSVH4.js","./chunk.PKUDIWIF.js","./chunk.VW2VCPJX.js","./chunk.UKAPFIPJ.js","./chunk.UT6642FC.js","./chunk.IW7YFPGG.js","./chunk.MB7LKKUD.js","./chunk.WVUJXDXZ.js","./chunk.ZIEHF67C.js","./chunk.UHX4WTM7.js","./chunk.IKX4VDTW.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.GZHZLJBF.js","./chunk.6MADC6DM.js","./chunk.OJGHDWI6.js","./chunk.JLEC3USG.js","./chunk.HDRD33II.js","./chunk.DX357TZ3.js","./chunk.H7KCWCB4.js","./chunk.XSNAG4JT.js","./chunk.XWAMQPUM.js","./chunk.SDO3U72B.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.FO5BOBYV.js"))),hr=ct(()=>_t(mr().then(e=>e.SceneFace)),{what:"This view"}),yr=ct(()=>mr().then(e=>e.SceneKeeping),{quiet:!0}),gr=ct(()=>_t(Yr().then(e=>e.PagesContent)),{what:"This page"}),wr=ct(()=>_t(Qr().then(e=>e.PictureFace)),{what:"This picture"}),Zr=hr.Face,Xr=yr.Face,eo=gr.Face,to=wr.Face;function xe(...e){let n=e.length>0?e:["scene","pages","picture"],o=new Set(n.flatMap(vr));return Promise.all([...[...o].map(a=>a.fetch()),Bn()]).then(()=>{},()=>{})}var vr=e=>e==="pages"?[gr]:e==="picture"?[wr]:[hr,yr],br=e=>vr(e).every(n=>n.here()),no=150,$t=0;function ur(e,n){if(br(e))return n();let o=++$t,a=()=>{o===$t&&($t+=1,n())};xe(e).then(a),setTimeout(a,no)}var ro=768;function oo(e,n){let o=n!==null&&n>=ro;(0,c.useEffect)(()=>{if(!o||e==="picture")return;let a=e==="pages"?"scene":"pages";if(br(a))return;let d=globalThis,l=()=>void xe(a),b=()=>{},p=Cn(()=>{if(d.requestIdleCallback&&d.cancelIdleCallback){let g=d.requestIdleCallback(l,{timeout:4e3});b=()=>d.cancelIdleCallback?.(g)}else{let g=setTimeout(l,1500);b=()=>clearTimeout(g)}});return()=>(p(),b())},[e,o])}function ao({asked:e,shown:n,onDrawn:o}){return(0,c.useLayoutEffect)(()=>o(e,n),[e,n,o]),null}function io({auto:e,scene:n}){return(0,y.jsx)("div",{"data-embed-content":"","aria-busy":"true",style:{flex:e?n?`0 0 ${Bt}px`:"0 0 auto":"1 1 auto",minHeight:0,background:"var(--graview-ground)"}})}var so=Ot(be(()=>(__graviewPreload(import.meta.url,["./chunk.AJZBJBMO.js"]),import("./chunk.5JNXQHN4.js")))).part((e,n)=>(0,y.jsx)(e.StudioPlace,{...n}),{quiet:!0});function Sr(e,n,o,a,d){return Lt(e,qn(n?nt(n):d??Sn,a),o)}function Wt(e){return e&&nt(e).overview?"graview":"scene"}function fr(e,n){if(n.homeView?.()===void 0)return!1;let o=e.pages?.first?.trim();return o===void 0||o===""||o==="/"||o.toLowerCase()==="home"}function kr(e){let[,n]=(0,c.useState)(!1),o=(0,c.useCallback)(()=>n(!0),[]),a=(0,c.useRef)(!1);return e.at&&!lt?(0,y.jsx)(Nt,{onReady:o,fetch:jt}):!a.current&&cr(e.draftView)?(0,y.jsx)(Nt,{onReady:o,fetch:Dt}):(a.current=!0,(0,y.jsx)(co,{...e}))}function co(e){let{app:n,stop:o,bar:a=!0,standing:d="Everything is in order",principal:l,heading:b=2}=e,{rootRef:p,scope:g,css:P,scheme:A,store:k,presence:S,brand:R,auto:v,height:ne}=Yn(e),ke=lr(e.draftView),L=Kn(e,In,ke.over),Z=e.basePath===void 0?{}:{basePath:e.basePath},[f]=(0,c.useState)(ot),C=e.notices??f,N=m=>wn(m,Z),re={...e.routing?{routing:e.routing}:{},...Z},[T]=(0,c.useState)(()=>{let m=e.at?.face;if(m)return m;let _=o===void 0&&fr(n,L)?"pages":Wt(o),ue=Ct({...re,face:_});return e.face===void 0&&e.onOpening?.(ue),ue}),[oe,z]=(0,c.useState)(()=>e.face!==void 0&&e.face!=="pages"&&!e.at&&o===void 0&&_n(re)&&fr(n,L)),x=(0,c.useRef)(e.onFace);x.current=e.onFace,(0,c.useLayoutEffect)(()=>{oe&&(x.current?.("pages"),z(!1))},[oe]);let F=oe?"pages":e.face??T,M=n.schema.kinds,O=e.routing==="address",V=(0,c.useMemo)(()=>e.at?lt.settleAt(e,k.seenBy(l??{kind:"human"}),L.places()):void 0,[]),U=(0,c.useMemo)(()=>Rn(L,n.schema),[L,n.schema]),G=(0,c.useMemo)(()=>{let m=V?.stop??(O?Wn(e.basePath):void 0)??o;return F==="scene"&&m===void 0&&U===void 0&&(e.path===void 0||It(e.path))?Mt(void 0):Sr(F,m,M,L.places(),U)},[]),[ie]=(0,c.useState)(F);(0,c.useEffect)(()=>{ie!=="pages"&&An(L)},[ie,L]);let $=(0,c.useRef)(void 0),he=m=>m===void 0||It(m)?"/":m;$.current??={path:he(V?.path??(O?F==="pages"?(At(window.location.pathname,e.basePath)??"/")+window.location.search:"/":e.path)),asked:e.path},e.path!==$.current.asked&&($.current={path:he(e.path),asked:e.path});let B=(0,c.useRef)(e.onNavigate);B.current=e.onNavigate;let K=(0,c.useCallback)((m,_)=>{$.current.path=m,B.current?.(m,_)},[]),{at:ae,setAt:H,steering:ye,steer:X}=tr($.current.path),j=(0,c.useContext)(Er);j&&(j.pages=()=>$.current.path);let q=(0,c.useRef)(void 0),Oe=(0,c.useCallback)(m=>void($.current.path=m),[]),J=Mn(p),[Ee,Y]=(0,c.useState)(!1),ze=e.pagesBelow!==void 0&&J!==null&&J<e.pagesBelow&&(F==="scene"||F==="graview")&&!Ee,E=ze?"pages":F,Ce=(0,c.useRef)(!1);Ce.current=Ee&&e.pagesBelow!==void 0&&J!==null&&J<e.pagesBelow&&(F==="scene"||F==="graview"),j&&(j.shown=E);let ce=(0,c.useRef)(F==="graview"?"graview":"scene");(E==="scene"||E==="graview")&&(ce.current=E),(0,c.useState)(()=>{if(!O||typeof window>"u"||E==="pages"||E==="picture")return;let{pathname:m,search:_,hash:ue}=window.location;At(m,e.basePath)==="/"&&window.history.replaceState(window.history.state,"",`${N(ve)}${_}${ue}`)}),Jn(p,E,e.onIntrinsicHeight),oo(E,J);let se=nr(e.onError,E),Pe=rr(e.onReady,E),Ne=(0,c.useRef)(e.onFaceDrawn);Ne.current=e.onFaceDrawn;let Le=(0,c.useCallback)((m,_)=>{Pe(_),Ne.current?.(m)},[Pe]),[pt,mt]=(0,c.useState)(null),Ge=L.places(),I=(0,c.useRef)({shown:E,onFace:e.onFace});I.current={shown:E,onFace:e.onFace};let ee=(0,c.useCallback)((m,_,ue)=>{if(O){q.current?.(m,_,ue);return}I.current.onFace?.(m),B.current?.(m==="pages"?_??$.current.path:ve,"push")},[O]),[te,Ae]=(0,c.useState)(void 0);(0,c.useEffect)(()=>{E==="pages"&&Ae(void 0)},[E]);let ge=(0,c.useRef)(o);(0,c.useEffect)(()=>{ge.current!==o&&(ge.current=o,Ae(void 0))},[o]);let Ue=(0,c.useCallback)(m=>{if(I.current.shown==="pages"){if(Y(!0),Ae(m),F==="scene"||F==="graview"){ur(F,()=>{O?window.history.pushState(null,"",`${N(ve)}${m??""}`):B.current?.(ve,"push")});return}ur(ce.current,()=>ee(ce.current,void 0,m))}},[O,F,e.basePath,ee]),Me=(0,c.useCallback)(m=>{if(I.current.shown==="pages"){ye.go.current||($.current.path=m),X(m);return}if($.current.path=m,H(m),Ce.current){Y(!1),O?window.history.pushState(null,"",N(m)):B.current?.(m,"push");return}ee("pages",m)},[ye,X,H,ee,O,e.basePath]),Re=L.arrangement?.(),le=E==="pages",Ve=O?N:void 0;return(0,y.jsxs)("section",{ref:p,className:g,"aria-label":e.label??n.name,"data-graview-embed":E,"data-graview-scheme":A,...ze?{"data-graview-embed-narrow":""}:{},style:{position:"relative",isolation:"isolate",height:ne,minHeight:v?0:320,display:"flex",flexDirection:"column",overflow:"hidden",borderRadius:"var(--graview-radius, 12px)"},children:[(0,y.jsx)("style",{children:P}),(0,y.jsxs)(Ln.Provider,{value:se,children:[(0,y.jsx)(Qn,{rootRef:p,board:C}),(0,y.jsx)(Un,{rootRef:p,firstLook:e.firstLook,app:Dn(R??{name:n.name},n.schema)}),(0,y.jsx)(We,{module:"@graview/react",report:se,content:!0,children:(0,y.jsx)(Pn,{store:k,views:L,initialView:G,scheme:A,...Zn(e,S,R),...e.onSeat?{onSeat:e.onSeat}:{},children:(0,y.jsxs)(Vn.Provider,{value:C,children:[(0,y.jsx)(po,{face:E,stop:te??o,kinds:M,places:Ge,opens:U}),j?(0,y.jsx)(lo,{into:j}):null,(0,y.jsx)(uo,{rootRef:p,face:F,shown:E,path:ae,stop:o,draft:ke.n,onDrawn:e.onDrawn}),O?(0,y.jsx)(jn,{pagesWere:V?.path,basePath:e.basePath,shown:E,onFace:e.onFace,toggle:q,kinds:M,places:Ge,opens:U,landed:Oe}):null,a&&E!=="picture"?(0,y.jsx)(We,{module:"@graview/embed",report:se,children:(0,y.jsx)(Xn,{name:R?.name??n.name,heading:b,named:Vt(a).name!==!1,faces:Vt(a).faces===!1?void 0:{scene:{label:yn(Re),current:!le,go:()=>Ue(),reach:()=>void xe(ce.current)},pages:{label:gn(Re),current:le,go:()=>Me($.current.path),reach:()=>void xe("pages")}},at:le?ae:null,without:e.pages?.without(),home:{...Ve?{href:Ve("/")}:{},go:()=>Me("/"),current:le&&ae.split("?")[0]==="/"},reach:{...Ve?{href:Ve}:{},go:m=>Me(m.path)},standing:d,hostActions:e.hostActions,keeping:le?void 0:(0,y.jsx)(mo,{app:n,studio:e.studio,report:se}),onFind:mt,switch:e.switch})}):null,(0,y.jsx)(Hn.Provider,{value:pt,children:(0,y.jsx)(We,{module:E==="pages"||E==="picture"?"@graview/pages":"@graview/react",report:se,content:!0,children:(0,y.jsxs)(c.Suspense,{fallback:(0,y.jsx)(io,{auto:v,scene:E!=="pages"&&E!=="picture"}),children:[E==="picture"?(0,y.jsx)(to,{scope:g,store:k,views:L,as:(o?nt(o).within?.view:void 0)??""}):E==="pages"?(0,y.jsx)(eo,{store:k,views:L,presence:S,auto:v,brand:R,steering:ye,overview:Ue,scope:g,titleLevel:er(b),quickAsk:at(e.quickAsk),props:{...e,onNavigate:K,...O?{}:{path:$.current.path}}}):(0,y.jsx)(Zr,{address:O,auto:v,scheme:A,scope:g,quickAsk:at(e.quickAsk)}),(0,y.jsx)(ao,{asked:F,shown:E,onDrawn:Le})]})},E)})]})})})]})]})}var It=e=>e.split(/[?#]/)[0]===ve,Er=(0,c.createContext)(null);function lo({into:e}){return e.view=rt().view,null}function uo({rootRef:e,face:n,shown:o,path:a,stop:d,draft:l,onDrawn:b}){let{view:p}=rt(),g=o==="scene"||o==="graview",P=Tt(p),A={face:n,path:g?ve:o==="picture"?d??"#":a,stop:P};return sr(e,`${o} ${g?P:A.path} ${l}`,A,b),null}var lt,fo=be(()=>(__graviewPreload(import.meta.url,["./chunk.3VFYSXMQ.js","./chunk.XSNAG4JT.js","./chunk.XWAMQPUM.js","./chunk.SDO3U72B.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.Z5IGHCZX.js"))),jt=()=>fo().then(e=>void(lt=e),()=>new Promise(e=>{let n=()=>{window.removeEventListener("online",n),clearTimeout(o),e()},o=setTimeout(n,1e4);window.addEventListener("online",n)}).then(jt));function po({face:e,stop:n,kinds:o,places:a,opens:d}){let{view:l,go:b}=rt(),p=(0,c.useRef)({face:e,stop:n});return(0,c.useLayoutEffect)(()=>{let g=p.current.stop!==n,P=p.current.face!==e,A=p.current.face==="pages";if(p.current={face:e,stop:n},!g&&!P||e==="pages"||e==="picture")return;let k=(g||A)&&n!==void 0?Sr(e,n,o,a):A&&zn(l)?Lt(e,Mt(d),o):e==="graview"?xt(l,!0):l.overview?kn(xt(l,!1),Nn(l,o)):l;b(k)},[e,n,o,l,b,d]),null}function mo({app:e,studio:n,report:o}){return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(c.Suspense,{fallback:null,children:(0,y.jsx)(Xr,{})}),n!==!1?(0,y.jsx)(We,{module:"@graview/studio",report:o,children:(0,y.jsx)(ho,{app:e,studio:n})}):null]})}function ho({app:e,studio:n}){let o={app:e,within:"box",...n?{onApply:n.onApply}:{},...n?.landmark?{landmark:n.landmark}:{},...n?.offered!==void 0?{offered:n.offered}:{}},a=n?.place;return a?(0,y.jsx)(a,{...o}):(0,y.jsx)(c.Suspense,{fallback:null,children:(0,y.jsx)(so,{...o})})}function yo({path:e,stop:n,...o},a){return{...o,app:a.app,at:a.at,...a.remote.presence?{presence:a.remote.presence}:{}}}function qt(e,n){let o=n.store??n.remote?.store??Gn(n.app,n.seed),a=n.notices??ot(),d=null,l={},b=0,p=n.label,g=n.app,P=Promise.resolve(),A=n.at?.face??n.face,k=A===void 0?void 0:Ct({...n,face:A}),S=k??Wt(n.stop),R=null,v=[],ne=f=>{if(R=f,f!==S)return;let C=v;v=[];for(let N of C)N()};function ke(){let[f,C]=(0,c.useState)(k),[N,re]=(0,c.useState)(n.stop),[T,oe]=(0,c.useState)(n.path),[z,x]=(0,c.useState)(n.scheme??"auto"),[F,M]=(0,c.useState)(n.principal),[O,V]=(0,c.useState)(n.seats),[U,G]=(0,c.useState)(n.quickAsk),[ie,$]=(0,c.useState)(n.people),[he,B]=(0,c.useState)(n.hostContext),[K,ae]=(0,c.useState)(n.brand),[H,ye]=(0,c.useState)(n.label),[X,j]=(0,c.useState)(n.hostActions),[q,Oe]=(0,c.useState)(void 0),[J,Ee]=(0,c.useState)(n.draftView);return d={app:Y=>{Oe(Y),oe(void 0),re(void 0)},face:C,stop:re,path:oe,scheme:x,seat:M,seats:V,quickAsk:G,people:$,hostContext:B,brand:ae,label:ye,hostActions:j,draft:Ee},(0,y.jsx)(Er.Provider,{value:l,children:(0,y.jsx)(kr,{...q?yo(n,q):n,store:o,notices:a,...f!==void 0?{face:f}:{},onOpening:Y=>{S=Y},...N!==void 0?{stop:N}:{},...T!==void 0?{path:T}:{},...F?{principal:F}:{},...O?{seats:O}:{},...U!==void 0?{quickAsk:U}:{},...ie?{people:ie}:{},...he?{hostContext:he}:{},...K?{brand:K}:{},label:H,hostActions:X,draftView:J,scheme:z,onFace:Y=>{S=Y,C(Y)},onSeat:M,onFaceDrawn:ne},q?.n??0)})}let L=()=>{let f=l.view?.focusId,C=f?o.graph.getNode(f)?.kind:void 0,N=(l.shown??S)==="scene"||(l.shown??S)==="graview";return{face:S,path:N?ve:l.pages?.()??n.path??"/",stop:l.view?Tt(l.view):n.stop??"#",...C?{kind:C}:{}}},Z=(0,pr.createRoot)(e);return(0,W.flushSync)(()=>Z.render((0,y.jsx)(ke,{}))),{get store(){return o},where:L,setApp:(f,C,N)=>{let re="graph"in C?{store:C}:C,T=()=>{let oe=L();o=re.store,p=N?.label??(p===g.name?f.name:p),g=f,(0,W.flushSync)(()=>{d?.label(p),d?.app({app:f,remote:re,at:oe,n:++b})})};lt?T():P=P.then(jt).then(T)},setFace:f=>{S=f,(0,W.flushSync)(()=>d?.face(f))},setStop:f=>(0,W.flushSync)(()=>d?.stop(f)),setPath:f=>(0,W.flushSync)(()=>{if(It(f)){(S==="pages"||S==="picture")&&(S="scene",d?.face("scene"));return}d?.path(f),S!=="pages"&&(S="pages",d?.face("pages"))}),setScheme:f=>(0,W.flushSync)(()=>d?.scheme(f)),setSeat:f=>(0,W.flushSync)(()=>d?.seat(f)),setSeats:f=>(0,W.flushSync)(()=>d?.seats(f)),setQuickAsk:f=>(0,W.flushSync)(()=>d?.quickAsk(f)),setPeople:f=>(0,W.flushSync)(()=>d?.people(f)),setHostContext:f=>(0,W.flushSync)(()=>d?.hostContext(f)),setBrand:f=>(0,W.flushSync)(()=>d?.brand(f)),setDraftView:f=>(0,W.flushSync)(()=>d?.draft(f)),setLabel:f=>{p=f,(0,W.flushSync)(()=>d?.label(f))},setHostActions:f=>(0,W.flushSync)(()=>d?.hostActions(f)),drawn:()=>P.then(()=>R===S?void 0:new Promise(f=>v.push(f))),notify:f=>{let C;return(0,W.flushSync)(()=>{C=a.notify(f)}),C},unmount:()=>Z.unmount()}}var Pr="/graview/live",zt="graview.ship",Gt=`${zt}.${Xe}`;var me={seat:"x-graview-seat",roles:"x-graview-roles",kind:"x-graview-kind",name:"x-graview-name",for:"x-graview-for",forRoles:"x-graview-for-roles",forName:"x-graview-for-name",via:"x-graview-via"};var He=class extends Error{constructor(n){super(n),this.name="Superseded"}},Se=e=>e?.lineage?{lineage:e.lineage}:{},go=(e,n)=>`${e.calls.map(o=>o.name.replace(/-/g," ")).join(", ")} (${n instanceof Error?n.message.split(`
2
- `)[0]??"":String(n)})`;function wo(e){if(!e)return[];try{let n=e.storage.getItem(e.key);if(n===null)return[];e.storage.removeItem(e.key);let o=JSON.parse(n);return Array.isArray(o)?o.filter(a=>!!a&&Array.isArray(a.calls)):[]}catch{return[]}}var De=class extends Error{constructor(o){super(o.sentence);this.refusal=o;this.name="RemoteRefusedError"}},vo={401:"forbidden",403:"forbidden",404:"missing",413:"limit"},Fe=class extends Error{constructor(o,a){super(o);this.conflicts=a;this.name="StaleWrite"}},qe=class extends Error{constructor(n){super(n),this.name="Unreached"}},bo=new Set([502,503,504]);async function So(e){try{return(await e.clone().json()).reason==="unavailable"}catch{return!1}}function ko(){let e=Math.random().toString(36).slice(2,8),n=0;return()=>`local-${e}-${++n}`}var Eo=1,Po=()=>({refusals:new Set,conflicts:new Set,statuses:new Set,helds:new Set,builds:new Set,who:new Set,declarations:new Set,tally:{reconnects:0,rebases:0,conflicts:0,resyncs:0}});async function ut(e){return(await Rr(e,wo(e.carry),"This app was updated while your changes were on the way.",Po())).remote}async function Rr(e,n,o,a){let d=e.fetch??fetch,l={"content-type":"application/json",...e.headers??{}},b={...ft(e.principal),[me.via]:e.via??"web"};Object.assign(l,b);let p=e.live===!0,g=e.presenceEveryMs,P=e.visible??To,A="connecting",k=a.statuses,S=a.tally,R=[],v,ne=[],ke=()=>A==="online"&&v!==void 0?"held":A,L=()=>{let t=ke();if(a.told!==t){a.told=t;for(let r of[...k])r(t)}},Z=t=>{if(!(t===A||de)&&(A==="offline"&&t==="online"&&S.reconnects++,A=t,L(),t==="online"))for(let r of R.splice(0))r.again()},f=t=>{if(de)return;let r=typeof t=="string"&&t.length>0?t:void 0,s=r!==v;if(v=r,C(),!!s&&(L(),r===void 0)){for(let i of ne.splice(0))i();Q&&clearTimeout(Q),Qt()}},C=()=>{if(a.toldHeld!==v){a.toldHeld=v;for(let t of[...a.helds])t(v??null)}},N=async(t,r)=>{let s;try{s=await d(t,r)}catch(i){throw m()||Z("offline"),new qe(i instanceof Error?i.message:String(i))}if(s.status===503&&await So(s))return Z("online"),s;if(bo.has(s.status))throw m()||Z("offline"),new qe(`The server is away (${s.status})`);return Z("online"),s},re=async(t=!1)=>{let r=`${e.url}/graview/state?opFormat=${_e.op}`,s=t?await d(r,{headers:l}):await N(r,{headers:l});if(!s.ok)throw new Error((await s.json().catch(()=>({}))).error??`The server refused (${s.status})`);return await s.json()},T=e.state??await re(!0);p||(A="online"),v=typeof T.held=="string"&&T.held.length>0?T.held:void 0,C();let oe=T.enabledModules??e.enabledModules,z=e.localApp?e.localApp(e.app):e.app,x=new hn({schema:z.schema,mutations:z.mutations??[],invariants:z.invariants??[],...z.policy?{policy:z.policy}:{},...z.modules?{modules:z.modules}:{},...oe?{enabledModules:oe}:{},...z.intelligence?{intelligence:z.intelligence}:{},...z.brand?.timeZone?{timeZone:z.brand.timeZone}:{},snapshot:T.snapshot,log:T.log,...T.horizon!==void 0?{horizon:T.horizon}:{},ids:ko(),...e.storeOptions??{}});fn.served.add(x);let F=pn(x),M=T.log.at(-1)?.seq??(T.horizon??0)-1,O=Pt.of(T.log,{horizon:T.horizon??0}),V=null,U,G=new Map,ie=a.who,$=!1,he=t=>{if(de)return;$=!0;let r=vn(new Map,t,Date.now(),1e4,V?.participant);U!==void 0&&r.delete(U);let s=r.size!==G.size;if(!s)for(let[i,u]of r)Rt(u,G.get(i))||(s=!0);if(G=r,!!s)for(let i of[...ie])i([...G.values()])},B=[],K=new Set,ae=t=>{let r=B.indexOf(t);r>=0&&B.splice(r,1)},H=new Map,ye=(t,r)=>{let s=H.get(t);s&&(H.delete(t),s.resolve({ops:r.filter(i=>i.batch===t),batch:t}))},X,j=[],q=(t,r=[])=>{if(t.length===0&&r.length===0)return[];if(X)return j.push({ops:t,drop:r}),[];let s=Math.min(...t.filter(w=>w.seq>M).map(w=>w.seq));if(Number.isFinite(s)&&s>M+1)return j.push({ops:t,drop:r}),Oe(),[];let i=B.filter(w=>t.some(Ie=>Ie.batch===w)),u=[...new Set([...r,...i])].filter(w=>K.has(w)),h,D=B.filter(w=>!i.includes(w));try{h=x.rebase({confirmed:t,pending:D,drop:u}).confirmed}catch(w){if(!(w instanceof mn))throw w;return j.push({ops:t,drop:r}),Oe(),[]}for(let w of i)ae(w);t.some(w=>w.seq>M)&&D.some(w=>!u.includes(w))&&S.rebases++,t.length>0&&(M=Math.max(M,...t.map(w=>w.seq)),O.note(t));for(let w of u)K.delete(w);for(let w of i)ye(w,t);return h},Oe=()=>{X||(X=Pe(re().then(t=>{if(J(t)){j=[];return}let r=new Set(t.log.map(u=>u.batch)),s=B.filter(u=>r.has(u));for(let u of s)ae(u);let i=x.adopt({snapshot:t.snapshot,log:t.log,...t.horizon!==void 0?{horizon:t.horizon}:{},pending:[...B],drop:[...K].filter(u=>!B.includes(u))});K.clear();for(let u of i.pending)K.add(u.batch);M=t.log.at(-1)?.seq??(t.horizon??0)-1,O=Pt.of(t.log,{horizon:t.horizon??0}),S.resyncs++;for(let u of s)ye(u,t.log)}).then(()=>{X=void 0;let t=j;j=[];for(let{ops:r,drop:s}of t)q(r,s)},()=>{X=void 0,j=[]})))},J=t=>(typeof t.build=="string"&&Xt(t.build),typeof t.version=="number"&&f(t.held),typeof t.version!="number"||t.version===T.version?!1:(wt(t.version),!0)),Ee=async t=>{let s=await(await N(`${e.url}/graview/since?seq=${t}&opFormat=${_e.op}`,{headers:l})).json();return J(s)?[]:s.ops??[]},Y=async()=>{let t=await ze();return X&&await X,t},ze=async()=>{if(V&&!m()&&P()){let r=await(await N(`${e.url}/graview/here`,{method:"POST",headers:l,body:JSON.stringify({presence:V,seq:M})})).json();return J(r)?[]:(typeof r.participant=="string"&&(U=r.participant),he(r.who??[]),q(r.ops??[]))}return q(await Ee(M))},E=new Map,Ce=new Map,ce=new Map,se=new Set,Pe=t=>(se.add(t),t.finally(()=>se.delete(t)).catch(()=>{}),t),Ne=Promise.resolve(),Le=0,pt=(t,r)=>{let s=Ne.then(()=>Ge(t,r));return Ne=s.catch(()=>{}),s},mt=()=>new Promise((t,r)=>R.push({again:t,give:r})),Ge=async(t,r)=>{let s,i;for(;;){try{s=await N(`${e.url}/graview/ops`,{method:"POST",headers:l,body:JSON.stringify({...t,opFormat:_e.op})})}catch(w){if(!(w instanceof qe)||te)throw w;if(await mt(),m())return Ke(t,r);continue}if(i=await s.json().catch(()=>({})),s.status===503&&i.reason==="unavailable"&&typeof i.held=="string"&&!te){if(typeof i.version=="number"?J(i):(f(i.held),!1))break;if(v!==void 0&&(St>0||p)){if(await new Promise(w=>ne.push(w)),te)throw new He("The client closed.");if(m())return Ke(t,r);continue}}let D;if(s.status===503&&i.reason==="unavailable"&&!te)D=Ut(e.backoff,Le++);else{if(Le=0,s.status!==429||te)break;D=Ao(s.headers.get("retry-after"),i.retryAfter)}if(await new Promise(w=>setTimeout(w,D)),m())return Ke(t,r)}if(de||J(i))throw new He("The app was changed.");if(!s.ok){let D=i.error??`The server refused (${s.status})`;throw i.conflict?new Fe(D,i.conflicts??[]):new De({reason:i.reason??vo[s.status]??"invalid",sentence:D,...i.wouldNeed?.length?{wouldNeed:i.wouldNeed}:{}})}let u=i.ops??[],h=u[0]?.seq;return h!==void 0&&h>M+1&&(u=await Ee(M)),r!==void 0&&(i.batch&&E.set(r,i.batch),ae(r)),q(u,r!==void 0?[r]:[]),{ops:i.ops??[],...i.batch?{batch:i.batch}:{}}},I,ee=!1,te=!1,Ae=0,ge,Ue=0,Me=0,Re=null,le=()=>{},Ve=new Promise(t=>{le=t}),m=()=>p&&ee&&I?.readyState===Eo,_=t=>{if(!m())return!1;try{return I.send(JSON.stringify(t)),!0}catch{return!1}},ue=(t=!1)=>{!V||!m()||!P()||!t&&Re&&Rt(V,Re)&&(g===void 0||Date.now()-Me<g)||_({t:"here",presence:V})&&(Re=V,Me=Date.now())},we=new Set,Q,Qt=()=>{if(Q=void 0,v!==void 0)return;let t=[...H.entries()].filter(([r])=>we.has(r));we.clear();for(let[,r]of t)_(r.message)},Zt=(t,r)=>{H.has(t)&&(we.add(t),Q&&clearTimeout(Q),Q=setTimeout(Qt,Math.max(0,r)))},Fr=t=>{H.has(t)&&we.add(t)},Ke=(t,r)=>new Promise((s,i)=>{let u=r??`send-${++Ue}`,h=t.undo?{t:"undo",cid:u,batches:t.undo,...t.intent?{intent:t.intent}:{},...t.batch?{batch:t.batch}:{},...t.via?{via:t.via}:{},...Se(t)}:{t:"call",cid:u,calls:t.calls??[],...t.intent?{intent:t.intent}:{},...t.batch?{batch:t.batch}:{},...t.base?.length?{base:t.base}:{},...t.via?{via:t.via}:{},...Se(t)};if(H.set(u,{message:h,...r!==void 0?{mine:r}:{},resolve:s,reject:i}),we.size>0||v!==void 0){we.add(u);return}_(h)}),ht=(t,r)=>m()?Ke(t,r):pt(t,r),Or=t=>{switch(t.t){case"welcome":{if(Xt(t.build),typeof t.version=="number"&&t.version!==T.version){wt(t.version);return}if(ee=!0,Ae=0,typeof t.participant=="string"&&(U=t.participant),f(t.held),q(t.ops??[]),we.clear(),Q&&clearTimeout(Q),Q=void 0,v!==void 0)for(let r of H.keys())we.add(r);else for(let r of H.values())_(r.message);ue(!0),Z("online"),le();return}case"ops":q(t.ops??[]);return;case"ack":{let r=H.get(t.cid);if(!r){q(t.ops??[]);return}H.delete(t.cid),Le=0,r.mine!==void 0&&(E.set(r.mine,t.batch),ae(r.mine)),q(t.ops??[],r.mine!==void 0?[r.mine]:[]),r.resolve({ops:t.ops??[],batch:t.batch});return}case"refused":case"conflict":{let r=H.get(t.cid);if(!r)return;if(t.t==="refused"&&t.reason==="unavailable"){v!==void 0?Fr(t.cid):Zt(t.cid,Ut(e.backoff,Le++));return}H.delete(t.cid),r.reject(t.t==="conflict"?new Fe(t.sentence,t.conflicts??[]):new De({reason:t.reason??"invalid",sentence:t.sentence,...t.wouldNeed?.length?{wouldNeed:[...t.wouldNeed]}:{}}));return}case"busy":typeof t.cid=="string"&&Zt(t.cid,typeof t.retryAfter=="number"?t.retryAfter:1e3);return;case"presence":he(t.who??[]);return;case"held":f(t.sentence);return;case"declaration":typeof t.version=="number"&&t.version!==T.version&&wt(t.version);return;case"reload":rn(typeof t.reason=="string"?t.reason:"This app was updated.");return;case"error":if(t.reopen===!0&&I){let r=I;an(r);try{r.close(1e3,"Opening again.")}catch{}}return;default:return}},de=!1,yt=a.declarations,gt=a.builds,Xt=t=>{if(!(de||a.otherBuild!==void 0||!e.build||typeof t!="string"||t.length===0||t===e.build)){a.otherBuild=t;for(let r of[...gt])r(t)}},en=()=>{let t=[],r=0;for(let s of B){let i=ce.get(s);i?t.push({calls:i.calls,...i.intent?{intent:i.intent}:{},...i.via?{via:i.via}:{},...Se(i),batch:s}):r++}return{carried:t,undos:r}},tn=(t,r)=>`${r} while ${t===1?"an undo of yours was":"undos of yours were"} on the way; ${t===1?"it was":"they were"} not made.`,nn=t=>{de=!0,V=null;let r=new He(t);for(let i of H.values())i.reject(r);H.clear(),Qe&&clearInterval(Qe),te=!0,ge&&clearTimeout(ge),Q&&clearTimeout(Q),fe&&clearTimeout(fe);for(let i of R.splice(0))i.give(r);for(let i of ne.splice(0))i();let s=I;I=void 0,ee=!1;try{s?.close(1e3,t)}catch{}le()};async function wt(t){if(de)return;if(!e.resolveApp){rn(`This app was changed on its server (version ${t}); reload the page to carry on.`);return}let{carried:r,undos:s}=en(),i=e.resolveApp,u=V;nn("The app was changed.");try{let h=await i(t),{state:D,...w}=e,Ie=await Rr({...w,app:h},r,"The app was changed while your changes were on the way.",a);u&&Ie.remote.presence.here(u);for(let Ze of[...yt])Ze(Ie.remote,t);let Dr=[...s>0?[Je(tn(s,"The app was changed"))]:[],...Ie.unheard()];for(let Ze of Dr)for(let Nr of Be)Nr(Ze.sentence,Ze)}catch(h){let D=`The app was changed, but the new version could not be opened: ${h instanceof Error?h.message:String(h)}`;for(let w of Be)w(D,Je(D))}}function rn(t){if(de)return;let{carried:r,undos:s}=en();nn(t);let i=!1;if(e.carry&&r.length>0)try{e.carry.storage.setItem(e.carry.key,JSON.stringify(r)),i=!0}catch{}let u=[];!i&&r.length>0&&u.push(`${t} ${r.length===1?"A change of yours was":`${r.length} changes of yours were`} not sent; make ${r.length===1?"it":"them"} again after the page reloads.`),s>0&&u.push(tn(s,"This app was updated"));for(let h of u)for(let D of Be)D(h,Je(h));(e.reloadPage??Ro)()}let on=()=>{if(te||!p)return;let t=`${e.url.replace(/^http/,"ws").replace(/\/$/,"")}${Pr}`,{"content-type":r,...s}=l,i;try{i=e.socket?e.socket(t,s,[Gt]):Hr(t,s)}catch{return sn()}I=i,ee=!1,i.onopen=()=>{I===i&&i.send(JSON.stringify({t:"hello",seq:M,protocol:Xe,wire:zt,opFormat:_e.op,...e.build?{build:e.build.slice(0,64)}:{},...e.hostProtocol!==void 0?{hostProtocol:e.hostProtocol}:{}}))},i.onmessage=u=>{if(I!==i)return;let h;try{h=JSON.parse(String(u.data))}catch{return}Or(h)},i.onclose=()=>an(i),i.onerror=()=>{}},fe,Cr=()=>{$=!1,fe&&clearTimeout(fe),fe=setTimeout(()=>{if(fe=void 0,$||te)return;let t=new Map([...G].filter(([,r])=>r.held!=="socket"));if(t.size!==G.size){G=t;for(let r of ie)r([...G.values()])}},1e4),fe.unref?.()};function an(t){if(I!==t)return;let r=ee;I=void 0,ee=!1,Re=null,r&&(Z("offline"),Cr()),sn()}let sn=()=>{if(te)return;let t=Ut(e.backoff,Ae);Ae++,ge=setTimeout(on,t)},Lr=x.applyAll.bind(x),Mr=x.undo.bind(x),Vr=x.previewAll.bind(x);x.previewAll=(t,r)=>Vr(t,{...e.principal?{author:e.principal}:{},...r});let Be=a.refusals,$e=[],Je=t=>({reason:"invalid",sentence:t}),Ye=a.conflicts,vt=!1,dn=async(t,r)=>{if(r instanceof He||de)return;let s=r instanceof De?r.refusal:ln(r),i=s.sentence;ae(t);try{q([],[t])}catch{}let u=ce.get(t);if(ce.delete(t),r instanceof Fe&&S.conflicts++,r instanceof Fe&&!m()&&await Y().catch(()=>[]),r instanceof Fe&&Ye.size>0){let h=!1,D={sentence:i,conflicts:r.conflicts,keepTheirs(){h=!0},useMine(){if(!(h||!u)){h=!0,vt=!0;try{x.applyAll(u.calls,{...u.intent?{intent:u.intent}:{},...u.via?{via:u.via}:{},...Se(u)})}finally{vt=!1}}}};for(let w of Ye)w(D);return}for(let h of Be)h(i,s)};x.applyAll=(t,r)=>{let s=un(x.log.all().filter(h=>K.has(h.batch))),i=Lr(t,{...e.principal?{author:e.principal}:{},...r});B.push(i.batch),K.add(i.batch),ce.set(i.batch,{calls:t,...r?.intent?{intent:r.intent}:{},...r?.via?{via:r.via}:{},...Se(r)});let u=vt?[]:O.baseFor(i.ops,s);return Ce.set(i.batch,Pe(ht({calls:t,...r?.intent?{intent:r.intent}:{},batch:i.batch,...u.length>0?{base:u}:{},...r?.via?{via:r.via}:{},...Se(r)},i.batch).catch(h=>dn(i.batch,h)))),i},x.apply=(t,r)=>x.applyAll([t],r),x.undo=(t,r)=>{let s=typeof t=="string"?[t]:t,i=Mr(s.map(h=>E.get(h)??h),{...e.principal?{author:e.principal}:{},...r});B.push(i.batch),K.add(i.batch);let u=Promise.allSettled(s.map(h=>Ce.get(h)));return Ce.set(i.batch,Pe(u.then(()=>ht({undo:s.map(h=>E.get(h)??h),...r?.intent?{intent:r.intent}:{},batch:i.batch,...r?.via?{via:r.via}:{},...Se(r)},i.batch)).catch(h=>dn(i.batch,h)))),i};let Br=async(t,r={})=>{bt++;try{return(await Pe(ht({calls:t,...r}))).ops}finally{bt--}},bt=0,cn={here(t){V=t,ue()},onWho(t){return ie.add(t),G.size>0&&t([...G.values()]),()=>{ie.delete(t)}},leave(){if(!V)return;let t=JSON.stringify({participant:U??V.participant});if(V=null,_({t:"bye"}))return;let r=globalThis.navigator?.sendBeacon;r?r.call(globalThis.navigator,`${e.url}/graview/leave`,t):d(`${e.url}/graview/leave`,{method:"POST",headers:l,body:t}).catch(()=>{})}},St=e.pollMs??800,Qe=St>0&&typeof setInterval=="function"?setInterval(()=>{m()||Y().catch(()=>{})},St):null;if(p){on();let t;await Promise.race([Ve,new Promise(r=>t=setTimeout(r,e.openTimeoutMs??3e3))]),clearTimeout(t)}if(n.length>0&&!de){let t=[],r=new Set(x.log.all().map(s=>s.batch));for(let s of n)if(!(s.batch!==void 0&&r.has(s.batch)))try{x.applyAll(s.calls,{...s.intent?{intent:s.intent}:{},...s.batch?{batch:s.batch}:{},...s.via?{via:s.via}:{},...Se(s)})}catch(i){t.push(go(s,i))}t.length>0&&$e.push(Je(`${o} ${t.length===1?"One no longer fits and was not made":`${t.length} no longer fit and were not made`}: ${t.join("; ")}.`))}return{remote:{store:x,version:T.version,migrated:T.migrated??[],send:Br,pull:Y,onRefusal(t){Be.add(t);let r=$e;$e=[];for(let s of r)t(s.sentence,s);return()=>Be.delete(t)},onDeclaration(t){return yt.add(t),()=>yt.delete(t)},onBuild(t){return gt.add(t),a.otherBuild!==void 0&&t(a.otherBuild),()=>gt.delete(t)},onConflict(t){return Ye.add(t),()=>Ye.delete(t)},revision:(t,r)=>O.of(t,r),seq:()=>M,participant:()=>U,transport:()=>m()?"socket":"poll",status:ke,onStatus(t){return k.add(t),()=>k.delete(t)},held:()=>v,onHeld(t){return a.helds.add(t),v!==void 0&&t(v),()=>a.helds.delete(t)},counters:()=>({...S}),who:()=>[...G.values()],pending:()=>B.length+bt,async settled(){for(;se.size>0;)await Promise.allSettled([...se])},presence:cn,close(){Qe&&clearInterval(Qe),F(),cn.leave(),te=!0,ge&&clearTimeout(ge),Q&&clearTimeout(Q),fe&&clearTimeout(fe);for(let r of R.splice(0))r.give(new Error("The client closed before the server could be reached."));for(let r of ne.splice(0))r();let t=I;I=void 0,ee=!1;try{t?.close(1e3,"Closed.")}catch{}}},unheard(){let t=$e;return $e=[],t}};function Hr(t,r){let s=globalThis.WebSocket;if(!s)throw new Error("This runtime has no WebSocket; the client polls instead.");let i=typeof globalThis.document<"u",u=e.subprotocol?[Gt]:[];if(!i)try{return new s(t,{headers:r,...u.length>0?{protocols:u}:{}})}catch{}let h=new URL(t);for(let[D,w]of Object.entries(b))h.searchParams.set(D,w);return u.length>0?new s(h.toString(),u):new s(h.toString())}}function Ao(e,n,o=Date.now()){let a,d=e?.trim();if(d)if(/^\d+(\.\d+)?$/.test(d))a=Number(d)*1e3;else{let p=Date.parse(d);Number.isFinite(p)&&(a=Math.max(0,p-o))}let l=typeof n=="number"&&Number.isFinite(n)&&n>=0?n:void 0,b=l!==void 0&&l<50&&a!==void 0&&Math.abs(l*1e3-a)<1e3;return l!==void 0&&!b?l:a??1e3}function Ro(){globalThis.location?.reload?.()}function To(){return globalThis.document?.visibilityState!=="hidden"}function Ut(e,n){if(typeof e=="function")return Math.max(0,e(n));let{min:o=250,max:a=1e4,factor:d=2}=e??{};return Math.min(a,o*d**n)*(.75+Math.random()*.5)}function ft(e){let n={};if(!e)return n;e.id&&(n[me.seat]=e.id),e.roles?.length&&(n[me.roles]=e.roles.join(",")),e.kind!=="human"&&(n[me.kind]=e.kind),e.name&&(n[me.name]=encodeURIComponent(e.name));let o=e.onBehalfOf;return o?.id&&(n[me.for]=o.id),o?.roles?.length&&(n[me.forRoles]=o.roles.join(",")),o?.name&&(n[me.forName]=encodeURIComponent(o.name)),n}var Tr="/graview/views";function Kt(e){let n=e.fetch??fetch,o=e.url.replace(/\/$/,""),a={"content-type":"application/json",...e.principal?ft(e.principal):{},...e.headers??{}},d=e.state?{hidden:e.state.hidden??[],removed:e.state.removed??[],may:e.state.may??et.may}:et,l=new Set,b=k=>{if(JSON.stringify(k)!==JSON.stringify(d)){d=k;for(let S of l)S()}},p=async(k,S)=>{let R=await n(`${o}${e.path??Tr}`,{method:k,headers:a,...S!==void 0?{body:JSON.stringify(S)}:{}}),v=await R.json();if(!R.ok)throw new Error(v.error??`The store answered ${R.status}.`);b({hidden:v.hidden??[],removed:v.removed??[],may:v.may??et.may})},g=()=>p("GET"),P=e.state?Promise.resolve():g().catch(()=>{}),A=e.pollMs?setInterval(()=>void g().catch(()=>{}),e.pollMs):void 0;return{ready:P,refresh:g,close:()=>clearInterval(A),current:()=>d,onChange(k){return l.add(k),()=>void l.delete(k)},hide:k=>p("POST",{hide:k}),show:k=>p("POST",{show:k}),remove:(k,S)=>p("POST",{remove:k,...S?{about:S}:{}}),async restore(k){let S=d.removed.find(R=>R.name===k)?.lens;await p("POST",{restore:k}),S&&await e.onDeclaration?.()},async lens(k){await p("POST",{lens:k}),await e.onDeclaration?.()}}}var Yt=document.getElementById("graview-app"),Jt=/^\/forms\/([^/]+)\/?$/.exec(location.pathname),xr=Jt?(__graviewPreload(import.meta.url,["./chunk.UR3XYOQ6.js","./chunk.WQONZBA3.js","./chunk.UGFDSE37.js","./chunk.NWA7Q6CI.js","./chunk.WP5W44Y4.js","./chunk.M5GJHVWZ.js","./chunk.HZCA3UWJ.js","./chunk.JBW3DI7E.js","./chunk.AGIO2GRV.js","./chunk.NIVTK2W5.js","./chunk.6QYJ2K6K.js","./chunk.3MMLRSRC.js","./chunk.DQOCBKC3.js","./chunk.OHSJQYJN.js","./chunk.DEUTHHGI.js","./chunk.EPUBSKKL.js","./chunk.ATDU5Y7V.js","./chunk.AQQZY6OY.js","./chunk.BCWPV4WR.js","./chunk.Y5ARSVH4.js","./chunk.PKUDIWIF.js","./chunk.VW2VCPJX.js","./chunk.IW7YFPGG.js","./chunk.MB7LKKUD.js","./chunk.JT3IZIU5.js","./chunk.S5MQVPLF.js","./chunk.WVUJXDXZ.js","./chunk.ZIEHF67C.js","./chunk.UHX4WTM7.js","./chunk.IKX4VDTW.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.GZHZLJBF.js","./chunk.6MADC6DM.js","./chunk.OJGHDWI6.js","./chunk.JLEC3USG.js","./chunk.HDRD33II.js","./chunk.DX357TZ3.js","./chunk.H7KCWCB4.js","./chunk.XSNAG4JT.js","./chunk.XWAMQPUM.js","./chunk.SDO3U72B.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.T7O6K3IN.js")):xe("pages");try{Jt?await xo(decodeURIComponent(Jt[1])):await Fo()}catch(e){let n=document.createElement("pre");n.setAttribute("role","alert"),n.style.cssText="margin:2rem;font:14px/1.5 ui-monospace,monospace;white-space:pre-wrap",n.textContent=e instanceof Error?e.message:String(e),Yt.replaceChildren(n),window.__graviewFailed=n.textContent}async function xo(e){let n=await fetch(`/graview/document?form=${encodeURIComponent(e)}`),o=await n.json();if(!n.ok)throw new Error(o.error??`The preview server did not hand over the form (${n.status}).`);let a=await it(o);if(!a.ok)throw new Error(tt(a.findings));let d=a.app,l=o.principal,b=await ut({app:d,url:location.origin,principal:l,...o.state?{state:o.state,openTimeoutMs:0}:{openTimeoutMs:3e3}});document.title=d.forms?.[e]?.title??d.name;let{mount:p}=await xr;window.__graview=p(Yt,{app:d,form:e,principal:l,remote:b,height:"100dvh",onSubmitted:()=>window.__graviewSubmitted=!0}),window.__graviewReady=!0}async function Fo(){let e=await fetch("/graview/document");if(!e.ok)throw new Error(`The preview server did not hand over the document (${e.status}).`);let n=await e.json(),a=await(async g=>{if(typeof g.module=="string")return(await import(g.module)).app;let P=await it(g);if(!P.ok)throw new Error(tt(P.findings));return P.app})(n);if(!a||typeof a!="object"||!("schema"in a))throw new Error("The app module the preview server handed does not export an app.");let d=n.principal,l=await ut({app:a,url:location.origin,principal:d,live:!0,subprotocol:!0,pollMs:1200,...n.state?{state:n.state,openTimeoutMs:0}:{openTimeoutMs:3e3}});document.title=a.name;let b,p=Kt({url:location.origin,principal:d,...n.views?{state:n.views}:{},onDeclaration:async()=>{let g=await(await fetch("/graview/document")).json();if(typeof g.module=="string")return;let P=await it(g);P.ok&&b?.setApp(P.app,l)}});await Promise.all([xr,p.ready]),b=qt(Yt,{app:a,remote:l,principal:d,studio:!1,face:"pages",routing:"address",bar:!0,height:"100dvh",label:a.name,heading:1,keptViews:p,...n.draftView?{draftView:n.draftView}:{}}),window.__graview=b,b.drawn().then(()=>{window.__graviewReady=!0})}
1
+ var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as Mt,b as Gn,c as Un,d as Kn,e as Jn,f as Vt,g as Yn,h as Dt}from"./chunk.J6ANRF6E.js";import{a as zr}from"./chunk.V4BCB7N2.js";import{a as Ht,b as Zn,c as Xn,d as er,e as Bt,f as tr,g as nr,h as rr,i as or,j as ar,k as ir,l as sr,m as dr,n as _e}from"./chunk.QO7MDWID.js";import{b as Qn}from"./chunk.FOP5RBGF.js";import{a as kt}from"./chunk.Q5WEOX3Q.js";import{a as Et,g as bn}from"./chunk.HG4DDNPG.js";import{k as tt}from"./chunk.KTFUVR4V.js";import{C as _n,H as jn,L as qn,M as zn,j as qr,k as Wn,n as ot,o as Nn,q as $n,u as In,z as at}from"./chunk.2UIUMG23.js";import{Aa as Vn,Ca as Dn,Da as Lt,G as Ct,Ha as Hn,Ia as Bn,La as rt,R as kn,W as En,a as Sn,b as Ft,c as nt,da as An,ea as Rn,j as Pn,m as Ot,sa as Tn,ta as xn,ua as Fn,va as On,wa as Cn,xa as Ln,za as Mn}from"./chunk.KA44WNB4.js";import{a as be}from"./chunk.SDO3U72B.js";import{Ad as xt,Pc as mn,Rc as hn,Sc as yn,Uc as et,Vb as At,Wb as fn,jb as Ie,kb as Xe,od as ve,pd as gn,qd as wn,vd as Rt,wb as un,wd as Tt,zc as pn,zd as vn}from"./chunk.4TJOS4C7.js";import"./chunk.2AZTW66C.js";import{b as Fe}from"./chunk.AJZBJBMO.js";async function it(e,n={}){let o=e.compiled===void 0||!Ur(e.compiled,e.document)?void 0:bn(e.compiled,n);if(o?.ok)return o;let{compileDocumentWithoutCheck:a}=await Gr();return a(e.document,n)}var cr,Gr=()=>cr??=(__graviewPreload(import.meta.url,["./chunk.4GQA3AJU.js","./chunk.HG4DDNPG.js","./chunk.X7JMJSLU.js","./chunk.5Y3Q7ONN.js","./chunk.KTFUVR4V.js","./chunk.4TJOS4C7.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.7QZYFLBS.js")).catch(e=>{throw cr=void 0,e});function Ur(e,n){let o=typeof e=="object"&&e!==null?e.document:void 0,a=n;if(typeof a=="string")try{a=JSON.parse(a)}catch{return!1}return o!==void 0&&kt(Et(o).document)===kt(Et(a).document)}var c=Fe(Ct(),1);var dt=Fe(Ct(),1),Wt="data-graview-drawn",Kr=200,lr=50,Jr=1e4,st=()=>typeof performance<"u"?performance.now():Date.now();function Yr(e){let n=[...e.querySelectorAll("img")];for(let o of e.querySelectorAll("[data-worker-view]"))o.shadowRoot&&n.push(...o.shadowRoot.querySelectorAll("img"));return n}function Qr(e,n){if(e.ownerDocument.fonts?.status==="loading"||xn()>0||Ln(n)>0||e.querySelector('[aria-busy="true"]')||Yr(e).some(a=>!a.complete&&a.loading!=="lazy"))return!1;for(let a of e.querySelectorAll("[data-worker-view-place]"))if(!a.querySelector("[data-worker-view][data-worker-view-drawn], [data-worker-view][data-worker-view-failed]"))return!1;return!0}function ur(e){let n=e.querySelector("[data-embed-content]"),o=[...e.querySelectorAll("[data-worker-view]")].map(a=>`${a.offsetWidth}x${a.offsetHeight}`);return`${e.scrollWidth}x${e.scrollHeight}|${n?`${n.scrollWidth}x${n.scrollHeight}`:""}|${o.join(",")}`}function Zr(e,n,o,a){e.removeAttribute(Wt);let d=e.ownerDocument.defaultView;if(!d)return()=>{};let l=st(),b=l,p=ur(e),g=!1,A,T=typeof MutationObserver>"u"?void 0:new MutationObserver(S=>{S.some(N=>!(N.target===e&&N.attributeName===Wt))&&(b=st())});T?.observe(e,{childList:!0,subtree:!0,characterData:!0,attributes:!0});let v=()=>{g=!0,T?.disconnect(),A!==void 0&&clearTimeout(A)},P=S=>{let N=!1,ne=()=>{N||(N=!0,S())};typeof d.requestAnimationFrame=="function"&&d.requestAnimationFrame(()=>setTimeout(ne,0)),setTimeout(ne,100)},C=()=>{if(g)return;let S=ur(e);S!==p&&(p=S,b=st());let N=st();if(Qr(e,a)&&N-b>=Kr||N-l>=Jr){P(()=>{g||(v(),e.setAttribute(Wt,n),Vn(),o())});return}A=setTimeout(C,lr)};return A=setTimeout(C,lr),v}function fr(e,n,o,a,d){Mn();let l=(0,dt.useRef)({place:o,onDrawn:a});l.current={place:o,onDrawn:a},(0,dt.useLayoutEffect)(()=>{d&&Cn(d);let b=A=>Zr(A,l.current.place.path,()=>l.current.onDrawn?.(l.current.place),d);if(e.current)return b(e.current);let p,g=!1;return queueMicrotask(()=>{!g&&e.current&&(p=b(e.current))}),()=>{g=!0,p?.()}},[n,e,d])}var ye=Fe(Ct(),1),je,Xr=be(()=>(__graviewPreload(import.meta.url,["./chunk.2VTMTW7K.js","./chunk.ETR6AV47.js","./chunk.I5TOMBIF.js","./chunk.QQTRAY5W.js","./chunk.DOBQ4LO4.js","./chunk.KA44WNB4.js","./chunk.SDO3U72B.js","./chunk.4TJOS4C7.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.PCEYZQAW.js"))),pr=()=>Xr().then(e=>void(je=e),()=>new Promise(e=>setTimeout(e,2e3)).then(pr)),Nt=Tn(pr),mr=e=>!!e&&je===void 0;function $t({onReady:e,fetch:n}){return(0,ye.useLayoutEffect)(()=>void n().then(e),[e,n]),null}var eo=0;function hr(e){let[n,o]=(0,ye.useState)(()=>je);(0,ye.useEffect)(()=>{if(!e||n)return;let l=!1;return Nt().then(()=>{l||o(je)}),()=>{l=!0}},[e,n]);let a=(0,ye.useMemo)(()=>eo+=1,[e]);return{over:(0,ye.useMemo)(()=>{let l=n??je;if(!e||!l)return;let{source:b,worker:p,...g}=e,A={...g,worker:p??{source:b},draft:!0};return{name:e.manifest.name,home:e.manifest.attach==="home",register:T=>l.registerWorkerView(T,A)}},[e,n]),n:a}}var wr=Fe(zr(),1),j=Fe(qr(),1);var h=Fe(kn(),1);function ct(e,n={}){let o=Lt(e);return{Face:o.part((d,l)=>(0,c.createElement)(d,l),n),fetch:()=>o.load().then(()=>{}),here:()=>o.current!==void 0||o.failed}}var jt=e=>Promise.all([e,qn()]).then(([n])=>n),vr=be(()=>(__graviewPreload(import.meta.url,["./chunk.EXEZBZGW.js","./chunk.NTLHEHOM.js","./chunk.V2GSBYDK.js","./chunk.NLBIX7LH.js","./chunk.GACKGEUY.js","./chunk.HJCQ6I3S.js","./chunk.KVEDIBXS.js","./chunk.7VT3TRHR.js","./chunk.VQAQQW4Q.js","./chunk.DWPU56S5.js","./chunk.7FRPNQU4.js","./chunk.BDHKWVNX.js","./chunk.ZH4NWRWB.js","./chunk.GUMJEVVP.js","./chunk.SAHNXAV3.js","./chunk.UGJSMNVO.js","./chunk.NR5ODXMO.js","./chunk.E5GM2SMO.js","./chunk.NQZ73QV7.js","./chunk.O45VO36H.js","./chunk.UT6642FC.js","./chunk.QO7MDWID.js","./chunk.FOP5RBGF.js","./chunk.TI4OSTQV.js","./chunk.MAFFUPCR.js","./chunk.GZHZLJBF.js","./chunk.RQBEQYB2.js","./chunk.OJGHDWI6.js","./chunk.6VAFNCR4.js","./chunk.N4M54YK6.js","./chunk.KVJFY7N5.js","./chunk.DPHTUTOS.js","./chunk.2UIUMG23.js","./chunk.KA44WNB4.js","./chunk.SDO3U72B.js","./chunk.4TJOS4C7.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.NWT5FPEK.js"))),to=be(()=>(__graviewPreload(import.meta.url,["./chunk.TMDI7KRS.js","./chunk.I7QIHN66.js","./chunk.2QNGGF55.js","./chunk.PMJUGHW4.js","./chunk.Y4MQGEUS.js","./chunk.UGFDSE37.js","./chunk.EXEZBZGW.js","./chunk.X7N3JUO4.js","./chunk.NTLHEHOM.js","./chunk.GNBN3BK7.js","./chunk.XTMOFRHL.js","./chunk.NLBIX7LH.js","./chunk.GACKGEUY.js","./chunk.PXQVXBNG.js","./chunk.UJRBOUGC.js","./chunk.DWPU56S5.js","./chunk.ZH4NWRWB.js","./chunk.2GLJH253.js","./chunk.GUMJEVVP.js","./chunk.4VW6THJF.js","./chunk.SAHNXAV3.js","./chunk.DHAK6PPX.js","./chunk.YDL5BSTG.js","./chunk.DUWYF7BO.js","./chunk.UGJSMNVO.js","./chunk.NR5ODXMO.js","./chunk.O45VO36H.js","./chunk.UT6642FC.js","./chunk.XOZU4OFA.js","./chunk.SUPWMV2F.js","./chunk.MB7LKKUD.js","./chunk.WVUJXDXZ.js","./chunk.TPG6IY4M.js","./chunk.NFDLCUCC.js","./chunk.X7JMJSLU.js","./chunk.PPRSGM64.js","./chunk.5Y3Q7ONN.js","./chunk.KTFUVR4V.js","./chunk.GZHZLJBF.js","./chunk.RQBEQYB2.js","./chunk.OJGHDWI6.js","./chunk.6VAFNCR4.js","./chunk.N4M54YK6.js","./chunk.KVJFY7N5.js","./chunk.DPHTUTOS.js","./chunk.2UIUMG23.js","./chunk.KA44WNB4.js","./chunk.SDO3U72B.js","./chunk.4TJOS4C7.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.664PBQAQ.js"))),no=be(()=>(__graviewPreload(import.meta.url,["./chunk.TMDI7KRS.js","./chunk.I7QIHN66.js","./chunk.2QNGGF55.js","./chunk.PMJUGHW4.js","./chunk.Y4MQGEUS.js","./chunk.UGFDSE37.js","./chunk.EXEZBZGW.js","./chunk.X7N3JUO4.js","./chunk.NTLHEHOM.js","./chunk.GNBN3BK7.js","./chunk.XTMOFRHL.js","./chunk.NLBIX7LH.js","./chunk.GACKGEUY.js","./chunk.PXQVXBNG.js","./chunk.UJRBOUGC.js","./chunk.DWPU56S5.js","./chunk.ZH4NWRWB.js","./chunk.2GLJH253.js","./chunk.GUMJEVVP.js","./chunk.4VW6THJF.js","./chunk.SAHNXAV3.js","./chunk.DHAK6PPX.js","./chunk.YDL5BSTG.js","./chunk.DUWYF7BO.js","./chunk.UGJSMNVO.js","./chunk.NR5ODXMO.js","./chunk.O45VO36H.js","./chunk.UT6642FC.js","./chunk.XOZU4OFA.js","./chunk.SUPWMV2F.js","./chunk.MB7LKKUD.js","./chunk.WVUJXDXZ.js","./chunk.TPG6IY4M.js","./chunk.NFDLCUCC.js","./chunk.X7JMJSLU.js","./chunk.PPRSGM64.js","./chunk.5Y3Q7ONN.js","./chunk.KTFUVR4V.js","./chunk.GZHZLJBF.js","./chunk.RQBEQYB2.js","./chunk.OJGHDWI6.js","./chunk.6VAFNCR4.js","./chunk.N4M54YK6.js","./chunk.KVJFY7N5.js","./chunk.DPHTUTOS.js","./chunk.2UIUMG23.js","./chunk.KA44WNB4.js","./chunk.SDO3U72B.js","./chunk.4TJOS4C7.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.YUH43J2K.js"))),br=ct(()=>jt(vr().then(e=>e.SceneFace)),{what:"This view"}),Sr=ct(()=>vr().then(e=>e.SceneKeeping),{quiet:!0}),Pr=ct(()=>jt(to().then(e=>e.PagesContent)),{what:"This page"}),kr=ct(()=>jt(no().then(e=>e.PictureFace)),{what:"This picture"}),ro=br.Face,oo=Sr.Face,ao=Pr.Face,io=kr.Face;function Oe(...e){let n=e.length>0?e:["scene","pages","picture"],o=new Set(n.flatMap(Er));return Promise.all([...[...o].map(a=>a.fetch()),$n()]).then(()=>{},()=>{})}var Er=e=>e==="pages"?[Pr]:e==="picture"?[kr]:[br,Sr],Ar=e=>Er(e).every(n=>n.here()),so=150,It=0;function yr(e,n){if(Ar(e))return n();let o=++It,a=()=>{o===It&&(It+=1,n())};Oe(e).then(a),setTimeout(a,so)}var co=768;function lo(e,n){let o=n!==null&&n>=co;(0,c.useEffect)(()=>{if(!o||e==="picture")return;let a=e==="pages"?"scene":"pages";if(Ar(a))return;let d=globalThis,l=()=>void Oe(a),b=()=>{},p=Dn(()=>{if(d.requestIdleCallback&&d.cancelIdleCallback){let g=d.requestIdleCallback(l,{timeout:4e3});b=()=>d.cancelIdleCallback?.(g)}else{let g=setTimeout(l,1500);b=()=>clearTimeout(g)}});return()=>(p(),b())},[e,o])}function uo({asked:e,shown:n,onDrawn:o}){return(0,c.useLayoutEffect)(()=>o(e,n),[e,n,o]),null}function fo({auto:e,scene:n}){return(0,h.jsx)("div",{"data-embed-content":"","aria-busy":"true",style:{flex:e?n?`0 0 ${Bt}px`:"0 0 auto":"1 1 auto",minHeight:0,background:"var(--graview-ground)"}})}var po=Lt(be(()=>(__graviewPreload(import.meta.url,["./chunk.AJZBJBMO.js"]),import("./chunk.5JNXQHN4.js")))).part((e,n)=>(0,h.jsx)(e.StudioPlace,{...n}),{quiet:!0});function Rr(e,n,o,a,d){return Vt(e,Jn(n?nt(n):d??Sn,a),o)}function qt(e){return e&&nt(e).overview?"graview":"scene"}function gr(e,n){if(n.homeView?.()===void 0)return!1;let o=e.pages?.first?.trim();return o===void 0||o===""||o==="/"||o.toLowerCase()==="home"}function Tr(e){let[,n]=(0,c.useState)(!1),o=(0,c.useCallback)(()=>n(!0),[]),a=(0,c.useRef)(!1);return e.at&&!lt?(0,h.jsx)($t,{onReady:o,fetch:zt}):!a.current&&mr(e.draftView)?(0,h.jsx)($t,{onReady:o,fetch:Nt}):(a.current=!0,(0,h.jsx)(mo,{...e}))}function mo(e){let{app:n,stop:o,bar:a=!0,standing:d="Everything is in order",principal:l,heading:b=2}=e,{rootRef:p,scope:g,css:A,scheme:T,store:v,presence:P,brand:C,auto:S,height:N}=tr(e),ne=hr(e.draftView),V=Xn(e,zn,ne.over),[Z]=(0,c.useState)(On),u=e.basePath===void 0?{}:{basePath:e.basePath},[D]=(0,c.useState)(ot),q=e.notices??D,K=m=>Rt(m,u),x={...e.routing?{routing:e.routing}:{},...u},[de]=(0,c.useState)(()=>{let m=e.at?.face;if(m)return m;let F=o===void 0&&gr(n,V)?"pages":qt(o),me=Mt({...x,face:F});return e.face===void 0&&e.onOpening?.(me),me}),[$,O]=(0,c.useState)(()=>e.face!==void 0&&e.face!=="pages"&&!e.at&&o===void 0&&Gn(x)&&gr(n,V)),Pe=(0,c.useRef)(e.onFace);Pe.current=e.onFace,(0,c.useLayoutEffect)(()=>{$&&(Pe.current?.("pages"),O(!1))},[$]);let k=$?"pages":e.face??de,te=n.schema.kinds,R=e.routing==="address",J=(0,c.useMemo)(()=>e.at?lt.settleAt(e,v.seenBy(l??{kind:"human"}),V.places()):void 0,[]),B=(0,c.useMemo)(()=>Rn(V,n.schema),[V,n.schema]),ce=(0,c.useMemo)(()=>{let m=J?.stop??(R?Un(e.basePath):void 0)??o;return k==="scene"&&m===void 0&&B===void 0&&(e.path===void 0||_t(e.path))?Dt(void 0):Rr(k,m,te,V.places(),B)},[]),[we]=(0,c.useState)(k);(0,c.useEffect)(()=>{we!=="pages"&&An(V)},[we,V]);let W=(0,c.useRef)(void 0),z=m=>m===void 0||_t(m)?"/":m;W.current??={path:z(J?.path??(R?k==="pages"?(Tt(window.location.pathname,e.basePath)??"/")+window.location.search:"/":e.path)),asked:e.path},e.path!==W.current.asked&&(W.current={path:z(e.path),asked:e.path});let I=(0,c.useRef)(e.onNavigate);I.current=e.onNavigate;let le=(0,c.useCallback)((m,F)=>{W.current.path=m,I.current?.(m,F)},[]),{at:L,setAt:ke,steering:Y,steer:X}=ir(W.current.path),M=(0,c.useContext)(xr);M&&(M.pages=()=>W.current.path);let Ee=(0,c.useRef)(void 0),ue=(0,c.useCallback)(m=>void(W.current.path=m),[]),re=Wn(p),[Q,ze]=(0,c.useState)(!1),Ae=e.pagesBelow!==void 0&&re!==null&&re<e.pagesBelow&&(k==="scene"||k==="graview")&&!Q,E=Ae?"pages":k,Re=(0,c.useRef)(!1);Re.current=Q&&e.pagesBelow!==void 0&&re!==null&&re<e.pagesBelow&&(k==="scene"||k==="graview"),M&&(M.shown=E);let fe=(0,c.useRef)(k==="graview"?"graview":"scene");(E==="scene"||E==="graview")&&(fe.current=E),(0,c.useState)(()=>{if(!R||typeof window>"u"||E==="pages"||E==="picture")return;let{pathname:m,search:F,hash:me}=window.location;Tt(m,e.basePath)==="/"&&window.history.replaceState(window.history.state,"",`${K(ve)}${F}${me}`)}),er(p,E,e.onIntrinsicHeight),lo(E,re);let oe=sr(e.onError,E),He=dr(e.onReady,E),Te=(0,c.useRef)(e.onFaceDrawn);Te.current=e.onFaceDrawn;let pt=(0,c.useCallback)((m,F)=>{He(F),Te.current?.(m)},[He]),[mt,ht]=(0,c.useState)(null),G=V.places(),ee=(0,c.useRef)({shown:E,onFace:e.onFace});ee.current={shown:E,onFace:e.onFace};let U=(0,c.useCallback)((m,F,me)=>{if(R){Ee.current?.(m,F,me);return}ee.current.onFace?.(m),I.current?.(m==="pages"?F??W.current.path:ve,"push")},[R]),[Be,pe]=(0,c.useState)(void 0);(0,c.useEffect)(()=>{E==="pages"&&pe(void 0)},[E]);let Ge=(0,c.useRef)(o);(0,c.useEffect)(()=>{Ge.current!==o&&(Ge.current=o,pe(void 0))},[o]);let We=(0,c.useCallback)(m=>{if(ee.current.shown==="pages"){if(ze(!0),pe(m),k==="scene"||k==="graview"){yr(k,()=>{R?window.history.pushState(null,"",`${K(ve)}${m??""}`):I.current?.(ve,"push")});return}yr(fe.current,()=>U(fe.current,void 0,m))}},[R,k,e.basePath,U]),ae=(0,c.useCallback)(m=>{if(ee.current.shown==="pages"){Y.go.current||(W.current.path=m),X(m);return}if(W.current.path=m,ke(m),Re.current){ze(!1),R?window.history.pushState(null,"",K(m)):I.current?.(m,"push");return}U("pages",m)},[Y,X,ke,U,R,e.basePath]),Le=V.arrangement?.(),xe=E==="pages",_=e.hrefOf,ie=_??(R?K:void 0),Ue=(0,c.useMemo)(()=>({open:ae,..._?{href:_}:R?{href:m=>Rt(m,e.basePath===void 0?{}:{basePath:e.basePath})}:{}}),[ae,R,e.basePath,_]);return(0,h.jsxs)("section",{ref:p,className:g,"aria-label":e.label??n.name,"data-graview-embed":E,"data-graview-scheme":T,...Ae?{"data-graview-embed-narrow":""}:{},style:{position:"relative",isolation:"isolate",height:N,minHeight:S?0:320,display:"flex",flexDirection:"column",overflow:"hidden",borderRadius:"var(--graview-radius, 12px)"},children:[(0,h.jsx)("style",{children:A}),(0,h.jsxs)(Bn.Provider,{value:oe,children:[(0,h.jsx)(nr,{rootRef:p,board:q}),(0,h.jsx)(Zn,{rootRef:p,firstLook:e.firstLook,app:_n(C??{name:n.name},n.schema)}),(0,h.jsx)(_e,{module:"@graview/react",report:oe,content:!0,children:(0,h.jsx)(Fn.Provider,{value:Z,children:(0,h.jsx)(En,{store:v,views:V,initialView:ce,scheme:T,...rr(e,P,C),...e.onSeat?{onSeat:e.onSeat}:{},children:(0,h.jsxs)(Nn.Provider,{value:q,children:[(0,h.jsx)(wo,{face:E,stop:Be??o,kinds:te,places:G,opens:B}),M?(0,h.jsx)(ho,{into:M}):null,(0,h.jsx)(yo,{rootRef:p,face:k,shown:E,path:L,stop:o,draft:ne.n,onDrawn:e.onDrawn,parts:Z}),R?(0,h.jsx)(Kn,{pagesWere:J?.path,basePath:e.basePath,shown:E,onFace:e.onFace,toggle:Ee,kinds:te,places:G,opens:B,landed:ue}):null,a&&E!=="picture"?(0,h.jsx)(_e,{module:"@graview/embed",report:oe,children:(0,h.jsx)(or,{name:C?.name??n.name,heading:b,named:Ht(a).name!==!1,faces:Ht(a).faces===!1?void 0:{scene:{label:gn(Le),current:!xe,go:()=>We(),reach:()=>void Oe(fe.current)},pages:{label:wn(Le),current:xe,go:()=>ae(W.current.path),reach:()=>void Oe("pages")}},at:xe?L:null,without:e.pages?.without(),home:{...ie?.("/")!==void 0?{href:ie("/")}:{},go:()=>ae("/"),current:xe&&L.split("?")[0]==="/"},reach:{...ie?{href:ie}:{},go:m=>ae(m.path)},standing:d,hostActions:e.hostActions,keeping:xe?void 0:(0,h.jsx)(vo,{app:n,studio:e.studio,report:oe}),onFind:ht,switch:e.switch})}):null,(0,h.jsx)(In.Provider,{value:mt,children:(0,h.jsx)(_e,{module:E==="pages"||E==="picture"?"@graview/pages":"@graview/react",report:oe,content:!0,children:(0,h.jsxs)(c.Suspense,{fallback:(0,h.jsx)(fo,{auto:S,scene:E!=="pages"&&E!=="picture"}),children:[E==="picture"?(0,h.jsx)(io,{scope:g,store:v,views:V,as:(o?nt(o).within?.view:void 0)??""}):E==="pages"?(0,h.jsx)(ao,{store:v,views:V,presence:P,auto:S,brand:C,steering:Y,overview:We,scope:g,titleLevel:ar(b),quickAsk:at(e.quickAsk),props:{...e,onNavigate:le,...R?{}:{path:W.current.path}}}):(0,h.jsx)(Hn.Provider,{value:Ue,children:(0,h.jsx)(ro,{address:R,auto:S,scheme:T,scope:g,quickAsk:at(e.quickAsk)})}),(0,h.jsx)(uo,{asked:k,shown:E,onDrawn:pt})]})},E)})]})})})})]})]})}var _t=e=>e.split(/[?#]/)[0]===ve,xr=(0,c.createContext)(null);function ho({into:e}){return e.view=rt().view,null}function yo({rootRef:e,face:n,shown:o,path:a,stop:d,draft:l,onDrawn:b,parts:p}){let{view:g}=rt(),A=o==="scene"||o==="graview",T=Ft(g),v={face:n,path:A?ve:o==="picture"?d??"#":a,stop:T};return fr(e,`${o} ${A?T:v.path} ${l}`,v,b,p),null}var lt,go=be(()=>(__graviewPreload(import.meta.url,["./chunk.J6ANRF6E.js","./chunk.2UIUMG23.js","./chunk.KA44WNB4.js","./chunk.SDO3U72B.js","./chunk.4TJOS4C7.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.YVOABA2U.js"))),zt=()=>go().then(e=>void(lt=e),()=>new Promise(e=>{let n=()=>{window.removeEventListener("online",n),clearTimeout(o),e()},o=setTimeout(n,1e4);window.addEventListener("online",n)}).then(zt));function wo({face:e,stop:n,kinds:o,places:a,opens:d}){let{view:l,go:b}=rt(),p=(0,c.useRef)({face:e,stop:n});return(0,c.useLayoutEffect)(()=>{let g=p.current.stop!==n,A=p.current.face!==e,T=p.current.face==="pages";if(p.current={face:e,stop:n},!g&&!A||e==="pages"||e==="picture")return;let v=(g||T)&&n!==void 0?Rr(e,n,o,a):T&&Yn(l)?Vt(e,Dt(d),o):e==="graview"?Ot(l,!0):l.overview?Pn(Ot(l,!1),jn(l,o)):l;b(v)},[e,n,o,l,b,d]),null}function vo({app:e,studio:n,report:o}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(c.Suspense,{fallback:null,children:(0,h.jsx)(oo,{})}),n!==!1?(0,h.jsx)(_e,{module:"@graview/studio",report:o,children:(0,h.jsx)(bo,{app:e,studio:n})}):null]})}function bo({app:e,studio:n}){let o={app:e,within:"box",...n?{onApply:n.onApply}:{},...n?.landmark?{landmark:n.landmark}:{},...n?.offered!==void 0?{offered:n.offered}:{}},a=n?.place;return a?(0,h.jsx)(a,{...o}):(0,h.jsx)(c.Suspense,{fallback:null,children:(0,h.jsx)(po,{...o})})}function So({path:e,stop:n,...o},a){return{...o,app:a.app,at:a.at,...a.remote.presence?{presence:a.remote.presence}:{}}}function Gt(e,n){let o=n.store??n.remote?.store??Qn(n.app,n.seed),a=n.notices??ot(),d=null,l={},b=0,p=n.label,g=n.app,A=Promise.resolve(),T=n.at?.face??n.face,v=T===void 0?void 0:Mt({...n,face:T}),P=v??qt(n.stop),C=null,S=[],N=u=>{if(C=u,u!==P)return;let D=S;S=[];for(let q of D)q()};function ne(){let[u,D]=(0,c.useState)(v),[q,K]=(0,c.useState)(n.stop),[x,de]=(0,c.useState)(n.path),[$,O]=(0,c.useState)(n.scheme??"auto"),[Pe,k]=(0,c.useState)(n.principal),[te,R]=(0,c.useState)(n.seats),[J,B]=(0,c.useState)(n.quickAsk),[ce,we]=(0,c.useState)(n.people),[W,z]=(0,c.useState)(n.hostContext),[I,le]=(0,c.useState)(n.brand),[L,ke]=(0,c.useState)(n.label),[Y,X]=(0,c.useState)(n.hostActions),[M,Ee]=(0,c.useState)(void 0),[ue,re]=(0,c.useState)(n.draftView);return d={app:Q=>{Ee(Q),de(void 0),K(void 0)},face:D,stop:K,path:de,scheme:O,seat:k,seats:R,quickAsk:B,people:we,hostContext:z,brand:le,label:ke,hostActions:X,draft:re},(0,h.jsx)(xr.Provider,{value:l,children:(0,h.jsx)(Tr,{...M?So(n,M):n,store:o,notices:a,...u!==void 0?{face:u}:{},onOpening:Q=>{P=Q},...q!==void 0?{stop:q}:{},...x!==void 0?{path:x}:{},...Pe?{principal:Pe}:{},...te?{seats:te}:{},...J!==void 0?{quickAsk:J}:{},...ce?{people:ce}:{},...W?{hostContext:W}:{},...I?{brand:I}:{},label:L,hostActions:Y,draftView:ue,scheme:$,onFace:Q=>{P=Q,D(Q)},onSeat:k,onFaceDrawn:N},M?.n??0)})}let V=()=>{let u=l.view?.focusId,D=u?o.graph.getNode(u)?.kind:void 0,q=(l.shown??P)==="scene"||(l.shown??P)==="graview";return{face:P,path:q?ve:l.pages?.()??n.path??"/",stop:l.view?Ft(l.view):n.stop??"#",...D?{kind:D}:{}}},Z=(0,wr.createRoot)(e);return(0,j.flushSync)(()=>Z.render((0,h.jsx)(ne,{}))),{get store(){return o},where:V,setApp:(u,D,q)=>{let K="graph"in D?{store:D}:D,x=()=>{let de=V();o=K.store,p=q?.label??(p===g.name?u.name:p),g=u,(0,j.flushSync)(()=>{d?.label(p),d?.app({app:u,remote:K,at:de,n:++b})})};lt?x():A=A.then(zt).then(x)},setFace:u=>{P=u,(0,j.flushSync)(()=>d?.face(u))},setStop:u=>(0,j.flushSync)(()=>d?.stop(u)),setPath:u=>(0,j.flushSync)(()=>{if(_t(u)){(P==="pages"||P==="picture")&&(P="scene",d?.face("scene"));return}d?.path(u),P!=="pages"&&(P="pages",d?.face("pages"))}),setScheme:u=>(0,j.flushSync)(()=>d?.scheme(u)),setSeat:u=>(0,j.flushSync)(()=>d?.seat(u)),setSeats:u=>(0,j.flushSync)(()=>d?.seats(u)),setQuickAsk:u=>(0,j.flushSync)(()=>d?.quickAsk(u)),setPeople:u=>(0,j.flushSync)(()=>d?.people(u)),setHostContext:u=>(0,j.flushSync)(()=>d?.hostContext(u)),setBrand:u=>(0,j.flushSync)(()=>d?.brand(u)),setDraftView:u=>(0,j.flushSync)(()=>d?.draft(u)),setLabel:u=>{p=u,(0,j.flushSync)(()=>d?.label(u))},setHostActions:u=>(0,j.flushSync)(()=>d?.hostActions(u)),drawn:()=>A.then(()=>C===P?void 0:new Promise(u=>S.push(u))),notify:u=>{let D;return(0,j.flushSync)(()=>{D=a.notify(u)}),D},unmount:()=>Z.unmount()}}var Fr="/graview/live",Ut="graview.ship",Kt=`${Ut}.${Xe}`;var ge={seat:"x-graview-seat",roles:"x-graview-roles",kind:"x-graview-kind",name:"x-graview-name",for:"x-graview-for",forRoles:"x-graview-for-roles",forName:"x-graview-for-name",via:"x-graview-via"};var Ve=class extends Error{constructor(n){super(n),this.name="Superseded"}},Se=e=>e?.lineage?{lineage:e.lineage}:{},Po=(e,n)=>`${e.calls.map(o=>o.name.replace(/-/g," ")).join(", ")} (${n instanceof Error?n.message.split(`
2
+ `)[0]??"":String(n)})`;function ko(e){if(!e)return[];try{let n=e.storage.getItem(e.key);if(n===null)return[];e.storage.removeItem(e.key);let o=JSON.parse(n);return Array.isArray(o)?o.filter(a=>!!a&&Array.isArray(a.calls)):[]}catch{return[]}}var De=class extends Error{constructor(o){super(o.sentence);this.refusal=o;this.name="RemoteRefusedError"}},Eo={401:"forbidden",403:"forbidden",404:"missing",413:"limit"},Ce=class extends Error{constructor(o,a){super(o);this.conflicts=a;this.name="StaleWrite"}},qe=class extends Error{constructor(n){super(n),this.name="Unreached"}},Ao=new Set([502,503,504]);async function Ro(e){try{return(await e.clone().json()).reason==="unavailable"}catch{return!1}}function To(){let e=Math.random().toString(36).slice(2,8),n=0;return()=>`local-${e}-${++n}`}var xo=1,Fo=()=>({refusals:new Set,conflicts:new Set,statuses:new Set,helds:new Set,builds:new Set,who:new Set,declarations:new Set,tally:{reconnects:0,rebases:0,conflicts:0,resyncs:0}});async function ut(e){return(await Cr(e,ko(e.carry),"This app was updated while your changes were on the way.",Fo())).remote}async function Cr(e,n,o,a){let d=e.fetch??fetch,l={"content-type":"application/json",...e.headers??{}},b={...ft(e.principal),[ge.via]:e.via??"web"};Object.assign(l,b);let p=e.live===!0,g=e.presenceEveryMs,A=e.visible??Lo,T="connecting",v=a.statuses,P=a.tally,C=[],S,N=[],ne=()=>T==="online"&&S!==void 0?"held":T,V=()=>{let t=ne();if(a.told!==t){a.told=t;for(let r of[...v])r(t)}},Z=t=>{if(!(t===T||se)&&(T==="offline"&&t==="online"&&P.reconnects++,T=t,V(),t==="online"))for(let r of C.splice(0))r.again()},u=t=>{if(se)return;let r=typeof t=="string"&&t.length>0?t:void 0,s=r!==S;if(S=r,D(),!!s&&(V(),r===void 0)){for(let i of N.splice(0))i();F&&clearTimeout(F),me()}},D=()=>{if(a.toldHeld!==S){a.toldHeld=S;for(let t of[...a.helds])t(S??null)}},q=async(t,r)=>{let s;try{s=await d(t,r)}catch(i){throw _()||Z("offline"),new qe(i instanceof Error?i.message:String(i))}if(s.status===503&&await Ro(s))return Z("online"),s;if(Ao.has(s.status))throw _()||Z("offline"),new qe(`The server is away (${s.status})`);return Z("online"),s},K=async(t=!1)=>{let r=`${e.url}/graview/state?opFormat=${Ie.op}`,s=t?await d(r,{headers:l}):await q(r,{headers:l});if(!s.ok)throw new Error((await s.json().catch(()=>({}))).error??`The server refused (${s.status})`);return await s.json()},x=e.state??await K(!0);p||(T="online"),S=typeof x.held=="string"&&x.held.length>0?x.held:void 0,D();let de=x.enabledModules??e.enabledModules,$=e.localApp?e.localApp(e.app):e.app,O=new yn({schema:$.schema,mutations:$.mutations??[],invariants:$.invariants??[],...$.policy?{policy:$.policy}:{},...$.modules?{modules:$.modules}:{},...de?{enabledModules:de}:{},...$.intelligence?{intelligence:$.intelligence}:{},...$.brand?.timeZone?{timeZone:$.brand.timeZone}:{},snapshot:x.snapshot,log:x.log,...x.horizon!==void 0?{horizon:x.horizon}:{},ids:To(),...e.storeOptions??{}});pn.served.add(O);let Pe=mn(O),k=x.log.at(-1)?.seq??(x.horizon??0)-1,te=At.of(x.log,{horizon:x.horizon??0}),R=null,J,B=new Map,ce=a.who,we=!1,W=t=>{if(se)return;we=!0;let r=vn(new Map,t,Date.now(),1e4,R?.participant);J!==void 0&&r.delete(J);let s=r.size!==B.size;if(!s)for(let[i,f]of r)xt(f,B.get(i))||(s=!0);if(B=r,!!s)for(let i of[...ce])i([...B.values()])},z=[],I=new Set,le=t=>{let r=z.indexOf(t);r>=0&&z.splice(r,1)},L=new Map,ke=(t,r)=>{let s=L.get(t);s&&(L.delete(t),s.resolve({ops:r.filter(i=>i.batch===t),batch:t}))},Y,X=[],M=(t,r=[])=>{if(t.length===0&&r.length===0)return[];if(Y)return X.push({ops:t,drop:r}),[];let s=Math.min(...t.filter(w=>w.seq>k).map(w=>w.seq));if(Number.isFinite(s)&&s>k+1)return X.push({ops:t,drop:r}),Ee(),[];let i=z.filter(w=>t.some($e=>$e.batch===w)),f=[...new Set([...r,...i])].filter(w=>I.has(w)),y,H=z.filter(w=>!i.includes(w));try{y=O.rebase({confirmed:t,pending:H,drop:f}).confirmed}catch(w){if(!(w instanceof hn))throw w;return X.push({ops:t,drop:r}),Ee(),[]}for(let w of i)le(w);t.some(w=>w.seq>k)&&H.some(w=>!f.includes(w))&&P.rebases++,t.length>0&&(k=Math.max(k,...t.map(w=>w.seq)),te.note(t));for(let w of f)I.delete(w);for(let w of i)ke(w,t);return y},Ee=()=>{Y||(Y=oe(K().then(t=>{if(ue(t)){X=[];return}let r=new Set(t.log.map(f=>f.batch)),s=z.filter(f=>r.has(f));for(let f of s)le(f);let i=O.adopt({snapshot:t.snapshot,log:t.log,...t.horizon!==void 0?{horizon:t.horizon}:{},pending:[...z],drop:[...I].filter(f=>!z.includes(f))});I.clear();for(let f of i.pending)I.add(f.batch);k=t.log.at(-1)?.seq??(t.horizon??0)-1,te=At.of(t.log,{horizon:t.horizon??0}),P.resyncs++;for(let f of s)ke(f,t.log)}).then(()=>{Y=void 0;let t=X;X=[];for(let{ops:r,drop:s}of t)M(r,s)},()=>{Y=void 0,X=[]})))},ue=t=>(typeof t.build=="string"&&en(t.build),typeof t.version=="number"&&u(t.held),typeof t.version!="number"||t.version===x.version?!1:(vt(t.version),!0)),re=async t=>{let s=await(await q(`${e.url}/graview/since?seq=${t}&opFormat=${Ie.op}`,{headers:l})).json();return ue(s)?[]:s.ops??[]},Q=async()=>{let t=await ze();return Y&&await Y,t},ze=async()=>{if(R&&!_()&&A()){let r=await(await q(`${e.url}/graview/here`,{method:"POST",headers:l,body:JSON.stringify({presence:R,seq:k})})).json();return ue(r)?[]:(typeof r.participant=="string"&&(J=r.participant),W(r.who??[]),M(r.ops??[]))}return M(await re(k))},Ae=new Map,E=new Map,Re=new Map,fe=new Set,oe=t=>(fe.add(t),t.finally(()=>fe.delete(t)).catch(()=>{}),t),He=Promise.resolve(),Te=0,pt=(t,r)=>{let s=He.then(()=>ht(t,r));return He=s.catch(()=>{}),s},mt=()=>new Promise((t,r)=>C.push({again:t,give:r})),ht=async(t,r)=>{let s,i;for(;;){try{s=await q(`${e.url}/graview/ops`,{method:"POST",headers:l,body:JSON.stringify({...t,opFormat:Ie.op})})}catch(w){if(!(w instanceof qe)||U)throw w;if(await mt(),_())return Ke(t,r);continue}if(i=await s.json().catch(()=>({})),s.status===503&&i.reason==="unavailable"&&typeof i.held=="string"&&!U){if(typeof i.version=="number"?ue(i):(u(i.held),!1))break;if(S!==void 0&&(Pt>0||p)){if(await new Promise(w=>N.push(w)),U)throw new Ve("The client closed.");if(_())return Ke(t,r);continue}}let H;if(s.status===503&&i.reason==="unavailable"&&!U)H=Jt(e.backoff,Te++);else{if(Te=0,s.status!==429||U)break;H=Oo(s.headers.get("retry-after"),i.retryAfter)}if(await new Promise(w=>setTimeout(w,H)),_())return Ke(t,r)}if(se||ue(i))throw new Ve("The app was changed.");if(!s.ok){let H=i.error??`The server refused (${s.status})`;throw i.conflict?new Ce(H,i.conflicts??[]):new De({reason:i.reason??Eo[s.status]??"invalid",sentence:H,...i.wouldNeed?.length?{wouldNeed:i.wouldNeed}:{}})}let f=i.ops??[],y=f[0]?.seq;return y!==void 0&&y>k+1&&(f=await re(k)),r!==void 0&&(i.batch&&Ae.set(r,i.batch),le(r)),M(f,r!==void 0?[r]:[]),{ops:i.ops??[],...i.batch?{batch:i.batch}:{}}},G,ee=!1,U=!1,Be=0,pe,Ge=0,We=0,ae=null,Le=()=>{},xe=new Promise(t=>{Le=t}),_=()=>p&&ee&&G?.readyState===xo,ie=t=>{if(!_())return!1;try{return G.send(JSON.stringify(t)),!0}catch{return!1}},Ue=(t=!1)=>{!R||!_()||!A()||!t&&ae&&xt(R,ae)&&(g===void 0||Date.now()-We<g)||ie({t:"here",presence:R})&&(ae=R,We=Date.now())},m=new Set,F,me=()=>{if(F=void 0,S!==void 0)return;let t=[...L.entries()].filter(([r])=>m.has(r));m.clear();for(let[,r]of t)ie(r.message)},Xt=(t,r)=>{L.has(t)&&(m.add(t),F&&clearTimeout(F),F=setTimeout(me,Math.max(0,r)))},Vr=t=>{L.has(t)&&m.add(t)},Ke=(t,r)=>new Promise((s,i)=>{let f=r??`send-${++Ge}`,y=t.undo?{t:"undo",cid:f,batches:t.undo,...t.intent?{intent:t.intent}:{},...t.batch?{batch:t.batch}:{},...t.via?{via:t.via}:{},...Se(t)}:{t:"call",cid:f,calls:t.calls??[],...t.intent?{intent:t.intent}:{},...t.batch?{batch:t.batch}:{},...t.base?.length?{base:t.base}:{},...t.via?{via:t.via}:{},...Se(t)};if(L.set(f,{message:y,...r!==void 0?{mine:r}:{},resolve:s,reject:i}),m.size>0||S!==void 0){m.add(f);return}ie(y)}),yt=(t,r)=>_()?Ke(t,r):pt(t,r),Dr=t=>{switch(t.t){case"welcome":{if(en(t.build),typeof t.version=="number"&&t.version!==x.version){vt(t.version);return}if(ee=!0,Be=0,typeof t.participant=="string"&&(J=t.participant),u(t.held),M(t.ops??[]),m.clear(),F&&clearTimeout(F),F=void 0,S!==void 0)for(let r of L.keys())m.add(r);else for(let r of L.values())ie(r.message);Ue(!0),Z("online"),Le();return}case"ops":M(t.ops??[]);return;case"ack":{let r=L.get(t.cid);if(!r){M(t.ops??[]);return}L.delete(t.cid),Te=0,r.mine!==void 0&&(Ae.set(r.mine,t.batch),le(r.mine)),M(t.ops??[],r.mine!==void 0?[r.mine]:[]),r.resolve({ops:t.ops??[],batch:t.batch});return}case"refused":case"conflict":{let r=L.get(t.cid);if(!r)return;if(t.t==="refused"&&t.reason==="unavailable"){S!==void 0?Vr(t.cid):Xt(t.cid,Jt(e.backoff,Te++));return}L.delete(t.cid),r.reject(t.t==="conflict"?new Ce(t.sentence,t.conflicts??[]):new De({reason:t.reason??"invalid",sentence:t.sentence,...t.wouldNeed?.length?{wouldNeed:[...t.wouldNeed]}:{}}));return}case"busy":typeof t.cid=="string"&&Xt(t.cid,typeof t.retryAfter=="number"?t.retryAfter:1e3);return;case"presence":W(t.who??[]);return;case"held":u(t.sentence);return;case"declaration":typeof t.version=="number"&&t.version!==x.version&&vt(t.version);return;case"reload":on(typeof t.reason=="string"?t.reason:"This app was updated.");return;case"error":if(t.reopen===!0&&G){let r=G;sn(r);try{r.close(1e3,"Opening again.")}catch{}}return;default:return}},se=!1,gt=a.declarations,wt=a.builds,en=t=>{if(!(se||a.otherBuild!==void 0||!e.build||typeof t!="string"||t.length===0||t===e.build)){a.otherBuild=t;for(let r of[...wt])r(t)}},tn=()=>{let t=[],r=0;for(let s of z){let i=Re.get(s);i?t.push({calls:i.calls,...i.intent?{intent:i.intent}:{},...i.via?{via:i.via}:{},...Se(i),batch:s}):r++}return{carried:t,undos:r}},nn=(t,r)=>`${r} while ${t===1?"an undo of yours was":"undos of yours were"} on the way; ${t===1?"it was":"they were"} not made.`,rn=t=>{se=!0,R=null;let r=new Ve(t);for(let i of L.values())i.reject(r);L.clear(),Qe&&clearInterval(Qe),U=!0,pe&&clearTimeout(pe),F&&clearTimeout(F),he&&clearTimeout(he);for(let i of C.splice(0))i.give(r);for(let i of N.splice(0))i();let s=G;G=void 0,ee=!1;try{s?.close(1e3,t)}catch{}Le()};async function vt(t){if(se)return;if(!e.resolveApp){on(`This app was changed on its server (version ${t}); reload the page to carry on.`);return}let{carried:r,undos:s}=tn(),i=e.resolveApp,f=R;rn("The app was changed.");try{let y=await i(t),{state:H,...w}=e,$e=await Cr({...w,app:y},r,"The app was changed while your changes were on the way.",a);f&&$e.remote.presence.here(f);for(let Ze of[...gt])Ze($e.remote,t);let _r=[...s>0?[Je(nn(s,"The app was changed"))]:[],...$e.unheard()];for(let Ze of _r)for(let jr of Me)jr(Ze.sentence,Ze)}catch(y){let H=`The app was changed, but the new version could not be opened: ${y instanceof Error?y.message:String(y)}`;for(let w of Me)w(H,Je(H))}}function on(t){if(se)return;let{carried:r,undos:s}=tn();rn(t);let i=!1;if(e.carry&&r.length>0)try{e.carry.storage.setItem(e.carry.key,JSON.stringify(r)),i=!0}catch{}let f=[];!i&&r.length>0&&f.push(`${t} ${r.length===1?"A change of yours was":`${r.length} changes of yours were`} not sent; make ${r.length===1?"it":"them"} again after the page reloads.`),s>0&&f.push(nn(s,"This app was updated"));for(let y of f)for(let H of Me)H(y,Je(y));(e.reloadPage??Co)()}let an=()=>{if(U||!p)return;let t=`${e.url.replace(/^http/,"ws").replace(/\/$/,"")}${Fr}`,{"content-type":r,...s}=l,i;try{i=e.socket?e.socket(t,s,[Kt]):Ir(t,s)}catch{return dn()}G=i,ee=!1,i.onopen=()=>{G===i&&i.send(JSON.stringify({t:"hello",seq:k,protocol:Xe,wire:Ut,opFormat:Ie.op,...e.build?{build:e.build.slice(0,64)}:{},...e.hostProtocol!==void 0?{hostProtocol:e.hostProtocol}:{}}))},i.onmessage=f=>{if(G!==i)return;let y;try{y=JSON.parse(String(f.data))}catch{return}Dr(y)},i.onclose=()=>sn(i),i.onerror=()=>{}},he,Hr=()=>{we=!1,he&&clearTimeout(he),he=setTimeout(()=>{if(he=void 0,we||U)return;let t=new Map([...B].filter(([,r])=>r.held!=="socket"));if(t.size!==B.size){B=t;for(let r of ce)r([...B.values()])}},1e4),he.unref?.()};function sn(t){if(G!==t)return;let r=ee;G=void 0,ee=!1,ae=null,r&&(Z("offline"),Hr()),dn()}let dn=()=>{if(U)return;let t=Jt(e.backoff,Be);Be++,pe=setTimeout(an,t)},Br=O.applyAll.bind(O),Wr=O.undo.bind(O),Nr=O.previewAll.bind(O);O.previewAll=(t,r)=>Nr(t,{...e.principal?{author:e.principal}:{},...r});let Me=a.refusals,Ne=[],Je=t=>({reason:"invalid",sentence:t}),Ye=a.conflicts,bt=!1,cn=async(t,r)=>{if(r instanceof Ve||se)return;let s=r instanceof De?r.refusal:un(r),i=s.sentence;le(t);try{M([],[t])}catch{}let f=Re.get(t);if(Re.delete(t),r instanceof Ce&&P.conflicts++,r instanceof Ce&&!_()&&await Q().catch(()=>[]),r instanceof Ce&&Ye.size>0){let y=!1,H={sentence:i,conflicts:r.conflicts,keepTheirs(){y=!0},useMine(){if(!(y||!f)){y=!0,bt=!0;try{O.applyAll(f.calls,{...f.intent?{intent:f.intent}:{},...f.via?{via:f.via}:{},...Se(f)})}finally{bt=!1}}}};for(let w of Ye)w(H);return}for(let y of Me)y(i,s)};O.applyAll=(t,r)=>{let s=fn(O.log.all().filter(y=>I.has(y.batch))),i=Br(t,{...e.principal?{author:e.principal}:{},...r});z.push(i.batch),I.add(i.batch),Re.set(i.batch,{calls:t,...r?.intent?{intent:r.intent}:{},...r?.via?{via:r.via}:{},...Se(r)});let f=bt?[]:te.baseFor(i.ops,s);return E.set(i.batch,oe(yt({calls:t,...r?.intent?{intent:r.intent}:{},batch:i.batch,...f.length>0?{base:f}:{},...r?.via?{via:r.via}:{},...Se(r)},i.batch).catch(y=>cn(i.batch,y)))),i},O.apply=(t,r)=>O.applyAll([t],r),O.undo=(t,r)=>{let s=typeof t=="string"?[t]:t,i=Wr(s.map(y=>Ae.get(y)??y),{...e.principal?{author:e.principal}:{},...r});z.push(i.batch),I.add(i.batch);let f=Promise.allSettled(s.map(y=>E.get(y)));return E.set(i.batch,oe(f.then(()=>yt({undo:s.map(y=>Ae.get(y)??y),...r?.intent?{intent:r.intent}:{},batch:i.batch,...r?.via?{via:r.via}:{},...Se(r)},i.batch)).catch(y=>cn(i.batch,y)))),i};let $r=async(t,r={})=>{St++;try{return(await oe(yt({calls:t,...r}))).ops}finally{St--}},St=0,ln={here(t){R=t,Ue()},onWho(t){return ce.add(t),B.size>0&&t([...B.values()]),()=>{ce.delete(t)}},leave(){if(!R)return;let t=JSON.stringify({participant:J??R.participant});if(R=null,ie({t:"bye"}))return;let r=globalThis.navigator?.sendBeacon;r?r.call(globalThis.navigator,`${e.url}/graview/leave`,t):d(`${e.url}/graview/leave`,{method:"POST",headers:l,body:t}).catch(()=>{})}},Pt=e.pollMs??800,Qe=Pt>0&&typeof setInterval=="function"?setInterval(()=>{_()||Q().catch(()=>{})},Pt):null;if(p){an();let t;await Promise.race([xe,new Promise(r=>t=setTimeout(r,e.openTimeoutMs??3e3))]),clearTimeout(t)}if(n.length>0&&!se){let t=[],r=new Set(O.log.all().map(s=>s.batch));for(let s of n)if(!(s.batch!==void 0&&r.has(s.batch)))try{O.applyAll(s.calls,{...s.intent?{intent:s.intent}:{},...s.batch?{batch:s.batch}:{},...s.via?{via:s.via}:{},...Se(s)})}catch(i){t.push(Po(s,i))}t.length>0&&Ne.push(Je(`${o} ${t.length===1?"One no longer fits and was not made":`${t.length} no longer fit and were not made`}: ${t.join("; ")}.`))}return{remote:{store:O,version:x.version,migrated:x.migrated??[],send:$r,pull:Q,onRefusal(t){Me.add(t);let r=Ne;Ne=[];for(let s of r)t(s.sentence,s);return()=>Me.delete(t)},onDeclaration(t){return gt.add(t),()=>gt.delete(t)},onBuild(t){return wt.add(t),a.otherBuild!==void 0&&t(a.otherBuild),()=>wt.delete(t)},onConflict(t){return Ye.add(t),()=>Ye.delete(t)},revision:(t,r)=>te.of(t,r),seq:()=>k,participant:()=>J,transport:()=>_()?"socket":"poll",status:ne,onStatus(t){return v.add(t),()=>v.delete(t)},held:()=>S,onHeld(t){return a.helds.add(t),S!==void 0&&t(S),()=>a.helds.delete(t)},counters:()=>({...P}),who:()=>[...B.values()],pending:()=>z.length+St,async settled(){for(;fe.size>0;)await Promise.allSettled([...fe])},presence:ln,close(){Qe&&clearInterval(Qe),Pe(),ln.leave(),U=!0,pe&&clearTimeout(pe),F&&clearTimeout(F),he&&clearTimeout(he);for(let r of C.splice(0))r.give(new Error("The client closed before the server could be reached."));for(let r of N.splice(0))r();let t=G;G=void 0,ee=!1;try{t?.close(1e3,"Closed.")}catch{}}},unheard(){let t=Ne;return Ne=[],t}};function Ir(t,r){let s=globalThis.WebSocket;if(!s)throw new Error("This runtime has no WebSocket; the client polls instead.");let i=typeof globalThis.document<"u",f=e.subprotocol?[Kt]:[];if(!i)try{return new s(t,{headers:r,...f.length>0?{protocols:f}:{}})}catch{}let y=new URL(t);for(let[H,w]of Object.entries(b))y.searchParams.set(H,w);return f.length>0?new s(y.toString(),f):new s(y.toString())}}function Oo(e,n,o=Date.now()){let a,d=e?.trim();if(d)if(/^\d+(\.\d+)?$/.test(d))a=Number(d)*1e3;else{let p=Date.parse(d);Number.isFinite(p)&&(a=Math.max(0,p-o))}let l=typeof n=="number"&&Number.isFinite(n)&&n>=0?n:void 0,b=l!==void 0&&l<50&&a!==void 0&&Math.abs(l*1e3-a)<1e3;return l!==void 0&&!b?l:a??1e3}function Co(){globalThis.location?.reload?.()}function Lo(){return globalThis.document?.visibilityState!=="hidden"}function Jt(e,n){if(typeof e=="function")return Math.max(0,e(n));let{min:o=250,max:a=1e4,factor:d=2}=e??{};return Math.min(a,o*d**n)*(.75+Math.random()*.5)}function ft(e){let n={};if(!e)return n;e.id&&(n[ge.seat]=e.id),e.roles?.length&&(n[ge.roles]=e.roles.join(",")),e.kind!=="human"&&(n[ge.kind]=e.kind),e.name&&(n[ge.name]=encodeURIComponent(e.name));let o=e.onBehalfOf;return o?.id&&(n[ge.for]=o.id),o?.roles?.length&&(n[ge.forRoles]=o.roles.join(",")),o?.name&&(n[ge.forName]=encodeURIComponent(o.name)),n}var Lr="/graview/views";function Yt(e){let n=e.fetch??fetch,o=e.url.replace(/\/$/,""),a={"content-type":"application/json",...e.principal?ft(e.principal):{},...e.headers??{}},d=e.state?{hidden:e.state.hidden??[],removed:e.state.removed??[],may:e.state.may??et.may}:et,l=new Set,b=v=>{if(JSON.stringify(v)!==JSON.stringify(d)){d=v;for(let P of l)P()}},p=async(v,P)=>{let C=await n(`${o}${e.path??Lr}`,{method:v,headers:a,...P!==void 0?{body:JSON.stringify(P)}:{}}),S=await C.json();if(!C.ok)throw new Error(S.error??`The store answered ${C.status}.`);b({hidden:S.hidden??[],removed:S.removed??[],may:S.may??et.may})},g=()=>p("GET"),A=e.state?Promise.resolve():g().catch(()=>{}),T=e.pollMs?setInterval(()=>void g().catch(()=>{}),e.pollMs):void 0;return{ready:A,refresh:g,close:()=>clearInterval(T),current:()=>d,onChange(v){return l.add(v),()=>void l.delete(v)},hide:v=>p("POST",{hide:v}),show:v=>p("POST",{show:v}),remove:(v,P)=>p("POST",{remove:v,...P?{about:P}:{}}),async restore(v){let P=d.removed.find(C=>C.name===v)?.lens;await p("POST",{restore:v}),P&&await e.onDeclaration?.()},async lens(v){await p("POST",{lens:v}),await e.onDeclaration?.()}}}var Zt=document.getElementById("graview-app"),Qt=/^\/forms\/([^/]+)\/?$/.exec(location.pathname),Mr=Qt?(__graviewPreload(import.meta.url,["./chunk.2QNGGF55.js","./chunk.Y4MQGEUS.js","./chunk.UGFDSE37.js","./chunk.EXEZBZGW.js","./chunk.X7N3JUO4.js","./chunk.NTLHEHOM.js","./chunk.GNBN3BK7.js","./chunk.XTMOFRHL.js","./chunk.NLBIX7LH.js","./chunk.GACKGEUY.js","./chunk.UJRBOUGC.js","./chunk.DWPU56S5.js","./chunk.ZH4NWRWB.js","./chunk.2GLJH253.js","./chunk.GUMJEVVP.js","./chunk.4VW6THJF.js","./chunk.SAHNXAV3.js","./chunk.DHAK6PPX.js","./chunk.YDL5BSTG.js","./chunk.DUWYF7BO.js","./chunk.UGJSMNVO.js","./chunk.NR5ODXMO.js","./chunk.XOZU4OFA.js","./chunk.SUPWMV2F.js","./chunk.MB7LKKUD.js","./chunk.V4BCB7N2.js","./chunk.FOP5RBGF.js","./chunk.WVUJXDXZ.js","./chunk.TPG6IY4M.js","./chunk.NFDLCUCC.js","./chunk.X7JMJSLU.js","./chunk.PPRSGM64.js","./chunk.5Y3Q7ONN.js","./chunk.KTFUVR4V.js","./chunk.GZHZLJBF.js","./chunk.RQBEQYB2.js","./chunk.OJGHDWI6.js","./chunk.6VAFNCR4.js","./chunk.N4M54YK6.js","./chunk.KVJFY7N5.js","./chunk.DPHTUTOS.js","./chunk.2UIUMG23.js","./chunk.KA44WNB4.js","./chunk.SDO3U72B.js","./chunk.4TJOS4C7.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.FPYL6REZ.js")):Oe("pages");try{Qt?await Mo(decodeURIComponent(Qt[1])):await Vo()}catch(e){let n=document.createElement("pre");n.setAttribute("role","alert"),n.style.cssText="margin:2rem;font:14px/1.5 ui-monospace,monospace;white-space:pre-wrap",n.textContent=e instanceof Error?e.message:String(e),Zt.replaceChildren(n),window.__graviewFailed=n.textContent}async function Mo(e){let n=await fetch(`/graview/document?form=${encodeURIComponent(e)}`),o=await n.json();if(!n.ok)throw new Error(o.error??`The preview server did not hand over the form (${n.status}).`);let a=await it(o);if(!a.ok)throw new Error(tt(a.findings));let d=a.app,l=o.principal,b=await ut({app:d,url:location.origin,principal:l,...o.state?{state:o.state,openTimeoutMs:0}:{openTimeoutMs:3e3}});document.title=d.forms?.[e]?.title??d.name;let{mount:p}=await Mr;window.__graview=p(Zt,{app:d,form:e,principal:l,remote:b,height:"100dvh",onSubmitted:()=>window.__graviewSubmitted=!0}),window.__graviewReady=!0}async function Vo(){let e=await fetch("/graview/document");if(!e.ok)throw new Error(`The preview server did not hand over the document (${e.status}).`);let n=await e.json(),a=await(async g=>{if(typeof g.module=="string")return(await import(g.module)).app;let A=await it(g);if(!A.ok)throw new Error(tt(A.findings));return A.app})(n);if(!a||typeof a!="object"||!("schema"in a))throw new Error("The app module the preview server handed does not export an app.");let d=n.principal,l=await ut({app:a,url:location.origin,principal:d,live:!0,subprotocol:!0,pollMs:1200,...n.state?{state:n.state,openTimeoutMs:0}:{openTimeoutMs:3e3}});document.title=a.name;let b,p=Yt({url:location.origin,principal:d,...n.views?{state:n.views}:{},onDeclaration:async()=>{let g=await(await fetch("/graview/document")).json();if(typeof g.module=="string")return;let A=await it(g);A.ok&&b?.setApp(A.app,l)}});await Promise.all([Mr,p.ready]),b=Gt(Zt,{app:a,remote:l,principal:d,studio:!1,face:"pages",routing:"address",bar:!0,height:"100dvh",label:a.name,heading:1,keptViews:p,...n.draftView?{draftView:n.draftView}:{}}),window.__graview=b,b.drawn().then(()=>{window.__graviewReady=!0})}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graview",
3
- "version": "0.1.46",
3
+ "version": "0.1.48",
4
4
  "type": "module",
5
5
  "description": "The Graview command line: start a product, check its declaration, write its agent docs, serve its store, preview a document with no product and photograph its places, say whether a product is on one release, host it for an agent over MCP, apply an act to it, sync its seed, install the authoring skills. The tool; @graview/* is the framework.",
6
6
  "keywords": [
@@ -29,11 +29,11 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@graview/core": "0.1.46",
33
- "@graview/guest": "0.1.46",
34
- "@graview/tools": "0.1.46",
35
- "@graview/ship": "0.1.46",
36
- "@graview/skills": "0.1.46"
32
+ "@graview/core": "0.1.48",
33
+ "@graview/skills": "0.1.48",
34
+ "@graview/guest": "0.1.48",
35
+ "@graview/tools": "0.1.48",
36
+ "@graview/ship": "0.1.48"
37
37
  },
38
38
  "engines": {
39
39
  "node": ">=22"
@@ -1 +0,0 @@
1
- import{a as T,c as h}from"./chunk.NMIXBH37.js";import{L as b,N as S}from"./chunk.AS4CQBOQ.js";var P=Symbol.for("@graview/core:file"),A=Symbol.for("@graview/core:node-ref"),p=e=>typeof e=="object"&&e!==null?e._zod?.def:void 0;function g(e){let t=p(e);return t?.[P]??(t?.innerType?g(t.innerType):void 0)}function v(e){let t=g(e);if(t)return{as:t,list:!1};let n=p(e);for(;n?.innerType;)n=p(n.innerType);let r=n?.type==="array"?g(n.element):void 0;return r?{as:r,list:!0}:void 0}function F(e){if(typeof e!="object"||e===null)return;let t=e[A];if(t)return t;let n=p(e);return n?.[A]??(n?.innerType?F(n.innerType):void 0)}function N(e){let t=e?.shape??{};return Object.entries(t).flatMap(([n,r])=>{let s=F(r);return s?[{name:n,kinds:s}]:[]})}var K=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.href=="string"&&typeof e.name=="string"&&typeof e.type=="string"&&typeof e.bytes=="number",W=e=>(Array.isArray(e)?e:[e]).filter(K);function I(e,t,n){let s=e.schema.tryDefinition(t)?.fields?.shape?.[n];return s===void 0?void 0:v(s)}function D(e,t){if(e===void 0)return[];if(!Array.isArray(e))return[`The view's accepts is a list of { "kind": <a kind>, "field": <its image, video or file field> }.`];let n=[],r=new Set(t.schema.kinds);for(let s of e){let{kind:l,field:d}=s??{};typeof l!="string"||typeof d!="string"?n.push(`Each of the view's accepts is { "kind": <a kind>, "field": <its image, video or file field> }.`):r.has(l)?I(t,l,d)?t.allMutations().some(o=>(o.creates??[]).includes(l)&&Object.hasOwn(o.input?.shape??{},d))||n.push(`No act of this app makes a "${l}" with its "${d}", so a file dropped could become nothing.`):n.push(`The view accepts files into ${l}'s "${d}", which holds no picture, video or file.`):n.push(`The view accepts files for "${l}", which is no kind of this app.`)}return n}function E(e){if(e===void 0||e===!0)return[];if(typeof e!="object"||e===null||Array.isArray(e))return[`The view's pictures is true, or { "width": <the widest it draws a picture, in pixels> }.`];let{width:t,...n}=e,r=[];return Object.keys(n).length>0&&r.push(`The view's pictures says ${Object.keys(n).map(s=>`"${s}"`).join(", ")}: only "width" is read.`),t!==void 0&&!(Number.isInteger(t)&&t>=16&&t<=4096)&&r.push("The view's pictures width is a whole number of pixels from 16 to 4096."),r}function x(e){return(e.acts??[]).map(t=>typeof t=="string"?{act:t}:t)}function B(e,t){let n=[],r=new Set(t.schema.kinds),s=new Set(t.schema.edgeKinds),l=new Set(t.allMutations().map(o=>o.name));(typeof e.name!="string"||!/^[a-z0-9][a-z0-9-]{0,62}$/.test(e.name))&&n.push(`The view's name "${String(e.name)}" is not lower-case letters, digits and hyphens.`),e.title!==void 0&&(typeof e.title!="string"||e.title.trim()===""||e.title.length>80)&&n.push("The view's title is empty or longer than 80 characters."),e.attach!=="home"&&!r.has(e.attach)&&n.push(`The view attaches to "${e.attach}", which is no kind of this app.`),e.cardinality!=="one"&&e.cardinality!=="many"&&n.push(`The view's cardinality is "${String(e.cardinality)}", not one or many.`),e.attach==="home"&&e.cardinality!=="many"&&n.push("A view of the home draws many records: its cardinality is many."),e.replaces!==void 0&&e.replaces!=="page"?n.push(`The view's replaces is "${String(e.replaces)}": the one thing a view replaces is "page", or leave it out to draw the view above the record's own fields.`):e.replaces==="page"&&(e.attach==="home"||e.cardinality!=="one")&&n.push('Only a view of one record replaces its page: replaces "page" needs cardinality one on a kind.'),e.gestures!==void 0&&typeof e.gestures!="boolean"&&n.push(`The view's gestures is "${String(e.gestures)}": it is true, or left out.`),e.bleed!==void 0&&typeof e.bleed!="boolean"&&n.push(`The view's bleed is "${String(e.bleed)}": it is true, or left out.`),n.push(...E(e.pictures)),n.push(...D(e.accepts,t));for(let o of e.reads?.kinds??[])r.has(o)||n.push(`The view reads "${o}", which is no kind of this app.`);for(let o of e.reads?.edges??[])s.has(o)||n.push(`The view reads the edge "${o}", which no kind of this app declares.`);let d=new Set;for(let o of x(e)){l.has(o.act)||n.push(`The view asks for the act "${o.act}", which this app does not declare.`);let c=o.as??o.act;d.has(c)&&n.push(`Two of the view's acts are called "${c}".`),d.add(c)}return n}function L(e,t,n){let{manifest:r}=n,s=n.input??{},d=e.seenBy(t).graph,o=r.attach==="home"?void 0:r.attach,c=o&&r.cardinality==="one"&&s.node?d.getNode(s.node.id):void 0,f=c&&c.kind===o?[c]:[],w=o&&r.cardinality==="many"?s.nodes?s.nodes.flatMap(i=>{let a=d.getNode(i.id);return a&&a.kind===o?[a]:[]}):d.nodesOfKind(o):[],$=new Set([...f,...w].map(i=>i.id)),k=T(d,$,{kinds:(r.reads?.kinds??[]).filter(i=>i!==o||r.cardinality==="one"),edges:r.reads?.edges??[]}),u=new Map;for(let i of[...w,...k.nodes])f.some(a=>a.id===i.id)||u.set(i.id,i);let j=new Set([...f.map(i=>i.id),...u.keys()]),M=[...k.edges],V=new Set(x(r).map(i=>i.act)),G=e.permittedMutations(t).filter(i=>V.has(i.name)).map(i=>({name:i.name,title:i.title??i.name,...i.description!==void 0?{description:i.description}:{},...i.subject?{subject:{kinds:i.subject.kinds,arg:i.subject.arg}}:{}})),m=i=>i?.filter(a=>j.has(a));return{view:r.name,...f[0]?{node:h(e,f[0])}:{},nodes:[...u.values()].map(i=>h(e,i)),edges:M,...r.title!==void 0?{label:r.title}:s.label!==void 0?{label:s.label}:{},cardinality:r.cardinality,...s.fidelity!==void 0?{fidelity:s.fidelity}:{},...s.mode!==void 0?{mode:s.mode}:{},...s.selected!==void 0?{selected:s.selected}:{},...s.implicated?{implicated:m(s.implicated)}:{},...s.flagged?{flagged:m(s.flagged)}:{},acts:G,...n.theme?{theme:n.theme}:{},locale:b(),timeZone:S(),...n.places?{places:n.places.filter((i,a,y)=>y.findIndex(O=>O.as===i.as)===a).map(({as:i,title:a,kind:y})=>({as:i,title:a,kind:y}))}:{}}}export{N as a,K as b,W as c,I as d,x as e,B as f,L as g};
@@ -1 +0,0 @@
1
- import{a as we,b as De,c as Ke,d as le,e as A,f as Me,h as Te}from"./chunk.6YD2DLIC.js";import{h as Ge,i as Ce,j as Ne}from"./chunk.IKX4VDTW.js";import{a as oe,b as se,c as H,d as Pe,e as Y,g as ee,h as _e}from"./chunk.TBQOSI4J.js";import{c as Ae,h as z,i as Fe,j as de}from"./chunk.KWQ7QOHD.js";import{A as ve,Ga as Ee,Ha as Q,Ia as ae,Lb as ce,Mb as Re,b as L,c as q,e as Se,f as je,g as _,h as S,k as G,l as J,m as C,n as Oe,o as B,p as D,r as $,s as X,t as E,u as R,v as V,w as M,x as e,y as K,z as U,za as xe}from"./chunk.AS4CQBOQ.js";var sn=n=>Object.entries(n).map(([s,r])=>[s,Object.keys(Q(r?.edges))]),pe=(n,s)=>Re(n,sn(s));var me="graview-document",ge=1,ze=256*1024,ne=64*1024,fe=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,ue=/^[a-z][A-Za-z0-9]*$/,rn=new Set(["id","kind"]),an=/^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|[a-z][A-Za-z0-9]*)$/,cn=["string","text","number","integer","boolean","date","datetime","enum","list","url","email","image","video","file","app-link","phone","place","duration"];function dn(){let n=k=>k in Object.prototype,s=U(k=>!n(k),"every object already has this name \u2014 choose another"),r=(k,N)=>[...k===void 0?[]:[je(k)],...N===void 0?[]:[Se(N)]],t=(k,N)=>S().check(...r(k,N)),a=(k,N,on)=>D(k).check(...r(N,on)),d=k=>S().check(_(fe,`${k} names are kebab-case, lower-case words joined by hyphens like "tool-note" (field and relation names are camelCase, like "supersededBy")`)),u=S().check(_(an,'relation names are one camelCase word, like "supersededBy" (kind names are kebab-case, like "tool-note")'),s),m=S().check(_(ue,'field names are one word or camelCase, like "dueDate", so rules say them bare (kind names are kebab-case, like "tool-note")'),U(k=>!rn.has(k),'a field cannot be called "id" or "kind" \u2014 the framework keeps those; try "type" or "category"'),s),h=t(1,500),i=t(1,2e3),o=t(1,300),p=$({type:V(cn),required:e(C()),description:e(h),label:e(t(1,60)),options:e(a(t(1,80),1,100)),of:e(V(["string","number","date","image","video","file"])),default:e(B()),unit:e(t(void 0,12)),format:e(V(["money","percent","duration","markdown"])),min:e(G()),max:e(G()),step:e(G()),renamedFrom:e(S().check(_(ue))),repeats:e(C())}).check(ve((k,N)=>{k.type==="enum"&&!k.options&&N.addIssue({code:"custom",message:'an enum field lists its "options"',path:["options"]}),k.type!=="enum"&&k.options&&N.addIssue({code:"custom",message:'"options" belongs only on an enum field',path:["options"]}),k.type!=="list"&&k.of&&N.addIssue({code:"custom",message:'"of" belongs only on a list field',path:["of"]}),k.repeats&&k.type!=="date"&&k.type!=="datetime"&&N.addIssue({code:"custom",message:'"repeats" belongs only on a date or datetime field',path:["repeats"]})})),w=S().check(_(new RegExp(`${fe.source}|${xe.source}`),'a relation goes to a kind of this document, like "house", or of another app, like "@nick/house/house"')),f=$({to:E([a(w,1),M("*")]),cardinality:e(V(["one","many"])),description:e(h),inverse:e(t(1,80)),appendOnly:e(C()),renamedFrom:e(S()),tidying:e(M("never"))}),l=E([i,$({expr:i,label:e(t(1,60)),description:e(h)})]),c=$({noun:e(t(1,40)),plural:e(t(1,40)),description:e(h),fields:R(m,p).check(U(k=>Object.keys(k).length>0,"a kind has at least one field")),label:e(o),describe:e(o),lifecycle:e($({field:m,retired:a(E([S(),G(),C()]),1)})),figure:e(t(void 0,2e4)),glance:e(a(m,1,20)),page:e($({fields:e(a(m,1,40)),groups:e(a($({title:t(1,60),fields:a(m,1,40)}),1,12))})),edges:e(R(u,f)),computed:e(R(S(),l).check(U(k=>Object.keys(k).length<=20,"a kind works out at most 20 computed fields"))),fieldRoles:e(R(S(),S())),renamedFrom:e(S().check(_(fe))),people:e(C()),archives:e(M(!1)),tidying:e(V(["never","no-links"]))}),O=E([S(),G(),C(),Oe(),D(B()),$({expr:i})]),y=S().check(_(/^\$[A-Za-z][A-Za-z0-9]*$/,'a reference is "$" and a name, like "$subject" or "$new"')),j=E([$({create:d("kind"),as:e(S().check(_(ue))),set:e(R(m,O))}),$({set:R(m,O),target:e(y)}),$({connect:u,from:y,to:y}),$({sever:u,from:y,to:y}),$({remove:y})]),v=$({title:e(t(1,80)),description:e(h),fromTheOtherEnd:e(t(1,80)),on:e(E([d("kind"),a(d("kind"),1)])),creates:e(d("kind")),sets:e(R(m,O)),writes:e(a(m,1)),connects:e(u),severs:e(u),setsOther:e(R(m,O)),replaces:e(E([M(!0),a(u,1,10)])),removes:e(M(!0)),args:e(R(m,p)),effects:e(a(j,1,20)),allowedWhen:e(i),refusal:e(o),destructive:e(C())}),b=$({act:d("act"),label:e(t(1,80)),args:e(R(S(),O))}),W=$({title:e(t(1,120)),description:e(h),over:E([M("graph"),d("kind")]),when:e(i),require:i,says:e(o),repairs:e(a(b,void 0,10))}),P=$({roles:E([a(d("role"),1),M("*")]),mutations:E([a(d("act"),1),M("*")]),kinds:e(E([D(d("kind")),M("*")])),describe:e(h),self:e(C()),ownEnd:e(C())}),g=e(a(d("field"),1)),x=$({roles:E([a(d("role"),1),M("*")]),kinds:a(d("kind"),1),own:e(C()),via:e(u),fields:g,hide:g}),F=$({grants:D(P),sees:e(D(x))}),te=$({accent:e(S().check(_(/^#[0-9a-fA-F]{6}$/,'an accent is a color like "#c2577a"'))),name:e(t(1,60)),currency:e(S().check(_(/^[A-Z]{3}$/,'a currency is its three-letter code, like "USD" or "EUR"'))),locale:e(t(2,35)),timeZone:e(t(1,64)),logo:e(E([t(1,ne),$({src:t(1,ne),alt:e(t(1,120))}),$({light:t(1,ne),dark:e(t(1,ne)),alt:e(t(1,120)),darkFallback:e(M("invert"))})])),favicon:e(E([t(1,ne),$({emoji:S()})])),typography:e($({display:e(t(1,200)),body:e(t(1,200)),mono:e(t(1,200))})),shape:e($({radius:e(G().check(q(0),L(32))),density:e(G().check(q(.75),L(1.5)))})),accents:e(R(S(),G().check(q(0),L(360)))),scheme:e(V(["light","dark","auto"])),subtitle:e(M(!1))}),I=R(S(),B()),Z=E([t(1,120),$({by:t(1,120),direction:e(V(["asc","desc"]))})]),ke=G().check(J(),q(1),L(9999)),Je=X({create:e(C()),options:e(X({sort:e(Z),columnSort:e(Z),search:e(a(t(1,120),void 0,40)),filters:e(a(t(1,120),void 0,40)),horizon:e(E([G().check(J(),q(1),L(200)),X({years:G().check(J(),q(1),L(200)),title:t(1,80),from:e(ke),to:e(ke)})]))}))}),Xe=$({card:e(D(B())),row:e(D(B())),page:e(D(B()))}),Qe=()=>{let k=e(V(["asc","desc"]));return E([t(1,120),$({by:t(1,120),direction:k,then:e(E([t(1,120),$({by:t(1,120),direction:k})]))})])},en=()=>E([t(1,120),$({by:t(1,120),order:e(a(t(1,80),void 0,40)),closed:e(a(t(1,80),void 0,40))})]),$e=X({order:e(D(S())),hide:e(D(S())),first:e(S()),primary:e(a(t(1,80),void 0,40)),scene:e(t(1,40)),pages:e(t(1,40)),lists:e(R(S(),$({filters:e(a(t(1,120),void 0,40)),sort:e(Qe()),group:e(en())})))}),nn=$({act:d("act"),title:e(t(1,80)),intro:e(h),fields:e(a(m,1,40)),say:e(h),submit:e(t(1,80)),role:e(d("role"))}),tn=$({$schema:e(S()),format:M(me),formatVersion:M(ge),name:t(1,80),description:e(h),version:e(G().check(J(),q(1))),kinds:R(d("kind"),c).check(U(k=>Object.keys(k).length>0,"a document declares at least one kind"),U(k=>Object.keys(k).length<=40,"a document declares at most 40 kinds")),computed:e(R(S(),l)),acts:e(R(d("act"),v)),rules:e(R(d("rule"),W)),roles:e(D(d("role"))),policy:e(F),modules:e(I),lenses:e(D(Je)),pages:e($e),views:e(R(S(),E([Xe,D(B())]))),brand:e(te),settings:e(D(I)),migrations:e(D(I)),connections:e(R(d("connection"),I)),forms:e(R(d("form"),nn))});return{FieldSpec:p,EdgeSpec:f,ComputedSpec:l,KindSpec:c,ValueSpec:O,EffectSpec:j,ActSpec:v,RepairSpec:b,RuleSpec:W,GrantSpec:P,SightSpec:x,PolicySpec:F,BrandSpec:te,PagesSpec:$e,DocumentSpec:tn}}var ln,T=()=>ln??=dn(),jn=K(()=>T().FieldSpec),On=K(()=>T().EdgeSpec),vn=K(()=>T().ComputedSpec),xn=K(()=>T().KindSpec),En=K(()=>T().ValueSpec),Rn=K(()=>T().EffectSpec),An=K(()=>T().ActSpec),Fn=K(()=>T().RepairSpec),Dn=K(()=>T().RuleSpec),Kn=K(()=>T().GrantSpec),Mn=K(()=>T().SightSpec),Tn=K(()=>T().PolicySpec),Pn=K(()=>T().BrandSpec),Gn=K(()=>T().PagesSpec),Ie=K(()=>T().DocumentSpec);var pn={};function Ve(n,s=pn,r=ge){let{document:t,respelled:a}=we(n),d=a.length>0?{respelled:a}:{};if(!t||typeof t!="object"||Array.isArray(t))return{document:t};let u=t;if(u.format!==me||typeof u.formatVersion!="number"||u.formatVersion>=r)return{document:t,...d};let m=u.formatVersion,h=structuredClone(u);for(let i=m;i<r;i++){let o=s[i];if(!o)throw new Error(`there is no upgrade from format ${i} to ${i+1}`);h={...o(h),formatVersion:i+1}}return{document:h,from:m,...d}}function qe(n,s,r){let t=Object.keys(n).filter(m=>n[m].edges?.[s]!==void 0);if(t.length===0)return;let a=t.map(m=>n[m].edges[s].to),d=a.some(m=>m==="*")?"*":[...new Set(a.flatMap(m=>m))];if(r.length===0||r.some(m=>t.includes(m)))return{reversed:!1,kinds:d};let u=t.filter(m=>{let h=n[m].edges[s].to;return h==="*"||r.every(i=>h.includes(i))});return u.length>0?{reversed:!0,kinds:u}:{reversed:!1,kinds:d}}var Ue=(n,s)=>{let r=n?.fields[s];return r!==void 0&&(r.type==="duration"||(r.type==="number"||r.type==="integer")&&r.format==="duration")};function Be(n,s,r,t){if(t==="out"){let a=n[s]?.edges?.[r]?.to;return a===void 0?[]:a==="*"?Object.keys(n):a}return Object.entries(n).filter(([,a])=>{let d=a.edges?.[r]?.to;return d!==void 0&&(d==="*"||d.includes(s))}).map(([a])=>a)}function ye(n,s,r){if(r.t==="ident")return n[s]?.edges?.[r.name]?Be(n,s,r.name,"out"):void 0;if(r.t==="where")return ye(n,s,r.set);if(r.t==="call"&&(r.fn==="out"||r.fn==="in")&&r.args[0]?.t==="lit"&&typeof r.args[0].value=="string")return Be(n,s,r.args[0].value,r.fn)}var Le=(n,s,r)=>{let t=s.filter(a=>n[a]?.fields[r]!==void 0);return t.length>0&&t.every(a=>Ue(n[a],r))};function We(n,s,r){let t=n.kinds,a=t[s],d=new Map(r),u=new Map,m=(i,o)=>{if(o>8)return!1;switch(i.t){case"ident":return Ue(a,i.name)||h(i.name,o+1);case"member":{let p=ye(t,s,i.object);return p!==void 0&&Le(t,p,i.name)}case"call":{if(i.fn!=="sum"&&i.fn!=="min"&&i.fn!=="max")return!1;let[p,w]=i.args,f=p&&ye(t,s,p);return f!==void 0&&w?.t==="ident"&&Le(t,f,w.name)}case"binary":return(i.op==="+"||i.op==="-")&&m(i.left,o)&&m(i.right,o);case"unary":return i.op==="-"&&m(i.operand,o);default:return!1}},h=(i,o)=>{if(a?.computed?.[i]===void 0)return!1;if(u.has(i))return u.get(i);u.set(i,!1);let p=d.get(i),w=p!==void 0&&m(p,o);return u.set(i,w),w};return r.map(([i])=>i).filter(i=>h(i,0))}function Ze(n,s,r=`kinds.${n}.page`){let t=s.page;if(!t)return[];let a=[],d=[...Object.keys(s.fields),...Object.keys(s.computed??{})],u=new Set,m=(i,o)=>{d.includes(i)?u.has(i)&&a.push(z("page-field-twice",o,`"${i}" is on ${n}'s page twice; name each field once`)):a.push(z("page-field",o,`${n}'s page is to show "${i}", and ${n} has no field or computed field called that`,`use one of: ${d.join(", ")}`)),u.add(i)};(t.fields??[]).forEach((i,o)=>m(i,`${r}.fields.${o}`));let h=new Set;return(t.groups??[]).forEach((i,o)=>{let p=i.title.trim().toLowerCase();h.has(p)&&a.push(z("page-group-twice",`${r}.groups.${o}.title`,`${n}'s page has two groups called "${i.title}"; give each its own title`)),h.add(p),i.fields.forEach((w,f)=>m(w,`${r}.groups.${o}.fields.${f}`))}),a}var fn=new Set(["subject","now","today","me"]);function un(n){if((typeof n=="string"?n:JSON.stringify(n??null)).length>ze)return{findings:[z("too-large","",`a document may be at most ${ze/1024} KB`)]};if(typeof n=="string")try{n=JSON.parse(n)}catch(t){return{findings:[z("not-json","",`this is not JSON: ${t.message}`)]}}try{n=Ve(n).document}catch(t){return{findings:[z("format","formatVersion",t.message)]}}let s=Ie.safeParse(n);if(!s.success)return{findings:s.error.issues.map(t=>{let a=t.path.map(String).join(".");if(t.code==="unrecognized_keys")return z("unknown-key",a,`${t.keys.map(d=>`"${d}"`).join(", ")} ${t.keys.length===1?"is":"are"} not part of a Graview document here`,"check the spelling against docs/declaration-document.md");if(t.code==="invalid_union"&&/\.effects\.\d+$/.test(a))return z("effect-shape",a,"this effect is not one Graview knows",'an effect is one of {"create": kind, "as"?: name, "set"?: {field: value}}, {"set": {field: value, \u2026}, "target"?: "$ref"}, {"connect"|"sever": relation, "from": "$ref", "to": "$ref"}, {"remove": "$ref"}');if(t.code==="invalid_key"){let d=t.issues?.[0]?.message;return z("shape",a,`the name "${String(t.path.at(-1))}" is not allowed here${d?`: ${d}`:""}`)}return z("shape",a,t.message)})};let r=s.data;return{document:r,findings:mn(r)}}var re=n=>[n??[]].flat();function He(n){let s=new Map;for(let[r,t]of Object.entries(n.kinds))for(let[a,d]of Object.entries(Q(t.edges))){let u=s.get(a);s.set(a,{name:a,from:[...u?.from??[],r],to:d.to==="*"||u?.to==="*"?"*":[...new Set([...u?.to??[],...d.to])],cardinality:d.cardinality??"many"})}return s}function pt(n){let s=new Map;for(let[t,a]of Object.entries(n.kinds)){let d=ee(a),u=ae(a.edges);s.set(t,{fields:new Set([...Object.keys(a.fields),...u.keys()]),edges:new Map(Object.entries(Q(a.edges)).map(([m,h])=>[m,h.cardinality??"many"])),...d?{computed:d}:{},...u.size>0?{linked:u}:{}})}let r=ee(n);return r&&s.set(Ae,{computed:r}),s}function Ye(n,s){let r=[],t=re(n.on),a=(d,u)=>{let m=qe(s.kinds,d,t)?.reversed===!0,[h,i]=m?["$to","$subject"]:["$subject","$to"];return u==="connect"?{connect:d,from:h,to:i}:{sever:d,from:h,to:i}};if(n.creates){let d=s.kinds[n.creates],u={};for(let m of Object.keys(d?.fields??{}))u[m]=`$${m}`;for(let m of n.effects??[])"set"in m&&!("create"in m)&&A(m.target)==="new"&&Object.assign(u,m.set);r.push({create:n.creates,as:"new",set:u})}return n.sets&&r.push({set:n.sets}),n.writes&&!(n.creates&&n.on===void 0)&&r.push({set:Object.fromEntries(n.writes.map(d=>[d,`$${d}`]))}),n.connects&&(n.replaces&&r.push({replace:n.replaces===!0?[n.connects]:[...n.replaces],keep:n.connects}),r.push(a(n.connects,"connect"))),n.severs&&r.push(a(n.severs,"sever")),n.setsOther&&(n.connects||n.severs)&&r.push({set:n.setsOther,target:"$to"}),n.removes&&r.push({remove:"$subject"}),n.effects&&r.push(...n.effects.filter(d=>!(n.creates&&"set"in d&&!("create"in d)&&A(d.target)==="new"))),r}function he(n,s,r){try{let t=H(n),a=oe(t);for(let d of a.unknownFunctions)r.push(z("unknown-function",s,`"${d}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));return t}catch(t){if(t instanceof se){r.push(z("expression",s,t.sentence+` (at character ${t.at+1})`));return}throw t}}function be(n,s,r){try{return Y(n)}catch(t){if(t instanceof Pe||t instanceof se){r.push(z("template",s,(t instanceof se,t.sentence)));return}throw t}}function mn(n){let s=[],r=new Set(Object.keys(n.kinds)),t=He(n),a=n.acts??{},d=new Set(n.roles??[]),u=(i,o)=>ae(n.kinds[i]?.edges).has(o),m=i=>Object.keys(n.kinds).some(o=>u(o,i));for(let[i,o]of Object.entries(n.kinds)){let p=`kinds.${i}`;for(let[f,l]of Object.entries(o.edges??{})){if(!Ee(l)&&l.to!=="*")for(let c of l.to)r.has(c)||s.push(z("edge-target",`${p}.edges.${f}.to`,`"${c}" is not a kind this document declares`));o.fields[f]&&s.push(z("edge-field-clash",`${p}.edges.${f}`,`"${f}" is both a field and a relation of ${i}`,"rename one of them"))}o.lifecycle&&!o.fields[o.lifecycle.field]&&s.push(z("lifecycle-field",`${p}.lifecycle.field`,`${i} has no field "${o.lifecycle.field}"`));let w=f=>o.computed!==void 0&&Object.hasOwn(o.computed,f);for(let f of o.glance??[])!o.fields[f]&&!w(f)&&s.push(z("glance-field",`${p}.glance`,`a glance at ${i} is to say "${f}", and ${i} has no field or computed field called that`,`use one of: ${[...Object.keys(o.fields),...Object.keys(o.computed??{})].join(", ")}`));s.push(...Ze(i,o));for(let f of["label","describe"]){let l=o[f];if(!l)continue;let c=be(l,`${p}.${f}`,s);for(let O of c??[])if(O.expr){for(let y of oe(O.expr).names)if(!o.fields[y]){if(w(y)){_e(o,y)||s.push(z("template-field",`${p}.${f}`,`${i}'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 ${i}'s own fields`));continue}s.push(z("template-field",`${p}.${f}`,`${i} 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,l]of Object.entries(o.fields)){l.default!==void 0&&l.type==="enum"&&!l.options?.includes(String(l.default))&&s.push(z("default-option",`${p}.fields.${f}.default`,`"${String(l.default)}" is not one of ${f}'s options`));let c=`${f}Repeat`;l.repeats&&(o.fields[c]||o.edges?.[c]||o.computed?.[c])&&s.push(z("repeat-clash",`${p}.fields.${f}.repeats`,`${i} already has "${c}", where how ${f} repeats is kept`))}}for(let[i,o]of Object.entries(a)){let p=`acts.${i}`;for(let c of re(o.on))r.has(c)||s.push(z("act-kind",`${p}.on`,`"${c}" is not a kind this document declares`));let w=re(o.on),f=Ye(o,n);if(o.creates&&o.on===void 0&&o.writes&&r.has(o.creates)){for(let c of o.writes)if(!n.kinds[o.creates].fields[c])if(n.kinds[o.creates].computed?.[c]!==void 0)s.push(z("computed-written",`${p}.writes`,`${o.creates}'s ${c} is worked out, not written: no act can set it`,"write the stored fields it is worked out from"));else{if(u(o.creates,c))continue;s.push(z("act-field",`${p}.writes`,`${o.creates} has no field "${c}"`))}}f.length===0&&s.push(z("act-empty",p,`"${i}" does nothing`,"give it effects or a shorthand such as sets or creates"));let l=new Map;f.forEach((c,O)=>{let y=f.length-(o.effects?.length??0),j=o.effects&&O>=y?`${p}.effects.${O-y}`:p;if("create"in c){if(!r.has(c.create))s.push(z("act-kind",`${j}.create`,`"${c.create}" is not a kind this document declares`));else for(let b of Object.keys(c.set??{}))n.kinds[c.create].fields[b]||(n.kinds[c.create].computed?.[b]!==void 0?s.push(z("computed-written",`${j}.set.${b}`,`${c.create}'s ${b} is worked out, not written: no act can set it`,"set the stored fields it is worked out from")):s.push(z("act-field",`${j}.set.${b}`,`${c.create} has no field "${b}"`)));c.as&&l.set(c.as,c.create)}else if("connect"in c||"sever"in c){let b="connect"in c?c.connect:c.sever;!t.has(b)&&!m(b)&&s.push(z("act-edge",`${j}.${"connect"in c?"connect":"sever"}`,`"${b}" is not a relation any kind declares`)),A(c.from)==="subject"&&w.length===0&&s.push(z("act-subject",`${p}.on`,`"${i}" acts on "$subject" but does not say which kinds it is "on"`))}else if("set"in c){let b=A(c.target??"$subject"),W=b==="subject"?w:l.has(b??"")?[l.get(b)]:[];b==="subject"&&w.length===0&&s.push(z("act-subject",`${p}.on`,`"${i}" changes "$subject" but does not say which kinds it is "on"`));for(let P of Object.keys(c.set))for(let g of W)if(!(!r.has(g)||n.kinds[g].fields[P]))if(n.kinds[g].computed?.[P]!==void 0)s.push(z("computed-written",`${j}.set.${P}`,`${g}'s ${P} is worked out, not written: no act can set it`,"set the stored fields it is worked out from"));else{if(u(g,P))continue;s.push(z("act-field",`${j}.set.${P}`,`${g} has no field "${P}"`))}}else"remove"in c&&A(c.remove)==="subject"&&w.length===0&&s.push(z("act-subject",`${p}.on`,`"${i}" removes "$subject" but does not say which kinds it is "on"`));("set"in c&&c.set?Object.values(c.set):[]).forEach(b=>{b&&typeof b=="object"&&!Array.isArray(b)&&"expr"in b&&he(b.expr,`${j}.set`,s)})}),o.allowedWhen&&he(o.allowedWhen,`${p}.allowedWhen`,s),o.refusal&&be(o.refusal,`${p}.refusal`,s)}for(let[i,o]of Object.entries(n.rules??{})){let p=`rules.${i}`;o.over!=="graph"&&!r.has(o.over)&&s.push(z("rule-kind",`${p}.over`,`"${o.over}" is not a kind this document declares`));let w=o.over==="graph"?void 0:n.kinds[o.over];for(let f of["when","require"]){let l=o[f];if(!l)continue;let c=he(l,`${p}.${f}`,s);if(!c)continue;let O=oe(c);for(let y of O.names)if(o.over==="graph")s.push(z("rule-name",`${p}.${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 j=Object.keys(w.edges??{}).find(v=>v.includes("-")&&v.split("-").includes(y));s.push(z("rule-name",`${p}.${f}`,`${o.over} has no field or relation called "${y}"`,j?`"${j}" reads as a subtraction in a rule; rename the relation to one camelCase word, like "${j.replace(/-([a-z0-9])/g,(v,b)=>b.toUpperCase())}"`:void 0))}for(let y of O.edges)!t.has(y)&&!m(y)&&s.push(z("rule-edge",`${p}.${f}`,`"${y}" is not a relation any kind declares`));for(let y of O.sweeps)r.has(y)?o.over!=="graph"&&s.push(Fe("rule-cost",`${p}.${f}`,`this rule looks at every ${y} for every ${o.over}, which grows slowly as the app grows`,"walk a relation with out()/in() instead of all() where you can")):s.push(z("rule-kind",`${p}.${f}`,`"${y}" is not a kind this document declares`))}o.says&&be(o.says,`${p}.says`,s),(o.repairs??[]).forEach((f,l)=>{!a[f.act]&&!ce(f.act)&&!pe(f.act,n.kinds)&&s.push(z("repair-act",`${p}.repairs.${l}.act`,`"${f.act}" is not an act this document declares`))})}let h=n.policy;return h&&(h.grants.forEach((i,o)=>{if(i.roles!=="*"&&d.size>0)for(let p of i.roles)d.has(p)||s.push(z("grant-role",`policy.grants.${o}.roles`,`"${p}" is not one of the document's roles`));if(i.mutations!=="*")for(let p of i.mutations)!a[p]&&!ce(p)&&!pe(p,n.kinds)&&s.push(z("grant-act",`policy.grants.${o}.mutations`,`"${p}" is not an act this document declares`))}),(h.sees??[]).forEach((i,o)=>{for(let p of i.kinds)r.has(p)||s.push(z("sight-kind",`policy.sees.${o}.kinds`,`"${p}" is not a kind this document declares`));if(i.roles!=="*"&&d.size>0)for(let p of i.roles)d.has(p)||s.push(z("sight-role",`policy.sees.${o}.roles`,`"${p}" is not one of the document's roles`))})),s.push(...Ne(n)),s}function gn(n,s,r,t){let a=new Map,d=re(n.on),u=new Map,m=new Map;(d.length>0||s.some(l=>"remove"in l&&A(l.remove)==="subject"||"from"in l&&(A(l.from)==="subject"||A(l.to)==="subject")||"set"in l&&!("create"in l)&&A(l.target??"$subject")==="subject"))&&a.set(le,{ref:d.length>0?d:"*",required:!0});let i=n.args??{},o=n.writes?.length===1,p=(l,c)=>c&&l.type===c.type&&l.min===void 0&&l.max===void 0&&l.step===void 0?{...l,...c.min===void 0?{}:{min:c.min},...c.max===void 0?{}:{max:c.max},...c.step===void 0?{}:{step:c.step}}:l,w=(l,c)=>c&&l.type===c.type&&l.format===void 0&&l.unit===void 0?{...p(l,c),...c.format?{format:c.format}:{},...c.unit?{unit:c.unit}:{}}:p(l,c),f=(l,c,O)=>{if(l===le||fn.has(l)||u.has(l)||a.has(l))return;let y=i[l]?w(i[l],O):void 0;a.set(l,y?{field:y,optional:!y.required,required:!!y.required}:c())};for(let l of s)if("create"in l){let c=r.kinds[l.create];for(let[O,y]of Object.entries(l.set??{})){let j=A(y),v=c?.fields[O];if(j&&v){let b=!!v.required&&v.default===void 0;f(j,()=>({field:v,optional:!b,required:b}),v)}}l.as&&u.set(l.as,l.create)}else if("connect"in l||"sever"in l){let c=t.get("connect"in l?l.connect:l.sever);for(let[O,y]of[["from",l.from],["to",l.to]]){let j=A(y);if(!j)continue;let v=O==="to"?c?.to??"*":c?.from??"*";v!=="*"&&!m.has(j)&&m.set(j,v),f(j,()=>({ref:v,required:!0}))}}else if("set"in l){let c=A(l.target??"$subject"),O=c==="subject"?d[0]:u.get(c??"")??m.get(c??"")?.[0];c&&c!=="subject"&&!u.has(c)&&f(c,()=>({ref:"*",required:!0}));for(let[y,j]of Object.entries(l.set)){let v=A(j);if(!v)continue;let b=O?r.kinds[O]?.fields[y]:void 0;f(v,()=>b?{field:b,optional:!o,required:o}:{any:!0,required:!1},b)}}else if("remove"in l){let c=A(l.remove);c&&f(c,()=>({ref:"*",required:!0}))}for(let[l,c]of Object.entries(i))a.has(l)||a.set(l,{field:c,optional:!c.required,required:!!c.required});return a}function ft(n,s={}){let r=un(n);if(!r.document||de(r.findings))return{ok:!1,findings:r.findings};let t=r.document,a=[...r.findings];s.previous&&a.push(...yn(t,s.previous));let d=zn(t,a);return de(d.findings)?{ok:!1,findings:d.findings}:Te(d,s)}function ie(n,s){return n.map(r=>{let t=!r.format&&r.expr?.t==="ident"?s?.[r.expr.name]?.format:void 0;return t==="money"||t==="percent"?{...r,format:t}:r})}function zn(n,s){let r=He(n),t={};for(let[i,o]of Object.entries(n.kinds)){let p=Me(o),w=o.label??(p?`{${p}}`:void 0),f=ee(o),l=f?We(n,i,[...f]):[];t[i]={...w?{label:ie(Y(w),o.fields)}:{},...o.describe?{describe:ie(Y(o.describe),o.fields)}:{},...f?{computed:[...f]}:{},...l.length>0?{durations:l}:{}}}let a={};for(let[i,o]of Object.entries(n.acts??{})){let p=Ye(o,n),w=gn(o,p,n,r),f=o.destructive??p.some(g=>"remove"in g||"sever"in g||"replace"in g),l=[...new Set(p.flatMap(g=>"create"in g?[g.create]:[]))],c=[...new Set(p.flatMap(g=>"connect"in g?[g.connect]:[]))],O=[...new Set(p.flatMap(g=>"sever"in g?[g.sever]:"replace"in g?g.replace:[]))],y=[...new Set(p.flatMap(g=>"set"in g&&!("create"in g)&&A(g.target??"$subject")==="subject"?Object.keys(g.set):[]))],j=new Map;for(let g of p){if(!("connect"in g)&&!("sever"in g))continue;let x=r.get("connect"in g?g.connect:g.sever);for(let[F,te]of[["from",g.from],["to",g.to]]){let I=A(te),Z=F==="to"?x?.to:x?.from;I&&I!=="subject"&&Z&&Z!=="*"&&j.set(I,[...new Set([...j.get(I)??[],...Z])])}}let v={};for(let g of p){if(!("set"in g)||"create"in g)continue;let x=A(g.target??"$subject");for(let F of x&&x!=="subject"&&j.get(x)||[])v[F]=[...new Set([...v[F]??[],...Object.keys(g.set)])]}let b={};for(let g of p)if(!(!("set"in g)||"create"in g||A(g.target??"$subject")!=="subject"))for(let[x,F]of Object.entries(g.set??{}))typeof F=="string"&&A(F)===void 0||typeof F=="number"||typeof F=="boolean"?b[x]=typeof F=="string"&&F.startsWith("$$")?F.slice(1):F:delete b[x];let W=l.length===0&&p.every(g=>!("set"in g)||!g.set||Object.values(g.set).every(x=>!(x&&typeof x=="object"&&!Array.isArray(x)&&"expr"in x))),P=new Map;for(let g of p)if(!(!("set"in g)||!g.set))for(let x of Object.values(g.set))x&&typeof x=="object"&&!Array.isArray(x)&&"expr"in x&&P.set(x.expr,H(x.expr));a[i]={title:o.title??i.replace(/-/g," "),effects:p,args:[...w],...o.allowedWhen?{guard:H(o.allowedWhen)}:{},...o.refusal?{refusal:ie(Y(o.refusal),n.kinds[[o.on??[]].flat()[0]??""]?.fields)}:{},exprs:[...P],destructive:f,idempotent:W,creates:l,connects:c,severs:O,writes:y,writesOther:v,sets:b}}let d={};for(let[i,o]of Object.entries(n.rules??{}))d[i]={title:o.title??i.replace(/-/g," "),require:H(o.require),...o.when?{when:H(o.when)}:{},...o.says?{says:ie(Y(o.says),n.kinds[o.over]?.fields)}:{}};let u=De(n,s),m=Ge(n),h=Ce(n);return{format:Ke,document:n,findings:s,kinds:t,...n.computed?{facts:[...ee(n)??[]]}:{},edges:[...r].map(([i,{from:o,to:p,cardinality:w}])=>[i,{from:o,to:p,cardinality:w}]),acts:a,rules:d,brand:u,...Object.keys(m).length>0?{viewSpecs:m}:{},...h?{home:h}:{}}}function ut(n,s,r){let t=/^defineNode\("([^"]+)"\)/.exec(s)?.[1],a=t?r.kinds[t]:void 0;if(!t||!a)return n;let d=Object.keys(a.fields).filter(u=>u!=="label").slice(0,3);return{...n,path:`kinds.${t}.glance`,fix:`Say which: "glance": [${d.map(u=>`"${u}"`).join(", ")}] on kinds.${t} \u2014 the facts a person compares one by, at a glance.`}}function yn(n,s){let r=[],t=new Set(Object.values(s.kinds).flatMap(a=>Object.keys(a.edges??{})));for(let[a,d]of Object.entries(n.kinds)){let u=d.renamedFrom;u&&!s.kinds[u]&&r.push(z("renamed-from-nothing",`kinds.${a}.renamedFrom`,`${a} says it was ${u}, and the previous version has no kind called ${u}`,"name the kind it was, or drop renamedFrom"));let m=s.kinds[u??a];for(let[h,i]of Object.entries(d.fields)){let o=i.renamedFrom;o&&!m?.fields[o]&&r.push(z("renamed-from-nothing",`kinds.${a}.fields.${h}.renamedFrom`,`${h} says it was ${o}, and the previous ${u??a} has no field called ${o}`,"name the field it was, or drop renamedFrom"))}for(let[h,i]of Object.entries(d.edges??{})){let o=i.renamedFrom;o&&!t.has(o)&&r.push(z("renamed-from-nothing",`kinds.${a}.edges.${h}.renamedFrom`,`${h} says it was ${o}, and the previous version has no relation called ${o}`,"name the relation it was, or drop renamedFrom"))}}return r}export{un as a,pt as b,Ye as c,ft as d,ut as e};
@@ -1,6 +0,0 @@
1
- import{a as k}from"./chunk.G4JJXA63.js";import{a as Q}from"./chunk.VC3BX2ZF.js";import{a as Y}from"./chunk.WAB7UDHU.js";import{a as X}from"./chunk.UHX4WTM7.js";import{c as _}from"./chunk.TBQOSI4J.js";import{cd as G,ed as H,fd as P,gd as J,kb as q,lb as z}from"./chunk.AS4CQBOQ.js";var O=e=>"failed"in e;function ue(e,n){let r=e.schema.kinds,t=e.policy?.sees;if(!t?.length||z(n))return{kinds:r};let o=q(n).roles??[],i=new Set(t.filter(s=>s.roles==="*"||o.some(a=>s.roles.includes(a))).flatMap(s=>s.kinds));return{kinds:r.filter(s=>i.has(s))}}function L(e,n){if(!n)return e;let r=new Set(n.kinds.filter(i=>e.tryDefinition(i)!==void 0));if(r.size===e.kinds.length)return e;let t=new Map,o=i=>{if(r.has(i)){if(!t.has(i)){let s=e.tryDefinition(i),a=Object.fromEntries(Object.entries(s?.edges??{}).flatMap(([l,d])=>{if(d.to==="*")return[[l,d]];let c=d.to.filter(u=>r.has(u));return c.length>0?[[l,{...d,to:c}]]:[]}));t.set(i,{...s,edges:a})}return t.get(i)}};return{...e,definitions:e.definitions.filter(i=>r.has(i.kind)),kinds:e.kinds.filter(i=>r.has(i)),tryDefinition:o,definition:i=>{let s=o(i);if(!s)throw new Error(`Unknown node kind "${i}"`);return s}}}var fe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),y=e=>fe(e).replace(/[-_]+/g," ").trim();function I(e){let n=[];for(let t of e.kinds){let o=e.tryDefinition(t);if(!o)continue;let i=o.display?.labels??{},s=Object.entries(o.fields?.shape??{}).filter(([d])=>d!=="id"&&d!=="kind").map(([d,c])=>{let u=X(c);return{name:d,type:u?.type,...u?.options?{options:u.options}:{},words:(i[d]??y(d)).toLowerCase()}}),a=Object.entries(o.edges??{}).map(([d,c])=>({name:d,from:t,to:c.to==="*"?e.kinds.filter(u=>u!==t):c.to,words:y(d)})),l=(o.plural??`${y(t)}s`).toLowerCase();n.push({kind:t,plural:l,noun:(o.noun??y(t)).toLowerCase(),fields:s,roles:o.fieldRoles??{},edges:a})}let r=new Map(n.map(t=>[t.kind,t]));return{schema:e,kinds:n,info:t=>r.get(t)}}var $=(e,n)=>n===void 0?void 0:e.fields.find(r=>r.name===n),A=e=>e?.type==="date"||e?.type==="datetime",N=e=>e?.type==="number"||e?.type==="integer"||e?.type==="duration",re=e=>` ${e.toLowerCase().replace(/[“”"’‘]/g,"'").replace(/[^\p{L}\p{N}' -]+/gu," ").replace(/\s+/g," ").trim()} `,E=(e,n)=>e.includes(` ${n} `),x=e=>e.endsWith("ies")?`${e.slice(0,-3)}y`:e.endsWith("ses")?e.slice(0,-2):e.endsWith("s")?e.slice(0,-1):e;function pe(e,n){let r=[];for(let t of n.kinds){let o=new Set([t.plural,t.noun,`${t.noun}s`,y(t.kind),`${y(t.kind)}s`]),i=-1;for(let s of o){let a=e.indexOf(` ${s} `);a>=0&&(i<0||a<i)&&(i=a)}i>=0&&r.push({info:t,at:i})}return r.sort((t,o)=>t.at-o.at).map(t=>t.info)}function v(e,n,r){let t=n.trim().toLowerCase();if(t.length===0)return;let o=e.fields.filter(i=>!r||r(i));return o.find(i=>i.words===t||y(i.name)===t||i.name.toLowerCase()===t)??o.find(i=>i.words===x(t)||y(i.name)===x(t))??o.find(i=>t.split(" ").some(s=>s.length>2&&(i.words.split(" ").includes(s)||i.words.split(" ").includes(x(s)))))}function oe(e,n,r){let t=n.trim().toLowerCase();if(t.length!==0)return e.edges.find(o=>o.words===t||o.name.toLowerCase()===t)??e.edges.find(o=>o.to.some(i=>{let s=r.info(i);return s!==void 0&&(s.noun===x(t)||s.plural===t||y(i)===x(t))}))??e.edges.find(o=>t.split(" ").some(i=>i.length>2&&o.words.split(" ").includes(i)))}function U(e){return/ (?:grouped |group |split |sorted |organi[sz]ed )?by ([\p{L}\p{N}' -]+?)(?= (?:and|with|for|in|on|only|where|from|this|that|as|sorted|grouped) |\s*$)/u.exec(e)?.[1]?.trim()}var me=/\bwho\b.*\b(covers?|cover|tends?|owns?|handles?|does|works? on|looks? after|is on|is assigned|staffs?|runs?)\b|\bcoverage\b|\bmatrix\b|\bwho covers\b/,ge=/\bcalendar\b|\bmonth\b|\bagenda\b|\bschedule\b|\bdue\b|\bdeadlines?\b|\bdates?\b|\bwhen\b/,ye=/\btimeline\b|\bover time\b|\bgantt\b|\bspans?\b|\bweek\b/,he=/\bboard\b|\bkanban\b|\bcolumns?\b|\bpipeline\b|\bstages?\b|\bstatus\b/,be=/\blaid out\b|\blayout\b|\bseating\b|\bwhere (?:they|it|each) (?:sits?|lies?|stands?)\b|\bfloor\b/,we=/\bplan\b|\bmap\b|\bregions?\b/,ke=/\blist\b|\btable\b|\bgroup(?:ed)? by\b|\bsort(?:ed)? by\b|\bonly\b|\bjust the\b/;function $e(e){let n=[];return/\blist\b|\btable\b/.test(e)&&n.push("blocks"),me.test(e)&&n.push("coverage"),be.test(e)&&n.push("board"),(/\bfloor plan\b/.test(e)||we.test(e))&&n.push("plan"),ye.test(e)&&n.push("timeline"),ge.test(e)&&n.push("calendar"),he.test(e)&&n.push("columns"),ke.test(e)&&!n.includes("blocks")&&n.push("blocks"),n.length===0&&U(e)&&n.push("columns"),n}var se=e=>{let n=r=>r?` and not ${r}`:"";if(/\boverdue\b|\blate\b|\bpast due\b/.test(e))return{cond:(r,t)=>`days(today(), ${r}) < 0${n(t)}`,says:r=>`overdue by ${r.words}`};if(/\btoday\b/.test(e))return{range:"day",cond:r=>`days(today(), ${r}) == 0`,says:r=>`with ${r.words} today`};if(/\bthis week\b|\bnext 7 days\b|\bnext week\b/.test(e))return{range:"week",cond:r=>`days(today(), ${r}) >= 0 and days(today(), ${r}) <= 6`,says:r=>`with ${r.words} in the next week`};if(/\bthis month\b|\bnext 30 days\b|\bnext month\b/.test(e))return{range:"month",cond:r=>`days(today(), ${r}) >= 0 and days(today(), ${r}) <= 30`,says:r=>`with ${r.words} in the next month`};if(/\blast month\b|\bpast month\b/.test(e))return{range:"month",cond:r=>`days(today(), ${r}) >= -30 and days(today(), ${r}) <= 0`,says:r=>`with ${r.words} in the last month`};if(/\bthis year\b/.test(e))return{range:"year",cond:r=>`days(today(), ${r}) >= 0 and days(today(), ${r}) <= 365`,says:r=>`with ${r.words} in the next year`};if(/\bquarter\b/.test(e))return{range:"quarter",cond:r=>`days(today(), ${r}) >= 0 and days(today(), ${r}) <= 91`,says:r=>`with ${r.words} in the next quarter`}},M=e=>{if(/\bagenda\b|\bin order\b/.test(e))return"agenda";if(/\btoday\b|\bday\b/.test(e))return"day";if(/\bweek\b/.test(e))return"week";if(/\bquarter\b/.test(e))return"quarter";if(/\byears\b/.test(e))return"years";if(/\byear\b/.test(e))return"year";if(/\bmonth\b/.test(e))return"month"},Z=/^(user|person|people|member|staff|gardener|volunteer|owner|agent|employee|worker|team|player|customer|client|contact|party|attendee|guest)s?$/,j=class extends Error{},h=e=>{throw new j(e)};function Se(e,n){let r=e.fields.filter(i=>i.type==="enum");if(n){let i=v(e,n);if(i&&i.type==="enum")return i;i&&h(`${e.plural}' ${i.words} is not a choice, so it has no columns`)}let t=$(e,e.roles.status??e.roles.column);if(t?.type==="enum")return t;let o=r.find(i=>/^(status|stage|state|phase)$/.test(i.name));return o||(r[0]?r[0]:h(`${e.plural} have no choice field to put in columns`))}function ee(e,n){let r=e.fields.filter(A),t=l=>{let d=$(e,e.roles[l]);return A(d)?d:void 0},i=r.find(l=>E(n,l.words)||E(n,y(l.name)))??t("start")??r.find(l=>/^(due|date|on|at|start|starts|begins|from|sown|when)/i.test(l.name))??r[0];if(!i)return h(`no date field on ${e.plural}`);let s=t("end")??r.find(l=>l!==i&&/^(end|ends|until|to|finish|finished|harvested|due|closes|through)/i.test(l.name)),a=e.fields.find(l=>l.type==="boolean"&&/^(done|finished|complete|completed|closed)$/.test(l.name));return{start:i,...s&&s!==i?{end:s}:{},...a?{done:a}:{}}}function ie(e){let n=$(e,e.roles.start),r=$(e,e.roles.end),t=$(e,e.roles.column??e.roles.day??e.roles.columns);if(N(n)&&N(r)&&t?.type==="enum")return{start:n,end:r,column:t}}function De(e,n,r,t){let o=[];for(let s of e.kinds)for(let a of s.edges)for(let l of a.to){let d=e.info(l);if(!d||d.kind===s.kind)continue;let c=0;n.includes(s)&&(c+=4),n.includes(d)&&(c+=4),(Z.test(d.kind)||Z.test(d.noun))&&(c+=3),t&&(a.words.includes(t)||d.noun===x(t))&&(c+=5),a.words.split(" ").some(u=>u.length>2&&r.includes(` ${u}`))&&(c+=2),o.push({rows:s,across:d,link:a,score:c})}let i=o.sort((s,a)=>a.score-s.score)[0];return i||h(n[0]?`${n[0].plural} are joined to nothing else, so there is no who-covers-what to draw`:"nothing here is joined to anything else, so there is no who-covers-what to draw")}function ae(e,n,r,t,o){let i=U(t);switch(e){case"columns":{if(i){let s=v(n,i);if(!s||s.type!=="enum"){let a=oe(n,i,r);if(a){let l=r.info(a.to[0]);return{lens:"coverage",kind:n.kind,across:l.kind,link:a.name}}}}return{lens:"columns",kind:n.kind,column:Se(n,i).name}}case"calendar":{let s=ee(n,t),a=M(t);return{lens:"calendar",kind:n.kind,start:s.start.name,...s.end?{end:s.end.name}:{},...s.done?{done:s.done.name}:{},...a?{range:a}:{}}}case"timeline":{let s=ie(n);if(s&&!/\bdates?\b|\bdue\b|\bdeadlines?\b|\bmonths?\b|\byears?\b/.test(t))return{lens:"timeline",kind:n.kind,start:s.start.name,end:s.end.name,column:s.column.name};let a=ee(n,t);return{lens:"calendar",kind:n.kind,start:a.start.name,...a.end?{end:a.end.name}:{},...a.done?{done:a.done.name}:{},range:M(t)??"quarter"}}case"coverage":{let s=De(r,o,t,i);return{lens:"coverage",kind:s.rows.kind,across:s.across.kind,link:s.link.name}}case"board":{let s=$(n,n.roles.x)??n.fields.find(c=>c.name==="x"),a=$(n,n.roles.y)??n.fields.find(c=>c.name==="y");if(!N(s)||!N(a))return h(`${n.plural} have no x and y to be laid out by`);let d=r.kinds.flatMap(c=>c.edges.filter(u=>u.to.includes(n.kind)&&c.kind!==n.kind))[0]??n.edges[0];return d?{lens:"board",kind:n.kind,x:s.name,y:a.name,fill:d.name,...d.from!==n.kind?{fillFrom:"occupant"}:{}}:h(`nothing is joined to ${n.plural} to fill them`)}case"plan":{let s=$(n,n.roles.outline)??n.fields.find(a=>a.name==="outline");return s?{lens:"plan",kind:n.kind,outline:s.name}:h(`${n.plural} have no outline to draw a plan from`)}case"blocks":{let s={lens:"blocks",kind:n.kind,as:/\bcards?\b/.test(t)?"card":"row"},a=/ group(?:ed)? by ([\p{L}\p{N} -]+?)(?= (?:and|only|sorted|with)|\s*$)/u.exec(t)?.[1]??(i&&!/ sort(?:ed)? by /.test(t)?i:void 0);if(a){let c=v(n,a);if(!c||c.type!=="enum")return h(c?`${n.plural}' ${c.words} is not a choice, so they cannot be grouped by it`:`${n.plural} have nothing called ${a} to group by`);s.group=c.name}let l=/ sort(?:ed)? by ([\p{L}\p{N} -]+?)(?= (?:and|only|grouped|with)|\s*$)/u.exec(t)?.[1];if(l){let c=v(n,l);if(!c)return h(`${n.plural} have nothing called ${l} to sort by`);s.sort={by:c.name,.../\b(newest|latest|desc|descending|most)\b/.test(t)?{direction:"desc"}:{}}}let d=V(n,t);return d.length>0&&(s.where=d),s}}}function V(e,n){let r=[],t=se(n);if(t){let o=e.fields.filter(A),i=$(e,e.roles.start),s=o.find(l=>E(n,l.words))??(A(i)?i:void 0)??o[0];(!s||!A(s))&&h(`no date field on ${e.plural}`);let a=e.fields.find(l=>l.type==="boolean"&&/^(done|finished|complete|completed|closed)$/.test(l.name));r.push({expr:t.cond(s.name,/\boverdue\b|\blate\b|\bpast due\b/.test(n)?a?.name:void 0),says:t.says(s)})}if(/\bonly\b|\bjust\b|\bthat are\b|\bwhich are\b/.test(n)){for(let o of e.fields){if(o.type!=="enum")continue;let i=o.options?.find(s=>E(n,s.toLowerCase())||E(n,y(s)));i&&r.push({expr:`${o.name} == '${i.replace(/'/g,"")}'`,says:`that are ${y(i)}`})}if(/\bnot done\b|\bundone\b|\bunfinished\b|\bopen ones\b|\bstill to do\b/.test(n)){let o=e.fields.find(i=>i.type==="boolean"&&/^(done|finished|complete|completed)$/.test(i.name));o&&r.push({expr:`not ${o.name}`,says:`not ${o.words}`})}}return r}var B={columns:"A board",calendar:"A calendar",timeline:"A timeline",coverage:"A grid",board:"A layout",plan:"A plan",blocks:"A list",reach:"A picture"};function Re(e,n){let r=n.info(e.kind),t=o=>o?$(r,o)?.words??y(o):"";switch(e.lens){case"columns":return{title:`${k(r.plural)} by ${t(e.column)}`,detail:`of ${r.plural} by ${t(e.column)}`};case"calendar":{let o=e.range??"month";if(o==="agenda")return{title:`${k(r.plural)} in date order`,detail:`of ${r.plural} in order of ${t(e.start)}`};let i=o==="years"?"year":o;return{title:`${k(r.plural)} by ${i}`,detail:`of ${r.plural} by ${t(e.start)}, a ${i} at a time`}}case"timeline":return{title:`${k(r.plural)} over the ${t(e.column)}`,detail:`of ${r.plural} from ${t(e.start)} to ${t(e.end)}, by ${t(e.column)}`};case"coverage":{let o=n.info(e.across);return{title:`${k(r.plural)} by ${o.noun}`,detail:`of which ${o.noun} covers which ${r.noun}`}}case"board":return{title:`${k(r.plural)} where they stand`,detail:`of ${r.plural} where they stand`};case"plan":return{title:`${k(r.plural)} on a plan`,detail:`of ${r.plural}`};default:{let o=[e.where?.map(i=>i.says).join(" and "),e.group?`by ${t(e.group)}`:void 0,e.sort?`in order of ${t(e.sort.by)}`:void 0].filter(i=>!!i);return{title:[k(r.plural),...o].join(" "),detail:[`of ${r.plural}`,...o].join(" ")}}}}function Ae(e,n){let r={title:n,on:e.kind};switch(e.lens){case"columns":return{name:"columns",...r,bindings:{[e.kind]:{column:e.column}}};case"calendar":return{name:"calendar",...r,bindings:{[e.kind]:{start:e.start,...e.end?{end:e.end}:{},...e.done?{done:e.done}:{}}},...e.range?{options:{range:e.range}}:{}};case"timeline":return{name:"timeline",...r,bindings:{[e.kind]:{start:e.start,end:e.end,column:e.column}}};case"coverage":return{name:"coverage",...r,bindings:{rows:{kind:e.kind},columns:{kind:e.across},link:{edge:e.link}}};case"board":return{name:"board",...r,bindings:{slots:{kind:e.kind},x:{field:e.x,on:"slots"},y:{field:e.y,on:"slots"},fill:{edge:e.fill}},...e.fillFrom?{options:{fillFrom:e.fillFrom}}:{}};case"plan":return{name:"plan",...r,bindings:{regions:{kind:e.kind},outline:{field:e.outline,on:"regions"}}};default:{let t=e.where?.length?` where ${e.where.map(i=>e.where.length>1?`(${i.expr})`:i.expr).join(" and ")}`:"",o={list:`all('${e.kind}')${t}`,as:e.as??"row"};return e.group&&(o.group=e.group),e.sort&&(o.sort=e.sort.direction?{by:e.sort.by,direction:e.sort.direction}:e.sort.by),o.empty="Nothing here yet.",{name:"blocks",...r,options:{blocks:[o]}}}}}function C(e,n){let r=o=>o.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,""),t=new Set(["home","overview",...Q(n).map(o=>o.slug),...(n.lenses??[]).flatMap(o=>o.title?[r(o.title)]:[])]);if(!t.has(r(e)))return e;for(let o=2;;o++)if(!t.has(r(`${e} ${o}`)))return`${e} ${o}`}var ne={title:[],headline:[],text:["tone"],figure:["as","currency","label"],list:["sort","limit","group","empty","as"],progress:["label"],group:["direction"],when:["show"],divider:[]};function Ee(e,n){if(!Array.isArray(n)||n.length===0)return"it has no blocks to draw";if(n.length>40)return"it has more blocks than a place draws";let r=(s,a)=>{if(typeof s!="string"||s.trim()==="")return`its ${a} says nothing`;try{return _(s)}catch(l){return`its ${a} does not read: ${l instanceof Error?l.message.replace(/ \(at character.*$/,""):String(l)}`}},t=s=>{if(s.t==="where")return t(s.set);if(s.t==="call"&&s.fn==="all"){let a=s.args[0];return a?.t==="lit"&&typeof a.value=="string"?e.info(a.value)??null:void 0}},o=(s,a)=>{switch(s.t){case"lit":return;case"ident":return a&&!a.fields.some(l=>l.name===s.name)&&!a.edges.some(l=>l.name===s.name)?`${a.plural} have nothing called ${s.name}`:void 0;case"member":return o(s.object,a);case"list":return s.items.map(l=>o(l,a)).find(Boolean);case"unary":return o(s.operand,a);case"binary":return o(s.left,a)??o(s.right,a);case"where":{let l=t(s.set);return l===null?"Nothing by that name here":o(s.set,a)??o(s.filter,l??void 0)}case"call":return s.fn==="all"?t(s)===null?"Nothing by that name here":void 0:s.args.map(l=>o(l,a)).find(Boolean)}},i=(s,a)=>{if(a>4)return"its blocks nest deeper than a place draws";for(let l of s){if(!w(l))return"a block is not an object";let d=Object.keys(ne).find(p=>p in l);if(!d)return`"${Object.keys(l)[0]??""}" is not a block a place draws`;let c=Object.keys(l).find(p=>p!==d&&p!=="key"&&!ne[d].includes(p));if(c)return`a ${d} block takes no "${c}"`;let u=l[d];if(d==="list"||d==="figure"||d==="when"){if(d==="figure"&&u===!0)continue;let p=r(u,d);if(typeof p=="string")return p;let g=o(p,void 0);if(g)return g;if(d==="list"){let f=t(p);if(f==null)return f===null?"Nothing by that name here":"its list does not say which records it lists, like all('task')";for(let m of["group","sort"]){let b=l[m],S=typeof b=="string"?b:w(b)&&typeof b.by=="string"?b.by:void 0;if(b===void 0)continue;let D=S?f.fields.find(ce=>ce.name===S):void 0;if(!D)return`${f.plural} have nothing called ${String(S??b)} to ${m} by`;if(m==="group"&&D.type!=="enum")return`${f.plural}' ${D.words} is not a choice, so they cannot be grouped by it`}}if(d==="when"){let f=l.show;if(!Array.isArray(f))return"a when block shows a list of blocks";let m=i(f,a+1);if(m)return m}}else if(d==="group"){if(!Array.isArray(u))return"a group block holds a list of blocks";let p=i(u,a+1);if(p)return p}else{if(d!=="divider"&&typeof u!="string")return`a ${d} block says words`;if(typeof u=="string")for(let p of u.matchAll(/\{([^{}]*)\}/g)){let g=p[1].split(/\|(?![|])/)[0],f=r(g,`${d}'s braces`);if(typeof f=="string")return f;let m=o(f,void 0);if(m)return m}}}};return i(n,1)}function T(e,n,r){let t=L(e.schema,r),o=f=>({ok:!1,failed:`Couldn't draw that: ${f.replace(/\.$/,"")}.`});if(!P(n.name)||n.name==="reach")return o(`"${String(n.name)}" is not a picture the seat can draw; it draws ${H.filter(f=>f!=="reach").join(", ")}`);if(typeof n.title!="string"||n.title.trim().length===0||n.title.length>80)return o("it needs a title of a few words");if(typeof n.on!="string"||!t.tryDefinition(n.on))return o("Nothing by that name here");let i=G[n.name],s=n.bindings??{};if(i.binds==="fields")for(let[f,m]of Object.entries(s)){if(!t.tryDefinition(f))return o("Nothing by that name here");let b=Object.keys(t.tryDefinition(f).fields?.shape??{});for(let[S,D]of Object.entries(m??{}))if(typeof D!="string"||!b.includes(D))return o(`${y(f)} has no field "${String(D)}" for its ${S}`);for(let S of i.requiredRoles)if(!(S in(m??{})))return o(`a ${n.name} needs ${y(f)}'s ${S}`)}else if(i.binds==="entities")for(let f of i.requiredRoles){let m=s[f];if(!m)return o(`a ${n.name} needs its ${f}`);if(typeof m.kind=="string"&&!t.tryDefinition(m.kind))return o("Nothing by that name here")}let a={...e,schema:t,lenses:[...e.lenses??[],n]},l=a.lenses.length-1,d=J(a),c=`lenses.${l}`,u=d.findings.find(f=>f.path===c||f.path.startsWith(`${c}.`));if(u)return o(u.message.replace(/^"[^"]*" /,"it "));let p=d.undrawn.find(f=>f.index===l);if(p)return o(p.why);let g=d.drawn.find(f=>f.index===l);if(!g)return o("its bindings name something the app does not have");if(g.as==="overview")return o(`"${n.title}" is the scene's own address; give it another title`);if(n.name==="blocks"){let f=Ee(I(t),n.options?.blocks);if(f)return o(f)}return{ok:!0,drawn:g}}function K(e){return{op:"add-lens",title:e.title,lens:e.name,on:e.on,...e.bindings?{bindings:e.bindings}:{},...e.options?{options:e.options}:{}}}function xe(e){return{op:"remove-lens",title:e.title,on:e.on}}var w=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function de(e){let n=w(e)?e:{},r=String(n.lens??n.name??""),t=n.bindings,o=typeof n.on=="string"?n.on:w(t)&&G[r]?.binds==="fields"?Object.keys(t)[0]??"":"";return{name:r,title:typeof n.title=="string"?n.title.trim():"",on:o,...w(t)?{bindings:t}:{},...w(n.options)?{options:n.options}:{}}}function ve(e){let n=o=>w(e.bindings?.[o])?e.bindings[o]:{},r=o=>typeof o=="string"?o:void 0,t=n(e.on);switch(e.name){case"columns":return r(t.column)?{lens:"columns",kind:e.on,column:t.column}:void 0;case"calendar":{let o=r(e.options?.range);return r(t.start)?{lens:"calendar",kind:e.on,start:t.start,...r(t.end)?{end:t.end}:{},...r(t.done)?{done:t.done}:{},...o?{range:o}:{}}:void 0}case"timeline":return r(t.start)&&r(t.end)&&r(t.column)?{lens:"timeline",kind:e.on,start:t.start,end:t.end,column:t.column}:void 0;case"coverage":{let o=w(e.bindings?.columns)?r(e.bindings.columns.kind):void 0,i=w(e.bindings?.link)?r(e.bindings.link.edge):void 0;return o&&i?{lens:"coverage",kind:e.on,across:o,link:i}:void 0}case"blocks":{let o=e.options?.blocks;if(!Array.isArray(o)||o.length!==1||!w(o[0]))return;let i=o[0],s=new RegExp(`^all\\('${e.on}'\\)(?: where (.+))?$`).exec(String(i.list??""));if(!s)return;let a=i.sort;return{lens:"blocks",kind:e.on,as:i.as==="card"?"card":"row",...typeof i.group=="string"?{group:i.group}:{},...typeof a=="string"?{sort:{by:a}}:w(a)&&typeof a.by=="string"?{sort:{by:a.by,...a.direction==="desc"?{direction:"desc"}:{}}}:{},...s[1]?{where:[{expr:s[1],says:"as asked"}]}:{}}}default:return}}function W(e,n,r,t,o){let i=I(L(e.schema,t)).info(n.on),s=ve(n);return{title:n.title,said:`${B[n.name]??"A picture"} of ${i?.plural??y(n.on)}.`,kind:n.on,lens:n,drawn:r,edit:K(n),by:o,asks:[],...s?{recipe:s}:{}}}function te(e){return{title:e.title,said:e.said,lens:{title:e.lens.title,lens:e.lens.name,on:e.lens.on,...e.lens.bindings?{bindings:e.lens.bindings}:{},...e.lens.options?{options:e.lens.options}:{}},edit:e.edit,by:e.by,check:"It draws, and graview check would take it."}}function F(e,n,r,t,o){let i=Re(e,n),s=e.title??o??C(i.title,r.app),a=Ae(e,s),l=T(r.app,a,r.sight);return l.ok?{title:s,said:`${B[e.lens]} ${i.detail}.`,kind:e.kind,lens:a,drawn:l.drawn,edit:K(a),by:"template",asks:t,recipe:e}:{failed:l.failed,...r.lastGood?{lastGood:r.lastGood}:{}}}function Ye(e,n){let r=I(L(n.app.schema,n.sight)),t=r.info(e.kind);if(!t)return{failed:"Couldn't draw that: Nothing by that name here."};let o=e.lens==="blocks"&&!e.group&&!e.sort&&!e.where?.length&&e.title===void 0;return F(o?{...e,title:C(`Every ${t.noun}`,n.app)}:e,r,n,[])}function Le(e,n,r,t){if(r.length>0)return r;let o=s=>{switch(e){case"columns":return s.fields.some(a=>a.type==="enum");case"calendar":return s.fields.some(A);case"timeline":return ie(s)!==void 0||s.fields.some(A);case"coverage":return s.edges.some(a=>a.to.some(l=>l!==s.kind));case"board":return s.fields.some(a=>a.name==="x")&&s.fields.some(a=>a.name==="y");case"plan":return s.fields.some(a=>a.name==="outline")||s.roles.outline!==void 0;default:return!0}};return[...n.kinds.filter(o)].sort((s,a)=>Number(a.fields.some(l=>E(t,l.words)))-Number(s.fields.some(l=>E(t,l.words))))}function Ie(e,n){let r=I(L(n.app.schema,n.sight)),t=re(e),o=$e(t);if(o.length===0)return;let i=pe(t,r),s;for(let a of o){let l=a==="coverage"?[i[0]??r.kinds[0]].filter(d=>!!d):Le(a,r,i,t);for(let d of l)try{let c=ae(a,d,r,t,i),u=F(c,r,n,[e]);if(!O(u))return u;s??=u.failed}catch(c){if(!(c instanceof j))throw c;s??=`Couldn't draw that: ${c.message}.`}l.length===0&&i.length===0&&(s??=`Couldn't draw that: nothing here has what ${B[a].toLowerCase()} needs.`)}return{failed:s??"Couldn't draw that: Nothing by that name here.",...n.lastGood?{lastGood:n.lastGood}:{}}}async function Oe(e,n){let r=n.lastGood?{lastGood:n.lastGood}:{};if(e.trim().length===0)return{failed:"Say what you would like to see, like \u201Ca board of tasks by status\u201D.",...r};let t=Ie(e,n);if(t&&!O(t))return t;if(!n.complete)return t??{failed:"Couldn't draw that: drawing freely needs AI, which isn't on here. Ask for a board, a calendar, a timeline, a list or who covers what.",...r};let o=await le(e,n,void 0);return O(o)&&t?t:o}async function je(e,n,r){let t={lastGood:e},o={...r,lastGood:e},i=I(L(r.app.schema,r.sight)),s=re(n),a=i.info(e.kind),l=[...e.asks,n];if(!a)return{failed:"Couldn't change that: Nothing by that name here.",...t};let d=e.recipe,c=/^ (?:call|name|title) (?:it|this)? ?(.+?) $/.exec(s)??/ (?:call|name) it (.+?) $/.exec(s);try{if(c){let g=n.replace(/^.*?\b(?:call|name|title)\b\s*(?:it|this)?\s*/i,"").replace(/^["“']|["”']$/g,"").trim();if(g.length===0)return{failed:"Couldn't change that: say what to call it.",...t};let f={...e.lens,title:C(g,r.app)},m=T(r.app,f,r.sight);return m.ok?{...e,title:f.title,lens:f,drawn:m.drawn,edit:K(f),asks:l,...d?{recipe:{...d,title:f.title}}:{}}:{failed:m.failed,...t}}let p=/ as (?:a |an )?(board|kanban|calendar|timeline|list|table|cards|rows|grid|plan|layout)\b/.exec(s);if(p){let g=p[1]==="board"||p[1]==="kanban"?"columns":p[1]==="calendar"?"calendar":p[1]==="timeline"?"timeline":p[1]==="grid"?"coverage":p[1]==="plan"?"plan":p[1]==="layout"?"board":"blocks",f=ae(g,a,i,s,[a]),m=p[1]==="cards"?"card":p[1]==="rows"?"row":void 0,b=g==="blocks"&&d?.lens==="blocks"?{...d,...m?{as:m}:{}}:g==="blocks"&&d?.lens==="columns"?{...f,group:d.column,...m?{as:m}:{}}:f;return F(R(b),i,o,l)}if(d){let g=Te(d,a,i,s);if(g)return F(g,i,o,l)}}catch(p){if(!(p instanceof j))throw p;return{failed:`Couldn't change that: ${p.message}.`,...t}}if(!r.complete)return{failed:"Couldn't change that: changing it freely needs AI, which isn't on here. Try \u201Cgroup by status\u201D, \u201Conly this month\u201D or \u201Cas a calendar\u201D.",...t};let u=await le(n,o,e);return O(u)?u:{...u,asks:l}}var R=e=>{let{title:n,...r}=e;return r};function Te(e,n,r,t){let o=/ (?:group(?:ed)?|split|organi[sz]ed?|put them|columns) by ([\p{L}\p{N} -]+?)(?= (?:and|only|with)|\s*$)/u.exec(t)?.[1]??(/^ by /.test(t)?U(t):void 0);if(o){let d=v(n,o);if(d?.type==="enum")return e.lens==="blocks"?{...R(e),group:d.name}:{lens:"columns",kind:e.kind,column:d.name};let c=oe(n,o,r);return c?{lens:"coverage",kind:e.kind,across:c.to[0],link:c.name}:h(d?`${n.plural}' ${d.words} is not a choice, so they cannot be grouped by it`:`${n.plural} have nothing called ${o} to group by`)}let i=/ (?:sort(?:ed)?|order(?:ed)?) by ([\p{L}\p{N} -]+?)(?= (?:and|only|with)|\s*$)/u.exec(t)?.[1];if(i){let d=v(n,i);return d?{...e.lens==="blocks"?R(e):{lens:"blocks",kind:e.kind,as:"row",...e.lens==="columns"?{group:e.column}:{}},sort:{by:d.name,.../\b(newest|latest|desc|descending|most)\b/.test(t)?{direction:"desc"}:{}}}:h(`${n.plural} have nothing called ${i} to sort by`)}if(/\b(?:all of them|everything|show all|clear the filter|no filter|without the filter)\b/.test(t)){if(e.lens!=="blocks"||!e.where)return h("it already shows all of them");let{where:d,...c}=R(e);return c}let s=se(t);if(s&&e.lens==="calendar"&&s.range)return{...R(e),range:s.range};if(s&&e.lens==="calendar"&&!s.range)return{lens:"blocks",kind:e.kind,as:"row",sort:{by:e.start},where:V(n,t)};let a=V(n,t);if(a.length>0){let d=e.lens==="blocks"?R(e):{lens:"blocks",kind:e.kind,as:"row",...e.lens==="columns"?{group:e.column}:{}};return{...d,where:[...d.where??[],...a]}}let l=e.lens==="calendar"?M(t):void 0;if(l)return{...R(e),range:l}}function Ne(e){return e.kinds.map(n=>{let r=n.fields.map(i=>`${i.name} (${i.type??"value"}${i.options?`: ${i.options.join(" | ")}`:""})`).join(", "),t=n.edges.map(i=>`${i.name} \u2192 ${i.to.join(" | ")}`).join(", "),o=Object.entries(n.roles).map(([i,s])=>`${i}=${s}`).join(", ");return`- ${n.kind} ("${n.plural}"): ${r}${t?`; relations: ${t}`:""}${o?`; roles: ${o}`:""}`}).join(`
2
- `)}var Fe=['columns \u2014 a board, records in columns by one choice field: {"lens": "columns", "on": K, "bindings": {K: {"column": "<enum field>"}}}','calendar \u2014 records on a calendar by a date: {"lens": "calendar", "on": K, "bindings": {K: {"start": "<date field>", "end"?: "<date field>", "done"?: "<boolean field>"}}, "options": {"range"?: "day" | "week" | "month" | "quarter" | "year" | "agenda"}}','timeline \u2014 minutes of a day in columns: {"lens": "timeline", "on": K, "bindings": {K: {"start": "<number field>", "end": "<number field>", "column": "<enum field>"}}}','coverage \u2014 who covers what, a grid of two kinds joined by a relation: {"lens": "coverage", "on": K, "bindings": {"rows": {"kind": K}, "columns": {"kind": J}, "link": {"edge": "<relation of K to J>"}}}',`blocks \u2014 anything else, as blocks: {"lens": "blocks", "on": K, "options": {"blocks": [{"headline": "words"}, {"list": "all('K') where <condition>", "group"?: "<enum field>", "sort"?: "<field>" | {"by": "<field>", "direction": "desc"}, "as"?: "row" | "card", "empty"?: "words"}, {"figure": "count(all('K'))", "label": "words"}]}}. Conditions read a record's own fields: status == 'open', not done, days(today(), due) <= 7.`].join(`
3
- `);function Ce(e,n,r){return["You draw a view of an app's data as JSON \u2014 never code. The app's kinds, their fields (with types) and relations:",Ne(n),"","The lenses you may use (prefer the first four; use blocks only when none of them fits):",Fe,"",r?`The view on screen now:
4
- ${JSON.stringify(r.lens)}
5
- Change it as asked, and keep everything not asked about.`:"",`Asked: ${JSON.stringify(e)}`,'Answer with ONE JSON object: {"title": "<a few words, like Deliverables by status>", "lens": \u2026, "on": \u2026, "bindings"?: \u2026, "options"?: \u2026}. Name only the kinds, fields and relations listed above. If it cannot be drawn from them, answer {"failed": "<one sentence saying why>"}.'].filter(t=>t!=="").join(`
6
- `)}async function le(e,n,r){let t=n.lastGood?{lastGood:n.lastGood}:{},o=I(L(n.app.schema,n.sight)),i;try{i=await n.complete(Ce(e,o,r))}catch{return{failed:"Couldn't draw that: the model did not answer.",...t}}let s=Y(i);if(typeof s!="object"||s===null||Array.isArray(s))return{failed:"Couldn't draw that: the model's answer was not a view.",...t};let a=s;if(typeof a.failed=="string")return{failed:`Couldn't draw that: ${a.failed.replace(/^Couldn't draw that:\s*/i,"").replace(/\.$/,"")}.`,...t};let l=de(a);if(!P(l.name))return{failed:`Couldn't draw that: "${l.name}" is not a picture the seat can draw.`,...t};let d=l.title?l.title.slice(0,80):r?.title??k(e.trim()).slice(0,80),c={...l,title:r&&r.title===d?d:C(d,n.app)},u=T(n.app,c,n.sight);return u.ok?{...W(n.app,c,u.drawn,n.sight,"model"),asks:[e]}:{failed:u.failed,...t}}function Qe(e,n,r){let t=[...e.lenses??[]];for(let o of n){let i={name:o.lens,title:o.title,on:o.on,...o.bindings?{bindings:o.bindings}:{},...o.options?{options:o.options}:{}};if(t.some(a=>a.title===i.title))continue;T({...e,lenses:t},i,r).ok&&(t=[...t,i])}return t.length===(e.lenses??[]).length?e:{...e,lenses:t}}async function Ze(e,n,r){let{app:t,drafts:o}=r,i=ue(t,r.principal),s=c=>{let u=de(c);return{lens:u,verdict:T(t,u,i)}};if(e==="keep_lens"){let{lens:c,verdict:u}=s(n);if(!u.ok)return{ok:!1,error:u.failed,reason:"invalid"};if(!o?.keep)return{ok:!1,error:"This app's declaration cannot be written from here."};let p=K(c),g=await o.keep(p);return g.ok?{ok:!0,data:{kept:p,said:g.said??`Adds \u201C${p.title}\u201D to the places.`,undo:xe(p)}}:{ok:!1,error:g.error}}if(n.lens!==void 0){let{lens:c,verdict:u}=s(n.lens);return u.ok?{ok:!0,data:te(W(t,c,u.drawn,i,"model"))}:{ok:!1,error:u.failed,reason:"invalid"}}let a={app:t,sight:i,...o?.complete?{complete:o.complete}:{}},l=String(n.ask??""),d;if(n.current!==void 0){let{lens:c,verdict:u}=s(n.current);if(!u.ok)return{ok:!1,error:u.failed,reason:"invalid"};d=await je(W(t,c,u.drawn,i,"model"),l,a)}else d=await Oe(l,a);return O(d)?{ok:!1,error:d.failed,reason:"invalid"}:{ok:!0,data:te(d)}}export{O as a,ue as b,T as c,K as d,xe as e,de as f,ve as g,W as h,te as i,Ye as j,Ie as k,Oe as l,je as m,Qe as n,Ze as o};
@@ -1 +0,0 @@
1
- import{a,b}from"./chunk.VDVJCLGS.js";import"./chunk.R2AG4NHQ.js";import"./chunk.XSNAG4JT.js";import"./chunk.XWAMQPUM.js";import"./chunk.SDO3U72B.js";import"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import"./chunk.AJZBJBMO.js";export{a as ActivityFilter,b as InteractionRow};
@@ -1 +0,0 @@
1
- import{a as ee,b as H,c as ne}from"./chunk.S5MQVPLF.js";import{A as _,C as U,E as J,I as Q,K as X,N as Y,a as O,i as D,l as G,p as q,s as z,t as W,x as j,y as Z}from"./chunk.XSNAG4JT.js";import{Ea as K,G as ae,R as M,_ as N,aa as T,pa as I,xa as $}from"./chunk.XWAMQPUM.js";import{jc as C}from"./chunk.AS4CQBOQ.js";import{b as F}from"./chunk.AJZBJBMO.js";var o=F(ae(),1);var u=F(M(),1),fe=e=>typeof e=="object"?e:{};function he({rootRef:e,firstLook:r,app:n}){let t=(0,o.useCallback)(()=>e.current,[e]);return r?(0,u.jsx)(Y,{firstLook:r,root:t,app:n}):null}function ge(e,r,n){let{app:t}=e,a=(0,o.useMemo)(()=>{let s=Q(r(t.schema,t.viewSpecs),t),d=n?se(s,n):s,i=e.views?e.views(t.schema,d):s,c=i===d?s:I(s,i);return X(c,t.schema,U(e.brand??t.brand,t.schema)),n?n.register(c):c},[e.views,t.schema,t.viewSpecs,t.lenses,t.pages,t.home,n]);return $(a,e.keptViews)}function se(e,r){let n={...e,register(t,a,s,d){return d?.name!==r.name&&e.register(t,a,s,d),n},...e.home?{home:t=>(r.home||e.home(t),n)}:{}};return n}var k=e=>e?e.getBoundingClientRect().height:0;function be(e,r,n){let t=(0,o.useRef)(n);t.current=n;let a=n!==void 0;(0,o.useLayoutEffect)(()=>{let s=e.current;if(!s||!a)return;let d=()=>{let m=[...s.children],h=m.find(b=>b.hasAttribute("data-graview-app-bar")),p=m.find(b=>b.hasAttribute("data-embed-content")),g=p?.querySelector("[data-embed-measure]")??null,l=m.find(b=>b.hasAttribute("data-graview-place-line"));return{strip:h,line:l,content:p,measure:g}},i=-1,c=()=>{let{strip:m,line:h,content:p,measure:g}=d(),l=Math.ceil(k(m)+k(h)+k(g||p));l!==i&&(i=l,t.current?.(l))};if(c(),typeof ResizeObserver>"u")return;let y=new ResizeObserver(c),R=()=>{y.disconnect();let{strip:m,line:h,content:p,measure:g}=d();for(let l of[s,m,h,p,g])l&&y.observe(l)};R();let w=new MutationObserver(()=>{R(),c()});return w.observe(s,{childList:!0}),()=>{y.disconnect(),w.disconnect()}},[e,r,a])}var we=480,ie=0;function Se(e){let{app:r,seed:n,scheme:t="auto",brand:a=r.brand,fonts:s=!0,height:d="100%",label:i}=e,c=(0,o.useRef)(null);K(c);let y=d==="viewport"?"100dvh":d,R=G(typeof y=="string"&&/vh\b/.test(y)),w=(0,o.useMemo)(()=>`graview-embed-${++ie}`,[]),m=(0,o.useMemo)(()=>e.store??e.remote?.store??H(r,n),[e.store,e.remote,r,n]),h=e.presence??e.remote?.presence,p=e.hostContext?.theme,g=ne(t==="auto"&&p===void 0,a?.scheme),l=t==="auto"?p??g:t,b=(0,o.useMemo)(()=>O(l,a,{scope:`.${w}`}),[l,a,w]);D(e.favicon?C(a):void 0),(0,o.useEffect)(()=>{if(!s||typeof document>"u")return;let v=ee(a);if(!v||document.querySelector(`link[href="${v}"]`))return;let f=document.createElement("link");f.rel="stylesheet",f.href=v,document.head.appendChild(f)},[a,s]);let A=(0,o.useRef)(void 0);(0,o.useLayoutEffect)(()=>{let v=c.current,f=A.current;if(A.current=i,!v||!i)return;let oe=S=>{let E=S.getAttribute("aria-label")??"",x=f&&f!==i?E.startsWith(`${f} \xB7 `)?E.slice(f.length+3):E===f?"":E:E;x===i&&(S.getAttribute("role")==="region"||S.tagName==="SECTION"&&!S.hasAttribute("role"))&&S.setAttribute("role","group");let P=x.startsWith(`${i} \xB7 `)||x===i?x:x?`${i} \xB7 ${x}`:i;P!==E&&S.setAttribute("aria-label",P)},B=()=>v.querySelectorAll("aside, nav, main, header, footer, section[aria-label]:not([role]), [role=region], [role=complementary], [role=navigation], [role=search]").forEach(S=>{S.hasAttribute("data-graview-named-by-lens")||oe(S)});B();let V=new MutationObserver(B);return V.observe(v,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["aria-label"]}),()=>V.disconnect()},[i]);let re=R?`${y}`.replace(/([\d.]+)[sdl]?vh\b/g,(v,f)=>`${+f*R/100}px`):y;return{rootRef:c,scope:w,css:b,scheme:l,store:m,presence:h,brand:a,auto:d==="auto",height:re}}function ve({rootRef:e,board:r}){let n=(0,o.useCallback)(()=>e.current?.querySelector("[data-embed-content]")??e.current,[e]);return(0,u.jsx)(q,{board:r,anchor:n})}function Re(e,r,n){return{brand:n,locale:e.locale,timeZone:e.timeZone,principal:e.principal,seats:e.seats,presence:r,people:e.people,memory:e.memory,presenceTtlMs:e.presenceTtlMs,onKeepLens:e.onKeepLens,ai:e.ai,files:e.files,resolveApp:e.resolveApp,history:e.history,linkedRecords:e.linkedRecords,subscriptions:e.subscriptions,keptViews:e.keptViews,signIn:e.signIn,menuSections:e.menuSections,app:e.app}}function Ee({name:e,heading:r,faces:n,at:t,without:a,home:s,reach:d,standing:i,hostActions:c,keeping:y,onFind:R,switch:w,named:m=!0}){let{brand:h,store:p,principal:g,views:l}=N();T();let b=a?.has("places")?[]:z({store:p,principal:g,views:l}),A=_();return(0,u.jsx)(j,{brand:h,name:e,named:m,description:h?.subtitle,heading:r,faces:n,home:s,places:b,current:t===null?null:W(b,t),reach:d,onFind:R,...w?{switch:w}:{},...n||t===null?{scenePlaces:A}:{},tools:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(J,{clean:i}),(0,u.jsx)(Z,{...c?{hostActions:c}:{},...y?{keeping:y}:{}})]})})}var xe=e=>e===!1?2:Math.min(e+1,6);function Ae(e){let[r,n]=(0,o.useState)(e),t=(0,o.useRef)(void 0),a=(0,o.useRef)(void 0),s=(0,o.useMemo)(()=>({go:t,at:n,pending:a}),[]),d=(0,o.useCallback)(i=>{if(t.current){t.current(i);return}a.current=i,n(i)},[]);return{at:r,setAt:n,steering:s,steer:d}}function de(e){let r=typeof e=="object"&&e!==null?e.name:void 0;return{name:typeof r=="string"&&r.length>0?r:typeof e=="object"?"Error":typeof e}}var L=()=>typeof performance<"u"?performance.now():Date.now();function ke(e,r){let n=(0,o.useRef)({onError:e,face:r});return n.current={onError:e,face:r},(0,o.useCallback)((t,a)=>n.current.onError?.(de(t),{module:a.module,face:n.current.face}),[])}function Fe(e,r){let n=(0,o.useRef)(null);n.current===null&&(n.current=L());let t=(0,o.useRef)({onReady:e,face:r});t.current={onReady:e,face:r};let a=(0,o.useRef)(!1);return(0,o.useCallback)(s=>{a.current||(a.current=!0,t.current.onReady?.({ms:Math.max(0,L()-(n.current??L())),face:s}))},[])}var te=class extends o.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(r,n){console.error(`[graview] ${this.props.module} threw while rendering`,r,n.componentStack),this.props.report(r,{module:this.props.module})}render(){return this.state.failed?(0,u.jsxs)("div",{role:"alert","data-graview-face-error":this.props.module,...this.props.content?{"data-embed-content":""}:{},style:this.props.content?{flex:"1 1 auto",display:"grid",alignContent:"center",justifyItems:"center",gap:8,padding:24,background:"var(--graview-ground)",color:"var(--graview-ink)",fontSize:"0.9375rem"}:{display:"inline-flex",alignItems:"center",gap:6,fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:[(0,u.jsx)("span",{children:this.props.content?"This part of the app could not draw.":"Could not draw."}),(0,u.jsx)("button",{type:"button",onClick:()=>this.setState({failed:!1}),style:{padding:"3px 11px",fontSize:"0.8125rem"},children:"Try again"})]}):this.props.children}};export{fe as a,he as b,ge as c,be as d,we as e,Se as f,ve as g,Re as h,Ee as i,xe as j,Ae as k,ke as l,Fe as m,te as n};
@@ -1 +0,0 @@
1
- import{k as a,l as o}from"./chunk.HZCA3UWJ.js";import"./chunk.JBW3DI7E.js";import"./chunk.AGIO2GRV.js";import"./chunk.NIVTK2W5.js";import"./chunk.OHSJQYJN.js";import"./chunk.DEUTHHGI.js";import"./chunk.EPUBSKKL.js";import"./chunk.ATDU5Y7V.js";import"./chunk.AQQZY6OY.js";import"./chunk.Y5ARSVH4.js";import"./chunk.PKUDIWIF.js";import"./chunk.VW2VCPJX.js";import"./chunk.WVUJXDXZ.js";import"./chunk.ZIEHF67C.js";import"./chunk.UHX4WTM7.js";import"./chunk.IKX4VDTW.js";import"./chunk.RNEJYIQ7.js";import"./chunk.TBQOSI4J.js";import"./chunk.KWQ7QOHD.js";import"./chunk.GZHZLJBF.js";import"./chunk.6MADC6DM.js";import"./chunk.OJGHDWI6.js";import"./chunk.JLEC3USG.js";import"./chunk.HDRD33II.js";import"./chunk.DX357TZ3.js";import"./chunk.H7KCWCB4.js";import"./chunk.XSNAG4JT.js";import{oa as n}from"./chunk.XWAMQPUM.js";import"./chunk.SDO3U72B.js";import"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import"./chunk.AJZBJBMO.js";var w=new WeakMap;function s(e,i){let t=w.get(e);t||w.set(e,t=new Map);let r=t.get(i);return r||t.set(i,r=a(o(e,n(e)),e,i)),r}export{s as frameworkViews};
@@ -1,6 +0,0 @@
1
- import{a as A,b as D,c as T,d as L,e as C,f as S,h as N}from"./chunk.BRDAO2OF.js";import"./chunk.AJZBJBMO.js";var V=0,$=1,z=2,K=3,j=1,W=2,I=3,X=1,Y=3,J=8,_="~",x=r=>typeof r=="object"&&r!==null&&!Array.isArray(r),M=new Set(["input","select","textarea","option"]),q=new Set(["value","checked","selected"]);function F(r,n){let d=r.ownerDocument??r,g=n.maxNodes??5e3,m=[],p=new Map,k=new WeakMap,E={dom:r,name:"div",namespace:"html",children:[],id:_};p.set(_,E);let O=0,R=!1,l=e=>{m.push(e),m.length>200&&m.shift(),n.onRefused?.(e)},o=()=>({dom:d.createComment(""),children:[],refused:!0}),i=(e,a)=>{if(e.namespace==="html"&&e.name&&M.has(e.name))return e.dom;if(a?.namespace==="html"&&a.name==="textarea")return a.dom},v=(e,a,f)=>{let s=e.dom;if(f!=null&&typeof f!="string")return l({reason:"value",element:e.name,name:a});let t=N(e.namespace,e.name,a,f??null,n);if("refused"in t){let h=N(e.namespace,e.name,a,null,n);return"refused"in h||s.removeAttribute(h.name),l(t.refused)}for(let h of t.dropped??[])l(h);let c=e.namespace==="html"&&q.has(t.name)&&M.has(e.name),u=s,y=c?t.name==="value"?u.value:t.name==="checked"?u.checked:u.selected:void 0;t.value===null?s.removeAttribute(t.name):s.setAttribute(t.name,t.value),n.onAttribute?.(s,t.name),c&&(t.name==="value"&&"value"in u?(u.value=t.value??"",y!==u.value&&n.onFieldSet?.(s)):t.name==="checked"&&"checked"in u?(u.checked=t.value!==null,y!==u.checked&&n.onFieldSet?.(s)):t.name==="selected"&&"selected"in u&&(u.selected=t.value!==null,y!==u.selected&&n.onFieldSet?.(s.parentElement?.closest("select")??s)))},b=e=>{if(!e.refused){O-=1,e.id!==void 0&&p.delete(e.id);for(let a of e.children)b(a)}},w=(e,a)=>{if(!x(e)||typeof e.id!="string"||p.has(e.id))return l({reason:"record"}),o();if(O>=g)return l({reason:"budget"}),R||(R=!0,n.onOverBudget?.()),o();let f=e.id;if(e.type===J)return o();if(e.type===Y){if(S(a.namespace,a.name))return l({reason:"child",element:a.name}),o();let y=d.createTextNode(String(e.data??"").slice(0,A)),h={dom:y,children:[],text:!0,id:f,parent:a};return p.set(f,h),k.set(y,f),O+=1,h}if(e.type!==X)return l({reason:"record"}),o();let s=String(e.element);if(S(a.namespace,a.name))return l({reason:"child",element:s}),o();let t=C(s,a.namespace);if("refused"in t)return l(t.refused),o();let c=d.createElementNS(t.namespace==="svg"?T:D,t.name);t.as&&c.setAttribute("data-graview-as",t.as),t.namespace==="html"&&t.name==="img"&&c.setAttribute("referrerpolicy","no-referrer"),t.namespace==="html"&&t.name==="a"&&(c.setAttribute("target","_blank"),c.setAttribute("rel","noopener noreferrer"),c.setAttribute("referrerpolicy","no-referrer"));let u={dom:c,name:t.name,namespace:t.namespace,children:[],id:f,parent:a};if(p.set(f,u),k.set(c,f),O+=1,x(e.attributes))for(let[y,h]of Object.entries(e.attributes))v(u,y,h);if(n.decorate?.(c,t.name,t.namespace),x(e.properties))for(let y of Object.keys(e.properties))l({reason:"attribute",element:t.name,name:y});if(x(e.eventListeners))for(let y of Object.keys(e.eventListeners))e.eventListeners[y]!=null&&l({reason:"attribute",element:t.name,name:`on${y}`});if(Array.isArray(e.children))for(let y of e.children){let h=w(y,u);u.children.push(h),c.appendChild(h.dom)}return u},G=e=>{if(!Array.isArray(e))return l({reason:"record"});let[a,f]=e,s=typeof f=="string"?p.get(f):void 0;if(!s)return l({reason:"record"});switch(a){case V:{if(s.text)return l({reason:"record"});let t=Number(e[3]),c=Number.isInteger(t)&&t>=0&&t<=s.children.length?t:s.children.length,u=w(e[2],s);s.dom.insertBefore(u.dom,s.children[c]?.dom??null),s.children.splice(c,0,u),s.namespace==="html"&&s.name==="textarea"&&n.onFieldSet?.(s.dom);return}case $:{let t=Number(e[2]),c=s.children[t];if(!c)return l({reason:"record"});s.children.splice(t,1),c.dom.parentNode?.removeChild(c.dom),b(c);return}case z:{if(!s.text)return l({reason:"record"});s.dom.data=String(e[2]??"").slice(0,A);let t=i(s,s.parent);t&&n.onFieldSet?.(t);return}case K:{if(s===E||s.text)return l({reason:"record"});let t=String(e[2]),c=e[4]??j;return c===W?v(s,t,e[3]):l(c===j||c===I?{reason:"attribute",element:s.name,name:c===I?`on${t}`:t}:{reason:"record"})}default:return l({reason:"record"})}};return{apply(e,a){if(!Array.isArray(e))return l({reason:"record"}),!0;for(let f=0;f<e.length;f+=1){if(a&&f%32===0&&a())return!1;G(e[f])}return!0},get refused(){return m},get size(){return O},idOf:e=>k.get(e),elementOf(e){let a=p.get(e);return a&&!a.text&&a!==E?a.dom:void 0},dispose(){for(let e of E.children)b(e);for(E.children.length=0;r.firstChild;)r.removeChild(r.firstChild)}}}var P=["https:","mailto:","tel:"];function H(r){if(!(typeof r!="string"||r.length>2e3||/[\s<>"]/.test(r.trim())||r.trim()!==r))try{let n=new URL(r);return!P.includes(n.protocol)||n.protocol==="https:"&&(n.hostname===""||n.username!==""||n.password!=="")?void 0:n.href}catch{return}}function Q(r){let n=new Set,d=g=>{if(typeof g!="string"||!/^(https|mailto|tel):/i.test(g))return;let m=H(g);m&&n.add(m)};for(let g of[...r?.node?[r.node]:[],...r?.nodes??[]])for(let[m,p]of Object.entries(g))m==="id"||m==="kind"||(Array.isArray(p)?p.forEach(d):d(p));return n}function U(r){return(r??[]).flatMap(n=>{try{let d=new URL(n);return d.protocol==="https:"&&d.hostname!==""&&d.username===""&&d.password===""?[d.origin]:[]}catch{return[]}})}function Z(r,n){let d=H(r);if(d&&(n.handed.has(d)||d.startsWith("https:")&&U(n.origins).includes(new URL(d).origin)))return d}function ee(r,n){let d=r.length>120?`${r.slice(0,119)}\u2026`:r,g="";try{g=new URL(r).protocol}catch{g=""}if(!P.includes(g))return`The link "${d}" was not drawn: a view links only to an https:, mailto: or tel: address.`;let m=U(n);return`The link "${d}" was not drawn: it is no address this view was handed. A view links out only to an address a record it was shown holds (a url field), as the record holds it${m.length>0?`, or an https: address on ${m.join(", ")}`:""}; a record or a place of this app is <a data-record> or <a data-place>.`}var ne=`
2
- :host { display: block; position: relative; contain: layout paint style; isolation: isolate; overflow: clip; min-width: 0; }
3
- [data-graview-view-root] { color: var(--graview-ink, CanvasText); font-family: var(--graview-font-body, system-ui, sans-serif); line-height: 1.45; }
4
- [data-graview-view-root] :is([data-graview-link], [data-graview-press]) { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: rgb(128 128 128 / 0.16); }
5
- [data-graview-view-root] a[href]::after { content: " \u2197" !important; content: " \u2197" / " (opens in a new tab)" !important; }
6
- `,te=new Set(["Enter"," ","Escape","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End"]),B=["click","input","change","keydown"];function le(r,n){let d=r.ownerDocument,g=d.createElement("style");g.setAttribute("data-graview-region",""),g.textContent=ne;let m=d.createElement("style");m.setAttribute("data-graview-view-style","");let p=d.createElement("div");p.setAttribute("data-graview-view-root",""),r.append(g,m,p);let k=F(p,{origin:n.origin,...n.asset?{asset:n.asset}:{},...n.imageOrigins?{imageOrigins:n.imageOrigins}:{},...n.picture?{picture:n.picture}:{},...n.link?{link:n.link}:{},...n.onRefused?{onRefused:n.onRefused}:{},...n.maxNodes!==void 0?{maxNodes:n.maxNodes}:{},...n.onOverBudget?{onOverBudget:n.onOverBudget}:{},decorate:(o,i,v)=>{v==="html"&&i==="button"&&o.setAttribute("type","button"),v==="html"&&(i==="input"||i==="textarea"||i==="select")&&o.setAttribute("autocomplete","off"),n.decorate?.(o,i,v)},...n.onFieldSet?{onFieldSet:n.onFieldSet}:{},...n.onAttribute?{onAttribute:n.onAttribute}:{}}),E=[],O="",R=o=>{for(let i=o.composedPath()[0];i&&i!==p&&i!==r;i=i.parentNode)if(i.nodeType===1&&k.idOf(i)!==void 0)return i},l=o=>{let i=R(o);if(!i||o.type==="keydown"&&!te.has(o.key))return;let v=n.before?.(o,i,p);if(v===!1)return;let b=i,w=i.namespaceURI==="http://www.w3.org/1999/xhtml"&&["input","select","textarea"].includes(i.localName);n.send({type:"dom-event",target:k.idOf(i),event:o.type,...w?{value:String(b.value??"")}:{},...w&&(b.type==="checkbox"||b.type==="radio")?{checked:b.checked}:{},...o.type==="keydown"?{key:o.key}:{},...v??{}})};for(let o of B)r.addEventListener(o,l);return r.addEventListener("toggle",l,!0),{apply:(o,i)=>k.apply(o,i),style(o){let i=L(o);E.length=0;for(let v of i.refused)E.push({reason:"css",name:"stylesheet",css:v}),E.length>200&&E.shift();O=i.css,m.textContent=O},renderer:k,get refused(){return[...k.refused,...E]},get css(){return O},dispose(){for(let o of B)r.removeEventListener(o,l);r.removeEventListener("toggle",l,!0),k.dispose(),r.replaceChildren()}}}export{ne as REGION_CSS,le as createOpenDrawing,Q as handedLinks,Z as judgeLink,ee as linkRefusedWords};
@@ -1 +0,0 @@
1
- import{a as ot}from"./chunk.KSXB4LDF.js";import"./chunk.PKUDIWIF.js";import{e as V,l as ue,m as G,q as st}from"./chunk.VW2VCPJX.js";import{a as ee}from"./chunk.G4JJXA63.js";import"./chunk.WBHM5I3I.js";import{b as nt}from"./chunk.VC3BX2ZF.js";import{d as tt}from"./chunk.WAB7UDHU.js";import"./chunk.IW7YFPGG.js";import"./chunk.Q7RQC3F7.js";import"./chunk.HDRD33II.js";import{d as et}from"./chunk.DX357TZ3.js";import{c as Ze}from"./chunk.H7KCWCB4.js";import{I as ze,V as Je,Xc as Ne,Yc as Xe,ca as Ye,ga as qe,gb as Ve,hb as Qe,ka as Ae,la as F}from"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import"./chunk.AJZBJBMO.js";var At="Nothing by that name here.",$=o=>o.normalize("NFD").replace(/\p{M}+/gu,"").toLowerCase().replace(/[’']/g,"'").replace(/[^\p{L}\p{N}' ]+/gu," ").replace(/\s+/g," ").trim(),Nt=/^(?:(?:can you |could you |please )?(?:go|take me|bring me|head|jump|navigate|switch|get me)(?: back)? to|(?:please )?(?:open|show(?: me)?|bring up|let me see|view)) (.+)$/,St=/^(?:(?:can you |could you |please )?tell me (?:about|of)|what(?: is|'s| are) (?:in |on )?|describe|explain|who(?: is|'s)) (.+)$/,Ot=/^(?:what(?: is|'s| am i looking at| do i see)(?: (?:here|this|on (?:this|the) (?:page|screen)|in view|this place|this page))?|where am i|describe (?:this|here|this place|this page)|tell me about (?:this|here|this place|this page))$/,rt=new Set(["here","this","this place","this page","on this page","on the page","on this screen","in view"]),Ct=/^(?:date|day|when|on|at|the date|the day)$/,jt=/^(?:what(?: is|'s) (?:wrong|broken|the (?:problem|matter|trouble))|what needs (?:fixing|attention|doing)|any (?:problems|issues|trouble)|(?:show(?: me)? |go to |open )?(?:the )?(?:problems|issues|trouble|standing|what's wrong)|is (?:anything|something) (?:wrong|broken)|are there (?:any )?(?:problems|issues))(?: (?:with|about|on|in) (.+))?$/,z=o=>o.replace(/^(?:the|a|an|my|our) /,""),te=new Set(["the","a","an","my","our","all","any","of","that","which","who","are","is","be","what","whats","what's","with","me","show","list","every","there","do","i","have","we","due","for","please","were","was","by","from","in","on"]),ft=864e5,he=o=>Date.UTC(Number(o.slice(0,4)),Number(o.slice(5,7))-1,Number(o.slice(8,10))),xe=o=>new Date(o).toISOString().slice(0,10),C=(o,i)=>xe(he(o)+i*ft),xt=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],Mt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Wt="(monday|tuesday|tues|wednesday|thursday|thurs|friday|saturday|sunday)",it="(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sept|sep|oct|nov|dec)",at="(\\d{1,2})(?:st|nd|rd|th)?",Dt=o=>xt.findIndex(i=>i.startsWith(o.slice(0,3))),dt=o=>Mt.findIndex(i=>o.startsWith(i.toLowerCase()));function Rt(o,i){return Je(o,{year:o.slice(0,4)!==i.slice(0,4)})}function Se(o,i,y){if(o<0||i<1||i>31)return;let f=Number(y.slice(0,4)),c=k=>{let j=Date.UTC(k,o,i);return new Date(j).getUTCMonth()===o?xe(j):void 0},p=c(f);if(p)return he(p)<he(y)-183*ft?c(f+1):p}function Oe(o,i,y){let f=new Date(he(i)).getUTCDay(),c=u=>{let S=(f-y+7)%7,w=C(i,-S+u*7);return{from:w,to:C(w,6)}},p=()=>{let u=`${i.slice(0,8)}01`,S=new Date(Date.UTC(Number(i.slice(0,4)),Number(i.slice(5,7)),1));return{from:u,to:C(xe(S.getTime()),-1)}},k=u=>u?{from:u,to:u,day:Rt(u,i)}:void 0,j=(u,S)=>{let w=Dt(S);return k(u==="this"||u==="next"?C(c(u==="next"?1:0).from,(w-y+7)%7):u==="last"?C(i,-((f-w+6)%7+1)):C(i,(w-f+7)%7))},J=u=>{let S=C(i,f===0?-1:6-f);return{from:C(S,u*7),to:C(S,u*7+1)}},B="\\b(?:(?:due |for |on |by )(?:the )?)?",P=[[/\b(?:overdue|past due|late)\b/,()=>({overdue:!0,to:C(i,-1)})],[/\b(?:due |for |on )?today\b/,()=>({from:i,to:i})],[/\b(?:due |for |on )?tomorrow\b/,()=>k(C(i,1))],[/\b(?:due |for |on )?yesterday\b/,()=>k(C(i,-1))],[/\b(?:due |for |on )?this week\b/,()=>c(0)],[/\b(?:due |for |on )?next week\b/,()=>c(1)],[/\b(?:due |for |on )?(?:last|previous) week\b/,()=>c(-1)],[/\b(?:due |for |on )?next weekend\b/,()=>J(1)],[/\b(?:due |for |on )?(?:this |the )?weekend\b/,()=>J(0)],[/\b(?:due |for |on )?this month\b/,()=>p()],[new RegExp(`${B}(\\d{4}) (\\d{2}) (\\d{2})\\b`),u=>k(Se(Number(u[2])-1,Number(u[3]),`${u[1]}-01-01`))],[new RegExp(`${B}${at} (?:of )?${it}\\b`),u=>k(Se(dt(u[2]),Number(u[1]),i))],[new RegExp(`${B}${it} (?:the )?${at}\\b`),u=>k(Se(dt(u[1]),Number(u[2]),i))],[new RegExp(`${B}(?:(this|next|last|coming) )?${Wt}\\b`),u=>j(u[1],u[2])]];for(let[u,S]of P){let w=o.match(u);if(!w)continue;let N=S(w);if(N)return{ask:{words:w[0],...N},rest:o.replace(w[0]," ").replace(/\s+/g," ").trim()}}}function ht(o,i,y={}){let f=y.principal??{kind:"human"},c=o.seenBy(f),p=c.schema,k=y.today??o.today?.()??ze(),j=y.weekStartsOn??1,J=o.kindsKeptFrom(f),B=o.modules.disabledKinds,P=p.kinds.filter(e=>!J.has(e)&&!B.has(e)),u=new Set(P),S=(y.places??[]).filter(e=>e.kind===null||u.has(e.kind)),w=c.graph,N=$(i).replace(/[?.!]+$/,"").trim();if(N.length===0)return{unresolved:!0};let M=e=>p.tryDefinition(e),H=e=>Ye(M(e.kind),e),I=e=>qe(p,e),se=e=>S.find(t=>t.kind===e&&t.address===Ne(p,e))?.address??Ne(p,e),ge=e=>Xe(p,e.kind,e.id),Me=e=>({to:"record",id:e.id,kind:e.kind,label:H(e),address:ge(e),said:`Went to ${H(e)}.`}),We=e=>{let t=`Went to ${e.title}.`;return e.kind===null?{to:"place",slug:e.slug,title:e.title,address:e.address,...e.slug==="overview"?{face:"scene"}:{},said:t}:e.lens||e.address.startsWith("/places/")?{to:"picture",kind:e.kind,as:e.slug,title:e.title,address:e.address,said:t}:{to:"kind",kind:e.kind,title:e.title,address:e.address,said:t}},De=()=>({unresolved:!0,say:At}),oe=e=>{let t=M(e.kind),s=et(e,t,{limit:3,excerpt:!0}).map(r=>r.alone.startsWith(r.label)?r.alone:`${r.label.toLowerCase()} ${r.alone}`).join(", "),n=c.violations().filter(r=>r.nodeIds.includes(e.id));return[`${H(e)} \u2014 ${Ae(F(t,e.kind))}${s?` (${s})`:""}.`,n.length>0?`Trouble: ${n.map(r=>r.message).join("; ")}.`:""].filter(Boolean).join(" ")},re=e=>{let t=new Set([G(e),G(z(e))]);for(let n of[" page"," view"," lens"," place"," picture"," list"])e.endsWith(n)&&(t.add(G(e.slice(0,-n.length))),t.add(G(z(e.slice(0,-n.length)))));t.delete("");let s=n=>t.has(G(n.title))||t.has(G(z($(n.title))))||t.has(G(n.slug));return S.find(n=>n.kind!==null&&n.address.startsWith("/places/")&&s(n))??S.find(s)},pe=e=>{let t=st(o,e,{principal:f,today:k,limit:6,near:!1,...y.selection?{from:y.selection}:{}}),s=t.hits.filter(r=>r.about==="node"&&u.has(r.kind)&&w.getNode(r.id)!==void 0),n=s.filter(r=>r.why.field==="label"&&r.why.strength==="exact");return n.length===1?{one:w.getNode(n[0].id),picks:s}:n.length>1?{picks:n}:s.length===1&&t.total===1?{one:w.getNode(s[0].id),picks:s}:{picks:s}},Re=e=>{let t=e.map(s=>`${s.label} (${F(M(s.kind),s.kind)})`);return`${e.length===1?"One thing matches":`${e.length} things match`}: ${t.join("; ")}.`},Ee=(e,t)=>{if(rt.has(e))return Le();let s=t?pe(z(e)||e):void 0,n=s?.one&&$(H(s.one))===$(z(e)||e)?void 0:re(e);if(n){let l=We(n);return{about:"place",say:t?`${l.said} ${me(n)}`:l.said,moves:[l],subject:n.slug}}let r=pe(z(e)||e);if(r.one){let l=Me(r.one);return{about:t?"describe":"record",say:t?`${l.said} ${oe(r.one)}`:l.said,moves:[l],subject:r.one.id}}if(r.picks.length>0)return{about:"picks",say:Re(r.picks),moves:[],picks:r.picks};let h=ae(e);if(h)return h;let d=Pe(e);if(d){if(d.rest.split(" ").every(l=>l===""||te.has(l))){let l=I(d.kind),v={to:"kind",kind:d.kind,title:l,address:se(d.kind),said:`Went to the ${l.toLowerCase()}.`};return{about:"kind",say:v.said,moves:[v]}}return{unresolved:!0}}return De()},me=e=>{if(e.kind===null){let h=P.map(l=>({kind:l,count:w.nodesOfKind(l).length})).filter(l=>l.count>0).map(l=>`${l.count} ${(l.count===1?F(M(l.kind),l.kind):I(l.kind)).toLowerCase()}`),d=c.violations().length;return[h.length>0?`It holds ${fe(h)}.`:"It holds nothing yet.",d>0?`${d===1?"One problem":`${d} problems`} to see to.`:""].filter(Boolean).join(" ")}let t=w.nodesOfKind(e.kind).length,s=I(e.kind).toLowerCase(),n=new Set(c.violations().flatMap(h=>h.nodeIds)),r=w.nodesOfKind(e.kind).filter(h=>n.has(h.id)).length;return[e.lens?`It draws the ${s} as ${Ae(e.lens)}${t>0?` \u2014 ${t} of them`:""}.`:`${t===0?"No":t} ${t===1?F(M(e.kind),e.kind):s} ${t===1?"is":"are"} here.`,r>0?`${r} ${r===1?"has":"have"} a problem.`:""].filter(Boolean).join(" ")},Le=()=>{let e=(y.selection??[]).map(s=>w.getNode(s)).find(s=>s!==void 0);if(e)return{about:"here",say:oe(e),moves:[],subject:e.id};let t=S.find(s=>s.slug===y.place)??S.find(s=>s.slug==="home");return t?{about:"here",say:`${t.title}. ${me(t)}`,moves:[],subject:t.slug}:{about:"here",say:me({slug:"home",title:"Home",kind:null,cardinality:"many",address:"/",stop:"#"}),moves:[]}},Pe=e=>{let t=P.flatMap(s=>[I(s),F(M(s),s),s].map(n=>({kind:s,name:$(n)}))).filter(s=>s.name.length>0).sort((s,n)=>n.name.length-s.name.length);for(let{kind:s,name:n}of t)if(!(` ${e} `.indexOf(` ${n} `)<0))return{kind:s,rest:` ${e} `.replace(` ${n} `," ").replace(/\s+/g," ").trim()}},ie=(e,t)=>{let s=V(p,e).filters.filter(d=>d.about==="field"&&d.type==="date");if(s.length===0)return;let n=s.find(d=>t.some(l=>$(d.key)===l||$(d.label)===l));if(n)return n;let r=M(e)?.fieldRoles??{};for(let d of["due","deadline","date","when","start","end"]){let l=r[d],v=l?s.find(x=>x.key===l):void 0;if(v)return v}return s.find(d=>["due","deadline","date","when","on","at"].includes(d.key.toLowerCase()))??(s.length===1?s[0]:void 0)},He=e=>{let t=M(e),s=V(p,e).filters;if(t?.lifecycle)return{conditions:[{key:"is",value:"current"}],holds:d=>ue(be,d,{key:"is",value:"current"})};let r=s.find(d=>d.about==="field"&&d.type==="boolean"&&ne.has($(d.key)));if(r)return{conditions:[{key:r.key,value:"false"}],holds:d=>d[r.key]!==!0};let h=s.find(d=>d.about==="field"&&d.type==="choice"&&(d.options??[]).some(l=>ne.has($(l))));if(h){let d=new Set((h.options??[]).filter(v=>ne.has($(v)))),l=(h.options??[]).filter(v=>!d.has(v));return l.length===1?{conditions:[{key:h.key,value:l[0]}],holds:v=>v[h.key]===l[0]}:"unsayable"}return{conditions:[],holds:()=>!0}},Ie=(e,t)=>{let s=e.words.startsWith("due")||$(t.key)==="due",n=Ct.test($(t.label));if(e.day)return s?`due ${e.day}`:n?`on ${e.day}`:`${t.label.toLowerCase()} on ${e.day}`;let r=e.words.replace(/^(?:due|for|on|by) (?:the )?/,"");return s?`due ${r}`:n?r:`${t.label.toLowerCase()} ${r}`},ye=new Set(c.violations().flatMap(e=>e.nodeIds)),be={schema:p,graph:c.graph,flagged:ye,today:k},ae=e=>{let t=Oe(e,k,j),s=Pe(t?.rest??e),n=s?.kind,r=(s?.rest??t?.rest??e).split(" ").filter(Boolean);if(!n&&t){let g=e.split(" "),m=P.filter(L=>ie(L,g)!==void 0),E=m.filter(L=>{let b=ie(L,g);return g.some(O=>$(b.key)===O||$(b.label)===O)}),U=m.length===1?m:E;if(U.length!==1)return;n=U[0]}if(!n)return;let h=V(p,n).filters,d=[],l=[],v=[],x=[],q=!1,de=[];for(let g=0;g<r.length;g++){let m=r[g],E=g>0&&(r[g-1]==="not"||r[g-1]==="un"),U=h.find(b=>b.about==="field"&&b.type==="choice"&&(b.options??[]).some(O=>$(O)===m));if(U&&!E){let b=(U.options??[]).find(O=>$(O)===m);d.push({key:U.key,value:b}),l.push(b);continue}let L=h.find(b=>b.about==="field"&&b.type==="boolean"&&[$(b.key),$(b.label)].some(O=>O===m||O===m.replace(/^un/,"")));if(L){let b=!E&&!(m.startsWith("un")&&!$(L.key).startsWith("un"));d.push({key:L.key,value:String(b)}),l.push(b?m:`not ${m.replace(/^un/,"")}`);continue}if(Pt.has(m)&&!E){let b=He(n);b==="unsayable"?(q=!0,x.push(O=>!ut(p,O))):(d.push(...b.conditions),x.push(b.holds)),l.push(m);continue}m==="not"||m==="un"||t&&h.some(b=>b.type==="date"&&($(b.key)===m||$(b.label)===m))||de.push(m)}if(r=de,r.some(g=>!te.has(g))||!t&&d.length===0&&x.length===0)return;let T=I(n).toLowerCase(),Q=I(n);if(t){let g=ie(n,e.split(" "));if(!g){let m={to:"kind",kind:n,title:Q,address:se(n),said:`Went to the ${T}.`};return{about:"kind",say:`${ee(Q)} carry no date, so I can't tell which are ${/^(?:due|for|on|overdue|past due|late)\b/.test(t.ask.words)?t.ask.words:`due ${t.ask.words}`}. ${m.said}`,moves:[m]}}if(t.ask.from&&d.push({key:g.key,value:`after:${C(t.ask.from,-1)}`}),t.ask.to&&d.push({key:g.key,value:`before:${C(t.ask.to,1)}`}),t.ask.overdue){let m=He(n);m==="unsayable"?(q=!0,x.push(E=>!ut(p,E))):(d.push(...m.conditions),x.push(m.holds))}t.ask.overdue?l.push("overdue"):v.push(Ie(t.ask,g))}let R=w.nodesOfKind(n).filter(g=>d.every(m=>ue(be,g,m))&&x.every(m=>m(g))),K=[...l,...v].join(" and "),Y=[...l,T,...v].join(" "),W=R.slice(0,6).map(g=>({about:"node",id:g.id,kind:n,label:H(g),why:{field:d[0]?.key??"label",reading:d[0]?.key??"Name",fragment:K,strength:"field"},current:!0,flagged:ye.has(g.id),address:ge(g)})),X=R.length===0?`No ${T} are ${K}.`:`${R.length===1?`One ${F(M(n),n)} is`:`${R.length} ${T} are`} ${K}: ${fe(R.slice(0,6).map(H))}${R.length>6?`, and ${R.length-6} more`:""}.`;if(q)return{about:"kind",say:X,moves:[],picks:W,offer:{draft:Y,label:"Show as a view"}};let Z=d.map(g=>`${g.key}:${g.value}`).join(","),we=`${se(n)}?${new URLSearchParams({filter:Z}).toString()}`,_={to:"kind",kind:n,title:ee(Y),filter:Z,address:we,said:`Went to the ${Y}.`};return{about:"kind",say:`${_.said} ${X}`,moves:[_],picks:W}},Te=e=>M(e)?.figure==="person"?!0:[e,F(M(e),e),I(e)].some(s=>$(s).split(" ").some(n=>Et.has(n))),pt=e=>{let t=[],s=n=>M(n)?.edges??{};for(let[n,r]of Object.entries(s(e)))for(let h of r.to??[])u.has(h)&&t.push({key:n,direction:"out",far:h,words:ct(`${r.description??""} ${n}`)});for(let n of P)for(let[r,h]of Object.entries(s(n)))(h.to??[]).includes(e)&&t.push({key:r,direction:"in",far:n,words:ct(`${h.inverse??""} ${r}`)});return t},mt=e=>{let t=e.match(/^(who|which|what)\b/)?.[1];if(!t)return;let s=Oe(e,k,j);if(!s||s.ask.overdue)return;let n=s.rest.split(" ").filter(Boolean),r=P.flatMap(a=>[I(a),F(M(a),a),a].map(A=>({kind:a,name:$(A)}))).filter(a=>a.name.length>0).sort((a,A)=>A.name.length-a.name.length),h=` ${n.join(" ")} `,d=[];for(let{kind:a,name:A}of r)h.includes(` ${A} `)&&(h=h.replace(` ${A} `," "),d.includes(a)||d.push(a));let l=h.match(/\b(?:is|are|was|were)\b|'s\b/)?.[0],v=h.replace(/'s\b/g," ").split(" ").filter(a=>a.length>0&&!te.has(a)&&!Ce.has(a)),x=t==="who"?d.find(Te):d[0];if(!x&&t!=="who")return;let q=d.find(a=>a!==x),de=v.flatMap(a=>[je(a),...lt.has(je(a))?[...lt]:[]]),T=P.filter(a=>q?a===q:a!==x).flatMap(a=>{let A=ie(a,e.split(" "))??V(p,a).filters.find(D=>D.about==="field"&&D.type==="date");return A?pt(a).filter(D=>(x?D.far===x:Te(D.far))&&D.far!==a).map(D=>({kind:a,field:A,relation:D,said:v.length===0||de.some(ve=>D.words.some(vt=>Lt(vt,ve)))})):[]}).filter(a=>a.said);if(T.length===0)return;let Q=T.filter(a=>n.some(A=>$(a.field.key)===A||$(a.field.label)===A)),R=T.length===1?T[0]:Q.length===1?Q[0]:void 0;if(!R)return;let{kind:K,field:Y,relation:W}=R,X=[...s.ask.from?[{key:Y.key,value:`after:${C(s.ask.from,-1)}`}]:[],...s.ask.to?[{key:Y.key,value:`before:${C(s.ask.to,1)}`}]:[]],Z=w.nodesOfKind(K).filter(a=>X.every(A=>ue(be,a,A))),we=a=>(W.direction==="out"?c.graph.out(a.id,W.key):c.graph.in(a.id,W.key)).filter(A=>A.kind===W.far&&u.has(W.far)),_=[],g=[];for(let a of Z){let A=we(a);A.length===0&&g.push(a);for(let D of A)_.some(ve=>ve.id===D.id)||_.push(D)}let m=Ie(s.ask,Y),E=s.ask.day?`On ${s.ask.day}`:ee(s.ask.words.replace(/^(?:due|for|on|by) (?:the )?/,"")),U=I(K).toLowerCase(),L=X.map(a=>`${a.key}:${a.value}`).join(","),b=`${U} ${m}`,O={to:"kind",kind:K,title:ee(b),filter:L,address:`${se(K)}?${new URLSearchParams({filter:L}).toString()}`,said:`Went to the ${b}.`};if(Z.length===0)return{about:"related",say:`No ${b}. ${O.said}`,moves:[O]};let le=v.join(" "),yt=l==="was"||l==="were",Ge=a=>yt?a===1?"was":"were":a===1?"is":"are",ce=_.map(H),bt=ce.length>8?[...ce.slice(0,8),`${ce.length-8} more`]:ce,kt=_.length===0?`${E}: nobody ${Ge(1)}${le?` ${le}`:""}.`:`${E}: ${fe(bt)}${le?` ${Ge(_.length)} ${le}`:""}.`,$t=t==="who"&&g.length>0?`${fe(g.slice(0,4).map(H))}${g.length>4?` and ${g.length-4} more`:""} ${g.length===1?"has":"have"} nobody.`:"",wt=_.slice(0,8).map(a=>({about:"node",id:a.id,kind:a.kind,label:H(a),why:{field:W.key,reading:Ze(p,W.direction==="out"?K:W.far,W.key,W.direction==="out"?"out":"in"),fragment:m,strength:"field"},current:!0,flagged:ye.has(a.id),address:ge(a)}));return{about:"related",say:[kt,$t,O.said].filter(Boolean).join(" "),moves:[O],picks:wt}},Ke=N.match(jt);if(Ke){let e=Ke[1];if(e&&!rt.has(e)&&!/^(?:it|this|that)$/.test(e)){let n=re(e),r=n?void 0:pe(z(e)||e);if(r?.one){let h=Me(r.one);return{about:"describe",say:`${h.said} ${oe(r.one)}`,moves:[h],subject:r.one.id}}if(!n)return r&&r.picks.length>0?{about:"picks",say:Re(r.picks),moves:[],picks:r.picks}:De()}if(e&&/^(?:it|this|that)$|^(?:here|this place|this page)$/.test(e)){let n=(y.selection??[]).map(r=>w.getNode(r)).find(r=>r!==void 0);if(n)return{about:"describe",say:oe(n),moves:[],subject:n.id}}let t=c.violations();if(t.length===0)return{about:"problems",say:"Nothing is wrong \u2014 every rule holds.",moves:[]};let s={to:"problems",address:"/problems",said:"Went to the problems."};return{about:"problems",say:`${s.said} ${Qe(t)}: ${t.slice(0,4).map(n=>n.message).join("; ")}${t.length>4?"\u2026":"."}`,moves:[s]}}if(Ot.test(N))return Le();let _e=mt(N);if(_e)return _e;let ke=Oe(N,k,j);if(ke&&!re(z(ke.ask.words))&&ke.rest.replace(/'s\b/g,"").split(" ").every(e=>e===""||te.has(e)||Ce.has(e))){let e=ae(N);if(e)return e}if(/^open /.test(N)){let e=ae(N);if(e)return e}let Fe=N.match(Nt)??N.match(/^(?:go|take me|head|get me)(?: back)? (home)$/);if(Fe)return Ee(Fe[1].trim(),!1);let Be=N.match(St);if(Be){let e=Ee(Be[1].trim(),!0);return"unresolved"in e&&e.unresolved&&!/^tell me|^describe/.test(N)?{unresolved:!0}:e}let $e=re(N);if($e){let e=We($e);return{about:"place",say:e.said,moves:[e],subject:$e.slug}}let Ue=ae(N);return Ue||{unresolved:!0}}var Ce=new Set(["who","whom","whose","which","what","whats","what's","who's"]),Et=new Set(["person","people","user","users","member","members","volunteer","volunteers","gardener","gardeners","player","players","staff","worker","workers","employee","employees","owner","owners","assignee","assignees","helper","helpers","student","students","teacher","teachers","customer","customers","client","clients","contact","contacts","author","authors"]),lt=new Set(["work","cover","staff","assign","do","run","schedul","roster","book","duty","serv","help"]);function je(o){let i=o.toLowerCase().replace(/'s$/,"");for(let y of["ing","ed","es","s"])if(i.length>y.length+2&&i.endsWith(y)){let f=i.slice(0,-y.length);return f.length>3&&f[f.length-1]===f[f.length-2]?f.slice(0,-1):f}return i}function ct(o){return o.toLowerCase().split(/[^a-z']+/).filter(i=>i.length>1&&!te.has(i)&&!Ce.has(i)&&!["it","they","them","their","its","this","here","to","at"].includes(i)).map(je)}var Lt=(o,i)=>o===i||o.length>=4&&i.length>=4&&(o.startsWith(i)||i.startsWith(o)),ne=new Set(["done","finished","complete","completed","closed","resolved","agreed","canceled","archived","shipped","delivered"]),Pt=new Set(["open","unfinished","outstanding","pending","remaining","undone","incomplete"]);function ut(o,i){return V(o,i.kind).filters.some(f=>f.about==="field"&&(f.type==="boolean"&&ne.has(f.key.toLowerCase())&&i[f.key]===!0||f.type==="choice"&&typeof i[f.key]=="string"&&ne.has(String(i[f.key]).toLowerCase())))}function fe(o){return o.length<=1?o[0]??"":`${o.slice(0,-1).join(", ")} and ${o[o.length-1]}`}function zt(o,i,y={}){let f=y.scene!==void 0?{...y.pages,scene:y.scene}:y.pages;return[...nt(o,i,f?{pages:f}:{})].map(({first:c,hidden:p,lens:k,...j})=>j)}function gt(o,i){return{...o.principal?{principal:o.principal}:{},...o.places?{places:o.places}:{},...o.selection?{selection:o.selection}:{},...o.place?{place:o.place}:{},...i??o.today?{today:i??o.today}:{},...o.weekStartsOn!==void 0?{weekStartsOn:o.weekStartsOn}:{}}}function Jt(o,i,y,f){let c=ht(o,i,gt(y,f));if(c.unresolved)return c.say?{reply:{say:c.say,proposals:[],grounded:!0}}:{};if(c.about==="picks")return{};let p=c.moves.length>0?{moves:c.moves}:{},k=c.subject?o.graph.getNode(c.subject):void 0;if(c.about==="problems")return{...p,problems:!0};if(k&&(c.about==="describe"||c.about==="here"))return{...p,told:k.id};let j=k?tt(o,ot(Ve(o.violations(),[k.id])).slice(0,3)):[];return{reply:{say:c.say,proposals:j,grounded:!0,...p,...c.picks&&c.picks.length>0?{picks:c.picks}:{},...c.offer?{offer:c.offer}:{}}}}function Yt(o,i,y={}){let f=gt(y),c=[];for(let p of i){let k=typeof p=="string"?p:typeof p=="object"&&p!==null&&typeof p.to=="string"?p.to:void 0;if(!k||k.trim().length===0)continue;let j=ht(o,/^(?:go|take me|open|show)\b/i.test(k.trim())?k:`go to ${k}`,f);if("moves"in j)for(let J of j.moves)c.some(B=>B.address===J.address)||c.push(J)}return c}export{At as NOTHING_BY_THAT_NAME,gt as askContextOf,Jt as goingFrom,Yt as movesFromNames,zt as placesFromViews,ht as resolveAsk};
@@ -1,3 +0,0 @@
1
- var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{G as f,R as u,qa as y}from"./chunk.XWAMQPUM.js";import{b as m}from"./chunk.AJZBJBMO.js";var d=m(f(),1),n=m(u(),1),c=/^\s*(\d{1,6})[.)]\s+(.*)$/s,S=/^\s*[-*•]\s+(.*)$/s;function h(o){let s=[];for(let p of o.replace(/\r\n?/g,`
2
- `).split(/\n[ \t]*\n+/)){let t=null,a=()=>{t&&(t.t==="p"?t.lines.length>0:t.items.length>0)&&s.push(t),t=null};for(let e of p.split(`
3
- `)){let i=c.exec(e),l=i?null:S.exec(e);if(i)t?.t!=="ol"&&(a(),t={t:"ol",start:Number(i[1]),items:[]}),t.items.push(i[2]);else if(l)t?.t!=="ul"&&(a(),t={t:"ul",items:[]}),t.items.push(l[1]);else if(t&&t.t!=="p"&&/^\s+\S/.test(e)){let r=t.items;r[r.length-1]=`${r[r.length-1]} ${e.trim()}`}else e.trim().length>0&&(t?.t!=="p"&&(a(),t={t:"p",lines:[]}),t.lines.push(e.trim()))}a()}return s}function T(o){return/[\r\n]/.test(o)}var k={display:"grid",gap:"0.7em",minWidth:0,overflowWrap:"anywhere"},x={margin:0},g={margin:0,paddingInlineStart:"1.6em",display:"grid",gap:"0.3em"},B=(0,d.lazy)(y(()=>(__graviewPreload(import.meta.url,["./chunk.XSNAG4JT.js","./chunk.XWAMQPUM.js","./chunk.SDO3U72B.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.RZXPBOGT.js"))));function b({text:o,className:s,style:p,markdown:t,headingsFrom:a}){return t?(0,n.jsx)(d.Suspense,{fallback:(0,n.jsx)(b,{text:o,...s?{className:s}:{},...p?{style:p}:{}}),children:(0,n.jsx)(B,{text:o,...s?{className:s}:{},...p?{style:p}:{},...a?{headingsFrom:a}:{}})}):(0,n.jsx)("div",{"data-graview-text-body":"",...s?{className:s}:{},style:{...k,...p},children:h(o).map((e,i)=>e.t==="p"?(0,n.jsx)("p",{style:x,children:e.lines.map((l,r)=>(0,n.jsxs)("span",{children:[r>0?(0,n.jsx)("br",{}):null,l]},r))},i):e.t==="ol"?(0,n.jsx)("ol",{start:e.start,style:g,children:e.items.map((l,r)=>(0,n.jsx)("li",{children:l},r))},i):(0,n.jsx)("ul",{style:g,children:e.items.map((l,r)=>(0,n.jsx)("li",{children:l},r))},i))})}export{T as a,b};