graview 0.1.47 → 0.1.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/preview/{chunk.SWWAEOZ7.js → chunk.2GLJH253.js} +1 -1
- package/dist/preview/{chunk.ETPKXUAN.js → chunk.2QNGGF55.js} +1 -1
- package/dist/preview/{chunk.O4WEJ47H.js → chunk.2UIUMG23.js} +3 -3
- package/dist/preview/{chunk.IXOQQBJE.js → chunk.2VTMTW7K.js} +1 -1
- package/dist/preview/chunk.37CJSWLL.js +1 -0
- package/dist/preview/{chunk.RG6WNOBW.js → chunk.3BAHAK6W.js} +1 -1
- package/dist/preview/{chunk.T42S2WMB.js → chunk.3RP3N2JP.js} +1 -1
- package/dist/preview/{chunk.C3NHNYA6.js → chunk.3UD7GG5B.js} +1 -1
- package/dist/preview/{chunk.L4YNDNX7.js → chunk.44G5A53D.js} +1 -1
- package/dist/preview/chunk.4GQA3AJU.js +1 -0
- package/dist/preview/{chunk.QGG6ZRJ5.js → chunk.4KX53HCV.js} +2 -2
- package/dist/preview/chunk.4TJOS4C7.js +5 -0
- package/dist/preview/{chunk.FWSCBHZ5.js → chunk.4VW6THJF.js} +1 -1
- package/dist/preview/{chunk.MCB26YCQ.js → chunk.5IM645XQ.js} +1 -1
- package/dist/preview/{chunk.RBJAPOZ3.js → chunk.5IPH2SCE.js} +1 -1
- package/dist/preview/{chunk.TBQOSI4J.js → chunk.5Y3Q7ONN.js} +1 -1
- package/dist/preview/chunk.664PBQAQ.js +1 -0
- package/dist/preview/{chunk.2MCZ4CU5.js → chunk.6TKILWRM.js} +1 -1
- package/dist/preview/{chunk.DQS7D2W2.js → chunk.6VAFNCR4.js} +1 -1
- package/dist/preview/chunk.72OZLWJL.js +1 -0
- package/dist/preview/chunk.72W6S746.js +1 -0
- package/dist/preview/{chunk.OONCUAOH.js → chunk.76W2FXEC.js} +1 -1
- package/dist/preview/{chunk.64WM4IBI.js → chunk.7FRPNQU4.js} +1 -1
- package/dist/preview/chunk.7LL7OSBY.js +6 -0
- package/dist/preview/chunk.7QZYFLBS.js +1 -0
- package/dist/preview/{chunk.6RY6OSE6.js → chunk.7VT3TRHR.js} +1 -1
- package/dist/preview/{chunk.W6COSBO2.js → chunk.B2IIEVBF.js} +2 -2
- package/dist/preview/{chunk.IQ2HKGJS.js → chunk.BDHKWVNX.js} +1 -1
- package/dist/preview/{chunk.57ZSMK3R.js → chunk.CH5ROV7N.js} +1 -1
- package/dist/preview/{chunk.RZF3QM4E.js → chunk.CJ23XTSW.js} +1 -1
- package/dist/preview/{chunk.VAFSSSSI.js → chunk.D5ETRTAF.js} +1 -1
- package/dist/preview/{chunk.47RTA6M3.js → chunk.DAUC2DFY.js} +1 -1
- package/dist/preview/{chunk.63JLXGYX.js → chunk.DFK2NA6L.js} +1 -1
- package/dist/preview/{chunk.7N2GXZYI.js → chunk.DHAK6PPX.js} +2 -2
- package/dist/preview/{chunk.NFIGGSMJ.js → chunk.DOBQ4LO4.js} +1 -1
- package/dist/preview/{chunk.H7KCWCB4.js → chunk.DPHTUTOS.js} +1 -1
- package/dist/preview/chunk.DQ7M3LFV.js +1 -0
- package/dist/preview/{chunk.63MS2LOP.js → chunk.DUWYF7BO.js} +1 -1
- package/dist/preview/{chunk.TCXKPILZ.js → chunk.DWPU56S5.js} +1 -1
- package/dist/preview/{chunk.WBHM5I3I.js → chunk.E5GM2SMO.js} +1 -1
- package/dist/preview/{chunk.N7JT6MG2.js → chunk.EMQ5POGB.js} +1 -1
- package/dist/preview/{chunk.SD6N4DGF.js → chunk.ENPCLMP2.js} +1 -1
- package/dist/preview/chunk.EXEZBZGW.js +1 -0
- package/dist/preview/{chunk.CMOXKRWT.js → chunk.EZJNUFNQ.js} +1 -1
- package/dist/preview/{chunk.C44MC5X3.js → chunk.FOP5RBGF.js} +1 -1
- package/dist/preview/chunk.FPYL6REZ.js +1 -0
- package/dist/preview/chunk.FQYOTK34.js +1 -0
- package/dist/preview/chunk.G7WDMUDV.js +1 -0
- package/dist/preview/{chunk.VSNHCGKC.js → chunk.GACKGEUY.js} +1 -1
- package/dist/preview/chunk.GH2SWMCW.js +1 -0
- package/dist/preview/chunk.GNBN3BK7.js +1 -0
- package/dist/preview/{chunk.KSM6NVAT.js → chunk.GT3F6FQ6.js} +1 -1
- package/dist/preview/chunk.GTPC6JOW.js +2 -0
- package/dist/preview/{chunk.IROYMLER.js → chunk.GUMJEVVP.js} +1 -1
- package/dist/preview/{chunk.3LDYUO77.js → chunk.GVNYPFIM.js} +1 -1
- package/dist/preview/{chunk.EYI3Y2DY.js → chunk.HC5N3CT2.js} +1 -1
- package/dist/preview/{chunk.6TIEX67B.js → chunk.HDE2MGGU.js} +1 -1
- package/dist/preview/{chunk.6YD2DLIC.js → chunk.HG4DDNPG.js} +1 -1
- package/dist/preview/{chunk.MBETS27C.js → chunk.HKA5T7DL.js} +1 -1
- package/dist/preview/{chunk.7ELB37JU.js → chunk.I5TOMBIF.js} +1 -1
- package/dist/preview/{chunk.76GF5US2.js → chunk.I7QIHN66.js} +1 -1
- package/dist/preview/chunk.ILZYRJDS.js +1 -0
- package/dist/preview/{chunk.QZEZHCOI.js → chunk.IRHSTUZM.js} +1 -1
- package/dist/preview/{chunk.PYE3WZM7.js → chunk.J2V76Z6G.js} +1 -1
- package/dist/preview/{chunk.WHEUTAXA.js → chunk.J6ANRF6E.js} +1 -1
- package/dist/preview/{chunk.Y4ZUJUUT.js → chunk.KA44WNB4.js} +1 -1
- package/dist/preview/chunk.KTFUVR4V.js +2 -0
- package/dist/preview/{chunk.BNPQUI3F.js → chunk.KVEDIBXS.js} +1 -1
- package/dist/preview/chunk.KVJFY7N5.js +2 -0
- package/dist/preview/{chunk.F67F6QZ6.js → chunk.KW65F4WA.js} +1 -1
- package/dist/preview/chunk.LGSFGNWE.js +1 -0
- package/dist/preview/{chunk.VXVWUIGO.js → chunk.LNON6P7K.js} +1 -1
- package/dist/preview/{chunk.2W22AWSL.js → chunk.LPD74WBI.js} +1 -1
- package/dist/preview/{chunk.SZR3Z43B.js → chunk.LXCJVZF3.js} +1 -1
- package/dist/preview/{chunk.Q7RQC3F7.js → chunk.MAFFUPCR.js} +1 -1
- package/dist/preview/chunk.MTXEURFE.js +1 -0
- package/dist/preview/{chunk.DNROW6LX.js → chunk.MVRG75ZD.js} +1 -1
- package/dist/preview/{chunk.5TM5VA2H.js → chunk.MVSV7T6E.js} +1 -1
- package/dist/preview/{chunk.4YXJPKXD.js → chunk.MZLWLIKR.js} +1 -1
- package/dist/preview/chunk.N4M54YK6.js +1 -0
- package/dist/preview/{chunk.KSXB4LDF.js → chunk.NB6WN4DO.js} +1 -1
- package/dist/preview/{chunk.UHX4WTM7.js → chunk.NFDLCUCC.js} +1 -1
- package/dist/preview/{chunk.AGIO2GRV.js → chunk.NLBIX7LH.js} +1 -1
- package/dist/preview/{chunk.FOQ27RAR.js → chunk.NQZ73QV7.js} +1 -1
- package/dist/preview/chunk.NR5ODXMO.js +1 -0
- package/dist/preview/{chunk.VC3UGFHY.js → chunk.NTLHEHOM.js} +1 -1
- package/dist/preview/{chunk.TJEV5ZAM.js → chunk.NWT5FPEK.js} +2 -2
- package/dist/preview/chunk.NX7IIZLO.js +1 -0
- package/dist/preview/{chunk.UKAPFIPJ.js → chunk.O45VO36H.js} +1 -1
- package/dist/preview/{chunk.OCTOGZVJ.js → chunk.OAIWGWGU.js} +2 -2
- package/dist/preview/{chunk.PC6PID5X.js → chunk.ODRL5OWR.js} +1 -1
- package/dist/preview/{chunk.24OZGU7J.js → chunk.OFRGDJYX.js} +1 -1
- package/dist/preview/chunk.OVO6L5IP.js +88 -0
- package/dist/preview/{chunk.RUPRZDN3.js → chunk.OZGETOTK.js} +1 -1
- package/dist/preview/{chunk.ZCYGUP3I.js → chunk.P6FQAILU.js} +1 -1
- package/dist/preview/{chunk.5M4TMZXC.js → chunk.PCEYZQAW.js} +1 -1
- package/dist/preview/{chunk.IPAZOKMQ.js → chunk.PMJUGHW4.js} +1 -1
- package/dist/preview/{chunk.RNEJYIQ7.js → chunk.PPRSGM64.js} +1 -1
- package/dist/preview/chunk.PQVUQVRL.js +1 -0
- package/dist/preview/{chunk.NEEOVRB7.js → chunk.PTXLOFQW.js} +1 -1
- package/dist/preview/{chunk.P4KCZRIG.js → chunk.PVEPU6EA.js} +1 -1
- package/dist/preview/chunk.QGE6YKSU.js +1 -0
- package/dist/preview/{chunk.Z6TMIAAB.js → chunk.QII2C5OV.js} +1 -1
- package/dist/preview/{chunk.FOJDVK2Q.js → chunk.QO7MDWID.js} +1 -1
- package/dist/preview/{chunk.RVJXO5GG.js → chunk.QPICKSSM.js} +1 -1
- package/dist/preview/{chunk.KRGM25HF.js → chunk.QQCDCRR2.js} +1 -1
- package/dist/preview/{chunk.F2VMMCVK.js → chunk.QQTRAY5W.js} +1 -1
- package/dist/preview/{chunk.ZWVN75EY.js → chunk.RLXKDXPB.js} +1 -1
- package/dist/preview/{chunk.5AGW4NRZ.js → chunk.RQBEQYB2.js} +1 -1
- package/dist/preview/chunk.SA34Y3X5.js +2 -0
- package/dist/preview/chunk.SAHNXAV3.js +1 -0
- package/dist/preview/{chunk.52VGZBO3.js → chunk.SFAAM4KE.js} +1 -1
- package/dist/preview/{chunk.4YS7547F.js → chunk.SKJJBLXF.js} +1 -1
- package/dist/preview/chunk.SUPWMV2F.js +1 -0
- package/dist/preview/{chunk.WJS6P7GI.js → chunk.TBRJOKIK.js} +1 -1
- package/dist/preview/{chunk.S5IQFZ5Z.js → chunk.TKMQROXF.js} +1 -1
- package/dist/preview/chunk.TMDI7KRS.js +18 -0
- package/dist/preview/chunk.TPG6IY4M.js +1 -0
- package/dist/preview/{chunk.PKUDIWIF.js → chunk.UGJSMNVO.js} +1 -1
- package/dist/preview/{chunk.EUPSAYEI.js → chunk.UJRBOUGC.js} +1 -1
- package/dist/preview/{chunk.IJNOT4S4.js → chunk.V2GSBYDK.js} +2 -2
- package/dist/preview/chunk.V3N34DSU.js +1 -0
- package/dist/preview/{chunk.ZQY6ODXC.js → chunk.V4BCB7N2.js} +1 -1
- package/dist/preview/{chunk.CTQULC5F.js → chunk.VQAQQW4Q.js} +1 -1
- package/dist/preview/{chunk.A7RKTSOH.js → chunk.W72TTRLX.js} +2 -2
- package/dist/preview/{chunk.IKX4VDTW.js → chunk.X7JMJSLU.js} +1 -1
- package/dist/preview/{chunk.GCKZ2YRJ.js → chunk.X7N3JUO4.js} +2 -2
- package/dist/preview/chunk.XOZU4OFA.js +1 -0
- package/dist/preview/{chunk.O2WWYZI7.js → chunk.XTMOFRHL.js} +1 -1
- package/dist/preview/{chunk.V7XHNRQM.js → chunk.Y4MQGEUS.js} +2 -2
- package/dist/preview/{chunk.MF73YBJL.js → chunk.YDL5BSTG.js} +1 -1
- package/dist/preview/chunk.YEVA72L2.js +1 -0
- package/dist/preview/chunk.YLWON7X3.js +1 -0
- package/dist/preview/chunk.YUH43J2K.js +1 -0
- package/dist/preview/{chunk.UV3YU64Z.js → chunk.YVOABA2U.js} +1 -1
- package/dist/preview/{chunk.R6V37SR7.js → chunk.ZH4NWRWB.js} +1 -1
- package/dist/preview/chunk.ZXZNAG35.js +1 -0
- package/dist/preview/index.html +50 -49
- package/dist/preview/page.js +2 -2
- package/package.json +6 -6
- package/dist/preview/chunk.2CLANQHZ.js +0 -1
- package/dist/preview/chunk.2L3VFGHX.js +0 -1
- package/dist/preview/chunk.4OGOTHRD.js +0 -1
- package/dist/preview/chunk.5G53VDOC.js +0 -1
- package/dist/preview/chunk.6QVXXQCW.js +0 -2
- package/dist/preview/chunk.7NNI7YH4.js +0 -1
- package/dist/preview/chunk.A3RNSSUQ.js +0 -1
- package/dist/preview/chunk.AS4CQBOQ.js +0 -5
- package/dist/preview/chunk.AWXDZUKH.js +0 -1
- package/dist/preview/chunk.AYA7SYIU.js +0 -1
- package/dist/preview/chunk.BBS5C2BY.js +0 -1
- package/dist/preview/chunk.COYLGLTI.js +0 -1
- package/dist/preview/chunk.DX357TZ3.js +0 -2
- package/dist/preview/chunk.GQHAAKJG.js +0 -1
- package/dist/preview/chunk.HDRD33II.js +0 -1
- package/dist/preview/chunk.I6JLOEJU.js +0 -1
- package/dist/preview/chunk.ISNEX772.js +0 -1
- package/dist/preview/chunk.IW7YFPGG.js +0 -1
- package/dist/preview/chunk.IYIN6VSN.js +0 -1
- package/dist/preview/chunk.JUWWRRHA.js +0 -1
- package/dist/preview/chunk.K2NCGPCL.js +0 -1
- package/dist/preview/chunk.KWQ7QOHD.js +0 -2
- package/dist/preview/chunk.MCCUVGTE.js +0 -1
- package/dist/preview/chunk.NDWW5EER.js +0 -1
- package/dist/preview/chunk.OJGUIWDD.js +0 -88
- package/dist/preview/chunk.PBKO5CKD.js +0 -1
- package/dist/preview/chunk.QGVLJTZS.js +0 -1
- package/dist/preview/chunk.RX2M4C5W.js +0 -2
- package/dist/preview/chunk.SGKK4UKP.js +0 -1
- package/dist/preview/chunk.T7RJCEJB.js +0 -18
- package/dist/preview/chunk.VW2VCPJX.js +0 -1
- package/dist/preview/chunk.WAB7UDHU.js +0 -1
- package/dist/preview/chunk.XYEFZ2OO.js +0 -1
- package/dist/preview/chunk.YHH4TWZ2.js +0 -1
- package/dist/preview/chunk.YVONXFKE.js +0 -6
- package/dist/preview/chunk.ZIEHF67C.js +0 -1
- package/dist/preview/chunk.ZL7ZBJUU.js +0 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as he,b as Ze,c as Xn,e as Re,f as _e,g as gn}from"./chunk.2AZTW66C.js";var Gt="en-US",Ge=/^\d{4}-\d{2}-\d{2}$/,Qn=/^\d{4}(-\d\d){2}[T ]\d\d:\d\d(:[\d.]+)?(Z|[+-][\d:]+)?$/,Vf=n=>!Number.isNaN(Date.parse(n)),H=(n,e=Date.now())=>{let t=et(n);return t?Bt(e,t).day:new Date(e).toISOString().slice(0,10)},et=n=>Ce(n)??Le,mn,yn,bn,Le;function Md(n){mn=vn(n.reader),yn=vn(n.app),bn=Ce(n.readerTimeZone),Le=Ce(n.appTimeZone)}function Nd(n,e){let t=[mn,yn,bn,Le];n.reader!==void 0&&(mn=vn(n.reader)),n.app!==void 0&&(yn=vn(n.app)),n.readerTimeZone!==void 0&&(bn=Ce(n.readerTimeZone)),n.appTimeZone!==void 0&&(Le=Ce(n.appTimeZone));try{return e()}finally{[mn,yn,bn,Le]=t}}var Io=n=>mn??vn(n)??yn??Gt,nt=n=>bn??Ce(n)??Le,Id=n=>nt(n)??Intl.DateTimeFormat().resolvedOptions().timeZone??"UTC",jd=/^\s*([+\-−]|\d)/;var Ct=new Map;function Ce(n){if(n&&!Ct.has(n)){let e=!1;try{new Intl.DateTimeFormat(Gt,{timeZone:n}),e=!jd.test(n)}catch{}Ct.set(n,e)}return n&&Ct.get(n)?n:void 0}var Ae=new Map;function vn(n){if(n&&!Ae.has(n)){let e=!1;try{e=Intl.DateTimeFormat.supportedLocalesOf(n).length>0}catch{}Ae.set(n,e)}return n&&Ae.get(n)?n:void 0}function ge(n,e,t,r){let o=`${t=Io(t)}${r?"#":"@"}${JSON.stringify(e)}`,i=Ae.get(o);return i||Ae.set(o,i=r?new Intl.NumberFormat(t,e):new Intl.DateTimeFormat(t,e)),i.format(n).replace(/ /g," ")}var Oe="UTC",tt=n=>Date.UTC(+n.slice(0,4),+n.slice(5,7)-1,+n.slice(8,10));function me(n,e){return Ge.test(n)?ge(tt(n),{year:"numeric",month:"short",day:"numeric",timeZone:Oe},e):n}function Bt(n,e){let t=`wall@${e??""}`,r=Ae.get(t);r||Ae.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 jo(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=Bt(i,t);return Td(s.day,s.minutes)-Math.floor(i/6e4)*6e4};return r-o(r-o(r))}var Td=(n,e)=>Date.UTC(+n.slice(0,4),+n.slice(5,7)-1,+n.slice(8,10),0,e),To=n=>/[Z+-][\d:]*$/.test(n.slice(16));function Do(n,e,t,r,o=!1){if(!Qn.test(n))return n;let i=To(n),s=Date.parse(n.replace(" ","T")+(i?"":"Z"));if(Number.isNaN(s))return n;let a=i?nt(r):Oe;return ge(s,{...e,hour:"numeric",minute:"2-digit",...i&&o?{timeZoneName:"short"}:{},...a?{timeZone:a}:{}},t)}var Kt=(n,e,t)=>Do(n,{year:"numeric",month:"short",day:"numeric"},e,t,!0),Dd=(n,e,t)=>Do(n,{},e,t);function Fd(n,e){if(Ge.test(n))return n;if(!Qn.test(n))return;if(!To(n))return n.slice(0,10);let t=Date.parse(n.replace(" ","T"));return Number.isNaN(t)?void 0:Bt(t,nt(e)).day}function ae(n,e,t={maximumFractionDigits:2}){return Number.isFinite(n)?ge(n,t,e,!0):String(n)}function Zd(n,e={},t){return Ge.test(n)?ge(tt(n),{weekday:e.weekday??"long",month:"short",day:"numeric",...e.year?{year:"numeric"}:{},timeZone:Oe},t):n}function Ld(n,e){return Ge.test(n)?ge(tt(n),{month:"short",day:"numeric",timeZone:Oe},e):n}function Cd(n,e={},t){if(!/^\d{4}-\d{2}/.test(n))return n;let r=e.year??!e.short;return ge(tt(`${n.slice(0,7)}-01`),{month:e.short?"short":"long",...r?{year:e.short?"2-digit":"numeric"}:{},timeZone:Oe},t)}var Gd=(n,e="short",t)=>ge(Date.UTC(1970,0,4+n),{weekday:e,timeZone:Oe},t),Bd=(n,e)=>ge(Date.UTC(1970,0,1,0,Math.round(n)),{hour:"numeric",minute:"2-digit",timeZone:Oe},e),Kd=/(?<![\w-])(\d{4}-\d{2}-\d{2})(?![\w-]|:)/g;function Ut(n,e){return n.includes("-")?n.replace(Kd,t=>me(t,e)):n}var xn=n=>n.charAt(0).toUpperCase()+n.slice(1),Fo=n=>/^.\p{Lu}/u.test(n)?n:n.charAt(0).toLowerCase()+n.slice(1),Zo=(n,e="and")=>n.length>1?`${n.slice(0,-1).join(", ")} ${e} ${n.at(-1)}`:n[0]??"";function Ud(n,e){return{...e,kind:n,edges:e.edges??{}}}function Vt(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??H()):!r.retired.includes(o)}function Z(n,e){if(n?.label)return n.label(e);let t=e.label;return typeof t=="string"&&t.length>0?t:e.id}function Vd(n){return n.title??C(n.name)}function C(n){let e=n.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return xn(e.replace(/\b[a-z]+\b/g,t=>Lo.has(t)?t.toUpperCase():t.endsWith("s")&&Lo.has(t.slice(0,-1))?`${t.slice(0,-1).toUpperCase()}s`:t))}var Lo=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 Wd(n,e,t){let r=n.tryDefinition(e);return`${ae(t)} ${t===1?K(r,e):ne(n,e).toLowerCase()}`}function ne(n,e){return n.tryDefinition(e)?.plural??`${C(e).toLowerCase()}s`}function qd(n,e){return xn(ne(n,e))}function Hd(n,e){let t=ne(n,e);return`All ${/^[A-Z][a-z]/.test(t)?t.charAt(0).toLowerCase()+t.slice(1):t}`}function rt(n,e){let t=n?.computed&&Object.hasOwn(n.computed,e)?n.computed[e]:void 0;return n?.display?.labels?.[e]??(typeof t=="object"?t.label:void 0)??(e==="label"?"Name":C(e))}var Yd=/^(u[nt]i|use|usu|uti|ubiq|eu|ewe|one|once)/,Jd=/^(hour|honest|hono[ur]r?|heir)/;function Co(n){let e=C(n).toLowerCase();return Jd.test(e)?"an":Yd.test(e)?"a":/^[aeiou]/.test(e)?"an":"a"}function Be(n){return`${Co(n)} ${C(n).toLowerCase()}`}function K(n,e){return n?.noun??C(e).toLowerCase()}function Ht(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 Yt(n,e="|"){return n.map(t=>nr(t)).join(e)}function Bo(n,e){return typeof e=="bigint"?e.toString():e}var qt=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 Ko(n){return new qt(n)}function Uo(n){return n==null}function Jt(n){let e=n.startsWith("^")?1:0,t=n.endsWith("$")?n.length-1:n.length;return n.slice(e,t)}function Vo(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 Go=Symbol("evaluating");function Wo(n,e,t){let r;Object.defineProperty(n,e,{get(){if(r!==Go)return r===void 0&&(r=Go,r=t()),r},set(o){Object.defineProperty(n,e,{value:o})},configurable:!0})}function it(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}function qo(n){let e=Object.getOwnPropertyDescriptor(n,"shape");return e?.get?e.get.raw:e?.value}function Xt(n){return qo(n._zod.def)??n._zod.def.shape}function Ho(n,e,t){Object.defineProperty(n,e,{get(){let r=t();return it(this,e,r),r},enumerable:!0,configurable:!0})}function Yo(n,e,t){e in n?it(n,e,t):n[e]=t}function Xd(n,e,t,r){let o=Xt(e);for(let i of t){let s=Object.getOwnPropertyDescriptor(o,i);s.enumerable&&(s.get?Ho(n,i,()=>{let a=e._zod.def.shape[i];return r?r(a,i):a}):Yo(n,i,r?r(s.value,i):s.value))}}function Qd(n,e){for(let t of Reflect.ownKeys(e)){let r=Object.getOwnPropertyDescriptor(e,t);r.enumerable&&(r.get?Ho(n,t,()=>e[t]):Yo(n,t,r.value))}}function Jo(...n){let e={};for(let t of n){let r=Object.getOwnPropertyDescriptors(t);Object.assign(e,r)}return Object.defineProperties({},e)}var Qt="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function ot(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function er(n){if(ot(n)===!1)return!1;let e=n.constructor;if(e===void 0||typeof e!="function")return!0;let t=e.prototype;return!(ot(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}var Xo=new Set(["string","number","symbol"]);function kn(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ke(n,e,t){let r=new n._zod.constr(e??n._zod.def);return(!e||t?.parent)&&(r._zod.parent=n),r}function N(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 nr(n){return typeof n=="bigint"?n.toString()+"n":typeof n=="string"?`"${n}"`:`${n}`}function Qo(n){return Object.keys(n).filter(e=>n[e]._zod.optin!==void 0&&n[e]._zod.optout==="optional")}var ei={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 ni(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=Xt(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 Ke(n,Jo(n._zod.def,{shape:ec(n,e)}))}function ec(n,e){let t={};return Xd(t,n,Reflect.ownKeys(Xt(n))),Qd(t,e),t}function de(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 ti(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 be(n,e){return e.map(t=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(n),t})}function wn(n){return typeof n=="string"?n:n?.message}function tr(n,e,t){var r;for(let o=e;o<n.length;o++)(r=n[o]).schema??(r.schema=t)}function ce(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:wn(n.inst?._zod.def?.error?.(n))??wn(i?.(n))??wn(e?.error?.(n))??wn(t.customError?.(n))??wn(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 nc=/[\uD800-\uDBFF]/;function rr(n){let e=n.length;if(!nc.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 or(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function ri(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 Sn(...n){let[e,t,r]=n;return typeof e=="string"?{message:e,code:"custom",input:t,inst:r}:{...e}}function oi(n,e){for(let t in e){let r=Object.getOwnPropertyDescriptor(e,t);r.get?Object.defineProperty(n,t,{...r,enumerable:!1}):tc(n,t,r.value)}}function Ee(n,e,t,r=!0){return Object.defineProperty(n,e,{configurable:!0,writable:!0,enumerable:r,value:t}),t}function ir(n,e,t){return Ee(n,e,t,!1)}function tc(n,e,t){Object.defineProperty(n,e,{configurable:!0,get(){return this==null?t:Ee(this,e,t.bind(this))},set(r){Ee(this,e,r)}})}function rc(n,e){let t=Object.getPrototypeOf(n);return e in t?void 0:t}var Wt,ye=!1,oc={configurable:!0,get(){ye=!0}};function U(n,e,t){let r=Object.getPrototypeOf(n._zod);if(e in r&&Wt!==n._zod){Wt=void 0;return}Wt=n._zod,Object.defineProperty(r,e,{configurable:!0,get(){Object.defineProperty(this,e,oc);let o=ye;ye=!1;try{let i=t(this);return ye?delete this[e]:Object.defineProperty(this,e,{configurable:!0,writable:!0,value:i}),ye=ye||o,i}catch(i){throw delete this[e],ye=ye||o,i}},set(o){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:o})}})}function ii(n,e,t,r){let o=rc(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 si;var sr={value:void 0,enumerable:!1},ai="captureStackTrace"in Error?Error:null;function ic(n){let e=ai;if(e){let t=e.stackTraceLimit;if(typeof t=="number"){try{e.stackTraceLimit=0}catch{return ai=null,new n}try{return new n}finally{e.stackTraceLimit=t}}}return new n}function O(n,e,t,r){let o={};function i(u){this.def=u,this.constr=p,this.traits=new Set}i.prototype=o;let s=t,a=s&&new WeakSet;function d(u,l){if(u._zod){if(u._zod.traits.has(n))return}else{sr.value=new i(l);try{Object.defineProperty(u,"_zod",sr)}finally{sr.value=void 0}}if(u._zod.traits.add(n),e(u,l),a){let h=Object.getPrototypeOf(u),b=u._zod.constr.prototype,y=h;for(;y&&y!==b;)y=Object.getPrototypeOf(y);let k=y??h;a.has(k)||(a.add(k),oi(k,s))}let g=p.prototype;for(let h in g)Object.prototype.hasOwnProperty.call(g,h)&&(h in u||(u[h]=g[h].bind(u)))}let f=r?.Parent??Object;class c extends f{}Object.defineProperty(c,"name",{value:n});function p(u){let l=r?.Parent?ic(c):this;d(l,u);let g=l._zod.deferred;if(g){for(let b of g)b();l._zod.deferred=void 0}let h=globalThis.__zod_globalConfig?.postProcessor;return h&&h(l),l}return Object.defineProperty(p,"init",{value:d}),Object.defineProperty(p,Symbol.hasInstance,{value:u=>r?.Parent&&u instanceof r.Parent?!0:u?._zod?.traits?.has(n)}),Object.defineProperty(p,"name",{value:n}),p}var le=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};(si=globalThis).__zod_globalConfig??(si.__zod_globalConfig={});var Ue=globalThis.__zod_globalConfig;function J(n){return n&&Object.assign(Ue,n),Ue}function sc(){let n=this._zod;return n.message??(n.message=JSON.stringify(n.def,Bo,2)),n.message}function ac(n){this._zod.message=n}var dc={get:sc,set:ac,enumerable:!0,configurable:!0},dr={value:void 0,enumerable:!1},di=new WeakSet([Object.prototype,Error.prototype]),ci=(n,e)=>{n.name="$ZodError",dr.value=e,Object.defineProperty(n,"issues",dr),dr.value=void 0,Object.defineProperty(n,"message",dc);let t=Object.getPrototypeOf(n);di.has(t)||(di.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})}}))},ep=O("$ZodError",ci),$n=O("$ZodError",ci,void 0,{Parent:Error});var uc=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 le;if(a.issues.length){let d=new(i?.Err??n)(a.issues.map(f=>ce(f,s,J())));throw Qt(d,i?.callee??e),d}return a.value};return e},cr=uc($n),lc=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(f=>ce(f,s,J())));throw Qt(d,i?.callee??e),d}return a.value};return e},ur=lc($n),fc=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 le;return i.issues.length?ui(n,i.issues,o):{success:!0,data:i.value}},lr=fc($n);function ui(n,e,t){let r;return{success:!1,get error(){return r||(r=new n(e.map(o=>ce(o,t,J()))),e=void 0,t=void 0),r},set error(o){r=o,e=void 0,t=void 0}}}var pc=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?ui(n,i.issues,o):{success:!0,data:i.value}},fr=pc($n);var li=/^(?:[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 fi=/^https?$/;var pi=/^[\s\S]{0,}$/;var pr=/^-?\d+(?:\.\d+)?$/,hi=/^(?:true|false)$/i,gi=/^null$/i;var X=O("$ZodCheck",(n,e)=>{var t;n._zod??(n._zod={}),n._zod.def=e,(t=n._zod).onattach??(t.onattach=[])});var mi=n=>{let e=n.value;return!Uo(e)&&e.length!==void 0},st={number:"number",bigint:"bigint",object:"date"},yi=O("$ZodCheckLessThan",(n,e)=>{X.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})}}),bi=O("$ZodCheckGreaterThan",(n,e)=>{X.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})}}),vi=O("$ZodCheckMultipleOf",(n,e)=>{X.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):Vo(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})}}),xi=O("$ZodCheckNumberFormat",(n,e)=>{X.init(n,e),e.format=e.format||"float64";let t=e.format?.includes("int"),r=t?"int":"number",[o,i]=ei[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 wi=O("$ZodCheckMaxLength",(n,e)=>{var t;X.init(n,e),(t=n._zod.def).when??(t.when=mi),n._zod.check=r=>{let o=r.value,i=o.length;if((typeof o=="string"&&i>e.maximum?rr(o):i)<=e.maximum)return;let a=or(o);r.issues.push({origin:a,code:"too_big",maximum:e.maximum,inclusive:!0,input:o,inst:n,continue:!e.abort})}}),ki=O("$ZodCheckMinLength",(n,e)=>{var t;X.init(n,e),(t=n._zod.def).when??(t.when=mi),n._zod.check=r=>{let o=r.value,i=o.length;if((typeof o=="string"&&i>=e.minimum&&i<e.minimum*2?rr(o):i)>=e.minimum)return;let a=or(o);r.issues.push({origin:a,code:"too_small",minimum:e.minimum,inclusive:!0,input:o,inst:n,continue:!e.abort})}});var gr=O("$ZodCheckStringFormat",(n,e)=>{var t,r;X.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=()=>{})}),Si=O("$ZodCheckRegex",(n,e)=>{gr.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 Ri={major:4,minor:6,patch:5};var G=O("$ZodType",(n,e)=>{var t;n??(n={}),n._zod.def=e,n._zod.bag=n._zod.bag||{},n._zod.version=Ri;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,f)=>{if(a.memo)return a;let c=de(a),p;for(let u of d){if(u._zod.def.when){if(ti(a)||!u._zod.def.when(a))continue}else if(c)continue;let l=a.issues.length,g=u._zod.check(a);if(g instanceof Promise&&f?.async===!1)throw new le;if(p||g instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await g,a.issues.length!==l&&(tr(a.issues,l,n),c||(c=de(a,l)))});else{if(a.issues.length===l)continue;tr(a.issues,l,n),c||(c=de(a,l))}}return p?p.then(()=>a):a},s=(a,d,f)=>{if(de(a))return a.aborted=!0,a;let c=i(d,o,f);if(c instanceof Promise){if(f.async===!1)throw new le;return c.then(p=>n._zod.parse(p,f))}return n._zod.parse(c,f)};n._zod.run=(a,d)=>{if(d.skipChecks)return n._zod.parse(a,d);if(d.direction==="backward"){let c=n._zod.parse({value:a.value,issues:[]},{...d,skipChecks:!0});return c instanceof Promise?c.then(p=>s(p,a,d)):s(c,a,d)}let f=n._zod.parse(a,d);if(f instanceof Promise){if(d.async===!1)throw new le;return f.then(c=>i(c,o,d))}return i(f,o,d)}}},{get"~standard"(){return ir(this,"~standard",gc(this))},set"~standard"(n){Ee(this,"~standard",n)}}),zi=(n,e)=>n.issues.length?{issues:n.issues.map(t=>ce(t,e,J()))}:{value:n.value};async function hc(n,e){let t={async:!0};return zi(await n._zod.run({value:e,issues:[]},t),t)}function gc(n){return{validate:e=>{let t={async:!1};try{let r=n._zod.run({value:e,issues:[]},t);if(!(r instanceof Promise))return zi(r,t)}catch{}return hc(n,e)},vendor:"zod",version:1}}var mr=O("$ZodString",(n,e)=>{G.init(n,e),n._zod.pattern=e.pattern??pi,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}}),ct=O("$ZodStringFormat",(n,e)=>{gr.init(n,e),mr.init(n,e)});var Mi=O("$ZodEmail",(n,e)=>{e.pattern??(e.pattern=li),ct.init(n,e)}),Ni=1,at=2;function mc(n){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(n):(new URL(n),!0)}catch{return!1}}function yc(n,e){return!("normalize"in e)&&!("hostname"in e)&&!("protocol"in e)?mc(n)||at:bc(n,e)}function bc(n,e){if(!e.normalize&&e.protocol?.source===fi.source&&!/^https?:\/\//i.test(n))return Ni;try{if(typeof URL<"u"){let t=URL;if(typeof t.parse=="function")return t.parse(n)??at}return new URL(n)}catch{return at}}var vc=/[\t\n\r]/g;function _i(n){return n.replace(vc,"")}function xc(n,e){return e.lastIndex=0,e.test(n.hostname)}function wc(n,e){return e.lastIndex=0,e.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol)}var Ii=O("$ZodURL",(n,e)=>{ct.init(n,e),n._zod.check=t=>{try{let r=t.value.trim(),o=yc(r,e);if(o===Ni){t.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:t.value,inst:n,continue:!e.abort});return}if(o===at){t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort});return}if(o===!0){t.value=_i(r);return}e.hostname&&!xc(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&&!wc(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:_i(r);return}catch{t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort})}}});var yr=O("$ZodNumber",(n,e)=>{G.init(n,e),n._zod.pattern=pr,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}}),ji=O("$ZodNumberFormat",(n,e)=>{xi.init(n,e),yr.init(n,e)}),Ti=O("$ZodBoolean",(n,e)=>{G.init(n,e),n._zod.pattern=hi,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 Di=O("$ZodNull",(n,e)=>{G.init(n,e),n._zod.pattern=gi,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 Fi=O("$ZodUnknown",(n,e)=>{G.init(n,e),n._zod.parse=t=>t}),Zi=O("$ZodNever",(n,e)=>{G.init(n,e),n._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:n}),t)});function Ai(n,e,t){n.issues.length&&e.issues.push(...be(t,n.issues)),e.value[t]=n.value}var Li=O("$ZodArray",(n,e)=>{G.init(n,e);let t=Ue.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 f=i[d],c=e.element._zod.run({value:f,issues:[]},o);if(c instanceof Promise)s.push(c.then(p=>Ai(p,r,d)));else if(Ai(c,r,d),a&&c.issues.length!==0&&de(c))break}return s.length?Promise.all(s).then(()=>r):r}});function dt(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(...be(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 kc=[];function Sc(n){let e=Object.keys(n.shape),t=Object.getOwnPropertySymbols(n.shape),r=t.length?t:kc,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=Qo(n.shape);return{...n,allKeys:o,symbolKeys:r,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(i)}}function $c(n,e,t,r,o,i,s){let a=[],d=o.keySet,f=o.catchall._zod,c=f.def.type,p=f.optin,u=f.optout,l=0;for(let g in e){if(s&&t.issues.length!==l){if(de(t,l))break;l=t.issues.length}if(d.has(g))continue;if(g==="__proto__"){c==="never"&&a.push(g);continue}if(c==="never"){a.push(g);continue}let h=f.run({value:e[g],issues:[]},r);h instanceof Promise?n.push(h.then(b=>dt(b,t,g,e,p,u))):dt(h,t,g,e,p,u)}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 Ci=O("$ZodObject",(n,e)=>{G.init(n,e);let t=Object.getOwnPropertyDescriptor(e,"shape"),r=t?.get?t.get.raw:e.shape??{};if(r){let f=()=>{let c={...r};return Object.defineProperty(e,"shape",{value:c}),f.raw=c,c};f.raw=r,Object.defineProperty(e,"shape",{get:f})}let o=Ko(()=>Sc(e));U(n,"propValues",f=>{let c=f.def.shape,p={};for(let u in c){let l=c[u]._zod;if(l.values){Object.prototype.hasOwnProperty.call(p,u)||it(p,u,new Set);for(let g of l.values)p[u].add(g);l.optin!==void 0&&p[u].add(void 0)}}return p});let i=ot,s=e.catchall,a,d=Ue.memoizer;d?.attach(n),n._zod.parse=(f,c)=>{a??(a=o.value);let p=f.value;if(!i(p))return f.issues.push({expected:"object",code:"invalid_type",input:p,inst:n}),f;f.value=d?d.alloc(n,f,{},c):{};let u=[],l=a.shape,g=c?.abortEarly,h=f.issues.length;for(let b of a.allKeys){if(g&&f.issues.length!==h){if(de(f,h))break;h=f.issues.length}if(b==="__proto__")continue;let y=l[b],k=y._zod.optin,A=y._zod.optout,m=y._zod.run({value:p[b],issues:[]},c);m instanceof Promise?u.push(m.then(w=>dt(w,f,b,p,k,A))):dt(m,f,b,p,k,A)}return s?$c(u,p,f,c,o.value,n,g===!0):u.length?Promise.all(u).then(()=>f):f}});function Oi(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=>!de(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=>ce(s,r,J())))}),e)}var Gi=O("$ZodUnion",(n,e)=>{G.init(n,e),U(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),U(n,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),U(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)))}),U(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=>Jt(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=>Oi(a,r,n,o)):Oi(s,r,n,o)}});var Bi=O("$ZodRecord",(n,e)=>{G.init(n,e);let t=Ue.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 c of a)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){if(d.add(typeof c=="number"?c.toString():c),c==="__proto__")continue;let p=e.keyType._zod.run({value:c,issues:[]},o);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(p.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map(g=>ce(g,o,J())),input:c,path:[c],inst:n});continue}let u=p.value;if(u==="__proto__")continue;let l=e.valueType._zod.run({value:i[c],issues:[]},o);l instanceof Promise?s.push(l.then(g=>{g.issues.length&&r.issues.push(...be(c,g.issues)),r.value[u]=g.value})):(l.issues.length&&r.issues.push(...be(c,l.issues)),r.value[u]=l.value)}let f;for(let c in i)if(!d.has(c))if(e.mode==="loose"){if(c==="__proto__")continue;r.value[c]=i[c]}else f=f??[],f.push(c);f&&f.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:f,continue:!0})}else{r.value=t?t.alloc(n,r,{},o):{};let d;for(let f of Reflect.ownKeys(i)){if(f==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,f))continue;let c=e.keyType._zod.run({value:f,issues:[]},o);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof f=="string"&&pr.test(f)&&c.issues.length){let g=e.keyType._zod.run({value:Number(f),issues:[]},o);if(g instanceof Promise)throw new Error("Async schemas not supported in object keys currently");g.issues.length===0&&(c=g)}if(c.issues.length){e.mode==="loose"?r.value[f]=i[f]:a?(d=d??[],d.push(f)):r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(g=>ce(g,o,J())),input:f,path:[f],inst:n});continue}let u=c.value;if(u==="__proto__")continue;let l=e.valueType._zod.run({value:i[f],issues:[]},o);l instanceof Promise?s.push(l.then(g=>{g.issues.length&&r.issues.push(...be(f,g.issues)),r.value[u]=g.value})):(l.issues.length&&r.issues.push(...be(f,l.issues)),r.value[u]=l.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 Ki=O("$ZodEnum",(n,e)=>{G.init(n,e);let t=Ht(e.entries),r=new Set(t);n._zod.values=r,U(n,"pattern",o=>{let i=Ht(o.def.entries).filter(s=>Xo.has(typeof s));return new RegExp(i.length?`^(${i.map(s=>kn(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}}),Ui=O("$ZodLiteral",(n,e)=>{G.init(n,e);let t=new Set(e.values);n._zod.values=t,U(n,"pattern",r=>{let o=r.def.values;return new RegExp(o.length?`^(${o.map(i=>typeof i=="string"?kn(i):i?kn(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 Ei(n,e){return n.value=e.issues.length?void 0:e.value,n}var Vi=O("$ZodOptional",(n,e)=>{G.init(n,e),U(n,"optin",t=>t.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),n._zod.optout="optional",U(n,"values",t=>{let r=t.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),U(n,"pattern",t=>{let r=t.def.innerType._zod.pattern;return r?new RegExp(`^(${Jt(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=>Ei(t,i)):Ei(t,o)}return e.innerType._zod.run(t,r)}});var Wi=O("$ZodLazy",(n,e)=>{G.init(n,e),Wo(n._zod,"innerType",()=>{let t=e;return t._cachedInner||(t._cachedInner=e.getter()),t._cachedInner}),U(n,"pattern",t=>t.innerType?._zod?.pattern),U(n,"propValues",t=>t.innerType?._zod?.propValues),U(n,"optin",t=>t.innerType?._zod?.optin??void 0),U(n,"optout",t=>t.innerType?._zod?.optout??void 0),n._zod.parse=(t,r)=>n._zod.innerType._zod.run(t,r)}),qi=O("$ZodCustom",(n,e)=>{X.init(n,e),G.init(n,e),n._zod.parse=(t,r)=>t,n._zod.check=t=>{let r=t.value,o=e.fn(r);if(o instanceof Promise)return o.then(i=>Pi(i,t,r,n));Pi(o,t,r,n)}});function Pi(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(Sn(o))}}var Rc=()=>{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=ri(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 ${nr(i.values[0])}`:`Invalid option: expected one of ${Yt(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":""}: ${Yt(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 Hi(){return{localeError:Rc()}}var Yi;var br=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 Ji(){return new br}(Yi=globalThis).__zod_globalRegistry??(Yi.__zod_globalRegistry=Ji());var Ve=globalThis.__zod_globalRegistry;function Xi(n){return n.checks&&(n.checks=[...n.checks]),n}function Qi(n,e){return new n(Xi({type:"string",...N(e)}))}function es(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...N(e)})}function ns(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...N(e)})}function ts(n,e){return new n(Xi({type:"number",checks:[],...N(e)}))}function rs(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...N(e)})}function os(n,e){return new n({type:"boolean",...N(e)})}function is(n,e){return new n({type:"null",...N(e)})}function ss(n){return new n({type:"unknown"})}function as(n,e){return new n({type:"never",...N(e)})}function ds(n,e){return new yi({check:"less_than",...N(e),value:n,inclusive:!0})}function cs(n,e){return new bi({check:"greater_than",...N(e),value:n,inclusive:!0})}function Ec(n,e){return new vi({check:"multiple_of",...N(e),value:n})}function vr(n,e){return new wi({check:"max_length",...N(e),maximum:n})}function Rn(n,e){return new ki({check:"min_length",...N(e),minimum:n})}function _n(n,e){return new Si({check:"string_format",format:"regex",...N(e),pattern:n})}function us(n,e,t){return new n({type:"custom",check:"custom",fn:e,...N(t)})}function ls(n,e){let t=Pc(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(Sn(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(Sn(i))}},n(r.value,r)),e);return t}function Pc(n,e){let t=new X({check:"custom",...N(e)});return t._zod.check=n,t}function fs(n){let e=new X({check:"describe"});return e._zod.onattach=[t=>{let r=Ve.get(t)??{};Ve.add(t,{...r,description:n})}],e._zod.check=()=>{},e}var V=O("ZodMiniType",(n,e)=>{if(!n._zod)throw new Error("Uninitialized schema in ZodMiniType.");G.init(n,e),n.def=e,n.type=e.type},{get with(){return this.check},set with(n){Ee(this,"with",n)},parse(n,e){return cr(this,n,e,{callee:this.parse})},parseAsync(n,e){return ur(this,n,e,{callee:this.parseAsync})},safeParse(n,e){return lr(this,n,e)},safeParseAsync(n,e){return fr(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 Ke(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)}}),hs=O("ZodMiniString",(n,e)=>{mr.init(n,e),V.init(n,e)});function F(n){return Qi(hs,n)}var gs=O("ZodMiniStringFormat",(n,e)=>{ct.init(n,e),hs.init(n,e)}),Nc=O("ZodMiniEmail",(n,e)=>{Mi.init(n,e),gs.init(n,e)});function tm(n){return es(Nc,n)}var Ic=O("ZodMiniURL",(n,e)=>{Ii.init(n,e),gs.init(n,e)});function rm(n){return ns(Ic,n)}var ms=O("ZodMiniNumber",(n,e)=>{yr.init(n,e),V.init(n,e)});function An(n){return ts(ms,n)}var jc=O("ZodMiniNumberFormat",(n,e)=>{ji.init(n,e),ms.init(n,e)});function om(n){return rs(jc,n)}var Tc=O("ZodMiniBoolean",(n,e)=>{Ti.init(n,e),V.init(n,e)});function im(n){return os(Tc,n)}var Dc=O("ZodMiniNull",(n,e)=>{Di.init(n,e),V.init(n,e)});function sm(n){return is(Dc,n)}var Fc=O("ZodMiniUnknown",(n,e)=>{Fi.init(n,e),V.init(n,e)});function xr(){return ss(Fc)}var Zc=O("ZodMiniNever",(n,e)=>{Zi.init(n,e),V.init(n,e)});function Lc(n){return as(Zc,n)}var Cc=O("ZodMiniArray",(n,e)=>{Li.init(n,e),V.init(n,e)});function am(n,e){return new Cc({type:"array",element:n,...N(e)})}var wr=O("ZodMiniObject",(n,e)=>{Ci.init(n,e),V.init(n,e),ii(n,"shape",t=>t._zod.def.shape,!1)});function We(n,e){let t={type:"object",shape:n??{},...N(e)};return new wr(t)}function qe(n,e){return new wr({type:"object",shape:n,catchall:Lc(),...N(e)})}function dm(n,e){return new wr({type:"object",shape:n,catchall:xr(),...N(e)})}function ys(n,e){return ni(n,e)}var Gc=O("ZodMiniUnion",(n,e)=>{Gi.init(n,e),V.init(n,e)});function cm(n,e){return new Gc({type:"union",options:n,...N(e)})}var ps=O("ZodMiniRecord",(n,e)=>{Bi.init(n,e),V.init(n,e)});function um(n,e,t){return!e||!e._zod?new ps({type:"record",keyType:F(),valueType:n,...N(e)}):new ps({type:"record",keyType:n,valueType:e,...N(t)})}var Bc=O("ZodMiniEnum",(n,e)=>{Ki.init(n,e),V.init(n,e),n.options=[...n._zod.values]});function bs(n,e){let t=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new Bc({type:"enum",entries:t,...N(e)})}var Kc=O("ZodMiniLiteral",(n,e)=>{Ui.init(n,e),V.init(n,e)});function vs(n,e){return new Kc({type:"literal",values:Array.isArray(n)?n:[n],...N(e)})}var Uc=O("ZodMiniOptional",(n,e)=>{Vi.init(n,e),V.init(n,e)});function Q(n){return new Uc({type:"optional",innerType:n})}var Vc=O("ZodMiniLazy",(n,e)=>{Wi.init(n,e),V.init(n,e)});function lm(n){return new Vc({type:"lazy",getter:n})}var Wc=O("ZodMiniCustom",(n,e)=>{qi.init(n,e),V.init(n,e)});function ut(n,e={}){return us(Wc,n,e)}function fm(n,e){return ls(n,e)}var pm=fs;J().localeError||J(Hi());var j=n=>typeof n=="object"&&n!==null?n._zod?.def:void 0,qc=n=>{if(typeof n!="object"||n===null||!("_zod"in n))return;let e=Ve.get(n)?.description;return typeof e=="string"?e:void 0};var Hc=(n,e)=>n?.src?.(e)??e,lt=n=>typeof n=="string"&&n.length<2049&&/^(?![^/?#]*:|\/\/)(?!(?:.*\/)?\.\.?(?:[/?#]|$))(?!.*%2e)[^\\\s]+$/i.test(n),kr=(n,e=1)=>e>0&&n===void 0||Number.isInteger(n)&&n>=e;function Sr(n){let e=n??{};return lt(e.href)&&typeof e.name=="string"&&/^.{1,255}$/s.test(e.name)&&/^[\w.+-]{1,60}\/[\w.+-]{1,60}$/.test(e.type)&&kr(e.bytes,0)&&kr(e.width)&&kr(e.height)&&(e.caption===void 0||typeof e.caption=="string"&&e.caption.length<501)&&(e.poster===void 0||lt(e.poster))&&(e.captions===void 0||lt(e.captions))&&(e.duration===void 0||typeof e.duration=="number"&&Number.isFinite(e.duration)&&e.duration>0)&&(e.at===void 0||xs(e.at)!==void 0)}function xs(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 ws=n=>n.type.startsWith("image/"),ks=n=>n.type.startsWith("video/");function Yc(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 Jc=(n,e)=>e==="image"?ws(n):e==="video"?ks(n):!0,Xc=n=>`${n==="image"?"an image":n==="video"?"a video":"a file"} the host stored, at a path on this host`,On=n=>(Array.isArray(n)?n:[n]).filter(Sr),Ss=Symbol.for("@graview/core:file"),Qc=(n,e)=>(Object.defineProperty(j(n),Ss,{value:e,enumerable:!0}),n);function $s(n){let e=j(n);return e?.[Ss]??(e?.innerType?$s(e.innerType):void 0)}var eu=()=>({href:F(),name:F(),type:F(),bytes:An(),width:Q(An()),height:Q(An()),caption:Q(F()),poster:Q(F()),duration:Q(An()),captions:Q(F()),at:Q(F())});function hy(n){return Qc(We(eu()).check(ut(e=>Sr(e)&&Jc(e,n),Xc(n))),n)}var ft=/^(?:https?:\/\/[^\s<>"'`\\]+|@?[A-Za-z0-9][\w.~-]*(?:\/[\w.~-]+)*)$/,pt=n=>typeof n=="string"&&n.length<501&&ft.test(n);var Rs=n=>typeof n=="object"&&n!==null?n._zod?.def:void 0,nu=/^@(?:https?:\/\/[^\s<>"'`\\#?]+|[A-Za-z0-9][\w.~-]*(?:\/[\w.~-]+)*)\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;function _s(n){if(typeof n!="string"||!n.startsWith("@")||!nu.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 pt(o)?{address:o,kind:r}:void 0}var tu=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*:\S[^\n]{0,199}$/,ru=n=>`${n.kind}:${n.id}`;function As(n,e){if(typeof n!="string"||!tu.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 ou(n,e){return(Array.isArray(n)?n:n==null?[]:[n]).flatMap(r=>{let o=As(r,e);return o?[o]:[]})}var Os=Symbol.for("@graview/core:linked"),by=(n,e)=>(Object.defineProperty(Rs(n),Os,{value:e,enumerable:!0}),n);function En(n){let e=Rs(n);return e?e[Os]??En(e.innerType):void 0}function iu(n){let e=n?.fields?.shape??{},t=new Map;for(let[r,o]of Object.entries(e)){let i=En(o);i&&t.set(r,i)}return t}function su(n){if(n.to==="*"||n.to.length===0)return;let e=n.to.map(_s);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 au=n=>n.to!=="*"&&n.to.some(e=>typeof e=="string"&&e.startsWith("@"));function vy(n){return Object.fromEntries(Object.entries(n??{}).filter(([,e])=>!au(e)))}function xy(n){let e=new Map;for(let[t,r]of Object.entries(n??{})){let o=su(r);o&&e.set(t,o)}return e}var $r=new WeakMap;function du(n,e){e?$r.set(n,e):$r.delete(n)}var Es=n=>$r.get(n);var ht=["sun","mon","tue","wed","thu","fri","sat"],cu=["day","week","month","year"],Ye=n=>`${n}Repeat`,zn=n=>n.endsWith("Repeat")&&n.length>6?n.slice(0,-6):void 0,Ms=/^\d{4}-\d{2}-\d{2}$/,Ns=Symbol.for("@graview/core:repeat");function gt(n){let e=j(n);return!!e&&(e[Ns]===1||gt(e.innerType))}var uu=n=>(Object.defineProperty(j(n),Ns,{value:1,enumerable:!0}),n),Rr=(n,e,t)=>n===void 0||Number.isInteger(n)&&n>=e&&n<=t,Ps=(n,e)=>n===void 0||Array.isArray(n)&&n.length<=e&&n.every(t=>typeof t=="string"&&Ms.test(t)),lu=["every","interval","on","until","count","except","continues"],Is=n=>Je(n)&&Object.keys(n).every(e=>lu.includes(e))&&Rr(n.interval,1,99)&&Rr(n.count,1,1e3)&&Ps(n.until===void 0?void 0:[n.until],1)&&Ps(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"?ht.includes(e):n.every==="month"&&e!==0&&Rr(e,-1,31))),Sy=()=>uu(xr().check(ut(n=>n===null||Is(n),"how a date repeats, or null"))),Pn=n=>Date.UTC(+n.slice(0,4),+n.slice(5,7)-1,+n.slice(8,10)),js=n=>new Date(n).toISOString().slice(0,10),_r=(n,e)=>js(Pn(n)+e*864e5),zs=(n,e,t)=>{let r=new Date(Date.UTC(n,e+1,0)).getUTCDate();return js(Date.UTC(n,e,t<0||t>r?r:t))},Je=n=>typeof n=="object"&&n!==null&&cu.includes(n.every);function He(n,e,t={}){let r=n.slice(0,10),o=n.slice(10),i=[];if(!Ms.test(r))return i;let s=Math.max(1,e.interval??1),a=e.every,d=t.from&&t.from>r?t.from.slice(0,10):r,f=[e.until,t.to?.slice(0,10)].filter(Boolean).sort()[0],c=t.limit??1e3,p=new Set(e.except??[]),u=+r.slice(0,4),l=+r.slice(5,7)-1,g=+r.slice(8,10),h=_r(r,-new Date(Pn(r)).getUTCDay()),b=(e.on?.length?e.on:[a==="week"?ht[new Date(Pn(r)).getUTCDay()]:g]).map(w=>typeof w=="string"?ht.indexOf(w):w),y=a==="day"?1:a==="week"?7:0,k=(+d.slice(0,4)-u)*12+(+d.slice(5,7)-1-l),A=e.count?0:Math.max(0,Math.floor((y?(Pn(d)-Pn(y===7?h:r))/864e5/y:a==="month"?k:k/12)/s)-1),m=0;for(let w=0;w<5e4&&i.length<c;w++,A++){let S=A*s,v=a==="day"?[_r(r,S)]:a==="week"?b.map(x=>_r(h,S*7+x)):a==="month"?b.map(x=>zs(u,l+S,x)):[zs(u+S,l,g)];for(let x of[...new Set(v)].sort())if(!(x<r)&&(f&&x>f||e.count&&m>=e.count||(m++,x>=d&&!p.has(x)&&i.push(x+o),i.length>=c)))return i}return i}function Ts(n,e,t){if(!Je(e)||typeof n!="string")return n;let r=He(n,e,{from:t,limit:1})[0];if(r)return r;let o=e.until||e.count?He(n,e):[];return o[o.length-1]??n}function fu(n,e,t){let r=n[e],o=n[Ye(e)];return typeof r=="string"&&Je(o)?Ts(r,o,t):r}function Mn(n,e){if(n.onBehalfOf){let{onBehalfOf:i,...s}=n;return`${Mn(s,e)}, for ${Mn(i,e)}`}if(n.id===void 0)return n.name??(n.kind==="agent"?"an agent":n.kind);let t=e.graph.getNode(n.id);if(t)return Z(e.schema.tryDefinition(t.kind),t);let r=e.seats?.find(i=>i.principal.id===n.id);if(r)return r.label;let o=e.people?.find(i=>i.id===n.id&&(i.kind===void 0||i.kind===n.kind));return o?o.name:n.name?n.name:/(^|:)migration$/.test(n.id)?"the upgrade":n.id.startsWith("form:")?"a visitor via a form":/[:_/]/.test(n.id)?{human:"somebody",agent:"an agent",rule:"a rule",system:"the system"}[n.kind]:n.id}var Xe="$archived",Pe=n=>n?.[Xe]===!0,Ay=(n,e=!1)=>e==="all"||Pe(n)===e,Ar=n=>n===!0||n==="true"?!0:n==="all"?"all":!1,Nn="$leftAlone",mt=new Set([Xe,Nn]);var te=class extends Error{constructor(t,r){super(r?`${t}
|
|
2
|
+
\u2192 ${r}`:t);this.hint=r;this.name="SchemaError"}};function pu(n,e){let t=n,r=new Map;for(let a of t){if(r.has(a.kind))throw new te(`Duplicate node kind "${a.kind}"`,"Each kind may be declared once; merge the two defineNode calls.");r.set(a.kind,a)}let o=new Map;for(let a of t)for(let[d,f]of Object.entries(a.edges)){if(f.to!=="*"){for(let p of f.to)if(!r.has(p))throw new te(`Edge "${d}" on "${a.kind}" points at undeclared kind "${p}"`,`Declared kinds: ${[...r.keys()].join(", ")}`)}let c=o.get(d);c?c.from.push(a.kind):o.set(d,{from:[a.kind],decl:f})}let i=new Map;for(let[a,{from:d,decl:f}]of o){let c=d.map(p=>r.get(p).edges[a].to);i.set(a,{kind:a,from:d,to:c.includes("*")?"*":[...new Set(c.flat())],cardinality:f.cardinality??"many",...f.description===void 0?{}:{description:f.description}})}let s=new Map;for(let a of t)s.set(a.kind,ys(a.fields,{id:F().check(Rn(1)),kind:vs(a.kind)}));return{definitions:t,computed:e,kinds:t.map(a=>a.kind),edgeKinds:[...i.keys()],definition(a){let d=r.get(a);if(!d)throw new te(`Unknown node kind "${String(a)}"`,`Declared kinds: ${[...r.keys()].join(", ")}`);return d},tryDefinition(a){return r.get(a)},edge(a){return i.get(a)},edgeAllowed(a,d,f){let c=r.get(d)?.edges[a];return c?c.to==="*"||c.to.includes(f):!1},parseNode(a){let d=a?.kind;if(typeof d!="string")throw new te("Node is missing a `kind`");let f=s.get(d);if(!f)throw new te(`Unknown node kind "${d}"`,`Declared kinds: ${[...r.keys()].join(", ")}`);let c={},p={};for(let[l,g]of Object.entries(a))mt.has(l)?g===!0&&(p[l]=!0):c[l]=g;let u=f.parse(c);return Object.keys(p).length>0?{...u,...p}:u},__node:void 0}}function M(n){return`${n.kind}\0${n.from}\0${n.to}`}var In={addedNodes:[],removedNodes:[],changedNodes:[],addedEdges:[],removedEdges:[],touched:[]};function Ds(n){return n.addedNodes.length===0&&n.removedNodes.length===0&&n.changedNodes.length===0&&n.addedEdges.length===0&&n.removedEdges.length===0}function hu(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 Qe(n,e){let t=new Map(n.nodes.map(u=>[u.id,u])),r=new Map(e.nodes.map(u=>[u.id,u])),o=e.nodes.filter(u=>!t.has(u.id)),i=n.nodes.filter(u=>!r.has(u.id)),s=[];for(let u of n.nodes){let l=r.get(u.id);if(!l||l===u)continue;let g=hu(u,l);g.length>0&&s.push({before:u,after:l,fields:g})}let a=new Map(n.edges.map(u=>[M(u),u])),d=new Map(e.edges.map(u=>[M(u),u])),f=e.edges.filter(u=>!a.has(M(u))),c=n.edges.filter(u=>!d.has(M(u))),p=new Set;for(let u of o)p.add(u.id);for(let u of i)p.add(u.id);for(let u of s)p.add(u.after.id);for(let u of[...f,...c])p.add(u.from),p.add(u.to);return{addedNodes:o,removedNodes:i,changedNodes:s,addedEdges:f,removedEdges:c,touched:[...p].sort()}}function ve(n,e,t){let r=new Set(t.flatMap(i=>i.op==="patch-node"?[i.id]:"node"in i?[i.node.id]:[i.edge.from,i.edge.to]));if(r.size===0)return In;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 Qe(o(n),o(e))}function gu(n){let e=n?.issues;return!Array.isArray(e)||e.length===0?n instanceof Error?n.message:String(n):e.map(t=>{let r=t.path?.length?C(String(t.path.at(-1))):null,o=t.message??"is not what the declaration allows";return r?`${r}: ${o}`:o}).join("; ")}var I=class extends Error{constructor(t,r){super(r?`${t}
|
|
3
|
+
${r}`:t);this.hint=r;this.name="GraphError"}},B=class extends I{constructor(t,r){super(r);this.id=t;this.name="MissingRecordError"}};function yt(n,e){try{n.parseNode(e);return}catch(t){if(t instanceof te)throw t;let r=t.issues??[];return{fields:new Set(r.flatMap(i=>i.code==="unrecognized_keys"&&i.keys?[...i.keys]:typeof i.path?.[0]=="string"?[i.path[0]]:[""])),error:t}}}var Or="n\0",Er="e\0",W=class n{constructor(e,t={}){this.schema=e;this.validate=t.validate??!0}nodes=new Map;edges=new Map;outIndex=new Map;inIndex=new Map;rank=0;ranks=new Map;lapsed=new Map;reordered=!1;counts=new Map;archived=new Set;listeners=new Set;validate;static from(e,t,r={}){let o=new n(e,r);return o.load(t),o}load(e){let t=this.snapshot();this.restore(e);let r=Qe(t,this.snapshot());return this.emit(r),r}getNode(e){return this.nodes.get(e)}has(e){return this.nodes.has(e)}allNodes(e){return this.reach([...this.nodes.values()],e,this.held)}count(e,t){return t||this.archived.size?this.nodesOfKind(e,t).length:this.counts.get(e)??0}allEdges(e){return this.reach([...this.edges.values()],e,t=>this.archived.has(t.from)||this.archived.has(t.to))}nodesOfKind(e,t){return this.allNodes(t).filter(r=>r.kind===e)}edgesOfKind(e,t){return this.allEdges(t).filter(r=>r.kind===e)}out(e,t,r){return this.reach(this.resolve(this.outIndex.get(e),t,"to"),r,this.held)}in(e,t,r){return this.reach(this.resolve(this.inIndex.get(e),t,"from"),r,this.held)}neighbors(e,t){let r=new Map;for(let o of[...this.out(e,void 0,t),...this.in(e,void 0,t)])r.set(o.id,o);return[...r.values()]}isArchived(e){return this.archived.has(e)}outEdges(e,t){return this.edgesFrom(this.outIndex.get(e),t)}inEdges(e,t){return this.edgesFrom(this.inIndex.get(e),t)}snapshot(){return{nodes:[...this.nodes.values()],edges:[...this.edges.values()]}}get size(){return{nodes:this.nodes.size,edges:this.edges.size}}applyPrimitives(e,t={}){let r=this.snapshot();try{for(let i of e)this.applyOne(i,t.restoring===!0,t.inPlace===!0);this.settleOrder()}catch(i){throw this.restore(r),i}let o=ve(r,this.snapshot(),e);return this.emit(o),o}preview(e,t={}){return n.from(this.schema,this.snapshot(),{validate:this.validate}).applyPrimitives(e,t)}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}restore(e){for(let t of[this.nodes,this.edges,this.outIndex,this.inIndex,this.ranks,this.lapsed,this.counts,this.archived])t.clear();this.reordered=!1;for(let t of e.nodes)this.insertNode(t,!0);for(let t of e.edges)this.insertEdge(t,!0)}tally(e,t){this.counts.set(e,(this.counts.get(e)??0)+t)}place(e,t){let r=t?this.lapsed.get(e):void 0;if(r===void 0){this.ranks.set(e,++this.rank);return}this.ranks.set(e,r),this.lapsed.delete(e),this.reordered=!0}lapse(e){let t=this.ranks.get(e);t!==void 0&&(this.ranks.delete(e),this.lapsed.set(e,t),this.lapsed.size>4096&&this.lapsed.delete(this.lapsed.keys().next().value))}settleOrder(){if(!this.reordered)return;this.reordered=!1;let e=o=>(i,s)=>this.ranks.get(o+i[0])-this.ranks.get(o+s[0]),t=[...this.nodes.entries()].sort(e(Or));this.nodes.clear();for(let[o,i]of t)this.nodes.set(o,i);let r=[...this.edges.entries()].sort(e(Er));this.edges.clear();for(let[o,i]of r)this.edges.set(o,i)}emit(e){if(!(e.addedNodes.length===0&&e.removedNodes.length===0&&e.changedNodes.length===0&&e.addedEdges.length===0&&e.removedEdges.length===0))for(let t of this.listeners)t(e)}applyOne(e,t,r){switch(e.op){case"add-node":this.insertNode(e.node,t,r);return;case"remove-node":{let o=e.node.id,i=this.nodes.get(o);if(!i)throw new B(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(Or+o),this.outIndex.delete(o),this.inIndex.delete(o);return}case"patch-node":{let o=this.nodes.get(e.id);if(!o)throw new B(e.id,`Cannot patch missing node "${e.id}"`);let i={...o};for(let[a,d]of Object.entries(e.after))Ze(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[Pe(s)?"add":"delete"](e.id),s.kind!==o.kind&&(this.tally(o.kind,-1),this.tally(s.kind,1));return}case"add-edge":this.insertEdge(e.edge,t,r);return;case"remove-edge":{if(!this.edges.has(M(e.edge)))throw new B(M(e.edge),`Cannot remove missing edge ${M(e.edge)}`);this.deleteEdge(e.edge);return}}}check(e){if(!this.validate)return e;try{return this.schema.parseNode(e)}catch(t){throw this.refusal(e,t)}}checkPatch(e,t,r){if(!this.validate)return t;let o=this.schema.tryDefinition(String(t.kind))?.fields?.shape;if(!o)return this.check(t);for(let a of r){if(a==="id"||a==="kind"||mt.has(a))continue;let d=o[a];if(!d){delete t[a];continue}let f=d.safeParse(t[a]);f.success&&(f.data===void 0?delete t[a]:t[a]=f.data)}let i=yt(this.schema,t);if(i===void 0)return t;let s=yt(this.schema,e)?.fields??new Set;if([...i.fields].some(a=>r.includes(a)||!s.has(a)))throw this.refusal(t,i.error);return t}refusal(e,t){if(t instanceof te)return t;{let r=e?.id??"?",o=e?.kind??"?",i=this.schema.tryDefinition(o),s=i&&e&&typeof e=="object"?Z(i,e):r;return new I(`${s} does not match what ${o} declares`,gu(t))}}insertNode(e,t,r=!1){if(this.nodes.has(e.id))throw new I(`Duplicate node id "${e.id}"`);this.nodes.set(e.id,t?e:this.check(e)),Pe(e)&&this.archived.add(e.id),this.tally(e.kind,1),this.place(Or+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 B(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 I(`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=M(e);this.edges.has(s)||(this.edges.set(s,e),this.place(Er+s,r),this.index(this.outIndex,e.from,s),this.index(this.inIndex,e.to,s))}deleteEdge(e){let t=M(e);this.edges.delete(t),this.lapse(Er+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 bt=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 mu(n,e){return{...e,name:n}}var vt=class extends Error{constructor(e){super(e),this.name="RuleBudgetError"}};function Fs(n,e,t){try{return e().map(r=>r.status?r:{...r,status:"violated"})}catch(r){let o=r instanceof vt,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 en(n,e,t={}){let r=t.context??{},o=t.today===void 0?{}:{today:t.today},i=t.onUnregistered??"skip",s=new Set(e.map(u=>u.name)),a=[];for(let u of e)u.scope==="graph"&&a.push(...Fs(u,()=>u.evaluate({graph:n,subject:void 0,context:r,...o}),void 0));let d=e.filter(u=>u.scope!=="graph"),f=new Map;for(let u of d){let l=u.scope.kind,g=f.get(l);g?g.push(u):f.set(l,[u])}for(let u of n.allNodes()){let l=n.schema.tryDefinition(u.kind),g=l?.requiresInvariant?.(u)??null;if(t.subjectFilter&&!t.subjectFilter(u,r))continue;if(g!==null&&!s.has(g)){if(i==="throw")throw new bt(g,u.id);continue}let h=!Vt(l,u,t.today);for(let b of f.get(u.kind)??[]){if(h&&b.judgesPast!==!0)continue;let y=b.scope.match;y&&!y(u)||a.push(...Fs(b,()=>b.evaluate({graph:n,subject:u,context:r,...o}),u.id))}}let c=new Set,p=a.filter(u=>{let l=`${u.message}|${[...u.nodeIds].sort().join(",")}`;return c.has(l)?!1:(c.add(l),!0)}).map(u=>{let l=Ut(u.message);return l===u.message?u:{...u,message:l}});return Pr?Pr(n,e,p,t.today):p}var Pr;function By(n){Pr=n}function yu(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 bu(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 xt=(n,e)=>n==="*"||n.includes(e);function D(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 q=n=>n.kind==="system"&&n.onBehalfOf===void 0,xe=(n,e)=>n.roles==="*"||(e.roles??[]).some(t=>n.roles.includes(t));function Zs(n){return Zo(n.map(e=>Be(C(e).toLowerCase())),"or")}function we(n,e,t,r,o,i,s={},a,d,f){if(!n)return{ok:!0};if(q(e))return{ok:!0};if(e=D(e),o!==void 0){if(we(n,e,t,r,void 0,i).ok)return{ok:!0};let l=!1;if(o.some(y=>we(n,e,y,r,void 0,i).ok)){if(!d||i===void 0||e.id!==void 0&&d()===e.id||!f&&n.grants.some(y=>y.roles!=="*"&&xe(y,e)&&o.some(k=>xt(y.mutations,k))))return{ok:!0};l=!0}let g=l?[t]:[t,...o],h=[...new Set(g.flatMap(y=>zr(n,y,r)))].sort(),b=(l?"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":`${Zs(h)} can`);return{ok:!1,refusal:{mutation:t,...r===void 0?{}:{kind:r},wouldNeed:h,message:Ls(n,g,r,b,s)}}}let c=!1;for(let l of n.grants){if(!xe(l,e)||!xt(l.mutations,t)||l.kinds!==void 0&&l.kinds!=="*"&&(r===void 0||!l.kinds.includes(r))||l.self&&(i===void 0||e.id===void 0||i!==e.id))continue;let g=l.ownEnd?a?.()??[]:[e.id];if(!g.length||g.some(h=>h!==e.id)){c=!0;continue}return{ok:!0}}let p=zr(n,t,r),u=c?"only on your own end of the link":p.length===0?"no role can":`${Zs(p)} can`;return{ok:!1,refusal:{mutation:t,...r===void 0?{}:{kind:r},wouldNeed:p,message:Ls(n,[t],r,u,s)}}}function Ls(n,e,t,r,o){let i=[...new Set(e.flatMap(a=>Cs(n,a,t)))],s=o.act?.(e[0]);return`Not permitted: ${s?`\u201C${s}\u201D`:e[0]}${t?` on ${Be(o.noun?.(t)??t)}`:""} \u2014 ${r}.`+(i.length>0?` ${i.join(" ")}`:"")}function Cs(n,e,t){return[...new Set(Gs(n,e,t).flatMap(r=>r.describe||[]))]}var Gs=(n,e,t)=>n.grants.filter(r=>xt(r.mutations,e)&&(t===void 0||xt(r.kinds??"*",t)));function zr(n,e,t){let r=Gs(n,e,t);return r.some(o=>o.roles==="*")?[]:[...new Set(r.flatMap(o=>o.roles))].sort()}function Mr(n,e,t){return n?t.filter(r=>{let o=D(e).id;return Nr(r).some(i=>we(n,e,r.name,i,void 0,o,void 0,()=>[o??[]].flat()).ok)}):t}var Nr=n=>n.subject&&n.subject.kinds!=="*"?n.subject.kinds:[void 0];var ee=class extends Error{constructor(t,r="refused"){super(t);this.sentence=t;this.reason=r;this.name="ActRefusal"}};var jn=class{constructor(e,t,r){this.present=e;this.timeline=t;this.unversioned=r}nodes=new Map;edges=new Map;touching=new Map;seq=Number.MAX_SAFE_INTEGER;wrote=new Map;begin(e){this.seq=e,this.wrote.clear()}writerOf(e){return t=>{let r=`${e}\0${t}`;return this.wrote.has(r)?this.wrote.get(r):this.timeline?.writers?.writerAt(e,t,this.seq)}}note(e,t){let r=e.op==="add-node"?e.node.id:e.op==="patch-node"?e.id:"";if(r===""||this.unversioned?.has(r))return;let o=e.op==="add-node"?Object.keys(e.node):Object.keys(e.after);for(let i of o)i!=="id"&&i!=="kind"&&this.wrote.set(`${r}\0${i}`,t(r,i))}node(e){return this.nodes.has(e)?this.nodes.get(e)??void 0:this.present.getNode(e)}setNode(e,t){this.nodes.set(e,t)}setEdge(e,t){let r=M(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=M(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,Bs(t,e.before));return}case"add-edge":this.setEdge(e.edge,!1);return;case"remove-edge":this.setEdge(e.edge,!0);return}}apply(e){switch(e.op){case"add-node":this.setNode(e.node.id,e.node);return;case"remove-node":for(let t of this.incident(e.node.id))this.setEdge(t,!1);this.setNode(e.node.id,null);return;case"patch-node":{if(this.unversioned?.has(e.id))return;let t=this.node(e.id);if(!t)return;this.setNode(e.id,Bs(t,e.after));return}case"add-edge":this.setEdge(e.edge,!0);return;case"remove-edge":this.setEdge(e.edge,!1);return}}};function Bs(n,e){let t={...n};for(let[r,o]of Object.entries(e))Ze(o)?delete t[r]:t[r]=o;return t}var vu=n=>n.op==="add-node"||n.op==="remove-node"?n.node.id:n.op==="patch-node"?n.id:void 0;function Ir(n,e,t,r){let o=c=>{let p=e.node(c);return p?t.served(p,e.writerOf(c))!==void 0:t.sees?.(c)??!1},i=vu(n);if(i===void 0){let c=n.edge,p=t.edgeClean(c)&&o(c.from)&&o(c.to);return e.apply(n),{primitives:p?[n]:[],faithful:!0}}let s=e.node(i),a=s?t.served(s,e.writerOf(i)):void 0;e.apply(n),e.note(n,r);let d=e.node(i),f=d?t.served(d,e.writerOf(i)):void 0;if(!a&&!f)return{primitives:[],faithful:!1};if(!a&&f){let c=e.incident(i).filter(u=>t.edgeClean(u)&&o(u.from===i?u.to:u.from)).map(u=>({op:"add-edge",edge:u})),p=n.op==="add-node"&&f===n.node&&c.length===0;return{primitives:p?[n]:[{op:"add-node",node:f},...c],faithful:p}}if(a&&!f){let c=n.op==="remove-node"&&a===s;return{primitives:c?[n]:[{op:"remove-node",node:a}],faithful:c}}if(n.op==="patch-node"){let c=(u,l)=>g=>g in u==(l!==void 0&&g in l);if(Object.keys(n.after).every(u=>c(a,s)(u)&&c(f,d)(u)))return{primitives:[n],faithful:!0};let p=u=>Object.fromEntries(Object.keys(n.after).map(l=>[l,l in u?u[l]:he]));return{primitives:[{op:"patch-node",id:i,before:p(a),after:p(f)}],faithful:!1}}return{primitives:[{op:"remove-node",node:a},{op:"add-node",node:f}],faithful:!1}}function Ks(n,e,t){if(n.length===0)return[];let r=e.log.all(),o=r[0]?.seq??0,i=n.every(u=>r[u.seq-o]?.id===u.id),s=new jn(e.present,e);if(!i)return s.begin(e.log.length??o+r.length),n.map(u=>{let l=D(u.author).id,g=u.primitives.map(h=>Ir(h,s,t,()=>l));return{op:u,primitives:g.flatMap(h=>h.primitives),faithful:g.every(h=>h.faithful)}});let a=new Set(n.map(u=>u.seq)),d=Number.POSITIVE_INFINITY,f=Number.NEGATIVE_INFINITY;for(let u of a)u<d&&(d=u),u>f&&(f=u);d-=o,f-=o;let c=xu(r,d,e.present,t),p=c?new jn(e.present,e,c.unversioned):s;for(let u=r.length-1;u>=d;u--){let l=r[u].primitives;for(let g=l.length-1;g>=0;g--)p.undo(l[g])}return wu(n,r,d,f,a,p,c?.judge??t,e)}function xu(n,e,t,r){let{sees:o,names:i}=r;if(!o||!i)return;let s=new Set,a=new Set,d=new Set,f=(p,u)=>{s.has(p)||a.has(p)||(o(p)?i(u)?(a.add(p),d.delete(p)):d.add(p):(s.add(p),d.delete(p)))};for(let p=e;p<n.length;p++)for(let u of n[p].primitives)u.op==="add-node"||u.op==="remove-node"?f(u.node.id,u.node):u.op==="patch-node"&&(f(u.id,u.before),f(u.id,u.after));for(let p of d){let u=t.getNode(p);u&&i(u)&&(d.delete(p),a.add(p))}return{unversioned:new Set([...d,...s]),judge:{...r,served:(p,u)=>d.has(p.id)?p:s.has(p.id)?void 0:r.served(p,u)}}}function wu(n,e,t,r,o,i,s,a){let d=new Map;for(let f=t;f<=r;f++){let c=e[f];if(i.begin(c.seq),!o.has(c.seq)){for(let l of c.primitives)i.apply(l);continue}let p=(l,g)=>a.writers?.writerAt(l,g,c.seq+1),u=c.primitives.map(l=>Ir(l,i,s,p));d.set(c.seq,{op:c,primitives:u.flatMap(l=>l.primitives),faithful:u.every(l=>l.faithful)})}return n.map(f=>d.get(f.seq))}function Qy(n,e,t,r){let o=new jn(e.present,e);return o.begin(e.log.length??e.log.all().length),n.flatMap(i=>Ir(i,o,t,()=>r).primitives)}var Vs="A change you cannot see",Ws={kind:"system",id:"withheld",name:"Someone"};function nn(n){return n.withheld===!0}var Tn=Re,qs=(n,e)=>Object.entries(n).some(([t,r])=>t!=="id"&&t!=="kind"&&T(r,e));function Hs(n){if(typeof n!="function")return n;let e=n,t=r=>e(r.id)&&!qs(r,e)?r:void 0;return{sees:e,shows:e,served:t,servedWith:t,optional:()=>!1,kindOf:()=>{}}}function T(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(T(n[t],e))return!0;return!1}for(let t in n)if(Object.hasOwn(n,t)&&(!e(t)||T(n[t],e)))return!0;return!1}function Ys(n,e){let t=r=>!e(r);return n.primitives.some(r=>Tn(r).some(t))||[...n.writes,...n.reads].some(t)||n.mutation!==null&&T(n.mutation.args,e)}function ku(n,e){if(Tn(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 qs(t,e.sees)?{op:"remove-node",node:Object.fromEntries(Object.entries(t).filter(([r,o])=>r==="id"||r==="kind"||!T(o,e.sees)))}:n}case"patch-node":{let t=e.kindOf(n.id),r={};for(let[i,s]of Object.entries(n.after))if(!T(s,e.sees))r[i]=s;else if(t!==void 0&&e.optional(t,i))r[i]=he;else return;let o=Object.fromEntries(Object.entries(n.before).filter(([,i])=>!T(i,e.sees)));return{op:"patch-node",id:n.id,before:o,after:r}}case"add-edge":case"remove-edge":return T(n.edge,e.sees)?void 0:n}}function jr(n,e,t){let r=Hs(e),o=i=>r.shows(i)&&Js(r,i);return{id:n.id,seq:n.seq,batch:n.batch,author:Ws,intent:Vs,mutation:null,primitives:t??n.primitives.flatMap(i=>{let s=ku(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 tn(n,e){let t=Hs(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=>!T(i,r.sees),sees:r.sees,names:i=>T(i,r.sees)};return Ks(n,r.timeline,o).map(({op:i,primitives:s,faithful:a})=>(!i.withheld&&a?Us(i,r,s):void 0)??jr(i,r,s))}return n.map(o=>(!o.withheld&&!Ys(o,r.shows)?Us(o,r):void 0)??jr(o,r))}function Us(n,e,t){let r=n.inverse??n.primitives;if(t&&t.length<n.primitives.length){if(!t.length)return;r=r.filter(h=>Tn(h).every(e.shows));let{inverse:l,...g}=n;n={...g,primitives:t}}let o=l=>e.sees(l)&&Js(e,l),i=n.reads.filter(o),s=new Set(n.primitives.flatMap(Tn)),a=n.writes.filter(l=>o(l)||e.sees(l)&&s.has(l)),d=i.length===n.reads.length&&a.length===n.writes.length?n:{...n,reads:i,writes:a},f=e.actor!==void 0&&D(n.author).id===e.actor;if(!f&&n.described?.some(l=>!e.sees(l)))return;if(!T(n,e.sees))return d;let c=new Set,p=l=>{if(typeof l=="string")c.add(l);else if(Array.isArray(l))for(let g of l)p(g);else if(l!==null&&typeof l=="object")for(let[g,h]of Object.entries(l))c.add(g),p(h)};t&&p(t);let u=l=>e.sees(l)||c.has(l);if(!T(r,u))return f&&n.mutation&&p(n.mutation.args),T({...d,primitives:[],inverse:[]},f?u:e.sees)?void 0:d}function Js(n,e){return n.timeline===void 0||n.kindOf(e)!==void 0}var ze=class extends I{constructor(t){super(t.message);this.check=t;this.name="UndoBlockedError"}get blockedBy(){return this.check.blockedBy}};function Dn(n,e){let t=new Set(e),r=n.undoneIds(),o=n.all().filter(l=>t.has(l.batch)&&!r.has(l.id)),i=[...n.epochs()].reverse().find(l=>l.horizon);if(i){let l=new Set(n.all().map(h=>h.batch)),g=e.filter(h=>!l.has(h));if(g.length>0)return{ok:!1,ops:o,blockedBy:[],includeBatches:[],reason:"missing",message:`Cannot undo ${g.map(h=>`batch ${h}`).join(", ")}: it is not after the undo horizon at op ${i.seq}${i.at?` (${i.at})`:""}. What was done before the horizon is archived, and undo does not reach behind it.`}}if(o.length===0)return{ok:!1,ops:o,blockedBy:[],includeBatches:[],reason:"missing",message:e.length===0?"No batch given to undo":`Nothing live to undo in ${e.join(", ")} \u2014 already undone, or never applied`};if(o.some(nn))return{ok:!1,ops:o,blockedBy:[],includeBatches:[],reason:"forbidden",message:o.every(nn)?"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(l=>l.enabledModules!==void 0))return{ok:!1,ops:o,blockedBy:[],includeBatches:[],message:"Cannot undo turning a module off or on: it is changed by turning the module the other way."};let s=new Set;for(let l of o)for(let g of l.writes)s.add(g);let a=Math.min(...o.map(l=>l.seq)),d=n.epochs().find(l=>l.change!==void 0&&l.seq>a);if(d){let l=o.find(g=>g.seq<d.seq);return{ok:!1,ops:o,blockedBy:[],includeBatches:[],message:`Cannot undo "${l.intent}": ${l.intent===d.change?"it changed the declaration":`it was done before the declaration changed (${d.change})`}, and undo does not reach back across that change.`}}let f=new Map(n.all().map(l=>[l.id,l.seq])),c=[];for(let l of n.all()){if(l.seq<=a||t.has(l.batch)||r.has(l.id)||l.undoes!==void 0&&(f.get(l.undoes)??-1)>a)continue;let g=l.reads.filter(h=>s.has(h));g.length>0&&c.push({op:l,overlap:g})}if(c.length===0)return{ok:!0,ops:o};let p=c.filter(l=>!nn(l.op)).map(l=>`"${l.op.intent}" (op ${l.op.id}, read ${l.overlap.join(", ")})`).join("; ");if(c.some(l=>nn(l.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 u=[...new Set(c.map(l=>l.op.batch))];return{ok:!1,ops:o,blockedBy:c,includeBatches:u,message:`Cannot undo on its own \u2014 a later operation depends on it: ${p}. Include ${u.map(l=>`batch ${l}`).join(", ")} to undo them together.`}}function Xs(n){return[...n].sort((e,t)=>t.seq-e.seq).flatMap(e=>_e(e))}var Me=class extends Error{refusal;constructor(e){super(e.message),this.name="PermissionDeniedError",this.refusal=e}};function Su(n){let e=n instanceof Error?n.message:String(n);if(n instanceof Me){let t=n.refusal.wouldNeed;return{reason:"forbidden",sentence:e,...t.length>0?{wouldNeed:[...t]}:{}}}return n instanceof B?{reason:"missing",sentence:e}:n instanceof ee?{reason:n.reason,sentence:n.sentence}:n instanceof ze?{reason:n.check.reason??"invalid",sentence:e}:{reason:"invalid",sentence:e}}var oe=class extends I{constructor(t,r){super(`Invalid arguments for mutation "${t}"`,r.map(o=>`${o.path.map(String).join(".")||"(root)"}: ${o.message}`).join("; "));this.mutation=t;this.issues=r;this.name="InvalidArguments"}};function yb(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 ea=["connect","disconnect"],na=n=>n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),ta=(n,e,t)=>`${n}-${e}-${na(t)}`;function bb(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}-${na(i)}`)return{act:t[1],kind:r,relation:i}}}}var Qs=n=>`${/^[aeiou]/i.test(n)?"an":"a"} ${n}`;function ra(n,e){let t=e.also?` (${e.also})`:"";return{title:`${e.one?`${n==="connect"?"Set":"Clear"} the ${e.to}`:`${n==="connect"?"Link":"Unlink"} ${Qs(e.to)}`}${t}`,fromTheOtherEnd:`${n==="connect"?"Link":"Unlink"} ${Qs(e.from)}${t}`}}function oa(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 $u=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 })`,rn=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?$u(e):`Op "${e.id}" has seq ${e.seq} but the log is ${this.length} long`);this.ops.push(gn(e))}static from(e,t=[],r={}){let o=new n,i=[...t].reverse().find(d=>d.horizon),s=r.horizon??i?.seq??0;if(!Number.isInteger(s)||s<0)throw new Error(`A log cannot begin at seq ${s}`);if(i&&r.horizon!==void 0&&i.seq!==r.horizon)throw new Error(`A log said to begin at seq ${r.horizon} has its checkpoint at seq ${i.seq}`);let a=e[0];if(a&&s>0&&a.seq!==s)throw new Error(`A log compacted at seq ${s} begins with op "${a.id}" at seq ${a.seq}`);o.start=s;for(let d of e)o.append(d);for(let d of t)o.markEpoch(d);return o}replace(e,t=[],r={}){let o=n.from(e,t,r);this.ops=o.ops,this.marks=o.marks,this.start=o.start}epochs(){return this.marks}lastEpoch(){return this.marks.at(-1)}markEpoch(e){if(!Number.isInteger(e.seq)||e.seq<0||e.seq>this.length)throw new Error(`An epoch at seq ${e.seq} starts past the end of a log ${this.length} long`);if(e.seq<this.start)throw new Error(`An epoch at seq ${e.seq} is behind the horizon at seq ${this.start}: it went to the archive with the ops before it`);let t=this.lastEpoch();if(t&&e.seq<t.seq)throw new Error(`An epoch at seq ${e.seq} comes before the last one, at seq ${t.seq}`);this.marks.push(e)}truncate(e){if(!Number.isInteger(e)||e<this.start||e>this.length)throw new Error(`Cannot cut a log ${this.length} long back to ${e}`);let t=this.lastEpoch();if(t&&t.seq>e)throw new Error(`Cannot cut the log back to ${e}: an epoch begins at seq ${t.seq}`);return this.ops.splice(e-this.start)}checkpointAt(e,t,r={}){if(!Number.isInteger(t)||t<this.start||t>this.length)throw new Error(`No checkpoint at seq ${t}: this log holds seqs ${this.start} to ${this.length}`);let o=[...this.marks].reverse().find(a=>a.seq<=t);if(o?.seq===t)return{...o,horizon:!0};let i=this.fold(e,{...r,...o?{from:o}:{},to:t}).snapshot(),s=this.ops[t-1-this.start]?.at??o?.at;return{seq:t,base:i,...o?.version!==void 0?{version:o.version}:{},...s!==void 0?{at:s}:{},horizon:!0}}compact(e){if(!Number.isInteger(e.seq)||e.seq<this.start||e.seq>this.length)throw new Error(`Cannot compact at seq ${e.seq}: this log holds seqs ${this.start} to ${this.length}`);let t=this.ops.slice(0,e.seq-this.start),r=this.marks.filter(o=>o.seq<e.seq);return this.ops=this.ops.slice(e.seq-this.start),this.marks=[{...e,horizon:!0},...this.marks.filter(o=>o.seq>e.seq)],this.start=e.seq,{ops:t,epochs:r}}get(e){return this.ops.find(t=>t.id===e)}live(){let e=this.undoneIds();return this.ops.filter(t=>!e.has(t.id))}undoneIds(){return Ne(this.ops)}opsInBatch(e){return this.ops.filter(t=>t.batch===e)}batches(){return Tr(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=W.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)))Ru(i,a);return i}toJSON(){return[...this.ops]}};function Ru(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 Ne(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 Tr(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 Dr(n){return n?.automated===!0&&n.kind!=="human"&&n.kind!=="rule"}var sa=n=>n?.[Nn]===!0,_u=(n,e)=>sa(("graph"in n?n.graph:n).getNode(e));function ia(n,e,t){let r=n.tryDefinition(e);return t===void 0?r?.tidying:r?.edges?.[t]?.tidying}var aa=n=>JSON.stringify(n.map(e=>[e.name,e.args]),(e,t)=>t&&typeof t=="object"&&!Array.isArray(t)?Object.fromEntries(Object.entries(t).sort()):t);function da(n,e){let t=Au(n);return[e,...e.map(r=>[r])].map(r=>t.get(aa(r))).find(Boolean)}function Au(n){let e=Ne(n),t=new Map(n.map(o=>[o.id,o])),r=new Map;for(let o of n){let i=o.undoes!==void 0&&!e.has(o.id)&&!o.withheld?t.get(o.undoes):void 0,s=i?.suggests??(i?.mutation&&(i.lineage||o.undoneLineage)?[i.mutation]:[]);if(s.length>0)for(let a of[s,...s.map(d=>[d])])r.set(aa(a),o)}return r}function ca(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,f=(d?[d.from,d.to]:["id"in a?a.id:a.node.id]).map(c=>e.getNode(c)??("node"in a?a.node:void 0));for(let c of f){if(!c)continue;if(sa(c))return s(`change \u201C${Z(n.tryDefinition(c.kind),c)}\u201D`,"a person said to leave it alone");if(!i)continue;let p=ia(n,c.kind);if(p==="never")return s(`change ${ne(n,c.kind)} on its own`,"the app says they are never tidied");if(d&&p==="no-links")return s(`link or unlink ${ne(n,c.kind)} on its own`,"the app says they are never linked automatically")}if(d&&i&&f[0]&&ia(n,f[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 Ou(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 wt={scene:0,overview:10,rail:20,popover:30,dialog:40,toast:50},Eu={plots:0,stage:1,tag:2,ties:2,lines:3,tieLabels:4,occupants:6,seatMarks:7,zoom:8,card:10,opened:11},Pu={under:0,raised:1,over:2},Fr=n=>`--graview-layer-${n}`,zu=n=>`var(${Fr(n)}, ${wt[n]})`;function Mu(){return Object.keys(wt).map(n=>` ${Fr(n)}: ${wt[n]};`).join(`
|
|
4
|
+
`)}function Nu(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 ua(){return`sub_${(globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`).replace(/-/g,"").slice(0,20)}`}function la(n){return{...n,id:n.id??ua(),at:n.at??new Date().toISOString()}}function Iu(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=la(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 Zr=(n,e)=>`${n}\0${e}`,fa=new WeakMap;function ju(n,e){let t=new Map;for(let[o,i]of Object.entries(e??{}))for(let[s,a]of Object.entries(i))t.set(Zr(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(Zr(o,i));if(!a)return;let d=0,f=a.length;for(;d<f;){let c=d+f>>1;a[c].seq<s?d=c+1:f=c}return d===0?void 0:a[d-1].by}}}}function Tu(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=>!Ze(n.after[e]))]}function Du(n,e){let t=n.end,r=D(e.author).id,o=e.undoes!==void 0?n.seqOf.get(e.undoes):void 0,i=[];for(let s of e.primitives){let a=Tu(s);if(!a)continue;let[d,f]=a;for(let c of f){let p=e.undoes===void 0?r:o!==void 0?n.writers.writerAt(d,c,o):void 0,u=Zr(d,c),l=n.fields.get(u);l||n.fields.set(u,l=[]),l.push({seq:t,by:p}),i.push(u)}}n.written.push({seq:t,keys:i}),n.seqOf.set(e.id,t),n.read.push(e),n.end++}function Fu(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 Fn(n){let e=n.all(),t=typeof n.length=="number"?n.length:e.length,r=t-e.length,o=fa.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&&Fu(o,i),r>o.base&&(o.read=o.read.slice(r-o.base),o.base=r))}else o=void 0;o||fa.set(n,o=ju(r,r>0?[...n.epochs?.()??[]].reverse().find(i=>i.horizon)?.writers:void 0));for(let i=o.end;i<t;i++)Du(o,e[i-r]);return o.writers}function pa(n,e,t,r){let o=Fn(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 Ie={served:new WeakSet},Zn=n=>n.fields!==void 0||(n.hide?.length??0)>0,ke=n=>Ie.on===!0||Ie.served.has(n);var Lr=new WeakMap;function Zu(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 Lu(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=D(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 Cu(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 ie(n){let e=n.all(),t=typeof n.length=="number"?n.length:e.length,r=t-e.length,o=Lr.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&&Cu(o,i),r>o.base&&(o.read=o.read.slice(r-o.base),o.base=r))}else o=void 0;o||Lr.set(n,o=Zu(r,r>0?Gu(n,r):void 0));for(let i=o.end;i<t;i++)Lu(o,e[i-r]);return o.records}function Gu(n,e){let t=[...n.epochs?.()??[]].reverse().find(r=>r.horizon);return t?.seq===e?t:void 0}function ha(n,e,t){ie(n);let r=Lr.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 on(n,e,t,r,o,i=Ie.on===!0){if(!n?.sees?.length||q(e))return!0;let s=n.sees.filter(a=>a.kinds.includes(t.kind)&&(i||!Zn(a)));return s.length===0?!1:(e=D(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 f=c=>c.id===d;return a.via?r.out(t.id,a.via).some(f)||r.in(t.id,a.via).some(f):t.id===d||r.out(t.id).some(f)||r.in(t.id).some(f)||o?.creatorOf(t.id)===d}))}var Gr=new Set;function kt(n,e){return q(e)?Gr:n.modules?.disabledKinds??Gr}function sn(n,e){return q(e)?!1:(n.policy?.sees?.length??0)>0||kt(n,e).size>0}function ba(n,e){if(!sn(n,e))return()=>!0;let t=n.modules?.disabledKinds??Gr,r=n.policy?.sees??[],o=D(e),i=ke(n),s=d=>!t.has(d)&&(r.length===0||r.some(f=>f.kinds.includes(d)&&xe(f,o)&&!f.own&&!f.via&&(i||!Zn(f)))),a=n.schema.kinds.every(s);return d=>a||d!==void 0&&s(d)}function Ln(n,e){return t=>{let r=kt(n,e);if(!n.policy?.sees?.length&&r.size===0)return!0;let o=ie(n.log),i=n.graph.getNode(t);if(i)return!r.has(i.kind)&&on(n.policy,e,i,n.graph,o,ke(n));let s=o.kindOf(t)??va(n,o,t);return s===void 0?!0:!r.has(s)&&on(n.policy,e,{id:t,kind:s},{out:()=>[],in:()=>[]},o,ke(n))}}var Bu={out:()=>[],in:()=>[]};function va(n,e,t){if(e.knowsAll||Ie.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 Ku(n,e,t=new Map,r){let o=kt(n,e);if(!n.policy?.sees?.length&&o.size===0)return()=>!0;let i=ie(n.log);return s=>{let a=t.get(s);if(a!==void 0)return a;let d,f=n.graph.getNode(s);if(f)d=!o.has(f.kind)&&on(n.policy,e,f,n.graph,i,ke(n));else{let c=i.kindOf(s)??va(n,i,s);if(c===void 0)return r?.add(s),!0;d=!o.has(c)&&on(n.policy,e,{id:s,kind:c},Bu,i,ke(n))}return t.set(s,d),d}}function Uu(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 Kr(n,e){return xa(n,e).lens}var Br=()=>({judged:new Map,shown:new Map});function xa(n,e){let t=Uu(n.schema),r=q(e)?void 0:D(e).id,o=()=>n.log.length??n.log.all().length,i=new WeakMap,s=n.graph,a=(c,p,u,l,g)=>{let h=(x,R)=>{if(!c(x.id))return;let $;for(let z in x)if(!(!Object.hasOwn(x,z)||z==="id"||z==="kind"||!T(x[z],c))&&!(r!==void 0&&R(z)===r)){if(!t(x.kind,z))return;($??=[]).push(z)}if(!$)return x;let _=$.join("\0"),E=i.get(x);if(E?.without===_)return E.node;let P=Object.fromEntries(Object.entries(x).filter(([z])=>!$.includes(z)));return i.set(x,{without:_,node:P}),P},b=x=>{let R=u();return h(x,$=>p().writerAt(x.id,$,R))},y=new WeakMap,k=g?x=>{let R=y.get(x);return R||y.set(x,R={node:b(x)}),R.node}:b,A=x=>{if(!c(x))return!1;let R=s.getNode(x);return R===void 0||k(R)!==void 0},m=g?.shown??new Map,w=g?x=>{let R=m.get(x);return R===void 0&&m.set(x,R=A(x)),R}:A,S=s.outEdges&&s.inEdges?{present:{getNode:x=>s.getNode(x),outEdges:x=>s.outEdges(x),inEdges:x=>s.inEdges(x)},log:n.log,get writers(){return p()}}:void 0,v={sees:c,shows:w,served:k,servedWith:h,optional:t,kindOf:l,...r!==void 0?{actor:r}:{},...S?{timeline:S}:{},hides:()=>sn(n,e),pin:g?()=>v:()=>d(Br())};return Ie.lens?.(v,n,e)??v};function d(c){let p,u=o(),l=ie(n.log);return a(Ku(n,e,c.judged,c.unnamed),()=>p??=Fn(n.log),()=>u,g=>s.getNode(g)?.kind??l.kindOf(g),c)}return{lens:a(Ln(n,e),()=>Fn(n.log),o,c=>s.getNode(c)?.kind??ie(n.log).kindOf(c)),pinWith:d}}var ga=new WeakMap,ma=new WeakMap,Vu=n=>{let e=new Set;for(let t of n)for(let r of t.primitives)r.op==="add-node"||r.op==="remove-node"?e.add(r.node.id):r.op==="patch-node"?e.add(r.id):(e.add(r.edge.from),e.add(r.edge.to));return e};function Wu(n,e){if(!sn(n,e))return n.log.all();let t=n.log.all(),r=n.log.length??t.length,o=r-t.length,i=[...kt(n,e)].sort().join("\0"),s=wa(e),a=ga.get(n.log);a||ga.set(n.log,a=new Map);let d=a.get(s),{pinWith:f}=xa(n,e),c=ma.get(n.log);c||ma.set(n.log,c=new Set);let p=d!==void 0&&d.horizon===o&&d.off===i&&d.length<=r&&(d.length===o||t[d.length-1-o]===d.last);if(d&&p){if(d.length===r)return d.ops;let g=t.slice(d.length-o),h=f(Br()),b=!0,y=Vu(g);for(let k of y){let A=d.judgments.judged.get(k),m=d.judgments.shown.get(k);if(A!==void 0&&h.sees(k)!==A||m!==void 0&&h.shows(k)!==m){b=!1;break}}if(b){for(let k of y)if(c.has(k)){b=!1;break}}if(b){let k=[...d.ops,...tn(g,f(d.judgments))],A={horizon:o,off:i,length:r,last:t.at(-1),ops:k,judgments:d.judgments};return a.set(s,A),k}}let u={...Br(),unnamed:c},l=tn(t,f(u));return a.set(s,{horizon:o,off:i,length:r,last:t.at(-1),ops:l,judgments:u}),l}function qu(n,e,t){return(t.subjectId===void 0||!e(t.subjectId)||n.shows(t.subjectId))&&t.nodeIds.every(r=>!e(r)||n.shows(r))&&!T(t,n.sees)}function Ur(n,e){return{all:()=>n,undoneIds:()=>Ne(n),epochs:e}}var ya=new WeakMap;function wa(n){let e=q(n)?n:D(n);return`${n.kind}|${e.id??""}|${(e.roles??[]).join(",")}|${n.onBehalfOf?"for":""}`}var Cr=(n,e)=>{let t=Reflect.get(n,e,n);return typeof t=="function"?t.bind(n):t},Hu=Symbol.for("@graview/core:seat");function Cn(n,e){if(!sn(n,e))return n;let t=wa(e),r=ya.get(n);r||ya.set(n,r=new Map);let o=r.get(t);if(o)return o;let i=n.graph,s=Kr(n,e),a=m=>{let w=$=>$===void 0?void 0:m.served($),S=$=>w($)!==void 0,v=$=>S(i.getNode($));return{served:w,seenNode:S,seenId:v,seenEdge:$=>v($.from)&&v($.to)&&!T($,m.sees),servedAll:$=>$.flatMap(_=>w(_)??[])}},{served:d,seenId:f}=a(s),c=()=>a(s.pin?.()??s),p=(m,w)=>{let S=Fn(n.log),v=s.pin?.()??s,x=m.nodes.flatMap($=>v.servedWith($,_=>S.writerAt($.id,_,w))??[]),R=new Set(x.map($=>$.id));return{nodes:x,edges:m.edges.filter($=>R.has($.from)&&R.has($.to)&&!T($,v.sees))}},u=m=>{let{removed:w,writers:S,...v}=m,x=p(m.base,m.seq);if(!m.creators)return{...v,base:x};let R=new Set(x.nodes.map(_=>_.id)),$=Object.fromEntries(Object.entries(m.creators).filter(([_,E])=>R.has(_)&&!T(E,s.sees)));return{...v,base:x,creators:$}},l=m=>m&&u(m),g=()=>Wu(n,e),h=()=>Ur(g(),()=>n.log.epochs()),b=new Proxy(i,{get(m,w){switch(w){case"getNode":return S=>d(m.getNode(S));case"has":return f;case"allNodes":case"nodesOfKind":return(...S)=>c().servedAll(m[w](...S));case"count":return(...S)=>c().servedAll(m.nodesOfKind(...S)).length;case"allEdges":case"edgesOfKind":case"outEdges":case"inEdges":return(...S)=>m[w](...S).filter(c().seenEdge);case"out":case"in":case"neighbors":return(S,...v)=>{let x=c();return x.seenId(S)?x.servedAll(m[w](S,...v)):[]};case"snapshot":return()=>{let S=m.snapshot(),v=c();return{...S,nodes:v.servedAll(S.nodes),edges:S.edges.filter(v.seenEdge)}};case"size":{let S=c();return{nodes:S.servedAll(m.allNodes({archived:"all"})).length,edges:m.allEdges({archived:"all"}).filter(S.seenEdge).length}}default:return Cr(m,w)}}}),y=()=>{let m=g();return Tr(m,Ne(m))},k=new Proxy(n.log,{get(m,w){switch(w){case"all":case"toJSON":return()=>[...g()];case"epochs":return()=>m.epochs().map(u);case"lastEpoch":return()=>l(m.lastEpoch());case"live":return()=>{let S=g(),v=Ne(S);return S.filter(x=>!v.has(x.id))};case"get":return S=>g().find(v=>v.id===S);case"opsInBatch":return S=>g().filter(v=>v.batch===S);case"batches":return y;default:return Cr(m,w)}}}),A=new Proxy(n,{get(m,w){switch(w){case Hu:return{store:m,principal:e};case"graph":return b;case"log":return k;case"snapshot":return b.snapshot;case"batches":return y;case"canUndo":return S=>Dn(h(),typeof S=="string"?[S]:S);case"violations":return S=>m.violations(S,b).filter(v=>qu(s,x=>i.has(x),v));case"findings":return()=>m.findings().filter(S=>(S.id.includes("->")?S.id.split("->").map((x,R)=>R===0?x.slice(x.indexOf(":")+1):x):[S.id]).every(x=>!i.has(x)||f(x))&&!T(S,s.sees));case"wouldChange":return S=>m.wouldChange(S,e);case"preview":return(S,v,x)=>m.preview(S,v,{author:e,...x});case"seenBy":return S=>Cn(m,S);case"seenFor":return e;case"checkpoint":return S=>l(m.checkpoint(S));default:return Cr(m,w)}}});return r.set(t,A),A}var Vr=new Set;function Wr(n,e){if(!n||e===void 0)return{enabled:new Set(Object.keys(n??{})),disabledKinds:Vr,disabledMutations:Vr,disabledInvariants:Vr,administered:ka(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 f of d.kinds??[])o.add(f);for(let f of d.mutations??[])i.add(f);for(let f of d.invariants??[])s.add(f)}for(let a of t){let d=n[a];for(let f of d?.kinds??[])o.delete(f);for(let f of d?.mutations??[])i.delete(f);for(let f of d?.invariants??[])s.delete(f)}return{enabled:t,disabledKinds:o,disabledMutations:i,disabledInvariants:s,administered:ka(n,t)}}function ka(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 Sa(n){return n.normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase().trim().replace(/\s+/g," ")}var St=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=Sa(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=qr(a.sorted,r);d<a.sorted.length&&a.sorted[d].startsWith(r);d+=1){let f=[...a.ids.get(a.sorted[d])??[]];s.push(...f),a.sorted[d]===r&&i.push(...f)}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=Z(this.graph.schema.tryDefinition(e.kind),e),r=Sa(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(qr(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=qr(r.sorted,t.key);r.sorted[i]===t.key&&r.sorted.splice(i,1)}};function qr(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 Yu(n,e){return e.includes("*")?"record":e.map(t=>K(n.tryDefinition(t),t)).join(" or ")}function $a(n,e,t,r){let o=Yu(n,e.kinds);if(r.length===0)return{ok:!1,reason:"none",candidates:r,message:`There is no ${o} called "${t}".`};let i=r.slice(0,10).map(a=>`${a.label} (${a.id})`),s=r.length>i.length?`, and ${r.length-i.length} more`:"";return{ok:!1,reason:"ambiguous",candidates:r,message:`"${t}" names more than one ${o}: ${i.join(", ")}${s}. Pass the id of the one you mean as ${e.name}.`}}var _a=Symbol.for("@graview/core:node-ref"),Ra=n=>typeof n=="object"&&n!==null?n[_a]:void 0;function Se(n="*"){return Ju(F().check(Rn(1)),n)}function Ju(n,e){let t=Object.freeze(e==="*"?["*"]:[...e]),r=o=>{o&&Object.defineProperty(o,_a,{value:t,enumerable:!0,configurable:!0})};return r(n),r(j(n)),n}function Hr(n){if(typeof n!="object"||n===null)return;let e=Ra(n);if(e)return e;let t=j(n),r=Ra(t);if(r)return r;let o=t?.innerType;return o?Hr(o):void 0}function Gn(n){let e=n.shape;if(!e)return[];let t=[];for(let[r,o]of Object.entries(e)){let i=Hr(o);i&&t.push({name:r,kinds:i,optional:o.safeParse(void 0).success})}return t}function Yr(n){if(n===null||typeof n!="object")return JSON.stringify(n)??"null";if(Array.isArray(n))return`[${n.map(r=>r===void 0?"null":Yr(r)).join(",")}]`;let e=n;return`{${Object.keys(e).filter(r=>e[r]!==void 0).sort().map(r=>`${JSON.stringify(r)}:${Yr(e[r])}`).join(",")}}`}var Aa=(n,e)=>n.key<e.key?-1:n.key>e.key?1:0;function Xu(n){let e=n.nodes.map(r=>({key:r.id,value:r})).sort(Aa),t=n.edges.map(r=>({key:M(r),value:{kind:r.kind,from:r.from,to:r.to}})).sort(Aa);return Yr({nodes:e.map(r=>r.value),edges:t.map(r=>r.value)})}function an(n){return`sha256:${Ea(Xu(n))}`}function Oa(n,e,t,r={}){let o=r.validate??!0,i=r.base??{nodes:[],edges:[]},s=an(t),a=W.from(n,i,{validate:o});for(let[h,b]of e.entries())try{a.applyPrimitives(b.primitives)}catch(y){let k=e[h-1];return{ok:!1,expected:an(a.snapshot()),actual:s,...k?{divergedAfter:k.id}:{},reason:`The log does not fold: op "${b.id}" (${b.intent}) could not be applied. ${y instanceof Error?y.message:String(y)}`}}let d=an(a.snapshot());if(d===s)return{ok:!0,hash:s};let f=h=>{let b=W.from(n,i,{validate:o});for(let y=0;y<=h;y++)b.applyPrimitives(e[y].primitives);return an(b.snapshot())},c=h=>{try{let b=W.from(n,t,{validate:o});for(let y=e.length-1;y>h;y--)b.applyPrimitives(_e(e[y]));return an(b.snapshot())}catch{return}},p=h=>{let b=c(h);return b!==void 0&&b!==f(h)},u=-1,l=e.length-1;for(;u<l;){let h=Math.floor((u+l)/2);p(h)?l=h:u=h+1}let g=l>=0?e[l]: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 Qu=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]),el=new TextEncoder,nl=new Uint32Array(64),tl=new Uint32Array(8),$t=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function Ea(n){let e=el.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=tl;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=nl;for(let d=0;d<r.length;d+=64){for(let y=0;y<16;y++)s[y]=o.getUint32(d+y*4);for(let y=16;y<64;y++){let k=s[y-15],A=s[y-2],m=(k>>>7|k<<25)^(k>>>18|k<<14)^k>>>3,w=(A>>>17|A<<15)^(A>>>19|A<<13)^A>>>10;s[y]=s[y-16]+m+s[y-7]+w>>>0}let f=i[0],c=i[1],p=i[2],u=i[3],l=i[4],g=i[5],h=i[6],b=i[7];for(let y=0;y<64;y++){let k=(l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7),A=l&g^~l&h,m=b+k+A+Qu[y]+s[y]>>>0,w=(f>>>2|f<<30)^(f>>>13|f<<19)^(f>>>22|f<<10),S=f&c^f&p^c&p,v=w+S>>>0;b=h,h=g,g=l,l=u+m>>>0,u=p,p=c,c=f,f=m+v>>>0}i[0]=i[0]+f>>>0,i[1]=i[1]+c>>>0,i[2]=i[2]+p>>>0,i[3]=i[3]+u>>>0,i[4]=i[4]+l>>>0,i[5]=i[5]+g>>>0,i[6]=i[6]+h>>>0,i[7]=i[7]+b>>>0}let a="";for(let d=0;d<8;d++){let f=i[d];a+=$t[f>>>24]+$t[f>>>16&255]+$t[f>>>8&255]+$t[f&255]}return a}var Bn=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 rl(n,e){return{...e,name:n}}function Jr(n){if(!n.creates?.length)return!1;let e=n.input.shape;return e===void 0||!("id"in e)}function Na(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 Jr(n)?[...r,"id"]:r}var Pa=(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 ol(n){let e=n?._zod?.def;for(let t=0;e?.innerType&&t<8;t++)e=e.innerType._zod?.def;return e}var il=/^-?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?$/;function Ia(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"||!il.test(i)||ol(t[o])?.type!=="number")continue;let s=Number(i);Number.isFinite(s)&&(r??={...e},r[o]=s)}return r??e}function sl(n){if(typeof n!="object"||n===null)return;let e=n.id;if(e!==void 0){if(typeof e!="string"||e.trim().length===0)throw new I("An id must be a non-empty string",`Got ${JSON.stringify(e)}.`);return e}}function al(n){let{id:e,...t}=n;return t}function za(n){return n.normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"")||"item"}function ja(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 dl(n,e){if(e.limited&&e.me===void 0)return Ma(n,e.held);let t=e.limited?`${n}.${ja(e.me)}`:n,r=t;for(let o=2;e.seen(r);o++)r=`${t}-${o}`;return e.held(r)?Ma(t,e.held):r}function Ma(n,e){let t;do t=`${n}-${Math.floor(Math.random()*36**6).toString(36).padStart(6,"0")}`;while(e(t));return t}function dn(n,e,t,r={}){let o=Jr(e)?sl(t):void 0,i=Ia(e.input,o===void 0?t:al(t)),s=Na(e);if(s&&typeof i=="object"&&i!==null&&!Array.isArray(i)){let m=Object.keys(i).filter(w=>!s.includes(w)&&i[w]!==void 0);if(m.length>0)throw new oe(e.name,[{path:[],message:Pa(m,s,e.writtenBy)}])}let a=e.input.safeParse(i);if(!a.success){let m=Object.keys(e.input.shape??{});throw new oe(e.name,a.error.issues.map(w=>w.code==="unrecognized_keys"&&m.length>0?{...w,message:Pa(w.keys,m,e.writtenBy)}:w))}let d=a.data,f=new Bn(r.seen??n),c=[],p=new Set,u=m=>f.has(m)||n.has(m)||p.has(m),l,g=m=>{let w=new Set([...n.outEdges(m),...n.inEdges(m)]);for(let S of w)f.getNode(S.from),f.getNode(S.to),c.push({op:"remove-edge",edge:S});return w},h={graph:f,schema:n.schema,me:r.me,emit(m){c.push(m)},addNode(m){c.push({op:"add-node",node:m})},removeNode(m){let w=f.getNode(m)&&n.getNode(m);if(!w)throw new B(m,`Cannot remove missing node "${m}"`);g(m),c.push({op:"remove-node",node:w})},patchNode(m,w){let S=f.getNode(m)&&n.getNode(m);if(!S)throw new B(m,`Cannot patch missing node "${m}"`);let v={},x={};for(let[R,$]of Object.entries(w)){let _=S[R];JSON.stringify(_)===JSON.stringify($)&&!r.keepUnchanged?.($,R,S)||(v[R]=_,x[R]=$)}Object.keys(x).length!==0&&c.push({op:"patch-node",id:m,before:v,after:x})},archiveNode:m=>h.patchNode(m,{[Xe]:!0}),unarchiveNode:m=>h.patchNode(m,{[Xe]:void 0}),mergeNode(m,w){let S=f.getNode(w)&&n.getNode(w);if(!S)throw new B(w,`Cannot merge into missing node "${w}"`);if(m===w||Pe(S))throw new I(m===w?"Cannot merge a record into itself":"Cannot merge into an archived record");let v=new Set([...n.outEdges(w),...n.inEdges(w)].map(M));for(let x of g(m)){let R={kind:x.kind,from:x.from===m?w:x.from,to:x.to===m?w:x.to};R.from!==R.to&&!v.has(M(R))&&(v.add(M(R)),c.push({op:"add-edge",edge:R}))}h.archiveNode(m),l=w},addEdge(m){c.push({op:"add-edge",edge:m})},removeEdge(m){c.push({op:"remove-edge",edge:m})},setSingleSource(m,w,S){n.inEdges(w,m).some(v=>v.from===S)||c.push({op:"add-edge",edge:{kind:m,from:S,to:w}});for(let v of n.inEdges(w,m))f.getNode(v.from),v.from!==S&&c.push({op:"remove-edge",edge:v})},freshId(m,w){if(o!==void 0&&!p.has(o)){if(r.seesInFull&&!r.seesInFull())throw new I(`"${e.name}" makes its own id here`,"Leave id out: the answer says the id it made.");if(u(o))throw new I(`Id "${o}" is already taken`,`"${e.name}" was asked to make a node with that id, and the graph has one. Pick another, or leave id out and let the act mint one.`);return p.add(o),o}let S=w?`${w}:${za(m)}`:za(m),x=dl(S,{seen:R=>(r.seen?r.seen.has(R):n.has(R))||p.has(R),held:u,limited:r.seesInFull!==void 0&&!r.seesInFull(w),me:r.me});return p.add(x),x}};e.apply(h,d);let b=r.check?.(c,e),y=new Set(c.flatMap(Re)),k=new Bn(r.seen??n),A=e.describe?.(d,k)??`${e.name}(${Object.entries(d).map(([m,w])=>`${m}=${JSON.stringify(w)}`).join(", ")})`;return{primitives:c,reads:[...new Set([...f.reads(),...k.reads()])],...e.describe?{described:[...k.reads(),...b??[]]}:{},writes:[...y],intent:A,...l!==void 0?{mergedInto:l}:{}}}var Kn=n=>n.trim().replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").replace(/-+/g,"-").toLowerCase();function Rt(n,e){let t=Kn(n),r=[...e];if(r.includes(n))return n;let o=r.filter(i=>Kn(i)===t);return o.length===1?o[0]:void 0}function cl(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 Xr(n,e){let t=[...e],r=Rt(n,t);if(r)return r;let o=Kn(n);if(o==="")return;let i,s=!1;for(let a of t){let d=cl(o,Kn(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 Ta=Symbol.for("@graview/core:amount"),av=(n,e)=>(Object.defineProperty(j(n),Ta,{value:e,enumerable:!0}),n);function Qr(n,e=!0){let t=j(n);return t?.[Ta]??(e&&t?.innerType?Qr(t.innerType):void 0)}function Da(n,e={}){let t=Number.isInteger(n),r={maximumFractionDigits:t?0:2,minimumFractionDigits:t?0:2};try{return ae(n,e.locale,e.currency?{style:"currency",currency:e.currency,...r}:r)}catch{return ae(n,e.locale,r)}}function Fa(n,{format:e,unit:t,currency:r,locale:o}){let i=/^[A-Z]{3}$/.test(t??"");return e==="money"||!e&&i?Da(n,{...o?{locale:o}:{},...(i?t:r)?{currency:i?t:r}:{}}):e==="percent"?ae(n,o,{style:"percent",maximumFractionDigits:0}):ae(n,o)+(t?` ${t}`:"")}var ul=Symbol.for("@graview/core:typed-field");function eo(n){let e=j(n);return e?e[ul]??eo(e.innerType):void 0}var ll=/^[("'“‘]*(?:(?:[a-z]{1,3}\.){2,}|(?:dr|mr|mrs|ms|mx|st|mt|vs|jr|sr|prof|no|fig|approx)\.)$/i;function fl(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]==="."&&ll.test(r))&&!(t.split(" ").length<3&&e.index+1<n.length))return t}}function Za(n,e=140){let t=n.replace(/^[#>\s]+|\*\*|`|\](\([^)\s]*\))?|\[/gm,"").replace(/\s+/g," ").trim(),r=fl(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 pl(n){let e=n.fields.shape;return Object.keys(e).flatMap(t=>{let r=gt(e[t])?zn(t):void 0;return r&&e[r]?[r]:[]})}var hl=[["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 La(n,e){let t=new Set(e.map(o=>o.name)),r=[];for(let o of n.definitions){let i=pl(o);if(i.length===0)continue;let s=o.kind,a=o.fields.shape,d=Object.keys(a).filter(c=>!(c in(o.fixed??{}))),f=c=>Z(o,c);for(let[c,p,u,l]of hl){let g=`${c}-${s}`;t.has(g)||r.push({name:g,derived:{kind:s,act:c},title:p,description:u,subject:{kinds:[s],arg:"id"},writes:i.map(Ye),...c==="skip"?{}:{creates:[s]},input:qe({id:Se([s]),on:F().check(_n(/^\d{4}-\d{2}-\d{2}$/,"a day, like 2026-10-21")),...i.length>1?{field:Q(bs(i))}:{},...c==="skip"?{}:Object.fromEntries(d.map(h=>[h,Q(a[h])]))}),describe:(h,b)=>l.replace("{}",f(b.getNode(String(h.id))??{id:h.id}))+me(String(h.on)),apply(h,b){let y=h.graph.getNode(String(b.id)),k=String(b.field??i[0]),A=y?.[k],m=y?.[Ye(k)],w=String(b.on);if(typeof A!="string"||!Je(m))throw new ee(`${f(y??{id:b.id})} does not repeat`,"refused");let S=He(A,m,{from:w,to:w})[0];if(!S)throw new ee(`${f(y)} does not fall on ${me(w)}`,"refused");let v=String(y.id),x=Object.fromEntries(d.filter(Y=>b[Y]!==void 0).map(Y=>[Y,b[Y]])),R=Ye(k),$=Y=>{let Mo=Object.fromEntries(Object.entries({...y,...Y,...x}).filter(([Jn,Lt])=>Lt!=null&&Jn!=="id")),No=h.freshId(f(Mo));h.addNode({...Mo,id:No,kind:s});for(let Jn of Object.keys(o.edges??{}))for(let Lt of h.graph.out(v,Jn))h.addEdge({kind:Jn,from:No,to:Lt.id})};if(c!=="split"){h.patchNode(v,{[R]:{...m,except:[...new Set([...m.except??[],w])].sort()}}),c==="detach"&&$({[k]:S,[R]:null});return}if(Object.keys(x).length===0)throw new ee(`Nothing to change: give ${f(y)} from ${me(w)} something new`,"invalid");if(w<=A.slice(0,10))return h.patchNode(v,x);let _=new Date(Date.parse(`${w}T00:00:00Z`)-864e5).toISOString().slice(0,10),E=m.count?He(A,{...m,except:[]},{to:_}).length:0,{count:P,except:z,...re}=m,zo=Y=>z?.some(Y)?{except:z.filter(Y)}:{};h.patchNode(v,{[R]:{...re,until:_,...zo(Y=>Y<w),...P?{count:E}:{}}}),$({[k]:S,[R]:{...re,...zo(Y=>Y>=w),...P?{count:P-E}:{},continues:v}})}})}}return r}function Ca(n,e){let t=new Set(e.map(d=>d.name)),r=e.filter(d=>!d.derived),o=new Set(r.flatMap(d=>d.connects??[])),i=new Set(r.flatMap(d=>d.severs??[])),s=[],a=(d,f)=>{let c=d.getNode(String(f));return c?Z(n.tryDefinition(c.kind),c):String(f)};for(let d of n.definitions){let f=d.kind,c=Object.entries(d.edges??{}),p=u=>u.to==="*"?"record":u.to.map(l=>K(n.tryDefinition(l),l)).join(" or ");for(let[u,l]of c){let g=p(l),h=l.cardinality==="one",b=c.some(([w,S])=>w!==u&&p(S)===g),y=w=>C(w).toLowerCase(),k=oa(f,u,l,y),A={to:k&&"to"in k?k.to:g,from:K(d,f),one:h,also:k&&"also"in k?k.also:b&&!k?y(u):void 0},m=A.from;for(let w of ea){let S=ta(w,f,u);if(t.has(S)||l.acts==="none"||(w==="connect"?o.has(u):i.has(u)||l.appendOnly))continue;let{title:v,fromTheOtherEnd:x}=ra(w,A),R=l.description?`: ${l.description.replace(/\.$/,"")}`:"";s.push({name:S,derived:{kind:f,act:w,relation:u},title:v,fromTheOtherEnd:x,description:w==="connect"?`Link this ${m} to ${/^[aeiou]/i.test(g)?"an":"a"} ${g}${R}.${h?" It has one, so this replaces the one it has.":""}`:`Take away the link between this ${m} and ${/^[aeiou]/i.test(g)?"an":"a"} ${g}${R}. Undo puts it back.`,subject:{kinds:[f],arg:"id"},...w==="connect"?{connects:[u]}:{severs:[u],destructive:!0},idempotent:!0,input:qe({id:Se([f]),to:Se(l.to==="*"?"*":l.to)}),describe:($,_)=>w==="disconnect"?`Unlink ${a(_,$.id)} from ${a(_,$.to)}`:h?`Set the ${g} of ${a(_,$.id)} to ${a(_,$.to)}`:`Link ${a(_,$.id)} to ${a(_,$.to)}`,apply($,_){let E=String(_.id),P=String(_.to);for(let re of[E,P])if(!$.graph.getNode(re))throw new ee(`there is no record "${re}"`,"invalid");let z=$.graph.out(E,u).some(re=>re.id===P);if(w==="disconnect"){if(!z)throw new ee(`${a($.graph,E)} is not linked to ${a($.graph,P)}`,"invalid");$.removeEdge({kind:u,from:E,to:P});return}if(h)for(let re of $.graph.out(E,u))re.id!==P&&$.removeEdge({kind:u,from:E,to:re.id});z||$.addEdge({kind:u,from:E,to:P})}})}}}return s}function no(n){let e=n.fields.shape;return Object.keys(e).filter(t=>!(t in(n.fixed??{})))}function to(n,e){let t=e.subject;return t?t.kinds==="*"?n.kinds:t.kinds:[]}function ro(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(Gn(n.input).map(s=>s.name));return Object.keys(o).filter(s=>s!==t.arg&&r.has(s)&&!i.has(s))}function oo(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 to(n,o)){let s=n.tryDefinition(i);if(s)for(let a of ro(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 Ga(n,e,t){let r=n.tryDefinition(t);if(!r)return[];let o=oo(n,e).get(t);return no(r).filter(i=>!o?.has(i))}var Ba=n=>`edit-${n}`;function Ka(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),to(n,i).includes(t)&&ro(i,r).length>0&&o.add(i.name));return[...o]}function Ua(n,e){let t=new Set(e.map(o=>o.name)),r=[];for(let o of n.definitions){let i=o.kind,s=Ba(i);if(t.has(s))continue;let a=Ga(n,e,i);if(a.length===0)continue;let d=oo(n,e).get(i),f=Object.fromEntries(no(o).flatMap(l=>d?.get(l)?.length?[[l,d.get(l)]]:[])),c=o.fields.shape,p=K(o,i),u=a.map(l=>rt(o,l).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: ${u.join(", ")}.`,subject:{kinds:[i],arg:"id"},writes:a,...Object.keys(f).length>0?{writtenBy:f}:{},input:qe({id:Se([i]),...Object.fromEntries(a.map(l=>[l,Q(yl(c[l]))]))}),describe:(l,g)=>gl(o,c,a,l,g),apply(l,g){let h={};for(let b of a){let y=g[b];y!==void 0&&(h[b]=y)}if(Object.keys(h).length===0)throw new ee(`Nothing to change \u2014 give at least one of ${u.join(", ")} a value.`,"invalid");l.patchNode(g.id,h)}})}return r}function gl(n,e,t,r,o){let i=o.getNode(r.id),s=i?Z(n,i):"a record",a=t.filter(d=>r[d]!==void 0).map((d,f)=>{let c=r[d],p=zn(d),u=p!==void 0&&p in e,l=rt(n,u?p:d);return`the ${l===l.toUpperCase()?l:Fo(l)}${f===0?` of ${s}`:""} to ${u?c?`repeat ${ml(c)}`:"stop repeating":Va(n,e[d],d,c)}`});return a.length===0?`Changed nothing on ${s}`:`Changed ${a.length>1?`${a.slice(0,-1).join(", ")} and ${a.at(-1)}`:a[0]}`}var ml=n=>`every ${(n.interval??1)>1?`${n.interval} ${n.every}s`:n.every}`;function Va(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(On(r).length>0)return On(r).map(i=>i.name).join(", ");if(En(e))return Array.isArray(r)&&r.length>1?`${r.length} linked records`:"a linked record";if(Array.isArray(r))return r.map(i=>Va(n,e,t,i)).join(", ");if(typeof r=="boolean")return r?"yes":"no";if(typeof r=="number"){let i=Qr(e);return i?Fa(r,i):eo(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(Ge.test(r))return me(r);if(Qn.test(r))return Kt(r);for(let i=j(e);i;i=j(i.innerType))if(i.type==="enum")return C(r);return`\u201C${Za(r,60)}\u201D`}function yl(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 Wa(n,e){return n.filter(t=>!t.derived&&(t.creates??[]).includes(e)).map(t=>t.name)}function _t(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"?Ka(n,e,t.derived.kind):Wa(e,t.derived.kind)}function bl(n,e){let t=new Set(e.map(o=>o.name)),r=[];for(let o of n.definitions){let i=o.kind,s=K(o,i),a=(f,c)=>{let p=f.getNode(String(c));return p?Z(o,p):String(c)},d=Se([i]);for(let[f,c,p,u]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 l=`${f}-${i}`,g=f==="leave-alone"||f==="allow-tidying";t.has(l)||!g&&f!=="remove"&&o.archives===!1||g&&o.tidying==="never"||r.push({name:l,derived:{kind:i,act:f},title:p,description:u,subject:{kinds:[i],arg:"id"},...f==="remove"?{destructive:!0}:{},idempotent:!0,input:We(f==="merge"?{id:d,into:d}:{id:d}),describe:(h,b)=>{let y=f==="remove"&&b.getNode(String(h.id)),k=y?new Set(Object.values(y).flatMap(A=>On(A).map(m=>m.href))).size:0;return`${c} ${a(b,h.id)}${f==="merge"?` into ${a(b,h.into)}`:""}${k?` and its ${k} file${k>1?"s":""}`:""}`},apply:g?(h,b)=>h.patchNode(String(b.id),{[Nn]:f==="leave-alone"?!0:void 0}):(h,b)=>h[`${f}Node`](b.id,b.into)})}}return r}function io(n,e){return[...Ua(n,e),...bl(n,e),...La(n,e),...Ca(n,e)]}var vl=n=>({$made:n}),At=n=>typeof n=="object"&&n!==null&&Object.keys(n).join()==="$made"&&Number.isInteger(n.$made)&&n.$made>=0,xl=(n,e)=>Object.fromEntries(Object.entries(n.args??{}).map(([t,r])=>[t,Array.isArray(r)?r.map(e):e(r)])),qa=n=>Object.values(n.args??{}).some(e=>At(e)||Array.isArray(e)&&e.some(At)),Ha=(n,e,t)=>({...n,args:xl(n,r=>{if(!At(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 wl=500,so=120;function Un(n){if(n===void 0)return;let{basis:e,confidence:t,model:r,suggestion:o,interaction:i}=n??{},s=typeof e=="string"?e.trim():"",a=typeof r=="string"?r.trim():"";if(!s||s.length>wl||t!==void 0&&!(typeof t=="number"&&t>=0&&t<=1)||r!==void 0&&!(a&&a.length<=so)||o!==void 0&&!(typeof o=="string"&&o.length>0&&o.length<=so)||i!==void 0&&!(typeof i=="string"&&i.length>0&&i.length<=so))throw new I("A lineage is { basis: 1\u2013500 characters, confidence?: 0\u20131, model?: 1\u2013120 characters, suggestion?: an op id, interaction?: an AI interaction's id }");return{basis:s,...t!==void 0?{confidence:t}:{},...a?{model:a}:{},...typeof o=="string"?{suggestion:o}:{},...typeof i=="string"?{interaction:i}:{}}}var cn="keep-link";function Ya(n){let e=(t,r)=>{let o=t.getNode(r);return o?Z(n.tryDefinition(o.kind),o):r};return{name:cn,title:"Keep this link",input:We({kind:F(),from:F(),to:F()}),describe:(t,r)=>`Keep the link from ${e(r,t.from)} to ${e(r,t.to)}`,apply(t,r){let{kind:o,from:i,to:s}=r;if(!t.graph.getNode(i)||!t.graph.getNode(s)){let a=M({kind:o,from:i,to:s});throw new B(a,`Cannot remove missing edge ${a}`)}t.removeEdge({kind:o,from:i,to:s}),t.addEdge({kind:o,from:i,to:s})}}}var Ja=(n,e)=>[...n].filter(t=>!t.derived&&t.name!==cn&&typeof e=="string"&&(t.connects?.includes(e)||t.severs?.includes(e))).map(t=>t.name);var Xa=["kind-unknown","node-shape","edge-dangling","edge-disallowed","rule-error","rule-budget"];function Qa(n,e){let t=yt(n,e);return t&&[...t.fields].filter(Boolean)}function kl(n,e,t){return n.tryDefinition(e)?.fields?.shape?.[t]}function Ot(n,e){try{return Z(n.tryDefinition(e.kind),e)}catch{return typeof e.label=="string"?e.label:"A record"}}var Sl=n=>`${n.kind}:${n.from}->${n.to}`,Et=(n,e)=>n<e?-1:n>e?1:0;function ed(n,e,t={}){let{schema:r}=n,o=[],i=new Map;for(let u of e.nodes)i.has(u.id)||i.set(u.id,u);let s=u=>e.edges.filter(l=>l.from===u||l.to===u),a=u=>({action:"drop",primitives:[...s(u.id).filter(l=>i.has(l.from)&&i.has(l.to)).map(l=>({op:"remove-edge",edge:l})),{op:"remove-node",node:u}]}),d=new Set;for(let u of[...i.values()].sort((l,g)=>Et(l.id,g.id))){if(!r.tryDefinition(u.kind)){d.add(u.id),o.push({code:"kind-unknown",id:u.id,message:`${Ot(r,u)} is a kind of record this app no longer has`,repair:a(u)});continue}let l=Qa(r,u);if(l===void 0)continue;let g=Ot(r,u),h=new Map,b=l.length>0;for(let y of l){if(y==="id"||y==="kind"){b=!1;continue}let k=kl(r,u.kind,y),A=k?k.safeParse(void 0):{success:!0,data:void 0},m=r.tryDefinition(u.kind)?.defaults;!A.success&&k&&m&&Object.hasOwn(m,y)&&(A=k.safeParse(m[y])),A.success?A.data===void 0?h.set(y,{action:"clear",value:he}):h.set(y,{action:"coerce",value:A.data}):b=!1}if(b){let y={...u};for(let[k,A]of h)A.value===he?delete y[k]:y[k]=A.value;Qa(r,y)!==void 0&&(b=!1)}if(l.length===0){o.push({code:"node-shape",id:u.id,message:`${g} does not fit what ${u.kind} declares`,repair:a(u)});continue}for(let y of l){let k=h.get(y),A=b&&k?{action:k.action,primitives:[{op:"patch-node",id:u.id,before:{[y]:u[y]===void 0?he:u[y]},after:{[y]:k.value}}]}:a(u);o.push({code:"node-shape",id:u.id,detail:y,message:`${g}: ${C(y)} does not fit what ${u.kind} declares`,repair:A})}}let f=new Set,c=[];for(let u of[...e.edges].sort((l,g)=>Et(M(l),M(g)))){if(f.has(M(u)))continue;f.add(M(u));let l=Sl(u),g=i.get(u.from),h=i.get(u.to);if(!g||!h){o.push({code:"edge-dangling",id:l,message:"A link points at a record that is not there",repair:{action:"drop",primitives:[{op:"remove-edge",edge:u}]}});continue}c.push(u),!(d.has(g.id)||d.has(h.id))&&(r.edgeAllowed(u.kind,g.kind,h.kind)||o.push({code:"edge-disallowed",id:l,message:`${Ot(r,g)} \u2192 ${Ot(r,h)}: this app does not allow that link between them`,repair:{action:"drop",primitives:[{op:"remove-edge",edge:u}]}}))}let p=n.invariants??[];if(p.length>0){let u=W.from(r,{nodes:[...i.values()],edges:c},{validate:!1}),l=new Set,g;try{g=en(u,p,t.invariantOptions??{})}catch{g=[{invariant:"rules",status:"could-not-judge",label:"The rules",message:"The rules could not be judged",nodeIds:[],repairs:[]}]}for(let h of g){let b=h.status==="could-not-judge"?"rule-error":h.status==="over-budget"?"rule-budget":void 0;if(!b)continue;let y=h.subjectId??h.invariant,k=`${b}|${y}|${h.invariant}`;l.has(k)||(l.add(k),o.push({code:b,id:y,detail:h.invariant,message:h.message}))}}return o.sort((u,l)=>Xa.indexOf(u.code)-Xa.indexOf(l.code)||Et(u.id,l.id)||Et(u.detail??"",l.detail??""))}var Vn=()=>globalThis.__graviewWatch;function nd(n){Vn()?.store?.(n)}function Pt(n){n!==void 0&&Vn()?.learn?.({ids:[n],words:[]})}function td(n,e){Vn()?.refused?.({...n,...e===void 0?{}:{author:e}})}function ao(n,e){let t=Vn();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 $l(n,e){n instanceof oe&&ao(n,e)}function Rl(n,e,t){Vn()?.seat?.(n,e,t)}function uo(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 H(e,t)}var co=15*6e4;function rd(n=Date.now(),e){let t=new Date(n).getTime(),r=et(e),o=H(r,t),i=new Date(Date.parse(`${o}T00:00:00Z`));if(i.setUTCDate(i.getUTCDate()+1),!r)return i.getTime()-t;let s=jo(i.toISOString().slice(0,10),0,r);for(;H(r,s)===o;)s+=co;for(;H(r,s-co)!==o;)s-=co;return s-t}function _l(n,e){let t,r=()=>{t=setTimeout(()=>{let o=n.tick(new Date);r(),e?.(o)},rd(Date.now(),n.timeZone)+1e3),t.unref?.()};return r(),()=>clearTimeout(t)}var zt=class extends I{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"}},lo="preview",L=(n,e)=>e===void 0?{}:{[n]:e},je={kind:"human"},od={kind:"system"},sd={kind:"system",id:"modules",name:"Modules"},id=n=>n.mutation===null&&n.undoes===void 0;function fo(n,e){return`${n.invariant}|${n.subjectId??""}|${n.line||e?.has(n.invariant)?n.label:n.message}`}var Al=new Set(["remove","archive","unarchive","merge"]),Ol={has:()=>!0},ad=n=>new Set(n.filter(e=>e.shape).map(e=>e.name));function dd(n,e,t){let r=ad(n),o=p=>fo(p,r),i=new Set(e.map(o)),s=new Set(t.map(o)),a=t.filter(p=>!i.has(o(p))),d=e.filter(p=>!s.has(o(p)));if(a.length===0||d.length===0)return{introduces:a,resolves:d};let f=p=>p.subjectId&&fo(p,Ol),c=d.map(f);return{introduces:a.filter(p=>{let u=f(p)?c.indexOf(f(p)):-1;return u<0||(c[u]=null,!1)}),resolves:d.filter((p,u)=>c[u]!==null)}}var un=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"}},Mt=class extends I{constructor(t,r){let o=Xr(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};function El(){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 po=class n{schema;graph;log;mutations=new Map;keeper;invariants;invariantOptions;policy;intelligence;may=new Map;by;declaredModules;startingModules;projected;nextId;now;validate;mintBatch;batchTag;counter=0;opCount=0;quiet=0;rehearsing=!1;suggesting=!1;ticked;timeZone;past;pastEvery;listeners=new Set;constructor(e){this.pastEvery=Math.max(1,e.pastEvery??64),this.past=e.past,this.schema=e.schema,this.invariants=e.invariants??[],this.invariantOptions=e.invariantOptions??{},this.timeZone=e.timeZone,this.timeZone&&(this.ticked={day:H(this.timeZone),on:H(this.timeZone)}),this.policy=e.policy,this.by=e.principal??je,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=El();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 I(`Duplicate mutation "${i.name}"`);this.mutations.set(i.name,i)}for(let i of e.past?[]:io(e.schema,e.mutations??[]))this.mutations.set(i.name,i);!e.past&&!this.mutations.has(cn)&&(this.keeper=Ya(e.schema),this.mutations.set(cn,this.keeper));let r=L("horizon",e.horizon),o={validate:this.validate};if(e.log){this.log=rn.from(e.log,e.epochs,r);let i=this.log.lastEpoch();this.graph=e.snapshot?W.from(e.schema,e.snapshot,o):this.log.fold(e.schema,{...o,...i?{from:i}:{}})}else this.log=rn.from([],e.epochs??(e.snapshot?[{seq:e.horizon??0,base:e.snapshot}]:[]),r),this.graph=W.from(e.schema,e.snapshot??{nodes:[],edges:[]},o);e.past||(this.countPastTheLog(),nd(this))}stillNow(){if(this.past)throw new zt(this.past)}countPastTheLog(){let e=t=>{let r=/(\d+)$/.exec(t);return r?Number(r[1]):0};for(let t of this.log.all())this.counter=Math.max(this.counter,e(t.batch)),this.opCount=Math.max(this.opCount,e(t.id));this.log.horizon>0&&(this.opCount=Math.max(this.opCount,this.log.length))}get modules(){let e=this.log.all(),t=e.at(-1)?.id,r=this.projected;if(r&&r.length===e.length&&r.last===t)return r.projection;let o,i=0;r&&r.length<=e.length&&(r.length===0||e[r.length-1]?.id===r.last)&&(o=r.said,i=r.length);for(let a=e.length-1;a>=i;a--){let d=e[a].enabledModules;if(d!==void 0){o=d;break}}let s=r&&o===r.said?r.projection:Wr(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=Wr(this.declaredModules,e).enabled,i=[...r].filter(c=>!o.has(c)),s=[...o].filter(c=>!r.has(c));if(i.length===0&&s.length===0)return;let a=c=>c.map(p=>{let u=this.declaredModules?.[p]?.kinds??[];return u.length>0?u.map(l=>ne(this.schema,l)).join(", "):p}).join(", "),d=[i.length>0?`Turn off ${a(i)}`:"",s.length>0?`turn on ${a(s)}`:""].filter(Boolean).join("; "),f={id:this.nextId(),seq:this.log.length,batch:t.batch??this.mintBatch("batch"),author:sd,intent:xn(d),mutation:null,primitives:[],reads:[],writes:[],at:this.now(),...L("via",t.via),enabledModules:[...o].sort()};return this.log.append(f),this.notify(In,[f]),f}mutation(e){let t=this.mutations.get(this.spelled(e));if(!t)throw new Mt(e,[...this.mutations.keys()]);if(this.mutationDisabled(t))throw new I(`Mutation "${e}" belongs to a module this workspace has turned off`,`Enabled modules: ${[...this.modules.enabled].join(", ")||"(none)"}`);return t}spelled(e){return this.mutations.has(e)?e:Rt(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()].filter(e=>e!==this.keeper&&!this.mutationDisabled(e))}viaOf(e,t){if(e!==void 0&&e===this.keeper){let r=Ja(this.mutations.values(),t?.args.kind);if(r.length>0)return r;let o=[...this.mutations.values()];return[...new Set(o.filter(i=>i.derived?.relation===t?.args.kind).flatMap(i=>_t(this.schema,o,i)??[]))]}if(e?.derived)return _t(this.schema,[...this.mutations.values()],e)}moved(e,t){return dd(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=je){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),i=o?.subject&&e.args[o.subject.arg];return we(this.policy,t,e.name,this.subjectKindOf(e,t),this.viaOf(o,e),typeof i=="string"?i:void 0,this.words,()=>{let s=D(t).id,a=this.namedIn(e,!1);try{for(let d of dn(this.graph,o,e.args,this.sighted(t)).primitives)"edge"in d&&d.edge.from!==s&&d.edge.to!==s&&a.push(d.edge.to)}catch{}return a},o?.derived&&(()=>ie(this.log).creatorOf(i)),o?.derived!==void 0&&Al.has(o.derived.act))}namedIn(e,t=!0){let r=this.mutations.get(e.name);if(!r)return[];let o=r.subject?.arg;return[...t&&o?[e.args[o]]:[],...Gn(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&&td(e,t),new Me(e)}get words(){return{act:e=>this.mutations.get(e)?.title,noun:e=>K(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=od){let r=this.modules.disabledKinds;if(r.size===0||!q(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&&D(e).id};if(e===void 0||!sn(this,e))return t;let r=Ln(this,e);return{...t,seen:Cn(this,e).graph,keepUnchanged:o=>T(o,r),seesInFull:ba(this,e)}}missingFor(e,t=je){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=Cn(this,t).graph;for(let s of o)if(!i.has(s))return new B(s,`\u201C${r.title??e.name}\u201D names a record that is not there.`)}mayAdminister(e,t=je){let r=this.modules.administered.get(e);return r?(r.mutations??[]).some(o=>{let i=this.mutations.get(o);return!!i&&Nr(i).some(s=>we(this.policy,t,o,s,this.viaOf(i)).ok)}):!1}seenBy(e){return Cn(this,e)}sees(e,t){return this.graph.has(t)&&Ln(this,e)(t)}labels;resolveRef(e,t,r=je){let o=(this.policy?.sees?.length??0)>0,i=u=>!o||this.sees(r,u),s=this.graph.getNode(t);if(this.labels??=new St(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=u=>{let l=u.filter(g=>!this.graph.isArchived(g));return l.length?l:u},f=d(a.exact.filter(i)),c=f.length>0,p=(c?f:d(a.prefix.filter(i))).map(u=>({id:u,kind:this.graph.getNode(u).kind,label:this.labels.labelOf(u)??u})).sort((u,l)=>u.label<l.label?-1:u.label>l.label?1:u.id<l.id?-1:1);return p.length===1?{ok:!0,id:p[0].id,label:p[0].label,by:c?"label":"prefix"}:$a(this.schema,e,t,p)}kindsKeptFrom(e=je){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&&!q(e)){let o=new Set(this.permittedMutations(e).flatMap(s=>s.creates??[])),i=ke(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||!Zn(d)))&&!o.has(s)&&t.add(s)}return t}permittedMutations(e=je){let t=this.allMutations(),r=Mr(this.policy,e,t.filter(i=>!i.derived)),o=t.filter(i=>i.derived!==void 0&&we(this.policy,e,i.name,i.derived.kind,this.viaOf(i),D(e).id).ok);return[...r,...o]}subjectKindOf(e,t=od){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(!(!q(t)&&!Ln(this,t)(i)))return this.graph.getNode(i)?.kind}today(){return this.pinned()??(this.ticked&&this.ticked.on===H(this.timeZone)?this.ticked.day:void 0)??(this.timeZone?H(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=Es(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=uo(e,this.timeZone),o=H(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(In,[]);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(In,[])}violations(e,t=this.graph){return en(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 dn(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=dn(this.graph,o,e.args,this.sighted(r.author));return this.previewPrimitives(i.primitives,{reads:i.reads,writes:i.writes,intent:i.intent,context:t})}previewAll(e,t={}){let{context:r,...o}=t;return{...this.rehearsal().applying(e,o,r),kept:!1}}rehearsal(){let e=Object.assign(Object.create(n.prototype),this),t=0;return Object.assign(e,{graph:W.from(this.schema,this.graph.snapshot(),{validate:this.validate}),log:rn.from(this.log.all(),this.log.epochs(),{horizon:this.log.horizon}),listeners:new Set,labels:void 0,nextId:()=>`${lo}:${++t}`,mintBatch:()=>lo,rehearsing:!0}),e}previewPrimitives(e,t){let r=this.violations(t.context),o=W.from(this.schema,this.graph.snapshot()),i=o.applyPrimitives(e,{restoring:t.restoring===!0}),s=en(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(v=>this.spelledCall(v));this.stillNow();let i=t.batch??this.mintBatch("batch"),s=t.author??this.by,a=Un(t.lineage),d=[],f=[],c=new Set,p=new Set,u=[],l=this.violations(r),g=this.graph.snapshot(),h=this.log.length,b=v=>{let x=this.policy?this.permits(v,s):void 0;x&&!x.ok&&this.refuse(x.refusal,s.id)},y=v=>{let x=this.refusesAgent(v,s)??this.namesTurnedOff(v,s);x&&this.refuse(x,s.id)},k=o.map(qa);o.forEach((v,x)=>k[x]||b(v)),o.forEach((v,x)=>k[x]||y(v));let A=Dr(s);A&&this.refuseDeclined(o,s),this.rehearsing||Pt(s.id);let m=[];try{for(let[v,x]of o.entries()){let R=k[v]?Ha(x,m,v):x;k[v]&&(b(R),y(R));let $=this.mutation(R.name),_=this.missingFor(R,s);if(_)throw _;let E;try{E=dn(this.graph,$,R.args,this.sighted(s))}catch(z){throw z instanceof oe&&!this.rehearsing&&ao(z,s.id),z}if(A){let z=ca(this.schema,this.graph,E.primitives,this.authorName(s),{declaration:!this.suggesting});z&&this.refuse({mutation:R.name,message:z,wouldNeed:[]},s.id)}if(E.primitives.length===0)continue;m[v]=E.primitives.find(z=>z.op==="add-node")?.node.id;let P={id:this.nextId(),seq:this.log.length,batch:i,author:s,intent:$.describe!==void 0?E.intent:t.intent??E.intent,...L("batchIntent",t.intent),mutation:R,primitives:E.primitives.map(Xn),reads:E.reads,writes:E.writes,...$.describe!==void 0&&E.described&&E.described.length>0?{described:E.described}:{},...L("mergedInto",E.mergedInto),at:this.now(),...L("via",t.via),...L("lineage",a)};this.graph.applyPrimitives(P.primitives),this.log.append(P),d.push(P),f.push(...P.primitives);for(let z of P.reads)c.add(z);for(let z of P.writes)p.add(z);u.push(P.intent)}}catch(v){throw this.putBack(g,h),v}let w=ve(g,this.graph.snapshot(),f);this.admitted(t,d,f,w,g,h);let S=this.violations(r);return this.notify(w,d),{batch:i,ops:d,diff:w,primitives:f,reads:[...c],writes:[...p],intent:t.intent??u.join("; "),...this.moved(l,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(f){throw this.graph.load(i),new un(d,f)}let a=this.log.length;for(let[d,f]of o.entries()){let c=gn({...f,seq:a+d});this.log.append(c),s.push(c)}return this.notify(ve(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 f=a.primitives.map(Xn),c={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,...L("batchIntent",a.batchIntent),mutation:a.mutation??null,primitives:f,reads:a.reads??[],writes:a.writes??[...new Set(f.flatMap(Re))],at:a.at??this.now(),...L("undoes",a.undoes),...L("via",a.via),...L("lineage",Un(a.lineage))};if(r.has(c.id))throw new I(`Op "${c.id}" (${c.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(c.id),c}),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 un(a,d)}for(let a of i)this.log.append(a);for(let a of i)Pt(a.author.id);return this.notify(ve(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=Un(t.lineage),f=e.map(Xn),c=[];if(f.length>0){let l={id:this.nextId(),seq:this.log.length,batch:r,author:o,intent:a,mutation:null,primitives:f,reads:[],writes:[...new Set(f.flatMap(Re))],at:this.now(),...L("via",t.via),...L("lineage",d)};this.graph.applyPrimitives(l.primitives),this.log.append(l),c.push(l),Pt(o.id)}let p=this.violations(),u=ve(s,this.graph.snapshot(),f);return this.notify(u,c),{batch:r,ops:c,diff:u,primitives:f,reads:[],writes:c[0]?.writes??[],intent:a,...this.moved(i,p),violationsAfter:p}}findings(){return ed({schema:this.schema,invariants:this.allInvariants()},this.graph.snapshot(),{invariantOptions:this.invariantOptions})}batches(){return this.log.batches()}canUndo(e){return Dn(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=Xs(r.ops),i=new Set;for(let s of r.ops)for(let a of s.writes)i.add(a);return{ok:!0,check:r,...this.previewPrimitives(o,{reads:[...new Set(r.ops.flatMap(s=>[...s.reads]))],writes:[...i],intent:`Undo: ${r.ops.map(s=>s.intent).join("; ")}`,restoring:r.ops.every(id),...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&&!q(o);if(i){let h=Dn(Ur(tn(this.log.all(),Kr(this,o)),()=>this.log.epochs()),r);if(!h.ok)throw new ze(h)}let s=this.canUndo(r);if(!s.ok)throw new ze(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=Un(t.lineage);if(this.policy)for(let h of s.ops){if(!h.mutation)continue;let b=D(h.author).id,y=A=>JSON.stringify(A).includes(JSON.stringify(b)),k=b!==void 0&&b!==D(o).id&&!q(o)&&!y(h.mutation.args)&&y(h.primitives)?{ok:!1,refusal:{mutation:h.mutation.name,wouldNeed:[],message:"it was done as somebody else."}}:this.permits(h.mutation,o);k.ok||this.refuse({...k.refusal,message:`Not permitted to undo "${h.intent}": ${k.refusal.message}`},o.id,!0)}let f=this.graph.snapshot(),c=this.violations(),p=[],u=this.log.length;for(let h of[...s.ops].sort((b,y)=>y.seq-b.seq)){let b={id:this.nextId(),seq:this.log.length,batch:a,author:o,intent:`Undo: ${h.intent}`,...L("batchIntent",t.intent),mutation:null,primitives:_e(h),reads:h.reads,writes:h.writes,at:this.now(),undoes:h.id,...L("via",t.via),...L("lineage",d),...L("undoneLineage",h.lineage)};this.graph.applyPrimitives(b.primitives,{restoring:id(h)}),this.log.append(b),p.push(b)}let l=ve(f,this.graph.snapshot(),p.flatMap(h=>[...h.primitives]));this.admitted(t,p,p.flatMap(h=>[...h.primitives]),l,f,u);let g=this.violations();return this.notify(l,p),{batch:a,ops:p,diff:l,primitives:p.flatMap(h=>[...h.primitives]),reads:[...new Set(p.flatMap(h=>[...h.reads]))],writes:[...new Set(p.flatMap(h=>[...h.writes]))],intent:t.intent??p.map(h=>h.intent).join("; "),...this.moved(c,g),violationsAfter:g}}authorName(e){return Mn(e,{graph:this.graph,schema:this.schema})}refuseDeclined(e,t){let r=da(this.log.all(),e);r&&this.refuse({mutation:e[0].name,message:`${this.authorName(t)} may not make this again: a person declined it on ${r.at.slice(0,10)}.`,wouldNeed:[]},t.id)}putBack(e,t){this.graph.load(e),this.log.length>t&&this.log.truncate(t)}admitted(e,t,r,o,i,s){if(!e.admit||t.length===0)return;let a=this.graph.size;try{e.admit({ops:t,primitives:r,added:{nodes:o.addedNodes.length,edges:o.addedEdges.length},removed:{nodes:o.removedNodes.length,edges:o.removedEdges.length},changed:{nodes:o.changedNodes.length},nodesAfter:a.nodes,edgesAfter:a.edges})}catch(d){throw this.putBack(i,s),d}}redo(e,t={}){return this.undo(e,t)}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(e,t){if(!(this.quiet>0)&&!(t.length===0&&Ds(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 I(`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 I(`Cannot rebase across an epoch: one begins at seq ${d.seq}, after pending op "${i[0].id}"`);let f=this.graph.snapshot(),c=[],p=[],u=[];this.quiet++;try{for(let b of[...i].reverse())this.graph.applyPrimitives(_e(b),{restoring:!0,inPlace:!0});this.log.truncate(s);let h=new Set(this.log.all().map(b=>b.id));for(let b of e.confirmed){if(h.has(b.id))continue;try{this.graph.applyPrimitives(b.primitives,{restoring:b.undoes!==void 0})}catch(k){throw new un(b,k)}let y=gn({...b,seq:this.log.length});this.log.append(y),h.add(b.id),c.push(y)}for(let b of e.pending){let y=i.filter(k=>k.batch===b);if(y.length!==0)try{p.push(...this.replay(b,y))}catch(k){u.push({batch:b,error:k})}}}catch(h){this.log.truncate(s);for(let b of i)this.log.append(b);throw this.graph.load(f),h}finally{this.quiet--}let l=Qe(f,this.graph.snapshot()),g=[...c,...p];return this.notify(l,g),{diff:l,confirmed:c,pending:p,refused:u}}adopt(e){this.stillNow();let t=new Set(e.drop??[]),r=(e.pending??[]).filter(l=>!t.has(l)),o=this.log.all(),i=this.graph.snapshot(),s={ops:[...o],epochs:[...this.log.epochs()],horizon:this.log.horizon},a=new Set(o.map(l=>l.id)),d=new Map(r.map(l=>[l,o.filter(g=>g.batch===l)]));if(e.log.length>0)this.log.replace(e.log,e.epochs,L("horizon",e.horizon));else{let l=e.horizon??0;this.log.replace([],e.epochs??[{seq:l,base:e.snapshot}],{horizon:l})}let f=[],c=[];this.quiet++;try{this.graph.load(e.snapshot),this.projected=void 0,this.countPastTheLog();for(let l of r){let g=d.get(l)??[];if(g.length!==0)try{f.push(...this.replay(l,g))}catch(h){c.push({batch:l,error:h})}}}catch(l){throw this.log.replace(s.ops,s.epochs,{horizon:s.horizon}),this.graph.load(i),this.projected=void 0,l}finally{this.quiet--}let p=this.log.all().filter(l=>!a.has(l.id)&&!f.includes(l)),u=Qe(i,this.graph.snapshot());return this.notify(u,[...p,...f]),{diff:u,adopted:p,pending:f,refused:c}}replay(e,t){let r=t[0],o={author:r.author,batch:e,...L("intent",r.batchIntent),...L("via",r.via),...L("lineage",r.lineage)};if(r.undoes!==void 0){let i=t.map(a=>this.log.get(a.undoes??"")),s=t.find((a,d)=>i[d]===void 0);if(s)throw new I(`What "${s.intent}" took back is no longer in the log`);return this.undoing([...new Set(i.map(a=>a.batch))],o).ops}return t.every(i=>i.mutation!==null)?this.applying(t.map(i=>i.mutation),o).ops:this.append(t.map(({seq:i,...s})=>s))}snapshot(){return this.graph.snapshot()}verify(){let e=this.log.lastEpoch();return Oa(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 h=this.log.length-(e.keepOps??1e3),y=Date.parse(e.now??this.now())-(e.keepDays??90)*864e5,k=t.find(m=>Date.parse(m.at)>y),A=k?k.seq:this.log.length;r=Math.min(h,A)}for(r=Math.min(Math.max(r,this.log.horizon),this.log.length);r>this.log.horizon&&r<this.log.length&&t[r-this.log.horizon].batch===t[r-1-this.log.horizon].batch;)r--;if(r<=this.log.horizon)return;let o=this.verify();if(!o.ok)throw new I(`Cannot compact a store that does not verify: ${o.reason}`);let{creators:i,removed:s,writers:a,...d}=this.log.checkpointAt(this.schema,r,{validate:this.validate}),f=new Set(d.base.nodes.map(h=>h.id)),{creators:c,removed:p}=ha(this.log,r,h=>f.has(h)),u=ie(this.log),l=pa(this.log,r,d.base.nodes,h=>T(h,b=>!f.has(b)&&u.kindOf(b)===void 0)),g=h=>h&&Object.keys(h).length>0;return{...d,...g(c)&&{creators:c},...p&&{removed:p},...g(l)&&{writers:l}}}compact(e){return this.stillNow(),this.log.compact(e)}};var Pl=n=>`lens:${n}`,zl={hidden:[],removed:[],may:{views:!1,lenses:!1}};function Ml(n,e,t){return n.name!==void 0&&e.may.views?"view":n.declared&&e.may.lenses&&t.lens?"lens":null}var cd=["full","summary","glyph"],Wn="view:",go=(n,e)=>n.as===e.as&&(n.over??[n.kind]).includes(e.kind),Nl=n=>n.filter((e,t)=>!n.slice(0,t).some(r=>go(r,e)));function pe(n){return n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function qn(n,e){return`/${pe(n.tryDefinition(e)?.plural??`${e}s`)}`}function Il(n,e,t){return`${qn(n,e)}/${encodeURIComponent(t)}`}function jl(n,e){return`/places/${encodeURIComponent(n)}${e?`?of=${encodeURIComponent(e)}`:""}`}function ud(n,e){return e.some(t=>t.as===n.as&&!go(n,t))}function Tl(n,e,t){return ud(n,e)?`${n.title} \xB7 ${(t.tryDefinition(n.kind)?.plural??`${n.kind}s`).toLowerCase()}`:n.title}var Te=(n,e,t="")=>`${n}|${e.cardinality}|${e.fidelity}|${t}`;function ho(n){switch(n){case"full":return["full","summary","glyph"];case"summary":return["summary","full","glyph"];case"glyph":return["glyph","summary","full"]}}function Dl(n){let e=new Map,t=[],r=[],o,i,s={arrange(a){return a!==void 0&&(o=a),s},arrangement:()=>o,home(a){return a!==void 0&&(i=a),s},homeView:()=>i,register(a,d,f,c){let p={...c?.over?.[1]?{over:c.over}:{},...c?.hidden?{hidden:!0}:{},...c?.name?{name:c.name}:{},...c?.declared?{declared:!0}:{}},u={kind:a,cardinality:d.cardinality,fidelity:d.fidelity,view:f,...c?.title?{title:c.title}:{},...c?.across?{across:c.across}:{},...c?.beside?{beside:!0}:{},...p};if(r.push(u),!c?.beside&&!p.hidden&&e.set(Te(a,d),u),c?.title){let l=pe(c.title);e.set(Te(a,d,l),u),d.cardinality==="many"&&!t.some(g=>g.kind===a&&g.as===l)&&t.push({kind:a,title:c.title,as:l,...c.across?{across:c.across}:{},...p,...c.lens?{lens:c.lens}:{},...c.reads?.length?{reads:c.reads}:{}})}return s},places:()=>t,forget(a,d){for(let c of cd)e.delete(Te(a,{cardinality:"many",fidelity:c},d));let f=t.findIndex(c=>c.kind===a&&c.as===d);return f>=0&&t.splice(f,1),s},lookup(a,d){return e.get(Te(a,d))?.view},resolve(a,d,f){if(f)for(let c of ho(d.fidelity)){let p=e.get(Te(a,{cardinality:d.cardinality,fidelity:c},f));if(p)return p}for(let c of ho(d.fidelity)){let p=e.get(Te(a,{cardinality:d.cardinality,fidelity:c}));if(p)return p}if(d.cardinality==="one")for(let c of ho(d.fidelity)){let p=e.get(Te(a,{cardinality:"many",fidelity:c}));if(p)return p}},registrations:()=>r,all(){return[...e.values()]},kindsWithViews(){return[...new Set([...e.values()].map(a=>a.kind))]}};return s}var Fl=["day","week","month","year","decade"];function ld(n){let e={};n.q&&n.q.trim().length>0&&(e.query=n.q);let t=Ar(n.archived);if(t&&(e.archived=t),n.sort){let[r,o]=n.sort.split(":");r&&(e.sort={by:r,direction:o==="desc"?"desc":"asc"})}if(n.filter){let r=[];for(let o of n.filter.split(",")){let i=o.indexOf(":");i<=0||r.push({key:o.slice(0,i),value:o.slice(i+1)})}r.length>0&&(e.filter=r)}if(n.group){let[r,o]=n.group.split(":");r&&(e.group={by:r,...Fl.includes(o)?{bucket:o}:{}})}return e}function mo(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 Nt(n,e,t){let r=mo(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 Zl(n,e,t){let r=mo(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 Hn={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"]}},Ll=20,pd=Object.keys(Hn),Cl=(n,e,t,r=Hn[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.`}),hd=n=>Object.hasOwn(Hn,n);function yo(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 ln=n=>typeof n=="object"&&n!==null&&!Array.isArray(n);function fd(n,e,t){let r=n.tryDefinition(e)?.fields.shape,o=j(r?.[t]);for(;o&&(o.type==="optional"||o.type==="default"||o.type==="nullable"||o.type==="prefault");)o=j(o.innerType);return o?.type!=="enum"?[]:(o.entries?Object.values(o.entries):o.values??[]).filter(s=>typeof s=="string")}function Gl(n){let e=[],t=[],r=[],o=new Set(n.schema.kinds),i=new Set;for(let d of o)for(let f of Object.keys(n.schema.tryDefinition(d)?.edges??{}))i.add(f);let s=d=>Object.keys(n.schema.tryDefinition(d)?.fields.shape??{}),a=new Map;return(n.lenses??[]).forEach((d,f)=>{let c=`lenses.${f}`,p=typeof d.title=="string"&&d.title.trim().length>0?d.title.trim():void 0,u=(v,x)=>{t.push({index:f,name:d.name,...p?{title:p}:{},why:v}),x&&r.push({severity:"warning",...x})};if(!hd(d.name)){p?u(`"${d.name}" is not a lens this framework draws`,{code:"lens-not-shipped",path:`${c}.name`,message:`"${p}" names the lens "${d.name}", which the framework does not ship, so nothing draws it.`,fix:`Name one of ${pd.join(", ")} \u2014 or register the view yourself and drop the title.`}):u("it is a lens this app wrote, drawn by the app's own views");return}if(!p)return u("it has no title, so it is bindings the checker holds and no place");let l=Hn[d.name],g=ln(d.options)?d.options:{};if(d.options!==void 0&&!ln(d.options))return u("its options are not an object",{code:"lens-options-not-an-object",path:`${c}.options`,message:`"${p}" has options that are not an object.`,fix:'Write them as { "<option>": <value> }, or drop them.'});for(let v of Object.keys(g))l.options.includes(v)||r.push({severity:"warning",code:"lens-option-unknown",path:`${c}.options.${v}`,...Cl(d.name,v,p,l.options)});let h={};for(let v of l.options)g[v]!==void 0&&(h[v]=g[v]);d.arrangedBy&&(h.arrangedBy=ld(d.arrangedBy));let b=ln(d.bindings)?d.bindings:{},y=[],k,A=(v,x,R)=>u(x,{code:"lens-cannot-draw",path:v,message:`"${p}" cannot draw: ${x}.`,fix:R});if(l.binds==="fields"){let v=Object.keys(b).filter(R=>ln(b[R])),x=v.filter(R=>!o.has(R));if(v.length===0)return A(`${c}.bindings`,"it binds no kind",`Bind a kind's fields: "bindings": { "<kind>": { ${l.requiredRoles.map(R=>`"${R}": "<field>"`).join(", ")} } }.`);if(x.length>0)return;if(h.bindings=b,y=v,d.name==="timeline"){let R=g.columns;if(Array.isArray(R))h.columns=R.map($=>typeof $=="string"?{id:$,label:$}:$);else{let $=v.flatMap(E=>{let P=b[E],z=typeof P.column=="string"?P.column:typeof P.columns=="string"?P.columns:void 0;return z?fd(n.schema,E,z):[]}),_=[...new Set($)];if(_.length===0)return A(`${c}.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=_.map(E=>({id:E,label:E.toUpperCase()}))}h.extent===void 0&&(h.extent=1440)}if(d.name==="columns"){if(h.sort!==void 0){let $=v.map(_=>Nt(h.sort,s(_),_)).find(Boolean);$&&(r.push({severity:"warning",code:"lens-sort",path:`${c}.options.sort`,message:`"${p}" cannot order its cards: ${$}.`,fix:'Write { "by": "<a field>", "direction": "asc" }, or drop it.'}),delete h.sort)}let R=new Set;for(let $ of v){let _=b[$].column;if(typeof _!="string"||!s($).includes(_))return;let E=fd(n.schema,$,_);if(E.length===0)return A(`${c}.bindings.${$}.column`,`its column field "${_}" is not a choice`,`Bind "column" to a choice field of ${$}, like a status.`);for(let P of E)R.add(P)}typeof h.move!="boolean"&&delete h.move,Number.isInteger(h.cap)&&h.cap>=1&&h.cap<=500||delete h.cap;for(let $ of["collapsed","hidden"])yo(h,$,_=>R.has(_))}if(d.name==="calendar"&&h.today!==void 0&&!(typeof h.today=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(h.today)))return A(`${c}.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 R=h.horizon,$=P=>P===void 0||Number.isInteger(P)&&P>=1&&P<=9999,_=typeof R=="number"?{years:R,title:"Years"}:R;ln(_)&&Number.isInteger(_.years)&&_.years>=1&&_.years<=200&&typeof _.title=="string"&&_.title.trim().length>0&&$(_.from)&&$(_.to)&&Object.keys(_).every(P=>["years","title","from","to"].includes(P))&&!(typeof _.from=="number"&&typeof _.to=="number"&&_.to<_.from)?h.horizon=_:(delete h.horizon,r.push({severity:"warning",code:"lens-horizon",path:`${c}.options.horizon`,message:`"${p}" has a horizon that is not a span of years, so it offers no span of years.`,fix:'Write { "years": 30, "title": "The career" } \u2014 "from" and "to" (years, like 1962 and 2023) only to pin its ends, which otherwise reach the first and last of its records.'}))}if(d.name==="calendar"&&h.range!==void 0&&!["day","week","month","quarter","year","years","agenda"].includes(h.range))return A(`${c}.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(l.binds==="entities"){let v=$=>{let _=b[$];if(ln(_)){if(typeof _.kind=="string")return _.kind;if(typeof _.edge=="string")return _.edge;if(Array.isArray(_.path))return{path:_.path};if(typeof _.field=="string")return _.field}};for(let $ of l.requiredRoles)if(v($)===void 0)return;let x=d.name==="coverage"?"rows":d.name==="board"?"slots":"regions",R=v(x);if(!o.has(R))return;if(d.name==="coverage"){let $=v("columns");if(!o.has($))return;let _=v("link");if(typeof _=="string"&&!i.has(_))return;Object.assign(h,{rows:R,columns:$,link:_}),$!==R&&(k=$);for(let[E,P]of[["sort",R],["columnSort",$]]){if(h[E]===void 0)continue;let z=Nt(h[E],s(P),P);z&&(r.push({severity:"warning",code:"lens-sort",path:`${c}.options.${E}`,message:`"${p}" cannot order its ${E==="sort"?"rows":"columns"}: ${z}.`,fix:`Write { "by": "<a field of ${P}>", "direction": "asc" }, or drop it.`}),delete h[E])}}else if(d.name==="board"){Object.assign(h,{slots:R,x:v("x"),y:v("y"),fill:v("fill")});for(let $ of["x","y"])if(!s(R).includes(h[$]))return}else{Object.assign(h,{regions:R,outline:v("outline")});for(let $ of["markers","at","within","nests","regionKind","markerKind"]){let _=v($);typeof _=="string"&&(h[$]=_)}}y=[R]}else if(d.name==="blocks"){if(!d.on)return A(`${c}.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 A(`${c}.options.blocks`,"it has no blocks to draw",`Say "options": { "blocks": [{ "headline": "\u2026" }, { "list": "all('<kind>')", "as": "card" }] }.`)}else{let v=["user","person","member"].find(x=>o.has(x));if(!d.on&&!v)return A(`${c}.on`,"it does not say which kind it stands on",'Say "on": "<the kind whose records are the people>".');y=v?[v]:[]}if(d.on!==void 0){if(typeof d.on!="string"||!o.has(d.on))return A(`${c}.on`,`it stands on "${String(d.on)}", which is not a kind`,`Use one of: ${[...o].join(", ")}.`);if(y=[d.on],d.name==="coverage"){let v=[h.rows,h.columns].find(x=>x!==d.on);k=typeof v=="string"?v:void 0}}let m=typeof h.rows=="string"?h.rows:y[0];if(m!==void 0){let v=["label",...s(m)],x=new Set(["is",...v,...Object.keys(n.schema.tryDefinition(m)?.edges??{})]);yo(h,"search",R=>v.includes(R)),yo(h,"filters",R=>x.has(R.split(".")[0]))}let w=pe(p);if(w.length===0)return A(`${c}.title`,"its title has no letters or digits to make an address of","Give it a title a person would say.");for(let v of y){let x=`${v}|${w}`;if(a.has(x))return u(`another lens on ${v} is already called "${p}"`,{code:"lens-title-taken",path:`${c}.title`,message:`"${p}" is the title of lenses.${a.get(x)} too, on the same kind, so one address would name two pictures.`,fix:"Give each its own title."})}for(let v of y)a.set(`${v}|${w}`,f);let S=d.create;S!==void 0&&typeof S!="boolean"&&r.push({severity:"warning",code:"lens-create",path:`${c}.create`,message:`"${p}" says create ${JSON.stringify(S)}, which is neither true nor false, so its page keeps the forms that begin its kind.`,fix:'Say "create": false to leave them off, or drop it.'}),e.push({index:f,lens:d.name,title:p,as:w,kinds:y,...k?{across:k}:{},options:h,...d.hidden===!0?{hidden:!0}:{},...S===!1?{create:!1}:{}})}),{drawn:e,undrawn:t,findings:r}}var Bl=6;function Kl(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 Ul(n,e,t){if(!n?.primary)return;let r=new Set(n.primary.map(pe));return{kinds:new Set(e.kinds.filter(o=>r.has(pe(o))||r.has(qn(e,o).slice(1)))),places:new Set(t.filter(o=>r.has(o.as)||r.has(pe(o.title))||o.name!==void 0&&n.primary.includes(Wn+o.name)).map(o=>`${o.kind}|${o.as}`))}}var gd="overview",Vl=`/places/${gd}`;function Wl(n){let e=n?.scene?.trim();return e||"Scene"}function ql(n){let e=n?.pages?.trim();return e||"Pages"}function Hl(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 md(n){return n.startsWith(Wn)&&n.slice(Wn.length).trim()||void 0}function Yl(n,e,t){let r=[],o=new Set;for(let i of e??[]){let s=md(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 Jl(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=pe(r),i=t.find(d=>d.title===r||Wn+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=>qn(e,d).slice(1)===o);return a?{to:"kind",kind:a}:void 0}function bo(n){let e=(n??"").replace(/\/+$/,"");return e===""?"":e.startsWith("/")?e:`/${e}`}function Xl(n,e={}){let t=typeof n=="string"?n:n.address,r=bo(e.basePath),o=t.startsWith("/")?t:`/${t}`;return r===""?o:o==="/"?r:o.startsWith("/?")||o.startsWith("/#")?`${r}${o.slice(1)}`:`${r}${o}`}function Ql(n,e){let t=bo(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 yd=Symbol.for("@graview/core:app-link"),ef=n=>(Object.defineProperty(j(n),yd,{value:1,enumerable:!0}),n);function bd(n){let e=j(n);return!!e&&(e[yd]===1||bd(e.innerType))}var rw=()=>ef(F().check(vr(500),_n(ft,"another app's address")));var It=(n,e)=>`${e.kind}\0${e.id??""}\0${n.address}\0${n.kind}\0${n.id}`;function nf(n,e,t=()=>{}){let r=new Map,o=new Map,i=s=>{let a=It(s,e),d=r.get(a);return d||(d=Promise.resolve().then(()=>n.resolve(s,e)).then(f=>tf(f)?f:null,()=>null).then(f=>(r.get(a)===d&&(o.set(a,f),t(s)),f)),r.set(a,d)),d};return{read(s){let a=It(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(It(s,e)),forget(s){if(!s){r.clear(),o.clear();return}let a=It(s,e);r.delete(a),o.delete(a)}}}function tf(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 rf={snapshot:1,op:2};var of=1;var jt=(n,e)=>`${n}\0${e}`;function xo(n){return n.op==="add-node"?Object.keys(n.node).filter(e=>e!=="id"&&e!=="kind").map(e=>[n.node.id,e]):n.op==="patch-node"?Object.keys(n.after).map(e=>[n.id,e]):[]}var vo=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 xo(r)){let s=jt(o,i);(this.revs.get(s)??this.floor)<t.seq&&this.revs.set(s,t.seq)}}of(e,t){return this.revs.get(jt(e,t))??this.floor}baseFor(e,t=new Set){let r=new Set,o=new Map;for(let i of e)for(let s of i.primitives)if(s.op==="add-node"&&r.add(s.node.id),!(s.op!=="patch-node"||r.has(s.id)||t.has(s.id)))for(let a of Object.keys(s.after)){let d=jt(s.id,a);t.has(d)||o.has(d)||o.set(d,{node:s.id,field:a,rev:this.of(s.id,a)})}return[...o.values()]}stale(e){return e.filter(t=>this.of(t.node,t.field)>t.rev)}};function sf(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 xo(r))e.add(jt(o,i))}return e}var af=/^#([0-9a-f]{3,8})$/i,df=/(rgba?|hsla?)\(([^)]+)\)/gi;function cf(n){let e=af.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 uf(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,f,c,p]=r;return d===void 0||f===void 0||c===void 0?null:{r:d,g:f,b:c,a:p??1}}let[o,i,s,a]=r;return o===void 0||i===void 0||s===void 0?null:{...xd(o,i>1?i/100:i,s>1?s/100:s),a:a??1}}function ko(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 So(n,e,t){return{...xd(n,e,t),a:1}}function xd(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],f=t-r/2;return{r:Math.round((s+f)*255),g:Math.round((a+f)*255),b:Math.round((d+f)*255)}}function fn(n){let e=[];for(let t of n.matchAll(df)){let r=uf(t[0]);r&&e.push(r)}for(let t of n.matchAll(/#[0-9a-fA-F]{3,8}\b/g)){let r=cf(t[0]);r&&e.push(r)}return e}function $o(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 wo(n){let e=n/255;return e<=.03928?e/12.92:((e+.055)/1.055)**2.4}function vd(n){return .2126*wo(n.r)+.7152*wo(n.g)+.0722*wo(n.b)}function pn(n,e){let[t,r]=[vd(n),vd(e)].sort((o,i)=>i-o);return(t+.05)/(r+.05)}var Tt=(n,e)=>`rgba(${Math.round(n.r)}, ${Math.round(n.g)}, ${Math.round(n.b)}, ${e})`,wd={r:0,g:0,b:0,a:1},Dt={r:255,g:255,b:255,a:1};function Ft(n){let e=fn(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=ko(e);for(let s of["dark","light"]){let a=n.base[s],d=fn(a.ground)[0]??(s==="dark"?wd:Dt),f=$o(fn(a.panel)[0]??Dt,d),c=hf(i,[f,d],s,4.5);c?Math.abs(c.l-i.l)>pf&&(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(c.l-i.l)*100)} points, which is far enough that it stops being the same color \u2014 supply one for ${s}`)):(r.add(`accent (${s})`),o.push(`no lightness of this hue clears 4.5:1 as text on the ${s} panel, so ${s} needs an accent of its own`));let p=c??i,u=So(p.h,p.s,p.l),l=n.accentInk?.[s]??(pn(Dt,u)>=pn(wd,u)?"#ffffff":"#000000"),g=pn(fn(l)[0]??Dt,u);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:Tt(u,1),accentDim:Tt(u,s==="dark"?.35:.22),accentInk:l,glow:Tt(u,s==="dark"?.28:.1),edgeBright:Tt(u,lf(u,f,s==="dark"?.55:.42,3)),...n.warn?.[s]?{warn:n.warn[s]}:{}};let h=fn(t[s].warn)[0];h&&ff(ko(h).h,p.h)<25&&(r.add(`warn (${s})`),o.push(`the warning color shares the accent's hue in ${s}, so "something is broken" looks like "this is selected"`))}return r.size>0?{ok:!1,missing:[...r].sort(),why:o.join("; ")}:{ok:!0,schemes:t}}function lf(n,e,t,r){for(let o=Math.round(t*100);o<=100;o++){let i=o/100;if(pn($o({...n,a:i},e),e)>=r)return i}return 1}function ff(n,e){let t=Math.abs(n-e)%360;return t>180?360-t:t}var pf=.3;function hf(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(f=>pn(So(n.h,n.s,d),f)>=r))return{...n,l:d}}return null}function gf(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 De=Object.freeze({navy:"#001769",turquoise:"#00e5b9",paper:"#f7f7f2",ink:"#18213a",muted:"#586174"}),Ro="Montserrat",_o=Object.freeze({display:550,body:450,label:600}),Ao=Object.freeze({display:600,body:400,label:600}),mf="-0.025em",yf=Object.freeze({minWidth:140,clearSpace:.5,microMax:24,regularMin:32,microBelow:28});var kd={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:De.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},Sd={ground:De.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:De.ink,inkMuted:De.muted,inkFaint:"#626b7d",accent:De.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},hn={dark:kd,light:Sd};var $e=Object.freeze({radius:8,density:1,radiusSmall:.72,radiusSmallFloor:2,pad:15,padSmall:10,gap:7}),Fe=Object.freeze({body:`"${Ro}", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif`,mono:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace'});function bf(n){let e=n?.shape?.radius??$e.radius,t=n?.shape?.density??$e.density;return Object.freeze({radius:e,radiusSmall:Math.max($e.radiusSmallFloor,Math.round(e*$e.radiusSmall)),pad:Math.round($e.pad*t),padSmall:Math.round($e.padSmall*t),gap:Math.round($e.gap*t)})}function vf(n){let e=n?.typography?.body??Fe.body,t=n?.typography?.display??e,o=e===Fe.body&&t===Fe.body?_o:Ao,i=n?.typography?.weights;return Object.freeze({body:e,display:t,mono:n?.typography?.mono??Fe.mono,weights:Object.freeze({display:i?.display??o.display,body:i?.body??o.body,label:i?.label??o.label})})}var bw=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 Rd(n){return/^\s*(<\?xml[^>]*>\s*)?(<!--[\s\S]*?-->\s*)*(<!DOCTYPE svg[^>]*>\s*)?<svg[\s>/]/i.test(n)}var _d="http://www.w3.org/2000/svg",xf=["http://www.w3.org/1999/xhtml","http://www.w3.org/1998/Math/MathML",_d],wf=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(" ")),kf=new Set(["title","desc"]),Yn="it embeds a page or media",Sf={script:"it has a script in it",foreignobject:"it embeds HTML (foreignObject)",iframe:Yn,embed:Yn,object:Yn,audio:Yn,video:Yn,style:"it has a style sheet in it; a mark is styled by its attributes",a:"it links to something (an <a> element)"},$f={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"};function Rf(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=$f[o.toLowerCase()];return i===void 0&&(e=!0),i??""});return e?null:t}function _f(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 Af(n,e,t){let r=Rf(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===_d?null:"it changes what its elements are (another xmlns)";if(e.startsWith("xmlns:"))return xf.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 _f(r)?null:o==="style"?"its style loads something outside itself":"it loads or links to something outside itself"}var $d=/^\s+([A-Za-z_][A-Za-z0-9_.:-]*)\s*=\s*(?:"([^"<]*)"|'([^'<]*)')/;function Ad(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 l=o.indexOf("-->",4);if(l<0)return"it has a comment that never ends";let g=o.slice(4,l);if(/^-?>/.test(g)||g.includes("--")||g.includes("<!")||g.endsWith("-"))return"it has a comment the page and the picture read differently";r+=l+3;continue}if(/^<!DOCTYPE/i.test(o)){let l=/^<!DOCTYPE\s+svg\b[^<>[\]]*>/i.exec(o);if(!l||e.length>0||t)return"it declares XML entities";r+=l[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],f=Sf[d.toLowerCase()];if(f)return f;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(!wf.has(d))return`it has a <${d}> element, which a picture does not need`;let c=e[e.length-1];if(c&&kf.has(c))return`it has an element inside a <${c}>, which the page reads as HTML`;let p=a[0].length;for(let l=$d.exec(o.slice(p));l;l=$d.exec(o.slice(p))){let g=Af(d,l[1],l[2]??l[3]??"");if(g)return g;p+=l[0].length}let u=/^\s*(\/?)>/.exec(o.slice(p));if(!u)return/(?:^|[\s/"'])on[a-z]+\s*=/i.test(o.slice(p,p+400))?"it has an event handler (an on\u2026 attribute)":`it is not one SVG: <${d}>'s attributes are not each quoted and apart`;u[1]!=="/"?e.push(d):e.length===0&&(t=!0),r+=p+u[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 Od(n){if(n){if(!Rd(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 Ad(n)===null?`data:image/svg+xml,${encodeURIComponent(n.trim())}`:void 0}}var Zt;function Of(){if(Zt===void 0)try{Zt=new RegExp("^\\p{RGI_Emoji}$","v")}catch{Zt=null}return Zt}function Ef(n){return/\p{Extended_Pictographic}|\p{Regional_Indicator}|⃣/u.test(n)}function Oo(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(Ef).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=Of();return r&&!r.test(n)?"it is not one of the standard emoji every emoji set draws":null}function Eo(n){return typeof n=="object"&&n!==null&&typeof n.emoji=="string"?n.emoji:void 0}function Ed(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 Pf(n){let e=n?.favicon;if(typeof e=="object"&&e!==null){let t=Eo(e);return t!==void 0&&Oo(t)===null?`data:image/svg+xml,${encodeURIComponent(Ed(t))}`:void 0}return Od(e)}function zf(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 Mf(n){if(n?.logo)return;let e=Eo(n?.favicon);return e!==void 0&&Oo(e)===null?e:void 0}var Pd={"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":Fe.mono},Nf=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","-apple-system","BlinkMacSystemFont"],zd=["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 If=n=>new Set(n.map(e=>e.toLowerCase()));function jf(n){return If([...Nf,...zd]).has(n.toLowerCase())||n.toLowerCase().startsWith("ui-")}function Tf(n){return Pd[n]??n}function Rw(n){let e=Ft({accent:n,base:hn});return e.ok||!e.missing.every(t=>t.startsWith("warn"))?e:Ft({accent:n,base:hn,warn:{light:hn.light.bad,dark:hn.dark.bad}})}function Df(n,e,t){if(t.rows===0)return;let r=ne(n,e.rows).toLowerCase(),o=ne(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=K(n.tryDefinition(e.rows),e.rows);return i?`No ${a} is linked to another yet: ${s}.`:`No ${a} is linked to ${Be(K(n.tryDefinition(e.columns),e.columns))} yet: ${s}.`}var se={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 Ff(n){return n?{connectors:{all:{...se.connectors.all,...n.connectors?.all??{}},byEdge:{...se.connectors.byEdge,...n.connectors?.byEdge??{}}},captions:{...se.captions,...n.captions??{}},grid:{...se.grid,...n.grid??{}},lattice:{...se.lattice,...n.lattice??{}},tags:{...se.tags,...n.tags??{}},emphasis:{...se.emphasis,...n.emphasis??{}},marks:{...se.marks,...n.marks??{}}}:se}function Zf(n,e){return{...n.connectors.all,...n.connectors.byEdge[e]??{}}}function Lf(n){return[` --graview-kit-grid: ${n.grid.visible?1:0};`,` --graview-kit-grid-size: ${n.grid.size}px;`,` --graview-kit-lattice: ${n.lattice.visible?1:0};`,` --graview-kit-lattice-size: ${n.lattice.size}px;`,` --graview-kit-tags: ${n.tags.visible?"inline-flex":"none"};`,` --graview-kit-captions: ${n.captions.visible?"block":"none"};`,` --graview-kit-rest: ${n.emphasis.rest};`,` --graview-kit-dim: ${n.emphasis.dim};`,` --graview-kit-flag: "${n.marks.flag.replace(/"/g,"'")}";`].join(`
|
|
5
|
+
`)}function Cf(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,f=new Set;for(let c of r){if(a.includes(c))for(let p of d)f.add(p);if(s.to==="*"||d.includes(c))for(let p of a)f.add(p)}if(f.size===0)return{ok:!1,at:o};r=f}return{ok:!0,reached:r}}function Gf(n){let e=n.name??"";return e&&n.onBehalfOfName?`${e}, for ${n.onBehalfOfName}`:e}function Po(n,e,t=2500){return n.held==="socket"?!0:n.until!==void 0?e<Date.parse(n.until):e-Date.parse(n.at)<t}function Bf(n){return`${n.kind}:${n.id??""}:${n.session??""}`}function Kf(n,e,t,r=2500,o){let i=new Map;for(let[s,a]of n)Po(a,t,r)&&i.set(s,a);for(let s of e){if(!Po(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 Uf(n,e){return!n||!e?n===e:n.participant===e.participant&&n.kind===e.kind&&n.name===e.name&&n.onBehalfOf===e.onBehalfOf&&n.onBehalfOfName===e.onBehalfOfName&&n.until===e.until&&n.held===e.held&&n.hue===e.hue&&n.stop===e.stop&&(n.over??null)===(e.over??null)&&(n.robot?.at??null)===(e.robot?.at??null)&&(n.robot?.mode??null)===(e.robot?.mode??null)}export{Ve as a,ds as b,cs as c,Ec as d,vr as e,Rn as f,_n as g,F as h,tm as i,rm as j,An as k,om as l,im as m,sm as n,xr as o,am as p,We as q,qe as r,dm as s,cm as t,um as u,bs as v,vs as w,Q as x,lm as y,ut as z,fm as A,pm as B,j as C,qc as D,Gt as E,Ge as F,Qn as G,Vf as H,H as I,Md as J,Nd as K,Io as L,nt as M,Id as N,me as O,Bt as P,jo as Q,Kt as R,Dd as S,Fd as T,ae as U,Zd as V,Ld as W,Cd as X,Gd as Y,Bd as Z,xn as _,Fo as $,Zo as aa,Ud as ba,Vt as ca,Z as da,Vd as ea,C as fa,Wd as ga,ne as ha,qd as ia,Hd as ja,rt as ka,Be as la,K as ma,Hc as na,lt as oa,Sr as pa,xs as qa,ws as ra,ks as sa,Yc as ta,On as ua,$s as va,hy as wa,pt as xa,bd as ya,rw as za,nu as Aa,ru as Ba,As as Ca,ou as Da,by as Ea,En as Fa,iu as Ga,au as Ha,vy as Ia,xy as Ja,du as Ka,Es as La,nf as Ma,ht as Na,cu as Oa,Ye as Pa,zn as Qa,gt as Ra,Sy as Sa,Je as Ta,He as Ua,Ts as Va,fu as Wa,Mn as Xa,Pe as Ya,Ay as Za,Ar as _a,mt as $a,pu as ab,M as bb,I as cb,W as db,mu as eb,vt as fb,By as gb,yu as hb,bu as ib,rf as jb,of as kb,D as lb,q as mb,xe as nb,we as ob,Qy as pb,Vs as qb,nn as rb,T as sb,tn as tb,Me as ub,ee as vb,Su as wb,oe as xb,rl as yb,Jr as zb,Na as Ab,dn as Bb,av as Cb,Qr as Db,Da as Eb,Fa as Fb,eo as Gb,Se as Hb,Hr as Ib,Gn as Jb,fl as Kb,Za as Lb,yb as Mb,bb as Nb,to as Ob,ro as Pb,oo as Qb,Ua as Rb,vl as Sb,At as Tb,Ne as Ub,vo as Vb,sf as Wb,cn as Xb,Dr as Yb,sa as Zb,_u as _b,Ou as $b,gf as ac,Ro as bc,mf as cc,hn as dc,Fe as ec,bf as fc,vf as gc,Rd as hc,Ad as ic,Od as jc,Pf as kc,zf as lc,Mf as mc,jf as nc,Tf as oc,Rw as pc,Zl as qc,Df as rc,Ff as sc,Zf as tc,Lf as uc,Eu as vc,Pu as wc,zu as xc,Mu as yc,Ie as zc,Zn as Ac,ie as Bc,Fn as Cc,sn as Dc,Ln as Ec,Kr as Fc,Cn as Gc,Nu as Hc,Iu as Ic,Cf as Jc,$l as Kc,Rl as Lc,Ea as Mc,Rt as Nc,Xr as Oc,_l as Pc,dd as Qc,un as Rc,po as Sc,Pl as Tc,zl as Uc,Ml as Vc,cd as Wc,go as Xc,Nl as Yc,pe as Zc,qn as _c,Il as $c,jl as ad,ud as bd,Tl as cd,Dl as dd,ld as ed,Hn as fd,Ll as gd,pd as hd,hd as id,Gl as jd,Bl as kd,Kl as ld,Ul as md,gd as nd,Vl as od,Wl as pd,ql as qd,Hl as rd,Yl as sd,Jl as td,bo as ud,Xl as vd,Ql as wd,Gf as xd,Bf as yd,Kf as zd,Uf as Ad};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as _,b as pe,e as ue,f as me,g as ce}from"./chunk.7NNI7YH4.js";import{b as G}from"./chunk.7N2GXZYI.js";import{c as de}from"./chunk.ZIEHF67C.js";import{n as P}from"./chunk.5AGW4NRZ.js";import{i as x,j as ie,k as oe,q as se,r as le}from"./chunk.HDRD33II.js";import{d as ae,e as re}from"./chunk.DX357TZ3.js";import{b as te,f as ne}from"./chunk.H7KCWCB4.js";import{$ as Y,Ca as Z,Da as ee,G as he,R as X,_ as O,ba as U}from"./chunk.Y4ZUJUUT.js";import{a as Q}from"./chunk.SDO3U72B.js";import{ea as W,ja as J}from"./chunk.AS4CQBOQ.js";import{b as D}from"./chunk.AJZBJBMO.js";var p=D(he(),1);var ve=ee(Q(()=>(__graviewPreload(import.meta.url,["./chunk.FWSCBHZ5.js","./chunk.7NNI7YH4.js","./chunk.7N2GXZYI.js","./chunk.WVUJXDXZ.js","./chunk.ZIEHF67C.js","./chunk.UHX4WTM7.js","./chunk.IKX4VDTW.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.GZHZLJBF.js","./chunk.5AGW4NRZ.js","./chunk.OJGHDWI6.js","./chunk.DQS7D2W2.js","./chunk.HDRD33II.js","./chunk.DX357TZ3.js","./chunk.H7KCWCB4.js","./chunk.O4WEJ47H.js","./chunk.Y4ZUJUUT.js","./chunk.SDO3U72B.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.CMOXKRWT.js")))),ye=ve.part((i,a)=>i.drawAppLink(a),{quiet:!0});var e=D(X(),1);function K({nodeId:i,field:a,value:l,stored:s=l,said:c}){let{fields:m,commit:o}=P(i),t=m.find(r=>r.field===a),{store:y,principal:I}=O(),u=y.graph.getNode(i)?.kind,g=y.schema.definitions.find(r=>r.kind===u),v=J(g,a),k=v.toLowerCase(),n=c??`${v.charAt(0).toUpperCase()}${v.slice(1)}: ${l}`,[w,E]=(0,p.useState)(!1),d=t?.shape.type==="number"?t.shape.amount:void 0,f=d&&s!==""&&Number.isFinite(Number(s))?ie(Number(s),d):s,[b,M]=(0,p.useState)(f),C=(0,p.useRef)(null),j=(0,p.useRef)(null),z=(0,p.useRef)(!1),S=r=>{z.current=r,E(!1)};(0,p.useEffect)(()=>M(f),[f,w]);let q=t?.shape.type==="date";if((0,p.useEffect)(()=>{if(q)return Z(()=>void ce())},[q]),(0,p.useEffect)(()=>{w?C.current?.focus():z.current&&(z.current=!1,j.current?.focus())},[w]),!t)return(0,e.jsx)("span",{"data-graview-field":a,"data-graview-readonly":"",title:`Read-only \u2014 nothing this app declares changes the ${k}`,style:{color:"var(--graview-ink)",cursor:"default",overflowWrap:"anywhere"},children:l});if(!w)return(0,e.jsx)("button",{ref:j,type:"button","data-graview-field":a,"data-graview-editable":t.mutation,...n===l?{}:{"aria-label":n},title:`${t.title} \u2014 changes the ${k}, and can be undone`,onClick:()=>E(!0),style:{all:"unset",cursor:"text",display:"inline-flex",alignItems:"flex-end",minHeight:24,minWidth:24,maxWidth:"100%",overflowWrap:"anywhere",paddingBottom:1,borderBottom:"1px dashed var(--graview-edge-bright)",color:"var(--graview-ink)"},children:l});let R=(r,{left:h=!1}={})=>{S(!h),!(r===s||r===""||r===void 0)&&(t.shape.type==="date"&&typeof r=="string"&&fe(r)||o(t,r))},fe=r=>{if(t.shape.type!=="date")return!1;let h=m.filter(L=>L.shape.type==="date"&&L.takesValue),T=le(h.map(L=>L.field),g?.fieldRoles??{}),A=T?.start===a?h.find(L=>L.field===T.end):void 0,F=y.graph.getNode(i)?.[T?.end??""];if(!A||typeof F!="string")return!1;let N=se(s===""?void 0:s,r,F,{time:t.shape.time===!0,instant:t.shape.instant===!0});if(N===void 0||N===F)return!1;let $=t.call(r),V=A.call(N);return y.applyAll($.name===V.name?[{name:$.name,args:{...$.args,...V.args}}]:[$,V],{author:I}),!0};if(!t.takesValue){let r=[t,...t.alternatives];return(0,e.jsx)("span",{role:"group","aria-label":`Change ${W(a).toLowerCase()}`,"data-graview-field":a,style:{display:"inline-flex",gap:6,alignItems:"center",flexWrap:"wrap"},onKeyDown:h=>{h.key==="Escape"&&S(!0)},children:r.map((h,T)=>(0,e.jsx)("button",{type:"button",ref:T===0?C:void 0,"data-graview-act":h.mutation,onClick:()=>{S(!0),o(h,void 0)},onBlur:A=>{let H=A.relatedTarget;(!H||!A.currentTarget.parentElement?.contains(H))&&S(!1)},style:{padding:"2px 9px",fontSize:"0.8125rem",borderRadius:999},children:h.title},h.mutation))})}return(0,e.jsxs)("form",{style:{display:"inline-flex",flexWrap:"wrap",gap:4,maxWidth:"100%"},onSubmit:r=>{r.preventDefault(),R(ge(t,b))},children:[t.shape.type==="choice"?(0,e.jsx)("select",{ref:C,"aria-label":W(a),"data-graview-field":a,value:b,onChange:r=>R(r.target.value),onBlur:()=>S(!1),style:{font:"inherit",fontSize:"inherit"},children:t.shape.options.map(r=>(0,e.jsx)("option",{value:r,children:te(g,a,r)},r))}):t.shape.type==="date"?(0,e.jsx)(me,{inputRef:C,label:W(a),value:b===""?void 0:b,time:t.shape.time===!0,instant:t.shape.instant===!0,onChange:r=>M(r??""),onLeave:r=>R(r,{left:!0}),onCancel:()=>S(!0),autoSelect:!0,boxStyle:{fontSize:"inherit",minHeight:24,padding:"0 3px"}}):(0,e.jsxs)(e.Fragment,{children:[d&&x(d).prefix?(0,e.jsx)("span",{"aria-hidden":"true",children:x(d).prefix}):null,(0,e.jsx)("input",{ref:C,"aria-label":d?`${W(a)}, ${x(d).hint}`:W(a),"data-graview-field":a,...d?{inputMode:"decimal",placeholder:x(d).placeholder,"data-graview-amount":d.format??"unit"}:{},type:d?"text":t.shape.type==="number"&&!t.shape.duration?"number":"text",...t.shape.type==="number"&&t.shape.duration?{placeholder:"1h 30m"}:{},...t.shape.type==="text"&&t.shape.holds==="phone"?{inputMode:"tel",autoComplete:"tel"}:{},...t.shape.type==="number"&&t.shape.min!==void 0&&!d?{min:t.shape.min}:{},...t.shape.type==="number"&&t.shape.max!==void 0&&!d?{max:t.shape.max}:{},...t.shape.type==="number"&&t.shape.step!==void 0&&!d?{step:t.shape.step}:{},value:b,onChange:r=>M(r.target.value),onBlur:()=>R(ge(t,b),{left:!0}),onKeyDown:r=>{r.key==="Escape"&&S(!0)},style:{font:"inherit",fontSize:"inherit",width:`min(${Math.max(6,b.length+1)}ch, 100%)`,maxWidth:"100%",minWidth:0,boxSizing:"border-box",minHeight:24,display:"inline-flex",alignItems:"center",padding:"0 3px"}}),d&&x(d).suffix?(0,e.jsx)("span",{"aria-hidden":"true",children:x(d).suffix}):null]}),t.open.length>0?(0,e.jsxs)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:["also needs ",t.open.map(r=>r.name).join(", ")]}):null]})}function ge(i,a){return i.shape.type==="number"&&i.shape.amount?oe(a,i.shape.amount):i.shape.type==="number"?i.shape.duration?ne(a)??a:Number(a):i.shape.type==="text"&&i.shape.holds?a.trim():a}function be({href:i,field:a,value:l,stored:s,nodeId:c}){let m=i.startsWith("tel:"),o=(t,y)=>(0,e.jsx)("a",{href:i,"data-graview-link":a,...y?{"aria-label":y}:{},...m?{}:{target:"_blank",rel:"noopener noreferrer"},style:{display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24,maxWidth:"100%",overflowWrap:"anywhere",color:"var(--graview-accent)"},children:t});return c===void 0?o(l):(0,e.jsxs)("span",{style:{display:"inline-flex",flexWrap:"wrap",alignItems:"center",gap:"0 10px",maxWidth:"100%"},children:[(0,e.jsx)(K,{nodeId:c,field:a,value:l,...s===void 0?{}:{stored:s}}),o(m?"Call":"Map",m?`Call ${l}`:`Open ${l} in maps`)]})}function De({id:i,hide:a=[],limit:l=10,labels:s={},shown:c=[]}){let{store:m}=O(),o=U(i);if(!o)return null;let t=m.schema.tryDefinition(o.kind),y=ae(o,t,{limit:l,said:c}).filter(u=>!a.includes(u.key)),I=de(t).length>0;return y.length===0&&!I?null:(0,e.jsxs)("div",{"data-graview-fields":o.id,style:{display:"grid",gap:14,alignContent:"start",minWidth:0,fontSize:"0.875rem"},children:[re(t,y).map((u,g)=>{let v=(0,e.jsx)("dl",{style:{margin:0,display:"grid",gridTemplateColumns:"auto 1fr",gap:"5px 16px",alignContent:"start",minWidth:0},children:u.fields.map(n=>n.files?(0,e.jsx)(_,{as:"field",nodeId:o.id,field:n.key,label:s[n.key]??n.label,files:n.files,labelStyle:B,style:{marginTop:6}},n.key):n.long?(0,e.jsx)(we,{nodeId:o.id,field:n.key,label:s[n.key]??n.label,value:n.value,markdown:n.markdown,labelStyle:B,style:{gridColumn:"1 / -1",marginTop:6}},n.key):(0,e.jsxs)("div",{style:{display:"contents"},children:[(0,e.jsx)("dt",{style:{...B,whiteSpace:"nowrap"},children:s[n.key]??n.label}),(0,e.jsxs)("dd",{style:{margin:0,minWidth:0},children:[n.linked?(0,e.jsx)(pe,{relation:n.linked.relation,refs:n.linked.refs,nodeId:o.id,field:n.key}):n.app?(0,e.jsx)(ye,{address:n.app,as:"record",nodeId:o.id,field:n.key}):n.href?(0,e.jsx)(be,{href:n.href,field:n.key,value:n.value,stored:n.stored,nodeId:o.id}):(0,e.jsx)(K,{nodeId:o.id,field:n.key,value:n.value,stored:n.stored}),n.repeats?(0,e.jsx)(ue,{nodeId:o.id,field:n.key,start:o[n.key],value:o[`${n.key}Repeat`],label:`${s[n.key]??n.label} repeats`}):null]})]},n.key))});if(!u.title)return(0,e.jsx)("div",{children:v},g);let k=`graview-field-group-${o.id}-${g}`;return(0,e.jsxs)("div",{role:"group","aria-labelledby":k,style:{display:"grid",gap:6,minWidth:0},children:[(0,e.jsx)("p",{id:k,"data-graview-field-group":u.title,style:ke,children:u.title}),v]},g)}),I?(0,e.jsx)(_,{as:"unfilled",nodeId:o.id,skip:a,labels:s,labelStyle:B}):null]})}var B={color:"var(--graview-ink-faint)",fontSize:"0.8125rem"},ke={margin:0,fontSize:"0.75rem",letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--graview-ink-muted)",fontWeight:560};function we(i){return Y()?(0,e.jsx)(xe,{...i}):(0,e.jsx)(Se,{...i})}function Se({field:i,label:a,value:l,labelStyle:s,valueStyle:c,style:m,markdown:o}){return(0,e.jsxs)("div",{"data-graview-long":i,style:{display:"grid",gap:6,minWidth:0,...m},children:[(0,e.jsx)("dt",{style:s,children:a}),(0,e.jsx)("dd",{style:{margin:0,minWidth:0,...c},children:(0,e.jsx)("div",{"data-graview-field":i,children:(0,e.jsx)(G,{text:l,markdown:o})})})]})}function xe({nodeId:i,field:a,label:l,value:s,labelStyle:c,valueStyle:m,style:o,markdown:t}){let{fields:y,commit:I}=P(i),u=y.find(f=>f.field===a&&f.takesValue),[g,v]=(0,p.useState)(!1),k=(0,p.useRef)(null),n=(0,p.useRef)(!1);(0,p.useEffect)(()=>{!g&&n.current&&(n.current=!1,k.current?.focus())},[g]);let w=f=>{n.current=f,v(!1)},E=l.toLowerCase(),d=(0,e.jsx)(G,{text:s,markdown:t});return(0,e.jsxs)("div",{"data-graview-long":a,style:{display:"grid",gap:6,minWidth:0,...o},children:[(0,e.jsxs)("dt",{style:{display:"flex",alignItems:"baseline",gap:10,...c},children:[(0,e.jsx)("span",{children:l}),u&&!g?(0,e.jsx)("button",{ref:k,type:"button","data-graview-editable":u.mutation,"aria-label":`Edit the ${E}`,title:`${u.title} \u2014 changes the ${E}, and can be undone`,onClick:()=>v(!0),style:Ee,children:"Edit"}):null]}),(0,e.jsx)("dd",{style:{margin:0,minWidth:0,...m},children:g&&u?(0,e.jsx)(p.Suspense,{fallback:d,children:(0,e.jsx)(Ie,{field:a,label:l,value:s,...t?{markdown:!0}:{},onCancel:()=>w(!0),onSave:(f,b)=>{w(!b),f!==s&&I(u,f)}})}):(0,e.jsx)("div",{"data-graview-field":a,...u?{}:{"data-graview-readonly":"",title:`Read-only \u2014 nothing this app declares changes the ${E}`},...u?{onClick:()=>v(!0)}:{},style:{cursor:u?"text":"default",minWidth:0},children:d})})]})}var Ie=(0,p.lazy)(()=>(__graviewPreload(import.meta.url,["./chunk.7N2GXZYI.js","./chunk.O4WEJ47H.js","./chunk.Y4ZUJUUT.js","./chunk.SDO3U72B.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.F67F6QZ6.js"))),Ee={all:"unset",cursor:"pointer",fontSize:"0.75rem",letterSpacing:"normal",textTransform:"none",color:"var(--graview-accent)",borderBottom:"1px dashed currentColor",minHeight:24,minWidth:24,display:"inline-flex",alignItems:"flex-end"};function Oe({nodeId:i,children:a}){let{fields:l}=P(i),s=U(i);if(!s)return(0,e.jsx)(e.Fragment,{children:a});let c=l.find(m=>{let o=s[m.field];return typeof o=="string"&&o===a});return c?(0,e.jsx)(K,{nodeId:i,field:c.field,value:a,said:a}):(0,e.jsx)(e.Fragment,{children:a})}export{ye as a,K as b,be as c,De as d,we as e,Oe as f};
|
|
1
|
+
var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as _,b as pe,e as ue,f as me,g as ce}from"./chunk.SAHNXAV3.js";import{b as G}from"./chunk.DHAK6PPX.js";import{c as de}from"./chunk.TPG6IY4M.js";import{n as P}from"./chunk.RQBEQYB2.js";import{b as x,c as ie,d as oe,j as se,k as le}from"./chunk.N4M54YK6.js";import{d as ae,e as re}from"./chunk.KVJFY7N5.js";import{b as te,f as ne}from"./chunk.DPHTUTOS.js";import{$ as Y,Ca as Z,Da as ee,G as he,R as X,_ as O,ba as U}from"./chunk.KA44WNB4.js";import{a as Q}from"./chunk.SDO3U72B.js";import{fa as W,ka as J}from"./chunk.4TJOS4C7.js";import{b as D}from"./chunk.AJZBJBMO.js";var p=D(he(),1);var ve=ee(Q(()=>(__graviewPreload(import.meta.url,["./chunk.4VW6THJF.js","./chunk.SAHNXAV3.js","./chunk.DHAK6PPX.js","./chunk.WVUJXDXZ.js","./chunk.TPG6IY4M.js","./chunk.NFDLCUCC.js","./chunk.X7JMJSLU.js","./chunk.PPRSGM64.js","./chunk.5Y3Q7ONN.js","./chunk.KTFUVR4V.js","./chunk.GZHZLJBF.js","./chunk.RQBEQYB2.js","./chunk.OJGHDWI6.js","./chunk.6VAFNCR4.js","./chunk.N4M54YK6.js","./chunk.KVJFY7N5.js","./chunk.DPHTUTOS.js","./chunk.2UIUMG23.js","./chunk.KA44WNB4.js","./chunk.SDO3U72B.js","./chunk.4TJOS4C7.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.EZJNUFNQ.js")))),ye=ve.part((i,a)=>i.drawAppLink(a),{quiet:!0});var e=D(X(),1);function K({nodeId:i,field:a,value:l,stored:s=l,said:c}){let{fields:m,commit:o}=P(i),t=m.find(r=>r.field===a),{store:y,principal:I}=O(),u=y.graph.getNode(i)?.kind,g=y.schema.definitions.find(r=>r.kind===u),v=J(g,a),k=v.toLowerCase(),n=c??`${v.charAt(0).toUpperCase()}${v.slice(1)}: ${l}`,[w,E]=(0,p.useState)(!1),d=t?.shape.type==="number"?t.shape.amount:void 0,f=d&&s!==""&&Number.isFinite(Number(s))?ie(Number(s),d):s,[b,M]=(0,p.useState)(f),C=(0,p.useRef)(null),j=(0,p.useRef)(null),z=(0,p.useRef)(!1),S=r=>{z.current=r,E(!1)};(0,p.useEffect)(()=>M(f),[f,w]);let q=t?.shape.type==="date";if((0,p.useEffect)(()=>{if(q)return Z(()=>void ce())},[q]),(0,p.useEffect)(()=>{w?C.current?.focus():z.current&&(z.current=!1,j.current?.focus())},[w]),!t)return(0,e.jsx)("span",{"data-graview-field":a,"data-graview-readonly":"",title:`Read-only \u2014 nothing this app declares changes the ${k}`,style:{color:"var(--graview-ink)",cursor:"default",overflowWrap:"anywhere"},children:l});if(!w)return(0,e.jsx)("button",{ref:j,type:"button","data-graview-field":a,"data-graview-editable":t.mutation,...n===l?{}:{"aria-label":n},title:`${t.title} \u2014 changes the ${k}, and can be undone`,onClick:()=>E(!0),style:{all:"unset",cursor:"text",display:"inline-flex",alignItems:"flex-end",minHeight:24,minWidth:24,maxWidth:"100%",overflowWrap:"anywhere",paddingBottom:1,borderBottom:"1px dashed var(--graview-edge-bright)",color:"var(--graview-ink)"},children:l});let R=(r,{left:h=!1}={})=>{S(!h),!(r===s||r===""||r===void 0)&&(t.shape.type==="date"&&typeof r=="string"&&fe(r)||o(t,r))},fe=r=>{if(t.shape.type!=="date")return!1;let h=m.filter(L=>L.shape.type==="date"&&L.takesValue),T=le(h.map(L=>L.field),g?.fieldRoles??{}),A=T?.start===a?h.find(L=>L.field===T.end):void 0,F=y.graph.getNode(i)?.[T?.end??""];if(!A||typeof F!="string")return!1;let N=se(s===""?void 0:s,r,F,{time:t.shape.time===!0,instant:t.shape.instant===!0});if(N===void 0||N===F)return!1;let $=t.call(r),V=A.call(N);return y.applyAll($.name===V.name?[{name:$.name,args:{...$.args,...V.args}}]:[$,V],{author:I}),!0};if(!t.takesValue){let r=[t,...t.alternatives];return(0,e.jsx)("span",{role:"group","aria-label":`Change ${W(a).toLowerCase()}`,"data-graview-field":a,style:{display:"inline-flex",gap:6,alignItems:"center",flexWrap:"wrap"},onKeyDown:h=>{h.key==="Escape"&&S(!0)},children:r.map((h,T)=>(0,e.jsx)("button",{type:"button",ref:T===0?C:void 0,"data-graview-act":h.mutation,onClick:()=>{S(!0),o(h,void 0)},onBlur:A=>{let H=A.relatedTarget;(!H||!A.currentTarget.parentElement?.contains(H))&&S(!1)},style:{padding:"2px 9px",fontSize:"0.8125rem",borderRadius:999},children:h.title},h.mutation))})}return(0,e.jsxs)("form",{style:{display:"inline-flex",flexWrap:"wrap",gap:4,maxWidth:"100%"},onSubmit:r=>{r.preventDefault(),R(ge(t,b))},children:[t.shape.type==="choice"?(0,e.jsx)("select",{ref:C,"aria-label":W(a),"data-graview-field":a,value:b,onChange:r=>R(r.target.value),onBlur:()=>S(!1),style:{font:"inherit",fontSize:"inherit"},children:t.shape.options.map(r=>(0,e.jsx)("option",{value:r,children:te(g,a,r)},r))}):t.shape.type==="date"?(0,e.jsx)(me,{inputRef:C,label:W(a),value:b===""?void 0:b,time:t.shape.time===!0,instant:t.shape.instant===!0,onChange:r=>M(r??""),onLeave:r=>R(r,{left:!0}),onCancel:()=>S(!0),autoSelect:!0,boxStyle:{fontSize:"inherit",minHeight:24,padding:"0 3px"}}):(0,e.jsxs)(e.Fragment,{children:[d&&x(d).prefix?(0,e.jsx)("span",{"aria-hidden":"true",children:x(d).prefix}):null,(0,e.jsx)("input",{ref:C,"aria-label":d?`${W(a)}, ${x(d).hint}`:W(a),"data-graview-field":a,...d?{inputMode:"decimal",placeholder:x(d).placeholder,"data-graview-amount":d.format??"unit"}:{},type:d?"text":t.shape.type==="number"&&!t.shape.duration?"number":"text",...t.shape.type==="number"&&t.shape.duration?{placeholder:"1h 30m"}:{},...t.shape.type==="text"&&t.shape.holds==="phone"?{inputMode:"tel",autoComplete:"tel"}:{},...t.shape.type==="number"&&t.shape.min!==void 0&&!d?{min:t.shape.min}:{},...t.shape.type==="number"&&t.shape.max!==void 0&&!d?{max:t.shape.max}:{},...t.shape.type==="number"&&t.shape.step!==void 0&&!d?{step:t.shape.step}:{},value:b,onChange:r=>M(r.target.value),onBlur:()=>R(ge(t,b),{left:!0}),onKeyDown:r=>{r.key==="Escape"&&S(!0)},style:{font:"inherit",fontSize:"inherit",width:`min(${Math.max(6,b.length+1)}ch, 100%)`,maxWidth:"100%",minWidth:0,boxSizing:"border-box",minHeight:24,display:"inline-flex",alignItems:"center",padding:"0 3px"}}),d&&x(d).suffix?(0,e.jsx)("span",{"aria-hidden":"true",children:x(d).suffix}):null]}),t.open.length>0?(0,e.jsxs)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:["also needs ",t.open.map(r=>r.name).join(", ")]}):null]})}function ge(i,a){return i.shape.type==="number"&&i.shape.amount?oe(a,i.shape.amount):i.shape.type==="number"?i.shape.duration?ne(a)??a:Number(a):i.shape.type==="text"&&i.shape.holds?a.trim():a}function be({href:i,field:a,value:l,stored:s,nodeId:c}){let m=i.startsWith("tel:"),o=(t,y)=>(0,e.jsx)("a",{href:i,"data-graview-link":a,...y?{"aria-label":y}:{},...m?{}:{target:"_blank",rel:"noopener noreferrer"},style:{display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24,maxWidth:"100%",overflowWrap:"anywhere",color:"var(--graview-accent)"},children:t});return c===void 0?o(l):(0,e.jsxs)("span",{style:{display:"inline-flex",flexWrap:"wrap",alignItems:"center",gap:"0 10px",maxWidth:"100%"},children:[(0,e.jsx)(K,{nodeId:c,field:a,value:l,...s===void 0?{}:{stored:s}}),o(m?"Call":"Map",m?`Call ${l}`:`Open ${l} in maps`)]})}function De({id:i,hide:a=[],limit:l=10,labels:s={},shown:c=[]}){let{store:m}=O(),o=U(i);if(!o)return null;let t=m.schema.tryDefinition(o.kind),y=ae(o,t,{limit:l,said:c}).filter(u=>!a.includes(u.key)),I=de(t).length>0;return y.length===0&&!I?null:(0,e.jsxs)("div",{"data-graview-fields":o.id,style:{display:"grid",gap:14,alignContent:"start",minWidth:0,fontSize:"0.875rem"},children:[re(t,y).map((u,g)=>{let v=(0,e.jsx)("dl",{style:{margin:0,display:"grid",gridTemplateColumns:"auto 1fr",gap:"5px 16px",alignContent:"start",minWidth:0},children:u.fields.map(n=>n.files?(0,e.jsx)(_,{as:"field",nodeId:o.id,field:n.key,label:s[n.key]??n.label,files:n.files,labelStyle:B,style:{marginTop:6}},n.key):n.long?(0,e.jsx)(we,{nodeId:o.id,field:n.key,label:s[n.key]??n.label,value:n.value,markdown:n.markdown,labelStyle:B,style:{gridColumn:"1 / -1",marginTop:6}},n.key):(0,e.jsxs)("div",{style:{display:"contents"},children:[(0,e.jsx)("dt",{style:{...B,whiteSpace:"nowrap"},children:s[n.key]??n.label}),(0,e.jsxs)("dd",{style:{margin:0,minWidth:0},children:[n.linked?(0,e.jsx)(pe,{relation:n.linked.relation,refs:n.linked.refs,nodeId:o.id,field:n.key}):n.app?(0,e.jsx)(ye,{address:n.app,as:"record",nodeId:o.id,field:n.key}):n.href?(0,e.jsx)(be,{href:n.href,field:n.key,value:n.value,stored:n.stored,nodeId:o.id}):(0,e.jsx)(K,{nodeId:o.id,field:n.key,value:n.value,stored:n.stored}),n.repeats?(0,e.jsx)(ue,{nodeId:o.id,field:n.key,start:o[n.key],value:o[`${n.key}Repeat`],label:`${s[n.key]??n.label} repeats`}):null]})]},n.key))});if(!u.title)return(0,e.jsx)("div",{children:v},g);let k=`graview-field-group-${o.id}-${g}`;return(0,e.jsxs)("div",{role:"group","aria-labelledby":k,style:{display:"grid",gap:6,minWidth:0},children:[(0,e.jsx)("p",{id:k,"data-graview-field-group":u.title,style:ke,children:u.title}),v]},g)}),I?(0,e.jsx)(_,{as:"unfilled",nodeId:o.id,skip:a,labels:s,labelStyle:B}):null]})}var B={color:"var(--graview-ink-faint)",fontSize:"0.8125rem"},ke={margin:0,fontSize:"0.75rem",letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--graview-ink-muted)",fontWeight:560};function we(i){return Y()?(0,e.jsx)(xe,{...i}):(0,e.jsx)(Se,{...i})}function Se({field:i,label:a,value:l,labelStyle:s,valueStyle:c,style:m,markdown:o}){return(0,e.jsxs)("div",{"data-graview-long":i,style:{display:"grid",gap:6,minWidth:0,...m},children:[(0,e.jsx)("dt",{style:s,children:a}),(0,e.jsx)("dd",{style:{margin:0,minWidth:0,...c},children:(0,e.jsx)("div",{"data-graview-field":i,children:(0,e.jsx)(G,{text:l,markdown:o})})})]})}function xe({nodeId:i,field:a,label:l,value:s,labelStyle:c,valueStyle:m,style:o,markdown:t}){let{fields:y,commit:I}=P(i),u=y.find(f=>f.field===a&&f.takesValue),[g,v]=(0,p.useState)(!1),k=(0,p.useRef)(null),n=(0,p.useRef)(!1);(0,p.useEffect)(()=>{!g&&n.current&&(n.current=!1,k.current?.focus())},[g]);let w=f=>{n.current=f,v(!1)},E=l.toLowerCase(),d=(0,e.jsx)(G,{text:s,markdown:t});return(0,e.jsxs)("div",{"data-graview-long":a,style:{display:"grid",gap:6,minWidth:0,...o},children:[(0,e.jsxs)("dt",{style:{display:"flex",alignItems:"baseline",gap:10,...c},children:[(0,e.jsx)("span",{children:l}),u&&!g?(0,e.jsx)("button",{ref:k,type:"button","data-graview-editable":u.mutation,"aria-label":`Edit the ${E}`,title:`${u.title} \u2014 changes the ${E}, and can be undone`,onClick:()=>v(!0),style:Ee,children:"Edit"}):null]}),(0,e.jsx)("dd",{style:{margin:0,minWidth:0,...m},children:g&&u?(0,e.jsx)(p.Suspense,{fallback:d,children:(0,e.jsx)(Ie,{field:a,label:l,value:s,...t?{markdown:!0}:{},onCancel:()=>w(!0),onSave:(f,b)=>{w(!b),f!==s&&I(u,f)}})}):(0,e.jsx)("div",{"data-graview-field":a,...u?{}:{"data-graview-readonly":"",title:`Read-only \u2014 nothing this app declares changes the ${E}`},...u?{onClick:()=>v(!0)}:{},style:{cursor:u?"text":"default",minWidth:0},children:d})})]})}var Ie=(0,p.lazy)(()=>(__graviewPreload(import.meta.url,["./chunk.DHAK6PPX.js","./chunk.2UIUMG23.js","./chunk.KA44WNB4.js","./chunk.SDO3U72B.js","./chunk.4TJOS4C7.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.KW65F4WA.js"))),Ee={all:"unset",cursor:"pointer",fontSize:"0.75rem",letterSpacing:"normal",textTransform:"none",color:"var(--graview-accent)",borderBottom:"1px dashed currentColor",minHeight:24,minWidth:24,display:"inline-flex",alignItems:"flex-end"};function Oe({nodeId:i,children:a}){let{fields:l}=P(i),s=U(i);if(!s)return(0,e.jsx)(e.Fragment,{children:a});let c=l.find(m=>{let o=s[m.field];return typeof o=="string"&&o===a});return c?(0,e.jsx)(K,{nodeId:i,field:c.field,value:a,said:a}):(0,e.jsx)(e.Fragment,{children:a})}export{ye as a,K as b,be as c,De as d,we as e,Oe as f};
|