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
@@ -1,14 +0,0 @@
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 lt,B as ce,C as In,D as We,E as Ge,F as _r,G as Fn,H as Re,I as Yr,J as Qr,K as H,L as dt,M as yt,N as Zr,O as ht,P as Yt,Q as Xr,R as J,S as Qt,T as ae,U as Wn,a as j,b as we,c as z,d as Ut,e as On,f as Hn,g as st,h as Z,i as ye,j as ne,k as C,l as X,m as K,n as ve,o as Vt,p as Se,q as ie,r as Vr,s as ft,t as jt,u as _,v as Fe,w as jr,x as zt,y as Ae,z as zr}from"./chunk.B6KT6BTG.js";import{a as Ie}from"./chunk.ZBR2QY67.js";import{a as _t,c as Y}from"./chunk.K46YRA65.js";import{b as Nn,c as Gr,d as Ur}from"./chunk.UJKT2G6M.js";import{a as Kr,d as Br,e as qr}from"./chunk.UGFDSE37.js";import{a as Or,c as Hr,f as Ir,g as Fr,i as Wr,j as Dr}from"./chunk.DLFWBG33.js";import{a as Cr,b as Ar,c as Rr,d as $n}from"./chunk.RYRTKIKB.js";import{b as Pr}from"./chunk.M5GJHVWZ.js";import{a as Lr,b as Tr,d as Kt,e as Mr,f as Er,i as Bt}from"./chunk.HZGVEHEN.js";import{a as qt,b as Gt}from"./chunk.PXQVXBNG.js";import{a as Nt,b as Ga,c as Ua,d as Ot,e as Va}from"./chunk.FPASZ4RD.js";import{b as Xa,c as or,e as ir,f as Ln}from"./chunk.2YABX3SC.js";import{a as Rn,b as rr}from"./chunk.DQOCBKC3.js";import{a as Wt,b as Dt,c as kr,e as br}from"./chunk.LSLLKICK.js";import{a as it,b as nr,e as ar}from"./chunk.EAUVEVVO.js";import{m as xr}from"./chunk.ZJ2VS4M4.js";import{a as lr,b as dr,c as cr,e as Sr,f as En,h as Ft}from"./chunk.PKUDIWIF.js";import{d as gr,e as mr,f as fr,g as yr,n as hr,o as wr,q as vr,s as It}from"./chunk.VW2VCPJX.js";import{a as Tn}from"./chunk.UKAPFIPJ.js";import{a as Cn,b as Qa,c as Za}from"./chunk.UT6642FC.js";import{a as sr}from"./chunk.IW7YFPGG.js";import{c as Ja,d as er,j as mt}from"./chunk.OYHQSXNC.js";import{r as An,s as tr}from"./chunk.6MADC6DM.js";import{g as Ht}from"./chunk.HDRD33II.js";import{b as ja,c as za,d as _a,e as Ya}from"./chunk.DX357TZ3.js";import{C as Mn,K as $r,N as Nr,e as Ba,f as qa,j as Ko,u as pr,v as ur}from"./chunk.6BJBPDF3.js";import{$ as oe,Ea as Ka,G as He,L as Ma,N as Ea,Q as $a,R as U,S as Pn,V as Na,W as Oa,_ as Ha,ca as Ia,da as Fa,fa as Wa,ja as ot,la as Da,na as Et,qa as $t,r as Ta,v as Oe}from"./chunk.XWAMQPUM.js";import{a as La}from"./chunk.SDO3U72B.js";import{$c as Ca,J as ga,U as gt,Vc as bn,Wb as ka,Xa as wa,Za as va,Zb as ba,_b as xa,_c as Tt,ba as rt,bd as Mt,ca as de,ea as ze,fa as Rt,gb as kn,ha as qe,hb as Sa,ja as ma,ka as fa,kd as xn,la as _e,ld as Aa,qb as Lt,qd as Ra,vc as Pa,wa as ya,xa as ha}from"./chunk.AS4CQBOQ.js";import{b as F}from"./chunk.AJZBJBMO.js";function Jr(e,t,n={}){let a=e.graph.getNode(t);if(!a)return;let r=e.schema.tryDefinition(a.kind),o=s=>de(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 b={edgeKind:s.kind,direction:d,...g?{description:g}:{},targets:[]};return l.set(L,b),b})()).targets.push({id:p.id,kind:p.kind,label:o(p)})}return{id:t,kind:a.kind,label:o(a),fields:_a(mt(e.schema,e.graph,a),r),violations:kn(e.violations(n.context),[t]),actions:Tn(e,[t],{focus:t,...n.principal?{principal:n.principal}:{},...n.context?{context:n.context}:{}}),links:[...l.values()].map(s=>{let d=ja(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 Ye(e,t,n={}){return{kind:t,members:e.graph.nodesOfKind(t),actions:Tn(e,[],{kindSelection:[t],...n.principal?{principal:n.principal}:{},...n.context?{context:n.context}:{}})}}function eo(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 Qe(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 De=F(He(),1);var wt=F(He(),1);var Le=F(U(),1),qo={problems:"Problems",search:"Search",map:"Connections",places:"Pictures","~draft":"A view drawn"},Go=e=>{try{return decodeURIComponent(e)}catch{return e}};function Uo(e,t,n={}){let{store:a}=e,r=a.schema,o=(n.base??"").replace(/\/$/,""),[l="/",s=""]=t.split("#")[0].split("?"),d=(x,$,T)=>({label:x,href:`${o}${$}`,path:$,...T?{current:T}:{}}),c=x=>{let $=n.registry?.sectionOf(x);return $?[$.path===void 0?{label:$.label}:d($.label,$.path)]:[]},p=x=>n.registry?.sectionOf(x)?.label,S=x=>{let $=p(x);return $===void 0?{}:{section:$}},[w,g,...L]=l.split("/").filter(Boolean).map(Go);if(w===void 0)return{as:"home",label:"Home",trail:[d("Home","/",!0)]};if(w==="places"&&g!==void 0&&L.length===0){let x=new URLSearchParams(s).get("of"),$=new Set(Fe(a,e.principal)),T=e.views?.places()??[],M=T.find(V=>$.has(V.kind)&&V.as===g&&(!x||j(r,V.kind)===x));if(M){let V=Ut(M.as,Tt(M,T)?j(r,M.kind):void 0);return{as:"place",kind:M.kind,label:M.title,...S(M.kind),trail:[...c(M.kind),d(M.title,V,!0)]}}}let I=L.length===0?we(r,w):void 0;if(I!==void 0){let x=d(qe(r,I),`/${j(r,I)}`);if(g===void 0)return{as:"list",kind:I,label:x.label,...S(I),trail:[...c(I),{...x,current:!0}]};let $=a.graph.getNode(g),T=$&&$.kind===I?de(r.tryDefinition(I),$):"Nothing lives here";return{as:"record",kind:I,id:g,label:T,...S(I),trail:[...c(I),x,d(T,z(r,I,g),!0)]}}let b=qo[w]??Vo((L.at(-1)??g??w).replace(/[-_]+/g," "));return{as:"page",label:b,trail:[d(b,l,!0)]}}var Vo=e=>e.charAt(0).toUpperCase()+e.slice(1),Dn=(0,wt.createContext)(null);function jo(e){let t=ce(),n=lt("/");return Y(e.context.store),Uo(e.context,`${t.pathname}${t.search}`,{registry:e.registry,base:n})}var zo={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},to={display:"flex",alignItems:"center",gap:6,minWidth:0},no={display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,lineHeight:"24px"};function ct({context:e,style:t}){let n=(0,wt.useContext)(Dn),a=(0,wt.useContext)(yt);return ht(a??Yo,"trail")||n?.registry?.without().has("trail")?null:(0,Le.jsx)(_o,{root:n??{context:e,registry:void 0},context:e,...t?{style:t}:{}})}function _o({root:e,context:t,style:n}){let a=jo(e);return a.trail.length<2?null:(0,Le.jsx)(Qo,{here:a,mark:a.as==="record"?{kind:a.kind,context:t}:void 0,...n?{style:n}:{},"data-testid":"page-trail"})}var Yo={count:()=>0,place:()=>()=>{},subscribe:()=>()=>{}};function Qo({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:{...ye,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?zo:{...to,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)(H,{to:o.path,style:{...ve,...to},...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:no,children:o.label})]}):(0,Le.jsx)("span",{style:no,children:o.label})]},`${l}:${o.label}`))})})}var A=F(U(),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 Zt(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 Ze=e=>`place:${e.kind}:${e.as}`;function pe(e,t){return Ut(t.as,Tt(t,e.views?.places()??[])?j(e.store.schema,t.kind):void 0)}function vt(e,t){let n=e.schema.tryDefinition(t);return e.graph.nodesOfKind(t).filter(a=>rt(n,a))}function Kn(e,t,n){let a=(o,l)=>Rt(e.schema,l,o),r=(typeof t=="string"?[t]:t).map(o=>a(vt(e,o).length,o)).join(" and ");return n?`${r} across ${a(vt(e,n).length,n)}`:r}function Bn({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=Zt(e,t).flatMap(w=>vt(r,w));if(!d)return null;let S=Zo(r,p,a,c);return(0,A.jsx)(An,{kind:t.kind,view:t.title,children:(0,A.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 Zo(e,t,n,a){let r=n?Mt({filter:n}).filter??[]:[];return r.length===0?t:Ft(t,{filter:r},{schema:e.schema,graph:e.graph,flagged:new Set(a)}).nodes}function Xo({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,A.jsx)(Bn,{context:r,place:o}):null}function Jo({context:e,kind:t}){let{store:n,views:a,invariantContext:r}=e,o=vt(n,t),l=n.schema.tryDefinition(t),s=_(n,t),c=a?.resolve(t,{cardinality:"many",fidelity:"full"})?.view,p=[...new Set(n.violations(r).flatMap(L=>L.nodeIds))];if(c&&!ot(c))return(0,A.jsx)(An,{kind:t,children:(0,A.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,A.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,A.jsx)(S,{node:L,fidelity:"summary",cardinality:"one",mode:"fullscreen",selected:!1,...p.includes(L.id)?{flagged:[L.id]}:{}},L.id):(0,A.jsx)("span",{style:{padding:"8px 14px",borderRadius:8,border:"1px solid var(--graview-edge-bright)",background:"var(--graview-ground)",color:"var(--graview-ink)"},children:de(l,L)},L.id)),o.length>w?(0,A.jsxs)("span",{style:{...C,alignSelf:"center",padding:"0 6px"},children:["+",o.length-w," more ",s.toLowerCase()]}):null]})}function qn(e){let{store:t}=e,n=jr(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=bn([...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:Ze(d),kind:d.kind,title:Ca(d,a,t.schema),to:pe(e,d),place:d})),...zt(e).filter(d=>!s.has(d)).map(d=>({key:`kind:${d}`,kind:d,title:_(t,d),to:`/${j(t.schema,d)}`}))]}var ao=.72,ei=540,ro=16/10;function ti(e){let t=(0,De.useRef)(null),[n,a]=(0,De.useState)(e);return(0,De.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 ni(e){for(let t=e.parentElement;t;t=t.parentElement)if(/(auto|scroll)/.test(getComputedStyle(t).overflowY))return t;return null}function ai(e){let[t,n]=(0,De.useState)(()=>typeof IntersectionObserver>"u");return(0,De.useLayoutEffect)(()=>{let a=e.current;if(t||!a)return;let r=new IntersectionObserver(o=>{o.some(l=>l.isIntersecting)&&(r.disconnect(),n(!0))},{root:ni(a),rootMargin:"50% 0px"});return r.observe(a),()=>r.disconnect()},[t,e]),t}function Gn({context:e,entry:t}){let{store:n,brand:a,principal:r}=e,{ref:o,width:l}=ti(ei),s=ai(o),d=l/ao,c=vt(n,t.kind),p=n.schema.tryDefinition(t.kind),S=c.length===0?Ye(n,t.kind,{...r?{principal:r}:{},...e.invariantContext?{context:e.invariantContext}:{}}).actions.affordances[0]:void 0,w=t.place!==void 0;return(0,A.jsxs)(H,{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,A.jsxs)("span",{ref:o,"data-testid":w?"place-picture":"kind-picture","aria-hidden":"true",inert:!0,style:{display:"block",position:"relative",width:"100%",aspectRatio:`${ro}`,overflow:"hidden",borderRadius:12,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",pointerEvents:"none"},children:[(0,A.jsx)("span",{style:{position:"absolute",left:0,top:0,width:d,height:d/ro,display:"grid",gridTemplateRows:"minmax(0, 1fr)",transform:`scale(${ao})`,transformOrigin:"0 0"},children:s?(0,A.jsx)(Kt.Provider,{value:null,children:t.place?(0,A.jsx)(Bn,{context:e,place:t.place}):(0,A.jsx)(Jo,{context:e,kind:t.kind})}):null}),c.length===0?(0,A.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,A.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,A.jsxs)("span",{style:{fontFamily:Hn,fontWeight:"var(--graview-weight-display)"},children:["No ",_(n,t.kind).toLowerCase()," yet"]}),S?(0,A.jsxs)("span",{style:C,children:["Begin with \u201C",S.label,"\u201D"]}):null]})}):null]}),(0,A.jsxs)("span",{style:{display:"grid",gap:2,minWidth:0},children:[(0,A.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[w?null:(0,A.jsx)(ie,{kind:t.kind,brand:a,schema:n.schema,size:8}),(0,A.jsx)("span",{style:{fontFamily:Hn,fontSize:"var(--graview-text-heading)",fontWeight:"var(--graview-weight-display)",lineHeight:1.3,overflowWrap:"anywhere",textWrap:"balance"},children:t.title})]}),(0,A.jsxs)("span",{style:C,children:[t.place?Kn(n,Zt(e,t.place),t.place.across):Kn(n,t.kind),!w&&p?.description?` \xB7 ${p.description}`:null]})]})]})}var oo={display:"grid",gap:"32px 28px",gridTemplateColumns:"repeat(auto-fill, minmax(min(420px, 100%), 1fr))"},ri=`
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 Un({context:e}){Y(e.store);let t=qn(e);return t.length===0?null:(0,A.jsxs)("section",{style:oo,"data-testid":"gallery",children:[(0,A.jsx)("style",{children:ri}),t.map(n=>(0,A.jsx)(Gn,{context:e,entry:n},n.key))]})}function Vn({context:e}){let{store:t}=e;Y(t);let n=bn(Te(e)).filter(r=>!r.hidden),a=qn(e);return(0,A.jsxs)(J,{context:e,style:st,children:[(0,A.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,A.jsx)("p",{style:ye,children:n.length===0?"None of its own yet":`${n.length} ${n.length===1?"picture":"pictures"}`}),(0,A.jsx)(ae,{context:e,children:"Pictures"}),(0,A.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,A.jsx)("div",{style:oo,"data-testid":"places",children:a.map(r=>(0,A.jsx)(Gn,{context:e,entry:r},r.key))}):null]})}function jn({context:e}){let{store:t,principal:n}=e;Y(t);let a=Ge(),r=We(),[o]=dt(),l=decodeURIComponent(a.as??""),[s,d]=(0,De.useState)(null),c=o.get("of"),p=o.get("filter"),w=Te(e).find(T=>T.as===l&&(!c||j(t.schema,T.kind)===c));if(!w)return(0,A.jsxs)(J,{context:e,children:[(0,A.jsx)(ae,{context:e,children:"No picture is called that."}),(0,A.jsx)("p",{style:ne,children:(0,A.jsxs)(H,{to:"/places",style:K,children:["The pictures there are ",(0,A.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]})})]});let g=_(t,w.kind),L=e.views?.resolve(w.kind,{cardinality:"many",fidelity:"full"},w.as)?.view,I=L?.flows===!0,b=L?.creates!==!1,x=Ye(t,w.kind,{...n?{principal:n}:{},...e.invariantContext?{context:e.invariantContext}:{}}),$=b?x.actions.affordances.map(T=>({affordance:T,mutation:t.allMutations().find(M=>M.name===T.mutation)})).filter(T=>T.mutation!==void 0):[];return(0,A.jsxs)(J,{context:e,style:st,children:[(0,A.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,A.jsx)(ct,{context:e}),(0,A.jsx)(ae,{context:e,children:w.title}),(0,A.jsxs)("p",{style:ne,"data-testid":"place-lede",children:[Kn(t,Zt(e,w),w.across),"."]}),p&&!I?(0,A.jsxs)("p",{style:{...C,margin:0},"data-testid":"place-narrowed",children:[`Only those where ${p.split(",").map(T=>T.replace(":"," is ")).join(" and ")}. `,(0,A.jsx)(H,{to:`?${(()=>{let T=new URLSearchParams(o);return T.delete("filter"),T.toString()})()}`,style:{...K,...C},children:"Show all"})]}):null,(0,A.jsx)("p",{style:{...C,margin:0,display:"flex",flexWrap:"wrap",gap:"4px 16px"},children:Zt(e,w).map((T,M)=>(0,A.jsxs)(H,{to:`/${j(t.schema,T)}`,style:{...K,...C},...M===0?{"data-testid":"place-as-list"}:{},children:["All ",(T===w.kind?g:_(t,T)).toLowerCase()," as a list ",(0,A.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]},T))})]}),(0,A.jsx)("div",{"data-testid":"place-lens","data-flows":I?"":void 0,style:I?{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:T=>{let M=T.target?.closest("[data-graview-pick]"),V=M?.getAttribute("data-graview-pick"),me=M?.getAttribute("data-graview-joins");if(me)try{let le=JSON.parse(me);if(Array.isArray(le)&&le.every(te=>typeof te=="string")){T.preventDefault(),d({at:Ze(w),ids:le});return}}catch{}if(!V)return;let be=t.graph.getNode(V);be&&(T.preventDefault(),r(z(t.schema,be.kind,V)))},children:(0,A.jsx)(Bn,{context:e,place:w,filter:p,...s?.at===Ze(w)?{chosen:s.ids}:{}})}),$.length>0?(0,A.jsx)("div",{style:{maxWidth:760,display:"grid",gap:40},"data-testid":"place-creators",children:$.map(({affordance:T,mutation:M})=>(0,A.jsxs)("section",{style:{...X,display:"grid",gap:14},children:[(0,A.jsx)("h2",{style:Z,children:M.title??M.name}),M.description?(0,A.jsx)("p",{style:{...C,margin:0,maxWidth:"58ch"},children:M.description}):null,(0,A.jsx)(Ie,{store:t,mutation:M,prefilled:T.args,open:T.open,label:T.label,...n?{principal:n}:{}})]},T.id))}):null]})}function oi(e,t=document){let n=qt(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||qt(l)===n)return o}for(let r of a)for(let o of r.querySelectorAll("h1, h2, h3, h4, h5, h6, [role=heading]"))if(qt(o.textContent??"")===n)return o;return null}function io(e,t={}){if(typeof document>"u"||typeof requestAnimationFrame>"u")return()=>{};let n=t.frames??120,a=0,r=()=>{let o=oi(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 G=F(He(),1);var Xt=F(He(),1);var Xe=F(U(),1);function so({context:e}){return oe()?(0,Xe.jsxs)(Xe.Fragment,{children:[(0,Xe.jsx)(ii,{context:e}),(0,Xe.jsx)(Hr,{face:"pages",on:e.quickAsk??!0})]}):null}function ii({context:e}){let{store:t}=e,n=oe(),{pathname:a}=ce(),r=(0,Xt.useRef)(n?.setSelection);return r.current=n?.setSelection,(0,Xt.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?[Oe(p.kind)]:[]}let c=l?we(t.schema,l):void 0;return c&&s?[decodeURIComponent(s)]:c?[Ta(c)]:[]})();o(c=>c.length===d.length&&c.every((p,S)=>p===d[S])?c:d)},[a]),null}var ue=F(He(),1);var co=F(Ko(),1);var se=F(U(),1);var si=(0,ue.lazy)($t(La(()=>(__graviewPreload(import.meta.url,["./chunk.K46YRA65.js","./chunk.UJKT2G6M.js","./chunk.UGFDSE37.js","./chunk.DLFWBG33.js","./chunk.RYRTKIKB.js","./chunk.M5GJHVWZ.js","./chunk.HZGVEHEN.js","./chunk.JBW3DI7E.js","./chunk.CBUSFM3E.js","./chunk.NIVTK2W5.js","./chunk.FPASZ4RD.js","./chunk.2YABX3SC.js","./chunk.DQOCBKC3.js","./chunk.V5FIZIX2.js","./chunk.DQHPEKWK.js","./chunk.LSLLKICK.js","./chunk.EAUVEVVO.js","./chunk.C2UFMFJ3.js","./chunk.ZJ2VS4M4.js","./chunk.Y5ARSVH4.js","./chunk.PKUDIWIF.js","./chunk.VW2VCPJX.js","./chunk.MB7LKKUD.js","./chunk.WVUJXDXZ.js","./chunk.OYHQSXNC.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.6BJBPDF3.js","./chunk.XWAMQPUM.js","./chunk.SDO3U72B.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.HWCHFQ7O.js")).then(e=>({default:e.TakeBack})))));function li({context:e,docked:t,at:n,...a}){let{store:r}=e,o=Y(r),[l]=(0,ue.useState)(()=>r.batches().length),s=(0,ue.useRef)(!1);return s.current||=o>0||!t&&l>0,s.current?(0,se.jsx)(ue.Suspense,{fallback:null,children:(0,se.jsx)(si,{context:e,docked:t,at:n,since:l,...a})}):null}function di(e,t,n){let{store:a,principal:r,embedded:o}=e;(0,ue.useEffect)(()=>{if(!n)return;let l=s=>{if(!qr(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))&&Kr(a,r)){s.preventDefault();try{Br(a,r)}catch{}}};return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[a,r,o,t,n])}function po({context:e,registry:t,root:n,children:a}){let r=(0,ue.useMemo)(Zr,[]),o=t?.without()??new Set;return di(e,n,!o.has("undo")),(0,se.jsxs)(yt.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,ue.useState)(!1);(0,ue.useLayoutEffect)(()=>r(!0),[]);let o=ht(t,"find"),l=ht(t,"undo"),s=ce(),d=ur();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,co.createPortal)((0,se.jsx)(lo,{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)(lo,{context:e,narrowsLists:S})}):null,!l&&!n.has("undo")?(0,se.jsx)(li,{context:e,docked:!0,at:s.pathname+s.search}):null,d?.own&&!n.has("undo")?(0,se.jsx)(zr,{context:e,own:d.own}):null]})}function lo({context:e,narrowsLists:t}){return(0,se.jsx)(yt.Provider,{value:null,children:(0,se.jsx)(Wn,{context:e,narrowsLists:t})})}var Q=F(He(),1);var ke=F(U(),1),pi=500,ui=10;function Jt(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 gi(e){let t=typeof getSelection=="function"?getSelection():null;return t!==null&&!t.isCollapsed&&t.containsNode(e,!0)}function uo(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 go({context:e,root:t,children:n}){return oe()===null?(0,ke.jsx)(ke.Fragment,{children:n}):(0,ke.jsx)(mi,{context:e,root:t,children:n})}function mi({context:e,root:t,children:n}){let{setMenuAt:a}=Ha(),{store:r}=e,o=r.schema,l=We(),{pathname:s,search:d}=ce(),c=lt("/").replace(/\/$/,""),p=(0,Q.useCallback)((h,m)=>e.views?.places().find(R=>R.as===h&&(m===null||R.kind===m)),[e.views]),S=(0,Q.useCallback)((h,m)=>{let[R="",N,ee]=h.split("/").filter(Boolean).map(P=>{try{return decodeURIComponent(P)}catch{return P}});if(ee!==void 0)return null;if(R==="places"&&N!==void 0){let P=p(N,new URLSearchParams(m).get("of"));return P?{face:"pages",place:P.as,about:[Oe(P.kind)],title:P.title}:null}let u=we(o,R);return u?N===void 0?{face:"pages",about:[Oe(u)],title:qe(o,u)}:r.graph.getNode(N)?{face:"pages",on:N,about:[N]}:null:null},[o,r,p]),w=(0,Q.useCallback)(h=>{let m=h.href;try{let R=new URL(m,location.href);if(R.origin===location.origin&&(c===""||R.pathname===c||R.pathname.startsWith(`${c}/`))){let N=S(R.pathname.slice(c.length),R.search);if(N)return{...N,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(),R=h.closest("[data-graview-field]")?.getAttribute("data-graview-field");if(R&&m.on!==void 0&&h.closest("[data-graview-pick], a[href]")===null)return{...m,field:R};let N=h.closest("[data-graview-act]")?.getAttribute("data-graview-act");if(N)return{...m,act:N};let ee=h.closest("a[href]"),u=h.closest("[data-graview-listed]"),P=[h.closest("[data-graview-pick]")?.getAttribute("data-graview-pick"),u&&(!ee||u.contains(ee)&&ee.classList.contains("graview-spec-item-link"))?u.getAttribute("data-graview-listed"):null].map(fe=>fe?r.graph.getNode(fe):void 0).find(Boolean);if(P)return{face:"pages",on:P.id,about:[P.id],href:`${c}${z(o,P.kind,P.id)}`};if(ee)return w(ee);let q=h.closest("[data-graview-record]")?.getAttribute("data-graview-record");return q&&r.graph.getNode(q)?{face:"pages",on:q,about:[q]}:m},[g,w,r,o,c]),I=(0,Q.useCallback)(h=>{let m=t.current;if(m===null||!m.contains(h)||Jt(h)||h.closest("[data-graview-popover]"))return null;let R=L(h);return{face:"pages",on:R.on,about:R.about??[],field:R.field,place:R.place,href:R.href,act:R.act,element:uo(h)}},[L,t]),b=(0,Q.useCallback)((h,m,R)=>{let N=L(h);a({...N,x:Math.round(m),y:Math.round(R),returnTo:uo(h)})},[L,a]),x=(0,Q.useCallback)(h=>{let m=h.getBoundingClientRect();b(h,m.left+Math.min(16,m.width/2),Math.min(m.bottom,m.top+36))},[b]),$=(0,Q.useRef)(0),T=(0,Q.useRef)(null),M=(0,Q.useRef)(!1),V=()=>{T.current&&clearTimeout(T.current.timer),T.current=null};(0,Q.useEffect)(()=>V,[]),(0,Q.useEffect)(()=>{let h=m=>{if(m.defaultPrevented||!(m.key==="ContextMenu"||m.key==="F10"&&m.shiftKey))return;let R=t.current,N=m.target instanceof Element?m.target:null,ee=N===null||N===document.body||N===document.documentElement,u=R!==null&&N!==null&&R.contains(N);if(!u&&!(ee&&document.querySelector("[data-graview-face='pages']")===R)||Jt(N)||N?.closest("[data-graview-popover]"))return;m.preventDefault(),$.current=Date.now();let P=u&&N instanceof HTMLElement?N:R?.querySelector("[data-graview-page-title], main h1, main")??null;P&&x(P)};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[t,x]),(0,Q.useEffect)(()=>{let h=t.current;if(!h)return;let m=R=>{let N=R.detail;N&&a({...N,face:"pages"})};return h.addEventListener(Pn,m),()=>h.removeEventListener(Pn,m)},[t,a]);let me=(0,Q.useMemo)(()=>h=>{if(h.face!=="pages")return null;let m=[],R=h.on===void 0?void 0:r.graph.getNode(h.on),N=h.place===void 0?void 0:e.views?.places().find(Ee=>Ee.as===h.place),ee=R?void 0:h.about.length===1&&h.about[0].startsWith("aggregate:")&&!N?fi(h.about[0]):void 0,u=R?z(o,R.kind,R.id):N?pe(e,N):ee?`/${j(o,ee)}`:void 0,P=u!==void 0&&s===u.split("?")[0];u!==void 0&&!P&&m.push({id:"open",label:"Open",run:()=>l(u)});let q=u!==void 0?`${c}${u}`:h.href;q!==void 0&&m.push({id:"open-in-a-new-tab",label:"Open in a new tab",run:()=>void window.open(q,"_blank","noopener")});let fe=R?`#focus=${encodeURIComponent(R.id)}`:N?`#focus=${encodeURIComponent(Oe(N.kind))}&view=${encodeURIComponent(N.as)}`:ee?`#focus=${encodeURIComponent(Oe(ee))}`:void 0;if(fe!==void 0&&(e.overview||!e.embedded)){let Ee=e.overview;m.push({id:"in-the-scene",label:"Show in the scene",run:()=>Ee?Ee(fe):location.assign(`${e.sceneHref??"/"}${fe}`)})}return R===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),R=h.element?.closest("[data-graview-field]")??t.current?.querySelector(`[data-graview-field="${CSS.escape(h.field)}"]`);return!m||!(R instanceof HTMLElement)||!R.hasAttribute("data-graview-editable")?null:{id:"field",at:"start",items:[{id:"change-field",label:`Change \u201C${ma(o.tryDefinition(m.kind),h.field)}\u201D`,run:()=>R.click()}]}},[r,o,t]),le=Fr(),te=or(),he=Pr(),Ke=(0,Q.useCallback)((h,m)=>{s===pe(e,h).split("?")[0]&&l(m?pe(e,m):"/")},[s,e,l]),xe=Dr(Ke),Pe=(0,Q.useMemo)(()=>[be,he,me,...xe?[xe]:[],...te?[te]:[],...le?[le]:[]],[be,he,me,xe,te,le]);return(0,ke.jsxs)(tr,{sections:Pe,children:[(0,ke.jsx)("div",{"data-graview-menu-ground":"",style:{display:"contents"},onContextMenu:h=>{let m=h.target;h.shiftKey||Jt(m)||gi(m)||(h.preventDefault(),!m.closest("[data-graview-popover]")&&(Date.now()-$.current<700||(h.clientX===0&&h.clientY===0&&m instanceof HTMLElement?x(m):b(m,h.clientX,h.clientY))))},onPointerDown:h=>{if(M.current=!1,h.pointerType==="mouse"||!h.isPrimary)return;let m=h.target;if(Jt(m)||m.closest("[data-graview-choose], [data-graview-popover]"))return;V();let{clientX:R,clientY:N}=h;T.current={x:R,y:N,timer:setTimeout(()=>{T.current=null,M.current=!0,$.current=Date.now(),b(m,R,N)},pi)}},onPointerMove:h=>{let m=T.current;m&&Math.hypot(h.clientX-m.x,h.clientY-m.y)>ui&&V()},onPointerUp:V,onPointerCancel:V,onClickCapture:h=>{M.current&&(M.current=!1,h.preventDefault(),h.stopPropagation())},children:n}),(0,ke.jsx)(yi,{openAt:x,readyAt:I}),(0,ke.jsx)(Wr,{placement:"page"}),(0,ke.jsx)(ir,{})]})}function fi(e){let t=e.slice(10).split("+");return t.length===1&&t[0]?t[0]:void 0}function yi({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)(Or,{placement:"menu",openActs:e,aimAt:t})})}var D=F(U(),1);function mo(e,t){return t==="*"?{label:"anything",path:null}:{label:_(e,t),path:`/${j(e.schema,t)}`}}function hi({context:e,relation:t}){let{store:n}=e,a=mo(n,t.from),r=mo(n,t.to),o=l=>l.path?(0,D.jsx)(H,{to:l.path,style:{...ve,fontWeight:550},children:l.label}):(0,D.jsx)("span",{children:l.label});return(0,D.jsxs)("li",{"data-testid":"relation","data-relation":t.edgeKind,style:{display:"grid",gridTemplateColumns:"30px minmax(0, 1fr) auto",gap:12,alignItems:"baseline"},children:[(0,D.jsx)(Ir,{edgeKind:t.edgeKind,...e.brand?.kit?{kit:e.brand.kit}:{}}),(0,D.jsxs)("span",{style:{display:"grid",gap:1},children:[(0,D.jsxs)("span",{children:[o(a)," ",(0,D.jsxs)("span",{style:C,"data-graview-speaks-ids":"",children:[ze(t.edgeKind)," \u2192"]})," ",o(r)]}),t.description||t.inverse?(0,D.jsxs)("span",{style:C,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,D.jsx)(H,{to:`${r.path}?with=${encodeURIComponent(t.edgeKind)}`,style:{...K,...C,fontVariantNumeric:"tabular-nums",display:"inline-block",minWidth:24,minHeight:24,textAlign:"center"},title:`The ${r.label.toLowerCase()} that have this`,children:t.count}):(0,D.jsx)("span",{style:{...C,fontVariantNumeric:"tabular-nums"},children:t.count})]})}function fo({context:e,heading:t=!0}){let{store:n}=e,a=new Set(Fe(n,e.principal)),r=Qe(n).relations.filter(o=>a.has(o.from)&&(o.to==="*"||a.has(o.to)));return r.length===0?null:(0,D.jsxs)("section",{style:{...X,display:"grid",gap:12},"data-testid":"kind-map",children:[t?(0,D.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap"},children:[(0,D.jsx)("h2",{style:Z,children:(0,D.jsx)(H,{to:"/map",style:ve,children:"Connections"})}),(0,D.jsx)("span",{style:C,children:r.length===1?"1 relation":`${r.length} relations`})]}):null,(0,D.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:10},children:r.map(o=>(0,D.jsx)(hi,{context:e,relation:o},`${o.edgeKind}|${o.from}|${o.to}`))})]})}function zn({context:e}){let{store:t}=e;Y(t);let n=new Set(Fe(t,e.principal)),a=Qe(t),r=a.relations.filter(o=>n.has(o.from));return(0,D.jsxs)(J,{context:e,children:[(0,D.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,D.jsx)("p",{style:ye,children:r.length===0?"No relations":`${r.length} ${r.length===1?"relation":"relations"}`}),(0,D.jsx)(ae,{context:e,children:"Connections"}),(0,D.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,D.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,D.jsxs)("li",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,D.jsx)(ie,{kind:o.kind,brand:e.brand,schema:t.schema,size:7}),(0,D.jsx)(H,{to:`/${j(t.schema,o.kind)}`,style:K,children:o.plural}),(0,D.jsx)("span",{style:C,children:o.count})]},o.kind))}),(0,D.jsx)(fo,{context:e,heading:!1})]})}function yo({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,D.jsxs)("section",{style:{...X,display:"grid",gap:10},"data-testid":"seat-questions",children:[(0,D.jsx)("h2",{style:Z,children:n.length===1?"The seat asked something":`The seat asked ${n.length} things`}),(0,D.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,D.jsxs)("li",{style:{display:"grid",gap:2},children:[(0,D.jsx)("span",{children:r.say}),o?(0,D.jsxs)(H,{to:z(a.schema,o.kind,o.id),style:{...K,...C},children:[de(a.schema.tryDefinition(o.kind),o)," \u2192"]}):null]},r.participant)})})]})}var B=F(U(),1);function _n({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(x=>({kind:x,members:n.graph.nodesOfKind(x).filter($=>rt(n.schema.tryDefinition(x),$))})),p=c.filter(x=>x.members.length>0),S=c.map(x=>({entry:x,creator:n.allMutations().find($=>($.creates??[]).includes(x.kind)&&n.permits({name:$.name,args:{}},e.principal).ok)})).find(x=>x.creator!==void 0),w=p.length===0?"Nothing here yet.":`${p.map(x=>Rt(n.schema,x.kind,x.members.length)).join(", ").replace(/, ([^,]*)$/," and $1")}.`,g=e.views?.homeView?.(),L=n.schema.kinds.some(x=>n.graph.nodesOfKind(x).length>0);if(g&&L){let x=a?.subtitle?(0,B.jsx)("p",{style:{...C,margin:0},"data-testid":"app-subtitle",children:a.subtitle}):null,$=g[Symbol.for("graview.home-blocks")]===!0;return(0,B.jsx)(J,{context:e,style:st,children:(0,B.jsxs)("div",{style:{display:"grid",gap:12},"data-testid":"home-view",children:[$?null:x,o.length>0?(0,B.jsx)(H,{to:"/problems",style:{...K,color:"var(--graview-warn)"},children:l}):null,(0,B.jsx)(Er.Provider,{value:$?x:null,children:(0,B.jsx)(Qt,{when:Et(g),children:(0,B.jsx)(g,{cardinality:"many",fidelity:"full",mode:"fullscreen",selected:!1})})})]})})}let I=new Set(Fe(n,e.principal)),b=Qe(n).relations.filter(x=>I.has(x.from)&&(x.to==="*"||I.has(x.to)));return(0,B.jsxs)(J,{context:e,style:st,children:[(0,B.jsxs)("header",{style:{display:"grid",gap:12},children:[a?.subtitle?(0,B.jsx)("p",{style:{...C,margin:0},"data-testid":"app-subtitle",children:a.subtitle}):null,(0,B.jsx)(ae,{context:e,"data-testid":"standing",children:w}),(0,B.jsxs)("p",{style:{...ne,display:"grid",gap:4},"data-testid":"standing-card",children:[p.length===0&&S?(0,B.jsxs)("span",{children:["Begin with \u201C",S.creator?.title??S.creator?.name,"\u201D, under"," ",(0,B.jsx)(H,{to:`/${j(n.schema,S.entry.kind)}`,style:K,children:_(n,S.entry.kind)}),"."]}):null,o.length===0?(0,B.jsx)("span",{children:"All rules hold."}):(0,B.jsx)(H,{to:"/problems",style:{...K,color:"var(--graview-warn)"},children:l})]})]}),(0,B.jsx)(Un,{context:e}),(0,B.jsxs)("section",{style:{...X,display:"grid",gap:14},"data-testid":"kinds",children:[(0,B.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap"},children:[(0,B.jsx)("h2",{style:Z,children:"What is here"}),b.length>0?(0,B.jsxs)(H,{to:"/map",style:{...K,...C,marginLeft:"auto"},"data-testid":"map-link",children:["Connections \xB7 ",b.length===1?"1 relation":`${b.length} relations`," ",(0,B.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]}):null]}),(0,B.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"8px 10px"},children:c.map(({kind:x,members:$})=>(0,B.jsx)("li",{style:{maxWidth:"100%"},children:(0,B.jsxs)(H,{to:`/${j(n.schema,x)}`,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,B.jsx)(ie,{kind:x,brand:a,schema:n.schema,size:7}),(0,B.jsx)("span",{style:{fontWeight:550,overflowWrap:"anywhere"},children:_(n,x)}),(0,B.jsx)("span",{style:{...C,fontVariantNumeric:"tabular-nums"},children:$.length===0?"none yet":gt($.length)})]})},x))})]}),s.length>0?(0,B.jsxs)("section",{style:{...X,display:"grid",gap:10},children:[(0,B.jsx)("h2",{style:Z,children:"Recently"}),(0,B.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},children:s.map(x=>(0,B.jsxs)("li",{style:C,children:[(0,B.jsx)("span",{style:{color:"var(--graview-ink)"},children:x.intent})," \u2014 ",ft(x,t,{graph:n.graph,schema:n.schema,...e.seats?{seats:e.seats}:{},...e.people?{people:e.people}:{}})]},x.id))})]}):null]})}var Me=F(He(),1);var Je=F(U(),1);function en({context:e,withheld:t,style:n,testId:a}){let r=oe(),o=xa(t,e.signIn??r?.signIn);return o?(0,Je.jsx)("p",{style:{...n,margin:0},children:(0,Je.jsx)("button",{type:"button","data-testid":"sign-in",onClick:()=>o.run(),style:Se,children:o.label})}):t.length===0?null:(0,Je.jsx)("ul",{style:{...n,margin:0,padding:0,listStyle:"none",display:"grid",gap:4},...a?{"data-testid":a}:{},children:t.map(l=>(0,Je.jsxs)("li",{style:C,children:[(0,Je.jsx)("s",{children:l.label})," \u2014 ",l.refusal.message]},l.id))})}var E=F(U(),1);function Yn({context:e}){let{store:t,brand:n,principal:a,invariantContext:r}=e;Y(t);let[o]=dt(),l=o.get("q")??"",s=typeof r?.today=="string"?r.today:void 0,d=vr(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,E.jsxs)(J,{context:e,children:[(0,E.jsx)("style",{children:Vt}),(0,E.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,E.jsx)("p",{style:ye,children:"Search"}),(0,E.jsx)(ae,{context:e,"data-testid":"search-heading",children:w.length===0?"Find anything by its name":d.hits.length===0?(0,E.jsxs)(E.Fragment,{children:["Nothing here is called \u201C",w,"\u201D."]}):(0,E.jsxs)(E.Fragment,{children:[wi(t,d.byKind)," for \u201C",w,"\u201D"]})}),w.length>0?(0,E.jsxs)("p",{style:{...C,margin:0},"data-testid":"search-searched",children:[It(t.schema,d.searched),d.conditions.filter(g=>g.key!=="is"&&g.admittedBy.length<d.searched.kinds.length).map(g=>(0,E.jsxs)("span",{children:[" ",g.key,":",g.value," narrows"," ",g.admittedBy.length===0?"nothing here":g.admittedBy.map(L=>_(t,L).toLowerCase()).join(" and "),"."]},`${g.key}:${g.value}`))]}):(0,E.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,E.jsx)("code",{children:"done:false"})," and the like narrow as a list does, and ",(0,E.jsx)("code",{children:"is:any"})," includes what is past."]})]}),p.length>0?(0,E.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},"data-testid":"search-named",children:p.map(g=>(0,E.jsx)("li",{"data-testid":"search-hit","data-about":g.about,children:g.about==="kind"?(0,E.jsxs)(H,{to:`/${j(t.schema,g.kind)}`,style:K,children:[g.label,g.count>0?(0,E.jsxs)("span",{style:C,children:[" \xB7 ",g.count," match"]}):null]}):g.about==="place"?(0,E.jsxs)(H,{to:pe(e,g),style:K,children:["Go to ",g.title]}):g.about==="rule"?(0,E.jsxs)(H,{to:"/problems",style:K,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,E.jsxs)("section",{className:"graview-list",style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",minWidth:0},"data-testid":"search-group","data-kind":g,children:[(0,E.jsxs)("h2",{className:"graview-group-head",style:{alignItems:"center"},children:[(0,E.jsx)(ie,{kind:g,brand:n,schema:t.schema,size:8}),(0,E.jsx)(H,{to:`/${j(t.schema,g)}?${new URLSearchParams({q:w}).toString()}`,style:K,"data-testid":"search-kind-link",children:_(t,g)}),(0,E.jsx)("span",{children:d.byKind[g]})]}),(0,E.jsx)("ul",{className:"graview-rows",children:c.filter(L=>L.kind===g).map(L=>(0,E.jsxs)("li",{"data-testid":"search-hit","data-about":"node",className:"graview-row",children:[(0,E.jsxs)(H,{to:z(t.schema,g,L.id),className:"graview-row-title",...L.label.length>60?{title:L.label}:{},children:[L.flagged?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("span",{role:"img","aria-label":"Breaks a rule:",style:{color:"var(--graview-warn)"},children:"\u26A0"})," "]}):null,L.label]}),L.apart||!L.current?(0,E.jsx)("span",{className:"graview-row-glance",children:[L.apart,L.current?"":"past"].filter(Boolean).join(" \xB7 ")}):null,(0,E.jsx)(tn,{why:L.why})]},L.id))})]},g)),w.length>0?(0,E.jsx)(vi,{asked:w}):null,w.length>0&&d.hits.length===0?(0,E.jsx)(wo,{store:t,kinds:d.searched.kinds,words:d.words,...a?{principal:a}:{},...r?{invariantContext:r}:{}}):null]})}function tn({why:e}){return e.strength==="near"?(0,E.jsxs)("span",{style:C,"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,E.jsxs)("span",{style:C,"data-testid":"search-why",children:[e.reading,": ",e.fragment]})}function wi(e,t){let n=Object.entries(t).map(([a,r])=>`${r} ${r===1?_e(e.schema.tryDefinition(a),a):_(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 ho(e,t,n={}){let a=[];for(let r of t){let o=Ye(e,r,{...n.principal?{principal:n.principal}:{},...n.invariantContext?{context:n.invariantContext}:{}});for(let l of nn(e,r,o.actions.affordances))a.some(s=>s.mutation.name===l.mutation.name)||a.push(l)}return a}function nn(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=sr(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 wo({store:e,kinds:t,words:n,principal:a,invariantContext:r}){let o=ho(e,t,{...a?{principal:a}:{},...r?{invariantContext:r}:{}});return o.length===0||n.trim().length===0?null:(0,E.jsx)("div",{style:{display:"grid",gap:24},"data-testid":"search-to-create",children:o.map(({kind:l,affordance:s,mutation:d,arg:c})=>(0,E.jsxs)("section",{style:{...X,display:"grid",gap:14},children:[(0,E.jsxs)("h2",{style:Z,children:[Ae(fa(_e(e.schema.tryDefinition(l),l)))," called \u201C",n,"\u201D"]}),(0,E.jsx)(Ie,{store:e,mutation:d,prefilled:s.args,open:s.open,initial:{[c]:n},...a?{principal:a}:{}})]},`${s.id}|${n}`))})}function vi({asked:e}){let t=oe();return t?(0,E.jsx)(Si,{asked:e,desk:t.aiDesk}):null}function Si({asked:e,desk:t}){return qa(t)?(0,E.jsx)("p",{style:{margin:0},children:(0,E.jsxs)("button",{type:"button","data-testid":"search-ask",onClick:a=>Ba(t,{pointed:{about:[]},asked:e,returnTo:a.currentTarget}),style:{...K,font:"inherit",padding:0,border:0,background:"transparent",cursor:"pointer",textAlign:"start"},children:["Ask: \u2018",e,"\u2019"]})}):null}var y=F(U(),1),So=8,ko=40;function ki(e,t){let n=t?.fields?.shape??{},a=Object.keys(n).find(r=>ha(n[r])&&ya(e[r]));return a===void 0?void 0:e[a]}function Qn({context:e}){let t=Ge(),n=we(e.store.schema,t.slug??"");return n?(0,y.jsx)(bo,{context:e,kind:n}):(0,y.jsx)(J,{context:e,children:(0,y.jsx)(ae,{context:e,children:"No such kind of thing here."})})}function bo({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]=dt(),w=`list-${(0,Me.useId)().replace(/:/g,"")}`,g=s.schema.tryDefinition(t),L=va(p.get("archived")),I=s.graph.nodesOfKind(t,{archived:L}),b=Qe(s).relations.filter(i=>i.from===t||i.to===t),x=new Set(s.violations(c).flatMap(i=>i.nodeIds)),$=yr(s.schema,fr(s.schema,mr(s.schema,t))),T=b.map(i=>i.edgeKind),M=Ri(p,$,T),V=["sort","filter","group","q","by","with","past","archived",...T].some(i=>p.has(i)),me=I.length>=ko,be=g?.fieldRoles?.when,le=e.views?.arrangement?.()?.lists?.[t],te=dr(le),he=lr(le?.group),Ke=Ai(me,be),xe=n??(te?{...Ke,...te}:Ke),Pe=V?M.arrangement:En(xe,$).arrangement,h=te?.sort,m=Pe.sort&&h?.then&&Pe.sort.by===h.by&&Pe.sort.direction===h.direction?{...Pe,sort:h}:Pe,R=hr(m.query??""),N=[...m.filter??[],...R.conditions].some(i=>i.key==="is"&&(i.value==="past"||i.value==="any"))||gr(g,[...m.filter??[],...R.conditions]),ee=N||!g?.lifecycle?m:{...m,filter:[...m.filter??[],{key:"is",value:"current"}]},u=new Map,P=Ft(I,ee,{schema:s.schema,graph:s.graph,flagged:x,...typeof c?.today=="string"?{today:c.today}:{},read:(i,f)=>{let O=u.get(i.id);return O||u.set(i.id,O=mt(s.schema,s.graph,i)),O[f]}}),q=he&&m.group?.by===he.by&&!m.group.bucket?$.groups.find(i=>i.key===he.by):void 0,fe=he&&q&&(q.type==="choice"||q.type==="boolean")?cr(P.groups,he,{type:q.type,...q.options?{options:q.options}:{}}):P.groups.map(i=>({...i,closed:!1})),Ee=new Set((p.get("open")??"").split(",").filter(Boolean)),Lo=!!m.query||(m.filter??[]).some(i=>i.key===he?.by),ea=i=>q?.type==="boolean"?i==="1"?"true":"false":i,ta=i=>i.closed&&!Lo&&!Ee.has(ea(i.key)),To=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,tt=g?.lifecycle&&!N?I.filter(i=>rt(g,i)):I,na=I.length-tt.length,on=m.group?.by??null,Mo=i=>{let f=new URLSearchParams(p);for(let re of["sort","filter","group","q","by","with","past","archived",...b.map(Ct=>Ct.edgeKind)])f.delete(re);let O=Sr(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||te||me||be)&&f.set("sort",""),S(f)},{principal:nt}=e,sn=Ye(s,t,{...nt?{principal:nt}:{},...e.invariantContext?{context:e.invariantContext}:{}}),Be=sn.actions.affordances.map(i=>({affordance:i,mutation:s.allMutations().find(f=>f.name===i.mutation)})).filter(i=>i.mutation!==void 0),Eo=sn.actions.withheld,ln=()=>new Set(Ce.length===0?Be.map(({mutation:i})=>i.name):[]),[dn,aa]=(0,Me.useState)(()=>({kind:t,open:ln()}));dn.kind!==t&&aa({kind:t,open:ln()});let ra=i=>(dn.kind===t?dn.open:ln()).has(i),oa=(i,f)=>aa(O=>{let re=new Set(O.open);return f?re.add(i):re.delete(i),{kind:O.kind,open:re}}),ia=`begin-${(0,Me.useId)().replace(/:/g,"")}`,sa=R.words&&Ce.length===0?Object.fromEntries(nn(s,t,sn.actions.affordances).map(i=>[i.mutation.name,i.arg])):{},Ve=_(s,t),kt=e.views?.lookup(t,{cardinality:"one",fidelity:"glyph"}),cn=kt!==void 0&&!ot(kt)?kt:void 0,pn=(m.group?.bucket??"day")==="day"?m.group?.by:void 0,un=(m.filter??[]).map(i=>i.key),$o=un.filter(i=>un.indexOf(i)===un.lastIndexOf(i)&&/choice|boolean/.test($.filters.find(f=>f.key===i)?.type??"")),gn=i=>{let f={...g?.computed?mt(s.schema,s.graph,i):i};pn&&!String(f[pn]).includes("T")&&delete f[pn];for(let O of $o)delete f[O];return f},bt=i=>{let f=de(g,i);if(a)return(0,y.jsxs)("li",{"data-testid":"record-row","data-graview-record":i.id,style:{minWidth:0},...vn(i.id),children:[wn(i,f),a(i,{label:f,href:z(s.schema,t,i.id),flagged:x.has(i.id),glance:jt(gn(i),g,f)})]},i.id);if(cn){let Sn=Bt(kt,i,s.graph),Wo=Object.fromEntries(Object.entries(gn(i)).filter(([Do])=>!Sn?.fields.has(Do))),ua=Sn?jt(Wo,g,Sn.title??f):"";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)"},...vn(i.id),children:[wn(i,f),(0,y.jsx)("div",{style:{flex:"1 1 14rem",minWidth:0},children:(0,y.jsx)(cn,{node:i,cardinality:"one",fidelity:"glyph",mode:"fullscreen",selected:!1,...x.has(i.id)?{flagged:[i.id]}:{}})}),ua?(0,y.jsx)("span",{style:{...C,flex:"0 1 auto",minWidth:0,overflowWrap:"anywhere"},"data-testid":"record-glance",children:ua}):null,(0,y.jsx)(Mi,{to:z(s.schema,t,i.id),label:x.has(i.id)?`${f} \u2014 implicated in a problem`:f})]},i.id)}let O=jt(gn(i),g,f),re=R.words?wr(g,i,R.words):void 0,Ct=me?void 0:er(i,g),At=ki(i,g),pa=(0,y.jsxs)(H,{to:z(s.schema,t,i.id),className:"graview-row-title",...f.length>60?{title:f}:{},children:[x.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,...vn(i.id),children:[wn(i,f),Ct?(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:14,minWidth:0},children:[(0,y.jsx)(it,{as:"thumb",file:Ct}),pa]}):pa,O||At?(0,y.jsxs)("span",{className:"graview-row-glance",children:[O,O&&At?" \xB7 ":null,At?(0,y.jsx)(Wt,{address:At}):null]}):null,re?(0,y.jsx)(tn,{why:re}):null]},i.id)},mn=Te(e).filter(i=>i.kind===t),la=le?.filters,No=(m.filter??[]).some(i=>i.key!=="is"||i.value!=="any"),Oo=!!(m.sort||m.group||m.query||No),Ho=tt.length>=So||V&&Oo,Ne=m.sort?$.sorts.find(i=>i.key===m.sort.by):void 0,fn=Ne?.type==="date"||Ne!==void 0&&Ne.key===be,da=me&&!P.grouped&&Ne&&(Ne.about==="label"||Ne.type==="text"||fn)?i=>{let f=Ne.about==="label"?de(g,i):i[Ne.key];if(typeof f!="string"||f.length===0)return fn?"No date":"#";if(fn)return f.slice(0,4);let O=f.trim().charAt(0).toLocaleUpperCase();return/\p{L}/u.test(O)?O:"#"}:void 0,je=da?Ce.reduce((i,f)=>{let O=da(f);return i.at(-1)?.key===O?i.at(-1).nodes.push(f):i.push({key:O,nodes:[f]}),i},[]):void 0,ca=P.grouped&&on?fe.flatMap(i=>ta(i)?[]:i.nodes):je&&je.length>1?je.flatMap(i=>i.nodes):Ce,yn=(0,Me.useMemo)(()=>ca.map(i=>i.id),[ca.map(i=>i.id).join(`
6
- `)]),$e=Cr(yn),hn=(0,Me.useId)(),pt=(nt?s.permittedMutations(nt):s.permittedMutations()).some(i=>{let f=i.subject?.kinds;return f!==void 0&&(f==="*"||f.includes(t))}),wn=(i,f)=>pt?(0,y.jsx)("span",{className:"graview-choose-at",children:(0,y.jsx)("input",{...$e.boxProps(i.id,f),onPointerEnter:$n,onFocus:$n})}):null,vn=i=>pt?{"data-graview-choose":i}:{},Io=(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]),at=r==="grid"?{margin:0,padding:0,listStyle:"none",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(100%, 15rem), 1fr))",alignItems:"start",gap:12}:a||cn?{margin:0,padding:0,listStyle:"none",display:"grid",gap:a&&r==="list"?6:0}:void 0,xt=at?void 0:"graview-rows",ut=i=>`list-at-${i.replace(/[^\p{L}\p{N}]/gu,"_")}`,Pt=b.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}}),Fo=new Set(Pt.map(i=>(i.words??"").toLowerCase()).filter((i,f,O)=>i&&O.indexOf(i)!==f));return(0,y.jsxs)(l?Ci:J,{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)(ct,{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:Ve}),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)(Li,{name:f.name,title:f.title??f.name,panel:`${ia}-${f.name}`,open:ra(f.name),onOpen:O=>oa(f.name,O)},i.id))}):null]}),Ce.length>0?(0,y.jsx)(Gr,{place:"here",to:[{label:`Skip to the ${Ce.length===1?_e(g,t):`${Ce.length} ${Ve.toLowerCase()}`}`,testid:"records",go:()=>{let i=document.querySelector(`[data-graview-skip-target="${CSS.escape(hn)}"]`);Nn(i?.querySelector('[data-graview-choose-box][tabindex="0"]')??i)}},...tt.length>0?[{label:"Skip to arranging them",testid:"arranging",go:()=>{let i=document.querySelector(`[data-graview-skip-target="${CSS.escape(hn)}"]`)?.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,Pt.length>0||mn.length>0?(0,y.jsxs)("p",{style:{...C,margin:0,display:"flex",flexWrap:"wrap",columnGap:18,rowGap:2},"data-testid":"kind-related",children:[Pt.length>0?(0,y.jsxs)("span",{"data-testid":"kind-relations",children:["Related:"," ",Pt.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)(H,{to:`/${j(s.schema,f)}`,style:K,title:_(s,f),children:O&&Fo.has(O.toLowerCase())?`${Ae(O)}: ${_(s,f).toLowerCase()}`:Ae(O??_(s,f))})]},`${i.edgeKind}|${i.from}|${i.to}`))]}):null,mn.length>0?(0,y.jsxs)("span",{"data-testid":"kind-pictures",children:["Also as:"," ",mn.map((i,f)=>(0,y.jsxs)("span",{children:[f>0?(0,y.jsx)("span",{"aria-hidden":"true",children:" \xB7 "}):null,(0,y.jsx)(H,{to:pe(e,i),style:K,children:i.title})]},Ze(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=!!(sa[f.name]&&Ce.length===0);return(0,y.jsx)(Ti,{name:f.name,id:`${ia}-${f.name}`,description:f.description,open:ra(f.name),onClose:()=>oa(f.name,!1),children:(0,y.jsx)(Ie,{store:s,mutation:f,prefilled:i.args,open:i.open,...O?{initial:{[sa[f.name]]:R.words}}:{},...e.principal?{principal:e.principal}:{}},O?`${f.name}|${R.words}`:f.name)},i.id)})}):null,M.dropped.length>0?(0,y.jsxs)("p",{style:{...C,margin:0},"data-testid":"list-dropped",children:["This link asked for ",M.dropped.join(", "),", which ",Ve.toLowerCase()," cannot be arranged by; the rest is shown."]}):null,tt.length>0?(0,y.jsx)(xr,{schema:s.schema,graph:s.graph,kind:t,arrangement:m,onChange:Mo,kept:{shown:Ce.length,of:tt.length},noun:{one:_e(g,t),many:Ve.toLowerCase()},...Ho?{}:{allow:!1},...la?{filters:la}:{},offers:$,chips:{nodes:tt,flagged:x,...typeof c?.today=="string"?{today:c.today}:{}},query:e.framed===!0&&e.barAbove!==!0}):null,(0,y.jsx)("style",{children:Vt}),pt?(0,y.jsx)("style",{children:Ar+Pi}):null,(0,y.jsx)("div",{className:"graview-list","data-graview-skip-target":hn,...pt?{...$e.listProps,ref:$e.list,tabIndex:-1,"data-graview-choosable":"","aria-label":$e.chosen.length>0?`${Ve}, ${$e.chosen.length} chosen`:Ve,role:"group"}:{},children:Ce.length===0&&R.words?(0,y.jsxs)("p",{style:ne,"data-testid":"none-yet",children:["Nothing here is called \u201C",R.words,"\u201D."," ",(0,y.jsx)("span",{style:C,"data-testid":"list-searched",children:It(s.schema,{kinds:[t],past:N})})," ",(0,y.jsx)(H,{to:"?",style:K,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)(H,{to:"?",style:K,children:"Show every one"})]}):null]}):P.grouped&&on?(0,y.jsx)("div",{style:{display:"grid",gap:"1rem"},"data-testid":"records","data-grouped":on,children:fe.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:at,className:xt,"data-graview-rows":"",children:i.nodes.map(bt)})]},i.key||"-");let f=ta(i),O=`${w}-${ut(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:()=>To(ea(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:bi,children:[" ",i.nodes.length===1?_e(g,t):Ve.toLowerCase()]})]})}),(0,y.jsx)("ul",{id:O,style:f?{...at,display:"none"}:at,className:xt,"data-graview-rows":"",hidden:f,children:f?null:i.nodes.map(bt)})]},i.key||"-")})}):je&&je.length>1?(0,y.jsxs)("div",{style:{display:"grid",gap:14},"data-testid":"records","data-sectioned":Ne?.type==="date"?"year":"letter",children:[(0,y.jsx)("nav",{"aria-label":"Jump to","data-testid":"list-index",style:{...C,display:"flex",flexWrap:"wrap",gap:Ne?.type==="date"?"0 10px":"0 4px",lineHeight:1.3},children:je.map(i=>(0,y.jsx)("a",{href:`#${ut(i.key)}`,onClick:f=>{f.preventDefault(),document.getElementById(ut(i.key))?.scrollIntoView({block:"start"})},style:{...ve,minWidth:24,justifyContent:"center"},children:i.key},i.key))}),je.map(i=>(0,y.jsxs)("section",{"data-testid":"list-section","aria-labelledby":ut(i.key),style:{display:"grid",gap:0},children:[(0,y.jsx)("h2",{id:ut(i.key),className:"graview-group-head",children:i.key}),(0,y.jsx)("ul",{style:at,className:xt,"data-graview-rows":"",children:i.nodes.map(bt)})]},i.key))]}):(0,y.jsx)("ul",{style:at,className:xt,"data-testid":"records","data-graview-rows":"",children:Ce.map(bt)})}),pt?(0,y.jsx)(Rr,{store:s,chosen:$e.chosen,...nt?{principal:nt}:{},...c?{context:c}:{},anchor:xi,of:yn.length,onChooseAll:()=>$e.choose(yn),onClear:$e.clear,onActed:Io}):null,na>0?(0,y.jsxs)(H,{to:vo(p,"filter","is:any"),style:{...K,...C,justifySelf:"start"},"data-testid":"past-link",children:["+",na," past"]}):null,L===!1&&s.graph.count(t,{archived:!0})>0?(0,y.jsxs)(H,{to:vo(p,"archived","true"),style:{...K,...C,justifySelf:"start"},"data-testid":"archived-link",children:["+",s.graph.count(t,{archived:!0})," archived"]}):null]}),(0,y.jsx)(en,{context:e,withheld:Eo,style:X,testId:"withheld"})]})}var bi={position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0},xi=()=>document.querySelector("[data-graview-choosable]")?.closest("[data-embed-content]")??null,Pi=`
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:${Pa.raised};display:flex;align-items:center}
10
- @media (pointer: coarse){
11
- .graview-list:not([data-graview-choosing]) [data-graview-choose]{padding-left:0}
12
- .graview-list:not([data-graview-choosing]) .graview-choose-at{display:none}
13
- }
14
- `;function Ci({children:e}){return(0,y.jsx)("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:40,minWidth:0},children:e})}var Ai=(e,t)=>t?{sort:{by:t,direction:"desc"}}:e?{sort:{by:"label",direction:"asc"}}:{};function Ri(e,t,n){let a=Mt({...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"}),En({...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 vo(e,t,n){let a=new URLSearchParams(e);return a.set(t,n),a.delete("past"),`?${a.toString()}`}function Li({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 Ti({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:{...C,margin:0,maxWidth:"58ch"},children:n}):null,o]})}function Mi({to:e,label:t}){let n=(0,Me.useRef)(null);return Lr(n),(0,y.jsx)(H,{ref:n,to:e,"aria-label":t,style:{position:"absolute",inset:0,borderRadius:6}})}var et=F(He(),1);var St=F(He(),1);var W=F(U(),1);function Zn({context:e}){let{store:t,brand:n,invariantContext:a,principal:r}=e;Y(t);let o=t.violations(a),l=t.allInvariants(),s=Nt(t,o),d=Ga(t.schema,l);return(0,W.jsxs)(J,{context:e,children:[(0,W.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,W.jsx)(ae,{context:e,children:o.length===0?"All rules hold":"What is broken"}),(0,W.jsx)("p",{style:ne,"data-testid":"problems-count",children:o.length===0?"Every declared rule is satisfied by what is here.":Sa(o)})]}),(0,W.jsx)(yo,{context:e}),s.map((c,p)=>{let S=c.nodeIds[0],w=S?t.graph.getNode(S):void 0;return(0,W.jsxs)("section",{style:{display:"grid",gap:10,padding:"16px 18px",borderLeft:"3px solid var(--graview-warn)",background:"var(--graview-panel-warning)",borderRadius:"0 var(--graview-radius, 12px) var(--graview-radius, 12px) 0"},children:[c.line?null:(0,W.jsx)(an,{violation:c,schema:t.schema,...n?{brand:n}:{}}),w?(0,W.jsxs)("p",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:8},children:[(0,W.jsx)(ie,{kind:w.kind,brand:n,schema:t.schema,size:7}),(0,W.jsx)(H,{to:z(t.schema,w.kind,w.id),style:K,children:de(t.schema.tryDefinition(w.kind),w)})]}):null,c.line?(0,W.jsx)(an,{violation:c,schema:t.schema,...n?{brand:n}:{}}):null,(0,W.jsx)(rn,{store:t,repairs:c.repairs,...r?{principal:r}:{}})]},p)}),l.length>0?(0,W.jsxs)("section",{style:{...X,display:"grid",gap:12},"data-testid":"rules",children:[(0,W.jsx)("h2",{style:Z,children:"The rules"}),(0,W.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,W.jsxs)("li",{"data-graview-rule":c.name,style:{display:"grid",gap:2},children:[(0,W.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",columnGap:12,rowGap:2},children:[S?(0,W.jsx)(Ot,{line:S,schema:t.schema,...n?{brand:n}:{},style:{flex:"1 1 18rem"}}):(0,W.jsx)("span",{style:{flex:"1 1 18rem",fontWeight:550},children:w}),(0,W.jsx)("span",{style:{...C,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,W.jsx)("span",{style:C,children:w}):null]},c.name)})})]}):null]})}function an({violation:e,schema:t,brand:n}){if(!e.line)return(0,W.jsx)("p",{style:{margin:0,color:"var(--graview-warn)",fontWeight:550},children:e.message});let a=Va(e),r=Ua(e);return r?(0,W.jsxs)("div",{style:{display:"grid",gap:4},"data-testid":"problem-line",children:[(0,W.jsx)("p",{style:{margin:0,color:"var(--graview-warn)",fontWeight:550},"data-testid":"problem-says",children:r}),a?(0,W.jsx)("span",{style:C,children:a}):null,(0,W.jsxs)("details",{"data-testid":"problem-judged",style:C,children:[(0,W.jsx)("summary",{style:{cursor:"pointer",width:"fit-content",minHeight:24},children:"How it is judged"}),(0,W.jsx)(Ot,{line:e.line,schema:t,...n?{brand:n}:{},lead:"none"})]})]}):(0,W.jsxs)("div",{style:{display:"grid",gap:2},"data-testid":"problem-line",children:[(0,W.jsx)(Ot,{line:e.line,schema:t,...n?{brand:n}:{},lead:"none",style:{color:"var(--graview-warn)"}}),a?(0,W.jsx)("span",{style:C,children:a}):null]})}function rn({store:e,repairs:t,principal:n}){let[a,r]=(0,St.useState)(null),[o,l]=(0,St.useState)(null),s=(0,St.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,W.jsxs)("div",{style:{display:"grid",gap:10},"data-testid":"repairs",children:[(0,W.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,W.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(Ht(e.schema,e.allMutations(),L))}},style:Se,children:w?`${p.label} \u2026`:p.label},S):(0,W.jsxs)("p",{"data-testid":"withheld","data-withheld":g.refusal.wouldNeed.join(",")||"nobody",style:{...C,margin:0},children:[(0,W.jsx)("s",{children:p.label})," \u2014 ",g.refusal.message]},S)})}),c&&d?(0,W.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,W.jsxs)("p",{"data-testid":"refused",role:"alert",style:{margin:0,color:"var(--graview-warn)",fontSize:On},children:["\u201C",d.label,"\u201D names ",d.mutation,", which this app does not declare."]}):null,o?(0,W.jsx)("p",{"data-testid":"refused",role:"alert",style:{margin:0,color:"var(--graview-warn)",fontSize:On},children:o}):null]})}var Xn=F(He(),1);var Ue=F(U(),1);function xo({store:e,link:t,principal:n}){let[a,r]=(0,Xn.useState)(!1),[o,l]=(0,Xn.useState)(null),s=Qa(t);return(0,Ue.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[(0,Ue.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,Ue.jsxs)("span",{style:{...C,display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,Ue.jsx)("span",{children:s}),(0,Ue.jsx)("button",{type:"button",style:{...Se,padding:"4px 10px"},onClick:()=>{try{e.apply({name:ka,args:{kind:t.edge.kind,from:t.edge.from,to:t.edge.to}},n?{author:n}:{}),r(!1)}catch(d){l(Ht(e.schema,e.allMutations(),d))}},children:"Keep this link"}),o?(0,Ue.jsx)("span",{role:"alert",children:o}):null]}):null]})}var ge=F(U(),1);function Po({nodeId:e,node:t,field:n,inPlace:a,labelStyle:r=ye}){return n.files?(0,ge.jsx)(it,{as:"field",read:!a,nodeId:e,field:n.key,label:n.label,files:n.files,labelStyle:r,style:{gap:4}}):n.long?(0,ge.jsx)(br,{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,ge.jsxs)("div",{style:{display:"grid",gap:2,minWidth:0,alignContent:"start"},children:[(0,ge.jsx)("dt",{style:r,children:n.label}),(0,ge.jsx)("dd",{style:{margin:0,overflowWrap:"anywhere",minWidth:0},children:n.linked?(0,ge.jsx)(nr,{relation:n.linked.relation,refs:n.linked.refs,...a?{nodeId:e,field:n.key}:{}}):n.app?(0,ge.jsx)(Wt,{address:n.app,as:"record",...a?{nodeId:e,field:n.key}:{}}):n.href?(0,ge.jsx)(kr,{href:n.href,field:n.key,value:n.value,stored:n.stored,...a?{nodeId:e}:{}}):a?(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsx)(Dt,{nodeId:e,field:n.key,value:n.value,stored:n.stored}),n.repeats?(0,ge.jsx)(ar,{nodeId:e,field:n.key,start:t?.[n.key],value:t?.[`${n.key}Repeat`],label:`${n.label} repeats`}):null]}):n.value})]})}var v=F(U(),1),Ei=[];function Jn({context:e}){let{store:t,brand:n,principal:a,invariantContext:r}=e;Y(t);let o=oe()!==null,l=Ge(),s=decodeURIComponent(l.id??""),d=Jr(t,s,{...a?{principal:a}:{},...r?{context:r}:{}}),c=Nt(t,d?.violations??Ei),[p,S]=(0,et.useState)(null),[w,g]=(0,et.useState)(!1),[L,I]=(0,et.useState)(null),b=(0,et.useRef)(null),x=(0,et.useRef)(null),$=rr({flow:"both",letters:!0}),T=u=>{(b.current?.parentElement?.querySelector(`[data-affordance="${u.replace(/["\\]/g,"\\$&")}"]`)??b.current)?.focus()};if(!d)return(0,v.jsx)(J,{context:e,children:(0,v.jsx)(ae,{context:e,children:"Nothing lives at this address."})});let M=t.graph.getNode(s),V=t.schema.tryDefinition(d.kind),me=V?.describe&&M?za(V,M):null,be=[...t.log.all()].filter(u=>!Lt(u)&&(u.writes.includes(s)||u.reads.includes(s))).slice(-8).reverse(),le=t.log.all().find(u=>!Lt(u)&&u.undoes===void 0&&u.primitives.some(P=>P.op==="add-node"&&P.node.id===s)),te=d.actions.affordances.filter(u=>u.provider!=="invariant"),he=te.filter(u=>u.destructive||u.setsAside),Ke=w||he.length<2?te:te.filter(u=>!he.includes(u)),xe=e.views?.lookup(d.kind,{cardinality:"one",fidelity:"full"}),Pe=xe!==void 0&&!ot(xe)?xe:void 0,h=Pe&&M?Bt(xe,M,t.graph):void 0,m=h?d.fields.filter(u=>!h.fields.has(u.key)):d.fields,R=h?d.links.flatMap(u=>{let P=u.targets.filter(q=>!h.records.has(q.id));return P.length>0?[{...u,targets:P}]:[]}):d.links,N=Pe!==void 0&&Da(xe),ee=o&&Ja(V).length>0;return(0,v.jsxs)(J,{context:e,children:[(0,v.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,v.jsx)(ct,{context:e}),(0,v.jsx)(ae,{context:e,children:o&&M?.label===d.label?(0,v.jsx)(Dt,{nodeId:s,field:"label",value:d.label,said:d.label}):d.label}),me&&me!==d.label?(0,v.jsx)("p",{style:ne,children:me}):null,le?.lineage?(0,v.jsxs)("p",{style:{...C,margin:0},"data-testid":"record-lineage",children:["Made by ",ft(le,a,{graph:t.graph,schema:t.schema,...e.seats?{seats:e.seats}:{},...e.people?{people:e.people}:{}}),", ",Cn(le.lineage)]}):null,(0,v.jsx)(_t,{context:e,stop:`#focus=${encodeURIComponent(s)}`,style:{...K,...C},"data-testid":"spatial-link"}),o&&M?(0,v.jsx)(Ln,{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,...C,justifySelf:"start"}}):null,Te(e).some(u=>u.kind===d.kind||u.across===d.kind)?(0,v.jsxs)("p",{style:{...C,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)(H,{to:pe(e,u),style:K,children:u.title})," ",(0,v.jsx)(_t,{context:e,stop:`#view=${encodeURIComponent(u.as)}`,style:{...K,...C,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"})})]},Ze(u)))]}):null]}),M&&wa(M)?(0,v.jsx)(Ni,{context:e,id:s,kind:d.kind}):null,M&&ba(t,s)?(0,v.jsx)($i,{context:e,id:s,kind:d.kind}):null,Pe&&M?(0,v.jsx)("section",{"data-testid":"record-view",style:{display:"grid",minWidth:0},children:(0,v.jsx)(Tr,{children:(0,v.jsx)(Qt,{when:Et(xe),children:(0,v.jsx)(Pe,{node:M,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)(an,{violation:u,schema:t.schema,...n?{brand:n}:{}}),(0,v.jsx)(rn,{store:t,repairs:eo(d.actions,u.repairs),...a?{principal:a}:{}})]},P))}):null,!N&&(m.length>0||ee)?(0,v.jsxs)("section",{style:{...X,display:"grid",gap:14},"data-testid":"record-fields",children:[(0,v.jsx)("h2",{style:Z,children:"The facts"}),Ya(V,m).map((u,P)=>{let q=(0,v.jsx)("dl",{style:{margin:0,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"14px 24px"},children:u.fields.map(fe=>(0,v.jsx)(Po,{nodeId:s,node:M,field:fe,inPlace:o},fe.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}),q]},P):(0,v.jsx)("div",{children:q},P)}),ee?(0,v.jsx)(it,{as:"unfilled",nodeId:s,skip:[...h?.fields??[]],labelStyle:ye,style:{gap:4}}):null]}):null,(N?[]:R).map(u=>(0,v.jsxs)("section",{style:{...X,display:"grid",gap:10},children:[(0,v.jsx)("p",{style:ye,children:Vr(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 q=Za(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)(H,{to:z(t.schema,P.kind,P.id),style:K,children:[P.label,P.apart?(0,v.jsxs)("span",{style:C,children:[" \xB7 ",P.apart]}):null]}),q?.provisional?(0,v.jsx)(xo,{store:t,link:q,...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.jsxs)(H,{to:`/${j(t.schema,P)}?${encodeURIComponent(u.edgeKind)}=${encodeURIComponent(s)}`,style:{...K,...C},"data-testid":"related-all",children:["Sort and filter ",u.description??`these ${_(t,P).toLowerCase()}`,u.targets.some(q=>q.kind!==P)?` (${_(t,P).toLowerCase()})`:""," ",(0,v.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]},P))]},`${u.edgeKind}|${u.direction}|${u.description??""}`)),!N&&(te.length>0||d.actions.withheld.length>0)?(0,v.jsxs)("section",{style:{...X,display:"grid",gap:14},"data-testid":"record-actions",children:[(0,v.jsx)("h2",{style:Z,ref:b,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,[Rn]:"",autoFocus:w&&u===he[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<te.length?(0,v.jsxs)("button",{type:"button","aria-expanded":!1,onClick:()=>g(!0),style:{...Se,...C},"data-testid":"record-actions-more",[Rn]:"",children:["Show ",te.length-Ke.length," more"]}):null]}),te.map(u=>{if(p!==u.id)return null;let P=t.allMutations().find(q=>q.name===u.mutation);return P?(0,v.jsxs)("div",{ref:x,onKeyDown:q=>{if(q.key!=="Escape"||q.defaultPrevented)return;q.preventDefault(),S(null);let fe=u.id;requestAnimationFrame(()=>T(fe))},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:{...C,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),I(u.mutation);let q=u.id;requestAnimationFrame(()=>T(q))},...a?{principal:a}:{}})]},u.id):null}),o&&L!==null&&p===null?(0,v.jsx)(Ln,{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,...C,justifySelf:"start"}}):null,(0,v.jsx)(en,{context:e,withheld:d.actions.withheld})]}):null,o?(0,v.jsx)(Ur,{id:s,style:X,headingStyle:Z}):null,be.length>0?(0,v.jsxs)("section",{style:{...X,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:C,children:[(0,v.jsx)("span",{style:{color:"var(--graview-ink)"},children:u.intent}),u.lineage?(0,v.jsxs)("span",{"data-graview-lineage":"",children:[" \xB7 ",Cn(u.lineage)]}):null," \u2014 ",ft(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 Ni({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=>!Lt(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)(H,{to:z(a.schema,d.kind,d.id),style:K,children:de(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=F(U(),1),Oi=(0,G.lazy)($t(()=>(__graviewPreload(import.meta.url,["./chunk.B6KT6BTG.js","./chunk.K46YRA65.js","./chunk.UJKT2G6M.js","./chunk.UGFDSE37.js","./chunk.DLFWBG33.js","./chunk.RYRTKIKB.js","./chunk.M5GJHVWZ.js","./chunk.HZGVEHEN.js","./chunk.JBW3DI7E.js","./chunk.CBUSFM3E.js","./chunk.NIVTK2W5.js","./chunk.FPASZ4RD.js","./chunk.2YABX3SC.js","./chunk.DQOCBKC3.js","./chunk.V5FIZIX2.js","./chunk.DQHPEKWK.js","./chunk.LSLLKICK.js","./chunk.EAUVEVVO.js","./chunk.C2UFMFJ3.js","./chunk.ZJ2VS4M4.js","./chunk.Y5ARSVH4.js","./chunk.PKUDIWIF.js","./chunk.VW2VCPJX.js","./chunk.MB7LKKUD.js","./chunk.WVUJXDXZ.js","./chunk.OYHQSXNC.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.6BJBPDF3.js","./chunk.XWAMQPUM.js","./chunk.SDO3U72B.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.KUUDW7VR.js")).then(e=>({default:e.DraftPage})))),Hi={kind:"human"};function Ii({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)(H,{to:`/${j(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 ${gt(e.total)} ${o}`:`${gt(a)} more \xB7 all ${o}`})})}function Fi({context:e,children:t}){let n=We(),a=e.store.schema,r=lt("/").replace(/\/$/,""),o=(0,G.useMemo)(()=>({href:l=>`${r}${z(a,l.kind,l.id)}`,go:l=>n(z(a,l.kind,l.id)),more:l=>(0,k.jsx)(Ii,{list:l,store:e.store})}),[r,a,n,e.store]);return(0,k.jsx)(Kt.Provider,{value:o,children:(0,k.jsx)(Mr.Provider,{value:(e.titleLevel??(e.framed&&!e.barAbove?1:2))-1,children:t})})}function Wi({steering:e}){let t=ce(),n=We(),a=`${t.pathname}${t.search}`;return(0,G.useLayoutEffect)(()=>e.at(a),[a,e]),(0,G.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 Di({context:e,to:t}){let{pathname:n}=ce(),a=oe(),r=(t??a)?.sayWhere,o=Ki(e,n);return(0,G.useEffect)(()=>(r?.(o),()=>r?.(null)),[r,o]),null}function Ki(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===xn)return"#overview=1";let l=e.views?.places().find(s=>s.as===a);return l?`#focus=${encodeURIComponent(Oe(l.kind))}&view=${encodeURIComponent(l.as)}`:"#"}let o=we(e.store.schema,n);return o?`#focus=${encodeURIComponent(a??Oe(o))}`:"#"}function Bi({onNavigate:e,path:t}){let n=ce(),a=In(),r=We(),o=n.hash&&!n.hash.includes("=")?n.hash:"",l=`${n.pathname}${n.search}${o}`,s=(0,G.useRef)(e);s.current=e;let d=(0,G.useRef)(null);(0,G.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,G.useRef)(t);return(0,G.useEffect)(()=>{t===void 0||t===c.current||(c.current=t,t!==l&&r(t))},[t]),null}function Co({context:e,registry:t,page:n}){let a=Ge(),r=we(e.store.schema,a.slug??""),o=n==="list"?Qn:Jn,s=(r?t?.lookup(r,n):void 0)??o;return(0,k.jsx)(s,{context:e})}function qi({context:e,registry:t,children:n}){let a=(0,G.useRef)(null);return Ka(a),(0,k.jsx)("div",{ref:a,"data-graview-face":"pages",style:{display:"contents"},children:(0,k.jsx)(po,{context:e,registry:t,root:a,children:(0,k.jsx)(go,{context:e,root:a,children:n})})})}function Gi(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 Ui(){let{pathname:e}=ce(),t=In(),n=(0,G.useRef)(null);(0,G.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,G.useRef)(e),r=(0,G.useRef)(!1);return(0,G.useEffect)(()=>{if(!r.current&&e===a.current)return;r.current=!0;let o=document.activeElement;if(Gi(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 Ao({context:e,children:t}){let n=We(),a=(0,G.useMemo)(()=>({record:(r,o)=>{let l=e.store.graph.getNode(r);l&&n(Gt(z(e.store.schema,l.kind,r),{section:o?.section}))},place:(r,o)=>{let l=e.views?.places().find(s=>s.as===r);l&&n(Gt(pe(e,l),o))},list:(r,o)=>{e.store.schema.tryDefinition(r)&&n(Gt(`/${j(e.store.schema,r)}`,o))},draft:()=>n("/~draft")}),[e,n]);return(0,k.jsx)(Wa.Provider,{value:a,children:t})}function Vi(){let{pathname:e,search:t,hash:n}=ce();return(0,G.useEffect)(()=>{let a=decodeURIComponent(n.replace(/^#/,""));if(!(!a||a.includes("=")))return io(a)},[e,t,n]),null}function ji({context:e,Home:t}){let n=ce(),a=e.views,r=n.key==="default"&&!(a&&Ia(a));(0,G.useEffect)(()=>{a&&Fa(a)},[a]);let o=r?Ra(e.views?.arrangement?.()?.first,e.store.schema,e.views?.places()??[]):void 0,l=o?.to==="place"?pe(e,o.place):o?.to==="kind"?`/${j(e.store.schema,o.kind)}`:void 0;return l?(0,k.jsx)(Fn,{to:l,replace:!0}):(0,k.jsx)(t,{context:e})}function Ro({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=I=>n===void 0?(0,k.jsx)(Yt,{context:e,children:I}):r?(0,k.jsx)(n,{context:e,children:I}):(0,k.jsx)(Yt,{context:e,children:(0,k.jsx)(n,{context:o,children:I})}),s=t?.lookupSurface("home")??_n,d=t?.lookupSurface("problems")??Zn,c=a?{...o,framed:!0}:e,[p,S]=(0,G.useState)(null),w=(0,G.useMemo)(()=>({context:c,registry:t}),[c,t]),g=(0,G.useMemo)(()=>({onFind:S,find:!(t?.without().has("find")??!1),places:!(t?.without().has("places")??!1)}),[t]),L=(0,k.jsx)(Dn.Provider,{value:w,children:(0,k.jsx)(Ao,{context:e,children:(0,k.jsx)(qi,{context:e,registry:t,children:l((0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(Xa,{face:"pages"}),(0,k.jsxs)(Fi,{context:c,children:[(0,k.jsx)(Ui,{}),(0,k.jsx)(Vi,{}),(0,k.jsxs)(Yr,{children:[(t?.routes()??[]).map(({path:I,component:b})=>(0,k.jsx)(Re,{path:I,element:(0,k.jsx)(b,{context:c})},I)),(0,k.jsx)(Re,{path:"/",element:(0,k.jsx)(ji,{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)(G.Suspense,{fallback:null,children:(0,k.jsx)(Oi,{context:c})})}),(0,k.jsx)(Re,{path:"/search",element:(0,k.jsx)(Yn,{context:c})}),(0,k.jsx)(Re,{path:"/map",element:(0,k.jsx)(zn,{context:c})}),(0,k.jsx)(Re,{path:"/places",element:(0,k.jsx)(Vn,{context:c})}),Te(c).some(I=>I.as===xn)?null:(0,k.jsx)(Re,{path:Aa,element:(0,k.jsx)(Fn,{to:"/",replace:!0})}),(0,k.jsx)(Re,{path:"/places/:as",element:(0,k.jsx)(jn,{context:c})}),(0,k.jsx)(Re,{path:"/:slug",element:(0,k.jsx)(Co,{context:c,registry:t,page:"list"})}),(0,k.jsx)(Re,{path:"/:slug/:id",element:(0,k.jsx)(Co,{context:c,registry:t,page:"record"})})]})]})]}))})})});return e.embedded||!a||r?L:(0,k.jsx)(Xr.Provider,{value:g,children:(0,k.jsx)(pr.Provider,{value:p,children:L})})}var zi=()=>typeof document>"u"?null:document.body;function _i({context:e,registry:t,basename:n,initialPath:a,onNavigate:r,path:o,steering:l,firstLook:s}){let[d,c]=(0,G.useState)(void 0),p=d!==void 0&&d.from===e.principal?{...e,principal:d.seat}:e;(0,G.useState)(()=>p.views?$r(p.views,p.store.schema,Mn(p.brand,p.store.schema)):void 0);let S=oe();ga({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??Hi,g=$a(p.store,w,p.history),I=(g.past&&g.live===p.store?g.past.store:p.store).seenBy(w),b=I===p.store?p:{...p,store:I};Na(p.store,p.principal);let x=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(Bi,{onNavigate:r,path:o}),l?(0,k.jsx)(Wi,{steering:l}):null,b.presence||S?(0,k.jsx)(Di,{context:b,to:S}):null,(0,k.jsx)(Ro,{context:b,...t?{registry:t}:{}}),s?(0,k.jsx)(Nr,{firstLook:s,root:zi,app:Mn(p.brand,p.store.schema)}):null]}),$=b.views?(0,k.jsxs)(Oa,{store:b.store,views:b.views,...b.principal?{principal:b.principal}:{},...b.brand?{brand:b.brand}:{},...b.locale?{locale:b.locale}:{},...b.timeZone?{timeZone:b.timeZone}:{},...b.settings?{settings:b.settings}:{},...b.presence&&!S?{presence:b.presence}:{},...b.people?{people:b.people}:{},...b.seats?{seats:b.seats}:{},onSeat:V=>S?S.takeSeat(V):c({from:e.principal,seat:V}),...b.onKeepLens?{onKeepLens:b.onKeepLens}:{},...b.ai?{ai:b.ai}:{},...b.subscriptions?{subscriptions:b.subscriptions}:{},...b.signIn?{signIn:b.signIn}:{},resolveApp:b.resolveApp??S?.resolveApp,linkedRecords:b.linkedRecords??S?.linkedRecords,...b.app?{app:b.app}:{},...b.menuSections?{menuSections:b.menuSections}:{},children:[x,(0,k.jsx)(Ao,{context:b,children:(0,k.jsx)(so,{context:b})})]}):x,T=(0,k.jsx)(Ea.Provider,{value:g,children:$}),M=b.files?(0,k.jsx)(Ma.Provider,{value:b.files,children:T}):T;if(a!==void 0){let V=n===void 0?a:`${n.replace(/\/$/,"")}${a}`;return(0,k.jsx)(_r,{initialEntries:[V],...n===void 0?{}:{basename:n},children:M})}return(0,k.jsx)(Qr,{...n===void 0?{}:{basename:n},children:M})}export{Xo as a,_i as b};
@@ -1 +0,0 @@
1
- import{G as m,R as u}from"./chunk.XWAMQPUM.js";import{md as S}from"./chunk.AS4CQBOQ.js";import{b as s}from"./chunk.AJZBJBMO.js";var o=s(m(),1),n=s(u(),1);function b({context:e,stop:r,title:t,label:a,style:l,className:i,children:f,...d}){let y=S(e.views?.arrangement?.()),p=f??(0,n.jsxs)(n.Fragment,{children:["In ",y==="Scene"?"the scene":y.replace(/^The /,"the ")," ",(0,n.jsx)("span",{"aria-hidden":"true",children:"\u2197"})]}),c=a?{"aria-label":a}:{};if(e.overview){let g=e.overview;return(0,n.jsx)("a",{href:r,...d,...c,...t?{title:t}:{},style:l,...i?{className:i}:{},onClick:h=>{h.preventDefault(),g(r)},children:p})}return e.embedded?null:(0,n.jsx)("a",{href:`${e.sceneHref??"/"}${r}`,...d,...c,...t?{title:t}:{},style:l,...i?{className:i}:{},children:p})}function w(){return(0,n.jsx)("a",{href:"#fresh","data-testid":"start-fresh",title:"Forget every edit made in this browser and return to the example",onClick:e=>{e.preventDefault();let r=new URL(window.location.href);r.searchParams.set("fresh","1"),window.location.assign(r.toString())},style:{color:"inherit",display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24},children:"Start fresh"})}function x(e){let r=(0,o.useRef)(0),t=(0,o.useCallback)(a=>e.subscribe(()=>{r.current+=1,a()}),[e]);return(0,o.useSyncExternalStore)(t,()=>r.current,()=>0)}function A(e){return e===void 0?{}:e==="sm"||e==="md"?{"data-size":e}:{style:{"--graview-control-height":typeof e=="number"?`${e}px`:e}}}var C=(e,r)=>r?`${e} ${r}`:e;export{b as a,w as b,x as c,A as d,C as e};
@@ -1 +0,0 @@
1
- import{b as on,c as an,d as te,e as sn,f as re,h as Oe,i as dn,n as cn,q as oe}from"./chunk.KWQ7QOHD.js";import{$a as We,B as pe,Ba as Be,Bb as Xe,C as me,Da as _e,F as ke,Gb as en,H as Ce,Ha as be,I as Ze,Ia as ve,Oa as He,Ra as Ue,aa as Ke,ab as Je,b as De,c as Te,cc as nn,d as $e,db as xe,e as K,ea as Ve,eb as Ye,g as de,h as M,i as Pe,j as Ge,k as ce,ka as Ie,l as Me,m as Le,nc as tn,o as Fe,oc as rn,p as le,q as he,ub as U,v as Ne,va as we,x as ne,xb as Qe,ya as qe,z as fe}from"./chunk.AS4CQBOQ.js";function ln(e){if(typeof e=="string")return{form:"string",light:e};if(typeof e!="object"||e===null)return;let s=e,n=w=>typeof s[w]=="string"?s[w]:void 0,t=n("light")??n("src");if(t===void 0)return;let[o,u,m]=[n("dark"),n("alt"),n("darkFallback")];return{form:n("light")!==void 0?"light":"src",light:t,...o!==void 0?{dark:o}:{},...u!==void 0?{alt:u}:{},...m!==void 0?{darkFallback:m}:{}}}function Gn(e,s){let n=e.brand??{},t=n.accent?rn(n.accent):void 0;t&&!t.ok&&s.push(dn("brand","brand.accent",`that accent cannot make a readable brand, so the app keeps Graview's colors: ${t.why}`,"pick a color further from orange-red, or a darker one"));let o=ln(n.logo),u=n.name??e.name,m=n.typography?Object.fromEntries(Object.entries(n.typography).filter(([,w])=>typeof w=="string"&&!/url\(|@import|[;{}<>\\]/i.test(w)).map(([w,L])=>[w,tn(L)])):void 0;return{name:u,schemes:t?.ok?t.schemes:nn,...n.currency?{currency:n.currency}:{},...n.locale?{locale:n.locale}:{},...n.timeZone?{timeZone:n.timeZone}:{},...o?{logo:o.dark||o.darkFallback==="invert"?{light:o.light,...o.dark?{dark:o.dark}:{darkFallback:"invert"}}:o.light,logoAlt:o.alt??u}:{},...n.favicon?{favicon:n.favicon}:{},...e.description?{subtitle:e.description}:{},...m?{typography:m}:{},...n.shape?{shape:n.shape}:{},...n.accents?{accents:n.accents}:{},...n.scheme?{scheme:n.scheme}:{}}}function fn(e){let{currency:s,locale:n,timeZone:t}=e.brand??{};return{...s?{currency:s}:{},...n?{locale:n}:{},...t?{timeZone:t}:{}}}var bn=Symbol.for("@graview/core:typed-field"),pn=(e,s)=>(/^(phone|place|duration)$/.test(s)&&(me(e)[bn]=s),e),mn=/^(?=(?:\D*\d){3})\+?[\d ()./-]+(?: *(?:ext\.?|x|#) *\d+)?$/i;function un(e){let s=M().check(K(300),fe(t=>Be(t,e)!==void 0,`a record of ${e.kinds.join(" or ")} in ${e.address}, as "<kind>:<id>"`)),n=e.cardinality==="one"?s:le(s).check(K(200));return _e(e.description?n.check(pe(e.description)):n,e)}var xn=new WeakMap;function gn(e,s){xn.set(e,s)}var On=[{where:"settings[]",was:"honoured",now:"honored",since:"0.1.16"},{where:"pages",was:"overview",now:"scene",since:"0.1.17"}],V=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function yn(e,s=On){if(!V(e))return{document:e,respelled:[]};let n=[],t=e;for(let o of s)t=Re(t,o.where.split("."),o,"",n);return{document:t,respelled:n}}function Re(e,s,n,t,o){if(s.length===0){if(!V(e)||!Object.hasOwn(e,n.was))return e;o.push(`${t}${n.was}`);let{[n.was]:T,...N}=e;return Object.hasOwn(e,n.now)?N:{...N,[n.now]:T}}if(!V(e))return e;let[u,...m]=s,w=u.endsWith("[]"),L=w?u.slice(0,-2):u,F=e[L],B=F;if(!w)B=Re(F,m,n,`${t}${L}.`,o);else if(Array.isArray(F)){let T=F.map((N,W)=>Re(N,m,n,`${t}${L}.${W}.`,o));B=T.some((N,W)=>N!==F[W])?T:F}return B===F?e:{...e,[L]:B}}var hn="graview-compiled@1";function Rn(e,s){return e.find(([n,t])=>n!==q&&"ref"in t&&(t.ref==="*"||t.ref.includes(s)))?.[0]}var q="id",ue=e=>typeof e=="string"&&/^\$[A-Za-z][A-Za-z0-9]*$/.test(e)?e.slice(1):void 0;function kn(e){let s=Object.entries(e.fields),n=t=>["name","title","label"].find(o=>t.some(([u])=>u===o))??t[0]?.[0];return n(s.filter(([,t])=>t.required&&(t.type==="string"||t.type==="text")))??n(s.filter(([,t])=>t.type==="string"))}function wn(e,s,n){let t;switch(e.type){case"string":case"place":t=M().check(K(500));break;case"phone":t=M().check(K(40),de(mn,"a phone number"));break;case"text":t=M().check(K(2e4)),e.format&&(me(t)[Symbol.for("@graview/core:markdown")]=1);break;case"number":case"integer":case"duration":{let u=e.min??(e.type==="duration"?0:void 0),m=[...e.type==="number"?[]:[Me()],...u===void 0?[]:[Te(u)],...e.max===void 0?[]:[De(e.max)],...e.step===void 0?[]:[$e(e.step)]];t=m.length>0?ce().check(...m):ce();break}case"boolean":t=Le();break;case"date":t=M().check(de(ke,"a date like 2026-10-02"));break;case"datetime":t=M().check(fe(Ce,"a date and time like 2026-10-02T14:30:00Z"));break;case"enum":t=Ne(e.options);break;case"list":t=le(e.of==="number"?ce():e.of==="date"?M().check(de(ke)):e.of==="image"||e.of==="video"||e.of==="file"?we(e.of):M().check(K(500))).check(K(200));break;case"image":case"video":case"file":t=we(e.type);break;case"app-link":t=qe();break;case"url":t=Ge();break;case"email":t=Pe();break}let o=e.type==="number"||e.type==="integer";return pn(t,o&&e.format==="duration"?"duration":e.type),e.description&&(t=t.check(pe(e.description))),o&&(e.format==="money"||e.format==="percent"||!e.format&&e.unit)&&Xe(t,{...n,...e.format?{format:e.format}:{},...e.unit?{unit:e.unit}:{}}),s?ne(t):t}var ie=e=>{throw new U(`there is no record "${e}"`,"invalid")},zn=(e,s)=>"field"in e?wn(e.field,e.optional,s):"ref"in e?en(e.ref):ne(Fe()),An=new WeakMap;var ze=(e,s)=>V(s)&&Object.keys(e??{}).length===Object.keys(s).length&&Object.keys(e??{}).every(n=>Object.hasOwn(s,n));function it(e,s={}){let n=V(e)?e.format:void 0;if(n!==hn)return{ok:!1,findings:[Oe("compiled-format","format",n===void 0?"this is not a compiled Graview app":`this compiled app is ${JSON.stringify(n)}, and this build reads ${hn}`,"compile the document instead")]};let t=e,o=yn(t.document).document,u=o===t.document?t:{...t,document:o},m=V(o)&&typeof o.name=="string"&&V(o.kinds)&&ze(o.kinds,u.kinds)&&ze(o.acts,u.acts)&&ze(o.rules,u.rules)&&Array.isArray(u.edges)&&Array.isArray(u.findings),w={ok:!1,findings:[Oe("compiled-shape","","this compiled app's parts do not match its document","compile the document instead")]};if(!m)return w;try{return Sn(u,s)}catch{return w}}function Sn(e,s={}){let{document:n}=e,t=n.brand?.timeZone,o=s.today??(()=>Ze(t)),u=new Map(e.edges.map(([h,r])=>[h,r])),m=new Map;for(let[h,r]of Object.entries(n.kinds)){let z=e.kinds[h]?.computed,R=ve(r.edges);m.set(h,{fields:new Set([...Object.keys(r.fields),...R.keys()]),edges:new Map(Object.entries(be(r.edges)).map(([j,$])=>[j,$.cardinality??"many"])),...z?{computed:new Map(z)}:{},...R.size>0?{linked:R}:{}})}e.facts&&m.set(an,{computed:new Map(e.facts)});let w=fn(n),L=new Map,F=Object.entries(n.kinds).map(([h,r])=>{let z={};for(let[i,g]of Object.entries(r.fields))z[i]=wn(g,!g.required,w),g.repeats&&(z[He(i)]=ne(Ue()));for(let[i,g]of ve(r.edges))z[i]=ne(un(g));let{label:R,describe:j,durations:$}=e.kinds[h]??{},P=Object.entries(r.computed??{}).map(([i,g])=>[i,typeof g=="string"?{expr:g}:g]),J=Object.hasOwn(r.fields,"label")&&!r.fields.label.label&&!/\{\s*label\b/.test(r.label??`{${kn(r)??""}}`),_=Object.fromEntries([...J?[["label","Label"]]:[],...Object.entries(r.fields).filter(([,i])=>i.label).map(([i,g])=>[i,g.label]),...P.filter(([,i])=>i.label).map(([i,g])=>[i,g.label])]),A=Object.keys(_).length>0,l=Object.fromEntries(Object.entries(r.fields).filter(([,i])=>i.default!==void 0).map(([i,g])=>[i,g.default]));L.set(h,l);let D=Object.fromEntries(Object.entries(be(r.edges)).map(([i,{renamedFrom:g,...I}])=>[i,I])),S=i=>r[i]?{[i]:r[i]}:{};return Ke(h,{fields:he(z),edges:D,...S("plural"),...S("noun"),...S("description"),...R?{label:i=>oe(R,{node:i,kinds:m,today:o(),money:w})||i.id}:{},...j?{describe:i=>oe(j,{node:i,kinds:m,today:o(),money:w})}:{},...S("lifecycle"),...S("figure"),...S("fieldRoles"),...S("people"),archives:r.archives,...r.tidying?{tidying:r.tidying}:{},...P.length>0?{computed:Object.fromEntries(P.map(([i,g])=>[i,$?.includes(i)?{...g,as:"duration"}:r.computed[i]]))}:{},...A||r.glance||r.page?{display:{...A?{labels:_}:{},...r.glance?{glance:[...r.glance]}:{},...r.page?{page:r.page}:{}}}:{},...Object.keys(l).length>0?{defaults:l}:{}})}),B=We(F,n.computed);function T(h){return B.tryDefinition(h.kind)?.label?.(h)??h.id}let N=h=>({id:"",kind:h,...L.get(h)}),W=[];for(let[h,r]of Object.entries(n.acts??{})){let z=e.acts[h],{title:R,effects:j,guard:$,refusal:P,destructive:J,idempotent:_,creates:A,connects:l,severs:D,writes:S,writesOther:i,sets:g}=z,I=new Map(z.args),ae={};for(let[d,x]of I)ae[d]=zn(x,w);let b=[r.on??[]].flat(),C=new Map(z.exprs),G=j.find(d=>"create"in d),Y=(d,x,f,v=null)=>{if(V(d)&&"expr"in d)return re(C.get(d.expr),{graph:f,subject:v,kinds:m,bindings:x,today:o()});let k=ue(d);return k===void 0?typeof d=="string"&&d.startsWith("$$")?d.slice(1):d:k==="now"?new Date().toISOString():k==="today"?o():x[k]},Ee=(d,x)=>{if(!G)return"";let f=n.kinds[G.create].fields,v=N(G.create),k=[];for(let[O,ee]of Object.entries(G.set??{})){try{v[O]=Y(ee,d,x)??v[O]}catch{}let Q=ue(ee);Q&&d[Q]!==void 0&&k.push(O)}let Z=T(v).trim(),H=k.filter(O=>v[O]!==!1&&f[O].type!=="text"&&!(/[^]{41}/.test(v[O])||/ .*[.!?]$/.test(v[O])&&!/[ .][A-Z]\w{0,3}\.$/.test(v[O]))&&T({...v,[O]:void 0}).trim()===Z).map(O=>v[O]===!0?f[O].label??Ve(O):cn(v[O],f[O].format,o(),[],w));return Z&&H.length>0?`${Z} (${H.join(", ")})`:Z};W.push(Qe(h,{input:he(ae),title:R,...r.description?{description:r.description}:{},...r.fromTheOtherEnd?{fromTheOtherEnd:r.fromTheOtherEnd}:{},...I.has(q)?{subject:{kinds:b.length>0?b:"*",arg:q}}:{},...J?{destructive:!0}:{},..._?{idempotent:!0}:{},...A.length>0?{creates:A}:{},...l.length>0?{connects:l}:{},...D.length>0?{severs:D}:{},writes:S,...Object.keys(i).length>0?{writesOther:i}:{},...Object.keys(g).length>0?{sets:g}:{},describe:(d,x)=>{let f=typeof d[q]=="string"?x.getNode(d[q]):void 0,v=f?T(f):Ee(d,x);return v?`${R}: ${v}`:R},apply(d,x){let f=d.graph,v=typeof x[q]=="string"?x[q]:void 0,k=v?f.getNode(v):void 0;if(v&&!k&&ie(v),k&&b.length>0&&!b.includes(k.kind))throw new U(`"${R}" acts on ${b.join(" or ")}, not on ${Ie(k.kind)}`,"invalid");let Z={};for(let[a,c]of Object.entries(x))c!==void 0&&(Z[a]=c);if($&&k){let a;try{a=re($,{graph:f,subject:k,kinds:m,bindings:Z,today:o()})}catch(c){throw c instanceof te?new U(`"${R}" could not be judged: ${c.sentence}`):c}if(a!==!0)throw new U(P?oe(P,{node:k,kinds:m,graph:f,bindings:Z,today:o(),money:w}):`"${R}" is not allowed for ${T(k)} right now`)}let H=new Map,O=a=>f.has(a)||[...H.values()].includes(a),ee=new Set,Q=a=>{let c=Je(a);ee.has(c)||(ee.add(c),d.removeEdge(a))},X=(a,c)=>{let p=ue(a);if(p==="subject")return v;if(p==="me"){let y=d.me;if(y&&n.kinds[f.getNode(y)?.kind]?.people)return y;throw new U(`"${R}" is done as you, and you have no record here`)}if(H.has(p))return H.get(p);try{return Y(a,Z,f,c??k??null)}catch(y){throw y instanceof te?new U(`"${R}" could not work out a value: ${y.sentence}`):y}};for(let a of j)if("create"in a){let c=n.kinds[a.create],p=N(a.create);for(let[ye,se]of Object.entries(a.set??{})){let je=X(se,void 0);je!==void 0&&(p[ye]=je)}let y=kn(c),E=d.freshId(String((y&&p[y])??a.create),a.create);d.addNode({...p,id:E}),a.as&&H.set(a.as,E)}else if("connect"in a||"sever"in a){let c="connect"in a?a.connect:a.sever,p=String(X(a.from,void 0)??""),y=String(X(a.to,void 0)??"");if(O(p)||ie(p),O(y)||ie(y),"connect"in a){if(u.get(c)?.cardinality==="one")for(let E of f.out(p,c))E.id!==y&&Q({kind:c,from:p,to:E.id});f.out(p,c).some(E=>E.id===y)||d.addEdge({kind:c,from:p,to:y})}else Q({kind:c,from:p,to:y})}else if("set"in a){let c=String(X(a.target??"$subject",void 0)??""),p=f.getNode(c);!p&&!O(c)&&ie(c);let y={};for(let[E,ye]of Object.entries(a.set)){let se=X(ye,p);se!==void 0&&(y[E]=se)}Object.keys(y).length>0&&d.patchNode(c,y)}else if("remove"in a){let c=String(X(a.remove,void 0)??"");f.has(c)||ie(c),d.removeNode(c)}else if("replace"in a&&k){let c=x.to;for(let p of a.replace){let y=u.get(p)?.from.includes(k.kind)??!0;for(let E of y?f.out(k.id,p):f.in(k.id,p))p===a.keep&&E.id===c||Q(y?{kind:p,from:k.id,to:E.id}:{kind:p,from:E.id,to:k.id})}}}}))}let Ae=[];for(let[h,r]of Object.entries(n.rules??{})){let{title:z,require:R,when:j,says:$}=e.rules[h],P=r.repairs??[],J=(A,l,D=o(),S)=>{let i=[],g={graph:A,subject:l,kinds:m,today:D,...S?{linked:S}:{},onUnread:b=>i.push(b)},I;try{if(j&&re(j,g)!==!0)return[];if(I=re(R,g)===!0,!I&&i.length>0)throw new te(`it reads ${on(i[0])}`,0)}catch(b){throw b instanceof sn?new Ye(b.sentence):b instanceof te?new Error(b.sentence):b}if(I)return[];let ae=P.flatMap(b=>{let C=n.acts?.[b.act],G={},Y=l&&C?.on&&C.fromTheOtherEnd&&![C.on].flat().includes(l.kind)?Rn(e.acts[b.act].args,l.kind):void 0;Y?G[Y]=l.id:l&&(C?.on||/^(edit|remove|archive|unarchive|merge|skip|detach|split)-/.test(b.act))&&(G[q]=l.id);for(let[x,f]of Object.entries(b.args??{}))G[x]=ue(f)==="subject"?l?.id:f;let d=(C?e.acts[b.act].args:[]).filter(([x,f])=>f.required&&G[x]===void 0).map(([x])=>x);return[{mutation:b.act,label:b.label??(Y?C.fromTheOtherEnd:C?.title)??b.act.replace(/-/g," "),args:G,...d.length>0?{missing:d}:{}}]});return[{invariant:h,...l?{subjectId:l.id}:{},label:z,message:$?oe($,{node:l,kinds:m,graph:A,today:D,money:w}):l?`${T(l)}: ${z}`:z,nodeIds:l?[l.id]:[],repairs:ae}]},_={label:z,shape:{over:r.over,require:R,when:j,says:$,declared:n.kinds,money:w,kinds:m,today:o},judgment:{require:r.require,...r.when?{when:r.when}:{},...r.says?{says:r.says}:{}},...r.description?{description:r.description}:{},...P.length>0?{repairs:P.map(A=>A.act)}:{}};Ae.push(r.over==="graph"?xe(h,{scope:"graph",..._,evaluate:({graph:A,today:l,context:D})=>J(A,null,l,D?.linked)}):xe(h,{scope:{kind:r.over},..._,evaluate:({graph:A,subject:l,today:D,context:S})=>J(A,l,D,S?.linked)}))}let Se=n.policy&&{...n.policy,...n.roles?{roles:n.roles}:{}},ge={name:n.name,schema:B,mutations:W,invariants:Ae,...Se?{policy:Se}:{},...e.brand?{brand:e.brand}:{},...n.modules?{modules:n.modules}:{},...n.lenses?{lenses:n.lenses}:{},...n.pages?{pages:n.pages}:{},...n.settings?{settings:n.settings}:{},...n.connections?{connections:n.connections}:{},...n.forms?{forms:n.forms}:{},...e.viewSpecs?{viewSpecs:e.viewSpecs}:{},...e.home?{home:e.home}:{},version:n.version??1};return gn(ge,n),An.set(ge,e),{ok:!0,app:ge,document:n,findings:e.findings,sights:n.policy?.sees,kinds:m}}export{yn as a,Gn as b,hn as c,q as d,ue as e,kn as f,it as g,Sn as h};
@@ -1 +0,0 @@
1
- import{a as we,b as De,c as Ke,d as le,e as A,f as Me,h as Te}from"./chunk.MGWMGLWE.js";import{h as Ge,i as Ce,j as Ne}from"./chunk.IKX4VDTW.js";import{a as oe,b as se,c as H,d as Pe,e as Y,g as ee,h as _e}from"./chunk.TBQOSI4J.js";import{c as Ae,h as z,i as Fe,j as de}from"./chunk.KWQ7QOHD.js";import{A as ve,Ga as Ee,Ha as Q,Ia as ae,Lb as ce,Mb as Re,b as L,c as q,e as Se,f as je,g as _,h as S,k as G,l as J,m as C,n as Oe,o as B,p as D,r as $,s as X,t as E,u as R,v as V,w as T,x as e,y as K,z as U,za as xe}from"./chunk.AS4CQBOQ.js";var sn=n=>Object.entries(n).map(([s,r])=>[s,Object.keys(Q(r?.edges))]),pe=(n,s)=>Re(n,sn(s));var me="graview-document",ge=1,ze=256*1024,ne=64*1024,fe=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,ue=/^[a-z][A-Za-z0-9]*$/,rn=new Set(["id","kind"]),an=/^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|[a-z][A-Za-z0-9]*)$/,cn=["string","text","number","integer","boolean","date","datetime","enum","list","url","email","image","video","file","app-link","phone","place","duration"];function dn(){let n=k=>k in Object.prototype,s=U(k=>!n(k),"every object already has this name \u2014 choose another"),r=(k,N)=>[...k===void 0?[]:[je(k)],...N===void 0?[]:[Se(N)]],t=(k,N)=>S().check(...r(k,N)),a=(k,N,on)=>D(k).check(...r(N,on)),d=k=>S().check(_(fe,`${k} names are kebab-case, lower-case words joined by hyphens like "tool-note" (field and relation names are camelCase, like "supersededBy")`)),u=S().check(_(an,'relation names are one camelCase word, like "supersededBy" (kind names are kebab-case, like "tool-note")'),s),m=S().check(_(ue,'field names are one word or camelCase, like "dueDate", so rules say them bare (kind names are kebab-case, like "tool-note")'),U(k=>!rn.has(k),'a field cannot be called "id" or "kind" \u2014 the framework keeps those; try "type" or "category"'),s),h=t(1,500),i=t(1,2e3),o=t(1,300),p=$({type:V(cn),required:e(C()),description:e(h),label:e(t(1,60)),options:e(a(t(1,80),1,100)),of:e(V(["string","number","date","image","video","file"])),default:e(B()),unit:e(t(void 0,12)),format:e(V(["money","percent","duration","markdown"])),min:e(G()),max:e(G()),step:e(G()),renamedFrom:e(S().check(_(ue))),repeats:e(C())}).check(ve((k,N)=>{k.type==="enum"&&!k.options&&N.addIssue({code:"custom",message:'an enum field lists its "options"',path:["options"]}),k.type!=="enum"&&k.options&&N.addIssue({code:"custom",message:'"options" belongs only on an enum field',path:["options"]}),k.type!=="list"&&k.of&&N.addIssue({code:"custom",message:'"of" belongs only on a list field',path:["of"]}),k.repeats&&k.type!=="date"&&k.type!=="datetime"&&N.addIssue({code:"custom",message:'"repeats" belongs only on a date or datetime field',path:["repeats"]})})),w=S().check(_(new RegExp(`${fe.source}|${xe.source}`),'a relation goes to a kind of this document, like "house", or of another app, like "@nick/house/house"')),f=$({to:E([a(w,1),T("*")]),cardinality:e(V(["one","many"])),description:e(h),inverse:e(t(1,80)),appendOnly:e(C()),renamedFrom:e(S()),tidying:e(T("never"))}),l=E([i,$({expr:i,label:e(t(1,60)),description:e(h)})]),c=$({noun:e(t(1,40)),plural:e(t(1,40)),description:e(h),fields:R(m,p).check(U(k=>Object.keys(k).length>0,"a kind has at least one field")),label:e(o),describe:e(o),lifecycle:e($({field:m,retired:a(E([S(),G(),C()]),1)})),figure:e(t(void 0,2e4)),glance:e(a(m,1,20)),page:e($({fields:e(a(m,1,40)),groups:e(a($({title:t(1,60),fields:a(m,1,40)}),1,12))})),edges:e(R(u,f)),computed:e(R(S(),l).check(U(k=>Object.keys(k).length<=20,"a kind works out at most 20 computed fields"))),fieldRoles:e(R(S(),S())),renamedFrom:e(S().check(_(fe))),people:e(C()),archives:e(T(!1)),tidying:e(V(["never","no-links"]))}),O=E([S(),G(),C(),Oe(),D(B()),$({expr:i})]),y=S().check(_(/^\$[A-Za-z][A-Za-z0-9]*$/,'a reference is "$" and a name, like "$subject" or "$new"')),j=E([$({create:d("kind"),as:e(S().check(_(ue))),set:e(R(m,O))}),$({set:R(m,O),target:e(y)}),$({connect:u,from:y,to:y}),$({sever:u,from:y,to:y}),$({remove:y})]),v=$({title:e(t(1,80)),description:e(h),fromTheOtherEnd:e(t(1,80)),on:e(E([d("kind"),a(d("kind"),1)])),creates:e(d("kind")),sets:e(R(m,O)),writes:e(a(m,1)),connects:e(u),severs:e(u),setsOther:e(R(m,O)),replaces:e(E([T(!0),a(u,1,10)])),removes:e(T(!0)),args:e(R(m,p)),effects:e(a(j,1,20)),allowedWhen:e(i),refusal:e(o),destructive:e(C())}),b=$({act:d("act"),label:e(t(1,80)),args:e(R(S(),O))}),W=$({title:e(t(1,120)),description:e(h),over:E([T("graph"),d("kind")]),when:e(i),require:i,says:e(o),repairs:e(a(b,void 0,10))}),P=$({roles:E([a(d("role"),1),T("*")]),mutations:E([a(d("act"),1),T("*")]),kinds:e(E([D(d("kind")),T("*")])),describe:e(h),self:e(C()),ownEnd:e(C())}),g=e(a(d("field"),1)),x=$({roles:E([a(d("role"),1),T("*")]),kinds:a(d("kind"),1),own:e(C()),via:e(u),fields:g,hide:g}),F=$({grants:D(P),sees:e(D(x))}),te=$({accent:e(S().check(_(/^#[0-9a-fA-F]{6}$/,'an accent is a color like "#c2577a"'))),name:e(t(1,60)),currency:e(S().check(_(/^[A-Z]{3}$/,'a currency is its three-letter code, like "USD" or "EUR"'))),locale:e(t(2,35)),timeZone:e(t(1,64)),logo:e(E([t(1,ne),$({src:t(1,ne),alt:e(t(1,120))}),$({light:t(1,ne),dark:e(t(1,ne)),alt:e(t(1,120)),darkFallback:e(T("invert"))})])),favicon:e(E([t(1,ne),$({emoji:S()})])),typography:e($({display:e(t(1,200)),body:e(t(1,200)),mono:e(t(1,200))})),shape:e($({radius:e(G().check(q(0),L(32))),density:e(G().check(q(.75),L(1.5)))})),accents:e(R(S(),G().check(q(0),L(360)))),scheme:e(V(["light","dark","auto"]))}),I=R(S(),B()),Z=E([t(1,120),$({by:t(1,120),direction:e(V(["asc","desc"]))})]),ke=G().check(J(),q(1),L(9999)),Je=X({create:e(C()),options:e(X({sort:e(Z),columnSort:e(Z),search:e(a(t(1,120),void 0,40)),filters:e(a(t(1,120),void 0,40)),horizon:e(E([G().check(J(),q(1),L(200)),X({years:G().check(J(),q(1),L(200)),title:t(1,80),from:e(ke),to:e(ke)})]))}))}),Xe=$({card:e(D(B())),row:e(D(B())),page:e(D(B()))}),Qe=()=>{let k=e(V(["asc","desc"]));return E([t(1,120),$({by:t(1,120),direction:k,then:e(E([t(1,120),$({by:t(1,120),direction:k})]))})])},en=()=>E([t(1,120),$({by:t(1,120),order:e(a(t(1,80),void 0,40)),closed:e(a(t(1,80),void 0,40))})]),$e=X({order:e(D(S())),hide:e(D(S())),first:e(S()),primary:e(a(t(1,80),void 0,40)),scene:e(t(1,40)),pages:e(t(1,40)),lists:e(R(S(),$({filters:e(a(t(1,120),void 0,40)),sort:e(Qe()),group:e(en())})))}),nn=$({act:d("act"),title:e(t(1,80)),intro:e(h),fields:e(a(m,1,40)),say:e(h),submit:e(t(1,80)),role:e(d("role"))}),tn=$({$schema:e(S()),format:T(me),formatVersion:T(ge),name:t(1,80),description:e(h),version:e(G().check(J(),q(1))),kinds:R(d("kind"),c).check(U(k=>Object.keys(k).length>0,"a document declares at least one kind"),U(k=>Object.keys(k).length<=40,"a document declares at most 40 kinds")),computed:e(R(S(),l)),acts:e(R(d("act"),v)),rules:e(R(d("rule"),W)),roles:e(D(d("role"))),policy:e(F),modules:e(I),lenses:e(D(Je)),pages:e($e),views:e(R(S(),E([Xe,D(B())]))),brand:e(te),settings:e(D(I)),migrations:e(D(I)),connections:e(R(d("connection"),I)),forms:e(R(d("form"),nn))});return{FieldSpec:p,EdgeSpec:f,ComputedSpec:l,KindSpec:c,ValueSpec:O,EffectSpec:j,ActSpec:v,RepairSpec:b,RuleSpec:W,GrantSpec:P,SightSpec:x,PolicySpec:F,BrandSpec:te,PagesSpec:$e,DocumentSpec:tn}}var ln,M=()=>ln??=dn(),jn=K(()=>M().FieldSpec),On=K(()=>M().EdgeSpec),vn=K(()=>M().ComputedSpec),xn=K(()=>M().KindSpec),En=K(()=>M().ValueSpec),Rn=K(()=>M().EffectSpec),An=K(()=>M().ActSpec),Fn=K(()=>M().RepairSpec),Dn=K(()=>M().RuleSpec),Kn=K(()=>M().GrantSpec),Mn=K(()=>M().SightSpec),Tn=K(()=>M().PolicySpec),Pn=K(()=>M().BrandSpec),Gn=K(()=>M().PagesSpec),Ie=K(()=>M().DocumentSpec);var pn={};function Ve(n,s=pn,r=ge){let{document:t,respelled:a}=we(n),d=a.length>0?{respelled:a}:{};if(!t||typeof t!="object"||Array.isArray(t))return{document:t};let u=t;if(u.format!==me||typeof u.formatVersion!="number"||u.formatVersion>=r)return{document:t,...d};let m=u.formatVersion,h=structuredClone(u);for(let i=m;i<r;i++){let o=s[i];if(!o)throw new Error(`there is no upgrade from format ${i} to ${i+1}`);h={...o(h),formatVersion:i+1}}return{document:h,from:m,...d}}function qe(n,s,r){let t=Object.keys(n).filter(m=>n[m].edges?.[s]!==void 0);if(t.length===0)return;let a=t.map(m=>n[m].edges[s].to),d=a.some(m=>m==="*")?"*":[...new Set(a.flatMap(m=>m))];if(r.length===0||r.some(m=>t.includes(m)))return{reversed:!1,kinds:d};let u=t.filter(m=>{let h=n[m].edges[s].to;return h==="*"||r.every(i=>h.includes(i))});return u.length>0?{reversed:!0,kinds:u}:{reversed:!1,kinds:d}}var Ue=(n,s)=>{let r=n?.fields[s];return r!==void 0&&(r.type==="duration"||(r.type==="number"||r.type==="integer")&&r.format==="duration")};function Be(n,s,r,t){if(t==="out"){let a=n[s]?.edges?.[r]?.to;return a===void 0?[]:a==="*"?Object.keys(n):a}return Object.entries(n).filter(([,a])=>{let d=a.edges?.[r]?.to;return d!==void 0&&(d==="*"||d.includes(s))}).map(([a])=>a)}function ye(n,s,r){if(r.t==="ident")return n[s]?.edges?.[r.name]?Be(n,s,r.name,"out"):void 0;if(r.t==="where")return ye(n,s,r.set);if(r.t==="call"&&(r.fn==="out"||r.fn==="in")&&r.args[0]?.t==="lit"&&typeof r.args[0].value=="string")return Be(n,s,r.args[0].value,r.fn)}var Le=(n,s,r)=>{let t=s.filter(a=>n[a]?.fields[r]!==void 0);return t.length>0&&t.every(a=>Ue(n[a],r))};function We(n,s,r){let t=n.kinds,a=t[s],d=new Map(r),u=new Map,m=(i,o)=>{if(o>8)return!1;switch(i.t){case"ident":return Ue(a,i.name)||h(i.name,o+1);case"member":{let p=ye(t,s,i.object);return p!==void 0&&Le(t,p,i.name)}case"call":{if(i.fn!=="sum"&&i.fn!=="min"&&i.fn!=="max")return!1;let[p,w]=i.args,f=p&&ye(t,s,p);return f!==void 0&&w?.t==="ident"&&Le(t,f,w.name)}case"binary":return(i.op==="+"||i.op==="-")&&m(i.left,o)&&m(i.right,o);case"unary":return i.op==="-"&&m(i.operand,o);default:return!1}},h=(i,o)=>{if(a?.computed?.[i]===void 0)return!1;if(u.has(i))return u.get(i);u.set(i,!1);let p=d.get(i),w=p!==void 0&&m(p,o);return u.set(i,w),w};return r.map(([i])=>i).filter(i=>h(i,0))}function Ze(n,s,r=`kinds.${n}.page`){let t=s.page;if(!t)return[];let a=[],d=[...Object.keys(s.fields),...Object.keys(s.computed??{})],u=new Set,m=(i,o)=>{d.includes(i)?u.has(i)&&a.push(z("page-field-twice",o,`"${i}" is on ${n}'s page twice; name each field once`)):a.push(z("page-field",o,`${n}'s page is to show "${i}", and ${n} has no field or computed field called that`,`use one of: ${d.join(", ")}`)),u.add(i)};(t.fields??[]).forEach((i,o)=>m(i,`${r}.fields.${o}`));let h=new Set;return(t.groups??[]).forEach((i,o)=>{let p=i.title.trim().toLowerCase();h.has(p)&&a.push(z("page-group-twice",`${r}.groups.${o}.title`,`${n}'s page has two groups called "${i.title}"; give each its own title`)),h.add(p),i.fields.forEach((w,f)=>m(w,`${r}.groups.${o}.fields.${f}`))}),a}var fn=new Set(["subject","now","today","me"]);function un(n){if((typeof n=="string"?n:JSON.stringify(n??null)).length>ze)return{findings:[z("too-large","",`a document may be at most ${ze/1024} KB`)]};if(typeof n=="string")try{n=JSON.parse(n)}catch(t){return{findings:[z("not-json","",`this is not JSON: ${t.message}`)]}}try{n=Ve(n).document}catch(t){return{findings:[z("format","formatVersion",t.message)]}}let s=Ie.safeParse(n);if(!s.success)return{findings:s.error.issues.map(t=>{let a=t.path.map(String).join(".");if(t.code==="unrecognized_keys")return z("unknown-key",a,`${t.keys.map(d=>`"${d}"`).join(", ")} ${t.keys.length===1?"is":"are"} not part of a Graview document here`,"check the spelling against docs/declaration-document.md");if(t.code==="invalid_union"&&/\.effects\.\d+$/.test(a))return z("effect-shape",a,"this effect is not one Graview knows",'an effect is one of {"create": kind, "as"?: name, "set"?: {field: value}}, {"set": {field: value, \u2026}, "target"?: "$ref"}, {"connect"|"sever": relation, "from": "$ref", "to": "$ref"}, {"remove": "$ref"}');if(t.code==="invalid_key"){let d=t.issues?.[0]?.message;return z("shape",a,`the name "${String(t.path.at(-1))}" is not allowed here${d?`: ${d}`:""}`)}return z("shape",a,t.message)})};let r=s.data;return{document:r,findings:mn(r)}}var re=n=>[n??[]].flat();function He(n){let s=new Map;for(let[r,t]of Object.entries(n.kinds))for(let[a,d]of Object.entries(Q(t.edges))){let u=s.get(a);s.set(a,{name:a,from:[...u?.from??[],r],to:d.to==="*"||u?.to==="*"?"*":[...new Set([...u?.to??[],...d.to])],cardinality:d.cardinality??"many"})}return s}function pt(n){let s=new Map;for(let[t,a]of Object.entries(n.kinds)){let d=ee(a),u=ae(a.edges);s.set(t,{fields:new Set([...Object.keys(a.fields),...u.keys()]),edges:new Map(Object.entries(Q(a.edges)).map(([m,h])=>[m,h.cardinality??"many"])),...d?{computed:d}:{},...u.size>0?{linked:u}:{}})}let r=ee(n);return r&&s.set(Ae,{computed:r}),s}function Ye(n,s){let r=[],t=re(n.on),a=(d,u)=>{let m=qe(s.kinds,d,t)?.reversed===!0,[h,i]=m?["$to","$subject"]:["$subject","$to"];return u==="connect"?{connect:d,from:h,to:i}:{sever:d,from:h,to:i}};if(n.creates){let d=s.kinds[n.creates],u={};for(let m of Object.keys(d?.fields??{}))u[m]=`$${m}`;for(let m of n.effects??[])"set"in m&&!("create"in m)&&A(m.target)==="new"&&Object.assign(u,m.set);r.push({create:n.creates,as:"new",set:u})}return n.sets&&r.push({set:n.sets}),n.writes&&!(n.creates&&n.on===void 0)&&r.push({set:Object.fromEntries(n.writes.map(d=>[d,`$${d}`]))}),n.connects&&(n.replaces&&r.push({replace:n.replaces===!0?[n.connects]:[...n.replaces],keep:n.connects}),r.push(a(n.connects,"connect"))),n.severs&&r.push(a(n.severs,"sever")),n.setsOther&&(n.connects||n.severs)&&r.push({set:n.setsOther,target:"$to"}),n.removes&&r.push({remove:"$subject"}),n.effects&&r.push(...n.effects.filter(d=>!(n.creates&&"set"in d&&!("create"in d)&&A(d.target)==="new"))),r}function he(n,s,r){try{let t=H(n),a=oe(t);for(let d of a.unknownFunctions)r.push(z("unknown-function",s,`"${d}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));return t}catch(t){if(t instanceof se){r.push(z("expression",s,t.sentence+` (at character ${t.at+1})`));return}throw t}}function be(n,s,r){try{return Y(n)}catch(t){if(t instanceof Pe||t instanceof se){r.push(z("template",s,(t instanceof se,t.sentence)));return}throw t}}function mn(n){let s=[],r=new Set(Object.keys(n.kinds)),t=He(n),a=n.acts??{},d=new Set(n.roles??[]),u=(i,o)=>ae(n.kinds[i]?.edges).has(o),m=i=>Object.keys(n.kinds).some(o=>u(o,i));for(let[i,o]of Object.entries(n.kinds)){let p=`kinds.${i}`;for(let[f,l]of Object.entries(o.edges??{})){if(!Ee(l)&&l.to!=="*")for(let c of l.to)r.has(c)||s.push(z("edge-target",`${p}.edges.${f}.to`,`"${c}" is not a kind this document declares`));o.fields[f]&&s.push(z("edge-field-clash",`${p}.edges.${f}`,`"${f}" is both a field and a relation of ${i}`,"rename one of them"))}o.lifecycle&&!o.fields[o.lifecycle.field]&&s.push(z("lifecycle-field",`${p}.lifecycle.field`,`${i} has no field "${o.lifecycle.field}"`));let w=f=>o.computed!==void 0&&Object.hasOwn(o.computed,f);for(let f of o.glance??[])!o.fields[f]&&!w(f)&&s.push(z("glance-field",`${p}.glance`,`a glance at ${i} is to say "${f}", and ${i} has no field or computed field called that`,`use one of: ${[...Object.keys(o.fields),...Object.keys(o.computed??{})].join(", ")}`));s.push(...Ze(i,o));for(let f of["label","describe"]){let l=o[f];if(!l)continue;let c=be(l,`${p}.${f}`,s);for(let O of c??[])if(O.expr){for(let y of oe(O.expr).names)if(!o.fields[y]){if(w(y)){_e(o,y)||s.push(z("template-field",`${p}.${f}`,`${i}'s ${y} is worked out from beyond the record, and a ${f} is said with no graph to read`,`show it in a view instead, or name a computed field worked out from ${i}'s own fields`));continue}s.push(z("template-field",`${p}.${f}`,`${i} has no field "${y}" for its ${f} to show`,f==="label"?"a label can only show the record's own fields and what they work out":void 0))}}}for(let[f,l]of Object.entries(o.fields)){l.default!==void 0&&l.type==="enum"&&!l.options?.includes(String(l.default))&&s.push(z("default-option",`${p}.fields.${f}.default`,`"${String(l.default)}" is not one of ${f}'s options`));let c=`${f}Repeat`;l.repeats&&(o.fields[c]||o.edges?.[c]||o.computed?.[c])&&s.push(z("repeat-clash",`${p}.fields.${f}.repeats`,`${i} already has "${c}", where how ${f} repeats is kept`))}}for(let[i,o]of Object.entries(a)){let p=`acts.${i}`;for(let c of re(o.on))r.has(c)||s.push(z("act-kind",`${p}.on`,`"${c}" is not a kind this document declares`));let w=re(o.on),f=Ye(o,n);if(o.creates&&o.on===void 0&&o.writes&&r.has(o.creates)){for(let c of o.writes)if(!n.kinds[o.creates].fields[c])if(n.kinds[o.creates].computed?.[c]!==void 0)s.push(z("computed-written",`${p}.writes`,`${o.creates}'s ${c} is worked out, not written: no act can set it`,"write the stored fields it is worked out from"));else{if(u(o.creates,c))continue;s.push(z("act-field",`${p}.writes`,`${o.creates} has no field "${c}"`))}}f.length===0&&s.push(z("act-empty",p,`"${i}" does nothing`,"give it effects or a shorthand such as sets or creates"));let l=new Map;f.forEach((c,O)=>{let y=f.length-(o.effects?.length??0),j=o.effects&&O>=y?`${p}.effects.${O-y}`:p;if("create"in c){if(!r.has(c.create))s.push(z("act-kind",`${j}.create`,`"${c.create}" is not a kind this document declares`));else for(let b of Object.keys(c.set??{}))n.kinds[c.create].fields[b]||(n.kinds[c.create].computed?.[b]!==void 0?s.push(z("computed-written",`${j}.set.${b}`,`${c.create}'s ${b} is worked out, not written: no act can set it`,"set the stored fields it is worked out from")):s.push(z("act-field",`${j}.set.${b}`,`${c.create} has no field "${b}"`)));c.as&&l.set(c.as,c.create)}else if("connect"in c||"sever"in c){let b="connect"in c?c.connect:c.sever;!t.has(b)&&!m(b)&&s.push(z("act-edge",`${j}.${"connect"in c?"connect":"sever"}`,`"${b}" is not a relation any kind declares`)),A(c.from)==="subject"&&w.length===0&&s.push(z("act-subject",`${p}.on`,`"${i}" acts on "$subject" but does not say which kinds it is "on"`))}else if("set"in c){let b=A(c.target??"$subject"),W=b==="subject"?w:l.has(b??"")?[l.get(b)]:[];b==="subject"&&w.length===0&&s.push(z("act-subject",`${p}.on`,`"${i}" changes "$subject" but does not say which kinds it is "on"`));for(let P of Object.keys(c.set))for(let g of W)if(!(!r.has(g)||n.kinds[g].fields[P]))if(n.kinds[g].computed?.[P]!==void 0)s.push(z("computed-written",`${j}.set.${P}`,`${g}'s ${P} is worked out, not written: no act can set it`,"set the stored fields it is worked out from"));else{if(u(g,P))continue;s.push(z("act-field",`${j}.set.${P}`,`${g} has no field "${P}"`))}}else"remove"in c&&A(c.remove)==="subject"&&w.length===0&&s.push(z("act-subject",`${p}.on`,`"${i}" removes "$subject" but does not say which kinds it is "on"`));("set"in c&&c.set?Object.values(c.set):[]).forEach(b=>{b&&typeof b=="object"&&!Array.isArray(b)&&"expr"in b&&he(b.expr,`${j}.set`,s)})}),o.allowedWhen&&he(o.allowedWhen,`${p}.allowedWhen`,s),o.refusal&&be(o.refusal,`${p}.refusal`,s)}for(let[i,o]of Object.entries(n.rules??{})){let p=`rules.${i}`;o.over!=="graph"&&!r.has(o.over)&&s.push(z("rule-kind",`${p}.over`,`"${o.over}" is not a kind this document declares`));let w=o.over==="graph"?void 0:n.kinds[o.over];for(let f of["when","require"]){let l=o[f];if(!l)continue;let c=he(l,`${p}.${f}`,s);if(!c)continue;let O=oe(c);for(let y of O.names)if(o.over==="graph")s.push(z("rule-name",`${p}.${f}`,`"${y}" means nothing in a rule over the whole graph`,`name a kind in "over", or use all('kind')`));else if(w&&!w.fields[y]&&!w.edges?.[y]&&w.computed?.[y]===void 0){let j=Object.keys(w.edges??{}).find(v=>v.includes("-")&&v.split("-").includes(y));s.push(z("rule-name",`${p}.${f}`,`${o.over} has no field or relation called "${y}"`,j?`"${j}" reads as a subtraction in a rule; rename the relation to one camelCase word, like "${j.replace(/-([a-z0-9])/g,(v,b)=>b.toUpperCase())}"`:void 0))}for(let y of O.edges)!t.has(y)&&!m(y)&&s.push(z("rule-edge",`${p}.${f}`,`"${y}" is not a relation any kind declares`));for(let y of O.sweeps)r.has(y)?o.over!=="graph"&&s.push(Fe("rule-cost",`${p}.${f}`,`this rule looks at every ${y} for every ${o.over}, which grows slowly as the app grows`,"walk a relation with out()/in() instead of all() where you can")):s.push(z("rule-kind",`${p}.${f}`,`"${y}" is not a kind this document declares`))}o.says&&be(o.says,`${p}.says`,s),(o.repairs??[]).forEach((f,l)=>{!a[f.act]&&!ce(f.act)&&!pe(f.act,n.kinds)&&s.push(z("repair-act",`${p}.repairs.${l}.act`,`"${f.act}" is not an act this document declares`))})}let h=n.policy;return h&&(h.grants.forEach((i,o)=>{if(i.roles!=="*"&&d.size>0)for(let p of i.roles)d.has(p)||s.push(z("grant-role",`policy.grants.${o}.roles`,`"${p}" is not one of the document's roles`));if(i.mutations!=="*")for(let p of i.mutations)!a[p]&&!ce(p)&&!pe(p,n.kinds)&&s.push(z("grant-act",`policy.grants.${o}.mutations`,`"${p}" is not an act this document declares`))}),(h.sees??[]).forEach((i,o)=>{for(let p of i.kinds)r.has(p)||s.push(z("sight-kind",`policy.sees.${o}.kinds`,`"${p}" is not a kind this document declares`));if(i.roles!=="*"&&d.size>0)for(let p of i.roles)d.has(p)||s.push(z("sight-role",`policy.sees.${o}.roles`,`"${p}" is not one of the document's roles`))})),s.push(...Ne(n)),s}function gn(n,s,r,t){let a=new Map,d=re(n.on),u=new Map,m=new Map;(d.length>0||s.some(l=>"remove"in l&&A(l.remove)==="subject"||"from"in l&&(A(l.from)==="subject"||A(l.to)==="subject")||"set"in l&&!("create"in l)&&A(l.target??"$subject")==="subject"))&&a.set(le,{ref:d.length>0?d:"*",required:!0});let i=n.args??{},o=n.writes?.length===1,p=(l,c)=>c&&l.type===c.type&&l.min===void 0&&l.max===void 0&&l.step===void 0?{...l,...c.min===void 0?{}:{min:c.min},...c.max===void 0?{}:{max:c.max},...c.step===void 0?{}:{step:c.step}}:l,w=(l,c)=>c&&l.type===c.type&&l.format===void 0&&l.unit===void 0?{...p(l,c),...c.format?{format:c.format}:{},...c.unit?{unit:c.unit}:{}}:p(l,c),f=(l,c,O)=>{if(l===le||fn.has(l)||u.has(l)||a.has(l))return;let y=i[l]?w(i[l],O):void 0;a.set(l,y?{field:y,optional:!y.required,required:!!y.required}:c())};for(let l of s)if("create"in l){let c=r.kinds[l.create];for(let[O,y]of Object.entries(l.set??{})){let j=A(y),v=c?.fields[O];if(j&&v){let b=!!v.required&&v.default===void 0;f(j,()=>({field:v,optional:!b,required:b}),v)}}l.as&&u.set(l.as,l.create)}else if("connect"in l||"sever"in l){let c=t.get("connect"in l?l.connect:l.sever);for(let[O,y]of[["from",l.from],["to",l.to]]){let j=A(y);if(!j)continue;let v=O==="to"?c?.to??"*":c?.from??"*";v!=="*"&&!m.has(j)&&m.set(j,v),f(j,()=>({ref:v,required:!0}))}}else if("set"in l){let c=A(l.target??"$subject"),O=c==="subject"?d[0]:u.get(c??"")??m.get(c??"")?.[0];c&&c!=="subject"&&!u.has(c)&&f(c,()=>({ref:"*",required:!0}));for(let[y,j]of Object.entries(l.set)){let v=A(j);if(!v)continue;let b=O?r.kinds[O]?.fields[y]:void 0;f(v,()=>b?{field:b,optional:!o,required:o}:{any:!0,required:!1},b)}}else if("remove"in l){let c=A(l.remove);c&&f(c,()=>({ref:"*",required:!0}))}for(let[l,c]of Object.entries(i))a.has(l)||a.set(l,{field:c,optional:!c.required,required:!!c.required});return a}function ft(n,s={}){let r=un(n);if(!r.document||de(r.findings))return{ok:!1,findings:r.findings};let t=r.document,a=[...r.findings];s.previous&&a.push(...yn(t,s.previous));let d=zn(t,a);return de(d.findings)?{ok:!1,findings:d.findings}:Te(d,s)}function ie(n,s){return n.map(r=>{let t=!r.format&&r.expr?.t==="ident"?s?.[r.expr.name]?.format:void 0;return t==="money"||t==="percent"?{...r,format:t}:r})}function zn(n,s){let r=He(n),t={};for(let[i,o]of Object.entries(n.kinds)){let p=Me(o),w=o.label??(p?`{${p}}`:void 0),f=ee(o),l=f?We(n,i,[...f]):[];t[i]={...w?{label:ie(Y(w),o.fields)}:{},...o.describe?{describe:ie(Y(o.describe),o.fields)}:{},...f?{computed:[...f]}:{},...l.length>0?{durations:l}:{}}}let a={};for(let[i,o]of Object.entries(n.acts??{})){let p=Ye(o,n),w=gn(o,p,n,r),f=o.destructive??p.some(g=>"remove"in g||"sever"in g||"replace"in g),l=[...new Set(p.flatMap(g=>"create"in g?[g.create]:[]))],c=[...new Set(p.flatMap(g=>"connect"in g?[g.connect]:[]))],O=[...new Set(p.flatMap(g=>"sever"in g?[g.sever]:"replace"in g?g.replace:[]))],y=[...new Set(p.flatMap(g=>"set"in g&&!("create"in g)&&A(g.target??"$subject")==="subject"?Object.keys(g.set):[]))],j=new Map;for(let g of p){if(!("connect"in g)&&!("sever"in g))continue;let x=r.get("connect"in g?g.connect:g.sever);for(let[F,te]of[["from",g.from],["to",g.to]]){let I=A(te),Z=F==="to"?x?.to:x?.from;I&&I!=="subject"&&Z&&Z!=="*"&&j.set(I,[...new Set([...j.get(I)??[],...Z])])}}let v={};for(let g of p){if(!("set"in g)||"create"in g)continue;let x=A(g.target??"$subject");for(let F of x&&x!=="subject"&&j.get(x)||[])v[F]=[...new Set([...v[F]??[],...Object.keys(g.set)])]}let b={};for(let g of p)if(!(!("set"in g)||"create"in g||A(g.target??"$subject")!=="subject"))for(let[x,F]of Object.entries(g.set??{}))typeof F=="string"&&A(F)===void 0||typeof F=="number"||typeof F=="boolean"?b[x]=typeof F=="string"&&F.startsWith("$$")?F.slice(1):F:delete b[x];let W=l.length===0&&p.every(g=>!("set"in g)||!g.set||Object.values(g.set).every(x=>!(x&&typeof x=="object"&&!Array.isArray(x)&&"expr"in x))),P=new Map;for(let g of p)if(!(!("set"in g)||!g.set))for(let x of Object.values(g.set))x&&typeof x=="object"&&!Array.isArray(x)&&"expr"in x&&P.set(x.expr,H(x.expr));a[i]={title:o.title??i.replace(/-/g," "),effects:p,args:[...w],...o.allowedWhen?{guard:H(o.allowedWhen)}:{},...o.refusal?{refusal:ie(Y(o.refusal),n.kinds[[o.on??[]].flat()[0]??""]?.fields)}:{},exprs:[...P],destructive:f,idempotent:W,creates:l,connects:c,severs:O,writes:y,writesOther:v,sets:b}}let d={};for(let[i,o]of Object.entries(n.rules??{}))d[i]={title:o.title??i.replace(/-/g," "),require:H(o.require),...o.when?{when:H(o.when)}:{},...o.says?{says:ie(Y(o.says),n.kinds[o.over]?.fields)}:{}};let u=De(n,s),m=Ge(n),h=Ce(n);return{format:Ke,document:n,findings:s,kinds:t,...n.computed?{facts:[...ee(n)??[]]}:{},edges:[...r].map(([i,{from:o,to:p,cardinality:w}])=>[i,{from:o,to:p,cardinality:w}]),acts:a,rules:d,brand:u,...Object.keys(m).length>0?{viewSpecs:m}:{},...h?{home:h}:{}}}function ut(n,s,r){let t=/^defineNode\("([^"]+)"\)/.exec(s)?.[1],a=t?r.kinds[t]:void 0;if(!t||!a)return n;let d=Object.keys(a.fields).filter(u=>u!=="label").slice(0,3);return{...n,path:`kinds.${t}.glance`,fix:`Say which: "glance": [${d.map(u=>`"${u}"`).join(", ")}] on kinds.${t} \u2014 the facts a person compares one by, at a glance.`}}function yn(n,s){let r=[],t=new Set(Object.values(s.kinds).flatMap(a=>Object.keys(a.edges??{})));for(let[a,d]of Object.entries(n.kinds)){let u=d.renamedFrom;u&&!s.kinds[u]&&r.push(z("renamed-from-nothing",`kinds.${a}.renamedFrom`,`${a} says it was ${u}, and the previous version has no kind called ${u}`,"name the kind it was, or drop renamedFrom"));let m=s.kinds[u??a];for(let[h,i]of Object.entries(d.fields)){let o=i.renamedFrom;o&&!m?.fields[o]&&r.push(z("renamed-from-nothing",`kinds.${a}.fields.${h}.renamedFrom`,`${h} says it was ${o}, and the previous ${u??a} has no field called ${o}`,"name the field it was, or drop renamedFrom"))}for(let[h,i]of Object.entries(d.edges??{})){let o=i.renamedFrom;o&&!t.has(o)&&r.push(z("renamed-from-nothing",`kinds.${a}.edges.${h}.renamedFrom`,`${h} says it was ${o}, and the previous version has no relation called ${o}`,"name the relation it was, or drop renamedFrom"))}}return r}export{un as a,pt as b,Ye as c,ft as d,ut as e};
@@ -1 +0,0 @@
1
- import{a as L}from"./chunk.UHX4WTM7.js";import{a as ae,b as ie,c as de,d as se,e as M,f as V,g as le}from"./chunk.IKX4VDTW.js";import{a as ue}from"./chunk.RNEJYIQ7.js";import{c as G,e as oe}from"./chunk.TBQOSI4J.js";import{a as j,b as Q,c as ee,d as ne,f as E,m as re,n as b,o as te,p as B}from"./chunk.KWQ7QOHD.js";import{b as v,d as ye,e as fe,g as pe,h as me,i as ce}from"./chunk.H7KCWCB4.js";import{C as x,Ca as J,Cb as Y,Db as q,Eb as C,I as W,R as H,U as P,_ as K,ca as X,ja as F,la as Z,qa as T,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 Ye(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 qe(e,n){for(let o of Ee(n)){let r=O(e[o]).find(t=>T(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(()=>G(e.expr))}:"neutral"}var ve=4;function xe(e){let n=typeof e.list=="string"?R(()=>G(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 f=R(()=>G(r));a=f?{t:"call",fn:"sort",args:[n,f,{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,M):void 0,i=e.group,s=typeof i=="string"?i:i&&typeof i=="object"&&typeof i.by=="string"?i.by:void 0,y=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(y).filter(f=>typeof f[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>ve)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(()=>G(p)):null,i=Be(a.tone),s=typeof a.label=="string"?a.label:void 0,y=p=>Object.hasOwn(a,p),f=typeof a.currency=="string"&&/^[A-Z]{3}$/.test(a.currency)?a.currency:void 0,u=y("list")?"list":y("headline")?"headline":typeof a.figure=="string"?"number":Pe.find(y);if(!u)return[];let m=r[u]=(r[u]??0)+1,c=a.key,S=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}:{},...f?{currency:f}:{},...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}:{},...f?{currency:f}:{},...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,`${S}.`),direction:a.direction==="row"?"row":"column"};case"when":return{t:u,when:l(a.when),show:he(a.show,n+1,`${S}.`)};default:return{t:u}}})(),key:S}]})}var Pe=["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:E(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 k(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?ye(l.value,{markdown:!0}):o&&e.length===1?(t=!0,l.value):fe(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?C(l.value,i):b(l.value,d.format,n.today,d.formatArgs,n.money,B(n.schema)))}).join(""),...r?{problem:r}:{},...t?{markdown:t}:{}}}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 Ce(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 Me(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 v(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 v(o.definition,e,n);let l=typeof n=="number"?Oe(o,e):void 0;if(l)return C(n,l);if(typeof n=="number")return P(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 Ve(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):P(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 Le(e,n,o){switch(e.t){case"title":{let r=k(e.parts,n);return h({t:"title",text:r.text},r.problem)}case"text":{let r=k(e.parts,n,!0),t=be(e.tone,n);return h({t:"text",text:r.text,...t?{tone:t}:{},...r.markdown?{markdown:r.markdown}:{}},r.problem)}case"badge":{let r=k(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 f=J(Object.hasOwn(n.node,e.field)?n.node[e.field]:void 0,t);return{t:"field",field:e.field,label:r,text:f.length>0?"linked record":g,...f.length>0?{linked:{relation:t,refs:f}}:{}}}let a=n.kinds.get(n.node.kind)?.computed?.has(e.field),d,l;if(a){let f=w({t:"ident",name:e.field,at:0},n);f.ok?d=f.value!==null&&typeof f.value=="object"?b(f.value,void 0,n.today,[],n.money,B(n.schema)):f.value:l=f.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"?Ce(d):ce(Ae(n,e.field),d),s=R(()=>Me(e.field,d,n,e.as,e.currency))??g,y=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}:{},...y?{app:y}:{}},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=>T(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?k(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=k(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:Ve(r.value,e.as,e.currency,n.today,n.money),a=e.label?k(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 Ie(e,n)}}function Se(e,n){let o=e.findIndex(r=>r.t==="headline");return e.map((r,t)=>({...Le(r,n,t===o),key:r.key}))}var _e=new Set(["every","some","sum","min","max","sort"]);function wn(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,y)=>{y===1&&_e.has(i.fn)||t(s)});return;default:return}},a=i=>{for(let s of i??[])t(s.expr)},d=(i,s)=>{i.forEach((y,f)=>{let u=s[f];if(u)switch(y.t){case"field":case"image":o.add(y.field);return;case"title":case"text":case"badge":case"headline":a(y.parts);return;case"number":t(y.value),a(y.label);return;case"progress":t(y.value),t(y.max);return;case"group":u.t==="group"&&d(y.blocks,u.blocks);return;case"when":u.t==="when"&&u.shown&&d(y.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 Ie(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=De(a,e.choiceOrder,n.schema));let d=a.length,l=a.slice(0,e.limit??M),i=l.slice(0,V),s=l.slice(V),y=(e.limit===void 0?d:l.length)-i.length,f=c=>e.group&&n.schema&&c.length>0?$e(c,e.group,n.schema,n.graph):void 0,u=f(i),m=s.length>0?f(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:y,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 De(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 $e(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 Ue(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(f=>D(f,n.by)===i);if(s.length===0)continue;let y=o.tryDefinition(s[0].kind);d.push({value:i,heading:n.headings[i]??K(v(y,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 Ue(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=B(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 S=d.get(c.id)??{node:c,members:[]};S.members.push(u),d.set(c.id,S)}}let y=[...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 f=s&&s!=="*"?Z(r.tryDefinition(s),s):void 0;return l.length>0&&y.push({value:null,...f?{heading:`No ${f}`}:{},members:l}),y}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 Ge=new WeakMap;function $(e){let n=Ge.get(e);return n||Ge.set(e,n=ue(e)),n}function We(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:X(e.tryDefinition(s.kind),s)}}return i};for(let[i,s]of t.get(o?o.kind:ee)?.computed??[])try{let y=[],f=E(s,{graph:n,subject:o,kinds:t,...r.today?{today:r.today}:{},...r.budget?{budget:r.budget}:{},...r.linked?{linked:r.linked}:{},onUnread:u=>y.push(u)});y.length>0&&(f===null||f instanceof j&&f.nodes.length===0)?d[i]=Q(y[0]):a[i]=l(f)}catch(y){if(!(y instanceof ne))throw y;d[i]=y.sentence}return{values:a,refused:d}}function On(e,n,o){let{values:r}=We(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 He=500,Ke=2e4,Te=new WeakMap;function Xe(e,n){let o=Te.get(e);o||Te.set(e,o=new Map);let r=o.get(n);return r||o.set(n,r=je(e,n)),r}function Bn(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:y}=r;return{node:a,graph:t.graph,schema:d,kinds:$(d),fields:a?Xe(d,a.kind):{},definition:l||void 0,today:r.today??t.today?.()??W(s?.timeZone),money:s,heading:r.heading??(i?2:3),firstHeading:y,budget:r.budget??(i?Ke:He),...i?{}:{glance:!0}}}export{ge as a,Ye as b,Ee as c,qe as d,he as e,Se as f,wn as g,ke as h,We as i,On as j,Bn as k};
@@ -1,2 +0,0 @@
1
- import{a as Se}from"./chunk.VC3BX2ZF.js";import{e as ke,f as $e,i as ve,j as J,k as xe}from"./chunk.OYHQSXNC.js";import{f as he}from"./chunk.TBQOSI4J.js";import{d as Z,e as be}from"./chunk.DX357TZ3.js";import{b as ye,e as we}from"./chunk.H7KCWCB4.js";import{Ab as ie,C as X,I as ne,Ic as pe,Nb as q,Ob as ae,Yc as me,ba as V,ca as K,ea as oe,fa as Y,ga as se,gc as le,gd as fe,ic as ce,ja as _,kc as de,la as re,od as ge,pc as L,qc as ue}from"./chunk.AS4CQBOQ.js";function Ie(n,r,t){let o=n.tryDefinition(r)?.fields.shape,e=X(o?.[t]),l=!1,i=!1;for(;e&&(e.type==="optional"||e.type==="default"||e.type==="nullable"||e.type==="prefault");)(e.type==="optional"||e.type==="nullable")&&(l=!0),(e.type==="default"||e.type==="prefault")&&(i=!0),e=X(e.innerType);if(e?.type!=="enum")return;let h=(e.entries?Object.values(e.entries):e.values??[]).filter(m=>typeof m=="string");return h.length>0?{values:h,empty:l&&!i}:void 0}function W(n,r,t){let o=Ie(n,r,t);if(!o)return[];let e=n.tryDefinition(r),l=o.values.map(i=>({value:i,label:ye(e,t,i)}));return o.empty&&l.push({value:null,label:`No ${_(e,t).toLowerCase()}`}),l}function z(n,r,t){let o=n[r];return typeof o=="string"&&t.some(e=>e.value===o)?o:null}function Q(n,r,t,o,e=W(n.schema,t.kind,o)){return De(n,r,t,o,e).flatMap(l=>l.move?[l.move]:[])}function De(n,r,t,o,e=W(n.schema,t.kind,o)){let l=Ce(n.schema,n.allMutations(),t.kind,o,e),i=z(t,o,e),h=re(n.schema.tryDefinition(t.kind),t.kind),m=[];for(let{value:S,label:A,by:O,acts:B}of l){if(S===i)continue;let D,G,F;for(let a of B){let f=O==="step"?{[a.subject.arg]:t.id}:{[a.subject.arg]:t.id,[o]:S},w={name:a.name,args:f};if(!a.input.safeParse(f).success){F??=`${a.title??a.name} asks for more than the ${h} itself.`;continue}let b=n.permits(w,r);if(!b.ok){G??=b.refusal?.message??`You may not ${a.title??a.name}.`;continue}try{ie(n.graph,a,f)}catch(c){G??=c instanceof Error?c.message:String(c);continue}D={to:S,call:w,title:a.title??a.name};break}m.push(D?{to:S,label:A,move:D}:{to:S,label:A,why:G??F??`Nothing in this app moves a ${h} to ${A}.`})}return m}function Ce(n,r,t,o,e=W(n,t,o)){let l=Re(n,r,t,o),i=Pe(n,r,t,o);return e.flatMap(h=>{if(h.value===null)return[];let m=l.filter(S=>S.sets?.[o]===h.value);return[{value:h.value,label:h.label,by:m.length>0?"step":i.length>0?"value":"none",acts:m.length>0?m:i}]})}function Re(n,r,t,o){return r.filter(e=>e.subject!==void 0&&e.derived===void 0&&typeof e.sets?.[o]=="string"&&q(n,e).includes(t))}function Pe(n,r,t,o){let e=n.tryDefinition(t);return e?r.filter(l=>{if(!l.subject||!q(n,l).includes(t)||!ae(l,e).includes(o))return!1;let i=l.input.shape;return i!==void 0&&o in i}).sort((l,i)=>+(l.derived!==void 0)-+(i.derived!==void 0)):[]}var ee=(n,r)=>r&&n[r]!==void 0?String(n[r]):"";function Ge(n,r,t){let o=a=>n.tryDefinition(a)?r.nodesOfKind(a).filter(f=>V(n.tryDefinition(a),f)):[],e=o(t.rows),l=o(t.columns),i=new Set(e.map(a=>a.id)),h=new Set(l.map(a=>a.id)),m=r.allEdges(),S=[],A=t.link;if(typeof A=="string"){let a=c=>n.tryDefinition(c)?.edges?.[A]?.to,f=(a(t.columns)??[]).some(c=>c===t.rows||c==="*"),w=(a(t.rows)??[]).some(c=>c===t.columns||c==="*"),b=f||!w;for(let c of m){if(c.kind!==A)continue;let P=b?c.to:c.from,s=b?c.from:c.to;i.has(P)&&h.has(s)&&S.push({rowId:P,columnId:s,via:[]})}}else{let a=new Map(A.path.map(w=>[w,new Map]));for(let w of m){let b=a.get(w.kind);if(!b)continue;let c=b.get(w.from);c?c.push(w.to):b.set(w.from,[w.to]);let P=b.get(w.to);P?P.push(w.from):b.set(w.to,[w.from])}let f=new Set;for(let w of l){let b=[{id:w.id,via:[]}];for(let c of A.path){let P=[],s=new Set;for(let k of b)for(let R of a.get(c).get(k.id)??[])s.has(`${k.id}|${R}`)||(s.add(`${k.id}|${R}`),P.push({id:R,via:[...k.via,k.id]}));b=P}for(let c of b){let P=`${c.id}|${w.id}`;!i.has(c.id)||f.has(P)||(f.add(P),S.push({rowId:c.id,columnId:w.id,via:c.via.slice(1)}))}}}let O=t.groupOrder??[],B=a=>O.indexOf(a)===-1?O.length:O.indexOf(a),D=(a,f)=>f==="label"?K(n.tryDefinition(a.kind),a):a[f],G=L(e,t.sort,D).map(a=>{let f=a;return{node:a,label:K(n.tryDefinition(a.kind),a),group:ee(f,t.rowGroup),ref:ee(f,t.rowRef)}}).sort((a,f)=>B(a.group)-B(f.group)||(t.sort!==void 0?0:a.ref<f.ref?-1:a.ref>f.ref?1:0)),F=L(l,t.columnSort,D).map(a=>({node:a,label:K(n.tryDefinition(a.kind),a),group:ee(a,t.columnGroup)})).sort((a,f)=>a.group<f.group?-1:a.group>f.group?1:t.columnSort!==void 0?0:a.node.id<f.node.id?-1:a.node.id>f.node.id?1:0);return{rows:G,columns:F,cells:S}}function Ae(n,r,t){let{rows:o,columns:e,cells:l}=Ge(n,r,t),i=(s,k)=>Y(n,s,k),h=s=>Y(n,s,1).replace(/^1 /,""),m=s=>({id:s.id,kind:s.kind,title:K(n.tryDefinition(s.kind),s),parts:[]}),S=s=>{let k=r.getNode(s);if(!k)return null;let R=n.tryDefinition(k.kind),j=K(R,k),H=Z(k,R,{limit:3,said:[j],glance:!0}).map(N=>N.alone.startsWith(N.label)?`${N.label.toLowerCase()}${N.alone.slice(N.label.length)}`:N.alone);return[j,...H].join(", ")},A=typeof t.link=="string"?[]:t.link.path.slice(0,-1).flatMap((s,k,R)=>{let j=pe(n,t.columns,R.slice(0,k+1));return j.ok?[...j.reached]:[]}),O=ue(n,t,{rows:o.length,columns:e.length,cells:l.length});if(O)return[{t:"text",text:`${i(t.rows,o.length)} against ${i(t.columns,e.length)}.`},{t:"text",text:O}];let B=[{t:"text",text:`${i(t.rows,o.length)} against ${i(t.columns,e.length)}${A.length>0?`, through ${[...new Set(A)].map(s=>i(s,2).replace(/^2 /,"")).join(" and ")}`:""}${e.length>0?`: ${e.map(s=>s.label).join(", ")}`:""}.`}],D=new Map(e.map(s=>[s.node.id,s.label])),G=new Map(e.map((s,k)=>[s.node.id,k])),F=new Map,a=new Map;for(let s of l){let k=F.get(s.rowId);k?k.push(s):F.set(s.rowId,[s]);let R=a.get(s.columnId);R?R.add(s.rowId):a.set(s.columnId,new Set([s.rowId]))}for(let s of o){let R=[...F.get(s.node.id)??[]].sort((j,H)=>G.get(j.columnId)-G.get(H.columnId)).map(j=>{let H=j.via.map(S).filter(N=>N!==null);return`${D.get(j.columnId)}${H.length>0?` (${H.join("; ")})`:""}`});B.push({t:"field",label:s.label,text:R.length>0?R.join(", "):"none"})}B.push({t:"list",as:"name",columns:1,groups:e.map(s=>{let k=a.get(s.node.id)??new Set,R=o.filter(j=>k.has(j.node.id)).map(j=>m(j.node));return{heading:`${s.label} (${R.length})`,items:R}})});let f=new Set(l.map(s=>s.rowId)),w=new Set(l.map(s=>s.columnId)),b=o.filter(s=>!f.has(s.node.id)),c=e.filter(s=>!w.has(s.node.id)),P=t.rows===t.columns;return b.length>0&&B.push({t:"text",text:`${P?`${b.length} with none across`:`${i(t.rows,b.length)} with no ${h(t.columns)}`}: ${b.map(s=>s.label).join(", ")}.`}),c.length>0&&B.push({t:"text",text:`${P?`${c.length} with none down`:`${i(t.columns,c.length)} on no ${h(t.rows)}`}: ${c.map(s=>s.label).join(", ")}.`}),B}function te(n,r,t,o={}){let{app:e,blocks:l=t?e?.viewSpecs?.[t.kind]?.[o.slot??"page"]:e?.home}=o;if(!l?.length)return[];let i=o.firstHeading??(t||o.blocks?void 0:1),h=xe(n,r,t,{...o,money:o.money??e?.brand,firstHeading:i});return t&&!h.node?[]:$e(typeof l[0]?.t=="string"?l:ke(l),h)}function Me(n,r){let t=n.viewSpecs??{};return r.filter(o=>o.cardinality==="one"&&o.replaces==="page"&&(t[o.attach]?.page?.length??0)>0).map(o=>{let e=E(n.schema,o.attach,1);return{at:`views.${o.attach}.page`,says:`The view "${o.name}" replaces ${Fe(e)}'s page, so its page slot is never drawn: leave out replaces to draw the slot under the view, or draw what the slot says in the view.`}})}var Fe=n=>`${/^[aeiou]/i.test(n)?"an":"a"} ${n}`,Ne=240,je=10,Ke=1160,He=40,Te=640,Ve=3,We=n=>Math.max(1,Math.floor((Math.min(n,Ke)-He+je)/(Ne+je)));function Ee(n,r,t,o){let{app:e}=o,l=o.width??1440,i=o.today??n.today()??ne(e.brand?.timeZone),h=n.seenBy(r),m=h.schema,S=h.graph,A=Se(e),O=typeof t=="string"?t.trim():t.slug,B=typeof t=="string"?A.find(d=>d.slug===O||d.title===O||d.address===O):A.find(d=>d.slug===t.slug&&d.kind===t.kind)??t,D=!B&&typeof t=="string"?S.getNode(O):void 0;if(!B&&!D)return{ok:!1,error:`"${O}" is not a place this app has, nor a record this seat can see.`,places:A.map(d=>d.slug)};let G=[],F=e.viewSpecs??{},a=We(l),f=(d,y)=>te(h,null,d,{app:e,today:i,...y}),w=(d,y,v)=>{let p=m.tryDefinition(d.kind),x=K(p,d);if(y==="name")return{id:d.id,kind:d.kind,title:x,parts:[]};if(F[d.kind]?.[y]){let M=f(d,{slot:y}),[I,...g]=M,C=I?.t==="title";return{id:d.id,kind:d.kind,title:C?I.text:x,parts:b(C?g:M,v,`views.${d.kind}.${y}`,` (${d.id})`,C?1:0)}}if(y==="row")return{id:d.id,kind:d.kind,title:x,parts:[]};let u=p?.computed?J(m,S,d):d,T=Z(u,p,{limit:3,said:[x],glance:!0,locale:e.brand?.locale,timeZone:e.brand?.timeZone});return{id:d.id,kind:d.kind,title:x,parts:T.map(M=>({t:"text",text:M.alone}))}};function b(d,y,v,p="",x=0){let $=[];return d.forEach((u,T)=>{let M=`${v}.${T+x}`;switch("problem"in u&&u.problem&&G.push({at:`${M}${p}`,says:u.problem}),u.t){case"title":$.push({t:"heading",level:3,text:u.text});return;case"text":$.push({t:"text",text:u.markdown?we(u.text):u.text,...u.tone?{tone:u.tone}:{}});return;case"badge":$.push({t:"badge",text:u.text});return;case"field":case"image":$.push({t:"field",label:u.label,text:u.text});return;case"progress":$.push({t:"progress",label:u.label,text:u.text});return;case"group":$.push(...b(u.blocks,y,`${M}.group`,p));return;case"when":$.push(...b(u.blocks,y,`${M}.show`,p));return;case"divider":case"figure":return;case"headline":$.push({t:"heading",level:u.level,text:u.text});return;case"number":$.push({t:"figure",text:u.text,...u.label?{label:u.label}:{}});return;case"list":{if(u.failed){$.push({t:"text",text:"\u2014"});return}if(u.members.length===0){u.empty&&$.push({t:"list",as:u.as,columns:1,groups:[],empty:u.empty});return}let I=y+1,g=I>Ve?"name":u.as,C=(u.groups??[{value:null,members:u.members}]).map(U=>({..."heading"in U&&U.heading?{heading:U.heading}:{},items:U.members.map(Be=>w(Be,g,I))}));$.push({t:"list",as:g,columns:g==="card"?a:1,groups:C,...u.more>0?{more:u.more}:{}});return}}}),$}let c=[],P,s,k;if(D){s="record";let d=m.tryDefinition(D.kind),y=K(d,D);k={slug:D.id,title:y,kind:D.kind,address:me(m,D.kind,D.id)};let v=F[D.kind]?.page,p=o.views?.find(x=>x.attach===D.kind&&x.cardinality==="one");if(p&&c.push({t:"view",name:p.name,...p.title?{title:p.title}:{},...p.replaces==="page"?{replaces:!0}:{},...p.parts?{parts:p.parts}:{}}),p?.replaces==="page")s=`view:${p.name}`,G.push(...Me(e,[p]));else{v&&c.push(...b(f(D,{slot:"page"}),1,`views.${D.kind}.page`));let x=d?.computed?J(m,S,D):D;for(let $ of be(d,Z(x,d,{said:[y],locale:e.brand?.locale,timeZone:e.brand?.timeZone}))){$.title&&c.push({t:"heading",level:2,text:$.title});for(let u of $.fields)c.push({t:"field",label:u.label,text:u.value,...u.long?{long:!0}:{},...u.markdown?{markdown:!0}:{}})}}}else{let d=B;k={slug:d.slug,title:d.title,kind:d.kind,address:d.address};let y=d.lens?fe(e).drawn.find(v=>v.as===d.slug&&(d.kind===null||v.kinds.includes(d.kind))):void 0;if(d.kind===null){let v=e.brand,p=v?.name??e.name,x=de(v)?.light,$=x&&ce(x)?x:void 0;if(P={name:p,...v?.subtitle?{subtitle:v.subtitle}:{},...$?{logo:{alt:v?.logoAlt??p,...le($)?{drawn:"inline SVG"}:{drawn:"image",src:$}}}:{}},e.home)s="blocks",c=b(f(null,{}),0,"views.home");else{s="derived";let u=n.kindsKeptFrom(r),T=new Set([...e.pages?.hide??[],...u,...n.modules.disabledKinds]),M=ge(m.kinds,e.pages?.order).filter(I=>!T.has(I));c.push({t:"heading",level:1,text:e.name??"Home"});for(let I of M){let g=S.nodesOfKind(I).filter(C=>V(m.tryDefinition(I),C)).length;g>0&&c.push({t:"text",text:`${g} ${E(m,I,g)}`})}}}else if(y?.lens==="blocks")s="lens:blocks",c=b(f(null,{blocks:y.options.blocks??[]}),0,`lenses.${y.index}.options.blocks`);else if(y?.lens==="columns"){s="lens:columns";let v=y.options.bindings??{};for(let p of Object.keys(v)){let x=v[p]?.column;if(!x)continue;let $=W(m,p,x),u=L(S.nodesOfKind(p).filter(g=>V(m.tryDefinition(p),g)),y.options.sort,(g,C)=>C==="label"?K(m.tryDefinition(g.kind),g):g[C]);Object.keys(v).length>1&&c.push({t:"heading",level:2,text:E(m,p,2).replace(/^./,g=>g.toUpperCase())}),c.push({t:"text",text:`${u.length} ${E(m,p,u.length)} in columns by ${_(m.tryDefinition(p),x).toLowerCase()}.`});let T=$.map(g=>({column:g,items:u.filter(C=>z(C,x,$)===g.value).map(C=>w(C,"card",1))})).filter(({column:g,items:C})=>g.value!==null||C.length>0).map(({column:g,items:C})=>({heading:`${g.label} (${C.length})`,items:C}));c.push({t:"list",as:"card",columns:1,groups:T});let M=new Map;for(let g of u)for(let C of Q(n,r,g,x,$))M.set(C.to,(M.get(C.to)??new Set).add(`"${C.title}"`));let I=$.filter(g=>g.value!==null&&M.has(g.value)).map(g=>`to ${g.label} by ${[...M.get(g.value)].join(" or ")}`);c.push({t:"text",text:I.length>0?`Moves: ${I.join("; ")}.`:"Moves: none for this seat."})}}else if(y?.lens==="coverage")s="lens:coverage",c=Ae(m,S,y.options);else if(y){s=`lens:${y.lens}`;let v=y.kinds.flatMap(p=>S.nodesOfKind(p).filter(x=>V(m.tryDefinition(p),x)));c.push({t:"text",text:`A ${y.lens} of ${v.length} ${y.kinds.map(p=>E(m,p,v.length)).join(" and ")}.`}),c.push({t:"list",as:"name",columns:1,groups:[{items:v.map(p=>w(p,"name",1))}]})}else{s="derived";let v=S.nodesOfKind(d.kind).filter(p=>V(m.tryDefinition(d.kind),p));c.push({t:"heading",level:1,text:d.title}),v.length===0?c.push({t:"list",as:"row",columns:1,groups:[],empty:`No ${E(m,d.kind,0)} yet.`}):c.push({t:"list",as:"row",columns:1,groups:[{items:v.map(p=>w(p,"row",1))}]})}}let R=r.kind==="system"?"the system":(r.roles??[]).length>0?(r.roles??[]).join(", "):r.kind,j=l<Te?"phone":"wide",H=k.kind===null?Le(m,S):[],N={...P?{masthead:P}:{},...H.length>0?{facts:H}:{},place:k,seat:R,width:l,variant:j,drawnBy:s,parts:c,problems:G};return{ok:!0,description:{...N,text:Oe(N)}}}function Le(n,r){let t=ve(n,r,null),o=e=>Array.isArray(e)?e.map(o).join(", "):e===null?"nothing":typeof e=="boolean"?e?"yes":"no":typeof e=="object"?e.label:String(e);return[...he(n)].map(([e,l])=>{let i=l.label??oe(e);return Object.hasOwn(t.values,e)?{name:e,label:i,value:o(t.values[e])}:{name:e,label:i,refused:t.refused[e]??"it could not be worked out"}})}function E(n,r,t){let o=n.tryDefinition(r);if(t===1)return o?.noun??r;let e=se(n,r);return e.charAt(0).toLowerCase()+e.slice(1)}function Oe(n){let r=[`${n.place.title} (${n.place.address}) \u2014 as ${n.seat}, ${n.width} wide (${n.variant}).`],t=n.masthead;t&&r.push(`Masthead: ${t.logo?`the logo ("${t.logo.alt}", ${t.logo.drawn==="image"?t.logo.src:"inline SVG"}), `:""}${t.name}${t.subtitle?` \u2014 ${t.subtitle}`:""}`);let o=(e,l)=>{for(let i of e)switch(i.t){case"heading":r.push(`${l}${"#".repeat(i.level)} ${i.text}`);break;case"text":r.push(`${l}${i.text}`);break;case"badge":r.push(`${l}[${i.text}]`);break;case"field":case"progress":r.push(`${l}${i.label}: ${i.text}`);break;case"figure":r.push(`${l}${i.text}${i.label?` \u2014 ${i.label}`:""}`);break;case"list":if(i.groups.length===0){i.empty&&r.push(`${l}(${i.empty})`);break}for(let h of i.groups){h.heading&&r.push(`${l}${h.heading}:`);for(let m of h.items)r.push(`${l}${h.heading?" ":""}- ${m.title}`),o(m.parts,`${l}${h.heading?" ":" "}`)}i.as==="card"&&i.columns>1&&r.push(`${l}(cards, ${i.columns} across)`),i.more&&r.push(`${l}and ${i.more} more`);break;case"view":r.push(`${l}[the view "${i.title??i.name}"${i.replaces?", in place of the page":""}]`),i.parts&&o(i.parts,`${l} `);break}};if(o(n.parts,""),n.facts){r.push("Facts of the whole graph (what fact('<name>') reads):");for(let e of n.facts)r.push(`- ${e.label} (${e.name}): ${e.value??`not worked out \u2014 ${e.refused}`}`)}if(n.problems.length>0){r.push("Problems:");for(let e of n.problems)r.push(`- ${e.at}: ${e.says}`)}return r.join(`
2
- `)}export{W as a,z as b,Q as c,De as d,Ce as e,Re as f,Pe as g,te as h,Me as i,Ee as j,Oe as k};