graview 0.1.59 → 0.1.60

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 (166) hide show
  1. package/README.md +4 -2
  2. package/dist/preview/chunk.2K4TT2BV.js +1 -0
  3. package/dist/preview/{chunk.J4HTSXUA.js → chunk.2USDHXB4.js} +1 -1
  4. package/dist/preview/{chunk.LHJWII6C.js → chunk.37TVS7CA.js} +1 -1
  5. package/dist/preview/chunk.3IZ3ABII.js +1 -0
  6. package/dist/preview/{chunk.E22DDEQI.js → chunk.3MOJF7BA.js} +1 -1
  7. package/dist/preview/{chunk.2XTCDFWU.js → chunk.3UOKUF5Z.js} +1 -1
  8. package/dist/preview/{chunk.MOAUE3N2.js → chunk.3V4WP7RY.js} +3 -3
  9. package/dist/preview/{chunk.IZ2ZTNEV.js → chunk.3XGA65Y3.js} +1 -1
  10. package/dist/preview/{chunk.TCPTVTFU.js → chunk.3ZT5WQYL.js} +1 -1
  11. package/dist/preview/{chunk.DWHPZBPZ.js → chunk.4LR64TPU.js} +1 -1
  12. package/dist/preview/{chunk.VNJKGSGZ.js → chunk.4MP72LPR.js} +1 -1
  13. package/dist/preview/{chunk.IPPZEGBX.js → chunk.4TCKEG6I.js} +1 -1
  14. package/dist/preview/{chunk.EZ3CRUBU.js → chunk.5DD62IOW.js} +2 -2
  15. package/dist/preview/{chunk.DGM3Y2FB.js → chunk.5YOLUDVO.js} +1 -1
  16. package/dist/preview/{chunk.VFRURRNI.js → chunk.67U6M7OV.js} +1 -1
  17. package/dist/preview/{chunk.2NJDT47T.js → chunk.6C2MHWSX.js} +1 -1
  18. package/dist/preview/{chunk.CYUMQPMH.js → chunk.6HF6POIX.js} +1 -1
  19. package/dist/preview/{chunk.KOGUYWHG.js → chunk.6WHAWOO7.js} +1 -1
  20. package/dist/preview/{chunk.N4LOI3YA.js → chunk.6ZQAR5ZA.js} +1 -1
  21. package/dist/preview/{chunk.2QESVWUW.js → chunk.7MHCGVGM.js} +1 -1
  22. package/dist/preview/{chunk.VNBEAF62.js → chunk.7N32AVIJ.js} +1 -1
  23. package/dist/preview/{chunk.CIB65YO6.js → chunk.7OPM55I2.js} +1 -1
  24. package/dist/preview/chunk.7TFLRR7D.js +1 -0
  25. package/dist/preview/{chunk.Q6LLURRM.js → chunk.7VKSXGTX.js} +1 -1
  26. package/dist/preview/{chunk.CLR6KAA3.js → chunk.A3ZXDG6V.js} +1 -1
  27. package/dist/preview/{chunk.2FOIJ5ID.js → chunk.A5PDXNY6.js} +1 -1
  28. package/dist/preview/{chunk.6O3YPUW3.js → chunk.AVBTPSQF.js} +1 -1
  29. package/dist/preview/{chunk.ZT3NEAFI.js → chunk.BF6S5UE4.js} +1 -1
  30. package/dist/preview/chunk.BLPYNNR4.js +1 -0
  31. package/dist/preview/{chunk.BDBLGGFJ.js → chunk.BQIHNT7C.js} +1 -1
  32. package/dist/preview/{chunk.B5HLA45D.js → chunk.BRT27WON.js} +1 -1
  33. package/dist/preview/{chunk.DO45KXLM.js → chunk.BXDM3UMN.js} +1 -1
  34. package/dist/preview/chunk.BYKD5RLA.js +1 -0
  35. package/dist/preview/chunk.C7OLSEWK.js +1 -0
  36. package/dist/preview/{chunk.WGTBQHHE.js → chunk.CC5BJH5A.js} +1 -1
  37. package/dist/preview/{chunk.HF5SNUTK.js → chunk.CFKZXLXS.js} +1 -1
  38. package/dist/preview/chunk.CMN6BBAD.js +1 -0
  39. package/dist/preview/{chunk.Z4CJJ4QP.js → chunk.CQT3W2SF.js} +1 -1
  40. package/dist/preview/{chunk.NOLGJFA4.js → chunk.D7YSL3NK.js} +2 -2
  41. package/dist/preview/{chunk.G2TCFWYX.js → chunk.DCHQHKSA.js} +1 -1
  42. package/dist/preview/{chunk.UFTAGUTU.js → chunk.EL5ICOOM.js} +1 -1
  43. package/dist/preview/{chunk.OVSZXILB.js → chunk.ENL2JJ47.js} +1 -1
  44. package/dist/preview/chunk.EQXB7LKI.js +1 -0
  45. package/dist/preview/{chunk.KE6ZRUMP.js → chunk.ERFT54HT.js} +1 -1
  46. package/dist/preview/{chunk.P6CHNBRR.js → chunk.F6V7RWDK.js} +1 -1
  47. package/dist/preview/{chunk.GDUM2UOM.js → chunk.FBJARKDT.js} +1 -1
  48. package/dist/preview/{chunk.QL555VQ2.js → chunk.FC6AF6CC.js} +1 -1
  49. package/dist/preview/{chunk.HVUUJQRE.js → chunk.FFTYMBBT.js} +1 -1
  50. package/dist/preview/chunk.FLUK3UXF.js +1 -0
  51. package/dist/preview/{chunk.UM5H2VVR.js → chunk.FRYBMS3W.js} +1 -1
  52. package/dist/preview/chunk.G3R4BTI7.js +1 -0
  53. package/dist/preview/{chunk.GQHFLOTZ.js → chunk.G4YJPKRG.js} +2 -2
  54. package/dist/preview/{chunk.MHILFBK6.js → chunk.GLWSVSQL.js} +1 -1
  55. package/dist/preview/{chunk.WTUB7W2D.js → chunk.GNBIVVL3.js} +1 -1
  56. package/dist/preview/{chunk.SU6WKQ73.js → chunk.GTKJJYQH.js} +1 -1
  57. package/dist/preview/{chunk.VS25R6R2.js → chunk.H45Q3O4F.js} +1 -1
  58. package/dist/preview/{chunk.6N7LNTB6.js → chunk.HDP3PS7N.js} +1 -1
  59. package/dist/preview/{chunk.QLTHHWBA.js → chunk.HDUO2USQ.js} +1 -1
  60. package/dist/preview/{chunk.2MFXP3FB.js → chunk.HUJ6YTWE.js} +1 -1
  61. package/dist/preview/{chunk.2FP4KEEG.js → chunk.I4XQBQRC.js} +1 -1
  62. package/dist/preview/chunk.IBOKXVWN.js +1 -0
  63. package/dist/preview/{chunk.4T5QIZKB.js → chunk.IGJZ4UH3.js} +2 -2
  64. package/dist/preview/{chunk.4QWTSI7V.js → chunk.IGVASEZU.js} +1 -1
  65. package/dist/preview/{chunk.CZH27V2R.js → chunk.IHBUBZQT.js} +1 -1
  66. package/dist/preview/chunk.IOK4GVJC.js +1 -0
  67. package/dist/preview/{chunk.ZUKYMU6C.js → chunk.JEYQBH33.js} +1 -1
  68. package/dist/preview/{chunk.S6VON4LU.js → chunk.JJGCTGWA.js} +1 -1
  69. package/dist/preview/{chunk.LKE2FBXL.js → chunk.JPONLMU7.js} +1 -1
  70. package/dist/preview/{chunk.Q3Y5EV5A.js → chunk.KBVTLNS5.js} +3 -3
  71. package/dist/preview/{chunk.YMRVKG6W.js → chunk.KDRLUBVF.js} +1 -1
  72. package/dist/preview/{chunk.YGZCESXY.js → chunk.KGW75Z5L.js} +1 -1
  73. package/dist/preview/{chunk.R4YDAJRL.js → chunk.KI37ZEV3.js} +1 -1
  74. package/dist/preview/chunk.L6AWE76F.js +1 -0
  75. package/dist/preview/{chunk.NIFQDN6R.js → chunk.LGEA5257.js} +1 -1
  76. package/dist/preview/{chunk.KKQXGN5U.js → chunk.LLYRFVIN.js} +1 -1
  77. package/dist/preview/{chunk.WEGPDJTB.js → chunk.LQVAABPS.js} +1 -1
  78. package/dist/preview/{chunk.4OMOP77U.js → chunk.LSY256J4.js} +1 -1
  79. package/dist/preview/{chunk.OLW44AP5.js → chunk.LZIBQ3VX.js} +1 -1
  80. package/dist/preview/{chunk.W2VOD6SD.js → chunk.M4UD4ARP.js} +1 -1
  81. package/dist/preview/chunk.MDJWK5W2.js +1 -0
  82. package/dist/preview/{chunk.QT6UV7HN.js → chunk.MJVYWLQQ.js} +1 -1
  83. package/dist/preview/{chunk.NSGQXCH6.js → chunk.MSWWWLEA.js} +1 -1
  84. package/dist/preview/{chunk.XOTES3PI.js → chunk.MVWC3VR3.js} +2 -2
  85. package/dist/preview/{chunk.V6EEDYYW.js → chunk.NC7FXY2H.js} +1 -1
  86. package/dist/preview/{chunk.MRYN42EQ.js → chunk.NGTRL5U4.js} +1 -1
  87. package/dist/preview/{chunk.ZLMI2NHC.js → chunk.NHUQ2N6J.js} +1 -1
  88. package/dist/preview/{chunk.LDYOQCY7.js → chunk.OLFJH4RK.js} +1 -1
  89. package/dist/preview/{chunk.3UTRR5YM.js → chunk.P6RORYOT.js} +1 -1
  90. package/dist/preview/{chunk.T227XQIO.js → chunk.PFSYXD6Q.js} +1 -1
  91. package/dist/preview/chunk.PHJ6WPWH.js +1 -0
  92. package/dist/preview/{chunk.HKINU7VO.js → chunk.PI44XMY2.js} +1 -1
  93. package/dist/preview/{chunk.P3CUCDHO.js → chunk.PNW5K7BW.js} +1 -1
  94. package/dist/preview/{chunk.6VNKGTLF.js → chunk.QBLKTFF4.js} +1 -1
  95. package/dist/preview/{chunk.ATVPAYS6.js → chunk.QDSEVPF3.js} +1 -1
  96. package/dist/preview/chunk.QFUMFQJU.js +1 -0
  97. package/dist/preview/{chunk.JPNBQFJ3.js → chunk.QHDCTAD7.js} +1 -1
  98. package/dist/preview/{chunk.P52UTBNO.js → chunk.QI4SLPQ4.js} +2 -2
  99. package/dist/preview/{chunk.ATSKKTUO.js → chunk.RQOX5YDW.js} +1 -1
  100. package/dist/preview/{chunk.VDGMFX5C.js → chunk.RXYNW5QB.js} +1 -1
  101. package/dist/preview/{chunk.ROHSF4WM.js → chunk.SB2PZKN5.js} +1 -1
  102. package/dist/preview/{chunk.3XIIJHQ6.js → chunk.SRVQJZRT.js} +1 -1
  103. package/dist/preview/{chunk.BPC4XQFZ.js → chunk.T7LQD67N.js} +2 -2
  104. package/dist/preview/{chunk.D3AISGQH.js → chunk.TAT2IQUR.js} +1 -1
  105. package/dist/preview/{chunk.E2REVMAG.js → chunk.TFWIG6LL.js} +1 -1
  106. package/dist/preview/{chunk.U5PX2ECA.js → chunk.TKVLNBRD.js} +1 -1
  107. package/dist/preview/{chunk.KSVJHSRH.js → chunk.TLJOZSDD.js} +1 -1
  108. package/dist/preview/{chunk.VGHZQEHS.js → chunk.TLWT67ON.js} +1 -1
  109. package/dist/preview/{chunk.AXXYJCSW.js → chunk.TY4GQJKC.js} +1 -1
  110. package/dist/preview/{chunk.SZG6HJWH.js → chunk.UITT6JWW.js} +1 -1
  111. package/dist/preview/{chunk.UHUBQ4EX.js → chunk.UJTE7UAP.js} +1 -1
  112. package/dist/preview/{chunk.GR2B7SKI.js → chunk.ULL6ZIJJ.js} +1 -1
  113. package/dist/preview/{chunk.HJOVOA52.js → chunk.UQWTZJBV.js} +1 -1
  114. package/dist/preview/{chunk.7JOG6XFC.js → chunk.URWAFZHF.js} +1 -1
  115. package/dist/preview/{chunk.BFN6B4C4.js → chunk.VADQ7ZGA.js} +1 -1
  116. package/dist/preview/chunk.VDMDPZ6U.js +1 -0
  117. package/dist/preview/{chunk.ZFH4SCCF.js → chunk.VFOON3Z3.js} +1 -1
  118. package/dist/preview/{chunk.QXMQUIQZ.js → chunk.VMV464JK.js} +1 -1
  119. package/dist/preview/{chunk.CUJX3IVA.js → chunk.VNDKKTED.js} +1 -1
  120. package/dist/preview/chunk.VSCIXAHN.js +5 -0
  121. package/dist/preview/{chunk.IIESMHXY.js → chunk.VUBNBTJP.js} +2 -2
  122. package/dist/preview/{chunk.MZJ3KTEU.js → chunk.VWJGQDCE.js} +1 -1
  123. package/dist/preview/{chunk.UITZ74YJ.js → chunk.VZJWJ5XM.js} +1 -1
  124. package/dist/preview/{chunk.RKZ4J3H2.js → chunk.W3W54DSX.js} +1 -1
  125. package/dist/preview/{chunk.6IUEGPCZ.js → chunk.WC3DENU4.js} +2 -2
  126. package/dist/preview/chunk.WQ6RCEUQ.js +1 -0
  127. package/dist/preview/{chunk.QC4YXFF7.js → chunk.WXUFATY5.js} +1 -1
  128. package/dist/preview/{chunk.QHU3KUZZ.js → chunk.X6A4VSSD.js} +1 -1
  129. package/dist/preview/{chunk.U7G56KXT.js → chunk.XGASJAV2.js} +1 -1
  130. package/dist/preview/{chunk.M3JIIF32.js → chunk.XR6YR6RV.js} +1 -1
  131. package/dist/preview/chunk.XZPKBHJT.js +1 -0
  132. package/dist/preview/{chunk.S7ZLGODY.js → chunk.Y5C4RXG7.js} +1 -1
  133. package/dist/preview/{chunk.L3K25NCS.js → chunk.Y7G3OGDE.js} +1 -1
  134. package/dist/preview/{chunk.E4SYOBGB.js → chunk.YEBGI6ED.js} +1 -1
  135. package/dist/preview/{chunk.G7HIAUEA.js → chunk.YFSBVZTG.js} +1 -1
  136. package/dist/preview/chunk.YFVJUHAK.js +1 -0
  137. package/dist/preview/{chunk.7XSDXX5Z.js → chunk.YH63KQ2G.js} +1 -1
  138. package/dist/preview/{chunk.F6P3WSMW.js → chunk.YZ7FUKAL.js} +1 -1
  139. package/dist/preview/{chunk.7AMBLGVB.js → chunk.Z2ERZ4S6.js} +1 -1
  140. package/dist/preview/{chunk.X2G4ZRB2.js → chunk.ZP5RT2EK.js} +1 -1
  141. package/dist/preview/{chunk.PS5SEND3.js → chunk.ZXOT3IXJ.js} +1 -1
  142. package/dist/preview/{chunk.EGJUFZD5.js → chunk.ZYM2SSGW.js} +1 -1
  143. package/dist/preview/index.html +50 -50
  144. package/dist/preview/page.js +2 -2
  145. package/package.json +6 -6
  146. package/dist/preview/chunk.3XLOFZRM.js +0 -1
  147. package/dist/preview/chunk.6BLNFVB4.js +0 -1
  148. package/dist/preview/chunk.6E36I2GC.js +0 -1
  149. package/dist/preview/chunk.CJUIJ6TL.js +0 -1
  150. package/dist/preview/chunk.FJTVY6AE.js +0 -1
  151. package/dist/preview/chunk.KHZA5F7A.js +0 -1
  152. package/dist/preview/chunk.LDLTQNJ2.js +0 -1
  153. package/dist/preview/chunk.MMWLLWFS.js +0 -1
  154. package/dist/preview/chunk.PCVPH5KM.js +0 -1
  155. package/dist/preview/chunk.QDZAITMN.js +0 -1
  156. package/dist/preview/chunk.U37WZMUO.js +0 -1
  157. package/dist/preview/chunk.U5JFW2YM.js +0 -1
  158. package/dist/preview/chunk.V5MOMBZG.js +0 -1
  159. package/dist/preview/chunk.VUSJ7HPC.js +0 -1
  160. package/dist/preview/chunk.VXRECLX6.js +0 -1
  161. package/dist/preview/chunk.W66VMALY.js +0 -1
  162. package/dist/preview/chunk.WGVIJDV5.js +0 -1
  163. package/dist/preview/chunk.X3MMJ3QC.js +0 -5
  164. package/dist/preview/chunk.X5YRNNHU.js +0 -1
  165. package/dist/preview/chunk.YMC2T2HN.js +0 -1
  166. package/dist/preview/chunk.YN6BXZHO.js +0 -1
@@ -1 +1 @@
1
- import"./chunk.WVUJXDXZ.js";import{b as C}from"./chunk.Q6LLURRM.js";import"./chunk.AXXYJCSW.js";import"./chunk.N4LOI3YA.js";import"./chunk.RKZ4J3H2.js";import"./chunk.HKINU7VO.js";import"./chunk.YGZCESXY.js";import"./chunk.2FOIJ5ID.js";import{ra as $,ta as E,ua as b,va as k}from"./chunk.X3MMJ3QC.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";function M(r,l,t){let p=r.getAttribute("data-record")??"",g=r.getAttribute("data-field")??"",e=Number(r.getAttribute("data-index")??"0"),c=[...l?.node?[l.node]:[],...l?.nodes??[]].find(a=>a.id===p);if(!p||!c)return{why:p?`names a record it was not shown ("${p.slice(0,80)}")`:"names no record (data-record)"};let s=g&&Object.hasOwn(c,g)?c[g]:void 0,o=(Array.isArray(s)?s:[s]).filter($),u=Number.isInteger(e)&&e>=0?o[e]:void 0,n=c.label?`"${c.label}"`:"a record";return g?u?(t==="video"?!b(u):!b(u)&&!E(u))?{why:`names "${u.name}" on ${n}, which is not ${t==="video"?"a video":"a picture or a video"}`}:{file:u,on:c}:{why:o.length===0?`names "${g}" on ${n}, which holds no file it was shown`:`names file ${r.getAttribute("data-index")} of "${g}" on ${n}, which holds ${o.length}`}:{why:`names no field of ${n} (data-field)`}}var A=r=>`${r.caption?.trim()||r.name}, ${k(r)}`;function T(r,l,t,p,g){let e=r.createElement("video");e.setAttribute("data-graview-video",""),e.setAttribute("controls",""),e.setAttribute("preload","metadata"),e.setAttribute("playsinline",""),e.setAttribute("aria-label",A(t));let c=t.poster?p(t.poster):void 0;c&&e.setAttribute("poster",c),t.width&&t.height?(e.setAttribute("width",String(t.width)),e.setAttribute("height",String(t.height)),e.style.aspectRatio=`${t.width} / ${t.height}`):e.style.aspectRatio="16 / 9",e.style.cssText+=";display:block;width:100%;height:auto;max-height:80vh;background:#000;border-radius:var(--graview-radius, 8px)";let s=t.captions?p(t.captions):void 0;if(s){let o=r.createElement("track");o.setAttribute("kind","captions"),o.setAttribute("src",s),o.setAttribute("srclang","en"),o.setAttribute("label","Captions"),o.setAttribute("default",""),e.appendChild(o)}return t.duration===void 0&&e.addEventListener("loadedmetadata",()=>Number.isFinite(e.duration)&&e.duration>0&&e.setAttribute("aria-label",A({...t,duration:e.duration}))),e.setAttribute("src",g),l.appendChild(e),e}function N(r,l){let t=r.document,p=new Set,g=n=>{p.has(n)||(p.add(n),l.onProblem?.(n))},e=n=>{let a=l.file?l.file(n):n;if(a!==void 0)try{let h=new r.URL(a,t.baseURI);return h.origin===r.location.origin&&/^https?:$/.test(h.protocol)?a:void 0}catch{return}},c=new WeakMap,s,o=n=>{if(typeof n.close=="function")return n.close();n.removeAttribute("open"),n.dispatchEvent(new r.Event("close"))},u=(n,a)=>g(`The ${n} in the view ${l.view} was not drawn: it ${a}.`);return{refresh(n){let a=l.shown();for(let h of Array.from(n.querySelectorAll("graview-video"))){let d=h.shadowRoot??h.attachShadow({mode:"open"});if(!l.pictures){c.delete(h),d.replaceChildren(),u("video",`asks for no pictures: a view places a record's video where its manifest says "pictures": true`);continue}let f=M(h,a,"video"),i="file"in f?JSON.stringify(f.file):"";if(c.get(h)===i&&d.childNodes.length>0)continue;if(c.set(h,i),d.replaceChildren(),"why"in f){u("video",f.why);continue}let m=e(f.file.href);if(!m){u("video",`names "${f.file.name}", which this host does not say it serves on this page`);continue}let w=t.createElement("style");w.textContent=":host { display: block; min-width: 0; }",d.appendChild(w),T(t,d,f.file,e,m)}},open(n){if(!l.pictures)return u("full-screen viewer",`asks for no pictures: a view opens a record's picture or video full screen where its manifest says "pictures": true`),!1;let a=M(n,l.shown(),"any");if("why"in a)return u("full-screen viewer",a.why),!1;let h=e(a.file.href);if(!h)return u("full-screen viewer",`names "${a.file.name}", which this host does not say it serves on this page`),!1;s&&o(s);let d=a.file,f=d.caption?.trim()||d.name,i=t.createElement("dialog");i.setAttribute("data-graview-lightbox",""),i.setAttribute("aria-label",b(d)?A(d):f),i.style.cssText="padding:0;border:0;border-radius:var(--graview-radius, 8px);max-width:min(96vw, 1600px);max-height:94vh;background:var(--graview-panel, Canvas);color:var(--graview-ink, CanvasText)";let m=t.createElement("figure");if(m.style.cssText="margin:0;display:grid;gap:8px;padding:10px",b(d))T(t,m,d,e,h);else{let v=t.createElement("img");v.setAttribute("src",h),v.setAttribute("alt",f),v.style.cssText="max-width:100%;max-height:80vh;object-fit:contain;display:block;margin:0 auto",m.appendChild(v)}let w=t.createElement("figcaption");w.style.cssText="display:flex;gap:12px;align-items:center;justify-content:space-between";let x=t.createElement("span");x.textContent=b(d)&&d.duration!==void 0?`${f} \xB7 ${C(d.duration)}`:f;let y=t.createElement("button");return y.type="button",y.textContent="Close",y.addEventListener("click",()=>o(i)),w.append(x,y),m.appendChild(w),i.appendChild(m),i.addEventListener("click",v=>v.target===i&&o(i)),i.addEventListener("close",()=>{i.remove(),s===i&&(s=void 0),n.focus?.()}),t.body.appendChild(i),s=i,typeof i.showModal=="function"?i.showModal():i.setAttribute("open",""),y.focus(),!0},dispose(){s&&o(s),s?.remove(),s=void 0}}}export{N as createGuestMedia,M as namedFile};
1
+ import"./chunk.WVUJXDXZ.js";import{b as C}from"./chunk.7VKSXGTX.js";import"./chunk.TY4GQJKC.js";import"./chunk.6ZQAR5ZA.js";import"./chunk.W3W54DSX.js";import"./chunk.PI44XMY2.js";import"./chunk.KGW75Z5L.js";import"./chunk.A5PDXNY6.js";import{ra as $,ta as E,ua as b,va as k}from"./chunk.VSCIXAHN.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";function M(r,l,t){let p=r.getAttribute("data-record")??"",g=r.getAttribute("data-field")??"",e=Number(r.getAttribute("data-index")??"0"),c=[...l?.node?[l.node]:[],...l?.nodes??[]].find(a=>a.id===p);if(!p||!c)return{why:p?`names a record it was not shown ("${p.slice(0,80)}")`:"names no record (data-record)"};let s=g&&Object.hasOwn(c,g)?c[g]:void 0,o=(Array.isArray(s)?s:[s]).filter($),u=Number.isInteger(e)&&e>=0?o[e]:void 0,n=c.label?`"${c.label}"`:"a record";return g?u?(t==="video"?!b(u):!b(u)&&!E(u))?{why:`names "${u.name}" on ${n}, which is not ${t==="video"?"a video":"a picture or a video"}`}:{file:u,on:c}:{why:o.length===0?`names "${g}" on ${n}, which holds no file it was shown`:`names file ${r.getAttribute("data-index")} of "${g}" on ${n}, which holds ${o.length}`}:{why:`names no field of ${n} (data-field)`}}var A=r=>`${r.caption?.trim()||r.name}, ${k(r)}`;function T(r,l,t,p,g){let e=r.createElement("video");e.setAttribute("data-graview-video",""),e.setAttribute("controls",""),e.setAttribute("preload","metadata"),e.setAttribute("playsinline",""),e.setAttribute("aria-label",A(t));let c=t.poster?p(t.poster):void 0;c&&e.setAttribute("poster",c),t.width&&t.height?(e.setAttribute("width",String(t.width)),e.setAttribute("height",String(t.height)),e.style.aspectRatio=`${t.width} / ${t.height}`):e.style.aspectRatio="16 / 9",e.style.cssText+=";display:block;width:100%;height:auto;max-height:80vh;background:#000;border-radius:var(--graview-radius, 8px)";let s=t.captions?p(t.captions):void 0;if(s){let o=r.createElement("track");o.setAttribute("kind","captions"),o.setAttribute("src",s),o.setAttribute("srclang","en"),o.setAttribute("label","Captions"),o.setAttribute("default",""),e.appendChild(o)}return t.duration===void 0&&e.addEventListener("loadedmetadata",()=>Number.isFinite(e.duration)&&e.duration>0&&e.setAttribute("aria-label",A({...t,duration:e.duration}))),e.setAttribute("src",g),l.appendChild(e),e}function N(r,l){let t=r.document,p=new Set,g=n=>{p.has(n)||(p.add(n),l.onProblem?.(n))},e=n=>{let a=l.file?l.file(n):n;if(a!==void 0)try{let h=new r.URL(a,t.baseURI);return h.origin===r.location.origin&&/^https?:$/.test(h.protocol)?a:void 0}catch{return}},c=new WeakMap,s,o=n=>{if(typeof n.close=="function")return n.close();n.removeAttribute("open"),n.dispatchEvent(new r.Event("close"))},u=(n,a)=>g(`The ${n} in the view ${l.view} was not drawn: it ${a}.`);return{refresh(n){let a=l.shown();for(let h of Array.from(n.querySelectorAll("graview-video"))){let d=h.shadowRoot??h.attachShadow({mode:"open"});if(!l.pictures){c.delete(h),d.replaceChildren(),u("video",`asks for no pictures: a view places a record's video where its manifest says "pictures": true`);continue}let f=M(h,a,"video"),i="file"in f?JSON.stringify(f.file):"";if(c.get(h)===i&&d.childNodes.length>0)continue;if(c.set(h,i),d.replaceChildren(),"why"in f){u("video",f.why);continue}let m=e(f.file.href);if(!m){u("video",`names "${f.file.name}", which this host does not say it serves on this page`);continue}let w=t.createElement("style");w.textContent=":host { display: block; min-width: 0; }",d.appendChild(w),T(t,d,f.file,e,m)}},open(n){if(!l.pictures)return u("full-screen viewer",`asks for no pictures: a view opens a record's picture or video full screen where its manifest says "pictures": true`),!1;let a=M(n,l.shown(),"any");if("why"in a)return u("full-screen viewer",a.why),!1;let h=e(a.file.href);if(!h)return u("full-screen viewer",`names "${a.file.name}", which this host does not say it serves on this page`),!1;s&&o(s);let d=a.file,f=d.caption?.trim()||d.name,i=t.createElement("dialog");i.setAttribute("data-graview-lightbox",""),i.setAttribute("aria-label",b(d)?A(d):f),i.style.cssText="padding:0;border:0;border-radius:var(--graview-radius, 8px);max-width:min(96vw, 1600px);max-height:94vh;background:var(--graview-panel, Canvas);color:var(--graview-ink, CanvasText)";let m=t.createElement("figure");if(m.style.cssText="margin:0;display:grid;gap:8px;padding:10px",b(d))T(t,m,d,e,h);else{let v=t.createElement("img");v.setAttribute("src",h),v.setAttribute("alt",f),v.style.cssText="max-width:100%;max-height:80vh;object-fit:contain;display:block;margin:0 auto",m.appendChild(v)}let w=t.createElement("figcaption");w.style.cssText="display:flex;gap:12px;align-items:center;justify-content:space-between";let x=t.createElement("span");x.textContent=b(d)&&d.duration!==void 0?`${f} \xB7 ${C(d.duration)}`:f;let y=t.createElement("button");return y.type="button",y.textContent="Close",y.addEventListener("click",()=>o(i)),w.append(x,y),m.appendChild(w),i.appendChild(m),i.addEventListener("click",v=>v.target===i&&o(i)),i.addEventListener("close",()=>{i.remove(),s===i&&(s=void 0),n.focus?.()}),t.body.appendChild(i),s=i,typeof i.showModal=="function"?i.showModal():i.setAttribute("open",""),y.focus(),!0},dispose(){s&&o(s),s?.remove(),s=void 0}}}export{N as createGuestMedia,M as namedFile};
@@ -1 +1 @@
1
- import{Ad as $,Bd as c,Dd as k,Ed as x,Md as f,Qd as b,Rd as S,Sd as P,Vd as A,Wd as L,ka as u,xd as w,yd as v}from"./chunk.X3MMJ3QC.js";function T(s){if(!(s.attach==="home"||s.cardinality==="one"||!s.title))return{kind:s.attach,title:s.title,as:$(s.title),name:s.name,lens:"view",...s.hidden?{hidden:!0}:{}}}function H(s,r=[]){let a=[];for(let n of f(s).drawn)for(let i of n.kinds)a.push({kind:i,title:n.title,as:n.as,...n.across?{across:n.across}:{},...n.kinds.length>1?{over:n.kinds}:{},...n.hidden?{hidden:!0}:{}});for(let n of[...s.views?.places?.()??[],...r.flatMap(i=>T(i)??[])])a.some(i=>i.kind===n.kind&&i.as===n.as)||a.push(n);return a}function U(s,r={}){return V(s.schema,H(s,r.views),{...s.pages?{pages:s.pages}:{},lenses:f(s).drawn,home:(s.home?.length??0)>0})}function V(s,r,a={}){let{pages:n}=a,i=s.kinds,d=r.filter(e=>i.includes(e.kind)),o=L(n?.first,s,d),N=new Set(n?.hide??[]),p=A(i,n?.order,d),m=p.flatMap(e=>e.view?[]:[e.kind]),O=p.flatMap(e=>e.view?[e.view]:[]),h=[{slug:"home",title:"Home",kind:null,cardinality:"many",address:"/",stop:"#",...o?.to==="home"||o===void 0&&a.home?{first:!0}:{}},{slug:b,title:P(n),kind:null,cardinality:"many",address:S,stop:"#"}],E=v([...d].sort((e,t)=>m.indexOf(e.kind)-m.indexOf(t.kind))),g=e=>{let t=a.lenses?.find(l=>l.as===e.as&&l.kinds.includes(e.kind)),y=x(e,d);return{slug:e.as,title:e.title,kind:e.kind,...e.over?{over:e.over.filter(l=>i.includes(l))}:{},cardinality:"many",address:k(e.as,y?c(s,e.kind).slice(1):void 0),stop:y?`#focus=aggregate:${e.kind}&in.view=${encodeURIComponent(e.as)}`:`#view=${encodeURIComponent(e.as)}`,...t?{lens:t.lens}:{},...e.name!==void 0?{view:e.name}:{},...e.hidden?{hidden:!0}:{},...o?.to==="place"&&o.place.as===e.as&&(o.place.kind===e.kind||e.over?.includes(o.place.kind))?{first:!0}:{}}};for(let e of E)O.some(t=>w(t,e))||h.push(g(e));for(let e of p){if(e.view){h.push(g(e.view));continue}let t=e.kind;h.push({slug:c(s,t).slice(1),title:u(s,t),kind:t,cardinality:"many",address:c(s,t),stop:`#focus=aggregate:${t}`,...N.has(t)?{hidden:!0}:{},...o?.to==="kind"&&o.kind===t?{first:!0}:{}})}return h}export{U as a,V as b};
1
+ import{Ad as v,Cd as $,Dd as c,Fd as k,Gd as x,Od as f,Sd as b,Td as S,Ud as P,Xd as A,Yd as L,ka as u,zd as w}from"./chunk.VSCIXAHN.js";function T(s){if(!(s.attach==="home"||s.cardinality==="one"||!s.title))return{kind:s.attach,title:s.title,as:$(s.title),name:s.name,lens:"view",...s.hidden?{hidden:!0}:{}}}function H(s,r=[]){let a=[];for(let n of f(s).drawn)for(let i of n.kinds)a.push({kind:i,title:n.title,as:n.as,...n.across?{across:n.across}:{},...n.kinds.length>1?{over:n.kinds}:{},...n.hidden?{hidden:!0}:{}});for(let n of[...s.views?.places?.()??[],...r.flatMap(i=>T(i)??[])])a.some(i=>i.kind===n.kind&&i.as===n.as)||a.push(n);return a}function U(s,r={}){return V(s.schema,H(s,r.views),{...s.pages?{pages:s.pages}:{},lenses:f(s).drawn,home:(s.home?.length??0)>0})}function V(s,r,a={}){let{pages:n}=a,i=s.kinds,d=r.filter(e=>i.includes(e.kind)),o=L(n?.first,s,d),N=new Set(n?.hide??[]),p=A(i,n?.order,d),m=p.flatMap(e=>e.view?[]:[e.kind]),O=p.flatMap(e=>e.view?[e.view]:[]),h=[{slug:"home",title:"Home",kind:null,cardinality:"many",address:"/",stop:"#",...o?.to==="home"||o===void 0&&a.home?{first:!0}:{}},{slug:b,title:P(n),kind:null,cardinality:"many",address:S,stop:"#"}],E=v([...d].sort((e,t)=>m.indexOf(e.kind)-m.indexOf(t.kind))),g=e=>{let t=a.lenses?.find(l=>l.as===e.as&&l.kinds.includes(e.kind)),y=x(e,d);return{slug:e.as,title:e.title,kind:e.kind,...e.over?{over:e.over.filter(l=>i.includes(l))}:{},cardinality:"many",address:k(e.as,y?c(s,e.kind).slice(1):void 0),stop:y?`#focus=aggregate:${e.kind}&in.view=${encodeURIComponent(e.as)}`:`#view=${encodeURIComponent(e.as)}`,...t?{lens:t.lens}:{},...e.name!==void 0?{view:e.name}:{},...e.hidden?{hidden:!0}:{},...o?.to==="place"&&o.place.as===e.as&&(o.place.kind===e.kind||e.over?.includes(o.place.kind))?{first:!0}:{}}};for(let e of E)O.some(t=>w(t,e))||h.push(g(e));for(let e of p){if(e.view){h.push(g(e.view));continue}let t=e.kind;h.push({slug:c(s,t).slice(1),title:u(s,t),kind:t,cardinality:"many",address:c(s,t),stop:`#focus=aggregate:${t}`,...N.has(t)?{hidden:!0}:{},...o?.to==="kind"&&o.kind===t?{first:!0}:{}})}return h}export{U as a,V as b};
@@ -1 +1 @@
1
- import{a as f}from"./chunk.MHILFBK6.js";import{ga as d}from"./chunk.X3MMJ3QC.js";function S(e){let o=e.indexOf("{"),a=e.indexOf("["),t=a!==-1&&(o===-1||a<o)?a:o;if(t===-1)return;let n=e[t],r=n==="["?"]":"}",i=0,u=!1,l=!1;for(let s=t;s<e.length;s++){let c=e[s];if(u){l?l=!1:c==="\\"?l=!0:c==='"'&&(u=!1);continue}if(c==='"')u=!0;else if(c===n)i+=1;else if(c===r&&(i-=1,i===0))try{return JSON.parse(e.slice(t,s+1))}catch{return}}}function w(e,o){let a;try{a=e.mutation(o.mutation)}catch{return o}let t={...o.args},n=!1;for(let r of f(a.input)){if(r.control!=="node")continue;let i=t[r.name];if(typeof i!="string"||i.length===0||e.graph.getNode(i))continue;let u=i.trim().toLowerCase(),l=[...e.graph.allNodes()].filter(s=>(r.kinds.includes("*")||r.kinds.includes(s.kind))&&d(e.schema.tryDefinition(s.kind),s).trim().toLowerCase()===u);l.length===1&&(t[r.name]=l[0].id,n=!0)}return n?{...o,args:t}:o}function x(e,o,a){let t=a===void 0?null:new Set(a),n=[];for(let r of o){if(typeof r.mutation!="string")continue;let i=!0;try{e.mutation(r.mutation)}catch{i=!1}i?t&&!t.has(r.mutation)&&n.push({proposal:r,why:"not-allowed"}):n.push({proposal:r,why:"unknown"})}return n}function v(e,o,a){let t=a===void 0?null:new Set(a);return o.filter(n=>{if(typeof n.mutation!="string"||t&&!t.has(n.mutation))return!1;try{e.mutation(n.mutation)}catch{return!1}return n.args!==null&&typeof n.args=="object"})}export{S as a,w as b,x as c,v as d};
1
+ import{a as f}from"./chunk.GLWSVSQL.js";import{ga as d}from"./chunk.VSCIXAHN.js";function S(e){let o=e.indexOf("{"),a=e.indexOf("["),t=a!==-1&&(o===-1||a<o)?a:o;if(t===-1)return;let n=e[t],r=n==="["?"]":"}",i=0,u=!1,l=!1;for(let s=t;s<e.length;s++){let c=e[s];if(u){l?l=!1:c==="\\"?l=!0:c==='"'&&(u=!1);continue}if(c==='"')u=!0;else if(c===n)i+=1;else if(c===r&&(i-=1,i===0))try{return JSON.parse(e.slice(t,s+1))}catch{return}}}function w(e,o){let a;try{a=e.mutation(o.mutation)}catch{return o}let t={...o.args},n=!1;for(let r of f(a.input)){if(r.control!=="node")continue;let i=t[r.name];if(typeof i!="string"||i.length===0||e.graph.getNode(i))continue;let u=i.trim().toLowerCase(),l=[...e.graph.allNodes()].filter(s=>(r.kinds.includes("*")||r.kinds.includes(s.kind))&&d(e.schema.tryDefinition(s.kind),s).trim().toLowerCase()===u);l.length===1&&(t[r.name]=l[0].id,n=!0)}return n?{...o,args:t}:o}function x(e,o,a){let t=a===void 0?null:new Set(a),n=[];for(let r of o){if(typeof r.mutation!="string")continue;let i=!0;try{e.mutation(r.mutation)}catch{i=!1}i?t&&!t.has(r.mutation)&&n.push({proposal:r,why:"not-allowed"}):n.push({proposal:r,why:"unknown"})}return n}function v(e,o,a){let t=a===void 0?null:new Set(a);return o.filter(n=>{if(typeof n.mutation!="string"||t&&!t.has(n.mutation))return!1;try{e.mutation(n.mutation)}catch{return!1}return n.args!==null&&typeof n.args=="object"})}export{S as a,w as b,x as c,v as d};
@@ -1 +1 @@
1
- import{b as x}from"./chunk.6E36I2GC.js";import"./chunk.CJUIJ6TL.js";import"./chunk.IIESMHXY.js";import"./chunk.WVUJXDXZ.js";import"./chunk.Q6LLURRM.js";import"./chunk.AXXYJCSW.js";import"./chunk.N4LOI3YA.js";import"./chunk.RKZ4J3H2.js";import"./chunk.HKINU7VO.js";import"./chunk.YGZCESXY.js";import"./chunk.GZHZLJBF.js";import{n as R}from"./chunk.KHZA5F7A.js";import"./chunk.OJGHDWI6.js";import"./chunk.KSVJHSRH.js";import"./chunk.NSGQXCH6.js";import"./chunk.SZG6HJWH.js";import"./chunk.2FOIJ5ID.js";import"./chunk.6IUEGPCZ.js";import"./chunk.CUJX3IVA.js";import{G as A,T as v,ca as g}from"./chunk.VNJKGSGZ.js";import"./chunk.SDO3U72B.js";import{Vc as k,ma as y,qa as c}from"./chunk.X3MMJ3QC.js";import"./chunk.FQLNBIQ5.js";import{b as u}from"./chunk.AJZBJBMO.js";var f=u(A(),1);var L=u(A(),1),S=(0,L.createContext)(void 0);var i=u(v(),1),W=new WeakMap,m=new WeakMap,P=(e,n)=>`${n.kind}\0${n.id??""}\0${e}`;function b(e,n,a){let p=P(n,a),o=W.get(e);o||W.set(e,o=new Map);let t=o.get(p);return t||(t=Promise.resolve().then(()=>e(n,a)).then(r=>C(r)?r:null,()=>null).then(r=>{let s=m.get(e);return s||m.set(e,s=new Map),s.set(p,r),r}),o.set(p,t)),t}function C(e){if(e===null)return!0;if(typeof e!="object"||e===void 0)return!1;if(e.denied===!0)return!0;let n=e;return typeof n.name=="string"&&n.name.trim()!==""&&typeof n.href=="string"}function h(e){if(/^https?:\/\//i.test(e))try{return new URL(e).href}catch{return}}var N=e=>h(e)??(c(e)?e:void 0),E=e=>h(e)??(e.startsWith("/")&&c(e)?e:void 0),I={kind:"human"},w={color:"var(--graview-ink-muted)"};function M({icon:e}){if(!e)return null;let n=E(e);if(n)return(0,i.jsx)("img",{src:n,alt:"",width:20,height:20,"data-graview-app-icon":"",style:{width:20,height:20,borderRadius:5,objectFit:"cover",flex:"0 0 auto"}});let a=[...e.trim()].slice(0,2).join("");return a?(0,i.jsx)("span",{"aria-hidden":"true","data-graview-app-icon":"",style:{flex:"0 0 auto",lineHeight:"20px"},children:a}):null}function V(e){let n=g(),a=(0,f.useContext)(S)??n?.resolveApp,p=n?.principal??I,o=()=>a?m.get(a)?.get(P(e,p))??"asking":null,[t,r]=(0,f.useState)(o);return(0,f.useEffect)(()=>{let s=o();if(r(s),s!=="asking"||!a)return;let l=!0;return b(a,e,p).then(d=>l&&r(d)),()=>{l=!1}},[a,e,p.kind,p.id]),t}function D({address:e,as:n="chip",nodeId:a,field:p,style:o}){let t=V(e),r={position:"relative",zIndex:k.raised,overflowWrap:"anywhere",minWidth:0,maxWidth:"100%",...o},s;if(t==="asking")s=(0,i.jsx)("span",{"data-graview-app-link":"","data-graview-app-state":"asking","aria-busy":"true",style:{...w,...r},children:"Linked app"});else if(t&&"denied"in t)s=(0,i.jsx)("span",{"data-graview-app-link":"","data-graview-app-state":"denied",style:{...w,fontStyle:"italic",...r},children:"linked app (no access)"});else if(t){let l=N(t.href),d=n==="record"?t.headline?.trim():void 0;s=(0,i.jsxs)(l?"a":"span",{"data-graview-app-link":"","data-graview-app-state":"found",...l?{href:l}:{},...!d&&t.headline?{title:t.headline}:{},style:{display:"inline-flex",alignItems:d?"flex-start":"center",minHeight:24,gap:8,color:"inherit",textUnderlineOffset:3,...r},children:[(0,i.jsx)(M,{icon:t.icon}),(0,i.jsxs)("span",{style:{display:"grid",minWidth:0},children:[(0,i.jsx)("span",{"data-graview-app-name":"",style:{fontWeight:600},children:t.name}),d?(0,i.jsx)("span",{"data-graview-app-headline":"",style:{...w,fontSize:"0.8125em",fontWeight:400},children:d}):null]})]})}else{let l=h(e);s=l?(0,i.jsx)("a",{"data-graview-app-link":"","data-graview-app-state":"plain",href:l,rel:"noopener noreferrer",target:"_blank",style:{color:"var(--graview-accent)",display:"inline-flex",alignItems:"center",minHeight:24,...r},children:e}):(0,i.jsx)("span",{"data-graview-app-link":"","data-graview-app-state":"plain",style:r,children:e})}return a&&p?(0,i.jsx)(H,{nodeId:a,field:p,address:e,drawn:s}):s}function H({nodeId:e,field:n,address:a,drawn:p}){let o=R(e).fields.some(s=>s.field===n),t=g()?.store;if(!o)return p;let r=y(t?t.schema.tryDefinition(String(t.graph.getNode(e)?.kind)):void 0,n).toLowerCase();return(0,i.jsxs)("span",{style:{display:"inline-flex",flexWrap:"wrap",alignItems:"baseline",gap:"4px 12px",maxWidth:"100%",minWidth:0},children:[p,(0,i.jsx)("span",{style:{fontSize:"0.8125rem"},children:(0,i.jsx)(x,{nodeId:e,field:n,value:"Change",stored:a,said:`Change the ${r}`})})]})}var Y=e=>(0,i.jsx)(D,{...e});export{D as AppLink,Y as drawAppLink};
1
+ import{b as x}from"./chunk.BYKD5RLA.js";import"./chunk.2K4TT2BV.js";import"./chunk.VUBNBTJP.js";import"./chunk.WVUJXDXZ.js";import"./chunk.7VKSXGTX.js";import"./chunk.TY4GQJKC.js";import"./chunk.6ZQAR5ZA.js";import"./chunk.W3W54DSX.js";import"./chunk.PI44XMY2.js";import"./chunk.KGW75Z5L.js";import"./chunk.GZHZLJBF.js";import{n as R}from"./chunk.IOK4GVJC.js";import"./chunk.OJGHDWI6.js";import"./chunk.TLJOZSDD.js";import"./chunk.MSWWWLEA.js";import"./chunk.UITT6JWW.js";import"./chunk.A5PDXNY6.js";import"./chunk.WC3DENU4.js";import"./chunk.VNDKKTED.js";import{G as A,T as v,ca as g}from"./chunk.4MP72LPR.js";import"./chunk.SDO3U72B.js";import{$c as k,ma as y,qa as c}from"./chunk.VSCIXAHN.js";import"./chunk.FQLNBIQ5.js";import{b as u}from"./chunk.AJZBJBMO.js";var f=u(A(),1);var L=u(A(),1),S=(0,L.createContext)(void 0);var i=u(v(),1),W=new WeakMap,m=new WeakMap,P=(e,n)=>`${n.kind}\0${n.id??""}\0${e}`;function b(e,n,a){let p=P(n,a),o=W.get(e);o||W.set(e,o=new Map);let t=o.get(p);return t||(t=Promise.resolve().then(()=>e(n,a)).then(r=>C(r)?r:null,()=>null).then(r=>{let s=m.get(e);return s||m.set(e,s=new Map),s.set(p,r),r}),o.set(p,t)),t}function C(e){if(e===null)return!0;if(typeof e!="object"||e===void 0)return!1;if(e.denied===!0)return!0;let n=e;return typeof n.name=="string"&&n.name.trim()!==""&&typeof n.href=="string"}function h(e){if(/^https?:\/\//i.test(e))try{return new URL(e).href}catch{return}}var N=e=>h(e)??(c(e)?e:void 0),E=e=>h(e)??(e.startsWith("/")&&c(e)?e:void 0),I={kind:"human"},w={color:"var(--graview-ink-muted)"};function M({icon:e}){if(!e)return null;let n=E(e);if(n)return(0,i.jsx)("img",{src:n,alt:"",width:20,height:20,"data-graview-app-icon":"",style:{width:20,height:20,borderRadius:5,objectFit:"cover",flex:"0 0 auto"}});let a=[...e.trim()].slice(0,2).join("");return a?(0,i.jsx)("span",{"aria-hidden":"true","data-graview-app-icon":"",style:{flex:"0 0 auto",lineHeight:"20px"},children:a}):null}function V(e){let n=g(),a=(0,f.useContext)(S)??n?.resolveApp,p=n?.principal??I,o=()=>a?m.get(a)?.get(P(e,p))??"asking":null,[t,r]=(0,f.useState)(o);return(0,f.useEffect)(()=>{let s=o();if(r(s),s!=="asking"||!a)return;let l=!0;return b(a,e,p).then(d=>l&&r(d)),()=>{l=!1}},[a,e,p.kind,p.id]),t}function D({address:e,as:n="chip",nodeId:a,field:p,style:o}){let t=V(e),r={position:"relative",zIndex:k.raised,overflowWrap:"anywhere",minWidth:0,maxWidth:"100%",...o},s;if(t==="asking")s=(0,i.jsx)("span",{"data-graview-app-link":"","data-graview-app-state":"asking","aria-busy":"true",style:{...w,...r},children:"Linked app"});else if(t&&"denied"in t)s=(0,i.jsx)("span",{"data-graview-app-link":"","data-graview-app-state":"denied",style:{...w,fontStyle:"italic",...r},children:"linked app (no access)"});else if(t){let l=N(t.href),d=n==="record"?t.headline?.trim():void 0;s=(0,i.jsxs)(l?"a":"span",{"data-graview-app-link":"","data-graview-app-state":"found",...l?{href:l}:{},...!d&&t.headline?{title:t.headline}:{},style:{display:"inline-flex",alignItems:d?"flex-start":"center",minHeight:24,gap:8,color:"inherit",textUnderlineOffset:3,...r},children:[(0,i.jsx)(M,{icon:t.icon}),(0,i.jsxs)("span",{style:{display:"grid",minWidth:0},children:[(0,i.jsx)("span",{"data-graview-app-name":"",style:{fontWeight:600},children:t.name}),d?(0,i.jsx)("span",{"data-graview-app-headline":"",style:{...w,fontSize:"0.8125em",fontWeight:400},children:d}):null]})]})}else{let l=h(e);s=l?(0,i.jsx)("a",{"data-graview-app-link":"","data-graview-app-state":"plain",href:l,rel:"noopener noreferrer",target:"_blank",style:{color:"var(--graview-accent)",display:"inline-flex",alignItems:"center",minHeight:24,...r},children:e}):(0,i.jsx)("span",{"data-graview-app-link":"","data-graview-app-state":"plain",style:r,children:e})}return a&&p?(0,i.jsx)(H,{nodeId:a,field:p,address:e,drawn:s}):s}function H({nodeId:e,field:n,address:a,drawn:p}){let o=R(e).fields.some(s=>s.field===n),t=g()?.store;if(!o)return p;let r=y(t?t.schema.tryDefinition(String(t.graph.getNode(e)?.kind)):void 0,n).toLowerCase();return(0,i.jsxs)("span",{style:{display:"inline-flex",flexWrap:"wrap",alignItems:"baseline",gap:"4px 12px",maxWidth:"100%",minWidth:0},children:[p,(0,i.jsx)("span",{style:{fontSize:"0.8125rem"},children:(0,i.jsx)(x,{nodeId:e,field:n,value:"Change",stored:a,said:`Change the ${r}`})})]})}var Y=e=>(0,i.jsx)(D,{...e});export{D as AppLink,Y as drawAppLink};
@@ -1 +1 @@
1
- import{a as c,b as d,c as e,d as f,e as g,f as h,g as i,h as j,i as k,j as l,k as m,l as n,m as o,n as p}from"./chunk.WEGPDJTB.js";import{a,b}from"./chunk.MRYN42EQ.js";import"./chunk.E22DDEQI.js";import"./chunk.OLW44AP5.js";import"./chunk.NSGQXCH6.js";import"./chunk.SZG6HJWH.js";import"./chunk.2FOIJ5ID.js";import"./chunk.6IUEGPCZ.js";import"./chunk.CUJX3IVA.js";import"./chunk.VNJKGSGZ.js";import"./chunk.SDO3U72B.js";import"./chunk.X3MMJ3QC.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";export{j as ARRANGE_NARROW,o as ArrangeBar,e as CHIP_FIELDS,d as MANY_AT_THE_FAR_END,c as TYPED_FROM,p as arrangementCaption,a as arrangementOf,i as chipOffers,m as directionWords,g as farCount,f as farCounts,l as inSentence,h as offeredFilters,n as preloadArrangeLists,k as sayCondition,b as withArrangement};
1
+ import{a as c,b as d,c as e,d as f,e as g,f as h,g as i,h as j,i as k,j as l,k as m,l as n,m as o,n as p}from"./chunk.LQVAABPS.js";import{a,b}from"./chunk.NGTRL5U4.js";import"./chunk.3MOJF7BA.js";import"./chunk.LZIBQ3VX.js";import"./chunk.MSWWWLEA.js";import"./chunk.UITT6JWW.js";import"./chunk.A5PDXNY6.js";import"./chunk.WC3DENU4.js";import"./chunk.VNDKKTED.js";import"./chunk.4MP72LPR.js";import"./chunk.SDO3U72B.js";import"./chunk.VSCIXAHN.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";export{j as ARRANGE_NARROW,o as ArrangeBar,e as CHIP_FIELDS,d as MANY_AT_THE_FAR_END,c as TYPED_FROM,p as arrangementCaption,a as arrangementOf,i as chipOffers,m as directionWords,g as farCount,f as farCounts,l as inSentence,h as offeredFilters,n as preloadArrangeLists,k as sayCondition,b as withArrangement};
@@ -1 +1 @@
1
- import{a as O,b,c as w,d as R,e as V}from"./chunk.HKINU7VO.js";import{h as d,i as S}from"./chunk.YGZCESXY.js";import{Ka as $,La as F}from"./chunk.X3MMJ3QC.js";var E=["card","row","page"],j=["good","warn","bad","neutral","accent"],U=["money","percent","date","time","datetime","relative","count"],_=4,T=40,I=120,L=["number","money","percent"],B=["large"],C=["card","row"],M=1e3,ce=100;function X(e){let n=/^\s*(out|in)\(\s*['"]([A-Za-z][A-Za-z0-9_-]*)['"]\s*\)\s*$/.exec(e);return n?{edge:n[2],way:n[1]}:/^[A-Za-z][A-Za-z0-9_-]*$/.test(e)?{edge:e}:void 0}var v={title:[],headline:[],list:["sort","limit","group","empty","as"],text:["tone","lines"],badge:["tone"],field:["as","currency","label"],image:["as","label"],progress:["label"],group:["direction"],when:["show"],divider:[],figure:["as","currency","label","emphasis"]},Z=Object.keys(v),G=`{"title": "{name}"}, {"headline": "{count(all('offer'))} offers"}, {"figure": expr, "as"?: "number"|"money"|"percent", "currency"?, "label"?, "emphasis"?: "large"}, {"list": expr, "sort"?, "limit"?, "group"?, "empty"?, "as"?: "card"|"row"}, {"text": "\u2026", "tone"?, "lines"?: 0-12}, {"badge": "{status}", "tone"?}, {"field": "quote", "as"?, "currency"?, "label"?}, {"image": "photos", "as"?: "thumb"|"gallery"}, {"progress": {"value": expr, "max": expr}, "label"?}, {"group": [blocks], "direction"?: "row"|"column"}, {"when": expr, "show": [blocks]}, {"divider": true}, {"figure": true}`,Y=e=>/^(image|video|file)$/.test(e?.of??e?.type??"");function ge(e){return Object.fromEntries(Object.entries(e.views??{}).filter(([,n])=>!Array.isArray(n)))}function ye(e){let n=e.views?.home;return Array.isArray(n)?n:void 0}var q={field:()=>!1,relation:()=>!1,figure:!1},z=e=>e.kind??"the home",m=(e,n)=>e!==void 0&&Object.hasOwn(e,n),g=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function W(e,n,t){let s=O(e);for(let a of s.unknownFunctions)t.findings.push(d("unknown-function",n,`"${a}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let a of s.names){if(t.kind===null){t.findings.push(d("view-name",n,`"${a}" names nothing here: these blocks are about no one record`,"reach records with all('<kind>'), like count(all('offer')) or first(all('party') where role == 'client').name"));continue}a==="id"||t.spec.field(a)||t.spec.relation(a)||t.findings.push(d("view-name",n,`${t.kind} has no field or relation called "${a}"`))}for(let a of s.edges)t.edges.has(a)||t.findings.push(d("view-edge",n,`"${a}" is not a relation any kind declares`));for(let a of s.sweeps)t.kinds.has(a)||t.findings.push(d("view-kind",n,`"${a}" is not a kind this document declares`))}function k(e,n,t){if(typeof e!="string"||e.length===0||e.length>2e3){t.findings.push(d("view-expression",n,`an expression is a line of the rule language, like "status == 'booked'"`));return}try{W(w(e),n,t)}catch(s){if(!(s instanceof b))throw s;t.findings.push(d("expression",n,`${s.sentence} (at character ${s.at+1})`))}}function A(e,n,t,s,a=!1){let l=s==="text";if(typeof e!="string"||e.length===0||e.length>300){t.findings.push(d("view-template",n,'a template is words with {field} in braces, like "{name}" or "{quote|money}", at most 300 characters'));return}let r;try{r=V(e)}catch(i){if(i instanceof R||i instanceof b){t.findings.push(d("template",n,i.sentence));return}throw i}for(let i of r)if(i.expr){if(W(i.expr,n,t),l&&!a&&!i.format&&i.expr.t==="ident"&&(t.slot==="card"||t.slot==="row")&&t.spec.prose?.(i.expr.name)){let o=i.expr.name;t.findings.push(S("view-whole-text",n,`${t.kind} ${t.slot} shows ${o} whole; it will be clamped. Use {${o}|excerpt} or move it to the page.`,`write {${o}|excerpt}, or {${o}|excerpt: 80} for fewer characters`))}if(s==="headline"&&!i.format&&i.expr.t==="ident"&&t.spec.prose?.(i.expr.name)){let o=i.expr.name;t.findings.push(S("view-headline-long",n,`${z(t)}${t.slot?` ${t.slot}`:""} heads it with ${o}, a long text, drawn at a headline's size; a headline is a few words.`,`say it in a text block, {"text": "{${o}}"}, or head it with {${o}|excerpt: 60}`))}}}var K=12;function J(e,n,t){typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=K||t.findings.push(d("view-lines",n,`lines is ${JSON.stringify(e)}, and a text block's lines is a whole number from 1 to ${K}, or 0 to show it whole`,'{"text": "{awards}", "lines": 6}, or "lines": 0 for no cut at all'))}function Q(e,n,t){if(typeof e=="string"){j.includes(e)||t.findings.push(d("view-tone",n,`"${e}" is not a tone`,`use one of ${j.join(", ")}, or {"expr": "if(status == 'booked', 'good', 'neutral')"}`));return}if(g(e)&&Object.keys(e).length===1&&"expr"in e){k(e.expr,`${n}.expr`,t);return}t.findings.push(d("view-tone",n,'a tone is a word or {"expr": \u2026}',`one of ${j.join(", ")}`))}function x(e,n,t,s){if(!Array.isArray(e)){s.findings.push(d("view-shape",n,"a view is a list of blocks"));return}if(t>_){s.findings.push(d("view-depth",n,`blocks nest at most ${_} deep`,"flatten a group or a condition"));return}e.forEach((a,l)=>ee(a,`${n}.${l}`,t,s))}function ee(e,n,t,s){if(t===1&&s.count++,s.all++,!g(e)){s.findings.push(d("view-block",n,"a block is an object naming what it shows",`one of ${G}`));return}let a=Object.keys(e),l=a.filter(o=>Z.includes(o)&&!(o==="group"&&a.includes("list")));if(l.length===0){s.findings.push(d("view-block",n,`${a.length>0?a.map(o=>`"${o}"`).join(", "):"an empty object"} is not a block Graview knows`,`one of ${G}`));return}if(l.length>1){s.findings.push(d("view-block",n,`a block is one thing, and this says ${l.map(o=>`"${o}"`).join(" and ")}`,"split it into two blocks"));return}let r=l[0];for(let o of a)o!==r&&o!="key"&&!v[r].includes(o)&&s.findings.push(d("unknown-key",`${n}.${o}`,`"${o}" is not part of a ${r} block`,v[r].length>0?`a ${r} block may also say ${v[r].map(f=>`"${f}"`).join(", ")}`:`a ${r} block says nothing else`));let i=e[r];switch(r){case"title":case"headline":case"text":case"badge":A(i,`${n}.${r}`,s,r==="text"||r==="headline"?r:void 0,r==="text"&&"lines"in e),"tone"in e&&Q(e.tone,`${n}.tone`,s),r==="text"&&"lines"in e&&J(e.lines,`${n}.lines`,s);return;case"image":case"field":{let o=r==="image";if(typeof i!="string"||!(o?s.spec.files?.(i):s.spec.field(i))){let u=typeof i=="string"&&s.spec.relation(i);s.findings.push(d(`view-${r}`,`${n}.${r}`,`${s.kind} has no ${o?"image, video or file ":""}field ${typeof i=="string"?`"${i}"`:"by that name"}`,u?`"${i}" is a relation; show it with {"text": "{${i}.name}"}`:void 0))}let f=o?["thumb","gallery"]:U;"as"in e&&!f.includes(e.as)&&s.findings.push(d("view-format",`${n}.as`,`"${String(e.as)}" is not a way to show ${o?"pictures":"a field"}`,`use one of ${f.join(", ")}`)),o||D(e,n,s,"field"),"label"in e&&oe(e.label,`${n}.label`,s);return}case"progress":{!g(i)||Object.keys(i).some(o=>o!=="value"&&o!=="max")||!("value"in i)||!("max"in i)?s.findings.push(d("view-progress",`${n}.progress`,'progress is {"value": expression, "max": expression}')):(k(i.value,`${n}.progress.value`,s),k(i.max,`${n}.progress.max`,s)),"label"in e&&A(e.label,`${n}.label`,s);return}case"group":"direction"in e&&e.direction!=="row"&&e.direction!=="column"&&s.findings.push(d("view-direction",`${n}.direction`,`a group runs "row" or "column", not "${String(e.direction)}"`)),x(i,`${n}.group`,t+1,s);return;case"when":k(i,`${n}.when`,s),"show"in e?x(e.show,`${n}.show`,t+1,s):s.findings.push(d("view-when",n,'a condition says what it shows: {"when": expr, "show": [blocks]}'));return;case"figure":if(typeof i=="string")return ne(e,n,s);for(let o of["as","currency","label","emphasis"])o in e&&s.findings.push(d("unknown-key",`${n}.${o}`,`"${o}" belongs to a figure that works a number out; {"figure": true} is the kind's picture`,`write {"figure": "count(all('offer'))", "as": "number"}`));i!==!0?s.findings.push(d("view-block",`${n}.figure`,`a figure is a number worked out, {"figure": "sum(all('offer'), net)", "as": "money"}, or the kind's picture, {"figure": true}`)):s.spec.figure||s.findings.push(d("view-figure",`${n}.figure`,`${z(s)} has no figure to show`,s.kind===null?`work a number out: {"figure": "count(all('offer'))"}`:'give the kind a "figure", or leave this block out'));return;case"list":return te(e,n,s);case"divider":i!==!0&&s.findings.push(d("view-block",`${n}.${r}`,`write {"${r}": true}`));return}}function ne(e,n,t){k(e.figure,`${n}.figure`,t),"as"in e&&!L.includes(e.as)&&t.findings.push(d("view-format",`${n}.as`,`"${String(e.as)}" is not a way to say a figure`,`use one of ${L.join(", ")}`)),D(e,n,t,"figure"),"label"in e&&A(e.label,`${n}.label`,t),"emphasis"in e&&!B.includes(e.emphasis)&&t.findings.push(d("view-emphasis",`${n}.emphasis`,`"${String(e.emphasis)}" is not how loudly a figure is said`,`use ${B.map(s=>`"${s}"`).join(", ")}, or leave it out for the figure's own size`))}function D(e,n,t,s){"currency"in e&&(typeof e.currency!="string"||!/^[A-Z]{3}$/.test(e.currency)?t.findings.push(d("view-currency",`${n}.currency`,'a currency is its three-letter code, like "USD" or "EUR"')):e.as!=="money"&&t.findings.push(d("view-currency",`${n}.currency`,`a currency belongs on a ${s} shown as money`,'add "as": "money"')))}function ie(e,n){let t=[...n.kinds],s=(l,r)=>{let i=new Set;for(let o of l){let f=n.vocabulary.namesOf(o)?.targets?.(r);if(f==="*")return t;for(let u of f??[])i.add(u)}return i.size>0?[...i]:void 0},a=l=>{switch(l.t){case"ident":return n.kind!==null&&n.spec.relation(l.name)?s([n.kind],l.name):void 0;case"member":{let r=a(l.object);return r?s(r,l.name):void 0}case"where":return a(l.set);case"call":{let r=l.args[0],i=r?.t==="lit"&&typeof r.value=="string"?r.value:void 0;if(l.fn==="all")return i!==void 0&&n.kinds.has(i)?[i]:void 0;let o=l.args.length===2&&l.args[1]?.t==="lit"&&typeof l.args[1].value=="string"?l.args[1].value:void 0;if(l.fn==="out"&&o!==void 0){let f=a(r);return f?s(f,o):void 0}if(l.fn==="out")return i!==void 0&&n.kind!==null?s([n.kind],i):void 0;if(l.fn==="in"){let f=o??i,u=o!==void 0?a(r):n.kind!==null?[n.kind]:void 0,c=f!==void 0?n.vocabulary.sources(f).filter(p=>{let y=n.vocabulary.namesOf(p)?.targets?.(f);return!u||y==="*"||u.some(h=>y?.includes(h))}):[];return c.length>0?c:void 0}if((l.fn==="sort"||l.fn==="first")&&r)return a(r);if(l.fn==="either"){let f=l.args.map(a);return f.every(u=>u!==void 0)?[...new Set(f.flatMap(u=>u??[]))]:void 0}return}default:return}};return a(e)}function N(e,n,t,s){let a;try{a=w(e)}catch(r){if(!(r instanceof b))throw r;s.findings.push(d("expression",n,`${r.sentence} (at character ${r.at+1})`));return}let l=O(a);for(let r of l.unknownFunctions)s.findings.push(d("unknown-function",n,`"${r}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let r of l.edges)s.edges.has(r)||s.findings.push(d("view-edge",n,`"${r}" is not a relation any kind declares`));if(t)for(let r of l.names)r==="id"||t.some(i=>s.vocabulary.namesOf(i)?.field(r)||s.vocabulary.namesOf(i)?.relation(r))||s.findings.push(d("view-name",n,`${t.join(" and ")} ${t.length===1?"has":"have"} no field or relation called "${r}"`))}function te(e,n,t){let s=e.list;k(s,`${n}.list`,t);let a;if(typeof s=="string")try{a=ie(w(s),t)}catch{a=void 0}let l=i=>{if(!a)return[...t.kinds].map(f=>t.vocabulary.namesOf(f)?.choices?.(i)).find(f=>f!==void 0);let o=a.map(f=>t.vocabulary.namesOf(f)?.choices?.(i));return o.every(f=>f!==void 0)?[...new Set(o.flatMap(f=>f??[]))]:void 0},r=a?a.join(" and "):"any kind";if("sort"in e){let i=e.sort;if(typeof i=="string")N(i,`${n}.sort`,a,t);else if(g(i)&&typeof i.by=="string"&&Object.keys(i).every(o=>o==="by"||o==="direction")){let o=i.direction;o!==void 0&&o!=="asc"&&o!=="desc"&&o!=="choices"?t.findings.push(d("list-sort",`${n}.sort.direction`,`a list is sorted "asc", "desc" or "choices", not "${String(o)}"`,'"choices" puts a choice field in the order its choices are declared')):o==="choices"?l(i.by)===void 0&&t.findings.push(d("list-sort",`${n}.sort.by`,`"${i.by}" is not a choice field of ${r}, so it has no declared order`,'sort by a choice field, or say "asc" or "desc"')):N(i.by,`${n}.sort.by`,a,t)}else t.findings.push(d("list-sort",`${n}.sort`,'a sort is a key, like "net", or {"by": key, "direction": "asc" | "desc" | "choices"}'))}if("limit"in e){let i=e.limit;(typeof i!="number"||!Number.isInteger(i)||i<1||i>M)&&t.findings.push(d("list-limit",`${n}.limit`,`a limit is a whole number from 1 to ${M}`))}if("group"in e){let i=e.group,o=typeof i=="string"?i:g(i)&&typeof i.by=="string"?i.by:void 0;if(!(typeof i=="string"||g(i)&&Object.keys(i).every(u=>u==="by"||u==="headings"))||o===void 0)t.findings.push(d("list-group",`${n}.group`,'a group is a choice field, like "type", or {"by": "type", "headings": {"pain": "What hurts"}} \u2014 or a relation, like "inGenre", a heading per linked record'));else{let u=l(o),c=u===void 0?X(o):void 0,p=c!==void 0&&(c.way!==void 0?t.edges.has(c.edge):a?a.every(y=>t.vocabulary.namesOf(y)?.relation(c.edge)):t.edges.has(c.edge));if(u===void 0&&!p&&t.findings.push(d("list-group",`${n}.group`,`"${o}" is not a choice field or a relation of ${r}, so it has nothing to group by`,'group by a field whose type is enum, or by a relation of the kind listed, like "inGenre"')),g(i)&&"headings"in i){let y=i.headings;if(!g(y)||Object.values(y).some(h=>typeof h!="string"||h.length===0||h.length>80))t.findings.push(d("list-group",`${n}.group.headings`,'headings are words per choice, like {"pain": "What hurts"}, at most 80 characters each'));else if(u)for(let h of Object.keys(y))u.includes(h)||t.findings.push(d("list-group",`${n}.group.headings.${h}`,`"${h}" is not one of ${o}'s choices`,`use ${u.join(", ")}`))}}}"empty"in e&&(typeof e.empty!="string"||e.empty.length===0||e.empty.length>200)&&t.findings.push(d("list-empty",`${n}.empty`,"what an empty list says is a sentence, at most 200 characters")),"as"in e&&!C.includes(e.as)&&t.findings.push(d("list-as",`${n}.as`,`a list draws each record as its "card" or its "row", not "${String(e.as)}"`))}function oe(e,n,t){(typeof e!="string"||e.length===0||e.length>60)&&t.findings.push(d("view-label",n,"a label is a few words, at most 60 characters"))}function P(e,n,t,s,a,l,r){let i={kind:null,spec:q,kinds:s,edges:a,vocabulary:t,findings:l,count:0,all:0};Array.isArray(e)&&e.length===0&&l.push(d("view-shape",n,`${r} has no blocks`,'give it one: {"headline": "\u2026"}')),x(e,n,1,i),H(i,n,r,"show less")}function H(e,n,t,s){e.count>T?e.findings.push(d("view-size",n,`${t} has ${e.count} blocks at its top; a view has at most ${T} there, a group or a condition counting as one`,`${s}, or gather some into a group`)):e.all>I&&e.findings.push(d("view-size",n,`${t} has ${e.all} blocks counting the ones inside its groups and conditions; a view has at most ${I} in all`,s))}function se(e,n,t,s,a){Array.isArray(e)&&e.forEach((l,r)=>{if(!g(l)||l.name!=="blocks"||!g(l.options)||!("blocks"in l.options))return;let i=[];P(l.options.blocks,`lenses.${r}.options.blocks`,n,t,s,i,`the lens "${String(l.title??r)}"`);for(let o of i)a.push({...o,severity:"warning"})})}function re(e,n,t,s,a,l,r){let i=[];if(e===void 0)return i;if(!g(e))return i.push(d("view-shape",n,'views are an object of kinds, each with a "card", a "row" or a "page"')),i;for(let[o,f]of Object.entries(e)){if(o==="home"&&Array.isArray(f)){P(f,`${n}.home`,r,s,a,i,"the home");continue}let u=t(o);if(!u){i.push(d("view-kind",`${n}.${o}`,`"${o}" is not a kind this ${l} declares`));continue}if(!g(f)){i.push(d("view-shape",`${n}.${o}`,`a kind's views are {"card": [blocks], "row": [blocks], "page": [blocks]}`));continue}for(let c of Object.keys(f))E.includes(c)||i.push(d("view-slot",`${n}.${o}.${c}`,`"${c}" is not a place a view is drawn`,`use ${E.map(p=>`"${p}"`).join(", ")}`));for(let c of E){let p=f[c];if(p===void 0)continue;let y={kind:o,spec:u,kinds:s,edges:a,vocabulary:r,findings:i,count:0,all:0,slot:c};x(p,`${n}.${o}.${c}`,1,y),H(y,`${n}.${o}.${c}`,`this ${c}`,"show less, or move detail to the page")}}return i}function he(e){let n=new Set(Object.keys(e.kinds)),t=new Set(Object.values(e.kinds).flatMap(r=>Object.keys($(r.edges)))),s=r=>{let i=m(e.kinds,r)?e.kinds[r]:void 0;return i?{field:o=>m(i.fields,o)||m(i.computed,o)||F(i.edges).has(o),relation:o=>m($(i.edges),o),figure:i.figure!==void 0,files:o=>m(i.fields,o)&&Y(i.fields[o]),choices:o=>m(i.fields,o)&&i.fields[o].type==="enum"?i.fields[o].options:void 0,targets:o=>m($(i.edges),o)?i.edges[o].to:void 0,prose:o=>m(i.fields,o)&&i.fields[o].type==="text"}:void 0},a={namesOf:s,sources:r=>Object.keys(e.kinds).filter(i=>m(e.kinds[i].edges,r))},l=re(e.views,"views",s,n,t,"document",a);return se(e.lenses,a,n,t,l),l}export{j as a,U as b,L as c,B as d,M as e,ce as f,X as g,ge as h,ye as i,he as j};
1
+ import{a as O,b,c as w,d as R,e as V}from"./chunk.PI44XMY2.js";import{h as d,i as S}from"./chunk.KGW75Z5L.js";import{Ka as $,La as F}from"./chunk.VSCIXAHN.js";var E=["card","row","page"],j=["good","warn","bad","neutral","accent"],U=["money","percent","date","time","datetime","relative","count"],_=4,T=40,I=120,L=["number","money","percent"],B=["large"],C=["card","row"],M=1e3,ce=100;function X(e){let n=/^\s*(out|in)\(\s*['"]([A-Za-z][A-Za-z0-9_-]*)['"]\s*\)\s*$/.exec(e);return n?{edge:n[2],way:n[1]}:/^[A-Za-z][A-Za-z0-9_-]*$/.test(e)?{edge:e}:void 0}var v={title:[],headline:[],list:["sort","limit","group","empty","as"],text:["tone","lines"],badge:["tone"],field:["as","currency","label"],image:["as","label"],progress:["label"],group:["direction"],when:["show"],divider:[],figure:["as","currency","label","emphasis"]},Z=Object.keys(v),G=`{"title": "{name}"}, {"headline": "{count(all('offer'))} offers"}, {"figure": expr, "as"?: "number"|"money"|"percent", "currency"?, "label"?, "emphasis"?: "large"}, {"list": expr, "sort"?, "limit"?, "group"?, "empty"?, "as"?: "card"|"row"}, {"text": "\u2026", "tone"?, "lines"?: 0-12}, {"badge": "{status}", "tone"?}, {"field": "quote", "as"?, "currency"?, "label"?}, {"image": "photos", "as"?: "thumb"|"gallery"}, {"progress": {"value": expr, "max": expr}, "label"?}, {"group": [blocks], "direction"?: "row"|"column"}, {"when": expr, "show": [blocks]}, {"divider": true}, {"figure": true}`,Y=e=>/^(image|video|file)$/.test(e?.of??e?.type??"");function ge(e){return Object.fromEntries(Object.entries(e.views??{}).filter(([,n])=>!Array.isArray(n)))}function ye(e){let n=e.views?.home;return Array.isArray(n)?n:void 0}var q={field:()=>!1,relation:()=>!1,figure:!1},z=e=>e.kind??"the home",m=(e,n)=>e!==void 0&&Object.hasOwn(e,n),g=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function W(e,n,t){let s=O(e);for(let a of s.unknownFunctions)t.findings.push(d("unknown-function",n,`"${a}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let a of s.names){if(t.kind===null){t.findings.push(d("view-name",n,`"${a}" names nothing here: these blocks are about no one record`,"reach records with all('<kind>'), like count(all('offer')) or first(all('party') where role == 'client').name"));continue}a==="id"||t.spec.field(a)||t.spec.relation(a)||t.findings.push(d("view-name",n,`${t.kind} has no field or relation called "${a}"`))}for(let a of s.edges)t.edges.has(a)||t.findings.push(d("view-edge",n,`"${a}" is not a relation any kind declares`));for(let a of s.sweeps)t.kinds.has(a)||t.findings.push(d("view-kind",n,`"${a}" is not a kind this document declares`))}function k(e,n,t){if(typeof e!="string"||e.length===0||e.length>2e3){t.findings.push(d("view-expression",n,`an expression is a line of the rule language, like "status == 'booked'"`));return}try{W(w(e),n,t)}catch(s){if(!(s instanceof b))throw s;t.findings.push(d("expression",n,`${s.sentence} (at character ${s.at+1})`))}}function A(e,n,t,s,a=!1){let l=s==="text";if(typeof e!="string"||e.length===0||e.length>300){t.findings.push(d("view-template",n,'a template is words with {field} in braces, like "{name}" or "{quote|money}", at most 300 characters'));return}let r;try{r=V(e)}catch(i){if(i instanceof R||i instanceof b){t.findings.push(d("template",n,i.sentence));return}throw i}for(let i of r)if(i.expr){if(W(i.expr,n,t),l&&!a&&!i.format&&i.expr.t==="ident"&&(t.slot==="card"||t.slot==="row")&&t.spec.prose?.(i.expr.name)){let o=i.expr.name;t.findings.push(S("view-whole-text",n,`${t.kind} ${t.slot} shows ${o} whole; it will be clamped. Use {${o}|excerpt} or move it to the page.`,`write {${o}|excerpt}, or {${o}|excerpt: 80} for fewer characters`))}if(s==="headline"&&!i.format&&i.expr.t==="ident"&&t.spec.prose?.(i.expr.name)){let o=i.expr.name;t.findings.push(S("view-headline-long",n,`${z(t)}${t.slot?` ${t.slot}`:""} heads it with ${o}, a long text, drawn at a headline's size; a headline is a few words.`,`say it in a text block, {"text": "{${o}}"}, or head it with {${o}|excerpt: 60}`))}}}var K=12;function J(e,n,t){typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=K||t.findings.push(d("view-lines",n,`lines is ${JSON.stringify(e)}, and a text block's lines is a whole number from 1 to ${K}, or 0 to show it whole`,'{"text": "{awards}", "lines": 6}, or "lines": 0 for no cut at all'))}function Q(e,n,t){if(typeof e=="string"){j.includes(e)||t.findings.push(d("view-tone",n,`"${e}" is not a tone`,`use one of ${j.join(", ")}, or {"expr": "if(status == 'booked', 'good', 'neutral')"}`));return}if(g(e)&&Object.keys(e).length===1&&"expr"in e){k(e.expr,`${n}.expr`,t);return}t.findings.push(d("view-tone",n,'a tone is a word or {"expr": \u2026}',`one of ${j.join(", ")}`))}function x(e,n,t,s){if(!Array.isArray(e)){s.findings.push(d("view-shape",n,"a view is a list of blocks"));return}if(t>_){s.findings.push(d("view-depth",n,`blocks nest at most ${_} deep`,"flatten a group or a condition"));return}e.forEach((a,l)=>ee(a,`${n}.${l}`,t,s))}function ee(e,n,t,s){if(t===1&&s.count++,s.all++,!g(e)){s.findings.push(d("view-block",n,"a block is an object naming what it shows",`one of ${G}`));return}let a=Object.keys(e),l=a.filter(o=>Z.includes(o)&&!(o==="group"&&a.includes("list")));if(l.length===0){s.findings.push(d("view-block",n,`${a.length>0?a.map(o=>`"${o}"`).join(", "):"an empty object"} is not a block Graview knows`,`one of ${G}`));return}if(l.length>1){s.findings.push(d("view-block",n,`a block is one thing, and this says ${l.map(o=>`"${o}"`).join(" and ")}`,"split it into two blocks"));return}let r=l[0];for(let o of a)o!==r&&o!="key"&&!v[r].includes(o)&&s.findings.push(d("unknown-key",`${n}.${o}`,`"${o}" is not part of a ${r} block`,v[r].length>0?`a ${r} block may also say ${v[r].map(f=>`"${f}"`).join(", ")}`:`a ${r} block says nothing else`));let i=e[r];switch(r){case"title":case"headline":case"text":case"badge":A(i,`${n}.${r}`,s,r==="text"||r==="headline"?r:void 0,r==="text"&&"lines"in e),"tone"in e&&Q(e.tone,`${n}.tone`,s),r==="text"&&"lines"in e&&J(e.lines,`${n}.lines`,s);return;case"image":case"field":{let o=r==="image";if(typeof i!="string"||!(o?s.spec.files?.(i):s.spec.field(i))){let u=typeof i=="string"&&s.spec.relation(i);s.findings.push(d(`view-${r}`,`${n}.${r}`,`${s.kind} has no ${o?"image, video or file ":""}field ${typeof i=="string"?`"${i}"`:"by that name"}`,u?`"${i}" is a relation; show it with {"text": "{${i}.name}"}`:void 0))}let f=o?["thumb","gallery"]:U;"as"in e&&!f.includes(e.as)&&s.findings.push(d("view-format",`${n}.as`,`"${String(e.as)}" is not a way to show ${o?"pictures":"a field"}`,`use one of ${f.join(", ")}`)),o||D(e,n,s,"field"),"label"in e&&oe(e.label,`${n}.label`,s);return}case"progress":{!g(i)||Object.keys(i).some(o=>o!=="value"&&o!=="max")||!("value"in i)||!("max"in i)?s.findings.push(d("view-progress",`${n}.progress`,'progress is {"value": expression, "max": expression}')):(k(i.value,`${n}.progress.value`,s),k(i.max,`${n}.progress.max`,s)),"label"in e&&A(e.label,`${n}.label`,s);return}case"group":"direction"in e&&e.direction!=="row"&&e.direction!=="column"&&s.findings.push(d("view-direction",`${n}.direction`,`a group runs "row" or "column", not "${String(e.direction)}"`)),x(i,`${n}.group`,t+1,s);return;case"when":k(i,`${n}.when`,s),"show"in e?x(e.show,`${n}.show`,t+1,s):s.findings.push(d("view-when",n,'a condition says what it shows: {"when": expr, "show": [blocks]}'));return;case"figure":if(typeof i=="string")return ne(e,n,s);for(let o of["as","currency","label","emphasis"])o in e&&s.findings.push(d("unknown-key",`${n}.${o}`,`"${o}" belongs to a figure that works a number out; {"figure": true} is the kind's picture`,`write {"figure": "count(all('offer'))", "as": "number"}`));i!==!0?s.findings.push(d("view-block",`${n}.figure`,`a figure is a number worked out, {"figure": "sum(all('offer'), net)", "as": "money"}, or the kind's picture, {"figure": true}`)):s.spec.figure||s.findings.push(d("view-figure",`${n}.figure`,`${z(s)} has no figure to show`,s.kind===null?`work a number out: {"figure": "count(all('offer'))"}`:'give the kind a "figure", or leave this block out'));return;case"list":return te(e,n,s);case"divider":i!==!0&&s.findings.push(d("view-block",`${n}.${r}`,`write {"${r}": true}`));return}}function ne(e,n,t){k(e.figure,`${n}.figure`,t),"as"in e&&!L.includes(e.as)&&t.findings.push(d("view-format",`${n}.as`,`"${String(e.as)}" is not a way to say a figure`,`use one of ${L.join(", ")}`)),D(e,n,t,"figure"),"label"in e&&A(e.label,`${n}.label`,t),"emphasis"in e&&!B.includes(e.emphasis)&&t.findings.push(d("view-emphasis",`${n}.emphasis`,`"${String(e.emphasis)}" is not how loudly a figure is said`,`use ${B.map(s=>`"${s}"`).join(", ")}, or leave it out for the figure's own size`))}function D(e,n,t,s){"currency"in e&&(typeof e.currency!="string"||!/^[A-Z]{3}$/.test(e.currency)?t.findings.push(d("view-currency",`${n}.currency`,'a currency is its three-letter code, like "USD" or "EUR"')):e.as!=="money"&&t.findings.push(d("view-currency",`${n}.currency`,`a currency belongs on a ${s} shown as money`,'add "as": "money"')))}function ie(e,n){let t=[...n.kinds],s=(l,r)=>{let i=new Set;for(let o of l){let f=n.vocabulary.namesOf(o)?.targets?.(r);if(f==="*")return t;for(let u of f??[])i.add(u)}return i.size>0?[...i]:void 0},a=l=>{switch(l.t){case"ident":return n.kind!==null&&n.spec.relation(l.name)?s([n.kind],l.name):void 0;case"member":{let r=a(l.object);return r?s(r,l.name):void 0}case"where":return a(l.set);case"call":{let r=l.args[0],i=r?.t==="lit"&&typeof r.value=="string"?r.value:void 0;if(l.fn==="all")return i!==void 0&&n.kinds.has(i)?[i]:void 0;let o=l.args.length===2&&l.args[1]?.t==="lit"&&typeof l.args[1].value=="string"?l.args[1].value:void 0;if(l.fn==="out"&&o!==void 0){let f=a(r);return f?s(f,o):void 0}if(l.fn==="out")return i!==void 0&&n.kind!==null?s([n.kind],i):void 0;if(l.fn==="in"){let f=o??i,u=o!==void 0?a(r):n.kind!==null?[n.kind]:void 0,c=f!==void 0?n.vocabulary.sources(f).filter(p=>{let y=n.vocabulary.namesOf(p)?.targets?.(f);return!u||y==="*"||u.some(h=>y?.includes(h))}):[];return c.length>0?c:void 0}if((l.fn==="sort"||l.fn==="first")&&r)return a(r);if(l.fn==="either"){let f=l.args.map(a);return f.every(u=>u!==void 0)?[...new Set(f.flatMap(u=>u??[]))]:void 0}return}default:return}};return a(e)}function N(e,n,t,s){let a;try{a=w(e)}catch(r){if(!(r instanceof b))throw r;s.findings.push(d("expression",n,`${r.sentence} (at character ${r.at+1})`));return}let l=O(a);for(let r of l.unknownFunctions)s.findings.push(d("unknown-function",n,`"${r}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let r of l.edges)s.edges.has(r)||s.findings.push(d("view-edge",n,`"${r}" is not a relation any kind declares`));if(t)for(let r of l.names)r==="id"||t.some(i=>s.vocabulary.namesOf(i)?.field(r)||s.vocabulary.namesOf(i)?.relation(r))||s.findings.push(d("view-name",n,`${t.join(" and ")} ${t.length===1?"has":"have"} no field or relation called "${r}"`))}function te(e,n,t){let s=e.list;k(s,`${n}.list`,t);let a;if(typeof s=="string")try{a=ie(w(s),t)}catch{a=void 0}let l=i=>{if(!a)return[...t.kinds].map(f=>t.vocabulary.namesOf(f)?.choices?.(i)).find(f=>f!==void 0);let o=a.map(f=>t.vocabulary.namesOf(f)?.choices?.(i));return o.every(f=>f!==void 0)?[...new Set(o.flatMap(f=>f??[]))]:void 0},r=a?a.join(" and "):"any kind";if("sort"in e){let i=e.sort;if(typeof i=="string")N(i,`${n}.sort`,a,t);else if(g(i)&&typeof i.by=="string"&&Object.keys(i).every(o=>o==="by"||o==="direction")){let o=i.direction;o!==void 0&&o!=="asc"&&o!=="desc"&&o!=="choices"?t.findings.push(d("list-sort",`${n}.sort.direction`,`a list is sorted "asc", "desc" or "choices", not "${String(o)}"`,'"choices" puts a choice field in the order its choices are declared')):o==="choices"?l(i.by)===void 0&&t.findings.push(d("list-sort",`${n}.sort.by`,`"${i.by}" is not a choice field of ${r}, so it has no declared order`,'sort by a choice field, or say "asc" or "desc"')):N(i.by,`${n}.sort.by`,a,t)}else t.findings.push(d("list-sort",`${n}.sort`,'a sort is a key, like "net", or {"by": key, "direction": "asc" | "desc" | "choices"}'))}if("limit"in e){let i=e.limit;(typeof i!="number"||!Number.isInteger(i)||i<1||i>M)&&t.findings.push(d("list-limit",`${n}.limit`,`a limit is a whole number from 1 to ${M}`))}if("group"in e){let i=e.group,o=typeof i=="string"?i:g(i)&&typeof i.by=="string"?i.by:void 0;if(!(typeof i=="string"||g(i)&&Object.keys(i).every(u=>u==="by"||u==="headings"))||o===void 0)t.findings.push(d("list-group",`${n}.group`,'a group is a choice field, like "type", or {"by": "type", "headings": {"pain": "What hurts"}} \u2014 or a relation, like "inGenre", a heading per linked record'));else{let u=l(o),c=u===void 0?X(o):void 0,p=c!==void 0&&(c.way!==void 0?t.edges.has(c.edge):a?a.every(y=>t.vocabulary.namesOf(y)?.relation(c.edge)):t.edges.has(c.edge));if(u===void 0&&!p&&t.findings.push(d("list-group",`${n}.group`,`"${o}" is not a choice field or a relation of ${r}, so it has nothing to group by`,'group by a field whose type is enum, or by a relation of the kind listed, like "inGenre"')),g(i)&&"headings"in i){let y=i.headings;if(!g(y)||Object.values(y).some(h=>typeof h!="string"||h.length===0||h.length>80))t.findings.push(d("list-group",`${n}.group.headings`,'headings are words per choice, like {"pain": "What hurts"}, at most 80 characters each'));else if(u)for(let h of Object.keys(y))u.includes(h)||t.findings.push(d("list-group",`${n}.group.headings.${h}`,`"${h}" is not one of ${o}'s choices`,`use ${u.join(", ")}`))}}}"empty"in e&&(typeof e.empty!="string"||e.empty.length===0||e.empty.length>200)&&t.findings.push(d("list-empty",`${n}.empty`,"what an empty list says is a sentence, at most 200 characters")),"as"in e&&!C.includes(e.as)&&t.findings.push(d("list-as",`${n}.as`,`a list draws each record as its "card" or its "row", not "${String(e.as)}"`))}function oe(e,n,t){(typeof e!="string"||e.length===0||e.length>60)&&t.findings.push(d("view-label",n,"a label is a few words, at most 60 characters"))}function P(e,n,t,s,a,l,r){let i={kind:null,spec:q,kinds:s,edges:a,vocabulary:t,findings:l,count:0,all:0};Array.isArray(e)&&e.length===0&&l.push(d("view-shape",n,`${r} has no blocks`,'give it one: {"headline": "\u2026"}')),x(e,n,1,i),H(i,n,r,"show less")}function H(e,n,t,s){e.count>T?e.findings.push(d("view-size",n,`${t} has ${e.count} blocks at its top; a view has at most ${T} there, a group or a condition counting as one`,`${s}, or gather some into a group`)):e.all>I&&e.findings.push(d("view-size",n,`${t} has ${e.all} blocks counting the ones inside its groups and conditions; a view has at most ${I} in all`,s))}function se(e,n,t,s,a){Array.isArray(e)&&e.forEach((l,r)=>{if(!g(l)||l.name!=="blocks"||!g(l.options)||!("blocks"in l.options))return;let i=[];P(l.options.blocks,`lenses.${r}.options.blocks`,n,t,s,i,`the lens "${String(l.title??r)}"`);for(let o of i)a.push({...o,severity:"warning"})})}function re(e,n,t,s,a,l,r){let i=[];if(e===void 0)return i;if(!g(e))return i.push(d("view-shape",n,'views are an object of kinds, each with a "card", a "row" or a "page"')),i;for(let[o,f]of Object.entries(e)){if(o==="home"&&Array.isArray(f)){P(f,`${n}.home`,r,s,a,i,"the home");continue}let u=t(o);if(!u){i.push(d("view-kind",`${n}.${o}`,`"${o}" is not a kind this ${l} declares`));continue}if(!g(f)){i.push(d("view-shape",`${n}.${o}`,`a kind's views are {"card": [blocks], "row": [blocks], "page": [blocks]}`));continue}for(let c of Object.keys(f))E.includes(c)||i.push(d("view-slot",`${n}.${o}.${c}`,`"${c}" is not a place a view is drawn`,`use ${E.map(p=>`"${p}"`).join(", ")}`));for(let c of E){let p=f[c];if(p===void 0)continue;let y={kind:o,spec:u,kinds:s,edges:a,vocabulary:r,findings:i,count:0,all:0,slot:c};x(p,`${n}.${o}.${c}`,1,y),H(y,`${n}.${o}.${c}`,`this ${c}`,"show less, or move detail to the page")}}return i}function he(e){let n=new Set(Object.keys(e.kinds)),t=new Set(Object.values(e.kinds).flatMap(r=>Object.keys($(r.edges)))),s=r=>{let i=m(e.kinds,r)?e.kinds[r]:void 0;return i?{field:o=>m(i.fields,o)||m(i.computed,o)||F(i.edges).has(o),relation:o=>m($(i.edges),o),figure:i.figure!==void 0,files:o=>m(i.fields,o)&&Y(i.fields[o]),choices:o=>m(i.fields,o)&&i.fields[o].type==="enum"?i.fields[o].options:void 0,targets:o=>m($(i.edges),o)?i.edges[o].to:void 0,prose:o=>m(i.fields,o)&&i.fields[o].type==="text"}:void 0},a={namesOf:s,sources:r=>Object.keys(e.kinds).filter(i=>m(e.kinds[i].edges,r))},l=re(e.views,"views",s,n,t,"document",a);return se(e.lenses,a,n,t,l),l}export{j as a,U as b,L as c,B as d,M as e,ce as f,X as g,ge as h,ye as i,he as j};
@@ -1 +1 @@
1
- import{Ma as y,Oa as k,T as w,j as c,l as h,m as b,r as f}from"./chunk.VNJKGSGZ.js";import{W as i}from"./chunk.X3MMJ3QC.js";import{b as g}from"./chunk.AJZBJBMO.js";var s=null,a=new Set,v=e=>{s={kind:e,n:(s?.n??0)+1};for(let t of a)t()},A=()=>s,C=e=>(a.add(e),()=>a.delete(e)),V=()=>{s=null};var d=g(w(),1);function T(e,t){if(e.length===0||t.length===0)return[];let o=new Set(t.map(n=>n.id));return e.filter(n=>n.nodeIds.some(l=>o.has(l)))}var x=(e,t)=>`${i(e)} ${e===1?"problem":"problems"} in ${t}`;function q({kind:e,plural:t,problems:o,flag:n,listed:l=!1}){let{view:p,go:P}=k(),{set:$}=y();if(o.length===0)return null;let u=x(o.length,t),m=o.length===1?"it":"them";return(0,d.jsx)("button",{type:"button",className:"graview-district-problems","data-testid":`district-problems-${e}`,"data-graview-problems":o.length,"aria-expanded":l,"aria-label":u,title:`${u} \u2014 ${o[0].message}${o.length>1?` (and ${i(o.length-1)} more)`:""}. Press to see ${m} and how to fix ${m}.`,onClick:r=>{r.stopPropagation(),p.overview||P(h(c(b(p,!0),null),"view",null)),$([f(e)]),v(e)},onDoubleClick:r=>r.stopPropagation(),onPointerDown:r=>r.stopPropagation(),children:(0,d.jsx)("span",{"aria-hidden":"true",children:`${n} ${i(o.length)}`})})}export{A as a,C as b,V as c,T as d,x as e,q as f};
1
+ import{Ma as y,Oa as k,T as w,j as c,l as h,m as b,r as f}from"./chunk.4MP72LPR.js";import{W as i}from"./chunk.VSCIXAHN.js";import{b as g}from"./chunk.AJZBJBMO.js";var s=null,a=new Set,v=e=>{s={kind:e,n:(s?.n??0)+1};for(let t of a)t()},A=()=>s,C=e=>(a.add(e),()=>a.delete(e)),V=()=>{s=null};var d=g(w(),1);function T(e,t){if(e.length===0||t.length===0)return[];let o=new Set(t.map(n=>n.id));return e.filter(n=>n.nodeIds.some(l=>o.has(l)))}var x=(e,t)=>`${i(e)} ${e===1?"problem":"problems"} in ${t}`;function q({kind:e,plural:t,problems:o,flag:n,listed:l=!1}){let{view:p,go:P}=k(),{set:$}=y();if(o.length===0)return null;let u=x(o.length,t),m=o.length===1?"it":"them";return(0,d.jsx)("button",{type:"button",className:"graview-district-problems","data-testid":`district-problems-${e}`,"data-graview-problems":o.length,"aria-expanded":l,"aria-label":u,title:`${u} \u2014 ${o[0].message}${o.length>1?` (and ${i(o.length-1)} more)`:""}. Press to see ${m} and how to fix ${m}.`,onClick:r=>{r.stopPropagation(),p.overview||P(h(c(b(p,!0),null),"view",null)),$([f(e)]),v(e)},onDoubleClick:r=>r.stopPropagation(),onPointerDown:r=>r.stopPropagation(),children:(0,d.jsx)("span",{"aria-hidden":"true",children:`${n} ${i(o.length)}`})})}export{A as a,C as b,V as c,T as d,x as e,q as f};
@@ -1 +1 @@
1
- import{C as O}from"./chunk.X3MMJ3QC.js";var k=3,A=k+1,P=A+1,z=(o,r)=>o<r?-1:o>r?1:0;function L(o){return(o??0)>4?k:2}function N(o,r,a){let n=[];for(let d of Object.values(o.tryDefinition(r)?.edges??{}))if(d.to!=="*")for(let i of d.to)i!==r&&a.includes(i)&&!n.includes(i)&&n.push(i);return n}function W(o,r={}){let a=[...o.kinds],n=[...(r.order??[]).filter(e=>a.includes(e)),...a.filter(e=>!(r.order??[]).includes(e)).sort(z)].filter((e,t,s)=>s.indexOf(e)===t),d=e=>n.indexOf(e),i=new Map,g=[],h=(e,t,s)=>{i.set(e,{col:t,row:s,side:L(r.counts?.[e])}),g.push({col:t,row:s})};for(let e of n){let t=o.tryDefinition(e)?.plot??r.plots?.[e];t&&h(e,t.col,t.row)}let l=new Map(n.map(e=>[e,N(o,e,a)])),b=new Set(n.filter(e=>l.get(e).length>0||n.some(t=>l.get(t).includes(e)))),v=new Map,C=new Set,D=e=>{let t=v.get(e);if(t!==void 0)return t;if(C.has(e))return-1;C.add(e);let s=0;for(let c of l.get(e))s=Math.max(s,D(c)+1);return C.delete(e),v.set(e,s),s};for(let e of n)b.has(e)&&D(e);let f=[];for(let e of n)b.has(e)&&(f[v.get(e)]??=[]).push(e);let I=new Map,T=Math.max(1,Math.ceil(Math.sqrt(f.length))),H=Math.max(1,...f.map(e=>e?.length??0)),w=Math.max(P,Math.round(r.pitch??P)),R=(e,t)=>r.upright?{col:e%T*w,row:(Math.floor(e/T)*(H+1)+t)*w}:{col:t*w,row:e===0?0:-e*w},$=e=>!g.some(t=>V(t,e)),S=(e,t,s)=>{let c=s;for(;!$(R(t,c))&&c<s+64;)c++;return i.has(e)||h(e,R(t,c).col,R(t,c).row),c},x=0;f.forEach((e=[],t)=>{let s=u=>{let m=l.get(u).map(p=>I.get(p)).filter(p=>p!==void 0);return m.length>0?m.reduce((p,q)=>p+q,0)/m.length:1/0},c=[...e].sort((u,m)=>s(u)-s(m)||d(u)-d(m)),y=0;for(let u of c)i.has(u)||(y=S(u,t,y),I.set(u,y),x=Math.max(x,y+1),y++)});let j=n.filter(e=>!b.has(e)&&!i.has(e)),M=Math.max(r.upright?x:f.length,Math.ceil(Math.sqrt(j.length*2)),1),E=b.size>0?1:0;return j.forEach((e,t)=>{r.upright?S(e,f.length+E+Math.floor(t/M),t%M):S(e,t%M,x+E+Math.floor(t/M))}),i}function V(o,r){return Math.abs(o.col-r.col)<A&&Math.abs(o.row-r.row)<A}function X(o,r,a,n=.5){return{x:(o-r)*a/2,y:(o+r)*a*n/2}}var G=1,B=/^(done|completed?|closed|finished|shipped|sent|won|lost|passed|declined|dropped|answered|resolved|fixed|archived|cancell?ed|retired|released|published|delivered|paid|merged|rejected|written[-_ ]?up|out)$/i,F=/^(doing|in[-_ ]?progress|active|building|started|working|in[-_ ]?review|review(ing)?|fixing|ongoing|underway|testing|drafting|writing|running)$/i;function _(o,r,a){let n=O(o.tryDefinition(r)?.fields.shape?.[a]);for(;n&&n.innerType!==void 0&&n.type!=="enum";)n=O(n.innerType);if(n?.type!=="enum")return;let d=(n.entries?Object.values(n.entries):n.values??[]).filter(i=>typeof i=="string");return d.length>0?d:void 0}function J(o,r){let a=o.tryDefinition(r);if(!a)return;let n=a.lifecycle,d=Object.keys(a.fields.shape??{}),i=[n?.field,...d.filter(l=>/^(status|stage|state|phase)$/i.test(l))].find(l=>l!==void 0&&_(o,r,l)!==void 0);if(!i)return;let g=_(o,r,i),h=n?.field===i&&Array.isArray(n.retired)?n.retired:[];return{field:i,values:g,tiers:g.map(l=>h.includes(l)||B.test(l)?"done":F.test(l)?"active":"waiting")}}export{P as a,W as b,X as c,G as d,J as e};
1
+ import{C as O}from"./chunk.VSCIXAHN.js";var k=3,A=k+1,P=A+1,z=(o,r)=>o<r?-1:o>r?1:0;function L(o){return(o??0)>4?k:2}function N(o,r,a){let n=[];for(let d of Object.values(o.tryDefinition(r)?.edges??{}))if(d.to!=="*")for(let i of d.to)i!==r&&a.includes(i)&&!n.includes(i)&&n.push(i);return n}function W(o,r={}){let a=[...o.kinds],n=[...(r.order??[]).filter(e=>a.includes(e)),...a.filter(e=>!(r.order??[]).includes(e)).sort(z)].filter((e,t,s)=>s.indexOf(e)===t),d=e=>n.indexOf(e),i=new Map,g=[],h=(e,t,s)=>{i.set(e,{col:t,row:s,side:L(r.counts?.[e])}),g.push({col:t,row:s})};for(let e of n){let t=o.tryDefinition(e)?.plot??r.plots?.[e];t&&h(e,t.col,t.row)}let l=new Map(n.map(e=>[e,N(o,e,a)])),b=new Set(n.filter(e=>l.get(e).length>0||n.some(t=>l.get(t).includes(e)))),v=new Map,C=new Set,D=e=>{let t=v.get(e);if(t!==void 0)return t;if(C.has(e))return-1;C.add(e);let s=0;for(let c of l.get(e))s=Math.max(s,D(c)+1);return C.delete(e),v.set(e,s),s};for(let e of n)b.has(e)&&D(e);let f=[];for(let e of n)b.has(e)&&(f[v.get(e)]??=[]).push(e);let I=new Map,T=Math.max(1,Math.ceil(Math.sqrt(f.length))),H=Math.max(1,...f.map(e=>e?.length??0)),w=Math.max(P,Math.round(r.pitch??P)),R=(e,t)=>r.upright?{col:e%T*w,row:(Math.floor(e/T)*(H+1)+t)*w}:{col:t*w,row:e===0?0:-e*w},$=e=>!g.some(t=>V(t,e)),S=(e,t,s)=>{let c=s;for(;!$(R(t,c))&&c<s+64;)c++;return i.has(e)||h(e,R(t,c).col,R(t,c).row),c},x=0;f.forEach((e=[],t)=>{let s=u=>{let m=l.get(u).map(p=>I.get(p)).filter(p=>p!==void 0);return m.length>0?m.reduce((p,q)=>p+q,0)/m.length:1/0},c=[...e].sort((u,m)=>s(u)-s(m)||d(u)-d(m)),y=0;for(let u of c)i.has(u)||(y=S(u,t,y),I.set(u,y),x=Math.max(x,y+1),y++)});let j=n.filter(e=>!b.has(e)&&!i.has(e)),M=Math.max(r.upright?x:f.length,Math.ceil(Math.sqrt(j.length*2)),1),E=b.size>0?1:0;return j.forEach((e,t)=>{r.upright?S(e,f.length+E+Math.floor(t/M),t%M):S(e,t%M,x+E+Math.floor(t/M))}),i}function V(o,r){return Math.abs(o.col-r.col)<A&&Math.abs(o.row-r.row)<A}function X(o,r,a,n=.5){return{x:(o-r)*a/2,y:(o+r)*a*n/2}}var G=1,B=/^(done|completed?|closed|finished|shipped|sent|won|lost|passed|declined|dropped|answered|resolved|fixed|archived|cancell?ed|retired|released|published|delivered|paid|merged|rejected|written[-_ ]?up|out)$/i,F=/^(doing|in[-_ ]?progress|active|building|started|working|in[-_ ]?review|review(ing)?|fixing|ongoing|underway|testing|drafting|writing|running)$/i;function _(o,r,a){let n=O(o.tryDefinition(r)?.fields.shape?.[a]);for(;n&&n.innerType!==void 0&&n.type!=="enum";)n=O(n.innerType);if(n?.type!=="enum")return;let d=(n.entries?Object.values(n.entries):n.values??[]).filter(i=>typeof i=="string");return d.length>0?d:void 0}function J(o,r){let a=o.tryDefinition(r);if(!a)return;let n=a.lifecycle,d=Object.keys(a.fields.shape??{}),i=[n?.field,...d.filter(l=>/^(status|stage|state|phase)$/i.test(l))].find(l=>l!==void 0&&_(o,r,l)!==void 0);if(!i)return;let g=_(o,r,i),h=n?.field===i&&Array.isArray(n.retired)?n.retired:[];return{field:i,values:g,tiers:g.map(l=>h.includes(l)||B.test(l)?"done":F.test(l)?"active":"waiting")}}export{P as a,W as b,X as c,G as d,J as e};
@@ -1,3 +1,3 @@
1
- import{b as te}from"./chunk.ATVPAYS6.js";import"./chunk.NSGQXCH6.js";import"./chunk.SZG6HJWH.js";import{c as ne}from"./chunk.2FOIJ5ID.js";import{G as ge,T as ee}from"./chunk.VNJKGSGZ.js";import"./chunk.SDO3U72B.js";import{Uc as q,ga as X,ia as Z}from"./chunk.X3MMJ3QC.js";import"./chunk.FQLNBIQ5.js";import{b as T}from"./chunk.AJZBJBMO.js";var M=T(ge(),1);var ye=6;function re($,S,m,x,E){let t=new Set($),o=new Map;for(let i of S)for(let[h,l,b]of[[i.from,i.to,"out"],[i.to,i.from,"in"]]){if(!t.has(h)||t.has(l))continue;let f=m(l);if(f===void 0)continue;let p=`${h}|${i.kind}|${b}|${f}`,v=o.get(p);v?v.others.includes(l)||v.others.push(l):o.set(p,{self:h,edge:i.kind,direction:b,kind:f,others:[l]})}let d=[];for(let i of o.values()){let h=m(i.self)??"",l=ne(E,i.direction==="out"?h:i.kind,i.edge,i.direction);if(i.others.length>ye){d.push({...i,others:i.others,lands:"district",words:l});continue}let b=[],f=[];for(let p of i.others)(x(p)?b:f).push(p);for(let p of b)d.push({...i,others:[p],lands:"record",words:l});f.length>0&&d.push({...i,others:f,lands:"district",words:l})}return d}function ie($,S=[]){let m=[...S],x=new Map,E=t=>m.some(o=>t.x<o.x+o.width&&o.x<t.x+t.width&&t.y<o.y+o.height&&o.y<t.y+t.height);for(let t of[...$].sort((o,d)=>o.y-d.y||o.x-d.x)){let o={x:t.x-t.width/2,y:t.y-t.height,width:t.width,height:t.height};for(let d=0;d<12&&E(o);d++)o.y+=t.height+2;m.push(o),x.set(t.key,{x:o.x,y:o.y})}return x}var s=T(ee(),1),he=4;function xe({frame:$,width:S,height:m,stageRef:x,tick:E,store:t,graphVersion:o,selection:d,view:i,rulers:{visibleRect:h,clipQuadratic:l,unsureOf:b,unsureDash:f,unsureOpacity:p}}){let v=n=>t.graph.getNode(n)?.kind,C=te(d,i,v),R=C.lens===null&&C.records.length<=he?C.records:[],oe=R.join(`
1
+ import{b as te}from"./chunk.QDSEVPF3.js";import"./chunk.MSWWWLEA.js";import"./chunk.UITT6JWW.js";import{c as ne}from"./chunk.A5PDXNY6.js";import{G as ge,T as ee}from"./chunk.4MP72LPR.js";import"./chunk.SDO3U72B.js";import{_c as q,ga as X,ia as Z}from"./chunk.VSCIXAHN.js";import"./chunk.FQLNBIQ5.js";import{b as T}from"./chunk.AJZBJBMO.js";var M=T(ge(),1);var ye=6;function re($,S,m,x,E){let t=new Set($),o=new Map;for(let i of S)for(let[h,l,b]of[[i.from,i.to,"out"],[i.to,i.from,"in"]]){if(!t.has(h)||t.has(l))continue;let f=m(l);if(f===void 0)continue;let p=`${h}|${i.kind}|${b}|${f}`,v=o.get(p);v?v.others.includes(l)||v.others.push(l):o.set(p,{self:h,edge:i.kind,direction:b,kind:f,others:[l]})}let d=[];for(let i of o.values()){let h=m(i.self)??"",l=ne(E,i.direction==="out"?h:i.kind,i.edge,i.direction);if(i.others.length>ye){d.push({...i,others:i.others,lands:"district",words:l});continue}let b=[],f=[];for(let p of i.others)(x(p)?b:f).push(p);for(let p of b)d.push({...i,others:[p],lands:"record",words:l});f.length>0&&d.push({...i,others:f,lands:"district",words:l})}return d}function ie($,S=[]){let m=[...S],x=new Map,E=t=>m.some(o=>t.x<o.x+o.width&&o.x<t.x+t.width&&t.y<o.y+o.height&&o.y<t.y+t.height);for(let t of[...$].sort((o,d)=>o.y-d.y||o.x-d.x)){let o={x:t.x-t.width/2,y:t.y-t.height,width:t.width,height:t.height};for(let d=0;d<12&&E(o);d++)o.y+=t.height+2;m.push(o),x.set(t.key,{x:o.x,y:o.y})}return x}var s=T(ee(),1),he=4;function xe({frame:$,width:S,height:m,stageRef:x,tick:E,store:t,graphVersion:o,selection:d,view:i,rulers:{visibleRect:h,clipQuadratic:l,unsureOf:b,unsureDash:f,unsureOpacity:p}}){let v=n=>t.graph.getNode(n)?.kind,C=te(d,i,v),R=C.lens===null&&C.records.length<=he?C.records:[],oe=R.join(`
2
2
  `),[y,K]=(0,M.useState)(null);(0,M.useLayoutEffect)(()=>{let n=x.current;if(!i.overview||R.length===0||!n||typeof document>"u"||$.t<1){K(null);return}let w=n.getBoundingClientRect(),B=e=>({x:e.left-w.left,y:e.top-w.top,width:e.width,height:e.height}),D=new Map,se=R.map(e=>`[data-graview-view="${CSS.escape(e)}"]`).join(","),k=null,H=()=>{if(k)return k;k={drawn:new Map,buildings:new Map};for(let e of n.querySelectorAll("[data-graview-pick], [data-graview-view], [data-graview-building]")){let r=e.getAttribute("data-graview-pick"),a=e.getAttribute("data-graview-view");for(let c of r!==null&&r===a?[r]:[r,a]){if(c===null)continue;let u=k.drawn.get(c);u?u.push(e):k.drawn.set(c,[e])}let L=e.getAttribute("data-graview-building");L!==null&&!k.buildings.has(L)&&k.buildings.set(L,e)}return k},P=e=>{if(D.has(e))return D.get(e);let r=null;for(let a of H().drawn.get(e)??[])if(!a.closest("[data-graview-offstage], [data-graview-screen]")&&!(!R.includes(e)&&a.closest(se))&&(r=h(a,n),r))break;if(!r){let a=H().buildings.get(e);a&&(r=B(a.getBoundingClientRect()))}return D.set(e,r),r},W=e=>{let r=n.querySelector(`[data-graview-plot="kind:${CSS.escape(e)}"] .graview-plot-tile`);return r?B(r.getBoundingClientRect()):null},de=re(R,t.graph.allEdges(),v,e=>P(e)!==null,t.schema),z=[];for(let e of n.querySelectorAll('[data-graview-view^="kind:"] .graview-kind-face')){let r=h(e,n);r&&z.push(r)}let Q=e=>({x:e.x+e.width/2,y:e.y+e.height/2}),O=[],V=new Set(R),I=new Set;for(let e of de){let r=v(e.self),a=P(e.self)??(r?W(r):null),L=e.lands==="record"?P(e.others[0]):W(e.kind);if(!a||!L)continue;for(let g of e.others)V.add(g);I.add(e.kind),r&&I.add(r);let c=Q(a),u=Q(L),A=Math.hypot(u.x-c.x,u.y-c.y);if(A<6)continue;let G=Math.min(40,A*.12)*(O.length%2===0?1:-1),le={x:(c.x+u.x)/2-(u.y-c.y)/A*G,y:(c.y+u.y)/2+(u.x-c.x)/A*G},J=l({p0:c,c:le,p1:u},z);if(J.length===0)continue;let ce=J.map(g=>`M ${g.p0.x.toFixed(1)} ${g.p0.y.toFixed(1)} Q ${g.c.x.toFixed(1)} ${g.c.y.toFixed(1)} ${g.p1.x.toFixed(1)} ${g.p1.y.toFixed(1)}`).join(" "),ue=g=>{let j=t.graph.getNode(g);return j?X(t.schema.tryDefinition(j.kind),j):g},U=e.lands==="record"?`${e.words}: ${ue(e.others[0])}`:`${e.words}: ${Z(t.schema,e.kind,e.others.length)}`,F=e.others[0],_=e.lands==="record"?b?.(e.edge,e.direction==="out"?e.self:F,e.direction==="out"?F:e.self):void 0;O.push({key:`${e.self}|${e.edge}|${e.direction}|${e.lands}|${F}`,link:e,d:ce,end:u,said:_!==void 0?`${U} \xB7 unsure`:U,..._!==void 0?{unsure:_}:{}})}let Y=[];for(let e of n.querySelectorAll(".graview-kind-face[data-graview-nameplate]")){let r=h(e,n);r&&Y.push(r)}let ae=ie(O.map(e=>({key:e.key,x:e.end.x,y:e.end.y-6,width:Math.min(260,14+e.said.length*6.6),height:20})),Y);K({lines:O,labels:ae,reached:[...V],districts:[...I]})},[oe,i.overview,$,o,E,S,m,x,t]);let N=(0,M.useMemo)(()=>{if(!y)return"";let n=y.reached.map(B=>`[data-graview-building="${CSS.escape(B)}"]`).join(","),w=y.districts.map(B=>`[data-graview-plot="kind:${CSS.escape(B)}"]`).join(",");return[".graview-ground[data-graview-altitude] .graview-building { opacity: 0.22; }",n?`.graview-ground[data-graview-altitude] .graview-building:is(${n}) { opacity: 1; }`:"",w?`.graview-ground[data-graview-altitude] .graview-plot:not(:is(${w})) .graview-plot-tile { opacity: 0.4; }`:""].join(`
3
3
  `)},[y]);return!y||y.lines.length===0?N?(0,s.jsx)("style",{children:N}):null:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("style",{children:N}),(0,s.jsx)("svg",{className:"graview-record-links","data-graview-world":"","data-graview-record-links":y.lines.length,"aria-hidden":"true",width:S,height:m,style:{position:"absolute",left:0,top:0,pointerEvents:"none",zIndex:q.lines},children:y.lines.map(n=>(0,s.jsxs)("g",{className:"graview-record-link","data-graview-link":n.link.edge,"data-graview-lands":n.link.lands,"data-graview-direction":n.link.direction,"data-graview-provisional":n.unsure!==void 0||void 0,children:[(0,s.jsx)("path",{className:"graview-record-link-line",d:n.d,...n.unsure!==void 0?{strokeDasharray:f,strokeOpacity:p}:{}}),n.link.lands==="record"?(0,s.jsx)("circle",{className:"graview-record-link-end",cx:n.end.x,cy:n.end.y,r:3}):null]},n.key))}),(0,s.jsx)("div",{"aria-hidden":"true","data-graview-world":"",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:q.tieLabels},children:y.lines.map(n=>{let w=y.labels.get(n.key);return w?(0,s.jsx)("span",{className:"graview-record-link-said","data-graview-link-said":n.link.edge,"data-graview-lands":n.link.lands,...n.unsure!==void 0?{title:n.unsure}:{},style:{position:"absolute",left:w.x,top:w.y,...n.unsure!==void 0?{pointerEvents:"auto"}:{}},children:n.said},n.key):null})})]})}export{xe as RecordLinks};
@@ -0,0 +1 @@
1
+ import{b as mn,c as gn,d as ae,e as yn,f as ne,h as je,i as ze,n as hn,r as se}from"./chunk.KGW75Z5L.js";import{B as ue,Ba as Je,C as ie,Db as W,Dc as ln,Ea as Ye,F as qe,Ga as Qe,H as Be,Ib as on,J as _e,Jb as an,K as He,Ka as Oe,La as xe,Lb as sn,Oc as fn,Pc as pn,Qb as dn,Qc as Se,Ra as Xe,Rc as un,Sc as Ae,Ua as en,Vb as cn,b as Pe,c as Me,d as Fe,da as we,e as V,ea as Ue,eb as nn,g as ce,gb as tn,h as F,i as Ne,j as Ce,k as le,l as Ie,lb as Re,m as Ke,mb as rn,na as We,o as Ve,p as fe,q as be,v as Ze,x as oe,ya as ve,z as pe}from"./chunk.VSCIXAHN.js";function kn(e){if(typeof e=="string")return{form:"string",light:e};if(typeof e!="object"||e===null)return;let a=e,n=w=>typeof a[w]=="string"?a[w]:void 0,t=n("light")??n("src");if(t===void 0)return;let[i,f,m]=[n("dark"),n("alt"),n("darkFallback")];return{form:n("light")!==void 0?"light":"src",light:t,...i!==void 0?{dark:i}:{},...f!==void 0?{alt:f}:{},...m!==void 0?{darkFallback:m}:{}}}function qn(e,a){let n=e.brand??{},t=n.ground,i=n.accent?Ae(n.accent,t):void 0;t&&un(i?.ok?i.schemes:Se(t),n.accent)&&(a.push(ze("brand","brand.ground","words would not read on that page background, so the app keeps Graview's","pick a lighter ground for the light scheme, a darker one for the dark")),t=void 0,i=n.accent?Ae(n.accent):void 0),i&&!i.ok&&a.push(ze("brand","brand.accent",`that accent cannot make a readable brand, so the app keeps Graview's colors: ${i.why}`,"pick a color further from orange-red, or a darker one"));let f=kn(n.logo),m=n.name??e.name,w=n.typography?Object.fromEntries(Object.entries(n.typography).filter(([,E])=>typeof E=="string"&&pn(E)===null).map(([E,T])=>[E,fn(T)])):void 0;return{name:m,schemes:i?.ok?i.schemes:t?Se(t):ln,...n.currency?{currency:n.currency}:{},...n.locale?{locale:n.locale}:{},...n.timeZone?{timeZone:n.timeZone}:{},...f?{logo:f.dark||f.darkFallback==="invert"?{light:f.light,...f.dark?{dark:f.dark}:{darkFallback:"invert"}}:f.light,logoAlt:f.alt??m}:{},...n.favicon?{favicon:n.favicon}:{},...e.description?{subtitle:e.description}:{},...n.subtitle===!1?{subtitleDrawn:!1}:{},...w?{typography:w}:{},...n.shape?{shape:n.shape}:{},...n.accents?{accents:n.accents}:{},...n.scheme?{scheme:n.scheme}:{}}}function bn(e){let{currency:a,locale:n,timeZone:t}=e.brand??{};return{...a?{currency:a}:{},...n?{locale:n}:{},...t?{timeZone:t}:{}}}var zn=Symbol.for("@graview/core:typed-field"),wn=(e,a)=>(/^(phone|place|duration)$/.test(a)&&(ie(e)[zn]=a),e),vn=/^(?=(?:\D*\d){3})\+?[\d ()./-]+(?: *(?:ext\.?|x|#) *\d+)?$/i;function On(e){let a=F().check(V(300),pe(t=>Ye(t,e)!==void 0,`a record of ${e.kinds.join(" or ")} in ${e.address}, as "<kind>:<id>"`)),n=e.cardinality==="one"?a:fe(a).check(V(200));return Qe(e.description?n.check(ue(e.description)):n,e)}var Dn=new WeakMap;function xn(e,a){Dn.set(e,a)}var Tn=[{where:"settings[]",was:"honoured",now:"honored",since:"0.1.16"},{where:"pages",was:"overview",now:"scene",since:"0.1.17"}],Z=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Rn(e,a=Tn){if(!Z(e))return{document:e,respelled:[]};let n=[],t=e;for(let i of a)t=Ee(t,i.where.split("."),i,"",n);return{document:t,respelled:n}}function Ee(e,a,n,t,i){if(a.length===0){if(!Z(e)||!Object.hasOwn(e,n.was))return e;i.push(`${t}${n.was}`);let{[n.was]:G,...N}=e;return Object.hasOwn(e,n.now)?N:{...N,[n.now]:G}}if(!Z(e))return e;let[f,...m]=a,w=f.endsWith("[]"),E=w?f.slice(0,-2):f,T=e[E],B=T;if(!w)B=Ee(T,m,n,`${t}${E}.`,i);else if(Array.isArray(T)){let G=T.map((N,J)=>Ee(N,m,n,`${t}${E}.${J}.`,i));B=G.some((N,J)=>N!==T[J])?G:T}return B===T?e:{...e,[E]:B}}var Sn="graview-compiled@1";function Ln(e,a){return e.find(([n,t])=>n!==q&&"ref"in t&&(t.ref==="*"||t.ref.includes(a)))?.[0]}var q="id",me=e=>typeof e=="string"&&/^\$[A-Za-z][A-Za-z0-9]*$/.test(e)?e.slice(1):void 0;function An(e){let a=Object.entries(e.fields),n=t=>["name","title","label"].find(i=>t.some(([f])=>f===i))??t[0]?.[0];return n(a.filter(([,t])=>t.required&&(t.type==="string"||t.type==="text")))??n(a.filter(([,t])=>t.type==="string"))}function jn(e,a,n){let t;switch(e.type){case"string":case"place":t=F().check(V(500));break;case"phone":t=F().check(V(40),ce(vn,"a phone number"));break;case"text":t=F().check(V(2e4)),e.format&&(ie(t)[Symbol.for("@graview/core:markdown")]=1);break;case"number":case"integer":case"duration":{let f=e.min??(e.type==="duration"?0:void 0),m=[...e.type==="number"?[]:[Ie()],...f===void 0?[]:[Me(f)],...e.max===void 0?[]:[Pe(e.max)],...e.step===void 0?[]:[Fe(e.step)]];t=m.length>0?le().check(...m):le();break}case"boolean":t=Ke();break;case"date":t=F().check(ce(Be,"a date like 2026-10-02, or a month (2016-05) or a year (2006) alone"));break;case"datetime":t=F().check(pe(_e,"a date and time like 2026-10-02T14:30:00Z"));break;case"enum":t=Ze(e.options);break;case"list":t=fe(e.of==="number"?le():e.of==="date"?F().check(ce(qe)):e.of==="image"||e.of==="video"||e.of==="file"?ve(e.of):F().check(V(500))).check(V(200));break;case"image":case"video":case"file":t=ve(e.type);break;case"app-link":t=Je();break;case"url":t=Ce();break;case"email":t=Ne();break}let i=e.type==="number"||e.type==="integer";return wn(t,i&&e.format==="duration"?"duration":e.type),e.collaborative!==void 0&&(e.type==="text"||e.type==="string")&&(ie(t)[Symbol.for("@graview/core:collaborative")]=e.collaborative?1:0),e.description&&(t=t.check(ue(e.description))),i&&(e.format==="money"||e.format==="percent"||!e.format&&e.unit)&&dn(t,{...n,...e.format?{format:e.format}:{},...e.unit?{unit:e.unit}:{}}),a?oe(t):t}var de=e=>{throw new W(`there is no record "${e}"`,"invalid")},$n=(e,a)=>"field"in e?jn(e.field,e.optional,a):"ref"in e?cn(e.ref):oe(Ve()),Gn=new WeakMap;var De=(e,a)=>Z(a)&&Object.keys(e??{}).length===Object.keys(a).length&&Object.keys(e??{}).every(n=>Object.hasOwn(a,n));function yt(e,a={}){let n=Z(e)?e.format:void 0;if(n!==Sn)return{ok:!1,findings:[je("compiled-format","format",n===void 0?"this is not a compiled Graview app":`this compiled app is ${JSON.stringify(n)}, and this build reads ${Sn}`,"compile the document instead")]};let t=e,i=Rn(t.document).document,f=i===t.document?t:{...t,document:i},m=Z(i)&&typeof i.name=="string"&&Z(i.kinds)&&De(i.kinds,f.kinds)&&De(i.acts,f.acts)&&De(i.rules,f.rules)&&Array.isArray(f.edges)&&Array.isArray(f.findings),w={ok:!1,findings:[je("compiled-shape","","this compiled app's parts do not match its document","compile the document instead")]};if(!m)return w;try{return Pn(f,a)}catch{return w}}function Pn(e,a={}){let{document:n}=e,t=n.brand?.timeZone,i=a.today??(()=>He(t)),f=new Map(e.edges.map(([g,o])=>[g,o])),m=new Map;for(let[g,o]of Object.entries(n.kinds)){let S=e.kinds[g]?.computed,x=xe(o.edges);m.set(g,{fields:new Set([...Object.keys(o.fields),...x.keys()]),edges:new Map(Object.entries(Oe(o.edges)).map(([L,D])=>[L,D.cardinality??"many"])),...S?{computed:new Map(S)}:{},...x.size>0?{linked:x}:{}})}e.facts&&m.set(gn,{computed:new Map(e.facts)});let w=bn(n),E=new Map,T=Object.entries(n.kinds).map(([g,o])=>{let S={};for(let[r,d]of Object.entries(o.fields))S[r]=jn(d,!d.required,w),d.repeats&&(S[Xe(r)]=oe(en()));for(let[r,d]of xe(o.edges))S[r]=oe(On(d));let{label:x,describe:L,durations:D}=e.kinds[g]??{},P=Object.entries(o.computed??{}).map(([r,d])=>[r,typeof d=="string"?{expr:d}:d]),Y=Object.hasOwn(o.fields,"label")&&!o.fields.label.label&&!/\{\s*label\b/.test(o.label??`{${An(o)??""}}`),_=Object.fromEntries([...Y?[["label","Label"]]:[],...Object.entries(o.fields).filter(([,r])=>r.label).map(([r,d])=>[r,d.label]),...P.filter(([,r])=>r.label).map(([r,d])=>[r,d.label])]),A=Object.keys(_).length>0,y=Object.entries(o.fields).filter(([,r])=>r.type==="enum"&&r.optionLabels&&Object.keys(r.optionLabels).length>0),$=Object.fromEntries(y.map(([r,d])=>[r,R=>typeof R=="string"&&Object.hasOwn(d.optionLabels,R)?d.optionLabels[R]:we(String(R))])),C=y.length>0,M=Object.fromEntries(Object.entries(o.fields).filter(([,r])=>r.default!==void 0).map(([r,d])=>[r,d.default]));E.set(g,M);let H=Object.fromEntries(Object.entries(Oe(o.edges)).map(([r,{renamedFrom:d,...R}])=>[r,R])),I=Object.entries(o.fields).flatMap(([r,d])=>d.aliases?[[r,d.aliases]]:[]),j=r=>o[r]?{[r]:o[r]}:{};return Ue(g,{fields:be(S),edges:H,...j("plural"),...j("noun"),...j("aliases"),...I.length>0?{fieldAliases:Object.fromEntries(I)}:{},...j("description"),...x?{label:r=>se(x,{node:r,kinds:m,today:i(),money:w})||r.id}:{},...L?{describe:r=>se(L,{node:r,kinds:m,today:i(),money:w})}:{},...j("lifecycle"),...j("figure"),...j("fieldRoles"),...j("people"),archives:o.archives,...o.tidying?{tidying:o.tidying}:{},...P.length>0?{computed:Object.fromEntries(P.map(([r,d])=>[r,Mn(d,D?.includes(r)??!1,w)??o.computed[r]]))}:{},...A||C||o.glance||o.page?{display:{...A?{labels:_}:{},...C?{format:$}:{},...o.glance?{glance:[...o.glance]}:{},...o.page?{page:o.page}:{}}}:{},...Object.keys(M).length>0?{defaults:M}:{},...e.kinds[g]?.keptInStep?{keptInStep:e.kinds[g].keptInStep}:{}})}),B=nn(T,n.computed);function G(g){return B.tryDefinition(g.kind)?.label?.(g)??g.id}let N=g=>({id:"",kind:g,...E.get(g)}),J=[];for(let[g,o]of Object.entries(n.acts??{})){let S=e.acts[g],{title:x,effects:L,guard:D,refusal:P,destructive:Y,idempotent:_,creates:A,connects:y,severs:$,writes:C,writesOther:M,sets:H}=S,I=new Map(S.args),j={};for(let[c,b]of I)j[c]=$n(b,w);let r=[o.on??[]].flat(),d=new Map(S.exprs),R=L.find(c=>"create"in c),Q=(c,b,p,v=null)=>{if(Z(c)&&"expr"in c)return ne(d.get(c.expr),{graph:p,subject:v,kinds:m,bindings:b,today:i()});let k=me(c);return k===void 0?typeof c=="string"&&c.startsWith("$$")?c.slice(1):c:k==="now"?new Date().toISOString():k==="today"?i():b[k]},$e=(c,b)=>{if(!R)return"";let p=n.kinds[R.create].fields,v=N(R.create),k=[];for(let[O,te]of Object.entries(R.set??{})){try{v[O]=Q(te,c,b)??v[O]}catch{}let X=me(te);X&&c[X]!==void 0&&k.push(O)}let K=G(v).trim(),U=k.filter(O=>v[O]!==!1&&p[O].type!=="text"&&!(/[^]{41}/.test(v[O])||/ .*[.!?]$/.test(v[O])&&!/[ .][A-Z]\w{0,3}\.$/.test(v[O]))&&G({...v,[O]:void 0}).trim()===K).map(O=>v[O]===!0?p[O].label??we(O):hn(v[O],p[O].format,i(),[],w));return K&&U.length>0?`${K} (${U.join(", ")})`:K};J.push(sn(g,{input:be(j),title:x,...o.description?{description:o.description}:{},...o.fromTheOtherEnd?{fromTheOtherEnd:o.fromTheOtherEnd}:{},...I.has(q)?{subject:{kinds:r.length>0?r:"*",arg:q}}:{},...Y?{destructive:!0}:{},..._?{idempotent:!0}:{},...A.length>0?{creates:A}:{},...y.length>0?{connects:y}:{},...$.length>0?{severs:$}:{},writes:C,...Object.keys(M).length>0?{writesOther:M}:{},...Object.keys(H).length>0?{sets:H}:{},...D?{allowedOn:(c,b)=>{let p=c.getNode(b);if(!p||r.length>0&&!r.includes(p.kind))return!1;try{return ne(D,{graph:c,subject:p,kinds:m,bindings:{},today:i()})===!0}catch{return!1}}}:{},describe:(c,b)=>{let p=typeof c[q]=="string"?b.getNode(c[q]):void 0,v=p?G(p):$e(c,b);return v?`${x}: ${v}`:x},apply(c,b){let p=c.graph,v=typeof b[q]=="string"?b[q]:void 0,k=v?p.getNode(v):void 0;if(v&&!k&&de(v),k&&r.length>0&&!r.includes(k.kind))throw new W(`"${x}" acts on ${r.join(" or ")}, not on ${We(k.kind)}`,"invalid");let K={};for(let[s,l]of Object.entries(b))l!==void 0&&(K[s]=l);if(D&&k){let s;try{s=ne(D,{graph:p,subject:k,kinds:m,bindings:K,today:i()})}catch(l){throw l instanceof ae?new W(`"${x}" could not be judged: ${l.sentence}`):l}if(s!==!0)throw new W(P?se(P,{node:k,kinds:m,graph:p,bindings:K,today:i(),money:w}):`"${x}" is not allowed for ${G(k)} right now`)}let U=new Map,O=s=>p.has(s)||[...U.values()].includes(s),te=new Set,X=s=>{let l=tn(s);te.has(l)||(te.add(l),c.removeEdge(s))},ee=(s,l)=>{let u=me(s);if(u==="subject")return v;if(u==="me"){let h=c.me;if(h&&n.kinds[p.getNode(h)?.kind]?.people)return h;throw new W(`"${x}" is done as you, and you have no record here`)}if(U.has(u))return U.get(u);try{return Q(s,K,p,l??k??null)}catch(h){throw h instanceof ae?new W(`"${x}" could not work out a value: ${h.sentence}`):h}};for(let s of L)if("create"in s){let l=n.kinds[s.create],u=N(s.create);for(let[he,ke]of Object.entries(s.set??{})){let Ge=ee(ke,void 0);Ge!==void 0&&(u[he]=Ge)}let h=An(l),z=String((h&&u[h])??s.create),ye=an(z,s.create,u,(he,ke)=>on(n.policy?.sees,he,ke)),re=c.freshId(ye?s.create:z,s.create,u);c.addNode({...u,id:re}),s.as&&U.set(s.as,re)}else if("connect"in s||"sever"in s){let l="connect"in s?s.connect:s.sever,u=String(ee(s.from,void 0)??""),h=String(ee(s.to,void 0)??"");if(O(u)||de(u),O(h)||de(h),"connect"in s){if(f.get(l)?.cardinality==="one")for(let z of p.out(u,l))z.id!==h&&X({kind:l,from:u,to:z.id});p.out(u,l).some(z=>z.id===h)||c.addEdge({kind:l,from:u,to:h})}else X({kind:l,from:u,to:h})}else if("set"in s){let l=String(ee(s.target??"$subject",void 0)??""),u=p.getNode(l);!u&&!O(l)&&de(l);let h={};for(let[z,ye]of Object.entries(s.set)){let re=ee(ye,u);re!==void 0&&(h[z]=re)}Object.keys(h).length>0&&c.patchNode(l,h)}else if("remove"in s){let l=String(ee(s.remove,void 0)??"");p.has(l)||de(l),c.removeNode(l)}else if("replace"in s&&k){let l=b.to;for(let u of s.replace){let h=f.get(u)?.from.includes(k.kind)??!0;for(let z of h?p.out(k.id,u):p.in(k.id,u))u===s.keep&&z.id===l||X(h?{kind:u,from:k.id,to:z.id}:{kind:u,from:z.id,to:k.id})}}}}))}let Te=[];for(let[g,o]of Object.entries(n.rules??{})){let{title:S,require:x,when:L,says:D}=e.rules[g],P=o.repairs??[],Y=(A,y,$=i(),C)=>{let M=[],H={graph:A,subject:y,kinds:m,today:$,...C?{linked:C}:{},onUnread:r=>M.push(r)},I;try{if(L&&ne(L,H)!==!0)return[];if(I=ne(x,H)===!0,!I&&M.length>0)throw new ae(`it reads ${mn(M[0])}`,0)}catch(r){throw r instanceof yn?new rn(r.sentence):r instanceof ae?new Error(r.sentence):r}if(I)return[];let j=P.flatMap(r=>{let d=n.acts?.[r.act],R={},Q=y&&d?.on&&d.fromTheOtherEnd&&![d.on].flat().includes(y.kind)?Ln(e.acts[r.act].args,y.kind):void 0;Q?R[Q]=y.id:y&&(d?.on||/^(edit|remove|archive|unarchive|merge|skip|detach|split)-/.test(r.act))&&(R[q]=y.id);for(let[b,p]of Object.entries(r.args??{}))R[b]=me(p)==="subject"?y?.id:p;let c=(d?e.acts[r.act].args:[]).filter(([b,p])=>p.required&&R[b]===void 0).map(([b])=>b);return[{mutation:r.act,label:r.label??(Q?d.fromTheOtherEnd:d?.title)??r.act.replace(/-/g," "),args:R,...c.length>0?{missing:c}:{}}]});return[{invariant:g,...y?{subjectId:y.id}:{},label:S,message:D?se(D,{node:y,kinds:m,graph:A,today:$,money:w}):y?`${G(y)}: ${S}`:S,nodeIds:y?[y.id]:[],repairs:j}]},_={label:S,shape:{over:o.over,require:x,when:L,says:D,declared:n.kinds,money:w,kinds:m,today:i},judgment:{require:o.require,...o.when?{when:o.when}:{},...o.says?{says:o.says}:{}},...o.description?{description:o.description}:{},...P.length>0?{repairs:P.map(A=>A.act)}:{}};Te.push(o.over==="graph"?Re(g,{scope:"graph",..._,evaluate:({graph:A,today:y,context:$})=>Y(A,null,y,$?.linked)}):Re(g,{scope:{kind:o.over},..._,evaluate:({graph:A,subject:y,today:$,context:C})=>Y(A,y,$,C?.linked)}))}let Le=n.policy&&{...n.policy,...n.roles?{roles:n.roles}:{}},ge={name:n.name,schema:B,mutations:J,invariants:Te,...Le?{policy:Le}:{},...e.brand?{brand:e.brand}:{},...n.modules?{modules:n.modules}:{},...n.lenses?{lenses:n.lenses}:{},...n.pages?{pages:n.pages}:{},...n.settings?{settings:n.settings}:{},...n.connections?{connections:n.connections}:{},...n.forms?{forms:n.forms}:{},...n.publishing?{publishing:n.publishing}:{},...n.purpose?{purpose:n.purpose}:{},...e.viewSpecs?{viewSpecs:e.viewSpecs}:{},...e.home?{home:e.home}:{},version:n.version??1};return xn(ge,n),Gn.set(ge,e),{ok:!0,app:ge,document:n,findings:e.findings,sights:n.policy?.sees,kinds:m}}function Mn(e,a,n){let t=a||e.format==="duration",i=e.format==="money"||e.format==="percent"||!e.format&&e.unit!==void 0;if(!(!t&&!i))return{...e,...t?{as:"duration"}:{},...i?{amount:{...n,...e.format?{format:e.format}:{},...e.unit?{unit:e.unit}:{}}}:{}}}export{Rn as a,qn as b,Sn as c,q as d,me as e,An as f,yt as g,Pn as h};
@@ -1 +1 @@
1
- import{a as I}from"./chunk.AXXYJCSW.js";import{a as ie,b as de,c as se,d as le,e as V,f as L,g as ue}from"./chunk.N4LOI3YA.js";import{a as ye}from"./chunk.RKZ4J3H2.js";import{c as T,e as ae,f as fe}from"./chunk.HKINU7VO.js";import{a as j,b as ee,c as ne,d as re,f as E,m as te,n as b,o as oe,p as B,q as v}from"./chunk.YGZCESXY.js";import{b as x,d as pe,e as me,g as ce,i as ge,j as he,k as be}from"./chunk.2FOIJ5ID.js";import{C as P,Fa as Y,K as H,Lb as q,Mb as Q,Nb as C,T as K,W as F,aa as J,ga as X,ma as N,oa as Z,ta as G,ua as A,va as z,wa as O,xa as M}from"./chunk.X3MMJ3QC.js";var we=e=>e.caption?.trim()||e.name,_=e=>A(e)?`${we(e)}, ${z(e)}`:we(e);function tn(e){let n=Math.max(0,Math.round(e)),t=a=>String(a).padStart(2,"0"),r=Math.floor(n/3600),o=Math.floor(n%3600/60);return r>0?`${r}:${t(o)}:${t(n%60)}`:`${o}:${t(n%60)}`}function Pe(e){let n=e?.fields?.shape??{};return Object.keys(n).filter(t=>{let r=P(n[t]);for(;r?.innerType;)r=P(r.innerType);return M(n[t])!==void 0||r?.type==="array"&&M(r.element)!==void 0})}function on(e,n){for(let t of Pe(n)){let r=O(e[t]).find(o=>G(o)||A(o));if(r)return r}}var k=e=>{try{return e()}catch{return null}},Te=e=>typeof e=="string"&&ie.includes(e);function Fe(e){if(e!==void 0)return Te(e)?e:e&&typeof e=="object"&&typeof e.expr=="string"?{expr:k(()=>T(e.expr))}:"neutral"}var Ne=4;function Me(e){let n=typeof e.list=="string"?k(()=>T(e.list)):null,t=e.sort,r=typeof t=="string"?t:t&&typeof t=="object"&&typeof t.by=="string"?t.by:void 0,o=t&&typeof t=="object"?t.direction:void 0,a=n,d;if(n&&r!==void 0)if(o==="choices")d=r;else{let y=k(()=>T(r));a=y?{t:"call",fn:"sort",args:[n,y,{t:"lit",value:o==="desc"?"desc":"asc",at:0}],at:0}:null}let l=typeof e.limit=="number"&&Number.isInteger(e.limit)&&e.limit>=1?Math.min(e.limit,V):void 0,i=e.group,s=typeof i=="string"?i:i&&typeof i=="object"&&typeof i.by=="string"?i.by:void 0,f=i&&typeof i=="object"&&i.headings&&typeof i.headings=="object"?i.headings:{};return{t:"list",source:a,...d?{choiceOrder:d}:{},...l?{limit:l}:{},...s?{group:{by:s,headings:Object.fromEntries(Object.entries(f).filter(y=>typeof y[1]=="string"))}}:{},...typeof e.empty=="string"?{empty:e.empty}:{},as:e.as==="card"?"card":"row"}}function Se(e,n=1,t=""){if(!Array.isArray(e)||n>Ne)return[];let r={};return e.flatMap(o=>{if(!o||typeof o!="object"||Array.isArray(o))return[];let a=o,d=p=>typeof p=="string"?k(()=>ae(p)):null,l=p=>typeof p=="string"?k(()=>T(p)):null,i=Fe(a.tone),s=typeof a.label=="string"?a.label:void 0,f=p=>Object.hasOwn(a,p),y=typeof a.currency=="string"&&/^[A-Z]{3}$/.test(a.currency)?a.currency:void 0,u=f("list")?"list":f("headline")?"headline":typeof a.figure=="string"?"number":Ce.find(f);if(!u)return[];let m=r[u]=(r[u]??0)+1,c=a.key,R=typeof c=="string"&&c?c:`${t}${u}.${m}`;return[{...(()=>{switch(u){case"list":return Me(a);case"number":{let p=se.includes(a.as)?a.as:void 0,W=le.includes(a.emphasis)?a.emphasis:void 0;return{t:u,value:l(a.figure),...p?{as:p}:{},...y?{currency:y}:{},...s?{label:d(s)}:{},...W?{emphasis:W}:{}}}case"headline":case"title":return{t:u,parts:d(a[u])};case"text":{let p=a.lines;return{t:u,parts:d(a[u]),...i?{tone:i}:{},...typeof p=="number"&&Number.isInteger(p)&&p>=0?{lines:p}:{}}}case"badge":return{t:u,parts:d(a[u]),...i?{tone:i}:{}};case"field":{let p=de.includes(a.as)?a.as:void 0;return{t:u,field:String(a.field),...p?{as:p}:{},...y?{currency:y}:{},...s?{label:s}:{}}}case"image":return{t:u,field:String(a.image),as:a.as==="gallery"?"gallery":"thumb",...s?{label:s}:{}};case"progress":{let p=a.progress??{};return{t:u,value:l(p.value),max:l(p.max),...s?{label:d(s)}:{}}}case"group":return{t:u,blocks:Se(a.group,n+1,`${R}.`),direction:a.direction==="row"?"row":"column"};case"when":return{t:u,when:l(a.when),show:Se(a.show,n+1,`${R}.`)};default:return{t:u}}})(),key:R}]})}var Ce=["title","text","badge","field","image","progress","group","when","divider","figure"],g="\u2014",Ve=500;function w(e,n){if(!e)return{ok:!1,problem:"an expression that does not parse"};try{return{ok:!0,value:E(e,{graph:n.graph??te,subject:n.node,kinds:n.kinds,today:n.today,budget:n.budget??Ve})}}catch(t){return{ok:!1,problem:t instanceof Error?t.message:String(t)}}}var Le=(e,n,t)=>!e.format&&e.expr?.t==="ident"&&typeof t=="string"&&n.fields[e.expr.name]?.format==="markdown";function S(e,n,t){if(!e)return{text:g,problem:"a template that does not parse"};let r,o;return{text:e.map(d=>{if(d.text!==void 0)return d.text;let l=w(d.expr??null,n);if(!l.ok)return r??=`{${d.source??""}}: ${l.problem}`,g;if(Le(d,n,l.value))return n.glance?pe(l.value,{markdown:!0}):t&&e.length===1?(o=!0,l.value):me(l.value);let i=!d.format&&d.expr?.t==="ident"&&typeof l.value=="number"?Ge(n,d.expr.name):void 0;return oe(d,i?C(l.value,i):b(l.value,d.format,n.today,d.formatArgs,n.money,v(n.schema)))}).join(""),...r?{problem:r}:{},...o?{markdown:o}:{}}}var Ie=" \xB7 ";function _e(e,n){if(!e||!n.node)return;let t=[[]];for(let d of e){if(d.text===void 0){t[t.length-1].push(d);continue}d.text.split(Ie).forEach((i,s)=>{s>0&&t.push([]),i!==""&&t[t.length-1].push({text:i})})}if(t.length<2)return;let r=d=>{let[l]=d;if(!(d.length!==1||!l||l.format||l.expr?.t!=="ident"))return n.fields[l.expr.name]?.type==="enum"?l.expr.name:void 0},o=0,a=t.flatMap(d=>{let l=r(d);if(l){let s=Object.hasOwn(n.node,l)?n.node[l]:void 0;return s==null||s===""?[]:(o++,[{text:x(n.definition,l,s),field:l}])}let i=S(d,n).text.trim();return i===""||i===g?[]:[{text:i}]});return o>0?a:void 0}function Re(e,n){if(e===void 0)return;if(typeof e=="string")return e;let t=w(e.expr,n);return t.ok&&Te(t.value)?t.value:"neutral"}function De(e){if(typeof e=="string")try{let n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"?n.href:void 0}catch{return}}var xe=(e,n)=>{let t=e.fields[n]?.type;return t==="phone"||t==="place"||t==="duration"?t:ge(e.definition,n)},Ge=(e,n)=>q(e.definition?.fields?.shape?.[n])??ce(e.definition,n);function $e(e,n,t,r,o){if(n==null||n==="")return g;if(typeof n=="boolean")return n?"yes":"no";if(r)return b(n,r,t.today,[],o?{...t.money,currency:o}:t.money);let a=t.fields[e];if(t.definition?.display?.format?.[e])return x(t.definition,e,n);let d=he(xe(t,e),n,t.money?.locale);if(d!==void 0)return d;if(a?.type==="date")return b(n,"date",t.today,[],t.money);if(a?.type==="datetime"&&typeof n=="string")return K(n,t.money?.locale,t.money?.timeZone);if(a?.type==="enum"&&typeof n=="string")return x(t.definition,e,n);let l=typeof n=="number"?Ge(t,e):void 0;if(l)return C(n,l);if(typeof n=="number")return F(n,t.money?.locale,{});let i=O(n);return i[0]?i.map(_).join(", "):Array.isArray(n)?n.map(s=>String(s)).join(", "):typeof n=="object"?g:String(n)}function Ue(e,n,t,r,o){return typeof e!="number"?String(e):n==="money"?Q(e,t?{...o,currency:t}:o):n==="percent"?b(e,n,r,[],o):F(e,o?.locale)}var h=(e,n)=>n?{...e,problem:n}:e;function ke(e){return e.firstHeading===void 0?e:{...e,firstHeading:void 0}}function We(e,n,t){switch(e.t){case"title":{let r=S(e.parts,n);return h({t:"title",text:r.text},r.problem)}case"text":{let r=S(e.parts,n,!0),o=Re(e.tone,n),a=n.glance&&!r.problem?_e(e.parts,n):void 0;return h({t:"text",text:r.text,...o?{tone:o}:{},...e.lines!==void 0?{lines:e.lines}:{},...r.markdown?{markdown:r.markdown}:{},...a?{runs:a}:{}},r.problem)}case"badge":{let r=S(e.parts,n);return h({t:"badge",text:r.text,tone:Re(e.tone,n)??"neutral"},r.problem)}case"field":{let r=e.label??N(n.definition,e.field);if(!n.node)return{t:"field",field:e.field,label:r,text:g,problem:`"${e.field}" names a field, and these blocks are about no one record`};let o=e.as===void 0?n.kinds.get(n.node.kind)?.linked?.get(e.field):void 0;if(o){let y=Y(Object.hasOwn(n.node,e.field)?n.node[e.field]:void 0,o);return{t:"field",field:e.field,label:r,text:y.length>0?"linked record":g,...y.length>0?{linked:{relation:o,refs:y}}:{}}}let a=n.kinds.get(n.node.kind)?.computed?.has(e.field),d,l;if(a){let y=w({t:"ident",name:e.field,at:0},n);y.ok?d=y.value!==null&&typeof y.value=="object"?b(y.value,void 0,n.today,[],n.money,v(n.schema)):y.value:l=y.problem}else d=Object.hasOwn(n.node,e.field)?n.node[e.field]:void 0;let i=e.as!==void 0?void 0:n.fields[e.field]?.type==="url"?De(d):be(xe(n,e.field),d),s=k(()=>$e(e.field,d,n,e.as,e.currency))??g,f=n.fields[e.field]?.type==="app-link"&&e.as===void 0&&typeof d=="string"?d:void 0;return h({t:"field",field:e.field,label:r,text:s,...i?{href:i}:{},...f?{app:f}:{}},l)}case"image":{let r=O(n.node&&Object.hasOwn(n.node,e.field)?n.node[e.field]:null),o=e.as==="gallery"?r:r.filter(a=>G(a)||A(a)).slice(0,1);return{t:"image",field:e.field,label:e.label??N(n.definition,e.field),as:e.as,files:o,text:o.map(_).join(", ")||g}}case"progress":{let r=w(e.value,n),o=w(e.max,n),a=e.label?S(e.label,n):{text:"Progress"},d=e.label?B(e.label,a.text):a.text,l=r.ok?o.ok?a.problem:o.problem:r.problem;return r.ok&&o.ok&&typeof r.value=="number"&&typeof o.value=="number"&&Number.isFinite(r.value)&&Number.isFinite(o.value)&&o.value>0?h({t:"progress",label:d,value:r.value,max:o.value,text:`${b(r.value,void 0,n.today)} of ${b(o.value,void 0,n.today)}`},l):h({t:"progress",label:d,text:g},l)}case"group":return{t:"group",direction:e.direction,blocks:Ae(e.blocks,ke(n))};case"when":{let r=w(e.when,n),o=r.ok&&r.value===!0;return h({t:"when",shown:o,blocks:o?Ae(e.show,ke(n)):[]},r.ok?void 0:r.problem)}case"divider":return{t:"divider"};case"figure":return{t:"figure"};case"headline":{let r=S(e.parts,n),o=Math.min(6,Math.max(1,(t?n.firstHeading:void 0)??n.heading??3));return h({t:"headline",level:o,text:e.parts?B(e.parts,r.text):r.text},r.problem)}case"number":{let r=w(e.value,n),o=!r.ok||r.value===null||typeof r.value=="object"?g:Ue(r.value,e.as,e.currency,n.today,n.money),a=e.label?S(e.label,n):void 0;return h({t:"number",text:o,...a&&e.label?{label:B(e.label,a.text)}:{},...e.emphasis?{emphasis:e.emphasis}:{}},r.ok?a?.problem:r.problem)}case"list":return Ke(e,n)}}function Ae(e,n){let t=e.findIndex(r=>r.t==="headline");return e.map((r,o)=>({...We(r,n,o===t),key:r.key}))}function Oe(e,n){let t=n.trim().toLowerCase();return e.some(r=>{switch(r.t){case"title":case"headline":return r.text.trim()!=="";case"text":case"badge":return t!==""&&r.text.toLowerCase().includes(t);case"group":return Oe(r.blocks,n);case"when":return r.shown&&Oe(r.blocks,n);default:return!1}})}var He=new Set(["every","some","sum","min","max","sort"]);function jn(e,n){let t=new Set,r=new Set,o=i=>{if(i)switch(i.t){case"ident":t.add(i.name);return;case"list":i.items.forEach(o);return;case"member":return o(i.object);case"unary":return o(i.operand);case"binary":return o(i.left),o(i.right);case"where":return o(i.set);case"call":i.args.forEach((s,f)=>{f===1&&He.has(i.fn)||o(s)});return;default:return}},a=i=>{for(let s of i??[])o(s.expr)},d=(i,s)=>{i.forEach((f,y)=>{let u=s[y];if(u)switch(f.t){case"field":case"image":t.add(f.field);return;case"title":case"text":case"badge":case"headline":a(f.parts);return;case"number":o(f.value),a(f.label);return;case"progress":o(f.value),o(f.max);return;case"group":u.t==="group"&&d(f.blocks,u.blocks);return;case"when":u.t==="when"&&u.shown&&d(f.show,u.blocks);return;case"list":if(u.t==="list")for(let m of u.members)r.add(m.id);return;default:return}})};d(e,n);let l=n[0];return{fields:t,records:r,...e[0]?.t==="title"&&l?.t==="title"?{title:l.text}:{}}}function Ke(e,n){let t=Math.min(6,(n.heading??3)+1),r=w(e.source,n);if(!r.ok)return{t:"list",as:e.as,failed:!0,members:[],headingLevel:t,more:0,problem:r.problem};let o=r.value,a=o instanceof j?o.nodes:o!==null&&typeof o=="object"&&!Array.isArray(o)?[o]:[];e.choiceOrder&&n.schema&&(a=Je(a,e.choiceOrder,n.schema));let d=a.length,l=a.slice(0,e.limit??V),i=l.slice(0,L),s=l.slice(L),f=(e.limit===void 0?d:l.length)-i.length,y=c=>e.group&&n.schema&&c.length>0?Xe(c,e.group,n.schema,n.graph):void 0,u=y(i),m=s.length>0?y(l):void 0;return{t:"list",as:e.as,failed:!1,members:i,...s.length>0?{rest:s}:{},...u?{groups:u}:{},...m?{everyGroup:m}:{},headingLevel:t,...i.length===0&&e.empty?{empty:e.empty}:{},more:f,total:d}}function D(e,n,t){let r=e.tryDefinition(n)?.fields?.shape,o=r&&Object.hasOwn(r,t)?I(r[t]):void 0;return o?.type==="enum"?o.options??[]:[]}var $=(e,n)=>Object.hasOwn(e,n)?e[n]:void 0;function Je(e,n,t){let r=o=>{let a=D(t,o.kind,n).indexOf(String($(o,n)));return a<0?Number.MAX_SAFE_INTEGER:a};return e.map((o,a)=>({node:o,i:a,rank:r(o)})).sort((o,a)=>o.rank-a.rank||o.i-a.i).map(o=>o.node)}function Xe(e,n,t,r){let o=e.some(i=>D(t,i.kind,n.by).length>0)?void 0:ue(n.by);if(o&&r)return Ze(e,o,n.headings,t,r);let a=[];for(let i of e)for(let s of D(t,i.kind,n.by))a.includes(s)||a.push(s);let d=[];for(let i of a){let s=e.filter(y=>$(y,n.by)===i);if(s.length===0)continue;let f=t.tryDefinition(s[0].kind);d.push({value:i,heading:n.headings[i]??J(x(f,n.by,i)),members:s})}let l=e.filter(i=>!a.includes(String($(i,n.by))));return l.length>0&&d.push({value:null,members:l}),d}function Ze(e,n,t,r,o){let a=u=>n.way??(Object.hasOwn(r.tryDefinition(u.kind)?.edges??{},n.edge)?"out":"in"),d=new Map,l=[],i=v(r),s;for(let u of e){let m=a(u)==="out"?o.out(u.id,n.edge):o.in(u.id,n.edge);m.length===0&&l.push(u);for(let c of m){s??=c.kind;let R=d.get(c.id)??{node:c,members:[]};R.members.push(u),d.set(c.id,R)}}let f=[...d.values()].map(({node:u,members:m})=>({value:u.id,heading:t[u.id]??i(u),members:m})).sort((u,m)=>u.heading.localeCompare(m.heading,void 0,{numeric:!0}));!s&&e[0]&&a(e[0])==="out"&&(s=(r.tryDefinition(e[0].kind)?.edges??{})[n.edge]?.to?.[0]);let y=s&&s!=="*"?Z(r.tryDefinition(s),s):void 0;return l.length>0&&f.push({value:null,...y?{heading:`No ${y}`}:{},members:l}),f}function je(e){return e.t==="list"||e.t==="headline"||e.t==="number"||e.t==="image"&&e.as==="gallery"?!0:e.t==="group"?e.blocks.some(je):e.t==="when"?e.show.some(je):!1}function Ee(e,n){let t=e.tryDefinition(n)?.fields?.shape??{},r={};for(let[o,a]of Object.entries(t)){let d=I(a);d&&(r[o]=d)}return r}var Be=new WeakMap;function U(e){let n=Be.get(e);return n||Be.set(e,n=ye(e)),n}function ze(e,n,t,r={}){let o=U(e),a={},d={},l=i=>{if(i instanceof j)return i.nodes.map(s=>l(s));if(Array.isArray(i))return i.map(s=>l(s));if(i!==null&&typeof i=="object"){let s=i;return{id:s.id,kind:s.kind,label:X(e.tryDefinition(s.kind),s)}}return i};for(let[i,s]of o.get(t?t.kind:ne)?.computed??[])try{let f=[],y=E(s,{graph:n,subject:t,kinds:o,...r.today?{today:r.today}:{},...r.budget?{budget:r.budget}:{},...r.linked?{linked:r.linked}:{},onUnread:u=>f.push(u)});f.length>0&&(y===null||y instanceof j&&y.nodes.length===0)?d[i]=ee(f[0]):a[i]=l(y)}catch(f){if(!(f instanceof re))throw f;d[i]=f.sentence}return{values:a,refused:d}}function vn(e,n,t){let{values:r}=ze(e,n,t);if(Object.keys(r).length===0)return t;let o=a=>Array.isArray(a)?a.map(o):a!==null&&typeof a=="object"?a.label:a;return{...t,...Object.fromEntries(Object.entries(r).map(([a,d])=>[a,o(d)]))}}function Pn(e,n){return[...fe(e.tryDefinition(n)).keys()]}var Ye=500,qe=2e4,ve=new WeakMap;function Qe(e,n){let t=ve.get(e);t||ve.set(e,t=new Map);let r=t.get(n);return r||t.set(n,r=Ee(e,n)),r}function Vn(e,n,t,r={}){if(n&&typeof e.seenBy!="function")throw new TypeError("blockContextFor: a seat is read from a store (its `seenBy`); a bare { graph, schema } is read as it is handed, with no principal");let o=n?e.seenBy(n):e,a=n&&t?o.graph.getNode(t.id)??null:t,d=o.schema,l=a&&d.tryDefinition(a.kind),i=!a||(r.slot??"page")==="page",{money:s,firstHeading:f}=r;return{node:a,graph:o.graph,schema:d,kinds:U(d),fields:a?Qe(d,a.kind):{},definition:l||void 0,today:r.today??o.today?.()??H(s?.timeZone),money:s,heading:r.heading??(i?2:3),firstHeading:f,budget:r.budget??(i?qe:Ye),...i?{}:{glance:!0}}}export{we as a,tn as b,Pe as c,on as d,Se as e,Ae as f,Oe as g,jn as h,je as i,U as j,ze as k,vn as l,Pn as m,Vn as n};
1
+ import{a as I}from"./chunk.TY4GQJKC.js";import{a as ie,b as de,c as se,d as le,e as V,f as L,g as ue}from"./chunk.6ZQAR5ZA.js";import{a as ye}from"./chunk.W3W54DSX.js";import{c as T,e as ae,f as fe}from"./chunk.PI44XMY2.js";import{a as j,b as ee,c as ne,d as re,f as E,m as te,n as b,o as oe,p as B,q as v}from"./chunk.KGW75Z5L.js";import{b as x,d as pe,e as me,g as ce,i as ge,j as he,k as be}from"./chunk.A5PDXNY6.js";import{C as P,Fa as Y,K as H,Rb as q,Sb as Q,T as K,Tb as C,W as F,aa as J,ga as X,ma as N,oa as Z,ta as G,ua as A,va as z,wa as O,xa as M}from"./chunk.VSCIXAHN.js";var we=e=>e.caption?.trim()||e.name,_=e=>A(e)?`${we(e)}, ${z(e)}`:we(e);function tn(e){let n=Math.max(0,Math.round(e)),t=a=>String(a).padStart(2,"0"),r=Math.floor(n/3600),o=Math.floor(n%3600/60);return r>0?`${r}:${t(o)}:${t(n%60)}`:`${o}:${t(n%60)}`}function Pe(e){let n=e?.fields?.shape??{};return Object.keys(n).filter(t=>{let r=P(n[t]);for(;r?.innerType;)r=P(r.innerType);return M(n[t])!==void 0||r?.type==="array"&&M(r.element)!==void 0})}function on(e,n){for(let t of Pe(n)){let r=O(e[t]).find(o=>G(o)||A(o));if(r)return r}}var k=e=>{try{return e()}catch{return null}},Te=e=>typeof e=="string"&&ie.includes(e);function Fe(e){if(e!==void 0)return Te(e)?e:e&&typeof e=="object"&&typeof e.expr=="string"?{expr:k(()=>T(e.expr))}:"neutral"}var Ne=4;function Me(e){let n=typeof e.list=="string"?k(()=>T(e.list)):null,t=e.sort,r=typeof t=="string"?t:t&&typeof t=="object"&&typeof t.by=="string"?t.by:void 0,o=t&&typeof t=="object"?t.direction:void 0,a=n,d;if(n&&r!==void 0)if(o==="choices")d=r;else{let y=k(()=>T(r));a=y?{t:"call",fn:"sort",args:[n,y,{t:"lit",value:o==="desc"?"desc":"asc",at:0}],at:0}:null}let l=typeof e.limit=="number"&&Number.isInteger(e.limit)&&e.limit>=1?Math.min(e.limit,V):void 0,i=e.group,s=typeof i=="string"?i:i&&typeof i=="object"&&typeof i.by=="string"?i.by:void 0,f=i&&typeof i=="object"&&i.headings&&typeof i.headings=="object"?i.headings:{};return{t:"list",source:a,...d?{choiceOrder:d}:{},...l?{limit:l}:{},...s?{group:{by:s,headings:Object.fromEntries(Object.entries(f).filter(y=>typeof y[1]=="string"))}}:{},...typeof e.empty=="string"?{empty:e.empty}:{},as:e.as==="card"?"card":"row"}}function Se(e,n=1,t=""){if(!Array.isArray(e)||n>Ne)return[];let r={};return e.flatMap(o=>{if(!o||typeof o!="object"||Array.isArray(o))return[];let a=o,d=p=>typeof p=="string"?k(()=>ae(p)):null,l=p=>typeof p=="string"?k(()=>T(p)):null,i=Fe(a.tone),s=typeof a.label=="string"?a.label:void 0,f=p=>Object.hasOwn(a,p),y=typeof a.currency=="string"&&/^[A-Z]{3}$/.test(a.currency)?a.currency:void 0,u=f("list")?"list":f("headline")?"headline":typeof a.figure=="string"?"number":Ce.find(f);if(!u)return[];let m=r[u]=(r[u]??0)+1,c=a.key,R=typeof c=="string"&&c?c:`${t}${u}.${m}`;return[{...(()=>{switch(u){case"list":return Me(a);case"number":{let p=se.includes(a.as)?a.as:void 0,W=le.includes(a.emphasis)?a.emphasis:void 0;return{t:u,value:l(a.figure),...p?{as:p}:{},...y?{currency:y}:{},...s?{label:d(s)}:{},...W?{emphasis:W}:{}}}case"headline":case"title":return{t:u,parts:d(a[u])};case"text":{let p=a.lines;return{t:u,parts:d(a[u]),...i?{tone:i}:{},...typeof p=="number"&&Number.isInteger(p)&&p>=0?{lines:p}:{}}}case"badge":return{t:u,parts:d(a[u]),...i?{tone:i}:{}};case"field":{let p=de.includes(a.as)?a.as:void 0;return{t:u,field:String(a.field),...p?{as:p}:{},...y?{currency:y}:{},...s?{label:s}:{}}}case"image":return{t:u,field:String(a.image),as:a.as==="gallery"?"gallery":"thumb",...s?{label:s}:{}};case"progress":{let p=a.progress??{};return{t:u,value:l(p.value),max:l(p.max),...s?{label:d(s)}:{}}}case"group":return{t:u,blocks:Se(a.group,n+1,`${R}.`),direction:a.direction==="row"?"row":"column"};case"when":return{t:u,when:l(a.when),show:Se(a.show,n+1,`${R}.`)};default:return{t:u}}})(),key:R}]})}var Ce=["title","text","badge","field","image","progress","group","when","divider","figure"],g="\u2014",Ve=500;function w(e,n){if(!e)return{ok:!1,problem:"an expression that does not parse"};try{return{ok:!0,value:E(e,{graph:n.graph??te,subject:n.node,kinds:n.kinds,today:n.today,budget:n.budget??Ve})}}catch(t){return{ok:!1,problem:t instanceof Error?t.message:String(t)}}}var Le=(e,n,t)=>!e.format&&e.expr?.t==="ident"&&typeof t=="string"&&n.fields[e.expr.name]?.format==="markdown";function S(e,n,t){if(!e)return{text:g,problem:"a template that does not parse"};let r,o;return{text:e.map(d=>{if(d.text!==void 0)return d.text;let l=w(d.expr??null,n);if(!l.ok)return r??=`{${d.source??""}}: ${l.problem}`,g;if(Le(d,n,l.value))return n.glance?pe(l.value,{markdown:!0}):t&&e.length===1?(o=!0,l.value):me(l.value);let i=!d.format&&d.expr?.t==="ident"&&typeof l.value=="number"?Ge(n,d.expr.name):void 0;return oe(d,i?C(l.value,i):b(l.value,d.format,n.today,d.formatArgs,n.money,v(n.schema)))}).join(""),...r?{problem:r}:{},...o?{markdown:o}:{}}}var Ie=" \xB7 ";function _e(e,n){if(!e||!n.node)return;let t=[[]];for(let d of e){if(d.text===void 0){t[t.length-1].push(d);continue}d.text.split(Ie).forEach((i,s)=>{s>0&&t.push([]),i!==""&&t[t.length-1].push({text:i})})}if(t.length<2)return;let r=d=>{let[l]=d;if(!(d.length!==1||!l||l.format||l.expr?.t!=="ident"))return n.fields[l.expr.name]?.type==="enum"?l.expr.name:void 0},o=0,a=t.flatMap(d=>{let l=r(d);if(l){let s=Object.hasOwn(n.node,l)?n.node[l]:void 0;return s==null||s===""?[]:(o++,[{text:x(n.definition,l,s),field:l}])}let i=S(d,n).text.trim();return i===""||i===g?[]:[{text:i}]});return o>0?a:void 0}function Re(e,n){if(e===void 0)return;if(typeof e=="string")return e;let t=w(e.expr,n);return t.ok&&Te(t.value)?t.value:"neutral"}function De(e){if(typeof e=="string")try{let n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"?n.href:void 0}catch{return}}var xe=(e,n)=>{let t=e.fields[n]?.type;return t==="phone"||t==="place"||t==="duration"?t:ge(e.definition,n)},Ge=(e,n)=>q(e.definition?.fields?.shape?.[n])??ce(e.definition,n);function $e(e,n,t,r,o){if(n==null||n==="")return g;if(typeof n=="boolean")return n?"yes":"no";if(r)return b(n,r,t.today,[],o?{...t.money,currency:o}:t.money);let a=t.fields[e];if(t.definition?.display?.format?.[e])return x(t.definition,e,n);let d=he(xe(t,e),n,t.money?.locale);if(d!==void 0)return d;if(a?.type==="date")return b(n,"date",t.today,[],t.money);if(a?.type==="datetime"&&typeof n=="string")return K(n,t.money?.locale,t.money?.timeZone);if(a?.type==="enum"&&typeof n=="string")return x(t.definition,e,n);let l=typeof n=="number"?Ge(t,e):void 0;if(l)return C(n,l);if(typeof n=="number")return F(n,t.money?.locale,{});let i=O(n);return i[0]?i.map(_).join(", "):Array.isArray(n)?n.map(s=>String(s)).join(", "):typeof n=="object"?g:String(n)}function Ue(e,n,t,r,o){return typeof e!="number"?String(e):n==="money"?Q(e,t?{...o,currency:t}:o):n==="percent"?b(e,n,r,[],o):F(e,o?.locale)}var h=(e,n)=>n?{...e,problem:n}:e;function ke(e){return e.firstHeading===void 0?e:{...e,firstHeading:void 0}}function We(e,n,t){switch(e.t){case"title":{let r=S(e.parts,n);return h({t:"title",text:r.text},r.problem)}case"text":{let r=S(e.parts,n,!0),o=Re(e.tone,n),a=n.glance&&!r.problem?_e(e.parts,n):void 0;return h({t:"text",text:r.text,...o?{tone:o}:{},...e.lines!==void 0?{lines:e.lines}:{},...r.markdown?{markdown:r.markdown}:{},...a?{runs:a}:{}},r.problem)}case"badge":{let r=S(e.parts,n);return h({t:"badge",text:r.text,tone:Re(e.tone,n)??"neutral"},r.problem)}case"field":{let r=e.label??N(n.definition,e.field);if(!n.node)return{t:"field",field:e.field,label:r,text:g,problem:`"${e.field}" names a field, and these blocks are about no one record`};let o=e.as===void 0?n.kinds.get(n.node.kind)?.linked?.get(e.field):void 0;if(o){let y=Y(Object.hasOwn(n.node,e.field)?n.node[e.field]:void 0,o);return{t:"field",field:e.field,label:r,text:y.length>0?"linked record":g,...y.length>0?{linked:{relation:o,refs:y}}:{}}}let a=n.kinds.get(n.node.kind)?.computed?.has(e.field),d,l;if(a){let y=w({t:"ident",name:e.field,at:0},n);y.ok?d=y.value!==null&&typeof y.value=="object"?b(y.value,void 0,n.today,[],n.money,v(n.schema)):y.value:l=y.problem}else d=Object.hasOwn(n.node,e.field)?n.node[e.field]:void 0;let i=e.as!==void 0?void 0:n.fields[e.field]?.type==="url"?De(d):be(xe(n,e.field),d),s=k(()=>$e(e.field,d,n,e.as,e.currency))??g,f=n.fields[e.field]?.type==="app-link"&&e.as===void 0&&typeof d=="string"?d:void 0;return h({t:"field",field:e.field,label:r,text:s,...i?{href:i}:{},...f?{app:f}:{}},l)}case"image":{let r=O(n.node&&Object.hasOwn(n.node,e.field)?n.node[e.field]:null),o=e.as==="gallery"?r:r.filter(a=>G(a)||A(a)).slice(0,1);return{t:"image",field:e.field,label:e.label??N(n.definition,e.field),as:e.as,files:o,text:o.map(_).join(", ")||g}}case"progress":{let r=w(e.value,n),o=w(e.max,n),a=e.label?S(e.label,n):{text:"Progress"},d=e.label?B(e.label,a.text):a.text,l=r.ok?o.ok?a.problem:o.problem:r.problem;return r.ok&&o.ok&&typeof r.value=="number"&&typeof o.value=="number"&&Number.isFinite(r.value)&&Number.isFinite(o.value)&&o.value>0?h({t:"progress",label:d,value:r.value,max:o.value,text:`${b(r.value,void 0,n.today)} of ${b(o.value,void 0,n.today)}`},l):h({t:"progress",label:d,text:g},l)}case"group":return{t:"group",direction:e.direction,blocks:Ae(e.blocks,ke(n))};case"when":{let r=w(e.when,n),o=r.ok&&r.value===!0;return h({t:"when",shown:o,blocks:o?Ae(e.show,ke(n)):[]},r.ok?void 0:r.problem)}case"divider":return{t:"divider"};case"figure":return{t:"figure"};case"headline":{let r=S(e.parts,n),o=Math.min(6,Math.max(1,(t?n.firstHeading:void 0)??n.heading??3));return h({t:"headline",level:o,text:e.parts?B(e.parts,r.text):r.text},r.problem)}case"number":{let r=w(e.value,n),o=!r.ok||r.value===null||typeof r.value=="object"?g:Ue(r.value,e.as,e.currency,n.today,n.money),a=e.label?S(e.label,n):void 0;return h({t:"number",text:o,...a&&e.label?{label:B(e.label,a.text)}:{},...e.emphasis?{emphasis:e.emphasis}:{}},r.ok?a?.problem:r.problem)}case"list":return Ke(e,n)}}function Ae(e,n){let t=e.findIndex(r=>r.t==="headline");return e.map((r,o)=>({...We(r,n,o===t),key:r.key}))}function Oe(e,n){let t=n.trim().toLowerCase();return e.some(r=>{switch(r.t){case"title":case"headline":return r.text.trim()!=="";case"text":case"badge":return t!==""&&r.text.toLowerCase().includes(t);case"group":return Oe(r.blocks,n);case"when":return r.shown&&Oe(r.blocks,n);default:return!1}})}var He=new Set(["every","some","sum","min","max","sort"]);function jn(e,n){let t=new Set,r=new Set,o=i=>{if(i)switch(i.t){case"ident":t.add(i.name);return;case"list":i.items.forEach(o);return;case"member":return o(i.object);case"unary":return o(i.operand);case"binary":return o(i.left),o(i.right);case"where":return o(i.set);case"call":i.args.forEach((s,f)=>{f===1&&He.has(i.fn)||o(s)});return;default:return}},a=i=>{for(let s of i??[])o(s.expr)},d=(i,s)=>{i.forEach((f,y)=>{let u=s[y];if(u)switch(f.t){case"field":case"image":t.add(f.field);return;case"title":case"text":case"badge":case"headline":a(f.parts);return;case"number":o(f.value),a(f.label);return;case"progress":o(f.value),o(f.max);return;case"group":u.t==="group"&&d(f.blocks,u.blocks);return;case"when":u.t==="when"&&u.shown&&d(f.show,u.blocks);return;case"list":if(u.t==="list")for(let m of u.members)r.add(m.id);return;default:return}})};d(e,n);let l=n[0];return{fields:t,records:r,...e[0]?.t==="title"&&l?.t==="title"?{title:l.text}:{}}}function Ke(e,n){let t=Math.min(6,(n.heading??3)+1),r=w(e.source,n);if(!r.ok)return{t:"list",as:e.as,failed:!0,members:[],headingLevel:t,more:0,problem:r.problem};let o=r.value,a=o instanceof j?o.nodes:o!==null&&typeof o=="object"&&!Array.isArray(o)?[o]:[];e.choiceOrder&&n.schema&&(a=Je(a,e.choiceOrder,n.schema));let d=a.length,l=a.slice(0,e.limit??V),i=l.slice(0,L),s=l.slice(L),f=(e.limit===void 0?d:l.length)-i.length,y=c=>e.group&&n.schema&&c.length>0?Xe(c,e.group,n.schema,n.graph):void 0,u=y(i),m=s.length>0?y(l):void 0;return{t:"list",as:e.as,failed:!1,members:i,...s.length>0?{rest:s}:{},...u?{groups:u}:{},...m?{everyGroup:m}:{},headingLevel:t,...i.length===0&&e.empty?{empty:e.empty}:{},more:f,total:d}}function D(e,n,t){let r=e.tryDefinition(n)?.fields?.shape,o=r&&Object.hasOwn(r,t)?I(r[t]):void 0;return o?.type==="enum"?o.options??[]:[]}var $=(e,n)=>Object.hasOwn(e,n)?e[n]:void 0;function Je(e,n,t){let r=o=>{let a=D(t,o.kind,n).indexOf(String($(o,n)));return a<0?Number.MAX_SAFE_INTEGER:a};return e.map((o,a)=>({node:o,i:a,rank:r(o)})).sort((o,a)=>o.rank-a.rank||o.i-a.i).map(o=>o.node)}function Xe(e,n,t,r){let o=e.some(i=>D(t,i.kind,n.by).length>0)?void 0:ue(n.by);if(o&&r)return Ze(e,o,n.headings,t,r);let a=[];for(let i of e)for(let s of D(t,i.kind,n.by))a.includes(s)||a.push(s);let d=[];for(let i of a){let s=e.filter(y=>$(y,n.by)===i);if(s.length===0)continue;let f=t.tryDefinition(s[0].kind);d.push({value:i,heading:n.headings[i]??J(x(f,n.by,i)),members:s})}let l=e.filter(i=>!a.includes(String($(i,n.by))));return l.length>0&&d.push({value:null,members:l}),d}function Ze(e,n,t,r,o){let a=u=>n.way??(Object.hasOwn(r.tryDefinition(u.kind)?.edges??{},n.edge)?"out":"in"),d=new Map,l=[],i=v(r),s;for(let u of e){let m=a(u)==="out"?o.out(u.id,n.edge):o.in(u.id,n.edge);m.length===0&&l.push(u);for(let c of m){s??=c.kind;let R=d.get(c.id)??{node:c,members:[]};R.members.push(u),d.set(c.id,R)}}let f=[...d.values()].map(({node:u,members:m})=>({value:u.id,heading:t[u.id]??i(u),members:m})).sort((u,m)=>u.heading.localeCompare(m.heading,void 0,{numeric:!0}));!s&&e[0]&&a(e[0])==="out"&&(s=(r.tryDefinition(e[0].kind)?.edges??{})[n.edge]?.to?.[0]);let y=s&&s!=="*"?Z(r.tryDefinition(s),s):void 0;return l.length>0&&f.push({value:null,...y?{heading:`No ${y}`}:{},members:l}),f}function je(e){return e.t==="list"||e.t==="headline"||e.t==="number"||e.t==="image"&&e.as==="gallery"?!0:e.t==="group"?e.blocks.some(je):e.t==="when"?e.show.some(je):!1}function Ee(e,n){let t=e.tryDefinition(n)?.fields?.shape??{},r={};for(let[o,a]of Object.entries(t)){let d=I(a);d&&(r[o]=d)}return r}var Be=new WeakMap;function U(e){let n=Be.get(e);return n||Be.set(e,n=ye(e)),n}function ze(e,n,t,r={}){let o=U(e),a={},d={},l=i=>{if(i instanceof j)return i.nodes.map(s=>l(s));if(Array.isArray(i))return i.map(s=>l(s));if(i!==null&&typeof i=="object"){let s=i;return{id:s.id,kind:s.kind,label:X(e.tryDefinition(s.kind),s)}}return i};for(let[i,s]of o.get(t?t.kind:ne)?.computed??[])try{let f=[],y=E(s,{graph:n,subject:t,kinds:o,...r.today?{today:r.today}:{},...r.budget?{budget:r.budget}:{},...r.linked?{linked:r.linked}:{},onUnread:u=>f.push(u)});f.length>0&&(y===null||y instanceof j&&y.nodes.length===0)?d[i]=ee(f[0]):a[i]=l(y)}catch(f){if(!(f instanceof re))throw f;d[i]=f.sentence}return{values:a,refused:d}}function vn(e,n,t){let{values:r}=ze(e,n,t);if(Object.keys(r).length===0)return t;let o=a=>Array.isArray(a)?a.map(o):a!==null&&typeof a=="object"?a.label:a;return{...t,...Object.fromEntries(Object.entries(r).map(([a,d])=>[a,o(d)]))}}function Pn(e,n){return[...fe(e.tryDefinition(n)).keys()]}var Ye=500,qe=2e4,ve=new WeakMap;function Qe(e,n){let t=ve.get(e);t||ve.set(e,t=new Map);let r=t.get(n);return r||t.set(n,r=Ee(e,n)),r}function Vn(e,n,t,r={}){if(n&&typeof e.seenBy!="function")throw new TypeError("blockContextFor: a seat is read from a store (its `seenBy`); a bare { graph, schema } is read as it is handed, with no principal");let o=n?e.seenBy(n):e,a=n&&t?o.graph.getNode(t.id)??null:t,d=o.schema,l=a&&d.tryDefinition(a.kind),i=!a||(r.slot??"page")==="page",{money:s,firstHeading:f}=r;return{node:a,graph:o.graph,schema:d,kinds:U(d),fields:a?Qe(d,a.kind):{},definition:l||void 0,today:r.today??o.today?.()??H(s?.timeZone),money:s,heading:r.heading??(i?2:3),firstHeading:f,budget:r.budget??(i?qe:Ye),...i?{}:{glance:!0}}}export{we as a,tn as b,Pe as c,on as d,Se as e,Ae as f,Oe as g,jn as h,je as i,U as j,ze as k,vn as l,Pn as m,Vn as n};
@@ -1 +1 @@
1
- import"./chunk.NSGQXCH6.js";import"./chunk.SZG6HJWH.js";import{b as m}from"./chunk.2FOIJ5ID.js";import"./chunk.6IUEGPCZ.js";import"./chunk.CUJX3IVA.js";import{T as p}from"./chunk.VNJKGSGZ.js";import"./chunk.SDO3U72B.js";import{W as l}from"./chunk.X3MMJ3QC.js";import"./chunk.FQLNBIQ5.js";import{b as f}from"./chunk.AJZBJBMO.js";var a=f(p(),1);function A({states:e,definition:v}){let s=e.values.reduce((t,n)=>t+n.count,0),u=t=>t===null?"with none":m(v,e.field,t).toLowerCase(),c=e.values.filter(t=>t.count>0).map(t=>`${l(t.count)} ${u(t.value)}`).join(", ");return s===0?null:(0,a.jsx)("div",{className:"graview-district-states",role:"img","aria-label":c,title:c,children:e.values.map((t,n)=>{if(t.count===0)return null;let y=e.values.filter(r=>r.count>0).length,w=t.count/s*(168-(y-1)),o=l(t.count),i=`${o} ${u(t.value)}`,d=r=>r.length*6.2+8<=w;return(0,a.jsx)("span",{"data-graview-tier":t.tier,style:{flexGrow:t.count},title:i,children:d(i)?i:d(o)?o:""},n)})})}export{A as StatesBar};
1
+ import"./chunk.MSWWWLEA.js";import"./chunk.UITT6JWW.js";import{b as m}from"./chunk.A5PDXNY6.js";import"./chunk.WC3DENU4.js";import"./chunk.VNDKKTED.js";import{T as p}from"./chunk.4MP72LPR.js";import"./chunk.SDO3U72B.js";import{W as l}from"./chunk.VSCIXAHN.js";import"./chunk.FQLNBIQ5.js";import{b as f}from"./chunk.AJZBJBMO.js";var a=f(p(),1);function A({states:e,definition:v}){let s=e.values.reduce((t,n)=>t+n.count,0),u=t=>t===null?"with none":m(v,e.field,t).toLowerCase(),c=e.values.filter(t=>t.count>0).map(t=>`${l(t.count)} ${u(t.value)}`).join(", ");return s===0?null:(0,a.jsx)("div",{className:"graview-district-states",role:"img","aria-label":c,title:c,children:e.values.map((t,n)=>{if(t.count===0)return null;let y=e.values.filter(r=>r.count>0).length,w=t.count/s*(168-(y-1)),o=l(t.count),i=`${o} ${u(t.value)}`,d=r=>r.length*6.2+8<=w;return(0,a.jsx)("span",{"data-graview-tier":t.tier,style:{flexGrow:t.count},title:i,children:d(i)?i:d(o)?o:""},n)})})}export{A as StatesBar};
@@ -1,3 +1,3 @@
1
- import{C as h,N as $,Ob as k,Sb as w,W as g,da as m}from"./chunk.X3MMJ3QC.js";function G(t,n,e){let r=t?.display?.format?.[n];return r?r(e):typeof e=="string"?m(e):String(e)}function Q(t,n,e,r){let s=t.tryDefinition(n)?.edges,i=s&&Object.hasOwn(s,e)?s[e]:void 0;return(r==="out"?i?.description:i?.inverse)??m(e).toLowerCase()}var A=Symbol.for("@graview/core:markdown");function S(t){let n=h(t);return!!n&&(n[A]===1||S(n.innerType))}var x=/^ {0,3}#{1,6}(?:[ \t]+|$)/,y=/^[ \t]*(?:[-*+•]|\d{1,9}[.)])[ \t]+(?:\[[ xX]\][ \t]+)?/,R=/^ {0,3}(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})$/,O=/^ {0,3}(?:`{3,}|~{3,})/,F=/^ {0,3}(?:>[ \t]?)+/,M=/^\|?\s*:?-{2,}:?\s*(?:\|\s*:?-{2,}:?\s*)*\|?$/,W={amp:"&",lt:"<",gt:">",quot:'"',"#39":"'",nbsp:" "};function _(t){return t.replace(/!?\[([^\]\n]{0,500})\]\([^)\n]{0,500}\)/g,"$1").replace(/<((?:https?:|mailto:)[^>\s]*)>/gi,"$1").replace(/<\/?[A-Za-z][^<>\n]*>/g,"").replace(/`+([^`\n]*)`+/g,"$1").replace(/(\*\*|__|~~)(?=\S)([^\n]{0,500}?\S)\1/g,"$2").replace(/(^|[^\w*])\*(?=\S)([^*\n]{0,500}?\S)\*(?![\w*])/g,"$1$2").replace(/(^|\W)_(?=\S)([^_\n]{0,500}?\S)_(?!\w)/g,"$1$2").replace(/\\([\\`*_{}[\]()#+\-.!>|~])/g,"$1").replace(/&(amp|lt|gt|quot|#39|nbsp);/g,(n,e)=>W[e]??"")}function N(t,n,e){let r=t.replace(/\r\n?/g,`
1
+ import{C as h,N as $,Ub as k,W as g,Yb as w,da as m}from"./chunk.VSCIXAHN.js";function G(t,n,e){let r=t?.display?.format?.[n];return r?r(e):typeof e=="string"?m(e):String(e)}function Q(t,n,e,r){let s=t.tryDefinition(n)?.edges,i=s&&Object.hasOwn(s,e)?s[e]:void 0;return(r==="out"?i?.description:i?.inverse)??m(e).toLowerCase()}var A=Symbol.for("@graview/core:markdown");function S(t){let n=h(t);return!!n&&(n[A]===1||S(n.innerType))}var x=/^ {0,3}#{1,6}(?:[ \t]+|$)/,y=/^[ \t]*(?:[-*+•]|\d{1,9}[.)])[ \t]+(?:\[[ xX]\][ \t]+)?/,R=/^ {0,3}(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})$/,O=/^ {0,3}(?:`{3,}|~{3,})/,F=/^ {0,3}(?:>[ \t]?)+/,M=/^\|?\s*:?-{2,}:?\s*(?:\|\s*:?-{2,}:?\s*)*\|?$/,W={amp:"&",lt:"<",gt:">",quot:'"',"#39":"'",nbsp:" "};function _(t){return t.replace(/!?\[([^\]\n]{0,500})\]\([^)\n]{0,500}\)/g,"$1").replace(/<((?:https?:|mailto:)[^>\s]*)>/gi,"$1").replace(/<\/?[A-Za-z][^<>\n]*>/g,"").replace(/`+([^`\n]*)`+/g,"$1").replace(/(\*\*|__|~~)(?=\S)([^\n]{0,500}?\S)\1/g,"$2").replace(/(^|[^\w*])\*(?=\S)([^*\n]{0,500}?\S)\*(?![\w*])/g,"$1$2").replace(/(^|\W)_(?=\S)([^_\n]{0,500}?\S)_(?!\w)/g,"$1$2").replace(/\\([\\`*_{}[\]()#+\-.!>|~])/g,"$1").replace(/&(amp|lt|gt|quot|#39|nbsp);/g,(n,e)=>W[e]??"")}function N(t,n,e){let r=t.replace(/\r\n?/g,`
2
2
  `).split(`
3
3
  `),s=[],i=[],u=0,d=!1,a=()=>{let o=i.join(" ").replace(/\s+/g," ").trim();o&&(s.push(o),u+=o.length),i=[]},c=0;for(;c<r.length&&u<=e;){let o=r[c++];if(n&&O.test(o)){d=!d,d||a();continue}if(!d&&(o.trim().length===0||n&&(R.test(o)||M.test(o.trim())))){a();continue}let f=!d&&n&&x.test(o),l=!d&&y.test(o);if((f||l)&&a(),n&&!d?(o=o.replace(F,""),f&&(o=o.replace(x,"").replace(/[ \t]+#+[ \t]*$/,"")),l&&(o=o.replace(y,"")),o.includes("|")&&(o=o.replace(/^[ \t]*\||\|[ \t]*$/g,"").split("|").map(p=>p.trim()).filter(Boolean).join(" \xB7 ")),o=_(Number.isFinite(e)?o.slice(0,e*2+200):o)):l&&(o=o.replace(y,"")),i.push(o),f&&a(),i.reduce((p,T)=>p+T.length,0)>e)break}return a(),{blocks:s,more:r.slice(c).some(o=>o.trim().length>0&&!(n&&(O.test(o)||R.test(o))))}}function j(t,n){return`${(t.slice(0,n+1).replace(/\s+\S*$/,"")||t.slice(0,n)).replace(/[\s,;:.—-]+$/,"")}\u2026`}function J(t,n={}){let e=n.most??160,{blocks:r,more:s}=N(t,n.markdown===!0,e),i=r[0]??"";if(i.length<=e)return(s||r.length>1)&&i.length>0&&!/[.!?…:]$/.test(i)?`${i}\u2026`:i;let u=w(i);return u&&u.length<=e?u:j(i,e)}var K=t=>N(t,!0,Number.POSITIVE_INFINITY).blocks.join(" ");var E={d:1440,h:60,m:1};function tn(t){if(typeof t=="number")return Number.isFinite(t)&&t>=0?Math.round(t):void 0;if(typeof t!="string")return;let n=t.trim().toLowerCase();if(/^\d+$/.test(n))return Number(n);let e=/^(\d+):([0-5]\d)(?::([0-5]\d))?$/.exec(n);if(e)return Number(e[1])*60+Number(e[2])+Math.round(Number(e[3]??0)/60);let r=0,s=!1,i=n.replace(/(\d*[.,]?\d+) *(days?|d|hours?|hrs?|hr|h|minutes?|mins?|min|m)(?![a-z])/g,(u,d,a)=>(s=!0,r+=Number(d.replace(",","."))*E[a[0]]," "));return s&&/^[\s,+]*(?:and[\s,+]*)*$/.test(i)?Math.round(r):void 0}function I(t,n){if(!Number.isFinite(t))return String(t);let e=Math.round(Math.abs(t)),r=Math.floor(e/60),s=e%60,i=[r?`${g(r,n)} h`:"",s||!r?`${g(s,n)} min`:""].filter(Boolean).join(" ");return t<0?`\u2212${i}`:i}var D=/^(\+?1[ .-]?)?\(?([2-9]\d\d)\)?[ .-]?(\d{3})[ .-]?(\d{4})(?: *(?:ext\.?|x|#) *(\d+))?$/i;function P(t,n){let e=t.trim(),r=/[-_](US|CA)\b/i.test($(n))?D.exec(e):null;if(!r)return e;let[,s,i,u,d,a]=r;return`${s?.startsWith("+")?"+1 ":""}(${i}) ${u}-${d}${a?` ext. ${a}`:""}`}function L(t){let[,n="",e]=/^(.*?)(?: *(?:ext\.?|x|#) *(\d+))?$/i.exec(t.trim())??[],r=n.replace(/\D/g,"");return r.length<3?void 0:`tel:${n.startsWith("+")?"+":""}${r}${e?`;ext=${e}`:""}`}var q=()=>/Mac|iPhone|iPad|iPod/.test(globalThis.navigator?.userAgent??"");function C(t,n=q()){let e=encodeURIComponent(t.trim());return n?`https://maps.apple.com/?q=${e}`:`https://www.google.com/maps/search/?api=1&query=${e}`}var H=t=>t?.fields?.shape??{},U=(t,n)=>{let e=H(t);return Object.hasOwn(e,n)?k(e[n]):void 0},b=(t,n)=>{let e=t?.computed,r=e&&Object.hasOwn(e,n)?e[n]:void 0;return typeof r=="object"?r:void 0},z=(t,n)=>{let e=b(t,n);return e?.as??(e?.format==="duration"?"duration":void 0)};function rn(t,n){let e=b(t,n);if(!e)return;if(e.amount)return e.amount;let r=e.format==="money"||e.format==="percent"?e.format:void 0;return r||!e.format&&e.unit?{...r?{format:r}:{},...e.unit?{unit:e.unit}:{}}:void 0}function on(t,n){return b(t,n)?.hidden===!0}function sn(t,n){return U(t,n)??(t&&z(t,n)==="duration"?"duration":void 0)}function dn(t,n,e){return t==="duration"?typeof n=="number"?I(n,e):void 0:t==="phone"?typeof n=="string"?P(n,e):void 0:t==="place"&&typeof n=="string"?n.trim():void 0}function un(t,n){if(!(typeof n!="string"||!n.trim()))return t==="phone"?L(n):t==="place"?C(n):void 0}export{S as a,G as b,Q as c,J as d,K as e,tn as f,rn as g,on as h,sn as i,dn as j,un as k};
@@ -1 +1 @@
1
- import{d as K}from"./chunk.ATSKKTUO.js";import{$b as Y,Db as V,ac as X,dc as B,h as P,jb as G,k as R,lc as $,mc as N,oa as q,q as I,vb as h,wb as v,x as _}from"./chunk.X3MMJ3QC.js";import{a as T,c as C,h as L}from"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";var te=Symbol.for("@graview/core:markdown"),ne=500;function ie(e){let n=e;for(let i=0;i<6;i++){let t=N(n);if(!t)return!1;if(t[$]!==void 0)return t[$]===1;if(t[te]===1)return!0;if(t.type==="string")return(t.checks??[]).some(s=>{let f=N(s);return f?.check==="max_length"&&(f.maximum??0)>ne});if(t.innerType===void 0)return!1;n=t.innerType}return!1}function O(e,n,i){if(n===void 0||i==="id"||i==="kind")return!1;let t=e.tryDefinition(n)?.fields?.shape;return!!t&&Object.prototype.hasOwnProperty.call(t,i)&&ie(t[i])}var re=e=>e>=55296&&e<=56319,oe=e=>e>=56320&&e<=57343;function S(e,n){let i=Math.min(e.length,n.length),t=0;for(;t<i&&e.charCodeAt(t)===n.charCodeAt(t);)t++;t>0&&re(e.charCodeAt(t-1))&&t--;let s=0;for(;s<i-t&&e.charCodeAt(e.length-1-s)===n.charCodeAt(n.length-1-s);)s++;return s>0&&oe(e.charCodeAt(e.length-s))&&s--,{at:t,removed:e.slice(t,e.length-s),inserted:n.slice(t,n.length-s)}}var w=e=>e.at+e.removed.length;function H(e){let n=S(e.removed,e.inserted);return{...n,at:e.at+n.at}}function U(e,n,i){if(w(e)<n.at)return e;if(e.at>w(n))return{...e,at:e.at+n.inserted.length-n.removed.length};let t=Math.min(e.at,n.at),s=w(e)-w(n),f=e.removed.slice(0,n.at-t)+n.inserted+(s>0?e.removed.slice(e.removed.length-s):""),r=n.at<e.at||n.at===e.at&&i;return H({at:t,removed:f,inserted:r?n.inserted+e.inserted:e.inserted+n.inserted})}function b(e,n){return[U(e,n,!1),U(n,e,!0)]}function D(e,n){let i=e.at+e.inserted.length;if(w(n)<e.at||n.at>i)return;let t=Math.min(e.at,n.at),s=w(n)-i,f=n.removed.slice(0,e.at-t),r=s>0?n.removed.slice(n.removed.length-s):"",l=T(f+e.inserted+r,{...n,at:n.at-t});return H({at:t,removed:f+e.removed+r,inserted:l})}function M(e,n,i){switch(e.op){case"patch-node":return e.id===n&&Object.prototype.hasOwnProperty.call(e.after,i);case"add-node":case"remove-node":return e.node.id===n;default:return!1}}function j(e,n,i){if(e.op!=="patch-node"||e.id!==n||!Object.prototype.hasOwnProperty.call(e.after,i))return;let t=e.before[i],s=e.after[i];return typeof s=="string"&&(t===void 0||t===""||C(t))?{at:0,removed:"",inserted:s}:void 0}var J=(e,n,i)=>e.flatMap(t=>t.op==="splice-text"&&t.id===n&&t.field===i?[t]:[]);function E(e,n,i,t,s,f){if(typeof f!="string"||s<n-1)return;let r=[];for(let o of e)if(!(o.seq<=s))for(let p of o.primitives){let a=j(p,i,t);if(a){r.push(a);continue}if(M(p,i,t))return;p.op==="splice-text"&&p.id===i&&p.field===t&&r.push(p)}let l=f;try{for(let o=r.length-1;o>=0;o--){let p=r[o];l=T(l,{at:p.at,removed:p.inserted,inserted:p.removed})}}catch{return}return{then:l,since:r}}function A(e,n){let i=e;for(let t of n)i=b(t,i)[1];return{at:i.at,removed:i.removed,inserted:i.inserted}}function Q(e,n,i){let t=i?A(S(i.then,n),i.since):S(e,n);return t.removed===""&&t.inserted===""?void 0:t}function Z(e){let n=e.schema,i=t=>{throw new V(t,"invalid")};return{name:h,title:"Type text",input:I({node:P(),field:P(),at:R(),remove:R(),insert:P(),rev:_(R())}),subject:{kinds:"*",arg:"node"},writes:[],describe:(t,s)=>{let{node:f,field:r,insert:l,remove:o}=t;return K({node:f,field:r,inserted:[...String(l??"")].length,removed:Number(o)||0},n,s)},apply(t,s){let{node:f,field:r,at:l,remove:o,insert:p,rev:a}=s;(![l,o,a??0].every(k=>Number.isInteger(k)&&k>=-1)||l<0||o<0)&&i("at and remove are whole numbers, none below 0, and rev a revision");let d=t.graph.getNode(f);if(!d)throw new G(f,"\u201CType text\u201D names a record that is not there.");if(O(n,d.kind,r)||i(`${q(n.tryDefinition(d.kind),d.kind)}'s "${r}" is not text typed together: write it whole, as its edit does`),o===0&&p==="")return;let c=d[r];if(typeof c!="string"||c===""){t.patchNode(f,{[r]:p});return}let g=e.graph.getNode(f)?.[r],m=a===void 0?{then:c,since:[]}:E(e.log.all(),e.log.horizon,f,r,Math.max(a,-1),g);m||i(`${r} was written whole since revision ${a}: read it again and type over what it holds now`);let{then:u,since:y}=m;l+o>u.length&&i(`${r} held ${u.length} characters at revision ${a??"now"}, so there is nothing at ${l}${o>0?`\u2013${l+o}`:""} to type over`);let x=A({at:l,removed:u.slice(l,l+o),inserted:p},y);x.removed===""&&x.inserted===""||t.emit({op:"splice-text",id:f,field:r,...x})}}}function ee(e,n,i,t,s=()=>!0){let f=i===void 0?void 0:e.tryDefinition(i);if(!f||typeof t!="string")return[];let r=new Set;for(let l of n)if(!(l.name===h||!Y(e,l).includes(i)||!X(l,f).includes(t))&&s(l)){r.add(l.name);for(let o of B(e,n,l)??[])r.add(o)}return[...r]}function se(e,n,i){if(!n.some(r=>r.op==="patch-node"))return[...n];let t=new Set,s=new Set,f=[];for(let r of n){if(r.op==="add-node"&&t.add(r.node.id),r.op!=="patch-node"||t.has(r.id)){r.op==="splice-text"&&s.add(`${r.id}\0${r.field}`),f.push(r);continue}let l=e.graph.getNode(r.id),o={},p={},a=[];for(let[d,c]of Object.entries(r.after)){let g=l?.[d],m=`${r.id}\0${d}`;if(typeof c=="string"&&typeof g=="string"&&g!==""&&!s.has(m)&&O(e.schema,l?.kind,d)){let u=i?.find(x=>x.node===r.id&&x.field===d),y=Q(g,c,u?E(e.log.all(),e.log.horizon,r.id,d,u.rev,g):void 0);if(y){a.push({op:"splice-text",id:r.id,field:d,...y}),s.add(m);continue}}o[d]=r.before[d],p[d]=c,s.add(m)}Object.keys(p).length>0&&f.push(a.length>0?{op:"patch-node",id:r.id,before:o,after:p}:r),f.push(...a)}return f}function de(e,n){let i=[];return[...n].sort((t,s)=>s.seq-t.seq).map(t=>{let s=L(t);if(!s.some(o=>o.op==="splice-text"))return i.push(...s),{op:t,primitives:s};let f=e.filter(o=>o.seq>t.seq).flatMap(o=>o.primitives),r=t.primitives.length,l=[];return s.forEach((o,p)=>{if(o.op!=="splice-text")return void l.push(o);let a=A(o,J([...t.primitives.slice(r-p),...f,...i,...l],o.id,o.field));(a.removed!==""||a.inserted!=="")&&l.push({op:"splice-text",id:o.id,field:o.field,...a})}),i.push(...l),{op:t,primitives:l}})}function ae(e,n){let i=(t,s)=>e.some(f=>M(f,t,s));return n.undoes!==void 0&&n.primitives.length===0&&e.some(t=>t.op==="splice-text")||n.primitives.length>0&&n.primitives.every(t=>t.op==="splice-text"&&!i(t.id,t.field))?!0:e.flatMap(t=>t.op==="splice-text"&&n.primitives.some(s=>M(s,t.id,t.field))?[t.id]:[])}function le(e,n,i){let t=new Map,s=[],f=new Set;for(let a of e){let d=a.primitives[0],c=a.mutation?.args,g=a.mutation?.name!==h||a.primitives.length!==1||!d?void 0:d.op==="splice-text"?d:j(d,String(c?.node),String(c?.field));g?s.push({batch:a.batch,node:String(c?.node),field:String(c?.field),splice:g}):f.add(a.batch)}if(s.length===0)return t;let r=a=>`${a.node}\0${a.field}`,l=new Set,o=new Set(e.map(a=>a.batch).filter(a=>!i.includes(a))),p=s;for(let a of n){if(o.has(a.batch)){p=p.filter(d=>d.batch!==a.batch);continue}for(let d of a.primitives){if(d.op==="add-edge"||d.op==="remove-edge")continue;let c=d.op==="add-node"||d.op==="remove-node"?d.node.id:d.id;for(let g of new Set(p.filter(m=>m.node===c).map(m=>m.field))){let m=d.op==="splice-text"?d.field===g?d:void 0:j(d,c,g);for(let u of p)u.node!==c||u.field!==g||(m?[m,u.splice]=b(m,u.splice):M(d,u.node,u.field)&&l.add(r(u)))}}}p.forEach((a,d)=>{if(!o.has(a.batch))return;let c={at:a.splice.at,removed:a.splice.inserted,inserted:a.splice.removed};for(let g of p.slice(d+1))r(g)===r(a)&&([c,g.splice]=b(c,g.splice))});for(let a of i){let d=p.filter(c=>c.batch===a);d.length===0||f.has(a)||d.some(c=>l.has(r(c)))||t.set(a,d.map(c=>({name:h,args:{node:c.node,field:c.field,at:c.splice.at,remove:c.splice.removed.length,insert:c.splice.inserted}})))}return t}v.typeText=Z;v.via=ee;v.collaborative=O;v.asSplices=se;v.undone=de;v.aside=ae;v.carried=le;function Ye(e){let{store:n,author:i,pending:t,provisional:s,asked:f}=e,r=new Map,l=(o,p)=>{r.get(o)?.(p),r.delete(o)};return{store:n,apply:(o,p)=>e.appliedAll(o,{...i?{author:i}:{},...p!==void 0?{batch:p}:{}}),hold(o){t.push(o),s.add(o),e.answers.set(o,new Promise(p=>r.set(o,p)))},ask:(o,p)=>void f.set(o,{calls:p}),send(o,p){f.set(o,{calls:p});let a=e.sent(o,p),d=()=>l(o,a);return a.then(c=>{Array.isArray(c?.ops)&&c.ops.length===0&&e.letGo.add(o),d()},d),a},drop(o){e.letGo.add(o),e.settle(o),f.delete(o),e.land([],[o]),l(o)},seen:e.seen,gone:e.gone,ahead(o,p,a){let d=t.indexOf(o),c=n.log.all(),g=m=>c.some(u=>u.batch===m&&u.primitives.some(y=>y.op==="splice-text"&&y.id===p&&y.field===a||y.op==="patch-node"&&y.id===p&&a in y.after));return t.slice(0,Math.max(0,d)).flatMap(m=>{let u=e.answers.get(m);return u&&g(m)?[{batch:m,answer:u}]:[]})}}}var ce=400,pe=/[\s.,;:!?)\]}]$/u,W=e=>typeof e=="string"?e:"";function z(e,n,i,t){let s=e.log.all(),f=s.findIndex(o=>o.batch===n);if(f<0)return;let r=W(e.graph.getNode(i)?.[t]),l;for(let o=s.length-1;o>=f;o--){let p=s[o];p.batch===n&&l===void 0&&(l=r);for(let a=p.primitives.length-1;a>=0;a--){let d=p.primitives[a];d.op==="splice-text"&&d.id===i&&d.field===t?r=T(r,{at:d.at,removed:d.inserted,inserted:d.removed}):d.op==="patch-node"&&d.id===i&&t in d.after&&(r=C(d.before[t])?"":W(d.before[t]))}}if(!(l===void 0||l===r))return S(r,l)}function Xe(e,n,i){let t,s=[],f,r,l=!1,o=new Set,p=c=>({name:h,args:{node:e,field:n,at:c.at,remove:c.removed.length,insert:c.inserted,rev:i.seen()}}),a=()=>{r&&clearTimeout(r),r=void 0,t!==void 0&&s.push(t),t=void 0,d()},d=()=>{if(f!==void 0||l||i.gone())return;let c=s.shift();if(c===void 0)return;let g=i.ahead(c,e,n).filter(u=>!o.has(u.batch));if(g.length>0){s.unshift(c),l=!0,Promise.allSettled(g.map(u=>u.answer)).then(()=>{for(let u of g)o.add(u.batch);l=!1,d()});return}let m=z(i.store,c,e,n);if(!m)return i.drop(c),d();f=c,i.send(c,[p(m)]).finally(()=>{f=void 0,d()})};return{splice(c,g,m){if(i.gone())return;let u=W(i.store.graph.getNode(e)?.[n]),y={at:c,removed:u.slice(c,c+g),inserted:m};if(t!==void 0){let F=z(i.store,t,e,n);(!F||!D(F,y))&&a()}let x=i.apply([{name:h,args:{node:e,field:n,at:c,remove:g,insert:m}}],t);if(x.ops.length===0)return;t===void 0&&(t=x.batch,i.hold(t));let k=z(i.store,t,e,n);if(k&&i.ask(t,[p(k)]),pe.test(m))return a();r&&clearTimeout(r),r=setTimeout(a,ce),r.unref?.()},flush:a,waiting:()=>s.length+(t!==void 0?1:0)+(f!==void 0?1:0)}}function Be(e,n){let i=n.find(l=>l.name===h)?.args;if(typeof i?.node!="string"||typeof i.field!="string")return;let{node:t,field:s}=i,f=()=>e.graph.getNode(t)?.[s],r=f();return{node:t,field:s,yours:r,over:l=>{let o=f();return{name:h,args:{node:t,field:s,at:0,remove:typeof o=="string"?o.length:0,insert:typeof r=="string"?r:"",rev:l}}}}}export{ce as TYPING_IDLE_MS,z as runSplice,Xe as typingOf,Ye as wireOf,Be as yoursOf};
1
+ import{d as K}from"./chunk.RQOX5YDW.js";import{Db as V,fc as Y,gc as X,h as P,jb as G,jc as B,k as R,oa as q,q as I,rc as $,sc as N,vb as h,wb as v,x as _}from"./chunk.VSCIXAHN.js";import{a as T,c as C,h as L}from"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";var te=Symbol.for("@graview/core:markdown"),ne=500;function ie(e){let n=e;for(let i=0;i<6;i++){let t=N(n);if(!t)return!1;if(t[$]!==void 0)return t[$]===1;if(t[te]===1)return!0;if(t.type==="string")return(t.checks??[]).some(s=>{let f=N(s);return f?.check==="max_length"&&(f.maximum??0)>ne});if(t.innerType===void 0)return!1;n=t.innerType}return!1}function O(e,n,i){if(n===void 0||i==="id"||i==="kind")return!1;let t=e.tryDefinition(n)?.fields?.shape;return!!t&&Object.prototype.hasOwnProperty.call(t,i)&&ie(t[i])}var re=e=>e>=55296&&e<=56319,oe=e=>e>=56320&&e<=57343;function S(e,n){let i=Math.min(e.length,n.length),t=0;for(;t<i&&e.charCodeAt(t)===n.charCodeAt(t);)t++;t>0&&re(e.charCodeAt(t-1))&&t--;let s=0;for(;s<i-t&&e.charCodeAt(e.length-1-s)===n.charCodeAt(n.length-1-s);)s++;return s>0&&oe(e.charCodeAt(e.length-s))&&s--,{at:t,removed:e.slice(t,e.length-s),inserted:n.slice(t,n.length-s)}}var w=e=>e.at+e.removed.length;function H(e){let n=S(e.removed,e.inserted);return{...n,at:e.at+n.at}}function U(e,n,i){if(w(e)<n.at)return e;if(e.at>w(n))return{...e,at:e.at+n.inserted.length-n.removed.length};let t=Math.min(e.at,n.at),s=w(e)-w(n),f=e.removed.slice(0,n.at-t)+n.inserted+(s>0?e.removed.slice(e.removed.length-s):""),r=n.at<e.at||n.at===e.at&&i;return H({at:t,removed:f,inserted:r?n.inserted+e.inserted:e.inserted+n.inserted})}function b(e,n){return[U(e,n,!1),U(n,e,!0)]}function D(e,n){let i=e.at+e.inserted.length;if(w(n)<e.at||n.at>i)return;let t=Math.min(e.at,n.at),s=w(n)-i,f=n.removed.slice(0,e.at-t),r=s>0?n.removed.slice(n.removed.length-s):"",l=T(f+e.inserted+r,{...n,at:n.at-t});return H({at:t,removed:f+e.removed+r,inserted:l})}function M(e,n,i){switch(e.op){case"patch-node":return e.id===n&&Object.prototype.hasOwnProperty.call(e.after,i);case"add-node":case"remove-node":return e.node.id===n;default:return!1}}function j(e,n,i){if(e.op!=="patch-node"||e.id!==n||!Object.prototype.hasOwnProperty.call(e.after,i))return;let t=e.before[i],s=e.after[i];return typeof s=="string"&&(t===void 0||t===""||C(t))?{at:0,removed:"",inserted:s}:void 0}var J=(e,n,i)=>e.flatMap(t=>t.op==="splice-text"&&t.id===n&&t.field===i?[t]:[]);function E(e,n,i,t,s,f){if(typeof f!="string"||s<n-1)return;let r=[];for(let o of e)if(!(o.seq<=s))for(let p of o.primitives){let a=j(p,i,t);if(a){r.push(a);continue}if(M(p,i,t))return;p.op==="splice-text"&&p.id===i&&p.field===t&&r.push(p)}let l=f;try{for(let o=r.length-1;o>=0;o--){let p=r[o];l=T(l,{at:p.at,removed:p.inserted,inserted:p.removed})}}catch{return}return{then:l,since:r}}function A(e,n){let i=e;for(let t of n)i=b(t,i)[1];return{at:i.at,removed:i.removed,inserted:i.inserted}}function Q(e,n,i){let t=i?A(S(i.then,n),i.since):S(e,n);return t.removed===""&&t.inserted===""?void 0:t}function Z(e){let n=e.schema,i=t=>{throw new V(t,"invalid")};return{name:h,title:"Type text",input:I({node:P(),field:P(),at:R(),remove:R(),insert:P(),rev:_(R())}),subject:{kinds:"*",arg:"node"},writes:[],describe:(t,s)=>{let{node:f,field:r,insert:l,remove:o}=t;return K({node:f,field:r,inserted:[...String(l??"")].length,removed:Number(o)||0},n,s)},apply(t,s){let{node:f,field:r,at:l,remove:o,insert:p,rev:a}=s;(![l,o,a??0].every(k=>Number.isInteger(k)&&k>=-1)||l<0||o<0)&&i("at and remove are whole numbers, none below 0, and rev a revision");let d=t.graph.getNode(f);if(!d)throw new G(f,"\u201CType text\u201D names a record that is not there.");if(O(n,d.kind,r)||i(`${q(n.tryDefinition(d.kind),d.kind)}'s "${r}" is not text typed together: write it whole, as its edit does`),o===0&&p==="")return;let c=d[r];if(typeof c!="string"||c===""){t.patchNode(f,{[r]:p});return}let g=e.graph.getNode(f)?.[r],m=a===void 0?{then:c,since:[]}:E(e.log.all(),e.log.horizon,f,r,Math.max(a,-1),g);m||i(`${r} was written whole since revision ${a}: read it again and type over what it holds now`);let{then:u,since:y}=m;l+o>u.length&&i(`${r} held ${u.length} characters at revision ${a??"now"}, so there is nothing at ${l}${o>0?`\u2013${l+o}`:""} to type over`);let x=A({at:l,removed:u.slice(l,l+o),inserted:p},y);x.removed===""&&x.inserted===""||t.emit({op:"splice-text",id:f,field:r,...x})}}}function ee(e,n,i,t,s=()=>!0){let f=i===void 0?void 0:e.tryDefinition(i);if(!f||typeof t!="string")return[];let r=new Set;for(let l of n)if(!(l.name===h||!Y(e,l).includes(i)||!X(l,f).includes(t))&&s(l)){r.add(l.name);for(let o of B(e,n,l)??[])r.add(o)}return[...r]}function se(e,n,i){if(!n.some(r=>r.op==="patch-node"))return[...n];let t=new Set,s=new Set,f=[];for(let r of n){if(r.op==="add-node"&&t.add(r.node.id),r.op!=="patch-node"||t.has(r.id)){r.op==="splice-text"&&s.add(`${r.id}\0${r.field}`),f.push(r);continue}let l=e.graph.getNode(r.id),o={},p={},a=[];for(let[d,c]of Object.entries(r.after)){let g=l?.[d],m=`${r.id}\0${d}`;if(typeof c=="string"&&typeof g=="string"&&g!==""&&!s.has(m)&&O(e.schema,l?.kind,d)){let u=i?.find(x=>x.node===r.id&&x.field===d),y=Q(g,c,u?E(e.log.all(),e.log.horizon,r.id,d,u.rev,g):void 0);if(y){a.push({op:"splice-text",id:r.id,field:d,...y}),s.add(m);continue}}o[d]=r.before[d],p[d]=c,s.add(m)}Object.keys(p).length>0&&f.push(a.length>0?{op:"patch-node",id:r.id,before:o,after:p}:r),f.push(...a)}return f}function de(e,n){let i=[];return[...n].sort((t,s)=>s.seq-t.seq).map(t=>{let s=L(t);if(!s.some(o=>o.op==="splice-text"))return i.push(...s),{op:t,primitives:s};let f=e.filter(o=>o.seq>t.seq).flatMap(o=>o.primitives),r=t.primitives.length,l=[];return s.forEach((o,p)=>{if(o.op!=="splice-text")return void l.push(o);let a=A(o,J([...t.primitives.slice(r-p),...f,...i,...l],o.id,o.field));(a.removed!==""||a.inserted!=="")&&l.push({op:"splice-text",id:o.id,field:o.field,...a})}),i.push(...l),{op:t,primitives:l}})}function ae(e,n){let i=(t,s)=>e.some(f=>M(f,t,s));return n.undoes!==void 0&&n.primitives.length===0&&e.some(t=>t.op==="splice-text")||n.primitives.length>0&&n.primitives.every(t=>t.op==="splice-text"&&!i(t.id,t.field))?!0:e.flatMap(t=>t.op==="splice-text"&&n.primitives.some(s=>M(s,t.id,t.field))?[t.id]:[])}function le(e,n,i){let t=new Map,s=[],f=new Set;for(let a of e){let d=a.primitives[0],c=a.mutation?.args,g=a.mutation?.name!==h||a.primitives.length!==1||!d?void 0:d.op==="splice-text"?d:j(d,String(c?.node),String(c?.field));g?s.push({batch:a.batch,node:String(c?.node),field:String(c?.field),splice:g}):f.add(a.batch)}if(s.length===0)return t;let r=a=>`${a.node}\0${a.field}`,l=new Set,o=new Set(e.map(a=>a.batch).filter(a=>!i.includes(a))),p=s;for(let a of n){if(o.has(a.batch)){p=p.filter(d=>d.batch!==a.batch);continue}for(let d of a.primitives){if(d.op==="add-edge"||d.op==="remove-edge")continue;let c=d.op==="add-node"||d.op==="remove-node"?d.node.id:d.id;for(let g of new Set(p.filter(m=>m.node===c).map(m=>m.field))){let m=d.op==="splice-text"?d.field===g?d:void 0:j(d,c,g);for(let u of p)u.node!==c||u.field!==g||(m?[m,u.splice]=b(m,u.splice):M(d,u.node,u.field)&&l.add(r(u)))}}}p.forEach((a,d)=>{if(!o.has(a.batch))return;let c={at:a.splice.at,removed:a.splice.inserted,inserted:a.splice.removed};for(let g of p.slice(d+1))r(g)===r(a)&&([c,g.splice]=b(c,g.splice))});for(let a of i){let d=p.filter(c=>c.batch===a);d.length===0||f.has(a)||d.some(c=>l.has(r(c)))||t.set(a,d.map(c=>({name:h,args:{node:c.node,field:c.field,at:c.splice.at,remove:c.splice.removed.length,insert:c.splice.inserted}})))}return t}v.typeText=Z;v.via=ee;v.collaborative=O;v.asSplices=se;v.undone=de;v.aside=ae;v.carried=le;function Ye(e){let{store:n,author:i,pending:t,provisional:s,asked:f}=e,r=new Map,l=(o,p)=>{r.get(o)?.(p),r.delete(o)};return{store:n,apply:(o,p)=>e.appliedAll(o,{...i?{author:i}:{},...p!==void 0?{batch:p}:{}}),hold(o){t.push(o),s.add(o),e.answers.set(o,new Promise(p=>r.set(o,p)))},ask:(o,p)=>void f.set(o,{calls:p}),send(o,p){f.set(o,{calls:p});let a=e.sent(o,p),d=()=>l(o,a);return a.then(c=>{Array.isArray(c?.ops)&&c.ops.length===0&&e.letGo.add(o),d()},d),a},drop(o){e.letGo.add(o),e.settle(o),f.delete(o),e.land([],[o]),l(o)},seen:e.seen,gone:e.gone,ahead(o,p,a){let d=t.indexOf(o),c=n.log.all(),g=m=>c.some(u=>u.batch===m&&u.primitives.some(y=>y.op==="splice-text"&&y.id===p&&y.field===a||y.op==="patch-node"&&y.id===p&&a in y.after));return t.slice(0,Math.max(0,d)).flatMap(m=>{let u=e.answers.get(m);return u&&g(m)?[{batch:m,answer:u}]:[]})}}}var ce=400,pe=/[\s.,;:!?)\]}]$/u,W=e=>typeof e=="string"?e:"";function z(e,n,i,t){let s=e.log.all(),f=s.findIndex(o=>o.batch===n);if(f<0)return;let r=W(e.graph.getNode(i)?.[t]),l;for(let o=s.length-1;o>=f;o--){let p=s[o];p.batch===n&&l===void 0&&(l=r);for(let a=p.primitives.length-1;a>=0;a--){let d=p.primitives[a];d.op==="splice-text"&&d.id===i&&d.field===t?r=T(r,{at:d.at,removed:d.inserted,inserted:d.removed}):d.op==="patch-node"&&d.id===i&&t in d.after&&(r=C(d.before[t])?"":W(d.before[t]))}}if(!(l===void 0||l===r))return S(r,l)}function Xe(e,n,i){let t,s=[],f,r,l=!1,o=new Set,p=c=>({name:h,args:{node:e,field:n,at:c.at,remove:c.removed.length,insert:c.inserted,rev:i.seen()}}),a=()=>{r&&clearTimeout(r),r=void 0,t!==void 0&&s.push(t),t=void 0,d()},d=()=>{if(f!==void 0||l||i.gone())return;let c=s.shift();if(c===void 0)return;let g=i.ahead(c,e,n).filter(u=>!o.has(u.batch));if(g.length>0){s.unshift(c),l=!0,Promise.allSettled(g.map(u=>u.answer)).then(()=>{for(let u of g)o.add(u.batch);l=!1,d()});return}let m=z(i.store,c,e,n);if(!m)return i.drop(c),d();f=c,i.send(c,[p(m)]).finally(()=>{f=void 0,d()})};return{splice(c,g,m){if(i.gone())return;let u=W(i.store.graph.getNode(e)?.[n]),y={at:c,removed:u.slice(c,c+g),inserted:m};if(t!==void 0){let F=z(i.store,t,e,n);(!F||!D(F,y))&&a()}let x=i.apply([{name:h,args:{node:e,field:n,at:c,remove:g,insert:m}}],t);if(x.ops.length===0)return;t===void 0&&(t=x.batch,i.hold(t));let k=z(i.store,t,e,n);if(k&&i.ask(t,[p(k)]),pe.test(m))return a();r&&clearTimeout(r),r=setTimeout(a,ce),r.unref?.()},flush:a,waiting:()=>s.length+(t!==void 0?1:0)+(f!==void 0?1:0)}}function Be(e,n){let i=n.find(l=>l.name===h)?.args;if(typeof i?.node!="string"||typeof i.field!="string")return;let{node:t,field:s}=i,f=()=>e.graph.getNode(t)?.[s],r=f();return{node:t,field:s,yours:r,over:l=>{let o=f();return{name:h,args:{node:t,field:s,at:0,remove:typeof o=="string"?o.length:0,insert:typeof r=="string"?r:"",rev:l}}}}}export{ce as TYPING_IDLE_MS,z as runSplice,Xe as typingOf,Ye as wireOf,Be as yoursOf};