graview 0.1.30 → 0.1.33

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 (174) hide show
  1. package/dist/preview/chunk.26LLZN3C.js +1 -0
  2. package/dist/preview/chunk.2NIOHEMX.js +1 -0
  3. package/dist/preview/chunk.2WPZXIRP.js +2 -0
  4. package/dist/preview/{chunk.XRJBLH4N.js → chunk.3AGY4QVS.js} +1 -1
  5. package/dist/preview/chunk.3HXN4BOY.js +1 -0
  6. package/dist/preview/{chunk.2CIBWZJG.js → chunk.3K6YSVHC.js} +1 -1
  7. package/dist/preview/chunk.3NDH3EDN.js +47 -0
  8. package/dist/preview/{chunk.FWCOJDOD.js → chunk.3TVXGJTU.js} +1 -1
  9. package/dist/preview/{chunk.NDADLJE6.js → chunk.3TY5NFLY.js} +1 -1
  10. package/dist/preview/{chunk.UWGWXFWZ.js → chunk.47STJVRV.js} +1 -1
  11. package/dist/preview/{chunk.X37L5TN5.js → chunk.4HNG4UXT.js} +1 -1
  12. package/dist/preview/{chunk.34ZMMURV.js → chunk.4HRAQNJO.js} +6 -6
  13. package/dist/preview/{chunk.QTMWHE5O.js → chunk.4HZ7QTXZ.js} +1 -1
  14. package/dist/preview/{chunk.3JGGBLRB.js → chunk.4MERAWS2.js} +1 -1
  15. package/dist/preview/chunk.52W7WYME.js +1 -0
  16. package/dist/preview/chunk.5A4AOFOA.js +1 -0
  17. package/dist/preview/chunk.5H4VXLZF.js +88 -0
  18. package/dist/preview/{chunk.XS7YFNDU.js → chunk.5T5XGILP.js} +1 -1
  19. package/dist/preview/chunk.5UL7YDUD.js +1 -0
  20. package/dist/preview/chunk.63GXY2ME.js +1 -0
  21. package/dist/preview/chunk.67TPUXAY.js +1 -0
  22. package/dist/preview/chunk.6QWV5MVH.js +25 -0
  23. package/dist/preview/{chunk.PAVR5TK5.js → chunk.6UGEYZAC.js} +1 -1
  24. package/dist/preview/chunk.6YCBYL2Y.js +2 -0
  25. package/dist/preview/{chunk.ZYKAS4BT.js → chunk.7GKUVQVF.js} +1 -1
  26. package/dist/preview/{chunk.T3VPD7JQ.js → chunk.7T7NZZTC.js} +1 -1
  27. package/dist/preview/chunk.AKFKM4SW.js +3 -0
  28. package/dist/preview/chunk.AOSMJKLH.js +1 -0
  29. package/dist/preview/{chunk.DT7LHWU2.js → chunk.AR3DCDHU.js} +1 -1
  30. package/dist/preview/{chunk.D3IECJ2S.js → chunk.ASCLIM2P.js} +1 -1
  31. package/dist/preview/chunk.B2GLDIAS.js +1 -0
  32. package/dist/preview/chunk.BHXGM3PV.js +1 -0
  33. package/dist/preview/chunk.BNV77BQZ.js +4 -0
  34. package/dist/preview/chunk.BQ3JHEHV.js +1 -0
  35. package/dist/preview/chunk.CAVBSL27.js +1 -0
  36. package/dist/preview/{chunk.YLQB3KBA.js → chunk.CDP2XL66.js} +1 -1
  37. package/dist/preview/chunk.CIPS2OGR.js +1 -0
  38. package/dist/preview/chunk.CN3UEF5N.js +90 -0
  39. package/dist/preview/{chunk.6XMEU2Q2.js → chunk.COQKECUH.js} +1 -1
  40. package/dist/preview/{chunk.QTA4ROAK.js → chunk.CWHRDBOF.js} +1 -1
  41. package/dist/preview/chunk.CX3KL2C5.js +1 -0
  42. package/dist/preview/{chunk.AK3IHFCF.js → chunk.D75KC3LL.js} +1 -1
  43. package/dist/preview/chunk.DAZ2VSRD.js +1 -0
  44. package/dist/preview/{chunk.3ADPAGPY.js → chunk.DYSPCGXX.js} +1 -1
  45. package/dist/preview/chunk.E2YEOMPH.js +1 -0
  46. package/dist/preview/chunk.EBGAYL32.js +1 -0
  47. package/dist/preview/chunk.EF3XNU4O.js +1 -0
  48. package/dist/preview/chunk.EJPI3ST6.js +1 -0
  49. package/dist/preview/chunk.EKPRNDUV.js +1 -0
  50. package/dist/preview/chunk.ERIT3R6N.js +1 -0
  51. package/dist/preview/chunk.EYTBDMTW.js +1 -0
  52. package/dist/preview/{chunk.HHPGWJDO.js → chunk.FWTIUYXH.js} +1 -1
  53. package/dist/preview/{chunk.6T2Q6NLO.js → chunk.G5NZVPJU.js} +1 -1
  54. package/dist/preview/chunk.GBRRGTIH.js +1 -0
  55. package/dist/preview/{chunk.VG56IUIQ.js → chunk.GO4XBWJO.js} +1 -1
  56. package/dist/preview/chunk.GV2CQVKV.js +1 -0
  57. package/dist/preview/chunk.GYICGZMG.js +3 -0
  58. package/dist/preview/chunk.H7BST3XO.js +1 -0
  59. package/dist/preview/chunk.H7EPE74C.js +1 -0
  60. package/dist/preview/{chunk.26CZTUY4.js → chunk.HAIG6NVX.js} +1 -1
  61. package/dist/preview/{chunk.V7BDAGDE.js → chunk.HLTRQU4Y.js} +1 -1
  62. package/dist/preview/{chunk.VS7K3SCD.js → chunk.I6FPNX43.js} +1 -1
  63. package/dist/preview/chunk.IDVAR5HM.js +1 -0
  64. package/dist/preview/{chunk.3URFMWXZ.js → chunk.IWQCOGHW.js} +2 -2
  65. package/dist/preview/chunk.J25KOSNW.js +1 -0
  66. package/dist/preview/chunk.JDUJDAGA.js +1 -0
  67. package/dist/preview/chunk.JOOQUWLT.js +341 -0
  68. package/dist/preview/{chunk.4SJUTBDV.js → chunk.JQU5GEU3.js} +1 -1
  69. package/dist/preview/chunk.K5ME5GCG.js +1 -0
  70. package/dist/preview/chunk.KSES5U5B.js +1 -0
  71. package/dist/preview/chunk.KSXB4LDF.js +1 -0
  72. package/dist/preview/chunk.LR3VDXPI.js +1 -0
  73. package/dist/preview/{chunk.WYTIOLPP.js → chunk.LXBOVRFI.js} +1 -1
  74. package/dist/preview/{chunk.42YX6NOY.js → chunk.MAF7C3VM.js} +1 -1
  75. package/dist/preview/chunk.MNP4JI33.js +5 -0
  76. package/dist/preview/{chunk.O2LK2AO7.js → chunk.MWGGV7DE.js} +1 -1
  77. package/dist/preview/chunk.N6OX4NEQ.js +1 -0
  78. package/dist/preview/chunk.NRAYZY3X.js +1 -0
  79. package/dist/preview/chunk.NTF7FVB2.js +1 -0
  80. package/dist/preview/{chunk.DZRTOURR.js → chunk.OC6IWRQ3.js} +1 -1
  81. package/dist/preview/chunk.OJGHDWI6.js +1 -0
  82. package/dist/preview/chunk.OKRNJXTV.js +1 -0
  83. package/dist/preview/chunk.PBSMLINK.js +1 -0
  84. package/dist/preview/chunk.PHKSMUIA.js +1 -0
  85. package/dist/preview/{chunk.JN7DIFR3.js → chunk.PIP6Z563.js} +1 -1
  86. package/dist/preview/chunk.QVVJRSRM.js +1 -0
  87. package/dist/preview/{chunk.L6OMEYL6.js → chunk.QYZNAUIR.js} +1 -1
  88. package/dist/preview/chunk.R6K6GF5R.js +1 -0
  89. package/dist/preview/{chunk.JTNWD2CN.js → chunk.RCKTBOY2.js} +1 -1
  90. package/dist/preview/{chunk.QNGWEV47.js → chunk.RIJUCHP4.js} +1 -1
  91. package/dist/preview/chunk.SHTJZ6UX.js +1 -0
  92. package/dist/preview/{chunk.PKK6FRZR.js → chunk.SYAEBGDC.js} +1 -1
  93. package/dist/preview/chunk.T5VG5A6V.js +1 -0
  94. package/dist/preview/{chunk.ERXSYPYL.js → chunk.TAQ764IQ.js} +1 -1
  95. package/dist/preview/{chunk.RIEHYQLK.js → chunk.TMVCTBAD.js} +50 -24
  96. package/dist/preview/{chunk.HHI65WFZ.js → chunk.UATVTXZY.js} +1 -1
  97. package/dist/preview/{chunk.XSTXV6FP.js → chunk.UBFNZMUX.js} +2 -2
  98. package/dist/preview/{chunk.WAFDCOOG.js → chunk.UGFJKSHU.js} +1 -1
  99. package/dist/preview/chunk.UHUGOTUU.js +19 -0
  100. package/dist/preview/chunk.ULRW47RP.js +1 -0
  101. package/dist/preview/chunk.UNL2HIF2.js +1 -0
  102. package/dist/preview/chunk.UVR2Z5ZC.js +1 -0
  103. package/dist/preview/chunk.UZGRRDHD.js +1 -0
  104. package/dist/preview/{chunk.BPWNWE7N.js → chunk.VG3O4LWB.js} +1 -1
  105. package/dist/preview/chunk.WAZ7OGBD.js +1 -0
  106. package/dist/preview/{chunk.3JNMSOFG.js → chunk.XANVHJQ4.js} +1 -1
  107. package/dist/preview/chunk.XBJYQNVE.js +1 -0
  108. package/dist/preview/chunk.XKABS745.js +1 -0
  109. package/dist/preview/chunk.XMC7YDWT.js +1 -0
  110. package/dist/preview/chunk.XNJEFUF7.js +3 -0
  111. package/dist/preview/chunk.Y2SFUALD.js +117 -0
  112. package/dist/preview/chunk.Y6ZNFQK3.js +6 -0
  113. package/dist/preview/{chunk.J2ITFGN3.js → chunk.YIR7PPF3.js} +1 -1
  114. package/dist/preview/index.html +51 -0
  115. package/dist/preview/page.js +6 -6
  116. package/package.json +6 -6
  117. package/dist/preview/chunk.2EXGG6BB.js +0 -1
  118. package/dist/preview/chunk.2NBYNZRD.js +0 -1
  119. package/dist/preview/chunk.2XAONC66.js +0 -1
  120. package/dist/preview/chunk.3R4W2P5X.js +0 -1
  121. package/dist/preview/chunk.3SKKIHU3.js +0 -4
  122. package/dist/preview/chunk.3VL5WECB.js +0 -1
  123. package/dist/preview/chunk.4ALKPNXM.js +0 -1
  124. package/dist/preview/chunk.4HP7UWA2.js +0 -1
  125. package/dist/preview/chunk.5U5J3ISK.js +0 -1
  126. package/dist/preview/chunk.6V2RG5JG.js +0 -5
  127. package/dist/preview/chunk.7BWT5L2L.js +0 -1
  128. package/dist/preview/chunk.C5CYZNSJ.js +0 -1
  129. package/dist/preview/chunk.CM6LOIQE.js +0 -88
  130. package/dist/preview/chunk.FDELO7NY.js +0 -116
  131. package/dist/preview/chunk.FGVKJWNS.js +0 -6
  132. package/dist/preview/chunk.GFF2FB2J.js +0 -25
  133. package/dist/preview/chunk.GLBHQFJ2.js +0 -1
  134. package/dist/preview/chunk.HSCTWAUV.js +0 -1
  135. package/dist/preview/chunk.INZUEWC5.js +0 -1
  136. package/dist/preview/chunk.JH6MU6TX.js +0 -2
  137. package/dist/preview/chunk.JISMMIMX.js +0 -1
  138. package/dist/preview/chunk.JPHNKWTY.js +0 -1
  139. package/dist/preview/chunk.K75FUIZI.js +0 -1
  140. package/dist/preview/chunk.K776HO42.js +0 -2
  141. package/dist/preview/chunk.KN3ULTGF.js +0 -1
  142. package/dist/preview/chunk.KOB6N3SL.js +0 -1
  143. package/dist/preview/chunk.KQT7WAQE.js +0 -1
  144. package/dist/preview/chunk.L4DECHXR.js +0 -327
  145. package/dist/preview/chunk.LQ7V6KEE.js +0 -1
  146. package/dist/preview/chunk.MD74YVRN.js +0 -3
  147. package/dist/preview/chunk.MGNP4LAM.js +0 -1
  148. package/dist/preview/chunk.NCTOBUCT.js +0 -1
  149. package/dist/preview/chunk.NO52VON3.js +0 -1
  150. package/dist/preview/chunk.OAF7TUMI.js +0 -1
  151. package/dist/preview/chunk.OQ4KFN6W.js +0 -1
  152. package/dist/preview/chunk.OQDETV4X.js +0 -1
  153. package/dist/preview/chunk.OXQMNIRO.js +0 -1
  154. package/dist/preview/chunk.OZNW5W4Z.js +0 -1
  155. package/dist/preview/chunk.QIAKO27D.js +0 -1
  156. package/dist/preview/chunk.R26DREVU.js +0 -1
  157. package/dist/preview/chunk.RI3PYG5T.js +0 -19
  158. package/dist/preview/chunk.RRVIXV7W.js +0 -1
  159. package/dist/preview/chunk.RYT5U3QM.js +0 -1
  160. package/dist/preview/chunk.SE5SKFQH.js +0 -1
  161. package/dist/preview/chunk.SOBC3CTN.js +0 -47
  162. package/dist/preview/chunk.SOD3PBJM.js +0 -1
  163. package/dist/preview/chunk.UDSEJKCY.js +0 -1
  164. package/dist/preview/chunk.UZWWDAGM.js +0 -14
  165. package/dist/preview/chunk.V5ZYUVMH.js +0 -1
  166. package/dist/preview/chunk.VOAZBHCG.js +0 -1
  167. package/dist/preview/chunk.VSZQXB4Q.js +0 -3
  168. package/dist/preview/chunk.W3S6UXNA.js +0 -1
  169. package/dist/preview/chunk.Y4UXEL6Y.js +0 -1
  170. package/dist/preview/chunk.YJUB4OD7.js +0 -1
  171. package/dist/preview/chunk.YNQDVGZM.js +0 -1
  172. package/dist/preview/chunk.YV2LJFGS.js +0 -1
  173. package/dist/preview/chunk.Z2YUYZT4.js +0 -1
  174. /package/dist/preview/{chunk.EYZ7MHBZ.js → chunk.GZHZLJBF.js} +0 -0
@@ -0,0 +1,3 @@
1
+ var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as Ee}from"./chunk.XANVHJQ4.js";import{a as Ne}from"./chunk.OKRNJXTV.js";import{a as je}from"./chunk.5UL7YDUD.js";import{a as X}from"./chunk.TI4OSTQV.js";import{a as Z}from"./chunk.PBSMLINK.js";import{e as pe}from"./chunk.JOOQUWLT.js";import{F as Ze,I as ve,O as Ie,Q as Re,Y as Me}from"./chunk.6QWV5MVH.js";import{$ as G,Bb as Pe,X as Y,Z as L,ca as Ce,ea as fe,ec as Te,fb as Oe,wb as $e,zb as V}from"./chunk.MNP4JI33.js";import{b as ce}from"./chunk.AJZBJBMO.js";var en=n=>/^(?:aggregate|kind):([^,]+)$/.exec(n)?.[1];function De(n,e){let t=n.about??[];if(n.field!==void 0&&n.on!==void 0&&e(n.on))return{on:"field",id:n.on,field:n.field};let i=t.filter(e);if(i.length>1)return{on:"selection",ids:i};if(n.on!==void 0&&e(n.on))return{on:"record",id:n.on};if(i.length===1)return{on:"record",id:i[0]};let r=[n.on,...t].map(o=>o===void 0?void 0:en(o)).find(o=>o!==void 0);return n.place!==void 0?{on:"lens",place:n.place,...r?{kind:r}:{}}:r!==void 0?{on:"list",kind:r}:{on:"place",place:"home"}}var me=n=>n.on==="record"||n.on==="field"?[n.id]:n.on==="selection"?n.ids:n.on==="act"&&n.id!==void 0?[n.id]:[],ee=(n,e)=>n.tryDefinition(e)?.fields?.shape??{},B=(n,e)=>n.tryDefinition(e)?.edges??{},ne=(n,e)=>new Set(n.tryDefinition(e)?.display?.hide??[]),E=(n,e)=>Y(n.tryDefinition(e.kind),e),ue=(n,e,t)=>Ce(n.tryDefinition(e),t)||L(t),ye=n=>typeof n=="boolean"?n?"yes":"no":String(n);function ke(n,e){let t=n.kindsKeptFrom(e);return new Set(n.schema.kinds.filter(i=>!t.has(i)))}function ge(n,e,t,i){if(!n.permits(e,t).ok)return!1;if(!i)return!0;try{return n.previewAll([e],{author:t}).ops.length>0}catch{return!1}}function te(n,e,t){let i=n,{principal:r}=t,o=t.each??8,u=X(i)?.store??i,d=u.seenBy(r),l=u.schema,m=ke(u,r),c=a=>{let g=d.graph.getNode(a);return g&&m.has(g.kind)?g:void 0},f=u.allMutations(),y=new Map(f.map(a=>[a.name,a])),b=[],x=new Set,k=a=>{x.has(a.id)||(x.add(a.id),b.push(a))},s=a=>a.slice(0,o),S=me(e).filter(a=>c(a)!==void 0);if(me(e).length>0&&S.length===0)return{target:e,candidates:[]};let h=S.length===1?c(S[0]):void 0,p=h?.kind??(e.on==="list"?e.kind:e.on==="lens"?e.kind??t.places?.find(a=>a.as===e.place)?.kind:void 0)??(e.on==="selection"?c(S[0])?.kind:void 0);if(p!==void 0&&!m.has(p))return{target:e,candidates:[]};let M=(a,g)=>`act:${a}${Object.keys(g).length>0?`:${Object.values(g).map(O=>String(O)).join(",")}`:""}`,P=(a,g,O,T,C)=>{a.destructive||Object.values(g).some(N=>typeof N=="string"&&u.graph.has(N)&&c(N)===void 0)||ge(u,{name:a.name,args:{...g}},r,T.length===0)&&k({type:"act",id:M(a.name,g),label:O,description:C??a.description??O,mutation:a.name,args:g,asks:T})};if(e.on!=="place"||t.acts)if(t.acts)for(let a of t.acts){let g=y.get(a.mutation);!g||a.destructive||e.on==="act"&&a.mutation!==e.act||P(g,a.args,a.label,(a.open??[]).filter(O=>!O.optional).map(O=>O.name),a.why)}else{let a=h?[h]:[];for(let g of f){if(e.on==="act"&&g.name!==e.act)continue;let O=g.input.shape??{},T=C=>Object.entries(O).filter(([N,w])=>N!==C&&w.safeParse?.(void 0).success===!1).map(([N])=>N);if(g.subject)for(let C of a)V(l,g).includes(C.kind)&&P(g,{[g.subject.arg]:C.id},`${g.title??L(g.name)}: ${E(l,C)}`,T(g.subject.arg));else p!==void 0&&(g.creates??[]).includes(p)&&P(g,{},g.title??L(g.name),T(void 0))}}let Ye=b.filter(a=>a.type==="act");b.splice(0,b.length,...s(Ye));let we=(a,g)=>{let O=Pe(l,f).get(a.kind),T=ee(l,a.kind),C=ne(l,a.kind),N=[];for(let[w,j]of Object.entries(T)){if(g!==void 0?w!==g:C.has(w)||a[w]!==void 0)continue;let H=Z(j),J=H?.type==="enum"?H.options??[]:H?.type==="boolean"?[!0,!1]:[];if(J.length===0)continue;let D=(O?.get(w)??[]).map(v=>y.get(v)).find(v=>v?.subject!==void 0&&ge(u,{name:v.name,args:{[v.subject.arg]:a.id,[w]:J.find(le=>le!==a[w])??J[0]}},r,!0));if(D?.subject)for(let v of J)a[w]!==v&&N.push({type:"fill",id:`fill:${a.id}:${w}:${ye(v)}`,label:`${ue(l,a.kind,w)}: ${ye(v)}`,description:`Set ${ue(l,a.kind,w).toLowerCase()} of ${E(l,a)} to ${ye(v)}`,record:a.id,field:w,value:v,call:{name:D.name,args:{[D.subject.arg]:a.id,[w]:v}}})}for(let[w,j]of Object.entries(B(l,a.kind))){if(g!==void 0&&w!==g)continue;let H=j.to==="*"?[...m]:j.to.filter($=>m.has($)),J=new Set(d.graph.out(a.id,w).map($=>$.id)),D=f.find($=>($.connects??[]).includes(w)&&$.subject!==void 0&&V(l,$).includes(a.kind));if(!D?.subject)continue;let v=$e(D.input).find($=>$.name!==D.subject.arg);if(!v)continue;let le=H.flatMap($=>v.kinds.length===0||v.kinds.includes($)?d.graph.nodesOfKind($):[]).filter($=>$.id!==a.id&&!J.has($.id)&&c($.id)!==void 0);for(let $ of s(le)){let xe={name:D.name,args:{[D.subject.arg]:a.id,[v.name]:$.id}};ge(u,xe,r,!0)&&N.push({type:"fill",id:`fill:${a.id}:${w}:${$.id}`,label:`${L(w)}: ${E(l,$)}`,description:`Link ${E(l,a)} to ${E(l,$)}${j.description?` as ${j.description}`:""}`,record:a.id,field:w,value:$.id,call:xe})}}return N};if(e.on==="field"&&h)for(let a of we(h,e.field))k(a);else if(h&&e.on==="record")for(let a of s(we(h)))k(a);let Ve=a=>{let g=G(l,a).toLowerCase(),O=[{type:"panel",id:`panel:${a}:list`,label:`A list of ${g}`,description:`Every ${fe(l.tryDefinition(a),a).toLowerCase()} this viewer may see, as a list`,panel:{lens:"blocks",kind:a}}],T=ne(l,a);for(let[C,N]of Object.entries(ee(l,a))){if(T.has(C))continue;let w=Z(N),j=ue(l,a,C).toLowerCase();if(w?.type==="enum")O.push({type:"panel",id:`panel:${a}:group:${C}`,label:`${U(g)} by ${j}`,description:`A list of ${g} grouped by ${j}`,panel:{lens:"blocks",kind:a,group:C}}),O.push({type:"panel",id:`panel:${a}:columns:${C}`,label:`Columns of ${g} by ${j}`,description:`${U(g)} in a column for each ${j}`,panel:{lens:"columns",kind:a,column:C}});else if(w?.type==="number"||w?.type==="integer"||w?.type==="date"||w?.type==="datetime"){let H=w.type==="date"||w.type==="datetime";O.push({type:"panel",id:`panel:${a}:sort:${C}`,label:`${U(g)} by ${j}`,description:`A list of ${g}, the ${H?"latest":"highest"} ${j} first`,panel:{lens:"blocks",kind:a,sort:{by:C,direction:"desc"}}}),H&&O.push({type:"panel",id:`panel:${a}:calendar:${C}`,label:`A calendar of ${g}`,description:`${U(g)} on a calendar by ${j}`,panel:{lens:"calendar",kind:a,start:C}})}}return O},Xe=e.on==="place"?[...m]:p!==void 0?[p]:[];for(let a of Xe)for(let g of s(Ve(a)))k(g);for(let a of s((t.places??[]).filter(g=>g.kind===void 0?e.on==="place":m.has(g.kind)&&(e.on==="place"||g.kind===p))))e.on==="lens"&&a.as===e.place||k({type:"place",id:`place:${a.as}`,label:a.title,description:`Go to ${a.title}`,place:a.as});if(h){let a=[];for(let[g,O]of Object.entries(B(l,h.kind)))for(let T of d.graph.out(h.id,g))c(T.id)&&a.push({type:"record",id:`record:${T.id}`,label:E(l,T),description:`${U(O.description??L(g))}: ${E(l,T)}`,record:T.id,relation:g});for(let g of l.kinds)for(let[O,T]of Object.entries(B(l,g)))if(!(T.to!=="*"&&!T.to.includes(h.kind)))for(let C of d.graph.in(h.id,O))C.kind===g&&c(C.id)&&a.push({type:"record",id:`record:${C.id}`,label:E(l,C),description:`${U(T.inverse??L(O))}: ${E(l,C)}`,record:C.id,relation:O});for(let g of s(a))k(g)}else if(e.on==="list"||e.on==="lens")for(let a of s(p!==void 0?d.graph.nodesOfKind(p):[]))c(a.id)&&k({type:"record",id:`record:${a.id}`,label:E(l,a),description:`Open ${E(l,a)}`,record:a.id});else if(e.on==="selection")for(let a of S){let g=c(a);k({type:"record",id:`record:${a}`,label:E(l,g),description:`Open ${E(l,g)}`,record:a})}return{target:e,candidates:b}}var U=n=>n&&`${n[0].toUpperCase()}${n.slice(1)}`,he=new WeakMap;function nn(n){let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619)>>>0;return e.toString(36)}function tn(n,e){let t=n,i=X(t)?.store??t,r=i.schema,o=ke(i,e),d=i.allMutations().filter(k=>!k.destructive&&i.permits({name:k.name,args:{}},e).ok!==!1),l=`${[...o].join(",")}|${d.map(k=>k.name).join(",")}`,m=he.get(r)?.get(l);if(m)return m;let c=[...o].map(k=>{let s=ne(r,k),S={};for(let[p,M]of Object.entries(ee(r,k))){if(s.has(p))continue;let P=Z(M);P&&(S[p]=P.type==="enum"?`enum:${(P.options??[]).join("|")}`:P.type)}let h={};for(let[p,M]of Object.entries(B(r,k)))h[p]=M.to==="*"?[...o]:M.to.filter(P=>o.has(P));return{kind:k,noun:fe(r.tryDefinition(k),k),plural:G(r,k),fields:S,relations:h}}),f=d.map(k=>({name:k.name,title:k.title??L(k.name),...k.subject?{on:V(r,k).filter(s=>o.has(s))}:{}})),y={kinds:c,acts:f},b={version:nn(JSON.stringify(y)),...y},x=he.get(r)??new Map;return x.set(l,b),he.set(r,x),b}var on=n=>n.name??n.id??n.kind;function He(n,e,t){let i=n,{principal:r}=t,o=X(i)?.store??i,u=o.seenBy(r),d=o.schema,l=ke(o,r),m=h=>{let p=u.graph.getNode(h);return p&&l.has(p.kind)?p:void 0},c=h=>({id:h.id,kind:h.kind,label:E(d,h)}),f=me(e),y=f.length===1?m(f[0]):void 0,b=y?Object.fromEntries(Object.keys(ee(d,y.kind)).filter(h=>!ne(d,y.kind).has(h)&&y[h]!==void 0&&h!=="label").map(h=>[h,y[h]])):{},x={on:e.on,...y?{record:{...c(y),fields:b}}:{},...e.on==="field"&&y?{field:e.field}:{},...e.on==="list"&&l.has(e.kind)?{kind:e.kind}:{},...e.on==="lens"?{place:e.place,...e.kind&&l.has(e.kind)?{kind:e.kind}:{}}:{},...e.on==="place"?{place:e.place}:{},...e.on==="act"?{act:e.act}:{}},k=[...new Set([...e.on==="selection"?e.ids:[],...t.selection??[]])].flatMap(h=>{let p=m(h);return p?[c(p)]:[]}),s=[];if(y){for(let h of Object.keys(B(d,y.kind)))for(let p of u.graph.out(y.id,h))m(p.id)&&s.push({...c(p),relation:h,direction:"out"});for(let h of d.kinds)for(let p of Object.keys(B(d,h)))for(let M of u.graph.in(y.id,p))M.kind===h&&m(M.id)&&s.push({...c(M),relation:p,direction:"in"})}let S=u.batches().filter(h=>!h.ops.every(Oe)).slice(-(t.recent??6)).reverse().map(h=>({intent:h.intent,at:h.at,by:on(h.author)}));return{...t.place!==void 0?{place:t.place}:{},target:x,selection:k,neighbors:s.slice(0,24),recent:S,schema:tn(o,r)}}function oe(n){if(!n.off)return n.fast??(n.decide?{model:n.name??"decide",decide:n.decide}:void 0)}function F(n){if(n.off)return;if(n.thinking)return n.thinking;let e=n.name??"model";if(n.complete){let t=n.complete;return{model:e,think:async({system:i,prompt:r})=>({text:await t(`${i}
2
+
3
+ ${r}`)})}}if(n.turn){let t=n.turn;return{model:e,think:async({system:i,prompt:r})=>({text:await t({system:i,messages:[{role:"user",content:r}],tools:[],call:async()=>({error:"No tools here."})})})}}}var be=(n,e,t)=>n?e/1e6*(n.inputPerMillion??0)+t/1e6*(n.outputPerMillion??0):void 0,Ae=()=>`ai-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;function rn(n,e,t=[]){let i=r=>{let o=n.graph.getNode(r);return o?Y(n.schema.tryDefinition(o.kind),o):"a record"};switch(e.on){case"record":return i(e.id);case"field":return`${i(e.id)} \xB7 ${e.field}`;case"selection":return`${e.ids.length} records`;case"list":return n.schema.tryDefinition(e.kind)?G(n.schema,e.kind):e.kind;case"lens":case"place":return t.find(r=>r.as===e.place)?.title??(e.place==="home"?"Home":e.place);case"act":return e.act}}var Le=n=>n.type!=="act"||n.asks.length===0,Se=(n,e)=>({id:n.id,type:n.type,label:n.label,...e!==void 0?{confidence:e}:{}});function W(n,e){let t=e.interaction??Ae(),i=te(e.store,e.target,{principal:e.principal,...e.acts?{acts:e.acts}:{},...e.places?{places:e.places}:{}}),r=He(e.store,e.target,{principal:e.principal,...e.place?{place:e.place}:{},...e.selection?{selection:e.selection}:{}}),o=[];return{id:t,catalog:i,state:r,entry:{id:t,at:new Date().toISOString(),by:e.by??e.principal,target:e.target,targetLabel:rn(e.store,e.target,e.places)},usage:o,meter:u=>{o.push(u),n.meter?.({...u,interaction:t})}}}async function re(n,e,t,i){let r=await n.decide(e,t),{inputTokens:o,outputTokens:u}=r.usage,d=be(n.price,o,u);return i({tier:"fast",model:n.model,inputTokens:o,outputTokens:u,...d!==void 0?{costUsd:d}:{}}),r.answers}async function q(n,e,t,i,r){let o=await n.think({system:e,prompt:t,state:i.state,catalog:i.catalog}),u=o.usage?.inputTokens,d=o.usage?.outputTokens,l=o.usage?.costUsd??(u!==void 0?be(n.price,u,d??0):void 0);return r({tier:"thinking",model:n.model,...u!==void 0?{inputTokens:u}:{},...d!==void 0?{outputTokens:d}:{},...l!==void 0?{costUsd:l}:{}}),Ne(o.text)}function ae(n,e){let t=new Map(n.map((i,r)=>[`c${r+1}`,i]));return{question:{type:"choice",instructions:e,criteria:Object.fromEntries([...t].map(([i,r])=>[i,`${r.label} \u2014 ${r.description}`]))},of:i=>t.get(i)}}function se(n,e,t){if(n?.type!=="choice")return[];let i=n,r=Object.entries(i.probabilities).sort((o,u)=>u[1]-o[1]);return r.some(([o])=>o===i.choice)||r.unshift([i.choice,i.confidence]),r.flatMap(([o,u])=>{let d=e(o);return d?[{candidate:d,confidence:u}]:[]}).slice(0,t)}var I=(n,e,t,i)=>({interaction:{...n.entry,ask:{kind:t,said:e??""},offered:[],outcome:"failed",failed:i,usage:[...n.usage]},offers:[]}),z="AI isn't on here.";async function Fe(n,e,t=3){let i=W(n,e),r=e.said??"Suggest",o=i.catalog.candidates.filter(Le).slice(0,24);if(o.length===0)return{interaction:{...i.entry,ask:{kind:"suggest",said:r},offered:[],outcome:"offered",usage:[]},offers:[]};let u=oe(n),d=F(n),l=[];try{if(u){let{question:m,of:c}=ae(o,"Which of these would the person most likely want to do next, here?"),f=await re(u,{...i.state,candidates:o.map(y=>({id:y.id,type:y.type,says:y.description}))},{next:m},i.meter);l=se(f.next,c,t)}else if(d){let m=await q(d,'You suggest what a person most likely wants to do next in an app. Answer only JSON: {"pick": [candidate ids, best first]}. Pick only ids from the candidates.',JSON.stringify({state:i.state,candidates:o.map(f=>({id:f.id,says:f.description}))}),i,i.meter);l=(Array.isArray(m?.pick)?m.pick.filter(f=>typeof f=="string"):[]).flatMap(f=>o.filter(y=>y.id===f)).slice(0,t).map(f=>({candidate:f}))}else return I(i,r,"suggest",z)}catch(m){return I(i,r,"suggest",m instanceof Error?m.message:String(m))}return{interaction:{...i.entry,ask:{kind:"suggest",said:r},offered:l.map(({candidate:m,confidence:c})=>Se(m,c)),outcome:"offered",usage:[...i.usage]},offers:l.map(({candidate:m})=>m)}}async function Je(n,e){let t=W(n,e),i=e.said??"Fill in",r=t.catalog.candidates.filter(f=>f.type==="fill"),o=new Map;for(let f of r)o.set(f.field,[...o.get(f.field)??[],f]);if(o.size===0)return{interaction:{...t.entry,ask:{kind:"fill",said:i},offered:[],outcome:"offered",usage:[]},offers:[]};let u=oe(n),d=F(n),l=[];try{if(u){let f=[...o].map(([b,x],k)=>({key:`f${k+1}`,field:b,...ae(x,`Which value fits "${b}" best for this record?`)})),y=await re(u,t.state,Object.fromEntries(f.map(b=>[b.key,b.question])),t.meter);for(let b of f){let x=!an(e.store,e.target,b.field)&&sn(e.store,e.target,b.field)!=="one";l.push(...se(y[b.key],b.of,x?3:1).filter((k,s)=>s===0||k.confidence>=.4))}}else if(d){let f=await q(d,`You fill in a record's fields in an app. Answer only JSON: {"fills": [candidate ids]}, at most one per field, only ids from the candidates.`,JSON.stringify({state:t.state,candidates:r.map(x=>({id:x.id,says:x.description}))}),t,t.meter),y=Array.isArray(f?.fills)?f.fills.filter(x=>typeof x=="string"):[],b=new Set;for(let x of y){let k=r.find(s=>s.id===x);k?.type==="fill"&&!b.has(k.field)&&(b.add(k.field),l.push({candidate:k}))}}else return I(t,i,"fill",z)}catch(f){return I(t,i,"fill",f instanceof Error?f.message:String(f))}let m=t.usage.at(-1)?.model,c=_(e.store,{interaction:t.id,target:e.target,basis:i,...m?{model:m}:{},proposals:l.flatMap(({candidate:f,confidence:y})=>f.type==="fill"?[{id:f.id,label:f.label,said:f.description,call:f.call,record:f.record,field:f.field,...y!==void 0?{confidence:y}:{}}]:[])},e.principal);return{interaction:{...t.entry,ask:{kind:"fill",said:i},offered:c.proposals.map(f=>({id:f.id,type:"fill",label:f.label,...f.confidence!==void 0?{confidence:f.confidence}:{}})),outcome:"offered",usage:[...t.usage]},offers:[],...c.proposals.length>0?{ghost:c}:{}}}function an(n,e,t){let i=e.on==="record"||e.on==="field"?e.id:void 0,r=i?n.graph.getNode(i)?.kind:void 0,o=(r?n.schema.tryDefinition(r)?.fields?.shape:void 0)??{};return t in o}function sn(n,e,t){let i=e.on==="record"||e.on==="field"?e.id:void 0,r=i?n.graph.getNode(i)?.kind:void 0;return r?n.schema.tryDefinition(r)?.edges?.[t]?.cardinality:void 0}async function Ue(n,e){let t=W(n,e),i=e.said??"Add one",r=new Set(e.store.allMutations().filter(c=>(c.creates??[]).length>0).map(c=>c.name)),o=t.catalog.candidates.filter(c=>c.type==="act"&&c.asks.length>0&&r.has(c.mutation));if(o.length===0)return I(t,i,"record","Nothing here makes a record.");let u=F(n);if(!u)return I(t,i,"record",z);let d;try{let c=await q(u,'You propose one new record for an app by filling in an act. Answer only JSON: {"act": a candidate id, "args": {argument: value}}. Use only the candidates, and fill every argument the act asks for with a value that fits the state.',JSON.stringify({ask:i,state:t.state,candidates:o.map(b=>({id:b.id,says:b.description,asks:b.asks}))}),t,t.meter),f=o.find(b=>b.id===c?.act),y=typeof c?.args=="object"&&c.args!==null?c.args:{};f&&(d={act:f,args:Object.fromEntries(Object.entries(y).filter(([b])=>f.asks.includes(b)))})}catch(c){return I(t,i,"record",c instanceof Error?c.message:String(c))}if(!d)return I(t,i,"record","The model named no act this app has here.");let l=t.usage.at(-1)?.model,m=_(e.store,{interaction:t.id,target:e.target,basis:i,...l?{model:l}:{},proposals:[{id:d.act.id,label:d.act.label,said:d.act.description,call:{name:d.act.mutation,args:{...d.act.args,...d.args}}}]},e.principal);return m.proposals.length===0?I(t,i,"record","What the model proposed could not be made here."):{interaction:{...t.entry,ask:{kind:"record",said:i},offered:m.proposals.map(c=>({id:c.id,type:"act",label:c.said})),outcome:"offered",usage:[...t.usage]},offers:[d.act],ghost:m}}async function Be(n,e){let t=W(n,e),i=e.said??"Make a panel",r=t.catalog.candidates.filter(c=>c.type==="panel");if(r.length===0)return I(t,i,"panel","Nothing here can be drawn as a panel.");let o=oe(n),u=F(n),d;try{if(u){let c=await q(u,'You choose a panel to draw in an app. Answer only JSON: {"panel": a candidate id, "title": a short title}. Choose only among the candidates.',JSON.stringify({ask:i,state:t.state,candidates:r.map(y=>({id:y.id,says:y.description}))}),t,t.meter),f=r.find(y=>y.id===c?.panel);f&&(d={panel:f,...typeof c?.title=="string"&&c.title.trim()?{title:c.title.trim().slice(0,60)}:{}})}else if(o){let{question:c,of:f}=ae(r,`Which panel answers this best: ${i}`),y=se((await re(o,t.state,{panel:c},t.meter)).panel,f,1)[0];y?.candidate.type==="panel"&&(d={panel:y.candidate,confidence:y.confidence})}else return I(t,i,"panel",z)}catch(c){return I(t,i,"panel",c instanceof Error?c.message:String(c))}if(!d)return I(t,i,"panel","The model named no panel this app can draw.");let l=d.title??d.panel.label,m={title:l,recipe:{...d.panel.panel,title:l}};return{interaction:{...t.entry,ask:{kind:"panel",said:i},offered:[Se(d.panel,d.confidence)],outcome:"drawn",panel:m,usage:[...t.usage]},offers:[d.panel],panel:m}}function dn(n){return n.off?void 0:n.answer}var ln=`You answer a person's question about what they are looking at in an app, from the state given and nothing else. Answer only JSON: {"answer": one to three short sentences, "pick": [candidate ids that act on the answer, best first, at most three]}. Pick only ids from the candidates, and none when nothing fits. Never say an id to the person.`;async function wn(n,e){let t=W(n,e),i=e.said.trim(),r=t.catalog.candidates.filter(s=>Le(s)||s.type==="panel"||s.type==="place"||s.type==="record").slice(0,32),o=dn(n),u=F(n),d=oe(n),l="",m=[],c=s=>s.flatMap(S=>r.filter(h=>h.id===S)).slice(0,3).map(S=>({candidate:S}));try{if(o){let s=await o.answer({said:i,target:e.target,targetLabel:t.entry.targetLabel,state:t.state,catalog:{target:t.catalog.target,candidates:r},...e.follows?{follows:e.follows}:{}}),S=s.usage?.inputTokens,h=s.usage?.outputTokens,p=s.usage?.costUsd??(S!==void 0?be(o.price,S,h??0):void 0);t.meter({tier:"thinking",model:o.model,...S!==void 0?{inputTokens:S}:{},...h!==void 0?{outputTokens:h}:{},...p!==void 0?{costUsd:p}:{}}),l=typeof s.text=="string"?s.text.trim():"",m=c(s.pick??[])}else if(u){let s=await q(u,ln,JSON.stringify({ask:i,about:t.entry.targetLabel,...e.follows?{follows:e.follows}:{},state:t.state,candidates:r.map(S=>({id:S.id,says:S.description}))}),t,t.meter);l=typeof s?.answer=="string"?s.answer.trim():"",m=c(Array.isArray(s?.pick)?s.pick:[])}else if(d&&r.length>0){let{question:s,of:S}=ae(r,`Which of these best answers, or acts on: ${i}`),h=await re(d,{...t.state,asked:i,candidates:r.map(p=>({id:p.id,type:p.type,says:p.description}))},{answer:s},t.meter);m=se(h.answer,S,3),l=m.length>0?`These fit \u201C${i}\u201D.`:""}else return I(t,i,"ask",z)}catch(s){return I(t,i,"ask",s instanceof Error?s.message:String(s))}if(!l&&m.length===0)return I(t,i,"ask","The AI had no answer to that here.");let f=t.usage.at(-1)?.model,y=m.flatMap(({candidate:s,confidence:S})=>{let h=ie(s);return h?[{...h,...S!==void 0?{confidence:S}:{}}]:[]}),b=y.length>0?_(e.store,{interaction:t.id,target:e.target,basis:i,...f?{model:f}:{},proposals:y},e.principal):void 0,x=m.map(({candidate:s})=>s).filter(s=>ie(s)===void 0),k=[...x.map(s=>Se(s,m.find(S=>S.candidate===s)?.confidence)),...(b?.proposals??[]).map(s=>({id:s.id,type:s.field!==void 0?"fill":"act",label:s.label,...s.confidence!==void 0?{confidence:s.confidence}:{}}))];return{interaction:{...t.entry,ask:{kind:"ask",said:i},offered:k,outcome:"offered",...l?{answer:l}:{},usage:[...t.usage]},offers:x,...b&&b.proposals.length>0?{ghost:b}:{},...l?{answer:l}:{}}}function _(n,e,t){let i=e.proposals.flatMap(r=>{try{let o=n.previewAll([r.call],{author:t}),u=o.ops.map(d=>d.intent).join("; ");return o.ops.length>0?[{...r,said:u||r.said}]:[]}catch{return[]}});return{...e,proposals:i}}function ie(n){if(n.type==="fill")return{id:n.id,label:n.label,said:n.description,call:n.call,record:n.record,field:n.field};if(n.type==="act"&&n.asks.length===0)return{id:n.id,label:n.label,said:n.description,call:{name:n.mutation,args:{...n.args}}}}function Ge(n,e,t){let i=e.proposals.filter(o=>t.ids===void 0||t.ids.includes(o.id));if(i.length===0)return{ok:!1,refused:"Nothing was chosen."};let r=i.flatMap(o=>o.confidence===void 0?[]:[o.confidence]);try{let u=n.applyAll(i.map(d=>d.call),{author:t.author,via:`ai:${e.interaction}`,intent:e.basis,lineage:{basis:`Asked \u201C${e.basis}\u201D`,...e.model?{model:e.model}:{},...r.length>0?{confidence:Math.min(...r)}:{},interaction:e.interaction}}).ops[0]?.batch;return u?{ok:!0,batch:u,accepted:i.map(d=>d.id)}:{ok:!1,refused:"That changes nothing now."}}catch(o){return{ok:!1,refused:o instanceof Error?o.message:String(o)}}}function We(n,e,t){let i=n.ask.kind==="suggest"?e.length>0:n.offered.length>0&&n.offered.every(r=>e.includes(r.id));return{...n,outcome:i?"accepted":"partly",accepted:e,batches:[...n.batches??[],t]}}var qe=n=>({...n,outcome:"dismissed"});var R=ce(Ze(),1);var A=ce(Re(),1);function _e(n,e,t){let i=e.on==="selection"?e.ids:e.on==="record"||e.on==="field"?[e.id]:[],r=i.length>0?Ee(n.store,i,{principal:n.principal,...i.length===1?{focus:i[0]}:{}}).affordances.map(o=>({mutation:o.mutation,label:o.label,args:o.args,open:o.open,why:o.why,...o.destructive?{destructive:!0}:{}})):void 0;return{store:n.store,target:e,principal:n.principal,interaction:Ae(),places:n.places,selection:n.selection,...r?{acts:r}:{},...n.place?{place:n.place}:{},...t?{said:t}:{}}}async function Ke(n,e){let t=await (__graviewPreload(import.meta.url,["./chunk.UBFNZMUX.js","./chunk.G4JJXA63.js","./chunk.HAIG6NVX.js","./chunk.UZGRRDHD.js","./chunk.OKRNJXTV.js","./chunk.CAVBSL27.js","./chunk.Q5WEOX3Q.js","./chunk.GV2CQVKV.js","./chunk.4HZ7QTXZ.js","./chunk.G5NZVPJU.js","./chunk.WVUJXDXZ.js","./chunk.ULRW47RP.js","./chunk.PBSMLINK.js","./chunk.3TY5NFLY.js","./chunk.D75KC3LL.js","./chunk.FWTIUYXH.js","./chunk.MAF7C3VM.js","./chunk.B2GLDIAS.js","./chunk.6YCBYL2Y.js","./chunk.UGFJKSHU.js","./chunk.MNP4JI33.js","./chunk.AJZBJBMO.js"]),import("./chunk.XKABS745.js")),i=t.recipeDraft(e.recipe,{app:n.app,sight:t.draftSight(n.app,n.principal)});if(t.isDraftFailure(i))return i.failed;n.seatTalk.setDraft(i,null),n.goTo.draft?.(),Qe()}function Qe(n=180){if(typeof document>"u")return;let e=document.querySelector('[data-testid="draft-keep"]'),t=document.activeElement,i=!t||t===document.body||t.closest?.("[inert]")!==null;if(e){i&&e.focus();return}n>0&&requestAnimationFrame(()=>Qe(n-1))}function cn(n,e,t){!t.ghost||t.ghost.proposals.length===0||(n.desk.setGhost({ghost:t.ghost}),n.desk.record(e))}async function Q(n,e,t,i){let r=_e(n,t,i),o=e==="suggest"?await Fe(n.ai,r):e==="fill"?await Je(n.ai,r):e==="record"?await Ue(n.ai,r):await Be(n.ai,r);if(o.interaction.outcome==="failed")return e!=="suggest"&&n.desk.record(o.interaction),o;if((e==="fill"||e==="record")&&(o.ghost?cn(n,o.interaction,o):n.desk.record({...o.interaction,outcome:"failed",failed:"Nothing here could be filled in."})),e==="panel"&&o.panel){let u=await Ke(n,o.panel);n.desk.record(u?{...o.interaction,outcome:"failed",failed:u}:o.interaction)}return o}async function fn(n,e,t){let i=e.interaction,r=ie(t);if(r){let o=i.usage?.at(-1)?.model,u=i.offered.find(l=>l.id===t.id)?.confidence,d=_(n.store,{interaction:i.id,target:i.target,basis:`${i.ask.said}: ${t.label}`,...o?{model:o}:{},proposals:[{...r,...u!==void 0?{confidence:u}:{}}]},n.principal);if(d.proposals.length===0){n.desk.record({...i,outcome:"failed",failed:"That can't be done now."});return}n.desk.setGhost({ghost:d}),n.desk.record(i);return}if(t.type==="panel"){let o=t.label,u={title:o,recipe:{...t.panel,title:o}},d=await Ke(n,u);n.desk.record(d?{...i,outcome:"failed",failed:d}:{...i,outcome:"drawn",accepted:[t.id],panel:u});return}t.type==="place"?n.goTo.place(t.place):t.type==="record"&&n.goTo.record(t.record),n.desk.record({...i,outcome:"accepted",accepted:[t.id]})}async function Mn(n,e){if(e.ask.kind==="ask")return pe(n.desk,{target:e.target,asked:e.ask.said}),null;let t=e.ask.kind==="panel"||e.ask.kind==="record"?e.ask.kind:"fill";return Q(n,t,e.target,e.ask.said)}var K={padding:"5px 10px",fontSize:"0.875rem",borderRadius:8,width:"100%",textAlign:"left",borderWidth:1,borderStyle:"solid",borderColor:"transparent",background:"none",boxShadow:"none"},ze={margin:0,padding:"4px 10px",fontSize:"0.8125rem",color:"var(--graview-ink-muted)"};function jn({target:n,close:e}){let t=je(),i=(0,R.useMemo)(()=>De(n,s=>t.store.graph.has(s)),[n,t.store]),r=(0,R.useMemo)(()=>{let s=_e(t,i);return te(t.store,i,{principal:t.principal,places:t.places,...s.acts?{acts:s.acts}:{}})},[t,i]),o=r.candidates.some(s=>s.type==="fill"),u=r.candidates.some(s=>s.type==="panel"),d=(0,R.useMemo)(()=>new Set(t.store.allMutations().filter(s=>(s.creates??[]).length>0).map(s=>s.name)),[t.store]),l=F(t.ai)!==void 0&&r.candidates.some(s=>s.type==="act"&&s.asks.length>0&&d.has(s.mutation)),[m,c]=(0,R.useState)(null),[f,y]=(0,R.useState)(!0),[b,x]=(0,R.useState)(null);(0,R.useEffect)(()=>{let s=!0;return y(!0),Q(t,"suggest",i).then(S=>{s&&(c(S),y(!1),S.interaction.outcome==="failed"&&x(S.interaction.failed??"The AI could not suggest anything here."))}),()=>{s=!1}},[i]);let k=s=>{e(),s()};return(0,A.jsxs)("div",{"data-testid":"inline-ai",style:{display:"grid",gap:2},children:[f?(0,A.jsx)("p",{role:"status","data-testid":"inline-ai-thinking",style:ze,children:"Thinking\u2026"}):b?(0,A.jsx)("p",{role:"status",style:ze,children:b}):null,(0,A.jsxs)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:2},children:[(m?.offers??[]).map(s=>(0,A.jsx)("li",{children:(0,A.jsxs)("button",{type:"button","data-menu-item":`ai-offer:${s.id}`,"data-ai-offer":s.id,"data-ai-offer-type":s.type,onClick:()=>k(()=>fn(t,m,s)),style:K,children:[s.label,(0,A.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",s.type==="panel"?"a panel":s.type==="place"?"go there":s.type==="record"?"open it":"suggested"]})]})},s.id)),o?(0,A.jsx)("li",{children:(0,A.jsx)("button",{type:"button","data-menu-item":"ai-fill",onClick:()=>k(()=>Q(t,"fill",i,"Fill in")),style:K,children:"Fill in with AI"})}):null,l?(0,A.jsx)("li",{children:(0,A.jsx)("button",{type:"button","data-menu-item":"ai-record",onClick:()=>k(()=>Q(t,"record",i,"Add one")),style:K,children:"Add one with AI"})}):null,u?(0,A.jsx)("li",{children:(0,A.jsx)("button",{type:"button","data-menu-item":"ai-panel",onClick:()=>k(()=>Q(t,"panel",i,"Draw a panel")),style:K,children:"Draw a panel"})}):null,(0,A.jsx)("li",{children:(0,A.jsx)("button",{type:"button","data-menu-item":"ai-ask",onClick:()=>{let s=document.activeElement;e(),pe(t.desk,{target:i,returnTo:s instanceof HTMLElement&&s!==document.body?s:null})},style:K,children:"Ask about this\u2026"})})]})]})}var de={display:"inline-flex",alignItems:"center",minHeight:28,padding:"2px 10px",fontSize:"0.8125rem",borderRadius:8};function En({placement:n="picture"}){let{store:e,principal:t,aiDesk:i}=Me(),r=Ie(e,t),{ghost:o,entries:u}=ve(i),[d,l]=(0,R.useState)(new Set);(0,R.useEffect)(()=>l(new Set),[o?.ghost.interaction]);let m=(0,R.useRef)(null),c=(0,R.useRef)(null),f=o?.batch;if((0,R.useEffect)(()=>{f!==void 0&&c.current?.focus()},[f]),!o)return null;let{ghost:y}=o,b=u.find(p=>p.id===y.interaction),x=()=>{let p=y.target.on==="record"||y.target.on==="field"?y.target.id:void 0,M=m.current?.closest("[data-graview-face], main")?.parentElement??document,P=(p?M.querySelector(`[data-graview-view="${CSS.escape(p)}"][tabindex]`):null)??document.querySelector("[data-graview-page-title]")??m.current?.closest("main")??document.querySelector("main");P&&!P.hasAttribute("tabindex")&&P.setAttribute("tabindex","-1"),P?.focus({preventScroll:!0}),i.setGhost(null)},k=y.proposals.filter(p=>!d.has(p.id)).map(p=>p.id),s=()=>{let p=Ge(r,y,{author:t,ids:k});if(!p.ok){i.setGhost({...o,refused:p.refused});return}b&&i.record(We(b,p.accepted,p.batch)),i.setGhost({ghost:y,batch:p.batch,took:p.accepted.length,...o.onCard?{onCard:!0}:{}})},S=()=>{b&&o.batch===void 0&&i.record(qe(b)),x()},h=()=>{if(o.batch!==void 0)try{r.undo(o.batch,{author:t}),x()}catch(p){i.setGhost({...o,refused:p instanceof Error?p.message:String(p)})}};return(0,A.jsxs)("section",{ref:m,"data-testid":"ai-ghost","data-interaction":y.interaction,"aria-label":"Proposed by AI",style:{...n==="card"?{position:"static"}:{position:n==="page"?"fixed":"absolute",insetInline:"max(12px, calc(50% - 220px))",bottom:"calc(var(--graview-foot-room, 0px) + 72px)",zIndex:Te("toast"),boxShadow:"var(--graview-lift-high)"},display:"grid",gap:8,padding:12,borderRadius:12,border:"1px dashed var(--graview-accent)",background:"var(--graview-float)",fontSize:"0.875rem"},children:[(0,A.jsx)("p",{style:{margin:0,color:"var(--graview-ink-muted)"},children:o.batch!==void 0?`Done: ${o.took===1?"one change":`${o.took} changes`}, as one.`:`Proposed by AI \xB7 ${y.basis}`}),o.batch===void 0?(0,A.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:4},children:y.proposals.map(p=>(0,A.jsx)("li",{"data-ghost-proposal":p.id,children:(0,A.jsxs)("label",{style:{display:"flex",alignItems:"baseline",gap:8,cursor:"pointer"},children:[(0,A.jsx)("input",{type:"checkbox",checked:!d.has(p.id),onChange:M=>{let P=new Set(d);M.target.checked?P.delete(p.id):P.add(p.id),l(P)}}),(0,A.jsx)("span",{style:{fontStyle:"italic",color:"var(--graview-ink)"},children:p.said}),p.confidence!==void 0?(0,A.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[Math.round(p.confidence*100),"% sure"]}):null]})},p.id))}):null,o.refused?(0,A.jsx)("p",{role:"alert",style:{margin:0,color:"var(--graview-warn)"},children:o.refused}):null,(0,A.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:o.batch===void 0?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("button",{type:"button","data-testid":"ghost-accept",disabled:k.length===0,onClick:s,style:de,children:k.length===y.proposals.length?"Accept":`Accept ${k.length} of ${y.proposals.length}`}),(0,A.jsx)("button",{type:"button","data-testid":"ghost-dismiss",onClick:S,style:de,children:"Dismiss"})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("button",{type:"button",ref:c,"data-testid":"ghost-undo",onClick:h,style:de,children:"Undo"}),(0,A.jsx)("button",{type:"button","data-testid":"ghost-close",onClick:x,style:de,children:"Close"})]})})]})}export{De as a,me as b,te as c,rn as d,wn as e,_e as f,Ke as g,Q as h,fn as i,Mn as j,jn as k,En as l};
@@ -0,0 +1 @@
1
+ import{b as n}from"./chunk.NTF7FVB2.js";import"./chunk.5UL7YDUD.js";import{a}from"./chunk.JDUJDAGA.js";import"./chunk.LR3VDXPI.js";import"./chunk.COQKECUH.js";import"./chunk.EJPI3ST6.js";import"./chunk.3K6YSVHC.js";import"./chunk.SHTJZ6UX.js";import"./chunk.UT6642FC.js";import"./chunk.TI4OSTQV.js";import"./chunk.GZHZLJBF.js";import"./chunk.XMC7YDWT.js";import"./chunk.6UGEYZAC.js";import"./chunk.OJGHDWI6.js";import"./chunk.B2GLDIAS.js";import"./chunk.6YCBYL2Y.js";import"./chunk.UGFJKSHU.js";import"./chunk.JOOQUWLT.js";import{Q as i}from"./chunk.6QWV5MVH.js";import"./chunk.MNP4JI33.js";import{b as o}from"./chunk.AJZBJBMO.js";var e=o(i(),1);function g({entries:d,style:l,headingStyle:p,className:r}){return(0,e.jsxs)("section",{...r?{className:r}:{},"data-testid":"record-ai","aria-label":"What AI did here",style:{display:"grid",gap:10,...l},children:[(0,e.jsx)("h2",{style:p??{margin:0,fontSize:"1rem"},children:"What AI did here"}),(0,e.jsx)("ol",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:8,fontSize:"0.875rem"},children:d.slice(0,8).map(t=>(0,e.jsx)(n,{entry:t,undo:s=>(0,e.jsx)(a,{batch:s})},t.id))})]})}export{g as RecordInteractions};
@@ -1 +1 @@
1
- import{A as Y,C as Z,F as ee,a as T,d as K,f as z,i as D,j as W,n as _,o as j,p as U,s as J,u as Q,w as X}from"./chunk.L4DECHXR.js";import{$ as I,G as se,R as $,Z as G,la as V,sa as q}from"./chunk.GFF2FB2J.js";import{Kb as M,Tb as P,Vb as O,tc as N}from"./chunk.6V2RG5JG.js";import{b as k}from"./chunk.AJZBJBMO.js";var o=k(se(),1);function ie(e){let t=[e?.typography?.body,e?.typography?.display,e?.typography?.mono],n=[];for(let a of t){let r=a?.split(",")[0]?.trim().replace(/^["']|["']$/g,"");!r||O(r)||r.toLowerCase()!==M.toLowerCase()&&(n.includes(r)||n.push(r))}return n}function ne(e){let t=ie(e);return t.length===0?null:`https://fonts.googleapis.com/css2?${t.map(a=>`family=${encodeURIComponent(a).replace(/%20/g,"+")}:wght@400;500;600;700`).join("&")}&display=swap`}var l=k($(),1);function be({rootRef:e,firstLook:t,app:n}){let a=(0,o.useCallback)(()=>e.current,[e]);return t?(0,l.jsx)(ee,{firstLook:t,root:a,app:n}):null}function ve(e,t){let{app:n}=e;return(0,o.useMemo)(()=>{let a=Y(t(n.schema,n.viewSpecs),n),r=e.views?V(a,e.views(n.schema,a)):a;return Z(r,n.schema,Q(e.brand??n.brand,n.schema)),r},[e.views,n.schema,n.viewSpecs,n.lenses,n.pages,n.home])}function ce(e,t){return new N({schema:e.schema,mutations:e.mutations??[],invariants:e.invariants??[],...t?{snapshot:t}:{},...e.policy?{policy:e.policy}:{},...e.intelligence?{intelligence:e.intelligence}:{}})}function te(e){if(typeof document>"u")return e==="dark"?"dark":"light";let t=document.documentElement.dataset.theme;return t==="dark"||t==="light"?t:e==="dark"||e==="light"?e:typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function de(e,t){let[n,a]=(0,o.useState)(()=>te(t));return(0,o.useEffect)(()=>{if(!e||typeof document>"u")return;let r=()=>a(te(t));r();let i=new MutationObserver(r);i.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});let d=typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)"):null;return d?.addEventListener?.("change",r),()=>{i.disconnect(),d?.removeEventListener?.("change",r)}},[e,t]),n}var A=e=>e?e.getBoundingClientRect().height:0;function Se(e,t,n){let a=(0,o.useRef)(n);a.current=n;let r=n!==void 0;(0,o.useLayoutEffect)(()=>{let i=e.current;if(!i||!r)return;let d=()=>{let u=[...i.children],b=u.find(v=>v.hasAttribute("data-graview-app-bar")),y=u.find(v=>v.hasAttribute("data-embed-content")),h=y?.querySelector("[data-embed-measure]")??null,c=u.find(v=>v.hasAttribute("data-graview-place-line"));return{strip:b,line:c,content:y,measure:h}},s=-1,f=()=>{let{strip:u,line:b,content:y,measure:h}=d(),c=Math.ceil(A(u)+A(b)+A(h||y));c!==s&&(s=c,a.current?.(c))};if(f(),typeof ResizeObserver>"u")return;let m=new ResizeObserver(f),E=()=>{m.disconnect();let{strip:u,line:b,content:y,measure:h}=d();for(let c of[i,u,b,y,h])c&&m.observe(c)};E();let g=new MutationObserver(()=>{E(),f()});return g.observe(i,{childList:!0}),()=>{m.disconnect(),g.disconnect()}},[e,t,r])}var we=480,le=0;function Ee(e){let{app:t,seed:n,scheme:a="auto",brand:r=t.brand,fonts:i=!0,height:d="100%",label:s}=e,f=(0,o.useRef)(null);q(f);let m=d==="viewport"?"100dvh":d,E=z(typeof m=="string"&&/vh\b/.test(m)),g=(0,o.useMemo)(()=>`graview-embed-${++le}`,[]),u=(0,o.useMemo)(()=>e.store??e.remote?.store??ce(t,n),[e.store,e.remote,t,n]),b=e.presence??e.remote?.presence,y=e.hostContext?.theme,h=de(a==="auto"&&y===void 0,r?.scheme),c=a==="auto"?y??h:a,v=(0,o.useMemo)(()=>T(c,r,{scope:`.${g}`}),[c,r,g]);K(e.favicon?P(r):void 0),(0,o.useEffect)(()=>{if(!i||typeof document>"u")return;let w=ne(r);if(!w||document.querySelector(`link[href="${w}"]`))return;let p=document.createElement("link");p.rel="stylesheet",p.href=w,document.head.appendChild(p)},[r,i]);let L=(0,o.useRef)(void 0);(0,o.useLayoutEffect)(()=>{let w=f.current,p=L.current;if(L.current=s,!w||!s)return;let ae=S=>{let R=S.getAttribute("aria-label")??"",x=p&&p!==s?R.startsWith(`${p} \xB7 `)?R.slice(p.length+3):R===p?"":R:R;x===s&&(S.getAttribute("role")==="region"||S.tagName==="SECTION"&&!S.hasAttribute("role"))&&S.setAttribute("role","group");let B=x.startsWith(`${s} \xB7 `)||x===s?x:x?`${s} \xB7 ${x}`:s;B!==R&&S.setAttribute("aria-label",B)},H=()=>w.querySelectorAll("aside, nav, main, header, footer, section[aria-label]:not([role]), [role=region], [role=complementary], [role=navigation], [role=search]").forEach(S=>{S.hasAttribute("data-graview-named-by-lens")||ae(S)});H();let C=new MutationObserver(H);return C.observe(w,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["aria-label"]}),()=>C.disconnect()},[s]);let oe=E?`${m}`.replace(/([\d.]+)[sdl]?vh\b/g,(w,p)=>`${+p*E/100}px`):m;return{rootRef:f,scope:g,css:v,scheme:c,store:u,presence:b,brand:r,auto:d==="auto",height:oe}}function Re({rootRef:e,board:t}){let n=(0,o.useCallback)(()=>e.current?.querySelector("[data-embed-content]")??e.current,[e]);return(0,l.jsx)(J,{board:t,anchor:n})}function xe(e,t,n){return{brand:n,locale:e.locale,principal:e.principal,seats:e.seats,presence:t,people:e.people,memory:e.memory,presenceTtlMs:e.presenceTtlMs,onKeepLens:e.onKeepLens,ai:e.ai,files:e.files,resolveApp:e.resolveApp,history:e.history,linkedRecords:e.linkedRecords,menuSections:e.menuSections,app:e.app}}function Ae({name:e,heading:t,faces:n,at:a,without:r,home:i,reach:d,standing:s,hostActions:f,keeping:m,onFind:E,switch:g}){let{brand:u,store:b,principal:y,views:h}=G();I();let c=r?.has("places")?[]:D({store:b,principal:y,views:h}),v=U();return(0,l.jsx)(_,{brand:u,name:e,description:u?.subtitle,heading:t,faces:n,home:i,places:c,current:a===null?null:W(c,a),reach:d,onFind:E,...g?{switch:g}:{},...n?{scenePlaces:v}:{},tools:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(X,{clean:s}),(0,l.jsx)(j,{...f?{hostActions:f}:{},...m?{keeping:m}:{}})]})})}var ke=e=>e===!1?2:Math.min(e+1,6);function Fe(e){let[t,n]=(0,o.useState)(e),a=(0,o.useRef)(void 0),r=(0,o.useRef)(void 0),i=(0,o.useMemo)(()=>({go:a,at:n,pending:r}),[]),d=(0,o.useCallback)(s=>{if(a.current){a.current(s);return}r.current=s,n(s)},[]);return{at:t,setAt:n,steering:i,steer:d}}function ue(e){let t=typeof e=="object"&&e!==null?e.name:void 0;return{name:typeof t=="string"&&t.length>0?t:typeof e=="object"?"Error":typeof e}}var F=()=>typeof performance<"u"?performance.now():Date.now();function Le(e,t){let n=(0,o.useRef)({onError:e,face:t});return n.current={onError:e,face:t},(0,o.useCallback)((a,r)=>n.current.onError?.(ue(a),{module:r.module,face:n.current.face}),[])}function He(e,t){let n=(0,o.useRef)(null);n.current===null&&(n.current=F());let a=(0,o.useRef)({onReady:e,face:t});a.current={onReady:e,face:t};let r=(0,o.useRef)(!1);return(0,o.useCallback)(i=>{r.current||(r.current=!0,a.current.onReady?.({ms:Math.max(0,F()-(n.current??F())),face:i}))},[])}var re=class extends o.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(t,n){console.error(`[graview] ${this.props.module} threw while rendering`,t,n.componentStack),this.props.report(t,{module:this.props.module})}render(){return this.state.failed?(0,l.jsxs)("div",{role:"alert","data-graview-face-error":this.props.module,...this.props.content?{"data-embed-content":""}:{},style:this.props.content?{flex:"1 1 auto",display:"grid",alignContent:"center",justifyItems:"center",gap:8,padding:24,background:"var(--graview-ground)",color:"var(--graview-ink)",fontSize:"0.9375rem"}:{display:"inline-flex",alignItems:"center",gap:6,fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:[(0,l.jsx)("span",{children:this.props.content?"This part of the app could not draw.":"Could not draw."}),(0,l.jsx)("button",{type:"button",onClick:()=>this.setState({failed:!1}),style:{padding:"3px 11px",fontSize:"0.8125rem"},children:"Try again"})]}):this.props.children}};export{be as a,ve as b,ce as c,Se as d,we as e,Ee as f,Re as g,xe as h,Ae as i,ke as j,Fe as k,Le as l,He as m,re as n};
1
+ import{C as Q,E as X,I as Y,K as Z,N as ee,a as T,i as K,l as z,o as D,p as W,t as _,u as j,w as U,z as J}from"./chunk.JOOQUWLT.js";import{F as se,Q as $,Y as G,_ as I,ka as V,ra as q}from"./chunk.6QWV5MVH.js";import{Lb as M,Ub as P,Wb as O,wc as N}from"./chunk.MNP4JI33.js";import{b as k}from"./chunk.AJZBJBMO.js";var o=k(se(),1);function ie(e){let t=[e?.typography?.body,e?.typography?.display,e?.typography?.mono],n=[];for(let a of t){let r=a?.split(",")[0]?.trim().replace(/^["']|["']$/g,"");!r||O(r)||r.toLowerCase()!==M.toLowerCase()&&(n.includes(r)||n.push(r))}return n}function ne(e){let t=ie(e);return t.length===0?null:`https://fonts.googleapis.com/css2?${t.map(a=>`family=${encodeURIComponent(a).replace(/%20/g,"+")}:wght@400;500;600;700`).join("&")}&display=swap`}var l=k($(),1);function be({rootRef:e,firstLook:t,app:n}){let a=(0,o.useCallback)(()=>e.current,[e]);return t?(0,l.jsx)(ee,{firstLook:t,root:a,app:n}):null}function Se(e,t){let{app:n}=e;return(0,o.useMemo)(()=>{let a=Y(t(n.schema,n.viewSpecs),n),r=e.views?V(a,e.views(n.schema,a)):a;return Z(r,n.schema,Q(e.brand??n.brand,n.schema)),r},[e.views,n.schema,n.viewSpecs,n.lenses,n.pages,n.home])}function ce(e,t){return new N({schema:e.schema,mutations:e.mutations??[],invariants:e.invariants??[],...t?{snapshot:t}:{},...e.policy?{policy:e.policy}:{},...e.intelligence?{intelligence:e.intelligence}:{}})}function te(e){if(typeof document>"u")return e==="dark"?"dark":"light";let t=document.documentElement.dataset.theme;return t==="dark"||t==="light"?t:e==="dark"||e==="light"?e:typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function de(e,t){let[n,a]=(0,o.useState)(()=>te(t));return(0,o.useEffect)(()=>{if(!e||typeof document>"u")return;let r=()=>a(te(t));r();let i=new MutationObserver(r);i.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});let d=typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)"):null;return d?.addEventListener?.("change",r),()=>{i.disconnect(),d?.removeEventListener?.("change",r)}},[e,t]),n}var A=e=>e?e.getBoundingClientRect().height:0;function ve(e,t,n){let a=(0,o.useRef)(n);a.current=n;let r=n!==void 0;(0,o.useLayoutEffect)(()=>{let i=e.current;if(!i||!r)return;let d=()=>{let u=[...i.children],b=u.find(S=>S.hasAttribute("data-graview-app-bar")),y=u.find(S=>S.hasAttribute("data-embed-content")),h=y?.querySelector("[data-embed-measure]")??null,c=u.find(S=>S.hasAttribute("data-graview-place-line"));return{strip:b,line:c,content:y,measure:h}},s=-1,f=()=>{let{strip:u,line:b,content:y,measure:h}=d(),c=Math.ceil(A(u)+A(b)+A(h||y));c!==s&&(s=c,a.current?.(c))};if(f(),typeof ResizeObserver>"u")return;let m=new ResizeObserver(f),E=()=>{m.disconnect();let{strip:u,line:b,content:y,measure:h}=d();for(let c of[i,u,b,y,h])c&&m.observe(c)};E();let g=new MutationObserver(()=>{E(),f()});return g.observe(i,{childList:!0}),()=>{m.disconnect(),g.disconnect()}},[e,t,r])}var we=480,le=0;function Ee(e){let{app:t,seed:n,scheme:a="auto",brand:r=t.brand,fonts:i=!0,height:d="100%",label:s}=e,f=(0,o.useRef)(null);q(f);let m=d==="viewport"?"100dvh":d,E=z(typeof m=="string"&&/vh\b/.test(m)),g=(0,o.useMemo)(()=>`graview-embed-${++le}`,[]),u=(0,o.useMemo)(()=>e.store??e.remote?.store??ce(t,n),[e.store,e.remote,t,n]),b=e.presence??e.remote?.presence,y=e.hostContext?.theme,h=de(a==="auto"&&y===void 0,r?.scheme),c=a==="auto"?y??h:a,S=(0,o.useMemo)(()=>T(c,r,{scope:`.${g}`}),[c,r,g]);K(e.favicon?P(r):void 0),(0,o.useEffect)(()=>{if(!i||typeof document>"u")return;let w=ne(r);if(!w||document.querySelector(`link[href="${w}"]`))return;let p=document.createElement("link");p.rel="stylesheet",p.href=w,document.head.appendChild(p)},[r,i]);let L=(0,o.useRef)(void 0);(0,o.useLayoutEffect)(()=>{let w=f.current,p=L.current;if(L.current=s,!w||!s)return;let ae=v=>{let R=v.getAttribute("aria-label")??"",x=p&&p!==s?R.startsWith(`${p} \xB7 `)?R.slice(p.length+3):R===p?"":R:R;x===s&&(v.getAttribute("role")==="region"||v.tagName==="SECTION"&&!v.hasAttribute("role"))&&v.setAttribute("role","group");let B=x.startsWith(`${s} \xB7 `)||x===s?x:x?`${s} \xB7 ${x}`:s;B!==R&&v.setAttribute("aria-label",B)},H=()=>w.querySelectorAll("aside, nav, main, header, footer, section[aria-label]:not([role]), [role=region], [role=complementary], [role=navigation], [role=search]").forEach(v=>{v.hasAttribute("data-graview-named-by-lens")||ae(v)});H();let C=new MutationObserver(H);return C.observe(w,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["aria-label"]}),()=>C.disconnect()},[s]);let oe=E?`${m}`.replace(/([\d.]+)[sdl]?vh\b/g,(w,p)=>`${+p*E/100}px`):m;return{rootRef:f,scope:g,css:S,scheme:c,store:u,presence:b,brand:r,auto:d==="auto",height:oe}}function Re({rootRef:e,board:t}){let n=(0,o.useCallback)(()=>e.current?.querySelector("[data-embed-content]")??e.current,[e]);return(0,l.jsx)(J,{board:t,anchor:n})}function xe(e,t,n){return{brand:n,locale:e.locale,principal:e.principal,seats:e.seats,presence:t,people:e.people,memory:e.memory,presenceTtlMs:e.presenceTtlMs,onKeepLens:e.onKeepLens,ai:e.ai,files:e.files,resolveApp:e.resolveApp,history:e.history,linkedRecords:e.linkedRecords,subscriptions:e.subscriptions,menuSections:e.menuSections,app:e.app}}function Ae({name:e,heading:t,faces:n,at:a,without:r,home:i,reach:d,standing:s,hostActions:f,keeping:m,onFind:E,switch:g}){let{brand:u,store:b,principal:y,views:h}=G();I();let c=r?.has("places")?[]:D({store:b,principal:y,views:h}),S=U();return(0,l.jsx)(_,{brand:u,name:e,description:u?.subtitle,heading:t,faces:n,home:i,places:c,current:a===null?null:W(c,a),reach:d,onFind:E,...g?{switch:g}:{},...n?{scenePlaces:S}:{},tools:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(X,{clean:s}),(0,l.jsx)(j,{...f?{hostActions:f}:{},...m?{keeping:m}:{}})]})})}var ke=e=>e===!1?2:Math.min(e+1,6);function Fe(e){let[t,n]=(0,o.useState)(e),a=(0,o.useRef)(void 0),r=(0,o.useRef)(void 0),i=(0,o.useMemo)(()=>({go:a,at:n,pending:r}),[]),d=(0,o.useCallback)(s=>{if(a.current){a.current(s);return}r.current=s,n(s)},[]);return{at:t,setAt:n,steering:i,steer:d}}function ue(e){let t=typeof e=="object"&&e!==null?e.name:void 0;return{name:typeof t=="string"&&t.length>0?t:typeof e=="object"?"Error":typeof e}}var F=()=>typeof performance<"u"?performance.now():Date.now();function Le(e,t){let n=(0,o.useRef)({onError:e,face:t});return n.current={onError:e,face:t},(0,o.useCallback)((a,r)=>n.current.onError?.(ue(a),{module:r.module,face:n.current.face}),[])}function He(e,t){let n=(0,o.useRef)(null);n.current===null&&(n.current=F());let a=(0,o.useRef)({onReady:e,face:t});a.current={onReady:e,face:t};let r=(0,o.useRef)(!1);return(0,o.useCallback)(i=>{r.current||(r.current=!0,a.current.onReady?.({ms:Math.max(0,F()-(n.current??F())),face:i}))},[])}var re=class extends o.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(t,n){console.error(`[graview] ${this.props.module} threw while rendering`,t,n.componentStack),this.props.report(t,{module:this.props.module})}render(){return this.state.failed?(0,l.jsxs)("div",{role:"alert","data-graview-face-error":this.props.module,...this.props.content?{"data-embed-content":""}:{},style:this.props.content?{flex:"1 1 auto",display:"grid",alignContent:"center",justifyItems:"center",gap:8,padding:24,background:"var(--graview-ground)",color:"var(--graview-ink)",fontSize:"0.9375rem"}:{display:"inline-flex",alignItems:"center",gap:6,fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:[(0,l.jsx)("span",{children:this.props.content?"This part of the app could not draw.":"Could not draw."}),(0,l.jsx)("button",{type:"button",onClick:()=>this.setState({failed:!1}),style:{padding:"3px 11px",fontSize:"0.8125rem"},children:"Try again"})]}):this.props.children}};export{be as a,Se as b,ce as c,ve as d,we as e,Ee as f,Re as g,xe as h,Ae as i,ke as j,Fe as k,Le as l,He as m,re as n};
@@ -1,4 +1,4 @@
1
- import{a as j,b as D}from"./chunk.XRJBLH4N.js";import"./chunk.3JNMSOFG.js";import"./chunk.PKK6FRZR.js";import"./chunk.OAF7TUMI.js";import{a as I}from"./chunk.QIAKO27D.js";import"./chunk.UT6642FC.js";import{a as k,b as V}from"./chunk.MB7LKKUD.js";import"./chunk.7BWT5L2L.js";import"./chunk.OZNW5W4Z.js";import"./chunk.NDADLJE6.js";import"./chunk.AK3IHFCF.js";import"./chunk.HHPGWJDO.js";import"./chunk.42YX6NOY.js";import"./chunk.3VL5WECB.js";import"./chunk.JH6MU6TX.js";import"./chunk.WAFDCOOG.js";import"./chunk.L4DECHXR.js";import{G as Q,R as H,ua as x}from"./chunk.GFF2FB2J.js";import{Z as B,dc as q}from"./chunk.6V2RG5JG.js";import{b}from"./chunk.AJZBJBMO.js";var t=b(Q(),1);var a=b(H(),1);function U(r){let n=[];return r.applied.length>0&&r.intent&&n.push(`${r.intent}.`),r.unchanged.length>0&&n.push(`${r.unchanged.length} already so.`),r.allOrNothing&&n.push("None of it was kept."),n.join(" ")}function ie({store:r,chosen:n,principal:d,context:v,via:S,anchor:E,of:g,onChooseAll:A,onClear:p,onActed:F}){let[K,W]=(0,t.useState)(0);(0,t.useEffect)(()=>r.subscribe(()=>W(e=>e+1)),[r]);let m=n.join(`
1
+ import{a as j,b as D}from"./chunk.3AGY4QVS.js";import"./chunk.SYAEBGDC.js";import"./chunk.UZGRRDHD.js";import"./chunk.XANVHJQ4.js";import{a as I}from"./chunk.EJPI3ST6.js";import"./chunk.SHTJZ6UX.js";import"./chunk.UT6642FC.js";import{a as k,b as V}from"./chunk.MB7LKKUD.js";import"./chunk.ULRW47RP.js";import"./chunk.PBSMLINK.js";import"./chunk.3TY5NFLY.js";import"./chunk.D75KC3LL.js";import"./chunk.FWTIUYXH.js";import"./chunk.MAF7C3VM.js";import"./chunk.B2GLDIAS.js";import"./chunk.6YCBYL2Y.js";import"./chunk.UGFJKSHU.js";import"./chunk.JOOQUWLT.js";import{F as Q,Q as H,ta as x}from"./chunk.6QWV5MVH.js";import{_ as B,ec as q}from"./chunk.MNP4JI33.js";import{b}from"./chunk.AJZBJBMO.js";var t=b(Q(),1);var a=b(H(),1);function U(r){let n=[];return r.applied.length>0&&r.intent&&n.push(`${r.intent}.`),r.unchanged.length>0&&n.push(`${r.unchanged.length} already so.`),r.allOrNothing&&n.push("None of it was kept."),n.join(" ")}function ie({store:r,chosen:n,principal:d,context:v,via:S,anchor:E,of:g,onChooseAll:A,onClear:p,onActed:F}){let[K,W]=(0,t.useState)(0);(0,t.useEffect)(()=>r.subscribe(()=>W(e=>e+1)),[r]);let m=n.join(`
2
2
  `),{acts:h,withheld:N}=(0,t.useMemo)(()=>j(r,n,{...d?{principal:d}:{},...v?{context:v}:{}}),[r,m,d,v,K]),[L,u]=(0,t.useState)(!1),[l,c]=(0,t.useState)(null),[s,O]=(0,t.useState)(null),w=(0,t.useRef)(null),M=(0,t.useId)(),f=(0,t.useMemo)(()=>[...new Set(n.map(e=>r.graph.getNode(e)?.kind))],[r,m]),_=f.length===1&&f[0]?`${B(r.schema,f[0],n.length)} chosen`:`${n.length} chosen`,P=typeof matchMedia=="function"&&matchMedia("(pointer: coarse), (max-width: 599px)").matches?2:3,C=h.filter(e=>!e.more),G=C.slice(0,P),T=[...C.slice(P),...h.filter(e=>e.more)];(0,t.useEffect)(()=>{c(null),u(!1)},[m]),(0,t.useLayoutEffect)(()=>{let e=w.current;if(!e)return;if(typeof e.showPopover=="function"&&!x(e))try{e.showPopover()}catch{}let i=()=>{V(e,E?.()??null),dispatchEvent(new Event(k))};i(),addEventListener("resize",i),addEventListener("scroll",i,!0);let o=typeof ResizeObserver=="function"?new ResizeObserver(i):null;return o?.observe(e),()=>{if(o?.disconnect(),removeEventListener("resize",i),removeEventListener("scroll",i,!0),e.isConnected&&x(e))try{e.hidePopover()}catch{}dispatchEvent(new Event(k))}},[E]);let y=(0,t.useRef)({asking:l,onClear:p});y.current={asking:l,onClear:p},(0,t.useEffect)(()=>{let e=i=>{if(i.key!=="Escape"||i.defaultPrevented)return;let o=document.activeElement;if(!(!(w.current?.contains(o)??!1)&&(o instanceof HTMLTextAreaElement||o instanceof HTMLInputElement&&o.type!=="checkbox"||o instanceof HTMLSelectElement))){if(i.preventDefault(),i.stopPropagation(),y.current.asking){c(null);return}y.current.onClear()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[]);let R=(e,i={})=>{let o=D(r,{mutation:e.mutation,subject:e.subject,args:{...e.args,...i},label:e.label},n,{...d?{author:d}:{},...S?{via:S}:{},...v?{context:v}:{}});c(null),u(!1),O(o.refused.length>0||o.applied.length===0?o:null),F(o.refused.map(z=>z.id))},J=e=>{O(null),u(!1),e.open.length>0?c(e):R(e)},$=e=>(0,a.jsxs)("button",{type:"button",className:"graview-several-act","data-testid":"several-act","data-act":e.id,"data-mutation":e.mutation,...e.destructive?{"data-tone":"warn"}:{},"aria-pressed":l?.id===e.id?!0:void 0,onClick:()=>J(e),children:[e.label,e.open.length>0?"\u2026":""]},e.id);return(0,a.jsxs)("div",{ref:w,popover:"manual",role:"region","aria-label":"The chosen records",className:"graview-several-bar","data-testid":"several-bar","data-graview-foot":"","data-graview-overlay":"","data-graview-popover":"","data-graview-offstage":"",style:X,children:[(0,a.jsx)("style",{children:Y}),(0,a.jsxs)("div",{className:"graview-several-line",children:[(0,a.jsx)("span",{role:"status","aria-live":"polite",className:"graview-several-count","data-testid":"several-count",children:_}),(0,a.jsxs)("div",{role:"group","aria-label":`What to do with the ${n.length} chosen`,className:"graview-several-acts",children:[G.map($),T.length>0?(0,a.jsx)("button",{type:"button",className:"graview-several-act","data-testid":"several-more","aria-expanded":L,"aria-controls":M,onClick:()=>u(e=>!e),children:"More"}):null,A&&g!==void 0&&g>n.length?(0,a.jsxs)("button",{type:"button",className:"graview-several-quiet","data-testid":"several-all",onClick:A,children:["Choose all ",g]}):null,(0,a.jsx)("button",{type:"button",className:"graview-several-quiet","data-testid":"several-clear","aria-keyshortcuts":"Escape",title:"Put the choice down \u2014 Escape",onClick:p,children:"Clear"})]})]}),L?(0,a.jsx)("div",{id:M,role:"group","aria-label":"More",className:"graview-several-acts","data-testid":"several-more-acts",children:T.map($)}):null,h.length===0?(0,a.jsx)("p",{className:"graview-several-said","data-testid":"several-none",children:N.length>0?`Nothing here can be done to all of them by you: ${N[0].message}`:"Nothing can be done to all of these at once."}):null,l?(0,a.jsx)("div",{className:"graview-several-ask",role:"group","aria-label":`${l.label}, for all ${n.length}`,"data-testid":"several-ask",children:(0,a.jsx)(I,{store:r,affordance:l.affordance,onApply:e=>R(l,e),onCancel:()=>c(null)})}):null,s?(0,a.jsxs)("div",{role:"alert",className:"graview-several-said","data-testid":"several-outcome",children:[U(s),s.refused.length>0?(0,a.jsxs)(a.Fragment,{children:[" ",s.refused.length===1?"One was not changed, and is still chosen:":`${s.refused.length} were not changed, and are still chosen:`,(0,a.jsx)("ul",{"data-testid":"several-refused",children:s.refused.map(e=>(0,a.jsxs)("li",{"data-record":e.id,children:["\u201C",e.label,"\u201D \u2014 ",e.message]},e.id))})]}):null]}):null]})}var X={position:"fixed",inset:"auto",margin:0,zIndex:q("toast"),boxSizing:"border-box",width:"max-content",height:"auto",bottom:"calc(16px + env(safe-area-inset-bottom, 0px))",left:16,overflow:"visible"},Y=`
3
3
  .graview-several-bar{display:grid;gap:8px;padding:8px 10px;border:1px solid var(--graview-edge);border-radius:var(--graview-radius,12px);background:var(--graview-float);color:var(--graview-ink);box-shadow:var(--graview-lift-high);font-size:.875rem;line-height:1.4;max-height:70vh;overflow:auto}
4
4
  .graview-several-line{display:flex;flex-wrap:wrap;align-items:center;gap:6px 12px;min-width:0}
@@ -0,0 +1 @@
1
+ import{B as w,D as b,G as k,J as $,N as p,Z as N,ca as D,ja as E,kb as F,qb as S,tb as T}from"./chunk.MNP4JI33.js";function W(e,n,r){let o=[...n?.creates??[],...n?.subject&&n.subject.kinds!=="*"?n.subject.kinds:[]];for(let t of o){let i=e.tryDefinition(t),a=i?.fields?.shape??{};if(!i||!(r in a))continue;let d=i.display?.format?.[r];return{label:i.display?.labels?.[r]??D(i,r),option:u=>d?d(u):N(u)}}return{label:D(void 0,r),option:t=>N(t)}}function P(e,n,r){if(r instanceof F){let o=n.find(i=>i.name===r.mutation);return`Not yet: ${r.issues.map(i=>{let a=i.path.length>0?W(e,o,String(i.path[0])).label:void 0;return a?`${a} \u2014 ${i.message.replace(/^./,d=>d.toLowerCase())}`:i.message}).join("; ")}.`}return r instanceof Error?r.message:String(r)}var x=864e5,Z=/^(\d{4})-(\d{2})-(\d{2})/,y=e=>String(e).padStart(2,"0"),M=e=>new Date(e).toISOString().slice(0,10),m=e=>Date.UTC(+e.slice(0,4),+e.slice(5,7)-1,+e.slice(8,10)),g=(e,n)=>M(m(e)+n*x),R=e=>new Date(m(e)).getUTCDay();function l(e,n,r){if(!(n>=1&&n<=12&&r>=1&&r<=31))return;let o=`${String(e).padStart(4,"0")}-${y(n)}-${y(r)}`;return M(m(o))===o?o:void 0}function I(e=new Date){return{day:`${e.getFullYear()}-${y(e.getMonth()+1)}-${y(e.getDate())}`,minutes:e.getHours()*60+e.getMinutes()}}var j=e=>/T\d\d:\d\d(:[\d.]+)?(Z|[+-]\d\d:?\d\d)$/.test(e);function h(e){if(typeof e!="string")return;if(j(e)){let o=new Date(e);return Number.isNaN(o.getTime())?void 0:I(o)}let n=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2}))?/.exec(e);if(!n||!l(Number(n[1]),Number(n[2]),Number(n[3])))return;let r=e.slice(0,10);return n[4]===void 0?{day:r}:{day:r,minutes:Number(n[4])*60+Number(n[5])}}function O(e,n){if(!n.time)return e.day;let r=e.minutes??9*60;if(!n.instant)return`${e.day}T${y(Math.floor(r/60))}:${y(r%60)}`;let[,o,t,i]=Z.exec(e.day);return new Date(Number(o),Number(t)-1,Number(i),Math.floor(r/60),r%60).toISOString().replace(/\.\d{3}Z$/,"Z")}function H(e,n=new Date){let r=Intl.DateTimeFormat().resolvedOptions().timeZone??"UTC",o=r;try{o=new Intl.DateTimeFormat(e??b,{timeZoneName:"short"}).formatToParts(n).find(t=>t.type==="timeZoneName")?.value??r}catch{o=r}return{zone:r,short:o}}function G(e,n,r,o){let t=h(n);if(!t)return r;let i=e===void 0?void 0:h(e),a=r===void 0?void 0:h(r),d=u=>m(u.day)+(u.minutes??0)*6e4,c=(u,s)=>{let f=d(u)+s;return{day:M(f),...o.time?{minutes:Math.round(f%x/6e4)}:{}}};return i&&a?O(c(a,d(t)-d(i)),o):a&&d(a)>=d(t)?r:o.time?O(c(t,36e5),o):r}var K=/^(start|starts|startsAt|startsOn|startAt|begins|from|opens|checkIn)$/i,X=/^(end|ends|endsAt|endsOn|endAt|until|to|finish|finishes|closes|through|checkOut)$/i;function V(e,n={}){let r=(n.start&&e.includes(n.start)?n.start:void 0)??e.find(t=>K.test(t)),o=(n.end&&e.includes(n.end)?n.end:void 0)??e.find(t=>t!==r&&X.test(t));return r&&o?{start:r,end:o}:void 0}var q=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],J=["sun","mon","tue","wed","thu","fri","sat"],v="(jan(?:uary)?|feb(?:ruary)?|mar(?:ch)?|apr(?:il)?|may|june?|july?|aug(?:ust)?|sept?(?:ember)?|oct(?:ober)?|nov(?:ember)?|dec(?:ember)?)",C="(sun(?:day)?|mon(?:day)?|tue(?:s|sday)?|wed(?:nesday)?|thu(?:r|rs|rsday)?|fri(?:day)?|sat(?:urday)?)",Q=e=>q.indexOf(e.slice(0,3))+1,L=e=>e===void 0?void 0:e.length===2?2e3+Number(e):Number(e);function ee(e){try{let n=new Intl.DateTimeFormat(e,{month:"numeric",day:"numeric"}).formatToParts(0).map(r=>r.type);return n.indexOf("month")<n.indexOf("day")}catch{return!0}}function ne(e){let n=(t,i)=>({minutes:i,rest:`${e.slice(0,t.index)} ${e.slice(t.index+t[0].length)}`}),r=/\b(noon|midday)\b/.exec(e);if(r)return n(r,12*60);if(r=/\bmidnight\b/.exec(e),r)return n(r,0);if(r=/\b(\d{1,2})(?::(\d{2}))?\s*([ap])\.?m?\.?(?=\s|$)/.exec(e),r){let t=Number(r[1]),i=Number(r[2]??0);return t<1||t>12||i>59?{rest:e,bad:!0}:n(r,(t%12+(r[3]==="p"?12:0))*60+i)}if(r=/\b(\d{1,2}):(\d{2})\b/.exec(e),r){let t=Number(r[1]),i=Number(r[2]);return t>23||i>59?{rest:e,bad:!0}:n(r,t*60+i)}if(r=/\bat\s+(\d{1,2})\b/.exec(e),r){let t=Number(r[1]);return t>23?{rest:e,bad:!0}:n(r,(t>=1&&t<=7?t+12:t)*60)}let o=/\b(morning|afternoon|evening|tonight)\b/.exec(e);return o?{minutes:{morning:9,afternoon:15,evening:18,tonight:20}[o[1]]*60,rest:o[1]==="tonight"?`${e.slice(0,o.index)} today ${e.slice(o.index+o[0].length)}`:`${e.slice(0,o.index)} ${e.slice(o.index+o[0].length)}`}:{rest:e}}function te(e,n,r){let o=e.replace(/\b(on|at|the|of|this)\b/g," ").replace(/\s+/g," ").trim();if(o==="")return null;if(o==="today"||o==="now")return n;if(o==="tomorrow"||o==="tmrw"||o==="tmr")return g(n,1);if(o==="yesterday")return g(n,-1);if(o==="next week")return g(n,7);let t=/^in (\d{1,3}) (day|days|week|weeks)$/.exec(o);if(t)return g(n,Number(t[1])*(t[2].startsWith("week")?7:1));if(t=new RegExp(`^(next )?${C}$`).exec(o),t){let u=(J.indexOf(t[2].slice(0,3))-R(n)+7)%7;return g(n,t[1]&&u===0?7:u)}if(t=/^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(o),t)return l(Number(t[1]),Number(t[2]),Number(t[3]));let i=o.replace(new RegExp(`^${C} `),"");t=new RegExp(`^(\\d{1,2})(?:st|nd|rd|th)? ${v}(?: (\\d{4}))?$`).exec(i);let a=t?{date:t[1],month:t[2],year:t[3]}:void 0;t=new RegExp(`^${v} (\\d{1,2})(?:st|nd|rd|th)?(?: (\\d{4}))?$`).exec(i);let d=a??(t?{date:t[2],month:t[1],year:t[3]}:void 0);if(d)return z(n,L(d.year),Q(d.month),Number(d.date));if(t=/^(\d{1,2})[/.-](\d{1,2})(?:[/.-](\d{2}|\d{4}))?$/.exec(i),t){let[c,u]=[Number(t[1]),Number(t[2])],[s,f]=ee(r)?[c,u]:[u,c];return z(n,L(t[3]),s,f)}}function z(e,n,r,o){if(n!==void 0)return l(n,r,o);let t=Number(e.slice(0,4)),i=l(t,r,o);return i===void 0?l(t+1,r,o):m(e)-m(i)>183*x?l(t+1,r,o):i}function re(e,n){let r=e.toLowerCase().replace(/,/g," ").replace(/(\d{4}-\d{2}-\d{2})t(?=\d)/,"$1 ").replace(/\s+/g," ").trim();if(r==="")return;let o=ne(r);if(o.bad)return;let t=te(o.rest,n.today,n.locale??b);if(t===void 0||t===null&&o.minutes===void 0)return;let i=t??n.base?.day??n.today;return n.time?{day:i,minutes:o.minutes??n.base?.minutes??9*60}:{day:i}}var oe=e=>/^[A-Z]{3}$/.test(e??"");function U(e){let{format:n,unit:r,currency:o,locale:t}=e,i=oe(r),a=n==="money"||!n&&i,d=a?i?r:o:void 0;return{...a?{format:"money"}:n?{format:n}:{},...r&&!(a&&i)?{unit:r}:{},...d?{currency:d}:{},...t?{locale:t}:{}}}function $e(e){switch(e.format){case"money":return e.currency?`An amount of money in ${e.currency}: a plain number, 1250.5 for 1,250.50 ${e.currency}.`:"An amount of money, in no named currency: a plain number.";case"percent":return"A fraction said as a percent: 0.15 is 15%.";default:return e.unit?`A number of ${e.unit}.`:"A number."}}function B(e){let n=w(e)?.innerType;return n===void 0?e:B(n)}var ie={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ue=e=>(e?._zod?.def?.checks??[]).map(n=>n._zod?.def).filter(n=>n!==void 0);function _(e){let n=B(e),r=w(n),o=r?.type,t=ue(n);if(o==="enum")return{type:"choice",options:Object.keys(r?.entries??{})};let i=E(n);if(i)return i==="image"?{type:"file",image:!0}:{type:"file"};if(o==="boolean")return{type:"boolean"};if(o==="array"){let a=_(r?.element);return a.type==="unknown"?{type:"unknown"}:{type:"several",of:a}}if(o==="number"){let a,d,c;for(let u of t){u.check==="multiple_of"&&typeof u.value=="number"?c=u.value:u.check==="number_format"&&(u.format==="safeint"||u.format==="int32"||u.format==="uint32")&&(c??=1);let s=u.check==="number_format"&&u.format?ie[u.format]:void 0,f=s?s[0]:u.check==="greater_than"&&u.inclusive&&typeof u.value=="number"?u.value:void 0,A=s?s[1]:u.check==="less_than"&&u.inclusive&&typeof u.value=="number"?u.value:void 0;f!==void 0&&(a=a===void 0?f:Math.max(a,f)),A!==void 0&&(d=d===void 0?A:Math.min(d,A))}return{type:"number",...a===void 0?{}:{min:a},...d===void 0?{}:{max:d},...c===void 0?{}:{step:c},...T(n)==="duration"?{duration:!0}:{},...S(e)?{amount:U(S(e))}:{}}}if(o==="string"){if(t.some(s=>s.fn===k||s.format==="datetime")||r?.format==="datetime")return{type:"date",time:!0,instant:!0};let d=[r?.pattern,...t.map(s=>s.pattern)].filter(s=>s instanceof RegExp).map(s=>s.source);if(d.some(s=>s.includes("\\d{4}")))return d.some(s=>s.includes("\\d{2}:\\d{2}"))?{type:"date",time:!0}:{type:"date"};let c=t.some(s=>s.check==="max_length"&&typeof s.maximum=="number"&&s.maximum>500),u=T(n);return c?{type:"text",long:!0}:u==="phone"||u==="place"?{type:"text",holds:u}:{type:"text"}}return{type:"unknown"}}function ae(e,n){let r=e?.shape;return!r||!(n in r)?{type:"unknown"}:_(r[n])}function de(e){if(e===void 0||e==="web"||e.startsWith("ai:")||e.startsWith("app:"))return;if(e==="api")return"via the API";if(e==="cli")return"via the command line";let[n,...r]=e.split(":"),o=r.join(":");return(n==="mcp"||n==="view")&&o?`via ${o}`:n==="mcp"?"via an agent's tools":`via ${e}`}var Y=e=>{if(!e.currency)return{before:!0};try{let n=$(e.locale),r=new Intl.NumberFormat(n,{style:"currency",currency:e.currency}).formatToParts(1),o=r.findIndex(a=>a.type==="currency"),t=r.findIndex(a=>a.type==="integer"),i;try{i=new Intl.DisplayNames([n],{type:"currency"}).of(e.currency)}catch{}return{...o>=0?{symbol:r[o].value}:{},before:o<t,...i?{name:i}:{}}}catch{return{symbol:e.currency,before:!0}}};function se(e){let n=e.locale;if(e.format==="money"){let{symbol:r,before:o,name:t}=Y(e),i=p(1250,n,{minimumFractionDigits:2,maximumFractionDigits:2});return{...r?o?{prefix:r}:{suffix:r}:{},placeholder:i,hint:t?`in ${t}`:e.currency?`in ${e.currency}`:"an amount of money"}}return e.format==="percent"?{suffix:"%",placeholder:p(15,n),hint:"as a percent"}:{...e.unit?{suffix:e.unit}:{},placeholder:"",hint:e.unit?`in ${e.unit}`:"a number"}}function ce(e,n){return e===void 0||!Number.isFinite(e)?"":n.format==="money"?p(e,n.locale,Number.isInteger(e)?{maximumFractionDigits:0}:{minimumFractionDigits:2,maximumFractionDigits:2}):n.format==="percent"?p(e*100,n.locale,{maximumFractionDigits:4}):p(e,n.locale,{maximumFractionDigits:6})}function fe(e){try{let n=new Intl.NumberFormat($(e)).formatToParts(12345.6);return{group:n.find(r=>r.type==="group")?.value??",",decimal:n.find(r=>r.type==="decimal")?.value??"."}}catch{return{group:",",decimal:"."}}}function me(e,n){let{group:r,decimal:o}=fe(n),t=e.replace(/[\s  ']/g,"").replace(/[−–]/g,"-");if(o!=="."&&!t.includes(o)&&/^-?\d+\.\d{1,2}$/.test(t))return Number(t);if(r&&(t=t.split(r).join("")),o!=="."&&(t=t.replace(o,".")),!/^-?(\d+\.?\d*|\.\d+)$/.test(t))return;let i=Number(t);return Number.isFinite(i)?i:void 0}function le(e,n){let r=e.trim();if(r==="")return;let o=n?.format==="money"&&n.currency?Y(n).symbol:void 0,t=r;o&&(t=t.split(o).join("")),n?.currency&&(t=t.replace(new RegExp(n.currency,"gi"),"")),t=t.replace(/^[$€£¥₹]|[$€£¥₹]$/g,""),/%\s*$/.test(t)&&(t=t.replace(/%\s*$/,"")),n?.unit&&n.format!=="money"&&(t=t.replace(new RegExp(`\\s*${n.unit.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*$`),""));let a=me(t,n?.locale);if(a!==void 0)return n?.format==="percent"?a/100:a}export{U as a,$e as b,B as c,_ as d,ae as e,W as f,P as g,de as h,se as i,ce as j,le as k,I as l,j as m,h as n,O as o,H as p,G as q,V as r,re as s};
@@ -0,0 +1 @@
1
+ import{D as l,K as p,R as k,S as y,c}from"./chunk.3NDH3EDN.js";import"./chunk.63GXY2ME.js";import"./chunk.UGFDSE37.js";import{b as m}from"./chunk.67TPUXAY.js";import"./chunk.Y6ZNFQK3.js";import"./chunk.NRAYZY3X.js";import"./chunk.RIJUCHP4.js";import"./chunk.TAQ764IQ.js";import"./chunk.YIR7PPF3.js";import"./chunk.3HXN4BOY.js";import"./chunk.GYICGZMG.js";import"./chunk.UHUGOTUU.js";import"./chunk.47STJVRV.js";import"./chunk.EBGAYL32.js";import"./chunk.DAZ2VSRD.js";import"./chunk.J25KOSNW.js";import"./chunk.LR3VDXPI.js";import"./chunk.CWHRDBOF.js";import"./chunk.3K6YSVHC.js";import"./chunk.SHTJZ6UX.js";import"./chunk.MB7LKKUD.js";import"./chunk.WVUJXDXZ.js";import"./chunk.ULRW47RP.js";import"./chunk.PBSMLINK.js";import"./chunk.3TY5NFLY.js";import"./chunk.D75KC3LL.js";import"./chunk.FWTIUYXH.js";import"./chunk.MAF7C3VM.js";import"./chunk.GZHZLJBF.js";import"./chunk.XMC7YDWT.js";import"./chunk.6UGEYZAC.js";import"./chunk.OJGHDWI6.js";import"./chunk.B2GLDIAS.js";import"./chunk.6YCBYL2Y.js";import"./chunk.UGFJKSHU.js";import"./chunk.JOOQUWLT.js";import{F as S,G as s,H as d,Q as f,Z as g}from"./chunk.6QWV5MVH.js";import"./chunk.MNP4JI33.js";import{b as n}from"./chunk.AJZBJBMO.js";var u=n(S(),1);var t=n(f(),1);function D({context:a}){let r=l(),h=g(),[w]=(0,u.useState)(()=>s(null)),o=d(h?.seatTalk??w),P=()=>{(window.history.state?.idx??0)>0?r(-1):r("/")};return(0,t.jsxs)(k,{context:a,"data-testid":"draft-page",children:[(0,t.jsx)(y,{context:a,...o.draft?{"data-testid":"draft-title"}:{},children:o.draft?o.draft.title:"Nothing drawn"}),o.draft?(0,t.jsx)(m,{page:!0,go:e=>r(e.address),onPick:e=>{let i=a.store.graph.getNode(e);i&&r(c(a.store.schema,i.kind,e))},onDiscard:P}):(0,t.jsxs)("p",{style:{margin:0,color:"var(--graview-ink-muted)"},children:["Ask for a way of seeing \u2014 \u201Ca board of tasks by status\u201D \u2014 and it is drawn here."," ",(0,t.jsx)(p,{to:"/",style:{color:"var(--graview-accent)"},children:"Home \u2192"})]})]})}export{D as DraftPage};
@@ -0,0 +1,4 @@
1
+ var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as $t,f as Ht,g as mn}from"./chunk.YIR7PPF3.js";import{h as Fr}from"./chunk.EBGAYL32.js";import{e as Hr,p as Nn,q as Dr}from"./chunk.DAZ2VSRD.js";import{a as Pe,b as So,c as Zt,d as Wr,e as Mo}from"./chunk.MWGGV7DE.js";import{b as yn}from"./chunk.JQU5GEU3.js";import{a as $r}from"./chunk.HAIG6NVX.js";import{a as Cr,b as Nr,c as Br}from"./chunk.XANVHJQ4.js";import{b as Rr,d as Er}from"./chunk.UT6642FC.js";import{a as Or,b as xo,c as bo,f as wo,g as vo,h as ko,i as Lr,j as Xt,k as qt,o as Bt,p as Qt,q as Tr,r as Pr}from"./chunk.XMC7YDWT.js";import{a as Ar,b as Ir}from"./chunk.6UGEYZAC.js";import{A as Sr,f as fr,g as Ut,h as mr,i as yr,j as gr,k as pr,m as Cn,n as hn,o as fn,p as Kt,q as po,v as xr,w as br,x as wr,y as vr,z as kr}from"./chunk.OJGHDWI6.js";import{c as Mr}from"./chunk.UGFJKSHU.js";import{B as at,C as co,D as cn,F as Te,J as gt,Q as Ae,R as uo,V as ho,W as Pn,X as Pt,Y as pe,_ as Ct,a as _t,b as oo,c as ro,d as io,e as lr,f as cr,fa as zt,g as In,ha as hr,i as It,k as mt,l as ao,m as Tn,n as dn,oa as fo,pa as mo,q as so,qa as Nt,s as we,sa as yo,t as Oe,u as ur,v as ln,w as Le,wa as go,x as Tt,xa as un,y as yt,z as lo}from"./chunk.6QWV5MVH.js";import{$ as At,Kb as sn,Pc as ar,Sc as sr,W as rr,X as An,Xc as dr,Z as rn,_ as Gt,aa as an,cc as Be,ea as ir}from"./chunk.MNP4JI33.js";import{b as se}from"./chunk.AJZBJBMO.js";var jr={width:1200,height:760,focusSize:{width:1200,height:420},relationSize:{width:240,height:140},contextSize:{width:300,height:104},gap:16,unit:16};var Yr=(e,t)=>e?`${e.edgeKind}|${e.direction}`:`raised|${t}`,Dt=(e,t,n)=>`${co}${e}|${t}|${n}`;function Bn(e,t){let n=e.map(()=>0),r=e.map((i,l)=>({size:i,index:l})).sort((i,l)=>i.size-l.size||i.index-l.index),o=Math.max(t,e.length),a=e.length;for(let{size:i,index:l}of r){let c=Math.max(1,Math.floor(o/a));n[l]=Math.min(i,c),o-=n[l],a-=1}return n}function Eo(e){return Yr(e.via,e.node.kind)}function $n(e,t){let n=[],r=0;return e.forEach((o,a)=>{if(o<=0)return;if(n.length>0&&o<=r){for(let l=0;l<o;l++)n[n.length-1].push(a);r-=o;return}let i=o;for(;i>0;){let l=Math.min(t,i);n.push(Array.from({length:l},()=>a)),i-=l,r=t-l}}),n}function Oo(e,t,n){let r=Bn(e,t*n);for(;$n(r,t).length>n;){let o=-1;if(r.forEach((a,i)=>{a>1&&(o<0||a>r[o])&&(o=i)}),o<0)break;r[o]=r[o]-1}return r}function fa(e,t,n){let r=o=>[t.chosen?.has(o.id)?0:1,t.hits?.has(o.id)?0:1,t.flagged?.has(o.id)?0:1,-(t.touched?.get(o.id)??0),-n.neighbors(o.id).length];return e.map((o,a)=>({node:o,index:a,key:r(o)})).sort((o,a)=>{for(let i=0;i<o.key.length;i++)if(o.key[i]!==a.key[i])return o.key[i]-a.key[i];return o.index-a.index}).map(o=>o.node)}var ma=5,ya=(e,t)=>{for(let n=0;n<e.length;n++)if(e[n]!==t[n])return e[n]<t[n];return!1};function Vr(e,t,n){if(e.length===0||t<2)return;let r=e[0].kind,o={schema:n.schema,graph:n.graph,...n.today?{today:n.today}:{}},a=[];for(let l of Hr(n.schema,r).groups)if(l.key!==n.exclude)if(l.buckets)for(let c of["decade","year","month"])a.push({by:l.key,bucket:c});else a.push({by:l.key});let i;return a.forEach((l,c)=>{let s=Fr(e,{group:l},o).groups;if(s.length<2||s.length>t)return;let h=s.filter(w=>w.key!=="").reduce((w,f)=>w+f.nodes.length,0)/e.length;if(h<.5||s.some(w=>w.nodes.length>e.length*.75))return;let g=[-Math.round(h*100),Math.abs(s.length-ma),c];(!i||ya(g,i.score))&&(i={grouping:{by:l.by,...l.bucket?{bucket:l.bucket}:{},groups:s},score:g})}),i?.grouping}function Lo(e,t){let n=f=>({id:f.node.id,kind:f.node.kind,node:f.node,...f.via?{via:f.via}:{}});if(e.length<=t.budget)return e.map(n);let r={...t.relevance,chosen:new Set([...t.relevance?.chosen??[],...t.selection??[]])},o=new Map;for(let f of e){let x=Yr(f.via,f.node.kind),v=o.get(x);v?v.push(f):o.set(x,[f])}let a=[...o.entries()].map(([f,x])=>({key:f,run:x,via:x[0].via,kinds:[...new Set(x.map(v=>v.node.kind))],members:[],whole:!1,extra:0})),i=Bn(a.map(f=>f.run.length),t.budget);a.forEach((f,x)=>f.whole=f.run.length<=i[x]);let l=a.filter(f=>!f.whole),c=a.filter(f=>f.whole).reduce((f,x)=>f+x.run.length,0),d=Math.max(l.length,t.budget-c);for(let f of l){f.members=fa(f.run.map(v=>v.node),r,t.graph);let x=d-(l.length-1);f.kinds.length>1&&f.kinds.length<=x?f.byKind=!0:f.kinds.length===1&&(f.grouping=Vr(f.members,x,{schema:t.schema,graph:t.graph,...f.via?{exclude:f.via.edgeKind}:{},...t.today?{today:t.today}:{}}))}let s=f=>f.byKind?f.kinds.length:f.grouping?f.grouping.groups.length:1;for(;l.reduce((f,x)=>f+s(x),0)>d;){let f=[...l].filter(x=>s(x)>1).sort((x,v)=>s(v)-s(x))[0];if(!f)break;f.grouping=void 0,f.byKind=!1}d-=l.reduce((f,x)=>f+s(x),0);let u=f=>f.byKind?f.kinds.some(x=>t.expanded.has(Dt(x,f.key,"kind"))):f.grouping?.groups.some(x=>t.expanded.has(Dt(f.kinds[0],f.key,Ro(f.grouping,x.key)))),h=l.filter(f=>!f.grouping&&!f.byKind?!0:u(f)),g=Bn(h.map(f=>f.members.length),Math.max(0,d));h.forEach((f,x)=>f.extra=d>0?g[x]:0);let w=[];for(let f of a){let{key:x,via:v}=f;if(f.whole){w.push(...f.run.map(n));continue}let y=p=>({id:p.id,kind:p.kind,node:p,...v?{via:v}:{}}),E=new Map(f.run.map((p,S)=>[p.node.id,S])),I=(p,S,A)=>{let O=[...p.slice(0,S)].sort((G,Y)=>E.get(G.id)-E.get(Y.id));w.push(...O.map(y));let H=p.slice(S);if(H.length===0)return;let T=H[0].kind;w.push({id:Dt(T,x,A?`more:${A}`:"more"),kind:T,...v?{via:v}:{},aggregate:{kind:T,memberIds:H.map(G=>G.id),label:S>0?`${H.length} more ${t.plural(T).toLowerCase()}`:`${H.length} ${t.plural(T).toLowerCase()}`,opens:{in:"picture",focus:Le(T),within:A?{filter:A}:{}}}})},j=v&&t.focusId?`${v.edgeKind}:${t.focusId}`:void 0;if(f.byKind){let p=f.kinds.find(S=>t.expanded.has(Dt(S,x,"kind")));for(let S of f.kinds){let A=f.members.filter(O=>O.kind===S);if(S===p){let O=f.extra+1;A.length<=O?w.push(...A.map(y)):I(A,O-1,j);continue}w.push({id:Dt(S,x,"kind"),kind:S,...v?{via:v}:{},aggregate:{kind:S,memberIds:A.map(O=>O.id),label:t.plural(S),opens:{in:"place"}}})}continue}let F=f.grouping;if(!F){I(f.members,f.extra,j);continue}let ee=f.kinds[0],_=F.groups.find(p=>t.expanded.has(Dt(ee,x,Ro(F,p.key))));for(let p of F.groups){if(p===_){let S=f.members.filter(O=>p.nodes.includes(O)),A=f.extra+1;if(S.length<=A)w.push(...S.map(y));else{let O=p.key!==""&&!p.key.includes(",")&&!F.bucket,H=[j,O?`${F.by}:${p.key}`:void 0].filter(Boolean).join(",")||void 0;I(S,A-1,H)}continue}w.push({id:Dt(ee,x,Ro(F,p.key)),kind:ee,...v?{via:v}:{},aggregate:{kind:ee,memberIds:f.members.filter(S=>p.nodes.includes(S)).map(S=>S.id),label:p.label.charAt(0).toUpperCase()+p.label.slice(1),opens:{in:"place"}}})}}return w}var Ro=(e,t)=>`${e.by}${e.bucket?`:${e.bucket}`:""}=${t||"none"}`;function _r(e,t,n,r,o=1){let a=l=>String(l).length*7.4,i=e.length*8.6+6+a(t)+14+(n>0?22+a(n):0);return{width:Math.max(i,r?184:0)*o,height:(r?38:22)*o,short:{width:i*o,height:22*o}}}function Ft(e,t,n=6){return e.x<t.x+t.width+n&&t.x<e.x+e.width+n&&e.y<t.y+t.height+n&&t.y<e.y+e.height+n}var Ao=(e,t,n,r)=>{let o=Math.max(e.x,Math.min(t.x,e.x+e.width)),a=Math.max(e.y,Math.min(t.y,e.y+e.height));return Math.abs(o-t.x)/n+Math.abs(a-t.y)/r<.92},gn=4,Gr=.45;function Io(e,t,n,r={},o={}){let a={};for(let b of e)a[b.kind]=b.count;let i={x:(r.left??0)+8,y:(r.top??0)+8,width:n.width-(r.left??0)-(r.right??0)-16,height:n.height-(r.top??0)-(r.bottom??0)-16},l=o.avoid??[],c=o.tilt??.5,d=b=>b.nameplate??{width:120,height:34,short:{width:90,height:20}},s=b=>e.map(R=>{let L=b.get(R.kind);return{card:R,plot:L,center:Zt(L.col+L.side/2,L.row+L.side/2,1,c)}}),u=(b,R)=>{let L=1/0,M=-1/0,N=1/0,P=-1/0;for(let{card:B,plot:te,center:U}of b){let W=U.x*R,J=U.y*R,X=te.side*R/2,fe=B.opened>0?d(B).width:d(B).short.width;L=Math.min(L,W-Math.max(X+(B.count>12?30:0),fe/2)),M=Math.max(M,W+Math.max(X,fe/2)),N=Math.min(N,J-X*c-R*Gr),P=Math.max(P,J+X*c+gn+d(B).short.height)}return{minX:L,maxX:M,minY:N,maxY:P}},h=b=>{let R=4,L=160;for(let M=0;M<24;M++){let N=(R+L)/2,P=u(b,N);P.maxX-P.minX<=i.width&&P.maxY-P.minY<=i.height?R=N:L=N}return R},g=b=>{let R={...o.order?{order:o.order}:{},counts:a,...o.plots?{plots:o.plots}:{},pitch:b},L=So(t,R),M=So(t,{...R,upright:!0}),N=h(s(L)),P=h(s(M)),B=n.height>n.width&&P>=N?M:L;return{map:B,fitted:B===M?P:N}},w=[],f=new Map,x=0,v=(b,R={x:0,y:0})=>{let L=u(w,b),M=i.x+i.width/2-(L.minX+L.maxX)/2+R.x,N=i.y+i.height/2-(L.minY+L.maxY)/2+R.y;return{originX:M,originY:N,cell:b}},y=b=>{let{originX:R,originY:L,cell:M}=b,N=w.map(({center:te})=>te.y),P=Math.max(...N),B=Math.min(...N);return w.map(({card:te,plot:U,center:W})=>{let J=R+W.x*M,X=L+W.y*M,fe=U.side*M/2,ie=fe*c,ve=P===B?.5:(W.y-B)/(P-B);return{card:te,plot:U,x:J,y:X,halfW:fe,halfH:ie,depth:1-ve*.65}})},E=(b,R=!0)=>{let L=[];return[...b].sort((N,P)=>(P.card.weight??P.card.count)-(N.card.weight??N.card.count)||e.indexOf(N.card)-e.indexOf(P.card)).filter(N=>[d(N.card),d(N.card).short].some(P=>{let B=F(N,P),te=(!R||B.x>=0&&B.y>=0&&B.x+B.width<=n.width&&B.y+B.height<=n.height)&&!L.some(U=>Ft(B,U,4))&&!b.some(U=>U!==N&&Ao(B,U,U.halfW,U.halfH))&&!l.some(U=>Ft(B,U,0));return te&&L.push(B),te})).length},I=b=>b.card.marquee?{x:b.x-b.card.marquee.width/2,y:b.y+b.halfH+gn+d(b.card).height,width:b.card.marquee.width,height:b.card.marquee.height}:null,j=(b,R,L)=>L.some(M=>{if(M===R)return!1;let N=I(M);return N!==null&&Ft(b,N,4)}),F=(b,R,L="under")=>L==="aside"?{x:b.x+b.halfW+gn,y:b.y-R.height/2,width:R.width,height:R.height}:L==="above"?{x:b.x-R.width/2,y:b.y-b.halfH-gn-Gr*S.cell-R.height,width:R.width,height:R.height}:{x:b.x-R.width/2,y:b.y+b.halfH+gn,width:R.width,height:R.height},ee=b=>b.some(R=>l.some(L=>Ao(L,R,R.halfW,R.halfH)||Ft(L,F(R,d(R.card).short),0))),_=b=>b.every(R=>{let L=F(R,d(R.card).short);return R.x-R.halfW>=0&&R.x+R.halfW<=n.width&&R.y-R.halfH>=0&&L.x>=0&&L.x+L.width<=n.width&&L.y+L.height<=n.height}),p={pitch:Pe,said:-1};for(let b of[Pe,Pe+1,Pe+2,Pe+3,Pe+5,Pe+7]){({map:f,fitted:x}=g(b)),w=s(f);let R=E(y(v(x)));if(R>p.said&&(p={pitch:b,said:R}),R===e.length)break}(p.pitch!==Pe+7||p.said!==e.length)&&({map:f,fitted:x}=g(p.pitch),w=s(f));let S=v(x);if(l.length>0&&ee(y(S))){let b;for(let R=1;R>=.3&&!b;R-=.05){let L=x*R,M=Math.max(...l.map(P=>P.width))/2+L,N=Math.max(...l.map(P=>P.height))/2+L/2;for(let P of[0,.5,.75,1,1.25]){for(let[B,te]of[[1,0],[-1,0],[0,1],[0,-1],[1,1],[-1,1],[1,-1],[-1,-1]]){let U=v(L,{x:B*M*P,y:te*N*P}),W=y(U);if(!ee(W)&&_(W)){b=U;break}if(P===0)break}if(b)break}}b&&(S=b)}let A=(b,R)=>{let L={x:n.width/2,y:n.height/2};return{cell:b.cell*R,originX:L.x+(b.originX-L.x)*R,originY:L.y+(b.originY-L.y)*R}},O=1;if(E(y(S))<e.length){let b={said:E(y(S),!1),area:1/0,pitch:-1,by:1},R={map:f,shape:w,fitted:x,where:S};for(let M of[Pe,Pe+1,Pe+2,Pe+3,Pe+5,Pe+7]){({map:f,fitted:x}=g(M)),w=s(f);let N=v(x);for(let P=1;P<=3.001;P+=.1){let B=E(y(A(N,P)),!1),te=u(w,x*P),U=(te.maxX-te.minX)*(te.maxY-te.minY);if((B>b.said||B===b.said&&U<b.area)&&(b={said:B,area:U,pitch:M,by:P}),B===e.length)break}}b.pitch<0?{map:f,shape:w,fitted:x,where:S}=R:({map:f,fitted:x}=g(b.pitch),w=s(f),O=b.by,S=A(v(x),O));let L=y(S).filter(M=>o.keep?.includes(M.card.kind));if(L.length>0){let M=L.flatMap(W=>[{x:W.x-W.halfW,y:W.y-W.halfH,width:W.halfW*2,height:W.halfH*2},F(W,d(W.card))]),N=Math.min(...M.map(W=>W.x)),P=Math.max(...M.map(W=>W.x+W.width)),B=Math.min(...M.map(W=>W.y)),te=Math.max(...M.map(W=>W.y+W.height)),U=(W,J,X)=>J-W>X-16?X/2-(W+J)/2:W<8?8-W:J>X-8?X-8-J:0;S={...S,originX:S.originX+U(N,P,n.width),originY:S.originY+U(B,te,n.height)}}}let H=o.zoom&&o.zoom!==1?o.zoom:1;H!==1&&(S=A(S,H));let T=y(S),G=[],Y=new Map,V=new Map,k=[...T].sort((b,R)=>(R.card.weight??R.card.count)-(b.card.weight??b.card.count)||e.indexOf(b.card)-e.indexOf(R.card));for(let b of k){let R=[["full",d(b.card),"under"],["short",d(b.card).short,"under"]],L="none",M=b===k[0],N=(B,te)=>R.filter(([U])=>U.startsWith(te)).map(([U,W,J])=>[U,W,J,B]),P=M?[...N(!1,"full"),...N(!1,"short"),...N(!0,"full"),...N(!0,"short")]:R.map(([B,te,U])=>[B,te,U,!1]);for(let[B,te,U,W]of P){let J=F(b,te,U);if((H!==1||O!==1||J.x>=0&&J.y>=0&&J.x+J.width<=n.width&&J.y+J.height<=n.height)&&!G.some(ie=>Ft(J,ie,4))&&(W||!T.some(ie=>ie!==b&&Ao(J,ie,ie.halfW,ie.halfH)))&&!j(J,b,T)&&!l.some(ie=>Ft(J,ie,0))){L=B,G.push(J),V.set(b.card.id,J);break}}Y.set(b.card.id,L)}let $=T.map(b=>({id:b.card.id,x:b.x-b.halfW,y:b.y-b.halfH,width:b.halfW*2,height:b.halfH*2+(b.card.opened>0?Math.max(b.card.openedMin??0,b.card.opened):0),depth:b.depth,plot:b.plot,nameplate:Y.get(b.card.id)??"none"})),q=u(w,S.cell),z={cell:S.cell,originX:S.originX,originY:S.originY,pan:o.pan??{x:0,y:0},extent:{x:S.originX+q.minX,y:S.originY+q.minY,width:q.maxX-q.minX,height:q.maxY-q.minY},openedShare:1,...c!==.5?{tilt:c}:{},...V.size>0?{nameplates:T.flatMap(b=>{let R=V.get(b.card.id);return R?[{id:b.card.id,x:R.x-(b.x-b.halfW),y:R.y-(b.y-b.halfH),width:R.width,height:R.height}]:[]})}:{},...T.some(b=>b.card.marquee)?{showings:T.flatMap(b=>{let R=I(b);return R?[{id:b.card.id,x:R.x-(b.x-b.halfW),y:R.y-(b.y-b.halfH),width:R.width,height:R.height}]:[]})}:{}};return{placed:$,frame:z,map:f}}function pt(e){let{width:t,height:n}=e.visible??e,r={x:t*.45,y:n*.45};if(!e.city)return r;let{extent:o}=e.city,a=24;return{x:Math.max(r.x,o.x+o.width-t+a,-o.x+a),y:Math.max(r.y,o.y+o.height-n+a,-o.y+a)}}var Hn=48;function To(e){if(!e.city)return[];let{width:t,height:n}=e.visible??e,r=[];for(let o of e.nodes){if(!o.id.startsWith("kind:")||Math.round(o.plane)!==2)continue;let a=o.x+o.width/2,i=o.y+o.height/2,l=a<0?"left":a>t?"right":i<0?"top":i>n?"bottom":null;if(!l)continue;let c=l==="left"||l==="right",d=c?Math.max(0,Math.min(n,i)):Math.max(0,Math.min(t,a)),s=(g,w)=>g<w/4?w/4-g:g>w*3/4?w*3/4-g:0,u=(g,w)=>g<Hn?Hn-g:g>w-Hn?w-Hn-g:0,h=c?{x:s(a,t),y:u(i,n)}:{x:u(a,t),y:s(i,n)};r.push({id:o.id,kind:o.id.slice(5),side:l,along:d,by:h})}return r}function Po(e,t,n,r,o){return{x:e.x+(n.x-e.x-t.x-r.x)*(1-o),y:e.y+(n.y-e.y-t.y-r.y)*(1-o)}}var ga={rankOf:()=>{},parentOf:()=>{}};function zr(e,t){if(t.size===0)return ga;let n=e.kinds,r=new Map,o=(d,s)=>{d!==s&&((r.get(d)??r.set(d,new Set).get(d)).add(s),(r.get(s)??r.set(s,new Set).get(s)).add(d))};for(let d of n){let s=e.tryDefinition(d);if(s)for(let u of Object.values(s.edges??{})){let h=u.to==="*"?n:u.to;for(let g of h)o(d,g)}}let a=new Map,i=new Map,l=[...t].filter(d=>n.includes(d));for(let d of l)a.set(d,0);let c=0;for(;l.length>0;){c+=1;let d=[];for(let s of[...l].sort((u,h)=>n.indexOf(u)-n.indexOf(h)))for(let u of[...r.get(s)??[]].sort((h,g)=>n.indexOf(h)-n.indexOf(g)))a.has(u)||(a.set(u,c),c===2&&i.set(u,s),d.push(u));l=d}return{rankOf:d=>{let s=a.get(d);if(s!==0)return s===1?"primary":"secondary"},parentOf:d=>i.get(d)}}function Ur(e,t,n,r,o={}){if(n){let a=new Map;for(let i of e.allEdges()){if(r&&i.kind!==r)continue;let l=i.from===n.id?i.to:i.to===n.id?i.from:null;if(l===null||l===n.id)continue;let c=e.getNode(l);if(!c||a.has(l))continue;let d=i.from===n.id?"out":"in",s=d==="out"?n.kind:c.kind,u=pa(t,s,i.kind,d);a.set(l,{node:c,via:{edgeKind:i.kind,direction:d,...u?{description:u}:{}}})}if(a.size>0){let i=l=>`${l.via.edgeKind}|${l.via.description??""}`;return[...a.values()].sort((l,c)=>(i(l)<i(c)?-1:i(l)>i(c)?1:0)||at(l.node,c.node))}}if(n){let a=o[n.id]??[],i=new Set,l=[];for(let c of a){if(c===n.id||i.has(c))continue;let d=e.getNode(c);d&&(r&&r!=="judges"&&d.kind!==r||(i.add(c),l.push({node:d,via:{edgeKind:"judges",direction:"out",description:"what it finds wrong"}})))}if(l.length>0)return l.sort((c,d)=>at(c.node,d.node))}return r?e.allNodes().filter(a=>a.kind===r).sort(at).map(a=>({node:a})):[]}function pa(e,t,n,r){let a=e.tryDefinition(t)?.edges?.[n];return r==="out"?a?.description:a?.inverse}function Kr(e,t,n){let r=new Map,o=[...t.values()].sort((d,s)=>d.plane-s.plane);for(let d of o)for(let s of d.aggregate?.memberIds??[])!t.has(s)&&!r.has(s)&&r.set(s,d.id);let a=d=>t.get(d)??t.get(r.get(d)??""),i=new Map,l=new Map,c=new Map;for(let d of e.allEdges()){let s=a(d.from),u=a(d.to);if(!s||!u||s.id===u.id&&!(n.overview&&s.aggregate&&s.plane===2))continue;let h=`${d.kind}:${s.id}:${u.id}`,g=i.get(h);if(g){let w=`${d.from}
2
+ ${d.to}`,f=l.get(h);if(f.has(w))continue;if(f.add(w),c.get(h).push({from:d.from,to:d.to}),g.single){let{single:x,...v}=g;i.set(h,v)}continue}l.set(h,new Set([`${d.from}
3
+ ${d.to}`])),c.set(h,[{from:d.from,to:d.to}]),i.set(h,{id:h,kind:d.kind,from:s.id,to:u.id,edges:[{from:d.from,to:d.to}],single:{from:d.from,to:d.to},...s.id===u.id?{loop:!0}:{},x1:s.x+s.width/2,y1:s.y+s.height/2,x2:u.x+u.width/2,y2:u.y+u.height/2})}return[...i.values()].map(d=>({...d,edges:c.get(d.id)})).sort(at)}var qr=.85,Xr=60,Co=160;function xa(e,t,n,r,o,a=qr){let i=e*t.width+Math.max(0,e-1)*n,l=Math.max(n,(r-i)/2);return Array.from({length:e},(c,d)=>({x:l+d*(t.width+n),y:o,depth:a}))}function ba(e,t,n,r,o){let a=e*t.width+Math.max(0,e-1)*n,i=Math.max(n,(r-a)/2);return Array.from({length:e},(l,c)=>({x:i+c*(t.width+n),y:o}))}function Dn(e,t,n,r={}){let o={...jr,...r},a=Math.max(8,o.unit??16)/16,i=o.inset?.left??0,l=n.overview?Math.max(0,o.dock?.right??0):0,c=n.overview?Math.max(0,o.dock?.bottom??0):0,d=o.width-l-i-(o.inset?.right??0),s=[],u=new Map,h=m=>n.past===!0||rr(t.tryDefinition(m.kind),m,o.today),g=new Set(r.hiddenKinds??[]),w=m=>!g.has(m.kind),f=n.focusId?yt(n.focusId).filter(m=>t.tryDefinition(m)!==void 0).filter(m=>!g.has(m)):[];n.focusId&&yt(n.focusId).length>0&&f.length===0&&(n={...n,focusId:null});let x=n.focusId?e.getNode(n.focusId):void 0;x&&!w(x)&&(n={...n,focusId:null},f=[]);let v=f.length>0?[...e.allNodes()].filter(m=>f.includes(m.kind)).sort(at):[],y=v.filter(w).filter(h),E=v.length-y.length,I=n.focusId&&f.length===0?e.getNode(n.focusId):void 0,j=n.zoom===!0&&!n.overview&&n.focusId!==null,F=Math.max(56,o.height*.062),ee=Math.min(o.height*.895,o.height-F),_=j?I!==void 0?{focusY:o.height*.03,focusH:o.height*.58,relationY:o.height*.645,relationH:o.height*.2,contextY:ee,contextH:F}:{focusY:o.height*.03,focusH:o.height*.71,relationY:o.height*.765,relationH:o.height*.1,contextY:ee,contextH:F}:I===void 0?{focusY:o.height*.045,focusH:o.height*.62,relationY:o.height*.68,relationH:o.height*.2,contextY:o.height*.918,contextH:o.height*.082}:(()=>{let m=o.height,D=m*.04,K=Math.max(m*.42,Math.min(m*.56,300)),ne=D+K+m*.06;return{focusY:D,focusH:K,relationY:ne,relationH:Math.max(m*.12,m*.878-m*.068-ne),contextY:m*.878,contextH:m*.092}})(),p=Math.min(o.headroom??0,_.focusY+_.focusH*.2),S=p>_.focusY?{..._,focusY:p,focusH:_.focusH-(p-_.focusY)}:_,A=m=>Math.min(o.gap*m,Math.round(d*.1)),O=j?Math.min(880,d-A(5)):Math.min(700,d-A(6)),H=j?d-A(5):Math.min(o.focusSize.width,d-A(6)),T=(m,D,K)=>({width:m===0?D:Math.min(D,(d-o.gap*(m+1))/m),height:K}),G=(m,D,K)=>{let ne=T(m,D,K),be=Math.min(D,Co*a,d-o.gap*2);return ne.width>=be?ne:{width:be,height:K}},Y=m=>Math.max(1,Math.floor((d-o.gap)/(Math.min(m,Co*a,d-o.gap*2)+o.gap))),V=new Set(n.expanded),k=n.overview?[]:Ur(e,t,I,n.relation,o.judged).filter(m=>w(m.node)).filter(m=>h(m.node)),$=n.overview?0:Math.max(0,Xr*a-S.contextH),q=k.length>0?S.focusH:S.contextY-S.focusY-o.gap*2-$,z=H,b=o.height,R=Math.min(d*.5/z,o.height*.48/b),L=z*R,M=b*R,N=new Set(r.plainGroups??[]),P=n.overview&&!I&&f.length>0&&n.focusId!==null,B=P&&f.length>0&&f.every(m=>N.has(m));if(P)for(let m of f)B&&r.besideTheMap!==!0?V.add(we(m)):V.delete(we(m));let te=P&&!B&&f.length===1?f[0]:void 0,U=te!==void 0&&(r.screens?.[te]?.length??0)>0,W,J=n.overview===!0&&I!==void 0&&r.besideTheMap===!0;n.overview&&(I||f.length>0)&&n.focusId&&!B&&!U&&!(P&&r.besideTheMap===!0)&&!J?(W={x:i+(d-L)/2,y:o.height*.53-M/2,width:L,height:M},on({id:n.focusId,kind:I?I.kind:f[0],plane:0,x:W.x,y:W.y,width:L,height:M,natural:{width:z,height:b},...I?{}:{aggregate:{kind:f.join("+"),memberIds:y.map(m=>m.id),label:r.plurals?.[n.focusId]??f.map(m=>At(t,m)).join(" and "),...E>0?{retired:E}:{}}}})):n.overview||(I?on({id:I.id,kind:I.kind,plane:0,x:i+(d-O)/2,y:S.focusY,width:O,height:q}):f.length>0&&n.focusId&&on({id:n.focusId,kind:f[0],plane:0,x:i+(d-H)/2,y:S.focusY,width:H,height:q,aggregate:{kind:f.join("+"),memberIds:y.map(m=>m.id),label:r.plurals?.[n.focusId]??f.map(m=>At(t,m)).join(" and "),...E>0?{retired:E}:{}}}));let X=26,fe=52,ie=22,ve=Math.round(o.relationSize.width*.75),ke=Math.max(1,Math.floor((d-o.gap)/(ve+o.gap))),$e=o.unit/16,ae=Math.max(2,Math.floor((S.relationH+o.gap)/(X*$e+o.gap))),Se=k.length>ke*ae,ot={schema:t,graph:e,focusId:I?.id,expanded:V,...o.relevance?{relevance:o.relevance}:{},...n.selection?{selection:n.selection}:{},plural:m=>At(t,m),...o.today?{today:o.today}:{}},oe=Se?Math.max(o.gap,ie*$e):o.gap,Ge,Ze;if(!Se)Ge=k.map(m=>({id:m.node.id,kind:m.node.kind,node:m.node,...m.via?{via:m.via}:{}})),Ze=Array.from({length:Math.max(1,Math.ceil(Ge.length/ke))},(m,D)=>Array.from({length:Math.min(ke,Ge.length-D*ke)},(K,ne)=>D*ke+ne));else{let m=Math.max(1,Math.floor((S.relationH+oe)/(fe*$e+oe))),D=new Map;for(let me of k){let Ee=Eo(me),Lt=D.get(Ee);Lt?Lt.push(me):D.set(Ee,[me])}let K=Oo([...D.values()].map(me=>me.length),ke,m),ne=[...D.values()].map((me,Ee)=>Lo(me,{...ot,budget:K[Ee]}));Ge=ne.flat();let be=ne.map((me,Ee)=>ne.slice(0,Ee).reduce((Lt,no)=>Lt+no.length,0)),Ke=ne.map(()=>0);Ze=$n(ne.map(me=>me.length),ke).map(me=>me.map(Ee=>be[Ee]+Ke[Ee]++))}let kt=Ze.length,Je=kt===1?S.relationH:(S.relationH-oe*(kt-1))/kt,Ce=T(Math.max(...Ze.map(m=>m.length),1),Ge.length<=2?Math.round(o.relationSize.width*1.35):o.relationSize.width,Je),lt=[];Ze.forEach((m,D)=>{let K=ba(m.length,Ce,o.gap,d,S.relationY+D*(Je+oe));m.forEach((ne,be)=>lt[ne]={...K[be],x:K[be].x+i})}),Ge.forEach((m,D)=>{let K=lt[D];on({id:m.id,kind:m.kind,plane:1,x:K.x,y:K.y,width:Ce.width,height:Ce.height,...m.via?{via:m.via}:{},...m.aggregate?{aggregate:m.aggregate}:{},...Se&&!m.aggregate?{compact:!0}:{}})});let rt=new Set(u.keys());for(let m of y)rt.add(m.id);let We=new Map;for(let m of e.allNodes()){let D=We.get(m.kind);D?D.push(m):We.set(m.kind,[m])}let Ne=new Set(f.length>0?f:I?[I.kind]:[]),je=[];for(let m of t.kinds){if(g.has(m))continue;let D=We.get(m)??[],K=D.filter(h);je.push({id:we(m),kind:m,members:K.sort(at),retired:D.length-K.length,...Ne.has(m)?{focused:!0}:{}})}for(let m of je)m.kind===n.relation&&(m.raised=!0);je.sort(at);let _e=zr(t,Ne),ze=!n.overview&&t.kinds.some(m=>_e.rankOf(m)==="primary"),Ye=[];for(let m of je)if(!n.overview&&V.has(m.id)&&m.members.length>0)for(let D of m.members)Ye.push({id:D.id,kind:D.kind});else{let D=ze?_e.rankOf(m.kind):void 0,K=D==="secondary"?_e.parentOf(m.kind):void 0;Ye.push({id:m.id,kind:m.kind,...m.raised?{raised:!0}:{},...m.focused?{focused:!0}:{},...n.overview&&V.has(m.id)?{opened:!0}:{},...D?{rank:D}:{},...K&&!V.has(we(K))?{nestedUnder:we(K)}:{},aggregate:{kind:m.kind,memberIds:m.members.map(ne=>ne.id),label:r.plurals?.[m.kind]??At(t,m.kind),...m.retired>0?{retired:m.retired}:{}}})}let ct=2;if(Ye.length<=Y((j?240:o.contextSize.width)*a))for(let m of Ye)delete m.nestedUnder;let ut=new Map;for(let m of Ye){if(m.nestedUnder===void 0)continue;let D=ut.get(m.nestedUnder)??0;D>=ct?delete m.nestedUnder:ut.set(m.nestedUnder,D+1)}let et=Ye.filter(m=>m.nestedUnder!==void 0),re=Ye.filter(m=>m.nestedUnder===void 0),Me=Y((j?240:o.contextSize.width)*a),it=!n.overview&&re.length>Me,Mt=Math.max(0,Me-1),ht=m=>m.focused?0:m.raised?1:2,ft=new Set([...re].map((m,D)=>({item:m,at:D})).sort((m,D)=>ht(m.item)-ht(D.item)||m.at-D.at).slice(0,Mt).map(({item:m})=>m.id)),Ie=new Set(it?re.filter(m=>!ft.has(m.id)).map(m=>m.id):[]),nn=et.filter(m=>!Ie.has(m.nestedUnder)),Rn=et.filter(m=>Ie.has(m.nestedUnder)),Rt=it?[...re.filter(m=>ft.has(m.id)),{id:ur,kind:"",beyond:[...re.filter(m=>Ie.has(m.id)),...Rn].map(m=>m.kind)}]:re,Ue=n.overview?{width:Math.min(220,d/6.5),height:Math.min(92,o.height*.125)}:G(Rt.length,(j?240:o.contextSize.width)*a,S.contextH),C=o.relevance?.flagged,he=(m,D)=>{let K=Mo(t,m);if(!K)return{};let ne=K.values.map(()=>0),be=0;for(let Ke of D){let me=K.values.indexOf(e.getNode(Ke)?.[K.field]);me<0?be++:ne[me]++}return{states:{field:K.field,values:[...K.values.map((Ke,me)=>({value:Ke,tier:K.tiers[me],count:ne[me]})),...be>0?[{value:null,tier:"waiting",count:be}]:[]]}}},ce=n.overview?Io(Rt.map(m=>{let D=m.aggregate?.memberIds??[],K=C?D.filter(ne=>C.has(ne)).length:0;return{id:m.id,kind:m.kind,count:D.length,opened:V.has(m.id)?qt(Xt(D.length))*a:0,openedMin:V.has(m.id)?qt(Math.min(ko,Xt(D.length)))*a:0,nameplate:_r(m.aggregate?.label??At(t,m.kind),D.length,K,Mo(t,m.kind)!==void 0,a),weight:K*1e3+D.length,...f.includes(m.kind)&&(r.screens?.[m.kind]?.length??0)>0?{marquee:{width:bo+12,height:wo(r.screens[m.kind].map(ne=>ne.title),bo,r.nameWidth)+8}}:{}}}),t,{width:o.width-l,height:o.height-c},o.chrome?{...o.inset,right:Math.min(o.inset?.right??0,8)}:o.inset??{},{...o.cityOrder?{order:o.cityOrder}:{},...o.plots?{plots:o.plots}:{},...r.cityZoom&&r.cityZoom!==1?{zoom:r.cityZoom}:{},keep:[...n.selection??[],...n.focusId?[n.focusId]:[]].flatMap(m=>m.startsWith("kind:")?[m.slice(5)]:m.startsWith("aggregate:")&&!m.includes("|")?[m.slice(10)]:J&&m===I?.id?[I.kind]:[]),...r.tilt!==void 0?{tilt:r.tilt}:{},pan:{x:n.pan?.x??0,y:n.pan?.y??0},...W||o.chrome?.length?{avoid:[...W?[W]:[],...o.chrome??[]]}:{}}):null,Re=new Map(ce?.placed.map(m=>[m.id,m.plot])??[]),tt=new Map(ce?.placed.map(m=>[m.id,m.nameplate])??[]),Et=ce?ce.placed.map(({x:m,y:D,depth:K,width:ne,height:be})=>({x:m,y:D,depth:K,width:ne,height:be})):xa(Rt.length,Ue,o.gap,d,S.contextY,j?.97:qr).map(m=>({...m,x:m.x+i})),En=.74,Ot=.8,Zn=52*a,Jn=86*a,Vt=(m,D)=>Math.min(1,m+(1-m)*D),eo=new Map;Rt.forEach((m,D)=>{let K=Et[D],ne=K.width??Ue.width,be=K.height??Ue.height,Ke=m.rank==="secondary"?En:1,me=ce?ne:Math.max(Math.min(ne,Co*a),ne*Ke),Ee=ce?be:Math.max(Xr*a,be*Ke);eo.set(m.id,{x:K.x+(ne-me)/2,y:K.y+(be-Ee),depth:m.rank==="secondary"?Vt(K.depth,.5):K.depth,width:me,height:Ee})});let On=[],Ln=Et[Et.length-1],to=new Map;for(let m of nn)to.set(m.nestedUnder,(to.get(m.nestedUnder)??0)+1);let or=new Map;for(let m of nn){let D=eo.get(m.nestedUnder);if(D){let K=to.get(m.nestedUnder)??1,ne=or.get(m.nestedUnder)??0;or.set(m.nestedUnder,ne+1);let be=.98,Ke=Ue.width*Ot,me=Math.max(Jn,Math.min(Ke,D.width/(be*(K-1)+1))),Ee=Math.max(Zn,Ue.height*Ot*(me/Ke)),Lt=me*be,no=(K-1)*Lt+me;On.push({...m,x:D.x+(D.width-no)/2+ne*Lt,y:Math.max(0,D.y-Ee+Math.min(Ee*.5,16)),width:me,height:Ee,depth:Vt(D.depth,.8)})}else if(Ln){let K=Ue.width*Ot,ne=Ue.height*Ot;On.push({...m,x:Ln.x,y:Ln.y,width:K,height:ne,depth:Vt(Ln.depth??1,.8)})}}for(let m of Rt)On.push({...m,...eo.get(m.id)});return On.forEach(m=>{on({id:m.id,kind:m.kind,plane:2,x:m.x,y:m.y,width:m.width,height:m.height,...m.aggregate?{aggregate:m.aggregate}:{},...m.raised?{raised:!0}:{},...m.focused?{focused:!0}:{},...m.opened?{opened:!0}:{},...m.opened?{openedRows:Math.max(1,Math.floor((Math.max(qt(Math.min(ko,Xt(m.aggregate?.memberIds.length??0))),qt(Xt(m.aggregate?.memberIds.length??0))*(ce?.frame.openedShare??1))-Lr)/vo))}:{},...m.rank?{rank:m.rank}:{},...m.nestedUnder?{nestedUnder:m.nestedUnder}:{},...m.beyond?{beyond:m.beyond}:{},...Re.has(m.id)?{plot:Re.get(m.id)}:{},...tt.has(m.id)?{nameplate:tt.get(m.id)}:{},...ce&&m.aggregate?he(m.kind,m.aggregate.memberIds):{},depth:m.depth})}),{nodes:s,connectors:Kr(e,u,n),width:o.width,height:o.height,...ce?{city:ce.frame}:{},...l>0||c>0?{visible:{width:o.width-l,height:o.height-c}}:{}};function on(m){let D=n.overview&&Oe(m.id)!==null?void 0:n.pins[m.id],K=D?{...m,x:D.x,y:D.y,pinned:!0}:{...m,pinned:!1},ne=n.pan?{...K,x:K.x+n.pan.x,y:K.y+n.pan.y}:K;s.push(ne),u.set(ne.id,ne)}}function No(e,t,n){let r=e.nodes.find(l=>l.id===t);if(!r||r.screenOf!==void 0)return null;let o={...r,x:n.x,y:n.y,pinned:!0},a=o.x+o.width/2,i=o.y+o.height/2;return{...e,nodes:e.nodes.map(l=>l.id===t?o:l),connectors:e.connectors.map(l=>l.from===t?{...l,x1:a,y1:i}:l.to===t?{...l,x2:a,y2:i}:l)}}function Bo(e,t){return t.x===0&&t.y===0?e:{...e,nodes:e.nodes.map(n=>({...n,x:n.x+t.x,y:n.y+t.y})),connectors:e.connectors.map(n=>({...n,x1:n.x1+t.x,y1:n.y1+t.y,x2:n.x2+t.x,y2:n.y2+t.y})),...e.city?{city:{...e.city,pan:{x:t.x,y:t.y}}}:{}}}var xe=(e,t,n)=>e+(t-e)*n;function Qr(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}var Zr=new WeakMap;function wa(e){let t=Zr.get(e);if(t)return t;let n=new Map,r=new Map;for(let o of e.nodes){n.set(o.id,o);for(let a of o.aggregate?.memberIds??[]){let i=r.get(a);i?i.push(o):r.set(a,[o])}}return t={byId:n,groupsOf:r},Zr.set(e,t),t}var Jr=new WeakMap;function ei(e,t){let n=Jr.get(t);if(n||Jr.set(t,n=new WeakMap),n.has(e))return n.get(e);let r=va(e,t);return n.set(e,r),r}function va(e,t){let{byId:n,groupsOf:r}=wa(t);if(e.screenOf!==void 0){let i=n.get(we(e.screenOf));if(i)return{...e,x:i.x,y:i.y,width:i.width,height:i.height}}if(Tt(e.id)||Oe(e.id)!==null){let i=(e.aggregate?.memberIds??[]).map(s=>n.get(s)).filter(s=>s!==void 0);if(i.length===0)return null;let l=i.map(Qr),c=l.reduce((s,u)=>s+u.x,0)/l.length,d=l.reduce((s,u)=>s+u.y,0)/l.length;return{...e,x:c-e.width/2,y:d-e.height/2}}let o=r.get(e.id)?.find(i=>i.id===we(e.kind)||i.id===Le(e.kind));if(!o)return null;let a=Qr(o);return{...e,x:a.x-e.width/2,y:a.y-e.height/2}}function Wt(e,t,n){let r=Math.max(0,Math.min(1,n)),o=new Map(e.nodes.map(s=>[s.id,s])),a=new Map(t.nodes.map(s=>[s.id,s])),i=[];for(let[s,u]of o){let h=a.get(s);if(h){i.push($o(u,h,r,1));continue}let g=ei(u,t)??u;i.push($o(u,g,r,1-r))}for(let[s,u]of a){if(o.has(s))continue;let h=ei(u,e)??u;i.push($o(h,u,r,r))}let l=new Map(e.connectors.map(s=>[s.id,s])),c=new Map(t.connectors.map(s=>[s.id,s])),d=[];for(let[s,u]of l){let h=c.get(s);d.push(h?{...ka(u,h,r),opacity:1}:{...u,opacity:1-r})}for(let[s,u]of c)l.has(s)||d.push({...u,opacity:r});return{nodes:i.filter(s=>s.opacity>0).sort((s,u)=>s.id<u.id?-1:s.id>u.id?1:0),connectors:d.filter(s=>s.opacity>0).sort((s,u)=>s.id<u.id?-1:s.id>u.id?1:0),width:xe(e.width,t.width,r),height:xe(e.height,t.height,r),t:r,...ti(e.city,t.city,r)?{city:ti(e.city,t.city,r)}:{}}}function ti(e,t,n){return e?t?{cell:xe(e.cell,t.cell,n),...e.tilt!==void 0||t.tilt!==void 0?{tilt:xe(e.tilt??.5,t.tilt??.5,n)}:{},originX:xe(e.originX,t.originX,n),originY:xe(e.originY,t.originY,n),pan:{x:xe(e.pan.x,t.pan.x,n),y:xe(e.pan.y,t.pan.y,n)},extent:{x:xe(e.extent.x,t.extent.x,n),y:xe(e.extent.y,t.extent.y,n),width:xe(e.extent.width,t.extent.width,n),height:xe(e.extent.height,t.extent.height,n)}}:e:t}function $o(e,t,n,r){return{id:t.id,kind:t.kind,plane:xe(e.plane,t.plane,n),x:xe(e.x,t.x,n),y:xe(e.y,t.y,n),width:xe(e.width,t.width,n),height:xe(e.height,t.height,n),pinned:t.pinned,opacity:r,...t.aggregate?{aggregate:t.aggregate}:{},...t.via?{via:t.via}:{},...t.raised?{raised:!0}:{},...t.focused?{focused:!0}:{},...t.opened?{opened:!0}:{},...t.openedRows!==void 0?{openedRows:t.openedRows}:{},...t.compact?{compact:!0}:{},...t.rank?{rank:t.rank}:{},...t.nestedUnder?{nestedUnder:t.nestedUnder}:{},...t.beyond?{beyond:t.beyond}:{},...t.plot?{plot:t.plot}:{},...t.nameplate?{nameplate:t.nameplate}:{},...t.states?{states:t.states}:{},...t.screenOf?{screenOf:t.screenOf}:{},...t.depth===void 0?{}:{depth:xe(e.depth??1,t.depth,n)},...t.natural?{natural:t.natural}:{}}}function ka(e,t,n){return{...t,x1:xe(e.x1,t.x1,n),y1:xe(e.y1,t.y1,n),x2:xe(e.x2,t.x2,n),y2:xe(e.y2,t.y2,n)}}function Fn(e){let t=Math.max(0,Math.min(1,e));return t<.5?4*t*t*t:1-(-2*t+2)**3/2}function Sa(e,t){let n=[];for(let o=0;o<e.length;o+=1){let a=e[o],i=e[(o+1)%e.length];if(a.y===i.y)continue;let l=Math.min(a.y,i.y),c=Math.max(a.y,i.y);t<l||t>=c||n.push(a.x+(t-a.y)/(i.y-a.y)*(i.x-a.x))}n.sort((o,a)=>o-a);let r={x0:0,x1:0};for(let o=0;o+1<n.length;o+=2){let a={x0:n[o],x1:n[o+1]};a.x1-a.x0>r.x1-r.x0&&(r=a)}return r}function Ma(e){let t=1/0,n=-1/0;for(let r of e)r.y<t&&(t=r.y),r.y>n&&(n=r.y);return{top:t,bottom:n}}function Ra(e){let t=0;for(let n=0;n<e.length;n+=1){let r=e[n],o=e[(n+1)%e.length];t+=r.x*o.y-o.x*r.y}return Math.abs(t)/2}function Ea(e){let t=0,n=0,r=0;for(let o=0;o<e.length;o+=1){let a=e[o],i=e[(o+1)%e.length],l=a.x*i.y-i.x*a.y;t+=l,n+=(a.x+i.x)*l,r+=(a.y+i.y)*l}if(Math.abs(t)<1e-9){let o=e.reduce((a,i)=>({x:a.x+i.x,y:a.y+i.y}),{x:0,y:0});return{x:o.x/e.length,y:o.y/e.length}}return{x:n/(3*t),y:r/(3*t)}}function Oa(e,t){let{room:n,height:r,size:o,floor:a,measure:i=xo,lines:l=2}=t,c=(f,x)=>f.every(v=>i(v,x)<=n)&&f.length*x*1.15<=r;if(c([e],o))return{lines:[e],fontSize:o,whole:!0};let d=e.split(/\s+/);if(l>1&&d.length>1){let f=1,x=1/0,v=0;for(let E=0;E<d.length-1;E+=1){v+=d[E].length+1;let I=Math.abs(v-e.length/2);I<x&&(x=I,f=E+1)}let y=[d.slice(0,f).join(" "),d.slice(f).join(" ")];if(c(y,o))return{lines:y,fontSize:o,whole:!0};for(let E=o;E>=a;E-=o*.06)if(c(y,E))return{lines:y,fontSize:E,whole:!0}}for(let f=o;f>=a;f-=o*.06)if(c([e],f))return{lines:[e],fontSize:f,whole:!0};let s=i(e,a)/Math.max(1,e.length),u=Math.floor(n/s)-1;if(u<4||a*1.15>r)return null;let h=e.slice(0,u),g=h.lastIndexOf(" ");return{lines:[`${g>3?h.slice(0,g):h}\u2026`],fontSize:a,whole:!1}}var La=(e,t)=>e.x0<t.x1&&t.x0<e.x1&&e.y0<t.y1&&t.y0<e.y1;var Q=se(Te(),1);var xt=se(Te(),1);function ni(e){let[t,n]=(0,xt.useState)(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(e).matches);return(0,xt.useEffect)(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;let r=window.matchMedia(e),o=()=>n(r.matches);return o(),r.addEventListener("change",o),()=>r.removeEventListener("change",o)},[e]),t}function Aa(){let e=()=>typeof document>"u"?null:document.documentElement.getAttribute("data-graview-motion"),[t,n]=(0,xt.useState)(e);return(0,xt.useEffect)(()=>{if(typeof document>"u"||typeof MutationObserver>"u")return;let r=new MutationObserver(()=>n(e()));return r.observe(document.documentElement,{attributes:!0,attributeFilter:["data-graview-motion"]}),n(e()),()=>r.disconnect()},[]),t}function oi(e){let t=ni("(prefers-reduced-motion: reduce)"),n=ni("(prefers-reduced-transparency: reduce)"),r=Aa();return kr({off:!e,reducedMotion:r==="reduce"||r!=="full"&&t,reducedTransparency:n})}var Ia=xr*1.5,Ta=30;function ri(e,t){let[n,r]=(0,xt.useState)(!1),o=e&&!n;return(0,xt.useEffect)(()=>{if(!o||!t||typeof requestAnimationFrame>"u")return;let a=[],i=0,l=0,c=d=>{if(i>0&&a.push(d-i),i=d,a.length>=Ta){if(!Sr(a,Ia)){r(!0);return}a.length=0}l=requestAnimationFrame(c)};return l=requestAnimationFrame(c),()=>cancelAnimationFrame(l)},[o,t]),o}var He=se(Te(),1);var Pa=520;function Ca(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function ii(e,t={}){let n=t.duration??Pa,r=(t.enabled??!0)&&!Ca(),o=(0,He.useRef)(e),[a,i]=(0,He.useState)(()=>Wt(e,e,1)),l=(0,He.useRef)(a),c=(0,He.useRef)(null),d=(0,He.useRef)(null);return(0,He.useEffect)(()=>{if(!r||typeof requestAnimationFrame>"u"){o.current=e;let x=Wt(e,e,1);if(l.current=x,i(x),typeof requestAnimationFrame>"u")return;let v=requestAnimationFrame(()=>{let y=Wt(e,e,1);l.current=y,i(y)});return()=>cancelAnimationFrame(v)}let s=performance.now(),h=d.current!==null&&l.current.t<1&&s-d.current<n?d.current:s;d.current=h;let g=Fn(Math.min(1,(s-h)/n)),w=o.current,f=x=>{let v=Math.min(1,(x-h)/n),y=g>=1?1:(Fn(v)-g)/(1-g),E=Wt(w,e,Math.max(0,y));l.current=E,i(E),v<1?c.current=requestAnimationFrame(f):(d.current=null,o.current=e,c.current=requestAnimationFrame(()=>{let I=Wt(e,e,1);l.current=I,i(I),c.current=null}))};return c.current=requestAnimationFrame(f),()=>{c.current!==null&&cancelAnimationFrame(c.current);let x=l.current;o.current={...e,...x.city?{city:x.city}:{},nodes:x.nodes.map(v=>({...v,plane:Math.round(v.plane)})),connectors:x.connectors}}},[e,n,r]),a}function ai(e=1100){let{store:t}=pe(),[n,r]=(0,He.useState)(()=>new Set);return(0,He.useEffect)(()=>{let o=null,a=t.subscribe(i=>{r(new Set(i.touched)),o&&clearTimeout(o),o=setTimeout(()=>r(new Set),e)});return()=>{a(),o&&clearTimeout(o)}},[t,e]),n}var Na={marks:new Map,acts:[]};function si(e=4e3){let{store:t}=pe(),[n,r]=(0,He.useState)(Na);return(0,He.useEffect)(()=>{let o=null,a=t.subscribe((i,l)=>{r(c=>{let d=new Map(c.marks),s=[...c.acts];for(let u of l){if(u.undoes!==void 0){let w=s.find(x=>x.batch===u.undoes||x.wrote.length>0),f=s.filter(x=>u.writes.some(v=>x.wrote.includes(v)));for(let x of f.length>0?f:w?[w]:[]){for(let v of x.wrote)d.delete(v);s=s.filter(v=>v.batch!==x.batch)}continue}if(u.author.kind!=="agent")continue;let h=u.author.id??"the seat";for(let w of u.writes)d.set(w,h);s.find(w=>w.batch===u.batch)?s=s.map(w=>w.batch===u.batch?{...w,wrote:[...new Set([...w.wrote,...u.writes])]}:w):s=[{batch:u.batch,who:h,intent:u.batchIntent??u.intent,at:u.at,wrote:[...u.writes]},...s].slice(0,12)}return d.size===c.marks.size&&s===c.acts&&d.size===0?c:{marks:d,acts:s}}),o&&clearTimeout(o),o=setTimeout(()=>r(c=>c.marks.size===0?c:{...c,marks:new Map}),e)});return()=>{a(),o&&clearTimeout(o)}},[t,e]),n}var jt=se(Ae(),1),Xe=16;function di({marks:e,questions:t=[],whereIs:n,stageRef:r,width:o,height:a}){if(e.size===0&&t.length===0)return null;let i=r.current,l=i?.getBoundingClientRect()??null,c=[];for(let[s,u]of e){let h=null;if(i&&l&&typeof CSS<"u"){let x=i.querySelector(`[data-graview-pick="${CSS.escape(s)}"]`)?.getBoundingClientRect();x&&x.width>0&&x.height>0&&(h={x:x.left-l.left,y:x.top-l.top,width:x.width,height:x.height})}if(h??=n(s),!h)continue;let g=Math.min(Math.max(h.x+h.width-Xe/2,Xe/2),o-Xe/2),w=Math.min(Math.max(h.y-Xe/4,Xe/2),a-Xe/2);c.push({id:s,who:u,x:g,y:w})}let d=[];for(let s of t){let u=n(s.id);u&&d.push({...s,x:Math.min(Math.max(u.x+u.width/2,Xe),o-Xe),y:Math.min(Math.max(u.y-Xe/2,Xe),a-Xe)})}return c.length===0&&d.length===0?null:(0,jt.jsxs)("div",{className:"graview-seat-marks","data-testid":"seat-marks","data-graview-seat-marks":c.length,children:[c.map(({id:s,who:u,x:h,y:g})=>(0,jt.jsx)("span",{className:"graview-seat-mark","data-testid":"seat-mark","data-graview-seat-mark":s,"data-graview-seat-who":u,title:`${u} just changed this`,"aria-hidden":"true",style:{left:h,top:g,"--graview-hue":sn(u)},children:"\u25C6"},s)),d.map(s=>(0,jt.jsxs)("span",{className:"graview-seat-asking","data-testid":"seat-question","data-graview-seat-asking":s.id,title:s.asks,style:{left:s.x,top:s.y},children:[(0,jt.jsx)("span",{"aria-hidden":"true",children:"?"}),(0,jt.jsx)("span",{className:"graview-seat-asking-said",children:s.asks})]},`asking:${s.id}`))]})}var Z=se(Ae(),1);function Ba({hue:e,mode:t}){let n=t==="docked";return(0,Z.jsxs)("svg",{viewBox:"0 0 32 38","aria-hidden":"true",children:[(0,Z.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round",strokeLinecap:"round",children:[(0,Z.jsx)("line",{x1:"16",y1:"3.5",x2:"16",y2:"7"}),(0,Z.jsx)("circle",{cx:"16",cy:"2.6",r:"1.5",fill:"none"}),(0,Z.jsx)("path",{d:"M8 16 V12.5 C8 8.5 11.5 7 16 7 C20.5 7 24 8.5 24 12.5 V16 Z",fill:"currentColor",fillOpacity:"0.1"}),t==="refused"?(0,Z.jsx)("line",{x1:"11",y1:"12.5",x2:"21",y2:"12.5",strokeWidth:"2"}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)("rect",{x:"10.2",y:"10.2",width:"11.6",height:"4.6",rx:"2.3",fill:"currentColor",fillOpacity:"0.14",strokeWidth:"1"}),(0,Z.jsx)("circle",{cx:"13.4",cy:"12.5",r:"1.25",fill:"currentColor",stroke:"none",opacity:n?.45:1}),(0,Z.jsx)("circle",{cx:"18.6",cy:"12.5",r:"1.25",fill:"currentColor",stroke:"none",opacity:n?.45:1}),t==="reading"?(0,Z.jsx)("line",{x1:"10.2",y1:"12.5",x2:"21.8",y2:"12.5",strokeWidth:"0.8",opacity:"0.7"}):null]}),(0,Z.jsx)("line",{x1:"16",y1:"16",x2:"16",y2:"18.5"}),(0,Z.jsx)("polygon",{points:"16,18.5 24,22.5 16,26.5 8,22.5",fill:"currentColor",fillOpacity:"0.22"}),(0,Z.jsx)("polygon",{points:"8,22.5 16,26.5 16,33.5 8,29.5",fill:"currentColor",fillOpacity:"0.08"}),(0,Z.jsx)("polygon",{points:"24,22.5 16,26.5 16,33.5 24,29.5",fill:"currentColor",fillOpacity:"0.3"}),t==="writing"?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)("polyline",{points:"24,24 28.5,20.5"}),(0,Z.jsx)("line",{x1:"27.5",y1:"19",x2:"30",y2:"21.5",strokeWidth:"1.8"})]}):(0,Z.jsx)("line",{x1:"24",y1:"24",x2:"26.5",y2:"29"}),(0,Z.jsx)("line",{x1:"8",y1:"24",x2:"5.5",y2:"29"}),(0,Z.jsx)("path",{d:"M9.5 33.5 v2.2 h4"}),(0,Z.jsx)("path",{d:"M22.5 33.5 v2.2 h-4"})]}),(0,Z.jsx)("title",{children:`robot, ${t}`})]})}function $a({hue:e}){return(0,Z.jsxs)("svg",{viewBox:"0 0 22 24","aria-hidden":"true",style:{color:`hsl(${Math.round(e)} 50% 48%)`},children:[(0,Z.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round",strokeLinecap:"round",children:[(0,Z.jsx)("circle",{cx:"11",cy:"6",r:"4.2"}),(0,Z.jsx)("path",{d:"M3 23 C3 15.5 6 13 11 13 C16 13 19 15.5 19 23"})]}),(0,Z.jsx)("title",{children:"somebody"})]})}function li({width:e,whereIs:t}){let{who:n,following:r,follow:o}=pe(),a=Tr([...n.values()],t,e);return a.length===0?null:(0,Z.jsx)("div",{className:"graview-occupants","data-testid":"occupants","data-graview-occupants":a.length,children:a.map((i,l)=>{if(i.kind==="over")return(0,Z.jsx)("div",{className:"graview-presence-over","data-testid":"presence-over","data-graview-over-by":i.presence.participant,style:{left:i.box.x-3,top:i.box.y-3,width:i.box.width+6,height:i.box.height+6,"--graview-hue":i.presence.hue}},`over:${i.presence.participant}`);if(i.kind==="count")return(0,Z.jsxs)("span",{className:"graview-figure-count","data-testid":"presence-count","data-graview-at":i.at,style:{left:i.point.x,top:i.point.y},title:`${i.n} more here`,children:["+",i.n]},`count:${i.at}:${l}`);let c=i.presence.hue,d=dr(i.presence)||"somebody";if(i.kind==="edge")return(0,Z.jsxs)("button",{type:"button",className:"graview-figure-edge","data-testid":"presence-edge","data-graview-person":i.presence.participant,style:{right:`calc(${Math.max(8,e-i.point.x)}px + var(--graview-dock, 0px))`,top:i.point.y},onClick:()=>o(i.presence.participant),"aria-label":`${d} is somewhere else \u2014 press to go where they are`,children:["\u2192 ",d]},`edge:${i.presence.participant}`);if(i.kind==="robot")return(0,Z.jsxs)("div",{className:"graview-figure","data-graview-figure":`theirs:${i.presence.participant}`,"data-graview-theirs":"","data-graview-mode":i.mode,"data-graview-at":i.presence.robot?.at??"",style:{transform:`translate(${i.point.x.toFixed(1)}px, ${i.point.y.toFixed(1)}px)`,"--graview-hue":c},children:[(0,Z.jsx)("span",{className:"graview-figure-body",role:"img","aria-label":`${d}'s agent \u2014 ${i.mode}`,style:{cursor:"default"},children:(0,Z.jsx)(Ba,{hue:c,mode:i.mode})}),(0,Z.jsxs)("span",{className:"graview-figure-name",children:[d,"'s agent"]})]},`robot:${i.presence.participant}`);let s=r?.participant===i.presence.participant;return(0,Z.jsxs)("div",{className:"graview-figure","data-graview-figure":i.presence.participant,"data-graview-person":"","data-graview-at":i.at,"data-graview-audience":i.audience?"":void 0,"data-graview-followed":s?"":void 0,style:{transform:`translate(${i.point.x.toFixed(1)}px, ${i.point.y.toFixed(1)}px)`,"--graview-hue":c},children:[(0,Z.jsx)("button",{type:"button",className:"graview-figure-body","aria-label":`${d} is here${s?". Press to stop following":". Press to go where they go"}`,"aria-pressed":s,onClick:u=>{u.stopPropagation(),o(s?null:i.presence.participant)},onPointerDown:u=>u.stopPropagation(),children:(0,Z.jsx)($a,{hue:c})}),(0,Z.jsx)("span",{className:"graview-figure-name",children:d})]},`person:${i.presence.participant}`)})})}var jn=se(Te(),1),bn=se(Ae(),1),ci={left:"\u2190",right:"\u2192",top:"\u2191",bottom:"\u2193"},Ho=36,xn=56;function ui({result:e,schema:t,chrome:n=[],onGo:r}){let o=To(e);if(o.length===0)return null;let a=s=>(s??[]).flatMap(u=>{let h=e.nodes.find(g=>g.id===u.id);return h?[{left:h.x+u.x,top:h.y+u.y,right:h.x+u.x+u.width,bottom:h.y+u.y+u.height}]:[]}),i=a(e.city?.showings),l=a(e.city?.nameplates),c=[...i,...l,...n.map(s=>({left:s.x,top:s.y,right:s.x+s.width,bottom:s.y+s.height}))],d=[];for(let s of["left","right","top","bottom"]){let u=e.visible??e,h=s==="left"||s==="right"?u.height:u.width,g=s==="left"||s==="right",w=s==="bottom"?Fa:s==="top"?xn:Wa+xn/2,f=-1/0,x=[],v=o.filter(y=>y.side===s).sort((y,E)=>y.along-E.along);for(let y of v){let E=an(t,y.kind),I=Ha(E),j=g?Wn:I/2,F=h-w-(g?0:j),ee=Math.max(xn,y.along,f+j+Da);if(ee>F)continue;let{at:_,inset:p}=ja([...c,...x],s,ee,I,u,h);if(_>F+.5)continue;f=_+j,x.push(hi(s,_,I,u,p));let S=s==="left"?{left:p,top:_,transform:"translateY(-50%)"}:s==="right"?{right:`calc(${p}px + var(--graview-dock, 0px))`,top:_,transform:"translateY(-50%)"}:s==="top"?{top:p,left:_,transform:"translateX(-50%)"}:{bottom:`calc(${p}px + var(--graview-scene-foot, var(--graview-sheet, 0px)))`,left:_,transform:"translateX(-50%)"};d.push((0,bn.jsx)("button",{type:"button",className:"graview-edge-sign","data-graview-past-edge":y.id,"aria-label":`${E}, past the ${s} edge \u2014 bring it into view`,title:`${E} is past the ${s} edge`,tabIndex:-1,onPointerDown:A=>A.stopPropagation(),onClick:A=>{A.stopPropagation(),r(y.by)},style:{...Ya,...S},children:s==="right"||s==="bottom"?`${E} ${ci[s]}`:`${ci[s]} ${E}`},y.id))}}return(0,bn.jsx)(bn.Fragment,{children:d})}var Ha=e=>(e.length+2)*7.4+22,Wn=Ho/2,pn=6,Da=6,Fa=236,Wa=56;function hi(e,t,n,r,o=pn){return e==="left"||e==="right"?{left:e==="left"?o:r.width-o-n,right:e==="left"?o+n:r.width-o,top:t-Wn,bottom:t+Wn}:{left:t-n/2,right:t+n/2,top:e==="top"?o:r.height-o-Ho,bottom:e==="top"?o+Ho:r.height-o}}function ja(e,t,n,r,o,a){let i=t==="left"||t==="right",l=f=>hi(t,f,r,o),c=f=>e.find(x=>{let v=l(f);return v.left<x.right&&x.left<v.right&&v.top<x.bottom&&x.top<v.bottom}),d=c(n);if(!d)return{at:n,inset:pn};let s=i?Wn:r/2,u=f=>{let x=n;for(let v=0;v<12;v++){let y=c(x);if(!y)return x;if(x=f>0?(i?y.bottom:y.right)+s+4:(i?y.top:y.left)-s-4,x>a-xn||x<xn)return null}return null},h=u(1);if(h!==null)return{at:h,inset:pn};let g=u(-1);if(g!==null)return{at:g,inset:pn};let w=t==="left"?d.right:t==="right"?o.width-d.left:t==="top"?d.bottom:o.height-d.top;return{at:n,inset:Math.max(pn,w+4)}}var Ya={position:"absolute",zIndex:Be.lines,minHeight:28,maxWidth:"40%",padding:"3px 10px",font:"inherit",fontSize:"0.75rem",letterSpacing:"0.04em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:"var(--graview-ink)",background:"var(--graview-panel)",border:"1px solid var(--graview-edge)",borderRadius:6,boxShadow:"0 2px 8px rgb(0 0 0 / 0.12)",cursor:"pointer"};function fi(e){let[t,n]=(0,jn.useState)(null);return(0,jn.useLayoutEffect)(()=>{let r=e.current,o=null;for(let l=r?.parentElement??null,c=0;l&&!o&&c<4;l=l.parentElement,c++)o=l.querySelector(":scope > [data-graview-scene-trail]");if(!r||!o)return;let a=()=>{let l=r.getBoundingClientRect(),c=o.getBoundingClientRect(),d=c.width>0&&c.height>0?{x:c.left-l.left,y:c.top-l.top,width:c.width,height:c.height}:null;n(s=>s===d||s&&d&&s.x===d.x&&s.y===d.y&&s.width===d.width&&s.height===d.height?s:d)};if(a(),typeof ResizeObserver>"u")return;let i=new ResizeObserver(a);return i.observe(o),()=>i.disconnect()},[e]),t}var bt=se(Te(),1),Va=180;function mi({view:e,result:t,frame:n,panned:r,closer:o,screenId:a,setCamera:i}){let l=(0,bt.useRef)(new Map),c=Math.round((t.nodes.find(u=>u.id===a)?.height??0)/16),d=(0,bt.useRef)(e.overview??!1),s=(0,bt.useRef)(null);if((0,bt.useEffect)(()=>{if(!e.overview||!a||!t.city){if(d.current&&!e.overview)return;i(F=>F.x===0&&F.y===0?F:{x:0,y:0});return}let u=t.nodes.find(F=>F.id===a);if(!u)return;let h=o>1&&u.screenOf?t.nodes.find(F=>F.id===we(u.screenOf)):void 0,g=h?{x:Math.min(u.x,h.x),y:Math.min(u.y,h.y),width:Math.max(u.x+u.width,h.x+h.width)-Math.min(u.x,h.x),height:Math.max(u.y+u.height,h.y+h.height)-Math.min(u.y,h.y)}:u;if(g.x>=0&&g.y>=0&&g.x+g.width<=t.width&&g.y+g.height<=t.height&&!h)return;let f=24,x=(F,ee,_)=>F<f?f-F:F+ee>_-f?_-f-(F+ee):0,v=pt(t),y=e.pan??{x:0,y:0},E=h?r.x+(t.width/2-(g.x+g.width/2)):r.x+x(g.x,g.width,t.width),I=t.height/2-(g.y+g.height/2),j=h?r.y+(u.y+I<f?f-u.y:I):r.y+x(g.y,g.height,t.height);i({x:(h?E:Math.max(-v.x,Math.min(v.x,E)))-y.x,y:(h?j:Math.max(-v.y,Math.min(v.y,j)))-y.y})},[a,e.overview,o,e.within?.view,c]),n.city){let u=new Map;for(let h of n.nodes){if(!h.plot||Math.round(h.plane)!==2)continue;let g=Zt(h.plot.col+h.plot.side/2,h.plot.row+h.plot.side/2,n.city.cell,n.city.tilt);u.set(h.id,{x:n.city.originX+r.x+g.x,y:n.city.originY+r.y+g.y})}l.current=u}return(0,bt.useEffect)(()=>{let u=e.overview??!1,h=d.current&&!u;if(d.current=u,u&&s.current&&(clearTimeout(s.current),s.current=null),!h)return;let g=e.focusId?yt(e.focusId)[0]:void 0,w=g?l.current.get(we(g)):void 0,f=t.nodes.find(x=>x.id===e.focusId);if(!w||!f){i({x:0,y:0});return}i({x:w.x-(f.x+f.width/2),y:w.y-(f.y+f.height/2)}),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{s.current=null,i({x:0,y:0})},Va)},[e.overview]),(0,bt.useEffect)(()=>()=>{s.current&&clearTimeout(s.current)},[]),{gliding:()=>s.current!==null}}var Vn=se(Te(),1),Yn="[data-graview-view]";function Ga(e,t){let n=null;for(let r=e?.closest(Yn)??null;r&&t.contains(r);r=r.parentElement?.closest(Yn)??null)n=r;return n}function yi(e,t){let n=e.getBoundingClientRect();return{left:n.left,top:n.top,right:n.right-t.right,bottom:n.bottom-t.bottom,box:n}}function gi(e,t,n){let r=(0,Vn.useRef)({dock:t,reveal:n});r.current={dock:t,reveal:n},(0,Vn.useEffect)(()=>{let o=e.current;if(!o)return;let a=c=>{let{dock:d}=r.current;if(c.key!=="Tab"||c.defaultPrevented||d.right<=0&&d.bottom<=0)return;let s=yi(o,d),u=[];for(let h of o.querySelectorAll(Yn)){if(h.parentElement?.closest(Yn)||h.inert||h.contains(document.activeElement))continue;let g=h.getBoundingClientRect(),w=Math.max(g.left,s.box.left),f=Math.min(g.right,s.box.right),x=Math.max(g.top,s.box.top),v=Math.min(g.bottom,s.box.bottom);f<=w||v<=x||!(d.right>0&&w>=s.right-1||d.bottom>0&&x>=s.bottom-1)||(h.inert=!0,u.push(h))}u.length!==0&&setTimeout(()=>{for(let h of u)h.inert=!1},0)},i=c=>{let d=c.target,s=Ga(d,o);if(!s)return;let u=!0;try{u=d?.matches(":focus-visible")??!0}catch{}requestAnimationFrame(()=>{for(let h=s.parentElement;h;h=h===o?null:h.parentElement)h.scrollTop!==0&&(h.scrollTop=0),h.scrollLeft!==0&&(h.scrollLeft=0);u&&s.isConnected&&l(s)})},l=c=>{let d=yi(o,r.current.dock),s=c.getBoundingClientRect(),u=12,h=(f,x,v,y)=>y-v>x-f-2*u||v<f+u?f+u-v:y>x-u?x-u-y:0,g=h(d.left,d.right,s.left,s.right),w=h(d.top,d.bottom,s.top,s.bottom);(Math.abs(g)>=1||Math.abs(w)>=1)&&r.current.reveal(Math.round(g),Math.round(w))};return document.addEventListener("keydown",a,!0),o.addEventListener("focusin",i),()=>{document.removeEventListener("keydown",a,!0),o.removeEventListener("focusin",i)}},[e])}var de=se(Te(),1);function pi(){let e=(0,de.useRef)(null),[t,n]=(0,de.useState)({right:0,bottom:0});return(0,de.useLayoutEffect)(()=>{let r=e.current;if(!r)return;let o=()=>{let i=r.getBoundingClientRect(),l={right:Math.round(i.width),bottom:Math.round(i.height)};n(c=>c.right===l.right&&c.bottom===l.bottom?c:l)};if(o(),typeof ResizeObserver>"u")return;let a=new ResizeObserver(o);return a.observe(r),()=>a.disconnect()},[]),{probe:e,dock:t}}function xi(){let[e,t]=(0,de.useState)(null),n=(0,de.useRef)(null),r=(0,de.useRef)(0),o=(0,de.useCallback)(i=>{n.current=i,r.current===0&&(r.current=requestAnimationFrame(()=>{r.current=0,t(n.current)}))},[]),a=(0,de.useCallback)(()=>{r.current!==0&&cancelAnimationFrame(r.current),r.current=0;let i=n.current;return n.current=null,i&&t(null),i},[]);return{held:e,place:o,release:a}}function bi({stage:e,pan:t,setView:n,settled:r}){let o=(0,de.useRef)({x:0,y:0}),a=(0,de.useRef)(0),i=(0,de.useRef)(!1),l=(0,de.useRef)(r);l.current=r;let c=(0,de.useCallback)(()=>[...e.current?.querySelectorAll("[data-graview-world]")??[]],[e]),d=(0,de.useCallback)(()=>{a.current===0&&(a.current=requestAnimationFrame(()=>{a.current=0;let{x:w,y:f}=o.current,x=w===0&&f===0?"":`translate3d(${w}px, ${f}px, 0)`;for(let v of c())v.style.transform=x}))},[c]),s=(0,de.useCallback)(()=>{i.current=!1;for(let w of c())w.style.transform="";l.current()},[c]),u=(0,de.useCallback)((w,f)=>{o.current={x:w.x-f.x,y:w.y-f.y},d()},[d]),h=(0,de.useCallback)(()=>{let{x:w,y:f}=o.current;return w===0&&f===0?!1:(o.current={x:0,y:0},i.current=!0,n(x=>{let v=x.pan??{x:0,y:0};return Ht(x,{x:v.x+w,y:v.y+f})}),window.setTimeout(()=>{i.current&&s()},300),!0)},[n,s]);(0,de.useLayoutEffect)(()=>{i.current&&s()},[t,s]);let g=(0,de.useCallback)(()=>o.current,[]);return{shiftTo:u,settle:h,settling:i,offset:g}}var _a=4;function wi({view:e,panned:t,limit:n,panWithin:r,moveByTransform:o,setView:a,setDragging:i,noteMoved:l,shift:c,district:d}){let s=(0,de.useRef)(!1),u=(0,de.useRef)(null),h=v=>{let y=e.pan??{x:0,y:0};u.current={kind:"pan",fromX:v.clientX,fromY:v.clientY,baseX:y.x,baseY:y.y,moved:!1}};return{onGroundDown:v=>{v.button===0&&(v.target.closest("[data-graview-view]")||h(v))},onCardDown:(v,y)=>{if(y.button===0){if(v.screenOf!==void 0&&!y.target.closest("[data-graview-grip]")){h(y);return}if(e.overview&&Oe(v.id)!==null){h(y);return}u.current={kind:"card",id:v.id,fromX:y.clientX,fromY:y.clientY,baseX:v.x-t.x,baseY:v.y-t.y,moved:!1}}},onDragMove:v=>{let y=u.current;if(!y)return;let E=v.clientX-y.fromX,I=v.clientY-y.fromY;if(!y.moved){if(Math.hypot(E,I)<_a)return;y.moved=!0,i(!0),v.currentTarget.setPointerCapture(v.pointerId)}if(y.kind==="pan"){let j=r(n(),{x:y.baseX+E,y:y.baseY+I});o?c.shiftTo(j,e.pan??{x:0,y:0}):a(F=>Ht(F,j))}else y.id&&d.place({id:y.id,x:y.baseX+E,y:y.baseY+I})},onDragUp:()=>{c.settle();let v=d.release();v&&a(y=>mn(y,v.id,{x:v.x,y:v.y})),u.current?.moved&&(s.current=!0,setTimeout(()=>s.current=!1,0),l()),u.current=null,!c.settling.current&&i(!1)},swallow:s}}function vi({stage:e,view:t,setView:n}){let r=(0,de.useRef)({view:t,charge:0,coolUntil:0,lastScale:1});r.current.view=t;let o=(0,de.useRef)(()=>{}),a=(0,de.useRef)(()=>{});return(0,de.useEffect)(()=>{let i=e.current;if(!i)return;let l=(u,h)=>{let g=r.current;if(h<g.coolUntil)return;let w=g.view.overview??!1;u!==w&&(g.coolUntil=h+600,g.charge=0,n(dn(g.view,u)))},c=u=>{let h=r.current,g=h.view.overview??!1;if(u.ctrlKey){if(u.preventDefault(),!g){if(h.charge+=u.deltaY,Math.abs(h.charge)<60)return;h.charge>0?l(!0,performance.now()):h.charge=0;return}o.current(Math.exp(-u.deltaY*.004),u.clientX,u.clientY);return}!g||u.target?.closest("[data-graview-view], .graview-scroll, [data-graview-overlay], .graview-zoom")||(u.preventDefault(),a.current(-u.deltaX,-u.deltaY))},d=u=>{u.preventDefault(),r.current.lastScale=1},s=u=>{u.preventDefault();let h=r.current,g=u.scale??1;if(!(h.view.overview??!1)){g<.72&&l(!0,performance.now());return}let w=g/(h.lastScale||1);h.lastScale=g;let f=u;o.current(w,f.clientX,f.clientY)};return i.addEventListener("wheel",c,{passive:!1}),i.addEventListener("gesturestart",d),i.addEventListener("gesturechange",s),()=>{i.removeEventListener("wheel",c),i.removeEventListener("gesturestart",d),i.removeEventListener("gesturechange",s)}},[n,e]),{zoomAbout:o,panBy:a}}var ki={directed:"You",autonomous:"An agent","co-edited":"You and an agent",rule:"A rule"};function Do(e,t){let n=new Set(e.map(o=>o.id)),r=new Set;for(let o of t){if(n.has(o)){r.add(o);continue}let a=e.find(i=>i.aggregate?.memberIds.includes(o));a&&r.add(a.id)}return r}function Fo(e){return e.emphasized?e.stressed?.95:.08:e.anyChosen?e.mine?.9:.12:e.touches?Math.max(.34,.9-.09*Math.max(0,(e.siblings??1)-1)):.12}function Wo(e){return e.edgeChosen?.9:e.lit?.78:e.own*(e.anyLit?e.kit.dim:e.kit.rest)}function nt(e,t){if(!e)return null;let n=Math.max(0,Math.min(2,Math.floor(e.plane))),r=Math.max(0,Math.min(2,Math.ceil(e.plane))),{scale:o}=n===r?Ut(n,t):mr(Ut(n,t),Ut(r,t),e.plane-n);return{x:e.x,y:e.y,width:e.width*o,height:e.height*o}}function Jt(e,t){if(typeof getComputedStyle>"u"||getComputedStyle(e).visibility==="hidden")return null;let n=-1/0,r=-1/0,o=1/0,a=1/0,i=e.getBoundingClientRect();n=Math.max(n,i.left),r=Math.max(r,i.top),o=Math.min(o,i.right),a=Math.min(a,i.bottom);let l=e.parentElement;for(;l&&l!==t;){let d=getComputedStyle(l);if(d.overflowX!=="visible"||d.overflowY!=="visible"){let s=l.getBoundingClientRect();d.overflowX!=="visible"&&(n=Math.max(n,s.left),o=Math.min(o,s.right)),d.overflowY!=="visible"&&(r=Math.max(r,s.top),a=Math.min(a,s.bottom))}l=l.parentElement}if(o-n<=2||a-r<=2)return null;let c=t.getBoundingClientRect();return{x:n-c.left,y:r-c.top,width:o-n,height:a-r}}function De(e,t,n,r=!1){if(!e||typeof document>"u")return null;let o=e.querySelector(`[data-graview-view="${CSS.escape(t)}"]`);if(!o)return null;let a=(n?o.querySelector(".graview-kind-block"):null)??o.querySelector('[data-graview-primitive="panel"], .graview-kind-face, .graview-kind-card')??(r?null:o.querySelector(':scope > [data-graview-primitive="chip"]'))??o;return Jt(a,e)}function Gn(e,t,n,r,o){let a=d=>e.nodes.find(s=>s.id===d);if(o.startsWith("screen:")){let d=e.nodes.find(s=>s.id===we(o.slice(7)));return d?De(t,d.id,!0)??nt(d,n):null}let i=a(o),l=Oe(o);if(!i&&l!==null&&(i=a(Le(l))),!i&&Tt(o)){let[d]=yt(o);d&&(i=a(we(d)))}if(!i){let d=r.places().find(s=>s.as===o);d&&(i=a(Le(d.kind))??a(we(d.kind)))}if(i||(i=[...e.nodes].filter(d=>d.aggregate?.memberIds.includes(o)).sort((d,s)=>d.plane-s.plane)[0]),!i)return null;let c=e.city!==void 0;return De(t,i.id,c&&i.aggregate!==void 0&&Math.round(i.plane)===2)??nt(i,n)}var st=se(Te(),1);var le=se(Ae(),1);function Mi({kinds:e}){let{store:t}=pe(),{view:n,go:r}=mo(),o=(0,st.useRef)(null),a=go("districts",{align:"start"}),i=a.open,l=h=>an(t.schema,h),c=h=>t.graph.allNodes().filter(g=>g.kind===h).length,d=h=>!n.overview&&n.focusId===Le(h),s=e.filter(h=>!d(h)),u=h=>{a.setOpen(!1);let g=o.current?.querySelector(".graview-beyond-more")??null;d(h)||r(mt(n,Le(h))),g?.focus({preventScroll:!0});let w=`[data-graview-view="${Le(h)}"][tabindex], [data-graview-view="${we(h)}"][tabindex]`,f=40,x=()=>{let v=document.querySelector(w);v?v.focus({preventScroll:!0}):--f>0&&requestAnimationFrame(x)};requestAnimationFrame(x)};return(0,le.jsxs)("div",{ref:o,className:"graview-beyond","data-graview-beyond":e.length,"data-graview-beyond-open":i?"":void 0,children:[(0,le.jsxs)("button",{type:"button",className:"graview-beyond-more","data-testid":"beyond-more",...a.trigger,"aria-haspopup":"menu",title:`${s.length} more district${s.length===1?"":"s"} \u2014 press to see them`,onPointerDown:h=>h.stopPropagation(),onClick:h=>{h.stopPropagation(),a.toggle()},children:[(0,le.jsxs)("span",{className:"graview-beyond-count",children:["+",s.length]}),(0,le.jsx)("span",{className:"graview-beyond-word",children:"more"}),(0,le.jsx)("span",{className:"graview-beyond-chevron","aria-hidden":"true",children:i?"\u25BE":"\u25B4"})]}),i?(0,le.jsx)("ul",{...a.pane,className:"graview-beyond-list",role:"menu","aria-label":"The other districts","data-testid":"beyond-list",style:yo,onPointerDown:h=>h.stopPropagation(),children:e.map(h=>(0,le.jsx)("li",{role:"none",children:(0,le.jsxs)("button",{type:"button",role:"menuitem","data-graview-pick":we(h),"aria-current":d(h)?"location":void 0,title:d(h)?`${l(h)} \u2014 where you are`:`Go to ${l(h)}`,onPointerDown:g=>g.stopPropagation(),onClick:g=>{g.stopPropagation(),u(h)},children:[(0,le.jsx)("span",{className:"graview-beyond-name",children:l(h)}),(0,le.jsx)("span",{className:"graview-beyond-tally",children:d(h)?"here":c(h)})]})},h))}):null]})}function za(e,t){if(e===t)return!0;let n=Object.keys(e);return n.length!==Object.keys(t).length?!1:n.every(r=>r==="x"||r==="y"||Yo(e[r],t[r]))}function Yo(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)!==Array.isArray(t)||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==Array.prototype)return!1;if(Array.isArray(e)){let o=t;if(e.length!==o.length)return!1;for(let a=0;a<e.length;a++)if(!Yo(e[a],o[a]))return!1;return!0}let r=Object.keys(e);return r.length!==Object.keys(t).length?!1:r.every(o=>Yo(e[o],t[o]))}var Ri=(0,st.memo)(Ei,(e,t)=>e.mode===t.mode&&e.selected===t.selected&&e.fidelity===t.fidelity&&za(e.node,t.node));function Ei({node:e,mode:t,selected:n,fidelity:r}){let{store:o,views:a,view:i}=pe(),l=Ct(),c=Ir(),d=Ar(),s=e.aggregate||Tt(e.id)||Oe(e.id)!==null?"many":"one",u={cardinality:s,fidelity:r??fr[Ka(e.plane)].fidelity},h=s==="many"&&e.id===i.focusId?i.within?.view:void 0,g=a.resolve(e.kind,u,h),w=g?.view,f=a.resolve(e.kind,{cardinality:"many",fidelity:"full"})?.view,x=f!==void 0&&f.generic!==!0,v=e.aggregate?.memberIds,y=(0,st.useMemo)(()=>(v??[]).map(j=>o.graph.getNode(j)).filter(j=>j!==void 0),[v,o,l]),E={...e.aggregate?{nodes:y,label:g?.title??e.aggregate.label}:{node:o.graph.getNode(e.id)},fidelity:u.fidelity,cardinality:u.cardinality,mode:t,selected:n,implicated:c,flagged:d,...e.raised?{raised:!0}:{},...e.focused?{focused:!0}:{},...e.opened?{opened:!0}:{},...e.openedRows!==void 0?{openedRows:e.openedRows}:{},...e.plot?{plot:e.plot}:{},...e.nameplate?{nameplate:e.nameplate}:{},...e.states?{states:e.states}:{},...e.aggregate?.retired?{retired:e.aggregate.retired}:{},...e.rank?{rank:e.rank}:{},...e.nestedUnder?{nestedUnder:e.nestedUnder}:{},...x?{hasOwnView:!0}:{}};if(!w)return(0,le.jsx)(Xa,{node:e,props:E});let I=[e.id,g?.title??"",u.fidelity,u.cardinality,t,n,e.raised??!1,e.focused??!1,e.opened??!1,e.openedRows??"",e.rank??"",e.nestedUnder??"",e.plot?`${e.plot.col},${e.plot.row},${e.plot.side}`:"",e.nameplate??"",e.states?e.states.values.map(j=>j.count).join(","):"",e.aggregate?jo(e.aggregate.memberIds):"",e.aggregate?.retired??"",c?jo(c):"",d?jo(d):"",x].join("|");return(0,le.jsx)(uo,{mode:t,children:(0,le.jsx)(Pr,{kind:E.label??e.kind,...g?.title?{view:g.title}:{},children:(0,le.jsx)(Ua,{signature:I,graph:l,draw:()=>(0,le.jsx)(w,{...E})})},`${e.id}|${g?.title??""}`)})}var Ua=(0,st.memo)(function({draw:t}){return(0,le.jsx)(le.Fragment,{children:t()})},(e,t)=>e.signature===t.signature&&e.graph===t.graph);function Ka(e){return Math.max(0,Math.min(2,Math.round(e)))}function Xa({node:e,props:t}){return(0,le.jsxs)("div",{style:{padding:8,font:"13px/1.4 system-ui",overflow:"hidden"},children:[(0,le.jsx)("strong",{children:t.label??e.kind}),t.nodes?(0,le.jsxs)("div",{children:[t.nodes.length," items"]}):(0,le.jsx)("div",{children:e.id})]})}var Oi=(0,st.memo)(function({node:t}){let{store:n}=pe(),r=Pt(),o=t.aggregate,a=o.opens,i=o.memberIds.length,l=Gt(n.schema,o.kind,i),c=o.memberIds.slice(0,3).map(h=>{let g=n.graph.getNode(h),w=g?n.schema.tryDefinition(g.kind):void 0;return g?w?.label?w.label(g):String(g.label??h):h}),d=o.memberIds,s=(0,st.useMemo)(()=>{let h=r?Pn(r):null;return h?d.filter(g=>h.has(g)).length:0},[r,d]),u=a.in==="picture";return(0,le.jsxs)("div",{className:"graview-band-group","data-graview-band":a.in,"data-graview-band-count":i,"data-graview-emphasis":r?s>0?"lit":"dimmed":void 0,title:u?`${o.label} \u2014 press twice to see them all, arranged`:`${o.label}: ${l} \u2014 press twice to open`,children:[(0,le.jsxs)("span",{className:"graview-band-group-head",children:[(0,le.jsx)("span",{className:"graview-band-group-name",children:o.label}),(0,le.jsx)("span",{className:"graview-band-group-open","aria-hidden":"true",children:u?"\u2197":"\u25BE"})]}),(0,le.jsxs)("span",{className:"graview-band-group-names",children:[u?null:(0,le.jsxs)("span",{className:"graview-band-group-count",children:[l,s>0?` \xB7 ${s} match`:""," \xB7 "]}),c.join(" \xB7 "),i>c.length?" \u2026":""]})]})}),Si=new WeakMap;function jo(e){let t=Si.get(e);if(t!==void 0)return t;let n=2166136261;for(let o of e){for(let a=0;a<o.length;a++)n=Math.imul(n^o.charCodeAt(a),16777619);n=Math.imul(n^44,16777619)}let r=`${e.length}:${(n>>>0).toString(36)}`;return Si.set(e,r),r}var wt=se(Te(),1);function Vo(e,t,n){let r=e.aggregate?[...e.aggregate.memberIds]:[e.id];return n?r.every(a=>t.includes(a))?t.filter(a=>!r.includes(a)):[...t,...r.filter(a=>!t.includes(a))]:r}function Li(){let[e,t]=(0,wt.useState)(16);return(0,wt.useEffect)(()=>{if(typeof window>"u")return;let n=document.documentElement,r=()=>{let a=parseFloat(getComputedStyle(n).fontSize);Number.isFinite(a)&&t(i=>Math.abs(i-a)<.5?i:a)};r();let o=new MutationObserver(r);return o.observe(n,{attributes:!0,attributeFilter:["style"]}),window.addEventListener("resize",r),()=>{o.disconnect(),window.removeEventListener("resize",r)}},[]),e}function Ai(e){let[t,n]=(0,wt.useState)(null);return(0,wt.useLayoutEffect)(()=>{let r=e.current?.getBoundingClientRect();!r||r.width===0||r.height===0||n(o=>o??{width:Math.round(r.width),height:Math.round(r.height)})},[e]),(0,wt.useEffect)(()=>{let r=e.current;if(!r||typeof ResizeObserver>"u")return;let o=l=>{!l||l.width===0||l.height===0||n(c=>{let d={width:Math.round(l.width),height:Math.round(l.height)};return c&&c.width===d.width&&c.height===d.height?c:d})},a=new ResizeObserver(l=>o(l[0]?.contentRect)),i=()=>o(r.getBoundingClientRect());return a.observe(r),addEventListener("resize",i),()=>{a.disconnect(),removeEventListener("resize",i)}},[e]),t}function Go(e,t){if(t==="dark")return`0 ${(10*e).toFixed(1)}px ${(34*e).toFixed(1)}px rgba(0,0,0,${(e+.12).toFixed(2)})`;let n=`0 ${(1+2*e).toFixed(1)}px ${(2+5*e).toFixed(1)}px rgba(20,30,32,${(.03+.06*e).toFixed(3)})`,r=`0 ${(6+26*e).toFixed(1)}px ${(18+60*e).toFixed(1)}px -${(10+10*e).toFixed(1)}px rgba(20,30,32,${(.1+.3*e).toFixed(3)})`;return`${n}, ${r}`}function Ii(e){return`matrix3d(${e.join(",")})`}var ye=se(Te(),1);var _o=(e,t)=>t.some(n=>e.x>n.x&&e.x<n.x+n.width&&e.y>n.y&&e.y<n.y+n.height);function zo(e,t){let n=[],r=[];for(let a=0;a<e.length-1;a++){let i=e[a],l=e[a+1],c=!_o(i,t);c&&r.length===0&&r.push(i);for(let d=1;d<=48;d++){let s=d/48,u={x:i.x+(l.x-i.x)*s,y:i.y+(l.y-i.y)*s},h=!_o(u,t);if(h===c)continue;let g=(d-1)/48,w=s;for(let v=0;v<10;v++){let y=(g+w)/2,E={x:i.x+(l.x-i.x)*y,y:i.y+(l.y-i.y)*y};!_o(E,t)===c?g=y:w=y}let f=(g+w)/2,x={x:i.x+(l.x-i.x)*f,y:i.y+(l.y-i.y)*f};h?r=[x]:(r.push(x),r.length>=2&&n.push(r),r=[]),c=h}c&&r.push(l)}return r.length>=2&&n.push(r),n}function wn(e,t){let n=Math.abs(t.x-e.x);if(Math.abs(t.y-e.y)>n){if(n<2)return[e,t];let a=(e.y+t.y)/2;return[e,{x:e.x,y:a},{x:t.x,y:a},t]}let o=(e.x+t.x)/2;return Math.abs(t.x-e.x)<2?[e,t]:[e,{x:o,y:e.y},{x:o,y:t.y},t]}var Ve=e=>Math.round(e*100)/100,vt=e=>e.map(t=>t.map((n,r)=>`${r===0?"M":"L"} ${Ve(n.x)} ${Ve(n.y)}`).join(" ")).join(" ");function Uo(e,t){if(e.length<3)return vt([e]);let n=[`M ${Ve(e[0].x)} ${Ve(e[0].y)}`];for(let o=1;o<e.length-1;o++){let a=e[o-1],i=e[o],l=e[o+1],c=Math.hypot(i.x-a.x,i.y-a.y),d=Math.hypot(l.x-i.x,l.y-i.y),s=Math.min(t,c/2,d/2),u={x:i.x+(a.x-i.x)/(c||1)*s,y:i.y+(a.y-i.y)/(c||1)*s},h={x:i.x+(l.x-i.x)/(d||1)*s,y:i.y+(l.y-i.y)/(d||1)*s};n.push(`L ${Ve(u.x)} ${Ve(u.y)} Q ${Ve(i.x)} ${Ve(i.y)} ${Ve(h.x)} ${Ve(h.y)}`)}let r=e[e.length-1];return n.push(`L ${Ve(r.x)} ${Ve(r.y)}`),n.join(" ")}function Ti(e,t){return t==="orthogonal"?vt([e]):Uo(e,10)}function Pi(e,t,n){if(e==="orthogonal"){let l=wn(t.p0,t.p1),c=l.slice(1).map((u,h)=>Math.hypot(u.x-l[h].x,u.y-l[h].y)),d=c.reduce((u,h)=>u+h,0)||1,s=n*d;for(let u=0;u<c.length;u++){let h=c[u];if(s<=h||u===c.length-1){let g=h===0?0:Math.min(1,s/h),w=l[u],f=l[u+1];return{x:w.x+(f.x-w.x)*g,y:w.y+(f.y-w.y)*g}}s-=h}return t.p1}let r=e==="straight"?{x:(t.p0.x+t.p1.x)/2,y:(t.p0.y+t.p1.y)/2}:t.c,o=(1-n)*(1-n),a=2*(1-n)*n,i=n*n;return{x:o*t.p0.x+a*r.x+i*t.p1.x,y:o*t.p0.y+a*r.y+i*t.p1.y}}function _n(e,t){return e!=="straight"?t:{...t,c:{x:(t.p0.x+t.p1.x)/2,y:(t.p0.y+t.p1.y)/2}}}function Ci(e,t){let n=t.x-e.x,r=t.y-e.y,o=(n/2+r)/2,a=(r-n/2)/2;if(Math.abs(o)<1||Math.abs(a)<1)return[e,t];let i={x:e.x+2*o,y:e.y+o};return[e,i,t]}function Ni(e){let t=[...e].sort((r,o)=>r.y-o.y||r.x-o.x),n=[];for(let r of t){let o=n.find(a=>r.y<a.bottom+3&&r.y+r.height>a.top-3);o?(o.boxes.push(r),o.top=Math.min(o.top,r.y),o.bottom=Math.max(o.bottom,r.y+r.height)):n.push({top:r.y,bottom:r.y+r.height,boxes:[r]})}for(let r of n)r.boxes.sort((o,a)=>o.x-a.x);return n.sort((r,o)=>r.top-o.top)}var vn=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,Xo=(e,t)=>e.findIndex(n=>n.boxes.some(r=>vn(r,t)));function Bi(e,t,n){return t<0?e[0].top-12*2:n>=e.length?e[e.length-1].bottom+12*2:(e[t].bottom+e[n].top)/2}function Qo(e,t){let n=[{from:-1/0,to:1/0}];for(let a of e){let i=[],l=-1/0;for(let d of a.boxes)i.push({from:l,to:d.x-12}),l=Math.max(l,d.x+d.width+12);i.push({from:l,to:1/0});let c=[];for(let d of n)for(let s of i){let u=Math.max(d.from,s.from),h=Math.min(d.to,s.to);h-u>=0&&c.push({from:u,to:h})}n=c}let r=t,o=1/0;for(let a of n){let i=Math.min(Math.max(t,a.from),a.to),l=a.from===-1/0||a.to===1/0,c=Math.abs(i-t)+(l?60:0);c<o&&(o=c,r=i)}return r}var qe=e=>({x:e.x,y:-(e.y+e.height),width:e.width,height:e.height}),zn=e=>e.map(t=>({x:t.x,y:-t.y}));function qo(e){let t=(r,o)=>Math.abs(r-o)<.5,n=e.filter((r,o)=>o===0||!(t(r.x,e[o-1].x)&&t(r.y,e[o-1].y)));return n.filter((r,o)=>{let a=n[o-1],i=n[o+1];return!a||!i||!(t(a.x,r.x)&&t(r.x,i.x)||t(a.y,r.y)&&t(r.y,i.y))})}function Zo(e,t,n){let r=e.boxes.filter(d=>!vn(d,t)&&d.y+d.height<=t.y+1&&d.x<t.x+t.width&&d.x+d.width>t.x),o=[{from:t.x+6,to:t.x+t.width-6}];for(let d of r)o=o.flatMap(s=>[{from:s.from,to:Math.min(s.to,d.x-12/2)},{from:Math.max(s.from,d.x+d.width+12/2),to:s.to}]).filter(s=>s.to>=s.from);let a=null;for(let d of o){let s=Math.min(Math.max(n,d.from),d.to);(a===null||Math.abs(s-n)<Math.abs(a-n))&&(a=s)}if(a!==null)return{x:a,tail:[{x:a,y:t.y}]};let i=n<t.x+t.width/2,l=Qo([e],i?t.x-12:t.x+t.width+12),c=t.y+t.height/2;return{x:l,tail:[{x:l,y:c},{x:l<t.x?t.x:t.x+t.width,y:c}]}}function Ko(e,t,n){let r=Zo({top:-e.bottom,bottom:-e.top,boxes:e.boxes.map(qe)},qe(t),n);return{x:r.x,head:zn(r.tail).reverse()}}function $i(e,t,n,r){let o=t;for(;o>r&&!e[o-1].boxes.some(a=>n>a.x-12/2&&n<a.x+a.width+12/2);)o--;return o}var Hi=(e,t)=>(e%3-1)*Math.max(0,Math.min(4,t/2-3));function Di(e,t,n,r,o,a,i,l){let c=f=>f<0?e[0].top-n:e[f+1].top-e[f].bottom,d=f=>(f<0?(n+e[0].top)/2:Bi(e,f,f+1))+Hi(l,c(f)),s=Zo(e[a],o,i),u=$i(e,a,s.x,t+1),h=d(t);if(u===t+1)return qo([...r.head,{x:r.x,y:h},{x:s.x,y:h},...s.tail]);let g=Qo(e.slice(t+1,u),s.x),w=d(u-1);return qo([...r.head,{x:r.x,y:h},{x:g,y:h},{x:g,y:w},{x:s.x,y:w},...s.tail])}function en(e,t,n,r=0){let o=Ni(n.some(s=>vn(s,e))&&n.some(s=>vn(s,t))?n:[...n,e,t]),a=Xo(o,e),i=Xo(o,t),l=e.x+e.width/2,c=t.x+t.width/2;if(a===i){if(!(a<o.length-1||o.length===1))return zn(en(qe(e),qe(t),n.map(qe),r));let u=Bi(o,a,a+1)+Hi(r,a<o.length-1?o[a+1].top-o[a].bottom:2*12),h=Ko(o[a],e,c),g=Ko(o[a],t,l);return qo([...h.head,{x:h.x,y:u},{x:g.x,y:u},...[...g.head].reverse()])}if(i<a)return zn(en(qe(e),qe(t),n.map(qe),r));let d=Ko(o[a],e,c);return Di(o,a,o[a].bottom,d,t,i,l,r)}function Jo(e,t,n,r=0){if(t.y+t.height<=e.y){let g=Jo(qe(e),qe(t),n.map(qe),r);return g?zn(g):null}let o=e.y+e.height;if(t.y<o)return null;let a=Ni([...n.filter(g=>g.y>=o&&!vn(g,t)),t]),i=Xo(a,t),l=t.x+t.width/2,c=Zo(a[i],t,l),d=$i(a,i,c.x,0),s=d===0?c.x:Qo(a.slice(0,d),c.x),u=Math.min(12,e.width/2),h=Math.min(Math.max(s,e.x+u),e.x+e.width-u);return Di(a,-1,o,{x:h,head:[{x:h,y:o}]},t,i,l,r)}function Fi(e,t=16){let n=new Map;for(let o of e){let a=o.a<o.b?`${o.a}\0${o.b}`:`${o.b}\0${o.a}`,i=n.get(a);i?i.push(o.key):n.set(a,[o.key])}let r=new Map;for(let o of n.values())o.forEach((a,i)=>r.set(a,(i-(o.length-1)/2)*t));return r}var Fe=se(Ae(),1);function Kn(e,t){let n=Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x),r=Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y);if(n>0&&r>0)return null;let o=n>.5*Math.min(e.width,t.width),a=!o&&r>.5*Math.min(e.height,t.height);if(o){let w={x:e.x+e.width,y:e.y+e.height/2},f={x:t.x+t.width,y:t.y+t.height/2};return{from:w,to:f,control:{x:Math.max(w.x,f.x)+18,y:(w.y+f.y)/2},mode:"stacked"}}if(a){let w={x:e.x+e.width/2,y:e.y},f={x:t.x+t.width/2,y:t.y};return{from:w,to:f,control:{x:(w.x+f.x)/2,y:Math.min(w.y,f.y)-18},mode:"abreast"}}let i={x:t.x+t.width/2,y:t.y+t.height/2},l={x:e.x+e.width/2,y:e.y+e.height/2},c=Un(e,i),d=Un(t,l),s=Math.hypot(d.x-c.x,d.y-c.y);if(s<8)return null;let u=Math.min(36,s*.12),h=-(d.y-c.y)/s,g=(d.x-c.x)/s;return{from:c,to:d,control:{x:(c.x+d.x)/2+h*u,y:(c.y+d.y)/2+g*u},mode:"direct"}}function Un(e,t){let n=e.x+e.width/2,r=e.y+e.height/2,o=t.x-n,a=t.y-r;if(o===0&&a===0)return{x:n,y:r};let i=o===0?1/0:e.width/2/Math.abs(o),l=a===0?1/0:e.height/2/Math.abs(a),c=Math.min(i,l),d=Math.max(0,c*.98);return{x:n+o*d,y:r+a*d}}function qa(e,t,n){let r=t.get(e.from),o=t.get(e.to);if(!r||!o)return!1;if(n)return!0;let a=Math.round(r.plane)===1||Math.round(o.plane)===1,i=l=>!!l.aggregate&&Math.round(l.plane)===2;return a&&!i(r)&&!i(o)}var Qa=()=>({clips:new Map,members:new Map,marks:new Map});function ji(e,t){let n=t.marks.get(e);if(n)return n;n=new Map;for(let r of e.querySelectorAll("[data-graview-pick], [data-graview-slot]"))for(let o of new Set([r.getAttribute("data-graview-pick"),r.getAttribute("data-graview-slot")])){if(o===null)continue;let a=n.get(o);a?a.push(r):n.set(o,[r])}return t.marks.set(e,n),n}function Za(e,t){let n=t.clips.get(e);if(n===void 0){let r=getComputedStyle(e);n=r.overflow!=="visible"||r.overflowX!=="visible"||r.overflowY!=="visible"?e.getBoundingClientRect():null,t.clips.set(e,n)}return n}function Ja(e,t,n){let r=e.parentElement;for(;r!==null;){let o=Za(r,n);if(o&&!(t.right>o.left+1&&t.left<o.right-1&&t.bottom>o.top+1&&t.top<o.bottom-1))return!1;if(r.hasAttribute("data-graview-view"))break;r=r.parentElement}return!0}function kn(e,t,n,r){if(!e||!t||typeof document>"u")return[];let o=r.members.get(t);o||r.members.set(t,o=new Map);let a=o.get(n);if(a)return a;let i=e.getBoundingClientRect(),l=[];for(let c of ji(t,r).get(n)??[]){if(c.closest("[data-graview-offstage]"))continue;let d=c.getBoundingClientRect();d.width<=2||d.height<=2||Ja(c,d,r)&&l.push({x:d.left-i.left,y:d.top-i.top,width:d.width,height:d.height})}return l.sort((c,d)=>c.width*c.height-d.width*d.height),o.set(n,l),l}function Xn(e,t,n,r,o){let a=new Map(e.map(y=>[y.id,y])),i=Qa(),l=new Map,c=y=>{if(!n||typeof document>"u")return null;let E=l.get(y);return E===void 0&&(E=n.querySelector(`[data-graview-view="${CSS.escape(y)}"]`),l.set(y,E)),E},d=new Map;for(let y of e){let E=De(n,y.id,r)??nt(y,o);E&&d.set(y.id,E)}let s=new Map;if(n&&typeof document<"u"){let y=n.getBoundingClientRect();for(let E of n.querySelectorAll("[data-graview-pick], [data-graview-slot]")){if(E.closest("[data-graview-offstage]"))continue;let I=E.getAttribute("data-graview-pick")??E.getAttribute("data-graview-slot");if(I===null)continue;let j=E.getBoundingClientRect();if(j.width<=2||j.height<=2||j.width>y.width*.6&&j.height>y.height*.6)continue;let F=s.get(I),ee={x:j.left-y.left,y:j.top-y.top,width:j.width,height:j.height};F?F.push(ee):s.set(I,[ee])}}let u=(y,E)=>{let I=[];for(let[j,F]of d)j!==y&&j!==E&&I.push(F);for(let[j,F]of s)j!==y&&j!==E&&I.push(...F);return I},h=y=>Math.round(a.get(y)?.plane??-1)===1,g=[];for(let y of e){let E=d.get(y.id);E&&Math.round(y.plane)===1&&g.push(E)}if(!r&&n&&typeof document<"u"){let y=n.getBoundingClientRect();for(let E of n.querySelectorAll("[data-graview-relation] > span")){let I=E.getBoundingClientRect();I.width>0&&I.height>0&&g.push({x:I.left-y.left,y:I.top-y.top,width:I.width,height:I.height})}}let w=(y,E)=>!r&&h(y)&&h(E)?g:void 0,f=r?void 0:e.find(y=>Math.round(y.plane)===0&&!y.aggregate),x=(y,E,I,j)=>{if(!f)return{};let F=y.to===f.id&&I===f.id;if(!F&&!(y.from===f.id&&E===f.id))return{};let ee=F?y.from:y.to,_=d.get(f.id),p=d.get(ee);if(ee===f.id||!h(ee)||!_||!p)return{};let S=c(f.id),A=T=>S!==null&&ji(S,i).get(T)?.some(G=>!G.closest("[data-graview-offstage]"))===!0,O=j.map(T=>T.from===f.id?T.to:T.from),H=O.length>0&&O.every(A);return{band:g,tie:{card:_,chip:p,cardIsTo:F,toward:ee,holds:a.get(ee)?.aggregate?.memberIds??[ee]},...H?{said:O}:{}}},v=[];for(let y of t){if(!qa(y,a,r))continue;let E=d.get(y.from),I=d.get(y.to);if(!E||!I)continue;let j=u(y.from,y.to),F=y.edges,ee=r&&F.some(S=>S.from!==y.from&&kn(n,c(y.from),S.from,i).length>0||S.to!==y.to&&kn(n,c(y.to),S.to,i).length>0),_=w(y.from,y.to);if(r&&!ee||y.loop||F.length===0){v.push({key:y.id,connector:y,edges:F,fromBox:E,toBox:I,fromAnchor:y.from,toAnchor:y.to,obstacles:j,hosts:[],..._?{band:_}:{},...x(y,y.from,y.to,F)});continue}let p=new Map;for(let S of F){let A=S.from===y.from?[]:kn(n,c(y.from),S.from,i),O=S.to===y.to?[]:kn(n,c(y.to),S.to,i),H=[y.from,y.to].find(L=>Math.round(a.get(L)?.plane??-1)===0);if(!r&&H!==void 0&&(H===y.from?S.from!==y.from:S.to!==y.to)&&kn(n,c(H),H===y.from?S.to:S.from,i).length>0)continue;let T=H!==void 0?a.get(H):void 0;if(!r&&T?.aggregate&&n&&(H===y.from?S.from!==y.from&&A.length===0:S.to!==y.to&&O.length===0))continue;let G=A.length>0?S.from:y.from,Y=O.length>0?S.to:y.to,V=`${y.id}|${G}|${Y}`,k=p.get(V);if(k){k.edges.push(S);continue}let $=A.length>0?A:[E],q=O.length>0?O:[I],z=$[0],b=q[0],R=1/0;for(let L of $)for(let M of q){let N=Math.hypot(L.x+L.width/2-(M.x+M.width/2),L.y+L.height/2-(M.y+M.height/2));N<R&&(R=N,z=L,b=M)}p.set(V,{edges:[S],fromBox:z,toBox:b,fromAnchor:G,toAnchor:Y})}for(let[S,A]of p)v.push({key:S,connector:y,obstacles:j,hosts:[...A.fromAnchor!==y.from?[E]:[],...A.toAnchor!==y.to?[I]:[]],..._?{band:_}:{},...A,...x(y,A.fromAnchor,A.toAnchor,A.edges)})}return v}function Yi(e,t,n){let r=new Map(t.map(i=>[i.id,i])),o=new Map;for(let i of n){let l=r.get(i.id);l&&(l.x!==i.x||l.y!==i.y)&&o.set(i.id,{x:i.x-l.x,y:i.y-l.y})}if(o.size===0)return[...e];let a=(i,l)=>{let c=o.get(l);return c?{...i,x:i.x+c.x,y:i.y+c.y}:i};return e.map(i=>{let{from:l,to:c}=i.connector;if(!o.has(l)&&!o.has(c))return i;let d=a(i.fromBox,l),s=a(i.toBox,c),u=i.tie&&{...i.tie,card:a(i.tie.card,i.tie.cardIsTo?c:l),chip:a(i.tie.chip,i.tie.toward)},h=g=>g===i.fromBox?d:g===i.toBox?s:i.tie&&g===i.tie.chip?u.chip:g;return{...i,fromBox:d,toBox:s,...u?{tie:u}:{},...i.band?{band:i.band.map(h)}:{}}})}function er(e,t){let n=(1-t)*(1-t),r=2*(1-t)*t,o=t*t;return{x:n*e.p0.x+r*e.c.x+o*e.p1.x,y:n*e.p0.y+r*e.c.y+o*e.p1.y}}function Wi(e,t,n){let r=(1-t)*(1-n),o=(1-t)*n+t*(1-n),a=t*n;return{p0:er(e,t),c:{x:r*e.p0.x+o*e.c.x+a*e.p1.x,y:r*e.p0.y+o*e.c.y+a*e.p1.y},p1:er(e,n)}}function Sn(e,t){let n=d=>t.some(s=>d.x>s.x&&d.x<s.x+s.width&&d.y>s.y&&d.y<s.y+s.height),r=d=>!n(er(e,d)),a=(d,s,u)=>{for(let h=0;h<10;h++){let g=(d+s)/2;r(g)===u?d=g:s=g}return(d+s)/2},i=[],l=null,c=r(0);c&&(l=0);for(let d=1;d<=64;d++){let s=d/64,u=r(s);if(u===c)continue;let h=a((d-1)/64,s,c);u?l=h:l!==null&&(h-l>.001&&i.push(Wi(e,l,h)),l=null),c=u}return l!==null&&1-l>.001&&i.push(Wi(e,l,1)),i}function Vi({strands:e,result:t,scheme:n,overview:r,selection:o,emphasis:a,stageRef:i,liveOf:l,onPickEdge:c,provisional:d,pointed:s=null}){let u=Bt(),h=new Set(t.nodes.filter(p=>p.plot!==void 0&&Math.round(p.plane)===2).map(p=>p.id)),g=p=>r&&t.city!==void 0&&h.has(p.from)&&h.has(p.to),w=Do(t.nodes,o),f=p=>w.size===0||w.has(p.from)||w.has(p.to),x=new Set(o.filter(p=>It(p)===null)),v=r?t.nodes.find(p=>Math.round(p.plane)===0):void 0,y=v?De(i.current,v.id,!1)??nt(v,n):null;if(e.length===0)return null;let E=p=>p.edges.some(S=>x.has(S.from)||x.has(S.to)),I=x.size>0&&e.some(E),j=new Map;for(let p of e)j.set(p.connector.id,(j.get(p.connector.id)??0)+1);let F=Fi(e.map(p=>({key:p.key,a:p.fromAnchor,b:p.toAnchor}))),ee=new Set,_=e.map((p,S)=>{let{connector:A,fromBox:O,toBox:H}=p,T={x:O.x+O.width/2,y:O.y+O.height/2},G={x:H.x+H.width/2,y:H.y+H.height/2},Y=r?Un(O,G):T,V=r?Un(H,T):G,k=A.loop===!0,{connector:$,style:q}=Qt(u,A.kind);if(!$.visible)return null;let z=k?Math.max(22,Math.min(O.width,O.height)*.3):0,b=k?{x:T.x+O.width*.22,y:T.y-O.height/2-z+7}:Y,R=(Y.x+V.x)/2,L=(Y.y+V.y)/2,M=Math.hypot(V.x-Y.x,V.y-Y.y),N=Math.min(r?40:90,M*(r?.09:.16)),P=0,B=0;if(M>0){P=-(V.y-Y.y)/M,B=(V.x-Y.x)/M;let re=R-t.width/2,Me=L-t.height/2;if(y&&!k){let it=y.x+y.width/2,Mt=y.y+y.height/2;re=R-it,Me=L-Mt;let ht=Math.abs(P*(it-Y.x)+B*(Mt-Y.y)),ft=Math.hypot(y.width/2,y.height/2)*.85+24,Ie=((it-Y.x)*(V.x-Y.x)+(Mt-Y.y)*(V.y-Y.y))/(M*M);ht<ft&&Ie>.1&&Ie<.9&&(N=Math.min(180,Math.max(N,(ft-ht)*2)))}P*re+B*Me<0&&(P=-P,B=-B)}N+=2*(F.get(p.key)??0);let te=_n($.route,{p0:Y,c:{x:R+P*N,y:L+B*N},p1:V}),U=g(A),W=$.route==="orthogonal"||U,J=(re,Me)=>U?Ci(re,Me):wn(re,Me),X=!k&&p.tie?Jo(p.tie.card,p.tie.chip,p.band??[],S):null,fe=X?p.tie.cardIsTo?X.reverse():X:!k&&p.band?en(O,H,p.band,S):null,ie=k||W||fe?[]:Sn(te,[O,H,...p.obstacles]),ve=fe?[fe]:!k&&W?zo(J(Y,V),[O,H,...p.obstacles]):[];if(!k&&ie.length===0&&ve.length===0)return null;let ke=ve[ve.length-1],$e=W||fe?ve[0]?.[0]:ie[0]?.p0,ae=W||fe?ke?.[ke.length-1]:ie[ie.length-1]?.p1,Se=re=>re.map(Me=>`M ${Me.p0.x} ${Me.p0.y} Q ${Me.c.x} ${Me.c.y} ${Me.p1.x} ${Me.p1.y}`).join(" "),ot=`M ${b.x-z} ${b.y} A ${z} ${z} 0 1 1 ${b.x+z} ${b.y} A ${z} ${z} 0 0 1 ${b.x-z} ${b.y}`,oe=k?ot:fe?Ti(fe,$.route):W?vt(ve):Se(ie),Ge=re=>({x:re.x-8,y:re.y-8,width:re.width+16,height:re.height+16}),Ze=[O,H,...p.hosts,...p.obstacles].map(Ge),kt=k?ot:fe?vt(ve):W?vt(zo(J(Y,V),Ze)):Se(Sn(te,Ze)),Je=p.edges.length===1?p.edges[0]:null,Ce=Je?$t(A.kind,Je.from,Je.to):null,lt=Ce!==null&&o.includes(Ce),rt=Ce!==null?d?.get(Ce):void 0,We=p.edges.some(re=>x.has(re.from)||x.has(re.to)),Ne=p.tie?.toward??"",je=p.tie!==void 0&&(s!==null&&(Ne===s||p.tie.holds.includes(s)||p.said?.includes(s)===!0)||x.has(Ne))&&!ee.has(Ne);je&&ee.add(Ne);let _e=!r&&x.size>0&&We||je,ze=a!==null&&A.kind===a||lt,Ye=l?.(A)!==void 0;if(r&&!Ye||!r&&!Ye&&x.size>0&&!We&&!ze&&!je||p.said!==void 0&&!je&&!p.said.some(re=>x.has(re))&&!ze)return null;let ct=r?Fo({emphasized:a!==null,stressed:ze,anyChosen:I,mine:We,touches:f(A),siblings:j.get(A.id)??1}):Wo({edgeChosen:lt,lit:_e,anyLit:I||a!==null,own:q.opacity,kit:u.emphasis}),St=_e&&$e&&ae?p.tie?p.tie.cardIsTo?$e:ae:p.edges.some(re=>x.has(re.from))?ae:$e:null,ut=(0,Fe.jsxs)("g",{children:[(0,Fe.jsx)("path",{"data-graview-connector":A.kind,"data-graview-edges":p.edges.length,"data-graview-from":p.fromAnchor,"data-graview-to":p.toAnchor,"data-graview-lit":_e||void 0,"data-graview-activity":l?.(A)?.manner,"data-graview-provisional":rt!==void 0||void 0,opacity:ct*(A.opacity??1)*(rt!==void 0?fn:1),d:oe,fill:"none",stroke:Kt(q),strokeWidth:(_e?Math.max(1.6,po(q,r)):po(q,r))+(ze?.6:0),strokeDasharray:rt!==void 0?hn:Cn[q.pattern],strokeLinecap:"round"}),St?(0,Fe.jsx)("circle",{cx:St.x,cy:St.y,r:2.6,fill:Kt(q),opacity:ct}):null,k&&r?(0,Fe.jsx)("text",{x:b.x,y:b.y-z-5,textAnchor:"middle",opacity:ct,style:{font:"9px var(--graview-font-body, system-ui)",letterSpacing:"0.09em",textTransform:"uppercase",fill:"var(--graview-ink-faint)"},children:rn(A.kind).toLowerCase()}):null]},p.key),et=null;return Ce&&c&&!k&&ct>=.2&&(et=(0,Fe.jsx)("path",{"data-graview-edge":Ce,className:"graview-edge-hit",d:kt,fill:"none",pathLength:1,strokeDasharray:"0.86",strokeDashoffset:-.07,stroke:"transparent",strokeWidth:14,style:{pointerEvents:"stroke",cursor:"pointer"},onClick:re=>{re.stopPropagation(),c(Ce,{x:re.clientX,y:re.clientY})},onContextMenu:re=>{re.preventDefault(),re.stopPropagation(),c(Ce,{x:re.clientX,y:re.clientY})},children:rt!==void 0?(0,Fe.jsx)("title",{children:rt}):null},`hit:${p.key}`)),{key:p.key,line:ut,hit:et}});return(0,Fe.jsxs)(Fe.Fragment,{children:[(0,Fe.jsx)("svg",{"aria-hidden":"true","data-graview-world":"",width:t.width,height:t.height,style:{position:"absolute",left:0,top:0,pointerEvents:"none",zIndex:Be.ties},children:_.map(p=>p?.line)}),_.some(p=>p?.hit)?(0,Fe.jsx)("svg",{"data-graview-world":"",width:t.width,height:t.height,style:{position:"absolute",left:0,top:0,pointerEvents:"none",zIndex:Be.tieLabels},children:_.map(p=>p?.hit)}):null]})}var es=e=>e.length*8.4+16;function Gi(e,t){let n=new Map;for(let a of e){let i=n.get(a.key);i?i.push(a):n.set(a.key,[a])}let r=[...n.values()].map(a=>{let i=Math.min(...a.map(c=>c.top)),l=a.filter(c=>c.top-i<=12);return{key:a[0].key,text:a[0].text,left:Math.min(...l.map(c=>c.left)),right:Math.max(...l.map(c=>c.right)),top:i}});r.sort((a,i)=>a.top-i.top||a.left-i.left);let o=r.map(a=>{let i=Math.max(a.right-a.left,Math.min(300,es(a.text))),l=(a.left+a.right)/2;return{left:l-i/2,right:l+i/2}});return r.map((a,i)=>{let l=r.map((v,y)=>({other:v,at:y})).filter(({other:v})=>v!==a&&Math.abs(v.top-a.top)<=12),c=l.filter(({other:v})=>v.right<=a.left).map(({other:v,at:y})=>o[y].right+8<=(v.right+a.left)/2?o[y].right+8:(v.right+a.left+8)/2),d=l.filter(({other:v})=>v.left>=a.right).map(({other:v,at:y})=>o[y].left-8>=(a.right+v.left)/2?o[y].left-8:(a.right+v.left-8)/2),s=Math.max(t.left,...c),u=Math.min(t.right,...d),h=a.right-a.left,g=o[i].right-o[i].left,w=Math.max(h,Math.min(g,u-s)),f=(a.left+a.right)/2,x=h>=w?a.left:Math.max(s,Math.min(f-w/2,u-w));return{key:a.key,text:a.text,left:x,width:w,top:a.top}})}function qn(e){return e<640?{left:8,right:56}:{left:8,right:Math.round(Math.min(128,e*.107))}}function ts(e){return Math.min(260,16+e.length*6.6)}var Mn=(e,t)=>Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));function zi(e,t,n){let r=new Map;for(let i of e){let l=r.get(i.said);l?l.push(i):r.set(i.said,[i])}let o=[],a=[];for(let[i,l]of r){let c=l[0],d=ts(i),{end:s,far:u}=c,h=x=>Math.max(0,Math.min(n.width-d,x)),g=[{x:h(s.x-d/2),y:u.y-22-6,width:d,height:22},{x:h(s.x-d/2),y:u.y+u.height+6,width:d,height:22},{x:u.x+u.width+6,y:s.y-22/2,width:d,height:22},{x:u.x-d-6,y:s.y-22/2,width:d,height:22}],w=g[0],f=1/0;for(let x of g){let y=x.x<0||x.y<0||x.x+x.width>n.width||x.y+x.height>n.height?1e9:0;for(let E of t)y+=Mn(x,E.title)*100+Mn(x,E.box);for(let E of o)y+=Mn(x,E)*100;if(y<f&&(f=y,w=x),y===0)break}o.push(w),a.push({said:i,keys:l.map(x=>x.key),...w})}return a}var _i=(e,t,n=2)=>t.x>=e.x-n&&t.x<=e.x+e.width+n&&t.y>=e.y-n&&t.y<=e.y+e.height+n;function tr(e,t){let n=new Set;for(let r of e)(t.edgeId&&r.edgeId===t.edgeId||t.point&&(_i(r.fromBox,t.point)||_i(r.toBox,t.point))||t.ids?.some(o=>r.ids.includes(o))||t.box&&(Mn(t.box,r.fromBox)>0||Mn(t.box,r.toBox)>0))&&n.add(r.key);return n}var ge=se(Ae(),1);function Ki(e){let t=Er(e);return t.length>0?new Map(t.map(n=>[$t(n.edge.kind,n.edge.from,n.edge.to),Rr(n)])):void 0}function Xi({frame:e,width:t,height:n,scheme:r,overview:o,selection:a,emphasis:i,stageRef:l,store:c,graphNodes:d,onPickEdge:s,liveOf:u,holding:h=!1,provisional:g,focusId:w=null,beside:f=!1}){let[x,v]=(0,ye.useState)(0),[y,E]=(0,ye.useState)(null),I=e.t<1,j=(0,ye.useRef)(""),F=(0,ye.useRef)([]),ee=()=>[...l.current?.querySelectorAll("[data-graview-relation] > span")??[]].map(T=>{let G=T.getBoundingClientRect();return`${Math.round(G.left)},${Math.round(G.top)},${Math.round(G.width)}`}).join(" ");(0,ye.useLayoutEffect)(()=>{I||h||(j.current=ee(),F.current=e.nodes,E(Xn(e.nodes,e.connectors,l.current,o,r)))},[e,I,h,a,o,d,r,x,l]),(0,ye.useEffect)(()=>{if(I||h||o||typeof requestAnimationFrame>"u")return;let T=requestAnimationFrame(()=>{ee()!==j.current&&v(G=>G+1)});return()=>cancelAnimationFrame(T)},[y]);let _=e.nodes.map(T=>T.id).join(`
4
+ `);(0,ye.useLayoutEffect)(()=>{let T=l.current;if(T===null||typeof window>"u")return;let G=0,Y=()=>{G===0&&(G=requestAnimationFrame(()=>{G=0,v(k=>k+1)}))};T.addEventListener("scroll",Y,{capture:!0,passive:!0}),window.addEventListener("resize",Y,{passive:!0});let V=typeof ResizeObserver>"u"?null:new ResizeObserver(Y);if(V){V.observe(T);for(let k of T.querySelectorAll("[data-graview-view]"))V.observe(k)}return()=>{G!==0&&cancelAnimationFrame(G),T.removeEventListener("scroll",Y,{capture:!0}),window.removeEventListener("resize",Y),V?.disconnect()}},[l,_]);let[p,S]=(0,ye.useState)(null),A=(y??[]).some(T=>T.tie!==void 0);if((0,ye.useEffect)(()=>{let T=l.current;if(!A||T===null)return;let G=V=>{let k=V.target?.closest?.("[data-graview-pick], [data-graview-view]");S(k?.getAttribute("data-graview-pick")??k?.getAttribute("data-graview-view")??null)},Y=()=>S(null);return T.addEventListener("pointerover",G),T.addEventListener("focusin",G),T.addEventListener("pointerleave",Y),T.addEventListener("focusout",Y),()=>{T.removeEventListener("pointerover",G),T.removeEventListener("focusin",G),T.removeEventListener("pointerleave",Y),T.removeEventListener("focusout",Y)}},[A,l]),I)return null;let O=(y&&h?Yi(y,F.current,e.nodes):y)??Xn(e.nodes,e.connectors,null,o,r),H=new Set;for(let T of O){if(T.edges.length!==1)continue;let G=T.edges[0];H.add(`${T.connector.kind}|${G.from}|${G.to}`)}return(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsx)(Vi,{strands:O,result:e,scheme:r,overview:o,selection:a,emphasis:i,stageRef:l,onPickEdge:s,liveOf:u,pointed:p,...g?{provisional:g}:{}}),o&&yn(a,{overview:o,focusId:w,beside:f},T=>c.graph.getNode(T)?.kind).records.length>0?(0,ge.jsx)(ye.Suspense,{fallback:null,children:(0,ge.jsx)(os,{frame:e,width:t,height:n,stageRef:l,tick:x,store:c,graphVersion:d,selection:a,view:{overview:o,focusId:w,beside:f},rulers:g?{...Ui,unsureOf:(T,G,Y)=>g.get($t(T,G,Y))}:Ui})}):null,o?null:(0,ge.jsx)(is,{...g?{provisional:g}:{},stageRef:l,nodes:e.nodes,scheme:r,selection:a,store:c,graphNodes:d,overview:o,width:t,height:n,onPickEdge:s,alreadyDrawn:H,tick:x})]})}var Ui={visibleRect:Jt,clipQuadratic:Sn,unsureDash:hn,unsureOpacity:fn},ns=un(_t(()=>(__graviewPreload(import.meta.url,["./chunk.JQU5GEU3.js","./chunk.B2GLDIAS.js","./chunk.6YCBYL2Y.js","./chunk.UGFJKSHU.js","./chunk.6QWV5MVH.js","./chunk.MNP4JI33.js","./chunk.AJZBJBMO.js"]),import("./chunk.UATVTXZY.js")))),os=ns.part((e,t)=>(0,ge.jsx)(e.RecordLinks,{...t}),{what:"The links",quiet:!0}),rs=44;function is({stageRef:e,nodes:t,scheme:n,selection:r,store:o,graphNodes:a,overview:i,width:l,height:c,onPickEdge:d,alreadyDrawn:s,tick:u,provisional:h}){let g=Bt(),w=(0,ye.useMemo)(()=>{if(r.length===0||r.length>4)return[];let p=new Set(r),S=[];for(let O of r){let H=It(O);H&&S.push({kind:H.kind,self:H.from,other:H.to})}for(let O of o.graph.allEdges()){let H=p.has(O.from)?O.from:p.has(O.to)?O.to:null;if(!H)continue;let T=H===O.from?O.to:O.from;p.has(T)||S.push({kind:O.kind,self:H,other:T})}if(S.length<=14)return S;let A=new Set(t.map(O=>O.id));return S.map((O,H)=>({tie:O,index:H,real:A.has(O.other)?0:1})).sort((O,H)=>O.real-H.real||O.index-H.index).slice(0,14).map(({tie:O})=>O)},[o,r,a,t]),f=()=>{if(w.length===0||typeof document>"u")return[];let p=e.current?.getBoundingClientRect();if(!p)return[];let S=[...e.current?.querySelectorAll("[data-graview-joins]")??[]].find(k=>{if(k.closest("[data-graview-offstage]"))return!1;try{let $=JSON.parse(k.getAttribute("data-graview-joins")??"[]");return $.length===r.length&&$.every(q=>r.includes(q))}catch{return!1}});if(S){let k=Jt(S,e.current);if(!k)return[];let $=[];for(let q of r){let z=t.find(M=>M.id===q);if(!z)continue;let b=De(e.current,z.id,i)??nt(z,n),R=b?Kn(k,b):null;if(!b||!R)continue;let L=[...o.graph.allEdges()].find(M=>M.from===q&&r.includes(M.to)||M.to===q&&r.includes(M.from));$.push({key:`join:${q}`,self:q,other:"",others:1,kind:L?.kind??"",endX:R.to.x,endY:R.to.y,...R,fromBox:k,toBox:b,proxy:!1,edgeId:L?$t(L.kind,L.from,L.to):null})}return $}let A=(k,$)=>{let q=e.current?.querySelectorAll(`[data-graview-pick="${CSS.escape(k)}"], [data-graview-slot="${CSS.escape(k)}"]`),z=[];for(let b of q??[]){if(b.closest("[data-graview-offstage]")||$(b)||b.closest("[data-graview-mark]"))continue;let R=Jt(b,e.current);R&&z.push(R)}return z.sort((b,R)=>b.width*b.height-R.width*R.height)},O=k=>t.find($=>$.id===k)??t.find($=>$.aggregate?.memberIds.includes(k)),H=k=>`[data-graview-pick="${CSS.escape(k)}"], [data-graview-slot="${CSS.escape(k)}"]`,T=(k,$)=>{let q=e.current;if(!q)return!1;for(let z of q.querySelectorAll("[data-graview-view]")){let b=z.querySelector(H(k));if(b===null||b.closest("[data-graview-offstage]"))continue;let R=z.querySelector(H($));if(R!==null&&!R.closest("[data-graview-offstage]"))return!0}return!1},G=[];if(!i&&e.current){for(let k of t){if(Math.round(k.plane)!==1)continue;let $=De(e.current,k.id,!1);$&&G.push($)}for(let k of e.current.querySelectorAll("[data-graview-relation] > span")){let $=k.getBoundingClientRect();$.width>0&&$.height>0&&G.push({x:$.left-p.left,y:$.top-p.top,width:$.width,height:$.height})}}let Y=new Map,V=[];for(let k of w){if(T(k.self,k.other))continue;let $=O(k.self),q=$?e.current?.querySelector(`[data-graview-view="${CSS.escape($.id)}"]`):null,z=!i&&$?.id===k.self&&Math.round($.plane)===1?De(e.current,$.id,!1):null,b=z?[z]:A(k.self,()=>!1);if(!(b.length>0)&&$){let ae=De(e.current,$.id,!1)??nt($,n);ae&&b.push(ae)}let L=t.find(ae=>ae.id===k.other),M=[],N=!1;if(L){let ae=De(e.current,L.id,i)??nt(L,n);ae&&M.push(ae)}else if(M.push(...A(k.other,ae=>q?q.contains(ae):!1)),M.length===0){let ae=O(k.other);if(ae&&(!$||ae.id!==$.id)){let Se=De(e.current,ae.id,i)??nt(ae,n);Se&&(M.push(Se),N=!0)}}if(b.length===0||M.length===0||N&&i)continue;let P=b[0],B=M[0],te=1/0;for(let ae of b)for(let Se of M){let ot=Math.hypot(ae.x+ae.width/2-(Se.x+Se.width/2),ae.y+ae.height/2-(Se.y+Se.height/2));ot<te&&(te=ot,P=ae,B=Se)}if(s?.has(`${k.kind}|${k.self}|${k.other}`)||s?.has(`${k.kind}|${k.other}|${k.self}`))continue;let U=`${k.kind}:${Math.round(P.x)},${Math.round(P.y)}:${Math.round(B.x)},${Math.round(B.y)}`,W=Y.get(U);if(W){W.others+=1;continue}let J=Kn(P,B);if(!J)continue;let{from:X,control:fe}=J,ie=z&&P===z?en(P,B,G,V.length):void 0,ve=ie?ie[ie.length-1]:J.to,ke=[...o.graph.allEdges()].find(ae=>ae.kind===k.kind&&(ae.from===k.self&&ae.to===k.other||ae.from===k.other&&ae.to===k.self)),$e={key:`${k.kind}:${k.self}:${k.other}`,self:k.self,other:k.other,others:1,kind:k.kind,endX:ve.x,endY:ve.y,from:X,to:ve,control:fe,fromBox:P,toBox:B,...ie?{points:ie}:{},proxy:N,edgeId:ke?$t(ke.kind,ke.from,ke.to):null};Y.set(U,$e),V.push($e)}for(let k of V){let $=[...o.graph.allEdges()].find(L=>L.kind===k.kind&&(L.from===k.self&&L.to===k.other||L.from===k.other&&L.to===k.self)),q=o.graph.getNode(k.self),z=o.graph.getNode(k.other);if(!$||!q||!z)continue;let b=$.from===k.self?"out":"in",R=Mr(o.schema,b==="out"?q.kind:z.kind,k.kind,b);k.said=k.proxy?`${R}: ${Gt(o.schema,z.kind,k.others)}`:`${R}: ${An(o.schema.tryDefinition(z.kind),z)}`}return V},[x,v]=(0,ye.useState)([]),[y,E]=(0,ye.useState)([]);(0,ye.useLayoutEffect)(()=>{let p=f();v(p),E(p.some(S=>S.said)?I(p):[])},[w,t,i,n,l,c,s,u,e]);let I=p=>{let S=e.current;if(!S)return[];let A=[];for(let O of S.querySelectorAll("[data-graview-view]")){let H=[...O.children].find(G=>!G.classList.contains("graview-kind-tag")),T=H?Jt(H,S):null;T&&A.push({box:T,title:{...T,height:Math.min(T.height,rs)}})}return zi(p.flatMap(O=>O.said?[{key:O.key,said:O.said,end:{x:O.endX,y:O.endY},far:O.toBox}]:[]),A,{width:l,height:c})},[j,F]=(0,ye.useState)(()=>new Set),ee=(0,ye.useRef)([]);ee.current=x.map(p=>({key:p.key,fromBox:p.fromBox,toBox:p.toBox,ids:[p.self,p.other],edgeId:p.edgeId}));let _=y.length>0;return(0,ye.useEffect)(()=>{let p=e.current;if(!p||!_)return;let S=k=>F($=>$.size===k.size&&[...k].every(q=>$.has(q))?$:k),A=0,O=null,H=()=>{if(A=0,!O)return;let k=p.getBoundingClientRect(),$=O.target instanceof Element?O.target:null;S(tr(ee.current,{point:{x:O.clientX-k.left,y:O.clientY-k.top},edgeId:$?.closest("[data-graview-edge]")?.getAttribute("data-graview-edge")??null}))},T=k=>{O=k,A||(A=requestAnimationFrame(H))},G=()=>{O=null,S(new Set)},Y=k=>{let $=k.target instanceof Element?k.target:null;if(!$)return;let q=p.getBoundingClientRect(),z=$.getBoundingClientRect(),b=$.closest("[data-graview-pick]")?.getAttribute("data-graview-pick")??$.closest("[data-graview-view]")?.getAttribute("data-graview-view");S(tr(ee.current,{...b?{ids:[b]}:{},box:{x:z.left-q.left,y:z.top-q.top,width:z.width,height:z.height}}))},V=k=>{k.relatedTarget instanceof Node&&p.contains(k.relatedTarget)||S(new Set)};return p.addEventListener("pointermove",T,{passive:!0}),p.addEventListener("pointerleave",G),p.addEventListener("focusin",Y),p.addEventListener("focusout",V),()=>{A&&cancelAnimationFrame(A),p.removeEventListener("pointermove",T),p.removeEventListener("pointerleave",G),p.removeEventListener("focusin",Y),p.removeEventListener("focusout",V)}},[e,_]),x.length===0?null:(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsx)("svg",{"aria-hidden":x.some(p=>p.edgeId)?void 0:!0,"data-graview-ties":x.length,"data-graview-world":"",width:l,height:c,style:{position:"absolute",left:0,top:0,pointerEvents:"none",zIndex:Be.lines},children:x.map(p=>{let{connector:S,style:A}=Qt(g,p.kind);if(!S.visible)return null;let O=p.edgeId?h?.get(p.edgeId):void 0,H={p0:p.from,c:p.control,p1:p.to},T=p.points?Uo(p.points,10):S.route==="orthogonal"?vt([wn(p.from,p.to)]):(({p0:Y,c:V,p1:k})=>`M ${Y.x} ${Y.y} Q ${V.x} ${V.y} ${k.x} ${k.y}`)(_n(S.route,H)),G=null;if(p.edgeId&&d&&!p.proxy){let Y=(k,$)=>$.x>=k.x&&$.x<=k.x+k.width&&$.y>=k.y&&$.y<=k.y+k.height,V=p.points?[...p.points]:[];for(let k=0;k<=(p.points?-1:40);k++){let $=Pi(S.route,H,k/40);Y(p.fromBox,$)||Y(p.toBox,$)||V.push($)}V.length>=2&&(G=(0,ge.jsx)("path",{"data-graview-edge":p.edgeId,className:"graview-edge-hit",d:`M ${V[0].x} ${V[0].y} ${V.slice(1).map(k=>`L ${k.x} ${k.y}`).join(" ")}`,fill:"none",pathLength:1,strokeDasharray:"0.86",strokeDashoffset:-.07,stroke:"transparent",strokeWidth:14,style:{pointerEvents:"stroke",cursor:"pointer"},onClick:k=>{k.stopPropagation(),d(p.edgeId,{x:k.clientX,y:k.clientY})},onContextMenu:k=>{k.preventDefault(),k.stopPropagation(),d(p.edgeId,{x:k.clientX,y:k.clientY})},children:O!==void 0?(0,ge.jsx)("title",{children:O}):null}))}return(0,ge.jsxs)("g",{opacity:(p.proxy?.32:.72)*(O!==void 0?fn:1),children:[(0,ge.jsx)("path",{"data-graview-tie":p.kind,"data-graview-tie-proxy":p.proxy||void 0,"data-graview-provisional":O!==void 0||void 0,d:T,fill:"none",stroke:Kt(A),strokeWidth:p.proxy?1.1:1.6,strokeDasharray:O!==void 0?hn:Cn[A.pattern],strokeLinecap:"round"}),(0,ge.jsx)("circle",{cx:p.endX,cy:p.endY,r:p.proxy?2:2.6,fill:Kt(A)}),G]},p.key)})}),(0,ge.jsx)("div",{"aria-hidden":"true","data-graview-world":"",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:Be.tieLabels},children:y.map(p=>{let S=x.find(A=>A.key===p.keys[0]);return(0,ge.jsx)("span",{className:"graview-record-link-said","data-graview-link-said":S?.kind,"data-graview-lands":S?.proxy?"district":"record","data-graview-said-for":p.keys.length,"data-graview-tie-said":p.keys.some(A=>j.has(A))?"shown":"waiting",style:{position:"absolute",left:p.x,top:p.y,transform:`translateX(min(0px, calc(${Math.round(l-p.x-8)}px - 100%)))`},children:p.said},p.said)})})]})}function qi({nodes:e,scheme:t,width:n,stageRef:r,moving:o=!1,holding:a=!1}){let i=Bt(),[l,c]=(0,ye.useState)([]);(0,ye.useLayoutEffect)(()=>{o||a||c(d())},[e,o,a,t,n,r]);function d(){let s=[];for(let h of e){if(!h.via||Math.round(h.plane)!==1)continue;let g=De(r.current,h.id,!1,!0),{scale:w}=Ut(1,t);s.push({key:`${h.via.edgeKind}|${h.via.direction}`,text:h.via.description??`${h.via.direction==="in"?"\u2190":"\u2192"} ${rn(h.via.edgeKind).toLowerCase()}`,left:g?.x??h.x,right:g?g.x+g.width:h.x+h.width*w,top:g?.y??h.y})}let u=qn(n);return Gi(s,{left:u.left,right:n-u.right})}return l.length===0||!i.captions.visible||o?null:(0,ge.jsx)("div",{"aria-hidden":"true",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:Be.lines},children:l.map(s=>{let{left:u,width:h}=s;return(0,ge.jsx)("div",{"data-graview-relation":s.key,title:s.text,style:{position:"absolute",left:u,width:h,textAlign:"center",top:Math.max(0,s.top-19),fontSize:"0.75rem",letterSpacing:"0.09em",textTransform:"uppercase",color:"var(--graview-ink-faint)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:(0,ge.jsx)("span",{style:{background:"var(--graview-ground)",padding:"1px 7px",borderRadius:4},children:s.text})},s.key)})})}var Yt=se(Te(),1);var ss=new Set;function Zi(e,t,n,r,o,a,i=0,l=0){let{store:c,views:d,hiddenKinds:s}=pe(),u=Pt(),h=(0,Yt.useContext)(zt),g=fo(),w=(0,Yt.useMemo)(()=>{let v={};for(let y of g){if(y.subjectId===void 0)continue;let E=v[y.subjectId]??=[];for(let I of y.nodeIds)I!==y.subjectId&&!E.includes(I)&&E.push(I)}return v},[g]),f=(0,Yt.useMemo)(()=>({flagged:new Set(g.flatMap(v=>v.nodeIds)),touched:Nn(c.log.all())}),[g,c,a]),x=(0,Yt.useMemo)(()=>({hits:u?Pn(u):ss,...f}),[u,f]);return(0,Yt.useMemo)(()=>({...e,cityZoom:r,...h?{besideTheMap:!0}:{},...s.size>0?{hiddenKinds:[...s].sort()}:{},...Object.keys(w).length>0?{judged:w}:{},relevance:x,inset:{...qn((t?.width??1200)-o.right),top:8,bottom:0},chrome:[{x:(t?.width??1200)-o.right-176,y:0,width:176,height:100},ds(t,o)],...o.right>0||o.bottom>0?{dock:o}:{},...i>0?{headroom:i}:{},unit:n,plainGroups:c.schema.kinds.filter(v=>hr(d.lookup(v,{cardinality:"many",fidelity:"full"}))),cityOrder:sr($r({name:"scene",schema:c.schema,mutations:c.allMutations().filter(v=>!v.derived)}).order.map(v=>v.kind),d.arrangement?.()?.order),screens:d.places().reduce((v,y)=>((v[y.kind]??=[]).push({as:y.as,title:y.title,...y.across?{across:y.across}:{}}),v),{}),...t?{width:t.width,height:Math.max(0,t.height-Math.max(64,l))}:{}}),[e,t,n,c,d,s,w,x,r,h,o.right,o.bottom,i,l])}var Qi=224;function ds(e,t){let n=e?.width??1200,r=e?.height??800,o=58;return{x:n-t.right-Qi,y:r-t.bottom-o,width:Qi,height:o}}var dt=se(Te(),1);var Ji=se(Te(),1);function Qn(e){let t=e?.closest?.("[data-graview-pick]")?.getAttribute("data-graview-joins");if(!t)return null;try{let n=JSON.parse(t);return Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string")?n:null}catch{return null}}function ea(e){(0,Ji.useEffect)(()=>{let t=e.current;if(!t)return;let n=()=>{for(let a of t.querySelectorAll("[data-graview-pick]"))a.getAttribute("tabindex")===null&&a.setAttribute("tabindex","0"),a.getAttribute("role")===null&&cs(a)&&a.setAttribute("role","button")};if(n(),typeof MutationObserver>"u")return;let r=0,o=new MutationObserver(()=>{r===0&&(r=typeof requestAnimationFrame>"u"?0:requestAnimationFrame(()=>{r=0,n()}),r===0&&n())});return o.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-graview-pick"]}),()=>{o.disconnect(),r!==0&&cancelAnimationFrame(r)}},[e])}var ls=new Set(["div","span","p","figure","img","td","output","b","i","em","strong","small","canvas","g","polygon","circle","rect","path","ellipse","polyline","line","use"]);function cs(e){return ls.has(e.localName.toLowerCase())}var tn=se(Ae(),1);function ta({node:e,useDom:t,blur:n,touched:r,frontY:o,centerY:a,screen:i,onDrawnHeight:l,crowded:c,activity:d,scheme:s,canvasWidth:u,canvasHeight:h,selected:g,onSelect:w,onPick:f,onTravel:x,onMenu:v,selection:y,onJackIn:E,onDragStart:I,onDragMove:j,onDragEnd:F,swallowClick:ee,children:_}){let{brand:p,store:S,actsDoor:A}=pe(),O=e.beyond?`${e.beyond.length} more district${e.beyond.length===1?"":"s"}`:e.aggregate?.opens?.in==="place"?`${e.aggregate.label}, ${Gt(S.schema,e.aggregate.kind,e.aggregate.memberIds.length)}`:e.aggregate?e.aggregate.label:(()=>{let M=S.graph.getNode(e.id);return M?An(S.schema.tryDefinition(e.kind),M):e.id})(),[H,T]=(0,dt.useState)(null),G=Math.round(e.plane)===0&&!e.aggregate;(0,dt.useLayoutEffect)(()=>{if(!G)return;let M=q.current;if(!M)return;let N=()=>{let B=[...M.children].find(X=>X.dataset.graviewKindtag===void 0);if(!B)return;let te=M.getBoundingClientRect(),U=B.getBoundingClientRect(),W=M.offsetWidth>0?te.width/M.offsetWidth:1,J={top:Math.round((U.top-te.top)/W)-9,right:Math.round((te.right-U.right)/W)+14};T(X=>X&&X.top===J.top&&X.right===J.right?X:J)};if(typeof ResizeObserver>"u"){N();return}let P=new ResizeObserver(N);P.observe(M);for(let B of M.children)P.observe(B);return()=>P.disconnect()},[G,e.id]);let Y=gr({plane:e.plane,...e.depth!==void 0?{depth:e.depth}:{},onPlot:o!==void 0},s),V=Y.style,k=yr(V,e.x,e.y,u,h),$=n?Y.blur:0,q=(0,dt.useRef)(null);ea(q);let z=e.natural,b=z?Math.min(e.width/z.width,e.height/z.height):1,R=(0,dt.useRef)(null);(0,dt.useEffect)(()=>{if(!i||!l)return;let M=R.current;if(!M||typeof ResizeObserver>"u")return;let N=()=>{let W=0,J=0;for(let X of M.children)if(!(!(X instanceof HTMLElement)||X.classList.contains("graview-screen-fullscreen"))){W=Math.max(W,X.offsetTop+X.offsetHeight);for(let fe of[X,...X.querySelectorAll("*")]){let ie=getComputedStyle(fe).overflowY;(ie==="auto"||ie==="scroll")&&(J+=fe.scrollHeight-fe.clientHeight)}}l(W+J)},P=0,B=()=>{P||(P=requestAnimationFrame(()=>{P=0,N()}))};N();let te=new ResizeObserver(B);te.observe(M);for(let W of M.children)te.observe(W);let U=new MutationObserver(B);return U.observe(M,{childList:!0,subtree:!0,characterData:!0,attributes:!0}),()=>{P&&cancelAnimationFrame(P),te.disconnect(),U.disconnect(),l(void 0)}},[i,l,e.id]);let L=t?{transform:Ii(k),transformOrigin:"0 0",filter:$>0?`blur(${$}px)`:void 0,opacity:pr(V)*(e.opacity??1),"--graview-lift-low":Go(V.shadow,s),...o!==void 0?{"--graview-front-y":`${o.toFixed(1)}px`}:{},...a!==void 0?{"--graview-center-y":`${a.toFixed(1)}px`}:{}}:{"--graview-lift-low":Go(V.shadow,s)};return(0,tn.jsxs)("div",{ref:q,"data-graview-view":e.id,...t?{}:{drawable:""},"data-graview-plane":Math.round(e.plane),"data-graview-selected":g||void 0,"data-graview-touched":r||void 0,"data-graview-plot":o!==void 0?"":void 0,"data-graview-screen":i?"":void 0,"data-graview-record-focus":Math.round(e.plane)===0&&!e.aggregate&&!z&&!i?"":void 0,"data-graview-nested":e.nestedUnder??void 0,"data-graview-crowded":c||void 0,"data-graview-pinned":e.pinned||void 0,"data-graview-activity":d?d.manner:void 0,"data-graview-wrote":d?.wrote||void 0,"data-graview-read":d&&!d.wrote?!0:void 0,"data-graview-broke":d?.broke||void 0,title:d?`${ki[d.manner]} ${d.wrote?"changed this":"read this"}: ${d.intent}`:e.aggregate&&Math.round(e.plane)!==0?`Open ${e.aggregate.label}`:void 0,role:"group","aria-label":O,"aria-keyshortcuts":A&&!e.beyond?A.key:void 0,tabIndex:0,onPointerDown:I,onPointerMove:j,onPointerUp:F,onPointerCancel:F,onClick:M=>{if(ee.current)return;let N=M.target?.closest("input, textarea, select, button, a[href], [contenteditable='true']");if(N&&!N.hasAttribute("data-graview-pick"))return;let P=M.metaKey||M.shiftKey,B=gt(M.target);if(B&&B!==e.id){M.stopPropagation(),f(B,P,Qn(M.target)??void 0);return}w(P)},onKeyDown:M=>{if(A&&!e.beyond&&M.key.toLowerCase()===A.key.toLowerCase()&&!M.metaKey&&!M.ctrlKey&&!M.altKey&&!M.target?.closest("input, textarea, select, [contenteditable='true']")){M.preventDefault(),M.stopPropagation();let U=gt(M.target)??e.id;y.includes(U)||f(U,!1),A.open(M.target instanceof HTMLElement?M.target:M.currentTarget);return}if(M.key!=="Enter"&&M.key!==" "||M.target?.closest("input, textarea, select, button, [contenteditable='true']"))return;let P=gt(M.target);if(M.preventDefault(),M.stopPropagation(),!P||P===e.id){y.length===1&&y[0]===e.id&&!M.metaKey&&!M.shiftKey?E():w(M.metaKey||M.shiftKey);return}let B=Qn(M.target);(B?y.length===B.length&&B.every(U=>y.includes(U)):y.length===1&&y[0]===P)&&!M.metaKey&&!M.shiftKey?x(P):f(P,M.metaKey||M.shiftKey,B??void 0)},onContextMenu:M=>{let N=gt(M.target);M.preventDefault(),M.stopPropagation();let P=N&&N!==e.id?N:e.id;f(P,!1,(P===N?Qn(M.target):null)??void 0),v({x:M.clientX,y:M.clientY,on:P})},onDoubleClick:M=>{let N=gt(M.target);if(N&&N!==e.id){M.stopPropagation(),x(N);return}E()},style:{position:"absolute",...t?{}:{pointerEvents:"none"},zIndex:e.opened?Be.opened:Be.card-Math.round(e.plane),left:t?0:Math.round(e.x),top:t?0:Math.round(e.y),width:Math.round(e.width),height:Math.round(e.height),boxSizing:"border-box",display:"flex",flexDirection:"column",justifyContent:"center",...L},children:[z?(0,tn.jsx)("div",{ref:R,"data-graview-natural":`${Math.round(z.width)}x${Math.round(z.height)}`,style:{position:"absolute",left:"50%",top:"50%",width:z.width,height:z.height,transform:`translate(-50%, -50%) scale(${b})`,transformOrigin:"50% 50%",display:"flex",flexDirection:"column"},children:_}):_,Math.round(e.plane)===0&&!e.aggregate?(0,tn.jsxs)("span",{"data-graview-kindtag":"",className:"graview-kind-tag","aria-hidden":"true",style:{...H??{},"--graview-hue":Math.round(sn(e.kind,p?.accents))},children:[(0,tn.jsx)("span",{style:{width:9,height:6,clipPath:"polygon(50% 0, 100% 50%, 50% 100%, 0 50%)",flex:"0 0 auto",background:`hsl(${Math.round(sn(e.kind,p?.accents))} 55% var(--graview-tint-lightness) / 0.9)`}}),ir(S.schema.tryDefinition(e.kind),e.kind)]}):null]})}var ue=se(Ae(),1);ho({search:Dr,touchWeights:Nn});var us=e=>e?{activity:e}:{},hs=e=>`${Math.round(e.x)} ${Math.round(e.y)}`,na=e=>e.stopPropagation(),aa=.6,sa=3,fs=80,oa=e=>Math.round(e.plane)===1&&(e.compact===!0||e.width<175||e.height<fs);function ms(e){let[t,n]=(0,Q.useState)(1),r=(0,Q.useRef)(1);return(0,Q.useEffect)(()=>{e||(r.current=1,n(1))},[e]),[t,r,n]}function ys(e){let[t,n]=(0,Q.useState)({x:0,y:0}),r=(0,Q.useMemo)(()=>({x:(e.pan?.x??0)+t.x,y:(e.pan?.y??0)+t.y}),[e.pan,t]),o=(0,Q.useMemo)(()=>t.x===0&&t.y===0?e:Ht(e,r),[e,t,r]),a=(0,Q.useRef)(t);a.current=t;let i=(0,Q.useCallback)((l,c)=>{let d=a.current,s=(u,h,g)=>Math.max(Math.min(-u,h),Math.min(Math.max(u,h),g+h))-h;return{x:s(l.x,d.x,c.x),y:s(l.y,d.y,c.y)}},[]);return[r,o,i,a,n]}function gs(e,t,n,r,o,a){let i=n!==null&&!t.overview,l=i?null:n,c=(0,Q.useMemo)(()=>{let h=t.pan?{...t,pan:void 0}:t;return l?mn(h,l.id,{x:l.x,y:l.y}):h},[t,l]),d=(0,Q.useMemo)(()=>Dn(e.graph,e.schema,c,r),[e,c,r,o]),s=(0,Q.useMemo)(()=>n&&i?No(d,n.id,{x:n.x,y:n.y})??Dn(e.graph,e.schema,mn(c,n.id,{x:n.x,y:n.y}),r):d,[d,n,i,e,c,r]);return[(0,Q.useMemo)(()=>Bo(s,a??{x:0,y:0}),[s,a]),i]}function ps(){let[e,t]=(0,Q.useState)(!1),[n,r]=(0,Q.useState)(!1),o=(0,Q.useRef)(null),a=(0,Q.useRef)(()=>!1),i=(0,Q.useCallback)(()=>{r(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{o.current=null,!a.current()&&r(!1)},160)},[]);return[e,n,t,i,a,()=>{t(!1),r(!1)}]}function xs(e){let t=(0,Q.useRef)(!1),n=e!==null&&!t.current;return(0,Q.useEffect)(()=>{e!==null&&(t.current=!0)},[e]),n}function bs({registerScene:e,scheme:t,views:n},r,o){let a=(0,Q.useRef)(r);a.current=r,(0,Q.useEffect)(()=>(e({whereIs:i=>Gn(a.current,o.current,t,n,i)}),()=>e(null)),[e,t,n])}function ws(e,t){(0,Q.useEffect)(()=>{let n;return e.onActive(r=>{let o=t.current;if(!o)return;let a=l=>{let c=o.getBoundingClientRect();e.set({x:l.clientX-c.left,y:l.clientY-c.top})},i=()=>e.set(null);r?(o.addEventListener("pointermove",a),o.addEventListener("pointerleave",i),n=()=>{o.removeEventListener("pointermove",a),o.removeEventListener("pointerleave",i)}):(n?.(),n=void 0)})},[e])}function vs(e,t,n,r,o,a,i,l){(0,Q.useEffect)(()=>{let c=t.current;if(!c||!e)return;let d=new Set;for(let u of n.nodes)(r.has(u.id)||u.aggregate?.memberIds.some(h=>r.has(h)))&&d.add(u.id);let s=e({canvas:c,layout:n,dirty:d,hostOf:u=>(c.parentElement??c).querySelector(`[data-graview-view="${CSS.escape(u)}"]`),drawOnDom:o,blur:a,scheme:i,fallBack:l});return()=>{s?.()}},[e,n,r,o,a,i,l])}var ks=_t(()=>(__graviewPreload(import.meta.url,["./chunk.OJGHDWI6.js","./chunk.MNP4JI33.js","./chunk.AJZBJBMO.js"]),import("./chunk.CN3UEF5N.js")));function Ss(e,t){let[n]=(0,Q.useState)(()=>{let s=br();return t?e==="dom"||e==="auto"&&s==="dom"?"dom":"gpu":vr(e,{operator:s,present:wr()})}),[r,o]=(0,Q.useState)(!1),a=(0,Q.useCallback)(()=>o(!0),[]),[i,l]=(0,Q.useState)(null),c=n==="gpu"&&!t&&!r&&i===null;return(0,Q.useEffect)(()=>{if(!c)return;let s=!0;return ks().then(u=>{s&&l(()=>u.attachGpu())},()=>{s&&o(!0)}),()=>{s=!1}},[c]),{attach:(n==="gpu"&&!r?t??i:null)??null,fallBack:a}}function Ms(){let[e,t]=(0,Q.useState)(()=>new Set),n=(0,Q.useCallback)(r=>{t(o=>o.size===r.size&&[...r].every(a=>o.has(a))?o:new Set(r))},[]);return[e,n]}function Rs(){let e=Or();return t=>{let n=t?e.get(t.id):void 0,r=t?.aggregate?.memberIds??[];if(!n&&r.length===0)return;let o=n,a=n?.wrote??!1,i=n?.read??!1,l=n?.broke??!1;for(let c of r){let d=e.get(c);d&&(a||=d.wrote,i||=d.read,l||=d.broke,(!o||d.at>o.at||d.at===o.at&&d.wrote&&!o.wrote)&&(o=d))}return o?{...o,wrote:a,read:i,broke:l}:void 0}}var ra=(e,t)=>e.includes(t)?e.filter(n=>n!==t):[...e,t];function Es(){let{views:e,view:t,setView:n,setSelection:r}=pe(),o=Pt(),a=(0,Q.useContext)(zt),i=l=>{if(Oe(l.id)===null&&!l.aggregate)return!1;let c=e.resolve(l.kind,{cardinality:"many",fidelity:"full"})?.view;return c!==void 0&&c.generic!==!0};return l=>({onSelect:c=>{if(cn(l.id)){r(s=>c?ra(s,l.id):[l.id]);return}let d=l.aggregate?ln(l.id):[];if(t.overview){r(s=>c?[...new Set([...s,l.id])]:[l.id]);return}if(d.length===1&&!c&&Math.round(l.plane)!==0){let s=d[0];n(u=>ao(u,u.relation===s?null:s));return}r(s=>Vo(l,s,c))},onPick:(c,d,s)=>r(u=>s?d?[...new Set([...u,...s])]:[...s]:d?ra(u,c):[c]),onTravel:c=>{n(d=>({...mt(d,c),relation:null})),r([c])},onJackIn:()=>{let c=l.aggregate?.opens;if(c){c.in==="place"?n(u=>so(u,l.id)):n(u=>Object.entries(c.within).reduce((h,[g,w])=>Tn(h,g,w),mt(dn(u,!1),c.focus))),r([]);return}let d=Oe(l.id),s=d!==null&&(o?.byKind[d]??0)>0;if(a&&d!==null&&t.overview&&!i(l)&&!(s&&t.q)){n(u=>Tn({...mt(u,`aggregate:${d}`),relation:null},"view",null)),r([]);return}n(u=>lo(u,l.id,{ownPicture:i(l),...s&&u.q?{carry:u.q}:{}})),r(l.aggregate?[]:[l.id])}})}var Os=un(_t(()=>(__graviewPreload(import.meta.url,["./chunk.XDYAG276.js","./chunk.HJCQ6I3S.js","./chunk.MWGGV7DE.js","./chunk.JQU5GEU3.js","./chunk.B2GLDIAS.js","./chunk.6YCBYL2Y.js","./chunk.UGFJKSHU.js","./chunk.6QWV5MVH.js","./chunk.MNP4JI33.js","./chunk.AJZBJBMO.js"]),import("./chunk.CDP2XL66.js")))),Ls=Os.part((e,t)=>(0,ue.jsx)(e.Ribbons,{...t}),{what:"The relations",quiet:!0}),ia="graview:map-from-above";function As(){let[e,t]=(0,Q.useState)(()=>{try{return globalThis.localStorage?.getItem(ia)==="1"}catch{return!1}}),n=(0,Q.useCallback)(r=>{t(r);try{globalThis.localStorage?.setItem(ia,r?"1":"0")}catch{}},[]);return[e,n]}var Is=un(_t(()=>(__graviewPreload(import.meta.url,["./chunk.XDYAG276.js","./chunk.MWGGV7DE.js","./chunk.6UGEYZAC.js","./chunk.6QWV5MVH.js","./chunk.MNP4JI33.js","./chunk.AJZBJBMO.js"]),import("./chunk.DYSPCGXX.js")))),Ts=Is.part((e,t)=>(0,ue.jsx)(e.Plots,{...t}),{quiet:!0});function Ps({zoom:e,zoomBy:t,above:n,setAbove:r}){let o=(a,i,l,c)=>(0,ue.jsx)("button",{type:"button",className:"graview-zoom-button","data-testid":`zoom-${a}`,"aria-label":`Zoom ${a}`,title:`Zoom ${a} \u2014 or pinch, or ctrl+wheel`,disabled:c,onClick:()=>t(l),children:i});return(0,ue.jsxs)("div",{className:"graview-zoom","data-graview-foot":"",role:"group","aria-label":"Zoom",onPointerDown:na,onClick:na,children:[o("out","\u2212",1/1.25,e<=aa+1e-6),(0,ue.jsxs)("span",{className:"graview-zoom-level","data-testid":"zoom-level","aria-live":"polite",children:[Math.round(e*100),"%"]}),o("in","+",1.25,e>=sa-1e-6),(0,ue.jsx)("button",{type:"button",className:"graview-zoom-button graview-zoom-above","data-testid":"from-above","aria-pressed":n,title:n?"See the city at an angle again":"See the city from straight above",onClick:()=>r(!n),children:"From above"})]})}function Cs({options:e,renderer:t="auto",attachRenderer:n,blur:r=!0,className:o,style:a,animate:i=!0,children:l}){let c=pe(),{store:d,scheme:s,views:u,view:h,setView:g,selection:w,setSelection:f,setMenuAt:x,emphasis:v,brand:y,noteMoved:E,robots:I,motion:j}=c,F=(0,Q.useContext)(zt),ee=(0,Q.useRef)(null),_=(0,Q.useRef)(null),p=Ai(_),S=Li(),{zoomAbout:A,panBy:O}=vi({stage:_,view:h,setView:g}),H=Ct(),T=1,[G,Y,V]=ms(h.overview),[k,$]=As(),q=(0,Q.useMemo)(()=>k?{...e,tilt:Wr}:e,[e,k]),{probe:z,dock:b}=pi(),R=!h.overview&&(h.zoom||h.past||h.relation)?Math.ceil(14+34*S/16+6):0,L=Zi(q,p,S,T*G,b,H,R,h.overview?0:b.bottom),M=fi(_),[N,P,B,te,U]=ys(h),W=(0,Q.useMemo)(()=>new Set(Object.keys(h.pins).filter(C=>Oe(C)===null)),[h.pins]),J=xi(),[X,fe]=gs(d,h,J.held,L,H,P.pan),[ie,ve,ke,$e,ae,Se]=ps(),ot=xs(p),oe=ii(X,{enabled:i&&!ie&&!ve&&p!==null&&!ot});(0,Q.useEffect)(()=>j.set(ie||ve||oe.t<1),[j,ie,ve,oe]);let Ge=ai(),Ze=si(),kt=mi({view:h,result:X,frame:oe,panned:N,closer:T,screenId:null,setCamera:U});bs(c,oe,_),ws(c.pointer,_);let[Je,Ce]=Ms(),{attach:lt,fallBack:rt}=Ss(t,n),We=oi(r);vs(lt,ee,oe,Ge,Ce,We,s,rt);let Ne=lt===null,je=ri(We&&Ne,ie||ve||oe.t<1),_e=Rs(),ze=bi({stage:_,pan:h.pan,setView:g,settled:Se});ae.current=ze.settle;let{onGroundDown:Ye,onCardDown:ct,onDragMove:St,onDragUp:ut,swallow:et}=wi({view:h,panned:N,limit:()=>pt(X),panWithin:B,moveByTransform:!0,setView:g,setDragging:ke,noteMoved:E,shift:ze,district:J});A.current=(C,he,ce)=>{if(!h.overview)return;ae.current();let Re=Y.current,tt=Math.max(aa,Math.min(sa,Re*C));if(Math.abs(tt-Re)<1e-4)return;Y.current=tt,$e(),V(tt);let Et=_.current?.getBoundingClientRect(),En=X.visible??X,Ot={x:En.width/2,y:En.height/2},Zn=Et&&he!==void 0&&ce!==void 0?{x:he-Et.left,y:ce-Et.top}:Ot,Jn=tt/Re;g(Vt=>Ht(Vt,Po(Vt.pan??{x:0,y:0},te.current,Zn,Ot,Jn))),E()};let re=(C,he,ce=pt(X))=>g(Re=>Ht(Re,B(ce,{x:(Re.pan?.x??0)+C,y:(Re.pan?.y??0)+he})));gi(_,b,(C,he)=>re(C,he)),O.current=(C,he)=>{$e();let ce=pt(X),Re=h.pan??{x:0,y:0},tt=ze.offset();ze.shiftTo(B(ce,{x:Re.x+tt.x+C,y:Re.y+tt.y+he}),Re),E()};let Me=Es(),it=Bt(),Mt=(0,Q.useCallback)(C=>Qt(it,C).connector.visible,[it]),ht=C=>_e(oe.nodes.find(he=>he.id===C)),ft=(C,he,ce,Re)=>C.originY+N.y+Zt(ce.col+ce.side/Re,ce.row+ce.side/Re,C.cell,C.tilt).y-he.y,Ie={width:X.width,height:X.height},nn={position:"relative",zIndex:Be.stage,...Ie},Rn=C=>Gn(oe,_.current,s,u,C),Rt=C=>Ne||Je.has(C),Ue=oe.nodes.filter(C=>C.screenOf===void 0).map(C=>(0,ue.jsx)(ta,{node:C,crowded:oa(C),useDom:Rt(C.id),blur:je||!Ne&&We,...C.plot&&oe.city&&Math.round(C.plane)===2?{frontY:ft(oe.city,C,C.plot,1),centerY:ft(oe.city,C,C.plot,2)}:{},touched:Ge.has(C.id),...us(_e(C)),scheme:s,canvasWidth:X.width,canvasHeight:X.height,selected:w.includes(C.id),...Me(C),onMenu:x,selection:w,onDragStart:he=>ct(C,he),onDragMove:St,onDragEnd:ut,swallowClick:et,children:C.beyond?(0,ue.jsx)(Mi,{kinds:C.beyond}):C.aggregate?.opens?(0,ue.jsx)(Oi,{node:C}):(0,ue.jsx)(Ri,{node:C,mode:"scene",selected:w.includes(C.id),...oa(C)?{fidelity:"glyph"}:{}})},C.id));return(0,ue.jsxs)("div",{ref:_,className:`graview-ground${o?` ${o}`:""}`,"data-graview-altitude":h.overview?"":void 0,"data-graview-reach":oe.city?hs(pt(X)):void 0,"data-graview-settled":oe.t>=1&&!kt.gliding()?"":void 0,"data-graview-box":p?`${p.width}x${p.height}`:void 0,"data-graview-renderer":Ne?"dom":"gpu","data-graview-blur":(Ne?je:We)?"":void 0,onPointerDown:Ye,onPointerMove:St,onPointerUp:ut,onPointerCancel:ut,onClick:C=>{et.current||C.target.closest("[data-graview-view], button, aside, section[aria-label], [data-graview-offstage], a, input, select")||(f([]),x(null))},style:{position:"relative",width:"100%",height:"100%",cursor:ie?"grabbing":"grab",touchAction:"none","--graview-altitude":h.overview?1:0,...oe.city?{"--graview-lattice-cell":`${oe.city.cell.toFixed(2)}px`,"--graview-lattice-tilt":(oe.city.tilt??.5).toFixed(3),"--graview-lattice-x":`${(oe.city.originX+oe.city.pan.x).toFixed(1)}px`,"--graview-lattice-y":`${(oe.city.originY+oe.city.pan.y).toFixed(1)}px`}:{},...ie?{userSelect:"none"}:{},overflow:"hidden",...a},children:[h.overview&&oe.city?(0,ue.jsx)(Q.Suspense,{fallback:null,children:(0,ue.jsx)(Ls,{frame:oe,...Ie,pan:oe.city.pan,store:d,graphVersion:H,selection:w,view:{overview:h.overview,focusId:h.focusId,beside:F},emphasis:v,hiddenKinds:c.hiddenKinds,drawn:Mt})}):null,(0,ue.jsx)("div",{ref:z,"aria-hidden":"true",style:{position:"absolute",top:0,right:0,width:"var(--graview-dock, 0px)",height:"var(--graview-sheet, 0px)",visibility:"hidden",pointerEvents:"none"}}),oe.city?(0,ue.jsx)(Q.Suspense,{fallback:null,children:(0,ue.jsx)(Ts,{frame:oe,...Ie,pan:oe.city?oe.city.pan:N,brand:y,pinned:W,close:T*G>1.2,swallowed:et,...h.overview?{chosen:yn(w,{overview:h.overview,focusId:h.focusId,beside:F},C=>d.graph.getNode(C)?.kind).records}:{},onFocus:C=>{let he=Oe(C);he!==null&&g(ce=>mt(ce,Le(he)))}})}):null,Ne?(0,ue.jsx)("div",{"data-graview-stage":"dom","data-graview-world":"",style:{...nn,overflow:"hidden"},children:Ue}):(0,ue.jsxs)("div",{"data-graview-world":"",style:nn,children:[(0,ue.jsx)("div",{"data-graview-stage":"dom","data-graview-under-canvas":"",style:{position:"absolute",left:0,top:0,...Ie,overflow:"hidden"},children:Ue.filter(C=>Je.has(String(C.key)))}),(0,ue.jsx)("canvas",{ref:ee,"data-graview-stage":"gpu",content:"drawable",layoutsubtree:"",...Ie,style:{display:"block",position:"relative",...Ie},children:Ue.filter(C=>!Je.has(String(C.key)))})]}),h.overview&&!ie?(0,ue.jsx)(ui,{result:X,schema:d.schema,chrome:M?[...L.chrome??[],M]:L.chrome??[],onGo:C=>{re(C.x,C.y),E()}}):null,h.overview?(0,ue.jsx)(Ps,{zoom:G,zoomBy:C=>A.current(C),above:k,setAbove:$}):null,(0,ue.jsx)(Xi,{frame:oe,focusId:h.focusId,beside:F,holding:fe,...Ie,scheme:s,overview:!!h.overview,selection:w,emphasis:v,stageRef:_,store:d,graphNodes:H,...(C=>C?{provisional:C}:{})(Ki(d)),onPickEdge:(C,he)=>{et.current||(f([C]),x(he?{...he,on:C}:null))},liveOf:C=>{let he=ht(C.from),ce=ht(C.to);return he?.wrote&&ce?.wrote?he.at>ce.at?he:ce:void 0}}),(0,ue.jsx)(li,{width:X.width,whereIs:Rn}),(0,ue.jsx)(di,{marks:Ze.marks,questions:[...I.values()].filter(C=>C.mode==="asking"&&C.at!==null&&C.say).map(C=>({id:C.at,who:C.who,asks:C.say})),whereIs:Rn,stageRef:_,...Ie}),(0,ue.jsx)(qi,{nodes:oe.nodes,moving:oe.t<1,holding:fe,scheme:s,width:X.width,stageRef:_}),l]})}var Qe=se(Te(),1);function Ns(){return ua(),null}var ca=()=>window.location.pathname.endsWith(ar),da=()=>(ca()?lr:io)(window.location.hash),Bs=e=>(ca()?cr:ro)(e);function ua(){let{view:e,setView:t,views:n,principal:r}=pe(),o=JSON.stringify(r),a=(0,Qe.useCallback)(s=>{let u=s.within?.view;if(u===void 0||s.focusId)return s;let h=n.places().find(g=>g.as===u);return h?{...s,focusId:Le(h.kind)}:s},[n]),i=(0,Qe.useRef)(!1);(0,Qe.useEffect)(()=>{if(typeof window>"u")return;let s=a(da());!In(s,oo)&&!In(s,e)&&(i.current=!0,t(s))},[]),(0,Qe.useEffect)(()=>{if(typeof window>"u")return;let s=()=>t(a(da()));return window.addEventListener("popstate",s),window.addEventListener("hashchange",s),()=>{window.removeEventListener("popstate",s),window.removeEventListener("hashchange",s)}},[t,a]);let l=(0,Qe.useRef)(!1),c=(0,Qe.useRef)(null),d=(0,Qe.useRef)(o);(0,Qe.useEffect)(()=>{if(typeof window>"u")return;if(i.current){i.current=!1;return}let s=d.current!==o;d.current=o;let u=Bs(e),h=u||`${window.location.pathname}${window.location.search}`;if((window.location.hash||(window.location.href.includes("#")?"#":""))===u){l.current=!0,c.current=e;return}if(!l.current){l.current=!0,c.current=e,window.history.replaceState({graview:Nt.at},"",h);return}if(s||ha(c.current,e)){window.history.replaceState({graview:Nt.at},"",h),c.current=e;return}c.current=e,window.history.pushState({graview:++Nt.at},"",h),Nt.depth=Nt.at,Nt.tell()},[e,o])}function ha(e,t){return e?e.focusId===t.focusId&&e.relation===t.relation&&(e.overview??!1)===(t.overview??!1)&&(e.zoom??!1)===(t.zoom??!1)&&(e.past??!1)===(t.past??!1)&&e.expanded.join(",")===t.expanded.join(",")&&(e.shown??[]).join(",")===(t.shown??[]).join(",")&&$s(e.within,t.within):!1}function $s(e,t){let n=r=>Object.entries(r??{}).sort(([o],[a])=>o.localeCompare(a)).map(([o,a])=>`${o}=${a}`).join("&");return n(la(e))===n(la(t))}function la(e){if(!e||!("q"in e))return e;let{q:t,...n}=e;return n}var nr=se(Te(),1);function Hs(e={}){let{store:t,selection:n,principal:r,providers:o}=pe(),{about:a,...i}=e,l=a??n,c=Ct();return(0,nr.useMemo)(()=>{let d=[...new Set(l.flatMap(u=>ln(u)))],s=l.map(u=>It(u)).filter(u=>u!==null);return Cr(t,l,{principal:r,kindSelection:d,edgeSelection:s,...o?{providers:o}:{},...i})},[t,l,e,c,r,o])}function Ds(){let{store:e,principal:t}=pe();return(0,nr.useMemo)(()=>({preview:(n,r)=>Br(e,n,r??{}),apply:(n,r)=>Nr(e,n,r??{},{author:t})}),[e,t])}export{Sa as a,Ma as b,Ra as c,Ea as d,Oa as e,La as f,Cs as g,Ns as h,Hs as i,Ds as j};
@@ -0,0 +1 @@
1
+ import{a as b,b as c,c as d,d as e,e as f}from"./chunk.GV2CQVKV.js";import"./chunk.4HZ7QTXZ.js";import"./chunk.3TY5NFLY.js";import"./chunk.FWTIUYXH.js";import"./chunk.MAF7C3VM.js";import{ib as a}from"./chunk.MNP4JI33.js";import"./chunk.AJZBJBMO.js";export{a as ActRefusal,e as compileDocumentWithoutCheck,d as effectsOf,f as inDocumentWords,c as kindShapes,b as readDocument};
@@ -0,0 +1 @@
1
+ import{c as b,d as J}from"./chunk.B2GLDIAS.js";import{a as O,f as q}from"./chunk.UGFJKSHU.js";import{$a as D,Ab as w,B as m,Ea as j,Fa as A,Pa as v,ab as L,bb as N,gc as Z,hc as k,ja as R,ma as x,ta as S,vb as M,zb as P}from"./chunk.MNP4JI33.js";var E=n=>n.safeParse?.(void 0).success??!1,T=n=>b(n).shape,F=n=>{let s=b(n);if(m(s)?.type!=="literal")return;let e=m(s)?.values;return e&&e.length===1&&typeof e[0]=="string"?e[0]:void 0};function g(n,s){let e=E(s),o=b(s),r=m(o)?.type,l=M(s);if(l)return{control:"node",name:n,optional:e,kinds:l};let y=S(s);if(y)return{control:"linked",name:n,optional:e,relation:y};if(A(s)){let a=j(n);return{control:"repeat",name:n,optional:e,...a?{of:a}:{}}}if(r==="boolean")return{control:"boolean",name:n,optional:e};let p=R(o);if(p)return{control:"file",name:n,optional:e,...p==="image"?{image:!0}:{}};if(r==="object"){let a=o.shape??{};return{control:"group",name:n,optional:e,fields:Object.entries(a).map(([c,d])=>g(c,d))}}if(r==="union"){let a=m(o)?.options??[],c=a.map(t=>T(t));if(c.every(t=>t!==void 0)){let t=Object.keys(c[0]??{}).find(f=>c.every(u=>F(u?.[f])!==void 0));if(t)return{control:"variant",name:n,optional:e,tag:t,options:a.map((f,u)=>({value:F(c[u]?.[t])??"",fields:Object.entries(c[u]??{}).filter(([h])=>h!==t).map(([h,z])=>g(h,z))}))}}let d=a.map(t=>F(t));return d.every(t=>t!==void 0)?{control:"choice",name:n,optional:e,options:d}:{control:"opaque",name:n,optional:e}}if(r==="array"){let a=m(o)?.element;return a!==void 0?{control:"list",name:n,optional:e,item:g(n,a)}:{control:"opaque",name:n,optional:e}}let i=J(s);return i.type==="text"?{control:"text",name:n,optional:e,...i.long?{long:!0}:{},...x(o)?{app:!0}:{},...O(o)?{markdown:!0}:{},...i.holds?{holds:i.holds}:{}}:i.type==="number"&&i.duration?{control:"text",name:n,optional:e,holds:"duration"}:i.type==="date"?{control:"date",name:n,optional:e,...i.time?{time:!0}:{},...i.instant?{instant:!0}:{}}:i.type==="number"?{control:"number",name:n,optional:e,...i.min===void 0?{}:{min:i.min},...i.max===void 0?{}:{max:i.max},...i.step===void 0?{}:{step:i.step},...i.amount?{amount:i.amount}:{}}:i.type==="choice"?{control:"choice",name:n,optional:e,options:i.options}:{control:"opaque",name:n,optional:e}}function B(n){let s=n.shape;return s?Object.entries(s).map(([e,o])=>g(e,o)):[]}function K(n,s){let e={...s};for(let o of n){let r=s[o.name];r===void 0&&!o.optional&&(o.control==="list"||o.control==="boolean")&&(e[o.name]=o.control==="list"?[]:!1),o.control==="text"&&o.holds&&typeof r=="string"&&(e[o.name]=r.trim()===""?void 0:o.holds==="duration"?q(r)??r:r.trim()),o.control==="group"&&r!==void 0&&typeof r=="object"&&r!==null&&(e[o.name]=K(o.fields,r))}return e}function C(n,s,e){let o=n.derived?.act==="edit"&&n.subject?e[n.subject.arg]:void 0,r=typeof o=="string"?s.getNode(o):void 0;return r?Object.fromEntries((n.writes??[]).filter(l=>r[l]!==void 0&&r[l]!==null).map(l=>[l,r[l]])):{}}function I(n,s){return Object.fromEntries(Object.entries(n).filter(([e,o])=>!Object.hasOwn(s,e)||JSON.stringify(o)!==JSON.stringify(s[e])))}function _(n,s,e,o){let r=Z.keptFrom?.(n,s),l=new Set;if(!r)return l;let y=Object.keys(e.input.shape??{});for(let c of e.creates??[]){let d=r({id:"\0new",kind:c});for(let t of y)d?.(t)&&l.add(t)}let p=o===void 0?void 0:n.graph.getNode(o),i=p&&n.schema.tryDefinition(p.kind),a=p&&r(p);if(i&&a)for(let c of w(e,i))a(c)&&y.includes(c)&&l.add(c);return l}function dn(n,s,e,o){let r=new Set,l=s?.sees??[];if(L(e)||!l.some(k))return r;let y=D(e),p=(d,t)=>{let f=l.filter(u=>u.kinds.includes(d)&&N(u,y));return f.some(k)?v.has(t)||f.some(u=>!k(u)||(u.fields===void 0||u.fields.includes(t))&&!u.hide?.includes(t)):!0},i=Object.keys(o.input.shape??{}),a=new Map,c=(d,t)=>a.set(d,a.get(d)===!0||t);for(let d of o.creates??[]){let t=Object.keys(n.tryDefinition(d)?.fields.shape??{});for(let f of i)t.includes(f)&&c(f,p(d,f))}for(let d of P(n,o)){let t=n.tryDefinition(d);if(t)for(let f of w(o,t))i.includes(f)&&c(f,p(d,f))}for(let[d,t]of a)t||r.add(d);return r}export{B as a,K as b,C as c,I as d,_ as e,dn as f};