graview 0.1.53 → 0.1.54
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.25P5SDNR.js +1 -0
- package/dist/preview/chunk.27O4LIDU.js +1 -0
- package/dist/preview/{chunk.J6OT74RM.js → chunk.2DFWOLL2.js} +1 -1
- package/dist/preview/{chunk.H6EMDQP5.js → chunk.2LMB5E6N.js} +1 -1
- package/dist/preview/{chunk.E52UTLQ2.js → chunk.2WSRJGW2.js} +1 -1
- package/dist/preview/{chunk.3377DLPA.js → chunk.33YC5RCB.js} +1 -1
- package/dist/preview/chunk.3G5DEGFA.js +1 -0
- package/dist/preview/{chunk.MDIAWTNK.js → chunk.3IEJQAK7.js} +1 -1
- package/dist/preview/{chunk.W54NXXC5.js → chunk.3JMZHCB4.js} +1 -1
- package/dist/preview/chunk.3MZIWKNG.js +5 -0
- package/dist/preview/{chunk.KAKJYAHM.js → chunk.3SOJJAMY.js} +1 -1
- package/dist/preview/{chunk.VTCPA4V4.js → chunk.3V2WXZU3.js} +1 -1
- package/dist/preview/{chunk.RUTZEEBR.js → chunk.3ZONBC6L.js} +1 -1
- package/dist/preview/{chunk.CSA6SWTI.js → chunk.45HTFSWD.js} +1 -1
- package/dist/preview/{chunk.MKWVNW4Q.js → chunk.463PGKOL.js} +3 -3
- package/dist/preview/chunk.4BX3KLAA.js +1 -0
- package/dist/preview/{chunk.XBNASVTY.js → chunk.4F5M5XZG.js} +1 -1
- package/dist/preview/{chunk.UVMLX4US.js → chunk.4GHXAWIE.js} +1 -1
- package/dist/preview/{chunk.ULTYDYTS.js → chunk.4KTHJY5N.js} +2 -2
- package/dist/preview/{chunk.65F3DF5Q.js → chunk.4TGQ6Z6E.js} +1 -1
- package/dist/preview/{chunk.HDXDYS4C.js → chunk.4V64RBCK.js} +1 -1
- package/dist/preview/{chunk.P7FN3SFB.js → chunk.4WH4N4V7.js} +1 -1
- package/dist/preview/{chunk.BB5XKTVC.js → chunk.562IVJHX.js} +1 -1
- package/dist/preview/{chunk.OP3ZUI4W.js → chunk.57VTD3CU.js} +1 -1
- package/dist/preview/{chunk.LCG3VLCB.js → chunk.5C43AM3X.js} +1 -1
- package/dist/preview/chunk.5M62CMLA.js +1 -0
- package/dist/preview/{chunk.G226CUJQ.js → chunk.5RH6FO3K.js} +1 -1
- package/dist/preview/{chunk.KCM2VOC7.js → chunk.5VF2RT4H.js} +1 -1
- package/dist/preview/{chunk.5H3VCAPN.js → chunk.5XAIP3BS.js} +1 -1
- package/dist/preview/{chunk.MT45H2T5.js → chunk.5ZWE72VJ.js} +1 -1
- package/dist/preview/{chunk.S6TN3MLY.js → chunk.644FUGSX.js} +1 -1
- package/dist/preview/{chunk.I6W3IQ4W.js → chunk.6BBB7SJL.js} +1 -1
- package/dist/preview/chunk.6SPORDJC.js +1 -0
- package/dist/preview/{chunk.5XFRWXYQ.js → chunk.6TILXTP6.js} +1 -1
- package/dist/preview/{chunk.BPPDBPTL.js → chunk.7JCUSYS5.js} +1 -1
- package/dist/preview/{chunk.GZBODS7Z.js → chunk.7SCENHVG.js} +1 -1
- package/dist/preview/{chunk.NCTTPW7A.js → chunk.7TMWMW4W.js} +1 -1
- package/dist/preview/{chunk.FGJM4LJO.js → chunk.7UD2JR6J.js} +1 -1
- package/dist/preview/{chunk.IYVBJDR7.js → chunk.AG7CUSSV.js} +1 -1
- package/dist/preview/{chunk.PEA4D66Y.js → chunk.AKLVSZ5A.js} +1 -1
- package/dist/preview/{chunk.5K5D4IMM.js → chunk.AN5QCSVK.js} +1 -1
- package/dist/preview/{chunk.UQ4CASST.js → chunk.ARRLAAG6.js} +1 -1
- package/dist/preview/{chunk.Y4VOCJ7R.js → chunk.AZGXBTOQ.js} +1 -1
- package/dist/preview/{chunk.T56SOSIR.js → chunk.B2X6DA2Q.js} +1 -1
- package/dist/preview/{chunk.4SVAHPJA.js → chunk.B6PKKEY3.js} +1 -1
- package/dist/preview/{chunk.MSPRCR3Q.js → chunk.BOMYLOCX.js} +1 -1
- package/dist/preview/{chunk.QATG5HNV.js → chunk.BPWSQVEN.js} +1 -1
- package/dist/preview/{chunk.K7WME4P4.js → chunk.BUDEUNBN.js} +1 -1
- package/dist/preview/{chunk.CIUQWCU4.js → chunk.C3AHDHX7.js} +1 -1
- package/dist/preview/{chunk.TXEWSZGO.js → chunk.C6HBYRGJ.js} +1 -1
- package/dist/preview/{chunk.56UFDIX5.js → chunk.C6HI3LRB.js} +1 -1
- package/dist/preview/{chunk.ASCTAUFD.js → chunk.CB5DGKR5.js} +1 -1
- package/dist/preview/{chunk.VOHDRH3P.js → chunk.CB7IUKY7.js} +2 -2
- package/dist/preview/{chunk.JCJ7NTW4.js → chunk.COWJTVZV.js} +1 -1
- package/dist/preview/{chunk.CYP5KXIQ.js → chunk.D2PJG5N7.js} +1 -1
- package/dist/preview/chunk.D6ACCKYJ.js +1 -0
- package/dist/preview/{chunk.DQPEVPKQ.js → chunk.DF7IPT7V.js} +2 -2
- package/dist/preview/{chunk.VRJ4TULC.js → chunk.DTJ4FIHM.js} +1 -1
- package/dist/preview/chunk.DVG47BK3.js +1 -0
- package/dist/preview/{chunk.GANAZIRD.js → chunk.E5JX5LWY.js} +1 -1
- package/dist/preview/{chunk.EG2N5F6L.js → chunk.EC7I33WI.js} +1 -1
- package/dist/preview/{chunk.UYCPQ6IW.js → chunk.FCZ7UFJI.js} +1 -1
- package/dist/preview/{chunk.A2RQFAZ6.js → chunk.FMP6NDRZ.js} +1 -1
- package/dist/preview/{chunk.FJN4OGAS.js → chunk.FRZQSSGE.js} +2 -2
- package/dist/preview/{chunk.FBRARPGR.js → chunk.FWKNR7XF.js} +2 -2
- package/dist/preview/{chunk.G6DISMVT.js → chunk.FWZF7X6A.js} +2 -2
- package/dist/preview/{chunk.HBVURYWY.js → chunk.GHPCSNM6.js} +2 -2
- package/dist/preview/{chunk.CWPRQSED.js → chunk.GKLDSHHH.js} +1 -1
- package/dist/preview/{chunk.7NFCI4LH.js → chunk.GVUJCOKD.js} +2 -2
- package/dist/preview/chunk.HLDMTKUP.js +1 -0
- package/dist/preview/{chunk.OZYZBRWO.js → chunk.IDYPQ45A.js} +1 -1
- package/dist/preview/{chunk.LAOZEYYQ.js → chunk.IMHUKSPM.js} +2 -2
- package/dist/preview/{chunk.U4T4Y2MT.js → chunk.IYYP6QUH.js} +1 -1
- package/dist/preview/chunk.J2Z6WLCH.js +88 -0
- package/dist/preview/chunk.J3OX474P.js +1 -0
- package/dist/preview/chunk.JCFYZEMY.js +1 -0
- package/dist/preview/{chunk.7BXOQEUP.js → chunk.JLB4QP6Q.js} +1 -1
- package/dist/preview/{chunk.DUZS52WX.js → chunk.JTOAZ2IR.js} +1 -1
- package/dist/preview/chunk.JXGDVJ4N.js +1 -0
- package/dist/preview/{chunk.YI7WHBAD.js → chunk.K2J26XMB.js} +1 -1
- package/dist/preview/{chunk.OPKXCL5R.js → chunk.KI6M3EWZ.js} +1 -1
- package/dist/preview/{chunk.3FRVG6JW.js → chunk.KJGNLWU3.js} +2 -2
- package/dist/preview/chunk.KLJDBYAZ.js +1 -0
- package/dist/preview/{chunk.3FUFVVR4.js → chunk.KRVEAIKW.js} +1 -1
- package/dist/preview/{chunk.AQJD23AN.js → chunk.L7MFTL5S.js} +1 -1
- package/dist/preview/{chunk.VTRI2MT2.js → chunk.LNOWO3IY.js} +2 -2
- package/dist/preview/{chunk.NAEEPUWJ.js → chunk.LOUICR7K.js} +1 -1
- package/dist/preview/{chunk.WDEMPWS4.js → chunk.LU3B3SZH.js} +1 -1
- package/dist/preview/{chunk.6S3B4XC4.js → chunk.LVOL2LEC.js} +1 -1
- package/dist/preview/chunk.LYFEGG6E.js +1 -0
- package/dist/preview/{chunk.USAGE5C6.js → chunk.MAWP27FD.js} +1 -1
- package/dist/preview/chunk.MDWCX3YU.js +1 -0
- package/dist/preview/{chunk.HAIHXBVX.js → chunk.MNW2ZBQ6.js} +1 -1
- package/dist/preview/{chunk.GYO57LKD.js → chunk.MPMROUZA.js} +1 -1
- package/dist/preview/{chunk.CANTHIRO.js → chunk.MVRNEC3Y.js} +1 -1
- package/dist/preview/{chunk.JQTO52Q7.js → chunk.NDI5OWIB.js} +1 -1
- package/dist/preview/{chunk.ICYJ7QJG.js → chunk.NEJSKMJV.js} +1 -1
- package/dist/preview/{chunk.XFIZLWYA.js → chunk.NGWHV4G6.js} +1 -1
- package/dist/preview/{chunk.EZXGVTT2.js → chunk.OCV46AFN.js} +1 -1
- package/dist/preview/{chunk.ZYYM52N5.js → chunk.OLKFEHWB.js} +1 -1
- package/dist/preview/{chunk.TLQTDKOL.js → chunk.OZ4EJ5M6.js} +2 -2
- package/dist/preview/chunk.PCNEM3WE.js +1 -0
- package/dist/preview/{chunk.HIFLBWQJ.js → chunk.PR2TSHE7.js} +2 -2
- package/dist/preview/{chunk.2LQ37DC2.js → chunk.PZ4G5QA5.js} +1 -1
- package/dist/preview/{chunk.TTFYXKLI.js → chunk.PZWJUQAO.js} +1 -1
- package/dist/preview/{chunk.4DCPB67O.js → chunk.Q6RUTFU3.js} +1 -1
- package/dist/preview/{chunk.JRU5BT7K.js → chunk.QB7RYJ67.js} +2 -2
- package/dist/preview/{chunk.JKCLYLT4.js → chunk.R7RDUW37.js} +1 -1
- package/dist/preview/{chunk.RIS3OKAI.js → chunk.RBYRT2I2.js} +1 -1
- package/dist/preview/{chunk.Z4YSCHZT.js → chunk.RCFAHV5N.js} +1 -1
- package/dist/preview/{chunk.S2ATSY6P.js → chunk.RLO3RDYH.js} +1 -1
- package/dist/preview/chunk.RYMSHMLM.js +1 -0
- package/dist/preview/chunk.SDO3DD77.js +6 -0
- package/dist/preview/chunk.SF4BYBH6.js +25 -0
- package/dist/preview/chunk.SG7YVKH4.js +1 -0
- package/dist/preview/chunk.T42H5RXN.js +1 -0
- package/dist/preview/{chunk.72Q4R7N6.js → chunk.TUNHUTQ5.js} +1 -1
- package/dist/preview/{chunk.GPYZR6HE.js → chunk.U7GN6UPR.js} +1 -1
- package/dist/preview/{chunk.6CVW53WA.js → chunk.ULSN3ASK.js} +1 -1
- package/dist/preview/{chunk.BQHRZJ5Z.js → chunk.VFMC45E7.js} +1 -1
- package/dist/preview/{chunk.36XV4ZMC.js → chunk.VGOWGOGD.js} +2 -2
- package/dist/preview/{chunk.YA7ZMGOL.js → chunk.VTO6UWUP.js} +1 -1
- package/dist/preview/chunk.VW6X53E7.js +1 -0
- package/dist/preview/{chunk.HIDLE6BN.js → chunk.VWQ57LTT.js} +3 -3
- package/dist/preview/{chunk.6ESAZJBN.js → chunk.VYKEIKY5.js} +1 -1
- package/dist/preview/{chunk.XDEKL6TJ.js → chunk.W6NCLU5Y.js} +1 -1
- package/dist/preview/{chunk.GBIVIHGD.js → chunk.WHGEDJB2.js} +2 -2
- package/dist/preview/{chunk.FCAKLO5U.js → chunk.WICMCZ27.js} +1 -1
- package/dist/preview/{chunk.E647LWH5.js → chunk.WVWXNW74.js} +2 -2
- package/dist/preview/{chunk.5E4UGVAD.js → chunk.XBDFXFWM.js} +1 -1
- package/dist/preview/{chunk.KWMBRB6O.js → chunk.XTT6ERI3.js} +1 -1
- package/dist/preview/{chunk.R3DWF35R.js → chunk.XZJ6XX5I.js} +1 -1
- package/dist/preview/{chunk.OCWZJNZF.js → chunk.Y2DFDMT6.js} +1 -1
- package/dist/preview/{chunk.UXNZPPWR.js → chunk.Y36MLVMT.js} +1 -1
- package/dist/preview/{chunk.UQENE3VE.js → chunk.Y36WSKL5.js} +1 -1
- package/dist/preview/chunk.YXRKZMS5.js +1 -0
- package/dist/preview/{chunk.34Q7OKK3.js → chunk.Z6O7RUSR.js} +1 -1
- package/dist/preview/chunk.ZAGP3OKY.js +1 -0
- package/dist/preview/{chunk.N6A3DIOY.js → chunk.ZBHFCSKO.js} +1 -1
- package/dist/preview/{chunk.BG2SC77J.js → chunk.ZDDWXRPK.js} +1 -1
- package/dist/preview/{chunk.TRPPN2GD.js → chunk.ZUBC3UFG.js} +1 -1
- package/dist/preview/{chunk.LDLWYAHK.js → chunk.ZYW7Q5EN.js} +1 -1
- package/dist/preview/index.html +50 -51
- package/dist/preview/page.js +2 -2
- package/package.json +6 -6
- package/dist/preview/chunk.2IKVO743.js +0 -1
- package/dist/preview/chunk.3Y7BDRP3.js +0 -1
- package/dist/preview/chunk.4DFO43VM.js +0 -1
- package/dist/preview/chunk.4QVZXCV5.js +0 -1
- package/dist/preview/chunk.52Y37IAD.js +0 -1
- package/dist/preview/chunk.6W2DUW5S.js +0 -5
- package/dist/preview/chunk.7R6GXJS4.js +0 -6
- package/dist/preview/chunk.B3T4N2XM.js +0 -25
- package/dist/preview/chunk.D3A24PQ6.js +0 -1
- package/dist/preview/chunk.FXNUR5JI.js +0 -88
- package/dist/preview/chunk.GGHZEAAT.js +0 -1
- package/dist/preview/chunk.GZWC72HS.js +0 -1
- package/dist/preview/chunk.H2B3SEI7.js +0 -1
- package/dist/preview/chunk.HE545Z6I.js +0 -1
- package/dist/preview/chunk.I62MCBQM.js +0 -1
- package/dist/preview/chunk.I6SUHXJF.js +0 -1
- package/dist/preview/chunk.LEKML4S4.js +0 -1
- package/dist/preview/chunk.MXTDQXVW.js +0 -1
- package/dist/preview/chunk.OXLYDXQV.js +0 -1
- package/dist/preview/chunk.P2W727C7.js +0 -1
- package/dist/preview/chunk.PFXGWY3P.js +0 -1
- package/dist/preview/chunk.Q5JVKSEN.js +0 -1
- package/dist/preview/chunk.Q5WEOX3Q.js +0 -1
- package/dist/preview/chunk.SHNYYBNW.js +0 -1
- package/dist/preview/chunk.THL67D77.js +0 -1
- package/dist/preview/chunk.XXCT6DLX.js +0 -1
- package/dist/preview/chunk.ZJXUWOG3.js +0 -1
- package/dist/preview/chunk.ZQWKS6K5.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk.GZBODS7Z.js";import"./chunk.CANTHIRO.js";import"./chunk.CSA6SWTI.js";import"./chunk.4DCPB67O.js";import"./chunk.Y4VOCJ7R.js";import"./chunk.IYVBJDR7.js";import"./chunk.VTCPA4V4.js";import"./chunk.FGJM4LJO.js";import"./chunk.K7WME4P4.js";import"./chunk.MDIAWTNK.js";import"./chunk.PEA4D66Y.js";import"./chunk.TRPPN2GD.js";import"./chunk.MT45H2T5.js";import"./chunk.S2ATSY6P.js";import"./chunk.72Q4R7N6.js";import"./chunk.6W2DUW5S.js";import"./chunk.SLBWPVIY.js";import"./chunk.AJZBJBMO.js";export{b as actOnSeveral,a as actsForSeveral};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk.3FRVG6JW.js";import"./chunk.7NFCI4LH.js";import"./chunk.RUTZEEBR.js";import"./chunk.FBRARPGR.js";import"./chunk.GZWC72HS.js";import"./chunk.ASCTAUFD.js";import"./chunk.CWPRQSED.js";import"./chunk.EZXGVTT2.js";import"./chunk.ULTYDYTS.js";import"./chunk.2LQ37DC2.js";import"./chunk.UXNZPPWR.js";import"./chunk.GYO57LKD.js";import"./chunk.HJCQ6I3S.js";import"./chunk.LCG3VLCB.js";import"./chunk.P7FN3SFB.js";import"./chunk.CANTHIRO.js";import"./chunk.R3DWF35R.js";import"./chunk.XBNASVTY.js";import"./chunk.6S3B4XC4.js";import"./chunk.52Y37IAD.js";import"./chunk.TLQTDKOL.js";import"./chunk.MSPRCR3Q.js";import"./chunk.CSA6SWTI.js";import"./chunk.4DCPB67O.js";import"./chunk.Y4VOCJ7R.js";import"./chunk.IYVBJDR7.js";import"./chunk.TXEWSZGO.js";import"./chunk.WVUJXDXZ.js";import"./chunk.VTCPA4V4.js";import"./chunk.FGJM4LJO.js";import"./chunk.K7WME4P4.js";import"./chunk.MDIAWTNK.js";import"./chunk.PEA4D66Y.js";import"./chunk.TRPPN2GD.js";import"./chunk.GZHZLJBF.js";import"./chunk.TTFYXKLI.js";import"./chunk.OJGHDWI6.js";import"./chunk.ICYJ7QJG.js";import"./chunk.MT45H2T5.js";import"./chunk.S2ATSY6P.js";import"./chunk.72Q4R7N6.js";import"./chunk.G6DISMVT.js";import"./chunk.W54NXXC5.js";import"./chunk.B3T4N2XM.js";import"./chunk.SDO3U72B.js";import"./chunk.6W2DUW5S.js";import"./chunk.SLBWPVIY.js";import"./chunk.AJZBJBMO.js";export{b as declaredLensView,a as formatFor};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as ve,b as qe,c as Ie,d as pe,e as R,f as fe,h as Ve}from"./chunk.XXCT6DLX.js";import{h as Le,i as Ue,j as We}from"./chunk.K7WME4P4.js";import{a as se,b as ie,c as H,d as Be,e as J,g as ne,h as Ze}from"./chunk.PEA4D66Y.js";import{c as _e,h as y,i as Ne,j as le}from"./chunk.TRPPN2GD.js";import{A as Re,Aa as Fe,Ha as De,Ia as ee,Ja as ce,Rb as Ke,Sb as de,Tb as Me,Ub as Pe,Vb as Te,b as W,c as L,e as xe,f as Ee,g as q,h as O,k as _,kc as Ge,l as X,lc as Ce,m as C,n as Ae,o as U,p as K,r as $,s as Q,t as x,u as E,v as I,w as P,x as n,y as M,z as Z}from"./chunk.6W2DUW5S.js";var ue=e=>Object.entries(e).map(([s,r])=>[s,Object.keys(ee(r?.edges))]),me=(e,s)=>Me(e,ue(s));function Ye(e){return[...Object.keys(e.acts??{}),...Object.keys(e.kinds).flatMap(s=>Ke(s)),...Pe(ue(e.kinds))]}var V=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function He(e){if(!V(e)||!V(e.kinds))return e;let s;try{let f=Object.fromEntries(Object.entries(e.kinds).map(([z,i])=>[z,V(i)&&V(i.edges)?{edges:i.edges}:{}]));s=Ye({acts:V(e.acts)?e.acts:{},kinds:f})}catch{return e}let r=new Set(s),t=!1,a=f=>{if(typeof f!="string"||r.has(f))return f;let z=Ge(f,s);return z===void 0?f:(t=!0,z)},d=V(e.policy)&&Array.isArray(e.policy.grants)?{...e.policy,grants:e.policy.grants.map(f=>V(f)&&Array.isArray(f.mutations)?{...f,mutations:f.mutations.map(a)}:f)}:void 0,u=V(e.rules)?Object.fromEntries(Object.entries(e.rules).map(([f,z])=>[f,V(z)&&Array.isArray(z.repairs)?{...z,repairs:z.repairs.map(i=>V(i)?{...i,act:a(i.act)}:i)}:z])):void 0;return t?{...e,...d?{policy:d}:{},...u?{rules:u}:{}}:e}function ge(e,s){let r=Ce(e,Ye(s));return r&&r!==e?`did you mean "${r}"?`:void 0}var he="graview-document",be=1,ke=256*1024,te=64*1024,ze=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,ye=/^[a-z][A-Za-z0-9]*$/,zn=new Set(["id","kind"]),yn=/^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|[a-z][A-Za-z0-9]*)$/,hn=["string","text","number","integer","boolean","date","datetime","enum","list","url","email","image","video","file","app-link","phone","place","duration"];function bn(){let e=k=>k in Object.prototype,s=Z(k=>!e(k),"every object already has this name \u2014 choose another"),r=(k,N)=>[...k===void 0?[]:[Ee(k)],...N===void 0?[]:[xe(N)]],t=(k,N)=>O().check(...r(k,N)),a=(k,N,gn)=>K(k).check(...r(N,gn)),d=k=>O().check(q(ze,`${k} names are kebab-case, lower-case words joined by hyphens like "tool-note" (field and relation names are camelCase, like "supersededBy")`)),u=O().check(q(yn,'relation names are one camelCase word, like "supersededBy" (kind names are kebab-case, like "tool-note")'),s),f=O().check(q(ye,'field names are one word or camelCase, like "dueDate", so rules say them bare (kind names are kebab-case, like "tool-note")'),Z(k=>!zn.has(k),'a field cannot be called "id" or "kind" \u2014 the framework keeps those; try "type" or "category"'),s),z=t(1,500),i=t(1,2e3),o=t(1,300),p=$({type:I(hn),required:n(C()),description:n(z),label:n(t(1,60)),options:n(a(t(1,80),1,100)),of:n(I(["string","number","date","image","video","file"])),default:n(U()),unit:n(t(void 0,12)),format:n(I(["money","percent","duration","markdown"])),min:n(_()),max:n(_()),step:n(_()),renamedFrom:n(O().check(q(ye))),repeats:n(C()),collaborative:n(C())}).check(Re((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=O().check(q(new RegExp(`${ze.source}|${Fe.source}`),'a relation goes to a kind of this document, like "house", or of another app, like "@nick/house/house"')),m=$({to:x([a(w,1),P("*")]),cardinality:n(I(["one","many"])),description:n(z),inverse:n(t(1,80)),appendOnly:n(C()),renamedFrom:n(O()),tidying:n(P("never"))}),l=x([i,$({expr:i,label:n(t(1,60)),description:n(z)})]),c=$({noun:n(t(1,40)),plural:n(t(1,40)),description:n(z),fields:E(f,p).check(Z(k=>Object.keys(k).length>0,"a kind has at least one field")),label:n(o),describe:n(o),lifecycle:n($({field:f,retired:a(x([O(),_(),C()]),1)})),figure:n(t(void 0,2e4)),glance:n(a(f,1,20)),page:n($({fields:n(a(f,1,40)),groups:n(a($({title:t(1,60),fields:a(f,1,40)}),1,12))})),edges:n(E(u,m)),computed:n(E(O(),l).check(Z(k=>Object.keys(k).length<=20,"a kind works out at most 20 computed fields"))),fieldRoles:n(E(O(),O())),renamedFrom:n(O().check(q(ze))),people:n(C()),archives:n(P(!1)),tidying:n(I(["never","no-links"]))}),j=x([O(),_(),C(),Ae(),K(U()),$({expr:i})]),h=O().check(q(/^\$[A-Za-z][A-Za-z0-9]*$/,'a reference is "$" and a name, like "$subject" or "$new"')),S=x([$({create:d("kind"),as:n(O().check(q(ye))),set:n(E(f,j))}),$({set:E(f,j),target:n(h)}),$({connect:u,from:h,to:h}),$({sever:u,from:h,to:h}),$({remove:h})]),A=$({title:n(t(1,80)),description:n(z),fromTheOtherEnd:n(t(1,80)),on:n(x([d("kind"),a(d("kind"),1)])),creates:n(d("kind")),sets:n(E(f,j)),writes:n(a(f,1)),connects:n(u),severs:n(u),setsOther:n(E(f,j)),replaces:n(x([P(!0),a(u,1,10)])),removes:n(P(!0)),args:n(E(f,p)),effects:n(a(S,1,20)),allowedWhen:n(i),refusal:n(o),destructive:n(C())}),b=$({act:d("act"),label:n(t(1,80)),args:n(E(O(),j))}),G=$({title:n(t(1,120)),description:n(z),over:x([P("graph"),d("kind")]),when:n(i),require:i,says:n(o),repairs:n(a(b,void 0,10))}),F=$({roles:x([a(d("role"),1),P("*")]),mutations:x([a(d("act"),1),P("*")]),kinds:n(x([K(d("kind")),P("*")])),describe:n(z),self:n(C()),ownEnd:n(C())}),g=n(a(d("field"),1)),v=$({roles:x([a(d("role"),1),P("*")]),kinds:a(d("kind"),1),own:n(C()),via:n(u),fields:g,hide:g}),D=$({grants:K(F),sees:n(K(v))}),oe=$({accent:n(O().check(q(/^#[0-9a-fA-F]{6}$/,'an accent is a color like "#c2577a"'))),name:n(t(1,60)),currency:n(O().check(q(/^[A-Z]{3}$/,'a currency is its three-letter code, like "USD" or "EUR"'))),locale:n(t(2,35)),timeZone:n(t(1,64)),logo:n(x([t(1,te),$({src:t(1,te),alt:n(t(1,120))}),$({light:t(1,te),dark:n(t(1,te)),alt:n(t(1,120)),darkFallback:n(P("invert"))})])),favicon:n(x([t(1,te),$({emoji:O()})])),typography:n($({display:n(t(1,200)),body:n(t(1,200)),mono:n(t(1,200))})),shape:n($({radius:n(_().check(L(0),W(32))),density:n(_().check(L(.75),W(1.5)))})),accents:n(E(O(),_().check(L(0),W(360)))),scheme:n(I(["light","dark","auto"])),subtitle:n(P(!1))}),B=E(O(),U()),Y=x([t(1,120),$({by:t(1,120),direction:n(I(["asc","desc"]))})]),je=_().check(X(),L(1),W(9999)),dn=Q({create:n(C()),options:n(Q({sort:n(Y),columnSort:n(Y),search:n(a(t(1,120),void 0,40)),filters:n(a(t(1,120),void 0,40)),horizon:n(x([_().check(X(),L(1),W(200)),Q({years:_().check(X(),L(1),W(200)),title:t(1,80),from:n(je),to:n(je)})]))}))}),ln=$({card:n(K(U())),row:n(K(U())),page:n(K(U()))}),pn=()=>{let k=n(I(["asc","desc"]));return x([t(1,120),$({by:t(1,120),direction:k,then:n(x([t(1,120),$({by:t(1,120),direction:k})]))})])},fn=()=>x([t(1,120),$({by:t(1,120),order:n(a(t(1,80),void 0,40)),closed:n(a(t(1,80),void 0,40))})]),Oe=Q({order:n(K(O())),hide:n(K(O())),first:n(O()),primary:n(a(t(1,80),void 0,40)),scene:n(t(1,40)),pages:n(t(1,40)),lists:n(E(O(),$({filters:n(a(t(1,120),void 0,40)),sort:n(pn()),group:n(fn()),export:n(C())})))}),un=$({act:d("act"),title:n(t(1,80)),intro:n(z),fields:n(a(f,1,40)),say:n(z),submit:n(t(1,80)),role:n(d("role"))}),mn=$({$schema:n(O()),format:P(he),formatVersion:P(be),name:t(1,80),description:n(z),version:n(_().check(X(),L(1))),kinds:E(d("kind"),c).check(Z(k=>Object.keys(k).length>0,"a document declares at least one kind"),Z(k=>Object.keys(k).length<=40,"a document declares at most 40 kinds")),computed:n(E(O(),l)),acts:n(E(d("act"),A)),rules:n(E(d("rule"),G)),roles:n(K(d("role"))),policy:n(D),modules:n(B),lenses:n(K(dn)),pages:n(Oe),views:n(E(O(),x([ln,K(U())]))),brand:n(oe),settings:n(K(B)),migrations:n(K(B)),connections:n(E(d("connection"),B)),forms:n(E(d("form"),un)),publishing:n($({mode:I(["live","on-publish"]),working:a(d("role"),void 0,40),publishers:n(a(d("role"),1,40))}))});return{FieldSpec:p,EdgeSpec:m,ComputedSpec:l,KindSpec:c,ValueSpec:j,EffectSpec:S,ActSpec:A,RepairSpec:b,RuleSpec:G,GrantSpec:F,SightSpec:v,PolicySpec:D,BrandSpec:oe,PagesSpec:Oe,DocumentSpec:mn}}var kn,T=()=>kn??=bn(),_n=M(()=>T().FieldSpec),Nn=M(()=>T().EdgeSpec),qn=M(()=>T().ComputedSpec),In=M(()=>T().KindSpec),Vn=M(()=>T().ValueSpec),Bn=M(()=>T().EffectSpec),Ln=M(()=>T().ActSpec),Un=M(()=>T().RepairSpec),Wn=M(()=>T().RuleSpec),Zn=M(()=>T().GrantSpec),Yn=M(()=>T().SightSpec),Hn=M(()=>T().PolicySpec),Jn=M(()=>T().BrandSpec),Xn=M(()=>T().PagesSpec),Je=M(()=>T().DocumentSpec);var $n={};function Xe(e,s=$n,r=be){let{document:t,respelled:a}=ve(e),d=a.length>0?{respelled:a}:{};if(!t||typeof t!="object"||Array.isArray(t))return{document:t};let u=t;if(u.format!==he||typeof u.formatVersion!="number"||u.formatVersion>=r)return{document:t,...d};let f=u.formatVersion,z=structuredClone(u);for(let i=f;i<r;i++){let o=s[i];if(!o)throw new Error(`there is no upgrade from format ${i} to ${i+1}`);z={...o(z),formatVersion:i+1}}return{document:z,from:f,...d}}function Qe(e,s,r){let t=Object.keys(e).filter(f=>e[f].edges?.[s]!==void 0);if(t.length===0)return;let a=t.map(f=>e[f].edges[s].to),d=a.some(f=>f==="*")?"*":[...new Set(a.flatMap(f=>f))];if(r.length===0||r.some(f=>t.includes(f)))return{reversed:!1,kinds:d};let u=t.filter(f=>{let z=e[f].edges[s].to;return z==="*"||r.every(i=>z.includes(i))});return u.length>0?{reversed:!0,kinds:u}:{reversed:!1,kinds:d}}var tn=(e,s)=>{let r=e?.fields[s];return r!==void 0&&(r.type==="duration"||(r.type==="number"||r.type==="integer")&&r.format==="duration")};function en(e,s,r,t){if(t==="out"){let a=e[s]?.edges?.[r]?.to;return a===void 0?[]:a==="*"?Object.keys(e):a}return Object.entries(e).filter(([,a])=>{let d=a.edges?.[r]?.to;return d!==void 0&&(d==="*"||d.includes(s))}).map(([a])=>a)}function $e(e,s,r){if(r.t==="ident")return e[s]?.edges?.[r.name]?en(e,s,r.name,"out"):void 0;if(r.t==="where")return $e(e,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 en(e,s,r.args[0].value,r.fn)}var nn=(e,s,r)=>{let t=s.filter(a=>e[a]?.fields[r]!==void 0);return t.length>0&&t.every(a=>tn(e[a],r))};function on(e,s,r){let t=e.kinds,a=t[s],d=new Map(r),u=new Map,f=(i,o)=>{if(o>8)return!1;switch(i.t){case"ident":return tn(a,i.name)||z(i.name,o+1);case"member":{let p=$e(t,s,i.object);return p!==void 0&&nn(t,p,i.name)}case"call":{if(i.fn!=="sum"&&i.fn!=="min"&&i.fn!=="max")return!1;let[p,w]=i.args,m=p&&$e(t,s,p);return m!==void 0&&w?.t==="ident"&&nn(t,m,w.name)}case"binary":return(i.op==="+"||i.op==="-")&&f(i.left,o)&&f(i.right,o);case"unary":return i.op==="-"&&f(i.operand,o);default:return!1}},z=(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&&f(p,o);return u.set(i,w),w};return r.map(([i])=>i).filter(i=>z(i,0))}function sn(e,s,r=`kinds.${e}.page`){let t=s.page;if(!t)return[];let a=[],d=[...Object.keys(s.fields),...Object.keys(s.computed??{})],u=new Set,f=(i,o)=>{d.includes(i)?u.has(i)&&a.push(y("page-field-twice",o,`"${i}" is on ${e}'s page twice; name each field once`)):a.push(y("page-field",o,`${e}'s page is to show "${i}", and ${e} has no field or computed field called that`,`use one of: ${d.join(", ")}`)),u.add(i)};(t.fields??[]).forEach((i,o)=>f(i,`${r}.fields.${o}`));let z=new Set;return(t.groups??[]).forEach((i,o)=>{let p=i.title.trim().toLowerCase();z.has(p)&&a.push(y("page-group-twice",`${r}.groups.${o}.title`,`${e}'s page has two groups called "${i.title}"; give each its own title`)),z.add(p),i.fields.forEach((w,m)=>f(w,`${r}.groups.${o}.fields.${m}`))}),a}function rn(e,s=[]){return Te({declared:Object.keys(e.fields),paged:[...e.page?.fields??[],...(e.page?.groups??[]).flatMap(r=>r.fields)],must:r=>!!e.fields[r].required&&e.fields[r].default===void 0,naming:s})}var wn=new Set(["subject","now","today","me"]);function Sn(e){if((typeof e=="string"?e:JSON.stringify(e??null)).length>ke)return{findings:[y("too-large","",`a document may be at most ${ke/1024} KB`)]};if(typeof e=="string")try{e=JSON.parse(e)}catch(t){return{findings:[y("not-json","",`this is not JSON: ${t.message}`)]}}try{e=Xe(e).document}catch(t){return{findings:[y("format","formatVersion",t.message)]}}e=He(e);let s=Je.safeParse(e);if(!s.success)return{findings:s.error.issues.map(t=>{let a=t.path.map(String).join(".");if(t.code==="unrecognized_keys")return y("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 y("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 y("shape",a,`the name "${String(t.path.at(-1))}" is not allowed here${d?`: ${d}`:""}`)}return y("shape",a,t.message)})};let r=s.data;return{document:r,findings:jn(r)}}var ae=e=>[e??[]].flat();function an(e){let s=new Map;for(let[r,t]of Object.entries(e.kinds))for(let[a,d]of Object.entries(ee(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 Et(e){let s=new Map;for(let[t,a]of Object.entries(e.kinds)){let d=ne(a),u=ce(a.edges);s.set(t,{fields:new Set([...Object.keys(a.fields),...u.keys()]),edges:new Map(Object.entries(ee(a.edges)).map(([f,z])=>[f,z.cardinality??"many"])),...d?{computed:d}:{},...u.size>0?{linked:u}:{}})}let r=ne(e);return r&&s.set(_e,{computed:r}),s}function cn(e,s){let r=[],t=ae(e.on),a=(d,u)=>{let f=Qe(s.kinds,d,t)?.reversed===!0,[z,i]=f?["$to","$subject"]:["$subject","$to"];return u==="connect"?{connect:d,from:z,to:i}:{sever:d,from:z,to:i}};if(e.creates){let d=s.kinds[e.creates],u={};for(let f of Object.keys(d?.fields??{}))u[f]=`$${f}`;for(let f of e.effects??[])"set"in f&&!("create"in f)&&R(f.target)==="new"&&Object.assign(u,f.set);r.push({create:e.creates,as:"new",set:u})}return e.sets&&r.push({set:e.sets}),e.writes&&!(e.creates&&e.on===void 0)&&r.push({set:Object.fromEntries(e.writes.map(d=>[d,`$${d}`]))}),e.connects&&(e.replaces&&r.push({replace:e.replaces===!0?[e.connects]:[...e.replaces],keep:e.connects}),r.push(a(e.connects,"connect"))),e.severs&&r.push(a(e.severs,"sever")),e.setsOther&&(e.connects||e.severs)&&r.push({set:e.setsOther,target:"$to"}),e.removes&&r.push({remove:"$subject"}),e.effects&&r.push(...e.effects.filter(d=>!(e.creates&&"set"in d&&!("create"in d)&&R(d.target)==="new"))),r}function we(e,s,r){try{let t=H(e),a=se(t);for(let d of a.unknownFunctions)r.push(y("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 ie){r.push(y("expression",s,t.sentence+` (at character ${t.at+1})`));return}throw t}}function Se(e,s,r){try{return J(e)}catch(t){if(t instanceof Be||t instanceof ie){r.push(y("template",s,(t instanceof ie,t.sentence)));return}throw t}}function jn(e){let s=[],r=new Set(Object.keys(e.kinds)),t=an(e),a=e.acts??{},d=new Set(e.roles??[]),u=(i,o)=>ce(e.kinds[i]?.edges).has(o),f=i=>Object.keys(e.kinds).some(o=>u(o,i));for(let[i,o]of Object.entries(e.kinds)){let p=`kinds.${i}`;for(let[m,l]of Object.entries(o.edges??{})){if(!De(l)&&l.to!=="*")for(let c of l.to)r.has(c)||s.push(y("edge-target",`${p}.edges.${m}.to`,`"${c}" is not a kind this document declares`));o.fields[m]&&s.push(y("edge-field-clash",`${p}.edges.${m}`,`"${m}" is both a field and a relation of ${i}`,"rename one of them"))}o.lifecycle&&!o.fields[o.lifecycle.field]&&s.push(y("lifecycle-field",`${p}.lifecycle.field`,`${i} has no field "${o.lifecycle.field}"`));let w=m=>o.computed!==void 0&&Object.hasOwn(o.computed,m);for(let m of o.glance??[])!o.fields[m]&&!w(m)&&s.push(y("glance-field",`${p}.glance`,`a glance at ${i} is to say "${m}", and ${i} has no field or computed field called that`,`use one of: ${[...Object.keys(o.fields),...Object.keys(o.computed??{})].join(", ")}`));s.push(...sn(i,o));for(let m of["label","describe"]){let l=o[m];if(!l)continue;let c=Se(l,`${p}.${m}`,s);for(let j of c??[])if(j.expr){for(let h of se(j.expr).names)if(!o.fields[h]){if(w(h)){Ze(o,h)||s.push(y("template-field",`${p}.${m}`,`${i}'s ${h} is worked out from beyond the record, and a ${m} is said with no graph to read`,`show it in a view instead, or name a computed field worked out from ${i}'s own fields`));continue}s.push(y("template-field",`${p}.${m}`,`${i} has no field "${h}" for its ${m} to show`,m==="label"?"a label can only show the record's own fields and what they work out":void 0))}}}for(let[m,l]of Object.entries(o.fields)){l.default!==void 0&&l.type==="enum"&&!l.options?.includes(String(l.default))&&s.push(y("default-option",`${p}.fields.${m}.default`,`"${String(l.default)}" is not one of ${m}'s options`));let c=`${m}Repeat`;l.repeats&&(o.fields[c]||o.edges?.[c]||o.computed?.[c])&&s.push(y("repeat-clash",`${p}.fields.${m}.repeats`,`${i} already has "${c}", where how ${m} repeats is kept`))}}for(let[i,o]of Object.entries(a)){let p=`acts.${i}`;for(let c of ae(o.on))r.has(c)||s.push(y("act-kind",`${p}.on`,`"${c}" is not a kind this document declares`));let w=ae(o.on),m=cn(o,e);if(o.creates&&o.on===void 0&&o.writes&&r.has(o.creates)){for(let c of o.writes)if(!e.kinds[o.creates].fields[c])if(e.kinds[o.creates].computed?.[c]!==void 0)s.push(y("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(y("act-field",`${p}.writes`,`${o.creates} has no field "${c}"`))}}m.length===0&&s.push(y("act-empty",p,`"${i}" does nothing`,"give it effects or a shorthand such as sets or creates"));let l=new Map;m.forEach((c,j)=>{let h=m.length-(o.effects?.length??0),S=o.effects&&j>=h?`${p}.effects.${j-h}`:p;if("create"in c){if(!r.has(c.create))s.push(y("act-kind",`${S}.create`,`"${c.create}" is not a kind this document declares`));else for(let b of Object.keys(c.set??{}))e.kinds[c.create].fields[b]||(e.kinds[c.create].computed?.[b]!==void 0?s.push(y("computed-written",`${S}.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(y("act-field",`${S}.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)&&!f(b)&&s.push(y("act-edge",`${S}.${"connect"in c?"connect":"sever"}`,`"${b}" is not a relation any kind declares`)),R(c.from)==="subject"&&w.length===0&&s.push(y("act-subject",`${p}.on`,`"${i}" acts on "$subject" but does not say which kinds it is "on"`))}else if("set"in c){let b=R(c.target??"$subject"),G=b==="subject"?w:l.has(b??"")?[l.get(b)]:[];b==="subject"&&w.length===0&&s.push(y("act-subject",`${p}.on`,`"${i}" changes "$subject" but does not say which kinds it is "on"`));for(let F of Object.keys(c.set))for(let g of G)if(!(!r.has(g)||e.kinds[g].fields[F]))if(e.kinds[g].computed?.[F]!==void 0)s.push(y("computed-written",`${S}.set.${F}`,`${g}'s ${F} is worked out, not written: no act can set it`,"set the stored fields it is worked out from"));else{if(u(g,F))continue;s.push(y("act-field",`${S}.set.${F}`,`${g} has no field "${F}"`))}}else"remove"in c&&R(c.remove)==="subject"&&w.length===0&&s.push(y("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&&we(b.expr,`${S}.set`,s)})}),o.allowedWhen&&we(o.allowedWhen,`${p}.allowedWhen`,s),o.refusal&&Se(o.refusal,`${p}.refusal`,s)}for(let[i,o]of Object.entries(e.rules??{})){let p=`rules.${i}`;o.over!=="graph"&&!r.has(o.over)&&s.push(y("rule-kind",`${p}.over`,`"${o.over}" is not a kind this document declares`));let w=o.over==="graph"?void 0:e.kinds[o.over];for(let m of["when","require"]){let l=o[m];if(!l)continue;let c=we(l,`${p}.${m}`,s);if(!c)continue;let j=se(c);for(let h of j.names)if(o.over==="graph")s.push(y("rule-name",`${p}.${m}`,`"${h}" means nothing in a rule over the whole graph`,`name a kind in "over", or use all('kind')`));else if(w&&!w.fields[h]&&!w.edges?.[h]&&w.computed?.[h]===void 0){let S=Object.keys(w.edges??{}).find(A=>A.includes("-")&&A.split("-").includes(h));s.push(y("rule-name",`${p}.${m}`,`${o.over} has no field or relation called "${h}"`,S?`"${S}" reads as a subtraction in a rule; rename the relation to one camelCase word, like "${S.replace(/-([a-z0-9])/g,(A,b)=>b.toUpperCase())}"`:void 0))}for(let h of j.edges)!t.has(h)&&!f(h)&&s.push(y("rule-edge",`${p}.${m}`,`"${h}" is not a relation any kind declares`));for(let h of j.sweeps)r.has(h)?o.over!=="graph"&&s.push(Ne("rule-cost",`${p}.${m}`,`this rule looks at every ${h} 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(y("rule-kind",`${p}.${m}`,`"${h}" is not a kind this document declares`))}o.says&&Se(o.says,`${p}.says`,s),(o.repairs??[]).forEach((m,l)=>{!a[m.act]&&!de(m.act)&&!me(m.act,e.kinds)&&s.push(y("repair-act",`${p}.repairs.${l}.act`,`"${m.act}" is not an act this document declares`,ge(m.act,e)))})}let z=e.policy;return z&&(z.grants.forEach((i,o)=>{if(i.roles!=="*"&&d.size>0)for(let p of i.roles)d.has(p)||s.push(y("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]&&!de(p)&&!me(p,e.kinds)&&s.push(y("grant-act",`policy.grants.${o}.mutations`,`"${p}" is not an act this document declares`,ge(p,e)))}),(z.sees??[]).forEach((i,o)=>{for(let p of i.kinds)r.has(p)||s.push(y("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(y("sight-role",`policy.sees.${o}.roles`,`"${p}" is not one of the document's roles`))})),s.push(...We(e)),s}function On(e){return e.label?[...e.label.matchAll(/\{\s*([A-Za-z_][A-Za-z0-9_]*)/g)].map(s=>s[1]):[fe(e)??[]].flat()}function vn(e,s,r,t){let a=new Map,d=ae(e.on),u=new Map,f=new Map;(d.length>0||s.some(l=>"remove"in l&&R(l.remove)==="subject"||"from"in l&&(R(l.from)==="subject"||R(l.to)==="subject")||"set"in l&&!("create"in l)&&R(l.target??"$subject")==="subject"))&&a.set(pe,{ref:d.length>0?d:"*",required:!0});let i=e.args??{},o=e.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),m=(l,c,j)=>{if(l===pe||wn.has(l)||u.has(l)||a.has(l))return;let h=i[l]?w(i[l],j):void 0;a.set(l,h?{field:h,optional:!h.required,required:!!h.required}:c())};for(let l of s)if("create"in l){let c=r.kinds[l.create],j=c?rn(c,On(c)):[],h=S=>j.includes(S)?j.indexOf(S):j.length;for(let[S,A]of Object.entries(l.set??{}).sort(([b],[G])=>h(b)-h(G))){let b=R(A),G=c?.fields[S];if(b&&G){let F=!!G.required&&G.default===void 0;m(b,()=>({field:G,optional:!F,required:F}),G)}}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[j,h]of[["from",l.from],["to",l.to]]){let S=R(h);if(!S)continue;let A=j==="to"?c?.to??"*":c?.from??"*";A!=="*"&&!f.has(S)&&f.set(S,A),m(S,()=>({ref:A,required:!0}))}}else if("set"in l){let c=R(l.target??"$subject"),j=c==="subject"?d[0]:u.get(c??"")??f.get(c??"")?.[0];c&&c!=="subject"&&!u.has(c)&&m(c,()=>({ref:"*",required:!0}));for(let[h,S]of Object.entries(l.set)){let A=R(S);if(!A)continue;let b=j?r.kinds[j]?.fields[h]:void 0;m(A,()=>b?{field:b,optional:!o,required:o}:{any:!0,required:!1},b)}}else if("remove"in l){let c=R(l.remove);c&&m(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 At(e,s={}){let r=Sn(e);if(!r.document||le(r.findings))return{ok:!1,findings:r.findings};let t=r.document,a=[...r.findings];s.previous&&a.push(...En(t,s.previous));let d=xn(t,a);return le(d.findings)?{ok:!1,findings:d.findings}:Ve(d,s)}function re(e,s){return e.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 xn(e,s){let r=an(e),t={};for(let[i,o]of Object.entries(e.kinds)){let p=fe(o),w=o.label??(p?`{${p}}`:void 0),m=ne(o),l=m?on(e,i,[...m]):[];t[i]={...w?{label:re(J(w),o.fields)}:{},...o.describe?{describe:re(J(o.describe),o.fields)}:{},...m?{computed:[...m]}:{},...l.length>0?{durations:l}:{}}}let a={};for(let[i,o]of Object.entries(e.acts??{})){let p=cn(o,e),w=vn(o,p,e,r),m=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]:[]))],j=[...new Set(p.flatMap(g=>"sever"in g?[g.sever]:"replace"in g?g.replace:[]))],h=[...new Set(p.flatMap(g=>"set"in g&&!("create"in g)&&R(g.target??"$subject")==="subject"?Object.keys(g.set):[]))],S=new Map;for(let g of p){if(!("connect"in g)&&!("sever"in g))continue;let v=r.get("connect"in g?g.connect:g.sever);for(let[D,oe]of[["from",g.from],["to",g.to]]){let B=R(oe),Y=D==="to"?v?.to:v?.from;B&&B!=="subject"&&Y&&Y!=="*"&&S.set(B,[...new Set([...S.get(B)??[],...Y])])}}let A={};for(let g of p){if(!("set"in g)||"create"in g)continue;let v=R(g.target??"$subject");for(let D of v&&v!=="subject"&&S.get(v)||[])A[D]=[...new Set([...A[D]??[],...Object.keys(g.set)])]}let b={};for(let g of p)if(!(!("set"in g)||"create"in g||R(g.target??"$subject")!=="subject"))for(let[v,D]of Object.entries(g.set??{}))typeof D=="string"&&R(D)===void 0||typeof D=="number"||typeof D=="boolean"?b[v]=typeof D=="string"&&D.startsWith("$$")?D.slice(1):D:delete b[v];let G=l.length===0&&p.every(g=>!("set"in g)||!g.set||Object.values(g.set).every(v=>!(v&&typeof v=="object"&&!Array.isArray(v)&&"expr"in v))),F=new Map;for(let g of p)if(!(!("set"in g)||!g.set))for(let v of Object.values(g.set))v&&typeof v=="object"&&!Array.isArray(v)&&"expr"in v&&F.set(v.expr,H(v.expr));a[i]={title:o.title??i.replace(/-/g," "),effects:p,args:[...w],...o.allowedWhen?{guard:H(o.allowedWhen)}:{},...o.refusal?{refusal:re(J(o.refusal),e.kinds[[o.on??[]].flat()[0]??""]?.fields)}:{},exprs:[...F],destructive:m,idempotent:G,creates:l,connects:c,severs:j,writes:h,writesOther:A,sets:b}}let d={};for(let[i,o]of Object.entries(e.rules??{}))d[i]={title:o.title??i.replace(/-/g," "),require:H(o.require),...o.when?{when:H(o.when)}:{},...o.says?{says:re(J(o.says),e.kinds[o.over]?.fields)}:{}};let u=qe(e,s),f=Le(e),z=Ue(e);return{format:Ie,document:e,findings:s,kinds:t,...e.computed?{facts:[...ne(e)??[]]}:{},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(f).length>0?{viewSpecs:f}:{},...z?{home:z}:{}}}function Rt(e,s,r){let t=/^defineNode\("([^"]+)"\)/.exec(s)?.[1],a=t?r.kinds[t]:void 0;if(!t||!a)return e;let d=Object.keys(a.fields).filter(u=>u!=="label").slice(0,3);return{...e,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 En(e,s){let r=[],t=new Set(Object.values(s.kinds).flatMap(a=>Object.keys(a.edges??{})));for(let[a,d]of Object.entries(e.kinds)){let u=d.renamedFrom;u&&!s.kinds[u]&&r.push(y("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 f=s.kinds[u??a];for(let[z,i]of Object.entries(d.fields)){let o=i.renamedFrom;o&&!f?.fields[o]&&r.push(y("renamed-from-nothing",`kinds.${a}.fields.${z}.renamedFrom`,`${z} says it was ${o}, and the previous ${u??a} has no field called ${o}`,"name the field it was, or drop renamedFrom"))}for(let[z,i]of Object.entries(d.edges??{})){let o=i.renamedFrom;o&&!t.has(o)&&r.push(y("renamed-from-nothing",`kinds.${a}.edges.${z}.renamedFrom`,`${z} says it was ${o}, and the previous version has no relation called ${o}`,"name the relation it was, or drop renamedFrom"))}}return r}export{Sn as a,Et as b,cn as c,At as d,Rt as e};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d,e,f}from"./chunk.ZJXUWOG3.js";import"./chunk.TI4OSTQV.js";import"./chunk.SLBWPVIY.js";import"./chunk.AJZBJBMO.js";export{e as askArchived,b as askDeclaration,a as declarationAt,f as pastAt,d as pastOf,c as seqAt};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{k as a,l as o}from"./chunk.GZWC72HS.js";import"./chunk.ASCTAUFD.js";import"./chunk.CWPRQSED.js";import"./chunk.EZXGVTT2.js";import"./chunk.2LQ37DC2.js";import"./chunk.UXNZPPWR.js";import"./chunk.GYO57LKD.js";import"./chunk.R3DWF35R.js";import"./chunk.XBNASVTY.js";import"./chunk.6S3B4XC4.js";import"./chunk.52Y37IAD.js";import"./chunk.TLQTDKOL.js";import"./chunk.WVUJXDXZ.js";import"./chunk.VTCPA4V4.js";import"./chunk.FGJM4LJO.js";import"./chunk.K7WME4P4.js";import"./chunk.MDIAWTNK.js";import"./chunk.PEA4D66Y.js";import"./chunk.TRPPN2GD.js";import"./chunk.GZHZLJBF.js";import"./chunk.TTFYXKLI.js";import"./chunk.OJGHDWI6.js";import"./chunk.ICYJ7QJG.js";import"./chunk.MT45H2T5.js";import"./chunk.S2ATSY6P.js";import"./chunk.72Q4R7N6.js";import"./chunk.G6DISMVT.js";import"./chunk.W54NXXC5.js";import{ta as n}from"./chunk.B3T4N2XM.js";import"./chunk.SDO3U72B.js";import"./chunk.6W2DUW5S.js";import"./chunk.SLBWPVIY.js";import"./chunk.AJZBJBMO.js";var w=new WeakMap;function s(e,i){let t=w.get(e);t||w.set(e,t=new Map);let r=t.get(i);return r||t.set(i,r=a(o(e,n(e)),e,i)),r}export{s as frameworkViews};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function t(n){if(Array.isArray(n))return n.map(t);if(n&&typeof n=="object"){let r={};for(let o of Object.keys(n).sort()){let e=n[o];e!==void 0&&(r[o]=t(e))}return r}return n}function i(n){return JSON.stringify(t(n))??"undefined"}export{i as a};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./chunk.AJZBJBMO.js";var W=1200,Y="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",q=4e7,A=e=>/^image\//i.test(e.type)&&!/^image\/svg/i.test(e.type);function w(e,t={}){let u={name:e.name,type:e.type,bytes:e.bytes};return/^video\//i.test(e.type)?{...u,...e.width!==void 0?{width:e.width}:{},...e.height!==void 0?{height:e.height}:{},...e.caption!==void 0?{caption:e.caption}:{},...e.duration!==void 0?{duration:e.duration}:{}}:A(e)?{...u,...e.width!==void 0?{width:e.width}:{},...e.height!==void 0?{height:e.height}:{},...e.caption!==void 0?{caption:e.caption}:{},...t.src!==void 0?{src:t.src}:{},...t.left!==void 0?{left:t.left}:{}}:u}var z=new Set(["id","kind","label"]),L=e=>{let t=e;return typeof t=="object"&&t!==null&&typeof t.href=="string"&&typeof t.name=="string"&&typeof t.type=="string"&&typeof t.bytes=="number"};function R(e,t){let u=o=>{let d;for(let[f,c]of Object.entries(o)){if(z.has(f))continue;let l=L(c)?t(c,o):Array.isArray(c)&&c.length>0&&c.every(L)?c.map(a=>t(a,o)):void 0;l!==void 0&&((d??={...o})[f]=l)}return d??o};return{...e,...e.node?{node:u(e.node)}:{},...e.nodes?{nodes:e.nodes.map(u)}:{}}}var B=e=>e.toLocaleString("en-US"),_=(e,t)=>`The picture "${e.name}" on ${t.label?`"${t.label}"`:"a record"}`;function C(e,t,u){let o=e===!0?1200:e.width??1200,d=t?.pictureBytes??15e5,f=t?.picturesBytes??12e6,c=Math.round(o*Math.min(2,Math.max(1,u||1)));return{width:o,perFile:d,perView:f,need:c,reckon:a=>Math.min(d,Math.ceil(a.bytes*(a.width&&a.width>c?(c/a.width)**2:1)))}}var M=(e,t)=>`${_(e,t)} is left out: at ${B(e.bytes)} bytes it is more than the host fetches for a view.`,N=(e,t,u,o)=>`${_(e,t)} is left out: the view ${u} is handed at most ${B(o)} bytes of pictures, and the pictures before it took them.`;function K(e,t){let{perView:u,reckon:o}=C(t.pictures,t.limits,2),d=[],f=0;return{props:R(e,(l,a)=>{if(!A(l))return w(l);let p=y=>(d.includes(y)||d.push(y),w(l,{left:y}));if(l.bytes>4e7)return p(M(l,a));let P=o(l);return f+P>u?p(N(l,a,t.view,u)):(f+=P,w(l,{src:t.standIn}))}),left:d}}function Q(e,t){let{width:u,perFile:o,perView:d,need:f,reckon:c}=C(t.pictures,t.limits,e.devicePixelRatio),l=t.shrink??((n,r,s)=>D(e,n,r,s)),a=new Map,p=new Map,P=new Set,y=!1,v=!1,F=()=>{v||y||(v=!0,queueMicrotask(()=>{v=!1,y||t.moved()}))},G=n=>{P.has(n)||(P.add(n),t.onLeft?.(n))},T=n=>{n?.state==="ready"&&(p.delete(n.url),n.url.startsWith("blob:")&&e.URL.revokeObjectURL(n.url))},E=_,k,S=n=>new Promise(r=>{let s=new e.Image;s.onload=()=>r(!0),s.onerror=()=>r(!1),e.setTimeout(()=>r(!1),2e3),s.src=n}),x=n=>new Promise((r,s)=>{let b=new e.FileReader;b.onload=()=>r(String(b.result)),b.onerror=s,b.readAsDataURL(n)}),H=async n=>{if(t.as==="blob"){let s=e.URL.createObjectURL(n);return k??=S(s),await k?{url:s,drawn:s}:{url:s,drawn:await x(n)}}let r=await x(n);return{url:r,drawn:r}},I=(n,r,s)=>({state:"left",said:`${E(n,r)} could not be loaded for the view ${t.view}${s?`: the host answered ${s}.`:"."}${s&&!t.file?" A host that serves the app under a base says where a record's files are (file, on the view's definition).":""}`}),O=async(n,r)=>{let s=I(n,r),b=t.file?t.file(n.href):n.href;if(b===void 0)return s;let i=new e.URL(b,e.document.baseURI);if(i.origin!==e.location.origin||!/^https?:$/.test(i.protocol))return s;let m=await e.fetch(i.href,{credentials:"same-origin"}),h=(m.headers.get("content-type")??"").split(";")[0].trim();if(!m.ok)return I(n,r,String(m.status));if(!A({type:h}))return I(n,r,`${h||"no type"}, not a picture`);let g=new e.Blob([await m.arrayBuffer()],{type:h});if(g.size>4e7)return s;if(!(n.width!==void 0&&n.width<=f)||g.size>o){let V=await l(g,f,o).catch(()=>{});if(V)g=V;else if(g.size>o)return s}return g.size>o?{state:"left",said:`${E(n,r)} is left out: made as small as the ${B(u)} pixels across the view ${t.view} draws a picture at, it is still more than the ${B(o)} bytes one picture is handed.`}:{state:"ready",...await H(g),bytes:g.size}},j=(n,r)=>{a.set(n.href,{state:"pending",bytes:c(n)}),O(n,r).then(s=>U(n.href,s),()=>U(n.href,{state:"left",said:`${E(n,r)} could not be loaded for the view ${t.view}.`}))},U=(n,r)=>{if(y||a.get(n)?.state!=="pending")return T(r);a.set(n,r),r.state==="ready"&&p.set(r.url,r.drawn),r.state==="left"&&G(r.said),F()};return{hand(n){if(y)return R(n,i=>w(i));let r=0,s=new Set,b=R(n,(i,m)=>{if(!A(i))return w(i);s.add(i.href);let h=a.get(i.href);if(h?.state==="left")return w(i,{left:h.said});if(!h&&i.bytes>4e7)return h={state:"left",said:M(i,m)},a.set(i.href,h),G(h.said),w(i,{left:h.said});let g=h?h.bytes:c(i);if(r+g>d){let $=N(i,m,t.view,d);return G($),w(i,{left:$})}return r+=g,h||j(i,m),w(i,h?.state==="ready"?{src:h.url}:{})});for(let[i,m]of a)s.has(i)||(T(m),a.delete(i));return b},drawn:n=>p.get(n),waiting:()=>[...a.values()].some(n=>n.state==="pending"),dispose(){y=!0;for(let n of a.values())T(n);a.clear(),p.clear()}}}async function D(e,t,u,o){if(typeof e.createImageBitmap!="function")return;let d=await e.createImageBitmap(t);try{if(d.width<=u&&t.size<=o)return t;let f=Math.min(1,u/d.width),c=Math.max(1,Math.round(d.width*f)),l=Math.max(1,Math.round(d.height*f)),a=e.document.createElement("canvas");a.width=c,a.height=l;let p=a.getContext("2d");if(!p)return;p.drawImage(d,0,0,c,l);let P=F=>new Promise(G=>a.toBlob(G,F,.85)),y=/^image\/(jpeg|webp|png)$/i.test(t.type)?t.type:"image/png",v=await P(y);return v&&v.size<=o?v:await P("image/jpeg")??v??void 0}finally{d.close()}}export{q as PICTURE_FETCH_BYTES,Y as PICTURE_STAND_IN,W as PICTURE_WIDTH,Q as createGuestPictures,w as guestFileOf,R as handFiles,A as isGuestPicture,C as pictureBudget,K as standInPictures};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk.6ESAZJBN.js";import"./chunk.OZYZBRWO.js";import"./chunk.G6DISMVT.js";import"./chunk.W54NXXC5.js";import"./chunk.B3T4N2XM.js";import"./chunk.SDO3U72B.js";import"./chunk.6W2DUW5S.js";import"./chunk.SLBWPVIY.js";import"./chunk.AJZBJBMO.js";export{a as ActivityFilter,b as InteractionRow};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as on,c as an,d as re,e as sn,f as oe,h as Oe,i as dn,n as cn,r as ie}from"./chunk.TRPPN2GD.js";import{Ab as U,B as ue,C as te,Ca as Be,Db as Qe,Ea as _e,F as ke,Fc as tn,Gc as rn,H as Ce,Hb as Xe,I as Ze,Ia as we,Ja as ve,Mb as en,Pa as He,Sa as Ue,b as De,ba as Ke,bb as We,c as Te,d as $e,db as Je,e as K,fa as Ve,g as ce,h as M,i as Pe,ib as xe,j as Ge,jb as Ye,k as le,l as Me,la as Ie,m as Le,o as Fe,p as fe,q as he,uc as nn,v as Ne,wa as be,x as ne,z as pe,za as qe}from"./chunk.6W2DUW5S.js";function ln(e){if(typeof e=="string")return{form:"string",light:e};if(typeof e!="object"||e===null)return;let s=e,n=b=>typeof s[b]=="string"?s[b]:void 0,t=n("light")??n("src");if(t===void 0)return;let[o,m,u]=[n("dark"),n("alt"),n("darkFallback")];return{form:n("light")!==void 0?"light":"src",light:t,...o!==void 0?{dark:o}:{},...m!==void 0?{alt:m}:{},...u!==void 0?{darkFallback:u}:{}}}function Gn(e,s){let n=e.brand??{},t=n.accent?rn(n.accent):void 0;t&&!t.ok&&s.push(dn("brand","brand.accent",`that accent cannot make a readable brand, so the app keeps Graview's colors: ${t.why}`,"pick a color further from orange-red, or a darker one"));let o=ln(n.logo),m=n.name??e.name,u=n.typography?Object.fromEntries(Object.entries(n.typography).filter(([,b])=>typeof b=="string"&&!/url\(|@import|[;{}<>\\]/i.test(b)).map(([b,L])=>[b,tn(L)])):void 0;return{name:m,schemes:t?.ok?t.schemes:nn,...n.currency?{currency:n.currency}:{},...n.locale?{locale:n.locale}:{},...n.timeZone?{timeZone:n.timeZone}:{},...o?{logo:o.dark||o.darkFallback==="invert"?{light:o.light,...o.dark?{dark:o.dark}:{darkFallback:"invert"}}:o.light,logoAlt:o.alt??m}:{},...n.favicon?{favicon:n.favicon}:{},...e.description?{subtitle:e.description}:{},...n.subtitle===!1?{subtitleDrawn:!1}:{},...u?{typography:u}:{},...n.shape?{shape:n.shape}:{},...n.accents?{accents:n.accents}:{},...n.scheme?{scheme:n.scheme}:{}}}function fn(e){let{currency:s,locale:n,timeZone:t}=e.brand??{};return{...s?{currency:s}:{},...n?{locale:n}:{},...t?{timeZone:t}:{}}}var wn=Symbol.for("@graview/core:typed-field"),pn=(e,s)=>(/^(phone|place|duration)$/.test(s)&&(te(e)[wn]=s),e),un=/^(?=(?:\D*\d){3})\+?[\d ()./-]+(?: *(?:ext\.?|x|#) *\d+)?$/i;function mn(e){let s=M().check(K(300),pe(t=>Be(t,e)!==void 0,`a record of ${e.kinds.join(" or ")} in ${e.address}, as "<kind>:<id>"`)),n=e.cardinality==="one"?s:fe(s).check(K(200));return _e(e.description?n.check(ue(e.description)):n,e)}var xn=new WeakMap;function gn(e,s){xn.set(e,s)}var On=[{where:"settings[]",was:"honoured",now:"honored",since:"0.1.16"},{where:"pages",was:"overview",now:"scene",since:"0.1.17"}],V=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function yn(e,s=On){if(!V(e))return{document:e,respelled:[]};let n=[],t=e;for(let o of s)t=Re(t,o.where.split("."),o,"",n);return{document:t,respelled:n}}function Re(e,s,n,t,o){if(s.length===0){if(!V(e)||!Object.hasOwn(e,n.was))return e;o.push(`${t}${n.was}`);let{[n.was]:T,...N}=e;return Object.hasOwn(e,n.now)?N:{...N,[n.now]:T}}if(!V(e))return e;let[m,...u]=s,b=m.endsWith("[]"),L=b?m.slice(0,-2):m,F=e[L],B=F;if(!b)B=Re(F,u,n,`${t}${L}.`,o);else if(Array.isArray(F)){let T=F.map((N,W)=>Re(N,u,n,`${t}${L}.${W}.`,o));B=T.some((N,W)=>N!==F[W])?T:F}return B===F?e:{...e,[L]:B}}var hn="graview-compiled@1";function Rn(e,s){return e.find(([n,t])=>n!==q&&"ref"in t&&(t.ref==="*"||t.ref.includes(s)))?.[0]}var q="id",me=e=>typeof e=="string"&&/^\$[A-Za-z][A-Za-z0-9]*$/.test(e)?e.slice(1):void 0;function kn(e){let s=Object.entries(e.fields),n=t=>["name","title","label"].find(o=>t.some(([m])=>m===o))??t[0]?.[0];return n(s.filter(([,t])=>t.required&&(t.type==="string"||t.type==="text")))??n(s.filter(([,t])=>t.type==="string"))}function bn(e,s,n){let t;switch(e.type){case"string":case"place":t=M().check(K(500));break;case"phone":t=M().check(K(40),ce(un,"a phone number"));break;case"text":t=M().check(K(2e4)),e.format&&(te(t)[Symbol.for("@graview/core:markdown")]=1);break;case"number":case"integer":case"duration":{let m=e.min??(e.type==="duration"?0:void 0),u=[...e.type==="number"?[]:[Me()],...m===void 0?[]:[Te(m)],...e.max===void 0?[]:[De(e.max)],...e.step===void 0?[]:[$e(e.step)]];t=u.length>0?le().check(...u):le();break}case"boolean":t=Le();break;case"date":t=M().check(ce(ke,"a date like 2026-10-02"));break;case"datetime":t=M().check(pe(Ce,"a date and time like 2026-10-02T14:30:00Z"));break;case"enum":t=Ne(e.options);break;case"list":t=fe(e.of==="number"?le():e.of==="date"?M().check(ce(ke)):e.of==="image"||e.of==="video"||e.of==="file"?be(e.of):M().check(K(500))).check(K(200));break;case"image":case"video":case"file":t=be(e.type);break;case"app-link":t=qe();break;case"url":t=Ge();break;case"email":t=Pe();break}let o=e.type==="number"||e.type==="integer";return pn(t,o&&e.format==="duration"?"duration":e.type),e.collaborative!==void 0&&(e.type==="text"||e.type==="string")&&(te(t)[Symbol.for("@graview/core:collaborative")]=e.collaborative?1:0),e.description&&(t=t.check(ue(e.description))),o&&(e.format==="money"||e.format==="percent"||!e.format&&e.unit)&&Xe(t,{...n,...e.format?{format:e.format}:{},...e.unit?{unit:e.unit}:{}}),s?ne(t):t}var ae=e=>{throw new U(`there is no record "${e}"`,"invalid")},zn=(e,s)=>"field"in e?bn(e.field,e.optional,s):"ref"in e?en(e.ref):ne(Fe()),An=new WeakMap;var ze=(e,s)=>V(s)&&Object.keys(e??{}).length===Object.keys(s).length&&Object.keys(e??{}).every(n=>Object.hasOwn(s,n));function it(e,s={}){let n=V(e)?e.format:void 0;if(n!==hn)return{ok:!1,findings:[Oe("compiled-format","format",n===void 0?"this is not a compiled Graview app":`this compiled app is ${JSON.stringify(n)}, and this build reads ${hn}`,"compile the document instead")]};let t=e,o=yn(t.document).document,m=o===t.document?t:{...t,document:o},u=V(o)&&typeof o.name=="string"&&V(o.kinds)&&ze(o.kinds,m.kinds)&&ze(o.acts,m.acts)&&ze(o.rules,m.rules)&&Array.isArray(m.edges)&&Array.isArray(m.findings),b={ok:!1,findings:[Oe("compiled-shape","","this compiled app's parts do not match its document","compile the document instead")]};if(!u)return b;try{return Sn(m,s)}catch{return b}}function Sn(e,s={}){let{document:n}=e,t=n.brand?.timeZone,o=s.today??(()=>Ze(t)),m=new Map(e.edges.map(([h,r])=>[h,r])),u=new Map;for(let[h,r]of Object.entries(n.kinds)){let z=e.kinds[h]?.computed,R=ve(r.edges);u.set(h,{fields:new Set([...Object.keys(r.fields),...R.keys()]),edges:new Map(Object.entries(we(r.edges)).map(([j,$])=>[j,$.cardinality??"many"])),...z?{computed:new Map(z)}:{},...R.size>0?{linked:R}:{}})}e.facts&&u.set(an,{computed:new Map(e.facts)});let b=fn(n),L=new Map,F=Object.entries(n.kinds).map(([h,r])=>{let z={};for(let[i,g]of Object.entries(r.fields))z[i]=bn(g,!g.required,b),g.repeats&&(z[He(i)]=ne(Ue()));for(let[i,g]of ve(r.edges))z[i]=ne(mn(g));let{label:R,describe:j,durations:$}=e.kinds[h]??{},P=Object.entries(r.computed??{}).map(([i,g])=>[i,typeof g=="string"?{expr:g}:g]),J=Object.hasOwn(r.fields,"label")&&!r.fields.label.label&&!/\{\s*label\b/.test(r.label??`{${kn(r)??""}}`),_=Object.fromEntries([...J?[["label","Label"]]:[],...Object.entries(r.fields).filter(([,i])=>i.label).map(([i,g])=>[i,g.label]),...P.filter(([,i])=>i.label).map(([i,g])=>[i,g.label])]),A=Object.keys(_).length>0,l=Object.fromEntries(Object.entries(r.fields).filter(([,i])=>i.default!==void 0).map(([i,g])=>[i,g.default]));L.set(h,l);let D=Object.fromEntries(Object.entries(we(r.edges)).map(([i,{renamedFrom:g,...I}])=>[i,I])),S=i=>r[i]?{[i]:r[i]}:{};return Ke(h,{fields:he(z),edges:D,...S("plural"),...S("noun"),...S("description"),...R?{label:i=>ie(R,{node:i,kinds:u,today:o(),money:b})||i.id}:{},...j?{describe:i=>ie(j,{node:i,kinds:u,today:o(),money:b})}:{},...S("lifecycle"),...S("figure"),...S("fieldRoles"),...S("people"),archives:r.archives,...r.tidying?{tidying:r.tidying}:{},...P.length>0?{computed:Object.fromEntries(P.map(([i,g])=>[i,$?.includes(i)?{...g,as:"duration"}:r.computed[i]]))}:{},...A||r.glance||r.page?{display:{...A?{labels:_}:{},...r.glance?{glance:[...r.glance]}:{},...r.page?{page:r.page}:{}}}:{},...Object.keys(l).length>0?{defaults:l}:{}})}),B=We(F,n.computed);function T(h){return B.tryDefinition(h.kind)?.label?.(h)??h.id}let N=h=>({id:"",kind:h,...L.get(h)}),W=[];for(let[h,r]of Object.entries(n.acts??{})){let z=e.acts[h],{title:R,effects:j,guard:$,refusal:P,destructive:J,idempotent:_,creates:A,connects:l,severs:D,writes:S,writesOther:i,sets:g}=z,I=new Map(z.args),se={};for(let[d,x]of I)se[d]=zn(x,b);let w=[r.on??[]].flat(),C=new Map(z.exprs),G=j.find(d=>"create"in d),Y=(d,x,f,v=null)=>{if(V(d)&&"expr"in d)return oe(C.get(d.expr),{graph:f,subject:v,kinds:u,bindings:x,today:o()});let k=me(d);return k===void 0?typeof d=="string"&&d.startsWith("$$")?d.slice(1):d:k==="now"?new Date().toISOString():k==="today"?o():x[k]},Ee=(d,x)=>{if(!G)return"";let f=n.kinds[G.create].fields,v=N(G.create),k=[];for(let[O,ee]of Object.entries(G.set??{})){try{v[O]=Y(ee,d,x)??v[O]}catch{}let Q=me(ee);Q&&d[Q]!==void 0&&k.push(O)}let Z=T(v).trim(),H=k.filter(O=>v[O]!==!1&&f[O].type!=="text"&&!(/[^]{41}/.test(v[O])||/ .*[.!?]$/.test(v[O])&&!/[ .][A-Z]\w{0,3}\.$/.test(v[O]))&&T({...v,[O]:void 0}).trim()===Z).map(O=>v[O]===!0?f[O].label??Ve(O):cn(v[O],f[O].format,o(),[],b));return Z&&H.length>0?`${Z} (${H.join(", ")})`:Z};W.push(Qe(h,{input:he(se),title:R,...r.description?{description:r.description}:{},...r.fromTheOtherEnd?{fromTheOtherEnd:r.fromTheOtherEnd}:{},...I.has(q)?{subject:{kinds:w.length>0?w:"*",arg:q}}:{},...J?{destructive:!0}:{},..._?{idempotent:!0}:{},...A.length>0?{creates:A}:{},...l.length>0?{connects:l}:{},...D.length>0?{severs:D}:{},writes:S,...Object.keys(i).length>0?{writesOther:i}:{},...Object.keys(g).length>0?{sets:g}:{},describe:(d,x)=>{let f=typeof d[q]=="string"?x.getNode(d[q]):void 0,v=f?T(f):Ee(d,x);return v?`${R}: ${v}`:R},apply(d,x){let f=d.graph,v=typeof x[q]=="string"?x[q]:void 0,k=v?f.getNode(v):void 0;if(v&&!k&&ae(v),k&&w.length>0&&!w.includes(k.kind))throw new U(`"${R}" acts on ${w.join(" or ")}, not on ${Ie(k.kind)}`,"invalid");let Z={};for(let[a,c]of Object.entries(x))c!==void 0&&(Z[a]=c);if($&&k){let a;try{a=oe($,{graph:f,subject:k,kinds:u,bindings:Z,today:o()})}catch(c){throw c instanceof re?new U(`"${R}" could not be judged: ${c.sentence}`):c}if(a!==!0)throw new U(P?ie(P,{node:k,kinds:u,graph:f,bindings:Z,today:o(),money:b}):`"${R}" is not allowed for ${T(k)} right now`)}let H=new Map,O=a=>f.has(a)||[...H.values()].includes(a),ee=new Set,Q=a=>{let c=Je(a);ee.has(c)||(ee.add(c),d.removeEdge(a))},X=(a,c)=>{let p=me(a);if(p==="subject")return v;if(p==="me"){let y=d.me;if(y&&n.kinds[f.getNode(y)?.kind]?.people)return y;throw new U(`"${R}" is done as you, and you have no record here`)}if(H.has(p))return H.get(p);try{return Y(a,Z,f,c??k??null)}catch(y){throw y instanceof re?new U(`"${R}" could not work out a value: ${y.sentence}`):y}};for(let a of j)if("create"in a){let c=n.kinds[a.create],p=N(a.create);for(let[ye,de]of Object.entries(a.set??{})){let je=X(de,void 0);je!==void 0&&(p[ye]=je)}let y=kn(c),E=d.freshId(String((y&&p[y])??a.create),a.create);d.addNode({...p,id:E}),a.as&&H.set(a.as,E)}else if("connect"in a||"sever"in a){let c="connect"in a?a.connect:a.sever,p=String(X(a.from,void 0)??""),y=String(X(a.to,void 0)??"");if(O(p)||ae(p),O(y)||ae(y),"connect"in a){if(m.get(c)?.cardinality==="one")for(let E of f.out(p,c))E.id!==y&&Q({kind:c,from:p,to:E.id});f.out(p,c).some(E=>E.id===y)||d.addEdge({kind:c,from:p,to:y})}else Q({kind:c,from:p,to:y})}else if("set"in a){let c=String(X(a.target??"$subject",void 0)??""),p=f.getNode(c);!p&&!O(c)&&ae(c);let y={};for(let[E,ye]of Object.entries(a.set)){let de=X(ye,p);de!==void 0&&(y[E]=de)}Object.keys(y).length>0&&d.patchNode(c,y)}else if("remove"in a){let c=String(X(a.remove,void 0)??"");f.has(c)||ae(c),d.removeNode(c)}else if("replace"in a&&k){let c=x.to;for(let p of a.replace){let y=m.get(p)?.from.includes(k.kind)??!0;for(let E of y?f.out(k.id,p):f.in(k.id,p))p===a.keep&&E.id===c||Q(y?{kind:p,from:k.id,to:E.id}:{kind:p,from:E.id,to:k.id})}}}}))}let Ae=[];for(let[h,r]of Object.entries(n.rules??{})){let{title:z,require:R,when:j,says:$}=e.rules[h],P=r.repairs??[],J=(A,l,D=o(),S)=>{let i=[],g={graph:A,subject:l,kinds:u,today:D,...S?{linked:S}:{},onUnread:w=>i.push(w)},I;try{if(j&&oe(j,g)!==!0)return[];if(I=oe(R,g)===!0,!I&&i.length>0)throw new re(`it reads ${on(i[0])}`,0)}catch(w){throw w instanceof sn?new Ye(w.sentence):w instanceof re?new Error(w.sentence):w}if(I)return[];let se=P.flatMap(w=>{let C=n.acts?.[w.act],G={},Y=l&&C?.on&&C.fromTheOtherEnd&&![C.on].flat().includes(l.kind)?Rn(e.acts[w.act].args,l.kind):void 0;Y?G[Y]=l.id:l&&(C?.on||/^(edit|remove|archive|unarchive|merge|skip|detach|split)-/.test(w.act))&&(G[q]=l.id);for(let[x,f]of Object.entries(w.args??{}))G[x]=me(f)==="subject"?l?.id:f;let d=(C?e.acts[w.act].args:[]).filter(([x,f])=>f.required&&G[x]===void 0).map(([x])=>x);return[{mutation:w.act,label:w.label??(Y?C.fromTheOtherEnd:C?.title)??w.act.replace(/-/g," "),args:G,...d.length>0?{missing:d}:{}}]});return[{invariant:h,...l?{subjectId:l.id}:{},label:z,message:$?ie($,{node:l,kinds:u,graph:A,today:D,money:b}):l?`${T(l)}: ${z}`:z,nodeIds:l?[l.id]:[],repairs:se}]},_={label:z,shape:{over:r.over,require:R,when:j,says:$,declared:n.kinds,money:b,kinds:u,today:o},judgment:{require:r.require,...r.when?{when:r.when}:{},...r.says?{says:r.says}:{}},...r.description?{description:r.description}:{},...P.length>0?{repairs:P.map(A=>A.act)}:{}};Ae.push(r.over==="graph"?xe(h,{scope:"graph",..._,evaluate:({graph:A,today:l,context:D})=>J(A,null,l,D?.linked)}):xe(h,{scope:{kind:r.over},..._,evaluate:({graph:A,subject:l,today:D,context:S})=>J(A,l,D,S?.linked)}))}let Se=n.policy&&{...n.policy,...n.roles?{roles:n.roles}:{}},ge={name:n.name,schema:B,mutations:W,invariants:Ae,...Se?{policy:Se}:{},...e.brand?{brand:e.brand}:{},...n.modules?{modules:n.modules}:{},...n.lenses?{lenses:n.lenses}:{},...n.pages?{pages:n.pages}:{},...n.settings?{settings:n.settings}:{},...n.connections?{connections:n.connections}:{},...n.forms?{forms:n.forms}:{},...n.publishing?{publishing:n.publishing}:{},...e.viewSpecs?{viewSpecs:e.viewSpecs}:{},...e.home?{home:e.home}:{},version:n.version??1};return gn(ge,n),An.set(ge,e),{ok:!0,app:ge,document:n,findings:e.findings,sights:n.policy?.sees,kinds:u}}export{yn as a,Gn as b,hn as c,q as d,me as e,kn as f,it as g,Sn as h};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as N}from"./chunk.TI4OSTQV.js";import{h as E}from"./chunk.SLBWPVIY.js";var S=globalThis[Symbol.for("@graview/core:publishing")]??={},T=()=>S.kit,P="publish",x=e=>e?.mode==="on-publish",Q=Symbol.for("@graview/core:seat"),G=(e,n)=>{let s=Reflect.get(e,n,e);return typeof s=="function"?s.bind(e):s},X,Y=()=>X??={name:P,title:"Publish",description:"Publish what collaborators have changed, so readers see it.",input:S.input(),apply(){}};var I=new WeakMap;function z(e){let n=e.all(),s=n.at(-1)?.id,o=I.get(e);if(o&&o.length===n.length&&o.last===s)return o.seq;let a,r;for(let t=n.length-1;t>=0;t--){let i=n[t];if(!(i.publishedThrough===void 0||(r??=e.undoneIds()).has(i.id))){a=i.publishedThrough;break}}return I.set(e,{length:n.length,last:s,seq:a}),a}function ee(e,n){if(!x(e))return{mutation:P,message:"this app is live: every edit reaches its readers as it is made, so there is nothing to publish.",wouldNeed:[]};let s=e.publishers??e.working;if(T().reads({mode:"on-publish",working:s},n))return{mutation:P,message:`only ${s.join(", ")||"nobody"} may publish.`,wouldNeed:[...s]}}var ne=(e,n,s,o,a,r)=>{let{log:t}=e,i=t.length,d=s.args.through;if(d!==void 0&&(!Number.isInteger(d)||d<t.horizon||d>i))throw new RangeError(`Cannot publish through seq ${String(d)}: this store holds seqs ${t.horizon} to ${i}.`);let f=d??i+1,p=z(t)??t.horizon,c=t.batches().filter(b=>!b.undone&&b.ops.some(m=>m.seq>=p&&m.seq<f&&m.publishedThrough===void 0)).length,g={id:n.id,seq:i,batch:o,author:a,intent:f<p?"Take back what was published":`Publish ${c===1?"1 change":`${c} changes`}`,...r.intent!==void 0?{batchIntent:r.intent}:{},mutation:s,primitives:[],reads:[],writes:[],at:n.at,...r.via!==void 0?{via:r.via}:{},publishedThrough:f};return t.append(g),g},te=new Set(["graph","log","snapshot","batches","violations","findings","canUndo","servedSeq","checkpoint"]);function se(e,n){let{seatView:s,viewsOf:o,viewKey:a,diff:r}=T(),t=o(e),i=a(n,"published"),d=t.get(i);if(d)return d;let f=s(e,n),p,c=()=>{let h=Math.max(e.publishedSeq??e.log.horizon,e.log.horizon);if(h>=e.log.length)return f;let u=e.log.all()[h-1-e.log.horizon]?.id;return(p?.seq!==h||p.id!==u)&&(p={seq:h,id:u,view:s(O(e,h),n)}),p.view},g=h=>h.servedSeq,b=h=>{let u=g(c()),v=c().graph.snapshot();return e.subscribe(()=>{let y=c(),k=g(y);if(k===u)return;let q=y.graph.snapshot(),M=k>u?y.log.all().filter(w=>w.seq>=u):[],l=r(v,q);[u,v]=[k,q],h(l,M)})},m=new Proxy(f,{get(h,u){switch(u){case Q:return{store:e,principal:n};case"subscribe":return b;case"seenBy":return(v,y)=>e.seenBy(v,y);case"seenFor":return n;default:return te.has(u)?G(c(),u):G(h,u)}}});return t.set(i,m),m}S.served=se;S.act=(e,n)=>x(e.publishing)&&!e.past&&!n.has(P)?Y():void 0;S.verdict=(e,n)=>{let s=ee(e.publishing,n);return s?{ok:!1,refusal:s}:{ok:!0}};S.seq=e=>x(e.publishing)?z(e.log):void 0;S.op=ne;function K(e,n){let s;for(let o of[...e??[]].sort((a,r)=>a.seq-r.seq)){if(o.seq>n)break;o.declaration&&(s=o.declaration)}return s}var R=new WeakMap;function oe(e,n){let s=K(e?.declarations,n),o=e?.declarationAt,a=[...e?.declarations??[]].filter(i=>i.seq<=n).sort((i,d)=>i.seq-d.seq).at(-1);if(!o||!a||a.declaration)return{declaration:s};let r=R.get(o);r||R.set(o,r=new Map);let t=r.get(a.seq);if(!t){let i={settled:!0,declaration:void 0,waiting:Promise.resolve()};try{let d=o(a.seq);d instanceof Promise?(i.settled=!1,i.waiting=d.then(f=>void Object.assign(i,{settled:!0,declaration:f}),()=>void(i.settled=!0))):i.declaration=d}catch{}r.set(a.seq,t=i)}return t.settled?{declaration:t.declaration??s}:{waiting:t.waiting}}var V=e=>e,$=new WeakMap,B=new WeakMap;function j(e,n){let s=typeof n=="string"?Date.parse(n):n.getTime();if(Number.isNaN(s))throw new RangeError(`\u201C${String(n)}\u201D is not a time`);let a=e.log.all().findIndex(r=>Date.parse(r.at)>s);return a===-1?e.log.length:e.log.horizon+a}function O(e,n,s={}){let o=N(e);if(o){let l=typeof n=="number"?n:j(e,n);if(l>e.servedSeq)throw new RangeError(`No moment at seq ${l}: this seat is served through seq ${e.servedSeq}`);return O(o.store,l,s).seenBy(o.principal)}let a=e.log,r=a.horizon,t=typeof n=="number"?n:j(e,n);if(!Number.isInteger(t)||t<r||t>a.length)throw new RangeError(`No moment at seq ${t}: this store holds seqs ${r} to ${a.length}${r>0?"; what is before its horizon is in the archive":""}`);let i=a.all(),d=s.declaration,f=d?.schema??e.schema,p=a.epochs().filter(l=>l.seq<=t),c=p.at(-1),g=c?.seq??r,b=l=>l>r?i[l-1-r]?.id:void 0,m=($.get(e)??[]).filter(l=>l.seq<=a.length&&b(l.seq)===l.id);$.set(e,m);let h=[...m].reverse().find(l=>l.seq>=g&&l.seq<=t),u=h?.seq??g,v=h?.base??c?.base??ae(e),y=U(e,f,v),k=e.pastEvery,q=(l,w)=>{m.some(D=>D.seq===l)||(m.push({seq:l,id:w,base:y.snapshot()}),m.sort((D,J)=>D.seq-J.seq))};for(let l=u;l<t;l++){let w=i[l-r];try{_(y,w)}catch{}(l+1)%k===0&&l+1<t&&q(l+1,w.id)}t-u>=k&&q(t,b(t));let M=i[t-1-r]?.at??c?.at;return L(e,d,{graph:y,log:i.slice(0,t-r),epochs:p,...r>0&&!p.some(l=>l.horizon)?{horizon:r}:{},seq:t,at:M,from:u})}var A=(e,n)=>n===void 0?{}:{[e]:n};function L(e,n,s){let o=V(e),a=e.constructor;return new a({schema:n?.schema??e.schema,invariants:n?.invariants??o.invariants,invariantOptions:o.invariantOptions,...A("policy",n?n.policy:e.policy),...A("modules",n?.modules??o.declaredModules),...A("enabledModules",o.startingModules),...A("timeZone",e.timeZone),intelligence:e.intelligence,principal:o.by,log:[...s.log],epochs:[...s.epochs],...A("horizon",s.horizon),snapshot:s.graph.snapshot(),validate:!1,now:o.now,past:{seq:s.seq,...A("at",s.at),foldedFrom:s.from,folded:s.seq-s.from}})}function U(e,n,s){let o=e.graph.constructor;try{return o.from(n,s,{validate:V(e).validate})}catch{return o.from(n,s,{validate:!1})}}var W=256,C=new WeakMap;function F(e){let n=C.get(e);return n||C.set(e,n={ops:new Map,epochs:new Map,chunks:new Map,marks:new Map}),n}function H(e,n){let s=-1,o;for(let[i,d]of e.epochs)i<=n&&i>s&&([s,o]=[i,d.base]);for(let[i,d]of e.marks)i<=n&&i>s&&([s,o]=[i,d]);let a=-1;for(let i=n-1;i>=Math.max(s,0);i--)if(!e.ops.has(i)){a=i;break}if(a<0&&o)return{from:s,base:o};let r=a<0?0:a-a%W,t=e.chunks.get(r);return!t||t.settled&&!t.refused&&a>=t.to?{ask:r}:t.settled?t.refused?{refused:t.refused}:a<0?{from:0,base:{nodes:[],edges:[]}}:{refused:`The archive is missing a change this moment needs (seq ${a})`}:{waiting:t.waiting}}function re(e,n,s,o){let a=Math.min(s+W,o),r={to:a,settled:!1,waiting:Promise.resolve()};r.waiting=Promise.resolve().then(()=>n(s,a)).then(t=>{let i=Array.isArray(t)?{ops:t}:t;if(!Array.isArray(i?.ops))throw new Error("its answer held no ops");for(let d of i.ops)Number.isInteger(d?.seq)&&d.seq<o&&!e.ops.has(d.seq)&&e.ops.set(d.seq,d);for(let d of i.epochs??[])Number.isInteger(d?.seq)&&d.seq<o&&d.base&&e.epochs.set(d.seq,d)}).then(()=>void(r.settled=!0),t=>void Object.assign(r,{settled:!0,refused:`Could not read the older changes from the archive: ${t instanceof Error?t.message:String(t)}`})),e.chunks.set(s,r)}function pe(e,n,s){let o=s?.archived,a=e.log.horizon;if(!o||n>=a)return;let r=F(o),t=H(r,n);return"ask"in t&&(re(r,o,t.ask,a),t=H(r,n)),"base"in t||"ask"in t?void 0:{seq:n,...t}}function Z(e,n,s,o){let a=N(e);if(a)return Z(a.store,n,s,o).seenBy(a.principal);if(!Number.isInteger(n)||n<0)throw new RangeError(`No moment at seq ${n}`);let r=F(s),t=H(r,n);if(!("base"in t))throw new RangeError("refused"in t?t.refused:`The changes before seq ${n} are still being read from the archive`);let i=U(e,o?.schema??e.schema,t.base),d=[],f=e.pastEvery;for(let c=t.from;c<n;c++){let g=r.ops.get(c);d.push(g);try{_(i,g)}catch{}(c+1)%f===0&&c+1<n&&!r.marks.has(c+1)&&r.marks.set(c+1,i.snapshot())}n-t.from>=f&&r.marks.set(n,i.snapshot());let p=r.epochs.get(t.from);return L(e,o,{graph:i,log:d,epochs:p?[p]:[],...t.from>0?{horizon:t.from}:{},seq:n,at:d.at(-1)?.at??p?.at,from:t.from})}function ae(e){let n=e.log.all(),s=e.log.horizon,o=n[0]?.id,a=B.get(e);if(a&&a.firstId===o)return a.base;let r=e.log.epochs().find(d=>d.seq>s),t=e.graph.constructor.from(e.schema,r?.base??e.graph.snapshot(),{validate:!1});for(let d=(r?.seq??e.log.length)-1;d>=s;d--)try{t.applyPrimitives(E(n[d-s]),{restoring:!0})}catch{}let i=t.snapshot();return B.set(e,{firstId:o,base:i}),i}function he(e,n,s={}){let o=typeof n=="number"?n:j(e,n),a=oe(s,o),r="declaration"in a?a.declaration:K(s.declarations,o);return s.archived&&o<e.log.horizon?Z(e,o,s.archived,r):O(e,o,{declaration:r})}function _(e,n){if(n.undoes!==void 0){e.applyPrimitives(n.primitives,{restoring:!0});return}try{e.applyPrimitives(n.primitives)}catch{e.applyPrimitives(n.primitives,{restoring:!0})}}export{K as a,oe as b,j as c,O as d,pe as e,he as f};
|
|
@@ -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{q as He}from"./chunk.GYO57LKD.js";import{d as Je,e as Ee,f as ze,g as je}from"./chunk.BG2SC77J.js";import{a as Ie}from"./chunk.4DCPB67O.js";import{e as X}from"./chunk.IYVBJDR7.js";import{a as j}from"./chunk.TXEWSZGO.js";import{f as De,g as Y,i as Pe}from"./chunk.S2ATSY6P.js";import{a as Se}from"./chunk.72Q4R7N6.js";import{$a as ke,Ba as K,Bb as ve,Da as he,Eb as Ae,Fa as ye,Fb as Oe,Ga as Z,Ib as Re,K as pe,Lb as Te,Na as ge,Oa as be,Ob as C,Ra as we,Wb as _e,Ya as W,a as fe,cd as $e,ea as G,kc as xe,lc as Me,mc as Ne,ya as me}from"./chunk.6W2DUW5S.js";var E=(t,e,n)=>{(t[e]===void 0||n>t[e])&&(t[e]=n)},z=(t,e,n)=>{(t[e]===void 0||n<t[e])&&(t[e]=n)},Q=(t,e)=>{t.format=e,e.includes("int")&&(t.isInt=!0)},Le=(t,e)=>{t.mime=t.mime?t.mime.filter(n=>e.includes(n)):[...e]},qe=(t,e)=>{t.multipleOf??=[],t.multipleOf.includes(e)||t.multipleOf.push(e)},Fe=(t,e)=>(t.patterns??=new Set).add(e),sn={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 I(t){let e={},{def:n,bag:r}=t._zod,i=t._zod.traits.has("$ZodCheck")?[t,...n.checks??[]]:n.checks??[];for(let o of i){let a=o._zod.def;switch(a.check){case"greater_than":E(e,a.inclusive?"minimum":"exclusiveMinimum",a.value);break;case"less_than":z(e,a.inclusive?"maximum":"exclusiveMaximum",a.value);break;case"multiple_of":qe(e,a.value);break;case"number_format":{Q(e,a.format);let d=sn[a.format];d&&(E(e,"minimum",d[0]),z(e,"maximum",d[1]));break}case"bigint_format":Q(e,a.format);break;case"min_length":case"min_size":E(e,"minimum",a.minimum);break;case"max_length":case"max_size":z(e,"maximum",a.maximum);break;case"length_equals":E(e,"minimum",a.length),z(e,"maximum",a.length);break;case"size_equals":E(e,"minimum",a.size),z(e,"maximum",a.size);break;case"string_format":Q(e,a.format),a.pattern&&Fe(e,a.pattern),(a.format==="base64"||a.format==="base64url")&&(e.contentEncoding=a.format),(a.local||a.precision===-1)&&(e.laxFormat=!0);break;case"mime_type":Le(e,a.mime);break}}r.minimum!==void 0&&E(e,"minimum",r.minimum),r.exclusiveMinimum!==void 0&&E(e,"exclusiveMinimum",r.exclusiveMinimum),r.maximum!==void 0&&z(e,"maximum",r.maximum),r.exclusiveMaximum!==void 0&&z(e,"exclusiveMaximum",r.exclusiveMaximum),r.multipleOf!==void 0&&qe(e,r.multipleOf),r.format!==void 0&&(e.format??=r.format,r.format.includes("int")&&(e.isInt=!0)),r.mime&&Le(e,r.mime);for(let o of r.patterns??[])Fe(e,o);return e}var dn={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""};function L(t){let e=t._zod.def;return e.type==="pipe"&&e.in._zod.traits.has("$ZodTransform")?L(e.out):e.type==="catch"?L(e.innerType):t._zod.optin}var cn=new Set(["promise","optional","nonoptional","nullable","readonly","default","prefault","catch"]);function _(t,e=new Set){if(e.has(t))return!1;e.add(t);let n=t._zod.def,r=n.type;return r==="transform"?!0:r==="array"?_(n.element,e):r==="set"?_(n.valueType,e):r==="lazy"?_(n.getter(),e):cn.has(r)?_(n.innerType,e):r==="intersection"?_(n.left,e)||_(n.right,e):r==="record"||r==="map"?_(n.keyType,e)||_(n.valueType,e):r==="pipe"?t._zod.traits.has("$ZodCodec")||_(n.in,e)||_(n.out,e):r==="object"?Object.values(n.shape).some(i=>_(i,e)):r==="union"?n.options.some(i=>_(i,e)):r==="tuple"?n.items.some(i=>_(i,e))||(n.rest?_(n.rest,e):!1):!1}function ln(t){let e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n])=>e.indexOf(+n)===-1).map(([,n])=>n)}function Be(t){let e=t.anyOf;if(!Array.isArray(e)||e.length===0||t.type!==void 0)return;let n=[];for(let r of e){if(!r||typeof r!="object")return;Be(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;n.includes(o)||n.push(o)}}delete t.anyOf,t.type=n.length===1?n[0]:n}var Ue=new Set(["type","properties","required","additionalProperties"]),We=t=>{let e=t.additionalProperties;return e&&typeof e=="object"&&Object.keys(e).length?e:null},Ce=(t,e)=>JSON.stringify(t)===JSON.stringify(e);function ee(t){for(let i of t){if(typeof i!="object"||i.type!=="object")return null;for(let o in i)if(!Ue.has(o))return null}let e={},n=new Set;for(let i of t){for(let o in i.properties){if(Object.prototype.hasOwnProperty.call(e,o))continue;let a=[];for(let d of t){let s=d.properties?.[o]??We(d);s&&!a.some(y=>Ce(y,s))&&a.push(s)}e[o]=a.length===1?a[0]:ee(a)??{allOf:a}}for(let o of i.required??[])n.add(o)}let r={type:"object",properties:e};if(n.size&&(r.required=[...n]),t.every(i=>i.additionalProperties===!1))r.additionalProperties=!1;else{let i=[];for(let o of t){let a=We(o);a&&!i.some(d=>Ce(d,a))&&i.push(a)}i.length===1?r.additionalProperties=i[0]:i.length>1&&(r.additionalProperties={allOf:i})}return r}function un(t){let e=t.allOf;if(!Array.isArray(e)||e.length<2)return;for(let i of Ue)if(i in t)return;let n=e.filter(i=>Array.isArray(i.oneOf)||Array.isArray(i.anyOf)),r;if(!n.length)r=ee(e);else{let i=n[0],o=Array.isArray(i.oneOf)?"oneOf":"anyOf";if(Object.keys(i).length!==1)return;let a=e.filter(s=>s!==i),d=i[o].map(s=>ee([...a,s]));if(d.some(s=>!s))return;r={[o]:d}}r&&(delete t.allOf,Object.assign(t,r))}function Ve(t){let e=t;for(let S of["anyOf","oneOf"]){let T=e[S];if(!Array.isArray(T))continue;let O=T.map(Ve);O.some((v,h)=>v!==T[h])&&(e={...e,[S]:O})}let n=[e.type].flat(),r=!n.includes("string")&&n.some(S=>S==="number"||S==="integer"),i=e.enum??(e.const!==void 0?[e.const]:void 0);if(!r&&!i?.some(S=>typeof S=="number"))return e;let{minimum:o,maximum:a,exclusiveMinimum:d,exclusiveMaximum:s,multipleOf:y,format:p,id:b,...f}=e;return f.enum?f.enum=f.enum.map(S=>typeof S=="number"?String(S):S):typeof f.const=="number"&&(f.const=String(f.const)),r&&(f.type="string",i||(f.pattern=n.includes("number")?"^-?\\d+(?:\\.\\d+)?$":"^-?\\d+$")),f}var B=class{constructor(e,n){this.override=e;this.refs=n}done=new Map;path=[];cyclic=new Map;write(e,n=!1){let r=this.refs.get(e);if(r!==void 0&&!n)return{$ref:r};if(this.path.includes(e))return this.cyclic.has(e)||this.cyclic.set(e,""),{};let i=this.done.get(e);if(i)return i;this.path.push(e);try{let o=this.written(e);return this.done.set(e,o),o}finally{this.path.pop()}}written(e){let n={},r,i=e._zod.toJSONSchema?.();i?Object.assign(n,i):r=this.process(e,n);let o=fe.get(e);if(o)for(let d of Object.keys(o))n[d]=o[d];_(e)&&(delete n.examples,delete n.default),"_prefault"in n&&(n.default??=n._prefault,delete n._prefault);let a=n;if(r){let d=this.write(r);a={...n};for(let s of Object.keys(d))s in n||(a[s]=d[s])}return this.override({zodSchema:e,jsonSchema:a}),Be(a),e._zod.def.type==="intersection"&&un(a),a}process(e,n){let r=e._zod.def;switch(r.type){case"string":{n.type="string";let{minimum:i,maximum:o,format:a,patterns:d,contentEncoding:s,laxFormat:y}=I(e);if(typeof i=="number"&&(n.minLength=i),typeof o=="number"&&(n.maxLength=o),a&&(n.format=dn[a]??a,(n.format===""||a==="time"||y)&&delete n.format),s&&(n.contentEncoding=s),d&&d.size>0){let p=[...d];p.length===1?n.pattern=p[0].source:n.allOf=p.map(b=>({pattern:b.source}))}return}case"number":{let{minimum:i,maximum:o,multipleOf:a,exclusiveMinimum:d,exclusiveMaximum:s,isInt:y}=I(e);if(n.type=y?"integer":"number",typeof d=="number"&&d>=(i??Number.NEGATIVE_INFINITY)?n.exclusiveMinimum=d:typeof i=="number"&&(n.minimum=i),typeof s=="number"&&s<=(o??Number.POSITIVE_INFINITY)?n.exclusiveMaximum=s:typeof o=="number"&&(n.maximum=o),a){let[p,...b]=new Set(a.filter(f=>Number.isFinite(f)&&f!==0).map(Math.abs));p!==void 0&&(n.multipleOf=p),b.length&&(n.allOf=[...n.allOf??[],...b.map(f=>({multipleOf:f}))])}return}case"boolean":case"success":n.type="boolean";return;case"null":n.type="null";return;case"never":n.not={};return;case"enum":{let i=ln(r.entries);i.length===0?n.not={}:(i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),n.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)n.not={};else if(i.length===1)n.type=i[0]===null?"null":typeof i[0],n.const=i[0];else if(i.length>1){for(let o of["number","string","boolean"])i.every(a=>typeof a===o)&&(n.type=o);i.every(o=>o===null)&&(n.type="null"),n.enum=i}return}case"template_literal":n.type="string",n.pattern=e._zod.pattern.source;return;case"file":{n.type="string",n.format="binary",n.contentEncoding="binary";let{minimum:i,maximum:o,mime:a}=I(e);i!==void 0&&(n.minLength=i),o!==void 0&&(n.maxLength=o),a&&(a.length===0?n.not={}:a.length===1?n.contentMediaType=a[0]:n.anyOf=a.map(d=>({contentMediaType:d})));return}case"array":{let{minimum:i,maximum:o}=I(e);typeof i=="number"&&(n.minItems=i),typeof o=="number"&&(n.maxItems=o),n.type="array",n.items=this.write(r.element);return}case"object":{let i=r.shape;n.type="object";let o={};n.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=>L(i[d])===void 0);a.length>0&&(n.required=a),r.catchall?._zod.def.type==="never"?n.additionalProperties=!1:r.catchall&&(n.additionalProperties=this.write(r.catchall));return}case"union":n[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);n.allOf=[...i(o)?o.allOf:[o],...i(a)?a.allOf:[a]];return}case"tuple":{let i=r.items;n.type="array",n.prefixItems=i.map(s=>this.write(s)),r.rest?n.items=this.write(r.rest):n.items=!1;let o=i.length;for(;o>0&&L(i[o-1])!==void 0;)o-=1;o>0&&(n.minItems=o),r.rest||(n.maxItems=i.length);let{minimum:a,maximum:d}=I(e);typeof a=="number"&&(n.minItems=a),typeof d=="number"&&(n.maxItems=d);return}case"record":{let i=r.keyType;n.type="object";let o=I(i).patterns;if(r.mode==="loose"&&o&&o.size>0){let d=this.write(r.valueType),s={};for(let y of o)s[y.source]=d;n.patternProperties=s}else n.propertyNames=Ve(this.write(i)),n.additionalProperties=this.write(r.valueType);let a=i._zod.values;if(a&&!r.partial&&L(r.valueType)===void 0){let d=[...a].filter(s=>typeof s=="string"||typeof s=="number");d.length>0&&(n.required=d.map(String))}return}case"nullable":n.anyOf=[this.write(r.innerType),{type:"null"}];return;case"default":case"prefault":{let i=r.defaultValue,o,a=!1,d=JSON.stringify(i,(s,y)=>typeof y=="bigint"?(a=!0,null):y);return!a&&d!==void 0&&(o=JSON.parse(d)),a||(n[r.type==="default"?"default":"_prefault"]=o),r.innerType}case"catch":{try{n.default=r.catchValue(void 0)}catch{}return r.innerType}case"readonly":return n.readOnly=!0,r.innerType;case"pipe":return r.in._zod.traits.has("$ZodTransform")?r.out:r.in;case"lazy":return e._zod.innerType;case"optional":case"nonoptional":case"promise":return r.innerType;default:return}}};function Ge(t,e=()=>{}){let n=t,r=new B(e,new Map),i=r.write(n,!0);if(r.cyclic.size>0){let o=new Map,a=0,d=[];for(let y of r.cyclic.keys())if(y===n)o.set(y,"#");else{let p=`__schema${a++}`;o.set(y,`#/$defs/${p}`),d.push([y,p])}r=new B(e,o),i=r.write(n,!0);let s={};for(let[y,p]of d)s[p]=r.write(y,!0);d.length>0&&(i={...i,$defs:s})}return JSON.parse(JSON.stringify({$schema:"https://json-schema.org/draft/2020-12/schema",...i}))}function Ke(t){return Ge(t,mn)}var fn={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string"},pn={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 mn(t){me(t.zodSchema)&&(t.jsonSchema["x-graview-app-link"]=!0);let e=ye(t.zodSchema);if(e&&(t.jsonSchema.type==="string"||t.jsonSchema.type==="array")){t.jsonSchema["x-graview-linked"]={address:e.address,kinds:[...e.kinds],cardinality:e.cardinality};let s=e.kinds.join(" or "),y=`${e.cardinality==="many"?"Records":"A record"}: a ${s} in the app ${e.address}, as "${e.kinds[0]}:<id>" \u2014 an id found there with find_linked. Linking never changes that app.`,p=t.jsonSchema.description;typeof p=="string"&&p.includes(y)||(t.jsonSchema.description=`${typeof p=="string"&&p?`${p.replace(/\.?$/,".")} `:""}${y}`)}if(we(t.zodSchema)&&(t.jsonSchema["x-graview-repeat"]=!0,!t.jsonSchema.type&&!t.jsonSchema.anyOf&&!t.jsonSchema.oneOf&&Object.assign(t.jsonSchema,hn())),Se(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 n=Te(t.zodSchema);if(n){let s=t.jsonSchema;s["x-graview-type"]=n,n==="duration"&&(s["x-graview-unit"]="minutes"),s.description??=pn[n]}let r=Re(t.zodSchema,!1);if(r){let s=De(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 y=t.jsonSchema.description;t.jsonSchema.description=typeof y=="string"&&y.length>0?`${y} ${Y(s)}`:Y(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=fn[i.format]??i.format,a.length===1?o.pattern=a[0]:a.length>1&&(o.allOf=a.map(s=>({pattern:s})))}function ne(t,e){let n=C(t.input),r=Ke(t.input);if(e&&r.properties){let o=a=>e.includes(a)?e.indexOf(a):e.length;r.properties=Object.fromEntries(Object.entries(r.properties).sort(([a],[d])=>o(a)-o(d)))}let i=r.properties??{};if(Ae(t)){let o=t.creates.join(" | ");i.id={type:"string",minLength:1,description:`Optional: the id for the ${o} this makes. Refused if the graph already has it; left out, one is minted from the label.`},r.properties=i}Oe(t)&&(r.additionalProperties=!1);for(let o of n){let a=i[o.name];if(!a)continue;let d=o.kinds.includes("*")?"any node kind":o.kinds.join(" | ");a.description=[a.description,`Id of a node (${d}).`].filter(Boolean).join(" ")}return{name:t.name,...t.title===void 0?{}:{title:t.title},description:t.description??t.title??t.name,inputSchema:r,nodeRefs:n}}function hn(){let t={type:"string",pattern:"^\\d{4}-\\d{2}-\\d{2}$"},e=(n,r)=>({type:"integer",minimum:n,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:[...be]},interval:e(1,99),on:{type:"array",minItems:1,maxItems:31,items:{anyOf:[{type:"string",enum:[...ge]},e(-1,31)]}},until:t,count:e(1,1e3),except:{type:"array",maxItems:500,items:t},continues:{type:"string",maxLength:200}},required:["every"],additionalProperties:!1}}function Ze(t){let e=new Set;for(let n=t;n;n=n.onBehalfOf)n.id!==void 0&&e.add(`${n.kind}:${n.id}`);return e}function U(t,e){let n=Ze(e),r=p=>{if(p.kind==="rule")return!1;let b=Ze(p);if(b.size===0)return!1;for(let f of b)if(n.has(f))return!1;return!0},i,o=()=>{if(i)return i;i=new Map;for(let p of t.log.live()){if(p.undoes!==void 0)continue;let b=r(p.author)?p.author:void 0;for(let f of p.primitives){f.op==="remove-node"&&i.delete(f.node.id);let S=f.op==="add-node"?f.node.id:f.op==="patch-node"||f.op==="splice-text"?f.id:void 0;if(S===void 0)continue;let T=f.op==="add-node"?Object.keys(f.node):f.op==="splice-text"?[f.field]:Object.keys(f.after),O=i.get(S);(f.op==="add-node"||!O)&&i.set(S,O=new Map);for(let v of T)v==="id"||v==="kind"||(b?O.set(v,b):O.delete(v))}}return i},a=t.schema,d=new Map,s=(p,b)=>{let f=`${p}\0${b}`,S=d.get(f);if(S===void 0){let T=a.tryDefinition(p)?.fields?.shape;S=T!==void 0&&b in T&&Pe(T[b]).type==="text",d.set(f,S)}return S},y=p=>t.graph.getNode(p)?.kind;return{prose:s,say:p=>W(p,{graph:t.graph,schema:a}),fieldBy(p,b){let f=y(p);if(!(f===void 0||!s(f,b)))return o().get(p)?.get(b)},recordBy(p){let b=y(p),f=o().get(p);if(b===void 0||!f)return;let S;for(let[T,O]of f)s(b,T)&&(S=O);return S}}}var te=(t,e,n)=>({untrusted:!0,authoredBy:n.say(e),text:t}),yn="the host's ranker";function Ye(t,e){return{...t,hits:t.hits.map(n=>{if(n.about!=="node")return n;n.why.by==="meaning"&&n.why.matched!==void 0&&(n={...n,why:{...n.why,matched:{untrusted:!0,authoredBy:yn,text:n.why.matched}}});let r=e.recordBy(n.id);if(!r)return n;let i=e.prose(n.kind,n.why.field)?e.fieldBy(n.id,n.why.field):r;return{...n,label:te(n.label,r,e),...n.apart!==void 0?{apart:te(n.apart,r,e)}:{},why:i?{...n.why,fragment:te(n.why.fragment,i,e)}:n.why}})}}var ie=(t,e,n)=>({title:t,readOnlyHint:e,destructiveHint:!1,idempotentHint:n,openWorldHint:!1}),gn={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:ie("Notify me when something happens",!1,!1)},bn={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:ie("Stop notifying me",!1,!0)},wn={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:ie("What I am notified of",!0,!0)},re=[gn,bn,wn];var F=t=>{let e;return()=>e??=t().catch(n=>{throw e=void 0,n})},Sn=F(()=>(__graviewPreload(import.meta.url,["./chunk.CANTHIRO.js","./chunk.CSA6SWTI.js","./chunk.IYVBJDR7.js","./chunk.VTCPA4V4.js","./chunk.FGJM4LJO.js","./chunk.K7WME4P4.js","./chunk.MDIAWTNK.js","./chunk.PEA4D66Y.js","./chunk.TRPPN2GD.js","./chunk.S2ATSY6P.js","./chunk.72Q4R7N6.js","./chunk.6W2DUW5S.js","./chunk.SLBWPVIY.js","./chunk.AJZBJBMO.js"]),import("./chunk.HE545Z6I.js"))),kn=()=>(__graviewPreload(import.meta.url,["./chunk.TXEWSZGO.js","./chunk.MDIAWTNK.js","./chunk.PEA4D66Y.js","./chunk.TRPPN2GD.js","./chunk.6W2DUW5S.js","./chunk.SLBWPVIY.js","./chunk.AJZBJBMO.js"]),import("./chunk.65F3DF5Q.js")).catch(()=>{}),vn=async()=>{(await kn())?.judgeWithLines()},q=F(()=>(__graviewPreload(import.meta.url,["./chunk.WVUJXDXZ.js","./chunk.VTCPA4V4.js","./chunk.FGJM4LJO.js","./chunk.K7WME4P4.js","./chunk.MDIAWTNK.js","./chunk.PEA4D66Y.js","./chunk.TRPPN2GD.js","./chunk.72Q4R7N6.js","./chunk.6W2DUW5S.js","./chunk.SLBWPVIY.js","./chunk.AJZBJBMO.js"]),import("./chunk.JCJ7NTW4.js"))),An=F(()=>(__graviewPreload(import.meta.url,["./chunk.7R6GXJS4.js","./chunk.G4JJXA63.js","./chunk.MSPRCR3Q.js","./chunk.CSA6SWTI.js","./chunk.3FUFVVR4.js","./chunk.XOZU4OFA.js","./chunk.IYVBJDR7.js","./chunk.Q5WEOX3Q.js","./chunk.P2W727C7.js","./chunk.XXCT6DLX.js","./chunk.TXEWSZGO.js","./chunk.WVUJXDXZ.js","./chunk.VTCPA4V4.js","./chunk.FGJM4LJO.js","./chunk.K7WME4P4.js","./chunk.MDIAWTNK.js","./chunk.PEA4D66Y.js","./chunk.TRPPN2GD.js","./chunk.MT45H2T5.js","./chunk.S2ATSY6P.js","./chunk.72Q4R7N6.js","./chunk.6W2DUW5S.js","./chunk.SLBWPVIY.js","./chunk.AJZBJBMO.js"]),import("./chunk.4QVZXCV5.js"))),On=F(()=>(__graviewPreload(import.meta.url,["./chunk.GZBODS7Z.js","./chunk.CANTHIRO.js","./chunk.CSA6SWTI.js","./chunk.4DCPB67O.js","./chunk.Y4VOCJ7R.js","./chunk.IYVBJDR7.js","./chunk.VTCPA4V4.js","./chunk.FGJM4LJO.js","./chunk.K7WME4P4.js","./chunk.MDIAWTNK.js","./chunk.PEA4D66Y.js","./chunk.TRPPN2GD.js","./chunk.MT45H2T5.js","./chunk.S2ATSY6P.js","./chunk.72Q4R7N6.js","./chunk.6W2DUW5S.js","./chunk.SLBWPVIY.js","./chunk.AJZBJBMO.js"]),import("./chunk.MXTDQXVW.js"))),Rn=F(()=>(__graviewPreload(import.meta.url,["./chunk.RIS3OKAI.js","./chunk.DUZS52WX.js","./chunk.MDIAWTNK.js","./chunk.PEA4D66Y.js","./chunk.TRPPN2GD.js","./chunk.6W2DUW5S.js","./chunk.SLBWPVIY.js","./chunk.AJZBJBMO.js"]),import("./chunk.XDEKL6TJ.js"))),Tn=t=>t.definitions.some(e=>Z(e).size>0),Xe=t=>({value:K(t),label:t.label,...t.describe?{describe:t.describe}:{},...t.card?{card:t.card}:{},fields:t.fields,...t.app?{app:t.app}:{}});async function _n(t,e,n,r){let i=String(n.relation??""),[o,a]=i.includes(".")?i.split(".",2):[void 0,i],d=t.schema.definitions.flatMap(v=>[...Z(v)].map(([h,u])=>({kind:v.kind,name:h,relation:u}))),s=d.filter(v=>v.name===a&&(o===void 0||v.kind===o));if(s.length!==1){let v=d.map(h=>`${h.kind}.${h.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: ${v}.`}}let{kind:y,name:p,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 f={kind:e.kind,...e.id===void 0?{}:{id:e.id},...e.roles?{roles:e.roles}:{}},S=typeof n.of=="string"?n.of:void 0;if(S!==void 0){let v=t.graph.getNode(S);if(!v||v.kind!==y)return{ok:!1,error:`No ${y} "${S}".`};let h=he(v[p],b),u=await Promise.all(h.map(w=>Promise.resolve().then(()=>r.resolve(w,f)).catch(()=>null)));return{ok:!0,data:{relation:`${y}.${p}`,app:b.address,records:u.map((w,k)=>w===null?{value:K(h[k]),missing:!0}:"denied"in w?{denied:!0,said:"linked record (no access)"}:Xe(w))},reads:[S]}}let T=typeof n.limit=="number"&&n.limit>0?Math.min(n.limit,20):20,O=await Promise.resolve().then(()=>r.find({address:b.address,kinds:b.kinds,query:String(n.query??""),limit:T},f)).catch(()=>[]);return Array.isArray(O)?{ok:!0,data:{relation:`${y}.${p}`,app:b.address,records:O.map(Xe),link:`edit-${y} with ${p} set to a record's value`}}:{ok:!0,data:{relation:`${y}.${p}`,app:b.address,denied:!0,said:"linked record (no access)"}}}var M=t=>({title:t,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}),Qe={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"]}]},oe={type:"number",description:"Where the page starts; 0 when unsaid."},se=[{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:Qe},required:["query"],additionalProperties:!1},mutating:!1,annotations:M("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:oe,archived:Qe},additionalProperties:!1},mutating:!1,annotations:M("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:oe},required:["id"],additionalProperties:!1},mutating:!1,annotations:M("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:oe,context:{type:"object",description:"Evaluation context, e.g. { weekStart }."}},additionalProperties:!1},mutating:!1,annotations:M("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:M("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, the forms it offers (each field in the order asked, its label, whether it must be answered, what it takes and its choices), 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"), a record's id, or a visitor form's "forms/<name>", 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, a record's id, or "forms/<name>" for a visitor form.`},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:M("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:M("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:M("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}}],nn={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}},ue={name:"suggest_changes",title:"Suggest changes",description:"Keep calls ({ act, args }) as one suggestion a person accepts or declines, with its basis and confidence (0 to 1). Changes nothing; a declined change is refused.",inputSchema:{type:"object",properties:{calls:{type:"array",items:{type:"object"}},basis:{type:"string"},confidence:{type:"number"}},required:["calls","basis"]},mutating:!0,annotations:{title:"Suggest changes",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},de={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"]},ce={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:de,current:de},additionalProperties:!1},mutating:!1,annotations:M("Draw a view")},tn={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:{...de,additionalProperties:!1},mutating:!0,annotations:{title:"Keep a view as a lens",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},rn={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:M("Find a record in another app")};function xn(t,e){return t===void 0?[]:t==="keep"&&!e?[ce,tn]:[ce]}var Mn="An argument that names a record takes its id or its name.",on=[...se.map(t=>t.name),nn.name,ue.name,ce.name,tn.name,rn.name,...re.map(t=>t.name)],an=64;function N(t){let{line:e,...n}=t;return n}function en(t){return{...t,...t.introduces?{introduces:t.introduces.map(N)}:{},...t.resolves?{resolves:t.resolves.map(N)}:{},...t.violationsAfter?{violationsAfter:t.violationsAfter.map(N)}:{}}}function Nn(t){let e=t.normalize("NFKD").replace(/\p{M}/gu,"").replace(/[^A-Za-z0-9_-]/g,"_");return e.length===0&&(e="act"),/^[A-Za-z_]/.test(e)||(e=`act_${e}`),e.slice(0,an)}function $n(t){let e=new Set(on),n=new Map;for(let r of t){let i=Nn(r),o=i;for(let a=2;e.has(o);a+=1)o=`${i.slice(0,an-`_${a}`.length)}_${a}`;e.add(o),n.set(r,o)}return n}function Dn(t,e){if(e.size===0)return t;let n=Object.fromEntries(Object.entries(t.properties??{}).filter(([i])=>!e.has(i))),r=(t.required??[]).filter(i=>!e.has(i));return{...t,properties:n,...t.required?{required:r}:{}}}function Pn(t,e,n,r){let i=ne(t,_e(r,t)),o=G(t),a=i.nodeRefs.length>0?`${i.description}${/[.!?]$/.test(i.description)?"":"."} ${Mn}`:i.description;return{name:e,title:o,description:a,inputSchema:Dn(i.inputSchema,n),mutating:!0,annotations:{title:o,readOnlyHint:!1,destructiveHint:t.destructive===!0||(t.severs?.length??0)>0,idempotentHint:t.idempotent===!0,openWorldHint:!1},act:t.name}}function le(t){if(t===null||typeof t!="object")return JSON.stringify(t)??"null";if(Array.isArray(t))return`[${t.map(le).join(",")}]`;let e=t;return`{${Object.keys(e).filter(n=>e[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${le(e[n])}`).join(",")}}`}function Jn(t){return`sha256:${$e(le(t))}`}function En(t,e,n,r,i,o=!1,a=!1,d=!1,s){let y=$n(t.map(f=>f.name)),p=[...xn(r,n),...o?[rn]:[],...a?re:[]];return{definitions:n?[...se.filter(f=>!f.mutating),...p]:[...se,nn,...d?[ue]:[],...p,...t.filter(f=>e.has(f.name)).map(f=>Pn(f,y.get(f.name),i(f),s))],names:y}}function At(t,e={}){let n=e.author??{kind:"agent"},r=t.allMutations(),i=new Set(t.permittedMutations(n).map(h=>h.name)),{definitions:o,names:a}=En(r,i,e.readOnly===!0,e.drafts?e.drafts.keep?"keep":"draw":void 0,h=>X(t.schema,t.policy,n,h),Tn(t.schema),e.subscriptions!==void 0,Ne(n),t.schema),d=Jn(o),s={app:e.app?.brand?.locale,appTimeZone:e.app?.brand?.timeZone},y=h=>pe(s,h),p=h=>{if(!on.includes(h)){for(let[u,w]of a)if(w===h)return u;return a.has(h)?h:xe(h,a.keys())}},b=h=>{let u=Me(h,a.keys());return u?` Did you mean "${u}"?`:""},f=h=>{let u=o.find(k=>k.name===h)??o.find(k=>k.act===h);if(u)return u;let w=p(h);return w===void 0?void 0:o.find(k=>k.act===w)},S=(h,u)=>{let w=r.find(c=>c.name===h);if(!w)return{args:u,resolved:[]};let k={...u},l=[];for(let c of C(w.input)){let m=k[c.name];if(typeof m!="string"||m.trim()==="")continue;let g=t.resolveRef(c,m,n);if(!g.ok){let A=g.reason==="none"?` Nothing was changed. Use search_graph to look it up, then pass its id as ${c.name}.`:" Nothing was changed.";return{ok:!1,error:`${g.message}${A}`,argument:c.name,candidates:g.candidates}}g.by!=="id"&&(k[c.name]=g.id,l.push({argument:c.name,given:m,id:g.id,label:g.label}))}return{args:k,resolved:l}},T=async(h,u)=>{try{await vn();let w=f(h);if(!w&&h===ue.name)return{ok:!1,error:"Only the app's own actor (automated: true) suggests changes.",reason:"forbidden"};if(!w){let l=p(h);if(l){let c=t.permits({name:l,args:u},n);if(!c.ok)return{ok:!1,error:c.refusal.message,reason:"forbidden"}}return{ok:!1,error:`Unknown tool "${h}".${b(h)} Available: ${o.map(c=>c.name).join(", ")}`}}if(w.mutating&&e.readOnly)return{ok:!1,error:`"${h}" changes the graph, and this seat is read-only.`,reason:"forbidden"};if(w.act!==void 0){let l=S(w.act,u);if("ok"in l)return l;let c=w.act,m=y(()=>j(t,n,t.apply({name:c,args:l.args},{...e.author?{author:e.author}:{},...V(e.via)})));return{ok:!0,data:{batch:m.batch,intent:m.intent,introduces:m.introduces.map(N),resolves:m.resolves.map(N),...l.resolved.length>0?{resolved:l.resolved}:{}},diff:m.diff}}let k=t.seenBy(n);switch(w.name){case"search_graph":{let l=typeof e.places=="function"?e.places():e.places,c=typeof u.subject=="string"?u.subject:void 0,m=He(k,String(u.query??""),{principal:n,rank:e.near,archived:ke(u.archived),limit:typeof u.limit=="number"&&u.limit>0?Math.min(u.limit,20):20,...l?{places:l}:{},...c?{subject:c,from:[c]}:{}}),g=m.later?await m.later:m;return{ok:!0,data:(await q()).searchRead(g,Ye(g,U(k,n))),reads:g.hits.flatMap(A=>A.about==="node"?[A.id]:[])}}case"get_graph":return{ok:!0,...(await q()).graphRead(k,U(k,n),u)};case"get_node":{let l=String(u.id??""),c=l,m;if(!k.graph.getNode(l)){let A=l.trim()===""?void 0:t.resolveRef({name:"id",kinds:["*"]},l,n);if(A?.ok)c=A.id,m={argument:"id",given:l,id:c,label:A.label};else return A?.reason==="ambiguous"?{ok:!1,error:A.message,argument:"id",candidates:A.candidates}:{ok:!1,error:`No node "${l}".`}}let g=(await q()).nodeRead(k,U(k,n),c,u);return{ok:!0,data:m?{...g.data,resolved:[m]}:g.data,reads:g.reads}}case"describe_place":{let l=e.app??{name:"",schema:t.schema},c=typeof u.width=="number"&&Number.isFinite(u.width)&&u.width>0?u.width:1440,{describePlace:m}=await Sn(),g=m(t,n,String(u.place??""),{app:l,width:c});if(!g.ok)return{ok:!1,error:`${g.error} The places are: ${g.places.join(", ")}.`};let A=new Set,$=H=>{for(let P of H)for(let x of P.groups??[])for(let D of x.items)A.add(D.id),$(D.parts)};return $(g.description.parts),{ok:!0,data:g.description,reads:[...A]}}case"find_linked":return _n(k,n,u,e.linked);case"draft_view":case"keep_lens":{let l=e.app??{name:"",schema:t.schema};return(await An()).runDraftTool(w.name,u,{app:l,principal:n,...e.drafts?{drafts:e.drafts}:{}})}case"get_violations":{let l=k.violations(u.context);return{ok:!0,...(await q()).violationsRead(l,u)}}case"get_affordances":{let l=u.selection??[];return{ok:!0,data:Ie(k,l,{...typeof e.derive=="function"?e.derive():e.derive,...e.author?{principal:e.author}:{},...u.context?{context:u.context}:{}}),reads:l.filter(m=>k.graph.has(m))}}case"preview_mutation":{let l=String(u.mutation),c=p(l)??l,m=S(c,u.args??{});if("ok"in m)return m;let g=t.missingFor({name:c,args:m.args},n);if(g)return{ok:!1,error:g.message,reason:"missing"};let A=j(t,n,t.preview({name:c,args:m.args},void 0,{author:n})),$=en(A);return{ok:!0,data:m.resolved.length>0?{...$,resolved:m.resolved}:$}}case"act_on_several":{let l=String(u.act??""),c=p(l)??l,m=r.find(R=>R.name===c);if(!m||!i.has(c)){let R=m?t.permits({name:c,args:{}},n):void 0;return R&&!R.ok?{ok:!1,error:R.refusal.message,reason:"forbidden"}:{ok:!1,error:`There is no act "${l}" this seat may run.${b(l)} Nothing was changed.`,reason:"invalid"}}let g=m.subject;if(!g)return{ok:!1,error:`"${G(m)}" does not act on a record, so it cannot be run on several. Nothing was changed.`,reason:"invalid"};let A=Array.isArray(u.records)?u.records.filter(R=>typeof R=="string"&&R.trim()!==""):[];if(A.length===0)return{ok:!1,error:"Name at least one record. Nothing was changed.",reason:"invalid"};let $=[],H=[];for(let R of A.slice(0,200)){let J=t.resolveRef({name:g.arg,kinds:g.kinds},R,n);if(!J.ok)return{ok:!1,error:`${J.message} Nothing was changed.`,argument:"records",candidates:J.candidates};$.push(J.id),J.by!=="id"&&H.push({argument:"records",given:R,id:J.id,label:J.label})}let P=S(c,{...u.args??{}});if("ok"in P)return P;let x=(await On()).actOnSeveral(t,{mutation:c,subject:g.arg,args:P.args},$,{author:n,...V(e.via)}),D=x.result?j(t,n,x.result):void 0;return{ok:!0,data:{...x.batch?{batch:x.batch,intent:x.intent}:{},applied:x.applied,unchanged:x.unchanged,refused:x.refused.map(R=>({record:R.id,label:R.label,error:R.message,reason:R.reason})),...x.allOrNothing?{keptNone:!0}:{},...D?{introduces:D.introduces.map(N),resolves:D.resolves.map(N)}:{},...H.length>0||P.resolved.length>0?{resolved:[...H,...P.resolved]}:{}},...D?{diff:D.diff}:{}}}case"subscribe":case"unsubscribe":case"list_subscriptions":{let l=await(await Rn()).runSubscriptionTool(w.name,u,{store:t,principal:e.subscriber??n,app:e.app?.name??"app",subscriptions:e.subscriptions});return l.ok?{ok:!0,data:l.data}:{ok:!1,error:l.error}}case"list_suggestions":{let l=Ee(t,n).map(c=>{let m=W(c.author,{graph:k.graph,schema:t.schema});return{id:c.id,intent:c.intent,by:m,at:c.at,about:c.about,...c.lineage?{basis:{untrusted:!0,authoredBy:m,text:c.lineage.basis},...c.lineage.confidence!==void 0?{confidence:c.lineage.confidence}:{}}:{}}});return{ok:!0,data:{suggestions:l},reads:[...new Set(l.flatMap(c=>c.about))]}}case"suggest_changes":{let l=u.calls.map(m=>({name:p(m.act)??m.act,args:m.args}));return{ok:!0,data:{suggestion:Je(t,l,{author:n,lineage:{basis:u.basis,confidence:u.confidence},...V(e.via)})?.id??null}}}case"accept_suggestion":case"decline_suggestion":{let l=String(u.suggestion??""),c={author:n,...V(e.via)},m=w.name==="accept_suggestion"?ze(t,l,c):je(t,l,c),g=j(t,n,m);return{ok:!0,data:{batch:g.batch,intent:g.intent,introduces:g.introduces.map(N),resolves:g.resolves.map(N)},diff:g.diff}}case"undo_batch":{let l=String(u.batch),c=u.include??[],m=k.canUndo([l,...c]);if(!m.ok)return{ok:!1,error:m.message};let g=j(t,n,t.undo([l,...c],{...e.author?{author:e.author}:{}}));return{ok:!0,data:en(g),diff:g.diff}}default:return{ok:!1,error:`Unknown tool "${h}".`}}}catch(w){let{reason:k,wouldNeed:l}=ve(w);return{ok:!1,error:w instanceof Error?w.message:String(w),reason:k,...l?{wouldNeed:l}:{}}}},O=new Set,v=h=>{for(let u of O)u(h)};return{definitions:o,hash:d,...e.author?{author:e.author}:{},onDiff(h){return t.subscribe(h)},onCall(h){return O.add(h),()=>O.delete(h)},async call(h,u){let w=f(h)?.mutating??!1,k={name:h,args:u,mutating:w,at:new Date().toISOString()};v({...k,phase:"running"});let l=m=>(v(m.ok?{...k,phase:"ok",...!w&&m.reads?{reads:m.reads}:{}}:{...k,phase:"failed",error:m.error}),m),c=await T(h,u);return l(c.ok&&!w?{...c,data:(await q()).withinReadChars(h,c.data)}:c)}}}function V(t){let e=typeof t=="function"?t():t;return e?{via:e}:{}}export{le as a,At as b};
|