graview 0.1.32 → 0.1.34

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.
Files changed (142) hide show
  1. package/dist/preview/{chunk.7GKUVQVF.js → chunk.2UPGH6FT.js} +1 -1
  2. package/dist/preview/{chunk.I6FPNX43.js → chunk.2YCFK5HU.js} +1 -1
  3. package/dist/preview/{chunk.4HZ7QTXZ.js → chunk.2YGQVI6T.js} +1 -1
  4. package/dist/preview/{chunk.3K6YSVHC.js → chunk.34CYK2DF.js} +1 -1
  5. package/dist/preview/{chunk.3TVXGJTU.js → chunk.35KI7XYV.js} +1 -1
  6. package/dist/preview/{chunk.COQKECUH.js → chunk.3C4RJIJU.js} +1 -1
  7. package/dist/preview/{chunk.TAQ764IQ.js → chunk.3H4NVUWV.js} +1 -1
  8. package/dist/preview/{chunk.K5ME5GCG.js → chunk.3MWBWSYF.js} +1 -1
  9. package/dist/preview/{chunk.MAF7C3VM.js → chunk.4K5QCJFH.js} +1 -1
  10. package/dist/preview/{chunk.ULRW47RP.js → chunk.52QAIGCD.js} +1 -1
  11. package/dist/preview/{chunk.D75KC3LL.js → chunk.577PGFUT.js} +1 -1
  12. package/dist/preview/{chunk.EBGAYL32.js → chunk.5EAQDBBE.js} +1 -1
  13. package/dist/preview/{chunk.4MERAWS2.js → chunk.6A62UVAE.js} +1 -1
  14. package/dist/preview/{chunk.7T7NZZTC.js → chunk.6FBQP336.js} +1 -1
  15. package/dist/preview/{chunk.EF3XNU4O.js → chunk.6K2HASOH.js} +1 -1
  16. package/dist/preview/chunk.6P7P2AW7.js +1 -0
  17. package/dist/preview/{chunk.LXBOVRFI.js → chunk.6VRJII5M.js} +1 -1
  18. package/dist/preview/{chunk.VG3O4LWB.js → chunk.6XO4PECH.js} +1 -1
  19. package/dist/preview/{chunk.GYICGZMG.js → chunk.7HPPJVIV.js} +2 -2
  20. package/dist/preview/{chunk.PIP6Z563.js → chunk.7JNDZWD6.js} +1 -1
  21. package/dist/preview/{chunk.6UGEYZAC.js → chunk.7MTX33WD.js} +1 -1
  22. package/dist/preview/{chunk.ASCLIM2P.js → chunk.7VUPKOKC.js} +1 -1
  23. package/dist/preview/{chunk.LLLZEGRK.js → chunk.7WHWD5YJ.js} +1 -1
  24. package/dist/preview/{chunk.NM6MZYFN.js → chunk.7X2ZO5BD.js} +1 -1
  25. package/dist/preview/{chunk.XNJEFUF7.js → chunk.AHCI7ZDO.js} +1 -1
  26. package/dist/preview/{chunk.JFAOHHJJ.js → chunk.APNN6BKF.js} +1 -1
  27. package/dist/preview/{chunk.QGTSHKJL.js → chunk.B2WRXGFI.js} +1 -1
  28. package/dist/preview/{chunk.HLTRQU4Y.js → chunk.B6VI576I.js} +1 -1
  29. package/dist/preview/{chunk.NTF7FVB2.js → chunk.BU2DSZ2L.js} +1 -1
  30. package/dist/preview/{chunk.T5VG5A6V.js → chunk.CNMITOKP.js} +1 -1
  31. package/dist/preview/chunk.CPW465TM.js +1 -0
  32. package/dist/preview/{chunk.47STJVRV.js → chunk.CZRX2FDI.js} +1 -1
  33. package/dist/preview/{chunk.GV2CQVKV.js → chunk.DMNXYMLC.js} +1 -1
  34. package/dist/preview/{chunk.F6ZK7RMB.js → chunk.DNDHDDM6.js} +2 -2
  35. package/dist/preview/{chunk.MWGGV7DE.js → chunk.DUUARGPE.js} +1 -1
  36. package/dist/preview/chunk.E7EQ2VTE.js +1 -0
  37. package/dist/preview/{chunk.UHUGOTUU.js → chunk.ETWVQ3A2.js} +1 -1
  38. package/dist/preview/{chunk.BNV77BQZ.js → chunk.F6WYSDSI.js} +3 -3
  39. package/dist/preview/{chunk.FWTIUYXH.js → chunk.FBY5IUGU.js} +1 -1
  40. package/dist/preview/{chunk.UATVTXZY.js → chunk.FCRFQ7ZW.js} +1 -1
  41. package/dist/preview/chunk.FRS3S7DN.js +1 -0
  42. package/dist/preview/{chunk.UGFJKSHU.js → chunk.FSAHO3LV.js} +1 -1
  43. package/dist/preview/{chunk.JQU5GEU3.js → chunk.FUQVNXLB.js} +1 -1
  44. package/dist/preview/{chunk.JDUJDAGA.js → chunk.G64AREGA.js} +1 -1
  45. package/dist/preview/{chunk.CN3UEF5N.js → chunk.GMOTRAKJ.js} +1 -1
  46. package/dist/preview/chunk.GNSAKLP2.js +1 -0
  47. package/dist/preview/{chunk.RCKTBOY2.js → chunk.HCDKSDIS.js} +1 -1
  48. package/dist/preview/chunk.HH6P4BLT.js +1 -0
  49. package/dist/preview/{chunk.AOSMJKLH.js → chunk.HJ56Q6WB.js} +1 -1
  50. package/dist/preview/chunk.HP3ZEDCD.js +117 -0
  51. package/dist/preview/{chunk.G5NZVPJU.js → chunk.HPD5ZDZH.js} +1 -1
  52. package/dist/preview/chunk.HPEGQN6E.js +1 -0
  53. package/dist/preview/chunk.HUKAVTMX.js +1 -0
  54. package/dist/preview/chunk.HWITWOP3.js +3 -0
  55. package/dist/preview/{chunk.3TY5NFLY.js → chunk.IHFNLKXV.js} +1 -1
  56. package/dist/preview/{chunk.2NIOHEMX.js → chunk.JQDYGI6G.js} +1 -1
  57. package/dist/preview/chunk.JZBBGY4B.js +1 -0
  58. package/dist/preview/chunk.KA3KI4UA.js +1 -0
  59. package/dist/preview/{chunk.OF34OZ4V.js → chunk.KSXB4LDF.js} +1 -1
  60. package/dist/preview/{chunk.HAIG6NVX.js → chunk.LAF6GTBN.js} +1 -1
  61. package/dist/preview/{chunk.UNL2HIF2.js → chunk.LCFDM7XY.js} +1 -1
  62. package/dist/preview/{chunk.E2YEOMPH.js → chunk.LIIC25G6.js} +1 -1
  63. package/dist/preview/chunk.M5HADQPP.js +1 -0
  64. package/dist/preview/chunk.MWJUZG3C.js +6 -0
  65. package/dist/preview/chunk.OMMKD2NU.js +2 -0
  66. package/dist/preview/{chunk.JOOQUWLT.js → chunk.PNVR3CXR.js} +2 -2
  67. package/dist/preview/{chunk.PBSMLINK.js → chunk.PPUAPAWR.js} +1 -1
  68. package/dist/preview/{chunk.SYAEBGDC.js → chunk.PW7YH6JV.js} +1 -1
  69. package/dist/preview/{chunk.OC6IWRQ3.js → chunk.Q7TP4RFE.js} +1 -1
  70. package/dist/preview/{chunk.CIPS2OGR.js → chunk.QPAUQJON.js} +1 -1
  71. package/dist/preview/{chunk.UZGRRDHD.js → chunk.QU356VB2.js} +1 -1
  72. package/dist/preview/chunk.QVKKXMNK.js +1 -0
  73. package/dist/preview/{chunk.3AGY4QVS.js → chunk.QVUL2FSI.js} +1 -1
  74. package/dist/preview/chunk.RH45AW2W.js +1 -0
  75. package/dist/preview/{chunk.6YCBYL2Y.js → chunk.RIW7SQH4.js} +1 -1
  76. package/dist/preview/{chunk.H7EPE74C.js → chunk.RN3EZVV4.js} +1 -1
  77. package/dist/preview/{chunk.3HXN4BOY.js → chunk.RYEAMM73.js} +1 -1
  78. package/dist/preview/{chunk.YIR7PPF3.js → chunk.SIH6RCAI.js} +1 -1
  79. package/dist/preview/{chunk.NRAYZY3X.js → chunk.T2L4NPSB.js} +1 -1
  80. package/dist/preview/{chunk.DHIUSUCL.js → chunk.T3M4FALL.js} +5 -5
  81. package/dist/preview/{chunk.CX3KL2C5.js → chunk.TCSZZAYB.js} +1 -1
  82. package/dist/preview/chunk.TPX6AVJL.js +1 -0
  83. package/dist/preview/{chunk.5UL7YDUD.js → chunk.U5ACEYAN.js} +1 -1
  84. package/dist/preview/{chunk.5T5XGILP.js → chunk.UA5UYINM.js} +1 -1
  85. package/dist/preview/{chunk.GO4XBWJO.js → chunk.UCIQIPBQ.js} +1 -1
  86. package/dist/preview/{chunk.EKPRNDUV.js → chunk.UHQD3NTK.js} +1 -1
  87. package/dist/preview/{chunk.RIJUCHP4.js → chunk.VKH3ZPPQ.js} +1 -1
  88. package/dist/preview/{chunk.UBFNZMUX.js → chunk.VMGWYCXU.js} +1 -1
  89. package/dist/preview/chunk.VOFUIWAX.js +27 -0
  90. package/dist/preview/{chunk.DYSPCGXX.js → chunk.VSOB2QEK.js} +1 -1
  91. package/dist/preview/{chunk.R6K6GF5R.js → chunk.VZHV25JE.js} +1 -1
  92. package/dist/preview/chunk.WAB6ZS2V.js +1 -0
  93. package/dist/preview/chunk.WLBXBNNH.js +1 -0
  94. package/dist/preview/chunk.WPCGHGDA.js +1 -0
  95. package/dist/preview/{chunk.QYZNAUIR.js → chunk.WYEYYCBH.js} +1 -1
  96. package/dist/preview/{chunk.MNP4JI33.js → chunk.X7W27IRI.js} +4 -4
  97. package/dist/preview/{chunk.J25KOSNW.js → chunk.XK4FVT2X.js} +1 -1
  98. package/dist/preview/{chunk.CWHRDBOF.js → chunk.XXMYKBLT.js} +1 -1
  99. package/dist/preview/{chunk.CDP2XL66.js → chunk.XZYJRNRY.js} +1 -1
  100. package/dist/preview/chunk.YCIX53AR.js +1 -0
  101. package/dist/preview/chunk.YEYY273R.js +1 -0
  102. package/dist/preview/{chunk.EJPI3ST6.js → chunk.YJCT3DV2.js} +1 -1
  103. package/dist/preview/chunk.YT2CYCVT.js +1 -0
  104. package/dist/preview/{chunk.B2GLDIAS.js → chunk.Z7ZCR4LN.js} +1 -1
  105. package/dist/preview/{chunk.CAVBSL27.js → chunk.ZE4CTZQ3.js} +1 -1
  106. package/dist/preview/chunk.ZFWV4JAJ.js +1 -0
  107. package/dist/preview/{chunk.5H4VXLZF.js → chunk.ZJX6ZKKM.js} +1 -1
  108. package/dist/preview/chunk.ZPQKAJRI.js +1 -0
  109. package/dist/preview/{chunk.OKRNJXTV.js → chunk.ZSW74NVJ.js} +1 -1
  110. package/dist/preview/chunk.ZTD2CNC3.js +25 -0
  111. package/dist/preview/{chunk.QVVJRSRM.js → chunk.ZTFW7RKP.js} +1 -1
  112. package/dist/preview/index.html +42 -42
  113. package/dist/preview/page.js +2 -2
  114. package/package.json +6 -6
  115. package/dist/preview/chunk.4HRAQNJO.js +0 -27
  116. package/dist/preview/chunk.52W7WYME.js +0 -1
  117. package/dist/preview/chunk.5TVB6BUY.js +0 -1
  118. package/dist/preview/chunk.63GXY2ME.js +0 -1
  119. package/dist/preview/chunk.6QWV5MVH.js +0 -25
  120. package/dist/preview/chunk.AKFKM4SW.js +0 -3
  121. package/dist/preview/chunk.BOO6WVM4.js +0 -117
  122. package/dist/preview/chunk.BQ3JHEHV.js +0 -1
  123. package/dist/preview/chunk.CJJLJ3KW.js +0 -2
  124. package/dist/preview/chunk.DAZ2VSRD.js +0 -1
  125. package/dist/preview/chunk.ERIT3R6N.js +0 -1
  126. package/dist/preview/chunk.EYTBDMTW.js +0 -1
  127. package/dist/preview/chunk.F6EH7HI2.js +0 -1
  128. package/dist/preview/chunk.FSTCX2AI.js +0 -1
  129. package/dist/preview/chunk.H7BST3XO.js +0 -1
  130. package/dist/preview/chunk.IDVAR5HM.js +0 -1
  131. package/dist/preview/chunk.K7PMDSOL.js +0 -1
  132. package/dist/preview/chunk.KSES5U5B.js +0 -1
  133. package/dist/preview/chunk.LR3VDXPI.js +0 -1
  134. package/dist/preview/chunk.N6OX4NEQ.js +0 -1
  135. package/dist/preview/chunk.PHKSMUIA.js +0 -1
  136. package/dist/preview/chunk.SHTJZ6UX.js +0 -1
  137. package/dist/preview/chunk.TCNBCTWO.js +0 -1
  138. package/dist/preview/chunk.WAZ7OGBD.js +0 -1
  139. package/dist/preview/chunk.XANVHJQ4.js +0 -1
  140. package/dist/preview/chunk.XKABS745.js +0 -1
  141. package/dist/preview/chunk.XMC7YDWT.js +0 -1
  142. package/dist/preview/chunk.Y6ZNFQK3.js +0 -6
@@ -0,0 +1,117 @@
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 zr,B as Se,C as Pn,D as Fe,E as qe,F as _r,G as An,H as Ce,I as Yr,J as Qr,K as F,L as ot,M as Cn,N as Xr,O as Rn,P as Ht,Q as Jr,R as ie,S as le,T as Ln,a as J,b as Te,c as te,d as Br,e as Sn,f as xn,g as it,h as ne,i as we,j as se,k as A,l as re,m as q,n as ke,o as Ft,p as be,q as ye,r as Vr,s as gt,t as Dt,u as ee,v as Ke,w as Ur,x as Wt,y as Ae,z as jr}from"./chunk.7X2ZO5BD.js";import{b as Gr,c as It,e as ae}from"./chunk.HUKAVTMX.js";import{a as Hr,d as Kr,e as qr}from"./chunk.UGFDSE37.js";import{a as Or,c as Ir,f as Fr,g as Dr,i as Wr}from"./chunk.FRS3S7DN.js";import{a as Ar,b as Cr,c as Rr,d as bn}from"./chunk.MWJUZG3C.js";import{a as Lr,b as Tr,d as $t,e as Mr,f as Nr,i as Ot}from"./chunk.T2L4NPSB.js";import{a as Et,b as kn,c as Sr,e as xr}from"./chunk.RYEAMM73.js";import{m as Pr}from"./chunk.ETWVQ3A2.js";import{a as dr,b as cr,c as pr,e as br,f as vn,h as Nt}from"./chunk.5EAQDBBE.js";import{d as mr,e as fr,f as yr,g as hr,n as wr,o as vr,q as kr,s as Mt}from"./chunk.YT2CYCVT.js";import{a as hn}from"./chunk.QVKKXMNK.js";import{a as Tt,b as ir,c as or,d as sr,e as lr}from"./chunk.ZE4CTZQ3.js";import{a as Ct,b as Ia,c as Fa,d as Rt,e as Da}from"./chunk.XK4FVT2X.js";import{b as _a,c as ar,e as rr,f as yn}from"./chunk.WAB6ZS2V.js";import{a as Ve,b as Ja,c as Za,d as er,e as tr,f as nr}from"./chunk.JZBBGY4B.js";import{a as mn,b as ja,c as za}from"./chunk.UT6642FC.js";import{b as Ya,c as Qa,i as ut}from"./chunk.52QAIGCD.js";import{r as fn,s as Xa}from"./chunk.WLBXBNNH.js";import{f as qa,g as rt,i as Ba,j as Ga,k as gn,q as Va,r as Ua}from"./chunk.Z7ZCR4LN.js";import{b as Lt,c as Wa,d as Ha,e as Ka}from"./chunk.RIW7SQH4.js";import{C as wn,K as Er,N as $r,e as $a,f as Oa,j as Di,q as ur,r as gr}from"./chunk.PNVR3CXR.js";import{F as $e,K as Sa,M as xa,P as Pa,Q as Y,T as Aa,U as Ca,Y as Ra,Z as ue,a as ka,aa as La,ba as Ta,da as Ma,ha as at,ia as Na,ra as Ea,s as ba,w as Ee}from"./chunk.ZTD2CNC3.js";import{Ec as ya,Fc as ha,Gb as ua,Hc as At,I as ra,Jb as ga,Kb as ma,Ma as da,N as pt,Oa as ca,Pc as un,Qc as wa,Uc as va,W as tt,X as fe,Ya as cn,Z as ve,Za as pa,_ as xt,aa as nt,ca as ia,da as oa,ea as He,ec as fa,fb as Pt,la as sa,ma as la,zc as pn}from"./chunk.X7W27IRI.js";import{b as H}from"./chunk.AJZBJBMO.js";function Zr(t,e,n={}){let a=t.graph.getNode(e);if(!a)return;let i=t.schema.tryDefinition(a.kind),r=l=>fe(t.schema.tryDefinition(l.kind),l),o=new Map;for(let l of t.graph.allEdges()){let d=l.from===e?"out":l.to===e?"in":null;if(!d)continue;let c=d==="out"?l.to:l.from,p=t.graph.getNode(c);if(!p)continue;let m=(d==="out"?i:t.schema.tryDefinition(p.kind))?.edges?.[l.kind],u=d==="in"?m?.inverse??m?.description:m?.description,k=`${l.kind}|${d}|${u??""}`;(o.get(k)??(()=>{let w={edgeKind:l.kind,direction:d,...u?{description:u}:{},targets:[]};return o.set(k,w),w})()).targets.push({id:p.id,kind:p.kind,label:r(p)})}return{id:e,kind:a.kind,label:r(a),fields:Ha(ut(t.schema,t.graph,a),i),violations:cn(t.violations(n.context),[e]),actions:hn(t,[e],{focus:e,...n.principal?{principal:n.principal}:{},...n.context?{context:n.context}:{}}),links:[...o.values()].map(l=>{let d=Lt(l.targets.flatMap(c=>{let p=t.graph.getNode(c.id);return p?[p]:[]}),c=>t.schema.tryDefinition(c));return{...l,targets:[...l.targets].map(c=>d.has(c.id)?{...c,apart:d.get(c.id)}:c).sort((c,p)=>c.label.localeCompare(p.label))}})}}function Ue(t,e,n={}){return{kind:e,members:t.graph.nodesOfKind(e),actions:hn(t,[],{kindSelection:[e],...n.principal?{principal:n.principal}:{},...n.context?{context:n.context}:{}})}}function ei(t,e){let n=(r,o)=>`${r}|${JSON.stringify(o)}`,a=new Map;for(let r of[...t.affordances,...t.withheld]){if(r.provider!=="invariant")continue;let o=n(r.mutation,r.args);a.has(o)||a.set(o,r.rank??Number.MAX_SAFE_INTEGER)}let i=Number.MAX_SAFE_INTEGER;return[...e].map((r,o)=>({repair:r,declared:o})).sort((r,o)=>(a.get(n(r.repair.mutation,r.repair.args??{}))??i)-(a.get(n(o.repair.mutation,o.repair.args??{}))??i)||r.declared-o.declared).map(r=>r.repair)}function je(t){let e=t.schema.kinds.map(i=>({kind:i,plural:nt(t.schema,i),count:t.graph.nodesOfKind(i).length})),n=new Map;for(let i of t.graph.allEdges()){let r=t.graph.getNode(i.from),o=t.graph.getNode(i.to);if(!r||!o)continue;let l=`${i.kind}|${r.kind}|${o.kind}`;n.set(l,(n.get(l)??0)+1)}let a=[];for(let{kind:i}of e){let r=t.schema.tryDefinition(i)?.edges??{};for(let[o,l]of Object.entries(r)){let d=l.to==="*"||l.to===void 0?(()=>{let c=[...n.keys()].filter(p=>p.startsWith(`${o}|${i}|`)).map(p=>p.split("|")[2]);return c.length>0?c:["*"]})():l.to;for(let c of d)a.push({edgeKind:o,from:i,to:c,...l.description?{description:l.description}:{},...l.inverse?{inverse:l.inverse}:{},count:n.get(`${o}|${i}|${c}`)??0})}}return{kinds:e,relations:a}}var De=H($e(),1);var ze=H($e(),1),S=H(Y(),1),Wi=`
2
+ form:where([data-graview-part="form"]) {
3
+ /* A grid item of the section above it and a grid container for the
4
+ fields below: both halves are allowed to be narrower than what is in
5
+ them, or a big enough text size pushes the page sideways. See the note
6
+ on \`column\` in pages.tsx. */
7
+ display: grid;
8
+ grid-template-columns: minmax(0, 1fr);
9
+ min-width: 0;
10
+ gap: 12px;
11
+ }
12
+ label:where([data-graview-part="field"]),
13
+ div:where([data-graview-part="field"][data-graview-field="date"]) {
14
+ display: grid;
15
+ /* A track the width it was given: see the note on \`column\` in pages.tsx. */
16
+ grid-template-columns: minmax(0, 1fr);
17
+ min-width: 0;
18
+ gap: 4px;
19
+ }
20
+ label:where([data-graview-part="field"][data-graview-field="boolean"]) {
21
+ grid-auto-flow: column;
22
+ justify-content: start;
23
+ align-items: center;
24
+ }
25
+ span:where([data-graview-part="label"]),
26
+ legend:where([data-graview-part="label"]),
27
+ p:where([data-graview-part="unasked"]) {
28
+ font-size: 0.8125rem;
29
+ color: var(--graview-ink-muted);
30
+ }
31
+ p:where([data-graview-part="unasked"]) { margin: 0; }
32
+ input:where([data-graview-part="control"]:not([type="checkbox"])),
33
+ select:where([data-graview-part="control"]) {
34
+ font: inherit;
35
+ /* A TARGET IN EVERY ENGINE, not only in the one it was measured in.
36
+ Padding and line height alone came to 24 in Chromium and to 22 in
37
+ WebKit, which has its own intrinsic metrics for a \`select\` and rounds
38
+ nothing up for anybody. So every picker on the routed face was under
39
+ the WCAG 2.2 minimum in the browser iOS ships, and the check that says
40
+ so (\`verify-pages\`' \`bigEnoughToHit\`) only ever ran there through
41
+ \`pnpm engines\`. */
42
+ min-height: 24px;
43
+ /* NEVER WIDER THAN ITS FIELD. A select is as wide as its longest option,
44
+ and a picker over 320 vehicles ("2027 Mercedes-Benz GLE AMG 53 4MATIC+
45
+ Coupe") was 618 pixels on a 390 phone, and the whole page scrolled
46
+ sideways. It shrinks to its track and cuts the option inside its box. */
47
+ min-width: 0;
48
+ max-width: 100%;
49
+ text-overflow: ellipsis;
50
+ box-sizing: border-box;
51
+ padding: 7px 10px;
52
+ border-radius: 8px;
53
+ border: 1px solid var(--graview-edge);
54
+ background: var(--graview-panel);
55
+ color: var(--graview-ink);
56
+ }
57
+ /* A PICKER THAT STILL LOOKS LIKE ONE.
58
+ WebKit ignores an author's padding and minimum height on a \`select\`
59
+ while the native appearance is on \u2014 so every picker on the routed face
60
+ came out 22 pixels tall in the browser iOS ships, under the 24 WCAG 2.2
61
+ asks for, while the same element measured 35 in Chromium. Turning the
62
+ appearance off is what makes the box the size it was asked to be, and it
63
+ takes the platform's chevron with it; the chevron is put back, in the ink
64
+ the scheme is already using. */
65
+ span:where([data-graview-part="picker"]) {
66
+ position: relative;
67
+ display: grid;
68
+ min-width: 0;
69
+ }
70
+ span:where([data-graview-part="picker"]) > select:where([data-graview-part="control"]) {
71
+ appearance: none;
72
+ padding-right: 28px;
73
+ }
74
+ span:where([data-graview-part="chevron"]) {
75
+ position: absolute;
76
+ right: 10px;
77
+ top: 50%;
78
+ transform: translateY(-50%);
79
+ font-size: 0.75rem;
80
+ line-height: 1;
81
+ color: var(--graview-ink-muted);
82
+ pointer-events: none;
83
+ }
84
+ fieldset:where([data-graview-part="group"]) {
85
+ display: grid;
86
+ gap: 10px;
87
+ border: 1px solid var(--graview-edge);
88
+ border-radius: 10px;
89
+ padding: 12px;
90
+ }
91
+ fieldset:where([data-graview-part="group"][data-graview-field="list"]) { gap: 8px; }
92
+ div:where([data-graview-part="item"]) {
93
+ display: flex;
94
+ gap: 8px;
95
+ align-items: end;
96
+ }
97
+ button:where([data-graview-part="add"]),
98
+ button:where([data-graview-part="submit"]) { justify-self: start; }
99
+ p:where([data-graview-part="refused"]) {
100
+ margin: 0;
101
+ color: var(--graview-warn);
102
+ font-size: 0.875rem;
103
+ }
104
+ `;function Hi({title:t,name:e,optional:n,amount:a,value:i,onChange:r}){let o=Ba(a),[l,d]=(0,ze.useState)(()=>typeof i=="number"?Ga(i,a):""),c=l.trim()!==""&&gn(l,a)===void 0;return(0,S.jsxs)("label",{"data-graview-part":"field","data-graview-field":"number","data-graview-amount":a.format??"unit",children:[(0,S.jsx)("span",{"data-graview-part":"label",children:t}),(0,S.jsxs)("span",{"data-graview-part":"amount",style:{display:"flex",alignItems:"center",gap:6},children:[o.prefix?(0,S.jsx)("span",{"data-graview-part":"amount-symbol","aria-hidden":"true",children:o.prefix}):null,(0,S.jsx)("input",{type:"text",inputMode:"decimal",name:e,required:!n,placeholder:o.placeholder,title:o.hint,"aria-invalid":c||void 0,value:l,onChange:p=>{d(p.target.value),r(gn(p.target.value,a))},"data-graview-part":"control",style:{flex:1,minWidth:0}}),o.suffix?(0,S.jsx)("span",{"data-graview-part":"amount-symbol","aria-hidden":"true",children:o.suffix}):null]}),c?(0,S.jsxs)("span",{"data-graview-part":"hint",role:"status",children:["Not an amount ",o.hint,": write it like ",o.prefix??"",o.placeholder,o.suffix?` ${o.suffix}`:""]}):null]})}function ti({children:t}){return(0,S.jsxs)("span",{"data-graview-part":"picker",children:[t,(0,S.jsx)("span",{"aria-hidden":"true","data-graview-part":"chevron",children:"\u25BE"})]})}var Ki=t=>({label:ve(t),option:e=>e}),qi={phone:"+1 555 123 4567",place:"An address or a place's name",duration:"1h 30m, 90 or 1:30"};function Kt({store:t,spec:e,value:n,onChange:a,prefilled:i,open:r,words:o=Ki,values:l}){if(e.name in i&&e.control!=="group"&&e.control!=="variant")return null;let d=e.control==="node"&&!e.kinds.includes("*")?e.kinds.map(g=>ve(He(t.schema.tryDefinition(g),g))).join(" or "):o(e.name).label,c=!(e.optional||e.control==="boolean"),p=c?(0,S.jsxs)(S.Fragment,{children:[d,(0,S.jsx)("span",{"aria-hidden":"true",children:" *"})]}):d;switch(e.control){case"text":case"date":return e.control==="text"&&e.long?(0,S.jsxs)("label",{"data-graview-part":"field","data-graview-field":"text",children:[(0,S.jsxs)("span",{"data-graview-part":"label",children:[p,e.markdown?(0,S.jsx)("span",{style:{fontWeight:"normal",color:"var(--graview-ink-faint)"},children:" \xB7 Markdown"}):null]}),(0,S.jsx)("textarea",{name:e.name,required:!e.optional,rows:6,value:typeof n=="string"?n:"",onChange:g=>a(g.target.value),"data-graview-part":"control",style:{fieldSizing:"content",minHeight:"7.5em",resize:"vertical",font:"inherit",lineHeight:1.5}})]}):e.control==="date"?(0,S.jsxs)("div",{"data-graview-part":"field","data-graview-field":"date",children:[(0,S.jsx)("span",{"data-graview-part":"label",children:p}),(0,S.jsx)(nr,{name:e.name,label:o(e.name).label,required:!e.optional,value:typeof n=="string"&&n!==""?n:void 0,time:e.time===!0,instant:e.instant===!0,onChange:a})]}):(0,S.jsxs)("label",{"data-graview-part":"field","data-graview-field":e.control==="text"&&e.holds?e.holds:e.control,children:[(0,S.jsx)("span",{"data-graview-part":"label",children:p}),(0,S.jsx)("input",{type:e.control==="text"&&e.holds==="phone"?"tel":"text",name:e.name,required:!e.optional,...e.control==="text"&&e.app?{placeholder:"@owner/app or https://\u2026"}:{},...e.control==="text"&&e.holds?{placeholder:qi[e.holds]}:{},...e.control==="text"&&e.holds==="phone"?{autoComplete:"tel"}:{},value:typeof n=="string"?n:typeof n=="number"?String(n):"",onChange:g=>a(g.target.value),"data-graview-part":"control"})]});case"number":return e.amount?(0,S.jsx)(Hi,{title:p,name:e.name,optional:e.optional,amount:e.amount,value:n,onChange:a}):(0,S.jsxs)("label",{"data-graview-part":"field","data-graview-field":e.control,children:[(0,S.jsx)("span",{"data-graview-part":"label",children:p}),(0,S.jsx)("input",{type:"number",name:e.name,required:!e.optional,...e.min===void 0?{}:{min:e.min},...e.max===void 0?{}:{max:e.max},...e.step===void 0?{}:{step:e.step},value:typeof n=="number"?n:"",onChange:g=>a(g.target.value===""?void 0:Number(g.target.value)),"data-graview-part":"control"})]});case"boolean":return(0,S.jsxs)("label",{"data-graview-part":"field","data-graview-field":"boolean",children:[(0,S.jsx)("input",{type:"checkbox",name:e.name,checked:n===!0,onChange:g=>a(g.target.checked),"data-graview-part":"control"}),(0,S.jsx)("span",{"data-graview-part":"label",children:p})]});case"choice":return(0,S.jsxs)("label",{"data-graview-part":"field","data-graview-field":e.control,children:[(0,S.jsx)("span",{"data-graview-part":"label",children:p}),(0,S.jsx)(ti,{children:(0,S.jsxs)("select",{name:e.name,required:!e.optional,value:typeof n=="string"?n:"",onChange:g=>a(g.target.value||void 0),"data-graview-part":"control",children:[(0,S.jsx)("option",{value:"",children:"\u2014"}),(e.options??[]).map(g=>(0,S.jsx)("option",{value:g,children:o(e.name).option(g)},g))]})})]});case"node":{let g=r.find(w=>w.name===e.name)?.candidates,m=new Set(Object.values(i).filter(w=>typeof w=="string")),u=(e.kinds.includes("*")?[...t.graph.allNodes()]:e.kinds.flatMap(w=>t.graph.nodesOfKind(w))).filter(w=>!m.has(w.id)),k=g?g.map(w=>t.graph.getNode(w)).filter(w=>w!==void 0):u,V=Lt(k,w=>t.schema.tryDefinition(w));return(0,S.jsxs)("label",{"data-graview-part":"field","data-graview-field":e.control,children:[(0,S.jsx)("span",{"data-graview-part":"label",children:p}),(0,S.jsx)(ti,{children:(0,S.jsxs)("select",{name:e.name,required:!e.optional,value:typeof n=="string"?n:"",onChange:w=>a(w.target.value||void 0),"data-graview-part":"control",children:[(0,S.jsx)("option",{value:"",children:"\u2014"}),k.map(w=>{let C=V.get(w.id);return(0,S.jsxs)("option",{value:w.id,children:[fe(t.schema.tryDefinition(w.kind),w),C?` \xB7 ${C}`:""]},w.id)})]})})]})}case"group":{let g=n??{};return(0,S.jsxs)("fieldset",{"data-graview-part":"group","data-graview-field":e.control,children:[(0,S.jsx)("legend",{"data-graview-part":"label",children:p}),e.fields.map(m=>(0,S.jsx)(Kt,{store:t,spec:m,value:g[m.name],onChange:u=>a({...g,[m.name]:u}),prefilled:i,open:r,words:o},m.name))]})}case"variant":{let g=n??{},m=typeof g[e.tag]=="string"?g[e.tag]:"",u=e.options.find(k=>k.value===m);return(0,S.jsxs)("fieldset",{"data-graview-part":"group","data-graview-field":e.control,children:[(0,S.jsx)("legend",{"data-graview-part":"label",children:p}),(0,S.jsxs)("label",{"data-graview-part":"field","data-graview-field":"choice",children:[(0,S.jsx)("span",{"data-graview-part":"label",children:ve(e.tag)}),(0,S.jsxs)("select",{value:m,onChange:k=>a({[e.tag]:k.target.value}),"data-graview-part":"control",children:[(0,S.jsx)("option",{value:"",children:"\u2014"}),e.options.map(k=>(0,S.jsx)("option",{value:k.value,children:ve(k.value)},k.value))]})]}),u?.fields.map(k=>(0,S.jsx)(Kt,{store:t,spec:k,value:g[k.name],onChange:V=>a({...g,[k.name]:V}),prefilled:i,open:r,words:o},k.name))]})}case"file":case"list":{let g=e.control==="file"?e:e.item.control==="file"?e.item:void 0;if(g||e.control==="file")return(0,S.jsx)(Ve,{as:"control",title:c?`${d} *`:d,value:n,onChange:a,several:g!==e,image:g?.image===!0,label:d});let m=Array.isArray(n)?n:[];return(0,S.jsxs)("fieldset",{"data-graview-part":"group","data-graview-field":"list",children:[(0,S.jsx)("legend",{"data-graview-part":"label",children:p}),m.map((u,k)=>(0,S.jsxs)("div",{"data-graview-part":"item",children:[(0,S.jsx)("div",{style:{flex:1},children:(0,S.jsx)(Kt,{store:t,spec:{...e.item,optional:!1},value:u,onChange:V=>a(m.map((w,C)=>C===k?V:w)),prefilled:i,open:r,words:o})}),(0,S.jsx)("button",{type:"button","data-graview-part":"remove",onClick:()=>a(m.filter((V,w)=>w!==k)),children:"remove"})]},k)),(0,S.jsx)("button",{type:"button","data-graview-part":"add",onClick:()=>a([...m,void 0]),children:"add another"})]})}case"linked":return(0,S.jsx)("div",{"data-graview-part":"field","data-graview-field":"linked",children:(0,S.jsx)(Za,{relation:e.relation,value:n,onChange:a,label:d})});case"repeat":return(0,S.jsx)(er,{value:n,onChange:a,start:e.of?l?.[e.of]:void 0,label:`${e.of?o(e.of).label:d} repeats`,name:e.name});case"opaque":return(0,S.jsxs)("p",{"data-graview-part":"unasked",children:["\u201C",ve(e.name),"\u201D needs a structured answer this form cannot ask for yet."]})}}function Oe({store:t,mutation:e,prefilled:n={},open:a=[],onDone:i,principal:r,initial:o,label:l,only:d}){let c=()=>or(e,t.graph,n),[p,g]=(0,ze.useState)(c),[m,u]=(0,ze.useState)(()=>({...p,...o})),[k,V]=(0,ze.useState)(null),w=r??t.seenFor,C=e.subject&&n[e.subject.arg],U=w?lr(t,w,e,typeof C=="string"?C:void 0):void 0,R=Tt(e.input).filter(D=>(d===void 0||d.includes(D.name))&&!U?.has(D.name)),j=D=>qa(t.schema,e,D),Q=Ua(R.filter(D=>D.control==="date").map(D=>D.name)),de=(0,ze.useRef)(void 0),me=(D,X)=>u(ce=>{let b={...ce,[D.name]:X};if(Q&&D.name===Q.start&&D.control==="date"){let x=M=>typeof M=="string"&&M!==""?M:void 0,L=x(ce[Q.start])??de.current;if(x(X)){de.current=x(X);let M=Va(L,x(X),x(ce[Q.end]),{time:D.time===!0,instant:D.instant===!0});M!==void 0&&(b[Q.end]=M)}}return b});return(0,S.jsxs)("form",{"data-testid":`form-${e.name}`,onSubmit:D=>{D.preventDefault();try{t.apply({name:e.name,args:{...sr(ir(R,m),p),...n}},r?{author:r}:{}),V(null);let X=c();g(X),u({...X}),i?.()}catch(X){V(rt(t.schema,t.allMutations(),X))}},"data-graview-part":"form",children:[(0,S.jsx)("style",{children:Wi}),R.map(D=>(0,S.jsx)(Kt,{store:t,spec:D,value:m[D.name],values:m,onChange:X=>me(D,X),prefilled:n,open:a,words:j},D.name)),k?(0,S.jsx)("p",{"data-testid":"refused","data-graview-part":"refused",role:"alert",children:k}):null,(0,S.jsx)("button",{type:"submit","data-graview-part":"submit",children:l??e.title??e.name})]})}var T=H(Y(),1);function Re(t){let e=t.views;if(!e)return[];let n=new Set(Ke(t.store,t.principal));return e.places().filter(a=>n.has(a.kind))}function qt(t,e){if(!e.over)return[e.kind];let n=new Set(Ke(t.store,t.principal));return e.over.filter(a=>a===e.kind||n.has(a))}var _e=t=>`place:${t.kind}:${t.as}`;function xe(t,e){return Br(e.as,ya(e,t.views?.places()??[])?J(t.store.schema,e.kind):void 0)}function mt(t,e){let n=t.schema.tryDefinition(e);return t.graph.nodesOfKind(e).filter(a=>tt(n,a))}function Tn(t,e,n){let a=(r,o)=>xt(t.schema,o,r),i=(typeof e=="string"?[e]:e).map(r=>a(mt(t,r).length,r)).join(" and ");return n?`${i} across ${a(mt(t,n).length,n)}`:i}function Mn({context:t,place:e,chosen:n,filter:a}){let{store:i,views:r,invariantContext:o}=t,d=r?.resolve(e.kind,{cardinality:"many",fidelity:"full"},e.as)?.view,c=[...new Set(i.violations(o).flatMap(m=>m.nodeIds))],p=qt(t,e).flatMap(m=>mt(i,m));if(!d)return null;let g=Bi(i,p,a,c);return(0,T.jsx)(fn,{kind:e.kind,view:e.title,children:(0,T.jsx)(d,{nodes:g,label:e.title,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1,...n&&n.length>0?{implicated:n}:{},...c.length>0?{flagged:c}:{}})})}function Bi(t,e,n,a){let i=n?At({filter:n}).filter??[]:[];return i.length===0?e:Nt(e,{filter:i},{schema:t.schema,graph:t.graph,flagged:new Set(a)}).nodes}function Gi({store:t,views:e,as:n,invariantContext:a}){ae(t);let i={store:t,views:e,...a?{invariantContext:a}:{}},r=e.places().find(o=>o.as===n);return r?(0,T.jsx)(Mn,{context:i,place:r}):null}function Vi({context:t,kind:e}){let{store:n,views:a,invariantContext:i}=t,r=mt(n,e),o=n.schema.tryDefinition(e),l=ee(n,e),c=a?.resolve(e,{cardinality:"many",fidelity:"full"})?.view,p=[...new Set(n.violations(i).flatMap(k=>k.nodeIds))];if(c&&!at(c))return(0,T.jsx)(fn,{kind:e,children:(0,T.jsx)(c,{nodes:r,label:l,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1,...p.length>0?{flagged:p}:{}})});let g=a?.resolve(e,{cardinality:"one",fidelity:"summary"})?.view,m=8,u=r.slice(0,m);return(0,T.jsxs)("div",{"data-testid":"kind-sheet",style:g?{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gridAutoRows:"max-content",alignContent:"center",gap:12,padding:24}:{display:"flex",flexWrap:"wrap",alignContent:"center",justifyContent:"center",gap:10,padding:24},children:[u.map(k=>g?(0,T.jsx)(g,{node:k,fidelity:"summary",cardinality:"one",mode:"fullscreen",selected:!1,...p.includes(k.id)?{flagged:[k.id]}:{}},k.id):(0,T.jsx)("span",{style:{padding:"8px 14px",borderRadius:8,border:"1px solid var(--graview-edge-bright)",background:"var(--graview-ground)",color:"var(--graview-ink)"},children:fe(o,k)},k.id)),r.length>m?(0,T.jsxs)("span",{style:{...A,alignSelf:"center",padding:"0 6px"},children:["+",r.length-m," more ",l.toLowerCase()]}):null]})}function Nn(t){let{store:e}=t,n=Ur(t),a=Re(t),i=pn([...a].sort((o,l)=>n.indexOf(o.kind)-n.indexOf(l.kind))).filter(o=>!o.hidden),r=new Set(i.flatMap(o=>o.over??[o.kind]));return[...i.map(o=>({key:_e(o),kind:o.kind,title:ha(o,a,e.schema),to:xe(t,o),place:o})),...Wt(t).filter(o=>!r.has(o)).map(o=>({key:`kind:${o}`,kind:o,title:ee(e,o),to:`/${J(e.schema,o)}`}))]}var ni=.72,Ui=540,ai=16/10;function ji(t){let e=(0,De.useRef)(null),[n,a]=(0,De.useState)(t);return(0,De.useLayoutEffect)(()=>{let i=e.current;if(!i||typeof ResizeObserver>"u")return;let r=()=>{let l=i.getBoundingClientRect().width;l>0&&a(d=>Math.abs(d-l)<.5?d:l)};r();let o=new ResizeObserver(r);return o.observe(i),()=>o.disconnect()},[]),{ref:e,width:n}}function zi(t){for(let e=t.parentElement;e;e=e.parentElement)if(/(auto|scroll)/.test(getComputedStyle(e).overflowY))return e;return null}function _i(t){let[e,n]=(0,De.useState)(()=>typeof IntersectionObserver>"u");return(0,De.useLayoutEffect)(()=>{let a=t.current;if(e||!a)return;let i=new IntersectionObserver(r=>{r.some(o=>o.isIntersecting)&&(i.disconnect(),n(!0))},{root:zi(a),rootMargin:"50% 0px"});return i.observe(a),()=>i.disconnect()},[e,t]),e}function En({context:t,entry:e}){let{store:n,brand:a,principal:i}=t,{ref:r,width:o}=ji(Ui),l=_i(r),d=o/ni,c=mt(n,e.kind),p=n.schema.tryDefinition(e.kind),g=c.length===0?Ue(n,e.kind,{...i?{principal:i}:{},...t.invariantContext?{context:t.invariantContext}:{}}).actions.affordances[0]:void 0,m=e.place!==void 0;return(0,T.jsxs)(F,{to:e.to,"data-testid":m?"place-card":"kind-card",className:"graview-gallery-card",style:{...ke,display:"grid",gap:10,alignContent:"start",minWidth:0},children:[(0,T.jsxs)("span",{ref:r,"data-testid":m?"place-picture":"kind-picture","aria-hidden":"true",inert:!0,style:{display:"block",position:"relative",width:"100%",aspectRatio:`${ai}`,overflow:"hidden",borderRadius:12,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",pointerEvents:"none"},children:[(0,T.jsx)("span",{style:{position:"absolute",left:0,top:0,width:d,height:d/ai,display:"grid",gridTemplateRows:"minmax(0, 1fr)",transform:`scale(${ni})`,transformOrigin:"0 0"},children:l?(0,T.jsx)($t.Provider,{value:null,children:e.place?(0,T.jsx)(Mn,{context:t,place:e.place}):(0,T.jsx)(Vi,{context:t,kind:e.kind})}):null}),c.length===0?(0,T.jsx)("span",{"data-testid":"picture-empty",style:{position:"absolute",inset:0,display:"grid",placeContent:"center",justifyItems:"center",gap:2,padding:20,textAlign:"center"},children:(0,T.jsxs)("span",{style:{display:"grid",gap:2,padding:"10px 16px",borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-ground)",color:"var(--graview-ink)"},children:[(0,T.jsxs)("span",{style:{fontFamily:xn,fontWeight:"var(--graview-weight-display)"},children:["No ",ee(n,e.kind).toLowerCase()," yet"]}),g?(0,T.jsxs)("span",{style:A,children:["Begin with \u201C",g.label,"\u201D"]}):null]})}):null]}),(0,T.jsxs)("span",{style:{display:"grid",gap:2,minWidth:0},children:[(0,T.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[m?null:(0,T.jsx)(ye,{kind:e.kind,brand:a,schema:n.schema,size:8}),(0,T.jsx)("span",{style:{fontFamily:xn,fontSize:"var(--graview-text-heading)",fontWeight:"var(--graview-weight-display)",lineHeight:1.3,overflowWrap:"anywhere",textWrap:"balance"},children:e.title})]}),(0,T.jsxs)("span",{style:A,children:[e.place?Tn(n,qt(t,e.place),e.place.across):Tn(n,e.kind),!m&&p?.description?` \xB7 ${p.description}`:null]})]})]})}var ri={display:"grid",gap:"32px 28px",gridTemplateColumns:"repeat(auto-fill, minmax(min(420px, 100%), 1fr))"},Yi=`
105
+ .graview-gallery-card > span:first-child { transition: border-color 160ms ease, box-shadow 160ms ease; }
106
+ .graview-gallery-card:hover > span:first-child,
107
+ .graview-gallery-card:focus-visible > span:first-child { border-color: var(--graview-edge-bright); box-shadow: 0 1px 0 var(--graview-edge), 0 10px 30px -18px var(--graview-ink); }
108
+ `;function $n({context:t}){ae(t.store);let e=Nn(t);return e.length===0?null:(0,T.jsxs)("section",{style:ri,"data-testid":"gallery",children:[(0,T.jsx)("style",{children:Yi}),e.map(n=>(0,T.jsx)(En,{context:t,entry:n},n.key))]})}function On({context:t}){let{store:e}=t;ae(e);let n=pn(Re(t)).filter(i=>!i.hidden),a=Nn(t);return(0,T.jsxs)(ie,{context:t,style:it,children:[(0,T.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,T.jsx)("p",{style:we,children:n.length===0?"None of its own yet":`${n.length} ${n.length===1?"picture":"pictures"}`}),(0,T.jsx)(le,{context:t,children:"Pictures"}),(0,T.jsx)("p",{style:se,children:n.length===0?"Nothing here has a picture of its own yet, so each kind is drawn as the scene draws it. Title a group view and it appears here by name.":"The ways this installation looks at what it holds \u2014 each one the same picture the scene shows, here as a page."})]}),a.length>0?(0,T.jsx)("div",{style:ri,"data-testid":"places",children:a.map(i=>(0,T.jsx)(En,{context:t,entry:i},i.key))}):null]})}function In({context:t}){let{store:e,principal:n}=t;ae(e);let a=qe(),i=Fe(),[r]=ot(),o=decodeURIComponent(a.as??""),[l,d]=(0,De.useState)(null),c=r.get("of"),p=r.get("filter"),m=Re(t).find(R=>R.as===o&&(!c||J(e.schema,R.kind)===c));if(!m)return(0,T.jsxs)(ie,{context:t,children:[(0,T.jsx)(le,{context:t,children:"No picture is called that."}),(0,T.jsx)("p",{style:se,children:(0,T.jsxs)(F,{to:"/places",style:q,children:["The pictures there are ",(0,T.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]})})]});let u=ee(e,m.kind),k=t.views?.resolve(m.kind,{cardinality:"many",fidelity:"full"},m.as)?.view,V=k?.flows===!0,w=k?.creates!==!1,C=Ue(e,m.kind,{...n?{principal:n}:{},...t.invariantContext?{context:t.invariantContext}:{}}),U=w?C.actions.affordances.map(R=>({affordance:R,mutation:e.allMutations().find(j=>j.name===R.mutation)})).filter(R=>R.mutation!==void 0):[];return(0,T.jsxs)(ie,{context:t,style:it,children:[(0,T.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,T.jsx)(le,{context:t,children:m.title}),(0,T.jsxs)("p",{style:se,"data-testid":"place-lede",children:[Tn(e,qt(t,m),m.across),"."]}),p&&!V?(0,T.jsxs)("p",{style:{...A,margin:0},"data-testid":"place-narrowed",children:[`Only those where ${p.split(",").map(R=>R.replace(":"," is ")).join(" and ")}. `,(0,T.jsx)(F,{to:`?${(()=>{let R=new URLSearchParams(r);return R.delete("filter"),R.toString()})()}`,style:{...q,...A},children:"Show all"})]}):null,(0,T.jsx)("p",{style:{...A,margin:0,display:"flex",flexWrap:"wrap",gap:"4px 16px"},children:qt(t,m).map((R,j)=>(0,T.jsxs)(F,{to:`/${J(e.schema,R)}`,style:{...q,...A},...j===0?{"data-testid":"place-as-list"}:{},children:["All ",(R===m.kind?u:ee(e,R)).toLowerCase()," as a list ",(0,T.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]},R))})]}),(0,T.jsx)("div",{"data-testid":"place-lens","data-flows":V?"":void 0,style:V?{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",maxWidth:"100%"}:{height:"min(72vh, 760px)",display:"grid",gridTemplateRows:"minmax(0, 1fr)",overflow:"auto",maxWidth:"100%",borderRadius:12,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)"},onClick:R=>{let j=R.target?.closest("[data-graview-pick]"),Q=j?.getAttribute("data-graview-pick"),de=j?.getAttribute("data-graview-joins");if(de)try{let D=JSON.parse(de);if(Array.isArray(D)&&D.every(X=>typeof X=="string")){R.preventDefault(),d({at:_e(m),ids:D});return}}catch{}if(!Q)return;let me=e.graph.getNode(Q);me&&(R.preventDefault(),i(te(e.schema,me.kind,Q)))},children:(0,T.jsx)(Mn,{context:t,place:m,filter:p,...l?.at===_e(m)?{chosen:l.ids}:{}})}),U.length>0?(0,T.jsx)("div",{style:{maxWidth:760,display:"grid",gap:40},"data-testid":"place-creators",children:U.map(({affordance:R,mutation:j})=>(0,T.jsxs)("section",{style:{...re,display:"grid",gap:14},children:[(0,T.jsx)("h2",{style:ne,children:j.title??j.name}),j.description?(0,T.jsx)("p",{style:{...A,margin:0,maxWidth:"58ch"},children:j.description}):null,(0,T.jsx)(Oe,{store:e,mutation:j,prefilled:R.args,open:R.open,label:R.label,...n?{principal:n}:{}})]},R.id))}):null]})}function st(t){return t.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-|-$/g,"")}function ft(t,e={}){let[n="/",a=""]=t.split("#")[0].split("?"),i=new URLSearchParams(a);e.filter&&i.set("filter",e.filter);let r=i.toString(),o=e.section?st(e.section):"";return`${n}${r?`?${r}`:""}${o?`#${o}`:""}`}function Qi(t,e=document){let n=st(t);if(!n)return null;let a=[e,...[...e.querySelectorAll("[data-worker-view]")].flatMap(i=>i.shadowRoot?[i.shadowRoot]:[])];for(let i of a)for(let r of i.querySelectorAll("[id], [data-section]")){let o=r.getAttribute("data-section")??r.id;if(o===t||st(o)===n)return r}for(let i of a)for(let r of i.querySelectorAll("h1, h2, h3, h4, h5, h6, [role=heading]"))if(st(r.textContent??"")===n)return r;return null}function ii(t,e={}){if(typeof document>"u"||typeof requestAnimationFrame>"u")return()=>{};let n=e.frames??120,a=0,i=()=>{let r=Qi(t,e.root??document);if(r){r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),r.scrollIntoView?.({block:"start"}),r.focus({preventScroll:!0});return}n-=1,n>0&&(a=requestAnimationFrame(i))};return a=requestAnimationFrame(()=>{a=requestAnimationFrame(i)}),()=>cancelAnimationFrame(a)}var z=H($e(),1);var Bt=H($e(),1);var Ye=H(Y(),1);function oi({context:t}){return ue()?(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsx)(Xi,{context:t}),(0,Ye.jsx)(Ir,{face:"pages",on:t.quickAsk??!0})]}):null}function Xi({context:t}){let{store:e}=t,n=ue(),{pathname:a}=Se(),i=(0,Bt.useRef)(n?.setSelection);return i.current=n?.setSelection,(0,Bt.useEffect)(()=>{let r=i.current;if(!r)return;let[,o,l]=a.split("/"),d=(()=>{if(o==="places"){let p=t.views?.places().find(g=>g.as===decodeURIComponent(l??""));return p?[Ee(p.kind)]:[]}let c=o?Te(e.schema,o):void 0;return c&&l?[decodeURIComponent(l)]:c?[ba(c)]:[]})();r(c=>c.length===d.length&&c.every((p,g)=>p===d[g])?c:d)},[a]),null}var he=H($e(),1);var li=H(Di(),1);var ge=H(Y(),1);var Ji=(0,he.lazy)(ka(()=>(__graviewPreload(import.meta.url,["./chunk.HUKAVTMX.js","./chunk.UGFDSE37.js","./chunk.FRS3S7DN.js","./chunk.MWJUZG3C.js","./chunk.T2L4NPSB.js","./chunk.VKH3ZPPQ.js","./chunk.3H4NVUWV.js","./chunk.SIH6RCAI.js","./chunk.RYEAMM73.js","./chunk.7HPPJVIV.js","./chunk.ETWVQ3A2.js","./chunk.CZRX2FDI.js","./chunk.5EAQDBBE.js","./chunk.YT2CYCVT.js","./chunk.XK4FVT2X.js","./chunk.WAB6ZS2V.js","./chunk.XXMYKBLT.js","./chunk.34CYK2DF.js","./chunk.JZBBGY4B.js","./chunk.MB7LKKUD.js","./chunk.WVUJXDXZ.js","./chunk.52QAIGCD.js","./chunk.PPUAPAWR.js","./chunk.IHFNLKXV.js","./chunk.577PGFUT.js","./chunk.FBY5IUGU.js","./chunk.4K5QCJFH.js","./chunk.GZHZLJBF.js","./chunk.WLBXBNNH.js","./chunk.7MTX33WD.js","./chunk.OJGHDWI6.js","./chunk.Z7ZCR4LN.js","./chunk.RIW7SQH4.js","./chunk.FSAHO3LV.js","./chunk.PNVR3CXR.js","./chunk.ZTD2CNC3.js","./chunk.X7W27IRI.js","./chunk.AJZBJBMO.js"]),import("./chunk.B2WRXGFI.js")).then(t=>({default:t.TakeBack}))));function Zi({context:t,docked:e,at:n}){let{store:a}=t,i=ae(a),[r]=(0,he.useState)(()=>a.batches().length),o=(0,he.useRef)(!1);return o.current||=i>0||!e&&r>0,o.current?(0,ge.jsx)(he.Suspense,{fallback:null,children:(0,ge.jsx)(Ji,{context:t,docked:e,at:n,since:r})}):null}function eo(t,e,n){let{store:a,principal:i,embedded:r}=t;(0,he.useEffect)(()=>{if(!n)return;let o=l=>{if(!qr(l))return;let d=l.target,c=d instanceof Node&&e.current?.contains(d),p=d===document.body||d===document.documentElement||d===document;if(!(!c&&!(p&&!r))&&Hr(a,i)){l.preventDefault();try{Kr(a,i)}catch{}}};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[a,i,r,e,n])}function di({context:t,registry:e,root:n,children:a}){let i=(0,he.useMemo)(Xr,[]),r=e?.without()??new Set;return eo(t,n,!r.has("undo")),(0,ge.jsxs)(Cn.Provider,{value:i,children:[(0,ge.jsx)(to,{context:t,placed:i,without:r}),a]})}function to({context:t,placed:e,without:n}){let[a,i]=(0,he.useState)(!1);(0,he.useLayoutEffect)(()=>i(!0),[]);let r=Rn(e,"find"),o=Rn(e,"undo"),l=Se(),d=gr();if(!a)return null;let c=l.pathname.split("/").filter(Boolean),g=(c.length===1?Te(t.store.schema,c[0]):void 0)!==void 0;return(0,ge.jsxs)(ge.Fragment,{children:[!r&&!n.has("find")&&d?(0,li.createPortal)((0,ge.jsx)(si,{context:t,narrowsLists:g}),d.slot):null,!r&&!n.has("find")&&!d?(0,ge.jsx)("div",{"data-testid":"face-find-bar",style:{display:"flex",alignItems:"center",padding:"8px 16px",borderBottom:"1px solid var(--graview-edge)",background:"var(--graview-bar)",minWidth:0},children:(0,ge.jsx)(si,{context:t,narrowsLists:g})}):null,!o&&!n.has("undo")?(0,ge.jsx)(Zi,{context:t,docked:!0,at:l.pathname+l.search}):null,d?.own&&!n.has("undo")?(0,ge.jsx)(jr,{context:t,own:d.own}):null]})}function si({context:t,narrowsLists:e}){return(0,ge.jsx)(Cn.Provider,{value:null,children:(0,ge.jsx)(Ln,{context:t,narrowsLists:e})})}var oe=H($e(),1);var Pe=H(Y(),1),no=500,ao=10;function Gt(t){return t instanceof HTMLElement?t.isContentEditable||t.tagName==="TEXTAREA"||t.tagName==="SELECT"?!0:t.tagName==="INPUT"&&!["button","submit","reset","checkbox","radio","image","file","color","range"].includes(t.type):!1}function ro(t){let e=typeof getSelection=="function"?getSelection():null;return e!==null&&!e.isCollapsed&&e.containsNode(t,!0)}function ci(t){let e=t.closest('a[href], button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"])');if(e)return e;let n=document.activeElement;return n instanceof HTMLElement&&n!==document.body?n:null}function pi({context:t,root:e,children:n}){return ue()===null?(0,Pe.jsx)(Pe.Fragment,{children:n}):(0,Pe.jsx)(io,{context:t,root:e,children:n})}function io({context:t,root:e,children:n}){let{setMenuAt:a}=Ra(),{store:i}=t,r=i.schema,o=Fe(),{pathname:l,search:d}=Se(),c=zr("/").replace(/\/$/,""),p=(0,oe.useCallback)((b,x)=>t.views?.places().find(L=>L.as===b&&(x===null||L.kind===x)),[t.views]),g=(0,oe.useCallback)((b,x)=>{let[L="",M,E]=b.split("/").filter(Boolean).map(Z=>{try{return decodeURIComponent(Z)}catch{return Z}});if(E!==void 0)return null;if(L==="places"&&M!==void 0){let Z=p(M,new URLSearchParams(x).get("of"));return Z?{face:"pages",place:Z.as,about:[Ee(Z.kind)],title:Z.title}:null}let _=Te(r,L);return _?M===void 0?{face:"pages",about:[Ee(_)],title:nt(r,_)}:i.graph.getNode(M)?{face:"pages",on:M,about:[M]}:null:null},[r,i,p]),m=(0,oe.useCallback)(b=>{let x=b.href;try{let L=new URL(x,location.href);if(L.origin===location.origin&&(c===""||L.pathname===c||L.pathname.startsWith(`${c}/`))){let M=g(L.pathname.slice(c.length),L.search);if(M)return{...M,href:x}}}catch{}return{face:"pages",about:[],href:x}},[c,g]),u=(0,oe.useCallback)(()=>g(l,d)??{face:"pages",about:[]},[g,l,d]),k=(0,oe.useCallback)(b=>{let x=u(),L=b.closest("[data-graview-field]")?.getAttribute("data-graview-field");if(L&&x.on!==void 0&&b.closest("[data-graview-pick], a[href]")===null)return{...x,field:L};let M=b.closest("[data-graview-act]")?.getAttribute("data-graview-act");if(M)return{...x,act:M};let E=b.closest("[data-graview-pick]")?.getAttribute("data-graview-pick");if(E&&i.graph.getNode(E))return{face:"pages",on:E,about:[E],href:`${c}${te(r,i.graph.getNode(E).kind,E)}`};let _=b.closest("a[href]");if(_)return m(_);let Z=b.closest("[data-graview-record]")?.getAttribute("data-graview-record");return Z&&i.graph.getNode(Z)?{face:"pages",on:Z,about:[Z]}:x},[u,m,i,r,c]),V=(0,oe.useCallback)(b=>{let x=e.current;if(x===null||!x.contains(b)||Gt(b)||b.closest("[data-graview-popover]"))return null;let L=k(b);return{face:"pages",on:L.on,about:L.about??[],field:L.field,place:L.place,href:L.href,act:L.act,element:ci(b)}},[k,e]),w=(0,oe.useCallback)((b,x,L)=>{let M=k(b);a({...M,x:Math.round(x),y:Math.round(L),returnTo:ci(b)})},[k,a]),C=(0,oe.useCallback)(b=>{let x=b.getBoundingClientRect();w(b,x.left+Math.min(16,x.width/2),Math.min(x.bottom,x.top+36))},[w]),U=(0,oe.useRef)(0),R=(0,oe.useRef)(null),j=(0,oe.useRef)(!1),Q=()=>{R.current&&clearTimeout(R.current.timer),R.current=null};(0,oe.useEffect)(()=>Q,[]),(0,oe.useEffect)(()=>{let b=x=>{if(x.defaultPrevented||!(x.key==="ContextMenu"||x.key==="F10"&&x.shiftKey))return;let L=e.current,M=x.target instanceof Element?x.target:null,E=M===null||M===document.body||M===document.documentElement,_=L!==null&&M!==null&&L.contains(M);if(!_&&!(E&&document.querySelector("[data-graview-face='pages']")===L)||Gt(M)||M?.closest("[data-graview-popover]"))return;x.preventDefault(),U.current=Date.now();let Z=_&&M instanceof HTMLElement?M:L?.querySelector("[data-graview-page-title], main h1, main")??null;Z&&C(Z)};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[e,C]);let de=(0,oe.useMemo)(()=>b=>{if(b.face!=="pages")return null;let x=[],L=b.on===void 0?void 0:i.graph.getNode(b.on),M=b.place===void 0?void 0:t.views?.places().find(G=>G.as===b.place),E=L?void 0:b.about.length===1&&b.about[0].startsWith("aggregate:")&&!M?oo(b.about[0]):void 0,_=L?te(r,L.kind,L.id):M?xe(t,M):E?`/${J(r,E)}`:void 0,Z=_!==void 0&&l===_.split("?")[0];_!==void 0&&!Z&&x.push({id:"open",label:"Open",run:()=>o(_)});let f=_!==void 0?`${c}${_}`:b.href;f!==void 0&&x.push({id:"open-in-a-new-tab",label:"Open in a new tab",run:()=>void window.open(f,"_blank","noopener")});let N=L?`#focus=${encodeURIComponent(L.id)}`:M?`#focus=${encodeURIComponent(Ee(M.kind))}&view=${encodeURIComponent(M.as)}`:E?`#focus=${encodeURIComponent(Ee(E))}`:void 0;if(N!==void 0&&(t.overview||!t.embedded)){let G=t.overview;x.push({id:"in-the-scene",label:"Show in the scene",run:()=>G?G(N):location.assign(`${t.sceneHref??"/"}${N}`)})}return L===void 0&&b.href===void 0&&x.push({id:"find",label:"Find\u2026",run:()=>{let G=e.current?.querySelector('[data-testid="nav-find"]')??document.querySelector('[data-testid="nav-find"]');G&&G.offsetParent!==null?G.focus():o("/search")}}),x.length>0?{id:"pages",items:x}:null},[i,r,t,l,c,o,e]),me=(0,oe.useMemo)(()=>b=>{if(b.face!=="pages"||b.field===void 0||b.on===void 0)return null;let x=i.graph.getNode(b.on),L=b.element?.closest("[data-graview-field]")??e.current?.querySelector(`[data-graview-field="${CSS.escape(b.field)}"]`);return!x||!(L instanceof HTMLElement)||!L.hasAttribute("data-graview-editable")?null:{id:"field",at:"start",items:[{id:"change-field",label:`Change \u201C${ia(r.tryDefinition(x.kind),b.field)}\u201D`,run:()=>L.click()}]}},[i,r,e]),D=Dr(),X=ar(),ce=(0,oe.useMemo)(()=>[me,de,...X?[X]:[],...D?[D]:[]],[me,de,X,D]);return(0,Pe.jsxs)(Xa,{sections:ce,children:[(0,Pe.jsx)("div",{"data-graview-menu-ground":"",style:{display:"contents"},onContextMenu:b=>{let x=b.target;b.shiftKey||Gt(x)||ro(x)||(b.preventDefault(),!x.closest("[data-graview-popover]")&&(Date.now()-U.current<700||(b.clientX===0&&b.clientY===0&&x instanceof HTMLElement?C(x):w(x,b.clientX,b.clientY))))},onPointerDown:b=>{if(j.current=!1,b.pointerType==="mouse"||!b.isPrimary)return;let x=b.target;if(Gt(x)||x.closest("[data-graview-choose], [data-graview-popover]"))return;Q();let{clientX:L,clientY:M}=b;R.current={x:L,y:M,timer:setTimeout(()=>{R.current=null,j.current=!0,U.current=Date.now(),w(x,L,M)},no)}},onPointerMove:b=>{let x=R.current;x&&Math.hypot(b.clientX-x.x,b.clientY-x.y)>ao&&Q()},onPointerUp:Q,onPointerCancel:Q,onClickCapture:b=>{j.current&&(j.current=!1,b.preventDefault(),b.stopPropagation())},children:n}),(0,Pe.jsx)(so,{openAt:C,readyAt:V}),(0,Pe.jsx)(Wr,{placement:"page"}),(0,Pe.jsx)(rr,{})]})}function oo(t){let e=t.slice(10).split("+");return e.length===1&&e[0]?e[0]:void 0}function so({openAt:t,readyAt:e}){return(0,Pe.jsx)("span",{"data-graview-menu-home":"",tabIndex:-1,onFocus:n=>{if(n.target!==n.currentTarget)return;let a=n.currentTarget.closest("[data-graview-face]"),i=a?.querySelector("[data-graview-page-title]")??a?.querySelector("main h1, main")??null;i&&(i.hasAttribute("tabindex")||i.setAttribute("tabindex","-1"),i.focus({preventScroll:!0}))},style:{position:"absolute",width:0,height:0,overflow:"hidden"},children:(0,Pe.jsx)(Or,{placement:"menu",openActs:t,aimAt:e})})}var K=H(Y(),1);function ui(t,e){return e==="*"?{label:"anything",path:null}:{label:ee(t,e),path:`/${J(t.schema,e)}`}}function lo({context:t,relation:e}){let{store:n}=t,a=ui(n,e.from),i=ui(n,e.to),r=o=>o.path?(0,K.jsx)(F,{to:o.path,style:{...ke,fontWeight:550},children:o.label}):(0,K.jsx)("span",{children:o.label});return(0,K.jsxs)("li",{"data-testid":"relation","data-relation":e.edgeKind,style:{display:"grid",gridTemplateColumns:"30px minmax(0, 1fr) auto",gap:12,alignItems:"baseline"},children:[(0,K.jsx)(Fr,{edgeKind:e.edgeKind,...t.brand?.kit?{kit:t.brand.kit}:{}}),(0,K.jsxs)("span",{style:{display:"grid",gap:1},children:[(0,K.jsxs)("span",{children:[r(a)," ",(0,K.jsxs)("span",{style:A,"data-graview-speaks-ids":"",children:[ve(e.edgeKind)," \u2192"]})," ",r(i)]}),e.description||e.inverse?(0,K.jsxs)("span",{style:A,children:[e.description?Ae(e.description):null,e.description&&e.inverse?" \xB7 ":null,e.inverse?`from the other end, ${e.inverse}`:null]}):null]}),i.path?(0,K.jsx)(F,{to:`${i.path}?with=${encodeURIComponent(e.edgeKind)}`,style:{...q,...A,fontVariantNumeric:"tabular-nums",display:"inline-block",minWidth:24,minHeight:24,textAlign:"center"},title:`The ${i.label.toLowerCase()} that have this`,children:e.count}):(0,K.jsx)("span",{style:{...A,fontVariantNumeric:"tabular-nums"},children:e.count})]})}function gi({context:t,heading:e=!0}){let{store:n}=t,a=new Set(Ke(n,t.principal)),i=je(n).relations.filter(r=>a.has(r.from)&&(r.to==="*"||a.has(r.to)));return i.length===0?null:(0,K.jsxs)("section",{style:{...re,display:"grid",gap:12},"data-testid":"kind-map",children:[e?(0,K.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap"},children:[(0,K.jsx)("h2",{style:ne,children:(0,K.jsx)(F,{to:"/map",style:ke,children:"Connections"})}),(0,K.jsx)("span",{style:A,children:i.length===1?"1 relation":`${i.length} relations`})]}):null,(0,K.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:10},children:i.map(r=>(0,K.jsx)(lo,{context:t,relation:r},`${r.edgeKind}|${r.from}|${r.to}`))})]})}function Fn({context:t}){let{store:e}=t;ae(e);let n=new Set(Ke(e,t.principal)),a=je(e),i=a.relations.filter(r=>n.has(r.from));return(0,K.jsxs)(ie,{context:t,children:[(0,K.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,K.jsx)("p",{style:we,children:i.length===0?"No relations":`${i.length} ${i.length===1?"relation":"relations"}`}),(0,K.jsx)(le,{context:t,children:"Connections"}),(0,K.jsx)("p",{style:se,children:i.length===0?"Nothing here is declared to relate to anything else yet.":"The kinds this installation holds, and the relations declared between them \u2014 each in the declaration's own words, with how many of it there are."})]}),(0,K.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"6px 18px"},"data-testid":"map-kinds",children:a.kinds.filter(r=>n.has(r.kind)).map(r=>(0,K.jsxs)("li",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,K.jsx)(ye,{kind:r.kind,brand:t.brand,schema:e.schema,size:7}),(0,K.jsx)(F,{to:`/${J(e.schema,r.kind)}`,style:q,children:r.plural}),(0,K.jsx)("span",{style:A,children:r.count})]},r.kind))}),(0,K.jsx)(gi,{context:t,heading:!1})]})}function mi({context:t}){let n=[...ue()?.robots.values()??[]].filter(i=>i.mode==="asking"&&i.say);if(n.length===0)return null;let{store:a}=t;return(0,K.jsxs)("section",{style:{...re,display:"grid",gap:10},"data-testid":"seat-questions",children:[(0,K.jsx)("h2",{style:ne,children:n.length===1?"The seat asked something":`The seat asked ${n.length} things`}),(0,K.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:8},children:n.map(i=>{let r=i.at?a.graph.getNode(i.at):void 0;return(0,K.jsxs)("li",{style:{display:"grid",gap:2},children:[(0,K.jsx)("span",{children:i.say}),r?(0,K.jsxs)(F,{to:te(a.schema,r.kind,r.id),style:{...q,...A},children:[fe(a.schema.tryDefinition(r.kind),r)," \u2192"]}):null]},i.participant)})})]})}var B=H(Y(),1);function Dn({context:t}){let{principal:e}=t,{store:n,brand:a,invariantContext:i}=t;ae(n);let r=n.violations(i),o=`${r.length===1?"A rule is broken":"Rules are broken"} \u2014 see what, and what would fix it`,l=[...n.log.all()].slice(-5).reverse(),c=Wt(t).map(C=>({kind:C,members:n.graph.nodesOfKind(C).filter(U=>tt(n.schema.tryDefinition(C),U))})),p=c.filter(C=>C.members.length>0),g=c.map(C=>({entry:C,creator:n.allMutations().find(U=>(U.creates??[]).includes(C.kind)&&n.permits({name:U.name,args:{}},t.principal).ok)})).find(C=>C.creator!==void 0),m=p.length===0?"Nothing here yet.":`${p.map(C=>xt(n.schema,C.kind,C.members.length)).join(", ").replace(/, ([^,]*)$/," and $1")}.`,u=t.views?.homeView?.(),k=n.schema.kinds.some(C=>n.graph.nodesOfKind(C).length>0);if(u&&k){let C=a?.subtitle?(0,B.jsx)("p",{style:{...A,margin:0},"data-testid":"app-subtitle",children:a.subtitle}):null,U=u[Symbol.for("graview.home-blocks")]===!0;return(0,B.jsx)(ie,{context:t,style:it,children:(0,B.jsxs)("div",{style:{display:"grid",gap:12},"data-testid":"home-view",children:[U?null:C,r.length>0?(0,B.jsx)(F,{to:"/problems",style:{...q,color:"var(--graview-warn)"},children:o}):null,(0,B.jsx)(Nr.Provider,{value:U?C:null,children:(0,B.jsx)(u,{cardinality:"many",fidelity:"full",mode:"fullscreen",selected:!1})})]})})}let V=new Set(Ke(n,t.principal)),w=je(n).relations.filter(C=>V.has(C.from)&&(C.to==="*"||V.has(C.to)));return(0,B.jsxs)(ie,{context:t,style:it,children:[(0,B.jsxs)("header",{style:{display:"grid",gap:12},children:[a?.subtitle?(0,B.jsx)("p",{style:{...A,margin:0},"data-testid":"app-subtitle",children:a.subtitle}):null,(0,B.jsx)(le,{context:t,"data-testid":"standing",children:m}),(0,B.jsxs)("p",{style:{...se,display:"grid",gap:4},"data-testid":"standing-card",children:[p.length===0&&g?(0,B.jsxs)("span",{children:["Begin with \u201C",g.creator?.title??g.creator?.name,"\u201D, under"," ",(0,B.jsx)(F,{to:`/${J(n.schema,g.entry.kind)}`,style:q,children:ee(n,g.entry.kind)}),"."]}):null,r.length===0?(0,B.jsx)("span",{children:"All rules hold."}):(0,B.jsx)(F,{to:"/problems",style:{...q,color:"var(--graview-warn)"},children:o})]})]}),(0,B.jsx)($n,{context:t}),(0,B.jsxs)("section",{style:{...re,display:"grid",gap:14},"data-testid":"kinds",children:[(0,B.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap"},children:[(0,B.jsx)("h2",{style:ne,children:"What is here"}),w.length>0?(0,B.jsxs)(F,{to:"/map",style:{...q,...A,marginLeft:"auto"},"data-testid":"map-link",children:["Connections \xB7 ",w.length===1?"1 relation":`${w.length} relations`," ",(0,B.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]}):null]}),(0,B.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"8px 10px"},children:c.map(({kind:C,members:U})=>(0,B.jsx)("li",{style:{maxWidth:"100%"},children:(0,B.jsxs)(F,{to:`/${J(n.schema,C)}`,style:{...ke,flexWrap:"wrap",gap:8,padding:"6px 14px 6px 10px",borderRadius:8,border:"1px solid var(--graview-edge-bright)",background:"var(--graview-panel)"},children:[(0,B.jsx)(ye,{kind:C,brand:a,schema:n.schema,size:7}),(0,B.jsx)("span",{style:{fontWeight:550,overflowWrap:"anywhere"},children:ee(n,C)}),(0,B.jsx)("span",{style:{...A,fontVariantNumeric:"tabular-nums"},children:U.length===0?"none yet":pt(U.length)})]})},C))})]}),l.length>0?(0,B.jsxs)("section",{style:{...re,display:"grid",gap:10},children:[(0,B.jsx)("h2",{style:ne,children:"Recently"}),(0,B.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},children:l.map(C=>(0,B.jsxs)("li",{style:A,children:[(0,B.jsx)("span",{style:{color:"var(--graview-ink)"},children:C.intent})," \u2014 ",gt(C,e,{graph:n.graph,schema:n.schema,...t.seats?{seats:t.seats}:{},...t.people?{people:t.people}:{}})]},C.id))})]}):null]})}var Me=H($e(),1);var Qe=H(Y(),1);function Vt({context:t,withheld:e,style:n,testId:a}){let i=ue(),r=ma(e,t.signIn??i?.signIn);return r?(0,Qe.jsx)("p",{style:{...n,margin:0},children:(0,Qe.jsx)("button",{type:"button","data-testid":"sign-in",onClick:()=>r.run(),style:be,children:r.label})}):e.length===0?null:(0,Qe.jsx)("ul",{style:{...n,margin:0,padding:0,listStyle:"none",display:"grid",gap:4},...a?{"data-testid":a}:{},children:e.map(o=>(0,Qe.jsxs)("li",{style:A,children:[(0,Qe.jsx)("s",{children:o.label})," \u2014 ",o.refusal.message]},o.id))})}var $=H(Y(),1);function Wn({context:t}){let{store:e,brand:n,principal:a,invariantContext:i}=t;ae(e);let[r]=ot(),o=r.get("q")??"",l=typeof i?.today=="string"?i.today:void 0,d=kr(e,o,{...a?{principal:a}:{},places:Re(t),flagged:new Set(e.violations(i).flatMap(u=>u.nodeIds)),...l?{today:l}:{},limit:200}),c=d.hits.filter(u=>u.about==="node"),p=d.hits.filter(u=>u.about==="kind"||u.about==="place"||u.about==="rule"),g=[...new Set(c.map(u=>u.kind))],m=o.trim();return(0,$.jsxs)(ie,{context:t,children:[(0,$.jsx)("style",{children:Ft}),(0,$.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,$.jsx)("p",{style:we,children:"Search"}),(0,$.jsx)(le,{context:t,"data-testid":"search-heading",children:m.length===0?"Find anything by its name":d.hits.length===0?(0,$.jsxs)($.Fragment,{children:["Nothing here is called \u201C",m,"\u201D."]}):(0,$.jsxs)($.Fragment,{children:[co(e,d.byKind)," for \u201C",m,"\u201D"]})}),m.length>0?(0,$.jsxs)("p",{style:{...A,margin:0},"data-testid":"search-searched",children:[Mt(e.schema,d.searched),d.conditions.filter(u=>u.key!=="is"&&u.admittedBy.length<d.searched.kinds.length).map(u=>(0,$.jsxs)("span",{children:[" ",u.key,":",u.value," narrows"," ",u.admittedBy.length===0?"nothing here":u.admittedBy.map(k=>ee(e,k).toLowerCase()).join(" and "),"."]},`${u.key}:${u.value}`))]}):(0,$.jsxs)("p",{style:se,children:["Type in the box above. Words find the start of words in names and in what each record says;"," ",(0,$.jsx)("code",{children:"done:false"})," and the like narrow as a list does, and ",(0,$.jsx)("code",{children:"is:any"})," includes what is past."]})]}),p.length>0?(0,$.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},"data-testid":"search-named",children:p.map(u=>(0,$.jsx)("li",{"data-testid":"search-hit","data-about":u.about,children:u.about==="kind"?(0,$.jsxs)(F,{to:`/${J(e.schema,u.kind)}`,style:q,children:[u.label,u.count>0?(0,$.jsxs)("span",{style:A,children:[" \xB7 ",u.count," match"]}):null]}):u.about==="place"?(0,$.jsxs)(F,{to:xe(t,u),style:q,children:["Go to ",u.title]}):u.about==="rule"?(0,$.jsxs)(F,{to:"/problems",style:q,children:["The rule \u201C",u.label,"\u201D"]}):null},`${u.about}:${u.about==="rule"?u.name:u.about==="place"?u.as:u.kind}`))}):null,g.map(u=>(0,$.jsxs)("section",{className:"graview-list",style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",minWidth:0},"data-testid":"search-group","data-kind":u,children:[(0,$.jsxs)("h2",{className:"graview-group-head",style:{alignItems:"center"},children:[(0,$.jsx)(ye,{kind:u,brand:n,schema:e.schema,size:8}),(0,$.jsx)(F,{to:`/${J(e.schema,u)}?${new URLSearchParams({q:m}).toString()}`,style:q,"data-testid":"search-kind-link",children:ee(e,u)}),(0,$.jsx)("span",{children:d.byKind[u]})]}),(0,$.jsx)("ul",{className:"graview-rows",children:c.filter(k=>k.kind===u).map(k=>(0,$.jsxs)("li",{"data-testid":"search-hit","data-about":"node",className:"graview-row",children:[(0,$.jsxs)(F,{to:te(e.schema,u,k.id),className:"graview-row-title",...k.label.length>60?{title:k.label}:{},children:[k.flagged?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)("span",{role:"img","aria-label":"Breaks a rule:",style:{color:"var(--graview-warn)"},children:"\u26A0"})," "]}):null,k.label]}),k.apart||!k.current?(0,$.jsx)("span",{className:"graview-row-glance",children:[k.apart,k.current?"":"past"].filter(Boolean).join(" \xB7 ")}):null,(0,$.jsx)(Ut,{why:k.why})]},k.id))})]},u)),m.length>0?(0,$.jsx)(po,{asked:m}):null,m.length>0&&d.hits.length===0?(0,$.jsx)(yi,{store:e,kinds:d.searched.kinds,words:d.words,...a?{principal:a}:{},...i?{invariantContext:i}:{}}):null]})}function Ut({why:t}){return t.strength==="near"?(0,$.jsxs)("span",{style:A,"data-testid":"search-why","data-near":"",children:["Near \u201C",t.asked,"\u201D",t.field==="label"?"":` \u2014 ${t.reading}: ${t.fragment}`]}):t.field==="label"?null:(0,$.jsxs)("span",{style:A,"data-testid":"search-why",children:[t.reading,": ",t.fragment]})}function co(t,e){let n=Object.entries(e).map(([a,i])=>`${i} ${i===1?He(t.schema.tryDefinition(a),a):ee(t,a).toLowerCase()}`);return n.length===0?"Found":n.length===1?Ae(n[0]):Ae(`${n.slice(0,-1).join(", ")} and ${n[n.length-1]}`)}function fi(t,e,n={}){let a=[];for(let i of e){let r=Ue(t,i,{...n.principal?{principal:n.principal}:{},...n.invariantContext?{context:n.invariantContext}:{}});for(let o of jt(t,i,r.actions.affordances))a.some(l=>l.mutation.name===o.mutation.name)||a.push(o)}return a}function jt(t,e,n){let a=t.schema.tryDefinition(e)?.fieldRoles?.label,i=[];for(let r of n){let o=t.allMutations().find(c=>c.name===r.mutation);if(!o||!o.creates?.includes(e)||i.some(c=>c.mutation.name===o.name))continue;let l=Tt(o.input).map(c=>c.name),d=l.includes("label")?"label":a&&l.includes(a)?a:void 0;!d||r.args[d]!==void 0||i.push({kind:e,affordance:r,mutation:o,arg:d})}return i}function yi({store:t,kinds:e,words:n,principal:a,invariantContext:i}){let r=fi(t,e,{...a?{principal:a}:{},...i?{invariantContext:i}:{}});return r.length===0||n.trim().length===0?null:(0,$.jsx)("div",{style:{display:"grid",gap:24},"data-testid":"search-to-create",children:r.map(({kind:o,affordance:l,mutation:d,arg:c})=>(0,$.jsxs)("section",{style:{...re,display:"grid",gap:14},children:[(0,$.jsxs)("h2",{style:ne,children:[Ae(oa(He(t.schema.tryDefinition(o),o)))," called \u201C",n,"\u201D"]}),(0,$.jsx)(Oe,{store:t,mutation:d,prefilled:l.args,open:l.open,initial:{[c]:n},...a?{principal:a}:{}})]},`${l.id}|${n}`))})}function po({asked:t}){let e=ue();return e?(0,$.jsx)(uo,{asked:t,desk:e.aiDesk}):null}function uo({asked:t,desk:e}){return Oa(e)?(0,$.jsx)("p",{style:{margin:0},children:(0,$.jsxs)("button",{type:"button","data-testid":"search-ask",onClick:a=>$a(e,{pointed:{about:[]},asked:t,returnTo:a.currentTarget}),style:{...q,font:"inherit",padding:0,border:0,background:"transparent",cursor:"pointer",textAlign:"start"},children:["Ask: \u2018",t,"\u2019"]})}):null}var v=H(Y(),1),wi=8,vi=40;function go(t,e){let n=e?.fields?.shape??{},a=Object.keys(n).find(i=>la(n[i])&&sa(t[i]));return a===void 0?void 0:t[a]}function Hn({context:t}){let e=qe(),n=Te(t.store.schema,e.slug??"");return n?(0,v.jsx)(ki,{context:t,kind:n}):(0,v.jsx)(ie,{context:t,children:(0,v.jsx)(le,{context:t,children:"No such kind of thing here."})})}function ki({context:t,kind:e,opening:n,row:a,layout:i="list",description:r,bare:o}){let{store:l,brand:d,invariantContext:c}=t;ae(l);let[p,g]=ot(),m=`list-${(0,Me.useId)().replace(/:/g,"")}`,u=l.schema.tryDefinition(e),k=ca(p.get("archived")),V=l.graph.nodesOfKind(e,{archived:k}),w=je(l).relations.filter(s=>s.from===e||s.to===e),C=new Set(l.violations(c).flatMap(s=>s.nodeIds)),U=hr(l.schema,yr(l.schema,fr(l.schema,e))),R=w.map(s=>s.edgeKind),j=vo(p,U,R),Q=["sort","filter","group","q","by","with","past","archived",...R].some(s=>p.has(s)),de=V.length>=vi,me=u?.fieldRoles?.when,D=t.views?.arrangement?.()?.lists?.[e],X=cr(D),ce=dr(D?.group),b=wo(de,me),x=n??(X?{...b,...X}:b),L=Q?j.arrangement:vn(x,U).arrangement,M=X?.sort,E=L.sort&&M?.then&&L.sort.by===M.by&&L.sort.direction===M.direction?{...L,sort:M}:L,_=wr(E.query??""),Z=[...E.filter??[],..._.conditions].some(s=>s.key==="is"&&(s.value==="past"||s.value==="any"))||mr(u,[...E.filter??[],..._.conditions]),f=Z||!u?.lifecycle?E:{...E,filter:[...E.filter??[],{key:"is",value:"current"}]},N=new Map,G=Nt(V,f,{schema:l.schema,graph:l.graph,flagged:C,...typeof c?.today=="string"?{today:c.today}:{},read:(s,y)=>{let O=N.get(s.id);return O||N.set(s.id,O=ut(l.schema,l.graph,s)),O[y]}}),I=ce&&E.group?.by===ce.by&&!E.group.bucket?U.groups.find(s=>s.key===ce.by):void 0,Gn=ce&&I&&(I.type==="choice"||I.type==="boolean")?pr(G.groups,ce,{type:I.type,...I.options?{options:I.options}:{}}):G.groups.map(s=>({...s,closed:!1})),Vn=new Set((p.get("open")??"").split(",").filter(Boolean)),Ai=!!E.query||(E.filter??[]).some(s=>s.key===ce?.by),Un=s=>I?.type==="boolean"?s==="1"?"true":"false":s,jn=s=>s.closed&&!Ai&&!Vn.has(Un(s.key)),Ci=s=>{let y=new URLSearchParams(p),O=new Set(Vn);O.has(s)?O.delete(s):O.add(s),O.size>0?y.set("open",[...O].join(",")):y.delete("open"),g(y,{replace:!0})},Ie=G.nodes,lt=u?.lifecycle&&!Z?V.filter(s=>tt(u,s)):V,zn=V.length-lt.length,Yt=E.group?.by??null,Ri=s=>{let y=new URLSearchParams(p);for(let pe of["sort","filter","group","q","by","with","past","archived",...w.map(bt=>bt.edgeKind)])y.delete(pe);let O=br(s);for(let pe of["sort","filter","group","q","archived"])O[pe]&&y.set(pe,O[pe]);![...y.keys()].some(pe=>["sort","filter","group","q"].includes(pe))&&(n||X||de||me)&&y.set("sort",""),g(y)},{principal:Je}=t,Qt=Ue(l,e,{...Je?{principal:Je}:{},...t.invariantContext?{context:t.invariantContext}:{}}),We=Qt.actions.affordances.map(s=>({affordance:s,mutation:l.allMutations().find(y=>y.name===s.mutation)})).filter(s=>s.mutation!==void 0),Li=Qt.actions.withheld,Xt=()=>new Set(Ie.length===0?We.map(({mutation:s})=>s.name):[]),[Jt,_n]=(0,Me.useState)(()=>({kind:e,open:Xt()}));Jt.kind!==e&&_n({kind:e,open:Xt()});let Yn=s=>(Jt.kind===e?Jt.open:Xt()).has(s),Qn=(s,y)=>_n(O=>{let pe=new Set(O.open);return y?pe.add(s):pe.delete(s),{kind:O.kind,open:pe}}),Xn=`begin-${(0,Me.useId)().replace(/:/g,"")}`,Jn=_.words&&Ie.length===0?Object.fromEntries(jt(l,e,Qt.actions.affordances).map(s=>[s.mutation.name,s.arg])):{},Ze=ee(l,e),ht=t.views?.lookup(e,{cardinality:"one",fidelity:"glyph"}),Zt=ht!==void 0&&!at(ht)?ht:void 0,en=(E.group?.bucket??"day")==="day"?E.group?.by:void 0,tn=(E.filter??[]).map(s=>s.key),Ti=tn.filter(s=>tn.indexOf(s)===tn.lastIndexOf(s)&&/choice|boolean/.test(U.filters.find(y=>y.key===s)?.type??"")),nn=s=>{let y={...u?.computed?ut(l.schema,l.graph,s):s};en&&!String(y[en]).includes("T")&&delete y[en];for(let O of Ti)delete y[O];return y},wt=s=>{let y=fe(u,s);if(a)return(0,v.jsxs)("li",{"data-testid":"record-row","data-graview-record":s.id,style:{minWidth:0},...ln(s.id),children:[sn(s,y),a(s,{label:y,href:te(l.schema,e,s.id),flagged:C.has(s.id),glance:Dt(nn(s),u,y)})]},s.id);if(Zt){let dn=Ot(ht,s,l.graph),Ii=Object.fromEntries(Object.entries(nn(s)).filter(([Fi])=>!dn?.fields.has(Fi))),aa=dn?Dt(Ii,u,dn.title??y):"";return(0,v.jsxs)("li",{"data-testid":"record-row","data-graview-record":s.id,style:{position:"relative",display:"flex",flexWrap:"wrap",alignItems:"baseline",columnGap:16,rowGap:2,paddingBlock:10,borderTop:"1px solid var(--graview-edge)"},...ln(s.id),children:[sn(s,y),(0,v.jsx)("div",{style:{flex:"1 1 14rem",minWidth:0},children:(0,v.jsx)(Zt,{node:s,cardinality:"one",fidelity:"glyph",mode:"fullscreen",selected:!1,...C.has(s.id)?{flagged:[s.id]}:{}})}),aa?(0,v.jsx)("span",{style:{...A,flex:"0 1 auto",minWidth:0,overflowWrap:"anywhere"},"data-testid":"record-glance",children:aa}):null,(0,v.jsx)(So,{to:te(l.schema,e,s.id),label:C.has(s.id)?`${y} \u2014 implicated in a problem`:y})]},s.id)}let O=Dt(nn(s),u,y),pe=_.words?vr(u,s,_.words):void 0,bt=de?void 0:Qa(s,u),St=go(s,u),na=(0,v.jsxs)(F,{to:te(l.schema,e,s.id),className:"graview-row-title",...y.length>60?{title:y}:{},children:[C.has(s.id)?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("span",{role:"img","aria-label":"Breaks a rule:",style:{color:"var(--graview-warn)"},children:"\u26A0"})," "]}):null,y]});return(0,v.jsxs)("li",{className:"graview-row","data-graview-record":s.id,...ln(s.id),children:[sn(s,y),bt?(0,v.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:14,minWidth:0},children:[(0,v.jsx)(Ve,{as:"thumb",file:bt}),na]}):na,O||St?(0,v.jsxs)("span",{className:"graview-row-glance",children:[O,O&&St?" \xB7 ":null,St?(0,v.jsx)(Et,{address:St}):null]}):null,pe?(0,v.jsx)(Ut,{why:pe}):null]},s.id)},an=Re(t).filter(s=>s.kind===e),Zn=D?.filters,Mi=(E.filter??[]).some(s=>s.key!=="is"||s.value!=="any"),Ni=!!(E.sort||E.group||E.query||Mi),Ei=lt.length>=wi||Q&&Ni,Ne=E.sort?U.sorts.find(s=>s.key===E.sort.by):void 0,rn=Ne?.type==="date"||Ne!==void 0&&Ne.key===me,ea=de&&!G.grouped&&Ne&&(Ne.about==="label"||Ne.type==="text"||rn)?s=>{let y=Ne.about==="label"?fe(u,s):s[Ne.key];if(typeof y!="string"||y.length===0)return rn?"No date":"#";if(rn)return y.slice(0,4);let O=y.trim().charAt(0).toLocaleUpperCase();return/\p{L}/u.test(O)?O:"#"}:void 0,Ge=ea?Ie.reduce((s,y)=>{let O=ea(y);return s.at(-1)?.key===O?s.at(-1).nodes.push(y):s.push({key:O,nodes:[y]}),s},[]):void 0,ta=G.grouped&&Yt?Gn.flatMap(s=>jn(s)?[]:s.nodes):Ge&&Ge.length>1?Ge.flatMap(s=>s.nodes):Ie,on=(0,Me.useMemo)(()=>ta.map(s=>s.id),[ta.map(s=>s.id).join(`
109
+ `)]),Le=Ar(on),dt=(Je?l.permittedMutations(Je):l.permittedMutations()).some(s=>{let y=s.subject?.kinds;return y!==void 0&&(y==="*"||y.includes(e))}),sn=(s,y)=>dt?(0,v.jsx)("span",{className:"graview-choose-at",children:(0,v.jsx)("input",{...Le.boxProps(s.id,y),onPointerEnter:bn,onFocus:bn})}):null,ln=s=>dt?{"data-graview-choose":s}:{},$i=(0,Me.useCallback)(s=>{Le.choose(s),requestAnimationFrame(()=>{let y=Le.list.current;((s[0]===void 0?null:y?.querySelector(`[data-graview-choose-box="${CSS.escape(s[0])}"]`))??y)?.focus({preventScroll:!0})})},[Le]),et=i==="grid"?{margin:0,padding:0,listStyle:"none",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(100%, 15rem), 1fr))",alignItems:"start",gap:12}:a||Zt?{margin:0,padding:0,listStyle:"none",display:"grid",gap:a&&i==="list"?6:0}:void 0,vt=et?void 0:"graview-rows",ct=s=>`list-at-${s.replace(/[^\p{L}\p{N}]/gu,"_")}`,kt=w.map(s=>{let y=s.from===e?s.to:s.from,O=s.from===e?s.description:s.inverse??s.description;return{relation:s,far:y,words:O}}),Oi=new Set(kt.map(s=>(s.words??"").toLowerCase()).filter((s,y,O)=>s&&O.indexOf(s)!==y));return(0,v.jsxs)(o?ho:ie,{context:t,children:[(0,v.jsxs)("div",{style:{display:"grid",gap:12},children:[(0,v.jsxs)("header",{style:{display:"grid",gap:4},children:[(0,v.jsxs)("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",columnGap:10,rowGap:4,minWidth:0},children:[(0,v.jsx)(ye,{kind:e,brand:d,schema:l.schema,size:8}),(0,v.jsx)(le,{context:t,children:Ze}),We.length>0?(0,v.jsx)("span",{style:{marginLeft:"auto",display:"flex",flexWrap:"wrap",columnGap:14},"data-testid":"beginnings-open",children:We.map(({affordance:s,mutation:y})=>(0,v.jsx)(ko,{name:y.name,title:y.title??y.name,panel:`${Xn}-${y.name}`,open:Yn(y.name),onOpen:O=>Qn(y.name,O)},s.id))}):null]}),r??u?.description?(0,v.jsx)("p",{style:se,children:r??u?.description}):null,kt.length>0||an.length>0?(0,v.jsxs)("p",{style:{...A,margin:0,display:"flex",flexWrap:"wrap",columnGap:18,rowGap:2},"data-testid":"kind-related",children:[kt.length>0?(0,v.jsxs)("span",{"data-testid":"kind-relations",children:["Related:"," ",kt.map(({relation:s,far:y,words:O},pe)=>(0,v.jsxs)("span",{"data-relation":s.edgeKind,children:[pe>0?(0,v.jsx)("span",{"aria-hidden":"true",children:" \xB7 "}):null,y==="*"?Ae(O??ve(s.edgeKind)):(0,v.jsx)(F,{to:`/${J(l.schema,y)}`,style:q,title:ee(l,y),children:O&&Oi.has(O.toLowerCase())?`${Ae(O)}: ${ee(l,y).toLowerCase()}`:Ae(O??ee(l,y))})]},`${s.edgeKind}|${s.from}|${s.to}`))]}):null,an.length>0?(0,v.jsxs)("span",{"data-testid":"kind-pictures",children:["Also as:"," ",an.map((s,y)=>(0,v.jsxs)("span",{children:[y>0?(0,v.jsx)("span",{"aria-hidden":"true",children:" \xB7 "}):null,(0,v.jsx)(F,{to:xe(t,s),style:q,children:s.title})]},_e(s)))]}):null]}):null]}),We.length>0?(0,v.jsx)("div",{style:{display:"contents"},"data-testid":"beginnings",children:We.map(({affordance:s,mutation:y})=>{let O=!!(Jn[y.name]&&Ie.length===0);return(0,v.jsx)(bo,{name:y.name,id:`${Xn}-${y.name}`,description:y.description,open:Yn(y.name),onClose:()=>Qn(y.name,!1),children:(0,v.jsx)(Oe,{store:l,mutation:y,prefilled:s.args,open:s.open,...O?{initial:{[Jn[y.name]]:_.words}}:{},...t.principal?{principal:t.principal}:{}},O?`${y.name}|${_.words}`:y.name)},s.id)})}):null,j.dropped.length>0?(0,v.jsxs)("p",{style:{...A,margin:0},"data-testid":"list-dropped",children:["This link asked for ",j.dropped.join(", "),", which ",Ze.toLowerCase()," cannot be arranged by; the rest is shown."]}):null,lt.length>0?(0,v.jsx)(Pr,{schema:l.schema,graph:l.graph,kind:e,arrangement:E,onChange:Ri,kept:{shown:Ie.length,of:lt.length},noun:{one:He(u,e),many:Ze.toLowerCase()},...Ei?{}:{allow:!1},...Zn?{filters:Zn}:{},offers:U,chips:{nodes:lt,flagged:C,...typeof c?.today=="string"?{today:c.today}:{}},query:t.framed===!0&&t.barAbove!==!0}):null,(0,v.jsx)("style",{children:Ft}),dt?(0,v.jsx)("style",{children:Cr+yo}):null,(0,v.jsx)("div",{className:"graview-list",...dt?{...Le.listProps,ref:Le.list,tabIndex:-1,"data-graview-choosable":"","aria-label":Le.chosen.length>0?`${Ze}, ${Le.chosen.length} chosen`:Ze,role:"group"}:{},children:Ie.length===0&&_.words?(0,v.jsxs)("p",{style:se,"data-testid":"none-yet",children:["Nothing here is called \u201C",_.words,"\u201D."," ",(0,v.jsx)("span",{style:A,"data-testid":"list-searched",children:Mt(l.schema,{kinds:[e],past:Z})})," ",(0,v.jsx)(F,{to:"?",style:q,children:"Show every one"})]}):Ie.length===0?(0,v.jsxs)("p",{style:se,"data-testid":"none-yet",children:[E.filter?.length||E.query?"None of them.":"None yet",!E.filter?.length&&!E.query&&We.length>0?` \u2014 the first one starts above, with \u201C${We[0]?.mutation.title??We[0]?.mutation.name}\u201D.`:!E.filter?.length&&!E.query?".":"",E.filter?.length||E.query?(0,v.jsxs)(v.Fragment,{children:[" ",(0,v.jsx)(F,{to:"?",style:q,children:"Show every one"})]}):null]}):G.grouped&&Yt?(0,v.jsx)("div",{style:{display:"grid",gap:"1rem"},"data-testid":"records","data-grouped":Yt,children:Gn.map(s=>{if(!s.closed)return(0,v.jsxs)("section",{style:{display:"grid",gap:0},"data-testid":"list-group",children:[(0,v.jsxs)("h2",{className:"graview-group-head",children:[s.label," ",(0,v.jsx)("span",{children:s.nodes.length})]}),(0,v.jsx)("ul",{style:et,className:vt,"data-graview-rows":"",children:s.nodes.map(wt)})]},s.key||"-");let y=jn(s),O=`${m}-${ct(s.key||"none")}`;return(0,v.jsxs)("section",{style:{display:"grid",gap:0},"data-testid":"list-group","data-closed":y?"shut":"open",children:[(0,v.jsx)("h2",{className:"graview-group-head",children:(0,v.jsxs)("button",{type:"button",className:"graview-group-toggle","aria-expanded":!y,"aria-controls":O,"data-testid":"list-group-toggle",onClick:()=>Ci(Un(s.key)),children:[(0,v.jsx)("span",{"aria-hidden":"true",children:y?"\u25B8":"\u25BE"}),s.label," ",(0,v.jsxs)("span",{children:["\xB7 ",s.nodes.length]}),(0,v.jsxs)("span",{style:mo,children:[" ",s.nodes.length===1?He(u,e):Ze.toLowerCase()]})]})}),(0,v.jsx)("ul",{id:O,style:y?{...et,display:"none"}:et,className:vt,"data-graview-rows":"",hidden:y,children:y?null:s.nodes.map(wt)})]},s.key||"-")})}):Ge&&Ge.length>1?(0,v.jsxs)("div",{style:{display:"grid",gap:14},"data-testid":"records","data-sectioned":Ne?.type==="date"?"year":"letter",children:[(0,v.jsx)("nav",{"aria-label":"Jump to","data-testid":"list-index",style:{...A,display:"flex",flexWrap:"wrap",gap:Ne?.type==="date"?"0 10px":"0 4px",lineHeight:1.3},children:Ge.map(s=>(0,v.jsx)("a",{href:`#${ct(s.key)}`,onClick:y=>{y.preventDefault(),document.getElementById(ct(s.key))?.scrollIntoView({block:"start"})},style:{...ke,minWidth:24,justifyContent:"center"},children:s.key},s.key))}),Ge.map(s=>(0,v.jsxs)("section",{"data-testid":"list-section","aria-labelledby":ct(s.key),style:{display:"grid",gap:0},children:[(0,v.jsx)("h2",{id:ct(s.key),className:"graview-group-head",children:s.key}),(0,v.jsx)("ul",{style:et,className:vt,"data-graview-rows":"",children:s.nodes.map(wt)})]},s.key))]}):(0,v.jsx)("ul",{style:et,className:vt,"data-testid":"records","data-graview-rows":"",children:Ie.map(wt)})}),dt?(0,v.jsx)(Rr,{store:l,chosen:Le.chosen,...Je?{principal:Je}:{},...c?{context:c}:{},anchor:fo,of:on.length,onChooseAll:()=>Le.choose(on),onClear:Le.clear,onActed:$i}):null,zn>0?(0,v.jsxs)(F,{to:hi(p,"filter","is:any"),style:{...q,...A,justifySelf:"start"},"data-testid":"past-link",children:["+",zn," past"]}):null,k===!1&&l.graph.count(e,{archived:!0})>0?(0,v.jsxs)(F,{to:hi(p,"archived","true"),style:{...q,...A,justifySelf:"start"},"data-testid":"archived-link",children:["+",l.graph.count(e,{archived:!0})," archived"]}):null]}),(0,v.jsx)(Vt,{context:t,withheld:Li,style:re,testId:"withheld"})]})}var mo={position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0},fo=()=>document.querySelector("[data-graview-choosable]")?.closest("[data-embed-content]")??null,yo=`
110
+ .graview-list[data-graview-choosable]{outline:none}
111
+ .graview-list [data-graview-choose]{position:relative;padding-left:34px}
112
+ .graview-choose-at{position:absolute;left:2px;top:0;bottom:0;z-index:${fa.raised};display:flex;align-items:center}
113
+ @media (pointer: coarse){
114
+ .graview-list:not([data-graview-choosing]) [data-graview-choose]{padding-left:0}
115
+ .graview-list:not([data-graview-choosing]) .graview-choose-at{display:none}
116
+ }
117
+ `;function ho({children:t}){return(0,v.jsx)("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:40,minWidth:0},children:t})}var wo=(t,e)=>e?{sort:{by:e,direction:"desc"}}:t?{sort:{by:"label",direction:"asc"}}:{};function vo(t,e,n){let a=At({...t.get("sort")?{sort:t.get("sort")}:{},...t.get("filter")?{filter:t.get("filter")}:{},...t.get("group")?{group:t.get("group")}:{},...t.get("q")?{q:t.get("q")}:{},...t.get("archived")?{archived:t.get("archived")}:{}}),i=[...a.filter??[]],r=t.get("by"),o=a.group??(r?{by:r}:void 0);for(let d of n){let c=t.get(d);c&&i.push({key:d,value:c})}let l=t.get("with");return l&&i.push({key:l,value:"*"}),t.get("past")==="1"&&!i.some(d=>d.key==="is")&&i.push({key:"is",value:"any"}),vn({...a.sort?{sort:a.sort}:{},...a.query?{query:a.query}:{},...i.length>0?{filter:i}:{},...o?{group:o}:{},...a.archived!==void 0?{archived:a.archived}:{}},e)}function hi(t,e,n){let a=new URLSearchParams(t);return a.set(e,n),a.delete("past"),`?${a.toString()}`}function ko({name:t,title:e,panel:n,open:a,onOpen:i}){return(0,v.jsxs)("button",{type:"button","data-testid":`act-open-${t}`,"data-graview-act":t,"aria-expanded":a,"aria-controls":n,onClick:()=>{i(!a),a||requestAnimationFrame(()=>document.getElementById(n)?.querySelector("input, select, textarea, button")?.focus())},style:{...ke,minHeight:28,margin:"-4px 0",padding:"0 2px",border:0,background:"none",font:"inherit",fontWeight:600,color:"var(--graview-ink)",cursor:"pointer"},children:[(0,v.jsx)("span",{"aria-hidden":"true",style:{marginRight:6},children:a?"\u2212":"+"}),e]})}function bo({name:t,id:e,description:n,open:a,onClose:i,children:r}){return(0,v.jsxs)("div",{"data-testid":`act-${t}`,id:e,hidden:!a,onKeyDown:o=>{o.key==="Escape"&&(o.preventDefault(),i(),document.querySelector(`[aria-controls="${e}"]`)?.focus())},style:a?{display:"grid",gap:12,padding:"4px 0 12px"}:void 0,children:[n?(0,v.jsx)("p",{style:{...A,margin:0,maxWidth:"58ch"},children:n}):null,r]})}function So({to:t,label:e}){let n=(0,Me.useRef)(null);return Lr(n),(0,v.jsx)(F,{ref:n,to:t,"aria-label":e,style:{position:"absolute",inset:0,borderRadius:6}})}var Xe=H($e(),1);var yt=H($e(),1);var W=H(Y(),1);function Kn({context:t}){let{store:e,brand:n,invariantContext:a,principal:i}=t;ae(e);let r=e.violations(a),o=e.allInvariants(),l=Ct(e,r),d=Ia(e.schema,o);return(0,W.jsxs)(ie,{context:t,children:[(0,W.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,W.jsx)(le,{context:t,children:r.length===0?"All rules hold":"What is broken"}),(0,W.jsx)("p",{style:se,"data-testid":"problems-count",children:r.length===0?"Every declared rule is satisfied by what is here.":pa(r)})]}),(0,W.jsx)(mi,{context:t}),l.map((c,p)=>{let g=c.nodeIds[0],m=g?e.graph.getNode(g):void 0;return(0,W.jsxs)("section",{style:{display:"grid",gap:10,padding:"16px 18px",borderLeft:"3px solid var(--graview-warn)",background:"var(--graview-panel-warning)",borderRadius:"0 var(--graview-radius, 12px) var(--graview-radius, 12px) 0"},children:[c.line?null:(0,W.jsx)(zt,{violation:c,schema:e.schema,...n?{brand:n}:{}}),m?(0,W.jsxs)("p",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:8},children:[(0,W.jsx)(ye,{kind:m.kind,brand:n,schema:e.schema,size:7}),(0,W.jsx)(F,{to:te(e.schema,m.kind,m.id),style:q,children:fe(e.schema.tryDefinition(m.kind),m)})]}):null,c.line?(0,W.jsx)(zt,{violation:c,schema:e.schema,...n?{brand:n}:{}}):null,(0,W.jsx)(_t,{store:e,repairs:c.repairs,...i?{principal:i}:{}})]},p)}),o.length>0?(0,W.jsxs)("section",{style:{...re,display:"grid",gap:12},"data-testid":"rules",children:[(0,W.jsx)("h2",{style:ne,children:"The rules"}),(0,W.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:10},children:o.map(c=>{let p=r.filter(u=>u.invariant===c.name).length,g=d.get(c.name),m=c.label??c.name;return(0,W.jsxs)("li",{"data-graview-rule":c.name,style:{display:"grid",gap:2},children:[(0,W.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",columnGap:12,rowGap:2},children:[g?(0,W.jsx)(Rt,{line:g,schema:e.schema,...n?{brand:n}:{},style:{flex:"1 1 18rem"}}):(0,W.jsx)("span",{style:{flex:"1 1 18rem",fontWeight:550},children:m}),(0,W.jsx)("span",{style:{...A,color:p>0?"var(--graview-warn)":"var(--graview-ink-faint)"},children:p===0?"holds":`broken in ${p} ${p===1?"place":"places"}`})]}),g&&m.trim().length>0?(0,W.jsx)("span",{style:A,children:m}):null]},c.name)})})]}):null]})}function zt({violation:t,schema:e,brand:n}){if(!t.line)return(0,W.jsx)("p",{style:{margin:0,color:"var(--graview-warn)",fontWeight:550},children:t.message});let a=Da(t),i=Fa(t);return i?(0,W.jsxs)("div",{style:{display:"grid",gap:4},"data-testid":"problem-line",children:[(0,W.jsx)("p",{style:{margin:0,color:"var(--graview-warn)",fontWeight:550},"data-testid":"problem-says",children:i}),a?(0,W.jsx)("span",{style:A,children:a}):null,(0,W.jsxs)("details",{"data-testid":"problem-judged",style:A,children:[(0,W.jsx)("summary",{style:{cursor:"pointer",width:"fit-content",minHeight:24},children:"How it is judged"}),(0,W.jsx)(Rt,{line:t.line,schema:e,...n?{brand:n}:{},lead:"none"})]})]}):(0,W.jsxs)("div",{style:{display:"grid",gap:2},"data-testid":"problem-line",children:[(0,W.jsx)(Rt,{line:t.line,schema:e,...n?{brand:n}:{},lead:"none",style:{color:"var(--graview-warn)"}}),a?(0,W.jsx)("span",{style:A,children:a}):null]})}function _t({store:t,repairs:e,principal:n}){let[a,i]=(0,yt.useState)(null),[r,o]=(0,yt.useState)(null),l=(0,yt.useRef)([]);if(e.length===0)return null;let d=a===null?null:e[a],c=d&&(d.missing??[]).length>0?t.allMutations().find(p=>p.name===d.mutation):void 0;return(0,W.jsxs)("div",{style:{display:"grid",gap:10},"data-testid":"repairs",children:[(0,W.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:e.map((p,g)=>{let m=(p.missing??[]).length>0,u=t.permits({name:p.mutation,args:{...p.args}},n);return u.ok?(0,W.jsx)("button",{ref:k=>{l.current[g]=k},type:"button","data-graview-repair":p.mutation,"data-graview-asks":m||void 0,"aria-expanded":m?a===g:void 0,onClick:()=>{if(o(null),m){i(a===g?null:g);return}i(null);try{t.apply({name:p.mutation,args:{...p.args}},n?{author:n}:{})}catch(k){o(rt(t.schema,t.allMutations(),k))}},style:be,children:m?`${p.label} \u2026`:p.label},g):(0,W.jsxs)("p",{"data-testid":"withheld","data-withheld":u.refusal.wouldNeed.join(",")||"nobody",style:{...A,margin:0},children:[(0,W.jsx)("s",{children:p.label})," \u2014 ",u.refusal.message]},g)})}),c&&d?(0,W.jsx)(Oe,{store:t,mutation:c,prefilled:{...d.args},only:d.missing??[],label:d.label,onDone:()=>{let p=a;i(null),requestAnimationFrame(()=>{let g=p===null?null:l.current[p];if(g?.isConnected){g.focus();return}let m=document.querySelector("[data-graview-page-title]")??document.querySelector("main h1, main h2");m&&(m.hasAttribute("tabindex")||(m.tabIndex=-1),m.focus())})},...n?{principal:n}:{}}):null,d&&!c&&(d.missing??[]).length>0?(0,W.jsxs)("p",{"data-testid":"refused",role:"alert",style:{margin:0,color:"var(--graview-warn)",fontSize:Sn},children:["\u201C",d.label,"\u201D names ",d.mutation,", which this app does not declare."]}):null,r?(0,W.jsx)("p",{"data-testid":"refused",role:"alert",style:{margin:0,color:"var(--graview-warn)",fontSize:Sn},children:r}):null]})}var qn=H($e(),1);var Be=H(Y(),1);function bi({store:t,link:e,principal:n}){let[a,i]=(0,qn.useState)(!1),[r,o]=(0,qn.useState)(null),l=ja(e);return(0,Be.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[(0,Be.jsx)("button",{type:"button","data-graview-provisional":"",title:l,"aria-label":`Unsure link: ${l}`,"aria-expanded":a,onClick:()=>i(!a),style:{border:"1px dashed var(--graview-ink-muted)",borderRadius:999,background:"transparent",color:"var(--graview-ink-muted)",font:"inherit",fontSize:"0.75rem",lineHeight:1,padding:"2px 6px",cursor:"pointer"},children:"unsure"}),a?(0,Be.jsxs)("span",{style:{...A,display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,Be.jsx)("span",{children:l}),(0,Be.jsx)("button",{type:"button",style:{...be,padding:"4px 10px"},onClick:()=>{try{t.apply({name:ua,args:{kind:e.edge.kind,from:e.edge.from,to:e.edge.to}},n?{author:n}:{}),i(!1)}catch(d){o(rt(t.schema,t.allMutations(),d))}},children:"Keep this link"}),r?(0,Be.jsx)("span",{role:"alert",children:r}):null]}):null]})}var h=H(Y(),1),xo=[];function Bn({context:t}){let{store:e,brand:n,principal:a,invariantContext:i}=t;ae(e);let r=ue()!==null,o=qe(),l=decodeURIComponent(o.id??""),d=Zr(e,l,{...a?{principal:a}:{},...i?{context:i}:{}}),c=Ct(e,d?.violations??xo),[p,g]=(0,Xe.useState)(null),[m,u]=(0,Xe.useState)(!1),[k,V]=(0,Xe.useState)(null),w=(0,Xe.useRef)(null),C=(0,Xe.useRef)(null),U=f=>{(w.current?.parentElement?.querySelector(`[data-affordance="${f.replace(/["\\]/g,"\\$&")}"]`)??w.current)?.focus()};if(!d)return(0,h.jsx)(ie,{context:t,children:(0,h.jsx)(le,{context:t,children:"Nothing lives at this address."})});let R=e.graph.getNode(l),j=e.schema.tryDefinition(d.kind),Q=j?.describe&&R?Wa(j,R):null,de=[...e.log.all()].filter(f=>!Pt(f)&&(f.writes.includes(l)||f.reads.includes(l))).slice(-8).reverse(),me=e.log.all().find(f=>!Pt(f)&&f.undoes===void 0&&f.primitives.some(N=>N.op==="add-node"&&N.node.id===l)),D=d.actions.affordances.filter(f=>f.provider!=="invariant"),X=D.filter(f=>f.destructive||f.setsAside),ce=m||X.length<2?D:D.filter(f=>!X.includes(f)),b=t.views?.lookup(d.kind,{cardinality:"one",fidelity:"full"}),x=b!==void 0&&!at(b)?b:void 0,L=x&&R?Ot(b,R,e.graph):void 0,M=L?d.fields.filter(f=>!L.fields.has(f.key)):d.fields,E=L?d.links.flatMap(f=>{let N=f.targets.filter(G=>!L.records.has(G.id));return N.length>0?[{...f,targets:N}]:[]}):d.links,_=x!==void 0&&Na(b),Z=r&&Ya(j).length>0;return(0,h.jsxs)(ie,{context:t,children:[(0,h.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,h.jsxs)("p",{style:{...we,display:"flex",alignItems:"center",gap:8},children:[(0,h.jsx)(ye,{kind:d.kind,brand:n,schema:e.schema,size:8}),(0,h.jsx)(F,{to:`/${J(e.schema,d.kind)}`,style:ke,children:ee(e,d.kind)})]}),(0,h.jsx)(le,{context:t,children:r&&R?.label===d.label?(0,h.jsx)(kn,{nodeId:l,field:"label",value:d.label,said:d.label}):d.label}),Q&&Q!==d.label?(0,h.jsx)("p",{style:se,children:Q}):null,me?.lineage?(0,h.jsxs)("p",{style:{...A,margin:0},"data-testid":"record-lineage",children:["Made by ",gt(me,a,{graph:e.graph,schema:e.schema,...t.seats?{seats:t.seats}:{},...t.people?{people:t.people}:{}}),", ",mn(me.lineage)]}):null,(0,h.jsx)(It,{context:t,stop:`#focus=${encodeURIComponent(l)}`,style:{...q,...A},"data-testid":"spatial-link"}),r&&R?(0,h.jsx)(yn,{choices:[{on:"changed",record:l},{on:"act",record:l},{on:"reaches",kind:d.kind,condition:"",record:l}],label:"Notify me when this changes",testId:"record-notify",style:{...be,...A,justifySelf:"start"}}):null,Re(t).some(f=>f.kind===d.kind||f.across===d.kind)?(0,h.jsxs)("p",{style:{...A,margin:0},"data-testid":"seen-in",children:["Seen in:"," ",Re(t).filter(f=>f.kind===d.kind||f.across===d.kind).map((f,N)=>(0,h.jsxs)("span",{children:[N>0?(0,h.jsx)("span",{"aria-hidden":"true",children:" \xB7 "}):null,(0,h.jsx)(F,{to:xe(t,f),style:q,children:f.title})," ",(0,h.jsx)(It,{context:t,stop:`#view=${encodeURIComponent(f.as)}`,style:{...q,...A,display:"inline-block",minWidth:24,textAlign:"center"},title:`${f.title}, in the scene`,label:`${f.title}, in the scene`,children:(0,h.jsx)("span",{"aria-hidden":"true",children:"\u2197"})})]},_e(f)))]}):null]}),R&&da(R)?(0,h.jsx)(Ao,{context:t,id:l,kind:d.kind}):null,R&&ga(e,l)?(0,h.jsx)(Po,{context:t,id:l,kind:d.kind}):null,x&&R?(0,h.jsx)("section",{"data-testid":"record-view",style:{display:"grid",minWidth:0},children:(0,h.jsx)(Tr,{children:(0,h.jsx)(x,{node:R,cardinality:"one",fidelity:"full",mode:"fullscreen",selected:!1,...d.violations.length>0?{flagged:[l]}:{}})})}):null,d.violations.length>0?(0,h.jsx)("section",{"data-testid":"record-violations",style:{display:"grid",gap:12,padding:"16px 18px",borderLeft:"3px solid var(--graview-warn)",background:"var(--graview-panel-warning)",borderRadius:"0 var(--graview-radius, 12px) var(--graview-radius, 12px) 0"},children:c.map((f,N)=>(0,h.jsxs)("div",{style:{display:"grid",gap:8},children:[(0,h.jsx)(zt,{violation:f,schema:e.schema,...n?{brand:n}:{}}),(0,h.jsx)(_t,{store:e,repairs:ei(d.actions,f.repairs),...a?{principal:a}:{}})]},N))}):null,!_&&(M.length>0||Z)?(0,h.jsxs)("section",{style:{...re,display:"grid",gap:14},"data-testid":"record-fields",children:[(0,h.jsx)("h2",{style:ne,children:"The facts"}),Ka(j,M).map((f,N)=>{let G=(0,h.jsx)("dl",{style:{margin:0,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"14px 24px"},children:f.fields.map(I=>I.files?(0,h.jsx)(Ve,{as:"field",read:!r,nodeId:l,field:I.key,label:I.label,files:I.files,labelStyle:we,style:{gap:4}},I.key):I.long?(0,h.jsx)(xr,{nodeId:l,field:I.key,label:I.label,value:I.value,markdown:I.markdown,style:{gridColumn:"1 / -1",gap:4},labelStyle:we,valueStyle:{lineHeight:1.6}},I.key):(0,h.jsxs)("div",{style:{display:"grid",gap:2,minWidth:0,alignContent:"start"},children:[(0,h.jsx)("dt",{style:we,children:I.label}),(0,h.jsx)("dd",{style:{margin:0,overflowWrap:"anywhere",minWidth:0},children:I.linked?(0,h.jsx)(Ja,{relation:I.linked.relation,refs:I.linked.refs,...r?{nodeId:l,field:I.key}:{}}):I.app?(0,h.jsx)(Et,{address:I.app,as:"record",...r?{nodeId:l,field:I.key}:{}}):I.href?(0,h.jsx)(Sr,{href:I.href,field:I.key,value:I.value,stored:I.stored,...r?{nodeId:l}:{}}):r?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(kn,{nodeId:l,field:I.key,value:I.value,stored:I.stored}),I.repeats?(0,h.jsx)(tr,{nodeId:l,field:I.key,start:R?.[I.key],value:R?.[`${I.key}Repeat`],label:`${I.label} repeats`}):null]}):I.value})]},I.key))});return f.title?(0,h.jsxs)("section",{style:{display:"grid",gap:10,minWidth:0},children:[(0,h.jsx)("h3",{"data-graview-field-group":f.title,style:{...ne,fontSize:"inherit"},children:f.title}),G]},N):(0,h.jsx)("div",{children:G},N)}),Z?(0,h.jsx)(Ve,{as:"unfilled",nodeId:l,skip:[...L?.fields??[]],labelStyle:we,style:{gap:4}}):null]}):null,(_?[]:E).map(f=>(0,h.jsxs)("section",{style:{...re,display:"grid",gap:10},children:[(0,h.jsx)("p",{style:we,children:Vr(e,f)}),f.description?(0,h.jsx)("h2",{style:ne,children:Ae(f.description)}):(0,h.jsxs)("h2",{style:ne,"aria-label":ve(f.edgeKind),children:[f.direction==="in"?"\u2190 ":"\u2192 ",ve(f.edgeKind)]}),(0,h.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"6px 18px"},children:f.targets.map(N=>{let G=za(e,f.direction==="in"?{kind:f.edgeKind,from:N.id,to:l}:{kind:f.edgeKind,from:l,to:N.id});return(0,h.jsxs)("li",{style:{display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,h.jsx)(ye,{kind:N.kind,brand:n,schema:e.schema,size:7}),(0,h.jsxs)(F,{to:te(e.schema,N.kind,N.id),style:q,children:[N.label,N.apart?(0,h.jsxs)("span",{style:A,children:[" \xB7 ",N.apart]}):null]}),G?.provisional?(0,h.jsx)(bi,{store:e,link:G,...a?{principal:a}:{}}):null]},N.id)})}),(f.direction==="out"&&e.schema.edge(f.edgeKind)?.cardinality==="one"?[]:[...new Set(f.targets.map(N=>N.kind))]).map(N=>(0,h.jsxs)(F,{to:`/${J(e.schema,N)}?${encodeURIComponent(f.edgeKind)}=${encodeURIComponent(l)}`,style:{...q,...A},"data-testid":"related-all",children:["Sort and filter ",f.description??`these ${ee(e,N).toLowerCase()}`,f.targets.some(G=>G.kind!==N)?` (${ee(e,N).toLowerCase()})`:""," ",(0,h.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]},N))]},`${f.edgeKind}|${f.direction}|${f.description??""}`)),!_&&(D.length>0||d.actions.withheld.length>0)?(0,h.jsxs)("section",{style:{...re,display:"grid",gap:14},"data-testid":"record-actions",children:[(0,h.jsx)("h2",{style:ne,ref:w,tabIndex:-1,children:"What can be done"}),(0,h.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:[ce.map(f=>{let N=p===f.id;return(0,h.jsx)("button",{type:"button","data-affordance":f.id,"data-rank":f.rank,"data-graview-act":f.mutation,autoFocus:m&&f===X[0],"aria-expanded":N,onClick:()=>{g(N?null:f.id),N||requestAnimationFrame(()=>C.current?.querySelector("input:not([type=hidden]), select, textarea, button")?.focus())},style:{...be,...N?{borderColor:"var(--graview-accent)",color:"var(--graview-accent)"}:{}},children:f.label},f.id)}),ce.length<D.length?(0,h.jsxs)("button",{type:"button","aria-expanded":!1,onClick:()=>u(!0),style:{...be,...A},"data-testid":"record-actions-more",children:["Show ",D.length-ce.length," more"]}):null]}),D.map(f=>{if(p!==f.id)return null;let N=e.allMutations().find(G=>G.name===f.mutation);return N?(0,h.jsxs)("div",{ref:C,onKeyDown:G=>{if(G.key!=="Escape"||G.defaultPrevented)return;G.preventDefault(),g(null);let I=f.id;requestAnimationFrame(()=>U(I))},style:{display:"grid",gap:10,padding:18,border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)"},children:[(0,h.jsx)("h3",{style:ne,children:f.label}),N.description?(0,h.jsx)("p",{style:{...A,margin:0},children:N.description}):null,(0,h.jsx)(Oe,{store:e,mutation:N,prefilled:f.args,open:f.open,label:f.label,onDone:()=>{g(null),V(f.mutation);let G=f.id;requestAnimationFrame(()=>U(G))},...a?{principal:a}:{}})]},f.id):null}),r&&k!==null&&p===null?(0,h.jsx)(yn,{choices:[{on:"act",act:k,record:l},{on:"act",act:k}],label:"Notify me when someone else does this",testId:"notify-after-act",style:{...be,...A,justifySelf:"start"}}):null,(0,h.jsx)(Vt,{context:t,withheld:d.actions.withheld})]}):null,r?(0,h.jsx)(Gr,{id:l,style:re,headingStyle:ne}):null,de.length>0?(0,h.jsxs)("section",{style:{...re,display:"grid",gap:10},"data-testid":"record-history",children:[(0,h.jsx)("h2",{style:ne,children:"What has happened"}),(0,h.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},children:de.map(f=>(0,h.jsxs)("li",{style:A,children:[(0,h.jsx)("span",{style:{color:"var(--graview-ink)"},children:f.intent}),f.lineage?(0,h.jsxs)("span",{"data-graview-lineage":"",children:[" \xB7 ",mn(f.lineage)]}):null," \u2014 ",gt(f,a,{graph:e.graph,schema:e.schema,...t.seats?{seats:t.seats}:{},...t.people?{people:t.people}:{}})]},f.id))})]}):null]})}function Po({context:t,id:e,kind:n}){let{store:a,principal:i}=t,r={name:`allow-tidying-${n}`,args:{id:e}},o=a.allMutations().some(l=>l.name===r.name)&&a.permits(r,i).ok;return(0,h.jsxs)("section",{"data-testid":"record-left-alone",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:12,padding:"12px 16px",border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)"},children:[(0,h.jsxs)("p",{style:{margin:0,flex:"1 1 16rem"},children:[(0,h.jsx)("strong",{children:"Left alone."})," Nothing automated changes it; tidying passes it by."]}),o?(0,h.jsx)("button",{type:"button",style:be,"data-testid":"allow-tidying",onClick:()=>a.apply(r,i?{author:i}:{}),children:"Allow tidying again"}):null]})}function Ao({context:t,id:e,kind:n}){let{store:a,principal:i}=t,r={name:`unarchive-${n}`,args:{id:e}},o=a.allMutations().some(c=>c.name===r.name)&&a.permits(r,i).ok,l=[...a.log.all()].reverse().find(c=>!Pt(c)&&c.mergedInto!==void 0&&c.writes.includes(e)),d=l?.mergedInto!==void 0?a.graph.getNode(l.mergedInto):void 0;return(0,h.jsxs)("section",{"data-testid":"record-archived",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:12,padding:"12px 16px",border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)"},children:[(0,h.jsxs)("p",{style:{margin:0,flex:"1 1 16rem"},children:[(0,h.jsx)("strong",{children:"Archived."})," Kept with its ties and history, and out of lists, counts and rules.",d?(0,h.jsxs)(h.Fragment,{children:[" ","Merged into ",(0,h.jsx)(F,{to:te(a.schema,d.kind,d.id),style:q,children:fe(a.schema.tryDefinition(d.kind),d)}),"."]}):null]}),o?(0,h.jsx)("button",{type:"button",style:be,"data-testid":"bring-it-back",onClick:()=>a.apply(r,i?{author:i}:{}),children:"Bring it back"}):null]})}var P=H(Y(),1),Co=(0,z.lazy)(()=>(__graviewPreload(import.meta.url,["./chunk.7X2ZO5BD.js","./chunk.HUKAVTMX.js","./chunk.UGFDSE37.js","./chunk.FRS3S7DN.js","./chunk.MWJUZG3C.js","./chunk.T2L4NPSB.js","./chunk.VKH3ZPPQ.js","./chunk.3H4NVUWV.js","./chunk.SIH6RCAI.js","./chunk.RYEAMM73.js","./chunk.7HPPJVIV.js","./chunk.ETWVQ3A2.js","./chunk.CZRX2FDI.js","./chunk.5EAQDBBE.js","./chunk.YT2CYCVT.js","./chunk.XK4FVT2X.js","./chunk.WAB6ZS2V.js","./chunk.XXMYKBLT.js","./chunk.34CYK2DF.js","./chunk.JZBBGY4B.js","./chunk.MB7LKKUD.js","./chunk.WVUJXDXZ.js","./chunk.52QAIGCD.js","./chunk.PPUAPAWR.js","./chunk.IHFNLKXV.js","./chunk.577PGFUT.js","./chunk.FBY5IUGU.js","./chunk.4K5QCJFH.js","./chunk.GZHZLJBF.js","./chunk.WLBXBNNH.js","./chunk.7MTX33WD.js","./chunk.OJGHDWI6.js","./chunk.Z7ZCR4LN.js","./chunk.RIW7SQH4.js","./chunk.FSAHO3LV.js","./chunk.PNVR3CXR.js","./chunk.ZTD2CNC3.js","./chunk.X7W27IRI.js","./chunk.AJZBJBMO.js"]),import("./chunk.E7EQ2VTE.js")).then(t=>({default:t.DraftPage}))),Ro={kind:"human"};function Lo({list:t,store:e}){let n=new Set(t.members.map(o=>o.kind)),a=t.total-t.members.length,i=n.size===1?[...n][0]:void 0;if(!i)return(0,P.jsx)("p",{className:"graview-spec-text graview-spec-more",children:`and ${a} more`});let r=nt(e.schema,i).toLowerCase();return(0,P.jsx)("p",{className:"graview-spec-text graview-spec-more",children:(0,P.jsx)(F,{to:`/${J(e.schema,i)}`,className:"graview-spec-link graview-spec-see-all","data-testid":"see-all",children:t.total===e.graph.nodesOfKind(i).length?`See all ${pt(t.total)} ${r}`:`${pt(a)} more \xB7 all ${r}`})})}function To({context:t,children:e}){let n=Fe(),a=t.store.schema,i=(0,z.useMemo)(()=>({href:r=>te(a,r.kind,r.id),go:r=>n(te(a,r.kind,r.id)),more:r=>(0,P.jsx)(Lo,{list:r,store:t.store})}),[a,n,t.store]);return(0,P.jsx)($t.Provider,{value:i,children:(0,P.jsx)(Mr.Provider,{value:(t.titleLevel??(t.framed&&!t.barAbove?1:2))-1,children:e})})}function Mo({steering:t}){let e=Se(),n=Fe(),a=`${e.pathname}${e.search}`;return(0,z.useLayoutEffect)(()=>t.at(a),[a,t]),(0,z.useLayoutEffect)(()=>{let i=o=>{o!==a&&n(o)};t.go.current=i;let r=t.pending?.current;return r!==void 0&&(t.pending.current=void 0,i(r)),()=>{t.go.current===i&&(t.go.current=void 0)}},[a,n,t]),null}function No({context:t,to:e}){let{pathname:n}=Se(),a=ue(),i=(e??a)?.sayWhere,r=Eo(t,n);return(0,z.useEffect)(()=>(i?.(r),()=>i?.(null)),[i,r]),null}function Eo(t,e){let[n="",a,i]=e.split("/").filter(Boolean).map(o=>{try{return decodeURIComponent(o)}catch{return o}});if(i!==void 0)return"#";if(n==="places"&&a!==void 0){if(a===un)return"#overview=1";let o=t.views?.places().find(l=>l.as===a);return o?`#focus=${encodeURIComponent(Ee(o.kind))}&view=${encodeURIComponent(o.as)}`:"#"}let r=Te(t.store.schema,n);return r?`#focus=${encodeURIComponent(a??Ee(r))}`:"#"}function $o({onNavigate:t,path:e}){let n=Se(),a=Pn(),i=Fe(),r=n.hash&&!n.hash.includes("=")?n.hash:"",o=`${n.pathname}${n.search}${r}`,l=(0,z.useRef)(t);l.current=t;let d=(0,z.useRef)(null);(0,z.useEffect)(()=>{let p=d.current;d.current=o,p!==null&&(o===p&&a!=="PUSH"||l.current?.(o,a==="POP"?"pop":a==="REPLACE"?"replace":"push"))},[n.key]);let c=(0,z.useRef)(e);return(0,z.useEffect)(()=>{e===void 0||e===c.current||(c.current=e,e!==o&&i(e))},[e]),null}function Si({context:t,registry:e,page:n}){let a=qe(),i=Te(t.store.schema,a.slug??""),r=n==="list"?Hn:Bn,l=(i?e?.lookup(i,n):void 0)??r;return(0,P.jsx)(l,{context:t})}function Oo({context:t,registry:e,children:n}){let a=(0,z.useRef)(null);return Ea(a),(0,P.jsx)("div",{ref:a,"data-graview-face":"pages",style:{display:"contents"},children:(0,P.jsx)(di,{context:t,registry:e,root:a,children:(0,P.jsx)(pi,{context:t,root:a,children:n})})})}function Io(t){return t instanceof HTMLElement?t.isContentEditable||t.tagName==="TEXTAREA"||t.tagName==="SELECT"?!0:t.tagName==="INPUT"&&!["button","submit","reset","checkbox","radio","image","file","color","range"].includes(t.type):!1}function Fo(){let{pathname:t}=Se(),e=Pn(),n=(0,z.useRef)(null);(0,z.useLayoutEffect)(()=>{if(e!=="POP"){for(let r=n.current?.parentElement;r;r=r.parentElement){let{overflowY:o}=getComputedStyle(r);if((o==="auto"||o==="scroll")&&r.scrollHeight>r.clientHeight){r.scrollTop=0;return}}window.scrollTo(0,0)}},[t]);let a=(0,z.useRef)(t),i=(0,z.useRef)(!1);return(0,z.useEffect)(()=>{if(!i.current&&t===a.current)return;i.current=!0;let r=document.activeElement;if(Io(r))return;let o=n.current?.closest("main")??document.querySelector("main"),d=n.current?.closest("[data-graview-face]")?.querySelector("[data-graview-page-title]")??o?.querySelector("h1, h2")??null??o??null;d&&(d.hasAttribute("tabindex")||d.setAttribute("tabindex","-1"),d.focus({preventScroll:!0}))},[t]),(0,P.jsx)("span",{ref:n,hidden:!0,"data-graview-scroll-reset":""})}function xi({context:t,children:e}){let n=Fe(),a=(0,z.useMemo)(()=>({record:(i,r)=>{let o=t.store.graph.getNode(i);o&&n(ft(te(t.store.schema,o.kind,i),{section:r?.section}))},place:(i,r)=>{let o=t.views?.places().find(l=>l.as===i);o&&n(ft(xe(t,o),r))},list:(i,r)=>{t.store.schema.tryDefinition(i)&&n(ft(`/${J(t.store.schema,i)}`,r))},draft:()=>n("/~draft")}),[t,n]);return(0,P.jsx)(Ma.Provider,{value:a,children:e})}function Do(){let{pathname:t,search:e,hash:n}=Se();return(0,z.useEffect)(()=>{let a=decodeURIComponent(n.replace(/^#/,""));if(!(!a||a.includes("=")))return ii(a)},[t,e,n]),null}function Wo({context:t,Home:e}){let n=Se(),a=t.views,i=n.key==="default"&&!(a&&La(a));(0,z.useEffect)(()=>{a&&Ta(a)},[a]);let r=i?va(t.views?.arrangement?.()?.first,t.store.schema,t.views?.places()??[]):void 0,o=r?.to==="place"?xe(t,r.place):r?.to==="kind"?`/${J(t.store.schema,r.kind)}`:void 0;return o?(0,P.jsx)(An,{to:o,replace:!0}):(0,P.jsx)(e,{context:t})}function Pi({context:t,registry:e}){let n=e?.lookupSurface("shell"),a=n!==void 0,i=a&&(e?.without().has("bar")??!1),r=a&&!i&&!t.embedded?{...t,barAbove:!0}:t,o=k=>n===void 0?(0,P.jsx)(Ht,{context:t,children:k}):i?(0,P.jsx)(n,{context:t,children:k}):(0,P.jsx)(Ht,{context:t,children:(0,P.jsx)(n,{context:r,children:k})}),l=e?.lookupSurface("home")??Dn,d=e?.lookupSurface("problems")??Kn,c=a?{...r,framed:!0}:t,[p,g]=(0,z.useState)(null),m=(0,z.useMemo)(()=>({onFind:g,find:!(e?.without().has("find")??!1),places:!(e?.without().has("places")??!1)}),[e]),u=(0,P.jsx)(xi,{context:t,children:(0,P.jsx)(Oo,{context:t,registry:e,children:o((0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(_a,{face:"pages"}),(0,P.jsxs)(To,{context:c,children:[(0,P.jsx)(Fo,{}),(0,P.jsx)(Do,{}),(0,P.jsxs)(Yr,{children:[(e?.routes()??[]).map(({path:k,component:V})=>(0,P.jsx)(Ce,{path:k,element:(0,P.jsx)(V,{context:c})},k)),(0,P.jsx)(Ce,{path:"/",element:(0,P.jsx)(Wo,{context:c,Home:l})}),(0,P.jsx)(Ce,{path:"/problems",element:(0,P.jsx)(d,{context:c})}),(0,P.jsx)(Ce,{path:"/~draft",element:(0,P.jsx)(z.Suspense,{fallback:null,children:(0,P.jsx)(Co,{context:c})})}),(0,P.jsx)(Ce,{path:"/search",element:(0,P.jsx)(Wn,{context:c})}),(0,P.jsx)(Ce,{path:"/map",element:(0,P.jsx)(Fn,{context:c})}),(0,P.jsx)(Ce,{path:"/places",element:(0,P.jsx)(On,{context:c})}),Re(c).some(k=>k.as===un)?null:(0,P.jsx)(Ce,{path:wa,element:(0,P.jsx)(An,{to:"/",replace:!0})}),(0,P.jsx)(Ce,{path:"/places/:as",element:(0,P.jsx)(In,{context:c})}),(0,P.jsx)(Ce,{path:"/:slug",element:(0,P.jsx)(Si,{context:c,registry:e,page:"list"})}),(0,P.jsx)(Ce,{path:"/:slug/:id",element:(0,P.jsx)(Si,{context:c,registry:e,page:"record"})})]})]})]}))})});return t.embedded||!a||i?u:(0,P.jsx)(Jr.Provider,{value:m,children:(0,P.jsx)(ur.Provider,{value:p,children:u})})}var Ho=()=>typeof document>"u"?null:document.body;function Ko({context:t,registry:e,basename:n,initialPath:a,onNavigate:i,path:r,steering:o,firstLook:l}){let[d,c]=(0,z.useState)(void 0),p=d!==void 0&&d.from===t.principal?{...t,principal:d.seat}:t;(0,z.useState)(()=>p.views?Er(p.views,p.store.schema,wn(p.brand,p.store.schema)):void 0);let g=ue();ra({reader:p.locale??g?.locale,app:p.brand?.locale??p.app?.brand?.locale});let m=p.principal??Ro,u=Pa(p.store,m,p.history),V=(u.past&&u.live===p.store?u.past.store:p.store).seenBy(m),w=V===p.store?p:{...p,store:V};Aa(p.store,p.principal);let C=(0,P.jsxs)(P.Fragment,{children:[i||r!==void 0?(0,P.jsx)($o,{onNavigate:i,path:r}):null,o?(0,P.jsx)(Mo,{steering:o}):null,w.presence||g?(0,P.jsx)(No,{context:w,to:g}):null,(0,P.jsx)(Pi,{context:w,...e?{registry:e}:{}}),l?(0,P.jsx)($r,{firstLook:l,root:Ho,app:wn(p.brand,p.store.schema)}):null]}),U=w.views?(0,P.jsxs)(Ca,{store:w.store,views:w.views,...w.principal?{principal:w.principal}:{},...w.brand?{brand:w.brand}:{},...w.locale?{locale:w.locale}:{},...w.settings?{settings:w.settings}:{},...w.presence&&!g?{presence:w.presence}:{},...w.people?{people:w.people}:{},...w.seats?{seats:w.seats}:{},onSeat:Q=>g?g.takeSeat(Q):c({from:t.principal,seat:Q}),...w.onKeepLens?{onKeepLens:w.onKeepLens}:{},...w.ai?{ai:w.ai}:{},...w.subscriptions?{subscriptions:w.subscriptions}:{},...w.signIn?{signIn:w.signIn}:{},resolveApp:w.resolveApp??g?.resolveApp,linkedRecords:w.linkedRecords??g?.linkedRecords,...w.app?{app:w.app}:{},...w.menuSections?{menuSections:w.menuSections}:{},children:[C,(0,P.jsx)(xi,{context:w,children:(0,P.jsx)(oi,{context:w})})]}):C,R=(0,P.jsx)(xa.Provider,{value:u,children:U}),j=w.files?(0,P.jsx)(Sa.Provider,{value:w.files,children:R}):R;if(a!==void 0){let Q=n===void 0?a:`${n.replace(/\/$/,"")}${a}`;return(0,P.jsx)(_r,{initialEntries:[Q],...n===void 0?{}:{basename:n},children:j})}return(0,P.jsx)(Qr,{...n===void 0?{}:{basename:n},children:j})}export{Gi as a,Ko as b};
@@ -1 +1 @@
1
- import{$a as k,db as O,eb as P,gb as h,hb as A,ic as E,jc as G,kc as F,mc as J,nc as W}from"./chunk.MNP4JI33.js";var I=(o,a)=>{let t=o.kindOf(a);return t===void 0?void 0:o.kept?.({id:a,kind:t})};function w(o,a){return o.flatMap(t=>{if(t.op!=="patch-node")return[t];let i=I(a,t.id);if(!i||!Object.keys(t.after).some(i))return[t];let c=r=>Object.fromEntries(Object.entries(r).filter(([f])=>!i(f))),s=c(t.after);return Object.keys(s).length===0?[]:[{op:"patch-node",id:t.id,before:c(t.before),after:s}]})}function _(o,a,t){if(!F(o,a))return t;let i=J(o,a),c=r=>o.graph.getNode(r)!==void 0||E(o.log).kindOf(r)!==void 0,s={...t};if(t.diff){let r=t.diff,f=G(o.log),l=o.log.length??o.log.all().length,u=t.ops?.[0]?.seq??l,x=k(a).id,y=(e,n)=>d=>f.writerAt(e,d,n),m=(e,n)=>i.shows(e.id)?i.servedWith(e,n):void 0,j=(e,n)=>e.flatMap(d=>m(d,n(d.id))??[]),S=e=>i.shows(e.from)&&i.shows(e.to)&&!h(e,i.sees),v=(e,n)=>t.ops?y(e,l):d=>n===void 0||n.includes(d)?x:f.writerAt(e,d,l),M=r.changedNodes.flatMap(e=>{let n=m(e.before,y(e.before.id,u)),d=m(e.after,v(e.after.id,e.fields));return n&&d?[{before:n,after:d,fields:e.fields.filter(p=>p in n||p in d)}]:[]}),D=new Set(r.changedNodes.map(e=>e.after.id)),g=new Map;for(let e of t.ops?.flatMap(n=>n.primitives)??t.primitives??[])e.op!=="patch-node"||D.has(e.id)||g.set(e.id,[...g.get(e.id)??[],...Object.keys(e.after)]);let B=[...g].flatMap(([e,n])=>{let d=o.graph.getNode(e);if(!d)return[];let p=m(d,y(e,u)),N=m(d,v(e,n));return p&&N&&JSON.stringify(p)!==JSON.stringify(N)?[{before:p,after:N,fields:n}]:[]});s.diff={addedNodes:j(r.addedNodes,e=>v(e)),removedNodes:j(r.removedNodes,e=>y(e,u)),changedNodes:[...M,...B],addedEdges:r.addedEdges.filter(S),removedEdges:r.removedEdges.filter(S),touched:[...r.touched.filter(i.shows),...[...g.keys()].filter(e=>i.shows(e)&&!r.touched.includes(e))]}}if(t.ops&&(s.ops=A(t.ops,i)),t.primitives){let r=s.ops;s.primitives=r?r.flatMap(f=>f.primitives):i.timeline?O(t.primitives,i.timeline,{served:(f,l)=>i.servedWith(f,l),edgeClean:f=>!h(f,i.sees),sees:i.sees},k(a).id):A([{id:"",seq:0,batch:"",author:{kind:"system"},intent:"",mutation:null,primitives:t.primitives,inverse:[],reads:[],writes:[],at:""}],i)[0].primitives}return i.kept&&s.primitives&&(s.primitives=w(s.primitives,i)),t.reads&&(s.reads=t.reads.filter(r=>i.shows(r)&&c(r))),t.writes&&(s.writes=t.writes.filter(i.shows)),t.intent!==void 0&&h(t.intent,i.sees)&&(s.intent=P),t.violationsAfter&&Object.assign(s,b?b(o,W(o,a),!!t.ops,s.primitives??[]):{introduces:[],resolves:[],violationsAfter:[]}),s}var b,z=o=>void(b=o);export{_ as a,z as b};
1
+ import{$a as k,db as O,eb as P,gb as h,hb as A,jc as E,kc as G,lc as F,nc as J,oc as W}from"./chunk.X7W27IRI.js";var I=(o,a)=>{let t=o.kindOf(a);return t===void 0?void 0:o.kept?.({id:a,kind:t})};function w(o,a){return o.flatMap(t=>{if(t.op!=="patch-node")return[t];let i=I(a,t.id);if(!i||!Object.keys(t.after).some(i))return[t];let c=r=>Object.fromEntries(Object.entries(r).filter(([f])=>!i(f))),s=c(t.after);return Object.keys(s).length===0?[]:[{op:"patch-node",id:t.id,before:c(t.before),after:s}]})}function _(o,a,t){if(!F(o,a))return t;let i=J(o,a),c=r=>o.graph.getNode(r)!==void 0||E(o.log).kindOf(r)!==void 0,s={...t};if(t.diff){let r=t.diff,f=G(o.log),l=o.log.length??o.log.all().length,u=t.ops?.[0]?.seq??l,x=k(a).id,y=(e,n)=>d=>f.writerAt(e,d,n),m=(e,n)=>i.shows(e.id)?i.servedWith(e,n):void 0,j=(e,n)=>e.flatMap(d=>m(d,n(d.id))??[]),S=e=>i.shows(e.from)&&i.shows(e.to)&&!h(e,i.sees),v=(e,n)=>t.ops?y(e,l):d=>n===void 0||n.includes(d)?x:f.writerAt(e,d,l),M=r.changedNodes.flatMap(e=>{let n=m(e.before,y(e.before.id,u)),d=m(e.after,v(e.after.id,e.fields));return n&&d?[{before:n,after:d,fields:e.fields.filter(p=>p in n||p in d)}]:[]}),D=new Set(r.changedNodes.map(e=>e.after.id)),g=new Map;for(let e of t.ops?.flatMap(n=>n.primitives)??t.primitives??[])e.op!=="patch-node"||D.has(e.id)||g.set(e.id,[...g.get(e.id)??[],...Object.keys(e.after)]);let B=[...g].flatMap(([e,n])=>{let d=o.graph.getNode(e);if(!d)return[];let p=m(d,y(e,u)),N=m(d,v(e,n));return p&&N&&JSON.stringify(p)!==JSON.stringify(N)?[{before:p,after:N,fields:n}]:[]});s.diff={addedNodes:j(r.addedNodes,e=>v(e)),removedNodes:j(r.removedNodes,e=>y(e,u)),changedNodes:[...M,...B],addedEdges:r.addedEdges.filter(S),removedEdges:r.removedEdges.filter(S),touched:[...r.touched.filter(i.shows),...[...g.keys()].filter(e=>i.shows(e)&&!r.touched.includes(e))]}}if(t.ops&&(s.ops=A(t.ops,i)),t.primitives){let r=s.ops;s.primitives=r?r.flatMap(f=>f.primitives):i.timeline?O(t.primitives,i.timeline,{served:(f,l)=>i.servedWith(f,l),edgeClean:f=>!h(f,i.sees),sees:i.sees},k(a).id):A([{id:"",seq:0,batch:"",author:{kind:"system"},intent:"",mutation:null,primitives:t.primitives,inverse:[],reads:[],writes:[],at:""}],i)[0].primitives}return i.kept&&s.primitives&&(s.primitives=w(s.primitives,i)),t.reads&&(s.reads=t.reads.filter(r=>i.shows(r)&&c(r))),t.writes&&(s.writes=t.writes.filter(i.shows)),t.intent!==void 0&&h(t.intent,i.sees)&&(s.intent=P),t.violationsAfter&&Object.assign(s,b?b(o,W(o,a),!!t.ops,s.primitives??[]):{introduces:[],resolves:[],violationsAfter:[]}),s}var b,z=o=>void(b=o);export{_ as a,z as b};
@@ -0,0 +1 @@
1
+ import{a as n}from"./chunk.HP3ZEDCD.js";import"./chunk.7X2ZO5BD.js";import"./chunk.HUKAVTMX.js";import"./chunk.UGFDSE37.js";import{j as s}from"./chunk.FRS3S7DN.js";import"./chunk.MWJUZG3C.js";import"./chunk.T2L4NPSB.js";import"./chunk.VKH3ZPPQ.js";import"./chunk.3H4NVUWV.js";import"./chunk.SIH6RCAI.js";import"./chunk.RYEAMM73.js";import"./chunk.7HPPJVIV.js";import"./chunk.ETWVQ3A2.js";import"./chunk.CZRX2FDI.js";import"./chunk.5EAQDBBE.js";import"./chunk.YT2CYCVT.js";import"./chunk.QVKKXMNK.js";import"./chunk.ZE4CTZQ3.js";import"./chunk.XK4FVT2X.js";import"./chunk.WAB6ZS2V.js";import"./chunk.XXMYKBLT.js";import"./chunk.34CYK2DF.js";import"./chunk.JZBBGY4B.js";import"./chunk.UT6642FC.js";import"./chunk.MB7LKKUD.js";import"./chunk.WVUJXDXZ.js";import"./chunk.52QAIGCD.js";import"./chunk.PPUAPAWR.js";import"./chunk.IHFNLKXV.js";import"./chunk.577PGFUT.js";import"./chunk.FBY5IUGU.js";import"./chunk.4K5QCJFH.js";import"./chunk.GZHZLJBF.js";import"./chunk.WLBXBNNH.js";import"./chunk.7MTX33WD.js";import"./chunk.OJGHDWI6.js";import"./chunk.Z7ZCR4LN.js";import"./chunk.RIW7SQH4.js";import"./chunk.FSAHO3LV.js";import"./chunk.PNVR3CXR.js";import{F as y,Q as i}from"./chunk.ZTD2CNC3.js";import"./chunk.X7W27IRI.js";import{b as r}from"./chunk.AJZBJBMO.js";var c=r(y(),1),e=r(i(),1);function v({store:d,views:t,as:a,scope:o}){let l=(0,c.useMemo)(()=>s({scope:`.${o}`}),[o]);return(0,e.jsxs)("div",{"data-testid":"embed-picture","data-embed-content":"",tabIndex:0,"aria-label":t.places().find(m=>m.as===a)?.title??"The picture",style:{flex:"1 1 auto",minHeight:0,display:"grid",gridTemplateRows:"minmax(0, 1fr)",overflow:"auto",background:"var(--graview-ground)",color:"var(--graview-ink)",fontFamily:"var(--graview-font-body, system-ui)"},children:[(0,e.jsx)("style",{children:l}),(0,e.jsx)(n,{store:d,views:t,as:a})]})}export{v as PictureFace};
@@ -0,0 +1 @@
1
+ var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{n as v}from"./chunk.PNVR3CXR.js";import{F as P,I as w,Q as p,Y as R,a as A,xa as b}from"./chunk.ZTD2CNC3.js";import{Rc as h}from"./chunk.X7W27IRI.js";import{b as a}from"./chunk.AJZBJBMO.js";var L=a(p(),1),B=v.part(e=>(0,L.jsx)(e.ActivityRail,{calls:[]}),{quiet:!0});var l=a(P(),1),S=a(p(),1),C=b(A(()=>(__graviewPreload(import.meta.url,["./chunk.BU2DSZ2L.js","./chunk.U5ACEYAN.js","./chunk.G64AREGA.js","./chunk.WAB6ZS2V.js","./chunk.3C4RJIJU.js","./chunk.YJCT3DV2.js","./chunk.34CYK2DF.js","./chunk.JZBBGY4B.js","./chunk.UT6642FC.js","./chunk.TI4OSTQV.js","./chunk.GZHZLJBF.js","./chunk.WLBXBNNH.js","./chunk.7MTX33WD.js","./chunk.OJGHDWI6.js","./chunk.Z7ZCR4LN.js","./chunk.RIW7SQH4.js","./chunk.FSAHO3LV.js","./chunk.PNVR3CXR.js","./chunk.ZTD2CNC3.js","./chunk.X7W27IRI.js","./chunk.AJZBJBMO.js"]),import("./chunk.HJ56Q6WB.js")))),F=C.part((e,r)=>{let t=e.RecordInteractions;return(0,S.jsx)(t,{...r})},{quiet:!0});function I(e,r,t){let o=e.target;return(o.on==="record"||o.on==="field"?o.id===r:o.on==="selection"?o.ids.includes(r):o.on==="act"?o.id===r:!1)||e.offered.some(n=>n.id===`record:${r}`||n.id.startsWith(`fill:${r}:`))||(e.batches??[]).some(n=>t(n).includes(r))}function T({id:e,style:r,headingStyle:t,className:o}){let{ai:d,aiDesk:n,store:f}=R(),{entries:y}=w(n),s=d.off===!0;(0,l.useEffect)(()=>{s||n.load()},[n,s]);let g=f.log.length,m=(0,l.useMemo)(()=>{let x=u=>f.log.all().flatMap(k=>k.batch===u?k.writes:[]);return y.filter(u=>I(u,e,x))},[y,e,f,g]);return s||m.length===0?null:(0,S.jsx)(l.Suspense,{fallback:null,children:(0,S.jsx)(F,{entries:m,...r?{style:r}:{},...t?{headingStyle:t}:{},...o?{className:o}:{}})})}var c=a(P(),1),i=a(p(),1);function ro({context:e,stop:r,title:t,label:o,style:d,className:n,children:f,...y}){let s=h(e.views?.arrangement?.()),g=f??(0,i.jsxs)(i.Fragment,{children:["In ",s==="Scene"?"the scene":s.replace(/^The /,"the ")," ",(0,i.jsx)("span",{"aria-hidden":"true",children:"\u2197"})]}),m=o?{"aria-label":o}:{};if(e.overview){let x=e.overview;return(0,i.jsx)("a",{href:r,...y,...m,...t?{title:t}:{},style:d,...n?{className:n}:{},onClick:u=>{u.preventDefault(),x(r)},children:g})}return e.embedded?null:(0,i.jsx)("a",{href:`${e.sceneHref??"/"}${r}`,...y,...m,...t?{title:t}:{},style:d,...n?{className:n}:{},children:g})}function oo(){return(0,i.jsx)("a",{href:"#fresh","data-testid":"start-fresh",title:"Forget every edit made in this browser and return to the example",onClick:e=>{e.preventDefault();let r=new URL(window.location.href);r.searchParams.set("fresh","1"),window.location.assign(r.toString())},style:{color:"inherit",display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24},children:"Start fresh"})}function to(e){let r=(0,c.useRef)(0),t=(0,c.useCallback)(o=>e.subscribe(()=>{r.current+=1,o()}),[e]);return(0,c.useSyncExternalStore)(t,()=>r.current,()=>0)}export{B as a,T as b,ro as c,oo as d,to as e};
@@ -0,0 +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 Je}from"./chunk.QVKKXMNK.js";import{a as Ue}from"./chunk.ZSW74NVJ.js";import{a as Le}from"./chunk.U5ACEYAN.js";import{a as oe}from"./chunk.TI4OSTQV.js";import{a as re}from"./chunk.PPUAPAWR.js";import{e as ke}from"./chunk.PNVR3CXR.js";import{F as sn,I as je,O as Ne,Q as De,Y as He}from"./chunk.ZTD2CNC3.js";import{$ as _,Bb as Me,X as te,Z as L,ca as Ie,ea as me,fb as ve,fc as Ee,wb as Re,zb as ie}from"./chunk.X7W27IRI.js";import{b as he}from"./chunk.AJZBJBMO.js";var an=e=>/^(?:aggregate|kind):([^,]+)$/.exec(e)?.[1];function Fe(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(r=>r===void 0?void 0:an(r)).find(r=>r!==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 K=e=>e.on==="record"||e.on==="field"?[e.id]:e.on==="selection"?e.ids:e.on==="act"&&e.id!==void 0?[e.id]:[],se=(e,n)=>e.tryDefinition(n)?.fields?.shape??{},G=(e,n)=>e.tryDefinition(n)?.edges??{},ae=(e,n)=>new Set(e.tryDefinition(n)?.display?.hide??[]),N=(e,n)=>te(e.tryDefinition(n.kind),n),be=(e,n,t)=>Ie(e.tryDefinition(n),t)||L(t),Ae=e=>typeof e=="boolean"?e?"yes":"no":String(e);function xe(e,n){let t=e.kindsKeptFrom(n);return new Set(e.schema.kinds.filter(i=>!t.has(i)))}function Se(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 de(e,n,t){let i=e,{principal:o}=t,r=t.each??8,l=oe(i)?.store??i,d=l.seenBy(o),a=l.schema,k=xe(l,o),c=s=>{let p=d.graph.getNode(s);return p&&k.has(p.kind)?p:void 0},f=l.allMutations(),g=new Map(f.map(s=>[s.name,s])),A=[],$=new Set,b=s=>{$.has(s.id)||($.add(s.id),A.push(s))},h=s=>s.slice(0,r),x=K(n).filter(s=>c(s)!==void 0);if(K(n).length>0&&x.length===0)return{target:n,candidates:[]};let m=x.length===1?c(x[0]):void 0,u=m?.kind??(n.on==="list"?n.kind:n.on==="lens"?n.kind??t.places?.find(s=>s.as===n.place)?.kind:void 0)??(n.on==="selection"?c(x[0])?.kind:void 0);if(u!==void 0&&!k.has(u))return{target:n,candidates:[]};let v=(s,p)=>`act:${s}${Object.keys(p).length>0?`:${Object.values(p).map(C=>String(C)).join(",")}`:""}`,P=(s,p,C,y,O)=>{s.destructive||Object.values(p).some(E=>typeof E=="string"&&l.graph.has(E)&&c(E)===void 0)||Se(l,{name:s.name,args:{...p}},o,y.length===0)&&b({type:"act",id:v(s.name,p),label:C,description:O??s.description??C,mutation:s.name,args:p,asks:y})};if(n.on!=="place"||t.acts)if(t.acts)for(let s of t.acts){let p=g.get(s.mutation);!p||s.destructive||n.on==="act"&&s.mutation!==n.act||P(p,s.args,s.label,(s.open??[]).filter(C=>!C.optional).map(C=>C.name),s.why)}else{let s=m?[m]:[];for(let p of f){if(n.on==="act"&&p.name!==n.act)continue;let C=p.input.shape??{},y=O=>Object.entries(C).filter(([E,w])=>E!==O&&w.safeParse?.(void 0).success===!1).map(([E])=>E);if(p.subject)for(let O of s)ie(a,p).includes(O.kind)&&P(p,{[p.subject.arg]:O.id},`${p.title??L(p.name)}: ${N(a,O)}`,y(p.subject.arg));else u!==void 0&&(p.creates??[]).includes(u)&&P(p,{},p.title??L(p.name),y(void 0))}}let W=A.filter(s=>s.type==="act");A.splice(0,A.length,...h(W));let q=(s,p)=>{let C=Me(a,f).get(s.kind),y=se(a,s.kind),O=ae(a,s.kind),E=[];for(let[w,j]of Object.entries(y)){if(p!==void 0?w!==p:O.has(w)||s[w]!==void 0)continue;let H=re(j),U=H?.type==="enum"?H.options??[]:H?.type==="boolean"?[!0,!1]:[];if(U.length===0)continue;let D=(C?.get(w)??[]).map(R=>g.get(R)).find(R=>R?.subject!==void 0&&Se(l,{name:R.name,args:{[R.subject.arg]:s.id,[w]:U.find(ge=>ge!==s[w])??U[0]}},o,!0));if(D?.subject)for(let R of U)s[w]!==R&&E.push({type:"fill",id:`fill:${s.id}:${w}:${Ae(R)}`,label:`${be(a,s.kind,w)}: ${Ae(R)}`,description:`Set ${be(a,s.kind,w).toLowerCase()} of ${N(a,s)} to ${Ae(R)}`,record:s.id,field:w,value:R,call:{name:D.name,args:{[D.subject.arg]:s.id,[w]:R}}})}for(let[w,j]of Object.entries(G(a,s.kind))){if(p!==void 0&&w!==p)continue;let H=j.to==="*"?[...k]:j.to.filter(I=>k.has(I)),U=new Set(d.graph.out(s.id,w).map(I=>I.id)),D=f.find(I=>(I.connects??[]).includes(w)&&I.subject!==void 0&&ie(a,I).includes(s.kind));if(!D?.subject)continue;let R=Re(D.input).find(I=>I.name!==D.subject.arg);if(!R)continue;let ge=H.flatMap(I=>R.kinds.length===0||R.kinds.includes(I)?d.graph.nodesOfKind(I):[]).filter(I=>I.id!==s.id&&!U.has(I.id)&&c(I.id)!==void 0);for(let I of h(ge)){let Pe={name:D.name,args:{[D.subject.arg]:s.id,[R.name]:I.id}};Se(l,Pe,o,!0)&&E.push({type:"fill",id:`fill:${s.id}:${w}:${I.id}`,label:`${L(w)}: ${N(a,I)}`,description:`Link ${N(a,s)} to ${N(a,I)}${j.description?` as ${j.description}`:""}`,record:s.id,field:w,value:I.id,call:Pe})}}return E};if(n.on==="field"&&m)for(let s of q(m,n.field))b(s);else if(m&&n.on==="record")for(let s of h(q(m)))b(s);let z=s=>{let p=_(a,s).toLowerCase(),C=[{type:"panel",id:`panel:${s}:list`,label:`A list of ${p}`,description:`Every ${me(a.tryDefinition(s),s).toLowerCase()} this viewer may see, as a list`,panel:{lens:"blocks",kind:s}}],y=ae(a,s);for(let[O,E]of Object.entries(se(a,s))){if(y.has(O))continue;let w=re(E),j=be(a,s,O).toLowerCase();if(w?.type==="enum")C.push({type:"panel",id:`panel:${s}:group:${O}`,label:`${F(p)} by ${j}`,description:`A list of ${p} grouped by ${j}`,panel:{lens:"blocks",kind:s,group:O}}),C.push({type:"panel",id:`panel:${s}:columns:${O}`,label:`Columns of ${p} by ${j}`,description:`${F(p)} in a column for each ${j}`,panel:{lens:"columns",kind:s,column:O}});else if(w?.type==="number"||w?.type==="integer"||w?.type==="date"||w?.type==="datetime"){let H=w.type==="date"||w.type==="datetime";C.push({type:"panel",id:`panel:${s}:sort:${O}`,label:`${F(p)} by ${j}`,description:`A list of ${p}, the ${H?"latest":"highest"} ${j} first`,panel:{lens:"blocks",kind:s,sort:{by:O,direction:"desc"}}}),H&&C.push({type:"panel",id:`panel:${s}:calendar:${O}`,label:`A calendar of ${p}`,description:`${F(p)} on a calendar by ${j}`,panel:{lens:"calendar",kind:s,start:O}})}}return C},ne=n.on==="place"?[...k]:u!==void 0?[u]:[];for(let s of ne)for(let p of h(z(s)))b(p);for(let s of h((t.places??[]).filter(p=>p.kind===void 0?n.on==="place":k.has(p.kind)&&(n.on==="place"||p.kind===u))))n.on==="lens"&&s.as===n.place||b({type:"place",id:`place:${s.as}`,label:s.title,description:`Go to ${s.title}`,place:s.as});if(m){let s=[];for(let[p,C]of Object.entries(G(a,m.kind)))for(let y of d.graph.out(m.id,p))c(y.id)&&s.push({type:"record",id:`record:${y.id}`,label:N(a,y),description:`${F(C.description??L(p))}: ${N(a,y)}`,record:y.id,relation:p});for(let p of a.kinds)for(let[C,y]of Object.entries(G(a,p)))if(!(y.to!=="*"&&!y.to.includes(m.kind)))for(let O of d.graph.in(m.id,C))O.kind===p&&c(O.id)&&s.push({type:"record",id:`record:${O.id}`,label:N(a,O),description:`${F(y.inverse??L(C))}: ${N(a,O)}`,record:O.id,relation:C});for(let p of h(s))b(p)}else if(n.on==="list"||n.on==="lens")for(let s of h(u!==void 0?d.graph.nodesOfKind(u):[]))c(s.id)&&b({type:"record",id:`record:${s.id}`,label:N(a,s),description:`Open ${N(a,s)}`,record:s.id});else if(n.on==="selection")for(let s of x){let p=c(s);b({type:"record",id:`record:${s}`,label:N(a,p),description:`Open ${N(a,p)}`,record:s})}return{target:n,candidates:A}}var F=e=>e&&`${e[0].toUpperCase()}${e.slice(1)}`,we=new WeakMap;function dn(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 ln(e,n){let t=e,i=oe(t)?.store??t,o=i.schema,r=xe(i,n),d=i.allMutations().filter(b=>!b.destructive&&i.permits({name:b.name,args:{}},n).ok!==!1),a=`${[...r].join(",")}|${d.map(b=>b.name).join(",")}`,k=we.get(o)?.get(a);if(k)return k;let c=[...r].map(b=>{let h=ae(o,b),x={};for(let[u,v]of Object.entries(se(o,b))){if(h.has(u))continue;let P=re(v);P&&(x[u]=P.type==="enum"?`enum:${(P.options??[]).join("|")}`:P.type)}let m={};for(let[u,v]of Object.entries(G(o,b)))m[u]=v.to==="*"?[...r]:v.to.filter(P=>r.has(P));return{kind:b,noun:me(o.tryDefinition(b),b),plural:_(o,b),fields:x,relations:m}}),f=d.map(b=>({name:b.name,title:b.title??L(b.name),...b.subject?{on:ie(o,b).filter(h=>r.has(h))}:{}})),g={kinds:c,acts:f},A={version:dn(JSON.stringify(g)),...g},$=we.get(o)??new Map;return $.set(a,A),we.set(o,$),A}var cn=e=>e.name??e.id??e.kind;function Ge(e,n,t){let i=e,{principal:o}=t,r=oe(i)?.store??i,l=r.seenBy(o),d=r.schema,a=xe(r,o),k=m=>{let u=l.graph.getNode(m);return u&&a.has(u.kind)?u:void 0},c=m=>({id:m.id,kind:m.kind,label:N(d,m)}),f=K(n),g=f.length===1?k(f[0]):void 0,A=g?Object.fromEntries(Object.keys(se(d,g.kind)).filter(m=>!ae(d,g.kind).has(m)&&g[m]!==void 0&&m!=="label").map(m=>[m,g[m]])):{},$={on:n.on,...g?{record:{...c(g),fields:A}}:{},...n.on==="field"&&g?{field:n.field}:{},...n.on==="list"&&a.has(n.kind)?{kind:n.kind}:{},...n.on==="lens"?{place:n.place,...n.kind&&a.has(n.kind)?{kind:n.kind}:{}}:{},...n.on==="place"?{place:n.place}:{},...n.on==="act"?{act:n.act}:{}},b=[...new Set([...n.on==="selection"?n.ids:[],...t.selection??[]])].flatMap(m=>{let u=k(m);return u?[c(u)]:[]}),h=[];if(g){for(let m of Object.keys(G(d,g.kind)))for(let u of l.graph.out(g.id,m))k(u.id)&&h.push({...c(u),relation:m,direction:"out"});for(let m of d.kinds)for(let u of Object.keys(G(d,m)))for(let v of l.graph.in(g.id,u))v.kind===m&&k(v.id)&&h.push({...c(v),relation:u,direction:"in"})}let x=l.batches().filter(m=>!m.ops.every(ve)).slice(-(t.recent??6)).reverse().map(m=>({intent:m.intent,at:m.at,by:cn(m.author)}));return{...t.place!==void 0?{place:t.place}:{},target:$,selection:b,neighbors:h.slice(0,24),recent:x,schema:ln(r,o)}}function Q(e){if(!e.off)return e.fast??(e.decide?{model:e.name??"decide",decide:e.decide}:void 0)}function Be(e){return e.suggestOnOpen!==!1&&Q(e)!==void 0}function J(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
+
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 Oe=(e,n,t)=>e?n/1e6*(e.inputPerMillion??0)+t/1e6*(e.outputPerMillion??0):void 0,Ce=()=>`ai-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;function fn(e,n,t=[]){let i=o=>{let r=e.graph.getNode(o);return r?te(e.schema.tryDefinition(r.kind),r):"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)?_(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 We=e=>e.type!=="act"||e.asks.length===0,$e=(e,n)=>({id:e.id,type:e.type,label:e.label,...n!==void 0?{confidence:n}:{}});function Y(e,n){let t=n.interaction??Ce(),i=de(n.store,n.target,{principal:n.principal,...n.acts?{acts:n.acts}:{},...n.places?{places:n.places}:{}}),o=Ge(n.store,n.target,{principal:n.principal,...n.place?{place:n.place}:{},...n.selection?{selection:n.selection}:{}}),r=[];return{id:t,catalog:i,state:o,entry:{id:t,at:new Date().toISOString(),by:n.by??n.principal,target:n.target,targetLabel:fn(n.store,n.target,n.places)},usage:r,meter:l=>{r.push(l),e.meter?.({...l,interaction:t})}}}async function ce(e,n,t,i){let o=await e.decide(n,t),{inputTokens:r,outputTokens:l}=o.usage,d=Oe(e.price,r,l);return i({tier:"fast",model:e.model,inputTokens:r,outputTokens:l,...d!==void 0?{costUsd:d}:{}}),o.answers}async function V(e,n,t,i,o){let r=await e.think({system:n,prompt:t,state:i.state,catalog:i.catalog}),l=r.usage?.inputTokens,d=r.usage?.outputTokens,a=r.usage?.costUsd??(l!==void 0?Oe(e.price,l,d??0):void 0);return o({tier:"thinking",model:e.model,...l!==void 0?{inputTokens:l}:{},...d!==void 0?{outputTokens:d}:{},...a!==void 0?{costUsd:a}:{}}),Ue(r.text)}function fe(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 ue(e,n,t){if(e?.type!=="choice")return[];let i=e,o=Object.entries(i.probabilities).sort((r,l)=>l[1]-r[1]);return o.some(([r])=>r===i.choice)||o.unshift([i.choice,i.confidence]),o.flatMap(([r,l])=>{let d=n(r);return d?[{candidate:d,confidence:l}]:[]}).slice(0,t)}var M=(e,n,t,i)=>({interaction:{...e.entry,ask:{kind:t,said:n??""},offered:[],outcome:"failed",failed:i,usage:[...e.usage]},offers:[]}),X="AI isn't on here.";async function qe(e,n,t=3){let i=Y(e,n),o=n.said??"Suggest",r=i.catalog.candidates.filter(We).slice(0,24);if(r.length===0)return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:[],outcome:"offered",usage:[]},offers:[]};let l=Q(e),d=J(e),a=[];try{if(l){let{question:k,of:c}=fe(r,"Which of these would the person most likely want to do next, here?"),f=await ce(l,{...i.state,candidates:r.map(g=>({id:g.id,type:g.type,says:g.description}))},{next:k},i.meter);a=ue(f.next,c,t)}else if(d){let k=await V(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:r.map(f=>({id:f.id,says:f.description}))}),i,i.meter);a=(Array.isArray(k?.pick)?k.pick.filter(f=>typeof f=="string"):[]).flatMap(f=>r.filter(g=>g.id===f)).slice(0,t).map(f=>({candidate:f}))}else return M(i,o,"suggest",X)}catch(k){return M(i,o,"suggest",k instanceof Error?k.message:String(k))}return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:a.map(({candidate:k,confidence:c})=>$e(k,c)),outcome:"offered",usage:[...i.usage]},offers:a.map(({candidate:k})=>k)}}async function ze(e,n){let t=Y(e,n),i=n.said??"Fill in",o=t.catalog.candidates.filter(f=>f.type==="fill"),r=new Map;for(let f of o)r.set(f.field,[...r.get(f.field)??[],f]);if(r.size===0)return{interaction:{...t.entry,ask:{kind:"fill",said:i},offered:[],outcome:"offered",usage:[]},offers:[]};let l=Q(e),d=J(e),a=[];try{if(l){let f=[...r].map(([A,$],b)=>({key:`f${b+1}`,field:A,...fe($,`Which value fits "${A}" best for this record?`)})),g=await ce(l,t.state,Object.fromEntries(f.map(A=>[A.key,A.question])),t.meter);for(let A of f){let $=!un(n.store,n.target,A.field)&&pn(n.store,n.target,A.field)!=="one";a.push(...ue(g[A.key],A.of,$?3:1).filter((b,h)=>h===0||b.confidence>=.4))}}else if(d){let f=await V(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($=>({id:$.id,says:$.description}))}),t,t.meter),g=Array.isArray(f?.fills)?f.fills.filter($=>typeof $=="string"):[],A=new Set;for(let $ of g){let b=o.find(h=>h.id===$);b?.type==="fill"&&!A.has(b.field)&&(A.add(b.field),a.push({candidate:b}))}}else return M(t,i,"fill",X)}catch(f){return M(t,i,"fill",f instanceof Error?f.message:String(f))}let k=t.usage.at(-1)?.model,c=Z(n.store,{interaction:t.id,target:n.target,basis:i,...k?{model:k}:{},proposals:a.flatMap(({candidate:f,confidence:g})=>f.type==="fill"?[{id:f.id,label:f.label,said:f.description,call:f.call,record:f.record,field:f.field,...g!==void 0?{confidence:g}:{}}]:[])},n.principal);return{interaction:{...t.entry,ask:{kind:"fill",said:i},offered:c.proposals.map(f=>({id:f.id,type:"fill",label:f.label,...f.confidence!==void 0?{confidence:f.confidence}:{}})),outcome:"offered",usage:[...t.usage]},offers:[],...c.proposals.length>0?{ghost:c}:{}}}function un(e,n,t){let i=n.on==="record"||n.on==="field"?n.id:void 0,o=i?e.graph.getNode(i)?.kind:void 0,r=(o?e.schema.tryDefinition(o)?.fields?.shape:void 0)??{};return t in r}function pn(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 _e(e,n){let t=Y(e,n),i=n.said??"Add one",o=new Set(n.store.allMutations().filter(c=>(c.creates??[]).length>0).map(c=>c.name)),r=t.catalog.candidates.filter(c=>c.type==="act"&&c.asks.length>0&&o.has(c.mutation));if(r.length===0)return M(t,i,"record","Nothing here makes a record.");let l=J(e);if(!l)return M(t,i,"record",X);let d;try{let c=await V(l,'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:r.map(A=>({id:A.id,says:A.description,asks:A.asks}))}),t,t.meter),f=r.find(A=>A.id===c?.act),g=typeof c?.args=="object"&&c.args!==null?c.args:{};f&&(d={act:f,args:Object.fromEntries(Object.entries(g).filter(([A])=>f.asks.includes(A)))})}catch(c){return M(t,i,"record",c instanceof Error?c.message:String(c))}if(!d)return M(t,i,"record","The model named no act this app has here.");let a=t.usage.at(-1)?.model,k=Z(n.store,{interaction:t.id,target:n.target,basis:i,...a?{model:a}:{},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 k.proposals.length===0?M(t,i,"record","What the model proposed could not be made here."):{interaction:{...t.entry,ask:{kind:"record",said:i},offered:k.proposals.map(c=>({id:c.id,type:"act",label:c.said})),outcome:"offered",usage:[...t.usage]},offers:[d.act],ghost:k}}async function Ke(e,n){let t=Y(e,n),i=n.said??"Make a panel",o=t.catalog.candidates.filter(c=>c.type==="panel");if(o.length===0)return M(t,i,"panel","Nothing here can be drawn as a panel.");let r=Q(e),l=J(e),d;try{if(l){let c=await V(l,'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(g=>({id:g.id,says:g.description}))}),t,t.meter),f=o.find(g=>g.id===c?.panel);f&&(d={panel:f,...typeof c?.title=="string"&&c.title.trim()?{title:c.title.trim().slice(0,60)}:{}})}else if(r){let{question:c,of:f}=fe(o,`Which panel answers this best: ${i}`),g=ue((await ce(r,t.state,{panel:c},t.meter)).panel,f,1)[0];g?.candidate.type==="panel"&&(d={panel:g.candidate,confidence:g.confidence})}else return M(t,i,"panel",X)}catch(c){return M(t,i,"panel",c instanceof Error?c.message:String(c))}if(!d)return M(t,i,"panel","The model named no panel this app can draw.");let a=d.title??d.panel.label,k={title:a,recipe:{...d.panel.panel,title:a}};return{interaction:{...t.entry,ask:{kind:"panel",said:i},offered:[$e(d.panel,d.confidence)],outcome:"drawn",panel:k,usage:[...t.usage]},offers:[d.panel],panel:k}}function yn(e){return e.off?void 0:e.answer}var gn=`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 Rn(e,n){let t=Y(e,n),i=n.said.trim(),o=t.catalog.candidates.filter(h=>We(h)||h.type==="panel"||h.type==="place"||h.type==="record").slice(0,32),r=yn(e),l=J(e),d=Q(e),a="",k=[],c=h=>h.flatMap(x=>o.filter(m=>m.id===x)).slice(0,3).map(x=>({candidate:x}));try{if(r){let h=await r.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}:{}}),x=h.usage?.inputTokens,m=h.usage?.outputTokens,u=h.usage?.costUsd??(x!==void 0?Oe(r.price,x,m??0):void 0);t.meter({tier:"thinking",model:r.model,...x!==void 0?{inputTokens:x}:{},...m!==void 0?{outputTokens:m}:{},...u!==void 0?{costUsd:u}:{}}),a=typeof h.text=="string"?h.text.trim():"",k=c(h.pick??[])}else if(l){let h=await V(l,gn,JSON.stringify({ask:i,about:t.entry.targetLabel,...n.follows?{follows:n.follows}:{},state:t.state,candidates:o.map(x=>({id:x.id,says:x.description}))}),t,t.meter);a=typeof h?.answer=="string"?h.answer.trim():"",k=c(Array.isArray(h?.pick)?h.pick:[])}else if(d&&o.length>0){let{question:h,of:x}=fe(o,`Which of these best answers, or acts on: ${i}`),m=await ce(d,{...t.state,asked:i,candidates:o.map(u=>({id:u.id,type:u.type,says:u.description}))},{answer:h},t.meter);k=ue(m.answer,x,3),a=k.length>0?`These fit \u201C${i}\u201D.`:""}else return M(t,i,"ask",X)}catch(h){return M(t,i,"ask",h instanceof Error?h.message:String(h))}if(!a&&k.length===0)return M(t,i,"ask","The AI had no answer to that here.");let f=t.usage.at(-1)?.model,g=k.flatMap(({candidate:h,confidence:x})=>{let m=le(h);return m?[{...m,...x!==void 0?{confidence:x}:{}}]:[]}),A=g.length>0?Z(n.store,{interaction:t.id,target:n.target,basis:i,...f?{model:f}:{},proposals:g},n.principal):void 0,$=k.map(({candidate:h})=>h).filter(h=>le(h)===void 0),b=[...$.map(h=>$e(h,k.find(x=>x.candidate===h)?.confidence)),...(A?.proposals??[]).map(h=>({id:h.id,type:h.field!==void 0?"fill":"act",label:h.label,...h.confidence!==void 0?{confidence:h.confidence}:{}}))];return{interaction:{...t.entry,ask:{kind:"ask",said:i},offered:b,outcome:"offered",...a?{answer:a}:{},usage:[...t.usage]},offers:$,...A&&A.proposals.length>0?{ghost:A}:{},...a?{answer:a}:{}}}function Z(e,n,t){let i=n.proposals.flatMap(o=>{try{let r=e.previewAll([o.call],{author:t}),l=r.ops.map(d=>d.intent).join("; ");return r.ops.length>0?[{...o,said:l||o.said}]:[]}catch{return[]}});return{...n,proposals:i}}function le(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 Qe(e,n,t){let i=n.proposals.filter(r=>t.ids===void 0||t.ids.includes(r.id));if(i.length===0)return{ok:!1,refused:"Nothing was chosen."};let o=i.flatMap(r=>r.confidence===void 0?[]:[r.confidence]);try{let l=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 l?{ok:!0,batch:l,accepted:i.map(d=>d.id)}:{ok:!1,refused:"That changes nothing now."}}catch(r){return{ok:!1,refused:r instanceof Error?r.message:String(r)}}}function Ye(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 Ve=e=>({...e,outcome:"dismissed"});var T=he(sn(),1);var S=he(De(),1);function Ze(e,n,t){let i=n.on==="selection"?n.ids:n.on==="record"||n.on==="field"?[n.id]:[],o=i.length>0?Je(e.store,i,{principal:e.principal,...i.length===1?{focus:i[0]}:{}}).affordances.map(r=>({mutation:r.mutation,label:r.label,args:r.args,open:r.open,why:r.why,...r.destructive?{destructive:!0}:{}})):void 0;return{store:e.store,target:n,principal:e.principal,interaction:Ce(),places:e.places,selection:e.selection,...o?{acts:o}:{},...e.place?{place:e.place}:{},...t?{said:t}:{}}}async function en(e,n,t){let i=await (__graviewPreload(import.meta.url,["./chunk.VMGWYCXU.js","./chunk.G4JJXA63.js","./chunk.LAF6GTBN.js","./chunk.QU356VB2.js","./chunk.ZSW74NVJ.js","./chunk.ZE4CTZQ3.js","./chunk.Q5WEOX3Q.js","./chunk.DMNXYMLC.js","./chunk.2YGQVI6T.js","./chunk.HPD5ZDZH.js","./chunk.WVUJXDXZ.js","./chunk.52QAIGCD.js","./chunk.PPUAPAWR.js","./chunk.IHFNLKXV.js","./chunk.577PGFUT.js","./chunk.FBY5IUGU.js","./chunk.4K5QCJFH.js","./chunk.Z7ZCR4LN.js","./chunk.RIW7SQH4.js","./chunk.FSAHO3LV.js","./chunk.X7W27IRI.js","./chunk.AJZBJBMO.js"]),import("./chunk.ZFWV4JAJ.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?.(),nn()}function nn(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(()=>nn(e-1))}async function ee(e,n,t,i,o){let r=Ze(e,t,i),l=n==="suggest"?await qe(e.ai,r):n==="fill"?await ze(e.ai,r):n==="record"?await _e(e.ai,r):await Ke(e.ai,r);if(l.interaction.outcome==="failed")return n!=="suggest"&&e.desk.record(l.interaction),l;let d=a=>{let k={...l.interaction,outcome:"failed",failed:a};return e.desk.record(k),{...l,interaction:k}};if(n==="fill"||n==="record"){if(!l.ghost||l.ghost.proposals.length===0)return d("Nothing here could be filled in.");o?.(),e.desk.setGhost({ghost:l.ghost}),e.desk.record(l.interaction)}if(n==="panel"&&l.panel){let a=await en(e,l.panel,o);if(a)return d(a);e.desk.record(l.interaction)}return l}var Te=new WeakMap,hn=64,Xe=new WeakMap;function mn(e){let n=Xe.get(e);if(!n){let t=n={n:0};Xe.set(e,t),e.subscribe(()=>void(t.n+=1))}return n.n}var tn=(e,n)=>{let t=K(n);return t.length>0?t.map(i=>e.graph.getNode(i)):[mn(e)]},on=(e,n)=>JSON.stringify({target:n,seat:e.principal}),rn=(e,n,t)=>{let i=tn(e.store,n);return t.schema===e.store.schema&&t.ai===e.ai&&i.length===t.depends.length&&i.every((o,r)=>o===t.depends[r])};function kn(e,n){let t=Te.get(e.store)?.get(on(e,n));return t?.result!==void 0&&rn(e,n,t)?t.result:void 0}function bn(e,n){let t=Te.get(e.store);t||Te.set(e.store,t=new Map);let i=on(e,n),o=t.get(i);if(o&&rn(e,n,o))return o.result?Promise.resolve(o.result):o.asked;let r=ee(e,"suggest",n),l={schema:e.store.schema,ai:e.ai,depends:tn(e.store,n),asked:r};t.delete(i),t.set(i,l),t.size>hn&&t.delete(t.keys().next().value);let d=t;return r.then(a=>{a.interaction.outcome!=="failed"?l.result=a:d.get(i)===l&&d.delete(i)}),r}async function An(e,n,t,i){let o=n.interaction,r=le(t);if(r){let l=o.usage?.at(-1)?.model,d=o.offered.find(k=>k.id===t.id)?.confidence,a=Z(e.store,{interaction:o.id,target:o.target,basis:`${o.ask.said}: ${t.label}`,...l?{model:l}:{},proposals:[{...r,...d!==void 0?{confidence:d}:{}}]},e.principal);if(a.proposals.length===0){let k="That can't be done now.";return e.desk.record({...o,outcome:"failed",failed:k}),k}i?.(),e.desk.setGhost({ghost:a}),e.desk.record(o);return}if(t.type==="panel"){let l=t.label,d={title:l,recipe:{...t.panel,title:l}},a=await en(e,d,i);return e.desk.record(a?{...o,outcome:"failed",failed:a}:{...o,outcome:"drawn",accepted:[t.id],panel:d}),a}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 Fn(e,n){if(n.ask.kind==="ask")return ke(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 ee(e,t,n.target,n.ask.said)}var B={padding:"5px 10px",fontSize:"0.875rem",borderRadius:8,width:"100%",textAlign:"left",borderWidth:1,borderStyle:"solid",borderColor:"transparent",background:"none",boxShadow:"none"},pe={margin:0,padding:"4px 10px",fontSize:"0.8125rem",color:"var(--graview-ink-muted)"};function Gn({target:e,close:n}){let t=Le(),i=(0,T.useMemo)(()=>Fe(e,y=>t.store.graph.has(y)),[e,t.store]),o=(0,T.useMemo)(()=>{let y=Ze(t,i);return de(t.store,i,{principal:t.principal,places:t.places,...y.acts?{acts:y.acts}:{}})},[t,i]),r=o.candidates.some(y=>y.type==="fill"),l=o.candidates.some(y=>y.type==="panel"),d=(0,T.useMemo)(()=>new Set(t.store.allMutations().filter(y=>(y.creates??[]).length>0).map(y=>y.name)),[t.store]),a=J(t.ai)!==void 0&&o.candidates.some(y=>y.type==="act"&&y.asks.length>0&&d.has(y.mutation)),k=Be(t.ai),c=kn(t,i),f=JSON.stringify(i),[g,A]=(0,T.useState)(!1),[$,b]=(0,T.useState)(null),[h,x]=(0,T.useState)(k&&c===void 0);(0,T.useEffect)(()=>{if(c!==void 0||!(k||g))return;let y=!0;return x(!0),bn(t,i).then(O=>{y&&(b(O),x(!1))}),()=>{y=!1}},[f,g]);let m=c??$,u=m?.interaction.outcome==="failed"?m.interaction.failed??"The AI could not suggest anything here.":null,v=(0,T.useRef)(!1),P=(0,T.useRef)(null);(0,T.useLayoutEffect)(()=>{m===null||!v.current||(v.current=!1,P.current?.querySelector("button")?.focus())},[m]);let W=(0,T.useRef)(!0);(0,T.useEffect)(()=>()=>{W.current=!1},[]);let[q,z]=(0,T.useState)(!1),[ne,s]=(0,T.useState)(null),p=y=>{if(q)return;z(!0),s(null);let O=!1;y(()=>{O=!0,n()}).then(w=>{W.current&&(z(!1),w?s(w):O||n())},w=>{W.current&&(z(!1),s(w instanceof Error?w.message:String(w)))})},C=y=>y.interaction.outcome==="failed"?y.interaction.failed??"The AI could not do that here.":void 0;return(0,S.jsxs)("div",{ref:P,"data-testid":"inline-ai",style:{display:"grid",gap:2},children:[h&&!g?(0,S.jsx)("p",{role:"status","data-testid":"inline-ai-thinking",style:pe,children:"Thinking\u2026"}):q?(0,S.jsx)("p",{role:"status","data-testid":"inline-ai-asking",style:pe,children:"Asking\u2026"}):ne?(0,S.jsx)("p",{role:"alert","data-testid":"inline-ai-failed",style:{...pe,color:"var(--graview-warn)"},children:ne}):u?(0,S.jsx)("p",{role:"status",style:pe,children:u}):null,(0,S.jsxs)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:2},children:[(m?.offers??[]).map(y=>(0,S.jsx)("li",{children:(0,S.jsxs)("button",{type:"button","data-menu-item":`ai-offer:${y.id}`,"data-ai-offer":y.id,"data-ai-offer-type":y.type,onClick:()=>p(O=>An(t,m,y,O)),style:B,children:[y.label,(0,S.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",y.type==="panel"?"a panel":y.type==="place"?"go there":y.type==="record"?"open it":"suggested"]})]})},y.id)),!k&&m===null?(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":"ai-suggest","aria-disabled":g||void 0,onClick:y=>{g||(v.current=document.activeElement===y.currentTarget,A(!0))},style:B,children:g?"Thinking\u2026":"Suggest\u2026"})}):null,r?(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":"ai-fill",onClick:()=>p(async y=>C(await ee(t,"fill",i,"Fill in",y))),style:B,children:"Fill in with AI"})}):null,a?(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":"ai-record",onClick:()=>p(async y=>C(await ee(t,"record",i,"Add one",y))),style:B,children:"Add one with AI"})}):null,l?(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":"ai-panel",onClick:()=>p(async y=>C(await ee(t,"panel",i,"Draw a panel",y))),style:B,children:"Draw a panel"})}):null,(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":"ai-ask",onClick:()=>{let y=document.activeElement;n(),ke(t.desk,{target:i,returnTo:y instanceof HTMLElement&&y!==document.body?y:null})},style:B,children:"Ask about this\u2026"})})]})]})}var ye={display:"inline-flex",alignItems:"center",minHeight:28,padding:"2px 10px",fontSize:"0.8125rem",borderRadius:8};function Bn({placement:e="picture"}){let{store:n,principal:t,aiDesk:i}=He(),o=Ne(n,t),{ghost:r,entries:l}=je(i),[d,a]=(0,T.useState)(new Set);(0,T.useEffect)(()=>a(new Set),[r?.ghost.interaction]);let k=(0,T.useRef)(null),c=(0,T.useRef)(null),f=r?.batch;if((0,T.useEffect)(()=>{f!==void 0&&c.current?.focus()},[f]),!r)return null;let{ghost:g}=r,A=l.find(u=>u.id===g.interaction),$=()=>{let u=g.target.on==="record"||g.target.on==="field"?g.target.id:void 0,v=k.current?.closest("[data-graview-face], main")?.parentElement??document,P=(u?v.querySelector(`[data-graview-view="${CSS.escape(u)}"][tabindex]`):null)??document.querySelector("[data-graview-page-title]")??k.current?.closest("main")??document.querySelector("main");P&&!P.hasAttribute("tabindex")&&P.setAttribute("tabindex","-1"),P?.focus({preventScroll:!0}),i.setGhost(null)},b=g.proposals.filter(u=>!d.has(u.id)).map(u=>u.id),h=()=>{let u=Qe(o,g,{author:t,ids:b});if(!u.ok){i.setGhost({...r,refused:u.refused});return}A&&i.record(Ye(A,u.accepted,u.batch)),i.setGhost({ghost:g,batch:u.batch,took:u.accepted.length,...r.onCard?{onCard:!0}:{}})},x=()=>{A&&r.batch===void 0&&i.record(Ve(A)),$()},m=()=>{if(r.batch!==void 0)try{o.undo(r.batch,{author:t}),$()}catch(u){i.setGhost({...r,refused:u instanceof Error?u.message:String(u)})}};return(0,S.jsxs)("section",{ref:k,"data-testid":"ai-ghost","data-interaction":g.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:Ee("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,S.jsx)("p",{style:{margin:0,color:"var(--graview-ink-muted)"},children:r.batch!==void 0?`Done: ${r.took===1?"one change":`${r.took} changes`}, as one.`:`Proposed by AI \xB7 ${g.basis}`}),r.batch===void 0?(0,S.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:4},children:g.proposals.map(u=>(0,S.jsx)("li",{"data-ghost-proposal":u.id,children:(0,S.jsxs)("label",{style:{display:"flex",alignItems:"baseline",gap:8,cursor:"pointer"},children:[(0,S.jsx)("input",{type:"checkbox",checked:!d.has(u.id),onChange:v=>{let P=new Set(d);v.target.checked?P.delete(u.id):P.add(u.id),a(P)}}),(0,S.jsx)("span",{style:{fontStyle:"italic",color:"var(--graview-ink)"},children:u.said}),u.confidence!==void 0?(0,S.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[Math.round(u.confidence*100),"% sure"]}):null]})},u.id))}):null,r.refused?(0,S.jsx)("p",{role:"alert",style:{margin:0,color:"var(--graview-warn)"},children:r.refused}):null,(0,S.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:r.batch===void 0?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("button",{type:"button","data-testid":"ghost-accept",disabled:b.length===0,onClick:h,style:ye,children:b.length===g.proposals.length?"Accept":`Accept ${b.length} of ${g.proposals.length}`}),(0,S.jsx)("button",{type:"button","data-testid":"ghost-dismiss",onClick:x,style:ye,children:"Dismiss"})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("button",{type:"button",ref:c,"data-testid":"ghost-undo",onClick:m,style:ye,children:"Undo"}),(0,S.jsx)("button",{type:"button","data-testid":"ghost-close",onClick:$,style:ye,children:"Close"})]})})]})}export{Fe as a,K as b,de as c,fn as d,Rn as e,Ze as f,en as g,ee as h,kn as i,bn as j,An as k,Fn as l,Gn as m,Bn as n};