graview 0.1.64 → 0.1.66
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/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/preview/chunk.2KFZHUAC.js +1 -0
- package/dist/preview/chunk.2MHNPBHC.js +1 -0
- package/dist/preview/{chunk.77JI5T4F.js → chunk.2VR7YEJ6.js} +1 -1
- package/dist/preview/chunk.32SHA3EY.js +1 -0
- package/dist/preview/chunk.3L4JMM3P.js +1 -0
- package/dist/preview/chunk.3PBTN7RO.js +1 -0
- package/dist/preview/chunk.45JP6VGJ.js +5 -0
- package/dist/preview/{chunk.DUP2CGVH.js → chunk.4AC2QM7T.js} +1 -1
- package/dist/preview/chunk.4FCFNAA4.js +1 -0
- package/dist/preview/chunk.4FDVINRJ.js +1 -0
- package/dist/preview/chunk.4JULYKGD.js +1 -0
- package/dist/preview/chunk.4U4D7WOI.js +1 -0
- package/dist/preview/chunk.4WGYUYWU.js +2 -0
- package/dist/preview/chunk.5B5SRTUK.js +1 -0
- package/dist/preview/chunk.5BX66FBP.js +1 -0
- package/dist/preview/chunk.5CXIEYHY.js +2 -0
- package/dist/preview/chunk.5EMIWORS.js +1 -0
- package/dist/preview/{chunk.D2XLECMP.js → chunk.5FNFRVTL.js} +1 -1
- package/dist/preview/chunk.5LJVOLKR.js +1 -0
- package/dist/preview/{chunk.APUQIELA.js → chunk.6EHHMWPP.js} +1 -1
- package/dist/preview/chunk.6EVMXBNB.js +1 -0
- package/dist/preview/chunk.6FQW6FNL.js +1 -0
- package/dist/preview/chunk.6HY6ZGEE.js +5 -0
- package/dist/preview/{chunk.K5YFUMRS.js → chunk.6LXIEM6B.js} +1 -1
- package/dist/preview/chunk.6MQ5NT7S.js +1 -0
- package/dist/preview/chunk.6P6NGZ6D.js +1 -0
- package/dist/preview/{chunk.XIVELWAM.js → chunk.6TLXFMX2.js} +1 -1
- package/dist/preview/chunk.72XP2ARZ.js +1 -0
- package/dist/preview/{chunk.2V7QTIAV.js → chunk.72ZCLEQC.js} +1 -1
- package/dist/preview/{chunk.ITBG37WJ.js → chunk.7BIPZTJB.js} +1 -1
- package/dist/preview/chunk.7VADSNPZ.js +1 -0
- package/dist/preview/{chunk.2VYGDY5Z.js → chunk.7VP6Y6D2.js} +1 -1
- package/dist/preview/{chunk.S7SHWDPR.js → chunk.7ZKBYXUM.js} +1 -1
- package/dist/preview/chunk.AK7NGFEX.js +6 -0
- package/dist/preview/{chunk.2VIS2NAT.js → chunk.ANS2IEEV.js} +1 -1
- package/dist/preview/{chunk.UDYFGYJP.js → chunk.B6JRTW3A.js} +1 -1
- package/dist/preview/chunk.BCQWAFGD.js +1 -0
- package/dist/preview/{chunk.7SRSE5IS.js → chunk.BFAFCVL4.js} +1 -1
- package/dist/preview/chunk.BGAC3B7X.js +1 -0
- package/dist/preview/chunk.BMENTGDC.js +21 -0
- package/dist/preview/chunk.BOCVLC7X.js +1 -0
- package/dist/preview/{chunk.7VAHHEDX.js → chunk.BUVTUAB5.js} +1 -1
- package/dist/preview/chunk.BXBEGMPO.js +22 -0
- package/dist/preview/{chunk.4XCYZRZ3.js → chunk.BZ7QWHAE.js} +1 -1
- package/dist/preview/chunk.C2C3AXGI.js +1141 -0
- package/dist/preview/chunk.CBXS23YH.js +23 -0
- package/dist/preview/chunk.CEQQIW7Z.js +1 -0
- package/dist/preview/chunk.CEVGND3Y.js +6 -0
- package/dist/preview/{chunk.WHX47OJM.js → chunk.CTASTRQN.js} +1 -1
- package/dist/preview/chunk.CU2WCYMK.js +1 -0
- package/dist/preview/{chunk.7CLKGKSF.js → chunk.CVPMSPCH.js} +1 -1
- package/dist/preview/chunk.DEHIR4EG.js +1 -0
- package/dist/preview/chunk.DPJNGFEZ.js +4 -0
- package/dist/preview/chunk.DQFHIJFN.js +1 -0
- package/dist/preview/chunk.DSYP43NN.js +1 -0
- package/dist/preview/chunk.DTCAUPLC.js +1 -0
- package/dist/preview/{chunk.4U45EY5M.js → chunk.DZFM6GSY.js} +1 -1
- package/dist/preview/chunk.E3UL4MCD.js +35 -0
- package/dist/preview/chunk.E4VRRWFP.js +1 -0
- package/dist/preview/chunk.E7EWNWAN.js +1 -0
- package/dist/preview/chunk.EG7OOJH5.js +1 -0
- package/dist/preview/{chunk.TQ2G4AM4.js → chunk.EMFOMSMI.js} +1 -1
- package/dist/preview/{chunk.5B7NG6WH.js → chunk.EQ4OODGO.js} +1 -1
- package/dist/preview/{chunk.CJHYGRWV.js → chunk.ES63XSIM.js} +1 -1
- package/dist/preview/chunk.EUAO4QNV.js +1 -0
- package/dist/preview/{chunk.47N2G7A5.js → chunk.EXYCN4WI.js} +1 -1
- package/dist/preview/chunk.F4VB6Q2W.js +1 -0
- package/dist/preview/chunk.F7672TKJ.js +1 -0
- package/dist/preview/chunk.FA42HCPW.js +1 -0
- package/dist/preview/{chunk.DLWFULWE.js → chunk.FBILPNGH.js} +1 -1
- package/dist/preview/chunk.FBJAQPZ6.js +1 -0
- package/dist/preview/{chunk.2DH42I7L.js → chunk.FDZE5LTJ.js} +2 -2
- package/dist/preview/chunk.FFOD5B4B.js +2 -0
- package/dist/preview/{chunk.TA2JTUNX.js → chunk.FIFUMX5X.js} +1 -1
- package/dist/preview/{chunk.T4TRJDBF.js → chunk.FK722SHI.js} +1 -1
- package/dist/preview/chunk.FV72U33M.js +1 -0
- package/dist/preview/chunk.FXT5CN32.js +19 -0
- package/dist/preview/chunk.GAFMWOME.js +1 -0
- package/dist/preview/{chunk.OXFDB5BB.js → chunk.GEFXU4VO.js} +1 -1
- package/dist/preview/chunk.GG47EIKO.js +1 -0
- package/dist/preview/chunk.GME63ZHI.js +1 -0
- package/dist/preview/{chunk.PVDDSBRG.js → chunk.GNEOSHQ6.js} +1 -1
- package/dist/preview/chunk.HOCD7KIR.js +1 -0
- package/dist/preview/chunk.HSSIMVVM.js +1 -0
- package/dist/preview/{chunk.ZA5TDCBC.js → chunk.I2737CPF.js} +1 -1
- package/dist/preview/chunk.I4Z7HVRT.js +1 -0
- package/dist/preview/chunk.IAEHUSQQ.js +1 -0
- package/dist/preview/chunk.IGK7EZCX.js +1 -0
- package/dist/preview/chunk.INHS3KTK.js +1 -0
- package/dist/preview/{chunk.JHUCKEJS.js → chunk.IWYMKGZZ.js} +1 -1
- package/dist/preview/chunk.J2MM6BUW.js +1 -0
- package/dist/preview/{chunk.JOM6MFVE.js → chunk.J7W2OFHY.js} +1 -1
- package/dist/preview/chunk.JMXXA4YG.js +1 -0
- package/dist/preview/chunk.JMYUQNXN.js +6 -0
- package/dist/preview/chunk.JO2X52D4.js +1 -0
- package/dist/preview/{chunk.YEXFVDRA.js → chunk.JXNVNFV4.js} +1 -1
- package/dist/preview/chunk.K6DFXDPZ.js +1 -0
- package/dist/preview/{chunk.WPQP54FM.js → chunk.KACSYPEV.js} +1 -1
- package/dist/preview/{chunk.R5MLRKAO.js → chunk.KBPJ7X7W.js} +1 -1
- package/dist/preview/chunk.KF27ME27.js +1 -0
- package/dist/preview/{chunk.WX23K7ZU.js → chunk.KSIEO5W7.js} +1 -1
- package/dist/preview/chunk.L25DCT5S.js +1 -0
- package/dist/preview/{chunk.UDU545CL.js → chunk.LETAQTLJ.js} +1 -1
- package/dist/preview/{chunk.VZAF3452.js → chunk.LGRVEHXT.js} +2 -2
- package/dist/preview/chunk.LINSO5PN.js +1 -0
- package/dist/preview/{chunk.XJWKIXPV.js → chunk.LLIURXFP.js} +1 -1
- package/dist/preview/{chunk.BVIJXL4J.js → chunk.LSN2IPAI.js} +1 -1
- package/dist/preview/chunk.M2JCFNHJ.js +1 -0
- package/dist/preview/{chunk.B3WVCSW5.js → chunk.M5FP4Y4Q.js} +1 -1
- package/dist/preview/{chunk.YSBTE3PX.js → chunk.M6ZN2KUO.js} +1 -1
- package/dist/preview/chunk.MODLZJD4.js +25 -0
- package/dist/preview/chunk.MWGZKZD6.js +1 -0
- package/dist/preview/{chunk.2JEN2RCB.js → chunk.NJRLJEJY.js} +1 -1
- package/dist/preview/chunk.NYLKG25K.js +4 -0
- package/dist/preview/{chunk.YMXWS4XN.js → chunk.OEIWIZCP.js} +1 -1
- package/dist/preview/{chunk.DQAMVVE6.js → chunk.OJY7VJ7D.js} +1 -1
- package/dist/preview/chunk.OMT4QUZY.js +23 -0
- package/dist/preview/{chunk.Z26T5E76.js → chunk.ONYBW45K.js} +1 -1
- package/dist/preview/chunk.OO2OP76C.js +1 -0
- package/dist/preview/{chunk.UJNLT3L6.js → chunk.OOSIKCOS.js} +1 -1
- package/dist/preview/{chunk.B6JR7EQO.js → chunk.OPTYYIGC.js} +1 -1
- package/dist/preview/{chunk.TMHVYI5R.js → chunk.OTV5XTBB.js} +1 -1
- package/dist/preview/{chunk.F6BNFLQM.js → chunk.OWFS2YDQ.js} +1 -1
- package/dist/preview/{chunk.CXDGE5ZS.js → chunk.OWO3OV62.js} +1 -1
- package/dist/preview/{chunk.4VRX7FCO.js → chunk.PAGEGBUD.js} +1 -1
- package/dist/preview/{chunk.NGRL3QOI.js → chunk.PDDIQ6PK.js} +1 -1
- package/dist/preview/{chunk.OW3M4OBN.js → chunk.PFQBCHQA.js} +1 -1
- package/dist/preview/{chunk.LDMBJC3B.js → chunk.PPSYUOH7.js} +1 -1
- package/dist/preview/{chunk.GH5UBSQI.js → chunk.PSQYDCVM.js} +1 -1
- package/dist/preview/chunk.QDVGHI7R.js +1 -0
- package/dist/preview/chunk.QFHWG4LN.js +1 -0
- package/dist/preview/chunk.QGIM2WAY.js +1 -0
- package/dist/preview/chunk.QHMHUL6B.js +3 -0
- package/dist/preview/chunk.QOS5T46W.js +1 -0
- package/dist/preview/{chunk.E4TXLT25.js → chunk.QPF4KSAW.js} +1 -1
- package/dist/preview/chunk.QQAZQDRW.js +1 -0
- package/dist/preview/chunk.QU52E5RG.js +3 -0
- package/dist/preview/{chunk.REXU6ARY.js → chunk.QWNSHISU.js} +2 -2
- package/dist/preview/chunk.RSMCTI2N.js +1 -0
- package/dist/preview/chunk.RWIN3POV.js +1 -0
- package/dist/preview/chunk.SSF47GUY.js +1 -0
- package/dist/preview/chunk.T6DPWW2K.js +3 -0
- package/dist/preview/chunk.TA36WBHK.js +1 -0
- package/dist/preview/chunk.TBY5IR7C.js +1 -0
- package/dist/preview/chunk.TGEL6EUA.js +1 -0
- package/dist/preview/chunk.TTGKX7LT.js +1 -0
- package/dist/preview/chunk.TXHYGFIZ.js +1 -0
- package/dist/preview/chunk.U3ED7W2U.js +1 -0
- package/dist/preview/chunk.U3HERHAI.js +88 -0
- package/dist/preview/chunk.U6QXLNHF.js +15 -0
- package/dist/preview/{chunk.P4TAX3HE.js → chunk.U6TEW6YD.js} +1 -1
- package/dist/preview/chunk.UJPX3BUV.js +1 -0
- package/dist/preview/chunk.V5I4GZEY.js +1 -0
- package/dist/preview/{chunk.HZPRMHSL.js → chunk.V7W5AQKL.js} +1 -1
- package/dist/preview/{chunk.77MLXWZV.js → chunk.VGHO3VCB.js} +1 -1
- package/dist/preview/{chunk.YIZPW7IK.js → chunk.VKZIEZ5C.js} +2 -2
- package/dist/preview/chunk.VT2YGDK2.js +1 -0
- package/dist/preview/{chunk.XCLW4GP7.js → chunk.W4YDPHCQ.js} +1 -1
- package/dist/preview/{chunk.2TCOLAL2.js → chunk.W53YNBSM.js} +1 -1
- package/dist/preview/chunk.WAB3L3ZI.js +1 -0
- package/dist/preview/chunk.WSDJPXJD.js +1 -0
- package/dist/preview/chunk.WSO7JOW5.js +1 -0
- package/dist/preview/{chunk.4DZOAB4D.js → chunk.WVLEGCRI.js} +1 -1
- package/dist/preview/chunk.XK65Y2KX.js +1 -0
- package/dist/preview/chunk.XMQG2PSM.js +50 -0
- package/dist/preview/{chunk.WFCE7NLK.js → chunk.XOE4KNP2.js} +2 -2
- package/dist/preview/chunk.Y7QDQ3WF.js +1 -0
- package/dist/preview/chunk.YIPXZUTT.js +2 -0
- package/dist/preview/chunk.YNEHJWJV.js +2 -0
- package/dist/preview/chunk.YXEO3Y65.js +1 -0
- package/dist/preview/chunk.Z274CL7J.js +1 -0
- package/dist/preview/chunk.Z7Y3R3YR.js +3 -0
- package/dist/preview/{chunk.JS2UZYGB.js → chunk.ZBVYD4OX.js} +1 -1
- package/dist/preview/{chunk.P6FNJR6E.js → chunk.ZD7T234N.js} +1 -1
- package/dist/preview/{chunk.2G5WLG3Z.js → chunk.ZQR2SN65.js} +1 -1
- package/dist/preview/chunk.ZR2TP3BF.js +111 -0
- package/dist/preview/chunk.ZRBGYXAO.js +6 -0
- package/dist/preview/index.html +57 -55
- package/dist/preview/page.js +2 -2
- package/dist/preview/splash.js +17 -14
- package/package.json +6 -6
- package/dist/preview/chunk.2D7K2IJQ.js +0 -4
- package/dist/preview/chunk.2E62YCMZ.js +0 -1
- package/dist/preview/chunk.2HV5FF6O.js +0 -1
- package/dist/preview/chunk.2JDAUKSN.js +0 -1133
- package/dist/preview/chunk.37I45R6V.js +0 -35
- package/dist/preview/chunk.3FKKH2XU.js +0 -74
- package/dist/preview/chunk.3J7XLJP2.js +0 -1
- package/dist/preview/chunk.3L37FY3G.js +0 -4
- package/dist/preview/chunk.3OEODIHB.js +0 -1
- package/dist/preview/chunk.3RD4JHVG.js +0 -88
- package/dist/preview/chunk.3RUV4HE4.js +0 -1
- package/dist/preview/chunk.3SAESG6X.js +0 -1
- package/dist/preview/chunk.4HTB6TX2.js +0 -1
- package/dist/preview/chunk.4Q5PCMGZ.js +0 -18
- package/dist/preview/chunk.52MBXPEK.js +0 -1
- package/dist/preview/chunk.5AD2QHWH.js +0 -3
- package/dist/preview/chunk.5HJ2GTKZ.js +0 -1
- package/dist/preview/chunk.5IEZF433.js +0 -2
- package/dist/preview/chunk.5PPCK7QT.js +0 -1
- package/dist/preview/chunk.6NRWLCIZ.js +0 -5
- package/dist/preview/chunk.75JQCTR6.js +0 -1
- package/dist/preview/chunk.7AOEZJRM.js +0 -1
- package/dist/preview/chunk.7ZG77OI3.js +0 -1
- package/dist/preview/chunk.7ZHH7WBN.js +0 -1
- package/dist/preview/chunk.AJEK3I5X.js +0 -6
- package/dist/preview/chunk.APRWUIE3.js +0 -1
- package/dist/preview/chunk.ATHLE33D.js +0 -1
- package/dist/preview/chunk.B2YTHEX5.js +0 -1
- package/dist/preview/chunk.BN42H3C6.js +0 -1
- package/dist/preview/chunk.CC7P435K.js +0 -9
- package/dist/preview/chunk.CM65MCHA.js +0 -1
- package/dist/preview/chunk.DJIF7IAQ.js +0 -2
- package/dist/preview/chunk.DMENNIHT.js +0 -1
- package/dist/preview/chunk.DN7UCBOA.js +0 -1
- package/dist/preview/chunk.DVSTLVIH.js +0 -15
- package/dist/preview/chunk.DYRULRFX.js +0 -1
- package/dist/preview/chunk.FN34P4IS.js +0 -1
- package/dist/preview/chunk.FUPYIOXZ.js +0 -1
- package/dist/preview/chunk.FXRYMT3U.js +0 -1
- package/dist/preview/chunk.G5BVZLCM.js +0 -1
- package/dist/preview/chunk.G7YLK4PX.js +0 -1
- package/dist/preview/chunk.GF62K25C.js +0 -1
- package/dist/preview/chunk.GFQPO3NC.js +0 -1
- package/dist/preview/chunk.GHHKRFPD.js +0 -1
- package/dist/preview/chunk.GP5DAA4P.js +0 -3
- package/dist/preview/chunk.HPG6CNKM.js +0 -1
- package/dist/preview/chunk.HSJEOM3W.js +0 -1
- package/dist/preview/chunk.IQGSEAQ2.js +0 -5
- package/dist/preview/chunk.K2HDEL7I.js +0 -1
- package/dist/preview/chunk.K2PXP5H6.js +0 -1
- package/dist/preview/chunk.K54ISAXN.js +0 -1
- package/dist/preview/chunk.KHXRJLLU.js +0 -50
- package/dist/preview/chunk.KMIFSPGQ.js +0 -1
- package/dist/preview/chunk.L4V5VLSM.js +0 -1
- package/dist/preview/chunk.LTOQ22ZJ.js +0 -1
- package/dist/preview/chunk.M5VHUIDB.js +0 -1
- package/dist/preview/chunk.N643PVQA.js +0 -1
- package/dist/preview/chunk.NJSK3UO2.js +0 -6
- package/dist/preview/chunk.NRPBTV6O.js +0 -21
- package/dist/preview/chunk.O7HHNQK4.js +0 -2
- package/dist/preview/chunk.PR74PGLC.js +0 -1
- package/dist/preview/chunk.QROPDEJF.js +0 -1
- package/dist/preview/chunk.QRT6BZR6.js +0 -1
- package/dist/preview/chunk.RDA35HZB.js +0 -2
- package/dist/preview/chunk.S6QZBWCJ.js +0 -1
- package/dist/preview/chunk.SADHOSRC.js +0 -19
- package/dist/preview/chunk.SJHUC4TL.js +0 -1
- package/dist/preview/chunk.SL5FXE3R.js +0 -1
- package/dist/preview/chunk.T4JP6BGP.js +0 -1
- package/dist/preview/chunk.TOLW64EO.js +0 -1
- package/dist/preview/chunk.TP3PZRHE.js +0 -1
- package/dist/preview/chunk.TUR2DA2M.js +0 -1
- package/dist/preview/chunk.TYIBLD2D.js +0 -1
- package/dist/preview/chunk.UD2GGG7L.js +0 -1
- package/dist/preview/chunk.UN2IAA5R.js +0 -1
- package/dist/preview/chunk.VLX7YWVH.js +0 -25
- package/dist/preview/chunk.VT4YBFZL.js +0 -1
- package/dist/preview/chunk.WMARJ5E3.js +0 -1
- package/dist/preview/chunk.X36BYTEG.js +0 -1
- package/dist/preview/chunk.XEG7ZDRG.js +0 -1
- package/dist/preview/chunk.XQ5RTPEF.js +0 -1
- package/dist/preview/chunk.YLOGIJOH.js +0 -1
- package/dist/preview/chunk.Z4XGEV34.js +0 -1
- package/dist/preview/chunk.ZNDVJGTY.js +0 -1
- package/dist/preview/chunk.ZQGLPP7A.js +0 -1
- /package/dist/preview/{chunk.GZHZLJBF.js → chunk.MIE4TJRW.js} +0 -0
package/dist/index.js
CHANGED
|
@@ -31,11 +31,11 @@ export async function main(given) {
|
|
|
31
31
|
// The page they serve is built into this package (`dist/preview/`, by scripts/build-preview-page.mjs): it is the tool's to carry, not a product's dependency's.
|
|
32
32
|
const { preview, shots } = await import("@graview/ship/cli");
|
|
33
33
|
const page = fileURLToPath(new URL("./preview/", import.meta.url));
|
|
34
|
-
if (command === "shots")
|
|
35
|
-
return shots(rest, { page });
|
|
36
34
|
// The opening screen's renderer rides beside the page (`@graview/pages/splash`, bundled there), so the tool depends on no face to draw it.
|
|
37
|
-
const { splashHtml } = (await import(new URL("./preview/splash.js", import.meta.url).href));
|
|
38
|
-
|
|
35
|
+
const { splashHtml, splashPage } = (await import(new URL("./preview/splash.js", import.meta.url).href));
|
|
36
|
+
if (command === "shots")
|
|
37
|
+
return shots(rest, { page, splash: splashHtml, splashPage });
|
|
38
|
+
return preview(rest, { page, splash: splashHtml, splashPage });
|
|
39
39
|
}
|
|
40
40
|
if (command === "sync-seed") {
|
|
41
41
|
const { syncSeed } = await import("@graview/ship/cli");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,IAAI,IAAI,IAAI,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEtE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,KAAwB;IACjD,iGAAiG;IACjG,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACxD,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAChC,IAAI,OAAO,KAAK,OAAO,EAAE,CAAC;QACxB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;QACpD,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IACD,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,OAAO,EAAE,CAAC;QACjD,gKAAgK;QAChK,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;QAC7D,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QACnE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,IAAI,IAAI,IAAI,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEtE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,KAAwB;IACjD,iGAAiG;IACjG,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACxD,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAChC,IAAI,OAAO,KAAK,OAAO,EAAE,CAAC;QACxB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;QACpD,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IACD,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,OAAO,EAAE,CAAC;QACjD,gKAAgK;QAChK,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;QAC7D,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QACnE,2IAA2I;QAC3I,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,CAAC,MAAM,MAAM,CAAC,IAAI,GAAG,CAAC,qBAAqB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAA+I,CAAC;QACtP,IAAI,OAAO,KAAK,OAAO;YAAE,OAAO,KAAK,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;QACtF,OAAO,OAAO,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;IACjE,CAAC;IACD,IAAI,OAAO,KAAK,WAAW,EAAE,CAAC;QAC5B,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;QACvD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,IAAI,OAAO,KAAK,OAAO,IAAI,OAAO,KAAK,OAAO,IAAI,OAAO,KAAK,OAAO,IAAI,OAAO,KAAK,UAAU,EAAE,CAAC;QACrH,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC;QAClF,OAAO,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACvK,CAAC;IACD,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;QACzB,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,CAAC;QACvD,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;IACD,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QACvB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC;QACpD,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;IACD,IAAI,CAAC,OAAO,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QAC/E,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC;QACpC,OAAO,CAAC,CAAC;IACX,CAAC;IACD,OAAO,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;AACzB,CAAC;AAED,wEAAwE;AACxE,KAAK,UAAU,KAAK;IAClB,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAC1D,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC;IACnG,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,CAAC;IAC7D,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC;IAC1D,OAAO,GAAG,UAAU,KAAK,WAAW,KAAK,SAAS,KAAK,WAAW,KAAK,cAAc,KAAK,WAAW,KAAK,YAAY,KAAK,UAAU,EAAE,CAAC;AAC1I,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{m}from"./chunk.U3HERHAI.js";import{G as N,W as f,_ as y}from"./chunk.MODLZJD4.js";import{b as g}from"./chunk.AJZBJBMO.js";var p=g(N(),1);var a=g(f(),1);var R={default:{background:"var(--graview-panel, #ffffff)",color:"var(--graview-ink, #1a1a1a)"},muted:{background:"var(--graview-panel-muted, #f7f5f1)",color:"var(--graview-ink, #1a1a1a)"},warning:{background:"var(--graview-panel-warning, #fdf3ec)",color:"var(--graview-ink, #1a1a1a)"}},T={color:"var(--graview-ink-muted, #55514a)"},C={color:"var(--graview-ink-faint, #625d55)"};function H(e){let[l,o]=(0,p.useState)(z);return(0,p.useEffect)(()=>{let r=e.current;if(!r||typeof ResizeObserver>"u")return;let t=()=>{let i=W(r,parseFloat(getComputedStyle(r).paddingBottom)||0);o(s=>s.overflowing===i.overflowing&&s.above===i.above&&s.below===i.below?s:i)};t();let d=new ResizeObserver(t);d.observe(r);for(let i of r.children)d.observe(i);return r.addEventListener("scroll",t,{passive:!0}),()=>{d.disconnect(),r.removeEventListener("scroll",t)}}),l}var z={overflowing:!1,above:!1,below:!1};function W(e,l=0){let o=e.scrollHeight>e.clientHeight+1,r=e.scrollWidth>e.clientWidth+1;return{overflowing:o||r,above:o&&e.scrollTop>1,below:o&&e.scrollTop+e.clientHeight<e.scrollHeight-l-1}}var A=(0,p.createContext)(null),I=(0,p.createContext)(null);function O({level:e,said:l=!0,style:o,children:r}){if(e===void 0)return(0,a.jsx)("strong",{style:o,...l?{}:{"aria-hidden":!0},children:r});let t=`h${e}`;return(0,a.jsx)(t,{style:{margin:0,...o},children:r})}function E({title:e,subtitle:l,meta:o,selected:r,tone:t="default",children:d,style:i,fit:s=!1,variant:w,heading:b}){let c=(0,p.useRef)(null),{overflowing:v,above:x,below:S}=H(c),P=y(),n=(w??(P==="fullscreen"?"page":"card"))==="page",k=(0,p.useContext)(A),u=(0,p.useContext)(I);return(0,a.jsxs)("div",{"data-graview-primitive":"panel","data-graview-variant":n?"page":"card","data-selected":r||void 0,style:{display:"flex",flexDirection:"column",gap:n?12:"var(--graview-gap, 7px)",height:n||s?"auto":"100%",maxHeight:n?"none":"100%",padding:n?0:"var(--graview-pad, 15px)",boxSizing:"border-box",borderRadius:n?0:"var(--graview-radius, 12px)",border:n?"none":`1px solid ${r?"var(--graview-accent, #2f6f5e)":"var(--graview-edge, #e4e0d8)"}`,boxShadow:n?"none":r?"0 0 0 1px var(--graview-accent-dim), var(--graview-lift-low)":"var(--graview-lift-low)",overflow:n?"visible":"hidden",...R[t],...n?{background:"transparent"}:{},...i},children:[t==="warning"?(0,a.jsx)("span",{"data-graview-broken":"",style:m,children:"Implicated in a problem."}):null,e===void 0||e===k?null:(0,a.jsxs)("div",{style:{display:"flex",alignItems:"baseline",flexWrap:"wrap",gap:8,minWidth:0},children:[t==="warning"?(0,a.jsx)("span",{"aria-hidden":"true",title:"Implicated in a problem",style:{color:"var(--graview-warn)",flex:"0 0 auto"},children:"\u26A0"}):null,(0,a.jsx)(O,{level:b,said:u===null||e!==u,style:{fontFamily:"var(--graview-font-display, inherit)",fontSize:n?"1.5625rem":"0.9375rem",lineHeight:n?1.15:1.25,fontWeight:n?600:560,letterSpacing:n?"-0.012em":"0.005em",minWidth:0,overflowWrap:"anywhere"},children:e}),o===void 0?null:(0,a.jsx)("span",{style:{marginLeft:"auto",fontSize:"0.75rem",letterSpacing:"0.08em",textTransform:"uppercase",minWidth:0,overflowWrap:"anywhere",...C},children:o})]}),l===void 0?null:(0,a.jsx)("div",{style:{fontSize:n?"0.90625rem":"0.8125rem",lineHeight:1.5,...T},children:l}),(0,a.jsx)("div",{ref:c,className:n?void 0:"graview-scroll",...v&&!n?{tabIndex:0,role:"region",...typeof e=="string"?{"aria-label":e}:{}}:{},style:{display:"flex",flexDirection:"column",gap:n?22:"var(--graview-gap, 7px)",flex:"1 1 auto",...n?{overflow:"visible"}:{marginBottom:"calc(-1 * var(--graview-pad, 15px))",paddingBottom:"var(--graview-pad, 15px)"},...!n&&!v?{overflow:"hidden"}:{}},"data-graview-more-above":x&&!n?"":void 0,"data-graview-more-below":S&&!n?"":void 0,children:d})]})}function h({label:e,hue:l,selected:o,title:r,pickId:t,emphasis:d}){let i=typeof e=="string"?e:void 0,s=l===void 0?void 0:Math.round(l);return(0,a.jsxs)("span",{"data-graview-primitive":"chip","data-selected":o||void 0,"data-graview-pick":t,"data-graview-emphasis":d,title:r??i,style:{cursor:t?"pointer":void 0,display:"inline-flex",alignItems:"center",alignSelf:"flex-start",minHeight:24,boxSizing:"border-box",padding:"3px 9px",borderRadius:6,fontSize:"0.8125rem",lineHeight:1.5,whiteSpace:"nowrap",maxWidth:"min(28ch, 100%)",overflow:"hidden",letterSpacing:"0.01em",border:`1px solid ${o?"var(--graview-accent)":s===void 0?"var(--graview-edge)":`hsl(${s} 55% var(--graview-tint-lightness) / 0.45)`}`,background:s===void 0?"var(--graview-panel-muted)":`hsl(${s} 55% var(--graview-tint-lightness) / calc(var(--graview-tint-alpha) * 0.65))`,color:"var(--graview-ink, #1a1a1a)",boxShadow:o?"0 0 14px -4px var(--graview-accent)":void 0},children:[s===void 0?null:(0,a.jsx)("span",{"aria-hidden":"true",style:{width:9,height:6,clipPath:"polygon(50% 0, 100% 50%, 50% 100%, 0 50%)",flex:"0 0 auto",marginRight:6,background:`hsl(${s} 55% var(--graview-tint-lightness) / 0.9)`}}),(0,a.jsx)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e})]})}function L({items:e,max:l=8,selectedIds:o=[],pick:r=!1}){let t=e.slice(0,l),d=e.length-t.length;return(0,a.jsxs)("div",{"data-graview-primitive":"roster",style:{display:"flex",flexWrap:"wrap",gap:6,alignContent:"flex-start"},children:[t.map(i=>(0,a.jsx)(h,{label:i.label,...i.hue===void 0?{}:{hue:i.hue},...r?{pickId:i.id}:{},...i.emphasis===void 0?{}:{emphasis:i.emphasis},selected:o.includes(i.id)},i.id)),d>0?(0,a.jsx)(h,{label:`+${d} more`}):null]})}function F({label:e,count:l,items:o,onExpand:r,flagged:t,problems:d}){return(0,a.jsx)(E,{title:e,meta:d?(0,a.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[d,(0,a.jsx)("span",{children:l})]}):l,tone:t?"warning":"muted",style:r?{cursor:"zoom-in"}:void 0,children:o&&o.length>0?(0,a.jsx)(L,{items:o,max:6,pick:!0}):null})}export{A as a,I as b,E as c,h as d,L as e,F as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as V}from"./chunk.ANS2IEEV.js";import"./chunk.V5I4GZEY.js";import"./chunk.XOZU4OFA.js";import{f as C,g as x,h as R}from"./chunk.GME63ZHI.js";import{a as D}from"./chunk.LLIURXFP.js";import{a as T,b as A,c as M}from"./chunk.PAGEGBUD.js";import"./chunk.WSDJPXJD.js";import"./chunk.F4VB6Q2W.js";import"./chunk.FFOD5B4B.js";import"./chunk.Z7Y3R3YR.js";import"./chunk.YXEO3Y65.js";import{a as F,c as $}from"./chunk.FBILPNGH.js";import{G as k,O as E,T as H,W as g}from"./chunk.MODLZJD4.js";import"./chunk.SDO3U72B.js";import"./chunk.6HY6ZGEE.js";import"./chunk.FQLNBIQ5.js";import{b as l}from"./chunk.AJZBJBMO.js";var m=l(k());var n=l(g()),B={maxWidth:560,margin:"0 auto",padding:"40px 20px 64px",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:16};function G({app:r,store:e,form:o,principal:i,heading:f=1,onSubmitted:a}){let t=(0,m.useMemo)(()=>C(r,o,e.allMutations()),[r,o,e]),d=H(e),v=(0,m.useMemo)(()=>d?e.seenBy(i):e,[d,e,i]),[p,b]=(0,m.useState)(!1),u=(0,m.useRef)(null);(0,m.useEffect)(()=>{p&&u.current?.focus()},[p]);let y=`h${f}`;if(!d)return null;if(!t)return(0,n.jsx)("main",{"data-graview-visitor-form":o,style:B,children:(0,n.jsx)("p",{role:"alert",children:"There is no form here."})});let S=R(t);return(0,n.jsxs)("main",{"data-graview-visitor-form":o,"aria-labelledby":"graview-visitor-form-title",style:B,children:[(0,n.jsx)(y,{id:"graview-visitor-form-title",style:{margin:0,fontSize:"var(--graview-text-title)"},children:t.title}),p?(0,n.jsxs)("div",{ref:u,role:"status",tabIndex:-1,"data-graview-part":"received",style:{display:"grid",gap:8,outline:"none"},children:[(0,n.jsx)("p",{style:{margin:0,fontWeight:600},children:S.said}),S.next?(0,n.jsx)("p",{style:{margin:0},children:S.next}):null]}):(0,n.jsxs)(n.Fragment,{children:[t.intro?(0,n.jsx)("p",{style:{margin:0,color:"var(--graview-ink-muted)"},children:t.intro}):null,(0,n.jsx)(V,{store:v,mutation:t.act,principal:i,only:t.fields.map(h=>h.name),label:t.submit,onDone:()=>{b(!0),a?.(o)}})]})]})}var s=l(k()),P=l($()),O=l(D());var c=l(g());function L(r){let{app:e,form:o,principal:i,scheme:f="auto",brand:a=e.brand,fonts:t=!0,height:d}=r,v=(0,s.useMemo)(()=>typeof i!="string"?i:e.forms?.[o]?x(e,o,i):{kind:"human",id:i,roles:[]},[e,o,i]),p=(0,s.useMemo)(()=>r.store??r.remote?.store??A(e,r.seed),[r.store,r.remote,e,r.seed]),b=M(f==="auto",a?.scheme),u=f==="auto"?b:f,y=`graview-form-${(0,s.useId)().replace(/[^a-zA-Z0-9_-]/g,"")}`,S=(0,s.useMemo)(()=>F(u,a,{scope:`.${y}`}),[u,a,y]);return(0,s.useEffect)(()=>{if(!t||typeof document>"u")return;let h=T(a);if(!h||document.querySelector(`link[href="${h}"]`))return;let w=document.createElement("link");w.rel="stylesheet",w.href=h,document.head.appendChild(w)},[a,t]),(0,c.jsxs)("section",{className:y,"aria-label":r.label??e.forms?.[o]?.title??e.name,"data-graview-embed":"form","data-graview-scheme":u,style:{position:"relative",isolation:"isolate",...d===void 0?{}:{minHeight:d},background:"var(--graview-ground)",color:"var(--graview-ink)",fontFamily:"var(--graview-font-body, system-ui)"},children:[(0,c.jsx)("style",{children:S}),(0,c.jsx)(E.Provider,{value:r.assetsAt,children:(0,c.jsx)(G,{app:e,store:p,form:o,principal:v,heading:r.heading??1,...r.onSubmitted?{onSubmitted:r.onSubmitted}:{}})})]})}function U(r,e){e.app.forms?.[e.form]||x(e.app,e.form,"form:");let o=e.store??e.remote?.store??A(e.app,e.seed),i=null;function f(){let[t,d]=(0,s.useState)(e.scheme??"auto");return i=d,(0,c.jsx)(L,{...e,store:o,scheme:t})}let a=(0,O.createRoot)(r);return(0,P.flushSync)(()=>a.render((0,c.jsx)(f,{}))),{store:o,setScheme:t=>(0,P.flushSync)(()=>i?.(t)),unmount:()=>a.unmount()}}export{L as FormEmbed,U as mount};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as o,l as u}from"./chunk.
|
|
1
|
+
import{g as o,l as u}from"./chunk.MODLZJD4.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as _,b as C,c as D,d as I,e as j,f as P,g as x,i as N}from"./chunk.GG47EIKO.js";var Y=0,Z=1,K=2,q=3,F=1,Q=2,U=3,ee=1,ne=3,te=8,H="~",v=o=>typeof o=="object"&&o!==null&&!Array.isArray(o),$=new Set(["input","select","textarea","option"]),re=new Set(["value","checked","selected"]),z=["aria-label","aria-labelledby","title"],se=o=>z.some(d=>(o.getAttribute(d)??"").trim()!=="");function de(o,d){let c=o.ownerDocument??o,h=d.maxNodes??5e3,p=[],g=new Map,T=new WeakMap,E={dom:o,name:"div",namespace:"html",children:[],id:H};g.set(H,E);let k=0,S=!1,b=new WeakMap,w=new Map,A=new Map,l=e=>{p.push(e),p.length>200&&p.shift(),d.onRefused?.(e)},y=()=>({dom:c.createComment(""),children:[],refused:!0}),X=(e,i)=>{if(e.namespace==="html"&&e.name&&$.has(e.name))return e.dom;if(i?.namespace==="html"&&i.name==="textarea")return i.dom},R=(e,i)=>{let s=e.dom,r=b.get(s)??s.getAttribute("role");if(r===null||!r.split(/\s+/).some(t=>_.includes(t.toLowerCase())))return void b.delete(s);if(se(s)){b.delete(s),s.getAttribute("role")!==r&&s.setAttribute("role",r);return}b.set(s,r),s.removeAttribute("role"),i&&l({reason:"value",element:e.name,name:"role"})},J=()=>{if(A.size===0)return;let e=new Set,i=s=>{for(let r of s.children){if(r.refused||r.text)continue;let t=r.dom.getAttribute("id");t&&e.add(t),i(r)}};i(E);for(let[s,r]of A){if(s.id===void 0||g.get(s.id)!==s){A.delete(s);continue}let t=s.dom;for(let[n,u]of r){let a=u.value.split(/\s+/).filter(m=>m!==""),f=a.filter(m=>!e.has(m));if(a.length>0&&f.length===0){if(u.drawn)continue;u.drawn=!0,t.setAttribute(n,u.value),R(s,!1)}else u.drawn&&(u.drawn=!1,t.removeAttribute(n),l({reason:"reference",element:s.name,name:n,ids:f.length>0?f:a}),R(s,!0))}}},L=(e,i,s,r=!0)=>{let t=e.dom;if(s!=null&&typeof s!="string")return l({reason:"value",element:e.name,name:i});let n=N(e.namespace,e.name,i,s??null,d);if("refused"in n){let m=N(e.namespace,e.name,i,null,d);return"refused"in m||t.removeAttribute(m.name),!("refused"in m)&&m.name==="role"&&b.delete(t),l(n.refused)}for(let m of n.dropped??[])l(m);let u=e.namespace==="html"&&re.has(n.name)&&$.has(e.name),a=t,f=u?n.name==="value"?a.value:n.name==="checked"?a.checked:a.selected:void 0;if(n.name==="role"&&b.delete(t),C.includes(n.name)){let m=A.get(e)??new Map;n.value===null?m.delete(n.name):m.set(n.name,{value:n.value,drawn:!0}),m.size>0?A.set(e,m):A.delete(e)}n.value===null?t.removeAttribute(n.name):t.setAttribute(n.name,n.value),r&&(n.name==="role"||z.includes(n.name))&&R(e,n.name==="role"),d.onAttribute?.(t,n.name),u&&(n.name==="value"&&"value"in a?(a.value=n.value??"",f!==a.value&&d.onFieldSet?.(t)):n.name==="checked"&&"checked"in a?(a.checked=n.value!==null,f!==a.checked&&d.onFieldSet?.(t)):n.name==="selected"&&"selected"in a&&(a.selected=n.value!==null,f!==a.selected&&d.onFieldSet?.(t.parentElement?.closest("select")??t)))},O=e=>{if(!e.refused){k-=1,e.id!==void 0&&g.delete(e.id);for(let i of e.children)O(i)}},M=(e,i)=>{if(!v(e)||typeof e.id!="string"||g.has(e.id))return l({reason:"record"}),y();if(k>=h)return l({reason:"budget"}),S||(S=!0,d.onOverBudget?.()),y();let s=e.id;if(e.type===te)return y();if(e.type===ne){if(x(i.namespace,i.name))return l({reason:"child",element:i.name}),y();let a=c.createTextNode(String(e.data??"").slice(0,D)),f={dom:a,children:[],text:!0,id:s,parent:i};return g.set(s,f),T.set(a,s),k+=1,f}if(e.type!==ee)return l({reason:"record"}),y();let r=String(e.element);if(x(i.namespace,i.name))return l({reason:"child",element:r}),y();let t=P(r,i.namespace);if("refused"in t)return l(t.refused),y();let n=c.createElementNS(t.namespace==="svg"?j:I,t.name);t.as&&n.setAttribute("data-graview-as",t.as),t.namespace==="html"&&t.name==="img"&&n.setAttribute("referrerpolicy","no-referrer"),t.namespace==="html"&&t.name==="a"&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer"),n.setAttribute("referrerpolicy","no-referrer"));let u={dom:n,name:t.name,namespace:t.namespace,children:[],id:s,parent:i};if(g.set(s,u),T.set(n,s),k+=1,v(e.attributes)){for(let[a,f]of Object.entries(e.attributes))L(u,a,f,!1);R(u,!0)}if(d.decorate?.(n,t.name,t.namespace),v(e.properties))for(let a of Object.keys(e.properties))l({reason:"attribute",element:t.name,name:a});if(v(e.eventListeners))for(let a of Object.keys(e.eventListeners))e.eventListeners[a]!=null&&l({reason:"attribute",element:t.name,name:`on${a}`});if(Array.isArray(e.children))for(let a of e.children){let f=M(a,u);u.children.push(f),n.appendChild(f.dom)}return u},V=e=>{if(!Array.isArray(e))return l({reason:"record"});let[i,s]=e,r=typeof s=="string"?g.get(s):void 0;if(!r)return l({reason:"record"});switch(i){case Y:{if(r.text)return l({reason:"record"});let t=Number(e[3]),n=Number.isInteger(t)&&t>=0&&t<=r.children.length?t:r.children.length,u=e[2],a=v(u)&&typeof u.id=="string"?w.get(u.id):void 0,f;a&&a.parent?.namespace===r.namespace&&!x(r.namespace,r.name)?(w.delete(u.id),a.parent=r,f=a):f=M(u,r),r.dom.insertBefore(f.dom,r.children[n]?.dom??null),r.children.splice(n,0,f),r.namespace==="html"&&r.name==="textarea"&&d.onFieldSet?.(r.dom);return}case Z:{let t=Number(e[2]),n=r.children[t];if(!n)return l({reason:"record"});r.children.splice(t,1),n.dom.parentNode?.removeChild(n.dom),n.id!==void 0&&!n.refused?w.set(n.id,n):O(n);return}case K:{if(!r.text)return l({reason:"record"});r.dom.data=String(e[2]??"").slice(0,D);let t=X(r,r.parent);t&&d.onFieldSet?.(t);return}case q:{if(r===E||r.text)return l({reason:"record"});let t=String(e[2]),n=e[4]??F;return n===Q?L(r,t,e[3]):l(n===F||n===U?{reason:"attribute",element:r.name,name:n===U?`on${t}`:t}:{reason:"record"})}default:return l({reason:"record"})}};return{apply(e,i){if(!Array.isArray(e))return l({reason:"record"}),!0;try{for(let s=0;s<e.length;s+=1){if(i&&s%32===0&&i())return!1;V(e[s])}return!0}finally{for(let s of w.values())O(s);w.clear(),J()}},get refused(){return p},get size(){return k},idOf:e=>T.get(e),elementOf(e){let i=g.get(e);return i&&!i.text&&i!==E?i.dom:void 0},dispose(){for(let e of E.children)O(e);for(E.children.length=0;o.firstChild;)o.removeChild(o.firstChild)}}}var oe=o=>typeof o=="string"&&/^#[A-Za-z_][A-Za-z0-9_.:-]{0,199}$/.test(o),B=["https:","mailto:","tel:"];function G(o){if(!(typeof o!="string"||o.length>2e3||/[\s<>"]/.test(o.trim())||o.trim()!==o))try{let d=new URL(o);return!B.includes(d.protocol)||d.protocol==="https:"&&(d.hostname===""||d.username!==""||d.password!=="")?void 0:d.href}catch{return}}function ce(o){let d=new Set,c=h=>{if(typeof h!="string"||!/^(https|mailto|tel):/i.test(h))return;let p=G(h);p&&d.add(p)};for(let h of[...o?.node?[o.node]:[],...o?.nodes??[]])for(let[p,g]of Object.entries(h))p==="id"||p==="kind"||(Array.isArray(g)?g.forEach(c):c(g));return d}function W(o){return(o??[]).flatMap(d=>{try{let c=new URL(d);return c.protocol==="https:"&&c.hostname!==""&&c.username===""&&c.password===""?[c.origin]:[]}catch{return[]}})}function ue(o,d){if(oe(o))return o;let c=G(o);if(c&&(d.handed.has(c)||c.startsWith("https:")&&W(d.origins).includes(new URL(c).origin)))return c}function fe(o,d){let c=o.length>120?`${o.slice(0,119)}\u2026`:o,h="";try{h=new URL(o).protocol}catch{h=""}if(!B.includes(h))return`The link "${c}" was not drawn: a view links only to an https:, mailto: or tel: address.`;let p=W(d);return`The link "${c}" was not drawn: it is no address this view was handed. A view links out only to an address a record it was shown holds (a url field), as the record holds it${p.length>0?`, or an https: address on ${p.join(", ")}`:""}; a record or a place of this app is <a data-record> or <a data-place>.`}export{de as a,ce as b,ue as c,fe as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as x}from"./chunk.WSO7JOW5.js";import"./chunk.XOE4KNP2.js";import"./chunk.V5I4GZEY.js";import"./chunk.WVUJXDXZ.js";import"./chunk.I2737CPF.js";import"./chunk.NJRLJEJY.js";import"./chunk.CVPMSPCH.js";import"./chunk.OTV5XTBB.js";import"./chunk.KBPJ7X7W.js";import"./chunk.OEIWIZCP.js";import"./chunk.MIE4TJRW.js";import{o as R}from"./chunk.5LJVOLKR.js";import"./chunk.OJGHDWI6.js";import"./chunk.OWFS2YDQ.js";import"./chunk.WSDJPXJD.js";import"./chunk.F4VB6Q2W.js";import"./chunk.FFOD5B4B.js";import"./chunk.Z7Y3R3YR.js";import"./chunk.YXEO3Y65.js";import"./chunk.U3HERHAI.js";import"./chunk.FBILPNGH.js";import{G as A,W as v,fa as g}from"./chunk.MODLZJD4.js";import"./chunk.SDO3U72B.js";import{ra as y,sd as k,wa as c}from"./chunk.6HY6ZGEE.js";import"./chunk.FQLNBIQ5.js";import{b as u}from"./chunk.AJZBJBMO.js";var f=u(A(),1);var L=u(A(),1),S=(0,L.createContext)(void 0);var i=u(v(),1),W=new WeakMap,m=new WeakMap,P=(e,n)=>`${n.kind}\0${n.id??""}\0${e}`;function b(e,n,a){let p=P(n,a),o=W.get(e);o||W.set(e,o=new Map);let t=o.get(p);return t||(t=Promise.resolve().then(()=>e(n,a)).then(r=>C(r)?r:null,()=>null).then(r=>{let s=m.get(e);return s||m.set(e,s=new Map),s.set(p,r),r}),o.set(p,t)),t}function C(e){if(e===null)return!0;if(typeof e!="object"||e===void 0)return!1;if(e.denied===!0)return!0;let n=e;return typeof n.name=="string"&&n.name.trim()!==""&&typeof n.href=="string"}function h(e){if(/^https?:\/\//i.test(e))try{return new URL(e).href}catch{return}}var N=e=>h(e)??(c(e)?e:void 0),E=e=>h(e)??(e.startsWith("/")&&c(e)?e:void 0),I={kind:"human"},w={color:"var(--graview-ink-muted)"};function M({icon:e}){if(!e)return null;let n=E(e);if(n)return(0,i.jsx)("img",{src:n,alt:"",width:20,height:20,"data-graview-app-icon":"",style:{width:20,height:20,borderRadius:5,objectFit:"cover",flex:"0 0 auto"}});let a=[...e.trim()].slice(0,2).join("");return a?(0,i.jsx)("span",{"aria-hidden":"true","data-graview-app-icon":"",style:{flex:"0 0 auto",lineHeight:"20px"},children:a}):null}function V(e){let n=g(),a=(0,f.useContext)(S)??n?.resolveApp,p=n?.principal??I,o=()=>a?m.get(a)?.get(P(e,p))??"asking":null,[t,r]=(0,f.useState)(o);return(0,f.useEffect)(()=>{let s=o();if(r(s),s!=="asking"||!a)return;let l=!0;return b(a,e,p).then(d=>l&&r(d)),()=>{l=!1}},[a,e,p.kind,p.id]),t}function D({address:e,as:n="chip",nodeId:a,field:p,style:o}){let t=V(e),r={position:"relative",zIndex:k.raised,overflowWrap:"anywhere",minWidth:0,maxWidth:"100%",...o},s;if(t==="asking")s=(0,i.jsx)("span",{"data-graview-app-link":"","data-graview-app-state":"asking","aria-busy":"true",style:{...w,...r},children:"Linked app"});else if(t&&"denied"in t)s=(0,i.jsx)("span",{"data-graview-app-link":"","data-graview-app-state":"denied",style:{...w,fontStyle:"italic",...r},children:"linked app (no access)"});else if(t){let l=N(t.href),d=n==="record"?t.headline?.trim():void 0;s=(0,i.jsxs)(l?"a":"span",{"data-graview-app-link":"","data-graview-app-state":"found",...l?{href:l}:{},...!d&&t.headline?{title:t.headline}:{},style:{display:"inline-flex",alignItems:d?"flex-start":"center",minHeight:24,gap:8,color:"inherit",textUnderlineOffset:3,...r},children:[(0,i.jsx)(M,{icon:t.icon}),(0,i.jsxs)("span",{style:{display:"grid",minWidth:0},children:[(0,i.jsx)("span",{"data-graview-app-name":"",style:{fontWeight:600},children:t.name}),d?(0,i.jsx)("span",{"data-graview-app-headline":"",style:{...w,fontSize:"0.8125em",fontWeight:400},children:d}):null]})]})}else{let l=h(e);s=l?(0,i.jsx)("a",{"data-graview-app-link":"","data-graview-app-state":"plain",href:l,rel:"noopener noreferrer",target:"_blank",style:{color:"var(--graview-accent)",display:"inline-flex",alignItems:"center",minHeight:24,...r},children:e}):(0,i.jsx)("span",{"data-graview-app-link":"","data-graview-app-state":"plain",style:r,children:e})}return a&&p?(0,i.jsx)(H,{nodeId:a,field:p,address:e,drawn:s}):s}function H({nodeId:e,field:n,address:a,drawn:p}){let o=R(e).fields.some(s=>s.field===n),t=g()?.store;if(!o)return p;let r=y(t?t.schema.tryDefinition(String(t.graph.getNode(e)?.kind)):void 0,n).toLowerCase();return(0,i.jsxs)("span",{style:{display:"inline-flex",flexWrap:"wrap",alignItems:"baseline",gap:"4px 12px",maxWidth:"100%",minWidth:0},children:[p,(0,i.jsx)("span",{style:{fontSize:"0.8125rem"},children:(0,i.jsx)(x,{nodeId:e,field:n,value:"Change",stored:a,said:`Change the ${r}`})})]})}var Y=e=>(0,i.jsx)(D,{...e});export{D as AppLink,Y as drawAppLink};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as A}from"./chunk.QDVGHI7R.js";import{a as x,c as T,d as w}from"./chunk.6P6NGZ6D.js";import{L as S,P as v,S as $}from"./chunk.6HY6ZGEE.js";function M(e,t,n){let r=e.schema.tryDefinition(t)?.fields?.shape?.[n];return r===void 0?void 0:A(r)}function I(e,t){if(e===void 0)return[];if(!Array.isArray(e))return[`The view's accepts is a list of { "kind": <a kind>, "field": <its image, video or file field> }.`];let n=[],i=new Set(t.schema.kinds);for(let r of e){let{kind:c,field:o}=r??{};typeof c!="string"||typeof o!="string"?n.push(`Each of the view's accepts is { "kind": <a kind>, "field": <its image, video or file field> }.`):i.has(c)?M(t,c,o)?t.allMutations().some(a=>(a.creates??[]).includes(c)&&Object.hasOwn(a.input?.shape??{},o))||n.push(`No act of this app makes a "${c}" with its "${o}", so a file dropped could become nothing.`):n.push(`The view accepts files into ${c}'s "${o}", which holds no picture, video or file.`):n.push(`The view accepts files for "${c}", which is no kind of this app.`)}return n}function E(e,t,n){if(e===void 0||e===!0)return[];let i=`The view's pictures is true; the kinds whose pictures it draws, ["circuit"]; or { "width": <the widest it draws a picture, in pixels> } with the fields it draws them from, by kind, { "circuit": "photo" }.`;if(typeof e!="object"||e===null)return[i];let r=new Set([...n.attach==="home"?[]:[n.attach],...n.reads?.kinds??[]]),c=new Set(t.schema.kinds),o=[],a=d=>{if(!c.has(d))return void o.push(`The view's pictures chooses "${d}", which is no kind of this app.`);r.has(d)||o.push(`The view's pictures chooses "${d}", whose records it is not handed: add "${d}" to its reads.kinds.`)};if(Array.isArray(e)){if(e.length===0||!e.every(d=>typeof d=="string"))return[i];for(let d of e)a(d);return o}for(let[d,l]of Object.entries(e)){if(d==="width"&&typeof l!="string"&&!Array.isArray(l)){Number.isInteger(l)&&l>=16&&l<=4096||o.push("The view's pictures width is a whole number of pixels from 16 to 4096.");continue}let f=typeof l=="string"?[l]:Array.isArray(l)&&l.length>0&&l.every(u=>typeof u=="string")?l:void 0;if(!f){o.push(`The view's pictures says "${d}": beside "width", it names a kind and the field it draws pictures from, "circuit": "photo", or its fields, "circuit": ["photo", "map"].`);continue}let y=o.length;if(a(d),!(o.length>y))for(let u of f){let p=M(t,d,u);p?p.as==="video"&&o.push(`The view's pictures chooses ${d}'s "${u}", which holds videos: the host plays a video where the view places it, and hands no picture of it.`):o.push(`The view's pictures chooses ${d}'s "${u}", which holds no picture.`)}}return o}function F(e){if(e===void 0)return[];if(typeof e!="object"||e===null||Array.isArray(e))return[`The view's scene is { "maxHeight": <the tallest its preview on the Scene is drawn, in pixels> }.`];let{maxHeight:t,...n}=e,i=[];return Object.keys(n).length>0&&i.push(`The view's scene says ${Object.keys(n).map(r=>`"${r}"`).join(", ")}: only "maxHeight" is read.`),t!==void 0&&!(Number.isInteger(t)&&t>=80&&t<=4e3)&&i.push("The view's scene maxHeight is a whole number of pixels from 80 to 4000."),i}function j(e){return(e.acts??[]).map(t=>typeof t=="string"?{act:t}:t)}function C(e,t){let n=[],i=new Set(t.schema.kinds),r=new Set(t.schema.edgeKinds),c=new Set(t.allMutations().map(a=>a.name));(typeof e.name!="string"||!/^[a-z0-9][a-z0-9-]{0,62}$/.test(e.name))&&n.push(`The view's name "${String(e.name)}" is not lower-case letters, digits and hyphens.`),e.title!==void 0&&(typeof e.title!="string"||e.title.trim()===""||e.title.length>80)&&n.push("The view's title is empty or longer than 80 characters."),e.attach!=="home"&&!i.has(e.attach)&&n.push(`The view attaches to "${e.attach}", which is no kind of this app.`),e.cardinality!=="one"&&e.cardinality!=="many"&&n.push(`The view's cardinality is "${String(e.cardinality)}", not one or many.`),e.attach==="home"&&e.cardinality!=="many"&&n.push("A view of the home draws many records: its cardinality is many."),e.replaces!==void 0&&e.replaces!=="page"?n.push(`The view's replaces is "${String(e.replaces)}": the one thing a view replaces is "page", or leave it out to draw the view above the record's own fields.`):e.replaces==="page"&&e.attach==="home"&&n.push(`The home's view is the home already: replaces "page" is for a view of a kind, of one record (its page) or of many (its list).`),e.gestures!==void 0&&typeof e.gestures!="boolean"&&n.push(`The view's gestures is "${String(e.gestures)}": it is true, or left out.`),e.bleed!==void 0&&typeof e.bleed!="boolean"&&n.push(`The view's bleed is "${String(e.bleed)}": it is true, or left out.`),e.heading!==void 0&&(e.heading!=="own"||e.attach==="home"||e.cardinality!=="many"||e.title===void 0)&&n.push(`The view's heading is "${String(e.heading)}": it is "own" on a view that is a place (a title, cardinality many), or left out.`),e.flows!==void 0&&typeof e.flows!="boolean"?n.push(`The view's flows is "${String(e.flows)}": it is false for a view that keeps its place's frame, or left out.`):e.flows===!1&&(e.attach==="home"||e.cardinality!=="many"||e.title===void 0)&&n.push("Only a view that is a place keeps a frame: flows false needs a title and cardinality many on a kind."),n.push(...F(e.scene)),e.scene!==void 0&&(e.attach==="home"||e.cardinality!=="many")&&n.push("Only a view of a kind's members is drawn on the Scene as a card: scene needs cardinality many on a kind."),n.push(...E(e.pictures,t,e)),n.push(...I(e.accepts,t));for(let a of e.reads?.kinds??[])i.has(a)||n.push(`The view reads "${a}", which is no kind of this app.`);for(let a of e.reads?.edges??[])r.has(a)||n.push(`The view reads the edge "${a}", which no kind of this app declares.`);let o=new Set;for(let a of j(e)){c.has(a.act)||n.push(`The view asks for the act "${a.act}", which this app does not declare.`);let d=a.as??a.act;o.has(d)&&n.push(`Two of the view's acts are called "${d}".`),o.add(d)}return n}function H(e,t,n){let i=[...new Set([...t.attach==="home"?[]:[t.attach],...t.reads?.kinds??[]])];if(i.length<2)return[];let r=new Set(t.reads?.edges??[]),c=o=>new RegExp(`(["'\`])${o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\1`).test(n);return e.schema.edgeKinds.filter(o=>{let a=e.schema.edge(o);return!r.has(o)&&a!==void 0&&a.from.some(d=>i.includes(d))&&(a.to==="*"||a.to.some(d=>i.includes(d)))&&c(o)})}function z(e,t,n){let i=H(e,t,n);if(i.length===0)return;let r=(c,o)=>c.length<2?c[0]??"":`${c.slice(0,-1).join(", ")} ${o} ${c[c.length-1]}`;return`"${t.name}" names ${r(i,"and")} but does not read ${i.length>1?"them":"it"}, so the view is handed no such links: add ${r(i.map(c=>`"${c}"`),"and")} to its manifest's reads.edges.`}function D(e,t){return[...t.attach==="home"?[]:[t.attach],...t.reads?.kinds??[]].some(i=>Object.keys(e.schema.tryDefinition(i)?.computed??{}).length>0)}function Z(e,t,n){let{manifest:i}=n,r=n.input??{},o=e.seenBy(t).graph,a=i.attach==="home"?void 0:i.attach,d=a&&i.cardinality==="one"&&r.node?o.getNode(r.node.id):void 0,l=d&&d.kind===a?[d]:[],f=a&&i.cardinality==="many"?r.nodes?r.nodes.flatMap(s=>{let h=o.getNode(s.id);return h&&h.kind===a?[h]:[]}):o.nodesOfKind(a):[],y=new Set([...l,...f].map(s=>s.id)),u=x(o,y,{kinds:(i.reads?.kinds??[]).filter(s=>s!==a||i.cardinality==="one"),edges:i.reads?.edges??[]}),p=new Map;for(let s of[...f,...u.nodes])l.some(h=>h.id===s.id)||p.set(s.id,s);let P=new Set([...l.map(s=>s.id),...p.keys()]),G=[...u.edges],O=new Set(j(i).map(s=>s.act)),V=e.permittedMutations(t).filter(s=>O.has(s.name)).map(s=>({name:s.name,title:s.title??s.name,...s.description!==void 0?{description:s.description}:{},...s.subject?{subject:{kinds:s.subject.kinds,arg:s.subject.arg}}:{}})),m=s=>s?.filter(h=>P.has(h)),k=n.computed,b=s=>k?{...w(e,s),...k(o,s)}:w(e,s);return{view:i.name,...l[0]?{node:b(l[0])}:{},nodes:[...p.values()].map(b),edges:G,...i.title!==void 0?{label:i.title}:r.label!==void 0?{label:r.label}:{},cardinality:i.cardinality,...r.fidelity!==void 0?{fidelity:r.fidelity}:{},...r.mode!==void 0?{mode:r.mode}:{},...r.selected!==void 0?{selected:r.selected}:{},...r.implicated?{implicated:m(r.implicated)}:{},...r.flagged?{flagged:m(r.flagged)}:{},acts:V,...n.theme?{theme:n.theme}:{},locale:v(),timeZone:$(),today:e.today()??S(),...T(e.schema,[...l,...p.values()]),...n.places?{places:n.places.filter((s,h,g)=>g.findIndex(W=>W.as===s.as)===h).map(({as:s,title:h,kind:g})=>({as:s,title:h,kind:g}))}:{}}}export{M as a,j as b,C as c,H as d,z as e,D as f,Z as g};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{g as A}from"./chunk.FK722SHI.js";import{t as H}from"./chunk.U3HERHAI.js";import{G as v,J as S,La as D,W as s,ea as k,ga as T}from"./chunk.MODLZJD4.js";import{a as B}from"./chunk.SDO3U72B.js";import{Ce as I,pe as L,td as R}from"./chunk.6HY6ZGEE.js";import{b as i}from"./chunk.AJZBJBMO.js";var O=i(v(),1);var P=i(s(),1),M=H.part((e,o)=>(0,P.jsx)(e.Inbox,{...o}),{quiet:!0});function N(e){let{store:o,whileAway:r,notifications:t,aiDesk:l}=k(),n=T(),d=A(),{entries:c}=S(l),p=(0,O.useMemo)(()=>o.log.all().some(f=>f.suggests!==void 0&&!f.withheld),[o,n]);return e>0||d>0||p||(r?.tidied??0)>0||(t?.length??0)>0||c.length>0}function j(e){return(0,P.jsx)(M,{...e})}var h=i(s(),1),F=e=>e.tabIndex>=0&&!e.disabled&&e.getClientRects().length>0;function V(e){if(!e)return!1;if(F(e))return e.focus({preventScroll:!1}),!0;let o=[...e.querySelectorAll("a[href], button, input, select, textarea, [tabindex]")].find(F);return o?(o.focus(),!0):(e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1"),e.focus(),!0)}var G=`.graview-skips{display:contents}
|
|
2
|
+
.graview-skip{position:absolute;width:0;height:0;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}
|
|
3
|
+
.graview-skip:focus{width:auto;height:auto;overflow:visible;clip-path:none;padding:6px 12px;border-radius:8px;border:1px solid var(--graview-accent);background:var(--graview-float,var(--graview-panel));color:var(--graview-ink);font:inherit;font-size:.875rem;font-weight:600;box-shadow:var(--graview-lift-high);outline:2px solid var(--graview-accent);outline-offset:1px}
|
|
4
|
+
.graview-skips[data-place=bar] .graview-skip:focus{position:fixed;left:8px;top:6px;z-index:${R("toast")}}
|
|
5
|
+
.graview-skips[data-place=here] .graview-skip:focus{position:static;justify-self:start}`;function _({to:e,place:o="bar"}){return e.length===0?null:(0,h.jsxs)("span",{className:"graview-skips","data-place":o,children:[(0,h.jsx)("style",{children:G}),e.map(r=>(0,h.jsx)("button",{type:"button",className:"graview-skip","data-graview-skip":r.testid,"data-testid":`skip-${r.testid}`,...r.opens?{"data-graview-skip-opens":""}:{},onClick:r.go,children:r.label},r.testid))]})}var m=i(v(),1),w=i(s(),1),K=D(B(()=>(__graviewPreload(import.meta.url,["./chunk.IAEHUSQQ.js","./chunk.7VADSNPZ.js","./chunk.FK722SHI.js","./chunk.U5P23GO7.js","./chunk.6EHHMWPP.js","./chunk.TXHYGFIZ.js","./chunk.WAB3L3ZI.js","./chunk.W53YNBSM.js","./chunk.2KFZHUAC.js","./chunk.V5I4GZEY.js","./chunk.PSQYDCVM.js","./chunk.QOS5T46W.js","./chunk.MIE4TJRW.js","./chunk.5LJVOLKR.js","./chunk.OJGHDWI6.js","./chunk.OWFS2YDQ.js","./chunk.WSDJPXJD.js","./chunk.F4VB6Q2W.js","./chunk.FFOD5B4B.js","./chunk.Z7Y3R3YR.js","./chunk.YXEO3Y65.js","./chunk.U3HERHAI.js","./chunk.FBILPNGH.js","./chunk.MODLZJD4.js","./chunk.SDO3U72B.js","./chunk.6HY6ZGEE.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.L25DCT5S.js")))),W=K.part((e,o)=>{let r=e.RecordInteractions;return(0,w.jsx)(r,{...o})},{quiet:!0});function $(e,o,r){let t=e.target;return(t.on==="record"||t.on==="field"?t.id===o:t.on==="selection"?t.ids.includes(o):t.on==="act"?t.id===o:!1)||e.offered.some(n=>n.id===`record:${o}`||n.id.startsWith(`fill:${o}:`))||(e.batches??[]).some(n=>r(n).includes(o))}function q({id:e,style:o,headingStyle:r,className:t}){let{ai:l,aiDesk:n,store:d}=k(),{entries:c}=S(n),p=l.off===!0;(0,m.useEffect)(()=>{p||n.load()},[n,p]);let f=d.log.length,g=(0,m.useMemo)(()=>{let b=x=>d.log.all().flatMap(C=>C.batch===x?C.writes:[]);return c.filter(x=>$(x,e,b))},[c,e,d,f]);return p||g.length===0?null:(0,w.jsx)(m.Suspense,{fallback:null,children:(0,w.jsx)(W,{entries:g,...o?{style:o}:{},...r?{headingStyle:r}:{},...t?{className:t}:{}})})}var u=i(v(),1);var y=i(s(),1),Q={textDecorationLine:"underline",textDecorationColor:"color-mix(in srgb, currentColor 50%, transparent)",textDecorationThickness:1,textUnderlineOffset:"0.2em"};function E({children:e,mark:o="\u2192"}){return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("span",{style:Q,children:e}),(0,y.jsx)("span",{"aria-hidden":"true",children:o})]})}var a=i(s(),1);function Er({context:e,stop:o,title:r,label:t,style:l,className:n,children:d,...c}){let p=L(e.views?.arrangement?.()),f=d??(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(E,{mark:"\u2197",children:["In ",p==="Scene"?"the scene":p.replace(/^The /,"the ")]})}),g=t?{"aria-label":t}:{};if(e.overview){let b=e.overview;return(0,a.jsx)("a",{href:o,...c,...g,...r?{title:r}:{},style:l,...n?{className:n}:{},onClick:x=>{x.preventDefault(),b(o)},children:f})}return e.embedded?null:(0,a.jsx)("a",{href:`${e.sceneHref??"/"}${o}`,...c,...g,...r?{title:r}:{},style:l,...n?{className:n}:{},children:f})}function Mr(){return(0,a.jsx)("a",{href:"#fresh","data-testid":"start-fresh",title:"Forget every edit made in this browser and return to the example",onClick:e=>{e.preventDefault(),window.location.assign(I(window.location.href))},style:{color:"inherit",display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24},children:"Start fresh"})}function Nr(e){let o=(0,u.useRef)(0),r=(0,u.useCallback)(t=>e.subscribe(()=>{o.current+=1,t()}),[e]);return(0,u.useSyncExternalStore)(r,()=>o.current,()=>0)}function Vr(e){return e===void 0?{}:e==="sm"||e==="md"?{"data-size":e}:{style:{"--graview-control-height":typeof e=="number"?`${e}px`:e}}}var Gr=(e,o)=>o?`${e} ${o}`:e;export{N as a,j as b,V as c,_ as d,q as e,E as f,Er as g,Mr as h,Nr as i,Vr as j,Gr as k};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as kn,c as bn,d as oe,e as wn,f as Y,h as Ee,i as je,n as vn,s as se,u as On}from"./chunk.YMXWS4XN.js";import{B as be,C as ue,Da as Oe,F as _e,Ga as en,H as He,Ja as nn,K as Ue,L as We,La as tn,Mb as U,Pa as xe,Qa as Re,Rb as cn,Sb as ln,Tc as mn,Ub as fn,Wa as rn,Za as on,Zb as pn,b as Fe,c as Ne,cc as un,d as Ce,e as K,ed as gn,fd as yn,g as ye,ga as Je,gd as Ae,h as Z,ha as Ye,hd as hn,i as Ie,id as ze,j as Ve,ja as Qe,jb as an,k as he,l as Ke,m as Ze,mb as sn,o as qe,p as fe,q as ve,rb as Se,sa as Xe,sb as dn,v as Be,x as pe,z as ke}from"./chunk.IQGSEAQ2.js";var Tn=[{where:"settings[]",was:"honoured",now:"honored",since:"0.1.16"},{where:"pages",was:"overview",now:"scene",since:"0.1.17"}],q=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function xn(e,d=Tn){if(!q(e))return{document:e,respelled:[]};let n=[],t=e;for(let a of d)t=De(t,a.where.split("."),a,"",n);return{document:t,respelled:n}}function De(e,d,n,t,a){if(d.length===0){if(!q(e)||!Object.hasOwn(e,n.was))return e;a.push(`${t}${n.was}`);let{[n.was]:ie,...B}=e;return Object.hasOwn(e,n.now)?B:{...B,[n.now]:ie}}if(!q(e))return e;let[f,...E]=d,k=f.endsWith("[]"),O=k?f.slice(0,-2):f,G=e[O],X=G;if(!k)X=De(G,E,n,`${t}${O}.`,a);else if(Array.isArray(G)){let ie=G.map((B,T)=>De(B,E,n,`${t}${O}.${T}.`,a));X=ie.some((B,T)=>B!==G[T])?ie:G}return X===G?e:{...e,[O]:X}}var Rn=new WeakMap;function Sn(e,d){Rn.set(e,d)}function Zn(e){return Rn.get(e)}function An(e){if(typeof e=="string")return{form:"string",light:e};if(typeof e!="object"||e===null)return;let d=e,n=k=>typeof d[k]=="string"?d[k]:void 0,t=n("light")??n("src");if(t===void 0)return;let[a,f,E]=[n("dark"),n("alt"),n("darkFallback")];return{form:n("light")!==void 0?"light":"src",light:t,...a!==void 0?{dark:a}:{},...f!==void 0?{alt:f}:{},...E!==void 0?{darkFallback:E}:{}}}function Qn(e,d){let n=e.brand??{},t=n.ground,a=n.accent?ze(n.accent,t):void 0;t&&hn(a?.ok?a.schemes:Ae(t),n.accent)&&(d.push(je("brand","brand.ground","words would not read on that page background, so the app keeps Graview's","pick a lighter ground for the light scheme, a darker one for the dark")),t=void 0,a=n.accent?ze(n.accent):void 0),a&&!a.ok&&d.push(je("brand","brand.accent",`that accent cannot make a readable brand, so the app keeps Graview's colors: ${a.why}`,"pick a color further from orange-red, or a darker one"));let f=An(n.logo),E=n.name??e.name,k=n.typography?Object.fromEntries(Object.entries(n.typography).filter(([,O])=>typeof O=="string"&&yn(O)===null).map(([O,G])=>[O,gn(G)])):void 0;return{name:E,schemes:a?.ok?a.schemes:t?Ae(t):mn,...n.currency?{currency:n.currency}:{},...n.locale?{locale:n.locale}:{},...n.timeZone?{timeZone:n.timeZone}:{},...f?{logo:f.dark||f.darkFallback==="invert"?{light:f.light,...f.dark?{dark:f.dark}:{darkFallback:"invert"}}:f.light,logoAlt:f.alt??E}:{},...n.favicon?{favicon:n.favicon}:{},...e.description?{subtitle:e.description}:{},...n.subtitle===!1?{subtitleDrawn:!1}:{},...k?{typography:k}:{},...n.shape?{shape:n.shape}:{},...n.accents?{accents:n.accents}:{},...n.scheme?{scheme:n.scheme}:{},...n.views&&(n.views.css||n.views.motion)?{views:{...n.views.css?{css:n.views.css}:{},...n.views.motion?{motion:n.views.motion}:{}}}:{}}}function zn(e){let{currency:d,locale:n,timeZone:t}=e.brand??{};return{...d?{currency:d}:{},...n?{locale:n}:{},...t?{timeZone:t}:{}}}var Gn=Symbol.for("@graview/core:typed-field"),En=(e,d)=>(/^(phone|place|duration)$/.test(d)&&(ue(e)[Gn]=d),e),jn=/^(?=(?:\D*\d){3})\+?[\d ()./-]+(?: *(?:ext\.?|x|#) *\d+)?$/i;function Dn(e){let d=Z().check(K(300),ke(t=>nn(t,e)!==void 0,`a record of ${e.kinds.join(" or ")} in ${e.address}, as "<kind>:<id>"`)),n=e.cardinality==="one"?d:fe(d).check(K(200));return tn(e.description?n.check(be(e.description)):n,e)}var Ln="graview-compiled@1";function Fn(e,d){return e.find(([n,t])=>n!==Q&&"ref"in t&&(t.ref==="*"||t.ref.includes(d)))?.[0]}var Q="id",me=e=>typeof e=="string"&&/^\$[A-Za-z][A-Za-z0-9]*$/.test(e)?e.slice(1):void 0;function $n(e){let d=Object.entries(e.fields),n=t=>["name","title","label"].find(a=>t.some(([f])=>f===a))??t[0]?.[0];return n(d.filter(([,t])=>t.required&&(t.type==="string"||t.type==="text")))??n(d.filter(([,t])=>t.type==="string"))}function Pn(e,d,n){let t;switch(e.type){case"string":case"place":t=Z().check(K(500));break;case"phone":t=Z().check(K(40),ye(jn,"a phone number"));break;case"text":t=Z().check(K(2e4)),e.format&&(ue(t)[Symbol.for("@graview/core:markdown")]=1);break;case"number":case"integer":case"duration":{let f=e.min??(e.type==="duration"?0:void 0),E=[...e.type==="number"?[]:[Ke()],...f===void 0?[]:[Ne(f)],...e.max===void 0?[]:[Fe(e.max)],...e.step===void 0?[]:[Ce(e.step)]];t=E.length>0?he().check(...E):he();break}case"boolean":t=Ze();break;case"date":t=Z().check(ye(He,"a date like 2026-10-02, or a month (2016-05) or a year (2006) alone"));break;case"datetime":t=Z().check(ke(Ue,"a date and time like 2026-10-02T14:30:00Z"));break;case"enum":t=Be(e.options),e.multiple&&(t=fe(t).check(K(e.options.length)));break;case"list":t=fe(e.of==="number"?he():e.of==="date"?Z().check(ye(_e)):e.of==="image"||e.of==="video"||e.of==="file"?Oe(e.of):Z().check(K(500))).check(K(200));break;case"image":case"video":case"file":t=Oe(e.type);break;case"app-link":t=en();break;case"url":t=Ve();break;case"email":t=Ie();break}let a=e.type==="number"||e.type==="integer";return En(t,a&&e.format==="duration"?"duration":e.type),e.collaborative!==void 0&&(e.type==="text"||e.type==="string")&&(ue(t)[Symbol.for("@graview/core:collaborative")]=e.collaborative?1:0),e.description&&(t=t.check(be(e.description))),a&&(e.format==="money"||e.format==="percent"||!e.format&&e.unit)&&pn(t,{...n,...e.format?{format:e.format}:{},...e.unit?{unit:e.unit}:{},...e.places===0?{places:0}:{}}),d?pe(t):t}var ge=e=>{throw new U(`there is no record "${e}"`,"invalid")},Nn=(e,d)=>"field"in e?Pn(e.field,e.optional,d):"ref"in e?un(e.ref):pe(qe()),Cn=new WeakMap;var Le=(e,d)=>q(d)&&Object.keys(e??{}).length===Object.keys(d).length&&Object.keys(e??{}).every(n=>Object.hasOwn(d,n));function xt(e,d={}){let n=q(e)?e.format:void 0;if(n!==Ln)return{ok:!1,findings:[Ee("compiled-format","format",n===void 0?"this is not a compiled Graview app":`this compiled app is ${JSON.stringify(n)}, and this build reads ${Ln}`,"compile the document instead")]};let t=e,a=xn(t.document).document,f=a===t.document?t:{...t,document:a},E=q(a)&&typeof a.name=="string"&&q(a.kinds)&&Le(a.kinds,f.kinds)&&Le(a.acts,f.acts)&&Le(a.rules,f.rules)&&Array.isArray(f.edges)&&Array.isArray(f.findings),k={ok:!1,findings:[Ee("compiled-shape","","this compiled app's parts do not match its document","compile the document instead")]};if(!E)return k;try{return In(f,d)}catch{return k}}function In(e,d={}){let{document:n}=e,t=n.brand?.timeZone,a=d.today??(()=>We(t)),f={...n.brand?.locale?{locale:n.brand.locale}:{},...t?{timeZone:t}:{}},E=new Map(e.edges.map(([p,i])=>[p,i])),k=new Map;for(let[p,i]of Object.entries(n.kinds)){let x=e.kinds[p]?.computed,w=Re(i.edges),j=new Map(Object.entries(i.fields).flatMap(([S,v])=>v.type==="enum"?[[S,v.optionLabels??{}]]:[]));k.set(p,{fields:new Set([...Object.keys(i.fields),...w.keys()]),edges:new Map(Object.entries(xe(i.edges)).map(([S,v])=>[S,v.cardinality??"many"])),...x?{computed:new Map(x)}:{},...w.size>0?{linked:w}:{},...j.size>0?{choices:j}:{}})}e.facts&&k.set(bn,{computed:new Map(e.facts)});let O=zn(n),G=p=>({from:p.from,via:p.via,sourceEnd:p.sourceEnd,back:p.back,values(i,x,w){let j={};for(let[S,v]of p.set)if("value"in v)j[S]=v.value;else try{let $=Y(v.expr,{graph:i,subject:x,kinds:k,bindings:{to:w},today:a(),...f});($===null||typeof $!="object"||Array.isArray($))&&(j[S]=$)}catch($){if(!($ instanceof oe))throw $}return j}}),X=new Map,ie=Object.entries(n.kinds).map(([p,i])=>{let x={};for(let[r,o]of Object.entries(i.fields))x[r]=Pn(o,!o.required,O),o.repeats&&(x[rn(r)]=pe(on()));for(let[r,o]of Re(i.edges))x[r]=pe(Dn(o));let{label:w,describe:j,durations:S}=e.kinds[p]??{},v=Object.entries(i.computed??{}).map(([r,o])=>[r,typeof o=="string"?{expr:o}:o]),$=Object.hasOwn(i.fields,"label")&&!i.fields.label.label&&!/\{\s*label\b/.test(i.label??`{${$n(i)??""}}`),ee=Object.fromEntries([...$?[["label","Label"]]:[],...Object.entries(i.fields).filter(([,r])=>r.label).map(([r,o])=>[r,o.label]),...v.filter(([,r])=>r.label).map(([r,o])=>[r,o.label])]),W=Object.keys(ee).length>0,L=Object.entries(i.fields).filter(([,r])=>r.type==="enum"&&(r.optionLabels&&Object.keys(r.optionLabels).length>0||r.multiple)),l=r=>o=>typeof o=="string"&&r.optionLabels&&Object.hasOwn(r.optionLabels,o)?r.optionLabels[o]:Ye(String(o)),M=Object.fromEntries(L.map(([r,o])=>[r,o.multiple?z=>Array.isArray(z)?z.map(l(o)).join(", "):l(o)(z):l(o)])),N=L.length>0,C=Object.fromEntries(Object.entries(i.fields).filter(([,r])=>r.default!==void 0).map(([r,o])=>[r,o.default]));X.set(p,C);let _=Object.fromEntries(Object.entries(xe(i.edges)).map(([r,{renamedFrom:o,...z}])=>[r,z])),I=Object.entries(i.fields).flatMap(([r,o])=>o.aliases?[[r,o.aliases]]:[]),P=r=>i[r]?{[r]:i[r]}:{};return Qe(p,{fields:ve(x),edges:_,...P("plural"),...P("noun"),...P("aliases"),...I.length>0?{fieldAliases:Object.fromEntries(I)}:{},...P("description"),...w?{label:r=>se(w,{node:r,kinds:k,today:a(),money:O})||r.id}:{},...j?{describe:r=>se(j,{node:r,kinds:k,today:a(),money:O})}:{},...P("lifecycle"),...P("figure"),...P("fieldRoles"),...P("people"),archives:i.archives,...i.tidying?{tidying:i.tidying}:{},...v.length>0?{computed:Object.fromEntries(v.map(([r,o])=>[r,Vn(o,S?.includes(r)??!1,O)??i.computed[r]]))}:{},...W||N||i.glance||i.page?{display:{...W?{labels:ee}:{},...N?{format:M}:{},...i.glance?{glance:[...i.glance]}:{},...i.page?{page:i.page}:{}}}:{},...Object.keys(C).length>0?{defaults:C}:{},...e.kinds[p]?.keptInStep?{keptInStep:e.kinds[p].keptInStep}:{},...e.kinds[p]?.derives?{derives:G(e.kinds[p].derives)}:{}})}),B=an(ie,n.computed);function T(p){return B.tryDefinition(p.kind)?.label?.(p)??p.id}let $e=p=>({id:"",kind:p,...X.get(p)}),Pe=[];for(let[p,i]of Object.entries(n.acts??{})){let x=e.acts[p],{title:w,effects:j,guard:S,refusal:v,destructive:$,idempotent:ee,creates:W,connects:L,severs:l,writes:M,writesOther:N,sets:C}=x,_={};for(let c of j)"through"in c&&(_[c.through]=[...new Set([..._[c.through]??[],...Object.keys(c.set)])]);let I=new Map(x.args),P={};for(let[c,A]of I)P[c]=Nn(A,O);let r=[i.on??[]].flat(),o=new Map(x.exprs),z=j.find(c=>"create"in c),J=(c,A,u,b=null)=>{if(q(c)&&"expr"in c)return Y(o.get(c.expr),{graph:u,subject:b,kinds:k,bindings:A,today:a(),...f});let h=me(c);return h===void 0?typeof c=="string"&&c.startsWith("$$")?c.slice(1):c:h==="now"?new Date().toISOString():h==="today"?a():A[h]},de=(c,A)=>{if(!z)return"";let u=n.kinds[z.create].fields,b=$e(z.create),h=[];for(let[R,ce]of Object.entries(z.set??{})){try{b[R]=J(ce,c,A)??b[R]}catch{}let ae=me(ce);ae&&c[ae]!==void 0&&h.push(R)}let V=T(b).trim(),ne=h.filter(R=>b[R]!==!1&&u[R].type!=="text"&&!(/[^]{41}/.test(b[R])||/ .*[.!?]$/.test(b[R])&&!/[ .][A-Z]\w{0,3}\.$/.test(b[R]))&&T({...b,[R]:void 0}).trim()===V).map(R=>b[R]===!0?u[R].label??Je(R):vn(b[R],u[R].format,a(),[],O));return V&&ne.length>0?`${V} (${ne.join(", ")})`:V};Pe.push(fn(p,{input:ve(P),title:w,...i.description?{description:i.description}:{},...i.fromTheOtherEnd?{fromTheOtherEnd:i.fromTheOtherEnd}:{},...I.has(Q)?{subject:{kinds:r.length>0?r:"*",arg:Q}}:{},...$?{destructive:!0}:{},...ee?{idempotent:!0}:{},...W.length>0?{creates:W}:{},...L.length>0?{connects:L}:{},...l.length>0?{severs:l}:{},writes:M,...Object.keys(N).length>0?{writesOther:N}:{},...Object.keys(_).length>0?{writesLinked:_}:{},...Object.keys(C).length>0?{sets:C}:{},...S?{allowedOn:(c,A)=>{let u=c.getNode(A);if(!u||r.length>0&&!r.includes(u.kind))return!1;try{return Y(S,{graph:c,subject:u,kinds:k,bindings:{},today:a(),...f})===!0}catch{return!1}}}:{},describe:(c,A)=>{let u=typeof c[Q]=="string"?A.getNode(c[Q]):void 0,b=u?T(u):de(c,A);return b?`${w}: ${b}`:w},apply(c,A){let u=c.graph,b=typeof A[Q]=="string"?A[Q]:void 0,h=b?u.getNode(b):void 0;if(b&&!h&&ge(b),h&&r.length>0&&!r.includes(h.kind))throw new U(`"${w}" acts on ${r.join(" or ")}, not on ${Xe(h.kind)}`,"invalid");let V={};for(let[s,m]of Object.entries(A))m!==void 0&&(V[s]=m);if(S&&h){let s;try{s=Y(S,{graph:u,subject:h,kinds:k,bindings:V,today:a(),...f})}catch(m){throw m instanceof oe?new U(`"${w}" could not be judged: ${m.sentence}`):m}if(s!==!0)throw new U(v?se(v,{node:h,kinds:k,graph:u,bindings:V,today:a(),money:O}):`"${w}" is not allowed for ${T(h)} right now`)}let ne=new Map,R=s=>u.has(s)||[...ne.values()].includes(s),ce=new Set,ae=s=>{let m=sn(s);ce.has(m)||(ce.add(m),c.removeEdge(s))},te=(s,m)=>{let g=me(s);if(g==="subject")return b;if(g==="me"){let y=c.me;if(y&&n.kinds[u.getNode(y)?.kind]?.people)return y;throw new U(`"${w}" is done as you, and you have no record here`)}if(ne.has(g))return ne.get(g);try{return J(s,V,u,m??h??null)}catch(y){throw y instanceof oe?new U(`"${w}" could not work out a value: ${y.sentence}`):y}};for(let s of j)if("create"in s){let m=n.kinds[s.create],g=$e(s.create);for(let[H,re]of Object.entries(s.set??{})){let Me=te(re,void 0);Me!==void 0&&(g[H]=Me)}let y=$n(m),D=String((y&&g[y])??s.create),le=ln(D,s.create,g,(H,re)=>cn(n.policy?.sees,H,re)),F=c.freshId(le?s.create:D,s.create,g);c.addNode({...g,id:F}),s.as&&ne.set(s.as,F)}else if("connect"in s||"sever"in s){let m="connect"in s?s.connect:s.sever,g=String(te(s.from,void 0)??""),y=String(te(s.to,void 0)??"");if(R(g)||ge(g),R(y)||ge(y),"connect"in s){if(E.get(m)?.cardinality==="one")for(let D of u.out(g,m))D.id!==y&&ae({kind:m,from:g,to:D.id});u.out(g,m).some(D=>D.id===y)||c.addEdge({kind:m,from:g,to:y})}else ae({kind:m,from:g,to:y})}else if("through"in s){if(!h)throw new U(`"${w}" carries a change to linked records, and has no record to start from`,"invalid");let g=E.get(s.through)?.from.includes(h.kind)??!0?u.out(h.id,s.through):u.in(h.id,s.through);for(let y of g){let D={};for(let[le,F]of Object.entries(s.set)){let H;if(me(F)==="to")H=y.id;else if(q(F)&&"expr"in F)try{H=Y(o.get(F.expr),{graph:u,subject:h,kinds:k,bindings:{...V,to:y},today:a(),...f})}catch(re){throw re instanceof oe?new U(`"${w}" could not work out a value for ${T(y)}: ${re.sentence}`):re}else H=te(F,void 0);H!==void 0&&(D[le]=H)}Object.keys(D).length>0&&c.patchNode(y.id,D)}}else if("set"in s){let m=String(te(s.target??"$subject",void 0)??""),g=u.getNode(m);!g&&!R(m)&&ge(m);let y={};for(let[D,le]of Object.entries(s.set)){let F=te(le,g);F!==void 0&&(y[D]=F)}Object.keys(y).length>0&&c.patchNode(m,y)}else if("remove"in s){let m=String(te(s.remove,void 0)??"");u.has(m)||ge(m),c.removeNode(m)}else if("replace"in s&&h){let m=A.to;for(let g of s.replace){let y=E.get(g)?.from.includes(h.kind)??!0;for(let D of y?u.out(h.id,g):u.in(h.id,g))g===s.keep&&D.id===m||ae(y?{kind:g,from:h.id,to:D.id}:{kind:g,from:D.id,to:h.id})}}}}))}let Te=[];for(let[p,i]of Object.entries(n.rules??{})){let{title:x,require:w,when:j,says:S,covers:v}=e.rules[p],$=i.repairs??[],ee=(L,l,M=a(),N)=>{let C=[],_={graph:L,subject:l,kinds:k,today:M,...f,...N?{linked:N}:{},onUnread:o=>C.push(o)},I,P=[];try{if(j&&Y(j,_)!==!0)return[];if(v&&l?(P=On(L,l,v),I=P.length===0):I=Y(w,_)===!0,!I&&C.length>0)throw new oe(`it reads ${kn(C[0])}`,0)}catch(o){throw o instanceof wn?new dn(o.sentence):o instanceof oe?new Error(o.sentence):o}if(I)return[];let r=$.flatMap(o=>{let z=n.acts?.[o.act],J={},de=l&&z?.on&&z.fromTheOtherEnd&&![z.on].flat().includes(l.kind)?Fn(e.acts[o.act].args,l.kind):void 0;de?J[de]=l.id:l&&(z?.on||/^(edit|remove|archive|unarchive|merge|skip|detach|split)-/.test(o.act))&&(J[Q]=l.id);for(let[u,b]of Object.entries(o.args??{}))J[u]=me(b)==="subject"?l?.id:b;let A=(z?e.acts[o.act].args:[]).filter(([u,b])=>b.required&&J[u]===void 0).map(([u])=>u);return[{mutation:o.act,label:o.label??(de?z.fromTheOtherEnd:z?.title)??o.act.replace(/-/g," "),args:J,...A.length>0?{missing:A}:{}}]});return v&&l?P.map(o=>({invariant:p,subjectId:l.id,label:x,message:S?se(S,{node:l,kinds:k,graph:L,today:M,money:O,bindings:{[l.kind]:l,[o.kind]:o}}):`${T(l)}: ${x} \u2014 ${T(o)}`,nodeIds:[l.id,o.id],repairs:r})):[{invariant:p,...l?{subjectId:l.id}:{},label:x,message:S?se(S,{node:l,kinds:k,graph:L,today:M,money:O}):l?`${T(l)}: ${x}`:x,nodeIds:l?[l.id]:[],repairs:r}]},W={label:x,shape:{over:i.over,require:w,...v?{covers:v}:{},when:j,says:S,declared:n.kinds,money:O,kinds:k,today:a},judgment:{...i.require?{require:i.require}:{},...i.covers?{covers:i.covers}:{},...i.when?{when:i.when}:{},...i.says?{says:i.says}:{}},...i.description?{description:i.description}:{},...$.length>0?{repairs:$.map(L=>L.act)}:{}};Te.push(i.over==="graph"?Se(p,{scope:"graph",...W,evaluate:({graph:L,today:l,context:M})=>ee(L,null,l,M?.linked)}):Se(p,{scope:{kind:i.over},...W,evaluate:({graph:L,subject:l,today:M,context:N})=>ee(L,l,M,N?.linked)}))}let Ge=n.policy&&{...n.policy,...n.roles?{roles:n.roles}:{}},we={name:n.name,schema:B,mutations:Pe,invariants:Te,...Ge?{policy:Ge}:{},...e.brand?{brand:e.brand}:{},...n.modules?{modules:n.modules}:{},...n.lenses?{lenses:n.lenses}:{},...n.pages?{pages:n.pages}:{},...n.settings?{settings:n.settings}:{},...n.connections?{connections:n.connections}:{},...n.forms?{forms:n.forms}:{},...n.publishing?{publishing:n.publishing}:{},...n.tidying?{tidying:n.tidying}:{},...n.purpose?{purpose:n.purpose}:{},...e.viewSpecs?{viewSpecs:e.viewSpecs}:{},...e.home?{home:e.home}:{},version:n.version??1};return Sn(we,n),Cn.set(we,e),{ok:!0,app:we,document:n,findings:e.findings,sights:n.policy?.sees,kinds:k}}function Vn(e,d,n){let t=d||e.format==="duration",a=e.format==="money"||e.format==="percent"||!e.format&&e.unit!==void 0;if(!(!t&&!a))return{...e,...t?{as:"duration"}:{},...a?{amount:{...n,...e.format?{format:e.format}:{},...e.unit?{unit:e.unit}:{},...e.places===0?{places:0}:{}}}:{}}}export{q as a,xn as b,Zn as c,Qn as d,Ln as e,Q as f,me as g,$n as h,xt as i,In as j};
|
|
1
|
+
import{b as kn,c as bn,d as oe,e as wn,f as Y,h as Ee,i as je,n as vn,s as se,u as On}from"./chunk.OEIWIZCP.js";import{B as be,C as ue,Ea as Oe,F as _e,H as He,Ha as en,K as Ue,Ka as nn,L as We,Ma as tn,Nb as U,Qa as xe,Ra as Re,Sb as cn,Tb as ln,Uc as mn,Vb as fn,Xa as rn,_a as on,_b as pn,b as Fe,c as Ne,d as Ce,dc as un,e as K,fd as gn,g as ye,ga as Je,gd as yn,h as Z,ha as Ye,hd as Ae,i as Ie,id as hn,j as Ve,ja as Qe,jd as ze,k as he,kb as an,l as Ke,m as Ze,nb as sn,o as qe,p as fe,q as ve,sb as Se,ta as Xe,tb as dn,v as Be,x as pe,z as ke}from"./chunk.6HY6ZGEE.js";var Tn=[{where:"settings[]",was:"honoured",now:"honored",since:"0.1.16"},{where:"pages",was:"overview",now:"scene",since:"0.1.17"}],q=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function xn(e,d=Tn){if(!q(e))return{document:e,respelled:[]};let n=[],t=e;for(let a of d)t=De(t,a.where.split("."),a,"",n);return{document:t,respelled:n}}function De(e,d,n,t,a){if(d.length===0){if(!q(e)||!Object.hasOwn(e,n.was))return e;a.push(`${t}${n.was}`);let{[n.was]:ie,...B}=e;return Object.hasOwn(e,n.now)?B:{...B,[n.now]:ie}}if(!q(e))return e;let[f,...E]=d,k=f.endsWith("[]"),O=k?f.slice(0,-2):f,G=e[O],X=G;if(!k)X=De(G,E,n,`${t}${O}.`,a);else if(Array.isArray(G)){let ie=G.map((B,T)=>De(B,E,n,`${t}${O}.${T}.`,a));X=ie.some((B,T)=>B!==G[T])?ie:G}return X===G?e:{...e,[O]:X}}var Rn=new WeakMap;function Sn(e,d){Rn.set(e,d)}function Zn(e){return Rn.get(e)}function An(e){if(typeof e=="string")return{form:"string",light:e};if(typeof e!="object"||e===null)return;let d=e,n=k=>typeof d[k]=="string"?d[k]:void 0,t=n("light")??n("src");if(t===void 0)return;let[a,f,E]=[n("dark"),n("alt"),n("darkFallback")];return{form:n("light")!==void 0?"light":"src",light:t,...a!==void 0?{dark:a}:{},...f!==void 0?{alt:f}:{},...E!==void 0?{darkFallback:E}:{}}}function Qn(e,d){let n=e.brand??{},t=n.ground,a=n.accent?ze(n.accent,t):void 0;t&&hn(a?.ok?a.schemes:Ae(t),n.accent)&&(d.push(je("brand","brand.ground","words would not read on that page background, so the app keeps Graview's","pick a lighter ground for the light scheme, a darker one for the dark")),t=void 0,a=n.accent?ze(n.accent):void 0),a&&!a.ok&&d.push(je("brand","brand.accent",`that accent cannot make a readable brand, so the app keeps Graview's colors: ${a.why}`,"pick a color further from orange-red, or a darker one"));let f=An(n.logo),E=n.name??e.name,k=n.typography?Object.fromEntries(Object.entries(n.typography).filter(([,O])=>typeof O=="string"&&yn(O)===null).map(([O,G])=>[O,gn(G)])):void 0;return{name:E,schemes:a?.ok?a.schemes:t?Ae(t):mn,...n.currency?{currency:n.currency}:{},...n.locale?{locale:n.locale}:{},...n.timeZone?{timeZone:n.timeZone}:{},...f?{logo:f.dark||f.darkFallback==="invert"?{light:f.light,...f.dark?{dark:f.dark}:{darkFallback:"invert"}}:f.light,logoAlt:f.alt??E}:{},...n.favicon?{favicon:n.favicon}:{},...e.description?{subtitle:e.description}:{},...n.subtitle===!1?{subtitleDrawn:!1}:{},...k?{typography:k}:{},...n.shape?{shape:n.shape}:{},...n.accents?{accents:n.accents}:{},...n.scheme?{scheme:n.scheme}:{},...n.views&&(n.views.css||n.views.motion)?{views:{...n.views.css?{css:n.views.css}:{},...n.views.motion?{motion:n.views.motion}:{}}}:{}}}function zn(e){let{currency:d,locale:n,timeZone:t}=e.brand??{};return{...d?{currency:d}:{},...n?{locale:n}:{},...t?{timeZone:t}:{}}}var Gn=Symbol.for("@graview/core:typed-field"),En=(e,d)=>(/^(phone|place|duration)$/.test(d)&&(ue(e)[Gn]=d),e),jn=/^(?=(?:\D*\d){3})\+?[\d ()./-]+(?: *(?:ext\.?|x|#) *\d+)?$/i;function Dn(e){let d=Z().check(K(300),ke(t=>nn(t,e)!==void 0,`a record of ${e.kinds.join(" or ")} in ${e.address}, as "<kind>:<id>"`)),n=e.cardinality==="one"?d:fe(d).check(K(200));return tn(e.description?n.check(be(e.description)):n,e)}var Ln="graview-compiled@1";function Fn(e,d){return e.find(([n,t])=>n!==Q&&"ref"in t&&(t.ref==="*"||t.ref.includes(d)))?.[0]}var Q="id",me=e=>typeof e=="string"&&/^\$[A-Za-z][A-Za-z0-9]*$/.test(e)?e.slice(1):void 0;function $n(e){let d=Object.entries(e.fields),n=t=>["name","title","label"].find(a=>t.some(([f])=>f===a))??t[0]?.[0];return n(d.filter(([,t])=>t.required&&(t.type==="string"||t.type==="text")))??n(d.filter(([,t])=>t.type==="string"))}function Pn(e,d,n){let t;switch(e.type){case"string":case"place":t=Z().check(K(500));break;case"phone":t=Z().check(K(40),ye(jn,"a phone number"));break;case"text":t=Z().check(K(2e4)),e.format&&(ue(t)[Symbol.for("@graview/core:markdown")]=1);break;case"number":case"integer":case"duration":{let f=e.min??(e.type==="duration"?0:void 0),E=[...e.type==="number"?[]:[Ke()],...f===void 0?[]:[Ne(f)],...e.max===void 0?[]:[Fe(e.max)],...e.step===void 0?[]:[Ce(e.step)]];t=E.length>0?he().check(...E):he();break}case"boolean":t=Ze();break;case"date":t=Z().check(ye(He,"a date like 2026-10-02, or a month (2016-05) or a year (2006) alone"));break;case"datetime":t=Z().check(ke(Ue,"a date and time like 2026-10-02T14:30:00Z"));break;case"enum":t=Be(e.options),e.multiple&&(t=fe(t).check(K(e.options.length)));break;case"list":t=fe(e.of==="number"?he():e.of==="date"?Z().check(ye(_e)):e.of==="image"||e.of==="video"||e.of==="file"?Oe(e.of):Z().check(K(500))).check(K(200));break;case"image":case"video":case"file":t=Oe(e.type);break;case"app-link":t=en();break;case"url":t=Ve();break;case"email":t=Ie();break}let a=e.type==="number"||e.type==="integer";return En(t,a&&e.format==="duration"?"duration":e.type),e.collaborative!==void 0&&(e.type==="text"||e.type==="string")&&(ue(t)[Symbol.for("@graview/core:collaborative")]=e.collaborative?1:0),e.description&&(t=t.check(be(e.description))),a&&(e.format==="money"||e.format==="percent"||!e.format&&e.unit)&&pn(t,{...n,...e.format?{format:e.format}:{},...e.unit?{unit:e.unit}:{},...e.places===0?{places:0}:{}}),d?pe(t):t}var ge=e=>{throw new U(`there is no record "${e}"`,"invalid")},Nn=(e,d)=>"field"in e?Pn(e.field,e.optional,d):"ref"in e?un(e.ref):pe(qe()),Cn=new WeakMap;var Le=(e,d)=>q(d)&&Object.keys(e??{}).length===Object.keys(d).length&&Object.keys(e??{}).every(n=>Object.hasOwn(d,n));function xt(e,d={}){let n=q(e)?e.format:void 0;if(n!==Ln)return{ok:!1,findings:[Ee("compiled-format","format",n===void 0?"this is not a compiled Graview app":`this compiled app is ${JSON.stringify(n)}, and this build reads ${Ln}`,"compile the document instead")]};let t=e,a=xn(t.document).document,f=a===t.document?t:{...t,document:a},E=q(a)&&typeof a.name=="string"&&q(a.kinds)&&Le(a.kinds,f.kinds)&&Le(a.acts,f.acts)&&Le(a.rules,f.rules)&&Array.isArray(f.edges)&&Array.isArray(f.findings),k={ok:!1,findings:[Ee("compiled-shape","","this compiled app's parts do not match its document","compile the document instead")]};if(!E)return k;try{return In(f,d)}catch{return k}}function In(e,d={}){let{document:n}=e,t=n.brand?.timeZone,a=d.today??(()=>We(t)),f={...n.brand?.locale?{locale:n.brand.locale}:{},...t?{timeZone:t}:{}},E=new Map(e.edges.map(([p,i])=>[p,i])),k=new Map;for(let[p,i]of Object.entries(n.kinds)){let x=e.kinds[p]?.computed,w=Re(i.edges),j=new Map(Object.entries(i.fields).flatMap(([S,v])=>v.type==="enum"?[[S,v.optionLabels??{}]]:[]));k.set(p,{fields:new Set([...Object.keys(i.fields),...w.keys()]),edges:new Map(Object.entries(xe(i.edges)).map(([S,v])=>[S,v.cardinality??"many"])),...x?{computed:new Map(x)}:{},...w.size>0?{linked:w}:{},...j.size>0?{choices:j}:{}})}e.facts&&k.set(bn,{computed:new Map(e.facts)});let O=zn(n),G=p=>({from:p.from,via:p.via,sourceEnd:p.sourceEnd,back:p.back,values(i,x,w){let j={};for(let[S,v]of p.set)if("value"in v)j[S]=v.value;else try{let $=Y(v.expr,{graph:i,subject:x,kinds:k,bindings:{to:w},today:a(),...f});($===null||typeof $!="object"||Array.isArray($))&&(j[S]=$)}catch($){if(!($ instanceof oe))throw $}return j}}),X=new Map,ie=Object.entries(n.kinds).map(([p,i])=>{let x={};for(let[r,o]of Object.entries(i.fields))x[r]=Pn(o,!o.required,O),o.repeats&&(x[rn(r)]=pe(on()));for(let[r,o]of Re(i.edges))x[r]=pe(Dn(o));let{label:w,describe:j,durations:S}=e.kinds[p]??{},v=Object.entries(i.computed??{}).map(([r,o])=>[r,typeof o=="string"?{expr:o}:o]),$=Object.hasOwn(i.fields,"label")&&!i.fields.label.label&&!/\{\s*label\b/.test(i.label??`{${$n(i)??""}}`),ee=Object.fromEntries([...$?[["label","Label"]]:[],...Object.entries(i.fields).filter(([,r])=>r.label).map(([r,o])=>[r,o.label]),...v.filter(([,r])=>r.label).map(([r,o])=>[r,o.label])]),W=Object.keys(ee).length>0,L=Object.entries(i.fields).filter(([,r])=>r.type==="enum"&&(r.optionLabels&&Object.keys(r.optionLabels).length>0||r.multiple)),l=r=>o=>typeof o=="string"&&r.optionLabels&&Object.hasOwn(r.optionLabels,o)?r.optionLabels[o]:Ye(String(o)),M=Object.fromEntries(L.map(([r,o])=>[r,o.multiple?z=>Array.isArray(z)?z.map(l(o)).join(", "):l(o)(z):l(o)])),N=L.length>0,C=Object.fromEntries(Object.entries(i.fields).filter(([,r])=>r.default!==void 0).map(([r,o])=>[r,o.default]));X.set(p,C);let _=Object.fromEntries(Object.entries(xe(i.edges)).map(([r,{renamedFrom:o,...z}])=>[r,z])),I=Object.entries(i.fields).flatMap(([r,o])=>o.aliases?[[r,o.aliases]]:[]),P=r=>i[r]?{[r]:i[r]}:{};return Qe(p,{fields:ve(x),edges:_,...P("plural"),...P("noun"),...P("aliases"),...I.length>0?{fieldAliases:Object.fromEntries(I)}:{},...P("description"),...w?{label:r=>se(w,{node:r,kinds:k,today:a(),money:O})||r.id}:{},...j?{describe:r=>se(j,{node:r,kinds:k,today:a(),money:O})}:{},...P("lifecycle"),...P("figure"),...P("fieldRoles"),...P("people"),archives:i.archives,...i.tidying?{tidying:i.tidying}:{},...v.length>0?{computed:Object.fromEntries(v.map(([r,o])=>[r,Vn(o,S?.includes(r)??!1,O)??i.computed[r]]))}:{},...W||N||i.glance||i.page?{display:{...W?{labels:ee}:{},...N?{format:M}:{},...i.glance?{glance:[...i.glance]}:{},...i.page?{page:i.page}:{}}}:{},...Object.keys(C).length>0?{defaults:C}:{},...e.kinds[p]?.keptInStep?{keptInStep:e.kinds[p].keptInStep}:{},...e.kinds[p]?.derives?{derives:G(e.kinds[p].derives)}:{}})}),B=an(ie,n.computed);function T(p){return B.tryDefinition(p.kind)?.label?.(p)??p.id}let $e=p=>({id:"",kind:p,...X.get(p)}),Pe=[];for(let[p,i]of Object.entries(n.acts??{})){let x=e.acts[p],{title:w,effects:j,guard:S,refusal:v,destructive:$,idempotent:ee,creates:W,connects:L,severs:l,writes:M,writesOther:N,sets:C}=x,_={};for(let c of j)"through"in c&&(_[c.through]=[...new Set([..._[c.through]??[],...Object.keys(c.set)])]);let I=new Map(x.args),P={};for(let[c,A]of I)P[c]=Nn(A,O);let r=[i.on??[]].flat(),o=new Map(x.exprs),z=j.find(c=>"create"in c),J=(c,A,u,b=null)=>{if(q(c)&&"expr"in c)return Y(o.get(c.expr),{graph:u,subject:b,kinds:k,bindings:A,today:a(),...f});let h=me(c);return h===void 0?typeof c=="string"&&c.startsWith("$$")?c.slice(1):c:h==="now"?new Date().toISOString():h==="today"?a():A[h]},de=(c,A)=>{if(!z)return"";let u=n.kinds[z.create].fields,b=$e(z.create),h=[];for(let[R,ce]of Object.entries(z.set??{})){try{b[R]=J(ce,c,A)??b[R]}catch{}let ae=me(ce);ae&&c[ae]!==void 0&&h.push(R)}let V=T(b).trim(),ne=h.filter(R=>b[R]!==!1&&u[R].type!=="text"&&!(/[^]{41}/.test(b[R])||/ .*[.!?]$/.test(b[R])&&!/[ .][A-Z]\w{0,3}\.$/.test(b[R]))&&T({...b,[R]:void 0}).trim()===V).map(R=>b[R]===!0?u[R].label??Je(R):vn(b[R],u[R].format,a(),[],O));return V&&ne.length>0?`${V} (${ne.join(", ")})`:V};Pe.push(fn(p,{input:ve(P),title:w,...i.description?{description:i.description}:{},...i.fromTheOtherEnd?{fromTheOtherEnd:i.fromTheOtherEnd}:{},...I.has(Q)?{subject:{kinds:r.length>0?r:"*",arg:Q}}:{},...$?{destructive:!0}:{},...ee?{idempotent:!0}:{},...W.length>0?{creates:W}:{},...L.length>0?{connects:L}:{},...l.length>0?{severs:l}:{},writes:M,...Object.keys(N).length>0?{writesOther:N}:{},...Object.keys(_).length>0?{writesLinked:_}:{},...Object.keys(C).length>0?{sets:C}:{},...S?{allowedOn:(c,A)=>{let u=c.getNode(A);if(!u||r.length>0&&!r.includes(u.kind))return!1;try{return Y(S,{graph:c,subject:u,kinds:k,bindings:{},today:a(),...f})===!0}catch{return!1}}}:{},describe:(c,A)=>{let u=typeof c[Q]=="string"?A.getNode(c[Q]):void 0,b=u?T(u):de(c,A);return b?`${w}: ${b}`:w},apply(c,A){let u=c.graph,b=typeof A[Q]=="string"?A[Q]:void 0,h=b?u.getNode(b):void 0;if(b&&!h&&ge(b),h&&r.length>0&&!r.includes(h.kind))throw new U(`"${w}" acts on ${r.join(" or ")}, not on ${Xe(h.kind)}`,"invalid");let V={};for(let[s,m]of Object.entries(A))m!==void 0&&(V[s]=m);if(S&&h){let s;try{s=Y(S,{graph:u,subject:h,kinds:k,bindings:V,today:a(),...f})}catch(m){throw m instanceof oe?new U(`"${w}" could not be judged: ${m.sentence}`):m}if(s!==!0)throw new U(v?se(v,{node:h,kinds:k,graph:u,bindings:V,today:a(),money:O}):`"${w}" is not allowed for ${T(h)} right now`)}let ne=new Map,R=s=>u.has(s)||[...ne.values()].includes(s),ce=new Set,ae=s=>{let m=sn(s);ce.has(m)||(ce.add(m),c.removeEdge(s))},te=(s,m)=>{let g=me(s);if(g==="subject")return b;if(g==="me"){let y=c.me;if(y&&n.kinds[u.getNode(y)?.kind]?.people)return y;throw new U(`"${w}" is done as you, and you have no record here`)}if(ne.has(g))return ne.get(g);try{return J(s,V,u,m??h??null)}catch(y){throw y instanceof oe?new U(`"${w}" could not work out a value: ${y.sentence}`):y}};for(let s of j)if("create"in s){let m=n.kinds[s.create],g=$e(s.create);for(let[H,re]of Object.entries(s.set??{})){let Me=te(re,void 0);Me!==void 0&&(g[H]=Me)}let y=$n(m),D=String((y&&g[y])??s.create),le=ln(D,s.create,g,(H,re)=>cn(n.policy?.sees,H,re)),F=c.freshId(le?s.create:D,s.create,g);c.addNode({...g,id:F}),s.as&&ne.set(s.as,F)}else if("connect"in s||"sever"in s){let m="connect"in s?s.connect:s.sever,g=String(te(s.from,void 0)??""),y=String(te(s.to,void 0)??"");if(R(g)||ge(g),R(y)||ge(y),"connect"in s){if(E.get(m)?.cardinality==="one")for(let D of u.out(g,m))D.id!==y&&ae({kind:m,from:g,to:D.id});u.out(g,m).some(D=>D.id===y)||c.addEdge({kind:m,from:g,to:y})}else ae({kind:m,from:g,to:y})}else if("through"in s){if(!h)throw new U(`"${w}" carries a change to linked records, and has no record to start from`,"invalid");let g=E.get(s.through)?.from.includes(h.kind)??!0?u.out(h.id,s.through):u.in(h.id,s.through);for(let y of g){let D={};for(let[le,F]of Object.entries(s.set)){let H;if(me(F)==="to")H=y.id;else if(q(F)&&"expr"in F)try{H=Y(o.get(F.expr),{graph:u,subject:h,kinds:k,bindings:{...V,to:y},today:a(),...f})}catch(re){throw re instanceof oe?new U(`"${w}" could not work out a value for ${T(y)}: ${re.sentence}`):re}else H=te(F,void 0);H!==void 0&&(D[le]=H)}Object.keys(D).length>0&&c.patchNode(y.id,D)}}else if("set"in s){let m=String(te(s.target??"$subject",void 0)??""),g=u.getNode(m);!g&&!R(m)&&ge(m);let y={};for(let[D,le]of Object.entries(s.set)){let F=te(le,g);F!==void 0&&(y[D]=F)}Object.keys(y).length>0&&c.patchNode(m,y)}else if("remove"in s){let m=String(te(s.remove,void 0)??"");u.has(m)||ge(m),c.removeNode(m)}else if("replace"in s&&h){let m=A.to;for(let g of s.replace){let y=E.get(g)?.from.includes(h.kind)??!0;for(let D of y?u.out(h.id,g):u.in(h.id,g))g===s.keep&&D.id===m||ae(y?{kind:g,from:h.id,to:D.id}:{kind:g,from:D.id,to:h.id})}}}}))}let Te=[];for(let[p,i]of Object.entries(n.rules??{})){let{title:x,require:w,when:j,says:S,covers:v}=e.rules[p],$=i.repairs??[],ee=(L,l,M=a(),N)=>{let C=[],_={graph:L,subject:l,kinds:k,today:M,...f,...N?{linked:N}:{},onUnread:o=>C.push(o)},I,P=[];try{if(j&&Y(j,_)!==!0)return[];if(v&&l?(P=On(L,l,v),I=P.length===0):I=Y(w,_)===!0,!I&&C.length>0)throw new oe(`it reads ${kn(C[0])}`,0)}catch(o){throw o instanceof wn?new dn(o.sentence):o instanceof oe?new Error(o.sentence):o}if(I)return[];let r=$.flatMap(o=>{let z=n.acts?.[o.act],J={},de=l&&z?.on&&z.fromTheOtherEnd&&![z.on].flat().includes(l.kind)?Fn(e.acts[o.act].args,l.kind):void 0;de?J[de]=l.id:l&&(z?.on||/^(edit|remove|archive|unarchive|merge|skip|detach|split)-/.test(o.act))&&(J[Q]=l.id);for(let[u,b]of Object.entries(o.args??{}))J[u]=me(b)==="subject"?l?.id:b;let A=(z?e.acts[o.act].args:[]).filter(([u,b])=>b.required&&J[u]===void 0).map(([u])=>u);return[{mutation:o.act,label:o.label??(de?z.fromTheOtherEnd:z?.title)??o.act.replace(/-/g," "),args:J,...A.length>0?{missing:A}:{}}]});return v&&l?P.map(o=>({invariant:p,subjectId:l.id,label:x,message:S?se(S,{node:l,kinds:k,graph:L,today:M,money:O,bindings:{[l.kind]:l,[o.kind]:o}}):`${T(l)}: ${x} \u2014 ${T(o)}`,nodeIds:[l.id,o.id],repairs:r})):[{invariant:p,...l?{subjectId:l.id}:{},label:x,message:S?se(S,{node:l,kinds:k,graph:L,today:M,money:O}):l?`${T(l)}: ${x}`:x,nodeIds:l?[l.id]:[],repairs:r}]},W={label:x,shape:{over:i.over,require:w,...v?{covers:v}:{},when:j,says:S,declared:n.kinds,money:O,kinds:k,today:a},judgment:{...i.require?{require:i.require}:{},...i.covers?{covers:i.covers}:{},...i.when?{when:i.when}:{},...i.says?{says:i.says}:{}},...i.description?{description:i.description}:{},...$.length>0?{repairs:$.map(L=>L.act)}:{}};Te.push(i.over==="graph"?Se(p,{scope:"graph",...W,evaluate:({graph:L,today:l,context:M})=>ee(L,null,l,M?.linked)}):Se(p,{scope:{kind:i.over},...W,evaluate:({graph:L,subject:l,today:M,context:N})=>ee(L,l,M,N?.linked)}))}let Ge=n.policy&&{...n.policy,...n.roles?{roles:n.roles}:{}},we={name:n.name,schema:B,mutations:Pe,invariants:Te,...Ge?{policy:Ge}:{},...e.brand?{brand:e.brand}:{},...n.modules?{modules:n.modules}:{},...n.lenses?{lenses:n.lenses}:{},...n.pages?{pages:n.pages}:{},...n.settings?{settings:n.settings}:{},...n.connections?{connections:n.connections}:{},...n.forms?{forms:n.forms}:{},...n.publishing?{publishing:n.publishing}:{},...n.tidying?{tidying:n.tidying}:{},...n.purpose?{purpose:n.purpose}:{},...e.viewSpecs?{viewSpecs:e.viewSpecs}:{},...e.home?{home:e.home}:{},version:n.version??1};return Sn(we,n),Cn.set(we,e),{ok:!0,app:we,document:n,findings:e.findings,sights:n.policy?.sees,kinds:k}}function Vn(e,d,n){let t=d||e.format==="duration",a=e.format==="money"||e.format==="percent"||!e.format&&e.unit!==void 0;if(!(!t&&!a))return{...e,...t?{as:"duration"}:{},...a?{amount:{...n,...e.format?{format:e.format}:{},...e.unit?{unit:e.unit}:{},...e.places===0?{places:0}:{}}}:{}}}export{q as a,xn as b,Zn as c,Qn as d,Ln as e,Q as f,me as g,$n as h,xt as i,In as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as fe,b as Ne,d as Ze,e as He,f as he,g as F,h as ke,j as We}from"./chunk.4AC2QM7T.js";import{h as Je,i as Xe,j as Qe}from"./chunk.CVPMSPCH.js";import{a as ae,b as ce,c as J,d as Ye,e as ee,g as se,h as en}from"./chunk.KBPJ7X7W.js";import{c as Be,h as k,i as Ue,j as ze,t as ye}from"./chunk.OEIWIZCP.js";import{A as re,Ia as Ie,Ld as qe,Md as Ve,Pa as Ke,Qa as Q,Ra as me,b as Z,c as U,e as ue,f as Me,g as P,h as O,ic as Pe,jc as ge,k as L,kc as Le,l as X,lc as Ge,m as _,mc as Ce,n as _e,o as H,p as I,r as w,s as oe,t as R,u as j,v as G,w as T,x as n,y as N,z as Y}from"./chunk.6HY6ZGEE.js";var be=e=>Object.entries(e).map(([s,i])=>[s,Object.keys(Q(i?.edges))]),$e=(e,s)=>Le(e,be(s));function nn(e){return[...Object.keys(e.acts??{}),...Object.keys(e.kinds).flatMap(s=>Pe(s)),...Ge(be(e.kinds))]}var B=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function tn(e){if(!B(e)||!B(e.kinds))return e;let s;try{let f=Object.fromEntries(Object.entries(e.kinds).map(([g,l])=>[g,B(l)&&B(l.edges)?{edges:l.edges}:{}]));s=nn({acts:B(e.acts)?e.acts:{},kinds:f})}catch{return e}let i=new Set(s),t=!1,o=f=>{if(typeof f!="string"||i.has(f))return f;let g=qe(f,s);return g===void 0?f:(t=!0,g)},a=B(e.policy)&&Array.isArray(e.policy.grants)?{...e.policy,grants:e.policy.grants.map(f=>B(f)&&Array.isArray(f.mutations)?{...f,mutations:f.mutations.map(o)}:f)}:void 0,u=B(e.rules)?Object.fromEntries(Object.entries(e.rules).map(([f,g])=>[f,B(g)&&Array.isArray(g.repairs)?{...g,repairs:g.repairs.map(l=>B(l)?{...l,act:o(l.act)}:l)}:g])):void 0;return t?{...e,...a?{policy:a}:{},...u?{rules:u}:{}}:e}function we(e,s){let i=Ve(e,nn(s));return i&&i!==e?`did you mean "${i}"?`:void 0}var Oe="graview-document",je=1,xe=256*1024,ne=64*1024,vn=["plain","editorial","shader","ascii"];var Se=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,ve=/^[a-z][A-Za-z0-9]*$/,On=/^[a-z0-9\u00df-\u00ff'-]+( [a-z0-9\u00df-\u00ff'-]+){0,2}$/,on=12,sn=60,jn=new Set(["id","kind"]),xn=/^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|[a-z][A-Za-z0-9]*)$/,An=["string","text","number","integer","boolean","date","datetime","enum","list","url","email","image","video","file","app-link","phone","place","duration"];function En(){let e=h=>h in Object.prototype,s=Y(h=>!e(h),"every object already has this name \u2014 choose another"),i=(h,D)=>[...h===void 0?[]:[Me(h)],...D===void 0?[]:[ue(D)]],t=(h,D)=>O().check(...i(h,D)),o=(h,D,te)=>I(h).check(...i(D,te)),a=h=>O().check(P(Se,`${h} names are kebab-case, lower-case words joined by hyphens like "tool-note" (field and relation names are camelCase, like "supersededBy")`)),u=O().check(P(xn,'relation names are one camelCase word, like "supersededBy" (kind names are kebab-case, like "tool-note")'),s),f=O().check(P(ve,'field names are one word or camelCase, like "dueDate", so rules say them bare (kind names are kebab-case, like "tool-note")'),Y(h=>!jn.has(h),'a field cannot be called "id" or "kind" \u2014 the framework keeps those; try "type" or "category"'),s),g=t(1,500),l=O().check(ue(40),P(On,'an alias is up to three lower-case words, like "supplier"')),r=t(1,2e3),p=t(1,300),y=w({type:G(An),required:n(_()),description:n(g),label:n(t(1,60)),aliases:n(o(l,1,on)),options:n(o(t(1,80),1,100)),multiple:n(_()),optionLabels:n(j(t(1,80),t(1,80))),of:n(G(["string","number","date","image","video","file"])),default:n(H()),unit:n(t(void 0,12)),format:n(G(["money","percent","duration","markdown"])),places:n(T(0)),min:n(L()),max:n(L()),step:n(L()),renamedFrom:n(O().check(P(ve))),repeats:n(_()),collaborative:n(_())}).check(re((h,D)=>{h.type==="enum"&&!h.options&&D.addIssue({code:"custom",message:'an enum field lists its "options"',path:["options"]}),h.type!=="enum"&&h.options&&D.addIssue({code:"custom",message:'"options" belongs only on an enum field',path:["options"]}),h.type!=="enum"&&h.multiple!==void 0&&D.addIssue({code:"custom",message:'"multiple" belongs only on an enum field: a choice that takes several of its options',path:["multiple"]});for(let te of Object.keys(h.optionLabels??{}))h.options?.includes(te)||D.addIssue({code:"custom",message:`"${te}" is labeled, and is none of the field's options`,path:["optionLabels",te]});h.type!=="list"&&h.of&&D.addIssue({code:"custom",message:'"of" belongs only on a list field',path:["of"]}),h.places!==void 0&&!(h.format==="money"||!h.format&&/^[A-Z]{3}$/.test(h.unit??""))&&D.addIssue({code:"custom",message:'"places" belongs only on money: a number field with "format": "money"',path:["places"]}),h.repeats&&h.type!=="date"&&h.type!=="datetime"&&D.addIssue({code:"custom",message:'"repeats" belongs only on a date or datetime field',path:["repeats"]})})),m=O().check(P(new RegExp(`${Se.source}|${Ie.source}`),'a relation goes to a kind of this document, like "house", or of another app, like "@nick/house/house"')),d=w({to:R([o(m,1),T("*")]),cardinality:n(G(["one","many"])),description:n(g),inverse:n(t(1,80)),appendOnly:n(_()),renamedFrom:n(O()),tidying:n(T("never"))}),c=R([r,w({expr:r,label:n(t(1,60)),description:n(g),format:n(G(["money","percent","duration"])),unit:n(t(1,12)),places:n(T(0)),hidden:n(_())})]),S=R([O(),L(),_(),_e(),I(H()),w({expr:r})]),b=w({noun:n(t(1,40)),plural:n(t(1,40)),aliases:n(o(l,1,on)),description:n(g),fields:j(f,y).check(Y(h=>Object.keys(h).length>0,"a kind has at least one field")),label:n(p),describe:n(p),lifecycle:n(w({field:f,retired:o(R([O(),L(),_()]),1)})),figure:n(t(void 0,2e4)),glance:n(o(f,1,20)),page:n(w({fields:n(o(f,1,40)),groups:n(o(w({title:t(1,60),fields:o(f,1,40)}),1,12))})),edges:n(j(u,d)),computed:n(j(O(),c).check(Y(h=>Object.keys(h).length<=sn,`a kind works out at most ${sn} computed fields`))),fieldRoles:n(j(O(),O())),renamedFrom:n(O().check(P(Se))),people:n(_()),archives:n(T(!1)),tidying:n(G(["never","no-links"])),derives:n(w({from:a("kind"),via:u,set:j(f,S)}))}),v=O().check(P(/^\$[A-Za-z][A-Za-z0-9]*$/,'a reference is "$" and a name, like "$subject" or "$new"')),x=R([w({create:a("kind"),as:n(O().check(P(ve))),set:n(j(f,S))}),w({set:j(f,S),target:n(v)}),w({connect:u,from:v,to:v}),w({sever:u,from:v,to:v}),w({remove:v})]),A=w({title:n(t(1,80)),description:n(g),fromTheOtherEnd:n(t(1,80)),on:n(R([a("kind"),o(a("kind"),1)])),creates:n(a("kind")),sets:n(j(f,S)),writes:n(o(f,1)),connects:n(u),severs:n(u),setsOther:n(j(f,S)),setsLinked:n(j(u,j(f,S))),replaces:n(R([T(!0),o(u,1,10)])),removes:n(T(!0)),args:n(j(f,y)),effects:n(o(x,1,20)),allowedWhen:n(r),refusal:n(p),destructive:n(_())}),$=w({act:a("act"),label:n(t(1,80)),args:n(j(O(),S))}),C=w({every:a("kind"),through:u,via:n(u)}),q=w({title:n(t(1,120)),description:n(g),over:R([T("graph"),a("kind")]),when:n(r),require:n(r),covers:n(C),says:n(p),repairs:n(o($,void 0,10))}).check(re((h,D)=>{!h.require&&!h.covers&&D.addIssue({code:"custom",message:'a rule says what must hold in "require", or what each record must be linked to in "covers"',path:["require"]}),h.require&&h.covers&&D.addIssue({code:"custom",message:'a rule is judged by "require" or by "covers", not both',path:["covers"]}),h.covers&&h.over==="graph"&&D.addIssue({code:"custom",message:'a coverage rule is over a kind, whose records it follows through their links; name the kind in "over"',path:["over"]})})),z=w({roles:R([o(a("role"),1),T("*")]),mutations:R([o(a("act")),T("*")]),kinds:n(R([I(a("kind")),T("*")])),describe:n(g),self:n(_()),ownEnd:n(_()),propose:n(R([o(a("act"),1),T("*")]))}).check(re((h,D)=>{Array.isArray(h.mutations)&&h.mutations.length===0&&h.propose===void 0&&D.addIssue({code:"custom",message:'a grant names at least one act in "mutations", or the acts it lets these roles propose in "propose"',path:["mutations"]})})),E=n(o(f,1)),M=w({roles:R([o(a("role"),1),T("*")]),kinds:o(a("kind"),1),own:n(_()),via:n(u),fields:E,hide:E}),ie=w({grants:I(z),sees:n(I(M))}),W=w({accent:n(O().check(P(/^#[0-9a-fA-F]{6}$/,'an accent is a color like "#c2577a"'))),ground:n(R([O().check(P(/^#[0-9a-fA-F]{6}$/,'a ground is a color like "#eef3f8"')),w({light:n(O().check(P(/^#[0-9a-fA-F]{6}$/,'a ground is a color like "#eef3f8"'))),dark:n(O().check(P(/^#[0-9a-fA-F]{6}$/,'a ground is a color like "#101826"')))})])),name:n(t(1,60)),currency:n(O().check(P(/^[A-Z]{3}$/,'a currency is its three-letter code, like "USD" or "EUR"'))),locale:n(t(2,35)),timeZone:n(t(1,64)),logo:n(R([t(1,ne),w({src:t(1,ne),alt:n(t(1,120))}),w({light:t(1,ne),dark:n(t(1,ne)),alt:n(t(1,120)),darkFallback:n(T("invert"))})])),favicon:n(R([t(1,ne),w({emoji:O()})])),typography:n(w({display:n(t(1,200)),body:n(t(1,200)),mono:n(t(1,200))})),shape:n(w({radius:n(L().check(U(0),Z(32))),density:n(L().check(U(.75),Z(1.5)))})),accents:n(j(O(),L().check(U(0),Z(360)))),scheme:n(G(["light","dark","auto"])),subtitle:n(T(!1)),splash:n(w({style:G(vn),image:n(t(1,ne)),title:n(t(1,80)),kicker:n(t(1,80)),shader:n(t(1,40)),scheme:n(G(["light","dark","device"]))})),views:n(w({css:n(t(1)),motion:n(G(["none","fade"]))}))}),V=j(O(),H()),Fe=R([t(1,120),w({by:t(1,120),direction:n(G(["asc","desc"]))})]),De=L().check(X(),U(1),Z(9999)),hn=oe({create:n(_()),options:n(oe({sort:n(Fe),columnSort:n(Fe),search:n(o(t(1,120),void 0,40)),filters:n(o(t(1,120),void 0,40)),horizon:n(R([L().check(X(),U(1),Z(200)),oe({years:L().check(X(),U(1),Z(200)),title:t(1,80),from:n(De),to:n(De)})]))}))}),kn=w({card:n(I(H())),row:n(I(H())),page:n(I(H()))}),bn=()=>{let h=n(G(["asc","desc"]));return R([t(1,120),w({by:t(1,120),direction:h,then:n(R([t(1,120),w({by:t(1,120),direction:h})]))})])},$n=()=>R([t(1,120),w({by:t(1,120),order:n(o(t(1,80),void 0,40)),closed:n(o(t(1,80),void 0,40))})]),Te=oe({order:n(I(O())),hide:n(I(O())),first:n(O()),primary:n(o(t(1,80),void 0,40)),scene:n(t(1,40)),pages:n(t(1,40)),lists:n(j(O(),w({filters:n(o(t(1,120),void 0,40)),sort:n(bn()),group:n($n()),export:n(_())})))}),wn=w({act:a("act"),title:n(t(1,80)),intro:n(g),fields:n(o(f,1,40)),say:n(g),submit:n(t(1,80)),role:n(a("role"))}),Sn=w({$schema:n(O()),format:T(Oe),formatVersion:T(je),name:t(1,80),description:n(g),version:n(L().check(X(),U(1))),kinds:j(a("kind"),b).check(Y(h=>Object.keys(h).length>0,"a document declares at least one kind"),Y(h=>Object.keys(h).length<=40,"a document declares at most 40 kinds")),computed:n(j(O(),c)),acts:n(j(a("act"),A)),rules:n(j(a("rule"),q)),roles:n(I(a("role"))),policy:n(ie),modules:n(V),lenses:n(I(hn)),pages:n(Te),views:n(j(O(),R([kn,I(H())]))),brand:n(W),settings:n(I(V)),migrations:n(I(V)),connections:n(j(a("connection"),V)),purpose:n(V),workflows:n(j(a("workflow"),V)),forms:n(j(a("form"),wn)),publishing:n(w({mode:G(["live","on-publish"]),working:o(a("role"),void 0,40),publishers:n(o(a("role"),1,40))})),tidying:n(w({autoAcceptAt:n(L().check(X(),U(1),Z(1e4)))}))});return{FieldSpec:y,EdgeSpec:d,ComputedSpec:c,KindSpec:b,ValueSpec:S,EffectSpec:x,ActSpec:A,RepairSpec:$,CoverSpec:C,RuleSpec:q,GrantSpec:z,SightSpec:M,PolicySpec:ie,BrandSpec:W,PagesSpec:Te,DocumentSpec:Sn}}var Rn,K=()=>Rn??=En(),Xn=N(()=>K().FieldSpec),Qn=N(()=>K().EdgeSpec),et=N(()=>K().ComputedSpec),nt=N(()=>K().KindSpec),tt=N(()=>K().ValueSpec),ot=N(()=>K().EffectSpec),st=N(()=>K().ActSpec),it=N(()=>K().RepairSpec),rt=N(()=>K().CoverSpec),at=N(()=>K().RuleSpec),ct=N(()=>K().GrantSpec),lt=N(()=>K().SightSpec),dt=N(()=>K().PolicySpec),pt=N(()=>K().BrandSpec),ft=N(()=>K().PagesSpec),rn=N(()=>K().DocumentSpec);var Fn={};function an(e,s=Fn,i=je){let{document:t,respelled:o}=Ne(e),a=o.length>0?{respelled:o}:{};if(!t||typeof t!="object"||Array.isArray(t))return{document:t};let u=t;if(u.format!==Oe||typeof u.formatVersion!="number"||u.formatVersion>=i)return{document:t,...a};let f=u.formatVersion,g=structuredClone(u);for(let l=f;l<i;l++){let r=s[l];if(!r)throw new Error(`there is no upgrade from format ${l} to ${l+1}`);g={...r(g),formatVersion:l+1}}return{document:g,from:f,...a}}function Ae(e,s,i){let t=Object.keys(e).filter(f=>e[f].edges?.[s]!==void 0);if(t.length===0)return;let o=t.map(f=>e[f].edges[s].to),a=o.some(f=>f==="*")?"*":[...new Set(o.flatMap(f=>f))];if(i.length===0||i.some(f=>t.includes(f)))return{reversed:!1,kinds:a};let u=t.filter(f=>{let g=e[f].edges[s].to;return g==="*"||i.every(l=>g.includes(l))});return u.length>0?{reversed:!0,kinds:u}:{reversed:!1,kinds:a}}var dn=(e,s)=>{let i=e?.fields[s];return i!==void 0&&(i.type==="duration"||(i.type==="number"||i.type==="integer")&&i.format==="duration")};function cn(e,s,i,t){if(t==="out"){let o=e[s]?.edges?.[i]?.to;return o===void 0?[]:o==="*"?Object.keys(e):o}return Object.entries(e).filter(([,o])=>{let a=o.edges?.[i]?.to;return a!==void 0&&(a==="*"||a.includes(s))}).map(([o])=>o)}function Ee(e,s,i){if(i.t==="ident")return e[s]?.edges?.[i.name]?cn(e,s,i.name,"out"):void 0;if(i.t==="where")return Ee(e,s,i.set);if(i.t==="call"&&(i.fn==="out"||i.fn==="in")&&i.args[0]?.t==="lit"&&typeof i.args[0].value=="string")return cn(e,s,i.args[0].value,i.fn)}var ln=(e,s,i)=>{let t=s.filter(o=>e[o]?.fields[i]!==void 0);return t.length>0&&t.every(o=>dn(e[o],i))};function pn(e,s,i){let t=e.kinds,o=t[s],a=new Map(i),u=new Map,f=(l,r)=>{if(r>8)return!1;switch(l.t){case"ident":return dn(o,l.name)||g(l.name,r+1);case"member":{let p=Ee(t,s,l.object);return p!==void 0&&ln(t,p,l.name)}case"call":{if(l.fn!=="sum"&&l.fn!=="min"&&l.fn!=="max")return!1;let[p,y]=l.args,m=p&&Ee(t,s,p);return m!==void 0&&y?.t==="ident"&&ln(t,m,y.name)}case"binary":return(l.op==="+"||l.op==="-")&&f(l.left,r)&&f(l.right,r);case"unary":return l.op==="-"&&f(l.operand,r);default:return!1}},g=(l,r)=>{if(o?.computed?.[l]===void 0)return!1;if(u.has(l))return u.get(l);u.set(l,!1);let p=a.get(l),y=p!==void 0&&f(p,r);return u.set(l,y),y};return i.map(([l])=>l).filter(l=>g(l,0))}var Dn="several choices";var Tn={title:["string","text"],rich_text:["string","text"],number:["number","integer"],select:["enum","string"],status:["enum","string"],multi_select:["list",Dn],date:["date","datetime"],checkbox:["boolean"],url:["url","string"],email:["email","string"],phone_number:["phone","string"],people:["string","text","list"]};var fn=new Set(Object.values(Tn).flat());function un(e,s){let i=new Map;if(!e||typeof e!="object")return new Map;let t=Object.values(e).flatMap(o=>o&&typeof o=="object"&&o.system==="notion"&&Array.isArray(o.sources)?o.sources.filter(a=>a&&typeof a=="object").map(a=>({system:"notion",kind:a.kind,properties:a.properties})):[o]);for(let o of t){if(!o||typeof o!="object"||typeof o.kind!="string")continue;let a=s[o.kind]?.fields;if(!a)continue;let u=[];o.system==="google-calendar"&&o.fields&&typeof o.fields=="object"?u=Object.values(o.fields).filter(g=>typeof g=="string"):o.system==="notion"&&(u=o.properties&&typeof o.properties=="object"?Object.keys(o.properties):Object.keys(a).filter(g=>fn.has(a[g].type)));let f=i.get(o.kind)??new Set;for(let g of u)Object.hasOwn(a,g)&&f.add(g);i.set(o.kind,f)}return new Map([...i].filter(([,o])=>o.size>0).map(([o,a])=>[o,Object.keys(s[o].fields).filter(u=>a.has(u))]))}function mn(e,s,i=`kinds.${e}.page`){let t=s.page;if(!t)return[];let o=[],a=[...Object.keys(s.fields),...Object.keys(s.computed??{})],u=new Set,f=(l,r)=>{a.includes(l)?u.has(l)&&o.push(k("page-field-twice",r,`"${l}" is on ${e}'s page twice; name each field once`)):o.push(k("page-field",r,`${e}'s page is to show "${l}", and ${e} has no field or computed field called that`,`use one of: ${a.join(", ")}`)),u.add(l)};(t.fields??[]).forEach((l,r)=>f(l,`${i}.fields.${r}`));let g=new Set;return(t.groups??[]).forEach((l,r)=>{let p=l.title.trim().toLowerCase();g.has(p)&&o.push(k("page-group-twice",`${i}.groups.${r}.title`,`${e}'s page has two groups called "${l.title}"; give each its own title`)),g.add(p),l.fields.forEach((y,m)=>f(y,`${i}.groups.${r}.fields.${m}`))}),o}function gn(e,s=[]){return Ce({declared:Object.keys(e.fields),paged:[...e.page?.fields??[],...(e.page?.groups??[]).flatMap(i=>i.fields)],must:i=>!!e.fields[i].required&&e.fields[i].default===void 0,naming:s})}var Nn=new Set(["subject","now","today","me"]);function Mn(e){if((typeof e=="string"?e:JSON.stringify(e??null)).length>xe)return{findings:[k("too-large","",`a document may be at most ${xe/1024} KB`)]};if(typeof e=="string")try{e=JSON.parse(e)}catch(t){return{findings:[k("not-json","",`this is not JSON: ${t.message}`)]}}try{e=an(e).document}catch(t){return{findings:[k("format","formatVersion",t.message)]}}e=tn(e);let s=rn.safeParse(e);if(!s.success)return{findings:s.error.issues.map(t=>{let o=t.path.map(String).join(".");if(t.code==="unrecognized_keys")return k("unknown-key",o,`${t.keys.map(a=>`"${a}"`).join(", ")} ${t.keys.length===1?"is":"are"} not part of a Graview document here`,"check the spelling against docs/declaration-document.md");if(t.code==="invalid_union"&&/\.effects\.\d+$/.test(o))return k("effect-shape",o,"this effect is not one Graview knows",'an effect is one of {"create": kind, "as"?: name, "set"?: {field: value}}, {"set": {field: value, \u2026}, "target"?: "$ref"}, {"connect"|"sever": relation, "from": "$ref", "to": "$ref"}, {"remove": "$ref"}');if(t.code==="invalid_key"){let a=t.issues?.[0]?.message;return k("shape",o,`the name "${String(t.path.at(-1))}" is not allowed here${a?`: ${a}`:""}`)}return k("shape",o,t.message)})};let i=s.data;return{document:i,findings:_n(i)}}var pe=e=>[e??[]].flat();function zn(e){let s=new Map;for(let[i,t]of Object.entries(e.kinds))for(let[o,a]of Object.entries(Q(t.edges))){let u=s.get(o);s.set(o,{name:o,from:[...u?.from??[],i],to:a.to==="*"||u?.to==="*"?"*":[...new Set([...u?.to??[],...a.to])],cardinality:a.cardinality??"many"})}return s}function Ht(e){let s=new Map;for(let[t,o]of Object.entries(e.kinds)){let a=se(o),u=me(o.edges);s.set(t,{fields:new Set([...Object.keys(o.fields),...u.keys()]),edges:new Map(Object.entries(Q(o.edges)).map(([f,g])=>[f,g.cardinality??"many"])),...a?{computed:a}:{},...u.size>0?{linked:u}:{}})}let i=se(e);return i&&s.set(Be,{computed:i}),s}function yn(e,s){let i=[],t=pe(e.on),o=(a,u)=>{let f=Ae(s.kinds,a,t)?.reversed===!0,[g,l]=f?["$to","$subject"]:["$subject","$to"];return u==="connect"?{connect:a,from:g,to:l}:{sever:a,from:g,to:l}};if(e.creates){let a=s.kinds[e.creates],u={};for(let f of Object.keys(a?.fields??{}))u[f]=`$${f}`;for(let f of e.effects??[])"set"in f&&!("create"in f)&&F(f.target)==="new"&&Object.assign(u,f.set);i.push({create:e.creates,as:"new",set:u})}if(e.sets&&i.push({set:e.sets}),e.writes&&!(e.creates&&e.on===void 0)&&i.push({set:Object.fromEntries(e.writes.map(a=>[a,`$${a}`]))}),e.connects&&(e.replaces&&i.push({replace:e.replaces===!0?[e.connects]:[...e.replaces],keep:e.connects}),i.push(o(e.connects,"connect"))),e.severs&&i.push(o(e.severs,"sever")),e.setsOther&&(e.connects||e.severs)&&i.push({set:e.setsOther,target:"$to"}),e.setsLinked&&t.length>0)for(let[a,u]of Object.entries(e.setsLinked))i.push({set:u,through:a});return e.removes&&i.push({remove:"$subject"}),e.effects&&i.push(...e.effects.filter(a=>!(e.creates&&"set"in a&&!("create"in a)&&F(a.target)==="new"))),i}function le(e,s,i){try{let t=J(e),o=ae(t);for(let a of o.unknownFunctions)i.push(k("unknown-function",s,`"${a}" is not a function the rule language knows`,"see the rule language in the graview-invariant skill"));return t}catch(t){if(t instanceof ce){i.push(k("expression",s,t.sentence+` (at character ${t.at+1})`));return}throw t}}function Re(e,s,i){try{return ee(e)}catch(t){if(t instanceof Ye||t instanceof ce){i.push(k("template",s,(t instanceof ce,t.sentence)));return}throw t}}function _n(e){let s=[],i=new Set(Object.keys(e.kinds)),t=zn(e),o=e.acts??{},a=new Set(e.roles??[]),u=(l,r)=>me(e.kinds[l]?.edges).has(r),f=l=>Object.keys(e.kinds).some(r=>u(r,l));for(let[l,r]of Object.entries(e.kinds)){let p=`kinds.${l}`;for(let[m,d]of Object.entries(r.edges??{})){if(!Ke(d)&&d.to!=="*")for(let c of d.to)i.has(c)||s.push(k("edge-target",`${p}.edges.${m}.to`,`"${c}" is not a kind this document declares`));r.fields[m]&&s.push(k("edge-field-clash",`${p}.edges.${m}`,`"${m}" is both a field and a relation of ${l}`,"rename one of them"))}r.lifecycle&&!r.fields[r.lifecycle.field]&&s.push(k("lifecycle-field",`${p}.lifecycle.field`,`${l} has no field "${r.lifecycle.field}"`));let y=m=>r.computed!==void 0&&Object.hasOwn(r.computed,m);for(let m of r.glance??[])!r.fields[m]&&!y(m)&&s.push(k("glance-field",`${p}.glance`,`a glance at ${l} is to say "${m}", and ${l} has no field or computed field called that`,`use one of: ${[...Object.keys(r.fields),...Object.keys(r.computed??{})].join(", ")}`));s.push(...mn(l,r));for(let m of["label","describe"]){let d=r[m];if(!d)continue;let c=Re(d,`${p}.${m}`,s);for(let S of c??[])if(S.expr){for(let b of ae(S.expr).names)if(!r.fields[b]){if(y(b)){en(r,b)||s.push(k("template-field",`${p}.${m}`,`${l}'s ${b} is worked out from beyond the record, and a ${m} is said with no graph to read`,`show it in a view instead, or name a computed field worked out from ${l}'s own fields`));continue}s.push(k("template-field",`${p}.${m}`,`${l} has no field "${b}" for its ${m} to show`,m==="label"?"a label can only show the record's own fields and what they work out":void 0))}}}for(let[m,d]of Object.entries(r.derives?.set??{}))fe(d)&&"expr"in d&&le(String(d.expr),`${p}.derives.set.${m}`,s);for(let[m,d]of Object.entries(r.fields)){if(d.default!==void 0&&d.type==="enum"){let b=(d.multiple?Array.isArray(d.default)?d.default:[d.default]:[d.default]).find(v=>!d.options?.includes(String(v)));(b!==void 0||!d.multiple&&Array.isArray(d.default))&&s.push(k("default-option",`${p}.fields.${m}.default`,`"${String(b??d.default)}" is not one of ${m}'s options`))}let c=`${m}Repeat`;d.repeats&&(r.fields[c]||r.edges?.[c]||r.computed?.[c])&&s.push(k("repeat-clash",`${p}.fields.${m}.repeats`,`${l} already has "${c}", where how ${m} repeats is kept`))}}for(let[l,r]of Object.entries(o)){let p=`acts.${l}`;for(let c of pe(r.on))i.has(c)||s.push(k("act-kind",`${p}.on`,`"${c}" is not a kind this document declares`));let y=pe(r.on),m=yn(r,e);if(r.creates&&r.on===void 0&&r.writes&&i.has(r.creates)){for(let c of r.writes)if(!e.kinds[r.creates].fields[c])if(e.kinds[r.creates].computed?.[c]!==void 0)s.push(k("computed-written",`${p}.writes`,`${r.creates}'s ${c} is worked out, not written: no act can set it`,"write the stored fields it is worked out from"));else{if(u(r.creates,c))continue;s.push(k("act-field",`${p}.writes`,`${r.creates} has no field "${c}"`))}}m.length===0&&s.push(k("act-empty",p,`"${l}" does nothing`,"give it effects or a shorthand such as sets or creates"));let d=new Map;m.forEach((c,S)=>{let b=m.length-(r.effects?.length??0),v=r.effects&&S>=b?`${p}.effects.${S-b}`:p;if("create"in c){if(!i.has(c.create))s.push(k("act-kind",`${v}.create`,`"${c.create}" is not a kind this document declares`));else for(let $ of Object.keys(c.set??{}))e.kinds[c.create].fields[$]||(e.kinds[c.create].computed?.[$]!==void 0?s.push(k("computed-written",`${v}.set.${$}`,`${c.create}'s ${$} is worked out, not written: no act can set it`,"set the stored fields it is worked out from")):s.push(k("act-field",`${v}.set.${$}`,`${c.create} has no field "${$}"`)));c.as&&d.set(c.as,c.create)}else if("connect"in c||"sever"in c){let $="connect"in c?c.connect:c.sever;!t.has($)&&!f($)&&s.push(k("act-edge",`${v}.${"connect"in c?"connect":"sever"}`,`"${$}" is not a relation any kind declares`)),F(c.from)==="subject"&&y.length===0&&s.push(k("act-subject",`${p}.on`,`"${l}" acts on "$subject" but does not say which kinds it is "on"`))}else if(!("through"in c))if("set"in c){let $=F(c.target??"$subject"),C=$==="subject"?y:d.has($??"")?[d.get($)]:[];$==="subject"&&y.length===0&&s.push(k("act-subject",`${p}.on`,`"${l}" changes "$subject" but does not say which kinds it is "on"`));for(let q of Object.keys(c.set))for(let z of C)if(!(!i.has(z)||e.kinds[z].fields[q]))if(e.kinds[z].computed?.[q]!==void 0)s.push(k("computed-written",`${v}.set.${q}`,`${z}'s ${q} is worked out, not written: no act can set it`,"set the stored fields it is worked out from"));else{if(u(z,q))continue;s.push(k("act-field",`${v}.set.${q}`,`${z} has no field "${q}"`))}}else"remove"in c&&F(c.remove)==="subject"&&y.length===0&&s.push(k("act-subject",`${p}.on`,`"${l}" removes "$subject" but does not say which kinds it is "on"`));let x="set"in c&&c.set?Object.values(c.set):[],A="through"in c?`${p}.setsLinked.${c.through}`:`${v}.set`;x.forEach($=>{$&&typeof $=="object"&&!Array.isArray($)&&"expr"in $&&le($.expr,A,s)})}),r.allowedWhen&&le(r.allowedWhen,`${p}.allowedWhen`,s),r.refusal&&Re(r.refusal,`${p}.refusal`,s)}for(let[l,r]of Object.entries(e.rules??{})){let p=`rules.${l}`;r.over!=="graph"&&!i.has(r.over)&&s.push(k("rule-kind",`${p}.over`,`"${r.over}" is not a kind this document declares`));let y=r.over==="graph"?void 0:e.kinds[r.over];if(r.covers&&y){let m=ye(r.over,r.covers,d=>t.get(d),d=>i.has(d));if("problem"in m){let{key:d,message:c,fix:S}=m.problem;d==="every"?s.push(k("rule-kind",`${p}.covers.every`,c,S)):s.push(k("rule-covers-relation",`${p}.covers.${d}`,c,S))}}for(let m of["when","require"]){let d=r[m];if(!d)continue;let c=le(d,`${p}.${m}`,s);if(!c)continue;let S=ae(c);for(let b of S.names)if(r.over==="graph")s.push(k("rule-name",`${p}.${m}`,`"${b}" means nothing in a rule over the whole graph`,`name a kind in "over", or use all('kind')`));else if(y&&!y.fields[b]&&!y.edges?.[b]&&y.computed?.[b]===void 0){let v=Object.keys(y.edges??{}).find(x=>x.includes("-")&&x.split("-").includes(b));s.push(k("rule-name",`${p}.${m}`,`${r.over} has no field or relation called "${b}"`,v?`"${v}" reads as a subtraction in a rule; rename the relation to one camelCase word, like "${v.replace(/-([a-z0-9])/g,(x,A)=>A.toUpperCase())}"`:void 0))}for(let b of S.edges)!t.has(b)&&!f(b)&&s.push(k("rule-edge",`${p}.${m}`,`"${b}" is not a relation any kind declares`));for(let b of S.sweeps)i.has(b)?r.over!=="graph"&&s.push(Ue("rule-cost",`${p}.${m}`,`this rule looks at every ${b} for every ${r.over}, which grows slowly as the app grows`,"walk a relation with out()/in() instead of all() where you can")):s.push(k("rule-kind",`${p}.${m}`,`"${b}" is not a kind this document declares`))}r.says&&Re(r.says,`${p}.says`,s),(r.repairs??[]).forEach((m,d)=>{!o[m.act]&&!ge(m.act)&&!$e(m.act,e.kinds)&&s.push(k("repair-act",`${p}.repairs.${d}.act`,`"${m.act}" is not an act this document declares`,we(m.act,e)))})}let g=e.policy;return g&&(g.grants.forEach((l,r)=>{if(l.roles!=="*"&&a.size>0)for(let p of l.roles)a.has(p)||s.push(k("grant-role",`policy.grants.${r}.roles`,`"${p}" is not one of the document's roles`));for(let p of["mutations","propose"]){let y=l[p];if(y!==void 0&&y!=="*")for(let m of y)!o[m]&&!ge(m)&&!$e(m,e.kinds)&&s.push(k("grant-act",`policy.grants.${r}.${p}`,`"${m}" is not an act this document declares`,we(m,e)))}}),(g.sees??[]).forEach((l,r)=>{for(let p of l.kinds)i.has(p)||s.push(k("sight-kind",`policy.sees.${r}.kinds`,`"${p}" is not a kind this document declares`));if(l.roles!=="*"&&a.size>0)for(let p of l.roles)a.has(p)||s.push(k("sight-role",`policy.sees.${r}.roles`,`"${p}" is not one of the document's roles`))})),s.push(...Qe(e)),s}function In(e){return e.label?[...e.label.matchAll(/\{\s*([A-Za-z_][A-Za-z0-9_]*)/g)].map(s=>s[1]):[ke(e)??[]].flat()}function Kn(e,s,i,t){let o=new Map,a=pe(e.on),u=new Map,f=new Map;(a.length>0||s.some(d=>"remove"in d&&F(d.remove)==="subject"||"from"in d&&(F(d.from)==="subject"||F(d.to)==="subject")||"set"in d&&!("create"in d)&&!("through"in d)&&F(d.target??"$subject")==="subject"||"through"in d))&&o.set(he,{ref:a.length>0?a:"*",required:!0});let l=e.args??{},r=e.writes?.length===1,p=(d,c)=>c&&d.type===c.type&&d.min===void 0&&d.max===void 0&&d.step===void 0?{...d,...c.min===void 0?{}:{min:c.min},...c.max===void 0?{}:{max:c.max},...c.step===void 0?{}:{step:c.step}}:d,y=(d,c)=>c&&d.type===c.type&&d.format===void 0&&d.unit===void 0?{...p(d,c),...c.format?{format:c.format}:{},...c.unit?{unit:c.unit}:{}}:p(d,c),m=(d,c,S)=>{if(d===he||Nn.has(d)||u.has(d)||o.has(d))return;let b=l[d]?y(l[d],S):void 0;o.set(d,b?{field:b,optional:!b.required,required:!!b.required}:c())};for(let d of s)if("create"in d){let c=i.kinds[d.create],S=c?gn(c,In(c)):[],b=v=>S.includes(v)?S.indexOf(v):S.length;for(let[v,x]of Object.entries(d.set??{}).sort(([A],[$])=>b(A)-b($))){let A=F(x),$=c?.fields[v];if(A&&$){let C=!!$.required&&$.default===void 0;m(A,()=>({field:$,optional:!C,required:C}),$)}}d.as&&u.set(d.as,d.create)}else if("connect"in d||"sever"in d){let c="connect"in d?d.connect:d.sever,S=t.get(c),b=F(d.from)==="subject"&&a.length>0?a.map(x=>Q(i.kinds[x]?.edges)[c]?.to):[],v=b.length>0&&b.every(Boolean)?b.includes("*")?"*":[...new Set(b.flat())]:void 0;for(let[x,A]of[["from",d.from],["to",d.to]]){let $=F(A);if(!$)continue;let C=x==="to"?v??S?.to??"*":S?.from??"*";C!=="*"&&!f.has($)&&f.set($,C),m($,()=>({ref:C,required:!0}))}}else if("through"in d){let c=Ae(i.kinds,d.through,a),S=c&&c.kinds!=="*"?c.kinds[0]:void 0;for(let[b,v]of Object.entries(d.set)){let x=F(v);if(!x||x==="to")continue;let A=S?i.kinds[S]?.fields[b]:void 0;m(x,()=>A?{field:A,optional:!0,required:!1}:{any:!0,required:!1},A)}}else if("set"in d){let c=F(d.target??"$subject"),S=c==="subject"?a[0]:u.get(c??"")??f.get(c??"")?.[0];c&&c!=="subject"&&!u.has(c)&&m(c,()=>({ref:"*",required:!0}));for(let[b,v]of Object.entries(d.set)){let x=F(v);if(!x)continue;let A=S?i.kinds[S]?.fields[b]:void 0;m(x,()=>A?{field:A,optional:!r,required:r}:{any:!0,required:!1},A)}}else if("remove"in d){let c=F(d.remove);c&&m(c,()=>({ref:"*",required:!0}))}for(let[d,c]of Object.entries(l))o.has(d)||o.set(d,{field:c,optional:!c.required,required:!!c.required});return o}function Wt(e,s={}){let i=Mn(e);if(!i.document||ze(i.findings))return{ok:!1,findings:i.findings};let t=i.document,o=[...i.findings];s.previous&&o.push(...Gn(t,s.previous));let a=Ln(t,o);return ze(a.findings)?{ok:!1,findings:a.findings}:We(a,s)}function de(e,s,i){return e.map(t=>{if(t.format||t.expr?.t!=="ident")return t;let o=t.expr.name,a=i?.[o],u=s?.[o]??(typeof a=="object"?a:void 0),f=u?.format;return f==="money"||f==="percent"?{...t,format:f,...f==="money"&&u?.places===0?{formatArgs:["0"]}:{}}:t})}function Pn(e,s,i){let t=i.kinds[e]?.edges?.[s.via]!==void 0?"to":"from",o=i.kinds[s.from],a=[],u={};for(let[f,g]of Object.entries(s.set))if(fe(g)&&"expr"in g){let l=J(g.expr);a.push([f,{expr:l}]),l.t==="ident"&&o?.fields[l.name]&&(u[f]=l.name)}else a.push([f,{value:typeof g=="string"&&g.startsWith("$$")?g.slice(1):g}]);return{from:s.from,via:s.via,sourceEnd:t,set:a,back:u}}function Ln(e,s){let i=zn(e),t={},o=un(e.connections,e.kinds);for(let[r,p]of Object.entries(e.kinds)){let y=ke(p),m=p.label??(y?`{${y}}`:void 0),d=se(p),c=d?pn(e,r,[...d]):[];t[r]={...m?{label:de(ee(m),p.fields,p.computed)}:{},...p.describe?{describe:de(ee(p.describe),p.fields,p.computed)}:{},...d?{computed:[...d]}:{},...c.length>0?{durations:c}:{},...o.has(r)?{keptInStep:o.get(r)}:{},...p.derives?{derives:Pn(r,p.derives,e)}:{}}}let a={};for(let[r,p]of Object.entries(e.acts??{})){let y=yn(p,e),m=Kn(p,y,e,i),d=p.destructive??y.some(z=>"remove"in z||"sever"in z||"replace"in z),c=[...new Set(y.flatMap(z=>"create"in z?[z.create]:[]))],S=[...new Set(y.flatMap(z=>"connect"in z?[z.connect]:[]))],b=[...new Set(y.flatMap(z=>"sever"in z?[z.sever]:"replace"in z?z.replace:[]))],v=[...new Set(y.flatMap(z=>"set"in z&&!("create"in z)&&!("through"in z)&&F(z.target??"$subject")==="subject"?Object.keys(z.set):[]))],x=new Map;for(let z of y){if(!("connect"in z)&&!("sever"in z))continue;let E=i.get("connect"in z?z.connect:z.sever);for(let[M,ie]of[["from",z.from],["to",z.to]]){let W=F(ie),V=M==="to"?E?.to:E?.from;W&&W!=="subject"&&V&&V!=="*"&&x.set(W,[...new Set([...x.get(W)??[],...V])])}}let A={};for(let z of y){if(!("set"in z)||"create"in z||"through"in z)continue;let E=F(z.target??"$subject");for(let M of E&&E!=="subject"&&x.get(E)||[])A[M]=[...new Set([...A[M]??[],...Object.keys(z.set)])]}let $={};for(let z of y)if(!(!("set"in z)||"create"in z||"through"in z||F(z.target??"$subject")!=="subject"))for(let[E,M]of Object.entries(z.set??{}))typeof M=="string"&&F(M)===void 0||typeof M=="number"||typeof M=="boolean"?$[E]=typeof M=="string"&&M.startsWith("$$")?M.slice(1):M:delete $[E];let C=c.length===0&&y.every(z=>!("set"in z)||!z.set||Object.values(z.set).every(E=>!(E&&typeof E=="object"&&!Array.isArray(E)&&"expr"in E))),q=new Map;for(let z of y)if(!(!("set"in z)||!z.set))for(let E of Object.values(z.set))E&&typeof E=="object"&&!Array.isArray(E)&&"expr"in E&&q.set(E.expr,J(E.expr));a[r]={title:p.title??r.replace(/-/g," "),effects:y,args:[...m],...p.allowedWhen?{guard:J(p.allowedWhen)}:{},...p.refusal?{refusal:de(ee(p.refusal),e.kinds[[p.on??[]].flat()[0]??""]?.fields)}:{},exprs:[...q],destructive:d,idempotent:C,creates:c,connects:S,severs:b,writes:v,writesOther:A,sets:$}}let u={};for(let[r,p]of Object.entries(e.rules??{})){let y=p.covers&&p.over!=="graph"?ye(p.over,p.covers,m=>i.get(m),m=>m in e.kinds):void 0;u[r]={title:p.title??r.replace(/-/g," "),...p.require?{require:J(p.require)}:{},...y&&"plan"in y?{covers:y.plan}:{},...p.when?{when:J(p.when)}:{},...p.says?{says:de(ee(p.says),e.kinds[p.over]?.fields)}:{}}}let f=Ze(e,s),g=Je(e),l=Xe(e);return{format:He,document:e,findings:s,kinds:t,...e.computed?{facts:[...se(e)??[]]}:{},edges:[...i].map(([r,{from:p,to:y,cardinality:m}])=>[r,{from:p,to:y,cardinality:m}]),acts:a,rules:u,brand:f,...Object.keys(g).length>0?{viewSpecs:g}:{},...l?{home:l}:{}}}function Yt(e,s,i){let t=/^defineNode\("([^"]+)"\)/.exec(s)?.[1],o=t?i.kinds[t]:void 0;if(!t||!o)return e;let a=Object.keys(o.fields).filter(u=>u!=="label").slice(0,3);return{...e,path:`kinds.${t}.glance`,fix:`Say which: "glance": [${a.map(u=>`"${u}"`).join(", ")}] on kinds.${t} \u2014 the facts a person compares one by, at a glance.`}}function Gn(e,s){let i=[],t=new Set(Object.values(s.kinds).flatMap(o=>Object.keys(o.edges??{})));for(let[o,a]of Object.entries(e.kinds)){let u=a.renamedFrom;u&&!s.kinds[u]&&i.push(k("renamed-from-nothing",`kinds.${o}.renamedFrom`,`${o} says it was ${u}, and the previous version has no kind called ${u}`,"name the kind it was, or drop renamedFrom"));let f=s.kinds[u??o];for(let[g,l]of Object.entries(a.fields)){let r=l.renamedFrom;r&&!f?.fields[r]&&i.push(k("renamed-from-nothing",`kinds.${o}.fields.${g}.renamedFrom`,`${g} says it was ${r}, and the previous ${u??o} has no field called ${r}`,"name the field it was, or drop renamedFrom"))}for(let[g,l]of Object.entries(a.edges??{})){let r=l.renamedFrom;r&&!t.has(r)&&i.push(k("renamed-from-nothing",`kinds.${o}.edges.${g}.renamedFrom`,`${g} says it was ${r}, and the previous version has no relation called ${r}`,"name the relation it was, or drop renamedFrom"))}}return i}export{Mn as a,Ht as b,yn as c,Wt as d,Yt as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk.MIE4TJRW.js";import{o as P}from"./chunk.5LJVOLKR.js";import"./chunk.OJGHDWI6.js";import"./chunk.OWFS2YDQ.js";import"./chunk.WSDJPXJD.js";import"./chunk.F4VB6Q2W.js";import"./chunk.FFOD5B4B.js";import"./chunk.Z7Y3R3YR.js";import"./chunk.YXEO3Y65.js";import"./chunk.U3HERHAI.js";import"./chunk.FBILPNGH.js";import{G as A,W as S,fa as b}from"./chunk.MODLZJD4.js";import"./chunk.SDO3U72B.js";import{Ja as w,sd as x,wa as L}from"./chunk.6HY6ZGEE.js";import"./chunk.FQLNBIQ5.js";import{b as R}from"./chunk.AJZBJBMO.js";var u=R(A(),1);var n=R(S(),1),C={kind:"human"},p={color:"var(--graview-ink-muted)"};function I(e){if(e){if(/^https?:\/\//i.test(e))try{return new URL(e).href}catch{return}return L(e)?e:void 0}}function z(e){let o=b(),t=o?.linkedReads,[i,a]=(0,u.useState)(()=>t?t.answered(e)??"asking":null);return(0,u.useEffect)(()=>{if(!t){a(o?.linkedRecords?"asking":null);return}let d=t.answered(e);if(a(d===void 0?"asking":d),d!==void 0)return;let s=!0;return t.ask(e).then(l=>s&&a(l)),()=>{s=!1}},[t,o?.linkedRecords,e.address,e.kind,e.id]),i}function V({reference:e,as:o}){let t=b(),i=z(e),a={position:"relative",zIndex:x.raised,overflowWrap:"anywhere",minWidth:0,maxWidth:"100%"};if(i==="asking")return(0,n.jsx)("span",{"data-graview-linked":"","data-graview-linked-state":"asking","aria-busy":"true",style:{...p,...a},children:"Linked record"});if(i&&"denied"in i)return(0,n.jsx)("span",{"data-graview-linked":"","data-graview-linked-state":"denied",style:{...p,fontStyle:"italic",...a},children:"linked record (no access)"});if(!i)return(0,n.jsx)("span",{"data-graview-linked":"","data-graview-linked-state":"missing",style:{...p,fontStyle:"italic",...a},children:"linked record (not found)"});let d=I(i.href),s=t?.linkedRecords,l=t?.principal??C,g=s?.open?c=>{c.metaKey||c.ctrlKey||(c.preventDefault(),s.open(e,l))}:void 0,k=(0,n.jsx)("a",{"data-graview-linked-title":"",...d?{href:d}:{role:"link",tabIndex:0},...g?{onClick:g,onKeyDown:c=>!d&&(c.key==="Enter"||c.key===" ")?g(c):void 0}:{},style:{fontWeight:600,color:"inherit",textUnderlineOffset:3,cursor:d||g?"pointer":"default"},children:i.label});return o==="chip"?(0,n.jsx)("span",{"data-graview-linked":"","data-graview-linked-state":"found",title:i.describe,style:{display:"inline-flex",alignItems:"center",minHeight:24,...a},children:k}):(0,n.jsx)(D,{record:i,title:k,base:a})}function D({record:e,title:o,base:t}){return(0,n.jsxs)("span",{"data-graview-linked":"","data-graview-linked-state":"found",style:{display:"grid",gap:2,padding:"8px 10px",border:"1px solid var(--graview-line)",borderRadius:"var(--graview-radius-sm, 6px)",background:"var(--graview-surface)",...t},children:[(0,n.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"2px 8px"},children:[o,e.app?(0,n.jsxs)("span",{"data-graview-linked-app":"",style:{...p,fontSize:"0.75rem"},children:["in ",e.app]}):null]}),e.describe?(0,n.jsx)("span",{"data-graview-linked-describe":"",style:{...p,fontSize:"0.8125rem"},children:e.describe}):null,e.card&&e.card.length>0?(0,n.jsx)("span",{"data-graview-linked-card":"",style:{display:"flex",flexWrap:"wrap",gap:"2px 12px",fontSize:"0.8125rem"},children:e.card.map(i=>(0,n.jsxs)("span",{children:[(0,n.jsx)("span",{style:p,children:i.label})," ",i.text]},i.label))}):null]})}function H({relation:e,refs:o,as:t="record",nodeId:i,field:a,style:d}){let s=(0,n.jsx)("span",{"data-graview-linked-list":"",style:{display:"grid",gap:6,minWidth:0,...d},children:o.map(l=>(0,n.jsx)(V,{reference:l,as:t},w(l)))});return i&&a?(0,n.jsx)(K,{nodeId:i,field:a,relation:e,refs:o,drawn:s}):s}function K({nodeId:e,field:o,relation:t,refs:i,drawn:a}){let{fields:d,commit:s}=P(e),l=d.find(f=>f.field===o),[g,k]=(0,u.useState)(!1);if(!l)return a;let c=t.cardinality==="one"?i[0]?w(i[0]):void 0:i.map(w);return(0,n.jsxs)("span",{style:{display:"grid",gap:6,minWidth:0},children:[a,g?(0,n.jsx)(N,{relation:t,value:c,label:"Link another record",onChange:f=>{s(l,f),k(!1)},onCancel:()=>k(!1)}):(0,n.jsx)("button",{type:"button","data-graview-linked-change":"",onClick:()=>k(!0),style:{justifySelf:"start",font:"inherit",fontSize:"0.8125rem",background:"none",border:0,padding:"4px 0",color:"var(--graview-accent)",cursor:"pointer",minHeight:24},children:"Change"})]})}function N({relation:e,value:o,onChange:t,onCancel:i,label:a}){let d=b(),s=d?.linkedRecords,l=d?.principal??C,g=(0,u.useId)(),[k,c]=(0,u.useState)(""),[f,m]=(0,u.useState)("asking");(0,u.useEffect)(()=>{if(!s)return;let r=!0;m("asking");let y=setTimeout(()=>{Promise.resolve().then(()=>s.find({address:e.address,kinds:e.kinds,query:k,limit:20},l)).then(h=>r&&m(Array.isArray(h)?h:"denied"),()=>r&&m([]))},150);return()=>{r=!1,clearTimeout(y)}},[s,e.address,e.kinds.join(","),k,l.kind,l.id]);let v=new Set([o].flat().filter(r=>typeof r=="string")),W=r=>{let y=w(r);if(e.cardinality==="one")return t(y);t(v.has(y)?[...v].filter(h=>h!==y):[...v,y])};return s?(0,n.jsxs)("span",{"data-graview-linked-picker":"",style:{display:"grid",gap:6,minWidth:0},children:[(0,n.jsx)("label",{htmlFor:g,style:{...p,fontSize:"0.8125rem"},children:a}),(0,n.jsx)("input",{id:g,type:"search",value:k,placeholder:`Find one in ${e.address}`,onChange:r=>c(r.target.value),style:{font:"inherit",minHeight:32,padding:"4px 8px",border:"1px solid var(--graview-line)",borderRadius:6,background:"var(--graview-surface)",color:"inherit",minWidth:0}}),f==="asking"?(0,n.jsx)("span",{"aria-busy":"true",style:p,children:"Looking\u2026"}):f==="denied"?(0,n.jsx)("span",{"data-graview-linked-state":"denied",style:{...p,fontStyle:"italic"},children:"linked record (no access)"}):f.length===0?(0,n.jsx)("span",{style:p,children:"Nothing there matches."}):(0,n.jsx)("ul",{role:"list",style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:4},children:f.map(r=>{let y=v.has(w(r));return(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button","data-graview-linked-candidate":w(r),"aria-pressed":y,onClick:()=>W(r),style:{display:"grid",gap:2,width:"100%",textAlign:"start",font:"inherit",padding:"6px 8px",minHeight:32,border:"1px solid var(--graview-line)",borderRadius:6,background:y?"var(--graview-accent-soft, var(--graview-surface))":"var(--graview-surface)",color:"inherit",cursor:"pointer"},children:[(0,n.jsx)("span",{style:{fontWeight:600},children:r.label}),r.describe?(0,n.jsx)("span",{style:{...p,fontSize:"0.8125rem"},children:r.describe}):null]})},w(r))})}),i?(0,n.jsx)("button",{type:"button",onClick:i,style:{justifySelf:"start",font:"inherit",fontSize:"0.8125rem",background:"none",border:0,padding:"4px 0",color:"var(--graview-ink-muted)",cursor:"pointer",minHeight:24},children:"Keep it as it is"}):null]}):(0,n.jsxs)("span",{"data-graview-linked-picker":"","data-graview-linked-state":"no-host",style:p,children:["This page cannot read ",e.address,", so nothing there can be linked here."]})}var T=e=>(0,n.jsx)(H,{...e}),U=e=>(0,n.jsx)(N,{...e});export{N as LinkedPicker,H as LinkedRecordView,U as drawLinkedPicker,T as drawLinkedRecord};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk.KHRS2SKB.js";import"./chunk.T6PU3NKP.js";import"./chunk.U3ED7W2U.js";import"./chunk.OPTYYIGC.js";import{a as x,b as P,c as L}from"./chunk.HOCD7KIR.js";import{b as R}from"./chunk.FDZE5LTJ.js";import"./chunk.LGRVEHXT.js";import"./chunk.CTASTRQN.js";import"./chunk.DPJNGFEZ.js";import"./chunk.YNEHJWJV.js";import"./chunk.QQAZQDRW.js";import"./chunk.72ZCLEQC.js";import"./chunk.ONYBW45K.js";import"./chunk.2VR7YEJ6.js";import"./chunk.FXT5CN32.js";import"./chunk.WVLEGCRI.js";import"./chunk.LETAQTLJ.js";import"./chunk.BUVTUAB5.js";import"./chunk.HJCQ6I3S.js";import"./chunk.OJY7VJ7D.js";import"./chunk.GEFXU4VO.js";import"./chunk.7VP6Y6D2.js";import"./chunk.WSO7JOW5.js";import"./chunk.XOE4KNP2.js";import"./chunk.25VJPUDH.js";import"./chunk.TXHYGFIZ.js";import"./chunk.WAB3L3ZI.js";import"./chunk.W53YNBSM.js";import"./chunk.2KFZHUAC.js";import"./chunk.V5I4GZEY.js";import"./chunk.TBY5IR7C.js";import"./chunk.FIFUMX5X.js";import"./chunk.BIDL7GQD.js";import"./chunk.V7W5AQKL.js";import"./chunk.EMFOMSMI.js";import"./chunk.QOS5T46W.js";import"./chunk.PPSYUOH7.js";import"./chunk.XOZU4OFA.js";import"./chunk.GME63ZHI.js";import"./chunk.Q5WEOX3Q.js";import"./chunk.4FCFNAA4.js";import"./chunk.4AC2QM7T.js";import"./chunk.YFVJUHAK.js";import"./chunk.JXNVNFV4.js";import"./chunk.WVUJXDXZ.js";import"./chunk.I2737CPF.js";import"./chunk.NJRLJEJY.js";import"./chunk.CVPMSPCH.js";import"./chunk.OTV5XTBB.js";import"./chunk.KBPJ7X7W.js";import"./chunk.OEIWIZCP.js";import"./chunk.MIE4TJRW.js";import{s as T}from"./chunk.5LJVOLKR.js";import"./chunk.OJGHDWI6.js";import"./chunk.OWFS2YDQ.js";import"./chunk.WSDJPXJD.js";import"./chunk.F4VB6Q2W.js";import"./chunk.FFOD5B4B.js";import"./chunk.Z7Y3R3YR.js";import"./chunk.YXEO3Y65.js";import"./chunk.U3HERHAI.js";import"./chunk.FBILPNGH.js";import{G as S,I as $,W as p,ea as C,ga as A}from"./chunk.MODLZJD4.js";import"./chunk.SDO3U72B.js";import{ka as v,td as k}from"./chunk.6HY6ZGEE.js";import"./chunk.FQLNBIQ5.js";import{b as i}from"./chunk.AJZBJBMO.js";var r=i(S(),1);var l=i(S(),1);var g=i(p(),1);var m={font:"inherit",fontSize:"0.875rem",minHeight:24,padding:0,border:0,borderRadius:2,background:"transparent",boxShadow:"none",color:"var(--graview-accent)",textDecoration:"underline",textUnderlineOffset:3,textAlign:"start",cursor:"pointer"};var e=i(p(),1);function Q({page:n=!1,go:E,onPick:y,onDiscard:N}){let{store:d,seatTalk:c}=C(),u=$(c),D=L(),h=E??D,{keep:M}=x(h),[H,f]=(0,r.useState)(!1);A();let t=u.draft;(0,r.useEffect)(()=>f(!1),[t]),(0,r.useEffect)(()=>{n||P(!1)},[n]);let w=(0,r.useRef)(null),b=t!==null&&!n;if((0,r.useLayoutEffect)(()=>{let s=w.current;if(!b||!s?.parentElement)return;let o=[];for(let a=s.previousElementSibling;a;a=a.previousElementSibling)a instanceof HTMLElement&&!a.inert&&a.tagName!=="STYLE"&&(a.inert=!0,o.push(a));return()=>{for(let a of o)a.inert=!1}},[b]),!t)return null;let G=R(t.drawn),F=d.schema.tryDefinition(t.kind),O=d.graph.nodesOfKind(t.kind).filter(s=>v(F,s)),q=()=>{c.setDraft(null),N?.()};return(0,e.jsxs)("section",{ref:w,"data-testid":"draft-frame","data-graview-draft-frame":n?"page":"scene","aria-label":`Draft: ${t.title}`,style:n?{display:"grid",gap:12,minWidth:0}:{position:"absolute",inset:12,zIndex:k("rail"),display:"grid",gridTemplateRows:"auto auto minmax(0, 1fr)",background:"var(--graview-panel)",border:"1px solid var(--graview-edge)",borderRadius:12,boxShadow:"var(--graview-lift-high)",overflow:"hidden",minHeight:0},children:[(0,e.jsxs)("p",{"data-testid":"draft-line",style:{...z,...n?{}:{padding:"10px 16px"}},children:[n?(0,e.jsx)("span",{children:"Draft"}):(0,e.jsxs)("span",{children:["Draft \u2014 ",(0,e.jsx)("span",{"data-testid":"draft-title",style:{color:"var(--graview-ink)",fontWeight:600},children:t.title})]}),(0,e.jsx)("span",{"aria-hidden":"true",children:"\xB7"}),(0,e.jsx)("button",{type:"button","data-testid":"draft-keep",disabled:H,title:`Keep \u201C${t.title}\u201D as a lens: a place of its own`,onClick:()=>{f(!0),M(t).finally(()=>f(!1))},style:m,children:"Keep as a lens"}),(0,e.jsx)("span",{"aria-hidden":"true",children:"\xB7"}),(0,e.jsx)("button",{type:"button","data-testid":"draft-discard",onClick:q,style:m,children:"Discard"})]}),u.draftNote?(0,e.jsx)("p",{"data-testid":"draft-note",role:"status",style:{margin:0,padding:n?0:"0 16px 8px",fontSize:"0.8125rem",color:"var(--graview-warn)"},children:u.draftNote}):(0,e.jsx)("span",{}),(0,e.jsx)("div",{"data-testid":"draft-lens","data-graview-draft":t.lens.name,role:"group","aria-label":t.title,tabIndex:0,style:n?{height:"min(72vh, 760px)",display:"grid",gridTemplateRows:"minmax(0, 1fr)",overflow:"auto",scrollbarGutter:"stable",border:"1px solid var(--graview-edge)",borderRadius:12,background:"var(--graview-panel)"}:{minHeight:0,overflow:"auto",scrollbarGutter:"stable",display:"grid",gridTemplateRows:"minmax(0, 1fr)"},onClick:s=>{let o=s.target?.closest("[data-graview-pick]")?.getAttribute("data-graview-pick");if(!o||!d.graph.getNode(o))return;s.preventDefault();let a=d.graph.getNode(o);y?(c.setDraft(null),y(o)):h({to:"record",id:o,kind:a.kind,label:o,address:"",said:""})},children:(0,e.jsx)(T,{kind:t.kind,view:t.title,children:(0,e.jsx)(G,{nodes:O,label:t.title,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1})})})]})}var z={margin:0,display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"4px 8px",fontSize:"0.875rem",color:"var(--graview-ink-muted)",borderBottom:"1px solid var(--graview-edge)",paddingBottom:8};export{Q as DraftFrame};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{sd as d}from"./chunk.6HY6ZGEE.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";var m="data-graview-refused-note",u=`position:absolute;z-index:${d.over};box-sizing:border-box;margin:0;padding:4px 8px;max-width:min(40ch,calc(100% - 8px));border-radius:6px;font:inherit;font-size:0.8125rem;line-height:1.35;color:var(--graview-ink,CanvasText);background:var(--graview-panel,Canvas);border:1px solid var(--graview-danger,#b42318);box-shadow:0 2px 8px rgb(0 0 0 / 0.12);pointer-events:none;overflow-wrap:anywhere`;function v(s){let n=new Map,p=0,a=(t,o)=>{let e=s.host.getBoundingClientRect(),r=t.getBoundingClientRect(),f=o.offsetWidth,i=o.offsetHeight,g=Math.max(4,Math.min(r.left-e.left,e.width-f-4)),c=r.bottom-e.top+4,h=c+i<=e.height||r.top-e.top-i-4<0?c:r.top-e.top-i-4;o.style.left=`${Math.round(g)}px`,o.style.top=`${Math.round(h)}px`},l={say(t,o){l.clear(t);let e=s.ownerDocument.createElement("p");e.setAttribute(m,""),e.setAttribute("role","status"),e.id=`graview-refused-${p+=1}`,e.setAttribute("style",u),e.textContent=o,s.appendChild(e),n.set(t,e),a(t,e)},clear(t){let o=n.get(t);o&&(o.remove(),n.delete(t))},refresh(){for(let[t,o]of n)t.isConnected?a(t,o):(o.remove(),n.delete(t))}};return l}export{v as createRefusalNotes};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as Q,b as Ie,c as Le,f as le,h as He}from"./chunk.T6DPWW2K.js";import"./chunk.CEVGND3Y.js";import{b as $e,c as De,d as xe,e as re,f as Ee,g as se,h as ae,i as je,j as ie,l as Me,m as Be,n as qe,o as Fe,p as de}from"./chunk.JMYUQNXN.js";import"./chunk.NYLKG25K.js";import{a as Ce}from"./chunk.TBY5IR7C.js";import{d as Re}from"./chunk.QFHWG4LN.js";import"./chunk.YIPXZUTT.js";import"./chunk.BJUUSIQY.js";import"./chunk.PPSYUOH7.js";import"./chunk.XOZU4OFA.js";import"./chunk.GME63ZHI.js";import"./chunk.NJRLJEJY.js";import"./chunk.MIE4TJRW.js";import{x as Oe}from"./chunk.5LJVOLKR.js";import"./chunk.OJGHDWI6.js";import"./chunk.OWFS2YDQ.js";import"./chunk.WSDJPXJD.js";import"./chunk.F4VB6Q2W.js";import"./chunk.FFOD5B4B.js";import"./chunk.Z7Y3R3YR.js";import"./chunk.YXEO3Y65.js";import"./chunk.U3HERHAI.js";import"./chunk.FBILPNGH.js";import{G as tn,W as Ae,ea as Te}from"./chunk.MODLZJD4.js";import"./chunk.SDO3U72B.js";import"./chunk.6HY6ZGEE.js";import"./chunk.FQLNBIQ5.js";import{b as oe}from"./chunk.AJZBJBMO.js";var p=oe(tn(),1);var q=oe(Ae(),1),R=t=>(t??"").replace(/\s+/g," ").trim(),ce=()=>new Promise(t=>requestAnimationFrame(()=>t())),on=t=>new Promise(s=>setTimeout(s,t));function rn(t){let s=t.cloneNode(!0);for(let r of s.querySelectorAll("span"))r.remove();return R(s.textContent).replace(/^[▸▾]\s*/,"")}function Ne(t){if(!t||!t.isConnected)return"";let s=t.innerText??t.textContent??"";return`${t.querySelectorAll("*").length}|${R(s)}`}function sn(t,s=80){if(!t)return"";let r=[],d=new Set,g="li, tr, article, [data-graview-listed], [data-graview-record], [data-graview-field]";for(let l of t.querySelectorAll(`h1, h2, h3, h4, ${g}`)){if(r.length>=s)break;if([...d].some(c=>c.contains(l))||l.closest("[data-graview-popover], [hidden], nav, [aria-hidden='true']"))continue;let a=/^h([1-4])$/i.exec(l.localName),i=(a?rn(l):R(l.innerText??l.textContent)).slice(0,140);if(i)if(a)r.push(`${"#".repeat(Number(a[1]))} ${i}`);else{let c=l.getAttribute("data-graview-field");r.push(c?`${c}: ${i}`:`- ${i}`),d.add(l)}}return r.join(`
|
|
2
|
+
`)}function an(t,s){let{store:r}=t,d=l=>Object.fromEntries(Object.entries(l).filter(([,a])=>a!==void 0&&typeof a!="object").map(([a,i])=>[a,typeof i=="string"?i.slice(0,80):i]));return{kinds:(s.kind?[s.kind]:r.schema.kinds.slice(0,6)).map(l=>{let a=r.graph.nodesOfKind(l),i=r.schema.tryDefinition(l);return{kind:l,count:a.length,fields:Object.keys(i?.fields?.shape??{}),relations:Object.keys(i?.edges??{}),some:(s.record?a.filter(c=>c.id===s.record):a.slice(0,3)).map(d)}})}}function dn(t,s){let r=t.store.schema,d=new Set,g=new Set;for(let l of r.definitions)for(let[a,i]of Object.entries(l.edges??{})){let c=Array.isArray(i?.to)?i.to:[];if(s.kind===void 0||l.kind===s.kind||c.includes(s.kind)){g.add(a);for(let S of[l.kind,...c])S!==s.kind&&r.tryDefinition(S)&&d.add(S)}}if(s.kind===void 0)for(let l of r.kinds)d.add(l);return{kinds:[...d],edges:[...g]}}var Ke={manifest:"The view could not start: what it reads is not this app's.",source:"The script is too long: make it shorter.",start:"The script did not start: it must be one plain script, with no syntax errors, that calls graview.onProps and graview.render.",error:"The script threw while drawing: read only what props gives (props.nodes for a list, props.node for one record), guard each value that may be missing, and call no function that does not exist."};async function Ve(t,s,r=15e3){let d=Date.now()+r;for(;Date.now()<d;){for(let l of document.querySelectorAll("[data-worker-view-place]")){let a=Oe(l),i=a?.name===t?a.drawing().root:void 0;if(a&&l.isConnected&&i?.isConnected&&i.childElementCount>0&&(s===void 0||await a.source()===s))return{element:l,handle:a}}let g=document.querySelector(`[data-worker-view-fell-back="${CSS.escape(t)}"]`);if(g)return{failed:Ke[g.getAttribute("data-worker-view-failed")??""]??Ke.error};await on(80)}return{failed:"The view did not draw in time: keep it simple and quick to draw."}}var ue=new Map,ln=(t,s)=>{let r=ue.get(t);return r||ue.set(t,r={phase:s(),steps:[],before:!1,putBack:null,began:!1,original:null,markup:null,talk:[],events:[],since:Date.now(),stop:null,covering:!1,pointed:null,about:null,kept:null,pressed:null,version:0,heard:new Set}),r};function cn(t,s,r){let{store:d}=t,g=s.record?[d.graph.getNode(s.record)].filter(Boolean):s.kind?d.graph.nodesOfKind(s.kind):d.schema.kinds.flatMap(a=>d.graph.nodesOfKind(a)),l=R(r).toLowerCase();return g.map(a=>String(a.label??"")).filter(a=>a.length>1&&l.includes(R(a).toLowerCase())).slice(0,40)}function Ge(t,s){return(s.kind?[s.kind]:t.store.schema.kinds).flatMap(d=>Object.keys(t.store.schema.tryDefinition(d)?.fields?.shape??{}))}function Pn({ask:t,close:s}){let r=Te(),{ai:d,aiDesk:g,aiHere:l,session:a,principal:i,keptViews:c,store:x,onProposeChange:S,composeChange:w,onDraftChange:A,app:j}=r,o=t.part,e=(0,p.useMemo)(()=>ln(t.at,()=>t.mode==="highlight"?{at:"highlighting"}:{at:"open"}),[t]),H=(0,p.useCallback)(n=>(e.heard.add(n),()=>void e.heard.delete(n)),[e]),T=(0,p.useSyncExternalStore)(H,()=>e.phase,()=>e.phase),ze=(0,p.useSyncExternalStore)(H,()=>e.version,()=>e.version),P=(0,p.useCallback)(()=>{e.version+=1,e.heard.forEach(n=>n())},[e]),b=(0,p.useCallback)(n=>{e.phase=n,P()},[e,P]),C=(0,p.useCallback)(async()=>{let n=e.putBack;e.putBack=null,n&&await n()},[e]),Y=(0,p.useCallback)(()=>{e.stop?.abort(),e.stop=null,C(),ue.delete(t.at),s()},[C,t.at,s,e]),v=(0,p.useCallback)(()=>o.main?.isConnected?o.main:gn(),[o]),N={name:o.name,slot:o.slot,...o.kind?{kind:o.kind}:{},...o.group?{group:o.group}:{}},pe=o.place??(o.kind?`${o.kind}-${o.slot}`:"home"),Je=t.fromScene?`From the scene: Better UI changes how \u201C${o.name}\u201D looks on its page here, for everyone in this app.`:`This changes how ${o.name} looks for everyone in this app.`,K=(0,p.useCallback)((n,f,u,h={})=>({id:Re(),at:new Date().toISOString(),by:i,target:{on:"place",place:pe},targetLabel:o.name,ask:{kind:"section",said:n},offered:[],outcome:f,stages:u.map(m=>({stage:m.stage,ms:m.ms,model:m.model})),usage:u.flatMap(m=>m.usage?[{tier:m.stage==="light"?"fast":"thinking",model:m.model,inputTokens:m.usage.inputTokens,outputTokens:m.usage.outputTokens}]:[]),...h}),[i,pe,o.name]),ge=S!==void 0&&w!==void 0&&Ce(x,i),M=(0,p.useMemo)(()=>pn(r,o),[r,o]),$=qe(N,dn(r,o),M.map(n=>n.act)),he=$!==void 0&&typeof c?.fork=="function"&&typeof c.draftFork=="function"&&c.current().may.views===!0,me=o.slot==="record"?{page:"record",kind:o.kind}:o.slot==="home"?{page:"home"}:{page:"list",kind:o.kind??""},V=(0,p.useCallback)(n=>({manifest:$,source:n,from:me,said:""}),[$,me]),we=T.at==="working";(0,p.useEffect)(()=>{if(!we)return;let n=o.record??(o.kind?`kind:${o.kind}`:null);return l({participant:`agent:graview-for-${i.id??"anyone"}:${a}`,kind:"agent",name:"Graview",...i.id?{onBehalfOf:i.id}:{},over:n,robot:{at:n,mode:"thinking"}}),()=>l(null)},[we]);let D=(0,p.useCallback)(()=>{if(e.original)return e.original;let n=v(),f=n?.innerText??"";return e.original=Q(X(n),cn(r,o,f)),e.original},[e,v,r,o]),F=(0,p.useCallback)(()=>Q(X(v()),D().records.map(n=>n.label)),[v,D]),G=(0,p.useCallback)(async n=>{if(await C(),n.kind==="spec"){let f=await A(_e(n.edits,n.said,d.name));e.putBack=f.undo}else c.draftFork(V(n.source)),e.putBack=()=>c.draftFork(null)},[C,A,e,c,V,d.name]),I=(0,p.useCallback)(async()=>{let n=e.steps.at(-1);e.before=!1,n?await G(n):await C()},[e,G,C]),y=(0,p.useCallback)((n,f)=>{e.talk.push({who:n,said:f}),P()},[e,P]),B=(0,p.useCallback)(n=>{e.events.at(-1)?.kind==="streaming"&&e.events.pop(),e.events.push(n),P()},[e,P]),z=()=>e.talk.filter(n=>n.who==="person").map(n=>n.said).join(" "),ke=(0,p.useCallback)(async n=>{if(!ge||!A)return!1;let u=(await (__graviewPreload(import.meta.url,["./chunk.W4YDPHCQ.js","./chunk.TBY5IR7C.js","./chunk.BIDL7GQD.js","./chunk.Q5WEOX3Q.js","./chunk.4FCFNAA4.js","./chunk.4AC2QM7T.js","./chunk.CVPMSPCH.js","./chunk.OTV5XTBB.js","./chunk.KBPJ7X7W.js","./chunk.OEIWIZCP.js","./chunk.6HY6ZGEE.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.BCQWAFGD.js"))).documentOfApp(j??{});if(!u)return!1;let h=e.steps.at(-1);if(h&&h.kind!=="spec")return!1;let m=h?.edits??[],k=m.length>0?w({document:u,edits:m}):void 0,L=k?.ok?k.document:u;if(!(n.mode==="just"?{can:!0}:await Me(d,n.words,N)).can)return!1;B({kind:"look",text:`Looking at how ${o.name} is set up`});let E=[],ee=await Be({ai:d,document:L,part:N,mode:n.mode==="choose"?"just":n.mode,...n.words?{words:n.words}:{},...n.pointed?{highlighted:[n.pointed.name,...n.pointed.lines]}:{},shows:sn(v(),30),judge:async U=>{let _=w({document:u,edits:[...m,...U]});return _.ok?(E=_.said,[]):[_.refused]}});if(!ee.ok)return!1;let en=[...m,...ee.edits],Pe=K(`Make \u201C${o.name}\u201D better: ${n.words}`,"offered",ee.stages),ne=Ne(v()),te={kind:"spec",edits:en,said:E[E.length-1]??E[0]??`${o.name} changed.`,entry:Pe};e.covering=!0,P();try{await G(te);let U=ne;for(let nn=Date.now()+1500;Date.now()<nn&&U===ne;)await ce(),U=Ne(v());let _=U===ne?["nothing changed"]:re(D(),F(),{fields:Ge(r,o),asked:z()});if(_.length>0)return await I(),g.record({...Pe,outcome:"failed",failed:_.join(" ")}),!1}catch{return await I(),!1}finally{e.covering=!1,P()}return e.steps.push(te),e.before=!1,B({kind:"passed",text:"Changed its settings \u2014 it's on the page"}),y("graview",`Done: ${te.said.replace(/\.$/,"")}.`),!0},[d,g,j,w,K,e,r,v,A,D,F,o,N,G,I,ge,B,y,P]),ye=(0,p.useCallback)(async n=>{if(!$||!c?.draftFork)return{findings:["This page cannot be drawn anew here."],drew:void 0};let f=D();e.covering=!0,P();try{c.draftFork(V(n)),e.putBack=()=>c.draftFork(null);let u=await Ve($.name,n),h;if("failed"in u)h=[u.failed];else{let k=[...await u.handle.check(n),...u.handle.refused()];if(k.length>0)h=k;else{await ce(),await ce();let L=u.element.closest("[data-graview-page-main], main")??X(v());h=re(f,Q(L,f.records.map(E=>E.label)),{fields:Ge(r,o),asked:z()});let O=u.handle.presses?await u.handle.presses(n).catch(()=>{}):void 0;O&&(e.pressed=O,h=[...h,...se(O,We(f,fe(r,o,f)),M.filter(E=>E.toggle).map(E=>E.act),W(o))])}}let m=de(F());if(h.length===0){let k=K(`Draw \u201C${o.name}\u201D anew: ${z()}`,"offered",[]);e.steps.push({kind:"view",source:n,said:Ee(o.name,f,F())??`${o.name} has a new design. Compare Before and After.`,entry:k}),e.before=!1}else await I();return{findings:h,drew:m}}finally{e.covering=!1,P()}},[$,c,D,e,P,V,F,r,o,K,I]),be=(0,p.useCallback)(async(n=[])=>{if(!$||!he){y("graview","Its settings can't do that, and a new design can't be drawn for it here.");return}let f=new AbortController;e.stop=f,e.markup??=Ue(v());let u=e.steps.length,h=[...e.steps].reverse().find(k=>k.kind==="view"),m=await Fe({ai:d,part:N,manifest:$,talk:e.talk,keep:un(D(),v(),o.name,r,o),...e.markup?{markup:e.markup}:{},...h?{current:h.source}:e.kept?{current:e.kept}:{},host:{look:()=>de(F()),read:()=>an(r,o),draft:ye},onEvent:k=>B(k),...e.about?{about:e.about}:{},acts:M,...n.length>0?{pressed:n}:{},noun:W(o),signal:f.signal});if(e.stop===f)if(e.stop=null,e.events.at(-1)?.kind==="streaming"&&e.events.pop(),g.record(K(`Draw \u201C${o.name}\u201D anew: ${z()}`,e.steps.length>u?"offered":"failed",m.stages,e.steps.length>u?{}:{failed:m.last?.findings.join(" ")??m.said})),m.passed){let k=e.pressed?ae(e.pressed,M,W(o)):void 0,L=je.test(m.said)?void 0:m.said;y("graview",[L??(k?void 0:"Here it is on the page."),k].filter(Boolean).join(" "))}else y("graview",m.said)},[d,g,M,F,K,he,e,r,ye,v,$,D,o,N,y,B]),ve=(0,p.useCallback)(async()=>{let f=[...e.steps].reverse().find(O=>O.kind==="view")?.source??e.kept;if(!f||!$)return[];B({kind:"look",text:"Pressing every control on the page"});let u=await Ve($.name);if("failed"in u||!u.handle.presses)return[];let h=await u.handle.presses(f).catch(()=>{});if(!h)return[];e.pressed=h;let m=D(),k=se(h,We(m,fe(r,o,m)),M.filter(O=>O.toggle).map(O=>O.act),W(o)),L=k.length>0?k:h.controls.slice(0,8).map(O=>`${O.control}: ${O.says}`);return B(k.length>0?{kind:"check",text:`Check: ${k.length} ${k.length===1?"control doesn't":"controls don't"} work \u2014 fixing`}:{kind:"passed",text:"Check: every control works"}),y("graview",k.length>0?`I pressed every control: ${k.join(" ")}`:`I pressed every control. ${ae(h,M,W(o))??"Each one did what it says."}`),L},[M,e,r,$,D,o,y,B]),J=(0,p.useCallback)(async(n,f="describe")=>{if(e.phase.at==="working")return;let u=e.pointed;e.pointed=null;let h={mode:f,words:n,...u?{pointed:u}:{}};e.about=u??e.about,y("person",n),e.events=[],e.since=Date.now(),b({at:"working"}),D(),e.markup??=Ue(v());let m=ie.test(n)?await ve().catch(()=>[]):[];!ie.test(n)&&await ke(h).catch(()=>!1)||await be(m),e.phase.at==="working"&&b(e.steps.length>0?{at:"draft"}:{at:"open"})},[be,ke,e,v,D,ve,y,b]),Z=(0,p.useCallback)(()=>{if(e.phase.at!=="working")return;let n=e.stop;e.stop=null,n?.abort(),e.covering=!1,e.steps=e.steps.filter(f=>f.entry.at<new Date(e.since).toISOString()),I(),y("graview","Stopped. The page is as it was."),b(e.steps.length>0?{at:"draft"}:{at:"open"})},[e,y,b,I]),Qe=(0,p.useCallback)(async n=>{let f=e.steps.at(-1);!f||n===e.before||(e.before=n,P(),n?await C():await G(f))},[e,C,G,P]),Xe=(0,p.useCallback)(async()=>{let n=e.steps.at(-1);if(!(!n||e.phase.at!=="draft")){b({at:"keeping"});try{let f,u;if(n.kind==="spec"){await C();let h=await S(_e(n.edits,n.said,d.name));if(h==="declined")return y("graview","It wasn't kept."),b({at:"draft"});typeof h=="object"&&([f,u]=[h.undo,h.note])}else{let h=await c.fork(V(n.source));e.putBack=null,c.draftFork?.(null),e.kept=n.source,h&&([f,u]=[h.undo,h.note])}g.record({...n.entry,outcome:"accepted"}),e.steps=[],e.before=!1,b({at:"kept",...f?{undo:f}:{},...u?{note:u}:{}})}catch{y("graview","It couldn't be kept."),b({at:"draft"})}}},[e,b,C,S,d.name,c,V,g,y]),Ye=(0,p.useCallback)(()=>{let n=e.steps.at(-1);n&&g.record({...n.entry,outcome:"dismissed"}),e.steps=[],e.before=!1,C(),y("graview","Put back as it was."),b({at:"open"})},[e,g,C,y,b]),Ze=(0,p.useCallback)(async()=>{if(!(e.phase.at!=="kept"||!e.phase.undo))try{await e.phase.undo(),e.kept=null,y("graview","Undone. The page is as it was."),b({at:"undone"})}catch{y("graview","It couldn't be put back.")}},[e,y,b]);if((0,p.useEffect)(()=>{e.began||!(t.mode==="just"||t.mode==="describe"&&t.words)||(e.began=!0,J(t.mode==="just"?"Make it easier to read at a glance":t.words,t.mode))},[e,t.mode,t.words,J]),(0,p.useEffect)(()=>{let n=f=>{if(f.key!=="Escape"||e.phase.at==="highlighting")return;if(f.preventDefault(),e.phase.at==="working")return Z();Y();let u=t.returnTo?.isConnected?t.returnTo:document.querySelector("[data-graview-page-title], main h1");u&&!u.hasAttribute("tabindex")&&!u.matches("a[href], button, input, select, textarea")&&u.setAttribute("tabindex","-1"),u?.focus?.()};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[e,Y,Z,t.returnTo]),T.at==="highlighting")return(0,q.jsx)(He,{box:v(),root:v(),whole:o.elements,wholeSaid:"The whole page",cancel:()=>b({at:"open"}),chose:n=>{e.pointed={name:xe(n)??$e(n.map(le)),lines:De(n.map(le))},b({at:"open"})}});let Se=e.steps.at(-1);return(0,q.jsxs)(q.Fragment,{children:[e.covering?(0,q.jsx)(Ie,{over:v(),name:o.name,said:`Graview is drafting \u201C${o.name}\u201D\u2026`}):null,(0,q.jsx)(Le,{name:o.name,scope:Je,phase:T.at,talk:e.talk,steps:e.events,since:e.since,working:T.at==="working"||T.at==="keeping",...Se&&T.at==="draft"?{draft:{said:Se.said,before:e.before}}:{},...T.at==="kept"?{kept:{...T.note?{note:T.note}:{},...T.undo?{undo:()=>void Ze()}:{}}}:{},about:(e.pointed??e.about)?.name??o.name,ask:n=>void J(n),just:()=>void J("Make it easier to read at a glance","just"),point:()=>b({at:"highlighting"}),stop:Z,compare:n=>void Qe(n),keep:()=>void Xe(),discard:Ye,close:Y})]})}function _e(t,s,r){return{said:s,add:[],drop:[],card:{said:s,adds:[],keeps:[],drops:[],breaking:[]},edits:t,via:`ai:${r??"model"}`}}function un(t,s,r,d,g){let l=X(s),a=g.slot==="home"?[...s?.querySelectorAll("h1")??[]].find(w=>l!==s&&!l?.contains(w)):void 0,i=R(a?.textContent)||R(l?.querySelector("[data-graview-page-title]")?.textContent)||(g.slot==="home"?"":R(l?.querySelector("h1")?.textContent))||(g.record?R(String(d.store.graph.getNode(g.record)?.label??"")):"")||r,c=fe(d,g,t),x=Object.fromEntries(t.records.flatMap(w=>w.facts?.length||w.under&&w.under!==i?[[w.label,{...c[w.label]?{id:c[w.label]}:{},...w.facts?.length?{shows:w.facts}:{},...w.under&&w.under!==i?{under:w.under}:{}}]]:[])),S=fn(d,t,c,i);return{title:i,headings:t.headings.filter(w=>w!==i),records:t.records.map(w=>w.label),...Object.keys(x).length>0?{says:x}:{},...S?{grouping:S}:{}}}function fe(t,s,r){let{store:d}=t,g=s.record?[d.graph.getNode(s.record)].filter(a=>a!==void 0):s.kind?d.graph.nodesOfKind(s.kind):d.schema.kinds.flatMap(a=>d.graph.nodesOfKind(a)),l={};for(let a of r.records){let i=g.find(c=>R(String(c.label??""))===R(a.label));i&&(l[a.label]=i.id)}return l}function fn(t,s,r,d){let{store:g}=t,l=s.records.filter(A=>A.under&&A.under!==d&&r[A.label]);if(l.length<2)return;let a=g.graph.allEdges(),i=new Map;for(let A of l){let j=r[A.label];for(let o of a){let e=o.from===j?o.to:o.to===j?o.from:void 0,H=e!==void 0?g.graph.getNode(e):void 0;if(!H||R(String(H.label??""))!==R(A.under))continue;let T=`${o.kind}\0${H.kind}\0${o.from===j?"from":"to"}`;i.set(T,(i.get(T)??0)+1)}}let c=[...i].sort((A,j)=>j[1]-A[1])[0];if(!c||c[1]<l.length/2)return;let[x,S,w]=c[0].split("\0");return{edge:x,kind:S,record:w}}var X=t=>t?.querySelector("main")??t;function Ue(t){if(!t?.isConnected)return null;let s=(t.querySelector("main")??t).cloneNode(!0);for(let d of s.querySelectorAll("script, style, svg, button, input, select, textarea, [hidden], [aria-hidden='true'], [data-graview-popover]"))d.remove();for(let d of[s,...s.querySelectorAll("*")])for(let g of[...d.getAttributeNames()])d.removeAttribute(g);let r=s.outerHTML.replace(/\s+/g," ").replace(/<(div|span)>\s*<\/\1>/g,"").trim();return r.length>6e3?r.slice(0,6e3):r}var W=t=>t.slot==="list"||t.slot==="group"?t.name.toLowerCase():t.slot==="record"?"parts":"records";function We(t,s){return t.records.flatMap(r=>s[r.label]?[{label:r.label,id:s[r.label],...r.presses?{presses:!0}:{},...r.opens?{opens:!0}:{}}]:[])}function pn(t,s){let{store:r}=t,d=s.kind?[s.kind]:r.schema.kinds,g=a=>r.schema.tryDefinition(a)?.fields?.shape??{},l=a=>{let i=a?._zod?.def;for(let c=0;c<6&&i&&i.type!=="boolean"&&i.innerType!==void 0;c++)i=i.innerType._zod?.def;return i?.type==="boolean"};return r.allMutations().flatMap(a=>{let i=a.subject;if(!i||a.creates?.length)return[];let c=d.find(w=>i.kinds==="*"||i.kinds.includes(w));if(!c)return[];let x=a.writes??[],S=x.length===1&&l(g(c)[x[0]])?x[0]:void 0;return[{act:a.name,title:String(a.title??a.name),record:i.arg,...S?{toggle:S}:{}}]}).slice(0,24)}function gn(){return document.querySelector("[data-graview-page-main], main")??document.querySelector("[data-graview-face]")}export{Pn as PageCard,Ne as drawnSignature,sn as outlineOf};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as Ie}from"./chunk.HJCQ6I3S.js";import{a as Se,b as Fe,c as Te,d as Ce}from"./chunk.OJY7VJ7D.js";import"./chunk.KACSYPEV.js";import{c as Me}from"./chunk.GEFXU4VO.js";import"./chunk.WSDJPXJD.js";import"./chunk.F4VB6Q2W.js";import"./chunk.FFOD5B4B.js";import"./chunk.Z7Y3R3YR.js";import"./chunk.YXEO3Y65.js";import{G as Qe,W as Oe}from"./chunk.MODLZJD4.js";import"./chunk.SDO3U72B.js";import"./chunk.6HY6ZGEE.js";import"./chunk.FQLNBIQ5.js";import{b as Re}from"./chunk.AJZBJBMO.js";var I=Re(Qe(),1);var O=.5,fe=1,Pe=.76,Ne=3,Ze=3,Ae=.6;function et(t){let n=De(t);for(;;){let s=n.next();if(s.done)return s.value}}function*De(t){let{ribbons:n,plots:s,cell:i}=t,u=t.tilt??.5,g=t.labels??[],k=[...s.values()],p=new Map;if(k.length===0||i<=0)return p;let R=1/0,j=1/0,E=-1/0,W=-1/0;for(let o of k)R=Math.min(R,o.col),j=Math.min(j,o.row),E=Math.max(E,o.col+o.side),W=Math.max(W,o.row+o.side);R-=3,j-=3,E+=3,W+=3;let M=Math.round((E-R)/O)+1,P=Math.round((W-j)/O)+1,H=o=>R+o*O,_=o=>j+o*O,B=4,te=(o,c)=>{if(g.length===0)return!1;let l=Me(o,c,i,u);for(let f of g)if(l.x>f.x-B&&l.x<f.x+f.width+B&&l.y>f.y-B&&l.y<f.y+f.height+B)return!0;return!1},L=(o,c)=>{for(let l of k)if(o>l.col-Pe&&o<l.col+l.side+Pe&&c>l.row-Pe&&c<l.row+l.side+Pe)return!0;return!1},A=M*P,N=new Uint8Array(A),S=new Uint8Array(A),ne=new Uint8Array(A),oe=new Uint8Array(A),G=new Uint8Array(A),re=new Uint8Array(A),V=new Float32Array(A);for(let o=0;o<P;o++){let c=_(o);for(let l=0;l<M;l++){let f=H(l),m=o*M+l;if(S[m]=L(f,c)?0:1,N[m]=S[m]&&!te(f,c)?1:0,l+1<M){let a=f+O/2;oe[m]=L(a,c)?0:1,ne[m]=oe[m]&&!te(a,c)?1:0}if(o+1<P){let a=c+O/2;re[m]=L(f,a)?0:1,G[m]=re[m]&&!te(f,a)?1:0}let e=1/0;for(let a of k)e=Math.min(e,Math.max(0,a.col-f,f-(a.col+a.side),a.row-c,c-(a.row+a.side)));V[m]=e}}let J=(o,c)=>{let l=[],f=(e,a)=>{let w=[],b=Math.min(1,a/3);for(let r=Math.ceil((e+b)/O-1e-9)*O;r<=e+a-b+1e-9;r+=O)w.push(r);return w},m=(e,a,w,b)=>{let r=Math.round((e-R)/O),d=Math.round((a-j)/O);r>=0&&d>=0&&r<M&&d<P&&c[d*M+r]&&l.push({i:r,j:d,out:w,curb:b})};for(let e of f(o.row,o.side))m(o.col-fe,e,1,{col:o.col,row:e}),m(o.col+o.side+fe,e,0,{col:o.col+o.side,row:e});for(let e of f(o.col,o.side))m(e,o.row-fe,3,{col:e,row:o.row}),m(e,o.row+o.side+fe,2,{col:e,row:o.row+o.side});return l};yield;let se=new Uint8Array(A),ie=new Uint8Array(A),le=[[1,0],[-1,0],[0,1],[0,-1]],ae=[1,0,3,2],D=A*4,X=new Float64Array(D),F=[new Int32Array(D),new Int32Array(D)],U=new je,ge=(o,c,l,f,m)=>{let e=l?N:S,a=l?ne:oe,w=l?G:re,b=J(o,e),r=J(c,e),d=new Map(r.map(h=>[h.j*M+h.i,h]));if(b.length===0||r.length===0)return{reached:-1,best:1/0,starts:b,goal:d,back:f};let y=(h,x)=>{let $=H(h),K=_(x);return(Math.max(0,c.col-$,$-(c.col+c.side))+Math.max(0,c.row-K,K-(c.row+c.side)))*Ae};X.fill(1/0),f.fill(-1),U.clear();let Y=-1,v=1/0;for(let h of b){let x=(h.j*M+h.i)*4+h.out;X[x]=0,U.push(x,y(h.i,h.j))}for(;U.size>0;){let h=U.peekKey();if(h>=v||h>=m)break;let x=U.pop(),$=x>>2,K=x&3,ee=$%M,ue=($-ee)/M,Ee=d.get($);if(Ee){let q=X[x]+(K===ae[Ee.out]?0:Ne);q<v&&(v=q,Y=x);continue}for(let q=0;q<4;q++){let[pe,Be]=le[q],be=ee+pe,xe=ue+Be;if(be<0||xe<0||be>=M||xe>=P)continue;let ke=xe*M+be;if(!e[ke])continue;let Le=pe+Be>0?$:ke;if(!(pe!==0?a:w)[Le])continue;let _e=(pe!==0?se:ie)[Le]?Ae:1,Je=O*_e*(1+Math.max(0,V[ke]-Ze))+(q===K?0:Ne),ve=ke*4+q,$e=X[x]+Je;$e<X[ve]&&(X[ve]=$e,f[ve]=x,U.push(ve,$e+y(be,xe)))}}return{reached:Y,best:v,starts:b,goal:d,back:f}},Q=new Map;for(let o of n){let c=s.get(o.from),l=s.get(o.to);if(!c||!l||c===l)continue;let f=ge(c,l,!1,F[1],1/0);if(f.reached===-1){yield;continue}let m=ge(c,l,!0,F[0],1.3*f.best+2+Ae*fe+1e-9),e=m.reached!==-1&&m.best<=1.3*f.best+2?m:f;if(e.reached===-1)continue;let{reached:a,starts:w,goal:b,back:r}=e,d=[];for(let v=a;v!==-1;v=r[v]){let h=v>>2,x=d[d.length-1],$={i:h%M,j:Math.floor(h/M)};(!x||x.i!==$.i||x.j!==$.j)&&d.push($)}d.reverse();for(let v=1;v<d.length;v++){let h=d[v-1],x=d[v],$=h.i+h.j<x.i+x.j?h:x;(h.i!==x.i?se:ie)[$.j*M+$.i]=1}let y=w.find(v=>v.i===d[0].i&&v.j===d[0].j),Y=b.get(d[d.length-1].j*M+d[d.length-1].i);Q.set(o.key,{cells:d,start:y.curb,end:Y.curb}),yield}let ce=new Map(n.map(o=>[o.key,o.width])),de=new Map(n.map((o,c)=>[o.key,c])),we=i*u/Math.sqrt(1+u*u),Z=(o,c)=>o==="col"?`r${c.row.toFixed(2)}`:`c${c.col.toFixed(2)}`,T=new Map;for(let[o,c]of Q)for(let l=1;l<c.cells.length;l++){let f=c.cells[l-1],m=c.cells[l],e=Z(f.i!==m.i?"col":"row",{col:H(f.i),row:_(f.j)});T.set(e,(T.get(e)??new Set).add(o))}for(let[o,c]of Q){let l=[c.start,...c.cells.map(r=>({col:H(r.i),row:_(r.j)})),c.end],f=r=>r>=2&&r<=c.cells.length,m=[];for(let r=1;r<l.length;r++){let d=Math.abs(l[r].col-l[r-1].col)>1e-9?"col":"row",y=m[m.length-1];y&&y.axis===d?y.to=r:m.push({from:r-1,to:r,axis:d})}if(m.length===0)continue;let e=m.map(r=>{if(!Array.from({length:r.to-r.from},(h,x)=>f(r.from+1+x)).some(Boolean))return 0;let d=T.get(Z(r.axis,l[r.from]))??new Set;if(!d.has(o))return 0;let y=[...d].sort((h,x)=>(de.get(h)??0)-(de.get(x)??0)),v=-(y.reduce((h,x)=>h+(ce.get(x)??2)+2,0)-2)/2;for(let h of y){if(h===o)return(v+(ce.get(h)??2)/2)/we;v+=(ce.get(h)??2)+2}return 0}),a=r=>{let d=m[r],y=l[d.from];return d.axis==="col"?{row:y.row+e[r]}:{col:y.col+e[r]}},w=(r,d,y)=>({col:r.col??d.col??y.col,row:r.row??d.row??y.row}),b=[w(a(0),{},l[0])];for(let r=0;r+1<m.length;r++)b.push(w(a(r),a(r+1),l[m[r].to]));b.push(w(a(m.length-1),{},l[l.length-1])),p.set(o,b.map(r=>Me(r.col,r.row,i,u)))}return p}var je=class{items=[];keys=[];get size(){return this.items.length}clear(){this.items.length=0,this.keys.length=0}peekKey(){return this.keys[0]??1/0}push(n,s){this.items.push(n),this.keys.push(s);let i=this.items.length-1;for(;i>0;){let u=i-1>>1;if(this.keys[u]<=this.keys[i])break;this.swap(i,u),i=u}}pop(){let n=this.items[0],s=this.items.pop(),i=this.keys.pop();if(this.items.length>0){this.items[0]=s,this.keys[0]=i;let u=0;for(;;){let g=2*u+1,k=g+1,p=u;if(g<this.items.length&&this.keys[g]<this.keys[p]&&(p=g),k<this.items.length&&this.keys[k]<this.keys[p]&&(p=k),p===u)break;this.swap(u,p),u=p}}return n}swap(n,s){let i=this.items[n];this.items[n]=this.items[s],this.items[s]=i;let u=this.keys[n];this.keys[n]=this.keys[s],this.keys[s]=u}},tt=16,z=new Map,Ue=0;function me(t){let n=[...t.plots].map(([s,i])=>`${s}:${i.col},${i.row},${i.side}`).join(";");return`${t.ribbons.map(s=>`${s.key}>${s.from}>${s.to}>${s.width}`).join(";")}|${n}`}var nt=t=>t.map(n=>`${Math.round(n.x)},${Math.round(n.y)},${Math.round(n.width)},${Math.round(n.height)}`).join(";"),Ke=(t,n)=>`${n}|${t.cell}|${t.tilt??.5}|${nt(t.labels??[])}`;function qe(t,n,s){for(z.set(Ke(t,n),{ground:n,cell:t.cell,tilt:t.tilt??.5,runs:s});z.size>tt;)z.delete(z.keys().next().value)}function ye(t){let n=Ke(t,me(t)),s=z.get(n);if(s)return z.delete(n),z.set(n,s),s.runs}function ze(t){let n=ye(t);if(n)return n;Ue+=1;let s=et(t);return qe(t,me(t),s),s}function We(t,n,s=8){let i=ye(t);if(i)return n(i),()=>{};let u=me(t),g=De(t),k=!1,p;Ue+=1;let R=()=>{if(p=void 0,k)return;let j=performance.now();for(;;){let E=g.next();if(E.done){qe(t,u,E.value),n(E.value);return}if(performance.now()-j>=s)break}p=setTimeout(R,0)};return p=setTimeout(R,0),()=>{k=!0,p!==void 0&&clearTimeout(p)}}function Ge(t,n,s){let i;for(let g of z.values())g.ground===t&&g.tilt===s&&(i=g);if(!i||n<=0)return;if(i.cell===n)return i.runs;let u=n/i.cell;return new Map([...i.runs].map(([g,k])=>[g,k.map(p=>({x:p.x*u,y:p.y*u}))]))}function Ve(t,n){let s=t.col+t.side,i=s+.25+.22*Math.max(0,n),u=t.row+t.side*Math.max(.1,.3-.06*n),g=t.row+t.side*Math.min(.9,.7+.06*n);return[{col:s,row:u},{col:i,row:u},{col:i,row:g},{col:s,row:g}]}function Xe(t,n){return t.map(s=>Me(s.col,s.row,n.cell,n.tilt))}function Ye(t){return t.map((n,s)=>`${s===0?"M":"L"} ${n.x.toFixed(1)} ${n.y.toFixed(1)}`).join(" ")}function He(t){if(t.length===0)return{x:0,y:0};let n=0;for(let i=1;i<t.length;i++)n+=Math.hypot(t[i].x-t[i-1].x,t[i].y-t[i-1].y);let s=n/2;for(let i=1;i<t.length;i++){let u=t[i-1],g=t[i],k=Math.hypot(g.x-u.x,g.y-u.y);if(k>=s&&k>0)return{x:u.x+(g.x-u.x)*s/k,y:u.y+(g.y-u.y)*s/k};s-=k}return t[t.length-1]}var C=Re(Oe(),1),he=new Map,ot=(t,n)=>t.length===n.length&&t.every((s,i)=>Math.round(s.x)===Math.round(n[i].x)&&Math.round(s.y)===Math.round(n[i].y)&&Math.round(s.width)===Math.round(n[i].width)&&Math.round(s.height)===Math.round(n[i].height));function dt({frame:t,width:n,height:s,pan:i,store:u,graphVersion:g,selection:k,view:p,emphasis:R,hiddenKinds:j,drawn:E}){let[W,M]=(0,I.useState)(null),P=t.city,H=e=>u.graph.getNode(e)?.kind,_=(0,I.useMemo)(()=>Se(u.graph.allEdges(),e=>u.graph.getNode(e)?.kind),[u,g]),B=new Map;for(let e of t.nodes){let a=e.id.startsWith("kind:")?Te(e.id):null;a!==null&&e.plot&&Math.round(e.plane)===2&&B.set(a,e.plot)}let te=[...B].map(([e,a])=>`${e}:${a.col},${a.row},${a.side}`).join(";"),L=P?.cell??0,A=_.filter(e=>B.has(e.from)&&B.has(e.to)&&!j.has(e.from)&&!j.has(e.to)&&E(e.edge)),N=P?.tilt??.5,S=`${te}|${L}|${N}`,[ne,oe]=(0,I.useState)(null),[G,re]=(0,I.useState)(null),V=t.t>=1,J=!!P&&!!p.overview;(0,I.useLayoutEffect)(()=>{let e=G?.parentElement;if(!e||!P||!V)return;let a=e.getBoundingClientRect(),w=P.originX+i.x,b=P.originY+i.y,r=[...e.querySelectorAll('[data-graview-view^="kind:"] .graview-kind-face')].flatMap(d=>{let y=d.getBoundingClientRect();return y.width>0&&y.height>0?[{x:y.left-a.left-w,y:y.top-a.top-b,width:y.width,height:y.height}]:[]});for(he.set(S,r);he.size>16;)he.delete(he.keys().next().value);oe(d=>d?.cards===S&&ot(d.labels,r)?d:{cards:S,labels:r})},[G,V,S]);let se=Math.max(0,...A.map(e=>e.links)),ie=A.map(e=>({key:e.key,from:e.from,to:e.to,width:Ie(e.links,se)})),le=me({ribbons:ie,plots:B}),ae=typeof window>"u",D=ne?.cards===S?ne.labels:he.get(S)??(ae?[]:void 0),F=L>0&&J&&V&&D!==void 0?{ribbons:ie,plots:B,cell:L,tilt:N,labels:D}:null,[U,ge]=(0,I.useState)(0),Q=F!==null&&!ae&&ye(F)===void 0,ce=`${le}|${L}|${N}|${(D??[]).map(e=>`${Math.round(e.x)},${Math.round(e.y)},${Math.round(e.width)},${Math.round(e.height)}`).join(";")}`;(0,I.useEffect)(()=>{if(!(!Q||!F))return We(F,()=>ge(e=>e+1))},[Q,ce]);let de=(0,I.useMemo)(()=>{if(L===0||!J)return[];let e=F?ae?ze(F):ye(F):Ge(le,L,N);if(!e)return[];let a=new Map;return A.flatMap(w=>{let b;if(w.from===w.to){let r=a.get(w.from)??0;a.set(w.from,r+1),b=Xe(Ve(B.get(w.from),r),{cell:L,tilt:N})}else b=e.get(w.key);return!b||b.length<2?[]:[{ribbon:w,points:b,d:Ye(b),middle:He(b),width:Ie(w.links,se)}]})},[L,N,le,D,V,J,U]),we=(0,I.useRef)([]),Z=(0,I.useRef)({x:0,y:0});if(Z.current=P?{x:P.originX+i.x,y:P.originY+i.y}:{x:0,y:0},(0,I.useEffect)(()=>{let e=G?.parentElement;if(!e||typeof window>"u")return;let a=0,w=null,b=()=>{a=0;let y=w;if(!y)return;let Y=y.target;if(y.pointerType==="touch"||y.buttons!==0||Y?.closest("[data-graview-view], button, a, input, select, textarea, [data-graview-overlay], [data-graview-offstage]")){M(null);return}let v=e.getBoundingClientRect(),h=y.clientX-v.left-Z.current.x,x=y.clientY-v.top-Z.current.y,$=null,K=1/0;for(let ee of we.current){let ue=rt(ee.points,h,x);ue<=ee.reach&&ue<K&&(K=ue,$=ee.key)}M($)},r=y=>{w=y,a===0&&(a=requestAnimationFrame(b))},d=()=>M(null);return e.addEventListener("pointermove",r,{passive:!0}),e.addEventListener("pointerleave",d),()=>{a!==0&&cancelAnimationFrame(a),e.removeEventListener("pointermove",r),e.removeEventListener("pointerleave",d)}},[G]),!P||!p.overview)return null;let T=Fe(k,p,H);if(T.records.length>0||T.lens!==null)return null;let o=T.districts.length>0?de.filter(({ribbon:e})=>T.districts.includes(e.from)||T.districts.includes(e.to)):de;if(o.length===0&&A.length===0)return null;let c=R??null,l=o.find(({ribbon:e})=>e.key===W);we.current=o.map(({ribbon:e,points:a,width:w})=>({key:e.key,points:a,reach:w/2+6}));let f={x:P.originX+i.x,y:P.originY+i.y},m=`translate(${f.x.toFixed(1)} ${f.y.toFixed(1)})`;return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("svg",{ref:re,className:"graview-ribbons","aria-hidden":"true","data-graview-world":"","data-graview-ribbons":o.length,width:n,height:s,style:{position:"absolute",left:0,top:0,pointerEvents:"none",overflow:"visible"},children:(0,C.jsx)("g",{transform:m,children:o.map(({ribbon:e,d:a,width:w})=>{let b=W===e.key||c!==null&&c===e.edge||T.districts.length>0,r=c!==null&&c!==e.edge;return(0,C.jsx)("g",{className:"graview-ribbon","data-graview-ribbon":e.edge,"data-graview-from":`kind:${e.from}`,"data-graview-to":`kind:${e.to}`,"data-graview-links":e.links,"data-graview-lit":b&&!r?"":void 0,"data-graview-receded":r?"":void 0,children:(0,C.jsx)("path",{className:"graview-ribbon-band",d:a,style:{strokeWidth:w}})},e.key)})})}),l?(0,C.jsx)("div",{className:"graview-ribbon-said","data-graview-world":"","data-testid":"ribbon-said",role:"status",style:{position:"absolute",left:f.x+l.middle.x,top:f.y+l.middle.y,pointerEvents:"none"},children:Ce(u.schema,l.ribbon)}):null]})}function rt(t,n,s){let i=1/0;for(let u=1;u<t.length;u++){let g=t[u-1],k=t[u],p=k.x-g.x,R=k.y-g.y,j=p*p+R*R,E=j===0?0:Math.max(0,Math.min(1,((n-g.x)*p+(s-g.y)*R)/j));i=Math.min(i,Math.hypot(n-(g.x+E*p),s-(g.y+E*R)))}return i}export{dt as Ribbons,rt as distanceTo};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as te}from"./chunk.YIPXZUTT.js";import"./chunk.BJUUSIQY.js";import"./chunk.NJRLJEJY.js";import"./chunk.YXEO3Y65.js";import"./chunk.U3HERHAI.js";import"./chunk.FBILPNGH.js";import{G as ne,W as N}from"./chunk.MODLZJD4.js";import"./chunk.SDO3U72B.js";import{eb as Z,la as Q,oa as X,td as ee,xd as $}from"./chunk.6HY6ZGEE.js";import"./chunk.FQLNBIQ5.js";import{b as P}from"./chunk.AJZBJBMO.js";var D=new WeakMap,we=5e3;function I(n){let e=D.get(n);if(e&&Date.now()-e.at<we)return e.list;let t={at:Date.now(),list:Promise.resolve([])};return t.list=Promise.resolve().then(()=>n.list()).catch(()=>[]).then(o=>t.value=[...o,...(t.value??[]).filter(i=>!o.some(l=>l.id===i.id))]),e?.value&&(t.value=e.value),D.set(n,t),t.list}var oe=n=>D.get(n)?.value;function re(n,e){let t=D.get(n);if(!t)return;let o=i=>[...i.filter(l=>l.id!==e.id),e];t.value&&(t.value=o(t.value)),D.set(n,{at:t.at,list:t.list.then(o),...t.value?{value:t.value}:{}})}function A(n,e){let t=$(n,e);return o=>n.graph.getNode(o)!==void 0&&t(o)}var z=["previewed","accepted","declined","undone","abandoned"],ve=["graph","light","full"],S={words:300,should:300,name:80,records:200,people:20,stages:8,examples:5},Se=365,xe=5e3,be=new RegExp("[\\u0000-\\u001f\\u007f-\\u009f\\u200b-\\u200f\\u2028-\\u202e\\u2066-\\u2069]","g");function ie(n,e){if(typeof n!="string")return;let t=n.replace(be," ").replace(/\s+/g," ").trim();return t.length===0?void 0:t.slice(0,e).trimEnd()}function h(n){return typeof n=="string"&&n.length>0&&n.length<=S.name&&/^[\p{L}\p{N}_][\p{L}\p{N}_.:/-]*$/u.test(n)?n:void 0}var W=(n,e)=>Array.isArray(n)?[...new Set(n.flatMap(t=>h(t)??[]))].slice(0,e):[];function ae(n){let e=typeof n.id=="string"?n.id.slice(0,S.name):void 0;return{kind:n.kind,...e!==void 0?{id:e}:{},...n.onBehalfOf?{onBehalfOf:ae(n.onBehalfOf)}:{}}}var le=n=>n?.kind==="visitor"||n?.onBehalfOf?.kind==="visitor",ke=()=>`tl-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,Oe=new Set(["record","field","selection","list","lens","place","act"]);function Pe(n){let e=n,t=o=>typeof o=="number"&&Number.isFinite(o)&&o>=0?Math.min(1e4,Math.round(o)):0;switch(e?.type){case"act":{let o=h(e.act);return o?{type:"act",act:o,records:t(e.records)}:void 0}case"plan":return{type:"plan",edits:t(e.edits)};case"answer":return{type:"answer"};case"refusal":return{type:"refusal"};case"view":{let o=typeof e.section=="string"?e.section.replace(/\s+/g," ").trim().slice(0,S.name):"";return o?{type:"view",section:o}:void 0}default:return}}function se(n,e,t={}){if(!n||typeof n!="object"||!e||le(e))return;let o=n,i=ie(o.words,S.words),l=Pe(o.decided),d=o.target;if(!i||!l||!d||!Oe.has(String(d.on)))return;let s={on:d.on,...h(d.kind)?{kind:h(d.kind)}:{},...h(d.id)?{id:h(d.id)}:{},...h(d.place)?{place:h(d.place)}:{}},c=o.reading,a=c&&(c.which==="itself"||c.which==="held")&&h(c.kind)?{which:c.which,kind:h(c.kind),records:W(c.records,S.records)}:void 0,g=W(o.people,S.people),f=Array.isArray(o.stages)?o.stages.flatMap(Te=>{let L=Te,V=h(L?.stage),E=L?.ms;return V&&typeof E=="number"&&Number.isFinite(E)&&E>=0?[{stage:V,ms:Math.round(E),...h(L.model)?{model:h(L.model)}:{}}]:[]}).slice(0,S.stages):[],w=z.includes(o.outcome)?o.outcome:"previewed",y=ve.includes(o.slot)?o.slot:void 0,b=o.rating==="up"||o.rating==="down"?o.rating:void 0,k=b==="down"?ie(o.should,S.should):void 0,O=typeof o.ms=="number"&&Number.isFinite(o.ms)&&o.ms>=0?Math.round(o.ms):void 0,r=t.id??h(o.id)??ke(),p=h(o.conversation)??r,m=h(o.follows),Y=h(o.interaction),J=W(o.examples,S.examples);return{id:r,at:t.at??new Date().toISOString(),by:ae(e),words:i,target:s,...a?{reading:a}:{},...g.length>0?{people:g}:{},decided:l,...y?{slot:y}:{},...f.length>0?{stages:f}:{},...O!==void 0?{ms:O}:{},outcome:w,...b?{rating:b}:{},...k?{should:k}:{},conversation:p,...m?{follows:m}:{},...Y?{interaction:Y}:{},...J.length>0?{examples:J}:{}}}function Ae(n,e){let t=e.outcome===void 0||e.outcome==="previewed"||n.outcome==="accepted"&&e.outcome!=="undone"||n.outcome==="undone"||(n.outcome==="declined"||n.outcome==="abandoned")&&e.outcome==="abandoned"?n.outcome:e.outcome,o=e.rating===void 0?n.rating:e.rating??void 0,i=o!=="down"?void 0:e.should===void 0?n.should:e.should??void 0,{rating:l,should:d,...s}=n;return{...s,outcome:t,...o?{rating:o}:{},...i?{should:i}:{},...e.examples?{examples:e.examples}:{},...e.pinned!==void 0?{pinned:e.pinned}:{},...e.excluded!==void 0?{excluded:e.excluded}:{}}}function Ce(n,e={}){let t=(e.now??Date.now())-(e.retentionDays??Se)*864e5,o=new Map;for(let d of n){let s=Date.parse(d.at);Number.isFinite(s)&&s>=t&&!le(d.by)&&o.set(d.id,d)}let i=[...o.values()],l=e.most??xe;return i.length>l?i.slice(i.length-l):i}function H(n,e,t={}){return"add"in e?Ce([...n,e.add],t):"remove"in e?n.filter(o=>o.id!==e.remove):n.map(o=>o.id===e.change?Ae(o,e.with):o)}var C=n=>n.onBehalfOf?C(n.onBehalfOf):n.id!==void 0?`${n.kind}:${n.id}`:`${n.kind}:?`,Re=n=>[...new Set([...n.target.id?[n.target.id]:[],...n.reading?.records??[],...n.people??[]])];function R(n,e){return n.filter(t=>Re(t).every(e))}var B=n=>!n.excluded&&n.rating!=="down"&&n.outcome!=="undone"&&(n.outcome==="accepted"||n.rating==="up"),U=n=>{let e=n.reading?.kind??n.target.kind??"";return n.decided.type==="act"?`act:${n.decided.act}:${e}:${n.reading?.which??""}`:n.decided.type==="plan"?`plan:${e}`:void 0};function De(n,e={}){let t=Math.max(1,e.minPeople??2),o=e.reader?C(e.reader):void 0,i=new Map;for(let l of n){let d=U(l);!d||!B(l)||C(l.by)===o||i.set(d,(i.get(d)??new Set).add(C(l.by)))}return new Set([...i].filter(([,l])=>l.size>=t).map(([l])=>l))}function ce(n,e){return n.filter(t=>(e.rating===void 0||(e.rating==="none"?t.rating===void 0:t.rating===e.rating))&&(e.outcome===void 0||t.outcome===e.outcome)&&(e.kind===void 0||(t.reading?.kind??t.target.kind)===e.kind))}var Le=n=>n.filter(e=>B(e)&&U(e)!==void 0);function ue(n){let e=Le(n).length;return e===0?"Nothing told here teaches suggestions yet: a telling that is accepted or rated \u{1F44D} will.":`Suggestions come from ${e} rated ${e===1?"telling":"tellings"} in this app.`}function ge(n,e=t=>t){switch(n.decided.type){case"act":return`${e(n.decided.act)}, over ${n.decided.records} ${n.decided.records===1?"record":"records"}`;case"plan":return`A plan of ${n.decided.edits} ${n.decided.edits===1?"change":"changes"} to the app`;case"answer":return"An open answer";case"refusal":return"Nothing it could do";case"view":return`A revision of \u201C${n.decided.section}\u201D`}}var G={previewed:"Previewed",accepted:"Accepted",declined:"Declined",undone:"Undone",abandoned:"Closed with nothing done"},Ee=new Set("a an and are as at be by can do does for from has have how i in is it its me my of on or our please the their them these they this those to was we what when where which who why will with you your all each every".split(" "));function de(n){return[...new Set(n.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").split(/[^\p{L}\p{N}]+/u).filter(e=>e.length>1&&!Ee.has(e)).map(e=>e.length>3&&e.endsWith("s")&&!e.endsWith("ss")?e.slice(0,-1):e))]}function M(n,e,t={}){let o=de(e.words);if(o.length===0)return[];let i=t.reader?C(t.reader):void 0,l=De(n,{...t.reader?{reader:t.reader}:{},...t.minPeople!==void 0?{minPeople:t.minPeople}:{}}),d=n.flatMap(a=>{let g=U(a);if(!g||!B(a)||t.rated&&a.rating!=="up")return[];if(!(i!==void 0&&C(a.by)===i)&&!l.has(g))return[];let w=de(a.words),y=o.filter(p=>w.some(m=>m===p||p.length>=3&&m.startsWith(p))).length;if(y===0)return[];let b=y/new Set([...o,...w]).size,k=e.kind!==void 0&&(a.target.kind===e.kind||a.reading?.kind===e.kind)?.25:e.kind!==void 0?-.25:0,O=e.act!==void 0&&a.decided.type==="act"&&a.decided.act===e.act?.15:0,r=Math.max(0,Math.min(1,b*.6+.25+k+O+(a.pinned?.1:0)));return r>=(t.floor??.35)?[{telling:a,score:r,lesson:g}]:[]});d.sort((a,g)=>g.score-a.score||Number(g.telling.pinned??!1)-Number(a.telling.pinned??!1)||(a.telling.at<g.telling.at?1:-1));let s=new Set,c=[];for(let a of d)if(!s.has(a.lesson)&&(s.add(a.lesson),c.push({telling:a.telling,score:a.score}),c.length>=(t.most??2)))break;return c}function pe(n){return n.map(({telling:e})=>({said:e.words,did:e.decided.type==="act"?`act ${e.decided.act} over ${e.reading?.which==="itself"?"the record itself":"each record it holds"}`:e.decided.type==="plan"?"a plan that changes the app":e.decided.type==="view"?"a revision of a view's section":e.decided.type,...e.reading?{reading:e.reading.which}:{}}))}var x=P(ne(),1),T=P(N(),1);function ye(n,e){if(e.on==="list"||e.on==="lens")return e.kind;let t=te(e)[0];return t?n.graph.getNode(t)?.kind:void 0}function $e(n,e,t,o,i){let l=n?oe(n):void 0;if(!l)return{examples:[],ids:[]};let d=ye(e,i),s=M(R(l,A(e,t)),{words:o,...d?{kind:d}:{}},{reader:t,rated:!0,most:3});return{examples:pe(s),ids:s.map(c=>c.telling.id)}}function Ne(n){let e=new Set((n.stages??[]).map(t=>t.stage));return e.has("thinking")?"full":e.has("light")?"light":e.has("fast")?"graph":(n.usage??[]).some(t=>t.tier==="thinking")?"full":void 0}function Ie(n,e){if(n.interaction.outcome==="failed"||e&&"refused"in e)return{type:"refusal"};if(e&&"question"in e)return e.proposal?{type:"plan",edits:e.parts.length}:{type:"refusal"};let t=n.ghost?.proposals??[];return t.length>0?{type:"act",act:t[0].call.name,records:new Set(t.map(i=>i.record??i.id)).size}:{type:"answer"}}function Me(n,e){let t=new Set;for(let o of e.ghost?.proposals??[])for(let i of Object.values(o.call.args))typeof i=="string"&&i!==o.record&&n.graph.getNode(i)&&t.add(i);return[...t]}function _e(n,e){let{target:t,result:o}=e,i=ye(n,t),l=t.on==="record"||t.on==="field"?t.id:void 0,d=t.on==="lens"||t.on==="place"?t.place:void 0,s=o.reading?{which:o.reading.which,kind:o.reading.kind,records:o.reading.records}:void 0,c=Me(n,o),a=Ne(o.interaction),g=Ie(o,e.plan);return{words:e.words,target:{on:t.on,...i?{kind:i}:{},...l?{id:l}:{},...d?{place:d}:{}},...s?{reading:s}:{},...c.length>0?{people:c}:{},decided:g,...a?{slot:a}:{},...o.interaction.stages?{stages:o.interaction.stages}:{},ms:e.ms,outcome:"previewed",...e.conversation?{conversation:e.conversation}:{},...e.follows?{follows:e.follows}:{},interaction:o.interaction.id,...e.examples&&e.examples.length>0?{examples:e.examples}:{}}}function Fe(n,e,t){if(!n)return;let o=se(e,t);if(o)return re(n,o),Promise.resolve().then(()=>n.add(o)).catch(()=>{}),o}function _(n,e,t){n&&Promise.resolve().then(()=>n.change(e,t)).catch(()=>{})}var We={accepted:"accepted",partly:"accepted",drawn:"accepted",dismissed:"declined"};function ze(n,e,t){let o,i=()=>{let c=n.get().entries.find(g=>g.id===t.interaction);if(!c)return;let a=c.undone?"undone":We[c.outcome];!a||a===o||(o=a,_(e,t.id,{outcome:a}),a==="undone"&&s())},l=n.subscribe(i),d=setTimeout(()=>s(),30*6e4),s=()=>{l(),clearTimeout(d)};return s}function He({told:n,telling:e}){let[t,o]=(0,x.useState)(e.rating),[i,l]=(0,x.useState)(""),[d,s]=(0,x.useState)(!1),c=(0,x.useId)();(0,x.useEffect)(()=>{o(e.rating),l(""),s(!1)},[e.id,e.rating]);let a=f=>{let w=t===f?void 0:f;o(w),s(!1),_(n,e.id,{rating:w??null})},g=()=>{let f=i.trim();!f||t!=="down"||(_(n,e.id,{should:f}),s(!0))};return(0,T.jsxs)("div",{"data-testid":"quick-ask-rating","data-rating":t??"",style:{display:"grid",gap:6},children:[(0,T.jsxs)("div",{role:"group","aria-label":"Was this right?",style:{display:"flex",gap:4,justifyContent:"flex-end"},children:[(0,T.jsx)("button",{type:"button","data-testid":"quick-ask-right","aria-label":"This was right",title:"This was right","aria-pressed":t==="up",onClick:()=>a("up"),style:t==="up"?fe:K,children:(0,T.jsx)("span",{"aria-hidden":"true",children:"\u{1F44D}"})}),(0,T.jsx)("button",{type:"button","data-testid":"quick-ask-wrong","aria-label":"This was wrong",title:"This was wrong","aria-pressed":t==="down",onClick:()=>a("down"),style:t==="down"?fe:K,children:(0,T.jsx)("span",{"aria-hidden":"true",children:"\u{1F44E}"})})]}),t==="down"?(0,T.jsxs)("div",{style:{display:"grid",gap:2},children:[(0,T.jsxs)("label",{htmlFor:c,style:{fontSize:"0.75rem",color:"var(--graview-ink-muted)"},children:["What should it have done? ",(0,T.jsx)("span",{style:{color:"var(--graview-ink-faint)"},children:"(optional)"})]}),(0,T.jsx)("input",{id:c,type:"text","data-testid":"quick-ask-should",value:i,maxLength:300,autoComplete:"off",enterKeyHint:"done",onChange:f=>{l(f.target.value),s(!1)},onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),g())},onBlur:g,style:Be}),d?(0,T.jsx)("span",{role:"status","data-testid":"quick-ask-should-kept",style:{fontSize:"0.75rem",color:"var(--graview-ink-muted)"},children:"Kept, to learn from."}):null]}):null]})}var K={display:"inline-grid",placeItems:"center",width:30,height:28,padding:0,font:"inherit",fontSize:"0.875rem",lineHeight:1,background:"transparent",border:"1px solid transparent",borderRadius:6,boxShadow:"none",cursor:"pointer",opacity:.7},fe={...K,opacity:1,borderColor:"var(--graview-accent)",background:"var(--graview-panel)"},Be={boxSizing:"border-box",width:"100%",height:32,padding:"0 8px",font:"inherit",fontSize:"max(1rem,16px)",color:"var(--graview-ink)",background:"var(--graview-panel)",border:"1px solid var(--graview-edge)",borderRadius:8};var j=n=>n.charAt(0).toUpperCase()+n.slice(1);function me(n,e){if(!e)return;let t=n.graph.getNode(e);if(t)return t.kind;let o=/^(?:kind|aggregate):(.+)$/.exec(e)?.[1];return o&&n.schema.tryDefinition(o)?o:void 0}function he(n,e,t){let o=n.schema;if(e.decided.type==="plan")return j(e.words);if(e.decided.type!=="act")return;let i=e.decided.act,l=n.allMutations().find(y=>y.name===i);if(!l)return;let d=l.title??l.name,s=y=>/\b(?:it|this|them)\b/i.test(d)?d.replace(/\b(?:it|this|them)\b/i,y):`${d} ${y}`,c=t?n.graph.getNode(t):void 0,a=c?Q(o.tryDefinition(c.kind),c):void 0,g=e.reading?.kind??e.target.kind;if(!g||!o.tryDefinition(g))return;if(e.reading?.which==="itself"||!e.reading&&c?.kind===g)return c&&c.kind===g&&a?j(s(a)):void 0;let f=c?new Set([...n.graph.in(c.id),...n.graph.out(c.id)].filter(y=>y.kind===g).map(y=>y.id)).size:me(n,t)===g?n.graph.allNodes().filter(y=>y.kind===g).length:0;if(f===0)return;let w=f===1?(o.tryDefinition(g)?.noun??g).toLowerCase():X(o,g).toLowerCase();return j(s(`the ${f} ${w}${a?` in ${a}`:""}`))}async function Ue(n,e,t){return R(await I(n),A(e,t))}function Ge(n,e,t,o,i,l=4){if(o.trim()==="")return[];let d=me(e,i);return M(n,{words:o,...d?{kind:d}:{}},{reader:t,most:l}).flatMap(({telling:s})=>{let c=he(e,s,i);return c?[{key:`told:${s.id}`,telling:s,label:c}]:[]})}function Ke(n,e,t,o,i=3){let l=new Set,d=[];for(let s of[...n].reverse()){if(d.length>=i)break;if(!(s.rating==="up"||s.outcome==="accepted")||s.by!==void 0&&t.id!==void 0&&s.by.id!==void 0&&s.by.id!==t.id)continue;let c=he(e,s,o);!c||l.has(c.toLowerCase())||(l.add(c.toLowerCase()),d.push({key:`told:${s.id}`,telling:s,label:c}))}return d}var v=P(ne(),1),u=P(N(),1);function je({told:n,store:e,principal:t,onClose:o}){let[i,l]=(0,v.useState)(null),[d,s]=(0,v.useState)({}),c=(0,v.useRef)(null);(0,v.useEffect)(()=>{let r=!0;return Promise.resolve().then(()=>n.list()).then(p=>r&&l(p),()=>r&&l([])),c.current?.focus({preventScroll:!0}),()=>{r=!1}},[n]);let a=(0,v.useMemo)(()=>i?R(i,$(e,t)):[],[i,e,t]),g=(0,v.useMemo)(()=>[...ce(a,d)].sort((r,p)=>r.at<p.at?1:-1),[a,d]),f=(0,v.useMemo)(()=>[...new Set(a.flatMap(r=>r.reading?.kind??r.target.kind??[]))].sort(),[a]),w=r=>e.allMutations().find(p=>p.name===r)?.title??r,y=r=>e.schema.tryDefinition(r)?.plural??r,b=r=>{try{return Z(r.by,{graph:e.graph,schema:e.schema})}catch{return r.by.id??r.by.kind}},k=(r,p)=>{l(m=>m&&H(m,{change:r,with:p})),Promise.resolve().then(()=>n.change(r,p)).catch(()=>{})},O=r=>{l(p=>p&&H(p,{remove:r})),Promise.resolve().then(()=>n.remove(r)).catch(()=>{})};return(0,u.jsxs)("section",{ref:c,tabIndex:-1,"data-testid":"told-panel","data-graview-overlay":"","aria-label":"What Graview has been told",onKeyDown:r=>{r.key==="Escape"&&(r.stopPropagation(),o())},style:qe,children:[(0,u.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[(0,u.jsx)("h2",{style:{margin:0,fontSize:"1rem",fontWeight:600,flex:"1 1 auto"},children:"What Graview has been told"}),(0,u.jsx)("button",{type:"button","data-testid":"told-close",onClick:o,style:F,children:"Close"})]}),(0,u.jsx)("p",{"data-testid":"told-teaching",style:{margin:0,fontSize:"0.875rem",color:"var(--graview-ink-muted)"},children:i===null?"Reading what was told\u2026":ue(a)}),(0,u.jsxs)("div",{role:"group","aria-label":"Show only",style:{display:"flex",flexWrap:"wrap",gap:8,fontSize:"0.8125rem"},children:[(0,u.jsxs)("label",{style:q,children:["Rating",(0,u.jsxs)("select",{"data-testid":"told-filter-rating",value:d.rating??"",onChange:r=>s(({rating:p,...m})=>r.target.value?{...m,rating:r.target.value}:m),children:[(0,u.jsx)("option",{value:"",children:"Any"}),(0,u.jsx)("option",{value:"up",children:"\u{1F44D} Right"}),(0,u.jsx)("option",{value:"down",children:"\u{1F44E} Wrong"}),(0,u.jsx)("option",{value:"none",children:"Not rated"})]})]}),(0,u.jsxs)("label",{style:q,children:["Outcome",(0,u.jsxs)("select",{"data-testid":"told-filter-outcome",value:d.outcome??"",onChange:r=>s(({outcome:p,...m})=>r.target.value?{...m,outcome:r.target.value}:m),children:[(0,u.jsx)("option",{value:"",children:"Any"}),z.map(r=>(0,u.jsx)("option",{value:r,children:G[r]},r))]})]}),(0,u.jsxs)("label",{style:q,children:["Kind",(0,u.jsxs)("select",{"data-testid":"told-filter-kind",value:d.kind??"",onChange:r=>s(({kind:p,...m})=>r.target.value?{...m,kind:r.target.value}:m),children:[(0,u.jsx)("option",{value:"",children:"Any"}),f.map(r=>(0,u.jsx)("option",{value:r,children:y(r)},r))]})]})]}),i!==null&&g.length===0?(0,u.jsx)("p",{"data-testid":"told-none",style:{margin:0,fontSize:"0.875rem",color:"var(--graview-ink-muted)"},children:a.length===0?"Nothing has been told here yet.":"Nothing told here fits these."}):null,(0,u.jsx)("ol",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:8,overflowY:"auto"},children:g.map(r=>(0,u.jsxs)("li",{"data-testid":"told-entry","data-telling":r.id,"data-outcome":r.outcome,"data-rating":r.rating??"","data-excluded":r.excluded?"":void 0,"data-pinned":r.pinned?"":void 0,style:Ye,children:[(0,u.jsxs)("p",{style:{margin:0,fontWeight:550,overflowWrap:"anywhere"},children:["\u201C",r.words,"\u201D"]}),(0,u.jsxs)("p",{style:{margin:0,fontSize:"0.8125rem"},children:[ge(r,w)," \xB7 ",G[r.outcome],r.rating?` \xB7 ${r.rating==="up"?"\u{1F44D} right":"\u{1F44E} wrong"}`:"",r.pinned?" \xB7 a good example":"",r.excluded?" \xB7 excluded from suggestions":""]}),r.should?(0,u.jsxs)("p",{style:{margin:0,fontSize:"0.8125rem",fontStyle:"italic"},children:["Should have: ",r.should]}):null,(0,u.jsxs)("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--graview-ink-muted)"},children:[b(r)," \xB7 ",(0,u.jsx)("time",{dateTime:r.at,children:new Date(r.at).toLocaleString()}),r.ms!==void 0?` \xB7 ${r.ms<1e3?`${r.ms} ms`:`${(r.ms/1e3).toFixed(1)} s`}`:""]}),(0,u.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:[(0,u.jsx)("button",{type:"button","data-testid":"told-pin","aria-pressed":r.pinned===!0,onClick:()=>k(r.id,{pinned:!r.pinned}),style:F,children:r.pinned?"Not a good example":"A good example"}),(0,u.jsx)("button",{type:"button","data-testid":"told-exclude","aria-pressed":r.excluded===!0,onClick:()=>k(r.id,{excluded:!r.excluded}),style:F,children:r.excluded?"Suggest it again":"Exclude from suggestions"}),(0,u.jsx)("button",{type:"button","data-testid":"told-delete",onClick:()=>O(r.id),style:F,children:"Delete"})]})]},r.id))})]})}var qe={position:"absolute",insetBlock:"60px 12px",insetInlineEnd:12,width:"min(440px, calc(100% - 24px))",boxSizing:"border-box",display:"flex",flexDirection:"column",gap:10,padding:14,borderRadius:12,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",color:"var(--graview-ink)",boxShadow:"var(--graview-lift-high)",zIndex:ee("popover"),overflow:"hidden"},Ye={display:"grid",gap:4,padding:10,borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)"},F={padding:"2px 10px",minHeight:28,font:"inherit",fontSize:"0.8125rem",borderRadius:8},q={display:"inline-flex",alignItems:"center",gap:4};export{He as RateTelling,je as ToldPanel,_ as changeTelling,$e as examplesHere,Fe as keepTelling,Ue as readToldHere,A as seenOnThisPage,_e as tellingDraftOf,Ke as toldForHere,I as toldListed,Ge as toldSuggestionsFrom,ze as watchTelling};
|