graview 0.1.67 → 0.1.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/preview/{chunk.YCD4JSXD.js → chunk.2BMZPALF.js} +1 -1
- package/dist/preview/{chunk.SNHKYH72.js → chunk.2KCDLCB2.js} +1 -1
- package/dist/preview/{chunk.O2OL6RQQ.js → chunk.2ME4DVBI.js} +1 -1
- package/dist/preview/chunk.2TUEBU7X.js +8 -0
- package/dist/preview/{chunk.LYEGRY77.js → chunk.2U6HB4XU.js} +1 -1
- package/dist/preview/{chunk.7S6ZRMW4.js → chunk.32JE2WS7.js} +1 -1
- package/dist/preview/{chunk.RG5G6YQD.js → chunk.3DEWQDP7.js} +1 -1
- package/dist/preview/{chunk.GVT4UUQA.js → chunk.3JMQKANL.js} +1 -1
- package/dist/preview/{chunk.A5PSEU3W.js → chunk.3VEZ5MOC.js} +1 -1
- package/dist/preview/chunk.3WPCS6KP.js +1 -0
- package/dist/preview/{chunk.5R744JGZ.js → chunk.42C3FIKK.js} +1 -1
- package/dist/preview/{chunk.IAEGJDF3.js → chunk.42KHFGN6.js} +1 -1
- package/dist/preview/{chunk.DZMIYEHQ.js → chunk.4DXPPM6T.js} +1 -1
- package/dist/preview/chunk.4GVKKBQL.js +1 -0
- package/dist/preview/{chunk.KX5ZBHMA.js → chunk.4TT3ZHSJ.js} +1 -1
- package/dist/preview/{chunk.QXLJGHMC.js → chunk.4YAO3A5Q.js} +3 -3
- package/dist/preview/{chunk.Z4TY44CD.js → chunk.5JKUT2OM.js} +1 -1
- package/dist/preview/chunk.5L4ADKTW.js +1 -0
- package/dist/preview/{chunk.BKYZSV2Y.js → chunk.64LCHHZB.js} +1 -1
- package/dist/preview/{chunk.ZEZUKRC6.js → chunk.6AANHELP.js} +1 -1
- package/dist/preview/{chunk.ZAQ4IDX6.js → chunk.6DMCEBSO.js} +1 -1
- package/dist/preview/{chunk.NKLPL7QD.js → chunk.6IR5LBJU.js} +1 -1
- package/dist/preview/{chunk.X226YATK.js → chunk.6WB2TYK7.js} +1 -1
- package/dist/preview/chunk.6ZENHSTQ.js +1 -0
- package/dist/preview/{chunk.EJ2EZL2G.js → chunk.7K2V5FUB.js} +1 -1
- package/dist/preview/chunk.7OL6H4LF.js +1 -0
- package/dist/preview/{chunk.4W57E7AX.js → chunk.7TDML5YU.js} +1 -1
- package/dist/preview/{chunk.AJMVRFYX.js → chunk.7WPVLEX2.js} +2 -2
- package/dist/preview/{chunk.XSWSBTUO.js → chunk.7ZTGB4O7.js} +1 -1
- package/dist/preview/{chunk.FRQSLWP4.js → chunk.ACNOP2IU.js} +1 -1
- package/dist/preview/{chunk.N4ZKZ4GM.js → chunk.AENP662H.js} +1 -1
- package/dist/preview/{chunk.SFBHPYRD.js → chunk.AQ2PI6MR.js} +1 -1
- package/dist/preview/chunk.ARS4HJD2.js +1 -0
- package/dist/preview/{chunk.STPA7HBK.js → chunk.AWV57UBJ.js} +1 -1
- package/dist/preview/{chunk.D7NWMXSX.js → chunk.AYZL3LCR.js} +3 -3
- package/dist/preview/{chunk.URQTF5SY.js → chunk.BHJRT57H.js} +1 -1
- package/dist/preview/{chunk.7UHPHEH5.js → chunk.BPNW5KCP.js} +1 -1
- package/dist/preview/{chunk.TTSGCNPT.js → chunk.BQAFFEOA.js} +1 -1
- package/dist/preview/chunk.C2QKA6XY.js +1 -0
- package/dist/preview/{chunk.6KJGRM7A.js → chunk.CE3NKAF7.js} +1 -1
- package/dist/preview/{chunk.QRQ5WPZI.js → chunk.CFE3MHWZ.js} +1 -1
- package/dist/preview/{chunk.H6KIEDZN.js → chunk.CGBOPPNL.js} +1 -1
- package/dist/preview/{chunk.LP2ZMAT2.js → chunk.CNN32262.js} +1 -1
- package/dist/preview/{chunk.HJUZMOW2.js → chunk.DCLF4WWZ.js} +1 -1
- package/dist/preview/{chunk.GMLONS5L.js → chunk.DGDW54KE.js} +1 -1
- package/dist/preview/{chunk.3GNT5MKP.js → chunk.DLSS56EU.js} +1 -1
- package/dist/preview/{chunk.QAM76AXV.js → chunk.DMZRFXH7.js} +1 -1
- package/dist/preview/{chunk.Z2XUVJAL.js → chunk.DPHH5ZVL.js} +1 -1
- package/dist/preview/{chunk.Z27NSSYL.js → chunk.DZ6UDZOB.js} +2 -2
- package/dist/preview/{chunk.6W6XMLSF.js → chunk.E423JCOS.js} +1 -1
- package/dist/preview/{chunk.35KMZHB7.js → chunk.EB7PZJEO.js} +1 -1
- package/dist/preview/{chunk.V7H4BUEB.js → chunk.ECNGVD25.js} +1 -1
- package/dist/preview/{chunk.B7KZBT27.js → chunk.EGSOHTZZ.js} +1 -1
- package/dist/preview/{chunk.OCXY5DCD.js → chunk.EGVM24ND.js} +1 -1
- package/dist/preview/{chunk.UDHPMVC4.js → chunk.ENLIIZF2.js} +1 -1
- package/dist/preview/{chunk.H3EGBDW2.js → chunk.EP5JS7ZH.js} +1 -1
- package/dist/preview/{chunk.TI5FR2QQ.js → chunk.F5GNNVSQ.js} +1 -1
- package/dist/preview/chunk.FHQ25SWY.js +1 -0
- package/dist/preview/{chunk.F464JKHZ.js → chunk.FSW535EA.js} +1 -1
- package/dist/preview/{chunk.G5GVT6JY.js → chunk.FZELUSK5.js} +1 -1
- package/dist/preview/{chunk.UWS4RMM3.js → chunk.G2BDEWJC.js} +1 -1
- package/dist/preview/chunk.GF3ZCX46.js +2 -0
- package/dist/preview/{chunk.UW52CMGJ.js → chunk.GJTEV6CK.js} +1 -1
- package/dist/preview/{chunk.A7GVTE5Y.js → chunk.GKTQ5CZA.js} +2 -2
- package/dist/preview/{chunk.ZG5VGP5U.js → chunk.GONZB3J3.js} +1 -1
- package/dist/preview/{chunk.FLJXYESX.js → chunk.GRBWXTST.js} +1 -1
- package/dist/preview/{chunk.Z3O2VZAJ.js → chunk.GRTBEA7O.js} +1 -1
- package/dist/preview/{chunk.QNP5OR3P.js → chunk.H3IGXHZR.js} +2 -2
- package/dist/preview/{chunk.ILJDLBPJ.js → chunk.H3W5C3XQ.js} +1 -1
- package/dist/preview/{chunk.O5VFKVZS.js → chunk.H4VNIAHN.js} +1 -1
- package/dist/preview/{chunk.7ARRVNUR.js → chunk.HH4D3JEI.js} +1 -1
- package/dist/preview/{chunk.MUSMNKE4.js → chunk.HWFJQ42Y.js} +1 -1
- package/dist/preview/{chunk.37RFCHSS.js → chunk.HXTKBISQ.js} +1 -1
- package/dist/preview/{chunk.J2OPIS3H.js → chunk.I34BWUB4.js} +1 -1
- package/dist/preview/{chunk.ZAPS4J6G.js → chunk.I63462I3.js} +1 -1
- package/dist/preview/{chunk.6UQFV53C.js → chunk.IKKKHHRN.js} +1 -1
- package/dist/preview/{chunk.GRFD42WM.js → chunk.IPGLITWA.js} +1 -1
- package/dist/preview/{chunk.3NSV3WKM.js → chunk.IT5DVKXY.js} +2 -2
- package/dist/preview/{chunk.JQ2WNKDW.js → chunk.IXMIU4D4.js} +1 -1
- package/dist/preview/{chunk.JVB5KDSG.js → chunk.JCETQQ7J.js} +1 -1
- package/dist/preview/{chunk.M7KXQGQL.js → chunk.JGRSUTPJ.js} +1 -1
- package/dist/preview/{chunk.KFT7JIEH.js → chunk.JLDJZET2.js} +1 -1
- package/dist/preview/{chunk.JQ63N4MZ.js → chunk.JULD4XFB.js} +1 -1
- package/dist/preview/{chunk.LVOTLGJB.js → chunk.JV432T4Q.js} +1 -1
- package/dist/preview/{chunk.6SJEZWH3.js → chunk.KAM73WVF.js} +1 -1
- package/dist/preview/{chunk.AKJS2NUM.js → chunk.KUCBNMIY.js} +1 -1
- package/dist/preview/{chunk.DWM7AR5Y.js → chunk.L7XKYGV7.js} +1 -1
- package/dist/preview/{chunk.EP6Q32WT.js → chunk.LFFJB6D3.js} +1 -1
- package/dist/preview/{chunk.264PB572.js → chunk.LMTG5NPG.js} +1 -1
- package/dist/preview/{chunk.EGPCVMDU.js → chunk.LOKGUALC.js} +1 -1
- package/dist/preview/{chunk.FPHRAO3R.js → chunk.LZ6MSQ5O.js} +1 -1
- package/dist/preview/chunk.MBTEOF4R.js +1 -0
- package/dist/preview/{chunk.RJY7VJBH.js → chunk.MIOLBZBS.js} +1 -1
- package/dist/preview/{chunk.G3GFDVO2.js → chunk.MK5RPEB2.js} +1 -1
- package/dist/preview/{chunk.NSOPYIT4.js → chunk.MKL4THIV.js} +1 -1
- package/dist/preview/{chunk.FVQKSN33.js → chunk.MPWLDQOG.js} +1 -1
- package/dist/preview/chunk.MSUZAJ2K.js +4 -0
- package/dist/preview/{chunk.MSAYU25L.js → chunk.N5Z34V7U.js} +1 -1
- package/dist/preview/chunk.N64RVSH3.js +1 -0
- package/dist/preview/{chunk.HAOB6O72.js → chunk.ND3DEDWB.js} +1 -1
- package/dist/preview/{chunk.GFLH7RCI.js → chunk.NFTPJAMJ.js} +1 -1
- package/dist/preview/{chunk.QZQCQWQG.js → chunk.NRCWMYLH.js} +1 -1
- package/dist/preview/{chunk.47XEJZ3O.js → chunk.O2VXTYUJ.js} +1 -1
- package/dist/preview/{chunk.6N4PE3U5.js → chunk.O32F6LGK.js} +1 -1
- package/dist/preview/{chunk.PZ7KY6XH.js → chunk.O5FTWXA2.js} +1 -1
- package/dist/preview/{chunk.T2OUHRAA.js → chunk.ODYJEDIW.js} +1 -1
- package/dist/preview/{chunk.DKEIEH2D.js → chunk.OQ4ZO3YY.js} +1 -1
- package/dist/preview/chunk.PI4RFOBU.js +1 -0
- package/dist/preview/{chunk.E5PYNAYT.js → chunk.PIMAG4WT.js} +2 -2
- package/dist/preview/{chunk.EFVSZKB5.js → chunk.PLIV3IQK.js} +1 -1
- package/dist/preview/{chunk.77C556NM.js → chunk.PPCDPYYU.js} +1 -1
- package/dist/preview/{chunk.MW7R5G3C.js → chunk.PZQ5P6WK.js} +1 -1
- package/dist/preview/chunk.Q42R2KW4.js +1 -0
- package/dist/preview/{chunk.WEMUKZKH.js → chunk.Q4VFLLUT.js} +1 -1
- package/dist/preview/{chunk.SY5ID44D.js → chunk.Q6H5HESF.js} +1 -1
- package/dist/preview/chunk.QM54TGU6.js +3 -0
- package/dist/preview/{chunk.HN4ZJ4B4.js → chunk.QOQ26NXM.js} +1 -1
- package/dist/preview/{chunk.SJQPTDAT.js → chunk.QUETLFBJ.js} +1 -1
- package/dist/preview/{chunk.P2EKKKK2.js → chunk.QWLK3GKG.js} +1 -1
- package/dist/preview/{chunk.JEC5FDKX.js → chunk.QYPU444Y.js} +1 -1
- package/dist/preview/{chunk.TXZQEJ5T.js → chunk.QZP3ARLH.js} +1 -1
- package/dist/preview/{chunk.WALVW3KJ.js → chunk.R3GE37OI.js} +1 -1
- package/dist/preview/chunk.R66ZVMWB.js +1 -0
- package/dist/preview/{chunk.YZPESGCP.js → chunk.RQG672MJ.js} +1 -1
- package/dist/preview/chunk.RYA7A4NA.js +1 -0
- package/dist/preview/{chunk.LRNFE3UK.js → chunk.SADR3MQI.js} +1 -1
- package/dist/preview/{chunk.MJY4SLWA.js → chunk.SS6KL5NT.js} +1 -1
- package/dist/preview/chunk.SUG6LIOX.js +1 -0
- package/dist/preview/{chunk.SO6NT5K7.js → chunk.TFJA4QV4.js} +1 -1
- package/dist/preview/{chunk.D4WJ7OM5.js → chunk.TOUSIUJF.js} +1 -1
- package/dist/preview/{chunk.ARWO4WOV.js → chunk.TR4YFVZN.js} +1 -1
- package/dist/preview/{chunk.XFLGSUYO.js → chunk.TRNJKHIA.js} +1 -1
- package/dist/preview/{chunk.5AKZROMR.js → chunk.TVWK3SGD.js} +1 -1
- package/dist/preview/chunk.U7PAFLUM.js +1 -0
- package/dist/preview/{chunk.NKYWIGC7.js → chunk.UAMPR4MD.js} +1 -1
- package/dist/preview/{chunk.UGQYMN4J.js → chunk.UD7VLXPM.js} +1 -1
- package/dist/preview/{chunk.UQIPEMJ5.js → chunk.UFURYU4R.js} +1 -1
- package/dist/preview/{chunk.R6JBA7UK.js → chunk.UODTUBQ7.js} +1 -1
- package/dist/preview/{chunk.NRURQGXV.js → chunk.VES4XMZX.js} +1 -1
- package/dist/preview/{chunk.QWGWOEBZ.js → chunk.VLXLBGMY.js} +1 -1
- package/dist/preview/{chunk.IDALEKIW.js → chunk.VTDOWXCP.js} +1 -1
- package/dist/preview/{chunk.4EMKCKDB.js → chunk.VV5JAM5W.js} +1 -1
- package/dist/preview/{chunk.JU6UFWS3.js → chunk.VW632VNJ.js} +1 -1
- package/dist/preview/{chunk.25QFDTCU.js → chunk.WC5WE34A.js} +1 -1
- package/dist/preview/chunk.WN7SAAH6.js +1 -0
- package/dist/preview/{chunk.4UUJHLHR.js → chunk.WV45KLXC.js} +1 -1
- package/dist/preview/{chunk.NAXOXBOF.js → chunk.XDZDNZ7B.js} +1 -1
- package/dist/preview/{chunk.MAKCZ6B6.js → chunk.XFH6GHBQ.js} +1 -1
- package/dist/preview/{chunk.2VUX54XH.js → chunk.XRE7SHLD.js} +1 -1
- package/dist/preview/{chunk.J6HF7IRQ.js → chunk.XXCHO2A5.js} +1 -1
- package/dist/preview/{chunk.A4EZAGG7.js → chunk.Y7OGJOPA.js} +1 -1
- package/dist/preview/{chunk.6NG76MDA.js → chunk.YBQ5GVAX.js} +2 -2
- package/dist/preview/{chunk.QF5QB5YR.js → chunk.YL2RBZFE.js} +1 -1
- package/dist/preview/{chunk.RSQ432QN.js → chunk.YM6SWEUI.js} +1 -1
- package/dist/preview/{chunk.7BJRHPE3.js → chunk.Z2X7BFCB.js} +2 -2
- package/dist/preview/{chunk.VBLQJVQ5.js → chunk.Z67LBSQO.js} +1 -1
- package/dist/preview/{chunk.OHAO6KKH.js → chunk.ZKXIZBCN.js} +1 -1
- package/dist/preview/{chunk.BDNQMKDG.js → chunk.ZLEBOR5T.js} +1 -1
- package/dist/preview/{chunk.CKDCTFLU.js → chunk.ZLNUZ6LR.js} +1 -1
- package/dist/preview/chunk.ZMADWPJO.js +1 -0
- package/dist/preview/chunk.ZO6VMEPP.js +1 -0
- package/dist/preview/chunk.ZUG7U7AT.js +1 -0
- package/dist/preview/index.html +55 -55
- package/dist/preview/page.js +2 -2
- package/package.json +6 -6
- package/dist/preview/chunk.2FHIINXG.js +0 -2
- package/dist/preview/chunk.3ENPWZBG.js +0 -1
- package/dist/preview/chunk.3ZODN6BW.js +0 -1
- package/dist/preview/chunk.55G4IPOO.js +0 -1
- package/dist/preview/chunk.5J6DVR7S.js +0 -1
- package/dist/preview/chunk.7WHQWLL6.js +0 -1
- package/dist/preview/chunk.B5SJMCTT.js +0 -7
- package/dist/preview/chunk.CTUJZ3IV.js +0 -1
- package/dist/preview/chunk.CY7FFKEZ.js +0 -1
- package/dist/preview/chunk.DEKRFTRN.js +0 -4
- package/dist/preview/chunk.EBKH3ILT.js +0 -1
- package/dist/preview/chunk.FOUBDGL3.js +0 -1
- package/dist/preview/chunk.HB5NWHFP.js +0 -3
- package/dist/preview/chunk.HVBKI5ZO.js +0 -1
- package/dist/preview/chunk.I3SDKMQS.js +0 -1
- package/dist/preview/chunk.J5OLYVZ4.js +0 -1
- package/dist/preview/chunk.JKFVNQY7.js +0 -1
- package/dist/preview/chunk.KGMSSXZL.js +0 -1
- package/dist/preview/chunk.NXZL5CA2.js +0 -1
- package/dist/preview/chunk.PSNMZBVS.js +0 -1
- package/dist/preview/chunk.R7CRBRD4.js +0 -1
- package/dist/preview/chunk.RR25BGWP.js +0 -1
- package/dist/preview/chunk.T27QKVKP.js +0 -1
- package/dist/preview/chunk.T3WCRS6M.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as u}from"./chunk.
|
|
1
|
+
import{b as u}from"./chunk.JULD4XFB.js";import{na as l}from"./chunk.6AANHELP.js";function a(e,n){let s=new Map;for(let o of e){let t=n(o.from),i=n(o.to);if(t===void 0||i===void 0)continue;let d=`${o.kind}|${t}|${i}`,r=s.get(d);r||s.set(d,r={edge:o.kind,from:t,to:i,links:0,froms:new Set,tos:new Set}),r.links+=1,r.froms.add(o.from),r.tos.add(o.to)}return[...s.entries()].sort(([o],[t])=>o<t?-1:o>t?1:0).map(([o,t])=>({key:o,edge:t.edge,from:t.from,to:t.to,links:t.links,fromCount:t.froms.size,toCount:t.tos.size}))}function m(e,n,s){let o=[],t=[];for(let d of e){let r=f(d);if(r!==null){o.includes(r)||o.push(r);continue}s(d)!==void 0&&t.push(d)}let i=n.overview&&n.focusId!==null?f(n.focusId):null;return n.beside&&n.overview&&i===null&&n.focusId!==null&&t.length===0&&o.length===0&&s(n.focusId)!==void 0&&t.push(n.focusId),{districts:o,records:t,lens:i}}function f(e){return e.startsWith("kind:")?e.slice(5)||null:e.startsWith("aggregate:")&&!e.includes("|")&&e.slice(10)||null}function y(e,n){let s=u(e,n.from,n.edge,"out"),o=n.from===n.to?" of their own":"";return`${l(e,n.from,n.fromCount)} \u2192 ${l(e,n.to,n.toCount)}${o}, ${s}`}export{a,m as b,f as c,y as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as a}from"./chunk.
|
|
1
|
+
import{g as a}from"./chunk.UD7VLXPM.js";import{c as l}from"./chunk.3DEWQDP7.js";import{Oa as d}from"./chunk.6AANHELP.js";function m(n){let r=new Map;for(let i of n.kinds){let e=n.tryDefinition(i),o=a(e),s=d(e);r.set(i,{fields:new Set(Object.keys(e?.fields?.shape??{})),edges:new Map(Object.entries(e?.edges??{}).map(([p,y])=>[p,y.cardinality??"many"])),...o?{computed:o}:{},...s.size>0?{linked:s}:{}})}let t=a(n);return t&&r.set(l,{computed:t}),r}export{m as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as a}from"./chunk.
|
|
1
|
+
import{e as a}from"./chunk.XXCHO2A5.js";import{l as i}from"./chunk.3VEZ5MOC.js";import{de as o}from"./chunk.6AANHELP.js";function p(t){let r=t.within??{};return o({...r.sort?{sort:r.sort}:{},...r.filter?{filter:r.filter}:{},...r.group?{group:r.group}:{},...r.q?{q:r.q}:{},...r.archived?{archived:r.archived}:{}})}function c(t,r){let m=a(r),e=t;for(let n of["sort","filter","group","q","archived"])e=i(e,n,m[n]??null);return e}export{p as a,c as b};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{a as K}from"./chunk.NYLKG25K.js";import{c as O}from"./chunk.H3W5C3XQ.js";import{G as Oe,W as Q}from"./chunk.3VEZ5MOC.js";import{td as Z}from"./chunk.6AANHELP.js";import{b as L}from"./chunk.AJZBJBMO.js";function ht(e){let t=e.elements[0]?.getRootNode();return t?.host?.closest("[data-worker-view-place]")??t?.host?.parentElement??void 0}var Ee=["no","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve"],G=e=>Ee[e]??String(e),ee=e=>e.replace(/\s+/g," ").trim(),x={li:["item","items"],a:["link","links"],button:["button","buttons"],img:["picture","pictures"],p:["paragraph","paragraphs"],ul:["list","lists"],ol:["list","lists"],table:["table","tables"],tr:["row","rows"],td:["cell","cells"],th:["column heading","column headings"],section:["section","sections"],article:["card","cards"],nav:["menu","menus"],form:["form","forms"],input:["field","fields"],label:["label","labels"]},je=new Set(["js","is","has","item","items","wrap","inner","outer","box","el","block","row","col","cell","card","pick","active","selected"]);function X(e){return e.split(/[-_]+/).filter(r=>/^[a-z]{3,}$/i.test(r)&&!je.has(r.toLowerCase())).at(-1)?.toLowerCase()}function Ne(e){if(e.length<2)return;let t=(r,n)=>Math.abs(r-n)<=6;if(e.every(r=>t(r.top,e[0].top)))return"columns";if(e.every(r=>t(r.left,e[0].left)))return"rows"}function ft(e){if(e.length===0)return"nothing";if(e.length===1){let[i]=e,l=/^h[1-6]$/.test(i.tag)?"heading":x[i.tag]?.[0]??i.classes.map(X).find(Boolean)??"part",g=ee(i.text);return g?`the ${l} \u201C${g.length>40?`${g.slice(0,39)}\u2026`:g}\u201D`:`the ${l}`}let r=e[0].classes.filter(i=>e.every(c=>c.classes.includes(i))).map(X).find(Boolean),n=new Set(e.map(i=>i.tag)),a=Ne(e.map(i=>i.box));if(r)return`the ${G(e.length)} ${r} ${a??(n.size===1&&x[e[0].tag]?x[e[0].tag][1]:"blocks")}`;if(n.size===1){let i=x[e[0].tag]?.[1]??(/^h[1-6]$/.test(e[0].tag)?"headings":a??"parts");return`the ${G(e.length)} ${i}`}let o=new Map;for(let i of e){let c=/^h[1-6]$/.test(i.tag)?"heading":x[i.tag]?.[0]??"part";o.set(c,(o.get(c)??0)+1)}let s=[...o].map(([i,c])=>c===1?`a ${i}`:`${G(c)} ${x[Object.keys(x).find(l=>x[l][0]===i)??""]?.[1]??`${i}s`}`);return s.length===1?s[0]:`${s.slice(0,-1).join(", ")} and ${s.at(-1)}`}function pt(e){return e.map(t=>`<${t.tag}${t.classes.length?` class="${t.classes.join(" ")}"`:""}> ${ee(t.text).slice(0,60)}`.trim())}function yt(e){if(e.length===1)for(let t of e){let r=t.matches("h1, h2, h3, h4, [role='heading']")?t:t.querySelector("h1, h2, h3, h4, [role='heading']");if(!r)continue;let n=r.cloneNode(!0);for(let o of n.querySelectorAll("span"))/^[\s·\d]+$/.test(o.textContent??"")&&o.remove();let a=(n.textContent??"").replace(/\s+/g," ").trim().replace(/^[▸▾]\s*/,"").replace(/\s*\d+$/,"");if(a)return a.length>60?`${a.slice(0,57)}\u2026`:a}}var ne=e=>e===void 0||e.off?void 0:e.fast??(e.decide?{model:e.name??"decide",decide:e.decide}:void 0),Me=/\b(look|looks|looking|nicer|prettier|cleaner|ugly|layout|laid out|lay it out|design|style|styled|theme|colou?rs?|font|bigger|smaller|larger|wider|narrower|taller|shorter|spacing|space|padding|margin|compact|dense|denser|roomier|columns?|grid|cards?|rows?|show (?:the )?\S+ (?:on|in) (?:each|every|the)|sort(?:ed)? by|order(?:ed)? by|group(?:ed)? by|readable|easier to read|at a glance|icons?|badges?|headings?|bold|highlight)\b/i;async function Ie(e,t,r){let n=t.trim(),a=ne(e);if(a&&n)try{let o=await a.decide({typed:n,on:r},{about:{type:"choice",instructions:`Somebody right-clicked \u201C${r}\u201D in an app and typed \u201C${n}\u201D. Is it about how \u201C${r}\u201D looks or is laid out, or about the records in it?`,criteria:{look:"How it looks or is laid out: making it look better, its style, size or spacing, what each row, card or page shows, its order or grouping",records:"The records themselves: changing, closing, assigning, adding, deleting or moving them, or a question about them"}}});e?.meter?.({tier:"fast",model:a.model,inputTokens:o.usage.inputTokens,outputTokens:o.usage.outputTokens,interaction:"menu"});let s=o.answers.about;if(s?.type==="choice"&&(s.choice==="look"||s.choice==="records"))return{about:s.choice,by:"fast",confidence:s.confidence}}catch{}return{about:Me.test(n)?"look":"records",by:"words"}}var Ce=/\b(colou?rs?|font|typeface|bigger|smaller|larger|wider|narrower|taller|spacing|padding|margin|border|shadow|rounded|corners?|columns? side by side|side by side|grid|chart|graph|picture of|animation|background|gradient|icons?|css|kanban|calendar)\b/i,re=.6;async function Le(e,t,r){let n=t.trim();if(!n)return{can:!0,by:"words"};let a=ne(e);if(a)try{let o=await a.decide({asked:n,on:r.name,page:r.slot},{can:{type:"choice",instructions:`Somebody asked of the page \u201C${r.name}\u201D: \u201C${n}\u201D. Can the app's view settings do it, or does it need drawing of its own?`,criteria:{spec:"The view settings can do it: which fields a card, a row or a page shows and in what order, a headline, a badge with a tone, a figure, a progress bar, a list of related records, how a list is sorted, grouped or filtered, a field's label or format",drawing:"It needs drawing the settings have no word for: colors, fonts, sizes, spacing, borders or shadows, a layout or columns side by side, a chart, a calendar, a board, or markup and styles of its own"}}});e?.meter?.({tier:"fast",model:a.model,inputTokens:o.usage.inputTokens,outputTokens:o.usage.outputTokens,interaction:"section"});let s=o.answers.can;if(s?.type==="choice"&&(s.choice==="spec"||s.choice==="drawing"))return{can:s.choice==="spec"||s.confidence<re,by:"fast",confidence:s.confidence}}catch{}return{can:!Ce.test(n),by:"words"}}var se=["set-view","set-glance","set-page-fields","arrange-pages","set-label","set-format"],Ke=new Set(["sort","group","filters"]);function ae(e){let t=[];e.length===0&&t.push("It changed nothing.");for(let r of e){let n=r?.op;if(typeof n!="string"||!se.includes(n)){t.push(`\u201C${String(n)}\u201D is not a change to how a page reads.`);continue}if(n==="arrange-pages")for(let a of Object.keys(r))a!=="op"&&!Ke.has(a)&&t.push(`arrange-pages may say only sort, group and filters here, not \u201C${a}\u201D.`);n==="set-label"&&r.field===void 0&&t.push("set-label may name only a field's label here, not a kind's.")}return t}var oe=["You change how one page of a Graview app reads, by editing its view spec: data that says what a kind's card, row and page show, and how a list opens. Nothing in it is code: no CSS, no markup, no colors or sizes of your own.","You are told the page (a kind's list, one group of it, a record's page, or the home), what was asked, the kind's fields and relations, and its spec as it stands.",'Answer with one JSON object and nothing else: {"edits": [...], "said": "<one sentence to the person saying what will change>"}. Or, where the spec has no word for it (colors, fonts, sizes, spacing, layout, a chart), answer {"cannot": "<one sentence saying what it would need>"}.',"The edits you may use, and no others:",`{"op":"set-view","kind":K,"slot":"card"|"row"|"page","blocks":[...]} \u2014 a kind's card, its row on a list, the blocks over its record page; {"op":"set-view","slot":"home","blocks":[...]} \u2014 the home. Blocks: {"title":"{name}"}, {"headline":"{count(out('rel'))} things"}, {"text":"{field}","lines":2}, {"badge":"{field}","tone":"good"|"warn"|"bad"|"neutral"|"accent"}, {"field":"due","as":"date"|"time"|"datetime"|"relative"|"money"|"percent"|"count","label":"Due"}, {"figure":"expr","as":"number"|"money"|"percent","label":"..."}, {"progress":{"value":"done","max":"total"},"label":"..."}, {"list":"out('rel')" or "all('kind')","as":"row"|"card","sort":{"by":"f","direction":"asc"|"desc"},"limit":5,"group":{"by":"f"},"empty":"None yet."}, {"group":[...blocks],"direction":"row"|"column"}, {"when":"rule expression","show":[...blocks]}, {"divider":true}. Templates say {field}; a row always leads with {"title":"{name}"} or the record's label field.`,`{"op":"set-glance","kind":K,"fields":[...]} \u2014 the few facts said beside a record's name on a list.`,`{"op":"set-page-fields","kind":K,"fields":[...],"groups":[{"title":"...","fields":[...]}]} \u2014 the order and groups of a record page's facts.`,`{"op":"arrange-pages","sort":{K:{"by":"f","direction":"asc"|"desc"}},"group":{K:{"by":"f"}},"filters":{K:["f"]}} \u2014 how a kind's list opens. A list sorts by one of its kind's fields or computed values, and groups only by a choice or a yes-or-no field of its own: grouping by a relation or by the record that holds it is not the spec's to say.`,'{"op":"set-label","kind":K,"field":F,"label":"..."}, {"op":"set-format","kind":K,"field":F,"format":"money"|"percent"|"duration"|null}.',"Name only fields and relations the kind has. Change only what the ask needs, on this page's kind. Keep every fact the page shows now unless asked to drop one.","Do what was asked or answer cannot: never something else in its place (grouping by another field than the one asked for, say)."].join(`
|
|
2
|
+
`);function E(e){let t=e.part.kind,r=e.document,n=t?r.kinds[t]:void 0,a=e.mode==="just"?"Make this page better: easier to read at a glance, the facts a person needs first. Change no data.":(e.words??"").trim();return JSON.stringify({page:{name:e.part.name,is:e.part.slot==="list"?"a kind's list":e.part.slot==="group"?`one group of a kind's list (\u201C${e.part.group}\u201D)`:e.part.slot==="record"?"a record's page (every record of the kind)":e.part.slot==="home"?"the home":"a place",...t?{kind:t}:{}},asked:a,...e.highlighted?.length?{pointed_at:e.highlighted}:{},...n?{fields:n.fields,relations:n.edges??n.relations,computed:n.computed,glance:n.glance,pageFields:n.pageFields}:{kinds:Object.keys(r.kinds)},now:{...t?{views:r.views?.[t]??null,list:r.pages?.lists?.[t]??null}:{home:r.views?.home??null}},...e.shows?{shows:e.shows.slice(0,1500)}:{},...e.findings?.length?{your_last_answer:e.last,what_broke:e.findings,repair:"Your last answer was refused as said in what_broke. Answer again, fixing each one \u2014 or, where the spec cannot do what was asked, answer cannot."}:{}})}function ie(e){let t=/```(?:json|js|javascript)?\s*([\s\S]*?)```/.exec(e)?.[1];for(let r of t?[t,e]:[e]){let n=r.indexOf("{"),a=r.lastIndexOf("}");if(!(n<0||a<=n))try{let o=JSON.parse(r.slice(n,a+1));if(o&&typeof o=="object"&&!Array.isArray(o))return o}catch{}}}function de(e){let t=ie(e);if(t){if(typeof t.cannot=="string"&&t.cannot.trim())return{cannot:t.cannot.trim()};if(Array.isArray(t.edits))return{edits:t.edits,said:typeof t.said=="string"&&t.said.trim()?t.said.trim():"Changed how this page reads."}}}function Ge(e){return async(t,r,n,a)=>{let o=Date.now();try{let s=await t.think({system:n,prompt:a,state:{},catalog:{candidates:[]}});return e.push({stage:r,model:t.model,ms:Date.now()-o,...s.usage?{usage:s.usage}:{}}),s.text}catch{e.push({stage:r,model:t.model,ms:Date.now()-o});return}}}async function ze(e){let t=[],r=e.ai.off?void 0:e.ai.light,n=O(e.ai),a=r??n;if(!a)return{ok:!1,refused:e.ai.withoutModel??"Changing a page needs AI, and none is on here.",stages:t};let o=Ge(t),s={part:e.part,document:e.document,mode:e.mode,...e.words?{words:e.words}:{},...e.highlighted?{highlighted:e.highlighted}:{},...e.shows?{shows:e.shows}:{}},i=async(h,k,v)=>{let f=await o(h,k,oe,v);return f===void 0?void 0:de(f)},c=await i(a,r?"light":"thinking",E(s));if(!c&&r&&(c=await i(r,"light",E(s))),!c)return{ok:!1,refused:"The model did not answer with a change to this page.",stages:t};if("cannot"in c)return{ok:!1,cannot:c.cannot,refused:c.cannot,stages:t};let l=async h=>{let k=ae(h);return k.length>0?k:[...await e.judge(h)]},g=await l(c.edits);if(g.length===0)return{ok:!0,edits:c.edits,said:c.said,repaired:!1,stages:t};let m=a;e.repairing?.(g);let y=await i(m,m===r?"light":"thinking",E({...s,findings:g,last:c}));return y&&"cannot"in y?{ok:!1,cannot:y.cannot,refused:y.cannot,stages:t}:y?(g=await l(y.edits),g.length>0?{ok:!1,refused:`It could not be changed so: ${g.join(" ")}`,stages:t}:{ok:!0,edits:y.edits,said:y.said,repaired:!0,stages:t}):{ok:!1,refused:`It could not be changed so: ${g.join(" ")}`,stages:t}}var te=e=>e.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,40)||"page";function Fe(e,t,r=[]){let n={...t.kinds.length?{kinds:[...t.kinds]}:{},...t.edges.length?{edges:[...t.edges]}:{}},a={...Object.keys(n).length>0?{reads:n}:{},...r.length>0?{acts:[...r]}:{}};if((e.slot==="list"||e.slot==="group")&&e.kind)return{name:`${te(e.kind)}-list`,attach:e.kind,cardinality:"many",replaces:"page",...a};if(e.slot==="record"&&e.kind)return{name:`${te(e.kind)}-page`,attach:e.kind,cardinality:"one",replaces:"page",...a};if(e.slot==="home")return{name:"home-page",attach:"home",cardinality:"many",...a}}var z=["You write a Graview worker view: one plain script, no imports and no build, that draws one page of an app through the global `graview`, in place of the page the app drew by itself.","The global: graview.style(css) a stylesheet; graview.onProps((props) => \u2026) on every push of what it is shown; graview.render(graview.html`\u2026`) draws markup, every ${value} escaped; graview.html`` nests: a list is ${items.map((one) => graview.html`<li>\u2026</li>`)}. Never build HTML as a string or with join(): a string is drawn as its words.","props.nodes holds the records a view of many is drawn for and those it reads; props.node the record a view of one is drawn for. A record is plain data: id, kind, label, and each field by name. props.edges are {kind, from, to}. props.choices[kind][field][option] is a choice's label.",'Link to a record with <a data-record="${node.id}">\u2026</a>. Give repeated rows data-key="${node.id}". Name each part a person would name with a heading inside a <section aria-labelledby="x-h"> whose heading has id="x-h"; never aria-label.',"The page draws its own title above your view: never draw the page's title again. Draw each other heading the page had, with the same words, and every record the page showed: each record still says what its row said (its status, its dates, its counts, in words) and stays under the heading it was under, unless what was asked changes that.",'Say things in words a person reads: a date as the page said it (\u201CSep 3\u201D), never as stored (2026-09-03). A date kept as YYYY-MM-DD is a day, not an instant: read it as new Date(`${value}T00:00`) \u2014 new Date(value) alone is midnight in London and the day before here \u2014 then .toLocaleDateString(props.locale, { month: "short", day: "numeric" }); never show a field\'s own name (order, done, holds), an id, true, false, null or undefined. Leave out a value the page did not show unless asked for it.',`CSS the host keeps: plain rules on your own classes and elements, one level, and @media. Give your outer element a class (class="pg") and style that: never :host, ::slotted or ::part, no url(), @import, @font-face, @keyframes or nesting. Colors, type and corners only through var(--graview-ink), var(--graview-ink-muted), var(--graview-panel), var(--graview-edge), var(--graview-accent), var(--graview-ground), var(--graview-radius). position may be static, relative, absolute or sticky. Set no height; lay it out well at a phone's width and at a desk's.`,"Never write the words import, export or require, nor <script>, <style>, or on\u2026= attributes.",'Answer with one JSON object and nothing else: {"source": "<the whole script>", "said": "<a few words on what you changed>"}.'].join(`
|
|
3
|
+
`);function F(e){return e.records.map(t=>{let r=e.says?.[t];return{record:t,...r?.id?{id:r.id}:{},...r?.shows?.length?{must_show:r.shows}:{},...r?.under?{under:r.under}:{}}})}function V(e){let[t,r]=e.record==="from"?["from","to"]:["to","from"];return`Group the records as the page did: each record sits under a heading that is the label of the ${e.kind} it is linked to \u2014 find the edge in props.edges with kind "${e.edge}" whose ${t} is the record's id; the ${e.kind} is props.nodes' node whose id is the edge's ${r}. Draw the headings in keep_these_headings' order; never guess a record's group from its fields.`}function W(e){let t=ie(e),r=t?.source,n=typeof r=="string"?r.trim().replace(/^```(?:js|javascript)?\s*/i,"").replace(/\s*```$/,"").replace(/^<script[^>]*>\s*/i,"").replace(/\s*<\/script>\s*$/i,""):void 0;if(!(typeof n!="string"||!/graview\.(render|onProps)/.test(n)))return{source:n,said:typeof t.said=="string"?t.said.trim():""}}var ue=["look","read","edit","draft","done","ask"],le=64e3,Ve=e=>e.length>80?`${e.slice(0,79)}\u2026`:e;function he(e,t,r){let n=[],a=e;return t.forEach((o,s)=>{let i=`Edit ${s+1}: \u201C${Ve(o.find)}\u201D`;if(!o.find)return void n.push(`${i} is no text to find: quote the text to change, exactly as it stands in ${r}.`);let c=0;for(let g=a.indexOf(o.find);g>=0&&c<2;g=a.indexOf(o.find,g+o.find.length))c+=1;if(c===0){let g=y=>y.replace(/\s+/g,""),m=g(o.find).length>0&&g(a).includes(g(o.find));return void n.push(`${i} is not in ${r}${m?" as written, but is there with other spacing":""}: quote it exactly as it stands there, spaces and quotes included.`)}if(c>1){let g=a.split(o.find).length-1;return void n.push(`${i} appears ${g} times in ${r}: quote more of the text around the place you mean, so it appears once.`)}let l=a.indexOf(o.find);a=`${a.slice(0,l)}${o.replace}${a.slice(l+o.find.length)}`}),n.length>0?{findings:n}:a===e?{findings:[`Your edits change nothing in ${r}: replace the text with something else, or say you are done.`]}:{source:a}}var fe=12,Y=[z.split(`
|
|
4
|
+
`).filter(e=>!e.startsWith("Answer with one JSON object")).join(`
|
|
5
|
+
`),"","You are Graview, redesigning one page of an app with the person who is looking at it. You work in steps, and each answer is ONE JSON object and nothing else:",'{"say": "<one short plain sentence the person reads: what you are doing or what you found>", "do": "look" | "read" | "edit" | "draft" | "done" | "ask", "edits": [{"find": "<text copied exactly from the script, there once>", "replace": "<what stands there instead>"}], "in": "page" | "draft", "source": "<the whole script>"}',"edits (and, if you like, in) only with edit; source only with draft.","You are shown, before your first step, what the page draws now (what_the_page_draws: its headings, each record's words and the heading it sits under, how they stand) and the records your view is handed (records_it_is_handed): edit or draft first.","- look: see what the page draws now again, as it stands.","- read: the records and fields your view is handed, again.",'- edit: change the script in place. Each find is text copied exactly from your_draft_on_the_page \u2014 or, with "in": "draft", from your_last_draft \u2014 long enough to be there once; replace is what stands there instead ("" takes it out). The code applies them in order, then draws and checks the result exactly as it does a draft; a find that is not there once is handed back to you. For a small change \u2014 a color, a corner, a size, a word, one rule, one part \u2014 answer with an edit, never the whole script again: "no rounded corners on the logo" is one edit of one declaration.',"- draft: for a redesign, or where there is no script on the page yet, your whole script, drawn where only you see it. You are told what the checks found (records, headings, dates, statuses or groups it lost; words it shows as the computer keeps them; a style the page will not keep, by its rule) and what it drew.",'With an edit or a draft, "say" is one sentence of what it does, as the person will read it once it is on the page ("Tasks are cards now, side by side, each with its status and date."). One the checks pass is shown to the person on the page, and your turn ends there.',"- done: you have finished this request; say in one sentence what you changed. Only once an edit or a draft passed, unless you must ask.","- ask: ask the person one short question, and wait for their answer.",`A control that changes a record is a press bound to one of the app's acts (acts_a_press_may_ask_for): <button data-act="finish" data-record="\${task.id}">Done</button> \u2014 the host runs the act for that record when it is pressed. A field the person types into is named for the act's argument, inside a fieldset with the press; data-prefill="field" fills it with the record's own text; data-save on a field saves it as it is typed. Never a checkbox, a toggle or a button bound to nothing, and never graview.act from your own click handler: it is refused. Every control on a record the page let a person press (marking it done, opening it) is kept, bound to the same act. A press that marks a record (an act with \`marks\`) shows what it marked from the record's own field: a record already marked says so and offers the act that undoes it (reopen), so a person sees the press land. The code presses every control headless and tells you what each one did.`,"Keep everything the page showed unless the person asked otherwise: every record, every heading, each record's words (its status, its dates, its counts) and its group. Fix what the checks found \u2014 with an edit where the fix is small \u2014 and keep going until one passes. Write to a person, never about code: no words like view, script, spec, host, CSS or stylesheet in what you say."].join(`
|
|
6
|
+
`);function H(e,t){let r=s=>s.length>le?`${s.slice(0,le)}
|
|
7
|
+
/* \u2026 the script goes on: quote only what you see */`:s,n=M(e.talk.filter(s=>s.who==="person").map(s=>s.said).join(" ")),a=n?e.rewordable??[]:[],o=e.keep&&a.length>0?{...e.keep,headings:e.keep.headings.filter(s=>!a.some(i=>i.trim().toLowerCase()===s.trim().toLowerCase()))}:e.keep;return JSON.stringify({page:e.part.name,view:{attach:e.manifest.attach,cardinality:e.manifest.cardinality,reads:e.manifest.reads??{}},conversation:e.talk.map(s=>({[s.who==="person"?"person":"you"]:s.said})),...e.about&&e.about.name!==e.part.name?{about:e.about.name,...e.about.lines?.length?{pointed_at:e.about.lines}:{}}:{},...e.acts?.length?{acts_a_press_may_ask_for:e.acts.map(s=>({act:s.act,title:s.title,record_goes_in:s.record,...s.toggle?{marks:s.toggle}:{}}))}:{},...e.pressed?.length?{the_controls_as_pressed:e.pressed,then:"The person says something does not work. This is what pressing every control of your draft found: fix what failed, with controls bound to acts."}:{},...e.section?{only_change:`Change only the part \u201C${e.section}\u201D of your_draft_on_the_page; keep every other part of the script as it is, byte for byte.`}:{},...o?{...o.title?{the_page_draws_its_title:o.title}:{},keep_these_headings:o.headings,records:F(o),...o.grouping?{grouping:V(o.grouping)}:{}}:{},...n?{you_may_reword:a.length>0?`The person asked for a heading's words to change: ${a.map(s=>`\u201C${s}\u201D`).join(", ")} may say new words, in the same place. Keep every other heading as it was.`:"The person asked for a heading's words to change: the heading they mean may say new words, in the same place. Keep every other heading as it was."}:{},...e.markup&&!e.current?{the_page_as_html:e.markup.slice(0,5e3)}:{},...e.current?{your_draft_on_the_page:r(e.current)}:{},...e.lastDraft!==void 0&&e.lastDraft!==e.current?{your_last_draft:r(e.lastDraft)}:{},your_steps:t.map((s,i)=>({said:s.said,did:s.did,...s.edits?{edits:s.edits}:{},...s.result!==void 0?{result:s.result}:{},...i<t.length-1&&(s.did==="draft"||s.did==="edit")?{note:s.did==="edit"?"an earlier edit":"an earlier draft"}:{}})),...t.length===0&&e.seen?{what_the_page_draws:e.seen.look,records_it_is_handed:e.seen.read}:{},next:t.length===0?e.current?"Edit or draft first, as one JSON object.":"Draft first, as one JSON object.":"Your next step, as one JSON object."})}function We(e){if(!Array.isArray(e)||e.length===0)return;let t=[];for(let r of e){let n=r?.find,a=r?.replace;if(typeof n!="string"||n.length===0||typeof a!="string")return;t.push({find:n,replace:a})}return t}function pe(e){let t=e.indexOf("{"),r=e.lastIndexOf("}");if(t<0||r<=t)return;let n;try{n=JSON.parse(e.slice(t,r+1))}catch{return}let a=ue.find(i=>i===n.do);if(!a)return;let o=typeof n.say=="string"?n.say.trim():"";if(a==="edit"){let i=We(n.edits),c=n.in==="draft"||n.in==="page"?n.in:void 0;return i?{say:o,do:"edit",...c?{in:c}:{},edits:i}:void 0}if(a!=="draft")return{say:o,do:a};let s=W(JSON.stringify({source:n.source,said:o}));return s?{say:o,do:"draft",source:s.source}:void 0}function Ye(e){let t=/^In “(.+?)”, /.exec(e)?.[1],r=/\((.+?) (?:is|are) kept\)/.exec(e)?.[1],n=/the (?:property|function) “([^”]+)”/i.exec(e)?.[1],a=n?/the function/i.test(e)?`${n}()`:n:/url\(\) is not allowed/.test(e)?"url()":/a value of “([^”]+)”/i.test(e)?`that value of ${/a value of “([^”]+)”/i.exec(e)[1]}`:void 0,o=/^The selector “([^”]+)” reaches outside/.exec(e)?.[1];if(o)return{short:`the selector \u201C${o}\u201D reaches outside the page`,still:`uses the selector \u201C${o}\u201D, which reaches outside the page`};let s=/^“(@[\w-]+)” is not allowed/.exec(e)?.[1];if(s)return{short:`${s} isn't allowed`,still:`uses ${s}, which isn't allowed`};if(/^The stylesheet is too long/.test(e))return{short:"the styles are too long to keep",still:"has styles too long to keep"};if(!a)return{short:"styles the page won't keep",still:"uses styles the page won't keep"};let i=t?` in \u201C${t}\u201D`:"";return{short:t&&r?`\u201C${t}\u201D keeps ${r}; ${a} isn't allowed`:`${a}${i} isn't allowed`,still:`uses ${a}${i}, which isn't allowed`}}function ye(e,t){let r=n=>n===1?`one of the ${t}`:`${n} ${t}`;switch(D(e)){case"fact-lost":{let n=/no longer says what it said: (.*?)(?: and (\d+) more)?\. Show/.exec(e),a=new Set([...(n?.[1]??"").matchAll(/” on “([^”]+)”/g)].map(i=>i[1])),o=[...(n?.[1]??"").matchAll(/“([^”]+)” on “/g)].some(i=>/\b(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*\.?\s+\d|\d{1,2}\s+(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i.test(i[1])),s=Math.max(1,a.size+Number(n?.[2]??0));return{short:`${o?"dates":"details"} lost on ${r(s)}`,still:`loses ${o?"the dates":"details"} on ${r(s)}`}}case"record-lost":{let n=/^It no longer shows (.*?)(?: and (\d+) more)?: show every record/.exec(e),a=Math.max(1,[...(n?.[1]??"").matchAll(/“/g)].length+Number(n?.[2]??0));return{short:`${r(a)} missing`,still:`leaves out ${r(a)}`}}case"record-twice":case"record-moved":return{short:`${t} in the wrong group`,still:`puts ${t} in the wrong group`};case"heading-lost":return{short:"headings missing",still:"drops headings the page had"};case"section-lost":{let n=/^“(.*)” is not drawn any more/.exec(e)?.[1]??"";return{short:`the part \u201C${n}\u201D missing`,still:`drops the part \u201C${n}\u201D`}}case"title-twice":return{short:"the title drawn twice",still:"draws the title twice"};case"computer-words":return{short:"words shown as the computer keeps them",still:"shows words as the computer keeps them"};case"did-not-draw":return{short:"it didn't draw",still:"doesn't draw"};case"style-refused":return Ye(e);case"edit-missed":{if(/^There is no script to edit/.test(e))return{short:"nothing to edit yet",still:"has nothing to edit"};if(/^Your edits change nothing/.test(e))return{short:"the edit changes nothing",still:"changes nothing"};let n=/appears (\d+) times/.exec(e)?.[1];return n?{short:`an edit's text appears ${n} times`,still:`quotes text that appears ${n} times`}:{short:"an edit's text isn't in the script",still:"quotes text that isn't in the script"}}case"unstyled":return{short:"a part left without its style",still:"leaves a part without its style"};case"control":return{short:"a control that doesn't work",still:"has a control that doesn't work"};default:{let n=(/^(.*?[.!?])(\s|$)/.exec(e.trim())?.[1]??e.trim()).replace(/[.!?]+$/,""),a=n.length>120?`${n.slice(0,119)}\u2026`:n;return{short:a,still:`fails a check: ${a}`}}}}function j(e,t="records"){return[...new Set(e.map(n=>ye(n,t).short))].slice(0,3).join(", ")}function we(e,t,r="records"){return`I tried twice, and the new design still ${ye(e,r).still}. ${t?"Keep it anyway, or stop?":"Say it another way, or stop?"}`}var ce=e=>{let t=D(e);return t==="other"?`other:${e}`:t};async function ge(e,t,r){if(t?.aborted)return"stopped";let n,a,o=await Promise.race([e.then(s=>({value:s})),...t?[new Promise(s=>t.addEventListener("abort",n=()=>s("stopped"),{once:!0}))]:[],...r!==void 0?[new Promise(s=>a=setTimeout(()=>s("late"),r))]:[]]);return n&&t?.removeEventListener("abort",n),a&&clearTimeout(a),o}async function He(e){let t=[],r=[],n=e.ai.off?void 0:e.ai.design??O(e.ai)??e.ai.light;if(!n)return{ended:"no-model",said:e.ai.withoutModel??"Changing how a page looks needs AI, and none is on here.",steps:r,stages:t};let a=h=>e.onEvent?.(h),o=e.noun??(e.part.slot==="record"?"parts":"records"),s,i,c=0,l=0,g=new Set,m=Math.max(2,e.steps??fe);a({kind:"look",text:`Looking at ${e.part.name}`});let y={look:e.host.look(),read:e.host.read()};for(let h=0;h<m;h++){let k=Date.now(),v=await ge((n.stream?n.stream({system:Y,prompt:H({...e,seen:y,...i?{lastDraft:i.source}:{}},r),state:{},catalog:{candidates:[]}},$=>a({kind:"streaming",text:me($)}),e.signal):n.think({system:Y,prompt:H({...e,seen:y,...i?{lastDraft:i.source}:{}},r),state:{},catalog:{candidates:[]}})).then($=>(t.push({stage:"thinking",model:n.model,ms:Date.now()-k,...$.usage?{usage:$.usage}:{}}),$.text),()=>{t.push({stage:"thinking",model:n.model,ms:Date.now()-k})}),e.signal,e.stepMs??10*6e4);if(v==="late")return{ended:"steps",said:s?"The model stopped answering; here is where it got to.":"The model didn't answer in time. Ask again, or say it another way.",...s?{passed:s}:{},...i?{last:i}:{},steps:r,stages:t};if(v==="stopped")return{ended:"stopped",said:"Stopped.",...s?{passed:s}:{},...i?{last:i}:{},steps:r,stages:t};let f=v.value===void 0?void 0:pe(v.value);if(!f){if(c+=1,c>=3)break;r.push({said:"",did:"look",result:{error:"Your answer was not one JSON object with say and do (with edits for an edit, the whole script in source for a draft). Answer again."}});continue}if(f.do==="look")a({kind:"look",text:`Looking at ${e.part.name}`}),r.push({said:f.say,did:"look",result:e.host.look()});else if(f.do==="read")a({kind:"read",text:`Reading what ${e.part.name} shows`}),r.push({said:f.say,did:"read",result:e.host.read()});else if(f.do==="draft"||f.do==="edit"){let $=f.source,P=f.edits??[];if(f.do==="edit"){a({kind:"edit",text:f.say?`Changing: ${f.say.replace(/\.$/,"")}`:"Changing it"});let S=f.in==="draft"?i?{script:i.source,where:"your last draft"}:void 0:e.current!==void 0?{script:e.current,where:"the script on the page"}:i?{script:i.source,where:"your last draft"}:void 0,_=S?he(S.script,P,S.where):{findings:[f.in==="draft"?"There is no script to edit yet: you have made no draft this turn, so edit the script on the page or draft the whole script.":"There is no script to edit yet: draft the whole script."]};if("findings"in _){a({kind:"check",text:`Check: ${j(_.findings,o)} \u2014 fixing`,findings:N(_.findings)}),r.push({said:f.say,did:"edit",edits:P,result:{findings:_.findings}});continue}$=_.source}else a({kind:"draft",text:f.say?`Drafting: ${f.say.replace(/\.$/,"")}`:"Drafting"});let T=f.do,A={said:f.say,did:T,...T==="edit"?{edits:P}:{}},d=q($,e.current!==void 0?{already:e.current}:{}),p=()=>e.host.draft($).catch(S=>({findings:[`The draft could not be judged: ${String(S instanceof Error?S.message:S).replace(/[.\s]+$/,"")}.`],drew:void 0})),w=d.length>0?{findings:d,drew:void 0}:await ge(p(),e.signal).then(S=>typeof S=="string"?void 0:S.value);if(!w)return{ended:"stopped",said:"Stopped.",...s?{passed:s}:{},...i?{last:i}:{},steps:r,stages:t};i={source:$,findings:w.findings},l+=1;let b=N(w.findings);try{e.ai.onDraftChecked?.({part:e.part.name,draft:l,passed:b.length===0,findings:b})}catch{}let C=w.findings.find(S=>g.has(ce(S)));if(g=new Set(w.findings.map(ce)),C!==void 0){let S=!w.findings.some(Pe=>D(Pe)==="did-not-draw"),_=we(C,S,o);return a({kind:"stuck",text:`Check: ${j([C],o)}, again`,findings:b}),r.push({...A,result:{findings:w.findings,drew:w.drew}}),{ended:"stuck",said:_,keepable:S,...s?{passed:s}:{},last:i,steps:r,stages:t}}if(w.findings.length===0)return s={source:$},a({kind:"passed",text:"Check: nothing lost \u2014 it's on the page"}),r.push({...A,result:{findings:[],drew:w.drew,shown:"It passed and is on the page now."}}),{ended:"done",said:f.say||"Here it is.",passed:s,last:i,steps:r,stages:t};a({kind:"check",text:`Check: ${j(w.findings,o)} \u2014 fixing`,findings:b}),r.push({...A,result:{findings:w.findings,drew:w.drew}})}else{if(f.do==="ask")return{ended:"ask",said:f.say||"What would you like it to look like?",...s?{passed:s}:{},...i?{last:i}:{},steps:r,stages:t};if(!s&&i&&i.findings.length>0&&h<m-2){r.push({said:f.say,did:"done",result:{not_yet:"No draft has passed the checks yet. Fix what the last check found with an edit or a draft, or ask the person."}});continue}return{ended:"done",said:f.say||(s?"Done.":"I stopped here."),...s?{passed:s}:{},...i?{last:i}:{},steps:r,stages:t}}}return{ended:"steps",said:s?"Here is where it got to.":"I haven't got it right yet. Tell me more, or ask me to keep going.",...s?{passed:s}:{},...i?{last:i}:{},steps:r,stages:t}}function me(e){let t=/"say"\s*:\s*"((?:[^"\\]|\\.)*)/.exec(e)?.[1],r="";if(t!==void 0)try{r=JSON.parse(`"${t.replace(/\\$/,"")}"`)}catch{r=t}let n=e.indexOf('"source"'),a=n>=0?e.slice(n).split("\\n").length:0,o=a>1?`writing it, ${a} lines so far`:"";return r&&o?`${r.replace(/\.$/,"")} \u2014 ${o}`:r||(o?`Writing the design, ${a} lines so far`:"Thinking\u2026")}function qe(e){return{headings:e.headings,records:e.records.map(t=>({record:t.label,says:t.facts??[],...t.under?{under:t.under}:{},at:{top:t.top,left:t.left},type_px:t.size}))}}function Se(e){let t=[];for(let r of e.matchAll(/graview\.style\(\s*([`"'])/g)){let n=r[1],a=r.index+r[0].length,o=a;for(;o<e.length&&e[o]!==n;)o+=e[o]==="\\"?2:1;o<e.length&&t.push({start:a,end:o,quote:n})}return t}var Et=["You revise one section of a view in a Graview app.","The view is a plain script: it draws HTML with graview.html`\u2026` templates and styles it with graview.style(css).","You are given the section's markup exactly as it stands in the script's template. It may hold ${\u2026} interpolations: keep each one you keep exactly as written, and never name a variable that is not already in them.","You are given the stylesheet rules that style only this section (you rewrite them), the rules it shares with the rest of the view (never restate or change those), the app's look (its scheme and the values of its --graview-* tokens), and the words the section shows now.",`Answer with one JSON object and nothing else: {"markup": "<the section's whole new markup>", "css": "<every rule that styles it now>", "said": "<one sentence to the person saying what you changed>"}.`,"Keep the same outer element, and keep its name \u2014 its label or its heading's words \u2014 so it is still found. Show the same data. Style every class the markup uses, or stop using it. Use var(--graview-\u2026) tokens for colors, type and corners, never colors of your own.","Never use import, export, require, <script>, <style>, or on\u2026= attributes."].join(" ");var u=e=>e.replace(/\s+/g," ").trim().toLowerCase(),J=["no","one","two","three","four","five","six","seven","eight","nine","ten"],et=e=>e.length<2?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function tt({refusal:e,rule:t,kept:r}){let n=e.name?`\u201C${e.name}\u201D`:"",a=t?`In \u201C${t}\u201D, `:"",o=r&&r.length>0?` (${et(r)} ${r.length===1?"is":"are"} kept)`:"",s=i=>a?`${a}${i}`:i.charAt(0).toUpperCase()+i.slice(1);switch(e.reason){case"selector":return`The selector \u201C${/^(host|host-context)$/.test(e.name??"")?":":/^(slotted|part)$/.test(e.name??"")?"::":""}${e.name??""}\u201D reaches outside the view and is removed with its rule: give the view's outer element a class and style that instead.`;case"at-rule":return`${n||"An at-rule"} is not allowed and is removed with what it holds: use plain rules and @media only.`;case"property":return`${s(`the property ${n}`)} is not allowed and is removed${o}: use ordinary layout, color and type properties.`;case"function":return`${s(`the function ${n}()`)} is not allowed and is removed${o}: use var(--graview-\u2026), calc(), min(), max(), clamp() or repeat().`;case"url":return`${s("url()")} is not allowed and is removed${o}: draw nothing from an address.`;case"value":return`${s(`a value of ${n||"a property"}`)} is not allowed and is removed${o} (position may be static, relative, absolute or sticky).`;case"size":return"The stylesheet is too long and is removed whole: keep it short.";default:return`${s(`a rule ${n?`near ${n} `:""}`)}could not be read and is removed: write plain CSS, one rule at a time, no nesting.`}}function nt(e){let t=[],r=e.replace(/\/\*[\s\S]*?\*\//g,a=>" ".repeat(a.length)),n=0;for(;n<r.length;){let a=r.indexOf("{",n);if(a<0)break;let o=0,s=a;for(;s<r.length;s++)if(r[s]==="{")o+=1;else if(r[s]==="}"&&--o===0)break;t.push({head:r.slice(n,a).replace(/\s+/g," ").trim(),text:r.slice(n,s+1)}),n=s+1}return t}function rt(e){let t=e.indexOf("{");return t<0||e.trimStart().startsWith("@")?[]:[...new Set([...e.slice(t+1).matchAll(/(?:^|;)\s*(-{0,2}[a-zA-Z][\w-]*)\s*:/g)].map(r=>r[1]))]}function $e(e){let t=[];for(let r of Se(e)){let n=e.slice(r.start,r.end).replace(/\$\{(?:[^{}]|\{[^{}]*\})*\}/g,"0"),a=K(n).refused;if(a.length===0)continue;if(a.some(s=>s.reason==="size")){t.push({refusal:{reason:"size"}});continue}let o=[...a];for(let s of nt(n)){let i=K(s.text),c=rt(i.css);for(let l of i.refused){let g=o.findIndex(m=>m.reason===l.reason&&m.name===l.name);g<0||(o.splice(g,1),t.push({refusal:l,...s.head?{rule:s.head}:{},...c.length>0?{kept:c}:{}}))}}t.push(...o.map(s=>({refusal:s})))}return t}var xe=e=>`${e.refusal.reason}|${e.refusal.name??""}|${(e.rule??"").replace(/\s+/g,"")}`;function q(e,t={}){let r=t.already===void 0?new Set:new Set($e(t.already).map(xe)),n=new Set;for(let a of $e(e))r.has(xe(a))||n.add(tt(a));return[...n]}var _e=/\b\d{4}-\d{2}-\d{2}(?:T[\d:.]+Z?)?\b/,Re=/<\/?[a-z][a-z0-9-]*(?:\s[^<>]*)?>/i,st=/(?<![\w])(undefined|null|NaN|\[object Object\]|true|false)(?![\w])/g,at=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],B=/\b(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*\.?\s+(\d{1,2})\b|\b(\d{1,2})\s+(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*\b/,Ae=/\b(mon|tue|wed|thu|fri|sat|sun)[a-z]*\b|\b(today|tomorrow|yesterday)\b/;function ke(e,t){let r=u(e),n=u(t);if(!n||r.includes(n))return!0;let a=i=>i.replace(/[^\p{L}\p{N}]+/gu,"");if(a(n).length>=3&&a(r).includes(a(n)))return!0;let o=B.exec(n);if(o){let i=o[1]??o[4],c=Number(o[2]??o[3]);for(let l of r.matchAll(new RegExp(B.source,"g")))if((l[1]??l[4])===i&&Number(l[2]??l[3])===c)return!0;return at.every(l=>!r.includes(l))&&Ae.test(r)}let s=/^\D*(\d+(?:[.,]\d+)?)\D*$/.exec(n);if(s){if(new RegExp(`(^|\\D)${s[1].replace(/[.,]/g,"[.,]")}(\\D|$)`).test(r))return!0;let i=Number(s[1]);return i===0?/\b(no|none|zero|nothing|not any)\b/.test(r):Number.isInteger(i)&&i<J.length&&new RegExp(`\\b${J[i]}\\b`).test(r)}return!1}var ot=/\b(hide|hides|hiding|remove|drop|without|no more|less|fewer|only|just|minimal|simpler|declutter|strip)\b/i,De=/\b(group|groups|grouped|regroup|section|sections|categor\w*|split|move|moved|bucket\w*|by (status|date|day|list|owner|person))\b/i;function it(e,t){if(!e||!ot.test(e))return!1;let r=e.toLowerCase();return/\b(only|just)\b[^.]*\b(name|names|title|titles|label|labels)\b/.test(r)?!0:B.test(u(t))||Ae.test(u(t))?/\b(date|dates|due|day|days|when|deadline|deadlines)\b/.test(r):/^\D*\d/.test(t)?/\b(count|counts|number|numbers|how many|total|totals)\b/.test(r):/\b(status|statuses|state|tag|tags|chip|chips|badge|badges|label|labels|pill|pills|meta|details)\b/.test(r)||r.includes(u(t))}var dt=/\b(re-?word\w*|re-?name\w*|re-?title\w*|re-?phrase\w*|rewrite|shorten|shorter|longer|wording|words|call it|say|says)\b/i,lt=/\b(heading|headings|title|titles|header|headers|headline|headlines)\b/i;function M(e){return!!(e&&dt.test(e)&<.test(e))}function be(e,t){let r=new Map;if(e.length!==t.length)return r;let n=new Set(e.map(u)),a=new Set(t.map(u));return e.forEach((o,s)=>{let i=t[s];u(o)!==u(i)&&!a.has(u(o))&&!n.has(u(i))&&r.set(o,i)}),r}function ve(e,t,r,n){if(!M(n.asked))return[...e];let a=be(t,r),o=s=>!n.mayReword||n.mayReword.some(i=>u(i)===u(s));return e.filter(s=>!(a.has(s)&&o(s)))}function D(e){return/^Edit \d+: “|^There is no script to edit|^Your edits change nothing/.test(e)?"edit-missed":/no longer says what it said/.test(e)?"fact-lost":/^It no longer shows “/.test(e)?"record-lost":/more often than the page did/.test(e)?"record-twice":/moved to another group/.test(e)?"record-moved":/no longer shows the heading/.test(e)?"heading-lost":/” is not drawn any more\.?$/.test(e)?"section-lost":/drawn twice/.test(e)?"title-twice":/markup as words|a date as “|as the computer keeps it|a field's name/.test(e)?"computer-words":/is still drawn and no rule styles it/.test(e)?"unstyled":/can no longer be marked|no longer opens? (its|their) page/.test(e)?"control":/did not draw|did not start|threw while drawing|could not start/.test(e)?"did-not-draw":/not allowed|is removed|reaches outside/.test(e)?"style-refused":"other"}var N=e=>e.map(t=>({kind:D(t),words:t}));function Je(e,t,r={}){let n=[],a=u(t.text),o=e.records.map(d=>d.label).filter(d=>d&&!a.includes(u(d)));o.length>0&&n.push(`It no longer shows ${o.slice(0,4).map(d=>`\u201C${d}\u201D`).join(", ")}${o.length>4?` and ${o.length-4} more`:""}: show every record the page showed.`);let s=(d,p)=>d.split(u(p)).length-1,i=u(e.text),c=e.records.map(d=>d.label).filter(d=>d&&s(a,d)>s(i,d));c.length>0&&!(r.asked&&De.test(r.asked))&&n.push(`It shows ${c.slice(0,4).map(d=>`\u201C${d}\u201D`).join(", ")}${c.length>4?` and ${c.length-4} more`:""} more often than the page did: show each record where the page showed it, and nowhere else.`);let l=[],g=[];for(let d of e.records){let p=t.records.find(b=>u(b.label)===u(d.label));if(!p)continue;let w=`${p.row??""} ${p.under??""}`;for(let b of d.facts??[])!ke(w,b)&&!it(r.asked,b)&&l.push(`\u201C${b}\u201D on \u201C${d.label}\u201D`);d.under&&p.under&&u(d.under)!==u(p.under)&&t.headings.some(b=>u(b)===u(d.under))&&!(r.asked&&De.test(r.asked))&&g.push(`\u201C${d.label}\u201D is under \u201C${p.under}\u201D, and was under \u201C${d.under}\u201D`)}l.length>0&&n.push(`A record no longer says what it said: ${l.slice(0,4).join(", ")}${l.length>4?` and ${l.length-4} more`:""}. Show on each record what the page showed on it (its status, its dates, its counts), in words.`),g.length>0&&n.push(`A record moved to another group: ${g.slice(0,3).join("; ")}${g.length>3?` and ${g.length-3} more`:""}. Keep each record under the heading it was under.`);let m=ve(e.headings.filter(d=>d&&!a.includes(u(d))),e.headings,t.headings,r);m.length>0&&n.push(`It no longer shows the heading${m.length>1?"s":""} ${m.map(d=>`\u201C${d}\u201D`).join(", ")}: keep each heading the page had.`);let y=new Map;for(let d of t.headings)d.trim()&&y.set(u(d),(y.get(u(d))??0)+1);let h=[...y].filter(([,d])=>d>1).map(([d])=>t.headings.find(p=>u(p)===d)),k=e.headings.filter(d=>!h.some(p=>u(p)===u(d)));h.length>0&&n.push(`The heading${h.length>1?"s":""} ${h.map(d=>`\u201C${d}\u201D`).join(", ")} ${h.length>1?"are":"is"} drawn twice: the page already draws its title above the view, so leave it out${k.length>0?` \u2014 and keep every other heading as it was: ${k.map(d=>`\u201C${d}\u201D`).join(", ")}`:""}.`);let v=Re.exec(t.text);v&&!Re.test(e.text)&&n.push(`It shows its own markup as words (\u201C${v[0].slice(0,40)}\u201D): build it with graview.html\`\u2026\`, nesting graview.html for each list, never a string of HTML.`);let f=_e.exec(t.text);f&&!_e.test(e.text)&&n.push(`It shows a date as \u201C${f[0]}\u201D: say dates in words, as the page did (\u201CSep 3\u201D).`);let $=Object.values(r.values??{}).flat().filter(d=>typeof d=="string").join(`
|
|
8
|
+
`),T=[...t.text.matchAll(st)].map(d=>d[1]).find(d=>{let p=new RegExp(`(^|[^\\w])${d.replace(/[[\]]/g,"\\$&")}([^\\w]|$)`);return!p.test(e.text)&&(d==="[object Object]"||!p.test($))});T&&n.push(`It shows \u201C${T}\u201D, which is a value as the computer keeps it, not words for a person: say it in words or leave it out.`);let A=d=>d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");for(let d of r.fields??[]){if(d.length<3||["label","name","title"].includes(d))continue;let p=(r.values?.[d]??[]).map(b=>A(String(b))).filter(b=>b.length>0&&b.length<=40),w=/[A-Z]/.test(d)?new RegExp(`\\b${d}\\b`):r.values?p.length>0?new RegExp(`(?:^|[^\\w])${d}(?:\\s*[:=]\\s*|\\s+)(?:${p.join("|")})(?![\\w])`):void 0:new RegExp(`(?:^|[^\\w])${d}\\s*[:=]\\s*(?:\\d|true\\b|false\\b|null\\b|undefined\\b)`);if(w&&w.test(t.text)&&!w.test(e.text)){n.push(`It shows \u201C${d}\u201D, a field's name, not words for a person: say what it means, or leave it out.`);break}}return n}function Te(e){let t=new Map;for(let r of e){let n=[...t.keys()].find(a=>Math.abs(a-r.top)<=6)??r.top;t.set(n,(t.get(n)??0)+1)}return Math.max(0,...t.values())}function Be(e,t,r){let n=[],a=Te(t.records),o=Te(r.records);o>1&&o!==a?n.push(`side by side, ${J[o]??o} to a line`):o===1&&a>1&&n.push("one under another");let s=h=>h.length?h.reduce((k,v)=>k+v.size,0)/h.length:0,i=s(t.records)>0?s(r.records)/s(t.records):1;i>=1.12?n.push("in bigger type"):i<=.89&&n.push("in smaller type");let c=(h,k)=>h.map(v=>u(v.label)).filter(v=>k.has(v)),l=new Set(t.records.map(h=>u(h.label)).filter(h=>r.records.some(k=>u(k.label)===h)));c(t.records,l).join("|")!==c(r.records,l).join("|")&&n.push("in a new order");let g=new Set(t.records.map(h=>u(h.label))),m=r.headings.filter(h=>h.trim()&&!t.headings.some(k=>u(k)===u(h))&&u(h)!==u(e)&&!g.has(u(h)));if(m.length>0&&n.push(`under ${m.length===1?"a new heading":"new headings"}: ${m.slice(0,3).map(h=>`\u201C${h}\u201D`).join(", ")}`),n.length===0)return;let y=/s$/i.test(e.trim());return`${e} now ${y?"show":"shows"} ${n.length===1?n[0]:`${n.slice(0,-1).join(", ")} and ${n.at(-1)}`}.`}var R=(e,t)=>new RegExp(`\\s${t}="([^"]*)"`).exec(e)?.[1];function Ue(e,t,r,n="record"){let a=e.problems.slice(0,5).map(l=>`${l.control}: ${l.says}`),o=l=>e.controls.some(g=>g.ok&&g.does==="act"&&R(g.element,"data-record")===l&&r.includes(R(g.element,"data-act")??"")),s=l=>e.controls.some(g=>g.ok&&g.does==="link"&&R(g.element,"data-record")===l),i=r.length>0?t.filter(l=>l.presses&&!o(l.id)):[];i.length>0&&a.push(`${i.slice(0,3).map(l=>`\u201C${l.label}\u201D`).join(", ")}${i.length>3?` and ${i.length-3} more`:""} can no longer be marked as the page let a person mark ${i.length===1?"it":"them"}: give each ${n} a press bound to ${r.map(l=>`\u201C${l}\u201D`).join(" or ")}, e.g. <button data-act="${r[0]}" data-record="${i[0].id}">\u2026</button>.`);let c=t.filter(l=>l.opens&&!s(l.id));return c.length>0&&a.push(`${c.slice(0,3).map(l=>`\u201C${l.label}\u201D`).join(", ")}${c.length>3?` and ${c.length-3} more`:""} no longer ${c.length===1?"opens its":"open their"} page: link each with data-record="its id".`),a}function Ze(e,t,r="records"){let n=[];for(let o of t){let s=new Set(e.controls.filter(i=>i.ok&&i.does==="act"&&R(i.element,"data-act")===o.act).map(i=>R(i.element,"data-record")??i.control));s.size>0&&n.push(`${o.title.replace(/[.…]+$/,"")} works on ${s.size===1?"one of the":`${s.size}`} ${r}`)}let a=new Set(e.controls.filter(o=>o.ok&&o.does==="link"&&R(o.element,"data-record")).map(o=>R(o.element,"data-record")));if(a.size>0&&n.push(`${a.size} open${a.size===1?"s its":" their"} page${a.size===1?"":"s"}`),n.length!==0)return`Pressing each control checked it: ${n.length<2?n[0]:`${n.slice(0,-1).join(", ")} and ${n.at(-1)}`}.`}var Qe=/\b(check ?box(es)?|button|click|tap|press|toggle|mark(ed|s|ing)?|complet(e|ed|ing)|finish(ed|es|ing)?|persist|sav(e|es|ed|ing)|updat(e|es|ed|ing)|works?|working|data)\b/i,Xe=/\b(does(n'?t| not)|did(n'?t| not)|can'?t|cannot|won'?t|not)\s+(work|working|persist|save|stick|change|update|do anything|mark|finish|complete|click|press)|\bfake\b|\bbroken\b|\bstill (broken|not)\b/i;var I=L(Oe(),1),U=L(Q(),1);function ct(e){let t=null;for(let r of e){if(!r.isConnected)continue;let n=r.getBoundingClientRect();n.width===0&&n.height===0||(t=t?{left:Math.min(t.left,n.left),top:Math.min(t.top,n.top),right:Math.max(t.right,n.right),bottom:Math.max(t.bottom,n.bottom)}:{left:n.left,top:n.top,right:n.right,bottom:n.bottom})}return t?new DOMRect(t.left,t.top,t.right-t.left,t.bottom-t.top):null}function Ft({elements:e,label:t}){let r=(0,I.useRef)(null);return(0,I.useEffect)(()=>{let n=0,a=()=>{let o=ct(e),s=r.current;s&&(s.style.display=o?"block":"none",o&&(s.style.left=`${Math.round(o.left-3)}px`,s.style.top=`${Math.round(o.top-3)}px`,s.style.width=`${Math.round(o.width+6)}px`,s.style.height=`${Math.round(o.height+6)}px`)),n=requestAnimationFrame(a)};return a(),()=>cancelAnimationFrame(n)},[e]),(0,U.jsx)("div",{ref:r,"aria-hidden":"true","data-testid":"section-outline",style:gt,children:t?(0,U.jsx)("span",{style:ut,children:t}):null})}var gt={position:"fixed",display:"none",boxSizing:"border-box",border:"2px dashed var(--graview-accent)",borderRadius:8,pointerEvents:"none",zIndex:Z("popover")},ut={position:"absolute",top:-11,left:8,padding:"0 6px",fontSize:"0.6875rem",lineHeight:"18px",borderRadius:999,color:"var(--graview-accent-ink, #fff)",background:"var(--graview-accent)"};export{ht as a,ft as b,pt as c,yt as d,ve as e,Je as f,Be as g,Ue as h,Ze as i,Qe as j,Xe as k,Ie as l,Le as m,ze as n,Fe as o,He as p,qe as q,ct as r,Ft as s};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import"./chunk.
|
|
1
|
+
import"./chunk.MSUZAJ2K.js";import{a as _,b as me,c as he,e as fe}from"./chunk.Q6H5HESF.js";import"./chunk.3JMQKANL.js";import"./chunk.XXCHO2A5.js";import"./chunk.SADR3MQI.js";import"./chunk.HJCQ6I3S.js";import{a as we,d as ve}from"./chunk.2BMZPALF.js";import"./chunk.GONZB3J3.js";import{d as ye}from"./chunk.DMZRFXH7.js";import"./chunk.DZ6UDZOB.js";import{a as de}from"./chunk.Q4VFLLUT.js";import"./chunk.6ZENHSTQ.js";import"./chunk.BHJRT57H.js";import"./chunk.BIDL7GQD.js";import"./chunk.CNN32262.js";import"./chunk.N5Z34V7U.js";import"./chunk.LOKGUALC.js";import"./chunk.Q5WEOX3Q.js";import"./chunk.KAM73WVF.js";import"./chunk.O32F6LGK.js";import"./chunk.EGSOHTZZ.js";import"./chunk.WVUJXDXZ.js";import"./chunk.L7XKYGV7.js";import"./chunk.CE3NKAF7.js";import"./chunk.R3GE37OI.js";import"./chunk.2KCDLCB2.js";import"./chunk.UD7VLXPM.js";import"./chunk.3DEWQDP7.js";import"./chunk.MIE4TJRW.js";import{p as pe,s as K}from"./chunk.CFE3MHWZ.js";import"./chunk.RD2FSSLV.js";import{a as ue}from"./chunk.HXTKBISQ.js";import"./chunk.TFJA4QV4.js";import"./chunk.HWFJQ42Y.js";import"./chunk.QUETLFBJ.js";import{b as ce}from"./chunk.JULD4XFB.js";import"./chunk.GRTBEA7O.js";import{t as ge}from"./chunk.H3IGXHZR.js";import"./chunk.7TDML5YU.js";import{G as Ee,K as L,Qa as le,Ra as W,W as ie,Z as se,ea as P,ga as $,j as N,l as ae,m as q,r as C,ra as G,v as re,z as oe}from"./chunk.3VEZ5MOC.js";import"./chunk.SDO3U72B.js";import{Z as V,ka as I,la as B,na as F,pa as M,td as ne,ua as te}from"./chunk.6AANHELP.js";import"./chunk.FQLNBIQ5.js";import{b as D}from"./chunk.AJZBJBMO.js";var p=D(Ee(),1);var e=D(ie(),1),Ae=ge.part((t,s)=>(0,e.jsx)(t.ProblemRows,{...s}),{what:"The problems",as:"li"}),R="var(--graview-gap, 8px)",Re=720;function je({showing:t}){return t.what==="lens"?(0,e.jsx)(Ne,{kind:t.kind},`lens:${t.kind}`):t.what==="record"?(0,e.jsx)(Ie,{id:t.id},`record:${t.id}`):(0,e.jsx)($e,{kind:t.kind},`district:${t.kind}`)}var U=[{height:"52%",share:.52,said:"Half of the screen"},{height:"66%",share:.66,said:"Two thirds of the screen"},{height:"calc(100% - 56px)",share:1,said:"Nearly all of the screen"}],xe=1,be=xe;function Ce(){let[t,s]=(0,p.useState)(be);return[t,n=>{be=n,s(n)}]}var Pe=t=>U.map(s=>s.share===1?t-56:t*s.share);function Te({region:t,rest:s,setRest:n,label:i}){let l=(0,p.useRef)(null),c=o=>n(Math.max(0,Math.min(2,o)));return(0,e.jsx)("div",{role:"separator","aria-orientation":"horizontal","aria-label":`How much of the screen ${i} takes`,"aria-valuemin":0,"aria-valuemax":2,"aria-valuenow":s,"aria-valuetext":U[s].said,tabIndex:0,"data-testid":"map-panel-handle","data-graview-rest":s,title:"Drag to see more or less of the map",onKeyDown:o=>{let r=o.key==="ArrowUp"?s+1:o.key==="ArrowDown"?s-1:o.key==="Home"?0:o.key==="End"?2:null;r!==null&&(o.preventDefault(),c(r))},onPointerDown:o=>{let r=t.current,u=r?.parentElement?.getBoundingClientRect().height??0;if(!(!r||u<=0||o.button!==0)){o.stopPropagation(),l.current={id:o.pointerId,from:o.clientY,height:r.getBoundingClientRect().height,rests:Pe(u)},r.style.transition="none";try{o.currentTarget.setPointerCapture(o.pointerId)}catch{}}},onPointerMove:o=>{let r=l.current,u=t.current;if(!r||!u||o.pointerId!==r.id)return;let g=r.rests;u.style.height=`${Math.round(Math.max(g[0]-24,Math.min(g[2],r.height+r.from-o.clientY)))}px`},onPointerUp:o=>{let r=l.current,u=t.current;if(l.current=null,!r||!u)return;let g=u.getBoundingClientRect().height;u.style.transition="",u.style.height="",Math.abs(o.clientY-r.from)<6?c(s===2?xe:s+1):c(r.rests.reduce((f,d,w)=>Math.abs(d-g)<Math.abs(r.rests[f]-g)?w:f,0))},onPointerCancel:()=>{let o=t.current;l.current=null,o&&(o.style.transition="",o.style.height="")},style:{flex:"0 0 auto",display:"flex",justifyContent:"center",alignItems:"center",height:22,cursor:"ns-resize",touchAction:"none"},children:(0,e.jsx)("span",{"aria-hidden":"true",style:{width:40,height:4,borderRadius:2,background:"var(--graview-edge-strong, var(--graview-edge))"}})})}function X({label:t,wide:s,testId:n,head:i,onClose:l,children:c}){let o=(0,p.useRef)(null),[r,u]=(0,p.useState)(!1),[g,f]=Ce(),d=U[g].height;(0,p.useLayoutEffect)(()=>{let v=o.current?.parentElement;if(!v)return;let S=()=>u(v.getBoundingClientRect().width<Re);if(S(),typeof ResizeObserver>"u")return;let h=new ResizeObserver(S);return h.observe(v),()=>h.disconnect()},[]);let w=(0,p.useRef)(l);return w.current=l,(0,p.useEffect)(()=>{let v=k=>{if(k.key!=="Escape"||k.defaultPrevented)return;let A=document.activeElement;A instanceof HTMLInputElement||A instanceof HTMLTextAreaElement||document.querySelector("[data-graview-popover]:popover-open")||S||w.current()},S=!1,h=()=>{S=document.querySelector('[data-testid="following-who"]')!==null};return window.addEventListener("keydown",h,!0),document.addEventListener("keydown",v),()=>{window.removeEventListener("keydown",h,!0),document.removeEventListener("keydown",v)}},[]),(0,e.jsxs)("section",{ref:o,"aria-label":t,"data-testid":n,"data-graview-map-panel":r?"sheet":"dock","data-graview-overlay":"","data-graview-offstage":"",className:"graview-map-panel",style:{position:"absolute",zIndex:ne("rail"),boxSizing:"border-box",display:"flex",flexDirection:"column",background:"var(--graview-panel)",color:"var(--graview-ink)",overflow:"hidden",border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",boxShadow:"var(--graview-lift-high)",...r?{left:R,right:R,bottom:`calc(${R} + env(safe-area-inset-bottom, 0px))`,height:d,transition:"height 180ms ease-out"}:{top:R,right:R,bottom:R,width:s}},children:[r?(0,e.jsx)("style",{children:`:has(> [data-graview-map-panel="sheet"]) { --graview-sheet: calc(${d} + 2 * ${R} + env(safe-area-inset-bottom, 0px)); }`}):(0,e.jsx)("style",{children:`:has(> [data-graview-map-panel="dock"]) { --graview-dock: calc(${s} + 2 * ${R}); }`}),r?(0,e.jsx)(Te,{region:o,rest:g,setRest:f,label:t}):null,(0,e.jsxs)("header",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:r?"4px 14px 10px 18px":"14px 14px 10px 18px",borderBottom:"1px solid var(--graview-edge)"},children:[(0,e.jsx)("div",{style:{flex:"1 1 auto",minWidth:0},children:i}),(0,e.jsx)("button",{type:"button","data-testid":"map-panel-close","aria-label":"Close",title:"Close (Escape)",onClick:l,style:{flex:"0 0 auto",minWidth:32,height:32,borderRadius:8,fontSize:"1.1rem",lineHeight:1},children:"\xD7"})]}),(0,e.jsx)("div",{style:{flex:"1 1 auto",minHeight:0,overflow:"auto"},children:c})]})}var J={fontSize:"0.75rem",letterSpacing:"0.09em",textTransform:"uppercase",color:"var(--graview-ink-faint)"},Q={margin:"2px 0 0",fontSize:"1.125rem",fontWeight:600,lineHeight:1.3,overflowWrap:"anywhere"},Z={margin:"4px 0 0",fontSize:"0.875rem",color:"var(--graview-ink-muted)"},j={margin:"14px 18px 6px",fontSize:"0.8125rem",fontWeight:600,color:"var(--graview-ink-muted)"},z={listStyle:"none",margin:0,padding:"0 10px 6px"},Y={all:"unset",outline:"revert-layer",boxSizing:"border-box",display:"flex",alignItems:"baseline",gap:8,width:"100%",padding:"6px 8px",borderRadius:6,cursor:"pointer",fontSize:"0.875rem"},H={minHeight:30,padding:"0 12px",borderRadius:8,fontSize:"0.8125rem"};function ee(){let{setSelection:t,setMenuAt:s}=P();return(n,i)=>{n.preventDefault(),t([i]),s({x:n.clientX,y:n.clientY,on:i})}}function Se({on:t,about:s}){let{setSelection:n,setMenuAt:i}=P();return(0,e.jsx)("button",{type:"button","data-testid":"map-panel-acts","aria-label":`What can be done with ${s}`,"aria-haspopup":"menu",style:H,onClick:l=>{let c=l.currentTarget.getBoundingClientRect();n([t]),i({x:Math.round(c.left),y:Math.round(c.bottom+4),on:t})},children:"Acts\u2026"})}var ke=(t,s)=>({...N(q(t,!1),s),relation:null});function Me(t,s){let n=`[data-graview-stage] [data-graview-view="${CSS.escape(t)}"][tabindex]`,i=null;for(let r=s?.parentElement??null;r&&!i;r=r.parentElement)i=r.querySelector(".graview-ground");i??=document.querySelector(".graview-ground");let l=i!==null&&!i.hasAttribute("tabindex");i&&l&&(i.setAttribute("tabindex","-1"),i.addEventListener("focusout",r=>{r.target===i&&i.removeAttribute("tabindex")},{once:!0})),i?.focus({preventScroll:!0});let c=performance.now()+5e3,o=()=>{let r=document.activeElement;if(!(r===null||r===document.body||r===document.documentElement||r===s||r===i))return;let g=document.querySelector(n);if(g&&g.isConnected&&!g.closest("[inert]"))return g.focus({preventScroll:!0});performance.now()<c&&requestAnimationFrame(o)};requestAnimationFrame(o)}function Ne({kind:t}){let s=ee(),{store:n,views:i,view:l,selection:c,setSelection:o}=P(),{go:r}=W(),u=$(),g=l.within?.view,f=i.places().filter(b=>b.kind===t),d=(g!==void 0?f.find(b=>b.as===g):void 0)??f.at(-1),w=i.resolve(t,{cardinality:"many",fidelity:"full"},d?.as??g),v=w?.view,S=n.schema.tryDefinition(t),h=(0,p.useMemo)(()=>n.graph.nodesOfKind(t).filter(b=>l.past===!0||I(S,b)),[n,t,u,l.past,S]),k=w?.title??d?.title??M(n.schema,t),A=v!==void 0&&G(v),m=c.filter(b=>n.graph.getNode(b)!==void 0),y=ue();return(0,e.jsxs)(X,{label:k,testId:"lens-panel",wide:"min(max(440px, 46%), 760px)",onClose:()=>r(ae(N(l,null),"view",null)),head:A?null:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:J,children:M(n.schema,t)}),(0,e.jsx)("h2",{style:Q,"data-testid":"lens-panel-title",children:k}),(0,e.jsxs)("p",{style:Z,children:[F(n.schema,t,h.length),S?.description?` \xB7 ${S.description}`:""]}),d?(0,e.jsx)("div",{style:{marginTop:10},children:(0,e.jsx)("button",{type:"button","data-testid":"lens-panel-open",style:H,title:`Open ${k} on its own`,onClick:()=>r(oe(l,t,d.as)),children:"Open \u2197"})}):null]}),children:[(0,e.jsx)("style",{children:`.graview-ground[data-graview-altitude] .graview-plot:not([data-graview-plot="${C(t)}"]) { opacity: 0.35; }
|
|
2
2
|
.graview-ground[data-graview-altitude] [data-graview-view^="kind:"]:not([data-graview-view="${C(t)}"]) { opacity: 0.4; }`}),(0,e.jsx)("div",{"data-graview-lens":d?.as??"",style:{padding:"8px 12px 16px",minHeight:"100%",boxSizing:"border-box",display:"grid",gridTemplateRows:"1fr",gridTemplateColumns:"minmax(0, 1fr)",alignItems:"start"},onClick:b=>{let a=L(b.target);if(!a||n.graph.getNode(a)===void 0)return;let x=b.target.closest("button, a, input, select, textarea, [contenteditable='true']");x&&!x.hasAttribute("data-graview-pick")||o([a])},onDoubleClick:b=>{let a=L(b.target);!a||n.graph.getNode(a)===void 0||r(ke(l,a))},onContextMenu:b=>{let a=L(b.target);!a||n.graph.getNode(a)===void 0||s(b,a)},children:v?(0,e.jsx)(de.Provider,{value:k,children:(0,e.jsx)(se,{mode:"fullscreen",children:(0,e.jsx)(K,{kind:t,...w?.title?{view:w.title}:{},children:(0,e.jsx)(v,{nodes:h,label:k,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1,...m.length>0?{implicated:m}:{},...y.length>0?{flagged:y}:{}})})})}):null})]})}function He(t,s,n,i){let l=i(n),c=new Map;for(let o of s){let r=o.from===n;if(!r&&o.to!==n)continue;let u=r?o.to:o.from,g=i(u);if(g===void 0||l===void 0)continue;let f=`${o.kind}|${r?"out":"in"}|${g}`,d=c.get(f);if(d){d.others.includes(u)||d.others.push(u);continue}c.set(f,{key:f,edge:o.kind,words:ce(t,r?l:g,o.kind,r?"out":"in"),kind:g,others:[u]})}return[...c.values()]}function Ie({id:t}){let s=ee(),{store:n,views:i,view:l,setSelection:c}=P(),{go:o}=W(),r=$(),u=n.graph.getNode(t),g=m=>n.graph.getNode(m)?.kind,f=(0,p.useMemo)(()=>He(n.schema,n.graph.allEdges(),t,g),[n,t,r]);if(!u)return null;let d=u.kind,w=m=>{let y=n.graph.getNode(m);return y?B(n.schema.tryDefinition(y.kind),y):m},v=te(n.schema.tryDefinition(d),d),h=i.resolve(d,{cardinality:"one",fidelity:"full"})?.view,k=h!==void 0&&!G(h),A=()=>l.focusId===t?o({...N(l,null),selection:[]}):c([]);return(0,e.jsxs)(X,{label:`${w(t)}: its links`,testId:"record-panel",wide:k?"min(max(440px, 46%), 760px)":"min(360px, 40%)",onClose:A,head:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:J,children:v}),(0,e.jsx)("h2",{style:Q,"data-testid":"record-panel-title",children:w(t)}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginTop:10},children:[(0,e.jsx)("button",{type:"button","data-testid":"record-panel-go",style:H,onClick:m=>{o(ke(l,t)),Me(t,m.currentTarget)},children:"Go to it"}),(0,e.jsx)(Se,{on:t,about:w(t)}),(0,e.jsxs)("button",{type:"button","data-testid":"record-panel-district",style:H,onClick:()=>c([C(d)]),children:["All ",M(n.schema,d).toLowerCase()]})]})]}),children:[(0,e.jsx)("div",{"data-graview-record-card":t,style:{padding:"8px 18px 0"},children:k?(0,e.jsx)(K,{kind:d,children:(0,e.jsx)(h,{node:u,fidelity:"full",cardinality:"one",mode:"fullscreen",selected:!1})}):(0,e.jsx)(ye,{id:t,shown:[w(t)]})}),f.length===0?(0,e.jsx)("p",{style:{...Z,margin:"14px 18px"},children:"No links yet."}):null,f.map(m=>(0,e.jsxs)("section",{"aria-label":m.words,"data-graview-links":m.edge,children:[(0,e.jsxs)("h3",{style:j,children:[m.words.charAt(0).toUpperCase()+m.words.slice(1)," ",(0,e.jsxs)("span",{style:{fontWeight:400,color:"var(--graview-ink-faint)"},children:["\xB7 ",m.others.length]})]}),(0,e.jsx)("ul",{style:z,children:m.others.map(y=>(0,e.jsx)("li",{children:(0,e.jsxs)("button",{type:"button",className:"graview-map-panel-row","data-graview-record":y,style:Y,onClick:()=>c([y]),onContextMenu:T=>s(T,y),children:[(0,e.jsx)("span",{style:{flex:"1 1 auto",minWidth:0,overflowWrap:"anywhere"},children:w(y)}),m.kind!==d?null:(0,e.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:v})]})},y))})]},m.key))]})}var Le=24;function $e({kind:t}){let s=ee(),{store:n,view:i,setSelection:l,setEmphasis:c}=P(),{go:o}=W(),r=$(),[u,g]=(0,p.useState)(""),f=n.schema.tryDefinition(t),d=(0,p.useMemo)(()=>n.graph.nodesOfKind(t).filter(a=>i.past===!0||I(f,a)).map(a=>({id:a.id,name:B(f,a)})).sort((a,x)=>a.name.localeCompare(x.name)),[n,t,r,i.past,f]),w=(0,p.useMemo)(()=>{let a=E=>{let O=n.graph.getNode(E);return O!==void 0&&(i.past===!0||I(n.schema.tryDefinition(O.kind),O))},x=n.graph.allEdges().filter(E=>a(E.from)&&a(E.to));return we(x,E=>n.graph.getNode(E)?.kind).filter(E=>E.from===t||E.to===t)},[n,t,r,i.past]);(0,p.useEffect)(()=>()=>c(null),[c]);let v=le(),S=pe().marks.flag,h=(0,p.useMemo)(()=>{let a=new Set(d.map(x=>x.id));return v.filter(x=>x.nodeIds.some(E=>a.has(E)))},[v,d]),k=(0,p.useMemo)(()=>[...new Set(h.flatMap(a=>a.nodeIds))].filter(a=>n.graph.getNode(a)?.kind===t).slice(0,300),[h,n,t]),A=(0,p.useRef)(null),m=(0,p.useSyncExternalStore)(me,_,_);(0,p.useEffect)(()=>{m?.kind!==t||h.length===0||(A.current?.scrollIntoView?.({block:"start"}),A.current?.focus({preventScroll:!0}))},[m?.n,m?.kind,t,h.length>0]),(0,p.useEffect)(()=>()=>{he(),setTimeout(()=>{let a=document.activeElement;if(a&&a!==document.body)return;let x=CSS.escape(t);document.querySelector(`[data-testid="district-problems-${x}"]`)?.focus({preventScroll:!0})??document.querySelector(`[data-graview-view="${C(t).replace(/["\\]/g,"\\$&")}"]`)?.focus({preventScroll:!0})},0)},[t]);let y=M(n.schema,t),T=u.trim().toLowerCase(),b=T?d.filter(a=>a.name.toLowerCase().includes(T)):d;return(0,e.jsxs)(X,{label:y,testId:"district-panel",wide:"min(360px, 40%)",onClose:()=>l([]),head:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:J,children:"District"}),(0,e.jsx)("h2",{style:Q,"data-testid":"district-panel-title",children:y}),(0,e.jsxs)("p",{style:Z,children:[F(n.schema,t,d.length),f?.description?` \xB7 ${f.description}`:""]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginTop:10},children:[(0,e.jsx)("button",{type:"button","data-testid":"district-panel-go",style:H,onClick:()=>o({...N(q(i,!1),re(t)),relation:null}),children:"Go in"}),(0,e.jsx)(Se,{on:C(t),about:`the ${y.toLowerCase()}`})]})]}),children:[h.length>0?(0,e.jsxs)("section",{"aria-label":"Problems","data-testid":"district-problems","data-graview-problems":h.length,children:[(0,e.jsx)("style",{children:`${k.map(a=>`.graview-ground[data-graview-altitude] .graview-building[data-graview-building="${CSS.escape(a)}"] polygon`).join(`,
|
|
3
3
|
`)} { stroke: var(--graview-accent); stroke-width: 2.2; stroke-opacity: 1; }`}),(0,e.jsxs)("h3",{ref:A,tabIndex:-1,"data-testid":"district-problems-heading",style:{display:"flex",alignItems:"baseline",gap:8,margin:0,padding:"14px 18px 8px",fontSize:"0.9375rem",fontWeight:600,color:"var(--graview-warn)",borderTop:"1px solid var(--graview-edge)",scrollMarginTop:0,outlineOffset:-2},children:[(0,e.jsx)("span",{"aria-hidden":"true",children:S}),(0,e.jsx)("span",{style:{color:"var(--graview-ink)"},children:fe(h.length,y)})]}),(0,e.jsx)("ol",{style:z,"data-testid":"district-problem-rows",children:(0,e.jsx)(p.Suspense,{fallback:null,children:(0,e.jsx)(Ae,{violations:h,pick:a=>{let x=a.subjectId??a.nodeIds[0];x!==void 0&&l([x])}})})})]}):null,w.length>0?(0,e.jsxs)("section",{"aria-label":"Relations",children:[(0,e.jsx)("h3",{style:j,children:"Relations"}),(0,e.jsx)("ul",{style:z,children:w.map(a=>(0,e.jsx)("li",{children:(0,e.jsxs)("div",{"data-graview-relation-said":a.edge,tabIndex:0,style:{...Y,cursor:"default"},onPointerEnter:()=>c(a.edge),onPointerLeave:()=>c(null),onFocus:()=>c(a.edge),onBlur:()=>c(null),children:[(0,e.jsx)("span",{style:{flex:"1 1 auto",minWidth:0},children:ve(n.schema,a)}),(0,e.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",fontVariantNumeric:"tabular-nums"},title:`${V(a.links)} links`,children:V(a.links)})]})},a.key))})]}):null,(0,e.jsxs)("div",{role:"group","aria-label":y,children:[(0,e.jsxs)("h3",{style:j,children:[y," ",(0,e.jsxs)("span",{style:{fontWeight:400,color:"var(--graview-ink-faint)"},children:["\xB7 ",d.length]})]}),d.length>Le?(0,e.jsx)("div",{style:{padding:"0 18px 6px"},children:(0,e.jsx)("input",{type:"search","data-testid":"district-panel-narrow","aria-label":`Narrow the ${y.toLowerCase()} by name`,placeholder:"Narrow by name",value:u,onChange:a=>g(a.target.value),style:{width:"100%",boxSizing:"border-box",minHeight:32}})}):null,(0,e.jsx)("ul",{style:z,children:b.map(a=>(0,e.jsx)("li",{children:(0,e.jsx)("button",{type:"button",className:"graview-map-panel-row","data-graview-record":a.id,style:Y,onClick:()=>l([a.id]),onContextMenu:x=>s(x,a.id),children:(0,e.jsx)("span",{style:{flex:"1 1 auto",minWidth:0,overflowWrap:"anywhere"},children:a.name})})},a.id))})]})]})}export{je as MapPanelFor};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as G,b as J}from"./chunk.
|
|
1
|
+
var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as G,b as J}from"./chunk.O2VXTYUJ.js";import"./chunk.64LCHHZB.js";import{a as S,b as W}from"./chunk.MB7LKKUD.js";import{a as K}from"./chunk.E423JCOS.js";import"./chunk.O5FTWXA2.js";import"./chunk.6ZENHSTQ.js";import"./chunk.CNN32262.js";import"./chunk.N5Z34V7U.js";import"./chunk.LOKGUALC.js";import"./chunk.EP5JS7ZH.js";import"./chunk.L7XKYGV7.js";import"./chunk.CE3NKAF7.js";import"./chunk.R3GE37OI.js";import"./chunk.2KCDLCB2.js";import"./chunk.UD7VLXPM.js";import"./chunk.3DEWQDP7.js";import"./chunk.TFJA4QV4.js";import"./chunk.HWFJQ42Y.js";import"./chunk.QUETLFBJ.js";import"./chunk.JULD4XFB.js";import"./chunk.GRTBEA7O.js";import"./chunk.H3IGXHZR.js";import"./chunk.7TDML5YU.js";import{D as H,E as V,G as ee,La as _,Va as x,W as D,fa as F}from"./chunk.3VEZ5MOC.js";import{a as j}from"./chunk.SDO3U72B.js";import{na as q,td as B}from"./chunk.6AANHELP.js";import"./chunk.FQLNBIQ5.js";import{b}from"./chunk.AJZBJBMO.js";var t=b(ee(),1);var a=b(D(),1);function ae(n){let r=[];return n.applied.length>0&&n.intent&&r.push(`${n.intent}.`),n.unchanged.length>0&&r.push(`${n.unchanged.length} already so.`),n.allOrNothing&&r.push("None of it was kept."),r.join(" ")}var re=_(j(()=>(__graviewPreload(import.meta.url,["./chunk.AQ2PI6MR.js","./chunk.H3W5C3XQ.js","./chunk.6WB2TYK7.js","./chunk.BJUUSIQY.js","./chunk.N5Z34V7U.js","./chunk.YL2RBZFE.js","./chunk.LOKGUALC.js","./chunk.JGRSUTPJ.js","./chunk.XOZU4OFA.js","./chunk.EP5JS7ZH.js","./chunk.CE3NKAF7.js","./chunk.TFJA4QV4.js","./chunk.HWFJQ42Y.js","./chunk.QUETLFBJ.js","./chunk.JULD4XFB.js","./chunk.GRTBEA7O.js","./chunk.H3IGXHZR.js","./chunk.7TDML5YU.js","./chunk.3VEZ5MOC.js","./chunk.SDO3U72B.js","./chunk.6AANHELP.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.I63462I3.js")))),te=re.part((n,r)=>(0,a.jsx)(n.SeveralAi,{...r}),{quiet:!0});function ne(n){let r=F()?.ai;return!H(r)||!V(r)?null:(0,a.jsx)(t.Suspense,{fallback:null,children:(0,a.jsx)(te,{...n})})}function ge({store:n,chosen:r,principal:d,context:v,via:k,anchor:A,of:g,onChooseAll:E,onClear:m,onActed:Q}){let[U,X]=(0,t.useState)(0);(0,t.useEffect)(()=>n.subscribe(()=>X(e=>e+1)),[n]);let f=r.join(`
|
|
2
2
|
`),{acts:c,withheld:N}=(0,t.useMemo)(()=>G(n,r,{...d?{principal:d}:{},...v?{context:v}:{}}),[n,f,d,v,U]),[O,p]=(0,t.useState)(!1),[l,u]=(0,t.useState)(null),[s,P]=(0,t.useState)(null),h=(0,t.useRef)(null),L=(0,t.useId)(),w=(0,t.useMemo)(()=>[...new Set(r.map(e=>n.graph.getNode(e)?.kind))],[n,f]),Y=w.length===1&&w[0]?`${q(n.schema,w[0],r.length)} chosen`:`${r.length} chosen`,M=typeof matchMedia=="function"&&matchMedia("(pointer: coarse), (max-width: 599px)").matches?2:3,C=c.filter(e=>!e.more),Z=C.slice(0,M),R=[...C.slice(M),...c.filter(e=>e.more)];(0,t.useEffect)(()=>{u(null),p(!1)},[f]),(0,t.useLayoutEffect)(()=>{let e=h.current;if(!e)return;if(typeof e.showPopover=="function"&&!x(e))try{e.showPopover()}catch{}let i=()=>{W(e,A?.()??null),dispatchEvent(new Event(S))};i(),addEventListener("resize",i),addEventListener("scroll",i,!0);let o=typeof ResizeObserver=="function"?new ResizeObserver(i):null;return o?.observe(e),()=>{if(o?.disconnect(),removeEventListener("resize",i),removeEventListener("scroll",i,!0),e.isConnected&&x(e))try{e.hidePopover()}catch{}dispatchEvent(new Event(S))}},[A]);let y=(0,t.useRef)({asking:l,onClear:m});y.current={asking:l,onClear:m},(0,t.useEffect)(()=>{let e=i=>{if(i.key!=="Escape"||i.defaultPrevented)return;let o=document.activeElement;if(!(!(h.current?.contains(o)??!1)&&(o instanceof HTMLTextAreaElement||o instanceof HTMLInputElement&&o.type!=="checkbox"||o instanceof HTMLSelectElement))){if(i.preventDefault(),i.stopPropagation(),y.current.asking){u(null);return}y.current.onClear()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[]);let T=(e,i={})=>{let o=J(n,{mutation:e.mutation,subject:e.subject,args:{...e.args,...i},label:e.label},r,{...d?{author:d}:{},...k?{via:k}:{},...v?{context:v}:{}});u(null),p(!1),P(o.refused.length>0||o.applied.length===0?o:null),Q(o.refused.map(I=>I.id))},$=e=>{P(null),p(!1),e.open.length>0?u(e):T(e)},z=e=>(0,a.jsxs)("button",{type:"button",className:"graview-several-act","data-testid":"several-act","data-act":e.id,"data-mutation":e.mutation,...e.destructive?{"data-tone":"warn"}:{},"aria-pressed":l?.id===e.id?!0:void 0,onClick:()=>$(e),children:[e.label,e.open.length>0?"\u2026":""]},e.id);return(0,a.jsxs)("div",{ref:h,popover:"manual",role:"region","aria-label":"The chosen records",className:"graview-several-bar","data-testid":"several-bar","data-graview-foot":"","data-graview-overlay":"","data-graview-popover":"","data-graview-offstage":"",style:ie,children:[(0,a.jsx)("style",{children:oe}),(0,a.jsxs)("div",{className:"graview-several-line",children:[(0,a.jsx)("span",{role:"status","aria-live":"polite",className:"graview-several-count","data-testid":"several-count",children:Y}),(0,a.jsxs)("div",{role:"group","aria-label":`What to do with the ${r.length} chosen`,className:"graview-several-acts",children:[Z.map(z),R.length>0?(0,a.jsx)("button",{type:"button",className:"graview-several-act","data-testid":"several-more","aria-expanded":O,"aria-controls":L,onClick:()=>p(e=>!e),children:"More"}):null,E&&g!==void 0&&g>r.length?(0,a.jsxs)("button",{type:"button",className:"graview-several-quiet","data-testid":"several-all",onClick:E,children:["Choose all ",g]}):null,(0,a.jsx)("button",{type:"button",className:"graview-several-quiet","data-testid":"several-clear","aria-keyshortcuts":"Escape",title:"Put the choice down \u2014 Escape",onClick:m,children:"Clear"})]})]}),c.length>0&&r.length>1?(0,a.jsx)(ne,{chosen:r,acts:c,onAct:$}):null,O?(0,a.jsx)("div",{id:L,role:"group","aria-label":"More",className:"graview-several-acts","data-testid":"several-more-acts",children:R.map(z)}):null,c.length===0?(0,a.jsx)("p",{className:"graview-several-said","data-testid":"several-none",children:N.length>0?`Nothing here can be done to all of them by you: ${N[0].message}`:"Nothing can be done to all of these at once."}):null,l?(0,a.jsx)("div",{className:"graview-several-ask",role:"group","aria-label":`${l.label}, for all ${r.length}`,"data-testid":"several-ask",children:(0,a.jsx)(K,{store:n,affordance:l.affordance,onApply:e=>T(l,e),onCancel:()=>u(null)})}):null,s?(0,a.jsxs)("div",{role:"alert",className:"graview-several-said","data-testid":"several-outcome",children:[ae(s),s.refused.length>0?(0,a.jsxs)(a.Fragment,{children:[" ",s.refused.length===1?"One was not changed, and is still chosen:":`${s.refused.length} were not changed, and are still chosen:`,(0,a.jsx)("ul",{"data-testid":"several-refused",children:s.refused.map(e=>(0,a.jsxs)("li",{"data-record":e.id,children:["\u201C",e.label,"\u201D \u2014 ",e.message]},e.id))})]}):null]}):null]})}var ie={position:"fixed",inset:"auto",margin:0,zIndex:B("toast"),boxSizing:"border-box",width:"max-content",height:"auto",bottom:"calc(16px + env(safe-area-inset-bottom, 0px))",left:16,overflow:"visible"},oe=`
|
|
3
3
|
.graview-several-bar{display:grid;gap:8px;padding:8px 10px;border:1px solid var(--graview-edge);border-radius:var(--graview-radius,12px);background:var(--graview-float);color:var(--graview-ink);box-shadow:var(--graview-lift-high);font-size:.875rem;line-height:1.4;max-height:70vh;overflow:auto}
|
|
4
4
|
.graview-several-line{display:flex;flex-wrap:wrap;align-items:center;gap:6px 12px;min-width:0}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{F as W,G,H as sn,I as z,J as D,L as P,La as pn,M as dn,Q as ln,T as _,Ta as hn,U as un,V as fn,W as H,X as cn,Y,Z as q,ac as X,cb as mn,da as J,fa as B,gb as wn,ha as yn,hc as $n,ia as gn,ta as Q}from"./chunk.ZEZUKRC6.js";var zn=864e5,j=e=>String(e).padStart(2,"0"),v=e=>new Date(e).toISOString().slice(0,10),E=e=>Date.UTC(+e.slice(0,4),+e.slice(5,7)-1,+e.slice(8,10)),Hn=(e,t)=>v(E(e)+t*zn),An=e=>new Date(E(e)).getUTCDay(),Yn=e=>/T\d\d:\d\d(:[\d.]+)?(Z|[+-]\d\d:?\d\d)$/.test(e),nn=["sun","mon","tue","wed","thu","fri","sat"],Nn=e=>dn(e)??"UTC";function Mn(e,t){if(W.test(e))return v(E(e))===e?{day:e}:void 0;if(G.test(e))return{day:e.length===4?`${e}-01-01`:`${e}-01`};if(D.test(e)&&!Yn(e)){let l=e.slice(0,10);return v(E(l))!==l?void 0:{day:l,minutes:Number(e.slice(11,13))*60+Number(e.slice(14,16))}}let a=Date.parse(e);if(!Number.isNaN(a))return{...un(a,t),stamp:a}}var bn=["EEEE","EEE","MMMM","MMM","yyyy","HH","mm","h","a","d"],kn=/[A-Za-z]+/y;function qn(e){let t=[],a=0;for(;a<e.length;){let l=e[a];if(l==="'"){let f="",y=a+1;for(;y<e.length;y++){if(e[y]==="'"){if(e[y+1]==="'"){f+="'",y++;continue}break}f+=e[y]}if(y>=e.length)return`the quoted words in "${e}" are never closed`;t.push({text:f}),a=y+1;continue}kn.lastIndex=a;let u=kn.exec(e);if(u){let f=u[0];for(;f.length>0;){let y=bn.find($=>f.startsWith($));if(!y)return`"${f}" is not a piece of a date pattern; the pieces are ${bn.map($=>`${$}`).join(", ")}, and other words go in single quotes`;t.push(y),f=f.slice(y.length)}a+=u[0].length;continue}t.push({text:l}),a++}return t}var xn="UTC",Sn=new Map;function Jn(e,t){let a=`${e}|${JSON.stringify(t)}`,l=Sn.get(a);if(!l){try{l=new Intl.DateTimeFormat(e,{...t,timeZone:xn})}catch{l=new Intl.DateTimeFormat("en-US",{...t,timeZone:xn})}Sn.set(a,l)}return l}var C=(e,t,a,l)=>Jn(e,t).formatToParts(a).find(u=>u.type===l)?.value??"";function Rn(e,t,a){let l=qn(t);if(typeof l=="string")return{problem:l};let u=ln(a),f=E(e.day),y=e.minutes,$=y===void 0?void 0:f+y*6e4;return l.map(x=>{if(typeof x!="string")return x.text;switch(x){case"EEEE":return C(u,{weekday:"long"},f,"weekday");case"EEE":return C(u,{weekday:"short"},f,"weekday");case"MMMM":return C(u,{month:"long"},f,"month");case"MMM":return C(u,{month:"short"},f,"month");case"yyyy":return e.day.slice(0,4);case"d":return String(Number(e.day.slice(8,10)));case"HH":return y===void 0?"":j(Math.floor(y/60));case"mm":return y===void 0?"":j(y%60);case"h":return y===void 0?"":String((Math.floor(y/60)+11)%12+1);case"a":return $===void 0?"":C(u,{hour:"numeric",hour12:!0},$,"dayPeriod")}}).join("")}var Bn=/^(\d{1,2}):(\d{2})$/;function On(e){let t=Bn.exec(e.trim());if(!t)return;let a=Number(t[1]),l=Number(t[2]);return a<=23&&l<=59?a*60+l:void 0}var En=e=>new Date(e).toISOString().replace(/\.\d{3}Z$/,"Z"),Qn=(e,t)=>`${e}T${j(Math.floor(t/60))}:${j(t%60)}`;function Tn(e,t,a){return En(fn(e.day,t,a))}function Fn(e,t){if(e.stamp!==void 0)return En(e.stamp+t*6e4);let a=E(e.day)+(e.minutes??0)*6e4+t*6e4,l=v(a);return Qn(l,Math.round((a-E(l))/6e4))}var Gn=e=>nn[An(e.day)];function Dn(e,t){let a=(An(e.day)-nn.indexOf(t)+7)%7;return Hn(e.day,-a)}var Vn=e=>typeof e=="string"&&nn.includes(e);var Wn=1e4,w=class{constructor(t){this.nodes=t}},Cn=Symbol.for("@graview/core:far-record"),Xn=e=>typeof e=="object"&&e!==null&&e[Cn]===!0;function ne(e){let t={...e.fields,id:`@${e.address}/${e.kind}:${e.id}`,kind:`@${e.address}/${e.kind}`,label:e.label};return Object.defineProperty(t,Cn,{value:!0}),t}function be(e){let t=`the linked record in ${e.ref.address}`;return e.reason==="denied"?`${t} is not one this viewer may open`:`${t} has not been read`}var ee="",g=class extends Error{constructor(a,l){super(a);this.sentence=a;this.at=l}},en=class extends g{},T=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof w)&&typeof e.id=="string",_n=e=>{let t=new Set;return new w(e.filter(a=>!t.has(a.id)&&t.add(a.id)))},k=e=>e===null?"nothing":e instanceof w?"a set of records":Array.isArray(e)?"a list":T(e)?"a record":typeof e=="string"?"a word":typeof e;function te(e,t){if(!G.test(e)&&!G.test(t))return;let a=f=>z(D.test(f)?f.slice(0,10):f),l=a(e),u=a(t);return l&&u?[l,u]:void 0}function In(e,t){let a=t.budget??Wn,l=(n,d)=>{if(a-=n,a<0)throw new en("this rule looks at too much of the graph to judge in one go",d)},u=t.today??P(),f=t.now??new Date().toISOString(),y=Nn(t.timeZone),$=new Map,x=new Set,S=t.bindings,rn=(n,d,o,i)=>{let p=`${n?.id}\0${d}`;if($.has(p))return $.get(p);if(x.has(p))throw new g(`"${d}"${n?` of ${Q(n.kind)}`:""} depends on itself`,i);x.add(p);let r=S;S=void 0;let s=a;a=Math.max(s,Wn);try{let c=A(o,n);return $.set(p,c),c}finally{a=s,S=r,x.delete(p)}},I=(n,d,o)=>{l(1,o);let i=t.kinds.get(n.kind),p=i?.computed?.get(d);if(p)return rn(n,d,p,o);let r=i?.linked?.get(d);if(r){let h=pn(Object.hasOwn(n,d)?n[d]:void 0,r);l(h.length,o);let b=t.linked??hn(t.graph),m=h.flatMap(N=>{let K=b?b(N):{unread:!0};return"record"in K?[ne(K.record)]:(t.onUnread?.({relation:d,ref:N,reason:"denied"in K?"denied":"unread"}),[])});return r.cardinality==="one"?m[0]??null:new w(m)}let s=Object.hasOwn(n,d);if(i?.fields.has(d)||s){let h=s?mn(n,d,u):void 0;return h===void 0?null:h}let c=i?.edges.get(d);if(c){let h=t.graph.out(n.id,d);return l(h.length,o),c==="one"?h[0]??null:new w(h)}if(d==="id")return n.id;if(Xn(n))return null;throw new g(`${Q(n.kind)} has no field or relation called "${d}"`,o)},M=(n,d,o)=>{if(n instanceof w)return n;if(n===null)return new w([]);if(T(n))return new w([n]);throw new g(`${o}(\u2026) needs a set of records, and was given ${k(n)}`,d)},O=(n,d,o)=>{if(n===null)return null;if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);throw new g(`${o}(\u2026) needs a word, and was given ${k(n)}`,d)},Z=(n,d,o)=>{let i=O(n,d,o);if(i===null)return null;let p=G.test(i)?z(i).from:i,r=Date.parse(p.length===10?`${p}T00:00:00Z`:p);if(Number.isNaN(r))throw new g(`${o}(\u2026) needs a date, and "${i}" is not one`,d);return r},V=(n,d,o)=>{if(n===null)return null;if(typeof n!="string")throw new g(`${o}(\u2026) needs a date, and was given ${k(n)}`,d);let i=Mn(n,y);if(!i)throw new g(`${o}(\u2026) needs a date, and "${n}" is not one`,d);return i},F=(n,d)=>T(n)&&T(d)?n.id===d.id:T(n)&&typeof d=="string"?n.id===d:typeof n=="string"&&T(d)?n===d.id:Array.isArray(n)&&Array.isArray(d)?n.length===d.length&&n.every((o,i)=>F(o,d[i])):n===d,R=(n,d,o)=>{if(n===null)return!1;if(typeof n=="boolean")return n;throw new g(`${o} must be true or false, and was ${k(n)}`,d)},L=(n,d)=>A(d,n);function A(n,d){switch(l(1,n.at),n.t){case"lit":return n.value;case"list":return n.items.map(o=>A(o,d));case"ident":{let o=S&&Object.hasOwn(S,n.name)?S[n.name]:void 0;if(o!==void 0)return o;if(d)return I(d,n.name,n.at);throw new g(`"${n.name}" means nothing in a rule over the whole graph`,n.at)}case"member":{let o=A(n.object,d);if(o===null)return null;if(T(o))return I(o,n.name,n.at);throw new g(`".${n.name}" needs a record before it, and was given ${k(o)}`,n.at)}case"unary":{let o=A(n.operand,d);if(n.op==="!")return!R(o,n.at,"what follows not");if(o===null)return null;if(typeof o!="number")throw new g(`"-" needs a number, and was given ${k(o)}`,n.at);return-o}case"where":{let o=M(A(n.set,d),n.at,"where");return l(o.nodes.length,n.at),new w(o.nodes.filter(i=>R(L(i,n.filter),n.at,"a where condition")))}case"binary":return Zn(n,d);case"call":return Kn(n,d)}}function Zn(n,d){if(n.op==="&&")return R(A(n.left,d),n.at,"each side of and")&&R(A(n.right,d),n.at,"each side of and");if(n.op==="||")return R(A(n.left,d),n.at,"each side of or")||R(A(n.right,d),n.at,"each side of or");let o=A(n.left,d),i=A(n.right,d);if(n.op==="&"||n.op==="|"||n.op==="-"&&(o instanceof w||i instanceof w)){let p=M(o,n.at,n.op).nodes,r=M(i,n.at,n.op).nodes;l(p.length+r.length,n.at);let s=new Set(r.map(c=>c.id));return _n(n.op==="|"?[...p,...r]:p.filter(c=>s.has(c.id)===(n.op==="&")))}switch(n.op){case"==":return F(o,i);case"!=":return!F(o,i);case"in":{if(i===null)return!1;if(i instanceof w)return i.nodes.some(p=>F(o,p));if(Array.isArray(i))return i.some(p=>F(o,p));if(typeof i=="string"&&typeof o=="string")return i.includes(o);throw new g(`"in" needs a list or a set on its right, and was given ${k(i)}`,n.at)}case"<":case"<=":case">":case">=":{if(o===null||i===null)return!1;if(!(typeof o=="number"&&typeof i=="number"||typeof o=="string"&&typeof i=="string"))throw new g(`cannot compare ${k(o)} with ${k(i)}`,n.at);let r=typeof o=="string"&&typeof i=="string"?te(o,i):void 0;if(r){let[s,c]=r,h=s.to<c.from,b=s.from>c.to,m=s.from===c.from&&s.to===c.to;return n.op==="<"?h:n.op==="<="?h||m:n.op===">"?b:b||m}return n.op==="<"?o<i:n.op==="<="?o<=i:n.op===">"?o>i:o>=i}default:{if(o===null||i===null)return null;if(n.op==="+"&&(typeof o=="string"||typeof i=="string")){let p=`${O(o,n.at,"+")}${O(i,n.at,"+")}`;if(p.length>1e4)throw new g("that makes a word too long",n.at);return p}if(typeof o!="number"||typeof i!="number")throw new g(`"${n.op}" needs numbers, and was given ${k(o)} and ${k(i)}`,n.at);return(n.op==="/"||n.op==="%")&&i===0?null:n.op==="+"?o+i:n.op==="-"?o-i:n.op==="*"?o*i:n.op==="/"?o/i:o%i}}}function on(n,d){let o=n.t==="call"&&(n.fn==="in"||n.fn==="out")&&n.args.length===1?n.args[0]:void 0;if(!(!d||o?.t!=="lit"||typeof o.value!="string"))return l(1,n.at),n.fn==="out"?t.graph.out(d.id,o.value):t.graph.in(d.id,o.value)}function Kn(n,d){let o=(r,s=r)=>{if(n.args.length<r||n.args.length>s)throw new g(`${n.fn}(\u2026) takes ${r===s?r:`${r} to ${s}`} argument${s===1?"":"s"}`,n.at)},i=r=>A(n.args[r],d),p=r=>{let s=i(r);if(typeof s!="string")throw new g(`${n.fn}(\u2026) needs a quoted name, like ${n.fn}('name')`,n.at);return s};switch(n.fn){case"out":case"in":{o(1,2);let r=(h,b)=>n.fn==="out"?t.graph.out(h,b):t.graph.in(h,b);if(n.args.length===2){let h=M(i(0),n.at,n.fn).nodes,b=p(1);return _n(h.flatMap(m=>{let N=r(m.id,b);return l(N.length+1,n.at),N}))}let s=p(0);if(!d)throw new g(`${n.fn}('${s}') needs a record to start from`,n.at);let c=r(d.id,s);return l(c.length,n.at),new w(c)}case"all":{o(1,2);let r=t.graph.nodesOfKind(p(0),{archived:n.args.length===2?i(1):!1});return l(r.length,n.at),new w(r)}case"archived":return o(0,1),wn(n.args.length===1?i(0):d);case"count":return o(1),(on(n.args[0],d)??M(i(0),n.at,"count").nodes).length;case"exists":return o(1),(on(n.args[0],d)??M(i(0),n.at,"exists").nodes).length>0;case"every":case"some":{o(2);let r=M(i(0),n.at,n.fn);l(r.nodes.length,n.at);let s=c=>R(L(c,n.args[1]),n.at,`the condition in ${n.fn}(\u2026)`);return n.fn==="every"?r.nodes.every(s):r.nodes.some(s)}case"sum":case"min":case"max":{o(2);let r=M(i(0),n.at,n.fn);l(r.nodes.length,n.at);let s=n.args[1],c=s.t==="lit"&&typeof s.value=="string"?s.value:void 0,h=s.t==="ident"?`'${s.name}'`:c!==void 0?`'${c}'`:"\u2026",b=r.nodes.map(m=>s.t==="ident"?I(m,s.name,n.at):c!==void 0?I(m,c,n.at):L(m,s)).filter(m=>{if(m===null)return!1;if(typeof m!="number")throw new g(`${n.fn}(\u2026, ${h}) needs a number for each member, and found ${k(m)}`,n.at);return!0});return n.fn==="sum"?b.reduce((m,N)=>m+N,0):b.length===0?null:n.fn==="min"?Math.min(...b):Math.max(...b)}case"fact":{o(1);let r=p(0),s=t.kinds.get(ee)?.computed?.get(r);if(!s)throw new g(`no fact is called "${r}"`,n.at);return rn(null,r,s,n.at)}case"first":return o(1),M(i(0),n.at,"first").nodes[0]??null;case"sort":{o(2,3);let r=M(i(0),n.at,"sort"),s=n.args.length===3?i(2):"asc";if(s!=="asc"&&s!=="desc")throw new g("sort(\u2026) goes 'asc' or 'desc'",n.at);let c=r.nodes.length;l(c+c*Math.ceil(Math.log2(c+1)),n.at);let h=r.nodes.map((m,N)=>({node:m,i:N,key:L(m,n.args[1])})),b=s==="desc"?-1:1;return h.sort((m,N)=>an(m.key,N.key,b,n.at)||m.i-N.i),new w(h.map(m=>m.node))}case"either":{if(n.args.length<1)throw new g("either(\u2026) takes at least one argument",n.at);for(let r=0;r<n.args.length;r++){let s=i(r);if(s!==null&&!(s instanceof w&&s.nodes.length===0))return s}return null}case"present":{o(1);let r=i(0);return r===null||r===""?!1:Array.isArray(r)?r.length>0:r instanceof w?r.nodes.length>0:!0}case"len":{o(1);let r=i(0);if(r===null)return 0;if(typeof r=="string"||Array.isArray(r))return r.length;if(r instanceof w)return r.nodes.length;throw new g(`len(\u2026) needs a word or a list, and was given ${k(r)}`,n.at)}case"contains":case"startsWith":{o(2);let r=i(0),s=i(1);if(r===null||s===null)return!1;if(n.fn==="contains"&&Array.isArray(r))return r.some(b=>F(b,s));let c=O(r,n.at,n.fn),h=O(s,n.at,n.fn);return n.fn==="contains"?c.toLowerCase().includes(h.toLowerCase()):c.startsWith(h)}case"lower":{o(1);let r=O(i(0),n.at,"lower");return r===null?null:r.toLowerCase()}case"concat":{if(n.args.length<1)throw new g("concat(\u2026) takes at least one argument",n.at);let r="";for(let s=0;s<n.args.length;s++)r+=O(i(s),n.at,"concat")??"";if(r.length>1e4)throw new g("that makes a word too long",n.at);return r}case"format":{o(2);let r=V(i(0),n.at,"format"),s=i(1);if(typeof s!="string")throw new g("format(\u2026) says its pattern in quotes, like format(start, 'EEE h:mm a')",n.at);if(r===null)return null;let c=Rn(r,s,t.locale);if(typeof c!="string")throw new g(c.problem,n.at);return c}case"datetime":case"at":{o(2);let r=V(i(0),n.at,n.fn),s=i(1);if(s===null||r===null)return null;let c=typeof s=="string"?On(s):void 0;if(c===void 0)throw new g(`${n.fn}(\u2026) needs a time of day written like '09:30', and was given ${typeof s=="string"?`"${s}"`:k(s)}`,n.at);return Tn(r,c,y)}case"addMinutes":{o(2);let r=V(i(0),n.at,"addMinutes"),s=i(1);if(r===null||s===null)return null;if(typeof s!="number"||!Number.isFinite(s))throw new g(`addMinutes(\u2026) needs a number of minutes, and was given ${k(s)}`,n.at);return Fn(r,Math.round(s))}case"weekday":{o(1);let r=V(i(0),n.at,"weekday");return r===null?null:Gn(r)}case"startOfWeek":{o(1,2);let r=V(i(0),n.at,"startOfWeek"),s=n.args.length===2?i(1):"mon";if(!Vn(s))throw new g("startOfWeek(\u2026) starts the week on a day said 'mon' to 'sun'",n.at);return r===null?null:Dn(r,s)}case"today":return o(0),u;case"now":return o(0),f;case"date":{o(1);let r=Z(i(0),n.at,"date");return r===null?null:new Date(r).toISOString().slice(0,10)}case"days":case"hours":{o(2);let r=Z(i(0),n.at,n.fn),s=Z(i(1),n.at,n.fn);if(r===null||s===null)return null;let c=(s-r)/(n.fn==="days"?864e5:36e5);return n.fn==="days"?Math.round(c):c}case"round":{o(1,2);let r=i(0);if(r===null)return null;if(typeof r!="number")throw new g(`round(\u2026) needs a number, and was given ${k(r)}`,n.at);let s=n.args.length===2?i(1):0;if(typeof s!="number"||!Number.isInteger(s)||s<0||s>12)throw new g("round(\u2026, places) takes a whole number of places from 0 to 12",n.at);let c=10**s,h=Math.sign(r)*Math.round(Math.abs(r)*c*(1+Number.EPSILON))/c;return Object.is(h,-0)?0:h}case"if":return o(3),R(i(0),n.at,"the condition in if(\u2026)")?i(1):i(2);default:throw new g(`"${n.fn}" is not a function the rule language knows`,n.at)}}function an(n,d,o,i){if(n===null||d===null)return n===d?0:n===null?1:-1;if(Array.isArray(n)&&Array.isArray(d)){for(let r=0;r<Math.max(n.length,d.length);r++){let s=an(n[r]??null,d[r]??null,o,i);if(s!==0)return s}return 0}let p=r=>typeof r=="number"||typeof r=="string"||typeof r=="boolean"?typeof r:k(r);if(p(n)!==p(d)||typeof n=="object"||typeof d=="object")throw new g(`sort(\u2026) cannot put ${k(n)} and ${k(d)} in order`,i);return typeof n=="string"?o*(n<d?-1:n>d?1:0):o*(Number(n)-Number(d))}return A(e,t.subject)}var ke=["out","in","all","count","exists","every","some","sum","min","max","present","len","contains","startsWith","lower","today","now","date","days","hours","if","first","sort","either","fact","archived","round","concat","format","datetime","at","addMinutes","weekday","startOfWeek"];var re=(e,t,a,l,u)=>({severity:"error",code:e,path:t,message:a,...l?{fix:l}:{},...u}),Se=(e,t,a,l,u)=>({...re(e,t,a,l,u?.length?{edits:u}:void 0),severity:"warning"}),Ae=e=>e.some(t=>t.severity==="error");function oe(e,t){return[...(e.edits??[]).map(a=>`${t}edit: ${JSON.stringify(a)}`),...e.details?[`${t}details: ${e.details}`]:[],...(e.fixes??[]).flatMap(a=>[`${t}fix: ${a.label}`,...(a.edits??[]).map(l=>`${t} edit: ${JSON.stringify(l)}`)])].map(a=>`
|
|
1
|
+
import{F as W,G,H as sn,I as z,J as D,L as P,La as pn,M as dn,Q as ln,T as _,Ta as hn,U as un,V as fn,W as H,X as cn,Y,Z as q,ac as X,cb as mn,da as J,fa as B,gb as wn,ha as yn,hc as $n,ia as gn,ta as Q}from"./chunk.6AANHELP.js";var zn=864e5,j=e=>String(e).padStart(2,"0"),v=e=>new Date(e).toISOString().slice(0,10),E=e=>Date.UTC(+e.slice(0,4),+e.slice(5,7)-1,+e.slice(8,10)),Hn=(e,t)=>v(E(e)+t*zn),An=e=>new Date(E(e)).getUTCDay(),Yn=e=>/T\d\d:\d\d(:[\d.]+)?(Z|[+-]\d\d:?\d\d)$/.test(e),nn=["sun","mon","tue","wed","thu","fri","sat"],Nn=e=>dn(e)??"UTC";function Mn(e,t){if(W.test(e))return v(E(e))===e?{day:e}:void 0;if(G.test(e))return{day:e.length===4?`${e}-01-01`:`${e}-01`};if(D.test(e)&&!Yn(e)){let l=e.slice(0,10);return v(E(l))!==l?void 0:{day:l,minutes:Number(e.slice(11,13))*60+Number(e.slice(14,16))}}let a=Date.parse(e);if(!Number.isNaN(a))return{...un(a,t),stamp:a}}var bn=["EEEE","EEE","MMMM","MMM","yyyy","HH","mm","h","a","d"],kn=/[A-Za-z]+/y;function qn(e){let t=[],a=0;for(;a<e.length;){let l=e[a];if(l==="'"){let f="",y=a+1;for(;y<e.length;y++){if(e[y]==="'"){if(e[y+1]==="'"){f+="'",y++;continue}break}f+=e[y]}if(y>=e.length)return`the quoted words in "${e}" are never closed`;t.push({text:f}),a=y+1;continue}kn.lastIndex=a;let u=kn.exec(e);if(u){let f=u[0];for(;f.length>0;){let y=bn.find($=>f.startsWith($));if(!y)return`"${f}" is not a piece of a date pattern; the pieces are ${bn.map($=>`${$}`).join(", ")}, and other words go in single quotes`;t.push(y),f=f.slice(y.length)}a+=u[0].length;continue}t.push({text:l}),a++}return t}var xn="UTC",Sn=new Map;function Jn(e,t){let a=`${e}|${JSON.stringify(t)}`,l=Sn.get(a);if(!l){try{l=new Intl.DateTimeFormat(e,{...t,timeZone:xn})}catch{l=new Intl.DateTimeFormat("en-US",{...t,timeZone:xn})}Sn.set(a,l)}return l}var C=(e,t,a,l)=>Jn(e,t).formatToParts(a).find(u=>u.type===l)?.value??"";function Rn(e,t,a){let l=qn(t);if(typeof l=="string")return{problem:l};let u=ln(a),f=E(e.day),y=e.minutes,$=y===void 0?void 0:f+y*6e4;return l.map(x=>{if(typeof x!="string")return x.text;switch(x){case"EEEE":return C(u,{weekday:"long"},f,"weekday");case"EEE":return C(u,{weekday:"short"},f,"weekday");case"MMMM":return C(u,{month:"long"},f,"month");case"MMM":return C(u,{month:"short"},f,"month");case"yyyy":return e.day.slice(0,4);case"d":return String(Number(e.day.slice(8,10)));case"HH":return y===void 0?"":j(Math.floor(y/60));case"mm":return y===void 0?"":j(y%60);case"h":return y===void 0?"":String((Math.floor(y/60)+11)%12+1);case"a":return $===void 0?"":C(u,{hour:"numeric",hour12:!0},$,"dayPeriod")}}).join("")}var Bn=/^(\d{1,2}):(\d{2})$/;function On(e){let t=Bn.exec(e.trim());if(!t)return;let a=Number(t[1]),l=Number(t[2]);return a<=23&&l<=59?a*60+l:void 0}var En=e=>new Date(e).toISOString().replace(/\.\d{3}Z$/,"Z"),Qn=(e,t)=>`${e}T${j(Math.floor(t/60))}:${j(t%60)}`;function Tn(e,t,a){return En(fn(e.day,t,a))}function Fn(e,t){if(e.stamp!==void 0)return En(e.stamp+t*6e4);let a=E(e.day)+(e.minutes??0)*6e4+t*6e4,l=v(a);return Qn(l,Math.round((a-E(l))/6e4))}var Gn=e=>nn[An(e.day)];function Dn(e,t){let a=(An(e.day)-nn.indexOf(t)+7)%7;return Hn(e.day,-a)}var Vn=e=>typeof e=="string"&&nn.includes(e);var Wn=1e4,w=class{constructor(t){this.nodes=t}},Cn=Symbol.for("@graview/core:far-record"),Xn=e=>typeof e=="object"&&e!==null&&e[Cn]===!0;function ne(e){let t={...e.fields,id:`@${e.address}/${e.kind}:${e.id}`,kind:`@${e.address}/${e.kind}`,label:e.label};return Object.defineProperty(t,Cn,{value:!0}),t}function be(e){let t=`the linked record in ${e.ref.address}`;return e.reason==="denied"?`${t} is not one this viewer may open`:`${t} has not been read`}var ee="",g=class extends Error{constructor(a,l){super(a);this.sentence=a;this.at=l}},en=class extends g{},T=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof w)&&typeof e.id=="string",_n=e=>{let t=new Set;return new w(e.filter(a=>!t.has(a.id)&&t.add(a.id)))},k=e=>e===null?"nothing":e instanceof w?"a set of records":Array.isArray(e)?"a list":T(e)?"a record":typeof e=="string"?"a word":typeof e;function te(e,t){if(!G.test(e)&&!G.test(t))return;let a=f=>z(D.test(f)?f.slice(0,10):f),l=a(e),u=a(t);return l&&u?[l,u]:void 0}function In(e,t){let a=t.budget??Wn,l=(n,d)=>{if(a-=n,a<0)throw new en("this rule looks at too much of the graph to judge in one go",d)},u=t.today??P(),f=t.now??new Date().toISOString(),y=Nn(t.timeZone),$=new Map,x=new Set,S=t.bindings,rn=(n,d,o,i)=>{let p=`${n?.id}\0${d}`;if($.has(p))return $.get(p);if(x.has(p))throw new g(`"${d}"${n?` of ${Q(n.kind)}`:""} depends on itself`,i);x.add(p);let r=S;S=void 0;let s=a;a=Math.max(s,Wn);try{let c=A(o,n);return $.set(p,c),c}finally{a=s,S=r,x.delete(p)}},I=(n,d,o)=>{l(1,o);let i=t.kinds.get(n.kind),p=i?.computed?.get(d);if(p)return rn(n,d,p,o);let r=i?.linked?.get(d);if(r){let h=pn(Object.hasOwn(n,d)?n[d]:void 0,r);l(h.length,o);let b=t.linked??hn(t.graph),m=h.flatMap(N=>{let K=b?b(N):{unread:!0};return"record"in K?[ne(K.record)]:(t.onUnread?.({relation:d,ref:N,reason:"denied"in K?"denied":"unread"}),[])});return r.cardinality==="one"?m[0]??null:new w(m)}let s=Object.hasOwn(n,d);if(i?.fields.has(d)||s){let h=s?mn(n,d,u):void 0;return h===void 0?null:h}let c=i?.edges.get(d);if(c){let h=t.graph.out(n.id,d);return l(h.length,o),c==="one"?h[0]??null:new w(h)}if(d==="id")return n.id;if(Xn(n))return null;throw new g(`${Q(n.kind)} has no field or relation called "${d}"`,o)},M=(n,d,o)=>{if(n instanceof w)return n;if(n===null)return new w([]);if(T(n))return new w([n]);throw new g(`${o}(\u2026) needs a set of records, and was given ${k(n)}`,d)},O=(n,d,o)=>{if(n===null)return null;if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);throw new g(`${o}(\u2026) needs a word, and was given ${k(n)}`,d)},Z=(n,d,o)=>{let i=O(n,d,o);if(i===null)return null;let p=G.test(i)?z(i).from:i,r=Date.parse(p.length===10?`${p}T00:00:00Z`:p);if(Number.isNaN(r))throw new g(`${o}(\u2026) needs a date, and "${i}" is not one`,d);return r},V=(n,d,o)=>{if(n===null)return null;if(typeof n!="string")throw new g(`${o}(\u2026) needs a date, and was given ${k(n)}`,d);let i=Mn(n,y);if(!i)throw new g(`${o}(\u2026) needs a date, and "${n}" is not one`,d);return i},F=(n,d)=>T(n)&&T(d)?n.id===d.id:T(n)&&typeof d=="string"?n.id===d:typeof n=="string"&&T(d)?n===d.id:Array.isArray(n)&&Array.isArray(d)?n.length===d.length&&n.every((o,i)=>F(o,d[i])):n===d,R=(n,d,o)=>{if(n===null)return!1;if(typeof n=="boolean")return n;throw new g(`${o} must be true or false, and was ${k(n)}`,d)},L=(n,d)=>A(d,n);function A(n,d){switch(l(1,n.at),n.t){case"lit":return n.value;case"list":return n.items.map(o=>A(o,d));case"ident":{let o=S&&Object.hasOwn(S,n.name)?S[n.name]:void 0;if(o!==void 0)return o;if(d)return I(d,n.name,n.at);throw new g(`"${n.name}" means nothing in a rule over the whole graph`,n.at)}case"member":{let o=A(n.object,d);if(o===null)return null;if(T(o))return I(o,n.name,n.at);throw new g(`".${n.name}" needs a record before it, and was given ${k(o)}`,n.at)}case"unary":{let o=A(n.operand,d);if(n.op==="!")return!R(o,n.at,"what follows not");if(o===null)return null;if(typeof o!="number")throw new g(`"-" needs a number, and was given ${k(o)}`,n.at);return-o}case"where":{let o=M(A(n.set,d),n.at,"where");return l(o.nodes.length,n.at),new w(o.nodes.filter(i=>R(L(i,n.filter),n.at,"a where condition")))}case"binary":return Zn(n,d);case"call":return Kn(n,d)}}function Zn(n,d){if(n.op==="&&")return R(A(n.left,d),n.at,"each side of and")&&R(A(n.right,d),n.at,"each side of and");if(n.op==="||")return R(A(n.left,d),n.at,"each side of or")||R(A(n.right,d),n.at,"each side of or");let o=A(n.left,d),i=A(n.right,d);if(n.op==="&"||n.op==="|"||n.op==="-"&&(o instanceof w||i instanceof w)){let p=M(o,n.at,n.op).nodes,r=M(i,n.at,n.op).nodes;l(p.length+r.length,n.at);let s=new Set(r.map(c=>c.id));return _n(n.op==="|"?[...p,...r]:p.filter(c=>s.has(c.id)===(n.op==="&")))}switch(n.op){case"==":return F(o,i);case"!=":return!F(o,i);case"in":{if(i===null)return!1;if(i instanceof w)return i.nodes.some(p=>F(o,p));if(Array.isArray(i))return i.some(p=>F(o,p));if(typeof i=="string"&&typeof o=="string")return i.includes(o);throw new g(`"in" needs a list or a set on its right, and was given ${k(i)}`,n.at)}case"<":case"<=":case">":case">=":{if(o===null||i===null)return!1;if(!(typeof o=="number"&&typeof i=="number"||typeof o=="string"&&typeof i=="string"))throw new g(`cannot compare ${k(o)} with ${k(i)}`,n.at);let r=typeof o=="string"&&typeof i=="string"?te(o,i):void 0;if(r){let[s,c]=r,h=s.to<c.from,b=s.from>c.to,m=s.from===c.from&&s.to===c.to;return n.op==="<"?h:n.op==="<="?h||m:n.op===">"?b:b||m}return n.op==="<"?o<i:n.op==="<="?o<=i:n.op===">"?o>i:o>=i}default:{if(o===null||i===null)return null;if(n.op==="+"&&(typeof o=="string"||typeof i=="string")){let p=`${O(o,n.at,"+")}${O(i,n.at,"+")}`;if(p.length>1e4)throw new g("that makes a word too long",n.at);return p}if(typeof o!="number"||typeof i!="number")throw new g(`"${n.op}" needs numbers, and was given ${k(o)} and ${k(i)}`,n.at);return(n.op==="/"||n.op==="%")&&i===0?null:n.op==="+"?o+i:n.op==="-"?o-i:n.op==="*"?o*i:n.op==="/"?o/i:o%i}}}function on(n,d){let o=n.t==="call"&&(n.fn==="in"||n.fn==="out")&&n.args.length===1?n.args[0]:void 0;if(!(!d||o?.t!=="lit"||typeof o.value!="string"))return l(1,n.at),n.fn==="out"?t.graph.out(d.id,o.value):t.graph.in(d.id,o.value)}function Kn(n,d){let o=(r,s=r)=>{if(n.args.length<r||n.args.length>s)throw new g(`${n.fn}(\u2026) takes ${r===s?r:`${r} to ${s}`} argument${s===1?"":"s"}`,n.at)},i=r=>A(n.args[r],d),p=r=>{let s=i(r);if(typeof s!="string")throw new g(`${n.fn}(\u2026) needs a quoted name, like ${n.fn}('name')`,n.at);return s};switch(n.fn){case"out":case"in":{o(1,2);let r=(h,b)=>n.fn==="out"?t.graph.out(h,b):t.graph.in(h,b);if(n.args.length===2){let h=M(i(0),n.at,n.fn).nodes,b=p(1);return _n(h.flatMap(m=>{let N=r(m.id,b);return l(N.length+1,n.at),N}))}let s=p(0);if(!d)throw new g(`${n.fn}('${s}') needs a record to start from`,n.at);let c=r(d.id,s);return l(c.length,n.at),new w(c)}case"all":{o(1,2);let r=t.graph.nodesOfKind(p(0),{archived:n.args.length===2?i(1):!1});return l(r.length,n.at),new w(r)}case"archived":return o(0,1),wn(n.args.length===1?i(0):d);case"count":return o(1),(on(n.args[0],d)??M(i(0),n.at,"count").nodes).length;case"exists":return o(1),(on(n.args[0],d)??M(i(0),n.at,"exists").nodes).length>0;case"every":case"some":{o(2);let r=M(i(0),n.at,n.fn);l(r.nodes.length,n.at);let s=c=>R(L(c,n.args[1]),n.at,`the condition in ${n.fn}(\u2026)`);return n.fn==="every"?r.nodes.every(s):r.nodes.some(s)}case"sum":case"min":case"max":{o(2);let r=M(i(0),n.at,n.fn);l(r.nodes.length,n.at);let s=n.args[1],c=s.t==="lit"&&typeof s.value=="string"?s.value:void 0,h=s.t==="ident"?`'${s.name}'`:c!==void 0?`'${c}'`:"\u2026",b=r.nodes.map(m=>s.t==="ident"?I(m,s.name,n.at):c!==void 0?I(m,c,n.at):L(m,s)).filter(m=>{if(m===null)return!1;if(typeof m!="number")throw new g(`${n.fn}(\u2026, ${h}) needs a number for each member, and found ${k(m)}`,n.at);return!0});return n.fn==="sum"?b.reduce((m,N)=>m+N,0):b.length===0?null:n.fn==="min"?Math.min(...b):Math.max(...b)}case"fact":{o(1);let r=p(0),s=t.kinds.get(ee)?.computed?.get(r);if(!s)throw new g(`no fact is called "${r}"`,n.at);return rn(null,r,s,n.at)}case"first":return o(1),M(i(0),n.at,"first").nodes[0]??null;case"sort":{o(2,3);let r=M(i(0),n.at,"sort"),s=n.args.length===3?i(2):"asc";if(s!=="asc"&&s!=="desc")throw new g("sort(\u2026) goes 'asc' or 'desc'",n.at);let c=r.nodes.length;l(c+c*Math.ceil(Math.log2(c+1)),n.at);let h=r.nodes.map((m,N)=>({node:m,i:N,key:L(m,n.args[1])})),b=s==="desc"?-1:1;return h.sort((m,N)=>an(m.key,N.key,b,n.at)||m.i-N.i),new w(h.map(m=>m.node))}case"either":{if(n.args.length<1)throw new g("either(\u2026) takes at least one argument",n.at);for(let r=0;r<n.args.length;r++){let s=i(r);if(s!==null&&!(s instanceof w&&s.nodes.length===0))return s}return null}case"present":{o(1);let r=i(0);return r===null||r===""?!1:Array.isArray(r)?r.length>0:r instanceof w?r.nodes.length>0:!0}case"len":{o(1);let r=i(0);if(r===null)return 0;if(typeof r=="string"||Array.isArray(r))return r.length;if(r instanceof w)return r.nodes.length;throw new g(`len(\u2026) needs a word or a list, and was given ${k(r)}`,n.at)}case"contains":case"startsWith":{o(2);let r=i(0),s=i(1);if(r===null||s===null)return!1;if(n.fn==="contains"&&Array.isArray(r))return r.some(b=>F(b,s));let c=O(r,n.at,n.fn),h=O(s,n.at,n.fn);return n.fn==="contains"?c.toLowerCase().includes(h.toLowerCase()):c.startsWith(h)}case"lower":{o(1);let r=O(i(0),n.at,"lower");return r===null?null:r.toLowerCase()}case"concat":{if(n.args.length<1)throw new g("concat(\u2026) takes at least one argument",n.at);let r="";for(let s=0;s<n.args.length;s++)r+=O(i(s),n.at,"concat")??"";if(r.length>1e4)throw new g("that makes a word too long",n.at);return r}case"format":{o(2);let r=V(i(0),n.at,"format"),s=i(1);if(typeof s!="string")throw new g("format(\u2026) says its pattern in quotes, like format(start, 'EEE h:mm a')",n.at);if(r===null)return null;let c=Rn(r,s,t.locale);if(typeof c!="string")throw new g(c.problem,n.at);return c}case"datetime":case"at":{o(2);let r=V(i(0),n.at,n.fn),s=i(1);if(s===null||r===null)return null;let c=typeof s=="string"?On(s):void 0;if(c===void 0)throw new g(`${n.fn}(\u2026) needs a time of day written like '09:30', and was given ${typeof s=="string"?`"${s}"`:k(s)}`,n.at);return Tn(r,c,y)}case"addMinutes":{o(2);let r=V(i(0),n.at,"addMinutes"),s=i(1);if(r===null||s===null)return null;if(typeof s!="number"||!Number.isFinite(s))throw new g(`addMinutes(\u2026) needs a number of minutes, and was given ${k(s)}`,n.at);return Fn(r,Math.round(s))}case"weekday":{o(1);let r=V(i(0),n.at,"weekday");return r===null?null:Gn(r)}case"startOfWeek":{o(1,2);let r=V(i(0),n.at,"startOfWeek"),s=n.args.length===2?i(1):"mon";if(!Vn(s))throw new g("startOfWeek(\u2026) starts the week on a day said 'mon' to 'sun'",n.at);return r===null?null:Dn(r,s)}case"today":return o(0),u;case"now":return o(0),f;case"date":{o(1);let r=Z(i(0),n.at,"date");return r===null?null:new Date(r).toISOString().slice(0,10)}case"days":case"hours":{o(2);let r=Z(i(0),n.at,n.fn),s=Z(i(1),n.at,n.fn);if(r===null||s===null)return null;let c=(s-r)/(n.fn==="days"?864e5:36e5);return n.fn==="days"?Math.round(c):c}case"round":{o(1,2);let r=i(0);if(r===null)return null;if(typeof r!="number")throw new g(`round(\u2026) needs a number, and was given ${k(r)}`,n.at);let s=n.args.length===2?i(1):0;if(typeof s!="number"||!Number.isInteger(s)||s<0||s>12)throw new g("round(\u2026, places) takes a whole number of places from 0 to 12",n.at);let c=10**s,h=Math.sign(r)*Math.round(Math.abs(r)*c*(1+Number.EPSILON))/c;return Object.is(h,-0)?0:h}case"if":return o(3),R(i(0),n.at,"the condition in if(\u2026)")?i(1):i(2);default:throw new g(`"${n.fn}" is not a function the rule language knows`,n.at)}}function an(n,d,o,i){if(n===null||d===null)return n===d?0:n===null?1:-1;if(Array.isArray(n)&&Array.isArray(d)){for(let r=0;r<Math.max(n.length,d.length);r++){let s=an(n[r]??null,d[r]??null,o,i);if(s!==0)return s}return 0}let p=r=>typeof r=="number"||typeof r=="string"||typeof r=="boolean"?typeof r:k(r);if(p(n)!==p(d)||typeof n=="object"||typeof d=="object")throw new g(`sort(\u2026) cannot put ${k(n)} and ${k(d)} in order`,i);return typeof n=="string"?o*(n<d?-1:n>d?1:0):o*(Number(n)-Number(d))}return A(e,t.subject)}var ke=["out","in","all","count","exists","every","some","sum","min","max","present","len","contains","startsWith","lower","today","now","date","days","hours","if","first","sort","either","fact","archived","round","concat","format","datetime","at","addMinutes","weekday","startOfWeek"];var re=(e,t,a,l,u)=>({severity:"error",code:e,path:t,message:a,...l?{fix:l}:{},...u}),Se=(e,t,a,l,u)=>({...re(e,t,a,l,u?.length?{edits:u}:void 0),severity:"warning"}),Ae=e=>e.some(t=>t.severity==="error");function oe(e,t){return[...(e.edits??[]).map(a=>`${t}edit: ${JSON.stringify(a)}`),...e.details?[`${t}details: ${e.details}`]:[],...(e.fixes??[]).flatMap(a=>[`${t}fix: ${a.label}`,...(a.edits??[]).map(l=>`${t} edit: ${JSON.stringify(l)}`)])].map(a=>`
|
|
2
2
|
${a}`).join("")}function Ne(e){return e.map(t=>`${t.severity==="error"?"\u2717":t.severity==="warning"?"!":"\xB7"} ${t.path||"(document)"}: ${t.message}${t.fix?` \u2014 ${t.fix}`:""}${oe(t," ")}`).join(`
|
|
3
3
|
`)}var ie=(e,t)=>e.to==="*"||e.to.includes(t);function Ln(e,t,a){let l=a(e);if(l){if(t.some(u=>l.from.includes(u)))return{step:{relation:e,out:!0},far:l.to};if(t.some(u=>ie(l,u)))return{step:{relation:e,out:!1},far:l.from}}}function Re(e,t,a,l){if(!l(t.every))return{problem:{key:"every",message:`"${t.every}" is not a kind this document declares`}};let u=Ln(t.through,[e],a);if(!u){let S=a(t.through);return{problem:{key:"through",message:S?`"${t.through}" is a relation of ${S.from.join(", ")}, not of ${e}, so a ${e} cannot be followed through it`:`"${t.through}" is not a relation any kind declares`,fix:S?`name a relation ${e} declares, or one that points at ${e}`:void 0}}}let f=u.far==="*"?"*":u.far;if(!t.via)return f==="*"||f.includes(t.every)?{plan:{every:t.every,through:u.step}}:{problem:{key:"through",message:`"${t.through}" reaches ${f.join(", ")}, not ${t.every}`,fix:`add "via": the relation from ${f.join(" or ")} to ${t.every}, or name a relation that reaches ${t.every}`}};let y=f==="*"?[t.every]:f,$=Ln(t.via,y,a);if(!$){let S=a(t.via);return{problem:{key:"via",message:S?`"${t.via}" is a relation of ${S.from.join(", ")}, which "${t.through}" does not reach`:`"${t.via}" is not a relation any kind declares`,fix:S?`name a relation of ${y.join(" or ")}, or one that points at it`:void 0}}}let x=f==="*"?[t.every]:$.far;return x==="*"||x.includes(t.every)?{plan:{every:t.every,through:u.step,via:f==="*"?{relation:$.step.relation,out:!$.step.out}:$.step}}:{problem:{key:"via",message:`"${t.via}" reaches ${x.join(", ")}, not ${t.every}`,fix:`name a relation that reaches ${t.every}`}}}var Pn=(e,t,a)=>a.out?e.out(t,a.relation):e.in(t,a.relation);function Oe(e,t,a){let l=new Set;for(let u of Pn(e,t.id,a.through)){if(!a.via){l.add(u.id);continue}for(let f of Pn(e,u.id,a.via))l.add(f.id)}return e.nodesOfKind(a.every).filter(u=>!l.has(u.id))}var _e=["money","percent","date","time","datetime","relative","upper","lower","count","words","and","plural","excerpt"],ae={getNode:()=>{},allNodes:()=>[],allEdges:()=>[],nodesOfKind:()=>[],edgesOfKind:()=>[],out:()=>[],in:()=>[],neighbors:()=>[],has:()=>!1};function Ce(e,t,a,l=[],u,f=U){return tn(e,t,a,l,u,f)}var jn=(e,t)=>e.capital?J(t):t,se=new Set(["words","plural","relative"]);function Ie(e,t){let a=e[0];return!a||a.text!==void 0||!a.format||!se.has(a.format)?t:/^[a-z][a-z'’-]*(?=\s|$|[,.;:!?])/.test(t)?J(t):t}function de(e){return e?t=>{let a=e.tryDefinition(t.kind)?.label;return a?a(t):U(t)}:U}var vn=["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],Un=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];function le(e,t){return!Number.isInteger(e)||e<0||e>99?q(e,t):e<20?vn[e]:e%10===0?Un[e/10]:`${Un[Math.floor(e/10)]}-${vn[e%10]}`}function ue(e){return/[^aeiou]y$/i.test(e)?`${e.slice(0,-1)}ies`:/(s|x|z|ch|sh)$/i.test(e)?`${e}es`:`${e}s`}var U=e=>String(e.name??e.title??e.label??e.id);function tn(e,t,a,l=[],u,f=U){if(t==="plural"){let y=e instanceof w?e.nodes.length:Array.isArray(e)?e.length:typeof e=="number"?e:null;return y===null||l[0]===void 0?"\u2014":y===1?l[0]:l[1]??ue(l[0])}if(e===null)return"\u2014";if(e instanceof w)return t==="count"?String(e.nodes.length):t==="and"?B(e.nodes.map(f)):e.nodes.map(f).join(", ");if(Array.isArray(e)){if(t==="count")return String(e.length);let y=e.map($=>tn($,void 0,a,[],u,f));return t==="and"?B(y):y.join(", ")}if(typeof e=="object")return f(e);switch(t){case"words":return typeof e=="number"?le(e,u?.locale):String(e);case"money":return typeof e=="number"?X(e,u,l[0]==="0"?0:void 0):String(e);case"percent":return typeof e=="number"?q(e,u?.locale,{style:"percent",maximumFractionDigits:0}):String(e);case"upper":return String(e).toUpperCase();case"lower":return String(e).toLowerCase();case"excerpt":return $n(String(e),Number(l[0])||void 0);case"date":return _(Y(String(e),u?.timeZone)??String(e).slice(0,10),u?.locale);case"time":return typeof e=="string"&&W.test(e)?_(e,u?.locale):cn(String(e),u?.locale,u?.timeZone);case"datetime":return typeof e=="string"&&W.test(e)?_(e,u?.locale):H(String(e),u?.locale,u?.timeZone);case"relative":{let y=Y(String(e),u?.timeZone),$=y===void 0?Date.parse(String(e)):Date.parse(`${y}T00:00:00Z`);if(Number.isNaN($))return String(e);let x=Math.round(($-Date.parse(`${a}T00:00:00Z`))/864e5);return x===0?"today":x===1?"tomorrow":x===-1?"yesterday":x>0?`in ${x} days`:`${-x} days ago`}default:return typeof e=="string"&&sn.test(e)?_(e,u?.locale):typeof e=="string"&&D.test(e)?H(e,u?.locale,u?.timeZone):String(e)}}function fe(e,t,a){return(Array.isArray(e)?e:[e]).map(l=>t[String(l)]??(a?yn(String(l)):gn(String(l)))).join(", ")}function Le(e,t){let a=t.today??P(),l=t.name??de(t.graph?.schema);return e.map(u=>{if(u.text!==void 0)return u.text;try{let f=In(u.expr,{graph:t.graph??ae,subject:t.node,kinds:t.kinds,today:a,budget:t.budget??500,...t.bindings?{bindings:t.bindings}:{}}),y=!u.format&&u.expr.t==="ident"&&t.node?t.kinds.get(t.node.kind)?.choices?.get(u.expr.name):void 0;return y&&(typeof f=="string"||Array.isArray(f))?jn(u,fe(f,y,e.length===1)):jn(u,tn(f,u.format,a,u.formatArgs,t.money,l))}catch(f){if(f instanceof g)return"\u2014";throw f}}).join("")}export{w as a,be as b,ee as c,g as d,en as e,In as f,ke as g,re as h,Se as i,Ae as j,Ne as k,_e as l,ae as m,Ce as n,jn as o,Ie as p,de as q,fe as r,Le as s,Re as t,Oe as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as o,l as u}from"./chunk.
|
|
1
|
+
import{g as o,l as u}from"./chunk.3VEZ5MOC.js";function c(t,n,i){let e=r=>encodeURIComponent(r);return`${o}${e(t)}:${e(n)}:${e(i)}`}function S(t,n,i){let e=new Set(t.shown??[]);if(i?e.add(n):e.delete(n),e.size===0){let{shown:r,...w}=t;return w}return{...t,shown:[...e].sort()}}function l(t,n){if(n===null||n.trim().length===0){let{q:i,...e}=t;return e}return{...t,q:n}}function p(t){let n=t.q!==void 0&&t.within?.q===t.q;return l(n?u(t,"q",null):t,null)}function h(t,n){if(!n){let{past:i,...e}=t;return e}return{...t,past:!0}}function f(t,n){if(n===null||n.x===0&&n.y===0){let{pan:i,...e}=t;return e}return{...t,pan:n}}function d(t,n,i){let e={...t.pins};return i===null?delete e[n]:e[n]=i,{...t,pins:e}}export{c as a,S as b,l as c,p as d,h as e,f,d as g};
|