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
package/dist/preview/page.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as Mt,b as Gn,c as Un,d as Kn,e as Jn,f as Vt,g as Yn,h as Dt}from"./chunk.WHEUTAXA.js";import{a as zr}from"./chunk.ZQY6ODXC.js";import{a as Ht,b as Zn,c as Xn,d as er,e as Bt,f as tr,g as nr,h as rr,i as or,j as ar,k as ir,l as sr,m as dr,n as _e}from"./chunk.FOJDVK2Q.js";import{b as Qn}from"./chunk.C44MC5X3.js";import{a as kt}from"./chunk.Q5WEOX3Q.js";import{a as Et,g as bn}from"./chunk.6YD2DLIC.js";import{k as tt}from"./chunk.KWQ7QOHD.js";import{C as _n,H as jn,L as qn,M as zn,j as qr,k as Wn,n as ot,o as Nn,q as $n,u as In,z as at}from"./chunk.O4WEJ47H.js";import{Aa as Vn,Ca as Dn,Da as Lt,G as Ct,Ha as Hn,Ia as Bn,La as rt,R as kn,W as En,a as Sn,b as Ft,c as nt,da as An,ea as Rn,j as Pn,m as Ot,sa as Tn,ta as xn,ua as Fn,va as On,wa as Cn,xa as Ln,za as Mn}from"./chunk.Y4ZUJUUT.js";import{a as be}from"./chunk.SDO3U72B.js";import{Mc as mn,Oc as hn,Pc as yn,Rc as et,Ub as At,Vb as fn,ib as Ie,jb as Xe,ld as ve,md as gn,nd as wn,sd as Rt,td as Tt,vb as un,wd as vn,xd as xt,yc as pn}from"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import{b as Fe}from"./chunk.AJZBJBMO.js";async function it(e,n={}){let o=e.compiled===void 0||!Ur(e.compiled,e.document)?void 0:bn(e.compiled,n);if(o?.ok)return o;let{compileDocumentWithoutCheck:a}=await Gr();return a(e.document,n)}var cr,Gr=()=>cr??=(__graviewPreload(import.meta.url,["./chunk.4OGOTHRD.js","./chunk.6YD2DLIC.js","./chunk.IKX4VDTW.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.AYA7SYIU.js")).catch(e=>{throw cr=void 0,e});function Ur(e,n){let o=typeof e=="object"&&e!==null?e.document:void 0,a=n;if(typeof a=="string")try{a=JSON.parse(a)}catch{return!1}return o!==void 0&&kt(Et(o).document)===kt(Et(a).document)}var c=Fe(Ct(),1);var dt=Fe(Ct(),1),Wt="data-graview-drawn",Kr=200,lr=50,Jr=1e4,st=()=>typeof performance<"u"?performance.now():Date.now();function Yr(e){let n=[...e.querySelectorAll("img")];for(let o of e.querySelectorAll("[data-worker-view]"))o.shadowRoot&&n.push(...o.shadowRoot.querySelectorAll("img"));return n}function Qr(e,n){if(e.ownerDocument.fonts?.status==="loading"||xn()>0||Ln(n)>0||e.querySelector('[aria-busy="true"]')||Yr(e).some(a=>!a.complete&&a.loading!=="lazy"))return!1;for(let a of e.querySelectorAll("[data-worker-view-place]"))if(!a.querySelector("[data-worker-view][data-worker-view-drawn], [data-worker-view][data-worker-view-failed]"))return!1;return!0}function ur(e){let n=e.querySelector("[data-embed-content]"),o=[...e.querySelectorAll("[data-worker-view]")].map(a=>`${a.offsetWidth}x${a.offsetHeight}`);return`${e.scrollWidth}x${e.scrollHeight}|${n?`${n.scrollWidth}x${n.scrollHeight}`:""}|${o.join(",")}`}function Zr(e,n,o,a){e.removeAttribute(Wt);let d=e.ownerDocument.defaultView;if(!d)return()=>{};let l=st(),b=l,p=ur(e),g=!1,A,T=typeof MutationObserver>"u"?void 0:new MutationObserver(S=>{S.some(N=>!(N.target===e&&N.attributeName===Wt))&&(b=st())});T?.observe(e,{childList:!0,subtree:!0,characterData:!0,attributes:!0});let v=()=>{g=!0,T?.disconnect(),A!==void 0&&clearTimeout(A)},P=S=>{let N=!1,ne=()=>{N||(N=!0,S())};typeof d.requestAnimationFrame=="function"&&d.requestAnimationFrame(()=>setTimeout(ne,0)),setTimeout(ne,100)},C=()=>{if(g)return;let S=ur(e);S!==p&&(p=S,b=st());let N=st();if(Qr(e,a)&&N-b>=Kr||N-l>=Jr){P(()=>{g||(v(),e.setAttribute(Wt,n),Vn(),o())});return}A=setTimeout(C,lr)};return A=setTimeout(C,lr),v}function fr(e,n,o,a,d){Mn();let l=(0,dt.useRef)({place:o,onDrawn:a});l.current={place:o,onDrawn:a},(0,dt.useLayoutEffect)(()=>{d&&Cn(d);let b=A=>Zr(A,l.current.place.path,()=>l.current.onDrawn?.(l.current.place),d);if(e.current)return b(e.current);let p,g=!1;return queueMicrotask(()=>{!g&&e.current&&(p=b(e.current))}),()=>{g=!0,p?.()}},[n,e,d])}var ye=Fe(Ct(),1),je,Xr=be(()=>(__graviewPreload(import.meta.url,["./chunk.IXOQQBJE.js","./chunk.ETR6AV47.js","./chunk.7ELB37JU.js","./chunk.F2VMMCVK.js","./chunk.NFIGGSMJ.js","./chunk.Y4ZUJUUT.js","./chunk.SDO3U72B.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.5M4TMZXC.js"))),pr=()=>Xr().then(e=>void(je=e),()=>new Promise(e=>setTimeout(e,2e3)).then(pr)),Nt=Tn(pr),mr=e=>!!e&&je===void 0;function $t({onReady:e,fetch:n}){return(0,ye.useLayoutEffect)(()=>void n().then(e),[e,n]),null}var eo=0;function hr(e){let[n,o]=(0,ye.useState)(()=>je);(0,ye.useEffect)(()=>{if(!e||n)return;let l=!1;return Nt().then(()=>{l||o(je)}),()=>{l=!0}},[e,n]);let a=(0,ye.useMemo)(()=>eo+=1,[e]);return{over:(0,ye.useMemo)(()=>{let l=n??je;if(!e||!l)return;let{source:b,worker:p,...g}=e,A={...g,worker:p??{source:b},draft:!0};return{name:e.manifest.name,home:e.manifest.attach==="home",register:T=>l.registerWorkerView(T,A)}},[e,n]),n:a}}var wr=Fe(zr(),1),j=Fe(qr(),1);var h=Fe(kn(),1);function ct(e,n={}){let o=Lt(e);return{Face:o.part((d,l)=>(0,c.createElement)(d,l),n),fetch:()=>o.load().then(()=>{}),here:()=>o.current!==void 0||o.failed}}var jt=e=>Promise.all([e,qn()]).then(([n])=>n),vr=be(()=>(__graviewPreload(import.meta.url,["./chunk.IYIN6VSN.js","./chunk.VC3UGFHY.js","./chunk.IJNOT4S4.js","./chunk.AGIO2GRV.js","./chunk.VSNHCGKC.js","./chunk.HJCQ6I3S.js","./chunk.BNPQUI3F.js","./chunk.6RY6OSE6.js","./chunk.CTQULC5F.js","./chunk.TCXKPILZ.js","./chunk.64WM4IBI.js","./chunk.IQ2HKGJS.js","./chunk.R6V37SR7.js","./chunk.IROYMLER.js","./chunk.7NNI7YH4.js","./chunk.PKUDIWIF.js","./chunk.VW2VCPJX.js","./chunk.WBHM5I3I.js","./chunk.FOQ27RAR.js","./chunk.UKAPFIPJ.js","./chunk.UT6642FC.js","./chunk.FOJDVK2Q.js","./chunk.C44MC5X3.js","./chunk.TI4OSTQV.js","./chunk.Q7RQC3F7.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.TJEV5ZAM.js"))),to=be(()=>(__graviewPreload(import.meta.url,["./chunk.T7RJCEJB.js","./chunk.76GF5US2.js","./chunk.ETPKXUAN.js","./chunk.IPAZOKMQ.js","./chunk.V7XHNRQM.js","./chunk.UGFDSE37.js","./chunk.IYIN6VSN.js","./chunk.GCKZ2YRJ.js","./chunk.VC3UGFHY.js","./chunk.YHH4TWZ2.js","./chunk.O2WWYZI7.js","./chunk.AGIO2GRV.js","./chunk.VSNHCGKC.js","./chunk.PXQVXBNG.js","./chunk.EUPSAYEI.js","./chunk.TCXKPILZ.js","./chunk.R6V37SR7.js","./chunk.SWWAEOZ7.js","./chunk.IROYMLER.js","./chunk.FWSCBHZ5.js","./chunk.7NNI7YH4.js","./chunk.7N2GXZYI.js","./chunk.MF73YBJL.js","./chunk.63MS2LOP.js","./chunk.PKUDIWIF.js","./chunk.VW2VCPJX.js","./chunk.UKAPFIPJ.js","./chunk.UT6642FC.js","./chunk.IW7YFPGG.js","./chunk.MB7LKKUD.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.MCCUVGTE.js"))),no=be(()=>(__graviewPreload(import.meta.url,["./chunk.T7RJCEJB.js","./chunk.76GF5US2.js","./chunk.ETPKXUAN.js","./chunk.IPAZOKMQ.js","./chunk.V7XHNRQM.js","./chunk.UGFDSE37.js","./chunk.IYIN6VSN.js","./chunk.GCKZ2YRJ.js","./chunk.VC3UGFHY.js","./chunk.YHH4TWZ2.js","./chunk.O2WWYZI7.js","./chunk.AGIO2GRV.js","./chunk.VSNHCGKC.js","./chunk.PXQVXBNG.js","./chunk.EUPSAYEI.js","./chunk.TCXKPILZ.js","./chunk.R6V37SR7.js","./chunk.SWWAEOZ7.js","./chunk.IROYMLER.js","./chunk.FWSCBHZ5.js","./chunk.7NNI7YH4.js","./chunk.7N2GXZYI.js","./chunk.MF73YBJL.js","./chunk.63MS2LOP.js","./chunk.PKUDIWIF.js","./chunk.VW2VCPJX.js","./chunk.UKAPFIPJ.js","./chunk.UT6642FC.js","./chunk.IW7YFPGG.js","./chunk.MB7LKKUD.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.JUWWRRHA.js"))),br=ct(()=>jt(vr().then(e=>e.SceneFace)),{what:"This view"}),Sr=ct(()=>vr().then(e=>e.SceneKeeping),{quiet:!0}),Pr=ct(()=>jt(to().then(e=>e.PagesContent)),{what:"This page"}),kr=ct(()=>jt(no().then(e=>e.PictureFace)),{what:"This picture"}),ro=br.Face,oo=Sr.Face,ao=Pr.Face,io=kr.Face;function Oe(...e){let n=e.length>0?e:["scene","pages","picture"],o=new Set(n.flatMap(Er));return Promise.all([...[...o].map(a=>a.fetch()),$n()]).then(()=>{},()=>{})}var Er=e=>e==="pages"?[Pr]:e==="picture"?[kr]:[br,Sr],Ar=e=>Er(e).every(n=>n.here()),so=150,It=0;function yr(e,n){if(Ar(e))return n();let o=++It,a=()=>{o===It&&(It+=1,n())};Oe(e).then(a),setTimeout(a,so)}var co=768;function lo(e,n){let o=n!==null&&n>=co;(0,c.useEffect)(()=>{if(!o||e==="picture")return;let a=e==="pages"?"scene":"pages";if(Ar(a))return;let d=globalThis,l=()=>void Oe(a),b=()=>{},p=Dn(()=>{if(d.requestIdleCallback&&d.cancelIdleCallback){let g=d.requestIdleCallback(l,{timeout:4e3});b=()=>d.cancelIdleCallback?.(g)}else{let g=setTimeout(l,1500);b=()=>clearTimeout(g)}});return()=>(p(),b())},[e,o])}function uo({asked:e,shown:n,onDrawn:o}){return(0,c.useLayoutEffect)(()=>o(e,n),[e,n,o]),null}function fo({auto:e,scene:n}){return(0,h.jsx)("div",{"data-embed-content":"","aria-busy":"true",style:{flex:e?n?`0 0 ${Bt}px`:"0 0 auto":"1 1 auto",minHeight:0,background:"var(--graview-ground)"}})}var po=Lt(be(()=>(__graviewPreload(import.meta.url,["./chunk.AJZBJBMO.js"]),import("./chunk.5JNXQHN4.js")))).part((e,n)=>(0,h.jsx)(e.StudioPlace,{...n}),{quiet:!0});function Rr(e,n,o,a,d){return Vt(e,Jn(n?nt(n):d??Sn,a),o)}function qt(e){return e&&nt(e).overview?"graview":"scene"}function gr(e,n){if(n.homeView?.()===void 0)return!1;let o=e.pages?.first?.trim();return o===void 0||o===""||o==="/"||o.toLowerCase()==="home"}function Tr(e){let[,n]=(0,c.useState)(!1),o=(0,c.useCallback)(()=>n(!0),[]),a=(0,c.useRef)(!1);return e.at&&!lt?(0,h.jsx)($t,{onReady:o,fetch:zt}):!a.current&&mr(e.draftView)?(0,h.jsx)($t,{onReady:o,fetch:Nt}):(a.current=!0,(0,h.jsx)(mo,{...e}))}function mo(e){let{app:n,stop:o,bar:a=!0,standing:d="Everything is in order",principal:l,heading:b=2}=e,{rootRef:p,scope:g,css:A,scheme:T,store:v,presence:P,brand:C,auto:S,height:N}=tr(e),ne=hr(e.draftView),V=Xn(e,zn,ne.over),[Z]=(0,c.useState)(On),u=e.basePath===void 0?{}:{basePath:e.basePath},[D]=(0,c.useState)(ot),q=e.notices??D,K=m=>Rt(m,u),x={...e.routing?{routing:e.routing}:{},...u},[de]=(0,c.useState)(()=>{let m=e.at?.face;if(m)return m;let F=o===void 0&&gr(n,V)?"pages":qt(o),me=Mt({...x,face:F});return e.face===void 0&&e.onOpening?.(me),me}),[$,O]=(0,c.useState)(()=>e.face!==void 0&&e.face!=="pages"&&!e.at&&o===void 0&&Gn(x)&&gr(n,V)),Pe=(0,c.useRef)(e.onFace);Pe.current=e.onFace,(0,c.useLayoutEffect)(()=>{$&&(Pe.current?.("pages"),O(!1))},[$]);let k=$?"pages":e.face??de,te=n.schema.kinds,R=e.routing==="address",J=(0,c.useMemo)(()=>e.at?lt.settleAt(e,v.seenBy(l??{kind:"human"}),V.places()):void 0,[]),B=(0,c.useMemo)(()=>Rn(V,n.schema),[V,n.schema]),ce=(0,c.useMemo)(()=>{let m=J?.stop??(R?Un(e.basePath):void 0)??o;return k==="scene"&&m===void 0&&B===void 0&&(e.path===void 0||_t(e.path))?Dt(void 0):Rr(k,m,te,V.places(),B)},[]),[we]=(0,c.useState)(k);(0,c.useEffect)(()=>{we!=="pages"&&An(V)},[we,V]);let W=(0,c.useRef)(void 0),z=m=>m===void 0||_t(m)?"/":m;W.current??={path:z(J?.path??(R?k==="pages"?(Tt(window.location.pathname,e.basePath)??"/")+window.location.search:"/":e.path)),asked:e.path},e.path!==W.current.asked&&(W.current={path:z(e.path),asked:e.path});let I=(0,c.useRef)(e.onNavigate);I.current=e.onNavigate;let le=(0,c.useCallback)((m,F)=>{W.current.path=m,I.current?.(m,F)},[]),{at:L,setAt:ke,steering:Y,steer:X}=ir(W.current.path),M=(0,c.useContext)(xr);M&&(M.pages=()=>W.current.path);let Ee=(0,c.useRef)(void 0),ue=(0,c.useCallback)(m=>void(W.current.path=m),[]),re=Wn(p),[Q,ze]=(0,c.useState)(!1),Ae=e.pagesBelow!==void 0&&re!==null&&re<e.pagesBelow&&(k==="scene"||k==="graview")&&!Q,E=Ae?"pages":k,Re=(0,c.useRef)(!1);Re.current=Q&&e.pagesBelow!==void 0&&re!==null&&re<e.pagesBelow&&(k==="scene"||k==="graview"),M&&(M.shown=E);let fe=(0,c.useRef)(k==="graview"?"graview":"scene");(E==="scene"||E==="graview")&&(fe.current=E),(0,c.useState)(()=>{if(!R||typeof window>"u"||E==="pages"||E==="picture")return;let{pathname:m,search:F,hash:me}=window.location;Tt(m,e.basePath)==="/"&&window.history.replaceState(window.history.state,"",`${K(ve)}${F}${me}`)}),er(p,E,e.onIntrinsicHeight),lo(E,re);let oe=sr(e.onError,E),He=dr(e.onReady,E),Te=(0,c.useRef)(e.onFaceDrawn);Te.current=e.onFaceDrawn;let pt=(0,c.useCallback)((m,F)=>{He(F),Te.current?.(m)},[He]),[mt,ht]=(0,c.useState)(null),G=V.places(),ee=(0,c.useRef)({shown:E,onFace:e.onFace});ee.current={shown:E,onFace:e.onFace};let U=(0,c.useCallback)((m,F,me)=>{if(R){Ee.current?.(m,F,me);return}ee.current.onFace?.(m),I.current?.(m==="pages"?F??W.current.path:ve,"push")},[R]),[Be,pe]=(0,c.useState)(void 0);(0,c.useEffect)(()=>{E==="pages"&&pe(void 0)},[E]);let Ge=(0,c.useRef)(o);(0,c.useEffect)(()=>{Ge.current!==o&&(Ge.current=o,pe(void 0))},[o]);let We=(0,c.useCallback)(m=>{if(ee.current.shown==="pages"){if(ze(!0),pe(m),k==="scene"||k==="graview"){yr(k,()=>{R?window.history.pushState(null,"",`${K(ve)}${m??""}`):I.current?.(ve,"push")});return}yr(fe.current,()=>U(fe.current,void 0,m))}},[R,k,e.basePath,U]),ae=(0,c.useCallback)(m=>{if(ee.current.shown==="pages"){Y.go.current||(W.current.path=m),X(m);return}if(W.current.path=m,ke(m),Re.current){ze(!1),R?window.history.pushState(null,"",K(m)):I.current?.(m,"push");return}U("pages",m)},[Y,X,ke,U,R,e.basePath]),Le=V.arrangement?.(),xe=E==="pages",_=e.hrefOf,ie=_??(R?K:void 0),Ue=(0,c.useMemo)(()=>({open:ae,..._?{href:_}:R?{href:m=>Rt(m,e.basePath===void 0?{}:{basePath:e.basePath})}:{}}),[ae,R,e.basePath,_]);return(0,h.jsxs)("section",{ref:p,className:g,"aria-label":e.label??n.name,"data-graview-embed":E,"data-graview-scheme":T,...Ae?{"data-graview-embed-narrow":""}:{},style:{position:"relative",isolation:"isolate",height:N,minHeight:S?0:320,display:"flex",flexDirection:"column",overflow:"hidden",borderRadius:"var(--graview-radius, 12px)"},children:[(0,h.jsx)("style",{children:A}),(0,h.jsxs)(Bn.Provider,{value:oe,children:[(0,h.jsx)(nr,{rootRef:p,board:q}),(0,h.jsx)(Zn,{rootRef:p,firstLook:e.firstLook,app:_n(C??{name:n.name},n.schema)}),(0,h.jsx)(_e,{module:"@graview/react",report:oe,content:!0,children:(0,h.jsx)(Fn.Provider,{value:Z,children:(0,h.jsx)(En,{store:v,views:V,initialView:ce,scheme:T,...rr(e,P,C),...e.onSeat?{onSeat:e.onSeat}:{},children:(0,h.jsxs)(Nn.Provider,{value:q,children:[(0,h.jsx)(wo,{face:E,stop:Be??o,kinds:te,places:G,opens:B}),M?(0,h.jsx)(ho,{into:M}):null,(0,h.jsx)(yo,{rootRef:p,face:k,shown:E,path:L,stop:o,draft:ne.n,onDrawn:e.onDrawn,parts:Z}),R?(0,h.jsx)(Kn,{pagesWere:J?.path,basePath:e.basePath,shown:E,onFace:e.onFace,toggle:Ee,kinds:te,places:G,opens:B,landed:ue}):null,a&&E!=="picture"?(0,h.jsx)(_e,{module:"@graview/embed",report:oe,children:(0,h.jsx)(or,{name:C?.name??n.name,heading:b,named:Ht(a).name!==!1,faces:Ht(a).faces===!1?void 0:{scene:{label:gn(Le),current:!xe,go:()=>We(),reach:()=>void Oe(fe.current)},pages:{label:wn(Le),current:xe,go:()=>ae(W.current.path),reach:()=>void Oe("pages")}},at:xe?L:null,without:e.pages?.without(),home:{...ie?.("/")!==void 0?{href:ie("/")}:{},go:()=>ae("/"),current:xe&&L.split("?")[0]==="/"},reach:{...ie?{href:ie}:{},go:m=>ae(m.path)},standing:d,hostActions:e.hostActions,keeping:xe?void 0:(0,h.jsx)(vo,{app:n,studio:e.studio,report:oe}),onFind:ht,switch:e.switch})}):null,(0,h.jsx)(In.Provider,{value:mt,children:(0,h.jsx)(_e,{module:E==="pages"||E==="picture"?"@graview/pages":"@graview/react",report:oe,content:!0,children:(0,h.jsxs)(c.Suspense,{fallback:(0,h.jsx)(fo,{auto:S,scene:E!=="pages"&&E!=="picture"}),children:[E==="picture"?(0,h.jsx)(io,{scope:g,store:v,views:V,as:(o?nt(o).within?.view:void 0)??""}):E==="pages"?(0,h.jsx)(ao,{store:v,views:V,presence:P,auto:S,brand:C,steering:Y,overview:We,scope:g,titleLevel:ar(b),quickAsk:at(e.quickAsk),props:{...e,onNavigate:le,...R?{}:{path:W.current.path}}}):(0,h.jsx)(Hn.Provider,{value:Ue,children:(0,h.jsx)(ro,{address:R,auto:S,scheme:T,scope:g,quickAsk:at(e.quickAsk)})}),(0,h.jsx)(uo,{asked:k,shown:E,onDrawn:pt})]})},E)})]})})})})]})]})}var _t=e=>e.split(/[?#]/)[0]===ve,xr=(0,c.createContext)(null);function ho({into:e}){return e.view=rt().view,null}function yo({rootRef:e,face:n,shown:o,path:a,stop:d,draft:l,onDrawn:b,parts:p}){let{view:g}=rt(),A=o==="scene"||o==="graview",T=Ft(g),v={face:n,path:A?ve:o==="picture"?d??"#":a,stop:T};return fr(e,`${o} ${A?T:v.path} ${l}`,v,b,p),null}var lt,go=be(()=>(__graviewPreload(import.meta.url,["./chunk.WHEUTAXA.js","./chunk.O4WEJ47H.js","./chunk.Y4ZUJUUT.js","./chunk.SDO3U72B.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.UV3YU64Z.js"))),zt=()=>go().then(e=>void(lt=e),()=>new Promise(e=>{let n=()=>{window.removeEventListener("online",n),clearTimeout(o),e()},o=setTimeout(n,1e4);window.addEventListener("online",n)}).then(zt));function wo({face:e,stop:n,kinds:o,places:a,opens:d}){let{view:l,go:b}=rt(),p=(0,c.useRef)({face:e,stop:n});return(0,c.useLayoutEffect)(()=>{let g=p.current.stop!==n,A=p.current.face!==e,T=p.current.face==="pages";if(p.current={face:e,stop:n},!g&&!A||e==="pages"||e==="picture")return;let v=(g||T)&&n!==void 0?Rr(e,n,o,a):T&&Yn(l)?Vt(e,Dt(d),o):e==="graview"?Ot(l,!0):l.overview?Pn(Ot(l,!1),jn(l,o)):l;b(v)},[e,n,o,l,b,d]),null}function vo({app:e,studio:n,report:o}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(c.Suspense,{fallback:null,children:(0,h.jsx)(oo,{})}),n!==!1?(0,h.jsx)(_e,{module:"@graview/studio",report:o,children:(0,h.jsx)(bo,{app:e,studio:n})}):null]})}function bo({app:e,studio:n}){let o={app:e,within:"box",...n?{onApply:n.onApply}:{},...n?.landmark?{landmark:n.landmark}:{},...n?.offered!==void 0?{offered:n.offered}:{}},a=n?.place;return a?(0,h.jsx)(a,{...o}):(0,h.jsx)(c.Suspense,{fallback:null,children:(0,h.jsx)(po,{...o})})}function So({path:e,stop:n,...o},a){return{...o,app:a.app,at:a.at,...a.remote.presence?{presence:a.remote.presence}:{}}}function Gt(e,n){let o=n.store??n.remote?.store??Qn(n.app,n.seed),a=n.notices??ot(),d=null,l={},b=0,p=n.label,g=n.app,A=Promise.resolve(),T=n.at?.face??n.face,v=T===void 0?void 0:Mt({...n,face:T}),P=v??qt(n.stop),C=null,S=[],N=u=>{if(C=u,u!==P)return;let D=S;S=[];for(let q of D)q()};function ne(){let[u,D]=(0,c.useState)(v),[q,K]=(0,c.useState)(n.stop),[x,de]=(0,c.useState)(n.path),[$,O]=(0,c.useState)(n.scheme??"auto"),[Pe,k]=(0,c.useState)(n.principal),[te,R]=(0,c.useState)(n.seats),[J,B]=(0,c.useState)(n.quickAsk),[ce,we]=(0,c.useState)(n.people),[W,z]=(0,c.useState)(n.hostContext),[I,le]=(0,c.useState)(n.brand),[L,ke]=(0,c.useState)(n.label),[Y,X]=(0,c.useState)(n.hostActions),[M,Ee]=(0,c.useState)(void 0),[ue,re]=(0,c.useState)(n.draftView);return d={app:Q=>{Ee(Q),de(void 0),K(void 0)},face:D,stop:K,path:de,scheme:O,seat:k,seats:R,quickAsk:B,people:we,hostContext:z,brand:le,label:ke,hostActions:X,draft:re},(0,h.jsx)(xr.Provider,{value:l,children:(0,h.jsx)(Tr,{...M?So(n,M):n,store:o,notices:a,...u!==void 0?{face:u}:{},onOpening:Q=>{P=Q},...q!==void 0?{stop:q}:{},...x!==void 0?{path:x}:{},...Pe?{principal:Pe}:{},...te?{seats:te}:{},...J!==void 0?{quickAsk:J}:{},...ce?{people:ce}:{},...W?{hostContext:W}:{},...I?{brand:I}:{},label:L,hostActions:Y,draftView:ue,scheme:$,onFace:Q=>{P=Q,D(Q)},onSeat:k,onFaceDrawn:N},M?.n??0)})}let V=()=>{let u=l.view?.focusId,D=u?o.graph.getNode(u)?.kind:void 0,q=(l.shown??P)==="scene"||(l.shown??P)==="graview";return{face:P,path:q?ve:l.pages?.()??n.path??"/",stop:l.view?Ft(l.view):n.stop??"#",...D?{kind:D}:{}}},Z=(0,wr.createRoot)(e);return(0,j.flushSync)(()=>Z.render((0,h.jsx)(ne,{}))),{get store(){return o},where:V,setApp:(u,D,q)=>{let K="graph"in D?{store:D}:D,x=()=>{let de=V();o=K.store,p=q?.label??(p===g.name?u.name:p),g=u,(0,j.flushSync)(()=>{d?.label(p),d?.app({app:u,remote:K,at:de,n:++b})})};lt?x():A=A.then(zt).then(x)},setFace:u=>{P=u,(0,j.flushSync)(()=>d?.face(u))},setStop:u=>(0,j.flushSync)(()=>d?.stop(u)),setPath:u=>(0,j.flushSync)(()=>{if(_t(u)){(P==="pages"||P==="picture")&&(P="scene",d?.face("scene"));return}d?.path(u),P!=="pages"&&(P="pages",d?.face("pages"))}),setScheme:u=>(0,j.flushSync)(()=>d?.scheme(u)),setSeat:u=>(0,j.flushSync)(()=>d?.seat(u)),setSeats:u=>(0,j.flushSync)(()=>d?.seats(u)),setQuickAsk:u=>(0,j.flushSync)(()=>d?.quickAsk(u)),setPeople:u=>(0,j.flushSync)(()=>d?.people(u)),setHostContext:u=>(0,j.flushSync)(()=>d?.hostContext(u)),setBrand:u=>(0,j.flushSync)(()=>d?.brand(u)),setDraftView:u=>(0,j.flushSync)(()=>d?.draft(u)),setLabel:u=>{p=u,(0,j.flushSync)(()=>d?.label(u))},setHostActions:u=>(0,j.flushSync)(()=>d?.hostActions(u)),drawn:()=>A.then(()=>C===P?void 0:new Promise(u=>S.push(u))),notify:u=>{let D;return(0,j.flushSync)(()=>{D=a.notify(u)}),D},unmount:()=>Z.unmount()}}var Fr="/graview/live",Ut="graview.ship",Kt=`${Ut}.${Xe}`;var ge={seat:"x-graview-seat",roles:"x-graview-roles",kind:"x-graview-kind",name:"x-graview-name",for:"x-graview-for",forRoles:"x-graview-for-roles",forName:"x-graview-for-name",via:"x-graview-via"};var Ve=class extends Error{constructor(n){super(n),this.name="Superseded"}},Se=e=>e?.lineage?{lineage:e.lineage}:{},Po=(e,n)=>`${e.calls.map(o=>o.name.replace(/-/g," ")).join(", ")} (${n instanceof Error?n.message.split(`
|
|
2
|
-
`)[0]??"":String(n)})`;function ko(e){if(!e)return[];try{let n=e.storage.getItem(e.key);if(n===null)return[];e.storage.removeItem(e.key);let o=JSON.parse(n);return Array.isArray(o)?o.filter(a=>!!a&&Array.isArray(a.calls)):[]}catch{return[]}}var De=class extends Error{constructor(o){super(o.sentence);this.refusal=o;this.name="RemoteRefusedError"}},Eo={401:"forbidden",403:"forbidden",404:"missing",413:"limit"},Ce=class extends Error{constructor(o,a){super(o);this.conflicts=a;this.name="StaleWrite"}},qe=class extends Error{constructor(n){super(n),this.name="Unreached"}},Ao=new Set([502,503,504]);async function Ro(e){try{return(await e.clone().json()).reason==="unavailable"}catch{return!1}}function To(){let e=Math.random().toString(36).slice(2,8),n=0;return()=>`local-${e}-${++n}`}var xo=1,Fo=()=>({refusals:new Set,conflicts:new Set,statuses:new Set,helds:new Set,builds:new Set,who:new Set,declarations:new Set,tally:{reconnects:0,rebases:0,conflicts:0,resyncs:0}});async function ut(e){return(await Cr(e,ko(e.carry),"This app was updated while your changes were on the way.",Fo())).remote}async function Cr(e,n,o,a){let d=e.fetch??fetch,l={"content-type":"application/json",...e.headers??{}},b={...ft(e.principal),[ge.via]:e.via??"web"};Object.assign(l,b);let p=e.live===!0,g=e.presenceEveryMs,A=e.visible??Lo,T="connecting",v=a.statuses,P=a.tally,C=[],S,N=[],ne=()=>T==="online"&&S!==void 0?"held":T,V=()=>{let t=ne();if(a.told!==t){a.told=t;for(let r of[...v])r(t)}},Z=t=>{if(!(t===T||se)&&(T==="offline"&&t==="online"&&P.reconnects++,T=t,V(),t==="online"))for(let r of C.splice(0))r.again()},u=t=>{if(se)return;let r=typeof t=="string"&&t.length>0?t:void 0,s=r!==S;if(S=r,D(),!!s&&(V(),r===void 0)){for(let i of N.splice(0))i();F&&clearTimeout(F),me()}},D=()=>{if(a.toldHeld!==S){a.toldHeld=S;for(let t of[...a.helds])t(S??null)}},q=async(t,r)=>{let s;try{s=await d(t,r)}catch(i){throw _()||Z("offline"),new qe(i instanceof Error?i.message:String(i))}if(s.status===503&&await Ro(s))return Z("online"),s;if(Ao.has(s.status))throw _()||Z("offline"),new qe(`The server is away (${s.status})`);return Z("online"),s},K=async(t=!1)=>{let r=`${e.url}/graview/state?opFormat=${Ie.op}`,s=t?await d(r,{headers:l}):await q(r,{headers:l});if(!s.ok)throw new Error((await s.json().catch(()=>({}))).error??`The server refused (${s.status})`);return await s.json()},x=e.state??await K(!0);p||(T="online"),S=typeof x.held=="string"&&x.held.length>0?x.held:void 0,D();let de=x.enabledModules??e.enabledModules,$=e.localApp?e.localApp(e.app):e.app,O=new yn({schema:$.schema,mutations:$.mutations??[],invariants:$.invariants??[],...$.policy?{policy:$.policy}:{},...$.modules?{modules:$.modules}:{},...de?{enabledModules:de}:{},...$.intelligence?{intelligence:$.intelligence}:{},...$.brand?.timeZone?{timeZone:$.brand.timeZone}:{},snapshot:x.snapshot,log:x.log,...x.horizon!==void 0?{horizon:x.horizon}:{},ids:To(),...e.storeOptions??{}});pn.served.add(O);let Pe=mn(O),k=x.log.at(-1)?.seq??(x.horizon??0)-1,te=At.of(x.log,{horizon:x.horizon??0}),R=null,J,B=new Map,ce=a.who,we=!1,W=t=>{if(se)return;we=!0;let r=vn(new Map,t,Date.now(),1e4,R?.participant);J!==void 0&&r.delete(J);let s=r.size!==B.size;if(!s)for(let[i,f]of r)xt(f,B.get(i))||(s=!0);if(B=r,!!s)for(let i of[...ce])i([...B.values()])},z=[],I=new Set,le=t=>{let r=z.indexOf(t);r>=0&&z.splice(r,1)},L=new Map,ke=(t,r)=>{let s=L.get(t);s&&(L.delete(t),s.resolve({ops:r.filter(i=>i.batch===t),batch:t}))},Y,X=[],M=(t,r=[])=>{if(t.length===0&&r.length===0)return[];if(Y)return X.push({ops:t,drop:r}),[];let s=Math.min(...t.filter(w=>w.seq>k).map(w=>w.seq));if(Number.isFinite(s)&&s>k+1)return X.push({ops:t,drop:r}),Ee(),[];let i=z.filter(w=>t.some($e=>$e.batch===w)),f=[...new Set([...r,...i])].filter(w=>I.has(w)),y,H=z.filter(w=>!i.includes(w));try{y=O.rebase({confirmed:t,pending:H,drop:f}).confirmed}catch(w){if(!(w instanceof hn))throw w;return X.push({ops:t,drop:r}),Ee(),[]}for(let w of i)le(w);t.some(w=>w.seq>k)&&H.some(w=>!f.includes(w))&&P.rebases++,t.length>0&&(k=Math.max(k,...t.map(w=>w.seq)),te.note(t));for(let w of f)I.delete(w);for(let w of i)ke(w,t);return y},Ee=()=>{Y||(Y=oe(K().then(t=>{if(ue(t)){X=[];return}let r=new Set(t.log.map(f=>f.batch)),s=z.filter(f=>r.has(f));for(let f of s)le(f);let i=O.adopt({snapshot:t.snapshot,log:t.log,...t.horizon!==void 0?{horizon:t.horizon}:{},pending:[...z],drop:[...I].filter(f=>!z.includes(f))});I.clear();for(let f of i.pending)I.add(f.batch);k=t.log.at(-1)?.seq??(t.horizon??0)-1,te=At.of(t.log,{horizon:t.horizon??0}),P.resyncs++;for(let f of s)ke(f,t.log)}).then(()=>{Y=void 0;let t=X;X=[];for(let{ops:r,drop:s}of t)M(r,s)},()=>{Y=void 0,X=[]})))},ue=t=>(typeof t.build=="string"&&en(t.build),typeof t.version=="number"&&u(t.held),typeof t.version!="number"||t.version===x.version?!1:(vt(t.version),!0)),re=async t=>{let s=await(await q(`${e.url}/graview/since?seq=${t}&opFormat=${Ie.op}`,{headers:l})).json();return ue(s)?[]:s.ops??[]},Q=async()=>{let t=await ze();return Y&&await Y,t},ze=async()=>{if(R&&!_()&&A()){let r=await(await q(`${e.url}/graview/here`,{method:"POST",headers:l,body:JSON.stringify({presence:R,seq:k})})).json();return ue(r)?[]:(typeof r.participant=="string"&&(J=r.participant),W(r.who??[]),M(r.ops??[]))}return M(await re(k))},Ae=new Map,E=new Map,Re=new Map,fe=new Set,oe=t=>(fe.add(t),t.finally(()=>fe.delete(t)).catch(()=>{}),t),He=Promise.resolve(),Te=0,pt=(t,r)=>{let s=He.then(()=>ht(t,r));return He=s.catch(()=>{}),s},mt=()=>new Promise((t,r)=>C.push({again:t,give:r})),ht=async(t,r)=>{let s,i;for(;;){try{s=await q(`${e.url}/graview/ops`,{method:"POST",headers:l,body:JSON.stringify({...t,opFormat:Ie.op})})}catch(w){if(!(w instanceof qe)||U)throw w;if(await mt(),_())return Ke(t,r);continue}if(i=await s.json().catch(()=>({})),s.status===503&&i.reason==="unavailable"&&typeof i.held=="string"&&!U){if(typeof i.version=="number"?ue(i):(u(i.held),!1))break;if(S!==void 0&&(Pt>0||p)){if(await new Promise(w=>N.push(w)),U)throw new Ve("The client closed.");if(_())return Ke(t,r);continue}}let H;if(s.status===503&&i.reason==="unavailable"&&!U)H=Jt(e.backoff,Te++);else{if(Te=0,s.status!==429||U)break;H=Oo(s.headers.get("retry-after"),i.retryAfter)}if(await new Promise(w=>setTimeout(w,H)),_())return Ke(t,r)}if(se||ue(i))throw new Ve("The app was changed.");if(!s.ok){let H=i.error??`The server refused (${s.status})`;throw i.conflict?new Ce(H,i.conflicts??[]):new De({reason:i.reason??Eo[s.status]??"invalid",sentence:H,...i.wouldNeed?.length?{wouldNeed:i.wouldNeed}:{}})}let f=i.ops??[],y=f[0]?.seq;return y!==void 0&&y>k+1&&(f=await re(k)),r!==void 0&&(i.batch&&Ae.set(r,i.batch),le(r)),M(f,r!==void 0?[r]:[]),{ops:i.ops??[],...i.batch?{batch:i.batch}:{}}},G,ee=!1,U=!1,Be=0,pe,Ge=0,We=0,ae=null,Le=()=>{},xe=new Promise(t=>{Le=t}),_=()=>p&&ee&&G?.readyState===xo,ie=t=>{if(!_())return!1;try{return G.send(JSON.stringify(t)),!0}catch{return!1}},Ue=(t=!1)=>{!R||!_()||!A()||!t&&ae&&xt(R,ae)&&(g===void 0||Date.now()-We<g)||ie({t:"here",presence:R})&&(ae=R,We=Date.now())},m=new Set,F,me=()=>{if(F=void 0,S!==void 0)return;let t=[...L.entries()].filter(([r])=>m.has(r));m.clear();for(let[,r]of t)ie(r.message)},Xt=(t,r)=>{L.has(t)&&(m.add(t),F&&clearTimeout(F),F=setTimeout(me,Math.max(0,r)))},Vr=t=>{L.has(t)&&m.add(t)},Ke=(t,r)=>new Promise((s,i)=>{let f=r??`send-${++Ge}`,y=t.undo?{t:"undo",cid:f,batches:t.undo,...t.intent?{intent:t.intent}:{},...t.batch?{batch:t.batch}:{},...t.via?{via:t.via}:{},...Se(t)}:{t:"call",cid:f,calls:t.calls??[],...t.intent?{intent:t.intent}:{},...t.batch?{batch:t.batch}:{},...t.base?.length?{base:t.base}:{},...t.via?{via:t.via}:{},...Se(t)};if(L.set(f,{message:y,...r!==void 0?{mine:r}:{},resolve:s,reject:i}),m.size>0||S!==void 0){m.add(f);return}ie(y)}),yt=(t,r)=>_()?Ke(t,r):pt(t,r),Dr=t=>{switch(t.t){case"welcome":{if(en(t.build),typeof t.version=="number"&&t.version!==x.version){vt(t.version);return}if(ee=!0,Be=0,typeof t.participant=="string"&&(J=t.participant),u(t.held),M(t.ops??[]),m.clear(),F&&clearTimeout(F),F=void 0,S!==void 0)for(let r of L.keys())m.add(r);else for(let r of L.values())ie(r.message);Ue(!0),Z("online"),Le();return}case"ops":M(t.ops??[]);return;case"ack":{let r=L.get(t.cid);if(!r){M(t.ops??[]);return}L.delete(t.cid),Te=0,r.mine!==void 0&&(Ae.set(r.mine,t.batch),le(r.mine)),M(t.ops??[],r.mine!==void 0?[r.mine]:[]),r.resolve({ops:t.ops??[],batch:t.batch});return}case"refused":case"conflict":{let r=L.get(t.cid);if(!r)return;if(t.t==="refused"&&t.reason==="unavailable"){S!==void 0?Vr(t.cid):Xt(t.cid,Jt(e.backoff,Te++));return}L.delete(t.cid),r.reject(t.t==="conflict"?new Ce(t.sentence,t.conflicts??[]):new De({reason:t.reason??"invalid",sentence:t.sentence,...t.wouldNeed?.length?{wouldNeed:[...t.wouldNeed]}:{}}));return}case"busy":typeof t.cid=="string"&&Xt(t.cid,typeof t.retryAfter=="number"?t.retryAfter:1e3);return;case"presence":W(t.who??[]);return;case"held":u(t.sentence);return;case"declaration":typeof t.version=="number"&&t.version!==x.version&&vt(t.version);return;case"reload":on(typeof t.reason=="string"?t.reason:"This app was updated.");return;case"error":if(t.reopen===!0&&G){let r=G;sn(r);try{r.close(1e3,"Opening again.")}catch{}}return;default:return}},se=!1,gt=a.declarations,wt=a.builds,en=t=>{if(!(se||a.otherBuild!==void 0||!e.build||typeof t!="string"||t.length===0||t===e.build)){a.otherBuild=t;for(let r of[...wt])r(t)}},tn=()=>{let t=[],r=0;for(let s of z){let i=Re.get(s);i?t.push({calls:i.calls,...i.intent?{intent:i.intent}:{},...i.via?{via:i.via}:{},...Se(i),batch:s}):r++}return{carried:t,undos:r}},nn=(t,r)=>`${r} while ${t===1?"an undo of yours was":"undos of yours were"} on the way; ${t===1?"it was":"they were"} not made.`,rn=t=>{se=!0,R=null;let r=new Ve(t);for(let i of L.values())i.reject(r);L.clear(),Qe&&clearInterval(Qe),U=!0,pe&&clearTimeout(pe),F&&clearTimeout(F),he&&clearTimeout(he);for(let i of C.splice(0))i.give(r);for(let i of N.splice(0))i();let s=G;G=void 0,ee=!1;try{s?.close(1e3,t)}catch{}Le()};async function vt(t){if(se)return;if(!e.resolveApp){on(`This app was changed on its server (version ${t}); reload the page to carry on.`);return}let{carried:r,undos:s}=tn(),i=e.resolveApp,f=R;rn("The app was changed.");try{let y=await i(t),{state:H,...w}=e,$e=await Cr({...w,app:y},r,"The app was changed while your changes were on the way.",a);f&&$e.remote.presence.here(f);for(let Ze of[...gt])Ze($e.remote,t);let _r=[...s>0?[Je(nn(s,"The app was changed"))]:[],...$e.unheard()];for(let Ze of _r)for(let jr of Me)jr(Ze.sentence,Ze)}catch(y){let H=`The app was changed, but the new version could not be opened: ${y instanceof Error?y.message:String(y)}`;for(let w of Me)w(H,Je(H))}}function on(t){if(se)return;let{carried:r,undos:s}=tn();rn(t);let i=!1;if(e.carry&&r.length>0)try{e.carry.storage.setItem(e.carry.key,JSON.stringify(r)),i=!0}catch{}let f=[];!i&&r.length>0&&f.push(`${t} ${r.length===1?"A change of yours was":`${r.length} changes of yours were`} not sent; make ${r.length===1?"it":"them"} again after the page reloads.`),s>0&&f.push(nn(s,"This app was updated"));for(let y of f)for(let H of Me)H(y,Je(y));(e.reloadPage??Co)()}let an=()=>{if(U||!p)return;let t=`${e.url.replace(/^http/,"ws").replace(/\/$/,"")}${Fr}`,{"content-type":r,...s}=l,i;try{i=e.socket?e.socket(t,s,[Kt]):Ir(t,s)}catch{return dn()}G=i,ee=!1,i.onopen=()=>{G===i&&i.send(JSON.stringify({t:"hello",seq:k,protocol:Xe,wire:Ut,opFormat:Ie.op,...e.build?{build:e.build.slice(0,64)}:{},...e.hostProtocol!==void 0?{hostProtocol:e.hostProtocol}:{}}))},i.onmessage=f=>{if(G!==i)return;let y;try{y=JSON.parse(String(f.data))}catch{return}Dr(y)},i.onclose=()=>sn(i),i.onerror=()=>{}},he,Hr=()=>{we=!1,he&&clearTimeout(he),he=setTimeout(()=>{if(he=void 0,we||U)return;let t=new Map([...B].filter(([,r])=>r.held!=="socket"));if(t.size!==B.size){B=t;for(let r of ce)r([...B.values()])}},1e4),he.unref?.()};function sn(t){if(G!==t)return;let r=ee;G=void 0,ee=!1,ae=null,r&&(Z("offline"),Hr()),dn()}let dn=()=>{if(U)return;let t=Jt(e.backoff,Be);Be++,pe=setTimeout(an,t)},Br=O.applyAll.bind(O),Wr=O.undo.bind(O),Nr=O.previewAll.bind(O);O.previewAll=(t,r)=>Nr(t,{...e.principal?{author:e.principal}:{},...r});let Me=a.refusals,Ne=[],Je=t=>({reason:"invalid",sentence:t}),Ye=a.conflicts,bt=!1,cn=async(t,r)=>{if(r instanceof Ve||se)return;let s=r instanceof De?r.refusal:un(r),i=s.sentence;le(t);try{M([],[t])}catch{}let f=Re.get(t);if(Re.delete(t),r instanceof Ce&&P.conflicts++,r instanceof Ce&&!_()&&await Q().catch(()=>[]),r instanceof Ce&&Ye.size>0){let y=!1,H={sentence:i,conflicts:r.conflicts,keepTheirs(){y=!0},useMine(){if(!(y||!f)){y=!0,bt=!0;try{O.applyAll(f.calls,{...f.intent?{intent:f.intent}:{},...f.via?{via:f.via}:{},...Se(f)})}finally{bt=!1}}}};for(let w of Ye)w(H);return}for(let y of Me)y(i,s)};O.applyAll=(t,r)=>{let s=fn(O.log.all().filter(y=>I.has(y.batch))),i=Br(t,{...e.principal?{author:e.principal}:{},...r});z.push(i.batch),I.add(i.batch),Re.set(i.batch,{calls:t,...r?.intent?{intent:r.intent}:{},...r?.via?{via:r.via}:{},...Se(r)});let f=bt?[]:te.baseFor(i.ops,s);return E.set(i.batch,oe(yt({calls:t,...r?.intent?{intent:r.intent}:{},batch:i.batch,...f.length>0?{base:f}:{},...r?.via?{via:r.via}:{},...Se(r)},i.batch).catch(y=>cn(i.batch,y)))),i},O.apply=(t,r)=>O.applyAll([t],r),O.undo=(t,r)=>{let s=typeof t=="string"?[t]:t,i=Wr(s.map(y=>Ae.get(y)??y),{...e.principal?{author:e.principal}:{},...r});z.push(i.batch),I.add(i.batch);let f=Promise.allSettled(s.map(y=>E.get(y)));return E.set(i.batch,oe(f.then(()=>yt({undo:s.map(y=>Ae.get(y)??y),...r?.intent?{intent:r.intent}:{},batch:i.batch,...r?.via?{via:r.via}:{},...Se(r)},i.batch)).catch(y=>cn(i.batch,y)))),i};let $r=async(t,r={})=>{St++;try{return(await oe(yt({calls:t,...r}))).ops}finally{St--}},St=0,ln={here(t){R=t,Ue()},onWho(t){return ce.add(t),B.size>0&&t([...B.values()]),()=>{ce.delete(t)}},leave(){if(!R)return;let t=JSON.stringify({participant:J??R.participant});if(R=null,ie({t:"bye"}))return;let r=globalThis.navigator?.sendBeacon;r?r.call(globalThis.navigator,`${e.url}/graview/leave`,t):d(`${e.url}/graview/leave`,{method:"POST",headers:l,body:t}).catch(()=>{})}},Pt=e.pollMs??800,Qe=Pt>0&&typeof setInterval=="function"?setInterval(()=>{_()||Q().catch(()=>{})},Pt):null;if(p){an();let t;await Promise.race([xe,new Promise(r=>t=setTimeout(r,e.openTimeoutMs??3e3))]),clearTimeout(t)}if(n.length>0&&!se){let t=[],r=new Set(O.log.all().map(s=>s.batch));for(let s of n)if(!(s.batch!==void 0&&r.has(s.batch)))try{O.applyAll(s.calls,{...s.intent?{intent:s.intent}:{},...s.batch?{batch:s.batch}:{},...s.via?{via:s.via}:{},...Se(s)})}catch(i){t.push(Po(s,i))}t.length>0&&Ne.push(Je(`${o} ${t.length===1?"One no longer fits and was not made":`${t.length} no longer fit and were not made`}: ${t.join("; ")}.`))}return{remote:{store:O,version:x.version,migrated:x.migrated??[],send:$r,pull:Q,onRefusal(t){Me.add(t);let r=Ne;Ne=[];for(let s of r)t(s.sentence,s);return()=>Me.delete(t)},onDeclaration(t){return gt.add(t),()=>gt.delete(t)},onBuild(t){return wt.add(t),a.otherBuild!==void 0&&t(a.otherBuild),()=>wt.delete(t)},onConflict(t){return Ye.add(t),()=>Ye.delete(t)},revision:(t,r)=>te.of(t,r),seq:()=>k,participant:()=>J,transport:()=>_()?"socket":"poll",status:ne,onStatus(t){return v.add(t),()=>v.delete(t)},held:()=>S,onHeld(t){return a.helds.add(t),S!==void 0&&t(S),()=>a.helds.delete(t)},counters:()=>({...P}),who:()=>[...B.values()],pending:()=>z.length+St,async settled(){for(;fe.size>0;)await Promise.allSettled([...fe])},presence:ln,close(){Qe&&clearInterval(Qe),Pe(),ln.leave(),U=!0,pe&&clearTimeout(pe),F&&clearTimeout(F),he&&clearTimeout(he);for(let r of C.splice(0))r.give(new Error("The client closed before the server could be reached."));for(let r of N.splice(0))r();let t=G;G=void 0,ee=!1;try{t?.close(1e3,"Closed.")}catch{}}},unheard(){let t=Ne;return Ne=[],t}};function Ir(t,r){let s=globalThis.WebSocket;if(!s)throw new Error("This runtime has no WebSocket; the client polls instead.");let i=typeof globalThis.document<"u",f=e.subprotocol?[Kt]:[];if(!i)try{return new s(t,{headers:r,...f.length>0?{protocols:f}:{}})}catch{}let y=new URL(t);for(let[H,w]of Object.entries(b))y.searchParams.set(H,w);return f.length>0?new s(y.toString(),f):new s(y.toString())}}function Oo(e,n,o=Date.now()){let a,d=e?.trim();if(d)if(/^\d+(\.\d+)?$/.test(d))a=Number(d)*1e3;else{let p=Date.parse(d);Number.isFinite(p)&&(a=Math.max(0,p-o))}let l=typeof n=="number"&&Number.isFinite(n)&&n>=0?n:void 0,b=l!==void 0&&l<50&&a!==void 0&&Math.abs(l*1e3-a)<1e3;return l!==void 0&&!b?l:a??1e3}function Co(){globalThis.location?.reload?.()}function Lo(){return globalThis.document?.visibilityState!=="hidden"}function Jt(e,n){if(typeof e=="function")return Math.max(0,e(n));let{min:o=250,max:a=1e4,factor:d=2}=e??{};return Math.min(a,o*d**n)*(.75+Math.random()*.5)}function ft(e){let n={};if(!e)return n;e.id&&(n[ge.seat]=e.id),e.roles?.length&&(n[ge.roles]=e.roles.join(",")),e.kind!=="human"&&(n[ge.kind]=e.kind),e.name&&(n[ge.name]=encodeURIComponent(e.name));let o=e.onBehalfOf;return o?.id&&(n[ge.for]=o.id),o?.roles?.length&&(n[ge.forRoles]=o.roles.join(",")),o?.name&&(n[ge.forName]=encodeURIComponent(o.name)),n}var Lr="/graview/views";function Yt(e){let n=e.fetch??fetch,o=e.url.replace(/\/$/,""),a={"content-type":"application/json",...e.principal?ft(e.principal):{},...e.headers??{}},d=e.state?{hidden:e.state.hidden??[],removed:e.state.removed??[],may:e.state.may??et.may}:et,l=new Set,b=v=>{if(JSON.stringify(v)!==JSON.stringify(d)){d=v;for(let P of l)P()}},p=async(v,P)=>{let C=await n(`${o}${e.path??Lr}`,{method:v,headers:a,...P!==void 0?{body:JSON.stringify(P)}:{}}),S=await C.json();if(!C.ok)throw new Error(S.error??`The store answered ${C.status}.`);b({hidden:S.hidden??[],removed:S.removed??[],may:S.may??et.may})},g=()=>p("GET"),A=e.state?Promise.resolve():g().catch(()=>{}),T=e.pollMs?setInterval(()=>void g().catch(()=>{}),e.pollMs):void 0;return{ready:A,refresh:g,close:()=>clearInterval(T),current:()=>d,onChange(v){return l.add(v),()=>void l.delete(v)},hide:v=>p("POST",{hide:v}),show:v=>p("POST",{show:v}),remove:(v,P)=>p("POST",{remove:v,...P?{about:P}:{}}),async restore(v){let P=d.removed.find(C=>C.name===v)?.lens;await p("POST",{restore:v}),P&&await e.onDeclaration?.()},async lens(v){await p("POST",{lens:v}),await e.onDeclaration?.()}}}var Zt=document.getElementById("graview-app"),Qt=/^\/forms\/([^/]+)\/?$/.exec(location.pathname),Mr=Qt?(__graviewPreload(import.meta.url,["./chunk.ETPKXUAN.js","./chunk.V7XHNRQM.js","./chunk.UGFDSE37.js","./chunk.IYIN6VSN.js","./chunk.GCKZ2YRJ.js","./chunk.VC3UGFHY.js","./chunk.YHH4TWZ2.js","./chunk.O2WWYZI7.js","./chunk.AGIO2GRV.js","./chunk.VSNHCGKC.js","./chunk.EUPSAYEI.js","./chunk.TCXKPILZ.js","./chunk.R6V37SR7.js","./chunk.SWWAEOZ7.js","./chunk.IROYMLER.js","./chunk.FWSCBHZ5.js","./chunk.7NNI7YH4.js","./chunk.7N2GXZYI.js","./chunk.MF73YBJL.js","./chunk.63MS2LOP.js","./chunk.PKUDIWIF.js","./chunk.VW2VCPJX.js","./chunk.IW7YFPGG.js","./chunk.MB7LKKUD.js","./chunk.ZQY6ODXC.js","./chunk.C44MC5X3.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.AWXDZUKH.js")):Oe("pages");try{Qt?await Mo(decodeURIComponent(Qt[1])):await Vo()}catch(e){let n=document.createElement("pre");n.setAttribute("role","alert"),n.style.cssText="margin:2rem;font:14px/1.5 ui-monospace,monospace;white-space:pre-wrap",n.textContent=e instanceof Error?e.message:String(e),Zt.replaceChildren(n),window.__graviewFailed=n.textContent}async function Mo(e){let n=await fetch(`/graview/document?form=${encodeURIComponent(e)}`),o=await n.json();if(!n.ok)throw new Error(o.error??`The preview server did not hand over the form (${n.status}).`);let a=await it(o);if(!a.ok)throw new Error(tt(a.findings));let d=a.app,l=o.principal,b=await ut({app:d,url:location.origin,principal:l,...o.state?{state:o.state,openTimeoutMs:0}:{openTimeoutMs:3e3}});document.title=d.forms?.[e]?.title??d.name;let{mount:p}=await Mr;window.__graview=p(Zt,{app:d,form:e,principal:l,remote:b,height:"100dvh",onSubmitted:()=>window.__graviewSubmitted=!0}),window.__graviewReady=!0}async function Vo(){let e=await fetch("/graview/document");if(!e.ok)throw new Error(`The preview server did not hand over the document (${e.status}).`);let n=await e.json(),a=await(async g=>{if(typeof g.module=="string")return(await import(g.module)).app;let A=await it(g);if(!A.ok)throw new Error(tt(A.findings));return A.app})(n);if(!a||typeof a!="object"||!("schema"in a))throw new Error("The app module the preview server handed does not export an app.");let d=n.principal,l=await ut({app:a,url:location.origin,principal:d,live:!0,subprotocol:!0,pollMs:1200,...n.state?{state:n.state,openTimeoutMs:0}:{openTimeoutMs:3e3}});document.title=a.name;let b,p=Yt({url:location.origin,principal:d,...n.views?{state:n.views}:{},onDeclaration:async()=>{let g=await(await fetch("/graview/document")).json();if(typeof g.module=="string")return;let A=await it(g);A.ok&&b?.setApp(A.app,l)}});await Promise.all([Mr,p.ready]),b=Gt(Zt,{app:a,remote:l,principal:d,studio:!1,face:"pages",routing:"address",bar:!0,height:"100dvh",label:a.name,heading:1,keptViews:p,...n.draftView?{draftView:n.draftView}:{}}),window.__graview=b,b.drawn().then(()=>{window.__graviewReady=!0})}
|
|
1
|
+
var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as Mt,b as Gn,c as Un,d as Kn,e as Jn,f as Vt,g as Yn,h as Dt}from"./chunk.J6ANRF6E.js";import{a as zr}from"./chunk.V4BCB7N2.js";import{a as Ht,b as Zn,c as Xn,d as er,e as Bt,f as tr,g as nr,h as rr,i as or,j as ar,k as ir,l as sr,m as dr,n as _e}from"./chunk.QO7MDWID.js";import{b as Qn}from"./chunk.FOP5RBGF.js";import{a as kt}from"./chunk.Q5WEOX3Q.js";import{a as Et,g as bn}from"./chunk.HG4DDNPG.js";import{k as tt}from"./chunk.KTFUVR4V.js";import{C as _n,H as jn,L as qn,M as zn,j as qr,k as Wn,n as ot,o as Nn,q as $n,u as In,z as at}from"./chunk.2UIUMG23.js";import{Aa as Vn,Ca as Dn,Da as Lt,G as Ct,Ha as Hn,Ia as Bn,La as rt,R as kn,W as En,a as Sn,b as Ft,c as nt,da as An,ea as Rn,j as Pn,m as Ot,sa as Tn,ta as xn,ua as Fn,va as On,wa as Cn,xa as Ln,za as Mn}from"./chunk.KA44WNB4.js";import{a as be}from"./chunk.SDO3U72B.js";import{Ad as xt,Pc as mn,Rc as hn,Sc as yn,Uc as et,Vb as At,Wb as fn,jb as Ie,kb as Xe,od as ve,pd as gn,qd as wn,vd as Rt,wb as un,wd as Tt,zc as pn,zd as vn}from"./chunk.4TJOS4C7.js";import"./chunk.2AZTW66C.js";import{b as Fe}from"./chunk.AJZBJBMO.js";async function it(e,n={}){let o=e.compiled===void 0||!Ur(e.compiled,e.document)?void 0:bn(e.compiled,n);if(o?.ok)return o;let{compileDocumentWithoutCheck:a}=await Gr();return a(e.document,n)}var cr,Gr=()=>cr??=(__graviewPreload(import.meta.url,["./chunk.4GQA3AJU.js","./chunk.HG4DDNPG.js","./chunk.X7JMJSLU.js","./chunk.5Y3Q7ONN.js","./chunk.KTFUVR4V.js","./chunk.4TJOS4C7.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.7QZYFLBS.js")).catch(e=>{throw cr=void 0,e});function Ur(e,n){let o=typeof e=="object"&&e!==null?e.document:void 0,a=n;if(typeof a=="string")try{a=JSON.parse(a)}catch{return!1}return o!==void 0&&kt(Et(o).document)===kt(Et(a).document)}var c=Fe(Ct(),1);var dt=Fe(Ct(),1),Wt="data-graview-drawn",Kr=200,lr=50,Jr=1e4,st=()=>typeof performance<"u"?performance.now():Date.now();function Yr(e){let n=[...e.querySelectorAll("img")];for(let o of e.querySelectorAll("[data-worker-view]"))o.shadowRoot&&n.push(...o.shadowRoot.querySelectorAll("img"));return n}function Qr(e,n){if(e.ownerDocument.fonts?.status==="loading"||xn()>0||Ln(n)>0||e.querySelector('[aria-busy="true"]')||Yr(e).some(a=>!a.complete&&a.loading!=="lazy"))return!1;for(let a of e.querySelectorAll("[data-worker-view-place]"))if(!a.querySelector("[data-worker-view][data-worker-view-drawn], [data-worker-view][data-worker-view-failed]"))return!1;return!0}function ur(e){let n=e.querySelector("[data-embed-content]"),o=[...e.querySelectorAll("[data-worker-view]")].map(a=>`${a.offsetWidth}x${a.offsetHeight}`);return`${e.scrollWidth}x${e.scrollHeight}|${n?`${n.scrollWidth}x${n.scrollHeight}`:""}|${o.join(",")}`}function Zr(e,n,o,a){e.removeAttribute(Wt);let d=e.ownerDocument.defaultView;if(!d)return()=>{};let l=st(),b=l,p=ur(e),g=!1,A,T=typeof MutationObserver>"u"?void 0:new MutationObserver(S=>{S.some(N=>!(N.target===e&&N.attributeName===Wt))&&(b=st())});T?.observe(e,{childList:!0,subtree:!0,characterData:!0,attributes:!0});let v=()=>{g=!0,T?.disconnect(),A!==void 0&&clearTimeout(A)},P=S=>{let N=!1,ne=()=>{N||(N=!0,S())};typeof d.requestAnimationFrame=="function"&&d.requestAnimationFrame(()=>setTimeout(ne,0)),setTimeout(ne,100)},C=()=>{if(g)return;let S=ur(e);S!==p&&(p=S,b=st());let N=st();if(Qr(e,a)&&N-b>=Kr||N-l>=Jr){P(()=>{g||(v(),e.setAttribute(Wt,n),Vn(),o())});return}A=setTimeout(C,lr)};return A=setTimeout(C,lr),v}function fr(e,n,o,a,d){Mn();let l=(0,dt.useRef)({place:o,onDrawn:a});l.current={place:o,onDrawn:a},(0,dt.useLayoutEffect)(()=>{d&&Cn(d);let b=A=>Zr(A,l.current.place.path,()=>l.current.onDrawn?.(l.current.place),d);if(e.current)return b(e.current);let p,g=!1;return queueMicrotask(()=>{!g&&e.current&&(p=b(e.current))}),()=>{g=!0,p?.()}},[n,e,d])}var ye=Fe(Ct(),1),je,Xr=be(()=>(__graviewPreload(import.meta.url,["./chunk.2VTMTW7K.js","./chunk.ETR6AV47.js","./chunk.I5TOMBIF.js","./chunk.QQTRAY5W.js","./chunk.DOBQ4LO4.js","./chunk.KA44WNB4.js","./chunk.SDO3U72B.js","./chunk.4TJOS4C7.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.PCEYZQAW.js"))),pr=()=>Xr().then(e=>void(je=e),()=>new Promise(e=>setTimeout(e,2e3)).then(pr)),Nt=Tn(pr),mr=e=>!!e&&je===void 0;function $t({onReady:e,fetch:n}){return(0,ye.useLayoutEffect)(()=>void n().then(e),[e,n]),null}var eo=0;function hr(e){let[n,o]=(0,ye.useState)(()=>je);(0,ye.useEffect)(()=>{if(!e||n)return;let l=!1;return Nt().then(()=>{l||o(je)}),()=>{l=!0}},[e,n]);let a=(0,ye.useMemo)(()=>eo+=1,[e]);return{over:(0,ye.useMemo)(()=>{let l=n??je;if(!e||!l)return;let{source:b,worker:p,...g}=e,A={...g,worker:p??{source:b},draft:!0};return{name:e.manifest.name,home:e.manifest.attach==="home",register:T=>l.registerWorkerView(T,A)}},[e,n]),n:a}}var wr=Fe(zr(),1),j=Fe(qr(),1);var h=Fe(kn(),1);function ct(e,n={}){let o=Lt(e);return{Face:o.part((d,l)=>(0,c.createElement)(d,l),n),fetch:()=>o.load().then(()=>{}),here:()=>o.current!==void 0||o.failed}}var jt=e=>Promise.all([e,qn()]).then(([n])=>n),vr=be(()=>(__graviewPreload(import.meta.url,["./chunk.EXEZBZGW.js","./chunk.NTLHEHOM.js","./chunk.V2GSBYDK.js","./chunk.NLBIX7LH.js","./chunk.GACKGEUY.js","./chunk.HJCQ6I3S.js","./chunk.KVEDIBXS.js","./chunk.7VT3TRHR.js","./chunk.VQAQQW4Q.js","./chunk.DWPU56S5.js","./chunk.7FRPNQU4.js","./chunk.BDHKWVNX.js","./chunk.ZH4NWRWB.js","./chunk.GUMJEVVP.js","./chunk.SAHNXAV3.js","./chunk.UGJSMNVO.js","./chunk.NR5ODXMO.js","./chunk.E5GM2SMO.js","./chunk.NQZ73QV7.js","./chunk.O45VO36H.js","./chunk.UT6642FC.js","./chunk.QO7MDWID.js","./chunk.FOP5RBGF.js","./chunk.TI4OSTQV.js","./chunk.MAFFUPCR.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.NWT5FPEK.js"))),to=be(()=>(__graviewPreload(import.meta.url,["./chunk.TMDI7KRS.js","./chunk.I7QIHN66.js","./chunk.2QNGGF55.js","./chunk.PMJUGHW4.js","./chunk.Y4MQGEUS.js","./chunk.UGFDSE37.js","./chunk.EXEZBZGW.js","./chunk.X7N3JUO4.js","./chunk.NTLHEHOM.js","./chunk.GNBN3BK7.js","./chunk.XTMOFRHL.js","./chunk.NLBIX7LH.js","./chunk.GACKGEUY.js","./chunk.PXQVXBNG.js","./chunk.UJRBOUGC.js","./chunk.DWPU56S5.js","./chunk.ZH4NWRWB.js","./chunk.2GLJH253.js","./chunk.GUMJEVVP.js","./chunk.4VW6THJF.js","./chunk.SAHNXAV3.js","./chunk.DHAK6PPX.js","./chunk.YDL5BSTG.js","./chunk.DUWYF7BO.js","./chunk.UGJSMNVO.js","./chunk.NR5ODXMO.js","./chunk.O45VO36H.js","./chunk.UT6642FC.js","./chunk.XOZU4OFA.js","./chunk.SUPWMV2F.js","./chunk.MB7LKKUD.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.664PBQAQ.js"))),no=be(()=>(__graviewPreload(import.meta.url,["./chunk.TMDI7KRS.js","./chunk.I7QIHN66.js","./chunk.2QNGGF55.js","./chunk.PMJUGHW4.js","./chunk.Y4MQGEUS.js","./chunk.UGFDSE37.js","./chunk.EXEZBZGW.js","./chunk.X7N3JUO4.js","./chunk.NTLHEHOM.js","./chunk.GNBN3BK7.js","./chunk.XTMOFRHL.js","./chunk.NLBIX7LH.js","./chunk.GACKGEUY.js","./chunk.PXQVXBNG.js","./chunk.UJRBOUGC.js","./chunk.DWPU56S5.js","./chunk.ZH4NWRWB.js","./chunk.2GLJH253.js","./chunk.GUMJEVVP.js","./chunk.4VW6THJF.js","./chunk.SAHNXAV3.js","./chunk.DHAK6PPX.js","./chunk.YDL5BSTG.js","./chunk.DUWYF7BO.js","./chunk.UGJSMNVO.js","./chunk.NR5ODXMO.js","./chunk.O45VO36H.js","./chunk.UT6642FC.js","./chunk.XOZU4OFA.js","./chunk.SUPWMV2F.js","./chunk.MB7LKKUD.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.YUH43J2K.js"))),br=ct(()=>jt(vr().then(e=>e.SceneFace)),{what:"This view"}),Sr=ct(()=>vr().then(e=>e.SceneKeeping),{quiet:!0}),Pr=ct(()=>jt(to().then(e=>e.PagesContent)),{what:"This page"}),kr=ct(()=>jt(no().then(e=>e.PictureFace)),{what:"This picture"}),ro=br.Face,oo=Sr.Face,ao=Pr.Face,io=kr.Face;function Oe(...e){let n=e.length>0?e:["scene","pages","picture"],o=new Set(n.flatMap(Er));return Promise.all([...[...o].map(a=>a.fetch()),$n()]).then(()=>{},()=>{})}var Er=e=>e==="pages"?[Pr]:e==="picture"?[kr]:[br,Sr],Ar=e=>Er(e).every(n=>n.here()),so=150,It=0;function yr(e,n){if(Ar(e))return n();let o=++It,a=()=>{o===It&&(It+=1,n())};Oe(e).then(a),setTimeout(a,so)}var co=768;function lo(e,n){let o=n!==null&&n>=co;(0,c.useEffect)(()=>{if(!o||e==="picture")return;let a=e==="pages"?"scene":"pages";if(Ar(a))return;let d=globalThis,l=()=>void Oe(a),b=()=>{},p=Dn(()=>{if(d.requestIdleCallback&&d.cancelIdleCallback){let g=d.requestIdleCallback(l,{timeout:4e3});b=()=>d.cancelIdleCallback?.(g)}else{let g=setTimeout(l,1500);b=()=>clearTimeout(g)}});return()=>(p(),b())},[e,o])}function uo({asked:e,shown:n,onDrawn:o}){return(0,c.useLayoutEffect)(()=>o(e,n),[e,n,o]),null}function fo({auto:e,scene:n}){return(0,h.jsx)("div",{"data-embed-content":"","aria-busy":"true",style:{flex:e?n?`0 0 ${Bt}px`:"0 0 auto":"1 1 auto",minHeight:0,background:"var(--graview-ground)"}})}var po=Lt(be(()=>(__graviewPreload(import.meta.url,["./chunk.AJZBJBMO.js"]),import("./chunk.5JNXQHN4.js")))).part((e,n)=>(0,h.jsx)(e.StudioPlace,{...n}),{quiet:!0});function Rr(e,n,o,a,d){return Vt(e,Jn(n?nt(n):d??Sn,a),o)}function qt(e){return e&&nt(e).overview?"graview":"scene"}function gr(e,n){if(n.homeView?.()===void 0)return!1;let o=e.pages?.first?.trim();return o===void 0||o===""||o==="/"||o.toLowerCase()==="home"}function Tr(e){let[,n]=(0,c.useState)(!1),o=(0,c.useCallback)(()=>n(!0),[]),a=(0,c.useRef)(!1);return e.at&&!lt?(0,h.jsx)($t,{onReady:o,fetch:zt}):!a.current&&mr(e.draftView)?(0,h.jsx)($t,{onReady:o,fetch:Nt}):(a.current=!0,(0,h.jsx)(mo,{...e}))}function mo(e){let{app:n,stop:o,bar:a=!0,standing:d="Everything is in order",principal:l,heading:b=2}=e,{rootRef:p,scope:g,css:A,scheme:T,store:v,presence:P,brand:C,auto:S,height:N}=tr(e),ne=hr(e.draftView),V=Xn(e,zn,ne.over),[Z]=(0,c.useState)(On),u=e.basePath===void 0?{}:{basePath:e.basePath},[D]=(0,c.useState)(ot),q=e.notices??D,K=m=>Rt(m,u),x={...e.routing?{routing:e.routing}:{},...u},[de]=(0,c.useState)(()=>{let m=e.at?.face;if(m)return m;let F=o===void 0&&gr(n,V)?"pages":qt(o),me=Mt({...x,face:F});return e.face===void 0&&e.onOpening?.(me),me}),[$,O]=(0,c.useState)(()=>e.face!==void 0&&e.face!=="pages"&&!e.at&&o===void 0&&Gn(x)&&gr(n,V)),Pe=(0,c.useRef)(e.onFace);Pe.current=e.onFace,(0,c.useLayoutEffect)(()=>{$&&(Pe.current?.("pages"),O(!1))},[$]);let k=$?"pages":e.face??de,te=n.schema.kinds,R=e.routing==="address",J=(0,c.useMemo)(()=>e.at?lt.settleAt(e,v.seenBy(l??{kind:"human"}),V.places()):void 0,[]),B=(0,c.useMemo)(()=>Rn(V,n.schema),[V,n.schema]),ce=(0,c.useMemo)(()=>{let m=J?.stop??(R?Un(e.basePath):void 0)??o;return k==="scene"&&m===void 0&&B===void 0&&(e.path===void 0||_t(e.path))?Dt(void 0):Rr(k,m,te,V.places(),B)},[]),[we]=(0,c.useState)(k);(0,c.useEffect)(()=>{we!=="pages"&&An(V)},[we,V]);let W=(0,c.useRef)(void 0),z=m=>m===void 0||_t(m)?"/":m;W.current??={path:z(J?.path??(R?k==="pages"?(Tt(window.location.pathname,e.basePath)??"/")+window.location.search:"/":e.path)),asked:e.path},e.path!==W.current.asked&&(W.current={path:z(e.path),asked:e.path});let I=(0,c.useRef)(e.onNavigate);I.current=e.onNavigate;let le=(0,c.useCallback)((m,F)=>{W.current.path=m,I.current?.(m,F)},[]),{at:L,setAt:ke,steering:Y,steer:X}=ir(W.current.path),M=(0,c.useContext)(xr);M&&(M.pages=()=>W.current.path);let Ee=(0,c.useRef)(void 0),ue=(0,c.useCallback)(m=>void(W.current.path=m),[]),re=Wn(p),[Q,ze]=(0,c.useState)(!1),Ae=e.pagesBelow!==void 0&&re!==null&&re<e.pagesBelow&&(k==="scene"||k==="graview")&&!Q,E=Ae?"pages":k,Re=(0,c.useRef)(!1);Re.current=Q&&e.pagesBelow!==void 0&&re!==null&&re<e.pagesBelow&&(k==="scene"||k==="graview"),M&&(M.shown=E);let fe=(0,c.useRef)(k==="graview"?"graview":"scene");(E==="scene"||E==="graview")&&(fe.current=E),(0,c.useState)(()=>{if(!R||typeof window>"u"||E==="pages"||E==="picture")return;let{pathname:m,search:F,hash:me}=window.location;Tt(m,e.basePath)==="/"&&window.history.replaceState(window.history.state,"",`${K(ve)}${F}${me}`)}),er(p,E,e.onIntrinsicHeight),lo(E,re);let oe=sr(e.onError,E),He=dr(e.onReady,E),Te=(0,c.useRef)(e.onFaceDrawn);Te.current=e.onFaceDrawn;let pt=(0,c.useCallback)((m,F)=>{He(F),Te.current?.(m)},[He]),[mt,ht]=(0,c.useState)(null),G=V.places(),ee=(0,c.useRef)({shown:E,onFace:e.onFace});ee.current={shown:E,onFace:e.onFace};let U=(0,c.useCallback)((m,F,me)=>{if(R){Ee.current?.(m,F,me);return}ee.current.onFace?.(m),I.current?.(m==="pages"?F??W.current.path:ve,"push")},[R]),[Be,pe]=(0,c.useState)(void 0);(0,c.useEffect)(()=>{E==="pages"&&pe(void 0)},[E]);let Ge=(0,c.useRef)(o);(0,c.useEffect)(()=>{Ge.current!==o&&(Ge.current=o,pe(void 0))},[o]);let We=(0,c.useCallback)(m=>{if(ee.current.shown==="pages"){if(ze(!0),pe(m),k==="scene"||k==="graview"){yr(k,()=>{R?window.history.pushState(null,"",`${K(ve)}${m??""}`):I.current?.(ve,"push")});return}yr(fe.current,()=>U(fe.current,void 0,m))}},[R,k,e.basePath,U]),ae=(0,c.useCallback)(m=>{if(ee.current.shown==="pages"){Y.go.current||(W.current.path=m),X(m);return}if(W.current.path=m,ke(m),Re.current){ze(!1),R?window.history.pushState(null,"",K(m)):I.current?.(m,"push");return}U("pages",m)},[Y,X,ke,U,R,e.basePath]),Le=V.arrangement?.(),xe=E==="pages",_=e.hrefOf,ie=_??(R?K:void 0),Ue=(0,c.useMemo)(()=>({open:ae,..._?{href:_}:R?{href:m=>Rt(m,e.basePath===void 0?{}:{basePath:e.basePath})}:{}}),[ae,R,e.basePath,_]);return(0,h.jsxs)("section",{ref:p,className:g,"aria-label":e.label??n.name,"data-graview-embed":E,"data-graview-scheme":T,...Ae?{"data-graview-embed-narrow":""}:{},style:{position:"relative",isolation:"isolate",height:N,minHeight:S?0:320,display:"flex",flexDirection:"column",overflow:"hidden",borderRadius:"var(--graview-radius, 12px)"},children:[(0,h.jsx)("style",{children:A}),(0,h.jsxs)(Bn.Provider,{value:oe,children:[(0,h.jsx)(nr,{rootRef:p,board:q}),(0,h.jsx)(Zn,{rootRef:p,firstLook:e.firstLook,app:_n(C??{name:n.name},n.schema)}),(0,h.jsx)(_e,{module:"@graview/react",report:oe,content:!0,children:(0,h.jsx)(Fn.Provider,{value:Z,children:(0,h.jsx)(En,{store:v,views:V,initialView:ce,scheme:T,...rr(e,P,C),...e.onSeat?{onSeat:e.onSeat}:{},children:(0,h.jsxs)(Nn.Provider,{value:q,children:[(0,h.jsx)(wo,{face:E,stop:Be??o,kinds:te,places:G,opens:B}),M?(0,h.jsx)(ho,{into:M}):null,(0,h.jsx)(yo,{rootRef:p,face:k,shown:E,path:L,stop:o,draft:ne.n,onDrawn:e.onDrawn,parts:Z}),R?(0,h.jsx)(Kn,{pagesWere:J?.path,basePath:e.basePath,shown:E,onFace:e.onFace,toggle:Ee,kinds:te,places:G,opens:B,landed:ue}):null,a&&E!=="picture"?(0,h.jsx)(_e,{module:"@graview/embed",report:oe,children:(0,h.jsx)(or,{name:C?.name??n.name,heading:b,named:Ht(a).name!==!1,faces:Ht(a).faces===!1?void 0:{scene:{label:gn(Le),current:!xe,go:()=>We(),reach:()=>void Oe(fe.current)},pages:{label:wn(Le),current:xe,go:()=>ae(W.current.path),reach:()=>void Oe("pages")}},at:xe?L:null,without:e.pages?.without(),home:{...ie?.("/")!==void 0?{href:ie("/")}:{},go:()=>ae("/"),current:xe&&L.split("?")[0]==="/"},reach:{...ie?{href:ie}:{},go:m=>ae(m.path)},standing:d,hostActions:e.hostActions,keeping:xe?void 0:(0,h.jsx)(vo,{app:n,studio:e.studio,report:oe}),onFind:ht,switch:e.switch})}):null,(0,h.jsx)(In.Provider,{value:mt,children:(0,h.jsx)(_e,{module:E==="pages"||E==="picture"?"@graview/pages":"@graview/react",report:oe,content:!0,children:(0,h.jsxs)(c.Suspense,{fallback:(0,h.jsx)(fo,{auto:S,scene:E!=="pages"&&E!=="picture"}),children:[E==="picture"?(0,h.jsx)(io,{scope:g,store:v,views:V,as:(o?nt(o).within?.view:void 0)??""}):E==="pages"?(0,h.jsx)(ao,{store:v,views:V,presence:P,auto:S,brand:C,steering:Y,overview:We,scope:g,titleLevel:ar(b),quickAsk:at(e.quickAsk),props:{...e,onNavigate:le,...R?{}:{path:W.current.path}}}):(0,h.jsx)(Hn.Provider,{value:Ue,children:(0,h.jsx)(ro,{address:R,auto:S,scheme:T,scope:g,quickAsk:at(e.quickAsk)})}),(0,h.jsx)(uo,{asked:k,shown:E,onDrawn:pt})]})},E)})]})})})})]})]})}var _t=e=>e.split(/[?#]/)[0]===ve,xr=(0,c.createContext)(null);function ho({into:e}){return e.view=rt().view,null}function yo({rootRef:e,face:n,shown:o,path:a,stop:d,draft:l,onDrawn:b,parts:p}){let{view:g}=rt(),A=o==="scene"||o==="graview",T=Ft(g),v={face:n,path:A?ve:o==="picture"?d??"#":a,stop:T};return fr(e,`${o} ${A?T:v.path} ${l}`,v,b,p),null}var lt,go=be(()=>(__graviewPreload(import.meta.url,["./chunk.J6ANRF6E.js","./chunk.2UIUMG23.js","./chunk.KA44WNB4.js","./chunk.SDO3U72B.js","./chunk.4TJOS4C7.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.YVOABA2U.js"))),zt=()=>go().then(e=>void(lt=e),()=>new Promise(e=>{let n=()=>{window.removeEventListener("online",n),clearTimeout(o),e()},o=setTimeout(n,1e4);window.addEventListener("online",n)}).then(zt));function wo({face:e,stop:n,kinds:o,places:a,opens:d}){let{view:l,go:b}=rt(),p=(0,c.useRef)({face:e,stop:n});return(0,c.useLayoutEffect)(()=>{let g=p.current.stop!==n,A=p.current.face!==e,T=p.current.face==="pages";if(p.current={face:e,stop:n},!g&&!A||e==="pages"||e==="picture")return;let v=(g||T)&&n!==void 0?Rr(e,n,o,a):T&&Yn(l)?Vt(e,Dt(d),o):e==="graview"?Ot(l,!0):l.overview?Pn(Ot(l,!1),jn(l,o)):l;b(v)},[e,n,o,l,b,d]),null}function vo({app:e,studio:n,report:o}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(c.Suspense,{fallback:null,children:(0,h.jsx)(oo,{})}),n!==!1?(0,h.jsx)(_e,{module:"@graview/studio",report:o,children:(0,h.jsx)(bo,{app:e,studio:n})}):null]})}function bo({app:e,studio:n}){let o={app:e,within:"box",...n?{onApply:n.onApply}:{},...n?.landmark?{landmark:n.landmark}:{},...n?.offered!==void 0?{offered:n.offered}:{}},a=n?.place;return a?(0,h.jsx)(a,{...o}):(0,h.jsx)(c.Suspense,{fallback:null,children:(0,h.jsx)(po,{...o})})}function So({path:e,stop:n,...o},a){return{...o,app:a.app,at:a.at,...a.remote.presence?{presence:a.remote.presence}:{}}}function Gt(e,n){let o=n.store??n.remote?.store??Qn(n.app,n.seed),a=n.notices??ot(),d=null,l={},b=0,p=n.label,g=n.app,A=Promise.resolve(),T=n.at?.face??n.face,v=T===void 0?void 0:Mt({...n,face:T}),P=v??qt(n.stop),C=null,S=[],N=u=>{if(C=u,u!==P)return;let D=S;S=[];for(let q of D)q()};function ne(){let[u,D]=(0,c.useState)(v),[q,K]=(0,c.useState)(n.stop),[x,de]=(0,c.useState)(n.path),[$,O]=(0,c.useState)(n.scheme??"auto"),[Pe,k]=(0,c.useState)(n.principal),[te,R]=(0,c.useState)(n.seats),[J,B]=(0,c.useState)(n.quickAsk),[ce,we]=(0,c.useState)(n.people),[W,z]=(0,c.useState)(n.hostContext),[I,le]=(0,c.useState)(n.brand),[L,ke]=(0,c.useState)(n.label),[Y,X]=(0,c.useState)(n.hostActions),[M,Ee]=(0,c.useState)(void 0),[ue,re]=(0,c.useState)(n.draftView);return d={app:Q=>{Ee(Q),de(void 0),K(void 0)},face:D,stop:K,path:de,scheme:O,seat:k,seats:R,quickAsk:B,people:we,hostContext:z,brand:le,label:ke,hostActions:X,draft:re},(0,h.jsx)(xr.Provider,{value:l,children:(0,h.jsx)(Tr,{...M?So(n,M):n,store:o,notices:a,...u!==void 0?{face:u}:{},onOpening:Q=>{P=Q},...q!==void 0?{stop:q}:{},...x!==void 0?{path:x}:{},...Pe?{principal:Pe}:{},...te?{seats:te}:{},...J!==void 0?{quickAsk:J}:{},...ce?{people:ce}:{},...W?{hostContext:W}:{},...I?{brand:I}:{},label:L,hostActions:Y,draftView:ue,scheme:$,onFace:Q=>{P=Q,D(Q)},onSeat:k,onFaceDrawn:N},M?.n??0)})}let V=()=>{let u=l.view?.focusId,D=u?o.graph.getNode(u)?.kind:void 0,q=(l.shown??P)==="scene"||(l.shown??P)==="graview";return{face:P,path:q?ve:l.pages?.()??n.path??"/",stop:l.view?Ft(l.view):n.stop??"#",...D?{kind:D}:{}}},Z=(0,wr.createRoot)(e);return(0,j.flushSync)(()=>Z.render((0,h.jsx)(ne,{}))),{get store(){return o},where:V,setApp:(u,D,q)=>{let K="graph"in D?{store:D}:D,x=()=>{let de=V();o=K.store,p=q?.label??(p===g.name?u.name:p),g=u,(0,j.flushSync)(()=>{d?.label(p),d?.app({app:u,remote:K,at:de,n:++b})})};lt?x():A=A.then(zt).then(x)},setFace:u=>{P=u,(0,j.flushSync)(()=>d?.face(u))},setStop:u=>(0,j.flushSync)(()=>d?.stop(u)),setPath:u=>(0,j.flushSync)(()=>{if(_t(u)){(P==="pages"||P==="picture")&&(P="scene",d?.face("scene"));return}d?.path(u),P!=="pages"&&(P="pages",d?.face("pages"))}),setScheme:u=>(0,j.flushSync)(()=>d?.scheme(u)),setSeat:u=>(0,j.flushSync)(()=>d?.seat(u)),setSeats:u=>(0,j.flushSync)(()=>d?.seats(u)),setQuickAsk:u=>(0,j.flushSync)(()=>d?.quickAsk(u)),setPeople:u=>(0,j.flushSync)(()=>d?.people(u)),setHostContext:u=>(0,j.flushSync)(()=>d?.hostContext(u)),setBrand:u=>(0,j.flushSync)(()=>d?.brand(u)),setDraftView:u=>(0,j.flushSync)(()=>d?.draft(u)),setLabel:u=>{p=u,(0,j.flushSync)(()=>d?.label(u))},setHostActions:u=>(0,j.flushSync)(()=>d?.hostActions(u)),drawn:()=>A.then(()=>C===P?void 0:new Promise(u=>S.push(u))),notify:u=>{let D;return(0,j.flushSync)(()=>{D=a.notify(u)}),D},unmount:()=>Z.unmount()}}var Fr="/graview/live",Ut="graview.ship",Kt=`${Ut}.${Xe}`;var ge={seat:"x-graview-seat",roles:"x-graview-roles",kind:"x-graview-kind",name:"x-graview-name",for:"x-graview-for",forRoles:"x-graview-for-roles",forName:"x-graview-for-name",via:"x-graview-via"};var Ve=class extends Error{constructor(n){super(n),this.name="Superseded"}},Se=e=>e?.lineage?{lineage:e.lineage}:{},Po=(e,n)=>`${e.calls.map(o=>o.name.replace(/-/g," ")).join(", ")} (${n instanceof Error?n.message.split(`
|
|
2
|
+
`)[0]??"":String(n)})`;function ko(e){if(!e)return[];try{let n=e.storage.getItem(e.key);if(n===null)return[];e.storage.removeItem(e.key);let o=JSON.parse(n);return Array.isArray(o)?o.filter(a=>!!a&&Array.isArray(a.calls)):[]}catch{return[]}}var De=class extends Error{constructor(o){super(o.sentence);this.refusal=o;this.name="RemoteRefusedError"}},Eo={401:"forbidden",403:"forbidden",404:"missing",413:"limit"},Ce=class extends Error{constructor(o,a){super(o);this.conflicts=a;this.name="StaleWrite"}},qe=class extends Error{constructor(n){super(n),this.name="Unreached"}},Ao=new Set([502,503,504]);async function Ro(e){try{return(await e.clone().json()).reason==="unavailable"}catch{return!1}}function To(){let e=Math.random().toString(36).slice(2,8),n=0;return()=>`local-${e}-${++n}`}var xo=1,Fo=()=>({refusals:new Set,conflicts:new Set,statuses:new Set,helds:new Set,builds:new Set,who:new Set,declarations:new Set,tally:{reconnects:0,rebases:0,conflicts:0,resyncs:0}});async function ut(e){return(await Cr(e,ko(e.carry),"This app was updated while your changes were on the way.",Fo())).remote}async function Cr(e,n,o,a){let d=e.fetch??fetch,l={"content-type":"application/json",...e.headers??{}},b={...ft(e.principal),[ge.via]:e.via??"web"};Object.assign(l,b);let p=e.live===!0,g=e.presenceEveryMs,A=e.visible??Lo,T="connecting",v=a.statuses,P=a.tally,C=[],S,N=[],ne=()=>T==="online"&&S!==void 0?"held":T,V=()=>{let t=ne();if(a.told!==t){a.told=t;for(let r of[...v])r(t)}},Z=t=>{if(!(t===T||se)&&(T==="offline"&&t==="online"&&P.reconnects++,T=t,V(),t==="online"))for(let r of C.splice(0))r.again()},u=t=>{if(se)return;let r=typeof t=="string"&&t.length>0?t:void 0,s=r!==S;if(S=r,D(),!!s&&(V(),r===void 0)){for(let i of N.splice(0))i();F&&clearTimeout(F),me()}},D=()=>{if(a.toldHeld!==S){a.toldHeld=S;for(let t of[...a.helds])t(S??null)}},q=async(t,r)=>{let s;try{s=await d(t,r)}catch(i){throw _()||Z("offline"),new qe(i instanceof Error?i.message:String(i))}if(s.status===503&&await Ro(s))return Z("online"),s;if(Ao.has(s.status))throw _()||Z("offline"),new qe(`The server is away (${s.status})`);return Z("online"),s},K=async(t=!1)=>{let r=`${e.url}/graview/state?opFormat=${Ie.op}`,s=t?await d(r,{headers:l}):await q(r,{headers:l});if(!s.ok)throw new Error((await s.json().catch(()=>({}))).error??`The server refused (${s.status})`);return await s.json()},x=e.state??await K(!0);p||(T="online"),S=typeof x.held=="string"&&x.held.length>0?x.held:void 0,D();let de=x.enabledModules??e.enabledModules,$=e.localApp?e.localApp(e.app):e.app,O=new yn({schema:$.schema,mutations:$.mutations??[],invariants:$.invariants??[],...$.policy?{policy:$.policy}:{},...$.modules?{modules:$.modules}:{},...de?{enabledModules:de}:{},...$.intelligence?{intelligence:$.intelligence}:{},...$.brand?.timeZone?{timeZone:$.brand.timeZone}:{},snapshot:x.snapshot,log:x.log,...x.horizon!==void 0?{horizon:x.horizon}:{},ids:To(),...e.storeOptions??{}});pn.served.add(O);let Pe=mn(O),k=x.log.at(-1)?.seq??(x.horizon??0)-1,te=At.of(x.log,{horizon:x.horizon??0}),R=null,J,B=new Map,ce=a.who,we=!1,W=t=>{if(se)return;we=!0;let r=vn(new Map,t,Date.now(),1e4,R?.participant);J!==void 0&&r.delete(J);let s=r.size!==B.size;if(!s)for(let[i,f]of r)xt(f,B.get(i))||(s=!0);if(B=r,!!s)for(let i of[...ce])i([...B.values()])},z=[],I=new Set,le=t=>{let r=z.indexOf(t);r>=0&&z.splice(r,1)},L=new Map,ke=(t,r)=>{let s=L.get(t);s&&(L.delete(t),s.resolve({ops:r.filter(i=>i.batch===t),batch:t}))},Y,X=[],M=(t,r=[])=>{if(t.length===0&&r.length===0)return[];if(Y)return X.push({ops:t,drop:r}),[];let s=Math.min(...t.filter(w=>w.seq>k).map(w=>w.seq));if(Number.isFinite(s)&&s>k+1)return X.push({ops:t,drop:r}),Ee(),[];let i=z.filter(w=>t.some($e=>$e.batch===w)),f=[...new Set([...r,...i])].filter(w=>I.has(w)),y,H=z.filter(w=>!i.includes(w));try{y=O.rebase({confirmed:t,pending:H,drop:f}).confirmed}catch(w){if(!(w instanceof hn))throw w;return X.push({ops:t,drop:r}),Ee(),[]}for(let w of i)le(w);t.some(w=>w.seq>k)&&H.some(w=>!f.includes(w))&&P.rebases++,t.length>0&&(k=Math.max(k,...t.map(w=>w.seq)),te.note(t));for(let w of f)I.delete(w);for(let w of i)ke(w,t);return y},Ee=()=>{Y||(Y=oe(K().then(t=>{if(ue(t)){X=[];return}let r=new Set(t.log.map(f=>f.batch)),s=z.filter(f=>r.has(f));for(let f of s)le(f);let i=O.adopt({snapshot:t.snapshot,log:t.log,...t.horizon!==void 0?{horizon:t.horizon}:{},pending:[...z],drop:[...I].filter(f=>!z.includes(f))});I.clear();for(let f of i.pending)I.add(f.batch);k=t.log.at(-1)?.seq??(t.horizon??0)-1,te=At.of(t.log,{horizon:t.horizon??0}),P.resyncs++;for(let f of s)ke(f,t.log)}).then(()=>{Y=void 0;let t=X;X=[];for(let{ops:r,drop:s}of t)M(r,s)},()=>{Y=void 0,X=[]})))},ue=t=>(typeof t.build=="string"&&en(t.build),typeof t.version=="number"&&u(t.held),typeof t.version!="number"||t.version===x.version?!1:(vt(t.version),!0)),re=async t=>{let s=await(await q(`${e.url}/graview/since?seq=${t}&opFormat=${Ie.op}`,{headers:l})).json();return ue(s)?[]:s.ops??[]},Q=async()=>{let t=await ze();return Y&&await Y,t},ze=async()=>{if(R&&!_()&&A()){let r=await(await q(`${e.url}/graview/here`,{method:"POST",headers:l,body:JSON.stringify({presence:R,seq:k})})).json();return ue(r)?[]:(typeof r.participant=="string"&&(J=r.participant),W(r.who??[]),M(r.ops??[]))}return M(await re(k))},Ae=new Map,E=new Map,Re=new Map,fe=new Set,oe=t=>(fe.add(t),t.finally(()=>fe.delete(t)).catch(()=>{}),t),He=Promise.resolve(),Te=0,pt=(t,r)=>{let s=He.then(()=>ht(t,r));return He=s.catch(()=>{}),s},mt=()=>new Promise((t,r)=>C.push({again:t,give:r})),ht=async(t,r)=>{let s,i;for(;;){try{s=await q(`${e.url}/graview/ops`,{method:"POST",headers:l,body:JSON.stringify({...t,opFormat:Ie.op})})}catch(w){if(!(w instanceof qe)||U)throw w;if(await mt(),_())return Ke(t,r);continue}if(i=await s.json().catch(()=>({})),s.status===503&&i.reason==="unavailable"&&typeof i.held=="string"&&!U){if(typeof i.version=="number"?ue(i):(u(i.held),!1))break;if(S!==void 0&&(Pt>0||p)){if(await new Promise(w=>N.push(w)),U)throw new Ve("The client closed.");if(_())return Ke(t,r);continue}}let H;if(s.status===503&&i.reason==="unavailable"&&!U)H=Jt(e.backoff,Te++);else{if(Te=0,s.status!==429||U)break;H=Oo(s.headers.get("retry-after"),i.retryAfter)}if(await new Promise(w=>setTimeout(w,H)),_())return Ke(t,r)}if(se||ue(i))throw new Ve("The app was changed.");if(!s.ok){let H=i.error??`The server refused (${s.status})`;throw i.conflict?new Ce(H,i.conflicts??[]):new De({reason:i.reason??Eo[s.status]??"invalid",sentence:H,...i.wouldNeed?.length?{wouldNeed:i.wouldNeed}:{}})}let f=i.ops??[],y=f[0]?.seq;return y!==void 0&&y>k+1&&(f=await re(k)),r!==void 0&&(i.batch&&Ae.set(r,i.batch),le(r)),M(f,r!==void 0?[r]:[]),{ops:i.ops??[],...i.batch?{batch:i.batch}:{}}},G,ee=!1,U=!1,Be=0,pe,Ge=0,We=0,ae=null,Le=()=>{},xe=new Promise(t=>{Le=t}),_=()=>p&&ee&&G?.readyState===xo,ie=t=>{if(!_())return!1;try{return G.send(JSON.stringify(t)),!0}catch{return!1}},Ue=(t=!1)=>{!R||!_()||!A()||!t&&ae&&xt(R,ae)&&(g===void 0||Date.now()-We<g)||ie({t:"here",presence:R})&&(ae=R,We=Date.now())},m=new Set,F,me=()=>{if(F=void 0,S!==void 0)return;let t=[...L.entries()].filter(([r])=>m.has(r));m.clear();for(let[,r]of t)ie(r.message)},Xt=(t,r)=>{L.has(t)&&(m.add(t),F&&clearTimeout(F),F=setTimeout(me,Math.max(0,r)))},Vr=t=>{L.has(t)&&m.add(t)},Ke=(t,r)=>new Promise((s,i)=>{let f=r??`send-${++Ge}`,y=t.undo?{t:"undo",cid:f,batches:t.undo,...t.intent?{intent:t.intent}:{},...t.batch?{batch:t.batch}:{},...t.via?{via:t.via}:{},...Se(t)}:{t:"call",cid:f,calls:t.calls??[],...t.intent?{intent:t.intent}:{},...t.batch?{batch:t.batch}:{},...t.base?.length?{base:t.base}:{},...t.via?{via:t.via}:{},...Se(t)};if(L.set(f,{message:y,...r!==void 0?{mine:r}:{},resolve:s,reject:i}),m.size>0||S!==void 0){m.add(f);return}ie(y)}),yt=(t,r)=>_()?Ke(t,r):pt(t,r),Dr=t=>{switch(t.t){case"welcome":{if(en(t.build),typeof t.version=="number"&&t.version!==x.version){vt(t.version);return}if(ee=!0,Be=0,typeof t.participant=="string"&&(J=t.participant),u(t.held),M(t.ops??[]),m.clear(),F&&clearTimeout(F),F=void 0,S!==void 0)for(let r of L.keys())m.add(r);else for(let r of L.values())ie(r.message);Ue(!0),Z("online"),Le();return}case"ops":M(t.ops??[]);return;case"ack":{let r=L.get(t.cid);if(!r){M(t.ops??[]);return}L.delete(t.cid),Te=0,r.mine!==void 0&&(Ae.set(r.mine,t.batch),le(r.mine)),M(t.ops??[],r.mine!==void 0?[r.mine]:[]),r.resolve({ops:t.ops??[],batch:t.batch});return}case"refused":case"conflict":{let r=L.get(t.cid);if(!r)return;if(t.t==="refused"&&t.reason==="unavailable"){S!==void 0?Vr(t.cid):Xt(t.cid,Jt(e.backoff,Te++));return}L.delete(t.cid),r.reject(t.t==="conflict"?new Ce(t.sentence,t.conflicts??[]):new De({reason:t.reason??"invalid",sentence:t.sentence,...t.wouldNeed?.length?{wouldNeed:[...t.wouldNeed]}:{}}));return}case"busy":typeof t.cid=="string"&&Xt(t.cid,typeof t.retryAfter=="number"?t.retryAfter:1e3);return;case"presence":W(t.who??[]);return;case"held":u(t.sentence);return;case"declaration":typeof t.version=="number"&&t.version!==x.version&&vt(t.version);return;case"reload":on(typeof t.reason=="string"?t.reason:"This app was updated.");return;case"error":if(t.reopen===!0&&G){let r=G;sn(r);try{r.close(1e3,"Opening again.")}catch{}}return;default:return}},se=!1,gt=a.declarations,wt=a.builds,en=t=>{if(!(se||a.otherBuild!==void 0||!e.build||typeof t!="string"||t.length===0||t===e.build)){a.otherBuild=t;for(let r of[...wt])r(t)}},tn=()=>{let t=[],r=0;for(let s of z){let i=Re.get(s);i?t.push({calls:i.calls,...i.intent?{intent:i.intent}:{},...i.via?{via:i.via}:{},...Se(i),batch:s}):r++}return{carried:t,undos:r}},nn=(t,r)=>`${r} while ${t===1?"an undo of yours was":"undos of yours were"} on the way; ${t===1?"it was":"they were"} not made.`,rn=t=>{se=!0,R=null;let r=new Ve(t);for(let i of L.values())i.reject(r);L.clear(),Qe&&clearInterval(Qe),U=!0,pe&&clearTimeout(pe),F&&clearTimeout(F),he&&clearTimeout(he);for(let i of C.splice(0))i.give(r);for(let i of N.splice(0))i();let s=G;G=void 0,ee=!1;try{s?.close(1e3,t)}catch{}Le()};async function vt(t){if(se)return;if(!e.resolveApp){on(`This app was changed on its server (version ${t}); reload the page to carry on.`);return}let{carried:r,undos:s}=tn(),i=e.resolveApp,f=R;rn("The app was changed.");try{let y=await i(t),{state:H,...w}=e,$e=await Cr({...w,app:y},r,"The app was changed while your changes were on the way.",a);f&&$e.remote.presence.here(f);for(let Ze of[...gt])Ze($e.remote,t);let _r=[...s>0?[Je(nn(s,"The app was changed"))]:[],...$e.unheard()];for(let Ze of _r)for(let jr of Me)jr(Ze.sentence,Ze)}catch(y){let H=`The app was changed, but the new version could not be opened: ${y instanceof Error?y.message:String(y)}`;for(let w of Me)w(H,Je(H))}}function on(t){if(se)return;let{carried:r,undos:s}=tn();rn(t);let i=!1;if(e.carry&&r.length>0)try{e.carry.storage.setItem(e.carry.key,JSON.stringify(r)),i=!0}catch{}let f=[];!i&&r.length>0&&f.push(`${t} ${r.length===1?"A change of yours was":`${r.length} changes of yours were`} not sent; make ${r.length===1?"it":"them"} again after the page reloads.`),s>0&&f.push(nn(s,"This app was updated"));for(let y of f)for(let H of Me)H(y,Je(y));(e.reloadPage??Co)()}let an=()=>{if(U||!p)return;let t=`${e.url.replace(/^http/,"ws").replace(/\/$/,"")}${Fr}`,{"content-type":r,...s}=l,i;try{i=e.socket?e.socket(t,s,[Kt]):Ir(t,s)}catch{return dn()}G=i,ee=!1,i.onopen=()=>{G===i&&i.send(JSON.stringify({t:"hello",seq:k,protocol:Xe,wire:Ut,opFormat:Ie.op,...e.build?{build:e.build.slice(0,64)}:{},...e.hostProtocol!==void 0?{hostProtocol:e.hostProtocol}:{}}))},i.onmessage=f=>{if(G!==i)return;let y;try{y=JSON.parse(String(f.data))}catch{return}Dr(y)},i.onclose=()=>sn(i),i.onerror=()=>{}},he,Hr=()=>{we=!1,he&&clearTimeout(he),he=setTimeout(()=>{if(he=void 0,we||U)return;let t=new Map([...B].filter(([,r])=>r.held!=="socket"));if(t.size!==B.size){B=t;for(let r of ce)r([...B.values()])}},1e4),he.unref?.()};function sn(t){if(G!==t)return;let r=ee;G=void 0,ee=!1,ae=null,r&&(Z("offline"),Hr()),dn()}let dn=()=>{if(U)return;let t=Jt(e.backoff,Be);Be++,pe=setTimeout(an,t)},Br=O.applyAll.bind(O),Wr=O.undo.bind(O),Nr=O.previewAll.bind(O);O.previewAll=(t,r)=>Nr(t,{...e.principal?{author:e.principal}:{},...r});let Me=a.refusals,Ne=[],Je=t=>({reason:"invalid",sentence:t}),Ye=a.conflicts,bt=!1,cn=async(t,r)=>{if(r instanceof Ve||se)return;let s=r instanceof De?r.refusal:un(r),i=s.sentence;le(t);try{M([],[t])}catch{}let f=Re.get(t);if(Re.delete(t),r instanceof Ce&&P.conflicts++,r instanceof Ce&&!_()&&await Q().catch(()=>[]),r instanceof Ce&&Ye.size>0){let y=!1,H={sentence:i,conflicts:r.conflicts,keepTheirs(){y=!0},useMine(){if(!(y||!f)){y=!0,bt=!0;try{O.applyAll(f.calls,{...f.intent?{intent:f.intent}:{},...f.via?{via:f.via}:{},...Se(f)})}finally{bt=!1}}}};for(let w of Ye)w(H);return}for(let y of Me)y(i,s)};O.applyAll=(t,r)=>{let s=fn(O.log.all().filter(y=>I.has(y.batch))),i=Br(t,{...e.principal?{author:e.principal}:{},...r});z.push(i.batch),I.add(i.batch),Re.set(i.batch,{calls:t,...r?.intent?{intent:r.intent}:{},...r?.via?{via:r.via}:{},...Se(r)});let f=bt?[]:te.baseFor(i.ops,s);return E.set(i.batch,oe(yt({calls:t,...r?.intent?{intent:r.intent}:{},batch:i.batch,...f.length>0?{base:f}:{},...r?.via?{via:r.via}:{},...Se(r)},i.batch).catch(y=>cn(i.batch,y)))),i},O.apply=(t,r)=>O.applyAll([t],r),O.undo=(t,r)=>{let s=typeof t=="string"?[t]:t,i=Wr(s.map(y=>Ae.get(y)??y),{...e.principal?{author:e.principal}:{},...r});z.push(i.batch),I.add(i.batch);let f=Promise.allSettled(s.map(y=>E.get(y)));return E.set(i.batch,oe(f.then(()=>yt({undo:s.map(y=>Ae.get(y)??y),...r?.intent?{intent:r.intent}:{},batch:i.batch,...r?.via?{via:r.via}:{},...Se(r)},i.batch)).catch(y=>cn(i.batch,y)))),i};let $r=async(t,r={})=>{St++;try{return(await oe(yt({calls:t,...r}))).ops}finally{St--}},St=0,ln={here(t){R=t,Ue()},onWho(t){return ce.add(t),B.size>0&&t([...B.values()]),()=>{ce.delete(t)}},leave(){if(!R)return;let t=JSON.stringify({participant:J??R.participant});if(R=null,ie({t:"bye"}))return;let r=globalThis.navigator?.sendBeacon;r?r.call(globalThis.navigator,`${e.url}/graview/leave`,t):d(`${e.url}/graview/leave`,{method:"POST",headers:l,body:t}).catch(()=>{})}},Pt=e.pollMs??800,Qe=Pt>0&&typeof setInterval=="function"?setInterval(()=>{_()||Q().catch(()=>{})},Pt):null;if(p){an();let t;await Promise.race([xe,new Promise(r=>t=setTimeout(r,e.openTimeoutMs??3e3))]),clearTimeout(t)}if(n.length>0&&!se){let t=[],r=new Set(O.log.all().map(s=>s.batch));for(let s of n)if(!(s.batch!==void 0&&r.has(s.batch)))try{O.applyAll(s.calls,{...s.intent?{intent:s.intent}:{},...s.batch?{batch:s.batch}:{},...s.via?{via:s.via}:{},...Se(s)})}catch(i){t.push(Po(s,i))}t.length>0&&Ne.push(Je(`${o} ${t.length===1?"One no longer fits and was not made":`${t.length} no longer fit and were not made`}: ${t.join("; ")}.`))}return{remote:{store:O,version:x.version,migrated:x.migrated??[],send:$r,pull:Q,onRefusal(t){Me.add(t);let r=Ne;Ne=[];for(let s of r)t(s.sentence,s);return()=>Me.delete(t)},onDeclaration(t){return gt.add(t),()=>gt.delete(t)},onBuild(t){return wt.add(t),a.otherBuild!==void 0&&t(a.otherBuild),()=>wt.delete(t)},onConflict(t){return Ye.add(t),()=>Ye.delete(t)},revision:(t,r)=>te.of(t,r),seq:()=>k,participant:()=>J,transport:()=>_()?"socket":"poll",status:ne,onStatus(t){return v.add(t),()=>v.delete(t)},held:()=>S,onHeld(t){return a.helds.add(t),S!==void 0&&t(S),()=>a.helds.delete(t)},counters:()=>({...P}),who:()=>[...B.values()],pending:()=>z.length+St,async settled(){for(;fe.size>0;)await Promise.allSettled([...fe])},presence:ln,close(){Qe&&clearInterval(Qe),Pe(),ln.leave(),U=!0,pe&&clearTimeout(pe),F&&clearTimeout(F),he&&clearTimeout(he);for(let r of C.splice(0))r.give(new Error("The client closed before the server could be reached."));for(let r of N.splice(0))r();let t=G;G=void 0,ee=!1;try{t?.close(1e3,"Closed.")}catch{}}},unheard(){let t=Ne;return Ne=[],t}};function Ir(t,r){let s=globalThis.WebSocket;if(!s)throw new Error("This runtime has no WebSocket; the client polls instead.");let i=typeof globalThis.document<"u",f=e.subprotocol?[Kt]:[];if(!i)try{return new s(t,{headers:r,...f.length>0?{protocols:f}:{}})}catch{}let y=new URL(t);for(let[H,w]of Object.entries(b))y.searchParams.set(H,w);return f.length>0?new s(y.toString(),f):new s(y.toString())}}function Oo(e,n,o=Date.now()){let a,d=e?.trim();if(d)if(/^\d+(\.\d+)?$/.test(d))a=Number(d)*1e3;else{let p=Date.parse(d);Number.isFinite(p)&&(a=Math.max(0,p-o))}let l=typeof n=="number"&&Number.isFinite(n)&&n>=0?n:void 0,b=l!==void 0&&l<50&&a!==void 0&&Math.abs(l*1e3-a)<1e3;return l!==void 0&&!b?l:a??1e3}function Co(){globalThis.location?.reload?.()}function Lo(){return globalThis.document?.visibilityState!=="hidden"}function Jt(e,n){if(typeof e=="function")return Math.max(0,e(n));let{min:o=250,max:a=1e4,factor:d=2}=e??{};return Math.min(a,o*d**n)*(.75+Math.random()*.5)}function ft(e){let n={};if(!e)return n;e.id&&(n[ge.seat]=e.id),e.roles?.length&&(n[ge.roles]=e.roles.join(",")),e.kind!=="human"&&(n[ge.kind]=e.kind),e.name&&(n[ge.name]=encodeURIComponent(e.name));let o=e.onBehalfOf;return o?.id&&(n[ge.for]=o.id),o?.roles?.length&&(n[ge.forRoles]=o.roles.join(",")),o?.name&&(n[ge.forName]=encodeURIComponent(o.name)),n}var Lr="/graview/views";function Yt(e){let n=e.fetch??fetch,o=e.url.replace(/\/$/,""),a={"content-type":"application/json",...e.principal?ft(e.principal):{},...e.headers??{}},d=e.state?{hidden:e.state.hidden??[],removed:e.state.removed??[],may:e.state.may??et.may}:et,l=new Set,b=v=>{if(JSON.stringify(v)!==JSON.stringify(d)){d=v;for(let P of l)P()}},p=async(v,P)=>{let C=await n(`${o}${e.path??Lr}`,{method:v,headers:a,...P!==void 0?{body:JSON.stringify(P)}:{}}),S=await C.json();if(!C.ok)throw new Error(S.error??`The store answered ${C.status}.`);b({hidden:S.hidden??[],removed:S.removed??[],may:S.may??et.may})},g=()=>p("GET"),A=e.state?Promise.resolve():g().catch(()=>{}),T=e.pollMs?setInterval(()=>void g().catch(()=>{}),e.pollMs):void 0;return{ready:A,refresh:g,close:()=>clearInterval(T),current:()=>d,onChange(v){return l.add(v),()=>void l.delete(v)},hide:v=>p("POST",{hide:v}),show:v=>p("POST",{show:v}),remove:(v,P)=>p("POST",{remove:v,...P?{about:P}:{}}),async restore(v){let P=d.removed.find(C=>C.name===v)?.lens;await p("POST",{restore:v}),P&&await e.onDeclaration?.()},async lens(v){await p("POST",{lens:v}),await e.onDeclaration?.()}}}var Zt=document.getElementById("graview-app"),Qt=/^\/forms\/([^/]+)\/?$/.exec(location.pathname),Mr=Qt?(__graviewPreload(import.meta.url,["./chunk.2QNGGF55.js","./chunk.Y4MQGEUS.js","./chunk.UGFDSE37.js","./chunk.EXEZBZGW.js","./chunk.X7N3JUO4.js","./chunk.NTLHEHOM.js","./chunk.GNBN3BK7.js","./chunk.XTMOFRHL.js","./chunk.NLBIX7LH.js","./chunk.GACKGEUY.js","./chunk.UJRBOUGC.js","./chunk.DWPU56S5.js","./chunk.ZH4NWRWB.js","./chunk.2GLJH253.js","./chunk.GUMJEVVP.js","./chunk.4VW6THJF.js","./chunk.SAHNXAV3.js","./chunk.DHAK6PPX.js","./chunk.YDL5BSTG.js","./chunk.DUWYF7BO.js","./chunk.UGJSMNVO.js","./chunk.NR5ODXMO.js","./chunk.XOZU4OFA.js","./chunk.SUPWMV2F.js","./chunk.MB7LKKUD.js","./chunk.V4BCB7N2.js","./chunk.FOP5RBGF.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.FPYL6REZ.js")):Oe("pages");try{Qt?await Mo(decodeURIComponent(Qt[1])):await Vo()}catch(e){let n=document.createElement("pre");n.setAttribute("role","alert"),n.style.cssText="margin:2rem;font:14px/1.5 ui-monospace,monospace;white-space:pre-wrap",n.textContent=e instanceof Error?e.message:String(e),Zt.replaceChildren(n),window.__graviewFailed=n.textContent}async function Mo(e){let n=await fetch(`/graview/document?form=${encodeURIComponent(e)}`),o=await n.json();if(!n.ok)throw new Error(o.error??`The preview server did not hand over the form (${n.status}).`);let a=await it(o);if(!a.ok)throw new Error(tt(a.findings));let d=a.app,l=o.principal,b=await ut({app:d,url:location.origin,principal:l,...o.state?{state:o.state,openTimeoutMs:0}:{openTimeoutMs:3e3}});document.title=d.forms?.[e]?.title??d.name;let{mount:p}=await Mr;window.__graview=p(Zt,{app:d,form:e,principal:l,remote:b,height:"100dvh",onSubmitted:()=>window.__graviewSubmitted=!0}),window.__graviewReady=!0}async function Vo(){let e=await fetch("/graview/document");if(!e.ok)throw new Error(`The preview server did not hand over the document (${e.status}).`);let n=await e.json(),a=await(async g=>{if(typeof g.module=="string")return(await import(g.module)).app;let A=await it(g);if(!A.ok)throw new Error(tt(A.findings));return A.app})(n);if(!a||typeof a!="object"||!("schema"in a))throw new Error("The app module the preview server handed does not export an app.");let d=n.principal,l=await ut({app:a,url:location.origin,principal:d,live:!0,subprotocol:!0,pollMs:1200,...n.state?{state:n.state,openTimeoutMs:0}:{openTimeoutMs:3e3}});document.title=a.name;let b,p=Yt({url:location.origin,principal:d,...n.views?{state:n.views}:{},onDeclaration:async()=>{let g=await(await fetch("/graview/document")).json();if(typeof g.module=="string")return;let A=await it(g);A.ok&&b?.setApp(A.app,l)}});await Promise.all([Mr,p.ready]),b=Gt(Zt,{app:a,remote:l,principal:d,studio:!1,face:"pages",routing:"address",bar:!0,height:"100dvh",label:a.name,heading:1,keptViews:p,...n.draftView?{draftView:n.draftView}:{}}),window.__graview=b,b.drawn().then(()=>{window.__graviewReady=!0})}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graview",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.48",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The Graview command line: start a product, check its declaration, write its agent docs, serve its store, preview a document with no product and photograph its places, say whether a product is on one release, host it for an agent over MCP, apply an act to it, sync its seed, install the authoring skills. The tool; @graview/* is the framework.",
|
|
6
6
|
"keywords": [
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@graview/
|
|
33
|
-
"@graview/
|
|
34
|
-
"@graview/
|
|
35
|
-
"@graview/
|
|
36
|
-
"@graview/
|
|
32
|
+
"@graview/core": "0.1.48",
|
|
33
|
+
"@graview/skills": "0.1.48",
|
|
34
|
+
"@graview/guest": "0.1.48",
|
|
35
|
+
"@graview/tools": "0.1.48",
|
|
36
|
+
"@graview/ship": "0.1.48"
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=22"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{k as a,l as b,m as c,n as d,o as e,p as f,q as g,r as h,s as i}from"./chunk.OCTOGZVJ.js";import"./chunk.UKAPFIPJ.js";import"./chunk.UT6642FC.js";import"./chunk.WAB7UDHU.js";import"./chunk.IW7YFPGG.js";import"./chunk.2W22AWSL.js";import"./chunk.TI4OSTQV.js";import"./chunk.UHX4WTM7.js";import"./chunk.HDRD33II.js";import"./chunk.DX357TZ3.js";import"./chunk.H7KCWCB4.js";import"./chunk.O4WEJ47H.js";import"./chunk.Y4ZUJUUT.js";import"./chunk.SDO3U72B.js";import"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import"./chunk.AJZBJBMO.js";export{i as GhostTray,h as InlineAiMenu,g as askAgain,c as askInline,a as askOf,b as drawPanel,d as heldSuggestion,e as suggestOnce,f as takeOffer};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{c as _e,d as xe,e as Me}from"./chunk.64WM4IBI.js";import{q as $e}from"./chunk.VW2VCPJX.js";import{a as Ne}from"./chunk.UKAPFIPJ.js";import{f as K}from"./chunk.IW7YFPGG.js";import{a as E}from"./chunk.Q7RQC3F7.js";import{a as Re,b as G,d as Te}from"./chunk.HDRD33II.js";import{a as ge}from"./chunk.H7KCWCB4.js";import{Aa as U,Ca as fe,Cb as ve,Ea as pe,Fa as V,Fb as Ae,Ib as q,K as le,Lc as Oe,Ma as me,Na as he,Qa as ye,Wa as F,Za as be,a as ce,da as C,vb as we,xa as ue,yb as ke,zb as Se}from"./chunk.AS4CQBOQ.js";var J=(t,n,e)=>{(t[n]===void 0||e>t[n])&&(t[n]=e)},D=(t,n,e)=>{(t[n]===void 0||e<t[n])&&(t[n]=e)},Z=(t,n)=>{t.format=n,n.includes("int")&&(t.isInt=!0)},Pe=(t,n)=>{t.mime=t.mime?t.mime.filter(e=>n.includes(e)):[...n]},Je=(t,n)=>{t.multipleOf??=[],t.multipleOf.includes(n)||t.multipleOf.push(n)},De=(t,n)=>(t.patterns??=new Set).add(n),Xe={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 z(t){let n={},{def:e,bag:r}=t._zod,i=t._zod.traits.has("$ZodCheck")?[t,...e.checks??[]]:e.checks??[];for(let o of i){let a=o._zod.def;switch(a.check){case"greater_than":J(n,a.inclusive?"minimum":"exclusiveMinimum",a.value);break;case"less_than":D(n,a.inclusive?"maximum":"exclusiveMaximum",a.value);break;case"multiple_of":Je(n,a.value);break;case"number_format":{Z(n,a.format);let d=Xe[a.format];d&&(J(n,"minimum",d[0]),D(n,"maximum",d[1]));break}case"bigint_format":Z(n,a.format);break;case"min_length":case"min_size":J(n,"minimum",a.minimum);break;case"max_length":case"max_size":D(n,"maximum",a.maximum);break;case"length_equals":J(n,"minimum",a.length),D(n,"maximum",a.length);break;case"size_equals":J(n,"minimum",a.size),D(n,"maximum",a.size);break;case"string_format":Z(n,a.format),a.pattern&&De(n,a.pattern),(a.format==="base64"||a.format==="base64url")&&(n.contentEncoding=a.format),(a.local||a.precision===-1)&&(n.laxFormat=!0);break;case"mime_type":Pe(n,a.mime);break}}r.minimum!==void 0&&J(n,"minimum",r.minimum),r.exclusiveMinimum!==void 0&&J(n,"exclusiveMinimum",r.exclusiveMinimum),r.maximum!==void 0&&D(n,"maximum",r.maximum),r.exclusiveMaximum!==void 0&&D(n,"exclusiveMaximum",r.exclusiveMaximum),r.multipleOf!==void 0&&Je(n,r.multipleOf),r.format!==void 0&&(n.format??=r.format,r.format.includes("int")&&(n.isInt=!0)),r.mime&&Pe(n,r.mime);for(let o of r.patterns??[])De(n,o);return n}var Qe={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""};function j(t){let n=t._zod.def;return n.type==="pipe"&&n.in._zod.traits.has("$ZodTransform")?j(n.out):n.type==="catch"?j(n.innerType):t._zod.optin}var en=new Set(["promise","optional","nonoptional","nullable","readonly","default","prefault","catch"]);function R(t,n=new Set){if(n.has(t))return!1;n.add(t);let e=t._zod.def,r=e.type;return r==="transform"?!0:r==="array"?R(e.element,n):r==="set"?R(e.valueType,n):r==="lazy"?R(e.getter(),n):en.has(r)?R(e.innerType,n):r==="intersection"?R(e.left,n)||R(e.right,n):r==="record"||r==="map"?R(e.keyType,n)||R(e.valueType,n):r==="pipe"?t._zod.traits.has("$ZodCodec")||R(e.in,n)||R(e.out,n):r==="object"?Object.values(e.shape).some(i=>R(i,n)):r==="union"?e.options.some(i=>R(i,n)):r==="tuple"?e.items.some(i=>R(i,n))||(e.rest?R(e.rest,n):!1):!1}function nn(t){let n=Object.values(t).filter(e=>typeof e=="number");return Object.entries(t).filter(([e])=>n.indexOf(+e)===-1).map(([,e])=>e)}function Ie(t){let n=t.anyOf;if(!Array.isArray(n)||n.length===0||t.type!==void 0)return;let e=[];for(let r of n){if(!r||typeof r!="object")return;Ie(r);let i=Object.keys(r);if(i.length!==1||i[0]!=="type")return;for(let o of[r.type].flat()){if(typeof o!="string")return;e.includes(o)||e.push(o)}}delete t.anyOf,t.type=e.length===1?e[0]:e}var je=new Set(["type","properties","required","additionalProperties"]),Ee=t=>{let n=t.additionalProperties;return n&&typeof n=="object"&&Object.keys(n).length?n:null},ze=(t,n)=>JSON.stringify(t)===JSON.stringify(n);function Y(t){for(let i of t){if(typeof i!="object"||i.type!=="object")return null;for(let o in i)if(!je.has(o))return null}let n={},e=new Set;for(let i of t){for(let o in i.properties){if(Object.prototype.hasOwnProperty.call(n,o))continue;let a=[];for(let d of t){let s=d.properties?.[o]??Ee(d);s&&!a.some(g=>ze(g,s))&&a.push(s)}n[o]=a.length===1?a[0]:Y(a)??{allOf:a}}for(let o of i.required??[])e.add(o)}let r={type:"object",properties:n};if(e.size&&(r.required=[...e]),t.every(i=>i.additionalProperties===!1))r.additionalProperties=!1;else{let i=[];for(let o of t){let a=Ee(o);a&&!i.some(d=>ze(d,a))&&i.push(a)}i.length===1?r.additionalProperties=i[0]:i.length>1&&(r.additionalProperties={allOf:i})}return r}function tn(t){let n=t.allOf;if(!Array.isArray(n)||n.length<2)return;for(let i of je)if(i in t)return;let e=n.filter(i=>Array.isArray(i.oneOf)||Array.isArray(i.anyOf)),r;if(!e.length)r=Y(n);else{let i=e[0],o=Array.isArray(i.oneOf)?"oneOf":"anyOf";if(Object.keys(i).length!==1)return;let a=n.filter(s=>s!==i),d=i[o].map(s=>Y([...a,s]));if(d.some(s=>!s))return;r={[o]:d}}r&&(delete t.allOf,Object.assign(t,r))}function He(t){let n=t;for(let k of["anyOf","oneOf"]){let A=n[k];if(!Array.isArray(A))continue;let m=A.map(He);m.some((l,w)=>l!==A[w])&&(n={...n,[k]:m})}let e=[n.type].flat(),r=!e.includes("string")&&e.some(k=>k==="number"||k==="integer"),i=n.enum??(n.const!==void 0?[n.const]:void 0);if(!r&&!i?.some(k=>typeof k=="number"))return n;let{minimum:o,maximum:a,exclusiveMinimum:d,exclusiveMaximum:s,multipleOf:g,format:f,id:b,...h}=n;return h.enum?h.enum=h.enum.map(k=>typeof k=="number"?String(k):k):typeof h.const=="number"&&(h.const=String(h.const)),r&&(h.type="string",i||(h.pattern=e.includes("number")?"^-?\\d+(?:\\.\\d+)?$":"^-?\\d+$")),h}var W=class{constructor(n,e){this.override=n;this.refs=e}done=new Map;path=[];cyclic=new Map;write(n,e=!1){let r=this.refs.get(n);if(r!==void 0&&!e)return{$ref:r};if(this.path.includes(n))return this.cyclic.has(n)||this.cyclic.set(n,""),{};let i=this.done.get(n);if(i)return i;this.path.push(n);try{let o=this.written(n);return this.done.set(n,o),o}finally{this.path.pop()}}written(n){let e={},r,i=n._zod.toJSONSchema?.();i?Object.assign(e,i):r=this.process(n,e);let o=ce.get(n);if(o)for(let d of Object.keys(o))e[d]=o[d];R(n)&&(delete e.examples,delete e.default),"_prefault"in e&&(e.default??=e._prefault,delete e._prefault);let a=e;if(r){let d=this.write(r);a={...e};for(let s of Object.keys(d))s in e||(a[s]=d[s])}return this.override({zodSchema:n,jsonSchema:a}),Ie(a),n._zod.def.type==="intersection"&&tn(a),a}process(n,e){let r=n._zod.def;switch(r.type){case"string":{e.type="string";let{minimum:i,maximum:o,format:a,patterns:d,contentEncoding:s,laxFormat:g}=z(n);if(typeof i=="number"&&(e.minLength=i),typeof o=="number"&&(e.maxLength=o),a&&(e.format=Qe[a]??a,(e.format===""||a==="time"||g)&&delete e.format),s&&(e.contentEncoding=s),d&&d.size>0){let f=[...d];f.length===1?e.pattern=f[0].source:e.allOf=f.map(b=>({pattern:b.source}))}return}case"number":{let{minimum:i,maximum:o,multipleOf:a,exclusiveMinimum:d,exclusiveMaximum:s,isInt:g}=z(n);if(e.type=g?"integer":"number",typeof d=="number"&&d>=(i??Number.NEGATIVE_INFINITY)?e.exclusiveMinimum=d:typeof i=="number"&&(e.minimum=i),typeof s=="number"&&s<=(o??Number.POSITIVE_INFINITY)?e.exclusiveMaximum=s:typeof o=="number"&&(e.maximum=o),a){let[f,...b]=new Set(a.filter(h=>Number.isFinite(h)&&h!==0).map(Math.abs));f!==void 0&&(e.multipleOf=f),b.length&&(e.allOf=[...e.allOf??[],...b.map(h=>({multipleOf:h}))])}return}case"boolean":case"success":e.type="boolean";return;case"null":e.type="null";return;case"never":e.not={};return;case"enum":{let i=nn(r.entries);i.length===0?e.not={}:(i.every(o=>typeof o=="number")&&(e.type="number"),i.every(o=>typeof o=="string")&&(e.type="string"),e.enum=i);return}case"literal":{let i=r.values.filter(o=>o!==void 0).map(o=>typeof o=="bigint"?Number(o):o);if(r.values.length===0)e.not={};else if(i.length===1)e.type=i[0]===null?"null":typeof i[0],e.const=i[0];else if(i.length>1){for(let o of["number","string","boolean"])i.every(a=>typeof a===o)&&(e.type=o);i.every(o=>o===null)&&(e.type="null"),e.enum=i}return}case"template_literal":e.type="string",e.pattern=n._zod.pattern.source;return;case"file":{e.type="string",e.format="binary",e.contentEncoding="binary";let{minimum:i,maximum:o,mime:a}=z(n);i!==void 0&&(e.minLength=i),o!==void 0&&(e.maxLength=o),a&&(a.length===0?e.not={}:a.length===1?e.contentMediaType=a[0]:e.anyOf=a.map(d=>({contentMediaType:d})));return}case"array":{let{minimum:i,maximum:o}=z(n);typeof i=="number"&&(e.minItems=i),typeof o=="number"&&(e.maxItems=o),e.type="array",e.items=this.write(r.element);return}case"object":{let i=r.shape;e.type="object";let o={};e.properties=o;for(let d in i)Object.defineProperty(o,d,{value:this.write(i[d]),writable:!0,enumerable:!0,configurable:!0});let a=Object.keys(i).filter(d=>j(i[d])===void 0);a.length>0&&(e.required=a),r.catchall?._zod.def.type==="never"?e.additionalProperties=!1:r.catchall&&(e.additionalProperties=this.write(r.catchall));return}case"union":e[r.inclusive===!1?"oneOf":"anyOf"]=r.options.map(i=>this.write(i));return;case"intersection":{let i=d=>"allOf"in d&&Object.keys(d).length===1,o=this.write(r.left),a=this.write(r.right);e.allOf=[...i(o)?o.allOf:[o],...i(a)?a.allOf:[a]];return}case"tuple":{let i=r.items;e.type="array",e.prefixItems=i.map(s=>this.write(s)),r.rest?e.items=this.write(r.rest):e.items=!1;let o=i.length;for(;o>0&&j(i[o-1])!==void 0;)o-=1;o>0&&(e.minItems=o),r.rest||(e.maxItems=i.length);let{minimum:a,maximum:d}=z(n);typeof a=="number"&&(e.minItems=a),typeof d=="number"&&(e.maxItems=d);return}case"record":{let i=r.keyType;e.type="object";let o=z(i).patterns;if(r.mode==="loose"&&o&&o.size>0){let d=this.write(r.valueType),s={};for(let g of o)s[g.source]=d;e.patternProperties=s}else e.propertyNames=He(this.write(i)),e.additionalProperties=this.write(r.valueType);let a=i._zod.values;if(a&&!r.partial&&j(r.valueType)===void 0){let d=[...a].filter(s=>typeof s=="string"||typeof s=="number");d.length>0&&(e.required=d.map(String))}return}case"nullable":e.anyOf=[this.write(r.innerType),{type:"null"}];return;case"default":case"prefault":{let i=r.defaultValue,o,a=!1,d=JSON.stringify(i,(s,g)=>typeof g=="bigint"?(a=!0,null):g);return!a&&d!==void 0&&(o=JSON.parse(d)),a||(e[r.type==="default"?"default":"_prefault"]=o),r.innerType}case"catch":{try{e.default=r.catchValue(void 0)}catch{}return r.innerType}case"readonly":return e.readOnly=!0,r.innerType;case"pipe":return r.in._zod.traits.has("$ZodTransform")?r.out:r.in;case"lazy":return n._zod.innerType;case"optional":case"nonoptional":case"promise":return r.innerType;default:return}}};function Le(t,n=()=>{}){let e=t,r=new W(n,new Map),i=r.write(e,!0);if(r.cyclic.size>0){let o=new Map,a=0,d=[];for(let g of r.cyclic.keys())if(g===e)o.set(g,"#");else{let f=`__schema${a++}`;o.set(g,`#/$defs/${f}`),d.push([g,f])}r=new W(n,o),i=r.write(e,!0);let s={};for(let[g,f]of d)s[f]=r.write(g,!0);d.length>0&&(i={...i,$defs:s})}return JSON.parse(JSON.stringify({$schema:"https://json-schema.org/draft/2020-12/schema",...i}))}function Fe(t){return Le(t,an)}var rn={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string"},on={phone:"A phone number as it is written, like +1 555 123 4567 or 020 7946 0958 ext. 12.",place:"An address or a place's name, as a person would search a map for it.",duration:"A length of time in whole minutes: 90 is 1 h 30 min."};function an(t){ue(t.zodSchema)&&(t.jsonSchema["x-graview-app-link"]=!0);let n=pe(t.zodSchema);if(n&&(t.jsonSchema.type==="string"||t.jsonSchema.type==="array")){t.jsonSchema["x-graview-linked"]={address:n.address,kinds:[...n.kinds],cardinality:n.cardinality};let s=n.kinds.join(" or "),g=`${n.cardinality==="many"?"Records":"A record"}: a ${s} in the app ${n.address}, as "${n.kinds[0]}:<id>" \u2014 an id found there with find_linked. Linking never changes that app.`,f=t.jsonSchema.description;typeof f=="string"&&f.includes(g)||(t.jsonSchema.description=`${typeof f=="string"&&f?`${f.replace(/\.?$/,".")} `:""}${g}`)}if(ye(t.zodSchema)&&(t.jsonSchema["x-graview-repeat"]=!0,!t.jsonSchema.type&&!t.jsonSchema.anyOf&&!t.jsonSchema.oneOf&&Object.assign(t.jsonSchema,sn())),ge(t.zodSchema)){t.jsonSchema.contentMediaType="text/markdown";let s=t.jsonSchema.description;typeof s=="string"&&s.endsWith("Written in Markdown.")||(t.jsonSchema.description=`${typeof s=="string"&&s?`${s.replace(/\.?$/,".")} `:""}Written in Markdown.`)}let e=Ae(t.zodSchema);if(e){let s=t.jsonSchema;s["x-graview-type"]=e,e==="duration"&&(s["x-graview-unit"]="minutes"),s.description??=on[e]}let r=ve(t.zodSchema,!1);if(r){let s=Re(r);t.jsonSchema["x-graview-format"]=s.format??"unit",s.currency&&(t.jsonSchema["x-graview-currency"]=s.currency),s.unit&&s.format!=="money"&&(t.jsonSchema["x-graview-unit"]=s.unit);let g=t.jsonSchema.description;t.jsonSchema.description=typeof g=="string"&&g.length>0?`${g} ${G(s)}`:G(s)}let i=t.zodSchema._zod?.def;if(!i||i.type!=="string"||typeof i.format!="string"||i.format==="regex")return;let o=t.jsonSchema,a=(i.checks??[]).map(s=>s._zod?.def).filter(s=>s?.format==="regex"&&s.pattern instanceof RegExp).map(s=>s.pattern.source);delete o.pattern;let d=o.allOf;Array.isArray(d)&&d.every(s=>typeof s=="object"&&s!==null&&Object.keys(s).length===1&&"pattern"in s)&&delete o.allOf,o.format=rn[i.format]??i.format,a.length===1?o.pattern=a[0]:a.length>1&&(o.allOf=a.map(s=>({pattern:s})))}function X(t){let n=q(t.input),e=Fe(t.input),r=e.properties??{};if(ke(t)){let i=t.creates.join(" | ");r.id={type:"string",minLength:1,description:`Optional: the id for the ${i} this makes. Refused if the graph already has it; left out, one is minted from the label.`},e.properties=r}Se(t)&&(e.additionalProperties=!1);for(let i of n){let o=r[i.name];if(!o)continue;let a=i.kinds.includes("*")?"any node kind":i.kinds.join(" | ");o.description=[o.description,`Id of a node (${a}).`].filter(Boolean).join(" ")}return{name:t.name,...t.title===void 0?{}:{title:t.title},description:t.description??t.title??t.name,inputSchema:e,nodeRefs:n}}function sn(){let t={type:"string",pattern:"^\\d{4}-\\d{2}-\\d{2}$"},n=(e,r)=>({type:"integer",minimum:e,maximum:r});return{type:"object",description:'How the date beside it repeats; the date is the first occurrence. "on" is weekdays for "week", days of the month (-1 the last) for "month".',properties:{every:{type:"string",enum:[...he]},interval:n(1,99),on:{type:"array",minItems:1,maxItems:31,items:{anyOf:[{type:"string",enum:[...me]},n(-1,31)]}},until:t,count:n(1,1e3),except:{type:"array",maxItems:500,items:t},continues:{type:"string",maxLength:200}},required:["every"],additionalProperties:!1}}function qe(t){let n=new Set;for(let e=t;e;e=e.onBehalfOf)e.id!==void 0&&n.add(`${e.kind}:${e.id}`);return n}function B(t,n){let e=qe(n),r=f=>{if(f.kind==="rule")return!1;let b=qe(f);if(b.size===0)return!1;for(let h of b)if(e.has(h))return!1;return!0},i,o=()=>{if(i)return i;i=new Map;for(let f of t.log.live()){if(f.undoes!==void 0)continue;let b=r(f.author)?f.author:void 0;for(let h of f.primitives){h.op==="remove-node"&&i.delete(h.node.id);let k=h.op==="add-node"?h.node.id:h.op==="patch-node"?h.id:void 0;if(k===void 0)continue;let A=h.op==="add-node"?Object.keys(h.node):Object.keys(h.after),m=i.get(k);(h.op==="add-node"||!m)&&i.set(k,m=new Map);for(let l of A)l==="id"||l==="kind"||(b?m.set(l,b):m.delete(l))}}return i},a=t.schema,d=new Map,s=(f,b)=>{let h=`${f}\0${b}`,k=d.get(h);if(k===void 0){let A=a.tryDefinition(f)?.fields?.shape;k=A!==void 0&&b in A&&Te(A[b]).type==="text",d.set(h,k)}return k},g=f=>t.graph.getNode(f)?.kind;return{prose:s,say:f=>F(f,{graph:t.graph,schema:a}),fieldBy(f,b){let h=g(f);if(!(h===void 0||!s(h,b)))return o().get(f)?.get(b)},recordBy(f){let b=g(f),h=o().get(f);if(b===void 0||!h)return;let k;for(let[A,m]of h)s(b,A)&&(k=m);return k}}}var Q=(t,n,e)=>({untrusted:!0,authoredBy:e.say(n),text:t}),dn="the host's ranker";function We(t,n){return{...t,hits:t.hits.map(e=>{if(e.about!=="node")return e;e.why.by==="meaning"&&e.why.matched!==void 0&&(e={...e,why:{...e.why,matched:{untrusted:!0,authoredBy:dn,text:e.why.matched}}});let r=n.recordBy(e.id);if(!r)return e;let i=n.prose(e.kind,e.why.field)?n.fieldBy(e.id,e.why.field):r;return{...e,label:Q(e.label,r,n),...e.apart!==void 0?{apart:Q(e.apart,r,n)}:{},why:i?{...e.why,fragment:Q(e.why.fragment,i,n)}:e.why}})}}var ee=(t,n,e)=>({title:t,readOnlyHint:n,destructiveHint:!1,idempotentHint:e,openWorldHint:!1}),cn={name:"subscribe",title:"Notify me when something happens",description:`Subscribe the person you act for to be told when something happens in this app \u2014 their host delivers it (an email, a push). on is one of: "act" (an act runs; give act, its declared name, and/or record), "created" (a record of kind is added), "changed" (a record of kind, or the one record, changes), "reaches" (a record of kind, or the one record, comes to satisfy condition, an expression in the app's rule language such as done == true or amount > 100). They are told only of changes someone else made, unless alsoMine is true, and only of records they may see. Returns the subscription and its sentence. Changes nothing in the app.`,inputSchema:{type:"object",properties:{on:{type:"string",enum:["act","created","changed","reaches"],description:"What to be told of."},act:{type:"string",description:"An act's declared name, for on: act."},kind:{type:"string",description:"A kind, for created, changed and reaches."},record:{type:"string",description:"One record, by id or name: for act, changed and reaches."},condition:{type:"string",description:"For reaches: what the record should come to satisfy, in the rule language (done == true)."},alsoMine:{type:"boolean",description:"Also when the person themselves made the change; false when unsaid."}},required:["on"],additionalProperties:!1},mutating:!1,annotations:ee("Notify me when something happens",!1,!1)},ln={name:"unsubscribe",title:"Stop notifying me",description:"Take away one of the person's subscriptions, by the id list_subscriptions or subscribe answered. Changes nothing in the app.",inputSchema:{type:"object",properties:{id:{type:"string",description:"The subscription's id."}},required:["id"],additionalProperties:!1},mutating:!1,annotations:ee("Stop notifying me",!1,!0)},un={name:"list_subscriptions",title:"What I am notified of",description:`List what the person you act for is told of in this app: each subscription's id and its sentence ("When someone else adds a task").`,inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:ee("What I am notified of",!0,!0)},ne=[cn,ln,un];var L=t=>{let n;return()=>n??=t().catch(e=>{throw n=void 0,e})},fn=L(()=>(__graviewPreload(import.meta.url,["./chunk.RX2M4C5W.js","./chunk.FOQ27RAR.js","./chunk.ZIEHF67C.js","./chunk.UHX4WTM7.js","./chunk.IKX4VDTW.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.DX357TZ3.js","./chunk.H7KCWCB4.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.SGKK4UKP.js"))),pn=()=>(__graviewPreload(import.meta.url,["./chunk.Q7RQC3F7.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.QGVLJTZS.js")).catch(()=>{}),mn=async()=>{(await pn())?.judgeWithLines()},H=L(()=>(__graviewPreload(import.meta.url,["./chunk.WVUJXDXZ.js","./chunk.ZIEHF67C.js","./chunk.UHX4WTM7.js","./chunk.IKX4VDTW.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.H7KCWCB4.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.PC6PID5X.js"))),hn=L(()=>(__graviewPreload(import.meta.url,["./chunk.YVONXFKE.js","./chunk.G4JJXA63.js","./chunk.WBHM5I3I.js","./chunk.FOQ27RAR.js","./chunk.WAB7UDHU.js","./chunk.IW7YFPGG.js","./chunk.Q5WEOX3Q.js","./chunk.4OGOTHRD.js","./chunk.6YD2DLIC.js","./chunk.Q7RQC3F7.js","./chunk.WVUJXDXZ.js","./chunk.ZIEHF67C.js","./chunk.UHX4WTM7.js","./chunk.IKX4VDTW.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.HDRD33II.js","./chunk.DX357TZ3.js","./chunk.H7KCWCB4.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.GQHAAKJG.js"))),yn=L(()=>(__graviewPreload(import.meta.url,["./chunk.47RTA6M3.js","./chunk.RX2M4C5W.js","./chunk.FOQ27RAR.js","./chunk.UKAPFIPJ.js","./chunk.UT6642FC.js","./chunk.ZIEHF67C.js","./chunk.UHX4WTM7.js","./chunk.IKX4VDTW.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.HDRD33II.js","./chunk.DX357TZ3.js","./chunk.H7KCWCB4.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.ZL7ZBJUU.js"))),gn=L(()=>(__graviewPreload(import.meta.url,["./chunk.Z6TMIAAB.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.63JLXGYX.js"))),bn=t=>t.definitions.some(n=>V(n).size>0),Be=t=>({value:U(t),label:t.label,...t.describe?{describe:t.describe}:{},...t.card?{card:t.card}:{},fields:t.fields,...t.app?{app:t.app}:{}});async function wn(t,n,e,r){let i=String(e.relation??""),[o,a]=i.includes(".")?i.split(".",2):[void 0,i],d=t.schema.definitions.flatMap(l=>[...V(l)].map(([w,S])=>({kind:l.kind,name:w,relation:S}))),s=d.filter(l=>l.name===a&&(o===void 0||l.kind===o));if(s.length!==1){let l=d.map(w=>`${w.kind}.${w.name}`).join(", ")||"none";return{ok:!1,error:`${s.length===0?`No relation to another app is called "${i}"`:`"${i}" names a relation of several kinds`}. The relations to other apps are: ${l}.`}}let{kind:g,name:f,relation:b}=s[0];if(!r)return{ok:!1,error:`This seat cannot read ${b.address}: its host reads no other app's records. Nothing was changed.`};let h={kind:n.kind,...n.id===void 0?{}:{id:n.id},...n.roles?{roles:n.roles}:{}},k=typeof e.of=="string"?e.of:void 0;if(k!==void 0){let l=t.graph.getNode(k);if(!l||l.kind!==g)return{ok:!1,error:`No ${g} "${k}".`};let w=fe(l[f],b),S=await Promise.all(w.map(c=>Promise.resolve().then(()=>r.resolve(c,h)).catch(()=>null)));return{ok:!0,data:{relation:`${g}.${f}`,app:b.address,records:S.map((c,u)=>c===null?{value:U(w[u]),missing:!0}:"denied"in c?{denied:!0,said:"linked record (no access)"}:Be(c))},reads:[k]}}let A=typeof e.limit=="number"&&e.limit>0?Math.min(e.limit,20):20,m=await Promise.resolve().then(()=>r.find({address:b.address,kinds:b.kinds,query:String(e.query??""),limit:A},h)).catch(()=>[]);return Array.isArray(m)?{ok:!0,data:{relation:`${g}.${f}`,app:b.address,records:m.map(Be),link:`edit-${g} with ${f} set to a record's value`}}:{ok:!0,data:{relation:`${g}.${f}`,app:b.address,denied:!0,said:"linked record (no access)"}}}var _=t=>({title:t,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}),Ce={description:'Which records: false (the default) the live ones, true only the archived ones, "all" both. An archived record is set aside, not gone: unarchive-<kind> brings it back.',anyOf:[{type:"boolean"},{type:"string",enum:["all"]}]},te={type:"number",description:"Where the page starts; 0 when unsaid."},oe=[{name:"search_graph",title:"Find by name",description:"Find things by name: records whose name or readable fields carry the words, and the kinds, places and rules the words name \u2014 each with why it matched. Reach for this before get_graph when you know what something is called. Words match the start of words, case and accents aside; key:value tokens narrow as a list's filter does (done:false, is:any for past records, kind:<kind>). Pass subject (a node id) to get the acts you may run on it as hits too. When few records match exactly, records with a near word follow \u2014 a typo, another form of the word, a meaning \u2014 each with near: true and why.matched, the record's own word that answered.",inputSchema:{type:"object",properties:{query:{type:"string",description:"Words, with optional key:value conditions."},limit:{type:"number",description:"Most hits to return; at most 20."},subject:{type:"string",description:"A node id whose acts to include."},archived:Ce},required:["query"],additionalProperties:!1},mutating:!1,annotations:_("Find by name")},{name:"get_graph",title:"Read the graph",description:"Read the graph, 25 nodes a page: their fields, the edges out of them, and how many more. Start here when you need the shape of the domain rather than one thing in it.",inputSchema:{type:"object",properties:{offset:te,archived:Ce},additionalProperties:!1},mutating:!1,annotations:_("Read the graph")},{name:"get_node",title:"Read one node",description:"Read one node: its fields, its links (id, kind and label, 20 each way a page), the violations that implicate it, and its computed values: read-only fields worked out from what you can see, which no act sets. Use this to check a thing before you change it.",inputSchema:{type:"object",properties:{id:{type:"string",description:"A node's id, or its name."},offset:te},required:["id"],additionalProperties:!1},mutating:!1,annotations:_("Read one node")},{name:"get_violations",title:"List the problems",description:"List the invariant violations the graph currently has, 20 a page, with the repairs that would resolve each one. Read this before proposing work: a rule that is already broken is more urgent than anything you could add.",inputSchema:{type:"object",properties:{offset:te,context:{type:"object",description:"Evaluation context, e.g. { weekStart }."}},additionalProperties:!1},mutating:!1,annotations:_("List the problems")},{name:"get_affordances",title:"Ask what can be done",description:"Ask what can legally be done with a selection, ranked. Prefer these over composing a mutation by hand: they are derived from the schema, the invariants and the shape of the graph, so they cannot name an action that does not exist.",inputSchema:{type:"object",properties:{selection:{type:"array",items:{type:"string"},description:"Node ids."},context:{type:"object"}},required:["selection"],additionalProperties:!1},mutating:!1,annotations:_("Ask what can be done")},{name:"describe_place",title:"Say what a place shows",description:`Say what one place of the app shows you, as a person in your seat would see it: its headings, its figures as drawn, its lists with each record's title and what its card or row says, the headings a list is grouped under, what an empty list says, and any block that could not be worked out. Pass a place's slug ("home", a lens's address like "the-offers", a kind's like "offers") or a record's id, and width 390 for a phone. Use it after a change to check what somebody now sees, instead of guessing.`,inputSchema:{type:"object",properties:{place:{type:"string",description:`"home", a place's slug, or a record's id.`},width:{type:"number",description:"The screen's width in CSS pixels; 390 is a phone, 1440 when unsaid."}},required:["place"],additionalProperties:!1},mutating:!1,annotations:_("Say what a place shows")},{name:"preview_mutation",title:"Try an act without applying it",description:"Try a mutation without applying it: get back the diff it would produce and any invariant it would break. Do this when you are unsure, rather than applying and undoing.",inputSchema:{type:"object",properties:{mutation:{type:"string"},args:{type:"object"}},required:["mutation","args"],additionalProperties:!1},mutating:!1,annotations:_("Try an act without applying it")},{name:"undo_batch",title:"Undo a batch",description:"Undo one batch of operations. Fails, naming the blocking operation, when a later operation read what it wrote.",inputSchema:{type:"object",properties:{batch:{type:"string"},include:{type:"array",items:{type:"string"}}},required:["batch"],additionalProperties:!1},mutating:!0,annotations:{title:"Undo a batch",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1}},{name:"list_suggestions",title:"List what is suggested",description:"List the suggestions waiting for a person: changes the app's own actor proposed and did not make, each with its id, what it would do, who suggested it, what it was based on and how sure (0 to 1). Nothing changes until one is accepted (accept_suggestion) or declined (decline_suggestion); a declined one is never suggested again.",inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:_("List what is suggested")},{name:"accept_suggestion",title:"Accept a suggestion",description:"Make a waiting suggestion's change, as this seat, carrying what it was based on. Returns the batch (undo_batch takes it back).",inputSchema:{type:"object",properties:{suggestion:{type:"string",description:"The suggestion's id, from list_suggestions."}},required:["suggestion"],additionalProperties:!1},mutating:!0,annotations:{title:"Accept a suggestion",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1}},{name:"decline_suggestion",title:"Decline a suggestion",description:"Decline a waiting suggestion: nothing changes, the decline is kept in the log, and the same change is never suggested or made by the app's own actor again.",inputSchema:{type:"object",properties:{suggestion:{type:"string",description:"The suggestion's id, from list_suggestions."}},required:["suggestion"],additionalProperties:!1},mutating:!0,annotations:{title:"Decline a suggestion",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}}],Ve={name:"act_on_several",title:"Do one act to several records",description:`Run one act on several records at once, as one change with one undo. act is the act (its tool name or its declared name), records the records it runs on (ids or names; each goes in the act's subject), args what every call shares ("Set stage to Declined" is args { stage: "declined" }). Each record is judged on its own: one this seat may not change is named with why, and the rest still apply. Returns the batch (undo_batch takes it all back), the records changed, those already so, and those refused.`,inputSchema:{type:"object",properties:{act:{type:"string",description:"The act to run on each record."},records:{type:"array",items:{type:"string"},minItems:1,maxItems:200,description:"Ids or names of the records."},args:{type:"object",description:"Arguments every call shares, besides the record."}},required:["act","records"],additionalProperties:!1},mutating:!0,annotations:{title:"Do one act to several records",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1}},ae={type:"object",description:"A lens, as draft_view returns one.",properties:{title:{type:"string"},lens:{type:"string"},on:{type:"string"},bindings:{type:"object"},options:{type:"object"}},required:["title","lens","on"]},se={name:"draft_view",title:"Draw a view",description:'Draw a view of the data from words ("a board of tasks by status", "who covers what") as a lens the app could keep; or check a lens you wrote (lens); or change the one on screen (current, with ask: "only this month"). Returns the lens and its add-lens edit, or one sentence saying why not. Writes nothing.',inputSchema:{type:"object",properties:{ask:{type:"string",description:"What to see, in words."},lens:ae,current:ae},additionalProperties:!1},mutating:!1,annotations:_("Draw a view")},Ge={name:"keep_lens",title:"Keep a view as a lens",description:"Keep a lens draft_view drew as one of the app's places: checked again, then written as the add-lens edit. Returns the remove-lens edit that takes it back.",inputSchema:{...ae,additionalProperties:!1},mutating:!0,annotations:{title:"Keep a view as a lens",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},Ke={name:"find_linked",title:"Find a record in another app",description:`A relation may go to a kind in another app (describe_app lists them under "Linked from other apps"). With relation and words, list the records there this seat may link \u2014 each with the value to link it by ("house:h1"), its name and its describe line. With of (a record id here), read the records that record links, as this seat may see them there. Linking one is the record's edit (edit-<kind>) with the relation set to the value. Another app this seat may not open answers denied, and nothing of it. Writes nothing; never changes the other app.`,inputSchema:{type:"object",properties:{relation:{type:"string",description:"The relation, by name (forHouse) or as <kind>.<relation> (scenario.forHouse)."},query:{type:"string",description:"Words to find by, in the other app's names; empty for the first few."},of:{type:"string",description:"A record here whose linked records to read, instead of finding."},limit:{type:"number",description:"Most records to return; at most 20."}},required:["relation"],additionalProperties:!1},mutating:!1,annotations:_("Find a record in another app")};function kn(t,n){return t===void 0?[]:t==="keep"&&!n?[se,Ge]:[se]}var Sn="An argument that names a record takes its id or its name.",Ze=[...oe.map(t=>t.name),Ve.name,se.name,Ge.name,Ke.name,...ne.map(t=>t.name)],Ye=64;function x(t){let{line:n,...e}=t;return e}function Ue(t){return{...t,...t.introduces?{introduces:t.introduces.map(x)}:{},...t.resolves?{resolves:t.resolves.map(x)}:{},...t.violationsAfter?{violationsAfter:t.violationsAfter.map(x)}:{}}}function vn(t){let n=t.normalize("NFKD").replace(/\p{M}/gu,"").replace(/[^A-Za-z0-9_-]/g,"_");return n.length===0&&(n="act"),/^[A-Za-z_]/.test(n)||(n=`act_${n}`),n.slice(0,Ye)}function An(t){let n=new Set(Ze),e=new Map;for(let r of t){let i=vn(r),o=i;for(let a=2;n.has(o);a+=1)o=`${i.slice(0,Ye-`_${a}`.length)}_${a}`;n.add(o),e.set(r,o)}return e}function On(t,n){if(n.size===0)return t;let e=Object.fromEntries(Object.entries(t.properties??{}).filter(([i])=>!n.has(i))),r=(t.required??[]).filter(i=>!n.has(i));return{...t,properties:e,...t.required?{required:r}:{}}}function Rn(t,n,e){let r=X(t),i=C(t),o=r.nodeRefs.length>0?`${r.description}${/[.!?]$/.test(r.description)?"":"."} ${Sn}`:r.description;return{name:n,title:i,description:o,inputSchema:On(r.inputSchema,e),mutating:!0,annotations:{title:i,readOnlyHint:!1,destructiveHint:t.destructive===!0||(t.severs?.length??0)>0,idempotentHint:t.idempotent===!0,openWorldHint:!1},act:t.name}}function de(t){if(t===null||typeof t!="object")return JSON.stringify(t)??"null";if(Array.isArray(t))return`[${t.map(de).join(",")}]`;let n=t;return`{${Object.keys(n).filter(e=>n[e]!==void 0).sort().map(e=>`${JSON.stringify(e)}:${de(n[e])}`).join(",")}}`}function Tn(t){return`sha256:${Oe(de(t))}`}function _n(t,n,e,r,i,o=!1,a=!1){let d=An(t.map(f=>f.name)),s=[...kn(r,e),...o?[Ke]:[],...a?ne:[]];return{definitions:e?[...oe.filter(f=>!f.mutating),...s]:[...oe,Ve,...s,...t.filter(f=>n.has(f.name)).map(f=>Rn(f,d.get(f.name),i(f)))],names:d}}function lt(t,n={}){let e=n.author??{kind:"agent"},r=t.allMutations(),i=new Set(t.permittedMutations(e).map(m=>m.name)),{definitions:o,names:a}=_n(r,i,n.readOnly===!0,n.drafts?n.drafts.keep?"keep":"draw":void 0,m=>K(t.schema,t.policy,e,m),bn(t.schema),n.subscriptions!==void 0),d=Tn(o),s={app:n.app?.brand?.locale,appTimeZone:n.app?.brand?.timeZone},g=m=>le(s,m),f=m=>{if(!Ze.includes(m)){for(let[l,w]of a)if(w===m)return l;return a.has(m)?m:void 0}},b=(m,l)=>{let w=r.find(u=>u.name===m);if(!w)return{args:l,resolved:[]};let S={...l},c=[];for(let u of q(w.input)){let p=S[u.name];if(typeof p!="string"||p.trim()==="")continue;let y=t.resolveRef(u,p,e);if(!y.ok){let v=y.reason==="none"?` Nothing was changed. Use search_graph to look it up, then pass its id as ${u.name}.`:" Nothing was changed.";return{ok:!1,error:`${y.message}${v}`,argument:u.name,candidates:y.candidates}}y.by!=="id"&&(S[u.name]=y.id,c.push({argument:u.name,given:p,id:y.id,label:y.label}))}return{args:S,resolved:c}},h=async(m,l)=>{try{await mn();let w=o.find(c=>c.name===m)??o.find(c=>c.act===m);if(!w){let c=f(m);if(c){let u=t.permits({name:c,args:l},e);if(!u.ok)return{ok:!1,error:u.refusal.message,reason:"forbidden"}}return{ok:!1,error:`Unknown tool "${m}". Available: ${o.map(u=>u.name).join(", ")}`}}if(w.mutating&&n.readOnly)return{ok:!1,error:`"${m}" changes the graph, and this seat is read-only.`,reason:"forbidden"};if(w.act!==void 0){let c=b(w.act,l);if("ok"in c)return c;let u=w.act,p=g(()=>E(t,e,t.apply({name:u,args:c.args},{...n.author?{author:n.author}:{},...ie(n.via)})));return{ok:!0,data:{batch:p.batch,intent:p.intent,introduces:p.introduces.map(x),resolves:p.resolves.map(x),...c.resolved.length>0?{resolved:c.resolved}:{}},diff:p.diff}}let S=t.seenBy(e);switch(w.name){case"search_graph":{let c=typeof n.places=="function"?n.places():n.places,u=typeof l.subject=="string"?l.subject:void 0,p=$e(S,String(l.query??""),{principal:e,rank:n.near,archived:be(l.archived),limit:typeof l.limit=="number"&&l.limit>0?Math.min(l.limit,20):20,...c?{places:c}:{},...u?{subject:u,from:[u]}:{}}),y=p.later?await p.later:p;return{ok:!0,data:(await H()).searchRead(y,We(y,B(S,e))),reads:y.hits.flatMap(v=>v.about==="node"?[v.id]:[])}}case"get_graph":return{ok:!0,...(await H()).graphRead(S,B(S,e),l)};case"get_node":{let c=String(l.id??""),u=c,p;if(!S.graph.getNode(c)){let v=c.trim()===""?void 0:t.resolveRef({name:"id",kinds:["*"]},c,e);if(v?.ok)u=v.id,p={argument:"id",given:c,id:u,label:v.label};else return v?.reason==="ambiguous"?{ok:!1,error:v.message,argument:"id",candidates:v.candidates}:{ok:!1,error:`No node "${c}".`}}let y=(await H()).nodeRead(S,B(S,e),u,l);return{ok:!0,data:p?{...y.data,resolved:[p]}:y.data,reads:y.reads}}case"describe_place":{let c=n.app??{name:"",schema:t.schema},u=typeof l.width=="number"&&Number.isFinite(l.width)&&l.width>0?l.width:1440,{describePlace:p}=await fn(),y=p(t,e,String(l.place??""),{app:c,width:u});if(!y.ok)return{ok:!1,error:`${y.error} The places are: ${y.places.join(", ")}.`};let v=new Set,M=I=>{for(let $ of I)for(let T of $.groups??[])for(let N of T.items)v.add(N.id),M(N.parts)};return M(y.description.parts),{ok:!0,data:y.description,reads:[...v]}}case"find_linked":return wn(S,e,l,n.linked);case"draft_view":case"keep_lens":{let c=n.app??{name:"",schema:t.schema};return(await hn()).runDraftTool(w.name,l,{app:c,principal:e,...n.drafts?{drafts:n.drafts}:{}})}case"get_violations":{let c=S.violations(l.context);return{ok:!0,...(await H()).violationsRead(c,l)}}case"get_affordances":{let c=l.selection??[];return{ok:!0,data:Ne(S,c,{...typeof n.derive=="function"?n.derive():n.derive,...n.author?{principal:n.author}:{},...l.context?{context:l.context}:{}}),reads:c.filter(p=>S.graph.has(p))}}case"preview_mutation":{let c=String(l.mutation),u=f(c)??c,p=b(u,l.args??{});if("ok"in p)return p;let y=t.missingFor({name:u,args:p.args},e);if(y)return{ok:!1,error:y.message,reason:"missing"};let v=E(t,e,t.preview({name:u,args:p.args},void 0,{author:e})),M=Ue(v);return{ok:!0,data:p.resolved.length>0?{...M,resolved:p.resolved}:M}}case"act_on_several":{let c=String(l.act??""),u=f(c)??c,p=r.find(O=>O.name===u);if(!p||!i.has(u)){let O=p?t.permits({name:u,args:{}},e):void 0;return O&&!O.ok?{ok:!1,error:O.refusal.message,reason:"forbidden"}:{ok:!1,error:`There is no act "${c}" this seat may run. Nothing was changed.`,reason:"invalid"}}let y=p.subject;if(!y)return{ok:!1,error:`"${C(p)}" does not act on a record, so it cannot be run on several. Nothing was changed.`,reason:"invalid"};let v=Array.isArray(l.records)?l.records.filter(O=>typeof O=="string"&&O.trim()!==""):[];if(v.length===0)return{ok:!1,error:"Name at least one record. Nothing was changed.",reason:"invalid"};let M=[],I=[];for(let O of v.slice(0,200)){let P=t.resolveRef({name:y.arg,kinds:y.kinds},O,e);if(!P.ok)return{ok:!1,error:`${P.message} Nothing was changed.`,argument:"records",candidates:P.candidates};M.push(P.id),P.by!=="id"&&I.push({argument:"records",given:O,id:P.id,label:P.label})}let $=b(u,{...l.args??{}});if("ok"in $)return $;let T=(await yn()).actOnSeveral(t,{mutation:u,subject:y.arg,args:$.args},M,{author:e,...ie(n.via)}),N=T.result?E(t,e,T.result):void 0;return{ok:!0,data:{...T.batch?{batch:T.batch,intent:T.intent}:{},applied:T.applied,unchanged:T.unchanged,refused:T.refused.map(O=>({record:O.id,label:O.label,error:O.message,reason:O.reason})),...T.allOrNothing?{keptNone:!0}:{},...N?{introduces:N.introduces.map(x),resolves:N.resolves.map(x)}:{},...I.length>0||$.resolved.length>0?{resolved:[...I,...$.resolved]}:{}},...N?{diff:N.diff}:{}}}case"subscribe":case"unsubscribe":case"list_subscriptions":{let c=await(await gn()).runSubscriptionTool(w.name,l,{store:t,principal:n.subscriber??e,app:n.app?.name??"app",subscriptions:n.subscriptions});return c.ok?{ok:!0,data:c.data}:{ok:!1,error:c.error}}case"list_suggestions":{let c=_e(t,e).map(u=>{let p=F(u.author,{graph:S.graph,schema:t.schema});return{id:u.id,intent:u.intent,by:p,at:u.at,about:u.about,...u.lineage?{basis:{untrusted:!0,authoredBy:p,text:u.lineage.basis},...u.lineage.confidence!==void 0?{confidence:u.lineage.confidence}:{}}:{}}});return{ok:!0,data:{suggestions:c},reads:[...new Set(c.flatMap(u=>u.about))]}}case"accept_suggestion":case"decline_suggestion":{let c=String(l.suggestion??""),u={author:e,...ie(n.via)},p=w.name==="accept_suggestion"?xe(t,c,u):Me(t,c,u),y=E(t,e,p);return{ok:!0,data:{batch:y.batch,intent:y.intent,introduces:y.introduces.map(x),resolves:y.resolves.map(x)},diff:y.diff}}case"undo_batch":{let c=String(l.batch),u=l.include??[],p=S.canUndo([c,...u]);if(!p.ok)return{ok:!1,error:p.message};let y=E(t,e,t.undo([c,...u],{...n.author?{author:n.author}:{}}));return{ok:!0,data:Ue(y),diff:y.diff}}default:return{ok:!1,error:`Unknown tool "${m}".`}}}catch(w){let{reason:S,wouldNeed:c}=we(w);return{ok:!1,error:w instanceof Error?w.message:String(w),reason:S,...c?{wouldNeed:c}:{}}}},k=new Set,A=m=>{for(let l of k)l(m)};return{definitions:o,hash:d,...n.author?{author:n.author}:{},onDiff(m){return t.subscribe(m)},onCall(m){return k.add(m),()=>k.delete(m)},async call(m,l){let w=(o.find(p=>p.name===m)??o.find(p=>p.act===m))?.mutating??!1,S={name:m,args:l,mutating:w,at:new Date().toISOString()};A({...S,phase:"running"});let c=p=>(A(p.ok?{...S,phase:"ok",...!w&&p.reads?{reads:p.reads}:{}}:{...S,phase:"failed",error:p.error}),p),u=await h(m,l);return c(u.ok&&!w?{...u,data:(await H()).withinReadChars(m,u.data)}:u)}}}function ie(t){let n=typeof t=="function"?t():t;return n?{via:n}:{}}export{de as a,lt as b};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as we,b as De,c as Ke,d as le,e as A,f as Me,h as Te}from"./chunk.6YD2DLIC.js";import{h as Ge,i as Ce,j as Ne}from"./chunk.IKX4VDTW.js";import{a as oe,b as se,c as H,d as Pe,e as Y,g as ee,h as _e}from"./chunk.TBQOSI4J.js";import{c as Ae,h as z,i as Fe,j as de}from"./chunk.KWQ7QOHD.js";import{A as ve,Ga as Ee,Ha as Q,Ia as ae,Lb as ce,Mb as Re,b as L,c as q,e as Se,f as je,g as _,h as S,k as G,l as J,m as C,n as Oe,o as B,p as D,r as $,s as X,t as E,u as R,v as V,w as M,x as e,y as K,z as U,za as xe}from"./chunk.AS4CQBOQ.js";var sn=n=>Object.entries(n).map(([s,r])=>[s,Object.keys(Q(r?.edges))]),pe=(n,s)=>Re(n,sn(s));var me="graview-document",ge=1,ze=256*1024,ne=64*1024,fe=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,ue=/^[a-z][A-Za-z0-9]*$/,rn=new Set(["id","kind"]),an=/^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|[a-z][A-Za-z0-9]*)$/,cn=["string","text","number","integer","boolean","date","datetime","enum","list","url","email","image","video","file","app-link","phone","place","duration"];function dn(){let n=k=>k in Object.prototype,s=U(k=>!n(k),"every object already has this name \u2014 choose another"),r=(k,N)=>[...k===void 0?[]:[je(k)],...N===void 0?[]:[Se(N)]],t=(k,N)=>S().check(...r(k,N)),a=(k,N,on)=>D(k).check(...r(N,on)),d=k=>S().check(_(fe,`${k} names are kebab-case, lower-case words joined by hyphens like "tool-note" (field and relation names are camelCase, like "supersededBy")`)),u=S().check(_(an,'relation names are one camelCase word, like "supersededBy" (kind names are kebab-case, like "tool-note")'),s),m=S().check(_(ue,'field names are one word or camelCase, like "dueDate", so rules say them bare (kind names are kebab-case, like "tool-note")'),U(k=>!rn.has(k),'a field cannot be called "id" or "kind" \u2014 the framework keeps those; try "type" or "category"'),s),h=t(1,500),i=t(1,2e3),o=t(1,300),p=$({type:V(cn),required:e(C()),description:e(h),label:e(t(1,60)),options:e(a(t(1,80),1,100)),of:e(V(["string","number","date","image","video","file"])),default:e(B()),unit:e(t(void 0,12)),format:e(V(["money","percent","duration","markdown"])),min:e(G()),max:e(G()),step:e(G()),renamedFrom:e(S().check(_(ue))),repeats:e(C())}).check(ve((k,N)=>{k.type==="enum"&&!k.options&&N.addIssue({code:"custom",message:'an enum field lists its "options"',path:["options"]}),k.type!=="enum"&&k.options&&N.addIssue({code:"custom",message:'"options" belongs only on an enum field',path:["options"]}),k.type!=="list"&&k.of&&N.addIssue({code:"custom",message:'"of" belongs only on a list field',path:["of"]}),k.repeats&&k.type!=="date"&&k.type!=="datetime"&&N.addIssue({code:"custom",message:'"repeats" belongs only on a date or datetime field',path:["repeats"]})})),w=S().check(_(new RegExp(`${fe.source}|${xe.source}`),'a relation goes to a kind of this document, like "house", or of another app, like "@nick/house/house"')),f=$({to:E([a(w,1),M("*")]),cardinality:e(V(["one","many"])),description:e(h),inverse:e(t(1,80)),appendOnly:e(C()),renamedFrom:e(S()),tidying:e(M("never"))}),l=E([i,$({expr:i,label:e(t(1,60)),description:e(h)})]),c=$({noun:e(t(1,40)),plural:e(t(1,40)),description:e(h),fields:R(m,p).check(U(k=>Object.keys(k).length>0,"a kind has at least one field")),label:e(o),describe:e(o),lifecycle:e($({field:m,retired:a(E([S(),G(),C()]),1)})),figure:e(t(void 0,2e4)),glance:e(a(m,1,20)),page:e($({fields:e(a(m,1,40)),groups:e(a($({title:t(1,60),fields:a(m,1,40)}),1,12))})),edges:e(R(u,f)),computed:e(R(S(),l).check(U(k=>Object.keys(k).length<=20,"a kind works out at most 20 computed fields"))),fieldRoles:e(R(S(),S())),renamedFrom:e(S().check(_(fe))),people:e(C()),archives:e(M(!1)),tidying:e(V(["never","no-links"]))}),O=E([S(),G(),C(),Oe(),D(B()),$({expr:i})]),y=S().check(_(/^\$[A-Za-z][A-Za-z0-9]*$/,'a reference is "$" and a name, like "$subject" or "$new"')),j=E([$({create:d("kind"),as:e(S().check(_(ue))),set:e(R(m,O))}),$({set:R(m,O),target:e(y)}),$({connect:u,from:y,to:y}),$({sever:u,from:y,to:y}),$({remove:y})]),v=$({title:e(t(1,80)),description:e(h),fromTheOtherEnd:e(t(1,80)),on:e(E([d("kind"),a(d("kind"),1)])),creates:e(d("kind")),sets:e(R(m,O)),writes:e(a(m,1)),connects:e(u),severs:e(u),setsOther:e(R(m,O)),replaces:e(E([M(!0),a(u,1,10)])),removes:e(M(!0)),args:e(R(m,p)),effects:e(a(j,1,20)),allowedWhen:e(i),refusal:e(o),destructive:e(C())}),b=$({act:d("act"),label:e(t(1,80)),args:e(R(S(),O))}),W=$({title:e(t(1,120)),description:e(h),over:E([M("graph"),d("kind")]),when:e(i),require:i,says:e(o),repairs:e(a(b,void 0,10))}),P=$({roles:E([a(d("role"),1),M("*")]),mutations:E([a(d("act"),1),M("*")]),kinds:e(E([D(d("kind")),M("*")])),describe:e(h),self:e(C()),ownEnd:e(C())}),g=e(a(d("field"),1)),x=$({roles:E([a(d("role"),1),M("*")]),kinds:a(d("kind"),1),own:e(C()),via:e(u),fields:g,hide:g}),F=$({grants:D(P),sees:e(D(x))}),te=$({accent:e(S().check(_(/^#[0-9a-fA-F]{6}$/,'an accent is a color like "#c2577a"'))),name:e(t(1,60)),currency:e(S().check(_(/^[A-Z]{3}$/,'a currency is its three-letter code, like "USD" or "EUR"'))),locale:e(t(2,35)),timeZone:e(t(1,64)),logo:e(E([t(1,ne),$({src:t(1,ne),alt:e(t(1,120))}),$({light:t(1,ne),dark:e(t(1,ne)),alt:e(t(1,120)),darkFallback:e(M("invert"))})])),favicon:e(E([t(1,ne),$({emoji:S()})])),typography:e($({display:e(t(1,200)),body:e(t(1,200)),mono:e(t(1,200))})),shape:e($({radius:e(G().check(q(0),L(32))),density:e(G().check(q(.75),L(1.5)))})),accents:e(R(S(),G().check(q(0),L(360)))),scheme:e(V(["light","dark","auto"])),subtitle:e(M(!1))}),I=R(S(),B()),Z=E([t(1,120),$({by:t(1,120),direction:e(V(["asc","desc"]))})]),ke=G().check(J(),q(1),L(9999)),Je=X({create:e(C()),options:e(X({sort:e(Z),columnSort:e(Z),search:e(a(t(1,120),void 0,40)),filters:e(a(t(1,120),void 0,40)),horizon:e(E([G().check(J(),q(1),L(200)),X({years:G().check(J(),q(1),L(200)),title:t(1,80),from:e(ke),to:e(ke)})]))}))}),Xe=$({card:e(D(B())),row:e(D(B())),page:e(D(B()))}),Qe=()=>{let k=e(V(["asc","desc"]));return E([t(1,120),$({by:t(1,120),direction:k,then:e(E([t(1,120),$({by:t(1,120),direction:k})]))})])},en=()=>E([t(1,120),$({by:t(1,120),order:e(a(t(1,80),void 0,40)),closed:e(a(t(1,80),void 0,40))})]),$e=X({order:e(D(S())),hide:e(D(S())),first:e(S()),primary:e(a(t(1,80),void 0,40)),scene:e(t(1,40)),pages:e(t(1,40)),lists:e(R(S(),$({filters:e(a(t(1,120),void 0,40)),sort:e(Qe()),group:e(en())})))}),nn=$({act:d("act"),title:e(t(1,80)),intro:e(h),fields:e(a(m,1,40)),say:e(h),submit:e(t(1,80)),role:e(d("role"))}),tn=$({$schema:e(S()),format:M(me),formatVersion:M(ge),name:t(1,80),description:e(h),version:e(G().check(J(),q(1))),kinds:R(d("kind"),c).check(U(k=>Object.keys(k).length>0,"a document declares at least one kind"),U(k=>Object.keys(k).length<=40,"a document declares at most 40 kinds")),computed:e(R(S(),l)),acts:e(R(d("act"),v)),rules:e(R(d("rule"),W)),roles:e(D(d("role"))),policy:e(F),modules:e(I),lenses:e(D(Je)),pages:e($e),views:e(R(S(),E([Xe,D(B())]))),brand:e(te),settings:e(D(I)),migrations:e(D(I)),connections:e(R(d("connection"),I)),forms:e(R(d("form"),nn))});return{FieldSpec:p,EdgeSpec:f,ComputedSpec:l,KindSpec:c,ValueSpec:O,EffectSpec:j,ActSpec:v,RepairSpec:b,RuleSpec:W,GrantSpec:P,SightSpec:x,PolicySpec:F,BrandSpec:te,PagesSpec:$e,DocumentSpec:tn}}var ln,T=()=>ln??=dn(),jn=K(()=>T().FieldSpec),On=K(()=>T().EdgeSpec),vn=K(()=>T().ComputedSpec),xn=K(()=>T().KindSpec),En=K(()=>T().ValueSpec),Rn=K(()=>T().EffectSpec),An=K(()=>T().ActSpec),Fn=K(()=>T().RepairSpec),Dn=K(()=>T().RuleSpec),Kn=K(()=>T().GrantSpec),Mn=K(()=>T().SightSpec),Tn=K(()=>T().PolicySpec),Pn=K(()=>T().BrandSpec),Gn=K(()=>T().PagesSpec),Ie=K(()=>T().DocumentSpec);var pn={};function Ve(n,s=pn,r=ge){let{document:t,respelled:a}=we(n),d=a.length>0?{respelled:a}:{};if(!t||typeof t!="object"||Array.isArray(t))return{document:t};let u=t;if(u.format!==me||typeof u.formatVersion!="number"||u.formatVersion>=r)return{document:t,...d};let m=u.formatVersion,h=structuredClone(u);for(let i=m;i<r;i++){let o=s[i];if(!o)throw new Error(`there is no upgrade from format ${i} to ${i+1}`);h={...o(h),formatVersion:i+1}}return{document:h,from:m,...d}}function qe(n,s,r){let t=Object.keys(n).filter(m=>n[m].edges?.[s]!==void 0);if(t.length===0)return;let a=t.map(m=>n[m].edges[s].to),d=a.some(m=>m==="*")?"*":[...new Set(a.flatMap(m=>m))];if(r.length===0||r.some(m=>t.includes(m)))return{reversed:!1,kinds:d};let u=t.filter(m=>{let h=n[m].edges[s].to;return h==="*"||r.every(i=>h.includes(i))});return u.length>0?{reversed:!0,kinds:u}:{reversed:!1,kinds:d}}var Ue=(n,s)=>{let r=n?.fields[s];return r!==void 0&&(r.type==="duration"||(r.type==="number"||r.type==="integer")&&r.format==="duration")};function Be(n,s,r,t){if(t==="out"){let a=n[s]?.edges?.[r]?.to;return a===void 0?[]:a==="*"?Object.keys(n):a}return Object.entries(n).filter(([,a])=>{let d=a.edges?.[r]?.to;return d!==void 0&&(d==="*"||d.includes(s))}).map(([a])=>a)}function ye(n,s,r){if(r.t==="ident")return n[s]?.edges?.[r.name]?Be(n,s,r.name,"out"):void 0;if(r.t==="where")return ye(n,s,r.set);if(r.t==="call"&&(r.fn==="out"||r.fn==="in")&&r.args[0]?.t==="lit"&&typeof r.args[0].value=="string")return Be(n,s,r.args[0].value,r.fn)}var Le=(n,s,r)=>{let t=s.filter(a=>n[a]?.fields[r]!==void 0);return t.length>0&&t.every(a=>Ue(n[a],r))};function We(n,s,r){let t=n.kinds,a=t[s],d=new Map(r),u=new Map,m=(i,o)=>{if(o>8)return!1;switch(i.t){case"ident":return Ue(a,i.name)||h(i.name,o+1);case"member":{let p=ye(t,s,i.object);return p!==void 0&&Le(t,p,i.name)}case"call":{if(i.fn!=="sum"&&i.fn!=="min"&&i.fn!=="max")return!1;let[p,w]=i.args,f=p&&ye(t,s,p);return f!==void 0&&w?.t==="ident"&&Le(t,f,w.name)}case"binary":return(i.op==="+"||i.op==="-")&&m(i.left,o)&&m(i.right,o);case"unary":return i.op==="-"&&m(i.operand,o);default:return!1}},h=(i,o)=>{if(a?.computed?.[i]===void 0)return!1;if(u.has(i))return u.get(i);u.set(i,!1);let p=d.get(i),w=p!==void 0&&m(p,o);return u.set(i,w),w};return r.map(([i])=>i).filter(i=>h(i,0))}function Ze(n,s,r=`kinds.${n}.page`){let t=s.page;if(!t)return[];let a=[],d=[...Object.keys(s.fields),...Object.keys(s.computed??{})],u=new Set,m=(i,o)=>{d.includes(i)?u.has(i)&&a.push(z("page-field-twice",o,`"${i}" is on ${n}'s page twice; name each field once`)):a.push(z("page-field",o,`${n}'s page is to show "${i}", and ${n} has no field or computed field called that`,`use one of: ${d.join(", ")}`)),u.add(i)};(t.fields??[]).forEach((i,o)=>m(i,`${r}.fields.${o}`));let h=new Set;return(t.groups??[]).forEach((i,o)=>{let p=i.title.trim().toLowerCase();h.has(p)&&a.push(z("page-group-twice",`${r}.groups.${o}.title`,`${n}'s page has two groups called "${i.title}"; give each its own title`)),h.add(p),i.fields.forEach((w,f)=>m(w,`${r}.groups.${o}.fields.${f}`))}),a}var fn=new Set(["subject","now","today","me"]);function un(n){if((typeof n=="string"?n:JSON.stringify(n??null)).length>ze)return{findings:[z("too-large","",`a document may be at most ${ze/1024} KB`)]};if(typeof n=="string")try{n=JSON.parse(n)}catch(t){return{findings:[z("not-json","",`this is not JSON: ${t.message}`)]}}try{n=Ve(n).document}catch(t){return{findings:[z("format","formatVersion",t.message)]}}let s=Ie.safeParse(n);if(!s.success)return{findings:s.error.issues.map(t=>{let a=t.path.map(String).join(".");if(t.code==="unrecognized_keys")return z("unknown-key",a,`${t.keys.map(d=>`"${d}"`).join(", ")} ${t.keys.length===1?"is":"are"} not part of a Graview document here`,"check the spelling against docs/declaration-document.md");if(t.code==="invalid_union"&&/\.effects\.\d+$/.test(a))return z("effect-shape",a,"this effect is not one Graview knows",'an effect is one of {"create": kind, "as"?: name, "set"?: {field: value}}, {"set": {field: value, \u2026}, "target"?: "$ref"}, {"connect"|"sever": relation, "from": "$ref", "to": "$ref"}, {"remove": "$ref"}');if(t.code==="invalid_key"){let d=t.issues?.[0]?.message;return z("shape",a,`the name "${String(t.path.at(-1))}" is not allowed here${d?`: ${d}`:""}`)}return z("shape",a,t.message)})};let r=s.data;return{document:r,findings:mn(r)}}var re=n=>[n??[]].flat();function He(n){let s=new Map;for(let[r,t]of Object.entries(n.kinds))for(let[a,d]of Object.entries(Q(t.edges))){let u=s.get(a);s.set(a,{name:a,from:[...u?.from??[],r],to:d.to==="*"||u?.to==="*"?"*":[...new Set([...u?.to??[],...d.to])],cardinality:d.cardinality??"many"})}return s}function pt(n){let s=new Map;for(let[t,a]of Object.entries(n.kinds)){let d=ee(a),u=ae(a.edges);s.set(t,{fields:new Set([...Object.keys(a.fields),...u.keys()]),edges:new Map(Object.entries(Q(a.edges)).map(([m,h])=>[m,h.cardinality??"many"])),...d?{computed:d}:{},...u.size>0?{linked:u}:{}})}let r=ee(n);return r&&s.set(Ae,{computed:r}),s}function Ye(n,s){let r=[],t=re(n.on),a=(d,u)=>{let m=qe(s.kinds,d,t)?.reversed===!0,[h,i]=m?["$to","$subject"]:["$subject","$to"];return u==="connect"?{connect:d,from:h,to:i}:{sever:d,from:h,to:i}};if(n.creates){let d=s.kinds[n.creates],u={};for(let m of Object.keys(d?.fields??{}))u[m]=`$${m}`;for(let m of n.effects??[])"set"in m&&!("create"in m)&&A(m.target)==="new"&&Object.assign(u,m.set);r.push({create:n.creates,as:"new",set:u})}return n.sets&&r.push({set:n.sets}),n.writes&&!(n.creates&&n.on===void 0)&&r.push({set:Object.fromEntries(n.writes.map(d=>[d,`$${d}`]))}),n.connects&&(n.replaces&&r.push({replace:n.replaces===!0?[n.connects]:[...n.replaces],keep:n.connects}),r.push(a(n.connects,"connect"))),n.severs&&r.push(a(n.severs,"sever")),n.setsOther&&(n.connects||n.severs)&&r.push({set:n.setsOther,target:"$to"}),n.removes&&r.push({remove:"$subject"}),n.effects&&r.push(...n.effects.filter(d=>!(n.creates&&"set"in d&&!("create"in d)&&A(d.target)==="new"))),r}function he(n,s,r){try{let t=H(n),a=oe(t);for(let d of a.unknownFunctions)r.push(z("unknown-function",s,`"${d}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));return t}catch(t){if(t instanceof se){r.push(z("expression",s,t.sentence+` (at character ${t.at+1})`));return}throw t}}function be(n,s,r){try{return Y(n)}catch(t){if(t instanceof Pe||t instanceof se){r.push(z("template",s,(t instanceof se,t.sentence)));return}throw t}}function mn(n){let s=[],r=new Set(Object.keys(n.kinds)),t=He(n),a=n.acts??{},d=new Set(n.roles??[]),u=(i,o)=>ae(n.kinds[i]?.edges).has(o),m=i=>Object.keys(n.kinds).some(o=>u(o,i));for(let[i,o]of Object.entries(n.kinds)){let p=`kinds.${i}`;for(let[f,l]of Object.entries(o.edges??{})){if(!Ee(l)&&l.to!=="*")for(let c of l.to)r.has(c)||s.push(z("edge-target",`${p}.edges.${f}.to`,`"${c}" is not a kind this document declares`));o.fields[f]&&s.push(z("edge-field-clash",`${p}.edges.${f}`,`"${f}" is both a field and a relation of ${i}`,"rename one of them"))}o.lifecycle&&!o.fields[o.lifecycle.field]&&s.push(z("lifecycle-field",`${p}.lifecycle.field`,`${i} has no field "${o.lifecycle.field}"`));let w=f=>o.computed!==void 0&&Object.hasOwn(o.computed,f);for(let f of o.glance??[])!o.fields[f]&&!w(f)&&s.push(z("glance-field",`${p}.glance`,`a glance at ${i} is to say "${f}", and ${i} has no field or computed field called that`,`use one of: ${[...Object.keys(o.fields),...Object.keys(o.computed??{})].join(", ")}`));s.push(...Ze(i,o));for(let f of["label","describe"]){let l=o[f];if(!l)continue;let c=be(l,`${p}.${f}`,s);for(let O of c??[])if(O.expr){for(let y of oe(O.expr).names)if(!o.fields[y]){if(w(y)){_e(o,y)||s.push(z("template-field",`${p}.${f}`,`${i}'s ${y} is worked out from beyond the record, and a ${f} is said with no graph to read`,`show it in a view instead, or name a computed field worked out from ${i}'s own fields`));continue}s.push(z("template-field",`${p}.${f}`,`${i} has no field "${y}" for its ${f} to show`,f==="label"?"a label can only show the record's own fields and what they work out":void 0))}}}for(let[f,l]of Object.entries(o.fields)){l.default!==void 0&&l.type==="enum"&&!l.options?.includes(String(l.default))&&s.push(z("default-option",`${p}.fields.${f}.default`,`"${String(l.default)}" is not one of ${f}'s options`));let c=`${f}Repeat`;l.repeats&&(o.fields[c]||o.edges?.[c]||o.computed?.[c])&&s.push(z("repeat-clash",`${p}.fields.${f}.repeats`,`${i} already has "${c}", where how ${f} repeats is kept`))}}for(let[i,o]of Object.entries(a)){let p=`acts.${i}`;for(let c of re(o.on))r.has(c)||s.push(z("act-kind",`${p}.on`,`"${c}" is not a kind this document declares`));let w=re(o.on),f=Ye(o,n);if(o.creates&&o.on===void 0&&o.writes&&r.has(o.creates)){for(let c of o.writes)if(!n.kinds[o.creates].fields[c])if(n.kinds[o.creates].computed?.[c]!==void 0)s.push(z("computed-written",`${p}.writes`,`${o.creates}'s ${c} is worked out, not written: no act can set it`,"write the stored fields it is worked out from"));else{if(u(o.creates,c))continue;s.push(z("act-field",`${p}.writes`,`${o.creates} has no field "${c}"`))}}f.length===0&&s.push(z("act-empty",p,`"${i}" does nothing`,"give it effects or a shorthand such as sets or creates"));let l=new Map;f.forEach((c,O)=>{let y=f.length-(o.effects?.length??0),j=o.effects&&O>=y?`${p}.effects.${O-y}`:p;if("create"in c){if(!r.has(c.create))s.push(z("act-kind",`${j}.create`,`"${c.create}" is not a kind this document declares`));else for(let b of Object.keys(c.set??{}))n.kinds[c.create].fields[b]||(n.kinds[c.create].computed?.[b]!==void 0?s.push(z("computed-written",`${j}.set.${b}`,`${c.create}'s ${b} is worked out, not written: no act can set it`,"set the stored fields it is worked out from")):s.push(z("act-field",`${j}.set.${b}`,`${c.create} has no field "${b}"`)));c.as&&l.set(c.as,c.create)}else if("connect"in c||"sever"in c){let b="connect"in c?c.connect:c.sever;!t.has(b)&&!m(b)&&s.push(z("act-edge",`${j}.${"connect"in c?"connect":"sever"}`,`"${b}" is not a relation any kind declares`)),A(c.from)==="subject"&&w.length===0&&s.push(z("act-subject",`${p}.on`,`"${i}" acts on "$subject" but does not say which kinds it is "on"`))}else if("set"in c){let b=A(c.target??"$subject"),W=b==="subject"?w:l.has(b??"")?[l.get(b)]:[];b==="subject"&&w.length===0&&s.push(z("act-subject",`${p}.on`,`"${i}" changes "$subject" but does not say which kinds it is "on"`));for(let P of Object.keys(c.set))for(let g of W)if(!(!r.has(g)||n.kinds[g].fields[P]))if(n.kinds[g].computed?.[P]!==void 0)s.push(z("computed-written",`${j}.set.${P}`,`${g}'s ${P} is worked out, not written: no act can set it`,"set the stored fields it is worked out from"));else{if(u(g,P))continue;s.push(z("act-field",`${j}.set.${P}`,`${g} has no field "${P}"`))}}else"remove"in c&&A(c.remove)==="subject"&&w.length===0&&s.push(z("act-subject",`${p}.on`,`"${i}" removes "$subject" but does not say which kinds it is "on"`));("set"in c&&c.set?Object.values(c.set):[]).forEach(b=>{b&&typeof b=="object"&&!Array.isArray(b)&&"expr"in b&&he(b.expr,`${j}.set`,s)})}),o.allowedWhen&&he(o.allowedWhen,`${p}.allowedWhen`,s),o.refusal&&be(o.refusal,`${p}.refusal`,s)}for(let[i,o]of Object.entries(n.rules??{})){let p=`rules.${i}`;o.over!=="graph"&&!r.has(o.over)&&s.push(z("rule-kind",`${p}.over`,`"${o.over}" is not a kind this document declares`));let w=o.over==="graph"?void 0:n.kinds[o.over];for(let f of["when","require"]){let l=o[f];if(!l)continue;let c=he(l,`${p}.${f}`,s);if(!c)continue;let O=oe(c);for(let y of O.names)if(o.over==="graph")s.push(z("rule-name",`${p}.${f}`,`"${y}" means nothing in a rule over the whole graph`,`name a kind in "over", or use all('kind')`));else if(w&&!w.fields[y]&&!w.edges?.[y]&&w.computed?.[y]===void 0){let j=Object.keys(w.edges??{}).find(v=>v.includes("-")&&v.split("-").includes(y));s.push(z("rule-name",`${p}.${f}`,`${o.over} has no field or relation called "${y}"`,j?`"${j}" reads as a subtraction in a rule; rename the relation to one camelCase word, like "${j.replace(/-([a-z0-9])/g,(v,b)=>b.toUpperCase())}"`:void 0))}for(let y of O.edges)!t.has(y)&&!m(y)&&s.push(z("rule-edge",`${p}.${f}`,`"${y}" is not a relation any kind declares`));for(let y of O.sweeps)r.has(y)?o.over!=="graph"&&s.push(Fe("rule-cost",`${p}.${f}`,`this rule looks at every ${y} for every ${o.over}, which grows slowly as the app grows`,"walk a relation with out()/in() instead of all() where you can")):s.push(z("rule-kind",`${p}.${f}`,`"${y}" is not a kind this document declares`))}o.says&&be(o.says,`${p}.says`,s),(o.repairs??[]).forEach((f,l)=>{!a[f.act]&&!ce(f.act)&&!pe(f.act,n.kinds)&&s.push(z("repair-act",`${p}.repairs.${l}.act`,`"${f.act}" is not an act this document declares`))})}let h=n.policy;return h&&(h.grants.forEach((i,o)=>{if(i.roles!=="*"&&d.size>0)for(let p of i.roles)d.has(p)||s.push(z("grant-role",`policy.grants.${o}.roles`,`"${p}" is not one of the document's roles`));if(i.mutations!=="*")for(let p of i.mutations)!a[p]&&!ce(p)&&!pe(p,n.kinds)&&s.push(z("grant-act",`policy.grants.${o}.mutations`,`"${p}" is not an act this document declares`))}),(h.sees??[]).forEach((i,o)=>{for(let p of i.kinds)r.has(p)||s.push(z("sight-kind",`policy.sees.${o}.kinds`,`"${p}" is not a kind this document declares`));if(i.roles!=="*"&&d.size>0)for(let p of i.roles)d.has(p)||s.push(z("sight-role",`policy.sees.${o}.roles`,`"${p}" is not one of the document's roles`))})),s.push(...Ne(n)),s}function gn(n,s,r,t){let a=new Map,d=re(n.on),u=new Map,m=new Map;(d.length>0||s.some(l=>"remove"in l&&A(l.remove)==="subject"||"from"in l&&(A(l.from)==="subject"||A(l.to)==="subject")||"set"in l&&!("create"in l)&&A(l.target??"$subject")==="subject"))&&a.set(le,{ref:d.length>0?d:"*",required:!0});let i=n.args??{},o=n.writes?.length===1,p=(l,c)=>c&&l.type===c.type&&l.min===void 0&&l.max===void 0&&l.step===void 0?{...l,...c.min===void 0?{}:{min:c.min},...c.max===void 0?{}:{max:c.max},...c.step===void 0?{}:{step:c.step}}:l,w=(l,c)=>c&&l.type===c.type&&l.format===void 0&&l.unit===void 0?{...p(l,c),...c.format?{format:c.format}:{},...c.unit?{unit:c.unit}:{}}:p(l,c),f=(l,c,O)=>{if(l===le||fn.has(l)||u.has(l)||a.has(l))return;let y=i[l]?w(i[l],O):void 0;a.set(l,y?{field:y,optional:!y.required,required:!!y.required}:c())};for(let l of s)if("create"in l){let c=r.kinds[l.create];for(let[O,y]of Object.entries(l.set??{})){let j=A(y),v=c?.fields[O];if(j&&v){let b=!!v.required&&v.default===void 0;f(j,()=>({field:v,optional:!b,required:b}),v)}}l.as&&u.set(l.as,l.create)}else if("connect"in l||"sever"in l){let c=t.get("connect"in l?l.connect:l.sever);for(let[O,y]of[["from",l.from],["to",l.to]]){let j=A(y);if(!j)continue;let v=O==="to"?c?.to??"*":c?.from??"*";v!=="*"&&!m.has(j)&&m.set(j,v),f(j,()=>({ref:v,required:!0}))}}else if("set"in l){let c=A(l.target??"$subject"),O=c==="subject"?d[0]:u.get(c??"")??m.get(c??"")?.[0];c&&c!=="subject"&&!u.has(c)&&f(c,()=>({ref:"*",required:!0}));for(let[y,j]of Object.entries(l.set)){let v=A(j);if(!v)continue;let b=O?r.kinds[O]?.fields[y]:void 0;f(v,()=>b?{field:b,optional:!o,required:o}:{any:!0,required:!1},b)}}else if("remove"in l){let c=A(l.remove);c&&f(c,()=>({ref:"*",required:!0}))}for(let[l,c]of Object.entries(i))a.has(l)||a.set(l,{field:c,optional:!c.required,required:!!c.required});return a}function ft(n,s={}){let r=un(n);if(!r.document||de(r.findings))return{ok:!1,findings:r.findings};let t=r.document,a=[...r.findings];s.previous&&a.push(...yn(t,s.previous));let d=zn(t,a);return de(d.findings)?{ok:!1,findings:d.findings}:Te(d,s)}function ie(n,s){return n.map(r=>{let t=!r.format&&r.expr?.t==="ident"?s?.[r.expr.name]?.format:void 0;return t==="money"||t==="percent"?{...r,format:t}:r})}function zn(n,s){let r=He(n),t={};for(let[i,o]of Object.entries(n.kinds)){let p=Me(o),w=o.label??(p?`{${p}}`:void 0),f=ee(o),l=f?We(n,i,[...f]):[];t[i]={...w?{label:ie(Y(w),o.fields)}:{},...o.describe?{describe:ie(Y(o.describe),o.fields)}:{},...f?{computed:[...f]}:{},...l.length>0?{durations:l}:{}}}let a={};for(let[i,o]of Object.entries(n.acts??{})){let p=Ye(o,n),w=gn(o,p,n,r),f=o.destructive??p.some(g=>"remove"in g||"sever"in g||"replace"in g),l=[...new Set(p.flatMap(g=>"create"in g?[g.create]:[]))],c=[...new Set(p.flatMap(g=>"connect"in g?[g.connect]:[]))],O=[...new Set(p.flatMap(g=>"sever"in g?[g.sever]:"replace"in g?g.replace:[]))],y=[...new Set(p.flatMap(g=>"set"in g&&!("create"in g)&&A(g.target??"$subject")==="subject"?Object.keys(g.set):[]))],j=new Map;for(let g of p){if(!("connect"in g)&&!("sever"in g))continue;let x=r.get("connect"in g?g.connect:g.sever);for(let[F,te]of[["from",g.from],["to",g.to]]){let I=A(te),Z=F==="to"?x?.to:x?.from;I&&I!=="subject"&&Z&&Z!=="*"&&j.set(I,[...new Set([...j.get(I)??[],...Z])])}}let v={};for(let g of p){if(!("set"in g)||"create"in g)continue;let x=A(g.target??"$subject");for(let F of x&&x!=="subject"&&j.get(x)||[])v[F]=[...new Set([...v[F]??[],...Object.keys(g.set)])]}let b={};for(let g of p)if(!(!("set"in g)||"create"in g||A(g.target??"$subject")!=="subject"))for(let[x,F]of Object.entries(g.set??{}))typeof F=="string"&&A(F)===void 0||typeof F=="number"||typeof F=="boolean"?b[x]=typeof F=="string"&&F.startsWith("$$")?F.slice(1):F:delete b[x];let W=l.length===0&&p.every(g=>!("set"in g)||!g.set||Object.values(g.set).every(x=>!(x&&typeof x=="object"&&!Array.isArray(x)&&"expr"in x))),P=new Map;for(let g of p)if(!(!("set"in g)||!g.set))for(let x of Object.values(g.set))x&&typeof x=="object"&&!Array.isArray(x)&&"expr"in x&&P.set(x.expr,H(x.expr));a[i]={title:o.title??i.replace(/-/g," "),effects:p,args:[...w],...o.allowedWhen?{guard:H(o.allowedWhen)}:{},...o.refusal?{refusal:ie(Y(o.refusal),n.kinds[[o.on??[]].flat()[0]??""]?.fields)}:{},exprs:[...P],destructive:f,idempotent:W,creates:l,connects:c,severs:O,writes:y,writesOther:v,sets:b}}let d={};for(let[i,o]of Object.entries(n.rules??{}))d[i]={title:o.title??i.replace(/-/g," "),require:H(o.require),...o.when?{when:H(o.when)}:{},...o.says?{says:ie(Y(o.says),n.kinds[o.over]?.fields)}:{}};let u=De(n,s),m=Ge(n),h=Ce(n);return{format:Ke,document:n,findings:s,kinds:t,...n.computed?{facts:[...ee(n)??[]]}:{},edges:[...r].map(([i,{from:o,to:p,cardinality:w}])=>[i,{from:o,to:p,cardinality:w}]),acts:a,rules:d,brand:u,...Object.keys(m).length>0?{viewSpecs:m}:{},...h?{home:h}:{}}}function ut(n,s,r){let t=/^defineNode\("([^"]+)"\)/.exec(s)?.[1],a=t?r.kinds[t]:void 0;if(!t||!a)return n;let d=Object.keys(a.fields).filter(u=>u!=="label").slice(0,3);return{...n,path:`kinds.${t}.glance`,fix:`Say which: "glance": [${d.map(u=>`"${u}"`).join(", ")}] on kinds.${t} \u2014 the facts a person compares one by, at a glance.`}}function yn(n,s){let r=[],t=new Set(Object.values(s.kinds).flatMap(a=>Object.keys(a.edges??{})));for(let[a,d]of Object.entries(n.kinds)){let u=d.renamedFrom;u&&!s.kinds[u]&&r.push(z("renamed-from-nothing",`kinds.${a}.renamedFrom`,`${a} says it was ${u}, and the previous version has no kind called ${u}`,"name the kind it was, or drop renamedFrom"));let m=s.kinds[u??a];for(let[h,i]of Object.entries(d.fields)){let o=i.renamedFrom;o&&!m?.fields[o]&&r.push(z("renamed-from-nothing",`kinds.${a}.fields.${h}.renamedFrom`,`${h} says it was ${o}, and the previous ${u??a} has no field called ${o}`,"name the field it was, or drop renamedFrom"))}for(let[h,i]of Object.entries(d.edges??{})){let o=i.renamedFrom;o&&!t.has(o)&&r.push(z("renamed-from-nothing",`kinds.${a}.edges.${h}.renamedFrom`,`${h} says it was ${o}, and the previous version has no relation called ${o}`,"name the relation it was, or drop renamedFrom"))}}return r}export{un as a,pt as b,Ye as c,ft as d,ut as e};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk.L4YNDNX7.js";import"./chunk.GCKZ2YRJ.js";import"./chunk.VC3UGFHY.js";import"./chunk.IJNOT4S4.js";import"./chunk.YHH4TWZ2.js";import"./chunk.O2WWYZI7.js";import"./chunk.AGIO2GRV.js";import"./chunk.VSNHCGKC.js";import"./chunk.HJCQ6I3S.js";import"./chunk.BNPQUI3F.js";import"./chunk.6RY6OSE6.js";import"./chunk.RX2M4C5W.js";import"./chunk.SWWAEOZ7.js";import"./chunk.IROYMLER.js";import"./chunk.FWSCBHZ5.js";import"./chunk.7NNI7YH4.js";import"./chunk.7N2GXZYI.js";import"./chunk.MF73YBJL.js";import"./chunk.63MS2LOP.js";import"./chunk.PKUDIWIF.js";import"./chunk.VW2VCPJX.js";import"./chunk.WBHM5I3I.js";import"./chunk.FOQ27RAR.js";import"./chunk.UKAPFIPJ.js";import"./chunk.UT6642FC.js";import"./chunk.Q7RQC3F7.js";import"./chunk.WVUJXDXZ.js";import"./chunk.ZIEHF67C.js";import"./chunk.UHX4WTM7.js";import"./chunk.IKX4VDTW.js";import"./chunk.RNEJYIQ7.js";import"./chunk.TBQOSI4J.js";import"./chunk.KWQ7QOHD.js";import"./chunk.GZHZLJBF.js";import"./chunk.5AGW4NRZ.js";import"./chunk.OJGHDWI6.js";import"./chunk.DQS7D2W2.js";import"./chunk.HDRD33II.js";import"./chunk.DX357TZ3.js";import"./chunk.H7KCWCB4.js";import"./chunk.O4WEJ47H.js";import"./chunk.Y4ZUJUUT.js";import"./chunk.SDO3U72B.js";import"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import"./chunk.AJZBJBMO.js";export{b as declaredLensView,a as formatFor};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as Z,b as qe}from"./chunk.5A4AOFOA.js";import"./chunk.KSXB4LDF.js";import"./chunk.2L3VFGHX.js";import{i as De,j as Ne,k as Oe}from"./chunk.IJNOT4S4.js";import"./chunk.VSNHCGKC.js";import"./chunk.HJCQ6I3S.js";import"./chunk.BNPQUI3F.js";import"./chunk.6RY6OSE6.js";import"./chunk.47RTA6M3.js";import"./chunk.RX2M4C5W.js";import"./chunk.64WM4IBI.js";import{a as We,b as S}from"./chunk.IQ2HKGJS.js";import{a as X,b as $e}from"./chunk.R6V37SR7.js";import"./chunk.IROYMLER.js";import"./chunk.7NNI7YH4.js";import"./chunk.PKUDIWIF.js";import"./chunk.VW2VCPJX.js";import"./chunk.WBHM5I3I.js";import"./chunk.FOQ27RAR.js";import"./chunk.UKAPFIPJ.js";import{b as Pe,c as Le}from"./chunk.UT6642FC.js";import"./chunk.WAB7UDHU.js";import"./chunk.IW7YFPGG.js";import"./chunk.TI4OSTQV.js";import"./chunk.Q7RQC3F7.js";import"./chunk.ZIEHF67C.js";import"./chunk.UHX4WTM7.js";import"./chunk.IKX4VDTW.js";import"./chunk.RNEJYIQ7.js";import"./chunk.TBQOSI4J.js";import"./chunk.KWQ7QOHD.js";import{u as Re}from"./chunk.5AGW4NRZ.js";import"./chunk.OJGHDWI6.js";import"./chunk.DQS7D2W2.js";import{g as ze}from"./chunk.HDRD33II.js";import"./chunk.DX357TZ3.js";import{c as Ce}from"./chunk.H7KCWCB4.js";import{m as Ie}from"./chunk.O4WEJ47H.js";import{G as ot,Ja as J,Oa as He,R as Me,Sa as Ee,_ as O,h as Ae,u as Te}from"./chunk.Y4ZUJUUT.js";import"./chunk.SDO3U72B.js";import{Zb as xe,_b as ke,ka as Q,la as N,wb as be,wc as Se}from"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import{b as Y}from"./chunk.AJZBJBMO.js";var a=Y(ot(),1);var t=Y(Me(),1);function bt(u,r,o){let c=r.on??r.about[r.about.length-1];De(u,r.about,{...o,pins:Z(),...c===void 0?{}:{focus:c}})}function xt({placement:u="float",chosen:r=!0}={}){let{menuAt:o}=O();return u==="menu"&&o===null?r?(0,t.jsx)(at,{}):null:(0,t.jsx)(lt,{placement:u})}function at(){let{store:u,setMenuAt:r,view:o}=O(),{selection:c}=J(),h=(0,a.useRef)(null),[E,y]=(0,a.useState)(null);(0,a.useLayoutEffect)(()=>{let b=h.current?.offsetParent??h.current?.parentElement;if(!b)return;let m=Math.round(b.getBoundingClientRect().width);m!==E&&y(m)});let v=c.length===1&&!o.overview?u.graph.getNode(c[0]):void 0;return!v||E===null||E>=Be?(0,t.jsx)("span",{ref:h,hidden:!0}):(0,t.jsx)("button",{type:"button",ref:h,"data-testid":"chosen-acts","aria-label":`What can be done with ${S(u,v.id)}`,"aria-haspopup":"menu",onClick:b=>{let m=b.currentTarget.getBoundingClientRect();r({x:Math.round(m.right),y:Math.round(m.bottom+4),on:v.id})},style:{position:"absolute",right:"calc(14px + var(--graview-dock, 0px))",top:98,zIndex:"var(--graview-layer-overview, 10)",minHeight:30,padding:"0 12px",borderRadius:8,fontSize:"0.8125rem",background:"var(--graview-float)",boxShadow:"var(--graview-lift-low)"},children:"Acts\u2026"})}var Be=564;function lt({placement:u}){let{store:r,menuAt:o,setMenuAt:c,view:h,signIn:E}=O(),y=(0,a.useRef)(null),v=(0,a.useRef)(null),b=(0,a.useRef)(null),m=(0,a.useRef)(null);o?.returnTo&&(m.current=o.returnTo);let Ke=e=>{let i=e.closest("[data-graview-asking]")?.getAttribute("data-graview-asking"),n=e.getAttribute("data-pin-for"),d=i??e.getAttribute("data-affordance")??(n===null?null:`pin:${n}`)??e.getAttribute("data-menu-item");v.current=d===null?null:{key:d,element:e}};(0,a.useEffect)(()=>{let e=y.current,i=v.current;if(i===null||document.activeElement!==document.body||i.element.isConnected)return;let n=i.key;if(!e){v.current=null;let k=m.current;m.current=null,(k?.isConnected?k:b.current)?.focus();return}((n.startsWith("pin:")?e.querySelector(`[data-pin-for="${CSS.escape(n.slice(4))}"]`):null)??e.querySelector(`[data-affordance="${CSS.escape(n)}"]:not([disabled])`)??e).focus()});let[_e,je]=(0,a.useState)(null);(0,a.useLayoutEffect)(()=>{let e=y.current?.offsetParent??y.current?.parentElement;if(e instanceof HTMLElement&&(b.current=e),!e)return;let i=e.getBoundingClientRect();je(n=>n&&n.left===i.left&&n.top===i.top&&n.width===i.width&&n.height===i.height?n:{left:i.left,top:i.top,width:i.width,height:i.height})});let{selection:Ue,set:Ve,clear:Ge}=J(),s=o?.about??Ue,[q,Ye]=(0,a.useState)(()=>Z()),F=o?.on??s[s.length-1],B=o?.about,Qe=(0,a.useMemo)(()=>({pins:q,...F===void 0?{}:{focus:F},...B?{about:B}:{}}),[q,F,B]),Je=(0,a.useMemo)(()=>new Set(r.allMutations().filter(e=>e.pinned).map(e=>e.name)),[r]),{affordances:g,withheld:ee,observations:te}=Ne(Qe),I=ke(ee,E),f=I?st:ee,Xe=o===null?null:{face:o.face??"scene",on:o.on,about:s,field:o.field,place:o.place,href:o.href,act:o.act,element:o.returnTo},ne=Re(Xe),ie=te.some(e=>e.id.startsWith("schema:waits:")),{apply:Ze,preview:et}=Oe(),[C,z]=(0,a.useState)(null),[tt,re]=(0,a.useState)(!1),[oe,ae]=(0,a.useState)(!1),[L,R]=(0,a.useState)(""),nt=$e({letters:!0}),[le,K]=(0,a.useState)(null),_=(0,a.useRef)([]),j=(e,i)=>{try{return et(e,i),Ze(e,i),K(null),c(null),_.current=[],!0}catch(n){return K(ze(r.schema,r.allMutations(),n)),_.current=n instanceof be?n.issues.map(d=>String(d.path[0]??"")).filter(Boolean):[],!1}},$=[...new Set(s.flatMap(e=>{let i=r.graph.getNode(e);return i?[i.kind]:[]}))],x=$.length>0?$:[...new Set(s.flatMap(e=>Te(e)))],p=s.length===1?Ae(s[0]):null,U=p?{from:r.graph.getNode(p.from),to:r.graph.getNode(p.to)}:null,se=p?Le(r,p):void 0,de=se?.provisional?se:void 0,ue=p?(()=>{let e=r.schema.tryDefinition(r.graph.getNode(p.from)?.kind??"")?.edges?.[p.kind],i=r.graph.getNode(p.to);return e?.inverse&&i?`From ${S(r,i.id)}: ${e.inverse}`:null})():null;(0,a.useEffect)(()=>{z(null),re(!1),ae(!1),K(null),R("")},[s,o?.about]);let l=o!==null,it=u==="menu"&&!l,A=(0,a.useRef)(o);A.current=o;let pe=Ee("acts",{open:l&&u==="menu",onOpenChange:e=>{e||c(null)},at:()=>A.current?{x:A.current.x,y:A.current.y}:null,returnTo:()=>{let e=A.current?.returnTo;if(e?.isConnected)return e;let i=A.current?.on;return i?document.querySelector(`[data-graview-view="${CSS.escape(i)}"]`):null},align:"start"}),ce=(_e?.width??Number.POSITIVE_INFINITY)<Be;if((0,a.useLayoutEffect)(()=>{let e=y.current?.offsetParent;if(!e||!ce||l)return;let i=y.current?.getBoundingClientRect().height??0,n=`${Math.round(i)+20}px`;if(e.style.paddingBottom===n)return;let d=e.style.paddingBottom;return e.style.paddingBottom=n,()=>{e.style.paddingBottom=d}}),s.length===0&&!l)return null;let ge=o?.title!==void 0||s.length>0&&!(s.length===1&&s[0]===h.focusId),he=Math.max(1,Math.min(9,g.length)),T=[...g.filter(e=>e.provider==="invariant"&&!e.destructive),...g.filter(e=>e.pinned&&e.provider!=="invariant"&&!e.destructive),...g.filter(e=>!e.ties&&!e.destructive&&!e.pinned&&e.provider!=="invariant"),...g.filter(e=>e.ties&&!e.destructive&&!e.pinned&&e.provider!=="invariant"),...g.filter(e=>e.destructive)],me=T.length>he&&!l,fe=L.trim().toLowerCase(),w=me&&fe.length>0?T.filter(e=>`${e.label} ${e.why}`.toLowerCase().includes(fe)):null,V=w??(tt||l?T:T.slice(0,he)),ye=w?0:T.length-V.length,W=[];for(let e of V){let i=!l&&e.provider==="invariant",n=!l&&!i&&e.pinned!==void 0&&!e.destructive,d=!l&&!i&&!n&&e.ties===!0&&!e.destructive,k=i?e.why:n?"pinned":d?"its ties":null,D=i?"violation":n||d?"ties":null,H=W[W.length-1];H&&H.heading===k?H.items.push(e):W.push({heading:k,tone:D,items:[e]})}let G=g.find(e=>e.id===C),P=s.length===1?S(r,s[0]):null,ve=e=>{if(!P)return e;let i=e.startsWith(`"${P}"`)?e.slice(P.length+2):e.startsWith(P)?e.slice(P.length):null;if(i===null)return e;let n=i.trimStart();return n.length===0?e:n[0].toUpperCase()+n.slice(1)},rt=new Set(l?[]:V.filter(e=>e.provider==="invariant").map(e=>e.why)),M=te.filter(e=>!rt.has(e.text)).map(e=>({...e,text:ve(e.text)}));return it?null:(0,t.jsxs)("section",{...l?pe.pane:{},ref:e=>{y.current=e,l&&pe.pane.ref(e)},"aria-label":"Inspector","data-graview-offstage":"","data-testid":l?"context-menu":"inspector-strip",tabIndex:-1,onFocus:e=>Ke(e.target),onBlur:e=>{e.relatedTarget!==null&&(v.current=null)},onMouseDown:e=>e.stopPropagation(),style:{...l?He:{position:"absolute",zIndex:Se("rail")},boxSizing:"border-box",display:"flex",flexDirection:"column",gap:7,padding:"9px 12px",borderRadius:"var(--graview-radius, 12px)",border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)",...l?{width:300,maxHeight:"min(52cqh, 420px)",overflow:"auto"}:ce?{left:10,right:10,width:"auto",bottom:10,maxHeight:"min(42cqh, 300px)",overflow:"auto"}:{left:14,top:h.overview?"min(296px, 38cqh)":44,width:236,maxHeight:h.overview?"calc(100cqh - min(296px, 38cqh) - 20px)":"calc(68cqh - 94px)",overflow:"auto"}},children:[(0,t.jsx)("h2",{style:{...Ie,margin:0},children:"Inspector"}),(0,t.jsxs)("div",{style:{display:ge||!l?"flex":"none",alignItems:"baseline",flexWrap:"wrap",gap:"2px 8px",minWidth:0,paddingRight:l?0:24},children:[ge?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("strong",{style:{fontSize:"0.9375rem",whiteSpace:"nowrap"},children:o?.title??(s.length===1?S(r,s[0]):`${s.length} selected`)}),$.length>0||p?(0,t.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",whiteSpace:"nowrap"},children:p?"relation":$.map(e=>N(r.schema.tryDefinition(e),e)).join(" \xB7 ")}):null,s.length===1&&!p&&o?.face!=="pages"?(0,t.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",whiteSpace:"nowrap"},children:h.expanded.includes(s[0])?"\xB7 double-click closes":"\xB7 double-click opens"}):null]}):null,(0,t.jsx)("span",{style:{flex:"1 1 auto"}})]}),l?null:(0,t.jsx)("button",{type:"button",onClick:()=>{c(null),Ge()},"aria-label":"Clear selection",title:"Clear selection",style:{position:"absolute",top:6,right:6,flex:"0 0 auto",width:24,height:24,display:"grid",placeItems:"center",padding:0,fontSize:"0.875rem",lineHeight:1,borderRadius:7},children:"\xD7"}),p&&U?(0,t.jsxs)("div",{style:{display:"grid",gap:6},children:[ue?(0,t.jsx)("p",{"data-testid":"edge-said",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:ue}):null,de?(0,t.jsx)("p",{"data-testid":"edge-provisional",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:Pe(de)}):null,(0,t.jsx)("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[["from",U.from],["to",U.to]].map(([e,i],n)=>(0,t.jsxs)(a.Fragment,{children:[n===1?(0,t.jsx)("span",{"aria-hidden":"true",style:{color:"var(--graview-ink-faint)"},children:"\u2192"}):null,i?(0,t.jsx)("button",{type:"button","data-testid":`edge-${e}`,onClick:()=>Ve([i.id]),title:`Select ${S(r,i.id)}`,style:{fontSize:"0.8125rem",padding:"3px 9px",borderRadius:6},children:S(r,i.id)}):(0,t.jsx)("span",{style:{fontSize:"0.8125rem",color:"var(--graview-ink-faint)"},children:"gone"})]},e))})]}):null,!p&&s.length===1&&xe(r,s[0])?(0,t.jsx)("p",{"data-testid":"left-alone",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:"Left alone: nothing automated changes it."}):null,M.length>0?(0,t.jsx)("div",{"data-testid":"observations",title:M.map(e=>e.text).join(`
|
|
2
|
-
`),style:{display:"grid",gap:3},children:M.slice(0,2).map(e=>(0,t.jsxs)("p",{style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:[e.text,e===M[1]&&M.length>2?(0,t.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" +",M.length-2]}):null]},e.id))}):null,l?ne.start.map(e=>(0,t.jsx)(Fe,{section:e,close:()=>c(null)},e.id)):null,le?(0,t.jsx)("p",{"data-testid":"refused",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-warn)"},children:le}):null,me?(0,t.jsx)("input",{"data-testid":"action-filter",value:L,onChange:e=>R(e.target.value),placeholder:`Filter ${T.length} actions\u2026`,"aria-label":"Filter actions",onKeyDown:e=>{if(e.key==="Escape"){e.stopPropagation(),L.length>0?R(""):e.currentTarget.blur();return}if(e.key==="Enter"&&w?.length===1){let i=w[0];if(i.destructive)return;i.open.length>0?z(i.id):j(i)&&R("")}},style:{font:"inherit",fontSize:"0.875rem",padding:"5px 9px",borderRadius:8,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",color:"var(--graview-ink)"}}):null,w!==null&&w.length===0?(0,t.jsxs)("p",{"data-testid":"no-matches",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:["Nothing offered here matches \u201C",L.trim(),"\u201D."]}):null,I&&g.length===0||g.length===0&&!ie&&s.length===0?null:g.length===0&&!ie?(0,t.jsx)("p",{"data-testid":"no-affordances",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:f.length>0?`Nothing you may do with ${p?"this relation":x.length===1?Q(N(r.schema.tryDefinition(x[0]),x[0])):"this mix of kinds"} \u2014 ${f.length} action${f.length===1?"":"s"} withheld.`:p?`Nothing can be done with this line yet \u2014 nothing this app declares makes or breaks \u201C${Ce(r.schema,r.graph.getNode(p.from)?.kind??"",p.kind,"out")}\u201D.`:`Nothing can be done with ${x.length===1?Q(N(r.schema.tryDefinition(x[0]),x[0])):"this mix of kinds"} yet \u2014 nothing this app declares acts on ${x.length===1?"it":"them"}.`}):(0,t.jsxs)("ol",{...nt,"data-testid":"affordances",style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",flexWrap:"nowrap",gap:2},children:[W.map((e,i)=>(0,t.jsxs)(a.Fragment,{children:[e.heading?(0,t.jsxs)("li",{"data-graview-heading":e.tone,style:{fontSize:"0.75rem",lineHeight:1.4,color:e.tone==="violation"?"var(--graview-warn)":"var(--graview-ink-faint)",...e.tone!=="violation"?{letterSpacing:"0.12em",textTransform:"uppercase",fontSize:"0.75rem"}:{},padding:"2px 2px 1px",marginTop:i>0?6:0},children:[e.tone==="violation"?"\u26A0 ":"",e.tone==="violation"?ve(e.heading):e.heading]}):i>0?(0,t.jsx)("li",{"aria-hidden":"true",style:{borderTop:"1px solid var(--graview-edge)",margin:"6px 0 3px"}}):null,e.items.map(n=>(0,t.jsxs)("li",{style:{display:"flex",gap:2,alignItems:"stretch"},onKeyDown:d=>{if(d.metaKey||d.ctrlKey||d.altKey)return;let k=d.currentTarget.querySelector("[data-affordance]"),D=d.currentTarget.querySelector("[data-pin-for]"),H=d.target===D,we=d.key==="ArrowRight"&&!H?D:H&&["ArrowLeft","ArrowUp","ArrowDown"].includes(d.key)?k:null;we&&(d.preventDefault(),d.stopPropagation(),we.focus())},children:[(0,t.jsxs)("button",{type:"button",[X]:"","data-affordance":n.id,"data-rank":n.rank,"data-graview-destructive":n.destructive||void 0,"aria-pressed":C===n.id,title:n.why,style:{padding:"5px 10px",fontSize:"0.875rem",borderRadius:8,width:"100%",textAlign:"left",borderWidth:1,borderStyle:"solid",borderColor:C===n.id?"var(--graview-accent)":l?"transparent":"var(--graview-edge)",background:l?"none":"var(--graview-panel)",boxShadow:"none",...n.destructive?{color:"var(--graview-warn)"}:{},...C===n.id?{color:"var(--graview-accent)"}:{}},onClick:()=>{if(n.open.length>0){z(C===n.id?null:n.id);return}j(n)},children:[n.label,n.open.length>0?(0,t.jsx)("span",{style:{color:"var(--graview-ink-faint)"},children:" \u2026"}):null,w?.length===1&&w[0]?.id===n.id&&!n.destructive?(0,t.jsx)("span",{"aria-hidden":"true",title:"Enter runs it",style:{float:"right",color:"var(--graview-ink-faint)",fontSize:"0.75rem"},children:"\u21B5"}):null]}),(0,t.jsx)("button",{type:"button","data-testid":"pin-toggle",tabIndex:-1,"data-pin-for":n.mutation,"aria-pressed":n.pinned!==void 0,"aria-label":n.pinned!==void 0?`Unpin ${n.label}`:`Pin ${n.label}`,title:n.pinned==="declared"?"Pinned by the app \u2014 unpin it for yourself":n.pinned==="user"?"Unpin":"Pin to the top",onClick:()=>Ye(qe(q,n.mutation,Je.has(n.mutation))),style:{flex:"0 0 auto",width:24,minHeight:24,display:"grid",placeItems:"center",padding:0,fontSize:"0.75rem",border:"1px solid transparent",background:"none",boxShadow:"none",borderRadius:7,color:n.pinned==="user"?"var(--graview-accent)":n.pinned==="declared"?"var(--graview-ink-muted)":"var(--graview-ink-faint)"},children:n.pinned!==void 0?"\u2605":"\u2606"})]},n.id))]},`${e.heading??"plain"}-${i}`)),ye>0?(0,t.jsx)("li",{children:(0,t.jsxs)("button",{type:"button",[X]:"",onClick:()=>re(!0),title:`Show all ${g.length} actions`,style:{padding:"4px 10px",fontSize:"0.875rem",borderRadius:8},children:["Show ",ye," more"]})}):null]}),I?(0,t.jsx)("button",{type:"button","data-testid":"sign-in",onClick:()=>{c(null),I.run()},style:{padding:"5px 10px",fontSize:"0.875rem",borderRadius:8,width:"100%",textAlign:"left"},children:I.label}):null,f.length>0?(0,t.jsxs)("ul",{"data-testid":"withheld",style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",flexWrap:"nowrap",gap:2},children:[f.slice(0,l||oe?f.length:3).map(e=>(0,t.jsxs)("li",{style:{display:"grid",gap:2},children:[(0,t.jsx)("button",{type:"button",disabled:!0,"data-affordance":e.id,"data-rank":e.rank,"data-withheld":e.refusal.wouldNeed.join(",")||"nobody",style:{padding:"4px 10px",fontSize:"0.875rem",borderRadius:8,borderStyle:"dashed",width:"100%",textAlign:"left",background:"none"},children:(0,t.jsx)("s",{children:e.label})}),(0,t.jsx)("span",{"data-testid":"withheld-why",style:{fontSize:"0.8125rem",lineHeight:1.4,color:"var(--graview-ink-muted)",padding:"0 10px"},children:e.refusal.message})]},e.id)),!l&&!oe&&f.length>3?(0,t.jsx)("li",{children:(0,t.jsxs)("button",{type:"button","data-testid":"withheld-more",onClick:()=>ae(!0),title:`Show all ${f.length} actions this seat may not take`,style:{padding:"4px 10px",fontSize:"0.875rem",borderRadius:8},children:["Show ",f.length-3," more withheld"]})}):null]}):null,l?ne.end.map(e=>(0,t.jsx)(Fe,{section:e,close:()=>c(null)},e.id)):null,G?(0,t.jsx)(We,{affordance:G,onApply:e=>{if(j(G,e))z(null);else return _.current},onCancel:()=>z(null)}):null]})}var st=[];function Fe({section:u,close:r}){return(0,t.jsxs)("div",{"data-menu-section":u.id,...u.heading?{role:"group","aria-label":u.heading}:{},style:{display:"grid",gap:2,borderTop:"1px solid var(--graview-edge)",paddingTop:5},children:[u.heading?(0,t.jsx)("p",{"aria-hidden":"true",style:{margin:0,padding:"2px 2px 1px",fontSize:"0.75rem",lineHeight:1.4,letterSpacing:"0.12em",textTransform:"uppercase",color:"var(--graview-ink-faint)"},children:u.heading}):null,u.items&&u.items.length>0?(0,t.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:2},children:u.items.map(o=>(0,t.jsx)("li",{children:(0,t.jsxs)("button",{type:"button","data-menu-item":o.id,onClick:()=>{r(),o.run()},style:{padding:"5px 10px",fontSize:"0.875rem",borderRadius:8,width:"100%",textAlign:"left",borderWidth:1,borderStyle:"solid",borderColor:"transparent",background:"none",boxShadow:"none"},children:[o.label,o.hint?(0,t.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",o.hint]}):null]})},o.id))}):null,u.render?.(r)]})}export{xt as InspectorPane,bt as prepareActs};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{Da as o,G as k,R as n}from"./chunk.Y4ZUJUUT.js";import{a as t}from"./chunk.SDO3U72B.js";import{b as p}from"./chunk.AJZBJBMO.js";var f=o(t(()=>(__graviewPreload(import.meta.url,["./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.ZWVN75EY.js")))),y=f.part((e,r)=>e.drawFiles(r),{quiet:!0});var d=o(t(()=>(__graviewPreload(import.meta.url,["./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.C3NHNYA6.js")))),I=d.part((e,r)=>e.drawLinkedRecord(r),{quiet:!0}),w=d.part((e,r)=>e.drawLinkedPicker(r),{what:"Picking a linked record"});var s=p(n(),1),m=o(t(()=>(__graviewPreload(import.meta.url,["./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.RUPRZDN3.js")))),E=m.part((e,r)=>(0,s.jsx)(e.RepeatPicker,{...r}),{quiet:!0}),W=m.part((e,r)=>(0,s.jsx)(e.RepeatEditor,{...r}),{quiet:!0});var a=p(k(),1),i=p(n(),1),c=o(t(()=>(__graviewPreload(import.meta.url,["./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.NEEOVRB7.js")))),l=c.part((e,r)=>(0,i.jsx)(e.WhenInput,{...r}),{quiet:!0});function M(e){return(0,i.jsx)(a.Suspense,{fallback:(0,i.jsx)("span",{"data-graview-when-arriving":"",style:{display:"inline-block",minHeight:24}}),children:(0,i.jsx)(l,{...e})})}var N=()=>c.load().then(()=>{},()=>{});export{y as a,I as b,w as c,E as d,W as e,M as f,N as g};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{G as l,N as p,U as k,W as y,c}from"./chunk.76GF5US2.js";import"./chunk.IPAZOKMQ.js";import"./chunk.V7XHNRQM.js";import"./chunk.UGFDSE37.js";import{b as m}from"./chunk.IYIN6VSN.js";import"./chunk.GCKZ2YRJ.js";import"./chunk.VC3UGFHY.js";import"./chunk.YHH4TWZ2.js";import"./chunk.O2WWYZI7.js";import"./chunk.AGIO2GRV.js";import"./chunk.VSNHCGKC.js";import"./chunk.EUPSAYEI.js";import"./chunk.TCXKPILZ.js";import"./chunk.R6V37SR7.js";import"./chunk.SWWAEOZ7.js";import"./chunk.IROYMLER.js";import"./chunk.FWSCBHZ5.js";import"./chunk.7NNI7YH4.js";import"./chunk.7N2GXZYI.js";import"./chunk.MF73YBJL.js";import"./chunk.63MS2LOP.js";import"./chunk.PKUDIWIF.js";import"./chunk.VW2VCPJX.js";import"./chunk.MB7LKKUD.js";import"./chunk.WVUJXDXZ.js";import"./chunk.ZIEHF67C.js";import"./chunk.UHX4WTM7.js";import"./chunk.IKX4VDTW.js";import"./chunk.RNEJYIQ7.js";import"./chunk.TBQOSI4J.js";import"./chunk.KWQ7QOHD.js";import"./chunk.GZHZLJBF.js";import"./chunk.5AGW4NRZ.js";import"./chunk.OJGHDWI6.js";import"./chunk.DQS7D2W2.js";import"./chunk.HDRD33II.js";import"./chunk.DX357TZ3.js";import"./chunk.H7KCWCB4.js";import"./chunk.O4WEJ47H.js";import{$ as g,G as S,H as s,I as d,R as f}from"./chunk.Y4ZUJUUT.js";import"./chunk.SDO3U72B.js";import"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import{b as n}from"./chunk.AJZBJBMO.js";var u=n(S(),1);var t=n(f(),1);function D({context:a}){let r=l(),h=g(),[w]=(0,u.useState)(()=>s(null)),o=d(h?.seatTalk??w),P=()=>{(window.history.state?.idx??0)>0?r(-1):r("/")};return(0,t.jsxs)(k,{context:a,"data-testid":"draft-page",children:[(0,t.jsx)(y,{context:a,...o.draft?{"data-testid":"draft-title"}:{},children:o.draft?o.draft.title:"Nothing drawn"}),o.draft?(0,t.jsx)(m,{page:!0,go:e=>r(e.address),onPick:e=>{let i=a.store.graph.getNode(e);i&&r(c(a.store.schema,i.kind,e))},onDiscard:P}):(0,t.jsxs)("p",{style:{margin:0,color:"var(--graview-ink-muted)"},children:["Ask for a way of seeing \u2014 \u201Ca board of tasks by status\u201D \u2014 and it is drawn here."," ",(0,t.jsx)(p,{to:"/",style:{color:"var(--graview-accent)"},children:"Home \u2192"})]})]})}export{D as DraftPage};
|