graview 0.1.44 → 0.1.46
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.RVQYXPCM.js → chunk.2JJYGYT2.js} +1 -1
- package/dist/preview/{chunk.P5K7EYDK.js → chunk.3MMLRSRC.js} +1 -1
- package/dist/preview/{chunk.D2RK2KJD.js → chunk.3OSGN463.js} +1 -1
- package/dist/preview/{chunk.3M4VCAA3.js → chunk.3VFYSXMQ.js} +1 -1
- package/dist/preview/{chunk.ZN77U6SU.js → chunk.4HYJHGI4.js} +1 -1
- package/dist/preview/{chunk.BA4KQR5H.js → chunk.4KNEBLB7.js} +1 -1
- package/dist/preview/chunk.4OGOTHRD.js +1 -0
- package/dist/preview/{chunk.UXLJZIYX.js → chunk.4RJZVTW7.js} +1 -1
- package/dist/preview/chunk.4Y6VGQVQ.js +1 -0
- package/dist/preview/{chunk.F4DWRBO7.js → chunk.55D33E5A.js} +1 -1
- package/dist/preview/{chunk.QJJKITXF.js → chunk.5ESCD57M.js} +1 -1
- package/dist/preview/chunk.5K6KX3UC.js +1 -0
- package/dist/preview/chunk.5R2R364Q.js +1 -0
- package/dist/preview/{chunk.ALFW4ZJQ.js → chunk.63JLXGYX.js} +1 -1
- package/dist/preview/{chunk.7PUFYK3B.js → chunk.64WM4IBI.js} +1 -1
- package/dist/preview/chunk.6BDM2XRX.js +1 -0
- package/dist/preview/{chunk.ATKKTPJS.js → chunk.6MADC6DM.js} +1 -1
- package/dist/preview/{chunk.6BIRNR5P.js → chunk.6OPI4WWO.js} +1 -1
- package/dist/preview/{chunk.YERDP6YF.js → chunk.6QYJ2K6K.js} +1 -1
- package/dist/preview/{chunk.N5ULWKR4.js → chunk.6RY6OSE6.js} +1 -1
- package/dist/preview/{chunk.P546VMA5.js → chunk.6SOUQNXR.js} +1 -1
- package/dist/preview/chunk.6UIW664O.js +6 -0
- package/dist/preview/{chunk.7B5BZZBG.js → chunk.6WA6ASQB.js} +1 -1
- package/dist/preview/chunk.6YD2DLIC.js +1 -0
- package/dist/preview/{chunk.DLVNW4HU.js → chunk.A5VGTO3E.js} +1 -1
- package/dist/preview/{chunk.RNUGQRJI.js → chunk.AGIO2GRV.js} +29 -7
- package/dist/preview/{chunk.HKD5SR45.js → chunk.AQQZY6OY.js} +2 -2
- package/dist/preview/{chunk.AW2T3KFV.js → chunk.AS4CQBOQ.js} +1 -1
- package/dist/preview/chunk.ATDU5Y7V.js +1 -0
- package/dist/preview/chunk.AYA7SYIU.js +1 -0
- package/dist/preview/{chunk.WPLKHIO5.js → chunk.BAMPYMUE.js} +1 -1
- package/dist/preview/{chunk.JEMQ66FT.js → chunk.BCWPV4WR.js} +1 -1
- package/dist/preview/{chunk.GAN77YDU.js → chunk.BFKV4GKP.js} +6 -6
- package/dist/preview/{chunk.B7FZLIAO.js → chunk.BNPQUI3F.js} +1 -1
- package/dist/preview/chunk.BRDAO2OF.js +4 -0
- package/dist/preview/{chunk.DGXWL4GC.js → chunk.CICGAEBW.js} +2 -2
- package/dist/preview/{chunk.LKF4BBCW.js → chunk.DEUTHHGI.js} +1 -1
- package/dist/preview/{chunk.7AEE3VHC.js → chunk.DQOCBKC3.js} +1 -1
- package/dist/preview/{chunk.KERLVJ6I.js → chunk.DX357TZ3.js} +1 -1
- package/dist/preview/{chunk.2CPC3HQI.js → chunk.EAJB2PJZ.js} +1 -1
- package/dist/preview/{chunk.NPS2WN7T.js → chunk.EPUBSKKL.js} +1 -1
- package/dist/preview/chunk.F37DHXA2.js +1 -0
- package/dist/preview/{chunk.EW364363.js → chunk.F5PBK4TF.js} +2 -2
- package/dist/preview/chunk.FGR7KCI6.js +1 -0
- package/dist/preview/chunk.FO5BOBYV.js +1 -0
- package/dist/preview/chunk.FVOJCVRX.js +1 -0
- package/dist/preview/chunk.FXTBMW3S.js +1 -0
- package/dist/preview/chunk.GEPNIMXW.js +1 -0
- package/dist/preview/chunk.GVY5UQTJ.js +1 -0
- package/dist/preview/{chunk.4EPT2CQG.js → chunk.H7KCWCB4.js} +1 -1
- package/dist/preview/{chunk.FVHECT47.js → chunk.HBD7FBZS.js} +1 -1
- package/dist/preview/{chunk.MZOIPCDA.js → chunk.HDRD33II.js} +1 -1
- package/dist/preview/chunk.HZCA3UWJ.js +1 -0
- package/dist/preview/{chunk.HP72LB3B.js → chunk.I3GP5JW7.js} +1 -1
- package/dist/preview/{chunk.LKXYZK5H.js → chunk.IJABD7SI.js} +1 -1
- package/dist/preview/{chunk.27ZVVPRZ.js → chunk.IKX4VDTW.js} +1 -1
- package/dist/preview/chunk.ITYQUSZI.js +6 -0
- package/dist/preview/chunk.IW7YFPGG.js +1 -0
- package/dist/preview/{chunk.IBWPRK2R.js → chunk.JBW3DI7E.js} +1 -1
- package/dist/preview/chunk.JF3GD4H5.js +50 -0
- package/dist/preview/{chunk.RYNCEZ6Q.js → chunk.JHIUG25Q.js} +1 -1
- package/dist/preview/{chunk.UZSZPMRC.js → chunk.JLEC3USG.js} +1 -1
- package/dist/preview/chunk.JLIUUFK2.js +1 -0
- package/dist/preview/{chunk.XPIDPZKS.js → chunk.JLYNMAME.js} +1 -1
- package/dist/preview/{chunk.EYEIDL3T.js → chunk.JNIGZEOF.js} +1 -1
- package/dist/preview/chunk.JQLR6KO2.js +1 -0
- package/dist/preview/chunk.JT3IZIU5.js +33 -0
- package/dist/preview/{chunk.NBOZPPSM.js → chunk.KRGM25HF.js} +1 -1
- package/dist/preview/{chunk.UG23RICT.js → chunk.KWQ7QOHD.js} +1 -1
- package/dist/preview/{chunk.H4GHKBMH.js → chunk.L2PI7V4R.js} +1 -1
- package/dist/preview/{chunk.ZP6PS5Z4.js → chunk.LETJC5TD.js} +1 -1
- package/dist/preview/{chunk.V4DR25S4.js → chunk.LKN734RR.js} +1 -1
- package/dist/preview/{chunk.5JPELFMA.js → chunk.LKVXSC5O.js} +1 -1
- package/dist/preview/{chunk.REEDZSCG.js → chunk.LUNATPAB.js} +2 -2
- package/dist/preview/{chunk.4WCQWILK.js → chunk.LVEFQLGQ.js} +1 -1
- package/dist/preview/{chunk.FNF6XQI5.js → chunk.M5GJHVWZ.js} +1 -1
- package/dist/preview/chunk.MWONSI3P.js +1 -0
- package/dist/preview/{chunk.56DR42FA.js → chunk.N7VNEUJR.js} +1 -1
- package/dist/preview/{chunk.FIJNKSMQ.js → chunk.NGIPVTTE.js} +1 -1
- package/dist/preview/chunk.NITU5H4J.js +1 -0
- package/dist/preview/{chunk.6NFR2LYQ.js → chunk.NIVTK2W5.js} +1 -1
- package/dist/preview/chunk.NMIXBH37.js +1 -0
- package/dist/preview/{chunk.JGYGSNQY.js → chunk.NWA7Q6CI.js} +1 -1
- package/dist/preview/{chunk.REOYQTFP.js → chunk.O24DD2VF.js} +1 -1
- package/dist/preview/{chunk.U3CV5CCL.js → chunk.OHSJQYJN.js} +1 -1
- package/dist/preview/chunk.ONEYVLC2.js +1 -0
- package/dist/preview/{chunk.CDFVEL2Y.js → chunk.P4O5DGLN.js} +1 -1
- package/dist/preview/{chunk.LULTKYE3.js → chunk.PC6PID5X.js} +1 -1
- package/dist/preview/{chunk.IIB22IIP.js → chunk.PKUDIWIF.js} +1 -1
- package/dist/preview/{chunk.YTXEPWVW.js → chunk.PLWVLW22.js} +1 -1
- package/dist/preview/{chunk.TDCO7LEA.js → chunk.Q7RQC3F7.js} +1 -1
- package/dist/preview/{chunk.ZKBSEUK4.js → chunk.QGVLJTZS.js} +1 -1
- package/dist/preview/{chunk.QNJYXB3U.js → chunk.R2AG4NHQ.js} +1 -1
- package/dist/preview/chunk.R4OU7O6C.js +1 -0
- package/dist/preview/{chunk.YGX2AE36.js → chunk.RNBPDB37.js} +1 -1
- package/dist/preview/{chunk.IN4PKQO5.js → chunk.RNEJYIQ7.js} +1 -1
- package/dist/preview/{chunk.VAUG5TGZ.js → chunk.RTI3FEDD.js} +1 -1
- package/dist/preview/{chunk.Y2MIG2C2.js → chunk.RZXPBOGT.js} +1 -1
- package/dist/preview/chunk.S5MQVPLF.js +1 -0
- package/dist/preview/{chunk.MFLJIFZD.js → chunk.S6WHA4CW.js} +1 -1
- package/dist/preview/{chunk.YTZDCIX2.js → chunk.SL2FZ54V.js} +1 -1
- package/dist/preview/{chunk.3L7OEBJH.js → chunk.SS27NH5O.js} +1 -1
- package/dist/preview/chunk.T7O6K3IN.js +1 -0
- package/dist/preview/{chunk.3IUJ4GW7.js → chunk.TBQOSI4J.js} +1 -1
- package/dist/preview/{chunk.FBIK4LTM.js → chunk.TFVFJFXC.js} +2 -2
- package/dist/preview/{chunk.2O2THM2R.js → chunk.TOZJZXWQ.js} +1 -1
- package/dist/preview/{chunk.PL2P2OON.js → chunk.UHX4WTM7.js} +1 -1
- package/dist/preview/{chunk.OGF6UORU.js → chunk.UKAPFIPJ.js} +1 -1
- package/dist/preview/{chunk.64QDUERE.js → chunk.UNCS63AM.js} +1 -1
- package/dist/preview/chunk.UOXFALRL.js +1 -0
- package/dist/preview/chunk.UPQZU7UO.js +21 -0
- package/dist/preview/chunk.UR3XYOQ6.js +104 -0
- package/dist/preview/chunk.URO2EGY7.js +1 -0
- package/dist/preview/{chunk.TJO5Y2OJ.js → chunk.UVNVDLV5.js} +1 -1
- package/dist/preview/chunk.V3QUTJR2.js +2 -0
- package/dist/preview/{chunk.RDGFZPKN.js → chunk.V5Z2OED6.js} +1 -1
- package/dist/preview/{chunk.EJAWDI2V.js → chunk.VAFSSSSI.js} +1 -1
- package/dist/preview/{chunk.5WEEZ7WD.js → chunk.VBPK6ARF.js} +1 -1
- package/dist/preview/{chunk.DAZEFSWI.js → chunk.VC3BX2ZF.js} +1 -1
- package/dist/preview/{chunk.IQWKEGWG.js → chunk.VDVJCLGS.js} +1 -1
- package/dist/preview/{chunk.MWUP5X47.js → chunk.VW2VCPJX.js} +1 -1
- package/dist/preview/{chunk.O4VSQ2ER.js → chunk.W45NKVSV.js} +1 -1
- package/dist/preview/{chunk.3TBH2FMZ.js → chunk.WAB7UDHU.js} +1 -1
- package/dist/preview/{chunk.OK4FSBHI.js → chunk.WBHM5I3I.js} +1 -1
- package/dist/preview/chunk.WM2LWHTJ.js +1 -0
- package/dist/preview/chunk.WO3DDFFY.js +1 -0
- package/dist/preview/{chunk.JLOSQ5UY.js → chunk.WP5W44Y4.js} +2 -2
- package/dist/preview/chunk.WQONZBA3.js +5 -0
- package/dist/preview/{chunk.T6S3CEW7.js → chunk.WSTBCWW7.js} +2 -2
- package/dist/preview/chunk.X233NILF.js +1 -0
- package/dist/preview/{chunk.FUYMLDNJ.js → chunk.X25KXCWI.js} +1 -1
- package/dist/preview/{chunk.FNXW46U4.js → chunk.XSNAG4JT.js} +82 -72
- package/dist/preview/chunk.XWAMQPUM.js +25 -0
- package/dist/preview/chunk.XXDBZQNY.js +18 -0
- package/dist/preview/{chunk.IQ3LUSD6.js → chunk.XXEYRHRG.js} +1 -1
- package/dist/preview/{chunk.7UV7ODXU.js → chunk.Y5ARSVH4.js} +1 -1
- package/dist/preview/{chunk.TTSNHX3F.js → chunk.Z5IGHCZX.js} +1 -1
- package/dist/preview/{chunk.B2CIQ66N.js → chunk.Z6TMIAAB.js} +1 -1
- package/dist/preview/chunk.ZIEHF67C.js +1 -0
- package/dist/preview/chunk.ZTIF23VF.js +1 -0
- package/dist/preview/index.html +49 -45
- package/dist/preview/page.js +2 -34
- package/package.json +6 -6
- package/dist/preview/chunk.2EXY4AHX.js +0 -117
- package/dist/preview/chunk.3JATXDSP.js +0 -1
- package/dist/preview/chunk.3OKJ4GOA.js +0 -1
- package/dist/preview/chunk.3PNDXNX6.js +0 -1
- package/dist/preview/chunk.4B4DKCS4.js +0 -1
- package/dist/preview/chunk.4JWT6LIS.js +0 -25
- package/dist/preview/chunk.6VIZGLDK.js +0 -1
- package/dist/preview/chunk.7HL7CFXJ.js +0 -1
- package/dist/preview/chunk.7JVBVB4A.js +0 -1
- package/dist/preview/chunk.CSQNDAEK.js +0 -1
- package/dist/preview/chunk.EJOTTZWZ.js +0 -1
- package/dist/preview/chunk.ESU2DD3J.js +0 -1
- package/dist/preview/chunk.EZRGGPAN.js +0 -1
- package/dist/preview/chunk.GAFYE37S.js +0 -3
- package/dist/preview/chunk.GBCWI2LF.js +0 -2
- package/dist/preview/chunk.HB34VQKQ.js +0 -1
- package/dist/preview/chunk.HKA27VJO.js +0 -1
- package/dist/preview/chunk.IPHWGBZE.js +0 -6
- package/dist/preview/chunk.JQ7WY2VZ.js +0 -1
- package/dist/preview/chunk.JUT2VCFW.js +0 -1
- package/dist/preview/chunk.L6FWIQXS.js +0 -1
- package/dist/preview/chunk.LUPBT6YM.js +0 -1
- package/dist/preview/chunk.LYSHLKAX.js +0 -1
- package/dist/preview/chunk.LYUPJ4VV.js +0 -1
- package/dist/preview/chunk.MOF2D6DV.js +0 -1
- package/dist/preview/chunk.NTFCZYOR.js +0 -1
- package/dist/preview/chunk.OAWAUB4P.js +0 -49
- package/dist/preview/chunk.OG6GNGTX.js +0 -21
- package/dist/preview/chunk.PSTE3LZL.js +0 -5
- package/dist/preview/chunk.PX6VAZFJ.js +0 -1
- package/dist/preview/chunk.RLMW7DU6.js +0 -1
- package/dist/preview/chunk.URCC626R.js +0 -1
- package/dist/preview/chunk.WE5SA6TP.js +0 -1
- package/dist/preview/chunk.WNYPP52L.js +0 -1
- package/dist/preview/chunk.YE4GZVOX.js +0 -1
- package/dist/preview/chunk.YWVOACSX.js +0 -5
- package/dist/preview/chunk.YYPK7IDM.js +0 -1
- package/dist/preview/chunk.ZZ5F5I3O.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{$ as Z,Ca as Q,Db as I,F,G as Y,I as L,Ka as X,Kb as en,O,R as j,S as B,T as U,U as K,Va as v,Xa as nn,_ as J,ka as P}from"./chunk.AW2T3KFV.js";var un=1e4,p=class{constructor(a){this.nodes=a}},rn=Symbol.for("@graview/core:far-record"),fn=e=>typeof e=="object"&&e!==null&&e[rn]===!0;function cn(e){let a={...e.fields,id:`@${e.address}/${e.kind}:${e.id}`,kind:`@${e.address}/${e.kind}`,label:e.label};return Object.defineProperty(a,rn,{value:!0}),a}function Nn(e){let a=`the linked record in ${e.ref.address}`;return e.reason==="denied"?`${a} is not one this viewer may open`:`${a} has not been read`}var pn="",f=class extends Error{constructor(g,l){super(g);this.sentence=g;this.at=l}},z=class extends f{},V=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof p)&&typeof e.id=="string",tn=e=>{let a=new Set;return new p(e.filter(g=>!a.has(g.id)&&a.add(g.id)))},w=e=>e===null?"nothing":e instanceof p?"a set of records":Array.isArray(e)?"a list":V(e)?"a record":typeof e=="string"?"a word":typeof e;function on(e,a){let g=a.budget??un,l=(n,s)=>{if(g-=n,g<0)throw new z("this rule looks at too much of the graph to judge in one go",s)},u=a.today??L(),b=a.now??new Date().toISOString(),k=new Map,S=new Set,A=a.bindings,q=(n,s,t,o)=>{let d=`${n?.id}\0${s}`;if(k.has(d))return k.get(d);if(S.has(d))throw new f(`"${s}"${n?` of ${P(n.kind)}`:""} depends on itself`,o);S.add(d);let r=A;A=void 0;try{let i=$(t,n);return k.set(d,i),i}finally{A=r,S.delete(d)}},E=(n,s,t)=>{l(1,t);let o=a.kinds.get(n.kind),d=o?.computed?.get(s);if(d)return q(n,s,d,t);let r=o?.linked?.get(s);if(r){let y=Q(Object.hasOwn(n,s)?n[s]:void 0,r);l(y.length,t);let m=a.linked??X(a.graph),h=y.flatMap(x=>{let C=m?m(x):{unread:!0};return"record"in C?[cn(C.record)]:(a.onUnread?.({relation:s,ref:x,reason:"denied"in C?"denied":"unread"}),[])});return r.cardinality==="one"?h[0]??null:new p(h)}let i=Object.hasOwn(n,s);if(o?.fields.has(s)||i){let y=i?v(n,s,u):void 0;return y===void 0?null:y}let c=o?.edges.get(s);if(c){let y=a.graph.out(n.id,s);return l(y.length,t),c==="one"?y[0]??null:new p(y)}if(s==="id")return n.id;if(fn(n))return null;throw new f(`${P(n.kind)} has no field or relation called "${s}"`,t)},N=(n,s,t)=>{if(n instanceof p)return n;if(n===null)return new p([]);if(V(n))return new p([n]);throw new f(`${t}(\u2026) needs a set of records, and was given ${w(n)}`,s)},G=(n,s,t)=>{if(n===null)return null;if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);throw new f(`${t}(\u2026) needs a word, and was given ${w(n)}`,s)},_=(n,s,t)=>{let o=G(n,s,t);if(o===null)return null;let d=Date.parse(o.length===10?`${o}T00:00:00Z`:o);if(Number.isNaN(d))throw new f(`${t}(\u2026) needs a date, and "${o}" is not one`,s);return d},M=(n,s)=>V(n)&&V(s)?n.id===s.id:V(n)&&typeof s=="string"?n.id===s:typeof n=="string"&&V(s)?n===s.id:Array.isArray(n)&&Array.isArray(s)?n.length===s.length&&n.every((t,o)=>M(t,s[o])):n===s,R=(n,s,t)=>{if(n===null)return!1;if(typeof n=="boolean")return n;throw new f(`${t} must be true or false, and was ${w(n)}`,s)},T=(n,s)=>$(s,n);function $(n,s){switch(l(1,n.at),n.t){case"lit":return n.value;case"list":return n.items.map(t=>$(t,s));case"ident":{let t=A&&Object.hasOwn(A,n.name)?A[n.name]:void 0;if(t!==void 0)return t;if(s)return E(s,n.name,n.at);throw new f(`"${n.name}" means nothing in a rule over the whole graph`,n.at)}case"member":{let t=$(n.object,s);if(t===null)return null;if(V(t))return E(t,n.name,n.at);throw new f(`".${n.name}" needs a record before it, and was given ${w(t)}`,n.at)}case"unary":{let t=$(n.operand,s);if(n.op==="!")return!R(t,n.at,"what follows not");if(t===null)return null;if(typeof t!="number")throw new f(`"-" needs a number, and was given ${w(t)}`,n.at);return-t}case"where":{let t=N($(n.set,s),n.at,"where");return l(t.nodes.length,n.at),new p(t.nodes.filter(o=>R(T(o,n.filter),n.at,"a where condition")))}case"binary":return dn(n,s);case"call":return ln(n,s)}}function dn(n,s){if(n.op==="&&")return R($(n.left,s),n.at,"each side of and")&&R($(n.right,s),n.at,"each side of and");if(n.op==="||")return R($(n.left,s),n.at,"each side of or")||R($(n.right,s),n.at,"each side of or");let t=$(n.left,s),o=$(n.right,s);if(n.op==="&"||n.op==="|"||n.op==="-"&&(t instanceof p||o instanceof p)){let d=N(t,n.at,n.op).nodes,r=N(o,n.at,n.op).nodes;l(d.length+r.length,n.at);let i=new Set(r.map(c=>c.id));return tn(n.op==="|"?[...d,...r]:d.filter(c=>i.has(c.id)===(n.op==="&")))}switch(n.op){case"==":return M(t,o);case"!=":return!M(t,o);case"in":{if(o===null)return!1;if(o instanceof p)return o.nodes.some(d=>M(t,d));if(Array.isArray(o))return o.some(d=>M(t,d));if(typeof o=="string"&&typeof t=="string")return o.includes(t);throw new f(`"in" needs a list or a set on its right, and was given ${w(o)}`,n.at)}case"<":case"<=":case">":case">=":{if(t===null||o===null)return!1;if(!(typeof t=="number"&&typeof o=="number"||typeof t=="string"&&typeof o=="string"))throw new f(`cannot compare ${w(t)} with ${w(o)}`,n.at);return n.op==="<"?t<o:n.op==="<="?t<=o:n.op===">"?t>o:t>=o}default:{if(t===null||o===null)return null;if(n.op==="+"&&(typeof t=="string"||typeof o=="string")){let d=`${G(t,n.at,"+")}${G(o,n.at,"+")}`;if(d.length>1e4)throw new f("that makes a word too long",n.at);return d}if(typeof t!="number"||typeof o!="number")throw new f(`"${n.op}" needs numbers, and was given ${w(t)} and ${w(o)}`,n.at);return(n.op==="/"||n.op==="%")&&o===0?null:n.op==="+"?t+o:n.op==="-"?t-o:n.op==="*"?t*o:n.op==="/"?t/o:t%o}}}function ln(n,s){let t=(r,i=r)=>{if(n.args.length<r||n.args.length>i)throw new f(`${n.fn}(\u2026) takes ${r===i?r:`${r} to ${i}`} argument${i===1?"":"s"}`,n.at)},o=r=>$(n.args[r],s),d=r=>{let i=o(r);if(typeof i!="string")throw new f(`${n.fn}(\u2026) needs a quoted name, like ${n.fn}('name')`,n.at);return i};switch(n.fn){case"out":case"in":{t(1,2);let r=(y,m)=>n.fn==="out"?a.graph.out(y,m):a.graph.in(y,m);if(n.args.length===2){let y=N(o(0),n.at,n.fn).nodes,m=d(1);return tn(y.flatMap(h=>{let x=r(h.id,m);return l(x.length+1,n.at),x}))}let i=d(0);if(!s)throw new f(`${n.fn}('${i}') needs a record to start from`,n.at);let c=r(s.id,i);return l(c.length,n.at),new p(c)}case"all":{t(1,2);let r=a.graph.nodesOfKind(d(0),{archived:n.args.length===2?o(1):!1});return l(r.length,n.at),new p(r)}case"archived":return t(0,1),nn(n.args.length===1?o(0):s);case"count":return t(1),N(o(0),n.at,"count").nodes.length;case"exists":return t(1),N(o(0),n.at,"exists").nodes.length>0;case"every":case"some":{t(2);let r=N(o(0),n.at,n.fn);l(r.nodes.length,n.at);let i=c=>R(T(c,n.args[1]),n.at,`the condition in ${n.fn}(\u2026)`);return n.fn==="every"?r.nodes.every(i):r.nodes.some(i)}case"sum":case"min":case"max":{t(2);let r=N(o(0),n.at,n.fn);l(r.nodes.length,n.at);let i=n.args[1],c=i.t==="lit"&&typeof i.value=="string"?i.value:void 0,y=i.t==="ident"?`'${i.name}'`:c!==void 0?`'${c}'`:"\u2026",m=r.nodes.map(h=>i.t==="ident"?E(h,i.name,n.at):c!==void 0?E(h,c,n.at):T(h,i)).filter(h=>{if(h===null)return!1;if(typeof h!="number")throw new f(`${n.fn}(\u2026, ${y}) needs a number for each member, and found ${w(h)}`,n.at);return!0});return n.fn==="sum"?m.reduce((h,x)=>h+x,0):m.length===0?null:n.fn==="min"?Math.min(...m):Math.max(...m)}case"fact":{t(1);let r=d(0),i=a.kinds.get(pn)?.computed?.get(r);if(!i)throw new f(`no fact is called "${r}"`,n.at);return q(null,r,i,n.at)}case"first":return t(1),N(o(0),n.at,"first").nodes[0]??null;case"sort":{t(2,3);let r=N(o(0),n.at,"sort"),i=n.args.length===3?o(2):"asc";if(i!=="asc"&&i!=="desc")throw new f("sort(\u2026) goes 'asc' or 'desc'",n.at);let c=r.nodes.length;l(c+c*Math.ceil(Math.log2(c+1)),n.at);let y=r.nodes.map((h,x)=>({node:h,i:x,key:T(h,n.args[1])})),m=i==="desc"?-1:1;return y.sort((h,x)=>H(h.key,x.key,m,n.at)||h.i-x.i),new p(y.map(h=>h.node))}case"either":{if(n.args.length<1)throw new f("either(\u2026) takes at least one argument",n.at);for(let r=0;r<n.args.length;r++){let i=o(r);if(i!==null&&!(i instanceof p&&i.nodes.length===0))return i}return null}case"present":{t(1);let r=o(0);return r===null||r===""?!1:Array.isArray(r)?r.length>0:r instanceof p?r.nodes.length>0:!0}case"len":{t(1);let r=o(0);if(r===null)return 0;if(typeof r=="string"||Array.isArray(r))return r.length;if(r instanceof p)return r.nodes.length;throw new f(`len(\u2026) needs a word or a list, and was given ${w(r)}`,n.at)}case"contains":case"startsWith":{t(2);let r=o(0),i=o(1);if(r===null||i===null)return!1;if(n.fn==="contains"&&Array.isArray(r))return r.some(m=>M(m,i));let c=G(r,n.at,n.fn),y=G(i,n.at,n.fn);return n.fn==="contains"?c.toLowerCase().includes(y.toLowerCase()):c.startsWith(y)}case"lower":{t(1);let r=G(o(0),n.at,"lower");return r===null?null:r.toLowerCase()}case"today":return t(0),u;case"now":return t(0),b;case"date":{t(1);let r=_(o(0),n.at,"date");return r===null?null:new Date(r).toISOString().slice(0,10)}case"days":case"hours":{t(2);let r=_(o(0),n.at,n.fn),i=_(o(1),n.at,n.fn);if(r===null||i===null)return null;let c=(i-r)/(n.fn==="days"?864e5:36e5);return n.fn==="days"?Math.round(c):c}case"if":return t(3),R(o(0),n.at,"the condition in if(\u2026)")?o(1):o(2);default:throw new f(`"${n.fn}" is not a function the rule language knows`,n.at)}}function H(n,s,t,o){if(n===null||s===null)return n===s?0:n===null?1:-1;if(Array.isArray(n)&&Array.isArray(s)){for(let r=0;r<Math.max(n.length,s.length);r++){let i=H(n[r]??null,s[r]??null,t,o);if(i!==0)return i}return 0}let d=r=>typeof r=="number"||typeof r=="string"||typeof r=="boolean"?typeof r:w(r);if(d(n)!==d(s)||typeof n=="object"||typeof s=="object")throw new f(`sort(\u2026) cannot put ${w(n)} and ${w(s)} in order`,o);return typeof n=="string"?t*(n<s?-1:n>s?1:0):t*(Number(n)-Number(s))}return $(e,a.subject)}var Sn=["out","in","all","count","exists","every","some","sum","min","max","present","len","contains","startsWith","lower","today","now","date","days","hours","if","first","sort","either","fact","archived"];var Vn=(e,a,g,l)=>({severity:"error",code:e,path:a,message:g,...l?{fix:l}:{}}),Gn=(e,a,g,l)=>({severity:"warning",code:e,path:a,message:g,...l?{fix:l}:{}}),Mn=e=>e.some(a=>a.severity==="error");function On(e){return e.map(a=>`${a.severity==="error"?"\u2717":a.severity==="warning"?"!":"\xB7"} ${a.path||"(document)"}: ${a.message}${a.fix?` \u2014 ${a.fix}`:""}`).join(`
|
|
1
|
+
import{$ as Z,Ca as Q,Db as I,F,G as Y,I as L,Ka as X,Kb as en,O,R as j,S as B,T as U,U as K,Va as v,Xa as nn,_ as J,ka as P}from"./chunk.AS4CQBOQ.js";var un=1e4,p=class{constructor(a){this.nodes=a}},rn=Symbol.for("@graview/core:far-record"),fn=e=>typeof e=="object"&&e!==null&&e[rn]===!0;function cn(e){let a={...e.fields,id:`@${e.address}/${e.kind}:${e.id}`,kind:`@${e.address}/${e.kind}`,label:e.label};return Object.defineProperty(a,rn,{value:!0}),a}function Nn(e){let a=`the linked record in ${e.ref.address}`;return e.reason==="denied"?`${a} is not one this viewer may open`:`${a} has not been read`}var pn="",f=class extends Error{constructor(g,l){super(g);this.sentence=g;this.at=l}},z=class extends f{},V=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof p)&&typeof e.id=="string",tn=e=>{let a=new Set;return new p(e.filter(g=>!a.has(g.id)&&a.add(g.id)))},w=e=>e===null?"nothing":e instanceof p?"a set of records":Array.isArray(e)?"a list":V(e)?"a record":typeof e=="string"?"a word":typeof e;function on(e,a){let g=a.budget??un,l=(n,s)=>{if(g-=n,g<0)throw new z("this rule looks at too much of the graph to judge in one go",s)},u=a.today??L(),b=a.now??new Date().toISOString(),k=new Map,S=new Set,A=a.bindings,q=(n,s,t,o)=>{let d=`${n?.id}\0${s}`;if(k.has(d))return k.get(d);if(S.has(d))throw new f(`"${s}"${n?` of ${P(n.kind)}`:""} depends on itself`,o);S.add(d);let r=A;A=void 0;try{let i=$(t,n);return k.set(d,i),i}finally{A=r,S.delete(d)}},E=(n,s,t)=>{l(1,t);let o=a.kinds.get(n.kind),d=o?.computed?.get(s);if(d)return q(n,s,d,t);let r=o?.linked?.get(s);if(r){let y=Q(Object.hasOwn(n,s)?n[s]:void 0,r);l(y.length,t);let m=a.linked??X(a.graph),h=y.flatMap(x=>{let C=m?m(x):{unread:!0};return"record"in C?[cn(C.record)]:(a.onUnread?.({relation:s,ref:x,reason:"denied"in C?"denied":"unread"}),[])});return r.cardinality==="one"?h[0]??null:new p(h)}let i=Object.hasOwn(n,s);if(o?.fields.has(s)||i){let y=i?v(n,s,u):void 0;return y===void 0?null:y}let c=o?.edges.get(s);if(c){let y=a.graph.out(n.id,s);return l(y.length,t),c==="one"?y[0]??null:new p(y)}if(s==="id")return n.id;if(fn(n))return null;throw new f(`${P(n.kind)} has no field or relation called "${s}"`,t)},N=(n,s,t)=>{if(n instanceof p)return n;if(n===null)return new p([]);if(V(n))return new p([n]);throw new f(`${t}(\u2026) needs a set of records, and was given ${w(n)}`,s)},G=(n,s,t)=>{if(n===null)return null;if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);throw new f(`${t}(\u2026) needs a word, and was given ${w(n)}`,s)},_=(n,s,t)=>{let o=G(n,s,t);if(o===null)return null;let d=Date.parse(o.length===10?`${o}T00:00:00Z`:o);if(Number.isNaN(d))throw new f(`${t}(\u2026) needs a date, and "${o}" is not one`,s);return d},M=(n,s)=>V(n)&&V(s)?n.id===s.id:V(n)&&typeof s=="string"?n.id===s:typeof n=="string"&&V(s)?n===s.id:Array.isArray(n)&&Array.isArray(s)?n.length===s.length&&n.every((t,o)=>M(t,s[o])):n===s,R=(n,s,t)=>{if(n===null)return!1;if(typeof n=="boolean")return n;throw new f(`${t} must be true or false, and was ${w(n)}`,s)},T=(n,s)=>$(s,n);function $(n,s){switch(l(1,n.at),n.t){case"lit":return n.value;case"list":return n.items.map(t=>$(t,s));case"ident":{let t=A&&Object.hasOwn(A,n.name)?A[n.name]:void 0;if(t!==void 0)return t;if(s)return E(s,n.name,n.at);throw new f(`"${n.name}" means nothing in a rule over the whole graph`,n.at)}case"member":{let t=$(n.object,s);if(t===null)return null;if(V(t))return E(t,n.name,n.at);throw new f(`".${n.name}" needs a record before it, and was given ${w(t)}`,n.at)}case"unary":{let t=$(n.operand,s);if(n.op==="!")return!R(t,n.at,"what follows not");if(t===null)return null;if(typeof t!="number")throw new f(`"-" needs a number, and was given ${w(t)}`,n.at);return-t}case"where":{let t=N($(n.set,s),n.at,"where");return l(t.nodes.length,n.at),new p(t.nodes.filter(o=>R(T(o,n.filter),n.at,"a where condition")))}case"binary":return dn(n,s);case"call":return ln(n,s)}}function dn(n,s){if(n.op==="&&")return R($(n.left,s),n.at,"each side of and")&&R($(n.right,s),n.at,"each side of and");if(n.op==="||")return R($(n.left,s),n.at,"each side of or")||R($(n.right,s),n.at,"each side of or");let t=$(n.left,s),o=$(n.right,s);if(n.op==="&"||n.op==="|"||n.op==="-"&&(t instanceof p||o instanceof p)){let d=N(t,n.at,n.op).nodes,r=N(o,n.at,n.op).nodes;l(d.length+r.length,n.at);let i=new Set(r.map(c=>c.id));return tn(n.op==="|"?[...d,...r]:d.filter(c=>i.has(c.id)===(n.op==="&")))}switch(n.op){case"==":return M(t,o);case"!=":return!M(t,o);case"in":{if(o===null)return!1;if(o instanceof p)return o.nodes.some(d=>M(t,d));if(Array.isArray(o))return o.some(d=>M(t,d));if(typeof o=="string"&&typeof t=="string")return o.includes(t);throw new f(`"in" needs a list or a set on its right, and was given ${w(o)}`,n.at)}case"<":case"<=":case">":case">=":{if(t===null||o===null)return!1;if(!(typeof t=="number"&&typeof o=="number"||typeof t=="string"&&typeof o=="string"))throw new f(`cannot compare ${w(t)} with ${w(o)}`,n.at);return n.op==="<"?t<o:n.op==="<="?t<=o:n.op===">"?t>o:t>=o}default:{if(t===null||o===null)return null;if(n.op==="+"&&(typeof t=="string"||typeof o=="string")){let d=`${G(t,n.at,"+")}${G(o,n.at,"+")}`;if(d.length>1e4)throw new f("that makes a word too long",n.at);return d}if(typeof t!="number"||typeof o!="number")throw new f(`"${n.op}" needs numbers, and was given ${w(t)} and ${w(o)}`,n.at);return(n.op==="/"||n.op==="%")&&o===0?null:n.op==="+"?t+o:n.op==="-"?t-o:n.op==="*"?t*o:n.op==="/"?t/o:t%o}}}function ln(n,s){let t=(r,i=r)=>{if(n.args.length<r||n.args.length>i)throw new f(`${n.fn}(\u2026) takes ${r===i?r:`${r} to ${i}`} argument${i===1?"":"s"}`,n.at)},o=r=>$(n.args[r],s),d=r=>{let i=o(r);if(typeof i!="string")throw new f(`${n.fn}(\u2026) needs a quoted name, like ${n.fn}('name')`,n.at);return i};switch(n.fn){case"out":case"in":{t(1,2);let r=(y,m)=>n.fn==="out"?a.graph.out(y,m):a.graph.in(y,m);if(n.args.length===2){let y=N(o(0),n.at,n.fn).nodes,m=d(1);return tn(y.flatMap(h=>{let x=r(h.id,m);return l(x.length+1,n.at),x}))}let i=d(0);if(!s)throw new f(`${n.fn}('${i}') needs a record to start from`,n.at);let c=r(s.id,i);return l(c.length,n.at),new p(c)}case"all":{t(1,2);let r=a.graph.nodesOfKind(d(0),{archived:n.args.length===2?o(1):!1});return l(r.length,n.at),new p(r)}case"archived":return t(0,1),nn(n.args.length===1?o(0):s);case"count":return t(1),N(o(0),n.at,"count").nodes.length;case"exists":return t(1),N(o(0),n.at,"exists").nodes.length>0;case"every":case"some":{t(2);let r=N(o(0),n.at,n.fn);l(r.nodes.length,n.at);let i=c=>R(T(c,n.args[1]),n.at,`the condition in ${n.fn}(\u2026)`);return n.fn==="every"?r.nodes.every(i):r.nodes.some(i)}case"sum":case"min":case"max":{t(2);let r=N(o(0),n.at,n.fn);l(r.nodes.length,n.at);let i=n.args[1],c=i.t==="lit"&&typeof i.value=="string"?i.value:void 0,y=i.t==="ident"?`'${i.name}'`:c!==void 0?`'${c}'`:"\u2026",m=r.nodes.map(h=>i.t==="ident"?E(h,i.name,n.at):c!==void 0?E(h,c,n.at):T(h,i)).filter(h=>{if(h===null)return!1;if(typeof h!="number")throw new f(`${n.fn}(\u2026, ${y}) needs a number for each member, and found ${w(h)}`,n.at);return!0});return n.fn==="sum"?m.reduce((h,x)=>h+x,0):m.length===0?null:n.fn==="min"?Math.min(...m):Math.max(...m)}case"fact":{t(1);let r=d(0),i=a.kinds.get(pn)?.computed?.get(r);if(!i)throw new f(`no fact is called "${r}"`,n.at);return q(null,r,i,n.at)}case"first":return t(1),N(o(0),n.at,"first").nodes[0]??null;case"sort":{t(2,3);let r=N(o(0),n.at,"sort"),i=n.args.length===3?o(2):"asc";if(i!=="asc"&&i!=="desc")throw new f("sort(\u2026) goes 'asc' or 'desc'",n.at);let c=r.nodes.length;l(c+c*Math.ceil(Math.log2(c+1)),n.at);let y=r.nodes.map((h,x)=>({node:h,i:x,key:T(h,n.args[1])})),m=i==="desc"?-1:1;return y.sort((h,x)=>H(h.key,x.key,m,n.at)||h.i-x.i),new p(y.map(h=>h.node))}case"either":{if(n.args.length<1)throw new f("either(\u2026) takes at least one argument",n.at);for(let r=0;r<n.args.length;r++){let i=o(r);if(i!==null&&!(i instanceof p&&i.nodes.length===0))return i}return null}case"present":{t(1);let r=o(0);return r===null||r===""?!1:Array.isArray(r)?r.length>0:r instanceof p?r.nodes.length>0:!0}case"len":{t(1);let r=o(0);if(r===null)return 0;if(typeof r=="string"||Array.isArray(r))return r.length;if(r instanceof p)return r.nodes.length;throw new f(`len(\u2026) needs a word or a list, and was given ${w(r)}`,n.at)}case"contains":case"startsWith":{t(2);let r=o(0),i=o(1);if(r===null||i===null)return!1;if(n.fn==="contains"&&Array.isArray(r))return r.some(m=>M(m,i));let c=G(r,n.at,n.fn),y=G(i,n.at,n.fn);return n.fn==="contains"?c.toLowerCase().includes(y.toLowerCase()):c.startsWith(y)}case"lower":{t(1);let r=G(o(0),n.at,"lower");return r===null?null:r.toLowerCase()}case"today":return t(0),u;case"now":return t(0),b;case"date":{t(1);let r=_(o(0),n.at,"date");return r===null?null:new Date(r).toISOString().slice(0,10)}case"days":case"hours":{t(2);let r=_(o(0),n.at,n.fn),i=_(o(1),n.at,n.fn);if(r===null||i===null)return null;let c=(i-r)/(n.fn==="days"?864e5:36e5);return n.fn==="days"?Math.round(c):c}case"if":return t(3),R(o(0),n.at,"the condition in if(\u2026)")?o(1):o(2);default:throw new f(`"${n.fn}" is not a function the rule language knows`,n.at)}}function H(n,s,t,o){if(n===null||s===null)return n===s?0:n===null?1:-1;if(Array.isArray(n)&&Array.isArray(s)){for(let r=0;r<Math.max(n.length,s.length);r++){let i=H(n[r]??null,s[r]??null,t,o);if(i!==0)return i}return 0}let d=r=>typeof r=="number"||typeof r=="string"||typeof r=="boolean"?typeof r:w(r);if(d(n)!==d(s)||typeof n=="object"||typeof s=="object")throw new f(`sort(\u2026) cannot put ${w(n)} and ${w(s)} in order`,o);return typeof n=="string"?t*(n<s?-1:n>s?1:0):t*(Number(n)-Number(s))}return $(e,a.subject)}var Sn=["out","in","all","count","exists","every","some","sum","min","max","present","len","contains","startsWith","lower","today","now","date","days","hours","if","first","sort","either","fact","archived"];var Vn=(e,a,g,l)=>({severity:"error",code:e,path:a,message:g,...l?{fix:l}:{}}),Gn=(e,a,g,l)=>({severity:"warning",code:e,path:a,message:g,...l?{fix:l}:{}}),Mn=e=>e.some(a=>a.severity==="error");function On(e){return e.map(a=>`${a.severity==="error"?"\u2717":a.severity==="warning"?"!":"\xB7"} ${a.path||"(document)"}: ${a.message}${a.fix?` \u2014 ${a.fix}`:""}`).join(`
|
|
2
2
|
`)}var Cn=["money","percent","date","time","datetime","relative","upper","lower","count","words","and","plural","excerpt"],gn={getNode:()=>{},allNodes:()=>[],allEdges:()=>[],nodesOfKind:()=>[],edgesOfKind:()=>[],out:()=>[],in:()=>[],neighbors:()=>[],has:()=>!1};function jn(e,a,g,l=[],u,b=D){return W(e,a,g,l,u,b)}var yn=(e,a)=>e.capital?J(a):a;function hn(e){return e?a=>{let g=e.tryDefinition(a.kind)?.label;return g?g(a):D(a)}:D}var sn=["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],an=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];function mn(e,a){return!Number.isInteger(e)||e<0||e>99?K(e,a):e<20?sn[e]:e%10===0?an[e/10]:`${an[Math.floor(e/10)]}-${sn[e%10]}`}function wn(e){return/[^aeiou]y$/i.test(e)?`${e.slice(0,-1)}ies`:/(s|x|z|ch|sh)$/i.test(e)?`${e}es`:`${e}s`}var D=e=>String(e.name??e.title??e.label??e.id);function W(e,a,g,l=[],u,b=D){if(a==="plural"){let k=e instanceof p?e.nodes.length:Array.isArray(e)?e.length:typeof e=="number"?e:null;return k===null||l[0]===void 0?"\u2014":k===1?l[0]:l[1]??wn(l[0])}if(e===null)return"\u2014";if(e instanceof p)return a==="count"?String(e.nodes.length):a==="and"?Z(e.nodes.map(b)):e.nodes.map(b).join(", ");if(Array.isArray(e)){if(a==="count")return String(e.length);let k=e.map(S=>W(S,void 0,g,[],u,b));return a==="and"?Z(k):k.join(", ")}if(typeof e=="object")return b(e);switch(a){case"words":return typeof e=="number"?mn(e,u?.locale):String(e);case"money":return typeof e=="number"?I(e,u):String(e);case"percent":return typeof e=="number"?K(e,u?.locale,{style:"percent",maximumFractionDigits:0}):String(e);case"upper":return String(e).toUpperCase();case"lower":return String(e).toLowerCase();case"excerpt":return en(String(e),Number(l[0])||void 0);case"date":return O(U(String(e),u?.timeZone)??String(e).slice(0,10),u?.locale);case"time":return typeof e=="string"&&F.test(e)?O(e,u?.locale):B(String(e),u?.locale,u?.timeZone);case"datetime":return typeof e=="string"&&F.test(e)?O(e,u?.locale):j(String(e),u?.locale,u?.timeZone);case"relative":{let k=U(String(e),u?.timeZone),S=k===void 0?Date.parse(String(e)):Date.parse(`${k}T00:00:00Z`);if(Number.isNaN(S))return String(e);let A=Math.round((S-Date.parse(`${g}T00:00:00Z`))/864e5);return A===0?"today":A===1?"tomorrow":A===-1?"yesterday":A>0?`in ${A} days`:`${-A} days ago`}default:return typeof e=="string"&&F.test(e)?O(e,u?.locale):typeof e=="string"&&Y.test(e)?j(e,u?.locale,u?.timeZone):String(e)}}function Un(e,a){let g=a.today??L(),l=a.name??hn(a.graph?.schema);return e.map(u=>{if(u.text!==void 0)return u.text;try{let b=on(u.expr,{graph:a.graph??gn,subject:a.node,kinds:a.kinds,today:g,budget:a.budget??500,...a.bindings?{bindings:a.bindings}:{}});return yn(u,W(b,u.format,g,u.formatArgs,a.money,l))}catch(b){if(b instanceof f)return"\u2014";throw b}}).join("")}export{p as a,Nn as b,pn as c,f as d,z as e,on as f,Sn as g,Vn as h,Gn as i,Mn as j,On as k,Cn as l,gn as m,jn as n,yn as o,hn as p,Un as q};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as xe}from"./chunk.HJCQ6I3S.js";import{a as je,b as Ee,c as Ie,d as Re}from"./chunk.B7FZLIAO.js";import"./chunk.TKUNRFDE.js";import{c as he}from"./chunk.N5ULWKR4.js";import"./chunk.MZOIPCDA.js";import"./chunk.KERLVJ6I.js";import"./chunk.4EPT2CQG.js";import{G as Ke,R as Pe}from"./chunk.4JWT6LIS.js";import"./chunk.SDO3U72B.js";import"./chunk.AW2T3KFV.js";import"./chunk.2AZTW66C.js";import{b as pe}from"./chunk.AJZBJBMO.js";var P=pe(Ke(),1);var E=.5,fe=1,ye=.76,Le=3,We=3,Ae=.6;function Oe(c){let{ribbons:m,plots:u,cell:i}=c,a=c.tilt??.5,g=c.labels??[],b=[...u.values()],k=new Map;if(b.length===0||i<=0)return k;let L=Math.min(...b.map(n=>n.col))-3,A=Math.min(...b.map(n=>n.row))-3,G=Math.max(...b.map(n=>n.col+n.side))+3,ce=Math.max(...b.map(n=>n.row+n.side))+3,h=Math.round((G-L)/E)+1,p=Math.round((ce-A)/E)+1,N=n=>L+n*E,B=n=>A+n*E,I=4,_=!0,C=(n,e)=>{if(!_)return!1;let t=he(n,e,i,a);return g.some(s=>t.x>s.x-I&&t.x<s.x+s.width+I&&t.y>s.y-I&&t.y<s.y+s.height+I)},H=(n,e)=>b.some(t=>n>t.col-ye&&n<t.col+t.side+ye&&e>t.row-ye&&e<t.row+t.side+ye),F=new Uint8Array(h*p),J=new Uint8Array(h*p);for(let n=0;n<h;n++)for(let e=0;e<p;e++){let t=N(n),s=B(e);J[e*h+n]=H(t,s)?0:1,F[e*h+n]=J[e*h+n]&&!C(t,s)?1:0}let Q=F,se=new Float32Array(h*p);for(let n=0;n<h;n++)for(let e=0;e<p;e++){let t=N(n),s=B(e);se[e*h+n]=Math.min(...b.map(o=>Math.max(0,o.col-t,t-(o.col+o.side),o.row-s,s-(o.row+o.side))))}let Z=(n,e,t,s)=>{let o=N(n)+t*E/2,l=B(e)+s*E/2;return!H(o,l)&&!C(o,l)},ue=n=>{let e=[],t=(o,l)=>{let w=[],d=Math.min(1,l/3);for(let y=Math.ceil((o+d)/E-1e-9)*E;y<=o+l-d+1e-9;y+=E)w.push(y);return w},s=(o,l,w,d)=>{let y=Math.round((o-L)/E),r=Math.round((l-A)/E);y>=0&&r>=0&&y<h&&r<p&&Q[r*h+y]&&e.push({i:y,j:r,out:w,curb:d})};for(let o of t(n.row,n.side))s(n.col-fe,o,1,{col:n.col,row:o}),s(n.col+n.side+fe,o,0,{col:n.col+n.side,row:o});for(let o of t(n.col,n.side))s(o,n.row-fe,3,{col:o,row:n.row}),s(o,n.row+n.side+fe,2,{col:o,row:n.row+n.side});return e},ee=new Map,V=(n,e,t,s)=>n<t||n===t&&e<s?`${n},${e}-${t},${s}`:`${t},${s}-${n},${e}`,de=[[1,0],[-1,0],[0,1],[0,-1]],X=new Map;for(let n of m){let e=u.get(n.from),t=u.get(n.to);if(!e||!t||e===t)continue;let s=-1,o=[],l=new Map,w=new Int32Array(0),d=1/0,y=[];for(let f of[!0,!1]){s=-1,d=1/0,_=f,Q=f?F:J,o=ue(e);let W=ue(t);if(o.length===0||W.length===0){y.push({reached:-1,starts:o,goal:l,back:w,best:d});continue}l=new Map(W.map(j=>[j.j*h+j.i,j]));let ne=(j,R)=>{let re=N(j),ae=B(R);return(Math.max(0,t.col-re,re-(t.col+t.side))+Math.max(0,t.row-ae,ae-(t.row+t.side)))*Ae},oe=h*p*4,ie=new Float64Array(oe).fill(1/0);w=new Int32Array(oe).fill(-1);let le=new ke;for(let j of o){let R=(j.j*h+j.i)*4+j.out;ie[R]=0,le.push(R,ne(j.i,j.j))}let Ce=[1,0,3,2];for(;le.size>0&&!(le.peekKey()>=d);){let R=le.pop(),re=Math.floor(R/4),ae=R%4,ge=re%h,we=Math.floor(re/h),ve=l.get(re);if(ve){let q=ie[R]+(ae===Ce[ve.out]?0:Le);q<d&&(d=q,s=R);continue}for(let q=0;q<4;q++){let[Me,$e]=de[q],U=ge+Me,z=we+$e;if(U<0||z<0||U>=h||z>=p||!Q[z*h+U]||!Z(ge,we,Me,$e))continue;let Te=E*(ee.has(V(ge,we,U,z))?Ae:1)*(1+Math.max(0,se[z*h+U]-We))+(q===ae?0:Le),me=(z*h+U)*4+q,be=ie[R]+Te;be<ie[me]&&(ie[me]=be,w[me]=R,le.push(me,be+ne(U,z)))}}y.push({reached:s,starts:o,goal:l,back:w,best:d})}_=!0,Q=F;let[r,v]=y,M=r&&r.reached!==-1&&(!v||v.reached===-1||r.best<=1.3*v.best+2)?r:v;if(!M||M.reached===-1)continue;({reached:s,starts:o,goal:l,back:w}=M);let x=[];for(let f=s;f!==-1;f=w[f]){let W=Math.floor(f/4),ne=x[x.length-1],oe={i:W%h,j:Math.floor(W/h)};(!ne||ne.i!==oe.i||ne.j!==oe.j)&&x.push(oe)}x.reverse();for(let f=1;f<x.length;f++){let W=V(x[f-1].i,x[f-1].j,x[f].i,x[f].j);ee.set(W,[...ee.get(W)??[],n.key])}let D=o.find(f=>f.i===x[0].i&&f.j===x[0].j),$=l.get(x[x.length-1].j*h+x[x.length-1].i);X.set(n.key,{cells:x,start:D.curb,end:$.curb})}let O=new Map(m.map(n=>[n.key,n.width])),T=new Map(m.map((n,e)=>[n.key,e])),te=i*a/Math.sqrt(1+a*a),Y=(n,e)=>n==="col"?`r${e.row.toFixed(2)}`:`c${e.col.toFixed(2)}`,K=new Map;for(let[n,e]of X)for(let t=1;t<e.cells.length;t++){let s=e.cells[t-1],o=e.cells[t],l=Y(s.i!==o.i?"col":"row",{col:N(s.i),row:B(s.j)});K.set(l,(K.get(l)??new Set).add(n))}for(let[n,e]of X){let t=[e.start,...e.cells.map(r=>({col:N(r.i),row:B(r.j)})),e.end],s=r=>r>=2&&r<=e.cells.length?V(e.cells[r-2].i,e.cells[r-2].j,e.cells[r-1].i,e.cells[r-1].j):null,o=[];for(let r=1;r<t.length;r++){let v=Math.abs(t[r].col-t[r-1].col)>1e-9?"col":"row",M=o[o.length-1];M&&M.axis===v?M.to=r:o.push({from:r-1,to:r,axis:v})}if(o.length===0)continue;let l=o.map(r=>{if(!Array.from({length:r.to-r.from},($,f)=>s(r.from+1+f)).some($=>$!==null))return 0;let v=K.get(Y(r.axis,t[r.from]))??new Set;if(!v.has(n))return 0;let M=[...v].sort(($,f)=>(T.get($)??0)-(T.get(f)??0)),D=-(M.reduce(($,f)=>$+(O.get(f)??2)+2,0)-2)/2;for(let $ of M){if($===n)return(D+(O.get($)??2)/2)/te;D+=(O.get($)??2)+2}return 0}),w=r=>{let v=o[r],M=t[v.from];return v.axis==="col"?{row:M.row+l[r]}:{col:M.col+l[r]}},d=(r,v,M)=>({col:r.col??v.col??M.col,row:r.row??v.row??M.row}),y=[d(w(0),{},t[0])];for(let r=0;r+1<o.length;r++)y.push(d(w(r),w(r+1),t[o[r].to]));y.push(d(w(o.length-1),{},t[t.length-1])),k.set(n,y.map(r=>he(r.col,r.row,i,a)))}return k}var ke=class{items=[];keys=[];get size(){return this.items.length}peekKey(){return this.keys[0]??1/0}push(m,u){this.items.push(m),this.keys.push(u);let i=this.items.length-1;for(;i>0;){let a=i-1>>1;if(this.keys[a]<=this.keys[i])break;this.swap(i,a),i=a}}pop(){let m=this.items[0],u=this.items.pop(),i=this.keys.pop();if(this.items.length>0){this.items[0]=u,this.keys[0]=i;let a=0;for(;;){let g=2*a+1,b=g+1,k=a;if(g<this.items.length&&this.keys[g]<this.keys[k]&&(k=g),b<this.items.length&&this.keys[b]<this.keys[k]&&(k=b),k===a)break;this.swap(a,k),a=k}}return m}swap(m,u){[this.items[m],this.items[u]]=[this.items[u],this.items[m]],[this.keys[m],this.keys[u]]=[this.keys[u],this.keys[m]]}};function Se(c,m){let u=c.col+c.side,i=u+.25+.22*Math.max(0,m),a=c.row+c.side*Math.max(.1,.3-.06*m),g=c.row+c.side*Math.min(.9,.7+.06*m);return[{col:u,row:a},{col:i,row:a},{col:i,row:g},{col:u,row:g}]}function Be(c,m){return c.map(u=>he(u.col,u.row,m.cell,m.tilt))}function Fe(c){return c.map((m,u)=>`${u===0?"M":"L"} ${m.x.toFixed(1)} ${m.y.toFixed(1)}`).join(" ")}function Ne(c){if(c.length===0)return{x:0,y:0};let m=0;for(let i=1;i<c.length;i++)m+=Math.hypot(c[i].x-c[i-1].x,c[i].y-c[i-1].y);let u=m/2;for(let i=1;i<c.length;i++){let a=c[i-1],g=c[i],b=Math.hypot(g.x-a.x,g.y-a.y);if(b>=u&&b>0)return{x:a.x+(g.x-a.x)*u/b,y:a.y+(g.y-a.y)*u/b};u-=b}return c[c.length-1]}var S=pe(Pe(),1);function Ue({frame:c,width:m,height:u,pan:i,store:a,graphVersion:g,selection:b,view:k,emphasis:L,hiddenKinds:A,drawn:G}){let[ce,h]=(0,P.useState)(null),p=c.city,N=e=>a.graph.getNode(e)?.kind,B=(0,P.useMemo)(()=>je(a.graph.allEdges(),e=>a.graph.getNode(e)?.kind),[a,g]),I=new Map;for(let e of c.nodes){let t=e.id.startsWith("kind:")?Ie(e.id):null;t!==null&&e.plot&&Math.round(e.plane)===2&&I.set(t,e.plot)}let _=[...I].map(([e,t])=>`${e}:${t.col},${t.row},${t.side}`).join(";"),C=p?.cell??0,H=B.filter(e=>I.has(e.from)&&I.has(e.to)&&!A.has(e.from)&&!A.has(e.to)&&G(e.edge)),F=p?.tilt??.5,[J,Q]=(0,P.useState)([]),se=J.map(e=>`${Math.round(e.x)},${Math.round(e.y)},${Math.round(e.width)},${Math.round(e.height)}`).join(";"),[Z,ue]=(0,P.useState)(null),ee=c.t>=1;(0,P.useLayoutEffect)(()=>{let e=Z?.parentElement;if(!e||!p||!ee)return;let t=e.getBoundingClientRect(),s=p.originX+i.x,o=p.originY+i.y,l=[...e.querySelectorAll('[data-graview-view^="kind:"] .graview-kind-face')].flatMap(d=>{let y=d.getBoundingClientRect();return y.width>0&&y.height>0?[{x:y.left-t.left-s,y:y.top-t.top-o,width:y.width,height:y.height}]:[]});l.map(d=>`${Math.round(d.x)},${Math.round(d.y)},${Math.round(d.width)},${Math.round(d.height)}`).join(";")!==se&&Q(l)},[Z,ee,_,C,F]);let V=(0,P.useMemo)(()=>{if(C===0)return[];let e=new Map,t=Math.max(0,...H.map(o=>o.links)),s=Oe({ribbons:H.map(o=>({key:o.key,from:o.from,to:o.to,width:xe(o.links,t)})),plots:I,cell:C,tilt:F,labels:J});return H.flatMap(o=>{let l;if(o.from===o.to){let w=e.get(o.from)??0;e.set(o.from,w+1),l=Be(Se(I.get(o.from),w),{cell:C,tilt:F})}else l=s.get(o.key);return!l||l.length<2?[]:[{ribbon:o,points:l,d:Fe(l),middle:Ne(l),width:xe(o.links,t)}]})},[C,F,_,B,G,A,se]),de=(0,P.useRef)([]),X=(0,P.useRef)({x:0,y:0});if(X.current=p?{x:p.originX+i.x,y:p.originY+i.y}:{x:0,y:0},(0,P.useEffect)(()=>{let e=Z?.parentElement;if(!e||typeof window>"u")return;let t=0,s=null,o=()=>{t=0;let d=s;if(!d)return;let y=d.target;if(d.pointerType==="touch"||d.buttons!==0||y?.closest("[data-graview-view], button, a, input, select, textarea, [data-graview-overlay], [data-graview-offstage]")){h(null);return}let r=e.getBoundingClientRect(),v=d.clientX-r.left-X.current.x,M=d.clientY-r.top-X.current.y,x=null,D=1/0;for(let $ of de.current){let f=qe($.points,v,M);f<=$.reach&&f<D&&(D=f,x=$.key)}h(x)},l=d=>{s=d,t===0&&(t=requestAnimationFrame(o))},w=()=>h(null);return e.addEventListener("pointermove",l,{passive:!0}),e.addEventListener("pointerleave",w),()=>{t!==0&&cancelAnimationFrame(t),e.removeEventListener("pointermove",l),e.removeEventListener("pointerleave",w)}},[Z]),!p||!k.overview||V.length===0)return null;let O=Ee(b,k,N);if(O.records.length>0||O.lens!==null)return null;let T=O.districts.length>0?V.filter(({ribbon:e})=>O.districts.includes(e.from)||O.districts.includes(e.to)):V;if(T.length===0)return null;let te=L??null,Y=T.find(({ribbon:e})=>e.key===ce);de.current=T.map(({ribbon:e,points:t,width:s})=>({key:e.key,points:t,reach:s/2+6}));let K={x:p.originX+i.x,y:p.originY+i.y},n=`translate(${K.x.toFixed(1)} ${K.y.toFixed(1)})`;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("svg",{ref:ue,className:"graview-ribbons","aria-hidden":"true","data-graview-world":"","data-graview-ribbons":T.length,width:m,height:u,style:{position:"absolute",left:0,top:0,pointerEvents:"none",overflow:"visible"},children:(0,S.jsx)("g",{transform:n,children:T.map(({ribbon:e,d:t,width:s})=>{let o=ce===e.key||te!==null&&te===e.edge||O.districts.length>0,l=te!==null&&te!==e.edge;return(0,S.jsx)("g",{className:"graview-ribbon","data-graview-ribbon":e.edge,"data-graview-from":`kind:${e.from}`,"data-graview-to":`kind:${e.to}`,"data-graview-links":e.links,"data-graview-lit":o&&!l?"":void 0,"data-graview-receded":l?"":void 0,children:(0,S.jsx)("path",{className:"graview-ribbon-band",d:t,style:{strokeWidth:s}})},e.key)})})}),Y?(0,S.jsx)("div",{className:"graview-ribbon-said","data-graview-world":"","data-testid":"ribbon-said",role:"status",style:{position:"absolute",left:K.x+Y.middle.x,top:K.y+Y.middle.y,pointerEvents:"none"},children:Re(a.schema,Y.ribbon)}):null]})}function qe(c,m,u){let i=1/0;for(let a=1;a<c.length;a++){let g=c[a-1],b=c[a],k=b.x-g.x,L=b.y-g.y,A=k*k+L*L,G=A===0?0:Math.max(0,Math.min(1,((m-g.x)*k+(u-g.y)*L)/A));i=Math.min(i,Math.hypot(m-(g.x+G*k),u-(g.y+G*L)))}return i}export{Ue as Ribbons,qe as distanceTo};
|
|
1
|
+
import{a as xe}from"./chunk.HJCQ6I3S.js";import{a as je,b as Ee,c as Ie,d as Re}from"./chunk.BNPQUI3F.js";import"./chunk.TKUNRFDE.js";import{c as he}from"./chunk.6RY6OSE6.js";import"./chunk.HDRD33II.js";import"./chunk.DX357TZ3.js";import"./chunk.H7KCWCB4.js";import{G as Ke,R as Pe}from"./chunk.XWAMQPUM.js";import"./chunk.SDO3U72B.js";import"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import{b as pe}from"./chunk.AJZBJBMO.js";var P=pe(Ke(),1);var E=.5,fe=1,ye=.76,Le=3,We=3,Ae=.6;function Oe(c){let{ribbons:m,plots:u,cell:i}=c,a=c.tilt??.5,g=c.labels??[],b=[...u.values()],k=new Map;if(b.length===0||i<=0)return k;let L=Math.min(...b.map(n=>n.col))-3,A=Math.min(...b.map(n=>n.row))-3,G=Math.max(...b.map(n=>n.col+n.side))+3,ce=Math.max(...b.map(n=>n.row+n.side))+3,h=Math.round((G-L)/E)+1,p=Math.round((ce-A)/E)+1,N=n=>L+n*E,B=n=>A+n*E,I=4,_=!0,C=(n,e)=>{if(!_)return!1;let t=he(n,e,i,a);return g.some(s=>t.x>s.x-I&&t.x<s.x+s.width+I&&t.y>s.y-I&&t.y<s.y+s.height+I)},H=(n,e)=>b.some(t=>n>t.col-ye&&n<t.col+t.side+ye&&e>t.row-ye&&e<t.row+t.side+ye),F=new Uint8Array(h*p),J=new Uint8Array(h*p);for(let n=0;n<h;n++)for(let e=0;e<p;e++){let t=N(n),s=B(e);J[e*h+n]=H(t,s)?0:1,F[e*h+n]=J[e*h+n]&&!C(t,s)?1:0}let Q=F,se=new Float32Array(h*p);for(let n=0;n<h;n++)for(let e=0;e<p;e++){let t=N(n),s=B(e);se[e*h+n]=Math.min(...b.map(o=>Math.max(0,o.col-t,t-(o.col+o.side),o.row-s,s-(o.row+o.side))))}let Z=(n,e,t,s)=>{let o=N(n)+t*E/2,l=B(e)+s*E/2;return!H(o,l)&&!C(o,l)},ue=n=>{let e=[],t=(o,l)=>{let w=[],d=Math.min(1,l/3);for(let y=Math.ceil((o+d)/E-1e-9)*E;y<=o+l-d+1e-9;y+=E)w.push(y);return w},s=(o,l,w,d)=>{let y=Math.round((o-L)/E),r=Math.round((l-A)/E);y>=0&&r>=0&&y<h&&r<p&&Q[r*h+y]&&e.push({i:y,j:r,out:w,curb:d})};for(let o of t(n.row,n.side))s(n.col-fe,o,1,{col:n.col,row:o}),s(n.col+n.side+fe,o,0,{col:n.col+n.side,row:o});for(let o of t(n.col,n.side))s(o,n.row-fe,3,{col:o,row:n.row}),s(o,n.row+n.side+fe,2,{col:o,row:n.row+n.side});return e},ee=new Map,V=(n,e,t,s)=>n<t||n===t&&e<s?`${n},${e}-${t},${s}`:`${t},${s}-${n},${e}`,de=[[1,0],[-1,0],[0,1],[0,-1]],X=new Map;for(let n of m){let e=u.get(n.from),t=u.get(n.to);if(!e||!t||e===t)continue;let s=-1,o=[],l=new Map,w=new Int32Array(0),d=1/0,y=[];for(let f of[!0,!1]){s=-1,d=1/0,_=f,Q=f?F:J,o=ue(e);let W=ue(t);if(o.length===0||W.length===0){y.push({reached:-1,starts:o,goal:l,back:w,best:d});continue}l=new Map(W.map(j=>[j.j*h+j.i,j]));let ne=(j,R)=>{let re=N(j),ae=B(R);return(Math.max(0,t.col-re,re-(t.col+t.side))+Math.max(0,t.row-ae,ae-(t.row+t.side)))*Ae},oe=h*p*4,ie=new Float64Array(oe).fill(1/0);w=new Int32Array(oe).fill(-1);let le=new ke;for(let j of o){let R=(j.j*h+j.i)*4+j.out;ie[R]=0,le.push(R,ne(j.i,j.j))}let Ce=[1,0,3,2];for(;le.size>0&&!(le.peekKey()>=d);){let R=le.pop(),re=Math.floor(R/4),ae=R%4,ge=re%h,we=Math.floor(re/h),ve=l.get(re);if(ve){let q=ie[R]+(ae===Ce[ve.out]?0:Le);q<d&&(d=q,s=R);continue}for(let q=0;q<4;q++){let[Me,$e]=de[q],U=ge+Me,z=we+$e;if(U<0||z<0||U>=h||z>=p||!Q[z*h+U]||!Z(ge,we,Me,$e))continue;let Te=E*(ee.has(V(ge,we,U,z))?Ae:1)*(1+Math.max(0,se[z*h+U]-We))+(q===ae?0:Le),me=(z*h+U)*4+q,be=ie[R]+Te;be<ie[me]&&(ie[me]=be,w[me]=R,le.push(me,be+ne(U,z)))}}y.push({reached:s,starts:o,goal:l,back:w,best:d})}_=!0,Q=F;let[r,v]=y,M=r&&r.reached!==-1&&(!v||v.reached===-1||r.best<=1.3*v.best+2)?r:v;if(!M||M.reached===-1)continue;({reached:s,starts:o,goal:l,back:w}=M);let x=[];for(let f=s;f!==-1;f=w[f]){let W=Math.floor(f/4),ne=x[x.length-1],oe={i:W%h,j:Math.floor(W/h)};(!ne||ne.i!==oe.i||ne.j!==oe.j)&&x.push(oe)}x.reverse();for(let f=1;f<x.length;f++){let W=V(x[f-1].i,x[f-1].j,x[f].i,x[f].j);ee.set(W,[...ee.get(W)??[],n.key])}let D=o.find(f=>f.i===x[0].i&&f.j===x[0].j),$=l.get(x[x.length-1].j*h+x[x.length-1].i);X.set(n.key,{cells:x,start:D.curb,end:$.curb})}let O=new Map(m.map(n=>[n.key,n.width])),T=new Map(m.map((n,e)=>[n.key,e])),te=i*a/Math.sqrt(1+a*a),Y=(n,e)=>n==="col"?`r${e.row.toFixed(2)}`:`c${e.col.toFixed(2)}`,K=new Map;for(let[n,e]of X)for(let t=1;t<e.cells.length;t++){let s=e.cells[t-1],o=e.cells[t],l=Y(s.i!==o.i?"col":"row",{col:N(s.i),row:B(s.j)});K.set(l,(K.get(l)??new Set).add(n))}for(let[n,e]of X){let t=[e.start,...e.cells.map(r=>({col:N(r.i),row:B(r.j)})),e.end],s=r=>r>=2&&r<=e.cells.length?V(e.cells[r-2].i,e.cells[r-2].j,e.cells[r-1].i,e.cells[r-1].j):null,o=[];for(let r=1;r<t.length;r++){let v=Math.abs(t[r].col-t[r-1].col)>1e-9?"col":"row",M=o[o.length-1];M&&M.axis===v?M.to=r:o.push({from:r-1,to:r,axis:v})}if(o.length===0)continue;let l=o.map(r=>{if(!Array.from({length:r.to-r.from},($,f)=>s(r.from+1+f)).some($=>$!==null))return 0;let v=K.get(Y(r.axis,t[r.from]))??new Set;if(!v.has(n))return 0;let M=[...v].sort(($,f)=>(T.get($)??0)-(T.get(f)??0)),D=-(M.reduce(($,f)=>$+(O.get(f)??2)+2,0)-2)/2;for(let $ of M){if($===n)return(D+(O.get($)??2)/2)/te;D+=(O.get($)??2)+2}return 0}),w=r=>{let v=o[r],M=t[v.from];return v.axis==="col"?{row:M.row+l[r]}:{col:M.col+l[r]}},d=(r,v,M)=>({col:r.col??v.col??M.col,row:r.row??v.row??M.row}),y=[d(w(0),{},t[0])];for(let r=0;r+1<o.length;r++)y.push(d(w(r),w(r+1),t[o[r].to]));y.push(d(w(o.length-1),{},t[t.length-1])),k.set(n,y.map(r=>he(r.col,r.row,i,a)))}return k}var ke=class{items=[];keys=[];get size(){return this.items.length}peekKey(){return this.keys[0]??1/0}push(m,u){this.items.push(m),this.keys.push(u);let i=this.items.length-1;for(;i>0;){let a=i-1>>1;if(this.keys[a]<=this.keys[i])break;this.swap(i,a),i=a}}pop(){let m=this.items[0],u=this.items.pop(),i=this.keys.pop();if(this.items.length>0){this.items[0]=u,this.keys[0]=i;let a=0;for(;;){let g=2*a+1,b=g+1,k=a;if(g<this.items.length&&this.keys[g]<this.keys[k]&&(k=g),b<this.items.length&&this.keys[b]<this.keys[k]&&(k=b),k===a)break;this.swap(a,k),a=k}}return m}swap(m,u){[this.items[m],this.items[u]]=[this.items[u],this.items[m]],[this.keys[m],this.keys[u]]=[this.keys[u],this.keys[m]]}};function Se(c,m){let u=c.col+c.side,i=u+.25+.22*Math.max(0,m),a=c.row+c.side*Math.max(.1,.3-.06*m),g=c.row+c.side*Math.min(.9,.7+.06*m);return[{col:u,row:a},{col:i,row:a},{col:i,row:g},{col:u,row:g}]}function Be(c,m){return c.map(u=>he(u.col,u.row,m.cell,m.tilt))}function Fe(c){return c.map((m,u)=>`${u===0?"M":"L"} ${m.x.toFixed(1)} ${m.y.toFixed(1)}`).join(" ")}function Ne(c){if(c.length===0)return{x:0,y:0};let m=0;for(let i=1;i<c.length;i++)m+=Math.hypot(c[i].x-c[i-1].x,c[i].y-c[i-1].y);let u=m/2;for(let i=1;i<c.length;i++){let a=c[i-1],g=c[i],b=Math.hypot(g.x-a.x,g.y-a.y);if(b>=u&&b>0)return{x:a.x+(g.x-a.x)*u/b,y:a.y+(g.y-a.y)*u/b};u-=b}return c[c.length-1]}var S=pe(Pe(),1);function Ue({frame:c,width:m,height:u,pan:i,store:a,graphVersion:g,selection:b,view:k,emphasis:L,hiddenKinds:A,drawn:G}){let[ce,h]=(0,P.useState)(null),p=c.city,N=e=>a.graph.getNode(e)?.kind,B=(0,P.useMemo)(()=>je(a.graph.allEdges(),e=>a.graph.getNode(e)?.kind),[a,g]),I=new Map;for(let e of c.nodes){let t=e.id.startsWith("kind:")?Ie(e.id):null;t!==null&&e.plot&&Math.round(e.plane)===2&&I.set(t,e.plot)}let _=[...I].map(([e,t])=>`${e}:${t.col},${t.row},${t.side}`).join(";"),C=p?.cell??0,H=B.filter(e=>I.has(e.from)&&I.has(e.to)&&!A.has(e.from)&&!A.has(e.to)&&G(e.edge)),F=p?.tilt??.5,[J,Q]=(0,P.useState)([]),se=J.map(e=>`${Math.round(e.x)},${Math.round(e.y)},${Math.round(e.width)},${Math.round(e.height)}`).join(";"),[Z,ue]=(0,P.useState)(null),ee=c.t>=1;(0,P.useLayoutEffect)(()=>{let e=Z?.parentElement;if(!e||!p||!ee)return;let t=e.getBoundingClientRect(),s=p.originX+i.x,o=p.originY+i.y,l=[...e.querySelectorAll('[data-graview-view^="kind:"] .graview-kind-face')].flatMap(d=>{let y=d.getBoundingClientRect();return y.width>0&&y.height>0?[{x:y.left-t.left-s,y:y.top-t.top-o,width:y.width,height:y.height}]:[]});l.map(d=>`${Math.round(d.x)},${Math.round(d.y)},${Math.round(d.width)},${Math.round(d.height)}`).join(";")!==se&&Q(l)},[Z,ee,_,C,F]);let V=(0,P.useMemo)(()=>{if(C===0)return[];let e=new Map,t=Math.max(0,...H.map(o=>o.links)),s=Oe({ribbons:H.map(o=>({key:o.key,from:o.from,to:o.to,width:xe(o.links,t)})),plots:I,cell:C,tilt:F,labels:J});return H.flatMap(o=>{let l;if(o.from===o.to){let w=e.get(o.from)??0;e.set(o.from,w+1),l=Be(Se(I.get(o.from),w),{cell:C,tilt:F})}else l=s.get(o.key);return!l||l.length<2?[]:[{ribbon:o,points:l,d:Fe(l),middle:Ne(l),width:xe(o.links,t)}]})},[C,F,_,B,G,A,se]),de=(0,P.useRef)([]),X=(0,P.useRef)({x:0,y:0});if(X.current=p?{x:p.originX+i.x,y:p.originY+i.y}:{x:0,y:0},(0,P.useEffect)(()=>{let e=Z?.parentElement;if(!e||typeof window>"u")return;let t=0,s=null,o=()=>{t=0;let d=s;if(!d)return;let y=d.target;if(d.pointerType==="touch"||d.buttons!==0||y?.closest("[data-graview-view], button, a, input, select, textarea, [data-graview-overlay], [data-graview-offstage]")){h(null);return}let r=e.getBoundingClientRect(),v=d.clientX-r.left-X.current.x,M=d.clientY-r.top-X.current.y,x=null,D=1/0;for(let $ of de.current){let f=qe($.points,v,M);f<=$.reach&&f<D&&(D=f,x=$.key)}h(x)},l=d=>{s=d,t===0&&(t=requestAnimationFrame(o))},w=()=>h(null);return e.addEventListener("pointermove",l,{passive:!0}),e.addEventListener("pointerleave",w),()=>{t!==0&&cancelAnimationFrame(t),e.removeEventListener("pointermove",l),e.removeEventListener("pointerleave",w)}},[Z]),!p||!k.overview||V.length===0)return null;let O=Ee(b,k,N);if(O.records.length>0||O.lens!==null)return null;let T=O.districts.length>0?V.filter(({ribbon:e})=>O.districts.includes(e.from)||O.districts.includes(e.to)):V;if(T.length===0)return null;let te=L??null,Y=T.find(({ribbon:e})=>e.key===ce);de.current=T.map(({ribbon:e,points:t,width:s})=>({key:e.key,points:t,reach:s/2+6}));let K={x:p.originX+i.x,y:p.originY+i.y},n=`translate(${K.x.toFixed(1)} ${K.y.toFixed(1)})`;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("svg",{ref:ue,className:"graview-ribbons","aria-hidden":"true","data-graview-world":"","data-graview-ribbons":T.length,width:m,height:u,style:{position:"absolute",left:0,top:0,pointerEvents:"none",overflow:"visible"},children:(0,S.jsx)("g",{transform:n,children:T.map(({ribbon:e,d:t,width:s})=>{let o=ce===e.key||te!==null&&te===e.edge||O.districts.length>0,l=te!==null&&te!==e.edge;return(0,S.jsx)("g",{className:"graview-ribbon","data-graview-ribbon":e.edge,"data-graview-from":`kind:${e.from}`,"data-graview-to":`kind:${e.to}`,"data-graview-links":e.links,"data-graview-lit":o&&!l?"":void 0,"data-graview-receded":l?"":void 0,children:(0,S.jsx)("path",{className:"graview-ribbon-band",d:t,style:{strokeWidth:s}})},e.key)})})}),Y?(0,S.jsx)("div",{className:"graview-ribbon-said","data-graview-world":"","data-testid":"ribbon-said",role:"status",style:{position:"absolute",left:K.x+Y.middle.x,top:K.y+Y.middle.y,pointerEvents:"none"},children:Re(a.schema,Y.ribbon)}):null]})}function qe(c,m,u){let i=1/0;for(let a=1;a<c.length;a++){let g=c[a-1],b=c[a],k=b.x-g.x,L=b.y-g.y,A=k*k+L*L,G=A===0?0:Math.max(0,Math.min(1,((m-g.x)*k+(u-g.y)*L)/A));i=Math.min(i,Math.hypot(m-(g.x+G*k),u-(g.y+G*L)))}return i}export{Ue as Ribbons,qe as distanceTo};
|
|
@@ -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.6OPI4WWO.js";import"./chunk.V3QUTJR2.js";import{a as K}from"./chunk.5ESCD57M.js";import"./chunk.DQOCBKC3.js";import"./chunk.ATDU5Y7V.js";import"./chunk.VC3BX2ZF.js";import"./chunk.UKAPFIPJ.js";import"./chunk.UT6642FC.js";import{a as S,b as W}from"./chunk.MB7LKKUD.js";import"./chunk.ZIEHF67C.js";import"./chunk.UHX4WTM7.js";import"./chunk.IKX4VDTW.js";import"./chunk.RNEJYIQ7.js";import"./chunk.TBQOSI4J.js";import"./chunk.KWQ7QOHD.js";import"./chunk.HDRD33II.js";import"./chunk.DX357TZ3.js";import"./chunk.H7KCWCB4.js";import"./chunk.XSNAG4JT.js";import{$ as F,D as H,E as V,G as ee,Ga as x,R as D,wa as _}from"./chunk.XWAMQPUM.js";import{a as j}from"./chunk.SDO3U72B.js";import{fa as q,wc as B}from"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.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.LUNATPAB.js","./chunk.UKAPFIPJ.js","./chunk.UT6642FC.js","./chunk.WAB7UDHU.js","./chunk.IW7YFPGG.js","./chunk.R2AG4NHQ.js","./chunk.TI4OSTQV.js","./chunk.UHX4WTM7.js","./chunk.HDRD33II.js","./chunk.DX357TZ3.js","./chunk.H7KCWCB4.js","./chunk.XSNAG4JT.js","./chunk.XWAMQPUM.js","./chunk.SDO3U72B.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.RNBPDB37.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}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk.GZHZLJBF.js";import{n as D}from"./chunk.
|
|
1
|
+
import"./chunk.GZHZLJBF.js";import{n as D}from"./chunk.6MADC6DM.js";import"./chunk.OJGHDWI6.js";import"./chunk.JLEC3USG.js";import"./chunk.HDRD33II.js";import{a as $}from"./chunk.DX357TZ3.js";import"./chunk.H7KCWCB4.js";import"./chunk.XSNAG4JT.js";import{G as P,R as C}from"./chunk.XWAMQPUM.js";import"./chunk.SDO3U72B.js";import{Ma as w,Oa as R,Sa as c,Y as S}from"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import{b as k}from"./chunk.AJZBJBMO.js";var m=k(P(),1);var e=k(C(),1),W=[["","Does not repeat"],["day","Daily"],["week","Weekly"],["month","Monthly"],["year","Yearly"]],E=r=>`${r}${r%100>=11&&r%100<=13?"th":["th","st","nd","rd"][r%10]??"th"}`,v={display:"flex",flexWrap:"wrap",gap:"6px 12px",alignItems:"center"};function N({value:r,onChange:d,start:p,label:s,name:l="repeat"}){let f=(0,m.useId)(),a=c(r)?r:void 0,i=typeof p=="string"&&/^\d{4}-\d{2}-\d{2}/.test(p)?p:void 0,u=i?w[new Date(`${i.slice(0,10)}T00:00:00Z`).getUTCDay()]:void 0,o=t=>{let n={...a??{every:"week"},...t};for(let b of Object.keys(n))n[b]===void 0&&delete n[b];d(n)},y=a?.every??"week",g=a?.on??(u?[u]:[]);return(0,e.jsxs)("fieldset",{"data-graview-part":"field","data-graview-field":"repeat","data-graview-repeat":l,style:{display:"grid",gap:8,border:"1px solid var(--graview-edge)",borderRadius:8,padding:"8px 12px",margin:0,minWidth:0},children:[(0,e.jsx)("legend",{"data-graview-part":"label",style:{padding:"0 4px"},children:s}),(0,e.jsxs)("div",{style:v,children:[(0,e.jsx)("label",{htmlFor:`${f}-every`,children:"Repeats"}),(0,e.jsx)("select",{id:`${f}-every`,name:`${l}.every`,value:a?.every??"",onChange:t=>{let n=t.target.value;d(n===""?void 0:{...a?.interval?{interval:a.interval}:{},...a?.until?{until:a.until}:{},every:n})},"data-graview-part":"control",children:W.map(([t,n])=>(0,e.jsx)("option",{value:t,children:n},t))}),a?(0,e.jsxs)("label",{style:v,children:["every",(0,e.jsx)("input",{type:"number",min:1,max:99,name:`${l}.interval`,"aria-label":`Every how many ${y}s`,value:a.interval??1,onChange:t=>o({interval:Number(t.target.value)>1?Math.min(99,Math.round(Number(t.target.value))):void 0}),style:{width:"4.5em"},"data-graview-part":"control"}),y,(a.interval??1)>1?"s":""]}):null]}),a?.every==="week"?(0,e.jsxs)("div",{role:"group","aria-label":"On",style:v,children:[(0,e.jsx)("span",{"aria-hidden":"true",children:"On"}),w.map((t,n)=>(0,e.jsxs)("label",{style:{display:"inline-flex",gap:4,alignItems:"center",minHeight:24},children:[(0,e.jsx)("input",{type:"checkbox",name:`${l}.on`,value:t,checked:g.includes(t),onChange:b=>{let h=w.filter(x=>x===t?b.target.checked:g.includes(x));o({on:h.length===0||h.length===1&&h[0]===u?void 0:h})}}),S(n,"short")]},t))]}):null,a?.every==="month"?(0,e.jsxs)("label",{style:v,children:["On",(0,e.jsxs)("select",{name:`${l}.on`,value:a.on?.[0]===-1?"last":"",onChange:t=>o({on:t.target.value==="last"?[-1]:void 0}),"data-graview-part":"control",children:[(0,e.jsx)("option",{value:"",children:i?`the ${E(Number(i.slice(8,10)))}`:"the same day"}),(0,e.jsx)("option",{value:"last",children:"the last day"})]})]}):null,a?(0,e.jsxs)("label",{style:v,children:["Until",(0,e.jsx)("input",{type:"date",name:`${l}.until`,value:a.until??"",onChange:t=>o({until:t.target.value||void 0}),"data-graview-part":"control"})]}):null,(0,e.jsx)("p",{"aria-live":"polite","data-graview-repeat-said":"",style:{margin:0,color:"var(--graview-ink-dim)",fontSize:"0.8125rem"},children:a?$(i??"",a):"Does not repeat"})]})}function M({nodeId:r,field:d,start:p,value:s,label:l}){let{fields:f,commit:a}=D(r),i=f.find(t=>t.field===R(d)&&t.takesValue&&t.open.length===0),[u,o]=(0,m.useState)(!1),[y,g]=(0,m.useState)(c(s)?s:void 0);return i?u?(0,e.jsxs)("form",{onSubmit:t=>{t.preventDefault(),o(!1),a(i,y??null)},style:{display:"grid",gap:6,marginTop:6},children:[(0,e.jsx)(N,{value:y,onChange:g,start:p,label:l,name:R(d)}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("button",{type:"submit","data-graview-repeat-keep":d,children:"Keep"}),(0,e.jsx)("button",{type:"button",onClick:()=>o(!1),children:"Cancel"})]})]}):(0,e.jsx)("button",{type:"button","data-graview-repeat-open":d,onClick:()=>(g(c(s)?s:void 0),o(!0)),style:{marginInlineStart:8,fontSize:"0.75rem",padding:"1px 8px",borderRadius:999,minHeight:24},children:c(s)?"Change how it repeats":"Repeat\u2026"}):null}export{M as RepeatEditor,N as RepeatPicker};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as Z,b as qe}from"./chunk.5A4AOFOA.js";import"./chunk.KSXB4LDF.js";import"./chunk.CDFVEL2Y.js";import{i as De,j as Ne,k as Oe}from"./chunk.T6S3CEW7.js";import"./chunk.6NFR2LYQ.js";import"./chunk.HJCQ6I3S.js";import"./chunk.B7FZLIAO.js";import"./chunk.N5ULWKR4.js";import"./chunk.6BIRNR5P.js";import"./chunk.GBCWI2LF.js";import"./chunk.7PUFYK3B.js";import{a as We,b as S}from"./chunk.QJJKITXF.js";import{a as X,b as $e}from"./chunk.7AEE3VHC.js";import"./chunk.LKF4BBCW.js";import"./chunk.JUT2VCFW.js";import"./chunk.IIB22IIP.js";import"./chunk.MWUP5X47.js";import"./chunk.OK4FSBHI.js";import"./chunk.DAZEFSWI.js";import"./chunk.OGF6UORU.js";import{b as Pe,c as Le}from"./chunk.UT6642FC.js";import"./chunk.3TBH2FMZ.js";import"./chunk.WE5SA6TP.js";import"./chunk.TI4OSTQV.js";import"./chunk.TDCO7LEA.js";import"./chunk.ESU2DD3J.js";import"./chunk.PL2P2OON.js";import"./chunk.27ZVVPRZ.js";import"./chunk.IN4PKQO5.js";import"./chunk.3IUJ4GW7.js";import"./chunk.UG23RICT.js";import{u as Re}from"./chunk.ATKKTPJS.js";import"./chunk.OJGHDWI6.js";import"./chunk.UZSZPMRC.js";import{g as ze}from"./chunk.MZOIPCDA.js";import"./chunk.KERLVJ6I.js";import{c as Ce}from"./chunk.4EPT2CQG.js";import{m as Ie}from"./chunk.FNXW46U4.js";import{Da as He,G as ot,Ha as Ee,R as Me,_ as O,h as Ae,u as Te,ya as J}from"./chunk.4JWT6LIS.js";import"./chunk.SDO3U72B.js";import{Zb as xe,_b as ke,ka as Q,la as N,wb as be,wc as Se}from"./chunk.AW2T3KFV.js";import"./chunk.2AZTW66C.js";import{b as Y}from"./chunk.AJZBJBMO.js";var a=Y(ot(),1);var t=Y(Me(),1);function bt(u,r,o){let c=r.on??r.about[r.about.length-1];De(u,r.about,{...o,pins:Z(),...c===void 0?{}:{focus:c}})}function xt({placement:u="float",chosen:r=!0}={}){let{menuAt:o}=O();return u==="menu"&&o===null?r?(0,t.jsx)(at,{}):null:(0,t.jsx)(lt,{placement:u})}function at(){let{store:u,setMenuAt:r,view:o}=O(),{selection:c}=J(),h=(0,a.useRef)(null),[E,y]=(0,a.useState)(null);(0,a.useLayoutEffect)(()=>{let b=h.current?.offsetParent??h.current?.parentElement;if(!b)return;let m=Math.round(b.getBoundingClientRect().width);m!==E&&y(m)});let v=c.length===1&&!o.overview?u.graph.getNode(c[0]):void 0;return!v||E===null||E>=Be?(0,t.jsx)("span",{ref:h,hidden:!0}):(0,t.jsx)("button",{type:"button",ref:h,"data-testid":"chosen-acts","aria-label":`What can be done with ${S(u,v.id)}`,"aria-haspopup":"menu",onClick:b=>{let m=b.currentTarget.getBoundingClientRect();r({x:Math.round(m.right),y:Math.round(m.bottom+4),on:v.id})},style:{position:"absolute",right:"calc(14px + var(--graview-dock, 0px))",top:98,zIndex:"var(--graview-layer-overview, 10)",minHeight:30,padding:"0 12px",borderRadius:8,fontSize:"0.8125rem",background:"var(--graview-float)",boxShadow:"var(--graview-lift-low)"},children:"Acts\u2026"})}var Be=564;function lt({placement:u}){let{store:r,menuAt:o,setMenuAt:c,view:h,signIn:E}=O(),y=(0,a.useRef)(null),v=(0,a.useRef)(null),b=(0,a.useRef)(null),m=(0,a.useRef)(null);o?.returnTo&&(m.current=o.returnTo);let Ke=e=>{let i=e.closest("[data-graview-asking]")?.getAttribute("data-graview-asking"),n=e.getAttribute("data-pin-for"),d=i??e.getAttribute("data-affordance")??(n===null?null:`pin:${n}`)??e.getAttribute("data-menu-item");v.current=d===null?null:{key:d,element:e}};(0,a.useEffect)(()=>{let e=y.current,i=v.current;if(i===null||document.activeElement!==document.body||i.element.isConnected)return;let n=i.key;if(!e){v.current=null;let k=m.current;m.current=null,(k?.isConnected?k:b.current)?.focus();return}((n.startsWith("pin:")?e.querySelector(`[data-pin-for="${CSS.escape(n.slice(4))}"]`):null)??e.querySelector(`[data-affordance="${CSS.escape(n)}"]:not([disabled])`)??e).focus()});let[_e,je]=(0,a.useState)(null);(0,a.useLayoutEffect)(()=>{let e=y.current?.offsetParent??y.current?.parentElement;if(e instanceof HTMLElement&&(b.current=e),!e)return;let i=e.getBoundingClientRect();je(n=>n&&n.left===i.left&&n.top===i.top&&n.width===i.width&&n.height===i.height?n:{left:i.left,top:i.top,width:i.width,height:i.height})});let{selection:Ue,set:Ve,clear:Ge}=J(),s=o?.about??Ue,[q,Ye]=(0,a.useState)(()=>Z()),F=o?.on??s[s.length-1],B=o?.about,Qe=(0,a.useMemo)(()=>({pins:q,...F===void 0?{}:{focus:F},...B?{about:B}:{}}),[q,F,B]),Je=(0,a.useMemo)(()=>new Set(r.allMutations().filter(e=>e.pinned).map(e=>e.name)),[r]),{affordances:g,withheld:ee,observations:te}=Ne(Qe),I=ke(ee,E),f=I?st:ee,Xe=o===null?null:{face:o.face??"scene",on:o.on,about:s,field:o.field,place:o.place,href:o.href,act:o.act,element:o.returnTo},ne=Re(Xe),ie=te.some(e=>e.id.startsWith("schema:waits:")),{apply:Ze,preview:et}=Oe(),[C,z]=(0,a.useState)(null),[tt,re]=(0,a.useState)(!1),[oe,ae]=(0,a.useState)(!1),[L,R]=(0,a.useState)(""),nt=$e({letters:!0}),[le,K]=(0,a.useState)(null),_=(0,a.useRef)([]),j=(e,i)=>{try{return et(e,i),Ze(e,i),K(null),c(null),_.current=[],!0}catch(n){return K(ze(r.schema,r.allMutations(),n)),_.current=n instanceof be?n.issues.map(d=>String(d.path[0]??"")).filter(Boolean):[],!1}},$=[...new Set(s.flatMap(e=>{let i=r.graph.getNode(e);return i?[i.kind]:[]}))],x=$.length>0?$:[...new Set(s.flatMap(e=>Te(e)))],p=s.length===1?Ae(s[0]):null,U=p?{from:r.graph.getNode(p.from),to:r.graph.getNode(p.to)}:null,se=p?Le(r,p):void 0,de=se?.provisional?se:void 0,ue=p?(()=>{let e=r.schema.tryDefinition(r.graph.getNode(p.from)?.kind??"")?.edges?.[p.kind],i=r.graph.getNode(p.to);return e?.inverse&&i?`From ${S(r,i.id)}: ${e.inverse}`:null})():null;(0,a.useEffect)(()=>{z(null),re(!1),ae(!1),K(null),R("")},[s,o?.about]);let l=o!==null,it=u==="menu"&&!l,A=(0,a.useRef)(o);A.current=o;let pe=Ee("acts",{open:l&&u==="menu",onOpenChange:e=>{e||c(null)},at:()=>A.current?{x:A.current.x,y:A.current.y}:null,returnTo:()=>{let e=A.current?.returnTo;if(e?.isConnected)return e;let i=A.current?.on;return i?document.querySelector(`[data-graview-view="${CSS.escape(i)}"]`):null},align:"start"}),ce=(_e?.width??Number.POSITIVE_INFINITY)<Be;if((0,a.useLayoutEffect)(()=>{let e=y.current?.offsetParent;if(!e||!ce||l)return;let i=y.current?.getBoundingClientRect().height??0,n=`${Math.round(i)+20}px`;if(e.style.paddingBottom===n)return;let d=e.style.paddingBottom;return e.style.paddingBottom=n,()=>{e.style.paddingBottom=d}}),s.length===0&&!l)return null;let ge=o?.title!==void 0||s.length>0&&!(s.length===1&&s[0]===h.focusId),he=Math.max(1,Math.min(9,g.length)),T=[...g.filter(e=>e.provider==="invariant"&&!e.destructive),...g.filter(e=>e.pinned&&e.provider!=="invariant"&&!e.destructive),...g.filter(e=>!e.ties&&!e.destructive&&!e.pinned&&e.provider!=="invariant"),...g.filter(e=>e.ties&&!e.destructive&&!e.pinned&&e.provider!=="invariant"),...g.filter(e=>e.destructive)],me=T.length>he&&!l,fe=L.trim().toLowerCase(),w=me&&fe.length>0?T.filter(e=>`${e.label} ${e.why}`.toLowerCase().includes(fe)):null,V=w??(tt||l?T:T.slice(0,he)),ye=w?0:T.length-V.length,W=[];for(let e of V){let i=!l&&e.provider==="invariant",n=!l&&!i&&e.pinned!==void 0&&!e.destructive,d=!l&&!i&&!n&&e.ties===!0&&!e.destructive,k=i?e.why:n?"pinned":d?"its ties":null,D=i?"violation":n||d?"ties":null,H=W[W.length-1];H&&H.heading===k?H.items.push(e):W.push({heading:k,tone:D,items:[e]})}let G=g.find(e=>e.id===C),P=s.length===1?S(r,s[0]):null,ve=e=>{if(!P)return e;let i=e.startsWith(`"${P}"`)?e.slice(P.length+2):e.startsWith(P)?e.slice(P.length):null;if(i===null)return e;let n=i.trimStart();return n.length===0?e:n[0].toUpperCase()+n.slice(1)},rt=new Set(l?[]:V.filter(e=>e.provider==="invariant").map(e=>e.why)),M=te.filter(e=>!rt.has(e.text)).map(e=>({...e,text:ve(e.text)}));return it?null:(0,t.jsxs)("section",{...l?pe.pane:{},ref:e=>{y.current=e,l&&pe.pane.ref(e)},"aria-label":"Inspector","data-graview-offstage":"","data-testid":l?"context-menu":"inspector-strip",tabIndex:-1,onFocus:e=>Ke(e.target),onBlur:e=>{e.relatedTarget!==null&&(v.current=null)},onMouseDown:e=>e.stopPropagation(),style:{...l?He:{position:"absolute",zIndex:Se("rail")},boxSizing:"border-box",display:"flex",flexDirection:"column",gap:7,padding:"9px 12px",borderRadius:"var(--graview-radius, 12px)",border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)",...l?{width:300,maxHeight:"min(52cqh, 420px)",overflow:"auto"}:ce?{left:10,right:10,width:"auto",bottom:10,maxHeight:"min(42cqh, 300px)",overflow:"auto"}:{left:14,top:h.overview?"min(296px, 38cqh)":44,width:236,maxHeight:h.overview?"calc(100cqh - min(296px, 38cqh) - 20px)":"calc(68cqh - 94px)",overflow:"auto"}},children:[(0,t.jsx)("h2",{style:{...Ie,margin:0},children:"Inspector"}),(0,t.jsxs)("div",{style:{display:ge||!l?"flex":"none",alignItems:"baseline",flexWrap:"wrap",gap:"2px 8px",minWidth:0,paddingRight:l?0:24},children:[ge?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("strong",{style:{fontSize:"0.9375rem",whiteSpace:"nowrap"},children:o?.title??(s.length===1?S(r,s[0]):`${s.length} selected`)}),$.length>0||p?(0,t.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",whiteSpace:"nowrap"},children:p?"relation":$.map(e=>N(r.schema.tryDefinition(e),e)).join(" \xB7 ")}):null,s.length===1&&!p&&o?.face!=="pages"?(0,t.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",whiteSpace:"nowrap"},children:h.expanded.includes(s[0])?"\xB7 double-click closes":"\xB7 double-click opens"}):null]}):null,(0,t.jsx)("span",{style:{flex:"1 1 auto"}})]}),l?null:(0,t.jsx)("button",{type:"button",onClick:()=>{c(null),Ge()},"aria-label":"Clear selection",title:"Clear selection",style:{position:"absolute",top:6,right:6,flex:"0 0 auto",width:24,height:24,display:"grid",placeItems:"center",padding:0,fontSize:"0.875rem",lineHeight:1,borderRadius:7},children:"\xD7"}),p&&U?(0,t.jsxs)("div",{style:{display:"grid",gap:6},children:[ue?(0,t.jsx)("p",{"data-testid":"edge-said",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:ue}):null,de?(0,t.jsx)("p",{"data-testid":"edge-provisional",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:Pe(de)}):null,(0,t.jsx)("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[["from",U.from],["to",U.to]].map(([e,i],n)=>(0,t.jsxs)(a.Fragment,{children:[n===1?(0,t.jsx)("span",{"aria-hidden":"true",style:{color:"var(--graview-ink-faint)"},children:"\u2192"}):null,i?(0,t.jsx)("button",{type:"button","data-testid":`edge-${e}`,onClick:()=>Ve([i.id]),title:`Select ${S(r,i.id)}`,style:{fontSize:"0.8125rem",padding:"3px 9px",borderRadius:6},children:S(r,i.id)}):(0,t.jsx)("span",{style:{fontSize:"0.8125rem",color:"var(--graview-ink-faint)"},children:"gone"})]},e))})]}):null,!p&&s.length===1&&xe(r,s[0])?(0,t.jsx)("p",{"data-testid":"left-alone",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:"Left alone: nothing automated changes it."}):null,M.length>0?(0,t.jsx)("div",{"data-testid":"observations",title:M.map(e=>e.text).join(`
|
|
1
|
+
import{a as Z,b as qe}from"./chunk.5A4AOFOA.js";import"./chunk.KSXB4LDF.js";import"./chunk.P4O5DGLN.js";import{i as De,j as Ne,k as Oe}from"./chunk.WSTBCWW7.js";import"./chunk.NIVTK2W5.js";import"./chunk.HJCQ6I3S.js";import"./chunk.BNPQUI3F.js";import"./chunk.6RY6OSE6.js";import"./chunk.6OPI4WWO.js";import"./chunk.V3QUTJR2.js";import"./chunk.64WM4IBI.js";import{a as We,b as S}from"./chunk.5ESCD57M.js";import{a as X,b as $e}from"./chunk.DQOCBKC3.js";import"./chunk.DEUTHHGI.js";import"./chunk.ATDU5Y7V.js";import"./chunk.PKUDIWIF.js";import"./chunk.VW2VCPJX.js";import"./chunk.WBHM5I3I.js";import"./chunk.VC3BX2ZF.js";import"./chunk.UKAPFIPJ.js";import{b as Pe,c as Le}from"./chunk.UT6642FC.js";import"./chunk.WAB7UDHU.js";import"./chunk.IW7YFPGG.js";import"./chunk.TI4OSTQV.js";import"./chunk.Q7RQC3F7.js";import"./chunk.ZIEHF67C.js";import"./chunk.UHX4WTM7.js";import"./chunk.IKX4VDTW.js";import"./chunk.RNEJYIQ7.js";import"./chunk.TBQOSI4J.js";import"./chunk.KWQ7QOHD.js";import{u as Re}from"./chunk.6MADC6DM.js";import"./chunk.OJGHDWI6.js";import"./chunk.JLEC3USG.js";import{g as ze}from"./chunk.HDRD33II.js";import"./chunk.DX357TZ3.js";import{c as Ce}from"./chunk.H7KCWCB4.js";import{m as Ie}from"./chunk.XSNAG4JT.js";import{Aa as J,Fa as He,G as ot,Ja as Ee,R as Me,_ as O,h as Ae,u as Te}from"./chunk.XWAMQPUM.js";import"./chunk.SDO3U72B.js";import{Zb as xe,_b as ke,ka as Q,la as N,wb as be,wc as Se}from"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import{b as Y}from"./chunk.AJZBJBMO.js";var a=Y(ot(),1);var t=Y(Me(),1);function bt(u,r,o){let c=r.on??r.about[r.about.length-1];De(u,r.about,{...o,pins:Z(),...c===void 0?{}:{focus:c}})}function xt({placement:u="float",chosen:r=!0}={}){let{menuAt:o}=O();return u==="menu"&&o===null?r?(0,t.jsx)(at,{}):null:(0,t.jsx)(lt,{placement:u})}function at(){let{store:u,setMenuAt:r,view:o}=O(),{selection:c}=J(),h=(0,a.useRef)(null),[E,y]=(0,a.useState)(null);(0,a.useLayoutEffect)(()=>{let b=h.current?.offsetParent??h.current?.parentElement;if(!b)return;let m=Math.round(b.getBoundingClientRect().width);m!==E&&y(m)});let v=c.length===1&&!o.overview?u.graph.getNode(c[0]):void 0;return!v||E===null||E>=Be?(0,t.jsx)("span",{ref:h,hidden:!0}):(0,t.jsx)("button",{type:"button",ref:h,"data-testid":"chosen-acts","aria-label":`What can be done with ${S(u,v.id)}`,"aria-haspopup":"menu",onClick:b=>{let m=b.currentTarget.getBoundingClientRect();r({x:Math.round(m.right),y:Math.round(m.bottom+4),on:v.id})},style:{position:"absolute",right:"calc(14px + var(--graview-dock, 0px))",top:98,zIndex:"var(--graview-layer-overview, 10)",minHeight:30,padding:"0 12px",borderRadius:8,fontSize:"0.8125rem",background:"var(--graview-float)",boxShadow:"var(--graview-lift-low)"},children:"Acts\u2026"})}var Be=564;function lt({placement:u}){let{store:r,menuAt:o,setMenuAt:c,view:h,signIn:E}=O(),y=(0,a.useRef)(null),v=(0,a.useRef)(null),b=(0,a.useRef)(null),m=(0,a.useRef)(null);o?.returnTo&&(m.current=o.returnTo);let Ke=e=>{let i=e.closest("[data-graview-asking]")?.getAttribute("data-graview-asking"),n=e.getAttribute("data-pin-for"),d=i??e.getAttribute("data-affordance")??(n===null?null:`pin:${n}`)??e.getAttribute("data-menu-item");v.current=d===null?null:{key:d,element:e}};(0,a.useEffect)(()=>{let e=y.current,i=v.current;if(i===null||document.activeElement!==document.body||i.element.isConnected)return;let n=i.key;if(!e){v.current=null;let k=m.current;m.current=null,(k?.isConnected?k:b.current)?.focus();return}((n.startsWith("pin:")?e.querySelector(`[data-pin-for="${CSS.escape(n.slice(4))}"]`):null)??e.querySelector(`[data-affordance="${CSS.escape(n)}"]:not([disabled])`)??e).focus()});let[_e,je]=(0,a.useState)(null);(0,a.useLayoutEffect)(()=>{let e=y.current?.offsetParent??y.current?.parentElement;if(e instanceof HTMLElement&&(b.current=e),!e)return;let i=e.getBoundingClientRect();je(n=>n&&n.left===i.left&&n.top===i.top&&n.width===i.width&&n.height===i.height?n:{left:i.left,top:i.top,width:i.width,height:i.height})});let{selection:Ue,set:Ve,clear:Ge}=J(),s=o?.about??Ue,[q,Ye]=(0,a.useState)(()=>Z()),F=o?.on??s[s.length-1],B=o?.about,Qe=(0,a.useMemo)(()=>({pins:q,...F===void 0?{}:{focus:F},...B?{about:B}:{}}),[q,F,B]),Je=(0,a.useMemo)(()=>new Set(r.allMutations().filter(e=>e.pinned).map(e=>e.name)),[r]),{affordances:g,withheld:ee,observations:te}=Ne(Qe),I=ke(ee,E),f=I?st:ee,Xe=o===null?null:{face:o.face??"scene",on:o.on,about:s,field:o.field,place:o.place,href:o.href,act:o.act,element:o.returnTo},ne=Re(Xe),ie=te.some(e=>e.id.startsWith("schema:waits:")),{apply:Ze,preview:et}=Oe(),[C,z]=(0,a.useState)(null),[tt,re]=(0,a.useState)(!1),[oe,ae]=(0,a.useState)(!1),[L,R]=(0,a.useState)(""),nt=$e({letters:!0}),[le,K]=(0,a.useState)(null),_=(0,a.useRef)([]),j=(e,i)=>{try{return et(e,i),Ze(e,i),K(null),c(null),_.current=[],!0}catch(n){return K(ze(r.schema,r.allMutations(),n)),_.current=n instanceof be?n.issues.map(d=>String(d.path[0]??"")).filter(Boolean):[],!1}},$=[...new Set(s.flatMap(e=>{let i=r.graph.getNode(e);return i?[i.kind]:[]}))],x=$.length>0?$:[...new Set(s.flatMap(e=>Te(e)))],p=s.length===1?Ae(s[0]):null,U=p?{from:r.graph.getNode(p.from),to:r.graph.getNode(p.to)}:null,se=p?Le(r,p):void 0,de=se?.provisional?se:void 0,ue=p?(()=>{let e=r.schema.tryDefinition(r.graph.getNode(p.from)?.kind??"")?.edges?.[p.kind],i=r.graph.getNode(p.to);return e?.inverse&&i?`From ${S(r,i.id)}: ${e.inverse}`:null})():null;(0,a.useEffect)(()=>{z(null),re(!1),ae(!1),K(null),R("")},[s,o?.about]);let l=o!==null,it=u==="menu"&&!l,A=(0,a.useRef)(o);A.current=o;let pe=Ee("acts",{open:l&&u==="menu",onOpenChange:e=>{e||c(null)},at:()=>A.current?{x:A.current.x,y:A.current.y}:null,returnTo:()=>{let e=A.current?.returnTo;if(e?.isConnected)return e;let i=A.current?.on;return i?document.querySelector(`[data-graview-view="${CSS.escape(i)}"]`):null},align:"start"}),ce=(_e?.width??Number.POSITIVE_INFINITY)<Be;if((0,a.useLayoutEffect)(()=>{let e=y.current?.offsetParent;if(!e||!ce||l)return;let i=y.current?.getBoundingClientRect().height??0,n=`${Math.round(i)+20}px`;if(e.style.paddingBottom===n)return;let d=e.style.paddingBottom;return e.style.paddingBottom=n,()=>{e.style.paddingBottom=d}}),s.length===0&&!l)return null;let ge=o?.title!==void 0||s.length>0&&!(s.length===1&&s[0]===h.focusId),he=Math.max(1,Math.min(9,g.length)),T=[...g.filter(e=>e.provider==="invariant"&&!e.destructive),...g.filter(e=>e.pinned&&e.provider!=="invariant"&&!e.destructive),...g.filter(e=>!e.ties&&!e.destructive&&!e.pinned&&e.provider!=="invariant"),...g.filter(e=>e.ties&&!e.destructive&&!e.pinned&&e.provider!=="invariant"),...g.filter(e=>e.destructive)],me=T.length>he&&!l,fe=L.trim().toLowerCase(),w=me&&fe.length>0?T.filter(e=>`${e.label} ${e.why}`.toLowerCase().includes(fe)):null,V=w??(tt||l?T:T.slice(0,he)),ye=w?0:T.length-V.length,W=[];for(let e of V){let i=!l&&e.provider==="invariant",n=!l&&!i&&e.pinned!==void 0&&!e.destructive,d=!l&&!i&&!n&&e.ties===!0&&!e.destructive,k=i?e.why:n?"pinned":d?"its ties":null,D=i?"violation":n||d?"ties":null,H=W[W.length-1];H&&H.heading===k?H.items.push(e):W.push({heading:k,tone:D,items:[e]})}let G=g.find(e=>e.id===C),P=s.length===1?S(r,s[0]):null,ve=e=>{if(!P)return e;let i=e.startsWith(`"${P}"`)?e.slice(P.length+2):e.startsWith(P)?e.slice(P.length):null;if(i===null)return e;let n=i.trimStart();return n.length===0?e:n[0].toUpperCase()+n.slice(1)},rt=new Set(l?[]:V.filter(e=>e.provider==="invariant").map(e=>e.why)),M=te.filter(e=>!rt.has(e.text)).map(e=>({...e,text:ve(e.text)}));return it?null:(0,t.jsxs)("section",{...l?pe.pane:{},ref:e=>{y.current=e,l&&pe.pane.ref(e)},"aria-label":"Inspector","data-graview-offstage":"","data-testid":l?"context-menu":"inspector-strip",tabIndex:-1,onFocus:e=>Ke(e.target),onBlur:e=>{e.relatedTarget!==null&&(v.current=null)},onMouseDown:e=>e.stopPropagation(),style:{...l?He:{position:"absolute",zIndex:Se("rail")},boxSizing:"border-box",display:"flex",flexDirection:"column",gap:7,padding:"9px 12px",borderRadius:"var(--graview-radius, 12px)",border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)",...l?{width:300,maxHeight:"min(52cqh, 420px)",overflow:"auto"}:ce?{left:10,right:10,width:"auto",bottom:10,maxHeight:"min(42cqh, 300px)",overflow:"auto"}:{left:14,top:h.overview?"min(296px, 38cqh)":44,width:236,maxHeight:h.overview?"calc(100cqh - min(296px, 38cqh) - 20px)":"calc(68cqh - 94px)",overflow:"auto"}},children:[(0,t.jsx)("h2",{style:{...Ie,margin:0},children:"Inspector"}),(0,t.jsxs)("div",{style:{display:ge||!l?"flex":"none",alignItems:"baseline",flexWrap:"wrap",gap:"2px 8px",minWidth:0,paddingRight:l?0:24},children:[ge?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("strong",{style:{fontSize:"0.9375rem",whiteSpace:"nowrap"},children:o?.title??(s.length===1?S(r,s[0]):`${s.length} selected`)}),$.length>0||p?(0,t.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",whiteSpace:"nowrap"},children:p?"relation":$.map(e=>N(r.schema.tryDefinition(e),e)).join(" \xB7 ")}):null,s.length===1&&!p&&o?.face!=="pages"?(0,t.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",whiteSpace:"nowrap"},children:h.expanded.includes(s[0])?"\xB7 double-click closes":"\xB7 double-click opens"}):null]}):null,(0,t.jsx)("span",{style:{flex:"1 1 auto"}})]}),l?null:(0,t.jsx)("button",{type:"button",onClick:()=>{c(null),Ge()},"aria-label":"Clear selection",title:"Clear selection",style:{position:"absolute",top:6,right:6,flex:"0 0 auto",width:24,height:24,display:"grid",placeItems:"center",padding:0,fontSize:"0.875rem",lineHeight:1,borderRadius:7},children:"\xD7"}),p&&U?(0,t.jsxs)("div",{style:{display:"grid",gap:6},children:[ue?(0,t.jsx)("p",{"data-testid":"edge-said",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:ue}):null,de?(0,t.jsx)("p",{"data-testid":"edge-provisional",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:Pe(de)}):null,(0,t.jsx)("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[["from",U.from],["to",U.to]].map(([e,i],n)=>(0,t.jsxs)(a.Fragment,{children:[n===1?(0,t.jsx)("span",{"aria-hidden":"true",style:{color:"var(--graview-ink-faint)"},children:"\u2192"}):null,i?(0,t.jsx)("button",{type:"button","data-testid":`edge-${e}`,onClick:()=>Ve([i.id]),title:`Select ${S(r,i.id)}`,style:{fontSize:"0.8125rem",padding:"3px 9px",borderRadius:6},children:S(r,i.id)}):(0,t.jsx)("span",{style:{fontSize:"0.8125rem",color:"var(--graview-ink-faint)"},children:"gone"})]},e))})]}):null,!p&&s.length===1&&xe(r,s[0])?(0,t.jsx)("p",{"data-testid":"left-alone",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:"Left alone: nothing automated changes it."}):null,M.length>0?(0,t.jsx)("div",{"data-testid":"observations",title:M.map(e=>e.text).join(`
|
|
2
2
|
`),style:{display:"grid",gap:3},children:M.slice(0,2).map(e=>(0,t.jsxs)("p",{style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:[e.text,e===M[1]&&M.length>2?(0,t.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" +",M.length-2]}):null]},e.id))}):null,l?ne.start.map(e=>(0,t.jsx)(Fe,{section:e,close:()=>c(null)},e.id)):null,le?(0,t.jsx)("p",{"data-testid":"refused",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-warn)"},children:le}):null,me?(0,t.jsx)("input",{"data-testid":"action-filter",value:L,onChange:e=>R(e.target.value),placeholder:`Filter ${T.length} actions\u2026`,"aria-label":"Filter actions",onKeyDown:e=>{if(e.key==="Escape"){e.stopPropagation(),L.length>0?R(""):e.currentTarget.blur();return}if(e.key==="Enter"&&w?.length===1){let i=w[0];if(i.destructive)return;i.open.length>0?z(i.id):j(i)&&R("")}},style:{font:"inherit",fontSize:"0.875rem",padding:"5px 9px",borderRadius:8,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",color:"var(--graview-ink)"}}):null,w!==null&&w.length===0?(0,t.jsxs)("p",{"data-testid":"no-matches",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:["Nothing offered here matches \u201C",L.trim(),"\u201D."]}):null,I&&g.length===0||g.length===0&&!ie&&s.length===0?null:g.length===0&&!ie?(0,t.jsx)("p",{"data-testid":"no-affordances",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:f.length>0?`Nothing you may do with ${p?"this relation":x.length===1?Q(N(r.schema.tryDefinition(x[0]),x[0])):"this mix of kinds"} \u2014 ${f.length} action${f.length===1?"":"s"} withheld.`:p?`Nothing can be done with this line yet \u2014 nothing this app declares makes or breaks \u201C${Ce(r.schema,r.graph.getNode(p.from)?.kind??"",p.kind,"out")}\u201D.`:`Nothing can be done with ${x.length===1?Q(N(r.schema.tryDefinition(x[0]),x[0])):"this mix of kinds"} yet \u2014 nothing this app declares acts on ${x.length===1?"it":"them"}.`}):(0,t.jsxs)("ol",{...nt,"data-testid":"affordances",style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",flexWrap:"nowrap",gap:2},children:[W.map((e,i)=>(0,t.jsxs)(a.Fragment,{children:[e.heading?(0,t.jsxs)("li",{"data-graview-heading":e.tone,style:{fontSize:"0.75rem",lineHeight:1.4,color:e.tone==="violation"?"var(--graview-warn)":"var(--graview-ink-faint)",...e.tone!=="violation"?{letterSpacing:"0.12em",textTransform:"uppercase",fontSize:"0.75rem"}:{},padding:"2px 2px 1px",marginTop:i>0?6:0},children:[e.tone==="violation"?"\u26A0 ":"",e.tone==="violation"?ve(e.heading):e.heading]}):i>0?(0,t.jsx)("li",{"aria-hidden":"true",style:{borderTop:"1px solid var(--graview-edge)",margin:"6px 0 3px"}}):null,e.items.map(n=>(0,t.jsxs)("li",{style:{display:"flex",gap:2,alignItems:"stretch"},onKeyDown:d=>{if(d.metaKey||d.ctrlKey||d.altKey)return;let k=d.currentTarget.querySelector("[data-affordance]"),D=d.currentTarget.querySelector("[data-pin-for]"),H=d.target===D,we=d.key==="ArrowRight"&&!H?D:H&&["ArrowLeft","ArrowUp","ArrowDown"].includes(d.key)?k:null;we&&(d.preventDefault(),d.stopPropagation(),we.focus())},children:[(0,t.jsxs)("button",{type:"button",[X]:"","data-affordance":n.id,"data-rank":n.rank,"data-graview-destructive":n.destructive||void 0,"aria-pressed":C===n.id,title:n.why,style:{padding:"5px 10px",fontSize:"0.875rem",borderRadius:8,width:"100%",textAlign:"left",borderWidth:1,borderStyle:"solid",borderColor:C===n.id?"var(--graview-accent)":l?"transparent":"var(--graview-edge)",background:l?"none":"var(--graview-panel)",boxShadow:"none",...n.destructive?{color:"var(--graview-warn)"}:{},...C===n.id?{color:"var(--graview-accent)"}:{}},onClick:()=>{if(n.open.length>0){z(C===n.id?null:n.id);return}j(n)},children:[n.label,n.open.length>0?(0,t.jsx)("span",{style:{color:"var(--graview-ink-faint)"},children:" \u2026"}):null,w?.length===1&&w[0]?.id===n.id&&!n.destructive?(0,t.jsx)("span",{"aria-hidden":"true",title:"Enter runs it",style:{float:"right",color:"var(--graview-ink-faint)",fontSize:"0.75rem"},children:"\u21B5"}):null]}),(0,t.jsx)("button",{type:"button","data-testid":"pin-toggle",tabIndex:-1,"data-pin-for":n.mutation,"aria-pressed":n.pinned!==void 0,"aria-label":n.pinned!==void 0?`Unpin ${n.label}`:`Pin ${n.label}`,title:n.pinned==="declared"?"Pinned by the app \u2014 unpin it for yourself":n.pinned==="user"?"Unpin":"Pin to the top",onClick:()=>Ye(qe(q,n.mutation,Je.has(n.mutation))),style:{flex:"0 0 auto",width:24,minHeight:24,display:"grid",placeItems:"center",padding:0,fontSize:"0.75rem",border:"1px solid transparent",background:"none",boxShadow:"none",borderRadius:7,color:n.pinned==="user"?"var(--graview-accent)":n.pinned==="declared"?"var(--graview-ink-muted)":"var(--graview-ink-faint)"},children:n.pinned!==void 0?"\u2605":"\u2606"})]},n.id))]},`${e.heading??"plain"}-${i}`)),ye>0?(0,t.jsx)("li",{children:(0,t.jsxs)("button",{type:"button",[X]:"",onClick:()=>re(!0),title:`Show all ${g.length} actions`,style:{padding:"4px 10px",fontSize:"0.875rem",borderRadius:8},children:["Show ",ye," more"]})}):null]}),I?(0,t.jsx)("button",{type:"button","data-testid":"sign-in",onClick:()=>{c(null),I.run()},style:{padding:"5px 10px",fontSize:"0.875rem",borderRadius:8,width:"100%",textAlign:"left"},children:I.label}):null,f.length>0?(0,t.jsxs)("ul",{"data-testid":"withheld",style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",flexWrap:"nowrap",gap:2},children:[f.slice(0,l||oe?f.length:3).map(e=>(0,t.jsxs)("li",{style:{display:"grid",gap:2},children:[(0,t.jsx)("button",{type:"button",disabled:!0,"data-affordance":e.id,"data-rank":e.rank,"data-withheld":e.refusal.wouldNeed.join(",")||"nobody",style:{padding:"4px 10px",fontSize:"0.875rem",borderRadius:8,borderStyle:"dashed",width:"100%",textAlign:"left",background:"none"},children:(0,t.jsx)("s",{children:e.label})}),(0,t.jsx)("span",{"data-testid":"withheld-why",style:{fontSize:"0.8125rem",lineHeight:1.4,color:"var(--graview-ink-muted)",padding:"0 10px"},children:e.refusal.message})]},e.id)),!l&&!oe&&f.length>3?(0,t.jsx)("li",{children:(0,t.jsxs)("button",{type:"button","data-testid":"withheld-more",onClick:()=>ae(!0),title:`Show all ${f.length} actions this seat may not take`,style:{padding:"4px 10px",fontSize:"0.875rem",borderRadius:8},children:["Show ",f.length-3," more withheld"]})}):null]}):null,l?ne.end.map(e=>(0,t.jsx)(Fe,{section:e,close:()=>c(null)},e.id)):null,G?(0,t.jsx)(We,{affordance:G,onApply:e=>{if(j(G,e))z(null);else return _.current},onCancel:()=>z(null)}):null]})}var st=[];function Fe({section:u,close:r}){return(0,t.jsxs)("div",{"data-menu-section":u.id,...u.heading?{role:"group","aria-label":u.heading}:{},style:{display:"grid",gap:2,borderTop:"1px solid var(--graview-edge)",paddingTop:5},children:[u.heading?(0,t.jsx)("p",{"aria-hidden":"true",style:{margin:0,padding:"2px 2px 1px",fontSize:"0.75rem",lineHeight:1.4,letterSpacing:"0.12em",textTransform:"uppercase",color:"var(--graview-ink-faint)"},children:u.heading}):null,u.items&&u.items.length>0?(0,t.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:2},children:u.items.map(o=>(0,t.jsx)("li",{children:(0,t.jsxs)("button",{type:"button","data-menu-item":o.id,onClick:()=>{r(),o.run()},style:{padding:"5px 10px",fontSize:"0.875rem",borderRadius:8,width:"100%",textAlign:"left",borderWidth:1,borderStyle:"solid",borderColor:"transparent",background:"none",boxShadow:"none"},children:[o.label,o.hint?(0,t.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",o.hint]}):null]})},o.id))}):null,u.render?.(r)]})}export{xt as InspectorPane,bt as prepareActs};
|
|
@@ -1,3 +1,3 @@
|
|
|
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 Ue}from"./chunk.OGF6UORU.js";import{a as Be}from"./chunk.3TBH2FMZ.js";import{a as We}from"./chunk.QNJYXB3U.js";import{a as X}from"./chunk.TI4OSTQV.js";import{a as fe}from"./chunk.PL2P2OON.js";import{e as ce}from"./chunk.FNXW46U4.js";import{E as we,G as ln,J as He,P as Le,R as Fe,_ as Je}from"./chunk.4JWT6LIS.js";import{Ib as Ne,Nb as le,Pb as je,ca as ae,ea as U,ga as q,ja as Ee,la as de,qb as Me,wc as De}from"./chunk.AW2T3KFV.js";import{b as Se}from"./chunk.AJZBJBMO.js";var cn=e=>/^(?:aggregate|kind):([^,]+)$/.exec(e)?.[1];function Ge(e,n){let t=e.about??[];if(e.field!==void 0&&e.on!==void 0&&n(e.on))return{on:"field",id:e.on,field:e.field};let i=t.filter(n);if(i.length>1)return{on:"selection",ids:i};if(e.on!==void 0&&n(e.on))return{on:"record",id:e.on};if(i.length===1)return{on:"record",id:i[0]};let o=[e.on,...t].map(s=>s===void 0?void 0:cn(s)).find(s=>s!==void 0);return e.place!==void 0?{on:"lens",place:e.place,...o?{kind:o}:{}}:o!==void 0?{on:"list",kind:o}:{on:"place",place:"home"}}var V=e=>e.on==="record"||e.on==="field"?[e.id]:e.on==="selection"?e.ids:e.on==="act"&&e.id!==void 0?[e.id]:[],ue=(e,n)=>e.tryDefinition(n)?.fields?.shape??{},K=(e,n)=>e.tryDefinition(n)?.edges??{},pe=(e,n)=>new Set(e.tryDefinition(n)?.display?.hide??[]),H=(e,n)=>ae(e.tryDefinition(n.kind),n),xe=(e,n,t)=>Ee(e.tryDefinition(n),t)||U(t),Oe=e=>typeof e=="boolean"?e?"yes":"no":String(e);function ge(e,n){let t=e.kindsKeptFrom(n);return new Set(e.schema.kinds.filter(i=>!t.has(i)))}function Ce(e,n,t,i){if(!e.permits(n,t).ok)return!1;if(!i)return!0;try{return e.previewAll([n],{author:t}).ops.length>0}catch{return!1}}function ye(e,n,t){let i=e,{principal:o}=t,s=t.each??8,c=X(i)?.store??i,d=c.seenBy(o),l=c.schema,p=ge(c,o),a=r=>{let y=d.graph.getNode(r);return y&&p.has(y.kind)?y:void 0},f=c.allMutations(),h=new Map(f.map(r=>[r.name,r])),b=[],P=new Set,S=r=>{P.has(r.id)||(P.add(r.id),b.push(r))},m=r=>r.slice(0,s),C=V(n).filter(r=>a(r)!==void 0);if(V(n).length>0&&C.length===0)return{target:n,candidates:[]};let k=C.length===1?a(C[0]):void 0,g=k?.kind??(n.on==="list"?n.kind:n.on==="lens"?n.kind??t.places?.find(r=>r.as===n.place)?.kind:void 0)??(n.on==="selection"?a(C[0])?.kind:void 0);if(g!==void 0&&!p.has(g))return{target:n,candidates:[]};let A=(r,y)=>`act:${r}${Object.keys(y).length>0?`:${Object.values(y).map(T=>String(T)).join(",")}`:""}`,w=(r,y,T,v,$)=>{r.destructive||Object.values(y).some(u=>typeof u=="string"&&c.graph.has(u)&&a(u)===void 0)||Ce(c,{name:r.name,args:{...y}},o,v.length===0)&&S({type:"act",id:A(r.name,y),label:T,description:$??r.description??T,mutation:r.name,args:y,asks:v})};if(n.on!=="place"||t.acts)if(t.acts)for(let r of t.acts){let y=h.get(r.mutation);!y||r.destructive||n.on==="act"&&r.mutation!==n.act||w(y,r.args,r.label,(r.open??[]).filter(T=>!T.optional).map(T=>T.name),r.why)}else{let r=k?[k]:[];for(let y of f){if(n.on==="act"&&y.name!==n.act)continue;let T=y.input.shape??{},v=$=>Object.entries(T).filter(([u,O])=>u!==$&&O.safeParse?.(void 0).success===!1).map(([u])=>u);if(y.subject)for(let $ of r)le(l,y).includes($.kind)&&w(y,{[y.subject.arg]:$.id},`${y.title??U(y.name)}: ${H(l,$)}`,v(y.subject.arg));else g!==void 0&&(y.creates??[]).includes(g)&&w(y,{},y.title??U(y.name),v(void 0))}}let M=b.filter(r=>r.type==="act");b.splice(0,b.length,...m(M));let L=(r,y)=>{let T=je(l,f).get(r.kind),v=ue(l,r.kind),$=pe(l,r.kind),u=[];for(let[O,j]of Object.entries(v)){if(y!==void 0?O!==y:$.has(O)||r[O]!==void 0)continue;let D=fe(j),z=D?.type==="enum"?D.options??[]:D?.type==="boolean"?[!0,!1]:[];if(z.length===0)continue;let W=(T?.get(O)??[]).map(N=>h.get(N)).find(N=>N?.subject!==void 0&&Ce(c,{name:N.name,args:{[N.subject.arg]:r.id,[O]:z.find(Ae=>Ae!==r[O])??z[0]}},o,!0));if(W?.subject)for(let N of z)r[O]!==N&&u.push({type:"fill",id:`fill:${r.id}:${O}:${Oe(N)}`,label:`${xe(l,r.kind,O)}: ${Oe(N)}`,description:`Set ${xe(l,r.kind,O).toLowerCase()} of ${H(l,r)} to ${Oe(N)}`,record:r.id,field:O,value:N,call:{name:W.name,args:{[W.subject.arg]:r.id,[O]:N}}})}for(let[O,j]of Object.entries(K(l,r.kind))){if(y!==void 0&&O!==y)continue;let D=j.to==="*"?[...p]:j.to.filter(R=>p.has(R)),z=new Set(d.graph.out(r.id,O).map(R=>R.id)),W=f.find(R=>(R.connects??[]).includes(O)&&R.subject!==void 0&&le(l,R).includes(r.kind));if(!W?.subject)continue;let N=Ne(W.input).find(R=>R.name!==W.subject.arg);if(!N)continue;let Ae=D.flatMap(R=>N.kinds.length===0||N.kinds.includes(R)?d.graph.nodesOfKind(R):[]).filter(R=>R.id!==r.id&&!z.has(R.id)&&a(R.id)!==void 0);for(let R of m(Ae)){let Re={name:W.name,args:{[W.subject.arg]:r.id,[N.name]:R.id}};Ce(c,Re,o,!0)&&u.push({type:"fill",id:`fill:${r.id}:${O}:${R.id}`,label:`${U(O)}: ${H(l,R)}`,description:`Link ${H(l,r)} to ${H(l,R)}${j.description?` as ${j.description}`:""}`,record:r.id,field:O,value:R.id,call:Re})}}return u};if(n.on==="field"&&k)for(let r of L(k,n.field))S(r);else if(k&&n.on==="record")for(let r of m(L(k)))S(r);let J=r=>{let y=q(l,r).toLowerCase(),T=[{type:"panel",id:`panel:${r}:list`,label:`A list of ${y}`,description:`Every ${de(l.tryDefinition(r),r).toLowerCase()} this viewer may see, as a list`,panel:{lens:"blocks",kind:r}}],v=pe(l,r);for(let[$,u]of Object.entries(ue(l,r))){if(v.has($))continue;let O=fe(u),j=xe(l,r,$).toLowerCase();if(O?.type==="enum")T.push({type:"panel",id:`panel:${r}:group:${$}`,label:`${_(y)} by ${j}`,description:`A list of ${y} grouped by ${j}`,panel:{lens:"blocks",kind:r,group:$}}),T.push({type:"panel",id:`panel:${r}:columns:${$}`,label:`Columns of ${y} by ${j}`,description:`${_(y)} in a column for each ${j}`,panel:{lens:"columns",kind:r,column:$}});else if(O?.type==="number"||O?.type==="integer"||O?.type==="date"||O?.type==="datetime"){let D=O.type==="date"||O.type==="datetime";T.push({type:"panel",id:`panel:${r}:sort:${$}`,label:`${_(y)} by ${j}`,description:`A list of ${y}, the ${D?"latest":"highest"} ${j} first`,panel:{lens:"blocks",kind:r,sort:{by:$,direction:"desc"}}}),D&&T.push({type:"panel",id:`panel:${r}:calendar:${$}`,label:`A calendar of ${y}`,description:`${_(y)} on a calendar by ${j}`,panel:{lens:"calendar",kind:r,start:$}})}}return T},F=n.on==="place"?[...p]:g!==void 0?[g]:[];for(let r of F)for(let y of m(J(r)))S(y);for(let r of m((t.places??[]).filter(y=>y.kind===void 0?n.on==="place":p.has(y.kind)&&(n.on==="place"||y.kind===g))))n.on==="lens"&&r.as===n.place||S({type:"place",id:`place:${r.as}`,label:r.title,description:`Go to ${r.title}`,place:r.as});if(k){let r=[];for(let[y,T]of Object.entries(K(l,k.kind)))for(let v of d.graph.out(k.id,y))a(v.id)&&r.push({type:"record",id:`record:${v.id}`,label:H(l,v),description:`${_(T.description??U(y))}: ${H(l,v)}`,record:v.id,relation:y});for(let y of l.kinds)for(let[T,v]of Object.entries(K(l,y)))if(!(v.to!=="*"&&!v.to.includes(k.kind)))for(let $ of d.graph.in(k.id,T))$.kind===y&&a($.id)&&r.push({type:"record",id:`record:${$.id}`,label:H(l,$),description:`${_(v.inverse??U(T))}: ${H(l,$)}`,record:$.id,relation:T});for(let y of m(r))S(y)}else if(n.on==="list"||n.on==="lens")for(let r of m(g!==void 0?d.graph.nodesOfKind(g):[]))a(r.id)&&S({type:"record",id:`record:${r.id}`,label:H(l,r),description:`Open ${H(l,r)}`,record:r.id});else if(n.on==="selection")for(let r of C){let y=a(r);S({type:"record",id:`record:${r}`,label:H(l,y),description:`Open ${H(l,y)}`,record:r})}return{target:n,candidates:b}}var _=e=>e&&`${e[0].toUpperCase()}${e.slice(1)}`,fn={columns:["board","kanban","column","lane","pipeline","stage","funnel"],board:["board","map","floor","layout","seat","slot"],calendar:["calendar","schedule","date","due","month","week","agenda","deadline","day"],timeline:["timeline","gantt","schedule","roadmap","span"],coverage:["coverage","matrix","grid","gap"],plan:["plan","floor","map","region","area"],blocks:["list","table","summary","overview","dashboard","card"]},un=new Set(["a","an","the","of","for","my","our","me","us","to","with","and","in","on","by","that","which","i","we","want","need","show","open","go","draw","make","new","view","views","panel","panels","page","lens","please","all","every","some","see","can","could","would","like","one","what","is","are","do","does","here","there","how","it","this","these","those"]),Z=e=>e.length>3&&e.endsWith("ies")?`${e.slice(0,-3)}y`:e.length>3&&e.endsWith("s")&&!e.endsWith("ss")?e.slice(0,-1):e,$e=e=>e.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").split(/[^a-z0-9]+/).filter(Boolean);function ze(e,n,t){let i=e,o=X(i)?.store??i,s=o.schema,c=ge(o,t.principal),d=o.seenBy(t.principal),l=V(n),p=new Set;for(let A of l){let w=d.graph.getNode(A)?.kind;w!==void 0&&c.has(w)&&p.add(w)}if(l.length>0&&p.size===0)return[];if(n.on==="list"&&p.add(n.kind),n.on==="lens"){let A=n.kind??t.places.find(w=>w.as===n.place)?.kind;A!==void 0&&p.add(A)}let a=new Map;for(let A of s.kinds){if(!c.has(A))continue;let w=s.tryDefinition(A);for(let M of[A,de(w,A),q(s,A)])for(let L of $e(M))a.set(Z(L),A)}let f=$e(t.said??"").filter(A=>!un.has(A)),h=new Set,b=[];for(let A of f){let w=a.get(Z(A));w!==void 0?h.add(w):b.push(Z(A))}let P=h.size>0?h:p;if((t.said??"").trim()!==""&&f.length===0)return[];if(P.size===0&&f.length===0)return[];let S=[];t.places.forEach((A,w)=>{if(A.hidden||n.on==="lens"&&A.as===n.place)return;let M=A.over??(A.kind!==void 0?[A.kind]:[]);if(M.length>0&&!M.some(F=>c.has(F)))return;let L=M.some(F=>P.has(F)),J=!L&&(A.reads??[]).some(F=>P.has(F));P.size>0&&!L&&!J||S.push({place:A,own:L,reads:J,at:w})});let m=A=>new Set($e(A.title).map(Z)),C=new Set(b.filter(A=>S.some(({place:w})=>m(w).has(A)))),k=[];for(let{place:A,own:w,reads:M,at:L}of S){let J=m(A),F=new Set((fn[A.lens??""]??[]).map(Z)),r=b.filter($=>J.has($)||F.has($)&&!C.has($)).length,y=b.length-r;if(b.length>0&&r===0)continue;let T=!M&&y===0?"full":"partial",v=(w?4:M?2:1)+r*2-y+(T==="full"?1:0);k.push({view:{place:A.as,title:A.title,...A.kind!==void 0?{kind:A.kind}:{},fit:T},score:v,at:L})}return k.filter((A,w)=>!k.slice(0,w).some(M=>M.view.place===A.view.place&&M.view.title===A.view.title)).sort((A,w)=>w.score-A.score||A.at-w.at).slice(0,t.most??3).map(A=>A.view)}var Pe=new WeakMap;function pn(e){let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619)>>>0;return n.toString(36)}function gn(e,n){let t=e,i=X(t)?.store??t,o=i.schema,s=ge(i,n),d=i.allMutations().filter(S=>!S.destructive&&i.permits({name:S.name,args:{}},n).ok!==!1),l=`${[...s].join(",")}|${d.map(S=>S.name).join(",")}`,p=Pe.get(o)?.get(l);if(p)return p;let a=[...s].map(S=>{let m=pe(o,S),C={};for(let[g,A]of Object.entries(ue(o,S))){if(m.has(g))continue;let w=fe(A);w&&(C[g]=w.type==="enum"?`enum:${(w.options??[]).join("|")}`:w.type)}let k={};for(let[g,A]of Object.entries(K(o,S)))k[g]=A.to==="*"?[...s]:A.to.filter(w=>s.has(w));return{kind:S,noun:de(o.tryDefinition(S),S),plural:q(o,S),fields:C,relations:k}}),f=d.map(S=>({name:S.name,title:S.title??U(S.name),...S.subject?{on:le(o,S).filter(m=>s.has(m))}:{}})),h={kinds:a,acts:f},b={version:pn(JSON.stringify(h)),...h},P=Pe.get(o)??new Map;return P.set(l,b),Pe.set(o,P),b}var yn=e=>e.name??e.id??e.kind;function qe(e,n,t){let i=e,{principal:o}=t,s=X(i)?.store??i,c=s.seenBy(o),d=s.schema,l=ge(s,o),p=k=>{let g=c.graph.getNode(k);return g&&l.has(g.kind)?g:void 0},a=k=>({id:k.id,kind:k.kind,label:H(d,k)}),f=V(n),h=f.length===1?p(f[0]):void 0,b=h?Object.fromEntries(Object.keys(ue(d,h.kind)).filter(k=>!pe(d,h.kind).has(k)&&h[k]!==void 0&&k!=="label").map(k=>[k,h[k]])):{},P={on:n.on,...h?{record:{...a(h),fields:b}}:{},...n.on==="field"&&h?{field:n.field}:{},...n.on==="list"&&l.has(n.kind)?{kind:n.kind}:{},...n.on==="lens"?{place:n.place,...n.kind&&l.has(n.kind)?{kind:n.kind}:{}}:{},...n.on==="place"?{place:n.place}:{},...n.on==="act"?{act:n.act}:{}},S=[...new Set([...n.on==="selection"?n.ids:[],...t.selection??[]])].flatMap(k=>{let g=p(k);return g?[a(g)]:[]}),m=[];if(h){for(let k of Object.keys(K(d,h.kind)))for(let g of c.graph.out(h.id,k))p(g.id)&&m.push({...a(g),relation:k,direction:"out"});for(let k of d.kinds)for(let g of Object.keys(K(d,k)))for(let A of c.graph.in(h.id,g))A.kind===k&&p(A.id)&&m.push({...a(A),relation:g,direction:"in"})}let C=c.batches().filter(k=>!k.ops.every(Me)).slice(-(t.recent??6)).reverse().map(k=>({intent:k.intent,at:k.at,by:yn(k.author)}));return{...t.place!==void 0?{place:t.place}:{},target:P,selection:S,neighbors:m.slice(0,24),recent:C,schema:gn(s,o)}}function ee(e){if(!e.off)return e.fast??(e.decide?{model:e.name??"decide",decide:e.decide}:void 0)}function B(e){if(e.off)return;if(e.thinking)return e.thinking;let n=e.name??"model";if(e.complete){let t=e.complete;return{model:n,think:async({system:i,prompt:o})=>({text:await t(`${i}
|
|
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 Ue}from"./chunk.UKAPFIPJ.js";import{a as Be}from"./chunk.WAB7UDHU.js";import{a as We}from"./chunk.R2AG4NHQ.js";import{a as X}from"./chunk.TI4OSTQV.js";import{a as fe}from"./chunk.UHX4WTM7.js";import{e as ce}from"./chunk.XSNAG4JT.js";import{E as we,G as ln,J as He,P as Le,R as Fe,_ as Je}from"./chunk.XWAMQPUM.js";import{Ib as Ne,Nb as le,Pb as je,ca as ae,ea as U,ga as q,ja as Ee,la as de,qb as Me,wc as De}from"./chunk.AS4CQBOQ.js";import{b as Se}from"./chunk.AJZBJBMO.js";var cn=e=>/^(?:aggregate|kind):([^,]+)$/.exec(e)?.[1];function Ge(e,n){let t=e.about??[];if(e.field!==void 0&&e.on!==void 0&&n(e.on))return{on:"field",id:e.on,field:e.field};let i=t.filter(n);if(i.length>1)return{on:"selection",ids:i};if(e.on!==void 0&&n(e.on))return{on:"record",id:e.on};if(i.length===1)return{on:"record",id:i[0]};let o=[e.on,...t].map(s=>s===void 0?void 0:cn(s)).find(s=>s!==void 0);return e.place!==void 0?{on:"lens",place:e.place,...o?{kind:o}:{}}:o!==void 0?{on:"list",kind:o}:{on:"place",place:"home"}}var V=e=>e.on==="record"||e.on==="field"?[e.id]:e.on==="selection"?e.ids:e.on==="act"&&e.id!==void 0?[e.id]:[],ue=(e,n)=>e.tryDefinition(n)?.fields?.shape??{},K=(e,n)=>e.tryDefinition(n)?.edges??{},pe=(e,n)=>new Set(e.tryDefinition(n)?.display?.hide??[]),H=(e,n)=>ae(e.tryDefinition(n.kind),n),xe=(e,n,t)=>Ee(e.tryDefinition(n),t)||U(t),Oe=e=>typeof e=="boolean"?e?"yes":"no":String(e);function ge(e,n){let t=e.kindsKeptFrom(n);return new Set(e.schema.kinds.filter(i=>!t.has(i)))}function Ce(e,n,t,i){if(!e.permits(n,t).ok)return!1;if(!i)return!0;try{return e.previewAll([n],{author:t}).ops.length>0}catch{return!1}}function ye(e,n,t){let i=e,{principal:o}=t,s=t.each??8,c=X(i)?.store??i,d=c.seenBy(o),l=c.schema,p=ge(c,o),a=r=>{let y=d.graph.getNode(r);return y&&p.has(y.kind)?y:void 0},f=c.allMutations(),h=new Map(f.map(r=>[r.name,r])),b=[],P=new Set,S=r=>{P.has(r.id)||(P.add(r.id),b.push(r))},m=r=>r.slice(0,s),C=V(n).filter(r=>a(r)!==void 0);if(V(n).length>0&&C.length===0)return{target:n,candidates:[]};let k=C.length===1?a(C[0]):void 0,g=k?.kind??(n.on==="list"?n.kind:n.on==="lens"?n.kind??t.places?.find(r=>r.as===n.place)?.kind:void 0)??(n.on==="selection"?a(C[0])?.kind:void 0);if(g!==void 0&&!p.has(g))return{target:n,candidates:[]};let A=(r,y)=>`act:${r}${Object.keys(y).length>0?`:${Object.values(y).map(T=>String(T)).join(",")}`:""}`,w=(r,y,T,v,$)=>{r.destructive||Object.values(y).some(u=>typeof u=="string"&&c.graph.has(u)&&a(u)===void 0)||Ce(c,{name:r.name,args:{...y}},o,v.length===0)&&S({type:"act",id:A(r.name,y),label:T,description:$??r.description??T,mutation:r.name,args:y,asks:v})};if(n.on!=="place"||t.acts)if(t.acts)for(let r of t.acts){let y=h.get(r.mutation);!y||r.destructive||n.on==="act"&&r.mutation!==n.act||w(y,r.args,r.label,(r.open??[]).filter(T=>!T.optional).map(T=>T.name),r.why)}else{let r=k?[k]:[];for(let y of f){if(n.on==="act"&&y.name!==n.act)continue;let T=y.input.shape??{},v=$=>Object.entries(T).filter(([u,O])=>u!==$&&O.safeParse?.(void 0).success===!1).map(([u])=>u);if(y.subject)for(let $ of r)le(l,y).includes($.kind)&&w(y,{[y.subject.arg]:$.id},`${y.title??U(y.name)}: ${H(l,$)}`,v(y.subject.arg));else g!==void 0&&(y.creates??[]).includes(g)&&w(y,{},y.title??U(y.name),v(void 0))}}let M=b.filter(r=>r.type==="act");b.splice(0,b.length,...m(M));let L=(r,y)=>{let T=je(l,f).get(r.kind),v=ue(l,r.kind),$=pe(l,r.kind),u=[];for(let[O,j]of Object.entries(v)){if(y!==void 0?O!==y:$.has(O)||r[O]!==void 0)continue;let D=fe(j),z=D?.type==="enum"?D.options??[]:D?.type==="boolean"?[!0,!1]:[];if(z.length===0)continue;let W=(T?.get(O)??[]).map(N=>h.get(N)).find(N=>N?.subject!==void 0&&Ce(c,{name:N.name,args:{[N.subject.arg]:r.id,[O]:z.find(Ae=>Ae!==r[O])??z[0]}},o,!0));if(W?.subject)for(let N of z)r[O]!==N&&u.push({type:"fill",id:`fill:${r.id}:${O}:${Oe(N)}`,label:`${xe(l,r.kind,O)}: ${Oe(N)}`,description:`Set ${xe(l,r.kind,O).toLowerCase()} of ${H(l,r)} to ${Oe(N)}`,record:r.id,field:O,value:N,call:{name:W.name,args:{[W.subject.arg]:r.id,[O]:N}}})}for(let[O,j]of Object.entries(K(l,r.kind))){if(y!==void 0&&O!==y)continue;let D=j.to==="*"?[...p]:j.to.filter(R=>p.has(R)),z=new Set(d.graph.out(r.id,O).map(R=>R.id)),W=f.find(R=>(R.connects??[]).includes(O)&&R.subject!==void 0&&le(l,R).includes(r.kind));if(!W?.subject)continue;let N=Ne(W.input).find(R=>R.name!==W.subject.arg);if(!N)continue;let Ae=D.flatMap(R=>N.kinds.length===0||N.kinds.includes(R)?d.graph.nodesOfKind(R):[]).filter(R=>R.id!==r.id&&!z.has(R.id)&&a(R.id)!==void 0);for(let R of m(Ae)){let Re={name:W.name,args:{[W.subject.arg]:r.id,[N.name]:R.id}};Ce(c,Re,o,!0)&&u.push({type:"fill",id:`fill:${r.id}:${O}:${R.id}`,label:`${U(O)}: ${H(l,R)}`,description:`Link ${H(l,r)} to ${H(l,R)}${j.description?` as ${j.description}`:""}`,record:r.id,field:O,value:R.id,call:Re})}}return u};if(n.on==="field"&&k)for(let r of L(k,n.field))S(r);else if(k&&n.on==="record")for(let r of m(L(k)))S(r);let J=r=>{let y=q(l,r).toLowerCase(),T=[{type:"panel",id:`panel:${r}:list`,label:`A list of ${y}`,description:`Every ${de(l.tryDefinition(r),r).toLowerCase()} this viewer may see, as a list`,panel:{lens:"blocks",kind:r}}],v=pe(l,r);for(let[$,u]of Object.entries(ue(l,r))){if(v.has($))continue;let O=fe(u),j=xe(l,r,$).toLowerCase();if(O?.type==="enum")T.push({type:"panel",id:`panel:${r}:group:${$}`,label:`${_(y)} by ${j}`,description:`A list of ${y} grouped by ${j}`,panel:{lens:"blocks",kind:r,group:$}}),T.push({type:"panel",id:`panel:${r}:columns:${$}`,label:`Columns of ${y} by ${j}`,description:`${_(y)} in a column for each ${j}`,panel:{lens:"columns",kind:r,column:$}});else if(O?.type==="number"||O?.type==="integer"||O?.type==="date"||O?.type==="datetime"){let D=O.type==="date"||O.type==="datetime";T.push({type:"panel",id:`panel:${r}:sort:${$}`,label:`${_(y)} by ${j}`,description:`A list of ${y}, the ${D?"latest":"highest"} ${j} first`,panel:{lens:"blocks",kind:r,sort:{by:$,direction:"desc"}}}),D&&T.push({type:"panel",id:`panel:${r}:calendar:${$}`,label:`A calendar of ${y}`,description:`${_(y)} on a calendar by ${j}`,panel:{lens:"calendar",kind:r,start:$}})}}return T},F=n.on==="place"?[...p]:g!==void 0?[g]:[];for(let r of F)for(let y of m(J(r)))S(y);for(let r of m((t.places??[]).filter(y=>y.kind===void 0?n.on==="place":p.has(y.kind)&&(n.on==="place"||y.kind===g))))n.on==="lens"&&r.as===n.place||S({type:"place",id:`place:${r.as}`,label:r.title,description:`Go to ${r.title}`,place:r.as});if(k){let r=[];for(let[y,T]of Object.entries(K(l,k.kind)))for(let v of d.graph.out(k.id,y))a(v.id)&&r.push({type:"record",id:`record:${v.id}`,label:H(l,v),description:`${_(T.description??U(y))}: ${H(l,v)}`,record:v.id,relation:y});for(let y of l.kinds)for(let[T,v]of Object.entries(K(l,y)))if(!(v.to!=="*"&&!v.to.includes(k.kind)))for(let $ of d.graph.in(k.id,T))$.kind===y&&a($.id)&&r.push({type:"record",id:`record:${$.id}`,label:H(l,$),description:`${_(v.inverse??U(T))}: ${H(l,$)}`,record:$.id,relation:T});for(let y of m(r))S(y)}else if(n.on==="list"||n.on==="lens")for(let r of m(g!==void 0?d.graph.nodesOfKind(g):[]))a(r.id)&&S({type:"record",id:`record:${r.id}`,label:H(l,r),description:`Open ${H(l,r)}`,record:r.id});else if(n.on==="selection")for(let r of C){let y=a(r);S({type:"record",id:`record:${r}`,label:H(l,y),description:`Open ${H(l,y)}`,record:r})}return{target:n,candidates:b}}var _=e=>e&&`${e[0].toUpperCase()}${e.slice(1)}`,fn={columns:["board","kanban","column","lane","pipeline","stage","funnel"],board:["board","map","floor","layout","seat","slot"],calendar:["calendar","schedule","date","due","month","week","agenda","deadline","day"],timeline:["timeline","gantt","schedule","roadmap","span"],coverage:["coverage","matrix","grid","gap"],plan:["plan","floor","map","region","area"],blocks:["list","table","summary","overview","dashboard","card"]},un=new Set(["a","an","the","of","for","my","our","me","us","to","with","and","in","on","by","that","which","i","we","want","need","show","open","go","draw","make","new","view","views","panel","panels","page","lens","please","all","every","some","see","can","could","would","like","one","what","is","are","do","does","here","there","how","it","this","these","those"]),Z=e=>e.length>3&&e.endsWith("ies")?`${e.slice(0,-3)}y`:e.length>3&&e.endsWith("s")&&!e.endsWith("ss")?e.slice(0,-1):e,$e=e=>e.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").split(/[^a-z0-9]+/).filter(Boolean);function ze(e,n,t){let i=e,o=X(i)?.store??i,s=o.schema,c=ge(o,t.principal),d=o.seenBy(t.principal),l=V(n),p=new Set;for(let A of l){let w=d.graph.getNode(A)?.kind;w!==void 0&&c.has(w)&&p.add(w)}if(l.length>0&&p.size===0)return[];if(n.on==="list"&&p.add(n.kind),n.on==="lens"){let A=n.kind??t.places.find(w=>w.as===n.place)?.kind;A!==void 0&&p.add(A)}let a=new Map;for(let A of s.kinds){if(!c.has(A))continue;let w=s.tryDefinition(A);for(let M of[A,de(w,A),q(s,A)])for(let L of $e(M))a.set(Z(L),A)}let f=$e(t.said??"").filter(A=>!un.has(A)),h=new Set,b=[];for(let A of f){let w=a.get(Z(A));w!==void 0?h.add(w):b.push(Z(A))}let P=h.size>0?h:p;if((t.said??"").trim()!==""&&f.length===0)return[];if(P.size===0&&f.length===0)return[];let S=[];t.places.forEach((A,w)=>{if(A.hidden||n.on==="lens"&&A.as===n.place)return;let M=A.over??(A.kind!==void 0?[A.kind]:[]);if(M.length>0&&!M.some(F=>c.has(F)))return;let L=M.some(F=>P.has(F)),J=!L&&(A.reads??[]).some(F=>P.has(F));P.size>0&&!L&&!J||S.push({place:A,own:L,reads:J,at:w})});let m=A=>new Set($e(A.title).map(Z)),C=new Set(b.filter(A=>S.some(({place:w})=>m(w).has(A)))),k=[];for(let{place:A,own:w,reads:M,at:L}of S){let J=m(A),F=new Set((fn[A.lens??""]??[]).map(Z)),r=b.filter($=>J.has($)||F.has($)&&!C.has($)).length,y=b.length-r;if(b.length>0&&r===0)continue;let T=!M&&y===0?"full":"partial",v=(w?4:M?2:1)+r*2-y+(T==="full"?1:0);k.push({view:{place:A.as,title:A.title,...A.kind!==void 0?{kind:A.kind}:{},fit:T},score:v,at:L})}return k.filter((A,w)=>!k.slice(0,w).some(M=>M.view.place===A.view.place&&M.view.title===A.view.title)).sort((A,w)=>w.score-A.score||A.at-w.at).slice(0,t.most??3).map(A=>A.view)}var Pe=new WeakMap;function pn(e){let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619)>>>0;return n.toString(36)}function gn(e,n){let t=e,i=X(t)?.store??t,o=i.schema,s=ge(i,n),d=i.allMutations().filter(S=>!S.destructive&&i.permits({name:S.name,args:{}},n).ok!==!1),l=`${[...s].join(",")}|${d.map(S=>S.name).join(",")}`,p=Pe.get(o)?.get(l);if(p)return p;let a=[...s].map(S=>{let m=pe(o,S),C={};for(let[g,A]of Object.entries(ue(o,S))){if(m.has(g))continue;let w=fe(A);w&&(C[g]=w.type==="enum"?`enum:${(w.options??[]).join("|")}`:w.type)}let k={};for(let[g,A]of Object.entries(K(o,S)))k[g]=A.to==="*"?[...s]:A.to.filter(w=>s.has(w));return{kind:S,noun:de(o.tryDefinition(S),S),plural:q(o,S),fields:C,relations:k}}),f=d.map(S=>({name:S.name,title:S.title??U(S.name),...S.subject?{on:le(o,S).filter(m=>s.has(m))}:{}})),h={kinds:a,acts:f},b={version:pn(JSON.stringify(h)),...h},P=Pe.get(o)??new Map;return P.set(l,b),Pe.set(o,P),b}var yn=e=>e.name??e.id??e.kind;function qe(e,n,t){let i=e,{principal:o}=t,s=X(i)?.store??i,c=s.seenBy(o),d=s.schema,l=ge(s,o),p=k=>{let g=c.graph.getNode(k);return g&&l.has(g.kind)?g:void 0},a=k=>({id:k.id,kind:k.kind,label:H(d,k)}),f=V(n),h=f.length===1?p(f[0]):void 0,b=h?Object.fromEntries(Object.keys(ue(d,h.kind)).filter(k=>!pe(d,h.kind).has(k)&&h[k]!==void 0&&k!=="label").map(k=>[k,h[k]])):{},P={on:n.on,...h?{record:{...a(h),fields:b}}:{},...n.on==="field"&&h?{field:n.field}:{},...n.on==="list"&&l.has(n.kind)?{kind:n.kind}:{},...n.on==="lens"?{place:n.place,...n.kind&&l.has(n.kind)?{kind:n.kind}:{}}:{},...n.on==="place"?{place:n.place}:{},...n.on==="act"?{act:n.act}:{}},S=[...new Set([...n.on==="selection"?n.ids:[],...t.selection??[]])].flatMap(k=>{let g=p(k);return g?[a(g)]:[]}),m=[];if(h){for(let k of Object.keys(K(d,h.kind)))for(let g of c.graph.out(h.id,k))p(g.id)&&m.push({...a(g),relation:k,direction:"out"});for(let k of d.kinds)for(let g of Object.keys(K(d,k)))for(let A of c.graph.in(h.id,g))A.kind===k&&p(A.id)&&m.push({...a(A),relation:g,direction:"in"})}let C=c.batches().filter(k=>!k.ops.every(Me)).slice(-(t.recent??6)).reverse().map(k=>({intent:k.intent,at:k.at,by:yn(k.author)}));return{...t.place!==void 0?{place:t.place}:{},target:P,selection:S,neighbors:m.slice(0,24),recent:C,schema:gn(s,o)}}function ee(e){if(!e.off)return e.fast??(e.decide?{model:e.name??"decide",decide:e.decide}:void 0)}function B(e){if(e.off)return;if(e.thinking)return e.thinking;let n=e.name??"model";if(e.complete){let t=e.complete;return{model:n,think:async({system:i,prompt:o})=>({text:await t(`${i}
|
|
2
2
|
|
|
3
|
-
${o}`)})}}if(e.turn){let t=e.turn;return{model:n,think:async({system:i,prompt:o})=>({text:await t({system:i,messages:[{role:"user",content:o}],tools:[],call:async()=>({error:"No tools here."})})})}}}var Te=(e,n,t)=>e?n/1e6*(e.inputPerMillion??0)+t/1e6*(e.outputPerMillion??0):void 0,ve=()=>`ai-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;function hn(e,n,t=[]){let i=o=>{let s=e.graph.getNode(o);return s?ae(e.schema.tryDefinition(s.kind),s):"a record"};switch(n.on){case"record":return i(n.id);case"field":return`${i(n.id)} \xB7 ${n.field}`;case"selection":return`${n.ids.length} records`;case"list":return e.schema.tryDefinition(n.kind)?q(e.schema,n.kind):n.kind;case"lens":case"place":return t.find(o=>o.as===n.place)?.title??(n.place==="home"?"Home":n.place);case"act":return n.act}}var _e=e=>e.type!=="act"||e.asks.length===0,me=(e,n)=>({id:e.id,type:e.type,label:e.label,...n!==void 0?{confidence:n}:{}});function Q(e,n){let t=n.interaction??ve(),i=ye(n.store,n.target,{principal:n.principal,...n.acts?{acts:n.acts}:{},...n.places?{places:n.places}:{}}),o=qe(n.store,n.target,{principal:n.principal,...n.place?{place:n.place}:{},...n.selection?{selection:n.selection}:{}}),s=[];return{id:t,catalog:i,state:o,entry:{id:t,at:new Date().toISOString(),by:n.by??n.principal,target:n.target,targetLabel:hn(n.store,n.target,n.places)},usage:s,meter:c=>{s.push(c),e.meter?.({...c,interaction:t})}}}async function ne(e,n,t,i){let o=await e.decide(n,t),{inputTokens:s,outputTokens:c}=o.usage,d=Te(e.price,s,c);return i({tier:"fast",model:e.model,inputTokens:s,outputTokens:c,...d!==void 0?{costUsd:d}:{}}),o.answers}async function te(e,n,t,i,o){let s=await e.think({system:n,prompt:t,state:i.state,catalog:i.catalog}),c=s.usage?.inputTokens,d=s.usage?.outputTokens,l=s.usage?.costUsd??(c!==void 0?Te(e.price,c,d??0):void 0);return o({tier:"thinking",model:e.model,...c!==void 0?{inputTokens:c}:{},...d!==void 0?{outputTokens:d}:{},...l!==void 0?{costUsd:l}:{}}),Be(s.text)}function ie(e,n){let t=new Map(e.map((i,o)=>[`c${o+1}`,i]));return{question:{type:"choice",instructions:n,criteria:Object.fromEntries([...t].map(([i,o])=>[i,`${o.label} \u2014 ${o.description}`]))},of:i=>t.get(i)}}function oe(e,n,t){if(e?.type!=="choice")return[];let i=e,o=Object.entries(i.probabilities).sort((s,c)=>c[1]-s[1]);return o.some(([s])=>s===i.choice)||o.unshift([i.choice,i.confidence]),o.flatMap(([s,c])=>{let d=n(s);return d?[{candidate:d,confidence:c}]:[]}).slice(0,t)}var E=(e,n,t,i)=>({interaction:{...e.entry,ask:{kind:t,said:n??""},offered:[],outcome:"failed",failed:i,usage:[...e.usage]},offers:[]}),Y="AI isn't on here.";async function Ke(e,n,t=3){let i=Q(e,n),o=n.said??"Suggest",s=i.catalog.candidates.filter(_e).slice(0,24);if(s.length===0)return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:[],outcome:"offered",usage:[]},offers:[]};let c=ee(e),d=B(e),l=[];try{if(c){let{question:p,of:a}=ie(s,"Which of these would the person most likely want to do next, here?"),f=await ne(c,{...i.state,candidates:s.map(h=>({id:h.id,type:h.type,says:h.description}))},{next:p},i.meter);l=oe(f.next,a,t)}else if(d){let p=await te(d,'You suggest what a person most likely wants to do next in an app. Answer only JSON: {"pick": [candidate ids, best first]}. Pick only ids from the candidates.',JSON.stringify({state:i.state,candidates:s.map(f=>({id:f.id,says:f.description}))}),i,i.meter);l=(Array.isArray(p?.pick)?p.pick.filter(f=>typeof f=="string"):[]).flatMap(f=>s.filter(h=>h.id===f)).slice(0,t).map(f=>({candidate:f}))}else return E(i,o,"suggest",Y)}catch(p){return E(i,o,"suggest",p instanceof Error?p.message:String(p))}return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:l.map(({candidate:p,confidence:a})=>me(p,a)),outcome:"offered",usage:[...i.usage]},offers:l.map(({candidate:p})=>p)}}var mn=e=>`several:${e}`;async function Fn(e,n,t=2){let i=Q(e,{...n,acts:[]}),o=n.said??"Suggest for the chosen",s=n.target.on==="selection"?n.target.ids.length:1,d=[...n.shared.map(a=>({type:"act",id:mn(a.id),label:a.label,description:`${a.label}, for all ${s} chosen`,mutation:a.mutation,args:a.args,asks:[]})),...i.catalog.candidates.filter(a=>a.type==="panel"||a.type==="place")].slice(0,24),l=ee(e);if(!l)return E(i,o,"suggest",Y);if(d.length===0)return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:[],outcome:"offered",usage:[]},offers:[]};let p;try{let{question:a,of:f}=ie(d,`Which of these would the person most likely want to do next with the ${s} records they chose together?`),h=await ne(l,{...i.state,candidates:d.map(b=>({id:b.id,type:b.type,says:b.description}))},{next:a},i.meter);p=oe(h.next,f,t).filter((b,P)=>P===0||b.confidence>=kn)}catch(a){return E(i,o,"suggest",a instanceof Error?a.message:String(a))}return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:p.map(({candidate:a,confidence:f})=>me(a,f)),outcome:"offered",usage:[...i.usage]},offers:p.map(({candidate:a})=>a)}}var kn=.25;async function Ve(e,n){let t=Q(e,n),i=n.said??"Fill in",o=t.catalog.candidates.filter(f=>f.type==="fill"),s=new Map;for(let f of o)s.set(f.field,[...s.get(f.field)??[],f]);if(s.size===0)return{interaction:{...t.entry,ask:{kind:"fill",said:i},offered:[],outcome:"offered",usage:[]},offers:[]};let c=ee(e),d=B(e),l=[];try{if(c){let f=[...s].map(([b,P],S)=>({key:`f${S+1}`,field:b,...ie(P,`Which value fits "${b}" best for this record?`)})),h=await ne(c,t.state,Object.fromEntries(f.map(b=>[b.key,b.question])),t.meter);for(let b of f){let P=!bn(n.store,n.target,b.field)&&An(n.store,n.target,b.field)!=="one";l.push(...oe(h[b.key],b.of,P?3:1).filter((S,m)=>m===0||S.confidence>=.4))}}else if(d){let f=await te(d,`You fill in a record's fields in an app. Answer only JSON: {"fills": [candidate ids]}, at most one per field, only ids from the candidates.`,JSON.stringify({state:t.state,candidates:o.map(P=>({id:P.id,says:P.description}))}),t,t.meter),h=Array.isArray(f?.fills)?f.fills.filter(P=>typeof P=="string"):[],b=new Set;for(let P of h){let S=o.find(m=>m.id===P);S?.type==="fill"&&!b.has(S.field)&&(b.add(S.field),l.push({candidate:S}))}}else return E(t,i,"fill",Y)}catch(f){return E(t,i,"fill",f instanceof Error?f.message:String(f))}let p=t.usage.at(-1)?.model,a=se(n.store,{interaction:t.id,target:n.target,basis:i,...p?{model:p}:{},proposals:l.flatMap(({candidate:f,confidence:h})=>f.type==="fill"?[{id:f.id,label:f.label,said:f.description,call:f.call,record:f.record,field:f.field,...h!==void 0?{confidence:h}:{}}]:[])},n.principal);return{interaction:{...t.entry,ask:{kind:"fill",said:i},offered:a.proposals.map(f=>({id:f.id,type:"fill",label:f.label,...f.confidence!==void 0?{confidence:f.confidence}:{}})),outcome:"offered",usage:[...t.usage]},offers:[],...a.proposals.length>0?{ghost:a}:{}}}function bn(e,n,t){let i=n.on==="record"||n.on==="field"?n.id:void 0,o=i?e.graph.getNode(i)?.kind:void 0,s=(o?e.schema.tryDefinition(o)?.fields?.shape:void 0)??{};return t in s}function An(e,n,t){let i=n.on==="record"||n.on==="field"?n.id:void 0,o=i?e.graph.getNode(i)?.kind:void 0;return o?e.schema.tryDefinition(o)?.edges?.[t]?.cardinality:void 0}async function Qe(e,n){let t=Q(e,n),i=n.said??"Add one",o=new Set(n.store.allMutations().filter(a=>(a.creates??[]).length>0).map(a=>a.name)),s=t.catalog.candidates.filter(a=>a.type==="act"&&a.asks.length>0&&o.has(a.mutation));if(s.length===0)return E(t,i,"record","Nothing here makes a record.");let c=B(e);if(!c)return E(t,i,"record",Y);let d;try{let a=await te(c,'You propose one new record for an app by filling in an act. Answer only JSON: {"act": a candidate id, "args": {argument: value}}. Use only the candidates, and fill every argument the act asks for with a value that fits the state.',JSON.stringify({ask:i,state:t.state,candidates:s.map(b=>({id:b.id,says:b.description,asks:b.asks}))}),t,t.meter),f=s.find(b=>b.id===a?.act),h=typeof a?.args=="object"&&a.args!==null?a.args:{};f&&(d={act:f,args:Object.fromEntries(Object.entries(h).filter(([b])=>f.asks.includes(b)))})}catch(a){return E(t,i,"record",a instanceof Error?a.message:String(a))}if(!d)return E(t,i,"record","The model named no act this app has here.");let l=t.usage.at(-1)?.model,p=se(n.store,{interaction:t.id,target:n.target,basis:i,...l?{model:l}:{},proposals:[{id:d.act.id,label:d.act.label,said:d.act.description,call:{name:d.act.mutation,args:{...d.act.args,...d.args}}}]},n.principal);return p.proposals.length===0?E(t,i,"record","What the model proposed could not be made here."):{interaction:{...t.entry,ask:{kind:"record",said:i},offered:p.proposals.map(a=>({id:a.id,type:"act",label:a.said})),outcome:"offered",usage:[...t.usage]},offers:[d.act],ghost:p}}async function Ye(e,n){let t=Q(e,n),i=n.said??"Make a panel",o=t.catalog.candidates.filter(a=>a.type==="panel");if(o.length===0)return E(t,i,"panel","Nothing here can be drawn as a panel.");let s=ee(e),c=B(e),d;try{if(c){let a=await te(c,'You choose a panel to draw in an app. Answer only JSON: {"panel": a candidate id, "title": a short title}. Choose only among the candidates.',JSON.stringify({ask:i,state:t.state,candidates:o.map(h=>({id:h.id,says:h.description}))}),t,t.meter),f=o.find(h=>h.id===a?.panel);f&&(d={panel:f,...typeof a?.title=="string"&&a.title.trim()?{title:a.title.trim().slice(0,60)}:{}})}else if(s){let{question:a,of:f}=ie(o,`Which panel answers this best: ${i}`),h=oe((await ne(s,t.state,{panel:a},t.meter)).panel,f,1)[0];h?.candidate.type==="panel"&&(d={panel:h.candidate,confidence:h.confidence})}else return E(t,i,"panel",Y)}catch(a){return E(t,i,"panel",a instanceof Error?a.message:String(a))}if(!d)return E(t,i,"panel","The model named no panel this app can draw.");let l=d.title??d.panel.label,p={title:l,recipe:{...d.panel.panel,title:l}};return{interaction:{...t.entry,ask:{kind:"panel",said:i},offered:[me(d.panel,d.confidence)],outcome:"drawn",panel:p,usage:[...t.usage]},offers:[d.panel],panel:p}}function Sn(e){return e.off?void 0:e.answer}var wn=`You answer a person's question about what they are looking at in an app, from the state given and nothing else. Answer only JSON: {"answer": one to three short sentences, "pick": [candidate ids that act on the answer, best first, at most three]}. Pick only ids from the candidates, and none when nothing fits. Never say an id to the person.`;async function Jn(e,n){let t=Q(e,n),i=n.said.trim(),o=t.catalog.candidates.filter(m=>_e(m)||m.type==="panel"||m.type==="place"||m.type==="record").slice(0,32),s=Sn(e),c=B(e),d=ee(e),l="",p=[],a=m=>m.flatMap(C=>o.filter(k=>k.id===C)).slice(0,3).map(C=>({candidate:C}));try{if(s){let m=await s.answer({said:i,target:n.target,targetLabel:t.entry.targetLabel,state:t.state,catalog:{target:t.catalog.target,candidates:o},...n.follows?{follows:n.follows}:{}}),C=m.usage?.inputTokens,k=m.usage?.outputTokens,g=m.usage?.costUsd??(C!==void 0?Te(s.price,C,k??0):void 0);t.meter({tier:"thinking",model:s.model,...C!==void 0?{inputTokens:C}:{},...k!==void 0?{outputTokens:k}:{},...g!==void 0?{costUsd:g}:{}}),l=typeof m.text=="string"?m.text.trim():"",p=a(m.pick??[])}else if(c){let m=await te(c,wn,JSON.stringify({ask:i,about:t.entry.targetLabel,...n.follows?{follows:n.follows}:{},state:t.state,candidates:o.map(C=>({id:C.id,says:C.description}))}),t,t.meter);l=typeof m?.answer=="string"?m.answer.trim():"",p=a(Array.isArray(m?.pick)?m.pick:[])}else if(d&&o.length>0){let{question:m,of:C}=ie(o,`Which of these best answers, or acts on: ${i}`),k=await ne(d,{...t.state,asked:i,candidates:o.map(g=>({id:g.id,type:g.type,says:g.description}))},{answer:m},t.meter);p=oe(k.answer,C,3),l=p.length>0?`These fit \u201C${i}\u201D.`:""}else return E(t,i,"ask",Y)}catch(m){return E(t,i,"ask",m instanceof Error?m.message:String(m))}if(!l&&p.length===0)return E(t,i,"ask","The AI had no answer to that here.");let f=t.usage.at(-1)?.model,h=p.flatMap(({candidate:m,confidence:C})=>{let k=he(m);return k?[{...k,...C!==void 0?{confidence:C}:{}}]:[]}),b=h.length>0?se(n.store,{interaction:t.id,target:n.target,basis:i,...f?{model:f}:{},proposals:h},n.principal):void 0,P=p.map(({candidate:m})=>m).filter(m=>he(m)===void 0),S=[...P.map(m=>me(m,p.find(C=>C.candidate===m)?.confidence)),...(b?.proposals??[]).map(m=>({id:m.id,type:m.field!==void 0?"fill":"act",label:m.label,...m.confidence!==void 0?{confidence:m.confidence}:{}}))];return{interaction:{...t.entry,ask:{kind:"ask",said:i},offered:S,outcome:"offered",...l?{answer:l}:{},usage:[...t.usage]},offers:P,...b&&b.proposals.length>0?{ghost:b}:{},...l?{answer:l}:{}}}function se(e,n,t){let i=n.proposals.flatMap(o=>{try{let s=e.previewAll([o.call],{author:t}),c=s.ops.map(d=>d.intent).join("; ");return s.ops.length>0?[{...o,said:c||o.said}]:[]}catch{return[]}});return{...n,proposals:i}}function he(e){if(e.type==="fill")return{id:e.id,label:e.label,said:e.description,call:e.call,record:e.record,field:e.field};if(e.type==="act"&&e.asks.length===0)return{id:e.id,label:e.label,said:e.description,call:{name:e.mutation,args:{...e.args}}}}function Xe(e,n,t){let i=n.proposals.filter(s=>t.ids===void 0||t.ids.includes(s.id));if(i.length===0)return{ok:!1,refused:"Nothing was chosen."};let o=i.flatMap(s=>s.confidence===void 0?[]:[s.confidence]);try{let c=e.applyAll(i.map(d=>d.call),{author:t.author,via:`ai:${n.interaction}`,intent:n.basis,lineage:{basis:`Asked \u201C${n.basis}\u201D`,...n.model?{model:n.model}:{},...o.length>0?{confidence:Math.min(...o)}:{},interaction:n.interaction}}).ops[0]?.batch;return c?{ok:!0,batch:c,accepted:i.map(d=>d.id)}:{ok:!1,refused:"That changes nothing now."}}catch(s){return{ok:!1,refused:s instanceof Error?s.message:String(s)}}}function Ze(e,n,t){let i=e.ask.kind==="suggest"?n.length>0:e.offered.length>0&&e.offered.every(o=>n.includes(o.id));return{...e,outcome:i?"accepted":"partly",accepted:n,batches:[...e.batches??[],t]}}var en=e=>({...e,outcome:"dismissed"});var I=Se(ln(),1);var x=Se(Fe(),1);function tn(e,n,t){let i=n.on==="selection"?n.ids:n.on==="record"||n.on==="field"?[n.id]:[],o=i.length>0?Ue(e.store,i,{principal:e.principal,...i.length===1?{focus:i[0]}:{}}).affordances.map(s=>({mutation:s.mutation,label:s.label,args:s.args,open:s.open,why:s.why,...s.destructive?{destructive:!0}:{}})):void 0;return{store:e.store,target:n,principal:e.principal,interaction:ve(),places:e.places,selection:e.selection,...o?{acts:o}:{},...e.place?{place:e.place}:{},...t?{said:t}:{}}}async function on(e,n,t){let i=await (__graviewPreload(import.meta.url,["./chunk.UXLJZIYX.js","./chunk.G4JJXA63.js","./chunk.OK4FSBHI.js","./chunk.DAZEFSWI.js","./chunk.3TBH2FMZ.js","./chunk.WE5SA6TP.js","./chunk.Q5WEOX3Q.js","./chunk.4B4DKCS4.js","./chunk.JQ7WY2VZ.js","./chunk.TDCO7LEA.js","./chunk.WVUJXDXZ.js","./chunk.ESU2DD3J.js","./chunk.PL2P2OON.js","./chunk.27ZVVPRZ.js","./chunk.IN4PKQO5.js","./chunk.3IUJ4GW7.js","./chunk.UG23RICT.js","./chunk.MZOIPCDA.js","./chunk.KERLVJ6I.js","./chunk.4EPT2CQG.js","./chunk.AW2T3KFV.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.CSQNDAEK.js")),o=i.recipeDraft(n.recipe,{app:e.app,sight:i.draftSight(e.app,e.principal)});if(i.isDraftFailure(o))return o.failed;t?.(),e.seatTalk.setDraft(o,null),e.goTo.draft?.(),sn()}function sn(e=180){if(typeof document>"u")return;let n=document.querySelector('[data-testid="draft-keep"]'),t=document.activeElement,i=!t||t===document.body||t.closest?.("[inert]")!==null;if(n){i&&n.focus();return}e>0&&requestAnimationFrame(()=>sn(e-1))}async function re(e,n,t,i,o){let s=tn(e,t,i),c=n==="suggest"?await Ke(e.ai,s):n==="fill"?await Ve(e.ai,s):n==="record"?await Qe(e.ai,s):await Ye(e.ai,s);if(c.interaction.outcome==="failed")return n!=="suggest"&&e.desk.record(c.interaction),c;let d=l=>{let p={...c.interaction,outcome:"failed",failed:l};return e.desk.record(p),{...c,interaction:p}};if(n==="fill"||n==="record"){if(!c.ghost||c.ghost.proposals.length===0)return d("Nothing here could be filled in.");o?.(),e.desk.setGhost({ghost:c.ghost}),e.desk.record(c.interaction)}if(n==="panel"&&c.panel){let l=await on(e,c.panel,o);if(l)return d(l);e.desk.record(c.interaction)}return c}var Ie=new WeakMap,xn=64,nn=new WeakMap;function On(e){let n=nn.get(e);if(!n){let t=n={n:0};nn.set(e,t),e.subscribe(()=>void(t.n+=1))}return n.n}var rn=(e,n)=>{let t=V(n);return t.length>0?t.map(i=>e.graph.getNode(i)):[On(e)]},an=(e,n,t)=>JSON.stringify({target:n,seat:e.principal,by:t}),dn=(e,n,t)=>{let i=rn(e.store,n);return t.schema===e.store.schema&&t.ai===e.ai&&i.length===t.depends.length&&i.every((o,s)=>o===t.depends[s])};function Cn(e,n,t="menu"){let i=Ie.get(e.store)?.get(an(e,n,t));return i?.result!==void 0&&dn(e,n,i)?i.result:void 0}function $n(e,n,t){let i=Ie.get(e.store);i||Ie.set(e.store,i=new Map);let o=an(e,n,t?.by??"menu"),s=i.get(o);if(s&&dn(e,n,s))return s.result?Promise.resolve(s.result):s.asked;let c=t?t.ask():re(e,"suggest",n),d={schema:e.store.schema,ai:e.ai,depends:rn(e.store,n),asked:c};i.delete(o),i.set(o,d),i.size>xn&&i.delete(i.keys().next().value);let l=i;return c.then(p=>{p.interaction.outcome!=="failed"?d.result=p:l.get(o)===d&&l.delete(o)}),c}async function Pn(e,n,t,i){let o=n.interaction,s=he(t);if(s){let c=o.usage?.at(-1)?.model,d=o.offered.find(p=>p.id===t.id)?.confidence,l=se(e.store,{interaction:o.id,target:o.target,basis:`${o.ask.said}: ${t.label}`,...c?{model:c}:{},proposals:[{...s,...d!==void 0?{confidence:d}:{}}]},e.principal);if(l.proposals.length===0){let p="That can't be done now.";return e.desk.record({...o,outcome:"failed",failed:p}),p}i?.(),e.desk.setGhost({ghost:l}),e.desk.record(o);return}if(t.type==="panel"){let c=t.label,d={title:c,recipe:{...t.panel,title:c}},l=await on(e,d,i);return e.desk.record(l?{...o,outcome:"failed",failed:l}:{...o,outcome:"drawn",accepted:[t.id],panel:d}),l}i?.(),t.type==="place"?e.goTo.place(t.place):t.type==="record"&&e.goTo.record(t.record),e.desk.record({...o,outcome:"accepted",accepted:[t.id]})}async function Yn(e,n){if(n.ask.kind==="ask")return ce(e.desk,{target:n.target,asked:n.ask.said}),null;let t=n.ask.kind==="panel"||n.ask.kind==="record"?n.ask.kind:"fill";return re(e,t,n.target,n.ask.said)}var G={padding:"5px 10px",fontSize:"0.875rem",borderRadius:8,width:"100%",textAlign:"left",borderWidth:1,borderStyle:"solid",borderColor:"transparent",background:"none",boxShadow:"none"},ke={margin:0,padding:"4px 10px",fontSize:"0.8125rem",color:"var(--graview-ink-muted)"};function Xn({target:e,close:n}){let t=We(),i=(0,I.useMemo)(()=>Ge(e,u=>t.store.graph.has(u)),[e,t.store]),o=(0,I.useMemo)(()=>{let u=tn(t,i);return ye(t.store,i,{principal:t.principal,places:t.places,...u.acts?{acts:u.acts}:{}})},[t,i]),s=o.candidates.some(u=>u.type==="fill"),c=o.candidates.some(u=>u.type==="panel"),d=(0,I.useMemo)(()=>c?ze(t.store,i,{principal:t.principal,places:t.places,most:1}):[],[c,t,i]),l=(0,I.useMemo)(()=>new Set(t.store.allMutations().filter(u=>(u.creates??[]).length>0).map(u=>u.name)),[t.store]),p=B(t.ai)!==void 0&&o.candidates.some(u=>u.type==="act"&&u.asks.length>0&&l.has(u.mutation)),a=we(t.ai),f=Cn(t,i),h=JSON.stringify(i),[b,P]=(0,I.useState)(!1),[S,m]=(0,I.useState)(null),[C,k]=(0,I.useState)(a&&f===void 0);(0,I.useEffect)(()=>{if(f!==void 0||!(a||b))return;let u=!0;return k(!0),$n(t,i).then(O=>{u&&(m(O),k(!1))}),()=>{u=!1}},[h,b]);let g=f??S,A=(g?.offers??[]).filter(u=>!(u.type==="place"&&d.some(O=>O.place===u.place))).slice(0,Math.max(0,3-d.length)),w=g?.interaction.outcome==="failed"?g.interaction.failed??"The AI could not suggest anything here.":null,M=(0,I.useRef)(!1),L=(0,I.useRef)(null);(0,I.useLayoutEffect)(()=>{g===null||!M.current||(M.current=!1,L.current?.querySelector("button")?.focus())},[g]);let J=(0,I.useRef)(!0);(0,I.useEffect)(()=>()=>{J.current=!1},[]);let[F,r]=(0,I.useState)(!1),[y,T]=(0,I.useState)(null),v=u=>{if(F)return;r(!0),T(null);let O=!1;u(()=>{O=!0,n()}).then(D=>{J.current&&(r(!1),D?T(D):O||n())},D=>{J.current&&(r(!1),T(D instanceof Error?D.message:String(D)))})},$=u=>u.interaction.outcome==="failed"?u.interaction.failed??"The AI could not do that here.":void 0;return(0,x.jsxs)("div",{ref:L,"data-testid":"inline-ai",style:{display:"grid",gap:2},children:[C&&!b?(0,x.jsx)("p",{role:"status","data-testid":"inline-ai-thinking",style:ke,children:"Thinking\u2026"}):F?(0,x.jsx)("p",{role:"status","data-testid":"inline-ai-asking",style:ke,children:"Asking\u2026"}):y?(0,x.jsx)("p",{role:"alert","data-testid":"inline-ai-failed",style:{...ke,color:"var(--graview-warn)"},children:y}):w?(0,x.jsx)("p",{role:"status",style:ke,children:w}):null,(0,x.jsxs)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:2},children:[A.map(u=>(0,x.jsx)("li",{children:(0,x.jsxs)("button",{type:"button","data-menu-item":`ai-offer:${u.id}`,"data-ai-offer":u.id,"data-ai-offer-type":u.type,onClick:()=>v(O=>Pn(t,g,u,O)),style:G,children:[u.label,(0,x.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",u.type==="panel"?"a panel":u.type==="place"?"go there":u.type==="record"?"open it":"suggested"]})]})},u.id)),!a&&g===null?(0,x.jsx)("li",{children:(0,x.jsx)("button",{type:"button","data-menu-item":"ai-suggest","aria-disabled":b||void 0,onClick:u=>{b||(M.current=document.activeElement===u.currentTarget,P(!0))},style:G,children:b?"Thinking\u2026":"Suggest\u2026"})}):null,s?(0,x.jsx)("li",{children:(0,x.jsx)("button",{type:"button","data-menu-item":"ai-fill",onClick:()=>v(async u=>$(await re(t,"fill",i,"Fill in",u))),style:G,children:"Fill in with AI"})}):null,p?(0,x.jsx)("li",{children:(0,x.jsx)("button",{type:"button","data-menu-item":"ai-record",onClick:()=>v(async u=>$(await re(t,"record",i,"Add one",u))),style:G,children:"Add one with AI"})}):null,d.map(u=>(0,x.jsx)("li",{children:(0,x.jsx)("button",{type:"button","data-menu-item":`ai-open:${u.place}`,"data-ai-existing":u.fit,onClick:()=>{n(),t.goTo.place(u.place),u.fit==="partial"&&ce(t.desk,{target:{on:"lens",place:u.place,...u.kind?{kind:u.kind}:{}}})},style:G,children:u.fit==="full"?`Open ${u.title}`:`Open and adjust ${u.title}`})},u.place)),c?(0,x.jsx)("li",{children:(0,x.jsx)("button",{type:"button","data-menu-item":"ai-panel",onClick:()=>v(async u=>$(await re(t,"panel",i,"Draw a panel",u))),style:G,children:d.length>0?"Draw a new view":"Draw a panel"})}):null,(0,x.jsx)("li",{children:(0,x.jsx)("button",{type:"button","data-menu-item":"ai-ask",onClick:()=>{let u=document.activeElement;n(),ce(t.desk,{target:i,returnTo:u instanceof HTMLElement&&u!==document.body?u:null})},style:G,children:"Ask about this\u2026"})})]})]})}var be={display:"inline-flex",alignItems:"center",minHeight:28,padding:"2px 10px",fontSize:"0.8125rem",borderRadius:8};function Zn({placement:e="picture"}){let{store:n,principal:t,aiDesk:i}=Je(),o=Le(n,t),{ghost:s,entries:c}=He(i),[d,l]=(0,I.useState)(new Set);(0,I.useEffect)(()=>l(new Set),[s?.ghost.interaction]);let p=(0,I.useRef)(null),a=(0,I.useRef)(null),f=s?.batch;if((0,I.useEffect)(()=>{f!==void 0&&a.current?.focus()},[f]),!s)return null;let{ghost:h}=s,b=c.find(g=>g.id===h.interaction),P=()=>{let g=h.target.on==="record"||h.target.on==="field"?h.target.id:void 0,A=p.current?.closest("[data-graview-face], main")?.parentElement??document,w=(g?A.querySelector(`[data-graview-view="${CSS.escape(g)}"][tabindex]`):null)??document.querySelector("[data-graview-page-title]")??p.current?.closest("main")??document.querySelector("main");w&&!w.hasAttribute("tabindex")&&w.setAttribute("tabindex","-1"),w?.focus({preventScroll:!0}),i.setGhost(null)},S=h.proposals.filter(g=>!d.has(g.id)).map(g=>g.id),m=()=>{let g=Xe(o,h,{author:t,ids:S});if(!g.ok){i.setGhost({...s,refused:g.refused});return}b&&i.record(Ze(b,g.accepted,g.batch)),i.setGhost({ghost:h,batch:g.batch,took:g.accepted.length,...s.onCard?{onCard:!0}:{}})},C=()=>{b&&s.batch===void 0&&i.record(en(b)),P()},k=()=>{if(s.batch!==void 0)try{o.undo(s.batch,{author:t}),P()}catch(g){i.setGhost({...s,refused:g instanceof Error?g.message:String(g)})}};return(0,x.jsxs)("section",{ref:p,"data-testid":"ai-ghost","data-interaction":h.interaction,"aria-label":"Proposed by AI",style:{...e==="card"?{position:"static"}:{position:e==="page"?"fixed":"absolute",insetInline:"max(12px, calc(50% - 220px))",bottom:"calc(var(--graview-foot-room, 0px) + 72px)",zIndex:De("toast"),boxShadow:"var(--graview-lift-high)"},display:"grid",gap:8,padding:12,borderRadius:12,border:"1px dashed var(--graview-accent)",background:"var(--graview-float)",fontSize:"0.875rem"},children:[(0,x.jsx)("p",{style:{margin:0,color:"var(--graview-ink-muted)"},children:s.batch!==void 0?`Done: ${s.took===1?"one change":`${s.took} changes`}, as one.`:`Proposed by AI \xB7 ${h.basis}`}),s.batch===void 0?(0,x.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:4},children:h.proposals.map(g=>(0,x.jsx)("li",{"data-ghost-proposal":g.id,children:(0,x.jsxs)("label",{style:{display:"flex",alignItems:"baseline",gap:8,cursor:"pointer"},children:[(0,x.jsx)("input",{type:"checkbox",checked:!d.has(g.id),onChange:A=>{let w=new Set(d);A.target.checked?w.delete(g.id):w.add(g.id),l(w)}}),(0,x.jsx)("span",{style:{fontStyle:"italic",color:"var(--graview-ink)"},children:g.said}),g.confidence!==void 0?(0,x.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[Math.round(g.confidence*100),"% sure"]}):null]})},g.id))}):null,s.refused?(0,x.jsx)("p",{role:"alert",style:{margin:0,color:"var(--graview-warn)"},children:s.refused}):null,(0,x.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:s.batch===void 0?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)("button",{type:"button","data-testid":"ghost-accept",disabled:S.length===0,onClick:m,style:be,children:S.length===h.proposals.length?"Accept":`Accept ${S.length} of ${h.proposals.length}`}),(0,x.jsx)("button",{type:"button","data-testid":"ghost-dismiss",onClick:C,style:be,children:"Dismiss"})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)("button",{type:"button",ref:a,"data-testid":"ghost-undo",onClick:k,style:be,children:"Undo"}),(0,x.jsx)("button",{type:"button","data-testid":"ghost-close",onClick:P,style:be,children:"Close"})]})})]})}export{Ge as a,V as b,ye as c,ze as d,ee as e,ve as f,hn as g,mn as h,Fn as i,Jn as j,tn as k,on as l,re as m,Cn as n,$n as o,Pn as p,Yn as q,Xn as r,Zn as s};
|
|
3
|
+
${o}`)})}}if(e.turn){let t=e.turn;return{model:n,think:async({system:i,prompt:o})=>({text:await t({system:i,messages:[{role:"user",content:o}],tools:[],call:async()=>({error:"No tools here."})})})}}}var Te=(e,n,t)=>e?n/1e6*(e.inputPerMillion??0)+t/1e6*(e.outputPerMillion??0):void 0,ve=()=>`ai-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;function hn(e,n,t=[]){let i=o=>{let s=e.graph.getNode(o);return s?ae(e.schema.tryDefinition(s.kind),s):"a record"};switch(n.on){case"record":return i(n.id);case"field":return`${i(n.id)} \xB7 ${n.field}`;case"selection":return`${n.ids.length} records`;case"list":return e.schema.tryDefinition(n.kind)?q(e.schema,n.kind):n.kind;case"lens":case"place":return t.find(o=>o.as===n.place)?.title??(n.place==="home"?"Home":n.place);case"act":return n.act}}var _e=e=>e.type!=="act"||e.asks.length===0,me=(e,n)=>({id:e.id,type:e.type,label:e.label,...n!==void 0?{confidence:n}:{}});function Q(e,n){let t=n.interaction??ve(),i=ye(n.store,n.target,{principal:n.principal,...n.acts?{acts:n.acts}:{},...n.places?{places:n.places}:{}}),o=qe(n.store,n.target,{principal:n.principal,...n.place?{place:n.place}:{},...n.selection?{selection:n.selection}:{}}),s=[];return{id:t,catalog:i,state:o,entry:{id:t,at:new Date().toISOString(),by:n.by??n.principal,target:n.target,targetLabel:hn(n.store,n.target,n.places)},usage:s,meter:c=>{s.push(c),e.meter?.({...c,interaction:t})}}}async function ne(e,n,t,i){let o=await e.decide(n,t),{inputTokens:s,outputTokens:c}=o.usage,d=Te(e.price,s,c);return i({tier:"fast",model:e.model,inputTokens:s,outputTokens:c,...d!==void 0?{costUsd:d}:{}}),o.answers}async function te(e,n,t,i,o){let s=await e.think({system:n,prompt:t,state:i.state,catalog:i.catalog}),c=s.usage?.inputTokens,d=s.usage?.outputTokens,l=s.usage?.costUsd??(c!==void 0?Te(e.price,c,d??0):void 0);return o({tier:"thinking",model:e.model,...c!==void 0?{inputTokens:c}:{},...d!==void 0?{outputTokens:d}:{},...l!==void 0?{costUsd:l}:{}}),Be(s.text)}function ie(e,n){let t=new Map(e.map((i,o)=>[`c${o+1}`,i]));return{question:{type:"choice",instructions:n,criteria:Object.fromEntries([...t].map(([i,o])=>[i,`${o.label} \u2014 ${o.description}`]))},of:i=>t.get(i)}}function oe(e,n,t){if(e?.type!=="choice")return[];let i=e,o=Object.entries(i.probabilities).sort((s,c)=>c[1]-s[1]);return o.some(([s])=>s===i.choice)||o.unshift([i.choice,i.confidence]),o.flatMap(([s,c])=>{let d=n(s);return d?[{candidate:d,confidence:c}]:[]}).slice(0,t)}var E=(e,n,t,i)=>({interaction:{...e.entry,ask:{kind:t,said:n??""},offered:[],outcome:"failed",failed:i,usage:[...e.usage]},offers:[]}),Y="AI isn't on here.";async function Ke(e,n,t=3){let i=Q(e,n),o=n.said??"Suggest",s=i.catalog.candidates.filter(_e).slice(0,24);if(s.length===0)return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:[],outcome:"offered",usage:[]},offers:[]};let c=ee(e),d=B(e),l=[];try{if(c){let{question:p,of:a}=ie(s,"Which of these would the person most likely want to do next, here?"),f=await ne(c,{...i.state,candidates:s.map(h=>({id:h.id,type:h.type,says:h.description}))},{next:p},i.meter);l=oe(f.next,a,t)}else if(d){let p=await te(d,'You suggest what a person most likely wants to do next in an app. Answer only JSON: {"pick": [candidate ids, best first]}. Pick only ids from the candidates.',JSON.stringify({state:i.state,candidates:s.map(f=>({id:f.id,says:f.description}))}),i,i.meter);l=(Array.isArray(p?.pick)?p.pick.filter(f=>typeof f=="string"):[]).flatMap(f=>s.filter(h=>h.id===f)).slice(0,t).map(f=>({candidate:f}))}else return E(i,o,"suggest",Y)}catch(p){return E(i,o,"suggest",p instanceof Error?p.message:String(p))}return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:l.map(({candidate:p,confidence:a})=>me(p,a)),outcome:"offered",usage:[...i.usage]},offers:l.map(({candidate:p})=>p)}}var mn=e=>`several:${e}`;async function Fn(e,n,t=2){let i=Q(e,{...n,acts:[]}),o=n.said??"Suggest for the chosen",s=n.target.on==="selection"?n.target.ids.length:1,d=[...n.shared.map(a=>({type:"act",id:mn(a.id),label:a.label,description:`${a.label}, for all ${s} chosen`,mutation:a.mutation,args:a.args,asks:[]})),...i.catalog.candidates.filter(a=>a.type==="panel"||a.type==="place")].slice(0,24),l=ee(e);if(!l)return E(i,o,"suggest",Y);if(d.length===0)return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:[],outcome:"offered",usage:[]},offers:[]};let p;try{let{question:a,of:f}=ie(d,`Which of these would the person most likely want to do next with the ${s} records they chose together?`),h=await ne(l,{...i.state,candidates:d.map(b=>({id:b.id,type:b.type,says:b.description}))},{next:a},i.meter);p=oe(h.next,f,t).filter((b,P)=>P===0||b.confidence>=kn)}catch(a){return E(i,o,"suggest",a instanceof Error?a.message:String(a))}return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:p.map(({candidate:a,confidence:f})=>me(a,f)),outcome:"offered",usage:[...i.usage]},offers:p.map(({candidate:a})=>a)}}var kn=.25;async function Ve(e,n){let t=Q(e,n),i=n.said??"Fill in",o=t.catalog.candidates.filter(f=>f.type==="fill"),s=new Map;for(let f of o)s.set(f.field,[...s.get(f.field)??[],f]);if(s.size===0)return{interaction:{...t.entry,ask:{kind:"fill",said:i},offered:[],outcome:"offered",usage:[]},offers:[]};let c=ee(e),d=B(e),l=[];try{if(c){let f=[...s].map(([b,P],S)=>({key:`f${S+1}`,field:b,...ie(P,`Which value fits "${b}" best for this record?`)})),h=await ne(c,t.state,Object.fromEntries(f.map(b=>[b.key,b.question])),t.meter);for(let b of f){let P=!bn(n.store,n.target,b.field)&&An(n.store,n.target,b.field)!=="one";l.push(...oe(h[b.key],b.of,P?3:1).filter((S,m)=>m===0||S.confidence>=.4))}}else if(d){let f=await te(d,`You fill in a record's fields in an app. Answer only JSON: {"fills": [candidate ids]}, at most one per field, only ids from the candidates.`,JSON.stringify({state:t.state,candidates:o.map(P=>({id:P.id,says:P.description}))}),t,t.meter),h=Array.isArray(f?.fills)?f.fills.filter(P=>typeof P=="string"):[],b=new Set;for(let P of h){let S=o.find(m=>m.id===P);S?.type==="fill"&&!b.has(S.field)&&(b.add(S.field),l.push({candidate:S}))}}else return E(t,i,"fill",Y)}catch(f){return E(t,i,"fill",f instanceof Error?f.message:String(f))}let p=t.usage.at(-1)?.model,a=se(n.store,{interaction:t.id,target:n.target,basis:i,...p?{model:p}:{},proposals:l.flatMap(({candidate:f,confidence:h})=>f.type==="fill"?[{id:f.id,label:f.label,said:f.description,call:f.call,record:f.record,field:f.field,...h!==void 0?{confidence:h}:{}}]:[])},n.principal);return{interaction:{...t.entry,ask:{kind:"fill",said:i},offered:a.proposals.map(f=>({id:f.id,type:"fill",label:f.label,...f.confidence!==void 0?{confidence:f.confidence}:{}})),outcome:"offered",usage:[...t.usage]},offers:[],...a.proposals.length>0?{ghost:a}:{}}}function bn(e,n,t){let i=n.on==="record"||n.on==="field"?n.id:void 0,o=i?e.graph.getNode(i)?.kind:void 0,s=(o?e.schema.tryDefinition(o)?.fields?.shape:void 0)??{};return t in s}function An(e,n,t){let i=n.on==="record"||n.on==="field"?n.id:void 0,o=i?e.graph.getNode(i)?.kind:void 0;return o?e.schema.tryDefinition(o)?.edges?.[t]?.cardinality:void 0}async function Qe(e,n){let t=Q(e,n),i=n.said??"Add one",o=new Set(n.store.allMutations().filter(a=>(a.creates??[]).length>0).map(a=>a.name)),s=t.catalog.candidates.filter(a=>a.type==="act"&&a.asks.length>0&&o.has(a.mutation));if(s.length===0)return E(t,i,"record","Nothing here makes a record.");let c=B(e);if(!c)return E(t,i,"record",Y);let d;try{let a=await te(c,'You propose one new record for an app by filling in an act. Answer only JSON: {"act": a candidate id, "args": {argument: value}}. Use only the candidates, and fill every argument the act asks for with a value that fits the state.',JSON.stringify({ask:i,state:t.state,candidates:s.map(b=>({id:b.id,says:b.description,asks:b.asks}))}),t,t.meter),f=s.find(b=>b.id===a?.act),h=typeof a?.args=="object"&&a.args!==null?a.args:{};f&&(d={act:f,args:Object.fromEntries(Object.entries(h).filter(([b])=>f.asks.includes(b)))})}catch(a){return E(t,i,"record",a instanceof Error?a.message:String(a))}if(!d)return E(t,i,"record","The model named no act this app has here.");let l=t.usage.at(-1)?.model,p=se(n.store,{interaction:t.id,target:n.target,basis:i,...l?{model:l}:{},proposals:[{id:d.act.id,label:d.act.label,said:d.act.description,call:{name:d.act.mutation,args:{...d.act.args,...d.args}}}]},n.principal);return p.proposals.length===0?E(t,i,"record","What the model proposed could not be made here."):{interaction:{...t.entry,ask:{kind:"record",said:i},offered:p.proposals.map(a=>({id:a.id,type:"act",label:a.said})),outcome:"offered",usage:[...t.usage]},offers:[d.act],ghost:p}}async function Ye(e,n){let t=Q(e,n),i=n.said??"Make a panel",o=t.catalog.candidates.filter(a=>a.type==="panel");if(o.length===0)return E(t,i,"panel","Nothing here can be drawn as a panel.");let s=ee(e),c=B(e),d;try{if(c){let a=await te(c,'You choose a panel to draw in an app. Answer only JSON: {"panel": a candidate id, "title": a short title}. Choose only among the candidates.',JSON.stringify({ask:i,state:t.state,candidates:o.map(h=>({id:h.id,says:h.description}))}),t,t.meter),f=o.find(h=>h.id===a?.panel);f&&(d={panel:f,...typeof a?.title=="string"&&a.title.trim()?{title:a.title.trim().slice(0,60)}:{}})}else if(s){let{question:a,of:f}=ie(o,`Which panel answers this best: ${i}`),h=oe((await ne(s,t.state,{panel:a},t.meter)).panel,f,1)[0];h?.candidate.type==="panel"&&(d={panel:h.candidate,confidence:h.confidence})}else return E(t,i,"panel",Y)}catch(a){return E(t,i,"panel",a instanceof Error?a.message:String(a))}if(!d)return E(t,i,"panel","The model named no panel this app can draw.");let l=d.title??d.panel.label,p={title:l,recipe:{...d.panel.panel,title:l}};return{interaction:{...t.entry,ask:{kind:"panel",said:i},offered:[me(d.panel,d.confidence)],outcome:"drawn",panel:p,usage:[...t.usage]},offers:[d.panel],panel:p}}function Sn(e){return e.off?void 0:e.answer}var wn=`You answer a person's question about what they are looking at in an app, from the state given and nothing else. Answer only JSON: {"answer": one to three short sentences, "pick": [candidate ids that act on the answer, best first, at most three]}. Pick only ids from the candidates, and none when nothing fits. Never say an id to the person.`;async function Jn(e,n){let t=Q(e,n),i=n.said.trim(),o=t.catalog.candidates.filter(m=>_e(m)||m.type==="panel"||m.type==="place"||m.type==="record").slice(0,32),s=Sn(e),c=B(e),d=ee(e),l="",p=[],a=m=>m.flatMap(C=>o.filter(k=>k.id===C)).slice(0,3).map(C=>({candidate:C}));try{if(s){let m=await s.answer({said:i,target:n.target,targetLabel:t.entry.targetLabel,state:t.state,catalog:{target:t.catalog.target,candidates:o},...n.follows?{follows:n.follows}:{}}),C=m.usage?.inputTokens,k=m.usage?.outputTokens,g=m.usage?.costUsd??(C!==void 0?Te(s.price,C,k??0):void 0);t.meter({tier:"thinking",model:s.model,...C!==void 0?{inputTokens:C}:{},...k!==void 0?{outputTokens:k}:{},...g!==void 0?{costUsd:g}:{}}),l=typeof m.text=="string"?m.text.trim():"",p=a(m.pick??[])}else if(c){let m=await te(c,wn,JSON.stringify({ask:i,about:t.entry.targetLabel,...n.follows?{follows:n.follows}:{},state:t.state,candidates:o.map(C=>({id:C.id,says:C.description}))}),t,t.meter);l=typeof m?.answer=="string"?m.answer.trim():"",p=a(Array.isArray(m?.pick)?m.pick:[])}else if(d&&o.length>0){let{question:m,of:C}=ie(o,`Which of these best answers, or acts on: ${i}`),k=await ne(d,{...t.state,asked:i,candidates:o.map(g=>({id:g.id,type:g.type,says:g.description}))},{answer:m},t.meter);p=oe(k.answer,C,3),l=p.length>0?`These fit \u201C${i}\u201D.`:""}else return E(t,i,"ask",Y)}catch(m){return E(t,i,"ask",m instanceof Error?m.message:String(m))}if(!l&&p.length===0)return E(t,i,"ask","The AI had no answer to that here.");let f=t.usage.at(-1)?.model,h=p.flatMap(({candidate:m,confidence:C})=>{let k=he(m);return k?[{...k,...C!==void 0?{confidence:C}:{}}]:[]}),b=h.length>0?se(n.store,{interaction:t.id,target:n.target,basis:i,...f?{model:f}:{},proposals:h},n.principal):void 0,P=p.map(({candidate:m})=>m).filter(m=>he(m)===void 0),S=[...P.map(m=>me(m,p.find(C=>C.candidate===m)?.confidence)),...(b?.proposals??[]).map(m=>({id:m.id,type:m.field!==void 0?"fill":"act",label:m.label,...m.confidence!==void 0?{confidence:m.confidence}:{}}))];return{interaction:{...t.entry,ask:{kind:"ask",said:i},offered:S,outcome:"offered",...l?{answer:l}:{},usage:[...t.usage]},offers:P,...b&&b.proposals.length>0?{ghost:b}:{},...l?{answer:l}:{}}}function se(e,n,t){let i=n.proposals.flatMap(o=>{try{let s=e.previewAll([o.call],{author:t}),c=s.ops.map(d=>d.intent).join("; ");return s.ops.length>0?[{...o,said:c||o.said}]:[]}catch{return[]}});return{...n,proposals:i}}function he(e){if(e.type==="fill")return{id:e.id,label:e.label,said:e.description,call:e.call,record:e.record,field:e.field};if(e.type==="act"&&e.asks.length===0)return{id:e.id,label:e.label,said:e.description,call:{name:e.mutation,args:{...e.args}}}}function Xe(e,n,t){let i=n.proposals.filter(s=>t.ids===void 0||t.ids.includes(s.id));if(i.length===0)return{ok:!1,refused:"Nothing was chosen."};let o=i.flatMap(s=>s.confidence===void 0?[]:[s.confidence]);try{let c=e.applyAll(i.map(d=>d.call),{author:t.author,via:`ai:${n.interaction}`,intent:n.basis,lineage:{basis:`Asked \u201C${n.basis}\u201D`,...n.model?{model:n.model}:{},...o.length>0?{confidence:Math.min(...o)}:{},interaction:n.interaction}}).ops[0]?.batch;return c?{ok:!0,batch:c,accepted:i.map(d=>d.id)}:{ok:!1,refused:"That changes nothing now."}}catch(s){return{ok:!1,refused:s instanceof Error?s.message:String(s)}}}function Ze(e,n,t){let i=e.ask.kind==="suggest"?n.length>0:e.offered.length>0&&e.offered.every(o=>n.includes(o.id));return{...e,outcome:i?"accepted":"partly",accepted:n,batches:[...e.batches??[],t]}}var en=e=>({...e,outcome:"dismissed"});var I=Se(ln(),1);var x=Se(Fe(),1);function tn(e,n,t){let i=n.on==="selection"?n.ids:n.on==="record"||n.on==="field"?[n.id]:[],o=i.length>0?Ue(e.store,i,{principal:e.principal,...i.length===1?{focus:i[0]}:{}}).affordances.map(s=>({mutation:s.mutation,label:s.label,args:s.args,open:s.open,why:s.why,...s.destructive?{destructive:!0}:{}})):void 0;return{store:e.store,target:n,principal:e.principal,interaction:ve(),places:e.places,selection:e.selection,...o?{acts:o}:{},...e.place?{place:e.place}:{},...t?{said:t}:{}}}async function on(e,n,t){let i=await (__graviewPreload(import.meta.url,["./chunk.4RJZVTW7.js","./chunk.G4JJXA63.js","./chunk.WBHM5I3I.js","./chunk.VC3BX2ZF.js","./chunk.WAB7UDHU.js","./chunk.IW7YFPGG.js","./chunk.Q5WEOX3Q.js","./chunk.4OGOTHRD.js","./chunk.6YD2DLIC.js","./chunk.Q7RQC3F7.js","./chunk.WVUJXDXZ.js","./chunk.ZIEHF67C.js","./chunk.UHX4WTM7.js","./chunk.IKX4VDTW.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.HDRD33II.js","./chunk.DX357TZ3.js","./chunk.H7KCWCB4.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.WO3DDFFY.js")),o=i.recipeDraft(n.recipe,{app:e.app,sight:i.draftSight(e.app,e.principal)});if(i.isDraftFailure(o))return o.failed;t?.(),e.seatTalk.setDraft(o,null),e.goTo.draft?.(),sn()}function sn(e=180){if(typeof document>"u")return;let n=document.querySelector('[data-testid="draft-keep"]'),t=document.activeElement,i=!t||t===document.body||t.closest?.("[inert]")!==null;if(n){i&&n.focus();return}e>0&&requestAnimationFrame(()=>sn(e-1))}async function re(e,n,t,i,o){let s=tn(e,t,i),c=n==="suggest"?await Ke(e.ai,s):n==="fill"?await Ve(e.ai,s):n==="record"?await Qe(e.ai,s):await Ye(e.ai,s);if(c.interaction.outcome==="failed")return n!=="suggest"&&e.desk.record(c.interaction),c;let d=l=>{let p={...c.interaction,outcome:"failed",failed:l};return e.desk.record(p),{...c,interaction:p}};if(n==="fill"||n==="record"){if(!c.ghost||c.ghost.proposals.length===0)return d("Nothing here could be filled in.");o?.(),e.desk.setGhost({ghost:c.ghost}),e.desk.record(c.interaction)}if(n==="panel"&&c.panel){let l=await on(e,c.panel,o);if(l)return d(l);e.desk.record(c.interaction)}return c}var Ie=new WeakMap,xn=64,nn=new WeakMap;function On(e){let n=nn.get(e);if(!n){let t=n={n:0};nn.set(e,t),e.subscribe(()=>void(t.n+=1))}return n.n}var rn=(e,n)=>{let t=V(n);return t.length>0?t.map(i=>e.graph.getNode(i)):[On(e)]},an=(e,n,t)=>JSON.stringify({target:n,seat:e.principal,by:t}),dn=(e,n,t)=>{let i=rn(e.store,n);return t.schema===e.store.schema&&t.ai===e.ai&&i.length===t.depends.length&&i.every((o,s)=>o===t.depends[s])};function Cn(e,n,t="menu"){let i=Ie.get(e.store)?.get(an(e,n,t));return i?.result!==void 0&&dn(e,n,i)?i.result:void 0}function $n(e,n,t){let i=Ie.get(e.store);i||Ie.set(e.store,i=new Map);let o=an(e,n,t?.by??"menu"),s=i.get(o);if(s&&dn(e,n,s))return s.result?Promise.resolve(s.result):s.asked;let c=t?t.ask():re(e,"suggest",n),d={schema:e.store.schema,ai:e.ai,depends:rn(e.store,n),asked:c};i.delete(o),i.set(o,d),i.size>xn&&i.delete(i.keys().next().value);let l=i;return c.then(p=>{p.interaction.outcome!=="failed"?d.result=p:l.get(o)===d&&l.delete(o)}),c}async function Pn(e,n,t,i){let o=n.interaction,s=he(t);if(s){let c=o.usage?.at(-1)?.model,d=o.offered.find(p=>p.id===t.id)?.confidence,l=se(e.store,{interaction:o.id,target:o.target,basis:`${o.ask.said}: ${t.label}`,...c?{model:c}:{},proposals:[{...s,...d!==void 0?{confidence:d}:{}}]},e.principal);if(l.proposals.length===0){let p="That can't be done now.";return e.desk.record({...o,outcome:"failed",failed:p}),p}i?.(),e.desk.setGhost({ghost:l}),e.desk.record(o);return}if(t.type==="panel"){let c=t.label,d={title:c,recipe:{...t.panel,title:c}},l=await on(e,d,i);return e.desk.record(l?{...o,outcome:"failed",failed:l}:{...o,outcome:"drawn",accepted:[t.id],panel:d}),l}i?.(),t.type==="place"?e.goTo.place(t.place):t.type==="record"&&e.goTo.record(t.record),e.desk.record({...o,outcome:"accepted",accepted:[t.id]})}async function Yn(e,n){if(n.ask.kind==="ask")return ce(e.desk,{target:n.target,asked:n.ask.said}),null;let t=n.ask.kind==="panel"||n.ask.kind==="record"?n.ask.kind:"fill";return re(e,t,n.target,n.ask.said)}var G={padding:"5px 10px",fontSize:"0.875rem",borderRadius:8,width:"100%",textAlign:"left",borderWidth:1,borderStyle:"solid",borderColor:"transparent",background:"none",boxShadow:"none"},ke={margin:0,padding:"4px 10px",fontSize:"0.8125rem",color:"var(--graview-ink-muted)"};function Xn({target:e,close:n}){let t=We(),i=(0,I.useMemo)(()=>Ge(e,u=>t.store.graph.has(u)),[e,t.store]),o=(0,I.useMemo)(()=>{let u=tn(t,i);return ye(t.store,i,{principal:t.principal,places:t.places,...u.acts?{acts:u.acts}:{}})},[t,i]),s=o.candidates.some(u=>u.type==="fill"),c=o.candidates.some(u=>u.type==="panel"),d=(0,I.useMemo)(()=>c?ze(t.store,i,{principal:t.principal,places:t.places,most:1}):[],[c,t,i]),l=(0,I.useMemo)(()=>new Set(t.store.allMutations().filter(u=>(u.creates??[]).length>0).map(u=>u.name)),[t.store]),p=B(t.ai)!==void 0&&o.candidates.some(u=>u.type==="act"&&u.asks.length>0&&l.has(u.mutation)),a=we(t.ai),f=Cn(t,i),h=JSON.stringify(i),[b,P]=(0,I.useState)(!1),[S,m]=(0,I.useState)(null),[C,k]=(0,I.useState)(a&&f===void 0);(0,I.useEffect)(()=>{if(f!==void 0||!(a||b))return;let u=!0;return k(!0),$n(t,i).then(O=>{u&&(m(O),k(!1))}),()=>{u=!1}},[h,b]);let g=f??S,A=(g?.offers??[]).filter(u=>!(u.type==="place"&&d.some(O=>O.place===u.place))).slice(0,Math.max(0,3-d.length)),w=g?.interaction.outcome==="failed"?g.interaction.failed??"The AI could not suggest anything here.":null,M=(0,I.useRef)(!1),L=(0,I.useRef)(null);(0,I.useLayoutEffect)(()=>{g===null||!M.current||(M.current=!1,L.current?.querySelector("button")?.focus())},[g]);let J=(0,I.useRef)(!0);(0,I.useEffect)(()=>()=>{J.current=!1},[]);let[F,r]=(0,I.useState)(!1),[y,T]=(0,I.useState)(null),v=u=>{if(F)return;r(!0),T(null);let O=!1;u(()=>{O=!0,n()}).then(D=>{J.current&&(r(!1),D?T(D):O||n())},D=>{J.current&&(r(!1),T(D instanceof Error?D.message:String(D)))})},$=u=>u.interaction.outcome==="failed"?u.interaction.failed??"The AI could not do that here.":void 0;return(0,x.jsxs)("div",{ref:L,"data-testid":"inline-ai",style:{display:"grid",gap:2},children:[C&&!b?(0,x.jsx)("p",{role:"status","data-testid":"inline-ai-thinking",style:ke,children:"Thinking\u2026"}):F?(0,x.jsx)("p",{role:"status","data-testid":"inline-ai-asking",style:ke,children:"Asking\u2026"}):y?(0,x.jsx)("p",{role:"alert","data-testid":"inline-ai-failed",style:{...ke,color:"var(--graview-warn)"},children:y}):w?(0,x.jsx)("p",{role:"status",style:ke,children:w}):null,(0,x.jsxs)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:2},children:[A.map(u=>(0,x.jsx)("li",{children:(0,x.jsxs)("button",{type:"button","data-menu-item":`ai-offer:${u.id}`,"data-ai-offer":u.id,"data-ai-offer-type":u.type,onClick:()=>v(O=>Pn(t,g,u,O)),style:G,children:[u.label,(0,x.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",u.type==="panel"?"a panel":u.type==="place"?"go there":u.type==="record"?"open it":"suggested"]})]})},u.id)),!a&&g===null?(0,x.jsx)("li",{children:(0,x.jsx)("button",{type:"button","data-menu-item":"ai-suggest","aria-disabled":b||void 0,onClick:u=>{b||(M.current=document.activeElement===u.currentTarget,P(!0))},style:G,children:b?"Thinking\u2026":"Suggest\u2026"})}):null,s?(0,x.jsx)("li",{children:(0,x.jsx)("button",{type:"button","data-menu-item":"ai-fill",onClick:()=>v(async u=>$(await re(t,"fill",i,"Fill in",u))),style:G,children:"Fill in with AI"})}):null,p?(0,x.jsx)("li",{children:(0,x.jsx)("button",{type:"button","data-menu-item":"ai-record",onClick:()=>v(async u=>$(await re(t,"record",i,"Add one",u))),style:G,children:"Add one with AI"})}):null,d.map(u=>(0,x.jsx)("li",{children:(0,x.jsx)("button",{type:"button","data-menu-item":`ai-open:${u.place}`,"data-ai-existing":u.fit,onClick:()=>{n(),t.goTo.place(u.place),u.fit==="partial"&&ce(t.desk,{target:{on:"lens",place:u.place,...u.kind?{kind:u.kind}:{}}})},style:G,children:u.fit==="full"?`Open ${u.title}`:`Open and adjust ${u.title}`})},u.place)),c?(0,x.jsx)("li",{children:(0,x.jsx)("button",{type:"button","data-menu-item":"ai-panel",onClick:()=>v(async u=>$(await re(t,"panel",i,"Draw a panel",u))),style:G,children:d.length>0?"Draw a new view":"Draw a panel"})}):null,(0,x.jsx)("li",{children:(0,x.jsx)("button",{type:"button","data-menu-item":"ai-ask",onClick:()=>{let u=document.activeElement;n(),ce(t.desk,{target:i,returnTo:u instanceof HTMLElement&&u!==document.body?u:null})},style:G,children:"Ask about this\u2026"})})]})]})}var be={display:"inline-flex",alignItems:"center",minHeight:28,padding:"2px 10px",fontSize:"0.8125rem",borderRadius:8};function Zn({placement:e="picture"}){let{store:n,principal:t,aiDesk:i}=Je(),o=Le(n,t),{ghost:s,entries:c}=He(i),[d,l]=(0,I.useState)(new Set);(0,I.useEffect)(()=>l(new Set),[s?.ghost.interaction]);let p=(0,I.useRef)(null),a=(0,I.useRef)(null),f=s?.batch;if((0,I.useEffect)(()=>{f!==void 0&&a.current?.focus()},[f]),!s)return null;let{ghost:h}=s,b=c.find(g=>g.id===h.interaction),P=()=>{let g=h.target.on==="record"||h.target.on==="field"?h.target.id:void 0,A=p.current?.closest("[data-graview-face], main")?.parentElement??document,w=(g?A.querySelector(`[data-graview-view="${CSS.escape(g)}"][tabindex]`):null)??document.querySelector("[data-graview-page-title]")??p.current?.closest("main")??document.querySelector("main");w&&!w.hasAttribute("tabindex")&&w.setAttribute("tabindex","-1"),w?.focus({preventScroll:!0}),i.setGhost(null)},S=h.proposals.filter(g=>!d.has(g.id)).map(g=>g.id),m=()=>{let g=Xe(o,h,{author:t,ids:S});if(!g.ok){i.setGhost({...s,refused:g.refused});return}b&&i.record(Ze(b,g.accepted,g.batch)),i.setGhost({ghost:h,batch:g.batch,took:g.accepted.length,...s.onCard?{onCard:!0}:{}})},C=()=>{b&&s.batch===void 0&&i.record(en(b)),P()},k=()=>{if(s.batch!==void 0)try{o.undo(s.batch,{author:t}),P()}catch(g){i.setGhost({...s,refused:g instanceof Error?g.message:String(g)})}};return(0,x.jsxs)("section",{ref:p,"data-testid":"ai-ghost","data-interaction":h.interaction,"aria-label":"Proposed by AI",style:{...e==="card"?{position:"static"}:{position:e==="page"?"fixed":"absolute",insetInline:"max(12px, calc(50% - 220px))",bottom:"calc(var(--graview-foot-room, 0px) + 72px)",zIndex:De("toast"),boxShadow:"var(--graview-lift-high)"},display:"grid",gap:8,padding:12,borderRadius:12,border:"1px dashed var(--graview-accent)",background:"var(--graview-float)",fontSize:"0.875rem"},children:[(0,x.jsx)("p",{style:{margin:0,color:"var(--graview-ink-muted)"},children:s.batch!==void 0?`Done: ${s.took===1?"one change":`${s.took} changes`}, as one.`:`Proposed by AI \xB7 ${h.basis}`}),s.batch===void 0?(0,x.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:4},children:h.proposals.map(g=>(0,x.jsx)("li",{"data-ghost-proposal":g.id,children:(0,x.jsxs)("label",{style:{display:"flex",alignItems:"baseline",gap:8,cursor:"pointer"},children:[(0,x.jsx)("input",{type:"checkbox",checked:!d.has(g.id),onChange:A=>{let w=new Set(d);A.target.checked?w.delete(g.id):w.add(g.id),l(w)}}),(0,x.jsx)("span",{style:{fontStyle:"italic",color:"var(--graview-ink)"},children:g.said}),g.confidence!==void 0?(0,x.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[Math.round(g.confidence*100),"% sure"]}):null]})},g.id))}):null,s.refused?(0,x.jsx)("p",{role:"alert",style:{margin:0,color:"var(--graview-warn)"},children:s.refused}):null,(0,x.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:s.batch===void 0?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)("button",{type:"button","data-testid":"ghost-accept",disabled:S.length===0,onClick:m,style:be,children:S.length===h.proposals.length?"Accept":`Accept ${S.length} of ${h.proposals.length}`}),(0,x.jsx)("button",{type:"button","data-testid":"ghost-dismiss",onClick:C,style:be,children:"Dismiss"})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)("button",{type:"button",ref:a,"data-testid":"ghost-undo",onClick:k,style:be,children:"Undo"}),(0,x.jsx)("button",{type:"button","data-testid":"ghost-close",onClick:P,style:be,children:"Close"})]})})]})}export{Ge as a,V as b,ye as c,ze as d,ee as e,ve as f,hn as g,mn as h,Fn as i,Jn as j,tn as k,on as l,re as m,Cn as n,$n as o,Pn as p,Yn as q,Xn as r,Zn as s};
|
|
@@ -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{l as k,n as M,o as I,p as B,s as P}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{l as k,n as M,o as I,p as B,s as P}from"./chunk.HDRD33II.js";import"./chunk.DX357TZ3.js";import"./chunk.H7KCWCB4.js";import"./chunk.XSNAG4JT.js";import{G as te,R as W,wa as q}from"./chunk.XWAMQPUM.js";import{a as L}from"./chunk.SDO3U72B.js";import"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import{b as h}from"./chunk.AJZBJBMO.js";var r=h(te(),1);var A=h(W(),1),U=q(L(()=>(__graviewPreload(import.meta.url,["./chunk.XSNAG4JT.js","./chunk.XWAMQPUM.js","./chunk.SDO3U72B.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.N7VNEUJR.js")))),v={Part:U.part((n,t)=>(0,A.jsx)(n.WhenMonth,{...t}),{quiet:!0}),prefetch:()=>U.prefetch()};var o=h(W(),1),z="try \u201Ctomorrow 3pm\u201D, \u201CFri 10:30\u201D or \u201C17 Oct\u201D";function K(n,t,d,p=!1){let S=Date.UTC(+n.day.slice(0,4),+n.day.slice(5,7)-1,+n.day.slice(8,10),0,t?n.minutes??0:0),g={weekday:p?"long":"short",year:"numeric",month:p?"long":"short",day:"numeric",...t?{hour:"numeric",minute:"2-digit"}:{},timeZone:"UTC"},m;try{m=new Intl.DateTimeFormat(d??"en-US",g)}catch{m=new Intl.DateTimeFormat("en-US",g)}return m.format(S).replace(/ /g," ")}function ce({value:n,time:t,instant:d=!1,label:p,name:S,required:g,autoFocus:m,autoSelect:H,locale:s,onChange:j,onLeave:_,onCancel:V,inputRef:w,boxStyle:Z}){let x=(0,r.useId)(),u=(0,r.useRef)(null),D=(0,r.useRef)(null),b=e=>{let a=M(e);return a?K(a,t,s):e??""},[T,C]=(0,r.useState)(()=>b(n)),[F,y]=(0,r.useState)(!1),[G,E]=(0,r.useState)(n),[J,Q]=(0,r.useState)(n);n!==J&&(Q(n),n!==G&&(E(n),C(b(n)))),(0,r.useEffect)(()=>{H&&(u.current?.focus(),u.current?.select())},[H]);let i=t&&d?B(s):void 0,N=T===b(n),l=M(n),c=N?l:P(T,{today:k().day,time:t,...l?{base:l}:{},...s?{locale:s}:{}}),X=N?n:c?I(c,{time:t,instant:d}):void 0,$=T.trim()==="",f=!$&&c===void 0;(0,r.useEffect)(()=>{u.current?.setCustomValidity(f?`Not a date this reads \u2014 ${z}`:"")},[f]);let O=e=>{E(e),j(e)},Y=e=>{C(e);let a=e.trim()===""?void 0:P(e,{today:k().day,time:t,...l?{base:l}:{},...s?{locale:s}:{}});O(a?I(a,{time:t,instant:d}):void 0)},ee=e=>{let a=t?{day:e,minutes:c?.minutes??l?.minutes??540}:{day:e},R=I(a,{time:t,instant:d});C(b(R)),O(R),y(!1),requestAnimationFrame(()=>{u.current?.focus(),u.current?.select()})},ne=$?`Type a date, or pick one \u2014 ${z}`:f?`Not a date this reads \u2014 ${z}`:c?`${K(c,t,s,!0)}${i?` ${i.short}`:""}`:"";return(0,o.jsxs)("span",{"data-graview-when":t?d?"instant":"moment":"day",style:{display:"inline-flex",flex:"1 1 14rem",flexWrap:"wrap",alignItems:"center",gap:"4px 6px",maxWidth:"100%",minWidth:0},onBlur:e=>{let a=e.relatedTarget;a&&e.currentTarget.contains(a)||!a&&typeof document<"u"&&!document.hasFocus()||(y(!1),_?.(X))},children:[(0,o.jsx)("input",{ref:e=>{u.current=e,typeof w=="function"?w(e):w&&(w.current=e)},type:"text",name:S,required:g,autoFocus:m,"aria-label":p,"aria-describedby":`${x}-said`,"aria-invalid":f||void 0,autoComplete:"off",spellCheck:!1,enterKeyHint:"done",placeholder:t?"tomorrow 3pm":"17 Oct",value:T,"data-graview-part":"control",onChange:e=>Y(e.target.value),onKeyDown:e=>{e.key==="Escape"?(e.preventDefault(),V?.()):e.key==="ArrowDown"&&e.altKey&&(e.preventDefault(),y(!0))},style:{flex:"1 1 12ch",minWidth:"10ch",maxWidth:"100%",boxSizing:"border-box",font:"inherit",...Z}}),(0,o.jsx)("button",{ref:D,type:"button","aria-label":`Pick a date for ${p}`,"aria-expanded":F,"aria-controls":`${x}-month`,"data-graview-part":"when-pick",onClick:()=>y(e=>!e),onPointerEnter:()=>v.prefetch(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:32,minHeight:32,padding:0,borderRadius:6},children:(0,o.jsxs)("svg",{"aria-hidden":"true",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",children:[(0,o.jsx)("rect",{x:"2",y:"3",width:"12",height:"11",rx:"1.5"}),(0,o.jsx)("path",{d:"M2 6.5h12M5.5 1.5v3M10.5 1.5v3"})]})}),(0,o.jsxs)("span",{id:`${x}-said`,"aria-live":"polite","data-graview-part":"when-said",...i?{"data-graview-zone":i.zone,title:`Times are in ${i.zone.replace(/_/g," ")} (${i.short})`}:{},style:{flexBasis:"100%",fontSize:"0.75rem",color:f?"var(--graview-bad)":"var(--graview-ink-faint)"},children:[ne,i&&!f&&!$?(0,o.jsx)("span",{"data-graview-part":"when-zone",children:` \xB7 ${(i.zone.split("/").at(-1)??i.zone).replace(/_/g," ")} time`}):null]}),F?(0,o.jsx)(r.Suspense,{fallback:null,children:(0,o.jsx)(v.Part,{id:`${x}-month`,label:p,selected:c?.day??l?.day,today:k().day,locale:s,onPick:ee,onClose:()=>{y(!1),D.current?.focus()}})}):null]})}export{ce as WhenInput,K as wallAsRead};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as a}from"./chunk.
|
|
1
|
+
import{s as a}from"./chunk.6MADC6DM.js";import{G as f,R as s,_ as l}from"./chunk.XWAMQPUM.js";import{b as i}from"./chunk.AJZBJBMO.js";var d=i(f(),1),p=i(s(),1),c=new Set;function B(e){return c.add(e),()=>void c.delete(e)}function S(){let{store:e,principal:o}=l();return(0,d.useMemo)(()=>n=>{let t=n.on===void 0?void 0:e.graph.getNode(n.on);if(!t)return null;let u=[...c].filter(r=>r.store===e&&r.kind===t.kind);return(n.element?u.find(r=>r.root()?.contains(n.element)??!1):u[0])?.section(t.id,o)??null},[e,o])}function v({children:e}){let o=S(),n=(0,d.useMemo)(()=>[o],[o]);return(0,p.jsx)(a,{sections:n,children:e})}export{B as a,S as b,v as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{G as l,N as p,U as k,W as y,c}from"./chunk.JF3GD4H5.js";import"./chunk.ONEYVLC2.js";import"./chunk.WQONZBA3.js";import"./chunk.UGFDSE37.js";import{b as m}from"./chunk.NWA7Q6CI.js";import"./chunk.WP5W44Y4.js";import"./chunk.M5GJHVWZ.js";import"./chunk.HZCA3UWJ.js";import"./chunk.JBW3DI7E.js";import"./chunk.AGIO2GRV.js";import"./chunk.NIVTK2W5.js";import"./chunk.6QYJ2K6K.js";import"./chunk.3MMLRSRC.js";import"./chunk.DQOCBKC3.js";import"./chunk.OHSJQYJN.js";import"./chunk.DEUTHHGI.js";import"./chunk.EPUBSKKL.js";import"./chunk.ATDU5Y7V.js";import"./chunk.AQQZY6OY.js";import"./chunk.BCWPV4WR.js";import"./chunk.Y5ARSVH4.js";import"./chunk.PKUDIWIF.js";import"./chunk.VW2VCPJX.js";import"./chunk.MB7LKKUD.js";import"./chunk.WVUJXDXZ.js";import"./chunk.ZIEHF67C.js";import"./chunk.UHX4WTM7.js";import"./chunk.IKX4VDTW.js";import"./chunk.RNEJYIQ7.js";import"./chunk.TBQOSI4J.js";import"./chunk.KWQ7QOHD.js";import"./chunk.GZHZLJBF.js";import"./chunk.6MADC6DM.js";import"./chunk.OJGHDWI6.js";import"./chunk.JLEC3USG.js";import"./chunk.HDRD33II.js";import"./chunk.DX357TZ3.js";import"./chunk.H7KCWCB4.js";import"./chunk.XSNAG4JT.js";import{$ as g,G as S,H as s,I as d,R as f}from"./chunk.XWAMQPUM.js";import"./chunk.SDO3U72B.js";import"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import{b as n}from"./chunk.AJZBJBMO.js";var u=n(S(),1);var t=n(f(),1);function D({context:a}){let r=l(),h=g(),[w]=(0,u.useState)(()=>s(null)),o=d(h?.seatTalk??w),P=()=>{(window.history.state?.idx??0)>0?r(-1):r("/")};return(0,t.jsxs)(k,{context:a,"data-testid":"draft-page",children:[(0,t.jsx)(y,{context:a,...o.draft?{"data-testid":"draft-title"}:{},children:o.draft?o.draft.title:"Nothing drawn"}),o.draft?(0,t.jsx)(m,{page:!0,go:e=>r(e.address),onPick:e=>{let i=a.store.graph.getNode(e);i&&r(c(a.store.schema,i.kind,e))},onDiscard:P}):(0,t.jsxs)("p",{style:{margin:0,color:"var(--graview-ink-muted)"},children:["Ask for a way of seeing \u2014 \u201Ca board of tasks by status\u201D \u2014 and it is drawn here."," ",(0,t.jsx)(p,{to:"/",style:{color:"var(--graview-accent)"},children:"Home \u2192"})]})]})}export{D as DraftPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk.
|
|
1
|
+
import"./chunk.XSNAG4JT.js";import{G as W,R as x}from"./chunk.XWAMQPUM.js";import"./chunk.SDO3U72B.js";import"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import{b as D}from"./chunk.AJZBJBMO.js";var g=D(W(),1);var o=D(x(),1),v=864e5,l=t=>Date.UTC(+t.slice(0,4),+t.slice(5,7)-1,+t.slice(8,10)),I=t=>new Date(t).toISOString().slice(0,10),s=(t,i)=>I(l(t)+i*v),m=(t,i)=>{let a=new Date(l(t)),u=a.getUTCMonth()+i,d=Date.UTC(a.getUTCFullYear(),u,1),w=new Date(Date.UTC(a.getUTCFullYear(),u+1,0)).getUTCDate();return I(d+(Math.min(a.getUTCDate(),w)-1)*v)};function p(t,i,a){try{return new Intl.DateTimeFormat(t??"en-US",{...i,timeZone:"UTC"}).format(a)}catch{return new Intl.DateTimeFormat("en-US",{...i,timeZone:"UTC"}).format(a)}}function F(t){try{let i=new Intl.Locale(t??"en-US"),a=i.getWeekInfo?.().firstDay??i.weekInfo?.firstDay;if(a!==void 0)return a%7}catch{return 0}return/^en-US|^en$|-(US|CA|JP|BR|IL|MX|PH)$/.test(t??"en-US")?0:1}function L({id:t,label:i,selected:a,today:u,locale:d,onPick:w,onClose:T}){let[r,f]=(0,g.useState)(a??u),U=(0,g.useRef)(null),y=F(d),b=`${r.slice(0,7)}-01`,M=(new Date(l(b)).getUTCDay()-y+7)%7,P=s(b,-M),A=Array.from({length:6},(e,n)=>Array.from({length:7},(S,c)=>s(P,n*7+c))),$=p(d,{month:"long",year:"numeric"},l(b)),h=(0,g.useRef)(!0);(0,g.useEffect)(()=>{h.current&&U.current?.querySelector(`[data-day="${r}"]`)?.focus(),h.current=!1},[r]);let E=e=>{let n={ArrowLeft:()=>s(r,-1),ArrowRight:()=>s(r,1),ArrowUp:()=>s(r,-7),ArrowDown:()=>s(r,7),PageUp:()=>m(r,e.shiftKey?-12:-1),PageDown:()=>m(r,e.shiftKey?12:1),Home:()=>s(r,-((new Date(l(r)).getUTCDay()-y+7)%7)),End:()=>s(r,6-(new Date(l(r)).getUTCDay()-y+7)%7)};n[e.key]?(e.preventDefault(),h.current=!0,f(n[e.key]())):e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),T())},R=Array.from({length:7},(e,n)=>l("1970-01-04")+(y+n)%7*v),C={minWidth:32,minHeight:32,padding:"0 8px",borderRadius:6};return(0,o.jsxs)("div",{id:t,role:"group","aria-label":`Pick a date for ${i}`,"data-graview-part":"when-month",onKeyDown:e=>{e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),T())},style:{flexBasis:"100%",width:"min(100%, 20rem)",boxSizing:"border-box",padding:8,border:"1px solid var(--graview-edge)",borderRadius:8,background:"var(--graview-panel)",color:"var(--graview-ink)"},children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:6,marginBottom:6},children:[(0,o.jsx)("button",{type:"button","aria-label":"Previous month",onClick:()=>f(m(r,-1)),style:C,children:"\u2039"}),(0,o.jsx)("span",{id:`${t}-title`,"aria-live":"polite",style:{fontWeight:600,fontSize:"0.875rem"},children:$}),(0,o.jsx)("button",{type:"button","aria-label":"Next month",onClick:()=>f(m(r,1)),style:C,children:"\u203A"})]}),(0,o.jsxs)("table",{ref:U,role:"grid","aria-labelledby":`${t}-title`,onKeyDown:E,style:{width:"100%",borderCollapse:"collapse",tableLayout:"fixed",fontSize:"0.8125rem"},children:[(0,o.jsx)("thead",{children:(0,o.jsx)("tr",{children:R.map(e=>(0,o.jsx)("th",{scope:"col",abbr:p(d,{weekday:"long"},e),style:{fontWeight:500,color:"var(--graview-ink-faint)",padding:"2px 0"},children:p(d,{weekday:"narrow"},e)},e))})}),(0,o.jsx)("tbody",{children:A.map(e=>(0,o.jsx)("tr",{children:e.map(n=>{let S=n.slice(0,7)===b.slice(0,7),c=n===a,k=n===u;return(0,o.jsx)("td",{role:"gridcell","aria-selected":c||void 0,style:{padding:1,textAlign:"center"},children:(0,o.jsx)("button",{type:"button","data-day":n,tabIndex:n===r?0:-1,"aria-label":`${p(d,{weekday:"long",year:"numeric",month:"long",day:"numeric"},l(n))}${k?", today":""}${c?", selected":""}`,...k?{"aria-current":"date"}:{},onClick:()=>w(n),onFocus:()=>n!==r&&f(n),style:{width:"100%",minHeight:36,padding:0,borderRadius:6,border:k?"1px solid var(--graview-accent)":"1px solid transparent",background:c?"var(--graview-accent)":"transparent",color:c?"var(--graview-accent-ink)":S?"var(--graview-ink)":"var(--graview-ink-faint)",fontWeight:c?600:400},children:Number(n.slice(8,10))})},n)})},e[0]))})]})]})}export{L as WhenMonth};
|