graview 0.1.38 → 0.1.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/preview/{chunk.XHWL7QBF.js → chunk.242EUAPE.js} +1 -1
- package/dist/preview/chunk.2CF2XKOS.js +1 -0
- package/dist/preview/chunk.2FGYWAID.js +1 -0
- package/dist/preview/{chunk.MWZK3HVG.js → chunk.2FLPDPEL.js} +1 -1
- package/dist/preview/{chunk.6IHXTT6Z.js → chunk.2GDXNTY5.js} +1 -1
- package/dist/preview/chunk.2JB4Y2ET.js +1 -0
- package/dist/preview/chunk.2NXH7VAI.js +1 -0
- package/dist/preview/chunk.2OSNYF5C.js +1 -0
- package/dist/preview/{chunk.GR5Q4HTW.js → chunk.2RVUDRRY.js} +1 -1
- package/dist/preview/chunk.2WACBAUN.js +9 -0
- package/dist/preview/chunk.35PHXNOC.js +1 -0
- package/dist/preview/chunk.3Q75TIGL.js +1 -0
- package/dist/preview/chunk.42XSBKPO.js +1 -0
- package/dist/preview/chunk.47KHZCNG.js +1 -0
- package/dist/preview/{chunk.Z3ZKYSPN.js → chunk.4QPVS2ZM.js} +1 -1
- package/dist/preview/{chunk.WERYQENC.js → chunk.4VG2KN7G.js} +1 -1
- package/dist/preview/{chunk.ZRQI5VJF.js → chunk.5RABSIF7.js} +1 -1
- package/dist/preview/{chunk.2VIGF4FO.js → chunk.67WWRC6Y.js} +1 -1
- package/dist/preview/chunk.6AVZWLRF.js +1 -0
- package/dist/preview/chunk.6CRRPXKP.js +1 -0
- package/dist/preview/{chunk.FUJM7GDV.js → chunk.6FNMDAX5.js} +1 -1
- package/dist/preview/chunk.6J37UQKG.js +1 -0
- package/dist/preview/chunk.6JEU3ZNE.js +1 -0
- package/dist/preview/chunk.6PSWHBL2.js +1 -0
- package/dist/preview/chunk.74NOI7QN.js +1 -0
- package/dist/preview/chunk.7LIKEE5Z.js +1 -0
- package/dist/preview/chunk.7WPCP2LZ.js +1 -0
- package/dist/preview/{chunk.JWJQ2VXS.js → chunk.ACBUAIDF.js} +1 -1
- package/dist/preview/{chunk.IEDXW36H.js → chunk.AKQXF7GW.js} +1 -1
- package/dist/preview/chunk.AUBGUDO5.js +1 -0
- package/dist/preview/chunk.AVKDWISO.js +1 -0
- package/dist/preview/{chunk.36SQJMEE.js → chunk.AWX7GP72.js} +1 -1
- package/dist/preview/chunk.BFNVG5JE.js +1 -0
- package/dist/preview/chunk.BNVMMOOY.js +1 -0
- package/dist/preview/{chunk.7H5KVW2F.js → chunk.BSAXZQSY.js} +1 -1
- package/dist/preview/{chunk.V2NBJDAX.js → chunk.BXT6FDT4.js} +1 -1
- package/dist/preview/{chunk.TKSGC6XH.js → chunk.C2PECN4C.js} +1 -1
- package/dist/preview/chunk.CL2ZS5EQ.js +1 -0
- package/dist/preview/chunk.CN5WAKHJ.js +5 -0
- package/dist/preview/{chunk.LF7PU77M.js → chunk.CNFL5IN5.js} +1 -1
- package/dist/preview/chunk.D25XEVKO.js +1 -0
- package/dist/preview/chunk.DL26BKT7.js +1 -0
- package/dist/preview/chunk.DPZTW24D.js +1 -0
- package/dist/preview/chunk.ESSSNLEO.js +1 -0
- package/dist/preview/chunk.ETOGQE2V.js +1 -0
- package/dist/preview/chunk.FDE3TSTK.js +1 -0
- package/dist/preview/chunk.FFZBOP65.js +1 -0
- package/dist/preview/chunk.FOQZADMA.js +25 -0
- package/dist/preview/chunk.G6VZNRQ5.js +1 -0
- package/dist/preview/chunk.GAFYE37S.js +3 -0
- package/dist/preview/{chunk.KNJZ2YNJ.js → chunk.GT2BITLW.js} +1 -1
- package/dist/preview/{chunk.ZLXPIEUC.js → chunk.GTV2VZAS.js} +2 -2
- package/dist/preview/{chunk.AZCFXPEL.js → chunk.GY6RYJHM.js} +1 -1
- package/dist/preview/chunk.GZIVMOY4.js +117 -0
- package/dist/preview/{chunk.VKHKYK5L.js → chunk.H5ADMSE7.js} +1 -1
- package/dist/preview/chunk.H5HWN7A2.js +1 -0
- package/dist/preview/chunk.H6XKMLDQ.js +1 -0
- package/dist/preview/chunk.H7POIT3V.js +1 -0
- package/dist/preview/{chunk.SGB6IMWN.js → chunk.HB7ELBVK.js} +1 -1
- package/dist/preview/chunk.HFYUAK5Z.js +6 -0
- package/dist/preview/{chunk.MCVY6RRS.js → chunk.HPAGOEZG.js} +1 -1
- package/dist/preview/{chunk.EUGWV3S6.js → chunk.I7XSDXQ3.js} +1 -1
- package/dist/preview/chunk.IDUPJMJO.js +1 -0
- package/dist/preview/chunk.IFTWVUJO.js +2 -0
- package/dist/preview/{chunk.RZVZG2BQ.js → chunk.ISXFH3CK.js} +1 -1
- package/dist/preview/chunk.J4IULZFD.js +1 -0
- package/dist/preview/chunk.JACGQ2PR.js +4 -0
- package/dist/preview/{chunk.67WL7BGF.js → chunk.JDRLSVOI.js} +1 -1
- package/dist/preview/chunk.JLDBFX6O.js +1 -0
- package/dist/preview/{chunk.RVJYEOFN.js → chunk.JQEYZB5I.js} +1 -1
- package/dist/preview/chunk.L3A6YLMT.js +21 -0
- package/dist/preview/chunk.LLEFYJPJ.js +344 -0
- package/dist/preview/chunk.LOZJQ5ZX.js +1 -0
- package/dist/preview/chunk.LPBM5AES.js +19 -0
- package/dist/preview/chunk.LPE4FLC6.js +6 -0
- package/dist/preview/{chunk.SZWX56WR.js → chunk.MIM2QLF5.js} +2 -2
- package/dist/preview/{chunk.FMVWXSQ7.js → chunk.N2K25KH3.js} +1 -1
- package/dist/preview/{chunk.2EJAIT33.js → chunk.N6MVK3KD.js} +1 -1
- package/dist/preview/{chunk.33GN2NUT.js → chunk.NGDXH66B.js} +1 -1
- package/dist/preview/chunk.O5JKDFDH.js +1 -0
- package/dist/preview/chunk.O6F3K6CU.js +1 -0
- package/dist/preview/{chunk.V5ZT5NSJ.js → chunk.OW7NSJ4H.js} +1 -1
- package/dist/preview/chunk.P5ODICND.js +32 -0
- package/dist/preview/{chunk.YPY5BOEI.js → chunk.PPG2SEIY.js} +1 -1
- package/dist/preview/chunk.PXQVXBNG.js +1 -0
- package/dist/preview/chunk.PYNYHNDS.js +1 -0
- package/dist/preview/{chunk.MVNUWK5Y.js → chunk.Q4TZHWQX.js} +1 -1
- package/dist/preview/chunk.QCWZSSNC.js +1 -0
- package/dist/preview/chunk.QIV65FWE.js +1 -0
- package/dist/preview/chunk.R5WY567U.js +88 -0
- package/dist/preview/{chunk.VNBR4DHD.js → chunk.RCM7NOPF.js} +2 -1
- package/dist/preview/chunk.S2U5CEP4.js +1 -0
- package/dist/preview/chunk.S356ACK2.js +1 -0
- package/dist/preview/chunk.SDO3U72B.js +1 -0
- package/dist/preview/chunk.SHNYYBNW.js +1 -0
- package/dist/preview/{chunk.DL637Q3W.js → chunk.SIGC3G7S.js} +1 -1
- package/dist/preview/chunk.STI447YW.js +1 -0
- package/dist/preview/chunk.T3TYD7QI.js +1 -0
- package/dist/preview/chunk.T73RB7LC.js +1 -0
- package/dist/preview/chunk.TD2LNFUB.js +1 -0
- package/dist/preview/{chunk.5XJEGXDO.js → chunk.TGVUIFKD.js} +1 -1
- package/dist/preview/chunk.TIH2PDFH.js +1 -0
- package/dist/preview/chunk.TKUNRFDE.js +1 -0
- package/dist/preview/{chunk.74RMHUCX.js → chunk.TNESS3LQ.js} +1 -1
- package/dist/preview/chunk.UHI3D7JC.js +1 -0
- package/dist/preview/{chunk.TOWYHWPB.js → chunk.UOPKRN55.js} +1 -1
- package/dist/preview/{chunk.BUVAMSOZ.js → chunk.UTCB3CE7.js} +2 -2
- package/dist/preview/{chunk.3D5T3XIE.js → chunk.UUBYFBPN.js} +1 -1
- package/dist/preview/{chunk.YUJG5SN5.js → chunk.UWW6ZEPY.js} +2 -2
- package/dist/preview/chunk.V5MYKNL7.js +5 -0
- package/dist/preview/{chunk.6UCRL4OF.js → chunk.VDAMCTNL.js} +1 -1
- package/dist/preview/chunk.VF7P3ZVZ.js +35 -0
- package/dist/preview/chunk.VIYECFKZ.js +6 -0
- package/dist/preview/{chunk.5MSO3KRO.js → chunk.VJXXCUKS.js} +1 -1
- package/dist/preview/{chunk.GZ3IXNA4.js → chunk.VNUHESMZ.js} +1 -1
- package/dist/preview/chunk.VZYCILPJ.js +1 -0
- package/dist/preview/chunk.W4HBRXMY.js +1 -0
- package/dist/preview/chunk.W7R2GFBW.js +47 -0
- package/dist/preview/chunk.WBLHCH5M.js +1 -0
- package/dist/preview/{chunk.NPX7SPXM.js → chunk.WVDKYUF3.js} +1 -1
- package/dist/preview/{chunk.LHO7L3CS.js → chunk.XEKLEHC3.js} +1 -1
- package/dist/preview/{chunk.IM7LXLIB.js → chunk.XFZKP4IF.js} +1 -1
- package/dist/preview/chunk.XQHDP5C3.js +1 -0
- package/dist/preview/chunk.XQTMO5PW.js +1 -0
- package/dist/preview/{chunk.UXIFQIHA.js → chunk.XRYTJNA7.js} +1 -1
- package/dist/preview/chunk.YO24NALN.js +1 -0
- package/dist/preview/{chunk.B5ILKGEF.js → chunk.YWNHCZQ5.js} +1 -1
- package/dist/preview/chunk.YWVOACSX.js +5 -0
- package/dist/preview/chunk.YYFLTMNN.js +1 -0
- package/dist/preview/chunk.YYIKSH2F.js +3 -0
- package/dist/preview/{chunk.QYRPELLU.js → chunk.Z5AB2DBF.js} +1 -1
- package/dist/preview/{chunk.6ONRWFA6.js → chunk.Z7LDT55A.js} +1 -1
- package/dist/preview/chunk.ZGCRMNER.js +1 -0
- package/dist/preview/{chunk.OE4QOBJF.js → chunk.ZHLQWMV5.js} +1 -1
- package/dist/preview/{chunk.ROGYDMES.js → chunk.ZJMDLRC5.js} +1 -1
- package/dist/preview/chunk.ZK3X23EU.js +1 -0
- package/dist/preview/chunk.ZOR6FKNI.js +1 -0
- package/dist/preview/chunk.ZRLXVYPG.js +1 -0
- package/dist/preview/index.html +47 -43
- package/dist/preview/page.js +8 -8
- package/package.json +6 -6
- package/dist/preview/chunk.2HFRVWWM.js +0 -1
- package/dist/preview/chunk.3FW4QNGV.js +0 -1
- package/dist/preview/chunk.3RT2GUZ5.js +0 -1
- package/dist/preview/chunk.3ZRHHB7X.js +0 -1
- package/dist/preview/chunk.4DEUD66C.js +0 -6
- package/dist/preview/chunk.4EQSP7I3.js +0 -1
- package/dist/preview/chunk.4Y6BCHV2.js +0 -1
- package/dist/preview/chunk.5VBBQ6Z3.js +0 -1
- package/dist/preview/chunk.6CKBIY7L.js +0 -1
- package/dist/preview/chunk.6XJP7F3I.js +0 -1
- package/dist/preview/chunk.7RSZMIAL.js +0 -1
- package/dist/preview/chunk.AFY35RJP.js +0 -1
- package/dist/preview/chunk.BRHRAVU2.js +0 -3
- package/dist/preview/chunk.DFVVS6C5.js +0 -1
- package/dist/preview/chunk.DQJAEU4V.js +0 -1
- package/dist/preview/chunk.ESSQAMPM.js +0 -1
- package/dist/preview/chunk.EV553KRT.js +0 -1
- package/dist/preview/chunk.EZP4FHDX.js +0 -35
- package/dist/preview/chunk.F6PIK2J2.js +0 -1
- package/dist/preview/chunk.FTJBW25J.js +0 -1
- package/dist/preview/chunk.FYIQZMVF.js +0 -1
- package/dist/preview/chunk.HUSFMFXH.js +0 -1
- package/dist/preview/chunk.HVTGPEVW.js +0 -1
- package/dist/preview/chunk.I3SQJ2L2.js +0 -1
- package/dist/preview/chunk.IU6ISXXC.js +0 -1
- package/dist/preview/chunk.K5KEECHL.js +0 -88
- package/dist/preview/chunk.L34FY7QQ.js +0 -1
- package/dist/preview/chunk.L73VUBXN.js +0 -4
- package/dist/preview/chunk.L7JKEEMM.js +0 -1
- package/dist/preview/chunk.LAW5PQEM.js +0 -1
- package/dist/preview/chunk.LDD3QX7G.js +0 -1
- package/dist/preview/chunk.LU5LSXSW.js +0 -1
- package/dist/preview/chunk.MQ7FNHXG.js +0 -25
- package/dist/preview/chunk.NH5TDAB2.js +0 -1
- package/dist/preview/chunk.NORRCKGN.js +0 -1
- package/dist/preview/chunk.NQQHOSOK.js +0 -1
- package/dist/preview/chunk.NWWMUOZM.js +0 -1
- package/dist/preview/chunk.OEF3GPRM.js +0 -1
- package/dist/preview/chunk.OS3L4ZOF.js +0 -2
- package/dist/preview/chunk.OTL3Z345.js +0 -1
- package/dist/preview/chunk.P3UPCI23.js +0 -1
- package/dist/preview/chunk.PGKIEDYV.js +0 -9
- package/dist/preview/chunk.PKUWET2F.js +0 -1
- package/dist/preview/chunk.POHEWJKZ.js +0 -1
- package/dist/preview/chunk.PUBG2L6F.js +0 -117
- package/dist/preview/chunk.QT4XGC5Z.js +0 -344
- package/dist/preview/chunk.QTTBZJ6W.js +0 -1
- package/dist/preview/chunk.RJDZOF2L.js +0 -1
- package/dist/preview/chunk.SGLJTSTD.js +0 -1
- package/dist/preview/chunk.SITFEJES.js +0 -1
- package/dist/preview/chunk.UF3L6FJO.js +0 -1
- package/dist/preview/chunk.VSYHU5MA.js +0 -1
- package/dist/preview/chunk.VTWFVPKD.js +0 -19
- package/dist/preview/chunk.VV4BPOIK.js +0 -1
- package/dist/preview/chunk.W2HCJQVK.js +0 -32
- package/dist/preview/chunk.WG5NIR23.js +0 -47
- package/dist/preview/chunk.WLPTY4BF.js +0 -5
- package/dist/preview/chunk.XDYAG276.js +0 -1
- package/dist/preview/chunk.XM3NPZLP.js +0 -1
- package/dist/preview/chunk.YAXZNQY6.js +0 -1
- package/dist/preview/chunk.YG423NEB.js +0 -1
- package/dist/preview/chunk.YVR3ZMTV.js +0 -1
- package/dist/preview/chunk.YXH3IWNR.js +0 -1
- package/dist/preview/chunk.ZYCNEOAQ.js +0 -1
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
var Tt="en-US",De=/^\d{4}-\d{2}-\d{2}$/,Wn=/^\d{4}(-\d\d){2}[T ]\d\d:\d\d(:[\d.]+)?(Z|[+-][\d:]+)?$/,mf=n=>!Number.isNaN(Date.parse(n)),W=(n,e=Date.now())=>{let t=qn(n);return t?Dt(e,t).day:new Date(e).toISOString().slice(0,10)},qn=n=>Te(n)??je,pn,hn,gn,je;function pd(n){pn=mn(n.reader),hn=mn(n.app),gn=Te(n.readerTimeZone),je=Te(n.appTimeZone)}function hd(n,e){let t=[pn,hn,gn,je];n.reader!==void 0&&(pn=mn(n.reader)),n.app!==void 0&&(hn=mn(n.app)),n.readerTimeZone!==void 0&&(gn=Te(n.readerTimeZone)),n.appTimeZone!==void 0&&(je=Te(n.appTimeZone));try{return e()}finally{[pn,hn,gn,je]=t}}var $o=n=>pn??mn(n)??hn??Tt,Hn=n=>gn??Te(n)??je,gd=n=>Hn(n)??Intl.DateTimeFormat().resolvedOptions().timeZone??"UTC",md=/^\s*([+\-−]|\d)/;var jt=new Map;function Te(n){if(n&&!jt.has(n)){let e=!1;try{new Intl.DateTimeFormat(Tt,{timeZone:n}),e=!md.test(n)}catch{}jt.set(n,e)}return n&&jt.get(n)?n:void 0}var $e=new Map;function mn(n){if(n&&!$e.has(n)){let e=!1;try{e=Intl.DateTimeFormat.supportedLocalesOf(n).length>0}catch{}$e.set(n,e)}return n&&$e.get(n)?n:void 0}function pe(n,e,t,r){let o=`${t=$o(t)}${r?"#":"@"}${JSON.stringify(e)}`,i=$e.get(o);return i||$e.set(o,i=r?new Intl.NumberFormat(t,e):new Intl.DateTimeFormat(t,e)),i.format(n).replace(/ /g," ")}var _e="UTC",Yn=n=>Date.UTC(+n.slice(0,4),+n.slice(5,7)-1,+n.slice(8,10));function he(n,e){return De.test(n)?pe(Yn(n),{year:"numeric",month:"short",day:"numeric",timeZone:_e},e):n}function Dt(n,e){let t=`wall@${e??""}`,r=$e.get(t);r||$e.set(t,r=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23",...e?{timeZone:e}:{}}));let o=Object.fromEntries(r.formatToParts(n).map(i=>[i.type,i.value]));return{day:`${o.year}-${o.month}-${o.day}`,minutes:Number(o.hour)%24*60+Number(o.minute)}}function _o(n,e,t){let r=Date.UTC(+n.slice(0,4),+n.slice(5,7)-1,+n.slice(8,10),0,e),o=i=>{let s=Dt(i,t);return yd(s.day,s.minutes)-Math.floor(i/6e4)*6e4};return r-o(r-o(r))}var yd=(n,e)=>Date.UTC(+n.slice(0,4),+n.slice(5,7)-1,+n.slice(8,10),0,e),Ro=n=>/[Z+-][\d:]*$/.test(n.slice(16));function Ao(n,e,t,r,o=!1){if(!Wn.test(n))return n;let i=Ro(n),s=Date.parse(n.replace(" ","T")+(i?"":"Z"));if(Number.isNaN(s))return n;let a=i?Hn(r):_e;return pe(s,{...e,hour:"numeric",minute:"2-digit",...i&&o?{timeZoneName:"short"}:{},...a?{timeZone:a}:{}},t)}var Zt=(n,e,t)=>Ao(n,{year:"numeric",month:"short",day:"numeric"},e,t,!0),bd=(n,e,t)=>Ao(n,{},e,t);function vd(n,e){if(De.test(n))return n;if(!Wn.test(n))return;if(!Ro(n))return n.slice(0,10);let t=Date.parse(n.replace(" ","T"));return Number.isNaN(t)?void 0:Dt(t,Hn(e)).day}function ie(n,e,t={maximumFractionDigits:2}){return Number.isFinite(n)?pe(n,t,e,!0):String(n)}function xd(n,e={},t){return De.test(n)?pe(Yn(n),{weekday:e.weekday??"long",month:"short",day:"numeric",...e.year?{year:"numeric"}:{},timeZone:_e},t):n}function wd(n,e){return De.test(n)?pe(Yn(n),{month:"short",day:"numeric",timeZone:_e},e):n}function kd(n,e={},t){if(!/^\d{4}-\d{2}/.test(n))return n;let r=e.year??!e.short;return pe(Yn(`${n.slice(0,7)}-01`),{month:e.short?"short":"long",...r?{year:e.short?"2-digit":"numeric"}:{},timeZone:_e},t)}var Sd=(n,e="short",t)=>pe(Date.UTC(1970,0,4+n),{weekday:e,timeZone:_e},t),$d=(n,e)=>pe(Date.UTC(1970,0,1,0,Math.round(n)),{hour:"numeric",minute:"2-digit",timeZone:_e},e),_d=/(?<![\w-])(\d{4}-\d{2}-\d{2})(?![\w-]|:)/g;function Ft(n,e){return n.includes("-")?n.replace(_d,t=>he(t,e)):n}var yn=n=>n.charAt(0).toUpperCase()+n.slice(1),Oo=(n,e="and")=>n.length>1?`${n.slice(0,-1).join(", ")} ${e} ${n.at(-1)}`:n[0]??"";function Rd(n,e){return{...e,kind:n,edges:e.edges??{}}}function Lt(n,e,t){let r=n?.lifecycle;if(!r)return!0;let o=e[r.field];return r.retired==="date"?typeof o!="string"||o.length===0?!0:o>=(t??W()):!r.retired.includes(o)}function D(n,e){if(n?.label)return n.label(e);let t=e.label;return typeof t=="string"&&t.length>0?t:e.id}function Ad(n){return n.title??C(n.name)}function C(n){let e=n.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return yn(e)}function Od(n,e,t){let r=n.tryDefinition(e);return`${ie(t)} ${t===1?U(r,e):Q(n,e).toLowerCase()}`}function Q(n,e){return n.tryDefinition(e)?.plural??`${C(e).toLowerCase()}s`}function Ed(n,e){return yn(Q(n,e))}function Pd(n,e){let t=Q(n,e);return`All ${/^[A-Z][a-z]/.test(t)?t.charAt(0).toLowerCase()+t.slice(1):t}`}function Jn(n,e){let t=n?.computed&&Object.hasOwn(n.computed,e)?n.computed[e]:void 0;return n?.display?.labels?.[e]??(typeof t=="object"?t.label:void 0)??(e==="label"?"Name":C(e))}var zd=/^(u[nt]i|use|usu|uti|ubiq|eu|ewe|one|once)/,Md=/^(hour|honest|hono[ur]r?|heir)/;function Eo(n){let e=C(n).toLowerCase();return Md.test(e)?"an":zd.test(e)?"a":/^[aeiou]/.test(e)?"an":"a"}function Ze(n){return`${Eo(n)} ${C(n).toLowerCase()}`}function U(n,e){return n?.noun??C(e).toLowerCase()}function Kt(n){let e=Object.values(n).filter(r=>typeof r=="number");return Object.entries(n).filter(([r,o])=>e.indexOf(+r)===-1).map(([r,o])=>o)}function Ut(n,e="|"){return n.map(t=>Ht(t)).join(e)}function Po(n,e){return typeof e=="bigint"?e.toString():e}var Gt=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function zo(n){return new Gt(n)}function Mo(n){return n==null}function Bt(n){let e=n.startsWith("^")?1:0,t=n.endsWith("$")?n.length-1:n.length;return n.slice(e,t)}function No(n,e){let t=n/e,r=Math.round(t),o=4*Number.EPSILON*Math.max(Math.abs(t),1);return Math.abs(t-r)<o?0:t-r}function Qn(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}function Io(n){let e=Object.getOwnPropertyDescriptor(n,"shape");return e?.get?e.get.raw:e?.value}function Vt(n){return Io(n._zod.def)??n._zod.def.shape}function jo(n,e,t){Object.defineProperty(n,e,{get(){let r=t();return Qn(this,e,r),r},enumerable:!0,configurable:!0})}function To(n,e,t){e in n?Qn(n,e,t):n[e]=t}function Nd(n,e,t,r){let o=Vt(e);for(let i of t){let s=Object.getOwnPropertyDescriptor(o,i);s.enumerable&&(s.get?jo(n,i,()=>{let a=e._zod.def.shape[i];return r?r(a,i):a}):To(n,i,r?r(s.value,i):s.value))}}function Id(n,e){for(let t of Reflect.ownKeys(e)){let r=Object.getOwnPropertyDescriptor(e,t);r.enumerable&&(r.get?jo(n,t,()=>e[t]):To(n,t,r.value))}}function Do(...n){let e={};for(let t of n){let r=Object.getOwnPropertyDescriptors(t);Object.assign(e,r)}return Object.defineProperties({},e)}var Wt="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function Xn(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function qt(n){if(Xn(n)===!1)return!1;let e=n.constructor;if(e===void 0||typeof e!="function")return!0;let t=e.prototype;return!(Xn(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}var Zo=new Set(["string","number","symbol"]);function vn(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Fe(n,e,t){let r=new n._zod.constr(e??n._zod.def);return(!e||t?.parent)&&(r._zod.parent=n),r}function z(n){let e=n;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function Ht(n){return typeof n=="bigint"?n.toString()+"n":typeof n=="string"?`"${n}"`:`${n}`}function Fo(n){return Object.keys(n).filter(e=>n[e]._zod.optin!==void 0&&n[e]._zod.optout==="optional")}var Lo={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Co(n,e){if(!qt(e))throw new Error("Invalid input to extend: expected a plain object");let t=n._zod.def.checks;if(t&&t.length>0){let o=Vt(n);for(let i of Reflect.ownKeys(e))if(Object.getOwnPropertyDescriptor(o,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Fe(n,Do(n._zod.def,{shape:jd(n,e)}))}function jd(n,e){let t={};return Nd(t,n,Reflect.ownKeys(Vt(n))),Id(t,e),t}function se(n,e=0){if(n.aborted===!0)return!0;for(let t=e;t<n.issues.length;t++)if(n.issues[t]?.continue!==!0)return!0;return!1}function Go(n,e=0){if(n.aborted===!0)return!0;for(let t=e;t<n.issues.length;t++)if(n.issues[t]?.continue===!1)return!0;return!1}function me(n,e){return e.map(t=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(n),t})}function bn(n){return typeof n=="string"?n:n?.message}function Yt(n,e,t){var r;for(let o=e;o<n.length;o++)(r=n[o]).schema??(r.schema=t)}function ae(n,e,t){var r;let o=n.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(r=n).schema??(r.schema=n.inst):n.schema=n.inst);let i=n.schema!==n.inst?n.schema?._zod.def?.error:void 0,s=n.message?n.message:bn(n.inst?._zod.def?.error?.(n))??bn(i?.(n))??bn(e?.error?.(n))??bn(t.customError?.(n))??bn(t.localeError?.(n))??"Invalid input",a={};for(let d of Object.keys(n))d==="inst"||d==="schema"||d==="continue"||d==="input"||d==="__proto__"||(a[d]=n[d]);return a.path??(a.path=[]),a.message=s,e?.reportInput&&(a.input=n.input),a}var Td=/[\uD800-\uDBFF]/;function Jt(n){let e=n.length;if(!Td.test(n))return e;let t=e;for(let r=0;r<e-1;r++)(n.charCodeAt(r)&64512)===55296&&(n.charCodeAt(r+1)&64512)===56320&&(t--,r++);return t}function Xt(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function Ko(n){let e=typeof n;switch(e){case"number":return Number.isNaN(n)?"nan":"number";case"object":{if(n===null)return"null";if(Array.isArray(n))return"array";let t=n;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&"constructor"in t&&t.constructor)return t.constructor.name}}return e}function xn(...n){let[e,t,r]=n;return typeof e=="string"?{message:e,code:"custom",input:t,inst:r}:{...e}}function Uo(n,e){for(let t in e){let r=Object.getOwnPropertyDescriptor(e,t);r.get?Object.defineProperty(n,t,{...r,enumerable:!1}):Dd(n,t,r.value)}}function Re(n,e,t,r=!0){return Object.defineProperty(n,e,{configurable:!0,writable:!0,enumerable:r,value:t}),t}function Qt(n,e,t){return Re(n,e,t,!1)}function Dd(n,e,t){Object.defineProperty(n,e,{configurable:!0,get(){return this==null?t:Re(this,e,t.bind(this))},set(r){Re(this,e,r)}})}function Zd(n,e){let t=Object.getPrototypeOf(n);return e in t?void 0:t}var Ct,ge=!1,Fd={configurable:!0,get(){ge=!0}};function ne(n,e,t){let r=Object.getPrototypeOf(n._zod);if(e in r&&Ct!==n._zod){Ct=void 0;return}Ct=n._zod,Object.defineProperty(r,e,{configurable:!0,get(){Object.defineProperty(this,e,Fd);let o=ge;ge=!1;try{let i=t(this);return ge?delete this[e]:Object.defineProperty(this,e,{configurable:!0,writable:!0,value:i}),ge=ge||o,i}catch(i){throw delete this[e],ge=ge||o,i}},set(o){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:o})}})}function Bo(n,e,t,r){let o=Zd(n,e);o&&Object.defineProperty(o,e,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,e,i),i.value=t(this),Object.defineProperty(this,e,i),i.value},set(i){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:r,value:i})}})}var Vo;var er={value:void 0,enumerable:!1},Wo="captureStackTrace"in Error?Error:null;function Ld(n){let e=Wo;if(e){let t=e.stackTraceLimit;if(typeof t=="number"){try{e.stackTraceLimit=0}catch{return Wo=null,new n}try{return new n}finally{e.stackTraceLimit=t}}}return new n}function O(n,e,t,r){let o={};function i(c){this.def=c,this.constr=p,this.traits=new Set}i.prototype=o;let s=t,a=s&&new WeakSet;function d(c,f){if(c._zod){if(c._zod.traits.has(n))return}else{er.value=new i(f);try{Object.defineProperty(c,"_zod",er)}finally{er.value=void 0}}if(c._zod.traits.add(n),e(c,f),a){let h=Object.getPrototypeOf(c),b=c._zod.constr.prototype,y=h;for(;y&&y!==b;)y=Object.getPrototypeOf(y);let k=y??h;a.has(k)||(a.add(k),Uo(k,s))}let g=p.prototype;for(let h in g)Object.prototype.hasOwnProperty.call(g,h)&&(h in c||(c[h]=g[h].bind(c)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:n});function p(c){let f=r?.Parent?Ld(u):this;d(f,c);let g=f._zod.deferred;if(g){for(let b of g)b();f._zod.deferred=void 0}let h=globalThis.__zod_globalConfig?.postProcessor;return h&&h(f),f}return Object.defineProperty(p,"init",{value:d}),Object.defineProperty(p,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(n)}),Object.defineProperty(p,"name",{value:n}),p}var ce=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};(Vo=globalThis).__zod_globalConfig??(Vo.__zod_globalConfig={});var Le=globalThis.__zod_globalConfig;function Y(n){return n&&Object.assign(Le,n),Le}function Cd(){let n=this._zod;return n.message??(n.message=JSON.stringify(n.def,Po,2)),n.message}function Gd(n){this._zod.message=n}var Kd={get:Cd,set:Gd,enumerable:!0,configurable:!0},tr={value:void 0,enumerable:!1},qo=new WeakSet([Object.prototype,Error.prototype]),Ho=(n,e)=>{n.name="$ZodError",tr.value=e,Object.defineProperty(n,"issues",tr),tr.value=void 0,Object.defineProperty(n,"message",Kd);let t=Object.getPrototypeOf(n);qo.has(t)||(qo.add(t),Object.defineProperty(t,"toString",{configurable:!0,enumerable:!1,get(){let r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}}))},$f=O("$ZodError",Ho),wn=O("$ZodError",Ho,void 0,{Parent:Error});var Bd=n=>{let e=(t,r,o,i)=>{let s=o?{...o,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new ce;if(a.issues.length){let d=new(i?.Err??n)(a.issues.map(l=>ae(l,s,Y())));throw Wt(d,i?.callee??e),d}return a.value};return e},rr=Bd(wn),Vd=n=>{let e=async(t,r,o,i)=>{let s=o?{...o,async:!0}:{async:!0},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){let d=new(i?.Err??n)(a.issues.map(l=>ae(l,s,Y())));throw Wt(d,i?.callee??e),d}return a.value};return e},or=Vd(wn),Wd=n=>(e,t,r)=>{let o=r?{...r,async:!1}:{async:!1},i=e._zod.run({value:t,issues:[]},o);if(i instanceof Promise)throw new ce;return i.issues.length?Yo(n,i.issues,o):{success:!0,data:i.value}},ir=Wd(wn);function Yo(n,e,t){let r;return{success:!1,get error(){return r||(r=new n(e.map(o=>ae(o,t,Y()))),e=void 0,t=void 0),r},set error(o){r=o,e=void 0,t=void 0}}}var qd=n=>async(e,t,r)=>{let o=r?{...r,async:!0}:{async:!0},i=e._zod.run({value:t,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?Yo(n,i.issues,o):{success:!0,data:i.value}},sr=qd(wn);var Jo=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Xo=/^https?$/;var Qo=/^[\s\S]{0,}$/;var ar=/^-?\d+(?:\.\d+)?$/,ei=/^(?:true|false)$/i,ni=/^null$/i;var J=O("$ZodCheck",(n,e)=>{var t;n._zod??(n._zod={}),n._zod.def=e,(t=n._zod).onattach??(t.onattach=[])});var ti=n=>{let e=n.value;return!Mo(e)&&e.length!==void 0},et={number:"number",bigint:"bigint",object:"date"},ri=O("$ZodCheckLessThan",(n,e)=>{J.init(n,e);let t=et[typeof e.value];n._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:et[typeof r.value]??t,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),oi=O("$ZodCheckGreaterThan",(n,e)=>{J.init(n,e);let t=et[typeof e.value];n._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:et[typeof r.value]??t,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),ii=O("$ZodCheckMultipleOf",(n,e)=>{J.init(n,e),n._zod.check=t=>{if(typeof t.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof t.value=="bigint"?e.value!==BigInt(0)&&t.value%e.value===BigInt(0):No(t.value,e.value)===0)||t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:e.value,input:t.value,inst:n,continue:!e.abort})}}),si=O("$ZodCheckNumberFormat",(n,e)=>{J.init(n,e),e.format=e.format||"float64";let t=e.format?.includes("int"),r=t?"int":"number",[o,i]=Lo[e.format];n._zod.check=s=>{let a=s.value;if(t){if(!Number.isInteger(a)){s.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:a,inst:n});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!e.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!e.abort});return}}a<o&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:n,continue:!e.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:n,continue:!e.abort})}});var ai=O("$ZodCheckMaxLength",(n,e)=>{var t;J.init(n,e),(t=n._zod.def).when??(t.when=ti),n._zod.check=r=>{let o=r.value,i=o.length;if((typeof o=="string"&&i>e.maximum?Jt(o):i)<=e.maximum)return;let a=Xt(o);r.issues.push({origin:a,code:"too_big",maximum:e.maximum,inclusive:!0,input:o,inst:n,continue:!e.abort})}}),di=O("$ZodCheckMinLength",(n,e)=>{var t;J.init(n,e),(t=n._zod.def).when??(t.when=ti),n._zod.check=r=>{let o=r.value,i=o.length;if((typeof o=="string"&&i>=e.minimum&&i<e.minimum*2?Jt(o):i)>=e.minimum)return;let a=Xt(o);r.issues.push({origin:a,code:"too_small",minimum:e.minimum,inclusive:!0,input:o,inst:n,continue:!e.abort})}});var cr=O("$ZodCheckStringFormat",(n,e)=>{var t,r;J.init(n,e),e.pattern?(t=n._zod).check??(t.check=o=>{e.pattern.lastIndex=0,!e.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:e.format,input:o.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:n,continue:!e.abort})}):(r=n._zod).check??(r.check=()=>{})}),ci=O("$ZodCheckRegex",(n,e)=>{cr.init(n,e),n._zod.check=t=>{e.pattern.lastIndex=0,!e.pattern.test(t.value)&&t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:e.pattern.toString(),inst:n,continue:!e.abort})}});var li={major:4,minor:6,patch:5};var G=O("$ZodType",(n,e)=>{var t;n??(n={}),n._zod.def=e,n._zod.bag=n._zod.bag||{},n._zod.version=li;let r=n._zod.def.checks,o=n._zod.traits.has("$ZodCheck")?[n,...r??[]]:r?.length?[...r]:[];for(let i of o)for(let s of i._zod.onattach)s(n);if(o.length===0)(t=n._zod).deferred??(t.deferred=[]),n._zod.deferred?.push(()=>{n._zod.run=n._zod.parse});else{let i=(a,d,l)=>{if(a.memo)return a;let u=se(a),p;for(let c of d){if(c._zod.def.when){if(Go(a)||!c._zod.def.when(a))continue}else if(u)continue;let f=a.issues.length,g=c._zod.check(a);if(g instanceof Promise&&l?.async===!1)throw new ce;if(p||g instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await g,a.issues.length!==f&&(Yt(a.issues,f,n),u||(u=se(a,f)))});else{if(a.issues.length===f)continue;Yt(a.issues,f,n),u||(u=se(a,f))}}return p?p.then(()=>a):a},s=(a,d,l)=>{if(se(a))return a.aborted=!0,a;let u=i(d,o,l);if(u instanceof Promise){if(l.async===!1)throw new ce;return u.then(p=>n._zod.parse(p,l))}return n._zod.parse(u,l)};n._zod.run=(a,d)=>{if(d.skipChecks)return n._zod.parse(a,d);if(d.direction==="backward"){let u=n._zod.parse({value:a.value,issues:[]},{...d,skipChecks:!0});return u instanceof Promise?u.then(p=>s(p,a,d)):s(u,a,d)}let l=n._zod.parse(a,d);if(l instanceof Promise){if(d.async===!1)throw new ce;return l.then(u=>i(u,o,d))}return i(l,o,d)}}},{get"~standard"(){return Qt(this,"~standard",Yd(this))},set"~standard"(n){Re(this,"~standard",n)}}),yi=(n,e)=>n.issues.length?{issues:n.issues.map(t=>ae(t,e,Y()))}:{value:n.value};async function Hd(n,e){let t={async:!0};return yi(await n._zod.run({value:e,issues:[]},t),t)}function Yd(n){return{validate:e=>{let t={async:!1};try{let r=n._zod.run({value:e,issues:[]},t);if(!(r instanceof Promise))return yi(r,t)}catch{}return Hd(n,e)},vendor:"zod",version:1}}var ur=O("$ZodString",(n,e)=>{G.init(n,e),n._zod.pattern=e.pattern??Qo,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=String(t.value)}catch{}return typeof t.value=="string"||t.issues.push({expected:"string",code:"invalid_type",input:t.value,inst:n}),t}}),rt=O("$ZodStringFormat",(n,e)=>{cr.init(n,e),ur.init(n,e)});var bi=O("$ZodEmail",(n,e)=>{e.pattern??(e.pattern=Jo),rt.init(n,e)}),vi=1,nt=2;function Jd(n){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(n):(new URL(n),!0)}catch{return!1}}function Xd(n,e){return!("normalize"in e)&&!("hostname"in e)&&!("protocol"in e)?Jd(n)||nt:Qd(n,e)}function Qd(n,e){if(!e.normalize&&e.protocol?.source===Xo.source&&!/^https?:\/\//i.test(n))return vi;try{if(typeof URL<"u"){let t=URL;if(typeof t.parse=="function")return t.parse(n)??nt}return new URL(n)}catch{return nt}}var ec=/[\t\n\r]/g;function fi(n){return n.replace(ec,"")}function nc(n,e){return e.lastIndex=0,e.test(n.hostname)}function tc(n,e){return e.lastIndex=0,e.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol)}var xi=O("$ZodURL",(n,e)=>{rt.init(n,e),n._zod.check=t=>{try{let r=t.value.trim(),o=Xd(r,e);if(o===vi){t.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:t.value,inst:n,continue:!e.abort});return}if(o===nt){t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort});return}if(o===!0){t.value=fi(r);return}e.hostname&&!nc(o,e.hostname)&&t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:t.value,inst:n,continue:!e.abort}),e.protocol&&!tc(o,e.protocol)&&t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:t.value,inst:n,continue:!e.abort}),t.value=e.normalize?o.href:fi(r);return}catch{t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort})}}});var lr=O("$ZodNumber",(n,e)=>{G.init(n,e),n._zod.pattern=ar,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=Number(t.value)}catch{}let o=t.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return t;let i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return t.issues.push({expected:"number",code:"invalid_type",input:o,inst:n,...i?{received:i}:{}}),t}}),wi=O("$ZodNumberFormat",(n,e)=>{si.init(n,e),lr.init(n,e)}),ki=O("$ZodBoolean",(n,e)=>{G.init(n,e),n._zod.pattern=ei,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=!!t.value}catch{}let o=t.value;return typeof o=="boolean"||t.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:n}),t}});var Si=O("$ZodNull",(n,e)=>{G.init(n,e),n._zod.pattern=ni,n._zod.values=new Set([null]),n._zod.parse=(t,r)=>{let o=t.value;return o===null||t.issues.push({expected:"null",code:"invalid_type",input:o,inst:n}),t}});var $i=O("$ZodUnknown",(n,e)=>{G.init(n,e),n._zod.parse=t=>t}),_i=O("$ZodNever",(n,e)=>{G.init(n,e),n._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:n}),t)});function pi(n,e,t){n.issues.length&&e.issues.push(...me(t,n.issues)),e.value[t]=n.value}var Ri=O("$ZodArray",(n,e)=>{G.init(n,e);let t=Le.memoizer;t?.attach(n),n._zod.parse=(r,o)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:n}),r;r.value=t?t.alloc(n,r,Array(i.length),o):Array(i.length);let s=[],a=o?.abortEarly;for(let d=0;d<i.length;d++){let l=i[d],u=e.element._zod.run({value:l,issues:[]},o);if(u instanceof Promise)s.push(u.then(p=>pi(p,r,d)));else if(pi(u,r,d),a&&u.issues.length!==0&&se(u))break}return s.length?Promise.all(s).then(()=>r):r}});function tt(n,e,t,r,o,i){let s=t in r,a=i==="optional";if(!(!s&&a&&o==="optional")){if(n.issues.length){if(o!==void 0&&a&&!s)return;e.issues.push(...me(t,n.issues))}if(!s&&o===void 0){n.issues.length||e.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[t]});return}n.value===void 0?(s||o==="defaulted"&&!a)&&(e.value[t]=void 0):e.value[t]=n.value}}var rc=[];function oc(n){let e=Object.keys(n.shape),t=Object.getOwnPropertySymbols(n.shape),r=t.length?t:rc,o=r.length?[...e,...r]:e;for(let s of o)if(!n.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(s)}": expected a Zod schema`);let i=Fo(n.shape);return{...n,allKeys:o,symbolKeys:r,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(i)}}function ic(n,e,t,r,o,i,s){let a=[],d=o.keySet,l=o.catchall._zod,u=l.def.type,p=l.optin,c=l.optout,f=0;for(let g in e){if(s&&t.issues.length!==f){if(se(t,f))break;f=t.issues.length}if(d.has(g))continue;if(g==="__proto__"){u==="never"&&a.push(g);continue}if(u==="never"){a.push(g);continue}let h=l.run({value:e[g],issues:[]},r);h instanceof Promise?n.push(h.then(b=>tt(b,t,g,e,p,c))):tt(h,t,g,e,p,c)}return a.length&&t.issues.push({code:"unrecognized_keys",keys:a,input:e,inst:i,continue:!0}),n.length?Promise.all(n).then(()=>t):t}var Ai=O("$ZodObject",(n,e)=>{G.init(n,e);let t=Object.getOwnPropertyDescriptor(e,"shape"),r=t?.get?t.get.raw:e.shape??{};if(r){let l=()=>{let u={...r};return Object.defineProperty(e,"shape",{value:u}),l.raw=u,u};l.raw=r,Object.defineProperty(e,"shape",{get:l})}let o=zo(()=>oc(e));ne(n,"propValues",l=>{let u=l.def.shape,p={};for(let c in u){let f=u[c]._zod;if(f.values){Object.prototype.hasOwnProperty.call(p,c)||Qn(p,c,new Set);for(let g of f.values)p[c].add(g);f.optin!==void 0&&p[c].add(void 0)}}return p});let i=Xn,s=e.catchall,a,d=Le.memoizer;d?.attach(n),n._zod.parse=(l,u)=>{a??(a=o.value);let p=l.value;if(!i(p))return l.issues.push({expected:"object",code:"invalid_type",input:p,inst:n}),l;l.value=d?d.alloc(n,l,{},u):{};let c=[],f=a.shape,g=u?.abortEarly,h=l.issues.length;for(let b of a.allKeys){if(g&&l.issues.length!==h){if(se(l,h))break;h=l.issues.length}if(b==="__proto__")continue;let y=f[b],k=y._zod.optin,R=y._zod.optout,m=y._zod.run({value:p[b],issues:[]},u);m instanceof Promise?c.push(m.then(w=>tt(w,l,b,p,k,R))):tt(m,l,b,p,k,R)}return s?ic(c,p,l,u,o.value,n,g===!0):c.length?Promise.all(c).then(()=>l):l}});function hi(n,e,t,r){for(let i of n)if(i.issues.length===0)return e.value=i.value,e;let o=n.filter(i=>!se(i));return o.length===1?(e.value=o[0].value,o[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:t,errors:n.map(i=>i.issues.map(s=>ae(s,r,Y())))}),e)}var Oi=O("$ZodUnion",(n,e)=>{G.init(n,e),ne(n,"optin",r=>r.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":r.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),ne(n,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),ne(n,"values",r=>{if(r.def.options.every(o=>o._zod.values))return new Set(r.def.options.flatMap(o=>Array.from(o._zod.values)))}),ne(n,"pattern",r=>{if(r.def.options.every(o=>o._zod.pattern)){let o=r.def.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>Bt(i.source)).join("|")})$`)}});let t=e.options.length===1?e.options[0]._zod.run:null;n._zod.parse=(r,o)=>{if(t)return t(r,o);let i=!1,s=[];for(let a of e.options){let d=a._zod.run({value:r.value,issues:[]},o);if(d instanceof Promise)s.push(d),i=!0;else{if(d.issues.length===0)return d;s.push(d)}}return i?Promise.all(s).then(a=>hi(a,r,n,o)):hi(s,r,n,o)}});var Ei=O("$ZodRecord",(n,e)=>{G.init(n,e);let t=Le.memoizer;t?.attach(n),n._zod.parse=(r,o)=>{let i=r.value;if(!qt(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),r;let s=[],a=e.keyType._zod.values;if(a&&!e.partial){r.value=t?t.alloc(n,r,{},o):{};let d=new Set;for(let u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){if(d.add(typeof u=="number"?u.toString():u),u==="__proto__")continue;let p=e.keyType._zod.run({value:u,issues:[]},o);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(p.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map(g=>ae(g,o,Y())),input:u,path:[u],inst:n});continue}let c=p.value;if(c==="__proto__")continue;let f=e.valueType._zod.run({value:i[u],issues:[]},o);f instanceof Promise?s.push(f.then(g=>{g.issues.length&&r.issues.push(...me(u,g.issues)),r.value[c]=g.value})):(f.issues.length&&r.issues.push(...me(u,f.issues)),r.value[c]=f.value)}let l;for(let u in i)if(!d.has(u))if(e.mode==="loose"){if(u==="__proto__")continue;r.value[u]=i[u]}else l=l??[],l.push(u);l&&l.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:l,continue:!0})}else{r.value=t?t.alloc(n,r,{},o):{};let d;for(let l of Reflect.ownKeys(i)){if(l==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,l))continue;let u=e.keyType._zod.run({value:l,issues:[]},o);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof l=="string"&&ar.test(l)&&u.issues.length){let g=e.keyType._zod.run({value:Number(l),issues:[]},o);if(g instanceof Promise)throw new Error("Async schemas not supported in object keys currently");g.issues.length===0&&(u=g)}if(u.issues.length){e.mode==="loose"?r.value[l]=i[l]:a?(d=d??[],d.push(l)):r.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(g=>ae(g,o,Y())),input:l,path:[l],inst:n});continue}let c=u.value;if(c==="__proto__")continue;let f=e.valueType._zod.run({value:i[l],issues:[]},o);f instanceof Promise?s.push(f.then(g=>{g.issues.length&&r.issues.push(...me(l,g.issues)),r.value[c]=g.value})):(f.issues.length&&r.issues.push(...me(l,f.issues)),r.value[c]=f.value)}d&&d.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:d,continue:!0})}return s.length?Promise.all(s).then(()=>r):r}});var Pi=O("$ZodEnum",(n,e)=>{G.init(n,e);let t=Kt(e.entries),r=new Set(t);n._zod.values=r,ne(n,"pattern",o=>{let i=Kt(o.def.entries).filter(s=>Zo.has(typeof s));return new RegExp(i.length?`^(${i.map(s=>vn(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),n._zod.parse=(o,i)=>{let s=o.value;return r.has(s)||o.issues.push({code:"invalid_value",values:t,input:s,inst:n}),o}}),zi=O("$ZodLiteral",(n,e)=>{G.init(n,e);let t=new Set(e.values);n._zod.values=t,ne(n,"pattern",r=>{let o=r.def.values;return new RegExp(o.length?`^(${o.map(i=>typeof i=="string"?vn(i):i?vn(i.toString()):String(i)).join("|")})$`:"^[^\\s\\S]$")}),n._zod.parse=(r,o)=>{let i=r.value;return t.has(i)||r.issues.push({code:"invalid_value",values:e.values,input:i,inst:n}),r}});function gi(n,e){return n.value=e.issues.length?void 0:e.value,n}var Mi=O("$ZodOptional",(n,e)=>{G.init(n,e),ne(n,"optin",t=>t.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),n._zod.optout="optional",ne(n,"values",t=>{let r=t.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),ne(n,"pattern",t=>{let r=t.def.innerType._zod.pattern;return r?new RegExp(`^(${Bt(r.source)})?$`):void 0}),n._zod.parse=(t,r)=>{if(t.value===void 0){if(e.innerType._zod.optin!=="defaulted")return t;let o=e.innerType._zod.run({value:t.value,issues:[]},r);return o instanceof Promise?o.then(i=>gi(t,i)):gi(t,o)}return e.innerType._zod.run(t,r)}});var Ni=O("$ZodCustom",(n,e)=>{J.init(n,e),G.init(n,e),n._zod.parse=(t,r)=>t,n._zod.check=t=>{let r=t.value,o=e.fn(r);if(o instanceof Promise)return o.then(i=>mi(i,t,r,n));mi(o,t,r,n)}});function mi(n,e,t,r){if(!n){let o={code:"custom",input:t,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),e.issues.push(xn(o))}}var sc=()=>{let n={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function e(i){return n[i]??null}let t={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function o(i,s){return i==="number"&&typeof s=="number"&&!Number.isFinite(s)?String(s):r[i]??i}return i=>{switch(i.code){case"invalid_type":{let s=o(i.expected),a=Ko(i.input),d=o(a,i.input);return`Invalid input: expected ${s}, received ${d}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${Ht(i.values[0])}`:`Invalid option: expected one of ${Ut(i.values,"|")}`;case"too_big":{let s=i.exact?"exactly ":i.inclusive?"<=":"<",a=e(i.origin);return a?`Too big: expected ${i.origin??"value"} to have ${s}${i.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${i.origin??"value"} to be ${s}${i.maximum.toString()}`}case"too_small":{let s=i.exact?"exactly ":i.inclusive?">=":">",a=e(i.origin);return a?`Too small: expected ${i.origin} to have ${s}${i.minimum.toString()} ${a.unit}`:`Too small: expected ${i.origin} to be ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${t[s.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${Ut(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":return i.options&&Array.isArray(i.options)&&i.options.length>0?`Invalid discriminator value. Expected ${i.options.map(a=>`'${a}'`).join(" | ")}`:i.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function Ii(){return{localeError:sc()}}var ji;var fr=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let o={...r,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Ti(){return new fr}(ji=globalThis).__zod_globalRegistry??(ji.__zod_globalRegistry=Ti());var Ce=globalThis.__zod_globalRegistry;function Di(n){return n.checks&&(n.checks=[...n.checks]),n}function Zi(n,e){return new n(Di({type:"string",...z(e)}))}function Fi(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...z(e)})}function Li(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...z(e)})}function Ci(n,e){return new n(Di({type:"number",checks:[],...z(e)}))}function Gi(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...z(e)})}function Ki(n,e){return new n({type:"boolean",...z(e)})}function Ui(n,e){return new n({type:"null",...z(e)})}function Bi(n){return new n({type:"unknown"})}function Vi(n,e){return new n({type:"never",...z(e)})}function Wi(n,e){return new ri({check:"less_than",...z(e),value:n,inclusive:!0})}function qi(n,e){return new oi({check:"greater_than",...z(e),value:n,inclusive:!0})}function uc(n,e){return new ii({check:"multiple_of",...z(e),value:n})}function pr(n,e){return new ai({check:"max_length",...z(e),maximum:n})}function kn(n,e){return new di({check:"min_length",...z(e),minimum:n})}function Sn(n,e){return new ci({check:"string_format",format:"regex",...z(e),pattern:n})}function Hi(n,e,t){return new n({type:"custom",check:"custom",fn:e,...z(t)})}function Yi(n,e){let t=lc(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(xn(o,r.value,t._zod.def));else{let i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),r.issues.push(xn(i))}},n(r.value,r)),e);return t}function lc(n,e){let t=new J({check:"custom",...z(e)});return t._zod.check=n,t}function Ji(n){let e=new J({check:"describe"});return e._zod.onattach=[t=>{let r=Ce.get(t)??{};Ce.add(t,{...r,description:n})}],e._zod.check=()=>{},e}var q=O("ZodMiniType",(n,e)=>{if(!n._zod)throw new Error("Uninitialized schema in ZodMiniType.");G.init(n,e),n.def=e,n.type=e.type},{get with(){return this.check},set with(n){Re(this,"with",n)},parse(n,e){return rr(this,n,e,{callee:this.parse})},parseAsync(n,e){return or(this,n,e,{callee:this.parseAsync})},safeParse(n,e){return ir(this,n,e)},safeParseAsync(n,e){return sr(this,n,e)},check(...n){let e=this.def;return this.clone({...e,checks:[...e.checks??[],...n.map(t=>typeof t=="function"?{_zod:{check:t,def:{check:"custom"},onattach:[]}}:t)]},{parent:!0})},clone(n,e){return Fe(this,n,e)},brand(){return this},register(n,e){return n.add(this,e),this},apply(n,...e){return e.length===0?n(this):n(this,...e)}}),Qi=O("ZodMiniString",(n,e)=>{ur.init(n,e),q.init(n,e)});function Z(n){return Zi(Qi,n)}var es=O("ZodMiniStringFormat",(n,e)=>{rt.init(n,e),Qi.init(n,e)}),hc=O("ZodMiniEmail",(n,e)=>{bi.init(n,e),es.init(n,e)});function Og(n){return Fi(hc,n)}var gc=O("ZodMiniURL",(n,e)=>{xi.init(n,e),es.init(n,e)});function Eg(n){return Li(gc,n)}var ns=O("ZodMiniNumber",(n,e)=>{lr.init(n,e),q.init(n,e)});function $n(n){return Ci(ns,n)}var mc=O("ZodMiniNumberFormat",(n,e)=>{wi.init(n,e),ns.init(n,e)});function Pg(n){return Gi(mc,n)}var yc=O("ZodMiniBoolean",(n,e)=>{ki.init(n,e),q.init(n,e)});function zg(n){return Ki(yc,n)}var bc=O("ZodMiniNull",(n,e)=>{Si.init(n,e),q.init(n,e)});function Mg(n){return Ui(bc,n)}var vc=O("ZodMiniUnknown",(n,e)=>{$i.init(n,e),q.init(n,e)});function hr(){return Bi(vc)}var xc=O("ZodMiniNever",(n,e)=>{_i.init(n,e),q.init(n,e)});function wc(n){return Vi(xc,n)}var kc=O("ZodMiniArray",(n,e)=>{Ri.init(n,e),q.init(n,e)});function Ng(n,e){return new kc({type:"array",element:n,...z(e)})}var gr=O("ZodMiniObject",(n,e)=>{Ai.init(n,e),q.init(n,e),Bo(n,"shape",t=>t._zod.def.shape,!1)});function Ge(n,e){let t={type:"object",shape:n??{},...z(e)};return new gr(t)}function Ke(n,e){return new gr({type:"object",shape:n,catchall:wc(),...z(e)})}function Ig(n,e){return new gr({type:"object",shape:n,catchall:hr(),...z(e)})}function ts(n,e){return Co(n,e)}var Sc=O("ZodMiniUnion",(n,e)=>{Oi.init(n,e),q.init(n,e)});function jg(n,e){return new Sc({type:"union",options:n,...z(e)})}var Xi=O("ZodMiniRecord",(n,e)=>{Ei.init(n,e),q.init(n,e)});function Tg(n,e,t){return!e||!e._zod?new Xi({type:"record",keyType:Z(),valueType:n,...z(e)}):new Xi({type:"record",keyType:n,valueType:e,...z(t)})}var $c=O("ZodMiniEnum",(n,e)=>{Pi.init(n,e),q.init(n,e),n.options=[...n._zod.values]});function rs(n,e){let t=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new $c({type:"enum",entries:t,...z(e)})}var _c=O("ZodMiniLiteral",(n,e)=>{zi.init(n,e),q.init(n,e)});function os(n,e){return new _c({type:"literal",values:Array.isArray(n)?n:[n],...z(e)})}var Rc=O("ZodMiniOptional",(n,e)=>{Mi.init(n,e),q.init(n,e)});function ee(n){return new Rc({type:"optional",innerType:n})}var Ac=O("ZodMiniCustom",(n,e)=>{Ni.init(n,e),q.init(n,e)});function ot(n,e={}){return Hi(Ac,n,e)}function Dg(n,e){return Yi(n,e)}var Zg=Ji;Y().localeError||Y(Ii());var I=n=>typeof n=="object"&&n!==null?n._zod?.def:void 0,Oc=n=>{if(typeof n!="object"||n===null||!("_zod"in n))return;let e=Ce.get(n)?.description;return typeof e=="string"?e:void 0};var Ec=(n,e)=>n?.src?.(e)??e,it=n=>typeof n=="string"&&n.length<2049&&/^(?![^/?#]*:|\/\/)(?!(?:.*\/)?\.\.?(?:[/?#]|$))(?!.*%2e)[^\\\s]+$/i.test(n),mr=(n,e=1)=>e>0&&n===void 0||Number.isInteger(n)&&n>=e;function yr(n){let e=n??{};return it(e.href)&&typeof e.name=="string"&&/^.{1,255}$/s.test(e.name)&&/^[\w.+-]{1,60}\/[\w.+-]{1,60}$/.test(e.type)&&mr(e.bytes,0)&&mr(e.width)&&mr(e.height)&&(e.caption===void 0||typeof e.caption=="string"&&e.caption.length<501)&&(e.poster===void 0||it(e.poster))&&(e.captions===void 0||it(e.captions))&&(e.duration===void 0||typeof e.duration=="number"&&Number.isFinite(e.duration)&&e.duration>0)}var is=n=>n.type.startsWith("image/"),ss=n=>n.type.startsWith("video/");function Pc(n){let e=n.duration===void 0?0:Math.round(n.duration);if(e<1)return"a video";if(e<60)return`a ${e}-second video`;let t=Math.round(e/60);return t<60?`a ${t}-minute video`:`a ${Math.floor(t/60)}-hour${t%60>0?` ${t%60}-minute`:""} video`}var zc=(n,e)=>e==="image"?is(n):e==="video"?ss(n):!0,Mc=n=>`${n==="image"?"an image":n==="video"?"a video":"a file"} the host stored, at a path on this host`,_n=n=>(Array.isArray(n)?n:[n]).filter(yr),as=Symbol.for("@graview/core:file"),Nc=(n,e)=>(Object.defineProperty(I(n),as,{value:e,enumerable:!0}),n);function ds(n){let e=I(n);return e?.[as]??(e?.innerType?ds(e.innerType):void 0)}var Ic=()=>({href:Z(),name:Z(),type:Z(),bytes:$n(),width:ee($n()),height:ee($n()),caption:ee(Z()),poster:ee(Z()),duration:ee($n()),captions:ee(Z())});function Fm(n){return Nc(Ge(Ic()).check(ot(e=>yr(e)&&zc(e,n),Mc(n))),n)}var st=/^(?:https?:\/\/[^\s<>"'`\\]+|@?[A-Za-z0-9][\w.~-]*(?:\/[\w.~-]+)*)$/,at=n=>typeof n=="string"&&n.length<501&&st.test(n);var cs=n=>typeof n=="object"&&n!==null?n._zod?.def:void 0,jc=/^@(?:https?:\/\/[^\s<>"'`\\#?]+|[A-Za-z0-9][\w.~-]*(?:\/[\w.~-]+)*)\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;function us(n){if(typeof n!="string"||!n.startsWith("@")||!jc.test(n))return;let e=n.lastIndexOf("/"),t=n.slice(0,e),r=n.slice(e+1),o=/^@https?:\/\//.test(t)||!t.includes("/")?t.slice(1):t;return at(o)?{address:o,kind:r}:void 0}var Tc=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*:\S[^\n]{0,199}$/,Dc=n=>`${n.kind}:${n.id}`;function ls(n,e){if(typeof n!="string"||!Tc.test(n))return;let t=n.indexOf(":"),r=n.slice(0,t);return e.kinds.includes(r)?{address:e.address,kind:r,id:n.slice(t+1)}:void 0}function Zc(n,e){return(Array.isArray(n)?n:n==null?[]:[n]).flatMap(r=>{let o=ls(r,e);return o?[o]:[]})}var fs=Symbol.for("@graview/core:linked"),Km=(n,e)=>(Object.defineProperty(cs(n),fs,{value:e,enumerable:!0}),n);function Rn(n){let e=cs(n);return e?e[fs]??Rn(e.innerType):void 0}function Fc(n){let e=n?.fields?.shape??{},t=new Map;for(let[r,o]of Object.entries(e)){let i=Rn(o);i&&t.set(r,i)}return t}function Lc(n){if(n.to==="*"||n.to.length===0)return;let e=n.to.map(us);if(e.some(r=>!r))return;let t=e[0].address;if(!e.some(r=>r.address!==t))return{address:t,kinds:[...new Set(e.map(r=>r.kind))],cardinality:n.cardinality??"many",...n.description?{description:n.description}:{}}}var Cc=n=>n.to!=="*"&&n.to.some(e=>typeof e=="string"&&e.startsWith("@"));function Um(n){return Object.fromEntries(Object.entries(n??{}).filter(([,e])=>!Cc(e)))}function Bm(n){let e=new Map;for(let[t,r]of Object.entries(n??{})){let o=Lc(r);o&&e.set(t,o)}return e}var br=new WeakMap;function Gc(n,e){e?br.set(n,e):br.delete(n)}var ps=n=>br.get(n);var dt=["sun","mon","tue","wed","thu","fri","sat"],Kc=["day","week","month","year"],Be=n=>`${n}Repeat`,On=n=>n.endsWith("Repeat")&&n.length>6?n.slice(0,-6):void 0,ms=/^\d{4}-\d{2}-\d{2}$/,ys=Symbol.for("@graview/core:repeat");function ct(n){let e=I(n);return!!e&&(e[ys]===1||ct(e.innerType))}var Uc=n=>(Object.defineProperty(I(n),ys,{value:1,enumerable:!0}),n),vr=(n,e,t)=>n===void 0||Number.isInteger(n)&&n>=e&&n<=t,hs=(n,e)=>n===void 0||Array.isArray(n)&&n.length<=e&&n.every(t=>typeof t=="string"&&ms.test(t)),Bc=["every","interval","on","until","count","except","continues"],bs=n=>Ve(n)&&Object.keys(n).every(e=>Bc.includes(e))&&vr(n.interval,1,99)&&vr(n.count,1,1e3)&&hs(n.until===void 0?void 0:[n.until],1)&&hs(n.except,500)&&(n.continues===void 0||typeof n.continues=="string"&&n.continues.length<=200)&&(n.on===void 0||Array.isArray(n.on)&&n.on.length>0&&n.on.length<=31&&n.on.every(e=>n.every==="week"?dt.includes(e):n.every==="month"&&e!==0&&vr(e,-1,31))),qm=()=>Uc(hr().check(ot(n=>n===null||bs(n),"how a date repeats, or null"))),An=n=>Date.UTC(+n.slice(0,4),+n.slice(5,7)-1,+n.slice(8,10)),vs=n=>new Date(n).toISOString().slice(0,10),xr=(n,e)=>vs(An(n)+e*864e5),gs=(n,e,t)=>{let r=new Date(Date.UTC(n,e+1,0)).getUTCDate();return vs(Date.UTC(n,e,t<0||t>r?r:t))},Ve=n=>typeof n=="object"&&n!==null&&Kc.includes(n.every);function Ue(n,e,t={}){let r=n.slice(0,10),o=n.slice(10),i=[];if(!ms.test(r))return i;let s=Math.max(1,e.interval??1),a=e.every,d=t.from&&t.from>r?t.from.slice(0,10):r,l=[e.until,t.to?.slice(0,10)].filter(Boolean).sort()[0],u=t.limit??1e3,p=new Set(e.except??[]),c=+r.slice(0,4),f=+r.slice(5,7)-1,g=+r.slice(8,10),h=xr(r,-new Date(An(r)).getUTCDay()),b=(e.on?.length?e.on:[a==="week"?dt[new Date(An(r)).getUTCDay()]:g]).map(w=>typeof w=="string"?dt.indexOf(w):w),y=a==="day"?1:a==="week"?7:0,k=(+d.slice(0,4)-c)*12+(+d.slice(5,7)-1-f),R=e.count?0:Math.max(0,Math.floor((y?(An(d)-An(y===7?h:r))/864e5/y:a==="month"?k:k/12)/s)-1),m=0;for(let w=0;w<5e4&&i.length<u;w++,R++){let S=R*s,x=a==="day"?[xr(r,S)]:a==="week"?b.map(v=>xr(h,S*7+v)):a==="month"?b.map(v=>gs(c,f+S,v)):[gs(c+S,f,g)];for(let v of[...new Set(x)].sort())if(!(v<r)&&(l&&v>l||e.count&&m>=e.count||(m++,v>=d&&!p.has(v)&&i.push(v+o),i.length>=u)))return i}return i}function xs(n,e,t){if(!Ve(e)||typeof n!="string")return n;let r=Ue(n,e,{from:t,limit:1})[0];if(r)return r;let o=e.until||e.count?Ue(n,e):[];return o[o.length-1]??n}function Vc(n,e,t){let r=n[e],o=n[Be(e)];return typeof r=="string"&&Ve(o)?xs(r,o,t):r}function En(n,e){if(n.onBehalfOf){let{onBehalfOf:i,...s}=n;return`${En(s,e)}, for ${En(i,e)}`}if(n.id===void 0)return n.name??(n.kind==="agent"?"an agent":n.kind);let t=e.graph.getNode(n.id);if(t)return D(e.schema.tryDefinition(t.kind),t);let r=e.seats?.find(i=>i.principal.id===n.id);if(r)return r.label;let o=e.people?.find(i=>i.id===n.id&&(i.kind===void 0||i.kind===n.kind));return o?o.name:n.name?n.name:/(^|:)migration$/.test(n.id)?"the upgrade":/[:_/]/.test(n.id)?{human:"somebody",agent:"an agent",rule:"a rule",system:"the system"}[n.kind]:n.id}var We="$archived",Ae=n=>n?.[We]===!0,Xm=(n,e=!1)=>e==="all"||Ae(n)===e,wr=n=>n===!0||n==="true"?!0:n==="all"?"all":!1,Pn="$leftAlone",ut=new Set([We,Pn]);var re="\0graview:unset",qe=n=>n===void 0||n===re;function zn(n){if(n.op!=="patch-node")return n;let e=t=>Object.fromEntries(Object.entries(t).map(([r,o])=>[r,o===void 0?re:o]));return{...n,before:e(n.before),after:e(n.after)}}function Mn(n){switch(n.op){case"add-node":return{op:"remove-node",node:n.node};case"remove-node":return{op:"add-node",node:n.node};case"patch-node":return{op:"patch-node",id:n.id,before:n.after,after:n.before};case"add-edge":return{op:"remove-edge",edge:n.edge};case"remove-edge":return{op:"add-edge",edge:n.edge}}}function Oe(n){switch(n.op){case"add-node":case"remove-node":return[n.node.id];case"patch-node":return[n.id];case"add-edge":case"remove-edge":return[n.edge.from,n.edge.to]}}var te=class extends Error{constructor(t,r){super(r?`${t}
|
|
2
|
-
\u2192 ${r}`:t);this.hint=r;this.name="SchemaError"}};function Wc(n,e){let t=n,r=new Map;for(let a of t){if(r.has(a.kind))throw new te(`Duplicate node kind "${a.kind}"`,"Each kind may be declared once; merge the two defineNode calls.");r.set(a.kind,a)}let o=new Map;for(let a of t)for(let[d,l]of Object.entries(a.edges)){if(l.to!=="*"){for(let p of l.to)if(!r.has(p))throw new te(`Edge "${d}" on "${a.kind}" points at undeclared kind "${p}"`,`Declared kinds: ${[...r.keys()].join(", ")}`)}let u=o.get(d);u?u.from.push(a.kind):o.set(d,{from:[a.kind],decl:l})}let i=new Map;for(let[a,{from:d,decl:l}]of o){let u=d.map(p=>r.get(p).edges[a].to);i.set(a,{kind:a,from:d,to:u.includes("*")?"*":[...new Set(u.flat())],cardinality:l.cardinality??"many",...l.description===void 0?{}:{description:l.description}})}let s=new Map;for(let a of t)s.set(a.kind,ts(a.fields,{id:Z().check(kn(1)),kind:os(a.kind)}));return{definitions:t,computed:e,kinds:t.map(a=>a.kind),edgeKinds:[...i.keys()],definition(a){let d=r.get(a);if(!d)throw new te(`Unknown node kind "${String(a)}"`,`Declared kinds: ${[...r.keys()].join(", ")}`);return d},tryDefinition(a){return r.get(a)},edge(a){return i.get(a)},edgeAllowed(a,d,l){let u=r.get(d)?.edges[a];return u?u.to==="*"||u.to.includes(l):!1},parseNode(a){let d=a?.kind;if(typeof d!="string")throw new te("Node is missing a `kind`");let l=s.get(d);if(!l)throw new te(`Unknown node kind "${d}"`,`Declared kinds: ${[...r.keys()].join(", ")}`);let u={},p={};for(let[f,g]of Object.entries(a))ut.has(f)?g===!0&&(p[f]=!0):u[f]=g;let c=l.parse(u);return Object.keys(p).length>0?{...c,...p}:c},__node:void 0}}function P(n){return`${n.kind}\0${n.from}\0${n.to}`}var Nn={addedNodes:[],removedNodes:[],changedNodes:[],addedEdges:[],removedEdges:[],touched:[]};function ws(n){return n.addedNodes.length===0&&n.removedNodes.length===0&&n.changedNodes.length===0&&n.addedEdges.length===0&&n.removedEdges.length===0}function qc(n,e){let t=new Set([...Object.keys(n),...Object.keys(e)]),r=[];for(let o of t){let i=n[o],s=e[o];JSON.stringify(i)!==JSON.stringify(s)&&r.push(o)}return r.sort()}function He(n,e){let t=new Map(n.nodes.map(c=>[c.id,c])),r=new Map(e.nodes.map(c=>[c.id,c])),o=e.nodes.filter(c=>!t.has(c.id)),i=n.nodes.filter(c=>!r.has(c.id)),s=[];for(let c of n.nodes){let f=r.get(c.id);if(!f||f===c)continue;let g=qc(c,f);g.length>0&&s.push({before:c,after:f,fields:g})}let a=new Map(n.edges.map(c=>[P(c),c])),d=new Map(e.edges.map(c=>[P(c),c])),l=e.edges.filter(c=>!a.has(P(c))),u=n.edges.filter(c=>!d.has(P(c))),p=new Set;for(let c of o)p.add(c.id);for(let c of i)p.add(c.id);for(let c of s)p.add(c.after.id);for(let c of[...l,...u])p.add(c.from),p.add(c.to);return{addedNodes:o,removedNodes:i,changedNodes:s,addedEdges:l,removedEdges:u,touched:[...p].sort()}}function ye(n,e,t){let r=new Set(t.flatMap(i=>i.op==="patch-node"?[i.id]:"node"in i?[i.node.id]:[i.edge.from,i.edge.to]));if(r.size===0)return Nn;let o=i=>({nodes:i.nodes.filter(s=>r.has(s.id)),edges:i.edges.filter(s=>r.has(s.from)||r.has(s.to))});return He(o(n),o(e))}function Hc(n){let e=n?.issues;return!Array.isArray(e)||e.length===0?n instanceof Error?n.message:String(n):e.map(t=>{let r=t.path?.length?C(String(t.path.at(-1))):null,o=t.message??"is not what the declaration allows";return r?`${r}: ${o}`:o}).join("; ")}var M=class extends Error{constructor(t,r){super(r?`${t}
|
|
3
|
-
${r}`:t);this.hint=r;this.name="GraphError"}},K=class extends M{constructor(t,r){super(r);this.id=t;this.name="MissingRecordError"}};function lt(n,e){try{n.parseNode(e);return}catch(t){if(t instanceof te)throw t;let r=t.issues??[];return{fields:new Set(r.flatMap(i=>i.code==="unrecognized_keys"&&i.keys?[...i.keys]:typeof i.path?.[0]=="string"?[i.path[0]]:[""])),error:t}}}var kr="n\0",Sr="e\0",B=class n{constructor(e,t={}){this.schema=e;this.validate=t.validate??!0}nodes=new Map;edges=new Map;outIndex=new Map;inIndex=new Map;rank=0;ranks=new Map;lapsed=new Map;reordered=!1;counts=new Map;archived=new Set;listeners=new Set;validate;static from(e,t,r={}){let o=new n(e,r);return o.load(t),o}load(e){let t=this.snapshot();this.restore(e);let r=He(t,this.snapshot());return this.emit(r),r}getNode(e){return this.nodes.get(e)}has(e){return this.nodes.has(e)}allNodes(e){return this.reach([...this.nodes.values()],e,this.held)}count(e,t){return t||this.archived.size?this.nodesOfKind(e,t).length:this.counts.get(e)??0}allEdges(e){return this.reach([...this.edges.values()],e,t=>this.archived.has(t.from)||this.archived.has(t.to))}nodesOfKind(e,t){return this.allNodes(t).filter(r=>r.kind===e)}edgesOfKind(e,t){return this.allEdges(t).filter(r=>r.kind===e)}out(e,t,r){return this.reach(this.resolve(this.outIndex.get(e),t,"to"),r,this.held)}in(e,t,r){return this.reach(this.resolve(this.inIndex.get(e),t,"from"),r,this.held)}neighbors(e,t){let r=new Map;for(let o of[...this.out(e,void 0,t),...this.in(e,void 0,t)])r.set(o.id,o);return[...r.values()]}isArchived(e){return this.archived.has(e)}outEdges(e,t){return this.edgesFrom(this.outIndex.get(e),t)}inEdges(e,t){return this.edgesFrom(this.inIndex.get(e),t)}snapshot(){return{nodes:[...this.nodes.values()],edges:[...this.edges.values()]}}get size(){return{nodes:this.nodes.size,edges:this.edges.size}}applyPrimitives(e,t={}){let r=this.snapshot();try{for(let i of e)this.applyOne(i,t.restoring===!0,t.inPlace===!0);this.settleOrder()}catch(i){throw this.restore(r),i}let o=ye(r,this.snapshot(),e);return this.emit(o),o}preview(e,t={}){return n.from(this.schema,this.snapshot(),{validate:this.validate}).applyPrimitives(e,t)}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}restore(e){for(let t of[this.nodes,this.edges,this.outIndex,this.inIndex,this.ranks,this.lapsed,this.counts,this.archived])t.clear();this.reordered=!1;for(let t of e.nodes)this.insertNode(t,!0);for(let t of e.edges)this.insertEdge(t,!0)}tally(e,t){this.counts.set(e,(this.counts.get(e)??0)+t)}place(e,t){let r=t?this.lapsed.get(e):void 0;if(r===void 0){this.ranks.set(e,++this.rank);return}this.ranks.set(e,r),this.lapsed.delete(e),this.reordered=!0}lapse(e){let t=this.ranks.get(e);t!==void 0&&(this.ranks.delete(e),this.lapsed.set(e,t),this.lapsed.size>4096&&this.lapsed.delete(this.lapsed.keys().next().value))}settleOrder(){if(!this.reordered)return;this.reordered=!1;let e=o=>(i,s)=>this.ranks.get(o+i[0])-this.ranks.get(o+s[0]),t=[...this.nodes.entries()].sort(e(kr));this.nodes.clear();for(let[o,i]of t)this.nodes.set(o,i);let r=[...this.edges.entries()].sort(e(Sr));this.edges.clear();for(let[o,i]of r)this.edges.set(o,i)}emit(e){if(!(e.addedNodes.length===0&&e.removedNodes.length===0&&e.changedNodes.length===0&&e.addedEdges.length===0&&e.removedEdges.length===0))for(let t of this.listeners)t(e)}applyOne(e,t,r){switch(e.op){case"add-node":this.insertNode(e.node,t,r);return;case"remove-node":{let o=e.node.id,i=this.nodes.get(o);if(!i)throw new K(o,`Cannot remove missing node "${o}"`);for(let s of[...this.outEdges(o),...this.inEdges(o)])this.deleteEdge(s);this.tally(i.kind,-1),this.archived.delete(o),this.nodes.delete(o),this.lapse(kr+o),this.outIndex.delete(o),this.inIndex.delete(o);return}case"patch-node":{let o=this.nodes.get(e.id);if(!o)throw new K(e.id,`Cannot patch missing node "${e.id}"`);let i={...o};for(let[a,d]of Object.entries(e.after))qe(d)?delete i[a]:i[a]=d;let s=t?i:this.checkPatch(o,i,Object.keys(e.after));this.nodes.set(e.id,s),this.archived[Ae(s)?"add":"delete"](e.id),s.kind!==o.kind&&(this.tally(o.kind,-1),this.tally(s.kind,1));return}case"add-edge":this.insertEdge(e.edge,t,r);return;case"remove-edge":{if(!this.edges.has(P(e.edge)))throw new K(P(e.edge),`Cannot remove missing edge ${P(e.edge)}`);this.deleteEdge(e.edge);return}}}check(e){if(!this.validate)return e;try{return this.schema.parseNode(e)}catch(t){throw this.refusal(e,t)}}checkPatch(e,t,r){if(!this.validate)return t;let o=this.schema.tryDefinition(String(t.kind))?.fields?.shape;if(!o)return this.check(t);for(let a of r){if(a==="id"||a==="kind"||ut.has(a))continue;let d=o[a];if(!d){delete t[a];continue}let l=d.safeParse(t[a]);l.success&&(l.data===void 0?delete t[a]:t[a]=l.data)}let i=lt(this.schema,t);if(i===void 0)return t;let s=lt(this.schema,e)?.fields??new Set;if([...i.fields].some(a=>r.includes(a)||!s.has(a)))throw this.refusal(t,i.error);return t}refusal(e,t){if(t instanceof te)return t;{let r=e?.id??"?",o=e?.kind??"?",i=this.schema.tryDefinition(o),s=i&&e&&typeof e=="object"?D(i,e):r;return new M(`${s} does not match what ${o} declares`,Hc(t))}}insertNode(e,t,r=!1){if(this.nodes.has(e.id))throw new M(`Duplicate node id "${e.id}"`);this.nodes.set(e.id,t?e:this.check(e)),Ae(e)&&this.archived.add(e.id),this.tally(e.kind,1),this.place(kr+e.id,r)}insertEdge(e,t,r=!1){let o=this.nodes.get(e.from),i=this.nodes.get(e.to);if(!o||!i){let a=o?e.to:e.from;throw new K(a,`Edge "${e.kind}" references missing node "${a}"`)}if(this.validate&&!t&&!this.schema.edgeAllowed(e.kind,o.kind,i.kind)){let a=this.schema.edge(e.kind);throw new M(`Edge "${e.kind}" is not declared from ${o.kind} to ${i.kind}`,a?`Declared: ${a.from.join("|")} -> ${a.to==="*"?"*":a.to.join("|")}`:`No edge kind "${e.kind}" is declared in this schema`)}let s=P(e);this.edges.has(s)||(this.edges.set(s,e),this.place(Sr+s,r),this.index(this.outIndex,e.from,s),this.index(this.inIndex,e.to,s))}deleteEdge(e){let t=P(e);this.edges.delete(t),this.lapse(Sr+t),this.outIndex.get(e.from)?.delete(t),this.inIndex.get(e.to)?.delete(t)}index(e,t,r){(e.get(t)??e.set(t,new Set).get(t)).add(r)}edgesFrom(e,t){if(!e)return[];let r=[];for(let o of e){let i=this.edges.get(o);i&&(t===void 0||i.kind===t)&&r.push(i)}return r}resolve(e,t,r){let o=[];for(let i of this.edgesFrom(e,t)){let s=this.nodes.get(i[r]);s&&o.push(s)}return o}held=e=>this.archived.has(e.id);reach(e,t,r){let o=t?.archived??!1;return o==="all"||!o&&!this.archived.size?e:e.filter(i=>r(i)===o)}};var ft=class extends Error{constructor(t,r){super(`No invariant registered under "${t}" (required by node "${r}")`);this.invariant=t;this.nodeId=r;this.name="UnregisteredInvariantError"}};function Yc(n,e){return{...e,name:n}}var pt=class extends Error{constructor(e){super(e),this.name="RuleBudgetError"}};function ks(n,e,t){try{return e().map(r=>r.status?r:{...r,status:"violated"})}catch(r){let o=r instanceof pt,i=r instanceof Error?r.message:String(r),s=n.label??n.name.replace(/-/g," ");return[{invariant:n.name,status:o?"over-budget":"could-not-judge",...t!==void 0?{subjectId:t}:{},label:s,message:`${s} could not be judged: ${i}`,nodeIds:t!==void 0?[t]:[],repairs:[]}]}}function Ye(n,e,t={}){let r=t.context??{},o=t.today===void 0?{}:{today:t.today},i=t.onUnregistered??"skip",s=new Set(e.map(c=>c.name)),a=[];for(let c of e)c.scope==="graph"&&a.push(...ks(c,()=>c.evaluate({graph:n,subject:void 0,context:r,...o}),void 0));let d=e.filter(c=>c.scope!=="graph"),l=new Map;for(let c of d){let f=c.scope.kind,g=l.get(f);g?g.push(c):l.set(f,[c])}for(let c of n.allNodes()){let f=n.schema.tryDefinition(c.kind),g=f?.requiresInvariant?.(c)??null;if(t.subjectFilter&&!t.subjectFilter(c,r))continue;if(g!==null&&!s.has(g)){if(i==="throw")throw new ft(g,c.id);continue}let h=!Lt(f,c,t.today);for(let b of l.get(c.kind)??[]){if(h&&b.judgesPast!==!0)continue;let y=b.scope.match;y&&!y(c)||a.push(...ks(b,()=>b.evaluate({graph:n,subject:c,context:r,...o}),c.id))}}let u=new Set,p=a.filter(c=>{let f=`${c.message}|${[...c.nodeIds].sort().join(",")}`;return u.has(f)?!1:(u.add(f),!0)}).map(c=>{let f=Ft(c.message);return f===c.message?c:{...c,message:f}});return $r?$r(n,e,p,t.today):p}var $r;function gy(n){$r=n}function Jc(n,e){let t=new Set(e);return n.filter(r=>r.nodeIds.some(o=>t.has(o))||r.subjectId!==void 0&&t.has(r.subjectId))}function Xc(n){let e=new Set(n.map(r=>r.invariant)).size;if(e===0)return"All rules hold";let t=`${e} ${e===1?"rule":"rules"} broken`;return n.length>e?`${t} in ${n.length} places`:t}var ht=(n,e)=>n==="*"||n.includes(e);function T(n){let e=n.onBehalfOf;if(!e)return n;let t=e.roles??[],r=n.roles===void 0?t:n.roles.filter(o=>t.includes(o));return{...n,...e.id!==void 0?{id:e.id}:{},roles:r}}var V=n=>n.kind==="system"&&n.onBehalfOf===void 0,be=(n,e)=>n.roles==="*"||(e.roles??[]).some(t=>n.roles.includes(t));function Ss(n){return Oo(n.map(e=>Ze(C(e).toLowerCase())),"or")}function ve(n,e,t,r,o,i,s={},a,d,l){if(!n)return{ok:!0};if(V(e))return{ok:!0};if(e=T(e),o!==void 0){if(ve(n,e,t,r,void 0,i).ok)return{ok:!0};let f=!1;if(o.some(y=>ve(n,e,y,r,void 0,i).ok)){if(!d||i===void 0||e.id!==void 0&&d()===e.id||!l&&n.grants.some(y=>y.roles!=="*"&&be(y,e)&&o.some(k=>ht(y.mutations,k))))return{ok:!0};f=!0}let g=f?[t]:[t,...o],h=[...new Set(g.flatMap(y=>_r(n,y,r)))].sort(),b=(f?"only on what you made; ":"")+(h.length===0?o.length===0?"no declared act creates or changes it, so no role can":"no role can":`${Ss(h)} can`);return{ok:!1,refusal:{mutation:t,...r===void 0?{}:{kind:r},wouldNeed:h,message:$s(n,g,r,b,s)}}}let u=!1;for(let f of n.grants){if(!be(f,e)||!ht(f.mutations,t)||f.kinds!==void 0&&f.kinds!=="*"&&(r===void 0||!f.kinds.includes(r))||f.self&&(i===void 0||e.id===void 0||i!==e.id))continue;let g=f.ownEnd?a?.()??[]:[e.id];if(!g.length||g.some(h=>h!==e.id)){u=!0;continue}return{ok:!0}}let p=_r(n,t,r),c=u?"only on your own end of the link":p.length===0?"no role can":`${Ss(p)} can`;return{ok:!1,refusal:{mutation:t,...r===void 0?{}:{kind:r},wouldNeed:p,message:$s(n,[t],r,c,s)}}}function $s(n,e,t,r,o){let i=[...new Set(e.flatMap(a=>_s(n,a,t)))],s=o.act?.(e[0]);return`Not permitted: ${s?`\u201C${s}\u201D`:e[0]}${t?` on ${Ze(o.noun?.(t)??t)}`:""} \u2014 ${r}.`+(i.length>0?` ${i.join(" ")}`:"")}function _s(n,e,t){return[...new Set(Rs(n,e,t).flatMap(r=>r.describe||[]))]}var Rs=(n,e,t)=>n.grants.filter(r=>ht(r.mutations,e)&&(t===void 0||ht(r.kinds??"*",t)));function _r(n,e,t){let r=Rs(n,e,t);return r.some(o=>o.roles==="*")?[]:[...new Set(r.flatMap(o=>o.roles))].sort()}function Rr(n,e,t){return n?t.filter(r=>{let o=T(e).id;return Ar(r).some(i=>ve(n,e,r.name,i,void 0,o,void 0,()=>[o??[]].flat()).ok)}):t}var Ar=n=>n.subject&&n.subject.kinds!=="*"?n.subject.kinds:[void 0];var X=class extends Error{constructor(t,r="refused"){super(t);this.sentence=t;this.reason=r;this.name="ActRefusal"}};var In=class{constructor(e,t,r){this.present=e;this.timeline=t;this.unversioned=r}nodes=new Map;edges=new Map;touching=new Map;seq=Number.MAX_SAFE_INTEGER;wrote=new Map;begin(e){this.seq=e,this.wrote.clear()}writerOf(e){return t=>{let r=`${e}\0${t}`;return this.wrote.has(r)?this.wrote.get(r):this.timeline?.writers?.writerAt(e,t,this.seq)}}note(e,t){let r=e.op==="add-node"?e.node.id:e.op==="patch-node"?e.id:"";if(r===""||this.unversioned?.has(r))return;let o=e.op==="add-node"?Object.keys(e.node):Object.keys(e.after);for(let i of o)i!=="id"&&i!=="kind"&&this.wrote.set(`${r}\0${i}`,t(r,i))}node(e){return this.nodes.has(e)?this.nodes.get(e)??void 0:this.present.getNode(e)}setNode(e,t){this.nodes.set(e,t)}setEdge(e,t){let r=P(e);this.edges.set(r,t?e:null);for(let o of[e.from,e.to]){let i=this.touching.get(o);i||this.touching.set(o,i=new Set),i.add(r)}}incident(e){let t=new Map;for(let r of[...this.present.outEdges(e),...this.present.inEdges(e)]){let o=P(r);this.edges.has(o)||t.set(o,r)}for(let r of this.touching.get(e)??[]){let o=this.edges.get(r);o&&t.set(r,o)}return[...t.values()]}undo(e){switch(e.op){case"add-node":this.setNode(e.node.id,null);return;case"remove-node":this.setNode(e.node.id,e.node);return;case"patch-node":{if(this.unversioned?.has(e.id))return;let t=this.node(e.id);if(!t)return;this.setNode(e.id,As(t,e.before));return}case"add-edge":this.setEdge(e.edge,!1);return;case"remove-edge":this.setEdge(e.edge,!0);return}}apply(e){switch(e.op){case"add-node":this.setNode(e.node.id,e.node);return;case"remove-node":for(let t of this.incident(e.node.id))this.setEdge(t,!1);this.setNode(e.node.id,null);return;case"patch-node":{if(this.unversioned?.has(e.id))return;let t=this.node(e.id);if(!t)return;this.setNode(e.id,As(t,e.after));return}case"add-edge":this.setEdge(e.edge,!0);return;case"remove-edge":this.setEdge(e.edge,!1);return}}};function As(n,e){let t={...n};for(let[r,o]of Object.entries(e))qe(o)?delete t[r]:t[r]=o;return t}var Qc=n=>n.op==="add-node"||n.op==="remove-node"?n.node.id:n.op==="patch-node"?n.id:void 0;function Or(n,e,t,r){let o=u=>{let p=e.node(u);return p?t.served(p,e.writerOf(u))!==void 0:t.sees?.(u)??!1},i=Qc(n);if(i===void 0){let u=n.edge,p=t.edgeClean(u)&&o(u.from)&&o(u.to);return e.apply(n),{primitives:p?[n]:[],faithful:!0}}let s=e.node(i),a=s?t.served(s,e.writerOf(i)):void 0;e.apply(n),e.note(n,r);let d=e.node(i),l=d?t.served(d,e.writerOf(i)):void 0;if(!a&&!l)return{primitives:[],faithful:!1};if(!a&&l){let u=e.incident(i).filter(c=>t.edgeClean(c)&&o(c.from===i?c.to:c.from)).map(c=>({op:"add-edge",edge:c})),p=n.op==="add-node"&&l===n.node&&u.length===0;return{primitives:p?[n]:[{op:"add-node",node:l},...u],faithful:p}}if(a&&!l){let u=n.op==="remove-node"&&a===s;return{primitives:u?[n]:[{op:"remove-node",node:a}],faithful:u}}if(n.op==="patch-node"){let u=(c,f)=>g=>g in c==(f!==void 0&&g in f);if(Object.keys(n.after).every(c=>u(a,s)(c)&&u(l,d)(c)))return{primitives:[n],faithful:!0};let p=c=>Object.fromEntries(Object.keys(n.after).map(f=>[f,f in c?c[f]:re]));return{primitives:[{op:"patch-node",id:i,before:p(a),after:p(l)}],faithful:!1}}return{primitives:[{op:"remove-node",node:a},{op:"add-node",node:l}],faithful:!1}}function Os(n,e,t){if(n.length===0)return[];let r=e.log.all(),o=r[0]?.seq??0,i=n.every(c=>r[c.seq-o]?.id===c.id),s=new In(e.present,e);if(!i)return s.begin(e.log.length??o+r.length),n.map(c=>{let f=T(c.author).id,g=c.primitives.map(h=>Or(h,s,t,()=>f));return{op:c,primitives:g.flatMap(h=>h.primitives),faithful:g.every(h=>h.faithful)}});let a=new Set(n.map(c=>c.seq)),d=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY;for(let c of a)c<d&&(d=c),c>l&&(l=c);d-=o,l-=o;let u=eu(r,d,e.present,t),p=u?new In(e.present,e,u.unversioned):s;for(let c=r.length-1;c>=d;c--){let f=r[c].primitives;for(let g=f.length-1;g>=0;g--)p.undo(f[g])}return nu(n,r,d,l,a,p,u?.judge??t,e)}function eu(n,e,t,r){let{sees:o,names:i}=r;if(!o||!i)return;let s=new Set,a=new Set,d=new Set,l=(p,c)=>{s.has(p)||a.has(p)||(o(p)?i(c)?(a.add(p),d.delete(p)):d.add(p):(s.add(p),d.delete(p)))};for(let p=e;p<n.length;p++)for(let c of n[p].primitives)c.op==="add-node"||c.op==="remove-node"?l(c.node.id,c.node):c.op==="patch-node"&&(l(c.id,c.before),l(c.id,c.after));for(let p of d){let c=t.getNode(p);c&&i(c)&&(d.delete(p),a.add(p))}return{unversioned:new Set([...d,...s]),judge:{...r,served:(p,c)=>d.has(p.id)?p:s.has(p.id)?void 0:r.served(p,c)}}}function nu(n,e,t,r,o,i,s,a){let d=new Map;for(let l=t;l<=r;l++){let u=e[l];if(i.begin(u.seq),!o.has(u.seq)){for(let f of u.primitives)i.apply(f);continue}let p=(f,g)=>a.writers?.writerAt(f,g,u.seq+1),c=u.primitives.map(f=>Or(f,i,s,p));d.set(u.seq,{op:u,primitives:c.flatMap(f=>f.primitives),faithful:c.every(f=>f.faithful)})}return n.map(l=>d.get(l.seq))}function _y(n,e,t,r){let o=new In(e.present,e);return o.begin(e.log.length??e.log.all().length),n.flatMap(i=>Or(i,o,t,()=>r).primitives)}var Ps="A change you cannot see",zs={kind:"system",id:"withheld",name:"Someone"};function Je(n){return n.withheld===!0}var jn=Oe,Ms=(n,e)=>Object.entries(n).some(([t,r])=>t!=="id"&&t!=="kind"&&j(r,e));function Ns(n){if(typeof n!="function")return n;let e=n,t=r=>e(r.id)&&!Ms(r,e)?r:void 0;return{sees:e,shows:e,served:t,servedWith:t,optional:()=>!1,kindOf:()=>{}}}function j(n,e){if(typeof n=="string")return!e(n);if(n===null||typeof n!="object")return!1;if(Array.isArray(n)){for(let t=0;t<n.length;t++)if(j(n[t],e))return!0;return!1}for(let t in n)if(Object.hasOwn(n,t)&&(!e(t)||j(n[t],e)))return!0;return!1}function Is(n,e){let t=r=>!e(r);return n.primitives.some(r=>jn(r).some(t))||[...n.writes,...n.reads].some(t)||n.mutation!==null&&j(n.mutation.args,e)}function tu(n,e){if(jn(n).every(e.shows))switch(n.op){case"add-node":{let t=e.served(n.node);return t?t===n.node?n:{op:"add-node",node:t}:void 0}case"remove-node":{let t=n.node;return Ms(t,e.sees)?{op:"remove-node",node:Object.fromEntries(Object.entries(t).filter(([r,o])=>r==="id"||r==="kind"||!j(o,e.sees)))}:n}case"patch-node":{let t=e.kindOf(n.id),r={};for(let[i,s]of Object.entries(n.after))if(!j(s,e.sees))r[i]=s;else if(t!==void 0&&e.optional(t,i))r[i]=re;else return;let o=Object.fromEntries(Object.entries(n.before).filter(([,i])=>!j(i,e.sees)));return{op:"patch-node",id:n.id,before:o,after:r}}case"add-edge":case"remove-edge":return j(n.edge,e.sees)?void 0:n}}function Er(n,e,t){let r=Ns(e),o=i=>r.shows(i)&&js(r,i);return{id:n.id,seq:n.seq,batch:n.batch,author:zs,intent:Ps,mutation:null,primitives:t??n.primitives.flatMap(i=>{let s=tu(i,r);return s?[s]:[]}),inverse:[],reads:n.reads.filter(o),writes:n.writes.filter(o),at:n.at,...n.undoes!==void 0?{undoes:n.undoes}:{},withheld:!0}}function Xe(n,e){let t=Ns(e);if(t.hides?.()===!1)return[...n];let r=t.pin?.()??t;if(r.redact)return r.redact(n);if(r.timeline){let o={served:(i,s)=>r.servedWith(i,s),edgeClean:i=>!j(i,r.sees),sees:r.sees,names:i=>j(i,r.sees)};return Os(n,r.timeline,o).map(({op:i,primitives:s,faithful:a})=>(!i.withheld&&a?Es(i,r,s):void 0)??Er(i,r,s))}return n.map(o=>(!o.withheld&&!Is(o,r.shows)?Es(o,r):void 0)??Er(o,r))}function Es(n,e,t){if(t&&t.length<n.primitives.length){if(!t.length)return;n={...n,primitives:t,inverse:n.inverse.filter(c=>jn(c).every(e.shows))}}let r=c=>e.sees(c)&&js(e,c),o=n.reads.filter(r),i=new Set(n.primitives.flatMap(jn)),s=n.writes.filter(c=>r(c)||e.sees(c)&&i.has(c)),a=o.length===n.reads.length&&s.length===n.writes.length?n:{...n,reads:o,writes:s},d=e.actor!==void 0&&T(n.author).id===e.actor;if(!d&&n.described?.some(c=>!e.sees(c)))return;if(!j(n,e.sees))return a;let l=new Set,u=c=>{if(typeof c=="string")l.add(c);else if(Array.isArray(c))for(let f of c)u(f);else if(c!==null&&typeof c=="object")for(let[f,g]of Object.entries(c))l.add(f),u(g)};t&&u(t);let p=c=>e.sees(c)||l.has(c);if(!j(a.inverse,p))return d&&n.mutation&&u(n.mutation.args),j({...a,primitives:[],inverse:[]},d?p:e.sees)?void 0:a}function js(n,e){return n.timeline===void 0||n.kindOf(e)!==void 0}var Ee=class extends M{constructor(t){super(t.message);this.check=t;this.name="UndoBlockedError"}get blockedBy(){return this.check.blockedBy}};function Tn(n,e){let t=new Set(e),r=n.undoneIds(),o=n.all().filter(f=>t.has(f.batch)&&!r.has(f.id)),i=[...n.epochs()].reverse().find(f=>f.horizon);if(i){let f=new Set(n.all().map(h=>h.batch)),g=e.filter(h=>!f.has(h));if(g.length>0)return{ok:!1,ops:o,blockedBy:[],includeBatches:[],reason:"missing",message:`Cannot undo ${g.map(h=>`batch ${h}`).join(", ")}: it is not after the undo horizon at op ${i.seq}${i.at?` (${i.at})`:""}. What was done before the horizon is archived, and undo does not reach behind it.`}}if(o.length===0)return{ok:!1,ops:o,blockedBy:[],includeBatches:[],reason:"missing",message:e.length===0?"No batch given to undo":`Nothing live to undo in ${e.join(", ")} \u2014 already undone, or never applied`};if(o.some(Je))return{ok:!1,ops:o,blockedBy:[],includeBatches:[],reason:"forbidden",message:o.every(Je)?"Cannot undo a change you cannot see: only somebody who can see it can take it back.":"Cannot undo this here: part of it is a change you cannot see, and only somebody who can see it can take it back."};if(o.some(f=>f.enabledModules!==void 0))return{ok:!1,ops:o,blockedBy:[],includeBatches:[],message:"Cannot undo turning a module off or on: it is changed by turning the module the other way."};let s=new Set;for(let f of o)for(let g of f.writes)s.add(g);let a=Math.min(...o.map(f=>f.seq)),d=n.epochs().find(f=>f.change!==void 0&&f.seq>a);if(d){let f=o.find(g=>g.seq<d.seq);return{ok:!1,ops:o,blockedBy:[],includeBatches:[],message:`Cannot undo "${f.intent}": ${f.intent===d.change?"it changed the declaration":`it was done before the declaration changed (${d.change})`}, and undo does not reach back across that change.`}}let l=new Map(n.all().map(f=>[f.id,f.seq])),u=[];for(let f of n.all()){if(f.seq<=a||t.has(f.batch)||r.has(f.id)||f.undoes!==void 0&&(l.get(f.undoes)??-1)>a)continue;let g=f.reads.filter(h=>s.has(h));g.length>0&&u.push({op:f,overlap:g})}if(u.length===0)return{ok:!0,ops:o};let p=u.filter(f=>!Je(f.op)).map(f=>`"${f.op.intent}" (op ${f.op.id}, read ${f.overlap.join(", ")})`).join("; ");if(u.some(f=>Je(f.op)))return{ok:!1,ops:o,blockedBy:u,includeBatches:[],message:`Cannot undo on its own \u2014 ${p?`a later operation depends on it: ${p}; and `:""}a later change you cannot see depends on it, which only somebody who can see it can take back.`};let c=[...new Set(u.map(f=>f.op.batch))];return{ok:!1,ops:o,blockedBy:u,includeBatches:c,message:`Cannot undo on its own \u2014 a later operation depends on it: ${p}. Include ${c.map(f=>`batch ${f}`).join(", ")} to undo them together.`}}function Ts(n){return[...n].sort((e,t)=>t.seq-e.seq).flatMap(e=>e.inverse)}var Qe=class extends Error{refusal;constructor(e){super(e.message),this.name="PermissionDeniedError",this.refusal=e}};function ru(n){let e=n instanceof Error?n.message:String(n);if(n instanceof Qe){let t=n.refusal.wouldNeed;return{reason:"forbidden",sentence:e,...t.length>0?{wouldNeed:[...t]}:{}}}return n instanceof K?{reason:"missing",sentence:e}:n instanceof X?{reason:n.reason,sentence:n.sentence}:n instanceof Ee?{reason:n.check.reason??"invalid",sentence:e}:{reason:"invalid",sentence:e}}var xe=class extends M{constructor(t,r){super(`Invalid arguments for mutation "${t}"`,r.map(o=>`${o.path.map(String).join(".")||"(root)"}: ${o.message}`).join("; "));this.mutation=t;this.issues=r;this.name="InvalidArguments"}};function Gy(n){let e=/^(edit|remove|archive|unarchive|merge|leave-alone|allow-tidying|skip|detach|split)-(.+)$/.exec(n);return e?{act:e[1],kind:e[2]}:void 0}var Zs=["connect","disconnect"],Fs=n=>n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),Ls=(n,e,t)=>`${n}-${e}-${Fs(t)}`;function Ky(n,e){let t=/^(connect|disconnect)-(.+)$/.exec(n);if(t){for(let[r,o]of e)if(t[2].startsWith(`${r}-`)){for(let i of o)if(t[2]===`${r}-${Fs(i)}`)return{act:t[1],kind:r,relation:i}}}}var Ds=n=>`${/^[aeiou]/i.test(n)?"an":"a"} ${n}`;function Cs(n,e){let t=e.also?` (${e.also})`:"";return{title:`${e.one?`${n==="connect"?"Set":"Clear"} the ${e.to}`:`${n==="connect"?"Link":"Unlink"} ${Ds(e.to)}`}${t}`,fromTheOtherEnd:`${n==="connect"?"Link":"Unlink"} ${Ds(e.from)}${t}`}}var ou=n=>`Op "${n.id}" has seq ${n.seq}, so the log begins at seq ${n.seq}: a log that begins past 0 begins at its undo horizon, and none was given (a checkpoint epoch, or { horizon })`,en=class n{ops=[];marks=[];start=0;get length(){return this.start+this.ops.length}get horizon(){return this.start}all(){return this.ops}opsFrom(e){return this.ops.slice(Math.max(0,e-this.start))}append(e){if(e.seq!==this.length)throw new Error(this.length===0&&e.seq>0?ou(e):`Op "${e.id}" has seq ${e.seq} but the log is ${this.length} long`);this.ops.push(e)}static from(e,t=[],r={}){let o=new n,i=[...t].reverse().find(d=>d.horizon),s=r.horizon??i?.seq??0;if(!Number.isInteger(s)||s<0)throw new Error(`A log cannot begin at seq ${s}`);if(i&&r.horizon!==void 0&&i.seq!==r.horizon)throw new Error(`A log said to begin at seq ${r.horizon} has its checkpoint at seq ${i.seq}`);let a=e[0];if(a&&s>0&&a.seq!==s)throw new Error(`A log compacted at seq ${s} begins with op "${a.id}" at seq ${a.seq}`);o.start=s;for(let d of e)o.append(d);for(let d of t)o.markEpoch(d);return o}replace(e,t=[],r={}){let o=n.from(e,t,r);this.ops=o.ops,this.marks=o.marks,this.start=o.start}epochs(){return this.marks}lastEpoch(){return this.marks.at(-1)}markEpoch(e){if(!Number.isInteger(e.seq)||e.seq<0||e.seq>this.length)throw new Error(`An epoch at seq ${e.seq} starts past the end of a log ${this.length} long`);if(e.seq<this.start)throw new Error(`An epoch at seq ${e.seq} is behind the horizon at seq ${this.start}: it went to the archive with the ops before it`);let t=this.lastEpoch();if(t&&e.seq<t.seq)throw new Error(`An epoch at seq ${e.seq} comes before the last one, at seq ${t.seq}`);this.marks.push(e)}truncate(e){if(!Number.isInteger(e)||e<this.start||e>this.length)throw new Error(`Cannot cut a log ${this.length} long back to ${e}`);let t=this.lastEpoch();if(t&&t.seq>e)throw new Error(`Cannot cut the log back to ${e}: an epoch begins at seq ${t.seq}`);return this.ops.splice(e-this.start)}checkpointAt(e,t,r={}){if(!Number.isInteger(t)||t<this.start||t>this.length)throw new Error(`No checkpoint at seq ${t}: this log holds seqs ${this.start} to ${this.length}`);let o=[...this.marks].reverse().find(a=>a.seq<=t);if(o?.seq===t)return{...o,horizon:!0};let i=this.fold(e,{...r,...o?{from:o}:{},to:t}).snapshot(),s=this.ops[t-1-this.start]?.at??o?.at;return{seq:t,base:i,...o?.version!==void 0?{version:o.version}:{},...s!==void 0?{at:s}:{},horizon:!0}}compact(e){if(!Number.isInteger(e.seq)||e.seq<this.start||e.seq>this.length)throw new Error(`Cannot compact at seq ${e.seq}: this log holds seqs ${this.start} to ${this.length}`);let t=this.ops.slice(0,e.seq-this.start),r=this.marks.filter(o=>o.seq<e.seq);return this.ops=this.ops.slice(e.seq-this.start),this.marks=[{...e,horizon:!0},...this.marks.filter(o=>o.seq>e.seq)],this.start=e.seq,{ops:t,epochs:r}}get(e){return this.ops.find(t=>t.id===e)}live(){let e=this.undoneIds();return this.ops.filter(t=>!e.has(t.id))}undoneIds(){return Pe(this.ops)}opsInBatch(e){return this.ops.filter(t=>t.batch===e)}batches(){return Pr(this.ops,this.undoneIds())}fold(e,t={}){let r=t.from?.seq??0;if(r<this.start)throw new Error(t.from?`An epoch at seq ${r} is behind the horizon at seq ${this.start}: fold from the checkpoint`:`A log compacted at seq ${this.start} does not fold from empty: fold from its checkpoint`);let o=t.from?.base??{nodes:[],edges:[]},i=B.from(e,o,t.validate!==void 0?{validate:t.validate}:{}),s=t.to??this.length;for(let a of this.ops.slice(r-this.start,Math.max(0,s-this.start)))iu(i,a);return i}toJSON(){return[...this.ops]}};function iu(n,e){if(e.undoes!==void 0){n.applyPrimitives(e.primitives,{restoring:!0});return}try{n.applyPrimitives(e.primitives)}catch{n.applyPrimitives(e.primitives,{restoring:!0})}}function Pe(n){let e=new Map;for(let r of n){if(!r.undoes)continue;let o=e.get(r.undoes);o?o.push(r.id):e.set(r.undoes,[r.id])}let t=new Map;for(let r=n.length-1;r>=0;r--){let o=n[r],i=e.get(o.id)??[];t.set(o.id,!i.some(s=>t.get(s)===!0))}return new Set(n.filter(r=>t.get(r.id)===!1).map(r=>r.id))}function Pr(n,e){let t=[],r=new Map;for(let o of n){let i=r.get(o.batch);i?i.push(o):(r.set(o.batch,[o]),t.push(o.batch))}return t.map(o=>{let i=r.get(o)??[],s=i[0];return{id:o,author:s.author,intent:s.batchIntent??s.intent,at:s.at,...s.lineage?{lineage:s.lineage}:{},ops:i,undone:i.every(a=>e.has(a.id))}})}function zr(n){return n?.automated===!0&&n.kind!=="human"&&n.kind!=="rule"}var Ks=n=>n?.[Pn]===!0,su=(n,e)=>Ks(("graph"in n?n.graph:n).getNode(e));function Gs(n,e,t){let r=n.tryDefinition(e);return t===void 0?r?.tidying:r?.edges?.[t]?.tidying}var Us=n=>JSON.stringify(n.map(e=>[e.name,e.args]),(e,t)=>t&&typeof t=="object"&&!Array.isArray(t)?Object.fromEntries(Object.entries(t).sort()):t);function Bs(n,e){let t=au(n);return[e,...e.map(r=>[r])].map(r=>t.get(Us(r))).find(Boolean)}function au(n){let e=Pe(n),t=new Map(n.map(o=>[o.id,o])),r=new Map;for(let o of n){let i=o.undoes!==void 0&&!e.has(o.id)&&!o.withheld?t.get(o.undoes):void 0,s=i?.suggests??(i?.mutation&&(i.lineage||o.undoneLineage)?[i.mutation]:[]);if(s.length>0)for(let a of[s,...s.map(d=>[d])])r.set(Us(a),o)}return r}function Vs(n,e,t,r,o={}){let i=o.declaration!==!1,s=(a,d)=>`${r} may not ${a}: ${d}.`;for(let a of t){let d="edge"in a?a.edge:void 0,l=(d?[d.from,d.to]:["id"in a?a.id:a.node.id]).map(u=>e.getNode(u)??("node"in a?a.node:void 0));for(let u of l){if(!u)continue;if(Ks(u))return s(`change \u201C${D(n.tryDefinition(u.kind),u)}\u201D`,"a person said to leave it alone");if(!i)continue;let p=Gs(n,u.kind);if(p==="never")return s(`change ${Q(n,u.kind)} on its own`,"the app says they are never tidied");if(d&&p==="no-links")return s(`link or unlink ${Q(n,u.kind)} on its own`,"the app says they are never linked automatically")}if(d&&i&&l[0]&&Gs(n,l[0].kind,d.kind)==="never")return s(`${a.op==="add-edge"?"make":"break"} a \u201C${d.kind}\u201D link on its own`,"the app says that relation is never tidied")}}function du(n,e){if(!e||n.length===0)return null;let t=e.roles,r=o=>t?o.wouldNeed.some(i=>t.includes(i)):o.wouldNeed.length>0;return n.every(({refusal:o})=>r(o))?e:null}var gt={scene:0,overview:10,rail:20,popover:30,dialog:40,toast:50},cu={plots:0,stage:1,tag:2,ties:2,lines:3,tieLabels:4,occupants:6,seatMarks:7,zoom:8,card:10,opened:11},uu={under:0,raised:1,over:2},Mr=n=>`--graview-layer-${n}`,lu=n=>`var(${Mr(n)}, ${gt[n]})`;function fu(){return Object.keys(gt).map(n=>` ${Mr(n)}: ${gt[n]};`).join(`
|
|
4
|
-
`)}function pu(n){let e=n.onBehalfOf??n;return{kind:e.kind,...e.id!==void 0?{id:e.id}:{},...e.name!==void 0?{name:e.name}:{},...e.roles!==void 0?{roles:e.roles}:{}}}function Ws(){return`sub_${(globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`).replace(/-/g,"").slice(0,20)}`}function qs(n){return{...n,id:n.id??Ws(),at:n.at??new Date().toISOString()}}function hu(n=[]){let e=[...n],t=new Set,r=()=>{for(let o of t)o()};return{list:o=>o===void 0?e:e.filter(i=>i.who.id===o),add(o){let i=qs(o);return e=[...e.filter(s=>s.id!==i.id),i],r(),i},remove(o){let i=e.length;e=e.filter(a=>a.id!==o);let s=e.length<i;return s&&r(),s},onChange(o){return t.add(o),()=>t.delete(o)}}}var Ys=(n,e)=>`${n}\0${e}`,Hs=new WeakMap;function gu(n){let e=new Map;return{base:n,end:n,read:[],fields:e,written:[],seqOf:new Map,writers:{writerAt:(r,o,i)=>{let s=e.get(Ys(r,o));if(!s)return;let a=0,d=s.length;for(;a<d;){let l=a+d>>1;s[l].seq<i?a=l+1:d=l}return a===0?void 0:s[a-1].by}}}}function mu(n){if(n.op==="add-node")return[n.node.id,Object.keys(n.node).filter(e=>e!=="id"&&e!=="kind")];if(n.op==="patch-node")return[n.id,Object.keys(n.after).filter(e=>!qe(n.after[e]))]}function yu(n,e){let t=n.end,r=T(e.author).id,o=e.undoes!==void 0?n.seqOf.get(e.undoes):void 0,i=[];for(let s of e.primitives){let a=mu(s);if(!a)continue;let[d,l]=a;for(let u of l){let p=e.undoes===void 0?r:o!==void 0?n.writers.writerAt(d,u,o):void 0,c=Ys(d,u),f=n.fields.get(c);f||n.fields.set(c,f=[]),f.push({seq:t,by:p}),i.push(c)}}n.written.push({seq:t,keys:i}),n.seqOf.set(e.id,t),n.read.push(e),n.end++}function bu(n,e){for(;n.written.length>0&&n.written.at(-1).seq>=e;){let{keys:t}=n.written.pop();for(let r of t)n.fields.get(r)?.pop()}for(let t of n.read.slice(e-n.base))n.seqOf.delete(t.id);n.read.length=e-n.base,n.end=e}function mt(n){let e=n.all(),t=typeof n.length=="number"?n.length:e.length,r=t-e.length,o=Hs.get(n);if(o&&o.base<=r&&r<=o.end){let i=Math.min(o.end,t);for(;i>r&&e[i-1-r]!==o.read[i-1-o.base];)i--;i===r&&r>o.base&&i<o.end?o=void 0:(i<o.end&&bu(o,i),r>o.base&&(o.read=o.read.slice(r-o.base),o.base=r))}else o=void 0;o||Hs.set(n,o=gu(r));for(let i=o.end;i<t;i++)yu(o,e[i-r]);return o.writers}var nn={served:new WeakSet},Dn=n=>n.fields!==void 0||(n.hide?.length??0)>0,we=n=>nn.on===!0||nn.served.has(n);var Nr=new WeakMap;function vu(n,e){let t=new Map,r=new Map(Object.entries(e??{}));return{base:n,end:n,read:[],kinds:t,creators:r,entries:[],records:{kindOf:o=>t.get(o),creatorOf:o=>r.get(o)}}}function xu(n,e){let t=n.end;for(let r of e.primitives){if(r.op!=="add-node"&&r.op!=="remove-node")continue;let{id:o,kind:i}=r.node;if(n.kinds.has(o)||(n.kinds.set(o,i),n.entries.push({seq:t,id:o,creator:!1})),r.op!=="add-node"||n.creators.has(o)||e.undoes!==void 0)continue;let s=T(e.author).id;s!==void 0&&(n.creators.set(o,s),n.entries.push({seq:t,id:o,creator:!0}))}n.read.push(e),n.end++}function wu(n,e){for(;n.entries.length>0&&n.entries.at(-1).seq>=e;){let t=n.entries.pop();(t.creator?n.creators:n.kinds).delete(t.id)}n.read.length=e-n.base,n.end=e}function le(n){let e=n.all(),t=typeof n.length=="number"?n.length:e.length,r=t-e.length,o=Nr.get(n);if(o&&o.base<=r&&r<=o.end){let i=Math.min(o.end,t);for(;i>r&&e[i-1-r]!==o.read[i-1-o.base];)i--;i===r&&r>o.base&&i<o.end?o=void 0:(i<o.end&&wu(o,i),r>o.base&&(o.read=o.read.slice(r-o.base),o.base=r))}else o=void 0;o||Nr.set(n,o=vu(r,r>0?ku(n,r)?.creators:void 0));for(let i=o.end;i<t;i++)xu(o,e[i-r]);return o.records}function ku(n,e){let t=[...n.epochs?.()??[]].reverse().find(r=>r.horizon);return t?.seq===e?t:void 0}function Js(n,e){le(n);let t=Nr.get(n),r=new Set;for(let i=t.entries.length-1;i>=0&&t.entries[i].seq>=e;i--)t.entries[i].creator&&r.add(t.entries[i].id);let o={};for(let[i,s]of t.creators)r.has(i)||(o[i]=s);return o}function tn(n,e,t,r,o,i=nn.on===!0){if(!n?.sees?.length||V(e))return!0;let s=n.sees.filter(a=>a.kinds.includes(t.kind)&&(i||!Dn(a)));return s.length===0?!1:(e=T(e),s.some(a=>{if(!be(a,e))return!1;if(!a.own&&!a.via)return!0;let d=e.id;if(d===void 0)return!1;let l=u=>u.id===d;return a.via?r.out(t.id,a.via).some(l)||r.in(t.id,a.via).some(l):t.id===d||r.out(t.id).some(l)||r.in(t.id).some(l)||o?.creatorOf(t.id)===d}))}var jr=new Set;function yt(n,e){return V(e)?jr:n.modules?.disabledKinds??jr}function rn(n,e){return V(e)?!1:(n.policy?.sees?.length??0)>0||yt(n,e).size>0}function na(n,e){if(!rn(n,e))return()=>!0;let t=n.modules?.disabledKinds??jr,r=n.policy?.sees??[],o=T(e),i=we(n),s=d=>!t.has(d)&&(r.length===0||r.some(l=>l.kinds.includes(d)&&be(l,o)&&!l.own&&!l.via&&(i||!Dn(l)))),a=n.schema.kinds.every(s);return d=>a||d!==void 0&&s(d)}function Zn(n,e){return t=>{let r=yt(n,e);if(!n.policy?.sees?.length&&r.size===0)return!0;let o=le(n.log),i=n.graph.getNode(t);if(i)return!r.has(i.kind)&&tn(n.policy,e,i,n.graph,o,we(n));let s=o.kindOf(t);return s===void 0?!0:!r.has(s)&&tn(n.policy,e,{id:t,kind:s},{out:()=>[],in:()=>[]},o,we(n))}}var Su={out:()=>[],in:()=>[]};function $u(n,e,t=new Map,r){let o=yt(n,e);if(!n.policy?.sees?.length&&o.size===0)return()=>!0;let i=le(n.log);return s=>{let a=t.get(s);if(a!==void 0)return a;let d,l=n.graph.getNode(s);if(l)d=!o.has(l.kind)&&tn(n.policy,e,l,n.graph,i,we(n));else{let u=i.kindOf(s);if(u===void 0)return r?.add(s),!0;d=!o.has(u)&&tn(n.policy,e,{id:s,kind:u},Su,i,we(n))}return t.set(s,d),d}}function _u(n){let e=new Map;return(t,r)=>{let o=`${t}\0${r}`,i=e.get(o);if(i===void 0){let s=n?.tryDefinition(t)?.fields?.shape,a=s?.[r];i=s!==void 0&&(a===void 0||a.safeParse?.(void 0).success===!0),e.set(o,i)}return i}}function Dr(n,e){return ta(n,e).lens}var Tr=()=>({judged:new Map,shown:new Map});function ta(n,e){let t=_u(n.schema),r=V(e)?void 0:T(e).id,o=()=>n.log.length??n.log.all().length,i=new WeakMap,s=n.graph,a=(u,p,c,f,g)=>{let h=(v,$)=>{if(!u(v.id))return;let _;for(let L in v)if(!(!Object.hasOwn(v,L)||L==="id"||L==="kind"||!j(v[L],u))&&!(r!==void 0&&$(L)===r)){if(!t(v.kind,L))return;(_??=[]).push(L)}if(!_)return v;let A=_.join("\0"),N=i.get(v);if(N?.without===A)return N.node;let E=Object.fromEntries(Object.entries(v).filter(([L])=>!_.includes(L)));return i.set(v,{without:A,node:E}),E},b=v=>{let $=c();return h(v,_=>p().writerAt(v.id,_,$))},y=new WeakMap,k=g?v=>{let $=y.get(v);return $||y.set(v,$={node:b(v)}),$.node}:b,R=v=>{if(!u(v))return!1;let $=s.getNode(v);return $===void 0||k($)!==void 0},m=g?.shown??new Map,w=g?v=>{let $=m.get(v);return $===void 0&&m.set(v,$=R(v)),$}:R,S=s.outEdges&&s.inEdges?{present:{getNode:v=>s.getNode(v),outEdges:v=>s.outEdges(v),inEdges:v=>s.inEdges(v)},log:n.log,get writers(){return p()}}:void 0,x={sees:u,shows:w,served:k,servedWith:h,optional:t,kindOf:f,...r!==void 0?{actor:r}:{},...S?{timeline:S}:{},hides:()=>rn(n,e),pin:g?()=>x:()=>d(Tr())};return nn.lens?.(x,n,e)??x};function d(u){let p,c=o(),f=le(n.log);return a($u(n,e,u.judged,u.unnamed),()=>p??=mt(n.log),()=>c,g=>s.getNode(g)?.kind??f.kindOf(g),u)}return{lens:a(Zn(n,e),()=>mt(n.log),o,u=>s.getNode(u)?.kind??le(n.log).kindOf(u)),pinWith:d}}var Xs=new WeakMap,Qs=new WeakMap,Ru=n=>{let e=new Set;for(let t of n)for(let r of t.primitives)r.op==="add-node"||r.op==="remove-node"?e.add(r.node.id):r.op==="patch-node"?e.add(r.id):(e.add(r.edge.from),e.add(r.edge.to));return e};function Au(n,e){if(!rn(n,e))return n.log.all();let t=n.log.all(),r=n.log.length??t.length,o=r-t.length,i=[...yt(n,e)].sort().join("\0"),s=ra(e),a=Xs.get(n.log);a||Xs.set(n.log,a=new Map);let d=a.get(s),{pinWith:l}=ta(n,e),u=Qs.get(n.log);u||Qs.set(n.log,u=new Set);let p=d!==void 0&&d.horizon===o&&d.off===i&&d.length<=r&&(d.length===o||t[d.length-1-o]===d.last);if(d&&p){if(d.length===r)return d.ops;let g=t.slice(d.length-o),h=l(Tr()),b=!0,y=Ru(g);for(let k of y){let R=d.judgments.judged.get(k),m=d.judgments.shown.get(k);if(R!==void 0&&h.sees(k)!==R||m!==void 0&&h.shows(k)!==m){b=!1;break}}if(b){for(let k of y)if(u.has(k)){b=!1;break}}if(b){let k=[...d.ops,...Xe(g,l(d.judgments))],R={horizon:o,off:i,length:r,last:t.at(-1),ops:k,judgments:d.judgments};return a.set(s,R),k}}let c={...Tr(),unnamed:u},f=Xe(t,l(c));return a.set(s,{horizon:o,off:i,length:r,last:t.at(-1),ops:f,judgments:c}),f}function Ou(n,e,t){return(t.subjectId===void 0||!e(t.subjectId)||n.shows(t.subjectId))&&t.nodeIds.every(r=>!e(r)||n.shows(r))&&!j(t,n.sees)}function Zr(n,e){return{all:()=>n,undoneIds:()=>Pe(n),epochs:e}}var ea=new WeakMap;function ra(n){let e=V(n)?n:T(n);return`${n.kind}|${e.id??""}|${(e.roles??[]).join(",")}|${n.onBehalfOf?"for":""}`}var Ir=(n,e)=>{let t=Reflect.get(n,e,n);return typeof t=="function"?t.bind(n):t},Eu=Symbol.for("@graview/core:seat");function Fn(n,e){if(!rn(n,e))return n;let t=ra(e),r=ea.get(n);r||ea.set(n,r=new Map);let o=r.get(t);if(o)return o;let i=n.graph,s=Dr(n,e),a=m=>{let w=_=>_===void 0?void 0:m.served(_),S=_=>w(_)!==void 0,x=_=>S(i.getNode(_));return{served:w,seenNode:S,seenId:x,seenEdge:_=>x(_.from)&&x(_.to)&&!j(_,m.sees),servedAll:_=>_.flatMap(A=>w(A)??[])}},{served:d,seenId:l}=a(s),u=()=>a(s.pin?.()??s),p=(m,w)=>{let S=mt(n.log),x=s.pin?.()??s,v=m.nodes.flatMap(_=>x.servedWith(_,A=>S.writerAt(_.id,A,w))??[]),$=new Set(v.map(_=>_.id));return{nodes:v,edges:m.edges.filter(_=>$.has(_.from)&&$.has(_.to)&&!j(_,x.sees))}},c=m=>{let w=p(m.base,m.seq);if(!m.creators)return{...m,base:w};let S=new Set(w.nodes.map(v=>v.id)),x=Object.fromEntries(Object.entries(m.creators).filter(([v,$])=>S.has(v)&&!j($,s.sees)));return{...m,base:w,creators:x}},f=m=>m&&c(m),g=()=>Au(n,e),h=()=>Zr(g(),()=>n.log.epochs()),b=new Proxy(i,{get(m,w){switch(w){case"getNode":return S=>d(m.getNode(S));case"has":return l;case"allNodes":case"nodesOfKind":return(...S)=>u().servedAll(m[w](...S));case"count":return(...S)=>u().servedAll(m.nodesOfKind(...S)).length;case"allEdges":case"edgesOfKind":case"outEdges":case"inEdges":return(...S)=>m[w](...S).filter(u().seenEdge);case"out":case"in":case"neighbors":return(S,...x)=>{let v=u();return v.seenId(S)?v.servedAll(m[w](S,...x)):[]};case"snapshot":return()=>{let S=m.snapshot(),x=u();return{...S,nodes:x.servedAll(S.nodes),edges:S.edges.filter(x.seenEdge)}};case"size":{let S=u();return{nodes:S.servedAll(m.allNodes({archived:"all"})).length,edges:m.allEdges({archived:"all"}).filter(S.seenEdge).length}}default:return Ir(m,w)}}}),y=()=>{let m=g();return Pr(m,Pe(m))},k=new Proxy(n.log,{get(m,w){switch(w){case"all":case"toJSON":return()=>[...g()];case"epochs":return()=>m.epochs().map(c);case"lastEpoch":return()=>f(m.lastEpoch());case"live":return()=>{let S=g(),x=Pe(S);return S.filter(v=>!x.has(v.id))};case"get":return S=>g().find(x=>x.id===S);case"opsInBatch":return S=>g().filter(x=>x.batch===S);case"batches":return y;default:return Ir(m,w)}}}),R=new Proxy(n,{get(m,w){switch(w){case Eu:return{store:m,principal:e};case"graph":return b;case"log":return k;case"snapshot":return b.snapshot;case"batches":return y;case"canUndo":return S=>Tn(h(),typeof S=="string"?[S]:S);case"violations":return S=>m.violations(S,b).filter(x=>Ou(s,v=>i.has(v),x));case"findings":return()=>m.findings().filter(S=>(S.id.includes("->")?S.id.split("->").map((v,$)=>$===0?v.slice(v.indexOf(":")+1):v):[S.id]).every(v=>!i.has(v)||l(v))&&!j(S,s.sees));case"wouldChange":return S=>m.wouldChange(S,e);case"preview":return(S,x,v)=>m.preview(S,x,{author:e,...v});case"seenBy":return S=>Fn(m,S);case"seenFor":return e;case"checkpoint":return S=>f(m.checkpoint(S));default:return Ir(m,w)}}});return r.set(t,R),R}var Fr=new Set;function Lr(n,e){if(!n||e===void 0)return{enabled:new Set(Object.keys(n??{})),disabledKinds:Fr,disabledMutations:Fr,disabledInvariants:Fr,administered:oa(n,new Set(Object.keys(n??{})))};let t=new Set,r=a=>{if(!(t.has(a)||!(a in n))){t.add(a);for(let d of n[a]?.requires??[])r(d)}};for(let a of e)r(a);for(let[a,d]of Object.entries(n))d.required&&r(a);let o=new Set,i=new Set,s=new Set;for(let[a,d]of Object.entries(n))if(!t.has(a)){for(let l of d.kinds??[])o.add(l);for(let l of d.mutations??[])i.add(l);for(let l of d.invariants??[])s.add(l)}for(let a of t){let d=n[a];for(let l of d?.kinds??[])o.delete(l);for(let l of d?.mutations??[])i.delete(l);for(let l of d?.invariants??[])s.delete(l)}return{enabled:t,disabledKinds:o,disabledMutations:i,disabledInvariants:s,administered:oa(n,t)}}function oa(n,e){let t=new Map;for(let[r,o]of Object.entries(n??{}))e.has(r)&&o.visibility==="admin"&&t.set(r,o);return t}function ia(n){return n.normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase().trim().replace(/\s+/g," ")}var bt=class{constructor(e){this.graph=e;for(let t of e.allNodes({archived:"all"}))this.file(t);e.subscribe(t=>this.follow(t))}kinds=new Map;filed=new Map;labelOf(e){return this.filed.get(e)?.label}lookup(e,t){let r=ia(t);if(r.length===0)return{exact:[],prefix:[]};let o=e.includes("*")?[...this.kinds.values()]:e.flatMap(a=>this.kinds.get(a)??[]),i=[],s=[];for(let a of o)for(let d=Cr(a.sorted,r);d<a.sorted.length&&a.sorted[d].startsWith(r);d+=1){let l=[...a.ids.get(a.sorted[d])??[]];s.push(...l),a.sorted[d]===r&&i.push(...l)}return{exact:i,prefix:s}}follow(e){for(let t of e.removedNodes)this.unfile(t.id);for(let t of e.changedNodes)this.unfile(t.after.id),this.file(t.after);for(let t of e.addedNodes)this.file(t)}file(e){let t=D(this.graph.schema.tryDefinition(e.kind),e),r=ia(t);this.filed.set(e.id,{kind:e.kind,key:r,label:t});let o=this.kinds.get(e.kind);o||this.kinds.set(e.kind,o={ids:new Map,sorted:[]});let i=o.ids.get(r);i?i.add(e.id):(o.ids.set(r,new Set([e.id])),o.sorted.splice(Cr(o.sorted,r),0,r))}unfile(e){let t=this.filed.get(e);if(!t)return;this.filed.delete(e);let r=this.kinds.get(t.kind),o=r?.ids.get(t.key);if(!r||!o||(o.delete(e),o.size>0))return;r.ids.delete(t.key);let i=Cr(r.sorted,t.key);r.sorted[i]===t.key&&r.sorted.splice(i,1)}};function Cr(n,e){let t=0,r=n.length;for(;t<r;){let o=t+r>>>1;n[o]<e?t=o+1:r=o}return t}function Pu(n,e){return e.includes("*")?"record":e.map(t=>U(n.tryDefinition(t),t)).join(" or ")}function sa(n,e,t,r){let o=Pu(n,e.kinds);if(r.length===0)return{ok:!1,reason:"none",candidates:r,message:`There is no ${o} called "${t}".`};let i=r.slice(0,10).map(a=>`${a.label} (${a.id})`),s=r.length>i.length?`, and ${r.length-i.length} more`:"";return{ok:!1,reason:"ambiguous",candidates:r,message:`"${t}" names more than one ${o}: ${i.join(", ")}${s}. Pass the id of the one you mean as ${e.name}.`}}var da=Symbol.for("@graview/core:node-ref"),aa=n=>typeof n=="object"&&n!==null?n[da]:void 0;function ke(n="*"){return zu(Z().check(kn(1)),n)}function zu(n,e){let t=Object.freeze(e==="*"?["*"]:[...e]),r=o=>{o&&Object.defineProperty(o,da,{value:t,enumerable:!0,configurable:!0})};return r(n),r(I(n)),n}function Gr(n){if(typeof n!="object"||n===null)return;let e=aa(n);if(e)return e;let t=I(n),r=aa(t);if(r)return r;let o=t?.innerType;return o?Gr(o):void 0}function Ln(n){let e=n.shape;if(!e)return[];let t=[];for(let[r,o]of Object.entries(e)){let i=Gr(o);i&&t.push({name:r,kinds:i,optional:o.safeParse(void 0).success})}return t}function Kr(n){if(n===null||typeof n!="object")return JSON.stringify(n)??"null";if(Array.isArray(n))return`[${n.map(r=>r===void 0?"null":Kr(r)).join(",")}]`;let e=n;return`{${Object.keys(e).filter(r=>e[r]!==void 0).sort().map(r=>`${JSON.stringify(r)}:${Kr(e[r])}`).join(",")}}`}var ca=(n,e)=>n.key<e.key?-1:n.key>e.key?1:0;function Mu(n){let e=n.nodes.map(r=>({key:r.id,value:r})).sort(ca),t=n.edges.map(r=>({key:P(r),value:{kind:r.kind,from:r.from,to:r.to}})).sort(ca);return Kr({nodes:e.map(r=>r.value),edges:t.map(r=>r.value)})}function on(n){return`sha256:${la(Mu(n))}`}function ua(n,e,t,r={}){let o=r.validate??!0,i=r.base??{nodes:[],edges:[]},s=on(t),a=B.from(n,i,{validate:o});for(let[h,b]of e.entries())try{a.applyPrimitives(b.primitives)}catch(y){let k=e[h-1];return{ok:!1,expected:on(a.snapshot()),actual:s,...k?{divergedAfter:k.id}:{},reason:`The log does not fold: op "${b.id}" (${b.intent}) could not be applied. ${y instanceof Error?y.message:String(y)}`}}let d=on(a.snapshot());if(d===s)return{ok:!0,hash:s};let l=h=>{let b=B.from(n,i,{validate:o});for(let y=0;y<=h;y++)b.applyPrimitives(e[y].primitives);return on(b.snapshot())},u=h=>{try{let b=B.from(n,t,{validate:o});for(let y=e.length-1;y>h;y--)b.applyPrimitives(e[y].inverse);return on(b.snapshot())}catch{return}},p=h=>{let b=u(h);return b!==void 0&&b!==l(h)},c=-1,f=e.length-1;for(;c<f;){let h=Math.floor((c+f)/2);p(h)?f=h:c=h+1}let g=f>=0?e[f]:void 0;return{ok:!1,expected:d,actual:s,...g?{divergedAfter:g.id}:{},reason:g?`The graph and the fold of its log part after op "${g.id}" (${g.intent}).`:"The graph and the fold of its log disagree before any op: the base it folds from does not match."}}var Nu=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Iu=new TextEncoder,ju=new Uint32Array(64),Tu=new Uint32Array(8),vt=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function la(n){let e=Iu.encode(n),t=e.length*8,r=new Uint8Array(e.length+9+63>>6<<6);r.set(e),r[e.length]=128;let o=new DataView(r.buffer);o.setUint32(r.length-8,Math.floor(t/2**32)),o.setUint32(r.length-4,t>>>0);let i=Tu;i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225;let s=ju;for(let d=0;d<r.length;d+=64){for(let y=0;y<16;y++)s[y]=o.getUint32(d+y*4);for(let y=16;y<64;y++){let k=s[y-15],R=s[y-2],m=(k>>>7|k<<25)^(k>>>18|k<<14)^k>>>3,w=(R>>>17|R<<15)^(R>>>19|R<<13)^R>>>10;s[y]=s[y-16]+m+s[y-7]+w>>>0}let l=i[0],u=i[1],p=i[2],c=i[3],f=i[4],g=i[5],h=i[6],b=i[7];for(let y=0;y<64;y++){let k=(f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7),R=f&g^~f&h,m=b+k+R+Nu[y]+s[y]>>>0,w=(l>>>2|l<<30)^(l>>>13|l<<19)^(l>>>22|l<<10),S=l&u^l&p^u&p,x=w+S>>>0;b=h,h=g,g=f,f=c+m>>>0,c=p,p=u,u=l,l=m+x>>>0}i[0]=i[0]+l>>>0,i[1]=i[1]+u>>>0,i[2]=i[2]+p>>>0,i[3]=i[3]+c>>>0,i[4]=i[4]+f>>>0,i[5]=i[5]+g>>>0,i[6]=i[6]+h>>>0,i[7]=i[7]+b>>>0}let a="";for(let d=0;d<8;d++){let l=i[d];a+=vt[l>>>24]+vt[l>>>16&255]+vt[l>>>8&255]+vt[l&255]}return a}var Cn=class{constructor(e){this.inner=e}seen=new Set;reads(){return[...this.seen]}markAll(e){for(let t of e)this.seen.add(t.id);return e}markEdges(e){for(let t of e)this.seen.add(t.from),this.seen.add(t.to);return e}getNode(e){return this.seen.add(e),this.inner.getNode(e)}has(e){return this.seen.add(e),this.inner.has(e)}allNodes(e){return this.markAll(this.inner.allNodes(e))}allEdges(e){return this.markEdges(this.inner.allEdges(e))}nodesOfKind(e,t){return this.markAll(this.inner.nodesOfKind(e,t))}edgesOfKind(e,t){return this.markEdges(this.inner.edgesOfKind(e,t))}out(e,t,r){return this.seen.add(e),this.markAll(this.inner.out(e,t,r))}in(e,t,r){return this.seen.add(e),this.markAll(this.inner.in(e,t,r))}neighbors(e,t){return this.seen.add(e),this.markAll(this.inner.neighbors(e,t))}};function Du(n,e){return{...e,name:n}}function Ur(n){if(!n.creates?.length)return!1;let e=n.input.shape;return e===void 0||!("id"in e)}function ga(n){let e=n.input,t=e._zod?.def;if(t?.type!=="object"||t.catchall!==void 0||!e.shape)return;let r=Object.keys(e.shape);return Ur(n)?[...r,"id"]:r}var fa=(n,e)=>`does not take ${n.map(t=>`"${t}"`).join(", ")}; it takes ${e.length>0?e.map(t=>`"${t}"`).join(", "):"nothing"}`;function Zu(n){if(typeof n!="object"||n===null)return;let e=n.id;if(e!==void 0){if(typeof e!="string"||e.trim().length===0)throw new M("An id must be a non-empty string",`Got ${JSON.stringify(e)}.`);return e}}function Fu(n){let{id:e,...t}=n;return t}function pa(n){return n.normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"")||"item"}function ma(n){let e=2166136261;for(let t=0;t<n.length;t++)e=Math.imul(e^n.charCodeAt(t),16777619);return(e>>>0).toString(36).padStart(7,"0")}function Lu(n,e){if(e.limited&&e.me===void 0)return ha(n,e.held);let t=e.limited?`${n}.${ma(e.me)}`:n,r=t;for(let o=2;e.seen(r);o++)r=`${t}-${o}`;return e.held(r)?ha(t,e.held):r}function ha(n,e){let t;do t=`${n}-${Math.floor(Math.random()*36**6).toString(36).padStart(6,"0")}`;while(e(t));return t}function sn(n,e,t,r={}){let o=Ur(e)?Zu(t):void 0,i=o===void 0?t:Fu(t),s=ga(e);if(s&&typeof i=="object"&&i!==null&&!Array.isArray(i)){let m=Object.keys(i).filter(w=>!s.includes(w)&&i[w]!==void 0);if(m.length>0)throw new xe(e.name,[{path:[],message:fa(m,s)}])}let a=e.input.safeParse(i);if(!a.success){let m=Object.keys(e.input.shape??{});throw new xe(e.name,a.error.issues.map(w=>w.code==="unrecognized_keys"&&m.length>0?{...w,message:fa(w.keys,m)}:w))}let d=a.data,l=new Cn(r.seen??n),u=[],p=new Set,c=m=>l.has(m)||n.has(m)||p.has(m),f,g=m=>{let w=new Set([...n.outEdges(m),...n.inEdges(m)]);for(let S of w)l.getNode(S.from),l.getNode(S.to),u.push({op:"remove-edge",edge:S});return w},h={graph:l,schema:n.schema,me:r.me,emit(m){u.push(m)},addNode(m){u.push({op:"add-node",node:m})},removeNode(m){let w=l.getNode(m)&&n.getNode(m);if(!w)throw new K(m,`Cannot remove missing node "${m}"`);g(m),u.push({op:"remove-node",node:w})},patchNode(m,w){let S=l.getNode(m)&&n.getNode(m);if(!S)throw new K(m,`Cannot patch missing node "${m}"`);let x={},v={};for(let[$,_]of Object.entries(w)){let A=S[$];JSON.stringify(A)===JSON.stringify(_)&&!r.keepUnchanged?.(_,$,S)||(x[$]=A,v[$]=_)}Object.keys(v).length!==0&&u.push({op:"patch-node",id:m,before:x,after:v})},archiveNode:m=>h.patchNode(m,{[We]:!0}),unarchiveNode:m=>h.patchNode(m,{[We]:void 0}),mergeNode(m,w){let S=l.getNode(w)&&n.getNode(w);if(!S)throw new K(w,`Cannot merge into missing node "${w}"`);if(m===w||Ae(S))throw new M(m===w?"Cannot merge a record into itself":"Cannot merge into an archived record");let x=new Set([...n.outEdges(w),...n.inEdges(w)].map(P));for(let v of g(m)){let $={kind:v.kind,from:v.from===m?w:v.from,to:v.to===m?w:v.to};$.from!==$.to&&!x.has(P($))&&(x.add(P($)),u.push({op:"add-edge",edge:$}))}h.archiveNode(m),f=w},addEdge(m){u.push({op:"add-edge",edge:m})},removeEdge(m){u.push({op:"remove-edge",edge:m})},setSingleSource(m,w,S){n.inEdges(w,m).some(x=>x.from===S)||u.push({op:"add-edge",edge:{kind:m,from:S,to:w}});for(let x of n.inEdges(w,m))l.getNode(x.from),x.from!==S&&u.push({op:"remove-edge",edge:x})},freshId(m,w){if(o!==void 0&&!p.has(o)){if(r.seesInFull&&!r.seesInFull())throw new M(`"${e.name}" makes its own id here`,"Leave id out: the answer says the id it made.");if(c(o))throw new M(`Id "${o}" is already taken`,`"${e.name}" was asked to make a node with that id, and the graph has one. Pick another, or leave id out and let the act mint one.`);return p.add(o),o}let S=w?`${w}:${pa(m)}`:pa(m),v=Lu(S,{seen:$=>(r.seen?r.seen.has($):n.has($))||p.has($),held:c,limited:r.seesInFull!==void 0&&!r.seesInFull(w),me:r.me});return p.add(v),v}};e.apply(h,d);let b=r.check?.(u,e),y=new Set(u.flatMap(Oe)),k=new Cn(r.seen??n),R=e.describe?.(d,k)??`${e.name}(${Object.entries(d).map(([m,w])=>`${m}=${JSON.stringify(w)}`).join(", ")})`;return{primitives:u,reads:[...new Set([...l.reads(),...k.reads()])],...e.describe?{described:[...k.reads(),...b??[]]}:{},writes:[...y],intent:R,...f!==void 0?{mergedInto:f}:{}}}var ya=Symbol.for("@graview/core:amount"),Eb=(n,e)=>(Object.defineProperty(I(n),ya,{value:e,enumerable:!0}),n);function Br(n,e=!0){let t=I(n);return t?.[ya]??(e&&t?.innerType?Br(t.innerType):void 0)}function ba(n,e={}){let t=Number.isInteger(n),r={maximumFractionDigits:t?0:2,minimumFractionDigits:t?0:2};try{return ie(n,e.locale,e.currency?{style:"currency",currency:e.currency,...r}:r)}catch{return ie(n,e.locale,r)}}function va(n,{format:e,unit:t,currency:r,locale:o}){let i=/^[A-Z]{3}$/.test(t??"");return e==="money"||!e&&i?ba(n,{...o?{locale:o}:{},...(i?t:r)?{currency:i?t:r}:{}}):e==="percent"?ie(n,o,{style:"percent",maximumFractionDigits:0}):ie(n,o)+(t?` ${t}`:"")}var Cu=Symbol.for("@graview/core:typed-field");function Vr(n){let e=I(n);return e?e[Cu]??Vr(e.innerType):void 0}var Gu=/^[("'“‘]*(?:(?:[a-z]{1,3}\.){2,}|(?:dr|mr|mrs|ms|mx|st|mt|vs|jr|sr|prof|no|fig|approx)\.)$/i;function Ku(n){for(let e of n.matchAll(/[.!?](?=\s|$)/g)){let t=n.slice(0,e.index+1),r=/\S+$/.exec(t)?.[0]??"";if(!(e[0]==="."&&Gu.test(r))&&!(t.split(" ").length<3&&e.index+1<n.length))return t}}function xa(n,e=140){let t=n.replace(/^[#>\s]+|\*\*|`|\](\([^)\s]*\))?|\[/gm,"").replace(/\s+/g," ").trim(),r=Ku(t);return r&&r.length<=e?r:t.length<=e?t:`${(t.slice(0,e+1).replace(/\s+\S*$/,"")||t.slice(0,e)).replace(/[\s,;:.—-]+$/,"")}\u2026`}function Uu(n){let e=n.fields.shape;return Object.keys(e).flatMap(t=>{let r=ct(e[t])?On(t):void 0;return r&&e[r]?[r]:[]})}var Bu=[["skip","Skip this one","Leave one day out of the series; the rest stay as they are.","Skip {} on "],["detach","Change just this one","Make one day of the series a record of its own, to change apart from the rest.","Change {} only on "],["split","Change from here","End the series the day before, and start it again from that day with what changes.","Change {} from "]];function wa(n,e){let t=new Set(e.map(o=>o.name)),r=[];for(let o of n.definitions){let i=Uu(o);if(i.length===0)continue;let s=o.kind,a=o.fields.shape,d=Object.keys(a).filter(u=>!(u in(o.fixed??{}))),l=u=>D(o,u);for(let[u,p,c,f]of Bu){let g=`${u}-${s}`;t.has(g)||r.push({name:g,derived:{kind:s,act:u},title:p,description:c,subject:{kinds:[s],arg:"id"},writes:i.map(Be),...u==="skip"?{}:{creates:[s]},input:Ke({id:ke([s]),on:Z().check(Sn(/^\d{4}-\d{2}-\d{2}$/,"a day, like 2026-10-21")),...i.length>1?{field:ee(rs(i))}:{},...u==="skip"?{}:Object.fromEntries(d.map(h=>[h,ee(a[h])]))}),describe:(h,b)=>f.replace("{}",l(b.getNode(String(h.id))??{id:h.id}))+he(String(h.on)),apply(h,b){let y=h.graph.getNode(String(b.id)),k=String(b.field??i[0]),R=y?.[k],m=y?.[Be(k)],w=String(b.on);if(typeof R!="string"||!Ve(m))throw new X(`${l(y??{id:b.id})} does not repeat`,"refused");let S=Ue(R,m,{from:w,to:w})[0];if(!S)throw new X(`${l(y)} does not fall on ${he(w)}`,"refused");let x=String(y.id),v=Object.fromEntries(d.filter(H=>b[H]!==void 0).map(H=>[H,b[H]])),$=Be(k),_=H=>{let ko=Object.fromEntries(Object.entries({...y,...H,...v}).filter(([Vn,It])=>It!=null&&Vn!=="id")),So=h.freshId(l(ko));h.addNode({...ko,id:So,kind:s});for(let Vn of Object.keys(o.edges??{}))for(let It of h.graph.out(x,Vn))h.addEdge({kind:Vn,from:So,to:It.id})};if(u!=="split"){h.patchNode(x,{[$]:{...m,except:[...new Set([...m.except??[],w])].sort()}}),u==="detach"&&_({[k]:S,[$]:null});return}if(Object.keys(v).length===0)throw new X(`Nothing to change: give ${l(y)} from ${he(w)} something new`,"invalid");if(w<=R.slice(0,10))return h.patchNode(x,v);let A=new Date(Date.parse(`${w}T00:00:00Z`)-864e5).toISOString().slice(0,10),N=m.count?Ue(R,{...m,except:[]},{to:A}).length:0,{count:E,except:L,...xo}=m,wo=H=>L?.some(H)?{except:L.filter(H)}:{};h.patchNode(x,{[$]:{...xo,until:A,...wo(H=>H<w),...E?{count:N}:{}}}),_({[k]:S,[$]:{...xo,...wo(H=>H>=w),...E?{count:E-N}:{},continues:x}})}})}}return r}function ka(n,e){let t=new Set(e.map(d=>d.name)),r=e.filter(d=>!d.derived),o=new Set(r.flatMap(d=>d.connects??[])),i=new Set(r.flatMap(d=>d.severs??[])),s=[],a=(d,l)=>{let u=d.getNode(String(l));return u?D(n.tryDefinition(u.kind),u):String(l)};for(let d of n.definitions){let l=d.kind,u=Object.entries(d.edges??{}),p=c=>c.to==="*"?"record":c.to.map(f=>U(n.tryDefinition(f),f)).join(" or ");for(let[c,f]of u){let g=p(f),h=f.cardinality==="one",b=u.some(([R,m])=>R!==c&&p(m)===g),y={to:g,from:U(d,l),one:h,also:b?C(c).toLowerCase():void 0},k=y.from;for(let R of Zs){let m=Ls(R,l,c);if(t.has(m)||f.acts==="none"||(R==="connect"?o.has(c):i.has(c)||f.appendOnly))continue;let{title:w,fromTheOtherEnd:S}=Cs(R,y),x=f.description?`: ${f.description.replace(/\.$/,"")}`:"";s.push({name:m,derived:{kind:l,act:R,relation:c},title:w,fromTheOtherEnd:S,description:R==="connect"?`Link this ${k} to ${/^[aeiou]/i.test(g)?"an":"a"} ${g}${x}.${h?" It has one, so this replaces the one it has.":""}`:`Take away the link between this ${k} and ${/^[aeiou]/i.test(g)?"an":"a"} ${g}${x}. Undo puts it back.`,subject:{kinds:[l],arg:"id"},...R==="connect"?{connects:[c]}:{severs:[c],destructive:!0},idempotent:!0,input:Ke({id:ke([l]),to:ke(f.to==="*"?"*":f.to)}),describe:(v,$)=>R==="disconnect"?`Unlink ${a($,v.id)} from ${a($,v.to)}`:h?`Set the ${g} of ${a($,v.id)} to ${a($,v.to)}`:`Link ${a($,v.id)} to ${a($,v.to)}`,apply(v,$){let _=String($.id),A=String($.to);for(let E of[_,A])if(!v.graph.getNode(E))throw new X(`there is no record "${E}"`,"invalid");let N=v.graph.out(_,c).some(E=>E.id===A);if(R==="disconnect"){if(!N)throw new X(`${a(v.graph,_)} is not linked to ${a(v.graph,A)}`,"invalid");v.removeEdge({kind:c,from:_,to:A});return}if(h)for(let E of v.graph.out(_,c))E.id!==A&&v.removeEdge({kind:c,from:_,to:E.id});N||v.addEdge({kind:c,from:_,to:A})}})}}}return s}function Sa(n){let e=n.fields.shape;return Object.keys(e).filter(t=>!(t in(n.fixed??{})))}function Wr(n,e){let t=e.subject;return t?t.kinds==="*"?n.kinds:t.kinds:[]}function qr(n,e){let t=n.subject;if(!t||!n.writes&&n.creates?.length)return[];let r=new Set(Object.keys(e.fields.shape));if(n.writes)return n.writes.filter(s=>r.has(s));let o=n.input.shape??{},i=new Set(Ln(n.input).map(s=>s.name));return Object.keys(o).filter(s=>s!==t.arg&&r.has(s)&&!i.has(s))}function $a(n,e){let t=new Map,r=(o,i,s)=>{let a=t.get(o)??new Map;a.get(i)?.includes(s)||(a.set(i,[...a.get(i)??[],s]),t.set(o,a))};for(let o of e){for(let i of Wr(n,o)){let s=n.tryDefinition(i);if(s)for(let a of qr(o,s))r(i,a,o.name)}for(let[i,s]of Object.entries(o.writesOther??{})){let a=n.tryDefinition(i)?.fields.shape;if(a)for(let d of s)d in a&&r(i,d,o.name)}}return t}function _a(n,e,t){let r=n.tryDefinition(t);if(!r)return[];let o=$a(n,e).get(t);return Sa(r).filter(i=>!o?.has(i))}var Ra=n=>`edit-${n}`;function Aa(n,e,t){let r=n.tryDefinition(t);if(!r)return[];let o=new Set;for(let i of e)i.derived||((i.creates??[]).includes(t)&&o.add(i.name),Wr(n,i).includes(t)&&qr(i,r).length>0&&o.add(i.name));return[...o]}function Oa(n,e){let t=new Set(e.map(o=>o.name)),r=[];for(let o of n.definitions){let i=o.kind,s=Ra(i);if(t.has(s))continue;let a=_a(n,e,i);if(a.length===0)continue;let d=o.fields.shape,l=U(o,i),u=a.map(p=>Jn(o,p).toLowerCase());r.push({name:s,derived:{kind:i,act:"edit"},idempotent:!0,title:`Change the ${l}`,description:`Change what was set when this ${l} was made: ${u.join(", ")}.`,subject:{kinds:[i],arg:"id"},writes:a,input:Ke({id:ke([i]),...Object.fromEntries(a.map(p=>[p,ee(qu(d[p]))]))}),describe:(p,c)=>Vu(o,d,a,p,c),apply(p,c){let f={};for(let g of a){let h=c[g];h!==void 0&&(f[g]=h)}if(Object.keys(f).length===0)throw new X(`Nothing to change \u2014 give at least one of ${u.join(", ")} a value.`,"invalid");p.patchNode(c.id,f)}})}return r}function Vu(n,e,t,r,o){let i=o.getNode(r.id),s=i?D(n,i):"a record",a=t.filter(d=>r[d]!==void 0).map((d,l)=>{let u=r[d],p=On(d),c=p!==void 0&&p in e,f=Jn(n,c?p:d);return`the ${f===f.toUpperCase()?f:f.charAt(0).toLowerCase()+f.slice(1)}${l===0?` of ${s}`:""} to ${c?u?`repeat ${Wu(u)}`:"stop repeating":Ea(n,e[d],d,u)}`});return a.length===0?`Changed nothing on ${s}`:`Changed ${a.length>1?`${a.slice(0,-1).join(", ")} and ${a.at(-1)}`:a[0]}`}var Wu=n=>`every ${(n.interval??1)>1?`${n.interval} ${n.every}s`:n.every}`;function Ea(n,e,t,r){if(r===null||r===""||Array.isArray(r)&&r.length===0)return"nothing";let o=n.display?.format?.[t];try{if(o)return String(o(r))}catch{}if(_n(r).length>0)return _n(r).map(i=>i.name).join(", ");if(Rn(e))return Array.isArray(r)&&r.length>1?`${r.length} linked records`:"a linked record";if(Array.isArray(r))return r.map(i=>Ea(n,e,t,i)).join(", ");if(typeof r=="boolean")return r?"yes":"no";if(typeof r=="number"){let i=Br(e);return i?va(r,i):Vr(e)==="duration"?`${r>=60?`${Math.floor(r/60)} h `:""}${r%60||r<60?`${r%60} min`:""}`.trim():String(r)}if(typeof r!="string")return"a new value";if(De.test(r))return he(r);if(Wn.test(r))return Zt(r);for(let i=I(e);i;i=I(i.innerType))if(i.type==="enum")return C(r);return`\u201C${xa(r,60)}\u201D`}function qu(n){let e=n;for(let t=0;t<4;t++){let r=e._zod?.def;if((r?.type==="default"||r?.type==="prefault")&&r.innerType)e=r.innerType;else break}return e}function Pa(n,e){return n.filter(t=>!t.derived&&(t.creates??[]).includes(e)).map(t=>t.name)}function xt(n,e,t){if(!t.derived)return;let r=t.derived.act;return r==="edit"||r==="skip"||r==="detach"||r==="split"||r==="connect"||r==="disconnect"?Aa(n,e,t.derived.kind):Pa(e,t.derived.kind)}function Hu(n,e){let t=new Set(e.map(o=>o.name)),r=[];for(let o of n.definitions){let i=o.kind,s=U(o,i),a=(l,u)=>{let p=l.getNode(String(u));return p?D(o,p):String(u)},d=ke([i]);for(let[l,u,p,c]of[["remove","Remove",`Remove the ${s}`,`Take this ${s} out of the graph, with every tie it has. Undo puts it back.`],["archive","Archive",`Archive the ${s}`,`Set this ${s} aside, with its ties and history kept.`],["unarchive","Bring back","Bring it back",`Bring this archived ${s} back.`],["merge","Merge",`Merge into another ${s}`,`The other takes this ${s}'s ties, and this one is archived.`],["leave-alone","Leave alone","Leave this one alone",`Nothing automated changes this ${s}: tidying passes it by until you allow it again.`],["allow-tidying","Allow tidying of","Allow tidying again",`Let tidying change this ${s} again.`]]){let f=`${l}-${i}`,g=l==="leave-alone"||l==="allow-tidying";t.has(f)||!g&&l!=="remove"&&o.archives===!1||g&&o.tidying==="never"||r.push({name:f,derived:{kind:i,act:l},title:p,description:c,subject:{kinds:[i],arg:"id"},...l==="remove"?{destructive:!0}:{},idempotent:!0,input:Ge(l==="merge"?{id:d,into:d}:{id:d}),describe:(h,b)=>{let y=l==="remove"&&b.getNode(String(h.id)),k=y?new Set(Object.values(y).flatMap(R=>_n(R).map(m=>m.href))).size:0;return`${u} ${a(b,h.id)}${l==="merge"?` into ${a(b,h.into)}`:""}${k?` and its ${k} file${k>1?"s":""}`:""}`},apply:g?(h,b)=>h.patchNode(String(b.id),{[Pn]:l==="leave-alone"?!0:void 0}):(h,b)=>h[`${l}Node`](b.id,b.into)})}}return r}function Hr(n,e){return[...Oa(n,e),...Hu(n,e),...wa(n,e),...ka(n,e)]}var Yu=500,Yr=120;function Gn(n){if(n===void 0)return;let{basis:e,confidence:t,model:r,suggestion:o,interaction:i}=n??{},s=typeof e=="string"?e.trim():"",a=typeof r=="string"?r.trim():"";if(!s||s.length>Yu||t!==void 0&&!(typeof t=="number"&&t>=0&&t<=1)||r!==void 0&&!(a&&a.length<=Yr)||o!==void 0&&!(typeof o=="string"&&o.length>0&&o.length<=Yr)||i!==void 0&&!(typeof i=="string"&&i.length>0&&i.length<=Yr))throw new M("A lineage is { basis: 1\u2013500 characters, confidence?: 0\u20131, model?: 1\u2013120 characters, suggestion?: an op id, interaction?: an AI interaction's id }");return{basis:s,...t!==void 0?{confidence:t}:{},...a?{model:a}:{},...typeof o=="string"?{suggestion:o}:{},...typeof i=="string"?{interaction:i}:{}}}var an="keep-link";function za(n){let e=(t,r)=>{let o=t.getNode(r);return o?D(n.tryDefinition(o.kind),o):r};return{name:an,title:"Keep this link",input:Ge({kind:Z(),from:Z(),to:Z()}),describe:(t,r)=>`Keep the link from ${e(r,t.from)} to ${e(r,t.to)}`,apply(t,r){let{kind:o,from:i,to:s}=r;if(!t.graph.getNode(i)||!t.graph.getNode(s)){let a=P({kind:o,from:i,to:s});throw new K(a,`Cannot remove missing edge ${a}`)}t.removeEdge({kind:o,from:i,to:s}),t.addEdge({kind:o,from:i,to:s})}}}var Ma=(n,e)=>[...n].filter(t=>!t.derived&&t.name!==an&&typeof e=="string"&&(t.connects?.includes(e)||t.severs?.includes(e))).map(t=>t.name);var Na=["kind-unknown","node-shape","edge-dangling","edge-disallowed","rule-error","rule-budget"];function Ia(n,e){let t=lt(n,e);return t&&[...t.fields].filter(Boolean)}function Ju(n,e,t){return n.tryDefinition(e)?.fields?.shape?.[t]}function wt(n,e){try{return D(n.tryDefinition(e.kind),e)}catch{return typeof e.label=="string"?e.label:"A record"}}var Xu=n=>`${n.kind}:${n.from}->${n.to}`,kt=(n,e)=>n<e?-1:n>e?1:0;function ja(n,e,t={}){let{schema:r}=n,o=[],i=new Map;for(let c of e.nodes)i.has(c.id)||i.set(c.id,c);let s=c=>e.edges.filter(f=>f.from===c||f.to===c),a=c=>({action:"drop",primitives:[...s(c.id).filter(f=>i.has(f.from)&&i.has(f.to)).map(f=>({op:"remove-edge",edge:f})),{op:"remove-node",node:c}]}),d=new Set;for(let c of[...i.values()].sort((f,g)=>kt(f.id,g.id))){if(!r.tryDefinition(c.kind)){d.add(c.id),o.push({code:"kind-unknown",id:c.id,message:`${wt(r,c)} is a kind of record this app no longer has`,repair:a(c)});continue}let f=Ia(r,c);if(f===void 0)continue;let g=wt(r,c),h=new Map,b=f.length>0;for(let y of f){if(y==="id"||y==="kind"){b=!1;continue}let k=Ju(r,c.kind,y),R=k?k.safeParse(void 0):{success:!0,data:void 0},m=r.tryDefinition(c.kind)?.defaults;!R.success&&k&&m&&Object.hasOwn(m,y)&&(R=k.safeParse(m[y])),R.success?R.data===void 0?h.set(y,{action:"clear",value:re}):h.set(y,{action:"coerce",value:R.data}):b=!1}if(b){let y={...c};for(let[k,R]of h)R.value===re?delete y[k]:y[k]=R.value;Ia(r,y)!==void 0&&(b=!1)}if(f.length===0){o.push({code:"node-shape",id:c.id,message:`${g} does not fit what ${c.kind} declares`,repair:a(c)});continue}for(let y of f){let k=h.get(y),R=b&&k?{action:k.action,primitives:[{op:"patch-node",id:c.id,before:{[y]:c[y]===void 0?re:c[y]},after:{[y]:k.value}}]}:a(c);o.push({code:"node-shape",id:c.id,detail:y,message:`${g}: ${C(y)} does not fit what ${c.kind} declares`,repair:R})}}let l=new Set,u=[];for(let c of[...e.edges].sort((f,g)=>kt(P(f),P(g)))){if(l.has(P(c)))continue;l.add(P(c));let f=Xu(c),g=i.get(c.from),h=i.get(c.to);if(!g||!h){o.push({code:"edge-dangling",id:f,message:"A link points at a record that is not there",repair:{action:"drop",primitives:[{op:"remove-edge",edge:c}]}});continue}u.push(c),!(d.has(g.id)||d.has(h.id))&&(r.edgeAllowed(c.kind,g.kind,h.kind)||o.push({code:"edge-disallowed",id:f,message:`${wt(r,g)} \u2192 ${wt(r,h)}: this app does not allow that link between them`,repair:{action:"drop",primitives:[{op:"remove-edge",edge:c}]}}))}let p=n.invariants??[];if(p.length>0){let c=B.from(r,{nodes:[...i.values()],edges:u},{validate:!1}),f=new Set,g;try{g=Ye(c,p,t.invariantOptions??{})}catch{g=[{invariant:"rules",status:"could-not-judge",label:"The rules",message:"The rules could not be judged",nodeIds:[],repairs:[]}]}for(let h of g){let b=h.status==="could-not-judge"?"rule-error":h.status==="over-budget"?"rule-budget":void 0;if(!b)continue;let y=h.subjectId??h.invariant,k=`${b}|${y}|${h.invariant}`;f.has(k)||(f.add(k),o.push({code:b,id:y,detail:h.invariant,message:h.message}))}}return o.sort((c,f)=>Na.indexOf(c.code)-Na.indexOf(f.code)||kt(c.id,f.id)||kt(c.detail??"",f.detail??""))}var Kn=()=>globalThis.__graviewWatch;function Ta(n){Kn()?.store?.(n)}function St(n){n!==void 0&&Kn()?.learn?.({ids:[n],words:[]})}function Da(n,e){Kn()?.refused?.({...n,...e===void 0?{}:{author:e}})}function Za(n,e){Kn()?.refusedInput?.({mutation:n.mutation,message:n.message,...e===void 0?{}:{author:e}})}function Qu(n,e,t){Kn()?.seat?.(n,e,t)}function Xr(n,e){if(typeof n=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(n))return n;let t=new Date(n).getTime();if(Number.isNaN(t))throw new Error(`Not a day: ${String(n)}`);return W(e,t)}var Jr=15*6e4;function Fa(n=Date.now(),e){let t=new Date(n).getTime(),r=qn(e),o=W(r,t),i=new Date(Date.parse(`${o}T00:00:00Z`));if(i.setUTCDate(i.getUTCDate()+1),!r)return i.getTime()-t;let s=_o(i.toISOString().slice(0,10),0,r);for(;W(r,s)===o;)s+=Jr;for(;W(r,s-Jr)!==o;)s-=Jr;return s-t}function el(n,e){let t,r=()=>{t=setTimeout(()=>{let o=n.tick(new Date);r(),e?.(o)},Fa(Date.now(),n.timeZone)+1e3),t.unref?.()};return r(),()=>clearTimeout(t)}var $t=class extends M{constructor(e){super(`This is the app as it stood${e.at?` at ${e.at}`:" at the start"}: the past is read, never changed`),this.name="PastError"}},Qr="preview",F=(n,e)=>e===void 0?{}:{[n]:e},ze={kind:"human"},La={kind:"system"},Ga={kind:"system",id:"modules",name:"Modules"},Ca=n=>n.mutation===null&&n.undoes===void 0;function eo(n,e){return`${n.invariant}|${n.subjectId??""}|${n.line||e?.has(n.invariant)?n.label:n.message}`}var nl=new Set(["remove","archive","unarchive","merge"]),tl={has:()=>!0},Ka=n=>new Set(n.filter(e=>e.shape).map(e=>e.name));function Ua(n,e,t){let r=Ka(n),o=p=>eo(p,r),i=new Set(e.map(o)),s=new Set(t.map(o)),a=t.filter(p=>!i.has(o(p))),d=e.filter(p=>!s.has(o(p)));if(a.length===0||d.length===0)return{introduces:a,resolves:d};let l=p=>p.subjectId&&eo(p,tl),u=d.map(l);return{introduces:a.filter(p=>{let c=l(p)?u.indexOf(l(p)):-1;return c<0||(u[c]=null,!1)}),resolves:d.filter((p,c)=>u[c]!==null)}}var dn=class extends Error{constructor(t,r){super(`Op "${t.id}" (${t.intent}) could not be applied: ${r instanceof Error?r.message:String(r)}`,{cause:r});this.op=t;this.name="ReceiveError"}},_t=class extends M{constructor(t,r){super(`Unknown mutation "${t}"`,`Registered: ${r.join(", ")||"(none)"}`);this.mutation=t;this.name="UnknownMutationError"}};function rl(){let n=globalThis.crypto,e=new Uint8Array(6);if(n?.getRandomValues)n.getRandomValues(e);else for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256);return[...e].map(t=>t.toString(36).padStart(2,"0")).join("")}var no=class n{schema;graph;log;mutations=new Map;keeper;invariants;invariantOptions;policy;intelligence;may=new Map;by;declaredModules;startingModules;projected;nextId;now;validate;mintBatch;batchTag;counter=0;opCount=0;quiet=0;rehearsing=!1;suggesting=!1;ticked;timeZone;past;pastEvery;listeners=new Set;constructor(e){this.pastEvery=Math.max(1,e.pastEvery??64),this.past=e.past,this.schema=e.schema,this.invariants=e.invariants??[],this.invariantOptions=e.invariantOptions??{},this.timeZone=e.timeZone,this.timeZone&&(this.ticked={day:W(this.timeZone),on:W(this.timeZone)}),this.policy=e.policy,this.by=e.principal??ze,this.intelligence=e.intelligence??[];for(let i of e.intelligence??[])i.may&&this.may.set(i.name,new Set(i.may));this.declaredModules=e.modules,this.startingModules=e.enabledModules,this.nextId=e.ids??(()=>`op${++this.opCount}`),this.now=e.now??(()=>new Date().toISOString()),this.validate=e.validate??!0;let t=rl();this.batchTag=e.batchIds?void 0:t,this.mintBatch=e.batchIds??(i=>`${i}:${t}:${++this.counter}`);for(let i of e.past?[]:e.mutations??[]){if(this.mutations.has(i.name))throw new M(`Duplicate mutation "${i.name}"`);this.mutations.set(i.name,i)}for(let i of e.past?[]:Hr(e.schema,e.mutations??[]))this.mutations.set(i.name,i);!e.past&&!this.mutations.has(an)&&(this.keeper=za(e.schema),this.mutations.set(an,this.keeper));let r=F("horizon",e.horizon),o={validate:this.validate};if(e.log){this.log=en.from(e.log,e.epochs,r);let i=this.log.lastEpoch();this.graph=e.snapshot?B.from(e.schema,e.snapshot,o):this.log.fold(e.schema,{...o,...i?{from:i}:{}})}else this.log=en.from([],e.epochs??(e.snapshot?[{seq:e.horizon??0,base:e.snapshot}]:[]),r),this.graph=B.from(e.schema,e.snapshot??{nodes:[],edges:[]},o);e.past||(this.countPastTheLog(),Ta(this))}stillNow(){if(this.past)throw new $t(this.past)}countPastTheLog(){let e=t=>{let r=/(\d+)$/.exec(t);return r?Number(r[1]):0};for(let t of this.log.all())this.counter=Math.max(this.counter,e(t.batch)),this.opCount=Math.max(this.opCount,e(t.id));this.log.horizon>0&&(this.opCount=Math.max(this.opCount,this.log.length))}get modules(){let e=this.log.all(),t=e.at(-1)?.id,r=this.projected;if(r&&r.length===e.length&&r.last===t)return r.projection;let o,i=0;r&&r.length<=e.length&&(r.length===0||e[r.length-1]?.id===r.last)&&(o=r.said,i=r.length);for(let a=e.length-1;a>=i;a--){let d=e[a].enabledModules;if(d!==void 0){o=d;break}}let s=r&&o===r.said?r.projection:Lr(this.declaredModules,o??this.startingModules);return this.projected={projection:s,length:e.length,last:t,said:o},s}setEnabledModules(e,t={}){this.stillNow();let r=this.modules.enabled,o=Lr(this.declaredModules,e).enabled,i=[...r].filter(u=>!o.has(u)),s=[...o].filter(u=>!r.has(u));if(i.length===0&&s.length===0)return;let a=u=>u.map(p=>{let c=this.declaredModules?.[p]?.kinds??[];return c.length>0?c.map(f=>Q(this.schema,f)).join(", "):p}).join(", "),d=[i.length>0?`Turn off ${a(i)}`:"",s.length>0?`turn on ${a(s)}`:""].filter(Boolean).join("; "),l={id:this.nextId(),seq:this.log.length,batch:t.batch??this.mintBatch("batch"),author:Ga,intent:yn(d),mutation:null,primitives:[],inverse:[],reads:[],writes:[],at:this.now(),...F("via",t.via),enabledModules:[...o].sort()};return this.log.append(l),this.notify(Nn,[l]),l}mutation(e){let t=this.mutations.get(e);if(!t)throw new _t(e,[...this.mutations.keys()]);if(this.mutationDisabled(t))throw new M(`Mutation "${e}" belongs to a module this workspace has turned off`,`Enabled modules: ${[...this.modules.enabled].join(", ")||"(none)"}`);return t}mutationDisabled(e){return this.modules.disabledMutations.has(e.name)?!0:e.derived!==void 0&&this.modules.disabledKinds.has(e.derived.kind)}allMutations(){return[...this.mutations.values()].filter(e=>e!==this.keeper&&!this.mutationDisabled(e))}viaOf(e,t){if(e!==void 0&&e===this.keeper){let r=Ma(this.mutations.values(),t?.args.kind);if(r.length>0)return r;let o=[...this.mutations.values()];return[...new Set(o.filter(i=>i.derived?.relation===t?.args.kind).flatMap(i=>xt(this.schema,o,i)??[]))]}if(e?.derived)return xt(this.schema,[...this.mutations.values()],e)}moved(e,t){return Ua(this.allInvariants(),e,t)}allInvariants(){return this.invariants.filter(e=>this.invariantEnabled(e))}invariantEnabled(e){if(this.modules.disabledInvariants.has(e.name))return!1;if(e.scope!=="graph"){let t=e.scope.kind;if(this.modules.disabledKinds.has(t))return!1}return!0}permits(e,t=ze){if(this.past)return{ok:!1,refusal:{mutation:e.name,wouldNeed:[],message:"Nothing changes while you look back."}};let r=this.refusesAgent(e,t)??this.namesTurnedOff(e,t);if(r)return{ok:!1,refusal:r};let o=this.mutations.get(e.name),i=o?.subject&&e.args[o.subject.arg];return ve(this.policy,t,e.name,this.subjectKindOf(e,t),this.viaOf(o,e),typeof i=="string"?i:void 0,this.words,()=>{let s=T(t).id,a=this.namedIn(e,!1);try{for(let d of sn(this.graph,o,e.args,this.sighted(t)).primitives)"edge"in d&&d.edge.from!==s&&d.edge.to!==s&&a.push(d.edge.to)}catch{}return a},o?.derived&&(()=>le(this.log).creatorOf(i)),o?.derived!==void 0&&nl.has(o.derived.act))}namedIn(e,t=!0){let r=this.mutations.get(e.name);if(!r)return[];let o=r.subject?.arg;return[...t&&o?[e.args[o]]:[],...Ln(r.input).flatMap(s=>s.name===o?[]:[e.args[s.name]])].flat().filter(s=>typeof s=="string")}refuse(e,t,r=!this.rehearsing){throw r&&Da(e,t),new Qe(e)}get words(){return{act:e=>this.mutations.get(e)?.title,noun:e=>U(this.schema.tryDefinition(e),e)}}refusesAgent(e,t){if(t.kind!=="agent"||t.id===void 0)return;let r=this.may.get(t.id);if(!r||r.has(e.name))return;let o=s=>`\u201C${this.mutations.get(s)?.title??s}\u201D`,i=[...r].map(o);return{mutation:e.name,message:`${t.id} may not ${o(e.name)} here: it was declared able to ${i.length===0?"do nothing else":i.join(", ")}.`,wouldNeed:[]}}namesTurnedOff(e,t=La){let r=this.modules.disabledKinds;if(r.size===0||!V(t))return;let o=this.mutations.get(e.name);if(!(!o||!this.namedIn(e).some(i=>r.has(this.graph.getNode(i)?.kind))))return{mutation:e.name,message:`\u201C${o.title??e.name}\u201D names a record of a module this workspace has turned off.`,wouldNeed:[]}}sighted(e){let t={me:e&&T(e).id};if(e===void 0||!rn(this,e))return t;let r=Zn(this,e);return{...t,seen:Fn(this,e).graph,keepUnchanged:o=>j(o,r),seesInFull:na(this,e)}}missingFor(e,t=ze){let r=this.mutations.get(e.name),o=new Set(this.namedIn(e));if(!r||o.size===0)return;let i=Fn(this,t).graph;for(let s of o)if(!i.has(s))return new K(s,`\u201C${r.title??e.name}\u201D names a record that is not there.`)}mayAdminister(e,t=ze){let r=this.modules.administered.get(e);return r?(r.mutations??[]).some(o=>{let i=this.mutations.get(o);return!!i&&Ar(i).some(s=>ve(this.policy,t,o,s,this.viaOf(i)).ok)}):!1}seenBy(e){return Fn(this,e)}sees(e,t){return this.graph.has(t)&&Zn(this,e)(t)}labels;resolveRef(e,t,r=ze){let o=(this.policy?.sees?.length??0)>0,i=c=>!o||this.sees(r,c),s=this.graph.getNode(t);if(this.labels??=new bt(this.graph),s&&i(t))return{ok:!0,id:t,label:this.labels.labelOf(t)??t,by:"id"};let a=this.labels.lookup(e.kinds,t),d=c=>{let f=c.filter(g=>!this.graph.isArchived(g));return f.length?f:c},l=d(a.exact.filter(i)),u=l.length>0,p=(u?l:d(a.prefix.filter(i))).map(c=>({id:c,kind:this.graph.getNode(c).kind,label:this.labels.labelOf(c)??c})).sort((c,f)=>c.label<f.label?-1:c.label>f.label?1:c.id<f.id?-1:1);return p.length===1?{ok:!0,id:p[0].id,label:p[0].label,by:u?"label":"prefix"}:sa(this.schema,e,t,p)}kindsKeptFrom(e=ze){let t=new Set;for(let[o,i]of this.modules.administered)if(!this.mayAdminister(o,e))for(let s of i.kinds??[])t.add(s);let r=this.policy?.sees??[];if(r.length>0&&!V(e)){let o=new Set(this.permittedMutations(e).flatMap(s=>s.creates??[])),i=we(this);for(let s of this.schema.kinds)!r.some(d=>d.kinds.includes(s)&&be(d,e)&&(!d.own&&!d.via||e.id!==void 0)&&(i||!Dn(d)))&&!o.has(s)&&t.add(s)}return t}permittedMutations(e=ze){let t=this.allMutations(),r=Rr(this.policy,e,t.filter(i=>!i.derived)),o=t.filter(i=>i.derived!==void 0&&ve(this.policy,e,i.name,i.derived.kind,this.viaOf(i),T(e).id).ok);return[...r,...o]}subjectKindOf(e,t=La){let o=this.mutations.get(e.name)?.subject;if(!o)return;let i=e.args[o.arg];if(typeof i!="string")return o.kinds!=="*"&&o.kinds.length===1?o.kinds[0]:void 0;if(!(!V(t)&&!Zn(this,t)(i)))return this.graph.getNode(i)?.kind}today(){return this.pinned()??(this.ticked&&this.ticked.on===W(this.timeZone)?this.ticked.day:void 0)??(this.timeZone?W(this.timeZone):void 0)}pinned(){let e=this.invariantOptions.context,t=this.invariantOptions.today??e?.today;return typeof t=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t)?t:void 0}judging(e){let t=this.today(),r=ps(this.graph),o=e??this.invariantOptions.context,i=r&&!(o&&"linked"in o)?{...o,linked:r}:e,s=i??o,a=this.timeZone&&t!==void 0&&e===void 0&&!(s&&"today"in s)?{...s,today:t}:i;return{...this.invariantOptions,...a===void 0?{}:{context:a},...t===void 0?{}:{today:t}}}tick(e=new Date){let t=this.pinned();if(t!==void 0)return{day:t,was:t,appeared:[],cleared:[]};let r=Xr(e,this.timeZone),o=W(this.timeZone);this.ticked&&(this.ticked={day:this.ticked.day,on:o});let i=this.today(),s=this.violations();this.ticked={day:r,on:o};let a=this.moved(s,this.violations());if(r!==i&&!this.rehearsing&&this.quiet===0)for(let d of this.listeners)d(Nn,[]);return{day:r,...i===void 0?{}:{was:i},appeared:a.introduces,cleared:a.resolves}}reread(){if(!(this.rehearsing||this.quiet>0))for(let e of this.listeners)e(Nn,[])}violations(e,t=this.graph){return Ye(t,this.allInvariants(),this.judging(e)).map(r=>this.asking(r))}required=new Map;asking(e){if(!e.repairs.some(o=>o.missing===void 0))return e;let t=!1,r=e.repairs.map(o=>{if(o.missing!==void 0)return o;let i=this.requiredOf(o.mutation).filter(s=>o.args?.[s]===void 0);return i.length===0?o:(t=!0,{...o,missing:i})});return t?{...e,repairs:r}:e}requiredOf(e){let t=this.required.get(e);if(t)return t;let r=this.mutations.get(e)?.input?.shape??{},o=Object.entries(r).filter(([,i])=>typeof i?.safeParse=="function"&&!i.safeParse(void 0).success).map(([i])=>i);return this.required.set(e,o),o}wouldChange(e,t){try{return sn(this.graph,this.mutation(e.name),e.args,this.sighted(t)).primitives.length>0}catch{return!0}}preview(e,t,r={}){let o=this.mutation(e.name),i=sn(this.graph,o,e.args,this.sighted(r.author));return this.previewPrimitives(i.primitives,{reads:i.reads,writes:i.writes,intent:i.intent,context:t})}previewAll(e,t={}){let{context:r,...o}=t;return{...this.rehearsal().applying(e,o,r),kept:!1}}rehearsal(){let e=Object.assign(Object.create(n.prototype),this),t=0;return Object.assign(e,{graph:B.from(this.schema,this.graph.snapshot(),{validate:this.validate}),log:en.from(this.log.all(),this.log.epochs(),{horizon:this.log.horizon}),listeners:new Set,labels:void 0,nextId:()=>`${Qr}:${++t}`,mintBatch:()=>Qr,rehearsing:!0}),e}previewPrimitives(e,t){let r=this.violations(t.context),o=B.from(this.schema,this.graph.snapshot()),i=o.applyPrimitives(e,{restoring:t.restoring===!0}),s=Ye(o,this.allInvariants(),this.judging(t.context));return{diff:i,primitives:e,reads:t.reads,writes:t.writes,intent:t.intent,...this.moved(r,s),violationsAfter:s}}apply(e,t={}){return this.applyAll([e],t)}applyAll(e,t={}){return this.applying(e,t)}applying(e,t,r){this.stillNow();let o=t.batch??this.mintBatch("batch"),i=t.author??this.by,s=Gn(t.lineage),a=[],d=[],l=new Set,u=new Set,p=[],c=this.violations(r),f=this.graph.snapshot(),g=this.log.length;if(this.policy)for(let k of e){let R=this.permits(k,i);R.ok||this.refuse(R.refusal,i.id)}for(let k of e){let R=this.refusesAgent(k,i)??this.namesTurnedOff(k,i);R&&this.refuse(R,i.id)}let h=zr(i);h&&this.refuseDeclined(e,i),this.rehearsing||St(i.id);try{for(let k of e){let R=this.mutation(k.name),m=this.missingFor(k,i);if(m)throw m;let w;try{w=sn(this.graph,R,k.args,this.sighted(i))}catch(x){throw x instanceof xe&&!this.rehearsing&&Za({mutation:x.mutation,message:x.issues.map(v=>`${v.path.map(String).join(".")}: ${v.message}`).join("; ")},i.id),x}if(h){let x=Vs(this.schema,this.graph,w.primitives,this.authorName(i),{declaration:!this.suggesting});x&&this.refuse({mutation:k.name,message:x,wouldNeed:[]},i.id)}if(w.primitives.length===0)continue;let S={id:this.nextId(),seq:this.log.length,batch:o,author:i,intent:R.describe!==void 0?w.intent:t.intent??w.intent,...F("batchIntent",t.intent),mutation:k,primitives:w.primitives.map(zn),inverse:[...w.primitives].reverse().map(zn).map(Mn),reads:w.reads,writes:w.writes,...R.describe!==void 0&&w.described&&w.described.length>0?{described:w.described}:{},...F("mergedInto",w.mergedInto),at:this.now(),...F("via",t.via),...F("lineage",s)};this.graph.applyPrimitives(S.primitives),this.log.append(S),a.push(S),d.push(...S.primitives);for(let x of S.reads)l.add(x);for(let x of S.writes)u.add(x);p.push(S.intent)}}catch(k){throw this.putBack(f,g),k}let b=ye(f,this.graph.snapshot(),d);this.admitted(t,a,d,b,f,g);let y=this.violations(r);return this.notify(b,a),{batch:o,ops:a,diff:b,primitives:d,reads:[...l],writes:[...u],intent:t.intent??p.join("; "),...this.moved(c,y),violationsAfter:y}}receive(e,t={}){this.stillNow();let r=new Set(this.log.all().map(d=>d.id)),o=e.filter(d=>!r.has(d.id));if(o.length===0)return[];let i=this.graph.snapshot(),s=[];if(!t.applied)for(let d of o)try{this.graph.applyPrimitives(d.primitives,{restoring:d.undoes!==void 0})}catch(l){throw this.graph.load(i),new dn(d,l)}let a=this.log.length;for(let[d,l]of o.entries()){let u={...l,seq:a+d};this.log.append(u),s.push(u)}return this.notify(ye(i,this.graph.snapshot(),o.flatMap(d=>d.primitives)),s),s}append(e,t={}){if(this.stillNow(),e.length===0)return[];let r=new Set(this.log.all().map(a=>a.id)),o,i=e.map((a,d)=>{let l=a.primitives.map(zn),u={id:a.id??this.nextId(),seq:this.log.length+d,batch:a.batch??t.batch??(o??=this.mintBatch("batch")),author:a.author,intent:a.intent,...F("batchIntent",a.batchIntent),mutation:a.mutation??null,primitives:l,inverse:a.inverse??[...l].reverse().map(Mn),reads:a.reads??[],writes:a.writes??[...new Set(l.flatMap(Oe))],at:a.at??this.now(),...F("undoes",a.undoes),...F("via",a.via),...F("lineage",Gn(a.lineage))};if(r.has(u.id))throw new M(`Op "${u.id}" (${u.intent}) is already in the log`,"A host-made op needs an id of its own; leave `id` out and the store mints one.");return r.add(u.id),u}),s=this.graph.snapshot();for(let a of i)try{this.graph.applyPrimitives(a.primitives,{restoring:a.undoes!==void 0})}catch(d){throw this.graph.load(s),new dn(a,d)}for(let a of i)this.log.append(a);for(let a of i)St(a.author.id);return this.notify(ye(s,this.graph.snapshot(),i.flatMap(a=>a.primitives)),i),i}applyPrimitives(e,t={}){this.stillNow();let r=t.batch??this.mintBatch("batch"),o=t.author??this.by,i=this.violations(),s=this.graph.snapshot(),a=t.intent??"Apply a change",d=Gn(t.lineage),l=e.map(zn),u=[];if(l.length>0){let f={id:this.nextId(),seq:this.log.length,batch:r,author:o,intent:a,mutation:null,primitives:l,inverse:[...l].reverse().map(Mn),reads:[],writes:[...new Set(l.flatMap(Oe))],at:this.now(),...F("via",t.via),...F("lineage",d)};this.graph.applyPrimitives(f.primitives),this.log.append(f),u.push(f),St(o.id)}let p=this.violations(),c=ye(s,this.graph.snapshot(),l);return this.notify(c,u),{batch:r,ops:u,diff:c,primitives:l,reads:[],writes:u[0]?.writes??[],intent:a,...this.moved(i,p),violationsAfter:p}}findings(){return ja({schema:this.schema,invariants:this.allInvariants()},this.graph.snapshot(),{invariantOptions:this.invariantOptions})}batches(){return this.log.batches()}canUndo(e){return Tn(this.log,typeof e=="string"?[e]:e)}previewUndo(e,t){let r=this.canUndo(e);if(!r.ok)return{ok:!1,check:r};let o=Ts(r.ops),i=new Set;for(let s of r.ops)for(let a of s.writes)i.add(a);return{ok:!0,check:r,...this.previewPrimitives(o,{reads:[...new Set(r.ops.flatMap(s=>[...s.reads]))],writes:[...i],intent:`Undo: ${r.ops.map(s=>s.intent).join("; ")}`,restoring:r.ops.every(Ca),...t===void 0?{}:{context:t}})}}undo(e,t={}){return this.undoing(e,t)}undoing(e,t){this.stillNow();let r=typeof e=="string"?[e]:e,o=t.author??this.by,i=(this.policy?.sees?.length??0)>0&&!V(o);if(i){let h=Tn(Zr(Xe(this.log.all(),Dr(this,o)),()=>this.log.epochs()),r);if(!h.ok)throw new Ee(h)}let s=this.canUndo(r);if(!s.ok)throw new Ee(i?{ok:!1,ops:[],blockedBy:[],includeBatches:[],message:"Cannot undo on its own \u2014 a later change you cannot see depends on it, which only somebody who can see it can take back."}:s);let a=t.batch??this.mintBatch("undo"),d=Gn(t.lineage);if(this.policy)for(let h of s.ops){if(!h.mutation)continue;let b=T(h.author).id,y=R=>JSON.stringify(R).includes(JSON.stringify(b)),k=b!==void 0&&b!==T(o).id&&!V(o)&&!y(h.mutation.args)&&y(h.primitives)?{ok:!1,refusal:{mutation:h.mutation.name,wouldNeed:[],message:"it was done as somebody else."}}:this.permits(h.mutation,o);k.ok||this.refuse({...k.refusal,message:`Not permitted to undo "${h.intent}": ${k.refusal.message}`},o.id,!0)}let l=this.graph.snapshot(),u=this.violations(),p=[],c=this.log.length;for(let h of[...s.ops].sort((b,y)=>y.seq-b.seq)){let b={id:this.nextId(),seq:this.log.length,batch:a,author:o,intent:`Undo: ${h.intent}`,...F("batchIntent",t.intent),mutation:null,primitives:h.inverse,inverse:[...h.inverse].reverse().map(Mn),reads:h.reads,writes:h.writes,at:this.now(),undoes:h.id,...F("via",t.via),...F("lineage",d),...F("undoneLineage",h.lineage)};this.graph.applyPrimitives(b.primitives,{restoring:Ca(h)}),this.log.append(b),p.push(b)}let f=ye(l,this.graph.snapshot(),p.flatMap(h=>[...h.primitives]));this.admitted(t,p,p.flatMap(h=>[...h.primitives]),f,l,c);let g=this.violations();return this.notify(f,p),{batch:a,ops:p,diff:f,primitives:p.flatMap(h=>[...h.primitives]),reads:[...new Set(p.flatMap(h=>[...h.reads]))],writes:[...new Set(p.flatMap(h=>[...h.writes]))],intent:t.intent??p.map(h=>h.intent).join("; "),...this.moved(u,g),violationsAfter:g}}authorName(e){return En(e,{graph:this.graph,schema:this.schema})}refuseDeclined(e,t){let r=Bs(this.log.all(),e);r&&this.refuse({mutation:e[0].name,message:`${this.authorName(t)} may not make this again: a person declined it on ${r.at.slice(0,10)}.`,wouldNeed:[]},t.id)}putBack(e,t){this.graph.load(e),this.log.length>t&&this.log.truncate(t)}admitted(e,t,r,o,i,s){if(!e.admit||t.length===0)return;let a=this.graph.size;try{e.admit({ops:t,primitives:r,added:{nodes:o.addedNodes.length,edges:o.addedEdges.length},removed:{nodes:o.removedNodes.length,edges:o.removedEdges.length},changed:{nodes:o.changedNodes.length},nodesAfter:a.nodes,edgesAfter:a.edges})}catch(d){throw this.putBack(i,s),d}}redo(e,t={}){return this.undo(e,t)}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(e,t){if(!(this.quiet>0)&&!(t.length===0&&ws(e)))for(let r of this.listeners)r(e,t)}rebase(e){this.stillNow();let t=new Set([...e.pending,...e.drop??[]]),r=this.log.all(),o=r.findIndex(h=>t.has(h.batch)),i=r.slice(o<0?r.length:o),s=this.log.horizon+(o<0?r.length:o),a=i.find(h=>!t.has(h.batch));if(a)throw new M(`Cannot rebase: op "${a.id}" (${a.intent}) comes after a pending batch and is neither pending nor dropped`,"While anything is pending, land the server's ops through rebase, so the log stays confirmed ops then pending ones.");let d=this.log.lastEpoch();if(d&&d.seq>s)throw new M(`Cannot rebase across an epoch: one begins at seq ${d.seq}, after pending op "${i[0].id}"`);let l=this.graph.snapshot(),u=[],p=[],c=[];this.quiet++;try{for(let b of[...i].reverse())this.graph.applyPrimitives(b.inverse,{restoring:!0,inPlace:!0});this.log.truncate(s);let h=new Set(this.log.all().map(b=>b.id));for(let b of e.confirmed){if(h.has(b.id))continue;try{this.graph.applyPrimitives(b.primitives,{restoring:b.undoes!==void 0})}catch(k){throw new dn(b,k)}let y={...b,seq:this.log.length};this.log.append(y),h.add(b.id),u.push(y)}for(let b of e.pending){let y=i.filter(k=>k.batch===b);if(y.length!==0)try{p.push(...this.replay(b,y))}catch(k){c.push({batch:b,error:k})}}}catch(h){this.log.truncate(s);for(let b of i)this.log.append(b);throw this.graph.load(l),h}finally{this.quiet--}let f=He(l,this.graph.snapshot()),g=[...u,...p];return this.notify(f,g),{diff:f,confirmed:u,pending:p,refused:c}}adopt(e){this.stillNow();let t=new Set(e.drop??[]),r=(e.pending??[]).filter(f=>!t.has(f)),o=this.log.all(),i=this.graph.snapshot(),s={ops:[...o],epochs:[...this.log.epochs()],horizon:this.log.horizon},a=new Set(o.map(f=>f.id)),d=new Map(r.map(f=>[f,o.filter(g=>g.batch===f)]));if(e.log.length>0)this.log.replace(e.log,e.epochs,F("horizon",e.horizon));else{let f=e.horizon??0;this.log.replace([],e.epochs??[{seq:f,base:e.snapshot}],{horizon:f})}let l=[],u=[];this.quiet++;try{this.graph.load(e.snapshot),this.projected=void 0,this.countPastTheLog();for(let f of r){let g=d.get(f)??[];if(g.length!==0)try{l.push(...this.replay(f,g))}catch(h){u.push({batch:f,error:h})}}}catch(f){throw this.log.replace(s.ops,s.epochs,{horizon:s.horizon}),this.graph.load(i),this.projected=void 0,f}finally{this.quiet--}let p=this.log.all().filter(f=>!a.has(f.id)&&!l.includes(f)),c=He(i,this.graph.snapshot());return this.notify(c,[...p,...l]),{diff:c,adopted:p,pending:l,refused:u}}replay(e,t){let r=t[0],o={author:r.author,batch:e,...F("intent",r.batchIntent),...F("via",r.via),...F("lineage",r.lineage)};if(r.undoes!==void 0){let i=t.map(a=>this.log.get(a.undoes??"")),s=t.find((a,d)=>i[d]===void 0);if(s)throw new M(`What "${s.intent}" took back is no longer in the log`);return this.undoing([...new Set(i.map(a=>a.batch))],o).ops}return t.every(i=>i.mutation!==null)?this.applying(t.map(i=>i.mutation),o).ops:this.append(t.map(({seq:i,...s})=>s))}snapshot(){return this.graph.snapshot()}verify(){let e=this.log.lastEpoch();return ua(this.schema,this.log.opsFrom(e?.seq??0),this.graph.snapshot(),{validate:this.validate,...e?{base:e.base}:{}})}checkpoint(e={}){let t=this.log.all(),r;if(e.seq!==void 0)r=e.seq;else{let a=this.log.length-(e.keepOps??1e3),l=Date.parse(e.now??this.now())-(e.keepDays??90)*864e5,u=t.find(c=>Date.parse(c.at)>l),p=u?u.seq:this.log.length;r=Math.min(a,p)}for(r=Math.min(Math.max(r,this.log.horizon),this.log.length);r>this.log.horizon&&r<this.log.length&&t[r-this.log.horizon].batch===t[r-1-this.log.horizon].batch;)r--;if(r<=this.log.horizon)return;let o=this.verify();if(!o.ok)throw new M(`Cannot compact a store that does not verify: ${o.reason}`);let i=this.log.checkpointAt(this.schema,r,{validate:this.validate}),s=Js(this.log,r);return Object.keys(s).length>0?{...i,creators:s}:i}compact(e){return this.stillNow(),this.log.compact(e)}};var ol=n=>`lens:${n}`,il={hidden:[],removed:[],may:{views:!1,lenses:!1}};function sl(n,e,t){return n.name!==void 0&&e.may.views?"view":n.declared&&e.may.lenses&&t.lens?"lens":null}var Ba=["full","summary","glyph"],ro=(n,e)=>n.as===e.as&&(n.over??[n.kind]).includes(e.kind),al=n=>n.filter((e,t)=>!n.slice(0,t).some(r=>ro(r,e)));function fe(n){return n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function Un(n,e){return`/${fe(n.tryDefinition(e)?.plural??`${e}s`)}`}function dl(n,e,t){return`${Un(n,e)}/${encodeURIComponent(t)}`}function cl(n,e){return`/places/${encodeURIComponent(n)}${e?`?of=${encodeURIComponent(e)}`:""}`}function Va(n,e){return e.some(t=>t.as===n.as&&!ro(n,t))}function ul(n,e,t){return Va(n,e)?`${n.title} \xB7 ${(t.tryDefinition(n.kind)?.plural??`${n.kind}s`).toLowerCase()}`:n.title}var Me=(n,e,t="")=>`${n}|${e.cardinality}|${e.fidelity}|${t}`;function to(n){switch(n){case"full":return["full","summary","glyph"];case"summary":return["summary","full","glyph"];case"glyph":return["glyph","summary","full"]}}function ll(n){let e=new Map,t=[],r=[],o,i,s={arrange(a){return a!==void 0&&(o=a),s},arrangement:()=>o,home(a){return a!==void 0&&(i=a),s},homeView:()=>i,register(a,d,l,u){let p={...u?.over?.[1]?{over:u.over}:{},...u?.hidden?{hidden:!0}:{},...u?.name?{name:u.name}:{},...u?.declared?{declared:!0}:{}},c={kind:a,cardinality:d.cardinality,fidelity:d.fidelity,view:l,...u?.title?{title:u.title}:{},...u?.across?{across:u.across}:{},...u?.beside?{beside:!0}:{},...p};if(r.push(c),!u?.beside&&!p.hidden&&e.set(Me(a,d),c),u?.title){let f=fe(u.title);e.set(Me(a,d,f),c),d.cardinality==="many"&&!t.some(g=>g.kind===a&&g.as===f)&&t.push({kind:a,title:u.title,as:f,...u.across?{across:u.across}:{},...p,...u.lens?{lens:u.lens}:{},...u.reads?.length?{reads:u.reads}:{}})}return s},places:()=>t,forget(a,d){for(let u of Ba)e.delete(Me(a,{cardinality:"many",fidelity:u},d));let l=t.findIndex(u=>u.kind===a&&u.as===d);return l>=0&&t.splice(l,1),s},lookup(a,d){return e.get(Me(a,d))?.view},resolve(a,d,l){if(l)for(let u of to(d.fidelity)){let p=e.get(Me(a,{cardinality:d.cardinality,fidelity:u},l));if(p)return p}for(let u of to(d.fidelity)){let p=e.get(Me(a,{cardinality:d.cardinality,fidelity:u}));if(p)return p}if(d.cardinality==="one")for(let u of to(d.fidelity)){let p=e.get(Me(a,{cardinality:"many",fidelity:u}));if(p)return p}},registrations:()=>r,all(){return[...e.values()]},kindsWithViews(){return[...new Set([...e.values()].map(a=>a.kind))]}};return s}var fl=["day","week","month","year","decade"];function Wa(n){let e={};n.q&&n.q.trim().length>0&&(e.query=n.q);let t=wr(n.archived);if(t&&(e.archived=t),n.sort){let[r,o]=n.sort.split(":");r&&(e.sort={by:r,direction:o==="desc"?"desc":"asc"})}if(n.filter){let r=[];for(let o of n.filter.split(",")){let i=o.indexOf(":");i<=0||r.push({key:o.slice(0,i),value:o.slice(i+1)})}r.length>0&&(e.filter=r)}if(n.group){let[r,o]=n.group.split(":");r&&(e.group={by:r,...fl.includes(o)?{bucket:o}:{}})}return e}function oo(n){if(typeof n=="string"&&n.length>0)return{by:n,direction:"asc"};if(typeof n!="object"||n===null)return;let{by:e,direction:t}=n;if(!(typeof e!="string"||e.length===0))return{by:e,direction:t==="desc"?"desc":"asc"}}function Rt(n,e,t){let r=oo(n);if(!r)return'an order is a field, like "released", or { "by": "released", "direction": "asc" | "desc" }';let o=typeof n=="object"&&n!==null?n.direction:void 0;if(o!==void 0&&o!=="asc"&&o!=="desc")return`an order runs "asc" or "desc", not "${String(o)}"`;if(r.by!=="label"&&!e.includes(r.by))return`${t} has no field "${r.by}" to order by (it has ${e.length>0?e.map(i=>`"${i}"`).join(", "):"none"}, and "label", its name)`}function pl(n,e,t){let r=oo(e);if(!r)return n;let o=r.direction==="desc"?-1:1;return n.map((i,s)=>({item:i,at:s,value:t(i,r.by)})).sort((i,s)=>{let a=(i.value===void 0||i.value===null||i.value===""?1:0)-(s.value===void 0||s.value===null||s.value===""?1:0);if(a!==0)return a;if(i.value===s.value||i.value===void 0||i.value===null)return i.at-s.at;let d=typeof i.value=="number"&&typeof s.value=="number"?i.value-s.value:String(i.value).localeCompare(String(s.value),void 0,{numeric:!0});return d===0?i.at-s.at:d*o}).map(i=>i.item)}var At={timeline:{binds:"fields",requiredRoles:["start","end"],options:["columns","extent","tick","minWindow","arranging"]},calendar:{binds:"fields",requiredRoles:["start"],options:["today","range","weekStartsOn","perCell","horizon","arranging","search","filters"]},coverage:{binds:"entities",requiredRoles:["rows","columns","link"],options:["rowRef","rowGroup","groupOrder","requiredGroups","requiredVia","badge","columnGroup","sort","columnSort","search","filters"]},board:{binds:"entities",requiredRoles:["slots","x","y","fill"],options:["fillFrom","slotCode","zones","aspect","emptyLabel","pickTarget","arranging","arrange"]},plan:{binds:"entities",requiredRoles:["regions","outline"],options:["hues","aspect","undrawnLabel","strayLabel","draw","place","help"]},reach:{binds:"nothing",requiredRoles:[],options:[]},blocks:{binds:"nothing",requiredRoles:[],options:["blocks"]},columns:{binds:"fields",requiredRoles:["column"],options:["sort","search","filters","move","collapsed","cap","hidden"]}},hl=20,Ha=Object.keys(At),Ya=n=>Object.hasOwn(At,n);function io(n,e,t){let r=n[e],o=Array.isArray(r)?r.filter(i=>typeof i=="string"&&t(i)):[];o.length>0?n[e]=o:delete n[e]}var cn=n=>typeof n=="object"&&n!==null&&!Array.isArray(n);function qa(n,e,t){let r=n.tryDefinition(e)?.fields.shape,o=I(r?.[t]);for(;o&&(o.type==="optional"||o.type==="default"||o.type==="nullable"||o.type==="prefault");)o=I(o.innerType);return o?.type!=="enum"?[]:(o.entries?Object.values(o.entries):o.values??[]).filter(s=>typeof s=="string")}function gl(n){let e=[],t=[],r=[],o=new Set(n.schema.kinds),i=new Set;for(let d of o)for(let l of Object.keys(n.schema.tryDefinition(d)?.edges??{}))i.add(l);let s=d=>Object.keys(n.schema.tryDefinition(d)?.fields.shape??{}),a=new Map;return(n.lenses??[]).forEach((d,l)=>{let u=`lenses.${l}`,p=typeof d.title=="string"&&d.title.trim().length>0?d.title.trim():void 0,c=(x,v)=>{t.push({index:l,name:d.name,...p?{title:p}:{},why:x}),v&&r.push({severity:"warning",...v})};if(!Ya(d.name)){p?c(`"${d.name}" is not a lens this framework draws`,{code:"lens-not-shipped",path:`${u}.name`,message:`"${p}" names the lens "${d.name}", which the framework does not ship, so nothing draws it.`,fix:`Name one of ${Ha.join(", ")} \u2014 or register the view yourself and drop the title.`}):c("it is a lens this app wrote, drawn by the app's own views");return}if(!p)return c("it has no title, so it is bindings the checker holds and no place");let f=At[d.name],g=cn(d.options)?d.options:{};if(d.options!==void 0&&!cn(d.options))return c("its options are not an object",{code:"lens-options-not-an-object",path:`${u}.options`,message:`"${p}" has options that are not an object.`,fix:'Write them as { "<option>": <value> }, or drop them.'});for(let x of Object.keys(g))f.options.includes(x)||r.push({severity:"warning",code:"lens-option-unknown",path:`${u}.options.${x}`,message:`The ${d.name} lens takes no option "${x}", so "${p}" ignores it.`,fix:f.options.length===0?`The ${d.name} lens takes no options; drop it.`:`Use one of: ${f.options.join(", ")}.`});let h={};for(let x of f.options)g[x]!==void 0&&(h[x]=g[x]);d.arrangedBy&&(h.arrangedBy=Wa(d.arrangedBy));let b=cn(d.bindings)?d.bindings:{},y=[],k,R=(x,v,$)=>c(v,{code:"lens-cannot-draw",path:x,message:`"${p}" cannot draw: ${v}.`,fix:$});if(f.binds==="fields"){let x=Object.keys(b).filter($=>cn(b[$])),v=x.filter($=>!o.has($));if(x.length===0)return R(`${u}.bindings`,"it binds no kind",`Bind a kind's fields: "bindings": { "<kind>": { ${f.requiredRoles.map($=>`"${$}": "<field>"`).join(", ")} } }.`);if(v.length>0)return;if(h.bindings=b,y=x,d.name==="timeline"){let $=g.columns;if(Array.isArray($))h.columns=$.map(_=>typeof _=="string"?{id:_,label:_}:_);else{let _=x.flatMap(N=>{let E=b[N],L=typeof E.column=="string"?E.column:typeof E.columns=="string"?E.columns:void 0;return L?qa(n.schema,N,L):[]}),A=[...new Set(_)];if(A.length===0)return R(`${u}.options.columns`,"it has no columns \u2014 no option names them and no `column` role is bound to a field of set values",'Bind "column" to a field whose values are the columns, or say "columns": ["mon", "tue", \u2026].');h.columns=A.map(N=>({id:N,label:N.toUpperCase()}))}h.extent===void 0&&(h.extent=1440)}if(d.name==="columns"){if(h.sort!==void 0){let _=x.map(A=>Rt(h.sort,s(A),A)).find(Boolean);_&&(r.push({severity:"warning",code:"lens-sort",path:`${u}.options.sort`,message:`"${p}" cannot order its cards: ${_}.`,fix:'Write { "by": "<a field>", "direction": "asc" }, or drop it.'}),delete h.sort)}let $=new Set;for(let _ of x){let A=b[_].column;if(typeof A!="string"||!s(_).includes(A))return;let N=qa(n.schema,_,A);if(N.length===0)return R(`${u}.bindings.${_}.column`,`its column field "${A}" is not a choice`,`Bind "column" to a choice field of ${_}, like a status.`);for(let E of N)$.add(E)}typeof h.move!="boolean"&&delete h.move,Number.isInteger(h.cap)&&h.cap>=1&&h.cap<=500||delete h.cap;for(let _ of["collapsed","hidden"])io(h,_,A=>$.has(A))}if(d.name==="calendar"&&h.today!==void 0&&!(typeof h.today=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(h.today)))return R(`${u}.options.today`,"its today is not a date",'Write it as "YYYY-MM-DD", or leave it out and the calendar opens on the day it is drawn.');if(d.name==="calendar"&&h.horizon!==void 0){let $=h.horizon,_=E=>E===void 0||Number.isInteger(E)&&E>=1&&E<=9999,A=typeof $=="number"?{years:$,title:"Years"}:$;cn(A)&&Number.isInteger(A.years)&&A.years>=1&&A.years<=200&&typeof A.title=="string"&&A.title.trim().length>0&&_(A.from)&&_(A.to)&&Object.keys(A).every(E=>["years","title","from","to"].includes(E))&&!(typeof A.from=="number"&&typeof A.to=="number"&&A.to<A.from)?h.horizon=A:(delete h.horizon,r.push({severity:"warning",code:"lens-horizon",path:`${u}.options.horizon`,message:`"${p}" has a horizon that is not a span of years, so it offers no span of years.`,fix:'Write { "years": 30, "title": "The career" } \u2014 "from" and "to" (years, like 1962 and 2023) only to pin its ends, which otherwise reach the first and last of its records.'}))}if(d.name==="calendar"&&h.range!==void 0&&!["day","week","month","quarter","year","years","agenda"].includes(h.range))return R(`${u}.options.range`,`its range "${String(h.range)}" is not one a calendar opens at`,"Use one of: day, week, month, quarter, year, agenda.")}else if(f.binds==="entities"){let x=_=>{let A=b[_];if(cn(A)){if(typeof A.kind=="string")return A.kind;if(typeof A.edge=="string")return A.edge;if(Array.isArray(A.path))return{path:A.path};if(typeof A.field=="string")return A.field}};for(let _ of f.requiredRoles)if(x(_)===void 0)return;let v=d.name==="coverage"?"rows":d.name==="board"?"slots":"regions",$=x(v);if(!o.has($))return;if(d.name==="coverage"){let _=x("columns");if(!o.has(_))return;let A=x("link");if(typeof A=="string"&&!i.has(A))return;Object.assign(h,{rows:$,columns:_,link:A}),_!==$&&(k=_);for(let[N,E]of[["sort",$],["columnSort",_]]){if(h[N]===void 0)continue;let L=Rt(h[N],s(E),E);L&&(r.push({severity:"warning",code:"lens-sort",path:`${u}.options.${N}`,message:`"${p}" cannot order its ${N==="sort"?"rows":"columns"}: ${L}.`,fix:`Write { "by": "<a field of ${E}>", "direction": "asc" }, or drop it.`}),delete h[N])}}else if(d.name==="board"){Object.assign(h,{slots:$,x:x("x"),y:x("y"),fill:x("fill")});for(let _ of["x","y"])if(!s($).includes(h[_]))return}else{Object.assign(h,{regions:$,outline:x("outline")});for(let _ of["markers","at","within","nests","regionKind","markerKind"]){let A=x(_);typeof A=="string"&&(h[_]=A)}}y=[$]}else if(d.name==="blocks"){if(!d.on)return R(`${u}.on`,"it does not say which kind it stands on",'Say "on": "<the kind it is a place of>".');if(!Array.isArray(h.blocks)||h.blocks.length===0)return R(`${u}.options.blocks`,"it has no blocks to draw",`Say "options": { "blocks": [{ "headline": "\u2026" }, { "list": "all('<kind>')", "as": "card" }] }.`)}else{let x=["user","person","member"].find(v=>o.has(v));if(!d.on&&!x)return R(`${u}.on`,"it does not say which kind it stands on",'Say "on": "<the kind whose records are the people>".');y=x?[x]:[]}if(d.on!==void 0){if(typeof d.on!="string"||!o.has(d.on))return R(`${u}.on`,`it stands on "${String(d.on)}", which is not a kind`,`Use one of: ${[...o].join(", ")}.`);if(y=[d.on],d.name==="coverage"){let x=[h.rows,h.columns].find(v=>v!==d.on);k=typeof x=="string"?x:void 0}}let m=typeof h.rows=="string"?h.rows:y[0];if(m!==void 0){let x=["label",...s(m)],v=new Set(["is",...x,...Object.keys(n.schema.tryDefinition(m)?.edges??{})]);io(h,"search",$=>x.includes($)),io(h,"filters",$=>v.has($.split(".")[0]))}let w=fe(p);if(w.length===0)return R(`${u}.title`,"its title has no letters or digits to make an address of","Give it a title a person would say.");for(let x of y){let v=`${x}|${w}`;if(a.has(v))return c(`another lens on ${x} is already called "${p}"`,{code:"lens-title-taken",path:`${u}.title`,message:`"${p}" is the title of lenses.${a.get(v)} too, on the same kind, so one address would name two pictures.`,fix:"Give each its own title."})}for(let x of y)a.set(`${x}|${w}`,l);let S=d.create;S!==void 0&&typeof S!="boolean"&&r.push({severity:"warning",code:"lens-create",path:`${u}.create`,message:`"${p}" says create ${JSON.stringify(S)}, which is neither true nor false, so its page keeps the forms that begin its kind.`,fix:'Say "create": false to leave them off, or drop it.'}),e.push({index:l,lens:d.name,title:p,as:w,kinds:y,...k?{across:k}:{},options:h,...d.hidden===!0?{hidden:!0}:{},...S===!1?{create:!1}:{}})}),{drawn:e,undrawn:t,findings:r}}var ml=6;function yl(n,e,t=[]){let r=n.kinds,o=s=>Object.values(n.tryDefinition(s)?.edges??{}).map(a=>(a.to??[]).filter(d=>d!==s)),i=new Set(r.flatMap(s=>o(s).flat()));return new Set([...e?.hide??[],...t,...r.filter(s=>!i.has(s)&&o(s).length>0&&o(s).every(a=>a.length>=2))])}function bl(n,e,t){if(!n?.primary)return;let r=new Set(n.primary.map(fe));return{kinds:new Set(e.kinds.filter(o=>r.has(fe(o))||r.has(Un(e,o).slice(1)))),places:new Set(t.filter(o=>r.has(o.as)||r.has(fe(o.title))).map(o=>`${o.kind}|${o.as}`))}}var Ja="overview",vl=`/places/${Ja}`;function xl(n){let e=n?.scene?.trim();return e||"Scene"}function wl(n){let e=n?.pages?.trim();return e||"Pages"}function kl(n,e){if(!e||e.length===0)return n;let t=e.filter(r=>n.includes(r));return[...new Set(t),...n.filter(r=>!t.includes(r))]}function Sl(n,e,t){if(n===void 0)return;let r=n.trim();if(r==="")return;if(r.toLowerCase()==="home"||r==="/")return{to:"home"};let o=fe(r),i=t.find(d=>d.title===r)??t.find(d=>d.as===o);if(i)return{to:"place",place:i};let s=e.kinds,a=s.find(d=>d===r)??s.find(d=>Un(e,d).slice(1)===o);return a?{to:"kind",kind:a}:void 0}function so(n){let e=(n??"").replace(/\/+$/,"");return e===""?"":e.startsWith("/")?e:`/${e}`}function $l(n,e={}){let t=typeof n=="string"?n:n.address,r=so(e.basePath),o=t.startsWith("/")?t:`/${t}`;return r===""?o:o==="/"?r:o.startsWith("/?")||o.startsWith("/#")?`${r}${o.slice(1)}`:`${r}${o}`}function _l(n,e){let t=so(e);if(t==="")return n.startsWith("/")?n:`/${n}`;if(!n.toLowerCase().startsWith(t.toLowerCase()))return null;let r=n.slice(t.length);return r===""||r==="/"?"/":r.startsWith("/")?r:null}var Xa=Symbol.for("@graview/core:app-link"),Rl=n=>(Object.defineProperty(I(n),Xa,{value:1,enumerable:!0}),n);function Qa(n){let e=I(n);return!!e&&(e[Xa]===1||Qa(e.innerType))}var bx=()=>Rl(Z().check(pr(500),Sn(st,"another app's address")));var Ot=(n,e)=>`${e.kind}\0${e.id??""}\0${n.address}\0${n.kind}\0${n.id}`;function Al(n,e,t=()=>{}){let r=new Map,o=new Map,i=s=>{let a=Ot(s,e),d=r.get(a);return d||(d=Promise.resolve().then(()=>n.resolve(s,e)).then(l=>Ol(l)?l:null,()=>null).then(l=>(r.get(a)===d&&(o.set(a,l),t(s)),l)),r.set(a,d)),d};return{read(s){let a=Ot(s,e);if(o.has(a)){let d=o.get(a);return d===null?{unread:!0}:"denied"in d?{denied:!0}:{record:d}}return i(s),{unread:!0}},ask:i,answered:s=>o.get(Ot(s,e)),forget(s){if(!s){r.clear(),o.clear();return}let a=Ot(s,e);r.delete(a),o.delete(a)}}}function Ol(n){if(n===null)return!0;if(typeof n!="object"||n===void 0)return!1;if(n.denied===!0)return!0;let e=n;return typeof e.label=="string"&&typeof e.id=="string"&&typeof e.kind=="string"&&typeof e.fields=="object"&&e.fields!==null}var El=1;var Et=(n,e)=>`${n}\0${e}`;function co(n){return n.op==="add-node"?Object.keys(n.node).filter(e=>e!=="id"&&e!=="kind").map(e=>[n.node.id,e]):n.op==="patch-node"?Object.keys(n.after).map(e=>[n.id,e]):[]}var ao=class n{revs=new Map;static of(e){let t=new n;return t.note(e),t}note(e){for(let t of e)for(let r of t.primitives)for(let[o,i]of co(r)){let s=Et(o,i);(this.revs.get(s)??-1)<t.seq&&this.revs.set(s,t.seq)}}of(e,t){return this.revs.get(Et(e,t))??-1}baseFor(e,t=new Set){let r=new Set,o=new Map;for(let i of e)for(let s of i.primitives)if(s.op==="add-node"&&r.add(s.node.id),!(s.op!=="patch-node"||r.has(s.id)||t.has(s.id)))for(let a of Object.keys(s.after)){let d=Et(s.id,a);t.has(d)||o.has(d)||o.set(d,{node:s.id,field:a,rev:this.of(s.id,a)})}return[...o.values()]}stale(e){return e.filter(t=>this.of(t.node,t.field)!==t.rev)}};function Pl(n){let e=new Set;for(let t of n)for(let r of t.primitives){r.op==="add-node"&&e.add(r.node.id);for(let[o,i]of co(r))e.add(Et(o,i))}return e}var zl=/^#([0-9a-f]{3,8})$/i,Ml=/(rgba?|hsla?)\(([^)]+)\)/gi;function Nl(n){let e=zl.exec(n.trim());if(!e)return null;let t=e[1];if((t.length===3||t.length===4)&&(t=[...t].map(i=>i+i).join("")),t.length!==6&&t.length!==8)return null;let r=Number.parseInt(t.slice(0,6),16),o=t.length===8?Number.parseInt(t.slice(6,8),16)/255:1;return{r:r>>16&255,g:r>>8&255,b:r&255,a:o}}function Il(n){let e=n.slice(0,n.indexOf("(")).toLowerCase(),r=n.slice(n.indexOf("(")+1,n.lastIndexOf(")")).split(/[,\s/]+/).filter(Boolean).map(d=>d.endsWith("%")?Number.parseFloat(d)/100:Number.parseFloat(d));if(r.some(Number.isNaN))return null;if(e.startsWith("rgb")){let[d,l,u,p]=r;return d===void 0||l===void 0||u===void 0?null:{r:d,g:l,b:u,a:p??1}}let[o,i,s,a]=r;return o===void 0||i===void 0||s===void 0?null:{...nd(o,i>1?i/100:i,s>1?s/100:s),a:a??1}}function lo(n){let e=n.r/255,t=n.g/255,r=n.b/255,o=Math.max(e,t,r),i=Math.min(e,t,r),s=(o+i)/2;if(o===i)return{h:0,s:0,l:s};let a=o-i,d=a/(1-Math.abs(2*s-1));return{h:((o===e?60*((t-r)/a%6):o===t?60*((r-e)/a+2):60*((e-t)/a+4))+360)%360,s:d,l:s}}function fo(n,e,t){return{...nd(n,e,t),a:1}}function nd(n,e,t){let r=(1-Math.abs(2*t-1))*e,o=(n%360+360)%360/60,i=r*(1-Math.abs(o%2-1)),[s,a,d]=o<1?[r,i,0]:o<2?[i,r,0]:o<3?[0,r,i]:o<4?[0,i,r]:o<5?[i,0,r]:[r,0,i],l=t-r/2;return{r:Math.round((s+l)*255),g:Math.round((a+l)*255),b:Math.round((d+l)*255)}}function un(n){let e=[];for(let t of n.matchAll(Ml)){let r=Il(t[0]);r&&e.push(r)}for(let t of n.matchAll(/#[0-9a-fA-F]{3,8}\b/g)){let r=Nl(t[0]);r&&e.push(r)}return e}function po(n,e){let t=n.a+e.a*(1-n.a);if(t===0)return{r:0,g:0,b:0,a:0};let r=(o,i)=>(o*n.a+i*e.a*(1-n.a))/t;return{r:r(n.r,e.r),g:r(n.g,e.g),b:r(n.b,e.b),a:t}}function uo(n){let e=n/255;return e<=.03928?e/12.92:((e+.055)/1.055)**2.4}function ed(n){return .2126*uo(n.r)+.7152*uo(n.g)+.0722*uo(n.b)}function ln(n,e){let[t,r]=[ed(n),ed(e)].sort((o,i)=>i-o);return(t+.05)/(r+.05)}var Pt=(n,e)=>`rgba(${Math.round(n.r)}, ${Math.round(n.g)}, ${Math.round(n.b)}, ${e})`,td={r:0,g:0,b:0,a:1},zt={r:255,g:255,b:255,a:1};function Mt(n){let e=un(n.accent)[0];if(!e)return{ok:!1,missing:["accent"],why:`"${n.accent}" is not a color this can read. Use a hex, rgb() or hsl() value.`};let t={},r=new Set,o=[],i=lo(e);for(let s of["dark","light"]){let a=n.base[s],d=un(a.ground)[0]??(s==="dark"?td:zt),l=po(un(a.panel)[0]??zt,d),u=Zl(i,[l,d],s,4.5);u?Math.abs(u.l-i.l)>Dl&&(r.add(`accent (${s})`),o.push(`reaching 4.5:1 on the ${s} panel would move the accent's lightness by ${Math.round(Math.abs(u.l-i.l)*100)} points, which is far enough that it stops being the same color \u2014 supply one for ${s}`)):(r.add(`accent (${s})`),o.push(`no lightness of this hue clears 4.5:1 as text on the ${s} panel, so ${s} needs an accent of its own`));let p=u??i,c=fo(p.h,p.s,p.l),f=n.accentInk?.[s]??(ln(zt,c)>=ln(td,c)?"#ffffff":"#000000"),g=ln(un(f)[0]??zt,c);g+.005<4.5&&(r.add(`accentInk (${s})`),o.push(`neither black nor white clears 4.5:1 on the accent (best ${g.toFixed(2)}:1), so text on a filled button has to be given`)),t[s]={...a,accent:Pt(c,1),accentDim:Pt(c,s==="dark"?.35:.22),accentInk:f,glow:Pt(c,s==="dark"?.28:.1),edgeBright:Pt(c,jl(c,l,s==="dark"?.55:.42,3)),...n.warn?.[s]?{warn:n.warn[s]}:{}};let h=un(t[s].warn)[0];h&&Tl(lo(h).h,p.h)<25&&(r.add(`warn (${s})`),o.push(`the warning color shares the accent's hue in ${s}, so "something is broken" looks like "this is selected"`))}return r.size>0?{ok:!1,missing:[...r].sort(),why:o.join("; ")}:{ok:!0,schemes:t}}function jl(n,e,t,r){for(let o=Math.round(t*100);o<=100;o++){let i=o/100;if(ln(po({...n,a:i},e),e)>=r)return i}return 1}function Tl(n,e){let t=Math.abs(n-e)%360;return t>180?360-t:t}var Dl=.3;function Zl(n,e,t,r){let o=t==="dark";for(let i=0;i<=100;i++){let s=o?n.l+i/100:n.l-i/100,a=o?n.l-i/100:n.l+i/100;for(let d of[s,a])if(!(d<0||d>1)&&e.every(l=>ln(fo(n.h,n.s,d),l)>=r))return{...n,l:d}}return null}function Fl(n,e){let t=e?.[n];if(t!==void 0)return(t%360+360)%360;let r=2166136261;for(let o=0;o<n.length;o++)r^=n.charCodeAt(o),r=Math.imul(r,16777619);return(r>>>0)%360}var Ne=Object.freeze({navy:"#001769",turquoise:"#00e5b9",paper:"#f7f7f2",ink:"#18213a",muted:"#586174"}),ho="Montserrat",go=Object.freeze({display:550,body:450,label:600}),mo=Object.freeze({display:600,body:400,label:600}),Ll="-0.025em",Cl=Object.freeze({minWidth:140,clearSpace:.5,microMax:24,regularMin:32,microBelow:28});var rd={ground:"#0a0f1f",groundDeep:"#060914",wash:"none",panel:"rgba(19, 27, 52, 0.96)",panelMuted:"rgba(14, 21, 42, 0.94)",panelWarning:"rgba(48, 33, 18, 0.95)",edge:"rgba(164, 178, 222, 0.18)",edgeBright:"rgba(154, 171, 255, 0.6)",ink:"#eef0f6",inkMuted:"#aab2c6",inkFaint:"#97a0b6",accent:"#9aabff",accentDim:"rgba(154, 171, 255, 0.32)",accentInk:Ne.navy,warn:"#f0a868",good:"#8fdcaa",bad:"#ffa3a3",glow:"rgba(154, 171, 255, 0.18)",bar:"rgba(10, 15, 31, 0.96)",float:"rgba(16, 23, 45, 0.98)",liftLow:"0 14px 36px -22px #000",liftHigh:"0 28px 64px -30px #000",tintAlpha:.2,tintLightness:52,gridAlpha:.35},od={ground:Ne.paper,groundDeep:"#efefe8",wash:"none",panel:"#ffffff",panelMuted:"#fafaf6",panelWarning:"#fdf4ea",edge:"rgba(24, 33, 58, 0.12)",edgeBright:"rgba(0, 23, 105, 0.6)",ink:Ne.ink,inkMuted:Ne.muted,inkFaint:"#626b7d",accent:Ne.navy,accentDim:"rgba(0, 23, 105, 0.16)",accentInk:"#ffffff",warn:"#9a5312",good:"#1b6436",bad:"#a1232d",glow:"rgba(0, 23, 105, 0.08)",bar:"rgba(255, 255, 255, 0.96)",float:"#ffffff",liftLow:"0 1px 2px rgba(24,33,58,0.06), 0 8px 24px -12px rgba(24,33,58,0.16)",liftHigh:"0 2px 6px rgba(24,33,58,0.08), 0 24px 56px -24px rgba(24,33,58,0.26)",tintAlpha:.16,tintLightness:46,gridAlpha:.5},fn={dark:rd,light:od};var Se=Object.freeze({radius:8,density:1,radiusSmall:.72,radiusSmallFloor:2,pad:15,padSmall:10,gap:7}),Ie=Object.freeze({body:`"${ho}", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif`,mono:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace'});function Gl(n){let e=n?.shape?.radius??Se.radius,t=n?.shape?.density??Se.density;return Object.freeze({radius:e,radiusSmall:Math.max(Se.radiusSmallFloor,Math.round(e*Se.radiusSmall)),pad:Math.round(Se.pad*t),padSmall:Math.round(Se.padSmall*t),gap:Math.round(Se.gap*t)})}function Kl(n){let e=n?.typography?.body??Ie.body,t=n?.typography?.display??e,o=e===Ie.body&&t===Ie.body?go:mo,i=n?.typography?.weights;return Object.freeze({body:e,display:t,mono:n?.typography?.mono??Ie.mono,weights:Object.freeze({display:i?.display??o.display,body:i?.body??o.body,label:i?.label??o.label})})}var Mx=Object.freeze({light:Object.freeze({roof:Object.freeze({saturation:48,lightness:82}),right:Object.freeze({saturation:40,lightness:66}),left:Object.freeze({saturation:34,lightness:55}),roofEdge:"rgba(255,255,255,0.75)",plot:Object.freeze({saturation:45,lightness:58,alpha:.12}),plotEdge:Object.freeze({saturation:40,lightness:48,alpha:.55})}),dark:Object.freeze({roof:Object.freeze({saturation:42,lightness:32}),right:Object.freeze({saturation:40,lightness:21}),left:Object.freeze({saturation:38,lightness:13}),roofEdge:"rgba(255,255,255,0.14)",plot:Object.freeze({saturation:45,lightness:48,alpha:.2}),plotEdge:Object.freeze({saturation:40,lightness:62,alpha:.55})})});function sd(n){return/^\s*(<\?xml[^>]*>\s*)?(<!--[\s\S]*?-->\s*)*(<!DOCTYPE svg[^>]*>\s*)?<svg[\s>/]/i.test(n)}var ad="http://www.w3.org/2000/svg",Ul=["http://www.w3.org/1999/xhtml","http://www.w3.org/1998/Math/MathML",ad],Bl=new Set("svg g defs symbol use title desc path rect circle ellipse line polyline polygon text tspan textPath linearGradient radialGradient stop pattern clipPath mask marker image filter feBlend feColorMatrix feComponentTransfer feComposite feDropShadow feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feMerge feMergeNode feMorphology feOffset feTile feTurbulence".split(" ")),Vl=new Set(["title","desc"]),Bn="it embeds a page or media",Wl={script:"it has a script in it",foreignobject:"it embeds HTML (foreignObject)",iframe:Bn,embed:Bn,object:Bn,audio:Bn,video:Bn,style:"it has a style sheet in it; a mark is styled by its attributes",a:"it links to something (an <a> element)"},ql={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"};function Hl(n){let e=!1,t=n.replace(/&(#x[0-9a-f]+|#[0-9]+|[a-z][a-z0-9]*);?/gi,(r,o)=>{if(o[0]==="#"){let s=o[1]==="x"||o[1]==="X"?parseInt(o.slice(2),16):parseInt(o.slice(1),10);return s>0&&s<=1114111?String.fromCodePoint(s):"\uFFFD"}let i=ql[o.toLowerCase()];return i===void 0&&(e=!0),i??""});return e?null:t}function Yl(n){if(/\\|@|expression\s*\(|(?:image-set|cross-fade|image|element|src)\s*\(/i.test(n))return!1;for(let[,e]of n.matchAll(/url\s*\(\s*["']?\s*([^)]*)/gi))if(!e.startsWith("#"))return!1;return!0}function Jl(n,e,t){let r=Hl(t);if(r===null)return"it declares XML entities";let o=(e.includes(":")?e.slice(e.indexOf(":")+1):e).toLowerCase();if(o.startsWith("on"))return"it has an event handler (an on\u2026 attribute)";if(e==="xml:base")return"it loads or links to something outside itself";if(e==="xmlns")return r===ad?null:"it changes what its elements are (another xmlns)";if(e.startsWith("xmlns:"))return Ul.includes(r)?"it changes what its elements are (another xmlns)":null;if(o==="href"||o==="src"){let i=r.replace(/[\u0000- ]+/g,"");return i.startsWith("#")||n==="image"&&/^data:image\/(png|jpe?g|gif|webp|avif);/i.test(i)?null:"it loads or links to something outside itself"}return Yl(r)?null:o==="style"?"its style loads something outside itself":"it loads or links to something outside itself"}var id=/^\s+([A-Za-z_][A-Za-z0-9_.:-]*)\s*=\s*(?:"([^"<]*)"|'([^'<]*)')/;function dd(n){if(/<!ENTITY/i.test(n))return"it declares XML entities";if(/<!\[CDATA\[/i.test(n))return"it has a CDATA section, which the page and the picture read differently";let e=[],t=!1,r=/^\s*(<\?xml\s[^?<>]*\?>)?/.exec(n)[0].length;for(;r<n.length;){let o=n.slice(r),i=/^[^<]+/.exec(o);if(i){if(e.length===0&&i[0].trim()!=="")return"it is not one SVG: there is text outside it";r+=i[0].length;continue}if(o.startsWith("<!--")){let f=o.indexOf("-->",4);if(f<0)return"it has a comment that never ends";let g=o.slice(4,f);if(/^-?>/.test(g)||g.includes("--")||g.includes("<!")||g.endsWith("-"))return"it has a comment the page and the picture read differently";r+=f+3;continue}if(/^<!DOCTYPE/i.test(o)){let f=/^<!DOCTYPE\s+svg\b[^<>[\]]*>/i.exec(o);if(!f||e.length>0||t)return"it declares XML entities";r+=f[0].length;continue}let s=/^<\/([A-Za-z][A-Za-z0-9_.:-]*)\s*>/.exec(o);if(s){if(e.pop()!==s[1])return`it is not one SVG: </${s[1]}> closes what is not open`;e.length===0&&(t=!0),r+=s[0].length;continue}let a=/^<([A-Za-z][A-Za-z0-9_.:-]*)/.exec(o);if(!a)return"it is not one SVG: it has markup a picture cannot hold";let d=a[1],l=Wl[d.toLowerCase()];if(l)return l;if(t)return`it is not one SVG: <${d}> comes after it ends`;if(e.length===0&&d!=="svg")return"it is not one SVG";if(d.includes(":"))return`it has an element of another kind (<${d}>)`;if(!Bl.has(d))return`it has a <${d}> element, which a picture does not need`;let u=e[e.length-1];if(u&&Vl.has(u))return`it has an element inside a <${u}>, which the page reads as HTML`;let p=a[0].length;for(let f=id.exec(o.slice(p));f;f=id.exec(o.slice(p))){let g=Jl(d,f[1],f[2]??f[3]??"");if(g)return g;p+=f[0].length}let c=/^\s*(\/?)>/.exec(o.slice(p));if(!c)return/(?:^|[\s/"'])on[a-z]+\s*=/i.test(o.slice(p,p+400))?"it has an event handler (an on\u2026 attribute)":`it is not one SVG: <${d}>'s attributes are not each quoted and apart`;c[1]!=="/"?e.push(d):e.length===0&&(t=!0),r+=p+c[0].length}return e.length>0?`it is not one SVG: <${e[e.length-1]}> is never closed`:t?null:"it is not one SVG"}function cd(n){if(n){if(!sd(n)){if(/^\s*</.test(n))return;let e=/^\s*([a-z][a-z0-9+.-]*):/i.exec(n)?.[1]?.toLowerCase();return e===void 0||e==="http"||e==="https"||e==="data"&&/^\s*data:image\//i.test(n)?n:void 0}return dd(n)===null?`data:image/svg+xml,${encodeURIComponent(n.trim())}`:void 0}}var Nt;function Xl(){if(Nt===void 0)try{Nt=new RegExp("^\\p{RGI_Emoji}$","v")}catch{Nt=null}return Nt}function Ql(n){return/\p{Extended_Pictographic}|\p{Regional_Indicator}|⃣/u.test(n)}function yo(n){if(typeof n!="string"||n.trim()==="")return"it is empty; give one emoji, like \u{1F3E1}";let e=[...new Intl.Segmenter("en",{granularity:"grapheme"}).segment(n)].map(o=>o.segment),t=e.filter(Ql).length;if(t===0)return"it is not an emoji; give one emoji, like \u{1F3E1}";if(e.length>1)return t===e.length?`it is ${e.length} emoji, and a mark is one`:"it has other characters beside the emoji; give the emoji alone";let r=Xl();return r&&!r.test(n)?"it is not one of the standard emoji every emoji set draws":null}function bo(n){return typeof n=="object"&&n!==null&&typeof n.emoji=="string"?n.emoji:void 0}function ud(n){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text x="50" y="50" dy=".35em" font-size="88" text-anchor="middle">${n}</text></svg>`}function ef(n){let e=n?.favicon;if(typeof e=="object"&&e!==null){let t=bo(e);return t!==void 0&&yo(t)===null?`data:image/svg+xml,${encodeURIComponent(ud(t))}`:void 0}return cd(e)}function nf(n){if(n?.logo)return;let e=bo(n?.favicon);return e!==void 0&&yo(e)===null?e:void 0}var ld={"system-sans":'ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif',"system-serif":'ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, Cambria, "Times New Roman", serif',"system-mono":Ie.mono},tf=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","-apple-system","BlinkMacSystemFont"],fd=["Georgia","Times New Roman","Times","Iowan Old Style","Palatino","Palatino Linotype","Charter","Cambria","Baskerville","Optima","Helvetica","Helvetica Neue","Arial","Verdana","Segoe UI","Roboto","Avenir","Avenir Next","Gill Sans","Menlo","Monaco","Consolas","SF Mono","SFMono-Regular","Courier New"];var rf=n=>new Set(n.map(e=>e.toLowerCase()));function of(n){return rf([...tf,...fd]).has(n.toLowerCase())||n.toLowerCase().startsWith("ui-")}function sf(n){return ld[n]??n}function Fx(n){let e=Mt({accent:n,base:fn});return e.ok||!e.missing.every(t=>t.startsWith("warn"))?e:Mt({accent:n,base:fn,warn:{light:fn.light.bad,dark:fn.dark.bad}})}function af(n,e,t){if(t.rows===0)return;let r=Q(n,e.rows).toLowerCase(),o=Q(n,e.columns).toLowerCase(),i=e.rows===e.columns,s=i?`link ${r} to each other`:`link ${r} to ${o}`;if(t.columns===0)return`No ${o} yet: ${s}.`;if(t.cells>0||typeof e.link=="object"&&e.link!==null)return;let a=U(n.tryDefinition(e.rows),e.rows);return i?`No ${a} is linked to another yet: ${s}.`:`No ${a} is linked to ${Ze(U(n.tryDefinition(e.columns),e.columns))} yet: ${s}.`}var oe={connectors:{all:{route:"curve",visible:!0},byEdge:{}},captions:{visible:!0},grid:{visible:!0,size:64},lattice:{visible:!0,size:46},tags:{visible:!0},emphasis:{rest:.34,dim:.12},marks:{flag:"\u26A0"}};function df(n){return n?{connectors:{all:{...oe.connectors.all,...n.connectors?.all??{}},byEdge:{...oe.connectors.byEdge,...n.connectors?.byEdge??{}}},captions:{...oe.captions,...n.captions??{}},grid:{...oe.grid,...n.grid??{}},lattice:{...oe.lattice,...n.lattice??{}},tags:{...oe.tags,...n.tags??{}},emphasis:{...oe.emphasis,...n.emphasis??{}},marks:{...oe.marks,...n.marks??{}}}:oe}function cf(n,e){return{...n.connectors.all,...n.connectors.byEdge[e]??{}}}function uf(n){return[` --graview-kit-grid: ${n.grid.visible?1:0};`,` --graview-kit-grid-size: ${n.grid.size}px;`,` --graview-kit-lattice: ${n.lattice.visible?1:0};`,` --graview-kit-lattice-size: ${n.lattice.size}px;`,` --graview-kit-tags: ${n.tags.visible?"inline-flex":"none"};`,` --graview-kit-captions: ${n.captions.visible?"block":"none"};`,` --graview-kit-rest: ${n.emphasis.rest};`,` --graview-kit-dim: ${n.emphasis.dim};`,` --graview-kit-flag: "${n.marks.flag.replace(/"/g,"'")}";`].join(`
|
|
5
|
-
`)}function lf(n,e,t){let r=new Set([e]);for(let[o,i]of t.entries()){let s=n.edge(i);if(!s)return{ok:!1,at:o};let a=s.from,d=s.to==="*"?n.kinds:s.to,l=new Set;for(let u of r){if(a.includes(u))for(let p of d)l.add(p);if(s.to==="*"||d.includes(u))for(let p of a)l.add(p)}if(l.size===0)return{ok:!1,at:o};r=l}return{ok:!0,reached:r}}function ff(n){let e=n.name??"";return e&&n.onBehalfOfName?`${e}, for ${n.onBehalfOfName}`:e}function vo(n,e,t=2500){return n.held==="socket"?!0:n.until!==void 0?e<Date.parse(n.until):e-Date.parse(n.at)<t}function pf(n){return`${n.kind}:${n.id??""}:${n.session??""}`}function hf(n,e,t,r=2500,o){let i=new Map;for(let[s,a]of n)vo(a,t,r)&&i.set(s,a);for(let s of e){if(!vo(s,t,r)){i.delete(s.participant);continue}let a=i.get(s.participant);(!a||Date.parse(a.at)<=Date.parse(s.at))&&i.set(s.participant,s)}return o!==void 0&&i.delete(o),i}function gf(n,e){return!n||!e?n===e:n.participant===e.participant&&n.kind===e.kind&&n.name===e.name&&n.onBehalfOf===e.onBehalfOf&&n.onBehalfOfName===e.onBehalfOfName&&n.until===e.until&&n.held===e.held&&n.hue===e.hue&&n.stop===e.stop&&(n.over??null)===(e.over??null)&&(n.robot?.at??null)===(e.robot?.at??null)&&(n.robot?.mode??null)===(e.robot?.mode??null)}export{Ce as a,Wi as b,qi as c,uc as d,pr as e,kn as f,Sn as g,Z as h,Og as i,Eg as j,$n as k,Pg as l,zg as m,Mg as n,hr as o,Ng as p,Ge as q,Ke as r,Ig as s,jg as t,Tg as u,rs as v,os as w,ee as x,ot as y,Dg as z,Zg as A,I as B,Oc as C,Tt as D,De as E,Wn as F,mf as G,W as H,pd as I,hd as J,$o as K,Hn as L,gd as M,he as N,Dt as O,_o as P,Zt as Q,bd as R,vd as S,ie as T,xd as U,wd as V,kd as W,Sd as X,$d as Y,yn as Z,Oo as _,Rd as $,Lt as aa,D as ba,Ad as ca,C as da,Od as ea,Q as fa,Ed as ga,Pd as ha,Jn as ia,Ze as ja,U as ka,Ec as la,it as ma,yr as na,is as oa,ss as pa,Pc as qa,_n as ra,ds as sa,Fm as ta,at as ua,Qa as va,bx as wa,jc as xa,Dc as ya,ls as za,Zc as Aa,Km as Ba,Rn as Ca,Fc as Da,Cc as Ea,Um as Fa,Bm as Ga,Gc as Ha,ps as Ia,Al as Ja,dt as Ka,Kc as La,Be as Ma,On as Na,ct as Oa,qm as Pa,Ve as Qa,Ue as Ra,xs as Sa,Vc as Ta,En as Ua,Ae as Va,Xm as Wa,wr as Xa,ut as Ya,Wc as Za,P as _a,Mn as $a,M as ab,B as bb,Yc as cb,pt as db,gy as eb,Jc as fb,Xc as gb,El as hb,T as ib,V as jb,be as kb,ve as lb,_y as mb,Ps as nb,Je as ob,j as pb,Xe as qb,X as rb,ru as sb,xe as tb,Du as ub,Ur as vb,ga as wb,sn as xb,Eb as yb,Br as zb,ba as Ab,va as Bb,Vr as Cb,ke as Db,Gr as Eb,Ln as Fb,Ku as Gb,xa as Hb,Gy as Ib,Ky as Jb,Wr as Kb,qr as Lb,$a as Mb,Oa as Nb,Pe as Ob,ao as Pb,Pl as Qb,an as Rb,zr as Sb,Ks as Tb,su as Ub,du as Vb,Fl as Wb,ho as Xb,Ll as Yb,fn as Zb,Ie as _b,Gl as $b,Kl as ac,sd as bc,dd as cc,cd as dc,ef as ec,nf as fc,of as gc,sf as hc,Fx as ic,pl as jc,af as kc,df as lc,cf as mc,uf as nc,cu as oc,uu as pc,lu as qc,fu as rc,nn as sc,Dn as tc,le as uc,mt as vc,rn as wc,Zn as xc,Dr as yc,Fn as zc,pu as Ac,hu as Bc,lf as Cc,Qu as Dc,la as Ec,el as Fc,Ua as Gc,dn as Hc,no as Ic,ol as Jc,il as Kc,sl as Lc,Ba as Mc,ro as Nc,al as Oc,fe as Pc,Un as Qc,dl as Rc,cl as Sc,Va as Tc,ul as Uc,ll as Vc,Wa as Wc,At as Xc,hl as Yc,Ha as Zc,Ya as _c,gl as $c,ml as ad,yl as bd,bl as cd,Ja as dd,vl as ed,xl as fd,wl as gd,kl as hd,Sl as id,so as jd,$l as kd,_l as ld,ff as md,pf as nd,hf as od,gf as pd};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function w(e){let t=e+1;return t*t-g(t).length}function g(e){if(e<3)return[];if(e%2===1){let i=(e-1)/2;return[[i,i]]}let t=e/2-1,r=e/2;return[[t,t],[r,t],[t,r],[r,r]]}function p(e){let t=2166136261;for(let r=0;r<e.length;r++)t=Math.imul(t^e.charCodeAt(r),16777619);return(t>>>0)%1e3/1e3}function M(e,t){let r=e.side+1,i=new Set(g(r).map(([o,n])=>`${o},${n}`)),a=e.side/r,d=[];for(let o=0;o<r;o++)for(let n=0;n<r;n++)i.has(`${n},${o}`)||d.push([n,o]);d.sort((o,n)=>o[0]+o[1]-(n[0]+n[1])||o[0]-n[0]);let c=t.slice(0,d.length);return{buildings:c.map((o,n)=>{let[u,m]=d[n];return{id:o,col:e.col+(u+.5)*a,row:e.row+(m+.5)*a,footprint:a*.62,height:.55+p(o)*.7}}),rest:Math.max(0,t.length-c.length)}}var b={done:.12,waiting:.55,active:1.05};function k(e,t,r=[]){let i=e.side,a=i/Math.max(1,t.length),d=Math.max(1,...t.map(s=>s.length)),c=a;for(let s=1;a/s>=i/8-1e-9&&(c=a/s,!(s*Math.floor(i/c+1e-9)>=d));s++);let f=Math.max(1,Math.floor(a/c+1e-9)),o=Math.max(1,Math.floor(i/c+1e-9)),n=i/o,u=[],m=[];return t.forEach((s,l)=>{let h=s.slice(0,f*o);h.forEach((x,y)=>{u.push({id:x,lane:l,col:e.col+(y%o+.5)*n,row:e.row+l*a+(Math.floor(y/o)+.5)*c,footprint:Math.min(n,c)*.66,height:r[l]??b.waiting})}),s.length>h.length&&m.push({lane:l,count:s.length-h.length,col:e.col-.15,row:e.row+(l+.5)*a})}),u.sort((s,l)=>s.col+s.row-(l.col+l.row)||s.col-l.col),{blocks:u,rests:m}}export{w as a,p as b,M as c,b as d,k as e};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as c,b as d,c as e,d as f,e as g,f as h,g as i,h as j,i as k,j as l,k as m,l as n,m as o,n as p}from"./chunk.VTWFVPKD.js";import{a,b}from"./chunk.ZRQI5VJF.js";import"./chunk.33GN2NUT.js";import"./chunk.2VIGF4FO.js";import"./chunk.MWZK3HVG.js";import"./chunk.3D5T3XIE.js";import"./chunk.GR5Q4HTW.js";import"./chunk.QT4XGC5Z.js";import"./chunk.MQ7FNHXG.js";import"./chunk.WLPTY4BF.js";import"./chunk.AJZBJBMO.js";export{j as ARRANGE_NARROW,o as ArrangeBar,e as CHIP_FIELDS,d as MANY_AT_THE_FAR_END,c as TYPED_FROM,p as arrangementCaption,a as arrangementOf,i as chipOffers,m as directionWords,g as farCount,f as farCounts,l as inSentence,h as offeredFilters,n as preloadArrangeLists,k as sayCondition,b as withArrangement};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{da as y,ea as V}from"./chunk.MQ7FNHXG.js";import{Mc as u,Pc as m}from"./chunk.WLPTY4BF.js";import"./chunk.AJZBJBMO.js";var c=t=>[t,...u.filter(r=>r!==t)];function w(t,r){if(r.hidden.length===0&&r.removed.length===0)return t;let f=new Set(r.removed.filter(e=>!e.lens).map(e=>e.name)),o=new Set(r.hidden),s=e=>e?.name!==void 0&&(f.has(e.name)||o.has(e.name)),a=(e,i,d)=>[...t.registrations()].reverse().find(n=>n.kind===e&&n.cardinality===i&&n.fidelity===d&&!n.beside&&!n.hidden&&!s(n)),h=(e,i)=>{for(let d of c(i.fidelity)){let n=a(e,i.cardinality,d);if(n)return n}if(i.cardinality==="one")for(let d of c(i.fidelity)){let n=a(e,"many",d);if(n)return n}},l={...t,register(e,i,d,n){return t.register(e,i,d,n),l},lookup(e,i){return t.lookup(e,i)===void 0?void 0:a(e,i.cardinality,i.fidelity)?.view},places:()=>t.places().filter(e=>!(e.name!==void 0&&f.has(e.name))).map(e=>e.name!==void 0&&o.has(e.name)&&!e.hidden?{...e,hidden:!0}:e),resolve(e,i,d){let n=t.resolve(e,i,d);return!n||!s(n)||d!==void 0&&n.name!==void 0&&!f.has(n.name)&&n.title!==void 0&&m(n.title)===d?n:h(e,i)},all:()=>t.all().filter(e=>!(e.name!==void 0&&f.has(e.name)))};return y(t)&&V(l),l}function v(t,r,f){let o,s=()=>{let a=r.current();o&&a.hidden===o.hidden&&a.removed===o.removed||(o=a,f(w(t,a)))};return s(),r.onChange?.(s)??(()=>{})}export{w as tidyViews,v as watchTidied};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{d as Se,f as be}from"./chunk.Z3ZKYSPN.js";import{e as pt}from"./chunk.6ONRWFA6.js";import{a as ae,b as tt}from"./chunk.ROGYDMES.js";import{b as Pe,c as U,d as X,e as it,f as rt}from"./chunk.6IHXTT6Z.js";import{a as yt,d as wt,f as vt}from"./chunk.YXH3IWNR.js";import{a as ve,b as gt}from"./chunk.OEF3GPRM.js";import{a as Ce,b as ft}from"./chunk.BRHRAVU2.js";import{a as mt,b as ht}from"./chunk.ZRQI5VJF.js";import{h as ut}from"./chunk.33GN2NUT.js";import{d as ot,e as ie,f as J,g as ye,h as st,j as lt,k as re}from"./chunk.2EJAIT33.js";import{j as dt,o as we}from"./chunk.I3SQJ2L2.js";import{c as ct}from"./chunk.FUJM7GDV.js";import{c as at,d as Re}from"./chunk.3D5T3XIE.js";import{c as nt}from"./chunk.GR5Q4HTW.js";import{$ as V,A as Je,H as q,S as I,U as Ye,_ as Ze,a as ge,ba as ue,ia as Qe,ja as j,k as je,ka as pe,m as _e,ma as me,n as qe,oa as he,qa as et,s as ne,sa as xe,ta as fe,ua as Ne,w as Ue,z as Xe}from"./chunk.MQ7FNHXG.js";import{T as Q,Wb as te,ba as $,da as ee,fb as Ke,ka as H}from"./chunk.WLPTY4BF.js";import{b as E}from"./chunk.AJZBJBMO.js";var v=E(q(),1);var St=E(q(),1);function bt(e){(0,St.useLayoutEffect)(()=>{let n=e.current,t=n?.parentElement;if(!n||!t)return;let a=n.style.bottom,o=()=>{let g=t.querySelector(zt);if(!g){n.style.bottom=a;return}let u=t.getBoundingClientRect(),m=g.getBoundingClientRect(),c=u.height>0?t.offsetHeight/u.height:1;n.style.bottom=`${Math.max(0,Math.round((u.bottom-m.top)*c))}px`};if(o(),typeof ResizeObserver>"u")return;let l=new ResizeObserver(o);return l.observe(t),()=>l.disconnect()},[e])}var zt=".graview-spec-listing";var $e=E(q(),1);var P=E(q(),1);var kt=E(q(),1);var B=E(I(),1);function xt({id:e,max:n=8,empty:t,hide:a}){let{store:o}=V();ue();let l=Kt(o,e,o.violations()),[g,u]=(0,kt.useState)(()=>new Set),m=a?l.flatMap(c=>{let f=c.ids.filter(r=>!a.has(r));return f.length>0?[{...c,ids:f}]:[]}):l;return m.length===0?t&&l.length===0?(0,B.jsx)("p",{style:{margin:0,fontSize:"0.875rem",color:"var(--graview-ink-faint)"},children:t}):null:(0,B.jsx)("div",{"data-graview-primitive":"connections",style:{display:"flex",flexDirection:"column",gap:12},children:m.map(c=>{let f=g.has(c.key),r=c.ids.length>n,d=f?c.ids:c.ids.slice(0,n),y=c.ids.length-Math.min(n,c.ids.length),k=`graview-more-${e}-${c.key}`.replace(/[^A-Za-z0-9_-]/g,"-");return(0,B.jsxs)("section",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,B.jsx)("h2",{...c.said?{"aria-label":c.said}:{},style:{margin:0,fontSize:"0.75rem",fontWeight:600,letterSpacing:"0.09em",textTransform:"uppercase",color:"var(--graview-ink-faint)"},children:c.label}),(0,B.jsxs)("div",{id:k,style:{display:"flex",flexWrap:"wrap",gap:6},children:[d.map(h=>{let w=o.graph.getNode(h);return w?(0,B.jsx)(X,{pickId:h,hue:te(w.kind),title:`Go to the ${H(o.schema.tryDefinition(w.kind),w.kind)}`,label:$(o.schema.tryDefinition(w.kind),w)},h):null}),r?(0,B.jsx)("button",{type:"button","data-graview-more":c.key,"aria-expanded":f,"aria-controls":k,...f?{}:{"aria-label":`${y} more: ${c.said??c.label}`},onClick:h=>{h.stopPropagation(),u(w=>{let S=new Set(w);return S.has(c.key)?S.delete(c.key):S.add(c.key),S})},style:Ft,children:f?"Show fewer":`+${y} more`}):null]})]},c.key)})})}var Ft={display:"inline-flex",alignItems:"center",alignSelf:"flex-start",minHeight:24,boxSizing:"border-box",padding:"3px 9px",borderRadius:6,border:"1px solid var(--graview-edge)",background:"var(--graview-panel-muted)",color:"var(--graview-accent)",font:"inherit",fontSize:"0.8125rem",lineHeight:1.5,whiteSpace:"nowrap",cursor:"pointer"};function Kt(e,n,t=[]){let a=e.graph.getNode(n);if(!a)return[];let o=new Map,l=[];for(let g of t)if(g.subjectId===n)for(let u of g.nodeIds)u!==n&&!l.includes(u)&&e.graph.has(u)&&l.push(u);l.length>0&&o.set("judges",{key:"judges",label:"what it finds wrong",ids:l});for(let g of e.graph.allEdges()){let u=g.from===n?g.to:g.to===n?g.from:null;if(u===null||u===n)continue;let m=e.graph.getNode(u);if(!m)continue;let c=g.from===n?"out":"in",f=c==="out"?a.kind:m.kind,r=jt(e.schema,f,g.kind,c),d=`${g.kind}:${c}:${r.label}`,y=o.get(d)??{key:d,...r,ids:[]};y.ids.includes(u)||y.ids.push(u),o.set(d,y)}for(let g of o.values())g.ids.sort();return[...o.values()].sort((g,u)=>g.key<u.key?-1:g.key>u.key?1:0)}function jt(e,n,t,a){let o=nt(e,n,t,a),l=ee(t).toLowerCase();return o.trim().toLowerCase()!==l?{label:o}:a==="out"?{label:`\u2192 ${l}`,said:l}:{label:`\u2190 ${l}`,said:`${l}, pointing here`}}var Nt=E(q(),1),oe=(0,Nt.createContext)(null);var s=E(I(),1),_t=he(ge(()=>(__graviewPreload(import.meta.url,["./chunk.VTWFVPKD.js","./chunk.ZRQI5VJF.js","./chunk.33GN2NUT.js","./chunk.2VIGF4FO.js","./chunk.MWZK3HVG.js","./chunk.3D5T3XIE.js","./chunk.GR5Q4HTW.js","./chunk.QT4XGC5Z.js","./chunk.MQ7FNHXG.js","./chunk.WLPTY4BF.js","./chunk.AJZBJBMO.js"]),import("./chunk.XM3NPZLP.js")))).part((e,n)=>(0,s.jsx)(e.ArrangeBar,{...n}),{what:"Arranging this list"}),qt=he(ge(()=>(__graviewPreload(import.meta.url,["./chunk.AZCFXPEL.js","./chunk.W2HCJQVK.js","./chunk.4DEUD66C.js","./chunk.LHO7L3CS.js","./chunk.L73VUBXN.js","./chunk.YG423NEB.js","./chunk.VNBR4DHD.js","./chunk.Z3ZKYSPN.js","./chunk.6ONRWFA6.js","./chunk.HJCQ6I3S.js","./chunk.GZ3IXNA4.js","./chunk.FMVWXSQ7.js","./chunk.IM7LXLIB.js","./chunk.7RSZMIAL.js","./chunk.ROGYDMES.js","./chunk.6IHXTT6Z.js","./chunk.YXH3IWNR.js","./chunk.OEF3GPRM.js","./chunk.BRHRAVU2.js","./chunk.VTWFVPKD.js","./chunk.ZRQI5VJF.js","./chunk.33GN2NUT.js","./chunk.2VIGF4FO.js","./chunk.67WL7BGF.js","./chunk.G4JJXA63.js","./chunk.5MSO3KRO.js","./chunk.QYRPELLU.js","./chunk.FTJBW25J.js","./chunk.UT6642FC.js","./chunk.MCVY6RRS.js","./chunk.RZVZG2BQ.js","./chunk.Q5WEOX3Q.js","./chunk.XHWL7QBF.js","./chunk.6UCRL4OF.js","./chunk.V2NBJDAX.js","./chunk.WVUJXDXZ.js","./chunk.2EJAIT33.js","./chunk.EUGWV3S6.js","./chunk.6XJP7F3I.js","./chunk.NPX7SPXM.js","./chunk.OE4QOBJF.js","./chunk.74RMHUCX.js","./chunk.GZHZLJBF.js","./chunk.I3SQJ2L2.js","./chunk.OJGHDWI6.js","./chunk.FUJM7GDV.js","./chunk.MWZK3HVG.js","./chunk.3D5T3XIE.js","./chunk.GR5Q4HTW.js","./chunk.QT4XGC5Z.js","./chunk.MQ7FNHXG.js","./chunk.WLPTY4BF.js","./chunk.AJZBJBMO.js"]),import("./chunk.K5KEECHL.js")))).part((e,n)=>(0,s.jsx)(e.KindStop,{...n}),{what:"This list"});function Ae(e){let{brand:n}=V();return te(e,n?.accents)}function Ut(e,n){if(!n.endsWith("\u2026")&&!n.endsWith("..."))return;let t=n.replace(/[…]|\.\.\.$/g,"").trim();if(!(t.length<12)){for(let a of Object.values(e))if(typeof a=="string"&&a.length>t.length&&a.startsWith(t))return a}}function Xt(e,n){let a=Math.max(0,...e.slice(0,n*2).map(l=>l.length))*7.5+28<=212/2?2:1,o=n*a;return{columns:a,shown:Math.min(e.length,o)}}var Jt=8,Rt=500,Yt=12;function Ct(e){return{x:e.clientX,y:e.clientY,pointerType:e.pointerType??""}}function Zt(e,n,t){let a=performance.now()+Rt,o=["pointerdown","pointerup","mousedown","mouseup","dblclick"],l=r=>{if(performance.now()>a||!(r instanceof MouseEvent))return!1;let d=Ct(r);return n.pointerType&&d.pointerType&&n.pointerType!==d.pointerType?!1:Math.hypot(d.x-n.x,d.y-n.y)<=Yt},g=r=>{if(!l(r))return c();r.stopPropagation()},u=r=>{if(!l(r))return c();r.stopPropagation(),r.preventDefault(),e.removeEventListener("click",u,!0),setTimeout(c,50),t()},m=!1,c=()=>{if(!m){m=!0,clearTimeout(f),e.removeEventListener("click",u,!0);for(let r of o)e.removeEventListener(r,g,!0)}};for(let r of o)e.addEventListener(r,g,!0);e.addEventListener("click",u,!0);let f=setTimeout(c,Rt)}function Qt({View:e,members:n,mode:t,flagged:a}){let{isSelected:o}=xe(),l=n.slice(0,Jt);return(0,s.jsxs)("div",{"data-graview-rows":"",style:{display:"grid",gap:4,minWidth:0},children:[l.map(g=>(0,s.jsx)("div",{"data-graview-pick":g.id,style:{minWidth:0,cursor:"pointer"},children:(0,s.jsx)(e,{node:g,cardinality:"one",fidelity:"glyph",mode:t,selected:o(g.id),...a?.includes(g.id)?{flagged:[g.id]}:{}})},g.id)),n.length>l.length?(0,s.jsx)(X,{label:`+${n.length-l.length} more`}):null]})}var en=11/15,tn=he(ge(()=>(__graviewPreload(import.meta.url,["./chunk.MWZK3HVG.js","./chunk.3D5T3XIE.js","./chunk.GR5Q4HTW.js","./chunk.QT4XGC5Z.js","./chunk.MQ7FNHXG.js","./chunk.WLPTY4BF.js","./chunk.AJZBJBMO.js"]),import("./chunk.UF3L6FJO.js")))).part((e,n)=>(0,s.jsx)(e.StatesBar,{...n}),{quiet:!0});function nn({text:e,accent:n}){let t=(0,P.useRef)(null),a=(0,P.useRef)(null),[o,l]=(0,P.useState)(1),[g,u]=(0,P.useState)(!1),m=o<1?`${o}em`:void 0;return(0,P.useLayoutEffect)(()=>{let c=t.current,f=a.current;if(!c||!f)return;let r=()=>{let y=c.clientWidth,k=f.offsetWidth;if(y<=0||k<=0)return;let h=parseFloat(getComputedStyle(f).fontSize)/parseFloat(getComputedStyle(c).fontSize)||1,w=k/h,S=Math.max(en,Math.min(1,Math.floor(y/w*100)/100));l(x=>Math.abs(x-S)<.01?x:S),u(w*S>y+.5)};if(r(),typeof ResizeObserver>"u")return;let d=new ResizeObserver(r);return d.observe(c),()=>d.disconnect()},[e]),(0,s.jsx)("span",{ref:t,"data-graview-district-name":"",...o<1?{"data-graview-fitted":""}:{},...g?{title:e}:{},style:{display:"block",minWidth:0,fontSize:"0.9375rem",lineHeight:1.25,letterSpacing:"0.05em",textTransform:"uppercase",color:n?"var(--graview-accent)":"var(--graview-ink-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:(0,s.jsx)("span",{ref:a,style:{fontSize:m},children:e})})}function Pt(e,n){return!!e?.display?.page?.groups?.length||Re(n,e).some(t=>t.long)}function At(e,n=me(e)){for(let t of e.kinds){let a=e.tryDefinition(t),o=a?.plural??`${String(t)}s`,l=r=>{let d=r.node,y=fe(),k=(0,P.useContext)(oe);if(!d)return null;let h=k?.nodeId===d.id?k:null,w=$(a,d),S=r.mode==="fullscreen"?Ut(d,w)??w:w,x=Ke(y,[d.id]);return(0,s.jsxs)(U,{title:(0,s.jsx)(vt,{nodeId:d.id,children:h?.title??S}),...h?{}:{subtitle:a?.describe?at(a,d):a?.description??String(t)},selected:r.selected,...r.flagged?.includes(d.id)?{tone:"warning"}:{},fit:!0,children:[h?(0,s.jsx)(oe.Provider,{value:null,children:h.body}):null,(0,s.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:"22px 34px",alignItems:"flex-start"},children:[(0,s.jsx)("div",{style:{flex:Pt(a,d)?"1 1 100%":"1 1 0",minWidth:"min(200px, 100%)"},children:(0,s.jsx)(wt,{id:d.id,shown:[S,w,a?.description,h?.title],...h?{hide:[...h.fields]}:{}})}),(0,s.jsx)("div",{style:{flex:Pt(a,d)?"1 1 100%":"1.4 1 0",minWidth:"min(220px, 100%)"},children:(0,s.jsx)(xt,{id:d.id,empty:`Nothing is connected to this ${H(a,String(t))} yet.`,...h?{hide:h.records}:{}})})]}),x.length>0?(0,s.jsx)("p",{"data-graview-broken":"",style:{margin:"14px 0 0",paddingTop:12,borderTop:"1px solid var(--graview-edge)",fontSize:"0.875rem",color:"var(--graview-warn)"},children:x.map(b=>b.message).join(" \xB7 ")}):null]})},g=r=>{let d=r.node;if(!d)return null;let{store:y}=V(),k=a?.computed?lt(y.schema,y.graph,d):d,h=Re(k,a,{limit:3,said:[$(a,d)],glance:!0}),w=Ae(t),S=h.filter(N=>!N.long&&!N.markdown),x=h.find(N=>N.long||N.markdown),b=ot(d,a);return(0,s.jsxs)(U,{title:$(a,d),selected:r.selected,tone:r.flagged?.includes(d.id)?"warning":"muted",fit:!0,children:[b?(0,s.jsx)(ve,{as:"thumb",file:b,size:64,style:{marginBottom:6}}):null,(0,s.jsx)(it,{items:S.map(N=>({id:N.key,label:N.alone,hue:w})),max:3}),x?(0,s.jsx)("p",{"data-graview-excerpt":x.key,title:x.value,style:{margin:S.length>0?"6px 0 0":0,fontSize:"0.8125rem",lineHeight:1.35,color:"var(--graview-ink-muted)",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:x.value}):null]})},u=r=>{let d=r.node,y=Ae(t),k=we().marks.flag;if(!d)return null;let h=r.flagged?.includes(d.id)??!1;return(0,s.jsx)(X,{label:h?`${$(a,d)} ${k}`:$(a,d),hue:y,selected:r.selected,title:h?`${ee(H(a,String(t)))} \u2014 implicated in a problem`:ee(H(a,String(t)))})},m=r=>r.fidelity==="full"?(0,s.jsx)(P.Suspense,{fallback:(0,s.jsx)(c,{...r}),children:(0,s.jsx)(qt,{kind:String(t),members:r.nodes??[],...r.flagged?{flagged:r.flagged}:{},...r.label?{label:r.label}:{},...r.retired?{retired:r.retired}:{}})}):(0,s.jsx)(c,{...r}),c=r=>{let{brand:d,store:y,views:k}=V(),{view:h,go:w}=Ne(),S=r.nodes??[],x=k.lookup(String(t),{cardinality:"one",fidelity:"glyph"}),b=x!==void 0&&!pe(x)?x:void 0,N=mt(h),C=ut(S,N,{schema:e,graph:y.graph,flagged:new Set(r.flagged??[])}),L=R=>({id:R.id,label:$(e.tryDefinition(R.kind),R),hue:te(R.kind,d?.accents)}),W=r.fidelity==="full"&&S.length>1?(0,s.jsx)(P.Suspense,{fallback:null,children:(0,s.jsx)(_t,{schema:e,graph:y.graph,kind:String(t),arrangement:N,onChange:R=>w(ht(h,R)),kept:{shown:C.nodes.length,of:S.length},style:{marginBottom:8}})}):null,se=R=>R.some(A=>r.flagged?.includes(A.id)),le=fe(),Y=we().marks.flag,z=(R,A,de)=>b?(0,s.jsx)(U,{title:R,meta:(0,s.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[(0,s.jsx)(be,{kind:String(t),plural:o,problems:Se(le,A),flag:Y}),(0,s.jsx)("span",{title:`${Q(A.length)} ${A.length===1?H(a,String(t)):o.toLowerCase()}`,children:Q(A.length)})]}),tone:se(A)?"warning":"muted",children:(0,s.jsx)(Qt,{View:b,members:A,mode:r.mode,...r.flagged?{flagged:r.flagged}:{}})},de):(0,s.jsx)(rt,{label:R,count:A.length,flagged:se(A),items:A.map(L),problems:(0,s.jsx)(be,{kind:String(t),plural:o,problems:Se(le,A),flag:Y})},de);return C.grouped?(0,s.jsxs)("div",{style:{display:"grid",gap:8},"data-graview-grouped":N.group?.by,children:[W,C.groups.map(R=>z(`${r.label??o} \xB7 ${R.label}`,R.nodes,R.key||"-"))]}):(0,s.jsxs)("div",{style:{display:"grid",gap:4},children:[W,z(r.label??o,C.nodes)]})},f=r=>{let d=r.nodes??[],y=Xt(d.map(p=>$(a,p)),r.openedRows??dt(d.length)),k=Ae(t),{brand:h}=V(),w=tt(String(t),e,h),S=we().marks.flag,{selection:x,set:b,clear:N}=xe(),{toggle:C,view:L,go:W}=Ne(),{views:se,hiddenKinds:le}=V(),Y=(0,P.useContext)(Qe),z=L.overview&&!le.has(String(t))?se.places().filter(p=>p.kind===String(t)):[],R=r.focused?L.within?.view??z[0]?.as:void 0,A=d.filter(p=>r.flagged?.includes(p.id)).length,de=A>0,Ot=fe(),Ht=Se(Ot,d),F=(L.overview??!1)&&r.nestedUnder===void 0,G=r.focused||r.raised,He=r.rank==="secondary"&&!G,M=r.nestedUnder!==void 0,Ie=new Set(x),K=Y?x.length===1&&x[0]===ne(String(t)):r.opened??!1,It=ct(),O=G||F?0:d.filter(p=>It.includes(p.id)&&!Ie.has(p.id)).length,ke=O>0&&!de,ce=Ze(),_=ce&&!M?ce.byKind[String(t)]??0:0,We=(0,P.useRef)(null),ze=(0,P.useRef)(null);(0,P.useLayoutEffect)(()=>{let p=ze.current,D=We.current;if(!p||!D||!F)return;let T=()=>D.style.setProperty("--graview-plate-h",`${p.offsetHeight}px`);if(T(),typeof ResizeObserver>"u")return;let Z=new ResizeObserver(T);return Z.observe(p,{box:"border-box"}),()=>Z.disconnect()},[F]);let Wt=M?8:Math.min(46,10+Math.round(Math.sqrt(d.length)*8)),Fe=M?(0,s.jsx)("span",{style:{fontSize:"0.75rem",lineHeight:1.25,letterSpacing:"0.05em",textTransform:"uppercase",color:G?"var(--graview-accent)":"var(--graview-ink-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r.label??o}):(0,s.jsx)(nn,{text:r.label??o,accent:!!G});return(0,s.jsxs)("div",{ref:We,className:"graview-kind-card","data-graview-rank":r.rank,"data-graview-landmark":w||void 0,"data-graview-nested":M||void 0,"data-graview-tied":O||void 0,"data-graview-hits":ce&&!M?_:void 0,"data-graview-emphasis":ce&&!M?_>0?"lit":"dimmed":void 0,...a?.description||M?{title:M?[r.label??o,a?.description].filter(Boolean).join(" \u2014 "):a.description}:{},style:{position:"relative",height:"100%","--graview-hue":Math.round(k)},children:[w?(0,s.jsx)("span",{className:"graview-kind-block graview-kind-landmark","data-graview-opened":r.opened||void 0,"aria-hidden":"true",style:{"--graview-rise":Wt},children:(0,s.jsx)(ae,{kind:String(t),schema:e,...h?{brand:h}:{},size:96})}):null,(0,s.jsxs)("div",{ref:ze,className:"graview-kind-face","data-graview-opened":r.opened||void 0,"data-graview-nameplate":F?r.nameplate??"full":void 0,style:{display:"flex",flexDirection:"column",gap:M?1:3,padding:M?"5px 7px":"7px 10px",borderRadius:"var(--graview-radius-sm, 9px)",justifyContent:"center",position:"relative",height:"100%",overflow:"hidden",boxSizing:"border-box",border:G?"1px solid var(--graview-accent)":O>0?"1px solid var(--graview-accent-dim)":`1px solid hsl(${Math.round(k)} 55% var(--graview-tint-lightness) / 0.34)`,backgroundColor:"var(--graview-panel)",backgroundImage:`linear-gradient(hsl(${Math.round(k)} 55% var(--graview-tint-lightness) / calc(var(--graview-tint-alpha) * ${G?1.1:He?.28:.5})), hsl(${Math.round(k)} 55% var(--graview-tint-lightness) / calc(var(--graview-tint-alpha) * ${G?1.1:He?.28:.5})))`,boxShadow:G?"0 0 0 1px var(--graview-accent-dim)":void 0},children:[!M&&!F&&d.length>0?(0,s.jsx)("div",{"data-graview-tally":d.length,"data-graview-broken":A||void 0,"aria-hidden":"true",style:{position:"absolute",left:0,right:0,top:0,display:"flex",height:3,background:`hsl(${Math.round(k)} 55% var(--graview-tint-lightness) / 0.4)`},children:A>0?(0,s.jsx)("span",{style:{width:`${Math.max(6,Math.round(A/d.length*100))}%`,background:"var(--graview-warn)"}}):null}):null,w?(0,s.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:M?4:6},children:[(0,s.jsx)(ae,{kind:String(t),schema:e,...h?{brand:h}:{},size:M?14:18}),Fe]}):Fe,(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:5,fontSize:"0.875rem"},children:[(0,s.jsx)("span",{title:d.length>0?`${Q(d.length)} ${d.length===1?H(a,String(t)):o.toLowerCase()}`:void 0,style:{fontVariantNumeric:"tabular-nums",color:ke?"var(--graview-accent)":"var(--graview-ink-faint)"},children:d.length===0?"none yet":ke?O===d.length?`${O} tied`:`${O} of ${d.length} tied`:Q(d.length)}),(0,s.jsx)(be,{kind:String(t),plural:o,problems:Ht,flag:S,listed:K}),(r.retired??0)>0?(0,s.jsxs)("button",{type:"button",className:"graview-kind-past","data-graview-retired":r.retired,title:`${r.retired} retired ${o.toLowerCase()} \u2014 press to widen the view to the past`,onClick:p=>{p.stopPropagation(),W(pt(L,!0))},onDoubleClick:p=>p.stopPropagation(),onPointerDown:p=>p.stopPropagation(),children:["+",r.retired," past"]}):null,_>0?(0,s.jsxs)("button",{type:"button",className:"graview-kind-hits","data-testid":`hits-${String(t)}`,title:`${_} ${_===1?"match":"matches"} for \u201C${L.q??""}\u201D \u2014 press to go in, narrowed`,onClick:p=>{p.stopPropagation(),W(Xe(L,ne(String(t)),{ownPicture:!0,...L.q?{carry:L.q}:{}}))},onDoubleClick:p=>p.stopPropagation(),onPointerDown:p=>p.stopPropagation(),children:[_," match"]}):null,O>0&&!ke?(0,s.jsxs)("span",{style:{fontSize:"0.8125rem",color:"var(--graview-accent)"},children:[O," tied"]}):null,r.hasOwnView&&!F?(0,s.jsx)("span",{title:`${o} has a view of its own`,"aria-label":"has its own view",style:{fontSize:"0.6875rem",color:"var(--graview-accent)"},children:"\u25C6"}):null,!M&&d.length>0&&!r.focused?(0,s.jsxs)("button",{type:"button",className:"graview-kind-open","data-testid":`open-${String(t)}`,"aria-expanded":K,"aria-label":K?`Close up the ${o}`:`See the ${o} in here`,title:K?"Close it up":`See the ${o} in here`,onClick:p=>{p.stopPropagation(),Y?K?N():b([ne(String(t))]):C(ne(String(t)))},onDoubleClick:p=>p.stopPropagation(),onPointerDown:p=>p.stopPropagation(),children:[(0,s.jsx)("span",{className:"graview-kind-open-word",children:K?"close":"open"})," ",(0,s.jsx)("span",{"aria-hidden":"true",children:K?"\u25B4":"\u25BE"})]}):null]}),F&&r.states?(0,s.jsx)(P.Suspense,{fallback:null,children:(0,s.jsx)(tn,{states:r.states,definition:a})}):null,r.opened?(0,s.jsxs)("div",{className:"graview-kind-members","data-graview-buildings":r.plot?.side??1,style:{display:"grid",gridTemplateColumns:`repeat(${y.columns}, minmax(0, 1fr))`,gap:3},children:[d.slice(0,y.shown).map(p=>{let D=r.flagged?.includes(p.id)??!1,T=$(a,p);return(0,s.jsx)(X,{pickId:p.id,label:D?`${T} ${S}`:T,title:D?`${T} \u2014 implicated in a problem`:void 0,hue:k,selected:Ie.has(p.id)},p.id)}),d.length>y.shown?(0,s.jsxs)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",padding:"2px 4px",gridColumn:"1 / -1"},children:["+",d.length-y.shown," more \u2014 double-click to go in"]}):null]}):null]}),!M&&z.length>0?(0,s.jsx)("div",{className:"graview-drive-in","data-testid":`drive-in-${String(t)}`,"data-graview-showing":R,onPointerDown:p=>p.stopPropagation(),onDoubleClick:p=>p.stopPropagation(),children:(0,s.jsx)("div",{className:"graview-drive-in-marquee",role:"group","aria-label":`${o}: pictures`,"data-graview-thumbs":z.length===1?"one":"two",children:z.map(p=>{let D=R===p.as;return(0,s.jsxs)("div",{className:"graview-drive-in-thumb","data-graview-pressed":D||void 0,children:[(0,s.jsx)("span",{className:"graview-drive-in-thumb-title","aria-hidden":"true",children:p.title}),(0,s.jsx)("button",{type:"button",className:"graview-drive-in-thumb-press","data-testid":`showing-${p.as}`,"aria-label":`${o}: ${p.title}`,"aria-pressed":D,title:D?`${p.title} is showing \u2014 press again to open it`:`Show ${p.title} on the billboard \u2014 double-click to open it`,onClick:T=>{T.stopPropagation();let Z=()=>W(Je(L,String(t),p.as));if(T.detail>=2||D&&r.focused){Z();return}W(_e(je(qe(L,!0),Ue(String(t))),"view",p.as)),T.detail===1&&Zt(T.currentTarget.ownerDocument,Ct(T.nativeEvent),Z)}})]},p.as)})})}):null]})};m.generic=!0,f.generic=!0,n.register(t,{cardinality:"one",fidelity:"full"},j(l)).register(t,{cardinality:"one",fidelity:"summary"},j(g)).register(t,{cardinality:"one",fidelity:"glyph"},j(u)).register(t,{cardinality:"many",fidelity:"full"},j(m)).register(t,{cardinality:"many",fidelity:"summary"},j(m)).register(t,{cardinality:"many",fidelity:"glyph"},j(f))}return n}var Me=E(I(),1),$t=new WeakMap;function an(e){let n=$t.get(e);return n||$t.set(e,n=At(e,me(e))),n}var Ve=et;function Vt(){return(0,$e.useContext)(Ve)}function jn({children:e}){return(0,Me.jsx)(Ve.Provider,{value:!0,children:e})}function Mt(e){let n=(0,$e.useContext)(Ve),{store:t}=V();if(n)return null;let a=e.kind??e.node?.kind??e.nodes?.[0]?.kind;if(!a)return null;let o=an(t.schema).lookup(a,{cardinality:e.cardinality,fidelity:e.fidelity});return o?(0,Me.jsx)(o,{...e}):null}var i=E(I(),1),Tt=(0,v.createContext)(null),Et=(e,n)=>e.trim().toLowerCase().replace(/[_-]+/g," ")===n.trim().toLowerCase().replace(/[_-]+/g," "),rn=(0,v.createContext)(null),Be=(0,v.createContext)(null);function Lt({block:e}){let n=(0,v.useContext)(Be),t=n?.slots?.[e.key],a=(0,i.jsx)(on,{block:e});return t?(0,i.jsx)(v.Suspense,{fallback:a,children:(0,i.jsx)(t,{block:e,node:n.node,drawn:a})}):a}function on({block:e}){let n=(0,v.useContext)(Tt),t=(0,v.useContext)(ln),a=(0,v.useContext)(Te),o=(0,v.useContext)(Pe);if(n&&e.t==="badge"&&n.values.some(l=>Et(l,e.text))||n&&e.t==="field"&&n.field!==void 0&&e.field===n.field||e.t==="badge"&&/^0(?:\s+\p{L}+)?$/u.test(e.text.trim()))return null;switch(e.t){case"title":return(0,i.jsx)("strong",{className:"graview-spec-title",...o!==null&&Et(o,e.text)?{"aria-hidden":!0}:{},children:e.text});case"text":return e.markdown||Ce(e.text)?(0,i.jsx)("div",{className:"graview-spec-text",...e.tone?{"data-graview-tone":e.tone}:{},children:(0,i.jsx)(ft,{text:e.text,markdown:e.markdown})}):(0,i.jsx)("p",{className:"graview-spec-text",...e.tone?{"data-graview-tone":e.tone}:{},children:e.text});case"badge":return(0,i.jsx)("span",{className:"graview-spec-badge","data-graview-tone":e.tone,children:e.text});case"field":return(0,i.jsxs)("span",{className:"graview-spec-field","data-graview-field":e.field,children:[(0,i.jsx)("span",{className:"graview-spec-label",children:e.label}),(0,i.jsx)("span",{className:"graview-spec-value",...Ce(e.text)?{style:{whiteSpace:"pre-line"}}:{},children:e.linked?(0,i.jsx)(gt,{relation:e.linked.relation,refs:e.linked.refs,as:"chip"}):e.app?(0,i.jsx)(yt,{address:e.app}):e.href?(0,i.jsx)("a",{className:"graview-spec-link",href:e.href,...e.href.startsWith("tel:")?{}:{rel:"noopener noreferrer",target:"_blank"},children:e.text}):e.text})]});case"image":return(0,i.jsx)(ve,{as:"block",field:e.field,files:e.files,label:e.label,view:e.as});case"progress":return e.value===void 0||e.max===void 0?(0,i.jsxs)("span",{className:"graview-spec-progress",children:[(0,i.jsx)("span",{className:"graview-spec-label",children:e.label}),(0,i.jsx)("span",{className:"graview-spec-value",children:e.text})]}):(0,i.jsxs)("span",{className:"graview-spec-progress",children:[(0,i.jsx)("span",{className:"graview-spec-label",children:e.label}),(0,i.jsx)("span",{className:"graview-spec-track",role:"progressbar","aria-label":e.label,"aria-valuemin":0,"aria-valuemax":e.max,"aria-valuenow":Math.max(0,Math.min(e.value,e.max)),"aria-valuetext":e.text,children:(0,i.jsx)("span",{className:"graview-spec-fill",style:{width:`${Math.round(Math.max(0,Math.min(e.value,e.max))/e.max*100)}%`}})}),(0,i.jsx)("span",{className:"graview-spec-value",children:e.text})]});case"group":return(0,i.jsx)("span",{className:"graview-spec-group","data-direction":e.direction,children:(0,i.jsx)(Ee,{blocks:e.blocks})});case"when":return e.shown?(0,i.jsx)(Ee,{blocks:e.blocks}):null;case"divider":return(0,i.jsx)("hr",{className:"graview-spec-divider"});case"figure":return(0,i.jsx)(sn,{});case"headline":{let l=`h${Math.min(6,e.level+t)}`,g=(0,i.jsx)(l,{className:"graview-spec-headline","data-level":e.level,children:e.text});return a!==null&&e.level===1?(0,i.jsxs)(i.Fragment,{children:[g,a]}):g}case"number":return(0,i.jsxs)("span",{className:"graview-spec-number",...e.emphasis?{"data-emphasis":e.emphasis}:{},children:[(0,i.jsx)("span",{className:"graview-spec-number-value",children:e.text}),e.label?(0,i.jsx)("span",{className:"graview-spec-label",children:e.label}):null]});case"list":return(0,i.jsx)(cn,{list:e})}}function sn(){let e=(0,v.useContext)(Be)?.figure;return e?(0,i.jsx)("span",{className:"graview-spec-figure","aria-hidden":"true",children:e()}):null}function Ee({blocks:e}){let n=[];for(let t=0;t<e.length;t++){let a=t;for(;e[a]?.t==="badge"&&e[a+1]?.t==="badge";)a++;if(a===t){n.push((0,i.jsx)(Lt,{block:e[t]},t));continue}n.push((0,i.jsx)("span",{className:"graview-spec-badges",children:e.slice(t,a+1).map((o,l)=>(0,i.jsx)(Lt,{block:o},l))},t)),t=a}return n}function Dt({blocks:e,ctx:n,view:t}){let a=(0,v.useContext)(rn)?.[t];return(0,i.jsx)(Be.Provider,{value:{figure:n.figure,slots:a,node:n.node},children:(0,i.jsx)(Ee,{blocks:e})})}function Ge({blocks:e,ctx:n,view:t}){return(0,i.jsx)(Dt,{blocks:J(e,n),ctx:n,view:t})}var Le=3,Bt=(0,v.createContext)(0),Gt=(0,v.createContext)(null),ln=(0,v.createContext)(0),Te=(0,v.createContext)(null);function dn({node:e,as:n,depth:t,said:a=null}){let{store:o,views:l}=V(),g=$(o.schema.tryDefinition(e.kind),e),u=l.lookup(e.kind,{cardinality:"one",fidelity:n==="card"?"summary":"glyph"});return n==="row"&&t<=Le&&(!u||pe(u))?(0,i.jsxs)("li",{className:"graview-spec-item","data-graview-listed":e.id,"data-as":n,children:[(0,i.jsx)(De,{node:e,label:g}),(0,i.jsx)("div",{className:"graview-spec graview-spec-row","data-graview-spec":"row","data-graview-kind":e.kind,"aria-hidden":"true",children:(0,i.jsx)("strong",{className:"graview-spec-title",children:g})})]}):(0,i.jsxs)("li",{className:"graview-spec-item","data-graview-listed":e.id,"data-as":n,children:[(0,i.jsx)(De,{node:e,label:g}),t<=Le&&u?(0,i.jsx)(Ye,{mode:"scene",children:(0,i.jsx)(Bt.Provider,{value:t,children:(0,i.jsx)(Tt.Provider,{value:a,children:(0,i.jsx)(Pe.Provider,{value:g,children:(0,i.jsx)(u,{node:e,cardinality:"one",fidelity:n==="card"?"summary":"glyph",mode:"scene",selected:!1})})})})}):(0,i.jsx)("span",{className:"graview-spec-item-name","aria-hidden":"true",children:g})]})}function De({node:e,label:n,describedBy:t}){let a=(0,v.useContext)(Gt),o=(0,v.useRef)(null);return bt(o),a?(0,i.jsx)("a",{ref:o,className:"graview-spec-item-link",href:a.href(e),"aria-label":n,...t?{"aria-describedby":t}:{},onClick:l=>{l.metaKey||l.ctrlKey||l.shiftKey||l.button!==0||(l.preventDefault(),l.stopPropagation(),a.go(e))}}):(0,i.jsx)("button",{ref:o,type:"button",className:"graview-spec-item-link","data-graview-pick":e.id,"aria-label":n,...t?{"aria-describedby":t}:{}})}function cn({list:e}){let n=(0,v.useContext)(Bt)+1,{store:t}=V(),a=(0,v.useContext)(Gt),[o,l]=(0,v.useState)(e.members.length);if(e.failed)return(0,i.jsx)("p",{className:"graview-spec-text",children:"\u2014"});if(e.members.length===0)return e.empty?(0,i.jsx)("p",{className:"graview-spec-text graview-spec-empty",children:e.empty}):null;let g=(b,N=null)=>n>Le?(0,i.jsx)("ul",{className:"graview-spec-list","data-as":"names",children:b.map(C=>(0,i.jsxs)("li",{className:"graview-spec-item","data-graview-listed":C.id,"data-as":"name",children:[(0,i.jsx)(De,{node:C,label:$(t.schema.tryDefinition(C.kind),C)}),(0,i.jsx)("span",{className:"graview-spec-item-name","aria-hidden":"true",children:$(t.schema.tryDefinition(C.kind),C)})]},C.id))}):(0,i.jsx)("ul",{className:"graview-spec-list","data-as":e.as,children:b.map(C=>(0,i.jsx)(dn,{node:C,as:e.as,depth:n,said:N},C.id))}),u=e.rest??[],m=Math.min(o,e.members.length+u.length),c=m>e.members.length?[...e.members,...u].slice(0,m):e.members,f=e.members.length+u.length-m,r=Math.max(1,e.members.length),d=f>0?(0,i.jsx)("p",{className:"graview-spec-text graview-spec-more",children:(0,i.jsx)("button",{type:"button",className:"graview-spec-show-more","data-graview-show-more":f,onClick:()=>l(m+r),children:`Show ${Math.min(r,f)} more`})}):null,y=e.total??e.members.length+e.more,k=e.more-u.length,h=d??(a?.more&&y>c.length?a.more({members:c,total:y}):k>0?(0,i.jsx)("p",{className:"graview-spec-text graview-spec-more",children:`and ${k} more`}):null);if(!e.groups)return(0,i.jsxs)("div",{className:"graview-spec-listing",children:[g(c),h]});let w=`h${e.headingLevel}`,S=m,x=m>e.members.length&&e.everyGroup?e.everyGroup.flatMap(b=>{if(S<=0)return[];let N=b.members.slice(0,S);return S-=N.length,[{...b,members:N}]}):e.groups;return(0,i.jsxs)("div",{className:"graview-spec-listing",children:[x.map(b=>(0,i.jsxs)("section",{className:"graview-spec-list-group","data-graview-group":b.value??"",children:[b.heading?(0,i.jsx)(w,{className:"graview-spec-list-heading",children:b.heading}):null,g(b.members,b.value!==null?{values:[b.value,...b.heading?[b.heading]:[]]}:null)]},b.value??"")),h]})}function sa({blocks:e,heading:n=2,firstHeading:t,slot:a,view:o=a}){let{store:l,brand:g}=V();ue();let u=re(l,null,null,{heading:n,firstHeading:t,money:g}),m=(0,v.useContext)(Te),c=e.some(f=>f.t==="headline");return(0,i.jsxs)("div",{className:`graview-spec graview-spec-${a}`,"data-graview-spec":a,children:[m!==null&&!c?m:null,(0,i.jsx)(Te.Provider,{value:c?m:null,children:(0,i.jsx)(Ge,{blocks:e,ctx:u,view:o})})]})}function Oe(e,n="card"){let{store:t,brand:a}=V(),o=t.schema;return{...re(t,null,e,{slot:n,money:a}),figure:()=>(0,i.jsx)(ae,{kind:e.kind,schema:o,...a?{brand:a}:{},size:22})}}function gn({slot:e,blocks:n,node:t,selected:a}){let o=Oe(t,e);return(0,i.jsx)("div",{className:`graview-spec graview-spec-${e}`,"data-graview-spec":e,"data-graview-kind":t.kind,...e==="row"&&n.some(st)?{"data-graview-tall":""}:{},...a?{"data-selected":""}:{},children:(0,i.jsx)(Ge,{blocks:n,ctx:o,view:`${t.kind}.${e}`})})}function un({blocks:e,node:n,selected:t,flagged:a}){let o=Oe(n),[l,...g]=e,u=l?.t==="title";return(0,i.jsx)(U,{...u?{title:J([l],o)[0].text}:{},selected:t,tone:a?"warning":"muted",fit:!0,children:(0,i.jsx)("div",{className:"graview-spec graview-spec-card","data-graview-spec":"card","data-graview-kind":n.kind,children:(0,i.jsx)(Ge,{blocks:u?g:e,ctx:o,view:`${n.kind}.card`})})})}function pn({blocks:e,props:n}){let t=n.node,a=Oe(t,"page"),o=Vt(),l=J(e,a),g=ye(e,l),u=g.title!==void 0&&(!o||g.title===$(a.schema?.tryDefinition(t.kind),t)),m=(0,i.jsx)("div",{className:"graview-spec graview-spec-page","data-graview-spec":"page","data-graview-kind":t.kind,children:(0,i.jsx)(Dt,{blocks:u?l.slice(1):l,ctx:a,view:`${t.kind}.page`})});return o?m:(0,i.jsx)(oe.Provider,{value:{nodeId:t.id,...g.title!==void 0?{title:g.title}:{},body:m,fields:g.fields,records:g.records},children:(0,i.jsx)(Mt,{...n})})}function la(e,n,t){return typeof e=="function"?e.says?.(n,t):void 0}function mn({blocks:e,node:n,selected:t}){let{store:a}=V();return(0,i.jsx)("div",{title:$(a.schema.tryDefinition(n.kind),n),style:{minWidth:0,maxWidth:"100%"},children:(0,i.jsx)(gn,{slot:"row",blocks:e,node:n,selected:t})})}function da(e,n,t){if(!t)return e;let a=new Set(n.kinds);for(let[o,l]of Object.entries(t)){if(!a.has(o)||!l)continue;let g=o;if(l.card){let u=ie(l.card),m=c=>c.node?(0,i.jsx)(un,{blocks:u,node:c.node,selected:c.selected,flagged:c.flagged?.includes(c.node.id)??!1}):null;e.register(g,{cardinality:"one",fidelity:"summary"},m)}if(l.row){let u=ie(l.row),m=c=>c.node?(0,i.jsx)(mn,{blocks:u,node:c.node,selected:c.selected}):null;m.says=(c,f)=>ye(u,J(u,re({graph:f,schema:n},null,c,{slot:"row"}))),e.register(g,{cardinality:"one",fidelity:"glyph"},m)}if(l.page){let u=ie(l.page),m=c=>c.node?(0,i.jsx)(pn,{blocks:u,props:c}):null;m.says=(c,f)=>ye(u,J(u,re({graph:f,schema:n},null,c))),e.register(g,{cardinality:"one",fidelity:"full"},m)}}return e}export{bt as a,jn as b,Tt as c,Gt as d,ln as e,Te as f,De as g,sa as h,la as i,da as j,At as k};
|