graview 0.1.45 → 0.1.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/dist/preview/{chunk.2YABX3SC.js → chunk.3MMLRSRC.js} +1 -1
  2. package/dist/preview/{chunk.FOFLD64U.js → chunk.3OSGN463.js} +1 -1
  3. package/dist/preview/{chunk.E37V2EJM.js → chunk.3VFYSXMQ.js} +1 -1
  4. package/dist/preview/chunk.4OGOTHRD.js +1 -0
  5. package/dist/preview/{chunk.W2RCWPLK.js → chunk.4Y6VGQVQ.js} +1 -1
  6. package/dist/preview/{chunk.JDMXZFSG.js → chunk.5ESCD57M.js} +1 -1
  7. package/dist/preview/{chunk.F6HMZL65.js → chunk.5K6KX3UC.js} +1 -1
  8. package/dist/preview/{chunk.L24FCXZ7.js → chunk.6BDM2XRX.js} +1 -1
  9. package/dist/preview/{chunk.JR7RDOEP.js → chunk.6OPI4WWO.js} +1 -1
  10. package/dist/preview/{chunk.FPASZ4RD.js → chunk.6QYJ2K6K.js} +1 -1
  11. package/dist/preview/{chunk.UY7IOVR6.js → chunk.6SOUQNXR.js} +1 -1
  12. package/dist/preview/{chunk.BGYY55VO.js → chunk.6WA6ASQB.js} +1 -1
  13. package/dist/preview/chunk.6YD2DLIC.js +1 -0
  14. package/dist/preview/{chunk.E4G6DXSB.js → chunk.A5VGTO3E.js} +1 -1
  15. package/dist/preview/{chunk.CBUSFM3E.js → chunk.AGIO2GRV.js} +29 -7
  16. package/dist/preview/{chunk.C2UFMFJ3.js → chunk.AQQZY6OY.js} +1 -1
  17. package/dist/preview/{chunk.EAUVEVVO.js → chunk.ATDU5Y7V.js} +1 -1
  18. package/dist/preview/{chunk.5EDA3JHU.js → chunk.AYA7SYIU.js} +1 -1
  19. package/dist/preview/{chunk.FTM64IDI.js → chunk.BAMPYMUE.js} +1 -1
  20. package/dist/preview/{chunk.ZJ2VS4M4.js → chunk.BCWPV4WR.js} +1 -1
  21. package/dist/preview/{chunk.4XOWRYRU.js → chunk.BFKV4GKP.js} +6 -6
  22. package/dist/preview/{chunk.W44VRHKS.js → chunk.CICGAEBW.js} +2 -2
  23. package/dist/preview/{chunk.DQHPEKWK.js → chunk.DEUTHHGI.js} +1 -1
  24. package/dist/preview/{chunk.KBHU54NM.js → chunk.EAJB2PJZ.js} +1 -1
  25. package/dist/preview/{chunk.LSLLKICK.js → chunk.EPUBSKKL.js} +1 -1
  26. package/dist/preview/{chunk.6USUVORO.js → chunk.F37DHXA2.js} +1 -1
  27. package/dist/preview/{chunk.BS2SJC2P.js → chunk.F5PBK4TF.js} +2 -2
  28. package/dist/preview/{chunk.EVW5YY3W.js → chunk.FGR7KCI6.js} +1 -1
  29. package/dist/preview/{chunk.6SWW6KEV.js → chunk.FO5BOBYV.js} +1 -1
  30. package/dist/preview/{chunk.II7VTGNC.js → chunk.FVOJCVRX.js} +1 -1
  31. package/dist/preview/{chunk.T7XH7FVJ.js → chunk.FXTBMW3S.js} +1 -1
  32. package/dist/preview/{chunk.7ZRFXI73.js → chunk.HBD7FBZS.js} +1 -1
  33. package/dist/preview/chunk.HZCA3UWJ.js +1 -0
  34. package/dist/preview/{chunk.6SJA4FSW.js → chunk.I3GP5JW7.js} +1 -1
  35. package/dist/preview/{chunk.L3FOLN3K.js → chunk.IJABD7SI.js} +1 -1
  36. package/dist/preview/{chunk.HWCHFQ7O.js → chunk.ITYQUSZI.js} +1 -1
  37. package/dist/preview/chunk.JF3GD4H5.js +50 -0
  38. package/dist/preview/{chunk.7KVWV577.js → chunk.JLIUUFK2.js} +1 -1
  39. package/dist/preview/{chunk.GER2XRD4.js → chunk.JNIGZEOF.js} +1 -1
  40. package/dist/preview/{chunk.CSDERNQV.js → chunk.JQLR6KO2.js} +1 -1
  41. package/dist/preview/{chunk.FHZBXMXR.js → chunk.JT3IZIU5.js} +1 -1
  42. package/dist/preview/{chunk.OF34OZ4V.js → chunk.KSXB4LDF.js} +1 -1
  43. package/dist/preview/{chunk.LEO2KWLZ.js → chunk.LETJC5TD.js} +1 -1
  44. package/dist/preview/{chunk.5O5IJVLN.js → chunk.LKN734RR.js} +1 -1
  45. package/dist/preview/{chunk.HGTPTRMM.js → chunk.LKVXSC5O.js} +1 -1
  46. package/dist/preview/{chunk.ICGNIK3Z.js → chunk.LUNATPAB.js} +2 -2
  47. package/dist/preview/{chunk.VSAPJAT3.js → chunk.LVEFQLGQ.js} +1 -1
  48. package/dist/preview/{chunk.KUUDW7VR.js → chunk.MWONSI3P.js} +1 -1
  49. package/dist/preview/{chunk.WPOTEXJZ.js → chunk.N7VNEUJR.js} +1 -1
  50. package/dist/preview/{chunk.FF6DBQMB.js → chunk.NGIPVTTE.js} +1 -1
  51. package/dist/preview/{chunk.2LKMNEWZ.js → chunk.NITU5H4J.js} +1 -1
  52. package/dist/preview/{chunk.DLFWBG33.js → chunk.NWA7Q6CI.js} +1 -1
  53. package/dist/preview/{chunk.L3FQZCWI.js → chunk.O24DD2VF.js} +1 -1
  54. package/dist/preview/{chunk.V5FIZIX2.js → chunk.OHSJQYJN.js} +1 -1
  55. package/dist/preview/chunk.ONEYVLC2.js +1 -0
  56. package/dist/preview/{chunk.URXSZQSF.js → chunk.P4O5DGLN.js} +1 -1
  57. package/dist/preview/{chunk.JSSFA3FC.js → chunk.PC6PID5X.js} +1 -1
  58. package/dist/preview/{chunk.5B2LH2SR.js → chunk.PLWVLW22.js} +1 -1
  59. package/dist/preview/{chunk.3NMINX5Z.js → chunk.R4OU7O6C.js} +1 -1
  60. package/dist/preview/{chunk.UM7GWXEW.js → chunk.RNBPDB37.js} +1 -1
  61. package/dist/preview/{chunk.ICCIZDTQ.js → chunk.RTI3FEDD.js} +1 -1
  62. package/dist/preview/{chunk.TBSNNOQU.js → chunk.RZXPBOGT.js} +1 -1
  63. package/dist/preview/{chunk.6KWFTSK4.js → chunk.SL2FZ54V.js} +1 -1
  64. package/dist/preview/{chunk.SDU76JU6.js → chunk.SS27NH5O.js} +1 -1
  65. package/dist/preview/{chunk.QPCSS322.js → chunk.T7O6K3IN.js} +1 -1
  66. package/dist/preview/{chunk.TOXWNEOQ.js → chunk.TFVFJFXC.js} +2 -2
  67. package/dist/preview/{chunk.2EFH63WS.js → chunk.TOZJZXWQ.js} +1 -1
  68. package/dist/preview/{chunk.ZEAH57AZ.js → chunk.UOXFALRL.js} +1 -1
  69. package/dist/preview/{chunk.K6KMLD2B.js → chunk.UPQZU7UO.js} +1 -1
  70. package/dist/preview/{chunk.ZBR2QY67.js → chunk.UR3XYOQ6.js} +1 -1
  71. package/dist/preview/{chunk.RPX35VYU.js → chunk.URO2EGY7.js} +1 -1
  72. package/dist/preview/{chunk.XMCFZD3A.js → chunk.UVNVDLV5.js} +1 -1
  73. package/dist/preview/chunk.V3QUTJR2.js +2 -0
  74. package/dist/preview/{chunk.SGKPGVBB.js → chunk.V5Z2OED6.js} +1 -1
  75. package/dist/preview/{chunk.FCAYURB4.js → chunk.VAFSSSSI.js} +1 -1
  76. package/dist/preview/{chunk.3HSPWSAI.js → chunk.VBPK6ARF.js} +1 -1
  77. package/dist/preview/{chunk.GIYFEGAP.js → chunk.VDVJCLGS.js} +1 -1
  78. package/dist/preview/{chunk.6X3G3PWL.js → chunk.W45NKVSV.js} +1 -1
  79. package/dist/preview/{chunk.66JF3UMG.js → chunk.WO3DDFFY.js} +1 -1
  80. package/dist/preview/{chunk.RYRTKIKB.js → chunk.WP5W44Y4.js} +1 -1
  81. package/dist/preview/{chunk.UJKT2G6M.js → chunk.WQONZBA3.js} +2 -2
  82. package/dist/preview/{chunk.GFLAGZSB.js → chunk.X233NILF.js} +1 -1
  83. package/dist/preview/{chunk.PRD3UNJX.js → chunk.X25KXCWI.js} +1 -1
  84. package/dist/preview/{chunk.6BJBPDF3.js → chunk.XSNAG4JT.js} +14 -4
  85. package/dist/preview/chunk.XXDBZQNY.js +18 -0
  86. package/dist/preview/{chunk.LNG3CQNI.js → chunk.Z5IGHCZX.js} +1 -1
  87. package/dist/preview/chunk.ZIEHF67C.js +1 -0
  88. package/dist/preview/index.html +27 -27
  89. package/dist/preview/page.js +2 -2
  90. package/package.json +6 -6
  91. package/dist/preview/chunk.B6KT6BTG.js +0 -49
  92. package/dist/preview/chunk.HZGVEHEN.js +0 -1
  93. package/dist/preview/chunk.J7G3AATY.js +0 -14
  94. package/dist/preview/chunk.K46YRA65.js +0 -1
  95. package/dist/preview/chunk.MGWMGLWE.js +0 -1
  96. package/dist/preview/chunk.OMZ3LDDN.js +0 -1
  97. package/dist/preview/chunk.OYHQSXNC.js +0 -1
  98. package/dist/preview/chunk.SZ34UAQ3.js +0 -2
@@ -0,0 +1,18 @@
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 zt,B as Ae,C as ro,D as ct,E as pe,F as Wn,G as De,H as Ue,I as oo,J as Kn,K as Re,L as io,M as so,N,O as pt,P as wt,Q as lo,R as vt,S as Qt,T as co,U as ee,V as Zt,W as ae,X as Bn,a as V,b as we,c as _,d as jt,e as Hn,f as In,g as dt,h as Z,i as he,j as ne,k as A,l as J,m as U,n as Ge,o as ve,p as _t,q as Se,r as ie,s as to,t as ht,u as no,v as Fn,w as Dn,x as z,y as Fe,z as ao}from"./chunk.JF3GD4H5.js";import{a as Ie}from"./chunk.UR3XYOQ6.js";import{a as Qe,b as Yt,d as Y}from"./chunk.ONEYVLC2.js";import{b as Nn,c as Jr,d as eo}from"./chunk.WQONZBA3.js";import{a as Qr,d as Zr,e as Xr}from"./chunk.UGFDSE37.js";import{a as Ur,c as Vr,f as jr,g as _r,i as zr,j as Yr}from"./chunk.NWA7Q6CI.js";import{a as Nr,b as Hr,c as Ir,d as On}from"./chunk.WP5W44Y4.js";import{b as Or}from"./chunk.M5GJHVWZ.js";import{a as Fr,b as Dr,d as qt,e as Wr,f as Kr,g as Br,j as Gt}from"./chunk.HZCA3UWJ.js";import{a as Ut,b as Vt}from"./chunk.PXQVXBNG.js";import{a as Ht,b as za,c as Ya,d as It,e as Qa}from"./chunk.6QYJ2K6K.js";import{b as ar,c as mr,e as fr,f as Tn}from"./chunk.3MMLRSRC.js";import{a as Ln,b as gr}from"./chunk.DQOCBKC3.js";import{a as Kt,b as Bt,c as Mr,e as Er}from"./chunk.EPUBSKKL.js";import{a as lt,b as pr,e as ur}from"./chunk.ATDU5Y7V.js";import{m as $r}from"./chunk.BCWPV4WR.js";import{a as hr,b as wr,c as vr,e as Tr,f as $n,h as Wt}from"./chunk.PKUDIWIF.js";import{d as br,e as xr,f as Pr,g as Cr,n as Ar,o as Rr,q as Lr,s as Dt}from"./chunk.VW2VCPJX.js";import{a as Mn}from"./chunk.UKAPFIPJ.js";import{a as An,b as tr,c as nr}from"./chunk.UT6642FC.js";import{a as yr}from"./chunk.IW7YFPGG.js";import{c as or,d as ir,e as sr,f as lr,j as yt,k as dr}from"./chunk.ZIEHF67C.js";import{a as rr}from"./chunk.UHX4WTM7.js";import{r as Rn,s as cr}from"./chunk.6MADC6DM.js";import{g as Ft}from"./chunk.HDRD33II.js";import{b as Za,c as Xa,d as Ja,e as er}from"./chunk.DX357TZ3.js";import{C as En,K as qr,N as Gr,e as ja,f as _a,j as Zo,u as Sr,v as kr}from"./chunk.XSNAG4JT.js";import{$ as oe,Ea as Va,G as He,L as Ha,N as Ia,Q as Fa,R as G,S as Cn,V as Da,W as Wa,_ as Ka,ca as Ba,da as qa,fa as Ga,ja as st,la as Ua,na as Ot,qa as Nt,r as Na,v as Ne}from"./chunk.XWAMQPUM.js";import{a as Oa}from"./chunk.SDO3U72B.js";import{$c as Ma,J as wa,U as ft,Vc as xn,Wb as Aa,Xa as xa,Za as Pa,Zb as Ra,_b as La,_c as Et,ba as it,bd as $t,ca as ce,ea as ze,fa as Tt,gb as bn,ha as qe,hb as Ca,ja as va,ka as Sa,kd as Pn,la as Ye,ld as Ea,qb as Mt,qd as $a,vc as Ta,wa as ka,xa as ba}from"./chunk.AS4CQBOQ.js";import{b as I}from"./chunk.AJZBJBMO.js";function po(e,t,n={}){let a=e.graph.getNode(t);if(!a)return;let r=e.schema.tryDefinition(a.kind),o=s=>ce(e.schema.tryDefinition(s.kind),s),l=new Map;for(let s of e.graph.allEdges()){let d=s.from===t?"out":s.to===t?"in":null;if(!d)continue;let c=d==="out"?s.to:s.from,p=e.graph.getNode(c);if(!p)continue;let w=(d==="out"?r:e.schema.tryDefinition(p.kind))?.edges?.[s.kind],g=d==="in"?w?.inverse??w?.description:w?.description,L=`${s.kind}|${d}|${g??""}`;(l.get(L)??(()=>{let x={edgeKind:s.kind,direction:d,...g?{description:g}:{},targets:[]};return l.set(L,x),x})()).targets.push({id:p.id,kind:p.kind,label:o(p)})}return{id:t,kind:a.kind,label:o(a),fields:Ja(yt(e.schema,e.graph,a),r),violations:bn(e.violations(n.context),[t]),actions:Mn(e,[t],{focus:t,...n.principal?{principal:n.principal}:{},...n.context?{context:n.context}:{}}),links:[...l.values()].map(s=>{let d=Za(s.targets.flatMap(c=>{let p=e.graph.getNode(c.id);return p?[p]:[]}),c=>e.schema.tryDefinition(c));return{...s,targets:[...s.targets].map(c=>d.has(c.id)?{...c,apart:d.get(c.id)}:c).sort((c,p)=>c.label.localeCompare(p.label))}})}}function Ze(e,t,n={}){return{kind:t,members:e.graph.nodesOfKind(t),actions:Mn(e,[],{kindSelection:[t],...n.principal?{principal:n.principal}:{},...n.context?{context:n.context}:{}})}}function uo(e,t){let n=(o,l)=>`${o}|${JSON.stringify(l)}`,a=new Map;for(let o of[...e.affordances,...e.withheld]){if(o.provider!=="invariant")continue;let l=n(o.mutation,o.args);a.has(l)||a.set(l,o.rank??Number.MAX_SAFE_INTEGER)}let r=Number.MAX_SAFE_INTEGER;return[...t].map((o,l)=>({repair:o,declared:l})).sort((o,l)=>(a.get(n(o.repair.mutation,o.repair.args??{}))??r)-(a.get(n(l.repair.mutation,l.repair.args??{}))??r)||o.declared-l.declared).map(o=>o.repair)}function Xe(e){let t=e.schema.kinds.map(r=>({kind:r,plural:qe(e.schema,r),count:e.graph.nodesOfKind(r).length})),n=new Map;for(let r of e.graph.allEdges()){let o=e.graph.getNode(r.from),l=e.graph.getNode(r.to);if(!o||!l)continue;let s=`${r.kind}|${o.kind}|${l.kind}`;n.set(s,(n.get(s)??0)+1)}let a=[];for(let{kind:r}of t){let o=e.schema.tryDefinition(r)?.edges??{};for(let[l,s]of Object.entries(o)){let d=s.to==="*"||s.to===void 0?(()=>{let c=[...n.keys()].filter(p=>p.startsWith(`${l}|${r}|`)).map(p=>p.split("|")[2]);return c.length>0?c:["*"]})():s.to;for(let c of d)a.push({edgeKind:l,from:r,to:c,...s.description?{description:s.description}:{},...s.inverse?{inverse:s.inverse}:{},count:n.get(`${l}|${r}|${c}`)??0})}}return{kinds:t,relations:a}}var We=I(He(),1);var St=I(He(),1);var Le=I(G(),1),Jo={problems:"Problems",search:"Search",map:"Connections",places:"Pictures","~draft":"A view drawn"},ei=e=>{try{return decodeURIComponent(e)}catch{return e}};function ti(e,t,n={}){let{store:a}=e,r=a.schema,o=(n.base??"").replace(/\/$/,""),[l="/",s=""]=t.split("#")[0].split("?"),d=(b,$,j)=>({label:b,href:`${o}${$}`,path:$,...j?{current:j}:{}}),c=b=>{let $=n.registry?.sectionOf(b);return $?[$.path===void 0?{label:$.label}:d($.label,$.path)]:[]},p=b=>n.registry?.sectionOf(b)?.label,S=b=>{let $=p(b);return $===void 0?{}:{section:$}},[w,g,...L]=l.split("/").filter(Boolean).map(ei);if(w===void 0)return{as:"home",label:"Home",trail:[d("Home","/",!0)]};if(w==="places"&&g!==void 0&&L.length===0){let b=new URLSearchParams(s).get("of"),$=new Set(Fe(a,e.principal)),j=e.views?.places()??[],C=j.find(D=>$.has(D.kind)&&D.as===g&&(!b||V(r,D.kind)===b));if(C){let D=jt(C.as,Et(C,j)?V(r,C.kind):void 0);return{as:"place",kind:C.kind,label:C.title,...S(C.kind),trail:[...c(C.kind),d(C.title,D,!0)]}}}let H=L.length===0?we(r,w):void 0;if(H!==void 0){let b=d(qe(r,H),`/${V(r,H)}`);if(g===void 0)return{as:"list",kind:H,label:b.label,...S(H),trail:[...c(H),{...b,current:!0}]};let $=a.graph.getNode(g),j=$&&$.kind===H?ce(r.tryDefinition(H),$):"Nothing lives here";return{as:"record",kind:H,id:g,label:j,...S(H),trail:[...c(H),b,d(j,_(r,H,g),!0)]}}let x=Jo[w]??ni((L.at(-1)??g??w).replace(/[-_]+/g," "));return{as:"page",label:x,trail:[d(x,l,!0)]}}var ni=e=>e.charAt(0).toUpperCase()+e.slice(1),qn=(0,St.createContext)(null);function ai(e){let t=pe(),n=ct("/");return Y(e.context.store),ti(e.context,`${t.pathname}${t.search}`,{registry:e.registry,base:n})}var ri={position:"absolute",width:1,height:1,margin:-1,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0},go={display:"flex",alignItems:"center",gap:6,minWidth:0},mo={display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,lineHeight:"24px"};function ut({context:e,style:t}){let n=(0,St.useContext)(qn),a=(0,St.useContext)(wt);return vt(a??ii,"trail")||n?.registry?.without().has("trail")?null:(0,Le.jsx)(oi,{root:n??{context:e,registry:void 0},context:e,...t?{style:t}:{}})}function oi({root:e,context:t,style:n}){let a=ai(e);return a.trail.length<2?null:(0,Le.jsx)(si,{here:a,mark:a.as==="record"?{kind:a.kind,context:t}:void 0,...n?{style:n}:{},"data-testid":"page-trail"})}var ii={count:()=>0,place:()=>()=>{},subscribe:()=>()=>{}};function si({here:e,mark:t,style:n,...a}){let r=e.as==="record"?e.trail.length-2:-1;return(0,Le.jsx)("nav",{"aria-label":"You are here","data-graview-trail":"",style:{minWidth:0,...n},...a,children:(0,Le.jsx)("ol",{style:{...he,listStyle:"none",padding:0,display:"flex",alignItems:"center",gap:6,minWidth:0,overflow:"hidden"},children:e.trail.map((o,l)=>(0,Le.jsxs)("li",{style:o.current?ri:{...go,flexShrink:l===e.trail.length-2?0:1,maxWidth:"100%"},...o.current?{"aria-current":"page"}:{},children:[l>0&&!o.current?(0,Le.jsx)("span",{"aria-hidden":"true",children:"\u203A"}):null,o.current?o.label:o.path!==void 0?(0,Le.jsxs)(N,{to:o.path,style:{...ve,...go},...l===r?{"data-testid":"trail-list"}:{},children:[l===r&&t?(0,Le.jsx)(ie,{kind:t.kind,brand:t.context.brand,schema:t.context.store.schema,size:8}):null,(0,Le.jsx)("span",{style:mo,children:o.label})]}):(0,Le.jsx)("span",{style:mo,children:o.label})]},`${l}:${o.label}`))})})}var R=I(G(),1);function Te(e){let t=e.views;if(!t)return[];let n=new Set(Fe(e.store,e.principal));return t.places().filter(a=>n.has(a.kind))}function Xt(e,t){if(!t.over)return[t.kind];let n=new Set(Fe(e.store,e.principal));return t.over.filter(a=>a===t.kind||n.has(a))}var Je=e=>`place:${e.kind}:${e.as}`;function ue(e,t){return jt(t.as,Et(t,e.views?.places()??[])?V(e.store.schema,t.kind):void 0)}function kt(e,t){let n=e.schema.tryDefinition(t);return e.graph.nodesOfKind(t).filter(a=>it(n,a))}function Gn(e,t,n){let a=(o,l)=>Tt(e.schema,l,o),r=(typeof t=="string"?[t]:t).map(o=>a(kt(e,o).length,o)).join(" and ");return n?`${r} across ${a(kt(e,n).length,n)}`:r}function Un({context:e,place:t,chosen:n,filter:a}){let{store:r,views:o,invariantContext:l}=e,d=o?.resolve(t.kind,{cardinality:"many",fidelity:"full"},t.as)?.view,c=[...new Set(r.violations(l).flatMap(w=>w.nodeIds))],p=Xt(e,t).flatMap(w=>kt(r,w));if(!d)return null;let S=li(r,p,a,c);return(0,R.jsx)(Rn,{kind:t.kind,view:t.title,children:(0,R.jsx)(d,{nodes:S,label:t.title,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1,...n&&n.length>0?{implicated:n}:{},...c.length>0?{flagged:c}:{}})})}function li(e,t,n,a){let r=n?$t({filter:n}).filter??[]:[];return r.length===0?t:Wt(t,{filter:r},{schema:e.schema,graph:e.graph,flagged:new Set(a)}).nodes}function di({store:e,views:t,as:n,invariantContext:a}){Y(e);let r={store:e,views:t,...a?{invariantContext:a}:{}},o=t.places().find(l=>l.as===n);return o?(0,R.jsx)(Un,{context:r,place:o}):null}function ci({context:e,kind:t}){let{store:n,views:a,invariantContext:r}=e,o=kt(n,t),l=n.schema.tryDefinition(t),s=z(n,t),c=a?.resolve(t,{cardinality:"many",fidelity:"full"})?.view,p=[...new Set(n.violations(r).flatMap(L=>L.nodeIds))];if(c&&!st(c))return(0,R.jsx)(Rn,{kind:t,children:(0,R.jsx)(c,{nodes:o,label:s,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1,...p.length>0?{flagged:p}:{}})});let S=a?.resolve(t,{cardinality:"one",fidelity:"summary"})?.view,w=8,g=o.slice(0,w);return(0,R.jsxs)("div",{"data-testid":"kind-sheet",style:S?{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:[g.map(L=>S?(0,R.jsx)(S,{node:L,fidelity:"summary",cardinality:"one",mode:"fullscreen",selected:!1,...p.includes(L.id)?{flagged:[L.id]}:{}},L.id):(0,R.jsx)("span",{style:{padding:"8px 14px",borderRadius:8,border:"1px solid var(--graview-edge-bright)",background:"var(--graview-ground)",color:"var(--graview-ink)"},children:ce(l,L)},L.id)),o.length>w?(0,R.jsxs)("span",{style:{...A,alignSelf:"center",padding:"0 6px"},children:["+",o.length-w," more ",s.toLowerCase()]}):null]})}function Vn(e){let{store:t}=e,n=ao(e),a=Te(e),r=e.views?.arrangement?.()?.order??[],o=d=>{let c=d.name===void 0?-1:r.indexOf(`view:${d.name}`);return c>=0?c-r.length:n.indexOf(d.kind)},l=xn([...a].sort((d,c)=>o(d)-o(c))).filter(d=>!d.hidden),s=new Set(l.flatMap(d=>d.over??[d.kind]));return[...l.map(d=>({key:Je(d),kind:d.kind,title:Ma(d,a,t.schema),to:ue(e,d),place:d})),...zt(e).filter(d=>!s.has(d)).map(d=>({key:`kind:${d}`,kind:d,title:z(t,d),to:`/${V(t.schema,d)}`}))]}var fo=.72,pi=540,yo=16/10;function ui(e){let t=(0,We.useRef)(null),[n,a]=(0,We.useState)(e);return(0,We.useLayoutEffect)(()=>{let r=t.current;if(!r||typeof ResizeObserver>"u")return;let o=()=>{let s=r.getBoundingClientRect().width;s>0&&a(d=>Math.abs(d-s)<.5?d:s)};o();let l=new ResizeObserver(o);return l.observe(r),()=>l.disconnect()},[]),{ref:t,width:n}}function gi(e){for(let t=e.parentElement;t;t=t.parentElement)if(/(auto|scroll)/.test(getComputedStyle(t).overflowY))return t;return null}function mi(e){let[t,n]=(0,We.useState)(()=>typeof IntersectionObserver>"u");return(0,We.useLayoutEffect)(()=>{let a=e.current;if(t||!a)return;let r=new IntersectionObserver(o=>{o.some(l=>l.isIntersecting)&&(r.disconnect(),n(!0))},{root:gi(a),rootMargin:"50% 0px"});return r.observe(a),()=>r.disconnect()},[t,e]),t}function jn({context:e,entry:t}){let{store:n,brand:a,principal:r}=e,{ref:o,width:l}=ui(pi),s=mi(o),d=l/fo,c=kt(n,t.kind),p=n.schema.tryDefinition(t.kind),S=c.length===0?Ze(n,t.kind,{...r?{principal:r}:{},...e.invariantContext?{context:e.invariantContext}:{}}).actions.affordances[0]:void 0,w=t.place!==void 0;return(0,R.jsxs)(N,{to:t.to,"data-testid":w?"place-card":"kind-card",className:"graview-gallery-card",style:{...ve,display:"grid",gap:10,alignContent:"start",minWidth:0},children:[(0,R.jsxs)("span",{ref:o,"data-testid":w?"place-picture":"kind-picture","aria-hidden":"true",inert:!0,style:{display:"block",position:"relative",width:"100%",aspectRatio:`${yo}`,overflow:"hidden",borderRadius:12,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",pointerEvents:"none"},children:[(0,R.jsx)("span",{style:{position:"absolute",left:0,top:0,width:d,height:d/yo,display:"grid",gridTemplateRows:"minmax(0, 1fr)",transform:`scale(${fo})`,transformOrigin:"0 0"},children:s?(0,R.jsx)(qt.Provider,{value:null,children:t.place?(0,R.jsx)(Un,{context:e,place:t.place}):(0,R.jsx)(ci,{context:e,kind:t.kind})}):null}),c.length===0?(0,R.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,R.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,R.jsxs)("span",{style:{fontFamily:In,fontWeight:"var(--graview-weight-display)"},children:["No ",z(n,t.kind).toLowerCase()," yet"]}),S?(0,R.jsxs)("span",{style:A,children:["Begin with \u201C",S.label,"\u201D"]}):null]})}):null]}),(0,R.jsxs)("span",{style:{display:"grid",gap:2,minWidth:0},children:[(0,R.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[w?null:(0,R.jsx)(ie,{kind:t.kind,brand:a,schema:n.schema,size:8}),(0,R.jsx)("span",{style:{fontFamily:In,fontSize:"var(--graview-text-heading)",fontWeight:"var(--graview-weight-display)",lineHeight:1.3,overflowWrap:"anywhere",textWrap:"balance"},children:t.title})]}),(0,R.jsxs)("span",{style:A,children:[t.place?Gn(n,Xt(e,t.place),t.place.across):Gn(n,t.kind),!w&&p?.description?` \xB7 ${p.description}`:null]})]})]})}var ho={display:"grid",gap:"32px 28px",gridTemplateColumns:"repeat(auto-fill, minmax(min(420px, 100%), 1fr))"},fi=`
2
+ .graview-gallery-card > span:first-child { transition: border-color 160ms ease, box-shadow 160ms ease; }
3
+ .graview-gallery-card:hover > span:first-child,
4
+ .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); }
5
+ `;function _n({context:e}){Y(e.store);let t=Vn(e);return t.length===0?null:(0,R.jsxs)("section",{style:ho,"data-testid":"gallery",children:[(0,R.jsx)("style",{children:fi}),t.map(n=>(0,R.jsx)(jn,{context:e,entry:n},n.key))]})}function zn({context:e}){let{store:t}=e;Y(t);let n=xn(Te(e)).filter(r=>!r.hidden),a=Vn(e);return(0,R.jsxs)(ee,{context:e,style:dt,children:[(0,R.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,R.jsx)("p",{style:he,children:n.length===0?"None of its own yet":`${n.length} ${n.length===1?"picture":"pictures"}`}),(0,R.jsx)(ae,{context:e,children:"Pictures"}),(0,R.jsx)("p",{style:ne,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,R.jsx)("div",{style:ho,"data-testid":"places",children:a.map(r=>(0,R.jsx)(jn,{context:e,entry:r},r.key))}):null]})}var yi={lede:!0},hi={lede:!1},wi={...ne,textWrap:"pretty"};function vi(e,t){if(t===void 0)return;let[n]=lr(sr([t]),dr(e.store,null,null,e.brand?{money:e.brand}:{}));return n?.t==="headline"&&!n.problem&&n.text.trim()!==""?n.text:void 0}function Yn({context:e}){let{store:t,principal:n}=e;Y(t);let a=Ue(),r=De(),[o]=pt(),l=decodeURIComponent(a.as??""),[s,d]=(0,We.useState)(null),c=o.get("of"),p=o.get("filter"),w=Te(e).find(C=>C.as===l&&(!c||V(t.schema,C.kind)===c));if(!w)return(0,R.jsxs)(ee,{context:e,children:[(0,R.jsx)(ae,{context:e,children:"No picture is called that."}),(0,R.jsx)("p",{style:ne,children:(0,R.jsx)(N,{to:"/places",style:Ge,children:(0,R.jsx)(Qe,{children:"The pictures there are"})})})]});let g=z(t,w.kind),L=e.views?.resolve(w.kind,{cardinality:"many",fidelity:"full"},w.as)?.view,H=L?.flows===!0,x=L?.creates!==!1,b=vi(e,L?.lede),$=Ze(t,w.kind,{...n?{principal:n}:{},...e.invariantContext?{context:e.invariantContext}:{}}),j=x?$.actions.affordances.map(C=>({affordance:C,mutation:t.allMutations().find(D=>D.name===C.mutation)})).filter(C=>C.mutation!==void 0):[];return(0,R.jsxs)(ee,{context:e,style:{...dt,gap:"var(--graview-space-6, 32px)"},children:[(0,R.jsxs)("header",{style:{display:"grid",gap:"var(--graview-space-2, 8px)"},children:[(0,R.jsx)(ut,{context:e}),(0,R.jsx)(ae,{context:e,children:w.title}),(0,R.jsx)("p",{style:wi,"data-testid":"place-lede",...b!==void 0?{"data-graview-lede":"headline"}:{},children:b??`${Gn(t,Xt(e,w),w.across)}.`}),p&&!H?(0,R.jsxs)("p",{style:{...A,margin:0},"data-testid":"place-narrowed",children:[`Only those where ${p.split(",").map(C=>C.replace(":"," is ")).join(" and ")}. `,(0,R.jsx)(N,{to:`?${(()=>{let C=new URLSearchParams(o);return C.delete("filter"),C.toString()})()}`,style:{...U,...A},children:"Show all"})]}):null,(0,R.jsx)("p",{style:{...A,margin:0,display:"flex",flexWrap:"wrap",gap:"4px 16px"},children:Xt(e,w).map((C,D)=>(0,R.jsx)(N,{to:`/${V(t.schema,C)}`,style:{...Ge,...A},...D===0?{"data-testid":"place-as-list"}:{},children:(0,R.jsxs)(Qe,{children:["All ",(C===w.kind?g:z(t,C)).toLowerCase()," as a list"]})},C))})]}),(0,R.jsx)("div",{"data-testid":"place-lens","data-flows":H?"":void 0,style:H?{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:C=>{let D=C.target?.closest("[data-graview-pick]"),le=D?.getAttribute("data-graview-pick"),be=D?.getAttribute("data-graview-joins");if(be)try{let X=JSON.parse(be);if(Array.isArray(X)&&X.every(de=>typeof de=="string")){C.preventDefault(),d({at:Je(w),ids:X});return}}catch{}if(!le)return;let fe=t.graph.getNode(le);fe&&(C.preventDefault(),r(_(t.schema,fe.kind,le)))},children:(0,R.jsx)(Br.Provider,{value:b!==void 0?yi:hi,children:(0,R.jsx)(Un,{context:e,place:w,filter:p,...s?.at===Je(w)?{chosen:s.ids}:{}})})}),j.length>0?(0,R.jsx)("div",{style:{maxWidth:760,display:"grid",gap:40},"data-testid":"place-creators",children:j.map(({affordance:C,mutation:D})=>(0,R.jsxs)("section",{style:{...J,display:"grid",gap:14},children:[(0,R.jsx)("h2",{style:Z,children:D.title??D.name}),D.description?(0,R.jsx)("p",{style:{...A,margin:0,maxWidth:"58ch"},children:D.description}):null,(0,R.jsx)(Ie,{store:t,mutation:D,prefilled:C.args,open:C.open,label:C.label,...n?{principal:n}:{}})]},C.id))}):null]})}function Si(e,t=document){let n=Ut(e);if(!n)return null;let a=[t,...[...t.querySelectorAll("[data-worker-view]")].flatMap(r=>r.shadowRoot?[r.shadowRoot]:[])];for(let r of a)for(let o of r.querySelectorAll("[id], [data-section]")){let l=o.getAttribute("data-section")??o.id;if(l===e||Ut(l)===n)return o}for(let r of a)for(let o of r.querySelectorAll("h1, h2, h3, h4, h5, h6, [role=heading]"))if(Ut(o.textContent??"")===n)return o;return null}function wo(e,t={}){if(typeof document>"u"||typeof requestAnimationFrame>"u")return()=>{};let n=t.frames??120,a=0,r=()=>{let o=Si(e,t.root??document);if(o){o.hasAttribute("tabindex")||o.setAttribute("tabindex","-1"),o.scrollIntoView?.({block:"start"}),o.focus({preventScroll:!0});return}n-=1,n>0&&(a=requestAnimationFrame(r))};return a=requestAnimationFrame(()=>{a=requestAnimationFrame(r)}),()=>cancelAnimationFrame(a)}var q=I(He(),1);var Jt=I(He(),1);var et=I(G(),1);function vo({context:e}){return oe()?(0,et.jsxs)(et.Fragment,{children:[(0,et.jsx)(ki,{context:e}),(0,et.jsx)(Vr,{face:"pages",on:e.quickAsk??!0})]}):null}function ki({context:e}){let{store:t}=e,n=oe(),{pathname:a}=pe(),r=(0,Jt.useRef)(n?.setSelection);return r.current=n?.setSelection,(0,Jt.useEffect)(()=>{let o=r.current;if(!o)return;let[,l,s]=a.split("/"),d=(()=>{if(l==="places"){let p=e.views?.places().find(S=>S.as===decodeURIComponent(s??""));return p?[Ne(p.kind)]:[]}let c=l?we(t.schema,l):void 0;return c&&s?[decodeURIComponent(s)]:c?[Na(c)]:[]})();o(c=>c.length===d.length&&c.every((p,S)=>p===d[S])?c:d)},[a]),null}var ge=I(He(),1);var ko=I(Zo(),1);var se=I(G(),1);var bi=(0,ge.lazy)(Nt(Oa(()=>(__graviewPreload(import.meta.url,["./chunk.ONEYVLC2.js","./chunk.WQONZBA3.js","./chunk.UGFDSE37.js","./chunk.NWA7Q6CI.js","./chunk.WP5W44Y4.js","./chunk.M5GJHVWZ.js","./chunk.HZCA3UWJ.js","./chunk.JBW3DI7E.js","./chunk.AGIO2GRV.js","./chunk.NIVTK2W5.js","./chunk.6QYJ2K6K.js","./chunk.3MMLRSRC.js","./chunk.DQOCBKC3.js","./chunk.OHSJQYJN.js","./chunk.DEUTHHGI.js","./chunk.EPUBSKKL.js","./chunk.ATDU5Y7V.js","./chunk.AQQZY6OY.js","./chunk.BCWPV4WR.js","./chunk.Y5ARSVH4.js","./chunk.PKUDIWIF.js","./chunk.VW2VCPJX.js","./chunk.MB7LKKUD.js","./chunk.WVUJXDXZ.js","./chunk.ZIEHF67C.js","./chunk.UHX4WTM7.js","./chunk.IKX4VDTW.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.GZHZLJBF.js","./chunk.6MADC6DM.js","./chunk.OJGHDWI6.js","./chunk.JLEC3USG.js","./chunk.HDRD33II.js","./chunk.DX357TZ3.js","./chunk.H7KCWCB4.js","./chunk.XSNAG4JT.js","./chunk.XWAMQPUM.js","./chunk.SDO3U72B.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.ITYQUSZI.js")).then(e=>({default:e.TakeBack})))));function xi({context:e,docked:t,at:n,...a}){let{store:r}=e,o=Y(r),[l]=(0,ge.useState)(()=>r.batches().length),s=(0,ge.useRef)(!1);return s.current||=o>0||!t&&l>0,s.current?(0,se.jsx)(ge.Suspense,{fallback:null,children:(0,se.jsx)(bi,{context:e,docked:t,at:n,since:l,...a})}):null}function Pi(e,t,n){let{store:a,principal:r,embedded:o}=e;(0,ge.useEffect)(()=>{if(!n)return;let l=s=>{if(!Xr(s))return;let d=s.target,c=d instanceof Node&&t.current?.contains(d),p=d===document.body||d===document.documentElement||d===document;if(!(!c&&!(p&&!o))&&Qr(a,r)){s.preventDefault();try{Zr(a,r)}catch{}}};return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[a,r,o,t,n])}function bo({context:e,registry:t,root:n,children:a}){let r=(0,ge.useMemo)(lo,[]),o=t?.without()??new Set;return Pi(e,n,!o.has("undo")),(0,se.jsxs)(wt.Provider,{value:r,children:[(0,se.jsx)(Ci,{context:e,placed:r,without:o}),a]})}function Ci({context:e,placed:t,without:n}){let[a,r]=(0,ge.useState)(!1);(0,ge.useLayoutEffect)(()=>r(!0),[]);let o=vt(t,"find"),l=vt(t,"undo"),s=pe(),d=kr();if(!a)return null;let c=s.pathname.split("/").filter(Boolean),S=(c.length===1?we(e.store.schema,c[0]):void 0)!==void 0;return(0,se.jsxs)(se.Fragment,{children:[!o&&!n.has("find")&&d?(0,ko.createPortal)((0,se.jsx)(So,{context:e,narrowsLists:S}),d.slot):null,!o&&!n.has("find")&&!d?(0,se.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,se.jsx)(So,{context:e,narrowsLists:S})}):null,!l&&!n.has("undo")?(0,se.jsx)(xi,{context:e,docked:!0,at:s.pathname+s.search}):null,d?.own&&!n.has("undo")?(0,se.jsx)(ro,{context:e,own:d.own}):null]})}function So({context:e,narrowsLists:t}){return(0,se.jsx)(wt.Provider,{value:null,children:(0,se.jsx)(Bn,{context:e,narrowsLists:t})})}var Q=I(He(),1);var ke=I(G(),1),Ai=500,Ri=10;function en(e){return e instanceof HTMLElement?e.isContentEditable||e.tagName==="TEXTAREA"||e.tagName==="SELECT"?!0:e.tagName==="INPUT"&&!["button","submit","reset","checkbox","radio","image","file","color","range"].includes(e.type):!1}function Li(e){let t=typeof getSelection=="function"?getSelection():null;return t!==null&&!t.isCollapsed&&t.containsNode(e,!0)}function xo(e){let t=e.closest('a[href], button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"])');if(t)return t;let n=document.activeElement;return n instanceof HTMLElement&&n!==document.body?n:null}function Po({context:e,root:t,children:n}){return oe()===null?(0,ke.jsx)(ke.Fragment,{children:n}):(0,ke.jsx)(Ti,{context:e,root:t,children:n})}function Ti({context:e,root:t,children:n}){let{setMenuAt:a}=Ka(),{store:r}=e,o=r.schema,l=De(),{pathname:s,search:d}=pe(),c=ct("/").replace(/\/$/,""),p=(0,Q.useCallback)((h,m)=>e.views?.places().find(T=>T.as===h&&(m===null||T.kind===m)),[e.views]),S=(0,Q.useCallback)((h,m)=>{let[T="",E,te]=h.split("/").filter(Boolean).map(P=>{try{return decodeURIComponent(P)}catch{return P}});if(te!==void 0)return null;if(T==="places"&&E!==void 0){let P=p(E,new URLSearchParams(m).get("of"));return P?{face:"pages",place:P.as,about:[Ne(P.kind)],title:P.title}:null}let u=we(o,T);return u?E===void 0?{face:"pages",about:[Ne(u)],title:qe(o,u)}:r.graph.getNode(E)?{face:"pages",on:E,about:[E]}:null:null},[o,r,p]),w=(0,Q.useCallback)(h=>{let m=h.href;try{let T=new URL(m,location.href);if(T.origin===location.origin&&(c===""||T.pathname===c||T.pathname.startsWith(`${c}/`))){let E=S(T.pathname.slice(c.length),T.search);if(E)return{...E,href:m}}}catch{}return{face:"pages",about:[],href:m}},[c,S]),g=(0,Q.useCallback)(()=>S(s,d)??{face:"pages",about:[]},[S,s,d]),L=(0,Q.useCallback)(h=>{let m=g(),T=h.closest("[data-graview-field]")?.getAttribute("data-graview-field");if(T&&m.on!==void 0&&h.closest("[data-graview-pick], a[href]")===null)return{...m,field:T};let E=h.closest("[data-graview-act]")?.getAttribute("data-graview-act");if(E)return{...m,act:E};let te=h.closest("a[href]"),u=h.closest("[data-graview-listed]"),P=[h.closest("[data-graview-pick]")?.getAttribute("data-graview-pick"),u&&(!te||u.contains(te)&&te.classList.contains("graview-spec-item-link"))?u.getAttribute("data-graview-listed"):null].map(ye=>ye?r.graph.getNode(ye):void 0).find(Boolean);if(P)return{face:"pages",on:P.id,about:[P.id],href:`${c}${_(o,P.kind,P.id)}`};if(te)return w(te);let B=h.closest("[data-graview-record]")?.getAttribute("data-graview-record");return B&&r.graph.getNode(B)?{face:"pages",on:B,about:[B]}:m},[g,w,r,o,c]),H=(0,Q.useCallback)(h=>{let m=t.current;if(m===null||!m.contains(h)||en(h)||h.closest("[data-graview-popover]"))return null;let T=L(h);return{face:"pages",on:T.on,about:T.about??[],field:T.field,place:T.place,href:T.href,act:T.act,element:xo(h)}},[L,t]),x=(0,Q.useCallback)((h,m,T)=>{let E=L(h);a({...E,x:Math.round(m),y:Math.round(T),returnTo:xo(h)})},[L,a]),b=(0,Q.useCallback)(h=>{let m=h.getBoundingClientRect();x(h,m.left+Math.min(16,m.width/2),Math.min(m.bottom,m.top+36))},[x]),$=(0,Q.useRef)(0),j=(0,Q.useRef)(null),C=(0,Q.useRef)(!1),D=()=>{j.current&&clearTimeout(j.current.timer),j.current=null};(0,Q.useEffect)(()=>D,[]),(0,Q.useEffect)(()=>{let h=m=>{if(m.defaultPrevented||!(m.key==="ContextMenu"||m.key==="F10"&&m.shiftKey))return;let T=t.current,E=m.target instanceof Element?m.target:null,te=E===null||E===document.body||E===document.documentElement,u=T!==null&&E!==null&&T.contains(E);if(!u&&!(te&&document.querySelector("[data-graview-face='pages']")===T)||en(E)||E?.closest("[data-graview-popover]"))return;m.preventDefault(),$.current=Date.now();let P=u&&E instanceof HTMLElement?E:T?.querySelector("[data-graview-page-title], main h1, main")??null;P&&b(P)};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[t,b]),(0,Q.useEffect)(()=>{let h=t.current;if(!h)return;let m=T=>{let E=T.detail;E&&a({...E,face:"pages"})};return h.addEventListener(Cn,m),()=>h.removeEventListener(Cn,m)},[t,a]);let le=(0,Q.useMemo)(()=>h=>{if(h.face!=="pages")return null;let m=[],T=h.on===void 0?void 0:r.graph.getNode(h.on),E=h.place===void 0?void 0:e.views?.places().find(Ee=>Ee.as===h.place),te=T?void 0:h.about.length===1&&h.about[0].startsWith("aggregate:")&&!E?Mi(h.about[0]):void 0,u=T?_(o,T.kind,T.id):E?ue(e,E):te?`/${V(o,te)}`:void 0,P=u!==void 0&&s===u.split("?")[0];u!==void 0&&!P&&m.push({id:"open",label:"Open",run:()=>l(u)});let B=u!==void 0?`${c}${u}`:h.href;B!==void 0&&m.push({id:"open-in-a-new-tab",label:"Open in a new tab",run:()=>void window.open(B,"_blank","noopener")});let ye=T?`#focus=${encodeURIComponent(T.id)}`:E?`#focus=${encodeURIComponent(Ne(E.kind))}&view=${encodeURIComponent(E.as)}`:te?`#focus=${encodeURIComponent(Ne(te))}`:void 0;if(ye!==void 0&&(e.overview||!e.embedded)){let Ee=e.overview;m.push({id:"in-the-scene",label:"Show in the scene",run:()=>Ee?Ee(ye):location.assign(`${e.sceneHref??"/"}${ye}`)})}return T===void 0&&h.href===void 0&&m.push({id:"find",label:"Find\u2026",run:()=>{let Ee=t.current?.querySelector('[data-testid="nav-find"]')??document.querySelector('[data-testid="nav-find"]');Ee&&Ee.offsetParent!==null?Ee.focus():l("/search")}}),m.length>0?{id:"pages",items:m}:null},[r,o,e,s,c,l,t]),be=(0,Q.useMemo)(()=>h=>{if(h.face!=="pages"||h.field===void 0||h.on===void 0)return null;let m=r.graph.getNode(h.on),T=h.element?.closest("[data-graview-field]")??t.current?.querySelector(`[data-graview-field="${CSS.escape(h.field)}"]`);return!m||!(T instanceof HTMLElement)||!T.hasAttribute("data-graview-editable")?null:{id:"field",at:"start",items:[{id:"change-field",label:`Change \u201C${va(o.tryDefinition(m.kind),h.field)}\u201D`,run:()=>T.click()}]}},[r,o,t]),fe=_r(),X=mr(),de=Or(),Ke=(0,Q.useCallback)((h,m)=>{s===ue(e,h).split("?")[0]&&l(m?ue(e,m):"/")},[s,e,l]),xe=Yr(Ke),Pe=(0,Q.useMemo)(()=>[be,de,le,...xe?[xe]:[],...X?[X]:[],...fe?[fe]:[]],[be,de,le,xe,X,fe]);return(0,ke.jsxs)(cr,{sections:Pe,children:[(0,ke.jsx)("div",{"data-graview-menu-ground":"",style:{display:"contents"},onContextMenu:h=>{let m=h.target;h.shiftKey||en(m)||Li(m)||(h.preventDefault(),!m.closest("[data-graview-popover]")&&(Date.now()-$.current<700||(h.clientX===0&&h.clientY===0&&m instanceof HTMLElement?b(m):x(m,h.clientX,h.clientY))))},onPointerDown:h=>{if(C.current=!1,h.pointerType==="mouse"||!h.isPrimary)return;let m=h.target;if(en(m)||m.closest("[data-graview-choose], [data-graview-popover]"))return;D();let{clientX:T,clientY:E}=h;j.current={x:T,y:E,timer:setTimeout(()=>{j.current=null,C.current=!0,$.current=Date.now(),x(m,T,E)},Ai)}},onPointerMove:h=>{let m=j.current;m&&Math.hypot(h.clientX-m.x,h.clientY-m.y)>Ri&&D()},onPointerUp:D,onPointerCancel:D,onClickCapture:h=>{C.current&&(C.current=!1,h.preventDefault(),h.stopPropagation())},children:n}),(0,ke.jsx)(Ei,{openAt:b,readyAt:H}),(0,ke.jsx)(zr,{placement:"page"}),(0,ke.jsx)(fr,{})]})}function Mi(e){let t=e.slice(10).split("+");return t.length===1&&t[0]?t[0]:void 0}function Ei({openAt:e,readyAt:t}){return(0,ke.jsx)("span",{"data-graview-menu-home":"",tabIndex:-1,onFocus:n=>{if(n.target!==n.currentTarget)return;let a=n.currentTarget.closest("[data-graview-face]"),r=a?.querySelector("[data-graview-page-title]")??a?.querySelector("main h1, main")??null;r&&(r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),r.focus({preventScroll:!0}))},style:{position:"absolute",width:0,height:0,overflow:"hidden"},children:(0,ke.jsx)(Ur,{placement:"menu",openActs:e,aimAt:t})})}var W=I(G(),1);function Co(e,t){return t==="*"?{label:"anything",path:null}:{label:z(e,t),path:`/${V(e.schema,t)}`}}function $i({context:e,relation:t}){let{store:n}=e,a=Co(n,t.from),r=Co(n,t.to),o=l=>l.path?(0,W.jsx)(N,{to:l.path,style:{...ve,fontWeight:550},children:l.label}):(0,W.jsx)("span",{children:l.label});return(0,W.jsxs)("li",{"data-testid":"relation","data-relation":t.edgeKind,style:{display:"grid",gridTemplateColumns:"30px minmax(0, 1fr) auto",gap:12,alignItems:"baseline"},children:[(0,W.jsx)(jr,{edgeKind:t.edgeKind,...e.brand?.kit?{kit:e.brand.kit}:{}}),(0,W.jsxs)("span",{style:{display:"grid",gap:1},children:[(0,W.jsxs)("span",{children:[o(a)," ",(0,W.jsxs)("span",{style:A,"data-graview-speaks-ids":"",children:[ze(t.edgeKind)," \u2192"]})," ",o(r)]}),t.description||t.inverse?(0,W.jsxs)("span",{style:A,children:[t.description?Ae(t.description):null,t.description&&t.inverse?" \xB7 ":null,t.inverse?`from the other end, ${t.inverse}`:null]}):null]}),r.path?(0,W.jsx)(N,{to:`${r.path}?with=${encodeURIComponent(t.edgeKind)}`,style:{...U,...A,fontVariantNumeric:"tabular-nums",display:"inline-block",minWidth:24,minHeight:24,textAlign:"center"},title:`The ${r.label.toLowerCase()} that have this`,children:t.count}):(0,W.jsx)("span",{style:{...A,fontVariantNumeric:"tabular-nums"},children:t.count})]})}function Ao({context:e,heading:t=!0}){let{store:n}=e,a=new Set(Fe(n,e.principal)),r=Xe(n).relations.filter(o=>a.has(o.from)&&(o.to==="*"||a.has(o.to)));return r.length===0?null:(0,W.jsxs)("section",{style:{...J,display:"grid",gap:12},"data-testid":"kind-map",children:[t?(0,W.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap"},children:[(0,W.jsx)("h2",{style:Z,children:(0,W.jsx)(N,{to:"/map",style:ve,children:"Connections"})}),(0,W.jsx)("span",{style:A,children:r.length===1?"1 relation":`${r.length} relations`})]}):null,(0,W.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:10},children:r.map(o=>(0,W.jsx)($i,{context:e,relation:o},`${o.edgeKind}|${o.from}|${o.to}`))})]})}function Qn({context:e}){let{store:t}=e;Y(t);let n=new Set(Fe(t,e.principal)),a=Xe(t),r=a.relations.filter(o=>n.has(o.from));return(0,W.jsxs)(ee,{context:e,children:[(0,W.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,W.jsx)("p",{style:he,children:r.length===0?"No relations":`${r.length} ${r.length===1?"relation":"relations"}`}),(0,W.jsx)(ae,{context:e,children:"Connections"}),(0,W.jsx)("p",{style:ne,children:r.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,W.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"6px 18px"},"data-testid":"map-kinds",children:a.kinds.filter(o=>n.has(o.kind)).map(o=>(0,W.jsxs)("li",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,W.jsx)(ie,{kind:o.kind,brand:e.brand,schema:t.schema,size:7}),(0,W.jsx)(N,{to:`/${V(t.schema,o.kind)}`,style:U,children:o.plural}),(0,W.jsx)("span",{style:A,children:o.count})]},o.kind))}),(0,W.jsx)(Ao,{context:e,heading:!1})]})}function Ro({context:e}){let n=[...oe()?.robots.values()??[]].filter(r=>r.mode==="asking"&&r.say);if(n.length===0)return null;let{store:a}=e;return(0,W.jsxs)("section",{style:{...J,display:"grid",gap:10},"data-testid":"seat-questions",children:[(0,W.jsx)("h2",{style:Z,children:n.length===1?"The seat asked something":`The seat asked ${n.length} things`}),(0,W.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:8},children:n.map(r=>{let o=r.at?a.graph.getNode(r.at):void 0;return(0,W.jsxs)("li",{style:{display:"grid",gap:2},children:[(0,W.jsx)("span",{children:r.say}),o?(0,W.jsxs)(N,{to:_(a.schema,o.kind,o.id),style:{...U,...A},children:[ce(a.schema.tryDefinition(o.kind),o)," \u2192"]}):null]},r.participant)})})]})}var K=I(G(),1);function Zn({context:e}){let{principal:t}=e,{store:n,brand:a,invariantContext:r}=e;Y(n);let o=n.violations(r),l=`${o.length===1?"A rule is broken":"Rules are broken"} \u2014 see what, and what would fix it`,s=[...n.log.all()].slice(-5).reverse(),c=zt(e).map(b=>({kind:b,members:n.graph.nodesOfKind(b).filter($=>it(n.schema.tryDefinition(b),$))})),p=c.filter(b=>b.members.length>0),S=c.map(b=>({entry:b,creator:n.allMutations().find($=>($.creates??[]).includes(b.kind)&&n.permits({name:$.name,args:{}},e.principal).ok)})).find(b=>b.creator!==void 0),w=p.length===0?"Nothing here yet.":`${p.map(b=>Tt(n.schema,b.kind,b.members.length)).join(", ").replace(/, ([^,]*)$/," and $1")}.`,g=e.views?.homeView?.(),L=n.schema.kinds.some(b=>n.graph.nodesOfKind(b).length>0);if(g&&L){let b=a?.subtitle&&a.subtitleDrawn!==!1?(0,K.jsx)("p",{style:{...A,margin:0},"data-testid":"app-subtitle",children:a.subtitle}):null,$=g[Symbol.for("graview.home-blocks")]===!0;return(0,K.jsx)(ee,{context:e,style:dt,children:(0,K.jsxs)("div",{style:{display:"grid",gap:12},"data-testid":"home-view",children:[$?null:b,o.length>0?(0,K.jsx)(N,{to:"/problems",style:{...U,color:"var(--graview-warn)"},children:l}):null,(0,K.jsx)(Kr.Provider,{value:$?b:null,children:(0,K.jsx)(Zt,{when:Ot(g),children:(0,K.jsx)(g,{cardinality:"many",fidelity:"full",mode:"fullscreen",selected:!1})})})]})})}let H=new Set(Fe(n,e.principal)),x=Xe(n).relations.filter(b=>H.has(b.from)&&(b.to==="*"||H.has(b.to)));return(0,K.jsxs)(ee,{context:e,style:dt,children:[(0,K.jsxs)("header",{style:{display:"grid",gap:12},children:[a?.subtitle&&a.subtitleDrawn!==!1?(0,K.jsx)("p",{style:{...A,margin:0},"data-testid":"app-subtitle",children:a.subtitle}):null,(0,K.jsx)(ae,{context:e,"data-testid":"standing",children:w}),(0,K.jsxs)("p",{style:{...ne,display:"grid",gap:4},"data-testid":"standing-card",children:[p.length===0&&S?(0,K.jsxs)("span",{children:["Begin with \u201C",S.creator?.title??S.creator?.name,"\u201D, under"," ",(0,K.jsx)(N,{to:`/${V(n.schema,S.entry.kind)}`,style:U,children:z(n,S.entry.kind)}),"."]}):null,o.length===0?(0,K.jsx)("span",{children:"All rules hold."}):(0,K.jsx)(N,{to:"/problems",style:{...U,color:"var(--graview-warn)"},children:l})]})]}),(0,K.jsx)(_n,{context:e}),(0,K.jsxs)("section",{style:{...J,display:"grid",gap:14},"data-testid":"kinds",children:[(0,K.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap"},children:[(0,K.jsx)("h2",{style:Z,children:"What is here"}),x.length>0?(0,K.jsx)(N,{to:"/map",style:{...Ge,...A,marginLeft:"auto"},"data-testid":"map-link",children:(0,K.jsxs)(Qe,{children:["Connections \xB7 ",x.length===1?"1 relation":`${x.length} relations`]})}):null]}),(0,K.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"8px 10px"},children:c.map(({kind:b,members:$})=>(0,K.jsx)("li",{style:{maxWidth:"100%"},children:(0,K.jsxs)(N,{to:`/${V(n.schema,b)}`,style:{...ve,flexWrap:"wrap",gap:8,padding:"6px 14px 6px 10px",borderRadius:8,border:"1px solid var(--graview-edge-bright)",background:"var(--graview-panel)"},children:[(0,K.jsx)(ie,{kind:b,brand:a,schema:n.schema,size:7}),(0,K.jsx)("span",{style:{fontWeight:550,overflowWrap:"anywhere"},children:z(n,b)}),(0,K.jsx)("span",{style:{...A,fontVariantNumeric:"tabular-nums"},children:$.length===0?"none yet":ft($.length)})]})},b))})]}),s.length>0?(0,K.jsxs)("section",{style:{...J,display:"grid",gap:10},children:[(0,K.jsx)("h2",{style:Z,children:"Recently"}),(0,K.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},children:s.map(b=>(0,K.jsxs)("li",{style:A,children:[(0,K.jsx)("span",{style:{color:"var(--graview-ink)"},children:b.intent})," \u2014 ",ht(b,t,{graph:n.graph,schema:n.schema,...e.seats?{seats:e.seats}:{},...e.people?{people:e.people}:{}})]},b.id))})]}):null]})}var Me=I(He(),1);var tt=I(G(),1);function tn({context:e,withheld:t,style:n,testId:a}){let r=oe(),o=La(t,e.signIn??r?.signIn);return o?(0,tt.jsx)("p",{style:{...n,margin:0},children:(0,tt.jsx)("button",{type:"button","data-testid":"sign-in",onClick:()=>o.run(),style:Se,children:o.label})}):t.length===0?null:(0,tt.jsx)("ul",{style:{...n,margin:0,padding:0,listStyle:"none",display:"grid",gap:4},...a?{"data-testid":a}:{},children:t.map(l=>(0,tt.jsxs)("li",{style:A,children:[(0,tt.jsx)("s",{children:l.label})," \u2014 ",l.refusal.message]},l.id))})}var M=I(G(),1);function Xn({context:e}){let{store:t,brand:n,principal:a,invariantContext:r}=e;Y(t);let[o]=pt(),l=o.get("q")??"",s=typeof r?.today=="string"?r.today:void 0,d=Lr(t,l,{...a?{principal:a}:{},places:Te(e),flagged:new Set(t.violations(r).flatMap(g=>g.nodeIds)),...s?{today:s}:{},limit:200}),c=d.hits.filter(g=>g.about==="node"),p=d.hits.filter(g=>g.about==="kind"||g.about==="place"||g.about==="rule"),S=[...new Set(c.map(g=>g.kind))],w=l.trim();return(0,M.jsxs)(ee,{context:e,children:[(0,M.jsx)("style",{children:_t}),(0,M.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,M.jsx)("p",{style:he,children:"Search"}),(0,M.jsx)(ae,{context:e,"data-testid":"search-heading",children:w.length===0?"Find anything by its name":d.hits.length===0?(0,M.jsxs)(M.Fragment,{children:["Nothing here is called \u201C",w,"\u201D."]}):(0,M.jsxs)(M.Fragment,{children:[Oi(t,d.byKind)," for \u201C",w,"\u201D"]})}),w.length>0?(0,M.jsxs)("p",{style:{...A,margin:0},"data-testid":"search-searched",children:[Dt(t.schema,d.searched),d.conditions.filter(g=>g.key!=="is"&&g.admittedBy.length<d.searched.kinds.length).map(g=>(0,M.jsxs)("span",{children:[" ",g.key,":",g.value," narrows"," ",g.admittedBy.length===0?"nothing here":g.admittedBy.map(L=>z(t,L).toLowerCase()).join(" and "),"."]},`${g.key}:${g.value}`))]}):(0,M.jsxs)("p",{style:ne,children:["Type in the box above. Words find the start of words in names and in what each record says;"," ",(0,M.jsx)("code",{children:"done:false"})," and the like narrow as a list does, and ",(0,M.jsx)("code",{children:"is:any"})," includes what is past."]})]}),p.length>0?(0,M.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},"data-testid":"search-named",children:p.map(g=>(0,M.jsx)("li",{"data-testid":"search-hit","data-about":g.about,children:g.about==="kind"?(0,M.jsxs)(N,{to:`/${V(t.schema,g.kind)}`,style:U,children:[g.label,g.count>0?(0,M.jsxs)("span",{style:A,children:[" \xB7 ",g.count," match"]}):null]}):g.about==="place"?(0,M.jsxs)(N,{to:ue(e,g),style:U,children:["Go to ",g.title]}):g.about==="rule"?(0,M.jsxs)(N,{to:"/problems",style:U,children:["The rule \u201C",g.label,"\u201D"]}):null},`${g.about}:${g.about==="rule"?g.name:g.about==="place"?g.as:g.kind}`))}):null,S.map(g=>(0,M.jsxs)("section",{className:"graview-list",style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",minWidth:0},"data-testid":"search-group","data-kind":g,children:[(0,M.jsxs)("h2",{className:"graview-group-head",style:{alignItems:"center"},children:[(0,M.jsx)(ie,{kind:g,brand:n,schema:t.schema,size:8}),(0,M.jsx)(N,{to:`/${V(t.schema,g)}?${new URLSearchParams({q:w}).toString()}`,style:U,"data-testid":"search-kind-link",children:z(t,g)}),(0,M.jsx)("span",{children:d.byKind[g]})]}),(0,M.jsx)("ul",{className:"graview-rows",children:c.filter(L=>L.kind===g).map(L=>(0,M.jsxs)("li",{"data-testid":"search-hit","data-about":"node",className:"graview-row",children:[(0,M.jsxs)(N,{to:_(t.schema,g,L.id),className:"graview-row-title",...L.label.length>60?{title:L.label}:{},children:[L.flagged?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)("span",{role:"img","aria-label":"Breaks a rule:",style:{color:"var(--graview-warn)"},children:"\u26A0"})," "]}):null,L.label]}),L.apart||!L.current?(0,M.jsx)("span",{className:"graview-row-glance",children:[L.apart,L.current?"":"past"].filter(Boolean).join(" \xB7 ")}):null,(0,M.jsx)(nn,{why:L.why})]},L.id))})]},g)),w.length>0?(0,M.jsx)(Ni,{asked:w}):null,w.length>0&&d.hits.length===0?(0,M.jsx)(To,{store:t,kinds:d.searched.kinds,words:d.words,...a?{principal:a}:{},...r?{invariantContext:r}:{}}):null]})}function nn({why:e}){return e.strength==="near"?(0,M.jsxs)("span",{style:A,"data-testid":"search-why","data-near":"",children:["Near \u201C",e.asked,"\u201D",e.field==="label"?"":` \u2014 ${e.reading}: ${e.fragment}`]}):e.field==="label"?null:(0,M.jsxs)("span",{style:A,"data-testid":"search-why",children:[e.reading,": ",e.fragment]})}function Oi(e,t){let n=Object.entries(t).map(([a,r])=>`${r} ${r===1?Ye(e.schema.tryDefinition(a),a):z(e,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 Lo(e,t,n={}){let a=[];for(let r of t){let o=Ze(e,r,{...n.principal?{principal:n.principal}:{},...n.invariantContext?{context:n.invariantContext}:{}});for(let l of an(e,r,o.actions.affordances))a.some(s=>s.mutation.name===l.mutation.name)||a.push(l)}return a}function an(e,t,n){let a=e.schema.tryDefinition(t)?.fieldRoles?.label,r=[];for(let o of n){let l=e.allMutations().find(c=>c.name===o.mutation);if(!l||!l.creates?.includes(t)||r.some(c=>c.mutation.name===l.name))continue;let s=yr(l.input).map(c=>c.name),d=s.includes("label")?"label":a&&s.includes(a)?a:void 0;!d||o.args[d]!==void 0||r.push({kind:t,affordance:o,mutation:l,arg:d})}return r}function To({store:e,kinds:t,words:n,principal:a,invariantContext:r}){let o=Lo(e,t,{...a?{principal:a}:{},...r?{invariantContext:r}:{}});return o.length===0||n.trim().length===0?null:(0,M.jsx)("div",{style:{display:"grid",gap:24},"data-testid":"search-to-create",children:o.map(({kind:l,affordance:s,mutation:d,arg:c})=>(0,M.jsxs)("section",{style:{...J,display:"grid",gap:14},children:[(0,M.jsxs)("h2",{style:Z,children:[Ae(Sa(Ye(e.schema.tryDefinition(l),l)))," called \u201C",n,"\u201D"]}),(0,M.jsx)(Ie,{store:e,mutation:d,prefilled:s.args,open:s.open,initial:{[c]:n},...a?{principal:a}:{}})]},`${s.id}|${n}`))})}function Ni({asked:e}){let t=oe();return t?(0,M.jsx)(Hi,{asked:e,desk:t.aiDesk}):null}function Hi({asked:e,desk:t}){return _a(t)?(0,M.jsx)("p",{style:{margin:0},children:(0,M.jsxs)("button",{type:"button","data-testid":"search-ask",onClick:a=>ja(t,{pointed:{about:[]},asked:e,returnTo:a.currentTarget}),style:{...U,font:"inherit",padding:0,border:0,background:"transparent",cursor:"pointer",textAlign:"start"},children:["Ask: \u2018",e,"\u2019"]})}):null}var y=I(G(),1),Eo=8,$o=40;function Ii(e,t){let n=t?.fields?.shape??{},a=Object.keys(n).find(r=>ba(n[r])&&ka(e[r]));return a===void 0?void 0:e[a]}function Jn({context:e}){let t=Ue(),n=we(e.store.schema,t.slug??"");return n?(0,y.jsx)(Oo,{context:e,kind:n}):(0,y.jsx)(ee,{context:e,children:(0,y.jsx)(ae,{context:e,children:"No such kind of thing here."})})}function Oo({context:e,kind:t,opening:n,row:a,layout:r="list",description:o,bare:l}){let{store:s,brand:d,invariantContext:c}=e;Y(s);let[p,S]=pt(),w=`list-${(0,Me.useId)().replace(/:/g,"")}`,g=s.schema.tryDefinition(t),L=Pa(p.get("archived")),H=s.graph.nodesOfKind(t,{archived:L}),x=Xe(s).relations.filter(i=>i.from===t||i.to===t),b=new Set(s.violations(c).flatMap(i=>i.nodeIds)),$=Cr(s.schema,Pr(s.schema,xr(s.schema,t))),j=x.map(i=>i.edgeKind),C=qi(p,$,j),D=["sort","filter","group","q","by","with","past","archived",...j].some(i=>p.has(i)),le=H.length>=$o,be=g?.fieldRoles?.when,fe=e.views?.arrangement?.()?.lists?.[t],X=wr(fe),de=hr(fe?.group),Ke=Bi(le,be),xe=n??(X?{...Ke,...X}:Ke),Pe=D?C.arrangement:$n(xe,$).arrangement,h=X?.sort,m=Pe.sort&&h?.then&&Pe.sort.by===h.by&&Pe.sort.direction===h.direction?{...Pe,sort:h}:Pe,T=Ar(m.query??""),E=[...m.filter??[],...T.conditions].some(i=>i.key==="is"&&(i.value==="past"||i.value==="any"))||br(g,[...m.filter??[],...T.conditions]),te=E||!g?.lifecycle?m:{...m,filter:[...m.filter??[],{key:"is",value:"current"}]},u=new Map,P=Wt(H,te,{schema:s.schema,graph:s.graph,flagged:b,...typeof c?.today=="string"?{today:c.today}:{},read:(i,f)=>{let O=u.get(i.id);return O||u.set(i.id,O=yt(s.schema,s.graph,i)),O[f]}}),B=de&&m.group?.by===de.by&&!m.group.bucket?$.groups.find(i=>i.key===de.by):void 0,ye=de&&B&&(B.type==="choice"||B.type==="boolean")?vr(P.groups,de,{type:B.type,...B.options?{options:B.options}:{}}):P.groups.map(i=>({...i,closed:!1})),Ee=new Set((p.get("open")??"").split(",").filter(Boolean)),Wo=!!m.query||(m.filter??[]).some(i=>i.key===de?.by),aa=i=>B?.type==="boolean"?i==="1"?"true":"false":i,ra=i=>i.closed&&!Wo&&!Ee.has(aa(i.key)),Ko=i=>{let f=new URLSearchParams(p),O=new Set(Ee);O.has(i)?O.delete(i):O.add(i),O.size>0?f.set("open",[...O].join(",")):f.delete("open"),S(f,{replace:!0})},Ce=P.nodes,at=g?.lifecycle&&!E?H.filter(i=>it(g,i)):H,oa=H.length-at.length,sn=m.group?.by??null,Bo=i=>{let f=new URLSearchParams(p);for(let re of["sort","filter","group","q","by","with","past","archived",...x.map(Rt=>Rt.edgeKind)])f.delete(re);let O=Tr(i);for(let re of["sort","filter","group","q","archived"])O[re]&&f.set(re,O[re]);![...f.keys()].some(re=>["sort","filter","group","q"].includes(re))&&(n||X||le||be)&&f.set("sort",""),S(f)},{principal:rt}=e,ln=Ze(s,t,{...rt?{principal:rt}:{},...e.invariantContext?{context:e.invariantContext}:{}}),Be=ln.actions.affordances.map(i=>({affordance:i,mutation:s.allMutations().find(f=>f.name===i.mutation)})).filter(i=>i.mutation!==void 0),qo=ln.actions.withheld,dn=()=>new Set(Ce.length===0?Be.map(({mutation:i})=>i.name):[]),[cn,ia]=(0,Me.useState)(()=>({kind:t,open:dn()}));cn.kind!==t&&ia({kind:t,open:dn()});let sa=i=>(cn.kind===t?cn.open:dn()).has(i),la=(i,f)=>ia(O=>{let re=new Set(O.open);return f?re.add(i):re.delete(i),{kind:O.kind,open:re}}),da=`begin-${(0,Me.useId)().replace(/:/g,"")}`,ca=T.words&&Ce.length===0?Object.fromEntries(an(s,t,ln.actions.affordances).map(i=>[i.mutation.name,i.arg])):{},je=z(s,t),xt=e.views?.lookup(t,{cardinality:"one",fidelity:"glyph"}),pn=xt!==void 0&&!st(xt)?xt:void 0,un=(m.group?.bucket??"day")==="day"?m.group?.by:void 0,gn=(m.filter??[]).map(i=>i.key),Go=gn.filter(i=>gn.indexOf(i)===gn.lastIndexOf(i)&&/choice|boolean/.test($.filters.find(f=>f.key===i)?.type??"")),mn=i=>{let f={...g?.computed?yt(s.schema,s.graph,i):i};un&&!String(f[un]).includes("T")&&delete f[un];for(let O of Go)delete f[O];return f},pa=i=>rr(g?.fields?.shape?.[i])?.type==="enum",Pt=i=>{let f=ce(g,i);if(a)return(0,y.jsxs)("li",{"data-testid":"record-row","data-graview-record":i.id,style:{minWidth:0},...Sn(i.id),children:[vn(i,f),a(i,{label:f,href:_(s.schema,t,i.id),flagged:b.has(i.id),glance:no(mn(i),g,f)})]},i.id);if(pn){let kn=Gt(xt,i,s.graph),Yo=Object.fromEntries(Object.entries(mn(i)).filter(([Qo])=>!kn?.fields.has(Qo))),ha=kn?Fn(Yo,g,kn.title??f,pa):[];return(0,y.jsxs)("li",{"data-testid":"record-row","data-graview-record":i.id,style:{position:"relative",display:"flex",flexWrap:"wrap",alignItems:"baseline",columnGap:16,rowGap:2,paddingBlock:10,borderTop:"1px solid var(--graview-edge)"},...Sn(i.id),children:[vn(i,f),(0,y.jsx)("div",{style:{flex:"1 1 14rem",minWidth:0},children:(0,y.jsx)(pn,{node:i,cardinality:"one",fidelity:"glyph",mode:"fullscreen",selected:!1,...b.has(i.id)?{flagged:[i.id]}:{}})}),ha.length>0?(0,y.jsx)("span",{style:{...A,flex:"0 1 auto",minWidth:0,overflowWrap:"anywhere"},"data-testid":"record-glance",children:(0,y.jsx)(Dn,{runs:ha})}):null,(0,y.jsx)(Vi,{to:_(s.schema,t,i.id),label:b.has(i.id)?`${f} \u2014 implicated in a problem`:f})]},i.id)}let O=Fn(mn(i),g,f,pa),re=O.length>0,Rt=T.words?Rr(g,i,T.words):void 0,fa=le?void 0:ir(i,g),Lt=Ii(i,g),ya=(0,y.jsxs)(N,{to:_(s.schema,t,i.id),className:"graview-row-title",...f.length>60?{title:f}:{},children:[b.has(i.id)?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("span",{role:"img","aria-label":"Breaks a rule:",style:{color:"var(--graview-warn)"},children:"\u26A0"})," "]}):null,f]});return(0,y.jsxs)("li",{className:"graview-row","data-graview-record":i.id,...Sn(i.id),children:[vn(i,f),fa?(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:14,minWidth:0},children:[(0,y.jsx)(lt,{as:"thumb",file:fa}),ya]}):ya,re||Lt?(0,y.jsxs)("span",{className:"graview-row-glance",children:[(0,y.jsx)(Dn,{runs:O}),re&&Lt?" \xB7 ":null,Lt?(0,y.jsx)(Kt,{address:Lt}):null]}):null,Rt?(0,y.jsx)(nn,{why:Rt}):null]},i.id)},fn=Te(e).filter(i=>i.kind===t),ua=fe?.filters,Uo=(m.filter??[]).some(i=>i.key!=="is"||i.value!=="any"),Vo=!!(m.sort||m.group||m.query||Uo),jo=at.length>=Eo||D&&Vo,Oe=m.sort?$.sorts.find(i=>i.key===m.sort.by):void 0,yn=Oe?.type==="date"||Oe!==void 0&&Oe.key===be,ga=le&&!P.grouped&&Oe&&(Oe.about==="label"||Oe.type==="text"||yn)?i=>{let f=Oe.about==="label"?ce(g,i):i[Oe.key];if(typeof f!="string"||f.length===0)return yn?"No date":"#";if(yn)return f.slice(0,4);let O=f.trim().charAt(0).toLocaleUpperCase();return/\p{L}/u.test(O)?O:"#"}:void 0,_e=ga?Ce.reduce((i,f)=>{let O=ga(f);return i.at(-1)?.key===O?i.at(-1).nodes.push(f):i.push({key:O,nodes:[f]}),i},[]):void 0,ma=P.grouped&&sn?ye.flatMap(i=>ra(i)?[]:i.nodes):_e&&_e.length>1?_e.flatMap(i=>i.nodes):Ce,hn=(0,Me.useMemo)(()=>ma.map(i=>i.id),[ma.map(i=>i.id).join(`
6
+ `)]),$e=Nr(hn),wn=(0,Me.useId)(),gt=(rt?s.permittedMutations(rt):s.permittedMutations()).some(i=>{let f=i.subject?.kinds;return f!==void 0&&(f==="*"||f.includes(t))}),vn=(i,f)=>gt?(0,y.jsx)("span",{className:"graview-choose-at",children:(0,y.jsx)("input",{...$e.boxProps(i.id,f),onPointerEnter:On,onFocus:On})}):null,Sn=i=>gt?{"data-graview-choose":i}:{},_o=(0,Me.useCallback)(i=>{$e.choose(i),requestAnimationFrame(()=>{let f=$e.list.current;((i[0]===void 0?null:f?.querySelector(`[data-graview-choose-box="${CSS.escape(i[0])}"]`))??f)?.focus({preventScroll:!0})})},[$e]),ot=r==="grid"?{margin:0,padding:0,listStyle:"none",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(100%, 15rem), 1fr))",alignItems:"start",gap:12}:a||pn?{margin:0,padding:0,listStyle:"none",display:"grid",gap:a&&r==="list"?6:0}:void 0,Ct=ot?void 0:"graview-rows",mt=i=>`list-at-${i.replace(/[^\p{L}\p{N}]/gu,"_")}`,At=x.map(i=>{let f=i.from===t?i.to:i.from,O=i.from===t?i.description:i.inverse??i.description;return{relation:i,far:f,words:O}}),zo=new Set(At.map(i=>(i.words??"").toLowerCase()).filter((i,f,O)=>i&&O.indexOf(i)!==f));return(0,y.jsxs)(l?Ki:ee,{context:e,children:[(0,y.jsxs)("div",{style:{display:"grid",gap:12},children:[(0,y.jsxs)("header",{style:{display:"grid",gap:4},children:[l?null:(0,y.jsx)(ut,{context:e}),(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",columnGap:10,rowGap:4,minWidth:0},children:[(0,y.jsx)(ie,{kind:t,brand:d,schema:s.schema,size:8}),(0,y.jsx)(ae,{context:e,children:je}),Be.length>0?(0,y.jsx)("span",{style:{marginLeft:"auto",display:"flex",flexWrap:"wrap",columnGap:14,rowGap:8},"data-testid":"beginnings-open",children:Be.map(({affordance:i,mutation:f})=>(0,y.jsx)(Gi,{name:f.name,title:f.title??f.name,panel:`${da}-${f.name}`,open:sa(f.name),onOpen:O=>la(f.name,O)},i.id))}):null]}),Ce.length>0?(0,y.jsx)(Jr,{place:"here",to:[{label:`Skip to the ${Ce.length===1?Ye(g,t):`${Ce.length} ${je.toLowerCase()}`}`,testid:"records",go:()=>{let i=document.querySelector(`[data-graview-skip-target="${CSS.escape(wn)}"]`);Nn(i?.querySelector('[data-graview-choose-box][tabindex="0"]')??i)}},...at.length>0?[{label:"Skip to arranging them",testid:"arranging",go:()=>{let i=document.querySelector(`[data-graview-skip-target="${CSS.escape(wn)}"]`)?.parentElement?.querySelector('[role="group"][aria-label="Arrange"]');Nn(i?.querySelector('button[data-testid$="-add"], button[data-testid$="-all"]')??i)}}]:[]]}):null,o??g?.description?(0,y.jsx)("p",{style:ne,children:o??g?.description}):null,At.length>0||fn.length>0?(0,y.jsxs)("p",{style:{...A,margin:0,display:"flex",flexWrap:"wrap",columnGap:18,rowGap:2},"data-testid":"kind-related",children:[At.length>0?(0,y.jsxs)("span",{"data-testid":"kind-relations",children:["Related:"," ",At.map(({relation:i,far:f,words:O},re)=>(0,y.jsxs)("span",{"data-relation":i.edgeKind,children:[re>0?(0,y.jsx)("span",{"aria-hidden":"true",children:" \xB7 "}):null,f==="*"?Ae(O??ze(i.edgeKind)):(0,y.jsx)(N,{to:`/${V(s.schema,f)}`,style:U,title:z(s,f),children:O&&zo.has(O.toLowerCase())?`${Ae(O)}: ${z(s,f).toLowerCase()}`:Ae(O??z(s,f))})]},`${i.edgeKind}|${i.from}|${i.to}`))]}):null,fn.length>0?(0,y.jsxs)("span",{"data-testid":"kind-pictures",children:["Also as:"," ",fn.map((i,f)=>(0,y.jsxs)("span",{children:[f>0?(0,y.jsx)("span",{"aria-hidden":"true",children:" \xB7 "}):null,(0,y.jsx)(N,{to:ue(e,i),style:U,children:i.title})]},Je(i)))]}):null]}):null]}),Be.length>0?(0,y.jsx)("div",{style:{display:"contents"},"data-testid":"beginnings",children:Be.map(({affordance:i,mutation:f})=>{let O=!!(ca[f.name]&&Ce.length===0);return(0,y.jsx)(Ui,{name:f.name,id:`${da}-${f.name}`,description:f.description,open:sa(f.name),onClose:()=>la(f.name,!1),children:(0,y.jsx)(Ie,{store:s,mutation:f,prefilled:i.args,open:i.open,...O?{initial:{[ca[f.name]]:T.words}}:{},...e.principal?{principal:e.principal}:{}},O?`${f.name}|${T.words}`:f.name)},i.id)})}):null,C.dropped.length>0?(0,y.jsxs)("p",{style:{...A,margin:0},"data-testid":"list-dropped",children:["This link asked for ",C.dropped.join(", "),", which ",je.toLowerCase()," cannot be arranged by; the rest is shown."]}):null,at.length>0?(0,y.jsx)($r,{schema:s.schema,graph:s.graph,kind:t,arrangement:m,onChange:Bo,kept:{shown:Ce.length,of:at.length},noun:{one:Ye(g,t),many:je.toLowerCase()},...jo?{}:{allow:!1},...ua?{filters:ua}:{},offers:$,chips:{nodes:at,flagged:b,...typeof c?.today=="string"?{today:c.today}:{}},query:e.framed===!0&&e.barAbove!==!0}):null,(0,y.jsx)("style",{children:_t}),gt?(0,y.jsx)("style",{children:Hr+Wi}):null,(0,y.jsx)("div",{className:"graview-list","data-graview-skip-target":wn,...gt?{...$e.listProps,ref:$e.list,tabIndex:-1,"data-graview-choosable":"","aria-label":$e.chosen.length>0?`${je}, ${$e.chosen.length} chosen`:je,role:"group"}:{},children:Ce.length===0&&T.words?(0,y.jsxs)("p",{style:ne,"data-testid":"none-yet",children:["Nothing here is called \u201C",T.words,"\u201D."," ",(0,y.jsx)("span",{style:A,"data-testid":"list-searched",children:Dt(s.schema,{kinds:[t],past:E})})," ",(0,y.jsx)(N,{to:"?",style:U,children:"Show every one"})]}):Ce.length===0?(0,y.jsxs)("p",{style:ne,"data-testid":"none-yet",children:[m.filter?.length||m.query?"None of them.":"None yet",!m.filter?.length&&!m.query&&Be.length>0?` \u2014 the first one starts above, with \u201C${Be[0]?.mutation.title??Be[0]?.mutation.name}\u201D.`:!m.filter?.length&&!m.query?".":"",m.filter?.length||m.query?(0,y.jsxs)(y.Fragment,{children:[" ",(0,y.jsx)(N,{to:"?",style:U,children:"Show every one"})]}):null]}):P.grouped&&sn?(0,y.jsx)("div",{style:{display:"grid",gap:"1rem"},"data-testid":"records","data-grouped":sn,children:ye.map(i=>{if(!i.closed)return(0,y.jsxs)("section",{style:{display:"grid",gap:0},"data-testid":"list-group",children:[(0,y.jsxs)("h2",{className:"graview-group-head",children:[i.label," ",(0,y.jsx)("span",{children:i.nodes.length})]}),(0,y.jsx)("ul",{style:ot,className:Ct,"data-graview-rows":"",children:i.nodes.map(Pt)})]},i.key||"-");let f=ra(i),O=`${w}-${mt(i.key||"none")}`;return(0,y.jsxs)("section",{style:{display:"grid",gap:0},"data-testid":"list-group","data-closed":f?"shut":"open",children:[(0,y.jsx)("h2",{className:"graview-group-head",children:(0,y.jsxs)("button",{type:"button",className:"graview-group-toggle","aria-expanded":!f,"aria-controls":O,"data-testid":"list-group-toggle",onClick:()=>Ko(aa(i.key)),children:[(0,y.jsx)("span",{"aria-hidden":"true",children:f?"\u25B8":"\u25BE"}),i.label," ",(0,y.jsxs)("span",{children:["\xB7 ",i.nodes.length]}),(0,y.jsxs)("span",{style:Fi,children:[" ",i.nodes.length===1?Ye(g,t):je.toLowerCase()]})]})}),(0,y.jsx)("ul",{id:O,style:f?{...ot,display:"none"}:ot,className:Ct,"data-graview-rows":"",hidden:f,children:f?null:i.nodes.map(Pt)})]},i.key||"-")})}):_e&&_e.length>1?(0,y.jsxs)("div",{style:{display:"grid",gap:14},"data-testid":"records","data-sectioned":Oe?.type==="date"?"year":"letter",children:[(0,y.jsx)("nav",{"aria-label":"Jump to","data-testid":"list-index",style:{...A,display:"flex",flexWrap:"wrap",gap:Oe?.type==="date"?"0 10px":"0 4px",lineHeight:1.3},children:_e.map(i=>(0,y.jsx)("a",{href:`#${mt(i.key)}`,onClick:f=>{f.preventDefault(),document.getElementById(mt(i.key))?.scrollIntoView({block:"start"})},style:{...ve,minWidth:24,justifyContent:"center"},children:i.key},i.key))}),_e.map(i=>(0,y.jsxs)("section",{"data-testid":"list-section","aria-labelledby":mt(i.key),style:{display:"grid",gap:0},children:[(0,y.jsx)("h2",{id:mt(i.key),className:"graview-group-head",children:i.key}),(0,y.jsx)("ul",{style:ot,className:Ct,"data-graview-rows":"",children:i.nodes.map(Pt)})]},i.key))]}):(0,y.jsx)("ul",{style:ot,className:Ct,"data-testid":"records","data-graview-rows":"",children:Ce.map(Pt)})}),gt?(0,y.jsx)(Ir,{store:s,chosen:$e.chosen,...rt?{principal:rt}:{},...c?{context:c}:{},anchor:Di,of:hn.length,onChooseAll:()=>$e.choose(hn),onClear:$e.clear,onActed:_o}):null,oa>0?(0,y.jsxs)(N,{to:Mo(p,"filter","is:any"),style:{...U,...A,justifySelf:"start"},"data-testid":"past-link",children:["+",oa," past"]}):null,L===!1&&s.graph.count(t,{archived:!0})>0?(0,y.jsxs)(N,{to:Mo(p,"archived","true"),style:{...U,...A,justifySelf:"start"},"data-testid":"archived-link",children:["+",s.graph.count(t,{archived:!0})," archived"]}):null]}),(0,y.jsx)(tn,{context:e,withheld:qo,style:J,testId:"withheld"})]})}var Fi={position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0},Di=()=>document.querySelector("[data-graview-choosable]")?.closest("[data-embed-content]")??null,Wi=`
7
+ .graview-list[data-graview-choosable]{outline:none}
8
+ .graview-list [data-graview-choose]{position:relative;padding-left:34px}
9
+ .graview-choose-at{position:absolute;left:2px;top:0;bottom:0;z-index:${Ta.raised};display:flex;align-items:center}
10
+ @media (min-width: 900px) and (pointer: fine){
11
+ .graview-list [data-graview-choose]{padding-left:0}
12
+ .graview-choose-at{left:-34px}
13
+ }
14
+ @media (pointer: coarse){
15
+ .graview-list:not([data-graview-choosing]) [data-graview-choose]{padding-left:0}
16
+ .graview-list:not([data-graview-choosing]) .graview-choose-at{display:none}
17
+ }
18
+ `;function Ki({children:e}){return(0,y.jsx)("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:40,minWidth:0},children:e})}var Bi=(e,t)=>t?{sort:{by:t,direction:"desc"}}:e?{sort:{by:"label",direction:"asc"}}:{};function qi(e,t,n){let a=$t({...e.get("sort")?{sort:e.get("sort")}:{},...e.get("filter")?{filter:e.get("filter")}:{},...e.get("group")?{group:e.get("group")}:{},...e.get("q")?{q:e.get("q")}:{},...e.get("archived")?{archived:e.get("archived")}:{}}),r=[...a.filter??[]],o=e.get("by"),l=a.group??(o?{by:o}:void 0);for(let d of n){let c=e.get(d);c&&r.push({key:d,value:c})}let s=e.get("with");return s&&r.push({key:s,value:"*"}),e.get("past")==="1"&&!r.some(d=>d.key==="is")&&r.push({key:"is",value:"any"}),$n({...a.sort?{sort:a.sort}:{},...a.query?{query:a.query}:{},...r.length>0?{filter:r}:{},...l?{group:l}:{},...a.archived!==void 0?{archived:a.archived}:{}},t)}function Mo(e,t,n){let a=new URLSearchParams(e);return a.set(t,n),a.delete("past"),`?${a.toString()}`}function Gi({name:e,title:t,panel:n,open:a,onOpen:r}){return(0,y.jsxs)("button",{type:"button","data-testid":`act-open-${e}`,"data-graview-act":e,"aria-expanded":a,"aria-controls":n,onClick:()=>{r(!a),a||requestAnimationFrame(()=>document.getElementById(n)?.querySelector("input, select, textarea, button")?.focus())},style:{...ve,minHeight:28,margin:"-4px 0",padding:"0 2px",border:0,background:"none",font:"inherit",fontWeight:600,color:"var(--graview-ink)",cursor:"pointer"},children:[(0,y.jsx)("span",{"aria-hidden":"true",style:{marginRight:6},children:a?"\u2212":"+"}),t]})}function Ui({name:e,id:t,description:n,open:a,onClose:r,children:o}){return(0,y.jsxs)("div",{"data-testid":`act-${e}`,id:t,hidden:!a,onKeyDown:l=>{l.key==="Escape"&&(l.preventDefault(),r(),document.querySelector(`[aria-controls="${t}"]`)?.focus())},style:a?{display:"grid",gap:12,padding:"4px 0 12px"}:void 0,children:[n?(0,y.jsx)("p",{style:{...A,margin:0,maxWidth:"58ch"},children:n}):null,o]})}function Vi({to:e,label:t}){let n=(0,Me.useRef)(null);return Fr(n),(0,y.jsx)(N,{ref:n,to:e,"aria-label":t,style:{position:"absolute",inset:0,borderRadius:6}})}var nt=I(He(),1);var bt=I(He(),1);var F=I(G(),1);function ea({context:e}){let{store:t,brand:n,invariantContext:a,principal:r}=e;Y(t);let o=t.violations(a),l=t.allInvariants(),s=Ht(t,o),d=za(t.schema,l);return(0,F.jsxs)(ee,{context:e,children:[(0,F.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,F.jsx)(ae,{context:e,children:o.length===0?"All rules hold":"What is broken"}),(0,F.jsx)("p",{style:ne,"data-testid":"problems-count",children:o.length===0?"Every declared rule is satisfied by what is here.":Ca(o)})]}),(0,F.jsx)(Ro,{context:e}),s.map((c,p)=>{let S=c.nodeIds[0],w=S?t.graph.getNode(S):void 0;return(0,F.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,F.jsx)(rn,{violation:c,schema:t.schema,...n?{brand:n}:{}}),w?(0,F.jsxs)("p",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:8},children:[(0,F.jsx)(ie,{kind:w.kind,brand:n,schema:t.schema,size:7}),(0,F.jsx)(N,{to:_(t.schema,w.kind,w.id),style:U,children:ce(t.schema.tryDefinition(w.kind),w)})]}):null,c.line?(0,F.jsx)(rn,{violation:c,schema:t.schema,...n?{brand:n}:{}}):null,(0,F.jsx)(on,{store:t,repairs:c.repairs,...r?{principal:r}:{}})]},p)}),l.length>0?(0,F.jsxs)("section",{style:{...J,display:"grid",gap:12},"data-testid":"rules",children:[(0,F.jsx)("h2",{style:Z,children:"The rules"}),(0,F.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:10},children:l.map(c=>{let p=o.filter(g=>g.invariant===c.name).length,S=d.get(c.name),w=c.label??c.name;return(0,F.jsxs)("li",{"data-graview-rule":c.name,style:{display:"grid",gap:2},children:[(0,F.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",columnGap:12,rowGap:2},children:[S?(0,F.jsx)(It,{line:S,schema:t.schema,...n?{brand:n}:{},style:{flex:"1 1 18rem"}}):(0,F.jsx)("span",{style:{flex:"1 1 18rem",fontWeight:550},children:w}),(0,F.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"}`})]}),S&&w.trim().length>0?(0,F.jsx)("span",{style:A,children:w}):null]},c.name)})})]}):null]})}function rn({violation:e,schema:t,brand:n}){if(!e.line)return(0,F.jsx)("p",{style:{margin:0,color:"var(--graview-warn)",fontWeight:550},children:e.message});let a=Qa(e),r=Ya(e);return r?(0,F.jsxs)("div",{style:{display:"grid",gap:4},"data-testid":"problem-line",children:[(0,F.jsx)("p",{style:{margin:0,color:"var(--graview-warn)",fontWeight:550},"data-testid":"problem-says",children:r}),a?(0,F.jsx)("span",{style:A,children:a}):null,(0,F.jsxs)("details",{"data-testid":"problem-judged",style:A,children:[(0,F.jsx)("summary",{style:{cursor:"pointer",width:"fit-content",minHeight:24},children:"How it is judged"}),(0,F.jsx)(It,{line:e.line,schema:t,...n?{brand:n}:{},lead:"none"})]})]}):(0,F.jsxs)("div",{style:{display:"grid",gap:2},"data-testid":"problem-line",children:[(0,F.jsx)(It,{line:e.line,schema:t,...n?{brand:n}:{},lead:"none",style:{color:"var(--graview-warn)"}}),a?(0,F.jsx)("span",{style:A,children:a}):null]})}function on({store:e,repairs:t,principal:n}){let[a,r]=(0,bt.useState)(null),[o,l]=(0,bt.useState)(null),s=(0,bt.useRef)([]);if(t.length===0)return null;let d=a===null?null:t[a],c=d&&(d.missing??[]).length>0?e.allMutations().find(p=>p.name===d.mutation):void 0;return(0,F.jsxs)("div",{style:{display:"grid",gap:10},"data-testid":"repairs",children:[(0,F.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:t.map((p,S)=>{let w=(p.missing??[]).length>0,g=e.permits({name:p.mutation,args:{...p.args}},n);return g.ok?(0,F.jsx)("button",{ref:L=>{s.current[S]=L},type:"button","data-graview-repair":p.mutation,"data-graview-asks":w||void 0,"aria-expanded":w?a===S:void 0,onClick:()=>{if(l(null),w){r(a===S?null:S);return}r(null);try{e.apply({name:p.mutation,args:{...p.args}},n?{author:n}:{})}catch(L){l(Ft(e.schema,e.allMutations(),L))}},style:Se,children:w?`${p.label} \u2026`:p.label},S):(0,F.jsxs)("p",{"data-testid":"withheld","data-withheld":g.refusal.wouldNeed.join(",")||"nobody",style:{...A,margin:0},children:[(0,F.jsx)("s",{children:p.label})," \u2014 ",g.refusal.message]},S)})}),c&&d?(0,F.jsx)(Ie,{store:e,mutation:c,prefilled:{...d.args},only:d.missing??[],label:d.label,autoFocus:!0,onDone:()=>{let p=a;r(null),requestAnimationFrame(()=>{let S=p===null?null:s.current[p];if(S?.isConnected){S.focus();return}let w=document.querySelector("[data-graview-page-title]")??document.querySelector("main h1, main h2");w&&(w.hasAttribute("tabindex")||(w.tabIndex=-1),w.focus())})},...n?{principal:n}:{}}):null,d&&!c&&(d.missing??[]).length>0?(0,F.jsxs)("p",{"data-testid":"refused",role:"alert",style:{margin:0,color:"var(--graview-warn)",fontSize:Hn},children:["\u201C",d.label,"\u201D names ",d.mutation,", which this app does not declare."]}):null,o?(0,F.jsx)("p",{"data-testid":"refused",role:"alert",style:{margin:0,color:"var(--graview-warn)",fontSize:Hn},children:o}):null]})}var ta=I(He(),1);var Ve=I(G(),1);function No({store:e,link:t,principal:n}){let[a,r]=(0,ta.useState)(!1),[o,l]=(0,ta.useState)(null),s=tr(t);return(0,Ve.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[(0,Ve.jsx)("button",{type:"button","data-graview-provisional":"",title:s,"aria-label":`Unsure link: ${s}`,"aria-expanded":a,onClick:()=>r(!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,Ve.jsxs)("span",{style:{...A,display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,Ve.jsx)("span",{children:s}),(0,Ve.jsx)("button",{type:"button",style:{...Se,padding:"4px 10px"},onClick:()=>{try{e.apply({name:Aa,args:{kind:t.edge.kind,from:t.edge.from,to:t.edge.to}},n?{author:n}:{}),r(!1)}catch(d){l(Ft(e.schema,e.allMutations(),d))}},children:"Keep this link"}),o?(0,Ve.jsx)("span",{role:"alert",children:o}):null]}):null]})}var me=I(G(),1);function Ho({nodeId:e,node:t,field:n,inPlace:a,labelStyle:r=he}){return n.files?(0,me.jsx)(lt,{as:"field",read:!a,nodeId:e,field:n.key,label:n.label,files:n.files,labelStyle:r,style:{gap:4}}):n.long?(0,me.jsx)(Er,{nodeId:e,field:n.key,label:n.label,value:n.value,markdown:n.markdown,style:{gridColumn:"1 / -1",gap:4},labelStyle:r,valueStyle:{lineHeight:1.6}}):(0,me.jsxs)("div",{style:{display:"grid",gap:2,minWidth:0,alignContent:"start"},children:[(0,me.jsx)("dt",{style:r,children:n.label}),(0,me.jsx)("dd",{style:{margin:0,overflowWrap:"anywhere",minWidth:0},children:n.linked?(0,me.jsx)(pr,{relation:n.linked.relation,refs:n.linked.refs,...a?{nodeId:e,field:n.key}:{}}):n.app?(0,me.jsx)(Kt,{address:n.app,as:"record",...a?{nodeId:e,field:n.key}:{}}):n.href?(0,me.jsx)(Mr,{href:n.href,field:n.key,value:n.value,stored:n.stored,...a?{nodeId:e}:{}}):a?(0,me.jsxs)(me.Fragment,{children:[(0,me.jsx)(Bt,{nodeId:e,field:n.key,value:n.value,stored:n.stored}),n.repeats?(0,me.jsx)(ur,{nodeId:e,field:n.key,start:t?.[n.key],value:t?.[`${n.key}Repeat`],label:`${n.label} repeats`}):null]}):n.value})]})}var v=I(G(),1),ji=[];function na({context:e}){let{store:t,brand:n,principal:a,invariantContext:r}=e;Y(t);let o=oe()!==null,l=Ue(),s=decodeURIComponent(l.id??""),d=po(t,s,{...a?{principal:a}:{},...r?{context:r}:{}}),c=Ht(t,d?.violations??ji),[p,S]=(0,nt.useState)(null),[w,g]=(0,nt.useState)(!1),[L,H]=(0,nt.useState)(null),x=(0,nt.useRef)(null),b=(0,nt.useRef)(null),$=gr({flow:"both",letters:!0}),j=u=>{(x.current?.parentElement?.querySelector(`[data-affordance="${u.replace(/["\\]/g,"\\$&")}"]`)??x.current)?.focus()};if(!d)return(0,v.jsx)(ee,{context:e,children:(0,v.jsx)(ae,{context:e,children:"Nothing lives at this address."})});let C=t.graph.getNode(s),D=t.schema.tryDefinition(d.kind),le=D?.describe&&C?Xa(D,C):null,be=[...t.log.all()].filter(u=>!Mt(u)&&(u.writes.includes(s)||u.reads.includes(s))).slice(-8).reverse(),fe=t.log.all().find(u=>!Mt(u)&&u.undoes===void 0&&u.primitives.some(P=>P.op==="add-node"&&P.node.id===s)),X=d.actions.affordances.filter(u=>u.provider!=="invariant"),de=X.filter(u=>u.destructive||u.setsAside),Ke=w||de.length<2?X:X.filter(u=>!de.includes(u)),xe=e.views?.lookup(d.kind,{cardinality:"one",fidelity:"full"}),Pe=xe!==void 0&&!st(xe)?xe:void 0,h=Pe&&C?Gt(xe,C,t.graph):void 0,m=h?d.fields.filter(u=>!h.fields.has(u.key)):d.fields,T=h?d.links.flatMap(u=>{let P=u.targets.filter(B=>!h.records.has(B.id));return P.length>0?[{...u,targets:P}]:[]}):d.links,E=Pe!==void 0&&Ua(xe),te=o&&or(D).length>0;return(0,v.jsxs)(ee,{context:e,children:[(0,v.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,v.jsx)(ut,{context:e}),(0,v.jsx)(ae,{context:e,children:o&&C?.label===d.label?(0,v.jsx)(Bt,{nodeId:s,field:"label",value:d.label,said:d.label}):d.label}),le&&le!==d.label?(0,v.jsx)("p",{style:ne,children:le}):null,fe?.lineage?(0,v.jsxs)("p",{style:{...A,margin:0},"data-testid":"record-lineage",children:["Made by ",ht(fe,a,{graph:t.graph,schema:t.schema,...e.seats?{seats:e.seats}:{},...e.people?{people:e.people}:{}}),", ",An(fe.lineage)]}):null,(0,v.jsx)(Yt,{context:e,stop:`#focus=${encodeURIComponent(s)}`,style:{...Ge,...A},"data-testid":"spatial-link"}),o&&C?(0,v.jsx)(Tn,{choices:[{on:"changed",record:s},{on:"act",record:s},{on:"reaches",kind:d.kind,condition:"",record:s}],label:"Notify me when this changes",testId:"record-notify",style:{...Se,...A,justifySelf:"start"}}):null,Te(e).some(u=>u.kind===d.kind||u.across===d.kind)?(0,v.jsxs)("p",{style:{...A,margin:0},"data-testid":"seen-in",children:["Seen in:"," ",Te(e).filter(u=>u.kind===d.kind||u.across===d.kind).map((u,P)=>(0,v.jsxs)("span",{children:[P>0?(0,v.jsx)("span",{"aria-hidden":"true",children:" \xB7 "}):null,(0,v.jsx)(N,{to:ue(e,u),style:U,children:u.title})," ",(0,v.jsx)(Yt,{context:e,stop:`#view=${encodeURIComponent(u.as)}`,style:{...U,...A,display:"inline-block",minWidth:24,textAlign:"center"},title:`${u.title}, in the scene`,label:`${u.title}, in the scene`,children:(0,v.jsx)("span",{"aria-hidden":"true",children:"\u2197"})})]},Je(u)))]}):null]}),C&&xa(C)?(0,v.jsx)(zi,{context:e,id:s,kind:d.kind}):null,C&&Ra(t,s)?(0,v.jsx)(_i,{context:e,id:s,kind:d.kind}):null,Pe&&C?(0,v.jsx)("section",{"data-testid":"record-view",style:{display:"grid",minWidth:0},children:(0,v.jsx)(Dr,{children:(0,v.jsx)(Zt,{when:Ot(xe),children:(0,v.jsx)(Pe,{node:C,cardinality:"one",fidelity:"full",mode:"fullscreen",selected:!1,...d.violations.length>0?{flagged:[s]}:{}})})})}):null,d.violations.length>0?(0,v.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((u,P)=>(0,v.jsxs)("div",{style:{display:"grid",gap:8},children:[(0,v.jsx)(rn,{violation:u,schema:t.schema,...n?{brand:n}:{}}),(0,v.jsx)(on,{store:t,repairs:uo(d.actions,u.repairs),...a?{principal:a}:{}})]},P))}):null,!E&&(m.length>0||te)?(0,v.jsxs)("section",{style:{...J,display:"grid",gap:14},"data-testid":"record-fields",children:[(0,v.jsx)("h2",{style:Z,children:"The facts"}),er(D,m).map((u,P)=>{let B=(0,v.jsx)("dl",{style:{margin:0,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"14px 24px"},children:u.fields.map(ye=>(0,v.jsx)(Ho,{nodeId:s,node:C,field:ye,inPlace:o},ye.key))});return u.title?(0,v.jsxs)("section",{style:{display:"grid",gap:10,minWidth:0},children:[(0,v.jsx)("h3",{"data-graview-field-group":u.title,style:{...Z,fontSize:"inherit"},children:u.title}),B]},P):(0,v.jsx)("div",{children:B},P)}),te?(0,v.jsx)(lt,{as:"unfilled",nodeId:s,skip:[...h?.fields??[]],labelStyle:he,style:{gap:4}}):null]}):null,(E?[]:T).map(u=>(0,v.jsxs)("section",{style:{...J,display:"grid",gap:10},children:[(0,v.jsx)("p",{style:he,children:to(t,u)}),u.description?(0,v.jsx)("h2",{style:Z,children:Ae(u.description)}):(0,v.jsxs)("h2",{style:Z,"aria-label":ze(u.edgeKind),children:[u.direction==="in"?"\u2190 ":"\u2192 ",ze(u.edgeKind)]}),(0,v.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"6px 18px"},children:u.targets.map(P=>{let B=nr(t,u.direction==="in"?{kind:u.edgeKind,from:P.id,to:s}:{kind:u.edgeKind,from:s,to:P.id});return(0,v.jsxs)("li",{style:{display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,v.jsx)(ie,{kind:P.kind,brand:n,schema:t.schema,size:7}),(0,v.jsxs)(N,{to:_(t.schema,P.kind,P.id),style:U,children:[P.label,P.apart?(0,v.jsxs)("span",{style:A,children:[" \xB7 ",P.apart]}):null]}),B?.provisional?(0,v.jsx)(No,{store:t,link:B,...a?{principal:a}:{}}):null]},P.id)})}),(u.direction==="out"&&t.schema.edge(u.edgeKind)?.cardinality==="one"?[]:[...new Set(u.targets.map(P=>P.kind))]).map(P=>(0,v.jsx)(N,{to:`/${V(t.schema,P)}?${encodeURIComponent(u.edgeKind)}=${encodeURIComponent(s)}`,style:{...Ge,...A},"data-testid":"related-all",children:(0,v.jsxs)(Qe,{children:["Sort and filter ",u.description??`these ${z(t,P).toLowerCase()}`,u.targets.some(B=>B.kind!==P)?` (${z(t,P).toLowerCase()})`:""]})},P))]},`${u.edgeKind}|${u.direction}|${u.description??""}`)),!E&&(X.length>0||d.actions.withheld.length>0)?(0,v.jsxs)("section",{style:{...J,display:"grid",gap:14},"data-testid":"record-actions",children:[(0,v.jsx)("h2",{style:Z,ref:x,tabIndex:-1,children:"What can be done"}),(0,v.jsxs)("div",{role:"toolbar","aria-label":"What can be done",...$,style:{display:"flex",flexWrap:"wrap",gap:8},children:[Ke.map(u=>{let P=p===u.id;return(0,v.jsx)("button",{type:"button","data-affordance":u.id,"data-rank":u.rank,"data-graview-act":u.mutation,[Ln]:"",autoFocus:w&&u===de[0],"aria-expanded":P,onClick:()=>S(P?null:u.id),style:{...Se,...P?{borderColor:"var(--graview-accent)",color:"var(--graview-accent)"}:{}},children:u.label},u.id)}),Ke.length<X.length?(0,v.jsxs)("button",{type:"button","aria-expanded":!1,onClick:()=>g(!0),style:{...Se,...A},"data-testid":"record-actions-more",[Ln]:"",children:["Show ",X.length-Ke.length," more"]}):null]}),X.map(u=>{if(p!==u.id)return null;let P=t.allMutations().find(B=>B.name===u.mutation);return P?(0,v.jsxs)("div",{ref:b,onKeyDown:B=>{if(B.key!=="Escape"||B.defaultPrevented)return;B.preventDefault(),S(null);let ye=u.id;requestAnimationFrame(()=>j(ye))},style:{display:"grid",gap:10,padding:18,border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)"},children:[(0,v.jsx)("h3",{style:Z,children:u.label}),P.description?(0,v.jsx)("p",{style:{...A,margin:0},children:P.description}):null,(0,v.jsx)(Ie,{store:t,mutation:P,prefilled:u.args,open:u.open,label:u.label,autoFocus:!0,onDone:()=>{S(null),H(u.mutation);let B=u.id;requestAnimationFrame(()=>j(B))},...a?{principal:a}:{}})]},u.id):null}),o&&L!==null&&p===null?(0,v.jsx)(Tn,{choices:[{on:"act",act:L,record:s},{on:"act",act:L}],label:"Notify me when someone else does this",testId:"notify-after-act",style:{...Se,...A,justifySelf:"start"}}):null,(0,v.jsx)(tn,{context:e,withheld:d.actions.withheld})]}):null,o?(0,v.jsx)(eo,{id:s,style:J,headingStyle:Z}):null,be.length>0?(0,v.jsxs)("section",{style:{...J,display:"grid",gap:10},"data-testid":"record-history",children:[(0,v.jsx)("h2",{style:Z,children:"What has happened"}),(0,v.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},children:be.map(u=>(0,v.jsxs)("li",{style:A,children:[(0,v.jsx)("span",{style:{color:"var(--graview-ink)"},children:u.intent}),u.lineage?(0,v.jsxs)("span",{"data-graview-lineage":"",children:[" \xB7 ",An(u.lineage)]}):null," \u2014 ",ht(u,a,{graph:t.graph,schema:t.schema,...e.seats?{seats:e.seats}:{},...e.people?{people:e.people}:{}})]},u.id))})]}):null]})}function _i({context:e,id:t,kind:n}){let{store:a,principal:r}=e,o={name:`allow-tidying-${n}`,args:{id:t}},l=a.allMutations().some(s=>s.name===o.name)&&a.permits(o,r).ok;return(0,v.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,v.jsxs)("p",{style:{margin:0,flex:"1 1 16rem"},children:[(0,v.jsx)("strong",{children:"Left alone."})," Nothing automated changes it; tidying passes it by."]}),l?(0,v.jsx)("button",{type:"button",style:Se,"data-testid":"allow-tidying",onClick:()=>a.apply(o,r?{author:r}:{}),children:"Allow tidying again"}):null]})}function zi({context:e,id:t,kind:n}){let{store:a,principal:r}=e,o={name:`unarchive-${n}`,args:{id:t}},l=a.allMutations().some(c=>c.name===o.name)&&a.permits(o,r).ok,s=[...a.log.all()].reverse().find(c=>!Mt(c)&&c.mergedInto!==void 0&&c.writes.includes(t)),d=s?.mergedInto!==void 0?a.graph.getNode(s.mergedInto):void 0;return(0,v.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,v.jsxs)("p",{style:{margin:0,flex:"1 1 16rem"},children:[(0,v.jsx)("strong",{children:"Archived."})," Kept with its ties and history, and out of lists, counts and rules.",d?(0,v.jsxs)(v.Fragment,{children:[" ","Merged into ",(0,v.jsx)(N,{to:_(a.schema,d.kind,d.id),style:U,children:ce(a.schema.tryDefinition(d.kind),d)}),"."]}):null]}),l?(0,v.jsx)("button",{type:"button",style:Se,"data-testid":"bring-it-back",onClick:()=>a.apply(o,r?{author:r}:{}),children:"Bring it back"}):null]})}var k=I(G(),1),Yi=(0,q.lazy)(Nt(()=>(__graviewPreload(import.meta.url,["./chunk.JF3GD4H5.js","./chunk.ONEYVLC2.js","./chunk.WQONZBA3.js","./chunk.UGFDSE37.js","./chunk.NWA7Q6CI.js","./chunk.WP5W44Y4.js","./chunk.M5GJHVWZ.js","./chunk.HZCA3UWJ.js","./chunk.JBW3DI7E.js","./chunk.AGIO2GRV.js","./chunk.NIVTK2W5.js","./chunk.6QYJ2K6K.js","./chunk.3MMLRSRC.js","./chunk.DQOCBKC3.js","./chunk.OHSJQYJN.js","./chunk.DEUTHHGI.js","./chunk.EPUBSKKL.js","./chunk.ATDU5Y7V.js","./chunk.AQQZY6OY.js","./chunk.BCWPV4WR.js","./chunk.Y5ARSVH4.js","./chunk.PKUDIWIF.js","./chunk.VW2VCPJX.js","./chunk.MB7LKKUD.js","./chunk.WVUJXDXZ.js","./chunk.ZIEHF67C.js","./chunk.UHX4WTM7.js","./chunk.IKX4VDTW.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.GZHZLJBF.js","./chunk.6MADC6DM.js","./chunk.OJGHDWI6.js","./chunk.JLEC3USG.js","./chunk.HDRD33II.js","./chunk.DX357TZ3.js","./chunk.H7KCWCB4.js","./chunk.XSNAG4JT.js","./chunk.XWAMQPUM.js","./chunk.SDO3U72B.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.MWONSI3P.js")).then(e=>({default:e.DraftPage})))),Qi={kind:"human"};function Zi({list:e,store:t}){let n=new Set(e.members.map(l=>l.kind)),a=e.total-e.members.length,r=n.size===1?[...n][0]:void 0;if(!r)return(0,k.jsx)("p",{className:"graview-spec-text graview-spec-more",children:`and ${a} more`});let o=qe(t.schema,r).toLowerCase();return(0,k.jsx)("p",{className:"graview-spec-text graview-spec-more",children:(0,k.jsx)(N,{to:`/${V(t.schema,r)}`,className:"graview-spec-link graview-spec-see-all","data-testid":"see-all",children:e.total===t.graph.nodesOfKind(r).length?`See all ${ft(e.total)} ${o}`:`${ft(a)} more \xB7 all ${o}`})})}function Xi({context:e,children:t}){let n=De(),a=e.store.schema,r=ct("/").replace(/\/$/,""),o=(0,q.useMemo)(()=>({href:l=>`${r}${_(a,l.kind,l.id)}`,go:l=>n(_(a,l.kind,l.id)),more:l=>(0,k.jsx)(Zi,{list:l,store:e.store})}),[r,a,n,e.store]);return(0,k.jsx)(qt.Provider,{value:o,children:(0,k.jsx)(Wr.Provider,{value:(e.titleLevel??(e.framed&&!e.barAbove?1:2))-1,children:t})})}function Ji({steering:e}){let t=pe(),n=De(),a=`${t.pathname}${t.search}`;return(0,q.useLayoutEffect)(()=>e.at(a),[a,e]),(0,q.useLayoutEffect)(()=>{let r=l=>{l!==a&&n(l)};e.go.current=r;let o=e.pending?.current;return o!==void 0&&(e.pending.current=void 0,r(o)),()=>{e.go.current===r&&(e.go.current=void 0)}},[a,n,e]),null}function es({context:e,to:t}){let{pathname:n}=pe(),a=oe(),r=(t??a)?.sayWhere,o=ts(e,n);return(0,q.useEffect)(()=>(r?.(o),()=>r?.(null)),[r,o]),null}function ts(e,t){let[n="",a,r]=t.split("/").filter(Boolean).map(l=>{try{return decodeURIComponent(l)}catch{return l}});if(r!==void 0)return"#";if(n==="places"&&a!==void 0){if(a===Pn)return"#overview=1";let l=e.views?.places().find(s=>s.as===a);return l?`#focus=${encodeURIComponent(Ne(l.kind))}&view=${encodeURIComponent(l.as)}`:"#"}let o=we(e.store.schema,n);return o?`#focus=${encodeURIComponent(a??Ne(o))}`:"#"}function ns({onNavigate:e,path:t}){let n=pe(),a=Wn(),r=De(),o=n.hash&&!n.hash.includes("=")?n.hash:"",l=`${n.pathname}${n.search}${o}`,s=(0,q.useRef)(e);s.current=e;let d=(0,q.useRef)(null);(0,q.useEffect)(()=>{let p=d.current;d.current=l,p!==null&&(l===p&&a!=="PUSH"||s.current?.(l,a==="POP"?"pop":a==="REPLACE"?"replace":"push"))},[n.key]);let c=(0,q.useRef)(t);return(0,q.useEffect)(()=>{t===void 0||t===c.current||(c.current=t,t!==l&&r(t))},[t]),null}function Io({context:e,registry:t,page:n}){let a=Ue(),r=we(e.store.schema,a.slug??""),o=n==="list"?Jn:na,s=(r?t?.lookup(r,n):void 0)??o;return(0,k.jsx)(s,{context:e})}function as({context:e,registry:t,children:n}){let a=(0,q.useRef)(null);return Va(a),(0,k.jsx)("div",{ref:a,"data-graview-face":"pages",style:{display:"contents"},children:(0,k.jsx)(bo,{context:e,registry:t,root:a,children:(0,k.jsx)(Po,{context:e,root:a,children:n})})})}function rs(e){return e instanceof HTMLElement?e.isContentEditable||e.tagName==="TEXTAREA"||e.tagName==="SELECT"?!0:e.tagName==="INPUT"&&!["button","submit","reset","checkbox","radio","image","file","color","range"].includes(e.type):!1}function os(){let{pathname:e}=pe(),t=Wn(),n=(0,q.useRef)(null);(0,q.useLayoutEffect)(()=>{if(t!=="POP"){for(let o=n.current?.parentElement;o;o=o.parentElement){let{overflowY:l}=getComputedStyle(o);if((l==="auto"||l==="scroll")&&o.scrollHeight>o.clientHeight){o.scrollTop=0;return}}window.scrollTo(0,0)}},[e]);let a=(0,q.useRef)(e),r=(0,q.useRef)(!1);return(0,q.useEffect)(()=>{if(!r.current&&e===a.current)return;r.current=!0;let o=document.activeElement;if(rs(o))return;let l=n.current?.closest("main")??document.querySelector("main"),d=n.current?.closest("[data-graview-face]")?.querySelector("[data-graview-page-title]")??l?.querySelector("h1, h2")??null??l??null;d&&(d.hasAttribute("tabindex")||d.setAttribute("tabindex","-1"),d.focus({preventScroll:!0}))},[e]),(0,k.jsx)("span",{ref:n,hidden:!0,"data-graview-scroll-reset":""})}function Fo({context:e,children:t}){let n=De(),a=(0,q.useMemo)(()=>({record:(r,o)=>{let l=e.store.graph.getNode(r);l&&n(Vt(_(e.store.schema,l.kind,r),{section:o?.section}))},place:(r,o)=>{let l=e.views?.places().find(s=>s.as===r);l&&n(Vt(ue(e,l),o))},list:(r,o)=>{e.store.schema.tryDefinition(r)&&n(Vt(`/${V(e.store.schema,r)}`,o))},draft:()=>n("/~draft")}),[e,n]);return(0,k.jsx)(Ga.Provider,{value:a,children:t})}function is(){let{pathname:e,search:t,hash:n}=pe();return(0,q.useEffect)(()=>{let a=decodeURIComponent(n.replace(/^#/,""));if(!(!a||a.includes("=")))return wo(a)},[e,t,n]),null}function ss({context:e,Home:t}){let n=pe(),a=e.views,r=n.key==="default"&&!(a&&Ba(a));(0,q.useEffect)(()=>{a&&qa(a)},[a]);let o=r?$a(e.views?.arrangement?.()?.first,e.store.schema,e.views?.places()??[]):void 0,l=o?.to==="place"?ue(e,o.place):o?.to==="kind"?`/${V(e.store.schema,o.kind)}`:void 0;return l?(0,k.jsx)(Kn,{to:l,replace:!0}):(0,k.jsx)(t,{context:e})}function Do({context:e,registry:t}){let n=t?.lookupSurface("shell"),a=n!==void 0,r=a&&(t?.without().has("bar")??!1),o=a&&!r&&!e.embedded?{...e,barAbove:!0}:e,l=H=>n===void 0?(0,k.jsx)(Qt,{context:e,children:H}):r?(0,k.jsx)(n,{context:e,children:H}):(0,k.jsx)(Qt,{context:e,children:(0,k.jsx)(n,{context:o,children:H})}),s=t?.lookupSurface("home")??Zn,d=t?.lookupSurface("problems")??ea,c=a?{...o,framed:!0}:e,[p,S]=(0,q.useState)(null),w=(0,q.useMemo)(()=>({context:c,registry:t}),[c,t]),g=(0,q.useMemo)(()=>({onFind:S,find:!(t?.without().has("find")??!1),places:!(t?.without().has("places")??!1)}),[t]),L=(0,k.jsx)(qn.Provider,{value:w,children:(0,k.jsx)(Fo,{context:e,children:(0,k.jsx)(as,{context:e,registry:t,children:l((0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(ar,{face:"pages"}),(0,k.jsxs)(Xi,{context:c,children:[(0,k.jsx)(os,{}),(0,k.jsx)(is,{}),(0,k.jsxs)(io,{children:[(t?.routes()??[]).map(({path:H,component:x})=>(0,k.jsx)(Re,{path:H,element:(0,k.jsx)(x,{context:c})},H)),(0,k.jsx)(Re,{path:"/",element:(0,k.jsx)(ss,{context:c,Home:s})}),(0,k.jsx)(Re,{path:"/problems",element:(0,k.jsx)(d,{context:c})}),(0,k.jsx)(Re,{path:"/~draft",element:(0,k.jsx)(q.Suspense,{fallback:null,children:(0,k.jsx)(Yi,{context:c})})}),(0,k.jsx)(Re,{path:"/search",element:(0,k.jsx)(Xn,{context:c})}),(0,k.jsx)(Re,{path:"/map",element:(0,k.jsx)(Qn,{context:c})}),(0,k.jsx)(Re,{path:"/places",element:(0,k.jsx)(zn,{context:c})}),Te(c).some(H=>H.as===Pn)?null:(0,k.jsx)(Re,{path:Ea,element:(0,k.jsx)(Kn,{to:"/",replace:!0})}),(0,k.jsx)(Re,{path:"/places/:as",element:(0,k.jsx)(Yn,{context:c})}),(0,k.jsx)(Re,{path:"/:slug",element:(0,k.jsx)(Io,{context:c,registry:t,page:"list"})}),(0,k.jsx)(Re,{path:"/:slug/:id",element:(0,k.jsx)(Io,{context:c,registry:t,page:"record"})})]})]})]}))})})});return e.embedded||!a||r?L:(0,k.jsx)(co.Provider,{value:g,children:(0,k.jsx)(Sr.Provider,{value:p,children:L})})}var ls=()=>typeof document>"u"?null:document.body;function ds({context:e,registry:t,basename:n,initialPath:a,onNavigate:r,path:o,steering:l,firstLook:s}){let[d,c]=(0,q.useState)(void 0),p=d!==void 0&&d.from===e.principal?{...e,principal:d.seat}:e;(0,q.useState)(()=>p.views?qr(p.views,p.store.schema,En(p.brand,p.store.schema)):void 0);let S=oe();wa({reader:p.locale??S?.locale,app:p.brand?.locale??p.app?.brand?.locale,readerTimeZone:p.timeZone??S?.timeZone,appTimeZone:p.brand?.timeZone??p.app?.brand?.timeZone});let w=p.principal??Qi,g=Fa(p.store,w,p.history),H=(g.past&&g.live===p.store?g.past.store:p.store).seenBy(w),x=H===p.store?p:{...p,store:H};Da(p.store,p.principal);let b=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(ns,{onNavigate:r,path:o}),l?(0,k.jsx)(Ji,{steering:l}):null,x.presence||S?(0,k.jsx)(es,{context:x,to:S}):null,(0,k.jsx)(Do,{context:x,...t?{registry:t}:{}}),s?(0,k.jsx)(Gr,{firstLook:s,root:ls,app:En(p.brand,p.store.schema)}):null]}),$=x.views?(0,k.jsxs)(Wa,{store:x.store,views:x.views,...x.principal?{principal:x.principal}:{},...x.brand?{brand:x.brand}:{},...x.locale?{locale:x.locale}:{},...x.timeZone?{timeZone:x.timeZone}:{},...x.settings?{settings:x.settings}:{},...x.presence&&!S?{presence:x.presence}:{},...x.people?{people:x.people}:{},...x.seats?{seats:x.seats}:{},onSeat:D=>S?S.takeSeat(D):c({from:e.principal,seat:D}),...x.onKeepLens?{onKeepLens:x.onKeepLens}:{},...x.ai?{ai:x.ai}:{},...x.subscriptions?{subscriptions:x.subscriptions}:{},...x.signIn?{signIn:x.signIn}:{},resolveApp:x.resolveApp??S?.resolveApp,linkedRecords:x.linkedRecords??S?.linkedRecords,...x.app?{app:x.app}:{},...x.menuSections?{menuSections:x.menuSections}:{},children:[b,(0,k.jsx)(Fo,{context:x,children:(0,k.jsx)(vo,{context:x})})]}):b,j=(0,k.jsx)(Ia.Provider,{value:g,children:$}),C=x.files?(0,k.jsx)(Ha.Provider,{value:x.files,children:j}):j;if(a!==void 0){let D=n===void 0?a:`${n.replace(/\/$/,"")}${a}`;return(0,k.jsx)(oo,{initialEntries:[D],...n===void 0?{}:{basename:n},children:C})}return(0,k.jsx)(so,{...n===void 0?{}:{basename:n},children:C})}export{di as a,ds as b};
@@ -1 +1 @@
1
- import{a as I,c as x}from"./chunk.E37V2EJM.js";import"./chunk.6BJBPDF3.js";import{b,c as A,j as v,q as w,s as O,v as G}from"./chunk.XWAMQPUM.js";import"./chunk.SDO3U72B.js";import{Xc as k,ld as E,sd as S,td as W}from"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import"./chunk.AJZBJBMO.js";var F=(e,i)=>k(e,i).slice(1);function j(e,i){let l=e.split("/").filter(Boolean);return l.length===i.length&&l.every((s,h)=>s.startsWith(":")||s==="*"||s===i[h])}var $=["problems","search","map","places"];function R(e,i,l,s,h=[]){let{schema:r}=i,o=r.kinds,f=t=>{if(t.startsWith(w))return(t.slice(w.length).split("|")[0]??"").split("+").every(V=>o.includes(V));let y=O(t);return y!==null?o.includes(y):t.startsWith("edge:")||l.graph.getNode(t)!==void 0},[p="/",u]=e.path.split("?"),n=p.split("/").filter(Boolean),m=u?`?${u}`:"",d=n.length>0&&!$.includes(n[0])?o.find(t=>F(r,t)===n[0]):void 0,c=e.path;if(n[0]==="places"&&n.length===2)`/places/${n[1]}`!==E&&!s.some(t=>t.as===decodeURIComponent(n[1]))&&(c="/");else if(d){let t=n[1]===void 0?void 0:decodeURIComponent(n[1]);c=`/${F(r,d)}${t!==void 0&&l.graph.getNode(t)?.kind===d?`/${n[1]}`:""}${m}`}else n.length>0&&n.length<=2&&!$.includes(n[0])&&!h.some(t=>j(t.path,n))&&(c="/");let g=A(e.stop),P=g.within?.view,U=P!==void 0&&!s.some(t=>t.as===P),a=g;if(U){let{view:t,...y}=g.within??{};a={...a,within:y}}if(g.focusId&&!f(g.focusId)){let t=e.kind&&o.includes(e.kind)?G(e.kind):null;a={...v(a,t),zoom:!1}}return a={...a,relation:a.relation&&(o.includes(a.relation)||r.edgeKinds.includes(a.relation))?a.relation:null,expanded:a.expanded.filter(f),pins:Object.fromEntries(Object.entries(a.pins).filter(([t])=>f(t))),...a.selection?{selection:a.selection.filter(f)}:{}},{face:e.face,path:c,stop:b(a),...e.kind?{kind:e.kind}:{}}}function B(e,i,l){let s=e.at,h=e.pages?.routes()??[];if(e.routing!=="address"||typeof window>"u")return R(s,e.app,i,l,h);let{pathname:r,search:o,hash:f}=window.location,p=W(r,e.basePath),u=I({routing:"address",...e.basePath===void 0?{}:{basePath:e.basePath},face:s.face}),n=u==="pages",m={...s,face:u,...p===null?{}:n?{path:p+o}:{stop:x(e.basePath)??s.stop}},d=R(m,e.app,i,l,h),c=n?d.path===m.path?null:S(d.path,e.basePath===void 0?{}:{basePath:e.basePath}):d.stop===b(A(m.stop))?null:r+o+d.stop;return p!==null&&c!==null&&c!==r+o+f&&window.history.replaceState(window.history.state,"",c),d}export{R as settle,B as settleAt};
1
+ import{a as I,c as x}from"./chunk.3VFYSXMQ.js";import"./chunk.XSNAG4JT.js";import{b,c as A,j as v,q as w,s as O,v as G}from"./chunk.XWAMQPUM.js";import"./chunk.SDO3U72B.js";import{Xc as k,ld as E,sd as S,td as W}from"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import"./chunk.AJZBJBMO.js";var F=(e,i)=>k(e,i).slice(1);function j(e,i){let l=e.split("/").filter(Boolean);return l.length===i.length&&l.every((s,h)=>s.startsWith(":")||s==="*"||s===i[h])}var $=["problems","search","map","places"];function R(e,i,l,s,h=[]){let{schema:r}=i,o=r.kinds,f=t=>{if(t.startsWith(w))return(t.slice(w.length).split("|")[0]??"").split("+").every(V=>o.includes(V));let y=O(t);return y!==null?o.includes(y):t.startsWith("edge:")||l.graph.getNode(t)!==void 0},[p="/",u]=e.path.split("?"),n=p.split("/").filter(Boolean),m=u?`?${u}`:"",d=n.length>0&&!$.includes(n[0])?o.find(t=>F(r,t)===n[0]):void 0,c=e.path;if(n[0]==="places"&&n.length===2)`/places/${n[1]}`!==E&&!s.some(t=>t.as===decodeURIComponent(n[1]))&&(c="/");else if(d){let t=n[1]===void 0?void 0:decodeURIComponent(n[1]);c=`/${F(r,d)}${t!==void 0&&l.graph.getNode(t)?.kind===d?`/${n[1]}`:""}${m}`}else n.length>0&&n.length<=2&&!$.includes(n[0])&&!h.some(t=>j(t.path,n))&&(c="/");let g=A(e.stop),P=g.within?.view,U=P!==void 0&&!s.some(t=>t.as===P),a=g;if(U){let{view:t,...y}=g.within??{};a={...a,within:y}}if(g.focusId&&!f(g.focusId)){let t=e.kind&&o.includes(e.kind)?G(e.kind):null;a={...v(a,t),zoom:!1}}return a={...a,relation:a.relation&&(o.includes(a.relation)||r.edgeKinds.includes(a.relation))?a.relation:null,expanded:a.expanded.filter(f),pins:Object.fromEntries(Object.entries(a.pins).filter(([t])=>f(t))),...a.selection?{selection:a.selection.filter(f)}:{}},{face:e.face,path:c,stop:b(a),...e.kind?{kind:e.kind}:{}}}function B(e,i,l){let s=e.at,h=e.pages?.routes()??[];if(e.routing!=="address"||typeof window>"u")return R(s,e.app,i,l,h);let{pathname:r,search:o,hash:f}=window.location,p=W(r,e.basePath),u=I({routing:"address",...e.basePath===void 0?{}:{basePath:e.basePath},face:s.face}),n=u==="pages",m={...s,face:u,...p===null?{}:n?{path:p+o}:{stop:x(e.basePath)??s.stop}},d=R(m,e.app,i,l,h),c=n?d.path===m.path?null:S(d.path,e.basePath===void 0?{}:{basePath:e.basePath}):d.stop===b(A(m.stop))?null:r+o+d.stop;return p!==null&&c!==null&&c!==r+o+f&&window.history.replaceState(window.history.state,"",c),d}export{R as settle,B as settleAt};
@@ -0,0 +1 @@
1
+ import{a as L}from"./chunk.UHX4WTM7.js";import{a as ae,b as ie,c as de,d as se,e as C,f as V,g as le}from"./chunk.IKX4VDTW.js";import{a as ue}from"./chunk.RNEJYIQ7.js";import{c as T,e as oe}from"./chunk.TBQOSI4J.js";import{a as j,b as Q,c as ee,d as ne,f as B,m as re,n as b,o as te,p as P}from"./chunk.KWQ7QOHD.js";import{b as G,d as fe,e as ye,g as pe,h as me,i as ce}from"./chunk.H7KCWCB4.js";import{C as x,Ca as z,Cb as Y,Db as q,Eb as M,I as W,R as H,U as v,_ as K,ca as J,ja as F,la as X,qa as E,ra as A,sa as Z,ta as O,ua as N}from"./chunk.AS4CQBOQ.js";var ge=e=>e.caption?.trim()||e.name,_=e=>A(e)?`${ge(e)}, ${Z(e)}`:ge(e);function Qe(e){let n=Math.max(0,Math.round(e)),o=a=>String(a).padStart(2,"0"),r=Math.floor(n/3600),t=Math.floor(n%3600/60);return r>0?`${r}:${o(t)}:${o(n%60)}`:`${t}:${o(n%60)}`}function Ee(e){let n=e?.fields?.shape??{};return Object.keys(n).filter(o=>{let r=x(n[o]);for(;r?.innerType;)r=x(r.innerType);return N(n[o])!==void 0||r?.type==="array"&&N(r.element)!==void 0})}function en(e,n){for(let o of Ee(n)){let r=O(e[o]).find(t=>E(t)||A(t));if(r)return r}}var R=e=>{try{return e()}catch{return null}},Re=e=>typeof e=="string"&&ae.includes(e);function Be(e){if(e!==void 0)return Re(e)?e:e&&typeof e=="object"&&typeof e.expr=="string"?{expr:R(()=>T(e.expr))}:"neutral"}var Pe=4;function xe(e){let n=typeof e.list=="string"?R(()=>T(e.list)):null,o=e.sort,r=typeof o=="string"?o:o&&typeof o=="object"&&typeof o.by=="string"?o.by:void 0,t=o&&typeof o=="object"?o.direction:void 0,a=n,d;if(n&&r!==void 0)if(t==="choices")d=r;else{let y=R(()=>T(r));a=y?{t:"call",fn:"sort",args:[n,y,{t:"lit",value:t==="desc"?"desc":"asc",at:0}],at:0}:null}let l=typeof e.limit=="number"&&Number.isInteger(e.limit)&&e.limit>=1?Math.min(e.limit,C):void 0,i=e.group,s=typeof i=="string"?i:i&&typeof i=="object"&&typeof i.by=="string"?i.by:void 0,f=i&&typeof i=="object"&&i.headings&&typeof i.headings=="object"?i.headings:{};return{t:"list",source:a,...d?{choiceOrder:d}:{},...l?{limit:l}:{},...s?{group:{by:s,headings:Object.fromEntries(Object.entries(f).filter(y=>typeof y[1]=="string"))}}:{},...typeof e.empty=="string"?{empty:e.empty}:{},as:e.as==="card"?"card":"row"}}function he(e,n=1,o=""){if(!Array.isArray(e)||n>Pe)return[];let r={};return e.flatMap(t=>{if(!t||typeof t!="object"||Array.isArray(t))return[];let a=t,d=p=>typeof p=="string"?R(()=>oe(p)):null,l=p=>typeof p=="string"?R(()=>T(p)):null,i=Be(a.tone),s=typeof a.label=="string"?a.label:void 0,f=p=>Object.hasOwn(a,p),y=typeof a.currency=="string"&&/^[A-Z]{3}$/.test(a.currency)?a.currency:void 0,u=f("list")?"list":f("headline")?"headline":typeof a.figure=="string"?"number":ve.find(f);if(!u)return[];let m=r[u]=(r[u]??0)+1,c=a.key,k=typeof c=="string"&&c?c:`${o}${u}.${m}`;return[{...(()=>{switch(u){case"list":return xe(a);case"number":{let p=de.includes(a.as)?a.as:void 0,U=se.includes(a.emphasis)?a.emphasis:void 0;return{t:u,value:l(a.figure),...p?{as:p}:{},...y?{currency:y}:{},...s?{label:d(s)}:{},...U?{emphasis:U}:{}}}case"headline":case"title":return{t:u,parts:d(a[u])};case"text":case"badge":return{t:u,parts:d(a[u]),...i?{tone:i}:{}};case"field":{let p=ie.includes(a.as)?a.as:void 0;return{t:u,field:String(a.field),...p?{as:p}:{},...y?{currency:y}:{},...s?{label:s}:{}}}case"image":return{t:u,field:String(a.image),as:a.as==="gallery"?"gallery":"thumb",...s?{label:s}:{}};case"progress":{let p=a.progress??{};return{t:u,value:l(p.value),max:l(p.max),...s?{label:d(s)}:{}}}case"group":return{t:u,blocks:he(a.group,n+1,`${k}.`),direction:a.direction==="row"?"row":"column"};case"when":return{t:u,when:l(a.when),show:he(a.show,n+1,`${k}.`)};default:return{t:u}}})(),key:k}]})}var ve=["title","text","badge","field","image","progress","group","when","divider","figure"],g="\u2014",Fe=500;function w(e,n){if(!e)return{ok:!1,problem:"an expression that does not parse"};try{return{ok:!0,value:B(e,{graph:n.graph??re,subject:n.node,kinds:n.kinds,today:n.today,budget:n.budget??Fe})}}catch(o){return{ok:!1,problem:o instanceof Error?o.message:String(o)}}}var Ne=(e,n,o)=>!e.format&&e.expr?.t==="ident"&&typeof o=="string"&&n.fields[e.expr.name]?.format==="markdown";function S(e,n,o){if(!e)return{text:g,problem:"a template that does not parse"};let r,t;return{text:e.map(d=>{if(d.text!==void 0)return d.text;let l=w(d.expr??null,n);if(!l.ok)return r??=`{${d.source??""}}: ${l.problem}`,g;if(Ne(d,n,l.value))return n.glance?fe(l.value,{markdown:!0}):o&&e.length===1?(t=!0,l.value):ye(l.value);let i=!d.format&&d.expr?.t==="ident"&&typeof l.value=="number"?Oe(n,d.expr.name):void 0;return te(d,i?M(l.value,i):b(l.value,d.format,n.today,d.formatArgs,n.money,P(n.schema)))}).join(""),...r?{problem:r}:{},...t?{markdown:t}:{}}}var Me=" \xB7 ";function Ce(e,n){if(!e||!n.node)return;let o=[[]];for(let d of e){if(d.text===void 0){o[o.length-1].push(d);continue}d.text.split(Me).forEach((i,s)=>{s>0&&o.push([]),i!==""&&o[o.length-1].push({text:i})})}if(o.length<2)return;let r=d=>{let[l]=d;if(!(d.length!==1||!l||l.format||l.expr?.t!=="ident"))return n.fields[l.expr.name]?.type==="enum"?l.expr.name:void 0},t=0,a=o.flatMap(d=>{let l=r(d);if(l){let s=Object.hasOwn(n.node,l)?n.node[l]:void 0;return s==null||s===""?[]:(t++,[{text:G(n.definition,l,s),field:l}])}let i=S(d,n).text.trim();return i===""||i===g?[]:[{text:i}]});return t>0?a:void 0}function be(e,n){if(e===void 0)return;if(typeof e=="string")return e;let o=w(e.expr,n);return o.ok&&Re(o.value)?o.value:"neutral"}function Ve(e){if(typeof e=="string")try{let n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"?n.href:void 0}catch{return}}var Ae=(e,n)=>{let o=e.fields[n]?.type;return o==="phone"||o==="place"||o==="duration"?o:pe(e.definition,n)},Oe=(e,n)=>Y(e.definition?.fields?.shape?.[n]);function Le(e,n,o,r,t){if(n==null||n==="")return g;if(typeof n=="boolean")return n?"yes":"no";if(r)return b(n,r,o.today,[],t?{...o.money,currency:t}:o.money);let a=o.fields[e];if(o.definition?.display?.format?.[e])return G(o.definition,e,n);let d=me(Ae(o,e),n,o.money?.locale);if(d!==void 0)return d;if(a?.type==="date")return b(n,"date",o.today,[],o.money);if(a?.type==="datetime"&&typeof n=="string")return H(n,o.money?.locale,o.money?.timeZone);if(a?.type==="enum"&&typeof n=="string")return G(o.definition,e,n);let l=typeof n=="number"?Oe(o,e):void 0;if(l)return M(n,l);if(typeof n=="number")return v(n,o.money?.locale,{});let i=O(n);return i[0]?i.map(_).join(", "):Array.isArray(n)?n.map(s=>String(s)).join(", "):typeof n=="object"?g:String(n)}function _e(e,n,o,r,t){return typeof e!="number"?String(e):n==="money"?q(e,o?{...t,currency:o}:t):n==="percent"?b(e,n,r,[],t):v(e,t?.locale)}var h=(e,n)=>n?{...e,problem:n}:e;function we(e){return e.firstHeading===void 0?e:{...e,firstHeading:void 0}}function Ie(e,n,o){switch(e.t){case"title":{let r=S(e.parts,n);return h({t:"title",text:r.text},r.problem)}case"text":{let r=S(e.parts,n,!0),t=be(e.tone,n),a=n.glance&&!r.problem?Ce(e.parts,n):void 0;return h({t:"text",text:r.text,...t?{tone:t}:{},...r.markdown?{markdown:r.markdown}:{},...a?{runs:a}:{}},r.problem)}case"badge":{let r=S(e.parts,n);return h({t:"badge",text:r.text,tone:be(e.tone,n)??"neutral"},r.problem)}case"field":{let r=e.label??F(n.definition,e.field);if(!n.node)return{t:"field",field:e.field,label:r,text:g,problem:`"${e.field}" names a field, and these blocks are about no one record`};let t=e.as===void 0?n.kinds.get(n.node.kind)?.linked?.get(e.field):void 0;if(t){let y=z(Object.hasOwn(n.node,e.field)?n.node[e.field]:void 0,t);return{t:"field",field:e.field,label:r,text:y.length>0?"linked record":g,...y.length>0?{linked:{relation:t,refs:y}}:{}}}let a=n.kinds.get(n.node.kind)?.computed?.has(e.field),d,l;if(a){let y=w({t:"ident",name:e.field,at:0},n);y.ok?d=y.value!==null&&typeof y.value=="object"?b(y.value,void 0,n.today,[],n.money,P(n.schema)):y.value:l=y.problem}else d=Object.hasOwn(n.node,e.field)?n.node[e.field]:void 0;let i=e.as!==void 0?void 0:n.fields[e.field]?.type==="url"?Ve(d):ce(Ae(n,e.field),d),s=R(()=>Le(e.field,d,n,e.as,e.currency))??g,f=n.fields[e.field]?.type==="app-link"&&e.as===void 0&&typeof d=="string"?d:void 0;return h({t:"field",field:e.field,label:r,text:s,...i?{href:i}:{},...f?{app:f}:{}},l)}case"image":{let r=O(n.node&&Object.hasOwn(n.node,e.field)?n.node[e.field]:null),t=e.as==="gallery"?r:r.filter(a=>E(a)||A(a)).slice(0,1);return{t:"image",field:e.field,label:e.label??F(n.definition,e.field),as:e.as,files:t,text:t.map(_).join(", ")||g}}case"progress":{let r=w(e.value,n),t=w(e.max,n),a=e.label?S(e.label,n):{text:"Progress"},d=a.text,l=r.ok?t.ok?a.problem:t.problem:r.problem;return r.ok&&t.ok&&typeof r.value=="number"&&typeof t.value=="number"&&Number.isFinite(r.value)&&Number.isFinite(t.value)&&t.value>0?h({t:"progress",label:d,value:r.value,max:t.value,text:`${b(r.value,void 0,n.today)} of ${b(t.value,void 0,n.today)}`},l):h({t:"progress",label:d,text:g},l)}case"group":return{t:"group",direction:e.direction,blocks:Se(e.blocks,we(n))};case"when":{let r=w(e.when,n),t=r.ok&&r.value===!0;return h({t:"when",shown:t,blocks:t?Se(e.show,we(n)):[]},r.ok?void 0:r.problem)}case"divider":return{t:"divider"};case"figure":return{t:"figure"};case"headline":{let r=S(e.parts,n),t=Math.min(6,Math.max(1,(o?n.firstHeading:void 0)??n.heading??3));return h({t:"headline",level:t,text:r.text},r.problem)}case"number":{let r=w(e.value,n),t=!r.ok||r.value===null||typeof r.value=="object"?g:_e(r.value,e.as,e.currency,n.today,n.money),a=e.label?S(e.label,n):void 0;return h({t:"number",text:t,...a?{label:a.text}:{},...e.emphasis?{emphasis:e.emphasis}:{}},r.ok?a?.problem:r.problem)}case"list":return $e(e,n)}}function Se(e,n){let o=e.findIndex(r=>r.t==="headline");return e.map((r,t)=>({...Ie(r,n,t===o),key:r.key}))}var De=new Set(["every","some","sum","min","max","sort"]);function kn(e,n){let o=new Set,r=new Set,t=i=>{if(i)switch(i.t){case"ident":o.add(i.name);return;case"list":i.items.forEach(t);return;case"member":return t(i.object);case"unary":return t(i.operand);case"binary":return t(i.left),t(i.right);case"where":return t(i.set);case"call":i.args.forEach((s,f)=>{f===1&&De.has(i.fn)||t(s)});return;default:return}},a=i=>{for(let s of i??[])t(s.expr)},d=(i,s)=>{i.forEach((f,y)=>{let u=s[y];if(u)switch(f.t){case"field":case"image":o.add(f.field);return;case"title":case"text":case"badge":case"headline":a(f.parts);return;case"number":t(f.value),a(f.label);return;case"progress":t(f.value),t(f.max);return;case"group":u.t==="group"&&d(f.blocks,u.blocks);return;case"when":u.t==="when"&&u.shown&&d(f.show,u.blocks);return;case"list":if(u.t==="list")for(let m of u.members)r.add(m.id);return;default:return}})};d(e,n);let l=n[0];return{fields:o,records:r,...e[0]?.t==="title"&&l?.t==="title"?{title:l.text}:{}}}function $e(e,n){let o=Math.min(6,(n.heading??3)+1),r=w(e.source,n);if(!r.ok)return{t:"list",as:e.as,failed:!0,members:[],headingLevel:o,more:0,problem:r.problem};let t=r.value,a=t instanceof j?t.nodes:t!==null&&typeof t=="object"&&!Array.isArray(t)?[t]:[];e.choiceOrder&&n.schema&&(a=Ue(a,e.choiceOrder,n.schema));let d=a.length,l=a.slice(0,e.limit??C),i=l.slice(0,V),s=l.slice(V),f=(e.limit===void 0?d:l.length)-i.length,y=c=>e.group&&n.schema&&c.length>0?We(c,e.group,n.schema,n.graph):void 0,u=y(i),m=s.length>0?y(l):void 0;return{t:"list",as:e.as,failed:!1,members:i,...s.length>0?{rest:s}:{},...u?{groups:u}:{},...m?{everyGroup:m}:{},headingLevel:o,...i.length===0&&e.empty?{empty:e.empty}:{},more:f,total:d}}function I(e,n,o){let r=e.tryDefinition(n)?.fields?.shape,t=r&&Object.hasOwn(r,o)?L(r[o]):void 0;return t?.type==="enum"?t.options??[]:[]}var D=(e,n)=>Object.hasOwn(e,n)?e[n]:void 0;function Ue(e,n,o){let r=t=>{let a=I(o,t.kind,n).indexOf(String(D(t,n)));return a<0?Number.MAX_SAFE_INTEGER:a};return e.map((t,a)=>({node:t,i:a,rank:r(t)})).sort((t,a)=>t.rank-a.rank||t.i-a.i).map(t=>t.node)}function We(e,n,o,r){let t=e.some(i=>I(o,i.kind,n.by).length>0)?void 0:le(n.by);if(t&&r)return He(e,t,n.headings,o,r);let a=[];for(let i of e)for(let s of I(o,i.kind,n.by))a.includes(s)||a.push(s);let d=[];for(let i of a){let s=e.filter(y=>D(y,n.by)===i);if(s.length===0)continue;let f=o.tryDefinition(s[0].kind);d.push({value:i,heading:n.headings[i]??K(G(f,n.by,i)),members:s})}let l=e.filter(i=>!a.includes(String(D(i,n.by))));return l.length>0&&d.push({value:null,members:l}),d}function He(e,n,o,r,t){let a=u=>n.way??(Object.hasOwn(r.tryDefinition(u.kind)?.edges??{},n.edge)?"out":"in"),d=new Map,l=[],i=P(r),s;for(let u of e){let m=a(u)==="out"?t.out(u.id,n.edge):t.in(u.id,n.edge);m.length===0&&l.push(u);for(let c of m){s??=c.kind;let k=d.get(c.id)??{node:c,members:[]};k.members.push(u),d.set(c.id,k)}}let f=[...d.values()].map(({node:u,members:m})=>({value:u.id,heading:o[u.id]??i(u),members:m})).sort((u,m)=>u.heading.localeCompare(m.heading,void 0,{numeric:!0}));!s&&e[0]&&a(e[0])==="out"&&(s=(r.tryDefinition(e[0].kind)?.edges??{})[n.edge]?.to?.[0]);let y=s&&s!=="*"?X(r.tryDefinition(s),s):void 0;return l.length>0&&f.push({value:null,...y?{heading:`No ${y}`}:{},members:l}),f}function ke(e){return e.t==="list"||e.t==="headline"||e.t==="number"||e.t==="image"&&e.as==="gallery"?!0:e.t==="group"?e.blocks.some(ke):e.t==="when"?e.show.some(ke):!1}function je(e,n){let o=e.tryDefinition(n)?.fields?.shape??{},r={};for(let[t,a]of Object.entries(o)){let d=L(a);d&&(r[t]=d)}return r}var Te=new WeakMap;function $(e){let n=Te.get(e);return n||Te.set(e,n=ue(e)),n}function Ke(e,n,o,r={}){let t=$(e),a={},d={},l=i=>{if(i instanceof j)return i.nodes.map(s=>l(s));if(Array.isArray(i))return i.map(s=>l(s));if(i!==null&&typeof i=="object"){let s=i;return{id:s.id,kind:s.kind,label:J(e.tryDefinition(s.kind),s)}}return i};for(let[i,s]of t.get(o?o.kind:ee)?.computed??[])try{let f=[],y=B(s,{graph:n,subject:o,kinds:t,...r.today?{today:r.today}:{},...r.budget?{budget:r.budget}:{},...r.linked?{linked:r.linked}:{},onUnread:u=>f.push(u)});f.length>0&&(y===null||y instanceof j&&y.nodes.length===0)?d[i]=Q(f[0]):a[i]=l(y)}catch(f){if(!(f instanceof ne))throw f;d[i]=f.sentence}return{values:a,refused:d}}function Tn(e,n,o){let{values:r}=Ke(e,n,o);if(Object.keys(r).length===0)return o;let t=a=>Array.isArray(a)?a.map(t):a!==null&&typeof a=="object"?a.label:a;return{...o,...Object.fromEntries(Object.entries(r).map(([a,d])=>[a,t(d)]))}}var Je=500,Xe=2e4,Ge=new WeakMap;function Ze(e,n){let o=Ge.get(e);o||Ge.set(e,o=new Map);let r=o.get(n);return r||o.set(n,r=je(e,n)),r}function xn(e,n,o,r={}){if(n&&typeof e.seenBy!="function")throw new TypeError("blockContextFor: a seat is read from a store (its `seenBy`); a bare { graph, schema } is read as it is handed, with no principal");let t=n?e.seenBy(n):e,a=n&&o?t.graph.getNode(o.id)??null:o,d=t.schema,l=a&&d.tryDefinition(a.kind),i=!a||(r.slot??"page")==="page",{money:s,firstHeading:f}=r;return{node:a,graph:t.graph,schema:d,kinds:$(d),fields:a?Ze(d,a.kind):{},definition:l||void 0,today:r.today??t.today?.()??W(s?.timeZone),money:s,heading:r.heading??(i?2:3),firstHeading:f,budget:r.budget??(i?Xe:Je),...i?{}:{glance:!0}}}export{ge as a,Qe as b,Ee as c,en as d,he as e,Se as f,kn as g,ke as h,Ke as i,Tn as j,xn as k};
@@ -5,43 +5,43 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
6
6
  <title>Graview preview</title>
7
7
  <link rel="preload" href="/graview/document" as="fetch" crossorigin="anonymous">
8
- <link rel="modulepreload" href="/chunk.E37V2EJM.js">
9
- <link rel="modulepreload" href="/chunk.FHZBXMXR.js">
10
- <link rel="modulepreload" href="/chunk.F6HMZL65.js">
8
+ <link rel="modulepreload" href="/chunk.3VFYSXMQ.js">
9
+ <link rel="modulepreload" href="/chunk.JT3IZIU5.js">
10
+ <link rel="modulepreload" href="/chunk.5K6KX3UC.js">
11
11
  <link rel="modulepreload" href="/chunk.S5MQVPLF.js">
12
12
  <link rel="modulepreload" href="/chunk.Q5WEOX3Q.js">
13
- <link rel="modulepreload" href="/chunk.MGWMGLWE.js">
13
+ <link rel="modulepreload" href="/chunk.6YD2DLIC.js">
14
14
  <link rel="modulepreload" href="/chunk.KWQ7QOHD.js">
15
- <link rel="modulepreload" href="/chunk.6BJBPDF3.js">
15
+ <link rel="modulepreload" href="/chunk.XSNAG4JT.js">
16
16
  <link rel="modulepreload" href="/chunk.XWAMQPUM.js">
17
17
  <link rel="modulepreload" href="/chunk.SDO3U72B.js">
18
18
  <link rel="modulepreload" href="/chunk.AS4CQBOQ.js">
19
19
  <link rel="modulepreload" href="/chunk.2AZTW66C.js">
20
20
  <link rel="modulepreload" href="/chunk.AJZBJBMO.js">
21
- <link rel="modulepreload" href="/chunk.CSDERNQV.js">
22
- <link rel="modulepreload" href="/chunk.J7G3AATY.js">
23
- <link rel="modulepreload" href="/chunk.B6KT6BTG.js">
24
- <link rel="modulepreload" href="/chunk.ZBR2QY67.js">
25
- <link rel="modulepreload" href="/chunk.K46YRA65.js">
26
- <link rel="modulepreload" href="/chunk.UJKT2G6M.js">
21
+ <link rel="modulepreload" href="/chunk.JQLR6KO2.js">
22
+ <link rel="modulepreload" href="/chunk.XXDBZQNY.js">
23
+ <link rel="modulepreload" href="/chunk.JF3GD4H5.js">
24
+ <link rel="modulepreload" href="/chunk.UR3XYOQ6.js">
25
+ <link rel="modulepreload" href="/chunk.ONEYVLC2.js">
26
+ <link rel="modulepreload" href="/chunk.WQONZBA3.js">
27
27
  <link rel="modulepreload" href="/chunk.UGFDSE37.js">
28
- <link rel="modulepreload" href="/chunk.DLFWBG33.js">
29
- <link rel="modulepreload" href="/chunk.RYRTKIKB.js">
28
+ <link rel="modulepreload" href="/chunk.NWA7Q6CI.js">
29
+ <link rel="modulepreload" href="/chunk.WP5W44Y4.js">
30
30
  <link rel="modulepreload" href="/chunk.M5GJHVWZ.js">
31
- <link rel="modulepreload" href="/chunk.HZGVEHEN.js">
31
+ <link rel="modulepreload" href="/chunk.HZCA3UWJ.js">
32
32
  <link rel="modulepreload" href="/chunk.JBW3DI7E.js">
33
- <link rel="modulepreload" href="/chunk.CBUSFM3E.js">
33
+ <link rel="modulepreload" href="/chunk.AGIO2GRV.js">
34
34
  <link rel="modulepreload" href="/chunk.NIVTK2W5.js">
35
35
  <link rel="modulepreload" href="/chunk.PXQVXBNG.js">
36
- <link rel="modulepreload" href="/chunk.FPASZ4RD.js">
37
- <link rel="modulepreload" href="/chunk.2YABX3SC.js">
36
+ <link rel="modulepreload" href="/chunk.6QYJ2K6K.js">
37
+ <link rel="modulepreload" href="/chunk.3MMLRSRC.js">
38
38
  <link rel="modulepreload" href="/chunk.DQOCBKC3.js">
39
- <link rel="modulepreload" href="/chunk.V5FIZIX2.js">
40
- <link rel="modulepreload" href="/chunk.DQHPEKWK.js">
41
- <link rel="modulepreload" href="/chunk.LSLLKICK.js">
42
- <link rel="modulepreload" href="/chunk.EAUVEVVO.js">
43
- <link rel="modulepreload" href="/chunk.C2UFMFJ3.js">
44
- <link rel="modulepreload" href="/chunk.ZJ2VS4M4.js">
39
+ <link rel="modulepreload" href="/chunk.OHSJQYJN.js">
40
+ <link rel="modulepreload" href="/chunk.DEUTHHGI.js">
41
+ <link rel="modulepreload" href="/chunk.EPUBSKKL.js">
42
+ <link rel="modulepreload" href="/chunk.ATDU5Y7V.js">
43
+ <link rel="modulepreload" href="/chunk.AQQZY6OY.js">
44
+ <link rel="modulepreload" href="/chunk.BCWPV4WR.js">
45
45
  <link rel="modulepreload" href="/chunk.Y5ARSVH4.js">
46
46
  <link rel="modulepreload" href="/chunk.PKUDIWIF.js">
47
47
  <link rel="modulepreload" href="/chunk.VW2VCPJX.js">
@@ -50,7 +50,7 @@
50
50
  <link rel="modulepreload" href="/chunk.IW7YFPGG.js">
51
51
  <link rel="modulepreload" href="/chunk.MB7LKKUD.js">
52
52
  <link rel="modulepreload" href="/chunk.WVUJXDXZ.js">
53
- <link rel="modulepreload" href="/chunk.OYHQSXNC.js">
53
+ <link rel="modulepreload" href="/chunk.ZIEHF67C.js">
54
54
  <link rel="modulepreload" href="/chunk.UHX4WTM7.js">
55
55
  <link rel="modulepreload" href="/chunk.IKX4VDTW.js">
56
56
  <link rel="modulepreload" href="/chunk.RNEJYIQ7.js">
@@ -62,9 +62,9 @@
62
62
  <link rel="modulepreload" href="/chunk.HDRD33II.js">
63
63
  <link rel="modulepreload" href="/chunk.DX357TZ3.js">
64
64
  <link rel="modulepreload" href="/chunk.H7KCWCB4.js">
65
- <link rel="modulepreload" href="/chunk.L24FCXZ7.js">
66
- <link rel="modulepreload" href="/chunk.ZEAH57AZ.js">
67
- <script>(()=>{const later=["/chunk.GFLAGZSB.js","/chunk.4XOWRYRU.js","/chunk.WSTBCWW7.js","/chunk.HJCQ6I3S.js","/chunk.BNPQUI3F.js","/chunk.6RY6OSE6.js","/chunk.SZ34UAQ3.js","/chunk.WBHM5I3I.js","/chunk.VC3BX2ZF.js","/chunk.Q7RQC3F7.js","/chunk.6USUVORO.js","/chunk.FOFLD64U.js","/chunk.BS2SJC2P.js","/chunk.UY7IOVR6.js","/chunk.64WM4IBI.js","/chunk.JDMXZFSG.js","/chunk.TI4OSTQV.js","/chunk.VSAPJAT3.js"],first=[...document.querySelectorAll('link[rel="modulepreload"]')];let left=first.length;const go=()=>{for(const href of later){const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};if(left===0)return go();const one=()=>{if(--left===0)go()};for(const link of first){link.addEventListener("load",one,{once:true});link.addEventListener("error",one,{once:true})}})()</script>
65
+ <link rel="modulepreload" href="/chunk.6BDM2XRX.js">
66
+ <link rel="modulepreload" href="/chunk.UOXFALRL.js">
67
+ <script>(()=>{const later=["/chunk.X233NILF.js","/chunk.BFKV4GKP.js","/chunk.WSTBCWW7.js","/chunk.HJCQ6I3S.js","/chunk.BNPQUI3F.js","/chunk.6RY6OSE6.js","/chunk.V3QUTJR2.js","/chunk.WBHM5I3I.js","/chunk.VC3BX2ZF.js","/chunk.Q7RQC3F7.js","/chunk.F37DHXA2.js","/chunk.3OSGN463.js","/chunk.F5PBK4TF.js","/chunk.6SOUQNXR.js","/chunk.64WM4IBI.js","/chunk.5ESCD57M.js","/chunk.TI4OSTQV.js","/chunk.LVEFQLGQ.js"],first=[...document.querySelectorAll('link[rel="modulepreload"]')];let left=first.length;const go=()=>{for(const href of later){const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};if(left===0)return go();const one=()=>{if(--left===0)go()};for(const link of first){link.addEventListener("load",one,{once:true});link.addEventListener("error",one,{once:true})}})()</script>
68
68
  <style>html,body{margin:0;height:100%}#graview-app{min-height:100dvh}</style>
69
69
  </head>
70
70
  <body>