graview 0.1.38 → 0.1.39
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.23WYWIAJ.js +1 -0
- package/dist/preview/{chunk.5XJEGXDO.js → chunk.2BJRS3YJ.js} +1 -1
- package/dist/preview/{chunk.ROGYDMES.js → chunk.2GGDOFTF.js} +1 -1
- package/dist/preview/chunk.2HF54MYG.js +1 -0
- package/dist/preview/{chunk.OE4QOBJF.js → chunk.2IX3CZNP.js} +1 -1
- package/dist/preview/chunk.2NSTEREJ.js +1 -0
- package/dist/preview/chunk.2RCNSHXK.js +1 -0
- package/dist/preview/chunk.37ASLBGE.js +1 -0
- package/dist/preview/{chunk.33GN2NUT.js → chunk.3ZNQ5YKX.js} +1 -1
- package/dist/preview/{chunk.EUGWV3S6.js → chunk.4BBJ62ZO.js} +1 -1
- package/dist/preview/chunk.4ECICQ2S.js +1 -0
- package/dist/preview/{chunk.B5ILKGEF.js → chunk.4PNFX3TX.js} +1 -1
- package/dist/preview/{chunk.WG5NIR23.js → chunk.546WEHEX.js} +1 -1
- package/dist/preview/chunk.57OPL5WD.js +1 -0
- package/dist/preview/{chunk.36SQJMEE.js → chunk.5JPRFXYQ.js} +1 -1
- package/dist/preview/chunk.5OJJ2TKZ.js +9 -0
- package/dist/preview/chunk.5R4E5C76.js +1 -0
- package/dist/preview/{chunk.7H5KVW2F.js → chunk.5XNVN4HE.js} +1 -1
- package/dist/preview/chunk.5ZMENPY4.js +5 -0
- package/dist/preview/{chunk.YPY5BOEI.js → chunk.67USHK26.js} +1 -1
- package/dist/preview/chunk.6CFP5UYP.js +1 -0
- package/dist/preview/{chunk.74RMHUCX.js → chunk.6DHHUBSC.js} +1 -1
- package/dist/preview/chunk.6HBEYRJU.js +1 -0
- package/dist/preview/chunk.6L7IDF3J.js +1 -0
- package/dist/preview/{chunk.ZRQI5VJF.js → chunk.6XU2CXRZ.js} +1 -1
- package/dist/preview/{chunk.2VIGF4FO.js → chunk.7EFNLMKU.js} +1 -1
- package/dist/preview/chunk.7WSXVXP3.js +1 -0
- package/dist/preview/chunk.ALDLAQ7V.js +1 -0
- package/dist/preview/chunk.AYHCQWSU.js +1 -0
- package/dist/preview/{chunk.QYRPELLU.js → chunk.B2IRADR2.js} +1 -1
- package/dist/preview/{chunk.V2NBJDAX.js → chunk.B7TB6YRZ.js} +1 -1
- package/dist/preview/chunk.BCHHBGM6.js +1 -0
- package/dist/preview/{chunk.LHO7L3CS.js → chunk.BEC5ZH2L.js} +1 -1
- package/dist/preview/chunk.BL4S3I2N.js +1 -0
- package/dist/preview/chunk.BS3FX4PX.js +1 -0
- package/dist/preview/chunk.BTSXYZ6Z.js +25 -0
- package/dist/preview/chunk.BYKR7NEE.js +1 -0
- package/dist/preview/chunk.BZSU4HH2.js +1 -0
- package/dist/preview/chunk.C2OAKTZX.js +1 -0
- package/dist/preview/chunk.C4CFYTCW.js +1 -0
- package/dist/preview/{chunk.6ONRWFA6.js → chunk.C6X7CKU6.js} +1 -1
- package/dist/preview/chunk.CAMQ7MYJ.js +1 -0
- package/dist/preview/{chunk.NPX7SPXM.js → chunk.CC47O2DW.js} +1 -1
- package/dist/preview/{chunk.ZLXPIEUC.js → chunk.CF7DHTKL.js} +2 -2
- package/dist/preview/{chunk.SGB6IMWN.js → chunk.CMN6VVK2.js} +1 -1
- package/dist/preview/chunk.CTK2P4JV.js +3 -0
- package/dist/preview/chunk.DAA7IDQ4.js +1 -0
- package/dist/preview/{chunk.6UCRL4OF.js → chunk.DYNBWIPF.js} +1 -1
- package/dist/preview/chunk.E3HXXUKY.js +1 -0
- package/dist/preview/{chunk.GZ3IXNA4.js → chunk.EBHKKOPO.js} +1 -1
- package/dist/preview/chunk.EDC4EMIX.js +1 -0
- package/dist/preview/chunk.EM4Y4YAD.js +2 -0
- package/dist/preview/{chunk.IEDXW36H.js → chunk.EWWJMS6G.js} +1 -1
- package/dist/preview/chunk.F5UVEF2R.js +1 -0
- package/dist/preview/{chunk.TKSGC6XH.js → chunk.FCXBCKED.js} +1 -1
- package/dist/preview/chunk.FGDHEVH4.js +1 -0
- package/dist/preview/{chunk.IM7LXLIB.js → chunk.FILCNVGH.js} +1 -1
- package/dist/preview/chunk.FJBQ4UP3.js +32 -0
- package/dist/preview/{chunk.RZVZG2BQ.js → chunk.FMN5XDLE.js} +1 -1
- package/dist/preview/chunk.G23VFYGF.js +88 -0
- package/dist/preview/chunk.G46WGK5E.js +1 -0
- package/dist/preview/chunk.GAFYE37S.js +3 -0
- package/dist/preview/{chunk.VNBR4DHD.js → chunk.GP2F7TIN.js} +1 -1
- package/dist/preview/chunk.GXKECZ4S.js +19 -0
- package/dist/preview/{chunk.3D5T3XIE.js → chunk.H5CZZZLX.js} +1 -1
- package/dist/preview/{chunk.V5ZT5NSJ.js → chunk.HA3PPIEQ.js} +1 -1
- package/dist/preview/chunk.HFDYFPMJ.js +1 -0
- package/dist/preview/chunk.HFYUAK5Z.js +6 -0
- package/dist/preview/chunk.HGS32FT2.js +1 -0
- package/dist/preview/chunk.HHUCPVG5.js +1 -0
- package/dist/preview/{chunk.LF7PU77M.js → chunk.I7CU2E3C.js} +1 -1
- package/dist/preview/{chunk.MCVY6RRS.js → chunk.IAZRY42B.js} +1 -1
- package/dist/preview/{chunk.5MSO3KRO.js → chunk.ITEF3U2E.js} +1 -1
- package/dist/preview/{chunk.AZCFXPEL.js → chunk.IXYBIDAN.js} +1 -1
- package/dist/preview/{chunk.FTJBW25J.js → chunk.J3M2MZHG.js} +1 -1
- package/dist/preview/{chunk.MVNUWK5Y.js → chunk.JBTU2PJ4.js} +1 -1
- package/dist/preview/chunk.JCR3ECUM.js +1 -0
- package/dist/preview/{chunk.JWJQ2VXS.js → chunk.JEZTPXEB.js} +1 -1
- package/dist/preview/chunk.KIJCOW25.js +1 -0
- package/dist/preview/{chunk.2EJAIT33.js → chunk.KJNUZYXS.js} +1 -1
- package/dist/preview/chunk.L7DQKPJV.js +117 -0
- package/dist/preview/{chunk.RVJYEOFN.js → chunk.LCYMYLOP.js} +1 -1
- package/dist/preview/chunk.LP2DJ5ZB.js +6 -0
- package/dist/preview/chunk.LP3QUPCE.js +1 -0
- package/dist/preview/chunk.M5QFUGGG.js +1 -0
- package/dist/preview/chunk.N2SV3KX7.js +1 -0
- package/dist/preview/chunk.N7N5OFPL.js +1 -0
- package/dist/preview/{chunk.WERYQENC.js → chunk.NG3YMQ36.js} +1 -1
- package/dist/preview/{chunk.MWZK3HVG.js → chunk.NSNGPQGT.js} +1 -1
- package/dist/preview/chunk.OJKS3UQS.js +1 -0
- package/dist/preview/{chunk.KNJZ2YNJ.js → chunk.OM5CDW2S.js} +1 -1
- package/dist/preview/{chunk.QT4XGC5Z.js → chunk.ORXFUK6F.js} +2 -2
- package/dist/preview/chunk.OXTUXWMU.js +1 -0
- package/dist/preview/chunk.OYMM2UWE.js +1 -0
- package/dist/preview/chunk.P3JYH6HO.js +1 -0
- package/dist/preview/{chunk.FMVWXSQ7.js → chunk.P4WYBSYA.js} +1 -1
- package/dist/preview/chunk.P5325GYR.js +1 -0
- package/dist/preview/chunk.PMER4LVT.js +1 -0
- package/dist/preview/chunk.PONWLTTB.js +1 -0
- package/dist/preview/chunk.PXQVXBNG.js +1 -0
- package/dist/preview/chunk.QCF6Z2AZ.js +1 -0
- package/dist/preview/chunk.QEXXLWEU.js +6 -0
- package/dist/preview/chunk.QMFUPTR4.js +1 -0
- package/dist/preview/{chunk.BUVAMSOZ.js → chunk.RM7NVN7B.js} +2 -2
- package/dist/preview/{chunk.YUJG5SN5.js → chunk.ROINZMNO.js} +1 -1
- package/dist/preview/chunk.ROKRQRID.js +35 -0
- package/dist/preview/chunk.RWB4235L.js +1 -0
- package/dist/preview/chunk.RXSHFG6S.js +1 -0
- package/dist/preview/chunk.SDO3U72B.js +1 -0
- package/dist/preview/chunk.SHNYYBNW.js +1 -0
- package/dist/preview/{chunk.L73VUBXN.js → chunk.SK33IHL2.js} +2 -2
- package/dist/preview/chunk.STBJV6HJ.js +1 -0
- package/dist/preview/chunk.TCUB6IDY.js +1 -0
- package/dist/preview/chunk.TJCTTJWE.js +1 -0
- package/dist/preview/{chunk.SZWX56WR.js → chunk.TU4KG22J.js} +2 -2
- package/dist/preview/chunk.U4E5GQTK.js +1 -0
- package/dist/preview/{chunk.Z3ZKYSPN.js → chunk.U7QMA4H7.js} +1 -1
- package/dist/preview/{chunk.UXIFQIHA.js → chunk.UB3O3QJQ.js} +1 -1
- package/dist/preview/{chunk.6XJP7F3I.js → chunk.UCZR33MK.js} +1 -1
- package/dist/preview/chunk.UGCNMAPC.js +1 -0
- package/dist/preview/{chunk.VKHKYK5L.js → chunk.UIUHGA6W.js} +1 -1
- package/dist/preview/chunk.VC4JPG7O.js +1 -0
- package/dist/preview/{chunk.DL637Q3W.js → chunk.W4OX4BMP.js} +1 -1
- package/dist/preview/chunk.WJQY4E45.js +1 -0
- package/dist/preview/{chunk.XHWL7QBF.js → chunk.WQPNGBR7.js} +1 -1
- package/dist/preview/chunk.WTZOOAIW.js +1 -0
- package/dist/preview/{chunk.FUJM7GDV.js → chunk.WXYUWBKX.js} +1 -1
- package/dist/preview/chunk.XBOZTQQA.js +1 -0
- package/dist/preview/{chunk.TOWYHWPB.js → chunk.XLI44BBI.js} +1 -1
- package/dist/preview/chunk.XLZ2QRRS.js +1 -0
- package/dist/preview/chunk.XQTMO5PW.js +1 -0
- package/dist/preview/chunk.YWVOACSX.js +5 -0
- package/dist/preview/{chunk.67WL7BGF.js → chunk.YXGI7H4Y.js} +1 -1
- package/dist/preview/{chunk.GR5Q4HTW.js → chunk.Z7JRBKA7.js} +1 -1
- package/dist/preview/chunk.ZR5KVYWZ.js +21 -0
- package/dist/preview/{chunk.6IHXTT6Z.js → chunk.ZTMDU3OH.js} +1 -1
- package/dist/preview/index.html +45 -43
- package/dist/preview/page.js +7 -7
- package/package.json +6 -6
- package/dist/preview/chunk.2HFRVWWM.js +0 -1
- package/dist/preview/chunk.3FW4QNGV.js +0 -1
- package/dist/preview/chunk.3RT2GUZ5.js +0 -1
- package/dist/preview/chunk.3ZRHHB7X.js +0 -1
- package/dist/preview/chunk.4DEUD66C.js +0 -6
- package/dist/preview/chunk.4EQSP7I3.js +0 -1
- package/dist/preview/chunk.4Y6BCHV2.js +0 -1
- package/dist/preview/chunk.5VBBQ6Z3.js +0 -1
- package/dist/preview/chunk.6CKBIY7L.js +0 -1
- package/dist/preview/chunk.7RSZMIAL.js +0 -1
- package/dist/preview/chunk.AFY35RJP.js +0 -1
- package/dist/preview/chunk.BRHRAVU2.js +0 -3
- package/dist/preview/chunk.DFVVS6C5.js +0 -1
- package/dist/preview/chunk.DQJAEU4V.js +0 -1
- package/dist/preview/chunk.ESSQAMPM.js +0 -1
- package/dist/preview/chunk.EV553KRT.js +0 -1
- package/dist/preview/chunk.EZP4FHDX.js +0 -35
- package/dist/preview/chunk.F6PIK2J2.js +0 -1
- package/dist/preview/chunk.FYIQZMVF.js +0 -1
- package/dist/preview/chunk.HUSFMFXH.js +0 -1
- package/dist/preview/chunk.HVTGPEVW.js +0 -1
- package/dist/preview/chunk.I3SQJ2L2.js +0 -1
- package/dist/preview/chunk.IU6ISXXC.js +0 -1
- package/dist/preview/chunk.K5KEECHL.js +0 -88
- package/dist/preview/chunk.L34FY7QQ.js +0 -1
- package/dist/preview/chunk.L7JKEEMM.js +0 -1
- package/dist/preview/chunk.LAW5PQEM.js +0 -1
- package/dist/preview/chunk.LDD3QX7G.js +0 -1
- package/dist/preview/chunk.LU5LSXSW.js +0 -1
- package/dist/preview/chunk.MQ7FNHXG.js +0 -25
- package/dist/preview/chunk.NH5TDAB2.js +0 -1
- package/dist/preview/chunk.NORRCKGN.js +0 -1
- package/dist/preview/chunk.NQQHOSOK.js +0 -1
- package/dist/preview/chunk.NWWMUOZM.js +0 -1
- package/dist/preview/chunk.OEF3GPRM.js +0 -1
- package/dist/preview/chunk.OS3L4ZOF.js +0 -2
- package/dist/preview/chunk.OTL3Z345.js +0 -1
- package/dist/preview/chunk.P3UPCI23.js +0 -1
- package/dist/preview/chunk.PGKIEDYV.js +0 -9
- package/dist/preview/chunk.PKUWET2F.js +0 -1
- package/dist/preview/chunk.POHEWJKZ.js +0 -1
- package/dist/preview/chunk.PUBG2L6F.js +0 -117
- package/dist/preview/chunk.QTTBZJ6W.js +0 -1
- package/dist/preview/chunk.RJDZOF2L.js +0 -1
- package/dist/preview/chunk.SGLJTSTD.js +0 -1
- package/dist/preview/chunk.SITFEJES.js +0 -1
- package/dist/preview/chunk.UF3L6FJO.js +0 -1
- package/dist/preview/chunk.VSYHU5MA.js +0 -1
- package/dist/preview/chunk.VTWFVPKD.js +0 -19
- package/dist/preview/chunk.VV4BPOIK.js +0 -1
- package/dist/preview/chunk.W2HCJQVK.js +0 -32
- package/dist/preview/chunk.WLPTY4BF.js +0 -5
- package/dist/preview/chunk.XM3NPZLP.js +0 -1
- package/dist/preview/chunk.YAXZNQY6.js +0 -1
- package/dist/preview/chunk.YG423NEB.js +0 -1
- package/dist/preview/chunk.YVR3ZMTV.js +0 -1
- package/dist/preview/chunk.YXH3IWNR.js +0 -1
- package/dist/preview/chunk.ZYCNEOAQ.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{c as _e,d as xe,e as Me}from"./chunk.IEDXW36H.js";import{q as $e}from"./chunk.2VIGF4FO.js";import{a as Ne}from"./chunk.FTJBW25J.js";import{f as K}from"./chunk.RZVZG2BQ.js";import{a as E}from"./chunk.V2NBJDAX.js";import{a as Re,b as G,d as Te}from"./chunk.MWZK3HVG.js";import{a as ge}from"./chunk.GR5Q4HTW.js";import{Aa as fe,Ca as pe,Cb as Ae,Da as V,Ec as Oe,Fb as q,J as le,Ka as me,La as he,Oa as ye,Ua as F,Xa as be,a as ce,ca as C,sb as we,va as ue,vb as ke,wb as Se,ya as U,zb as ve}from"./chunk.WLPTY4BF.js";var J=(t,n,e)=>{(t[n]===void 0||e>t[n])&&(t[n]=e)},D=(t,n,e)=>{(t[n]===void 0||e<t[n])&&(t[n]=e)},Z=(t,n)=>{t.format=n,n.includes("int")&&(t.isInt=!0)},Pe=(t,n)=>{t.mime=t.mime?t.mime.filter(e=>n.includes(e)):[...n]},Je=(t,n)=>{t.multipleOf??=[],t.multipleOf.includes(n)||t.multipleOf.push(n)},De=(t,n)=>(t.patterns??=new Set).add(n),Xe={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function z(t){let n={},{def:e,bag:r}=t._zod,i=t._zod.traits.has("$ZodCheck")?[t,...e.checks??[]]:e.checks??[];for(let o of i){let a=o._zod.def;switch(a.check){case"greater_than":J(n,a.inclusive?"minimum":"exclusiveMinimum",a.value);break;case"less_than":D(n,a.inclusive?"maximum":"exclusiveMaximum",a.value);break;case"multiple_of":Je(n,a.value);break;case"number_format":{Z(n,a.format);let d=Xe[a.format];d&&(J(n,"minimum",d[0]),D(n,"maximum",d[1]));break}case"bigint_format":Z(n,a.format);break;case"min_length":case"min_size":J(n,"minimum",a.minimum);break;case"max_length":case"max_size":D(n,"maximum",a.maximum);break;case"length_equals":J(n,"minimum",a.length),D(n,"maximum",a.length);break;case"size_equals":J(n,"minimum",a.size),D(n,"maximum",a.size);break;case"string_format":Z(n,a.format),a.pattern&&De(n,a.pattern),(a.format==="base64"||a.format==="base64url")&&(n.contentEncoding=a.format),(a.local||a.precision===-1)&&(n.laxFormat=!0);break;case"mime_type":Pe(n,a.mime);break}}r.minimum!==void 0&&J(n,"minimum",r.minimum),r.exclusiveMinimum!==void 0&&J(n,"exclusiveMinimum",r.exclusiveMinimum),r.maximum!==void 0&&D(n,"maximum",r.maximum),r.exclusiveMaximum!==void 0&&D(n,"exclusiveMaximum",r.exclusiveMaximum),r.multipleOf!==void 0&&Je(n,r.multipleOf),r.format!==void 0&&(n.format??=r.format,r.format.includes("int")&&(n.isInt=!0)),r.mime&&Pe(n,r.mime);for(let o of r.patterns??[])De(n,o);return n}var Qe={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""};function j(t){let n=t._zod.def;return n.type==="pipe"&&n.in._zod.traits.has("$ZodTransform")?j(n.out):n.type==="catch"?j(n.innerType):t._zod.optin}var en=new Set(["promise","optional","nonoptional","nullable","readonly","default","prefault","catch"]);function R(t,n=new Set){if(n.has(t))return!1;n.add(t);let e=t._zod.def,r=e.type;return r==="transform"?!0:r==="array"?R(e.element,n):r==="set"?R(e.valueType,n):r==="lazy"?R(e.getter(),n):en.has(r)?R(e.innerType,n):r==="intersection"?R(e.left,n)||R(e.right,n):r==="record"||r==="map"?R(e.keyType,n)||R(e.valueType,n):r==="pipe"?t._zod.traits.has("$ZodCodec")||R(e.in,n)||R(e.out,n):r==="object"?Object.values(e.shape).some(i=>R(i,n)):r==="union"?e.options.some(i=>R(i,n)):r==="tuple"?e.items.some(i=>R(i,n))||(e.rest?R(e.rest,n):!1):!1}function nn(t){let n=Object.values(t).filter(e=>typeof e=="number");return Object.entries(t).filter(([e])=>n.indexOf(+e)===-1).map(([,e])=>e)}function Ie(t){let n=t.anyOf;if(!Array.isArray(n)||n.length===0||t.type!==void 0)return;let e=[];for(let r of n){if(!r||typeof r!="object")return;Ie(r);let i=Object.keys(r);if(i.length!==1||i[0]!=="type")return;for(let o of[r.type].flat()){if(typeof o!="string")return;e.includes(o)||e.push(o)}}delete t.anyOf,t.type=e.length===1?e[0]:e}var je=new Set(["type","properties","required","additionalProperties"]),Ee=t=>{let n=t.additionalProperties;return n&&typeof n=="object"&&Object.keys(n).length?n:null},ze=(t,n)=>JSON.stringify(t)===JSON.stringify(n);function Y(t){for(let i of t){if(typeof i!="object"||i.type!=="object")return null;for(let o in i)if(!je.has(o))return null}let n={},e=new Set;for(let i of t){for(let o in i.properties){if(Object.prototype.hasOwnProperty.call(n,o))continue;let a=[];for(let d of t){let s=d.properties?.[o]??Ee(d);s&&!a.some(g=>ze(g,s))&&a.push(s)}n[o]=a.length===1?a[0]:Y(a)??{allOf:a}}for(let o of i.required??[])e.add(o)}let r={type:"object",properties:n};if(e.size&&(r.required=[...e]),t.every(i=>i.additionalProperties===!1))r.additionalProperties=!1;else{let i=[];for(let o of t){let a=Ee(o);a&&!i.some(d=>ze(d,a))&&i.push(a)}i.length===1?r.additionalProperties=i[0]:i.length>1&&(r.additionalProperties={allOf:i})}return r}function tn(t){let n=t.allOf;if(!Array.isArray(n)||n.length<2)return;for(let i of je)if(i in t)return;let e=n.filter(i=>Array.isArray(i.oneOf)||Array.isArray(i.anyOf)),r;if(!e.length)r=Y(n);else{let i=e[0],o=Array.isArray(i.oneOf)?"oneOf":"anyOf";if(Object.keys(i).length!==1)return;let a=n.filter(s=>s!==i),d=i[o].map(s=>Y([...a,s]));if(d.some(s=>!s))return;r={[o]:d}}r&&(delete t.allOf,Object.assign(t,r))}function He(t){let n=t;for(let k of["anyOf","oneOf"]){let A=n[k];if(!Array.isArray(A))continue;let m=A.map(He);m.some((l,w)=>l!==A[w])&&(n={...n,[k]:m})}let e=[n.type].flat(),r=!e.includes("string")&&e.some(k=>k==="number"||k==="integer"),i=n.enum??(n.const!==void 0?[n.const]:void 0);if(!r&&!i?.some(k=>typeof k=="number"))return n;let{minimum:o,maximum:a,exclusiveMinimum:d,exclusiveMaximum:s,multipleOf:g,format:f,id:b,...h}=n;return h.enum?h.enum=h.enum.map(k=>typeof k=="number"?String(k):k):typeof h.const=="number"&&(h.const=String(h.const)),r&&(h.type="string",i||(h.pattern=e.includes("number")?"^-?\\d+(?:\\.\\d+)?$":"^-?\\d+$")),h}var W=class{constructor(n,e){this.override=n;this.refs=e}done=new Map;path=[];cyclic=new Map;write(n,e=!1){let r=this.refs.get(n);if(r!==void 0&&!e)return{$ref:r};if(this.path.includes(n))return this.cyclic.has(n)||this.cyclic.set(n,""),{};let i=this.done.get(n);if(i)return i;this.path.push(n);try{let o=this.written(n);return this.done.set(n,o),o}finally{this.path.pop()}}written(n){let e={},r,i=n._zod.toJSONSchema?.();i?Object.assign(e,i):r=this.process(n,e);let o=ce.get(n);if(o)for(let d of Object.keys(o))e[d]=o[d];R(n)&&(delete e.examples,delete e.default),"_prefault"in e&&(e.default??=e._prefault,delete e._prefault);let a=e;if(r){let d=this.write(r);a={...e};for(let s of Object.keys(d))s in e||(a[s]=d[s])}return this.override({zodSchema:n,jsonSchema:a}),Ie(a),n._zod.def.type==="intersection"&&tn(a),a}process(n,e){let r=n._zod.def;switch(r.type){case"string":{e.type="string";let{minimum:i,maximum:o,format:a,patterns:d,contentEncoding:s,laxFormat:g}=z(n);if(typeof i=="number"&&(e.minLength=i),typeof o=="number"&&(e.maxLength=o),a&&(e.format=Qe[a]??a,(e.format===""||a==="time"||g)&&delete e.format),s&&(e.contentEncoding=s),d&&d.size>0){let f=[...d];f.length===1?e.pattern=f[0].source:e.allOf=f.map(b=>({pattern:b.source}))}return}case"number":{let{minimum:i,maximum:o,multipleOf:a,exclusiveMinimum:d,exclusiveMaximum:s,isInt:g}=z(n);if(e.type=g?"integer":"number",typeof d=="number"&&d>=(i??Number.NEGATIVE_INFINITY)?e.exclusiveMinimum=d:typeof i=="number"&&(e.minimum=i),typeof s=="number"&&s<=(o??Number.POSITIVE_INFINITY)?e.exclusiveMaximum=s:typeof o=="number"&&(e.maximum=o),a){let[f,...b]=new Set(a.filter(h=>Number.isFinite(h)&&h!==0).map(Math.abs));f!==void 0&&(e.multipleOf=f),b.length&&(e.allOf=[...e.allOf??[],...b.map(h=>({multipleOf:h}))])}return}case"boolean":case"success":e.type="boolean";return;case"null":e.type="null";return;case"never":e.not={};return;case"enum":{let i=nn(r.entries);i.length===0?e.not={}:(i.every(o=>typeof o=="number")&&(e.type="number"),i.every(o=>typeof o=="string")&&(e.type="string"),e.enum=i);return}case"literal":{let i=r.values.filter(o=>o!==void 0).map(o=>typeof o=="bigint"?Number(o):o);if(r.values.length===0)e.not={};else if(i.length===1)e.type=i[0]===null?"null":typeof i[0],e.const=i[0];else if(i.length>1){for(let o of["number","string","boolean"])i.every(a=>typeof a===o)&&(e.type=o);i.every(o=>o===null)&&(e.type="null"),e.enum=i}return}case"template_literal":e.type="string",e.pattern=n._zod.pattern.source;return;case"file":{e.type="string",e.format="binary",e.contentEncoding="binary";let{minimum:i,maximum:o,mime:a}=z(n);i!==void 0&&(e.minLength=i),o!==void 0&&(e.maxLength=o),a&&(a.length===0?e.not={}:a.length===1?e.contentMediaType=a[0]:e.anyOf=a.map(d=>({contentMediaType:d})));return}case"array":{let{minimum:i,maximum:o}=z(n);typeof i=="number"&&(e.minItems=i),typeof o=="number"&&(e.maxItems=o),e.type="array",e.items=this.write(r.element);return}case"object":{let i=r.shape;e.type="object";let o={};e.properties=o;for(let d in i)Object.defineProperty(o,d,{value:this.write(i[d]),writable:!0,enumerable:!0,configurable:!0});let a=Object.keys(i).filter(d=>j(i[d])===void 0);a.length>0&&(e.required=a),r.catchall?._zod.def.type==="never"?e.additionalProperties=!1:r.catchall&&(e.additionalProperties=this.write(r.catchall));return}case"union":e[r.inclusive===!1?"oneOf":"anyOf"]=r.options.map(i=>this.write(i));return;case"intersection":{let i=d=>"allOf"in d&&Object.keys(d).length===1,o=this.write(r.left),a=this.write(r.right);e.allOf=[...i(o)?o.allOf:[o],...i(a)?a.allOf:[a]];return}case"tuple":{let i=r.items;e.type="array",e.prefixItems=i.map(s=>this.write(s)),r.rest?e.items=this.write(r.rest):e.items=!1;let o=i.length;for(;o>0&&j(i[o-1])!==void 0;)o-=1;o>0&&(e.minItems=o),r.rest||(e.maxItems=i.length);let{minimum:a,maximum:d}=z(n);typeof a=="number"&&(e.minItems=a),typeof d=="number"&&(e.maxItems=d);return}case"record":{let i=r.keyType;e.type="object";let o=z(i).patterns;if(r.mode==="loose"&&o&&o.size>0){let d=this.write(r.valueType),s={};for(let g of o)s[g.source]=d;e.patternProperties=s}else e.propertyNames=He(this.write(i)),e.additionalProperties=this.write(r.valueType);let a=i._zod.values;if(a&&!r.partial&&j(r.valueType)===void 0){let d=[...a].filter(s=>typeof s=="string"||typeof s=="number");d.length>0&&(e.required=d.map(String))}return}case"nullable":e.anyOf=[this.write(r.innerType),{type:"null"}];return;case"default":case"prefault":{let i=r.defaultValue,o,a=!1,d=JSON.stringify(i,(s,g)=>typeof g=="bigint"?(a=!0,null):g);return!a&&d!==void 0&&(o=JSON.parse(d)),a||(e[r.type==="default"?"default":"_prefault"]=o),r.innerType}case"catch":{try{e.default=r.catchValue(void 0)}catch{}return r.innerType}case"readonly":return e.readOnly=!0,r.innerType;case"pipe":return r.in._zod.traits.has("$ZodTransform")?r.out:r.in;case"lazy":return n._zod.innerType;case"optional":case"nonoptional":case"promise":return r.innerType;default:return}}};function Le(t,n=()=>{}){let e=t,r=new W(n,new Map),i=r.write(e,!0);if(r.cyclic.size>0){let o=new Map,a=0,d=[];for(let g of r.cyclic.keys())if(g===e)o.set(g,"#");else{let f=`__schema${a++}`;o.set(g,`#/$defs/${f}`),d.push([g,f])}r=new W(n,o),i=r.write(e,!0);let s={};for(let[g,f]of d)s[f]=r.write(g,!0);d.length>0&&(i={...i,$defs:s})}return JSON.parse(JSON.stringify({$schema:"https://json-schema.org/draft/2020-12/schema",...i}))}function Fe(t){return Le(t,an)}var rn={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string"},on={phone:"A phone number as it is written, like +1 555 123 4567 or 020 7946 0958 ext. 12.",place:"An address or a place's name, as a person would search a map for it.",duration:"A length of time in whole minutes: 90 is 1 h 30 min."};function an(t){ue(t.zodSchema)&&(t.jsonSchema["x-graview-app-link"]=!0);let n=pe(t.zodSchema);if(n&&(t.jsonSchema.type==="string"||t.jsonSchema.type==="array")){t.jsonSchema["x-graview-linked"]={address:n.address,kinds:[...n.kinds],cardinality:n.cardinality};let s=n.kinds.join(" or "),g=`${n.cardinality==="many"?"Records":"A record"}: a ${s} in the app ${n.address}, as "${n.kinds[0]}:<id>" \u2014 an id found there with find_linked. Linking never changes that app.`,f=t.jsonSchema.description;typeof f=="string"&&f.includes(g)||(t.jsonSchema.description=`${typeof f=="string"&&f?`${f.replace(/\.?$/,".")} `:""}${g}`)}if(ye(t.zodSchema)&&(t.jsonSchema["x-graview-repeat"]=!0,!t.jsonSchema.type&&!t.jsonSchema.anyOf&&!t.jsonSchema.oneOf&&Object.assign(t.jsonSchema,sn())),ge(t.zodSchema)){t.jsonSchema.contentMediaType="text/markdown";let s=t.jsonSchema.description;typeof s=="string"&&s.endsWith("Written in Markdown.")||(t.jsonSchema.description=`${typeof s=="string"&&s?`${s.replace(/\.?$/,".")} `:""}Written in Markdown.`)}let e=Ae(t.zodSchema);if(e){let s=t.jsonSchema;s["x-graview-type"]=e,e==="duration"&&(s["x-graview-unit"]="minutes"),s.description??=on[e]}let r=ve(t.zodSchema,!1);if(r){let s=Re(r);t.jsonSchema["x-graview-format"]=s.format??"unit",s.currency&&(t.jsonSchema["x-graview-currency"]=s.currency),s.unit&&s.format!=="money"&&(t.jsonSchema["x-graview-unit"]=s.unit);let g=t.jsonSchema.description;t.jsonSchema.description=typeof g=="string"&&g.length>0?`${g} ${G(s)}`:G(s)}let i=t.zodSchema._zod?.def;if(!i||i.type!=="string"||typeof i.format!="string"||i.format==="regex")return;let o=t.jsonSchema,a=(i.checks??[]).map(s=>s._zod?.def).filter(s=>s?.format==="regex"&&s.pattern instanceof RegExp).map(s=>s.pattern.source);delete o.pattern;let d=o.allOf;Array.isArray(d)&&d.every(s=>typeof s=="object"&&s!==null&&Object.keys(s).length===1&&"pattern"in s)&&delete o.allOf,o.format=rn[i.format]??i.format,a.length===1?o.pattern=a[0]:a.length>1&&(o.allOf=a.map(s=>({pattern:s})))}function X(t){let n=q(t.input),e=Fe(t.input),r=e.properties??{};if(ke(t)){let i=t.creates.join(" | ");r.id={type:"string",minLength:1,description:`Optional: the id for the ${i} this makes. Refused if the graph already has it; left out, one is minted from the label.`},e.properties=r}Se(t)&&(e.additionalProperties=!1);for(let i of n){let o=r[i.name];if(!o)continue;let a=i.kinds.includes("*")?"any node kind":i.kinds.join(" | ");o.description=[o.description,`Id of a node (${a}).`].filter(Boolean).join(" ")}return{name:t.name,...t.title===void 0?{}:{title:t.title},description:t.description??t.title??t.name,inputSchema:e,nodeRefs:n}}function sn(){let t={type:"string",pattern:"^\\d{4}-\\d{2}-\\d{2}$"},n=(e,r)=>({type:"integer",minimum:e,maximum:r});return{type:"object",description:'How the date beside it repeats; the date is the first occurrence. "on" is weekdays for "week", days of the month (-1 the last) for "month".',properties:{every:{type:"string",enum:[...he]},interval:n(1,99),on:{type:"array",minItems:1,maxItems:31,items:{anyOf:[{type:"string",enum:[...me]},n(-1,31)]}},until:t,count:n(1,1e3),except:{type:"array",maxItems:500,items:t},continues:{type:"string",maxLength:200}},required:["every"],additionalProperties:!1}}function qe(t){let n=new Set;for(let e=t;e;e=e.onBehalfOf)e.id!==void 0&&n.add(`${e.kind}:${e.id}`);return n}function B(t,n){let e=qe(n),r=f=>{if(f.kind==="rule")return!1;let b=qe(f);if(b.size===0)return!1;for(let h of b)if(e.has(h))return!1;return!0},i,o=()=>{if(i)return i;i=new Map;for(let f of t.log.live()){if(f.undoes!==void 0)continue;let b=r(f.author)?f.author:void 0;for(let h of f.primitives){h.op==="remove-node"&&i.delete(h.node.id);let k=h.op==="add-node"?h.node.id:h.op==="patch-node"?h.id:void 0;if(k===void 0)continue;let A=h.op==="add-node"?Object.keys(h.node):Object.keys(h.after),m=i.get(k);(h.op==="add-node"||!m)&&i.set(k,m=new Map);for(let l of A)l==="id"||l==="kind"||(b?m.set(l,b):m.delete(l))}}return i},a=t.schema,d=new Map,s=(f,b)=>{let h=`${f}\0${b}`,k=d.get(h);if(k===void 0){let A=a.tryDefinition(f)?.fields?.shape;k=A!==void 0&&b in A&&Te(A[b]).type==="text",d.set(h,k)}return k},g=f=>t.graph.getNode(f)?.kind;return{prose:s,say:f=>F(f,{graph:t.graph,schema:a}),fieldBy(f,b){let h=g(f);if(!(h===void 0||!s(h,b)))return o().get(f)?.get(b)},recordBy(f){let b=g(f),h=o().get(f);if(b===void 0||!h)return;let k;for(let[A,m]of h)s(b,A)&&(k=m);return k}}}var Q=(t,n,e)=>({untrusted:!0,authoredBy:e.say(n),text:t}),dn="the host's ranker";function We(t,n){return{...t,hits:t.hits.map(e=>{if(e.about!=="node")return e;e.why.by==="meaning"&&e.why.matched!==void 0&&(e={...e,why:{...e.why,matched:{untrusted:!0,authoredBy:dn,text:e.why.matched}}});let r=n.recordBy(e.id);if(!r)return e;let i=n.prose(e.kind,e.why.field)?n.fieldBy(e.id,e.why.field):r;return{...e,label:Q(e.label,r,n),...e.apart!==void 0?{apart:Q(e.apart,r,n)}:{},why:i?{...e.why,fragment:Q(e.why.fragment,i,n)}:e.why}})}}var ee=(t,n,e)=>({title:t,readOnlyHint:n,destructiveHint:!1,idempotentHint:e,openWorldHint:!1}),cn={name:"subscribe",title:"Notify me when something happens",description:`Subscribe the person you act for to be told when something happens in this app \u2014 their host delivers it (an email, a push). on is one of: "act" (an act runs; give act, its declared name, and/or record), "created" (a record of kind is added), "changed" (a record of kind, or the one record, changes), "reaches" (a record of kind, or the one record, comes to satisfy condition, an expression in the app's rule language such as done == true or amount > 100). They are told only of changes someone else made, unless alsoMine is true, and only of records they may see. Returns the subscription and its sentence. Changes nothing in the app.`,inputSchema:{type:"object",properties:{on:{type:"string",enum:["act","created","changed","reaches"],description:"What to be told of."},act:{type:"string",description:"An act's declared name, for on: act."},kind:{type:"string",description:"A kind, for created, changed and reaches."},record:{type:"string",description:"One record, by id or name: for act, changed and reaches."},condition:{type:"string",description:"For reaches: what the record should come to satisfy, in the rule language (done == true)."},alsoMine:{type:"boolean",description:"Also when the person themselves made the change; false when unsaid."}},required:["on"],additionalProperties:!1},mutating:!1,annotations:ee("Notify me when something happens",!1,!1)},ln={name:"unsubscribe",title:"Stop notifying me",description:"Take away one of the person's subscriptions, by the id list_subscriptions or subscribe answered. Changes nothing in the app.",inputSchema:{type:"object",properties:{id:{type:"string",description:"The subscription's id."}},required:["id"],additionalProperties:!1},mutating:!1,annotations:ee("Stop notifying me",!1,!0)},un={name:"list_subscriptions",title:"What I am notified of",description:`List what the person you act for is told of in this app: each subscription's id and its sentence ("When someone else adds a task").`,inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:ee("What I am notified of",!0,!0)},ne=[cn,ln,un];var L=t=>{let n;return()=>n??=t().catch(e=>{throw n=void 0,e})},fn=L(()=>(__graviewPreload(import.meta.url,["./chunk.IM7LXLIB.js","./chunk.QYRPELLU.js","./chunk.2EJAIT33.js","./chunk.EUGWV3S6.js","./chunk.6XJP7F3I.js","./chunk.NPX7SPXM.js","./chunk.OE4QOBJF.js","./chunk.74RMHUCX.js","./chunk.3D5T3XIE.js","./chunk.GR5Q4HTW.js","./chunk.WLPTY4BF.js","./chunk.AJZBJBMO.js"]),import("./chunk.SGLJTSTD.js"))),pn=()=>(__graviewPreload(import.meta.url,["./chunk.V2NBJDAX.js","./chunk.NPX7SPXM.js","./chunk.OE4QOBJF.js","./chunk.74RMHUCX.js","./chunk.WLPTY4BF.js","./chunk.AJZBJBMO.js"]),import("./chunk.V5ZT5NSJ.js")).catch(()=>{}),mn=async()=>{(await pn())?.judgeWithLines()},H=L(()=>(__graviewPreload(import.meta.url,["./chunk.WVUJXDXZ.js","./chunk.2EJAIT33.js","./chunk.EUGWV3S6.js","./chunk.6XJP7F3I.js","./chunk.NPX7SPXM.js","./chunk.OE4QOBJF.js","./chunk.74RMHUCX.js","./chunk.GR5Q4HTW.js","./chunk.WLPTY4BF.js","./chunk.AJZBJBMO.js"]),import("./chunk.MVNUWK5Y.js"))),hn=L(()=>(__graviewPreload(import.meta.url,["./chunk.67WL7BGF.js","./chunk.G4JJXA63.js","./chunk.5MSO3KRO.js","./chunk.QYRPELLU.js","./chunk.MCVY6RRS.js","./chunk.RZVZG2BQ.js","./chunk.Q5WEOX3Q.js","./chunk.XHWL7QBF.js","./chunk.6UCRL4OF.js","./chunk.V2NBJDAX.js","./chunk.WVUJXDXZ.js","./chunk.2EJAIT33.js","./chunk.EUGWV3S6.js","./chunk.6XJP7F3I.js","./chunk.NPX7SPXM.js","./chunk.OE4QOBJF.js","./chunk.74RMHUCX.js","./chunk.MWZK3HVG.js","./chunk.3D5T3XIE.js","./chunk.GR5Q4HTW.js","./chunk.WLPTY4BF.js","./chunk.AJZBJBMO.js"]),import("./chunk.4Y6BCHV2.js"))),yn=L(()=>(__graviewPreload(import.meta.url,["./chunk.TKSGC6XH.js","./chunk.IM7LXLIB.js","./chunk.QYRPELLU.js","./chunk.FTJBW25J.js","./chunk.UT6642FC.js","./chunk.2EJAIT33.js","./chunk.EUGWV3S6.js","./chunk.6XJP7F3I.js","./chunk.NPX7SPXM.js","./chunk.OE4QOBJF.js","./chunk.74RMHUCX.js","./chunk.MWZK3HVG.js","./chunk.3D5T3XIE.js","./chunk.GR5Q4HTW.js","./chunk.WLPTY4BF.js","./chunk.AJZBJBMO.js"]),import("./chunk.QTTBZJ6W.js"))),gn=L(()=>(__graviewPreload(import.meta.url,["./chunk.SGB6IMWN.js","./chunk.NPX7SPXM.js","./chunk.OE4QOBJF.js","./chunk.74RMHUCX.js","./chunk.WLPTY4BF.js","./chunk.AJZBJBMO.js"]),import("./chunk.KNJZ2YNJ.js"))),bn=t=>t.definitions.some(n=>V(n).size>0),Be=t=>({value:U(t),label:t.label,...t.describe?{describe:t.describe}:{},...t.card?{card:t.card}:{},fields:t.fields,...t.app?{app:t.app}:{}});async function wn(t,n,e,r){let i=String(e.relation??""),[o,a]=i.includes(".")?i.split(".",2):[void 0,i],d=t.schema.definitions.flatMap(l=>[...V(l)].map(([w,S])=>({kind:l.kind,name:w,relation:S}))),s=d.filter(l=>l.name===a&&(o===void 0||l.kind===o));if(s.length!==1){let l=d.map(w=>`${w.kind}.${w.name}`).join(", ")||"none";return{ok:!1,error:`${s.length===0?`No relation to another app is called "${i}"`:`"${i}" names a relation of several kinds`}. The relations to other apps are: ${l}.`}}let{kind:g,name:f,relation:b}=s[0];if(!r)return{ok:!1,error:`This seat cannot read ${b.address}: its host reads no other app's records. Nothing was changed.`};let h={kind:n.kind,...n.id===void 0?{}:{id:n.id},...n.roles?{roles:n.roles}:{}},k=typeof e.of=="string"?e.of:void 0;if(k!==void 0){let l=t.graph.getNode(k);if(!l||l.kind!==g)return{ok:!1,error:`No ${g} "${k}".`};let w=fe(l[f],b),S=await Promise.all(w.map(c=>Promise.resolve().then(()=>r.resolve(c,h)).catch(()=>null)));return{ok:!0,data:{relation:`${g}.${f}`,app:b.address,records:S.map((c,u)=>c===null?{value:U(w[u]),missing:!0}:"denied"in c?{denied:!0,said:"linked record (no access)"}:Be(c))},reads:[k]}}let A=typeof e.limit=="number"&&e.limit>0?Math.min(e.limit,20):20,m=await Promise.resolve().then(()=>r.find({address:b.address,kinds:b.kinds,query:String(e.query??""),limit:A},h)).catch(()=>[]);return Array.isArray(m)?{ok:!0,data:{relation:`${g}.${f}`,app:b.address,records:m.map(Be),link:`edit-${g} with ${f} set to a record's value`}}:{ok:!0,data:{relation:`${g}.${f}`,app:b.address,denied:!0,said:"linked record (no access)"}}}var _=t=>({title:t,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}),Ce={description:'Which records: false (the default) the live ones, true only the archived ones, "all" both. An archived record is set aside, not gone: unarchive-<kind> brings it back.',anyOf:[{type:"boolean"},{type:"string",enum:["all"]}]},te={type:"number",description:"Where the page starts; 0 when unsaid."},oe=[{name:"search_graph",title:"Find by name",description:"Find things by name: records whose name or readable fields carry the words, and the kinds, places and rules the words name \u2014 each with why it matched. Reach for this before get_graph when you know what something is called. Words match the start of words, case and accents aside; key:value tokens narrow as a list's filter does (done:false, is:any for past records, kind:<kind>). Pass subject (a node id) to get the acts you may run on it as hits too. When few records match exactly, records with a near word follow \u2014 a typo, another form of the word, a meaning \u2014 each with near: true and why.matched, the record's own word that answered.",inputSchema:{type:"object",properties:{query:{type:"string",description:"Words, with optional key:value conditions."},limit:{type:"number",description:"Most hits to return; at most 20."},subject:{type:"string",description:"A node id whose acts to include."},archived:Ce},required:["query"],additionalProperties:!1},mutating:!1,annotations:_("Find by name")},{name:"get_graph",title:"Read the graph",description:"Read the graph, 25 nodes a page: their fields, the edges out of them, and how many more. Start here when you need the shape of the domain rather than one thing in it.",inputSchema:{type:"object",properties:{offset:te,archived:Ce},additionalProperties:!1},mutating:!1,annotations:_("Read the graph")},{name:"get_node",title:"Read one node",description:"Read one node: its fields, its links (id, kind and label, 20 each way a page), the violations that implicate it, and its computed values: read-only fields worked out from what you can see, which no act sets. Use this to check a thing before you change it.",inputSchema:{type:"object",properties:{id:{type:"string",description:"A node's id, or its name."},offset:te},required:["id"],additionalProperties:!1},mutating:!1,annotations:_("Read one node")},{name:"get_violations",title:"List the problems",description:"List the invariant violations the graph currently has, 20 a page, with the repairs that would resolve each one. Read this before proposing work: a rule that is already broken is more urgent than anything you could add.",inputSchema:{type:"object",properties:{offset:te,context:{type:"object",description:"Evaluation context, e.g. { weekStart }."}},additionalProperties:!1},mutating:!1,annotations:_("List the problems")},{name:"get_affordances",title:"Ask what can be done",description:"Ask what can legally be done with a selection, ranked. Prefer these over composing a mutation by hand: they are derived from the schema, the invariants and the shape of the graph, so they cannot name an action that does not exist.",inputSchema:{type:"object",properties:{selection:{type:"array",items:{type:"string"},description:"Node ids."},context:{type:"object"}},required:["selection"],additionalProperties:!1},mutating:!1,annotations:_("Ask what can be done")},{name:"describe_place",title:"Say what a place shows",description:`Say what one place of the app shows you, as a person in your seat would see it: its headings, its figures as drawn, its lists with each record's title and what its card or row says, the headings a list is grouped under, what an empty list says, and any block that could not be worked out. Pass a place's slug ("home", a lens's address like "the-offers", a kind's like "offers") or a record's id, and width 390 for a phone. Use it after a change to check what somebody now sees, instead of guessing.`,inputSchema:{type:"object",properties:{place:{type:"string",description:`"home", a place's slug, or a record's id.`},width:{type:"number",description:"The screen's width in CSS pixels; 390 is a phone, 1440 when unsaid."}},required:["place"],additionalProperties:!1},mutating:!1,annotations:_("Say what a place shows")},{name:"preview_mutation",title:"Try an act without applying it",description:"Try a mutation without applying it: get back the diff it would produce and any invariant it would break. Do this when you are unsure, rather than applying and undoing.",inputSchema:{type:"object",properties:{mutation:{type:"string"},args:{type:"object"}},required:["mutation","args"],additionalProperties:!1},mutating:!1,annotations:_("Try an act without applying it")},{name:"undo_batch",title:"Undo a batch",description:"Undo one batch of operations. Fails, naming the blocking operation, when a later operation read what it wrote.",inputSchema:{type:"object",properties:{batch:{type:"string"},include:{type:"array",items:{type:"string"}}},required:["batch"],additionalProperties:!1},mutating:!0,annotations:{title:"Undo a batch",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1}},{name:"list_suggestions",title:"List what is suggested",description:"List the suggestions waiting for a person: changes the app's own actor proposed and did not make, each with its id, what it would do, who suggested it, what it was based on and how sure (0 to 1). Nothing changes until one is accepted (accept_suggestion) or declined (decline_suggestion); a declined one is never suggested again.",inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:_("List what is suggested")},{name:"accept_suggestion",title:"Accept a suggestion",description:"Make a waiting suggestion's change, as this seat, carrying what it was based on. Returns the batch (undo_batch takes it back).",inputSchema:{type:"object",properties:{suggestion:{type:"string",description:"The suggestion's id, from list_suggestions."}},required:["suggestion"],additionalProperties:!1},mutating:!0,annotations:{title:"Accept a suggestion",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1}},{name:"decline_suggestion",title:"Decline a suggestion",description:"Decline a waiting suggestion: nothing changes, the decline is kept in the log, and the same change is never suggested or made by the app's own actor again.",inputSchema:{type:"object",properties:{suggestion:{type:"string",description:"The suggestion's id, from list_suggestions."}},required:["suggestion"],additionalProperties:!1},mutating:!0,annotations:{title:"Decline a suggestion",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}}],Ve={name:"act_on_several",title:"Do one act to several records",description:`Run one act on several records at once, as one change with one undo. act is the act (its tool name or its declared name), records the records it runs on (ids or names; each goes in the act's subject), args what every call shares ("Set stage to Declined" is args { stage: "declined" }). Each record is judged on its own: one this seat may not change is named with why, and the rest still apply. Returns the batch (undo_batch takes it all back), the records changed, those already so, and those refused.`,inputSchema:{type:"object",properties:{act:{type:"string",description:"The act to run on each record."},records:{type:"array",items:{type:"string"},minItems:1,maxItems:200,description:"Ids or names of the records."},args:{type:"object",description:"Arguments every call shares, besides the record."}},required:["act","records"],additionalProperties:!1},mutating:!0,annotations:{title:"Do one act to several records",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1}},ae={type:"object",description:"A lens, as draft_view returns one.",properties:{title:{type:"string"},lens:{type:"string"},on:{type:"string"},bindings:{type:"object"},options:{type:"object"}},required:["title","lens","on"]},se={name:"draft_view",title:"Draw a view",description:'Draw a view of the data from words ("a board of tasks by status", "who covers what") as a lens the app could keep; or check a lens you wrote (lens); or change the one on screen (current, with ask: "only this month"). Returns the lens and its add-lens edit, or one sentence saying why not. Writes nothing.',inputSchema:{type:"object",properties:{ask:{type:"string",description:"What to see, in words."},lens:ae,current:ae},additionalProperties:!1},mutating:!1,annotations:_("Draw a view")},Ge={name:"keep_lens",title:"Keep a view as a lens",description:"Keep a lens draft_view drew as one of the app's places: checked again, then written as the add-lens edit. Returns the remove-lens edit that takes it back.",inputSchema:{...ae,additionalProperties:!1},mutating:!0,annotations:{title:"Keep a view as a lens",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},Ke={name:"find_linked",title:"Find a record in another app",description:`A relation may go to a kind in another app (describe_app lists them under "Linked from other apps"). With relation and words, list the records there this seat may link \u2014 each with the value to link it by ("house:h1"), its name and its describe line. With of (a record id here), read the records that record links, as this seat may see them there. Linking one is the record's edit (edit-<kind>) with the relation set to the value. Another app this seat may not open answers denied, and nothing of it. Writes nothing; never changes the other app.`,inputSchema:{type:"object",properties:{relation:{type:"string",description:"The relation, by name (forHouse) or as <kind>.<relation> (scenario.forHouse)."},query:{type:"string",description:"Words to find by, in the other app's names; empty for the first few."},of:{type:"string",description:"A record here whose linked records to read, instead of finding."},limit:{type:"number",description:"Most records to return; at most 20."}},required:["relation"],additionalProperties:!1},mutating:!1,annotations:_("Find a record in another app")};function kn(t,n){return t===void 0?[]:t==="keep"&&!n?[se,Ge]:[se]}var Sn="An argument that names a record takes its id or its name.",Ze=[...oe.map(t=>t.name),Ve.name,se.name,Ge.name,Ke.name,...ne.map(t=>t.name)],Ye=64;function x(t){let{line:n,...e}=t;return e}function Ue(t){return{...t,...t.introduces?{introduces:t.introduces.map(x)}:{},...t.resolves?{resolves:t.resolves.map(x)}:{},...t.violationsAfter?{violationsAfter:t.violationsAfter.map(x)}:{}}}function vn(t){let n=t.normalize("NFKD").replace(/\p{M}/gu,"").replace(/[^A-Za-z0-9_-]/g,"_");return n.length===0&&(n="act"),/^[A-Za-z_]/.test(n)||(n=`act_${n}`),n.slice(0,Ye)}function An(t){let n=new Set(Ze),e=new Map;for(let r of t){let i=vn(r),o=i;for(let a=2;n.has(o);a+=1)o=`${i.slice(0,Ye-`_${a}`.length)}_${a}`;n.add(o),e.set(r,o)}return e}function On(t,n){if(n.size===0)return t;let e=Object.fromEntries(Object.entries(t.properties??{}).filter(([i])=>!n.has(i))),r=(t.required??[]).filter(i=>!n.has(i));return{...t,properties:e,...t.required?{required:r}:{}}}function Rn(t,n,e){let r=X(t),i=C(t),o=r.nodeRefs.length>0?`${r.description}${/[.!?]$/.test(r.description)?"":"."} ${Sn}`:r.description;return{name:n,title:i,description:o,inputSchema:On(r.inputSchema,e),mutating:!0,annotations:{title:i,readOnlyHint:!1,destructiveHint:t.destructive===!0||(t.severs?.length??0)>0,idempotentHint:t.idempotent===!0,openWorldHint:!1},act:t.name}}function de(t){if(t===null||typeof t!="object")return JSON.stringify(t)??"null";if(Array.isArray(t))return`[${t.map(de).join(",")}]`;let n=t;return`{${Object.keys(n).filter(e=>n[e]!==void 0).sort().map(e=>`${JSON.stringify(e)}:${de(n[e])}`).join(",")}}`}function Tn(t){return`sha256:${Oe(de(t))}`}function _n(t,n,e,r,i,o=!1,a=!1){let d=An(t.map(f=>f.name)),s=[...kn(r,e),...o?[Ke]:[],...a?ne:[]];return{definitions:e?[...oe.filter(f=>!f.mutating),...s]:[...oe,Ve,...s,...t.filter(f=>n.has(f.name)).map(f=>Rn(f,d.get(f.name),i(f)))],names:d}}function lt(t,n={}){let e=n.author??{kind:"agent"},r=t.allMutations(),i=new Set(t.permittedMutations(e).map(m=>m.name)),{definitions:o,names:a}=_n(r,i,n.readOnly===!0,n.drafts?n.drafts.keep?"keep":"draw":void 0,m=>K(t.schema,t.policy,e,m),bn(t.schema),n.subscriptions!==void 0),d=Tn(o),s={app:n.app?.brand?.locale,appTimeZone:n.app?.brand?.timeZone},g=m=>le(s,m),f=m=>{if(!Ze.includes(m)){for(let[l,w]of a)if(w===m)return l;return a.has(m)?m:void 0}},b=(m,l)=>{let w=r.find(u=>u.name===m);if(!w)return{args:l,resolved:[]};let S={...l},c=[];for(let u of q(w.input)){let p=S[u.name];if(typeof p!="string"||p.trim()==="")continue;let y=t.resolveRef(u,p,e);if(!y.ok){let v=y.reason==="none"?` Nothing was changed. Use search_graph to look it up, then pass its id as ${u.name}.`:" Nothing was changed.";return{ok:!1,error:`${y.message}${v}`,argument:u.name,candidates:y.candidates}}y.by!=="id"&&(S[u.name]=y.id,c.push({argument:u.name,given:p,id:y.id,label:y.label}))}return{args:S,resolved:c}},h=async(m,l)=>{try{await mn();let w=o.find(c=>c.name===m)??o.find(c=>c.act===m);if(!w){let c=f(m);if(c){let u=t.permits({name:c,args:l},e);if(!u.ok)return{ok:!1,error:u.refusal.message,reason:"forbidden"}}return{ok:!1,error:`Unknown tool "${m}". Available: ${o.map(u=>u.name).join(", ")}`}}if(w.mutating&&n.readOnly)return{ok:!1,error:`"${m}" changes the graph, and this seat is read-only.`,reason:"forbidden"};if(w.act!==void 0){let c=b(w.act,l);if("ok"in c)return c;let u=w.act,p=g(()=>E(t,e,t.apply({name:u,args:c.args},{...n.author?{author:n.author}:{},...ie(n.via)})));return{ok:!0,data:{batch:p.batch,intent:p.intent,introduces:p.introduces.map(x),resolves:p.resolves.map(x),...c.resolved.length>0?{resolved:c.resolved}:{}},diff:p.diff}}let S=t.seenBy(e);switch(w.name){case"search_graph":{let c=typeof n.places=="function"?n.places():n.places,u=typeof l.subject=="string"?l.subject:void 0,p=$e(S,String(l.query??""),{principal:e,rank:n.near,archived:be(l.archived),limit:typeof l.limit=="number"&&l.limit>0?Math.min(l.limit,20):20,...c?{places:c}:{},...u?{subject:u,from:[u]}:{}}),y=p.later?await p.later:p;return{ok:!0,data:(await H()).searchRead(y,We(y,B(S,e))),reads:y.hits.flatMap(v=>v.about==="node"?[v.id]:[])}}case"get_graph":return{ok:!0,...(await H()).graphRead(S,B(S,e),l)};case"get_node":{let c=String(l.id??""),u=c,p;if(!S.graph.getNode(c)){let v=c.trim()===""?void 0:t.resolveRef({name:"id",kinds:["*"]},c,e);if(v?.ok)u=v.id,p={argument:"id",given:c,id:u,label:v.label};else return v?.reason==="ambiguous"?{ok:!1,error:v.message,argument:"id",candidates:v.candidates}:{ok:!1,error:`No node "${c}".`}}let y=(await H()).nodeRead(S,B(S,e),u,l);return{ok:!0,data:p?{...y.data,resolved:[p]}:y.data,reads:y.reads}}case"describe_place":{let c=n.app??{name:"",schema:t.schema},u=typeof l.width=="number"&&Number.isFinite(l.width)&&l.width>0?l.width:1440,{describePlace:p}=await fn(),y=p(t,e,String(l.place??""),{app:c,width:u});if(!y.ok)return{ok:!1,error:`${y.error} The places are: ${y.places.join(", ")}.`};let v=new Set,M=I=>{for(let $ of I)for(let T of $.groups??[])for(let N of T.items)v.add(N.id),M(N.parts)};return M(y.description.parts),{ok:!0,data:y.description,reads:[...v]}}case"find_linked":return wn(S,e,l,n.linked);case"draft_view":case"keep_lens":{let c=n.app??{name:"",schema:t.schema};return(await hn()).runDraftTool(w.name,l,{app:c,principal:e,...n.drafts?{drafts:n.drafts}:{}})}case"get_violations":{let c=S.violations(l.context);return{ok:!0,...(await H()).violationsRead(c,l)}}case"get_affordances":{let c=l.selection??[];return{ok:!0,data:Ne(S,c,{...typeof n.derive=="function"?n.derive():n.derive,...n.author?{principal:n.author}:{},...l.context?{context:l.context}:{}}),reads:c.filter(p=>S.graph.has(p))}}case"preview_mutation":{let c=String(l.mutation),u=f(c)??c,p=b(u,l.args??{});if("ok"in p)return p;let y=t.missingFor({name:u,args:p.args},e);if(y)return{ok:!1,error:y.message,reason:"missing"};let v=E(t,e,t.preview({name:u,args:p.args},void 0,{author:e})),M=Ue(v);return{ok:!0,data:p.resolved.length>0?{...M,resolved:p.resolved}:M}}case"act_on_several":{let c=String(l.act??""),u=f(c)??c,p=r.find(O=>O.name===u);if(!p||!i.has(u)){let O=p?t.permits({name:u,args:{}},e):void 0;return O&&!O.ok?{ok:!1,error:O.refusal.message,reason:"forbidden"}:{ok:!1,error:`There is no act "${c}" this seat may run. Nothing was changed.`,reason:"invalid"}}let y=p.subject;if(!y)return{ok:!1,error:`"${C(p)}" does not act on a record, so it cannot be run on several. Nothing was changed.`,reason:"invalid"};let v=Array.isArray(l.records)?l.records.filter(O=>typeof O=="string"&&O.trim()!==""):[];if(v.length===0)return{ok:!1,error:"Name at least one record. Nothing was changed.",reason:"invalid"};let M=[],I=[];for(let O of v.slice(0,200)){let P=t.resolveRef({name:y.arg,kinds:y.kinds},O,e);if(!P.ok)return{ok:!1,error:`${P.message} Nothing was changed.`,argument:"records",candidates:P.candidates};M.push(P.id),P.by!=="id"&&I.push({argument:"records",given:O,id:P.id,label:P.label})}let $=b(u,{...l.args??{}});if("ok"in $)return $;let T=(await yn()).actOnSeveral(t,{mutation:u,subject:y.arg,args:$.args},M,{author:e,...ie(n.via)}),N=T.result?E(t,e,T.result):void 0;return{ok:!0,data:{...T.batch?{batch:T.batch,intent:T.intent}:{},applied:T.applied,unchanged:T.unchanged,refused:T.refused.map(O=>({record:O.id,label:O.label,error:O.message,reason:O.reason})),...T.allOrNothing?{keptNone:!0}:{},...N?{introduces:N.introduces.map(x),resolves:N.resolves.map(x)}:{},...I.length>0||$.resolved.length>0?{resolved:[...I,...$.resolved]}:{}},...N?{diff:N.diff}:{}}}case"subscribe":case"unsubscribe":case"list_subscriptions":{let c=await(await gn()).runSubscriptionTool(w.name,l,{store:t,principal:n.subscriber??e,app:n.app?.name??"app",subscriptions:n.subscriptions});return c.ok?{ok:!0,data:c.data}:{ok:!1,error:c.error}}case"list_suggestions":{let c=_e(t,e).map(u=>{let p=F(u.author,{graph:S.graph,schema:t.schema});return{id:u.id,intent:u.intent,by:p,at:u.at,about:u.about,...u.lineage?{basis:{untrusted:!0,authoredBy:p,text:u.lineage.basis},...u.lineage.confidence!==void 0?{confidence:u.lineage.confidence}:{}}:{}}});return{ok:!0,data:{suggestions:c},reads:[...new Set(c.flatMap(u=>u.about))]}}case"accept_suggestion":case"decline_suggestion":{let c=String(l.suggestion??""),u={author:e,...ie(n.via)},p=w.name==="accept_suggestion"?xe(t,c,u):Me(t,c,u),y=E(t,e,p);return{ok:!0,data:{batch:y.batch,intent:y.intent,introduces:y.introduces.map(x),resolves:y.resolves.map(x)},diff:y.diff}}case"undo_batch":{let c=String(l.batch),u=l.include??[],p=S.canUndo([c,...u]);if(!p.ok)return{ok:!1,error:p.message};let y=E(t,e,t.undo([c,...u],{...n.author?{author:n.author}:{}}));return{ok:!0,data:Ue(y),diff:y.diff}}default:return{ok:!1,error:`Unknown tool "${m}".`}}}catch(w){let{reason:S,wouldNeed:c}=we(w);return{ok:!1,error:w instanceof Error?w.message:String(w),reason:S,...c?{wouldNeed:c}:{}}}},k=new Set,A=m=>{for(let l of k)l(m)};return{definitions:o,hash:d,...n.author?{author:n.author}:{},onDiff(m){return t.subscribe(m)},onCall(m){return k.add(m),()=>k.delete(m)},async call(m,l){let w=(o.find(p=>p.name===m)??o.find(p=>p.act===m))?.mutating??!1,S={name:m,args:l,mutating:w,at:new Date().toISOString()};A({...S,phase:"running"});let c=p=>(A(p.ok?{...S,phase:"ok",...!w&&p.reads?{reads:p.reads}:{}}:{...S,phase:"failed",error:p.error}),p),u=await h(m,l);return c(u.ok&&!w?{...u,data:(await H()).withinReadChars(m,u.data)}:u)}}}function ie(t){let n=typeof t=="function"?t():t;return n?{via:n}:{}}export{de as a,lt as b};
|
|
1
|
+
var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{c as _e,d as xe,e as Me}from"./chunk.EWWJMS6G.js";import{q as $e}from"./chunk.7EFNLMKU.js";import{a as Ne}from"./chunk.J3M2MZHG.js";import{f as K}from"./chunk.FMN5XDLE.js";import{a as E}from"./chunk.B7TB6YRZ.js";import{a as Re,b as G,d as Te}from"./chunk.NSNGPQGT.js";import{a as ge}from"./chunk.Z7JRBKA7.js";import{Aa as fe,Ab as ve,Ca as pe,Da as V,Db as Ae,Gb as q,Hc as Oe,J as le,Ka as me,La as he,Oa as ye,Ua as F,Xa as be,a as ce,ca as C,tb as we,va as ue,wb as ke,xb as Se,ya as U}from"./chunk.5ZMENPY4.js";var J=(t,n,e)=>{(t[n]===void 0||e>t[n])&&(t[n]=e)},D=(t,n,e)=>{(t[n]===void 0||e<t[n])&&(t[n]=e)},Z=(t,n)=>{t.format=n,n.includes("int")&&(t.isInt=!0)},Pe=(t,n)=>{t.mime=t.mime?t.mime.filter(e=>n.includes(e)):[...n]},Je=(t,n)=>{t.multipleOf??=[],t.multipleOf.includes(n)||t.multipleOf.push(n)},De=(t,n)=>(t.patterns??=new Set).add(n),Xe={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function z(t){let n={},{def:e,bag:r}=t._zod,i=t._zod.traits.has("$ZodCheck")?[t,...e.checks??[]]:e.checks??[];for(let o of i){let a=o._zod.def;switch(a.check){case"greater_than":J(n,a.inclusive?"minimum":"exclusiveMinimum",a.value);break;case"less_than":D(n,a.inclusive?"maximum":"exclusiveMaximum",a.value);break;case"multiple_of":Je(n,a.value);break;case"number_format":{Z(n,a.format);let d=Xe[a.format];d&&(J(n,"minimum",d[0]),D(n,"maximum",d[1]));break}case"bigint_format":Z(n,a.format);break;case"min_length":case"min_size":J(n,"minimum",a.minimum);break;case"max_length":case"max_size":D(n,"maximum",a.maximum);break;case"length_equals":J(n,"minimum",a.length),D(n,"maximum",a.length);break;case"size_equals":J(n,"minimum",a.size),D(n,"maximum",a.size);break;case"string_format":Z(n,a.format),a.pattern&&De(n,a.pattern),(a.format==="base64"||a.format==="base64url")&&(n.contentEncoding=a.format),(a.local||a.precision===-1)&&(n.laxFormat=!0);break;case"mime_type":Pe(n,a.mime);break}}r.minimum!==void 0&&J(n,"minimum",r.minimum),r.exclusiveMinimum!==void 0&&J(n,"exclusiveMinimum",r.exclusiveMinimum),r.maximum!==void 0&&D(n,"maximum",r.maximum),r.exclusiveMaximum!==void 0&&D(n,"exclusiveMaximum",r.exclusiveMaximum),r.multipleOf!==void 0&&Je(n,r.multipleOf),r.format!==void 0&&(n.format??=r.format,r.format.includes("int")&&(n.isInt=!0)),r.mime&&Pe(n,r.mime);for(let o of r.patterns??[])De(n,o);return n}var Qe={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""};function j(t){let n=t._zod.def;return n.type==="pipe"&&n.in._zod.traits.has("$ZodTransform")?j(n.out):n.type==="catch"?j(n.innerType):t._zod.optin}var en=new Set(["promise","optional","nonoptional","nullable","readonly","default","prefault","catch"]);function R(t,n=new Set){if(n.has(t))return!1;n.add(t);let e=t._zod.def,r=e.type;return r==="transform"?!0:r==="array"?R(e.element,n):r==="set"?R(e.valueType,n):r==="lazy"?R(e.getter(),n):en.has(r)?R(e.innerType,n):r==="intersection"?R(e.left,n)||R(e.right,n):r==="record"||r==="map"?R(e.keyType,n)||R(e.valueType,n):r==="pipe"?t._zod.traits.has("$ZodCodec")||R(e.in,n)||R(e.out,n):r==="object"?Object.values(e.shape).some(i=>R(i,n)):r==="union"?e.options.some(i=>R(i,n)):r==="tuple"?e.items.some(i=>R(i,n))||(e.rest?R(e.rest,n):!1):!1}function nn(t){let n=Object.values(t).filter(e=>typeof e=="number");return Object.entries(t).filter(([e])=>n.indexOf(+e)===-1).map(([,e])=>e)}function Ie(t){let n=t.anyOf;if(!Array.isArray(n)||n.length===0||t.type!==void 0)return;let e=[];for(let r of n){if(!r||typeof r!="object")return;Ie(r);let i=Object.keys(r);if(i.length!==1||i[0]!=="type")return;for(let o of[r.type].flat()){if(typeof o!="string")return;e.includes(o)||e.push(o)}}delete t.anyOf,t.type=e.length===1?e[0]:e}var je=new Set(["type","properties","required","additionalProperties"]),Ee=t=>{let n=t.additionalProperties;return n&&typeof n=="object"&&Object.keys(n).length?n:null},ze=(t,n)=>JSON.stringify(t)===JSON.stringify(n);function Y(t){for(let i of t){if(typeof i!="object"||i.type!=="object")return null;for(let o in i)if(!je.has(o))return null}let n={},e=new Set;for(let i of t){for(let o in i.properties){if(Object.prototype.hasOwnProperty.call(n,o))continue;let a=[];for(let d of t){let s=d.properties?.[o]??Ee(d);s&&!a.some(g=>ze(g,s))&&a.push(s)}n[o]=a.length===1?a[0]:Y(a)??{allOf:a}}for(let o of i.required??[])e.add(o)}let r={type:"object",properties:n};if(e.size&&(r.required=[...e]),t.every(i=>i.additionalProperties===!1))r.additionalProperties=!1;else{let i=[];for(let o of t){let a=Ee(o);a&&!i.some(d=>ze(d,a))&&i.push(a)}i.length===1?r.additionalProperties=i[0]:i.length>1&&(r.additionalProperties={allOf:i})}return r}function tn(t){let n=t.allOf;if(!Array.isArray(n)||n.length<2)return;for(let i of je)if(i in t)return;let e=n.filter(i=>Array.isArray(i.oneOf)||Array.isArray(i.anyOf)),r;if(!e.length)r=Y(n);else{let i=e[0],o=Array.isArray(i.oneOf)?"oneOf":"anyOf";if(Object.keys(i).length!==1)return;let a=n.filter(s=>s!==i),d=i[o].map(s=>Y([...a,s]));if(d.some(s=>!s))return;r={[o]:d}}r&&(delete t.allOf,Object.assign(t,r))}function He(t){let n=t;for(let k of["anyOf","oneOf"]){let A=n[k];if(!Array.isArray(A))continue;let m=A.map(He);m.some((l,w)=>l!==A[w])&&(n={...n,[k]:m})}let e=[n.type].flat(),r=!e.includes("string")&&e.some(k=>k==="number"||k==="integer"),i=n.enum??(n.const!==void 0?[n.const]:void 0);if(!r&&!i?.some(k=>typeof k=="number"))return n;let{minimum:o,maximum:a,exclusiveMinimum:d,exclusiveMaximum:s,multipleOf:g,format:f,id:b,...h}=n;return h.enum?h.enum=h.enum.map(k=>typeof k=="number"?String(k):k):typeof h.const=="number"&&(h.const=String(h.const)),r&&(h.type="string",i||(h.pattern=e.includes("number")?"^-?\\d+(?:\\.\\d+)?$":"^-?\\d+$")),h}var W=class{constructor(n,e){this.override=n;this.refs=e}done=new Map;path=[];cyclic=new Map;write(n,e=!1){let r=this.refs.get(n);if(r!==void 0&&!e)return{$ref:r};if(this.path.includes(n))return this.cyclic.has(n)||this.cyclic.set(n,""),{};let i=this.done.get(n);if(i)return i;this.path.push(n);try{let o=this.written(n);return this.done.set(n,o),o}finally{this.path.pop()}}written(n){let e={},r,i=n._zod.toJSONSchema?.();i?Object.assign(e,i):r=this.process(n,e);let o=ce.get(n);if(o)for(let d of Object.keys(o))e[d]=o[d];R(n)&&(delete e.examples,delete e.default),"_prefault"in e&&(e.default??=e._prefault,delete e._prefault);let a=e;if(r){let d=this.write(r);a={...e};for(let s of Object.keys(d))s in e||(a[s]=d[s])}return this.override({zodSchema:n,jsonSchema:a}),Ie(a),n._zod.def.type==="intersection"&&tn(a),a}process(n,e){let r=n._zod.def;switch(r.type){case"string":{e.type="string";let{minimum:i,maximum:o,format:a,patterns:d,contentEncoding:s,laxFormat:g}=z(n);if(typeof i=="number"&&(e.minLength=i),typeof o=="number"&&(e.maxLength=o),a&&(e.format=Qe[a]??a,(e.format===""||a==="time"||g)&&delete e.format),s&&(e.contentEncoding=s),d&&d.size>0){let f=[...d];f.length===1?e.pattern=f[0].source:e.allOf=f.map(b=>({pattern:b.source}))}return}case"number":{let{minimum:i,maximum:o,multipleOf:a,exclusiveMinimum:d,exclusiveMaximum:s,isInt:g}=z(n);if(e.type=g?"integer":"number",typeof d=="number"&&d>=(i??Number.NEGATIVE_INFINITY)?e.exclusiveMinimum=d:typeof i=="number"&&(e.minimum=i),typeof s=="number"&&s<=(o??Number.POSITIVE_INFINITY)?e.exclusiveMaximum=s:typeof o=="number"&&(e.maximum=o),a){let[f,...b]=new Set(a.filter(h=>Number.isFinite(h)&&h!==0).map(Math.abs));f!==void 0&&(e.multipleOf=f),b.length&&(e.allOf=[...e.allOf??[],...b.map(h=>({multipleOf:h}))])}return}case"boolean":case"success":e.type="boolean";return;case"null":e.type="null";return;case"never":e.not={};return;case"enum":{let i=nn(r.entries);i.length===0?e.not={}:(i.every(o=>typeof o=="number")&&(e.type="number"),i.every(o=>typeof o=="string")&&(e.type="string"),e.enum=i);return}case"literal":{let i=r.values.filter(o=>o!==void 0).map(o=>typeof o=="bigint"?Number(o):o);if(r.values.length===0)e.not={};else if(i.length===1)e.type=i[0]===null?"null":typeof i[0],e.const=i[0];else if(i.length>1){for(let o of["number","string","boolean"])i.every(a=>typeof a===o)&&(e.type=o);i.every(o=>o===null)&&(e.type="null"),e.enum=i}return}case"template_literal":e.type="string",e.pattern=n._zod.pattern.source;return;case"file":{e.type="string",e.format="binary",e.contentEncoding="binary";let{minimum:i,maximum:o,mime:a}=z(n);i!==void 0&&(e.minLength=i),o!==void 0&&(e.maxLength=o),a&&(a.length===0?e.not={}:a.length===1?e.contentMediaType=a[0]:e.anyOf=a.map(d=>({contentMediaType:d})));return}case"array":{let{minimum:i,maximum:o}=z(n);typeof i=="number"&&(e.minItems=i),typeof o=="number"&&(e.maxItems=o),e.type="array",e.items=this.write(r.element);return}case"object":{let i=r.shape;e.type="object";let o={};e.properties=o;for(let d in i)Object.defineProperty(o,d,{value:this.write(i[d]),writable:!0,enumerable:!0,configurable:!0});let a=Object.keys(i).filter(d=>j(i[d])===void 0);a.length>0&&(e.required=a),r.catchall?._zod.def.type==="never"?e.additionalProperties=!1:r.catchall&&(e.additionalProperties=this.write(r.catchall));return}case"union":e[r.inclusive===!1?"oneOf":"anyOf"]=r.options.map(i=>this.write(i));return;case"intersection":{let i=d=>"allOf"in d&&Object.keys(d).length===1,o=this.write(r.left),a=this.write(r.right);e.allOf=[...i(o)?o.allOf:[o],...i(a)?a.allOf:[a]];return}case"tuple":{let i=r.items;e.type="array",e.prefixItems=i.map(s=>this.write(s)),r.rest?e.items=this.write(r.rest):e.items=!1;let o=i.length;for(;o>0&&j(i[o-1])!==void 0;)o-=1;o>0&&(e.minItems=o),r.rest||(e.maxItems=i.length);let{minimum:a,maximum:d}=z(n);typeof a=="number"&&(e.minItems=a),typeof d=="number"&&(e.maxItems=d);return}case"record":{let i=r.keyType;e.type="object";let o=z(i).patterns;if(r.mode==="loose"&&o&&o.size>0){let d=this.write(r.valueType),s={};for(let g of o)s[g.source]=d;e.patternProperties=s}else e.propertyNames=He(this.write(i)),e.additionalProperties=this.write(r.valueType);let a=i._zod.values;if(a&&!r.partial&&j(r.valueType)===void 0){let d=[...a].filter(s=>typeof s=="string"||typeof s=="number");d.length>0&&(e.required=d.map(String))}return}case"nullable":e.anyOf=[this.write(r.innerType),{type:"null"}];return;case"default":case"prefault":{let i=r.defaultValue,o,a=!1,d=JSON.stringify(i,(s,g)=>typeof g=="bigint"?(a=!0,null):g);return!a&&d!==void 0&&(o=JSON.parse(d)),a||(e[r.type==="default"?"default":"_prefault"]=o),r.innerType}case"catch":{try{e.default=r.catchValue(void 0)}catch{}return r.innerType}case"readonly":return e.readOnly=!0,r.innerType;case"pipe":return r.in._zod.traits.has("$ZodTransform")?r.out:r.in;case"lazy":return n._zod.innerType;case"optional":case"nonoptional":case"promise":return r.innerType;default:return}}};function Le(t,n=()=>{}){let e=t,r=new W(n,new Map),i=r.write(e,!0);if(r.cyclic.size>0){let o=new Map,a=0,d=[];for(let g of r.cyclic.keys())if(g===e)o.set(g,"#");else{let f=`__schema${a++}`;o.set(g,`#/$defs/${f}`),d.push([g,f])}r=new W(n,o),i=r.write(e,!0);let s={};for(let[g,f]of d)s[f]=r.write(g,!0);d.length>0&&(i={...i,$defs:s})}return JSON.parse(JSON.stringify({$schema:"https://json-schema.org/draft/2020-12/schema",...i}))}function Fe(t){return Le(t,an)}var rn={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string"},on={phone:"A phone number as it is written, like +1 555 123 4567 or 020 7946 0958 ext. 12.",place:"An address or a place's name, as a person would search a map for it.",duration:"A length of time in whole minutes: 90 is 1 h 30 min."};function an(t){ue(t.zodSchema)&&(t.jsonSchema["x-graview-app-link"]=!0);let n=pe(t.zodSchema);if(n&&(t.jsonSchema.type==="string"||t.jsonSchema.type==="array")){t.jsonSchema["x-graview-linked"]={address:n.address,kinds:[...n.kinds],cardinality:n.cardinality};let s=n.kinds.join(" or "),g=`${n.cardinality==="many"?"Records":"A record"}: a ${s} in the app ${n.address}, as "${n.kinds[0]}:<id>" \u2014 an id found there with find_linked. Linking never changes that app.`,f=t.jsonSchema.description;typeof f=="string"&&f.includes(g)||(t.jsonSchema.description=`${typeof f=="string"&&f?`${f.replace(/\.?$/,".")} `:""}${g}`)}if(ye(t.zodSchema)&&(t.jsonSchema["x-graview-repeat"]=!0,!t.jsonSchema.type&&!t.jsonSchema.anyOf&&!t.jsonSchema.oneOf&&Object.assign(t.jsonSchema,sn())),ge(t.zodSchema)){t.jsonSchema.contentMediaType="text/markdown";let s=t.jsonSchema.description;typeof s=="string"&&s.endsWith("Written in Markdown.")||(t.jsonSchema.description=`${typeof s=="string"&&s?`${s.replace(/\.?$/,".")} `:""}Written in Markdown.`)}let e=Ae(t.zodSchema);if(e){let s=t.jsonSchema;s["x-graview-type"]=e,e==="duration"&&(s["x-graview-unit"]="minutes"),s.description??=on[e]}let r=ve(t.zodSchema,!1);if(r){let s=Re(r);t.jsonSchema["x-graview-format"]=s.format??"unit",s.currency&&(t.jsonSchema["x-graview-currency"]=s.currency),s.unit&&s.format!=="money"&&(t.jsonSchema["x-graview-unit"]=s.unit);let g=t.jsonSchema.description;t.jsonSchema.description=typeof g=="string"&&g.length>0?`${g} ${G(s)}`:G(s)}let i=t.zodSchema._zod?.def;if(!i||i.type!=="string"||typeof i.format!="string"||i.format==="regex")return;let o=t.jsonSchema,a=(i.checks??[]).map(s=>s._zod?.def).filter(s=>s?.format==="regex"&&s.pattern instanceof RegExp).map(s=>s.pattern.source);delete o.pattern;let d=o.allOf;Array.isArray(d)&&d.every(s=>typeof s=="object"&&s!==null&&Object.keys(s).length===1&&"pattern"in s)&&delete o.allOf,o.format=rn[i.format]??i.format,a.length===1?o.pattern=a[0]:a.length>1&&(o.allOf=a.map(s=>({pattern:s})))}function X(t){let n=q(t.input),e=Fe(t.input),r=e.properties??{};if(ke(t)){let i=t.creates.join(" | ");r.id={type:"string",minLength:1,description:`Optional: the id for the ${i} this makes. Refused if the graph already has it; left out, one is minted from the label.`},e.properties=r}Se(t)&&(e.additionalProperties=!1);for(let i of n){let o=r[i.name];if(!o)continue;let a=i.kinds.includes("*")?"any node kind":i.kinds.join(" | ");o.description=[o.description,`Id of a node (${a}).`].filter(Boolean).join(" ")}return{name:t.name,...t.title===void 0?{}:{title:t.title},description:t.description??t.title??t.name,inputSchema:e,nodeRefs:n}}function sn(){let t={type:"string",pattern:"^\\d{4}-\\d{2}-\\d{2}$"},n=(e,r)=>({type:"integer",minimum:e,maximum:r});return{type:"object",description:'How the date beside it repeats; the date is the first occurrence. "on" is weekdays for "week", days of the month (-1 the last) for "month".',properties:{every:{type:"string",enum:[...he]},interval:n(1,99),on:{type:"array",minItems:1,maxItems:31,items:{anyOf:[{type:"string",enum:[...me]},n(-1,31)]}},until:t,count:n(1,1e3),except:{type:"array",maxItems:500,items:t},continues:{type:"string",maxLength:200}},required:["every"],additionalProperties:!1}}function qe(t){let n=new Set;for(let e=t;e;e=e.onBehalfOf)e.id!==void 0&&n.add(`${e.kind}:${e.id}`);return n}function B(t,n){let e=qe(n),r=f=>{if(f.kind==="rule")return!1;let b=qe(f);if(b.size===0)return!1;for(let h of b)if(e.has(h))return!1;return!0},i,o=()=>{if(i)return i;i=new Map;for(let f of t.log.live()){if(f.undoes!==void 0)continue;let b=r(f.author)?f.author:void 0;for(let h of f.primitives){h.op==="remove-node"&&i.delete(h.node.id);let k=h.op==="add-node"?h.node.id:h.op==="patch-node"?h.id:void 0;if(k===void 0)continue;let A=h.op==="add-node"?Object.keys(h.node):Object.keys(h.after),m=i.get(k);(h.op==="add-node"||!m)&&i.set(k,m=new Map);for(let l of A)l==="id"||l==="kind"||(b?m.set(l,b):m.delete(l))}}return i},a=t.schema,d=new Map,s=(f,b)=>{let h=`${f}\0${b}`,k=d.get(h);if(k===void 0){let A=a.tryDefinition(f)?.fields?.shape;k=A!==void 0&&b in A&&Te(A[b]).type==="text",d.set(h,k)}return k},g=f=>t.graph.getNode(f)?.kind;return{prose:s,say:f=>F(f,{graph:t.graph,schema:a}),fieldBy(f,b){let h=g(f);if(!(h===void 0||!s(h,b)))return o().get(f)?.get(b)},recordBy(f){let b=g(f),h=o().get(f);if(b===void 0||!h)return;let k;for(let[A,m]of h)s(b,A)&&(k=m);return k}}}var Q=(t,n,e)=>({untrusted:!0,authoredBy:e.say(n),text:t}),dn="the host's ranker";function We(t,n){return{...t,hits:t.hits.map(e=>{if(e.about!=="node")return e;e.why.by==="meaning"&&e.why.matched!==void 0&&(e={...e,why:{...e.why,matched:{untrusted:!0,authoredBy:dn,text:e.why.matched}}});let r=n.recordBy(e.id);if(!r)return e;let i=n.prose(e.kind,e.why.field)?n.fieldBy(e.id,e.why.field):r;return{...e,label:Q(e.label,r,n),...e.apart!==void 0?{apart:Q(e.apart,r,n)}:{},why:i?{...e.why,fragment:Q(e.why.fragment,i,n)}:e.why}})}}var ee=(t,n,e)=>({title:t,readOnlyHint:n,destructiveHint:!1,idempotentHint:e,openWorldHint:!1}),cn={name:"subscribe",title:"Notify me when something happens",description:`Subscribe the person you act for to be told when something happens in this app \u2014 their host delivers it (an email, a push). on is one of: "act" (an act runs; give act, its declared name, and/or record), "created" (a record of kind is added), "changed" (a record of kind, or the one record, changes), "reaches" (a record of kind, or the one record, comes to satisfy condition, an expression in the app's rule language such as done == true or amount > 100). They are told only of changes someone else made, unless alsoMine is true, and only of records they may see. Returns the subscription and its sentence. Changes nothing in the app.`,inputSchema:{type:"object",properties:{on:{type:"string",enum:["act","created","changed","reaches"],description:"What to be told of."},act:{type:"string",description:"An act's declared name, for on: act."},kind:{type:"string",description:"A kind, for created, changed and reaches."},record:{type:"string",description:"One record, by id or name: for act, changed and reaches."},condition:{type:"string",description:"For reaches: what the record should come to satisfy, in the rule language (done == true)."},alsoMine:{type:"boolean",description:"Also when the person themselves made the change; false when unsaid."}},required:["on"],additionalProperties:!1},mutating:!1,annotations:ee("Notify me when something happens",!1,!1)},ln={name:"unsubscribe",title:"Stop notifying me",description:"Take away one of the person's subscriptions, by the id list_subscriptions or subscribe answered. Changes nothing in the app.",inputSchema:{type:"object",properties:{id:{type:"string",description:"The subscription's id."}},required:["id"],additionalProperties:!1},mutating:!1,annotations:ee("Stop notifying me",!1,!0)},un={name:"list_subscriptions",title:"What I am notified of",description:`List what the person you act for is told of in this app: each subscription's id and its sentence ("When someone else adds a task").`,inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:ee("What I am notified of",!0,!0)},ne=[cn,ln,un];var L=t=>{let n;return()=>n??=t().catch(e=>{throw n=void 0,e})},fn=L(()=>(__graviewPreload(import.meta.url,["./chunk.FILCNVGH.js","./chunk.B2IRADR2.js","./chunk.KJNUZYXS.js","./chunk.4BBJ62ZO.js","./chunk.UCZR33MK.js","./chunk.CC47O2DW.js","./chunk.2IX3CZNP.js","./chunk.6DHHUBSC.js","./chunk.H5CZZZLX.js","./chunk.Z7JRBKA7.js","./chunk.5ZMENPY4.js","./chunk.AJZBJBMO.js"]),import("./chunk.BCHHBGM6.js"))),pn=()=>(__graviewPreload(import.meta.url,["./chunk.B7TB6YRZ.js","./chunk.CC47O2DW.js","./chunk.2IX3CZNP.js","./chunk.6DHHUBSC.js","./chunk.5ZMENPY4.js","./chunk.AJZBJBMO.js"]),import("./chunk.HA3PPIEQ.js")).catch(()=>{}),mn=async()=>{(await pn())?.judgeWithLines()},H=L(()=>(__graviewPreload(import.meta.url,["./chunk.WVUJXDXZ.js","./chunk.KJNUZYXS.js","./chunk.4BBJ62ZO.js","./chunk.UCZR33MK.js","./chunk.CC47O2DW.js","./chunk.2IX3CZNP.js","./chunk.6DHHUBSC.js","./chunk.Z7JRBKA7.js","./chunk.5ZMENPY4.js","./chunk.AJZBJBMO.js"]),import("./chunk.JBTU2PJ4.js"))),hn=L(()=>(__graviewPreload(import.meta.url,["./chunk.YXGI7H4Y.js","./chunk.G4JJXA63.js","./chunk.ITEF3U2E.js","./chunk.B2IRADR2.js","./chunk.IAZRY42B.js","./chunk.FMN5XDLE.js","./chunk.Q5WEOX3Q.js","./chunk.WQPNGBR7.js","./chunk.DYNBWIPF.js","./chunk.B7TB6YRZ.js","./chunk.WVUJXDXZ.js","./chunk.KJNUZYXS.js","./chunk.4BBJ62ZO.js","./chunk.UCZR33MK.js","./chunk.CC47O2DW.js","./chunk.2IX3CZNP.js","./chunk.6DHHUBSC.js","./chunk.NSNGPQGT.js","./chunk.H5CZZZLX.js","./chunk.Z7JRBKA7.js","./chunk.5ZMENPY4.js","./chunk.AJZBJBMO.js"]),import("./chunk.QCF6Z2AZ.js"))),yn=L(()=>(__graviewPreload(import.meta.url,["./chunk.FCXBCKED.js","./chunk.FILCNVGH.js","./chunk.B2IRADR2.js","./chunk.J3M2MZHG.js","./chunk.UT6642FC.js","./chunk.KJNUZYXS.js","./chunk.4BBJ62ZO.js","./chunk.UCZR33MK.js","./chunk.CC47O2DW.js","./chunk.2IX3CZNP.js","./chunk.6DHHUBSC.js","./chunk.NSNGPQGT.js","./chunk.H5CZZZLX.js","./chunk.Z7JRBKA7.js","./chunk.5ZMENPY4.js","./chunk.AJZBJBMO.js"]),import("./chunk.BL4S3I2N.js"))),gn=L(()=>(__graviewPreload(import.meta.url,["./chunk.CMN6VVK2.js","./chunk.CC47O2DW.js","./chunk.2IX3CZNP.js","./chunk.6DHHUBSC.js","./chunk.5ZMENPY4.js","./chunk.AJZBJBMO.js"]),import("./chunk.OM5CDW2S.js"))),bn=t=>t.definitions.some(n=>V(n).size>0),Be=t=>({value:U(t),label:t.label,...t.describe?{describe:t.describe}:{},...t.card?{card:t.card}:{},fields:t.fields,...t.app?{app:t.app}:{}});async function wn(t,n,e,r){let i=String(e.relation??""),[o,a]=i.includes(".")?i.split(".",2):[void 0,i],d=t.schema.definitions.flatMap(l=>[...V(l)].map(([w,S])=>({kind:l.kind,name:w,relation:S}))),s=d.filter(l=>l.name===a&&(o===void 0||l.kind===o));if(s.length!==1){let l=d.map(w=>`${w.kind}.${w.name}`).join(", ")||"none";return{ok:!1,error:`${s.length===0?`No relation to another app is called "${i}"`:`"${i}" names a relation of several kinds`}. The relations to other apps are: ${l}.`}}let{kind:g,name:f,relation:b}=s[0];if(!r)return{ok:!1,error:`This seat cannot read ${b.address}: its host reads no other app's records. Nothing was changed.`};let h={kind:n.kind,...n.id===void 0?{}:{id:n.id},...n.roles?{roles:n.roles}:{}},k=typeof e.of=="string"?e.of:void 0;if(k!==void 0){let l=t.graph.getNode(k);if(!l||l.kind!==g)return{ok:!1,error:`No ${g} "${k}".`};let w=fe(l[f],b),S=await Promise.all(w.map(c=>Promise.resolve().then(()=>r.resolve(c,h)).catch(()=>null)));return{ok:!0,data:{relation:`${g}.${f}`,app:b.address,records:S.map((c,u)=>c===null?{value:U(w[u]),missing:!0}:"denied"in c?{denied:!0,said:"linked record (no access)"}:Be(c))},reads:[k]}}let A=typeof e.limit=="number"&&e.limit>0?Math.min(e.limit,20):20,m=await Promise.resolve().then(()=>r.find({address:b.address,kinds:b.kinds,query:String(e.query??""),limit:A},h)).catch(()=>[]);return Array.isArray(m)?{ok:!0,data:{relation:`${g}.${f}`,app:b.address,records:m.map(Be),link:`edit-${g} with ${f} set to a record's value`}}:{ok:!0,data:{relation:`${g}.${f}`,app:b.address,denied:!0,said:"linked record (no access)"}}}var _=t=>({title:t,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}),Ce={description:'Which records: false (the default) the live ones, true only the archived ones, "all" both. An archived record is set aside, not gone: unarchive-<kind> brings it back.',anyOf:[{type:"boolean"},{type:"string",enum:["all"]}]},te={type:"number",description:"Where the page starts; 0 when unsaid."},oe=[{name:"search_graph",title:"Find by name",description:"Find things by name: records whose name or readable fields carry the words, and the kinds, places and rules the words name \u2014 each with why it matched. Reach for this before get_graph when you know what something is called. Words match the start of words, case and accents aside; key:value tokens narrow as a list's filter does (done:false, is:any for past records, kind:<kind>). Pass subject (a node id) to get the acts you may run on it as hits too. When few records match exactly, records with a near word follow \u2014 a typo, another form of the word, a meaning \u2014 each with near: true and why.matched, the record's own word that answered.",inputSchema:{type:"object",properties:{query:{type:"string",description:"Words, with optional key:value conditions."},limit:{type:"number",description:"Most hits to return; at most 20."},subject:{type:"string",description:"A node id whose acts to include."},archived:Ce},required:["query"],additionalProperties:!1},mutating:!1,annotations:_("Find by name")},{name:"get_graph",title:"Read the graph",description:"Read the graph, 25 nodes a page: their fields, the edges out of them, and how many more. Start here when you need the shape of the domain rather than one thing in it.",inputSchema:{type:"object",properties:{offset:te,archived:Ce},additionalProperties:!1},mutating:!1,annotations:_("Read the graph")},{name:"get_node",title:"Read one node",description:"Read one node: its fields, its links (id, kind and label, 20 each way a page), the violations that implicate it, and its computed values: read-only fields worked out from what you can see, which no act sets. Use this to check a thing before you change it.",inputSchema:{type:"object",properties:{id:{type:"string",description:"A node's id, or its name."},offset:te},required:["id"],additionalProperties:!1},mutating:!1,annotations:_("Read one node")},{name:"get_violations",title:"List the problems",description:"List the invariant violations the graph currently has, 20 a page, with the repairs that would resolve each one. Read this before proposing work: a rule that is already broken is more urgent than anything you could add.",inputSchema:{type:"object",properties:{offset:te,context:{type:"object",description:"Evaluation context, e.g. { weekStart }."}},additionalProperties:!1},mutating:!1,annotations:_("List the problems")},{name:"get_affordances",title:"Ask what can be done",description:"Ask what can legally be done with a selection, ranked. Prefer these over composing a mutation by hand: they are derived from the schema, the invariants and the shape of the graph, so they cannot name an action that does not exist.",inputSchema:{type:"object",properties:{selection:{type:"array",items:{type:"string"},description:"Node ids."},context:{type:"object"}},required:["selection"],additionalProperties:!1},mutating:!1,annotations:_("Ask what can be done")},{name:"describe_place",title:"Say what a place shows",description:`Say what one place of the app shows you, as a person in your seat would see it: its headings, its figures as drawn, its lists with each record's title and what its card or row says, the headings a list is grouped under, what an empty list says, and any block that could not be worked out. Pass a place's slug ("home", a lens's address like "the-offers", a kind's like "offers") or a record's id, and width 390 for a phone. Use it after a change to check what somebody now sees, instead of guessing.`,inputSchema:{type:"object",properties:{place:{type:"string",description:`"home", a place's slug, or a record's id.`},width:{type:"number",description:"The screen's width in CSS pixels; 390 is a phone, 1440 when unsaid."}},required:["place"],additionalProperties:!1},mutating:!1,annotations:_("Say what a place shows")},{name:"preview_mutation",title:"Try an act without applying it",description:"Try a mutation without applying it: get back the diff it would produce and any invariant it would break. Do this when you are unsure, rather than applying and undoing.",inputSchema:{type:"object",properties:{mutation:{type:"string"},args:{type:"object"}},required:["mutation","args"],additionalProperties:!1},mutating:!1,annotations:_("Try an act without applying it")},{name:"undo_batch",title:"Undo a batch",description:"Undo one batch of operations. Fails, naming the blocking operation, when a later operation read what it wrote.",inputSchema:{type:"object",properties:{batch:{type:"string"},include:{type:"array",items:{type:"string"}}},required:["batch"],additionalProperties:!1},mutating:!0,annotations:{title:"Undo a batch",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1}},{name:"list_suggestions",title:"List what is suggested",description:"List the suggestions waiting for a person: changes the app's own actor proposed and did not make, each with its id, what it would do, who suggested it, what it was based on and how sure (0 to 1). Nothing changes until one is accepted (accept_suggestion) or declined (decline_suggestion); a declined one is never suggested again.",inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:_("List what is suggested")},{name:"accept_suggestion",title:"Accept a suggestion",description:"Make a waiting suggestion's change, as this seat, carrying what it was based on. Returns the batch (undo_batch takes it back).",inputSchema:{type:"object",properties:{suggestion:{type:"string",description:"The suggestion's id, from list_suggestions."}},required:["suggestion"],additionalProperties:!1},mutating:!0,annotations:{title:"Accept a suggestion",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1}},{name:"decline_suggestion",title:"Decline a suggestion",description:"Decline a waiting suggestion: nothing changes, the decline is kept in the log, and the same change is never suggested or made by the app's own actor again.",inputSchema:{type:"object",properties:{suggestion:{type:"string",description:"The suggestion's id, from list_suggestions."}},required:["suggestion"],additionalProperties:!1},mutating:!0,annotations:{title:"Decline a suggestion",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}}],Ve={name:"act_on_several",title:"Do one act to several records",description:`Run one act on several records at once, as one change with one undo. act is the act (its tool name or its declared name), records the records it runs on (ids or names; each goes in the act's subject), args what every call shares ("Set stage to Declined" is args { stage: "declined" }). Each record is judged on its own: one this seat may not change is named with why, and the rest still apply. Returns the batch (undo_batch takes it all back), the records changed, those already so, and those refused.`,inputSchema:{type:"object",properties:{act:{type:"string",description:"The act to run on each record."},records:{type:"array",items:{type:"string"},minItems:1,maxItems:200,description:"Ids or names of the records."},args:{type:"object",description:"Arguments every call shares, besides the record."}},required:["act","records"],additionalProperties:!1},mutating:!0,annotations:{title:"Do one act to several records",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1}},ae={type:"object",description:"A lens, as draft_view returns one.",properties:{title:{type:"string"},lens:{type:"string"},on:{type:"string"},bindings:{type:"object"},options:{type:"object"}},required:["title","lens","on"]},se={name:"draft_view",title:"Draw a view",description:'Draw a view of the data from words ("a board of tasks by status", "who covers what") as a lens the app could keep; or check a lens you wrote (lens); or change the one on screen (current, with ask: "only this month"). Returns the lens and its add-lens edit, or one sentence saying why not. Writes nothing.',inputSchema:{type:"object",properties:{ask:{type:"string",description:"What to see, in words."},lens:ae,current:ae},additionalProperties:!1},mutating:!1,annotations:_("Draw a view")},Ge={name:"keep_lens",title:"Keep a view as a lens",description:"Keep a lens draft_view drew as one of the app's places: checked again, then written as the add-lens edit. Returns the remove-lens edit that takes it back.",inputSchema:{...ae,additionalProperties:!1},mutating:!0,annotations:{title:"Keep a view as a lens",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},Ke={name:"find_linked",title:"Find a record in another app",description:`A relation may go to a kind in another app (describe_app lists them under "Linked from other apps"). With relation and words, list the records there this seat may link \u2014 each with the value to link it by ("house:h1"), its name and its describe line. With of (a record id here), read the records that record links, as this seat may see them there. Linking one is the record's edit (edit-<kind>) with the relation set to the value. Another app this seat may not open answers denied, and nothing of it. Writes nothing; never changes the other app.`,inputSchema:{type:"object",properties:{relation:{type:"string",description:"The relation, by name (forHouse) or as <kind>.<relation> (scenario.forHouse)."},query:{type:"string",description:"Words to find by, in the other app's names; empty for the first few."},of:{type:"string",description:"A record here whose linked records to read, instead of finding."},limit:{type:"number",description:"Most records to return; at most 20."}},required:["relation"],additionalProperties:!1},mutating:!1,annotations:_("Find a record in another app")};function kn(t,n){return t===void 0?[]:t==="keep"&&!n?[se,Ge]:[se]}var Sn="An argument that names a record takes its id or its name.",Ze=[...oe.map(t=>t.name),Ve.name,se.name,Ge.name,Ke.name,...ne.map(t=>t.name)],Ye=64;function x(t){let{line:n,...e}=t;return e}function Ue(t){return{...t,...t.introduces?{introduces:t.introduces.map(x)}:{},...t.resolves?{resolves:t.resolves.map(x)}:{},...t.violationsAfter?{violationsAfter:t.violationsAfter.map(x)}:{}}}function vn(t){let n=t.normalize("NFKD").replace(/\p{M}/gu,"").replace(/[^A-Za-z0-9_-]/g,"_");return n.length===0&&(n="act"),/^[A-Za-z_]/.test(n)||(n=`act_${n}`),n.slice(0,Ye)}function An(t){let n=new Set(Ze),e=new Map;for(let r of t){let i=vn(r),o=i;for(let a=2;n.has(o);a+=1)o=`${i.slice(0,Ye-`_${a}`.length)}_${a}`;n.add(o),e.set(r,o)}return e}function On(t,n){if(n.size===0)return t;let e=Object.fromEntries(Object.entries(t.properties??{}).filter(([i])=>!n.has(i))),r=(t.required??[]).filter(i=>!n.has(i));return{...t,properties:e,...t.required?{required:r}:{}}}function Rn(t,n,e){let r=X(t),i=C(t),o=r.nodeRefs.length>0?`${r.description}${/[.!?]$/.test(r.description)?"":"."} ${Sn}`:r.description;return{name:n,title:i,description:o,inputSchema:On(r.inputSchema,e),mutating:!0,annotations:{title:i,readOnlyHint:!1,destructiveHint:t.destructive===!0||(t.severs?.length??0)>0,idempotentHint:t.idempotent===!0,openWorldHint:!1},act:t.name}}function de(t){if(t===null||typeof t!="object")return JSON.stringify(t)??"null";if(Array.isArray(t))return`[${t.map(de).join(",")}]`;let n=t;return`{${Object.keys(n).filter(e=>n[e]!==void 0).sort().map(e=>`${JSON.stringify(e)}:${de(n[e])}`).join(",")}}`}function Tn(t){return`sha256:${Oe(de(t))}`}function _n(t,n,e,r,i,o=!1,a=!1){let d=An(t.map(f=>f.name)),s=[...kn(r,e),...o?[Ke]:[],...a?ne:[]];return{definitions:e?[...oe.filter(f=>!f.mutating),...s]:[...oe,Ve,...s,...t.filter(f=>n.has(f.name)).map(f=>Rn(f,d.get(f.name),i(f)))],names:d}}function lt(t,n={}){let e=n.author??{kind:"agent"},r=t.allMutations(),i=new Set(t.permittedMutations(e).map(m=>m.name)),{definitions:o,names:a}=_n(r,i,n.readOnly===!0,n.drafts?n.drafts.keep?"keep":"draw":void 0,m=>K(t.schema,t.policy,e,m),bn(t.schema),n.subscriptions!==void 0),d=Tn(o),s={app:n.app?.brand?.locale,appTimeZone:n.app?.brand?.timeZone},g=m=>le(s,m),f=m=>{if(!Ze.includes(m)){for(let[l,w]of a)if(w===m)return l;return a.has(m)?m:void 0}},b=(m,l)=>{let w=r.find(u=>u.name===m);if(!w)return{args:l,resolved:[]};let S={...l},c=[];for(let u of q(w.input)){let p=S[u.name];if(typeof p!="string"||p.trim()==="")continue;let y=t.resolveRef(u,p,e);if(!y.ok){let v=y.reason==="none"?` Nothing was changed. Use search_graph to look it up, then pass its id as ${u.name}.`:" Nothing was changed.";return{ok:!1,error:`${y.message}${v}`,argument:u.name,candidates:y.candidates}}y.by!=="id"&&(S[u.name]=y.id,c.push({argument:u.name,given:p,id:y.id,label:y.label}))}return{args:S,resolved:c}},h=async(m,l)=>{try{await mn();let w=o.find(c=>c.name===m)??o.find(c=>c.act===m);if(!w){let c=f(m);if(c){let u=t.permits({name:c,args:l},e);if(!u.ok)return{ok:!1,error:u.refusal.message,reason:"forbidden"}}return{ok:!1,error:`Unknown tool "${m}". Available: ${o.map(u=>u.name).join(", ")}`}}if(w.mutating&&n.readOnly)return{ok:!1,error:`"${m}" changes the graph, and this seat is read-only.`,reason:"forbidden"};if(w.act!==void 0){let c=b(w.act,l);if("ok"in c)return c;let u=w.act,p=g(()=>E(t,e,t.apply({name:u,args:c.args},{...n.author?{author:n.author}:{},...ie(n.via)})));return{ok:!0,data:{batch:p.batch,intent:p.intent,introduces:p.introduces.map(x),resolves:p.resolves.map(x),...c.resolved.length>0?{resolved:c.resolved}:{}},diff:p.diff}}let S=t.seenBy(e);switch(w.name){case"search_graph":{let c=typeof n.places=="function"?n.places():n.places,u=typeof l.subject=="string"?l.subject:void 0,p=$e(S,String(l.query??""),{principal:e,rank:n.near,archived:be(l.archived),limit:typeof l.limit=="number"&&l.limit>0?Math.min(l.limit,20):20,...c?{places:c}:{},...u?{subject:u,from:[u]}:{}}),y=p.later?await p.later:p;return{ok:!0,data:(await H()).searchRead(y,We(y,B(S,e))),reads:y.hits.flatMap(v=>v.about==="node"?[v.id]:[])}}case"get_graph":return{ok:!0,...(await H()).graphRead(S,B(S,e),l)};case"get_node":{let c=String(l.id??""),u=c,p;if(!S.graph.getNode(c)){let v=c.trim()===""?void 0:t.resolveRef({name:"id",kinds:["*"]},c,e);if(v?.ok)u=v.id,p={argument:"id",given:c,id:u,label:v.label};else return v?.reason==="ambiguous"?{ok:!1,error:v.message,argument:"id",candidates:v.candidates}:{ok:!1,error:`No node "${c}".`}}let y=(await H()).nodeRead(S,B(S,e),u,l);return{ok:!0,data:p?{...y.data,resolved:[p]}:y.data,reads:y.reads}}case"describe_place":{let c=n.app??{name:"",schema:t.schema},u=typeof l.width=="number"&&Number.isFinite(l.width)&&l.width>0?l.width:1440,{describePlace:p}=await fn(),y=p(t,e,String(l.place??""),{app:c,width:u});if(!y.ok)return{ok:!1,error:`${y.error} The places are: ${y.places.join(", ")}.`};let v=new Set,M=I=>{for(let $ of I)for(let T of $.groups??[])for(let N of T.items)v.add(N.id),M(N.parts)};return M(y.description.parts),{ok:!0,data:y.description,reads:[...v]}}case"find_linked":return wn(S,e,l,n.linked);case"draft_view":case"keep_lens":{let c=n.app??{name:"",schema:t.schema};return(await hn()).runDraftTool(w.name,l,{app:c,principal:e,...n.drafts?{drafts:n.drafts}:{}})}case"get_violations":{let c=S.violations(l.context);return{ok:!0,...(await H()).violationsRead(c,l)}}case"get_affordances":{let c=l.selection??[];return{ok:!0,data:Ne(S,c,{...typeof n.derive=="function"?n.derive():n.derive,...n.author?{principal:n.author}:{},...l.context?{context:l.context}:{}}),reads:c.filter(p=>S.graph.has(p))}}case"preview_mutation":{let c=String(l.mutation),u=f(c)??c,p=b(u,l.args??{});if("ok"in p)return p;let y=t.missingFor({name:u,args:p.args},e);if(y)return{ok:!1,error:y.message,reason:"missing"};let v=E(t,e,t.preview({name:u,args:p.args},void 0,{author:e})),M=Ue(v);return{ok:!0,data:p.resolved.length>0?{...M,resolved:p.resolved}:M}}case"act_on_several":{let c=String(l.act??""),u=f(c)??c,p=r.find(O=>O.name===u);if(!p||!i.has(u)){let O=p?t.permits({name:u,args:{}},e):void 0;return O&&!O.ok?{ok:!1,error:O.refusal.message,reason:"forbidden"}:{ok:!1,error:`There is no act "${c}" this seat may run. Nothing was changed.`,reason:"invalid"}}let y=p.subject;if(!y)return{ok:!1,error:`"${C(p)}" does not act on a record, so it cannot be run on several. Nothing was changed.`,reason:"invalid"};let v=Array.isArray(l.records)?l.records.filter(O=>typeof O=="string"&&O.trim()!==""):[];if(v.length===0)return{ok:!1,error:"Name at least one record. Nothing was changed.",reason:"invalid"};let M=[],I=[];for(let O of v.slice(0,200)){let P=t.resolveRef({name:y.arg,kinds:y.kinds},O,e);if(!P.ok)return{ok:!1,error:`${P.message} Nothing was changed.`,argument:"records",candidates:P.candidates};M.push(P.id),P.by!=="id"&&I.push({argument:"records",given:O,id:P.id,label:P.label})}let $=b(u,{...l.args??{}});if("ok"in $)return $;let T=(await yn()).actOnSeveral(t,{mutation:u,subject:y.arg,args:$.args},M,{author:e,...ie(n.via)}),N=T.result?E(t,e,T.result):void 0;return{ok:!0,data:{...T.batch?{batch:T.batch,intent:T.intent}:{},applied:T.applied,unchanged:T.unchanged,refused:T.refused.map(O=>({record:O.id,label:O.label,error:O.message,reason:O.reason})),...T.allOrNothing?{keptNone:!0}:{},...N?{introduces:N.introduces.map(x),resolves:N.resolves.map(x)}:{},...I.length>0||$.resolved.length>0?{resolved:[...I,...$.resolved]}:{}},...N?{diff:N.diff}:{}}}case"subscribe":case"unsubscribe":case"list_subscriptions":{let c=await(await gn()).runSubscriptionTool(w.name,l,{store:t,principal:n.subscriber??e,app:n.app?.name??"app",subscriptions:n.subscriptions});return c.ok?{ok:!0,data:c.data}:{ok:!1,error:c.error}}case"list_suggestions":{let c=_e(t,e).map(u=>{let p=F(u.author,{graph:S.graph,schema:t.schema});return{id:u.id,intent:u.intent,by:p,at:u.at,about:u.about,...u.lineage?{basis:{untrusted:!0,authoredBy:p,text:u.lineage.basis},...u.lineage.confidence!==void 0?{confidence:u.lineage.confidence}:{}}:{}}});return{ok:!0,data:{suggestions:c},reads:[...new Set(c.flatMap(u=>u.about))]}}case"accept_suggestion":case"decline_suggestion":{let c=String(l.suggestion??""),u={author:e,...ie(n.via)},p=w.name==="accept_suggestion"?xe(t,c,u):Me(t,c,u),y=E(t,e,p);return{ok:!0,data:{batch:y.batch,intent:y.intent,introduces:y.introduces.map(x),resolves:y.resolves.map(x)},diff:y.diff}}case"undo_batch":{let c=String(l.batch),u=l.include??[],p=S.canUndo([c,...u]);if(!p.ok)return{ok:!1,error:p.message};let y=E(t,e,t.undo([c,...u],{...n.author?{author:n.author}:{}}));return{ok:!0,data:Ue(y),diff:y.diff}}default:return{ok:!1,error:`Unknown tool "${m}".`}}}catch(w){let{reason:S,wouldNeed:c}=we(w);return{ok:!1,error:w instanceof Error?w.message:String(w),reason:S,...c?{wouldNeed:c}:{}}}},k=new Set,A=m=>{for(let l of k)l(m)};return{definitions:o,hash:d,...n.author?{author:n.author}:{},onDiff(m){return t.subscribe(m)},onCall(m){return k.add(m),()=>k.delete(m)},async call(m,l){let w=(o.find(p=>p.name===m)??o.find(p=>p.act===m))?.mutating??!1,S={name:m,args:l,mutating:w,at:new Date().toISOString()};A({...S,phase:"running"});let c=p=>(A(p.ok?{...S,phase:"ok",...!w&&p.reads?{reads:p.reads}:{}}:{...S,phase:"failed",error:p.error}),p),u=await h(m,l);return c(u.ok&&!w?{...u,data:(await H()).withinReadChars(m,u.data)}:u)}}}function ie(t){let n=typeof t=="function"?t():t;return n?{via:n}:{}}export{de as a,lt as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk.WVUJXDXZ.js";import{b as C}from"./chunk.KJNUZYXS.js";import"./chunk.4BBJ62ZO.js";import"./chunk.UCZR33MK.js";import"./chunk.CC47O2DW.js";import"./chunk.2IX3CZNP.js";import"./chunk.6DHHUBSC.js";import"./chunk.Z7JRBKA7.js";import{na as $,oa as E,pa as b,qa as k}from"./chunk.5ZMENPY4.js";import"./chunk.AJZBJBMO.js";function M(r,l,t){let p=r.getAttribute("data-record")??"",g=r.getAttribute("data-field")??"",e=Number(r.getAttribute("data-index")??"0"),c=[...l?.node?[l.node]:[],...l?.nodes??[]].find(a=>a.id===p);if(!p||!c)return{why:p?`names a record it was not shown ("${p.slice(0,80)}")`:"names no record (data-record)"};let s=g&&Object.hasOwn(c,g)?c[g]:void 0,o=(Array.isArray(s)?s:[s]).filter($),u=Number.isInteger(e)&&e>=0?o[e]:void 0,n=c.label?`"${c.label}"`:"a record";return g?u?(t==="video"?!b(u):!b(u)&&!E(u))?{why:`names "${u.name}" on ${n}, which is not ${t==="video"?"a video":"a picture or a video"}`}:{file:u,on:c}:{why:o.length===0?`names "${g}" on ${n}, which holds no file it was shown`:`names file ${r.getAttribute("data-index")} of "${g}" on ${n}, which holds ${o.length}`}:{why:`names no field of ${n} (data-field)`}}var A=r=>`${r.caption?.trim()||r.name}, ${k(r)}`;function T(r,l,t,p,g){let e=r.createElement("video");e.setAttribute("data-graview-video",""),e.setAttribute("controls",""),e.setAttribute("preload","metadata"),e.setAttribute("playsinline",""),e.setAttribute("aria-label",A(t));let c=t.poster?p(t.poster):void 0;c&&e.setAttribute("poster",c),t.width&&t.height?(e.setAttribute("width",String(t.width)),e.setAttribute("height",String(t.height)),e.style.aspectRatio=`${t.width} / ${t.height}`):e.style.aspectRatio="16 / 9",e.style.cssText+=";display:block;width:100%;height:auto;max-height:80vh;background:#000;border-radius:var(--graview-radius, 8px)";let s=t.captions?p(t.captions):void 0;if(s){let o=r.createElement("track");o.setAttribute("kind","captions"),o.setAttribute("src",s),o.setAttribute("srclang","en"),o.setAttribute("label","Captions"),o.setAttribute("default",""),e.appendChild(o)}return t.duration===void 0&&e.addEventListener("loadedmetadata",()=>Number.isFinite(e.duration)&&e.duration>0&&e.setAttribute("aria-label",A({...t,duration:e.duration}))),e.setAttribute("src",g),l.appendChild(e),e}function N(r,l){let t=r.document,p=new Set,g=n=>{p.has(n)||(p.add(n),l.onProblem?.(n))},e=n=>{let a=l.file?l.file(n):n;if(a!==void 0)try{let h=new r.URL(a,t.baseURI);return h.origin===r.location.origin&&/^https?:$/.test(h.protocol)?a:void 0}catch{return}},c=new WeakMap,s,o=n=>{if(typeof n.close=="function")return n.close();n.removeAttribute("open"),n.dispatchEvent(new r.Event("close"))},u=(n,a)=>g(`The ${n} in the view ${l.view} was not drawn: it ${a}.`);return{refresh(n){let a=l.shown();for(let h of Array.from(n.querySelectorAll("graview-video"))){let d=h.shadowRoot??h.attachShadow({mode:"open"});if(!l.pictures){c.delete(h),d.replaceChildren(),u("video",`asks for no pictures: a view places a record's video where its manifest says "pictures": true`);continue}let f=M(h,a,"video"),i="file"in f?JSON.stringify(f.file):"";if(c.get(h)===i&&d.childNodes.length>0)continue;if(c.set(h,i),d.replaceChildren(),"why"in f){u("video",f.why);continue}let m=e(f.file.href);if(!m){u("video",`names "${f.file.name}", which this host does not say it serves on this page`);continue}let w=t.createElement("style");w.textContent=":host { display: block; min-width: 0; }",d.appendChild(w),T(t,d,f.file,e,m)}},open(n){if(!l.pictures)return u("full-screen viewer",`asks for no pictures: a view opens a record's picture or video full screen where its manifest says "pictures": true`),!1;let a=M(n,l.shown(),"any");if("why"in a)return u("full-screen viewer",a.why),!1;let h=e(a.file.href);if(!h)return u("full-screen viewer",`names "${a.file.name}", which this host does not say it serves on this page`),!1;s&&o(s);let d=a.file,f=d.caption?.trim()||d.name,i=t.createElement("dialog");i.setAttribute("data-graview-lightbox",""),i.setAttribute("aria-label",b(d)?A(d):f),i.style.cssText="padding:0;border:0;border-radius:var(--graview-radius, 8px);max-width:min(96vw, 1600px);max-height:94vh;background:var(--graview-panel, Canvas);color:var(--graview-ink, CanvasText)";let m=t.createElement("figure");if(m.style.cssText="margin:0;display:grid;gap:8px;padding:10px",b(d))T(t,m,d,e,h);else{let v=t.createElement("img");v.setAttribute("src",h),v.setAttribute("alt",f),v.style.cssText="max-width:100%;max-height:80vh;object-fit:contain;display:block;margin:0 auto",m.appendChild(v)}let w=t.createElement("figcaption");w.style.cssText="display:flex;gap:12px;align-items:center;justify-content:space-between";let x=t.createElement("span");x.textContent=b(d)&&d.duration!==void 0?`${f} \xB7 ${C(d.duration)}`:f;let y=t.createElement("button");return y.type="button",y.textContent="Close",y.addEventListener("click",()=>o(i)),w.append(x,y),m.appendChild(w),i.appendChild(m),i.addEventListener("click",v=>v.target===i&&o(i)),i.addEventListener("close",()=>{i.remove(),s===i&&(s=void 0),n.focus?.()}),t.body.appendChild(i),s=i,typeof i.showModal=="function"?i.showModal():i.setAttribute("open",""),y.focus(),!0},dispose(){s&&o(s),s?.remove(),s=void 0}}}export{N as createGuestMedia,M as namedFile};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Se,b as Pe,c as Ge,d as ge,e as F,f as Ce,h as Ne}from"./chunk.6UCRL4OF.js";import{h as Ie,i as qe,j as Ve}from"./chunk.6XJP7F3I.js";import{a as se,b as re,c as Z,d as _e,e as Y,g as ne,h as Be}from"./chunk.OE4QOBJF.js";import{c as Me,h as g,i as Te,j as me}from"./chunk.74RMHUCX.js";import{Ea as De,Fa as ee,Ga as fe,Ib as ue,Jb as Ke,b as L,c as q,e as xe,f as Ee,g as C,h as j,k as T,l as X,m as G,n as Ae,o as V,p as K,r as k,s as Q,t as E,u as R,v as I,w as P,x as n,xa as Fe,y as U,z as Re}from"./chunk.WLPTY4BF.js";var ln=e=>Object.entries(e).map(([o,s])=>[o,Object.keys(ee(s?.edges))]),ze=(e,o)=>Ke(e,ln(o));var ye="graview-document",be=1,ke=256*1024,he=64*1024,$e=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,we=/^[a-z][A-Za-z0-9]*$/,pn=new Set(["id","kind"]),fn=e=>e in Object.prototype,Ze=U(e=>!fn(e),"every object already has this name \u2014 choose another"),Ye=(e,o)=>[...e===void 0?[]:[Ee(e)],...o===void 0?[]:[xe(o)]],h=(e,o)=>j().check(...Ye(e,o)),v=(e,o,s)=>K(e).check(...Ye(o,s)),D=e=>j().check(C($e,`${e} names are kebab-case, lower-case words joined by hyphens like "tool-note" (field and relation names are camelCase, like "supersededBy")`)),un=/^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|[a-z][A-Za-z0-9]*)$/,W=j().check(C(un,'relation names are one camelCase word, like "supersededBy" (kind names are kebab-case, like "tool-note")'),Ze),N=j().check(C(we,'field names are one word or camelCase, like "dueDate", so rules say them bare (kind names are kebab-case, like "tool-note")'),U(e=>!pn.has(e),'a field cannot be called "id" or "kind" \u2014 the framework keeps those; try "type" or "category"'),Ze),B=h(1,500),H=h(1,2e3),ae=h(1,300),mn=["string","text","number","integer","boolean","date","datetime","enum","list","url","email","image","video","file","app-link","phone","place","duration"],Je=k({type:I(mn),required:n(G()),description:n(B),label:n(h(1,60)),options:n(v(h(1,80),1,100)),of:n(I(["string","number","date","image","video","file"])),default:n(V()),unit:n(h(void 0,12)),format:n(I(["money","percent","duration","markdown"])),min:n(T()),max:n(T()),step:n(T()),renamedFrom:n(j().check(C(we))),repeats:n(G())}).check(Re((e,o)=>{e.type==="enum"&&!e.options&&o.addIssue({code:"custom",message:'an enum field lists its "options"',path:["options"]}),e.type!=="enum"&&e.options&&o.addIssue({code:"custom",message:'"options" belongs only on an enum field',path:["options"]}),e.type!=="list"&&e.of&&o.addIssue({code:"custom",message:'"of" belongs only on a list field',path:["of"]}),e.repeats&&e.type!=="date"&&e.type!=="datetime"&&o.addIssue({code:"custom",message:'"repeats" belongs only on a date or datetime field',path:["repeats"]})})),gn=j().check(C(new RegExp(`${$e.source}|${Fe.source}`),'a relation goes to a kind of this document, like "house", or of another app, like "@nick/house/house"')),zn=k({to:E([v(gn,1),P("*")]),cardinality:n(I(["one","many"])),description:n(B),inverse:n(h(1,80)),appendOnly:n(G()),renamedFrom:n(j()),tidying:n(P("never"))}),He=E([H,k({expr:H,label:n(h(1,60)),description:n(B)})]),hn=k({noun:n(h(1,40)),plural:n(h(1,40)),description:n(B),fields:R(N,Je).check(U(e=>Object.keys(e).length>0,"a kind has at least one field")),label:n(ae),describe:n(ae),lifecycle:n(k({field:N,retired:v(E([j(),T(),G()]),1)})),figure:n(h(void 0,2e4)),glance:n(v(N,1,20)),page:n(k({fields:n(v(N,1,40)),groups:n(v(k({title:h(1,60),fields:v(N,1,40)}),1,12))})),edges:n(R(W,zn)),computed:n(R(j(),He).check(U(e=>Object.keys(e).length<=20,"a kind works out at most 20 computed fields"))),fieldRoles:n(R(j(),j())),renamedFrom:n(j().check(C($e))),people:n(G()),archives:n(P(!1)),tidying:n(I(["never","no-links"]))}),te=E([j(),T(),G(),Ae(),K(V()),k({expr:H})]),J=j().check(C(/^\$[A-Za-z][A-Za-z0-9]*$/,'a reference is "$" and a name, like "$subject" or "$new"')),yn=E([k({create:D("kind"),as:n(j().check(C(we))),set:n(R(N,te))}),k({set:R(N,te),target:n(J)}),k({connect:W,from:J,to:J}),k({sever:W,from:J,to:J}),k({remove:J})]),bn=k({title:n(h(1,80)),description:n(B),fromTheOtherEnd:n(h(1,80)),on:n(E([D("kind"),v(D("kind"),1)])),creates:n(D("kind")),sets:n(R(N,te)),writes:n(v(N,1)),connects:n(W),severs:n(W),setsOther:n(R(N,te)),replaces:n(E([P(!0),v(W,1,10)])),removes:n(P(!0)),args:n(R(N,Je)),effects:n(v(yn,1,20)),allowedWhen:n(H),refusal:n(ae),destructive:n(G())}),kn=k({act:D("act"),label:n(h(1,80)),args:n(R(j(),te))}),$n=k({title:n(h(1,120)),description:n(B),over:E([P("graph"),D("kind")]),when:n(H),require:H,says:n(ae),repairs:n(v(kn,void 0,10))}),wn=k({roles:E([v(D("role"),1),P("*")]),mutations:E([v(D("act"),1),P("*")]),kinds:n(E([K(D("kind")),P("*")])),describe:n(B),self:n(G()),ownEnd:n(G())}),Le=n(v(D("field"),1)),jn=k({roles:E([v(D("role"),1),P("*")]),kinds:v(D("kind"),1),own:n(G()),via:n(W),fields:Le,hide:Le}),On=k({grants:K(wn),sees:n(K(jn))}),vn=k({accent:n(j().check(C(/^#[0-9a-fA-F]{6}$/,'an accent is a color like "#c2577a"'))),name:n(h(1,60)),currency:n(j().check(C(/^[A-Z]{3}$/,'a currency is its three-letter code, like "USD" or "EUR"'))),locale:n(h(2,35)),timeZone:n(h(1,64)),logo:n(E([h(1,he),k({src:h(1,he),alt:n(h(1,120))})])),favicon:n(E([h(1,he),k({emoji:j()})])),typography:n(k({display:n(h(1,200)),body:n(h(1,200)),mono:n(h(1,200))})),shape:n(k({radius:n(T().check(q(0),L(32))),density:n(T().check(q(.75),L(1.5)))})),accents:n(R(j(),T().check(q(0),L(360)))),scheme:n(I(["light","dark","auto"]))}),ie=R(j(),V()),Ue=E([h(1,120),k({by:h(1,120),direction:n(I(["asc","desc"]))})]),We=T().check(X(),q(1),L(9999)),Sn=Q({create:n(G()),options:n(Q({sort:n(Ue),columnSort:n(Ue),search:n(v(h(1,120),void 0,40)),filters:n(v(h(1,120),void 0,40)),horizon:n(E([T().check(X(),q(1),L(200)),Q({years:T().check(X(),q(1),L(200)),title:h(1,80),from:n(We),to:n(We)})]))}))}),xn=k({card:n(K(V())),row:n(K(V())),page:n(K(V()))}),En=()=>{let e=n(I(["asc","desc"]));return E([h(1,120),k({by:h(1,120),direction:e,then:n(E([h(1,120),k({by:h(1,120),direction:e})]))})])},An=()=>E([h(1,120),k({by:h(1,120),order:n(v(h(1,80),void 0,40)),closed:n(v(h(1,80),void 0,40))})]),Rn=Q({order:n(K(j())),hide:n(K(j())),first:n(j()),primary:n(v(h(1,80),void 0,40)),scene:n(h(1,40)),pages:n(h(1,40)),lists:n(R(j(),k({filters:n(v(h(1,120),void 0,40)),sort:n(En()),group:n(An())})))}),Xe=k({$schema:n(j()),format:P(ye),formatVersion:P(be),name:h(1,80),description:n(B),version:n(T().check(X(),q(1))),kinds:R(D("kind"),hn).check(U(e=>Object.keys(e).length>0,"a document declares at least one kind"),U(e=>Object.keys(e).length<=40,"a document declares at most 40 kinds")),computed:n(R(j(),He)),acts:n(R(D("act"),bn)),rules:n(R(D("rule"),$n)),roles:n(K(D("role"))),policy:n(On),modules:n(ie),lenses:n(K(Sn)),pages:n(Rn),views:n(R(j(),E([xn,K(V())]))),brand:n(vn),settings:n(K(ie)),migrations:n(K(ie)),connections:n(R(D("connection"),ie))});var Fn={};function Qe(e,o=Fn,s=be){let{document:a,respelled:l}=Se(e),p=l.length>0?{respelled:l}:{};if(!a||typeof a!="object"||Array.isArray(a))return{document:a};let u=a;if(u.format!==ye||typeof u.formatVersion!="number"||u.formatVersion>=s)return{document:a,...p};let z=u.formatVersion,$=structuredClone(u);for(let r=z;r<s;r++){let t=o[r];if(!t)throw new Error(`there is no upgrade from format ${r} to ${r+1}`);$={...t($),formatVersion:r+1}}return{document:$,from:z,...p}}function en(e,o,s){let a=Object.keys(e).filter(z=>e[z].edges?.[o]!==void 0);if(a.length===0)return;let l=a.map(z=>e[z].edges[o].to),p=l.some(z=>z==="*")?"*":[...new Set(l.flatMap(z=>z))];if(s.length===0||s.some(z=>a.includes(z)))return{reversed:!1,kinds:p};let u=a.filter(z=>{let $=e[z].edges[o].to;return $==="*"||s.every(r=>$.includes(r))});return u.length>0?{reversed:!0,kinds:u}:{reversed:!1,kinds:p}}var on=(e,o)=>{let s=e?.fields[o];return s!==void 0&&(s.type==="duration"||(s.type==="number"||s.type==="integer")&&s.format==="duration")};function nn(e,o,s,a){if(a==="out"){let l=e[o]?.edges?.[s]?.to;return l===void 0?[]:l==="*"?Object.keys(e):l}return Object.entries(e).filter(([,l])=>{let p=l.edges?.[s]?.to;return p!==void 0&&(p==="*"||p.includes(o))}).map(([l])=>l)}function je(e,o,s){if(s.t==="ident")return e[o]?.edges?.[s.name]?nn(e,o,s.name,"out"):void 0;if(s.t==="where")return je(e,o,s.set);if(s.t==="call"&&(s.fn==="out"||s.fn==="in")&&s.args[0]?.t==="lit"&&typeof s.args[0].value=="string")return nn(e,o,s.args[0].value,s.fn)}var tn=(e,o,s)=>{let a=o.filter(l=>e[l]?.fields[s]!==void 0);return a.length>0&&a.every(l=>on(e[l],s))};function sn(e,o,s){let a=e.kinds,l=a[o],p=new Map(s),u=new Map,z=(r,t)=>{if(t>8)return!1;switch(r.t){case"ident":return on(l,r.name)||$(r.name,t+1);case"member":{let d=je(a,o,r.object);return d!==void 0&&tn(a,d,r.name)}case"call":{if(r.fn!=="sum"&&r.fn!=="min"&&r.fn!=="max")return!1;let[d,w]=r.args,f=d&&je(a,o,d);return f!==void 0&&w?.t==="ident"&&tn(a,f,w.name)}case"binary":return(r.op==="+"||r.op==="-")&&z(r.left,t)&&z(r.right,t);case"unary":return r.op==="-"&&z(r.operand,t);default:return!1}},$=(r,t)=>{if(l?.computed?.[r]===void 0)return!1;if(u.has(r))return u.get(r);u.set(r,!1);let d=p.get(r),w=d!==void 0&&z(d,t);return u.set(r,w),w};return s.map(([r])=>r).filter(r=>$(r,0))}function rn(e,o,s=`kinds.${e}.page`){let a=o.page;if(!a)return[];let l=[],p=[...Object.keys(o.fields),...Object.keys(o.computed??{})],u=new Set,z=(r,t)=>{p.includes(r)?u.has(r)&&l.push(g("page-field-twice",t,`"${r}" is on ${e}'s page twice; name each field once`)):l.push(g("page-field",t,`${e}'s page is to show "${r}", and ${e} has no field or computed field called that`,`use one of: ${p.join(", ")}`)),u.add(r)};(a.fields??[]).forEach((r,t)=>z(r,`${s}.fields.${t}`));let $=new Set;return(a.groups??[]).forEach((r,t)=>{let d=r.title.trim().toLowerCase();$.has(d)&&l.push(g("page-group-twice",`${s}.groups.${t}.title`,`${e}'s page has two groups called "${r.title}"; give each its own title`)),$.add(d),r.fields.forEach((w,f)=>z(w,`${s}.groups.${t}.fields.${f}`))}),l}var Dn=new Set(["subject","now","today","me"]);function Kn(e){if((typeof e=="string"?e:JSON.stringify(e??null)).length>ke)return{findings:[g("too-large","",`a document may be at most ${ke/1024} KB`)]};if(typeof e=="string")try{e=JSON.parse(e)}catch(a){return{findings:[g("not-json","",`this is not JSON: ${a.message}`)]}}try{e=Qe(e).document}catch(a){return{findings:[g("format","formatVersion",a.message)]}}let o=Xe.safeParse(e);if(!o.success)return{findings:o.error.issues.map(a=>{let l=a.path.map(String).join(".");if(a.code==="unrecognized_keys")return g("unknown-key",l,`${a.keys.map(p=>`"${p}"`).join(", ")} ${a.keys.length===1?"is":"are"} not part of a Graview document here`,"check the spelling against docs/declaration-document.md");if(a.code==="invalid_union"&&/\.effects\.\d+$/.test(l))return g("effect-shape",l,"this effect is not one Graview knows",'an effect is one of {"create": kind, "as"?: name, "set"?: {field: value}}, {"set": {field: value, \u2026}, "target"?: "$ref"}, {"connect"|"sever": relation, "from": "$ref", "to": "$ref"}, {"remove": "$ref"}');if(a.code==="invalid_key"){let p=a.issues?.[0]?.message;return g("shape",l,`the name "${String(a.path.at(-1))}" is not allowed here${p?`: ${p}`:""}`)}return g("shape",l,a.message)})};let s=o.data;return{document:s,findings:Mn(s)}}var de=e=>[e??[]].flat();function an(e){let o=new Map;for(let[s,a]of Object.entries(e.kinds))for(let[l,p]of Object.entries(ee(a.edges))){let u=o.get(l);o.set(l,{name:l,from:[...u?.from??[],s],to:p.to==="*"||u?.to==="*"?"*":[...new Set([...u?.to??[],...p.to])],cardinality:p.cardinality??"many"})}return o}function ht(e){let o=new Map;for(let[a,l]of Object.entries(e.kinds)){let p=ne(l),u=fe(l.edges);o.set(a,{fields:new Set([...Object.keys(l.fields),...u.keys()]),edges:new Map(Object.entries(ee(l.edges)).map(([z,$])=>[z,$.cardinality??"many"])),...p?{computed:p}:{},...u.size>0?{linked:u}:{}})}let s=ne(e);return s&&o.set(Me,{computed:s}),o}function cn(e,o){let s=[],a=de(e.on),l=(p,u)=>{let z=en(o.kinds,p,a)?.reversed===!0,[$,r]=z?["$to","$subject"]:["$subject","$to"];return u==="connect"?{connect:p,from:$,to:r}:{sever:p,from:$,to:r}};if(e.creates){let p=o.kinds[e.creates],u={};for(let z of Object.keys(p?.fields??{}))u[z]=`$${z}`;for(let z of e.effects??[])"set"in z&&!("create"in z)&&F(z.target)==="new"&&Object.assign(u,z.set);s.push({create:e.creates,as:"new",set:u})}return e.sets&&s.push({set:e.sets}),e.writes&&!(e.creates&&e.on===void 0)&&s.push({set:Object.fromEntries(e.writes.map(p=>[p,`$${p}`]))}),e.connects&&(e.replaces&&s.push({replace:e.replaces===!0?[e.connects]:[...e.replaces],keep:e.connects}),s.push(l(e.connects,"connect"))),e.severs&&s.push(l(e.severs,"sever")),e.setsOther&&(e.connects||e.severs)&&s.push({set:e.setsOther,target:"$to"}),e.removes&&s.push({remove:"$subject"}),e.effects&&s.push(...e.effects.filter(p=>!(e.creates&&"set"in p&&!("create"in p)&&F(p.target)==="new"))),s}function Oe(e,o,s){try{let a=Z(e),l=se(a);for(let p of l.unknownFunctions)s.push(g("unknown-function",o,`"${p}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));return a}catch(a){if(a instanceof re){s.push(g("expression",o,a.sentence+` (at character ${a.at+1})`));return}throw a}}function ve(e,o,s){try{return Y(e)}catch(a){if(a instanceof _e||a instanceof re){s.push(g("template",o,(a instanceof re,a.sentence)));return}throw a}}function Mn(e){let o=[],s=new Set(Object.keys(e.kinds)),a=an(e),l=e.acts??{},p=new Set(e.roles??[]),u=(r,t)=>fe(e.kinds[r]?.edges).has(t),z=r=>Object.keys(e.kinds).some(t=>u(t,r));for(let[r,t]of Object.entries(e.kinds)){let d=`kinds.${r}`;for(let[f,c]of Object.entries(t.edges??{})){if(!De(c)&&c.to!=="*")for(let i of c.to)s.has(i)||o.push(g("edge-target",`${d}.edges.${f}.to`,`"${i}" is not a kind this document declares`));t.fields[f]&&o.push(g("edge-field-clash",`${d}.edges.${f}`,`"${f}" is both a field and a relation of ${r}`,"rename one of them"))}t.lifecycle&&!t.fields[t.lifecycle.field]&&o.push(g("lifecycle-field",`${d}.lifecycle.field`,`${r} has no field "${t.lifecycle.field}"`));let w=f=>t.computed!==void 0&&Object.hasOwn(t.computed,f);for(let f of t.glance??[])!t.fields[f]&&!w(f)&&o.push(g("glance-field",`${d}.glance`,`a glance at ${r} is to say "${f}", and ${r} has no field or computed field called that`,`use one of: ${[...Object.keys(t.fields),...Object.keys(t.computed??{})].join(", ")}`));o.push(...rn(r,t));for(let f of["label","describe"]){let c=t[f];if(!c)continue;let i=ve(c,`${d}.${f}`,o);for(let A of i??[])if(A.expr){for(let y of se(A.expr).names)if(!t.fields[y]){if(w(y)){Be(t,y)||o.push(g("template-field",`${d}.${f}`,`${r}'s ${y} is worked out from beyond the record, and a ${f} is said with no graph to read`,`show it in a view instead, or name a computed field worked out from ${r}'s own fields`));continue}o.push(g("template-field",`${d}.${f}`,`${r} has no field "${y}" for its ${f} to show`,f==="label"?"a label can only show the record's own fields and what they work out":void 0))}}}for(let[f,c]of Object.entries(t.fields)){c.default!==void 0&&c.type==="enum"&&!c.options?.includes(String(c.default))&&o.push(g("default-option",`${d}.fields.${f}.default`,`"${String(c.default)}" is not one of ${f}'s options`));let i=`${f}Repeat`;c.repeats&&(t.fields[i]||t.edges?.[i]||t.computed?.[i])&&o.push(g("repeat-clash",`${d}.fields.${f}.repeats`,`${r} already has "${i}", where how ${f} repeats is kept`))}}for(let[r,t]of Object.entries(l)){let d=`acts.${r}`;for(let i of de(t.on))s.has(i)||o.push(g("act-kind",`${d}.on`,`"${i}" is not a kind this document declares`));let w=de(t.on),f=cn(t,e);if(t.creates&&t.on===void 0&&t.writes&&s.has(t.creates)){for(let i of t.writes)if(!e.kinds[t.creates].fields[i])if(e.kinds[t.creates].computed?.[i]!==void 0)o.push(g("computed-written",`${d}.writes`,`${t.creates}'s ${i} is worked out, not written: no act can set it`,"write the stored fields it is worked out from"));else{if(u(t.creates,i))continue;o.push(g("act-field",`${d}.writes`,`${t.creates} has no field "${i}"`))}}f.length===0&&o.push(g("act-empty",d,`"${r}" does nothing`,"give it effects or a shorthand such as sets or creates"));let c=new Map;f.forEach((i,A)=>{let y=f.length-(t.effects?.length??0),O=t.effects&&A>=y?`${d}.effects.${A-y}`:d;if("create"in i){if(!s.has(i.create))o.push(g("act-kind",`${O}.create`,`"${i.create}" is not a kind this document declares`));else for(let b of Object.keys(i.set??{}))e.kinds[i.create].fields[b]||(e.kinds[i.create].computed?.[b]!==void 0?o.push(g("computed-written",`${O}.set.${b}`,`${i.create}'s ${b} is worked out, not written: no act can set it`,"set the stored fields it is worked out from")):o.push(g("act-field",`${O}.set.${b}`,`${i.create} has no field "${b}"`)));i.as&&c.set(i.as,i.create)}else if("connect"in i||"sever"in i){let b="connect"in i?i.connect:i.sever;!a.has(b)&&!z(b)&&o.push(g("act-edge",`${O}.${"connect"in i?"connect":"sever"}`,`"${b}" is not a relation any kind declares`)),F(i.from)==="subject"&&w.length===0&&o.push(g("act-subject",`${d}.on`,`"${r}" acts on "$subject" but does not say which kinds it is "on"`))}else if("set"in i){let b=F(i.target??"$subject"),le=b==="subject"?w:c.has(b??"")?[c.get(b)]:[];b==="subject"&&w.length===0&&o.push(g("act-subject",`${d}.on`,`"${r}" changes "$subject" but does not say which kinds it is "on"`));for(let _ of Object.keys(i.set))for(let m of le)if(!(!s.has(m)||e.kinds[m].fields[_]))if(e.kinds[m].computed?.[_]!==void 0)o.push(g("computed-written",`${O}.set.${_}`,`${m}'s ${_} is worked out, not written: no act can set it`,"set the stored fields it is worked out from"));else{if(u(m,_))continue;o.push(g("act-field",`${O}.set.${_}`,`${m} has no field "${_}"`))}}else"remove"in i&&F(i.remove)==="subject"&&w.length===0&&o.push(g("act-subject",`${d}.on`,`"${r}" removes "$subject" but does not say which kinds it is "on"`));("set"in i&&i.set?Object.values(i.set):[]).forEach(b=>{b&&typeof b=="object"&&!Array.isArray(b)&&"expr"in b&&Oe(b.expr,`${O}.set`,o)})}),t.allowedWhen&&Oe(t.allowedWhen,`${d}.allowedWhen`,o),t.refusal&&ve(t.refusal,`${d}.refusal`,o)}for(let[r,t]of Object.entries(e.rules??{})){let d=`rules.${r}`;t.over!=="graph"&&!s.has(t.over)&&o.push(g("rule-kind",`${d}.over`,`"${t.over}" is not a kind this document declares`));let w=t.over==="graph"?void 0:e.kinds[t.over];for(let f of["when","require"]){let c=t[f];if(!c)continue;let i=Oe(c,`${d}.${f}`,o);if(!i)continue;let A=se(i);for(let y of A.names)if(t.over==="graph")o.push(g("rule-name",`${d}.${f}`,`"${y}" means nothing in a rule over the whole graph`,`name a kind in "over", or use all('kind')`));else if(w&&!w.fields[y]&&!w.edges?.[y]&&w.computed?.[y]===void 0){let O=Object.keys(w.edges??{}).find(S=>S.includes("-")&&S.split("-").includes(y));o.push(g("rule-name",`${d}.${f}`,`${t.over} has no field or relation called "${y}"`,O?`"${O}" reads as a subtraction in a rule; rename the relation to one camelCase word, like "${O.replace(/-([a-z0-9])/g,(S,b)=>b.toUpperCase())}"`:void 0))}for(let y of A.edges)!a.has(y)&&!z(y)&&o.push(g("rule-edge",`${d}.${f}`,`"${y}" is not a relation any kind declares`));for(let y of A.sweeps)s.has(y)?t.over!=="graph"&&o.push(Te("rule-cost",`${d}.${f}`,`this rule looks at every ${y} for every ${t.over}, which grows slowly as the app grows`,"walk a relation with out()/in() instead of all() where you can")):o.push(g("rule-kind",`${d}.${f}`,`"${y}" is not a kind this document declares`))}t.says&&ve(t.says,`${d}.says`,o),(t.repairs??[]).forEach((f,c)=>{!l[f.act]&&!ue(f.act)&&!ze(f.act,e.kinds)&&o.push(g("repair-act",`${d}.repairs.${c}.act`,`"${f.act}" is not an act this document declares`))})}let $=e.policy;return $&&($.grants.forEach((r,t)=>{if(r.roles!=="*"&&p.size>0)for(let d of r.roles)p.has(d)||o.push(g("grant-role",`policy.grants.${t}.roles`,`"${d}" is not one of the document's roles`));if(r.mutations!=="*")for(let d of r.mutations)!l[d]&&!ue(d)&&!ze(d,e.kinds)&&o.push(g("grant-act",`policy.grants.${t}.mutations`,`"${d}" is not an act this document declares`))}),($.sees??[]).forEach((r,t)=>{for(let d of r.kinds)s.has(d)||o.push(g("sight-kind",`policy.sees.${t}.kinds`,`"${d}" is not a kind this document declares`));if(r.roles!=="*"&&p.size>0)for(let d of r.roles)p.has(d)||o.push(g("sight-role",`policy.sees.${t}.roles`,`"${d}" is not one of the document's roles`))})),o.push(...Ve(e)),o}function Tn(e,o,s,a){let l=new Map,p=de(e.on),u=new Map,z=new Map;(p.length>0||o.some(c=>"remove"in c&&F(c.remove)==="subject"||"from"in c&&(F(c.from)==="subject"||F(c.to)==="subject")||"set"in c&&!("create"in c)&&F(c.target??"$subject")==="subject"))&&l.set(ge,{ref:p.length>0?p:"*",required:!0});let r=e.args??{},t=e.writes?.length===1,d=(c,i)=>i&&c.type===i.type&&c.min===void 0&&c.max===void 0&&c.step===void 0?{...c,...i.min===void 0?{}:{min:i.min},...i.max===void 0?{}:{max:i.max},...i.step===void 0?{}:{step:i.step}}:c,w=(c,i)=>i&&c.type===i.type&&c.format===void 0&&c.unit===void 0?{...d(c,i),...i.format?{format:i.format}:{},...i.unit?{unit:i.unit}:{}}:d(c,i),f=(c,i,A)=>{if(c===ge||Dn.has(c)||u.has(c)||l.has(c))return;let y=r[c]?w(r[c],A):void 0;l.set(c,y?{field:y,optional:!y.required,required:!!y.required}:i())};for(let c of o)if("create"in c){let i=s.kinds[c.create];for(let[A,y]of Object.entries(c.set??{})){let O=F(y),S=i?.fields[A];if(O&&S){let b=!!S.required&&S.default===void 0;f(O,()=>({field:S,optional:!b,required:b}),S)}}c.as&&u.set(c.as,c.create)}else if("connect"in c||"sever"in c){let i=a.get("connect"in c?c.connect:c.sever);for(let[A,y]of[["from",c.from],["to",c.to]]){let O=F(y);if(!O)continue;let S=A==="to"?i?.to??"*":i?.from??"*";S!=="*"&&!z.has(O)&&z.set(O,S),f(O,()=>({ref:S,required:!0}))}}else if("set"in c){let i=F(c.target??"$subject"),A=i==="subject"?p[0]:u.get(i??"")??z.get(i??"")?.[0];i&&i!=="subject"&&!u.has(i)&&f(i,()=>({ref:"*",required:!0}));for(let[y,O]of Object.entries(c.set)){let S=F(O);if(!S)continue;let b=A?s.kinds[A]?.fields[y]:void 0;f(S,()=>b?{field:b,optional:!t,required:t}:{any:!0,required:!1},b)}}else if("remove"in c){let i=F(c.remove);i&&f(i,()=>({ref:"*",required:!0}))}for(let[c,i]of Object.entries(r))l.has(c)||l.set(c,{field:i,optional:!i.required,required:!!i.required});return l}function yt(e,o={}){let s=Kn(e);if(!s.document||me(s.findings))return{ok:!1,findings:s.findings};let a=s.document,l=[...s.findings];o.previous&&l.push(...Gn(a,o.previous));let p=Pn(a,l);return me(p.findings)?{ok:!1,findings:p.findings}:Ne(p,o)}function ce(e,o){return e.map(s=>{let a=!s.format&&s.expr?.t==="ident"?o?.[s.expr.name]?.format:void 0;return a==="money"||a==="percent"?{...s,format:a}:s})}function Pn(e,o){let s=an(e),a={};for(let[r,t]of Object.entries(e.kinds)){let d=Ce(t),w=t.label??(d?`{${d}}`:void 0),f=ne(t),c=f?sn(e,r,[...f]):[];a[r]={...w?{label:ce(Y(w),t.fields)}:{},...t.describe?{describe:ce(Y(t.describe),t.fields)}:{},...f?{computed:[...f]}:{},...c.length>0?{durations:c}:{}}}let l={};for(let[r,t]of Object.entries(e.acts??{})){let d=cn(t,e),w=Tn(t,d,e,s),f=t.destructive??d.some(m=>"remove"in m||"sever"in m||"replace"in m),c=[...new Set(d.flatMap(m=>"create"in m?[m.create]:[]))],i=[...new Set(d.flatMap(m=>"connect"in m?[m.connect]:[]))],A=[...new Set(d.flatMap(m=>"sever"in m?[m.sever]:"replace"in m?m.replace:[]))],y=[...new Set(d.flatMap(m=>"set"in m&&!("create"in m)&&F(m.target??"$subject")==="subject"?Object.keys(m.set):[]))],O=new Map;for(let m of d){if(!("connect"in m)&&!("sever"in m))continue;let x=s.get("connect"in m?m.connect:m.sever);for(let[M,dn]of[["from",m.from],["to",m.to]]){let oe=F(dn),pe=M==="to"?x?.to:x?.from;oe&&oe!=="subject"&&pe&&pe!=="*"&&O.set(oe,[...new Set([...O.get(oe)??[],...pe])])}}let S={};for(let m of d){if(!("set"in m)||"create"in m)continue;let x=F(m.target??"$subject");for(let M of x&&x!=="subject"&&O.get(x)||[])S[M]=[...new Set([...S[M]??[],...Object.keys(m.set)])]}let b={};for(let m of d)if(!(!("set"in m)||"create"in m||F(m.target??"$subject")!=="subject"))for(let[x,M]of Object.entries(m.set??{}))typeof M=="string"&&F(M)===void 0||typeof M=="number"||typeof M=="boolean"?b[x]=typeof M=="string"&&M.startsWith("$$")?M.slice(1):M:delete b[x];let le=c.length===0&&d.every(m=>!("set"in m)||!m.set||Object.values(m.set).every(x=>!(x&&typeof x=="object"&&!Array.isArray(x)&&"expr"in x))),_=new Map;for(let m of d)if(!(!("set"in m)||!m.set))for(let x of Object.values(m.set))x&&typeof x=="object"&&!Array.isArray(x)&&"expr"in x&&_.set(x.expr,Z(x.expr));l[r]={title:t.title??r.replace(/-/g," "),effects:d,args:[...w],...t.allowedWhen?{guard:Z(t.allowedWhen)}:{},...t.refusal?{refusal:ce(Y(t.refusal),e.kinds[[t.on??[]].flat()[0]??""]?.fields)}:{},exprs:[..._],destructive:f,idempotent:le,creates:c,connects:i,severs:A,writes:y,writesOther:S,sets:b}}let p={};for(let[r,t]of Object.entries(e.rules??{}))p[r]={title:t.title??r.replace(/-/g," "),require:Z(t.require),...t.when?{when:Z(t.when)}:{},...t.says?{says:ce(Y(t.says),e.kinds[t.over]?.fields)}:{}};let u=Pe(e,o),z=Ie(e),$=qe(e);return{format:Ge,document:e,findings:o,kinds:a,...e.computed?{facts:[...ne(e)??[]]}:{},edges:[...s].map(([r,{from:t,to:d,cardinality:w}])=>[r,{from:t,to:d,cardinality:w}]),acts:l,rules:p,brand:u,...Object.keys(z).length>0?{viewSpecs:z}:{},...$?{home:$}:{}}}function bt(e,o,s){let a=/^defineNode\("([^"]+)"\)/.exec(o)?.[1],l=a?s.kinds[a]:void 0;if(!a||!l)return e;let p=Object.keys(l.fields).filter(u=>u!=="label").slice(0,3);return{...e,path:`kinds.${a}.glance`,fix:`Say which: "glance": [${p.map(u=>`"${u}"`).join(", ")}] on kinds.${a} \u2014 the facts a person compares one by, at a glance.`}}function Gn(e,o){let s=[],a=new Set(Object.values(o.kinds).flatMap(l=>Object.keys(l.edges??{})));for(let[l,p]of Object.entries(e.kinds)){let u=p.renamedFrom;u&&!o.kinds[u]&&s.push(g("renamed-from-nothing",`kinds.${l}.renamedFrom`,`${l} says it was ${u}, and the previous version has no kind called ${u}`,"name the kind it was, or drop renamedFrom"));let z=o.kinds[u??l];for(let[$,r]of Object.entries(p.fields)){let t=r.renamedFrom;t&&!z?.fields[t]&&s.push(g("renamed-from-nothing",`kinds.${l}.fields.${$}.renamedFrom`,`${$} says it was ${t}, and the previous ${u??l} has no field called ${t}`,"name the field it was, or drop renamedFrom"))}for(let[$,r]of Object.entries(p.edges??{})){let t=r.renamedFrom;t&&!a.has(t)&&s.push(g("renamed-from-nothing",`kinds.${l}.edges.${$}.renamedFrom`,`${$} says it was ${t}, and the previous version has no relation called ${t}`,"name the relation it was, or drop renamedFrom"))}}return s}export{Kn as a,ht as b,cn as c,yt as d,bt as e};
|
|
1
|
+
import{a as Se,b as Pe,c as Ge,d as ge,e as F,f as Ce,h as Ne}from"./chunk.DYNBWIPF.js";import{h as Ie,i as qe,j as Ve}from"./chunk.UCZR33MK.js";import{a as se,b as re,c as Z,d as _e,e as Y,g as ne,h as Be}from"./chunk.2IX3CZNP.js";import{c as Me,h as g,i as Te,j as me}from"./chunk.6DHHUBSC.js";import{Ea as De,Fa as ee,Ga as fe,Jb as ue,Kb as Ke,b as L,c as q,e as xe,f as Ee,g as C,h as j,k as T,l as X,m as G,n as Ae,o as V,p as K,r as k,s as Q,t as E,u as R,v as I,w as P,x as n,xa as Fe,y as U,z as Re}from"./chunk.5ZMENPY4.js";var ln=e=>Object.entries(e).map(([o,s])=>[o,Object.keys(ee(s?.edges))]),ze=(e,o)=>Ke(e,ln(o));var ye="graview-document",be=1,ke=256*1024,he=64*1024,$e=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,we=/^[a-z][A-Za-z0-9]*$/,pn=new Set(["id","kind"]),fn=e=>e in Object.prototype,Ze=U(e=>!fn(e),"every object already has this name \u2014 choose another"),Ye=(e,o)=>[...e===void 0?[]:[Ee(e)],...o===void 0?[]:[xe(o)]],h=(e,o)=>j().check(...Ye(e,o)),v=(e,o,s)=>K(e).check(...Ye(o,s)),D=e=>j().check(C($e,`${e} names are kebab-case, lower-case words joined by hyphens like "tool-note" (field and relation names are camelCase, like "supersededBy")`)),un=/^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|[a-z][A-Za-z0-9]*)$/,W=j().check(C(un,'relation names are one camelCase word, like "supersededBy" (kind names are kebab-case, like "tool-note")'),Ze),N=j().check(C(we,'field names are one word or camelCase, like "dueDate", so rules say them bare (kind names are kebab-case, like "tool-note")'),U(e=>!pn.has(e),'a field cannot be called "id" or "kind" \u2014 the framework keeps those; try "type" or "category"'),Ze),B=h(1,500),H=h(1,2e3),ae=h(1,300),mn=["string","text","number","integer","boolean","date","datetime","enum","list","url","email","image","video","file","app-link","phone","place","duration"],Je=k({type:I(mn),required:n(G()),description:n(B),label:n(h(1,60)),options:n(v(h(1,80),1,100)),of:n(I(["string","number","date","image","video","file"])),default:n(V()),unit:n(h(void 0,12)),format:n(I(["money","percent","duration","markdown"])),min:n(T()),max:n(T()),step:n(T()),renamedFrom:n(j().check(C(we))),repeats:n(G())}).check(Re((e,o)=>{e.type==="enum"&&!e.options&&o.addIssue({code:"custom",message:'an enum field lists its "options"',path:["options"]}),e.type!=="enum"&&e.options&&o.addIssue({code:"custom",message:'"options" belongs only on an enum field',path:["options"]}),e.type!=="list"&&e.of&&o.addIssue({code:"custom",message:'"of" belongs only on a list field',path:["of"]}),e.repeats&&e.type!=="date"&&e.type!=="datetime"&&o.addIssue({code:"custom",message:'"repeats" belongs only on a date or datetime field',path:["repeats"]})})),gn=j().check(C(new RegExp(`${$e.source}|${Fe.source}`),'a relation goes to a kind of this document, like "house", or of another app, like "@nick/house/house"')),zn=k({to:E([v(gn,1),P("*")]),cardinality:n(I(["one","many"])),description:n(B),inverse:n(h(1,80)),appendOnly:n(G()),renamedFrom:n(j()),tidying:n(P("never"))}),He=E([H,k({expr:H,label:n(h(1,60)),description:n(B)})]),hn=k({noun:n(h(1,40)),plural:n(h(1,40)),description:n(B),fields:R(N,Je).check(U(e=>Object.keys(e).length>0,"a kind has at least one field")),label:n(ae),describe:n(ae),lifecycle:n(k({field:N,retired:v(E([j(),T(),G()]),1)})),figure:n(h(void 0,2e4)),glance:n(v(N,1,20)),page:n(k({fields:n(v(N,1,40)),groups:n(v(k({title:h(1,60),fields:v(N,1,40)}),1,12))})),edges:n(R(W,zn)),computed:n(R(j(),He).check(U(e=>Object.keys(e).length<=20,"a kind works out at most 20 computed fields"))),fieldRoles:n(R(j(),j())),renamedFrom:n(j().check(C($e))),people:n(G()),archives:n(P(!1)),tidying:n(I(["never","no-links"]))}),te=E([j(),T(),G(),Ae(),K(V()),k({expr:H})]),J=j().check(C(/^\$[A-Za-z][A-Za-z0-9]*$/,'a reference is "$" and a name, like "$subject" or "$new"')),yn=E([k({create:D("kind"),as:n(j().check(C(we))),set:n(R(N,te))}),k({set:R(N,te),target:n(J)}),k({connect:W,from:J,to:J}),k({sever:W,from:J,to:J}),k({remove:J})]),bn=k({title:n(h(1,80)),description:n(B),fromTheOtherEnd:n(h(1,80)),on:n(E([D("kind"),v(D("kind"),1)])),creates:n(D("kind")),sets:n(R(N,te)),writes:n(v(N,1)),connects:n(W),severs:n(W),setsOther:n(R(N,te)),replaces:n(E([P(!0),v(W,1,10)])),removes:n(P(!0)),args:n(R(N,Je)),effects:n(v(yn,1,20)),allowedWhen:n(H),refusal:n(ae),destructive:n(G())}),kn=k({act:D("act"),label:n(h(1,80)),args:n(R(j(),te))}),$n=k({title:n(h(1,120)),description:n(B),over:E([P("graph"),D("kind")]),when:n(H),require:H,says:n(ae),repairs:n(v(kn,void 0,10))}),wn=k({roles:E([v(D("role"),1),P("*")]),mutations:E([v(D("act"),1),P("*")]),kinds:n(E([K(D("kind")),P("*")])),describe:n(B),self:n(G()),ownEnd:n(G())}),Le=n(v(D("field"),1)),jn=k({roles:E([v(D("role"),1),P("*")]),kinds:v(D("kind"),1),own:n(G()),via:n(W),fields:Le,hide:Le}),On=k({grants:K(wn),sees:n(K(jn))}),vn=k({accent:n(j().check(C(/^#[0-9a-fA-F]{6}$/,'an accent is a color like "#c2577a"'))),name:n(h(1,60)),currency:n(j().check(C(/^[A-Z]{3}$/,'a currency is its three-letter code, like "USD" or "EUR"'))),locale:n(h(2,35)),timeZone:n(h(1,64)),logo:n(E([h(1,he),k({src:h(1,he),alt:n(h(1,120))})])),favicon:n(E([h(1,he),k({emoji:j()})])),typography:n(k({display:n(h(1,200)),body:n(h(1,200)),mono:n(h(1,200))})),shape:n(k({radius:n(T().check(q(0),L(32))),density:n(T().check(q(.75),L(1.5)))})),accents:n(R(j(),T().check(q(0),L(360)))),scheme:n(I(["light","dark","auto"]))}),ie=R(j(),V()),Ue=E([h(1,120),k({by:h(1,120),direction:n(I(["asc","desc"]))})]),We=T().check(X(),q(1),L(9999)),Sn=Q({create:n(G()),options:n(Q({sort:n(Ue),columnSort:n(Ue),search:n(v(h(1,120),void 0,40)),filters:n(v(h(1,120),void 0,40)),horizon:n(E([T().check(X(),q(1),L(200)),Q({years:T().check(X(),q(1),L(200)),title:h(1,80),from:n(We),to:n(We)})]))}))}),xn=k({card:n(K(V())),row:n(K(V())),page:n(K(V()))}),En=()=>{let e=n(I(["asc","desc"]));return E([h(1,120),k({by:h(1,120),direction:e,then:n(E([h(1,120),k({by:h(1,120),direction:e})]))})])},An=()=>E([h(1,120),k({by:h(1,120),order:n(v(h(1,80),void 0,40)),closed:n(v(h(1,80),void 0,40))})]),Rn=Q({order:n(K(j())),hide:n(K(j())),first:n(j()),primary:n(v(h(1,80),void 0,40)),scene:n(h(1,40)),pages:n(h(1,40)),lists:n(R(j(),k({filters:n(v(h(1,120),void 0,40)),sort:n(En()),group:n(An())})))}),Xe=k({$schema:n(j()),format:P(ye),formatVersion:P(be),name:h(1,80),description:n(B),version:n(T().check(X(),q(1))),kinds:R(D("kind"),hn).check(U(e=>Object.keys(e).length>0,"a document declares at least one kind"),U(e=>Object.keys(e).length<=40,"a document declares at most 40 kinds")),computed:n(R(j(),He)),acts:n(R(D("act"),bn)),rules:n(R(D("rule"),$n)),roles:n(K(D("role"))),policy:n(On),modules:n(ie),lenses:n(K(Sn)),pages:n(Rn),views:n(R(j(),E([xn,K(V())]))),brand:n(vn),settings:n(K(ie)),migrations:n(K(ie)),connections:n(R(D("connection"),ie))});var Fn={};function Qe(e,o=Fn,s=be){let{document:a,respelled:l}=Se(e),p=l.length>0?{respelled:l}:{};if(!a||typeof a!="object"||Array.isArray(a))return{document:a};let u=a;if(u.format!==ye||typeof u.formatVersion!="number"||u.formatVersion>=s)return{document:a,...p};let z=u.formatVersion,$=structuredClone(u);for(let r=z;r<s;r++){let t=o[r];if(!t)throw new Error(`there is no upgrade from format ${r} to ${r+1}`);$={...t($),formatVersion:r+1}}return{document:$,from:z,...p}}function en(e,o,s){let a=Object.keys(e).filter(z=>e[z].edges?.[o]!==void 0);if(a.length===0)return;let l=a.map(z=>e[z].edges[o].to),p=l.some(z=>z==="*")?"*":[...new Set(l.flatMap(z=>z))];if(s.length===0||s.some(z=>a.includes(z)))return{reversed:!1,kinds:p};let u=a.filter(z=>{let $=e[z].edges[o].to;return $==="*"||s.every(r=>$.includes(r))});return u.length>0?{reversed:!0,kinds:u}:{reversed:!1,kinds:p}}var on=(e,o)=>{let s=e?.fields[o];return s!==void 0&&(s.type==="duration"||(s.type==="number"||s.type==="integer")&&s.format==="duration")};function nn(e,o,s,a){if(a==="out"){let l=e[o]?.edges?.[s]?.to;return l===void 0?[]:l==="*"?Object.keys(e):l}return Object.entries(e).filter(([,l])=>{let p=l.edges?.[s]?.to;return p!==void 0&&(p==="*"||p.includes(o))}).map(([l])=>l)}function je(e,o,s){if(s.t==="ident")return e[o]?.edges?.[s.name]?nn(e,o,s.name,"out"):void 0;if(s.t==="where")return je(e,o,s.set);if(s.t==="call"&&(s.fn==="out"||s.fn==="in")&&s.args[0]?.t==="lit"&&typeof s.args[0].value=="string")return nn(e,o,s.args[0].value,s.fn)}var tn=(e,o,s)=>{let a=o.filter(l=>e[l]?.fields[s]!==void 0);return a.length>0&&a.every(l=>on(e[l],s))};function sn(e,o,s){let a=e.kinds,l=a[o],p=new Map(s),u=new Map,z=(r,t)=>{if(t>8)return!1;switch(r.t){case"ident":return on(l,r.name)||$(r.name,t+1);case"member":{let d=je(a,o,r.object);return d!==void 0&&tn(a,d,r.name)}case"call":{if(r.fn!=="sum"&&r.fn!=="min"&&r.fn!=="max")return!1;let[d,w]=r.args,f=d&&je(a,o,d);return f!==void 0&&w?.t==="ident"&&tn(a,f,w.name)}case"binary":return(r.op==="+"||r.op==="-")&&z(r.left,t)&&z(r.right,t);case"unary":return r.op==="-"&&z(r.operand,t);default:return!1}},$=(r,t)=>{if(l?.computed?.[r]===void 0)return!1;if(u.has(r))return u.get(r);u.set(r,!1);let d=p.get(r),w=d!==void 0&&z(d,t);return u.set(r,w),w};return s.map(([r])=>r).filter(r=>$(r,0))}function rn(e,o,s=`kinds.${e}.page`){let a=o.page;if(!a)return[];let l=[],p=[...Object.keys(o.fields),...Object.keys(o.computed??{})],u=new Set,z=(r,t)=>{p.includes(r)?u.has(r)&&l.push(g("page-field-twice",t,`"${r}" is on ${e}'s page twice; name each field once`)):l.push(g("page-field",t,`${e}'s page is to show "${r}", and ${e} has no field or computed field called that`,`use one of: ${p.join(", ")}`)),u.add(r)};(a.fields??[]).forEach((r,t)=>z(r,`${s}.fields.${t}`));let $=new Set;return(a.groups??[]).forEach((r,t)=>{let d=r.title.trim().toLowerCase();$.has(d)&&l.push(g("page-group-twice",`${s}.groups.${t}.title`,`${e}'s page has two groups called "${r.title}"; give each its own title`)),$.add(d),r.fields.forEach((w,f)=>z(w,`${s}.groups.${t}.fields.${f}`))}),l}var Dn=new Set(["subject","now","today","me"]);function Kn(e){if((typeof e=="string"?e:JSON.stringify(e??null)).length>ke)return{findings:[g("too-large","",`a document may be at most ${ke/1024} KB`)]};if(typeof e=="string")try{e=JSON.parse(e)}catch(a){return{findings:[g("not-json","",`this is not JSON: ${a.message}`)]}}try{e=Qe(e).document}catch(a){return{findings:[g("format","formatVersion",a.message)]}}let o=Xe.safeParse(e);if(!o.success)return{findings:o.error.issues.map(a=>{let l=a.path.map(String).join(".");if(a.code==="unrecognized_keys")return g("unknown-key",l,`${a.keys.map(p=>`"${p}"`).join(", ")} ${a.keys.length===1?"is":"are"} not part of a Graview document here`,"check the spelling against docs/declaration-document.md");if(a.code==="invalid_union"&&/\.effects\.\d+$/.test(l))return g("effect-shape",l,"this effect is not one Graview knows",'an effect is one of {"create": kind, "as"?: name, "set"?: {field: value}}, {"set": {field: value, \u2026}, "target"?: "$ref"}, {"connect"|"sever": relation, "from": "$ref", "to": "$ref"}, {"remove": "$ref"}');if(a.code==="invalid_key"){let p=a.issues?.[0]?.message;return g("shape",l,`the name "${String(a.path.at(-1))}" is not allowed here${p?`: ${p}`:""}`)}return g("shape",l,a.message)})};let s=o.data;return{document:s,findings:Mn(s)}}var de=e=>[e??[]].flat();function an(e){let o=new Map;for(let[s,a]of Object.entries(e.kinds))for(let[l,p]of Object.entries(ee(a.edges))){let u=o.get(l);o.set(l,{name:l,from:[...u?.from??[],s],to:p.to==="*"||u?.to==="*"?"*":[...new Set([...u?.to??[],...p.to])],cardinality:p.cardinality??"many"})}return o}function ht(e){let o=new Map;for(let[a,l]of Object.entries(e.kinds)){let p=ne(l),u=fe(l.edges);o.set(a,{fields:new Set([...Object.keys(l.fields),...u.keys()]),edges:new Map(Object.entries(ee(l.edges)).map(([z,$])=>[z,$.cardinality??"many"])),...p?{computed:p}:{},...u.size>0?{linked:u}:{}})}let s=ne(e);return s&&o.set(Me,{computed:s}),o}function cn(e,o){let s=[],a=de(e.on),l=(p,u)=>{let z=en(o.kinds,p,a)?.reversed===!0,[$,r]=z?["$to","$subject"]:["$subject","$to"];return u==="connect"?{connect:p,from:$,to:r}:{sever:p,from:$,to:r}};if(e.creates){let p=o.kinds[e.creates],u={};for(let z of Object.keys(p?.fields??{}))u[z]=`$${z}`;for(let z of e.effects??[])"set"in z&&!("create"in z)&&F(z.target)==="new"&&Object.assign(u,z.set);s.push({create:e.creates,as:"new",set:u})}return e.sets&&s.push({set:e.sets}),e.writes&&!(e.creates&&e.on===void 0)&&s.push({set:Object.fromEntries(e.writes.map(p=>[p,`$${p}`]))}),e.connects&&(e.replaces&&s.push({replace:e.replaces===!0?[e.connects]:[...e.replaces],keep:e.connects}),s.push(l(e.connects,"connect"))),e.severs&&s.push(l(e.severs,"sever")),e.setsOther&&(e.connects||e.severs)&&s.push({set:e.setsOther,target:"$to"}),e.removes&&s.push({remove:"$subject"}),e.effects&&s.push(...e.effects.filter(p=>!(e.creates&&"set"in p&&!("create"in p)&&F(p.target)==="new"))),s}function Oe(e,o,s){try{let a=Z(e),l=se(a);for(let p of l.unknownFunctions)s.push(g("unknown-function",o,`"${p}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));return a}catch(a){if(a instanceof re){s.push(g("expression",o,a.sentence+` (at character ${a.at+1})`));return}throw a}}function ve(e,o,s){try{return Y(e)}catch(a){if(a instanceof _e||a instanceof re){s.push(g("template",o,(a instanceof re,a.sentence)));return}throw a}}function Mn(e){let o=[],s=new Set(Object.keys(e.kinds)),a=an(e),l=e.acts??{},p=new Set(e.roles??[]),u=(r,t)=>fe(e.kinds[r]?.edges).has(t),z=r=>Object.keys(e.kinds).some(t=>u(t,r));for(let[r,t]of Object.entries(e.kinds)){let d=`kinds.${r}`;for(let[f,c]of Object.entries(t.edges??{})){if(!De(c)&&c.to!=="*")for(let i of c.to)s.has(i)||o.push(g("edge-target",`${d}.edges.${f}.to`,`"${i}" is not a kind this document declares`));t.fields[f]&&o.push(g("edge-field-clash",`${d}.edges.${f}`,`"${f}" is both a field and a relation of ${r}`,"rename one of them"))}t.lifecycle&&!t.fields[t.lifecycle.field]&&o.push(g("lifecycle-field",`${d}.lifecycle.field`,`${r} has no field "${t.lifecycle.field}"`));let w=f=>t.computed!==void 0&&Object.hasOwn(t.computed,f);for(let f of t.glance??[])!t.fields[f]&&!w(f)&&o.push(g("glance-field",`${d}.glance`,`a glance at ${r} is to say "${f}", and ${r} has no field or computed field called that`,`use one of: ${[...Object.keys(t.fields),...Object.keys(t.computed??{})].join(", ")}`));o.push(...rn(r,t));for(let f of["label","describe"]){let c=t[f];if(!c)continue;let i=ve(c,`${d}.${f}`,o);for(let A of i??[])if(A.expr){for(let y of se(A.expr).names)if(!t.fields[y]){if(w(y)){Be(t,y)||o.push(g("template-field",`${d}.${f}`,`${r}'s ${y} is worked out from beyond the record, and a ${f} is said with no graph to read`,`show it in a view instead, or name a computed field worked out from ${r}'s own fields`));continue}o.push(g("template-field",`${d}.${f}`,`${r} has no field "${y}" for its ${f} to show`,f==="label"?"a label can only show the record's own fields and what they work out":void 0))}}}for(let[f,c]of Object.entries(t.fields)){c.default!==void 0&&c.type==="enum"&&!c.options?.includes(String(c.default))&&o.push(g("default-option",`${d}.fields.${f}.default`,`"${String(c.default)}" is not one of ${f}'s options`));let i=`${f}Repeat`;c.repeats&&(t.fields[i]||t.edges?.[i]||t.computed?.[i])&&o.push(g("repeat-clash",`${d}.fields.${f}.repeats`,`${r} already has "${i}", where how ${f} repeats is kept`))}}for(let[r,t]of Object.entries(l)){let d=`acts.${r}`;for(let i of de(t.on))s.has(i)||o.push(g("act-kind",`${d}.on`,`"${i}" is not a kind this document declares`));let w=de(t.on),f=cn(t,e);if(t.creates&&t.on===void 0&&t.writes&&s.has(t.creates)){for(let i of t.writes)if(!e.kinds[t.creates].fields[i])if(e.kinds[t.creates].computed?.[i]!==void 0)o.push(g("computed-written",`${d}.writes`,`${t.creates}'s ${i} is worked out, not written: no act can set it`,"write the stored fields it is worked out from"));else{if(u(t.creates,i))continue;o.push(g("act-field",`${d}.writes`,`${t.creates} has no field "${i}"`))}}f.length===0&&o.push(g("act-empty",d,`"${r}" does nothing`,"give it effects or a shorthand such as sets or creates"));let c=new Map;f.forEach((i,A)=>{let y=f.length-(t.effects?.length??0),O=t.effects&&A>=y?`${d}.effects.${A-y}`:d;if("create"in i){if(!s.has(i.create))o.push(g("act-kind",`${O}.create`,`"${i.create}" is not a kind this document declares`));else for(let b of Object.keys(i.set??{}))e.kinds[i.create].fields[b]||(e.kinds[i.create].computed?.[b]!==void 0?o.push(g("computed-written",`${O}.set.${b}`,`${i.create}'s ${b} is worked out, not written: no act can set it`,"set the stored fields it is worked out from")):o.push(g("act-field",`${O}.set.${b}`,`${i.create} has no field "${b}"`)));i.as&&c.set(i.as,i.create)}else if("connect"in i||"sever"in i){let b="connect"in i?i.connect:i.sever;!a.has(b)&&!z(b)&&o.push(g("act-edge",`${O}.${"connect"in i?"connect":"sever"}`,`"${b}" is not a relation any kind declares`)),F(i.from)==="subject"&&w.length===0&&o.push(g("act-subject",`${d}.on`,`"${r}" acts on "$subject" but does not say which kinds it is "on"`))}else if("set"in i){let b=F(i.target??"$subject"),le=b==="subject"?w:c.has(b??"")?[c.get(b)]:[];b==="subject"&&w.length===0&&o.push(g("act-subject",`${d}.on`,`"${r}" changes "$subject" but does not say which kinds it is "on"`));for(let _ of Object.keys(i.set))for(let m of le)if(!(!s.has(m)||e.kinds[m].fields[_]))if(e.kinds[m].computed?.[_]!==void 0)o.push(g("computed-written",`${O}.set.${_}`,`${m}'s ${_} is worked out, not written: no act can set it`,"set the stored fields it is worked out from"));else{if(u(m,_))continue;o.push(g("act-field",`${O}.set.${_}`,`${m} has no field "${_}"`))}}else"remove"in i&&F(i.remove)==="subject"&&w.length===0&&o.push(g("act-subject",`${d}.on`,`"${r}" removes "$subject" but does not say which kinds it is "on"`));("set"in i&&i.set?Object.values(i.set):[]).forEach(b=>{b&&typeof b=="object"&&!Array.isArray(b)&&"expr"in b&&Oe(b.expr,`${O}.set`,o)})}),t.allowedWhen&&Oe(t.allowedWhen,`${d}.allowedWhen`,o),t.refusal&&ve(t.refusal,`${d}.refusal`,o)}for(let[r,t]of Object.entries(e.rules??{})){let d=`rules.${r}`;t.over!=="graph"&&!s.has(t.over)&&o.push(g("rule-kind",`${d}.over`,`"${t.over}" is not a kind this document declares`));let w=t.over==="graph"?void 0:e.kinds[t.over];for(let f of["when","require"]){let c=t[f];if(!c)continue;let i=Oe(c,`${d}.${f}`,o);if(!i)continue;let A=se(i);for(let y of A.names)if(t.over==="graph")o.push(g("rule-name",`${d}.${f}`,`"${y}" means nothing in a rule over the whole graph`,`name a kind in "over", or use all('kind')`));else if(w&&!w.fields[y]&&!w.edges?.[y]&&w.computed?.[y]===void 0){let O=Object.keys(w.edges??{}).find(S=>S.includes("-")&&S.split("-").includes(y));o.push(g("rule-name",`${d}.${f}`,`${t.over} has no field or relation called "${y}"`,O?`"${O}" reads as a subtraction in a rule; rename the relation to one camelCase word, like "${O.replace(/-([a-z0-9])/g,(S,b)=>b.toUpperCase())}"`:void 0))}for(let y of A.edges)!a.has(y)&&!z(y)&&o.push(g("rule-edge",`${d}.${f}`,`"${y}" is not a relation any kind declares`));for(let y of A.sweeps)s.has(y)?t.over!=="graph"&&o.push(Te("rule-cost",`${d}.${f}`,`this rule looks at every ${y} for every ${t.over}, which grows slowly as the app grows`,"walk a relation with out()/in() instead of all() where you can")):o.push(g("rule-kind",`${d}.${f}`,`"${y}" is not a kind this document declares`))}t.says&&ve(t.says,`${d}.says`,o),(t.repairs??[]).forEach((f,c)=>{!l[f.act]&&!ue(f.act)&&!ze(f.act,e.kinds)&&o.push(g("repair-act",`${d}.repairs.${c}.act`,`"${f.act}" is not an act this document declares`))})}let $=e.policy;return $&&($.grants.forEach((r,t)=>{if(r.roles!=="*"&&p.size>0)for(let d of r.roles)p.has(d)||o.push(g("grant-role",`policy.grants.${t}.roles`,`"${d}" is not one of the document's roles`));if(r.mutations!=="*")for(let d of r.mutations)!l[d]&&!ue(d)&&!ze(d,e.kinds)&&o.push(g("grant-act",`policy.grants.${t}.mutations`,`"${d}" is not an act this document declares`))}),($.sees??[]).forEach((r,t)=>{for(let d of r.kinds)s.has(d)||o.push(g("sight-kind",`policy.sees.${t}.kinds`,`"${d}" is not a kind this document declares`));if(r.roles!=="*"&&p.size>0)for(let d of r.roles)p.has(d)||o.push(g("sight-role",`policy.sees.${t}.roles`,`"${d}" is not one of the document's roles`))})),o.push(...Ve(e)),o}function Tn(e,o,s,a){let l=new Map,p=de(e.on),u=new Map,z=new Map;(p.length>0||o.some(c=>"remove"in c&&F(c.remove)==="subject"||"from"in c&&(F(c.from)==="subject"||F(c.to)==="subject")||"set"in c&&!("create"in c)&&F(c.target??"$subject")==="subject"))&&l.set(ge,{ref:p.length>0?p:"*",required:!0});let r=e.args??{},t=e.writes?.length===1,d=(c,i)=>i&&c.type===i.type&&c.min===void 0&&c.max===void 0&&c.step===void 0?{...c,...i.min===void 0?{}:{min:i.min},...i.max===void 0?{}:{max:i.max},...i.step===void 0?{}:{step:i.step}}:c,w=(c,i)=>i&&c.type===i.type&&c.format===void 0&&c.unit===void 0?{...d(c,i),...i.format?{format:i.format}:{},...i.unit?{unit:i.unit}:{}}:d(c,i),f=(c,i,A)=>{if(c===ge||Dn.has(c)||u.has(c)||l.has(c))return;let y=r[c]?w(r[c],A):void 0;l.set(c,y?{field:y,optional:!y.required,required:!!y.required}:i())};for(let c of o)if("create"in c){let i=s.kinds[c.create];for(let[A,y]of Object.entries(c.set??{})){let O=F(y),S=i?.fields[A];if(O&&S){let b=!!S.required&&S.default===void 0;f(O,()=>({field:S,optional:!b,required:b}),S)}}c.as&&u.set(c.as,c.create)}else if("connect"in c||"sever"in c){let i=a.get("connect"in c?c.connect:c.sever);for(let[A,y]of[["from",c.from],["to",c.to]]){let O=F(y);if(!O)continue;let S=A==="to"?i?.to??"*":i?.from??"*";S!=="*"&&!z.has(O)&&z.set(O,S),f(O,()=>({ref:S,required:!0}))}}else if("set"in c){let i=F(c.target??"$subject"),A=i==="subject"?p[0]:u.get(i??"")??z.get(i??"")?.[0];i&&i!=="subject"&&!u.has(i)&&f(i,()=>({ref:"*",required:!0}));for(let[y,O]of Object.entries(c.set)){let S=F(O);if(!S)continue;let b=A?s.kinds[A]?.fields[y]:void 0;f(S,()=>b?{field:b,optional:!t,required:t}:{any:!0,required:!1},b)}}else if("remove"in c){let i=F(c.remove);i&&f(i,()=>({ref:"*",required:!0}))}for(let[c,i]of Object.entries(r))l.has(c)||l.set(c,{field:i,optional:!i.required,required:!!i.required});return l}function yt(e,o={}){let s=Kn(e);if(!s.document||me(s.findings))return{ok:!1,findings:s.findings};let a=s.document,l=[...s.findings];o.previous&&l.push(...Gn(a,o.previous));let p=Pn(a,l);return me(p.findings)?{ok:!1,findings:p.findings}:Ne(p,o)}function ce(e,o){return e.map(s=>{let a=!s.format&&s.expr?.t==="ident"?o?.[s.expr.name]?.format:void 0;return a==="money"||a==="percent"?{...s,format:a}:s})}function Pn(e,o){let s=an(e),a={};for(let[r,t]of Object.entries(e.kinds)){let d=Ce(t),w=t.label??(d?`{${d}}`:void 0),f=ne(t),c=f?sn(e,r,[...f]):[];a[r]={...w?{label:ce(Y(w),t.fields)}:{},...t.describe?{describe:ce(Y(t.describe),t.fields)}:{},...f?{computed:[...f]}:{},...c.length>0?{durations:c}:{}}}let l={};for(let[r,t]of Object.entries(e.acts??{})){let d=cn(t,e),w=Tn(t,d,e,s),f=t.destructive??d.some(m=>"remove"in m||"sever"in m||"replace"in m),c=[...new Set(d.flatMap(m=>"create"in m?[m.create]:[]))],i=[...new Set(d.flatMap(m=>"connect"in m?[m.connect]:[]))],A=[...new Set(d.flatMap(m=>"sever"in m?[m.sever]:"replace"in m?m.replace:[]))],y=[...new Set(d.flatMap(m=>"set"in m&&!("create"in m)&&F(m.target??"$subject")==="subject"?Object.keys(m.set):[]))],O=new Map;for(let m of d){if(!("connect"in m)&&!("sever"in m))continue;let x=s.get("connect"in m?m.connect:m.sever);for(let[M,dn]of[["from",m.from],["to",m.to]]){let oe=F(dn),pe=M==="to"?x?.to:x?.from;oe&&oe!=="subject"&&pe&&pe!=="*"&&O.set(oe,[...new Set([...O.get(oe)??[],...pe])])}}let S={};for(let m of d){if(!("set"in m)||"create"in m)continue;let x=F(m.target??"$subject");for(let M of x&&x!=="subject"&&O.get(x)||[])S[M]=[...new Set([...S[M]??[],...Object.keys(m.set)])]}let b={};for(let m of d)if(!(!("set"in m)||"create"in m||F(m.target??"$subject")!=="subject"))for(let[x,M]of Object.entries(m.set??{}))typeof M=="string"&&F(M)===void 0||typeof M=="number"||typeof M=="boolean"?b[x]=typeof M=="string"&&M.startsWith("$$")?M.slice(1):M:delete b[x];let le=c.length===0&&d.every(m=>!("set"in m)||!m.set||Object.values(m.set).every(x=>!(x&&typeof x=="object"&&!Array.isArray(x)&&"expr"in x))),_=new Map;for(let m of d)if(!(!("set"in m)||!m.set))for(let x of Object.values(m.set))x&&typeof x=="object"&&!Array.isArray(x)&&"expr"in x&&_.set(x.expr,Z(x.expr));l[r]={title:t.title??r.replace(/-/g," "),effects:d,args:[...w],...t.allowedWhen?{guard:Z(t.allowedWhen)}:{},...t.refusal?{refusal:ce(Y(t.refusal),e.kinds[[t.on??[]].flat()[0]??""]?.fields)}:{},exprs:[..._],destructive:f,idempotent:le,creates:c,connects:i,severs:A,writes:y,writesOther:S,sets:b}}let p={};for(let[r,t]of Object.entries(e.rules??{}))p[r]={title:t.title??r.replace(/-/g," "),require:Z(t.require),...t.when?{when:Z(t.when)}:{},...t.says?{says:ce(Y(t.says),e.kinds[t.over]?.fields)}:{}};let u=Pe(e,o),z=Ie(e),$=qe(e);return{format:Ge,document:e,findings:o,kinds:a,...e.computed?{facts:[...ne(e)??[]]}:{},edges:[...s].map(([r,{from:t,to:d,cardinality:w}])=>[r,{from:t,to:d,cardinality:w}]),acts:l,rules:p,brand:u,...Object.keys(z).length>0?{viewSpecs:z}:{},...$?{home:$}:{}}}function bt(e,o,s){let a=/^defineNode\("([^"]+)"\)/.exec(o)?.[1],l=a?s.kinds[a]:void 0;if(!a||!l)return e;let p=Object.keys(l.fields).filter(u=>u!=="label").slice(0,3);return{...e,path:`kinds.${a}.glance`,fix:`Say which: "glance": [${p.map(u=>`"${u}"`).join(", ")}] on kinds.${a} \u2014 the facts a person compares one by, at a glance.`}}function Gn(e,o){let s=[],a=new Set(Object.values(o.kinds).flatMap(l=>Object.keys(l.edges??{})));for(let[l,p]of Object.entries(e.kinds)){let u=p.renamedFrom;u&&!o.kinds[u]&&s.push(g("renamed-from-nothing",`kinds.${l}.renamedFrom`,`${l} says it was ${u}, and the previous version has no kind called ${u}`,"name the kind it was, or drop renamedFrom"));let z=o.kinds[u??l];for(let[$,r]of Object.entries(p.fields)){let t=r.renamedFrom;t&&!z?.fields[t]&&s.push(g("renamed-from-nothing",`kinds.${l}.fields.${$}.renamedFrom`,`${$} says it was ${t}, and the previous ${u??l} has no field called ${t}`,"name the field it was, or drop renamedFrom"))}for(let[$,r]of Object.entries(p.edges??{})){let t=r.renamedFrom;t&&!a.has(t)&&s.push(g("renamed-from-nothing",`kinds.${l}.edges.${$}.renamedFrom`,`${$} says it was ${t}, and the previous version has no relation called ${t}`,"name the relation it was, or drop renamedFrom"))}}return s}export{Kn as a,ht as b,cn as c,yt as d,bt as e};
|
|
@@ -0,0 +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{$ as S,F as g,G as T,R as v,qa as C}from"./chunk.BTSXYZ6Z.js";import{a as m}from"./chunk.SDO3U72B.js";import"./chunk.5ZMENPY4.js";import{b as c}from"./chunk.AJZBJBMO.js";var n=c(T(),1),r=c(v(),1),s=null,u=null,f=new Set,a=()=>{for(let e of f)e()},y=e=>(f.add(e),()=>void f.delete(e)),E=300,d=()=>{u!==null&&clearTimeout(u),u=null};function q(e,t){d(),x.prefetch(),!(s?.element===t&&s.target.on===e.on)&&(s={target:e,element:t},a())}function M(e=!1){if(d(),s!==null){if(e){s=null,a();return}u=setTimeout(()=>{u=null,s=null,a()},E)}}var R=()=>d(),P=()=>s,b="graview:hover-chips",h;function A(e){if(h!==void 0)return h;try{return(e??localStorage).getItem(b)!=="off"}catch{return!0}}function I(e,t){h=e;try{(t??localStorage).setItem(b,e?"on":"off")}catch{}e||(s=null),a()}function w(){let e=S(),t=g(e?.ai),o=e?.memory,l=(0,n.useSyncExternalStore)(y,()=>A(o),()=>!1),i=(0,n.useCallback)(H=>I(H,o),[o]);return{offered:t,on:t&&l,set:i}}function z({legend:e,style:t,choice:o}){let l=w();return l.offered?(0,r.jsxs)("fieldset",{"data-testid":"setting-hover-chips",style:{border:0,margin:0,padding:0,display:"grid",gap:5,...t},children:[(0,r.jsx)("legend",{style:{...e,padding:0},children:"AI suggestions on hover"}),(0,r.jsx)("span",{style:{fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:"A quiet suggestion beside a record the pointer rests on, when the AI is sure of one."}),(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[!0,!1].map(i=>(0,r.jsx)("button",{type:"button","aria-pressed":l.on===i,"data-testid":`setting-hover-chips-${i?"on":"off"}`,onClick:()=>l.set(i),style:o(l.on===i),children:i?"On":"Off"},String(i)))})]}):null}var x=C(m(()=>(__graviewPreload(import.meta.url,["./chunk.RM7NVN7B.js","./chunk.J3M2MZHG.js","./chunk.UT6642FC.js","./chunk.IAZRY42B.js","./chunk.FMN5XDLE.js","./chunk.UIUHGA6W.js","./chunk.TI4OSTQV.js","./chunk.4BBJ62ZO.js","./chunk.NSNGPQGT.js","./chunk.H5CZZZLX.js","./chunk.Z7JRBKA7.js","./chunk.ORXFUK6F.js","./chunk.BTSXYZ6Z.js","./chunk.SDO3U72B.js","./chunk.5ZMENPY4.js","./chunk.AJZBJBMO.js"]),import("./chunk.RXSHFG6S.js")))),k=x.part((e,t)=>{let o=e.HoverChip;return(0,r.jsx)(o,{...t})},{quiet:!0}),p=null,O=()=>p;function L(){let{on:e}=w(),t=(0,n.useSyncExternalStore)(y,P,()=>null),[o]=(0,n.useState)(()=>Symbol("hover-chip")),l=(0,n.useSyncExternalStore)(y,O,()=>null);return(0,n.useEffect)(()=>{if(e)return p===null&&(p=o,a()),()=>{p===o&&(p=null,s=null,d(),a())}},[e,o,l]),!e||t===null||l!==o||!t.element.isConnected?null:(0,r.jsx)(n.Suspense,{fallback:null,children:(0,r.jsx)(k,{rest:t,hold:R,leave:M})})}export{L as HoverChipDoor,z as HoverChipsSwitch,R as holdRest,A as hoverChipsWanted,M as leaveRest,q as restOn,I as setHoverChipsWanted,w as useHoverChipsSetting};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{G as h,Z as d,_ as a,aa as c,va as u}from"./chunk.BTSXYZ6Z.js";import{b as l}from"./chunk.AJZBJBMO.js";var i=l(h(),1);function w(){let e=u();return(0,i.useMemo)(()=>[...new Set(e.flatMap(o=>o.nodeIds))],[e])}function S(){let e=g(),o=d();return(0,i.useMemo)(()=>{if(!o)return e;let n=o.matched;return n.length===0&&e.length===0?[m]:[...new Set([...e,...n])]},[o,e])}function g(){let{store:e,selection:o}=a(),n=c();return(0,i.useMemo)(()=>{if(o.length===0)return[];let r=new Set(o),s=new Set(r);for(let t of e.graph.allEdges())r.has(t.from)&&s.add(t.to),r.has(t.to)&&s.add(t.from);for(let t of e.violations())if(t.subjectId!==void 0&&r.has(t.subjectId))for(let f of t.nodeIds)s.add(f);return[...s]},[e,o,n])}var m="search:nothing";export{w as a,S as b,g as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b,c as m,d as g}from"./chunk.STBJV6HJ.js";import"./chunk.F5UVEF2R.js";import"./chunk.FGDHEVH4.js";import"./chunk.5ZMENPY4.js";import"./chunk.AJZBJBMO.js";var A=new Set(["input","select","textarea"]),y=r=>r.namespaceURI==="http://www.w3.org/1999/xhtml"&&A.has(r.localName),E=r=>r.localName==="select"||r.type==="checkbox"||r.type==="radio",v=r=>r.type==="checkbox"||r.type==="radio"?!r.checked:r.localName!=="select"&&r.value==="";function h(r){return r.type==="checkbox"||r.type==="radio"?`checked:${r.checked}`:r.localName==="select"&&r.multiple?`selected:${[...r.selectedOptions].map(d=>d.value).join("\0")}`:`value:${r.value}`}function T(r=d=>d.isTrusted){let d=new WeakMap,u=new WeakSet,s=new WeakMap,o={heard(e,t){if(!(!y(t)||!r(e))&&(e.type==="input"||e.type==="change"&&E(t))&&((E(t)||v(t))&&u.delete(t),v(t)&&s.delete(t),d.set(t,h(t)),t.type==="radio"&&t.name)){let i=t.getRootNode();for(let c of i.querySelectorAll?.('input[type="radio"]')??[])c.name===t.name&&d.set(c,h(c))}},filled(e){d.delete(e),s.delete(e),y(e)&&!v(e)?u.add(e):u.delete(e)},press(e,t,i){if(e.type!=="click"||!r(e))return;let c=t.closest("[data-act]");if(!(!c||y(c)&&c.hasAttribute("data-save")))return o.collect(c,i)},collect(e,t){if(!e.hasAttribute("data-act")||!t.contains(e))return;let i=e.closest("[data-record]"),c=e.closest("fieldset, [role='group']")??t,l=[];for(let n of c.querySelectorAll("input[name], select[name], textarea[name]")){let a=n,f=!u.has(a)&&d.get(a)===h(a);if(a.type==="radio"){if(!a.checked)continue;l.push({name:a.name,value:a.value,typed:f,empty:!1,chosen:!0});continue}if(a.localName==="select"){l.push({name:a.name,value:a.value,typed:f,empty:a.value===""&&!f,chosen:!0});continue}if(a.type==="checkbox"){l.push({name:a.name,value:a.checked,typed:f,empty:!a.checked&&!u.has(a)&&!f});continue}let k=(a.type==="number"||a.type==="range")&&a.value!==""&&Number.isFinite(a.valueAsNumber)?a.valueAsNumber:a.value,w=f?s.get(a):void 0;l.push({name:a.name,value:k,typed:f,empty:a.value===""&&!f,...w?{from:w}:{}})}return{as:e.getAttribute("data-act")??"",...i&&t.contains(i)?{record:i.getAttribute("data-record")}:{},fields:l}},prefilled(e,t){u.delete(e),s.set(e,t),d.set(e,h(e))}};return o}var M=1e3;function x(r){let d=r.getAttribute("data-debounce")?.trim(),u=d?Number(d):Number.NaN;return Number.isFinite(u)?Math.min(1e4,Math.max(250,Math.round(u))):M}function R(r){let d=r.trusted??(e=>e.isTrusted),u=r.timers??{set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)},s=new Map,o=(e,t)=>{let i=s.get(e);i&&u.clear(i.handle),s.delete(e);let c=r.reader.collect(e,t);c&&r.save(c,e)};return{heard(e,t,i){if(!y(t)||!d(e)||!t.hasAttribute("data-act"))return;let c=t.getAttribute("data-save");if(e.type==="input"&&c==="input"){let l=s.get(t);l&&u.clear(l.handle),s.set(t,{root:i,handle:u.set(()=>o(t,i),x(t))})}else e.type==="change"&&(c==="change"||c==="input"&&s.has(t))&&o(t,i)},flush(){for(let[e,{root:t}]of[...s])o(e,t)},get waiting(){return s.size}}}var N=new Set(["text","search","email","url","tel","number"]);function O(r,d,u,s){for(let o of r.querySelectorAll("input[data-prefill], textarea[data-prefill]")){let e=o;if(u.has(e))continue;let t=e.getAttribute("data-prefill")??"";if(t===""||e.getAttribute("name")!==t||e.localName==="input"&&!N.has(e.type))continue;if(e.value!==""){u.add(e);continue}let c=[...(e.closest("fieldset, [role='group']")??r).querySelectorAll("[data-act]")],l=e.closest("[data-record]"),n=new Set(c.map(p=>p.closest("[data-record]")?.getAttribute("data-record")).filter(p=>typeof p=="string")),a=l&&r.contains(l)?l.getAttribute("data-record"):n.size===1?[...n][0]:void 0;if(!a)continue;let f=s({record:a,field:t,acts:c.map(p=>p.getAttribute("data-act")??"")});if(f!==void 0){if(e.value=f,u.add(e),e.value!==f){e.value="";continue}d.prefilled(e,{record:a,field:t,value:f})}}}function L(r,d,u,s){let o=g(d,s.as);if(!o)return m("undeclared",`This view may not ask for \u201C${s.as}\u201D: its manifest does not name it.`);let e=r.allMutations().find(n=>n.name===o.act);if(!e)return m("unknown-act","There is no act by that name here.");let t={};if(s.record!==void 0){let n=o.record??e.subject?.arg;if(!n)return m("unbound",`\u201C${s.as}\u201D is not done to a record.`);if(!u.has(s.record))return m("unbound","That press is bound to a record this view was not shown.");t[n]=s.record}for(let[n,a]of Object.entries(o.constants??{})){if(n in t)return m("malformed",`\u201C${n}\u201D is both the bound record and a constant.`);t[n]=a}let i=e.input?.shape??{},c=new Set(Object.keys(i)),l=new Set;for(let n of s.fields)if(!(!c.has(n.name)||n.name in t)){if(l.has(n.name))return m("malformed",`Two fields here are called \u201C${n.name}\u201D.`);if(l.add(n.name),n.typed&&n.chosen){let a=b(i[n.name])?.find(f=>String(f)===String(n.value));if(a!==void 0)t[n.name]=a;else if(typeof n.value=="string"&&u.has(n.value))t[n.name]=n.value;else return m("untyped",`\u201C${n.name}\u201D was a choice among the view's own words, not one this app declares, so it was not sent.`)}else{if(n.typed&&n.from&&!(s.record===n.from.record&&n.name===n.from.field&&S(r,o,n.from.record,n.from.field)))return m("untyped",`\u201C${n.name}\u201D was filled in from a record for an act that writes it back there, not for this one, so it was not sent.`);if(n.typed&&n.from&&String(n.value)===n.from.value)t[n.name]=r.graph.getNode(n.from.record)?.[n.name]??n.value;else if(n.typed)t[n.name]=n.value;else if(!n.empty)return m("untyped",`\u201C${n.name}\u201D was filled in by the view, not typed by you, so it was not sent.`)}}return{ok:!0,name:o.act,args:t}}function S(r,d,u,s){let o=r.allMutations().find(c=>c.name===d.act),e=o?.subject;if(!o||!e||(d.record??e.arg)!==e.arg||s===e.arg||Object.hasOwn(d.constants??{},s)||!Object.hasOwn(o.input.shape??{},s)||Object.keys(o.writesOther??{}).length>0)return!1;let t=r.graph.getNode(u)?.kind,i=t===void 0?void 0:r.schema.tryDefinition(t);return!i||e.kinds!=="*"&&!e.kinds.includes(t)||!Object.hasOwn(i.fields.shape??{},s)?!1:o.writes?.includes(s)??!1}function j(r,d,u,s,o){if(!s.has(o.record))return;let e=r.seenBy(d).graph.getNode(o.record);if(!e||!o.acts.some(c=>{let l=g(u,c);if(!l||!S(r,l,o.record,o.field))return!1;let n=r.allMutations().find(a=>a.name===l.act).subject;return r.permits({name:l.act,args:{[n.arg]:o.record}},d).ok}))return;let i=e[o.field];return typeof i=="string"?i:typeof i=="number"&&Number.isFinite(i)?String(i):void 0}export{M as SAVE_DEBOUNCE_MS,T as createPressReader,R as createSaver,O as fillPrefills,L as judgePress,j as prefillOf,x as saveDebounceOf,S as writesBack};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as G,b as J}from"./chunk.
|
|
1
|
+
var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as G,b as J}from"./chunk.FCXBCKED.js";import"./chunk.FILCNVGH.js";import{a as K}from"./chunk.2RCNSHXK.js";import"./chunk.RWB4235L.js";import"./chunk.B2IRADR2.js";import"./chunk.J3M2MZHG.js";import"./chunk.UT6642FC.js";import{a as S,b as W}from"./chunk.MB7LKKUD.js";import"./chunk.KJNUZYXS.js";import"./chunk.4BBJ62ZO.js";import"./chunk.UCZR33MK.js";import"./chunk.CC47O2DW.js";import"./chunk.2IX3CZNP.js";import"./chunk.6DHHUBSC.js";import"./chunk.NSNGPQGT.js";import"./chunk.H5CZZZLX.js";import"./chunk.Z7JRBKA7.js";import"./chunk.ORXFUK6F.js";import{$ as F,Aa as x,D as H,E as V,G as ee,R as D,qa as _}from"./chunk.BTSXYZ6Z.js";import{a as j}from"./chunk.SDO3U72B.js";import{ea as q,tc as B}from"./chunk.5ZMENPY4.js";import{b}from"./chunk.AJZBJBMO.js";var t=b(ee(),1);var a=b(D(),1);function ae(n){let r=[];return n.applied.length>0&&n.intent&&r.push(`${n.intent}.`),n.unchanged.length>0&&r.push(`${n.unchanged.length} already so.`),n.allOrNothing&&r.push("None of it was kept."),r.join(" ")}var re=_(j(()=>(__graviewPreload(import.meta.url,["./chunk.RM7NVN7B.js","./chunk.J3M2MZHG.js","./chunk.UT6642FC.js","./chunk.IAZRY42B.js","./chunk.FMN5XDLE.js","./chunk.UIUHGA6W.js","./chunk.TI4OSTQV.js","./chunk.4BBJ62ZO.js","./chunk.NSNGPQGT.js","./chunk.H5CZZZLX.js","./chunk.Z7JRBKA7.js","./chunk.ORXFUK6F.js","./chunk.BTSXYZ6Z.js","./chunk.SDO3U72B.js","./chunk.5ZMENPY4.js","./chunk.AJZBJBMO.js"]),import("./chunk.UB3O3QJQ.js")))),te=re.part((n,r)=>(0,a.jsx)(n.SeveralAi,{...r}),{quiet:!0});function ne(n){let r=F()?.ai;return!H(r)||!V(r)?null:(0,a.jsx)(t.Suspense,{fallback:null,children:(0,a.jsx)(te,{...n})})}function me({store:n,chosen:r,principal:d,context:v,via:k,anchor:A,of:g,onChooseAll:E,onClear:m,onActed:Q}){let[U,X]=(0,t.useState)(0);(0,t.useEffect)(()=>n.subscribe(()=>X(e=>e+1)),[n]);let f=r.join(`
|
|
2
2
|
`),{acts:c,withheld:N}=(0,t.useMemo)(()=>G(n,r,{...d?{principal:d}:{},...v?{context:v}:{}}),[n,f,d,v,U]),[O,p]=(0,t.useState)(!1),[l,u]=(0,t.useState)(null),[s,P]=(0,t.useState)(null),h=(0,t.useRef)(null),L=(0,t.useId)(),w=(0,t.useMemo)(()=>[...new Set(r.map(e=>n.graph.getNode(e)?.kind))],[n,f]),Y=w.length===1&&w[0]?`${q(n.schema,w[0],r.length)} chosen`:`${r.length} chosen`,M=typeof matchMedia=="function"&&matchMedia("(pointer: coarse), (max-width: 599px)").matches?2:3,C=c.filter(e=>!e.more),Z=C.slice(0,M),R=[...C.slice(M),...c.filter(e=>e.more)];(0,t.useEffect)(()=>{u(null),p(!1)},[f]),(0,t.useLayoutEffect)(()=>{let e=h.current;if(!e)return;if(typeof e.showPopover=="function"&&!x(e))try{e.showPopover()}catch{}let i=()=>{W(e,A?.()??null),dispatchEvent(new Event(S))};i(),addEventListener("resize",i),addEventListener("scroll",i,!0);let o=typeof ResizeObserver=="function"?new ResizeObserver(i):null;return o?.observe(e),()=>{if(o?.disconnect(),removeEventListener("resize",i),removeEventListener("scroll",i,!0),e.isConnected&&x(e))try{e.hidePopover()}catch{}dispatchEvent(new Event(S))}},[A]);let y=(0,t.useRef)({asking:l,onClear:m});y.current={asking:l,onClear:m},(0,t.useEffect)(()=>{let e=i=>{if(i.key!=="Escape"||i.defaultPrevented)return;let o=document.activeElement;if(!(!(h.current?.contains(o)??!1)&&(o instanceof HTMLTextAreaElement||o instanceof HTMLInputElement&&o.type!=="checkbox"||o instanceof HTMLSelectElement))){if(i.preventDefault(),i.stopPropagation(),y.current.asking){u(null);return}y.current.onClear()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[]);let T=(e,i={})=>{let o=J(n,{mutation:e.mutation,subject:e.subject,args:{...e.args,...i},label:e.label},r,{...d?{author:d}:{},...k?{via:k}:{},...v?{context:v}:{}});u(null),p(!1),P(o.refused.length>0||o.applied.length===0?o:null),Q(o.refused.map(I=>I.id))},$=e=>{P(null),p(!1),e.open.length>0?u(e):T(e)},z=e=>(0,a.jsxs)("button",{type:"button",className:"graview-several-act","data-testid":"several-act","data-act":e.id,"data-mutation":e.mutation,...e.destructive?{"data-tone":"warn"}:{},"aria-pressed":l?.id===e.id?!0:void 0,onClick:()=>$(e),children:[e.label,e.open.length>0?"\u2026":""]},e.id);return(0,a.jsxs)("div",{ref:h,popover:"manual",role:"region","aria-label":"The chosen records",className:"graview-several-bar","data-testid":"several-bar","data-graview-foot":"","data-graview-overlay":"","data-graview-popover":"","data-graview-offstage":"",style:ie,children:[(0,a.jsx)("style",{children:oe}),(0,a.jsxs)("div",{className:"graview-several-line",children:[(0,a.jsx)("span",{role:"status","aria-live":"polite",className:"graview-several-count","data-testid":"several-count",children:Y}),(0,a.jsxs)("div",{role:"group","aria-label":`What to do with the ${r.length} chosen`,className:"graview-several-acts",children:[Z.map(z),R.length>0?(0,a.jsx)("button",{type:"button",className:"graview-several-act","data-testid":"several-more","aria-expanded":O,"aria-controls":L,onClick:()=>p(e=>!e),children:"More"}):null,E&&g!==void 0&&g>r.length?(0,a.jsxs)("button",{type:"button",className:"graview-several-quiet","data-testid":"several-all",onClick:E,children:["Choose all ",g]}):null,(0,a.jsx)("button",{type:"button",className:"graview-several-quiet","data-testid":"several-clear","aria-keyshortcuts":"Escape",title:"Put the choice down \u2014 Escape",onClick:m,children:"Clear"})]})]}),c.length>0&&r.length>1?(0,a.jsx)(ne,{chosen:r,acts:c,onAct:$}):null,O?(0,a.jsx)("div",{id:L,role:"group","aria-label":"More",className:"graview-several-acts","data-testid":"several-more-acts",children:R.map(z)}):null,c.length===0?(0,a.jsx)("p",{className:"graview-several-said","data-testid":"several-none",children:N.length>0?`Nothing here can be done to all of them by you: ${N[0].message}`:"Nothing can be done to all of these at once."}):null,l?(0,a.jsx)("div",{className:"graview-several-ask",role:"group","aria-label":`${l.label}, for all ${r.length}`,"data-testid":"several-ask",children:(0,a.jsx)(K,{store:n,affordance:l.affordance,onApply:e=>T(l,e),onCancel:()=>u(null)})}):null,s?(0,a.jsxs)("div",{role:"alert",className:"graview-several-said","data-testid":"several-outcome",children:[ae(s),s.refused.length>0?(0,a.jsxs)(a.Fragment,{children:[" ",s.refused.length===1?"One was not changed, and is still chosen:":`${s.refused.length} were not changed, and are still chosen:`,(0,a.jsx)("ul",{"data-testid":"several-refused",children:s.refused.map(e=>(0,a.jsxs)("li",{"data-record":e.id,children:["\u201C",e.label,"\u201D \u2014 ",e.message]},e.id))})]}):null]}):null]})}var ie={position:"fixed",inset:"auto",margin:0,zIndex:B("toast"),boxSizing:"border-box",width:"max-content",height:"auto",bottom:"calc(16px + env(safe-area-inset-bottom, 0px))",left:16,overflow:"visible"},oe=`
|
|
3
3
|
.graview-several-bar{display:grid;gap:8px;padding:8px 10px;border:1px solid var(--graview-edge);border-radius:var(--graview-radius,12px);background:var(--graview-float);color:var(--graview-ink);box-shadow:var(--graview-lift-high);font-size:.875rem;line-height:1.4;max-height:70vh;overflow:auto}
|
|
4
4
|
.graview-several-line{display:flex;flex-wrap:wrap;align-items:center;gap:6px 12px;min-width:0}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as O,b}from"./chunk.CMN6VVK2.js";import"./chunk.CC47O2DW.js";import"./chunk.2IX3CZNP.js";import"./chunk.6DHHUBSC.js";import"./chunk.ORXFUK6F.js";import{G as z,R as M,_ as S}from"./chunk.BTSXYZ6Z.js";import"./chunk.SDO3U72B.js";import{Dc as A}from"./chunk.5ZMENPY4.js";import{b as v}from"./chunk.AJZBJBMO.js";var o=v(z(),1);var t=v(M(),1);function G(i){for(let d of i)for(let[r,s]of Object.entries(d))if(s===!1)return`${r} == true`;return""}var w={margin:0,fontSize:"0.8125rem",color:"var(--graview-ink-muted)"};function j({ask:i,close:d}){let{store:r,principal:s,subscriptions:h,app:f}=S(),c=(0,o.useRef)(null),p=(0,o.useId)(),[n,u]=(0,o.useState)(0),[l,y]=(0,o.useState)(!0),[m,P]=(0,o.useState)(()=>{let e=i.choices.find(g=>g.on==="reaches");if(!e)return"";let a=e.record!==void 0?r.graph.getNode(e.record):void 0;return G(a?[a]:r.graph.nodesOfKind(e.kind).slice(0,5))}),[C,x]=(0,o.useState)(null),[W,k]=(0,o.useState)(!1);(0,o.useEffect)(()=>{let e=c.current;e&&!e.open&&e.showModal()},[]);let T=()=>{let e=i.returnTo;d(),requestAnimationFrame(()=>{e?.isConnected?e.focus():document.querySelector("[data-graview-page-title], main h1, [data-testid='activity-button']")?.focus()})},N=e=>e.on==="reaches"?{...e,condition:m}:e,E=e=>b(r,{when:N(e),alsoMine:!l}),L=async()=>{let e=N(i.choices[n]),a=O(r,e);if(a){x(a);return}k(!0);try{await h.add({who:A(s),app:f?.name??"app",when:e,...l?{}:{alsoMine:!0}}),T()}catch(g){k(!1),x(g instanceof Error?g.message:String(g))}};return(0,t.jsx)("dialog",{ref:c,"aria-labelledby":p,"data-testid":"notify-sheet",onClose:T,onClick:e=>{e.target===e.currentTarget&&e.currentTarget.close()},style:{width:"min(92vw, 420px)",padding:0,border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)",color:"var(--graview-ink)",boxShadow:"var(--graview-lift-high)"},children:(0,t.jsxs)("form",{method:"dialog",onSubmit:e=>{e.preventDefault(),L()},style:{display:"grid",gap:12,padding:18},children:[(0,t.jsx)("h2",{id:p,style:{margin:0,fontSize:"1.0625rem"},children:"Notify me"}),(0,t.jsxs)("fieldset",{style:{margin:0,padding:0,border:0,display:"grid",gap:6},children:[(0,t.jsx)("legend",{style:{...w,marginBottom:6},children:"Tell me"}),i.choices.map((e,a)=>(0,t.jsxs)("label",{style:{display:"flex",gap:8,alignItems:"baseline",cursor:"pointer"},children:[(0,t.jsx)("input",{type:"radio",name:`${p}-when`,checked:n===a,onChange:()=>u(a),"data-notify-choice":e.on}),(0,t.jsx)("span",{children:e.on==="reaches"?`When ${e.record!==void 0?"it":"one"} reaches a condition`:E(e)})]},a))]}),i.choices[n]?.on==="reaches"?(0,t.jsxs)("label",{style:{display:"grid",gap:4},children:[(0,t.jsx)("span",{style:w,children:"The condition, in the app's own words (done == true, amount > 100)"}),(0,t.jsx)("input",{value:m,onChange:e=>P(e.target.value),"data-testid":"notify-condition",autoComplete:"off",spellCheck:!1})]}):null,(0,t.jsxs)("label",{style:{display:"flex",gap:8,alignItems:"center"},children:[(0,t.jsx)("input",{type:"checkbox",checked:l,onChange:e=>y(e.target.checked),"data-testid":"notify-others-only"}),"Only when someone else does it"]}),(0,t.jsxs)("p",{style:w,"data-testid":"notify-said",children:[E(i.choices[n]),"."]}),C?(0,t.jsx)("p",{role:"alert",style:{margin:0,color:"var(--graview-danger, var(--graview-ink))"},children:C}):null,(0,t.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[(0,t.jsx)("button",{type:"button",onClick:()=>c.current?.close(),children:"Cancel"}),(0,t.jsx)("button",{type:"submit",autoFocus:!0,disabled:W,"data-testid":"notify-keep",style:{borderColor:"var(--graview-accent)",color:"var(--graview-accent)"},children:"Notify me"})]})]})})}function B({style:i}){let{store:d,principal:r,subscriptions:s,app:h}=S(),f=(r.onBehalfOf??r).id,[c,p]=(0,o.useState)([]);return(0,o.useEffect)(()=>{if(f===void 0)return;let n=!0,u=()=>void Promise.resolve(s.list(f)).then(y=>n&&p(y.filter(m=>m.app===(h?.name??"app"))),()=>n&&p([]));u();let l=s.onChange?.(u);return()=>{n=!1,l?.()}},[s,f,h]),c.length===0?null:(0,t.jsxs)("section",{"aria-label":"What you are told of","data-testid":"notified",style:{display:"grid",gap:6,...i},children:[(0,t.jsx)("span",{style:{fontSize:"0.75rem",letterSpacing:"0.14em",textTransform:"uppercase",color:"var(--graview-ink-faint)"},children:"You are told"}),(0,t.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:4},children:c.map(n=>(0,t.jsxs)("li",{style:{display:"flex",gap:8,alignItems:"baseline",justifyContent:"space-between"},"data-subscription":n.id,children:[(0,t.jsx)("span",{style:{fontSize:"0.8125rem"},children:b(d,n)}),(0,t.jsx)("button",{type:"button","data-testid":"notify-stop","aria-label":`Stop: ${b(d,n)}`,onClick:u=>{let l=u.currentTarget.closest("li"),y=(l?.nextElementSibling??l?.previousElementSibling)?.querySelector("button");Promise.resolve(s.remove(n.id)).then(()=>(y??document.querySelector("[data-testid='activity-button']"))?.focus())},style:{padding:"1px 8px",fontSize:"0.8125rem"},children:"Stop"})]},n.id))})]})}export{B as NotifiedList,j as NotifySheet};
|