graview 0.1.59 → 0.1.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/preview/chunk.2K4TT2BV.js +1 -0
- package/dist/preview/{chunk.J4HTSXUA.js → chunk.2USDHXB4.js} +1 -1
- package/dist/preview/{chunk.LHJWII6C.js → chunk.37TVS7CA.js} +1 -1
- package/dist/preview/chunk.3IZ3ABII.js +1 -0
- package/dist/preview/{chunk.E22DDEQI.js → chunk.3MOJF7BA.js} +1 -1
- package/dist/preview/{chunk.2XTCDFWU.js → chunk.3UOKUF5Z.js} +1 -1
- package/dist/preview/{chunk.MOAUE3N2.js → chunk.3V4WP7RY.js} +3 -3
- package/dist/preview/{chunk.IZ2ZTNEV.js → chunk.3XGA65Y3.js} +1 -1
- package/dist/preview/{chunk.TCPTVTFU.js → chunk.3ZT5WQYL.js} +1 -1
- package/dist/preview/{chunk.DWHPZBPZ.js → chunk.4LR64TPU.js} +1 -1
- package/dist/preview/{chunk.VNJKGSGZ.js → chunk.4MP72LPR.js} +1 -1
- package/dist/preview/{chunk.IPPZEGBX.js → chunk.4TCKEG6I.js} +1 -1
- package/dist/preview/{chunk.EZ3CRUBU.js → chunk.5DD62IOW.js} +2 -2
- package/dist/preview/{chunk.DGM3Y2FB.js → chunk.5YOLUDVO.js} +1 -1
- package/dist/preview/{chunk.VFRURRNI.js → chunk.67U6M7OV.js} +1 -1
- package/dist/preview/{chunk.2NJDT47T.js → chunk.6C2MHWSX.js} +1 -1
- package/dist/preview/{chunk.CYUMQPMH.js → chunk.6HF6POIX.js} +1 -1
- package/dist/preview/{chunk.KOGUYWHG.js → chunk.6WHAWOO7.js} +1 -1
- package/dist/preview/{chunk.N4LOI3YA.js → chunk.6ZQAR5ZA.js} +1 -1
- package/dist/preview/{chunk.2QESVWUW.js → chunk.7MHCGVGM.js} +1 -1
- package/dist/preview/{chunk.VNBEAF62.js → chunk.7N32AVIJ.js} +1 -1
- package/dist/preview/{chunk.CIB65YO6.js → chunk.7OPM55I2.js} +1 -1
- package/dist/preview/chunk.7TFLRR7D.js +1 -0
- package/dist/preview/{chunk.Q6LLURRM.js → chunk.7VKSXGTX.js} +1 -1
- package/dist/preview/{chunk.CLR6KAA3.js → chunk.A3ZXDG6V.js} +1 -1
- package/dist/preview/{chunk.2FOIJ5ID.js → chunk.A5PDXNY6.js} +1 -1
- package/dist/preview/{chunk.6O3YPUW3.js → chunk.AVBTPSQF.js} +1 -1
- package/dist/preview/{chunk.ZT3NEAFI.js → chunk.BF6S5UE4.js} +1 -1
- package/dist/preview/chunk.BLPYNNR4.js +1 -0
- package/dist/preview/{chunk.BDBLGGFJ.js → chunk.BQIHNT7C.js} +1 -1
- package/dist/preview/{chunk.B5HLA45D.js → chunk.BRT27WON.js} +1 -1
- package/dist/preview/{chunk.DO45KXLM.js → chunk.BXDM3UMN.js} +1 -1
- package/dist/preview/chunk.BYKD5RLA.js +1 -0
- package/dist/preview/chunk.C7OLSEWK.js +1 -0
- package/dist/preview/{chunk.WGTBQHHE.js → chunk.CC5BJH5A.js} +1 -1
- package/dist/preview/{chunk.HF5SNUTK.js → chunk.CFKZXLXS.js} +1 -1
- package/dist/preview/chunk.CMN6BBAD.js +1 -0
- package/dist/preview/{chunk.Z4CJJ4QP.js → chunk.CQT3W2SF.js} +1 -1
- package/dist/preview/{chunk.NOLGJFA4.js → chunk.D7YSL3NK.js} +2 -2
- package/dist/preview/{chunk.G2TCFWYX.js → chunk.DCHQHKSA.js} +1 -1
- package/dist/preview/{chunk.UFTAGUTU.js → chunk.EL5ICOOM.js} +1 -1
- package/dist/preview/{chunk.OVSZXILB.js → chunk.ENL2JJ47.js} +1 -1
- package/dist/preview/chunk.EQXB7LKI.js +1 -0
- package/dist/preview/{chunk.KE6ZRUMP.js → chunk.ERFT54HT.js} +1 -1
- package/dist/preview/{chunk.P6CHNBRR.js → chunk.F6V7RWDK.js} +1 -1
- package/dist/preview/{chunk.GDUM2UOM.js → chunk.FBJARKDT.js} +1 -1
- package/dist/preview/{chunk.QL555VQ2.js → chunk.FC6AF6CC.js} +1 -1
- package/dist/preview/{chunk.HVUUJQRE.js → chunk.FFTYMBBT.js} +1 -1
- package/dist/preview/chunk.FLUK3UXF.js +1 -0
- package/dist/preview/{chunk.UM5H2VVR.js → chunk.FRYBMS3W.js} +1 -1
- package/dist/preview/chunk.G3R4BTI7.js +1 -0
- package/dist/preview/{chunk.GQHFLOTZ.js → chunk.G4YJPKRG.js} +2 -2
- package/dist/preview/{chunk.MHILFBK6.js → chunk.GLWSVSQL.js} +1 -1
- package/dist/preview/{chunk.WTUB7W2D.js → chunk.GNBIVVL3.js} +1 -1
- package/dist/preview/{chunk.SU6WKQ73.js → chunk.GTKJJYQH.js} +1 -1
- package/dist/preview/{chunk.VS25R6R2.js → chunk.H45Q3O4F.js} +1 -1
- package/dist/preview/{chunk.6N7LNTB6.js → chunk.HDP3PS7N.js} +1 -1
- package/dist/preview/{chunk.QLTHHWBA.js → chunk.HDUO2USQ.js} +1 -1
- package/dist/preview/{chunk.2MFXP3FB.js → chunk.HUJ6YTWE.js} +1 -1
- package/dist/preview/{chunk.2FP4KEEG.js → chunk.I4XQBQRC.js} +1 -1
- package/dist/preview/chunk.IBOKXVWN.js +1 -0
- package/dist/preview/{chunk.4T5QIZKB.js → chunk.IGJZ4UH3.js} +2 -2
- package/dist/preview/{chunk.4QWTSI7V.js → chunk.IGVASEZU.js} +1 -1
- package/dist/preview/{chunk.CZH27V2R.js → chunk.IHBUBZQT.js} +1 -1
- package/dist/preview/chunk.IOK4GVJC.js +1 -0
- package/dist/preview/{chunk.ZUKYMU6C.js → chunk.JEYQBH33.js} +1 -1
- package/dist/preview/{chunk.S6VON4LU.js → chunk.JJGCTGWA.js} +1 -1
- package/dist/preview/{chunk.LKE2FBXL.js → chunk.JPONLMU7.js} +1 -1
- package/dist/preview/{chunk.Q3Y5EV5A.js → chunk.KBVTLNS5.js} +3 -3
- package/dist/preview/{chunk.YMRVKG6W.js → chunk.KDRLUBVF.js} +1 -1
- package/dist/preview/{chunk.YGZCESXY.js → chunk.KGW75Z5L.js} +1 -1
- package/dist/preview/{chunk.R4YDAJRL.js → chunk.KI37ZEV3.js} +1 -1
- package/dist/preview/chunk.L6AWE76F.js +1 -0
- package/dist/preview/{chunk.NIFQDN6R.js → chunk.LGEA5257.js} +1 -1
- package/dist/preview/{chunk.KKQXGN5U.js → chunk.LLYRFVIN.js} +1 -1
- package/dist/preview/{chunk.WEGPDJTB.js → chunk.LQVAABPS.js} +1 -1
- package/dist/preview/{chunk.4OMOP77U.js → chunk.LSY256J4.js} +1 -1
- package/dist/preview/{chunk.OLW44AP5.js → chunk.LZIBQ3VX.js} +1 -1
- package/dist/preview/{chunk.W2VOD6SD.js → chunk.M4UD4ARP.js} +1 -1
- package/dist/preview/chunk.MDJWK5W2.js +1 -0
- package/dist/preview/{chunk.QT6UV7HN.js → chunk.MJVYWLQQ.js} +1 -1
- package/dist/preview/{chunk.NSGQXCH6.js → chunk.MSWWWLEA.js} +1 -1
- package/dist/preview/{chunk.XOTES3PI.js → chunk.MVWC3VR3.js} +2 -2
- package/dist/preview/{chunk.V6EEDYYW.js → chunk.NC7FXY2H.js} +1 -1
- package/dist/preview/{chunk.MRYN42EQ.js → chunk.NGTRL5U4.js} +1 -1
- package/dist/preview/{chunk.ZLMI2NHC.js → chunk.NHUQ2N6J.js} +1 -1
- package/dist/preview/{chunk.LDYOQCY7.js → chunk.OLFJH4RK.js} +1 -1
- package/dist/preview/{chunk.3UTRR5YM.js → chunk.P6RORYOT.js} +1 -1
- package/dist/preview/{chunk.T227XQIO.js → chunk.PFSYXD6Q.js} +1 -1
- package/dist/preview/chunk.PHJ6WPWH.js +1 -0
- package/dist/preview/{chunk.HKINU7VO.js → chunk.PI44XMY2.js} +1 -1
- package/dist/preview/{chunk.P3CUCDHO.js → chunk.PNW5K7BW.js} +1 -1
- package/dist/preview/{chunk.6VNKGTLF.js → chunk.QBLKTFF4.js} +1 -1
- package/dist/preview/{chunk.ATVPAYS6.js → chunk.QDSEVPF3.js} +1 -1
- package/dist/preview/chunk.QFUMFQJU.js +1 -0
- package/dist/preview/{chunk.JPNBQFJ3.js → chunk.QHDCTAD7.js} +1 -1
- package/dist/preview/{chunk.P52UTBNO.js → chunk.QI4SLPQ4.js} +2 -2
- package/dist/preview/{chunk.ATSKKTUO.js → chunk.RQOX5YDW.js} +1 -1
- package/dist/preview/{chunk.VDGMFX5C.js → chunk.RXYNW5QB.js} +1 -1
- package/dist/preview/{chunk.ROHSF4WM.js → chunk.SB2PZKN5.js} +1 -1
- package/dist/preview/{chunk.3XIIJHQ6.js → chunk.SRVQJZRT.js} +1 -1
- package/dist/preview/{chunk.BPC4XQFZ.js → chunk.T7LQD67N.js} +2 -2
- package/dist/preview/{chunk.D3AISGQH.js → chunk.TAT2IQUR.js} +1 -1
- package/dist/preview/{chunk.E2REVMAG.js → chunk.TFWIG6LL.js} +1 -1
- package/dist/preview/{chunk.U5PX2ECA.js → chunk.TKVLNBRD.js} +1 -1
- package/dist/preview/{chunk.KSVJHSRH.js → chunk.TLJOZSDD.js} +1 -1
- package/dist/preview/{chunk.VGHZQEHS.js → chunk.TLWT67ON.js} +1 -1
- package/dist/preview/{chunk.AXXYJCSW.js → chunk.TY4GQJKC.js} +1 -1
- package/dist/preview/{chunk.SZG6HJWH.js → chunk.UITT6JWW.js} +1 -1
- package/dist/preview/{chunk.UHUBQ4EX.js → chunk.UJTE7UAP.js} +1 -1
- package/dist/preview/{chunk.GR2B7SKI.js → chunk.ULL6ZIJJ.js} +1 -1
- package/dist/preview/{chunk.HJOVOA52.js → chunk.UQWTZJBV.js} +1 -1
- package/dist/preview/{chunk.7JOG6XFC.js → chunk.URWAFZHF.js} +1 -1
- package/dist/preview/{chunk.BFN6B4C4.js → chunk.VADQ7ZGA.js} +1 -1
- package/dist/preview/chunk.VDMDPZ6U.js +1 -0
- package/dist/preview/{chunk.ZFH4SCCF.js → chunk.VFOON3Z3.js} +1 -1
- package/dist/preview/{chunk.QXMQUIQZ.js → chunk.VMV464JK.js} +1 -1
- package/dist/preview/{chunk.CUJX3IVA.js → chunk.VNDKKTED.js} +1 -1
- package/dist/preview/chunk.VSCIXAHN.js +5 -0
- package/dist/preview/{chunk.IIESMHXY.js → chunk.VUBNBTJP.js} +2 -2
- package/dist/preview/{chunk.MZJ3KTEU.js → chunk.VWJGQDCE.js} +1 -1
- package/dist/preview/{chunk.UITZ74YJ.js → chunk.VZJWJ5XM.js} +1 -1
- package/dist/preview/{chunk.RKZ4J3H2.js → chunk.W3W54DSX.js} +1 -1
- package/dist/preview/{chunk.6IUEGPCZ.js → chunk.WC3DENU4.js} +2 -2
- package/dist/preview/chunk.WQ6RCEUQ.js +1 -0
- package/dist/preview/{chunk.QC4YXFF7.js → chunk.WXUFATY5.js} +1 -1
- package/dist/preview/{chunk.QHU3KUZZ.js → chunk.X6A4VSSD.js} +1 -1
- package/dist/preview/{chunk.U7G56KXT.js → chunk.XGASJAV2.js} +1 -1
- package/dist/preview/{chunk.M3JIIF32.js → chunk.XR6YR6RV.js} +1 -1
- package/dist/preview/chunk.XZPKBHJT.js +1 -0
- package/dist/preview/{chunk.S7ZLGODY.js → chunk.Y5C4RXG7.js} +1 -1
- package/dist/preview/{chunk.L3K25NCS.js → chunk.Y7G3OGDE.js} +1 -1
- package/dist/preview/{chunk.E4SYOBGB.js → chunk.YEBGI6ED.js} +1 -1
- package/dist/preview/{chunk.G7HIAUEA.js → chunk.YFSBVZTG.js} +1 -1
- package/dist/preview/chunk.YFVJUHAK.js +1 -0
- package/dist/preview/{chunk.7XSDXX5Z.js → chunk.YH63KQ2G.js} +1 -1
- package/dist/preview/{chunk.F6P3WSMW.js → chunk.YZ7FUKAL.js} +1 -1
- package/dist/preview/{chunk.7AMBLGVB.js → chunk.Z2ERZ4S6.js} +1 -1
- package/dist/preview/{chunk.X2G4ZRB2.js → chunk.ZP5RT2EK.js} +1 -1
- package/dist/preview/{chunk.PS5SEND3.js → chunk.ZXOT3IXJ.js} +1 -1
- package/dist/preview/{chunk.EGJUFZD5.js → chunk.ZYM2SSGW.js} +1 -1
- package/dist/preview/index.html +50 -50
- package/dist/preview/page.js +2 -2
- package/package.json +6 -6
- package/dist/preview/chunk.3XLOFZRM.js +0 -1
- package/dist/preview/chunk.6BLNFVB4.js +0 -1
- package/dist/preview/chunk.6E36I2GC.js +0 -1
- package/dist/preview/chunk.CJUIJ6TL.js +0 -1
- package/dist/preview/chunk.FJTVY6AE.js +0 -1
- package/dist/preview/chunk.KHZA5F7A.js +0 -1
- package/dist/preview/chunk.LDLTQNJ2.js +0 -1
- package/dist/preview/chunk.MMWLLWFS.js +0 -1
- package/dist/preview/chunk.PCVPH5KM.js +0 -1
- package/dist/preview/chunk.QDZAITMN.js +0 -1
- package/dist/preview/chunk.U37WZMUO.js +0 -1
- package/dist/preview/chunk.U5JFW2YM.js +0 -1
- package/dist/preview/chunk.V5MOMBZG.js +0 -1
- package/dist/preview/chunk.VUSJ7HPC.js +0 -1
- package/dist/preview/chunk.VXRECLX6.js +0 -1
- package/dist/preview/chunk.W66VMALY.js +0 -1
- package/dist/preview/chunk.WGVIJDV5.js +0 -1
- package/dist/preview/chunk.X3MMJ3QC.js +0 -5
- package/dist/preview/chunk.X5YRNNHU.js +0 -1
- package/dist/preview/chunk.YMC2T2HN.js +0 -1
- package/dist/preview/chunk.YN6BXZHO.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{G as P}from"./chunk.
|
|
1
|
+
import{G as P}from"./chunk.4MP72LPR.js";import{Cc as b,Dc as $,Ec as y,Fc as k,Gc as _,Xc as O,Zc as S,ad as T,bd as E}from"./chunk.VSCIXAHN.js";import{a as x}from"./chunk.AJZBJBMO.js";var D=x(l=>{"use strict";var U=P();function C(r){var e="https://react.dev/errors/"+r;if(1<arguments.length){e+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)e+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+r+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function d(){}var s={d:{f:d,r:function(){throw Error(C(522))},D:d,C:d,L:d,m:d,X:d,S:d,M:d},p:0,findDOMNode:null},V=Symbol.for("react.portal");function j(r,e,a){var t=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:V,key:t==null?null:""+t,children:r,containerInfo:e,implementation:a}}var u=U.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(r,e){if(r==="font")return"";if(typeof e=="string")return e==="use-credentials"?e:""}l.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s;l.createPortal=function(r,e){var a=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)throw Error(C(299));return j(r,e,null,a)};l.flushSync=function(r){var e=u.T,a=s.p;try{if(u.T=null,s.p=2,r)return r()}finally{u.T=e,s.p=a,s.d.f()}};l.preconnect=function(r,e){typeof r=="string"&&(e?(e=e.crossOrigin,e=typeof e=="string"?e==="use-credentials"?e:"":void 0):e=null,s.d.C(r,e))};l.prefetchDNS=function(r){typeof r=="string"&&s.d.D(r)};l.preinit=function(r,e){if(typeof r=="string"&&e&&typeof e.as=="string"){var a=e.as,t=h(a,e.crossOrigin),n=typeof e.integrity=="string"?e.integrity:void 0,i=typeof e.fetchPriority=="string"?e.fetchPriority:void 0;a==="style"?s.d.S(r,typeof e.precedence=="string"?e.precedence:void 0,{crossOrigin:t,integrity:n,fetchPriority:i}):a==="script"&&s.d.X(r,{crossOrigin:t,integrity:n,fetchPriority:i,nonce:typeof e.nonce=="string"?e.nonce:void 0})}};l.preinitModule=function(r,e){if(typeof r=="string")if(typeof e=="object"&&e!==null){if(e.as==null||e.as==="script"){var a=h(e.as,e.crossOrigin);s.d.M(r,{crossOrigin:a,integrity:typeof e.integrity=="string"?e.integrity:void 0,nonce:typeof e.nonce=="string"?e.nonce:void 0})}}else e==null&&s.d.M(r)};l.preload=function(r,e){if(typeof r=="string"&&typeof e=="object"&&e!==null&&typeof e.as=="string"){var a=e.as,t=h(a,e.crossOrigin);s.d.L(r,a,{crossOrigin:t,integrity:typeof e.integrity=="string"?e.integrity:void 0,nonce:typeof e.nonce=="string"?e.nonce:void 0,type:typeof e.type=="string"?e.type:void 0,fetchPriority:typeof e.fetchPriority=="string"?e.fetchPriority:void 0,referrerPolicy:typeof e.referrerPolicy=="string"?e.referrerPolicy:void 0,imageSrcSet:typeof e.imageSrcSet=="string"?e.imageSrcSet:void 0,imageSizes:typeof e.imageSizes=="string"?e.imageSizes:void 0,media:typeof e.media=="string"?e.media:void 0})}};l.preloadModule=function(r,e){if(typeof r=="string")if(e){var a=h(e.as,e.crossOrigin);s.d.m(r,{as:typeof e.as=="string"&&e.as!=="script"?e.as:void 0,crossOrigin:a,integrity:typeof e.integrity=="string"?e.integrity:void 0})}else s.d.m(r)};l.requestFormReset=function(r){s.d.r(r)};l.unstable_batchedUpdates=function(r,e){return r(e)};l.useFormState=function(r,e,a){return u.H.useFormState(r,e,a)};l.useFormStatus=function(){return u.H.useHostTransitionStatus()};l.version="19.2.8"});var W=x((X,L)=>{"use strict";function N(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(N)}catch(r){console.error(r)}}N(),L.exports=D()});var I={name:"Graview",typography:{body:y.body,mono:y.mono},schemes:$},R={ground:"--graview-ground",groundDeep:"--graview-ground-deep",wash:"--graview-wash",panel:"--graview-panel",panelMuted:"--graview-panel-muted",panelWarning:"--graview-panel-warning",edge:"--graview-edge",edgeBright:"--graview-edge-bright",ink:"--graview-ink",inkMuted:"--graview-ink-muted",inkFaint:"--graview-ink-faint",accent:"--graview-accent",accentDim:"--graview-accent-dim",accentInk:"--graview-accent-ink",warn:"--graview-warn",good:"--graview-good",bad:"--graview-bad",glow:"--graview-glow",bar:"--graview-bar",float:"--graview-float",liftLow:"--graview-lift-low",liftHigh:"--graview-lift-high",tintAlpha:"--graview-tint-alpha",tintLightness:"--graview-tint-lightness",gridAlpha:"--graview-grid-alpha"};function B(r){return Object.keys(R).map(e=>` ${R[e]}: ${r[e]};`).join(`
|
|
2
2
|
`)}function A(r,e){let a=r===e?r:`${r} ${e}`;return` ${a} [data-graview-view] { transition: none; }
|
|
3
3
|
${a} [data-graview-touched] > * { animation: none; }
|
|
4
4
|
${a} [data-graview-view][data-graview-wrote] > *,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as hr,b as ue,c as Ce,d as Nn,f as Ae,g as gr,h as Ge,i as In,j as wi}from"./chunk.FQLNBIQ5.js";var yr="en-US",gt=/^\d{4}-\d{2}-\d{2}$/,xi=/^\d{4}(?:-(?:0[1-9]|1[0-2]))?$/,br=/^\d{4}(?:-(?:0[1-9]|1[0-2])(?:-\d{2})?)?$/,mt=/^\d{4}(-\d\d){2}[T ]\d\d:\d\d(:[\d.]+)?(Z|[+-][\d:]+)?$/,Sh=n=>!Number.isNaN(Date.parse(n)),ne=(n,e=Date.now())=>{let t=yt(n);return t?vr(e,t).day:new Date(e).toISOString().slice(0,10)},yt=n=>cn(n)??dn,Tn,jn,Dn,dn;function Fc(n){Tn=Fn(n.reader),jn=Fn(n.app),Dn=cn(n.readerTimeZone),dn=cn(n.appTimeZone)}function Lc(n,e){let t=[Tn,jn,Dn,dn];n.reader!==void 0&&(Tn=Fn(n.reader)),n.app!==void 0&&(jn=Fn(n.app)),n.readerTimeZone!==void 0&&(Dn=cn(n.readerTimeZone)),n.appTimeZone!==void 0&&(dn=cn(n.appTimeZone));try{return e()}finally{[Tn,jn,Dn,dn]=t}}var ki=n=>Tn??Fn(n)??jn??yr,bt=n=>Dn??cn(n)??dn,Zc=n=>bt(n)??Intl.DateTimeFormat().resolvedOptions().timeZone??"UTC",Cc=/^\s*([+\-−]|\d)/;var mr=new Map;function cn(n){if(n&&!mr.has(n)){let e=!1;try{new Intl.DateTimeFormat(yr,{timeZone:n}),e=!Cc.test(n)}catch{}mr.set(n,e)}return n&&mr.get(n)?n:void 0}var Ke=new Map;function Fn(n){if(n&&!Ke.has(n)){let e=!1;try{e=Intl.DateTimeFormat.supportedLocalesOf(n).length>0}catch{}Ke.set(n,e)}return n&&Ke.get(n)?n:void 0}function _e(n,e,t,r){let o=`${t=ki(t)}${r?"#":"@"}${JSON.stringify(e)}`,i=Ke.get(o);return i||Ke.set(o,i=r?new Intl.NumberFormat(t,e):new Intl.DateTimeFormat(t,e)),i.format(n).replace(/ /g," ")}var Be="UTC",vt=n=>Date.UTC(+n.slice(0,4),+n.slice(5,7)-1,+n.slice(8,10));function Oe(n,e){return xi.test(n)?n.length===4?n:Ai(n,{},e):gt.test(n)?_e(vt(n),{year:"numeric",month:"short",day:"numeric",timeZone:Be},e):n}function vr(n,e){let t=`wall@${e??""}`,r=Ke.get(t);r||Ke.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 Si(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=vr(i,t);return Gc(s.day,s.minutes)-Math.floor(i/6e4)*6e4};return r-o(r-o(r))}var Gc=(n,e)=>Date.UTC(+n.slice(0,4),+n.slice(5,7)-1,+n.slice(8,10),0,e),Ri=n=>/[Z+-][\d:]*$/.test(n.slice(16));function $i(n,e,t,r,o=!1){if(!mt.test(n))return n;let i=Ri(n),s=Date.parse(n.replace(" ","T")+(i?"":"Z"));if(Number.isNaN(s))return n;let a=i?bt(r):Be;return _e(s,{...e,hour:"numeric",minute:"2-digit",...i&&o?{timeZoneName:"short"}:{},...a?{timeZone:a}:{}},t)}var wr=(n,e,t)=>$i(n,{year:"numeric",month:"short",day:"numeric"},e,t,!0),Kc=(n,e,t)=>$i(n,{},e,t);function Bc(n,e){if(gt.test(n))return n;if(!mt.test(n))return;if(!Ri(n))return n.slice(0,10);let t=Date.parse(n.replace(" ","T"));return Number.isNaN(t)?void 0:vr(t,bt(e)).day}function me(n,e,t={maximumFractionDigits:2}){return Number.isFinite(n)?_e(n,t,e,!0):String(n)}function Vc(n,e={},t){return gt.test(n)?_e(vt(n),{weekday:e.weekday??"long",month:"short",day:"numeric",...e.year?{year:"numeric"}:{},timeZone:Be},t):n}function Uc(n,e){return gt.test(n)?_e(vt(n),{month:"short",day:"numeric",timeZone:Be},e):n}function Ai(n,e={},t){if(!/^\d{4}-\d{2}/.test(n))return n;let r=e.year??!e.short;return _e(vt(`${n.slice(0,7)}-01`),{month:e.short?"short":"long",...r?{year:e.short?"2-digit":"numeric"}:{},timeZone:Be},t)}var Wc=(n,e="short",t)=>_e(Date.UTC(1970,0,4+n),{weekday:e,timeZone:Be},t),qc=(n,e)=>_e(Date.UTC(1970,0,1,0,Math.round(n)),{hour:"numeric",minute:"2-digit",timeZone:Be},e),Hc=/(?<![\w-])(\d{4}-\d{2}-\d{2})(?![\w-]|:)/g;function xr(n,e){return n.includes("-")?n.replace(Hc,t=>Oe(t,e)):n}var ln=n=>n.charAt(0).toUpperCase()+n.slice(1),_i=n=>/^.\p{Lu}/u.test(n)?n:n.charAt(0).toLowerCase()+n.slice(1),Oi=(n,e="and")=>n.length>1?`${n.slice(0,-1).join(", ")} ${e} ${n.at(-1)}`:n[0]??"";function K(n){let e=n.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return ln(e.replace(/\b[a-z]+\b/g,t=>Pi.has(t)?t.toUpperCase():t.endsWith("s")&&Pi.has(t.slice(0,-1))?`${t.slice(0,-1).toUpperCase()}s`:t))}var Pi=new Set("id url uri api ip ioc cve cvss cwe cpe sku vat iban isbn pdf csv json html css sla kpi roi faq ssn ein vin gps sms crm erp seo utm ui ux ai dns ssl tls http https sql uuid mfa sso cto ceo cfo coo rsvp eta".split(" "));function Yc(n,e){return{...e,kind:n,edges:e.edges??{}}}function kr(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??ne()):!r.retired.includes(o)}function B(n,e){if(n?.label)return n.label(e);let t=e.label;return typeof t=="string"&&t.length>0?t:e.id}function Jc(n){return n.title??K(n.name)}function Xc(n,e,t){let r=n.tryDefinition(e);return`${me(t)} ${t===1?Y(r,e):ae(n,e).toLowerCase()}`}function ae(n,e){return n.tryDefinition(e)?.plural??`${K(e).toLowerCase()}s`}function Qc(n,e){return ln(ae(n,e))}function el(n,e){let t=ae(n,e);return`All ${/^[A-Z][a-z]/.test(t)?t.charAt(0).toLowerCase()+t.slice(1):t}`}function wt(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":K(e))}var nl=/^(u[nt]i|use|usu|uti|ubiq|eu|ewe|one|once)/,tl=/^(hour|honest|hono[ur]r?|heir)/;function Ei(n){let e=K(n).toLowerCase();return tl.test(e)?"an":nl.test(e)?"a":/^[aeiou]/.test(e)?"an":"a"}function un(n){return`${Ei(n)} ${K(n).toLowerCase()}`}function Y(n,e){return n?.noun??K(e).toLowerCase()}function $r(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 Ar(n,e="|"){return n.map(t=>Mr(t)).join(e)}function zi(n,e){return typeof e=="bigint"?e.toString():e}var Rr=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 Ni(n){return new Rr(n)}function Ii(n){return n==null}function _r(n){let e=n.startsWith("^")?1:0,t=n.endsWith("$")?n.length-1:n.length;return n.slice(e,t)}function Ti(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}var Mi=Symbol("evaluating");function ji(n,e,t){let r;Object.defineProperty(n,e,{get(){if(r!==Mi)return r===void 0&&(r=Mi,r=t()),r},set(o){Object.defineProperty(n,e,{value:o})},configurable:!0})}function kt(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}function Di(n){let e=Object.getOwnPropertyDescriptor(n,"shape");return e?.get?e.get.raw:e?.value}function Or(n){return Di(n._zod.def)??n._zod.def.shape}function Fi(n,e,t){Object.defineProperty(n,e,{get(){let r=t();return kt(this,e,r),r},enumerable:!0,configurable:!0})}function Li(n,e,t){e in n?kt(n,e,t):n[e]=t}function rl(n,e,t,r){let o=Or(e);for(let i of t){let s=Object.getOwnPropertyDescriptor(o,i);s.enumerable&&(s.get?Fi(n,i,()=>{let a=e._zod.def.shape[i];return r?r(a,i):a}):Li(n,i,r?r(s.value,i):s.value))}}function ol(n,e){for(let t of Reflect.ownKeys(e)){let r=Object.getOwnPropertyDescriptor(e,t);r.enumerable&&(r.get?Fi(n,t,()=>e[t]):Li(n,t,r.value))}}function Zi(...n){let e={};for(let t of n){let r=Object.getOwnPropertyDescriptors(t);Object.assign(e,r)}return Object.defineProperties({},e)}var Pr="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function xt(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Er(n){if(xt(n)===!1)return!1;let e=n.constructor;if(e===void 0||typeof e!="function")return!0;let t=e.prototype;return!(xt(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}var Ci=new Set(["string","number","symbol"]);function Zn(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fn(n,e,t){let r=new n._zod.constr(e??n._zod.def);return(!e||t?.parent)&&(r._zod.parent=n),r}function I(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 Mr(n){return typeof n=="bigint"?n.toString()+"n":typeof n=="string"?`"${n}"`:`${n}`}function Gi(n){return Object.keys(n).filter(e=>n[e]._zod.optin!==void 0&&n[e]._zod.optout==="optional")}var Ki={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 Bi(n,e){if(!Er(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=Or(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 fn(n,Zi(n._zod.def,{shape:il(n,e)}))}function il(n,e){let t={};return rl(t,n,Reflect.ownKeys(Or(n))),ol(t,e),t}function ye(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 Vi(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 Ee(n,e){return e.map(t=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(n),t})}function Ln(n){return typeof n=="string"?n:n?.message}function zr(n,e,t){var r;for(let o=e;o<n.length;o++)(r=n[o]).schema??(r.schema=t)}function be(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:Ln(n.inst?._zod.def?.error?.(n))??Ln(i?.(n))??Ln(e?.error?.(n))??Ln(t.customError?.(n))??Ln(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 sl=/[\uD800-\uDBFF]/;function Nr(n){let e=n.length;if(!sl.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 Ir(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function Ui(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 Cn(...n){let[e,t,r]=n;return typeof e=="string"?{message:e,code:"custom",input:t,inst:r}:{...e}}function Wi(n,e){for(let t in e){let r=Object.getOwnPropertyDescriptor(e,t);r.get?Object.defineProperty(n,t,{...r,enumerable:!1}):al(n,t,r.value)}}function Ve(n,e,t,r=!0){return Object.defineProperty(n,e,{configurable:!0,writable:!0,enumerable:r,value:t}),t}function Tr(n,e,t){return Ve(n,e,t,!1)}function al(n,e,t){Object.defineProperty(n,e,{configurable:!0,get(){return this==null?t:Ve(this,e,t.bind(this))},set(r){Ve(this,e,r)}})}function dl(n,e){let t=Object.getPrototypeOf(n);return e in t?void 0:t}var Sr,Pe=!1,cl={configurable:!0,get(){Pe=!0}};function J(n,e,t){let r=Object.getPrototypeOf(n._zod);if(e in r&&Sr!==n._zod){Sr=void 0;return}Sr=n._zod,Object.defineProperty(r,e,{configurable:!0,get(){Object.defineProperty(this,e,cl);let o=Pe;Pe=!1;try{let i=t(this);return Pe?delete this[e]:Object.defineProperty(this,e,{configurable:!0,writable:!0,value:i}),Pe=Pe||o,i}catch(i){throw delete this[e],Pe=Pe||o,i}},set(o){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:o})}})}function qi(n,e,t,r){let o=dl(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 Hi;var jr={value:void 0,enumerable:!1},Yi="captureStackTrace"in Error?Error:null;function ll(n){let e=Yi;if(e){let t=e.stackTraceLimit;if(typeof t=="number"){try{e.stackTraceLimit=0}catch{return Yi=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=f,this.traits=new Set}i.prototype=o;let s=t,a=s&&new WeakSet;function d(c,p){if(c._zod){if(c._zod.traits.has(n))return}else{jr.value=new i(p);try{Object.defineProperty(c,"_zod",jr)}finally{jr.value=void 0}}if(c._zod.traits.add(n),e(c,p),a){let h=Object.getPrototypeOf(c),v=c._zod.constr.prototype,b=h;for(;b&&b!==v;)b=Object.getPrototypeOf(b);let k=b??h;a.has(k)||(a.add(k),Wi(k,s))}let g=f.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 f(c){let p=r?.Parent?ll(u):this;d(p,c);let g=p._zod.deferred;if(g){for(let v of g)v();p._zod.deferred=void 0}let h=globalThis.__zod_globalConfig?.postProcessor;return h&&h(p),p}return Object.defineProperty(f,"init",{value:d}),Object.defineProperty(f,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(n)}),Object.defineProperty(f,"name",{value:n}),f}var we=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};(Hi=globalThis).__zod_globalConfig??(Hi.__zod_globalConfig={});var pn=globalThis.__zod_globalConfig;function re(n){return n&&Object.assign(pn,n),pn}function ul(){let n=this._zod;return n.message??(n.message=JSON.stringify(n.def,zi,2)),n.message}function fl(n){this._zod.message=n}var pl={get:ul,set:fl,enumerable:!0,configurable:!0},Fr={value:void 0,enumerable:!1},Ji=new WeakSet([Object.prototype,Error.prototype]),Xi=(n,e)=>{n.name="$ZodError",Fr.value=e,Object.defineProperty(n,"issues",Fr),Fr.value=void 0,Object.defineProperty(n,"message",pl);let t=Object.getPrototypeOf(n);Ji.has(t)||(Ji.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})}}))},Ih=O("$ZodError",Xi),Gn=O("$ZodError",Xi,void 0,{Parent:Error});var gl=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 we;if(a.issues.length){let d=new(i?.Err??n)(a.issues.map(l=>be(l,s,re())));throw Pr(d,i?.callee??e),d}return a.value};return e},Lr=gl(Gn),ml=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=>be(l,s,re())));throw Pr(d,i?.callee??e),d}return a.value};return e},Zr=ml(Gn),yl=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 we;return i.issues.length?Qi(n,i.issues,o):{success:!0,data:i.value}},Cr=yl(Gn);function Qi(n,e,t){let r;return{success:!1,get error(){return r||(r=new n(e.map(o=>be(o,t,re()))),e=void 0,t=void 0),r},set error(o){r=o,e=void 0,t=void 0}}}var bl=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?Qi(n,i.issues,o):{success:!0,data:i.value}},Gr=bl(Gn);var es=/^(?:[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 ns=/^https?$/;var ts=/^[\s\S]{0,}$/;var Kr=/^-?\d+(?:\.\d+)?$/,rs=/^(?:true|false)$/i,os=/^null$/i;var oe=O("$ZodCheck",(n,e)=>{var t;n._zod??(n._zod={}),n._zod.def=e,(t=n._zod).onattach??(t.onattach=[])});var is=n=>{let e=n.value;return!Ii(e)&&e.length!==void 0},St={number:"number",bigint:"bigint",object:"date"},ss=O("$ZodCheckLessThan",(n,e)=>{oe.init(n,e);let t=St[typeof e.value];n._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:St[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})}}),as=O("$ZodCheckGreaterThan",(n,e)=>{oe.init(n,e);let t=St[typeof e.value];n._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:St[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})}}),ds=O("$ZodCheckMultipleOf",(n,e)=>{oe.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):Ti(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})}}),cs=O("$ZodCheckNumberFormat",(n,e)=>{oe.init(n,e),e.format=e.format||"float64";let t=e.format?.includes("int"),r=t?"int":"number",[o,i]=Ki[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 ls=O("$ZodCheckMaxLength",(n,e)=>{var t;oe.init(n,e),(t=n._zod.def).when??(t.when=is),n._zod.check=r=>{let o=r.value,i=o.length;if((typeof o=="string"&&i>e.maximum?Nr(o):i)<=e.maximum)return;let a=Ir(o);r.issues.push({origin:a,code:"too_big",maximum:e.maximum,inclusive:!0,input:o,inst:n,continue:!e.abort})}}),us=O("$ZodCheckMinLength",(n,e)=>{var t;oe.init(n,e),(t=n._zod.def).when??(t.when=is),n._zod.check=r=>{let o=r.value,i=o.length;if((typeof o=="string"&&i>=e.minimum&&i<e.minimum*2?Nr(o):i)>=e.minimum)return;let a=Ir(o);r.issues.push({origin:a,code:"too_small",minimum:e.minimum,inclusive:!0,input:o,inst:n,continue:!e.abort})}});var Vr=O("$ZodCheckStringFormat",(n,e)=>{var t,r;oe.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=()=>{})}),fs=O("$ZodCheckRegex",(n,e)=>{Vr.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 hs={major:4,minor:6,patch:5};var U=O("$ZodType",(n,e)=>{var t;n??(n={}),n._zod.def=e,n._zod.bag=n._zod.bag||{},n._zod.version=hs;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=ye(a),f;for(let c of d){if(c._zod.def.when){if(Vi(a)||!c._zod.def.when(a))continue}else if(u)continue;let p=a.issues.length,g=c._zod.check(a);if(g instanceof Promise&&l?.async===!1)throw new we;if(f||g instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await g,a.issues.length!==p&&(zr(a.issues,p,n),u||(u=ye(a,p)))});else{if(a.issues.length===p)continue;zr(a.issues,p,n),u||(u=ye(a,p))}}return f?f.then(()=>a):a},s=(a,d,l)=>{if(ye(a))return a.aborted=!0,a;let u=i(d,o,l);if(u instanceof Promise){if(l.async===!1)throw new we;return u.then(f=>n._zod.parse(f,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(f=>s(f,a,d)):s(u,a,d)}let l=n._zod.parse(a,d);if(l instanceof Promise){if(d.async===!1)throw new we;return l.then(u=>i(u,o,d))}return i(l,o,d)}}},{get"~standard"(){return Tr(this,"~standard",wl(this))},set"~standard"(n){Ve(this,"~standard",n)}}),ws=(n,e)=>n.issues.length?{issues:n.issues.map(t=>be(t,e,re()))}:{value:n.value};async function vl(n,e){let t={async:!0};return ws(await n._zod.run({value:e,issues:[]},t),t)}function wl(n){return{validate:e=>{let t={async:!1};try{let r=n._zod.run({value:e,issues:[]},t);if(!(r instanceof Promise))return ws(r,t)}catch{}return vl(n,e)},vendor:"zod",version:1}}var Ur=O("$ZodString",(n,e)=>{U.init(n,e),n._zod.pattern=e.pattern??ts,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}}),At=O("$ZodStringFormat",(n,e)=>{Vr.init(n,e),Ur.init(n,e)});var xs=O("$ZodEmail",(n,e)=>{e.pattern??(e.pattern=es),At.init(n,e)}),ks=1,Rt=2;function xl(n){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(n):(new URL(n),!0)}catch{return!1}}function kl(n,e){return!("normalize"in e)&&!("hostname"in e)&&!("protocol"in e)?xl(n)||Rt:Sl(n,e)}function Sl(n,e){if(!e.normalize&&e.protocol?.source===ns.source&&!/^https?:\/\//i.test(n))return ks;try{if(typeof URL<"u"){let t=URL;if(typeof t.parse=="function")return t.parse(n)??Rt}return new URL(n)}catch{return Rt}}var Rl=/[\t\n\r]/g;function gs(n){return n.replace(Rl,"")}function $l(n,e){return e.lastIndex=0,e.test(n.hostname)}function Al(n,e){return e.lastIndex=0,e.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol)}var Ss=O("$ZodURL",(n,e)=>{At.init(n,e),n._zod.check=t=>{try{let r=t.value.trim(),o=kl(r,e);if(o===ks){t.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:t.value,inst:n,continue:!e.abort});return}if(o===Rt){t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort});return}if(o===!0){t.value=gs(r);return}e.hostname&&!$l(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&&!Al(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:gs(r);return}catch{t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort})}}});var Wr=O("$ZodNumber",(n,e)=>{U.init(n,e),n._zod.pattern=Kr,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}}),Rs=O("$ZodNumberFormat",(n,e)=>{cs.init(n,e),Wr.init(n,e)}),$s=O("$ZodBoolean",(n,e)=>{U.init(n,e),n._zod.pattern=rs,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 As=O("$ZodNull",(n,e)=>{U.init(n,e),n._zod.pattern=os,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 _s=O("$ZodUnknown",(n,e)=>{U.init(n,e),n._zod.parse=t=>t}),Os=O("$ZodNever",(n,e)=>{U.init(n,e),n._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:n}),t)});function ms(n,e,t){n.issues.length&&e.issues.push(...Ee(t,n.issues)),e.value[t]=n.value}var Ps=O("$ZodArray",(n,e)=>{U.init(n,e);let t=pn.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(f=>ms(f,r,d)));else if(ms(u,r,d),a&&u.issues.length!==0&&ye(u))break}return s.length?Promise.all(s).then(()=>r):r}});function $t(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(...Ee(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 _l=[];function Ol(n){let e=Object.keys(n.shape),t=Object.getOwnPropertySymbols(n.shape),r=t.length?t:_l,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=Gi(n.shape);return{...n,allKeys:o,symbolKeys:r,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(i)}}function Pl(n,e,t,r,o,i,s){let a=[],d=o.keySet,l=o.catchall._zod,u=l.def.type,f=l.optin,c=l.optout,p=0;for(let g in e){if(s&&t.issues.length!==p){if(ye(t,p))break;p=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(v=>$t(v,t,g,e,f,c))):$t(h,t,g,e,f,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 Es=O("$ZodObject",(n,e)=>{U.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=Ni(()=>Ol(e));J(n,"propValues",l=>{let u=l.def.shape,f={};for(let c in u){let p=u[c]._zod;if(p.values){Object.prototype.hasOwnProperty.call(f,c)||kt(f,c,new Set);for(let g of p.values)f[c].add(g);p.optin!==void 0&&f[c].add(void 0)}}return f});let i=xt,s=e.catchall,a,d=pn.memoizer;d?.attach(n),n._zod.parse=(l,u)=>{a??(a=o.value);let f=l.value;if(!i(f))return l.issues.push({expected:"object",code:"invalid_type",input:f,inst:n}),l;l.value=d?d.alloc(n,l,{},u):{};let c=[],p=a.shape,g=u?.abortEarly,h=l.issues.length;for(let v of a.allKeys){if(g&&l.issues.length!==h){if(ye(l,h))break;h=l.issues.length}if(v==="__proto__")continue;let b=p[v],k=b._zod.optin,$=b._zod.optout,x=b._zod.run({value:f[v],issues:[]},u);x instanceof Promise?c.push(x.then(_=>$t(_,l,v,f,k,$))):$t(x,l,v,f,k,$)}return s?Pl(c,f,l,u,o.value,n,g===!0):c.length?Promise.all(c).then(()=>l):l}});function ys(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=>!ye(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=>be(s,r,re())))}),e)}var Ms=O("$ZodUnion",(n,e)=>{U.init(n,e),J(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),J(n,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),J(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)))}),J(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=>_r(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=>ys(a,r,n,o)):ys(s,r,n,o)}});var zs=O("$ZodRecord",(n,e)=>{U.init(n,e);let t=pn.memoizer;t?.attach(n),n._zod.parse=(r,o)=>{let i=r.value;if(!Er(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 f=e.keyType._zod.run({value:u,issues:[]},o);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(f.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(g=>be(g,o,re())),input:u,path:[u],inst:n});continue}let c=f.value;if(c==="__proto__")continue;let p=e.valueType._zod.run({value:i[u],issues:[]},o);p instanceof Promise?s.push(p.then(g=>{g.issues.length&&r.issues.push(...Ee(u,g.issues)),r.value[c]=g.value})):(p.issues.length&&r.issues.push(...Ee(u,p.issues)),r.value[c]=p.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"&&Kr.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=>be(g,o,re())),input:l,path:[l],inst:n});continue}let c=u.value;if(c==="__proto__")continue;let p=e.valueType._zod.run({value:i[l],issues:[]},o);p instanceof Promise?s.push(p.then(g=>{g.issues.length&&r.issues.push(...Ee(l,g.issues)),r.value[c]=g.value})):(p.issues.length&&r.issues.push(...Ee(l,p.issues)),r.value[c]=p.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 Ns=O("$ZodEnum",(n,e)=>{U.init(n,e);let t=$r(e.entries),r=new Set(t);n._zod.values=r,J(n,"pattern",o=>{let i=$r(o.def.entries).filter(s=>Ci.has(typeof s));return new RegExp(i.length?`^(${i.map(s=>Zn(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}}),Is=O("$ZodLiteral",(n,e)=>{U.init(n,e);let t=new Set(e.values);n._zod.values=t,J(n,"pattern",r=>{let o=r.def.values;return new RegExp(o.length?`^(${o.map(i=>typeof i=="string"?Zn(i):i?Zn(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 bs(n,e){return n.value=e.issues.length?void 0:e.value,n}var Ts=O("$ZodOptional",(n,e)=>{U.init(n,e),J(n,"optin",t=>t.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),n._zod.optout="optional",J(n,"values",t=>{let r=t.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),J(n,"pattern",t=>{let r=t.def.innerType._zod.pattern;return r?new RegExp(`^(${_r(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=>bs(t,i)):bs(t,o)}return e.innerType._zod.run(t,r)}});var js=O("$ZodLazy",(n,e)=>{U.init(n,e),ji(n._zod,"innerType",()=>{let t=e;return t._cachedInner||(t._cachedInner=e.getter()),t._cachedInner}),J(n,"pattern",t=>t.innerType?._zod?.pattern),J(n,"propValues",t=>t.innerType?._zod?.propValues),J(n,"optin",t=>t.innerType?._zod?.optin??void 0),J(n,"optout",t=>t.innerType?._zod?.optout??void 0),n._zod.parse=(t,r)=>n._zod.innerType._zod.run(t,r)}),Ds=O("$ZodCustom",(n,e)=>{oe.init(n,e),U.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=>vs(i,t,r,n));vs(o,t,r,n)}});function vs(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(Cn(o))}}var El=()=>{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=Ui(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 ${Mr(i.values[0])}`:`Invalid option: expected one of ${Ar(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":""}: ${Ar(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 Fs(){return{localeError:El()}}var Ls;var qr=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 Zs(){return new qr}(Ls=globalThis).__zod_globalRegistry??(Ls.__zod_globalRegistry=Zs());var hn=globalThis.__zod_globalRegistry;function Cs(n){return n.checks&&(n.checks=[...n.checks]),n}function Gs(n,e){return new n(Cs({type:"string",...I(e)}))}function Ks(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...I(e)})}function Bs(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...I(e)})}function Vs(n,e){return new n(Cs({type:"number",checks:[],...I(e)}))}function Us(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...I(e)})}function Ws(n,e){return new n({type:"boolean",...I(e)})}function qs(n,e){return new n({type:"null",...I(e)})}function Hs(n){return new n({type:"unknown"})}function Ys(n,e){return new n({type:"never",...I(e)})}function Js(n,e){return new ss({check:"less_than",...I(e),value:n,inclusive:!0})}function Xs(n,e){return new as({check:"greater_than",...I(e),value:n,inclusive:!0})}function Il(n,e){return new ds({check:"multiple_of",...I(e),value:n})}function Hr(n,e){return new ls({check:"max_length",...I(e),maximum:n})}function Kn(n,e){return new us({check:"min_length",...I(e),minimum:n})}function Bn(n,e){return new fs({check:"string_format",format:"regex",...I(e),pattern:n})}function Qs(n,e,t){return new n({type:"custom",check:"custom",fn:e,...I(t)})}function ea(n,e){let t=Tl(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(Cn(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(Cn(i))}},n(r.value,r)),e);return t}function Tl(n,e){let t=new oe({check:"custom",...I(e)});return t._zod.check=n,t}function na(n){let e=new oe({check:"describe"});return e._zod.onattach=[t=>{let r=hn.get(t)??{};hn.add(t,{...r,description:n})}],e._zod.check=()=>{},e}var X=O("ZodMiniType",(n,e)=>{if(!n._zod)throw new Error("Uninitialized schema in ZodMiniType.");U.init(n,e),n.def=e,n.type=e.type},{get with(){return this.check},set with(n){Ve(this,"with",n)},parse(n,e){return Lr(this,n,e,{callee:this.parse})},parseAsync(n,e){return Zr(this,n,e,{callee:this.parseAsync})},safeParse(n,e){return Cr(this,n,e)},safeParseAsync(n,e){return Gr(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 fn(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)}}),ra=O("ZodMiniString",(n,e)=>{Ur.init(n,e),X.init(n,e)});function L(n){return Gs(ra,n)}var oa=O("ZodMiniStringFormat",(n,e)=>{At.init(n,e),ra.init(n,e)}),Fl=O("ZodMiniEmail",(n,e)=>{xs.init(n,e),oa.init(n,e)});function jy(n){return Ks(Fl,n)}var Ll=O("ZodMiniURL",(n,e)=>{Ss.init(n,e),oa.init(n,e)});function Dy(n){return Bs(Ll,n)}var ia=O("ZodMiniNumber",(n,e)=>{Wr.init(n,e),X.init(n,e)});function Ue(n){return Vs(ia,n)}var Zl=O("ZodMiniNumberFormat",(n,e)=>{Rs.init(n,e),ia.init(n,e)});function Fy(n){return Us(Zl,n)}var Cl=O("ZodMiniBoolean",(n,e)=>{$s.init(n,e),X.init(n,e)});function Ly(n){return Ws(Cl,n)}var Gl=O("ZodMiniNull",(n,e)=>{As.init(n,e),X.init(n,e)});function Zy(n){return qs(Gl,n)}var Kl=O("ZodMiniUnknown",(n,e)=>{_s.init(n,e),X.init(n,e)});function Yr(){return Hs(Kl)}var Bl=O("ZodMiniNever",(n,e)=>{Os.init(n,e),X.init(n,e)});function Vl(n){return Ys(Bl,n)}var Ul=O("ZodMiniArray",(n,e)=>{Ps.init(n,e),X.init(n,e)});function Cy(n,e){return new Ul({type:"array",element:n,...I(e)})}var Jr=O("ZodMiniObject",(n,e)=>{Es.init(n,e),X.init(n,e),qi(n,"shape",t=>t._zod.def.shape,!1)});function Me(n,e){let t={type:"object",shape:n??{},...I(e)};return new Jr(t)}function gn(n,e){return new Jr({type:"object",shape:n,catchall:Vl(),...I(e)})}function Gy(n,e){return new Jr({type:"object",shape:n,catchall:Yr(),...I(e)})}function sa(n,e){return Bi(n,e)}var Wl=O("ZodMiniUnion",(n,e)=>{Ms.init(n,e),X.init(n,e)});function Ky(n,e){return new Wl({type:"union",options:n,...I(e)})}var ta=O("ZodMiniRecord",(n,e)=>{zs.init(n,e),X.init(n,e)});function By(n,e,t){return!e||!e._zod?new ta({type:"record",keyType:L(),valueType:n,...I(e)}):new ta({type:"record",keyType:n,valueType:e,...I(t)})}var ql=O("ZodMiniEnum",(n,e)=>{Ns.init(n,e),X.init(n,e),n.options=[...n._zod.values]});function aa(n,e){let t=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new ql({type:"enum",entries:t,...I(e)})}var Hl=O("ZodMiniLiteral",(n,e)=>{Is.init(n,e),X.init(n,e)});function da(n,e){return new Hl({type:"literal",values:Array.isArray(n)?n:[n],...I(e)})}var Yl=O("ZodMiniOptional",(n,e)=>{Ts.init(n,e),X.init(n,e)});function Q(n){return new Yl({type:"optional",innerType:n})}var Jl=O("ZodMiniLazy",(n,e)=>{js.init(n,e),X.init(n,e)});function Vy(n){return new Jl({type:"lazy",getter:n})}var Xl=O("ZodMiniCustom",(n,e)=>{Ds.init(n,e),X.init(n,e)});function _t(n,e={}){return Qs(Xl,n,e)}function Uy(n,e){return ea(n,e)}var Wy=na;re().localeError||re(Fs());var D=n=>typeof n=="object"&&n!==null?n._zod?.def:void 0,Ql=n=>{if(typeof n!="object"||n===null||!("_zod"in n))return;let e=hn.get(n)?.description;return typeof e=="string"?e:void 0};var eu=(n,e)=>n?.src?.(e)??e,Ot=n=>typeof n=="string"&&n.length<2049&&/^(?![^/?#]*:|\/\/)(?!(?:.*\/)?\.\.?(?:[/?#]|$))(?!.*%2e)[^\\\s]+$/i.test(n),Xr=(n,e=1)=>e>0&&n===void 0||Number.isInteger(n)&&n>=e;function Qr(n){let e=n??{};return Ot(e.href)&&typeof e.name=="string"&&/^.{1,255}$/s.test(e.name)&&/^[\w.+-]{1,60}\/[\w.+-]{1,60}$/.test(e.type)&&Xr(e.bytes,0)&&Xr(e.width)&&Xr(e.height)&&(e.caption===void 0||typeof e.caption=="string"&&e.caption.length<501)&&(e.poster===void 0||Ot(e.poster))&&(e.captions===void 0||Ot(e.captions))&&(e.duration===void 0||typeof e.duration=="number"&&Number.isFinite(e.duration)&&e.duration>0)&&(e.at===void 0||ca(e.at)!==void 0)}function ca(n){return typeof n=="string"&&n.length<41&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d{1,9})?)?(Z|[+-]\d{2}:?\d{2})$/.test(n)&&Number.isFinite(Date.parse(n))?n:void 0}var la=n=>n.type.startsWith("image/"),ua=n=>n.type.startsWith("video/");function nu(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 tu=(n,e)=>e==="image"?la(n):e==="video"?ua(n):!0,ru=n=>`${n==="image"?"an image":n==="video"?"a video":"a file"} the host stored, at a path on this host`,Vn=n=>(Array.isArray(n)?n:[n]).filter(Qr),fa=Symbol.for("@graview/core:file"),ou=(n,e)=>(Object.defineProperty(D(n),fa,{value:e,enumerable:!0}),n);function pa(n){let e=D(n);return e?.[fa]??(e?.innerType?pa(e.innerType):void 0)}var iu=()=>({href:L(),name:L(),type:L(),bytes:Ue(),width:Q(Ue()),height:Q(Ue()),caption:Q(L()),poster:Q(L()),duration:Q(Ue()),captions:Q(L()),at:Q(L())});function qb(n){return ou(Me(iu()).check(_t(e=>Qr(e)&&tu(e,n),ru(n))),n)}var Pt=/^(?:https?:\/\/[^\s<>"'`\\]+|@?[A-Za-z0-9][\w.~-]*(?:\/[\w.~-]+)*)$/,Et=n=>typeof n=="string"&&n.length<501&&Pt.test(n);var ha=n=>typeof n=="object"&&n!==null?n._zod?.def:void 0,su=/^@(?:https?:\/\/[^\s<>"'`\\#?]+|[A-Za-z0-9][\w.~-]*(?:\/[\w.~-]+)*)\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;function ga(n){if(typeof n!="string"||!n.startsWith("@")||!su.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 Et(o)?{address:o,kind:r}:void 0}var au=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*:\S[^\n]{0,199}$/,du=n=>`${n.kind}:${n.id}`;function ma(n,e){if(typeof n!="string"||!au.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 cu(n,e){return(Array.isArray(n)?n:n==null?[]:[n]).flatMap(r=>{let o=ma(r,e);return o?[o]:[]})}var ya=Symbol.for("@graview/core:linked"),Xb=(n,e)=>(Object.defineProperty(ha(n),ya,{value:e,enumerable:!0}),n);function Un(n){let e=ha(n);return e?e[ya]??Un(e.innerType):void 0}function lu(n){let e=n?.fields?.shape??{},t=new Map;for(let[r,o]of Object.entries(e)){let i=Un(o);i&&t.set(r,i)}return t}function uu(n){if(n.to==="*"||n.to.length===0)return;let e=n.to.map(ga);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 fu=n=>n.to!=="*"&&n.to.some(e=>typeof e=="string"&&e.startsWith("@"));function Qb(n){return Object.fromEntries(Object.entries(n??{}).filter(([,e])=>!fu(e)))}function ev(n){let e=new Map;for(let[t,r]of Object.entries(n??{})){let o=uu(r);o&&e.set(t,o)}return e}var eo=new WeakMap;function pu(n,e){e?eo.set(n,e):eo.delete(n)}var ba=n=>eo.get(n);var Mt=["sun","mon","tue","wed","thu","fri","sat"],hu=["day","week","month","year"],yn=n=>`${n}Repeat`,qn=n=>n.endsWith("Repeat")&&n.length>6?n.slice(0,-6):void 0,xa=/^\d{4}-\d{2}-\d{2}$/,ka=Symbol.for("@graview/core:repeat");function zt(n){let e=D(n);return!!e&&(e[ka]===1||zt(e.innerType))}var gu=n=>(Object.defineProperty(D(n),ka,{value:1,enumerable:!0}),n),no=(n,e,t)=>n===void 0||Number.isInteger(n)&&n>=e&&n<=t,va=(n,e)=>n===void 0||Array.isArray(n)&&n.length<=e&&n.every(t=>typeof t=="string"&&xa.test(t)),mu=["every","interval","on","until","count","except","continues"],Sa=n=>bn(n)&&Object.keys(n).every(e=>mu.includes(e))&&no(n.interval,1,99)&&no(n.count,1,1e3)&&va(n.until===void 0?void 0:[n.until],1)&&va(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"?Mt.includes(e):n.every==="month"&&e!==0&&no(e,-1,31))),rv=()=>gu(Yr().check(_t(n=>n===null||Sa(n),"how a date repeats, or null"))),Wn=n=>Date.UTC(+n.slice(0,4),+n.slice(5,7)-1,+n.slice(8,10)),Ra=n=>new Date(n).toISOString().slice(0,10),to=(n,e)=>Ra(Wn(n)+e*864e5),wa=(n,e,t)=>{let r=new Date(Date.UTC(n,e+1,0)).getUTCDate();return Ra(Date.UTC(n,e,t<0||t>r?r:t))},bn=n=>typeof n=="object"&&n!==null&&hu.includes(n.every);function mn(n,e,t={}){let r=n.slice(0,10),o=n.slice(10),i=[];if(!xa.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,f=new Set(e.except??[]),c=+r.slice(0,4),p=+r.slice(5,7)-1,g=+r.slice(8,10),h=to(r,-new Date(Wn(r)).getUTCDay()),v=(e.on?.length?e.on:[a==="week"?Mt[new Date(Wn(r)).getUTCDay()]:g]).map(_=>typeof _=="string"?Mt.indexOf(_):_),b=a==="day"?1:a==="week"?7:0,k=(+d.slice(0,4)-c)*12+(+d.slice(5,7)-1-p),$=e.count?0:Math.max(0,Math.floor((b?(Wn(d)-Wn(b===7?h:r))/864e5/b:a==="month"?k:k/12)/s)-1),x=0;for(let _=0;_<5e4&&i.length<u;_++,$++){let A=$*s,m=a==="day"?[to(r,A)]:a==="week"?v.map(y=>to(h,A*7+y)):a==="month"?v.map(y=>wa(c,p+A,y)):[wa(c+A,p,g)];for(let y of[...new Set(m)].sort())if(!(y<r)&&(l&&y>l||e.count&&x>=e.count||(x++,y>=d&&!f.has(y)&&i.push(y+o),i.length>=u)))return i}return i}function $a(n,e,t){if(!bn(e)||typeof n!="string")return n;let r=mn(n,e,{from:t,limit:1})[0];if(r)return r;let o=e.until||e.count?mn(n,e):[];return o[o.length-1]??n}function yu(n,e,t){let r=n[e],o=n[yn(e)];return typeof r=="string"&&bn(o)?$a(r,o,t):r}var Nt=["human","visitor","agent","rule","system"],bu=new Set(Nt);function ro(n){return bu.has(n?.kind)?n.kind:"system"}function Hn(n,e){if(n.onBehalfOf){let{onBehalfOf:s,...a}=n;return`${Hn(a,e)}, for ${Hn(s,e)}`}let t=ro(n);if(n.id===void 0)return n.name??(t==="agent"?"an agent":t==="visitor"?"a visitor":t);let r=e.graph.getNode(n.id);if(r)return B(e.schema.tryDefinition(r.kind),r);let o=e.seats?.find(s=>s.principal.id===n.id);if(o)return o.label;let i=e.people?.find(s=>s.id===n.id&&(s.kind===void 0||s.kind===n.kind));return i?i.name:n.name?n.name:/(^|:)migration$/.test(n.id)?"the upgrade":n.id.startsWith("form:")?"a visitor via a form":/[:_/]/.test(n.id)?{human:"somebody",visitor:"a visitor",agent:"an agent",rule:"a rule",system:"the system"}[t]:n.id}var vn="$archived",We=n=>n?.[vn]===!0,cv=(n,e=!1)=>e==="all"||We(n)===e,oo=n=>n===!0||n==="true"?!0:n==="all"?"all":!1,Yn="$leftAlone",It=new Set([vn,Yn]);var de=class extends Error{constructor(t,r){super(r?`${t}
|
|
2
|
+
\u2192 ${r}`:t);this.hint=r;this.name="SchemaError"}};function vu(n,e){let t=n,r=new Map;for(let a of t){if(r.has(a.kind))throw new de(`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 f of l.to)if(!r.has(f))throw new de(`Edge "${d}" on "${a.kind}" points at undeclared kind "${f}"`,`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(f=>r.get(f).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,sa(a.fields,{id:L().check(Kn(1)),kind:da(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 de(`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 de("Node is missing a `kind`");let l=s.get(d);if(!l)throw new de(`Unknown node kind "${d}"`,`Declared kinds: ${[...r.keys()].join(", ")}`);let u={},f={};for(let[p,g]of Object.entries(a))It.has(p)?g===!0&&(f[p]=!0):u[p]=g;let c=l.parse(u);return Object.keys(f).length>0?{...c,...f}:c},__node:void 0}}var io="0.1.60";var wn={snapshot:2,op:3},xn=class extends Error{constructor(t,r,o,i,s){super(s!==void 0?`This ${t} holds a ${s} that @graview ${io} does not know: upgrade the framework to read it.`:`This ${t} is in a newer format (${r}${i?`, written by @graview ${i}`:""}) than @graview ${io} reads (${o}). `+(t==="snapshot"?"Refold it from the log, or upgrade the framework.":"Upgrade the framework to read it."));this.what=t;this.found=r;this.supported=o;this.writtenBy=i;this.unknown=s;this.name="NewerFormatError"}},so=["add-node","remove-node","patch-node","add-edge","remove-edge","splice-text"],wu=new Set(so);function ao(n){throw new xn("op",wn.op+1,wn.op,void 0,`primitive "${n?.op}"`)}var co=new Set;function lo(n){for(let e in n){let t=n[e]?.$type;if(t!==void 0&&!co.has(t))throw new xn("op",wn.op+1,wn.op,void 0,`value type "${t}" in "${e}"`)}}function Aa(n){for(let e of n.primitives)wu.has(e?.op)||ao(e)}function N(n){return`${n.kind}\0${n.from}\0${n.to}`}var Jn={addedNodes:[],removedNodes:[],changedNodes:[],addedEdges:[],removedEdges:[],touched:[]};function _a(n){return n.addedNodes.length===0&&n.removedNodes.length===0&&n.changedNodes.length===0&&n.addedEdges.length===0&&n.removedEdges.length===0}function xu(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 ze(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 p=r.get(c.id);if(!p||p===c)continue;let g=xu(c,p);g.length>0&&s.push({before:c,after:p,fields:g})}let a=new Map(n.edges.map(c=>[N(c),c])),d=new Map(e.edges.map(c=>[N(c),c])),l=e.edges.filter(c=>!a.has(N(c))),u=n.edges.filter(c=>!d.has(N(c))),f=new Set;for(let c of o)f.add(c.id);for(let c of i)f.add(c.id);for(let c of s)f.add(c.after.id);for(let c of[...l,...u])f.add(c.from),f.add(c.to);return{addedNodes:o,removedNodes:i,changedNodes:s,addedEdges:l,removedEdges:u,touched:[...f].sort()}}function Ne(n,e,t){let r=new Set(t.flatMap(i=>i.op==="patch-node"||i.op==="splice-text"?[i.id]:"node"in i?[i.node.id]:[i.edge.from,i.edge.to]));if(r.size===0)return Jn;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 ze(o(n),o(e))}var Tt={idLength:200,dataLength:4096,sameKindPerPair:1};function Oa({id:n,data:e}){if(n!==void 0&&!(typeof n=="string"&&n.length<=Tt.idLength&&/^[^\s\p{Cc}]+$/u.test(n)))return`A link's id is 1\u2013${Tt.idLength} characters with no space`;if(e!==void 0&&!(e&&typeof e=="object"&&!Array.isArray(e)&&JSON.stringify(e).length<=Tt.dataLength))return`A link's data is a JSON object of at most ${Tt.dataLength} characters`}function ku(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?K(String(t.path.at(-1))):null,o=t.message??"is not what the declaration allows";return r?`${r}: ${o}`:o}).join("; ")}var z=class extends Error{constructor(t,r){super(r?`${t}
|
|
3
|
+
${r}`:t);this.hint=r;this.name="GraphError"}},W=class extends z{constructor(t,r){super(r);this.id=t;this.name="MissingRecordError"}};function jt(n,e){try{n.parseNode(e);return}catch(t){if(t instanceof de)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 uo="n\0",fo="e\0",ee=class n{constructor(e,t={}){this.schema=e;this.validate=t.validate??!0}nodes=new Map;edges=new Map;linkIds=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=ze(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)}linkById(e){return this.edges.get(this.linkIds.get(e))}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=Ne(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){let t=new Map([...this.lapsed,...this.ranks]);for(let o of[this.nodes,this.edges,this.linkIds,this.outIndex,this.inIndex,this.ranks,this.lapsed,this.counts,this.archived])o.clear();this.reordered=!1;for(let o of e.nodes)this.insertNode(o,!0);for(let o of e.edges)this.insertEdge(o,!0);let r=[...this.ranks.keys()];if(r.every((o,i)=>t.get(o)>(o[0]===r[i-1]?.[0]?t.get(r[i-1]):0))){for(let[o,i]of t)(this.ranks.has(o)?this.ranks:this.lapsed).set(o,i);for(;this.lapsed.size>4096;)this.lapsed.delete(this.lapsed.keys().next().value)}}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(uo));this.nodes.clear();for(let[o,i]of t)this.nodes.set(o,i);let r=[...this.edges.entries()].sort(e(fo));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":lo(e.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 W(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(uo+o),this.outIndex.delete(o),this.inIndex.delete(o);return}case"patch-node":{let o=this.nodes.get(e.id);if(!o)throw new W(e.id,`Cannot patch missing node "${e.id}"`);lo(e.after);let i={...o};for(let[a,d]of Object.entries(e.after))Ce(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[We(s)?"add":"delete"](e.id),s.kind!==o.kind&&(this.tally(o.kind,-1),this.tally(s.kind,1));return}case"splice-text":{let o=this.nodes.get(e.id);if(!o)throw new W(e.id,`Cannot splice the text of missing node "${e.id}"`);let i=o[e.field],s;try{typeof i=="string"&&e.field!=="id"&&e.field!=="kind"&&(s=hr(i,e))}catch{}if(s===void 0)throw new z(`Cannot splice ${e.id}.${e.field}: it does not hold ${JSON.stringify(e.removed)} at ${e.at}`,"A corrupt op: the text it was made against is not the text the log folds to.");let a={...o,[e.field]:s};this.nodes.set(e.id,t?a:this.checkPatch(o,a,[e.field]));return}case"add-edge":this.insertEdge(e.edge,t,r);return;case"remove-edge":{let o=e.edge.id===void 0?e.edge:this.linkById(e.edge.id);if(!o||!this.edges.has(N(o)))throw new W(e.edge.id??N(e.edge),`Cannot remove missing edge ${e.edge.id??N(e.edge)}`);this.deleteEdge(o);return}default:ao(e)}}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"||It.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=jt(this.schema,t);if(i===void 0)return t;let s=jt(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 de)return t;{let r=e?.id??"?",o=e?.kind??"?",i=this.schema.tryDefinition(o),s=i&&e&&typeof e=="object"?B(i,e):r;return new z(`${s} does not match what ${o} declares`,ku(t))}}insertNode(e,t,r=!1){if(this.nodes.has(e.id))throw new z(`Duplicate node id "${e.id}"`);this.nodes.set(e.id,t?e:this.check(e)),We(e)&&this.archived.add(e.id),this.tally(e.kind,1),this.place(uo+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 W(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 z(`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=N(e);if(!t&&(e.id!==void 0||e.data!==void 0)){let a=this.edges.get(s),d=Oa(e)??(a&&e.id!==void 0&&a.id!==e.id?`A second "${e.kind}" link between two records is not allowed yet`:(this.linkIds.get(e.id)??s)!==s?`Link id "${e.id}" is already taken`:void 0);if(d)throw new z(d)}this.edges.has(s)||(this.edges.set(s,e),e.id!==void 0&&this.linkIds.set(e.id,s),this.place(fo+s,r),this.index(this.outIndex,e.from,s),this.index(this.inIndex,e.to,s))}deleteEdge(e){let t=N(e),r=this.edges.get(t)?.id;r!==void 0&&this.linkIds.delete(r),this.edges.delete(t),this.lapse(fo+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 Dt=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 Su(n,e){return{...e,name:n}}var Ft=class extends Error{constructor(e){super(e),this.name="RuleBudgetError"}};function Pa(n,e,t){try{return e().map(r=>r.status?r:{...r,status:"violated"})}catch(r){let o=r instanceof Ft,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 kn(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(...Pa(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 p=c.scope.kind,g=l.get(p);g?g.push(c):l.set(p,[c])}for(let c of n.allNodes()){let p=n.schema.tryDefinition(c.kind),g=p?.requiresInvariant?.(c)??null;if(t.subjectFilter&&!t.subjectFilter(c,r))continue;if(g!==null&&!s.has(g)){if(i==="throw")throw new Dt(g,c.id);continue}let h=!kr(p,c,t.today);for(let v of l.get(c.kind)??[]){if(h&&v.judgesPast!==!0)continue;let b=v.scope.match;b&&!b(c)||a.push(...Pa(v,()=>v.evaluate({graph:n,subject:c,context:r,...o}),c.id))}}let u=new Set,f=a.filter(c=>{let p=`${c.message}|${[...c.nodeIds].sort().join(",")}`;return u.has(p)?!1:(u.add(p),!0)}).map(c=>{let p=xr(c.message);return p===c.message?c:{...c,message:p}});return po?po(n,e,f,t.today):f}var po;function zv(n){po=n}function Ru(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 $u(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 Lt=(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,xe=(n,e)=>n.roles==="*"||(e.roles??[]).some(t=>n.roles.includes(t));function Ea(n){return Oi(n.map(e=>un(K(e).toLowerCase())),"or")}function ke(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(ke(n,e,t,r,void 0,i).ok)return{ok:!0};let p=!1;if(o.some(b=>ke(n,e,b,r,void 0,i).ok)){if(!d||i===void 0||e.id!==void 0&&d()===e.id||!l&&n.grants.some(b=>b.roles!=="*"&&xe(b,e)&&o.some(k=>Lt(b.mutations,k))))return{ok:!0};p=!0}let g=p?[t]:[t,...o],h=[...new Set(g.flatMap(b=>ho(n,b,r)))].sort(),v=(p?"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":`${Ea(h)} can`);return{ok:!1,refusal:{mutation:t,...r===void 0?{}:{kind:r},wouldNeed:h,message:Ma(n,g,r,v,s)}}}let u=!1;for(let p of n.grants){if(!xe(p,e)||!Lt(p.mutations,t)||p.kinds!==void 0&&p.kinds!=="*"&&(r===void 0||!p.kinds.includes(r))||p.self&&(i===void 0||e.id===void 0||i!==e.id))continue;let g=p.ownEnd?a?.()??[]:[e.id];if(!g.length||g.some(h=>h!==e.id)){u=!0;continue}return{ok:!0}}let f=ho(n,t,r),c=u?"only on your own end of the link":f.length===0?"no role can":`${Ea(f)} can`;return{ok:!1,refusal:{mutation:t,...r===void 0?{}:{kind:r},wouldNeed:f,message:Ma(n,[t],r,c,s)}}}function Ma(n,e,t,r,o){let i=[...new Set(e.flatMap(a=>za(n,a,t)))],s=o.act?.(e[0]);return`Not permitted: ${s?`\u201C${s}\u201D`:e[0]}${t?` on ${un(o.noun?.(t)??t)}`:""} \u2014 ${r}.`+(i.length>0?` ${i.join(" ")}`:"")}function za(n,e,t){return[...new Set(Na(n,e,t).flatMap(r=>r.describe||[]))]}var Na=(n,e,t)=>n.grants.filter(r=>Lt(r.mutations,e)&&(t===void 0||Lt(r.kinds??"*",t)));function ho(n,e,t){let r=Na(n,e,t);return r.some(o=>o.roles==="*")?[]:[...new Set(r.flatMap(o=>o.roles))].sort()}function go(n,e,t){return n?t.filter(r=>{let o=T(e).id;return mo(r).some(i=>ke(n,e,r.name,i,void 0,o,void 0,()=>[o??[]].flat()).ok)}):t}var mo=n=>n.subject&&n.subject.kinds!=="*"?n.subject.kinds:[void 0];var Zt="type-text",ie={};var se=class extends Error{constructor(t,r="refused"){super(t);this.sentence=t;this.reason=r;this.name="ActRefusal"}};var Ct="publish",yo=n=>n?.mode==="on-publish",bo=(n,e,t)=>yo(n)&&!V(e)&&(t==="published"||!(T(e).roles??[]).some(r=>n.working.includes(r))),q=globalThis[Symbol.for("@graview/core:publishing")]??={};q.input=()=>Me({through:Q(Ue())});var Xn=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.op==="splice-text"?e.id:"";if(r===""||this.unversioned?.has(r))return;let o=e.op==="add-node"?Object.keys(e.node):e.op==="splice-text"?[e.field]: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=N(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=N(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,Ia(t,e.before));return}case"splice-text":{let t=this.unversioned?.has(e.id)?void 0:this.node(e.id);t&&this.setNode(e.id,gr(t,e,!0));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,Ia(t,e.after));return}case"splice-text":{let t=this.unversioned?.has(e.id)?void 0:this.node(e.id);t&&this.setNode(e.id,gr(t,e));return}case"add-edge":this.setEdge(e.edge,!0);return;case"remove-edge":this.setEdge(e.edge,!1);return}}};function Ia(n,e){let t={...n};for(let[r,o]of Object.entries(e))Ce(o)?delete t[r]:t[r]=o;return t}var Au=n=>n.op==="add-node"||n.op==="remove-node"?n.node.id:n.op==="patch-node"||n.op==="splice-text"?n.id:void 0;function vo(n,e,t,r){let o=u=>{let f=e.node(u);return f?t.served(f,e.writerOf(u))!==void 0:t.sees?.(u)??!1},i=Au(n);if(i===void 0){let u=n.edge,f=t.edgeClean(u)&&o(u.from)&&o(u.to);return e.apply(n),{primitives:f?[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})),f=n.op==="add-node"&&l===n.node&&u.length===0;return{primitives:f?[n]:[{op:"add-node",node:l},...u],faithful:f}}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,p)=>g=>g in c==(p!==void 0&&g in p);if(Object.keys(n.after).every(c=>u(a,s)(c)&&u(l,d)(c)))return{primitives:[n],faithful:!0};let f=c=>Object.fromEntries(Object.keys(n.after).map(p=>[p,p in c?c[p]:ue]));return{primitives:[{op:"patch-node",id:i,before:f(a),after:f(l)}],faithful:!1}}if(n.op==="splice-text"){let u=n.field;if(a[u]===s[u]&&l[u]===d[u])return{primitives:[n],faithful:!0};let f=c=>({[u]:u in c?c[u]:ue});return{primitives:[{op:"patch-node",id:i,before:f(a),after:f(l)}],faithful:!1}}return{primitives:[{op:"remove-node",node:a},{op:"add-node",node:l}],faithful:!1}}function Ta(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 Xn(e.present,e);if(!i)return s.begin(e.log.length??o+r.length),n.map(c=>{let p=T(c.author).id,g=c.primitives.map(h=>vo(h,s,t,()=>p));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=_u(r,d,e.present,t),f=u?new Xn(e.present,e,u.unversioned):s;for(let c=r.length-1;c>=d;c--){let p=r[c].primitives;for(let g=p.length-1;g>=0;g--)f.undo(p[g])}return Ou(n,r,d,l,a,f,u?.judge??t,e)}function _u(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=(f,c)=>{s.has(f)||a.has(f)||(o(f)?i(c)?(a.add(f),d.delete(f)):d.add(f):(s.add(f),d.delete(f)))};for(let f=e;f<n.length;f++)for(let c of n[f].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)):c.op==="splice-text"&&(l(c.id,{}),s.has(c.id)||(a.add(c.id),d.delete(c.id)));for(let f of d){let c=t.getNode(f);c&&i(c)&&(d.delete(f),a.add(f))}return{unversioned:new Set([...d,...s]),judge:{...r,served:(f,c)=>d.has(f.id)?f:s.has(f.id)?void 0:r.served(f,c)}}}function Ou(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 p of u.primitives)i.apply(p);continue}let f=(p,g)=>a.writers?.writerAt(p,g,u.seq+1),c=u.primitives.map(p=>vo(p,i,s,f));d.set(u.seq,{op:u,primitives:c.flatMap(p=>p.primitives),faithful:c.every(p=>p.faithful)})}return n.map(l=>d.get(l.seq))}function Vv(n,e,t,r){let o=new Xn(e.present,e);return o.begin(e.log.length??e.log.all().length),n.flatMap(i=>vo(i,o,t,()=>r).primitives)}var Da="A change you cannot see",Fa={kind:"system",id:"withheld",name:"Someone"};function Sn(n){return n.withheld===!0}var Qn=Ae,La=(n,e)=>Object.entries(n).some(([t,r])=>t!=="id"&&t!=="kind"&&j(r,e));function Za(n){if(typeof n!="function")return n;let e=n,t=r=>e(r.id)&&!La(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 Ca(n,e){let t=r=>!e(r);return n.primitives.some(r=>Qn(r).some(t))||[...n.writes,...n.reads].some(t)||n.mutation!==null&&j(n.mutation.args,e)}function Pu(n,e){if(Qn(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 La(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]=ue;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;case"splice-text":return j(n.removed,e.sees)||j(n.inserted,e.sees)?void 0:n}}function wo(n,e,t){let r=Za(e),o=i=>r.shows(i)&&Ga(r,i);return{id:n.id,seq:n.seq,batch:n.batch,author:Fa,intent:Da,mutation:null,primitives:t??n.primitives.flatMap(i=>{let s=Pu(i,r);return s?[s]:[]}),reads:n.reads.filter(o),writes:n.writes.filter(o),at:n.at,...n.undoes!==void 0?{undoes:n.undoes}:{},withheld:!0}}function Rn(n,e){let t=Za(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 Ta(n,r.timeline,o).map(({op:i,primitives:s,faithful:a})=>(!i.withheld&&a?ja(i,r,s):void 0)??wo(i,r,s))}return n.map(o=>(!o.withheld&&!Ca(o,r.shows)?ja(o,r):void 0)??wo(o,r))}function ja(n,e,t){let r=n.inverse??n.primitives;if(t&&t.length<n.primitives.length){if(!t.length)return;r=r.filter(h=>Qn(h).every(e.shows));let{inverse:p,...g}=n;n={...g,primitives:t}}let o=p=>e.sees(p)&&Ga(e,p),i=n.reads.filter(o),s=new Set(n.primitives.flatMap(Qn)),a=n.writes.filter(p=>o(p)||e.sees(p)&&s.has(p)),d=i.length===n.reads.length&&a.length===n.writes.length?n:{...n,reads:i,writes:a},l=e.actor!==void 0&&T(n.author).id===e.actor;if(!l&&n.described?.some(p=>!e.sees(p)))return;if(!j(n,e.sees))return d;let u=new Set,f=p=>{if(typeof p=="string")u.add(p);else if(Array.isArray(p))for(let g of p)f(g);else if(p!==null&&typeof p=="object")for(let[g,h]of Object.entries(p))u.add(g),f(h)};t&&f(t);let c=p=>e.sees(p)||u.has(p);if(!j(r,c))return l&&n.mutation&&f(n.mutation.args),j({...d,primitives:[],inverse:[]},l?c:e.sees)?void 0:d}function Ga(n,e){return n.timeline===void 0||n.kindOf(e)!==void 0}var qe=class extends z{constructor(t){super(t.message);this.check=t;this.name="UndoBlockedError"}get blockedBy(){return this.check.blockedBy}};function et(n,e){let t=new Set(e),r=n.undoneIds(),o=n.all().filter(h=>t.has(h.batch)&&!r.has(h.id)),i=[...n.epochs()].reverse().find(h=>h.horizon);if(i){let h=new Set(n.all().map(b=>b.batch)),v=e.filter(b=>!h.has(b));if(v.length>0)return{ok:!1,ops:o,blockedBy:[],includeBatches:[],reason:"missing",message:`Cannot undo ${v.map(b=>`batch ${b}`).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(Sn))return{ok:!1,ops:o,blockedBy:[],includeBatches:[],reason:"forbidden",message:o.every(Sn)?"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(h=>h.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=i&&o.some(h=>h.publishedThrough!==void 0)?q.undo?.(n,o,i):void 0;if(s)return{ok:!1,ops:o,blockedBy:[],includeBatches:[],message:s};let a=new Set;for(let h of o)for(let v of h.writes)a.add(v);let d=Math.min(...o.map(h=>h.seq)),l=n.epochs().find(h=>h.change!==void 0&&h.seq>d);if(l){let h=o.find(v=>v.seq<l.seq);return{ok:!1,ops:o,blockedBy:[],includeBatches:[],message:`Cannot undo "${h.intent}": ${h.intent===l.change?"it changed the declaration":`it was done before the declaration changed (${l.change})`}, and undo does not reach back across that change.`}}let u=new Map(n.all().map(h=>[h.id,h.seq])),f=o.flatMap(h=>h.primitives),c=[];for(let h of n.all()){if(h.seq<=d||t.has(h.batch)||r.has(h.id)||h.undoes!==void 0&&(u.get(h.undoes)??-1)>d)continue;let v=ie.aside?.(f,h);if(v===!0)continue;let b=[...new Set([...h.reads.filter(k=>a.has(k)),...v??[]])];b.length>0&&c.push({op:h,overlap:b})}if(c.length===0)return{ok:!0,ops:o};let p=c.filter(h=>!Sn(h.op)).map(h=>`"${h.op.intent}" (op ${h.op.id}, read ${h.overlap.join(", ")})`).join("; ");if(c.some(h=>Sn(h.op)))return{ok:!1,ops:o,blockedBy:c,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 g=[...new Set(c.map(h=>h.op.batch))];return{ok:!1,ops:o,blockedBy:c,includeBatches:g,message:`Cannot undo on its own \u2014 a later operation depends on it: ${p}. Include ${g.map(h=>`batch ${h}`).join(", ")} to undo them together.`}}function Ka(n,e){return e?xo(e,n).flatMap(t=>[...t.primitives]):[...n].sort((t,r)=>r.seq-t.seq).flatMap(t=>Ge(t))}function xo(n,e){return ie.undone?ie.undone(n,e):[...e].sort((t,r)=>r.seq-t.seq).map(t=>({op:t,primitives:Ge(t)}))}var He=class extends Error{refusal;constructor(e){super(e.message),this.name="PermissionDeniedError",this.refusal=e}};function Eu(n){let e=n instanceof Error?n.message:String(n);if(n instanceof He){let t=n.refusal.wouldNeed;return{reason:"forbidden",sentence:e,...t.length>0?{wouldNeed:[...t]}:{}}}return n instanceof W?{reason:"missing",sentence:e}:n instanceof se?{reason:n.reason,sentence:n.sentence}:n instanceof qe?{reason:n.check.reason??"invalid",sentence:e}:{reason:"invalid",sentence:e}}var pe=class extends z{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"}};var Mu=["edit","remove","archive","unarchive","merge","leave-alone","allow-tidying"];var uw=n=>Mu.map(e=>`${e}-${n}`);function Va(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 ko=["connect","disconnect"],Ua=n=>n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),So=(n,e,t)=>`${n}-${e}-${Ua(t)}`;function fw(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}-${Ua(i)}`)return{act:t[1],kind:r,relation:i}}}}var pw=n=>[...n].flatMap(([e,t])=>[...t].flatMap(r=>ko.map(o=>So(o,e,r)))),Ba=n=>`${/^[aeiou]/i.test(n)?"an":"a"} ${n}`;function Wa(n,e){let t=e.also?` (${e.also})`:"";return{title:`${e.one?`${n==="connect"?"Set":"Clear"} the ${e.to}`:`${n==="connect"?"Link":"Unlink"} ${Ba(e.to)}`}${t}`,fromTheOtherEnd:`${n==="connect"?"Link":"Unlink"} ${Ba(e.from)}${t}`}}function qa(n,e,t,r){if(t.cardinality!=="one"||t.to==="*"||t.to.length!==1||t.to[0]!==n)return;let o=t.description?.trim().replace(/\.$/,"");return o&&/^the\s+\S/i.test(o)&&!/[.;:!?,()]/.test(o)&&o.split(/\s+/).length<=8?{to:o.replace(/^the\s+/i,"")}:{also:r(e)}}var Ye=n=>n.trim().replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").replace(/-+/g,"-").toLowerCase();function Gt(n,e){let t=Ye(n),r=[...e];if(r.includes(n))return n;let o=r.filter(i=>Ye(i)===t);return o.length===1?o[0]:void 0}function zu(n,e){let t=Array.from({length:e.length+1},(r,o)=>o);for(let r=1;r<=n.length;r+=1){let o=[r];for(let i=1;i<=e.length;i+=1)o[i]=Math.min(t[i]+1,o[i-1]+1,t[i-1]+(n[r-1]===e[i-1]?0:1));t=o}return t[e.length]}function Ro(n,e){let t=[...e],r=Gt(n,t);if(r)return r;let o=Ye(n);if(o==="")return;let i,s=!1;for(let a of t){let d=zu(o,Ye(a));d>Math.max(2,Math.floor(Math.max(o.length,a.length)/3))||(!i||d<i.far?(i={act:a,far:d},s=!1):d===i.far&&(s=!0))}return i&&!s?i.act:void 0}var Nu=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 })`,$n=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?Nu(e):`Op "${e.id}" has seq ${e.seq} but the log is ${this.length} long`);Aa(e),this.ops.push(In(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}horizonEpoch(){for(let e=this.marks.length-1;e>=0;e--)if(this.marks[e].horizon)return this.marks[e]}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 Je(this.ops)}opsInBatch(e){return this.ops.filter(t=>t.batch===e)}batches(){return $o(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=ee.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 Je(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 $o(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 Ao(n){return n?.automated===!0&&n.kind!=="human"&&n.kind!=="rule"}var Ya=n=>n?.[Yn]===!0,Tu=(n,e)=>Ya(("graph"in n?n.graph:n).getNode(e));function Ha(n,e,t){let r=n.tryDefinition(e);return t===void 0?r?.tidying:r?.edges?.[t]?.tidying}var ju=n=>JSON.stringify(n,(e,t)=>t&&typeof t=="object"&&!Array.isArray(t)?Object.fromEntries(Object.entries(t).sort()):t);var Du=/^(archive|unarchive|remove|leave-alone|allow-tidying)$/;function Fu(n,e){let t=Ye(n.name),r=e?.act(n.name),o=n.args??{},i=r?r.derived:Va(t),{id:s}=o;if(i&&typeof s=="string"){if(Du.test(i.act))return[i.act,s];if(i.act==="merge")return["merge",...[s,o.into].sort()];if(i.relation)return[i.act,i.relation,s,o.to]}let a=r?.subject?.arg??"id",[d,l]=Object.keys(o).filter(u=>u!==a);return r?.connects?.length===1&&d&&!l&&e.has(o[a])&&e.has(o[d])?["connect",r.connects[0],o[a],o[d]]:[t,r?.creates?.length&&typeof s=="string"&&!e.has(s)?{...o,id:0}:o]}var Ja=(n,e)=>`\u2248${ju(n.map(t=>Fu(t,e)))}`;function Xa(n,e,t){let r=Lu(n,t);return[e,...e.map(o=>[o])].map(o=>r.get(Ja(o,t))).find(Boolean)}function Lu(n,e){let t=Je(n),r=new Map(n.map(i=>[i.id,i])),o=new Map;for(let i of n){let s=i.undoes!==void 0&&!t.has(i.id)&&!i.withheld?r.get(i.undoes):void 0;if(s?.suggests&&s.author.kind===i.author.kind&&s.author.id===i.author.id)continue;let a=s?.suggests??(s?.mutation&&(s.lineage||i.undoneLineage)?[s.mutation]:[]);if(a.length>0)for(let d of[a,...a.map(l=>[l])])o.set(Ja(d,e),i)}return o}function Qa(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(Ya(u))return s(`change \u201C${B(n.tryDefinition(u.kind),u)}\u201D`,"a person said to leave it alone");if(!i)continue;let f=Ha(n,u.kind);if(f==="never")return s(`change ${ae(n,u.kind)} on its own`,"the app says they are never tidied");if(d&&f==="no-links")return s(`link or unlink ${ae(n,u.kind)} on its own`,"the app says they are never linked automatically")}if(d&&i&&l[0]&&Ha(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 Zu(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 Kt={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},Gu={under:0,raised:1,over:2},_o=n=>`--graview-layer-${n}`,Ku=n=>`var(${_o(n)}, ${Kt[n]})`;function Bu(){return Object.keys(Kt).map(n=>` ${_o(n)}: ${Kt[n]};`).join(`
|
|
4
|
+
`)}function Vu(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 ed(){return`sub_${(globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`).replace(/-/g,"").slice(0,20)}`}function nd(n){return{...n,id:n.id??ed(),at:n.at??new Date().toISOString()}}function Uu(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=nd(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 Oo=(n,e)=>`${n}\0${e}`,td=new WeakMap;function Wu(n,e){let t=new Map;for(let[o,i]of Object.entries(e??{}))for(let[s,a]of Object.entries(i))t.set(Oo(o,s),[{seq:n-1,by:a}]);return{base:n,end:n,read:[],fields:t,written:[],seqOf:new Map,writers:{writerAt:(o,i,s)=>{let a=t.get(Oo(o,i));if(!a)return;let d=0,l=a.length;for(;d<l;){let u=d+l>>1;a[u].seq<s?d=u+1:l=u}return d===0?void 0:a[d-1].by}}}}function qu(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=>!Ce(n.after[e]))];if(n.op==="splice-text")return[n.id,[n.field]]}function Hu(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=qu(s);if(!a)continue;let[d,l]=a;for(let u of l){let f=e.undoes===void 0?r:o!==void 0?n.writers.writerAt(d,u,o):void 0,c=Oo(d,u),p=n.fields.get(c);p||n.fields.set(c,p=[]),p.push({seq:t,by:f}),i.push(c)}}n.written.push({seq:t,keys:i}),n.seqOf.set(e.id,t),n.read.push(e),n.end++}function Yu(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 nt(n){let e=n.all(),t=typeof n.length=="number"?n.length:e.length,r=t-e.length,o=td.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&&Yu(o,i),r>o.base&&(o.read=o.read.slice(r-o.base),o.base=r))}else o=void 0;o||td.set(n,o=Wu(r,r>0?[...n.epochs?.()??[]].reverse().find(i=>i.horizon)?.writers:void 0));for(let i=o.end;i<t;i++)Hu(o,e[i-r]);return o.writers}function rd(n,e,t,r){let o=nt(n),i={};for(let s of t)for(let a in s){if(!Object.hasOwn(s,a)||a==="id"||a==="kind"||!r(s[a]))continue;let d=o.writerAt(s.id,a,e);d!==void 0&&((i[s.id]??={})[a]=d)}return i}var Xe={served:new WeakSet},tt=n=>n.fields!==void 0||(n.hide?.length??0)>0,od=(n,e,t)=>(n??[]).some(r=>r.kinds.includes(e)&&(r.hide?.includes(t)===!0||r.fields!==void 0&&!r.fields.includes(t))),id=(n,e,t,r)=>Object.entries(t).some(([o,i])=>typeof i=="string"&&i.trim()!==""&&n.includes(i.trim())&&r(e,o)),Ie=n=>Xe.on===!0||Xe.served.has(n);var Po=new WeakMap;function Ju(n,e){let t=new Map(Object.entries(e?.removed??{})),r=new Map(Object.entries(e?.creators??{})),o=n===0||e?.removed!==void 0;return{base:n,end:n,read:[],kinds:t,creators:r,entries:[],records:{kindOf:i=>t.get(i),creatorOf:i=>r.get(i),knowsAll: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 Qu(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 ce(n){let e=n.all(),t=typeof n.length=="number"?n.length:e.length,r=t-e.length,o=Po.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&&Qu(o,i),r>o.base&&(o.read=o.read.slice(r-o.base),o.base=r))}else o=void 0;o||Po.set(n,o=Ju(r,r>0?ef(n,r):void 0));for(let i=o.end;i<t;i++)Xu(o,e[i-r]);return o.records}function ef(n,e){let t=[...n.epochs?.()??[]].reverse().find(r=>r.horizon);return t?.seq===e?t:void 0}function sd(n,e,t){ce(n);let r=Po.get(n),o=[new Set,new Set];for(let a=r.entries.length-1;a>=0&&r.entries[a].seq>=e;a--)o[+r.entries[a].creator].add(r.entries[a].id);let i={},s={};for(let[a,d]of r.creators)o[1].has(a)||(i[a]=d);for(let[a,d]of r.kinds)!o[0].has(a)&&!t(a)&&(s[a]=d);return r.records.knowsAll?{creators:i,removed:s}:{creators:i}}function An(n,e,t,r,o,i=Xe.on===!0){if(!n?.sees?.length||V(e))return!0;let s=n.sees.filter(a=>a.kinds.includes(t.kind)&&(i||!tt(a)));return s.length===0?!1:(e=T(e),s.some(a=>{if(!xe(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 dd=Symbol.for("@graview/core:node-ref"),ad=n=>typeof n=="object"&&n!==null?n[dd]:void 0;function Te(n="*"){return nf(L().check(Kn(1)),n)}function nf(n,e){let t=Object.freeze(e==="*"?["*"]:[...e]),r=o=>{o&&Object.defineProperty(o,dd,{value:t,enumerable:!0,configurable:!0})};return r(n),r(D(n)),n}function rt(n){if(typeof n!="object"||n===null)return;let e=ad(n);if(e)return e;let t=D(n),r=ad(t);if(r)return r;let o=t?.innerType;return o?rt(o):void 0}function ot(n){let e=n.shape;if(!e)return[];let t=[];for(let[r,o]of Object.entries(e)){let i=rt(o);i&&t.push({name:r,kinds:i,optional:o.safeParse(void 0).success})}return t}var Mo=new Set;function Bt(n,e){return V(e)?Mo:n.modules?.disabledKinds??Mo}function Qe(n,e){return V(e)?!1:(n.policy?.sees?.length??0)>0||Bt(n,e).size>0}function fd(n,e){if(!Qe(n,e))return()=>!0;let t=n.modules?.disabledKinds??Mo,r=n.policy?.sees??[],o=T(e),i=Ie(n),s=u=>!t.has(u)&&(r.length===0||r.some(f=>f.kinds.includes(u)&&xe(f,o)&&!f.own&&!f.via&&(i||!tt(f)))),a=n.schema.kinds.every(s),d=u=>s(u)&&tf(n.schema,u).every(f=>f.every(c=>c==="*"?a:s(c))),l=a&&n.schema.kinds.every(d);return u=>l||u!==void 0&&d(u)}function it(n,e){return t=>{let r=Bt(n,e);if(!n.policy?.sees?.length&&r.size===0)return!0;let o=ce(n.log),i=n.graph.getNode(t);if(i)return!r.has(i.kind)&&An(n.policy,e,i,n.graph,o,Ie(n));let s=o.kindOf(t)??pd(n,o,t);return s===void 0?!0:!r.has(s)&&An(n.policy,e,{id:t,kind:s},{out:()=>[],in:()=>[]},o,Ie(n))}}function tf(n,e){let t=n?.tryDefinition?.(e)?.fields?.shape??{};return Object.values(t).flatMap(r=>{let o=rt(r);return o&&r.safeParse?.(void 0).success===!1?[o]:[]})}var rf={out:()=>[],in:()=>[]};function pd(n,e,t){if(e.knowsAll||Xe.served.has(n))return;let r=t.indexOf(":");if(r<=0)return;let o=t.slice(0,r);return n.schema?.tryDefinition(o)?o:void 0}function of(n,e,t=new Map,r){let o=Bt(n,e);if(!n.policy?.sees?.length&&o.size===0)return()=>!0;let i=ce(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)&&An(n.policy,e,l,n.graph,i,Ie(n));else{let u=i.kindOf(s)??pd(n,i,s);if(u===void 0)return r?.add(s),!0;d=!o.has(u)&&An(n.policy,e,{id:s,kind:u},rf,i,Ie(n))}return t.set(s,d),d}}function sf(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 Vt(n,e){return hd(n,e).lens}var zo=()=>({judged:new Map,shown:new Map});function hd(n,e){let t=sf(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,f,c,p,g)=>{let h=(y,S)=>{if(!u(y.id))return;let w;for(let M in y)if(!(!Object.hasOwn(y,M)||M==="id"||M==="kind"||!j(y[M],u))&&!(r!==void 0&&S(M)===r)){if(!t(y.kind,M))return;(w??=[]).push(M)}if(!w)return y;let R=w.join("\0"),P=i.get(y);if(P?.without===R)return P.node;let E=Object.fromEntries(Object.entries(y).filter(([M])=>!w.includes(M)));return i.set(y,{without:R,node:E}),E},v=y=>{let S=c();return h(y,w=>f().writerAt(y.id,w,S))},b=new WeakMap,k=g?y=>{let S=b.get(y);return S||b.set(y,S={node:v(y)}),S.node}:v,$=y=>{if(!u(y))return!1;let S=s.getNode(y);return S===void 0||k(S)!==void 0},x=g?.shown??new Map,_=g?y=>{let S=x.get(y);return S===void 0&&x.set(y,S=$(y)),S}:$,A=s.outEdges&&s.inEdges?{present:{getNode:y=>s.getNode(y),outEdges:y=>s.outEdges(y),inEdges:y=>s.inEdges(y)},log:n.log,get writers(){return f()}}:void 0,m={sees:u,shows:_,served:k,servedWith:h,optional:t,kindOf:p,...r!==void 0?{actor:r}:{},...A?{timeline:A}:{},hides:()=>Qe(n,e),pin:g?()=>m:()=>d(zo())};return Xe.lens?.(m,n,e)??m};function d(u){let f,c=o(),p=ce(n.log);return a(of(n,e,u.judged,u.unnamed),()=>f??=nt(n.log),()=>c,g=>s.getNode(g)?.kind??p.kindOf(g),u)}return{lens:a(it(n,e),()=>nt(n.log),o,u=>s.getNode(u)?.kind??ce(n.log).kindOf(u)),pinWith:d}}var cd=new WeakMap,ld=new WeakMap,af=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"||r.op==="splice-text"?e.add(r.id):(e.add(r.edge.from),e.add(r.edge.to));return e};function gd(n,e){if(!Qe(n,e))return n.log.all();let t=n.log.all(),r=n.log.length??t.length,o=r-t.length,i=[...Bt(n,e)].sort().join("\0"),s=md(e),a=cd.get(n.log);a||cd.set(n.log,a=new Map);let d=a.get(s),{pinWith:l}=hd(n,e),u=ld.get(n.log);u||ld.set(n.log,u=new Set);let f=d!==void 0&&d.horizon===o&&d.off===i&&d.length<=r&&(d.length===o||t[d.length-1-o]===d.last);if(d&&f){if(d.length===r)return d.ops;let g=t.slice(d.length-o),h=l(zo()),v=!0,b=af(g);for(let k of b){let $=d.judgments.judged.get(k),x=d.judgments.shown.get(k);if($!==void 0&&h.sees(k)!==$||x!==void 0&&h.shows(k)!==x){v=!1;break}}if(v){for(let k of b)if(u.has(k)){v=!1;break}}if(v){let k=[...d.ops,...Rn(g,l(d.judgments))],$={horizon:o,off:i,length:r,last:t.at(-1),ops:k,judgments:d.judgments};return a.set(s,$),k}}let c={...zo(),unnamed:u},p=Rn(t,l(c));return a.set(s,{horizon:o,off:i,length:r,last:t.at(-1),ops:p,judgments:c}),p}function df(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 No(n,e){return{all:()=>n,undoneIds:()=>Je(n),epochs:e}}var ud=new WeakMap;function md(n){let e=V(n)?n:T(n);return`${n.kind}|${e.id??""}|${(e.roles??[]).join(",")}|${n.onBehalfOf?`for:${n.id??""}`:""}`}var yd=(n,e)=>`${md(n)}@${e}`,Eo=(n,e)=>{let t=Reflect.get(n,e,n);return typeof t=="function"?t.bind(n):t},cf=Symbol.for("@graview/core:seat");function Se(n,e,t={}){if(bo(n.publishing,e,t.as)){if(q.served)return q.served(n,e);throw new Error("Load @graview/core/publishing to serve a reader of an app that publishes.")}return vd(n,e)}var lf=()=>q.served!==void 0;function bd(n){let e=ud.get(n);return e||ud.set(n,e=new Map),e}function vd(n,e){if(!Qe(n,e))return n;let t=yd(e,"head"),r=bd(n),o=r.get(t);if(o)return o;let i=n.graph,s=Vt(n,e),a=x=>{let _=w=>w===void 0?void 0:x.served(w),A=w=>_(w)!==void 0,m=w=>A(i.getNode(w));return{served:_,seenNode:A,seenId:m,seenEdge:w=>m(w.from)&&m(w.to)&&!j(w,x.sees),servedAll:w=>w.flatMap(R=>_(R)??[])}},{served:d,seenId:l}=a(s),u=()=>a(s.pin?.()??s),f=(x,_)=>{let A=nt(n.log),m=s.pin?.()??s,y=x.nodes.flatMap(w=>m.servedWith(w,R=>A.writerAt(w.id,R,_))??[]),S=new Set(y.map(w=>w.id));return{nodes:y,edges:x.edges.filter(w=>S.has(w.from)&&S.has(w.to)&&!j(w,m.sees))}},c=x=>{let{removed:_,writers:A,published:m,...y}=x,S=f(x.base,x.seq);if(!x.creators)return{...y,base:S};let w=new Set(S.nodes.map(P=>P.id)),R=Object.fromEntries(Object.entries(x.creators).filter(([P,E])=>w.has(P)&&!j(E,s.sees)));return{...y,base:S,creators:R}},p=x=>x&&c(x),g=()=>gd(n,e),h=()=>No(g(),()=>n.log.epochs()),v=new Proxy(i,{get(x,_){switch(_){case"getNode":return A=>d(x.getNode(A));case"has":return l;case"allNodes":case"nodesOfKind":return(...A)=>u().servedAll(x[_](...A));case"count":return(...A)=>u().servedAll(x.nodesOfKind(...A)).length;case"allEdges":case"edgesOfKind":case"outEdges":case"inEdges":return(...A)=>x[_](...A).filter(u().seenEdge);case"out":case"in":case"neighbors":return(A,...m)=>{let y=u();return y.seenId(A)?y.servedAll(x[_](A,...m)):[]};case"snapshot":return()=>{let A=x.snapshot(),m=u();return{...A,nodes:m.servedAll(A.nodes),edges:A.edges.filter(m.seenEdge)}};case"size":{let A=u();return{nodes:A.servedAll(x.allNodes({archived:"all"})).length,edges:x.allEdges({archived:"all"}).filter(A.seenEdge).length}}default:return Eo(x,_)}}}),b=()=>{let x=g();return $o(x,Je(x))},k=new Proxy(n.log,{get(x,_){switch(_){case"all":case"toJSON":return()=>[...g()];case"epochs":return()=>x.epochs().map(c);case"lastEpoch":return()=>p(x.lastEpoch());case"horizonEpoch":return()=>p(x.horizonEpoch());case"live":return()=>{let A=g(),m=Je(A);return A.filter(y=>!m.has(y.id))};case"get":return A=>g().find(m=>m.id===A);case"opsInBatch":return A=>g().filter(m=>m.batch===A);case"batches":return b;default:return Eo(x,_)}}}),$=new Proxy(n,{get(x,_){switch(_){case cf:return{store:x,principal:e};case"graph":return v;case"log":return k;case"snapshot":return v.snapshot;case"batches":return b;case"canUndo":return A=>et(h(),typeof A=="string"?[A]:A);case"violations":return A=>x.violations(A,v).filter(m=>df(s,y=>i.has(y),m));case"findings":return()=>x.findings().filter(A=>(A.id.includes("->")?A.id.split("->").map((y,S)=>S===0?y.slice(y.indexOf(":")+1):y):[A.id]).every(y=>!i.has(y)||l(y))&&!j(A,s.sees));case"wouldChange":return A=>x.wouldChange(A,e);case"preview":return(A,m,y)=>x.preview(A,m,{author:e,...y});case"seenBy":return(A,m)=>Se(x,A,m);case"seenFor":return e;case"servedSeq":return x.servedSeq;case"checkpoint":return A=>p(x.checkpoint(A));default:return Eo(x,_)}}});return r.set(t,$),$}q.kit={seatView:vd,viewsOf:bd,viewKey:yd,diff:ze,reads:bo};var Io=new Set;function To(n,e){if(!n||e===void 0)return{enabled:new Set(Object.keys(n??{})),disabledKinds:Io,disabledMutations:Io,disabledInvariants:Io,administered:wd(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:wd(n,t)}}function wd(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 xd(n){return n.normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase().trim().replace(/\s+/g," ")}var Ut=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=xd(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=jo(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=B(this.graph.schema.tryDefinition(e.kind),e),r=xd(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(jo(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=jo(r.sorted,t.key);r.sorted[i]===t.key&&r.sorted.splice(i,1)}};function jo(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 uf(n,e){return e.includes("*")?"record":e.map(t=>Y(n.tryDefinition(t),t)).join(" or ")}function kd(n,e,t,r){let o=uf(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}.`}}function Do(n){if(n===null||typeof n!="object")return JSON.stringify(n)??"null";if(Array.isArray(n))return`[${n.map(r=>r===void 0?"null":Do(r)).join(",")}]`;let e=n;return`{${Object.keys(e).filter(r=>e[r]!==void 0).sort().map(r=>`${JSON.stringify(r)}:${Do(e[r])}`).join(",")}}`}var Sd=(n,e)=>n.key<e.key?-1:n.key>e.key?1:0;function ff(n){let e=n.nodes.map(r=>({key:r.id,value:r})).sort(Sd),t=n.edges.map(r=>({key:N(r),value:{kind:r.kind,from:r.from,to:r.to,id:r.id,data:r.data}})).sort(Sd);return Do({nodes:e.map(r=>r.value),edges:t.map(r=>r.value)})}function _n(n){return`sha256:${$d(ff(n))}`}function Rd(n,e,t,r={}){let o=r.validate??!0,i=r.base??{nodes:[],edges:[]},s=_n(t),a=ee.from(n,i,{validate:o});for(let[h,v]of e.entries())try{a.applyPrimitives(v.primitives)}catch(b){let k=e[h-1];return{ok:!1,expected:_n(a.snapshot()),actual:s,...k?{divergedAfter:k.id}:{},reason:`The log does not fold: op "${v.id}" (${v.intent}) could not be applied. ${b instanceof Error?b.message:String(b)}`}}let d=_n(a.snapshot());if(d===s)return{ok:!0,hash:s};let l=h=>{let v=ee.from(n,i,{validate:o});for(let b=0;b<=h;b++)v.applyPrimitives(e[b].primitives);return _n(v.snapshot())},u=h=>{try{let v=ee.from(n,t,{validate:o});for(let b=e.length-1;b>h;b--)v.applyPrimitives(Ge(e[b]));return _n(v.snapshot())}catch{return}},f=h=>{let v=u(h);return v!==void 0&&v!==l(h)},c=-1,p=e.length-1;for(;c<p;){let h=Math.floor((c+p)/2);f(h)?p=h:c=h+1}let g=p>=0?e[p]: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 pf=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]),hf=new TextEncoder,gf=new Uint32Array(64),mf=new Uint32Array(8),Wt=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function $d(n){let e=hf.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=mf;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=gf;for(let d=0;d<r.length;d+=64){for(let b=0;b<16;b++)s[b]=o.getUint32(d+b*4);for(let b=16;b<64;b++){let k=s[b-15],$=s[b-2],x=(k>>>7|k<<25)^(k>>>18|k<<14)^k>>>3,_=($>>>17|$<<15)^($>>>19|$<<13)^$>>>10;s[b]=s[b-16]+x+s[b-7]+_>>>0}let l=i[0],u=i[1],f=i[2],c=i[3],p=i[4],g=i[5],h=i[6],v=i[7];for(let b=0;b<64;b++){let k=(p>>>6|p<<26)^(p>>>11|p<<21)^(p>>>25|p<<7),$=p&g^~p&h,x=v+k+$+pf[b]+s[b]>>>0,_=(l>>>2|l<<30)^(l>>>13|l<<19)^(l>>>22|l<<10),A=l&u^l&f^u&f,m=_+A>>>0;v=h,h=g,g=p,p=c+x>>>0,c=f,f=u,u=l,l=x+m>>>0}i[0]=i[0]+l>>>0,i[1]=i[1]+u>>>0,i[2]=i[2]+f>>>0,i[3]=i[3]+c>>>0,i[4]=i[4]+p>>>0,i[5]=i[5]+g>>>0,i[6]=i[6]+h>>>0,i[7]=i[7]+v>>>0}let a="";for(let d=0;d<8;d++){let l=i[d];a+=Wt[l>>>24]+Wt[l>>>16&255]+Wt[l>>>8&255]+Wt[l&255]}return a}var st=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 yf(n,e){return{...e,name:n}}function Fo(n){if(!n.creates?.length)return!1;let e=n.input.shape;return e===void 0||!("id"in e)}function Pd(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 Fo(n)?[...r,"id"]:r}var Ad=(n,e,t={})=>{let r=n.filter(s=>t[s]?.length),o=n.filter(s=>!t[s]?.length);return`${[...o.length>0?[`does not take ${o.map(s=>`"${s}"`).join(", ")}`]:[],...r.map(s=>`${s} is set by ${t[s].join(" or ")}`)].join("; ")}; it takes ${e.length>0?e.map(s=>`"${s}"`).join(", "):"nothing"}`};function bf(n){let e=n?._zod?.def;for(let t=0;e?.innerType&&t<8;t++)e=e.innerType._zod?.def;return e}var vf=/^-?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?$/;function Ed(n,e){let t=n?.shape;if(!t||typeof e!="object"||e===null||Array.isArray(e))return e;let r;for(let[o,i]of Object.entries(e)){if(typeof i!="string"||!vf.test(i)||bf(t[o])?.type!=="number")continue;let s=Number(i);Number.isFinite(s)&&(r??={...e},r[o]=s)}return r??e}var Md=n=>typeof n=="string"&&n.length<=200&&/^[^\s\p{Cc}]+$/u.test(n);function wf(n){if(typeof n!="object"||n===null)return;let e=n.id;if(e!==void 0){if(!Md(e))throw new z("An id is 1\u2013200 characters with no space",`Got ${JSON.stringify(e)}.`);return e}}function xf(n){let{id:e,...t}=n;return t}function _d(n){return n.normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"")||"item"}function Lo(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 kf(n,e){if(e.limited&&e.me===void 0)return Od(n,e.held);let t=e.limited?`${n}.${Lo(e.me)}`:n,r=t;for(let o=2;e.seen(r);o++)r=`${t}-${o}`;return e.held(r)?Od(t,e.held):r}function Od(n,e){let t;do t=`${n}-${Math.floor(Math.random()*36**6).toString(36).padStart(6,"0")}`;while(e(t));return t}function On(n,e,t,r={}){let o=Fo(e)?wf(t):void 0,i=Ed(e.input,o===void 0?t:xf(t)),s=Pd(e);if(s&&typeof i=="object"&&i!==null&&!Array.isArray(i)){let m=Object.keys(i).filter(y=>!s.includes(y)&&i[y]!==void 0);if(m.length>0)throw new pe(e.name,[{path:[],message:Ad(m,s,e.writtenBy)}])}let a=e.clearable&&typeof i=="object"&&i!==null&&!Array.isArray(i)?e.clearable.filter(m=>i[m]===null):[],d=e.input.safeParse(a.length>0?Object.fromEntries(Object.entries(i).filter(([m])=>!a.includes(m))):i);if(d.success)for(let m of a)d.data[m]=null;if(!d.success){let m=Object.keys(e.input.shape??{});throw new pe(e.name,d.error.issues.map(y=>y.code==="unrecognized_keys"&&m.length>0?{...y,message:Ad(y.keys,m,e.writtenBy)}:y))}let l=d.data,u=new st(r.seen??n),f=[],c=new Set,p=r.me===void 0?void 0:`.${Lo(r.me)}`,g=m=>!r.seesInFull||r.seesInFull()||p!==void 0&&new RegExp(`\\${p}(-[0-9a-z]+)?$`).test(m),h=m=>u.has(m)||n.has(m)||c.has(m)||r.everHeld?.(m)===!0,v,b=m=>{let y=new Set([...n.outEdges(m),...n.inEdges(m)]);for(let S of y)u.getNode(S.from),u.getNode(S.to),f.push({op:"remove-edge",edge:S});return y},k={graph:u,schema:n.schema,me:r.me,emit(m){f.push(m)},addNode(m){f.push({op:"add-node",node:m})},removeNode(m){let y=u.getNode(m)&&n.getNode(m);if(!y)throw new W(m,`Cannot remove missing node "${m}"`);b(m),f.push({op:"remove-node",node:y})},patchNode(m,y){let S=u.getNode(m)&&n.getNode(m);if(!S)throw new W(m,`Cannot patch missing node "${m}"`);let w={},R={};for(let[P,E]of Object.entries(y)){let M=S[P];JSON.stringify(M)===JSON.stringify(E)&&!r.keepUnchanged?.(E,P,S)||(w[P]=M,R[P]=E)}Object.keys(R).length!==0&&f.push({op:"patch-node",id:m,before:w,after:R})},archiveNode:m=>k.patchNode(m,{[vn]:!0}),unarchiveNode:m=>k.patchNode(m,{[vn]:void 0}),mergeNode(m,y){let S=u.getNode(y)&&n.getNode(y);if(!S)throw new W(y,`Cannot merge into missing node "${y}"`);if(m===y||We(S))throw new z(m===y?"Cannot merge a record into itself":"Cannot merge into an archived record");let w=new Set([...n.outEdges(y),...n.inEdges(y)].map(N));for(let R of b(m)){let P={...R,from:R.from===m?y:R.from,to:R.to===m?y:R.to};P.from!==P.to&&!w.has(N(P))&&(w.add(N(P)),f.push({op:"add-edge",edge:P}))}k.archiveNode(m),v=y},addEdge(m){f.push({op:"add-edge",edge:m})},removeEdge(m){f.push({op:"remove-edge",edge:m.id!==void 0&&n.linkById(m.id)||m})},setSingleSource(m,y,S){n.inEdges(y,m).some(w=>w.from===S)||f.push({op:"add-edge",edge:{kind:m,from:S,to:y}});for(let w of n.inEdges(y,m))u.getNode(w.from),w.from!==S&&f.push({op:"remove-edge",edge:w})},freshId(m,y,S){if(o!==void 0&&!c.has(o)){if(y&&!o.startsWith(`${y}:`)){let Z=o.includes(":")?o.slice(o.indexOf(":")+1):o;throw new z(`Id "${o}" does not say its kind: ask for "${y}:${Z||o}"`,`Every ${y} id starts "${y}:", the ones "${e.name}" mints and the ones a caller asks for alike, so a later call names it as it names the rest.`)}if(!g(o))throw new z(`"${e.name}" makes its own id here`,`Leave id out${p?`, or end it "${p}"`:""}.`);if(h(o))throw new z(`Id "${o}" is already taken`,`"${e.name}" was asked to make a node with that id, and the graph has or had one. Pick another, or leave id out and let the act mint one.`);return c.add(o),o}let w=r.hint;if(o===void 0&&!c.size&&Md(w)&&(!y||w.startsWith(`${y}:`))&&g(w)&&!h(w))return c.add(w),w;y&&r.keeps&&[l,S??{}].some(Z=>id(m,y,Z,r.keeps))&&(m=y);let R=y?`${y}:${_d(m)}`:_d(m),P=r.seesInFull!==void 0&&!r.seesInFull(y),M=kf(R,{seen:Z=>(r.seen?r.seen.has(Z):n.has(Z))||c.has(Z)||!P&&r.everHeld?.(Z)===!0,held:h,limited:P,me:r.me});return c.add(M),M}};if(e.apply(k,l),o!==void 0&&!c.has(o))throw new z(`"${e.name}" did not make a record with id "${o}": it names what it makes itself`);let $=r.check?.(f,e),x=new Set(f.flatMap(Ae)),_=new st(r.seen??n),A=e.describe?.(l,_)??`${e.name}(${Object.entries(l).map(([m,y])=>`${m}=${JSON.stringify(y)}`).join(", ")})`;return{primitives:f,reads:[...new Set([...u.reads(),..._.reads()])],...e.describe?{described:[..._.reads(),...$??[]]}:{},writes:[...x],intent:A,...v!==void 0?{mergedInto:v}:{},...c.size>0?{firstMinted:c.values().next().value}:{}}}function Zo(n,e,t,r,o,i){if(typeof r!="string"||typeof o!="string")return n.allowedOn===void 0;if(n.allowedOn)return n.allowedOn(t,r);let s=n.subject?.arg??"id",a=n.input.shape??{},d=t.getNode(r)?.[o],l={[s]:r,...o!==s&&o in a&&d!==void 0&&d!==null?{[o]:d}:{}},u=n.input.safeParse?.(l),f=u?.success?u.data:l,c=()=>{},p={graph:t,schema:e,me:i,addNode:c,removeNode:c,patchNode:c,archiveNode:c,unarchiveNode:c,mergeNode:c,addEdge:c,removeEdge:c,setSingleSource:c,freshId:(g,h)=>`${h?`${h}:`:""}${g}`,emit:c};try{n.apply(p,f)}catch(g){let h=g;return!(h?.name==="ActRefusal"&&h.reason!=="invalid")}return!0}var zd=Symbol.for("@graview/core:amount"),lx=(n,e)=>(Object.defineProperty(D(n),zd,{value:e,enumerable:!0}),n);function Co(n,e=!0){let t=D(n);return t?.[zd]??(e&&t?.innerType?Co(t.innerType):void 0)}function Nd(n,e={}){let t=Number.isInteger(n),r={maximumFractionDigits:t?0:2,minimumFractionDigits:t?0:2};try{return me(n,e.locale,e.currency?{style:"currency",currency:e.currency,...r}:r)}catch{return me(n,e.locale,r)}}function Id(n,{format:e,unit:t,currency:r,locale:o}){let i=/^[A-Z]{3}$/.test(t??"");return e==="money"||!e&&i?Nd(n,{...o?{locale:o}:{},...(i?t:r)?{currency:i?t:r}:{}}):e==="percent"?me(n,o,{style:"percent",maximumFractionDigits:0}):me(n,o)+(t?` ${t}`:"")}var Sf=Symbol.for("@graview/core:typed-field");function Go(n){let e=D(n);return e?e[Sf]??Go(e.innerType):void 0}var Rf=/^[("'“‘]*(?:(?:[a-z]{1,3}\.){2,}|(?:dr|mr|mrs|ms|mx|st|mt|vs|jr|sr|prof|no|fig|approx)\.)$/i;function $f(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]==="."&&Rf.test(r))&&!(t.split(" ").length<3&&e.index+1<n.length))return t}}function Td(n,e=140){let t=n.replace(/^[#>\s]+|\*\*|`|\](\([^)\s]*\))?|\[/gm,"").replace(/\s+/g," ").trim(),r=$f(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 Ko(n){let e=n.fields.shape;return Object.keys(e).flatMap(t=>{let r=zt(e[t])?qn(t):void 0;return r&&e[r]?[r]:[]})}var Af=[["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 jd(n,e){let t=new Set(e.map(o=>o.name)),r=[];for(let o of n.definitions){let i=Ko(o);if(i.length===0)continue;let s=o.kind,a=o.fields.shape,d=at(n,e).get(s),l=new Set(o.keptInStep??[]),u=g=>(d?.get(g)?.length??0)>0&&!l.has(g),f=je(o).filter(g=>!u(g)),c=Object.fromEntries(je(o).filter(u).map(g=>[g,d.get(g)])),p=g=>B(o,g);for(let[g,h,v,b]of Af){let k=`${g}-${s}`;t.has(k)||r.push({name:k,derived:{kind:s,act:g},title:h,description:v,subject:{kinds:[s],arg:"id"},writes:i.map(yn),...g==="skip"?{}:{creates:[s],...Object.keys(c).length>0?{writtenBy:c}:{}},input:gn({id:Te([s]),on:L().check(Bn(/^\d{4}-\d{2}-\d{2}$/,"a day, like 2026-10-21")),...i.length>1?{field:Q(aa(i))}:{},...g==="skip"?{}:Object.fromEntries(f.map($=>[$,Q(a[$])]))}),describe:($,x)=>b.replace("{}",p(x.getNode(String($.id))??{id:$.id}))+Oe(String($.on)),apply($,x){let _=$.graph.getNode(String(x.id)),A=String(x.field??i[0]),m=_?.[A],y=_?.[yn(A)],S=String(x.on);if(typeof m!="string"||!bn(y))throw new se(`${p(_??{id:x.id})} does not repeat`,"refused");let w=mn(m,y,{from:S,to:S})[0];if(!w)throw new se(`${p(_)} does not fall on ${Oe(S)}`,"refused");let R=String(_.id),P=Object.fromEntries(f.filter(H=>x[H]!==void 0).map(H=>[H,x[H]])),E=yn(A),M=H=>{let fr=Object.fromEntries(Object.entries({..._,...H,...P}).filter(([ht,pr])=>pr!=null&&ht!=="id")),vi=$.freshId(p(fr),s,fr);$.addNode({...fr,id:vi,kind:s});for(let ht of Object.keys(o.edges??{}))for(let pr of $.graph.out(R,ht))$.addEdge({kind:ht,from:vi,to:pr.id})};if(g!=="split"){$.patchNode(R,{[E]:{...y,except:[...new Set([...y.except??[],S])].sort()}}),g==="detach"&&M({[A]:w,[E]:null});return}if(Object.keys(P).length===0)throw new se(`Nothing to change: give ${p(_)} from ${Oe(S)} something new`,"invalid");if(S<=m.slice(0,10))return $.patchNode(R,P);let Z=new Date(Date.parse(`${S}T00:00:00Z`)-864e5).toISOString().slice(0,10),Ze=y.count?mn(m,{...y,except:[]},{to:Z}).length:0,{count:an,except:C,...le}=y,G=H=>C?.some(H)?{except:C.filter(H)}:{};$.patchNode(R,{[E]:{...le,until:Z,...G(H=>H<S),...an?{count:Ze}:{}}}),M({[A]:w,[E]:{...le,...G(H=>H>=S),...an?{count:an-Ze}:{},continues:R}})}})}}return r}function Dd(n,e,t,r){if(n==="detach")return!0;if(n!=="split"||typeof e.on!="string")return!1;let o=t?.[String(e.field??r[0])];return typeof o!="string"||e.on>o.slice(0,10)}function Fd(n,e){let t=new Set(e.map(a=>a.name)),r=e.filter(a=>!a.derived&&!a.creates?.length),o=(a,d,l,u)=>r.some(f=>{if(!(f[a]??[]).includes(l))return!1;let c=f.subject?.kinds;return c===void 0||c==="*"||c.includes(d)||u.to==="*"||c.some(p=>u.to.includes(p))}),i=[],s=(a,d)=>{let l=a.getNode(String(d));return l?B(n.tryDefinition(l.kind),l):String(d)};for(let a of n.definitions){let d=a.kind,l=Object.entries(a.edges??{}),u=f=>f.to==="*"?"record":f.to.map(c=>Y(n.tryDefinition(c),c)).join(" or ");for(let[f,c]of l){let p=u(c),g=c.cardinality==="one",h=l.some(([x,_])=>x!==f&&u(_)===p),v=x=>K(x).toLowerCase(),b=qa(d,f,c,v),k={to:b&&"to"in b?b.to:p,from:Y(a,d),one:g,also:b&&"also"in b?b.also:h&&!b?v(f):void 0},$=k.from;for(let x of ko){let _=So(x,d,f);if(t.has(_)||c.acts==="none"||(x==="connect"?o("connects",d,f,c):o("severs",d,f,c)||c.appendOnly))continue;let{title:A,fromTheOtherEnd:m}=Wa(x,k),y=c.description?`: ${c.description.replace(/\.$/,"")}`:"";i.push({name:_,derived:{kind:d,act:x,relation:f},title:A,fromTheOtherEnd:m,description:x==="connect"?`Link this ${$} to ${/^[aeiou]/i.test(p)?"an":"a"} ${p}${y}.${g?" It has one, so this replaces the one it has.":""}`:`Take away the link between this ${$} and ${/^[aeiou]/i.test(p)?"an":"a"} ${p}${y}. Undo puts it back.`,subject:{kinds:[d],arg:"id"},...x==="connect"?{connects:[f]}:{severs:[f],destructive:!0},idempotent:!0,input:gn({id:Te([d]),to:Te(c.to==="*"?"*":c.to)}),describe:(S,w)=>x==="disconnect"?`Unlink ${s(w,S.id)} from ${s(w,S.to)}`:g?`Set the ${p} of ${s(w,S.id)} to ${s(w,S.to)}`:`Link ${s(w,S.id)} to ${s(w,S.to)}`,apply(S,w){let R=String(w.id),P=String(w.to);for(let M of[R,P])if(!S.graph.getNode(M))throw new se(`there is no record "${M}"`,"invalid");let E=S.graph.out(R,f).some(M=>M.id===P);if(x==="disconnect"){if(!E)throw new se(`${s(S.graph,R)} is not linked to ${s(S.graph,P)}`,"invalid");S.removeEdge({kind:f,from:R,to:P});return}if(g)for(let M of S.graph.out(R,f))M.id!==P&&S.removeEdge({kind:f,from:R,to:M.id});E||S.addEdge({kind:f,from:R,to:P})}})}}}return i}function _f(n){let e=new Set(n.declared),t=[...new Set([...(n.paged??[]).filter(o=>e.has(o)),...n.declared])],r=(n.naming??[]).filter(o=>e.has(o));return[...new Set([...r,...t.filter(n.must),...t])]}var Bo=n=>`\xA7${n}\xA7`;function Of(n,e){if(n.label)try{let r={id:Bo(e.length),kind:n.kind};e.forEach((s,a)=>r[s]=Bo(a));let o=String(n.label(r)),i=e.map((s,a)=>[s,o.indexOf(Bo(a))]).filter(([,s])=>s>=0);if(i.length>0)return i.sort((s,a)=>s[1]-a[1]).map(([s])=>s)}catch{}let t=["name","title","label"].find(r=>e.includes(r));return t?[t]:[]}var Ld=new WeakMap;function qt(n){let e=Ld.get(n);if(e)return e;let t=n.fields.shape??{},r=Object.keys(t),o=n.display?.page,i=_f({declared:r,paged:[...o?.fields??[],...(o?.groups??[]).flatMap(s=>s.fields)],must:s=>t[s]?.safeParse?.(void 0).success===!1&&!Object.hasOwn(n.defaults??{},s),naming:Of(n,r)});return Ld.set(n,i),i}function Pf(n,e){let t=e.subject?.kinds,r=e.creates?.[0]??e.derived?.kind??(t!==void 0&&t!=="*"&&t.length===1?t[0]:void 0);return r===void 0?void 0:n.tryDefinition(r)}function Ef(n,e){let t=Object.keys(e.input?.shape??{}),r=n?Pf(n,e):void 0;if(!r)return t;let o=qt(r),i=d=>d!==e.subject?.arg&&o.includes(d),s=t.filter(i).sort((d,l)=>o.indexOf(d)-o.indexOf(l)),a=0;return t.map(d=>i(d)?s[a++]:d)}function Vo(n,e,t=r=>r.name){let r=o=>{let i=e.indexOf(t(o));return i<0?e.length:i};return[...n].sort((o,i)=>r(o)-r(i))}function je(n){let e=n.fields.shape;return Object.keys(e).filter(t=>!(t in(n.fixed??{})))}function Uo(n,e){let t=e.subject;return t?t.kinds==="*"?n.kinds:t.kinds:[]}function Wo(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(ot(n.input).map(s=>s.name));return Object.keys(o).filter(s=>s!==t.arg&&r.has(s)&&!i.has(s))}function at(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 Uo(n,o)){let s=n.tryDefinition(i);if(s)for(let a of Wo(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 Cd(n,e,t){let r=n.tryDefinition(t);if(!r)return[];let o=at(n,e).get(t);return je(r).filter(i=>!o?.has(i))}var Gd=n=>`edit-${n}`;function Kd(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),Uo(n,i).includes(t)&&Wo(i,r).length>0&&o.add(i.name));return[...o]}function Bd(n,e){let t=new Set(e.map(o=>o.name)),r=[];for(let o of n.definitions){let i=o.kind,s=Gd(i);if(t.has(s))continue;let a=new Set((o.keptInStep??[]).filter(h=>je(o).includes(h))),d=Cd(n,e,i),l=Vo(je(o).filter(h=>d.includes(h)||a.has(h)),qt(o),h=>h);if(l.length===0)continue;let u=at(n,e).get(i),f=Object.fromEntries(je(o).flatMap(h=>!l.includes(h)&&u?.get(h)?.length?[[h,u.get(h)]]:[])),c=o.fields.shape,p=Y(o,i),g=l.map(h=>wt(o,h).toLowerCase());r.push({name:s,derived:{kind:i,act:"edit"},idempotent:!0,title:`Change the ${p}`,description:`Change what was set when this ${p} was made: ${g.join(", ")}.`,subject:{kinds:[i],arg:"id"},writes:l,...Object.keys(f).length>0?{writtenBy:f}:{},...l.some(h=>Zd(c[h]))?{clearable:l.filter(h=>Zd(c[h]))}:{},input:gn({id:Te([i]),...Object.fromEntries(l.map(h=>[h,Q(Nf(c[h]))]))}),describe:(h,v)=>Mf(o,c,l,h,v),apply(h,v){let b={};for(let k of l){let $=v[k];$===null?b[k]=void 0:$!==void 0&&(b[k]=$)}if(Object.keys(b).length===0)throw new se(`Nothing to change \u2014 give at least one of ${g.join(", ")} a value.`,"invalid");h.patchNode(v.id,b)}})}return r}function Mf(n,e,t,r,o){let i=o.getNode(r.id),s=i?B(n,i):"a record",a=t.filter(d=>r[d]!==void 0).map((d,l)=>{let u=r[d],f=qn(d),c=f!==void 0&&f in e,p=wt(n,c?f:d);return`the ${p===p.toUpperCase()?p:_i(p)}${l===0?` of ${s}`:""} to ${c?u?`repeat ${zf(u)}`:"stop repeating":Vd(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 zf=n=>`every ${(n.interval??1)>1?`${n.interval} ${n.every}s`:n.every}`;function Vd(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(Vn(r).length>0)return Vn(r).map(i=>i.name).join(", ");if(Un(e))return Array.isArray(r)&&r.length>1?`${r.length} linked records`:"a linked record";if(Array.isArray(r))return r.map(i=>Vd(n,e,t,i)).join(", ");if(typeof r=="boolean")return r?"yes":"no";if(typeof r=="number"){let i=Co(e);return i?Id(r,i):Go(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(br.test(r))return Oe(r);if(mt.test(r))return wr(r);for(let i=D(e);i;i=D(i.innerType))if(i.type==="enum")return K(r);return`\u201C${Td(r,60)}\u201D`}function Zd(n){return n._zod?.def?.type==="optional"}function Nf(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 Ht(n,e){return n.filter(t=>!t.derived&&(t.creates??[]).includes(e)).map(t=>t.name)}function Yt(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"?Kd(n,e,t.derived.kind):Ht(e,t.derived.kind)}function If(n,e){let t=new Set(e.map(o=>o.name)),r=[];for(let o of n.definitions){let i=o.kind,s=Y(o,i),a=(l,u)=>{let f=l.getNode(String(u));return f?B(o,f):String(u)},d=Te([i]);for(let[l,u,f,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 p=`${l}-${i}`,g=l==="leave-alone"||l==="allow-tidying";t.has(p)||!g&&l!=="remove"&&o.archives===!1||g&&o.tidying==="never"||r.push({name:p,derived:{kind:i,act:l},title:f,description:c,subject:{kinds:[i],arg:"id"},...l==="remove"?{destructive:!0}:{},idempotent:!0,input:Me(l==="merge"?{id:d,into:d}:{id:d}),describe:(h,v)=>{let b=l==="remove"&&v.getNode(String(h.id)),k=b?new Set(Object.values(b).flatMap(_=>Vn(_).map(A=>A.href))).size:0,$=l==="merge"&&a(v,h.id)===a(v,h.into),x=_=>$?`${a(v,_)} (${String(_)})`:a(v,_);return`${u} ${x(h.id)}${l==="merge"?` into ${x(h.into)}`:""}${k?` and its ${k} file${k>1?"s":""}`:""}`},apply:g?(h,v)=>h.patchNode(String(v.id),{[Yn]:l==="leave-alone"?!0:void 0}):(h,v)=>h[`${l}Node`](v.id,v.into)})}}return r}function qo(n,e){return[...Bd(n,e),...If(n,e),...jd(n,e),...Fd(n,e)]}var Tf=n=>({$made:n}),Jt=n=>typeof n=="object"&&n!==null&&Object.keys(n).join()==="$made"&&Number.isInteger(n.$made)&&n.$made>=0,jf=(n,e)=>Object.fromEntries(Object.entries(n.args??{}).map(([t,r])=>[t,Array.isArray(r)?r.map(e):e(r)])),Ud=n=>Object.values(n.args??{}).some(e=>Jt(e)||Array.isArray(e)&&e.some(Jt)),Wd=(n,e,t)=>({...n,args:jf(n,r=>{if(!Jt(r))return r;let o=r.$made<t?e[r.$made]:void 0;if(o===void 0)throw new Error(`\u201C${n.name}\u201D names the record call ${r.$made+1} makes, and no call before it made that record.`);return o})});var Df=500,Ff=120,Lf=50,Zf=200,qd=4e3,Cf=["model","suggestion","interaction","actor","run"],Hd=n=>typeof n=="string"&&n.length>0&&n.length<=Ff,Gf=n=>typeof n=="string"&&n.length<=240&&n.lastIndexOf("#")>0&&n.lastIndexOf("#")<n.length-1,Kf=n=>{let e=JSON.stringify(n);return e===void 0?void 0:JSON.parse(e)};function dt(n){if(n===void 0)return;let e=n&&typeof n=="object"&&!Array.isArray(n)?n:{},t=typeof e.basis=="string"?e.basis.trim():"",r={basis:t},o=t!==""&&t.length<=Df;for(let i of Object.keys(e)){let s=e[i];i==="basis"||s===void 0||(i==="model"&&typeof s=="string"&&(s=s.trim()),i==="confidence"?o&&=typeof s=="number"&&s>=0&&s<=1:Cf.includes(i)?o&&=Hd(s):i==="evidence"?o&&=Array.isArray(s)&&s.length<=Lf&&s.every(Hd):i==="read"?o&&=Array.isArray(s)&&s.length<=Zf&&s.every(Gf):o&&=i!=="__proto__"&&i!=="constructor"&&i!=="prototype"&&(s=Kf(s))!==void 0,o&&(r[i]=s))}if(!o)throw new z("A lineage is { basis: 1 to 500 characters, confidence?: 0 to 1, model?, suggestion?, interaction?, actor?, run?: 1 to 120 characters, evidence?: up to 50 ids, read?: up to 200 <id>#<field> }");if(JSON.stringify(r).length>qd)throw new z(`A lineage is at most ${qd} characters written out.`);return r}var Pn="keep-link";function Yd(n){let e=(t,r)=>{let o=t.getNode(r);return o?B(n.tryDefinition(o.kind),o):r};return{name:Pn,title:"Keep this link",input:Me({kind:L(),from:L(),to:L()}),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 d=N({kind:o,from:i,to:s});throw new W(d,`Cannot remove missing edge ${d}`)}let a=t.graph.edgesOfKind(o,{archived:"all"}).find(d=>d.from===i&&d.to===s)??{kind:o,from:i,to:s};t.removeEdge(a),t.addEdge(a)}}}var Ho=(n,e)=>[...n].filter(t=>!t.derived&&t.name!==Pn&&typeof e=="string"&&(t.connects?.includes(e)||t.severs?.includes(e))).map(t=>t.name);var Jd=["kind-unknown","node-shape","edge-dangling","edge-disallowed","rule-error","rule-budget"];function Xd(n,e){let t=jt(n,e);return t&&[...t.fields].filter(Boolean)}function Bf(n,e,t){return n.tryDefinition(e)?.fields?.shape?.[t]}function Xt(n,e){try{return B(n.tryDefinition(e.kind),e)}catch{return typeof e.label=="string"?e.label:"A record"}}var Vf=n=>`${n.kind}:${n.from}->${n.to}`,Qt=(n,e)=>n<e?-1:n>e?1:0;function Qd(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(p=>p.from===c||p.to===c),a=c=>({action:"drop",primitives:[...s(c.id).filter(p=>i.has(p.from)&&i.has(p.to)).map(p=>({op:"remove-edge",edge:p})),{op:"remove-node",node:c}]}),d=new Set;for(let c of[...i.values()].sort((p,g)=>Qt(p.id,g.id))){if(!r.tryDefinition(c.kind)){d.add(c.id),o.push({code:"kind-unknown",id:c.id,message:`${Xt(r,c)} is a kind of record this app no longer has`,repair:a(c)});continue}let p=Xd(r,c);if(p===void 0)continue;let g=Xt(r,c),h=new Map,v=p.length>0;for(let b of p){if(b==="id"||b==="kind"){v=!1;continue}let k=Bf(r,c.kind,b),$=k?k.safeParse(void 0):{success:!0,data:void 0},x=r.tryDefinition(c.kind)?.defaults;!$.success&&k&&x&&Object.hasOwn(x,b)&&($=k.safeParse(x[b])),$.success?$.data===void 0?h.set(b,{action:"clear",value:ue}):h.set(b,{action:"coerce",value:$.data}):v=!1}if(v){let b={...c};for(let[k,$]of h)$.value===ue?delete b[k]:b[k]=$.value;Xd(r,b)!==void 0&&(v=!1)}if(p.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 b of p){let k=h.get(b),$=v&&k?{action:k.action,primitives:[{op:"patch-node",id:c.id,before:{[b]:c[b]===void 0?ue:c[b]},after:{[b]:k.value}}]}:a(c);o.push({code:"node-shape",id:c.id,detail:b,message:`${g}: ${K(b)} does not fit what ${c.kind} declares`,repair:$})}}let l=new Set,u=[];for(let c of[...e.edges].sort((p,g)=>Qt(N(p),N(g)))){if(l.has(N(c)))continue;l.add(N(c));let p=Vf(c),g=i.get(c.from),h=i.get(c.to);if(!g||!h){o.push({code:"edge-dangling",id:p,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:p,message:`${Xt(r,g)} \u2192 ${Xt(r,h)}: this app does not allow that link between them`,repair:{action:"drop",primitives:[{op:"remove-edge",edge:c}]}}))}let f=n.invariants??[];if(f.length>0){let c=ee.from(r,{nodes:[...i.values()],edges:u},{validate:!1}),p=new Set,g;try{g=kn(c,f,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 v=h.status==="could-not-judge"?"rule-error":h.status==="over-budget"?"rule-budget":void 0;if(!v)continue;let b=h.subjectId??h.invariant,k=`${v}|${b}|${h.invariant}`;p.has(k)||(p.add(k),o.push({code:v,id:b,detail:h.invariant,message:h.message}))}}return o.sort((c,p)=>Jd.indexOf(c.code)-Jd.indexOf(p.code)||Qt(c.id,p.id)||Qt(c.detail??"",p.detail??""))}var ct=()=>globalThis.__graviewWatch;function ec(n){ct()?.store?.(n)}function er(n){n!==void 0&&ct()?.learn?.({ids:[n],words:[]})}function nc(n,e){ct()?.refused?.({...n,...e===void 0?{}:{author:e}})}function Yo(n,e){let t=ct();if(!t?.refusedInput)return;let r=n.issues.map(o=>`${o.path.map(String).join(".")}: ${o.message}`).join("; ");t.refusedInput({mutation:n.mutation,message:r,...e===void 0?{}:{author:e}})}function Uf(n,e){n instanceof pe&&Yo(n,e)}function Wf(n,e,t){ct()?.seat?.(n,e,t)}function Xo(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 ne(e,t)}var Jo=15*6e4;function tc(n=Date.now(),e){let t=new Date(n).getTime(),r=yt(e),o=ne(r,t),i=new Date(Date.parse(`${o}T00:00:00Z`));if(i.setUTCDate(i.getUTCDate()+1),!r)return i.getTime()-t;let s=Si(i.toISOString().slice(0,10),0,r);for(;ne(r,s)===o;)s+=Jo;for(;ne(r,s-Jo)!==o;)s-=Jo;return s-t}function qf(n,e){let t,r=()=>{t=setTimeout(()=>{let o=n.tick(new Date);r(),e?.(o)},tc(Date.now(),n.timeZone)+1e3),t.unref?.()};return r(),()=>clearTimeout(t)}var nr=class extends z{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"}},Qo="preview",F=(n,e)=>e===void 0?{}:{[n]:e},en={kind:"human"},rc={kind:"system"},sc={kind:"system",id:"modules",name:"Modules"},oc=n=>n.mutation===null&&n.undoes===void 0;function ei(n,e){return`${n.invariant}|${n.subjectId??""}|${n.line||e?.has(n.invariant)?n.label:n.message}`}var Hf=new Set(["remove","archive","unarchive","merge"]),Yf={has:()=>!0},ac=n=>new Set(n.filter(e=>e.shape).map(e=>e.name));function dc(n,e,t){let r=ac(n),o=f=>ei(f,r),i=new Set(e.map(o)),s=new Set(t.map(o)),a=t.filter(f=>!i.has(o(f))),d=e.filter(f=>!s.has(o(f)));if(a.length===0||d.length===0)return{introduces:a,resolves:d};let l=f=>f.subjectId&&ei(f,Yf),u=d.map(l);return{introduces:a.filter(f=>{let c=l(f)?u.indexOf(l(f)):-1;return c<0||(u[c]=null,!1)}),resolves:d.filter((f,c)=>u[c]!==null)}}var En=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"}},tr=class extends z{constructor(t,r){let o=Ro(t,r);super(`Unknown mutation "${t}"${o?` \u2014 did you mean "${o}"?`:""}`,`Registered: ${r.join(", ")||"(none)"}`);this.mutation=t;this.name="UnknownMutationError",this.nearest=o}nearest},ic=n=>new Map(n.map(e=>[e.id,e.batch]));function Jf(){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 ni=class n{schema;graph;log;mutations=new Map;keeper;typer;invariants;invariantOptions;policy;publishing;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:ne(this.timeZone),on:ne(this.timeZone)}),this.policy=e.policy,this.publishing=e.publishing,this.by=e.principal??en,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=Jf();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 z(`Duplicate mutation "${i.name}"`);this.mutations.set(i.name,i)}for(let i of e.past?[]:qo(e.schema,e.mutations??[]))this.mutations.set(i.name,i);!e.past&&!this.mutations.has(Pn)&&(this.keeper=Yd(e.schema),this.mutations.set(Pn,this.keeper));let r=F("horizon",e.horizon),o={validate:this.validate};if(e.log){this.log=$n.from(e.log,e.epochs,r);let i=this.log.lastEpoch();this.graph=e.snapshot?ee.from(e.schema,e.snapshot,o):this.log.fold(e.schema,{...o,...i?{from:i}:{}})}else this.log=$n.from([],e.epochs??(e.snapshot?[{seq:e.horizon??0,base:e.snapshot}]:[]),r),this.graph=ee.from(e.schema,e.snapshot??{nodes:[],edges:[]},o);e.past||(this.countPastTheLog(),ec(this))}stillNow(){if(this.past)throw new nr(this.past)}countPastTheLog(){this.countPast(this.log.all())}countPast(e){let t=r=>{let o=/(\d+)$/.exec(r);return o?Number(o[1]):0};for(let r of e)this.counter=Math.max(this.counter,t(r.batch)),this.opCount=Math.max(this.opCount,t(r.id));this.log.horizon>0&&(this.opCount=Math.max(this.opCount,this.log.length))}get servedSeq(){return this.log.length}get publishedSeq(){return q.seq?.(this)}get publisher(){return q.act?.(this,this.mutations)}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}}o??=this.log.horizonEpoch()?.enabledModules;let s=r&&o===r.said?r.projection:To(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=To(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(f=>{let c=this.declaredModules?.[f]?.kinds??[];return c.length>0?c.map(p=>ae(this.schema,p)).join(", "):f}).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:sc,intent:ln(d),mutation:null,primitives:[],reads:[],writes:[],at:this.now(),...F("via",t.via),enabledModules:[...o].sort()};return this.log.append(l),this.notify(Jn,[l]),l}mutation(e){let t=this.mutations.get(this.spelled(e))??(e===Ct?this.publisher:void 0);if(!t)throw new tr(e,[...this.mutations.keys()]);if(this.mutationDisabled(t))throw new z(`Mutation "${e}" belongs to a module this workspace has turned off`,`Enabled modules: ${[...this.modules.enabled].join(", ")||"(none)"}`);return t}spelled(e){return e===Zt&&!this.typer&&ie.typeText&&!this.past&&!this.mutations.has(e)&&this.mutations.set(e,this.typer=ie.typeText(this)),this.mutations.has(e)?e:Gt(e,this.mutations.keys())??e}spelledCall(e){let t=this.spelled(e.name);return t===e.name?e:{...e,name: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(),...this.publisher?[this.publisher]:[]].filter(e=>e!==this.keeper&&e!==this.typer&&!this.mutationDisabled(e))}viaOf(e,t,r){if(e!==void 0&&e===this.keeper){let o=Ho(this.mutations.values(),t?.args.kind);if(o.length>0)return o;let i=[...this.mutations.values()];return[...new Set(i.filter(s=>s.derived?.relation===t?.args.kind).flatMap(s=>Yt(this.schema,i,s)??[]))]}if(e!==void 0&&e===this.typer){let o=r===void 0||V(r)?this.graph:Se(this,r).graph,i=s=>!this.mutationDisabled(s)&&Zo(s,this.schema,o,t?.args.node,t?.args.field,r&&T(r).id);return ie.via(this.schema,[...this.mutations.values()],this.subjectKindOf(t,r),t?.args.field,i)}if(e?.derived)return Yt(this.schema,[...this.mutations.values()],e)}moved(e,t){return dc(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=en){if(e=this.spelledCall(e),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)??(e.name===Ct?this.publisher:void 0);if(o&&o===this.publisher)return q.verdict(this,t);let i=o!==void 0&&o===this.keeper&&Ho(this.mutations.values(),e.args.kind).length===0,s=i?e.args.from:o?.subject&&e.args[o.subject.arg],a=this.subjectKindOf(e,t),d=ke(this.policy,t,e.name,a,this.viaOf(o,e,t),typeof s=="string"?s:void 0,this.words,()=>{let l=T(t).id,u=this.namedIn(e,!1);try{for(let f of On(this.graph,o,e.args,this.sighted(t)).primitives)"edge"in f&&f.edge.from!==l&&f.edge.to!==l&&u.push(f.edge.to)}catch{}return u},o!==void 0&&(o.derived!==void 0||o===this.typer||i)?()=>this.madeBy(o,e,s):void 0,o?.derived!==void 0&&Hf.has(o.derived.act));return!d.ok||!o?.derived||!this.repeatMakes(o,e,s,t)?d:ke(this.policy,t,e.name,a,Ht([...this.mutations.values()],o.derived.kind),typeof s=="string"?s:void 0,this.words)}repeatMakes(e,t,r,o){let i=e.derived.act;if(i!=="detach"&&i!=="split")return!1;let s=this.schema.tryDefinition(e.derived.kind);if(!s)return!1;let a=typeof r=="string"?(V(o)?this.graph:Se(this,o).graph).getNode(r):void 0;return Dd(i,t.args,a,Ko(s))}madeBy(e,t,r){let o=ce(this.log),i=o.creatorOf(r),s=t.args.into;if(!(e.derived?.act==="merge"&&typeof s=="string"&&o.creatorOf(s)!==i))return i}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]]:[],...ot(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&&nc(e,t),new He(e)}get words(){return{act:e=>this.mutations.get(e)?.title,noun:e=>Y(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=rc){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,everHeld:o=>ce(this.log).kindOf(o)!==void 0,keeps:(o,i)=>od(this.policy?.sees,o,i)};if(e===void 0||!Qe(this,e))return t;let r=it(this,e);return{...t,seen:Se(this,e).graph,keepUnchanged:o=>j(o,r),seesInFull:fd(this,e)}}collaborative(e,t){return ie.collaborative?.(this.schema,this.graph.getNode(e)?.kind,t)??!1}asSplices(e,t){return ie.asSplices?ie.asSplices(this,e,t):e}missingFor(e,t=en){e=this.spelledCall(e);let r=this.mutations.get(e.name),o=new Set(this.namedIn(e));if(!r||o.size===0)return;let i=Se(this,t).graph;for(let s of o)if(!i.has(s))return new W(s,`\u201C${r.title??e.name}\u201D names a record that is not there.`)}mayAdminister(e,t=en){let r=this.modules.administered.get(e);return r?(r.mutations??[]).some(o=>{let i=this.mutations.get(o);return!!i&&mo(i).some(s=>ke(this.policy,t,o,s,this.viaOf(i)).ok)}):!1}seenBy(e,t){return Se(this,e,t)}sees(e,t){return this.graph.has(t)&&it(this,e)(t)}labels;resolveRef(e,t,r=en){let o=(this.policy?.sees?.length??0)>0,i=c=>!o||this.sees(r,c),s=this.graph.getNode(t);if(this.labels??=new Ut(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 p=c.filter(g=>!this.graph.isArchived(g));return p.length?p:c},l=d(a.exact.filter(i)),u=l.length>0,f=(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,p)=>c.label<p.label?-1:c.label>p.label?1:c.id<p.id?-1:1);return f.length===1?{ok:!0,id:f[0].id,label:f[0].label,by:u?"label":"prefix"}:kd(this.schema,e,t,f)}kindsKeptFrom(e=en){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=Ie(this);for(let s of this.schema.kinds)!r.some(d=>d.kinds.includes(s)&&xe(d,e)&&(!d.own&&!d.via||e.id!==void 0)&&(i||!tt(d)))&&!o.has(s)&&t.add(s)}return t}permittedMutations(e=en){let t=this.allMutations(),r=go(this.policy,e,t.filter(s=>!s.derived&&s!==this.publisher)),o=this.publisher&&q.verdict(this,e).ok?[this.publisher]:[],i=t.filter(s=>s.derived!==void 0&&ke(this.policy,e,s.name,s.derived.kind,this.viaOf(s),T(e).id).ok);return[...r,...o,...i]}subjectKindOf(e,t=rc){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)&&!Se(this,t).graph.has(i)))return this.graph.getNode(i)?.kind}today(){return this.pinned()??(this.ticked&&this.ticked.on===ne(this.timeZone)?this.ticked.day:void 0)??(this.timeZone?ne(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=ba(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=Xo(e,this.timeZone),o=ne(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(Jn,[]);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(Jn,[])}violations(e,t=this.graph){return kn(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 On(this.graph,this.mutation(e.name),e.args,this.sighted(t)).primitives.length>0}catch{return!0}}preview(e,t,r={}){e=this.spelledCall(e);let o=this.mutation(e.name),i=On(this.graph,o,e.args,this.sighted(r.author));return this.previewPrimitives(this.asSplices(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;Object.assign(e,{graph:ee.from(this.schema,this.graph.snapshot(),{validate:this.validate}),log:$n.from(this.log.all(),this.log.epochs(),{horizon:this.log.horizon}),listeners:new Set,labels:void 0,nextId:()=>`${Qo}:${++t}`,mintBatch:()=>Qo,rehearsing:!0});let r=this.typer&&ie.typeText(e);return Object.assign(e,{typer:r,mutations:r?new Map(this.mutations).set(Zt,r):new Map(this.mutations)}),e}previewPrimitives(e,t){let r=this.violations(t.context),o=ee.from(this.schema,this.graph.snapshot()),i=o.applyPrimitives(e,{restoring:t.restoring===!0}),s=kn(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){let o=e.map(w=>this.spelledCall(w));this.stillNow();let i=t.batch??this.mintBatch("batch"),s=t.author??this.by,a=dt(t.lineage),d=[],l=[],u=new Set,f=new Set,c=[],p=this.violations(r),g=this.graph.snapshot(),h=this.log.length,v=w=>{let R=this.policy||this.publisher&&w.name===Ct?this.permits(w,s):void 0;R&&!R.ok&&this.refuse(R.refusal,s.id)},b=w=>{let R=this.refusesAgent(w,s)??this.namesTurnedOff(w,s);R&&this.refuse(R,s.id)},k=o.map(Ud);o.forEach((w,R)=>k[R]||v(w)),o.forEach((w,R)=>k[R]||b(w));let $=Ao(s);$&&this.refuseDeclined(o,s),this.rehearsing||er(s.id);let x=[],_=[],A=new Map,m=w=>typeof w=="string"?A.get(w)??w:Array.isArray(w)?w.map(m):w;try{for(let[w,R]of o.entries()){let{mintedHint:P,...E}=R,M=A.size?{...E,args:Object.fromEntries(Object.entries(E.args).map(([G,H])=>[G,m(H)]))}:E,Z=k[w]?Wd(M,x,w):M;k[w]&&(v(Z),b(Z));let Ze=this.mutation(Z.name);if(Ze===this.publisher){let G=q.op(this,{id:this.nextId(),at:this.now()},Z,i,s,t);d.push(G),c.push(G.intent);continue}let an=this.missingFor(Z,s);if(an)throw an;let C;try{C=On(this.graph,Ze,Z.args,{...this.sighted(s),hint:P})}catch(G){throw G instanceof pe&&!this.rehearsing&&Yo(G,s.id),G}if(P!==void 0&&C.firstMinted!==void 0&&C.firstMinted!==P&&A.set(P,C.firstMinted),$){let G=Qa(this.schema,this.graph,C.primitives,this.authorName(s),{declaration:!this.suggesting});G&&this.refuse({mutation:Z.name,message:G,wouldNeed:[]},s.id)}if(C.primitives.length===0)continue;_[w]=C.firstMinted,x[w]=C.primitives.find(G=>G.op==="add-node")?.node.id;let le={id:this.nextId(),seq:this.log.length,batch:i,author:s,intent:Ze.describe!==void 0?C.intent:t.intent??C.intent,...F("batchIntent",t.intent),mutation:Z,primitives:this.asSplices(C.primitives,t.base).map(Nn),reads:C.reads,writes:C.writes,...Ze.describe!==void 0&&C.described&&C.described.length>0?{described:C.described}:{},...F("mergedInto",C.mergedInto),at:this.now(),...F("via",t.via),...F("lineage",a)};this.graph.applyPrimitives(le.primitives),this.log.append(le),d.push(le),l.push(...le.primitives);for(let G of le.reads)u.add(G);for(let G of le.writes)f.add(G);c.push(le.intent)}}catch(w){throw this.putBack(g,h),w}let y=Ne(g,this.graph.snapshot(),l);this.admitted(t,d,l,y,g,h);let S=this.violations(r);return this.notify(y,d),{batch:i,ops:d,..._.length>0?{minted:_}:{},diff:y,primitives:l,reads:[...u],writes:[...f],intent:t.intent??c.join("; "),...this.moved(p,S),violationsAfter:S}}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 En(d,l)}let a=this.log.length;for(let[d,l]of o.entries()){let u=In({...l,seq:a+d});this.log.append(u),s.push(u)}return this.countPast(s),this.notify(Ne(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(Nn),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,reads:a.reads??[],writes:a.writes??[...new Set(l.flatMap(Ae))],at:a.at??this.now(),...F("undoes",a.undoes),...F("via",a.via),...F("lineage",dt(a.lineage))};if(r.has(u.id))throw new z(`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 En(a,d)}for(let a of i)this.log.append(a);this.countPast(i);for(let a of i)er(a.author.id);return this.notify(Ne(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=dt(t.lineage),l=this.asSplices(e,t.base).map(Nn),u=[];if(l.length>0){let p={id:this.nextId(),seq:this.log.length,batch:r,author:o,intent:a,mutation:null,primitives:l,reads:[],writes:[...new Set(l.flatMap(Ae))],at:this.now(),...F("via",t.via),...F("lineage",d)};this.graph.applyPrimitives(p.primitives),this.log.append(p),u.push(p),er(o.id)}let f=this.violations(),c=Ne(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,f),violationsAfter:f}}findings(){return Qd({schema:this.schema,invariants:this.allInvariants()},this.graph.snapshot(),{invariantOptions:this.invariantOptions})}batches(){return this.log.batches()}canUndo(e){return et(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=Ka(r.ops,this.log.all()),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(oc),...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 v=et(No(Rn(this.log.all(),Vt(this,o)),()=>this.log.epochs()),r);if(!v.ok)throw new qe(v)}let s=this.canUndo(r);if(!s.ok)throw new qe(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=dt(t.lineage),l=this.undoRefusal(s.ops,o);l&&this.refuse(l,o.id,!0);let u=this.graph.snapshot(),f=this.violations(),c=[],p=this.log.length;for(let{op:v,primitives:b}of xo(this.log.all(),s.ops)){let k={id:this.nextId(),seq:this.log.length,batch:a,author:o,intent:`Undo: ${v.intent}`,...F("batchIntent",t.intent),mutation:null,primitives:b,reads:v.reads,writes:v.writes,at:this.now(),undoes:v.id,...F("via",t.via),...F("lineage",d),...F("undoneLineage",v.lineage)};this.graph.applyPrimitives(k.primitives,{restoring:oc(v)}),this.log.append(k),c.push(k)}let g=Ne(u,this.graph.snapshot(),c.flatMap(v=>[...v.primitives]));this.admitted(t,c,c.flatMap(v=>[...v.primitives]),g,u,p);let h=this.violations();return this.notify(g,c),{batch:a,ops:c,diff:g,primitives:c.flatMap(v=>[...v.primitives]),reads:[...new Set(c.flatMap(v=>[...v.reads]))],writes:[...new Set(c.flatMap(v=>[...v.writes]))],intent:t.intent??c.map(v=>v.intent).join("; "),...this.moved(f,h),violationsAfter:h}}mayUndo(e,t=this.by){let r=this.canUndo(e);if(!r.ok)return{ok:!1,check:r};let o=this.undoRefusal(r.ops,t);return o?{ok:!1,refusal:o}:{ok:!0}}undoRefusal(e,t){if(this.policy||this.publisher)for(let r of e){let o=this.rootOf(r),i=T(o.author).id;if(!o.mutation){if(o.primitives.length===0)continue;if(this.policy&&!V(t)&&i!==T(t).id&&!this.grantsEveryAct(t))return{mutation:"undo",wouldNeed:[],message:`Not permitted to undo "${r.intent}": no act made it, so only whoever did may take it back.`};continue}let s=d=>JSON.stringify(d).includes(JSON.stringify(i)),a=i!==void 0&&i!==T(t).id&&!V(t)&&!s(o.mutation.args)&&s(o.primitives)?{ok:!1,refusal:{mutation:o.mutation.name,wouldNeed:[],message:"it was done as somebody else."}}:this.permits(o.mutation,t);if(!a.ok)return{...a.refusal,message:`Not permitted to undo "${r.intent}": ${a.refusal.message}`}}}rootOf(e){let t=e;for(let r=t.undoes===void 0?void 0:this.log.get(t.undoes);r!==void 0;r=t.undoes===void 0?void 0:this.log.get(t.undoes))t=r;return t}grantsEveryAct(e){let t=T(e);return(this.policy?.grants??[]).some(r=>xe(r,t)&&r.mutations==="*"&&(r.kinds===void 0||r.kinds==="*")&&!r.self&&!r.ownEnd)}authorName(e){return Hn(e,{graph:this.graph,schema:this.schema})}actMeanings(){return{act:e=>this.mutations.get(this.spelled(e)),has:e=>this.graph.has(e)}}refuseDeclined(e,t){let r=Xa(this.log.all(),e,this.actMeanings());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&&_a(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 z(`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 z(`Cannot rebase across an epoch: one begins at seq ${d.seq}, after pending op "${i[0].id}"`);let l=this.graph.snapshot(),u=[],f=[],c=[];this.quiet++;try{for(let k of[...i].reverse())this.graph.applyPrimitives(Ge(k),{restoring:!0,inPlace:!0});this.log.truncate(s);let h=new Set(this.log.all().map(k=>k.id));for(let k of e.confirmed){if(h.has(k.id))continue;try{this.graph.applyPrimitives(k.primitives,{restoring:k.undoes!==void 0})}catch(x){throw new En(k,x)}let $=In({...k,seq:this.log.length});this.log.append($),h.add(k.id),u.push($)}this.countPast(u);let v=ie.carried?.(i,u,e.pending),b=ic(i);for(let k of e.pending){let $=i.filter(x=>x.batch===k);if($.length!==0)try{f.push(...this.replay(k,$,v?.get(k),b))}catch(x){c.push({batch:k,error:x})}}}catch(h){this.log.truncate(s);for(let v of i)this.log.append(v);throw this.graph.load(l),h}finally{this.quiet--}let p=ze(l,this.graph.snapshot()),g=[...u,...f];return this.notify(p,g),{diff:p,confirmed:u,pending:f,refused:c}}adopt(e){this.stillNow();let t=new Set(e.drop??[]),r=(e.pending??[]).filter(p=>!t.has(p)),o=this.log.all(),i=this.graph.snapshot(),s={ops:[...o],epochs:[...this.log.epochs()],horizon:this.log.horizon},a=new Set(o.map(p=>p.id)),d=new Map(r.map(p=>[p,o.filter(g=>g.batch===p)]));if(e.log.length>0)this.log.replace(e.log,e.epochs,F("horizon",e.horizon));else{let p=e.horizon??0;this.log.replace([],e.epochs??[{seq:p,base:e.snapshot}],{horizon:p})}let l=[],u=[];this.quiet++;try{this.graph.load(e.snapshot),this.projected=void 0,this.countPastTheLog();for(let p of r){let g=d.get(p)??[];if(g.length!==0)try{l.push(...this.replay(p,g,void 0,ic(o)))}catch(h){u.push({batch:p,error:h})}}}catch(p){throw this.log.replace(s.ops,s.epochs,{horizon:s.horizon}),this.graph.load(i),this.projected=void 0,p}finally{this.quiet--}let f=this.log.all().filter(p=>!a.has(p.id)&&!l.includes(p)),c=ze(i,this.graph.snapshot());return this.notify(c,[...f,...l]),{diff:c,adopted:f,pending:l,refused:u}}replay(e,t,r,o=new Map){let i=t[0],s={author:i.author,batch:e,...F("intent",i.batchIntent),...F("via",i.via),...F("lineage",i.lineage)};if(i.undoes!==void 0){let a=t.map(l=>this.log.get(l.undoes??"")?.batch??o.get(l.undoes??"")),d=t.find((l,u)=>a[u]===void 0||!this.log.all().some(f=>f.batch===a[u]));if(d)throw new z(`What "${d.intent}" took back is no longer in the log`);return this.undoing([...new Set(a)],s).ops}return r?this.applying(r,s).ops:t.every(a=>a.mutation!==null)?this.applying(t.map(a=>a.mutation),s).ops:this.append(t.map(({seq:a,...d})=>d))}snapshot(){return this.graph.snapshot()}verify(){let e=this.log.lastEpoch();return Rd(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 l=this.log.length-(e.keepOps??1e3),f=Date.parse(e.now??this.now())-(e.keepDays??90)*864e5,c=t.find(g=>Date.parse(g.at)>f),p=c?c.seq:this.log.length;r=Math.min(l,p)}let o=yo(this.publishing)&&this.publishedSeq===void 0?[0]:[],i=[...e.pins??[],...o].filter(l=>Number.isInteger(l));for(i.length>0&&(r=Math.min(r,...i)),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 s=this.verify();if(!s.ok)throw new z(`Cannot compact a store that does not verify: ${s.reason}`);let a=this.log.horizonEpoch()?.published??[],d=(q.behind?.(this,r)??[]).flatMap(l=>l>=this.log.horizon?[this.epochAt(l)]:a.filter(u=>u.seq===l));return{...this.epochAt(r),...d.length>0&&{published:d}}}epochAt(e){let t=this.log.all(),{creators:r,removed:o,writers:i,published:s,...a}=this.log.checkpointAt(this.schema,e,{validate:this.validate}),d=new Set(a.base.nodes.map(g=>g.id)),{creators:l,removed:u}=sd(this.log,e,g=>d.has(g)),f=ce(this.log),c=rd(this.log,e,a.base.nodes,g=>j(g,h=>!d.has(h)&&f.kindOf(h)===void 0)),p=g=>g&&Object.keys(g).length>0;return{...a,...p(l)&&{creators:l},...u&&{removed:u},...p(c)&&{writers:c},...F("enabledModules",t.slice(0,e-this.log.horizon).reverse().find(g=>g.enabledModules)?.enabledModules??this.log.horizonEpoch()?.enabledModules),...F("publishedThrough",q.seq?.(this,e))}}compact(e){return this.stillNow(),this.log.compact(e)}};var Xf=n=>`lens:${n}`,Qf={hidden:[],removed:[],may:{views:!1,lenses:!1}};function ep(n,e,t){return n.name!==void 0&&e.may.views?"view":n.declared&&e.may.lenses&&t.lens?"lens":null}var cc=["full","summary","glyph"],lt="view:",ri=(n,e)=>n.as===e.as&&(n.over??[n.kind]).includes(e.kind),np=n=>n.filter((e,t)=>!n.slice(0,t).some(r=>ri(r,e))),tp=n=>n.filter(e=>!e.hidden);function Re(n){return n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function ut(n,e){return`/${Re(n.tryDefinition(e)?.plural??`${e}s`)}`}function rp(n,e,t){return`${ut(n,e)}/${encodeURIComponent(t)}`}function op(n,e){return`/places/${encodeURIComponent(n)}${e?`?of=${encodeURIComponent(e)}`:""}`}function lc(n,e){return e.some(t=>t.as===n.as&&!ri(n,t))}function ip(n,e,t){return lc(n,e)?`${n.title} \xB7 ${(t.tryDefinition(n.kind)?.plural??`${n.kind}s`).toLowerCase()}`:n.title}var nn=(n,e,t="")=>`${n}|${e.cardinality}|${e.fidelity}|${t}`;function ti(n){switch(n){case"full":return["full","summary","glyph"];case"summary":return["summary","full","glyph"];case"glyph":return["glyph","summary","full"]}}function sp(n){let e=new Map,t=[],r=[],o,i=[],s={arrange(a){return a!==void 0&&(o=a),s},arrangement:()=>o,home(a,d){return a!==void 0&&i.push({view:a,...d?.name!==void 0?{name:d.name}:{}}),s},homeView:()=>i.at(-1)?.view,homes:()=>i,register(a,d,l,u){let f={...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}:{},...f};if(r.push(c),!u?.beside&&!f.hidden&&e.set(nn(a,d),c),u?.title){let p=Re(u.title);e.set(nn(a,d,p),c),d.cardinality==="many"&&!t.some(g=>g.kind===a&&g.as===p)&&t.push({kind:a,title:u.title,as:p,...u.across?{across:u.across}:{},...f,...u.lens?{lens:u.lens}:{},...u.reads?.length?{reads:u.reads}:{}})}return s},places:()=>t,forget(a,d){for(let u of cc)e.delete(nn(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(nn(a,d))?.view},resolve(a,d,l){if(l)for(let u of ti(d.fidelity)){let f=e.get(nn(a,{cardinality:d.cardinality,fidelity:u},l));if(f)return f}for(let u of ti(d.fidelity)){let f=e.get(nn(a,{cardinality:d.cardinality,fidelity:u}));if(f)return f}if(d.cardinality==="one")for(let u of ti(d.fidelity)){let f=e.get(nn(a,{cardinality:"many",fidelity:u}));if(f)return f}},registrations:()=>r,all(){return[...e.values()]},kindsWithViews(){return[...new Set([...e.values()].map(a=>a.kind))]}};return s}var ap=["day","week","month","year","decade"];function uc(n){let e={};n.q&&n.q.trim().length>0&&(e.query=n.q);let t=oo(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,...ap.includes(o)?{bucket:o}:{}})}return e}function oi(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 rr(n,e,t){let r=oi(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 dp(n,e,t){let r=oi(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 ft={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"]}},cp=20,pc=Object.keys(ft),lp=(n,e,t,r=ft[n].options)=>({message:`The ${n} lens takes no option "${e}", so "${t}" ignores it.`,fix:r.length?`Use one of: ${r.join(", ")}.`:`The ${n} lens takes no options; drop it.`}),hc=n=>Object.hasOwn(ft,n);function ii(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 Mn=n=>typeof n=="object"&&n!==null&&!Array.isArray(n);function fc(n,e,t){let r=n.tryDefinition(e)?.fields.shape,o=D(r?.[t]);for(;o&&(o.type==="optional"||o.type==="default"||o.type==="nullable"||o.type==="prefault");)o=D(o.innerType);return o?.type!=="enum"?[]:(o.entries?Object.values(o.entries):o.values??[]).filter(s=>typeof s=="string")}function up(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}`,f=typeof d.title=="string"&&d.title.trim().length>0?d.title.trim():void 0,c=(m,y)=>{t.push({index:l,name:d.name,...f?{title:f}:{},why:m}),y&&r.push({severity:"warning",...y})};if(!hc(d.name)){f?c(`"${d.name}" is not a lens this framework draws`,{code:"lens-not-shipped",path:`${u}.name`,message:`"${f}" names the lens "${d.name}", which the framework does not ship, so nothing draws it.`,fix:`Name one of ${pc.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(!f)return c("it has no title, so it is bindings the checker holds and no place");let p=ft[d.name],g=Mn(d.options)?d.options:{};if(d.options!==void 0&&!Mn(d.options))return c("its options are not an object",{code:"lens-options-not-an-object",path:`${u}.options`,message:`"${f}" has options that are not an object.`,fix:'Write them as { "<option>": <value> }, or drop them.'});for(let m of Object.keys(g))p.options.includes(m)||r.push({severity:"warning",code:"lens-option-unknown",path:`${u}.options.${m}`,...lp(d.name,m,f,p.options)});let h={};for(let m of p.options)g[m]!==void 0&&(h[m]=g[m]);d.arrangedBy&&(h.arrangedBy=uc(d.arrangedBy));let v=Mn(d.bindings)?d.bindings:{},b=[],k,$=(m,y,S)=>c(y,{code:"lens-cannot-draw",path:m,message:`"${f}" cannot draw: ${y}.`,fix:S});if(p.binds==="fields"){let m=Object.keys(v).filter(S=>Mn(v[S])),y=m.filter(S=>!o.has(S));if(m.length===0)return $(`${u}.bindings`,"it binds no kind",`Bind a kind's fields: "bindings": { "<kind>": { ${p.requiredRoles.map(S=>`"${S}": "<field>"`).join(", ")} } }.`);if(y.length>0)return;if(h.bindings=v,b=m,d.name==="timeline"){let S=g.columns;if(Array.isArray(S))h.columns=S.map(w=>typeof w=="string"?{id:w,label:w}:w);else{let w=m.flatMap(P=>{let E=v[P],M=typeof E.column=="string"?E.column:typeof E.columns=="string"?E.columns:void 0;return M?fc(n.schema,P,M):[]}),R=[...new Set(w)];if(R.length===0)return $(`${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=R.map(P=>({id:P,label:P.toUpperCase()}))}h.extent===void 0&&(h.extent=1440)}if(d.name==="columns"){if(h.sort!==void 0){let w=m.map(R=>rr(h.sort,s(R),R)).find(Boolean);w&&(r.push({severity:"warning",code:"lens-sort",path:`${u}.options.sort`,message:`"${f}" cannot order its cards: ${w}.`,fix:'Write { "by": "<a field>", "direction": "asc" }, or drop it.'}),delete h.sort)}let S=new Set;for(let w of m){let R=v[w].column;if(typeof R!="string"||!s(w).includes(R))return;let P=fc(n.schema,w,R);if(P.length===0)return $(`${u}.bindings.${w}.column`,`its column field "${R}" is not a choice`,`Bind "column" to a choice field of ${w}, like a status.`);for(let E of P)S.add(E)}typeof h.move!="boolean"&&delete h.move,Number.isInteger(h.cap)&&h.cap>=1&&h.cap<=500||delete h.cap;for(let w of["collapsed","hidden"])ii(h,w,R=>S.has(R))}if(d.name==="calendar"&&h.today!==void 0&&!(typeof h.today=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(h.today)))return $(`${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 S=h.horizon,w=E=>E===void 0||Number.isInteger(E)&&E>=1&&E<=9999,R=typeof S=="number"?{years:S,title:"Years"}:S;Mn(R)&&Number.isInteger(R.years)&&R.years>=1&&R.years<=200&&typeof R.title=="string"&&R.title.trim().length>0&&w(R.from)&&w(R.to)&&Object.keys(R).every(E=>["years","title","from","to"].includes(E))&&!(typeof R.from=="number"&&typeof R.to=="number"&&R.to<R.from)?h.horizon=R:(delete h.horizon,r.push({severity:"warning",code:"lens-horizon",path:`${u}.options.horizon`,message:`"${f}" 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 $(`${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(p.binds==="entities"){let m=w=>{let R=v[w];if(Mn(R)){if(typeof R.kind=="string")return R.kind;if(typeof R.edge=="string")return R.edge;if(Array.isArray(R.path))return{path:R.path};if(typeof R.field=="string")return R.field}};for(let w of p.requiredRoles)if(m(w)===void 0)return;let y=d.name==="coverage"?"rows":d.name==="board"?"slots":"regions",S=m(y);if(!o.has(S))return;if(d.name==="coverage"){let w=m("columns");if(!o.has(w))return;let R=m("link");if(typeof R=="string"&&!i.has(R))return;Object.assign(h,{rows:S,columns:w,link:R}),w!==S&&(k=w);for(let[P,E]of[["sort",S],["columnSort",w]]){if(h[P]===void 0)continue;let M=rr(h[P],s(E),E);M&&(r.push({severity:"warning",code:"lens-sort",path:`${u}.options.${P}`,message:`"${f}" cannot order its ${P==="sort"?"rows":"columns"}: ${M}.`,fix:`Write { "by": "<a field of ${E}>", "direction": "asc" }, or drop it.`}),delete h[P])}}else if(d.name==="board"){Object.assign(h,{slots:S,x:m("x"),y:m("y"),fill:m("fill")});for(let w of["x","y"])if(!s(S).includes(h[w]))return}else{Object.assign(h,{regions:S,outline:m("outline")});for(let w of["markers","at","within","nests","regionKind","markerKind"]){let R=m(w);typeof R=="string"&&(h[w]=R)}}b=[S]}else if(d.name==="blocks"){if(!d.on)return $(`${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 $(`${u}.options.blocks`,"it has no blocks to draw",`Say "options": { "blocks": [{ "headline": "\u2026" }, { "list": "all('<kind>')", "as": "card" }] }.`)}else{let m=["user","person","member"].find(y=>o.has(y));if(!d.on&&!m)return $(`${u}.on`,"it does not say which kind it stands on",'Say "on": "<the kind whose records are the people>".');b=m?[m]:[]}if(d.on!==void 0){if(typeof d.on!="string"||!o.has(d.on))return $(`${u}.on`,`it stands on "${String(d.on)}", which is not a kind`,`Use one of: ${[...o].join(", ")}.`);if(b=[d.on],d.name==="coverage"){let m=[h.rows,h.columns].find(y=>y!==d.on);k=typeof m=="string"?m:void 0}}let x=typeof h.rows=="string"?h.rows:b[0];if(x!==void 0){let m=["label",...s(x)],y=new Set(["is",...m,...Object.keys(n.schema.tryDefinition(x)?.edges??{})]);ii(h,"search",S=>m.includes(S)),ii(h,"filters",S=>y.has(S.split(".")[0]))}let _=Re(f);if(_.length===0)return $(`${u}.title`,"its title has no letters or digits to make an address of","Give it a title a person would say.");for(let m of b){let y=`${m}|${_}`;if(a.has(y))return c(`another lens on ${m} is already called "${f}"`,{code:"lens-title-taken",path:`${u}.title`,message:`"${f}" is the title of lenses.${a.get(y)} too, on the same kind, so one address would name two pictures.`,fix:"Give each its own title."})}for(let m of b)a.set(`${m}|${_}`,l);let A=d.create;A!==void 0&&typeof A!="boolean"&&r.push({severity:"warning",code:"lens-create",path:`${u}.create`,message:`"${f}" says create ${JSON.stringify(A)}, 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:f,as:_,kinds:b,...k?{across:k}:{},options:h,...d.hidden===!0?{hidden:!0}:{},...A===!1?{create:!1}:{}})}),{drawn:e,undrawn:t,findings:r}}var fp=6;function pp(n,e,t=[]){let r=n.kinds,o=s=>Object.values(n.tryDefinition(s)?.edges??{}).map(a=>(a.to==="*"?r: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 hp(n,e,t){if(!n?.primary)return;let r=new Set(n.primary.map(Re));return{kinds:new Set(e.kinds.filter(o=>r.has(Re(o))||r.has(ut(e,o).slice(1)))),places:new Set(t.filter(o=>r.has(o.as)||r.has(Re(o.title))||o.name!==void 0&&n.primary.includes(lt+o.name)).map(o=>`${o.kind}|${o.as}`))}}var gc="overview",gp=`/places/${gc}`;function mp(n){let e=n?.scene?.trim();return e||"Scene"}function yp(n){let e=n?.pages?.trim();return e||"Pages"}function bp(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 mc(n){return n.startsWith(lt)&&n.slice(lt.length).trim()||void 0}function vp(n,e,t){let r=[],o=new Set;for(let i of e??[]){let s=mc(i),a=s===void 0?void 0:t.find(d=>d.name===s&&n.includes(d.kind));a?r.some(d=>d.view===a)||r.push({kind:a.kind,view:a}):s===void 0&&n.includes(i)&&!o.has(i)&&(o.add(i),r.push({kind:i}))}for(let i of n)o.has(i)||r.push({kind:i});return r}function wp(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=Re(r),i=t.find(d=>d.title===r||lt+d.name===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=>ut(e,d).slice(1)===o);return a?{to:"kind",kind:a}:void 0}function si(n){let e=(n??"").replace(/\/+$/,"");return e===""?"":e.startsWith("/")?e:`/${e}`}function xp(n,e={}){let t=typeof n=="string"?n:n.address,r=si(e.basePath),o=t.startsWith("/")?t:`/${t}`;return r===""?o:o==="/"?r:o.startsWith("/?")||o.startsWith("/#")?`${r}${o.slice(1)}`:`${r}${o}`}function kp(n,e){let t=si(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 or=2500,Sp=or*4;function Rp(n){let e=n.name??"";return e&&n.onBehalfOfName?`${e}, for ${n.onBehalfOfName}`:e}function ai(n,e,t=or){return n.held==="socket"?!0:n.until!==void 0?e<Date.parse(n.until):e-Date.parse(n.at)<t}var fS=new Set(Nt);function $p(n){return`${n.kind}:${n.id??""}:${n.session??""}`}function Ap(n,e,t,r=or,o){let i=new Map;for(let[s,a]of n)ai(a,t,r)&&i.set(s,a);for(let s of e){if(!ai(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 _p(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)&&JSON.stringify(n.caret)===JSON.stringify(e.caret)}var yc=Symbol.for("@graview/core:app-link"),Op=n=>(Object.defineProperty(D(n),yc,{value:1,enumerable:!0}),n);function bc(n){let e=D(n);return!!e&&(e[yc]===1||bc(e.innerType))}var mS=()=>Op(L().check(Hr(500),Bn(Pt,"another app's address")));var ir=(n,e)=>`${e.kind}\0${e.id??""}\0${n.address}\0${n.kind}\0${n.id}`;function Pp(n,e,t=()=>{}){let r=new Map,o=new Map,i=s=>{let a=ir(s,e),d=r.get(a);return d||(d=Promise.resolve().then(()=>n.resolve(s,e)).then(l=>Ep(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=ir(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(ir(s,e)),forget(s){if(!s){r.clear(),o.clear();return}let a=ir(s,e);r.delete(a),o.delete(a)}}}function Ep(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 Mp=1;var sr=(n,e)=>`${n}\0${e}`;function ci(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]):n.op==="splice-text"?[[n.id,n.field]]:[]}var di=class n{revs=new Map;floor;constructor(e=0){this.floor=Math.max(0,Math.floor(e))-1}static of(e,t={}){let r=new n(t.horizon);return r.note(e),r}note(e){for(let t of e)for(let r of t.primitives)for(let[o,i]of ci(r)){let s=sr(o,i);(this.revs.get(s)??this.floor)<t.seq&&this.revs.set(s,t.seq)}}of(e,t){return this.revs.get(sr(e,t))??this.floor}baseFor(e,t=new Set,r){let o=new Set,i=new Map;for(let s of e)for(let a of s.primitives)if(a.op==="add-node"&&o.add(a.node.id),!(a.op!=="patch-node"||o.has(a.id)||t.has(a.id)))for(let d of Object.keys(a.after)){let l=sr(a.id,d);t.has(l)||i.has(l)||r?.(a.id,d)||i.set(l,{node:a.id,field:d,rev:this.of(a.id,d)})}return[...i.values()]}stale(e){return e.filter(t=>this.of(t.node,t.field)>t.rev)}};function zp(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 ci(r))e.add(sr(o,i))}return e}var RS=Symbol.for("@graview/core:collaborative"),$S=n=>typeof n=="object"&&n!==null?n._zod?.def:void 0;var Np=/^#([0-9a-f]{3,8})$/i,Ip=/(rgba?|hsla?)\(([^)]+)\)/gi;function Tp(n){let e=Np.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 jp(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,f]=r;return d===void 0||l===void 0||u===void 0?null:{r:d,g:l,b:u,a:f??1}}let[o,i,s,a]=r;return o===void 0||i===void 0||s===void 0?null:{...wc(o,i>1?i/100:i,s>1?s/100:s),a:a??1}}function tn(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 $e(n,e,t){return{...wc(n,e,t),a:1}}function wc(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 te(n){let e=[];for(let t of n.matchAll(Ip)){let r=jp(t[0]);r&&e.push(r)}for(let t of n.matchAll(/#[0-9a-fA-F]{3,8}\b/g)){let r=Tp(t[0]);r&&e.push(r)}return e}function rn(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 li(n){let e=n/255;return e<=.03928?e/12.92:((e+.055)/1.055)**2.4}function vc(n){return .2126*li(n.r)+.7152*li(n.g)+.0722*li(n.b)}function he(n,e){let[t,r]=[vc(n),vc(e)].sort((o,i)=>i-o);return(t+.05)/(r+.05)}var ar=(n,e)=>`rgba(${Math.round(n.r)}, ${Math.round(n.g)}, ${Math.round(n.b)}, ${e})`,xc={r:0,g:0,b:0,a:1},dr={r:255,g:255,b:255,a:1};function cr(n){let e=te(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=tn(e);for(let s of["dark","light"]){let a=n.base[s],d=te(a.ground)[0]??(s==="dark"?xc:dr),l=rn(te(a.panel)[0]??dr,d),u=Lp(i,[l,d],s,4.5);u?Math.abs(u.l-i.l)>Fp&&(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 f=u??i,c=$e(f.h,f.s,f.l),p=n.accentInk?.[s]??(he(dr,c)>=he(xc,c)?"#ffffff":"#000000"),g=he(te(p)[0]??dr,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:ar(c,1),accentDim:ar(c,s==="dark"?.35:.22),accentInk:p,glow:ar(c,s==="dark"?.28:.1),edgeBright:ar(c,ui(c,l,s==="dark"?.55:.42,3)),...n.warn?.[s]?{warn:n.warn[s]}:{}};let h=te(t[s].warn)[0];h&&Dp(tn(h).h,f.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 ui(n,e,t,r){for(let o=Math.round(t*100);o<=100;o++){let i=o/100;if(he(rn({...n,a:i},e),e)>=r)return i}return 1}function Dp(n,e){let t=Math.abs(n-e)%360;return t>180?360-t:t}var Fp=.3;function Lp(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=>he($e(n.h,n.s,d),l)>=r))return{...n,l:d}}return null}function Zp(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 on=Object.freeze({navy:"#001769",turquoise:"#00e5b9",paper:"#f7f7f2",ink:"#18213a",muted:"#586174"}),fi="Montserrat",pi=Object.freeze({display:550,body:450,label:600}),hi=Object.freeze({display:600,body:400,label:600}),Cp="-0.025em",Gp=Object.freeze({minWidth:140,clearSpace:.5,microMax:24,regularMin:32,microBelow:28});var kc={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:on.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},Sc={ground:on.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:on.ink,inkMuted:on.muted,inkFaint:"#626b7d",accent:on.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},De={dark:kc,light:Sc};var Fe=Object.freeze({radius:8,density:1,radiusSmall:.72,radiusSmallFloor:2,pad:15,padSmall:10,gap:7}),sn=Object.freeze({body:`"${fi}", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif`,mono:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace'});function Kp(n){let e=n?.shape?.radius??Fe.radius,t=n?.shape?.density??Fe.density;return Object.freeze({radius:e,radiusSmall:Math.max(Fe.radiusSmallFloor,Math.round(e*Fe.radiusSmall)),pad:Math.round(Fe.pad*t),padSmall:Math.round(Fe.padSmall*t),gap:Math.round(Fe.gap*t)})}function Bp(n){let e=n?.typography?.body??sn.body,t=n?.typography?.display??e,o=e===sn.body&&t===sn.body?pi:hi,i=n?.typography?.weights;return Object.freeze({body:e,display:t,mono:n?.typography?.mono??sn.mono,weights:Object.freeze({display:i?.display??o.display,body:i?.body??o.body,label:i?.label??o.label})})}var TS=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 $c(n){return/^\s*(<\?xml[^>]*>\s*)?(<!--[\s\S]*?-->\s*)*(<!DOCTYPE svg[^>]*>\s*)?<svg[\s>/]/i.test(n)}var Ac="http://www.w3.org/2000/svg",Vp=["http://www.w3.org/1999/xhtml","http://www.w3.org/1998/Math/MathML",Ac],Up=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(" ")),Wp=new Set(["title","desc"]),pt="it embeds a page or media",qp={script:"it has a script in it",foreignobject:"it embeds HTML (foreignObject)",iframe:pt,embed:pt,object:pt,audio:pt,video:pt,style:"it has a style sheet in it; a mark is styled by its attributes",a:"it links to something (an <a> element)"},Hp={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"};function Yp(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=Hp[o.toLowerCase()];return i===void 0&&(e=!0),i??""});return e?null:t}function Jp(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 Xp(n,e,t){let r=Yp(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===Ac?null:"it changes what its elements are (another xmlns)";if(e.startsWith("xmlns:"))return Vp.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 Jp(r)?null:o==="style"?"its style loads something outside itself":"it loads or links to something outside itself"}var Rc=/^\s+([A-Za-z_][A-Za-z0-9_.:-]*)\s*=\s*(?:"([^"<]*)"|'([^'<]*)')/;function _c(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 p=o.indexOf("-->",4);if(p<0)return"it has a comment that never ends";let g=o.slice(4,p);if(/^-?>/.test(g)||g.includes("--")||g.includes("<!")||g.endsWith("-"))return"it has a comment the page and the picture read differently";r+=p+3;continue}if(/^<!DOCTYPE/i.test(o)){let p=/^<!DOCTYPE\s+svg\b[^<>[\]]*>/i.exec(o);if(!p||e.length>0||t)return"it declares XML entities";r+=p[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=qp[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(!Up.has(d))return`it has a <${d}> element, which a picture does not need`;let u=e[e.length-1];if(u&&Wp.has(u))return`it has an element inside a <${u}>, which the page reads as HTML`;let f=a[0].length;for(let p=Rc.exec(o.slice(f));p;p=Rc.exec(o.slice(f))){let g=Xp(d,p[1],p[2]??p[3]??"");if(g)return g;f+=p[0].length}let c=/^\s*(\/?)>/.exec(o.slice(f));if(!c)return/(?:^|[\s/"'])on[a-z]+\s*=/i.test(o.slice(f,f+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+=f+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 Oc(n){if(n){if(!$c(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 _c(n)===null?`data:image/svg+xml,${encodeURIComponent(n.trim())}`:void 0}}var lr;function Qp(){if(lr===void 0)try{lr=new RegExp("^\\p{RGI_Emoji}$","v")}catch{lr=null}return lr}function eh(n){return/\p{Extended_Pictographic}|\p{Regional_Indicator}|⃣/u.test(n)}function gi(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(eh).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=Qp();return r&&!r.test(n)?"it is not one of the standard emoji every emoji set draws":null}function mi(n){return typeof n=="object"&&n!==null&&typeof n.emoji=="string"?n.emoji:void 0}function Pc(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 nh(n){let e=n?.favicon;if(typeof e=="object"&&e!==null){let t=mi(e);return t!==void 0&&gi(t)===null?`data:image/svg+xml,${encodeURIComponent(Pc(t))}`:void 0}return Oc(e)}function th(n){let e=n?.logo;return typeof e=="string"?e===""?void 0:{light:e}:e&&typeof e.light=="string"&&e.light!==""?e:void 0}function rh(n){if(n?.logo)return;let e=mi(n?.favicon);return e!==void 0&&gi(e)===null?e:void 0}var Ec={"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":sn.mono},oh=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","-apple-system","BlinkMacSystemFont"],Mc=["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 ih=n=>new Set(n.map(e=>e.toLowerCase()));function sh(n){return ih([...oh,...Mc]).has(n.toLowerCase())||n.toLowerCase().startsWith("ui-")}function ah(n){return Ec[n]??n}function LS(n){if(/url\(|@import|[;{}<>\\]|\/\*|[\u0000-\u001f\u007f]/i.test(n))return"it is not a list of font names; a document names a face, never where one comes from";for(let e of n.split(",")){let t=e.trim();if(!(/^"[^"']*"$/.test(t)||/^'[^"']*'$/.test(t))&&/["']/.test(t))return`${t} is not quoted in one pair; write a face as Georgia or "Times New Roman"`}return null}var bi={r:255,g:255,b:255,a:1},Nc={r:0,g:0,b:0,a:1},zn=n=>`#${[n.r,n.g,n.b].map(e=>Math.round(Math.max(0,Math.min(255,e))).toString(16).padStart(2,"0")).join("")}`,Le=(n,e)=>`rgba(${Math.round(n.r)}, ${Math.round(n.g)}, ${Math.round(n.b)}, ${e})`,yi=(n,e,t)=>({r:n.r+(e.r-n.r)*t,g:n.g+(e.g-n.g)*t,b:n.b+(e.b-n.b)*t,a:1});function dh(n){return typeof n=="string"?{light:n}:{...n.light?{light:n.light}:{},...n.dark?{dark:n.dark}:{}}}function ch(n){let e=te(n)[0];if(!e)return;let{h:t,s:r}=tn(e);return zn($e(t,Math.min(r,.45),.08))}function lh(n){return he(bi,n)>he(Nc,n)}function Ic(n,e){let t=te(n.edgeBright)[0];return Le(t,ui({...t,a:1},e,t.a,3))}function uh(n,e,t){let{h:r,s:o}=tn(t),i=yi(t,bi,.8);return{...n,ground:e,groundDeep:zn(yi(t,Nc,.04)),panel:zn(i),panelMuted:zn(yi(t,bi,.55)),edge:Le($e(r,Math.min(o,.5),.14),.14),edgeBright:Ic(n,i),bar:Le(i,.96),float:zn(i)}}function zc(n,e,t){let{h:r,s:o,l:i}=tn(t),s=a=>$e(r,o,Math.min(1,i+a));return{...n,ground:e,groundDeep:zn($e(r,o,i*.6)),panel:Le(s(.07),.96),panelMuted:Le(s(.035),.94),edge:Le($e(r,Math.min(o,.45),.75),.18),edgeBright:Ic(n,rn({...s(.07),a:.96},t)),bar:Le(t,.96),float:Le(s(.05),.98)}}function Tc(n){if(n===void 0)return De;let e=dh(n),t=e.dark??(e.light?ch(e.light):void 0),r=e.light?te(e.light)[0]:void 0,o=t?te(t)[0]:void 0;return{light:r?lh(r)?zc(De.dark,e.light,r):uh(De.light,e.light,r):De.light,dark:o?zc(De.dark,t,o):De.dark}}var fh=[["ink","ink",["ground","panel","panelMuted","panelWarning","float","bar"],4.5],["inkMuted","muted ink",["ground","panel","panelMuted","float","bar"],4.5],["inkFaint","faint ink",["panel","panelMuted","float"],4.5],["accent","the accent",["ground","panel","float"],4.5],["warn","the warning color",["panel","panelWarning","float"],4.5],["good","the good status",["ground","panel"],4.5],["bad","the bad status",["ground","panel"],4.5],["edgeBright","the lit edge",["panel"],3]],ph={panel:"a card",panelMuted:"a receded card",panelWarning:"a flagged card",float:"a floating sheet",bar:"the bar"};function BS(n,e){for(let t of["light","dark"]){let r={...n[t],...t==="light"&&e?{accent:e}:{}},o=te(r.ground)[0];for(let[i,s,a,d]of fh)for(let l of a){let u=l==="ground"?[o]:te(String(r[l])).map(f=>rn(f,o));for(let f of u){let c=rn(te(String(r[i]))[0],f),p=he(c,f);if(p<d)return{scheme:t,what:s,text:c,ground:o,...l==="ground"?{}:{card:f,surface:ph[l]},ratio:p,requires:d}}}}return null}function qS(n,e){let t=Tc(e),r=cr({accent:n,base:t});return r.ok||!r.missing.every(o=>o.startsWith("warn"))?r:cr({accent:n,base:t,warn:{light:t.light.bad,dark:t.dark.bad}})}function hh(n,e,t){if(t.rows===0)return;let r=ae(n,e.rows).toLowerCase(),o=ae(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=Y(n.tryDefinition(e.rows),e.rows);return i?`No ${a} is linked to another yet: ${s}.`:`No ${a} is linked to ${un(Y(n.tryDefinition(e.columns),e.columns))} yet: ${s}.`}function gh(n,e){let t=o=>o?._zod?.def,r={};for(let o of new Set(e)){let i=n.tryDefinition(o),s=i?.fields?.shape??{};for(let[a,d]of Object.entries(s)){let l=t(d);for(let f=0;f<6&&l?.innerType!==void 0&&l.type!=="enum";f++)l=t(l.innerType);if(l?.type!=="enum"||!l.entries)continue;let u=i?.display?.format?.[a];(r[o]??={})[a]=Object.fromEntries(Object.values(l.entries).map(f=>[String(f),u?u(f):K(String(f))]))}}return r}var ge={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 mh(n){return n?{connectors:{all:{...ge.connectors.all,...n.connectors?.all??{}},byEdge:{...ge.connectors.byEdge,...n.connectors?.byEdge??{}}},captions:{...ge.captions,...n.captions??{}},grid:{...ge.grid,...n.grid??{}},lattice:{...ge.lattice,...n.lattice??{}},tags:{...ge.tags,...n.tags??{}},emphasis:{...ge.emphasis,...n.emphasis??{}},marks:{...ge.marks,...n.marks??{}}}:ge}function yh(n,e){return{...n.connectors.all,...n.connectors.byEdge[e]??{}}}function bh(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
|
+
`)}var jc=n=>n?.kind==="visitor"||n?.onBehalfOf?.kind==="visitor",ur=new WeakMap;function vh(n,e){e?ur.set(n,e):ur.delete(n)}function wh(n,e,t){if(!n||jc(t))return;let r=ur.get(n)??ur.get(wi(n)?.store??{});if(r)try{r(e,t)}catch{}}function xh(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 f of d)l.add(f);if(s.to==="*"||d.includes(u))for(let f of a)l.add(f)}if(l.size===0)return{ok:!1,at:o};r=l}return{ok:!0,reached:r}}var Dc="graview:fresh";function kh(n,e){let t=new URL(n),r="1";try{let o=Array.from(crypto.getRandomValues(new Uint8Array(16)),i=>i.toString(16).padStart(2,"0")).join("");(e??globalThis.sessionStorage).setItem(Dc,o),r=o}catch{}return t.searchParams.set("fresh",r),t.toString()}export{hn as a,Js as b,Xs as c,Il as d,Hr as e,Kn as f,Bn as g,L as h,jy as i,Dy as j,Ue as k,Fy as l,Ly as m,Zy as n,Yr as o,Cy as p,Me as q,gn as r,Gy as s,Ky as t,By as u,aa as v,da as w,Q as x,Vy as y,_t as z,Uy as A,Wy as B,D as C,Ql as D,yr as E,gt as F,xi as G,br as H,mt as I,Sh as J,ne as K,Fc as L,Lc as M,ki as N,bt as O,Zc as P,Oe as Q,vr as R,Si as S,wr as T,Kc as U,Bc as V,me as W,Vc as X,Uc as Y,Ai as Z,Wc as _,qc as $,ln as aa,_i as ba,Oi as ca,K as da,Yc as ea,kr as fa,B as ga,Jc as ha,Xc as ia,ae as ja,Qc as ka,el as la,wt as ma,un as na,Y as oa,eu as pa,Ot as qa,Qr as ra,ca as sa,la as ta,ua,nu as va,Vn as wa,pa as xa,qb as ya,Et as za,bc as Aa,mS as Ba,su as Ca,du as Da,ma as Ea,cu as Fa,Xb as Ga,Un as Ha,lu as Ia,fu as Ja,Qb as Ka,ev as La,pu as Ma,ba as Na,Pp as Oa,Mt as Pa,hu as Qa,yn as Ra,qn as Sa,zt as Ta,rv as Ua,bn as Va,mn as Wa,$a as Xa,yu as Ya,ro as Za,Hn as _a,vn as $a,We as ab,cv as bb,oo as cb,It as db,vu as eb,wn as fb,N as gb,Jn as hb,z as ib,W as jb,ee as kb,Su as lb,Ft as mb,zv as nb,Ru as ob,$u as pb,Mp as qb,T as rb,V as sb,xe as tb,ke as ub,Zt as vb,ie as wb,Vv as xb,Da as yb,Sn as zb,j as Ab,Rn as Bb,He as Cb,se as Db,Eu as Eb,pe as Fb,Xe as Gb,tt as Hb,od as Ib,id as Jb,ce as Kb,yf as Lb,Fo as Mb,Pd as Nb,On as Ob,Zo as Pb,lx as Qb,Co as Rb,Nd as Sb,Id as Tb,Go as Ub,Te as Vb,rt as Wb,ot as Xb,$f as Yb,Td as Zb,uw as _b,Va as $b,fw as ac,pw as bc,_f as cc,Ef as dc,Vo as ec,Uo as fc,Wo as gc,at as hc,Bd as ic,Yt as jc,Tf as kc,Jt as lc,Je as mc,di as nc,zp as oc,dt as pc,Pn as qc,RS as rc,$S as sc,Gt as tc,Ro as uc,Ao as vc,Ya as wc,Tu as xc,Ja as yc,Zu as zc,Zp as Ac,fi as Bc,Cp as Cc,De as Dc,sn as Ec,Kp as Fc,Bp as Gc,$c as Hc,_c as Ic,Oc as Jc,nh as Kc,th as Lc,rh as Mc,sh as Nc,ah as Oc,LS as Pc,Tc as Qc,BS as Rc,qS as Sc,oi as Tc,dp as Uc,hh as Vc,gh as Wc,mh as Xc,yh as Yc,bh as Zc,Cu as _c,Gu as $c,Ku as ad,Bu as bd,nt as cd,Qe as dd,it as ed,Vt as fd,Se as gd,lf as hd,Vu as id,Uu as jd,jc as kd,vh as ld,wh as md,xh as nd,Uf as od,Wf as pd,$d as qd,qf as rd,dc as sd,En as td,ni as ud,Xf as vd,Qf as wd,ep as xd,cc as yd,ri as zd,np as Ad,tp as Bd,Re as Cd,ut as Dd,rp as Ed,op as Fd,lc as Gd,ip as Hd,sp as Id,uc as Jd,ft as Kd,cp as Ld,pc as Md,hc as Nd,up as Od,fp as Pd,pp as Qd,hp as Rd,gc as Sd,gp as Td,mp as Ud,yp as Vd,bp as Wd,vp as Xd,wp as Yd,si as Zd,xp as _d,kp as $d,Sp as ae,Rp as be,$p as ce,Ap as de,_p as ee,kh as fe};
|