graview 0.1.68 → 0.1.69
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.ODYJEDIW.js → chunk.26RYER7Y.js} +1 -1
- package/dist/preview/{chunk.TRNJKHIA.js → chunk.2AL26ZPJ.js} +1 -1
- package/dist/preview/chunk.2WFOKJB4.js +1 -0
- package/dist/preview/chunk.3D37E2G5.js +1 -0
- package/dist/preview/chunk.3PT3BU6K.js +1 -0
- package/dist/preview/{chunk.7ZTGB4O7.js → chunk.3TKIZGC7.js} +1 -1
- package/dist/preview/{chunk.AQ2PI6MR.js → chunk.3VNOTHA5.js} +1 -1
- package/dist/preview/{chunk.QWLK3GKG.js → chunk.3XTIYX6M.js} +1 -1
- package/dist/preview/{chunk.GF3ZCX46.js → chunk.447RWLS7.js} +2 -2
- package/dist/preview/{chunk.E423JCOS.js → chunk.47VEV4BX.js} +1 -1
- package/dist/preview/{chunk.NRCWMYLH.js → chunk.4FJ4OPSJ.js} +1 -1
- package/dist/preview/{chunk.XFH6GHBQ.js → chunk.4O7WYLCK.js} +1 -1
- package/dist/preview/{chunk.MSUZAJ2K.js → chunk.4R7H3GIL.js} +2 -2
- package/dist/preview/{chunk.EB7PZJEO.js → chunk.4RPKCW4J.js} +1 -1
- package/dist/preview/{chunk.YM6SWEUI.js → chunk.523EFGHU.js} +1 -1
- package/dist/preview/chunk.5DU6FA5R.js +1 -0
- package/dist/preview/{chunk.LFFJB6D3.js → chunk.5MOXQUZH.js} +1 -1
- package/dist/preview/chunk.5TWRTGP6.js +1 -0
- package/dist/preview/{chunk.AWV57UBJ.js → chunk.66TRDXYR.js} +1 -1
- package/dist/preview/{chunk.AYZL3LCR.js → chunk.6BNSDPZE.js} +3 -3
- package/dist/preview/chunk.6BR2SUAE.js +1 -0
- package/dist/preview/{chunk.32JE2WS7.js → chunk.6TDVNWFU.js} +1 -1
- package/dist/preview/{chunk.UAMPR4MD.js → chunk.6XBQDXT6.js} +1 -1
- package/dist/preview/{chunk.TVWK3SGD.js → chunk.6ZFYFT5A.js} +1 -1
- package/dist/preview/{chunk.N5Z34V7U.js → chunk.7L3I776Z.js} +1 -1
- package/dist/preview/chunk.7OLKVOS6.js +1 -0
- package/dist/preview/{chunk.MKL4THIV.js → chunk.7T2P42VW.js} +1 -1
- package/dist/preview/{chunk.QM54TGU6.js → chunk.AG7WJYM5.js} +2 -2
- package/dist/preview/{chunk.ECNGVD25.js → chunk.AHYMIVBX.js} +1 -1
- package/dist/preview/chunk.AMAOZVEO.js +1 -0
- package/dist/preview/chunk.AMV2ILR6.js +1 -0
- package/dist/preview/{chunk.RQG672MJ.js → chunk.AUNQNTKY.js} +1 -1
- package/dist/preview/{chunk.HXTKBISQ.js → chunk.AZRICZKT.js} +1 -1
- package/dist/preview/{chunk.L7XKYGV7.js → chunk.B422DSYN.js} +1 -1
- package/dist/preview/{chunk.XDZDNZ7B.js → chunk.B5EFNTDA.js} +1 -1
- package/dist/preview/{chunk.F5GNNVSQ.js → chunk.BO32A3W5.js} +1 -1
- package/dist/preview/{chunk.ZLEBOR5T.js → chunk.BQORHDAH.js} +1 -1
- package/dist/preview/{chunk.4GVKKBQL.js → chunk.BSQI3KM2.js} +1 -1
- package/dist/preview/{chunk.BPNW5KCP.js → chunk.C6CT6F4C.js} +1 -1
- package/dist/preview/{chunk.JV432T4Q.js → chunk.CA2SYEYE.js} +1 -1
- package/dist/preview/{chunk.64LCHHZB.js → chunk.CCCONK73.js} +1 -1
- package/dist/preview/{chunk.GONZB3J3.js → chunk.CDSHUWSK.js} +1 -1
- package/dist/preview/{chunk.NFTPJAMJ.js → chunk.CKSRW3LA.js} +1 -1
- package/dist/preview/{chunk.LOKGUALC.js → chunk.CLIC2QBA.js} +1 -1
- package/dist/preview/{chunk.PLIV3IQK.js → chunk.CLZYNFFH.js} +1 -1
- package/dist/preview/{chunk.GKTQ5CZA.js → chunk.CSVDBDRZ.js} +2 -2
- package/dist/preview/{chunk.GJTEV6CK.js → chunk.CUEIGKFG.js} +1 -1
- package/dist/preview/{chunk.IPGLITWA.js → chunk.CYEPHT7V.js} +1 -1
- package/dist/preview/{chunk.BQAFFEOA.js → chunk.D3SWJ7OS.js} +1 -1
- package/dist/preview/{chunk.ACNOP2IU.js → chunk.D5JZQZ74.js} +1 -1
- package/dist/preview/{chunk.6AANHELP.js → chunk.DHPXRDT5.js} +5 -5
- package/dist/preview/{chunk.R3GE37OI.js → chunk.DKUEZPGR.js} +1 -1
- package/dist/preview/{chunk.2TUEBU7X.js → chunk.DO3FQM6R.js} +1 -1
- package/dist/preview/{chunk.G2BDEWJC.js → chunk.DRAPVGQZ.js} +1 -1
- package/dist/preview/{chunk.6WB2TYK7.js → chunk.DU76ASS4.js} +1 -1
- package/dist/preview/{chunk.AENP662H.js → chunk.EEUCRZA3.js} +1 -1
- package/dist/preview/{chunk.WC5WE34A.js → chunk.EK3JXEZL.js} +1 -1
- package/dist/preview/{chunk.2BMZPALF.js → chunk.EL7XXGQY.js} +1 -1
- package/dist/preview/{chunk.2KCDLCB2.js → chunk.EP7YT7LT.js} +1 -1
- package/dist/preview/{chunk.SS6KL5NT.js → chunk.EQZPEOIW.js} +1 -1
- package/dist/preview/{chunk.VW632VNJ.js → chunk.F4CDJBDS.js} +1 -1
- package/dist/preview/{chunk.O5FTWXA2.js → chunk.FE3SINPK.js} +1 -1
- package/dist/preview/{chunk.JULD4XFB.js → chunk.FIY4RUK5.js} +1 -1
- package/dist/preview/{chunk.3VEZ5MOC.js → chunk.FWXW4T4I.js} +1 -1
- package/dist/preview/{chunk.FSW535EA.js → chunk.G43YUGNW.js} +1 -1
- package/dist/preview/{chunk.QYPU444Y.js → chunk.GF5CZPZ7.js} +1 -1
- package/dist/preview/{chunk.4TT3ZHSJ.js → chunk.GPBHUIZQ.js} +1 -1
- package/dist/preview/{chunk.YL2RBZFE.js → chunk.GTF6EMVE.js} +1 -1
- package/dist/preview/chunk.GVFGS2HY.js +1 -0
- package/dist/preview/{chunk.EGSOHTZZ.js → chunk.HCX6KPRF.js} +1 -1
- package/dist/preview/{chunk.4YAO3A5Q.js → chunk.HGH27XZG.js} +3 -3
- package/dist/preview/{chunk.7WPVLEX2.js → chunk.HMJXB6KC.js} +2 -2
- package/dist/preview/chunk.HTEQCRVP.js +1 -0
- package/dist/preview/{chunk.VTDOWXCP.js → chunk.HU3KEWFO.js} +1 -1
- package/dist/preview/{chunk.DZ6UDZOB.js → chunk.I4H2GS4O.js} +2 -2
- package/dist/preview/{chunk.UD7VLXPM.js → chunk.I7KN732Z.js} +1 -1
- package/dist/preview/{chunk.YBQ5GVAX.js → chunk.I7OFRF6N.js} +2 -2
- package/dist/preview/{chunk.ZKXIZBCN.js → chunk.IAVIYJTL.js} +1 -1
- package/dist/preview/{chunk.CNN32262.js → chunk.IO5VFTXC.js} +1 -1
- package/dist/preview/{chunk.PIMAG4WT.js → chunk.IPKESOIU.js} +2 -2
- package/dist/preview/{chunk.42KHFGN6.js → chunk.IRNEWNUB.js} +1 -1
- package/dist/preview/{chunk.XRE7SHLD.js → chunk.ISZFRLNJ.js} +1 -1
- package/dist/preview/{chunk.GRTBEA7O.js → chunk.IY3DV52G.js} +1 -1
- package/dist/preview/{chunk.VES4XMZX.js → chunk.IYHY4VEC.js} +1 -1
- package/dist/preview/{chunk.HWFJQ42Y.js → chunk.J2N7EKMX.js} +1 -1
- package/dist/preview/{chunk.IT5DVKXY.js → chunk.J7O23NKZ.js} +2 -2
- package/dist/preview/chunk.JDUA5PH2.js +1 -0
- package/dist/preview/{chunk.DCLF4WWZ.js → chunk.JHAMSDAI.js} +1 -1
- package/dist/preview/{chunk.IKKKHHRN.js → chunk.JN3WZGJY.js} +1 -1
- package/dist/preview/{chunk.H4VNIAHN.js → chunk.JPAE6K4E.js} +1 -1
- package/dist/preview/{chunk.DGDW54KE.js → chunk.JQEXH23N.js} +1 -1
- package/dist/preview/{chunk.MPWLDQOG.js → chunk.KEGL6NBD.js} +1 -1
- package/dist/preview/{chunk.EGVM24ND.js → chunk.KHKCTVHD.js} +1 -1
- package/dist/preview/{chunk.VV5JAM5W.js → chunk.KKFKSJUN.js} +1 -1
- package/dist/preview/{chunk.Q6H5HESF.js → chunk.KLEKC4ZX.js} +1 -1
- package/dist/preview/chunk.KVQYOFDV.js +1 -0
- package/dist/preview/{chunk.ZLNUZ6LR.js → chunk.KW7PHJYX.js} +1 -1
- package/dist/preview/{chunk.PPCDPYYU.js → chunk.LAVLPYSC.js} +1 -1
- package/dist/preview/{chunk.FZELUSK5.js → chunk.LGNGFG5V.js} +1 -1
- package/dist/preview/{chunk.SADR3MQI.js → chunk.LKM2R5UF.js} +1 -1
- package/dist/preview/{chunk.42C3FIKK.js → chunk.LMZ2WMGH.js} +1 -1
- package/dist/preview/{chunk.KAM73WVF.js → chunk.MATUPDZ3.js} +1 -1
- package/dist/preview/{chunk.Z2X7BFCB.js → chunk.MD3N26BC.js} +2 -2
- package/dist/preview/{chunk.TFJA4QV4.js → chunk.MH3AQO2R.js} +1 -1
- package/dist/preview/chunk.MHHNO3O2.js +1 -0
- package/dist/preview/{chunk.DMZRFXH7.js → chunk.MKN7ADJB.js} +1 -1
- package/dist/preview/{chunk.ND3DEDWB.js → chunk.ML5EHDZG.js} +1 -1
- package/dist/preview/{chunk.Q4VFLLUT.js → chunk.MUWI54IP.js} +1 -1
- package/dist/preview/{chunk.PZQ5P6WK.js → chunk.MV27WMNW.js} +1 -1
- package/dist/preview/{chunk.6DMCEBSO.js → chunk.N7A3T5QU.js} +1 -1
- package/dist/preview/{chunk.H3IGXHZR.js → chunk.NLZHNPDU.js} +2 -2
- package/dist/preview/{chunk.4DXPPM6T.js → chunk.NRECR3NQ.js} +1 -1
- package/dist/preview/{chunk.LZ6MSQ5O.js → chunk.NSAGOOJW.js} +1 -1
- package/dist/preview/{chunk.LMTG5NPG.js → chunk.O7NYSO6F.js} +1 -1
- package/dist/preview/{chunk.2ME4DVBI.js → chunk.OD5QZHRC.js} +1 -1
- package/dist/preview/{chunk.QUETLFBJ.js → chunk.P26ATAAI.js} +1 -1
- package/dist/preview/{chunk.3JMQKANL.js → chunk.PJL3I2IW.js} +1 -1
- package/dist/preview/{chunk.6IR5LBJU.js → chunk.POKGLN4T.js} +1 -1
- package/dist/preview/{chunk.IXMIU4D4.js → chunk.PZ3KM3TY.js} +1 -1
- package/dist/preview/{chunk.MIOLBZBS.js → chunk.QEBD7SC4.js} +1 -1
- package/dist/preview/{chunk.DPHH5ZVL.js → chunk.QK7EUIPL.js} +1 -1
- package/dist/preview/{chunk.7TDML5YU.js → chunk.QNC2OKLF.js} +1 -1
- package/dist/preview/{chunk.QOQ26NXM.js → chunk.QRNKGPAD.js} +1 -1
- package/dist/preview/{chunk.QZP3ARLH.js → chunk.QVCKTDG3.js} +1 -1
- package/dist/preview/{chunk.2U6HB4XU.js → chunk.R7POSVUK.js} +1 -1
- package/dist/preview/{chunk.UFURYU4R.js → chunk.RNAL35ID.js} +1 -1
- package/dist/preview/{chunk.KUCBNMIY.js → chunk.ROYCJXPE.js} +1 -1
- package/dist/preview/chunk.RZ73YG5K.js +1 -0
- package/dist/preview/{chunk.JLDJZET2.js → chunk.S2NQRD6W.js} +1 -1
- package/dist/preview/{chunk.O32F6LGK.js → chunk.SAWASNDO.js} +1 -1
- package/dist/preview/{chunk.CFE3MHWZ.js → chunk.SCVKHGO3.js} +1 -1
- package/dist/preview/chunk.SM37MNS2.js +1 -0
- package/dist/preview/{chunk.DLSS56EU.js → chunk.T2BZBR7S.js} +1 -1
- package/dist/preview/{chunk.OQ4ZO3YY.js → chunk.T3PELB6I.js} +1 -1
- package/dist/preview/{chunk.TR4YFVZN.js → chunk.TAJBXG5U.js} +1 -1
- package/dist/preview/{chunk.3DEWQDP7.js → chunk.TLPCYKLW.js} +1 -1
- package/dist/preview/{chunk.7K2V5FUB.js → chunk.TQQDUJLX.js} +1 -1
- package/dist/preview/{chunk.CGBOPPNL.js → chunk.TQRC5VAM.js} +1 -1
- package/dist/preview/chunk.U563J5IM.js +1 -0
- package/dist/preview/{chunk.GRBWXTST.js → chunk.UAEOCWSG.js} +1 -1
- package/dist/preview/{chunk.Y7OGJOPA.js → chunk.UHJSZ2XZ.js} +1 -1
- package/dist/preview/{chunk.JGRSUTPJ.js → chunk.UPOYRCKI.js} +1 -1
- package/dist/preview/{chunk.I63462I3.js → chunk.VBBH5R5T.js} +1 -1
- package/dist/preview/chunk.VBYJBW32.js +1 -0
- package/dist/preview/{chunk.HH4D3JEI.js → chunk.VEQIH7HR.js} +1 -1
- package/dist/preview/chunk.VHLL6VC6.js +1 -0
- package/dist/preview/{chunk.VLXLBGMY.js → chunk.VQDL4EEP.js} +1 -1
- package/dist/preview/{chunk.UODTUBQ7.js → chunk.VQOYFBEV.js} +1 -1
- package/dist/preview/{chunk.H3W5C3XQ.js → chunk.VR553M6J.js} +1 -1
- package/dist/preview/{chunk.ENLIIZF2.js → chunk.VXPEXUQF.js} +1 -1
- package/dist/preview/{chunk.Z67LBSQO.js → chunk.W3WXI5B3.js} +1 -1
- package/dist/preview/{chunk.5JKUT2OM.js → chunk.W43XWQRC.js} +1 -1
- package/dist/preview/{chunk.BHJRT57H.js → chunk.WFJCC6G3.js} +1 -1
- package/dist/preview/{chunk.I34BWUB4.js → chunk.WJHLE73Y.js} +1 -1
- package/dist/preview/{chunk.MK5RPEB2.js → chunk.WQ7K5O2I.js} +1 -1
- package/dist/preview/{chunk.EP5JS7ZH.js → chunk.WV6SP6IJ.js} +1 -1
- package/dist/preview/{chunk.XXCHO2A5.js → chunk.YJ4PFOPC.js} +1 -1
- package/dist/preview/{chunk.JCETQQ7J.js → chunk.YZKHTBTC.js} +1 -1
- package/dist/preview/{chunk.CE3NKAF7.js → chunk.ZE5RSKXF.js} +1 -1
- package/dist/preview/{chunk.WV45KLXC.js → chunk.ZQYHNFRZ.js} +1 -1
- package/dist/preview/{chunk.TOUSIUJF.js → chunk.ZT3ZG52B.js} +1 -1
- package/dist/preview/{chunk.O2VXTYUJ.js → chunk.ZU3RPI34.js} +1 -1
- package/dist/preview/index.html +55 -55
- package/dist/preview/page.js +2 -2
- package/package.json +6 -6
- package/dist/preview/chunk.3WPCS6KP.js +0 -1
- package/dist/preview/chunk.5L4ADKTW.js +0 -1
- package/dist/preview/chunk.6ZENHSTQ.js +0 -1
- package/dist/preview/chunk.7OL6H4LF.js +0 -1
- package/dist/preview/chunk.ARS4HJD2.js +0 -1
- package/dist/preview/chunk.C2QKA6XY.js +0 -1
- package/dist/preview/chunk.FHQ25SWY.js +0 -1
- package/dist/preview/chunk.MBTEOF4R.js +0 -1
- package/dist/preview/chunk.N64RVSH3.js +0 -1
- package/dist/preview/chunk.PI4RFOBU.js +0 -1
- package/dist/preview/chunk.Q42R2KW4.js +0 -1
- package/dist/preview/chunk.R66ZVMWB.js +0 -1
- package/dist/preview/chunk.RYA7A4NA.js +0 -1
- package/dist/preview/chunk.SUG6LIOX.js +0 -1
- package/dist/preview/chunk.U7PAFLUM.js +0 -1
- package/dist/preview/chunk.WN7SAAH6.js +0 -1
- package/dist/preview/chunk.ZMADWPJO.js +0 -1
- package/dist/preview/chunk.ZO6VMEPP.js +0 -1
- package/dist/preview/chunk.ZUG7U7AT.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{r as qe}from"./chunk.SADR3MQI.js";import{d as $e,e as De,h as Je,i as Ee,k as He,l as je,m as ze}from"./chunk.XDZDNZ7B.js";import{a as We}from"./chunk.N5Z34V7U.js";import{e as X}from"./chunk.EP5JS7ZH.js";import{a as j}from"./chunk.EGSOHTZZ.js";import{f as Ie,g as Y,i as Le}from"./chunk.QUETLFBJ.js";import{a as be}from"./chunk.GRTBEA7O.js";import{$b as Re,Ga as me,Ja as K,Jc as xe,Jd as Pe,La as he,Ld as Me,Md as Ne,Na as ye,O as pe,Oa as Z,Ob as ve,Va as ge,Wa as we,Wb as Ae,Xb as Oe,Za as ke,a as fe,cc as _e,eb as F,fc as C,ib as Se,ma as G,nc as Te}from"./chunk.6AANHELP.js";var E=(t,e,n)=>{(t[e]===void 0||n>t[e])&&(t[e]=n)},H=(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)},Fe=(t,e)=>{t.mime=t.mime?t.mime.filter(n=>e.includes(n)):[...e]},Ce=(t,e)=>{t.multipleOf??=[],t.multipleOf.includes(e)||t.multipleOf.push(e)},Be=(t,e)=>(t.patterns??=new Set).add(e),gt={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function z(t){let e={},{def:n,bag:o}=t._zod,i=t._zod.traits.has("$ZodCheck")?[t,...n.checks??[]]:n.checks??[];for(let r of i){let a=r._zod.def;switch(a.check){case"greater_than":E(e,a.inclusive?"minimum":"exclusiveMinimum",a.value);break;case"less_than":H(e,a.inclusive?"maximum":"exclusiveMaximum",a.value);break;case"multiple_of":Ce(e,a.value);break;case"number_format":{Q(e,a.format);let d=gt[a.format];d&&(E(e,"minimum",d[0]),H(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":H(e,"maximum",a.maximum);break;case"length_equals":E(e,"minimum",a.length),H(e,"maximum",a.length);break;case"size_equals":E(e,"minimum",a.size),H(e,"maximum",a.size);break;case"string_format":Q(e,a.format),a.pattern&&Be(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":Fe(e,a.mime);break}}o.minimum!==void 0&&E(e,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&E(e,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&H(e,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&H(e,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&Ce(e,o.multipleOf),o.format!==void 0&&(e.format??=o.format,o.format.includes("int")&&(e.isInt=!0)),o.mime&&Fe(e,o.mime);for(let r of o.patterns??[])Be(e,r);return e}var wt={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 kt=new Set(["promise","optional","nonoptional","nullable","readonly","default","prefault","catch"]);function T(t,e=new Set){if(e.has(t))return!1;e.add(t);let n=t._zod.def,o=n.type;return o==="transform"?!0:o==="array"?T(n.element,e):o==="set"?T(n.valueType,e):o==="lazy"?T(n.getter(),e):kt.has(o)?T(n.innerType,e):o==="intersection"?T(n.left,e)||T(n.right,e):o==="record"||o==="map"?T(n.keyType,e)||T(n.valueType,e):o==="pipe"?t._zod.traits.has("$ZodCodec")||T(n.in,e)||T(n.out,e):o==="object"?Object.values(n.shape).some(i=>T(i,e)):o==="union"?n.options.some(i=>T(i,e)):o==="tuple"?n.items.some(i=>T(i,e))||(n.rest?T(n.rest,e):!1):!1}function bt(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 Ge(t){let e=t.anyOf;if(!Array.isArray(e)||e.length===0||t.type!==void 0)return;let n=[];for(let o of e){if(!o||typeof o!="object")return;Ge(o);let i=Object.keys(o);if(i.length!==1||i[0]!=="type")return;for(let r of[o.type].flat()){if(typeof r!="string")return;n.includes(r)||n.push(r)}}delete t.anyOf,t.type=n.length===1?n[0]:n}var Ke=new Set(["type","properties","required","additionalProperties"]),Ue=t=>{let e=t.additionalProperties;return e&&typeof e=="object"&&Object.keys(e).length?e:null},Ve=(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 r in i)if(!Ke.has(r))return null}let e={},n=new Set;for(let i of t){for(let r in i.properties){if(Object.prototype.hasOwnProperty.call(e,r))continue;let a=[];for(let d of t){let s=d.properties?.[r]??Ue(d);s&&!a.some(g=>Ve(g,s))&&a.push(s)}e[r]=a.length===1?a[0]:ee(a)??{allOf:a}}for(let r of i.required??[])n.add(r)}let o={type:"object",properties:e};if(n.size&&(o.required=[...n]),t.every(i=>i.additionalProperties===!1))o.additionalProperties=!1;else{let i=[];for(let r of t){let a=Ue(r);a&&!i.some(d=>Ve(d,a))&&i.push(a)}i.length===1?o.additionalProperties=i[0]:i.length>1&&(o.additionalProperties={allOf:i})}return o}function St(t){let e=t.allOf;if(!Array.isArray(e)||e.length<2)return;for(let i of Ke)if(i in t)return;let n=e.filter(i=>Array.isArray(i.oneOf)||Array.isArray(i.anyOf)),o;if(!n.length)o=ee(e);else{let i=n[0],r=Array.isArray(i.oneOf)?"oneOf":"anyOf";if(Object.keys(i).length!==1)return;let a=e.filter(s=>s!==i),d=i[r].map(s=>ee([...a,s]));if(d.some(s=>!s))return;o={[r]:d}}o&&(delete t.allOf,Object.assign(t,o))}function Ze(t){let e=t;for(let k of["anyOf","oneOf"]){let R=e[k];if(!Array.isArray(R))continue;let v=R.map(Ze);v.some((A,m)=>A!==R[m])&&(e={...e,[k]:v})}let n=[e.type].flat(),o=!n.includes("string")&&n.some(k=>k==="number"||k==="integer"),i=e.enum??(e.const!==void 0?[e.const]:void 0);if(!o&&!i?.some(k=>typeof k=="number"))return e;let{minimum:r,maximum:a,exclusiveMinimum:d,exclusiveMaximum:s,multipleOf:g,format:p,id:w,...h}=e;return h.enum?h.enum=h.enum.map(k=>typeof k=="number"?String(k):k):typeof h.const=="number"&&(h.const=String(h.const)),o&&(h.type="string",i||(h.pattern=n.includes("number")?"^-?\\d+(?:\\.\\d+)?$":"^-?\\d+$")),h}var B=class{constructor(e,n){this.override=e;this.refs=n}done=new Map;path=[];cyclic=new Map;write(e,n=!1){let o=this.refs.get(e);if(o!==void 0&&!n)return{$ref:o};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 r=this.written(e);return this.done.set(e,r),r}finally{this.path.pop()}}written(e){let n={},o,i=e._zod.toJSONSchema?.();i?Object.assign(n,i):o=this.process(e,n);let r=fe.get(e);if(r)for(let d of Object.keys(r))n[d]=r[d];T(e)&&(delete n.examples,delete n.default),"_prefault"in n&&(n.default??=n._prefault,delete n._prefault);let a=n;if(o){let d=this.write(o);a={...n};for(let s of Object.keys(d))s in n||(a[s]=d[s])}return this.override({zodSchema:e,jsonSchema:a}),Ge(a),e._zod.def.type==="intersection"&&St(a),a}process(e,n){let o=e._zod.def;switch(o.type){case"string":{n.type="string";let{minimum:i,maximum:r,format:a,patterns:d,contentEncoding:s,laxFormat:g}=z(e);if(typeof i=="number"&&(n.minLength=i),typeof r=="number"&&(n.maxLength=r),a&&(n.format=wt[a]??a,(n.format===""||a==="time"||g)&&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(w=>({pattern:w.source}))}return}case"number":{let{minimum:i,maximum:r,multipleOf:a,exclusiveMinimum:d,exclusiveMaximum:s,isInt:g}=z(e);if(n.type=g?"integer":"number",typeof d=="number"&&d>=(i??Number.NEGATIVE_INFINITY)?n.exclusiveMinimum=d:typeof i=="number"&&(n.minimum=i),typeof s=="number"&&s<=(r??Number.POSITIVE_INFINITY)?n.exclusiveMaximum=s:typeof r=="number"&&(n.maximum=r),a){let[p,...w]=new Set(a.filter(h=>Number.isFinite(h)&&h!==0).map(Math.abs));p!==void 0&&(n.multipleOf=p),w.length&&(n.allOf=[...n.allOf??[],...w.map(h=>({multipleOf:h}))])}return}case"boolean":case"success":n.type="boolean";return;case"null":n.type="null";return;case"never":n.not={};return;case"enum":{let i=bt(o.entries);i.length===0?n.not={}:(i.every(r=>typeof r=="number")&&(n.type="number"),i.every(r=>typeof r=="string")&&(n.type="string"),n.enum=i);return}case"literal":{let i=o.values.filter(r=>r!==void 0).map(r=>typeof r=="bigint"?Number(r):r);if(o.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 r of["number","string","boolean"])i.every(a=>typeof a===r)&&(n.type=r);i.every(r=>r===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:r,mime:a}=z(e);i!==void 0&&(n.minLength=i),r!==void 0&&(n.maxLength=r),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:r}=z(e);typeof i=="number"&&(n.minItems=i),typeof r=="number"&&(n.maxItems=r),n.type="array",n.items=this.write(o.element);return}case"object":{let i=o.shape;n.type="object";let r={};n.properties=r;for(let d in i)Object.defineProperty(r,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),o.catchall?._zod.def.type==="never"?n.additionalProperties=!1:o.catchall&&(n.additionalProperties=this.write(o.catchall));return}case"union":n[o.inclusive===!1?"oneOf":"anyOf"]=o.options.map(i=>this.write(i));return;case"intersection":{let i=d=>"allOf"in d&&Object.keys(d).length===1,r=this.write(o.left),a=this.write(o.right);n.allOf=[...i(r)?r.allOf:[r],...i(a)?a.allOf:[a]];return}case"tuple":{let i=o.items;n.type="array",n.prefixItems=i.map(s=>this.write(s)),o.rest?n.items=this.write(o.rest):n.items=!1;let r=i.length;for(;r>0&&L(i[r-1])!==void 0;)r-=1;r>0&&(n.minItems=r),o.rest||(n.maxItems=i.length);let{minimum:a,maximum:d}=z(e);typeof a=="number"&&(n.minItems=a),typeof d=="number"&&(n.maxItems=d);return}case"record":{let i=o.keyType;n.type="object";let r=z(i).patterns;if(o.mode==="loose"&&r&&r.size>0){let d=this.write(o.valueType),s={};for(let g of r)s[g.source]=d;n.patternProperties=s}else n.propertyNames=Ze(this.write(i)),n.additionalProperties=this.write(o.valueType);let a=i._zod.values;if(a&&!o.partial&&L(o.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(o.innerType),{type:"null"}];return;case"default":case"prefault":{let i=o.defaultValue,r,a=!1,d=JSON.stringify(i,(s,g)=>typeof g=="bigint"?(a=!0,null):g);return!a&&d!==void 0&&(r=JSON.parse(d)),a||(n[o.type==="default"?"default":"_prefault"]=r),o.innerType}case"catch":{try{n.default=o.catchValue(void 0)}catch{}return o.innerType}case"readonly":return n.readOnly=!0,o.innerType;case"pipe":return o.in._zod.traits.has("$ZodTransform")?o.out:o.in;case"lazy":return e._zod.innerType;case"optional":case"nonoptional":case"promise":return o.innerType;default:return}}};function Ye(t,e=()=>{}){let n=t,o=new B(e,new Map),i=o.write(n,!0);if(o.cyclic.size>0){let r=new Map,a=0,d=[];for(let g of o.cyclic.keys())if(g===n)r.set(g,"#");else{let p=`__schema${a++}`;r.set(g,`#/$defs/${p}`),d.push([g,p])}o=new B(e,r),i=o.write(n,!0);let s={};for(let[g,p]of d)s[p]=o.write(g,!0);d.length>0&&(i={...i,$defs:s})}return JSON.parse(JSON.stringify({$schema:"https://json-schema.org/draft/2020-12/schema",...i}))}function Xe(t){return Ye(t,Ot)}var vt={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string"},At={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 Ot(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 "),g=`${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(g)||(t.jsonSchema.description=`${typeof p=="string"&&p?`${p.replace(/\.?$/,".")} `:""}${g}`)}if(ke(t.zodSchema)&&(t.jsonSchema["x-graview-repeat"]=!0,!t.jsonSchema.type&&!t.jsonSchema.anyOf&&!t.jsonSchema.oneOf&&Object.assign(t.jsonSchema,Rt())),be(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=_e(t.zodSchema);if(n){let s=t.jsonSchema;s["x-graview-type"]=n,n==="duration"&&(s["x-graview-unit"]="minutes"),s.description??=At[n]}let o=Re(t.zodSchema,!1);if(o){let s=Ie(o);t.jsonSchema["x-graview-format"]=s.format??"unit",s.currency&&(t.jsonSchema["x-graview-currency"]=s.currency),s.unit&&s.format!=="money"&&(t.jsonSchema["x-graview-unit"]=s.unit);let g=t.jsonSchema.description;t.jsonSchema.description=typeof g=="string"&&g.length>0?`${g} ${Y(s)}`:Y(s)}let i=t.zodSchema._zod?.def;if(!i||i.type!=="string"||typeof i.format!="string"||i.format==="regex")return;let r=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 r.pattern;let d=r.allOf;Array.isArray(d)&&d.every(s=>typeof s=="object"&&s!==null&&Object.keys(s).length===1&&"pattern"in s)&&delete r.allOf,r.format=vt[i.format]??i.format,a.length===1?r.pattern=a[0]:a.length>1&&(r.allOf=a.map(s=>({pattern:s})))}function te(t,e){let n=C(t.input),o=Xe(t.input);if(e&&o.properties){let r=a=>e.includes(a)?e.indexOf(a):e.length;o.properties=Object.fromEntries(Object.entries(o.properties).sort(([a],[d])=>r(a)-r(d)))}let i=o.properties??{};if(Ae(t)){let r=t.creates.join(" | ");i.id={type:"string",minLength:1,description:`Optional: the id for the ${r} this makes, beginning with its kind (${t.creates.map(a=>`"${a}:"`).join(" or ")}). Refused if the graph already has it; left out, one is minted from the label.`},o.properties=i}Oe(t)&&(o.additionalProperties=!1);for(let r of n){let a=i[r.name];if(!a)continue;let d=r.kinds.includes("*")?"any node kind":r.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:o,nodeRefs:n}}function Rt(){let t={type:"string",pattern:"^\\d{4}-\\d{2}-\\d{2}$"},e=(n,o)=>({type:"integer",minimum:n,maximum:o});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:[...we]},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 Qe(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=Qe(e),o=p=>{if(p.kind==="rule")return!1;let w=Qe(p);if(w.size===0)return!1;for(let h of w)if(n.has(h))return!1;return!0},i,r=()=>{if(i)return i;i=new Map;for(let p of t.log.live()){if(p.undoes!==void 0)continue;let w=o(p.author)?p.author:void 0;for(let h of p.primitives){h.op==="remove-node"&&i.delete(h.node.id);let k=h.op==="add-node"?h.node.id:h.op==="patch-node"||h.op==="splice-text"?h.id:void 0;if(k===void 0)continue;let R=h.op==="add-node"?Object.keys(h.node):h.op==="splice-text"?[h.field]:Object.keys(h.after),v=i.get(k);(h.op==="add-node"||!v)&&i.set(k,v=new Map);for(let A of R)A==="id"||A==="kind"||(w?v.set(A,w):v.delete(A))}}return i},a=t.schema,d=new Map,s=(p,w)=>{let h=`${p}\0${w}`,k=d.get(h);if(k===void 0){let R=a.tryDefinition(p)?.fields?.shape;k=R!==void 0&&w in R&&Le(R[w]).type==="text",d.set(h,k)}return k},g=p=>t.graph.getNode(p)?.kind;return{prose:s,say:p=>F(p,{graph:t.graph,schema:a}),fieldBy(p,w){let h=g(p);if(!(h===void 0||!s(h,w)))return r().get(p)?.get(w)},recordBy(p){let w=g(p),h=r().get(p);if(w===void 0||!h)return;let k;for(let[R,v]of h)s(w,R)&&(k=v);return k}}}var ne=(t,e,n)=>({untrusted:!0,authoredBy:n.say(e),text:t}),_t="the host's ranker";function et(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:_t,text:n.why.matched}}});let o=e.recordBy(n.id);if(!o)return n;let i=e.prose(n.kind,n.why.field)?e.fieldBy(n.id,n.why.field):o;return{...n,label:ne(n.label,o,e),...n.apart!==void 0?{apart:ne(n.apart,o,e)}:{},why:i?{...n.why,fragment:ne(n.why.fragment,i,e)}:n.why}})}}var ie=(t,e,n)=>({title:t,readOnlyHint:e,destructiveHint:!1,idempotentHint:n,openWorldHint:!1}),Tt={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)},xt={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)},Pt={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)},oe=[Tt,xt,Pt];var it=t=>({type:"string",enum:[...t],description:"The workflow, by its name."}),tt=t=>({name:"run_workflow",title:"Run a workflow now",description:"Run one of the app's workflows now, by hand, as the app's own actor: its steps make, change, set aside or suggest what they say, as its approve setting says. With dryRun: true nothing is kept and the answer says what it would do. The first run after a workflow is added or changed is a dry run whatever you ask; run it again to keep it. A paused workflow only dry-runs. Returns the run: its outcome, what it made, changed, archived and suggested, what it held back and why.",inputSchema:{type:"object",properties:{name:it(t),dryRun:{type:"boolean",description:"Keep nothing; say what it would do. False when unsaid."}},required:["name"],additionalProperties:!1},mutating:!0,annotations:{title:"Run a workflow now",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1}}),nt=(t,e)=>({name:t?"pause_workflow":"resume_workflow",title:t?"Pause a workflow":"Resume a workflow",description:t?"Pause one of the app's workflows: it runs on no schedule and no change until it is resumed, and run_workflow only dry-runs it. Changes the app's declaration, not its records. Returns the edit that takes it back.":"Resume a paused workflow: it runs again on its schedule and the changes it waits for. Changes the app's declaration, not its records. Returns the edit that takes it back.",inputSchema:{type:"object",properties:{name:it(e)},required:["name"],additionalProperties:!1},mutating:!0,annotations:{title:t?"Pause a workflow":"Resume a workflow",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}}),ot=["run_workflow","pause_workflow","resume_workflow"];function rt(t,e){return e===void 0||t.length===0?[]:e==="manage"?[tt(t),nt(!0,t),nt(!1,t)]:[tt(t)]}function Mt(t){return{run:t.id,workflow:t.workflow,outcome:t.outcome,dry:t.dry,made:t.made,changed:t.changed,archived:t.archived,suggested:t.suggested,heldBack:t.heldBack,notes:t.notes}}async function at(t,e,n){let o=n.workflows.declared(),i=o.map(w=>w.name),r=String(e.name??"");if(!i.includes(r))return{ok:!1,error:`No workflow is called "${r}". The app's workflows are: ${i.join(", ")||"none"}. Nothing was changed.`,reason:"invalid"};if(t==="run_workflow"){let w=await n.workflows.run(r,{dryRun:e.dryRun===!0,...n.principal.id!==void 0?{who:n.principal.id}:{}});return{ok:!0,data:Mt(w)}}let a=n.workflows.edit;if(!a)return{ok:!1,error:"This seat's host does not write the app's declaration, so it cannot pause or resume a workflow. Nothing was changed.",reason:"forbidden"};let d=t==="pause_workflow",s=o.find(w=>w.name===r),g=s.status;if(g==="paused"===d)return{ok:!0,data:{workflow:r,status:g,said:`\u201C${s.title}\u201D is already ${g}. Nothing was changed.`}};let p=await a({op:d?"pause-workflow":"resume-workflow",name:r});return p.ok?{ok:!0,data:{workflow:r,status:d?"paused":"active",...p.said?{said:p.said}:{},undo:{op:d?"resume-workflow":"pause-workflow",name:r}}}:{ok:!1,error:p.error}}var q=t=>{let e;return()=>e??=t().catch(n=>{throw e=void 0,n})},Nt=q(()=>(__graviewPreload(import.meta.url,["./chunk.64LCHHZB.js","./chunk.CNN32262.js","./chunk.EP5JS7ZH.js","./chunk.L7XKYGV7.js","./chunk.CE3NKAF7.js","./chunk.R3GE37OI.js","./chunk.2KCDLCB2.js","./chunk.UD7VLXPM.js","./chunk.3DEWQDP7.js","./chunk.QUETLFBJ.js","./chunk.JULD4XFB.js","./chunk.GRTBEA7O.js","./chunk.6AANHELP.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.3WPCS6KP.js"))),$t=()=>(__graviewPreload(import.meta.url,["./chunk.EGSOHTZZ.js","./chunk.2KCDLCB2.js","./chunk.UD7VLXPM.js","./chunk.3DEWQDP7.js","./chunk.6AANHELP.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.ECNGVD25.js")).catch(()=>{}),Dt=async()=>{(await $t())?.judgeWithLines()},W=q(()=>(__graviewPreload(import.meta.url,["./chunk.WVUJXDXZ.js","./chunk.L7XKYGV7.js","./chunk.CE3NKAF7.js","./chunk.R3GE37OI.js","./chunk.2KCDLCB2.js","./chunk.UD7VLXPM.js","./chunk.3DEWQDP7.js","./chunk.JULD4XFB.js","./chunk.GRTBEA7O.js","./chunk.6AANHELP.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.NRCWMYLH.js"))),Jt=q(()=>(__graviewPreload(import.meta.url,["./chunk.VTDOWXCP.js","./chunk.G4JJXA63.js","./chunk.TBY5IR7C.js","./chunk.BHJRT57H.js","./chunk.BIDL7GQD.js","./chunk.CNN32262.js","./chunk.JGRSUTPJ.js","./chunk.XOZU4OFA.js","./chunk.EP5JS7ZH.js","./chunk.Q5WEOX3Q.js","./chunk.KAM73WVF.js","./chunk.O32F6LGK.js","./chunk.EGSOHTZZ.js","./chunk.WVUJXDXZ.js","./chunk.L7XKYGV7.js","./chunk.CE3NKAF7.js","./chunk.R3GE37OI.js","./chunk.2KCDLCB2.js","./chunk.UD7VLXPM.js","./chunk.3DEWQDP7.js","./chunk.TFJA4QV4.js","./chunk.HWFJQ42Y.js","./chunk.QUETLFBJ.js","./chunk.JULD4XFB.js","./chunk.GRTBEA7O.js","./chunk.6AANHELP.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.5L4ADKTW.js"))),Et=q(()=>(__graviewPreload(import.meta.url,["./chunk.O2VXTYUJ.js","./chunk.64LCHHZB.js","./chunk.CNN32262.js","./chunk.N5Z34V7U.js","./chunk.LOKGUALC.js","./chunk.EP5JS7ZH.js","./chunk.L7XKYGV7.js","./chunk.CE3NKAF7.js","./chunk.R3GE37OI.js","./chunk.2KCDLCB2.js","./chunk.UD7VLXPM.js","./chunk.3DEWQDP7.js","./chunk.TFJA4QV4.js","./chunk.HWFJQ42Y.js","./chunk.QUETLFBJ.js","./chunk.JULD4XFB.js","./chunk.GRTBEA7O.js","./chunk.6AANHELP.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.U7PAFLUM.js"))),Ht=q(()=>(__graviewPreload(import.meta.url,["./chunk.SS6KL5NT.js","./chunk.WV45KLXC.js","./chunk.2KCDLCB2.js","./chunk.UD7VLXPM.js","./chunk.3DEWQDP7.js","./chunk.6AANHELP.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.7K2V5FUB.js"))),jt=t=>t.definitions.some(e=>Z(e).size>0),st=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 zt(t,e,n,o){let i=String(n.relation??""),[r,a]=i.includes(".")?i.split(".",2):[void 0,i],d=t.schema.definitions.flatMap(A=>[...Z(A)].map(([m,u])=>({kind:A.kind,name:m,relation:u}))),s=d.filter(A=>A.name===a&&(r===void 0||A.kind===r));if(s.length!==1){let A=d.map(m=>`${m.kind}.${m.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: ${A}.`}}let{kind:g,name:p,relation:w}=s[0];if(!o)return{ok:!1,error:`This seat cannot read ${w.address}: its host reads no other app's records. Nothing was changed.`};let h={kind:e.kind,...e.id===void 0?{}:{id:e.id},...e.roles?{roles:e.roles}:{},...e.onBehalfOf?{onBehalfOf:e.onBehalfOf}:{}},k=typeof n.of=="string"?n.of:void 0;if(k!==void 0){let A=t.graph.getNode(k);if(!A||A.kind!==g)return{ok:!1,error:`No ${g} "${k}".`};let m=he(A[p],w),u=await Promise.all(m.map(b=>Promise.resolve().then(()=>o.resolve(b,h)).catch(()=>null)));return{ok:!0,data:{relation:`${g}.${p}`,app:w.address,records:u.map((b,S)=>b===null?{value:K(m[S]),missing:!0}:"denied"in b?{denied:!0,said:"linked record (no access)"}:st(b))},reads:[k]}}let R=typeof n.limit=="number"&&n.limit>0?Math.min(n.limit,20):20,v=await Promise.resolve().then(()=>o.find({address:w.address,kinds:w.kinds,query:String(n.query??""),limit:R},h)).catch(()=>[]);return Array.isArray(v)?{ok:!0,data:{relation:`${g}.${p}`,app:w.address,records:v.map(st),link:`edit-${g} with ${p} set to a record's value`}}:{ok:!0,data:{relation:`${g}.${p}`,app:w.address,denied:!0,said:"linked record (no access)"}}}var M=t=>({title:t,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}),dt={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"]}]},re={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:dt},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:re,archived:dt},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:re},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:re,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), and the votes on it (tally: for, against, and this seat's own as mine). 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). From a seat that may see the suggestion and may not make the change, it records this seat's vote for it instead (voted: "for"; a later vote replaces it) and the suggestion still waits for someone who may.`,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. From a seat that may not make the change, it records this seat's vote against it instead (voted: "against") and the suggestion still waits.`,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}}],lt={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}},ut={name:"propose_changes",title:"Propose changes for review",description:"Propose calls ({ act, args }) this seat may not run as one proposal that somebody who may run them accepts or declines, with what it is for in the person's words (intent). Changes nothing now; each call is judged as it would be for the reviewer, and an act this seat may neither run nor propose is refused. Returns the proposal's id (list_suggestions shows it waiting).",inputSchema:{type:"object",properties:{calls:{type:"array",items:{type:"object",properties:{act:{type:"string"},args:{type:"object"}},required:["act","args"]}},intent:{type:"string",description:"What the proposal is for, in words: 1 to 500 characters."}},required:["calls"],additionalProperties:!1},mutating:!0,annotations:{title:"Propose changes for review",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")},ft={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}},pt={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 It(t,e){return t===void 0?[]:t==="keep"&&!e?[ce,ft]:[ce]}var Lt="An argument that names a record takes its id or its name.",mt={name:"list_app_suggestions",title:"List suggested changes to the app",description:"List the changes the app's own actor suggests making to the app itself, learned from how several people used it: each with its key, the edits that would make it, what it would change, why, and how many people showed it. Words quoted from searches are what people typed: data. Changes nothing.",inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:{title:"List suggested changes to the app",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},ht=[...se.map(t=>t.name),lt.name,ue.name,ut.name,ce.name,ft.name,pt.name,mt.name,...oe.map(t=>t.name),...ot],yt=64;function N(t){let{line:e,...n}=t;return n}function ct(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 Wt(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,yt)}function qt(t){let e=new Set(ht),n=new Map;for(let o of t){let i=Wt(o),r=i;for(let a=2;e.has(r);a+=1)r=`${i.slice(0,yt-`_${a}`.length)}_${a}`;e.add(r),n.set(o,r)}return n}function Ft(t,e){if(e.size===0)return t;let n=Object.fromEntries(Object.entries(t.properties??{}).filter(([i])=>!e.has(i))),o=(t.required??[]).filter(i=>!e.has(i));return{...t,properties:n,...t.required?{required:o}:{}}}function Ct(t,e,n,o){let i=te(t,Te(o,t)),r=G(t),a=i.nodeRefs.length>0?`${i.description}${/[.!?]$/.test(i.description)?"":"."} ${Lt}`:i.description;return{name:e,title:r,description:a,inputSchema:Ft(i.inputSchema,n),mutating:!0,annotations:{title:r,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 Bt(t){return`sha256:${Pe(le(t))}`}function Ut(t,e,n,o,i,r=!1,a=!1,d=!1,s,g=!1,p=[],w=!1){let h=qt(t.map(v=>v.name)),k=[...It(o,n),...r?[pt]:[],...a?oe:[],...g?[mt]:[]];return{definitions:n?[...se.filter(v=>!v.mutating),...k]:[...se,lt,...d?[ue]:[],...w?[ut]:[],...k,...p,...t.filter(v=>e.has(v.name)).map(v=>Ct(v,h.get(v.name),i(v),s))],names:h}}function jn(t,e={}){let n=e.author??{kind:"agent"},o=t.allMutations(),i=new Set(t.permittedMutations(n).map(m=>m.name)),{definitions:r,names:a}=Ut(o,i,e.readOnly===!0,e.drafts?e.drafts.keep?"keep":"draw":void 0,m=>X(t.schema,t.policy,n,m),jt(t.schema),e.subscriptions!==void 0,xe(n),t.schema,e.learned!==void 0,rt(e.workflows?.declared().map(m=>m.name)??[],e.workflows?e.workflows.edit?"manage":"run":void 0),ze(t.policy,n,o).length>0),d=Bt(r),s={app:e.app?.brand?.locale,appTimeZone:e.app?.brand?.timeZone},g=m=>pe(s,m),p=m=>{if(!ht.includes(m)){for(let[u,b]of a)if(b===m)return u;return a.has(m)?m:Me(m,a.keys())}},w=m=>{let u=Ne(m,a.keys());return u?` Did you mean "${u}"?`:""},h=m=>{let u=r.find(S=>S.name===m)??r.find(S=>S.act===m);if(u)return u;let b=p(m);return b===void 0?void 0:r.find(S=>S.act===b)},k=(m,u)=>{let b=o.find(l=>l.name===m);if(!b)return{args:u,resolved:[]};let S={...u},c=[];for(let l of C(b.input)){let f=S[l.name];if(typeof f!="string"||f.trim()==="")continue;let y=t.resolveRef(l,f,n);if(!y.ok){let O=y.reason==="none"?` Nothing was changed. Use search_graph to look it up, then pass its id as ${l.name}.`:" Nothing was changed.";return{ok:!1,error:`${y.message}${O}`,argument:l.name,candidates:y.candidates}}y.by!=="id"&&(S[l.name]=y.id,c.push({argument:l.name,given:f,id:y.id,label:y.label}))}return{args:S,resolved:c}},R=async(m,u)=>{try{await Dt();let b=h(m);if(!b&&m===ue.name)return{ok:!1,error:"Only the app's own actor (automated: true) suggests changes.",reason:"forbidden"};if(!b){let c=p(m);if(c){let l=t.permits({name:c,args:u},n);if(!l.ok)return{ok:!1,error:l.refusal.message,reason:"forbidden"}}return{ok:!1,error:`Unknown tool "${m}".${w(m)} Available: ${r.map(l=>l.name).join(", ")}`}}if(b.mutating&&e.readOnly)return{ok:!1,error:`"${m}" changes the graph, and this seat is read-only.`,reason:"forbidden"};if(b.act!==void 0){let c=k(b.act,u);if("ok"in c)return c;let l=b.act,f=g(()=>j(t,n,t.apply({name:l,args:c.args},{...e.author?{author:e.author}:{},...V(e.via)})));return{ok:!0,data:{batch:f.batch,intent:f.intent,introduces:f.introduces.map(N),resolves:f.resolves.map(N),...c.resolved.length>0?{resolved:c.resolved}:{}},diff:f.diff}}let S=t.seenBy(n);switch(b.name){case"search_graph":{let c=typeof e.places=="function"?e.places():e.places,l=typeof u.subject=="string"?u.subject:void 0,f=qe(S,String(u.query??""),{principal:n,rank:e.near,archived:Se(u.archived),limit:typeof u.limit=="number"&&u.limit>0?Math.min(u.limit,20):20,...c?{places:c}:{},...l?{subject:l,from:[l]}:{}}),y=f.later?await f.later:f;return{ok:!0,data:(await W()).searchRead(y,et(y,U(S,n))),reads:y.hits.flatMap(O=>O.about==="node"?[O.id]:[])}}case"get_graph":return{ok:!0,...(await W()).graphRead(S,U(S,n),u)};case"get_node":{let c=String(u.id??""),l=c,f;if(!S.graph.getNode(c)){let O=c.trim()===""?void 0:t.resolveRef({name:"id",kinds:["*"]},c,n);if(O?.ok)l=O.id,f={argument:"id",given:c,id:l,label:O.label};else return O?.reason==="ambiguous"?{ok:!1,error:O.message,argument:"id",candidates:O.candidates}:{ok:!1,error:`No node "${c}".`}}let y=(await W()).nodeRead(S,U(S,n),l,u);return{ok:!0,data:f?{...y.data,resolved:[f]}:y.data,reads:y.reads}}case"describe_place":{let c=e.app??{name:"",schema:t.schema},l=typeof u.width=="number"&&Number.isFinite(u.width)&&u.width>0?u.width:1440,{describePlace:f}=await Nt(),y=f(t,n,String(u.place??""),{app:c,width:l});if(!y.ok)return{ok:!1,error:`${y.error} The places are: ${y.places.join(", ")}.`};let O=new Set,P=I=>{for(let D of I)for(let x of D.groups??[])for(let $ of x.items)O.add($.id),P($.parts)};return P(y.description.parts),{ok:!0,data:y.description,reads:[...O]}}case"find_linked":return zt(S,n,u,e.linked);case"draft_view":case"keep_lens":{let c=e.app??{name:"",schema:t.schema};return(await Jt()).runDraftTool(b.name,u,{app:c,principal:n,...e.drafts?{drafts:e.drafts}:{}})}case"get_violations":{let c=S.violations(u.context);return{ok:!0,...(await W()).violationsRead(c,u)}}case"get_affordances":{let c=u.selection??[];return{ok:!0,data:We(S,c,{...typeof e.derive=="function"?e.derive():e.derive,...e.author?{principal:e.author}:{},...u.context?{context:u.context}:{}}),reads:c.filter(f=>S.graph.has(f))}}case"preview_mutation":{let c=String(u.mutation),l=p(c)??c,f=k(l,u.args??{});if("ok"in f)return f;let y=t.missingFor({name:l,args:f.args},n);if(y)return{ok:!1,error:y.message,reason:"missing"};let O=j(t,n,t.preview({name:l,args:f.args},void 0,{author:n})),P=ct(O);return{ok:!0,data:f.resolved.length>0?{...P,resolved:f.resolved}:P}}case"act_on_several":{let c=String(u.act??""),l=p(c)??c,f=o.find(_=>_.name===l);if(!f||!i.has(l)){let _=f?t.permits({name:l,args:{}},n):void 0;return _&&!_.ok?{ok:!1,error:_.refusal.message,reason:"forbidden"}:{ok:!1,error:`There is no act "${c}" this seat may run.${w(c)} Nothing was changed.`,reason:"invalid"}}let y=f.subject;if(!y)return{ok:!1,error:`"${G(f)}" does not act on a record, so it cannot be run on several. Nothing was changed.`,reason:"invalid"};let O=Array.isArray(u.records)?u.records.filter(_=>typeof _=="string"&&_.trim()!==""):[];if(O.length===0)return{ok:!1,error:"Name at least one record. Nothing was changed.",reason:"invalid"};let P=[],I=[];for(let _ of O.slice(0,200)){let J=t.resolveRef({name:y.arg,kinds:y.kinds},_,n);if(!J.ok)return{ok:!1,error:`${J.message} Nothing was changed.`,argument:"records",candidates:J.candidates};P.push(J.id),J.by!=="id"&&I.push({argument:"records",given:_,id:J.id,label:J.label})}let D=k(l,{...u.args??{}});if("ok"in D)return D;let x=(await Et()).actOnSeveral(t,{mutation:l,subject:y.arg,args:D.args},P,{author:n,...V(e.via)}),$=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(_=>({record:_.id,label:_.label,error:_.message,reason:_.reason})),...x.allOrNothing?{keptNone:!0}:{},...$?{introduces:$.introduces.map(N),resolves:$.resolves.map(N)}:{},...I.length>0||D.resolved.length>0?{resolved:[...I,...D.resolved]}:{}},...$?{diff:$.diff}:{}}}case"subscribe":case"unsubscribe":case"list_subscriptions":{let c=await(await Ht()).runSubscriptionTool(b.name,u,{store:t,principal:e.subscriber??n,app:e.app?.name??"app",subscriptions:e.subscriptions});return c.ok?{ok:!0,data:c.data}:{ok:!1,error:c.error}}case"run_workflow":case"pause_workflow":case"resume_workflow":{let c=await at(b.name,u,{principal:n,workflows:e.workflows});return c.ok?{ok:!0,data:c.data}:{ok:!1,error:c.error,...c.reason?{reason:c.reason}:{}}}case"list_app_suggestions":return{ok:!0,data:{suggestions:(await e.learned()).map(({key:l,said:f,why:y,edits:O,evidence:P})=>({key:l,said:f,why:y,edits:O,evidence:P}))}};case"list_suggestions":{let c=De(t,n).map(l=>{let f=F(l.author,{graph:S.graph,schema:t.schema});return{id:l.id,intent:l.intent,by:f,at:l.at,about:l.about,tally:l.tally,...He(l)?{proposedBy:l.lineage.proposedBy}:{},...l.lineage?{basis:{untrusted:!0,authoredBy:f,text:l.lineage.basis},...l.lineage.confidence!==void 0?{confidence:l.lineage.confidence}:{}}:{}}});return{ok:!0,data:{suggestions:c},reads:[...new Set(c.flatMap(l=>l.about))]}}case"suggest_changes":{let c=u.calls.map(f=>({name:p(f.act)??f.act,args:f.args}));return{ok:!0,data:{suggestion:$e(t,c,{author:n,lineage:{basis:u.basis,confidence:u.confidence},...V(e.via)})?.id??null}}}case"propose_changes":{let c=(u.calls??[]).map(y=>({name:p(y.act)??y.act,args:y.args??{}})),l=typeof u.intent=="string"&&u.intent.trim()!==""?u.intent.trim():void 0,f=je(t,n,c,l);return{ok:!0,data:{proposal:f?.id??null,...f?{intent:f.intent}:{}}}}case"accept_suggestion":case"decline_suggestion":{let c=String(u.suggestion??""),l={author:n,...V(e.via)},f=b.name==="accept_suggestion"?Je(t,c,l):Ee(t,c,l),y=j(t,n,f);return{ok:!0,data:{batch:y.batch,intent:y.intent,...f.voted?{voted:f.voted}:{},introduces:y.introduces.map(N),resolves:y.resolves.map(N)},diff:y.diff}}case"undo_batch":{let c=String(u.batch),l=u.include??[],f=S.canUndo([c,...l]);if(!f.ok)return{ok:!1,error:f.message};let y=j(t,n,t.undo([c,...l],{...e.author?{author:e.author}:{}}));return{ok:!0,data:ct(y),diff:y.diff}}default:return{ok:!1,error:`Unknown tool "${m}".`}}}catch(b){let{reason:S,wouldNeed:c}=ve(b);return{ok:!1,error:b instanceof Error?b.message:String(b),reason:S,...c?{wouldNeed:c}:{}}}},v=new Set,A=m=>{for(let u of v)u(m)};return{definitions:r,hash:d,...e.author?{author:e.author}:{},onDiff(m){return t.subscribe(m)},onCall(m){return v.add(m),()=>v.delete(m)},async call(m,u){let b=h(m)?.mutating??!1,S={name:m,args:u,mutating:b,at:new Date().toISOString()};A({...S,phase:"running"});let c=f=>(A(f.ok?{...S,phase:"ok",...!b&&f.reads?{reads:f.reads}:{}}:{...S,phase:"failed",error:f.error}),f),l=await R(m,u);return c(l.ok&&!b?{...l,data:(await W()).withinReadChars(m,l.data)}:l)}}}function V(t){let e=typeof t=="function"?t():t;return e?{via:e}:{}}export{le as a,jn as b};
|
|
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{r as qe}from"./chunk.LKM2R5UF.js";import{d as $e,e as De,h as Je,i as Ee,k as He,l as je,m as ze}from"./chunk.B5EFNTDA.js";import{a as We}from"./chunk.7L3I776Z.js";import{e as X}from"./chunk.WV6SP6IJ.js";import{a as j}from"./chunk.HCX6KPRF.js";import{f as Ie,g as Y,i as Le}from"./chunk.P26ATAAI.js";import{a as be}from"./chunk.IY3DV52G.js";import{$b as Re,Ga as me,Ja as K,Jc as xe,Jd as Pe,La as he,Ld as Me,Md as Ne,Na as ye,O as pe,Oa as Z,Ob as ve,Va as ge,Wa as we,Wb as Ae,Xb as Oe,Za as ke,a as fe,cc as _e,eb as F,fc as C,ib as Se,ma as G,nc as Te}from"./chunk.DHPXRDT5.js";var E=(t,e,n)=>{(t[e]===void 0||n>t[e])&&(t[e]=n)},H=(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)},Fe=(t,e)=>{t.mime=t.mime?t.mime.filter(n=>e.includes(n)):[...e]},Ce=(t,e)=>{t.multipleOf??=[],t.multipleOf.includes(e)||t.multipleOf.push(e)},Be=(t,e)=>(t.patterns??=new Set).add(e),gt={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function z(t){let e={},{def:n,bag:o}=t._zod,i=t._zod.traits.has("$ZodCheck")?[t,...n.checks??[]]:n.checks??[];for(let r of i){let a=r._zod.def;switch(a.check){case"greater_than":E(e,a.inclusive?"minimum":"exclusiveMinimum",a.value);break;case"less_than":H(e,a.inclusive?"maximum":"exclusiveMaximum",a.value);break;case"multiple_of":Ce(e,a.value);break;case"number_format":{Q(e,a.format);let d=gt[a.format];d&&(E(e,"minimum",d[0]),H(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":H(e,"maximum",a.maximum);break;case"length_equals":E(e,"minimum",a.length),H(e,"maximum",a.length);break;case"size_equals":E(e,"minimum",a.size),H(e,"maximum",a.size);break;case"string_format":Q(e,a.format),a.pattern&&Be(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":Fe(e,a.mime);break}}o.minimum!==void 0&&E(e,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&E(e,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&H(e,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&H(e,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&Ce(e,o.multipleOf),o.format!==void 0&&(e.format??=o.format,o.format.includes("int")&&(e.isInt=!0)),o.mime&&Fe(e,o.mime);for(let r of o.patterns??[])Be(e,r);return e}var wt={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 kt=new Set(["promise","optional","nonoptional","nullable","readonly","default","prefault","catch"]);function T(t,e=new Set){if(e.has(t))return!1;e.add(t);let n=t._zod.def,o=n.type;return o==="transform"?!0:o==="array"?T(n.element,e):o==="set"?T(n.valueType,e):o==="lazy"?T(n.getter(),e):kt.has(o)?T(n.innerType,e):o==="intersection"?T(n.left,e)||T(n.right,e):o==="record"||o==="map"?T(n.keyType,e)||T(n.valueType,e):o==="pipe"?t._zod.traits.has("$ZodCodec")||T(n.in,e)||T(n.out,e):o==="object"?Object.values(n.shape).some(i=>T(i,e)):o==="union"?n.options.some(i=>T(i,e)):o==="tuple"?n.items.some(i=>T(i,e))||(n.rest?T(n.rest,e):!1):!1}function bt(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 Ge(t){let e=t.anyOf;if(!Array.isArray(e)||e.length===0||t.type!==void 0)return;let n=[];for(let o of e){if(!o||typeof o!="object")return;Ge(o);let i=Object.keys(o);if(i.length!==1||i[0]!=="type")return;for(let r of[o.type].flat()){if(typeof r!="string")return;n.includes(r)||n.push(r)}}delete t.anyOf,t.type=n.length===1?n[0]:n}var Ke=new Set(["type","properties","required","additionalProperties"]),Ue=t=>{let e=t.additionalProperties;return e&&typeof e=="object"&&Object.keys(e).length?e:null},Ve=(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 r in i)if(!Ke.has(r))return null}let e={},n=new Set;for(let i of t){for(let r in i.properties){if(Object.prototype.hasOwnProperty.call(e,r))continue;let a=[];for(let d of t){let s=d.properties?.[r]??Ue(d);s&&!a.some(g=>Ve(g,s))&&a.push(s)}e[r]=a.length===1?a[0]:ee(a)??{allOf:a}}for(let r of i.required??[])n.add(r)}let o={type:"object",properties:e};if(n.size&&(o.required=[...n]),t.every(i=>i.additionalProperties===!1))o.additionalProperties=!1;else{let i=[];for(let r of t){let a=Ue(r);a&&!i.some(d=>Ve(d,a))&&i.push(a)}i.length===1?o.additionalProperties=i[0]:i.length>1&&(o.additionalProperties={allOf:i})}return o}function St(t){let e=t.allOf;if(!Array.isArray(e)||e.length<2)return;for(let i of Ke)if(i in t)return;let n=e.filter(i=>Array.isArray(i.oneOf)||Array.isArray(i.anyOf)),o;if(!n.length)o=ee(e);else{let i=n[0],r=Array.isArray(i.oneOf)?"oneOf":"anyOf";if(Object.keys(i).length!==1)return;let a=e.filter(s=>s!==i),d=i[r].map(s=>ee([...a,s]));if(d.some(s=>!s))return;o={[r]:d}}o&&(delete t.allOf,Object.assign(t,o))}function Ze(t){let e=t;for(let k of["anyOf","oneOf"]){let R=e[k];if(!Array.isArray(R))continue;let v=R.map(Ze);v.some((A,m)=>A!==R[m])&&(e={...e,[k]:v})}let n=[e.type].flat(),o=!n.includes("string")&&n.some(k=>k==="number"||k==="integer"),i=e.enum??(e.const!==void 0?[e.const]:void 0);if(!o&&!i?.some(k=>typeof k=="number"))return e;let{minimum:r,maximum:a,exclusiveMinimum:d,exclusiveMaximum:s,multipleOf:g,format:p,id:w,...h}=e;return h.enum?h.enum=h.enum.map(k=>typeof k=="number"?String(k):k):typeof h.const=="number"&&(h.const=String(h.const)),o&&(h.type="string",i||(h.pattern=n.includes("number")?"^-?\\d+(?:\\.\\d+)?$":"^-?\\d+$")),h}var B=class{constructor(e,n){this.override=e;this.refs=n}done=new Map;path=[];cyclic=new Map;write(e,n=!1){let o=this.refs.get(e);if(o!==void 0&&!n)return{$ref:o};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 r=this.written(e);return this.done.set(e,r),r}finally{this.path.pop()}}written(e){let n={},o,i=e._zod.toJSONSchema?.();i?Object.assign(n,i):o=this.process(e,n);let r=fe.get(e);if(r)for(let d of Object.keys(r))n[d]=r[d];T(e)&&(delete n.examples,delete n.default),"_prefault"in n&&(n.default??=n._prefault,delete n._prefault);let a=n;if(o){let d=this.write(o);a={...n};for(let s of Object.keys(d))s in n||(a[s]=d[s])}return this.override({zodSchema:e,jsonSchema:a}),Ge(a),e._zod.def.type==="intersection"&&St(a),a}process(e,n){let o=e._zod.def;switch(o.type){case"string":{n.type="string";let{minimum:i,maximum:r,format:a,patterns:d,contentEncoding:s,laxFormat:g}=z(e);if(typeof i=="number"&&(n.minLength=i),typeof r=="number"&&(n.maxLength=r),a&&(n.format=wt[a]??a,(n.format===""||a==="time"||g)&&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(w=>({pattern:w.source}))}return}case"number":{let{minimum:i,maximum:r,multipleOf:a,exclusiveMinimum:d,exclusiveMaximum:s,isInt:g}=z(e);if(n.type=g?"integer":"number",typeof d=="number"&&d>=(i??Number.NEGATIVE_INFINITY)?n.exclusiveMinimum=d:typeof i=="number"&&(n.minimum=i),typeof s=="number"&&s<=(r??Number.POSITIVE_INFINITY)?n.exclusiveMaximum=s:typeof r=="number"&&(n.maximum=r),a){let[p,...w]=new Set(a.filter(h=>Number.isFinite(h)&&h!==0).map(Math.abs));p!==void 0&&(n.multipleOf=p),w.length&&(n.allOf=[...n.allOf??[],...w.map(h=>({multipleOf:h}))])}return}case"boolean":case"success":n.type="boolean";return;case"null":n.type="null";return;case"never":n.not={};return;case"enum":{let i=bt(o.entries);i.length===0?n.not={}:(i.every(r=>typeof r=="number")&&(n.type="number"),i.every(r=>typeof r=="string")&&(n.type="string"),n.enum=i);return}case"literal":{let i=o.values.filter(r=>r!==void 0).map(r=>typeof r=="bigint"?Number(r):r);if(o.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 r of["number","string","boolean"])i.every(a=>typeof a===r)&&(n.type=r);i.every(r=>r===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:r,mime:a}=z(e);i!==void 0&&(n.minLength=i),r!==void 0&&(n.maxLength=r),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:r}=z(e);typeof i=="number"&&(n.minItems=i),typeof r=="number"&&(n.maxItems=r),n.type="array",n.items=this.write(o.element);return}case"object":{let i=o.shape;n.type="object";let r={};n.properties=r;for(let d in i)Object.defineProperty(r,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),o.catchall?._zod.def.type==="never"?n.additionalProperties=!1:o.catchall&&(n.additionalProperties=this.write(o.catchall));return}case"union":n[o.inclusive===!1?"oneOf":"anyOf"]=o.options.map(i=>this.write(i));return;case"intersection":{let i=d=>"allOf"in d&&Object.keys(d).length===1,r=this.write(o.left),a=this.write(o.right);n.allOf=[...i(r)?r.allOf:[r],...i(a)?a.allOf:[a]];return}case"tuple":{let i=o.items;n.type="array",n.prefixItems=i.map(s=>this.write(s)),o.rest?n.items=this.write(o.rest):n.items=!1;let r=i.length;for(;r>0&&L(i[r-1])!==void 0;)r-=1;r>0&&(n.minItems=r),o.rest||(n.maxItems=i.length);let{minimum:a,maximum:d}=z(e);typeof a=="number"&&(n.minItems=a),typeof d=="number"&&(n.maxItems=d);return}case"record":{let i=o.keyType;n.type="object";let r=z(i).patterns;if(o.mode==="loose"&&r&&r.size>0){let d=this.write(o.valueType),s={};for(let g of r)s[g.source]=d;n.patternProperties=s}else n.propertyNames=Ze(this.write(i)),n.additionalProperties=this.write(o.valueType);let a=i._zod.values;if(a&&!o.partial&&L(o.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(o.innerType),{type:"null"}];return;case"default":case"prefault":{let i=o.defaultValue,r,a=!1,d=JSON.stringify(i,(s,g)=>typeof g=="bigint"?(a=!0,null):g);return!a&&d!==void 0&&(r=JSON.parse(d)),a||(n[o.type==="default"?"default":"_prefault"]=r),o.innerType}case"catch":{try{n.default=o.catchValue(void 0)}catch{}return o.innerType}case"readonly":return n.readOnly=!0,o.innerType;case"pipe":return o.in._zod.traits.has("$ZodTransform")?o.out:o.in;case"lazy":return e._zod.innerType;case"optional":case"nonoptional":case"promise":return o.innerType;default:return}}};function Ye(t,e=()=>{}){let n=t,o=new B(e,new Map),i=o.write(n,!0);if(o.cyclic.size>0){let r=new Map,a=0,d=[];for(let g of o.cyclic.keys())if(g===n)r.set(g,"#");else{let p=`__schema${a++}`;r.set(g,`#/$defs/${p}`),d.push([g,p])}o=new B(e,r),i=o.write(n,!0);let s={};for(let[g,p]of d)s[p]=o.write(g,!0);d.length>0&&(i={...i,$defs:s})}return JSON.parse(JSON.stringify({$schema:"https://json-schema.org/draft/2020-12/schema",...i}))}function Xe(t){return Ye(t,Ot)}var vt={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string"},At={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 Ot(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 "),g=`${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(g)||(t.jsonSchema.description=`${typeof p=="string"&&p?`${p.replace(/\.?$/,".")} `:""}${g}`)}if(ke(t.zodSchema)&&(t.jsonSchema["x-graview-repeat"]=!0,!t.jsonSchema.type&&!t.jsonSchema.anyOf&&!t.jsonSchema.oneOf&&Object.assign(t.jsonSchema,Rt())),be(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=_e(t.zodSchema);if(n){let s=t.jsonSchema;s["x-graview-type"]=n,n==="duration"&&(s["x-graview-unit"]="minutes"),s.description??=At[n]}let o=Re(t.zodSchema,!1);if(o){let s=Ie(o);t.jsonSchema["x-graview-format"]=s.format??"unit",s.currency&&(t.jsonSchema["x-graview-currency"]=s.currency),s.unit&&s.format!=="money"&&(t.jsonSchema["x-graview-unit"]=s.unit);let g=t.jsonSchema.description;t.jsonSchema.description=typeof g=="string"&&g.length>0?`${g} ${Y(s)}`:Y(s)}let i=t.zodSchema._zod?.def;if(!i||i.type!=="string"||typeof i.format!="string"||i.format==="regex")return;let r=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 r.pattern;let d=r.allOf;Array.isArray(d)&&d.every(s=>typeof s=="object"&&s!==null&&Object.keys(s).length===1&&"pattern"in s)&&delete r.allOf,r.format=vt[i.format]??i.format,a.length===1?r.pattern=a[0]:a.length>1&&(r.allOf=a.map(s=>({pattern:s})))}function te(t,e){let n=C(t.input),o=Xe(t.input);if(e&&o.properties){let r=a=>e.includes(a)?e.indexOf(a):e.length;o.properties=Object.fromEntries(Object.entries(o.properties).sort(([a],[d])=>r(a)-r(d)))}let i=o.properties??{};if(Ae(t)){let r=t.creates.join(" | ");i.id={type:"string",minLength:1,description:`Optional: the id for the ${r} this makes, beginning with its kind (${t.creates.map(a=>`"${a}:"`).join(" or ")}). Refused if the graph already has it; left out, one is minted from the label.`},o.properties=i}Oe(t)&&(o.additionalProperties=!1);for(let r of n){let a=i[r.name];if(!a)continue;let d=r.kinds.includes("*")?"any node kind":r.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:o,nodeRefs:n}}function Rt(){let t={type:"string",pattern:"^\\d{4}-\\d{2}-\\d{2}$"},e=(n,o)=>({type:"integer",minimum:n,maximum:o});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:[...we]},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 Qe(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=Qe(e),o=p=>{if(p.kind==="rule")return!1;let w=Qe(p);if(w.size===0)return!1;for(let h of w)if(n.has(h))return!1;return!0},i,r=()=>{if(i)return i;i=new Map;for(let p of t.log.live()){if(p.undoes!==void 0)continue;let w=o(p.author)?p.author:void 0;for(let h of p.primitives){h.op==="remove-node"&&i.delete(h.node.id);let k=h.op==="add-node"?h.node.id:h.op==="patch-node"||h.op==="splice-text"?h.id:void 0;if(k===void 0)continue;let R=h.op==="add-node"?Object.keys(h.node):h.op==="splice-text"?[h.field]:Object.keys(h.after),v=i.get(k);(h.op==="add-node"||!v)&&i.set(k,v=new Map);for(let A of R)A==="id"||A==="kind"||(w?v.set(A,w):v.delete(A))}}return i},a=t.schema,d=new Map,s=(p,w)=>{let h=`${p}\0${w}`,k=d.get(h);if(k===void 0){let R=a.tryDefinition(p)?.fields?.shape;k=R!==void 0&&w in R&&Le(R[w]).type==="text",d.set(h,k)}return k},g=p=>t.graph.getNode(p)?.kind;return{prose:s,say:p=>F(p,{graph:t.graph,schema:a}),fieldBy(p,w){let h=g(p);if(!(h===void 0||!s(h,w)))return r().get(p)?.get(w)},recordBy(p){let w=g(p),h=r().get(p);if(w===void 0||!h)return;let k;for(let[R,v]of h)s(w,R)&&(k=v);return k}}}var ne=(t,e,n)=>({untrusted:!0,authoredBy:n.say(e),text:t}),_t="the host's ranker";function et(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:_t,text:n.why.matched}}});let o=e.recordBy(n.id);if(!o)return n;let i=e.prose(n.kind,n.why.field)?e.fieldBy(n.id,n.why.field):o;return{...n,label:ne(n.label,o,e),...n.apart!==void 0?{apart:ne(n.apart,o,e)}:{},why:i?{...n.why,fragment:ne(n.why.fragment,i,e)}:n.why}})}}var ie=(t,e,n)=>({title:t,readOnlyHint:e,destructiveHint:!1,idempotentHint:n,openWorldHint:!1}),Tt={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)},xt={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)},Pt={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)},oe=[Tt,xt,Pt];var it=t=>({type:"string",enum:[...t],description:"The workflow, by its name."}),tt=t=>({name:"run_workflow",title:"Run a workflow now",description:"Run one of the app's workflows now, by hand, as the app's own actor: its steps make, change, set aside or suggest what they say, as its approve setting says. With dryRun: true nothing is kept and the answer says what it would do. The first run after a workflow is added or changed is a dry run whatever you ask; run it again to keep it. A paused workflow only dry-runs. Returns the run: its outcome, what it made, changed, archived and suggested, what it held back and why.",inputSchema:{type:"object",properties:{name:it(t),dryRun:{type:"boolean",description:"Keep nothing; say what it would do. False when unsaid."}},required:["name"],additionalProperties:!1},mutating:!0,annotations:{title:"Run a workflow now",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1}}),nt=(t,e)=>({name:t?"pause_workflow":"resume_workflow",title:t?"Pause a workflow":"Resume a workflow",description:t?"Pause one of the app's workflows: it runs on no schedule and no change until it is resumed, and run_workflow only dry-runs it. Changes the app's declaration, not its records. Returns the edit that takes it back.":"Resume a paused workflow: it runs again on its schedule and the changes it waits for. Changes the app's declaration, not its records. Returns the edit that takes it back.",inputSchema:{type:"object",properties:{name:it(e)},required:["name"],additionalProperties:!1},mutating:!0,annotations:{title:t?"Pause a workflow":"Resume a workflow",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}}),ot=["run_workflow","pause_workflow","resume_workflow"];function rt(t,e){return e===void 0||t.length===0?[]:e==="manage"?[tt(t),nt(!0,t),nt(!1,t)]:[tt(t)]}function Mt(t){return{run:t.id,workflow:t.workflow,outcome:t.outcome,dry:t.dry,made:t.made,changed:t.changed,archived:t.archived,suggested:t.suggested,heldBack:t.heldBack,notes:t.notes}}async function at(t,e,n){let o=n.workflows.declared(),i=o.map(w=>w.name),r=String(e.name??"");if(!i.includes(r))return{ok:!1,error:`No workflow is called "${r}". The app's workflows are: ${i.join(", ")||"none"}. Nothing was changed.`,reason:"invalid"};if(t==="run_workflow"){let w=await n.workflows.run(r,{dryRun:e.dryRun===!0,...n.principal.id!==void 0?{who:n.principal.id}:{}});return{ok:!0,data:Mt(w)}}let a=n.workflows.edit;if(!a)return{ok:!1,error:"This seat's host does not write the app's declaration, so it cannot pause or resume a workflow. Nothing was changed.",reason:"forbidden"};let d=t==="pause_workflow",s=o.find(w=>w.name===r),g=s.status;if(g==="paused"===d)return{ok:!0,data:{workflow:r,status:g,said:`\u201C${s.title}\u201D is already ${g}. Nothing was changed.`}};let p=await a({op:d?"pause-workflow":"resume-workflow",name:r});return p.ok?{ok:!0,data:{workflow:r,status:d?"paused":"active",...p.said?{said:p.said}:{},undo:{op:d?"resume-workflow":"pause-workflow",name:r}}}:{ok:!1,error:p.error}}var q=t=>{let e;return()=>e??=t().catch(n=>{throw e=void 0,n})},Nt=q(()=>(__graviewPreload(import.meta.url,["./chunk.CCCONK73.js","./chunk.IO5VFTXC.js","./chunk.WV6SP6IJ.js","./chunk.B422DSYN.js","./chunk.ZE5RSKXF.js","./chunk.DKUEZPGR.js","./chunk.EP7YT7LT.js","./chunk.I7KN732Z.js","./chunk.TLPCYKLW.js","./chunk.P26ATAAI.js","./chunk.FIY4RUK5.js","./chunk.IY3DV52G.js","./chunk.DHPXRDT5.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.2WFOKJB4.js"))),$t=()=>(__graviewPreload(import.meta.url,["./chunk.HCX6KPRF.js","./chunk.EP7YT7LT.js","./chunk.I7KN732Z.js","./chunk.TLPCYKLW.js","./chunk.DHPXRDT5.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.AHYMIVBX.js")).catch(()=>{}),Dt=async()=>{(await $t())?.judgeWithLines()},W=q(()=>(__graviewPreload(import.meta.url,["./chunk.WVUJXDXZ.js","./chunk.B422DSYN.js","./chunk.ZE5RSKXF.js","./chunk.DKUEZPGR.js","./chunk.EP7YT7LT.js","./chunk.I7KN732Z.js","./chunk.TLPCYKLW.js","./chunk.FIY4RUK5.js","./chunk.IY3DV52G.js","./chunk.DHPXRDT5.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.4FJ4OPSJ.js"))),Jt=q(()=>(__graviewPreload(import.meta.url,["./chunk.HU3KEWFO.js","./chunk.G4JJXA63.js","./chunk.TBY5IR7C.js","./chunk.WFJCC6G3.js","./chunk.BIDL7GQD.js","./chunk.IO5VFTXC.js","./chunk.UPOYRCKI.js","./chunk.XOZU4OFA.js","./chunk.WV6SP6IJ.js","./chunk.Q5WEOX3Q.js","./chunk.MATUPDZ3.js","./chunk.SAWASNDO.js","./chunk.HCX6KPRF.js","./chunk.WVUJXDXZ.js","./chunk.B422DSYN.js","./chunk.ZE5RSKXF.js","./chunk.DKUEZPGR.js","./chunk.EP7YT7LT.js","./chunk.I7KN732Z.js","./chunk.TLPCYKLW.js","./chunk.MH3AQO2R.js","./chunk.J2N7EKMX.js","./chunk.P26ATAAI.js","./chunk.FIY4RUK5.js","./chunk.IY3DV52G.js","./chunk.DHPXRDT5.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.AMV2ILR6.js"))),Et=q(()=>(__graviewPreload(import.meta.url,["./chunk.ZU3RPI34.js","./chunk.CCCONK73.js","./chunk.IO5VFTXC.js","./chunk.7L3I776Z.js","./chunk.CLIC2QBA.js","./chunk.WV6SP6IJ.js","./chunk.B422DSYN.js","./chunk.ZE5RSKXF.js","./chunk.DKUEZPGR.js","./chunk.EP7YT7LT.js","./chunk.I7KN732Z.js","./chunk.TLPCYKLW.js","./chunk.MH3AQO2R.js","./chunk.J2N7EKMX.js","./chunk.P26ATAAI.js","./chunk.FIY4RUK5.js","./chunk.IY3DV52G.js","./chunk.DHPXRDT5.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.AMAOZVEO.js"))),Ht=q(()=>(__graviewPreload(import.meta.url,["./chunk.EQZPEOIW.js","./chunk.ZQYHNFRZ.js","./chunk.EP7YT7LT.js","./chunk.I7KN732Z.js","./chunk.TLPCYKLW.js","./chunk.DHPXRDT5.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.TQQDUJLX.js"))),jt=t=>t.definitions.some(e=>Z(e).size>0),st=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 zt(t,e,n,o){let i=String(n.relation??""),[r,a]=i.includes(".")?i.split(".",2):[void 0,i],d=t.schema.definitions.flatMap(A=>[...Z(A)].map(([m,u])=>({kind:A.kind,name:m,relation:u}))),s=d.filter(A=>A.name===a&&(r===void 0||A.kind===r));if(s.length!==1){let A=d.map(m=>`${m.kind}.${m.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: ${A}.`}}let{kind:g,name:p,relation:w}=s[0];if(!o)return{ok:!1,error:`This seat cannot read ${w.address}: its host reads no other app's records. Nothing was changed.`};let h={kind:e.kind,...e.id===void 0?{}:{id:e.id},...e.roles?{roles:e.roles}:{},...e.onBehalfOf?{onBehalfOf:e.onBehalfOf}:{}},k=typeof n.of=="string"?n.of:void 0;if(k!==void 0){let A=t.graph.getNode(k);if(!A||A.kind!==g)return{ok:!1,error:`No ${g} "${k}".`};let m=he(A[p],w),u=await Promise.all(m.map(b=>Promise.resolve().then(()=>o.resolve(b,h)).catch(()=>null)));return{ok:!0,data:{relation:`${g}.${p}`,app:w.address,records:u.map((b,S)=>b===null?{value:K(m[S]),missing:!0}:"denied"in b?{denied:!0,said:"linked record (no access)"}:st(b))},reads:[k]}}let R=typeof n.limit=="number"&&n.limit>0?Math.min(n.limit,20):20,v=await Promise.resolve().then(()=>o.find({address:w.address,kinds:w.kinds,query:String(n.query??""),limit:R},h)).catch(()=>[]);return Array.isArray(v)?{ok:!0,data:{relation:`${g}.${p}`,app:w.address,records:v.map(st),link:`edit-${g} with ${p} set to a record's value`}}:{ok:!0,data:{relation:`${g}.${p}`,app:w.address,denied:!0,said:"linked record (no access)"}}}var M=t=>({title:t,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}),dt={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"]}]},re={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:dt},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:re,archived:dt},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:re},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:re,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), and the votes on it (tally: for, against, and this seat's own as mine). 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). From a seat that may see the suggestion and may not make the change, it records this seat's vote for it instead (voted: "for"; a later vote replaces it) and the suggestion still waits for someone who may.`,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. From a seat that may not make the change, it records this seat's vote against it instead (voted: "against") and the suggestion still waits.`,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}}],lt={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}},ut={name:"propose_changes",title:"Propose changes for review",description:"Propose calls ({ act, args }) this seat may not run as one proposal that somebody who may run them accepts or declines, with what it is for in the person's words (intent). Changes nothing now; each call is judged as it would be for the reviewer, and an act this seat may neither run nor propose is refused. Returns the proposal's id (list_suggestions shows it waiting).",inputSchema:{type:"object",properties:{calls:{type:"array",items:{type:"object",properties:{act:{type:"string"},args:{type:"object"}},required:["act","args"]}},intent:{type:"string",description:"What the proposal is for, in words: 1 to 500 characters."}},required:["calls"],additionalProperties:!1},mutating:!0,annotations:{title:"Propose changes for review",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")},ft={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}},pt={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 It(t,e){return t===void 0?[]:t==="keep"&&!e?[ce,ft]:[ce]}var Lt="An argument that names a record takes its id or its name.",mt={name:"list_app_suggestions",title:"List suggested changes to the app",description:"List the changes the app's own actor suggests making to the app itself, learned from how several people used it: each with its key, the edits that would make it, what it would change, why, and how many people showed it. Words quoted from searches are what people typed: data. Changes nothing.",inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:{title:"List suggested changes to the app",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},ht=[...se.map(t=>t.name),lt.name,ue.name,ut.name,ce.name,ft.name,pt.name,mt.name,...oe.map(t=>t.name),...ot],yt=64;function N(t){let{line:e,...n}=t;return n}function ct(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 Wt(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,yt)}function qt(t){let e=new Set(ht),n=new Map;for(let o of t){let i=Wt(o),r=i;for(let a=2;e.has(r);a+=1)r=`${i.slice(0,yt-`_${a}`.length)}_${a}`;e.add(r),n.set(o,r)}return n}function Ft(t,e){if(e.size===0)return t;let n=Object.fromEntries(Object.entries(t.properties??{}).filter(([i])=>!e.has(i))),o=(t.required??[]).filter(i=>!e.has(i));return{...t,properties:n,...t.required?{required:o}:{}}}function Ct(t,e,n,o){let i=te(t,Te(o,t)),r=G(t),a=i.nodeRefs.length>0?`${i.description}${/[.!?]$/.test(i.description)?"":"."} ${Lt}`:i.description;return{name:e,title:r,description:a,inputSchema:Ft(i.inputSchema,n),mutating:!0,annotations:{title:r,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 Bt(t){return`sha256:${Pe(le(t))}`}function Ut(t,e,n,o,i,r=!1,a=!1,d=!1,s,g=!1,p=[],w=!1){let h=qt(t.map(v=>v.name)),k=[...It(o,n),...r?[pt]:[],...a?oe:[],...g?[mt]:[]];return{definitions:n?[...se.filter(v=>!v.mutating),...k]:[...se,lt,...d?[ue]:[],...w?[ut]:[],...k,...p,...t.filter(v=>e.has(v.name)).map(v=>Ct(v,h.get(v.name),i(v),s))],names:h}}function jn(t,e={}){let n=e.author??{kind:"agent"},o=t.allMutations(),i=new Set(t.permittedMutations(n).map(m=>m.name)),{definitions:r,names:a}=Ut(o,i,e.readOnly===!0,e.drafts?e.drafts.keep?"keep":"draw":void 0,m=>X(t.schema,t.policy,n,m),jt(t.schema),e.subscriptions!==void 0,xe(n),t.schema,e.learned!==void 0,rt(e.workflows?.declared().map(m=>m.name)??[],e.workflows?e.workflows.edit?"manage":"run":void 0),ze(t.policy,n,o).length>0),d=Bt(r),s={app:e.app?.brand?.locale,appTimeZone:e.app?.brand?.timeZone},g=m=>pe(s,m),p=m=>{if(!ht.includes(m)){for(let[u,b]of a)if(b===m)return u;return a.has(m)?m:Me(m,a.keys())}},w=m=>{let u=Ne(m,a.keys());return u?` Did you mean "${u}"?`:""},h=m=>{let u=r.find(S=>S.name===m)??r.find(S=>S.act===m);if(u)return u;let b=p(m);return b===void 0?void 0:r.find(S=>S.act===b)},k=(m,u)=>{let b=o.find(l=>l.name===m);if(!b)return{args:u,resolved:[]};let S={...u},c=[];for(let l of C(b.input)){let f=S[l.name];if(typeof f!="string"||f.trim()==="")continue;let y=t.resolveRef(l,f,n);if(!y.ok){let O=y.reason==="none"?` Nothing was changed. Use search_graph to look it up, then pass its id as ${l.name}.`:" Nothing was changed.";return{ok:!1,error:`${y.message}${O}`,argument:l.name,candidates:y.candidates}}y.by!=="id"&&(S[l.name]=y.id,c.push({argument:l.name,given:f,id:y.id,label:y.label}))}return{args:S,resolved:c}},R=async(m,u)=>{try{await Dt();let b=h(m);if(!b&&m===ue.name)return{ok:!1,error:"Only the app's own actor (automated: true) suggests changes.",reason:"forbidden"};if(!b){let c=p(m);if(c){let l=t.permits({name:c,args:u},n);if(!l.ok)return{ok:!1,error:l.refusal.message,reason:"forbidden"}}return{ok:!1,error:`Unknown tool "${m}".${w(m)} Available: ${r.map(l=>l.name).join(", ")}`}}if(b.mutating&&e.readOnly)return{ok:!1,error:`"${m}" changes the graph, and this seat is read-only.`,reason:"forbidden"};if(b.act!==void 0){let c=k(b.act,u);if("ok"in c)return c;let l=b.act,f=g(()=>j(t,n,t.apply({name:l,args:c.args},{...e.author?{author:e.author}:{},...V(e.via)})));return{ok:!0,data:{batch:f.batch,intent:f.intent,introduces:f.introduces.map(N),resolves:f.resolves.map(N),...c.resolved.length>0?{resolved:c.resolved}:{}},diff:f.diff}}let S=t.seenBy(n);switch(b.name){case"search_graph":{let c=typeof e.places=="function"?e.places():e.places,l=typeof u.subject=="string"?u.subject:void 0,f=qe(S,String(u.query??""),{principal:n,rank:e.near,archived:Se(u.archived),limit:typeof u.limit=="number"&&u.limit>0?Math.min(u.limit,20):20,...c?{places:c}:{},...l?{subject:l,from:[l]}:{}}),y=f.later?await f.later:f;return{ok:!0,data:(await W()).searchRead(y,et(y,U(S,n))),reads:y.hits.flatMap(O=>O.about==="node"?[O.id]:[])}}case"get_graph":return{ok:!0,...(await W()).graphRead(S,U(S,n),u)};case"get_node":{let c=String(u.id??""),l=c,f;if(!S.graph.getNode(c)){let O=c.trim()===""?void 0:t.resolveRef({name:"id",kinds:["*"]},c,n);if(O?.ok)l=O.id,f={argument:"id",given:c,id:l,label:O.label};else return O?.reason==="ambiguous"?{ok:!1,error:O.message,argument:"id",candidates:O.candidates}:{ok:!1,error:`No node "${c}".`}}let y=(await W()).nodeRead(S,U(S,n),l,u);return{ok:!0,data:f?{...y.data,resolved:[f]}:y.data,reads:y.reads}}case"describe_place":{let c=e.app??{name:"",schema:t.schema},l=typeof u.width=="number"&&Number.isFinite(u.width)&&u.width>0?u.width:1440,{describePlace:f}=await Nt(),y=f(t,n,String(u.place??""),{app:c,width:l});if(!y.ok)return{ok:!1,error:`${y.error} The places are: ${y.places.join(", ")}.`};let O=new Set,P=I=>{for(let D of I)for(let x of D.groups??[])for(let $ of x.items)O.add($.id),P($.parts)};return P(y.description.parts),{ok:!0,data:y.description,reads:[...O]}}case"find_linked":return zt(S,n,u,e.linked);case"draft_view":case"keep_lens":{let c=e.app??{name:"",schema:t.schema};return(await Jt()).runDraftTool(b.name,u,{app:c,principal:n,...e.drafts?{drafts:e.drafts}:{}})}case"get_violations":{let c=S.violations(u.context);return{ok:!0,...(await W()).violationsRead(c,u)}}case"get_affordances":{let c=u.selection??[];return{ok:!0,data:We(S,c,{...typeof e.derive=="function"?e.derive():e.derive,...e.author?{principal:e.author}:{},...u.context?{context:u.context}:{}}),reads:c.filter(f=>S.graph.has(f))}}case"preview_mutation":{let c=String(u.mutation),l=p(c)??c,f=k(l,u.args??{});if("ok"in f)return f;let y=t.missingFor({name:l,args:f.args},n);if(y)return{ok:!1,error:y.message,reason:"missing"};let O=j(t,n,t.preview({name:l,args:f.args},void 0,{author:n})),P=ct(O);return{ok:!0,data:f.resolved.length>0?{...P,resolved:f.resolved}:P}}case"act_on_several":{let c=String(u.act??""),l=p(c)??c,f=o.find(_=>_.name===l);if(!f||!i.has(l)){let _=f?t.permits({name:l,args:{}},n):void 0;return _&&!_.ok?{ok:!1,error:_.refusal.message,reason:"forbidden"}:{ok:!1,error:`There is no act "${c}" this seat may run.${w(c)} Nothing was changed.`,reason:"invalid"}}let y=f.subject;if(!y)return{ok:!1,error:`"${G(f)}" does not act on a record, so it cannot be run on several. Nothing was changed.`,reason:"invalid"};let O=Array.isArray(u.records)?u.records.filter(_=>typeof _=="string"&&_.trim()!==""):[];if(O.length===0)return{ok:!1,error:"Name at least one record. Nothing was changed.",reason:"invalid"};let P=[],I=[];for(let _ of O.slice(0,200)){let J=t.resolveRef({name:y.arg,kinds:y.kinds},_,n);if(!J.ok)return{ok:!1,error:`${J.message} Nothing was changed.`,argument:"records",candidates:J.candidates};P.push(J.id),J.by!=="id"&&I.push({argument:"records",given:_,id:J.id,label:J.label})}let D=k(l,{...u.args??{}});if("ok"in D)return D;let x=(await Et()).actOnSeveral(t,{mutation:l,subject:y.arg,args:D.args},P,{author:n,...V(e.via)}),$=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(_=>({record:_.id,label:_.label,error:_.message,reason:_.reason})),...x.allOrNothing?{keptNone:!0}:{},...$?{introduces:$.introduces.map(N),resolves:$.resolves.map(N)}:{},...I.length>0||D.resolved.length>0?{resolved:[...I,...D.resolved]}:{}},...$?{diff:$.diff}:{}}}case"subscribe":case"unsubscribe":case"list_subscriptions":{let c=await(await Ht()).runSubscriptionTool(b.name,u,{store:t,principal:e.subscriber??n,app:e.app?.name??"app",subscriptions:e.subscriptions});return c.ok?{ok:!0,data:c.data}:{ok:!1,error:c.error}}case"run_workflow":case"pause_workflow":case"resume_workflow":{let c=await at(b.name,u,{principal:n,workflows:e.workflows});return c.ok?{ok:!0,data:c.data}:{ok:!1,error:c.error,...c.reason?{reason:c.reason}:{}}}case"list_app_suggestions":return{ok:!0,data:{suggestions:(await e.learned()).map(({key:l,said:f,why:y,edits:O,evidence:P})=>({key:l,said:f,why:y,edits:O,evidence:P}))}};case"list_suggestions":{let c=De(t,n).map(l=>{let f=F(l.author,{graph:S.graph,schema:t.schema});return{id:l.id,intent:l.intent,by:f,at:l.at,about:l.about,tally:l.tally,...He(l)?{proposedBy:l.lineage.proposedBy}:{},...l.lineage?{basis:{untrusted:!0,authoredBy:f,text:l.lineage.basis},...l.lineage.confidence!==void 0?{confidence:l.lineage.confidence}:{}}:{}}});return{ok:!0,data:{suggestions:c},reads:[...new Set(c.flatMap(l=>l.about))]}}case"suggest_changes":{let c=u.calls.map(f=>({name:p(f.act)??f.act,args:f.args}));return{ok:!0,data:{suggestion:$e(t,c,{author:n,lineage:{basis:u.basis,confidence:u.confidence},...V(e.via)})?.id??null}}}case"propose_changes":{let c=(u.calls??[]).map(y=>({name:p(y.act)??y.act,args:y.args??{}})),l=typeof u.intent=="string"&&u.intent.trim()!==""?u.intent.trim():void 0,f=je(t,n,c,l);return{ok:!0,data:{proposal:f?.id??null,...f?{intent:f.intent}:{}}}}case"accept_suggestion":case"decline_suggestion":{let c=String(u.suggestion??""),l={author:n,...V(e.via)},f=b.name==="accept_suggestion"?Je(t,c,l):Ee(t,c,l),y=j(t,n,f);return{ok:!0,data:{batch:y.batch,intent:y.intent,...f.voted?{voted:f.voted}:{},introduces:y.introduces.map(N),resolves:y.resolves.map(N)},diff:y.diff}}case"undo_batch":{let c=String(u.batch),l=u.include??[],f=S.canUndo([c,...l]);if(!f.ok)return{ok:!1,error:f.message};let y=j(t,n,t.undo([c,...l],{...e.author?{author:e.author}:{}}));return{ok:!0,data:ct(y),diff:y.diff}}default:return{ok:!1,error:`Unknown tool "${m}".`}}}catch(b){let{reason:S,wouldNeed:c}=ve(b);return{ok:!1,error:b instanceof Error?b.message:String(b),reason:S,...c?{wouldNeed:c}:{}}}},v=new Set,A=m=>{for(let u of v)u(m)};return{definitions:r,hash:d,...e.author?{author:e.author}:{},onDiff(m){return t.subscribe(m)},onCall(m){return v.add(m),()=>v.delete(m)},async call(m,u){let b=h(m)?.mutating??!1,S={name:m,args:u,mutating:b,at:new Date().toISOString()};A({...S,phase:"running"});let c=f=>(A(f.ok?{...S,phase:"ok",...!b&&f.reads?{reads:f.reads}:{}}:{...S,phase:"failed",error:f.error}),f),l=await R(m,u);return c(l.ok&&!b?{...l,data:(await W()).withinReadChars(m,l.data)}:l)}}}function V(t){let e=typeof t=="function"?t():t;return e?{via:e}:{}}export{le as a,jn as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as U,b as Y,c as G,d as D}from"./chunk.
|
|
1
|
+
import{a as U,b as Y,c as G,d as D}from"./chunk.ZQYHNFRZ.js";import"./chunk.NLZHNPDU.js";import"./chunk.QNC2OKLF.js";import{G as ae,R as L,S as F,W as V,fa as _}from"./chunk.FWXW4T4I.js";import"./chunk.SDO3U72B.js";import{W as H,db as K,eb as B,td as M}from"./chunk.DHPXRDT5.js";import"./chunk.FQLNBIQ5.js";import{b as R}from"./chunk.AJZBJBMO.js";function O(n,t){let r=K(n);return r==="agent"?"agent":r!=="human"&&r!=="visitor"?"app":n.onBehalfOf!==void 0?"person":n.id===void 0||t?.id===void 0||n.id===t.id?"you":"person"}var re=n=>n.ops.filter(t=>t.withheld!==!0);function X(n,t={}){let r=[];for(let e of n.batches()){let s=e.ops[0],d=e.ops.at(-1),l=re(e).length===0,h=l?void 0:Y(e.ops),c=r.at(-1);if(h&&c?.typed&&c.author&&U(c.author,e.author)&&c.typed.node===h.node&&c.typed.field===h.field){let S=G(c.typed,h);r[r.length-1]={...c,seq:d.seq+1,at:d.at,batch:e.id,batches:[...c.batches??[],e.id],typed:S,said:D(S,n.schema,n.graph,!1)};continue}r.push({seq:d.seq+1,from:s.seq,at:d.at,batch:e.id,maker:l?"person":O(e.author,t.me),author:l?void 0:e.author,said:h?D(h,n.schema,n.graph,!1):e.intent,declaration:!1,withheld:l,...h?{batches:[e.id],typed:h}:{}})}let i=[...n.log.epochs().filter(e=>e.change!==void 0).map(e=>({seq:e.seq,sentence:e.change,...e.at?{at:e.at}:{}})),...t.declarations??[]];for(let e of i){if(e.seq<n.log.horizon||e.seq>n.log.length)continue;let s=r.findIndex(d=>d.seq===e.seq);if(s>=0&&!r[s].withheld){r[s]={...r[s],declaration:!0,said:e.sentence};continue}r.push({seq:e.seq,from:e.seq,at:e.at,batch:void 0,maker:e.author?O(e.author,t.me):"app",author:e.author,said:e.sentence,declaration:!0,withheld:!1})}return r.sort((e,s)=>e.seq-s.seq||+(e.batch!==void 0)-+(s.batch!==void 0))}function J(n,t){let r=n.log.all(),i=new Map(r.map(e=>[e.id,e.seq]));return n.batches().filter(e=>!e.undone&&e.ops[0].seq>=t).filter(e=>!e.ops.every(s=>s.sentOut!==void 0)).filter(e=>!e.ops.every(s=>s.undoes!==void 0&&(i.get(s.undoes)??-1)>=t)).map(e=>e.id)}function Q(n,t){return n.withheld?"Someone":n.maker==="you"?"you":n.author?B(n.author,t):"the app"}var p=R(ae(),1);var o=R(V(),1),oe={kind:"human"},ie=[1,2,4,8],se=900,E={you:"You",person:"A person",agent:"An agent",app:"The app"},Z={you:"var(--graview-accent)",person:"var(--graview-ink-muted)",agent:"var(--graview-activity, var(--graview-good))",app:"var(--graview-edge-bright)"};function de(n,t,r){return[...new Set([...r,t,...n.map(i=>i.seq)])].sort((i,e)=>i-e)}function le(n,t){let r=n.withheld===!0;return{seq:n.seq+1,from:n.seq,at:n.at,batch:n.batch,maker:r?"person":O(n.author,t),author:r?void 0:n.author,said:n.batchIntent??n.intent,declaration:!1,withheld:r}}function ce(n,t){let r=0;for(let i=0;i<n.length;i++)n[i]<=t&&(r=i);return r}function pe(n,t,r){let i=J(n,t);if(i.length===0)return null;let e=n.canUndo(i);if(!e.ok)return null;let s=new Set(n.permittedMutations(r).map(d=>d.name));return e.ops.every(d=>d.mutation!==null&&s.has(d.mutation.name))?i:null}function we({face:n}){let t=L(),r=_(),i=r?.principal??oe,e=F(t.live,i),s=e.log.length,d=(0,p.useMemo)(()=>X(e,{me:i,...t.host?.declarations?{declarations:t.host.declarations}:{}}),[e,i,t.host,s]),l=e.log.horizon,h=l>0&&t.host?.archived!==void 0,c=t.kept,S=(0,p.useMemo)(()=>h?c?.stops??Array.from({length:l},(a,g)=>g):[],[h,c,l]),m=(0,p.useMemo)(()=>de(d,l,S),[d,l,S]),f=t.archive,y=f?.seq??t.past?.seq??s,x=t.host?.kept&&(f?.behindKept||c!==void 0&&(y<=c.through||c.from>0&&y<=c.from))?t.host.kept:void 0,w=ce(m,y),b=m.length-1,j=y<l&&t.past?.seq===y?t.past.store.log.all().at(-1):void 0,q=j?le(j,i):y<l?void 0:[...d].reverse().find(a=>a.seq<=y&&a.seq>(m[w-1]??-1))??[...d].reverse().find(a=>a.seq<=y),[k,A]=(0,p.useState)(!1),[T,ee]=(0,p.useState)(1),[C,W]=(0,p.useState)(null);(0,p.useEffect)(()=>{if(!k)return;if(w>=b){A(!1);return}let a=setTimeout(()=>t.show(m[w+1]),se/T);return()=>clearTimeout(a)},[k,w,b,T,m,t]);let z=(0,p.useMemo)(()=>t.past&&!f&&y>=l?pe(e,y,i):null,[t.past,f,e,y,l,i,s]),N=a=>Q(a,{graph:e.graph,schema:e.schema,...r?.seats?{seats:r.seats}:{},...r?.people?{people:r.people}:{}}),v=t.past?t.past.at?H(t.past.at,r?.locale):"the start":null,$=f?f.refused?"The archive could not be read":f.behindKept?"Nothing this far back is kept":"Reading the older changes from the archive\u2026":q?`${N(q)==="you"?"You":N(q)}: ${q.said}`:"Nothing had happened yet",I=(0,p.useRef)(null);(0,p.useLayoutEffect)(()=>{let a=I.current,g=a?.parentElement;if(n!=="scene"||!a||!g)return;let u=()=>g.style.setProperty("--graview-sheet",`${Math.ceil(a.getBoundingClientRect().height)+24}px`);u();let P=typeof ResizeObserver>"u"?null:new ResizeObserver(u);return P?.observe(a),()=>{P?.disconnect(),g.style.removeProperty("--graview-sheet")}},[n]);let te=n==="scene"?{position:"absolute",left:"50%",bottom:12,transform:"translateX(-50%)",width:"min(720px, calc(100% - 32px))",zIndex:M("rail")}:{position:"sticky",top:0,zIndex:M("rail"),margin:"0 auto 12px",maxWidth:960,width:"100%"};return(0,o.jsxs)("section",{ref:I,"aria-label":"Timeline","data-testid":"timeline","data-graview-past":t.past?String(t.past.seq):"now","data-graview-offstage":"",style:{...te,boxSizing:"border-box",display:"grid",gap:8,padding:"10px 12px",borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)",color:"var(--graview-ink)",fontSize:"0.8125rem"},children:[(0,o.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"4px 12px"},children:[(0,o.jsx)("strong",{"data-testid":"as-of",role:"status",style:{fontWeight:600},children:f?"Archived changes":v?`As of ${v}`:"Now"}),(0,o.jsx)("span",{"data-testid":"timeline-caption",style:{color:"var(--graview-ink-muted)",minWidth:0,overflowWrap:"anywhere"},children:$}),v?(0,o.jsx)("span",{style:{color:"var(--graview-ink-faint)"},"data-testid":"past-read-only",children:"Nothing changes while you look back."}):null]}),(0,o.jsxs)("div",{style:{position:"relative",height:22},"aria-hidden":"true",children:[h?(0,o.jsx)("span",{"data-testid":"timeline-archived",title:"Changes read from the archive as you scrub back",style:{position:"absolute",left:0,bottom:0,height:6,width:`${b===0?0:m.indexOf(l)/b*100}%`,borderRadius:2,background:"var(--graview-edge)"}}):null,m.slice(1).map((a,g)=>{let u=[...d].reverse().find(ne=>ne.seq===a);if(!u)return null;let P=b===0?0:(g+1)/b*100;return(0,o.jsx)("span",{"data-graview-tick":a,"data-maker":u.maker,...u.declaration?{"data-declaration":""}:{},title:`${E[u.maker]}: ${u.said}`,style:{position:"absolute",left:`calc(${P}% - 1px)`,bottom:0,width:u.declaration?4:2,height:u.declaration?22:12,borderRadius:2,background:u.declaration?"var(--graview-ink)":Z[u.maker],opacity:a<=y?1:.45}},`${a}:${u.batch??"declaration"}`)})]}),(0,o.jsx)("input",{type:"range","data-testid":"scrubber","aria-label":"Moment",min:0,max:b,step:1,value:w,"aria-valuetext":v?`As of ${v}. ${$}`:`Now. ${$}`,onChange:a=>{A(!1),t.show(m[Number(a.currentTarget.value)]??s)},style:{width:"100%",margin:0,accentColor:"var(--graview-accent)"}}),(0,o.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:8},children:[(0,o.jsx)("button",{type:"button","data-testid":"play","aria-pressed":k,onClick:()=>{!k&&w>=b&&t.show(m[0]),A(!k)},style:{minHeight:28,minWidth:64},children:k?"Pause":"Play"}),(0,o.jsxs)("label",{style:{display:"inline-flex",alignItems:"center",gap:6,color:"var(--graview-ink-muted)"},children:["Speed",(0,o.jsx)("select",{"data-testid":"speed",value:T,onChange:a=>ee(Number(a.currentTarget.value)),style:{minHeight:28},children:ie.map(a=>(0,o.jsxs)("option",{value:a,children:[a,"\xD7"]},a))})]}),(0,o.jsx)("span",{"aria-hidden":"true",style:{display:"inline-flex",gap:10,color:"var(--graview-ink-faint)",flexWrap:"wrap"},children:Object.keys(E).filter(a=>d.some(g=>g.maker===a)).map(a=>(0,o.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[(0,o.jsx)("span",{style:{width:8,height:8,borderRadius:2,background:Z[a]}}),E[a]]},a))}),(0,o.jsxs)("span",{style:{marginLeft:"auto",display:"inline-flex",gap:8},children:[z?(0,o.jsx)("button",{type:"button","data-testid":"restore-here",title:"Take back every change since, as one change you can undo",onClick:()=>{W(null);try{e.undo([...z],{author:i,intent:v?`Restore to ${v}`:"Restore"}),t.show(null)}catch(a){W(a instanceof Error?a.message:String(a))}},style:{minHeight:28},children:"Restore to here"}):null,(0,o.jsx)("button",{type:"button","data-testid":"back-to-now",onClick:()=>t.show(null),style:{minHeight:28},children:"Back to now"})]})]}),C?(0,o.jsx)("span",{role:"alert","data-testid":"restore-refused",style:{color:"var(--graview-warn)"},children:C}):null,f?.refused?(0,o.jsx)("span",{role:"alert","data-testid":"archive-refused",style:{color:"var(--graview-warn)"},children:f.refused}):null,x?(0,o.jsxs)("span",{"data-testid":"timeline-kept",style:{color:"var(--graview-ink-faint)"},children:[x.sentence,x.action?(0,o.jsxs)(o.Fragment,{children:[" ",(0,o.jsx)("a",{"data-testid":"timeline-kept-action",href:x.action.href,style:{color:"var(--graview-ink-muted)"},children:x.action.label})]}):null]}):null,l>0&&!h?(0,o.jsx)("span",{"data-testid":"timeline-horizon",style:{color:"var(--graview-ink-faint)"},children:"The changes before the timeline's start were archived."}):null]})}export{we as Timeline};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fc as w,sc as S}from"./chunk.
|
|
1
|
+
import{fc as w,sc as S}from"./chunk.DHPXRDT5.js";function v(s){return[...s.mutations??[],...S(s.schema,s.mutations??[])]}function B(s){let i=[...s.schema.kinds],a=v(s),d=new Map,c=new Map;for(let e of a){c.set(e.name,e.creates??[]);let n=w(e.input).filter(t=>!t.optional&&!t.kinds.includes("*")).flatMap(t=>t.kinds);d.set(e.name,[...new Set(n)])}let g=new Map;for(let e of i)g.set(e,[]);for(let e of a)for(let n of c.get(e.name)??[])g.get(n)?.push(e.name);let p=new Map,l=new Set;for(let e=0;;e+=1){let n=[];for(let t of a)if((d.get(t.name)??[]).every(o=>l.has(o)))for(let o of c.get(t.name)??[])l.has(o)||n.push(o);if(n.length===0)break;for(let t of n)l.add(t),p.set(t,e)}let h=e=>{let n=g.get(e)??[];if(n.length===0)return[];let t=n.map(r=>d.get(r)??[]).sort((r,o)=>r.length-o.length)[0];return[...new Set(t)].filter(r=>r!==e)},y=new Map,u=e=>{let n=y.get(e);if(n)return n;let t=new Set;y.set(e,t);for(let r of h(e)){t.add(r);for(let o of u(r))t.add(o)}return t.delete(e),t},f=new Map(i.map(e=>[e,0]));for(let e of i)for(let n of u(e))f.set(n,(f.get(n)??0)+1);let m=i.map(e=>({kind:e,madeBy:[...g.get(e)??[]].sort(),needs:[...h(e)].sort(),depth:p.get(e)??null})).sort((e,n)=>(e.depth??Number.MAX_SAFE_INTEGER)-(n.depth??Number.MAX_SAFE_INTEGER)||(f.get(n.kind)??0)-(f.get(e.kind)??0)||e.kind.localeCompare(n.kind)),k=m.filter(e=>e.depth===0).map(e=>e.kind),A=[...new Set(a.filter(e=>(d.get(e.name)??[]).length===0).filter(e=>(c.get(e.name)??[]).length>0).map(e=>e.name))].sort(),M=m.filter(e=>e.depth===null).map(e=>({kind:e.kind,why:e.madeBy.length===0?"no act declares that it creates this kind":`every act that makes it needs ${e.needs.map(n=>`"${n}"`).join(", ")}, which nothing can make first`}));return{order:m,roots:k,doors:A,unreachable:M}}export{B as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as je,c as Ge}from"./chunk.BQAFFEOA.js";import{b as _e}from"./chunk.AWV57UBJ.js";import{a as He,b as ze,c as Ve,d as Q}from"./chunk.YBQ5GVAX.js";import"./chunk.EB7PZJEO.js";import{k as qe,l as Ke}from"./chunk.MSUZAJ2K.js";import"./chunk.64LCHHZB.js";import"./chunk.42KHFGN6.js";import"./chunk.RQG672MJ.js";import"./chunk.Q6H5HESF.js";import{e as Pe}from"./chunk.3JMQKANL.js";import{m as Be}from"./chunk.42C3FIKK.js";import{a as Fe,b as Ie}from"./chunk.2ME4DVBI.js";import{h as Me}from"./chunk.XXCHO2A5.js";import{e as Re,f as Ee}from"./chunk.SADR3MQI.js";import"./chunk.HJCQ6I3S.js";import"./chunk.2BMZPALF.js";import{e as de}from"./chunk.GONZB3J3.js";import"./chunk.LFFJB6D3.js";import"./chunk.DMZRFXH7.js";import"./chunk.DZ6UDZOB.js";import{a as Ce}from"./chunk.E423JCOS.js";import"./chunk.O5FTWXA2.js";import"./chunk.Q4VFLLUT.js";import"./chunk.6ZENHSTQ.js";import{a as De,b as Te,j as Le}from"./chunk.VTDOWXCP.js";import"./chunk.G4JJXA63.js";import{a as $e}from"./chunk.TBY5IR7C.js";import"./chunk.BHJRT57H.js";import"./chunk.BIDL7GQD.js";import"./chunk.CNN32262.js";import"./chunk.N5Z34V7U.js";import"./chunk.LOKGUALC.js";import"./chunk.JGRSUTPJ.js";import"./chunk.XOZU4OFA.js";import"./chunk.EP5JS7ZH.js";import"./chunk.Q5WEOX3Q.js";import"./chunk.KAM73WVF.js";import"./chunk.O32F6LGK.js";import"./chunk.EGSOHTZZ.js";import"./chunk.WVUJXDXZ.js";import"./chunk.L7XKYGV7.js";import{a as Ne}from"./chunk.CE3NKAF7.js";import"./chunk.R3GE37OI.js";import"./chunk.2KCDLCB2.js";import"./chunk.UD7VLXPM.js";import"./chunk.3DEWQDP7.js";import"./chunk.MIE4TJRW.js";import{s as Ae}from"./chunk.CFE3MHWZ.js";import"./chunk.RD2FSSLV.js";import"./chunk.HXTKBISQ.js";import"./chunk.TFJA4QV4.js";import"./chunk.HWFJQ42Y.js";import{d as se,l as Se}from"./chunk.QUETLFBJ.js";import{b as xe}from"./chunk.JULD4XFB.js";import"./chunk.GRTBEA7O.js";import{F as Oe,t as te}from"./chunk.H3IGXHZR.js";import"./chunk.7TDML5YU.js";import{G as st,Qa as re,Ra as ee,W as be,Z as ke,ea as K,ga as oe,j as fe,l as he,m as me,r as X,ra as ye}from"./chunk.3VEZ5MOC.js";import"./chunk.SDO3U72B.js";import{L as ge,T as ue,Z as $,cb as J,la as W,na as ae,pa as we,ra as ve}from"./chunk.6AANHELP.js";import"./chunk.FQLNBIQ5.js";import{b as ie}from"./chunk.AJZBJBMO.js";var g=ie(st(),1);var dt=300,lt=14,Z=50,pt=3,ct=2;function We(e,n,o){let s=e.tryDefinition(n)?.fields?.shape;return(s?.[o]===void 0?void 0:Ne(s[o]))?.type}var gt=(e,n)=>Object.keys(e.tryDefinition(n)?.fields?.shape??{}),ut=e=>e==="date"||e==="datetime",Qe=/^(due|dueOn|dueAt|dueDate|deadline|by)$/i,wt=/^(date|on|day|when|at|start|starts|startsOn|startsAt|begins|from|sown|scheduled|scheduledFor|planned|plannedFor)$/i,vt=/^(done|finished|complete|completed|closed)$/i;function pe(e,n){let o=e.tryDefinition(n),s=gt(e,n),a=s.filter(c=>ut(We(e,n,c)));if(a.length===0)return;let i=o?.fieldRoles??{},r=c=>i[c]!==void 0&&a.includes(i[c])?i[c]:void 0,p=r("start")??r("when")??a.find(c=>Qe.test(c))??a.find(c=>wt.test(c));if(!p)return;let k=r("end")??a.find(c=>c!==p&&/^(end|ends|until|to|finish|finished|harvested|through)$/i.test(c)),m=s.find(c=>vt.test(c)&&We(e,n,c)==="boolean");return{field:p,due:Qe.test(p),...k?{end:k}:{},...m?{done:m}:{}}}function le(e,n){return Math.round((Date.parse(`${n.slice(0,10)}T00:00:00Z`)-Date.parse(`${e.slice(0,10)}T00:00:00Z`))/864e5)}var _=e=>typeof e=="string"&&/^\d{4}-\d{2}-\d{2}/.test(e)?e.slice(0,10):void 0;function Ze(e,n,o,s){let a=de(e,n);if(a&&o.length>0&&o.length<=dt)return{shape:"board",field:a.field};let i=pe(e,n);if(i&&!i.due){let r=l=>{let v=_(l[i.field]),b=_(J(l,i.field,s));return v&&b?le(v,b):0},p=o.map(l=>({from:_(J(l,i.field,s)),to:i.end&&_(l[i.end])?H(_(l[i.end]),r(l)):void 0})).filter(l=>l.from!==void 0).map(l=>({from:l.from,to:l.to&&l.to>l.from?l.to:l.from})),k=`${s.slice(0,7)}-01`,m=H(`${H(k,31).slice(0,7)}-01`,-1),c=p.filter(l=>l.from<=m&&l.to>=k),w=p.map(l=>le(l.from,l.to)).sort((l,v)=>l-v),u=w[Math.floor(w.length/2)]??0;if(c.length>0&&u<=lt){let l=H(s,-((new Date(`${s}T00:00:00Z`).getUTCDay()+6)%7)),v=H(l,6),b=c.every(f=>f.from>=l&&f.to<=v);return{shape:"calendar",start:i.field,...i.end?{end:i.end}:{},...i.done?{done:i.done}:{},range:b?"week":"month"}}}return{shape:"table"}}function Ue(e,n){let o=pe(e,n);return o?{by:o.field,direction:o.due?"asc":"desc"}:void 0}function Ye(e,n,o={}){switch(n.shape){case"board":return{lens:"columns",kind:e,column:n.field};case"calendar":return{lens:"calendar",kind:e,start:n.start,...n.end?{end:n.end}:{},...n.done?{done:n.done}:{},range:n.range};case"table":return{lens:"blocks",kind:e,as:"row",...o.group?.by?{group:o.group.by}:{},...o.sort?{sort:{by:o.sort.by,...o.sort.direction==="desc"?{direction:"desc"}:{}}}:{}}}}var ft=60;function Je(e,n,o,s){let a=e.tryDefinition(n),i=o.slice(0,ft),r=new Map;i.forEach(w=>{let u=W(a,w);se(w,a,{glance:!0,said:[u]}).forEach((l,v)=>{if(l.long||l.files||l.app)return;let b=r.get(l.key);b?b.count++:r.set(l.key,{label:l.label,count:1,at:v})})});let p=Math.max(1,Math.ceil(i.length/3)),k=[...r.entries()].filter(([,w])=>w.count>=p).sort((w,u)=>w[1].at-u[1].at).slice(0,pt).map(([w,u])=>({about:"field",key:w,label:u.label})),m=new Map;for(let w of i){let u=new Set;for(let[l,v]of[["out",s.outEdges(w.id)],["in",s.inEdges(w.id)]])for(let b of v){let f=s.getNode(l==="out"?b.to:b.from);if(!f||f.id===w.id)continue;let x=`${b.kind}|${l}`;if(u.has(x))continue;u.add(x);let y=m.get(x);y?y.count++:m.set(x,{edge:b.kind,direction:l,far:f.kind,count:1})}}let c=[...m.entries()].sort((w,u)=>u[1].count-w[1].count).slice(0,ct).map(([w,u])=>{let l=xe(e,u.direction==="out"?n:u.far,u.edge,u.direction);return{about:"edge",key:w,label:l.charAt(0).toUpperCase()+l.slice(1),edge:u.edge,direction:u.direction}});return[...k,...c]}function Xe(e,n,o,s){if(o.about==="field"){let r=e.tryDefinition(n.kind);return{text:se(n,r,{excerpt:!0}).find(k=>k.key===o.key)?.value??""}}let i=(o.direction==="out"?s.outEdges(n.id):s.inEdges(n.id)).filter(r=>r.kind===o.edge).map(r=>s.getNode(o.direction==="out"?r.to:r.from)).filter(r=>r!==void 0).map(r=>W(e.tryDefinition(r.kind),r));return i.length===0?{text:""}:i.length===1?{text:i[0]}:{text:`${i[0]} +${i.length-1}`,title:i.join(", ")}}function et(e,n,o=()=>{}){let s=new Map;for(let a of e){let i=a.nodeIds.filter(p=>n.has(p));if(i.length===0&&!(a.subjectId!==void 0&&n.has(a.subjectId)))continue;let r=s.get(a.invariant)??{invariant:a.invariant,label:o(a.invariant)||a.label||a.message,violations:[],records:new Set};r.violations.push(a);for(let p of i)r.records.add(p);a.subjectId!==void 0&&n.has(a.subjectId)&&r.records.add(a.subjectId),s.set(a.invariant,r)}return[...s.values()].sort((a,i)=>i.violations.length-a.violations.length).map(a=>({invariant:a.invariant,label:a.label,violations:a.violations,records:[...a.records]}))}var tt=6;function nt(e,n,o,s){let a=pe(e,n);if(!a)return;let i=de(e,n),r=m=>{if(a.done!==void 0&&m[a.done]===!0)return!0;if(!i)return!1;let c=i.values.indexOf(String(m[i.field]));return c>=0&&i.tiers[c]==="done"},p=0,k=0;for(let m of o){let c=_(J(m,a.field,s));if(!c||r(m))continue;let w=le(s,c);a.due&&w<0?p++:w>=0&&w<=tt&&k++}if(!(p===0&&k===0))return{field:a.field,due:a.due,overdue:p,soon:k}}function H(e,n){return new Date(Date.parse(`${e.slice(0,10)}T00:00:00Z`)+n*864e5).toISOString().slice(0,10)}function ce(e,n,o){return n==="overdue"?[{key:e.field,value:`before:${o}`}]:[{key:e.field,value:`after:${H(o,-1)}`},{key:e.field,value:`before:${H(o,tt+1)}`}]}function it(e,n,o,s){let a=new Set,i=new Set;for(let r of e)if(!(r.at<=o))for(let p of r.primitives)p.op==="add-node"&&p.node?.kind===n?a.add(p.node.id):(p.op==="patch-node"||p.op==="splice-text")&&p.id!==void 0&&s(p.id)===n&&i.add(p.id);for(let r of a)i.delete(r);return{added:[...a].filter(r=>s(r)===n).length,changed:[...i].filter(r=>s(r)===n).length}}var t=ie(be(),1),ht=560;function mt(e,n){let[o,s]=(0,g.useState)(0);return(0,g.useEffect)(()=>{let a=e.current;if(!a||!n){s(0);return}let i=0,r=()=>{i=0;let c=a.getBoundingClientRect().bottom;s([...a.querySelectorAll('[data-testid="kind-stop-table"] tbody tr[data-graview-pick]')].filter(w=>w.getBoundingClientRect().top>c-24).length)},p=()=>{i||(i=requestAnimationFrame(r))};r(),a.addEventListener("scroll",p,{passive:!0});let k=typeof ResizeObserver>"u"?null:new ResizeObserver(p);k?.observe(a);let m=a.querySelector('[data-testid="kind-stop-body"]');return m&&k?.observe(m),()=>{a.removeEventListener("scroll",p),k?.disconnect(),i&&cancelAnimationFrame(i)}},[e,n]),o}function bt({narrow:e,at:n,children:o}){return e?(0,t.jsx)("div",{ref:n,className:"graview-kind-stop-scroll","data-testid":"kind-stop-scroll",children:o}):(0,t.jsx)(t.Fragment,{children:o})}function kt(e){let[n,o]=(0,g.useState)(!1);return(0,g.useLayoutEffect)(()=>{let s=e.current;if(!s)return;let a=()=>{let r=s.getBoundingClientRect().width;r>0&&o(r<ht)};if(a(),typeof ResizeObserver>"u")return;let i=new ResizeObserver(a);return i.observe(s),()=>i.disconnect()},[e]),n}var ot="as",yt=(e,n)=>`graview:kind-seen:${e}:${n}`;function xt(e){try{return localStorage.getItem(e)}catch{return null}}function St(e,n){try{localStorage.setItem(e,n)}catch{}}var Nt=(e,n)=>({...fe(me(e,!1),n),relation:null});function rn({kind:e,members:n,flagged:o=[],label:s,retired:a=0}){let{store:i,brand:r,principal:p,views:k,view:m}=K(),{go:c}=ee(),w=oe(),u=i.schema,l=u.tryDefinition(e),v=s??we(u,e),b=i.today()??ge(),f=n,x=(0,g.useId)(),y=(0,g.useMemo)(()=>Ze(u,e,f,b),[u,e,f,b]),N=m.within?.[ot]==="table"?{shape:"table"}:y,R=Fe(m),D=N.shape==="table"&&!R.sort?Ue(u,e):void 0,E=D?{...R,sort:D}:R,L=(0,g.useMemo)(()=>new Set(o),[o]),h=(0,g.useMemo)(()=>Me(f,E,{schema:u,graph:i.graph,flagged:L,today:b}),[f,E,u,i,L,b,w]),C=(0,g.useMemo)(()=>Ee(u,Re(u,e)),[u,e]),P=k.arrangement?.()?.lists?.[e]?.filters,q=M=>c(Ie(m,M)),j=(0,g.useMemo)(()=>({name:r?.name??"app",schema:u,...i.policy?{policy:i.policy}:{}}),[r,u,i]),U=JSON.stringify(Ye(e,N,E)),F=(0,g.useMemo)(()=>{let M=Le(JSON.parse(U),{app:j,sight:Te(j,p)});return De(M)?void 0:M},[U,j,p]),G=N.shape!=="table"&&F!==void 0,z=(0,g.useRef)(null),O=kt(z),[V,d]=(0,g.useState)(!1),A=(0,g.useId)(),I=(0,g.useMemo)(()=>$e(i,p),[i,p]),B=(f.length>1||a>0)&&!G?(0,t.jsx)(Be,{schema:u,graph:i.graph,kind:e,arrangement:E,onChange:q,offers:C,...P?{filters:P}:{},kept:{shown:h.nodes.length,of:f.length},testId:"kind-arrange",chips:{nodes:f,flagged:L,today:b},...a>0?{past:{count:a,widen:()=>c(Pe(m,!0))}}:{}}):null,T=!!E.query||(E.filter?.length??0)>0,Y=(0,g.useRef)(null),ne=mt(Y,O&&!G);return(0,t.jsxs)("section",{ref:z,"aria-labelledby":x,className:"graview-kind-stop","data-testid":"kind-stop","data-graview-kind-stop":e,"data-graview-shape":N.shape,"data-graview-narrow":O||void 0,children:[(0,t.jsx)("style",{children:Lt}),(0,t.jsxs)(bt,{narrow:O,at:Y,children:[(0,t.jsx)(At,{kind:e,plural:v,count:f.length,headingId:x,description:l?.description,...O?{tools:{open:V,id:A,toggle:()=>d(M=>!M),narrowed:T}}:{}}),O&&V?(0,t.jsxs)("div",{id:A,className:"graview-kind-stop-tools","data-testid":"kind-stop-tools",role:"group","aria-label":`Find, filter and arrange the ${v.toLowerCase()}`,children:[B,f.length>0?(0,t.jsx)(at,{derived:y,shape:N,draft:F,author:!1}):null,(0,t.jsx)(rt,{kind:e,plural:v})]}):null,(0,t.jsx)(Rt,{kind:e,plural:v,members:f,today:b,arrangement:E,onArrange:q,compact:O}),O&&T&&!V?(0,t.jsxs)("p",{className:"graview-kind-stop-narrowed","data-testid":"kind-stop-narrowed",children:[(0,t.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:[$(h.nodes.length)," of ",$(f.length)," shown"]})," ",(0,t.jsx)("button",{type:"button",className:"graview-kind-stop-link",onClick:()=>q({}),children:"Show all"})]}):null,O?null:B,f.length>0&&!O?(0,t.jsx)(at,{derived:y,shape:N,draft:F,author:I}):null,(0,t.jsx)("div",{className:"graview-kind-stop-body","data-testid":"kind-stop-body",children:f.length===0?(0,t.jsx)("p",{className:"graview-kind-stop-empty","data-testid":"kind-stop-empty",children:"Nothing here yet."}):G?(0,t.jsx)(Dt,{draft:F,nodes:f}):h.nodes.length===0?(0,t.jsxs)("p",{className:"graview-kind-stop-empty","data-testid":"kind-stop-none-kept",children:["None of the ",$(f.length)," ",v.toLowerCase()," ",E.query?`says \u201C${E.query}\u201D`:"is kept by these filters","."," ",(0,t.jsx)("button",{type:"button",className:"graview-kind-stop-link",onClick:()=>q({}),children:"Show them all"})]}):(0,t.jsx)(Tt,{kind:e,nodes:h.nodes,groups:h.grouped?h.groups.map(M=>({key:M.key,label:M.label,nodes:M.nodes})):void 0,flagged:L,plural:v,arrangement:E})})]}),ne>0?(0,t.jsxs)("button",{type:"button",className:"graview-kind-stop-below","data-testid":"kind-stop-below","data-graview-below":ne,onClick:()=>Y.current?.scrollBy({top:Math.round(Y.current.clientHeight*.8),behavior:"smooth"}),children:[ae(u,e,ne).replace(/^(\S+)\s/,"$1 more ")," below ",(0,t.jsx)("span",{"aria-hidden":"true",children:"\u2193"})]}):null]})}function rt({kind:e,plural:n}){let{setSelection:o,setMenuAt:s}=K();return(0,t.jsx)("button",{type:"button",className:"graview-kind-stop-quiet","data-testid":"kind-stop-acts","aria-haspopup":"menu","aria-label":`What can be done with the ${n.toLowerCase()}`,onClick:a=>{let i=a.currentTarget.getBoundingClientRect();o([X(e)]),s({x:Math.round(i.left),y:Math.round(i.bottom+4),on:X(e)})},children:"Acts\u2026"})}function At({kind:e,plural:n,count:o,headingId:s,description:a,tools:i}){let{store:r}=K(),p=(0,g.useMemo)(()=>({about:[X(e)]}),[e]),{affordances:k}=qe(p),{apply:m,preview:c}=Ke(),w=(0,g.useMemo)(()=>{let S=N=>r.allMutations().find(R=>R.name===N.mutation)?.creates?.includes(e)??!1;return k.find(N=>!N.destructive&&!N.setsAside&&S(N))},[k,r,e]),[u,l]=(0,g.useState)(!1),[v,b]=(0,g.useState)(null),f=(0,g.useRef)(null),x=(0,g.useRef)(null);(0,g.useEffect)(()=>{let S=x.current;if(!S||S.closest('[data-testid="kind-stop"]')?.contains(document.activeElement))return;let N=!1;try{N=document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.matches(":focus-visible")}catch{N=!0}N?delete S.dataset.graviewQuietFocus:S.dataset.graviewQuietFocus="",S.focus({preventScroll:!0})},[e]);let y=(S,N)=>{try{c(S,N),m(S,N),b(null),l(!1),requestAnimationFrame(()=>f.current?.focus())}catch(R){return b(Se(r.schema,r.allMutations(),R)),[]}};return(0,t.jsxs)("header",{className:"graview-kind-stop-head",children:[(0,t.jsxs)("div",{className:"graview-kind-stop-title",children:[(0,t.jsx)("h2",{id:s,ref:x,tabIndex:-1,"data-testid":"kind-stop-title",onKeyDown:S=>delete S.currentTarget.dataset.graviewQuietFocus,onBlur:S=>delete S.currentTarget.dataset.graviewQuietFocus,children:n}),(0,t.jsxs)("p",{"data-testid":"kind-stop-count",children:[ae(r.schema,e,o),a?` \xB7 ${a}`:""]})]}),(0,t.jsxs)("div",{className:"graview-kind-stop-acts",children:[w?(0,t.jsx)("button",{ref:f,type:"button",className:"graview-kind-stop-primary","data-testid":"kind-stop-primary","data-affordance":w.id,"aria-expanded":w.open.length>0?u:void 0,onClick:()=>{b(null),w.open.length===0?y(w):l(S=>!S)},children:w.label}):null,i?(0,t.jsx)("button",{type:"button",className:"graview-kind-stop-more-tools","data-testid":"kind-stop-tools-open","aria-expanded":i.open,"aria-controls":i.open?i.id:void 0,"aria-label":`Find, filter, arrange and act on the ${n.toLowerCase()}`,title:"Find, filter, arrange and acts","data-narrowed":i.narrowed||void 0,onClick:i.toggle,children:(0,t.jsx)("span",{"aria-hidden":"true",children:"\u22EF"})}):(0,t.jsx)(rt,{kind:e,plural:n})]}),u&&w?(0,t.jsx)("div",{className:"graview-kind-stop-ask","data-testid":"kind-stop-ask","aria-label":w.label,role:"group",children:(0,t.jsx)(Ce,{affordance:w,onApply:S=>y(w,S),onCancel:()=>{l(!1),f.current?.focus()}})}):null,v?(0,t.jsx)("p",{role:"alert",className:"graview-kind-stop-failed","data-testid":"kind-stop-failed",children:v}):null]})}var Ct=te.part((e,n)=>(0,t.jsx)(e.ProblemRows,{...n}),{what:"The problems",as:"li"});function Rt({kind:e,plural:n,members:o,today:s,arrangement:a,onArrange:i,compact:r=!1}){let{store:p,brand:k,setSelection:m}=K(),c=p.schema,w=re(),u=(0,g.useMemo)(()=>new Set(o.map(h=>h.id)),[o]),l=(0,g.useMemo)(()=>et(w,u,h=>p.allInvariants().find(C=>C.name===h)?.label),[w,u,p]),v=(0,g.useMemo)(()=>nt(c,e,o,s),[c,e,o,s]),b=yt(Oe(k,c),e),[f]=(0,g.useState)(()=>xt(b));(0,g.useEffect)(()=>()=>St(b,new Date().toISOString()),[b]);let x=oe(),y=(0,g.useMemo)(()=>f?it(p.log.all(),e,f,h=>p.graph.getNode(h)?.kind):null,[f,p,e,x]),[S,N]=(0,g.useState)(null),R=h=>i({...a,filter:[...(a.filter??[]).filter(C=>!h?.some(P=>P.key===C.key)),...h??[]]}),D=l.reduce((h,C)=>h+C.violations.length,0),E=[];if(v&&(v.overdue>0||v.soon>0)){let h=v.field;E.push((0,t.jsxs)("li",{"data-testid":"kind-stop-dates",children:[v.overdue>0?(0,t.jsxs)("button",{type:"button",className:"graview-kind-stop-fact","data-tone":"warn",onClick:()=>R(ce(v,"overdue",s)),"aria-label":`${$(v.overdue)} overdue \u2014 show only these`,children:[$(v.overdue)," overdue"]}):null,v.soon>0?(0,t.jsxs)("button",{type:"button",className:"graview-kind-stop-fact",onClick:()=>R(ce(v,"soon",s)),"aria-label":`${$(v.soon)} in the next 7 days \u2014 show only these`,children:[$(v.soon)," ",v.due?"due":""," in the next 7 days"]}):null,(0,t.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:[" by ",ve(c.tryDefinition(e),h).toLowerCase()]})]},"dates"))}let L=(a.filter??[]).some(h=>h.key==="is"&&h.value==="flagged");if(l.length>0&&r){let h=l.map(C=>C.label).join(", ");E.push((0,t.jsxs)("li",{className:"graview-kind-stop-problems-line","data-testid":"kind-stop-problems","data-graview-problems":D,children:[(0,t.jsxs)("span",{className:"graview-kind-stop-warn",children:[(0,t.jsx)("span",{"aria-hidden":"true",children:"\u26A0 "}),D===1?"1 problem":`${$(D)} problems`]}),(0,t.jsxs)("span",{className:"graview-kind-stop-quiet-text graview-kind-stop-rules-said",title:h,children:[" ","\xB7 ",h]}),(0,t.jsx)("button",{type:"button",className:"graview-kind-stop-link","data-testid":"kind-stop-only-problems","aria-pressed":L,"aria-label":L?`Show all the ${n.toLowerCase()}`:`Show only the ${n.toLowerCase()} with a problem`,onClick:()=>L?i({...a,filter:(a.filter??[]).filter(C=>!(C.key==="is"&&C.value==="flagged"))}):R([{key:"is",value:"flagged"}]),children:L?"Show all":"Show"})]},"problems"))}else l.length>0&&E.push((0,t.jsxs)("li",{"data-testid":"kind-stop-problems","data-graview-problems":D,children:[(0,t.jsxs)("span",{className:"graview-kind-stop-warn",children:[(0,t.jsx)("span",{"aria-hidden":"true",children:"\u26A0 "}),D===1?"1 problem":`${$(D)} problems`]}),(0,t.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:[" in ",n.toLowerCase(),":"]}),(0,t.jsx)("ul",{className:"graview-kind-stop-rules",children:l.map(h=>(0,t.jsx)(Et,{group:h,open:S===h.invariant,onToggle:()=>N(C=>C===h.invariant?null:h.invariant),onPick:C=>m([C])},h.invariant))}),(0,t.jsxs)("button",{type:"button",className:"graview-kind-stop-link","data-testid":"kind-stop-only-problems",onClick:()=>R([{key:"is",value:"flagged"}]),children:["Show only the ",n.toLowerCase()," with a problem"]})]},"problems"));if(y&&(y.added>0||y.changed>0)){let h=[y.added>0?`${$(y.added)} added`:"",y.changed>0?`${$(y.changed)} changed`:""].filter(Boolean);E.push((0,t.jsxs)("li",{"data-testid":"kind-stop-since",children:[(0,t.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:["Since you last looked (",ue(f.slice(0,10)),"):"]})," ",h.join(", ")]},"since"))}return E.length===0?null:(0,t.jsx)("ul",{className:"graview-kind-stop-going-on","aria-label":`What is going on in the ${n.toLowerCase()}`,"data-testid":"kind-stop-going-on",children:E})}function Et({group:e,open:n,onToggle:o,onPick:s}){let a=(0,g.useId)();return(0,t.jsxs)("li",{"data-graview-rule":e.invariant,children:[(0,t.jsxs)("button",{type:"button",className:"graview-kind-stop-rule","aria-expanded":n,"aria-controls":a,onClick:o,onPointerEnter:te.prefetch,onFocus:te.prefetch,children:[(0,t.jsx)("span",{"aria-hidden":"true",className:"graview-kind-stop-chevron","data-open":n||void 0,children:"\u203A"}),e.label," ",(0,t.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:["\xB7 ",$(e.violations.length)]})]}),n?(0,t.jsx)("ol",{id:a,className:"graview-kind-stop-problem-rows","data-testid":"kind-stop-problem-rows",children:(0,t.jsx)(g.Suspense,{fallback:null,children:(0,t.jsx)(Ct,{violations:e.violations,pick:i=>{let r=i.subjectId??e.records[0]??i.nodeIds[0];r!==void 0&&s(r)}})})}):null]})}var $t={board:"Board",calendar:"Calendar",table:"Table"};function at({derived:e,shape:n,draft:o,author:s}){let{view:a}=K(),{go:i}=ee(),{keep:r}=je(Ge()),[p,k]=(0,g.useState)(!1),m=e.shape==="table"?[]:[e.shape,"table"];return!s&&m.length===0?null:(0,t.jsxs)("div",{className:"graview-kind-stop-shape","data-testid":"kind-stop-shape",children:[m.length>0?(0,t.jsx)("span",{role:"group","aria-label":"Show as",className:"graview-kind-stop-switch",children:m.map(c=>(0,t.jsx)("button",{type:"button","aria-pressed":n.shape===c,"data-testid":`kind-stop-as-${c}`,onClick:()=>i(he(a,ot,c===e.shape?null:c)),children:$t[c]},c))}):null,s?(0,t.jsx)("span",{className:"graview-kind-stop-quiet-text","data-testid":"kind-stop-derived",children:o?`${o.said.replace(/\.$/,"")}, derived from the declaration`:"Derived from the declaration"}):null,o&&s?(0,t.jsx)("button",{type:"button",className:"graview-kind-stop-link","data-testid":"kind-stop-keep",disabled:p,title:`Keep \u201C${o.title}\u201D as a lens: a place of its own`,onClick:()=>{k(!0),r(o).finally(()=>k(!1))},children:"Keep as a lens"}):null]})}function Dt({draft:e,nodes:n}){let o=_e(e.drawn);return(0,t.jsx)("div",{className:"graview-kind-stop-lens","data-graview-draft":e.lens.name,children:(0,t.jsx)(ke,{mode:"scene",children:(0,t.jsx)(Ae,{kind:e.kind,view:e.title,children:(0,t.jsx)(o,{nodes:n,label:e.title,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1})})})})}function Tt({kind:e,nodes:n,groups:o,flagged:s,plural:a,arrangement:i}){let{store:r,views:p,view:k,selection:m,setSelection:c,setMenuAt:w,principal:u}=K(),{go:l}=ee(),v=r.schema,b=r.graph,f=(0,g.useMemo)(()=>(o?o.flatMap(d=>d.nodes):n).map(d=>d.id),[n,o]),x=He(f),y=(0,g.useMemo)(()=>r.permittedMutations(u).some(d=>{let A=d.subject?.kinds;return A!==void 0&&(A==="*"||A.includes(e))}),[r,u,e]),S=(0,g.useRef)(null),N=d=>{x.choose(d),requestAnimationFrame(()=>{let A=x.list.current;((d[0]===void 0?null:A?.querySelector(`[data-graview-choose-box="${CSS.escape(d[0])}"]`))??A)?.focus({preventScroll:!0})})},R=x.chosen.length,D=p.lookup(e,{cardinality:"one",fidelity:"glyph"}),E=D!==void 0&&!ye(D)?D:void 0,L=d=>m.includes(d),h=re(),C=(0,g.useMemo)(()=>Je(v,e,n,b),[v,e,n,b]),[P,q]=(0,g.useState)(Z);(0,g.useEffect)(()=>q(Z),[i.query,i.filter?.length,i.sort?.by,i.group?.by]);let j=v.tryDefinition(e),U=d=>h.filter(A=>A.nodeIds.includes(d)||A.subjectId===d).map(A=>A.message),F=i.sort?.by,G=`${a}${i.sort?`, in order of ${C.find(d=>d.key===F)?.label.toLowerCase()??F}`:""}`,z=P,O=d=>{let A=W(j,d),I=s.has(d.id)?U(d.id):[];return(0,t.jsxs)("tr",{"data-graview-pick":d.id,tabIndex:-1,"data-graview-record":d.id,"data-flagged":I.length>0||void 0,...y?{"data-graview-choose":d.id}:{},children:[y?(0,t.jsx)("td",{className:"graview-choose-at",children:(0,t.jsx)("input",{...x.boxProps(d.id,A),onPointerEnter:Q,onFocus:Q})}):null,(0,t.jsxs)("th",{scope:"row",className:"graview-kind-stop-name",children:[E?(0,t.jsx)("div",{"data-graview-pick":d.id,className:"graview-kind-stop-own-row",children:(0,t.jsx)(E,{node:d,cardinality:"one",fidelity:"glyph",mode:"scene",selected:L(d.id),...I.length>0?{flagged:[d.id]}:{}})}):(0,t.jsx)("button",{type:"button","data-testid":"kind-stop-row-go",title:`Go to ${A}`,onClick:()=>l(Nt(k,d.id)),children:A}),I.length>0?(0,t.jsxs)("span",{className:"graview-kind-stop-flag",title:I.join(" \xB7 "),children:[(0,t.jsx)("span",{"aria-hidden":"true",children:"\u26A0"}),(0,t.jsx)("span",{className:"graview-kind-stop-hidden",children:`Problem: ${I.join(". ")}`})]}):null]}),C.map(B=>{let T=Xe(v,d,B,b);return(0,t.jsx)("td",{"data-label":B.label,"data-short":T.text.length>0&&T.text.length<=14||void 0,"data-empty":T.text?void 0:"",...T.title?{title:T.title}:{},children:T.text?(0,t.jsx)("span",{children:T.text}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{"aria-hidden":"true",children:"\u2014"}),(0,t.jsx)("i",{className:"graview-kind-stop-hidden",children:"none"})]})},B.key)}),(0,t.jsx)("td",{className:"graview-kind-stop-row-acts",children:(0,t.jsx)("button",{type:"button","data-testid":"kind-stop-row-acts","aria-haspopup":"menu","aria-label":`What can be done with ${A}`,onClick:B=>{let T=B.currentTarget.getBoundingClientRect();c([d.id]),w({x:Math.round(T.left),y:Math.round(T.bottom+4),on:d.id})},children:(0,t.jsx)("span",{"aria-hidden":"true",children:"\u22EF"})})})]},d.id)},V=d=>{let A=d.slice(0,Math.max(0,z));return z-=A.length,A.map(O)};return(0,t.jsxs)("div",{className:"graview-kind-stop-table-at",...y?{...x.listProps,ref:d=>{S.current=d,x.list.current=d},tabIndex:-1,role:"group","aria-label":R>0?`${a}, ${R} chosen`:a,"data-graview-choosable":""}:{},children:[y?(0,t.jsx)("style",{children:ze}):null,(0,t.jsxs)("table",{className:"graview-kind-stop-table","data-testid":"kind-stop-table",children:[(0,t.jsx)("caption",{className:"graview-kind-stop-hidden",children:G}),(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{children:[y?(0,t.jsx)("td",{className:"graview-choose-at graview-choose-all",children:(0,t.jsx)("input",{type:"checkbox",className:"graview-choose-box","data-testid":"kind-stop-choose-all","aria-label":`Choose all ${$(n.length)} ${a.toLowerCase()}`,checked:R>0&&R===n.length,ref:d=>{d&&(d.indeterminate=R>0&&R<n.length)},onPointerEnter:Q,onFocus:Q,onChange:()=>R===n.length?x.clear():x.choose(f)})}):null,(0,t.jsx)("th",{scope:"col","aria-sort":F==="label"?i.sort?.direction==="desc"?"descending":"ascending":void 0,children:"Name"}),C.map(d=>(0,t.jsx)("th",{scope:"col","aria-sort":d.about==="field"&&d.key===F?i.sort?.direction==="desc"?"descending":"ascending":void 0,children:d.label},d.key)),(0,t.jsx)("th",{scope:"col",children:(0,t.jsx)("span",{className:"graview-kind-stop-hidden",children:"Acts"})})]})}),o?o.map(d=>z<=0?null:(0,t.jsxs)("tbody",{"data-graview-group":d.key,children:[(0,t.jsx)("tr",{className:"graview-kind-stop-group",children:(0,t.jsxs)("th",{scope:"rowgroup",colSpan:C.length+(y?3:2),children:[d.label," ",(0,t.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:["\xB7 ",$(d.nodes.length)]})]})}),V(d.nodes)]},d.key||"-")):(0,t.jsx)("tbody",{children:V(n)})]}),y?(0,t.jsx)(Ve,{store:r,chosen:x.chosen,principal:u,anchor:()=>S.current?.closest('[data-testid="kind-stop"]')??null,of:f.length,onChooseAll:()=>x.choose(f),onClear:x.clear,onActed:N}):null,n.length>P?(0,t.jsxs)("p",{className:"graview-kind-stop-more",children:[(0,t.jsxs)("span",{className:"graview-kind-stop-quiet-text","data-testid":"kind-stop-shown",children:[$(P)," of ",$(n.length)," shown"]})," ",(0,t.jsxs)("button",{type:"button",className:"graview-kind-stop-link","data-testid":"kind-stop-more",onClick:()=>q(d=>d+Z),children:["Show ",$(Math.min(Z,n.length-P))," more"]})]}):null]})}var Lt=`
|
|
1
|
+
import{a as je,c as Ge}from"./chunk.D3SWJ7OS.js";import{b as _e}from"./chunk.66TRDXYR.js";import{a as He,b as ze,c as Ve,d as Q}from"./chunk.I7OFRF6N.js";import"./chunk.4RPKCW4J.js";import{k as qe,l as Ke}from"./chunk.4R7H3GIL.js";import"./chunk.CCCONK73.js";import"./chunk.IRNEWNUB.js";import"./chunk.AUNQNTKY.js";import"./chunk.KLEKC4ZX.js";import{e as Pe}from"./chunk.PJL3I2IW.js";import{m as Be}from"./chunk.LMZ2WMGH.js";import{a as Fe,b as Ie}from"./chunk.OD5QZHRC.js";import{h as Me}from"./chunk.YJ4PFOPC.js";import{e as Re,f as Ee}from"./chunk.LKM2R5UF.js";import"./chunk.HJCQ6I3S.js";import"./chunk.EL7XXGQY.js";import{e as de}from"./chunk.CDSHUWSK.js";import"./chunk.5MOXQUZH.js";import"./chunk.MKN7ADJB.js";import"./chunk.I4H2GS4O.js";import{a as Ce}from"./chunk.47VEV4BX.js";import"./chunk.FE3SINPK.js";import"./chunk.MUWI54IP.js";import"./chunk.3D37E2G5.js";import{a as De,b as Te,j as Le}from"./chunk.HU3KEWFO.js";import"./chunk.G4JJXA63.js";import{a as $e}from"./chunk.TBY5IR7C.js";import"./chunk.WFJCC6G3.js";import"./chunk.BIDL7GQD.js";import"./chunk.IO5VFTXC.js";import"./chunk.7L3I776Z.js";import"./chunk.CLIC2QBA.js";import"./chunk.UPOYRCKI.js";import"./chunk.XOZU4OFA.js";import"./chunk.WV6SP6IJ.js";import"./chunk.Q5WEOX3Q.js";import"./chunk.MATUPDZ3.js";import"./chunk.SAWASNDO.js";import"./chunk.HCX6KPRF.js";import"./chunk.WVUJXDXZ.js";import"./chunk.B422DSYN.js";import{a as Ne}from"./chunk.ZE5RSKXF.js";import"./chunk.DKUEZPGR.js";import"./chunk.EP7YT7LT.js";import"./chunk.I7KN732Z.js";import"./chunk.TLPCYKLW.js";import"./chunk.MIE4TJRW.js";import{s as Ae}from"./chunk.SCVKHGO3.js";import"./chunk.RD2FSSLV.js";import"./chunk.AZRICZKT.js";import"./chunk.MH3AQO2R.js";import"./chunk.J2N7EKMX.js";import{d as se,l as Se}from"./chunk.P26ATAAI.js";import{b as xe}from"./chunk.FIY4RUK5.js";import"./chunk.IY3DV52G.js";import{F as Oe,t as te}from"./chunk.NLZHNPDU.js";import"./chunk.QNC2OKLF.js";import{G as st,Qa as re,Ra as ee,W as be,Z as ke,ea as K,ga as oe,j as fe,l as he,m as me,r as X,ra as ye}from"./chunk.FWXW4T4I.js";import"./chunk.SDO3U72B.js";import{L as ge,T as ue,Z as $,cb as J,la as W,na as ae,pa as we,ra as ve}from"./chunk.DHPXRDT5.js";import"./chunk.FQLNBIQ5.js";import{b as ie}from"./chunk.AJZBJBMO.js";var g=ie(st(),1);var dt=300,lt=14,Z=50,pt=3,ct=2;function We(e,n,o){let s=e.tryDefinition(n)?.fields?.shape;return(s?.[o]===void 0?void 0:Ne(s[o]))?.type}var gt=(e,n)=>Object.keys(e.tryDefinition(n)?.fields?.shape??{}),ut=e=>e==="date"||e==="datetime",Qe=/^(due|dueOn|dueAt|dueDate|deadline|by)$/i,wt=/^(date|on|day|when|at|start|starts|startsOn|startsAt|begins|from|sown|scheduled|scheduledFor|planned|plannedFor)$/i,vt=/^(done|finished|complete|completed|closed)$/i;function pe(e,n){let o=e.tryDefinition(n),s=gt(e,n),a=s.filter(c=>ut(We(e,n,c)));if(a.length===0)return;let i=o?.fieldRoles??{},r=c=>i[c]!==void 0&&a.includes(i[c])?i[c]:void 0,p=r("start")??r("when")??a.find(c=>Qe.test(c))??a.find(c=>wt.test(c));if(!p)return;let k=r("end")??a.find(c=>c!==p&&/^(end|ends|until|to|finish|finished|harvested|through)$/i.test(c)),m=s.find(c=>vt.test(c)&&We(e,n,c)==="boolean");return{field:p,due:Qe.test(p),...k?{end:k}:{},...m?{done:m}:{}}}function le(e,n){return Math.round((Date.parse(`${n.slice(0,10)}T00:00:00Z`)-Date.parse(`${e.slice(0,10)}T00:00:00Z`))/864e5)}var _=e=>typeof e=="string"&&/^\d{4}-\d{2}-\d{2}/.test(e)?e.slice(0,10):void 0;function Ze(e,n,o,s){let a=de(e,n);if(a&&o.length>0&&o.length<=dt)return{shape:"board",field:a.field};let i=pe(e,n);if(i&&!i.due){let r=l=>{let v=_(l[i.field]),b=_(J(l,i.field,s));return v&&b?le(v,b):0},p=o.map(l=>({from:_(J(l,i.field,s)),to:i.end&&_(l[i.end])?H(_(l[i.end]),r(l)):void 0})).filter(l=>l.from!==void 0).map(l=>({from:l.from,to:l.to&&l.to>l.from?l.to:l.from})),k=`${s.slice(0,7)}-01`,m=H(`${H(k,31).slice(0,7)}-01`,-1),c=p.filter(l=>l.from<=m&&l.to>=k),w=p.map(l=>le(l.from,l.to)).sort((l,v)=>l-v),u=w[Math.floor(w.length/2)]??0;if(c.length>0&&u<=lt){let l=H(s,-((new Date(`${s}T00:00:00Z`).getUTCDay()+6)%7)),v=H(l,6),b=c.every(f=>f.from>=l&&f.to<=v);return{shape:"calendar",start:i.field,...i.end?{end:i.end}:{},...i.done?{done:i.done}:{},range:b?"week":"month"}}}return{shape:"table"}}function Ue(e,n){let o=pe(e,n);return o?{by:o.field,direction:o.due?"asc":"desc"}:void 0}function Ye(e,n,o={}){switch(n.shape){case"board":return{lens:"columns",kind:e,column:n.field};case"calendar":return{lens:"calendar",kind:e,start:n.start,...n.end?{end:n.end}:{},...n.done?{done:n.done}:{},range:n.range};case"table":return{lens:"blocks",kind:e,as:"row",...o.group?.by?{group:o.group.by}:{},...o.sort?{sort:{by:o.sort.by,...o.sort.direction==="desc"?{direction:"desc"}:{}}}:{}}}}var ft=60;function Je(e,n,o,s){let a=e.tryDefinition(n),i=o.slice(0,ft),r=new Map;i.forEach(w=>{let u=W(a,w);se(w,a,{glance:!0,said:[u]}).forEach((l,v)=>{if(l.long||l.files||l.app)return;let b=r.get(l.key);b?b.count++:r.set(l.key,{label:l.label,count:1,at:v})})});let p=Math.max(1,Math.ceil(i.length/3)),k=[...r.entries()].filter(([,w])=>w.count>=p).sort((w,u)=>w[1].at-u[1].at).slice(0,pt).map(([w,u])=>({about:"field",key:w,label:u.label})),m=new Map;for(let w of i){let u=new Set;for(let[l,v]of[["out",s.outEdges(w.id)],["in",s.inEdges(w.id)]])for(let b of v){let f=s.getNode(l==="out"?b.to:b.from);if(!f||f.id===w.id)continue;let x=`${b.kind}|${l}`;if(u.has(x))continue;u.add(x);let y=m.get(x);y?y.count++:m.set(x,{edge:b.kind,direction:l,far:f.kind,count:1})}}let c=[...m.entries()].sort((w,u)=>u[1].count-w[1].count).slice(0,ct).map(([w,u])=>{let l=xe(e,u.direction==="out"?n:u.far,u.edge,u.direction);return{about:"edge",key:w,label:l.charAt(0).toUpperCase()+l.slice(1),edge:u.edge,direction:u.direction}});return[...k,...c]}function Xe(e,n,o,s){if(o.about==="field"){let r=e.tryDefinition(n.kind);return{text:se(n,r,{excerpt:!0}).find(k=>k.key===o.key)?.value??""}}let i=(o.direction==="out"?s.outEdges(n.id):s.inEdges(n.id)).filter(r=>r.kind===o.edge).map(r=>s.getNode(o.direction==="out"?r.to:r.from)).filter(r=>r!==void 0).map(r=>W(e.tryDefinition(r.kind),r));return i.length===0?{text:""}:i.length===1?{text:i[0]}:{text:`${i[0]} +${i.length-1}`,title:i.join(", ")}}function et(e,n,o=()=>{}){let s=new Map;for(let a of e){let i=a.nodeIds.filter(p=>n.has(p));if(i.length===0&&!(a.subjectId!==void 0&&n.has(a.subjectId)))continue;let r=s.get(a.invariant)??{invariant:a.invariant,label:o(a.invariant)||a.label||a.message,violations:[],records:new Set};r.violations.push(a);for(let p of i)r.records.add(p);a.subjectId!==void 0&&n.has(a.subjectId)&&r.records.add(a.subjectId),s.set(a.invariant,r)}return[...s.values()].sort((a,i)=>i.violations.length-a.violations.length).map(a=>({invariant:a.invariant,label:a.label,violations:a.violations,records:[...a.records]}))}var tt=6;function nt(e,n,o,s){let a=pe(e,n);if(!a)return;let i=de(e,n),r=m=>{if(a.done!==void 0&&m[a.done]===!0)return!0;if(!i)return!1;let c=i.values.indexOf(String(m[i.field]));return c>=0&&i.tiers[c]==="done"},p=0,k=0;for(let m of o){let c=_(J(m,a.field,s));if(!c||r(m))continue;let w=le(s,c);a.due&&w<0?p++:w>=0&&w<=tt&&k++}if(!(p===0&&k===0))return{field:a.field,due:a.due,overdue:p,soon:k}}function H(e,n){return new Date(Date.parse(`${e.slice(0,10)}T00:00:00Z`)+n*864e5).toISOString().slice(0,10)}function ce(e,n,o){return n==="overdue"?[{key:e.field,value:`before:${o}`}]:[{key:e.field,value:`after:${H(o,-1)}`},{key:e.field,value:`before:${H(o,tt+1)}`}]}function it(e,n,o,s){let a=new Set,i=new Set;for(let r of e)if(!(r.at<=o))for(let p of r.primitives)p.op==="add-node"&&p.node?.kind===n?a.add(p.node.id):(p.op==="patch-node"||p.op==="splice-text")&&p.id!==void 0&&s(p.id)===n&&i.add(p.id);for(let r of a)i.delete(r);return{added:[...a].filter(r=>s(r)===n).length,changed:[...i].filter(r=>s(r)===n).length}}var t=ie(be(),1),ht=560;function mt(e,n){let[o,s]=(0,g.useState)(0);return(0,g.useEffect)(()=>{let a=e.current;if(!a||!n){s(0);return}let i=0,r=()=>{i=0;let c=a.getBoundingClientRect().bottom;s([...a.querySelectorAll('[data-testid="kind-stop-table"] tbody tr[data-graview-pick]')].filter(w=>w.getBoundingClientRect().top>c-24).length)},p=()=>{i||(i=requestAnimationFrame(r))};r(),a.addEventListener("scroll",p,{passive:!0});let k=typeof ResizeObserver>"u"?null:new ResizeObserver(p);k?.observe(a);let m=a.querySelector('[data-testid="kind-stop-body"]');return m&&k?.observe(m),()=>{a.removeEventListener("scroll",p),k?.disconnect(),i&&cancelAnimationFrame(i)}},[e,n]),o}function bt({narrow:e,at:n,children:o}){return e?(0,t.jsx)("div",{ref:n,className:"graview-kind-stop-scroll","data-testid":"kind-stop-scroll",children:o}):(0,t.jsx)(t.Fragment,{children:o})}function kt(e){let[n,o]=(0,g.useState)(!1);return(0,g.useLayoutEffect)(()=>{let s=e.current;if(!s)return;let a=()=>{let r=s.getBoundingClientRect().width;r>0&&o(r<ht)};if(a(),typeof ResizeObserver>"u")return;let i=new ResizeObserver(a);return i.observe(s),()=>i.disconnect()},[e]),n}var ot="as",yt=(e,n)=>`graview:kind-seen:${e}:${n}`;function xt(e){try{return localStorage.getItem(e)}catch{return null}}function St(e,n){try{localStorage.setItem(e,n)}catch{}}var Nt=(e,n)=>({...fe(me(e,!1),n),relation:null});function rn({kind:e,members:n,flagged:o=[],label:s,retired:a=0}){let{store:i,brand:r,principal:p,views:k,view:m}=K(),{go:c}=ee(),w=oe(),u=i.schema,l=u.tryDefinition(e),v=s??we(u,e),b=i.today()??ge(),f=n,x=(0,g.useId)(),y=(0,g.useMemo)(()=>Ze(u,e,f,b),[u,e,f,b]),N=m.within?.[ot]==="table"?{shape:"table"}:y,R=Fe(m),D=N.shape==="table"&&!R.sort?Ue(u,e):void 0,E=D?{...R,sort:D}:R,L=(0,g.useMemo)(()=>new Set(o),[o]),h=(0,g.useMemo)(()=>Me(f,E,{schema:u,graph:i.graph,flagged:L,today:b}),[f,E,u,i,L,b,w]),C=(0,g.useMemo)(()=>Ee(u,Re(u,e)),[u,e]),P=k.arrangement?.()?.lists?.[e]?.filters,q=M=>c(Ie(m,M)),j=(0,g.useMemo)(()=>({name:r?.name??"app",schema:u,...i.policy?{policy:i.policy}:{}}),[r,u,i]),U=JSON.stringify(Ye(e,N,E)),F=(0,g.useMemo)(()=>{let M=Le(JSON.parse(U),{app:j,sight:Te(j,p)});return De(M)?void 0:M},[U,j,p]),G=N.shape!=="table"&&F!==void 0,z=(0,g.useRef)(null),O=kt(z),[V,d]=(0,g.useState)(!1),A=(0,g.useId)(),I=(0,g.useMemo)(()=>$e(i,p),[i,p]),B=(f.length>1||a>0)&&!G?(0,t.jsx)(Be,{schema:u,graph:i.graph,kind:e,arrangement:E,onChange:q,offers:C,...P?{filters:P}:{},kept:{shown:h.nodes.length,of:f.length},testId:"kind-arrange",chips:{nodes:f,flagged:L,today:b},...a>0?{past:{count:a,widen:()=>c(Pe(m,!0))}}:{}}):null,T=!!E.query||(E.filter?.length??0)>0,Y=(0,g.useRef)(null),ne=mt(Y,O&&!G);return(0,t.jsxs)("section",{ref:z,"aria-labelledby":x,className:"graview-kind-stop","data-testid":"kind-stop","data-graview-kind-stop":e,"data-graview-shape":N.shape,"data-graview-narrow":O||void 0,children:[(0,t.jsx)("style",{children:Lt}),(0,t.jsxs)(bt,{narrow:O,at:Y,children:[(0,t.jsx)(At,{kind:e,plural:v,count:f.length,headingId:x,description:l?.description,...O?{tools:{open:V,id:A,toggle:()=>d(M=>!M),narrowed:T}}:{}}),O&&V?(0,t.jsxs)("div",{id:A,className:"graview-kind-stop-tools","data-testid":"kind-stop-tools",role:"group","aria-label":`Find, filter and arrange the ${v.toLowerCase()}`,children:[B,f.length>0?(0,t.jsx)(at,{derived:y,shape:N,draft:F,author:!1}):null,(0,t.jsx)(rt,{kind:e,plural:v})]}):null,(0,t.jsx)(Rt,{kind:e,plural:v,members:f,today:b,arrangement:E,onArrange:q,compact:O}),O&&T&&!V?(0,t.jsxs)("p",{className:"graview-kind-stop-narrowed","data-testid":"kind-stop-narrowed",children:[(0,t.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:[$(h.nodes.length)," of ",$(f.length)," shown"]})," ",(0,t.jsx)("button",{type:"button",className:"graview-kind-stop-link",onClick:()=>q({}),children:"Show all"})]}):null,O?null:B,f.length>0&&!O?(0,t.jsx)(at,{derived:y,shape:N,draft:F,author:I}):null,(0,t.jsx)("div",{className:"graview-kind-stop-body","data-testid":"kind-stop-body",children:f.length===0?(0,t.jsx)("p",{className:"graview-kind-stop-empty","data-testid":"kind-stop-empty",children:"Nothing here yet."}):G?(0,t.jsx)(Dt,{draft:F,nodes:f}):h.nodes.length===0?(0,t.jsxs)("p",{className:"graview-kind-stop-empty","data-testid":"kind-stop-none-kept",children:["None of the ",$(f.length)," ",v.toLowerCase()," ",E.query?`says \u201C${E.query}\u201D`:"is kept by these filters","."," ",(0,t.jsx)("button",{type:"button",className:"graview-kind-stop-link",onClick:()=>q({}),children:"Show them all"})]}):(0,t.jsx)(Tt,{kind:e,nodes:h.nodes,groups:h.grouped?h.groups.map(M=>({key:M.key,label:M.label,nodes:M.nodes})):void 0,flagged:L,plural:v,arrangement:E})})]}),ne>0?(0,t.jsxs)("button",{type:"button",className:"graview-kind-stop-below","data-testid":"kind-stop-below","data-graview-below":ne,onClick:()=>Y.current?.scrollBy({top:Math.round(Y.current.clientHeight*.8),behavior:"smooth"}),children:[ae(u,e,ne).replace(/^(\S+)\s/,"$1 more ")," below ",(0,t.jsx)("span",{"aria-hidden":"true",children:"\u2193"})]}):null]})}function rt({kind:e,plural:n}){let{setSelection:o,setMenuAt:s}=K();return(0,t.jsx)("button",{type:"button",className:"graview-kind-stop-quiet","data-testid":"kind-stop-acts","aria-haspopup":"menu","aria-label":`What can be done with the ${n.toLowerCase()}`,onClick:a=>{let i=a.currentTarget.getBoundingClientRect();o([X(e)]),s({x:Math.round(i.left),y:Math.round(i.bottom+4),on:X(e)})},children:"Acts\u2026"})}function At({kind:e,plural:n,count:o,headingId:s,description:a,tools:i}){let{store:r}=K(),p=(0,g.useMemo)(()=>({about:[X(e)]}),[e]),{affordances:k}=qe(p),{apply:m,preview:c}=Ke(),w=(0,g.useMemo)(()=>{let S=N=>r.allMutations().find(R=>R.name===N.mutation)?.creates?.includes(e)??!1;return k.find(N=>!N.destructive&&!N.setsAside&&S(N))},[k,r,e]),[u,l]=(0,g.useState)(!1),[v,b]=(0,g.useState)(null),f=(0,g.useRef)(null),x=(0,g.useRef)(null);(0,g.useEffect)(()=>{let S=x.current;if(!S||S.closest('[data-testid="kind-stop"]')?.contains(document.activeElement))return;let N=!1;try{N=document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.matches(":focus-visible")}catch{N=!0}N?delete S.dataset.graviewQuietFocus:S.dataset.graviewQuietFocus="",S.focus({preventScroll:!0})},[e]);let y=(S,N)=>{try{c(S,N),m(S,N),b(null),l(!1),requestAnimationFrame(()=>f.current?.focus())}catch(R){return b(Se(r.schema,r.allMutations(),R)),[]}};return(0,t.jsxs)("header",{className:"graview-kind-stop-head",children:[(0,t.jsxs)("div",{className:"graview-kind-stop-title",children:[(0,t.jsx)("h2",{id:s,ref:x,tabIndex:-1,"data-testid":"kind-stop-title",onKeyDown:S=>delete S.currentTarget.dataset.graviewQuietFocus,onBlur:S=>delete S.currentTarget.dataset.graviewQuietFocus,children:n}),(0,t.jsxs)("p",{"data-testid":"kind-stop-count",children:[ae(r.schema,e,o),a?` \xB7 ${a}`:""]})]}),(0,t.jsxs)("div",{className:"graview-kind-stop-acts",children:[w?(0,t.jsx)("button",{ref:f,type:"button",className:"graview-kind-stop-primary","data-testid":"kind-stop-primary","data-affordance":w.id,"aria-expanded":w.open.length>0?u:void 0,onClick:()=>{b(null),w.open.length===0?y(w):l(S=>!S)},children:w.label}):null,i?(0,t.jsx)("button",{type:"button",className:"graview-kind-stop-more-tools","data-testid":"kind-stop-tools-open","aria-expanded":i.open,"aria-controls":i.open?i.id:void 0,"aria-label":`Find, filter, arrange and act on the ${n.toLowerCase()}`,title:"Find, filter, arrange and acts","data-narrowed":i.narrowed||void 0,onClick:i.toggle,children:(0,t.jsx)("span",{"aria-hidden":"true",children:"\u22EF"})}):(0,t.jsx)(rt,{kind:e,plural:n})]}),u&&w?(0,t.jsx)("div",{className:"graview-kind-stop-ask","data-testid":"kind-stop-ask","aria-label":w.label,role:"group",children:(0,t.jsx)(Ce,{affordance:w,onApply:S=>y(w,S),onCancel:()=>{l(!1),f.current?.focus()}})}):null,v?(0,t.jsx)("p",{role:"alert",className:"graview-kind-stop-failed","data-testid":"kind-stop-failed",children:v}):null]})}var Ct=te.part((e,n)=>(0,t.jsx)(e.ProblemRows,{...n}),{what:"The problems",as:"li"});function Rt({kind:e,plural:n,members:o,today:s,arrangement:a,onArrange:i,compact:r=!1}){let{store:p,brand:k,setSelection:m}=K(),c=p.schema,w=re(),u=(0,g.useMemo)(()=>new Set(o.map(h=>h.id)),[o]),l=(0,g.useMemo)(()=>et(w,u,h=>p.allInvariants().find(C=>C.name===h)?.label),[w,u,p]),v=(0,g.useMemo)(()=>nt(c,e,o,s),[c,e,o,s]),b=yt(Oe(k,c),e),[f]=(0,g.useState)(()=>xt(b));(0,g.useEffect)(()=>()=>St(b,new Date().toISOString()),[b]);let x=oe(),y=(0,g.useMemo)(()=>f?it(p.log.all(),e,f,h=>p.graph.getNode(h)?.kind):null,[f,p,e,x]),[S,N]=(0,g.useState)(null),R=h=>i({...a,filter:[...(a.filter??[]).filter(C=>!h?.some(P=>P.key===C.key)),...h??[]]}),D=l.reduce((h,C)=>h+C.violations.length,0),E=[];if(v&&(v.overdue>0||v.soon>0)){let h=v.field;E.push((0,t.jsxs)("li",{"data-testid":"kind-stop-dates",children:[v.overdue>0?(0,t.jsxs)("button",{type:"button",className:"graview-kind-stop-fact","data-tone":"warn",onClick:()=>R(ce(v,"overdue",s)),"aria-label":`${$(v.overdue)} overdue \u2014 show only these`,children:[$(v.overdue)," overdue"]}):null,v.soon>0?(0,t.jsxs)("button",{type:"button",className:"graview-kind-stop-fact",onClick:()=>R(ce(v,"soon",s)),"aria-label":`${$(v.soon)} in the next 7 days \u2014 show only these`,children:[$(v.soon)," ",v.due?"due":""," in the next 7 days"]}):null,(0,t.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:[" by ",ve(c.tryDefinition(e),h).toLowerCase()]})]},"dates"))}let L=(a.filter??[]).some(h=>h.key==="is"&&h.value==="flagged");if(l.length>0&&r){let h=l.map(C=>C.label).join(", ");E.push((0,t.jsxs)("li",{className:"graview-kind-stop-problems-line","data-testid":"kind-stop-problems","data-graview-problems":D,children:[(0,t.jsxs)("span",{className:"graview-kind-stop-warn",children:[(0,t.jsx)("span",{"aria-hidden":"true",children:"\u26A0 "}),D===1?"1 problem":`${$(D)} problems`]}),(0,t.jsxs)("span",{className:"graview-kind-stop-quiet-text graview-kind-stop-rules-said",title:h,children:[" ","\xB7 ",h]}),(0,t.jsx)("button",{type:"button",className:"graview-kind-stop-link","data-testid":"kind-stop-only-problems","aria-pressed":L,"aria-label":L?`Show all the ${n.toLowerCase()}`:`Show only the ${n.toLowerCase()} with a problem`,onClick:()=>L?i({...a,filter:(a.filter??[]).filter(C=>!(C.key==="is"&&C.value==="flagged"))}):R([{key:"is",value:"flagged"}]),children:L?"Show all":"Show"})]},"problems"))}else l.length>0&&E.push((0,t.jsxs)("li",{"data-testid":"kind-stop-problems","data-graview-problems":D,children:[(0,t.jsxs)("span",{className:"graview-kind-stop-warn",children:[(0,t.jsx)("span",{"aria-hidden":"true",children:"\u26A0 "}),D===1?"1 problem":`${$(D)} problems`]}),(0,t.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:[" in ",n.toLowerCase(),":"]}),(0,t.jsx)("ul",{className:"graview-kind-stop-rules",children:l.map(h=>(0,t.jsx)(Et,{group:h,open:S===h.invariant,onToggle:()=>N(C=>C===h.invariant?null:h.invariant),onPick:C=>m([C])},h.invariant))}),(0,t.jsxs)("button",{type:"button",className:"graview-kind-stop-link","data-testid":"kind-stop-only-problems",onClick:()=>R([{key:"is",value:"flagged"}]),children:["Show only the ",n.toLowerCase()," with a problem"]})]},"problems"));if(y&&(y.added>0||y.changed>0)){let h=[y.added>0?`${$(y.added)} added`:"",y.changed>0?`${$(y.changed)} changed`:""].filter(Boolean);E.push((0,t.jsxs)("li",{"data-testid":"kind-stop-since",children:[(0,t.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:["Since you last looked (",ue(f.slice(0,10)),"):"]})," ",h.join(", ")]},"since"))}return E.length===0?null:(0,t.jsx)("ul",{className:"graview-kind-stop-going-on","aria-label":`What is going on in the ${n.toLowerCase()}`,"data-testid":"kind-stop-going-on",children:E})}function Et({group:e,open:n,onToggle:o,onPick:s}){let a=(0,g.useId)();return(0,t.jsxs)("li",{"data-graview-rule":e.invariant,children:[(0,t.jsxs)("button",{type:"button",className:"graview-kind-stop-rule","aria-expanded":n,"aria-controls":a,onClick:o,onPointerEnter:te.prefetch,onFocus:te.prefetch,children:[(0,t.jsx)("span",{"aria-hidden":"true",className:"graview-kind-stop-chevron","data-open":n||void 0,children:"\u203A"}),e.label," ",(0,t.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:["\xB7 ",$(e.violations.length)]})]}),n?(0,t.jsx)("ol",{id:a,className:"graview-kind-stop-problem-rows","data-testid":"kind-stop-problem-rows",children:(0,t.jsx)(g.Suspense,{fallback:null,children:(0,t.jsx)(Ct,{violations:e.violations,pick:i=>{let r=i.subjectId??e.records[0]??i.nodeIds[0];r!==void 0&&s(r)}})})}):null]})}var $t={board:"Board",calendar:"Calendar",table:"Table"};function at({derived:e,shape:n,draft:o,author:s}){let{view:a}=K(),{go:i}=ee(),{keep:r}=je(Ge()),[p,k]=(0,g.useState)(!1),m=e.shape==="table"?[]:[e.shape,"table"];return!s&&m.length===0?null:(0,t.jsxs)("div",{className:"graview-kind-stop-shape","data-testid":"kind-stop-shape",children:[m.length>0?(0,t.jsx)("span",{role:"group","aria-label":"Show as",className:"graview-kind-stop-switch",children:m.map(c=>(0,t.jsx)("button",{type:"button","aria-pressed":n.shape===c,"data-testid":`kind-stop-as-${c}`,onClick:()=>i(he(a,ot,c===e.shape?null:c)),children:$t[c]},c))}):null,s?(0,t.jsx)("span",{className:"graview-kind-stop-quiet-text","data-testid":"kind-stop-derived",children:o?`${o.said.replace(/\.$/,"")}, derived from the declaration`:"Derived from the declaration"}):null,o&&s?(0,t.jsx)("button",{type:"button",className:"graview-kind-stop-link","data-testid":"kind-stop-keep",disabled:p,title:`Keep \u201C${o.title}\u201D as a lens: a place of its own`,onClick:()=>{k(!0),r(o).finally(()=>k(!1))},children:"Keep as a lens"}):null]})}function Dt({draft:e,nodes:n}){let o=_e(e.drawn);return(0,t.jsx)("div",{className:"graview-kind-stop-lens","data-graview-draft":e.lens.name,children:(0,t.jsx)(ke,{mode:"scene",children:(0,t.jsx)(Ae,{kind:e.kind,view:e.title,children:(0,t.jsx)(o,{nodes:n,label:e.title,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1})})})})}function Tt({kind:e,nodes:n,groups:o,flagged:s,plural:a,arrangement:i}){let{store:r,views:p,view:k,selection:m,setSelection:c,setMenuAt:w,principal:u}=K(),{go:l}=ee(),v=r.schema,b=r.graph,f=(0,g.useMemo)(()=>(o?o.flatMap(d=>d.nodes):n).map(d=>d.id),[n,o]),x=He(f),y=(0,g.useMemo)(()=>r.permittedMutations(u).some(d=>{let A=d.subject?.kinds;return A!==void 0&&(A==="*"||A.includes(e))}),[r,u,e]),S=(0,g.useRef)(null),N=d=>{x.choose(d),requestAnimationFrame(()=>{let A=x.list.current;((d[0]===void 0?null:A?.querySelector(`[data-graview-choose-box="${CSS.escape(d[0])}"]`))??A)?.focus({preventScroll:!0})})},R=x.chosen.length,D=p.lookup(e,{cardinality:"one",fidelity:"glyph"}),E=D!==void 0&&!ye(D)?D:void 0,L=d=>m.includes(d),h=re(),C=(0,g.useMemo)(()=>Je(v,e,n,b),[v,e,n,b]),[P,q]=(0,g.useState)(Z);(0,g.useEffect)(()=>q(Z),[i.query,i.filter?.length,i.sort?.by,i.group?.by]);let j=v.tryDefinition(e),U=d=>h.filter(A=>A.nodeIds.includes(d)||A.subjectId===d).map(A=>A.message),F=i.sort?.by,G=`${a}${i.sort?`, in order of ${C.find(d=>d.key===F)?.label.toLowerCase()??F}`:""}`,z=P,O=d=>{let A=W(j,d),I=s.has(d.id)?U(d.id):[];return(0,t.jsxs)("tr",{"data-graview-pick":d.id,tabIndex:-1,"data-graview-record":d.id,"data-flagged":I.length>0||void 0,...y?{"data-graview-choose":d.id}:{},children:[y?(0,t.jsx)("td",{className:"graview-choose-at",children:(0,t.jsx)("input",{...x.boxProps(d.id,A),onPointerEnter:Q,onFocus:Q})}):null,(0,t.jsxs)("th",{scope:"row",className:"graview-kind-stop-name",children:[E?(0,t.jsx)("div",{"data-graview-pick":d.id,className:"graview-kind-stop-own-row",children:(0,t.jsx)(E,{node:d,cardinality:"one",fidelity:"glyph",mode:"scene",selected:L(d.id),...I.length>0?{flagged:[d.id]}:{}})}):(0,t.jsx)("button",{type:"button","data-testid":"kind-stop-row-go",title:`Go to ${A}`,onClick:()=>l(Nt(k,d.id)),children:A}),I.length>0?(0,t.jsxs)("span",{className:"graview-kind-stop-flag",title:I.join(" \xB7 "),children:[(0,t.jsx)("span",{"aria-hidden":"true",children:"\u26A0"}),(0,t.jsx)("span",{className:"graview-kind-stop-hidden",children:`Problem: ${I.join(". ")}`})]}):null]}),C.map(B=>{let T=Xe(v,d,B,b);return(0,t.jsx)("td",{"data-label":B.label,"data-short":T.text.length>0&&T.text.length<=14||void 0,"data-empty":T.text?void 0:"",...T.title?{title:T.title}:{},children:T.text?(0,t.jsx)("span",{children:T.text}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{"aria-hidden":"true",children:"\u2014"}),(0,t.jsx)("i",{className:"graview-kind-stop-hidden",children:"none"})]})},B.key)}),(0,t.jsx)("td",{className:"graview-kind-stop-row-acts",children:(0,t.jsx)("button",{type:"button","data-testid":"kind-stop-row-acts","aria-haspopup":"menu","aria-label":`What can be done with ${A}`,onClick:B=>{let T=B.currentTarget.getBoundingClientRect();c([d.id]),w({x:Math.round(T.left),y:Math.round(T.bottom+4),on:d.id})},children:(0,t.jsx)("span",{"aria-hidden":"true",children:"\u22EF"})})})]},d.id)},V=d=>{let A=d.slice(0,Math.max(0,z));return z-=A.length,A.map(O)};return(0,t.jsxs)("div",{className:"graview-kind-stop-table-at",...y?{...x.listProps,ref:d=>{S.current=d,x.list.current=d},tabIndex:-1,role:"group","aria-label":R>0?`${a}, ${R} chosen`:a,"data-graview-choosable":""}:{},children:[y?(0,t.jsx)("style",{children:ze}):null,(0,t.jsxs)("table",{className:"graview-kind-stop-table","data-testid":"kind-stop-table",children:[(0,t.jsx)("caption",{className:"graview-kind-stop-hidden",children:G}),(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{children:[y?(0,t.jsx)("td",{className:"graview-choose-at graview-choose-all",children:(0,t.jsx)("input",{type:"checkbox",className:"graview-choose-box","data-testid":"kind-stop-choose-all","aria-label":`Choose all ${$(n.length)} ${a.toLowerCase()}`,checked:R>0&&R===n.length,ref:d=>{d&&(d.indeterminate=R>0&&R<n.length)},onPointerEnter:Q,onFocus:Q,onChange:()=>R===n.length?x.clear():x.choose(f)})}):null,(0,t.jsx)("th",{scope:"col","aria-sort":F==="label"?i.sort?.direction==="desc"?"descending":"ascending":void 0,children:"Name"}),C.map(d=>(0,t.jsx)("th",{scope:"col","aria-sort":d.about==="field"&&d.key===F?i.sort?.direction==="desc"?"descending":"ascending":void 0,children:d.label},d.key)),(0,t.jsx)("th",{scope:"col",children:(0,t.jsx)("span",{className:"graview-kind-stop-hidden",children:"Acts"})})]})}),o?o.map(d=>z<=0?null:(0,t.jsxs)("tbody",{"data-graview-group":d.key,children:[(0,t.jsx)("tr",{className:"graview-kind-stop-group",children:(0,t.jsxs)("th",{scope:"rowgroup",colSpan:C.length+(y?3:2),children:[d.label," ",(0,t.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:["\xB7 ",$(d.nodes.length)]})]})}),V(d.nodes)]},d.key||"-")):(0,t.jsx)("tbody",{children:V(n)})]}),y?(0,t.jsx)(Ve,{store:r,chosen:x.chosen,principal:u,anchor:()=>S.current?.closest('[data-testid="kind-stop"]')??null,of:f.length,onChooseAll:()=>x.choose(f),onClear:x.clear,onActed:N}):null,n.length>P?(0,t.jsxs)("p",{className:"graview-kind-stop-more",children:[(0,t.jsxs)("span",{className:"graview-kind-stop-quiet-text","data-testid":"kind-stop-shown",children:[$(P)," of ",$(n.length)," shown"]})," ",(0,t.jsxs)("button",{type:"button",className:"graview-kind-stop-link","data-testid":"kind-stop-more",onClick:()=>q(d=>d+Z),children:["Show ",$(Math.min(Z,n.length-P))," more"]})]}):null]})}var Lt=`
|
|
2
2
|
.graview-kind-stop{container-type:inline-size;box-sizing:border-box;height:100%;min-height:0;display:flex;flex-direction:column;gap:10px;padding:16px 18px 12px;border:1px solid var(--graview-edge);border-radius:var(--graview-radius,12px);background:var(--graview-panel);color:var(--graview-ink);box-shadow:var(--graview-lift-low);overflow:auto;overscroll-behavior:contain}
|
|
3
3
|
[data-graview-map-panel] .graview-kind-stop{height:auto;padding:4px 6px 12px;border:0;box-shadow:none;background:none;overflow:visible}
|
|
4
4
|
.graview-kind-stop :focus-visible{outline:2px solid var(--graview-accent);outline-offset:2px}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as p}from"./chunk.
|
|
1
|
+
import{b as p}from"./chunk.ZT3ZG52B.js";import{vc as g}from"./chunk.DHPXRDT5.js";function w(n){let r=n.policy?.sees??[];if(r.length===0)return!0;let t=o=>o.fields===void 0&&(o.hide?.length??0)===0;return n.schema.kinds.every(o=>r.some(s=>s.roles==="*"&&!s.own&&!s.via&&t(s)&&s.kinds.includes(o)))}function b(n){let r=n;for(let t=0;t<8&&r?._zod?.def;t+=1){let o=r._zod.def;if(o.type==="enum")return Object.values(o.entries);if(o.type==="literal")return o.values;if(!("innerType"in o))return;r=o.innerType}}var c=(n,r)=>({ok:!1,reason:n,message:r});function k(n,r){return p(n).find(t=>(t.as??t.act)===r)??p(n).find(t=>t.act===r&&t.as===void 0)}var m=n=>typeof n=="object"&&n!==null&&!Array.isArray(n)&&"href"in n;function S(n,r,t,o,s){let l=k(r,t);if(!l)return c("undeclared",`This view may not ask for \u201C${t}\u201D: its manifest does not name it.`);let u={},f=new Map;for(let[a,d]of Object.entries(o)){let y=i=>{if(!m(i))return i;let e=typeof i.href=="string"?s?.file(i.href):void 0;if(!e)throw c("malformed",`\u201C${a}\u201D is a file the host did not hand this view: a view hands an act a file the person dropped (event.files), or one a record it was shown holds, as it was handed.`);let h=s?.dropped(e.href);if(h){if(f.has(e.href))throw c("malformed",`\u201C${a}\u201D hands the act a dropped file it already carries: each file a person dropped goes in one act, once.`);f.set(e.href,h)}return e};try{u[a]=Array.isArray(d)?d.map(y):y(d)}catch(i){return i}}if(!w(n)){let a=new Set([...f.values()].map(e=>e.target)),d=a.size===1?[...a][0]:void 0,y=e=>m(e)&&typeof e.href=="string"&&f.has(e.href)||g(e)||d!==void 0&&e===d&&s?.shown.has(d)===!0;return f.size>0&&a.size===1&&Object.values(u).every(e=>Array.isArray(e)?e.every(y):y(e))?{ok:!0,name:l.act,args:{...u,...l.constants??{}},spent:[...f.keys()]}:c("press-only","In this app some members may not see some records, so a view's act applies only when you press it.")}return{ok:!0,name:l.act,args:{...u,...l.constants??{}}}}export{w as a,b,c,k as d,S as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h,i as E}from"./chunk.
|
|
1
|
+
import{h,i as E}from"./chunk.P26ATAAI.js";import{e as z}from"./chunk.FIY4RUK5.js";import{a as M}from"./chunk.IY3DV52G.js";import{Ab as g,C as y,Da as R,Ga as j,Na as O,Qb as N,Rb as k,Ya as P,Za as D,ec as T,ga as S,jb as L,nc as Z,oc as q,pc as K,qc as v,yb as V,zb as I}from"./chunk.DHPXRDT5.js";var J=n=>n.safeParse?.(void 0).success??!1,C=n=>h(n).shape,A=n=>{let r=h(n);if(y(r)?.type!=="literal")return;let o=y(r)?.values;return o&&o.length===1&&typeof o[0]=="string"?o[0]:void 0};function F(n,r){let o=J(r),e=h(r),t=y(e)?.type,c=T(r);if(c)return{control:"node",name:n,optional:o,kinds:c};let m=O(r);if(m)return{control:"linked",name:n,optional:o,relation:m};if(D(r)){let d=P(n);return{control:"repeat",name:n,optional:o,...d?{of:d}:{}}}if(t==="boolean")return{control:"boolean",name:n,optional:o};let f=R(e);if(f)return{control:"file",name:n,optional:o,...f==="image"?{image:!0}:f==="video"?{video:!0}:{}};if(t==="object"){let d=e.shape??{};return{control:"group",name:n,optional:o,fields:Object.entries(d).map(([a,l])=>F(a,l))}}if(t==="union"){let d=y(e)?.options??[],a=d.map(s=>C(s));if(a.every(s=>s!==void 0)){let s=Object.keys(a[0]??{}).find(u=>a.every(p=>A(p?.[u])!==void 0));if(s)return{control:"variant",name:n,optional:o,tag:s,options:d.map((u,p)=>({value:A(a[p]?.[s])??"",fields:Object.entries(a[p]??{}).filter(([w])=>w!==s).map(([w,B])=>F(w,B))}))}}let l=d.map(s=>A(s));return l.every(s=>s!==void 0)?{control:"choice",name:n,optional:o,options:l}:{control:"opaque",name:n,optional:o}}if(t==="array"){let d=y(e)?.element,a=d===void 0?void 0:F(n,d);return a?.control==="choice"?{...a,optional:o,multiple:!0}:a!==void 0?{control:"list",name:n,optional:o,item:a}:{control:"opaque",name:n,optional:o}}let i=E(r);return i.type==="text"?{control:"text",name:n,optional:o,...i.long?{long:!0}:{},...j(e)?{app:!0}:{},...M(e)?{markdown:!0}:{},...i.holds?{holds:i.holds}:{}}:i.type==="number"&&i.duration?{control:"text",name:n,optional:o,holds:"duration"}:i.type==="date"?{control:"date",name:n,optional:o,...i.time?{time:!0}:{},...i.instant?{instant:!0}:{},...i.partial?{partial:!0}:{}}:i.type==="number"?{control:"number",name:n,optional:o,...i.min===void 0?{}:{min:i.min},...i.max===void 0?{}:{max:i.max},...i.step===void 0?{}:{step:i.step},...i.amount?{amount:i.amount}:{}}:i.type==="choice"?{control:"choice",name:n,optional:o,options:i.options}:{control:"opaque",name:n,optional:o}}function H(n){let r=n.shape;return r?Object.entries(r).map(([o,e])=>F(o,e)):[]}function W(n,r){let o={...r};for(let e of n){let t=r[e.name];t===void 0&&!e.optional&&(e.control==="list"||e.control==="boolean")&&(o[e.name]=e.control==="list"?[]:!1),e.control==="text"&&e.holds&&typeof t=="string"&&(o[e.name]=t.trim()===""?void 0:e.holds==="duration"?z(t)??t:t.trim()),e.control==="group"&&t!==void 0&&typeof t=="object"&&t!==null&&(o[e.name]=W(e.fields,t))}return o}function G(n,r){return q(H(r.input),Z(n,r))}var x="visitor";function gn(n,r,o,e){let t=N.keptFrom?.(n,r),c=new Set;if(!t)return c;let m=Object.keys(o.input.shape??{});for(let a of o.creates??[]){let l=t({id:"\0new",kind:a});for(let s of m)l?.(s)&&c.add(s)}let f=e===void 0?void 0:n.graph.getNode(e),i=f&&n.schema.tryDefinition(f.kind),d=f&&t(f);if(i&&d)for(let a of v(o,i))d(a)&&m.includes(a)&&c.add(a);return c}function _(n,r,o,e){let t=new Set,c=r?.sees??[];if(I(o)||!c.some(k))return t;let m=V(o),f=(l,s)=>{let u=c.filter(p=>p.kinds.includes(l)&&g(p,m));return u.some(k)?L.has(s)||u.some(p=>!k(p)||(p.fields===void 0||p.fields.includes(s))&&!p.hide?.includes(s)):!0},i=Object.keys(e.input.shape??{}),d=new Map,a=(l,s)=>d.set(l,d.get(l)===!0||s);for(let l of e.creates??[]){let s=Object.keys(n.tryDefinition(l)?.fields.shape??{});for(let u of i)s.includes(u)&&a(u,f(l,u))}for(let l of K(n,e)){let s=n.tryDefinition(l);if(s)for(let u of v(e,s))i.includes(u)&&a(u,f(l,u))}for(let[l,s]of d)s||t.add(l);return t}var $=(n,r)=>r.title??S(n);function Q(n,r,o){let e=n?.sees;return!e||e.length===0?!0:e.some(t=>t.kinds.includes(o)&&g(t,r)&&!t.own&&!t.via)}function b(n){switch(n.control){case"node":return[n];case"group":return n.fields.flatMap(b);case"variant":return n.options.flatMap(r=>r.fields.flatMap(b));case"list":return b(n.item);default:return[]}}function U(n,r,o,e){return e.has(o.name)?!1:b(o).every(t=>t.kinds.some(c=>c!=="*"&&Q(n,r,c)))}var X=n=>({kind:"human",id:"form:",roles:[n]});function vn(n,r,o=n.mutations??[]){let e=n.forms?.[r];if(!e)return;let t=o.find(a=>a.name===e.act);if(!t)return;let c=e.role??x,m=X(c),f=_(n.schema,n.policy,m,t),i=G(n.schema,t),d=e.fields?e.fields.flatMap(a=>i.find(l=>l.name===a)??[]):i.filter(a=>U(n.policy,m,a,f));return{name:r,title:$(r,e),...e.intro?{intro:e.intro}:{},...e.say?{say:e.say}:{},submit:e.submit??t.title??S(t.name),role:c,act:t,fields:d}}function An(n,r,o){let e=n.forms?.[r];if(!e)throw new Error(`There is no form called "${r}"${n.forms?`: the forms are ${Object.keys(n.forms).join(", ")}`:": the app declares none"}.`);return{kind:"visitor",id:o,name:`a visitor via the ${$(r,e)} form`,roles:[e.role??x]}}function xn(n){return{said:"Received \u2014 thank you.",...n.say?{next:n.say}:{}}}export{H as a,W as b,G as c,gn as d,_ as e,vn as f,An as g,xn as h};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Y,b as _,c as D,e as R,h as z,i as q,j as k,k as S,l as N,o as H,p as P}from"./chunk.
|
|
1
|
+
import{a as Y,b as _,c as D,e as R,h as z,i as q,j as k,k as S,l as N,o as H,p as P}from"./chunk.LKM2R5UF.js";import{b as V}from"./chunk.P26ATAAI.js";import{G,L as T,T as A,aa as W,cb as F,ga as j,ha as B,hb as U,la as I}from"./chunk.DHPXRDT5.js";function ne(e,r){return e===void 0||e===!0?!0:e===!1?!1:e[r]!==!1}function oe(e){let r={};return e.query&&e.query.trim().length>0&&(r.q=e.query),e.archived!==void 0&&e.archived!==!1&&(r.archived=String(e.archived)),e.sort&&(r.sort=e.sort.direction==="desc"?`${e.sort.by}:desc`:e.sort.by),e.filter?.length&&(r.filter=e.filter.map(n=>`${n.key}:${n.value}`).join(",")),e.group&&(r.group=e.group.bucket?`${e.group.by}:${e.group.bucket}`:e.group.by),r}function ie(e,r){let n=[],d={};if(e.query&&(d.query=e.query),e.archived!==void 0&&e.archived!==!1&&(d.archived=e.archived),e.sort&&(r.sorts.some(u=>u.key===e.sort.by)?d.sort=e.sort:n.push(`sort ${e.sort.by}`)),e.filter){let u=e.filter.filter(c=>r.filters.find(a=>a.key===c.key)?!0:(n.push(`filter ${c.key}`),!1));u.length>0&&(d.filter=u)}return e.group&&(r.groups.some(u=>u.key===e.group.by)?d.group=e.group:n.push(`group ${e.group.by}`)),{arrangement:d,dropped:n}}function x(e,r){return I(e.schema.tryDefinition(r.kind),k(r))}var se=(e,r)=>e==null?r==null?0:1:r==null?-1:typeof e=="number"&&typeof r=="number"?e-r:typeof e=="boolean"&&typeof r=="boolean"?e===r?0:e?1:-1:String(e).localeCompare(String(r),void 0,{numeric:!0,sensitivity:"base"});function de(e,r,n){if(n==="label")return x(e,r);let d=e.schema.tryDefinition(r.kind);return d&&n in(d.fields.shape??{})?F(q(r),n,e.today??T()):d?.computed?.[n]!==void 0?e.read?.(r,n):S(e.graph,r.id,n).map(c=>x(e,c)).sort()[0]}var ue=/^(\d{4})-(\d{2})-(\d{2})/;function Z(e,r){if(G.test(e)){let[s,i]=[e.slice(0,4),e.slice(5,7)];return r==="year"?`${s}-01-01`:r==="decade"?`${String(Number(s)-Number(s)%10).padStart(4,"0")}-01-01`:r==="month"&&i?`${s}-${i}-01`:e}let n=ue.exec(e);if(!n)return;let[,d,u,c]=n;if(r==="day")return`${d}-${u}-${c}`;if(r==="month")return`${d}-${u}-01`;if(r==="year")return`${d}-01-01`;if(r==="decade")return`${String(Number(d)-Number(d)%10).padStart(4,"0")}-01-01`;let l=new Date(Date.UTC(Number(d),Number(u)-1,Number(c))),a=(l.getUTCDay()+6)%7;return l.setUTCDate(l.getUTCDate()-a),l.toISOString().slice(0,10)}function le(e,r){return G.test(e)?A(e):r==="month"?W(e):r==="week"?`Week of ${A(e)}`:r==="year"?e.slice(0,4):r==="decade"?`The ${e.slice(0,4)}s`:A(e)}function ae(e,r,n){return Q(e,n)(r)}function Q(e,r){let{words:n,conditions:d}=H(r);if(n.length===0&&d.length===0)return()=>!0;let u=new Map,c=l=>{let a=u.get(l);return a||(a=new Set(R(e.schema,l).filters.map(s=>s.key)),u.set(l,a)),a};return l=>{let a=c(l.kind),s=d.filter(i=>a.has(i.key));return s.every(i=>N(e,l,i))?n.length>0?P(e.schema.tryDefinition(l.kind),k(l),n,e.searchIn)!==void 0:s.length>0:!1}}function fe(e,r,n){let d=r.query?.trim(),u=r.archived===void 0?e:e.filter(t=>U(t,r.archived)),c=d?u.filter(Q(n,d)):u,l=r.filter?.length?c.filter(t=>r.filter.every(f=>N(n,t,f))):[...c],a=[];for(let t=r.sort;t&&a.length<4;t=t.then)a.push(t);let s=a.length>0?l.map((t,f)=>({node:t,index:f,values:a.map(o=>de(n,t,o.by))})).sort((t,f)=>{for(let[o,p]of a.entries()){let[b,E]=[t.values[o],f.values[o]],C=se(b,E),M=p.direction==="desc"&&C!==0&&b!==void 0&&E!==void 0?-C:C;if(M!==0)return M}return t.index-f.index}).map(t=>t.node):l,i=r.group;if(!i)return{nodes:s,groups:[{key:"",label:"",nodes:s}],grouped:!1};let y=new Map,g=(t,f,o)=>{let p=y.get(t)??{label:f,nodes:[]};p.nodes.push(o),y.set(t,p)},O=s[0],m=O?n.schema.tryDefinition(O.kind):void 0,L=m?.fields.shape??{},ee=m?Y(m,i.by):j(i.by),$=i.by in L,h=$?_(L[i.by]):void 0,re=D(n.schema,O?.kind??"").find(t=>t.key===i.by)?.label,w=$?`No ${ee.toLowerCase()}`:`Without ${(re??j(i.by)).toLowerCase()}`,K=$?new Map:V([...new Map(s.flatMap(t=>S(n.graph,t.id,i.by)).map(t=>[t.id,t])).values()].map(k),t=>n.schema.tryDefinition(t));for(let t of s){if($){let o=F(q(t),i.by,n.today??T());if(o==null||o==="")g("",w,t);else if(h==="date"){let p=i.bucket??"day",b=Z(String(o),p);b?g(b,le(b,p),t):g("",w,t)}else if(h==="boolean")g(o?"1":"0",o?"Yes":"No",t);else{let p=m?.display?.format?.[i.by];g(String(o),p?p(o):h==="choice"?B(String(o)):String(o),t)}continue}let f=S(n.graph,t.id,i.by).map(o=>({id:o.id,label:K.has(o.id)?`${x(n,o)} \xB7 ${K.get(o.id)}`:x(n,o)})).sort((o,p)=>o.label.localeCompare(p.label));f.length===0?g("",w,t):g(f.map(o=>o.id).join(","),f.map(o=>o.label).join(", "),t)}let v=h==="choice"?z(L[i.by]):void 0,te=[...y.entries()].sort(([t,f],[o,p])=>t===""?1:o===""?-1:v?v.indexOf(t)-v.indexOf(o):h==="boolean"?o.localeCompare(t):h==="date"?t.localeCompare(o):f.label.localeCompare(p.label)).map(([t,f])=>({key:t,label:f.label,nodes:f.nodes}));return{nodes:s,groups:te,grouped:!0}}function J(e){if(e===void 0)return;if(typeof e=="string")return{by:e,direction:"asc"};let r=e.then===void 0?void 0:typeof e.then=="string"?{by:e.then,direction:"asc"}:{by:e.then.by,direction:e.then.direction??"asc"};return{by:e.by,direction:e.direction??"asc",...r?{then:r}:{}}}function X(e){if(e!==void 0)return typeof e=="string"?{by:e}:e}function ce(e){let r=J(e?.sort),n=X(e?.group);if(!(!r&&!n))return{...r?{sort:r}:{},...n?{group:{by:n.by}}:{}}}var pe=(e,r)=>r?e==="1"?"true":"false":e;function ge(e,r,n){let d=n.type==="boolean",u=d?["true","false"]:n.options??[],c=[...new Set([...(r.order??[]).filter(s=>u.includes(s)),...u])],l=r.closed??[],a=s=>{if(s.key==="")return[1,0];let i=pe(s.key,d);if(l.includes(i))return[2,l.indexOf(i)];let y=c.indexOf(i);return[0,y<0?c.length:y]};return e.map((s,i)=>({group:s,at:i,rank:a(s)})).sort((s,i)=>s.rank[0]-i.rank[0]||s.rank[1]-i.rank[1]||s.at-i.at).map(({group:s,rank:i})=>({...s,closed:i[0]===2}))}export{X as a,ce as b,ge as c,ne as d,oe as e,ie as f,ae as g,fe as h};
|