graview 0.1.45 → 0.1.47

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 (145) hide show
  1. package/dist/preview/{chunk.L2PI7V4R.js → chunk.24OZGU7J.js} +1 -1
  2. package/dist/preview/{chunk.EVW5YY3W.js → chunk.2CLANQHZ.js} +1 -1
  3. package/dist/preview/{chunk.URXSZQSF.js → chunk.2L3VFGHX.js} +1 -1
  4. package/dist/preview/chunk.2MCZ4CU5.js +1 -0
  5. package/dist/preview/{chunk.R2AG4NHQ.js → chunk.2W22AWSL.js} +1 -1
  6. package/dist/preview/chunk.3LDYUO77.js +1 -0
  7. package/dist/preview/{chunk.JR7RDOEP.js → chunk.47RTA6M3.js} +1 -1
  8. package/dist/preview/chunk.4OGOTHRD.js +1 -0
  9. package/dist/preview/{chunk.WPOTEXJZ.js → chunk.4YS7547F.js} +1 -1
  10. package/dist/preview/{chunk.6X3G3PWL.js → chunk.4YXJPKXD.js} +1 -1
  11. package/dist/preview/{chunk.UNCS63AM.js → chunk.52VGZBO3.js} +1 -1
  12. package/dist/preview/{chunk.PRD3UNJX.js → chunk.57ZSMK3R.js} +1 -1
  13. package/dist/preview/{chunk.6MADC6DM.js → chunk.5AGW4NRZ.js} +1 -1
  14. package/dist/preview/chunk.5G53VDOC.js +1 -0
  15. package/dist/preview/chunk.5M4TMZXC.js +1 -0
  16. package/dist/preview/{chunk.GEPNIMXW.js → chunk.5TM5VA2H.js} +1 -1
  17. package/dist/preview/{chunk.Y5ARSVH4.js → chunk.63MS2LOP.js} +1 -1
  18. package/dist/preview/{chunk.HGTPTRMM.js → chunk.6QVXXQCW.js} +1 -1
  19. package/dist/preview/{chunk.UM7GWXEW.js → chunk.6TIEX67B.js} +1 -1
  20. package/dist/preview/chunk.6YD2DLIC.js +1 -0
  21. package/dist/preview/chunk.76GF5US2.js +50 -0
  22. package/dist/preview/{chunk.55D33E5A.js → chunk.7ELB37JU.js} +1 -1
  23. package/dist/preview/chunk.7N2GXZYI.js +3 -0
  24. package/dist/preview/{chunk.EAUVEVVO.js → chunk.7NNI7YH4.js} +1 -1
  25. package/dist/preview/{chunk.KUUDW7VR.js → chunk.A3RNSSUQ.js} +1 -1
  26. package/dist/preview/{chunk.W44VRHKS.js → chunk.A7RKTSOH.js} +2 -2
  27. package/dist/preview/{chunk.CBUSFM3E.js → chunk.AGIO2GRV.js} +29 -7
  28. package/dist/preview/{chunk.QPCSS322.js → chunk.AWXDZUKH.js} +1 -1
  29. package/dist/preview/{chunk.5EDA3JHU.js → chunk.AYA7SYIU.js} +1 -1
  30. package/dist/preview/{chunk.T7XH7FVJ.js → chunk.BBS5C2BY.js} +1 -1
  31. package/dist/preview/{chunk.L3FOLN3K.js → chunk.C3NHNYA6.js} +1 -1
  32. package/dist/preview/{chunk.S5MQVPLF.js → chunk.C44MC5X3.js} +1 -1
  33. package/dist/preview/{chunk.L3FQZCWI.js → chunk.CMOXKRWT.js} +1 -1
  34. package/dist/preview/{chunk.7ZRFXI73.js → chunk.COYLGLTI.js} +1 -1
  35. package/dist/preview/{chunk.UY7IOVR6.js → chunk.CTQULC5F.js} +1 -1
  36. package/dist/preview/{chunk.5B2LH2SR.js → chunk.DNROW6LX.js} +1 -1
  37. package/dist/preview/{chunk.JLEC3USG.js → chunk.DQS7D2W2.js} +1 -1
  38. package/dist/preview/{chunk.ZBR2QY67.js → chunk.ETPKXUAN.js} +1 -1
  39. package/dist/preview/{chunk.XXEYRHRG.js → chunk.ETR6AV47.js} +1 -1
  40. package/dist/preview/{chunk.FPASZ4RD.js → chunk.EUPSAYEI.js} +1 -1
  41. package/dist/preview/{chunk.6SJA4FSW.js → chunk.EYI3Y2DY.js} +1 -1
  42. package/dist/preview/chunk.F2VMMCVK.js +1 -0
  43. package/dist/preview/{chunk.SDU76JU6.js → chunk.F67F6QZ6.js} +1 -1
  44. package/dist/preview/chunk.FOJDVK2Q.js +1 -0
  45. package/dist/preview/{chunk.VC3BX2ZF.js → chunk.FOQ27RAR.js} +1 -1
  46. package/dist/preview/{chunk.LSLLKICK.js → chunk.FWSCBHZ5.js} +1 -1
  47. package/dist/preview/chunk.G446PWV6.js +1 -0
  48. package/dist/preview/{chunk.RYRTKIKB.js → chunk.GCKZ2YRJ.js} +2 -2
  49. package/dist/preview/{chunk.66JF3UMG.js → chunk.GQHAAKJG.js} +1 -1
  50. package/dist/preview/chunk.I6JLOEJU.js +1 -0
  51. package/dist/preview/chunk.IJNOT4S4.js +4 -0
  52. package/dist/preview/chunk.IPAZOKMQ.js +1 -0
  53. package/dist/preview/{chunk.JDMXZFSG.js → chunk.IQ2HKGJS.js} +1 -1
  54. package/dist/preview/{chunk.DQHPEKWK.js → chunk.IROYMLER.js} +1 -1
  55. package/dist/preview/chunk.ISNEX772.js +1 -0
  56. package/dist/preview/{chunk.3NMINX5Z.js → chunk.IXOQQBJE.js} +1 -1
  57. package/dist/preview/{chunk.DLFWBG33.js → chunk.IYIN6VSN.js} +1 -1
  58. package/dist/preview/chunk.JUWWRRHA.js +1 -0
  59. package/dist/preview/{chunk.GER2XRD4.js → chunk.K2NCGPCL.js} +1 -1
  60. package/dist/preview/{chunk.4KNEBLB7.js → chunk.KSM6NVAT.js} +1 -1
  61. package/dist/preview/{chunk.OF34OZ4V.js → chunk.KSXB4LDF.js} +1 -1
  62. package/dist/preview/{chunk.4XOWRYRU.js → chunk.L4YNDNX7.js} +6 -6
  63. package/dist/preview/{chunk.E4G6DXSB.js → chunk.MBETS27C.js} +1 -1
  64. package/dist/preview/{chunk.FOFLD64U.js → chunk.MCB26YCQ.js} +1 -1
  65. package/dist/preview/chunk.MCCUVGTE.js +1 -0
  66. package/dist/preview/{chunk.ZJ2VS4M4.js → chunk.MF73YBJL.js} +1 -1
  67. package/dist/preview/{chunk.ZEAH57AZ.js → chunk.N7JT6MG2.js} +1 -1
  68. package/dist/preview/{chunk.SGKPGVBB.js → chunk.NDWW5EER.js} +1 -1
  69. package/dist/preview/{chunk.VSAPJAT3.js → chunk.NEEOVRB7.js} +1 -1
  70. package/dist/preview/{chunk.NMIXBH37.js → chunk.NFIGGSMJ.js} +1 -1
  71. package/dist/preview/{chunk.JBW3DI7E.js → chunk.O2WWYZI7.js} +1 -1
  72. package/dist/preview/{chunk.6BJBPDF3.js → chunk.O4WEJ47H.js} +14 -4
  73. package/dist/preview/{chunk.ICGNIK3Z.js → chunk.OCTOGZVJ.js} +2 -2
  74. package/dist/preview/{chunk.FTM64IDI.js → chunk.OJGUIWDD.js} +1 -1
  75. package/dist/preview/{chunk.GIYFEGAP.js → chunk.OONCUAOH.js} +1 -1
  76. package/dist/preview/{chunk.3HSPWSAI.js → chunk.P4KCZRIG.js} +1 -1
  77. package/dist/preview/{chunk.W2RCWPLK.js → chunk.PBKO5CKD.js} +1 -1
  78. package/dist/preview/{chunk.JSSFA3FC.js → chunk.PC6PID5X.js} +1 -1
  79. package/dist/preview/{chunk.JLYNMAME.js → chunk.PYE3WZM7.js} +1 -1
  80. package/dist/preview/{chunk.BS2SJC2P.js → chunk.QGG6ZRJ5.js} +2 -2
  81. package/dist/preview/{chunk.LEO2KWLZ.js → chunk.QZEZHCOI.js} +1 -1
  82. package/dist/preview/{chunk.DQOCBKC3.js → chunk.R6V37SR7.js} +1 -1
  83. package/dist/preview/{chunk.FF6DBQMB.js → chunk.RBJAPOZ3.js} +1 -1
  84. package/dist/preview/{chunk.TBSNNOQU.js → chunk.RG6WNOBW.js} +1 -1
  85. package/dist/preview/{chunk.5O5IJVLN.js → chunk.RUPRZDN3.js} +1 -1
  86. package/dist/preview/{chunk.S6WHA4CW.js → chunk.RVJXO5GG.js} +1 -1
  87. package/dist/preview/chunk.RX2M4C5W.js +2 -0
  88. package/dist/preview/{chunk.KBHU54NM.js → chunk.RZF3QM4E.js} +1 -1
  89. package/dist/preview/{chunk.7KVWV577.js → chunk.S5IQFZ5Z.js} +1 -1
  90. package/dist/preview/{chunk.2EFH63WS.js → chunk.SD6N4DGF.js} +1 -1
  91. package/dist/preview/{chunk.RPX35VYU.js → chunk.SGKK4UKP.js} +1 -1
  92. package/dist/preview/{chunk.V5FIZIX2.js → chunk.SWWAEOZ7.js} +1 -1
  93. package/dist/preview/chunk.SZR3Z43B.js +1 -0
  94. package/dist/preview/{chunk.ICCIZDTQ.js → chunk.T42S2WMB.js} +1 -1
  95. package/dist/preview/chunk.T7RJCEJB.js +18 -0
  96. package/dist/preview/{chunk.2YABX3SC.js → chunk.TCXKPILZ.js} +1 -1
  97. package/dist/preview/{chunk.TOXWNEOQ.js → chunk.TJEV5ZAM.js} +3 -3
  98. package/dist/preview/{chunk.LNG3CQNI.js → chunk.UV3YU64Z.js} +1 -1
  99. package/dist/preview/{chunk.UJKT2G6M.js → chunk.V7XHNRQM.js} +2 -2
  100. package/dist/preview/{chunk.FCAYURB4.js → chunk.VAFSSSSI.js} +1 -1
  101. package/dist/preview/{chunk.M5GJHVWZ.js → chunk.VC3UGFHY.js} +1 -1
  102. package/dist/preview/{chunk.NIVTK2W5.js → chunk.VSNHCGKC.js} +1 -1
  103. package/dist/preview/{chunk.XMCFZD3A.js → chunk.VXVWUIGO.js} +1 -1
  104. package/dist/preview/chunk.W6COSBO2.js +21 -0
  105. package/dist/preview/{chunk.E37V2EJM.js → chunk.WHEUTAXA.js} +1 -1
  106. package/dist/preview/{chunk.HWCHFQ7O.js → chunk.WJS6P7GI.js} +1 -1
  107. package/dist/preview/chunk.X5G7FOPY.js +12 -0
  108. package/dist/preview/{chunk.BGYY55VO.js → chunk.XYEFZ2OO.js} +1 -1
  109. package/dist/preview/chunk.Y4ZUJUUT.js +25 -0
  110. package/dist/preview/chunk.YHH4TWZ2.js +1 -0
  111. package/dist/preview/{chunk.4RJZVTW7.js → chunk.YVONXFKE.js} +1 -1
  112. package/dist/preview/{chunk.5R2R364Q.js → chunk.Z4UM4CMT.js} +1 -1
  113. package/dist/preview/{chunk.4HYJHGI4.js → chunk.ZCYGUP3I.js} +1 -1
  114. package/dist/preview/chunk.ZIEHF67C.js +1 -0
  115. package/dist/preview/{chunk.II7VTGNC.js → chunk.ZL7ZBJUU.js} +1 -1
  116. package/dist/preview/{chunk.FHZBXMXR.js → chunk.ZQY6ODXC.js} +1 -1
  117. package/dist/preview/{chunk.6KWFTSK4.js → chunk.ZWVN75EY.js} +1 -1
  118. package/dist/preview/index.html +36 -36
  119. package/dist/preview/page.js +2 -2
  120. package/package.json +6 -6
  121. package/dist/preview/chunk.2JJYGYT2.js +0 -1
  122. package/dist/preview/chunk.2LKMNEWZ.js +0 -1
  123. package/dist/preview/chunk.6SWW6KEV.js +0 -1
  124. package/dist/preview/chunk.6UIW664O.js +0 -6
  125. package/dist/preview/chunk.6USUVORO.js +0 -1
  126. package/dist/preview/chunk.B6KT6BTG.js +0 -49
  127. package/dist/preview/chunk.C2UFMFJ3.js +0 -3
  128. package/dist/preview/chunk.CSDERNQV.js +0 -1
  129. package/dist/preview/chunk.F6HMZL65.js +0 -1
  130. package/dist/preview/chunk.GFLAGZSB.js +0 -1
  131. package/dist/preview/chunk.GVY5UQTJ.js +0 -1
  132. package/dist/preview/chunk.HZGVEHEN.js +0 -1
  133. package/dist/preview/chunk.J7G3AATY.js +0 -14
  134. package/dist/preview/chunk.JHIUG25Q.js +0 -1
  135. package/dist/preview/chunk.K46YRA65.js +0 -1
  136. package/dist/preview/chunk.K6KMLD2B.js +0 -21
  137. package/dist/preview/chunk.L24FCXZ7.js +0 -1
  138. package/dist/preview/chunk.MGWMGLWE.js +0 -1
  139. package/dist/preview/chunk.OMZ3LDDN.js +0 -1
  140. package/dist/preview/chunk.OYHQSXNC.js +0 -1
  141. package/dist/preview/chunk.SZ34UAQ3.js +0 -2
  142. package/dist/preview/chunk.WM2LWHTJ.js +0 -1
  143. package/dist/preview/chunk.WSTBCWW7.js +0 -4
  144. package/dist/preview/chunk.XWAMQPUM.js +0 -25
  145. package/dist/preview/chunk.ZTIF23VF.js +0 -1
@@ -1 +0,0 @@
1
- import{a as b}from"./chunk.PXQVXBNG.js";import{a as m,d as $,e as v,f as A}from"./chunk.GVY5UQTJ.js";import{Xc as w}from"./chunk.AS4CQBOQ.js";var E=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),x=e=>e?._zod?.def;function S(e){let n=x(e);for(;n&&(n.type==="optional"||n.type==="default"||n.type==="nullable"||n.type==="prefault");)n=x(n.innerType);return n}function O(e){if(e?.type==="boolean")return["true","false"];if(e?.type==="enum")return(e.entries?Object.values(e.entries):e.values??[]).filter(n=>typeof n=="string")}var p=e=>e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[-_]/g," ").replace(/^./,n=>n.toUpperCase());function W(e,n,i){let l=e.tryDefinition(n);if(!l)return[];let t=new Set(l.display?.hide??[]),r=[];for(let[o,s]of Object.entries(l.fields.shape??{})){if(o==="id"||o==="kind"||o==="label"||t.has(o))continue;let a=S(s);if(a?.type==="array"||a?.type==="object"||a?.type==="record")continue;let u=O(a);r.push({key:o,label:p(o),...u?{options:u}:{}})}let d=new Map;for(let[o,s]of Object.entries(l.edges??{}))d.set(o,s.to==="*"?[]:[...s.to]);for(let o of e.definitions)if(o.kind!==n)for(let[s,a]of Object.entries(o.edges??{}))!d.has(s)&&(a.to==="*"||a.to.includes(n))&&d.set(s,[o.kind]);let f=[];for(let[o,s]of d){r.push({key:o,label:p(o)});let a=i&&s.length===1&&s[0]!==n?e.tryDefinition(s[0]):void 0;for(let[u,c]of Object.entries(a?.fields.shape??{})){let y=S(c);y?.type==="enum"&&!a?.display?.hide?.includes(u)&&f.push({key:`${o}.${u}`,label:`${p(o)} \xB7 ${p(u)}`,options:O(y)})}}return r.push(...f),r.push({key:"is",label:"Is",options:l.lifecycle?["current","past","any","flagged","clear"]:["flagged","clear"]}),r}var j=e=>e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function D(e,n,i,l={}){if(i==null)return{ok:!0};if(!E(i))return{ok:!1,says:'A filter is an object of a field and the value it keeps, like { where: { stage: "building" } }.'};let t=Object.entries(i);if(t.length===0)return{ok:!0};let r=[];for(let s of n)for(let a of W(e,s,l.through===!0))r.some(u=>u.key===a.key)||r.push(a);let d=n[0]?e.tryDefinition(n[0]):void 0,f=d?d.plural??`${p(d.kind)}s`:"These",o=[];for(let[s,a]of t){let u=r.find(y=>y.key===s);if(!u)return{ok:!1,says:`${f.replace(/^./,y=>y.toUpperCase())} have no field "${s}" to filter by${r.length>0?`; they filter by ${j(r.map(y=>y.key))}`:""}.`};if(typeof a!="string"&&typeof a!="number"&&typeof a!="boolean")return{ok:!1,says:`The filter on "${s}" is ${Array.isArray(a)?"a list":a===null?"null":`a ${typeof a}`}; it keeps one value: a word, a number, or true or false.`};let c=String(a);if(c.trim().length===0)return{ok:!1,says:`The filter on "${s}" keeps nothing; give it a value, or leave "${s}" out.`};if(c.includes(","))return{ok:!1,says:`The filter on "${s}" holds a comma, which an address reads as a second filter; keep one value.`};if(u.options&&u.options.length>0&&!u.options.includes(c))return{ok:!1,says:`${u.label} has no choice "${c}"; its choices are ${j(u.options.map(y=>`"${y}"`))}.`};o.push(`${s}:${c}`)}return{ok:!0,filter:o.join(",")}}var P=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");function L(e,n){let i=e.find(r=>r.as===n);if(i)return i;let l=n.trim().toLowerCase(),t=P(n);return e.find(r=>r.title!==void 0&&r.title.trim().toLowerCase()===l)??(t?e.find(r=>r.as===t||r.title!==void 0&&P(r.title)===t):void 0)}function q(e){let n=[];for(let i of e){if(typeof i!="object"||i===null)continue;let{as:l,slug:t,title:r,kind:d}=i,f=typeof l=="string"&&l.length>0?l:typeof t=="string"&&t.length>0?t:void 0;!f||n.some(o=>o.as===f)||n.push({as:f,title:typeof r=="string"?r:f,kind:typeof d=="string"?d:""})}return n}var N=e=>` Its places: ${e.map(n=>typeof n=="string"?`"${n}"`:n.title&&n.title!==n.as?`"${n.as}" (${n.title})`:`"${n.as}"`).join(", ")||"none"}.`,g=e=>`"${e.length>80?`${e.slice(0,79)}\u2026`:e}"`,h=(e,n)=>`${"place"in e?`The place ${g(e.place)}`:`${g(e.record)} is no record this viewer may see and`} is no place of this app: it goes nowhere.${N(n)}`;function k(e){let n={};for(let i of e.split(",")){let l=i.indexOf(":");l>0&&(n[i.slice(0,l).trim()]=i.slice(l+1).trim())}return n}function M(e,n=new Set){return e.kinds.filter(i=>!n.has(i)).map(i=>({slug:w(e,i).slice(1),kind:i}))}function G(e,n){let i=[...new Set(n.places.map(c=>c.as))],l=n.lists.map(c=>c.slug).filter(c=>!i.includes(c)),t;if(e.section!==void 0&&e.section!==null){if(typeof e.section!="string"||b(e.section).length===0||e.section.length>120)return{ok:!1,says:`The section ${typeof e.section=="string"?g(e.section):"asked for"} names nothing on a page: a section is a heading's words or an element's id, like "shipping-soon". It goes nowhere.`};t=e.section}let r=t!==void 0?{section:t}:{};if("record"in e&&n.sees(e.record))return e.where!==void 0&&e.where!==null?{ok:!1,says:`${g(e.record)} is one record, and a filter narrows a list or a place: it goes nowhere. Go to { place, where } for a list narrowed.`}:{ok:!0,arrival:{record:e.record,...r}};let d="place"in e?e.place:e.record,f=L(n.places,d),o=f?void 0:n.lists.find(c=>c.slug===d||c.kind===d);if(!f&&!o)return{ok:!1,says:`${h(e,n.places.filter((c,y,R)=>R.findIndex(T=>T.as===c.as)===y))}${I(l)}`};let s=f?[f.kind]:[o.kind],a;if(e.where!==void 0&&e.where!==null){if(!n.schema)return{ok:!1,says:`The place ${g(d)} cannot be narrowed here: it goes nowhere.`};let c=D(n.schema,s,e.where,{through:o!==void 0});if(!c.ok)return{ok:!1,says:`The filter on ${g(d)} goes nowhere: ${c.says}`};a=c.filter}let u=a?{filter:a}:{};return{ok:!0,arrival:f?{place:f.as,...u,...r}:{list:o.kind,...u,...r}}}var I=e=>e.length===0?"":` Its lists: ${e.slice(0,8).map(n=>`"${n}"`).join(", ")}${e.length>8?` and ${e.length-8} more`:""}.`;function V(e){let n=new WeakSet,i=t=>{let r=G(t,{sees:e.sees,places:e.places(),lists:e.lists?.()??[],...e.schema?{schema:e.schema}:{}});return r.ok?e.onNavigate?.(r.arrival):e.onLost?.(r.says),r.ok},l={link(t){let r=v(t,[...t.querySelectorAll("input, select, textarea")].some(m));r&&!t.hasAttribute("data-graview-link")?(t.setAttribute("data-graview-link",""),!t.hasAttribute("role")&&(t.localName==="a"||$(t))&&t.setAttribute("role","link"),!t.hasAttribute("tabindex")&&t.localName!=="button"&&(t.setAttribute("tabindex","0"),n.add(t))):!r&&t.hasAttribute("data-graview-link")&&(t.removeAttribute("data-graview-link"),t.getAttribute("role")==="link"&&t.removeAttribute("role"),n.delete(t)&&t.removeAttribute("tabindex"))},refresh(t){for(let r of t.querySelectorAll("[data-record], [data-place], [data-graview-link]"))l.link(r)},pressed(t,r,d){if(t.type!=="click"&&!(t.type==="keydown"&&t.key==="Enter"))return!1;let f=A(r,d,o=>o.hasAttribute("data-graview-link"));return f?(t.preventDefault(),t.stopPropagation(),l.follow(f),!0):!1},follow(t){let r=t.getAttribute("data-record"),d=t.getAttribute("data-place"),f=t.getAttribute("data-filter"),o=t.getAttribute("data-section"),s={...f?{where:k(f)}:{},...o?{section:o}:{}};r?i({record:r,...s}):d&&i({place:d,...s})},go:i};return l}export{q as a,N as b,g as c,h as d,k as e,M as f,G as g,V as h};
@@ -1,4 +0,0 @@
1
- var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as Bt,f as $t,g as bn}from"./chunk.NIVTK2W5.js";import{b as wn}from"./chunk.BNPQUI3F.js";import{a as Ne,b as No,c as Zt,d as ni,e as Bo}from"./chunk.6RY6OSE6.js";import{h as ti}from"./chunk.PKUDIWIF.js";import{e as Jr,p as Yn,q as ei}from"./chunk.VW2VCPJX.js";import{a as Zr}from"./chunk.WBHM5I3I.js";import{a as Xr,b as qr,c as Qr}from"./chunk.UKAPFIPJ.js";import{b as Wr,d as Vr}from"./chunk.UT6642FC.js";import{a as Yr,b as Lo,c as Io,f as To,g as Po,h as Co,i as zr,j as Xt,k as qt,o as Nt,p as Qt,q as Kr,r as Ur}from"./chunk.6MADC6DM.js";import{A as Fr,f as Lr,g as Kt,h as Ir,i as Tr,j as Pr,k as Cr,m as Vn,n as gn,o as xn,p as Ut,q as Ao,v as Nr,w as Br,x as $r,y as Hr,z as Dr}from"./chunk.OJGHDWI6.js";import{a as Gr,b as _r}from"./chunk.JLEC3USG.js";import{c as jr}from"./chunk.H7KCWCB4.js";import{A as dt,B as vo,Ba as Mo,C as pn,Ca as Eo,Da as Ct,Fa as Ro,G as Ce,Ja as Oo,K as gt,R as Ie,T as ko,X as So,Y as Wn,Z as Tt,_ as ye,a as po,aa as Pt,b as yo,c as go,d as Er,e as Rr,f as Fn,h as Lt,ha as _t,j as pt,ja as Ar,k as xo,l as jn,m as fn,p as bo,r as we,s as Ae,t as Or,u as mn,v as Le,w as It,wa as yn,x as yt,y as wo}from"./chunk.XWAMQPUM.js";import{a as Gt}from"./chunk.SDO3U72B.js";import{$b as hn,ba as wr,ca as Dn,ea as cn,fa as zt,ga as At,ha as un,la as vr,ld as kr,od as Sr,uc as He,ud as Mr}from"./chunk.AS4CQBOQ.js";import{b as se}from"./chunk.AJZBJBMO.js";var oi={width:1200,height:760,focusSize:{width:1200,height:420},relationSize:{width:240,height:140},contextSize:{width:300,height:104},gap:16,unit:16};var ri=(e,t)=>e?`${e.edgeKind}|${e.direction}`:`raised|${t}`,Ht=(e,t,n)=>`${vo}${e}|${t}|${n}`;function zn(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 u=Math.max(1,Math.floor(o/a));n[l]=Math.min(i,u),o-=n[l],a-=1}return n}function Ho(e){return ri(e.via,e.node.kind)}function Jt(e,t,n=[]){let r=[],o=0;return e.forEach((a,i)=>{if(a<=0)return;let l=Math.min(t,Math.max(1,n[i]??1)),u=Math.max(a,l);if(r.length>0&&a<=t&&u<=o){r[r.length-1].push({run:i,cards:a,slots:u}),o-=u;return}let d=a,s=!0;for(;d>0;){let c=Math.min(t,d),h=s?Math.max(c,l):c;r.push([{run:i,cards:c,slots:h}]),d-=c,o=t-h,s=!1}}),r}function Do(e,t,n,r=[]){let o=zn(e,t*n);for(;Jt(o,t,r).length>n;){let a=-1;if(o.forEach((i,l)=>{i>1&&(a<0||i>o[a])&&(a=l)}),a<0)break;o[a]=o[a]-1}return o}function Va(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 Ya=5,za=(e,t)=>{for(let n=0;n<e.length;n++)if(e[n]!==t[n])return e[n]<t[n];return!1};function ii(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 Jr(n.schema,r).groups)if(l.key!==n.exclude)if(l.buckets)for(let u of["decade","year","month"])a.push({by:l.key,bucket:u});else a.push({by:l.key});let i;return a.forEach((l,u)=>{let s=ti(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 y=[-Math.round(h*100),Math.abs(s.length-Ya),u];(!i||za(y,i.score))&&(i={grouping:{by:l.by,...l.bucket?{bucket:l.bucket}:{},groups:s},score:y})}),i?.grouping}function Fo(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 p=ri(f.via,f.node.kind),v=o.get(p);v?v.push(f):o.set(p,[f])}let a=[...o.entries()].map(([f,p])=>({key:f,run:p,via:p[0].via,kinds:[...new Set(p.map(v=>v.node.kind))],members:[],whole:!1,extra:0})),i=zn(a.map(f=>f.run.length),t.budget);a.forEach((f,p)=>f.whole=f.run.length<=i[p]);let l=a.filter(f=>!f.whole),u=a.filter(f=>f.whole).reduce((f,p)=>f+p.run.length,0),d=Math.max(l.length,t.budget-u);for(let f of l){f.members=Va(f.run.map(v=>v.node),r,t.graph);let p=d-(l.length-1);f.kinds.length>1&&f.kinds.length<=p?f.byKind=!0:f.kinds.length===1&&(f.grouping=ii(f.members,p,{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,p)=>f+s(p),0)>d;){let f=[...l].filter(p=>s(p)>1).sort((p,v)=>s(v)-s(p))[0];if(!f)break;f.grouping=void 0,f.byKind=!1}d-=l.reduce((f,p)=>f+s(p),0);let c=f=>f.byKind?f.kinds.some(p=>t.expanded.has(Ht(p,f.key,"kind"))):f.grouping?.groups.some(p=>t.expanded.has(Ht(f.kinds[0],f.key,$o(f.grouping,p.key)))),h=l.filter(f=>!f.grouping&&!f.byKind?!0:c(f)),y=zn(h.map(f=>f.members.length),Math.max(0,d));h.forEach((f,p)=>f.extra=d>0?y[p]:0);let w=[];for(let f of a){let{key:p,via:v}=f;if(f.whole){w.push(...f.run.map(n));continue}let k=g=>({id:g.id,kind:g.kind,node:g,...v?{via:v}:{}}),x=new Map(f.run.map((g,E)=>[g.node.id,E])),O=(g,E,I)=>{let A=[...g.slice(0,E)].sort((N,$)=>x.get(N.id)-x.get($.id));w.push(...A.map(k));let j=g.slice(E);if(j.length===0)return;let K=j[0].kind;w.push({id:Ht(K,p,I?`more:${I}`:"more"),kind:K,...v?{via:v}:{},aggregate:{kind:K,memberIds:j.map(N=>N.id),label:E>0?`${j.length} more ${t.plural(K).toLowerCase()}`:`${j.length} ${t.plural(K).toLowerCase()}`,opens:{in:"picture",focus:Le(K),within:I?{filter:I}:{}}}})},G=v&&t.focusId?`${v.edgeKind}:${t.focusId}`:void 0;if(f.byKind){let g=f.kinds.find(E=>t.expanded.has(Ht(E,p,"kind")));for(let E of f.kinds){let I=f.members.filter(A=>A.kind===E);if(E===g){let A=f.extra+1;I.length<=A?w.push(...I.map(k)):O(I,A-1,G);continue}w.push({id:Ht(E,p,"kind"),kind:E,...v?{via:v}:{},aggregate:{kind:E,memberIds:I.map(A=>A.id),label:t.plural(E),opens:{in:"place"}}})}continue}let F=f.grouping;if(!F){O(f.members,f.extra,G);continue}let Q=f.kinds[0],z=F.groups.find(g=>t.expanded.has(Ht(Q,p,$o(F,g.key))));for(let g of F.groups){if(g===z){let E=f.members.filter(A=>g.nodes.includes(A)),I=f.extra+1;if(E.length<=I)w.push(...E.map(k));else{let A=g.key!==""&&!g.key.includes(",")&&!F.bucket,j=[G,A?`${F.by}:${g.key}`:void 0].filter(Boolean).join(",")||void 0;O(E,I-1,j)}continue}w.push({id:Ht(Q,p,$o(F,g.key)),kind:Q,...v?{via:v}:{},aggregate:{kind:Q,memberIds:f.members.filter(E=>g.nodes.includes(E)).map(E=>E.id),label:g.label.charAt(0).toUpperCase()+g.label.slice(1),opens:{in:"place"}}})}}return w}var $o=(e,t)=>`${e.by}${e.bucket?`:${e.bucket}`:""}=${t||"none"}`;var Gn=300,ai=12,en=8,jo=19;var _n=(e,t=1)=>(e.length*8.4+16)*t;function vn(e){return e.description??`${e.direction==="in"?"\u2190":"\u2192"} ${cn(e.edgeKind).toLowerCase()}`}function Wo(e,t,n=1){let r=l=>_n(l,n),o=new Map;for(let l of e){let u=o.get(l.key);u?u.push(l):o.set(l.key,[l])}let a=[...o.values()].map(l=>{let u=Math.min(...l.map(s=>s.top)),d=l.filter(s=>s.top-u<=ai);return{key:l[0].key,text:l[0].text,left:Math.min(...d.map(s=>s.left)),right:Math.max(...d.map(s=>s.right)),top:u}});a.sort((l,u)=>l.top-u.top||l.left-u.left);let i=a.map(l=>{let u=Math.max(l.right-l.left,Math.min(Gn,r(l.text))),d=(l.left+l.right)/2;return{left:d-u/2,right:d+u/2}});return a.map((l,u)=>{let d=a.map((x,O)=>({other:x,at:O})).filter(({other:x})=>x!==l&&Math.abs(x.top-l.top)<=ai),s=d.filter(({other:x})=>x.right<=l.left).map(({other:x,at:O})=>i[O].right+en<=(x.right+l.left)/2?i[O].right+en:(x.right+l.left+en)/2),c=d.filter(({other:x})=>x.left>=l.right).map(({other:x,at:O})=>i[O].left-en>=(l.right+x.left)/2?i[O].left-en:(l.right+x.left-en)/2),h=Math.max(t.left,...s),y=Math.min(t.right,...c),w=l.right-l.left,f=i[u].right-i[u].left,p=Math.max(w,Math.min(f,y-h)),v=(l.left+l.right)/2,k=w>=p?l.left:Math.max(h,Math.min(v-p/2,y-p));return{key:l.key,text:l.text,left:k,width:p,top:l.top}})}function di(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 Dt(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 Vo=(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},kn=4,si=.45;function Yo(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??[],u=o.tilt??.5,d=b=>b.nameplate??{width:120,height:34,short:{width:90,height:20}},s=b=>e.map(M=>{let T=b.get(M.kind);return{card:M,plot:T,center:Zt(T.col+T.side/2,T.row+T.side/2,1,u)}}),c=(b,M)=>{let T=1/0,S=-1/0,P=1/0,L=-1/0;for(let{card:H,plot:Z,center:U}of b){let V=U.x*M,ne=U.y*M,X=Z.side*M/2,ce=H.opened>0?d(H).width:d(H).short.width;T=Math.min(T,V-Math.max(X+(H.count>12?30:0),ce/2)),S=Math.max(S,V+Math.max(X,ce/2)),P=Math.min(P,ne-X*u-M*si),L=Math.max(L,ne+X*u+kn+d(H).short.height)}return{minX:T,maxX:S,minY:P,maxY:L}},h=b=>{let M=4,T=160;for(let S=0;S<24;S++){let P=(M+T)/2,L=c(b,P);L.maxX-L.minX<=i.width&&L.maxY-L.minY<=i.height?M=P:T=P}return M},y=b=>{let M={...o.order?{order:o.order}:{},counts:a,...o.plots?{plots:o.plots}:{},pitch:b},T=No(t,M),S=No(t,{...M,upright:!0}),P=h(s(T)),L=h(s(S)),H=n.height>n.width&&L>=P?S:T;return{map:H,fitted:H===S?L:P}},w=[],f=new Map,p=0,v=(b,M={x:0,y:0})=>{let T=c(w,b),S=i.x+i.width/2-(T.minX+T.maxX)/2+M.x,P=i.y+i.height/2-(T.minY+T.maxY)/2+M.y;return{originX:S,originY:P,cell:b}},k=b=>{let{originX:M,originY:T,cell:S}=b,P=w.map(({center:Z})=>Z.y),L=Math.max(...P),H=Math.min(...P);return w.map(({card:Z,plot:U,center:V})=>{let ne=M+V.x*S,X=T+V.y*S,ce=U.side*S/2,ae=ce*u,Se=L===H?.5:(V.y-H)/(L-H);return{card:Z,plot:U,x:ne,y:X,halfW:ce,halfH:ae,depth:1-Se*.65}})},x=(b,M=!0)=>{let T=[];return[...b].sort((P,L)=>(L.card.weight??L.card.count)-(P.card.weight??P.card.count)||e.indexOf(P.card)-e.indexOf(L.card)).filter(P=>[d(P.card),d(P.card).short].some(L=>{let H=F(P,L),Z=(!M||H.x>=0&&H.y>=0&&H.x+H.width<=n.width&&H.y+H.height<=n.height)&&!T.some(U=>Dt(H,U,4))&&!b.some(U=>U!==P&&Vo(H,U,U.halfW,U.halfH))&&!l.some(U=>Dt(H,U,0));return Z&&T.push(H),Z})).length},O=b=>b.card.marquee?{x:b.x-b.card.marquee.width/2,y:b.y+b.halfH+kn+d(b.card).height,width:b.card.marquee.width,height:b.card.marquee.height}:null,G=(b,M,T)=>T.some(S=>{if(S===M)return!1;let P=O(S);return P!==null&&Dt(b,P,4)}),F=(b,M,T="under")=>T==="aside"?{x:b.x+b.halfW+kn,y:b.y-M.height/2,width:M.width,height:M.height}:T==="above"?{x:b.x-M.width/2,y:b.y-b.halfH-kn-si*E.cell-M.height,width:M.width,height:M.height}:{x:b.x-M.width/2,y:b.y+b.halfH+kn,width:M.width,height:M.height},Q=b=>b.some(M=>l.some(T=>Vo(T,M,M.halfW,M.halfH)||Dt(T,F(M,d(M.card).short),0))),z=b=>b.every(M=>{let T=F(M,d(M.card).short);return M.x-M.halfW>=0&&M.x+M.halfW<=n.width&&M.y-M.halfH>=0&&T.x>=0&&T.x+T.width<=n.width&&T.y+T.height<=n.height}),g={pitch:Ne,said:-1};for(let b of[Ne,Ne+1,Ne+2,Ne+3,Ne+5,Ne+7]){({map:f,fitted:p}=y(b)),w=s(f);let M=x(k(v(p)));if(M>g.said&&(g={pitch:b,said:M}),M===e.length)break}(g.pitch!==Ne+7||g.said!==e.length)&&({map:f,fitted:p}=y(g.pitch),w=s(f));let E=v(p);if(l.length>0&&Q(k(E))){let b;for(let M=1;M>=.3&&!b;M-=.05){let T=p*M,S=Math.max(...l.map(L=>L.width))/2+T,P=Math.max(...l.map(L=>L.height))/2+T/2;for(let L of[0,.5,.75,1,1.25]){for(let[H,Z]of[[1,0],[-1,0],[0,1],[0,-1],[1,1],[-1,1],[1,-1],[-1,-1]]){let U=v(T,{x:H*S*L,y:Z*P*L}),V=k(U);if(!Q(V)&&z(V)){b=U;break}if(L===0)break}if(b)break}}b&&(E=b)}let I=(b,M)=>{let T={x:n.width/2,y:n.height/2};return{cell:b.cell*M,originX:T.x+(b.originX-T.x)*M,originY:T.y+(b.originY-T.y)*M}},A=1;if(x(k(E))<e.length){let b={said:x(k(E),!1),area:1/0,pitch:-1,by:1},M={map:f,shape:w,fitted:p,where:E};for(let S of[Ne,Ne+1,Ne+2,Ne+3,Ne+5,Ne+7]){({map:f,fitted:p}=y(S)),w=s(f);let P=v(p);for(let L=1;L<=3.001;L+=.1){let H=x(k(I(P,L)),!1),Z=c(w,p*L),U=(Z.maxX-Z.minX)*(Z.maxY-Z.minY);if((H>b.said||H===b.said&&U<b.area)&&(b={said:H,area:U,pitch:S,by:L}),H===e.length)break}}b.pitch<0?{map:f,shape:w,fitted:p,where:E}=M:({map:f,fitted:p}=y(b.pitch),w=s(f),A=b.by,E=I(v(p),A));let T=k(E).filter(S=>o.keep?.includes(S.card.kind));if(T.length>0){let S=T.flatMap(V=>[{x:V.x-V.halfW,y:V.y-V.halfH,width:V.halfW*2,height:V.halfH*2},F(V,d(V.card))]),P=Math.min(...S.map(V=>V.x)),L=Math.max(...S.map(V=>V.x+V.width)),H=Math.min(...S.map(V=>V.y)),Z=Math.max(...S.map(V=>V.y+V.height)),U=(V,ne,X)=>ne-V>X-16?X/2-(V+ne)/2:V<8?8-V:ne>X-8?X-8-ne:0;E={...E,originX:E.originX+U(P,L,n.width),originY:E.originY+U(H,Z,n.height)}}}let j=o.zoom&&o.zoom!==1?o.zoom:1;j!==1&&(E=I(E,j));let K=k(E),N=[],$=new Map,Y=new Map,B=[...K].sort((b,M)=>(M.card.weight??M.card.count)-(b.card.weight??b.card.count)||e.indexOf(b.card)-e.indexOf(M.card));for(let b of B){let M=[["full",d(b.card),"under"],["short",d(b.card).short,"under"]],T="none",S=b===B[0],P=(H,Z)=>M.filter(([U])=>U.startsWith(Z)).map(([U,V,ne])=>[U,V,ne,H]),L=S?[...P(!1,"full"),...P(!1,"short"),...P(!0,"full"),...P(!0,"short")]:M.map(([H,Z,U])=>[H,Z,U,!1]);for(let[H,Z,U,V]of L){let ne=F(b,Z,U);if((j!==1||A!==1||ne.x>=0&&ne.y>=0&&ne.x+ne.width<=n.width&&ne.y+ne.height<=n.height)&&!N.some(ae=>Dt(ne,ae,4))&&(V||!K.some(ae=>ae!==b&&Vo(ne,ae,ae.halfW,ae.halfH)))&&!G(ne,b,K)&&!l.some(ae=>Dt(ne,ae,0))){T=H,N.push(ne),Y.set(b.card.id,ne);break}}$.set(b.card.id,T)}let J=K.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:$.get(b.card.id)??"none"})),R=c(w,E.cell),D={cell:E.cell,originX:E.originX,originY:E.originY,pan:o.pan??{x:0,y:0},extent:{x:E.originX+R.minX,y:E.originY+R.minY,width:R.maxX-R.minX,height:R.maxY-R.minY},openedShare:1,...u!==.5?{tilt:u}:{},...Y.size>0?{nameplates:K.flatMap(b=>{let M=Y.get(b.card.id);return M?[{id:b.card.id,x:M.x-(b.x-b.halfW),y:M.y-(b.y-b.halfH),width:M.width,height:M.height}]:[]})}:{},...K.some(b=>b.card.marquee)?{showings:K.flatMap(b=>{let M=O(b);return M?[{id:b.card.id,x:M.x-(b.x-b.halfW),y:M.y-(b.y-b.halfH),width:M.width,height:M.height}]:[]})}:{}};return{placed:J,frame:D,map:f}}function xt(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 Kn=48;function zo(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 u=l==="left"||l==="right",d=u?Math.max(0,Math.min(n,i)):Math.max(0,Math.min(t,a)),s=(y,w)=>y<w/4?w/4-y:y>w*3/4?w*3/4-y:0,c=(y,w)=>y<Kn?Kn-y:y>w-Kn?w-Kn-y:0,h=u?{x:s(a,t),y:c(i,n)}:{x:c(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 Go(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 li(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 c of Object.values(s.edges??{})){let h=c.to==="*"?n:c.to;for(let y of h)o(d,y)}}let a=new Map,i=new Map,l=[...t].filter(d=>n.includes(d));for(let d of l)a.set(d,0);let u=0;for(;l.length>0;){u+=1;let d=[];for(let s of[...l].sort((c,h)=>n.indexOf(c)-n.indexOf(h)))for(let c of[...r.get(s)??[]].sort((h,y)=>n.indexOf(h)-n.indexOf(y)))a.has(c)||(a.set(c,u),u===2&&i.set(c,s),d.push(c));l=d}return{rankOf:d=>{let s=a.get(d);if(s!==0)return s===1?"primary":"secondary"},parentOf:d=>i.get(d)}}function ci(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 u=e.getNode(l);if(!u||a.has(l))continue;let d=i.from===n.id?"out":"in",s=d==="out"?n.kind:u.kind,c=_a(t,s,i.kind,d);a.set(l,{node:u,via:{edgeKind:i.kind,direction:d,...c?{description:c}:{}}})}if(a.size>0){let i=l=>`${l.via.edgeKind}|${l.via.description??""}`;return[...a.values()].sort((l,u)=>(i(l)<i(u)?-1:i(l)>i(u)?1:0)||dt(l.node,u.node))}}if(n){let a=o[n.id]??[],i=new Set,l=[];for(let u of a){if(u===n.id||i.has(u))continue;let d=e.getNode(u);d&&(r&&r!=="judges"&&d.kind!==r||(i.add(u),l.push({node:d,via:{edgeKind:"judges",direction:"out",description:"what it finds wrong"}})))}if(l.length>0)return l.sort((u,d)=>dt(u.node,d.node))}return r?e.allNodes().filter(a=>a.kind===r).sort(dt).map(a=>({node:a})):[]}function _a(e,t,n,r){let a=e.tryDefinition(t)?.edges?.[n];return r==="out"?a?.description:a?.inverse}function ui(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,u=new Map;for(let d of e.allEdges()){let s=a(d.from),c=a(d.to);if(!s||!c||s.id===c.id&&!(n.overview&&s.aggregate&&s.plane===2))continue;let h=`${d.kind}:${s.id}:${c.id}`,y=i.get(h);if(y){let w=`${d.from}
2
- ${d.to}`,f=l.get(h);if(f.has(w))continue;if(f.add(w),u.get(h).push({from:d.from,to:d.to}),y.single){let{single:p,...v}=y;i.set(h,v)}continue}l.set(h,new Set([`${d.from}
3
- ${d.to}`])),u.set(h,[{from:d.from,to:d.to}]),i.set(h,{id:h,kind:d.kind,from:s.id,to:c.id,edges:[{from:d.from,to:d.to}],single:{from:d.from,to:d.to},...s.id===c.id?{loop:!0}:{},x1:s.x+s.width/2,y1:s.y+s.height/2,x2:c.x+c.width/2,y2:c.y+c.height/2})}return[...i.values()].map(d=>({...d,edges:u.get(d.id)})).sort(dt)}var fi=.85,hi=60,_o=160;function Ka(e,t,n,r,o,a=fi){let i=e*t.width+Math.max(0,e-1)*n,l=Math.max(n,(r-i)/2);return Array.from({length:e},(u,d)=>({x:l+d*(t.width+n),y:o,depth:a}))}function Un(e,t,n,r={}){let o={...oi,...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,u=n.overview?Math.max(0,o.dock?.bottom??0):0,d=o.width-l-i-(o.inset?.right??0),s=[],c=new Map,h=m=>n.past===!0||wr(t.tryDefinition(m.kind),m,o.today),y=new Set(r.hiddenKinds??[]),w=m=>!y.has(m.kind),f=n.focusId?yt(n.focusId).filter(m=>t.tryDefinition(m)!==void 0).filter(m=>!y.has(m)):[];n.focusId&&yt(n.focusId).length>0&&f.length===0&&(n={...n,focusId:null});let p=n.focusId?e.getNode(n.focusId):void 0;p&&!w(p)&&(n={...n,focusId:null},f=[]);let v=f.length>0?[...e.allNodes()].filter(m=>f.includes(m.kind)).sort(dt):[],k=v.filter(w).filter(h),x=v.length-k.length,O=n.focusId&&f.length===0?e.getNode(n.focusId):void 0,G=n.zoom===!0&&!n.overview&&n.focusId!==null,F=Math.max(56,o.height*.062),Q=Math.min(o.height*.895,o.height-F),z=G?O!==void 0?{focusY:o.height*.03,focusH:o.height*.58,relationY:o.height*.645,relationH:o.height*.2,contextY:Q,contextH:F}:{focusY:o.height*.03,focusH:o.height*.71,relationY:o.height*.765,relationH:o.height*.1,contextY:Q,contextH:F}:O===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,W=m*.04,_=Math.max(m*.42,Math.min(m*.56,300)),oe=W+_+m*.06;return{focusY:W,focusH:_,relationY:oe,relationH:Math.max(m*.12,m*.878-m*.068-oe),contextY:m*.878,contextH:m*.092}})(),g=Math.min(o.headroom??0,z.focusY+z.focusH*.2),E=g>z.focusY?{...z,focusY:g,focusH:z.focusH-(g-z.focusY)}:z,I=m=>Math.min(o.gap*m,Math.round(d*.1)),A=G?Math.min(880,d-I(5)):Math.min(700,d-I(6)),j=G?d-I(5):Math.min(o.focusSize.width,d-I(6)),K=(m,W,_)=>({width:m===0?W:Math.min(W,(d-o.gap*(m+1))/m),height:_}),N=(m,W,_)=>{let oe=K(m,W,_),be=Math.min(W,_o*a,d-o.gap*2);return oe.width>=be?oe:{width:be,height:_}},$=m=>Math.max(1,Math.floor((d-o.gap)/(Math.min(m,_o*a,d-o.gap*2)+o.gap))),Y=new Set(n.expanded),B=n.overview?[]:ci(e,t,O,n.relation,o.judged).filter(m=>w(m.node)).filter(m=>h(m.node)),J=n.overview?0:Math.max(0,hi*a-E.contextH),R=B.length>0?E.focusH:E.contextY-E.focusY-o.gap*2-J,D=j,b=o.height,M=Math.min(d*.5/D,o.height*.48/b),T=D*M,S=b*M,P=new Set(r.plainGroups??[]),L=n.overview&&!O&&f.length>0&&n.focusId!==null,H=L&&f.length>0&&f.every(m=>P.has(m));if(L)for(let m of f)H&&r.besideTheMap!==!0?Y.add(we(m)):Y.delete(we(m));let Z=L&&!H&&f.length===1?f[0]:void 0,U=Z!==void 0&&(r.screens?.[Z]?.length??0)>0,V,ne=n.overview===!0&&O!==void 0&&r.besideTheMap===!0;n.overview&&(O||f.length>0)&&n.focusId&&!H&&!U&&!(L&&r.besideTheMap===!0)&&!ne?(V={x:i+(d-T)/2,y:o.height*.53-S/2,width:T,height:S},ln({id:n.focusId,kind:O?O.kind:f[0],plane:0,x:V.x,y:V.y,width:T,height:S,natural:{width:D,height:b},...O?{}:{aggregate:{kind:f.join("+"),memberIds:k.map(m=>m.id),label:r.plurals?.[n.focusId]??f.map(m=>At(t,m)).join(" and "),...x>0?{retired:x}:{}}}})):n.overview||(O?ln({id:O.id,kind:O.kind,plane:0,x:i+(d-A)/2,y:E.focusY,width:A,height:R}):f.length>0&&n.focusId&&ln({id:n.focusId,kind:f[0],plane:0,x:i+(d-j)/2,y:E.focusY,width:j,height:R,aggregate:{kind:f.join("+"),memberIds:k.map(m=>m.id),label:r.plurals?.[n.focusId]??f.map(m=>At(t,m)).join(" and "),...x>0?{retired:x}:{}}}));let X=26,ce=52,ae=22,Se=Math.round(o.relationSize.width*.75),ke=Math.max(1,Math.floor((d-o.gap)/(Se+o.gap))),Re=o.unit/16,Te=new Map;for(let m of B){let W=Ho(m),_=Te.get(W);_?_.push(m):Te.set(W,[m])}let Pe=[...Te.values()],re=Pe.length>1,ee=Math.max(o.gap,ae*Re),et=re?ee:o.gap,St=Math.max(2,Math.floor((E.relationH+et)/(X*Re+et))),an=Math.min(o.relationSize.width,(d-o.gap*(ke+1))/ke)+o.gap,_e=Pe.map(m=>{let W=m[0].via;return!re||!W?1:Math.ceil((Math.min(Gn*Re,_n(vn(W),Re))+o.gap)/an)}),Be=Pe.map(m=>m.length),ut=Jt(Be,ke,_e),Ke=B.length>ke*St||ut.length>St,tt={schema:t,graph:e,focusId:O?.id,expanded:Y,...o.relevance?{relevance:o.relevance}:{},...n.selection?{selection:n.selection}:{},plural:m=>At(t,m),...o.today?{today:o.today}:{}},Oe=Ke||re?ee:o.gap,Ye,$e;if(!Ke)Ye=Pe.flat().map(m=>({id:m.node.id,kind:m.node.kind,node:m.node,...m.via?{via:m.via}:{}})),$e=ut;else{let m=Math.max(1,Math.floor((E.relationH+Oe)/(ce*Re+Oe))),_=Jt(Be.map(()=>1),ke,_e).length<=m?_e:[],oe=Do(Be,ke,m,_),be=Pe.map((me,Ee)=>Fo(me,{...tt,budget:oe[Ee]}));Ye=be.flat(),$e=Jt(be.map(me=>me.length),ke,_)}let Fe=$e.length,Mt=Fe===1?E.relationH:(E.relationH-Oe*(Fe-1))/Fe,Ue=K(Math.max(...$e.map(m=>m.reduce((W,_)=>W+_.slots,0)),1),Ye.length<=2?Math.round(o.relationSize.width*1.35):o.relationSize.width,Mt),it=[];{let m=Ue.width+o.gap,W=[],_=0,oe=new Map;for(let me of $e.flat())oe.set(me.run,(oe.get(me.run)??0)+me.cards);for(let me=0;me<Pe.length;me++)W[me]=_,_+=oe.get(me)??0;let be=Pe.map(()=>0);$e.forEach((me,Ee)=>{let st=me.reduce((mt,fo)=>mt+fo.slots,0),$n=st*Ue.width+Math.max(0,st-1)*o.gap,Hn=i+Math.max(o.gap,(d-$n)/2),Fa=E.relationY+Ee*(Mt+Oe);for(let mt of me){let fo=mt.slots*m-o.gap,ja=mt.cards*m-o.gap,Wa=Hn+(fo-ja)/2;for(let mo=0;mo<mt.cards;mo++)it[W[mt.run]+be[mt.run]++]={x:Wa+mo*m,y:Fa};Hn+=mt.slots*m}})}Ye.forEach((m,W)=>{let _=it[W];ln({id:m.id,kind:m.kind,plane:1,x:_.x,y:_.y,width:Ue.width,height:Ue.height,...m.via?{via:m.via}:{},...m.aggregate?{aggregate:m.aggregate}:{},...Ke&&!m.aggregate?{compact:!0}:{}})});let Et=new Set(c.keys());for(let m of k)Et.add(m.id);let Xe=new Map;for(let m of e.allNodes()){let W=Xe.get(m.kind);W?W.push(m):Xe.set(m.kind,[m])}let ie=new Set(f.length>0?f:O?[O.kind]:[]),ve=[];for(let m of t.kinds){if(y.has(m))continue;let W=Xe.get(m)??[],_=W.filter(h);ve.push({id:we(m),kind:m,members:_.sort(dt),retired:W.length-_.length,...ie.has(m)?{focused:!0}:{}})}for(let m of ve)m.kind===n.relation&&(m.raised=!0);ve.sort(dt);let nt=li(t,ie),Rt=!n.overview&&t.kinds.some(m=>nt.rankOf(m)==="primary"),je=[];for(let m of ve)if(!n.overview&&Y.has(m.id)&&m.members.length>0)for(let W of m.members)je.push({id:W.id,kind:W.kind});else{let W=Rt?nt.rankOf(m.kind):void 0,_=W==="secondary"?nt.parentOf(m.kind):void 0;je.push({id:m.id,kind:m.kind,...m.raised?{raised:!0}:{},...m.focused?{focused:!0}:{},...n.overview&&Y.has(m.id)?{opened:!0}:{},...W?{rank:W}:{},..._&&!Y.has(we(_))?{nestedUnder:we(_)}:{},aggregate:{kind:m.kind,memberIds:m.members.map(oe=>oe.id),label:r.plurals?.[m.kind]??At(t,m.kind),...m.retired>0?{retired:m.retired}:{}}})}let Ot=2;if(je.length<=$((G?240:o.contextSize.width)*a))for(let m of je)delete m.nestedUnder;let sn=new Map;for(let m of je){if(m.nestedUnder===void 0)continue;let W=sn.get(m.nestedUnder)??0;W>=Ot?delete m.nestedUnder:sn.set(m.nestedUnder,W+1)}let dn=je.filter(m=>m.nestedUnder!==void 0),ht=je.filter(m=>m.nestedUnder===void 0),Vt=$((G?240:o.contextSize.width)*a),C=!n.overview&&ht.length>Vt,he=Math.max(0,Vt-1),xe=m=>m.focused?0:m.raised?1:2,Me=new Set([...ht].map((m,W)=>({item:m,at:W})).sort((m,W)=>xe(m.item)-xe(W.item)||m.at-W.at).slice(0,he).map(({item:m})=>m.id)),qe=new Set(C?ht.filter(m=>!Me.has(m.id)).map(m=>m.id):[]),Yt=dn.filter(m=>!qe.has(m.nestedUnder)),In=dn.filter(m=>qe.has(m.nestedUnder)),ft=C?[...ht.filter(m=>Me.has(m.id)),{id:Or,kind:"",beyond:[...ht.filter(m=>qe.has(m.id)),...In].map(m=>m.kind)}]:ht,at=n.overview?{width:Math.min(220,d/6.5),height:Math.min(92,o.height*.125)}:N(ft.length,(G?240:o.contextSize.width)*a,E.contextH),Tn=o.relevance?.flagged,Pn=(m,W)=>{let _=Bo(t,m);if(!_)return{};let oe=_.values.map(()=>0),be=0;for(let me of W){let Ee=_.values.indexOf(e.getNode(me)?.[_.field]);Ee<0?be++:oe[Ee]++}return{states:{field:_.field,values:[..._.values.map((me,Ee)=>({value:me,tier:_.tiers[Ee],count:oe[Ee]})),...be>0?[{value:null,tier:"waiting",count:be}]:[]]}}},ot=n.overview?Yo(ft.map(m=>{let W=m.aggregate?.memberIds??[],_=Tn?W.filter(oe=>Tn.has(oe)).length:0;return{id:m.id,kind:m.kind,count:W.length,opened:Y.has(m.id)?qt(Xt(W.length))*a:0,openedMin:Y.has(m.id)?qt(Math.min(Co,Xt(W.length)))*a:0,nameplate:di(m.aggregate?.label??At(t,m.kind),W.length,_,Bo(t,m.kind)!==void 0,a),weight:_*1e3+W.length,...f.includes(m.kind)&&(r.screens?.[m.kind]?.length??0)>0?{marquee:{width:Io+12,height:To(r.screens[m.kind].map(oe=>oe.title),Io,r.nameWidth)+8}}:{}}}),t,{width:o.width-l,height:o.height-u},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)]:ne&&m===O?.id?[O.kind]:[]),...r.tilt!==void 0?{tilt:r.tilt}:{},pan:{x:n.pan?.x??0,y:n.pan?.y??0},...V||o.chrome?.length?{avoid:[...V?[V]:[],...o.chrome??[]]}:{}}):null,gr=new Map(ot?.placed.map(m=>[m.id,m.plot])??[]),xr=new Map(ot?.placed.map(m=>[m.id,m.nameplate])??[]),lo=ot?ot.placed.map(({x:m,y:W,depth:_,width:oe,height:be})=>({x:m,y:W,depth:_,width:oe,height:be})):Ka(ft.length,at,o.gap,d,E.contextY,G?.97:fi).map(m=>({...m,x:m.x+i})),$a=.74,Cn=.8,Ha=52*a,Da=86*a,co=(m,W)=>Math.min(1,m+(1-m)*W),uo=new Map;ft.forEach((m,W)=>{let _=lo[W],oe=_.width??at.width,be=_.height??at.height,me=m.rank==="secondary"?$a:1,Ee=ot?oe:Math.max(Math.min(oe,_o*a),oe*me),st=ot?be:Math.max(hi*a,be*me);uo.set(m.id,{x:_.x+(oe-Ee)/2,y:_.y+(be-st),depth:m.rank==="secondary"?co(_.depth,.5):_.depth,width:Ee,height:st})});let Nn=[],Bn=lo[lo.length-1],ho=new Map;for(let m of Yt)ho.set(m.nestedUnder,(ho.get(m.nestedUnder)??0)+1);let br=new Map;for(let m of Yt){let W=uo.get(m.nestedUnder);if(W){let _=ho.get(m.nestedUnder)??1,oe=br.get(m.nestedUnder)??0;br.set(m.nestedUnder,oe+1);let be=.98,me=at.width*Cn,Ee=Math.max(Da,Math.min(me,W.width/(be*(_-1)+1))),st=Math.max(Ha,at.height*Cn*(Ee/me)),$n=Ee*be,Hn=(_-1)*$n+Ee;Nn.push({...m,x:W.x+(W.width-Hn)/2+oe*$n,y:Math.max(0,W.y-st+Math.min(st*.5,16)),width:Ee,height:st,depth:co(W.depth,.8)})}else if(Bn){let _=at.width*Cn,oe=at.height*Cn;Nn.push({...m,x:Bn.x,y:Bn.y,width:_,height:oe,depth:co(Bn.depth??1,.8)})}}for(let m of ft)Nn.push({...m,...uo.get(m.id)});return Nn.forEach(m=>{ln({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(Co,Xt(m.aggregate?.memberIds.length??0))),qt(Xt(m.aggregate?.memberIds.length??0))*(ot?.frame.openedShare??1))-zr)/Po))}:{},...m.rank?{rank:m.rank}:{},...m.nestedUnder?{nestedUnder:m.nestedUnder}:{},...m.beyond?{beyond:m.beyond}:{},...gr.has(m.id)?{plot:gr.get(m.id)}:{},...xr.has(m.id)?{nameplate:xr.get(m.id)}:{},...ot&&m.aggregate?Pn(m.kind,m.aggregate.memberIds):{},depth:m.depth})}),{nodes:s,connectors:ui(e,c,n),width:o.width,height:o.height,...ot?{city:ot.frame}:{},...l>0||u>0?{visible:{width:o.width-l,height:o.height-u}}:{}};function ln(m){let W=n.overview&&Ae(m.id)!==null?void 0:n.pins[m.id],_=W?{...m,x:W.x,y:W.y,pinned:!0}:{...m,pinned:!1},oe=n.pan?{..._,x:_.x+n.pan.x,y:_.y+n.pan.y}:_;s.push(oe),c.set(oe.id,oe)}}function Ko(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 Uo(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 ge=(e,t,n)=>e+(t-e)*n;function mi(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}var pi=new WeakMap;function Ua(e){let t=pi.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},pi.set(e,t),t}var yi=new WeakMap;function gi(e,t){let n=yi.get(t);if(n||yi.set(t,n=new WeakMap),n.has(e))return n.get(e);let r=Xa(e,t);return n.set(e,r),r}function Xa(e,t){let{byId:n,groupsOf:r}=Ua(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(It(e.id)||Ae(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(mi),u=l.reduce((s,c)=>s+c.x,0)/l.length,d=l.reduce((s,c)=>s+c.y,0)/l.length;return{...e,x:u-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=mi(o);return{...e,x:a.x-e.width/2,y:a.y-e.height/2}}function Ft(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,c]of o){let h=a.get(s);if(h){i.push(Xo(c,h,r,1));continue}let y=gi(c,t)??c;i.push(Xo(c,y,r,1-r))}for(let[s,c]of a){if(o.has(s))continue;let h=gi(c,e)??c;i.push(Xo(h,c,r,r))}let l=new Map(e.connectors.map(s=>[s.id,s])),u=new Map(t.connectors.map(s=>[s.id,s])),d=[];for(let[s,c]of l){let h=u.get(s);d.push(h?{...qa(c,h,r),opacity:1}:{...c,opacity:1-r})}for(let[s,c]of u)l.has(s)||d.push({...c,opacity:r});return{nodes:i.filter(s=>s.opacity>0).sort((s,c)=>s.id<c.id?-1:s.id>c.id?1:0),connectors:d.filter(s=>s.opacity>0).sort((s,c)=>s.id<c.id?-1:s.id>c.id?1:0),width:ge(e.width,t.width,r),height:ge(e.height,t.height,r),t:r,...xi(e.city,t.city,r)?{city:xi(e.city,t.city,r)}:{}}}function xi(e,t,n){return e?t?{cell:ge(e.cell,t.cell,n),...e.tilt!==void 0||t.tilt!==void 0?{tilt:ge(e.tilt??.5,t.tilt??.5,n)}:{},originX:ge(e.originX,t.originX,n),originY:ge(e.originY,t.originY,n),pan:{x:ge(e.pan.x,t.pan.x,n),y:ge(e.pan.y,t.pan.y,n)},extent:{x:ge(e.extent.x,t.extent.x,n),y:ge(e.extent.y,t.extent.y,n),width:ge(e.extent.width,t.extent.width,n),height:ge(e.extent.height,t.extent.height,n)}}:e:t}function Xo(e,t,n,r){return{id:t.id,kind:t.kind,plane:ge(e.plane,t.plane,n),x:ge(e.x,t.x,n),y:ge(e.y,t.y,n),width:ge(e.width,t.width,n),height:ge(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:ge(e.depth??1,t.depth,n)},...t.natural?{natural:t.natural}:{}}}function qa(e,t,n){return{...t,x1:ge(e.x1,t.x1,n),y1:ge(e.y1,t.y1,n),x2:ge(e.x2,t.x2,n),y2:ge(e.y2,t.y2,n)}}function Xn(e){let t=Math.max(0,Math.min(1,e));return t<.5?4*t*t*t:1-(-2*t+2)**3/2}function Qa(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),u=Math.max(a.y,i.y);t<l||t>=u||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 Za(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 Ja(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 es(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 ts(e,t){let{room:n,height:r,size:o,floor:a,measure:i=Lo,lines:l=2}=t,u=(f,p)=>f.every(v=>i(v,p)<=n)&&f.length*p*1.15<=r;if(u([e],o))return{lines:[e],fontSize:o,whole:!0};let d=e.split(/\s+/);if(l>1&&d.length>1){let f=1,p=1/0,v=0;for(let x=0;x<d.length-1;x+=1){v+=d[x].length+1;let O=Math.abs(v-e.length/2);O<p&&(p=O,f=x+1)}let k=[d.slice(0,f).join(" "),d.slice(f).join(" ")];if(u(k,o))return{lines:k,fontSize:o,whole:!0};for(let x=o;x>=a;x-=o*.06)if(u(k,x))return{lines:k,fontSize:x,whole:!0}}for(let f=o;f>=a;f-=o*.06)if(u([e],f))return{lines:[e],fontSize:f,whole:!0};let s=i(e,a)/Math.max(1,e.length),c=Math.floor(n/s)-1;if(c<4||a*1.15>r)return null;let h=e.slice(0,c),y=h.lastIndexOf(" ");return{lines:[`${y>3?h.slice(0,y):h}\u2026`],fontSize:a,whole:!1}}var ns=(e,t)=>e.x0<t.x1&&t.x0<e.x1&&e.y0<t.y1&&t.y0<e.y1;var q=se(Ce(),1);var bt=se(Ce(),1);function bi(e){let[t,n]=(0,bt.useState)(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(e).matches);return(0,bt.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 os(){let e=()=>typeof document>"u"?null:document.documentElement.getAttribute("data-graview-motion"),[t,n]=(0,bt.useState)(e);return(0,bt.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 wi(e){let t=bi("(prefers-reduced-motion: reduce)"),n=bi("(prefers-reduced-transparency: reduce)"),r=os();return Dr({off:!e,reducedMotion:r==="reduce"||r!=="full"&&t,reducedTransparency:n})}var rs=Nr*1.5,is=30;function vi(e,t){let[n,r]=(0,bt.useState)(!1),o=e&&!n;return(0,bt.useEffect)(()=>{if(!o||!t||typeof requestAnimationFrame>"u")return;let a=[],i=0,l=0,u=d=>{if(i>0&&a.push(d-i),i=d,a.length>=is){if(!Fr(a,rs)){r(!0);return}a.length=0}l=requestAnimationFrame(u)};return l=requestAnimationFrame(u),()=>cancelAnimationFrame(l)},[o,t]),o}var We=se(Ce(),1);var as=520;function ss(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function ki(e,t={}){let n=t.duration??as,r=(t.enabled??!0)&&!ss(),o=(0,We.useRef)(e),[a,i]=(0,We.useState)(()=>Ft(e,e,1)),l=(0,We.useRef)(a),u=(0,We.useRef)(null),d=(0,We.useRef)(null);return(0,We.useEffect)(()=>{if(!r||typeof requestAnimationFrame>"u"){o.current=e;let p=Ft(e,e,1);if(l.current=p,i(p),typeof requestAnimationFrame>"u")return;let v=requestAnimationFrame(()=>{let k=Ft(e,e,1);l.current=k,i(k)});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 y=Xn(Math.min(1,(s-h)/n)),w=o.current,f=p=>{let v=Math.min(1,(p-h)/n),k=y>=1?1:(Xn(v)-y)/(1-y),x=Ft(w,e,Math.max(0,k));l.current=x,i(x),v<1?u.current=requestAnimationFrame(f):(d.current=null,o.current=e,u.current=requestAnimationFrame(()=>{let O=Ft(e,e,1);l.current=O,i(O),u.current=null}))};return u.current=requestAnimationFrame(f),()=>{u.current!==null&&cancelAnimationFrame(u.current);let p=l.current;o.current={...e,...p.city?{city:p.city}:{},nodes:p.nodes.map(v=>({...v,plane:Math.round(v.plane)})),connectors:p.connectors}}},[e,n,r]),a}function Si(e=1100){let{store:t}=ye(),[n,r]=(0,We.useState)(()=>new Set);return(0,We.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 ds={marks:new Map,acts:[]};function Mi(e=4e3){let{store:t}=ye(),[n,r]=(0,We.useState)(ds);return(0,We.useEffect)(()=>{let o=null,a=t.subscribe((i,l)=>{r(u=>{let d=new Map(u.marks),s=[...u.acts];for(let c of l){if(c.undoes!==void 0){let w=s.find(p=>p.batch===c.undoes||p.wrote.length>0),f=s.filter(p=>c.writes.some(v=>p.wrote.includes(v)));for(let p of f.length>0?f:w?[w]:[]){for(let v of p.wrote)d.delete(v);s=s.filter(v=>v.batch!==p.batch)}continue}if(c.author.kind!=="agent")continue;let h=c.author.id??"the seat";for(let w of c.writes)d.set(w,h);s.find(w=>w.batch===c.batch)?s=s.map(w=>w.batch===c.batch?{...w,wrote:[...new Set([...w.wrote,...c.writes])]}:w):s=[{batch:c.batch,who:h,intent:c.batchIntent??c.intent,at:c.at,wrote:[...c.writes]},...s].slice(0,12)}return d.size===u.marks.size&&s===u.acts&&d.size===0?u:{marks:d,acts:s}}),o&&clearTimeout(o),o=setTimeout(()=>r(u=>u.marks.size===0?u:{...u,marks:new Map}),e)});return()=>{a(),o&&clearTimeout(o)}},[t,e]),n}var jt=se(Ie(),1),Qe=16;function Ei({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,u=[];for(let[s,c]of e){let h=null;if(i&&l&&typeof CSS<"u"){let p=i.querySelector(`[data-graview-pick="${CSS.escape(s)}"]`)?.getBoundingClientRect();p&&p.width>0&&p.height>0&&(h={x:p.left-l.left,y:p.top-l.top,width:p.width,height:p.height})}if(h??=n(s),!h)continue;let y=Math.min(Math.max(h.x+h.width-Qe/2,Qe/2),o-Qe/2),w=Math.min(Math.max(h.y-Qe/4,Qe/2),a-Qe/2);u.push({id:s,who:c,x:y,y:w})}let d=[];for(let s of t){let c=n(s.id);c&&d.push({...s,x:Math.min(Math.max(c.x+c.width/2,Qe),o-Qe),y:Math.min(Math.max(c.y-Qe/2,Qe),a-Qe)})}return u.length===0&&d.length===0?null:(0,jt.jsxs)("div",{className:"graview-seat-marks","data-testid":"seat-marks","data-graview-seat-marks":u.length,children:[u.map(({id:s,who:c,x:h,y})=>(0,jt.jsx)("span",{className:"graview-seat-mark","data-testid":"seat-mark","data-graview-seat-mark":s,"data-graview-seat-who":c,title:`${c} just changed this`,"aria-hidden":"true",style:{left:h,top:y,"--graview-hue":hn(c)},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 te=se(Ie(),1);function ls({hue:e,mode:t}){let n=t==="docked";return(0,te.jsxs)("svg",{viewBox:"0 0 32 38","aria-hidden":"true",children:[(0,te.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round",strokeLinecap:"round",children:[(0,te.jsx)("line",{x1:"16",y1:"3.5",x2:"16",y2:"7"}),(0,te.jsx)("circle",{cx:"16",cy:"2.6",r:"1.5",fill:"none"}),(0,te.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,te.jsx)("line",{x1:"11",y1:"12.5",x2:"21",y2:"12.5",strokeWidth:"2"}):(0,te.jsxs)(te.Fragment,{children:[(0,te.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,te.jsx)("circle",{cx:"13.4",cy:"12.5",r:"1.25",fill:"currentColor",stroke:"none",opacity:n?.45:1}),(0,te.jsx)("circle",{cx:"18.6",cy:"12.5",r:"1.25",fill:"currentColor",stroke:"none",opacity:n?.45:1}),t==="reading"?(0,te.jsx)("line",{x1:"10.2",y1:"12.5",x2:"21.8",y2:"12.5",strokeWidth:"0.8",opacity:"0.7"}):null]}),(0,te.jsx)("line",{x1:"16",y1:"16",x2:"16",y2:"18.5"}),(0,te.jsx)("polygon",{points:"16,18.5 24,22.5 16,26.5 8,22.5",fill:"currentColor",fillOpacity:"0.22"}),(0,te.jsx)("polygon",{points:"8,22.5 16,26.5 16,33.5 8,29.5",fill:"currentColor",fillOpacity:"0.08"}),(0,te.jsx)("polygon",{points:"24,22.5 16,26.5 16,33.5 24,29.5",fill:"currentColor",fillOpacity:"0.3"}),t==="writing"?(0,te.jsxs)(te.Fragment,{children:[(0,te.jsx)("polyline",{points:"24,24 28.5,20.5"}),(0,te.jsx)("line",{x1:"27.5",y1:"19",x2:"30",y2:"21.5",strokeWidth:"1.8"})]}):(0,te.jsx)("line",{x1:"24",y1:"24",x2:"26.5",y2:"29"}),(0,te.jsx)("line",{x1:"8",y1:"24",x2:"5.5",y2:"29"}),(0,te.jsx)("path",{d:"M9.5 33.5 v2.2 h4"}),(0,te.jsx)("path",{d:"M22.5 33.5 v2.2 h-4"})]}),(0,te.jsx)("title",{children:`robot, ${t}`})]})}function cs({hue:e}){return(0,te.jsxs)("svg",{viewBox:"0 0 22 24","aria-hidden":"true",style:{color:`hsl(${Math.round(e)} 50% 48%)`},children:[(0,te.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round",strokeLinecap:"round",children:[(0,te.jsx)("circle",{cx:"11",cy:"6",r:"4.2"}),(0,te.jsx)("path",{d:"M3 23 C3 15.5 6 13 11 13 C16 13 19 15.5 19 23"})]}),(0,te.jsx)("title",{children:"somebody"})]})}function Ri({width:e,whereIs:t}){let{who:n,following:r,follow:o}=ye(),a=Kr([...n.values()],t,e);return a.length===0?null:(0,te.jsx)("div",{className:"graview-occupants","data-testid":"occupants","data-graview-occupants":a.length,children:a.map((i,l)=>{if(i.kind==="over")return(0,te.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,te.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 u=i.presence.hue,d=Mr(i.presence)||"somebody";if(i.kind==="edge")return(0,te.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,te.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":u},children:[(0,te.jsx)("span",{className:"graview-figure-body",role:"img","aria-label":`${d}'s agent \u2014 ${i.mode}`,style:{cursor:"default"},children:(0,te.jsx)(ls,{hue:u,mode:i.mode})}),(0,te.jsxs)("span",{className:"graview-figure-name",children:[d,"'s agent"]})]},`robot:${i.presence.participant}`);let s=r?.participant===i.presence.participant;return(0,te.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":u},children:[(0,te.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:c=>{c.stopPropagation(),o(s?null:i.presence.participant)},onPointerDown:c=>c.stopPropagation(),children:(0,te.jsx)(cs,{hue:u})}),(0,te.jsx)("span",{className:"graview-figure-name",children:d})]},`person:${i.presence.participant}`)})})}var Qn=se(Ce(),1),En=se(Ie(),1),Oi={left:"\u2190",right:"\u2192",top:"\u2191",bottom:"\u2193"},qo=36,Mn=56;function Ai({result:e,schema:t,chrome:n=[],onGo:r}){let o=zo(e);if(o.length===0)return null;let a=s=>(s??[]).flatMap(c=>{let h=e.nodes.find(y=>y.id===c.id);return h?[{left:h.x+c.x,top:h.y+c.y,right:h.x+c.x+c.width,bottom:h.y+c.y+c.height}]:[]}),i=a(e.city?.showings),l=a(e.city?.nameplates),u=[...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 c=e.visible??e,h=s==="left"||s==="right"?c.height:c.width,y=s==="left"||s==="right",w=s==="bottom"?fs:s==="top"?Mn:ms+Mn/2,f=-1/0,p=[],v=o.filter(k=>k.side===s).sort((k,x)=>k.along-x.along);for(let k of v){let x=un(t,k.kind),O=us(x),G=y?qn:O/2,F=h-w-(y?0:G),Q=Math.max(Mn,k.along,f+G+hs);if(Q>F)continue;let{at:z,inset:g}=ps([...u,...p],s,Q,O,c,h);if(z>F+.5)continue;f=z+G,p.push(Li(s,z,O,c,g));let E=s==="left"?{left:g,top:z,transform:"translateY(-50%)"}:s==="right"?{right:`calc(${g}px + var(--graview-dock, 0px))`,top:z,transform:"translateY(-50%)"}:s==="top"?{top:g,left:z,transform:"translateX(-50%)"}:{bottom:`calc(${g}px + var(--graview-scene-foot, var(--graview-sheet, 0px)))`,left:z,transform:"translateX(-50%)"};d.push((0,En.jsx)("button",{type:"button",className:"graview-edge-sign","data-graview-past-edge":k.id,"aria-label":`${x}, past the ${s} edge \u2014 bring it into view`,title:`${x} is past the ${s} edge`,tabIndex:-1,onPointerDown:I=>I.stopPropagation(),onClick:I=>{I.stopPropagation(),r(k.by)},style:{...ys,...E},children:s==="right"||s==="bottom"?`${x} ${Oi[s]}`:`${Oi[s]} ${x}`},k.id))}}return(0,En.jsx)(En.Fragment,{children:d})}var us=e=>(e.length+2)*7.4+22,qn=qo/2,Sn=6,hs=6,fs=236,ms=56;function Li(e,t,n,r,o=Sn){return e==="left"||e==="right"?{left:e==="left"?o:r.width-o-n,right:e==="left"?o+n:r.width-o,top:t-qn,bottom:t+qn}:{left:t-n/2,right:t+n/2,top:e==="top"?o:r.height-o-qo,bottom:e==="top"?o+qo:r.height-o}}function ps(e,t,n,r,o,a){let i=t==="left"||t==="right",l=f=>Li(t,f,r,o),u=f=>e.find(p=>{let v=l(f);return v.left<p.right&&p.left<v.right&&v.top<p.bottom&&p.top<v.bottom}),d=u(n);if(!d)return{at:n,inset:Sn};let s=i?qn:r/2,c=f=>{let p=n;for(let v=0;v<12;v++){let k=u(p);if(!k)return p;if(p=f>0?(i?k.bottom:k.right)+s+4:(i?k.top:k.left)-s-4,p>a-Mn||p<Mn)return null}return null},h=c(1);if(h!==null)return{at:h,inset:Sn};let y=c(-1);if(y!==null)return{at:y,inset:Sn};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(Sn,w+4)}}var ys={position:"absolute",zIndex:He.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 Ii(e){let[t,n]=(0,Qn.useState)(null);return(0,Qn.useLayoutEffect)(()=>{let r=e.current,o=null;for(let l=r?.parentElement??null,u=0;l&&!o&&u<4;l=l.parentElement,u++)o=l.querySelector(":scope > [data-graview-scene-trail]");if(!r||!o)return;let a=()=>{let l=r.getBoundingClientRect(),u=o.getBoundingClientRect(),d=u.width>0&&u.height>0?{x:u.left-l.left,y:u.top-l.top,width:u.width,height:u.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 wt=se(Ce(),1),gs=180;function Ti({view:e,result:t,frame:n,panned:r,closer:o,screenId:a,setCamera:i}){let l=(0,wt.useRef)(new Map),u=Math.round((t.nodes.find(c=>c.id===a)?.height??0)/16),d=(0,wt.useRef)(e.overview??!1),s=(0,wt.useRef)(null);if((0,wt.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 c=t.nodes.find(F=>F.id===a);if(!c)return;let h=o>1&&c.screenOf?t.nodes.find(F=>F.id===we(c.screenOf)):void 0,y=h?{x:Math.min(c.x,h.x),y:Math.min(c.y,h.y),width:Math.max(c.x+c.width,h.x+h.width)-Math.min(c.x,h.x),height:Math.max(c.y+c.height,h.y+h.height)-Math.min(c.y,h.y)}:c;if(y.x>=0&&y.y>=0&&y.x+y.width<=t.width&&y.y+y.height<=t.height&&!h)return;let f=24,p=(F,Q,z)=>F<f?f-F:F+Q>z-f?z-f-(F+Q):0,v=xt(t),k=e.pan??{x:0,y:0},x=h?r.x+(t.width/2-(y.x+y.width/2)):r.x+p(y.x,y.width,t.width),O=t.height/2-(y.y+y.height/2),G=h?r.y+(c.y+O<f?f-c.y:O):r.y+p(y.y,y.height,t.height);i({x:(h?x:Math.max(-v.x,Math.min(v.x,x)))-k.x,y:(h?G:Math.max(-v.y,Math.min(v.y,G)))-k.y})},[a,e.overview,o,e.within?.view,u]),n.city){let c=new Map;for(let h of n.nodes){if(!h.plot||Math.round(h.plane)!==2)continue;let y=Zt(h.plot.col+h.plot.side/2,h.plot.row+h.plot.side/2,n.city.cell,n.city.tilt);c.set(h.id,{x:n.city.originX+r.x+y.x,y:n.city.originY+r.y+y.y})}l.current=c}return(0,wt.useEffect)(()=>{let c=e.overview??!1,h=d.current&&!c;if(d.current=c,c&&s.current&&(clearTimeout(s.current),s.current=null),!h)return;let y=e.focusId?yt(e.focusId)[0]:void 0,w=y?l.current.get(we(y)):void 0,f=t.nodes.find(p=>p.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})},gs)},[e.overview]),(0,wt.useEffect)(()=>()=>{s.current&&clearTimeout(s.current)},[]),{gliding:()=>s.current!==null}}var Jn=se(Ce(),1),Zn="[data-graview-view]";function xs(e,t){let n=null;for(let r=e?.closest(Zn)??null;r&&t.contains(r);r=r.parentElement?.closest(Zn)??null)n=r;return n}function Pi(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 Ci(e,t,n){let r=(0,Jn.useRef)({dock:t,reveal:n});r.current={dock:t,reveal:n},(0,Jn.useEffect)(()=>{let o=e.current;if(!o)return;let a=u=>{let{dock:d}=r.current;if(u.key!=="Tab"||u.defaultPrevented||d.right<=0&&d.bottom<=0)return;let s=Pi(o,d),c=[];for(let h of o.querySelectorAll(Zn)){if(h.parentElement?.closest(Zn)||h.inert||h.contains(document.activeElement))continue;let y=h.getBoundingClientRect(),w=Math.max(y.left,s.box.left),f=Math.min(y.right,s.box.right),p=Math.max(y.top,s.box.top),v=Math.min(y.bottom,s.box.bottom);f<=w||v<=p||!(d.right>0&&w>=s.right-1||d.bottom>0&&p>=s.bottom-1)||(h.inert=!0,c.push(h))}c.length!==0&&setTimeout(()=>{for(let h of c)h.inert=!1},0)},i=u=>{let d=u.target,s=xs(d,o);if(!s)return;let c=!0;try{c=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);c&&s.isConnected&&l(s)})},l=u=>{let d=Pi(o,r.current.dock),s=u.getBoundingClientRect(),c=12,h=(f,p,v,k)=>k-v>p-f-2*c||v<f+c?f+c-v:k>p-c?p-c-k:0,y=h(d.left,d.right,s.left,s.right),w=h(d.top,d.bottom,s.top,s.bottom);(Math.abs(y)>=1||Math.abs(w)>=1)&&r.current.reveal(Math.round(y),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(Ce(),1);function Ni(){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(u=>u.right===l.right&&u.bottom===l.bottom?u:l)};if(o(),typeof ResizeObserver>"u")return;let a=new ResizeObserver(o);return a.observe(r),()=>a.disconnect()},[]),{probe:e,dock:t}}function Bi(){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 $i({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 u=(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,p=w===0&&f===0?"":`translate3d(${w}px, ${f}px, 0)`;for(let v of u())v.style.transform=p}))},[u]),s=(0,de.useCallback)(()=>{i.current=!1;for(let w of u())w.style.transform="";l.current()},[u]),c=(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(p=>{let v=p.pan??{x:0,y:0};return $t(p,{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 y=(0,de.useCallback)(()=>o.current,[]);return{shiftTo:c,settle:h,settling:i,offset:y}}var bs=4;function Hi({view:e,panned:t,limit:n,panWithin:r,moveByTransform:o,setView:a,setDragging:i,noteMoved:l,shift:u,district:d}){let s=(0,de.useRef)(!1),c=(0,de.useRef)(null),h=v=>{let k=e.pan??{x:0,y:0};c.current={kind:"pan",fromX:v.clientX,fromY:v.clientY,baseX:k.x,baseY:k.y,moved:!1}};return{onGroundDown:v=>{v.button===0&&(v.target.closest("[data-graview-view]")||h(v))},onCardDown:(v,k)=>{if(k.button===0){if(v.screenOf!==void 0&&!k.target.closest("[data-graview-grip]")){h(k);return}if(e.overview&&Ae(v.id)!==null){h(k);return}c.current={kind:"card",id:v.id,fromX:k.clientX,fromY:k.clientY,baseX:v.x-t.x,baseY:v.y-t.y,moved:!1}}},onDragMove:v=>{let k=c.current;if(!k)return;let x=v.clientX-k.fromX,O=v.clientY-k.fromY;if(!k.moved){if(Math.hypot(x,O)<bs)return;k.moved=!0,i(!0),v.currentTarget.setPointerCapture(v.pointerId)}if(k.kind==="pan"){let G=r(n(),{x:k.baseX+x,y:k.baseY+O});o?u.shiftTo(G,e.pan??{x:0,y:0}):a(F=>$t(F,G))}else k.id&&d.place({id:k.id,x:k.baseX+x,y:k.baseY+O})},onDragUp:()=>{u.settle();let v=d.release();v&&a(k=>bn(k,v.id,{x:v.x,y:v.y})),c.current?.moved&&(s.current=!0,setTimeout(()=>s.current=!1,0),l()),c.current=null,!u.settling.current&&i(!1)},swallow:s}}function Di({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=(c,h)=>{let y=r.current;if(h<y.coolUntil)return;let w=y.view.overview??!1;c!==w&&(y.coolUntil=h+600,y.charge=0,n(fn(y.view,c)))},u=c=>{let h=r.current,y=h.view.overview??!1;if(c.ctrlKey){if(c.preventDefault(),!y){if(h.charge+=c.deltaY,Math.abs(h.charge)<60)return;h.charge>0?l(!0,performance.now()):h.charge=0;return}o.current(Math.exp(-c.deltaY*.004),c.clientX,c.clientY);return}!y||c.target?.closest("[data-graview-view], .graview-scroll, [data-graview-overlay], .graview-zoom")||(c.preventDefault(),a.current(-c.deltaX,-c.deltaY))},d=c=>{c.preventDefault(),r.current.lastScale=1},s=c=>{c.preventDefault();let h=r.current,y=c.scale??1;if(!(h.view.overview??!1)){y<.72&&l(!0,performance.now());return}let w=y/(h.lastScale||1);h.lastScale=y;let f=c;o.current(w,f.clientX,f.clientY)};return i.addEventListener("wheel",u,{passive:!1}),i.addEventListener("gesturestart",d),i.addEventListener("gesturechange",s),()=>{i.removeEventListener("wheel",u),i.removeEventListener("gesturestart",d),i.removeEventListener("gesturechange",s)}},[n,e]),{zoomAbout:o,panBy:a}}var Fi={directed:"You",autonomous:"An agent","co-edited":"You and an agent",rule:"A rule"};function Qo(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 Zo(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 Jo(e){return e.edgeChosen?.9:e.lit?.78:e.own*(e.anyLit?e.kit.dim:e.kit.rest)}function rt(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?Kt(n,t):Ir(Kt(n,t),Kt(r,t),e.plane-n);return{x:e.x,y:e.y,width:e.width*o,height:e.height*o}}function tn(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 u=t.getBoundingClientRect();return{x:n-u.left,y:r-u.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 tn(a,e)}function eo(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)??rt(d,n):null}let i=a(o),l=Ae(o);if(!i&&l!==null&&(i=a(Le(l))),!i&&It(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 u=e.city!==void 0;return De(t,i.id,u&&i.aggregate!==void 0&&Math.round(i.plane)===2)??rt(i,n)}var lt=se(Ce(),1);var le=se(Ie(),1);function Wi({kinds:e}){let{store:t}=ye(),{view:n,go:r}=Eo(),o=(0,lt.useRef)(null),a=Oo("districts",{align:"start"}),i=a.open,l=h=>un(t.schema,h),u=h=>t.graph.allNodes().filter(y=>y.kind===h).length,d=h=>!n.overview&&n.focusId===Le(h),s=e.filter(h=>!d(h)),c=h=>{a.setOpen(!1);let y=o.current?.querySelector(".graview-beyond-more")??null;d(h)||r(pt(n,Le(h))),y?.focus({preventScroll:!0});let w=`[data-graview-view="${Le(h)}"][tabindex], [data-graview-view="${we(h)}"][tabindex]`,f=40,p=()=>{let v=document.querySelector(w);v?v.focus({preventScroll:!0}):--f>0&&requestAnimationFrame(p)};requestAnimationFrame(p)};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:Ro,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:y=>y.stopPropagation(),onClick:y=>{y.stopPropagation(),c(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":u(h)})]})},h))}):null]})}function ws(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"||tr(e[r],t[r]))}function tr(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(!tr(e[a],o[a]))return!1;return!0}let r=Object.keys(e);return r.length!==Object.keys(t).length?!1:r.every(o=>tr(e[o],t[o]))}var Vi=(0,lt.memo)(Yi,(e,t)=>e.mode===t.mode&&e.selected===t.selected&&e.fidelity===t.fidelity&&ws(e.node,t.node));function Yi({node:e,mode:t,selected:n,fidelity:r}){let{store:o,views:a,view:i}=ye(),l=Pt(),u=_r(),d=Gr(),s=e.aggregate||It(e.id)||Ae(e.id)!==null?"many":"one",c={cardinality:s,fidelity:r??Lr[ks(e.plane)].fidelity},h=s==="many"&&e.id===i.focusId?i.within?.view:void 0,y=a.resolve(e.kind,c,h),w=y?.view,f=a.resolve(e.kind,{cardinality:"many",fidelity:"full"})?.view,p=f!==void 0&&f.generic!==!0,v=e.aggregate?.memberIds,k=(0,lt.useMemo)(()=>(v??[]).map(G=>o.graph.getNode(G)).filter(G=>G!==void 0),[v,o,l]),x={...e.aggregate?{nodes:k,label:y?.title??e.aggregate.label}:{node:o.graph.getNode(e.id)},fidelity:c.fidelity,cardinality:c.cardinality,mode:t,selected:n,implicated:u,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}:{},...p?{hasOwnView:!0}:{}};if(!w)return(0,le.jsx)(Ss,{node:e,props:x});let O=[e.id,y?.title??"",c.fidelity,c.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(G=>G.count).join(","):"",e.aggregate?er(e.aggregate.memberIds):"",e.aggregate?.retired??"",u?er(u):"",d?er(d):"",p].join("|");return(0,le.jsx)(ko,{mode:t,children:(0,le.jsx)(Ur,{kind:x.label??e.kind,...y?.title?{view:y.title}:{},children:(0,le.jsx)(vs,{signature:O,graph:l,draw:()=>(0,le.jsx)(w,{...x})})},`${e.id}|${y?.title??""}`)})}var vs=(0,lt.memo)(function({draw:t}){return(0,le.jsx)(le.Fragment,{children:t()})},(e,t)=>e.signature===t.signature&&e.graph===t.graph);function ks(e){return Math.max(0,Math.min(2,Math.round(e)))}function Ss({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 zi=(0,lt.memo)(function({node:t}){let{store:n}=ye(),r=Tt(),o=t.aggregate,a=o.opens,i=o.memberIds.length,l=zt(n.schema,o.kind,i),u=o.memberIds.slice(0,3).map(h=>{let y=n.graph.getNode(h),w=y?n.schema.tryDefinition(y.kind):void 0;return y?w?.label?w.label(y):String(y.label??h):h}),d=o.memberIds,s=(0,lt.useMemo)(()=>{let h=r?Wn(r):null;return h?d.filter(y=>h.has(y)).length:0},[r,d]),c=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:c?`${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:c?"\u2197":"\u25BE"})]}),(0,le.jsxs)("span",{className:"graview-band-group-names",children:[c?null:(0,le.jsxs)("span",{className:"graview-band-group-count",children:[l,s>0?` \xB7 ${s} match`:""," \xB7 "]}),u.join(" \xB7 "),i>u.length?" \u2026":""]})]})}),ji=new WeakMap;function er(e){let t=ji.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 ji.set(e,r),r}var vt=se(Ce(),1);function nr(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 Gi(){let[e,t]=(0,vt.useState)(16);return(0,vt.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 _i(e){let[t,n]=(0,vt.useState)(null);return(0,vt.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,vt.useEffect)(()=>{let r=e.current;if(!r||typeof ResizeObserver>"u")return;let o=l=>{!l||l.width===0||l.height===0||n(u=>{let d={width:Math.round(l.width),height:Math.round(l.height)};return u&&u.width===d.width&&u.height===d.height?u: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 or(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 Ki(e){return`matrix3d(${e.join(",")})`}var fe=se(Ce(),1);var rr=(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 ir(e,t){let n=[],r=[];for(let a=0;a<e.length-1;a++){let i=e[a],l=e[a+1],u=!rr(i,t);u&&r.length===0&&r.push(i);for(let d=1;d<=48;d++){let s=d/48,c={x:i.x+(l.x-i.x)*s,y:i.y+(l.y-i.y)*s},h=!rr(c,t);if(h===u)continue;let y=(d-1)/48,w=s;for(let v=0;v<10;v++){let k=(y+w)/2,x={x:i.x+(l.x-i.x)*k,y:i.y+(l.y-i.y)*k};!rr(x,t)===u?y=k:w=k}let f=(y+w)/2,p={x:i.x+(l.x-i.x)*f,y:i.y+(l.y-i.y)*f};h?r=[p]:(r.push(p),r.length>=2&&n.push(r),r=[]),u=h}u&&r.push(l)}return r.length>=2&&n.push(r),n}function Rn(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 Ge=e=>Math.round(e*100)/100,kt=e=>e.map(t=>t.map((n,r)=>`${r===0?"M":"L"} ${Ge(n.x)} ${Ge(n.y)}`).join(" ")).join(" ");function ar(e,t){if(e.length<3)return kt([e]);let n=[`M ${Ge(e[0].x)} ${Ge(e[0].y)}`];for(let o=1;o<e.length-1;o++){let a=e[o-1],i=e[o],l=e[o+1],u=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,u/2,d/2),c={x:i.x+(a.x-i.x)/(u||1)*s,y:i.y+(a.y-i.y)/(u||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 ${Ge(c.x)} ${Ge(c.y)} Q ${Ge(i.x)} ${Ge(i.y)} ${Ge(h.x)} ${Ge(h.y)}`)}let r=e[e.length-1];return n.push(`L ${Ge(r.x)} ${Ge(r.y)}`),n.join(" ")}function Ui(e,t){return t==="orthogonal"?kt([e]):ar(e,10)}function Xi(e,t,n){if(e==="orthogonal"){let l=Rn(t.p0,t.p1),u=l.slice(1).map((c,h)=>Math.hypot(c.x-l[h].x,c.y-l[h].y)),d=u.reduce((c,h)=>c+h,0)||1,s=n*d;for(let c=0;c<u.length;c++){let h=u[c];if(s<=h||c===u.length-1){let y=h===0?0:Math.min(1,s/h),w=l[c],f=l[c+1];return{x:w.x+(f.x-w.x)*y,y:w.y+(f.y-w.y)*y}}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 to(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 qi(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 Qi(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 On=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,dr=(e,t)=>e.findIndex(n=>n.boxes.some(r=>On(r,t)));function Zi(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 cr(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 u=[];for(let d of n)for(let s of i){let c=Math.max(d.from,s.from),h=Math.min(d.to,s.to);h-c>=0&&u.push({from:c,to:h})}n=u}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,u=Math.abs(i-t)+(l?60:0);u<o&&(o=u,r=i)}return r}var Ze=e=>({x:e.x,y:-(e.y+e.height),width:e.width,height:e.height}),no=e=>e.map(t=>({x:t.x,y:-t.y}));function lr(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 ur(e,t,n){let r=e.boxes.filter(d=>!On(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=cr([e],i?t.x-12:t.x+t.width+12),u=t.y+t.height/2;return{x:l,tail:[{x:l,y:u},{x:l<t.x?t.x:t.x+t.width,y:u}]}}function sr(e,t,n){let r=ur({top:-e.bottom,bottom:-e.top,boxes:e.boxes.map(Ze)},Ze(t),n);return{x:r.x,head:no(r.tail).reverse()}}function Ji(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 ea=(e,t)=>(e%3-1)*Math.max(0,Math.min(4,t/2-3));function ta(e,t,n,r,o,a,i,l){let u=f=>f<0?e[0].top-n:e[f+1].top-e[f].bottom,d=f=>(f<0?(n+e[0].top)/2:Zi(e,f,f+1))+ea(l,u(f)),s=ur(e[a],o,i),c=Ji(e,a,s.x,t+1),h=d(t);if(c===t+1)return lr([...r.head,{x:r.x,y:h},{x:s.x,y:h},...s.tail]);let y=cr(e.slice(t+1,c),s.x),w=d(c-1);return lr([...r.head,{x:r.x,y:h},{x:y,y:h},{x:y,y:w},{x:s.x,y:w},...s.tail])}function nn(e,t,n,r=0){let o=Qi(n.some(s=>On(s,e))&&n.some(s=>On(s,t))?n:[...n,e,t]),a=dr(o,e),i=dr(o,t),l=e.x+e.width/2,u=t.x+t.width/2;if(a===i){if(!(a<o.length-1||o.length===1))return no(nn(Ze(e),Ze(t),n.map(Ze),r));let c=Zi(o,a,a+1)+ea(r,a<o.length-1?o[a+1].top-o[a].bottom:2*12),h=sr(o[a],e,u),y=sr(o[a],t,l);return lr([...h.head,{x:h.x,y:c},{x:y.x,y:c},...[...y.head].reverse()])}if(i<a)return no(nn(Ze(e),Ze(t),n.map(Ze),r));let d=sr(o[a],e,u);return ta(o,a,o[a].bottom,d,t,i,l,r)}function hr(e,t,n,r=0){if(t.y+t.height<=e.y){let y=hr(Ze(e),Ze(t),n.map(Ze),r);return y?no(y):null}let o=e.y+e.height;if(t.y<o)return null;let a=Qi([...n.filter(y=>y.y>=o&&!On(y,t)),t]),i=dr(a,t),l=t.x+t.width/2,u=ur(a[i],t,l),d=Ji(a,i,u.x,0),s=d===0?u.x:cr(a.slice(0,d),u.x),c=Math.min(12,e.width/2),h=Math.min(Math.max(s,e.x+c),e.x+e.width-c);return ta(a,-1,o,{x:h,head:[{x:h,y:o}]},t,i,l,r)}function na(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 Ve=se(Ie(),1);function mr(e,t,n,r){let o=[];for(let a of e.querySelectorAll("[data-graview-relation] > span")){let i=a.getBoundingClientRect();if(i.width<=0||i.height<=0)continue;let l=i.top-t.top,u=a.parentElement?.getAttribute("data-graview-relation"),d=1/0;for(let s of n){if(Math.round(s.plane)!==1||!s.via||`${s.via.edgeKind}|${s.via.direction}`!==u)continue;let c=r(s.id);c&&c.y>=l+i.height-1&&(d=Math.min(d,c.y))}o.push({x:i.left-t.left,y:l,width:i.width,height:d-l<=i.height*4?d-l:i.height})}return o}function ro(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},u=oo(e,i),d=oo(t,l),s=Math.hypot(d.x-u.x,d.y-u.y);if(s<8)return null;let c=Math.min(36,s*.12),h=-(d.y-u.y)/s,y=(d.x-u.x)/s;return{from:u,to:d,control:{x:(u.x+d.x)/2+h*c,y:(u.y+d.y)/2+y*c},mode:"direct"}}function oo(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),u=Math.min(i,l),d=Math.max(0,u*.98);return{x:n+o*d,y:r+a*d}}function Ms(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 ra=e=>({clips:new Map,members:new Map,marks:new Map,...e?{owed:e}:{}});function ia(e,t){let n=ra();for(let[r,o]of t){let a=e.querySelector(`[data-graview-view="${CSS.escape(r)}"]`);if(a!==null){for(let i of o)if(on(e,a,i,n).length>0)return!0}}return!1}function aa(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 Es(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 Rs(e,t,n){let r=e.parentElement;for(;r!==null;){let o=Es(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 on(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 d of aa(t,r).get(n)??[]){if(d.closest("[data-graview-offstage]"))continue;let s=d.getBoundingClientRect();s.width<=2||s.height<=2||Rs(d,s,r)&&l.push({x:s.left-i.left,y:s.top-i.top,width:s.width,height:s.height})}l.sort((d,s)=>d.width*d.height-s.width*s.height),o.set(n,l);let u=t.getAttribute("data-graview-view");return l.length===0&&r.owed&&u!==null&&r.owed.set(u,(r.owed.get(u)??new Set).add(n)),l}function io(e,t,n,r,o,a){let i=new Map(e.map(x=>[x.id,x])),l=ra(a),u=new Map,d=x=>{if(!n||typeof document>"u")return null;let O=u.get(x);return O===void 0&&(O=n.querySelector(`[data-graview-view="${CSS.escape(x)}"]`),u.set(x,O)),O},s=new Map;for(let x of e){let O=De(n,x.id,r)??rt(x,o);O&&s.set(x.id,O)}let c=new Map;if(n&&typeof document<"u"){let x=n.getBoundingClientRect();for(let O of n.querySelectorAll("[data-graview-pick], [data-graview-slot]")){if(O.closest("[data-graview-offstage]"))continue;let G=O.getAttribute("data-graview-pick")??O.getAttribute("data-graview-slot");if(G===null)continue;let F=O.getBoundingClientRect();if(F.width<=2||F.height<=2||F.width>x.width*.6&&F.height>x.height*.6)continue;let Q=c.get(G),z={x:F.left-x.left,y:F.top-x.top,width:F.width,height:F.height};Q?Q.push(z):c.set(G,[z])}}let h=(x,O)=>{let G=[];for(let[F,Q]of s)F!==x&&F!==O&&G.push(Q);for(let[F,Q]of c)F!==x&&F!==O&&G.push(...Q);return G},y=x=>Math.round(i.get(x)?.plane??-1)===1,w=[];for(let x of e){let O=s.get(x.id);O&&Math.round(x.plane)===1&&w.push(O)}if(!r&&n&&typeof document<"u"){let x=n.getBoundingClientRect();w.push(...mr(n,x,e,O=>s.get(O)))}let f=(x,O)=>!r&&y(x)&&y(O)?w:void 0,p=r?void 0:e.find(x=>Math.round(x.plane)===0&&!x.aggregate),v=(x,O,G,F)=>{if(!p)return{};let Q=x.to===p.id&&G===p.id;if(!Q&&!(x.from===p.id&&O===p.id))return{};let z=Q?x.from:x.to,g=s.get(p.id),E=s.get(z);if(z===p.id||!y(z)||!g||!E)return{};let I=d(p.id),A=N=>I!==null&&aa(I,l).get(N)?.some($=>!$.closest("[data-graview-offstage]"))===!0,j=F.map(N=>N.from===p.id?N.to:N.from),K=j.length>0&&j.every(A);return{band:w,tie:{card:g,chip:E,cardIsTo:Q,toward:z,holds:i.get(z)?.aggregate?.memberIds??[z]},...K?{said:j}:{}}},k=[];for(let x of t){if(!Ms(x,i,r))continue;let O=s.get(x.from),G=s.get(x.to);if(!O||!G)continue;let F=h(x.from,x.to),Q=x.edges,z=r&&Q.some(I=>I.from!==x.from&&on(n,d(x.from),I.from,l).length>0||I.to!==x.to&&on(n,d(x.to),I.to,l).length>0),g=f(x.from,x.to);if(r&&!z||x.loop||Q.length===0){k.push({key:x.id,connector:x,edges:Q,fromBox:O,toBox:G,fromAnchor:x.from,toAnchor:x.to,obstacles:F,hosts:[],...g?{band:g}:{},...v(x,x.from,x.to,Q)});continue}let E=new Map;for(let I of Q){let A=I.from===x.from?[]:on(n,d(x.from),I.from,l),j=I.to===x.to?[]:on(n,d(x.to),I.to,l),K=[x.from,x.to].find(S=>Math.round(i.get(S)?.plane??-1)===0);if(!r&&K!==void 0&&(K===x.from?I.from!==x.from:I.to!==x.to)&&on(n,d(K),K===x.from?I.to:I.from,l).length>0)continue;let N=K!==void 0?i.get(K):void 0;if(!r&&N?.aggregate&&n&&(K===x.from?I.from!==x.from&&A.length===0:I.to!==x.to&&j.length===0))continue;let $=A.length>0?I.from:x.from,Y=j.length>0?I.to:x.to,B=`${x.id}|${$}|${Y}`,J=E.get(B);if(J){J.edges.push(I);continue}let R=A.length>0?A:[O],D=j.length>0?j:[G],b=R[0],M=D[0],T=1/0;for(let S of R)for(let P of D){let L=Math.hypot(S.x+S.width/2-(P.x+P.width/2),S.y+S.height/2-(P.y+P.height/2));L<T&&(T=L,b=S,M=P)}E.set(B,{edges:[I],fromBox:b,toBox:M,fromAnchor:$,toAnchor:Y})}for(let[I,A]of E)k.push({key:I,connector:x,obstacles:F,hosts:[...A.fromAnchor!==x.from?[O]:[],...A.toAnchor!==x.to?[G]:[]],...g?{band:g}:{},...A,...v(x,A.fromAnchor,A.toAnchor,A.edges)})}return k}function sa(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 u=o.get(l);return u?{...i,x:i.x+u.x,y:i.y+u.y}:i};return e.map(i=>{let{from:l,to:u}=i.connector;if(!o.has(l)&&!o.has(u))return i;let d=a(i.fromBox,l),s=a(i.toBox,u),c=i.tie&&{...i.tie,card:a(i.tie.card,i.tie.cardIsTo?u:l),chip:a(i.tie.chip,i.tie.toward)},h=y=>y===i.fromBox?d:y===i.toBox?s:i.tie&&y===i.tie.chip?c.chip:y;return{...i,fromBox:d,toBox:s,...c?{tie:c}:{},...i.band?{band:i.band.map(h)}:{}}})}function fr(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 oa(e,t,n){let r=(1-t)*(1-n),o=(1-t)*n+t*(1-n),a=t*n;return{p0:fr(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:fr(e,n)}}function An(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(fr(e,d)),a=(d,s,c)=>{for(let h=0;h<10;h++){let y=(d+s)/2;r(y)===c?d=y:s=y}return(d+s)/2},i=[],l=null,u=r(0);u&&(l=0);for(let d=1;d<=64;d++){let s=d/64,c=r(s);if(c===u)continue;let h=a((d-1)/64,s,u);c?l=h:l!==null&&(h-l>.001&&i.push(oa(e,l,h)),l=null),u=c}return l!==null&&1-l>.001&&i.push(oa(e,l,1)),i}function da({strands:e,result:t,scheme:n,overview:r,selection:o,emphasis:a,stageRef:i,liveOf:l,onPickEdge:u,provisional:d,pointed:s=null}){let c=Nt(),h=new Set(t.nodes.filter(g=>g.plot!==void 0&&Math.round(g.plane)===2).map(g=>g.id)),y=g=>r&&t.city!==void 0&&h.has(g.from)&&h.has(g.to),w=Qo(t.nodes,o),f=g=>w.size===0||w.has(g.from)||w.has(g.to),p=new Set(o.filter(g=>Lt(g)===null)),v=r?t.nodes.find(g=>Math.round(g.plane)===0):void 0,k=v?De(i.current,v.id,!1)??rt(v,n):null;if(e.length===0)return null;let x=g=>g.edges.some(E=>p.has(E.from)||p.has(E.to)),O=p.size>0&&e.some(x),G=new Map;for(let g of e)G.set(g.connector.id,(G.get(g.connector.id)??0)+1);let F=na(e.map(g=>({key:g.key,a:g.fromAnchor,b:g.toAnchor}))),Q=new Set,z=e.map((g,E)=>{let{connector:I,fromBox:A,toBox:j}=g,K={x:A.x+A.width/2,y:A.y+A.height/2},N={x:j.x+j.width/2,y:j.y+j.height/2},$=r?oo(A,N):K,Y=r?oo(j,K):N,B=I.loop===!0,{connector:J,style:R}=Qt(c,I.kind);if(!J.visible)return null;let D=B?Math.max(22,Math.min(A.width,A.height)*.3):0,b=B?{x:K.x+A.width*.22,y:K.y-A.height/2-D+7}:$,M=($.x+Y.x)/2,T=($.y+Y.y)/2,S=Math.hypot(Y.x-$.x,Y.y-$.y),P=Math.min(r?40:90,S*(r?.09:.16)),L=0,H=0;if(S>0){L=-(Y.y-$.y)/S,H=(Y.x-$.x)/S;let ie=M-t.width/2,ve=T-t.height/2;if(k&&!B){let nt=k.x+k.width/2,Rt=k.y+k.height/2;ie=M-nt,ve=T-Rt;let je=Math.abs(L*(nt-$.x)+H*(Rt-$.y)),Ot=Math.hypot(k.width/2,k.height/2)*.85+24,ze=((nt-$.x)*(Y.x-$.x)+(Rt-$.y)*(Y.y-$.y))/(S*S);je<Ot&&ze>.1&&ze<.9&&(P=Math.min(180,Math.max(P,(Ot-je)*2)))}L*ie+H*ve<0&&(L=-L,H=-H)}P+=2*(F.get(g.key)??0);let Z=to(J.route,{p0:$,c:{x:M+L*P,y:T+H*P},p1:Y}),U=y(I),V=J.route==="orthogonal"||U,ne=(ie,ve)=>U?qi(ie,ve):Rn(ie,ve),X=!B&&g.tie?hr(g.tie.card,g.tie.chip,g.band??[],E):null,ce=X?g.tie.cardIsTo?X.reverse():X:!B&&g.band?nn(A,j,g.band,E):null,ae=B||V||ce?[]:An(Z,[A,j,...g.obstacles]),Se=ce?[ce]:!B&&V?ir(ne($,Y),[A,j,...g.obstacles]):[];if(!B&&ae.length===0&&Se.length===0)return null;let ke=Se[Se.length-1],Re=V||ce?Se[0]?.[0]:ae[0]?.p0,Te=V||ce?ke?.[ke.length-1]:ae[ae.length-1]?.p1,Pe=ie=>ie.map(ve=>`M ${ve.p0.x} ${ve.p0.y} Q ${ve.c.x} ${ve.c.y} ${ve.p1.x} ${ve.p1.y}`).join(" "),re=`M ${b.x-D} ${b.y} A ${D} ${D} 0 1 1 ${b.x+D} ${b.y} A ${D} ${D} 0 0 1 ${b.x-D} ${b.y}`,ee=B?re:ce?Ui(ce,J.route):V?kt(Se):Pe(ae),et=ie=>({x:ie.x-8,y:ie.y-8,width:ie.width+16,height:ie.height+16}),St=[A,j,...g.hosts,...g.obstacles].map(et),an=B?re:ce?kt(Se):V?kt(ir(ne($,Y),St)):Pe(An(Z,St)),_e=g.edges.length===1?g.edges[0]:null,Be=_e?Bt(I.kind,_e.from,_e.to):null,ut=Be!==null&&o.includes(Be),Ke=Be!==null?d?.get(Be):void 0,tt=g.edges.some(ie=>p.has(ie.from)||p.has(ie.to)),Oe=g.tie?.toward??"",Ye=g.tie!==void 0&&(s!==null&&(Oe===s||g.tie.holds.includes(s)||g.said?.includes(s)===!0)||p.has(Oe))&&!Q.has(Oe);Ye&&Q.add(Oe);let $e=!r&&p.size>0&&tt||Ye,Fe=a!==null&&I.kind===a||ut,Mt=l?.(I)!==void 0;if(r&&!Mt||!r&&!Mt&&p.size>0&&!tt&&!Fe&&!Ye||g.said!==void 0&&!Ye&&!g.said.some(ie=>p.has(ie))&&!Fe)return null;let Ue=r?Zo({emphasized:a!==null,stressed:Fe,anyChosen:O,mine:tt,touches:f(I),siblings:G.get(I.id)??1}):Jo({edgeChosen:ut,lit:$e,anyLit:O||a!==null,own:R.opacity,kit:c.emphasis}),it=$e&&Re&&Te?g.tie?g.tie.cardIsTo?Re:Te:g.edges.some(ie=>p.has(ie.from))?Te:Re:null,Et=(0,Ve.jsxs)("g",{children:[(0,Ve.jsx)("path",{"data-graview-connector":I.kind,"data-graview-edges":g.edges.length,"data-graview-from":g.fromAnchor,"data-graview-to":g.toAnchor,"data-graview-lit":$e||void 0,"data-graview-activity":l?.(I)?.manner,"data-graview-provisional":Ke!==void 0||void 0,opacity:Ue*(I.opacity??1)*(Ke!==void 0?xn:1),d:ee,fill:"none",stroke:Ut(R),strokeWidth:($e?Math.max(1.6,Ao(R,r)):Ao(R,r))+(Fe?.6:0),strokeDasharray:Ke!==void 0?gn:Vn[R.pattern],strokeLinecap:"round"}),it?(0,Ve.jsx)("circle",{cx:it.x,cy:it.y,r:2.6,fill:Ut(R),opacity:Ue}):null,B&&r?(0,Ve.jsx)("text",{x:b.x,y:b.y-D-5,textAnchor:"middle",opacity:Ue,style:{font:"9px var(--graview-font-body, system-ui)",letterSpacing:"0.09em",textTransform:"uppercase",fill:"var(--graview-ink-faint)"},children:cn(I.kind).toLowerCase()}):null]},g.key),Xe=null;return Be&&u&&!B&&Ue>=.2&&(Xe=(0,Ve.jsx)("path",{"data-graview-edge":Be,className:"graview-edge-hit",d:an,fill:"none",pathLength:1,strokeDasharray:"0.86",strokeDashoffset:-.07,stroke:"transparent",strokeWidth:14,style:{pointerEvents:"stroke",cursor:"pointer"},onClick:ie=>{ie.stopPropagation(),u(Be,{x:ie.clientX,y:ie.clientY})},onContextMenu:ie=>{ie.preventDefault(),ie.stopPropagation(),u(Be,{x:ie.clientX,y:ie.clientY})},children:Ke!==void 0?(0,Ve.jsx)("title",{children:Ke}):null},`hit:${g.key}`)),{key:g.key,line:Et,hit:Xe}});return(0,Ve.jsxs)(Ve.Fragment,{children:[(0,Ve.jsx)("svg",{"aria-hidden":"true","data-graview-world":"",width:t.width,height:t.height,style:{position:"absolute",left:0,top:0,pointerEvents:"none",zIndex:He.ties},children:z.map(g=>g?.line)}),z.some(g=>g?.hit)?(0,Ve.jsx)("svg",{"data-graview-world":"",width:t.width,height:t.height,style:{position:"absolute",left:0,top:0,pointerEvents:"none",zIndex:He.tieLabels},children:z.map(g=>g?.hit)}):null]})}function la(e,t,n){if(t.size===0||typeof MutationObserver>"u")return()=>{};let r=0,o=()=>{r=0,ia(e,t)&&n()},a=()=>{r===0&&(r=requestAnimationFrame(o))},i=({target:u})=>{for(let d=u instanceof Element?u:u.parentElement;d&&d!==e;d=d.parentElement)if(t.has(d.getAttribute("data-graview-view")??""))return!0;return!1},l=new MutationObserver(u=>{u.some(i)&&a()});return l.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-graview-pick","data-graview-slot","data-graview-offstage"]}),a(),()=>{l.disconnect(),cancelAnimationFrame(r)}}function ao(e){return e<640?{left:8,right:56}:{left:8,right:Math.round(Math.min(128,e*.107))}}function Os(e){return Math.min(260,16+e.length*6.6)}var Ln=(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 ua(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 u=l[0],d=Os(i),{end:s,far:c}=u,h=p=>Math.max(0,Math.min(n.width-d,p)),y=[{x:h(s.x-d/2),y:c.y-22-6,width:d,height:22},{x:h(s.x-d/2),y:c.y+c.height+6,width:d,height:22},{x:c.x+c.width+6,y:s.y-22/2,width:d,height:22},{x:c.x-d-6,y:s.y-22/2,width:d,height:22}],w=y[0],f=1/0;for(let p of y){let k=p.x<0||p.y<0||p.x+p.width>n.width||p.y+p.height>n.height?1e9:0;for(let x of t)k+=Ln(p,x.title)*100+Ln(p,x.box);for(let x of o)k+=Ln(p,x)*100;if(k<f&&(f=k,w=p),k===0)break}o.push(w),a.push({said:i,keys:l.map(p=>p.key),...w})}return a}var ca=(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 pr(e,t){let n=new Set;for(let r of e)(t.edgeId&&r.edgeId===t.edgeId||t.point&&(ca(r.fromBox,t.point)||ca(r.toBox,t.point))||t.ids?.some(o=>r.ids.includes(o))||t.box&&(Ln(t.box,r.fromBox)>0||Ln(t.box,r.toBox)>0))&&n.add(r.key);return n}var pe=se(Ie(),1);function ma(e){let t=Vr(e);return t.length>0?new Map(t.map(n=>[Bt(n.edge.kind,n.edge.from,n.edge.to),Wr(n)])):void 0}function pa({frame:e,width:t,height:n,scheme:r,overview:o,selection:a,emphasis:i,stageRef:l,store:u,graphNodes:d,onPickEdge:s,liveOf:c,holding:h=!1,provisional:y,focusId:w=null,beside:f=!1}){let[p,v]=(0,fe.useState)(0),[k,x]=(0,fe.useState)(null),O=e.t<1,G=(0,fe.useRef)(""),F=(0,fe.useRef)([]),Q=(0,fe.useRef)(new Map),z=()=>[...l.current?.querySelectorAll("[data-graview-relation] > span")??[]].map(N=>{let $=N.getBoundingClientRect();return`${Math.round($.left)},${Math.round($.top)},${Math.round($.width)}`}).join(" ");(0,fe.useLayoutEffect)(()=>{if(O||h)return;G.current=z(),F.current=e.nodes;let N=new Map;x(io(e.nodes,e.connectors,l.current,o,r,N)),Q.current=N},[e,O,h,a,o,d,r,p,l]),(0,fe.useEffect)(()=>{let N=l.current;if(!(O||h||N===null))return la(N,Q.current,()=>v($=>$+1))},[k,O,h,l]),(0,fe.useEffect)(()=>{if(O||h||o||typeof requestAnimationFrame>"u")return;let N=requestAnimationFrame(()=>{z()!==G.current&&v($=>$+1)});return()=>cancelAnimationFrame(N)},[k]);let g=e.nodes.map(N=>N.id).join(`
4
- `);(0,fe.useLayoutEffect)(()=>{let N=l.current;if(N===null||typeof window>"u")return;let $=0,Y=()=>{$===0&&($=requestAnimationFrame(()=>{$=0,v(J=>J+1)}))};N.addEventListener("scroll",Y,{capture:!0,passive:!0}),window.addEventListener("resize",Y,{passive:!0});let B=typeof ResizeObserver>"u"?null:new ResizeObserver(Y);if(B){B.observe(N);for(let J of N.querySelectorAll("[data-graview-view]"))B.observe(J)}return()=>{$!==0&&cancelAnimationFrame($),N.removeEventListener("scroll",Y,{capture:!0}),window.removeEventListener("resize",Y),B?.disconnect()}},[l,g]);let[E,I]=(0,fe.useState)(null),A=(k??[]).some(N=>N.tie!==void 0);if((0,fe.useEffect)(()=>{let N=l.current;if(!A||N===null)return;let $=B=>{let J=B.target?.closest?.("[data-graview-pick], [data-graview-view]");I(J?.getAttribute("data-graview-pick")??J?.getAttribute("data-graview-view")??null)},Y=()=>I(null);return N.addEventListener("pointerover",$),N.addEventListener("focusin",$),N.addEventListener("pointerleave",Y),N.addEventListener("focusout",Y),()=>{N.removeEventListener("pointerover",$),N.removeEventListener("focusin",$),N.removeEventListener("pointerleave",Y),N.removeEventListener("focusout",Y)}},[A,l]),O)return null;let j=(k&&h?sa(k,F.current,e.nodes):k)??io(e.nodes,e.connectors,null,o,r),K=new Set;for(let N of j){if(N.edges.length===1){let $=N.edges[0];K.add(`${N.connector.kind}|${$.from}|${$.to}`);continue}for(let $ of N.edges)(N.connector.from===$.from||N.connector.to===$.to)&&K.add(`${N.connector.kind}|${$.from}|${$.to}`)}return(0,pe.jsxs)(pe.Fragment,{children:[(0,pe.jsx)(da,{strands:j,result:e,scheme:r,overview:o,selection:a,emphasis:i,stageRef:l,onPickEdge:s,liveOf:c,pointed:E,...y?{provisional:y}:{}}),o&&wn(a,{overview:o,focusId:w,beside:f},N=>u.graph.getNode(N)?.kind).records.length>0?(0,pe.jsx)(fe.Suspense,{fallback:null,children:(0,pe.jsx)(Ls,{frame:e,width:t,height:n,stageRef:l,tick:p,store:u,graphVersion:d,selection:a,view:{overview:o,focusId:w,beside:f},rulers:y?{...ha,unsureOf:(N,$,Y)=>y.get(Bt(N,$,Y))}:ha})}):null,o?null:(0,pe.jsx)(Ts,{...y?{provisional:y}:{},stageRef:l,nodes:e.nodes,scheme:r,selection:a,store:u,graphNodes:d,overview:o,width:t,height:n,onPickEdge:s,alreadyDrawn:K,tick:p})]})}var ha={visibleRect:tn,clipQuadratic:An,unsureDash:gn,unsureOpacity:xn},As=yn(Gt(()=>(__graviewPreload(import.meta.url,["./chunk.BNPQUI3F.js","./chunk.HDRD33II.js","./chunk.DX357TZ3.js","./chunk.H7KCWCB4.js","./chunk.XWAMQPUM.js","./chunk.SDO3U72B.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.S6WHA4CW.js")))),Ls=As.part((e,t)=>(0,pe.jsx)(e.RecordLinks,{...t}),{what:"The links",quiet:!0}),Is=44;function Ts({stageRef:e,nodes:t,scheme:n,selection:r,store:o,graphNodes:a,overview:i,width:l,height:u,onPickEdge:d,alreadyDrawn:s,tick:c,provisional:h}){let y=Nt(),w=(0,fe.useMemo)(()=>{if(r.length===0||r.length>4)return[];let g=new Set(r),E=[];for(let A of r){let j=Lt(A);j&&E.push({kind:j.kind,self:j.from,other:j.to})}for(let A of o.graph.allEdges()){let j=g.has(A.from)?A.from:g.has(A.to)?A.to:null;if(!j)continue;let K=j===A.from?A.to:A.from;g.has(K)||E.push({kind:A.kind,self:j,other:K})}if(E.length<=14)return E;let I=new Set(t.map(A=>A.id));return E.map((A,j)=>({tie:A,index:j,real:I.has(A.other)?0:1})).sort((A,j)=>A.real-j.real||A.index-j.index).slice(0,14).map(({tie:A})=>A)},[o,r,a,t]),f=()=>{if(w.length===0||typeof document>"u")return[];let g=e.current?.getBoundingClientRect();if(!g)return[];let E=[...e.current?.querySelectorAll("[data-graview-joins]")??[]].find(R=>{if(R.closest("[data-graview-offstage]"))return!1;try{let D=JSON.parse(R.getAttribute("data-graview-joins")??"[]");return D.length===r.length&&D.every(b=>r.includes(b))}catch{return!1}});if(E){let R=tn(E,e.current);if(!R)return[];let D=[];for(let b of r){let M=t.find(L=>L.id===b);if(!M)continue;let T=De(e.current,M.id,i)??rt(M,n),S=T?ro(R,T):null;if(!T||!S)continue;let P=[...o.graph.allEdges()].find(L=>L.from===b&&r.includes(L.to)||L.to===b&&r.includes(L.from));D.push({key:`join:${b}`,self:b,other:"",others:1,kind:P?.kind??"",endX:S.to.x,endY:S.to.y,...S,fromBox:R,toBox:T,proxy:!1,edgeId:P?Bt(P.kind,P.from,P.to):null})}return D}let I=(R,D)=>{let b=e.current?.querySelectorAll(`[data-graview-pick="${CSS.escape(R)}"], [data-graview-slot="${CSS.escape(R)}"]`),M=[];for(let T of b??[]){if(T.closest("[data-graview-offstage]")||D(T)||T.closest("[data-graview-mark]"))continue;let S=tn(T,e.current);S&&M.push(S)}return M.sort((T,S)=>T.width*T.height-S.width*S.height)},A=R=>t.find(D=>D.id===R)??t.find(D=>D.aggregate?.memberIds.includes(R)),j=R=>`[data-graview-pick="${CSS.escape(R)}"], [data-graview-slot="${CSS.escape(R)}"]`,K=(R,D)=>{let b=e.current;if(!b)return!1;for(let M of b.querySelectorAll("[data-graview-view]")){let T=M.querySelector(j(R));if(T===null||T.closest("[data-graview-offstage]"))continue;let S=M.querySelector(j(D));if(S!==null&&!S.closest("[data-graview-offstage]"))return!0}return!1},N=[];if(!i&&e.current){for(let D of t){if(Math.round(D.plane)!==1)continue;let b=De(e.current,D.id,!1);b&&N.push(b)}let R=e.current;N.push(...mr(R,g,t,D=>De(R,D,!1)))}let $=new Map,Y=[];for(let R of w){if(K(R.self,R.other))continue;let D=A(R.self),b=D?e.current?.querySelector(`[data-graview-view="${CSS.escape(D.id)}"]`):null,M=!i&&D?.id===R.self&&Math.round(D.plane)===1?De(e.current,D.id,!1):null,T=M?[M]:I(R.self,()=>!1);if(!(T.length>0)&&D){let re=De(e.current,D.id,!1)??rt(D,n);re&&T.push(re)}let P=t.find(re=>re.id===R.other),L=[],H=!1;if(P){let re=De(e.current,P.id,i)??rt(P,n);re&&L.push(re)}else if(L.push(...I(R.other,re=>b?b.contains(re):!1)),L.length===0){let re=A(R.other);if(re&&(!D||re.id!==D.id)){let ee=De(e.current,re.id,i)??rt(re,n);ee&&(L.push(ee),H=!0)}}if(T.length===0||L.length===0||H&&i)continue;let Z=T[0],U=L[0],V=1/0;for(let re of T)for(let ee of L){let et=Math.hypot(re.x+re.width/2-(ee.x+ee.width/2),re.y+re.height/2-(ee.y+ee.height/2));et<V&&(V=et,Z=re,U=ee)}if(s?.has(`${R.kind}|${R.self}|${R.other}`)||s?.has(`${R.kind}|${R.other}|${R.self}`))continue;let ne=`${R.kind}:${Math.round(Z.x)},${Math.round(Z.y)}:${Math.round(U.x)},${Math.round(U.y)}`,X=$.get(ne);if(X){X.others+=1;continue}let ce=ro(Z,U);if(!ce)continue;let{from:ae,control:Se}=ce,ke=M&&Z===M?nn(Z,U,N,Y.length):void 0,Re=ke?ke[ke.length-1]:ce.to,Te=[...o.graph.allEdges()].find(re=>re.kind===R.kind&&(re.from===R.self&&re.to===R.other||re.from===R.other&&re.to===R.self)),Pe={key:`${R.kind}:${R.self}:${R.other}`,self:R.self,other:R.other,others:1,kind:R.kind,endX:Re.x,endY:Re.y,from:ae,to:Re,control:Se,fromBox:Z,toBox:U,...ke?{points:ke}:{},proxy:H,edgeId:Te?Bt(Te.kind,Te.from,Te.to):null};$.set(ne,Pe),Y.push(Pe)}let B=i?void 0:t.find(R=>Math.round(R.plane)===0&&!R.aggregate),J=R=>{let D=t.find(b=>b.id===R.other)??t.find(b=>b.aggregate?.memberIds.includes(R.other));return D!==void 0&&Math.round(D.plane)===1&&D.via?.edgeKind===R.kind};for(let R of Y){if(B&&(R.self!==B.id||J(R)))continue;let D=[...o.graph.allEdges()].find(L=>L.kind===R.kind&&(L.from===R.self&&L.to===R.other||L.from===R.other&&L.to===R.self)),b=o.graph.getNode(R.self),M=o.graph.getNode(R.other);if(!D||!b||!M)continue;let T=D.from===R.self?"out":"in",S=jr(o.schema,T==="out"?b.kind:M.kind,R.kind,T),P=R.proxy?(T==="out"?o.graph.out(R.self,R.kind):o.graph.in(R.self,R.kind)).filter(L=>L.kind===M.kind).length:1;R.said=R.proxy?`${S}: ${zt(o.schema,M.kind,Math.max(P,R.others))}`:`${S}: ${Dn(o.schema.tryDefinition(M.kind),M)}`}return Y},[p,v]=(0,fe.useState)([]),[k,x]=(0,fe.useState)([]);(0,fe.useLayoutEffect)(()=>{let g=f();v(g),x(g.some(E=>E.said)?O(g):[])},[w,t,i,n,l,u,s,c,e]);let O=g=>{let E=e.current;if(!E)return[];let I=[];for(let A of E.querySelectorAll("[data-graview-view]")){let j=[...A.children].find(N=>!N.classList.contains("graview-kind-tag")),K=j?tn(j,E):null;K&&I.push({box:K,title:{...K,height:Math.min(K.height,Is)}})}return ua(g.flatMap(A=>A.said?[{key:A.key,said:A.said,end:{x:A.endX,y:A.endY},far:A.toBox}]:[]),I,{width:l,height:u})},[G,F]=(0,fe.useState)(()=>new Set),Q=(0,fe.useRef)([]);Q.current=p.map(g=>({key:g.key,fromBox:g.fromBox,toBox:g.toBox,ids:[g.self,g.other],edgeId:g.edgeId}));let z=k.length>0;return(0,fe.useEffect)(()=>{let g=e.current;if(!g||!z)return;let E=B=>F(J=>J.size===B.size&&[...B].every(R=>J.has(R))?J:B),I=0,A=null,j=()=>{if(I=0,!A)return;let B=g.getBoundingClientRect(),J=A.target instanceof Element?A.target:null;E(pr(Q.current,{point:{x:A.clientX-B.left,y:A.clientY-B.top},edgeId:J?.closest("[data-graview-edge]")?.getAttribute("data-graview-edge")??null}))},K=B=>{A=B,I||(I=requestAnimationFrame(j))},N=()=>{A=null,E(new Set)},$=B=>{let J=B.target instanceof Element?B.target:null;if(!J)return;let R=g.getBoundingClientRect(),D=J.getBoundingClientRect(),b=J.closest("[data-graview-pick]")?.getAttribute("data-graview-pick")??J.closest("[data-graview-view]")?.getAttribute("data-graview-view");E(pr(Q.current,{...b?{ids:[b]}:{},box:{x:D.left-R.left,y:D.top-R.top,width:D.width,height:D.height}}))},Y=B=>{B.relatedTarget instanceof Node&&g.contains(B.relatedTarget)||E(new Set)};return g.addEventListener("pointermove",K,{passive:!0}),g.addEventListener("pointerleave",N),g.addEventListener("focusin",$),g.addEventListener("focusout",Y),()=>{I&&cancelAnimationFrame(I),g.removeEventListener("pointermove",K),g.removeEventListener("pointerleave",N),g.removeEventListener("focusin",$),g.removeEventListener("focusout",Y)}},[e,z]),p.length===0?null:(0,pe.jsxs)(pe.Fragment,{children:[(0,pe.jsx)("svg",{"aria-hidden":p.some(g=>g.edgeId)?void 0:!0,"data-graview-ties":p.length,"data-graview-world":"",width:l,height:u,style:{position:"absolute",left:0,top:0,pointerEvents:"none",zIndex:He.lines},children:p.map(g=>{let{connector:E,style:I}=Qt(y,g.kind);if(!E.visible)return null;let A=g.edgeId?h?.get(g.edgeId):void 0,j={p0:g.from,c:g.control,p1:g.to},K=g.points?ar(g.points,10):E.route==="orthogonal"?kt([Rn(g.from,g.to)]):(({p0:$,c:Y,p1:B})=>`M ${$.x} ${$.y} Q ${Y.x} ${Y.y} ${B.x} ${B.y}`)(to(E.route,j)),N=null;if(g.edgeId&&d&&!g.proxy){let $=(B,J)=>J.x>=B.x&&J.x<=B.x+B.width&&J.y>=B.y&&J.y<=B.y+B.height,Y=g.points?[...g.points]:[];for(let B=0;B<=(g.points?-1:40);B++){let J=Xi(E.route,j,B/40);$(g.fromBox,J)||$(g.toBox,J)||Y.push(J)}Y.length>=2&&(N=(0,pe.jsx)("path",{"data-graview-edge":g.edgeId,className:"graview-edge-hit",d:`M ${Y[0].x} ${Y[0].y} ${Y.slice(1).map(B=>`L ${B.x} ${B.y}`).join(" ")}`,fill:"none",pathLength:1,strokeDasharray:"0.86",strokeDashoffset:-.07,stroke:"transparent",strokeWidth:14,style:{pointerEvents:"stroke",cursor:"pointer"},onClick:B=>{B.stopPropagation(),d(g.edgeId,{x:B.clientX,y:B.clientY})},onContextMenu:B=>{B.preventDefault(),B.stopPropagation(),d(g.edgeId,{x:B.clientX,y:B.clientY})},children:A!==void 0?(0,pe.jsx)("title",{children:A}):null}))}return(0,pe.jsxs)("g",{opacity:(g.proxy?.32:.72)*(A!==void 0?xn:1),children:[(0,pe.jsx)("path",{"data-graview-tie":g.kind,"data-graview-tie-proxy":g.proxy||void 0,"data-graview-provisional":A!==void 0||void 0,d:K,fill:"none",stroke:Ut(I),strokeWidth:g.proxy?1.1:1.6,strokeDasharray:A!==void 0?gn:Vn[I.pattern],strokeLinecap:"round"}),(0,pe.jsx)("circle",{cx:g.endX,cy:g.endY,r:g.proxy?2:2.6,fill:Ut(I)}),N]},g.key)})}),(0,pe.jsx)("div",{"aria-hidden":"true","data-graview-world":"",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:He.tieLabels},children:k.map(g=>{let E=p.find(I=>I.key===g.keys[0]);return(0,pe.jsx)("span",{className:"graview-record-link-said","data-graview-link-said":E?.kind,"data-graview-lands":E?.proxy?"district":"record","data-graview-said-for":g.keys.length,"data-graview-tie-said":g.keys.some(I=>G.has(I))?"shown":"waiting",style:{position:"absolute",left:g.x,top:g.y,transform:`translateX(min(0px, calc(${Math.round(l-g.x-8)}px - 100%)))`},children:g.said},g.said)})})]})}function fa(){return typeof document>"u"?1:parseFloat(getComputedStyle(document.documentElement).fontSize)/16||1}function ya({nodes:e,scheme:t,width:n,stageRef:r,moving:o=!1,holding:a=!1}){let i=Nt(),[l,u]=(0,fe.useState)([]);(0,fe.useLayoutEffect)(()=>{o||a||u(d())},[e,o,a,t,n,r]);function d(){let c=[],h=[];for(let p of e){if(!p.via||Math.round(p.plane)!==1)continue;let v=De(r.current,p.id,!1,!0),{scale:k}=Kt(1,t);c.push({key:`${p.via.edgeKind}|${p.via.direction}`,text:vn(p.via),left:v?.x??p.x,right:v?v.x+v.width:p.x+p.width*k,top:v?.y??p.y}),h.push(Math.round(p.y))}let y=new Map;c.forEach((p,v)=>y.set(h[v],Math.min(y.get(h[v])??1/0,p.top)));let w=c.map((p,v)=>({...p,top:y.get(h[v])??p.top})),f=ao(n);return Wo(w,{left:f.left,right:n-f.right},fa())}if(l.length===0||!i.captions.visible||o)return null;let s=jo*fa();return(0,pe.jsx)("div",{"aria-hidden":"true",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:He.lines},children:l.map(c=>{let{left:h,width:y}=c;return(0,pe.jsx)("div",{"data-graview-relation":c.key,title:c.text,style:{position:"absolute",left:h,width:y,textAlign:"center",top:Math.max(0,c.top-s),fontSize:"0.75rem",letterSpacing:"0.09em",textTransform:"uppercase",color:"var(--graview-ink-faint)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:(0,pe.jsx)("span",{style:{background:"var(--graview-ground)",padding:"1px 7px",borderRadius:4},children:c.text})},c.key)})})}var Wt=se(Ce(),1);var Cs=new Set;function xa(e,t,n,r,o,a,i=0,l=0){let{store:u,views:d,hiddenKinds:s}=ye(),c=Tt(),h=(0,Wt.useContext)(_t),y=Mo(),w=(0,Wt.useMemo)(()=>{let v={};for(let k of y){if(k.subjectId===void 0)continue;let x=v[k.subjectId]??=[];for(let O of k.nodeIds)O!==k.subjectId&&!x.includes(O)&&x.push(O)}return v},[y]),f=(0,Wt.useMemo)(()=>({flagged:new Set(y.flatMap(v=>v.nodeIds)),touched:Yn(u.log.all())}),[y,u,a]),p=(0,Wt.useMemo)(()=>({hits:c?Wn(c):Cs,...f}),[c,f]);return(0,Wt.useMemo)(()=>({...e,cityZoom:r,...h?{besideTheMap:!0}:{},...s.size>0?{hiddenKinds:[...s].sort()}:{},...Object.keys(w).length>0?{judged:w}:{},relevance:p,inset:{...ao((t?.width??1200)-o.right),top:8,bottom:0},chrome:[{x:(t?.width??1200)-o.right-176,y:0,width:176,height:100},Ns(t,o)],...o.right>0||o.bottom>0?{dock:o}:{},...i>0?{headroom:i}:{},unit:n,plainGroups:u.schema.kinds.filter(v=>Ar(d.lookup(v,{cardinality:"many",fidelity:"full"}))),cityOrder:Sr(Zr({name:"scene",schema:u.schema,mutations:u.allMutations().filter(v=>!v.derived)}).order.map(v=>v.kind),d.arrangement?.()?.order),screens:d.places().reduce((v,k)=>((v[k.kind]??=[]).push({as:k.as,title:k.title,...k.across?{across:k.across}:{}}),v),{}),...t?{width:t.width,height:Math.max(0,t.height-Math.max(64,l))}:{}}),[e,t,n,u,d,s,w,p,r,h,o.right,o.bottom,i,l])}var ga=224;function Ns(e,t){let n=e?.width??1200,r=e?.height??800,o=58;return{x:n-t.right-ga,y:r-t.bottom-o,width:ga,height:o}}var ct=se(Ce(),1);var ba=se(Ce(),1);function so(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 wa(e){(0,ba.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&&$s(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 Bs=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 $s(e){return Bs.has(e.localName.toLowerCase())}var rn=se(Ie(),1);function va({node:e,useDom:t,blur:n,touched:r,frontY:o,centerY:a,screen:i,onDrawnHeight:l,crowded:u,activity:d,scheme:s,canvasWidth:c,canvasHeight:h,selected:y,onSelect:w,onPick:f,onTravel:p,onMenu:v,selection:k,onJackIn:x,onDragStart:O,onDragMove:G,onDragEnd:F,swallowClick:Q,children:z}){let{brand:g,store:E,actsDoor:I}=ye(),A=e.beyond?`${e.beyond.length} more district${e.beyond.length===1?"":"s"}`:e.aggregate?.opens?.in==="place"?`${e.aggregate.label}, ${zt(E.schema,e.aggregate.kind,e.aggregate.memberIds.length)}`:e.aggregate?e.aggregate.label:(()=>{let S=E.graph.getNode(e.id);return S?Dn(E.schema.tryDefinition(e.kind),S):e.id})(),[j,K]=(0,ct.useState)(null),N=Math.round(e.plane)===0&&!e.aggregate;(0,ct.useLayoutEffect)(()=>{if(!N)return;let S=R.current;if(!S)return;let P=()=>{let H=[...S.children].find(X=>X.dataset.graviewKindtag===void 0);if(!H)return;let Z=S.getBoundingClientRect(),U=H.getBoundingClientRect(),V=S.offsetWidth>0?Z.width/S.offsetWidth:1,ne={top:Math.round((U.top-Z.top)/V)-9,right:Math.round((Z.right-U.right)/V)+14};K(X=>X&&X.top===ne.top&&X.right===ne.right?X:ne)};if(typeof ResizeObserver>"u"){P();return}let L=new ResizeObserver(P);L.observe(S);for(let H of S.children)L.observe(H);return()=>L.disconnect()},[N,e.id]);let $=Pr({plane:e.plane,...e.depth!==void 0?{depth:e.depth}:{},onPlot:o!==void 0},s),Y=$.style,B=Tr(Y,e.x,e.y,c,h),J=n?$.blur:0,R=(0,ct.useRef)(null);wa(R);let D=e.natural,b=D?Math.min(e.width/D.width,e.height/D.height):1,M=(0,ct.useRef)(null);(0,ct.useEffect)(()=>{if(!i||!l)return;let S=M.current;if(!S||typeof ResizeObserver>"u")return;let P=()=>{let V=0,ne=0;for(let X of S.children)if(!(!(X instanceof HTMLElement)||X.classList.contains("graview-screen-fullscreen"))){V=Math.max(V,X.offsetTop+X.offsetHeight);for(let ce of[X,...X.querySelectorAll("*")]){let ae=getComputedStyle(ce).overflowY;(ae==="auto"||ae==="scroll")&&(ne+=ce.scrollHeight-ce.clientHeight)}}l(V+ne)},L=0,H=()=>{L||(L=requestAnimationFrame(()=>{L=0,P()}))};P();let Z=new ResizeObserver(H);Z.observe(S);for(let V of S.children)Z.observe(V);let U=new MutationObserver(H);return U.observe(S,{childList:!0,subtree:!0,characterData:!0,attributes:!0}),()=>{L&&cancelAnimationFrame(L),Z.disconnect(),U.disconnect(),l(void 0)}},[i,l,e.id]);let T=t?{transform:Ki(B),transformOrigin:"0 0",filter:J>0?`blur(${J}px)`:void 0,opacity:Cr(Y)*(e.opacity??1),"--graview-lift-low":or(Y.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":or(Y.shadow,s)};return(0,rn.jsxs)("div",{ref:R,"data-graview-view":e.id,...t?{}:{drawable:""},"data-graview-plane":Math.round(e.plane),"data-graview-selected":y||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&&!D&&!i?"":void 0,"data-graview-nested":e.nestedUnder??void 0,"data-graview-crowded":u||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?`${Fi[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":A,"aria-keyshortcuts":I&&!e.beyond?I.key:void 0,tabIndex:0,onPointerDown:O,onPointerMove:G,onPointerUp:F,onPointerCancel:F,onClick:S=>{if(Q.current)return;let P=S.target?.closest("input, textarea, select, button, a[href], [contenteditable='true']");if(P&&!P.hasAttribute("data-graview-pick"))return;let L=S.metaKey||S.shiftKey,H=gt(S.target);if(H&&H!==e.id){S.stopPropagation(),f(H,L,so(S.target)??void 0);return}w(L)},onKeyDown:S=>{if(I&&!e.beyond&&S.key.toLowerCase()===I.key.toLowerCase()&&!S.metaKey&&!S.ctrlKey&&!S.altKey&&!S.target?.closest("input, textarea, select, [contenteditable='true']")){S.preventDefault(),S.stopPropagation();let U=gt(S.target)??e.id;k.includes(U)||f(U,!1),I.open(S.target instanceof HTMLElement?S.target:S.currentTarget);return}if(S.key!=="Enter"&&S.key!==" "||S.target?.closest("input, textarea, select, button, [contenteditable='true']"))return;let L=gt(S.target);if(S.preventDefault(),S.stopPropagation(),!L||L===e.id){k.length===1&&k[0]===e.id&&!S.metaKey&&!S.shiftKey?x():w(S.metaKey||S.shiftKey);return}let H=so(S.target);(H?k.length===H.length&&H.every(U=>k.includes(U)):k.length===1&&k[0]===L)&&!S.metaKey&&!S.shiftKey?p(L):f(L,S.metaKey||S.shiftKey,H??void 0)},onContextMenu:S=>{let P=gt(S.target);S.preventDefault(),S.stopPropagation();let L=P&&P!==e.id?P:e.id;f(L,!1,(L===P?so(S.target):null)??void 0),v({x:S.clientX,y:S.clientY,on:L})},onDoubleClick:S=>{let P=gt(S.target);if(P&&P!==e.id){S.stopPropagation(),p(P);return}x()},style:{position:"absolute",...t?{}:{pointerEvents:"none"},zIndex:e.opened?He.opened:He.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",...T},children:[D?(0,rn.jsx)("div",{ref:M,"data-graview-natural":`${Math.round(D.width)}x${Math.round(D.height)}`,style:{position:"absolute",left:"50%",top:"50%",width:D.width,height:D.height,transform:`translate(-50%, -50%) scale(${b})`,transformOrigin:"50% 50%",display:"flex",flexDirection:"column"},children:z}):z,Math.round(e.plane)===0&&!e.aggregate?(0,rn.jsxs)("span",{"data-graview-kindtag":"",className:"graview-kind-tag","aria-hidden":"true",style:{...j??{},"--graview-hue":Math.round(hn(e.kind,g?.accents))},children:[(0,rn.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(hn(e.kind,g?.accents))} 55% var(--graview-tint-lightness) / 0.9)`}}),vr(E.schema.tryDefinition(e.kind),e.kind)]}):null]})}var ue=se(Ie(),1);So({search:ei,touchWeights:Yn});var Hs=e=>e?{activity:e}:{},Ds=e=>`${Math.round(e.x)} ${Math.round(e.y)}`,ka=e=>e.stopPropagation(),Ra=.6,Oa=3,Fs=80,Sa=e=>Math.round(e.plane)===1&&(e.compact===!0||e.width<175||e.height<Fs);function js(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 Ws(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:$t(e,r),[e,t,r]),a=(0,q.useRef)(t);a.current=t;let i=(0,q.useCallback)((l,u)=>{let d=a.current,s=(c,h,y)=>Math.max(Math.min(-c,h),Math.min(Math.max(c,h),y+h))-h;return{x:s(l.x,d.x,u.x),y:s(l.y,d.y,u.y)}},[]);return[r,o,i,a,n]}function Vs(e,t,n,r,o,a){let i=n!==null&&!t.overview,l=i?null:n,u=(0,q.useMemo)(()=>{let h=t.pan?{...t,pan:void 0}:t;return l?bn(h,l.id,{x:l.x,y:l.y}):h},[t,l]),d=(0,q.useMemo)(()=>Un(e.graph,e.schema,u,r),[e,u,r,o]),s=(0,q.useMemo)(()=>n&&i?Ko(d,n.id,{x:n.x,y:n.y})??Un(e.graph,e.schema,bn(u,n.id,{x:n.x,y:n.y}),r):d,[d,n,i,e,u,r]);return[(0,q.useMemo)(()=>Uo(s,a??{x:0,y:0}),[s,a]),i]}function Ys(){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 zs(e){let t=(0,q.useRef)(!1),n=e!==null&&!t.current;return(0,q.useEffect)(()=>{e!==null&&(t.current=!0)},[e]),n}function Gs({registerScene:e,scheme:t,views:n},r,o){let a=(0,q.useRef)(r);a.current=r,(0,q.useEffect)(()=>(e({whereIs:i=>eo(a.current,o.current,t,n,i)}),()=>e(null)),[e,t,n])}function _s(e,t){(0,q.useEffect)(()=>{let n;return e.onActive(r=>{let o=t.current;if(!o)return;let a=l=>{let u=o.getBoundingClientRect();e.set({x:l.clientX-u.left,y:l.clientY-u.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 Ks(e,t,n,r,o,a,i,l){(0,q.useEffect)(()=>{let u=t.current;if(!u||!e)return;let d=new Set;for(let c of n.nodes)(r.has(c.id)||c.aggregate?.memberIds.some(h=>r.has(h)))&&d.add(c.id);let s=e({canvas:u,layout:n,dirty:d,hostOf:c=>(u.parentElement??u).querySelector(`[data-graview-view="${CSS.escape(c)}"]`),drawOnDom:o,blur:a,scheme:i,fallBack:l});return()=>{s?.()}},[e,n,r,o,a,i,l])}var Us=Gt(()=>(__graviewPreload(import.meta.url,["./chunk.OJGHDWI6.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.KRGM25HF.js")));function Xs(e,t){let[n]=(0,q.useState)(()=>{let s=Br();return t?e==="dom"||e==="auto"&&s==="dom"?"dom":"gpu":Hr(e,{operator:s,present:$r()})}),[r,o]=(0,q.useState)(!1),a=(0,q.useCallback)(()=>o(!0),[]),[i,l]=(0,q.useState)(null),u=n==="gpu"&&!t&&!r&&i===null;return(0,q.useEffect)(()=>{if(!u)return;let s=!0;return Us().then(c=>{s&&l(()=>c.attachGpu())},()=>{s&&o(!0)}),()=>{s=!1}},[u]),{attach:(n==="gpu"&&!r?t??i:null)??null,fallBack:a}}function qs(){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 Qs(){let e=Yr();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 u of r){let d=e.get(u);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 Ma=(e,t)=>e.includes(t)?e.filter(n=>n!==t):[...e,t];function Zs(){let{views:e,view:t,setView:n,setSelection:r}=ye(),o=Tt(),a=(0,q.useContext)(_t),i=l=>{if(Ae(l.id)===null&&!l.aggregate)return!1;let u=e.resolve(l.kind,{cardinality:"many",fidelity:"full"})?.view;return u!==void 0&&u.generic!==!0};return l=>({onSelect:u=>{if(pn(l.id)){r(s=>u?Ma(s,l.id):[l.id]);return}let d=l.aggregate?mn(l.id):[];if(t.overview){r(s=>u?[...new Set([...s,l.id])]:[l.id]);return}if(d.length===1&&!u&&Math.round(l.plane)!==0){let s=d[0];n(c=>xo(c,c.relation===s?null:s));return}r(s=>nr(l,s,u))},onPick:(u,d,s)=>r(c=>s?d?[...new Set([...c,...s])]:[...s]:d?Ma(c,u):[u]),onTravel:u=>{n(d=>({...pt(d,u),relation:null})),r([u])},onJackIn:()=>{let u=l.aggregate?.opens;if(u){u.in==="place"?n(c=>bo(c,l.id)):n(c=>Object.entries(u.within).reduce((h,[y,w])=>jn(h,y,w),pt(fn(c,!1),u.focus))),r([]);return}let d=Ae(l.id),s=d!==null&&(o?.byKind[d]??0)>0;if(a&&d!==null&&t.overview&&!i(l)&&!(s&&t.q)){n(c=>jn({...pt(c,`aggregate:${d}`),relation:null},"view",null)),r([]);return}n(c=>wo(c,l.id,{ownPicture:i(l),...s&&c.q?{carry:c.q}:{}})),r(l.aggregate?[]:[l.id])}})}var Js=yn(Gt(()=>(__graviewPreload(import.meta.url,["./chunk.HJCQ6I3S.js","./chunk.BNPQUI3F.js","./chunk.TKUNRFDE.js","./chunk.6RY6OSE6.js","./chunk.HDRD33II.js","./chunk.DX357TZ3.js","./chunk.H7KCWCB4.js","./chunk.XWAMQPUM.js","./chunk.SDO3U72B.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.L2PI7V4R.js")))),ed=Js.part((e,t)=>(0,ue.jsx)(e.Ribbons,{...t}),{what:"The relations",quiet:!0}),Ea="graview:map-from-above";function td(){let[e,t]=(0,q.useState)(()=>{try{return globalThis.localStorage?.getItem(Ea)==="1"}catch{return!1}}),n=(0,q.useCallback)(r=>{t(r);try{globalThis.localStorage?.setItem(Ea,r?"1":"0")}catch{}},[]);return[e,n]}var nd=yn(Gt(()=>(__graviewPreload(import.meta.url,["./chunk.TKUNRFDE.js","./chunk.6RY6OSE6.js","./chunk.JLEC3USG.js","./chunk.XWAMQPUM.js","./chunk.SDO3U72B.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.4KNEBLB7.js")))),od=nd.part((e,t)=>(0,ue.jsx)(e.Plots,{...t}),{quiet:!0});function rd({zoom:e,zoomBy:t,above:n,setAbove:r}){let o=(a,i,l,u)=>(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:u,onClick:()=>t(l),children:i});return(0,ue.jsxs)("div",{className:"graview-zoom","data-graview-foot":"",role:"group","aria-label":"Zoom",onPointerDown:ka,onClick:ka,children:[o("out","\u2212",1/1.25,e<=Ra+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>=Oa-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 id({options:e,renderer:t="auto",attachRenderer:n,blur:r=!0,className:o,style:a,animate:i=!0,children:l}){let u=ye(),{store:d,scheme:s,views:c,view:h,setView:y,selection:w,setSelection:f,setMenuAt:p,emphasis:v,brand:k,noteMoved:x,robots:O,motion:G}=u,F=(0,q.useContext)(_t),Q=(0,q.useRef)(null),z=(0,q.useRef)(null),g=_i(z),E=Gi(),{zoomAbout:I,panBy:A}=Di({stage:z,view:h,setView:y}),j=Pt(),K=1,[N,$,Y]=js(h.overview),[B,J]=td(),R=(0,q.useMemo)(()=>B?{...e,tilt:ni}:e,[e,B]),{probe:D,dock:b}=Ni(),M=!h.overview&&(h.zoom||h.past||h.relation)?Math.ceil(14+34*E/16+6):0,T=xa(R,g,E,K*N,b,j,M,h.overview?0:b.bottom),S=Ii(z),[P,L,H,Z,U]=Ws(h),V=(0,q.useMemo)(()=>new Set(Object.keys(h.pins).filter(C=>Ae(C)===null)),[h.pins]),ne=Bi(),[X,ce]=Vs(d,h,ne.held,T,j,L.pan),[ae,Se,ke,Re,Te,Pe]=Ys(),re=zs(g),ee=ki(X,{enabled:i&&!ae&&!Se&&g!==null&&!re});(0,q.useEffect)(()=>G.set(ae||Se||ee.t<1),[G,ae,Se,ee]);let et=Si(),St=Mi(),an=Ti({view:h,result:X,frame:ee,panned:P,closer:K,screenId:null,setCamera:U});Gs(u,ee,z),_s(u.pointer,z);let[_e,Be]=qs(),{attach:ut,fallBack:Ke}=Xs(t,n),tt=wi(r);Ks(ut,Q,ee,et,Be,tt,s,Ke);let Oe=ut===null,Ye=vi(tt&&Oe,ae||Se||ee.t<1),$e=Qs(),Fe=$i({stage:z,pan:h.pan,setView:y,settled:Pe});Te.current=Fe.settle;let{onGroundDown:Mt,onCardDown:Ue,onDragMove:it,onDragUp:Et,swallow:Xe}=Hi({view:h,panned:P,limit:()=>xt(X),panWithin:H,moveByTransform:!0,setView:y,setDragging:ke,noteMoved:x,shift:Fe,district:ne});I.current=(C,he,xe)=>{if(!h.overview)return;Te.current();let Me=$.current,qe=Math.max(Ra,Math.min(Oa,Me*C));if(Math.abs(qe-Me)<1e-4)return;$.current=qe,Re(),Y(qe);let Yt=z.current?.getBoundingClientRect(),In=X.visible??X,ft={x:In.width/2,y:In.height/2},at=Yt&&he!==void 0&&xe!==void 0?{x:he-Yt.left,y:xe-Yt.top}:ft,Tn=qe/Me;y(Pn=>$t(Pn,Go(Pn.pan??{x:0,y:0},Z.current,at,ft,Tn))),x()};let ie=(C,he,xe=xt(X))=>y(Me=>$t(Me,H(xe,{x:(Me.pan?.x??0)+C,y:(Me.pan?.y??0)+he})));Ci(z,b,(C,he)=>ie(C,he)),A.current=(C,he)=>{Re();let xe=xt(X),Me=h.pan??{x:0,y:0},qe=Fe.offset();Fe.shiftTo(H(xe,{x:Me.x+qe.x+C,y:Me.y+qe.y+he}),Me),x()};let ve=Zs(),nt=Nt(),Rt=(0,q.useCallback)(C=>Qt(nt,C).connector.visible,[nt]),je=C=>$e(ee.nodes.find(he=>he.id===C)),Ot=(C,he,xe,Me)=>C.originY+P.y+Zt(xe.col+xe.side/Me,xe.row+xe.side/Me,C.cell,C.tilt).y-he.y,ze={width:X.width,height:X.height},sn={position:"relative",zIndex:He.stage,...ze},dn=C=>eo(ee,z.current,s,c,C),ht=C=>Oe||_e.has(C),Vt=ee.nodes.filter(C=>C.screenOf===void 0).map(C=>(0,ue.jsx)(va,{node:C,crowded:Sa(C),useDom:ht(C.id),blur:Ye||!Oe&&tt,...C.plot&&ee.city&&Math.round(C.plane)===2?{frontY:Ot(ee.city,C,C.plot,1),centerY:Ot(ee.city,C,C.plot,2)}:{},touched:et.has(C.id),...Hs($e(C)),scheme:s,canvasWidth:X.width,canvasHeight:X.height,selected:w.includes(C.id),...ve(C),onMenu:p,selection:w,onDragStart:he=>Ue(C,he),onDragMove:it,onDragEnd:Et,swallowClick:Xe,children:C.beyond?(0,ue.jsx)(Wi,{kinds:C.beyond}):C.aggregate?.opens?(0,ue.jsx)(zi,{node:C}):(0,ue.jsx)(Vi,{node:C,mode:"scene",selected:w.includes(C.id),...Sa(C)?{fidelity:"glyph"}:{}})},C.id));return(0,ue.jsxs)("div",{ref:z,className:`graview-ground${o?` ${o}`:""}`,"data-graview-altitude":h.overview?"":void 0,"data-graview-reach":ee.city?Ds(xt(X)):void 0,"data-graview-settled":ee.t>=1&&!an.gliding()?"":void 0,"data-graview-box":g?`${g.width}x${g.height}`:void 0,"data-graview-renderer":Oe?"dom":"gpu","data-graview-blur":(Oe?Ye:tt)?"":void 0,onPointerDown:Mt,onPointerMove:it,onPointerUp:Et,onPointerCancel:Et,onClick:C=>{Xe.current||C.target.closest("[data-graview-view], button, aside, section[aria-label], [data-graview-offstage], a, input, select")||(f([]),p(null))},style:{position:"relative",width:"100%",height:"100%",cursor:ae?"grabbing":"grab",touchAction:"none","--graview-altitude":h.overview?1:0,...ee.city?{"--graview-lattice-cell":`${ee.city.cell.toFixed(2)}px`,"--graview-lattice-tilt":(ee.city.tilt??.5).toFixed(3),"--graview-lattice-x":`${(ee.city.originX+ee.city.pan.x).toFixed(1)}px`,"--graview-lattice-y":`${(ee.city.originY+ee.city.pan.y).toFixed(1)}px`}:{},...ae?{userSelect:"none"}:{},overflow:"hidden",...a},children:[h.overview&&ee.city?(0,ue.jsx)(q.Suspense,{fallback:null,children:(0,ue.jsx)(ed,{frame:ee,...ze,pan:ee.city.pan,store:d,graphVersion:j,selection:w,view:{overview:h.overview,focusId:h.focusId,beside:F},emphasis:v,hiddenKinds:u.hiddenKinds,drawn:Rt})}):null,(0,ue.jsx)("div",{ref:D,"aria-hidden":"true",style:{position:"absolute",top:0,right:0,width:"var(--graview-dock, 0px)",height:"var(--graview-sheet, 0px)",visibility:"hidden",pointerEvents:"none"}}),ee.city?(0,ue.jsx)(q.Suspense,{fallback:null,children:(0,ue.jsx)(od,{frame:ee,...ze,pan:ee.city?ee.city.pan:P,brand:k,pinned:V,close:K*N>1.2,swallowed:Xe,...h.overview?{chosen:wn(w,{overview:h.overview,focusId:h.focusId,beside:F},C=>d.graph.getNode(C)?.kind).records}:{},onFocus:C=>{let he=Ae(C);he!==null&&y(xe=>pt(xe,Le(he)))}})}):null,Oe?(0,ue.jsx)("div",{"data-graview-stage":"dom","data-graview-world":"",style:{...sn,overflow:"hidden"},children:Vt}):(0,ue.jsxs)("div",{"data-graview-world":"",style:sn,children:[(0,ue.jsx)("div",{"data-graview-stage":"dom","data-graview-under-canvas":"",style:{position:"absolute",left:0,top:0,...ze,overflow:"hidden"},children:Vt.filter(C=>_e.has(String(C.key)))}),(0,ue.jsx)("canvas",{ref:Q,"data-graview-stage":"gpu",content:"drawable",layoutsubtree:"",...ze,style:{display:"block",position:"relative",...ze},children:Vt.filter(C=>!_e.has(String(C.key)))})]}),h.overview&&!ae?(0,ue.jsx)(Ai,{result:X,schema:d.schema,chrome:S?[...T.chrome??[],S]:T.chrome??[],onGo:C=>{ie(C.x,C.y),x()}}):null,h.overview?(0,ue.jsx)(rd,{zoom:N,zoomBy:C=>I.current(C),above:B,setAbove:J}):null,(0,ue.jsx)(pa,{frame:ee,focusId:h.focusId,beside:F,holding:ce,...ze,scheme:s,overview:!!h.overview,selection:w,emphasis:v,stageRef:z,store:d,graphNodes:j,...(C=>C?{provisional:C}:{})(ma(d)),onPickEdge:(C,he)=>{Xe.current||(f([C]),p(he?{...he,on:C}:null))},liveOf:C=>{let he=je(C.from),xe=je(C.to);return he?.wrote&&xe?.wrote?he.at>xe.at?he:xe:void 0}}),(0,ue.jsx)(Ri,{width:X.width,whereIs:dn}),(0,ue.jsx)(Ei,{marks:St.marks,questions:[...O.values()].filter(C=>C.mode==="asking"&&C.at!==null&&C.say).map(C=>({id:C.at,who:C.who,asks:C.say})),whereIs:dn,stageRef:z,...ze}),(0,ue.jsx)(ya,{nodes:ee.nodes,moving:ee.t<1,holding:ce,scheme:s,width:X.width,stageRef:z}),l]})}var Je=se(Ce(),1);function ad(){return Ta(),null}var Ia=()=>window.location.pathname.endsWith(kr),Aa=()=>(Ia()?Er:go)(window.location.hash),sd=e=>(Ia()?Rr:yo)(e);function Ta(){let{view:e,setView:t,views:n,principal:r}=ye(),o=JSON.stringify(r),a=(0,Je.useCallback)(s=>{let c=s.within?.view;if(c===void 0||s.focusId)return s;let h=n.places().find(y=>y.as===c);return h?{...s,focusId:Le(h.kind)}:s},[n]),i=(0,Je.useRef)(!1);(0,Je.useEffect)(()=>{if(typeof window>"u")return;let s=a(Aa());!Fn(s,po)&&!Fn(s,e)&&(i.current=!0,t(s))},[]),(0,Je.useEffect)(()=>{if(typeof window>"u")return;let s=()=>t(a(Aa()));return window.addEventListener("popstate",s),window.addEventListener("hashchange",s),()=>{window.removeEventListener("popstate",s),window.removeEventListener("hashchange",s)}},[t,a]);let l=(0,Je.useRef)(!1),u=(0,Je.useRef)(null),d=(0,Je.useRef)(o);(0,Je.useEffect)(()=>{if(typeof window>"u")return;if(i.current){i.current=!1;return}let s=d.current!==o;d.current=o;let c=sd(e),h=c||`${window.location.pathname}${window.location.search}`;if((window.location.hash||(window.location.href.includes("#")?"#":""))===c){l.current=!0,u.current=e;return}if(!l.current){l.current=!0,u.current=e,window.history.replaceState({graview:Ct.at},"",h);return}if(s||Pa(u.current,e)){window.history.replaceState({graview:Ct.at},"",h),u.current=e;return}u.current=e,window.history.pushState({graview:++Ct.at},"",h),Ct.depth=Ct.at,Ct.tell()},[e,o])}function Pa(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(",")&&dd(e.within,t.within):!1}function dd(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 yr=se(Ce(),1);var Ca=new WeakMap,ld=64,Na=new WeakMap,cd=0,ud=e=>{if(e===void 0)return 0;let t=Na.get(e);return t===void 0&&Na.set(e,t=cd+=1),t};function Ba(e,t,n,r={}){let o=()=>{let d=[...new Set(t.flatMap(c=>mn(c)))],s=t.map(c=>Lt(c)).filter(c=>c!==null);return Xr(e,t,{...n.principal?{principal:n.principal}:{},kindSelection:d,edgeSelection:s,...n.providers?{providers:n.providers}:{},...n.pins?{pins:n.pins}:{},...n.focus!==void 0?{focus:n.focus}:{},...r})};if(Object.keys(r).length>0)return o();let a=Ca.get(e);if(!a){let d={kept:new Map,at:e.log.length};Ca.set(e,a=d),e.subscribe(()=>d.kept.clear())}a.at!==e.log.length&&(a.kept.clear(),a.at=e.log.length);let i=JSON.stringify([t,n.principal??null,ud(n.providers),n.pins??null,n.focus??null]),l=a.kept.get(i);if(l)return l;let u=o();return a.kept.set(i,u),a.kept.size>ld&&a.kept.delete(a.kept.keys().next().value),u}function hd(e,t,n={}){return Ba(e,t,n)}function fd(e={}){let{store:t,selection:n,principal:r,providers:o}=ye(),{about:a,principal:i=r,providers:l=o,pins:u,focus:d,...s}=e,c=a??n,h=Pt();return(0,yr.useMemo)(()=>Ba(t,c,{principal:i,providers:l,pins:u,focus:d},s),[t,c,e,h,i,l])}function md(){let{store:e,principal:t}=ye();return(0,yr.useMemo)(()=>({preview:(n,r)=>Qr(e,n,r??{},{pressed:t?{author:t}:{}}),apply:(n,r)=>qr(e,n,r??{},{author:t})}),[e,t])}export{Qa as a,Za as b,Ja as c,es as d,ts as e,ns as f,id as g,ad as h,hd as i,fd as j,md as k};
@@ -1,25 +0,0 @@
1
- var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as Ke}from"./chunk.SDO3U72B.js";import{$b as Nn,Fa as Ln,Hc as Gn,J as _n,Ja as gt,Kc as Wn,La as Hn,Nc as Fn,Wa as Dn,ad as Kn,qd as Bn,vd as Fe,wc as jn,wd as ht}from"./chunk.AS4CQBOQ.js";import{a as We,b as _}from"./chunk.AJZBJBMO.js";var uo=We(w=>{"use strict";var kt=Symbol.for("react.transitional.element"),Vr=Symbol.for("react.portal"),Ir=Symbol.for("react.fragment"),Cr=Symbol.for("react.strict_mode"),_r=Symbol.for("react.profiler"),Lr=Symbol.for("react.consumer"),Hr=Symbol.for("react.context"),Dr=Symbol.for("react.forward_ref"),Nr=Symbol.for("react.suspense"),jr=Symbol.for("react.memo"),oo=Symbol.for("react.lazy"),Gr=Symbol.for("react.activity"),Qn=Symbol.iterator;function Wr(e){return e===null||typeof e!="object"?null:(e=Qn&&e[Qn]||e["@@iterator"],typeof e=="function"?e:null)}var ro={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},io=Object.assign,ao={};function ge(e,t,n){this.props=e,this.context=t,this.refs=ao,this.updater=n||ro}ge.prototype.isReactComponent={};ge.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};ge.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function so(){}so.prototype=ge.prototype;function Pt(e,t,n){this.props=e,this.context=t,this.refs=ao,this.updater=n||ro}var Rt=Pt.prototype=new so;Rt.constructor=Pt;io(Rt,ge.prototype);Rt.isPureReactComponent=!0;var eo=Array.isArray;function At(){}var M={H:null,A:null,T:null,S:null},lo=Object.prototype.hasOwnProperty;function Tt(e,t,n){var o=n.ref;return{$$typeof:kt,type:e,key:t,ref:o!==void 0?o:null,props:n}}function Fr(e,t){return Tt(e.type,t,e.props)}function Mt(e){return typeof e=="object"&&e!==null&&e.$$typeof===kt}function Kr(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var to=/\/+/g;function Et(e,t){return typeof e=="object"&&e!==null&&e.key!=null?Kr(""+e.key):t.toString(36)}function Br(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch(typeof e.status=="string"?e.then(At,At):(e.status="pending",e.then(function(t){e.status==="pending"&&(e.status="fulfilled",e.value=t)},function(t){e.status==="pending"&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}function me(e,t,n,o,r){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var a=!1;if(e===null)a=!0;else switch(i){case"bigint":case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case kt:case Vr:a=!0;break;case oo:return a=e._init,me(a(e._payload),t,n,o,r)}}if(a)return r=r(e),a=o===""?"."+Et(e,0):o,eo(r)?(n="",a!=null&&(n=a.replace(to,"$&/")+"/"),me(r,t,n,"",function(u){return u})):r!=null&&(Mt(r)&&(r=Fr(r,n+(r.key==null||e&&e.key===r.key?"":(""+r.key).replace(to,"$&/")+"/")+a)),t.push(r)),1;a=0;var d=o===""?".":o+":";if(eo(e))for(var s=0;s<e.length;s++)o=e[s],i=d+Et(o,s),a+=me(o,t,n,i,r);else if(s=Wr(e),typeof s=="function")for(e=s.call(e),s=0;!(o=e.next()).done;)o=o.value,i=d+Et(o,s++),a+=me(o,t,n,i,r);else if(i==="object"){if(typeof e.then=="function")return me(Br(e),t,n,o,r);throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.")}return a}function Xe(e,t,n){if(e==null)return e;var o=[],r=0;return me(e,o,"","",function(i){return t.call(n,i,r++)}),o}function qr(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var no=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},$r={map:Xe,forEach:function(e,t,n){Xe(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Xe(e,function(){t++}),t},toArray:function(e){return Xe(e,function(t){return t})||[]},only:function(e){if(!Mt(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};w.Activity=Gr;w.Children=$r;w.Component=ge;w.Fragment=Ir;w.Profiler=_r;w.PureComponent=Pt;w.StrictMode=Cr;w.Suspense=Nr;w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=M;w.__COMPILER_RUNTIME={__proto__:null,c:function(e){return M.H.useMemoCache(e)}};w.cache=function(e){return function(){return e.apply(null,arguments)}};w.cacheSignal=function(){return null};w.cloneElement=function(e,t,n){if(e==null)throw Error("The argument must be a React element, but you passed "+e+".");var o=io({},e.props),r=e.key;if(t!=null)for(i in t.key!==void 0&&(r=""+t.key),t)!lo.call(t,i)||i==="key"||i==="__self"||i==="__source"||i==="ref"&&t.ref===void 0||(o[i]=t[i]);var i=arguments.length-2;if(i===1)o.children=n;else if(1<i){for(var a=Array(i),d=0;d<i;d++)a[d]=arguments[d+2];o.children=a}return Tt(e.type,r,o)};w.createContext=function(e){return e={$$typeof:Hr,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:Lr,_context:e},e};w.createElement=function(e,t,n){var o,r={},i=null;if(t!=null)for(o in t.key!==void 0&&(i=""+t.key),t)lo.call(t,o)&&o!=="key"&&o!=="__self"&&o!=="__source"&&(r[o]=t[o]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var d=Array(a),s=0;s<a;s++)d[s]=arguments[s+2];r.children=d}if(e&&e.defaultProps)for(o in a=e.defaultProps,a)r[o]===void 0&&(r[o]=a[o]);return Tt(e,i,r)};w.createRef=function(){return{current:null}};w.forwardRef=function(e){return{$$typeof:Dr,render:e}};w.isValidElement=Mt;w.lazy=function(e){return{$$typeof:oo,_payload:{_status:-1,_result:e},_init:qr}};w.memo=function(e,t){return{$$typeof:jr,type:e,compare:t===void 0?null:t}};w.startTransition=function(e){var t=M.T,n={};M.T=n;try{var o=e(),r=M.S;r!==null&&r(n,o),typeof o=="object"&&o!==null&&typeof o.then=="function"&&o.then(At,no)}catch(i){no(i)}finally{t!==null&&n.types!==null&&(t.types=n.types),M.T=t}};w.unstable_useCacheRefresh=function(){return M.H.useCacheRefresh()};w.use=function(e){return M.H.use(e)};w.useActionState=function(e,t,n){return M.H.useActionState(e,t,n)};w.useCallback=function(e,t){return M.H.useCallback(e,t)};w.useContext=function(e){return M.H.useContext(e)};w.useDebugValue=function(){};w.useDeferredValue=function(e,t){return M.H.useDeferredValue(e,t)};w.useEffect=function(e,t){return M.H.useEffect(e,t)};w.useEffectEvent=function(e){return M.H.useEffectEvent(e)};w.useId=function(){return M.H.useId()};w.useImperativeHandle=function(e,t,n){return M.H.useImperativeHandle(e,t,n)};w.useInsertionEffect=function(e,t){return M.H.useInsertionEffect(e,t)};w.useLayoutEffect=function(e,t){return M.H.useLayoutEffect(e,t)};w.useMemo=function(e,t){return M.H.useMemo(e,t)};w.useOptimistic=function(e,t){return M.H.useOptimistic(e,t)};w.useReducer=function(e,t,n){return M.H.useReducer(e,t,n)};w.useRef=function(e){return M.H.useRef(e)};w.useState=function(e){return M.H.useState(e)};w.useSyncExternalStore=function(e,t,n){return M.H.useSyncExternalStore(e,t,n)};w.useTransition=function(){return M.H.useTransition()};w.version="19.2.8"});var N=We((ka,co)=>{"use strict";co.exports=uo()});var vo=We(et=>{"use strict";var oi=Symbol.for("react.transitional.element"),ri=Symbol.for("react.fragment");function wo(e,t,n){var o=null;if(n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),"key"in t){n={};for(var r in t)r!=="key"&&(n[r]=t[r])}else n=t;return t=n.ref,{$$typeof:oi,type:e,key:o,ref:t!==void 0?t:null,props:n}}et.Fragment=ri;et.jsx=wo;et.jsxs=wo});var Ce=We((Ca,bo)=>{"use strict";bo.exports=vo()});var fe={focusId:null,relation:null,expanded:[],pins:{}},Be=e=>{let t=Number(e);return Number.isFinite(t)?t:null};function te(e){let t=new URLSearchParams;e.focusId&&t.set("focus",e.focusId),e.relation&&t.set("relation",e.relation),e.overview&&t.set("overview","1"),e.zoom&&t.set("zoom","1"),e.past&&t.set("past","1"),e.shown&&e.shown.length>0&&t.set("show",[...e.shown].sort().join(",")),e.selection!==void 0&&e.selection.length>0&&t.set("sel",[...e.selection].sort().join(",")),e.expanded.length>0&&t.set("expand",[...e.expanded].sort().join(","));for(let o of Object.keys(e.pins).sort()){let r=e.pins[o];t.set(`pin.${o}`,`${qe(r.x)},${qe(r.y)}`)}e.pan&&(e.pan.x!==0||e.pan.y!==0)&&t.set("pan",`${qe(e.pan.x)},${qe(e.pan.y)}`);for(let o of Object.keys(e.within??{}).sort()){let r=e.within[o];r.length>0&&t.set(`in.${o}`,r)}e.q&&e.q.trim().length>0&&t.set("q",e.q);let n=t.toString();return n?`#${n}`:"#"}function kr(e){return e&&e.startsWith("agg:")?`aggregate:${e.slice(4)}`:e}function $e(e){let t=e.includes("#")?e.slice(e.indexOf("#")+1):e,n=new URLSearchParams(t),o=Object.create(null);for(let[m,p]of n){if(!m.startsWith("pin."))continue;let[g,v]=p.split(","),k=g===void 0?null:Be(g),y=v===void 0?null:Be(v);k===null||y===null||(o[m.slice(4)]={x:k,y})}let r=Object.create(null);for(let[m,p]of n)!m.startsWith("in.")||p.length===0||(r[m.slice(3)]=p);let i=n.get("view");i&&i.length>0&&r.view===void 0&&(r.view=i);let a=n.get("pan")?.split(",")??[],d=a[0]===void 0?null:Be(a[0]),s=a[1]===void 0?null:Be(a[1]),u=(n.get("sel")??"").split(",").filter(m=>m.length>0).sort(),f=n.get("overview")==="1";return{...u.length>0?{selection:u}:{},...f?{overview:!0}:{},...n.get("zoom")==="1"?{zoom:!0}:{},...n.get("past")==="1"?{past:!0}:{},...n.get("show")?{shown:[...new Set(n.get("show").split(",").filter(Boolean))].sort()}:{},...d!==null&&s!==null?{pan:{x:d,y:s}}:{},...Object.keys(r).length>0?{within:r}:{},...n.get("q")?.trim()?{q:n.get("q")}:{},focusId:kr(n.get("focus")),relation:n.get("relation"),expanded:(n.get("expand")??"").split(",").filter(m=>m.length>0&&(f||!m.startsWith("kind:"))).sort(),pins:o}}function la(e){let t=$e(e);return te(t)==="#"?{...t,overview:!0}:t}function da(e){let t=te(e);return t==="#overview=1"?"":t}function qe(e){return Math.round(e*100)/100}function $n(e,t){return te(e)===te(t)}var qn="edge:";function zn(e){if(!e.startsWith(qn))return null;let t=e.slice(qn.length).split(":");if(t.length!==3)return null;let[n,o,r]=t;if(!n||!o||!r)return null;try{return{kind:decodeURIComponent(n),from:decodeURIComponent(o),to:decodeURIComponent(r)}}catch{return null}}function St(e){let{pan:t,...n}=e;return{...n,pins:{}}}function q(e,t){if(t===e.focusId)return{...e,focusId:t};let n=St(e);return{...n.within?.q!==void 0?ae(n,"q",null):n,focusId:t}}function Un(e,t){return{...e,relation:t}}function ae(e,t,n){let o={...e.within??{}};if(n===null?delete o[t]:o[t]=n,Object.keys(o).length===0){let{within:r,...i}=e;return i}return{...e,within:o}}function pe(e,t){if(t!==e.overview&&(e=St(e)),!t){let n=e.expanded.filter(o=>!o.startsWith("kind:"));return{...e,overview:!1,expanded:n}}return{...e,overview:t}}function ze(e,t){if(t.length===0){let{selection:n,...o}=e;return o}return{...e,selection:[...t]}}function Ve(e,t){if(t!==(e.zoom===!0)&&(e=St(e)),!t){let{zoom:n,...o}=e;return o}return{...e,zoom:!0}}function Ue(e,t){let n=new Set(e.expanded);return n.has(t)?n.delete(t):n.add(t),{...e,expanded:[...n].sort()}}var Ze="aggregate:",Ye="kind:";function wt(e){return`${Ye}${e}`}function ye(e){return e.startsWith(Ye)?e.slice(Ye.length):null}var fa="kinds:beyond";function Pr(e){let t=ye(e);return t?[t]:se(e)}function ne(...e){return`${Ze}${[...e].sort().join("+")}`}function Yn(e){return e.startsWith(Ze)}function se(e){return!Yn(e)||e.includes("|")?[]:e.slice(Ze.length).split("+").filter(Boolean)}function Zn(e,t,n={}){let o=ye(t);if(o!==null&&e.overview&&n.ownPicture!==!0)return Ue(e,t);let r=o!==null?ne(o):t;if(e.zoom&&e.focusId===r&&!(o!==null&&n.carry))return Ve(e,!1);if(o!==null&&n.carry){let i=pe({...q(e,r),relation:null},!1);return ae(Ve(i,!0),"q",n.carry)}return Ve({...q(e,r),relation:null},!0)}function Rr(e,t,n){return ae(pe(q(e,ne(t)),!1),"view",n)}function pa(e,t){return e.id<t.id?-1:e.id>t.id?1:0}var Xn="aggregate:";function vt(e){return e.startsWith(Xn)&&e.includes("|")}var bt=e=>e?.off===!0,Tr=e=>e!==void 0&&!bt(e)&&(e.fast!==void 0||e.thinking!==void 0||e.answer!==void 0||e.decide!==void 0||e.complete!==void 0||e.turn!==void 0),Jn=e=>e!==void 0&&!bt(e)&&(e.fast!==void 0||e.decide!==void 0),Mr=e=>e?.suggestOnOpen!==!1&&Jn(e),Or=e=>e?.hoverChips===!0&&Jn(e);var xt={};var fo=_(N(),1),zr={turns:[],outcomes:new Map,busy:!1,pending:null,draft:null,draftNote:null},po=e=>`graview:seat:${e}`;function Ur(e){if(!e)return{};try{let t=sessionStorage.getItem(e);if(!t)return{};let n=JSON.parse(t);return{...Array.isArray(n.turns)?{turns:n.turns}:{},...Array.isArray(n.outcomes)?{outcomes:new Map(n.outcomes)}:{},...n.draft?.drawn?{draft:n.draft}:{}}}catch{return{}}}function Yr(e,t){if(e)try{sessionStorage.setItem(e,JSON.stringify({turns:t.turns.slice(-40),outcomes:[...t.outcomes],draft:t.draft}))}catch{}}function Ot(e){let t=e===null?null:po(e),n={...zr,...Ur(t)},o=new Set,r=(i,a=!0)=>{n=i,a&&Yr(t,n);for(let d of[...o])d()};return{get:()=>n,subscribe(i){return o.add(i),()=>void o.delete(i)},setTurns:i=>r({...n,turns:i(n.turns)}),settle:(i,a)=>r({...n,outcomes:new Map(n.outcomes).set(i,a)}),setBusy:i=>r({...n,busy:i},!1),ask:i=>r({...n,pending:i.trim()||null}),takePending(){let i=n.pending;return i!==null&&r({...n,pending:null},!1),i},setDraft:(i,a=null)=>r({...n,draft:i,draftNote:a})}}function Zr(e){return(0,fo.useSyncExternalStore)(e.subscribe,e.get,e.get)}var mo=_(N(),1),Xr={entries:[],ghost:null,loaded:!1};function yo(e,t){let n=new Map(e.map(o=>[o.id,o]));for(let o of t)n.set(o.id,{...n.get(o.id),...o});return[...n.values()].sort((o,r)=>o.at<r.at?1:o.at>r.at?-1:0)}function Vt(e){let t=Xr,n=new Set,o=r=>{t=r;for(let i of[...n])i()};return{get:()=>t,subscribe:r=>(n.add(r),()=>n.delete(r)),record:r=>{o({...t,entries:yo(t.entries,[r])}),Promise.resolve(e()?.keep?.(r)).catch(i=>{console.warn("The host did not keep an AI interaction:",i)})},setGhost:r=>o({...t,ghost:r}),load:()=>{if(t.loaded)return;o({...t,loaded:!0});let r=e()?.load;r&&Promise.resolve(r()).then(i=>o({...t,entries:yo(t.entries,i)})).catch(i=>{console.warn("The host's AI interactions could not be read:",i)})}}}function Jr(e){return(0,mo.useSyncExternalStore)(e.subscribe,e.get,e.get)}function go(e){return e?.closest?.("[data-graview-pick]")?.getAttribute("data-graview-pick")??null}var Je=_(N(),1),Qe=(0,Je.createContext)(void 0),Qr=()=>(0,Je.useContext)(Qe);var A=_(N(),1),Ie=(0,A.createContext)(null);function So(){return(0,A.useContext)(Ie)}function ei(e,t){let n=So(),o=(0,A.useMemo)(()=>n?n.live.seenBy(t):e,[n,e,t]),r=(0,A.useRef)(0),i=(0,A.useCallback)(a=>o.subscribe(()=>{r.current+=1,a()}),[o]);return(0,A.useSyncExternalStore)(i,()=>r.current,()=>0),o}var ti=Ke(()=>(__graviewPreload(import.meta.url,["./chunk.TI4OSTQV.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.E2AJ7U5Z.js"))),ho,ni=400;function It(e,t,n){let o=(0,A.useContext)(Ie),r=o!==null&&o.owns(e,t),[i,a]=(0,A.useState)(null),[d,s]=(0,A.useState)(ho);(0,A.useEffect)(()=>{if(d||r||i===null)return;let x=!0;return ti().then(V=>{ho=V,x&&s(V)},()=>{}),()=>{x=!1}},[d,r,i]);let[u,f]=(0,A.useState)(0),m=(0,A.useMemo)(()=>r||i===null||i>=e.log.length||!d?void 0:d.askArchived(e,i,n)??d.askDeclaration(n,i),[r,e,i,n,d,u]),p=m&&"waiting"in m?m.waiting:void 0,g=m&&"seq"in m?m:null,[v,k]=(0,A.useState)(void 0);(0,A.useEffect)(()=>{if(!p)return;let x=!0,V=setTimeout(()=>x&&k(p),ni);return p.then(()=>x&&f(O=>O+1)),()=>{x=!1,clearTimeout(V)}},[p]);let y=p!==void 0&&v!==p||g!==null,b=(0,A.useMemo)(()=>{if(r||i===null||i>=e.log.length||!d||y)return null;try{let x=d.pastAt(e,i,n);return{seq:i,at:x.past?.at,store:x}}catch{return null}},[r,e,i,n,d,y,u]),h=(0,A.useRef)(null),E=y?h.current:b;(0,A.useEffect)(()=>{h.current=E},[E]);let P=(0,A.useCallback)(x=>a(x===null?null:x>=e.log.length?Number.POSITIVE_INFINITY:x),[e]),D=(0,A.useCallback)((x,V)=>[e,E?.store].some(O=>O!==void 0&&(O===x||O.seenBy(V)===x)),[e,E]),C=i!==null,G=(0,A.useMemo)(()=>({past:E,open:C,show:P,live:e,host:n,owns:D,archive:g}),[E,C,P,e,n,D,g]);return r?o:G}var xo=e=>`graview:setting:${e}`;function Eo(){return localStorage}function Ao(e,t){try{let n=(t??Eo()).getItem(xo(e.name));if(n!==null&&e.options.some(o=>o.value===n))return n}catch{}return e.initial}function ko(e,t,n){try{(n??Eo()).setItem(xo(e.name),t)}catch{}}function Po(e,t){if(typeof document>"u")return;let n=document.documentElement;if(e.honored==="root-font-size"){n.style.fontSize=t===e.initial?"":t;return}let o=`graview${e.name.replace(/-([a-z0-9])/g,(r,i)=>i.toUpperCase()).replace(/^[a-z]/,r=>r.toUpperCase())}`;t===e.initial?delete n.dataset[o]:n.dataset[o]=t}var L=_(N(),1);function Ct(e){return Fe(e)}var ii=12,ai=4;function si(e,t,n){let o=Ct(t);return e.get(o)??{participant:o,who:t.id??t.kind,at:null,mode:"docked",since:n,trail:[]}}var tt=(e,t)=>t===null||e[e.length-1]===t?e:[...e,t].slice(-ii);function Ro(e,t){let n=e.filter(r=>r.length>0);if(n.length===0)return null;if(n.length<=ai)return n[0];let o=new Set(n.map(r=>t(r)).filter(r=>r!==void 0));return o.size===1?wt([...o][0]):n[0]}function _t(e,t,n){let o=new Map(e);if(t.type==="rest"){for(let[a,d]of e)d.mode!=="asking"&&d.mode!=="docked"&&t.at-d.since>=t.holdMs&&o.set(a,{...d,mode:"docked",at:null,trail:[],say:void 0,confidence:void 0});return o}if(t.author.kind!=="agent")return o;let r=si(e,t.author,t.at),i=a=>o.set(r.participant,{...r,...a,since:t.at});switch(t.type){case"read":{let a=Ro(t.ids,n);return i({at:a,mode:"reading",trail:tt(r.trail,a)}),o}case"about-to-write":case"write":{let a=Ro(t.ids,n);return i({at:a,mode:"writing",trail:tt(r.trail,a),say:void 0,confidence:void 0}),o}case"refused":return i({at:t.where,mode:"refused",say:t.say,confidence:void 0,trail:tt(r.trail,t.where)}),o;case"asking":return i({at:t.where??r.at,mode:"asking",say:t.say,...t.confidence!==void 0?{confidence:t.confidence}:{confidence:void 0},trail:tt(r.trail,t.where)}),o;case"said":return i({say:t.say,...t.confidence!==void 0?{confidence:t.confidence}:{confidence:void 0},...t.caption?{caption:t.caption}:{}}),o;case"over":return i({over:t.over}),o;case"home":return i({at:null,mode:"docked",trail:[],say:void 0,confidence:void 0,over:null}),o;default:return o}}var To="graview:session";function Mo(e){let t=()=>typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID().slice(0,8):Math.random().toString(36).slice(2,10);try{let n=e??sessionStorage,o=n.getItem(To);if(o)return o;let r=t();return n.setItem(To,r),r}catch{return t()}}var Lt={name:"share-where",title:"Where you are",description:"Whether the others here see which stop you are on.",honored:"root-attribute",options:[{value:"shared",label:"Shown"},{value:"private",label:"Hidden"}],initial:"shared"},Ht={name:"share-over",title:"What you point at",description:"Whether the others see the thing under your pointer, outlined in your color.",honored:"root-attribute",options:[{value:"private",label:"Kept to yourself"},{value:"shared",label:"Outlined for others"}],initial:"private"},Oo=[Lt,Ht],di=800;function Vo(e){let{channel:t,store:n,view:o,principal:r,session:i,robots:a,seatWho:d,settingValues:s,setView:u,ttlMs:f=1e4,people:m,seats:p}=e,[g,v]=(0,L.useState)(()=>new Map),[k,y]=(0,L.useState)(null),[b,h]=(0,L.useState)(null),[E,P]=(0,L.useState)(null),D=typeof r.id=="string"&&r.id.length>0,C=D&&(s[Lt.name]??Lt.initial)==="shared",G=C&&(s[Ht.name]??Ht.initial)==="shared",x=Ct({kind:r.kind,...r.id?{id:r.id}:{},session:i}),V=D?Dn(r,{graph:n.graph,schema:n.schema,...p?{seats:p}:{},...m?{people:m}:{}}):"",O=d?a.get(`agent:${d}:${i}`):void 0,W=(0,L.useMemo)(()=>!t||!C?null:{participant:x,kind:r.kind,name:V,...r.onBehalfOf?.id?{onBehalfOf:r.onBehalfOf.id,...r.onBehalfOf.name?{onBehalfOfName:r.onBehalfOf.name}:{}}:{},hue:Nn(r.id??"nobody"),stop:E??te(o),...G?{over:k}:{},...O?{robot:{at:O.at,mode:O.mode}}:{},at:new Date().toISOString()},[t,C,G,x,V,r.id,r.kind,r.onBehalfOf?.id,r.onBehalfOf?.name,o,E,k,O?.at,O?.mode]);(0,L.useEffect)(()=>{if(!t||!W)return;t.here(W);let I=setInterval(()=>t.here({...W,at:new Date().toISOString()}),di);return()=>clearInterval(I)},[t,W]),(0,L.useEffect)(()=>t?t.onWho(K=>v(ht(new Map,K,Date.now(),f))):void 0,[t,f]);let Z=g.size>0;(0,L.useEffect)(()=>{if(!Z)return;let I=setInterval(()=>{v(K=>{let Q=ht(K,[],Date.now(),f);return Q.size===K.size?K:Q})},Math.max(250,Math.min(1e3,f/4)));return()=>clearInterval(I)},[Z,f]),(0,L.useEffect)(()=>{if(!t||typeof window>"u")return;let I=()=>t.leave();return window.addEventListener("pagehide",I),()=>window.removeEventListener("pagehide",I)},[t]),(0,L.useEffect)(()=>{if(!G||typeof document>"u")return;let I=null,K=Q=>{let Ee=go(Q.target);Ee!==I&&(I=Ee,y(Ee))};return document.addEventListener("pointermove",K,{passive:!0}),()=>document.removeEventListener("pointermove",K)},[G]);let X=(0,L.useRef)(null),$=b?g.get(b)??null:null,de=(0,L.useCallback)(I=>{X.current=null,h(I)},[]);return(0,L.useEffect)(()=>{if(b){if(!$){h(null);return}$.stop!==X.current?.stop&&(X.current={stop:$.stop,at:Date.now()},u($e($.stop)))}},[b,$,u]),(0,L.useEffect)(()=>{let I=X.current;!b||I===null||Date.now()-I.at<400||$n(o,$e(I.stop))||h(null)},[o,b]),(0,L.useEffect)(()=>{if(!b||typeof document>"u")return;let I=K=>{K.key==="Escape"&&h(null)};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[b]),(0,L.useMemo)(()=>({who:g,sharing:W?{participant:x,name:V}:null,following:$,follow:de,sayWhere:P}),[g,W,x,V,$,de])}var U=_(N(),1);function Io(e){return Fe(e.author)}function ui(e,t){return e.length>1?"co-edited":t==="rule"?"rule":t==="agent"?"autonomous":"directed"}function Co(e,t,n,o,r){let i=new Map;for(let[s,u]of e)o-u.at<r&&i.set(s,u);let a=new Set(n.flatMap(s=>s.nodeIds)),d=(s,u,f)=>{let m=i.get(s),p=m?.participants.includes(Io(u))?m.participants:[...m?.participants??[],Io(u)];i.set(s,{at:o,manner:ui(p,u.author.kind),intent:u.intent,wrote:(m?.wrote??!1)||(f.wrote??!1),read:(m?.read??!1)||(f.read??!1),broke:(m?.broke??!1)||a.has(s),participants:p})};for(let s of t){for(let u of s.writes)d(u,s,{wrote:!0});for(let u of s.reads)s.writes.includes(u)||d(u,s,{read:!0})}for(let s of n)for(let u of s.nodeIds){let f=i.get(u);i.set(u,{at:o,manner:f?.manner??"rule",intent:f?.intent??s.message,wrote:f?.wrote??!1,read:f?.read??!1,broke:!0,participants:f?.participants??["rule::"]})}return i}var ci=2600;function _o(e,t=ci){let[n,o]=(0,U.useState)(()=>new Map),r=(0,U.useRef)(n);r.current=n;let i=(0,U.useRef)(null),a=(0,U.useCallback)(s=>{r.current=s,o(s),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{r.current=new Map,o(new Map)},t)},[t]);(0,U.useEffect)(()=>{let s=e.violations(),u=e.subscribe((f,m)=>{let p=e.violations(),g=Fn(e.allInvariants(),s,p).introduces;s=p,a(Co(r.current,m,g.map(v=>({nodeIds:v.nodeIds,message:v.message})),Date.now(),t))});return()=>{u(),i.current&&clearTimeout(i.current)}},[e,t,a]);let d=(0,U.useCallback)(s=>{s.reads.length!==0&&a(Co(r.current,[fi(s)],[],Date.now(),t))},[t,a]);return{activity:n,noteAttention:d}}function fi(e){return{id:`attention:${e.intent}`,seq:-1,batch:"attention",author:e.author,intent:e.intent,mutation:null,primitives:[],reads:e.reads,writes:[],at:new Date().toISOString()}}var l=_(N(),1);function Lo(){let e=null,t=new Set,n=new Set,o=r=>{for(let i of n)i(r)};return{subscribe(r){return t.add(r),t.size===1&&o(!0),()=>{t.delete(r),t.size===0&&(e=null,o(!1))}},snapshot:()=>e,set(r){if(!(e===r||e&&r&&e.x===r.x&&e.y===r.y)){e=r;for(let i of t)i()}},get listeners(){return t.size},onActive(r){return n.add(r),()=>void n.delete(r)}}}var nt=_(N(),1),pi=e=>e.definitions.some(t=>Ln(t).size>0);function Ho(e,t,n){let[o,r]=(0,nt.useState)(void 0),i=(n.roles??[]).join("\0");return(0,nt.useEffect)(()=>{if(!t||!pi(e.schema)){r(void 0);return}let a=!0,d=!1,s=e.graph,u=()=>{d||(d=!0,queueMicrotask(()=>{d=!1,a&&e.reread()}))},f=Hn(t,{kind:n.kind,...n.id===void 0?{}:{id:n.id},...n.roles?{roles:n.roles}:{}},u);return gt(s,f.read),r(f),e.reread(),()=>{a=!1,gt(s,void 0)}},[e,t,n.kind,n.id,i]),o}function Do(){let e=!1,t=new Set;return{moving:()=>e,set(n){if(n!==e){e=n;for(let o of t)o()}},subscribe(n){return t.add(n),()=>t.delete(n)}}}var le=_(Ce(),1),yi="graview:place-menu",_e=(0,l.createContext)(null),Wo=(0,l.createContext)("scene");function mi({mode:e,children:t}){return(0,le.jsx)(Wo.Provider,{value:e,children:t})}function gi(){return(0,l.useContext)(Wo)}var Fo={kind:"human"},hi=[],Si=[],wi=[],Dt=[];function Ko(e,t){let n=(0,l.useId)();(0,l.useEffect)(()=>{if(!globalThis.__graviewWatch)return;let o=t??Fo,r=()=>Wn(e,o,n);r();let i,a=e.subscribe(()=>{clearTimeout(i),i=setTimeout(r,250)});return()=>{clearTimeout(i),a(),globalThis.__graviewWatch?.unseen?.({words:[],from:n,gone:!0})}},[e,t,n])}var vi={off:!0};function bi({store:e,views:t,initialView:n,scheme:o="dark",initialSelection:r,principal:i,seats:a=hi,onSeat:d,people:s=Si,memory:u,presenceTtlMs:f,app:m,settings:p=m?.settings??wi,presence:g,brand:v,locale:k,timeZone:y,onKeepLens:b,providers:h,ai:E,files:P,resolveApp:D,history:C,linkedRecords:G,menuSections:x,keptViews:V,subscriptions:O,signIn:W,view:Z,onViewChange:X,children:$}){let de=(0,l.useContext)(_e),I=x??de?.menuSections,K=W??de?.signIn,Q=V??de?.keptViews,[Ee,fr]=(0,l.useState)(null),ue=Ee??i??a[0]?.principal??Fo,He=It(e,ue,C),Jt=He.past&&He.live===e?He.past.store:e,H=(0,l.useMemo)(()=>Jt.seenBy(ue),[Jt,ue]);Ko(e,ue);let[re]=(0,l.useState)(()=>Mo(u)),[Qt,pr]=(0,l.useState)(!1),en=(0,l.useCallback)(()=>pr(!0),[]),ie=(0,l.useMemo)(()=>g?[...p,...Oo]:p,[p,g]),[ct]=(0,l.useState)(()=>n??Wt(t,e.schema)),[yr,tn]=(0,l.useState)(()=>ze(ct??fe,r??ct?.selection??[])),Ae=(0,l.useRef)(ct??fe).current,[nn,mr]=(0,l.useState)(null),[on,gr]=(0,l.useState)(null),J=(0,l.useContext)(_e),[rn]=(0,l.useState)(()=>J?.seatTalk??Ot(v?.name??e.schema.kinds.join(","))),ft=E??J?.ai??xt,De=(0,l.useMemo)(()=>ft.off?vi:ft,[ft]),an=(0,l.useRef)(De.interactions);an.current=De.interactions;let[sn]=(0,l.useState)(()=>J?.aiDesk??Vt(()=>an.current)),[hr]=(0,l.useState)(()=>J?.subscriptions??Gn()),ln=O??J?.subscriptions??hr,pt=b??J?.onKeepLens,Ne=m??J?.app,je=k??J?.locale,Sr=v?.locale??Ne?.brand?.locale,Ge=y??J?.timeZone;_n({reader:je,app:Sr,readerTimeZone:Ge,appTimeZone:v?.timeZone??Ne?.brand?.timeZone});let dn=(0,l.useRef)(null),un=(0,l.useCallback)(c=>{dn.current=c},[]),cn=(0,l.useCallback)(c=>dn.current?.whereIs(c)??null,[]),[fn]=(0,l.useState)(()=>Lo()),[pn]=(0,l.useState)(()=>Do()),[yt,wr]=(0,l.useState)(null),[ke,yn]=(0,l.useState)(()=>new Map),Pe=(0,l.useRef)(ke);Pe.current=ke;let Re=(0,l.useRef)(null),mt=(0,l.useCallback)(c=>H.graph.getNode(c)?.kind,[H]),ee=(0,l.useCallback)(c=>{let S=_t(Pe.current,c,mt);Pe.current=S,yn(S),Re.current&&clearTimeout(Re.current),[...S.values()].some(T=>T.mode!=="docked"&&T.mode!=="asking")&&(Re.current=setTimeout(()=>{let T=_t(Pe.current,{type:"rest",at:Date.now(),holdMs:Gt},mt);Pe.current=T,yn(T)},Gt+20))},[mt]),mn=(0,l.useCallback)(c=>ee({...c,at:c.at??Date.now()}),[ee]),gn=(0,l.useCallback)(c=>{wr(c),c&&ee({type:"home",author:{kind:"agent",id:c,session:re},at:Date.now()})},[ee,re]);(0,l.useEffect)(()=>H.subscribe((c,S)=>{for(let R of S)R.author.kind==="agent"&&ee({type:"write",author:R.author,ids:R.writes,at:Date.now()})}),[H,ee]),(0,l.useEffect)(()=>()=>{Re.current&&clearTimeout(Re.current)},[]);let z=(0,l.useMemo)(()=>({...ue,session:re}),[ue,re]),hn=Ho(H,G,z),Sn=(0,l.useCallback)(c=>{fr(c),d?.(c)},[d]),[Te,vr]=(0,l.useState)(()=>Object.fromEntries(ie.map(c=>[c.name,Ao(c,u)])));(0,l.useEffect)(()=>{for(let c of ie)Po(c,Te[c.name]??c.initial)},[ie,Te]);let wn=(0,l.useCallback)((c,S)=>{let R=ie.find(T=>T.name===c);!R||!R.options.some(T=>T.value===S)||(ko(R,S,u),vr(T=>({...T,[c]:S})))},[ie,u]),[vn,br]=(0,l.useState)(null),{activity:bn,noteAttention:xn}=_o(H),En=(0,l.useCallback)(c=>{xn(c),ee({type:"read",author:c.author,ids:c.reads,at:Date.now()})},[xn,ee]),ce=(0,l.useCallback)(c=>{if(ye(c)!==null||se(c).length>0||vt(c))return!0;let S=zn(c);return S?H.graph.allEdges().some(R=>R.kind===S.kind&&R.from===S.from&&R.to===S.to):H.graph.getNode(c)!==void 0},[H]),An=(0,l.useCallback)(c=>{let S=c.selection??Dt,R=S.filter(ce),T=R.length===S.length?c:ze(c,R);return T.focusId!==null&&!ce(T.focusId)&&(T=q(T,null)),T},[ce]),Me=(0,l.useCallback)(c=>{let S=An(c),R=Go(H,z,S.shown);if(S.focusId!==null&&R.size>0){let T=se(S.focusId),Cn=H.graph.getNode(S.focusId);(T.length>0?T.every(Ar=>R.has(Ar)):Cn?R.has(Cn.kind):!1)&&(S={...S,focusId:null})}if(!S.overview&&S.focusId===null){let T=Ae.focusId!==null&&!ce(Ae.focusId)?Wt(t,e.schema)??{...fe,overview:!0}:Ae;T.focusId!==null&&ce(T.focusId)?S={...S,focusId:T.focusId}:T.overview===!0&&(S={...S,overview:!0})}return S},[An,ce,H,Ae,z,t,e.schema]),B=Me(Z??yr),kn=(0,l.useMemo)(()=>Go(H,z,B.shown),[H,z,B.shown]),Pn=(0,l.useMemo)(()=>[...H.modules.administered.entries()].map(([c,S])=>{let R=H.mayAdminister(c,z);return{name:c,...S.description?{description:S.description}:{},kinds:S.kinds??[],canShow:R,shown:R&&(B.shown??[]).includes(c)}}),[H,z,B.shown]),Oe=(0,l.useCallback)(c=>{let S=R=>Me(typeof c=="function"?c(R):c);if(Z!==void 0){X?.(S(Z));return}X&&X(S(B)),tn(R=>S(R))},[B,X,Z,Me]);(0,l.useEffect)(()=>{Z===void 0&&tn(c=>{let S=Me(c);return S===c?c:S})},[B,Z,Me]);let Rn=B.selection??Dt,Tn=(0,l.useCallback)(c=>{Oe(S=>ze(S,typeof c=="function"?c(S.selection??Dt):c))},[Oe]),{who:Mn,following:On,follow:Vn,sayWhere:xr,sharing:In}=Vo({channel:g,store:H,view:B,principal:z,session:re,robots:ke,seatWho:yt,settingValues:Te,setView:Oe,seats:a,people:s,...f!==void 0?{ttlMs:f}:{}}),Er=(0,l.useMemo)(()=>({store:H,scheme:o,views:t,view:B,setView:Oe,homeView:Ae,selection:Rn,setSelection:Tn,menuAt:nn,setMenuAt:mr,whereIs:cn,pointer:fn,motion:pn,registerScene:un,robots:ke,noteSeat:mn,seatWho:yt,registerSeatWho:gn,actsDoor:on,registerActsDoor:gr,seatTalk:rn,aiDesk:sn,...u?{memory:u}:{},who:Mn,following:On,follow:Vn,sayWhere:xr,sharing:In,session:re,ai:De,resolveApp:D,linkedRecords:G,menuSections:I,...Q?{keptViews:Q}:{},subscriptions:ln,signIn:K,linkedReads:hn,movedByHand:Qt,noteMoved:en,emphasis:vn,setEmphasis:br,activity:bn,noteAttention:En,principal:z,seats:a,people:s,takeSeat:Sn,settings:ie,settingValues:Te,chooseSetting:wn,hiddenKinds:kn,administered:Pn,...h?{providers:h}:{},...v?{brand:v}:{},...pt?{onKeepLens:pt}:{},app:Ne,...je?{locale:je}:{},...Ge?{timeZone:Ge}:{}}),[H,o,t,B,Oe,Rn,Tn,nn,cn,fn,pn,un,ke,mn,yt,gn,on,rn,sn,u,Mn,On,Vn,In,re,De,D,G,I,Q,ln,K,hn,Qt,en,vn,bn,En,z,a,s,Sn,ie,Te,wn,kn,Pn,h,v,pt,Ne,je,Ge]);return(0,le.jsx)(_e.Provider,{value:Er,children:(0,le.jsx)(Ie.Provider,{value:He,children:(0,le.jsx)(Pi,{children:P?(0,le.jsx)(Qe.Provider,{value:P,children:$}):$})})})}var Bo=(0,l.createContext)(null),Nt,jt=new Set,xi=e=>(jt.add(e),()=>void jt.delete(e)),No=()=>Nt;function Ei(e){if(!Nt){Nt=e;for(let t of[...jt])t()}}var Ai=300;function ki(e){let t=0;return async(n,o)=>{let r=++t;return await new Promise(i=>setTimeout(i,Ai)),r===t?e(n,o):[]}}function Pi({children:e}){let{store:t,view:n,views:o,principal:r,hiddenKinds:i,selection:a,ai:d}=oe(),s=ot(),u=n.q,f=n.focusId,m=!!(u&&u.trim().length>0),p=(0,l.useSyncExternalStore)(xi,No,No),g=(0,l.useMemo)(()=>m&&p?{flagged:new Set(t.violations().flatMap(E=>E.nodeIds)),touched:p.touchWeights(t.log.all())}:null,[t,s,m,p]),v=f?t.graph.getNode(f)?.kind??ye(f)??(se(f).length===1?se(f)[0]:void 0):void 0,k=(0,l.useMemo)(()=>d.near&&ki(d.near),[d.near]),y=(0,l.useMemo)(()=>!u||!g||!p?null:p.search(t,u,{...v?{inKind:v}:{},principal:r,places:o.places(),kinds:t.schema.kinds.filter(E=>!i.has(E)),from:[...a,...f&&t.graph.has(f)?[f]:[]],flagged:g.flagged,touched:g.touched,limit:200,rank:k}),[t,u,r,o,i,a,f,v,g,k]),[b,h]=(0,l.useState)();return(0,l.useEffect)(()=>void y?.later?.then(E=>h([y,E])),[y]),(0,le.jsx)(Bo.Provider,{value:b?.[0]===y?b[1]:y,children:e})}var jo=new WeakMap;function ds(e){let t=jo.get(e);return t||jo.set(e,t=new Set(e.matched)),t}function Ri(){return(0,l.useContext)(Bo)}function oe(){let e=(0,l.useContext)(_e);if(!e)throw new Error("useGraview must be used inside a <GraviewProvider>.");return e}function Ft(){return(0,l.useContext)(_e)??null}function ot(){let{store:e}=oe(),t=(0,l.useRef)(null),n=(0,l.useRef)(null),o=(0,l.useCallback)(()=>(n.current!==e&&(n.current=e,t.current=null),t.current??=e.graph.allNodes(),t.current),[e]),r=(0,l.useCallback)(i=>e.subscribe(()=>{t.current=null,i()}),[e]);return(0,l.useSyncExternalStore)(r,o,o)}function Ti(e){let{store:t}=oe(),n=(0,l.useCallback)(r=>t.subscribe(r),[t]),o=(0,l.useCallback)(()=>e===null?void 0:t.graph.getNode(e),[t,e]);return(0,l.useSyncExternalStore)(n,o,o)}function Go(e,t,n){let o=new Set(e.modules.disabledKinds);for(let r of e.kindsKeptFrom(t))o.add(r);for(let[r,i]of e.modules.administered)if(!(e.mayAdminister(r,t)&&(n??[]).includes(r)))for(let a of i.kinds??[])o.add(a);return o}var Gt=2600;var qo=new WeakSet,Mi=e=>qo.has(e),Oi=e=>void qo.add(e);function Wt(e,t){let n=Bn(e.arrangement?.()?.first,t,e.places());if(!(!n||n.to==="home"))return n.to==="place"?{...fe,focusId:ne(n.place.kind),within:{view:n.place.as}}:{...fe,focusId:ne(n.kind)}}var $o=_(N(),1),Vi=(0,$o.createContext)(!1);var rt=Symbol.for("graview.default-view");function zo(e){return Object.defineProperty(e,rt,{value:!0,enumerable:!1}),e}function Uo(e){return typeof e=="function"&&e[rt]===!0}var it=Symbol.for("graview.replaces-page");function Yo(e){return Object.defineProperty(e,it,{value:!0,enumerable:!1}),e}function Zo(e){return typeof e=="function"&&e[it]===!0}var at=Symbol.for("graview.bleeds");function Xo(e){return Object.defineProperty(e,at,{value:!0,enumerable:!1}),e}function Jo(e){return typeof e=="function"&&e[at]===!0}function Ii(e){return Kn(e)}function Ci(e,t){if(t===e)return e;for(let r of t.registrations())e.register(r.kind,r,r.view,r);let n=t.arrangement?.();n&&e.arrange?.(n);let o=t.homeView?.();return o&&e.home?.(o),e}var F=_(N(),1),Y=_(Ce(),1),Kt=new Set,st=0;function tr(e){return()=>{st+=1;let t=e();return t.then(()=>void(st-=1),()=>void(st-=1)),t}}var _i=()=>st,nr=!1,or=!1,lt=new Set;function Li(){nr=!0}function Hi(){or=!0;for(let e of[...lt])e();lt.clear()}var rr=()=>or||!nr;function Di(e){return rr()?(e(),()=>{}):(lt.add(e),()=>void lt.delete(e))}var Qo=!1;function Bt(){for(let e of[...Kt])e()}function Ni(){Qo||typeof window>"u"||(Qo=!0,window.addEventListener("online",Bt))}function qt(e){let t,n=!1,o=!1,r,i=0,a=new Set,d=()=>{i+=1;for(let p of[...a])p()},s=p=>(a.add(p),()=>void a.delete(p)),u=()=>i,f=()=>void m().catch(()=>{});function m(){if(n)return Promise.resolve(t);if(r)return r;let p=e().then(g=>(t=g,n=!0,o=!1,r=void 0,Kt.delete(f),d(),g),g=>{throw r=void 0,o=!0,Kt.add(f),Ni(),d(),g});return p.catch(()=>{}),r=p,p}return{load:m,prefetch:f,get current(){return t},get failed(){return o},part(p,g={}){let v=g.what??"This part";function k(h){(0,F.useSyncExternalStore)(s,u,u);let E=(0,F.useRef)(null),P=(0,F.useRef)(null),D=(0,F.useRef)(!1);return(0,F.useEffect)(()=>{o&&r===void 0&&f()},[]),n&&typeof document<"u"&&E.current!==null&&document.activeElement===E.current&&(D.current=!0),(0,F.useLayoutEffect)(()=>{if(!(!n||!D.current)){D.current=!1;for(let C=P.current?.nextElementSibling??null;C!==null;C=C.nextElementSibling){let G=C.matches(er)?C:C.querySelector(er);if(G instanceof HTMLElement){G.focus();return}}}}),n?(0,Y.jsxs)(Y.Fragment,{children:[D.current?(0,Y.jsx)("span",{ref:P,hidden:!0}):null,p(t,h)]}):g.quiet?null:(0,Y.jsx)(ji,{what:v,button:E,...g.as?{as:g.as}:{}})}let y=(0,F.lazy)(tr(()=>m().then(()=>({default:k}),()=>({default:k}))));function b(h){let[E]=(0,F.useState)(()=>n||o);return(0,F.createElement)(E?k:y,h)}return b}}}var er="button,a[href],input,select,textarea,[tabindex]:not([tabindex='-1'])";function ji({what:e,button:t,as:n="p"}){let r=typeof navigator<"u"&&navigator.onLine===!1?`${e} will load when you're back online.`:`${e} didn't load.`;return(0,Y.jsxs)(n,{"data-testid":"lazy-part-missing",style:{margin:0,fontSize:"0.875rem",color:"var(--graview-ink-muted)"},children:[(0,Y.jsx)("span",{role:"status",children:r})," ",(0,Y.jsx)("button",{ref:t,type:"button","data-testid":"lazy-part-retry",onClick:Bt,style:{font:"inherit",fontWeight:600,color:"var(--graview-ink)",background:"none",border:"1px solid var(--graview-edge)",borderRadius:6,padding:"2px 10px"},children:"Try again"})]})}var Se=_(N(),1);function Gi(){let{selection:e,setSelection:t}=oe();return(0,Se.useMemo)(()=>({selection:e,set:n=>t(n),clear:()=>t([]),toggle:n=>t(o=>o.includes(n)?o.filter(r=>r!==n):[...o,n]),isSelected:n=>e.includes(n)}),[e,t])}function Wi(){let{store:e}=oe(),t=ot();return(0,Se.useMemo)(()=>Fi(e),[e,t])}var ir=new WeakMap;function Fi(e){let t=ir.get(e);if(!t){let n={violations:null};e.subscribe(()=>{n.violations=null}),ir.set(e,n),t=n}return t.violations??=e.violations(),t.violations}function Ki(){let{view:e,setView:t}=oe();return(0,Se.useMemo)(()=>({view:e,url:te(e),focus:n=>t(o=>q(o,n)),show:n=>t(o=>Un(o,n)),toggle:n=>t(o=>Ue(o,n)),go:n=>t(n)}),[e,t])}var he={at:0,depth:0,listeners:new Set,tell(){for(let e of this.listeners)e()}};typeof window<"u"&&window.addEventListener("popstate",e=>{let t=e.state;he.at=typeof t?.graview=="number"?t.graview:0,he.at>he.depth&&(he.depth=he.at),he.tell()});var j=_(N(),1),zt={profile:{trigger:"profile-button",pane:"profile",opens:"press",focus:"into",drawn:["shell","embed"]},problems:{trigger:"standing",pane:"problems",opens:"press",focus:"into",drawn:["shell","embed"]},places:{trigger:"app-places-open",pane:"app-places",opens:"press",focus:"into",drawn:["embed"]},here:{trigger:"here-open",pane:"here-list",opens:"press",focus:"into",drawn:["shell","embed","pages"]},suggested:{trigger:"suggested-button",pane:"suggested",opens:"press",focus:"into",drawn:["shell","embed","pages"]},activity:{trigger:"activity-button",pane:"activity",opens:"press",focus:"into",drawn:["shell","embed","pages"]},find:{trigger:"find-box",pane:"find-strip",opens:"typing",focus:"stays",drawn:["shell"]},districts:{trigger:"beyond-more",pane:"beyond-list",opens:"press",focus:"into",drawn:["shell","embed"]},acts:{trigger:null,pane:"context-menu",opens:"context-menu",focus:"into",drawn:["shell","embed","pages"]},arrange:{trigger:"arrange-add",pane:"arrange-list",opens:"press",focus:"into",drawn:["pages"]},"studio-ask":{trigger:"studio-agent",pane:"studio-agent-panel",opens:"press",focus:"into",drawn:["studio"]}},Bi={position:"fixed",inset:"auto",margin:0,zIndex:jn("popover"),boxSizing:"border-box"},dt=6,we=8,qi=e=>typeof e.showPopover=="function";function ut(e){try{return e.matches(":popover-open")}catch{return!1}}function $i(e){if(typeof e=="function"){let o=e();return o?{left:o.x,right:o.x,top:o.y,bottom:o.y}:null}let t=e.current;if(!t||!t.isConnected)return null;let n=t.getBoundingClientRect();return{left:n.left,right:n.right,top:n.top,bottom:n.bottom}}function Ut(e,t,n={}){let o=$i(t);if(!o)return;let r={width:document.documentElement.clientWidth||innerWidth,height:innerHeight},i=e.dataset.graviewDesignedHeight??=e.style.maxHeight;e.style.maxHeight=i;let a=e.getBoundingClientRect(),d=r.height-o.bottom-dt-we,s=o.top-dt-we,u=a.height<=d||d>=s,f=Math.max(96,Math.floor(u?d:s)),m=Math.min(a.height,f);a.height>f&&(e.style.maxHeight=i?`min(${i}, ${f}px)`:`${f}px`);let p=a.width,g=n.align==="start"?o.left:o.right-p,v=typeof t=="function"?null:t.current?.closest("[data-graview-embed]")?.getBoundingClientRect();v&&p<=v.right-v.left&&(g<v.left?g=o.left+p<=v.right?o.left:v.left:g+p>v.right&&(g=o.right-p>=v.left?o.right-p:v.right-p));let k=p>=r.width-2*we?Math.max(0,(r.width-p)/2):Math.max(we,Math.min(g,r.width-we-p)),y=u?o.bottom+dt:Math.max(we,o.top-dt-m);e.style.left=`${Math.round(k)}px`,e.style.top=`${Math.round(y)}px`}function ar(e,t,n,o={}){let r=o.align??"end";(0,j.useLayoutEffect)(()=>{let i=e.current;if(!t||!i)return;if(qi(i)&&!ut(i))try{i.showPopover(),Ui()}catch{}let a=0,d=u=>{u?.target instanceof Node&&i.contains(u.target)||(cancelAnimationFrame(a),a=requestAnimationFrame(()=>Ut(i,n,{align:r})))};Ut(i,n,{align:r}),addEventListener("resize",d),addEventListener("scroll",d,!0);let s=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>d());return s?.observe(i),()=>{if(cancelAnimationFrame(a),removeEventListener("resize",d),removeEventListener("scroll",d,!0),s?.disconnect(),i.isConnected&&ut(i))try{i.hidePopover()}catch{}}},[t,e,r])}var Yt=new Set;function zi(e){return Yt.add(e),()=>Yt.delete(e)}function Ui(){for(let e of Yt)if(!(!e.isConnected||!ut(e)))try{e.hidePopover(),e.showPopover()}catch{}}var ve=null,Yi='button:not([disabled]), [href], input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex="-1"])';function Zi(e){for(let t of e.querySelectorAll(Yi))if(t.closest("[hidden]")===null&&getComputedStyle(t).visibility!=="hidden")return t;return e}var $t=()=>{let e=document.activeElement;return e===null||e===document.body};function Xi(e,t={}){let{at:n,returnTo:o,onOpenChange:r}=t,i=t.popover!==!1,[a,d]=(0,j.useState)(!1),s=t.open??a,u=(0,j.useRef)(null),f=(0,j.useRef)(null),m=(0,j.useCallback)(h=>{u.current=h},[]),p=(0,j.useCallback)(h=>{f.current=h},[]),g=`graview-popover-${(0,j.useId)().replace(/:/g,"")}`,v=(0,j.useRef)({onOpenChange:r,returnTo:o,controlled:t.open!==void 0});v.current={onOpenChange:r,returnTo:o,controlled:t.open!==void 0};let k=(0,j.useCallback)(h=>{v.current.controlled||d(h),v.current.onOpenChange?.(h)},[]),y=(0,j.useCallback)(()=>{(document.querySelector(`[aria-controls="${g}"]`)??u.current??v.current.returnTo?.()??null)?.focus({preventScroll:!0})},[g]),b=(0,j.useCallback)(h=>{let E=f.current,P=typeof document>"u"?null:document.activeElement,D=P===null||P===document.body||E!==null&&E.contains(P);k(!1),!(!h||!D)&&(y(),requestAnimationFrame(()=>{$t()&&y()}))},[k,y]);return ar(f,i&&s,n??u,t.align?{align:t.align}:{}),(0,j.useEffect)(()=>{if(!i||!s)return;let h={name:e,close:()=>b(!1)};if(ve&&ve.close!==h.close&&ve.close(),ve=h,zt[e].focus==="into"){let x=f.current;x&&!x.contains(document.activeElement)&&Zi(x).focus({preventScroll:!0})}let E=x=>{x.key==="Escape"&&b(!0)},P=x=>{let V=x.target;if(!(V instanceof Node))return;let O=f.current;if(O?.contains(V)||u.current?.contains(V))return;let W=V instanceof Element?V.closest('[role="dialog"], [role="alertdialog"]'):null;W&&!(O&&W.contains(O))||(b(!1),zt[e].focus==="into"&&requestAnimationFrame(()=>{($t()||O!==null&&O.contains(document.activeElement))&&y()}))},D=null,C=null,G=x=>{let V=x.target;if(!(V instanceof Element))return;let O=f.current,W=V.closest('[role="dialog"], [role="alertdialog"]');!W||O&&(O.contains(W)||W.contains(O))||(D=W,b(!1))};return document.addEventListener("keydown",E),document.addEventListener("pointerdown",P,!0),document.addEventListener("focusin",G),()=>{document.removeEventListener("keydown",E),document.removeEventListener("pointerdown",P,!0),document.removeEventListener("focusin",G);let x=D;x&&typeof MutationObserver<"u"&&(C?.disconnect(),C=new MutationObserver(()=>{x.isConnected||(C?.disconnect(),requestAnimationFrame(()=>{($t()||document.activeElement.closest("[hidden]")!==null)&&y()}))}),C.observe(document.body,{childList:!0,subtree:!0}),setTimeout(()=>C?.disconnect(),10*6e4)),ve?.close===h.close&&(ve=null)}},[i,s,e,b,y]),{open:s,setOpen:h=>h?k(!0):b(!0),toggle:()=>s?b(!0):k(!0),trigger:{ref:m,"aria-expanded":s,"aria-controls":g,"data-graview-popover-trigger":e},pane:{ref:p,id:g,popover:"manual",tabIndex:-1,"data-graview-popover":e,"data-graview-overlay":""}}}var be=_(N(),1);var sr=(0,be.createContext)(null);function Ji(){let e=(0,be.useContext)(sr),t=Ft(),n=(o,r,i)=>t?.setView(a=>ae(ae(pe(q(a,ne(o)),!1),"view",r),"filter",i?.filter??null));return(0,be.useMemo)(()=>e??{record:o=>{t&&(t.setView(r=>q(pe(r,!1),o)),t.setSelection([o]))},place:(o,r)=>{let i=t?.views.places().find(a=>a.as===o);i&&n(i.kind,i.as,r)},list:(o,r)=>n(o,null,r)},[e,t])}var xe=_(N(),1);var Qi=qt(Ke(()=>(__graviewPreload(import.meta.url,["./chunk.XWAMQPUM.js","./chunk.SDO3U72B.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.4HYJHGI4.js"))));function ea(e,t,n){let o,r=!1,i=()=>{let{hidden:d,removed:s}=t.current();o||r||d.length+s.length===0||(o=()=>{},Qi.load().then(u=>{r||(o=u.watchTidied(e,t,n))},String))};i();let a=t.onChange?.(i);return()=>{r=!0,a?.(),o?.()}}function ta(e,t){let[n,o]=(0,xe.useState)();return(0,xe.useEffect)(()=>t?ea(e,t,r=>o([e,r])):void 0,[e,t]),n?.[0]===e?n[1]:e}var lr=_(N(),1),na=(0,lr.createContext)(!1);var dr=_(N(),1),oa=(0,dr.createContext)(null);var ur=_(N(),1),Zt='button:not([disabled]), a[href], input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex="-1"])',Xt=e=>e instanceof HTMLElement&&(e.matches(Zt)||e.hasAttribute("tabindex")),Le=e=>typeof e.checkVisibility=="function"?e.checkVisibility():e.getClientRects().length>0;function ra(e,t){let n=s=>s.replace(/["\\]/g,"\\$&"),o=t.getAttribute("data-testid"),r=t.getAttribute("data-graview-pick"),i=t.getAttribute("aria-label"),a=o?`[data-testid="${n(o)}"]`:r?`[data-graview-pick="${n(r)}"]`:i?`${t.tagName.toLowerCase()}[aria-label="${n(i)}"]`:null;if(!a)return null;let d=e.querySelector(a);return d&&Xt(d)&&Le(d)?d:null}var ia=e=>e.isConnected&&Xt(e)&&!e.matches(":disabled")&&e instanceof HTMLElement&&Le(e);function cr(e,t){let n=t?ra(e,t):null;if(n)return n;let o=e.querySelector("[data-graview-view][tabindex]");if(o&&Le(o))return o;for(let r of e.querySelectorAll(Zt))if(Le(r))return r;return Xt(e)&&Le(e)?e:null}function aa(e){(0,ur.useEffect)(()=>{let t=e.current;if(!t||typeof MutationObserver>"u")return;let n=[],o=y=>{let b=y.target;if(b instanceof Element){n=[];for(let h=b;h&&h!==t.parentElement;h=h.parentElement)n.push(h)}},r=!1,i=!1,a=t.ownerDocument,d=()=>!i&&a.defaultView!==null,s=(y,b)=>void setTimeout(()=>d()&&b(),y),u=y=>void requestAnimationFrame(()=>d()&&y()),f=y=>{if(r=!1,i)return;let b=a.activeElement;if(!(!(b===null||b===a.body||b===a.documentElement)||n.length===0)){if(ia(n[0])){y&&n[0]instanceof HTMLElement&&n[0].focus({preventScroll:!0});return}for(let E of n.slice(1)){if(!E.isConnected)continue;let P=cr(E,n[0]);if(P){P.focus({preventScroll:!0}),n=[];return}}}},m=(y,b=Date.now()+2500)=>{s(100,()=>{f(y);let h=a.activeElement;(h===null||h===a.body||h===a.documentElement)&&n.length>0&&Date.now()<b&&m(y,b)})},p=()=>{r||n.length===0||(r=!0,s(60,()=>u(()=>{f(!1),m(!1)})))},g=y=>{if(!(y instanceof KeyboardEvent&&!["Enter"," ","Escape"].includes(y.key))){if(!(y instanceof KeyboardEvent)){let b=y.target instanceof Element?y.target.closest(Zt):null,h=a.activeElement,E=h===null||h===a.body||h===a.documentElement;if(b&&E&&t.contains(b)){n=[];for(let P=b;P&&P!==t.parentElement;P=P.parentElement)n.push(P);s(150,()=>u(()=>{f(!1),m(!1)}));return}}!(y instanceof KeyboardEvent)&&!(y.target instanceof Node&&n[0]?.contains(y.target))||s(150,()=>u(()=>{f(!0),m(!0)}))}},v=new MutationObserver(()=>{n.length>0&&!n[0].isConnected&&p()}),k=y=>{y.relatedTarget===null&&p()};return t.addEventListener("focusin",o),t.addEventListener("focusout",k),t.addEventListener("click",g),t.addEventListener("keydown",g),v.observe(t,{childList:!0,subtree:!0}),()=>{i=!0,t.removeEventListener("focusin",o),t.removeEventListener("focusout",k),t.removeEventListener("click",g),t.removeEventListener("keydown",g),v.disconnect()}},[e])}export{fe as a,te as b,$e as c,la as d,da as e,$n as f,qn as g,zn as h,St as i,q as j,Un as k,ae as l,pe as m,ze as n,Ve as o,Ue as p,Ze as q,wt as r,ye as s,fa as t,Pr as u,ne as v,Yn as w,se as x,Zn as y,Rr as z,pa as A,Xn as B,vt as C,Tr as D,Mr as E,Or as F,N as G,Ot as H,Zr as I,Jr as J,go as K,Qe as L,Qr as M,Ie as N,So as O,ei as P,It as Q,Ce as R,yi as S,mi as T,gi as U,Ko as V,bi as W,Ei as X,ds as Y,Ri as Z,oe as _,Ft as $,ot as aa,Ti as ba,Mi as ca,Oi as da,Wt as ea,sr as fa,Ji as ga,Vi as ha,zo as ia,Uo as ja,Yo as ka,Zo as la,Xo as ma,Jo as na,Ii as oa,Ci as pa,tr as qa,_i as ra,Li as sa,Hi as ta,rr as ua,Di as va,qt as wa,ta as xa,na as ya,oa as za,Gi as Aa,Wi as Ba,Ki as Ca,he as Da,aa as Ea,Bi as Fa,ut as Ga,ar as Ha,zi as Ia,Xi as Ja};
2
- /*! Bundled license information:
3
-
4
- react/cjs/react.production.js:
5
- (**
6
- * @license React
7
- * react.production.js
8
- *
9
- * Copyright (c) Meta Platforms, Inc. and affiliates.
10
- *
11
- * This source code is licensed under the MIT license found in the
12
- * LICENSE file in the root directory of this source tree.
13
- *)
14
-
15
- react/cjs/react-jsx-runtime.production.js:
16
- (**
17
- * @license React
18
- * react-jsx-runtime.production.js
19
- *
20
- * Copyright (c) Meta Platforms, Inc. and affiliates.
21
- *
22
- * This source code is licensed under the MIT license found in the
23
- * LICENSE file in the root directory of this source tree.
24
- *)
25
- */
@@ -1 +0,0 @@
1
- import{b as A,c as m,d as v}from"./chunk.55D33E5A.js";import"./chunk.2JJYGYT2.js";import"./chunk.NMIXBH37.js";import{b as g,c as b,d as S}from"./chunk.GVY5UQTJ.js";import"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import"./chunk.AJZBJBMO.js";var N=new Set(["input","select","textarea"]),h=r=>r.namespaceURI==="http://www.w3.org/1999/xhtml"&&N.has(r.localName),x=r=>r.localName==="select"||r.type==="checkbox"||r.type==="radio",w=r=>r.type==="checkbox"||r.type==="radio"?!r.checked:r.localName!=="select"&&r.value==="";function y(r){return r.type==="checkbox"||r.type==="radio"?`checked:${r.checked}`:r.localName==="select"&&r.multiple?`selected:${[...r.selectedOptions].map(a=>a.value).join("\0")}`:`value:${r.value}`}function I(r=a=>a.isTrusted){let a=new WeakMap,c=new WeakSet,o=new WeakMap,i={heard(e,t){if(!(!h(t)||!r(e))&&(e.type==="input"||e.type==="change"&&x(t))&&((x(t)||w(t))&&c.delete(t),w(t)&&o.delete(t),a.set(t,y(t)),t.type==="radio"&&t.name)){let d=t.getRootNode();for(let u of d.querySelectorAll?.('input[type="radio"]')??[])u.name===t.name&&a.set(u,y(u))}},filled(e){a.delete(e),o.delete(e),h(e)&&!w(e)?c.add(e):c.delete(e)},press(e,t,d){if(!r(e))return;let u=t.closest("[data-act]");if(!u||!b(u))return;let l=e.type==="keydown"?e.key:void 0;if(!(e.type!=="click"&&!((l==="Enter"||l===" ")&&t===u&&!g(u))))return i.collect(u,d)},collect(e,t){if(!e.hasAttribute("data-act")||!t.contains(e))return;let d=e.closest("[data-record]"),u=e.closest("fieldset, [role='group']")??t,l=[];for(let n of u.querySelectorAll("input[name], select[name], textarea[name]")){let s=n,f=!c.has(s)&&a.get(s)===y(s);if(s.type==="radio"){if(!s.checked)continue;l.push({name:s.name,value:s.value,typed:f,empty:!1,chosen:!0});continue}if(s.localName==="select"){l.push({name:s.name,value:s.value,typed:f,empty:s.value===""&&!f,chosen:!0});continue}if(s.type==="checkbox"){l.push({name:s.name,value:s.checked,typed:f,empty:!s.checked&&!c.has(s)&&!f});continue}let P=(s.type==="number"||s.type==="range")&&s.value!==""&&Number.isFinite(s.valueAsNumber)?s.valueAsNumber:s.value,E=f?o.get(s):void 0;l.push({name:s.name,value:P,typed:f,empty:s.value===""&&!f,...E?{from:E}:{}})}return{as:e.getAttribute("data-act")??"",...d&&t.contains(d)?{record:d.getAttribute("data-record")}:{},fields:l}},prefilled(e,t){c.delete(e),o.set(e,t),a.set(e,y(e))}};return i}var k=new WeakMap;function H(r){for(let a of r.querySelectorAll("[data-act], [data-graview-press]")){let c=b(a)&&!g(a)&&!h(a),o=k.get(a);if(c&&!o){let i=!a.hasAttribute("tabindex"),e=S(a);i&&a.setAttribute("tabindex","0"),e&&a.setAttribute("role","button"),a.setAttribute("data-graview-press",""),k.set(a,{tab:i,role:e})}else!c&&o&&(o.tab&&a.removeAttribute("tabindex"),o.role&&a.getAttribute("role")==="button"&&a.removeAttribute("role"),a.removeAttribute("data-graview-press"),k.delete(a))}}var T=1e3;function R(r){let a=r.getAttribute("data-debounce")?.trim(),c=a?Number(a):Number.NaN;return Number.isFinite(c)?Math.min(1e4,Math.max(250,Math.round(c))):T}function $(r){let a=r.trusted??(e=>e.isTrusted),c=r.timers??{set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)},o=new Map,i=(e,t)=>{let d=o.get(e);d&&c.clear(d.handle),o.delete(e);let u=r.reader.collect(e,t);u&&r.save(u,e)};return{heard(e,t,d){if(!h(t)||!a(e)||!t.hasAttribute("data-act"))return;let u=t.getAttribute("data-save");if(e.type==="input"&&u==="input"){let l=o.get(t);l&&c.clear(l.handle),o.set(t,{root:d,handle:c.set(()=>i(t,d),R(t))})}else e.type==="change"&&(u==="change"||u==="input"&&o.has(t))&&i(t,d)},flush(){for(let[e,{root:t}]of[...o])i(e,t)},get waiting(){return o.size}}}var O=new Set(["text","search","email","url","tel","number"]);function F(r,a,c,o){for(let i of r.querySelectorAll("input[data-prefill], textarea[data-prefill]")){let e=i;if(c.has(e))continue;let t=e.getAttribute("data-prefill")??"";if(t===""||e.getAttribute("name")!==t||e.localName==="input"&&!O.has(e.type))continue;if(e.value!==""){c.add(e);continue}let u=[...(e.closest("fieldset, [role='group']")??r).querySelectorAll("[data-act]")],l=e.closest("[data-record]"),n=new Set(u.map(p=>p.closest("[data-record]")?.getAttribute("data-record")).filter(p=>typeof p=="string")),s=l&&r.contains(l)?l.getAttribute("data-record"):n.size===1?[...n][0]:void 0;if(!s)continue;let f=o({record:s,field:t,acts:u.map(p=>p.getAttribute("data-act")??"")});if(f!==void 0){if(e.value=f,c.add(e),e.value!==f){e.value="";continue}a.prefilled(e,{record:s,field:t,value:f})}}}function W(r,a,c,o){let i=v(a,o.as);if(!i)return m("undeclared",`This view may not ask for \u201C${o.as}\u201D: its manifest does not name it.`);let e=r.allMutations().find(n=>n.name===i.act);if(!e)return m("unknown-act","There is no act by that name here.");let t={};if(o.record!==void 0){let n=i.record??e.subject?.arg;if(!n)return m("unbound",`\u201C${o.as}\u201D is not done to a record.`);if(!c.has(o.record))return m("unbound","That press is bound to a record this view was not shown.");t[n]=o.record}for(let[n,s]of Object.entries(i.constants??{})){if(n in t)return m("malformed",`\u201C${n}\u201D is both the bound record and a constant.`);t[n]=s}let d=e.input?.shape??{},u=new Set(Object.keys(d)),l=new Set;for(let n of o.fields)if(!(!u.has(n.name)||n.name in t)){if(l.has(n.name))return m("malformed",`Two fields here are called \u201C${n.name}\u201D.`);if(l.add(n.name),n.typed&&n.chosen){let s=A(d[n.name])?.find(f=>String(f)===String(n.value));if(s!==void 0)t[n.name]=s;else if(typeof n.value=="string"&&c.has(n.value))t[n.name]=n.value;else return m("untyped",`\u201C${n.name}\u201D was a choice among the view's own words, not one this app declares, so it was not sent.`)}else{if(n.typed&&n.from&&!(o.record===n.from.record&&n.name===n.from.field&&M(r,i,n.from.record,n.from.field)))return m("untyped",`\u201C${n.name}\u201D was filled in from a record for an act that writes it back there, not for this one, so it was not sent.`);if(n.typed&&n.from&&String(n.value)===n.from.value)t[n.name]=r.graph.getNode(n.from.record)?.[n.name]??n.value;else if(n.typed)t[n.name]=n.value;else if(!n.empty)return m("untyped",`\u201C${n.name}\u201D was filled in by the view, not typed by you, so it was not sent.`)}}return{ok:!0,name:i.act,args:t}}function M(r,a,c,o){let i=r.allMutations().find(u=>u.name===a.act),e=i?.subject;if(!i||!e||(a.record??e.arg)!==e.arg||o===e.arg||Object.hasOwn(a.constants??{},o)||!Object.hasOwn(i.input.shape??{},o)||Object.keys(i.writesOther??{}).length>0)return!1;let t=r.graph.getNode(c)?.kind,d=t===void 0?void 0:r.schema.tryDefinition(t);return!d||e.kinds!=="*"&&!e.kinds.includes(t)||!Object.hasOwn(d.fields.shape??{},o)?!1:i.writes?.includes(o)??!1}function q(r,a,c,o,i){if(!o.has(i.record))return;let e=r.seenBy(a).graph.getNode(i.record);if(!e||!i.acts.some(u=>{let l=v(c,u);if(!l||!M(r,l,i.record,i.field))return!1;let n=r.allMutations().find(s=>s.name===l.act).subject;return r.permits({name:l.act,args:{[n.arg]:i.record}},a).ok}))return;let d=e[i.field];return typeof d=="string"?d:typeof d=="number"&&Number.isFinite(d)?String(d):void 0}export{T as SAVE_DEBOUNCE_MS,I as createPressReader,$ as createSaver,F as fillPrefills,W as judgePress,H as markPresses,q as prefillOf,R as saveDebounceOf,M as writesBack};