graview 0.1.30 → 0.1.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/dist/preview/chunk.2NIOHEMX.js +1 -0
  2. package/dist/preview/{chunk.XRJBLH4N.js → chunk.3AGY4QVS.js} +1 -1
  3. package/dist/preview/chunk.3HXN4BOY.js +1 -0
  4. package/dist/preview/{chunk.2CIBWZJG.js → chunk.3K6YSVHC.js} +1 -1
  5. package/dist/preview/{chunk.FWCOJDOD.js → chunk.3TVXGJTU.js} +1 -1
  6. package/dist/preview/{chunk.NDADLJE6.js → chunk.3TY5NFLY.js} +1 -1
  7. package/dist/preview/{chunk.UWGWXFWZ.js → chunk.47STJVRV.js} +1 -1
  8. package/dist/preview/{chunk.34ZMMURV.js → chunk.4HRAQNJO.js} +6 -6
  9. package/dist/preview/{chunk.QTMWHE5O.js → chunk.4HZ7QTXZ.js} +1 -1
  10. package/dist/preview/{chunk.3JGGBLRB.js → chunk.4MERAWS2.js} +1 -1
  11. package/dist/preview/chunk.52W7WYME.js +1 -0
  12. package/dist/preview/chunk.5A4AOFOA.js +1 -0
  13. package/dist/preview/chunk.5H4VXLZF.js +88 -0
  14. package/dist/preview/{chunk.XS7YFNDU.js → chunk.5T5XGILP.js} +1 -1
  15. package/dist/preview/chunk.5TVB6BUY.js +1 -0
  16. package/dist/preview/chunk.5UL7YDUD.js +1 -0
  17. package/dist/preview/chunk.63GXY2ME.js +1 -0
  18. package/dist/preview/chunk.6QWV5MVH.js +25 -0
  19. package/dist/preview/{chunk.PAVR5TK5.js → chunk.6UGEYZAC.js} +1 -1
  20. package/dist/preview/chunk.6YCBYL2Y.js +2 -0
  21. package/dist/preview/{chunk.ZYKAS4BT.js → chunk.7GKUVQVF.js} +1 -1
  22. package/dist/preview/{chunk.T3VPD7JQ.js → chunk.7T7NZZTC.js} +1 -1
  23. package/dist/preview/chunk.AKFKM4SW.js +3 -0
  24. package/dist/preview/chunk.AOSMJKLH.js +1 -0
  25. package/dist/preview/{chunk.D3IECJ2S.js → chunk.ASCLIM2P.js} +1 -1
  26. package/dist/preview/chunk.B2GLDIAS.js +1 -0
  27. package/dist/preview/chunk.BNV77BQZ.js +4 -0
  28. package/dist/preview/chunk.BOO6WVM4.js +117 -0
  29. package/dist/preview/chunk.BQ3JHEHV.js +1 -0
  30. package/dist/preview/chunk.CAVBSL27.js +1 -0
  31. package/dist/preview/{chunk.YLQB3KBA.js → chunk.CDP2XL66.js} +1 -1
  32. package/dist/preview/chunk.CIPS2OGR.js +1 -0
  33. package/dist/preview/chunk.CJJLJ3KW.js +2 -0
  34. package/dist/preview/chunk.CN3UEF5N.js +90 -0
  35. package/dist/preview/{chunk.6XMEU2Q2.js → chunk.COQKECUH.js} +1 -1
  36. package/dist/preview/{chunk.QTA4ROAK.js → chunk.CWHRDBOF.js} +1 -1
  37. package/dist/preview/chunk.CX3KL2C5.js +1 -0
  38. package/dist/preview/{chunk.AK3IHFCF.js → chunk.D75KC3LL.js} +1 -1
  39. package/dist/preview/chunk.DAZ2VSRD.js +1 -0
  40. package/dist/preview/{chunk.RIEHYQLK.js → chunk.DHIUSUCL.js} +50 -24
  41. package/dist/preview/{chunk.3ADPAGPY.js → chunk.DYSPCGXX.js} +1 -1
  42. package/dist/preview/chunk.E2YEOMPH.js +1 -0
  43. package/dist/preview/chunk.EBGAYL32.js +1 -0
  44. package/dist/preview/chunk.EF3XNU4O.js +1 -0
  45. package/dist/preview/chunk.EJPI3ST6.js +1 -0
  46. package/dist/preview/chunk.EKPRNDUV.js +1 -0
  47. package/dist/preview/chunk.ERIT3R6N.js +1 -0
  48. package/dist/preview/chunk.EYTBDMTW.js +1 -0
  49. package/dist/preview/chunk.F6EH7HI2.js +1 -0
  50. package/dist/preview/{chunk.3URFMWXZ.js → chunk.F6ZK7RMB.js} +2 -2
  51. package/dist/preview/chunk.FSTCX2AI.js +1 -0
  52. package/dist/preview/{chunk.HHPGWJDO.js → chunk.FWTIUYXH.js} +1 -1
  53. package/dist/preview/{chunk.6T2Q6NLO.js → chunk.G5NZVPJU.js} +1 -1
  54. package/dist/preview/{chunk.VG56IUIQ.js → chunk.GO4XBWJO.js} +1 -1
  55. package/dist/preview/chunk.GV2CQVKV.js +1 -0
  56. package/dist/preview/chunk.GYICGZMG.js +3 -0
  57. package/dist/preview/chunk.H7BST3XO.js +1 -0
  58. package/dist/preview/chunk.H7EPE74C.js +1 -0
  59. package/dist/preview/{chunk.26CZTUY4.js → chunk.HAIG6NVX.js} +1 -1
  60. package/dist/preview/{chunk.V7BDAGDE.js → chunk.HLTRQU4Y.js} +1 -1
  61. package/dist/preview/{chunk.VS7K3SCD.js → chunk.I6FPNX43.js} +1 -1
  62. package/dist/preview/chunk.IDVAR5HM.js +1 -0
  63. package/dist/preview/chunk.J25KOSNW.js +1 -0
  64. package/dist/preview/chunk.JDUJDAGA.js +1 -0
  65. package/dist/preview/{chunk.X37L5TN5.js → chunk.JFAOHHJJ.js} +1 -1
  66. package/dist/preview/chunk.JOOQUWLT.js +341 -0
  67. package/dist/preview/{chunk.4SJUTBDV.js → chunk.JQU5GEU3.js} +1 -1
  68. package/dist/preview/chunk.K5ME5GCG.js +1 -0
  69. package/dist/preview/chunk.K7PMDSOL.js +1 -0
  70. package/dist/preview/chunk.KSES5U5B.js +1 -0
  71. package/dist/preview/{chunk.DT7LHWU2.js → chunk.LLLZEGRK.js} +1 -1
  72. package/dist/preview/chunk.LR3VDXPI.js +1 -0
  73. package/dist/preview/{chunk.WYTIOLPP.js → chunk.LXBOVRFI.js} +1 -1
  74. package/dist/preview/{chunk.42YX6NOY.js → chunk.MAF7C3VM.js} +1 -1
  75. package/dist/preview/chunk.MNP4JI33.js +5 -0
  76. package/dist/preview/{chunk.O2LK2AO7.js → chunk.MWGGV7DE.js} +1 -1
  77. package/dist/preview/chunk.N6OX4NEQ.js +1 -0
  78. package/dist/preview/chunk.NM6MZYFN.js +47 -0
  79. package/dist/preview/chunk.NRAYZY3X.js +1 -0
  80. package/dist/preview/chunk.NTF7FVB2.js +1 -0
  81. package/dist/preview/{chunk.DZRTOURR.js → chunk.OC6IWRQ3.js} +1 -1
  82. package/dist/preview/chunk.OF34OZ4V.js +1 -0
  83. package/dist/preview/chunk.OJGHDWI6.js +1 -0
  84. package/dist/preview/chunk.OKRNJXTV.js +1 -0
  85. package/dist/preview/chunk.PBSMLINK.js +1 -0
  86. package/dist/preview/chunk.PHKSMUIA.js +1 -0
  87. package/dist/preview/{chunk.JN7DIFR3.js → chunk.PIP6Z563.js} +1 -1
  88. package/dist/preview/chunk.QGTSHKJL.js +1 -0
  89. package/dist/preview/chunk.QVVJRSRM.js +1 -0
  90. package/dist/preview/{chunk.L6OMEYL6.js → chunk.QYZNAUIR.js} +1 -1
  91. package/dist/preview/chunk.R6K6GF5R.js +1 -0
  92. package/dist/preview/{chunk.JTNWD2CN.js → chunk.RCKTBOY2.js} +1 -1
  93. package/dist/preview/{chunk.QNGWEV47.js → chunk.RIJUCHP4.js} +1 -1
  94. package/dist/preview/chunk.SHTJZ6UX.js +1 -0
  95. package/dist/preview/{chunk.PKK6FRZR.js → chunk.SYAEBGDC.js} +1 -1
  96. package/dist/preview/chunk.T5VG5A6V.js +1 -0
  97. package/dist/preview/{chunk.ERXSYPYL.js → chunk.TAQ764IQ.js} +1 -1
  98. package/dist/preview/chunk.TCNBCTWO.js +1 -0
  99. package/dist/preview/{chunk.HHI65WFZ.js → chunk.UATVTXZY.js} +1 -1
  100. package/dist/preview/{chunk.XSTXV6FP.js → chunk.UBFNZMUX.js} +2 -2
  101. package/dist/preview/{chunk.WAFDCOOG.js → chunk.UGFJKSHU.js} +1 -1
  102. package/dist/preview/chunk.UHUGOTUU.js +19 -0
  103. package/dist/preview/chunk.ULRW47RP.js +1 -0
  104. package/dist/preview/chunk.UNL2HIF2.js +1 -0
  105. package/dist/preview/chunk.UZGRRDHD.js +1 -0
  106. package/dist/preview/{chunk.BPWNWE7N.js → chunk.VG3O4LWB.js} +1 -1
  107. package/dist/preview/chunk.WAZ7OGBD.js +1 -0
  108. package/dist/preview/{chunk.3JNMSOFG.js → chunk.XANVHJQ4.js} +1 -1
  109. package/dist/preview/chunk.XKABS745.js +1 -0
  110. package/dist/preview/chunk.XMC7YDWT.js +1 -0
  111. package/dist/preview/chunk.XNJEFUF7.js +3 -0
  112. package/dist/preview/chunk.Y6ZNFQK3.js +6 -0
  113. package/dist/preview/{chunk.J2ITFGN3.js → chunk.YIR7PPF3.js} +1 -1
  114. package/dist/preview/index.html +51 -0
  115. package/dist/preview/page.js +6 -6
  116. package/package.json +6 -6
  117. package/dist/preview/chunk.2EXGG6BB.js +0 -1
  118. package/dist/preview/chunk.2NBYNZRD.js +0 -1
  119. package/dist/preview/chunk.2XAONC66.js +0 -1
  120. package/dist/preview/chunk.3R4W2P5X.js +0 -1
  121. package/dist/preview/chunk.3SKKIHU3.js +0 -4
  122. package/dist/preview/chunk.3VL5WECB.js +0 -1
  123. package/dist/preview/chunk.4ALKPNXM.js +0 -1
  124. package/dist/preview/chunk.4HP7UWA2.js +0 -1
  125. package/dist/preview/chunk.5U5J3ISK.js +0 -1
  126. package/dist/preview/chunk.6V2RG5JG.js +0 -5
  127. package/dist/preview/chunk.7BWT5L2L.js +0 -1
  128. package/dist/preview/chunk.C5CYZNSJ.js +0 -1
  129. package/dist/preview/chunk.CM6LOIQE.js +0 -88
  130. package/dist/preview/chunk.FDELO7NY.js +0 -116
  131. package/dist/preview/chunk.FGVKJWNS.js +0 -6
  132. package/dist/preview/chunk.GFF2FB2J.js +0 -25
  133. package/dist/preview/chunk.GLBHQFJ2.js +0 -1
  134. package/dist/preview/chunk.HSCTWAUV.js +0 -1
  135. package/dist/preview/chunk.INZUEWC5.js +0 -1
  136. package/dist/preview/chunk.JH6MU6TX.js +0 -2
  137. package/dist/preview/chunk.JISMMIMX.js +0 -1
  138. package/dist/preview/chunk.JPHNKWTY.js +0 -1
  139. package/dist/preview/chunk.K75FUIZI.js +0 -1
  140. package/dist/preview/chunk.K776HO42.js +0 -2
  141. package/dist/preview/chunk.KN3ULTGF.js +0 -1
  142. package/dist/preview/chunk.KOB6N3SL.js +0 -1
  143. package/dist/preview/chunk.KQT7WAQE.js +0 -1
  144. package/dist/preview/chunk.L4DECHXR.js +0 -327
  145. package/dist/preview/chunk.LQ7V6KEE.js +0 -1
  146. package/dist/preview/chunk.MD74YVRN.js +0 -3
  147. package/dist/preview/chunk.MGNP4LAM.js +0 -1
  148. package/dist/preview/chunk.NCTOBUCT.js +0 -1
  149. package/dist/preview/chunk.NO52VON3.js +0 -1
  150. package/dist/preview/chunk.OAF7TUMI.js +0 -1
  151. package/dist/preview/chunk.OQ4KFN6W.js +0 -1
  152. package/dist/preview/chunk.OQDETV4X.js +0 -1
  153. package/dist/preview/chunk.OXQMNIRO.js +0 -1
  154. package/dist/preview/chunk.OZNW5W4Z.js +0 -1
  155. package/dist/preview/chunk.QIAKO27D.js +0 -1
  156. package/dist/preview/chunk.R26DREVU.js +0 -1
  157. package/dist/preview/chunk.RI3PYG5T.js +0 -19
  158. package/dist/preview/chunk.RRVIXV7W.js +0 -1
  159. package/dist/preview/chunk.RYT5U3QM.js +0 -1
  160. package/dist/preview/chunk.SE5SKFQH.js +0 -1
  161. package/dist/preview/chunk.SOBC3CTN.js +0 -47
  162. package/dist/preview/chunk.SOD3PBJM.js +0 -1
  163. package/dist/preview/chunk.UDSEJKCY.js +0 -1
  164. package/dist/preview/chunk.UZWWDAGM.js +0 -14
  165. package/dist/preview/chunk.V5ZYUVMH.js +0 -1
  166. package/dist/preview/chunk.VOAZBHCG.js +0 -1
  167. package/dist/preview/chunk.VSZQXB4Q.js +0 -3
  168. package/dist/preview/chunk.W3S6UXNA.js +0 -1
  169. package/dist/preview/chunk.Y4UXEL6Y.js +0 -1
  170. package/dist/preview/chunk.YJUB4OD7.js +0 -1
  171. package/dist/preview/chunk.YNQDVGZM.js +0 -1
  172. package/dist/preview/chunk.YV2LJFGS.js +0 -1
  173. package/dist/preview/chunk.Z2YUYZT4.js +0 -1
  174. /package/dist/preview/{chunk.EYZ7MHBZ.js → chunk.GZHZLJBF.js} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graview",
3
- "version": "0.1.30",
3
+ "version": "0.1.32",
4
4
  "type": "module",
5
5
  "description": "The Graview command line: start a product, check its declaration, write its agent docs, serve its store, preview a document with no product and photograph its places, say whether a product is on one release, host it for an agent over MCP, apply an act to it, sync its seed, install the authoring skills. The tool; @graview/* is the framework.",
6
6
  "keywords": [
@@ -29,11 +29,11 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@graview/ship": "0.1.30",
33
- "@graview/skills": "0.1.30",
34
- "@graview/tools": "0.1.30",
35
- "@graview/core": "0.1.30",
36
- "@graview/guest": "0.1.30"
32
+ "@graview/core": "0.1.32",
33
+ "@graview/guest": "0.1.32",
34
+ "@graview/ship": "0.1.32",
35
+ "@graview/skills": "0.1.32",
36
+ "@graview/tools": "0.1.32"
37
37
  },
38
38
  "engines": {
39
39
  "node": ">=22"
@@ -1 +0,0 @@
1
- import"./chunk.WVUJXDXZ.js";import{b as v,c as ae}from"./chunk.OZNW5W4Z.js";import"./chunk.NDADLJE6.js";import"./chunk.AK3IHFCF.js";import"./chunk.HHPGWJDO.js";import"./chunk.42YX6NOY.js";import"./chunk.EYZ7MHBZ.js";import{o as re}from"./chunk.KQT7WAQE.js";import"./chunk.PAVR5TK5.js";import"./chunk.OQDETV4X.js";import"./chunk.3VL5WECB.js";import"./chunk.JH6MU6TX.js";import"./chunk.WAFDCOOG.js";import"./chunk.L4DECHXR.js";import{G as Fe,M as _,O as Z,R as ee,Z as te,aa as ne}from"./chunk.GFF2FB2J.js";import{ba as Q,cc as X,fa as Y,ga as k,ha as j}from"./chunk.6V2RG5JG.js";import{b as z}from"./chunk.AJZBJBMO.js";var g=z(Fe(),1);async function ie(e,n){let a=await createImageBitmap(e);try{let i=Math.min(1,n/Math.max(a.width,a.height)),o=document.createElement("canvas");o.width=Math.max(1,Math.round(a.width*i)),o.height=Math.max(1,Math.round(a.height*i));let s=o.getContext("2d");if(s===null)throw new Error("This browser will not give us a canvas to resize with.");return s.drawImage(a,0,0,o.width,o.height),o}finally{a.close()}}var t=z(ee(),1),$e=2048,xe=.85;function H(e){return e<1e3?`${e} bytes`:e<1e6?`${Math.round(e/1e3)} KB`:`${(e/1e6).toFixed(e<1e7?1:0)} MB`}function U(e){if(e.type==="application/pdf")return"PDF";let n=/\.([a-z0-9]{2,5})$/i.exec(e.name??"")?.[1];return n?n.toUpperCase():(e.type.split("/")[1]??e.type).replace(/^x-|^vnd\./,"").split(/[.+-]/)[0].toUpperCase()}function ce(e){let n=[...new Set(e.map(a=>a==="image/*"?"pictures":a==="*/*"||a==="*"?"any file":`${U({type:a})} files`))];return n.length<=1?n[0]??"no files":`${n.slice(0,-1).join(", ")} and ${n[n.length-1]}`}function ge(e,n){if(e.length===0)return!0;let a=`${n.split("/")[0]}/*`;return e.some(i=>i==="*"||i==="*/*"||i===n||i===a)}var le=/^image\/hei[cf]$|\.hei[cf]$/i,oe=e=>le.test(e.type)||le.test(e.name);async function Se(e,n,a){let i=e.name||(a.camera?"photo.jpg":"file"),o=e.type||(oe({type:"",name:i})?"image/heic":"application/octet-stream"),s=oe({type:o,name:i}),d=o.startsWith("image/")||s;if(a.image&&!d)return{refused:`\u201C${i}\u201D isn\u2019t a picture.`};if(s||d&&/^image\/(jpeg|webp)$/.test(o)&&(a.camera||e.size>n.maxBytes||e.size>15e5))try{let l=await ie(e,$e),f=await new Promise(y=>l.toBlob(y,"image/jpeg",xe));if(f)return se({blob:f,name:s?i.replace(/\.hei[cf]$/i,"")+".jpg":i,type:"image/jpeg",width:l.width,height:l.height},n)}catch{if(s&&!ge(n.kinds,o))return{refused:`\u201C${i}\u201D is a HEIC photo, which this browser can\u2019t turn into a JPEG and this host doesn\u2019t take. Save it as a JPEG and try again.`}}let c={};if(d&&!s)try{let l=await createImageBitmap(e);c={width:l.width,height:l.height},l.close()}catch{}return se({blob:e,name:i,type:o,...c},n)}function se(e,n){return ge(n.kinds,e.type)?e.blob.size>n.maxBytes?{refused:`\u201C${e.name}\u201D is ${H(e.blob.size)}; this host takes files up to ${H(n.maxBytes)}.`}:e:{refused:`\u201C${e.name}\u201D is a ${U(e)} file; this host takes ${ce(n.kinds)}.`}}async function Ce(e,n,a){let i;try{i=await n.upload(e.blob,e.name)}catch(s){let d=s instanceof Error&&s.message.trim()?s.message.trim():"the host refused it";return{refused:`\u201C${e.name}\u201D wasn\u2019t kept: ${d}`}}return Y(i)?a&&!k(i)?{refused:`\u201C${e.name}\u201D isn\u2019t a picture.`}:{...i,...i.width===void 0&&e.width?{width:e.width}:{},...i.height===void 0&&e.height?{height:e.height}:{}}:{refused:`The host\u2019s answer for \u201C${e.name}\u201D isn\u2019t a file a record can keep.`}}var F="var(--graview-radius, 8px)",C={color:"var(--graview-ink-muted)",fontSize:"0.8125rem"};function pe(e){let n=_(),a=Z()?.past!=null,[i,o]=(0,g.useState)(!1);return[n?.kept?.(e.href)===!1||a&&i,()=>o(!0)]}function he({file:e,style:n}){return(0,t.jsx)("span",{role:"img","aria-label":`${v(e)}, removed later`,"data-graview-removed-later":e.href,style:{display:"grid",placeItems:"center",textAlign:"center",padding:4,boxSizing:"border-box",fontSize:"0.6875rem",lineHeight:1.2,color:"var(--graview-ink-muted)",border:"1px dashed var(--graview-edge-bright)",borderRadius:F,...n},children:"removed later"})}function O({file:e,size:n=56,style:a}){let[i,o]=pe(e);return i?(0,t.jsx)(he,{file:e,style:{width:n,height:n,flex:"none",...a}}):(0,t.jsx)("img",{onError:o,src:e.href,alt:v(e),width:n,height:n,loading:"lazy",decoding:"async","data-graview-thumb":e.href,style:{width:n,height:n,objectFit:"cover",borderRadius:F,display:"block",flex:"none",background:"var(--graview-edge)",...a}})}function Ee({file:e,onOpen:n}){let[a,i]=pe(e);return a?(0,t.jsx)(he,{file:e,style:{width:"100%",aspectRatio:"1"}}):(0,t.jsx)("button",{type:"button","aria-label":`Open ${v(e)} full size`,onClick:o=>n(o.currentTarget),style:{padding:0,border:0,background:"none",cursor:"zoom-in",display:"block",width:"100%",borderRadius:F},children:(0,t.jsx)("img",{src:e.href,alt:v(e),loading:"lazy",decoding:"async",onError:i,style:{width:"100%",aspectRatio:"1",objectFit:"cover",borderRadius:F,display:"block",background:"var(--graview-edge)"}})})}function N({files:e,label:n}){let a=e.filter(k),i=e.filter(l=>!k(l)),[o,s]=(0,g.useState)(null),d=(0,g.useRef)(null),m=(0,g.useRef)(null);(0,g.useEffect)(()=>{let l=d.current;o!==null&&l&&!l.open&&l.showModal?.()},[o]);let c=o===null?void 0:a[o];return(0,t.jsxs)("div",{style:{display:"grid",gap:10,minWidth:0},children:[a.length>0?(0,t.jsx)("ul",{"data-graview-gallery":"","aria-label":n,style:{listStyle:"none",margin:0,padding:0,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(96px, 1fr))",gap:8},children:a.map((l,f)=>(0,t.jsx)("li",{style:{minWidth:0},children:(0,t.jsx)(Ee,{file:l,onOpen:y=>{m.current=y,s(f)}})},l.href))}):null,i.length>0?(0,t.jsx)("ul",{"data-graview-documents":"",style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:10},children:i.map(l=>(0,t.jsxs)("li",{"data-graview-document":l.type,style:{display:"grid",gap:6,minWidth:0},children:[l.type==="application/pdf"?(0,t.jsx)("object",{data:l.href,type:"application/pdf","aria-label":v(l),style:{width:"100%",height:420,border:"1px solid var(--graview-edge)",borderRadius:F},children:(0,t.jsxs)("p",{style:{margin:0,padding:12},children:["This browser shows no PDF here: ",(0,t.jsxs)("a",{href:l.href,download:l.name,children:["download ",l.name]}),"."]})}):null,(0,t.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",gap:"2px 10px",alignItems:"baseline",minWidth:0,overflowWrap:"anywhere"},children:[(0,t.jsx)("a",{href:l.href,download:l.name,...l.type==="application/pdf"?{target:"_blank",rel:"noopener"}:{},children:l.name}),(0,t.jsxs)("span",{style:C,children:[U(l)," \xB7 ",H(l.bytes)]})]}),l.caption?(0,t.jsx)("span",{style:C,children:l.caption}):null]},l.href))}):null,c?(0,t.jsx)("dialog",{ref:d,"data-graview-full":c.href,"aria-label":v(c),onClose:()=>{s(null),m.current?.focus()},onClick:l=>{l.target===l.currentTarget&&l.currentTarget.close()},style:{padding:0,border:0,borderRadius:F,maxWidth:"min(96vw, 1600px)",maxHeight:"94vh",background:"var(--graview-panel)",color:"var(--graview-ink)"},children:(0,t.jsxs)("figure",{style:{margin:0,display:"grid",gap:8,padding:10},children:[(0,t.jsx)("img",{src:c.href,alt:v(c),style:{maxWidth:"100%",maxHeight:"80vh",objectFit:"contain",display:"block",margin:"0 auto"}}),(0,t.jsxs)("figcaption",{style:{display:"flex",gap:12,alignItems:"center",justifyContent:"space-between"},children:[(0,t.jsx)("span",{children:c.caption??c.name}),(0,t.jsx)("form",{method:"dialog",style:{margin:0},children:(0,t.jsx)("button",{type:"submit",autoFocus:!0,children:"Close"})})]})]})}):null]})}function me({value:e,onChange:n,several:a,image:i,label:o,thumbs:s=!0}){let d=_(),m=(0,g.useId)(),c=(0,g.useRef)(null),l=(0,g.useRef)(null),[f,y]=(0,g.useState)(null),[$,I]=(0,g.useState)(null),[A,E]=(0,g.useState)([]),[D,L]=(0,g.useState)(!1),x=d?i?d.kinds.filter(r=>r.startsWith("image/")||r==="*"||r==="*/*"):d.kinds:[],G=d?d.kinds.length===0||x.some(r=>r.startsWith("image/")||r.startsWith("*")):!1,P=!!d&&(!i||G),q=i?a?"pictures":"a picture":a?"files":"a file",K=i?x.length>0?x.join(","):"image/*":d?.kinds.join(",")||void 0,be=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,V=(0,g.useRef)(e);V.current=e;let J=(0,g.useRef)(null),R=(0,g.useRef)(null);(0,g.useEffect)(()=>{let r=R.current;if(!r||r.from===e)return;R.current=null;let u=J.current?.children,h=u?.[Math.min(r.at,u.length-1)];((r.what==="move"?h?.querySelector("[data-graview-file-move]"):null)??h?.querySelector("[data-graview-file-remove]")??c.current?.parentElement?.querySelector("[data-graview-file-choose]"))?.focus()});let T=async(r,u)=>{if(!d||r.length===0)return;let h=a?r:r.slice(0,1),p=[],w=[];h.length<r.length&&w.push(`${o} holds one ${i?"picture":"file"}, so ${r.slice(1).map(b=>`\u201C${b.name||"the photo"}\u201D`).join(", ")} ${r.length>2?"were":"was"} left out.`),E([]),I(null);for(let b of h){y(`Sending ${b.name||"the photo"}\u2026`);let B=await Se(b,d,{image:i,camera:u==="camera"});if("refused"in B){w.push(B.refused);continue}let S=await Ce(B,d,i);"refused"in S?w.push(S.refused):[...a?V.current:[],...p].some(ke=>ke.href===S.href)?w.push(`\u201C${S.name}\u201D is already here.`):p.push(S)}if(y(null),E(w),p.length!==0)try{n(a?[...V.current,...p]:p.slice(-1)),I(`Added ${p.map(b=>b.name).join(", ")}.`)}catch(b){E([...w,b instanceof Error?b.message:String(b)])}},W=(r,u,h)=>{try{R.current=h?{...h,from:e}:null,n(r),I(u)}catch(p){R.current=null,E([p instanceof Error?p.message:String(p)])}},M=r=>r?Array.from(r):[],we=r=>{let u=M(r.clipboardData?.files);!P||u.length===0||(r.preventDefault(),T(u,"pasted"))},ve=r=>{L(!1),P&&(r.preventDefault(),T(M(r.dataTransfer?.files),"dropped"))};return(0,t.jsxs)("div",{role:"group","aria-labelledby":`${m}-label`,"data-graview-file-editor":"","data-graview-dropping":D?"":void 0,onPaste:we,onDragOver:r=>{P&&(r.preventDefault(),L(!0))},onDragLeave:()=>L(!1),onDrop:ve,style:{display:"grid",gap:8,minWidth:0,padding:D?6:0,outline:D?"2px dashed var(--graview-accent)":"none",borderRadius:F},children:[(0,t.jsx)("span",{id:`${m}-label`,style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap"},children:o}),e.length>0&&(a||e.length>1)?(0,t.jsx)("ul",{ref:J,style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:6},children:e.map((r,u)=>(0,t.jsxs)("li",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap",minWidth:0},children:[s&&k(r)?(0,t.jsx)(O,{file:r,size:40}):null,(0,t.jsx)("span",{style:{flex:"1 1 8rem",minWidth:0,overflowWrap:"anywhere"},children:r.name}),(0,t.jsx)(ue,{file:r,onCaption:h=>W(e.map((p,w)=>w===u?de(p,h):p),h?`${r.name} now says \u201C${h}\u201D.`:`${r.name} says its name again.`)}),a&&u>0?(0,t.jsx)("button",{type:"button","data-graview-file-move":"","aria-label":`Move ${r.name} earlier`,onClick:()=>W(e.map((h,p)=>p===u-1?r:p===u?e[u-1]:h),`Moved ${r.name} earlier.`,{at:u-1,what:"move"}),children:"\u2191"}):null,a?(0,t.jsx)("button",{type:"button","data-graview-file-remove":"","aria-label":`Remove ${r.name}`,onClick:()=>W(e.filter((h,p)=>p!==u),`Removed ${r.name}.`,{at:u,what:"remove"}),children:"Remove"}):null]},`${u}:${r.href}`))}):e.length===1?(0,t.jsx)(ue,{file:e[0],onCaption:r=>W([de(e[0],r)],r?`${e[0].name} now says \u201C${r}\u201D.`:`${e[0].name} says its name again.`)}):null,P?(0,t.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:8,alignItems:"center"},children:[(0,t.jsx)("input",{ref:c,type:"file",hidden:!0,multiple:a,...K?{accept:K}:{},"data-graview-file-input":"","aria-label":`Choose ${q}`,onChange:r=>{let u=M(r.currentTarget.files);r.currentTarget.value="",T(u,"picked")}}),(0,t.jsx)("button",{type:"button",disabled:f!==null,onClick:()=>c.current?.click(),"data-graview-file-choose":"",children:e.length>0&&!a?`Replace ${i?"the picture":"the file"}`:`Choose ${q}`}),G?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("input",{ref:l,type:"file",hidden:!0,accept:"image/*",capture:"environment","data-graview-photo-input":"","aria-label":"Take a photo",onChange:r=>{let u=M(r.currentTarget.files);r.currentTarget.value="",T(u,"camera")}}),be?(0,t.jsx)("button",{type:"button",disabled:f!==null,onClick:()=>l.current?.click(),children:"Take a photo"}):null]}):null,(0,t.jsxs)("span",{style:C,"data-graview-file-takes":"",children:["or drop or paste ",a?"them":"it"," here \xB7 ",d.kinds.length>0?ce(x.length>0?x:d.kinds):"any file",", up to ",H(d.maxBytes)]})]}):(0,t.jsx)("p",{style:{...C,margin:0},"data-graview-file-none":"",children:d?"This host doesn\u2019t take pictures, so none can be added here.":"This host doesn\u2019t take files, so none can be added here."}),(0,t.jsx)("p",{"aria-live":"polite",style:{...C,margin:0,minHeight:f||$?void 0:0},"data-graview-file-status":"",children:f??$??""}),A.length>0?(0,t.jsx)("div",{role:"alert","data-graview-file-refused":"",style:{color:"var(--graview-warn)",fontSize:"0.875rem",display:"grid",gap:2},children:A.map((r,u)=>(0,t.jsx)("p",{style:{margin:0},children:r},u))}):null]})}var de=(e,n)=>{let{caption:a,...i}=e;return n?{...i,caption:n}:i};function ue({file:e,onCaption:n}){let[a,i]=(0,g.useState)(e.caption??"");(0,g.useEffect)(()=>i(e.caption??""),[e.caption]);let o=()=>{let s=a.trim().slice(0,500);s!==(e.caption??"")&&n(s)};return(0,t.jsx)("input",{type:"text",value:a,placeholder:k(e)?"What it shows":"What it is","aria-label":`What ${e.name} ${k(e)?"shows":"is"}`,"data-graview-file-caption":e.href,onChange:s=>i(s.target.value),onBlur:o,onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),o())},style:{flex:"1 1 10rem",minWidth:0,font:"inherit",fontSize:"0.875rem",minHeight:24}})}function ye({field:e,label:n,labelStyle:a,valueStyle:i,style:o,children:s}){return(0,t.jsxs)("div",{"data-graview-files":e,style:{display:"grid",gap:6,minWidth:0,gridColumn:"1 / -1",...o},children:[(0,t.jsx)("dt",{style:a,children:n}),(0,t.jsx)("dd",{style:{margin:0,minWidth:0,display:"grid",gap:10,...i},children:s})]})}function fe(e){let{nodeId:n,field:a,label:i,files:o}=e,{fields:s,commit:d}=re(n),m=s.find(y=>y.field===a&&y.takesValue),c=m?.shape,l=c?.type==="several"?c.of:c,f=c?.type==="several";return o.length===0&&l?.type!=="file"?null:(0,t.jsxs)(ye,{...e,children:[(0,t.jsx)(N,{files:o,label:i}),m&&l?.type==="file"?(0,t.jsx)(me,{value:o,thumbs:!1,several:f,image:l.image===!0,label:i,onChange:y=>{let $=f?y:y[y.length-1];$!==void 0&&d(m,$)}}):null]})}function Le(e){switch(e.as){case"field":return e.read?e.files.length>0?(0,t.jsx)(ye,{...e,children:(0,t.jsx)(N,{files:e.files,label:e.label})}):null:(0,t.jsx)(fe,{...e});case"unfilled":return(0,t.jsx)(Pe,{...e});case"thumb":return(0,t.jsx)(O,{...e});case"block":return e.files.length>0?(0,t.jsx)("span",{className:"graview-spec-image","data-graview-field":e.field,"data-graview-image":e.view,style:{display:"block",minWidth:0,...e.view==="gallery"?{position:"relative",zIndex:X.raised}:{}},children:e.view==="thumb"?(0,t.jsx)(O,{file:e.files[0],size:72}):(0,t.jsx)(N,{files:e.files,label:e.label})}):null;case"control":{let n=(0,t.jsx)(me,{value:j(e.value),several:e.several,image:e.image,label:e.label,onChange:a=>e.onChange(e.several?a:a[a.length-1])});return e.title===void 0?n:(0,t.jsxs)("fieldset",{"data-graview-part":"group","data-graview-field":e.several?"files":"file",children:[(0,t.jsx)("legend",{"data-graview-part":"label",children:e.title}),n]})}}}function Pe({nodeId:e,skip:n,labels:a,labelStyle:i,style:o}){let{store:s}=te(),d=ne(e),m=d?s.schema.tryDefinition(d.kind):void 0,c=ae(m).filter(l=>!n.includes(l)&&!(m?.display?.hide??[]).includes(l)&&j(d?.[l]).length===0);return c.length===0?null:(0,t.jsx)("dl",{style:{margin:0,display:"grid",gap:14,minWidth:0},children:c.map(l=>(0,t.jsx)(fe,{nodeId:e,field:l,label:a?.[l]??Q(m,l),files:[],...i?{labelStyle:i}:{},...o?{style:o}:{}},l))})}export{me as FilesEditor,$e as SEND_EDGE,Le as drawFiles,ce as kindsWords,Se as prepare,Ce as send,H as sizeWords,ge as takes,U as typeWords};
@@ -1 +0,0 @@
1
- import{b as m}from"./chunk.FDELO7NY.js";import"./chunk.SOBC3CTN.js";import"./chunk.KN3ULTGF.js";import"./chunk.UGFDSE37.js";import{g}from"./chunk.R26DREVU.js";import"./chunk.JPHNKWTY.js";import"./chunk.FGVKJWNS.js";import"./chunk.3JNMSOFG.js";import"./chunk.YV2LJFGS.js";import"./chunk.QNGWEV47.js";import"./chunk.ERXSYPYL.js";import"./chunk.J2ITFGN3.js";import"./chunk.V5ZYUVMH.js";import"./chunk.GLBHQFJ2.js";import"./chunk.UT6642FC.js";import"./chunk.QTA4ROAK.js";import"./chunk.2CIBWZJG.js";import"./chunk.MB7LKKUD.js";import"./chunk.RRVIXV7W.js";import"./chunk.7BWT5L2L.js";import"./chunk.VSZQXB4Q.js";import"./chunk.RI3PYG5T.js";import"./chunk.UWGWXFWZ.js";import"./chunk.SE5SKFQH.js";import"./chunk.W3S6UXNA.js";import"./chunk.UZWWDAGM.js";import"./chunk.WVUJXDXZ.js";import"./chunk.OZNW5W4Z.js";import"./chunk.NDADLJE6.js";import"./chunk.AK3IHFCF.js";import"./chunk.HHPGWJDO.js";import"./chunk.42YX6NOY.js";import"./chunk.EYZ7MHBZ.js";import"./chunk.KQT7WAQE.js";import"./chunk.PAVR5TK5.js";import"./chunk.OQDETV4X.js";import"./chunk.3VL5WECB.js";import"./chunk.JH6MU6TX.js";import"./chunk.WAFDCOOG.js";import"./chunk.L4DECHXR.js";import{G as b,R as l}from"./chunk.GFF2FB2J.js";import{Rc as n}from"./chunk.6V2RG5JG.js";import{b as t}from"./chunk.AJZBJBMO.js";var y=t(b(),1),a=t(l(),1);function P({store:h,auto:c,brand:r,views:f,presence:i,steering:o,overview:s,scope:d,titleLevel:v=2,props:e}){let u=(0,y.useMemo)(()=>g({scope:`.${d}`}),[d]);return(0,a.jsxs)("div",{"data-embed-content":"",style:c?{flex:"0 0 auto",background:"var(--graview-ground)"}:{flex:"1 1 auto",minHeight:0,overflow:"auto",background:"var(--graview-ground)"},children:[(0,a.jsx)("style",{children:u}),(0,a.jsx)("div",{"data-embed-measure":"",style:{display:"flow-root"},children:(0,a.jsx)(m,{context:{store:h,embedded:!0,...e.bar!==!1?{barAbove:!0}:{},...s?{overview:s}:{},titleLevel:v,views:f,settings:e.app.settings??[],...i?{presence:i}:{},...r?{brand:r}:{},...e.locale?{locale:e.locale}:{},...e.principal?{principal:e.principal}:{},...e.seats?{seats:e.seats}:{},...e.people?{people:e.people}:{}},...e.pages?{registry:e.pages}:{},...o?{steering:o}:{},...e.routing==="address"?n(e.basePath)===""?{}:{basename:n(e.basePath)}:{initialPath:e.path??"/"},...e.path!==void 0?{path:e.path}:{},...e.onNavigate?{onNavigate:e.onNavigate}:{}})})]})}export{P as PagesContent};
@@ -1 +0,0 @@
1
- import{a,b}from"./chunk.XRJBLH4N.js";import"./chunk.3JNMSOFG.js";import"./chunk.PKK6FRZR.js";import"./chunk.OAF7TUMI.js";import"./chunk.UT6642FC.js";import"./chunk.OZNW5W4Z.js";import"./chunk.NDADLJE6.js";import"./chunk.AK3IHFCF.js";import"./chunk.HHPGWJDO.js";import"./chunk.42YX6NOY.js";import"./chunk.3VL5WECB.js";import"./chunk.JH6MU6TX.js";import"./chunk.WAFDCOOG.js";import"./chunk.6V2RG5JG.js";import"./chunk.AJZBJBMO.js";export{b as actOnSeveral,a as actsForSeveral};
@@ -1 +0,0 @@
1
- import{f as U}from"./chunk.JPHNKWTY.js";import{a as _e}from"./chunk.3JNMSOFG.js";import{c as ve,d as Ae,e as Oe}from"./chunk.6XMEU2Q2.js";import{q as Re}from"./chunk.W3S6UXNA.js";import{a as D}from"./chunk.6T2Q6NLO.js";import{a as Se,b as C,d as be}from"./chunk.3VL5WECB.js";import{a as fe}from"./chunk.WAFDCOOG.js";import{Aa as ce,Ba as le,Ea as ue,Ka as H,Na as me,X as W,a as ae,ib as pe,la as oe,lb as he,mb as ye,oa as V,pb as ge,pc as ke,qa as se,sa as de,sb as we,ta as B,vb as I}from"./chunk.6V2RG5JG.js";var N=(t,n,e)=>{(t[n]===void 0||e>t[n])&&(t[n]=e)},J=(t,n,e)=>{(t[n]===void 0||e<t[n])&&(t[n]=e)},G=(t,n)=>{t.format=n,n.includes("int")&&(t.isInt=!0)},xe=(t,n)=>{t.mime=t.mime?t.mime.filter(e=>n.includes(e)):[...n]},Te=(t,n)=>{t.multipleOf??=[],t.multipleOf.includes(n)||t.multipleOf.push(n)},Me=(t,n)=>(t.patterns??=new Set).add(n),Ue={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function P(t){let n={},{def:e,bag:r}=t._zod,i=t._zod.traits.has("$ZodCheck")?[t,...e.checks??[]]:e.checks??[];for(let a of i){let o=a._zod.def;switch(o.check){case"greater_than":N(n,o.inclusive?"minimum":"exclusiveMinimum",o.value);break;case"less_than":J(n,o.inclusive?"maximum":"exclusiveMaximum",o.value);break;case"multiple_of":Te(n,o.value);break;case"number_format":{G(n,o.format);let c=Ue[o.format];c&&(N(n,"minimum",c[0]),J(n,"maximum",c[1]));break}case"bigint_format":G(n,o.format);break;case"min_length":case"min_size":N(n,"minimum",o.minimum);break;case"max_length":case"max_size":J(n,"maximum",o.maximum);break;case"length_equals":N(n,"minimum",o.length),J(n,"maximum",o.length);break;case"size_equals":N(n,"minimum",o.size),J(n,"maximum",o.size);break;case"string_format":G(n,o.format),o.pattern&&Me(n,o.pattern),(o.format==="base64"||o.format==="base64url")&&(n.contentEncoding=o.format),(o.local||o.precision===-1)&&(n.laxFormat=!0);break;case"mime_type":xe(n,o.mime);break}}r.minimum!==void 0&&N(n,"minimum",r.minimum),r.exclusiveMinimum!==void 0&&N(n,"exclusiveMinimum",r.exclusiveMinimum),r.maximum!==void 0&&J(n,"maximum",r.maximum),r.exclusiveMaximum!==void 0&&J(n,"exclusiveMaximum",r.exclusiveMaximum),r.multipleOf!==void 0&&Te(n,r.multipleOf),r.format!==void 0&&(n.format??=r.format,r.format.includes("int")&&(n.isInt=!0)),r.mime&&xe(n,r.mime);for(let a of r.patterns??[])Me(n,a);return n}var Ge={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""};function z(t){let n=t._zod.def;return n.type==="pipe"&&n.in._zod.traits.has("$ZodTransform")?z(n.out):n.type==="catch"?z(n.innerType):t._zod.optin}var Ke=new Set(["promise","optional","nonoptional","nullable","readonly","default","prefault","catch"]);function A(t,n=new Set){if(n.has(t))return!1;n.add(t);let e=t._zod.def,r=e.type;return r==="transform"?!0:r==="array"?A(e.element,n):r==="set"?A(e.valueType,n):r==="lazy"?A(e.getter(),n):Ke.has(r)?A(e.innerType,n):r==="intersection"?A(e.left,n)||A(e.right,n):r==="record"||r==="map"?A(e.keyType,n)||A(e.valueType,n):r==="pipe"?t._zod.traits.has("$ZodCodec")||A(e.in,n)||A(e.out,n):r==="object"?Object.values(e.shape).some(i=>A(i,n)):r==="union"?e.options.some(i=>A(i,n)):r==="tuple"?e.items.some(i=>A(i,n))||(e.rest?A(e.rest,n):!1):!1}function Ze(t){let n=Object.values(t).filter(e=>typeof e=="number");return Object.entries(t).filter(([e])=>n.indexOf(+e)===-1).map(([,e])=>e)}function Je(t){let n=t.anyOf;if(!Array.isArray(n)||n.length===0||t.type!==void 0)return;let e=[];for(let r of n){if(!r||typeof r!="object")return;Je(r);let i=Object.keys(r);if(i.length!==1||i[0]!=="type")return;for(let a of[r.type].flat()){if(typeof a!="string")return;e.includes(a)||e.push(a)}}delete t.anyOf,t.type=e.length===1?e[0]:e}var De=new Set(["type","properties","required","additionalProperties"]),$e=t=>{let n=t.additionalProperties;return n&&typeof n=="object"&&Object.keys(n).length?n:null},Ne=(t,n)=>JSON.stringify(t)===JSON.stringify(n);function K(t){for(let i of t){if(typeof i!="object"||i.type!=="object")return null;for(let a in i)if(!De.has(a))return null}let n={},e=new Set;for(let i of t){for(let a in i.properties){if(Object.prototype.hasOwnProperty.call(n,a))continue;let o=[];for(let c of t){let s=c.properties?.[a]??$e(c);s&&!o.some(p=>Ne(p,s))&&o.push(s)}n[a]=o.length===1?o[0]:K(o)??{allOf:o}}for(let a of i.required??[])e.add(a)}let r={type:"object",properties:n};if(e.size&&(r.required=[...e]),t.every(i=>i.additionalProperties===!1))r.additionalProperties=!1;else{let i=[];for(let a of t){let o=$e(a);o&&!i.some(c=>Ne(c,o))&&i.push(o)}i.length===1?r.additionalProperties=i[0]:i.length>1&&(r.additionalProperties={allOf:i})}return r}function Ye(t){let n=t.allOf;if(!Array.isArray(n)||n.length<2)return;for(let i of De)if(i in t)return;let e=n.filter(i=>Array.isArray(i.oneOf)||Array.isArray(i.anyOf)),r;if(!e.length)r=K(n);else{let i=e[0],a=Array.isArray(i.oneOf)?"oneOf":"anyOf";if(Object.keys(i).length!==1)return;let o=n.filter(s=>s!==i),c=i[a].map(s=>K([...o,s]));if(c.some(s=>!s))return;r={[a]:c}}r&&(delete t.allOf,Object.assign(t,r))}function Pe(t){let n=t;for(let u of["anyOf","oneOf"]){let f=n[u];if(!Array.isArray(f))continue;let k=f.map(Pe);k.some((g,l)=>g!==f[l])&&(n={...n,[u]:k})}let e=[n.type].flat(),r=!e.includes("string")&&e.some(u=>u==="number"||u==="integer"),i=n.enum??(n.const!==void 0?[n.const]:void 0);if(!r&&!i?.some(u=>typeof u=="number"))return n;let{minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:s,multipleOf:p,format:h,id:S,...y}=n;return y.enum?y.enum=y.enum.map(u=>typeof u=="number"?String(u):u):typeof y.const=="number"&&(y.const=String(y.const)),r&&(y.type="string",i||(y.pattern=e.includes("number")?"^-?\\d+(?:\\.\\d+)?$":"^-?\\d+$")),y}var L=class{constructor(n,e){this.override=n;this.refs=e}done=new Map;path=[];cyclic=new Map;write(n,e=!1){let r=this.refs.get(n);if(r!==void 0&&!e)return{$ref:r};if(this.path.includes(n))return this.cyclic.has(n)||this.cyclic.set(n,""),{};let i=this.done.get(n);if(i)return i;this.path.push(n);try{let a=this.written(n);return this.done.set(n,a),a}finally{this.path.pop()}}written(n){let e={},r,i=n._zod.toJSONSchema?.();i?Object.assign(e,i):r=this.process(n,e);let a=ae.get(n);if(a)for(let c of Object.keys(a))e[c]=a[c];A(n)&&(delete e.examples,delete e.default),"_prefault"in e&&(e.default??=e._prefault,delete e._prefault);let o=e;if(r){let c=this.write(r);o={...e};for(let s of Object.keys(c))s in e||(o[s]=c[s])}return this.override({zodSchema:n,jsonSchema:o}),Je(o),n._zod.def.type==="intersection"&&Ye(o),o}process(n,e){let r=n._zod.def;switch(r.type){case"string":{e.type="string";let{minimum:i,maximum:a,format:o,patterns:c,contentEncoding:s,laxFormat:p}=P(n);if(typeof i=="number"&&(e.minLength=i),typeof a=="number"&&(e.maxLength=a),o&&(e.format=Ge[o]??o,(e.format===""||o==="time"||p)&&delete e.format),s&&(e.contentEncoding=s),c&&c.size>0){let h=[...c];h.length===1?e.pattern=h[0].source:e.allOf=h.map(S=>({pattern:S.source}))}return}case"number":{let{minimum:i,maximum:a,multipleOf:o,exclusiveMinimum:c,exclusiveMaximum:s,isInt:p}=P(n);if(e.type=p?"integer":"number",typeof c=="number"&&c>=(i??Number.NEGATIVE_INFINITY)?e.exclusiveMinimum=c:typeof i=="number"&&(e.minimum=i),typeof s=="number"&&s<=(a??Number.POSITIVE_INFINITY)?e.exclusiveMaximum=s:typeof a=="number"&&(e.maximum=a),o){let[h,...S]=new Set(o.filter(y=>Number.isFinite(y)&&y!==0).map(Math.abs));h!==void 0&&(e.multipleOf=h),S.length&&(e.allOf=[...e.allOf??[],...S.map(y=>({multipleOf:y}))])}return}case"boolean":case"success":e.type="boolean";return;case"null":e.type="null";return;case"never":e.not={};return;case"enum":{let i=Ze(r.entries);i.length===0?e.not={}:(i.every(a=>typeof a=="number")&&(e.type="number"),i.every(a=>typeof a=="string")&&(e.type="string"),e.enum=i);return}case"literal":{let i=r.values.filter(a=>a!==void 0).map(a=>typeof a=="bigint"?Number(a):a);if(r.values.length===0)e.not={};else if(i.length===1)e.type=i[0]===null?"null":typeof i[0],e.const=i[0];else if(i.length>1){for(let a of["number","string","boolean"])i.every(o=>typeof o===a)&&(e.type=a);i.every(a=>a===null)&&(e.type="null"),e.enum=i}return}case"template_literal":e.type="string",e.pattern=n._zod.pattern.source;return;case"file":{e.type="string",e.format="binary",e.contentEncoding="binary";let{minimum:i,maximum:a,mime:o}=P(n);i!==void 0&&(e.minLength=i),a!==void 0&&(e.maxLength=a),o&&(o.length===0?e.not={}:o.length===1?e.contentMediaType=o[0]:e.anyOf=o.map(c=>({contentMediaType:c})));return}case"array":{let{minimum:i,maximum:a}=P(n);typeof i=="number"&&(e.minItems=i),typeof a=="number"&&(e.maxItems=a),e.type="array",e.items=this.write(r.element);return}case"object":{let i=r.shape;e.type="object";let a={};e.properties=a;for(let c in i)Object.defineProperty(a,c,{value:this.write(i[c]),writable:!0,enumerable:!0,configurable:!0});let o=Object.keys(i).filter(c=>z(i[c])===void 0);o.length>0&&(e.required=o),r.catchall?._zod.def.type==="never"?e.additionalProperties=!1:r.catchall&&(e.additionalProperties=this.write(r.catchall));return}case"union":e[r.inclusive===!1?"oneOf":"anyOf"]=r.options.map(i=>this.write(i));return;case"intersection":{let i=c=>"allOf"in c&&Object.keys(c).length===1,a=this.write(r.left),o=this.write(r.right);e.allOf=[...i(a)?a.allOf:[a],...i(o)?o.allOf:[o]];return}case"tuple":{let i=r.items;e.type="array",e.prefixItems=i.map(s=>this.write(s)),r.rest?e.items=this.write(r.rest):e.items=!1;let a=i.length;for(;a>0&&z(i[a-1])!==void 0;)a-=1;a>0&&(e.minItems=a),r.rest||(e.maxItems=i.length);let{minimum:o,maximum:c}=P(n);typeof o=="number"&&(e.minItems=o),typeof c=="number"&&(e.maxItems=c);return}case"record":{let i=r.keyType;e.type="object";let a=P(i).patterns;if(r.mode==="loose"&&a&&a.size>0){let c=this.write(r.valueType),s={};for(let p of a)s[p.source]=c;e.patternProperties=s}else e.propertyNames=Pe(this.write(i)),e.additionalProperties=this.write(r.valueType);let o=i._zod.values;if(o&&!r.partial&&z(r.valueType)===void 0){let c=[...o].filter(s=>typeof s=="string"||typeof s=="number");c.length>0&&(e.required=c.map(String))}return}case"nullable":e.anyOf=[this.write(r.innerType),{type:"null"}];return;case"default":case"prefault":{let i=r.defaultValue,a,o=!1,c=JSON.stringify(i,(s,p)=>typeof p=="bigint"?(o=!0,null):p);return!o&&c!==void 0&&(a=JSON.parse(c)),o||(e[r.type==="default"?"default":"_prefault"]=a),r.innerType}case"catch":{try{e.default=r.catchValue(void 0)}catch{}return r.innerType}case"readonly":return e.readOnly=!0,r.innerType;case"pipe":return r.in._zod.traits.has("$ZodTransform")?r.out:r.in;case"lazy":return n._zod.innerType;case"optional":case"nonoptional":case"promise":return r.innerType;default:return}}};function Ee(t,n=()=>{}){let e=t,r=new L(n,new Map),i=r.write(e,!0);if(r.cyclic.size>0){let a=new Map,o=0,c=[];for(let p of r.cyclic.keys())if(p===e)a.set(p,"#");else{let h=`__schema${o++}`;a.set(p,`#/$defs/${h}`),c.push([p,h])}r=new L(n,a),i=r.write(e,!0);let s={};for(let[p,h]of c)s[h]=r.write(p,!0);c.length>0&&(i={...i,$defs:s})}return JSON.parse(JSON.stringify({$schema:"https://json-schema.org/draft/2020-12/schema",...i}))}function ze(t){return Ee(t,en)}var Xe={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string"},Qe={phone:"A phone number as it is written, like +1 555 123 4567 or 020 7946 0958 ext. 12.",place:"An address or a place's name, as a person would search a map for it.",duration:"A length of time in whole minutes: 90 is 1 h 30 min."};function en(t){oe(t.zodSchema)&&(t.jsonSchema["x-graview-app-link"]=!0);let n=de(t.zodSchema);if(n&&(t.jsonSchema.type==="string"||t.jsonSchema.type==="array")){t.jsonSchema["x-graview-linked"]={address:n.address,kinds:[...n.kinds],cardinality:n.cardinality};let s=n.kinds.join(" or "),p=`${n.cardinality==="many"?"Records":"A record"}: a ${s} in the app ${n.address}, as "${n.kinds[0]}:<id>" \u2014 an id found there with find_linked. Linking never changes that app.`,h=t.jsonSchema.description;typeof h=="string"&&h.includes(p)||(t.jsonSchema.description=`${typeof h=="string"&&h?`${h.replace(/\.?$/,".")} `:""}${p}`)}if(ue(t.zodSchema)&&(t.jsonSchema["x-graview-repeat"]=!0,!t.jsonSchema.type&&!t.jsonSchema.anyOf&&!t.jsonSchema.oneOf&&Object.assign(t.jsonSchema,nn())),fe(t.zodSchema)){t.jsonSchema.contentMediaType="text/markdown";let s=t.jsonSchema.description;typeof s=="string"&&s.endsWith("Written in Markdown.")||(t.jsonSchema.description=`${typeof s=="string"&&s?`${s.replace(/\.?$/,".")} `:""}Written in Markdown.`)}let e=we(t.zodSchema);if(e){let s=t.jsonSchema;s["x-graview-type"]=e,e==="duration"&&(s["x-graview-unit"]="minutes"),s.description??=Qe[e]}let r=ge(t.zodSchema,!1);if(r){let s=Se(r);t.jsonSchema["x-graview-format"]=s.format??"unit",s.currency&&(t.jsonSchema["x-graview-currency"]=s.currency),s.unit&&s.format!=="money"&&(t.jsonSchema["x-graview-unit"]=s.unit);let p=t.jsonSchema.description;t.jsonSchema.description=typeof p=="string"&&p.length>0?`${p} ${C(s)}`:C(s)}let i=t.zodSchema._zod?.def;if(!i||i.type!=="string"||typeof i.format!="string"||i.format==="regex")return;let a=t.jsonSchema,o=(i.checks??[]).map(s=>s._zod?.def).filter(s=>s?.format==="regex"&&s.pattern instanceof RegExp).map(s=>s.pattern.source);delete a.pattern;let c=a.allOf;Array.isArray(c)&&c.every(s=>typeof s=="object"&&s!==null&&Object.keys(s).length===1&&"pattern"in s)&&delete a.allOf,a.format=Xe[i.format]??i.format,o.length===1?a.pattern=o[0]:o.length>1&&(a.allOf=o.map(s=>({pattern:s})))}function Z(t){let n=I(t.input),e=ze(t.input),r=e.properties??{};if(he(t)){let i=t.creates.join(" | ");r.id={type:"string",minLength:1,description:`Optional: the id for the ${i} this makes. Refused if the graph already has it; left out, one is minted from the label.`},e.properties=r}ye(t)&&(e.additionalProperties=!1);for(let i of n){let a=r[i.name];if(!a)continue;let o=i.kinds.includes("*")?"any node kind":i.kinds.join(" | ");a.description=[a.description,`Id of a node (${o}).`].filter(Boolean).join(" ")}return{name:t.name,...t.title===void 0?{}:{title:t.title},description:t.description??t.title??t.name,inputSchema:e,nodeRefs:n}}function nn(){let t={type:"string",pattern:"^\\d{4}-\\d{2}-\\d{2}$"},n=(e,r)=>({type:"integer",minimum:e,maximum:r});return{type:"object",description:'How the date beside it repeats; the date is the first occurrence. "on" is weekdays for "week", days of the month (-1 the last) for "month".',properties:{every:{type:"string",enum:[...le]},interval:n(1,99),on:{type:"array",minItems:1,maxItems:31,items:{anyOf:[{type:"string",enum:[...ce]},n(-1,31)]}},until:t,count:n(1,1e3),except:{type:"array",maxItems:500,items:t},continues:{type:"string",maxLength:200}},required:["every"],additionalProperties:!1}}function je(t){let n=new Set;for(let e=t;e;e=e.onBehalfOf)e.id!==void 0&&n.add(`${e.kind}:${e.id}`);return n}function F(t,n){let e=je(n),r=h=>{if(h.kind==="rule")return!1;let S=je(h);if(S.size===0)return!1;for(let y of S)if(e.has(y))return!1;return!0},i,a=()=>{if(i)return i;i=new Map;for(let h of t.log.live()){if(h.undoes!==void 0)continue;let S=r(h.author)?h.author:void 0;for(let y of h.primitives){y.op==="remove-node"&&i.delete(y.node.id);let u=y.op==="add-node"?y.node.id:y.op==="patch-node"?y.id:void 0;if(u===void 0)continue;let f=y.op==="add-node"?Object.keys(y.node):Object.keys(y.after),k=i.get(u);(y.op==="add-node"||!k)&&i.set(u,k=new Map);for(let g of f)g==="id"||g==="kind"||(S?k.set(g,S):k.delete(g))}}return i},o=t.schema,c=new Map,s=(h,S)=>{let y=`${h}\0${S}`,u=c.get(y);if(u===void 0){let f=o.tryDefinition(h)?.fields?.shape;u=f!==void 0&&S in f&&be(f[S]).type==="text",c.set(y,u)}return u},p=h=>t.graph.getNode(h)?.kind;return{prose:s,say:h=>H(h,{graph:t.graph,schema:o}),fieldBy(h,S){let y=p(h);if(!(y===void 0||!s(y,S)))return a().get(h)?.get(S)},recordBy(h){let S=p(h),y=a().get(h);if(S===void 0||!y)return;let u;for(let[f,k]of y)s(S,f)&&(u=k);return u}}}var Y=(t,n,e)=>({untrusted:!0,authoredBy:e.say(n),text:t}),tn="the host's ranker";function He(t,n){return{...t,hits:t.hits.map(e=>{if(e.about!=="node")return e;e.why.by==="meaning"&&e.why.matched!==void 0&&(e={...e,why:{...e.why,matched:{untrusted:!0,authoredBy:tn,text:e.why.matched}}});let r=n.recordBy(e.id);if(!r)return e;let i=n.prose(e.kind,e.why.field)?n.fieldBy(e.id,e.why.field):r;return{...e,label:Y(e.label,r,n),...e.apart!==void 0?{apart:Y(e.apart,r,n)}:{},why:i?{...e.why,fragment:Y(e.why.fragment,i,n)}:e.why}})}}var q=t=>{let n;return()=>n??=t().catch(e=>{throw n=void 0,e})},rn=q(()=>import("./chunk.SOD3PBJM.js")),an=()=>import("./chunk.DZRTOURR.js").catch(()=>{}),on=async()=>{(await an())?.judgeWithLines()},j=q(()=>import("./chunk.OXQMNIRO.js")),sn=q(()=>import("./chunk.4HP7UWA2.js")),dn=q(()=>import("./chunk.2XAONC66.js")),cn=t=>t.definitions.some(n=>B(n).size>0),Ie=t=>({value:V(t),label:t.label,...t.describe?{describe:t.describe}:{},...t.card?{card:t.card}:{},fields:t.fields,...t.app?{app:t.app}:{}});async function ln(t,n,e,r){let i=String(e.relation??""),[a,o]=i.includes(".")?i.split(".",2):[void 0,i],c=t.schema.definitions.flatMap(g=>[...B(g)].map(([l,d])=>({kind:g.kind,name:l,relation:d}))),s=c.filter(g=>g.name===o&&(a===void 0||g.kind===a));if(s.length!==1){let g=c.map(l=>`${l.kind}.${l.name}`).join(", ")||"none";return{ok:!1,error:`${s.length===0?`No relation to another app is called "${i}"`:`"${i}" names a relation of several kinds`}. The relations to other apps are: ${g}.`}}let{kind:p,name:h,relation:S}=s[0];if(!r)return{ok:!1,error:`This seat cannot read ${S.address}: its host reads no other app's records. Nothing was changed.`};let y={kind:n.kind,...n.id===void 0?{}:{id:n.id},...n.roles?{roles:n.roles}:{}},u=typeof e.of=="string"?e.of:void 0;if(u!==void 0){let g=t.graph.getNode(u);if(!g||g.kind!==p)return{ok:!1,error:`No ${p} "${u}".`};let l=se(g[h],S),d=await Promise.all(l.map(m=>Promise.resolve().then(()=>r.resolve(m,y)).catch(()=>null)));return{ok:!0,data:{relation:`${p}.${h}`,app:S.address,records:d.map((m,w)=>m===null?{value:V(l[w]),missing:!0}:"denied"in m?{denied:!0,said:"linked record (no access)"}:Ie(m))},reads:[u]}}let f=typeof e.limit=="number"&&e.limit>0?Math.min(e.limit,20):20,k=await Promise.resolve().then(()=>r.find({address:S.address,kinds:S.kinds,query:String(e.query??""),limit:f},y)).catch(()=>[]);return Array.isArray(k)?{ok:!0,data:{relation:`${p}.${h}`,app:S.address,records:k.map(Ie),link:`edit-${p} with ${h} set to a record's value`}}:{ok:!0,data:{relation:`${p}.${h}`,app:S.address,denied:!0,said:"linked record (no access)"}}}var R=t=>({title:t,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}),Le={description:'Which records: false (the default) the live ones, true only the archived ones, "all" both. An archived record is set aside, not gone: unarchive-<kind> brings it back.',anyOf:[{type:"boolean"},{type:"string",enum:["all"]}]},X={type:"number",description:"Where the page starts; 0 when unsaid."},ne=[{name:"search_graph",title:"Find by name",description:"Find things by name: records whose name or readable fields carry the words, and the kinds, places and rules the words name \u2014 each with why it matched. Reach for this before get_graph when you know what something is called. Words match the start of words, case and accents aside; key:value tokens narrow as a list's filter does (done:false, is:any for past records, kind:<kind>). Pass subject (a node id) to get the acts you may run on it as hits too. When few records match exactly, records with a near word follow \u2014 a typo, another form of the word, a meaning \u2014 each with near: true and why.matched, the record's own word that answered.",inputSchema:{type:"object",properties:{query:{type:"string",description:"Words, with optional key:value conditions."},limit:{type:"number",description:"Most hits to return; at most 20."},subject:{type:"string",description:"A node id whose acts to include."},archived:Le},required:["query"],additionalProperties:!1},mutating:!1,annotations:R("Find by name")},{name:"get_graph",title:"Read the graph",description:"Read the graph, 25 nodes a page: their fields, the edges out of them, and how many more. Start here when you need the shape of the domain rather than one thing in it.",inputSchema:{type:"object",properties:{offset:X,archived:Le},additionalProperties:!1},mutating:!1,annotations:R("Read the graph")},{name:"get_node",title:"Read one node",description:"Read one node: its fields, its links (id, kind and label, 20 each way a page), the violations that implicate it, and its computed values: read-only fields worked out from what you can see, which no act sets. Use this to check a thing before you change it.",inputSchema:{type:"object",properties:{id:{type:"string",description:"A node's id, or its name."},offset:X},required:["id"],additionalProperties:!1},mutating:!1,annotations:R("Read one node")},{name:"get_violations",title:"List the problems",description:"List the invariant violations the graph currently has, 20 a page, with the repairs that would resolve each one. Read this before proposing work: a rule that is already broken is more urgent than anything you could add.",inputSchema:{type:"object",properties:{offset:X,context:{type:"object",description:"Evaluation context, e.g. { weekStart }."}},additionalProperties:!1},mutating:!1,annotations:R("List the problems")},{name:"get_affordances",title:"Ask what can be done",description:"Ask what can legally be done with a selection, ranked. Prefer these over composing a mutation by hand: they are derived from the schema, the invariants and the shape of the graph, so they cannot name an action that does not exist.",inputSchema:{type:"object",properties:{selection:{type:"array",items:{type:"string"},description:"Node ids."},context:{type:"object"}},required:["selection"],additionalProperties:!1},mutating:!1,annotations:R("Ask what can be done")},{name:"describe_place",title:"Say what a place shows",description:`Say what one place of the app shows you, as a person in your seat would see it: its headings, its figures as drawn, its lists with each record's title and what its card or row says, the headings a list is grouped under, what an empty list says, and any block that could not be worked out. Pass a place's slug ("home", a lens's address like "the-offers", a kind's like "offers") or a record's id, and width 390 for a phone. Use it after a change to check what somebody now sees, instead of guessing.`,inputSchema:{type:"object",properties:{place:{type:"string",description:`"home", a place's slug, or a record's id.`},width:{type:"number",description:"The screen's width in CSS pixels; 390 is a phone, 1440 when unsaid."}},required:["place"],additionalProperties:!1},mutating:!1,annotations:R("Say what a place shows")},{name:"preview_mutation",title:"Try an act without applying it",description:"Try a mutation without applying it: get back the diff it would produce and any invariant it would break. Do this when you are unsure, rather than applying and undoing.",inputSchema:{type:"object",properties:{mutation:{type:"string"},args:{type:"object"}},required:["mutation","args"],additionalProperties:!1},mutating:!1,annotations:R("Try an act without applying it")},{name:"undo_batch",title:"Undo a batch",description:"Undo one batch of operations. Fails, naming the blocking operation, when a later operation read what it wrote.",inputSchema:{type:"object",properties:{batch:{type:"string"},include:{type:"array",items:{type:"string"}}},required:["batch"],additionalProperties:!1},mutating:!0,annotations:{title:"Undo a batch",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1}},{name:"list_suggestions",title:"List what is suggested",description:"List the suggestions waiting for a person: changes the app's own actor proposed and did not make, each with its id, what it would do, who suggested it, what it was based on and how sure (0 to 1). Nothing changes until one is accepted (accept_suggestion) or declined (decline_suggestion); a declined one is never suggested again.",inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:R("List what is suggested")},{name:"accept_suggestion",title:"Accept a suggestion",description:"Make a waiting suggestion's change, as this seat, carrying what it was based on. Returns the batch (undo_batch takes it back).",inputSchema:{type:"object",properties:{suggestion:{type:"string",description:"The suggestion's id, from list_suggestions."}},required:["suggestion"],additionalProperties:!1},mutating:!0,annotations:{title:"Accept a suggestion",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1}},{name:"decline_suggestion",title:"Decline a suggestion",description:"Decline a waiting suggestion: nothing changes, the decline is kept in the log, and the same change is never suggested or made by the app's own actor again.",inputSchema:{type:"object",properties:{suggestion:{type:"string",description:"The suggestion's id, from list_suggestions."}},required:["suggestion"],additionalProperties:!1},mutating:!0,annotations:{title:"Decline a suggestion",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}}],qe={name:"act_on_several",title:"Do one act to several records",description:`Run one act on several records at once, as one change with one undo. act is the act (its tool name or its declared name), records the records it runs on (ids or names; each goes in the act's subject), args what every call shares ("Set stage to Declined" is args { stage: "declined" }). Each record is judged on its own: one this seat may not change is named with why, and the rest still apply. Returns the batch (undo_batch takes it all back), the records changed, those already so, and those refused.`,inputSchema:{type:"object",properties:{act:{type:"string",description:"The act to run on each record."},records:{type:"array",items:{type:"string"},minItems:1,maxItems:200,description:"Ids or names of the records."},args:{type:"object",description:"Arguments every call shares, besides the record."}},required:["act","records"],additionalProperties:!1},mutating:!0,annotations:{title:"Do one act to several records",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1}},te={type:"object",description:"A lens, as draft_view returns one.",properties:{title:{type:"string"},lens:{type:"string"},on:{type:"string"},bindings:{type:"object"},options:{type:"object"}},required:["title","lens","on"]},ie={name:"draft_view",title:"Draw a view",description:'Draw a view of the data from words ("a board of tasks by status", "who covers what") as a lens the app could keep; or check a lens you wrote (lens); or change the one on screen (current, with ask: "only this month"). Returns the lens and its add-lens edit, or one sentence saying why not. Writes nothing.',inputSchema:{type:"object",properties:{ask:{type:"string",description:"What to see, in words."},lens:te,current:te},additionalProperties:!1},mutating:!1,annotations:R("Draw a view")},We={name:"keep_lens",title:"Keep a view as a lens",description:"Keep a lens draft_view drew as one of the app's places: checked again, then written as the add-lens edit. Returns the remove-lens edit that takes it back.",inputSchema:{...te,additionalProperties:!1},mutating:!0,annotations:{title:"Keep a view as a lens",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},Ve={name:"find_linked",title:"Find a record in another app",description:`A relation may go to a kind in another app (describe_app lists them under "Linked from other apps"). With relation and words, list the records there this seat may link \u2014 each with the value to link it by ("house:h1"), its name and its describe line. With of (a record id here), read the records that record links, as this seat may see them there. Linking one is the record's edit (edit-<kind>) with the relation set to the value. Another app this seat may not open answers denied, and nothing of it. Writes nothing; never changes the other app.`,inputSchema:{type:"object",properties:{relation:{type:"string",description:"The relation, by name (forHouse) or as <kind>.<relation> (scenario.forHouse)."},query:{type:"string",description:"Words to find by, in the other app's names; empty for the first few."},of:{type:"string",description:"A record here whose linked records to read, instead of finding."},limit:{type:"number",description:"Most records to return; at most 20."}},required:["relation"],additionalProperties:!1},mutating:!1,annotations:R("Find a record in another app")};function un(t,n){return t===void 0?[]:t==="keep"&&!n?[ie,We]:[ie]}var fn="An argument that names a record takes its id or its name.",Be=[...ne.map(t=>t.name),qe.name,ie.name,We.name,Ve.name],Ce=64;function _(t){let{line:n,...e}=t;return e}function Fe(t){return{...t,...t.introduces?{introduces:t.introduces.map(_)}:{},...t.resolves?{resolves:t.resolves.map(_)}:{},...t.violationsAfter?{violationsAfter:t.violationsAfter.map(_)}:{}}}function mn(t){let n=t.normalize("NFKD").replace(/\p{M}/gu,"").replace(/[^A-Za-z0-9_-]/g,"_");return n.length===0&&(n="act"),/^[A-Za-z_]/.test(n)||(n=`act_${n}`),n.slice(0,Ce)}function pn(t){let n=new Set(Be),e=new Map;for(let r of t){let i=mn(r),a=i;for(let o=2;n.has(a);o+=1)a=`${i.slice(0,Ce-`_${o}`.length)}_${o}`;n.add(a),e.set(r,a)}return e}function hn(t,n){if(n.size===0)return t;let e=Object.fromEntries(Object.entries(t.properties??{}).filter(([i])=>!n.has(i))),r=(t.required??[]).filter(i=>!n.has(i));return{...t,properties:e,...t.required?{required:r}:{}}}function yn(t,n,e){let r=Z(t),i=W(t),a=r.nodeRefs.length>0?`${r.description}${/[.!?]$/.test(r.description)?"":"."} ${fn}`:r.description;return{name:n,title:i,description:a,inputSchema:hn(r.inputSchema,e),mutating:!0,annotations:{title:i,readOnlyHint:!1,destructiveHint:t.destructive===!0||(t.severs?.length??0)>0,idempotentHint:t.idempotent===!0,openWorldHint:!1},act:t.name}}function re(t){if(t===null||typeof t!="object")return JSON.stringify(t)??"null";if(Array.isArray(t))return`[${t.map(re).join(",")}]`;let n=t;return`{${Object.keys(n).filter(e=>n[e]!==void 0).sort().map(e=>`${JSON.stringify(e)}:${re(n[e])}`).join(",")}}`}function gn(t){return`sha256:${ke(re(t))}`}function wn(t,n,e,r,i,a=!1){let o=pn(t.map(p=>p.name)),c=[...un(r,e),...a?[Ve]:[]];return{definitions:e?[...ne.filter(p=>!p.mutating),...c]:[...ne,qe,...c,...t.filter(p=>n.has(p.name)).map(p=>yn(p,o.get(p.name),i(p)))],names:o}}function Qn(t,n={}){let e=n.author??{kind:"agent"},r=t.allMutations(),i=new Set(t.permittedMutations(e).map(u=>u.name)),{definitions:a,names:o}=wn(r,i,n.readOnly===!0,n.drafts?n.drafts.keep?"keep":"draw":void 0,u=>U(t.schema,t.policy,e,u),cn(t.schema)),c=gn(a),s=u=>{if(!Be.includes(u)){for(let[f,k]of o)if(k===u)return f;return o.has(u)?u:void 0}},p=(u,f)=>{let k=r.find(d=>d.name===u);if(!k)return{args:f,resolved:[]};let g={...f},l=[];for(let d of I(k.input)){let m=g[d.name];if(typeof m!="string"||m.trim()==="")continue;let w=t.resolveRef(d,m,e);if(!w.ok){let b=w.reason==="none"?` Nothing was changed. Use search_graph to look it up, then pass its id as ${d.name}.`:" Nothing was changed.";return{ok:!1,error:`${w.message}${b}`,argument:d.name,candidates:w.candidates}}w.by!=="id"&&(g[d.name]=w.id,l.push({argument:d.name,given:m,id:w.id,label:w.label}))}return{args:g,resolved:l}},h=async(u,f)=>{try{await on();let k=a.find(l=>l.name===u)??a.find(l=>l.act===u);if(!k){let l=s(u);if(l){let d=t.permits({name:l,args:f},e);if(!d.ok)return{ok:!1,error:d.refusal.message,reason:"forbidden"}}return{ok:!1,error:`Unknown tool "${u}". Available: ${a.map(d=>d.name).join(", ")}`}}if(k.mutating&&n.readOnly)return{ok:!1,error:`"${u}" changes the graph, and this seat is read-only.`,reason:"forbidden"};if(k.act!==void 0){let l=p(k.act,f);if("ok"in l)return l;let d=D(t,e,t.apply({name:k.act,args:l.args},{...n.author?{author:n.author}:{},...Q(n.via)}));return{ok:!0,data:{batch:d.batch,intent:d.intent,introduces:d.introduces.map(_),resolves:d.resolves.map(_),...l.resolved.length>0?{resolved:l.resolved}:{}},diff:d.diff}}let g=t.seenBy(e);switch(k.name){case"search_graph":{let l=typeof n.places=="function"?n.places():n.places,d=typeof f.subject=="string"?f.subject:void 0,m=Re(g,String(f.query??""),{principal:e,rank:n.near,archived:me(f.archived),limit:typeof f.limit=="number"&&f.limit>0?Math.min(f.limit,20):20,...l?{places:l}:{},...d?{subject:d,from:[d]}:{}}),w=m.later?await m.later:m;return{ok:!0,data:(await j()).searchRead(w,He(w,F(g,e))),reads:w.hits.flatMap(b=>b.about==="node"?[b.id]:[])}}case"get_graph":return{ok:!0,...(await j()).graphRead(g,F(g,e),f)};case"get_node":{let l=String(f.id??""),d=l,m;if(!g.graph.getNode(l)){let b=l.trim()===""?void 0:t.resolveRef({name:"id",kinds:["*"]},l,e);if(b?.ok)d=b.id,m={argument:"id",given:l,id:d,label:b.label};else return b?.reason==="ambiguous"?{ok:!1,error:b.message,argument:"id",candidates:b.candidates}:{ok:!1,error:`No node "${l}".`}}let w=(await j()).nodeRead(g,F(g,e),d,f);return{ok:!0,data:m?{...w.data,resolved:[m]}:w.data,reads:w.reads}}case"describe_place":{let l=n.app??{name:"",schema:t.schema},d=typeof f.width=="number"&&Number.isFinite(f.width)&&f.width>0?f.width:1440,{describePlace:m}=await rn(),w=m(t,e,String(f.place??""),{app:l,width:d});if(!w.ok)return{ok:!1,error:`${w.error} The places are: ${w.places.join(", ")}.`};let b=new Set,x=E=>{for(let M of E)for(let O of M.groups??[])for(let T of O.items)b.add(T.id),x(T.parts)};return x(w.description.parts),{ok:!0,data:w.description,reads:[...b]}}case"find_linked":return ln(g,e,f,n.linked);case"draft_view":case"keep_lens":{let l=n.app??{name:"",schema:t.schema};return(await sn()).runDraftTool(k.name,f,{app:l,principal:e,...n.drafts?{drafts:n.drafts}:{}})}case"get_violations":{let l=g.violations(f.context);return{ok:!0,...(await j()).violationsRead(l,f)}}case"get_affordances":{let l=f.selection??[];return{ok:!0,data:_e(g,l,{...typeof n.derive=="function"?n.derive():n.derive,...n.author?{principal:n.author}:{},...f.context?{context:f.context}:{}}),reads:l.filter(m=>g.graph.has(m))}}case"preview_mutation":{let l=String(f.mutation),d=s(l)??l,m=p(d,f.args??{});if("ok"in m)return m;let w=t.missingFor({name:d,args:m.args},e);if(w)return{ok:!1,error:w.message,reason:"missing"};let b=D(t,e,t.preview({name:d,args:m.args},void 0,{author:e})),x=Fe(b);return{ok:!0,data:m.resolved.length>0?{...x,resolved:m.resolved}:x}}case"act_on_several":{let l=String(f.act??""),d=s(l)??l,m=r.find(v=>v.name===d);if(!m||!i.has(d)){let v=m?t.permits({name:d,args:{}},e):void 0;return v&&!v.ok?{ok:!1,error:v.refusal.message,reason:"forbidden"}:{ok:!1,error:`There is no act "${l}" this seat may run. Nothing was changed.`,reason:"invalid"}}let w=m.subject;if(!w)return{ok:!1,error:`"${W(m)}" does not act on a record, so it cannot be run on several. Nothing was changed.`,reason:"invalid"};let b=Array.isArray(f.records)?f.records.filter(v=>typeof v=="string"&&v.trim()!==""):[];if(b.length===0)return{ok:!1,error:"Name at least one record. Nothing was changed.",reason:"invalid"};let x=[],E=[];for(let v of b.slice(0,200)){let $=t.resolveRef({name:w.arg,kinds:w.kinds},v,e);if(!$.ok)return{ok:!1,error:`${$.message} Nothing was changed.`,argument:"records",candidates:$.candidates};x.push($.id),$.by!=="id"&&E.push({argument:"records",given:v,id:$.id,label:$.label})}let M=p(d,{...f.args??{}});if("ok"in M)return M;let O=(await dn()).actOnSeveral(t,{mutation:d,subject:w.arg,args:M.args},x,{author:e,...Q(n.via)}),T=O.result?D(t,e,O.result):void 0;return{ok:!0,data:{...O.batch?{batch:O.batch,intent:O.intent}:{},applied:O.applied,unchanged:O.unchanged,refused:O.refused.map(v=>({record:v.id,label:v.label,error:v.message,reason:v.reason})),...O.allOrNothing?{keptNone:!0}:{},...T?{introduces:T.introduces.map(_),resolves:T.resolves.map(_)}:{},...E.length>0||M.resolved.length>0?{resolved:[...E,...M.resolved]}:{}},...T?{diff:T.diff}:{}}}case"list_suggestions":{let l=ve(t,e).map(d=>{let m=H(d.author,{graph:g.graph,schema:t.schema});return{id:d.id,intent:d.intent,by:m,at:d.at,about:d.about,...d.lineage?{basis:{untrusted:!0,authoredBy:m,text:d.lineage.basis},...d.lineage.confidence!==void 0?{confidence:d.lineage.confidence}:{}}:{}}});return{ok:!0,data:{suggestions:l},reads:[...new Set(l.flatMap(d=>d.about))]}}case"accept_suggestion":case"decline_suggestion":{let l=String(f.suggestion??""),d={author:e,...Q(n.via)},m=k.name==="accept_suggestion"?Ae(t,l,d):Oe(t,l,d),w=D(t,e,m);return{ok:!0,data:{batch:w.batch,intent:w.intent,introduces:w.introduces.map(_),resolves:w.resolves.map(_)},diff:w.diff}}case"undo_batch":{let l=String(f.batch),d=f.include??[],m=g.canUndo([l,...d]);if(!m.ok)return{ok:!1,error:m.message};let w=D(t,e,t.undo([l,...d],{...n.author?{author:n.author}:{}}));return{ok:!0,data:Fe(w),diff:w.diff}}default:return{ok:!1,error:`Unknown tool "${u}".`}}}catch(k){let{reason:g,wouldNeed:l}=pe(k);return{ok:!1,error:k instanceof Error?k.message:String(k),reason:g,...l?{wouldNeed:l}:{}}}},S=new Set,y=u=>{for(let f of S)f(u)};return{definitions:a,hash:c,...n.author?{author:n.author}:{},onDiff(u){return t.subscribe(u)},onCall(u){return S.add(u),()=>S.delete(u)},async call(u,f){let k=(a.find(m=>m.name===u)??a.find(m=>m.act===u))?.mutating??!1,g={name:u,args:f,mutating:k,at:new Date().toISOString()};y({...g,phase:"running"});let l=m=>(y(m.ok?{...g,phase:"ok",...!k&&m.reads?{reads:m.reads}:{}}:{...g,phase:"failed",error:m.error}),m),d=await h(u,f);return l(d.ok&&!k?{...d,data:(await j()).withinReadChars(u,d.data)}:d)}}}function Q(t){let n=typeof t=="function"?t():t;return n?{via:n}:{}}export{re as a,Qn as b};
@@ -1,4 +0,0 @@
1
- import{a as Ie,b as wo,c as qt,d as Mr,e as vo}from"./chunk.O2LK2AO7.js";import{a as Rr}from"./chunk.26CZTUY4.js";import{a as Er,b as Or,c as Lr}from"./chunk.3JNMSOFG.js";import{a as Ct,f as Nt,g as hn}from"./chunk.J2ITFGN3.js";import{b as fr,d as mr}from"./chunk.UT6642FC.js";import{h as Sr}from"./chunk.SE5SKFQH.js";import{e as vr,p as Pn,q as kr}from"./chunk.W3S6UXNA.js";import{b as fn}from"./chunk.4SJUTBDV.js";import{a as yr,c as yo,d as go,g as po,h as xo,i as bo,j as gr,k as Kt,l as Ut,p as Pt,q as Xt,r as br,s as wr}from"./chunk.KQT7WAQE.js";import{a as pr,b as xr}from"./chunk.PAVR5TK5.js";import{a as cr,b as Xe,c as In,d as ur,f as Tn,g as cn,h as un,i as _t,j as mo}from"./chunk.OQDETV4X.js";import{c as hr}from"./chunk.WAFDCOOG.js";import{$ as It,B as lt,C as Ln,D as Gt,G as Be,I as ao,K as xt,R as Le,S as so,W as lo,X as An,Y as At,Z as xe,a as an,b as eo,c as to,d as no,e as ar,f as sr,g as En,ga as zt,i as Ot,ia as lr,k as gt,l as oo,m as On,n as sn,pa as co,q as ro,qa as uo,ra as Tt,s as ve,t as Ee,ta as ho,u as dr,v as dn,w as Oe,x as Lt,xa as fo,y as pt,ya as ln,z as io}from"./chunk.GFF2FB2J.js";import{$ as Vt,Jb as rn,Mc as or,Pc as rr,Uc as ir,V as er,W as Rn,Y as Wt,Z as Yt,_ as Et,ba as tr,bc as Ce,da as nr}from"./chunk.6V2RG5JG.js";import{b as ce}from"./chunk.AJZBJBMO.js";var Ar={width:1200,height:760,focusSize:{width:1200,height:420},relationSize:{width:240,height:140},contextSize:{width:300,height:104},gap:16,unit:16};var Ir=(e,t)=>e?`${e.edgeKind}|${e.direction}`:`raised|${t}`,$t=(e,t,n)=>`${Ln}${e}|${t}|${n}`;function Zi(e,t){if(!Gt(e))return null;let[n="",r="",o="",a=""]=e.slice(Ln.length).split("|"),i=t.definitions.find(b=>b.kind===n),l=Vt(t,n),c=r==="raised"?null:(()=>{let b=i?.edges[r]??t.definitions.map(x=>x.edges[r]).find(Boolean);return((o==="in"?b?.inverse:b?.description)??Wt(r)).toLowerCase()})(),[s="",d=""]=a.split("="),u=s.split(":")[0],h=a===""||a==="kind"||a.startsWith("more")?null:`${tr(i,u).toLowerCase()}: ${d==="none"?"none":d}`;return[a.startsWith("more")?`More ${l.toLowerCase()}`:l,[c,h].filter(Boolean).join(", ")].filter(Boolean).join(" \u2014 ")}function Cn(e,t){let n=e.map(()=>0),r=e.map((i,l)=>({size:i,index:l})).sort((i,l)=>i.size-l.size||i.index-l.index),o=Math.max(t,e.length),a=e.length;for(let{size:i,index:l}of r){let c=Math.max(1,Math.floor(o/a));n[l]=Math.min(i,c),o-=n[l],a-=1}return n}function So(e){return Ir(e.via,e.node.kind)}function Nn(e,t){let n=[],r=0;return e.forEach((o,a)=>{if(o<=0)return;if(n.length>0&&o<=r){for(let l=0;l<o;l++)n[n.length-1].push(a);r-=o;return}let i=o;for(;i>0;){let l=Math.min(t,i);n.push(Array.from({length:l},()=>a)),i-=l,r=t-l}}),n}function Mo(e,t,n){let r=Cn(e,t*n);for(;Nn(r,t).length>n;){let o=-1;if(r.forEach((a,i)=>{a>1&&(o<0||a>r[o])&&(o=i)}),o<0)break;r[o]=r[o]-1}return r}function Ji(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 ea=5,ta=(e,t)=>{for(let n=0;n<e.length;n++)if(e[n]!==t[n])return e[n]<t[n];return!1};function Tr(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 vr(n.schema,r).groups)if(l.key!==n.exclude)if(l.buckets)for(let c of["decade","year","month"])a.push({by:l.key,bucket:c});else a.push({by:l.key});let i;return a.forEach((l,c)=>{let d=Sr(e,{group:l},o).groups;if(d.length<2||d.length>t)return;let h=d.filter(b=>b.key!=="").reduce((b,f)=>b+f.nodes.length,0)/e.length;if(h<.5||d.some(b=>b.nodes.length>e.length*.75))return;let p=[-Math.round(h*100),Math.abs(d.length-ea),c];(!i||ta(p,i.score))&&(i={grouping:{by:l.by,...l.bucket?{bucket:l.bucket}:{},groups:d},score:p})}),i?.grouping}function Ro(e,t){let n=f=>({id:f.node.id,kind:f.node.kind,node:f.node,...f.via?{via:f.via}:{}});if(e.length<=t.budget)return e.map(n);let r={...t.relevance,chosen:new Set([...t.relevance?.chosen??[],...t.selection??[]])},o=new Map;for(let f of e){let x=Ir(f.via,f.node.kind),w=o.get(x);w?w.push(f):o.set(x,[f])}let a=[...o.entries()].map(([f,x])=>({key:f,run:x,via:x[0].via,kinds:[...new Set(x.map(w=>w.node.kind))],members:[],whole:!1,extra:0})),i=Cn(a.map(f=>f.run.length),t.budget);a.forEach((f,x)=>f.whole=f.run.length<=i[x]);let l=a.filter(f=>!f.whole),c=a.filter(f=>f.whole).reduce((f,x)=>f+x.run.length,0),s=Math.max(l.length,t.budget-c);for(let f of l){f.members=Ji(f.run.map(w=>w.node),r,t.graph);let x=s-(l.length-1);f.kinds.length>1&&f.kinds.length<=x?f.byKind=!0:f.kinds.length===1&&(f.grouping=Tr(f.members,x,{schema:t.schema,graph:t.graph,...f.via?{exclude:f.via.edgeKind}:{},...t.today?{today:t.today}:{}}))}let d=f=>f.byKind?f.kinds.length:f.grouping?f.grouping.groups.length:1;for(;l.reduce((f,x)=>f+d(x),0)>s;){let f=[...l].filter(x=>d(x)>1).sort((x,w)=>d(w)-d(x))[0];if(!f)break;f.grouping=void 0,f.byKind=!1}s-=l.reduce((f,x)=>f+d(x),0);let u=f=>f.byKind?f.kinds.some(x=>t.expanded.has($t(x,f.key,"kind"))):f.grouping?.groups.some(x=>t.expanded.has($t(f.kinds[0],f.key,ko(f.grouping,x.key)))),h=l.filter(f=>!f.grouping&&!f.byKind?!0:u(f)),p=Cn(h.map(f=>f.members.length),Math.max(0,s));h.forEach((f,x)=>f.extra=s>0?p[x]:0);let b=[];for(let f of a){let{key:x,via:w}=f;if(f.whole){b.push(...f.run.map(n));continue}let y=g=>({id:g.id,kind:g.kind,node:g,...w?{via:w}:{}}),O=new Map(f.run.map((g,S)=>[g.node.id,S])),I=(g,S,C)=>{let E=[...g.slice(0,S)].sort((G,Y)=>O.get(G.id)-O.get(Y.id));b.push(...E.map(y));let D=g.slice(S);if(D.length===0)return;let A=D[0].kind;b.push({id:$t(A,x,C?`more:${C}`:"more"),kind:A,...w?{via:w}:{},aggregate:{kind:A,memberIds:D.map(G=>G.id),label:S>0?`${D.length} more ${t.plural(A).toLowerCase()}`:`${D.length} ${t.plural(A).toLowerCase()}`,opens:{in:"picture",focus:Oe(A),within:C?{filter:C}:{}}}})},W=w&&t.focusId?`${w.edgeKind}:${t.focusId}`:void 0;if(f.byKind){let g=f.kinds.find(S=>t.expanded.has($t(S,x,"kind")));for(let S of f.kinds){let C=f.members.filter(E=>E.kind===S);if(S===g){let E=f.extra+1;C.length<=E?b.push(...C.map(y)):I(C,E-1,W);continue}b.push({id:$t(S,x,"kind"),kind:S,...w?{via:w}:{},aggregate:{kind:S,memberIds:C.map(E=>E.id),label:t.plural(S),opens:{in:"place"}}})}continue}let H=f.grouping;if(!H){I(f.members,f.extra,W);continue}let X=f.kinds[0],te=H.groups.find(g=>t.expanded.has($t(X,x,ko(H,g.key))));for(let g of H.groups){if(g===te){let S=f.members.filter(E=>g.nodes.includes(E)),C=f.extra+1;if(S.length<=C)b.push(...S.map(y));else{let E=g.key!==""&&!g.key.includes(",")&&!H.bucket,D=[W,E?`${H.by}:${g.key}`:void 0].filter(Boolean).join(",")||void 0;I(S,C-1,D)}continue}b.push({id:$t(X,x,ko(H,g.key)),kind:X,...w?{via:w}:{},aggregate:{kind:X,memberIds:f.members.filter(S=>g.nodes.includes(S)).map(S=>S.id),label:g.label.charAt(0).toUpperCase()+g.label.slice(1),opens:{in:"place"}}})}}return b}var ko=(e,t)=>`${e.by}${e.bucket?`:${e.bucket}`:""}=${t||"none"}`;function Cr(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 Bt(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 Eo=(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},mn=4,Pr=.45;function Oo(e,t,n,r={},o={}){let a={};for(let v of e)a[v.kind]=v.count;let i={x:(r.left??0)+8,y:(r.top??0)+8,width:n.width-(r.left??0)-(r.right??0)-16,height:n.height-(r.top??0)-(r.bottom??0)-16},l=o.avoid??[],c=o.tilt??.5,s=v=>v.nameplate??{width:120,height:34,short:{width:90,height:20}},d=v=>e.map(M=>{let L=v.get(M.kind);return{card:M,plot:L,center:qt(L.col+L.side/2,L.row+L.side/2,1,c)}}),u=(v,M)=>{let L=1/0,B=-1/0,$=1/0,R=-1/0;for(let{card:N,plot:F,center:z}of v){let V=z.x*M,U=z.y*M,ae=F.side*M/2,oe=N.opened>0?s(N).width:s(N).short.width;L=Math.min(L,V-Math.max(ae+(N.count>12?30:0),oe/2)),B=Math.max(B,V+Math.max(ae,oe/2)),$=Math.min($,U-ae*c-M*Pr),R=Math.max(R,U+ae*c+mn+s(N).short.height)}return{minX:L,maxX:B,minY:$,maxY:R}},h=v=>{let M=4,L=160;for(let B=0;B<24;B++){let $=(M+L)/2,R=u(v,$);R.maxX-R.minX<=i.width&&R.maxY-R.minY<=i.height?M=$:L=$}return M},p=v=>{let M={...o.order?{order:o.order}:{},counts:a,...o.plots?{plots:o.plots}:{},pitch:v},L=wo(t,M),B=wo(t,{...M,upright:!0}),$=h(d(L)),R=h(d(B)),N=n.height>n.width&&R>=$?B:L;return{map:N,fitted:N===B?R:$}},b=[],f=new Map,x=0,w=(v,M={x:0,y:0})=>{let L=u(b,v),B=i.x+i.width/2-(L.minX+L.maxX)/2+M.x,$=i.y+i.height/2-(L.minY+L.maxY)/2+M.y;return{originX:B,originY:$,cell:v}},y=v=>{let{originX:M,originY:L,cell:B}=v,$=b.map(({center:F})=>F.y),R=Math.max(...$),N=Math.min(...$);return b.map(({card:F,plot:z,center:V})=>{let U=M+V.x*B,ae=L+V.y*B,oe=z.side*B/2,J=oe*c,he=R===N?.5:(V.y-N)/(R-N);return{card:F,plot:z,x:U,y:ae,halfW:oe,halfH:J,depth:1-he*.65}})},O=(v,M=!0)=>{let L=[];return[...v].sort(($,R)=>(R.card.weight??R.card.count)-($.card.weight??$.card.count)||e.indexOf($.card)-e.indexOf(R.card)).filter($=>[s($.card),s($.card).short].some(R=>{let N=H($,R),F=(!M||N.x>=0&&N.y>=0&&N.x+N.width<=n.width&&N.y+N.height<=n.height)&&!L.some(z=>Bt(N,z,4))&&!v.some(z=>z!==$&&Eo(N,z,z.halfW,z.halfH))&&!l.some(z=>Bt(N,z,0));return F&&L.push(N),F})).length},I=v=>v.card.marquee?{x:v.x-v.card.marquee.width/2,y:v.y+v.halfH+mn+s(v.card).height,width:v.card.marquee.width,height:v.card.marquee.height}:null,W=(v,M,L)=>L.some(B=>{if(B===M)return!1;let $=I(B);return $!==null&&Bt(v,$,4)}),H=(v,M,L="under")=>L==="aside"?{x:v.x+v.halfW+mn,y:v.y-M.height/2,width:M.width,height:M.height}:L==="above"?{x:v.x-M.width/2,y:v.y-v.halfH-mn-Pr*S.cell-M.height,width:M.width,height:M.height}:{x:v.x-M.width/2,y:v.y+v.halfH+mn,width:M.width,height:M.height},X=v=>v.some(M=>l.some(L=>Eo(L,M,M.halfW,M.halfH)||Bt(L,H(M,s(M.card).short),0))),te=v=>v.every(M=>{let L=H(M,s(M.card).short);return M.x-M.halfW>=0&&M.x+M.halfW<=n.width&&M.y-M.halfH>=0&&L.x>=0&&L.x+L.width<=n.width&&L.y+L.height<=n.height}),g={pitch:Ie,said:-1};for(let v of[Ie,Ie+1,Ie+2,Ie+3,Ie+5,Ie+7]){({map:f,fitted:x}=p(v)),b=d(f);let M=O(y(w(x)));if(M>g.said&&(g={pitch:v,said:M}),M===e.length)break}(g.pitch!==Ie+7||g.said!==e.length)&&({map:f,fitted:x}=p(g.pitch),b=d(f));let S=w(x);if(l.length>0&&X(y(S))){let v;for(let M=1;M>=.3&&!v;M-=.05){let L=x*M,B=Math.max(...l.map(R=>R.width))/2+L,$=Math.max(...l.map(R=>R.height))/2+L/2;for(let R of[0,.5,.75,1,1.25]){for(let[N,F]of[[1,0],[-1,0],[0,1],[0,-1],[1,1],[-1,1],[1,-1],[-1,-1]]){let z=w(L,{x:N*B*R,y:F*$*R}),V=y(z);if(!X(V)&&te(V)){v=z;break}if(R===0)break}if(v)break}}v&&(S=v)}let C=(v,M)=>{let L={x:n.width/2,y:n.height/2};return{cell:v.cell*M,originX:L.x+(v.originX-L.x)*M,originY:L.y+(v.originY-L.y)*M}},E=1;if(O(y(S))<e.length){let v={said:O(y(S),!1),area:1/0,pitch:-1,by:1},M={map:f,shape:b,fitted:x,where:S};for(let B of[Ie,Ie+1,Ie+2,Ie+3,Ie+5,Ie+7]){({map:f,fitted:x}=p(B)),b=d(f);let $=w(x);for(let R=1;R<=3.001;R+=.1){let N=O(y(C($,R)),!1),F=u(b,x*R),z=(F.maxX-F.minX)*(F.maxY-F.minY);if((N>v.said||N===v.said&&z<v.area)&&(v={said:N,area:z,pitch:B,by:R}),N===e.length)break}}v.pitch<0?{map:f,shape:b,fitted:x,where:S}=M:({map:f,fitted:x}=p(v.pitch),b=d(f),E=v.by,S=C(w(x),E));let L=y(S).filter(B=>o.keep?.includes(B.card.kind));if(L.length>0){let B=L.flatMap(V=>[{x:V.x-V.halfW,y:V.y-V.halfH,width:V.halfW*2,height:V.halfH*2},H(V,s(V.card))]),$=Math.min(...B.map(V=>V.x)),R=Math.max(...B.map(V=>V.x+V.width)),N=Math.min(...B.map(V=>V.y)),F=Math.max(...B.map(V=>V.y+V.height)),z=(V,U,ae)=>U-V>ae-16?ae/2-(V+U)/2:V<8?8-V:U>ae-8?ae-8-U:0;S={...S,originX:S.originX+z($,R,n.width),originY:S.originY+z(N,F,n.height)}}}let D=o.zoom&&o.zoom!==1?o.zoom:1;D!==1&&(S=C(S,D));let A=y(S),G=[],Y=new Map,_=[...A].sort((v,M)=>(M.card.weight??M.card.count)-(v.card.weight??v.card.count)||e.indexOf(v.card)-e.indexOf(M.card));for(let v of _){let M=[["full",s(v.card),"under"],["short",s(v.card).short,"under"]],L="none",B=v===_[0],$=(N,F)=>M.filter(([z])=>z.startsWith(F)).map(([z,V,U])=>[z,V,U,N]),R=B?[...$(!1,"full"),...$(!1,"short"),...$(!0,"full"),...$(!0,"short")]:M.map(([N,F,z])=>[N,F,z,!1]);for(let[N,F,z,V]of R){let U=H(v,F,z);if((D!==1||E!==1||U.x>=0&&U.y>=0&&U.x+U.width<=n.width&&U.y+U.height<=n.height)&&!G.some(J=>Bt(U,J,4))&&(V||!A.some(J=>J!==v&&Eo(U,J,J.halfW,J.halfH)))&&!W(U,v,A)&&!l.some(J=>Bt(U,J,0))){L=N,G.push(U);break}}Y.set(v.card.id,L)}let k=A.map(v=>({id:v.card.id,x:v.x-v.halfW,y:v.y-v.halfH,width:v.halfW*2,height:v.halfH*2+(v.card.opened>0?Math.max(v.card.openedMin??0,v.card.opened):0),depth:v.depth,plot:v.plot,nameplate:Y.get(v.card.id)??"none"})),T=u(b,S.cell),Q={cell:S.cell,originX:S.originX,originY:S.originY,pan:o.pan??{x:0,y:0},extent:{x:S.originX+T.minX,y:S.originY+T.minY,width:T.maxX-T.minX,height:T.maxY-T.minY},openedShare:1,...c!==.5?{tilt:c}:{},...A.some(v=>v.card.marquee)?{showings:A.flatMap(v=>{let M=I(v);return M?[{id:v.card.id,x:M.x-(v.x-v.halfW),y:M.y-(v.y-v.halfH),width:M.width,height:M.height}]:[]})}:{}};return{placed:k,frame:Q,map:f}}function bt(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 $n=48;function Lo(e){if(!e.city)return[];let{width:t,height:n}=e.visible??e,r=[];for(let o of e.nodes){if(!o.id.startsWith("kind:")||Math.round(o.plane)!==2)continue;let a=o.x+o.width/2,i=o.y+o.height/2,l=a<0?"left":a>t?"right":i<0?"top":i>n?"bottom":null;if(!l)continue;let c=l==="left"||l==="right",s=c?Math.max(0,Math.min(n,i)):Math.max(0,Math.min(t,a)),d=(p,b)=>p<b/4?b/4-p:p>b*3/4?b*3/4-p:0,u=(p,b)=>p<$n?$n-p:p>b-$n?b-$n-p:0,h=c?{x:d(a,t),y:u(i,n)}:{x:u(a,t),y:d(i,n)};r.push({id:o.id,kind:o.id.slice(5),side:l,along:s,by:h})}return r}function Ao(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 na={rankOf:()=>{},parentOf:()=>{}};function Nr(e,t){if(t.size===0)return na;let n=e.kinds,r=new Map,o=(s,d)=>{s!==d&&((r.get(s)??r.set(s,new Set).get(s)).add(d),(r.get(d)??r.set(d,new Set).get(d)).add(s))};for(let s of n){let d=e.tryDefinition(s);if(d)for(let u of Object.values(d.edges??{})){let h=u.to==="*"?n:u.to;for(let p of h)o(s,p)}}let a=new Map,i=new Map,l=[...t].filter(s=>n.includes(s));for(let s of l)a.set(s,0);let c=0;for(;l.length>0;){c+=1;let s=[];for(let d of[...l].sort((u,h)=>n.indexOf(u)-n.indexOf(h)))for(let u of[...r.get(d)??[]].sort((h,p)=>n.indexOf(h)-n.indexOf(p)))a.has(u)||(a.set(u,c),c===2&&i.set(u,d),s.push(u));l=s}return{rankOf:s=>{let d=a.get(s);if(d!==0)return d===1?"primary":"secondary"},parentOf:s=>i.get(s)}}function $r(e,t,n,r,o={}){if(n){let a=new Map;for(let i of e.allEdges()){if(r&&i.kind!==r)continue;let l=i.from===n.id?i.to:i.to===n.id?i.from:null;if(l===null||l===n.id)continue;let c=e.getNode(l);if(!c||a.has(l))continue;let s=i.from===n.id?"out":"in",d=s==="out"?n.kind:c.kind,u=oa(t,d,i.kind,s);a.set(l,{node:c,via:{edgeKind:i.kind,direction:s,...u?{description:u}:{}}})}if(a.size>0){let i=l=>`${l.via.edgeKind}|${l.via.description??""}`;return[...a.values()].sort((l,c)=>(i(l)<i(c)?-1:i(l)>i(c)?1:0)||lt(l.node,c.node))}}if(n){let a=o[n.id]??[],i=new Set,l=[];for(let c of a){if(c===n.id||i.has(c))continue;let s=e.getNode(c);s&&(r&&r!=="judges"&&s.kind!==r||(i.add(c),l.push({node:s,via:{edgeKind:"judges",direction:"out",description:"what it finds wrong"}})))}if(l.length>0)return l.sort((c,s)=>lt(c.node,s.node))}return r?e.allNodes().filter(a=>a.kind===r).sort(lt).map(a=>({node:a})):[]}function oa(e,t,n,r){let a=e.tryDefinition(t)?.edges?.[n];return r==="out"?a?.description:a?.inverse}function Br(e,t,n){let r=new Map,o=[...t.values()].sort((s,d)=>s.plane-d.plane);for(let s of o)for(let d of s.aggregate?.memberIds??[])!t.has(d)&&!r.has(d)&&r.set(d,s.id);let a=s=>t.get(s)??t.get(r.get(s)??""),i=new Map,l=new Map,c=new Map;for(let s of e.allEdges()){let d=a(s.from),u=a(s.to);if(!d||!u||d.id===u.id&&!(n.overview&&d.aggregate&&d.plane===2))continue;let h=`${s.kind}:${d.id}:${u.id}`,p=i.get(h);if(p){let b=`${s.from}
2
- ${s.to}`,f=l.get(h);if(f.has(b))continue;if(f.add(b),c.get(h).push({from:s.from,to:s.to}),p.single){let{single:x,...w}=p;i.set(h,w)}continue}l.set(h,new Set([`${s.from}
3
- ${s.to}`])),c.set(h,[{from:s.from,to:s.to}]),i.set(h,{id:h,kind:s.kind,from:d.id,to:u.id,edges:[{from:s.from,to:s.to}],single:{from:s.from,to:s.to},...d.id===u.id?{loop:!0}:{},x1:d.x+d.width/2,y1:d.y+d.height/2,x2:u.x+u.width/2,y2:u.y+u.height/2})}return[...i.values()].map(s=>({...s,edges:c.get(s.id)})).sort(lt)}var Hr=.85,ra=60,Io=160;function ia(e,t,n,r,o,a=Hr){let i=e*t.width+Math.max(0,e-1)*n,l=Math.max(n,(r-i)/2);return Array.from({length:e},(c,s)=>({x:l+s*(t.width+n),y:o,depth:a}))}function aa(e,t,n,r,o){let a=e*t.width+Math.max(0,e-1)*n,i=Math.max(n,(r-a)/2);return Array.from({length:e},(l,c)=>({x:i+c*(t.width+n),y:o}))}function Bn(e,t,n,r={}){let o={...Ar,...r},a=Math.max(8,o.unit??16)/16,i=o.inset?.left??0,l=n.overview?Math.max(0,o.dock?.right??0):0,c=n.overview?Math.max(0,o.dock?.bottom??0):0,s=o.width-l-i-(o.inset?.right??0),d=[],u=new Map,h=m=>n.past===!0||er(t.tryDefinition(m.kind),m,o.today),p=new Set(r.hiddenKinds??[]),b=m=>!p.has(m.kind),f=n.focusId?pt(n.focusId).filter(m=>t.tryDefinition(m)!==void 0).filter(m=>!p.has(m)):[];n.focusId&&pt(n.focusId).length>0&&f.length===0&&(n={...n,focusId:null});let x=n.focusId?e.getNode(n.focusId):void 0;x&&!b(x)&&(n={...n,focusId:null},f=[]);let w=f.length>0?[...e.allNodes()].filter(m=>f.includes(m.kind)).sort(lt):[],y=w.filter(b).filter(h),O=w.length-y.length,I=n.focusId&&f.length===0?e.getNode(n.focusId):void 0,W=n.zoom===!0&&!n.overview&&n.focusId!==null,H=Math.max(56,o.height*.062),X=Math.min(o.height*.895,o.height-H),te=W?I!==void 0?{focusY:o.height*.03,focusH:o.height*.58,relationY:o.height*.645,relationH:o.height*.2,contextY:X,contextH:H}:{focusY:o.height*.03,focusH:o.height*.71,relationY:o.height*.765,relationH:o.height*.1,contextY:X,contextH:H}:I===void 0?{focusY:o.height*.045,focusH:o.height*.62,relationY:o.height*.68,relationH:o.height*.2,contextY:o.height*.918,contextH:o.height*.082}:(()=>{let m=o.height,j=m*.04,K=Math.max(m*.42,Math.min(m*.56,300)),ee=j+K+m*.06;return{focusY:j,focusH:K,relationY:ee,relationH:Math.max(m*.12,m*.878-m*.068-ee),contextY:m*.878,contextH:m*.092}})(),g=Math.min(o.headroom??0,te.focusY+te.focusH*.2),S=g>te.focusY?{...te,focusY:g,focusH:te.focusH-(g-te.focusY)}:te,C=m=>Math.min(o.gap*m,Math.round(s*.1)),E=W?Math.min(880,s-C(5)):Math.min(700,s-C(6)),D=W?s-C(5):Math.min(o.focusSize.width,s-C(6)),A=(m,j,K)=>({width:m===0?j:Math.min(j,(s-o.gap*(m+1))/m),height:K}),G=(m,j,K)=>{let ee=A(m,j,K),we=Math.min(j,Io*a,s-o.gap*2);return ee.width>=we?ee:{width:we,height:K}},Y=m=>Math.max(1,Math.floor((s-o.gap)/(Math.min(m,Io*a,s-o.gap*2)+o.gap))),_=new Set(n.expanded),k=n.overview?[]:$r(e,t,I,n.relation,o.judged).filter(m=>b(m.node)).filter(m=>h(m.node)),T=k.length>0?S.focusH:S.contextY-S.focusY-o.gap*2,Q=D,v=o.height,M=Math.min(s*.5/Q,o.height*.48/v),L=Q*M,B=v*M,$=new Set(r.plainGroups??[]),R=n.overview&&!I&&f.length>0&&n.focusId!==null,N=R&&f.length>0&&f.every(m=>$.has(m));if(R)for(let m of f)N&&r.besideTheMap!==!0?_.add(ve(m)):_.delete(ve(m));let F=R&&!N&&f.length===1?f[0]:void 0,z=F!==void 0&&(r.screens?.[F]?.length??0)>0,V,U=n.overview===!0&&I!==void 0&&r.besideTheMap===!0;n.overview&&(I||f.length>0)&&n.focusId&&!N&&!z&&!(R&&r.besideTheMap===!0)&&!U?(V={x:i+(s-L)/2,y:o.height*.53-B/2,width:L,height:B},on({id:n.focusId,kind:I?I.kind:f[0],plane:0,x:V.x,y:V.y,width:L,height:B,natural:{width:Q,height:v},...I?{}:{aggregate:{kind:f.join("+"),memberIds:y.map(m=>m.id),label:r.plurals?.[n.focusId]??f.map(m=>Et(t,m)).join(" and "),...O>0?{retired:O}:{}}}})):n.overview||(I?on({id:I.id,kind:I.kind,plane:0,x:i+(s-E)/2,y:S.focusY,width:E,height:T}):f.length>0&&n.focusId&&on({id:n.focusId,kind:f[0],plane:0,x:i+(s-D)/2,y:S.focusY,width:D,height:T,aggregate:{kind:f.join("+"),memberIds:y.map(m=>m.id),label:r.plurals?.[n.focusId]??f.map(m=>Et(t,m)).join(" and "),...O>0?{retired:O}:{}}}));let ae=26,oe=52,J=22,he=Math.round(o.relationSize.width*.75),ye=Math.max(1,Math.floor((s-o.gap)/(he+o.gap))),Ne=o.unit/16,Ve=Math.max(2,Math.floor((S.relationH+o.gap)/(ae*Ne+o.gap))),re=k.length>ye*Ve,Ae={schema:t,graph:e,focusId:I?.id,expanded:_,...o.relevance?{relevance:o.relevance}:{},...n.selection?{selection:n.selection}:{},plural:m=>Et(t,m),...o.today?{today:o.today}:{}},je=re?Math.max(o.gap,J*Ne):o.gap,ne,Je;if(!re)ne=k.map(m=>({id:m.node.id,kind:m.node.kind,node:m.node,...m.via?{via:m.via}:{}})),Je=Array.from({length:Math.max(1,Math.ceil(ne.length/ye))},(m,j)=>Array.from({length:Math.min(ye,ne.length-j*ye)},(K,ee)=>j*ye+ee));else{let m=Math.max(1,Math.floor((S.relationH+je)/(oe*Ne+je))),j=new Map;for(let me of k){let Re=So(me),Rt=j.get(Re);Rt?Rt.push(me):j.set(Re,[me])}let K=Mo([...j.values()].map(me=>me.length),ye,m),ee=[...j.values()].map((me,Re)=>Ro(me,{...Ae,budget:K[Re]}));ne=ee.flat();let we=ee.map((me,Re)=>ee.slice(0,Re).reduce((Rt,Jn)=>Rt+Jn.length,0)),Ue=ee.map(()=>0);Je=Nn(ee.map(me=>me.length),ye).map(me=>me.map(Re=>we[Re]+Ue[Re]++))}let ht=Je.length,jt=ht===1?S.relationH:(S.relationH-je*(ht-1))/ht,Ge=A(Math.max(...Je.map(m=>m.length),1),ne.length<=2?Math.round(o.relationSize.width*1.35):o.relationSize.width,jt),$e=[];Je.forEach((m,j)=>{let K=aa(m.length,Ge,o.gap,s,S.relationY+j*(jt+je));m.forEach((ee,we)=>$e[ee]={...K[we],x:K[we].x+i})}),ne.forEach((m,j)=>{let K=$e[j];on({id:m.id,kind:m.kind,plane:1,x:K.x,y:K.y,width:Ge.width,height:Ge.height,...m.via?{via:m.via}:{},...m.aggregate?{aggregate:m.aggregate}:{},...re&&!m.aggregate?{compact:!0}:{}})});let nt=new Set(u.keys());for(let m of y)nt.add(m.id);let We=new Map;for(let m of e.allNodes()){let j=We.get(m.kind);j?j.push(m):We.set(m.kind,[m])}let ze=new Set(f.length>0?f:I?[I.kind]:[]),_e=[];for(let m of t.kinds){if(p.has(m))continue;let j=We.get(m)??[],K=j.filter(h);_e.push({id:ve(m),kind:m,members:K.sort(lt),retired:j.length-K.length,...ze.has(m)?{focused:!0}:{}})}for(let m of _e)m.kind===n.relation&&(m.raised=!0);_e.sort(lt);let et=Nr(t,ze),ot=!n.overview&&t.kinds.some(m=>et.rankOf(m)==="primary"),Me=[];for(let m of _e)if(!n.overview&&_.has(m.id)&&m.members.length>0)for(let j of m.members)Me.push({id:j.id,kind:j.kind});else{let j=ot?et.rankOf(m.kind):void 0,K=j==="secondary"?et.parentOf(m.kind):void 0;Me.push({id:m.id,kind:m.kind,...m.raised?{raised:!0}:{},...m.focused?{focused:!0}:{},...n.overview&&_.has(m.id)?{opened:!0}:{},...j?{rank:j}:{},...K&&!_.has(ve(K))?{nestedUnder:ve(K)}:{},aggregate:{kind:m.kind,memberIds:m.members.map(ee=>ee.id),label:r.plurals?.[m.kind]??Et(t,m.kind),...m.retired>0?{retired:m.retired}:{}}})}let rt=2;if(Me.length<=Y((W?240:o.contextSize.width)*a))for(let m of Me)delete m.nestedUnder;let ft=new Map;for(let m of Me){if(m.nestedUnder===void 0)continue;let j=ft.get(m.nestedUnder)??0;j>=rt?delete m.nestedUnder:ft.set(m.nestedUnder,j+1)}let St=Me.filter(m=>m.nestedUnder!==void 0),Ke=Me.filter(m=>m.nestedUnder===void 0),ie=Y((W?240:o.contextSize.width)*a),ke=!n.overview&&Ke.length>ie,Te=Math.max(0,ie-1),at=m=>m.focused?0:m.raised?1:2,mt=new Set([...Ke].map((m,j)=>({item:m,at:j})).sort((m,j)=>at(m.item)-at(j.item)||m.at-j.at).slice(0,Te).map(({item:m})=>m.id)),yt=new Set(ke?Ke.filter(m=>!mt.has(m.id)).map(m=>m.id):[]),st=St.filter(m=>!yt.has(m.nestedUnder)),P=St.filter(m=>yt.has(m.nestedUnder)),se=ke?[...Ke.filter(m=>mt.has(m.id)),{id:dr,kind:"",beyond:[...Ke.filter(m=>yt.has(m.id)),...P].map(m=>m.kind)}]:Ke,fe=n.overview?{width:Math.min(220,s/6.5),height:Math.min(92,o.height*.125)}:G(se.length,(W?240:o.contextSize.width)*a,S.contextH),Se=o.relevance?.flagged,dt=(m,j)=>{let K=vo(t,m);if(!K)return{};let ee=K.values.map(()=>0),we=0;for(let Ue of j){let me=K.values.indexOf(e.getNode(Ue)?.[K.field]);me<0?we++:ee[me]++}return{states:{field:K.field,values:[...K.values.map((Ue,me)=>({value:Ue,tier:K.tiers[me],count:ee[me]})),...we>0?[{value:null,tier:"waiting",count:we}]:[]]}}},Pe=n.overview?Oo(se.map(m=>{let j=m.aggregate?.memberIds??[],K=Se?j.filter(ee=>Se.has(ee)).length:0;return{id:m.id,kind:m.kind,count:j.length,opened:_.has(m.id)?Ut(Kt(j.length))*a:0,openedMin:_.has(m.id)?Ut(Math.min(bo,Kt(j.length)))*a:0,nameplate:Cr(m.aggregate?.label??Et(t,m.kind),j.length,K,vo(t,m.kind)!==void 0,a),weight:K*1e3+j.length,...f.includes(m.kind)&&(r.screens?.[m.kind]?.length??0)>0?{marquee:{width:go+12,height:po(r.screens[m.kind].map(ee=>ee.title),go,r.nameWidth)+8}}:{}}}),t,{width:o.width-l,height:o.height-c},o.chrome?{...o.inset,right:Math.min(o.inset?.right??0,8)}:o.inset??{},{...o.cityOrder?{order:o.cityOrder}:{},...o.plots?{plots:o.plots}:{},...r.cityZoom&&r.cityZoom!==1?{zoom:r.cityZoom}:{},keep:[...n.selection??[],...n.focusId?[n.focusId]:[]].flatMap(m=>m.startsWith("kind:")?[m.slice(5)]:m.startsWith("aggregate:")&&!m.includes("|")?[m.slice(10)]:U&&m===I?.id?[I.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,en=new Map(Pe?.placed.map(m=>[m.id,m.plot])??[]),tn=new Map(Pe?.placed.map(m=>[m.id,m.nameplate])??[]),nn=Pe?Pe.placed.map(({x:m,y:j,depth:K,width:ee,height:we})=>({x:m,y:j,depth:K,width:ee,height:we})):ia(se.length,fe,o.gap,s,S.contextY,W?.97:Hr).map(m=>({...m,x:m.x+i})),Xn=.74,Mt=.8,qi=52*a,Qi=86*a,qn=(m,j)=>Math.min(1,m+(1-m)*j),Qn=new Map;se.forEach((m,j)=>{let K=nn[j],ee=K.width??fe.width,we=K.height??fe.height,Ue=m.rank==="secondary"?Xn:1,me=Pe?ee:Math.max(Math.min(ee,Io*a),ee*Ue),Re=Pe?we:Math.max(ra*a,we*Ue);Qn.set(m.id,{x:K.x+(ee-me)/2,y:K.y+(we-Re),depth:m.rank==="secondary"?qn(K.depth,.5):K.depth,width:me,height:Re})});let Sn=[],Mn=nn[nn.length-1],Zn=new Map;for(let m of st)Zn.set(m.nestedUnder,(Zn.get(m.nestedUnder)??0)+1);let Jo=new Map;for(let m of st){let j=Qn.get(m.nestedUnder);if(j){let K=Zn.get(m.nestedUnder)??1,ee=Jo.get(m.nestedUnder)??0;Jo.set(m.nestedUnder,ee+1);let we=.98,Ue=fe.width*Mt,me=Math.max(Qi,Math.min(Ue,j.width/(we*(K-1)+1))),Re=Math.max(qi,fe.height*Mt*(me/Ue)),Rt=me*we,Jn=(K-1)*Rt+me;Sn.push({...m,x:j.x+(j.width-Jn)/2+ee*Rt,y:Math.max(0,j.y-Re+Math.min(Re*.5,16)),width:me,height:Re,depth:qn(j.depth,.8)})}else if(Mn){let K=fe.width*Mt,ee=fe.height*Mt;Sn.push({...m,x:Mn.x,y:Mn.y,width:K,height:ee,depth:qn(Mn.depth??1,.8)})}}for(let m of se)Sn.push({...m,...Qn.get(m.id)});return Sn.forEach(m=>{on({id:m.id,kind:m.kind,plane:2,x:m.x,y:m.y,width:m.width,height:m.height,...m.aggregate?{aggregate:m.aggregate}:{},...m.raised?{raised:!0}:{},...m.focused?{focused:!0}:{},...m.opened?{opened:!0}:{},...m.opened?{openedRows:Math.max(1,Math.floor((Math.max(Ut(Math.min(bo,Kt(m.aggregate?.memberIds.length??0))),Ut(Kt(m.aggregate?.memberIds.length??0))*(Pe?.frame.openedShare??1))-gr)/xo))}:{},...m.rank?{rank:m.rank}:{},...m.nestedUnder?{nestedUnder:m.nestedUnder}:{},...m.beyond?{beyond:m.beyond}:{},...en.has(m.id)?{plot:en.get(m.id)}:{},...tn.has(m.id)?{nameplate:tn.get(m.id)}:{},...Pe&&m.aggregate?dt(m.kind,m.aggregate.memberIds):{},depth:m.depth})}),{nodes:d,connectors:Br(e,u,n),width:o.width,height:o.height,...Pe?{city:Pe.frame}:{},...l>0||c>0?{visible:{width:o.width-l,height:o.height-c}}:{}};function on(m){let j=n.overview&&Ee(m.id)!==null?void 0:n.pins[m.id],K=j?{...m,x:j.x,y:j.y,pinned:!0}:{...m,pinned:!1},ee=n.pan?{...K,x:K.x+n.pan.x,y:K.y+n.pan.y}:K;d.push(ee),u.set(ee.id,ee)}}function To(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 Po(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 be=(e,t,n)=>e+(t-e)*n;function Dr(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}var Fr=new WeakMap;function sa(e){let t=Fr.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},Fr.set(e,t),t}var jr=new WeakMap;function Wr(e,t){let n=jr.get(t);if(n||jr.set(t,n=new WeakMap),n.has(e))return n.get(e);let r=da(e,t);return n.set(e,r),r}function da(e,t){let{byId:n,groupsOf:r}=sa(t);if(e.screenOf!==void 0){let i=n.get(ve(e.screenOf));if(i)return{...e,x:i.x,y:i.y,width:i.width,height:i.height}}if(Lt(e.id)||Ee(e.id)!==null){let i=(e.aggregate?.memberIds??[]).map(d=>n.get(d)).filter(d=>d!==void 0);if(i.length===0)return null;let l=i.map(Dr),c=l.reduce((d,u)=>d+u.x,0)/l.length,s=l.reduce((d,u)=>d+u.y,0)/l.length;return{...e,x:c-e.width/2,y:s-e.height/2}}let o=r.get(e.id)?.find(i=>i.id===ve(e.kind)||i.id===Oe(e.kind));if(!o)return null;let a=Dr(o);return{...e,x:a.x-e.width/2,y:a.y-e.height/2}}function Ht(e,t,n){let r=Math.max(0,Math.min(1,n)),o=new Map(e.nodes.map(d=>[d.id,d])),a=new Map(t.nodes.map(d=>[d.id,d])),i=[];for(let[d,u]of o){let h=a.get(d);if(h){i.push(Co(u,h,r,1));continue}let p=Wr(u,t)??u;i.push(Co(u,p,r,1-r))}for(let[d,u]of a){if(o.has(d))continue;let h=Wr(u,e)??u;i.push(Co(h,u,r,r))}let l=new Map(e.connectors.map(d=>[d.id,d])),c=new Map(t.connectors.map(d=>[d.id,d])),s=[];for(let[d,u]of l){let h=c.get(d);s.push(h?{...la(u,h,r),opacity:1}:{...u,opacity:1-r})}for(let[d,u]of c)l.has(d)||s.push({...u,opacity:r});return{nodes:i.filter(d=>d.opacity>0).sort((d,u)=>d.id<u.id?-1:d.id>u.id?1:0),connectors:s.filter(d=>d.opacity>0).sort((d,u)=>d.id<u.id?-1:d.id>u.id?1:0),width:be(e.width,t.width,r),height:be(e.height,t.height,r),t:r,...Yr(e.city,t.city,r)?{city:Yr(e.city,t.city,r)}:{}}}function Yr(e,t,n){return e?t?{cell:be(e.cell,t.cell,n),...e.tilt!==void 0||t.tilt!==void 0?{tilt:be(e.tilt??.5,t.tilt??.5,n)}:{},originX:be(e.originX,t.originX,n),originY:be(e.originY,t.originY,n),pan:{x:be(e.pan.x,t.pan.x,n),y:be(e.pan.y,t.pan.y,n)},extent:{x:be(e.extent.x,t.extent.x,n),y:be(e.extent.y,t.extent.y,n),width:be(e.extent.width,t.extent.width,n),height:be(e.extent.height,t.extent.height,n)}}:e:t}function Co(e,t,n,r){return{id:t.id,kind:t.kind,plane:be(e.plane,t.plane,n),x:be(e.x,t.x,n),y:be(e.y,t.y,n),width:be(e.width,t.width,n),height:be(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:be(e.depth??1,t.depth,n)},...t.natural?{natural:t.natural}:{}}}function la(e,t,n){return{...t,x1:be(e.x1,t.x1,n),y1:be(e.y1,t.y1,n),x2:be(e.x2,t.x2,n),y2:be(e.y2,t.y2,n)}}function Hn(e){let t=Math.max(0,Math.min(1,e));return t<.5?4*t*t*t:1-(-2*t+2)**3/2}function ca(e,t){let n=[];for(let o=0;o<e.length;o+=1){let a=e[o],i=e[(o+1)%e.length];if(a.y===i.y)continue;let l=Math.min(a.y,i.y),c=Math.max(a.y,i.y);t<l||t>=c||n.push(a.x+(t-a.y)/(i.y-a.y)*(i.x-a.x))}n.sort((o,a)=>o-a);let r={x0:0,x1:0};for(let o=0;o+1<n.length;o+=2){let a={x0:n[o],x1:n[o+1]};a.x1-a.x0>r.x1-r.x0&&(r=a)}return r}function ua(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 ha(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 fa(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 ma(e,t){let{room:n,height:r,size:o,floor:a,measure:i=yo,lines:l=2}=t,c=(f,x)=>f.every(w=>i(w,x)<=n)&&f.length*x*1.15<=r;if(c([e],o))return{lines:[e],fontSize:o,whole:!0};let s=e.split(/\s+/);if(l>1&&s.length>1){let f=1,x=1/0,w=0;for(let O=0;O<s.length-1;O+=1){w+=s[O].length+1;let I=Math.abs(w-e.length/2);I<x&&(x=I,f=O+1)}let y=[s.slice(0,f).join(" "),s.slice(f).join(" ")];if(c(y,o))return{lines:y,fontSize:o,whole:!0};for(let O=o;O>=a;O-=o*.06)if(c(y,O))return{lines:y,fontSize:O,whole:!0}}for(let f=o;f>=a;f-=o*.06)if(c([e],f))return{lines:[e],fontSize:f,whole:!0};let d=i(e,a)/Math.max(1,e.length),u=Math.floor(n/d)-1;if(u<4||a*1.15>r)return null;let h=e.slice(0,u),p=h.lastIndexOf(" ");return{lines:[`${p>3?h.slice(0,p):h}\u2026`],fontSize:a,whole:!1}}var ya=(e,t)=>e.x0<t.x1&&t.x0<e.x1&&e.y0<t.y1&&t.y0<e.y1;var Z=ce(Be(),1);var He=ce(Be(),1);var ga=520;function pa(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function Vr(e,t={}){let n=t.duration??ga,r=(t.enabled??!0)&&!pa(),o=(0,He.useRef)(e),[a,i]=(0,He.useState)(()=>Ht(e,e,1)),l=(0,He.useRef)(a),c=(0,He.useRef)(null),s=(0,He.useRef)(null);return(0,He.useEffect)(()=>{if(!r||typeof requestAnimationFrame>"u"){o.current=e;let x=Ht(e,e,1);if(l.current=x,i(x),typeof requestAnimationFrame>"u")return;let w=requestAnimationFrame(()=>{let y=Ht(e,e,1);l.current=y,i(y)});return()=>cancelAnimationFrame(w)}let d=performance.now(),h=s.current!==null&&l.current.t<1&&d-s.current<n?s.current:d;s.current=h;let p=Hn(Math.min(1,(d-h)/n)),b=o.current,f=x=>{let w=Math.min(1,(x-h)/n),y=p>=1?1:(Hn(w)-p)/(1-p),O=Ht(b,e,Math.max(0,y));l.current=O,i(O),w<1?c.current=requestAnimationFrame(f):(s.current=null,o.current=e,c.current=requestAnimationFrame(()=>{let I=Ht(e,e,1);l.current=I,i(I),c.current=null}))};return c.current=requestAnimationFrame(f),()=>{c.current!==null&&cancelAnimationFrame(c.current);let x=l.current;o.current={...e,...x.city?{city:x.city}:{},nodes:x.nodes.map(w=>({...w,plane:Math.round(w.plane)})),connectors:x.connectors}}},[e,n,r]),a}function Gr(e=1100){let{store:t}=xe(),[n,r]=(0,He.useState)(()=>new Set);return(0,He.useEffect)(()=>{let o=null,a=t.subscribe(i=>{r(new Set(i.touched)),o&&clearTimeout(o),o=setTimeout(()=>r(new Set),e)});return()=>{a(),o&&clearTimeout(o)}},[t,e]),n}var xa={marks:new Map,acts:[]};function zr(e=4e3){let{store:t}=xe(),[n,r]=(0,He.useState)(xa);return(0,He.useEffect)(()=>{let o=null,a=t.subscribe((i,l)=>{r(c=>{let s=new Map(c.marks),d=[...c.acts];for(let u of l){if(u.undoes!==void 0){let b=d.find(x=>x.batch===u.undoes||x.wrote.length>0),f=d.filter(x=>u.writes.some(w=>x.wrote.includes(w)));for(let x of f.length>0?f:b?[b]:[]){for(let w of x.wrote)s.delete(w);d=d.filter(w=>w.batch!==x.batch)}continue}if(u.author.kind!=="agent")continue;let h=u.author.id??"the seat";for(let b of u.writes)s.set(b,h);d.find(b=>b.batch===u.batch)?d=d.map(b=>b.batch===u.batch?{...b,wrote:[...new Set([...b.wrote,...u.writes])]}:b):d=[{batch:u.batch,who:h,intent:u.batchIntent??u.intent,at:u.at,wrote:[...u.writes]},...d].slice(0,12)}return s.size===c.marks.size&&d===c.acts&&s.size===0?c:{marks:s,acts:d}}),o&&clearTimeout(o),o=setTimeout(()=>r(c=>c.marks.size===0?c:{...c,marks:new Map}),e)});return()=>{a(),o&&clearTimeout(o)}},[t,e]),n}var Dt=ce(Le(),1),qe=16;function _r({marks:e,questions:t=[],whereIs:n,stageRef:r,width:o,height:a}){if(e.size===0&&t.length===0)return null;let i=r.current,l=i?.getBoundingClientRect()??null,c=[];for(let[d,u]of e){let h=null;if(i&&l&&typeof CSS<"u"){let x=i.querySelector(`[data-graview-pick="${CSS.escape(d)}"]`)?.getBoundingClientRect();x&&x.width>0&&x.height>0&&(h={x:x.left-l.left,y:x.top-l.top,width:x.width,height:x.height})}if(h??=n(d),!h)continue;let p=Math.min(Math.max(h.x+h.width-qe/2,qe/2),o-qe/2),b=Math.min(Math.max(h.y-qe/4,qe/2),a-qe/2);c.push({id:d,who:u,x:p,y:b})}let s=[];for(let d of t){let u=n(d.id);u&&s.push({...d,x:Math.min(Math.max(u.x+u.width/2,qe),o-qe),y:Math.min(Math.max(u.y-qe/2,qe),a-qe)})}return c.length===0&&s.length===0?null:(0,Dt.jsxs)("div",{className:"graview-seat-marks","data-testid":"seat-marks","data-graview-seat-marks":c.length,children:[c.map(({id:d,who:u,x:h,y:p})=>(0,Dt.jsx)("span",{className:"graview-seat-mark","data-testid":"seat-mark","data-graview-seat-mark":d,"data-graview-seat-who":u,title:`${u} just changed this`,"aria-hidden":"true",style:{left:h,top:p,"--graview-hue":rn(u)},children:"\u25C6"},d)),s.map(d=>(0,Dt.jsxs)("span",{className:"graview-seat-asking","data-testid":"seat-question","data-graview-seat-asking":d.id,title:d.asks,style:{left:d.x,top:d.y},children:[(0,Dt.jsx)("span",{"aria-hidden":"true",children:"?"}),(0,Dt.jsx)("span",{className:"graview-seat-asking-said",children:d.asks})]},`asking:${d.id}`))]})}var q=ce(Le(),1);function ba({hue:e,mode:t}){let n=t==="docked";return(0,q.jsxs)("svg",{viewBox:"0 0 32 38","aria-hidden":"true",children:[(0,q.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round",strokeLinecap:"round",children:[(0,q.jsx)("line",{x1:"16",y1:"3.5",x2:"16",y2:"7"}),(0,q.jsx)("circle",{cx:"16",cy:"2.6",r:"1.5",fill:"none"}),(0,q.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,q.jsx)("line",{x1:"11",y1:"12.5",x2:"21",y2:"12.5",strokeWidth:"2"}):(0,q.jsxs)(q.Fragment,{children:[(0,q.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,q.jsx)("circle",{cx:"13.4",cy:"12.5",r:"1.25",fill:"currentColor",stroke:"none",opacity:n?.45:1}),(0,q.jsx)("circle",{cx:"18.6",cy:"12.5",r:"1.25",fill:"currentColor",stroke:"none",opacity:n?.45:1}),t==="reading"?(0,q.jsx)("line",{x1:"10.2",y1:"12.5",x2:"21.8",y2:"12.5",strokeWidth:"0.8",opacity:"0.7"}):null]}),(0,q.jsx)("line",{x1:"16",y1:"16",x2:"16",y2:"18.5"}),(0,q.jsx)("polygon",{points:"16,18.5 24,22.5 16,26.5 8,22.5",fill:"currentColor",fillOpacity:"0.22"}),(0,q.jsx)("polygon",{points:"8,22.5 16,26.5 16,33.5 8,29.5",fill:"currentColor",fillOpacity:"0.08"}),(0,q.jsx)("polygon",{points:"24,22.5 16,26.5 16,33.5 24,29.5",fill:"currentColor",fillOpacity:"0.3"}),t==="writing"?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)("polyline",{points:"24,24 28.5,20.5"}),(0,q.jsx)("line",{x1:"27.5",y1:"19",x2:"30",y2:"21.5",strokeWidth:"1.8"})]}):(0,q.jsx)("line",{x1:"24",y1:"24",x2:"26.5",y2:"29"}),(0,q.jsx)("line",{x1:"8",y1:"24",x2:"5.5",y2:"29"}),(0,q.jsx)("path",{d:"M9.5 33.5 v2.2 h4"}),(0,q.jsx)("path",{d:"M22.5 33.5 v2.2 h-4"})]}),(0,q.jsx)("title",{children:`robot, ${t}`})]})}function wa({hue:e}){return(0,q.jsxs)("svg",{viewBox:"0 0 22 24","aria-hidden":"true",style:{color:`hsl(${Math.round(e)} 50% 48%)`},children:[(0,q.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round",strokeLinecap:"round",children:[(0,q.jsx)("circle",{cx:"11",cy:"6",r:"4.2"}),(0,q.jsx)("path",{d:"M3 23 C3 15.5 6 13 11 13 C16 13 19 15.5 19 23"})]}),(0,q.jsx)("title",{children:"somebody"})]})}function Kr({width:e,whereIs:t}){let{who:n,following:r,follow:o}=xe(),a=br([...n.values()],t,e);return a.length===0?null:(0,q.jsx)("div",{className:"graview-occupants","data-testid":"occupants","data-graview-occupants":a.length,children:a.map((i,l)=>{if(i.kind==="over")return(0,q.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,q.jsxs)("span",{className:"graview-figure-count","data-testid":"presence-count","data-graview-at":i.at,style:{left:i.point.x,top:i.point.y},title:`${i.n} more here`,children:["+",i.n]},`count:${i.at}:${l}`);let c=i.presence.hue,s=ir(i.presence)||"somebody";if(i.kind==="edge")return(0,q.jsxs)("button",{type:"button",className:"graview-figure-edge","data-testid":"presence-edge","data-graview-person":i.presence.participant,style:{left:Math.max(8,i.point.x-120),top:i.point.y},onClick:()=>o(i.presence.participant),"aria-label":`${s} is somewhere else \u2014 press to go where they are`,children:["\u2192 ",s]},`edge:${i.presence.participant}`);if(i.kind==="robot")return(0,q.jsxs)("div",{className:"graview-figure","data-graview-figure":`theirs:${i.presence.participant}`,"data-graview-theirs":"","data-graview-mode":i.mode,"data-graview-at":i.presence.robot?.at??"",style:{transform:`translate(${i.point.x.toFixed(1)}px, ${i.point.y.toFixed(1)}px)`,"--graview-hue":c},children:[(0,q.jsx)("span",{className:"graview-figure-body",role:"img","aria-label":`${s}'s agent \u2014 ${i.mode}`,style:{cursor:"default"},children:(0,q.jsx)(ba,{hue:c,mode:i.mode})}),(0,q.jsxs)("span",{className:"graview-figure-name",children:[s,"'s agent"]})]},`robot:${i.presence.participant}`);let d=r?.participant===i.presence.participant;return(0,q.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":d?"":void 0,style:{transform:`translate(${i.point.x.toFixed(1)}px, ${i.point.y.toFixed(1)}px)`,"--graview-hue":c},children:[(0,q.jsx)("button",{type:"button",className:"graview-figure-body","aria-label":`${s} is here${d?". Press to stop following":". Press to go where they go"}`,"aria-pressed":d,onClick:u=>{u.stopPropagation(),o(d?null:i.presence.participant)},onPointerDown:u=>u.stopPropagation(),children:(0,q.jsx)(wa,{hue:c})}),(0,q.jsx)("span",{className:"graview-figure-name",children:s})]},`person:${i.presence.participant}`)})})}var pn=ce(Le(),1),Ur={left:"\u2190",right:"\u2192",top:"\u2191",bottom:"\u2193"},No=36,gn=56;function Xr({result:e,schema:t,chrome:n=[],onGo:r}){let o=Lo(e);if(o.length===0)return null;let i=[...(e.city?.showings??[]).flatMap(c=>{let s=e.nodes.find(d=>d.id===c.id);return s?[{left:s.x+c.x,top:s.y+c.y,right:s.x+c.x+c.width,bottom:s.y+c.y+c.height}]:[]}),...n.map(c=>({left:c.x,top:c.y,right:c.x+c.width,bottom:c.y+c.height}))],l=[];for(let c of["left","right","top","bottom"]){let s=e.visible??e,d=c==="left"||c==="right"?s.height:s.width,u=c==="left"||c==="right",h=c==="bottom"?Sa:c==="top"?gn:Ma+gn/2,p=-1/0,b=[],f=o.filter(x=>x.side===c).sort((x,w)=>x.along-w.along);for(let x of f){let w=Vt(t,x.kind),y=va(w),O=u?Dn:y/2,I=d-h-(u?0:O),W=Math.max(gn,x.along,p+O+ka);if(W>I)continue;let{at:H,inset:X}=Ra([...i,...b],c,W,y,s,d);if(H>I+.5)continue;p=H+O,b.push(qr(c,H,y,s,X));let te=c==="left"?{left:X,top:H,transform:"translateY(-50%)"}:c==="right"?{right:`calc(${X}px + var(--graview-dock, 0px))`,top:H,transform:"translateY(-50%)"}:c==="top"?{top:X,left:H,transform:"translateX(-50%)"}:{bottom:`calc(${X}px + var(--graview-scene-foot, var(--graview-sheet, 0px)))`,left:H,transform:"translateX(-50%)"};l.push((0,pn.jsx)("button",{type:"button",className:"graview-edge-sign","data-graview-past-edge":x.id,"aria-label":`${w}, past the ${c} edge \u2014 bring it into view`,title:`${w} is past the ${c} edge`,tabIndex:-1,onPointerDown:g=>g.stopPropagation(),onClick:g=>{g.stopPropagation(),r(x.by)},style:{...Ea,...te},children:c==="right"||c==="bottom"?`${w} ${Ur[c]}`:`${Ur[c]} ${w}`},x.id))}}return(0,pn.jsx)(pn.Fragment,{children:l})}var va=e=>(e.length+2)*7.4+22,Dn=No/2,yn=6,ka=6,Sa=236,Ma=56;function qr(e,t,n,r,o=yn){return e==="left"||e==="right"?{left:e==="left"?o:r.width-o-n,right:e==="left"?o+n:r.width-o,top:t-Dn,bottom:t+Dn}:{left:t-n/2,right:t+n/2,top:e==="top"?o:r.height-o-No,bottom:e==="top"?o+No:r.height-o}}function Ra(e,t,n,r,o,a){let i=t==="left"||t==="right",l=b=>qr(t,b,r,o),c=b=>e.find(f=>{let x=l(b);return x.left<f.right&&f.left<x.right&&x.top<f.bottom&&f.top<x.bottom}),s=c(n);if(!s)return{at:n,inset:yn};let d=i?Dn:r/2,u=(i?s.bottom:s.right)+d+4,h=(i?s.top:s.left)-d-4;if(u<=a-gn&&!c(u))return{at:u,inset:yn};if(h>=gn&&!c(h))return{at:h,inset:yn};let p=t==="left"?s.right:t==="right"?o.width-s.left:t==="top"?s.bottom:o.height-s.top;return{at:n,inset:Math.max(yn,p+4)}}var Ea={position:"absolute",zIndex:Ce.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"};var wt=ce(Be(),1),Oa=180;function Qr({view:e,result:t,frame:n,panned:r,closer:o,screenId:a,setCamera:i}){let l=(0,wt.useRef)(new Map),c=Math.round((t.nodes.find(u=>u.id===a)?.height??0)/16),s=(0,wt.useRef)(e.overview??!1),d=(0,wt.useRef)(null);if((0,wt.useEffect)(()=>{if(!e.overview||!a||!t.city){if(s.current&&!e.overview)return;i(H=>H.x===0&&H.y===0?H:{x:0,y:0});return}let u=t.nodes.find(H=>H.id===a);if(!u)return;let h=o>1&&u.screenOf?t.nodes.find(H=>H.id===ve(u.screenOf)):void 0,p=h?{x:Math.min(u.x,h.x),y:Math.min(u.y,h.y),width:Math.max(u.x+u.width,h.x+h.width)-Math.min(u.x,h.x),height:Math.max(u.y+u.height,h.y+h.height)-Math.min(u.y,h.y)}:u;if(p.x>=0&&p.y>=0&&p.x+p.width<=t.width&&p.y+p.height<=t.height&&!h)return;let f=24,x=(H,X,te)=>H<f?f-H:H+X>te-f?te-f-(H+X):0,w=bt(t),y=e.pan??{x:0,y:0},O=h?r.x+(t.width/2-(p.x+p.width/2)):r.x+x(p.x,p.width,t.width),I=t.height/2-(p.y+p.height/2),W=h?r.y+(u.y+I<f?f-u.y:I):r.y+x(p.y,p.height,t.height);i({x:(h?O:Math.max(-w.x,Math.min(w.x,O)))-y.x,y:(h?W:Math.max(-w.y,Math.min(w.y,W)))-y.y})},[a,e.overview,o,e.within?.view,c]),n.city){let u=new Map;for(let h of n.nodes){if(!h.plot||Math.round(h.plane)!==2)continue;let p=qt(h.plot.col+h.plot.side/2,h.plot.row+h.plot.side/2,n.city.cell,n.city.tilt);u.set(h.id,{x:n.city.originX+r.x+p.x,y:n.city.originY+r.y+p.y})}l.current=u}return(0,wt.useEffect)(()=>{let u=e.overview??!1,h=s.current&&!u;if(s.current=u,u&&d.current&&(clearTimeout(d.current),d.current=null),!h)return;let p=e.focusId?pt(e.focusId)[0]:void 0,b=p?l.current.get(ve(p)):void 0,f=t.nodes.find(x=>x.id===e.focusId);if(!b||!f){i({x:0,y:0});return}i({x:b.x-(f.x+f.width/2),y:b.y-(f.y+f.height/2)}),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,i({x:0,y:0})},Oa)},[e.overview]),(0,wt.useEffect)(()=>()=>{d.current&&clearTimeout(d.current)},[]),{gliding:()=>d.current!==null}}var jn=ce(Be(),1),Fn="[data-graview-view]";function La(e,t){let n=null;for(let r=e?.closest(Fn)??null;r&&t.contains(r);r=r.parentElement?.closest(Fn)??null)n=r;return n}function Zr(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 Jr(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=c=>{let{dock:s}=r.current;if(c.key!=="Tab"||c.defaultPrevented||s.right<=0&&s.bottom<=0)return;let d=Zr(o,s),u=[];for(let h of o.querySelectorAll(Fn)){if(h.parentElement?.closest(Fn)||h.inert||h.contains(document.activeElement))continue;let p=h.getBoundingClientRect(),b=Math.max(p.left,d.box.left),f=Math.min(p.right,d.box.right),x=Math.max(p.top,d.box.top),w=Math.min(p.bottom,d.box.bottom);f<=b||w<=x||!(s.right>0&&b>=d.right-1||s.bottom>0&&x>=d.bottom-1)||(h.inert=!0,u.push(h))}u.length!==0&&setTimeout(()=>{for(let h of u)h.inert=!1},0)},i=c=>{let s=c.target,d=La(s,o);if(!d)return;let u=!0;try{u=s?.matches(":focus-visible")??!0}catch{}requestAnimationFrame(()=>{for(let h=d.parentElement;h;h=h===o?null:h.parentElement)h.scrollTop!==0&&(h.scrollTop=0),h.scrollLeft!==0&&(h.scrollLeft=0);u&&d.isConnected&&l(d)})},l=c=>{let s=Zr(o,r.current.dock),d=c.getBoundingClientRect(),u=12,h=(f,x,w,y)=>y-w>x-f-2*u||w<f+u?f+u-w:y>x-u?x-u-y:0,p=h(s.left,s.right,d.left,d.right),b=h(s.top,s.bottom,d.top,d.bottom);(Math.abs(p)>=1||Math.abs(b)>=1)&&r.current.reveal(Math.round(p),Math.round(b))};return document.addEventListener("keydown",a,!0),o.addEventListener("focusin",i),()=>{document.removeEventListener("keydown",a,!0),o.removeEventListener("focusin",i)}},[e])}var de=ce(Be(),1);function ei(){let e=(0,de.useRef)(null),[t,n]=(0,de.useState)({right:0,bottom:0});return(0,de.useLayoutEffect)(()=>{let r=e.current;if(!r)return;let o=()=>{let i=r.getBoundingClientRect(),l={right:Math.round(i.width),bottom:Math.round(i.height)};n(c=>c.right===l.right&&c.bottom===l.bottom?c:l)};if(o(),typeof ResizeObserver>"u")return;let a=new ResizeObserver(o);return a.observe(r),()=>a.disconnect()},[]),{probe:e,dock:t}}function ti(){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 ni({stage:e,pan:t,setView:n,settled:r}){let o=(0,de.useRef)({x:0,y:0}),a=(0,de.useRef)(0),i=(0,de.useRef)(!1),l=(0,de.useRef)(r);l.current=r;let c=(0,de.useCallback)(()=>[...e.current?.querySelectorAll("[data-graview-world]")??[]],[e]),s=(0,de.useCallback)(()=>{a.current===0&&(a.current=requestAnimationFrame(()=>{a.current=0;let{x:b,y:f}=o.current,x=b===0&&f===0?"":`translate3d(${b}px, ${f}px, 0)`;for(let w of c())w.style.transform=x}))},[c]),d=(0,de.useCallback)(()=>{i.current=!1;for(let b of c())b.style.transform="";l.current()},[c]),u=(0,de.useCallback)((b,f)=>{o.current={x:b.x-f.x,y:b.y-f.y},s()},[s]),h=(0,de.useCallback)(()=>{let{x:b,y:f}=o.current;return b===0&&f===0?!1:(o.current={x:0,y:0},i.current=!0,n(x=>{let w=x.pan??{x:0,y:0};return Nt(x,{x:w.x+b,y:w.y+f})}),window.setTimeout(()=>{i.current&&d()},300),!0)},[n,d]);(0,de.useLayoutEffect)(()=>{i.current&&d()},[t,d]);let p=(0,de.useCallback)(()=>o.current,[]);return{shiftTo:u,settle:h,settling:i,offset:p}}var Aa=4;function oi({view:e,panned:t,limit:n,panWithin:r,moveByTransform:o,setView:a,setDragging:i,noteMoved:l,shift:c,district:s}){let d=(0,de.useRef)(!1),u=(0,de.useRef)(null),h=w=>{let y=e.pan??{x:0,y:0};u.current={kind:"pan",fromX:w.clientX,fromY:w.clientY,baseX:y.x,baseY:y.y,moved:!1}};return{onGroundDown:w=>{w.button===0&&(w.target.closest("[data-graview-view]")||h(w))},onCardDown:(w,y)=>{if(y.button===0){if(w.screenOf!==void 0&&!y.target.closest("[data-graview-grip]")){h(y);return}if(e.overview&&Ee(w.id)!==null){h(y);return}u.current={kind:"card",id:w.id,fromX:y.clientX,fromY:y.clientY,baseX:w.x-t.x,baseY:w.y-t.y,moved:!1}}},onDragMove:w=>{let y=u.current;if(!y)return;let O=w.clientX-y.fromX,I=w.clientY-y.fromY;if(!y.moved){if(Math.hypot(O,I)<Aa)return;y.moved=!0,i(!0),w.currentTarget.setPointerCapture(w.pointerId)}if(y.kind==="pan"){let W=r(n(),{x:y.baseX+O,y:y.baseY+I});o?c.shiftTo(W,e.pan??{x:0,y:0}):a(H=>Nt(H,W))}else y.id&&s.place({id:y.id,x:y.baseX+O,y:y.baseY+I})},onDragUp:()=>{c.settle();let w=s.release();w&&a(y=>hn(y,w.id,{x:w.x,y:w.y})),u.current?.moved&&(d.current=!0,setTimeout(()=>d.current=!1,0),l()),u.current=null,!c.settling.current&&i(!1)},swallow:d}}function ri({stage:e,view:t,setView:n}){let r=(0,de.useRef)({view:t,charge:0,coolUntil:0,lastScale:1});r.current.view=t;let o=(0,de.useRef)(()=>{}),a=(0,de.useRef)(()=>{});return(0,de.useEffect)(()=>{let i=e.current;if(!i)return;let l=(u,h)=>{let p=r.current;if(h<p.coolUntil)return;let b=p.view.overview??!1;u!==b&&(p.coolUntil=h+600,p.charge=0,n(sn(p.view,u)))},c=u=>{let h=r.current,p=h.view.overview??!1;if(u.ctrlKey){if(u.preventDefault(),!p){if(h.charge+=u.deltaY,Math.abs(h.charge)<60)return;h.charge>0?l(!0,performance.now()):h.charge=0;return}o.current(Math.exp(-u.deltaY*.004),u.clientX,u.clientY);return}!p||u.target?.closest("[data-graview-view], .graview-scroll, [data-graview-overlay], .graview-zoom")||(u.preventDefault(),a.current(-u.deltaX,-u.deltaY))},s=u=>{u.preventDefault(),r.current.lastScale=1},d=u=>{u.preventDefault();let h=r.current,p=u.scale??1;if(!(h.view.overview??!1)){p<.72&&l(!0,performance.now());return}let b=p/(h.lastScale||1);h.lastScale=p;let f=u;o.current(b,f.clientX,f.clientY)};return i.addEventListener("wheel",c,{passive:!1}),i.addEventListener("gesturestart",s),i.addEventListener("gesturechange",d),()=>{i.removeEventListener("wheel",c),i.removeEventListener("gesturestart",s),i.removeEventListener("gesturechange",d)}},[n,e]),{zoomAbout:o,panBy:a}}var ii={directed:"You",autonomous:"An agent","co-edited":"You and an agent",rule:"A rule"};function $o(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 Bo(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 Ho(e){return e.edgeChosen?.9:e.lit?.78:e.own*(e.anyLit?e.kit.dim:e.kit.rest)}function tt(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?Xe(n,t):In(Xe(n,t),Xe(r,t),e.plane-n);return{x:e.x,y:e.y,width:e.width*o,height:e.height*o}}function Qt(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 s=getComputedStyle(l);if(s.overflowX!=="visible"||s.overflowY!=="visible"){let d=l.getBoundingClientRect();s.overflowX!=="visible"&&(n=Math.max(n,d.left),o=Math.min(o,d.right)),s.overflowY!=="visible"&&(r=Math.max(r,d.top),a=Math.min(a,d.bottom))}l=l.parentElement}if(o-n<=2||a-r<=2)return null;let c=t.getBoundingClientRect();return{x:n-c.left,y:r-c.top,width:o-n,height:a-r}}function De(e,t,n,r=!1){if(!e||typeof document>"u")return null;let o=e.querySelector(`[data-graview-view="${CSS.escape(t)}"]`);if(!o)return null;let a=(n?o.querySelector(".graview-kind-block"):null)??o.querySelector('[data-graview-primitive="panel"], .graview-kind-face, .graview-kind-card')??(r?null:o.querySelector(':scope > [data-graview-primitive="chip"]'))??o;return Qt(a,e)}function Wn(e,t,n,r,o){let a=s=>e.nodes.find(d=>d.id===s);if(o.startsWith("screen:")){let s=e.nodes.find(d=>d.id===ve(o.slice(7)));return s?De(t,s.id,!0)??tt(s,n):null}let i=a(o),l=Ee(o);if(!i&&l!==null&&(i=a(Oe(l))),!i&&Lt(o)){let[s]=pt(o);s&&(i=a(ve(s)))}if(!i){let s=r.places().find(d=>d.as===o);s&&(i=a(Oe(s.kind))??a(ve(s.kind)))}if(i||(i=[...e.nodes].filter(s=>s.aggregate?.memberIds.includes(o)).sort((s,d)=>s.plane-d.plane)[0]),!i)return null;let c=e.city!==void 0;return De(t,i.id,c&&i.aggregate!==void 0&&Math.round(i.plane)===2)??tt(i,n)}var ct=ce(Be(),1);var le=ce(Le(),1);function si({kinds:e}){let{store:t}=xe(),{view:n,go:r}=uo(),o=(0,ct.useRef)(null),a=fo("districts",{align:"start"}),i=a.open,l=h=>Vt(t.schema,h),c=h=>t.graph.allNodes().filter(p=>p.kind===h).length,s=h=>!n.overview&&n.focusId===Oe(h),d=e.filter(h=>!s(h)),u=h=>{a.setOpen(!1);let p=o.current?.querySelector(".graview-beyond-more")??null;s(h)||r(gt(n,Oe(h))),p?.focus({preventScroll:!0});let b=`[data-graview-view="${Oe(h)}"][tabindex], [data-graview-view="${ve(h)}"][tabindex]`,f=40,x=()=>{let w=document.querySelector(b);w?w.focus({preventScroll:!0}):--f>0&&requestAnimationFrame(x)};requestAnimationFrame(x)};return(0,le.jsxs)("div",{ref:o,className:"graview-beyond","data-graview-beyond":e.length,"data-graview-beyond-open":i?"":void 0,children:[(0,le.jsxs)("button",{type:"button",className:"graview-beyond-more","data-testid":"beyond-more",...a.trigger,"aria-haspopup":"menu",title:`${d.length} more district${d.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:["+",d.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:ho,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":ve(h),"aria-current":s(h)?"location":void 0,title:s(h)?`${l(h)} \u2014 where you are`:`Go to ${l(h)}`,onPointerDown:p=>p.stopPropagation(),onClick:p=>{p.stopPropagation(),u(h)},children:[(0,le.jsx)("span",{className:"graview-beyond-name",children:l(h)}),(0,le.jsx)("span",{className:"graview-beyond-tally",children:s(h)?"here":c(h)})]})},h))}):null]})}function Ia(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"||Fo(e[r],t[r]))}function Fo(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(!Fo(e[a],o[a]))return!1;return!0}let r=Object.keys(e);return r.length!==Object.keys(t).length?!1:r.every(o=>Fo(e[o],t[o]))}var di=(0,ct.memo)(li,(e,t)=>e.mode===t.mode&&e.selected===t.selected&&e.fidelity===t.fidelity&&Ia(e.node,t.node));function li({node:e,mode:t,selected:n,fidelity:r}){let{store:o,views:a,view:i}=xe(),l=It(),c=xr(),s=pr(),d=e.aggregate||Lt(e.id)||Ee(e.id)!==null?"many":"one",u={cardinality:d,fidelity:r??cr[Pa(e.plane)].fidelity},h=d==="many"&&e.id===i.focusId?i.within?.view:void 0,p=a.resolve(e.kind,u,h),b=p?.view,f=a.resolve(e.kind,{cardinality:"many",fidelity:"full"})?.view,x=f!==void 0&&f.generic!==!0,w=e.aggregate?.memberIds,y=(0,ct.useMemo)(()=>(w??[]).map(W=>o.graph.getNode(W)).filter(W=>W!==void 0),[w,o,l]),O={...e.aggregate?{nodes:y,label:p?.title??e.aggregate.label}:{node:o.graph.getNode(e.id)},fidelity:u.fidelity,cardinality:u.cardinality,mode:t,selected:n,implicated:c,flagged:s,...e.raised?{raised:!0}:{},...e.focused?{focused:!0}:{},...e.opened?{opened:!0}:{},...e.openedRows!==void 0?{openedRows:e.openedRows}:{},...e.plot?{plot:e.plot}:{},...e.nameplate?{nameplate:e.nameplate}:{},...e.states?{states:e.states}:{},...e.aggregate?.retired?{retired:e.aggregate.retired}:{},...e.rank?{rank:e.rank}:{},...e.nestedUnder?{nestedUnder:e.nestedUnder}:{},...x?{hasOwnView:!0}:{}};if(!b)return(0,le.jsx)(Ca,{node:e,props:O});let I=[e.id,p?.title??"",u.fidelity,u.cardinality,t,n,e.raised??!1,e.focused??!1,e.opened??!1,e.openedRows??"",e.rank??"",e.nestedUnder??"",e.plot?`${e.plot.col},${e.plot.row},${e.plot.side}`:"",e.nameplate??"",e.states?e.states.values.map(W=>W.count).join(","):"",e.aggregate?Do(e.aggregate.memberIds):"",e.aggregate?.retired??"",c?Do(c):"",s?Do(s):"",x].join("|");return(0,le.jsx)(so,{mode:t,children:(0,le.jsx)(wr,{kind:O.label??e.kind,...p?.title?{view:p.title}:{},children:(0,le.jsx)(Ta,{signature:I,graph:l,draw:()=>(0,le.jsx)(b,{...O})})},`${e.id}|${p?.title??""}`)})}var Ta=(0,ct.memo)(function({draw:t}){return(0,le.jsx)(le.Fragment,{children:t()})},(e,t)=>e.signature===t.signature&&e.graph===t.graph);function Pa(e){return Math.max(0,Math.min(2,Math.round(e)))}function Ca({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 ci=(0,ct.memo)(function({node:t}){let{store:n}=xe(),r=At(),o=t.aggregate,a=o.opens,i=o.memberIds.length,l=Yt(n.schema,o.kind,i),c=o.memberIds.slice(0,3).map(h=>{let p=n.graph.getNode(h),b=p?n.schema.tryDefinition(p.kind):void 0;return p?b?.label?b.label(p):String(p.label??h):h}),s=o.memberIds,d=(0,ct.useMemo)(()=>{let h=r?An(r):null;return h?s.filter(p=>h.has(p)).length:0},[r,s]),u=a.in==="picture";return(0,le.jsxs)("div",{className:"graview-band-group","data-graview-band":a.in,"data-graview-band-count":i,"data-graview-emphasis":r?d>0?"lit":"dimmed":void 0,title:u?`${o.label} \u2014 press twice to see them all, arranged`:`${o.label}: ${l} \u2014 press twice to open`,children:[(0,le.jsxs)("span",{className:"graview-band-group-head",children:[(0,le.jsx)("span",{className:"graview-band-group-name",children:o.label}),(0,le.jsx)("span",{className:"graview-band-group-open","aria-hidden":"true",children:u?"\u2197":"\u25BE"})]}),(0,le.jsxs)("span",{className:"graview-band-group-names",children:[u?null:(0,le.jsxs)("span",{className:"graview-band-group-count",children:[l,d>0?` \xB7 ${d} match`:""," \xB7 "]}),c.join(" \xB7 "),i>c.length?" \u2026":""]})]})}),ai=new WeakMap;function Do(e){let t=ai.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 ai.set(e,r),r}var vt=ce(Be(),1);function jo(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 ui(){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 hi(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(c=>{let s={width:Math.round(l.width),height:Math.round(l.height)};return c&&c.width===s.width&&c.height===s.height?c:s})},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 fi(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 mi(e){return`matrix3d(${e.join(",")})`}var ge=ce(Be(),1);var Wo=(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 Yo(e,t){let n=[],r=[];for(let a=0;a<e.length-1;a++){let i=e[a],l=e[a+1],c=!Wo(i,t);c&&r.length===0&&r.push(i);for(let s=1;s<=48;s++){let d=s/48,u={x:i.x+(l.x-i.x)*d,y:i.y+(l.y-i.y)*d},h=!Wo(u,t);if(h===c)continue;let p=(s-1)/48,b=d;for(let w=0;w<10;w++){let y=(p+b)/2,O={x:i.x+(l.x-i.x)*y,y:i.y+(l.y-i.y)*y};!Wo(O,t)===c?p=y:b=y}let f=(p+b)/2,x={x:i.x+(l.x-i.x)*f,y:i.y+(l.y-i.y)*f};h?r=[x]:(r.push(x),r.length>=2&&n.push(r),r=[]),c=h}c&&r.push(l)}return r.length>=2&&n.push(r),n}function xn(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 Ye=e=>Math.round(e*100)/100,kt=e=>e.map(t=>t.map((n,r)=>`${r===0?"M":"L"} ${Ye(n.x)} ${Ye(n.y)}`).join(" ")).join(" ");function Vo(e,t){if(e.length<3)return kt([e]);let n=[`M ${Ye(e[0].x)} ${Ye(e[0].y)}`];for(let o=1;o<e.length-1;o++){let a=e[o-1],i=e[o],l=e[o+1],c=Math.hypot(i.x-a.x,i.y-a.y),s=Math.hypot(l.x-i.x,l.y-i.y),d=Math.min(t,c/2,s/2),u={x:i.x+(a.x-i.x)/(c||1)*d,y:i.y+(a.y-i.y)/(c||1)*d},h={x:i.x+(l.x-i.x)/(s||1)*d,y:i.y+(l.y-i.y)/(s||1)*d};n.push(`L ${Ye(u.x)} ${Ye(u.y)} Q ${Ye(i.x)} ${Ye(i.y)} ${Ye(h.x)} ${Ye(h.y)}`)}let r=e[e.length-1];return n.push(`L ${Ye(r.x)} ${Ye(r.y)}`),n.join(" ")}function yi(e,t){return t==="orthogonal"?kt([e]):Vo(e,10)}function gi(e,t,n){if(e==="orthogonal"){let l=xn(t.p0,t.p1),c=l.slice(1).map((u,h)=>Math.hypot(u.x-l[h].x,u.y-l[h].y)),s=c.reduce((u,h)=>u+h,0)||1,d=n*s;for(let u=0;u<c.length;u++){let h=c[u];if(d<=h||u===c.length-1){let p=h===0?0:Math.min(1,d/h),b=l[u],f=l[u+1];return{x:b.x+(f.x-b.x)*p,y:b.y+(f.y-b.y)*p}}d-=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 Yn(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 pi(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 xi(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 bn=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,zo=(e,t)=>e.findIndex(n=>n.boxes.some(r=>bn(r,t)));function bi(e,t,n){return t<0?e[0].top-12*2:n>=e.length?e[e.length-1].bottom+12*2:(e[t].bottom+e[n].top)/2}function Ko(e,t){let n=[{from:-1/0,to:1/0}];for(let a of e){let i=[],l=-1/0;for(let s of a.boxes)i.push({from:l,to:s.x-12}),l=Math.max(l,s.x+s.width+12);i.push({from:l,to:1/0});let c=[];for(let s of n)for(let d of i){let u=Math.max(s.from,d.from),h=Math.min(s.to,d.to);h-u>=0&&c.push({from:u,to:h})}n=c}let r=t,o=1/0;for(let a of n){let i=Math.min(Math.max(t,a.from),a.to),l=a.from===-1/0||a.to===1/0,c=Math.abs(i-t)+(l?60:0);c<o&&(o=c,r=i)}return r}var Qe=e=>({x:e.x,y:-(e.y+e.height),width:e.width,height:e.height}),Vn=e=>e.map(t=>({x:t.x,y:-t.y}));function _o(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 Uo(e,t,n){let r=e.boxes.filter(s=>!bn(s,t)&&s.y+s.height<=t.y+1&&s.x<t.x+t.width&&s.x+s.width>t.x),o=[{from:t.x+6,to:t.x+t.width-6}];for(let s of r)o=o.flatMap(d=>[{from:d.from,to:Math.min(d.to,s.x-12/2)},{from:Math.max(d.from,s.x+s.width+12/2),to:d.to}]).filter(d=>d.to>=d.from);let a=null;for(let s of o){let d=Math.min(Math.max(n,s.from),s.to);(a===null||Math.abs(d-n)<Math.abs(a-n))&&(a=d)}if(a!==null)return{x:a,tail:[{x:a,y:t.y}]};let i=n<t.x+t.width/2,l=Ko([e],i?t.x-12:t.x+t.width+12),c=t.y+t.height/2;return{x:l,tail:[{x:l,y:c},{x:l<t.x?t.x:t.x+t.width,y:c}]}}function Go(e,t,n){let r=Uo({top:-e.bottom,bottom:-e.top,boxes:e.boxes.map(Qe)},Qe(t),n);return{x:r.x,head:Vn(r.tail).reverse()}}function wi(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 vi=(e,t)=>(e%3-1)*Math.max(0,Math.min(4,t/2-3));function ki(e,t,n,r,o,a,i,l){let c=f=>f<0?e[0].top-n:e[f+1].top-e[f].bottom,s=f=>(f<0?(n+e[0].top)/2:bi(e,f,f+1))+vi(l,c(f)),d=Uo(e[a],o,i),u=wi(e,a,d.x,t+1),h=s(t);if(u===t+1)return _o([...r.head,{x:r.x,y:h},{x:d.x,y:h},...d.tail]);let p=Ko(e.slice(t+1,u),d.x),b=s(u-1);return _o([...r.head,{x:r.x,y:h},{x:p,y:h},{x:p,y:b},{x:d.x,y:b},...d.tail])}function Zt(e,t,n,r=0){let o=xi(n.some(d=>bn(d,e))&&n.some(d=>bn(d,t))?n:[...n,e,t]),a=zo(o,e),i=zo(o,t),l=e.x+e.width/2,c=t.x+t.width/2;if(a===i){if(!(a<o.length-1||o.length===1))return Vn(Zt(Qe(e),Qe(t),n.map(Qe),r));let u=bi(o,a,a+1)+vi(r,a<o.length-1?o[a+1].top-o[a].bottom:2*12),h=Go(o[a],e,c),p=Go(o[a],t,l);return _o([...h.head,{x:h.x,y:u},{x:p.x,y:u},...[...p.head].reverse()])}if(i<a)return Vn(Zt(Qe(e),Qe(t),n.map(Qe),r));let s=Go(o[a],e,c);return ki(o,a,o[a].bottom,s,t,i,l,r)}function Xo(e,t,n,r=0){if(t.y+t.height<=e.y){let p=Xo(Qe(e),Qe(t),n.map(Qe),r);return p?Vn(p):null}let o=e.y+e.height;if(t.y<o)return null;let a=xi([...n.filter(p=>p.y>=o&&!bn(p,t)),t]),i=zo(a,t),l=t.x+t.width/2,c=Uo(a[i],t,l),s=wi(a,i,c.x,0),d=s===0?c.x:Ko(a.slice(0,s),c.x),u=Math.min(12,e.width/2),h=Math.min(Math.max(d,e.x+u),e.x+e.width-u);return ki(a,-1,o,{x:h,head:[{x:h,y:o}]},t,i,l,r)}function Si(e,t=16){let n=new Map;for(let o of e){let a=o.a<o.b?`${o.a}\0${o.b}`:`${o.b}\0${o.a}`,i=n.get(a);i?i.push(o.key):n.set(a,[o.key])}let r=new Map;for(let o of n.values())o.forEach((a,i)=>r.set(a,(i-(o.length-1)/2)*t));return r}var Fe=ce(Le(),1);function zn(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 b={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:b,to:f,control:{x:Math.max(b.x,f.x)+18,y:(b.y+f.y)/2},mode:"stacked"}}if(a){let b={x:e.x+e.width/2,y:e.y},f={x:t.x+t.width/2,y:t.y};return{from:b,to:f,control:{x:(b.x+f.x)/2,y:Math.min(b.y,f.y)-18},mode:"abreast"}}let i={x:t.x+t.width/2,y:t.y+t.height/2},l={x:e.x+e.width/2,y:e.y+e.height/2},c=Gn(e,i),s=Gn(t,l),d=Math.hypot(s.x-c.x,s.y-c.y);if(d<8)return null;let u=Math.min(36,d*.12),h=-(s.y-c.y)/d,p=(s.x-c.x)/d;return{from:c,to:s,control:{x:(c.x+s.x)/2+h*u,y:(c.y+s.y)/2+p*u},mode:"direct"}}function Gn(e,t){let n=e.x+e.width/2,r=e.y+e.height/2,o=t.x-n,a=t.y-r;if(o===0&&a===0)return{x:n,y:r};let i=o===0?1/0:e.width/2/Math.abs(o),l=a===0?1/0:e.height/2/Math.abs(a),c=Math.min(i,l),s=Math.max(0,c*.98);return{x:n+o*s,y:r+a*s}}function Na(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 $a=()=>({clips:new Map,members:new Map,marks:new Map});function Ri(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 Ba(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 Ha(e,t,n){let r=e.parentElement;for(;r!==null;){let o=Ba(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 wn(e,t,n,r){if(!e||!t||typeof document>"u")return[];let o=r.members.get(t);o||r.members.set(t,o=new Map);let a=o.get(n);if(a)return a;let i=e.getBoundingClientRect(),l=[];for(let c of Ri(t,r).get(n)??[]){if(c.closest("[data-graview-offstage]"))continue;let s=c.getBoundingClientRect();s.width<=2||s.height<=2||Ha(c,s,r)&&l.push({x:s.left-i.left,y:s.top-i.top,width:s.width,height:s.height})}return l.sort((c,s)=>c.width*c.height-s.width*s.height),o.set(n,l),l}function _n(e,t,n,r,o){let a=new Map(e.map(y=>[y.id,y])),i=$a(),l=new Map,c=y=>{if(!n||typeof document>"u")return null;let O=l.get(y);return O===void 0&&(O=n.querySelector(`[data-graview-view="${CSS.escape(y)}"]`),l.set(y,O)),O},s=new Map;for(let y of e){let O=De(n,y.id,r)??tt(y,o);O&&s.set(y.id,O)}let d=new Map;if(n&&typeof document<"u"){let y=n.getBoundingClientRect();for(let O of n.querySelectorAll("[data-graview-pick], [data-graview-slot]")){if(O.closest("[data-graview-offstage]"))continue;let I=O.getAttribute("data-graview-pick")??O.getAttribute("data-graview-slot");if(I===null)continue;let W=O.getBoundingClientRect();if(W.width<=2||W.height<=2||W.width>y.width*.6&&W.height>y.height*.6)continue;let H=d.get(I),X={x:W.left-y.left,y:W.top-y.top,width:W.width,height:W.height};H?H.push(X):d.set(I,[X])}}let u=(y,O)=>{let I=[];for(let[W,H]of s)W!==y&&W!==O&&I.push(H);for(let[W,H]of d)W!==y&&W!==O&&I.push(...H);return I},h=y=>Math.round(a.get(y)?.plane??-1)===1,p=[];for(let y of e){let O=s.get(y.id);O&&Math.round(y.plane)===1&&p.push(O)}if(!r&&n&&typeof document<"u"){let y=n.getBoundingClientRect();for(let O of n.querySelectorAll("[data-graview-relation] > span")){let I=O.getBoundingClientRect();I.width>0&&I.height>0&&p.push({x:I.left-y.left,y:I.top-y.top,width:I.width,height:I.height})}}let b=(y,O)=>!r&&h(y)&&h(O)?p:void 0,f=r?void 0:e.find(y=>Math.round(y.plane)===0&&!y.aggregate),x=(y,O,I,W)=>{if(!f)return{};let H=y.to===f.id&&I===f.id;if(!H&&!(y.from===f.id&&O===f.id))return{};let X=H?y.from:y.to,te=s.get(f.id),g=s.get(X);if(X===f.id||!h(X)||!te||!g)return{};let S=c(f.id),C=A=>S!==null&&Ri(S,i).get(A)?.some(G=>!G.closest("[data-graview-offstage]"))===!0,E=W.map(A=>A.from===f.id?A.to:A.from),D=E.length>0&&E.every(C);return{band:p,tie:{card:te,chip:g,cardIsTo:H,toward:X,holds:a.get(X)?.aggregate?.memberIds??[X]},...D?{said:E}:{}}},w=[];for(let y of t){if(!Na(y,a,r))continue;let O=s.get(y.from),I=s.get(y.to);if(!O||!I)continue;let W=u(y.from,y.to),H=y.edges,X=r&&H.some(S=>S.from!==y.from&&wn(n,c(y.from),S.from,i).length>0||S.to!==y.to&&wn(n,c(y.to),S.to,i).length>0),te=b(y.from,y.to);if(r&&!X||y.loop||H.length===0){w.push({key:y.id,connector:y,edges:H,fromBox:O,toBox:I,fromAnchor:y.from,toAnchor:y.to,obstacles:W,hosts:[],...te?{band:te}:{},...x(y,y.from,y.to,H)});continue}let g=new Map;for(let S of H){let C=S.from===y.from?[]:wn(n,c(y.from),S.from,i),E=S.to===y.to?[]:wn(n,c(y.to),S.to,i),D=[y.from,y.to].find(B=>Math.round(a.get(B)?.plane??-1)===0);if(!r&&D!==void 0&&(D===y.from?S.from!==y.from:S.to!==y.to)&&wn(n,c(D),D===y.from?S.to:S.from,i).length>0)continue;let A=D!==void 0?a.get(D):void 0;if(!r&&A?.aggregate&&n&&(D===y.from?S.from!==y.from&&C.length===0:S.to!==y.to&&E.length===0))continue;let G=C.length>0?S.from:y.from,Y=E.length>0?S.to:y.to,_=`${y.id}|${G}|${Y}`,k=g.get(_);if(k){k.edges.push(S);continue}let T=C.length>0?C:[O],Q=E.length>0?E:[I],v=T[0],M=Q[0],L=1/0;for(let B of T)for(let $ of Q){let R=Math.hypot(B.x+B.width/2-($.x+$.width/2),B.y+B.height/2-($.y+$.height/2));R<L&&(L=R,v=B,M=$)}g.set(_,{edges:[S],fromBox:v,toBox:M,fromAnchor:G,toAnchor:Y})}for(let[S,C]of g)w.push({key:S,connector:y,obstacles:W,hosts:[...C.fromAnchor!==y.from?[O]:[],...C.toAnchor!==y.to?[I]:[]],...te?{band:te}:{},...C,...x(y,C.fromAnchor,C.toAnchor,C.edges)})}return w}function Ei(e,t,n){let r=new Map(t.map(i=>[i.id,i])),o=new Map;for(let i of n){let l=r.get(i.id);l&&(l.x!==i.x||l.y!==i.y)&&o.set(i.id,{x:i.x-l.x,y:i.y-l.y})}if(o.size===0)return[...e];let a=(i,l)=>{let c=o.get(l);return c?{...i,x:i.x+c.x,y:i.y+c.y}:i};return e.map(i=>{let{from:l,to:c}=i.connector;if(!o.has(l)&&!o.has(c))return i;let s=a(i.fromBox,l),d=a(i.toBox,c),u=i.tie&&{...i.tie,card:a(i.tie.card,i.tie.cardIsTo?c:l),chip:a(i.tie.chip,i.tie.toward)},h=p=>p===i.fromBox?s:p===i.toBox?d:i.tie&&p===i.tie.chip?u.chip:p;return{...i,fromBox:s,toBox:d,...u?{tie:u}:{},...i.band?{band:i.band.map(h)}:{}}})}function qo(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 Mi(e,t,n){let r=(1-t)*(1-n),o=(1-t)*n+t*(1-n),a=t*n;return{p0:qo(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:qo(e,n)}}function vn(e,t){let n=s=>t.some(d=>s.x>d.x&&s.x<d.x+d.width&&s.y>d.y&&s.y<d.y+d.height),r=s=>!n(qo(e,s)),a=(s,d,u)=>{for(let h=0;h<10;h++){let p=(s+d)/2;r(p)===u?s=p:d=p}return(s+d)/2},i=[],l=null,c=r(0);c&&(l=0);for(let s=1;s<=64;s++){let d=s/64,u=r(d);if(u===c)continue;let h=a((s-1)/64,d,c);u?l=h:l!==null&&(h-l>.001&&i.push(Mi(e,l,h)),l=null),c=u}return l!==null&&1-l>.001&&i.push(Mi(e,l,1)),i}function Oi({strands:e,result:t,scheme:n,overview:r,selection:o,emphasis:a,stageRef:i,liveOf:l,onPickEdge:c,provisional:s,pointed:d=null}){let u=Pt(),h=new Set(t.nodes.filter(g=>g.plot!==void 0&&Math.round(g.plane)===2).map(g=>g.id)),p=g=>r&&t.city!==void 0&&h.has(g.from)&&h.has(g.to),b=$o(t.nodes,o),f=g=>b.size===0||b.has(g.from)||b.has(g.to),x=new Set(o.filter(g=>Ot(g)===null)),w=r?t.nodes.find(g=>Math.round(g.plane)===0):void 0,y=w?De(i.current,w.id,!1)??tt(w,n):null;if(e.length===0)return null;let O=g=>g.edges.some(S=>x.has(S.from)||x.has(S.to)),I=x.size>0&&e.some(O),W=new Map;for(let g of e)W.set(g.connector.id,(W.get(g.connector.id)??0)+1);let H=Si(e.map(g=>({key:g.key,a:g.fromAnchor,b:g.toAnchor}))),X=new Set,te=e.map((g,S)=>{let{connector:C,fromBox:E,toBox:D}=g,A={x:E.x+E.width/2,y:E.y+E.height/2},G={x:D.x+D.width/2,y:D.y+D.height/2},Y=r?Gn(E,G):A,_=r?Gn(D,A):G,k=C.loop===!0,{connector:T,style:Q}=Xt(u,C.kind);if(!T.visible)return null;let v=k?Math.max(22,Math.min(E.width,E.height)*.3):0,M=k?{x:A.x+E.width*.22,y:A.y-E.height/2-v+7}:Y,L=(Y.x+_.x)/2,B=(Y.y+_.y)/2,$=Math.hypot(_.x-Y.x,_.y-Y.y),R=Math.min(r?40:90,$*(r?.09:.16)),N=0,F=0;if($>0){N=-(_.y-Y.y)/$,F=(_.x-Y.x)/$;let ie=L-t.width/2,ke=B-t.height/2;if(y&&!k){let Te=y.x+y.width/2,at=y.y+y.height/2;ie=L-Te,ke=B-at;let mt=Math.abs(N*(Te-Y.x)+F*(at-Y.y)),yt=Math.hypot(y.width/2,y.height/2)*.85+24,st=((Te-Y.x)*(_.x-Y.x)+(at-Y.y)*(_.y-Y.y))/($*$);mt<yt&&st>.1&&st<.9&&(R=Math.min(180,Math.max(R,(yt-mt)*2)))}N*ie+F*ke<0&&(N=-N,F=-F)}R+=2*(H.get(g.key)??0);let z=Yn(T.route,{p0:Y,c:{x:L+N*R,y:B+F*R},p1:_}),V=p(C),U=T.route==="orthogonal"||V,ae=(ie,ke)=>V?pi(ie,ke):xn(ie,ke),oe=!k&&g.tie?Xo(g.tie.card,g.tie.chip,g.band??[],S):null,J=oe?g.tie.cardIsTo?oe.reverse():oe:!k&&g.band?Zt(E,D,g.band,S):null,he=k||U||J?[]:vn(z,[E,D,...g.obstacles]),ye=J?[J]:!k&&U?Yo(ae(Y,_),[E,D,...g.obstacles]):[];if(!k&&he.length===0&&ye.length===0)return null;let Ne=ye[ye.length-1],Ve=U||J?ye[0]?.[0]:he[0]?.p0,re=U||J?Ne?.[Ne.length-1]:he[he.length-1]?.p1,Ae=ie=>ie.map(ke=>`M ${ke.p0.x} ${ke.p0.y} Q ${ke.c.x} ${ke.c.y} ${ke.p1.x} ${ke.p1.y}`).join(" "),je=`M ${M.x-v} ${M.y} A ${v} ${v} 0 1 1 ${M.x+v} ${M.y} A ${v} ${v} 0 0 1 ${M.x-v} ${M.y}`,ne=k?je:J?yi(J,T.route):U?kt(ye):Ae(he),Je=ie=>({x:ie.x-8,y:ie.y-8,width:ie.width+16,height:ie.height+16}),ht=[E,D,...g.hosts,...g.obstacles].map(Je),jt=k?je:J?kt(ye):U?kt(Yo(ae(Y,_),ht)):Ae(vn(z,ht)),Ge=g.edges.length===1?g.edges[0]:null,$e=Ge?Ct(C.kind,Ge.from,Ge.to):null,nt=$e!==null&&o.includes($e),We=$e!==null?s?.get($e):void 0,ze=g.edges.some(ie=>x.has(ie.from)||x.has(ie.to)),_e=g.tie?.toward??"",et=g.tie!==void 0&&(d!==null&&(_e===d||g.tie.holds.includes(d)||g.said?.includes(d)===!0)||x.has(_e))&&!X.has(_e);et&&X.add(_e);let ot=!r&&x.size>0&&ze||et,Me=a!==null&&C.kind===a||nt,rt=l?.(C)!==void 0;if(r&&!rt||!r&&!rt&&x.size>0&&!ze&&!Me&&!et||g.said!==void 0&&!et&&!g.said.some(ie=>x.has(ie))&&!Me)return null;let it=r?Bo({emphasized:a!==null,stressed:Me,anyChosen:I,mine:ze,touches:f(C),siblings:W.get(C.id)??1}):Ho({edgeChosen:nt,lit:ot,anyLit:I||a!==null,own:Q.opacity,kit:u.emphasis}),ft=ot&&Ve&&re?g.tie?g.tie.cardIsTo?Ve:re:g.edges.some(ie=>x.has(ie.from))?re:Ve:null,St=(0,Fe.jsxs)("g",{children:[(0,Fe.jsx)("path",{"data-graview-connector":C.kind,"data-graview-edges":g.edges.length,"data-graview-from":g.fromAnchor,"data-graview-to":g.toAnchor,"data-graview-lit":ot||void 0,"data-graview-activity":l?.(C)?.manner,"data-graview-provisional":We!==void 0||void 0,opacity:it*(C.opacity??1)*(We!==void 0?un:1),d:ne,fill:"none",stroke:_t(Q),strokeWidth:(ot?Math.max(1.6,mo(Q,r)):mo(Q,r))+(Me?.6:0),strokeDasharray:We!==void 0?cn:Tn[Q.pattern],strokeLinecap:"round"}),ft?(0,Fe.jsx)("circle",{cx:ft.x,cy:ft.y,r:2.6,fill:_t(Q),opacity:it}):null,k&&r?(0,Fe.jsx)("text",{x:M.x,y:M.y-v-5,textAnchor:"middle",opacity:it,style:{font:"9px var(--graview-font-body, system-ui)",letterSpacing:"0.09em",textTransform:"uppercase",fill:"var(--graview-ink-faint)"},children:Wt(C.kind).toLowerCase()}):null]},g.key),Ke=null;return $e&&c&&!k&&it>=.2&&(Ke=(0,Fe.jsx)("path",{"data-graview-edge":$e,className:"graview-edge-hit",d:jt,fill:"none",pathLength:1,strokeDasharray:"0.86",strokeDashoffset:-.07,stroke:"transparent",strokeWidth:14,style:{pointerEvents:"stroke",cursor:"pointer"},onClick:ie=>{ie.stopPropagation(),c($e,{x:ie.clientX,y:ie.clientY})},onContextMenu:ie=>{ie.preventDefault(),ie.stopPropagation(),c($e,{x:ie.clientX,y:ie.clientY})},children:We!==void 0?(0,Fe.jsx)("title",{children:We}):null},`hit:${g.key}`)),{key:g.key,line:St,hit:Ke}});return(0,Fe.jsxs)(Fe.Fragment,{children:[(0,Fe.jsx)("svg",{"aria-hidden":"true","data-graview-world":"",width:t.width,height:t.height,style:{position:"absolute",left:0,top:0,pointerEvents:"none",zIndex:Ce.ties},children:te.map(g=>g?.line)}),te.some(g=>g?.hit)?(0,Fe.jsx)("svg",{"data-graview-world":"",width:t.width,height:t.height,style:{position:"absolute",left:0,top:0,pointerEvents:"none",zIndex:Ce.tieLabels},children:te.map(g=>g?.hit)}):null]})}var Da=e=>e.length*8.4+16;function Li(e,t){let n=new Map;for(let a of e){let i=n.get(a.key);i?i.push(a):n.set(a.key,[a])}let r=[...n.values()].map(a=>{let i=Math.min(...a.map(c=>c.top)),l=a.filter(c=>c.top-i<=12);return{key:a[0].key,text:a[0].text,left:Math.min(...l.map(c=>c.left)),right:Math.max(...l.map(c=>c.right)),top:i}});r.sort((a,i)=>a.top-i.top||a.left-i.left);let o=r.map(a=>{let i=Math.max(a.right-a.left,Math.min(300,Da(a.text))),l=(a.left+a.right)/2;return{left:l-i/2,right:l+i/2}});return r.map((a,i)=>{let l=r.map((w,y)=>({other:w,at:y})).filter(({other:w})=>w!==a&&Math.abs(w.top-a.top)<=12),c=l.filter(({other:w})=>w.right<=a.left).map(({other:w,at:y})=>o[y].right+8<=(w.right+a.left)/2?o[y].right+8:(w.right+a.left+8)/2),s=l.filter(({other:w})=>w.left>=a.right).map(({other:w,at:y})=>o[y].left-8>=(a.right+w.left)/2?o[y].left-8:(a.right+w.left-8)/2),d=Math.max(t.left,...c),u=Math.min(t.right,...s),h=a.right-a.left,p=o[i].right-o[i].left,b=Math.max(h,Math.min(p,u-d)),f=(a.left+a.right)/2,x=h>=b?a.left:Math.max(d,Math.min(f-b/2,u-b));return{key:a.key,text:a.text,left:x,width:b,top:a.top}})}function Kn(e){return e<640?{left:8,right:56}:{left:8,right:Math.round(Math.min(128,e*.107))}}function Fa(e){return Math.min(260,16+e.length*6.6)}var kn=(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 Ii(e,t,n){let r=new Map;for(let i of e){let l=r.get(i.said);l?l.push(i):r.set(i.said,[i])}let o=[],a=[];for(let[i,l]of r){let c=l[0],s=Fa(i),{end:d,far:u}=c,h=x=>Math.max(0,Math.min(n.width-s,x)),p=[{x:h(d.x-s/2),y:u.y-22-6,width:s,height:22},{x:h(d.x-s/2),y:u.y+u.height+6,width:s,height:22},{x:u.x+u.width+6,y:d.y-22/2,width:s,height:22},{x:u.x-s-6,y:d.y-22/2,width:s,height:22}],b=p[0],f=1/0;for(let x of p){let y=x.x<0||x.y<0||x.x+x.width>n.width||x.y+x.height>n.height?1e9:0;for(let O of t)y+=kn(x,O.title)*100+kn(x,O.box);for(let O of o)y+=kn(x,O)*100;if(y<f&&(f=y,b=x),y===0)break}o.push(b),a.push({said:i,keys:l.map(x=>x.key),...b})}return a}var Ai=(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 Qo(e,t){let n=new Set;for(let r of e)(t.edgeId&&r.edgeId===t.edgeId||t.point&&(Ai(r.fromBox,t.point)||Ai(r.toBox,t.point))||t.ids?.some(o=>r.ids.includes(o))||t.box&&(kn(t.box,r.fromBox)>0||kn(t.box,r.toBox)>0))&&n.add(r.key);return n}var pe=ce(Le(),1);function Pi(e){let t=mr(e);return t.length>0?new Map(t.map(n=>[Ct(n.edge.kind,n.edge.from,n.edge.to),fr(n)])):void 0}function Ci({frame:e,width:t,height:n,scheme:r,overview:o,selection:a,emphasis:i,stageRef:l,store:c,graphNodes:s,onPickEdge:d,liveOf:u,holding:h=!1,provisional:p,focusId:b=null,beside:f=!1}){let[x,w]=(0,ge.useState)(0),[y,O]=(0,ge.useState)(null),I=e.t<1,W=(0,ge.useRef)(""),H=(0,ge.useRef)([]),X=()=>[...l.current?.querySelectorAll("[data-graview-relation] > span")??[]].map(A=>{let G=A.getBoundingClientRect();return`${Math.round(G.left)},${Math.round(G.top)},${Math.round(G.width)}`}).join(" ");(0,ge.useLayoutEffect)(()=>{I||h||(W.current=X(),H.current=e.nodes,O(_n(e.nodes,e.connectors,l.current,o,r)))},[e,I,h,a,o,s,r,x,l]),(0,ge.useEffect)(()=>{if(I||h||o||typeof requestAnimationFrame>"u")return;let A=requestAnimationFrame(()=>{X()!==W.current&&w(G=>G+1)});return()=>cancelAnimationFrame(A)},[y]);let te=e.nodes.map(A=>A.id).join(`
4
- `);(0,ge.useLayoutEffect)(()=>{let A=l.current;if(A===null||typeof window>"u")return;let G=0,Y=()=>{G===0&&(G=requestAnimationFrame(()=>{G=0,w(k=>k+1)}))};A.addEventListener("scroll",Y,{capture:!0,passive:!0}),window.addEventListener("resize",Y,{passive:!0});let _=typeof ResizeObserver>"u"?null:new ResizeObserver(Y);if(_){_.observe(A);for(let k of A.querySelectorAll("[data-graview-view]"))_.observe(k)}return()=>{G!==0&&cancelAnimationFrame(G),A.removeEventListener("scroll",Y,{capture:!0}),window.removeEventListener("resize",Y),_?.disconnect()}},[l,te]);let[g,S]=(0,ge.useState)(null),C=(y??[]).some(A=>A.tie!==void 0);if((0,ge.useEffect)(()=>{let A=l.current;if(!C||A===null)return;let G=_=>{let k=_.target?.closest?.("[data-graview-pick], [data-graview-view]");S(k?.getAttribute("data-graview-pick")??k?.getAttribute("data-graview-view")??null)},Y=()=>S(null);return A.addEventListener("pointerover",G),A.addEventListener("focusin",G),A.addEventListener("pointerleave",Y),A.addEventListener("focusout",Y),()=>{A.removeEventListener("pointerover",G),A.removeEventListener("focusin",G),A.removeEventListener("pointerleave",Y),A.removeEventListener("focusout",Y)}},[C,l]),I)return null;let E=(y&&h?Ei(y,H.current,e.nodes):y)??_n(e.nodes,e.connectors,null,o,r),D=new Set;for(let A of E){if(A.edges.length!==1)continue;let G=A.edges[0];D.add(`${A.connector.kind}|${G.from}|${G.to}`)}return(0,pe.jsxs)(pe.Fragment,{children:[(0,pe.jsx)(Oi,{strands:E,result:e,scheme:r,overview:o,selection:a,emphasis:i,stageRef:l,onPickEdge:d,liveOf:u,pointed:g,...p?{provisional:p}:{}}),o&&fn(a,{overview:o,focusId:b,beside:f},A=>c.graph.getNode(A)?.kind).records.length>0?(0,pe.jsx)(ge.Suspense,{fallback:null,children:(0,pe.jsx)(Wa,{frame:e,width:t,height:n,stageRef:l,tick:x,store:c,graphVersion:s,selection:a,view:{overview:o,focusId:b,beside:f},rulers:p?{...Ti,unsureOf:(A,G,Y)=>p.get(Ct(A,G,Y))}:Ti})}):null,o?null:(0,pe.jsx)(Va,{...p?{provisional:p}:{},stageRef:l,nodes:e.nodes,scheme:r,selection:a,store:c,graphNodes:s,overview:o,width:t,height:n,onPickEdge:d,alreadyDrawn:D,tick:x})]})}var Ti={visibleRect:Qt,clipQuadratic:vn,unsureDash:cn,unsureOpacity:un},ja=ln(an(()=>import("./chunk.HHI65WFZ.js"))),Wa=ja.part((e,t)=>(0,pe.jsx)(e.RecordLinks,{...t}),{what:"The links",quiet:!0}),Ya=44;function Va({stageRef:e,nodes:t,scheme:n,selection:r,store:o,graphNodes:a,overview:i,width:l,height:c,onPickEdge:s,alreadyDrawn:d,tick:u,provisional:h}){let p=Pt(),b=(0,ge.useMemo)(()=>{if(r.length===0||r.length>4)return[];let g=new Set(r),S=[];for(let E of r){let D=Ot(E);D&&S.push({kind:D.kind,self:D.from,other:D.to})}for(let E of o.graph.allEdges()){let D=g.has(E.from)?E.from:g.has(E.to)?E.to:null;if(!D)continue;let A=D===E.from?E.to:E.from;g.has(A)||S.push({kind:E.kind,self:D,other:A})}if(S.length<=14)return S;let C=new Set(t.map(E=>E.id));return S.map((E,D)=>({tie:E,index:D,real:C.has(E.other)?0:1})).sort((E,D)=>E.real-D.real||E.index-D.index).slice(0,14).map(({tie:E})=>E)},[o,r,a,t]),f=()=>{if(b.length===0||typeof document>"u")return[];let g=e.current?.getBoundingClientRect();if(!g)return[];let S=[...e.current?.querySelectorAll("[data-graview-joins]")??[]].find(k=>{if(k.closest("[data-graview-offstage]"))return!1;try{let T=JSON.parse(k.getAttribute("data-graview-joins")??"[]");return T.length===r.length&&T.every(Q=>r.includes(Q))}catch{return!1}});if(S){let k=Qt(S,e.current);if(!k)return[];let T=[];for(let Q of r){let v=t.find($=>$.id===Q);if(!v)continue;let M=De(e.current,v.id,i)??tt(v,n),L=M?zn(k,M):null;if(!M||!L)continue;let B=[...o.graph.allEdges()].find($=>$.from===Q&&r.includes($.to)||$.to===Q&&r.includes($.from));T.push({key:`join:${Q}`,self:Q,other:"",others:1,kind:B?.kind??"",endX:L.to.x,endY:L.to.y,...L,fromBox:k,toBox:M,proxy:!1,edgeId:B?Ct(B.kind,B.from,B.to):null})}return T}let C=(k,T)=>{let Q=e.current?.querySelectorAll(`[data-graview-pick="${CSS.escape(k)}"], [data-graview-slot="${CSS.escape(k)}"]`),v=[];for(let M of Q??[]){if(M.closest("[data-graview-offstage]")||T(M)||M.closest("[data-graview-mark]"))continue;let L=Qt(M,e.current);L&&v.push(L)}return v.sort((M,L)=>M.width*M.height-L.width*L.height)},E=k=>t.find(T=>T.id===k)??t.find(T=>T.aggregate?.memberIds.includes(k)),D=k=>`[data-graview-pick="${CSS.escape(k)}"], [data-graview-slot="${CSS.escape(k)}"]`,A=(k,T)=>{let Q=e.current;if(!Q)return!1;for(let v of Q.querySelectorAll("[data-graview-view]")){let M=v.querySelector(D(k));if(M===null||M.closest("[data-graview-offstage]"))continue;let L=v.querySelector(D(T));if(L!==null&&!L.closest("[data-graview-offstage]"))return!0}return!1},G=[];if(!i&&e.current){for(let k of t){if(Math.round(k.plane)!==1)continue;let T=De(e.current,k.id,!1);T&&G.push(T)}for(let k of e.current.querySelectorAll("[data-graview-relation] > span")){let T=k.getBoundingClientRect();T.width>0&&T.height>0&&G.push({x:T.left-g.left,y:T.top-g.top,width:T.width,height:T.height})}}let Y=new Map,_=[];for(let k of b){if(A(k.self,k.other))continue;let T=E(k.self),Q=T?e.current?.querySelector(`[data-graview-view="${CSS.escape(T.id)}"]`):null,v=!i&&T?.id===k.self&&Math.round(T.plane)===1?De(e.current,T.id,!1):null,M=v?[v]:C(k.self,()=>!1);if(!(M.length>0)&&T){let re=De(e.current,T.id,!1)??tt(T,n);re&&M.push(re)}let B=t.find(re=>re.id===k.other),$=[],R=!1;if(B){let re=De(e.current,B.id,i)??tt(B,n);re&&$.push(re)}else if($.push(...C(k.other,re=>Q?Q.contains(re):!1)),$.length===0){let re=E(k.other);if(re&&(!T||re.id!==T.id)){let Ae=De(e.current,re.id,i)??tt(re,n);Ae&&($.push(Ae),R=!0)}}if(M.length===0||$.length===0||R&&i)continue;let N=M[0],F=$[0],z=1/0;for(let re of M)for(let Ae of $){let je=Math.hypot(re.x+re.width/2-(Ae.x+Ae.width/2),re.y+re.height/2-(Ae.y+Ae.height/2));je<z&&(z=je,N=re,F=Ae)}if(d?.has(`${k.kind}|${k.self}|${k.other}`)||d?.has(`${k.kind}|${k.other}|${k.self}`))continue;let V=`${k.kind}:${Math.round(N.x)},${Math.round(N.y)}:${Math.round(F.x)},${Math.round(F.y)}`,U=Y.get(V);if(U){U.others+=1;continue}let ae=zn(N,F);if(!ae)continue;let{from:oe,control:J}=ae,he=v&&N===v?Zt(N,F,G,_.length):void 0,ye=he?he[he.length-1]:ae.to,Ne=[...o.graph.allEdges()].find(re=>re.kind===k.kind&&(re.from===k.self&&re.to===k.other||re.from===k.other&&re.to===k.self)),Ve={key:`${k.kind}:${k.self}:${k.other}`,self:k.self,other:k.other,others:1,kind:k.kind,endX:ye.x,endY:ye.y,from:oe,to:ye,control:J,fromBox:N,toBox:F,...he?{points:he}:{},proxy:R,edgeId:Ne?Ct(Ne.kind,Ne.from,Ne.to):null};Y.set(V,Ve),_.push(Ve)}for(let k of _){let T=[...o.graph.allEdges()].find(B=>B.kind===k.kind&&(B.from===k.self&&B.to===k.other||B.from===k.other&&B.to===k.self)),Q=o.graph.getNode(k.self),v=o.graph.getNode(k.other);if(!T||!Q||!v)continue;let M=T.from===k.self?"out":"in",L=hr(o.schema,M==="out"?Q.kind:v.kind,k.kind,M);k.said=k.proxy?`${L}: ${Yt(o.schema,v.kind,k.others)}`:`${L}: ${Rn(o.schema.tryDefinition(v.kind),v)}`}return _},[x,w]=(0,ge.useState)([]),[y,O]=(0,ge.useState)([]);(0,ge.useLayoutEffect)(()=>{let g=f();w(g),O(g.some(S=>S.said)?I(g):[])},[b,t,i,n,l,c,d,u,e]);let I=g=>{let S=e.current;if(!S)return[];let C=[];for(let E of S.querySelectorAll("[data-graview-view]")){let D=[...E.children].find(G=>!G.classList.contains("graview-kind-tag")),A=D?Qt(D,S):null;A&&C.push({box:A,title:{...A,height:Math.min(A.height,Ya)}})}return Ii(g.flatMap(E=>E.said?[{key:E.key,said:E.said,end:{x:E.endX,y:E.endY},far:E.toBox}]:[]),C,{width:l,height:c})},[W,H]=(0,ge.useState)(()=>new Set),X=(0,ge.useRef)([]);X.current=x.map(g=>({key:g.key,fromBox:g.fromBox,toBox:g.toBox,ids:[g.self,g.other],edgeId:g.edgeId}));let te=y.length>0;return(0,ge.useEffect)(()=>{let g=e.current;if(!g||!te)return;let S=k=>H(T=>T.size===k.size&&[...k].every(Q=>T.has(Q))?T:k),C=0,E=null,D=()=>{if(C=0,!E)return;let k=g.getBoundingClientRect(),T=E.target instanceof Element?E.target:null;S(Qo(X.current,{point:{x:E.clientX-k.left,y:E.clientY-k.top},edgeId:T?.closest("[data-graview-edge]")?.getAttribute("data-graview-edge")??null}))},A=k=>{E=k,C||(C=requestAnimationFrame(D))},G=()=>{E=null,S(new Set)},Y=k=>{let T=k.target instanceof Element?k.target:null;if(!T)return;let Q=g.getBoundingClientRect(),v=T.getBoundingClientRect(),M=T.closest("[data-graview-pick]")?.getAttribute("data-graview-pick")??T.closest("[data-graview-view]")?.getAttribute("data-graview-view");S(Qo(X.current,{...M?{ids:[M]}:{},box:{x:v.left-Q.left,y:v.top-Q.top,width:v.width,height:v.height}}))},_=k=>{k.relatedTarget instanceof Node&&g.contains(k.relatedTarget)||S(new Set)};return g.addEventListener("pointermove",A,{passive:!0}),g.addEventListener("pointerleave",G),g.addEventListener("focusin",Y),g.addEventListener("focusout",_),()=>{C&&cancelAnimationFrame(C),g.removeEventListener("pointermove",A),g.removeEventListener("pointerleave",G),g.removeEventListener("focusin",Y),g.removeEventListener("focusout",_)}},[e,te]),x.length===0?null:(0,pe.jsxs)(pe.Fragment,{children:[(0,pe.jsx)("svg",{"aria-hidden":x.some(g=>g.edgeId)?void 0:!0,"data-graview-ties":x.length,"data-graview-world":"",width:l,height:c,style:{position:"absolute",left:0,top:0,pointerEvents:"none",zIndex:Ce.lines},children:x.map(g=>{let{connector:S,style:C}=Xt(p,g.kind);if(!S.visible)return null;let E=g.edgeId?h?.get(g.edgeId):void 0,D={p0:g.from,c:g.control,p1:g.to},A=g.points?Vo(g.points,10):S.route==="orthogonal"?kt([xn(g.from,g.to)]):(({p0:Y,c:_,p1:k})=>`M ${Y.x} ${Y.y} Q ${_.x} ${_.y} ${k.x} ${k.y}`)(Yn(S.route,D)),G=null;if(g.edgeId&&s&&!g.proxy){let Y=(k,T)=>T.x>=k.x&&T.x<=k.x+k.width&&T.y>=k.y&&T.y<=k.y+k.height,_=g.points?[...g.points]:[];for(let k=0;k<=(g.points?-1:40);k++){let T=gi(S.route,D,k/40);Y(g.fromBox,T)||Y(g.toBox,T)||_.push(T)}_.length>=2&&(G=(0,pe.jsx)("path",{"data-graview-edge":g.edgeId,className:"graview-edge-hit",d:`M ${_[0].x} ${_[0].y} ${_.slice(1).map(k=>`L ${k.x} ${k.y}`).join(" ")}`,fill:"none",pathLength:1,strokeDasharray:"0.86",strokeDashoffset:-.07,stroke:"transparent",strokeWidth:14,style:{pointerEvents:"stroke",cursor:"pointer"},onClick:k=>{k.stopPropagation(),s(g.edgeId,{x:k.clientX,y:k.clientY})},onContextMenu:k=>{k.preventDefault(),k.stopPropagation(),s(g.edgeId,{x:k.clientX,y:k.clientY})},children:E!==void 0?(0,pe.jsx)("title",{children:E}):null}))}return(0,pe.jsxs)("g",{opacity:(g.proxy?.32:.72)*(E!==void 0?un:1),children:[(0,pe.jsx)("path",{"data-graview-tie":g.kind,"data-graview-tie-proxy":g.proxy||void 0,"data-graview-provisional":E!==void 0||void 0,d:A,fill:"none",stroke:_t(C),strokeWidth:g.proxy?1.1:1.6,strokeDasharray:E!==void 0?cn:Tn[C.pattern],strokeLinecap:"round"}),(0,pe.jsx)("circle",{cx:g.endX,cy:g.endY,r:g.proxy?2:2.6,fill:_t(C)}),G]},g.key)})}),(0,pe.jsx)("div",{"aria-hidden":"true","data-graview-world":"",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:Ce.tieLabels},children:y.map(g=>{let S=x.find(C=>C.key===g.keys[0]);return(0,pe.jsx)("span",{className:"graview-record-link-said","data-graview-link-said":S?.kind,"data-graview-lands":S?.proxy?"district":"record","data-graview-said-for":g.keys.length,"data-graview-tie-said":g.keys.some(C=>W.has(C))?"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 Ni({nodes:e,scheme:t,width:n,stageRef:r,moving:o=!1,holding:a=!1}){let i=Pt(),[l,c]=(0,ge.useState)([]);(0,ge.useLayoutEffect)(()=>{o||a||c(s())},[e,o,a,t,n,r]);function s(){let d=[];for(let h of e){if(!h.via||Math.round(h.plane)!==1)continue;let p=De(r.current,h.id,!1,!0),{scale:b}=Xe(1,t);d.push({key:`${h.via.edgeKind}|${h.via.direction}`,text:h.via.description??`${h.via.direction==="in"?"\u2190":"\u2192"} ${Wt(h.via.edgeKind).toLowerCase()}`,left:p?.x??h.x,right:p?p.x+p.width:h.x+h.width*b,top:p?.y??h.y})}let u=Kn(n);return Li(d,{left:u.left,right:n-u.right})}return l.length===0||!i.captions.visible||o?null:(0,pe.jsx)("div",{"aria-hidden":"true",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:Ce.lines},children:l.map(d=>{let{left:u,width:h}=d;return(0,pe.jsx)("div",{"data-graview-relation":d.key,title:d.text,style:{position:"absolute",left:u,width:h,textAlign:"center",top:Math.max(0,d.top-19),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:d.text})},d.key)})})}var Ft=ce(Be(),1);var za=new Set;function $i(e,t,n,r,o,a,i,l=0){let{store:c,views:s,hiddenKinds:d}=xe(),u=At(),h=(0,Ft.useContext)(zt),p=co(),b=(0,Ft.useMemo)(()=>{let w={};for(let y of p){if(y.subjectId===void 0)continue;let O=w[y.subjectId]??=[];for(let I of y.nodeIds)I!==y.subjectId&&!O.includes(I)&&O.push(I)}return w},[p]),f=(0,Ft.useMemo)(()=>({flagged:new Set(p.flatMap(w=>w.nodeIds)),touched:Pn(c.log.all())}),[p,c,i]),x=(0,Ft.useMemo)(()=>({hits:u?An(u):za,...f}),[u,f]);return(0,Ft.useMemo)(()=>({...e,cityZoom:o,...h?{besideTheMap:!0}:{},...d.size>0?{hiddenKinds:[...d].sort()}:{},...Object.keys(b).length>0?{judged:b}:{},relevance:x,inset:{...Kn((t?.width??1200)-a.right),top:8,bottom:r?0:56},chrome:[{x:(t?.width??1200)-a.right-176,y:0,width:176,height:100}],...a.right>0||a.bottom>0?{dock:a}:{},...l>0?{headroom:l}:{},unit:n,plainGroups:c.schema.kinds.filter(w=>lr(s.lookup(w,{cardinality:"many",fidelity:"full"}))),cityOrder:rr(Rr({name:"scene",schema:c.schema,mutations:c.allMutations().filter(w=>!w.derived)}).order.map(w=>w.kind),s.arrangement?.()?.order),screens:s.places().reduce((w,y)=>((w[y.kind]??=[]).push({as:y.as,title:y.title,...y.across?{across:y.across}:{}}),w),{}),...t?{width:t.width,height:r?Math.max(0,t.height-64):t.height}:{}}),[e,t,n,c,s,d,b,x,o,r,h,a.right,a.bottom,l])}var ut=ce(Be(),1);var Bi=ce(Be(),1);function Un(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 Hi(e){(0,Bi.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&&Ka(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 _a=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 Ka(e){return _a.has(e.localName.toLowerCase())}var Jt=ce(Le(),1);function Di({node:e,useDom:t,touched:n,frontY:r,centerY:o,screen:a,onDrawnHeight:i,crowded:l,activity:c,scheme:s,canvasWidth:d,canvasHeight:u,selected:h,onSelect:p,onPick:b,onTravel:f,onMenu:x,selection:w,onJackIn:y,onDragStart:O,onDragMove:I,onDragEnd:W,swallowClick:H,children:X}){let{brand:te,store:g,actsDoor:S}=xe(),C=e.beyond?`${e.beyond.length} more district${e.beyond.length===1?"":"s"}`:e.aggregate?.opens?.in==="place"?`${e.aggregate.label}, ${Yt(g.schema,e.aggregate.kind,e.aggregate.memberIds.length)}`:e.aggregate?e.aggregate.label:(()=>{let R=g.graph.getNode(e.id);return R?Rn(g.schema.tryDefinition(e.kind),R):e.id})(),[E,D]=(0,ut.useState)(null),A=Math.round(e.plane)===0&&!e.aggregate;(0,ut.useLayoutEffect)(()=>{if(!A)return;let R=v.current;if(!R)return;let N=()=>{let z=[...R.children].find(J=>J.dataset.graviewKindtag===void 0);if(!z)return;let V=R.getBoundingClientRect(),U=z.getBoundingClientRect(),ae=R.offsetWidth>0?V.width/R.offsetWidth:1,oe={top:Math.round((U.top-V.top)/ae)-9,right:Math.round((V.right-U.right)/ae)+14};D(J=>J&&J.top===oe.top&&J.right===oe.right?J:oe)};if(typeof ResizeObserver>"u"){N();return}let F=new ResizeObserver(N);F.observe(R);for(let z of R.children)F.observe(z);return()=>F.disconnect()},[A,e.id]);let G=r!==void 0?0:e.plane-(1-(e.depth??1))*.55,Y=Math.max(0,Math.min(2,Math.floor(G))),_=Math.max(0,Math.min(2,Math.ceil(G))),k=Y===_?Xe(Y,s):In(Xe(Y,s),Xe(_,s),G-Y),T=ur(k,e.x,e.y,d,u),Q=Xe(Math.max(0,Math.min(2,Math.round(G))),s).blur,v=(0,ut.useRef)(null);Hi(v);let M=e.natural,L=M?Math.min(e.width/M.width,e.height/M.height):1,B=(0,ut.useRef)(null);(0,ut.useEffect)(()=>{if(!a||!i)return;let R=B.current;if(!R||typeof ResizeObserver>"u")return;let N=()=>{let ae=0,oe=0;for(let J of R.children)if(!(!(J instanceof HTMLElement)||J.classList.contains("graview-screen-fullscreen"))){ae=Math.max(ae,J.offsetTop+J.offsetHeight);for(let he of[J,...J.querySelectorAll("*")]){let ye=getComputedStyle(he).overflowY;(ye==="auto"||ye==="scroll")&&(oe+=he.scrollHeight-he.clientHeight)}}i(ae+oe)},F=0,z=()=>{F||(F=requestAnimationFrame(()=>{F=0,N()}))};N();let V=new ResizeObserver(z);V.observe(R);for(let ae of R.children)V.observe(ae);let U=new MutationObserver(z);return U.observe(R,{childList:!0,subtree:!0,characterData:!0,attributes:!0}),()=>{F&&cancelAnimationFrame(F),V.disconnect(),U.disconnect(),i(void 0)}},[a,i,e.id]);let $=t?{transform:mi(T),transformOrigin:"0 0",filter:Q>0?`blur(${Q}px)`:void 0,opacity:(1-k.falloff*.55)*(e.opacity??1),"--graview-lift-low":fi(k.shadow,s),...r!==void 0?{"--graview-front-y":`${r.toFixed(1)}px`}:{},...o!==void 0?{"--graview-center-y":`${o.toFixed(1)}px`}:{}}:{};return(0,Jt.jsxs)("div",{ref:v,"data-graview-view":e.id,...t?{}:{drawable:""},"data-graview-plane":Math.round(e.plane),"data-graview-selected":h||void 0,"data-graview-touched":n||void 0,"data-graview-plot":r!==void 0?"":void 0,"data-graview-screen":a?"":void 0,"data-graview-record-focus":Math.round(e.plane)===0&&!e.aggregate&&!M&&!a?"":void 0,"data-graview-nested":e.nestedUnder??void 0,"data-graview-crowded":l||void 0,"data-graview-pinned":e.pinned||void 0,"data-graview-activity":c?c.manner:void 0,"data-graview-wrote":c?.wrote||void 0,"data-graview-read":c&&!c.wrote?!0:void 0,"data-graview-broke":c?.broke||void 0,title:c?`${ii[c.manner]} ${c.wrote?"changed this":"read this"}: ${c.intent}`:e.aggregate&&Math.round(e.plane)!==0?`Open ${e.aggregate.label}`:void 0,role:"group","aria-label":C,"aria-keyshortcuts":S&&!e.beyond?S.key:void 0,tabIndex:0,onPointerDown:O,onPointerMove:I,onPointerUp:W,onPointerCancel:W,onClick:R=>{if(H.current)return;let N=R.target?.closest("input, textarea, select, button, a[href], [contenteditable='true']");if(N&&!N.hasAttribute("data-graview-pick"))return;let F=R.metaKey||R.shiftKey,z=xt(R.target);if(z&&z!==e.id){R.stopPropagation(),b(z,F,Un(R.target)??void 0);return}p(F)},onKeyDown:R=>{if(S&&!e.beyond&&R.key.toLowerCase()===S.key.toLowerCase()&&!R.metaKey&&!R.ctrlKey&&!R.altKey&&!R.target?.closest("input, textarea, select, [contenteditable='true']")){R.preventDefault(),R.stopPropagation();let U=xt(R.target)??e.id;w.includes(U)||b(U,!1),S.open(R.target instanceof HTMLElement?R.target:R.currentTarget);return}if(R.key!=="Enter"&&R.key!==" "||R.target?.closest("input, textarea, select, button, [contenteditable='true']"))return;let F=xt(R.target);if(R.preventDefault(),R.stopPropagation(),!F||F===e.id){w.length===1&&w[0]===e.id&&!R.metaKey&&!R.shiftKey?y():p(R.metaKey||R.shiftKey);return}let z=Un(R.target);(z?w.length===z.length&&z.every(U=>w.includes(U)):w.length===1&&w[0]===F)&&!R.metaKey&&!R.shiftKey?f(F):b(F,R.metaKey||R.shiftKey,z??void 0)},onContextMenu:R=>{let N=xt(R.target);R.preventDefault(),R.stopPropagation();let F=N&&N!==e.id?N:e.id;b(F,!1,(F===N?Un(R.target):null)??void 0),x({x:R.clientX,y:R.clientY,on:F})},onDoubleClick:R=>{let N=xt(R.target);if(N&&N!==e.id){R.stopPropagation(),f(N);return}y()},style:{position:"absolute",...t?{}:{pointerEvents:"none"},zIndex:e.opened?Ce.opened:Ce.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",...$},children:[M?(0,Jt.jsx)("div",{ref:B,"data-graview-natural":`${Math.round(M.width)}x${Math.round(M.height)}`,style:{position:"absolute",left:"50%",top:"50%",width:M.width,height:M.height,transform:`translate(-50%, -50%) scale(${L})`,transformOrigin:"50% 50%",display:"flex",flexDirection:"column"},children:X}):X,Math.round(e.plane)===0&&!e.aggregate?(0,Jt.jsxs)("span",{"data-graview-kindtag":"",className:"graview-kind-tag","aria-hidden":"true",style:{...E??{},"--graview-hue":Math.round(rn(e.kind,te?.accents))},children:[(0,Jt.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(rn(e.kind,te?.accents))} 55% var(--graview-tint-lightness) / 0.9)`}}),nr(g.schema.tryDefinition(e.kind),e.kind)]}):null]})}var ue=ce(Le(),1);lo({search:kr,touchWeights:Pn});var Ua=e=>e?{activity:e}:{},Xa=e=>`${Math.round(e.x)} ${Math.round(e.y)}`,Fi=e=>e.stopPropagation(),Vi=.6,Gi=3,qa=80,ji=e=>Math.round(e.plane)===1&&(e.compact===!0||e.width<175||e.height<qa);function Qa(e){let[t,n]=(0,Z.useState)(1),r=(0,Z.useRef)(1);return(0,Z.useEffect)(()=>{e||(r.current=1,n(1))},[e]),[t,r,n]}function Za(e){let[t,n]=(0,Z.useState)({x:0,y:0}),r=(0,Z.useMemo)(()=>({x:(e.pan?.x??0)+t.x,y:(e.pan?.y??0)+t.y}),[e.pan,t]),o=(0,Z.useMemo)(()=>t.x===0&&t.y===0?e:Nt(e,r),[e,t,r]),a=(0,Z.useRef)(t);a.current=t;let i=(0,Z.useCallback)((l,c)=>{let s=a.current,d=(u,h,p)=>Math.max(Math.min(-u,h),Math.min(Math.max(u,h),p+h))-h;return{x:d(l.x,s.x,c.x),y:d(l.y,s.y,c.y)}},[]);return[r,o,i,a,n]}function Ja(e,t,n,r,o,a){let i=n!==null&&!t.overview,l=i?null:n,c=(0,Z.useMemo)(()=>{let h=t.pan?{...t,pan:void 0}:t;return l?hn(h,l.id,{x:l.x,y:l.y}):h},[t,l]),s=(0,Z.useMemo)(()=>Bn(e.graph,e.schema,c,r),[e,c,r,o]),d=(0,Z.useMemo)(()=>n&&i?To(s,n.id,{x:n.x,y:n.y})??Bn(e.graph,e.schema,hn(c,n.id,{x:n.x,y:n.y}),r):s,[s,n,i,e,c,r]);return[(0,Z.useMemo)(()=>Po(d,a??{x:0,y:0}),[d,a]),i]}function es(){let[e,t]=(0,Z.useState)(!1),[n,r]=(0,Z.useState)(!1),o=(0,Z.useRef)(null),a=(0,Z.useRef)(()=>!1),i=(0,Z.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 ts(e){let t=(0,Z.useRef)(!1),n=e!==null&&!t.current;return(0,Z.useEffect)(()=>{e!==null&&(t.current=!0)},[e]),n}function ns({registerScene:e,scheme:t,views:n},r,o){let a=(0,Z.useRef)(r);a.current=r,(0,Z.useEffect)(()=>(e({whereIs:i=>Wn(a.current,o.current,t,n,i)}),()=>e(null)),[e,t,n])}function os(e,t){(0,Z.useEffect)(()=>{let n;return e.onActive(r=>{let o=t.current;if(!o)return;let a=l=>{let c=o.getBoundingClientRect();e.set({x:l.clientX-c.left,y:l.clientY-c.top})},i=()=>e.set(null);r?(o.addEventListener("pointermove",a),o.addEventListener("pointerleave",i),n=()=>{o.removeEventListener("pointermove",a),o.removeEventListener("pointerleave",i)}):(n?.(),n=void 0)})},[e])}function rs(e,t,n,r,o,a){(0,Z.useEffect)(()=>{if(e==="dom")return;let i=n.current;if(!i||!t)return;let l=new Set;for(let s of r.nodes)(o.has(s.id)||s.aggregate?.memberIds.some(d=>o.has(d)))&&l.add(s.id);let c=t({canvas:i,layout:r,dirty:l,hostOf:s=>(i.parentElement??i).querySelector(`[data-graview-view="${CSS.escape(s)}"]`),drawOnDom:a});return()=>{c?.()}},[e,t,r,o,a])}function is(){let[e,t]=(0,Z.useState)(()=>new Set),n=(0,Z.useCallback)(r=>{t(o=>o.size===r.size&&[...r].every(a=>o.has(a))?o:new Set(r))},[]);return[e,n]}function as(){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 c of r){let s=e.get(c);s&&(a||=s.wrote,i||=s.read,l||=s.broke,(!o||s.at>o.at||s.at===o.at&&s.wrote&&!o.wrote)&&(o=s))}return o?{...o,wrote:a,read:i,broke:l}:void 0}}var Wi=(e,t)=>e.includes(t)?e.filter(n=>n!==t):[...e,t];function ss(){let{views:e,view:t,setView:n,setSelection:r}=xe(),o=At(),a=(0,Z.useContext)(zt),i=l=>{if(Ee(l.id)===null&&!l.aggregate)return!1;let c=e.resolve(l.kind,{cardinality:"many",fidelity:"full"})?.view;return c!==void 0&&c.generic!==!0};return l=>({onSelect:c=>{if(Gt(l.id)){r(d=>c?Wi(d,l.id):[l.id]);return}let s=l.aggregate?dn(l.id):[];if(t.overview){r(d=>c?[...new Set([...d,l.id])]:[l.id]);return}if(s.length===1&&!c&&Math.round(l.plane)!==0){let d=s[0];n(u=>oo(u,u.relation===d?null:d));return}r(d=>jo(l,d,c))},onPick:(c,s,d)=>r(u=>d?s?[...new Set([...u,...d])]:[...d]:s?Wi(u,c):[c]),onTravel:c=>{n(s=>({...gt(s,c),relation:null})),r([c])},onJackIn:()=>{let c=l.aggregate?.opens;if(c){c.in==="place"?n(u=>ro(u,l.id)):n(u=>Object.entries(c.within).reduce((h,[p,b])=>On(h,p,b),gt(sn(u,!1),c.focus))),r([]);return}let s=Ee(l.id),d=s!==null&&(o?.byKind[s]??0)>0;if(a&&s!==null&&t.overview&&!i(l)&&!(d&&t.q)){n(u=>On({...gt(u,`aggregate:${s}`),relation:null},"view",null)),r([]);return}n(u=>io(u,l.id,{ownPicture:i(l),...d&&u.q?{carry:u.q}:{}})),r(l.aggregate?[]:[l.id])}})}var ds=ln(an(()=>import("./chunk.YLQB3KBA.js"))),ls=ds.part((e,t)=>(0,ue.jsx)(e.Ribbons,{...t}),{what:"The relations",quiet:!0}),Yi="graview:map-from-above";function cs(){let[e,t]=(0,Z.useState)(()=>{try{return globalThis.localStorage?.getItem(Yi)==="1"}catch{return!1}}),n=(0,Z.useCallback)(r=>{t(r);try{globalThis.localStorage?.setItem(Yi,r?"1":"0")}catch{}},[]);return[e,n]}var us=ln(an(()=>import("./chunk.3ADPAGPY.js"))),hs=us.part((e,t)=>(0,ue.jsx)(e.Plots,{...t}),{quiet:!0});function fs({zoom:e,zoomBy:t,above:n,setAbove:r}){let o=(a,i,l,c)=>(0,ue.jsx)("button",{type:"button",className:"graview-zoom-button","data-testid":`zoom-${a}`,"aria-label":`Zoom ${a}`,title:`Zoom ${a} \u2014 or pinch, or ctrl+wheel`,disabled:c,onClick:()=>t(l),children:i});return(0,ue.jsxs)("div",{className:"graview-zoom","data-graview-foot":"",role:"group","aria-label":"Zoom",onPointerDown:Fi,onClick:Fi,children:[o("out","\u2212",1/1.25,e<=Vi+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>=Gi-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 ms({options:e,renderer:t="auto",attachRenderer:n,className:r,style:o,animate:a=!0,children:i}){let l=xe(),{store:c,scheme:s,views:d,view:u,setView:h,selection:p,setSelection:b,setMenuAt:f,emphasis:x,brand:w,noteMoved:y,robots:O,seatTalk:I,motion:W}=l,H=(0,Z.useContext)(zt),X=ao(I),te=(0,Z.useRef)(null),g=(0,Z.useRef)(null),S=hi(g),C=ui(),{zoomAbout:E,panBy:D}=ri({stage:g,view:u,setView:h}),A=It(),G=1,[Y,_,k]=Qa(u.overview),[T,Q]=cs(),v=(0,Z.useMemo)(()=>T?{...e,tilt:Mr}:e,[e,T]),{probe:M,dock:L}=ei(),B=!u.overview&&(u.zoom||u.past||u.relation)?Math.ceil(14+34*C/16+6):0,$=$i(v,S,C,X,G*Y,L,A,B),[R,N,F,z,V]=Za(u),U=(0,Z.useMemo)(()=>new Set(Object.keys(u.pins).filter(P=>Ee(P)===null)),[u.pins]),ae=ti(),[oe,J]=Ja(c,u,ae.held,$,A,N.pan),[he,ye,Ne,Ve,re,Ae]=es(),je=ts(S),ne=Vr(oe,{enabled:a&&!he&&!ye&&S!==null&&!je});(0,Z.useEffect)(()=>W.set(he||ye||ne.t<1),[W,he,ye,ne]);let Je=Gr(),ht=zr(),jt=Qr({view:u,result:oe,frame:ne,panned:R,closer:G,screenId:null,setCamera:V});ns(l,ne,g),os(l.pointer,g);let[Ge,$e]=is();rs(t,n,te,ne,Je,$e);let nt=t==="dom"||t==="auto"&&!n,We=as(),ze=ni({stage:g,pan:u.pan,setView:h,settled:Ae});re.current=ze.settle;let{onGroundDown:_e,onCardDown:et,onDragMove:ot,onDragUp:Me,swallow:rt}=oi({view:u,panned:R,limit:()=>bt(oe),panWithin:F,moveByTransform:nt,setView:h,setDragging:Ne,noteMoved:y,shift:ze,district:ae});E.current=(P,se,fe)=>{if(!u.overview)return;re.current();let Se=_.current,dt=Math.max(Vi,Math.min(Gi,Se*P));if(Math.abs(dt-Se)<1e-4)return;_.current=dt,Ve(),k(dt);let Pe=g.current?.getBoundingClientRect(),en=oe.visible??oe,tn={x:en.width/2,y:en.height/2},nn=Pe&&se!==void 0&&fe!==void 0?{x:se-Pe.left,y:fe-Pe.top}:tn,Xn=dt/Se;h(Mt=>Nt(Mt,Ao(Mt.pan??{x:0,y:0},z.current,nn,tn,Xn))),y()};let it=(P,se,fe=bt(oe))=>h(Se=>Nt(Se,F(fe,{x:(Se.pan?.x??0)+P,y:(Se.pan?.y??0)+se})));Jr(g,L,(P,se)=>it(P,se)),D.current=(P,se)=>{Ve();let fe=bt(oe),Se=u.pan??{x:0,y:0};if(nt){let dt=ze.offset();ze.shiftTo(F(fe,{x:Se.x+dt.x+P,y:Se.y+dt.y+se}),Se)}else it(P,se,fe);y()};let ft=ss(),St=Pt(),Ke=(0,Z.useCallback)(P=>Xt(St,P).connector.visible,[St]),ie=P=>We(ne.nodes.find(se=>se.id===P)),ke=(P,se,fe,Se)=>P.originY+R.y+qt(fe.col+fe.side/Se,fe.row+fe.side/Se,P.cell,P.tilt).y-se.y,Te={width:oe.width,height:oe.height},at={position:"relative",zIndex:Ce.stage,...Te},mt=P=>Wn(ne,g.current,s,d,P),yt=P=>nt||Ge.has(P),st=ne.nodes.filter(P=>P.screenOf===void 0).map(P=>(0,ue.jsx)(Di,{node:P,crowded:ji(P),useDom:yt(P.id),...P.plot&&ne.city&&Math.round(P.plane)===2?{frontY:ke(ne.city,P,P.plot,1),centerY:ke(ne.city,P,P.plot,2)}:{},touched:Je.has(P.id),...Ua(We(P)),scheme:s,canvasWidth:oe.width,canvasHeight:oe.height,selected:p.includes(P.id),...ft(P),onMenu:f,selection:p,onDragStart:se=>et(P,se),onDragMove:ot,onDragEnd:Me,swallowClick:rt,children:P.beyond?(0,ue.jsx)(si,{kinds:P.beyond}):P.aggregate?.opens?(0,ue.jsx)(ci,{node:P}):(0,ue.jsx)(di,{node:P,mode:"scene",selected:p.includes(P.id),...ji(P)?{fidelity:"glyph"}:{}})},P.id));return(0,ue.jsxs)("div",{ref:g,className:`graview-ground${r?` ${r}`:""}`,"data-graview-altitude":u.overview?"":void 0,"data-graview-reach":ne.city?Xa(bt(oe)):void 0,"data-graview-settled":ne.t>=1&&!jt.gliding()?"":void 0,"data-graview-box":S?`${S.width}x${S.height}`:void 0,onPointerDown:_e,onPointerMove:ot,onPointerUp:Me,onPointerCancel:Me,onClick:P=>{rt.current||P.target.closest("[data-graview-view], button, aside, section[aria-label], [data-graview-offstage], a, input, select")||(b([]),f(null))},style:{position:"relative",width:"100%",height:"100%",cursor:he?"grabbing":"grab",touchAction:"none","--graview-altitude":u.overview?1:0,...ne.city?{"--graview-lattice-cell":`${ne.city.cell.toFixed(2)}px`,"--graview-lattice-tilt":(ne.city.tilt??.5).toFixed(3),"--graview-lattice-x":`${(ne.city.originX+ne.city.pan.x).toFixed(1)}px`,"--graview-lattice-y":`${(ne.city.originY+ne.city.pan.y).toFixed(1)}px`}:{},...he?{userSelect:"none"}:{},overflow:"hidden",...o},children:[u.overview&&ne.city?(0,ue.jsx)(Z.Suspense,{fallback:null,children:(0,ue.jsx)(ls,{frame:ne,...Te,pan:ne.city.pan,store:c,graphVersion:A,selection:p,view:{overview:u.overview,focusId:u.focusId,beside:H},emphasis:x,hiddenKinds:l.hiddenKinds,drawn:Ke})}):null,(0,ue.jsx)("div",{ref:M,"aria-hidden":"true",style:{position:"absolute",top:0,right:0,width:"var(--graview-dock, 0px)",height:"var(--graview-sheet, 0px)",visibility:"hidden",pointerEvents:"none"}}),ne.city?(0,ue.jsx)(Z.Suspense,{fallback:null,children:(0,ue.jsx)(hs,{frame:ne,...Te,pan:ne.city?ne.city.pan:R,brand:w,pinned:U,close:G*Y>1.2,swallowed:rt,...u.overview?{chosen:fn(p,{overview:u.overview,focusId:u.focusId,beside:H},P=>c.graph.getNode(P)?.kind).records}:{},onFocus:P=>{let se=Ee(P);se!==null&&h(fe=>gt(fe,Oe(se)))}})}):null,nt?(0,ue.jsx)("div",{"data-graview-stage":"dom","data-graview-world":"",style:{...at,overflow:"hidden"},children:st}):(0,ue.jsxs)("div",{style:at,children:[(0,ue.jsx)("div",{"data-graview-stage":"dom","data-graview-under-canvas":"",style:{position:"absolute",left:0,top:0,...Te,overflow:"hidden"},children:st.filter(P=>Ge.has(String(P.key)))}),(0,ue.jsx)("canvas",{ref:te,"data-graview-stage":"gpu",content:"drawable",layoutsubtree:"",...Te,style:{display:"block",position:"relative",...Te},children:st.filter(P=>!Ge.has(String(P.key)))})]}),u.overview&&!he?(0,ue.jsx)(Xr,{result:oe,schema:c.schema,...$.chrome?{chrome:$.chrome}:{},onGo:P=>{it(P.x,P.y),y()}}):null,u.overview?(0,ue.jsx)(fs,{zoom:Y,zoomBy:P=>E.current(P),above:T,setAbove:Q}):null,(0,ue.jsx)(Ci,{frame:ne,focusId:u.focusId,beside:H,holding:J,...Te,scheme:s,overview:!!u.overview,selection:p,emphasis:x,stageRef:g,store:c,graphNodes:A,...(P=>P?{provisional:P}:{})(Pi(c)),onPickEdge:(P,se)=>{rt.current||(b([P]),f(se?{...se,on:P}:null))},liveOf:P=>{let se=ie(P.from),fe=ie(P.to);return se?.wrote&&fe?.wrote?se.at>fe.at?se:fe:void 0}}),(0,ue.jsx)(Kr,{width:oe.width,whereIs:mt}),(0,ue.jsx)(_r,{marks:ht.marks,questions:[...O.values()].filter(P=>P.mode==="asking"&&P.at!==null&&P.say).map(P=>({id:P.at,who:P.who,asks:P.say})),whereIs:mt,stageRef:g,...Te}),(0,ue.jsx)(Ni,{nodes:ne.nodes,moving:ne.t<1,holding:J,scheme:s,width:oe.width,stageRef:g}),i]})}var Ze=ce(Be(),1);function ys(){return Ui(),null}var Ki=()=>window.location.pathname.endsWith(or),zi=()=>(Ki()?ar:no)(window.location.hash),gs=e=>(Ki()?sr:to)(e);function Ui(){let{view:e,setView:t,views:n,principal:r}=xe(),o=JSON.stringify(r),a=(0,Ze.useCallback)(d=>{let u=d.within?.view;if(u===void 0||d.focusId)return d;let h=n.places().find(p=>p.as===u);return h?{...d,focusId:Oe(h.kind)}:d},[n]),i=(0,Ze.useRef)(!1);(0,Ze.useEffect)(()=>{if(typeof window>"u")return;let d=a(zi());!En(d,eo)&&!En(d,e)&&(i.current=!0,t(d))},[]),(0,Ze.useEffect)(()=>{if(typeof window>"u")return;let d=()=>t(a(zi()));return window.addEventListener("popstate",d),window.addEventListener("hashchange",d),()=>{window.removeEventListener("popstate",d),window.removeEventListener("hashchange",d)}},[t,a]);let l=(0,Ze.useRef)(!1),c=(0,Ze.useRef)(null),s=(0,Ze.useRef)(o);(0,Ze.useEffect)(()=>{if(typeof window>"u")return;if(i.current){i.current=!1;return}let d=s.current!==o;s.current=o;let u=gs(e),h=u||`${window.location.pathname}${window.location.search}`;if((window.location.hash||(window.location.href.includes("#")?"#":""))===u){l.current=!0,c.current=e;return}if(!l.current){l.current=!0,c.current=e,window.history.replaceState({graview:Tt.at},"",h);return}if(d||Xi(c.current,e)){window.history.replaceState({graview:Tt.at},"",h),c.current=e;return}c.current=e,window.history.pushState({graview:++Tt.at},"",h),Tt.depth=Tt.at,Tt.tell()},[e,o])}function Xi(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(",")&&ps(e.within,t.within):!1}function ps(e,t){let n=r=>Object.entries(r??{}).sort(([o],[a])=>o.localeCompare(a)).map(([o,a])=>`${o}=${a}`).join("&");return n(_i(e))===n(_i(t))}function _i(e){if(!e||!("q"in e))return e;let{q:t,...n}=e;return n}var Zo=ce(Be(),1);function xs(e={}){let{store:t,selection:n,principal:r,providers:o}=xe(),{about:a,...i}=e,l=a??n,c=It();return(0,Zo.useMemo)(()=>{let s=[...new Set(l.flatMap(u=>dn(u)))],d=l.map(u=>Ot(u)).filter(u=>u!==null);return Er(t,l,{principal:r,kindSelection:s,edgeSelection:d,...o?{providers:o}:{},...i})},[t,l,e,c,r,o])}function bs(){let{store:e,principal:t}=xe();return(0,Zo.useMemo)(()=>({preview:(n,r)=>Lr(e,n,r??{}),apply:(n,r)=>Or(e,n,r??{},{author:t})}),[e,t])}export{Zi as a,ca as b,ua as c,ha as d,fa as e,ma as f,ya as g,ms as h,ys as i,xs as j,bs as k};
@@ -1 +0,0 @@
1
- import{B as p,I as y,M as f,Y as g,ba as b,ia as w,jb as F,pb as h,sb as x}from"./chunk.6V2RG5JG.js";function $(e,n,t){let i=[...n?.creates??[],...n?.subject&&n.subject.kinds!=="*"?n.subject.kinds:[]];for(let r of i){let o=e.tryDefinition(r),a=o?.fields?.shape??{};if(!o||!(t in a))continue;let d=o.display?.format?.[t];return{label:o.display?.labels?.[t]??b(o,t),option:u=>d?d(u):g(u)}}return{label:b(void 0,t),option:r=>g(r)}}function S(e,n,t){if(t instanceof F){let i=n.find(o=>o.name===t.mutation);return`Not yet: ${t.issues.map(o=>{let a=o.path.length>0?$(e,i,String(o.path[0])).label:void 0;return a?`${a} \u2014 ${o.message.replace(/^./,d=>d.toLowerCase())}`:o.message}).join("; ")}.`}return t instanceof Error?t.message:String(t)}var _=e=>/^[A-Z]{3}$/.test(e??"");function k(e){let{format:n,unit:t,currency:i,locale:r}=e,o=_(t),a=n==="money"||!n&&o,d=a?o?t:i:void 0;return{...a?{format:"money"}:n?{format:n}:{},...t&&!(a&&o)?{unit:t}:{},...d?{currency:d}:{},...r?{locale:r}:{}}}function P(e){switch(e.format){case"money":return e.currency?`An amount of money in ${e.currency}: a plain number, 1250.5 for 1,250.50 ${e.currency}.`:"An amount of money, in no named currency: a plain number.";case"percent":return"A fraction said as a percent: 0.15 is 15%.";default:return e.unit?`A number of ${e.unit}.`:"A number."}}function M(e){let n=p(e)?.innerType;return n===void 0?e:M(n)}var R={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},D=e=>(e?._zod?.def?.checks??[]).map(n=>n._zod?.def).filter(n=>n!==void 0);function A(e){let n=M(e),t=p(n),i=t?.type,r=D(n);if(i==="enum")return{type:"choice",options:Object.keys(t?.entries??{})};let o=w(n);if(o)return o==="image"?{type:"file",image:!0}:{type:"file"};if(i==="boolean")return{type:"boolean"};if(i==="array"){let a=A(t?.element);return a.type==="unknown"?{type:"unknown"}:{type:"several",of:a}}if(i==="number"){let a,d,c;for(let u of r){u.check==="multiple_of"&&typeof u.value=="number"?c=u.value:u.check==="number_format"&&(u.format==="safeint"||u.format==="int32"||u.format==="uint32")&&(c??=1);let s=u.check==="number_format"&&u.format?R[u.format]:void 0,m=s?s[0]:u.check==="greater_than"&&u.inclusive&&typeof u.value=="number"?u.value:void 0,l=s?s[1]:u.check==="less_than"&&u.inclusive&&typeof u.value=="number"?u.value:void 0;m!==void 0&&(a=a===void 0?m:Math.max(a,m)),l!==void 0&&(d=d===void 0?l:Math.min(d,l))}return{type:"number",...a===void 0?{}:{min:a},...d===void 0?{}:{max:d},...c===void 0?{}:{step:c},...x(n)==="duration"?{duration:!0}:{},...h(e)?{amount:k(h(e))}:{}}}if(i==="string"){let d=[t?.pattern,...r.map(s=>s.pattern)].filter(s=>s instanceof RegExp).map(s=>s.source);if(d.some(s=>s.includes("\\d{4}")))return d.some(s=>s.includes("\\d{2}:\\d{2}"))?{type:"date",time:!0}:{type:"date"};let c=r.some(s=>s.check==="max_length"&&typeof s.maximum=="number"&&s.maximum>500),u=x(n);return c?{type:"text",long:!0}:u==="phone"||u==="place"?{type:"text",holds:u}:{type:"text"}}return{type:"unknown"}}function E(e,n){let t=e?.shape;return!t||!(n in t)?{type:"unknown"}:A(t[n])}function j(e){if(e===void 0||e==="web"||e.startsWith("ai:")||e.startsWith("app:"))return;if(e==="api")return"via the API";if(e==="cli")return"via the command line";let[n,...t]=e.split(":"),i=t.join(":");return(n==="mcp"||n==="view")&&i?`via ${i}`:n==="mcp"?"via an agent's tools":`via ${e}`}var N=e=>{if(!e.currency)return{before:!0};try{let n=y(e.locale),t=new Intl.NumberFormat(n,{style:"currency",currency:e.currency}).formatToParts(1),i=t.findIndex(a=>a.type==="currency"),r=t.findIndex(a=>a.type==="integer"),o;try{o=new Intl.DisplayNames([n],{type:"currency"}).of(e.currency)}catch{}return{...i>=0?{symbol:t[i].value}:{},before:i<r,...o?{name:o}:{}}}catch{return{symbol:e.currency,before:!0}}};function v(e){let n=e.locale;if(e.format==="money"){let{symbol:t,before:i,name:r}=N(e),o=f(1250,n,{minimumFractionDigits:2,maximumFractionDigits:2});return{...t?i?{prefix:t}:{suffix:t}:{},placeholder:o,hint:r?`in ${r}`:e.currency?`in ${e.currency}`:"an amount of money"}}return e.format==="percent"?{suffix:"%",placeholder:f(15,n),hint:"as a percent"}:{...e.unit?{suffix:e.unit}:{},placeholder:"",hint:e.unit?`in ${e.unit}`:"a number"}}function I(e,n){return e===void 0||!Number.isFinite(e)?"":n.format==="money"?f(e,n.locale,Number.isInteger(e)?{maximumFractionDigits:0}:{minimumFractionDigits:2,maximumFractionDigits:2}):n.format==="percent"?f(e*100,n.locale,{maximumFractionDigits:4}):f(e,n.locale,{maximumFractionDigits:6})}function W(e){try{let n=new Intl.NumberFormat(y(e)).formatToParts(12345.6);return{group:n.find(t=>t.type==="group")?.value??",",decimal:n.find(t=>t.type==="decimal")?.value??"."}}catch{return{group:",",decimal:"."}}}function O(e,n){let{group:t,decimal:i}=W(n),r=e.replace(/[\s  ']/g,"").replace(/[−–]/g,"-");if(i!=="."&&!r.includes(i)&&/^-?\d+\.\d{1,2}$/.test(r))return Number(r);if(t&&(r=r.split(t).join("")),i!=="."&&(r=r.replace(i,".")),!/^-?(\d+\.?\d*|\.\d+)$/.test(r))return;let o=Number(r);return Number.isFinite(o)?o:void 0}function B(e,n){let t=e.trim();if(t==="")return;let i=n?.format==="money"&&n.currency?N(n).symbol:void 0,r=t;i&&(r=r.split(i).join("")),n?.currency&&(r=r.replace(new RegExp(n.currency,"gi"),"")),r=r.replace(/^[$€£¥₹]|[$€£¥₹]$/g,""),/%\s*$/.test(r)&&(r=r.replace(/%\s*$/,"")),n?.unit&&n.format!=="money"&&(r=r.replace(new RegExp(`\\s*${n.unit.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*$`),""));let a=O(r,n?.locale);if(a!==void 0)return n?.format==="percent"?a/100:a}export{k as a,P as b,M as c,A as d,E as e,$ as f,S as g,j as h,v as i,I as j,B as k};
@@ -1 +0,0 @@
1
- import{B as G,r as O,t as v,u as C,v as S}from"./chunk.L4DECHXR.js";import{A as E,G as I,Z as m,d as V,k as g,m as p,n as y,o as u,p as D,w as B}from"./chunk.GFF2FB2J.js";import{$ as M,Ac as T,wc as P,xc as k,zc as R}from"./chunk.6V2RG5JG.js";import{b as A}from"./chunk.AJZBJBMO.js";var W=A(I(),1);function j(e,t){try{t.length===0?localStorage.removeItem(v(e)):localStorage.setItem(v(e),JSON.stringify(t))}catch{}}function F(e,t){j(e,[...S(e).filter(n=>n.title!==t.title),t])}function H(e,t){j(e,S(e).filter(n=>n.title!==t))}function J(e,t){for(let n of e.places().filter(o=>o.title===t))e.forget?.(n.kind,n.as)}var U=e=>e===!0?{written:!0}:typeof e=="object"&&e!==null?{written:e.kept===!0,...e.said?{said:e.said}:{}}:{written:!1},N=e=>({title:e.title,lens:e.lens,on:e.on,...e.bindings?{bindings:e.bindings}:{},...e.options?{options:e.options}:{}});function Z(e,t){let n=o=>t.some(r=>r.title===o||r.as===P(o));if(!n(e))return e;for(let o=2;;o++)if(!n(`${e} ${o}`))return`${e} ${o}`}function ie(e){let{store:t,views:n,brand:o,seatTalk:r,onKeepLens:d}=m(),h=(0,W.useContext)(O),L=C(o,t.schema),b=async f=>{let{edit:i}=f;if(f.written&&d)try{await d({op:"remove-lens",title:i.title,on:i.on})}catch{}H(L,i.title),J(n,i.title),h?.dismiss(`kept:${i.title}`),r.setTurns(l=>[...l.map(s=>s.kept&&s.kept.edit.title===i.title&&!s.kept.taken?{...s,kept:{...s.kept,taken:!0}}:s),{role:"seat",text:`Took \u201C${i.title}\u201D back out of the places.`}]);let a=M(t.schema,i.on);e({to:"kind",kind:i.on,title:a,address:k(t.schema,i.on),said:`Went to ${a}.`})};return{keep:async f=>{let i=Z(f.edit.title,n.places()),a={...f.edit,title:i},l=!1,s;if(d)try{({written:l,said:s}=U(await d(a)))}catch{l=!1}l||F(L,N(a)),G(n,t.schema,[N(a)]);let K=n.places(),c=K.find(w=>w.title===i),x=s??(l?`Kept \u201C${i}\u201D as a lens: it is in the places now.`:d?`Kept \u201C${i}\u201D as your own lens. Ask the owner to keep it for everyone.`:`Kept \u201C${i}\u201D as your own lens.`),$={edit:a,written:l};r.setDraft(null),r.setTurns(w=>[...w,{role:"seat",text:x,kept:$}]),r.get().open||h?.notify({kind:"toast",id:`kept:${i}`,sentence:x,timeout:1e4,action:{label:"Take back",onSelect:()=>void b($)}}),c&&e({to:"picture",kind:c.kind,as:c.as,title:i,address:R(c.as,T(c,K)?k(t.schema,c.kind).slice(1):void 0),said:`Went to ${i}.`})},takeBack:b}}var q=A(I(),1);function _(e,t){switch(t.to){case"place":return{view:V("#")};case"picture":return{view:u(E(p(e,"filter",null),t.kind,t.as),[])};case"kind":{let n=D(y({...g(e,B(t.kind)),relation:null},!1),!0);return{view:u(p(p(n,"view",null),"filter",t.filter??null),[])}}case"record":return{view:u(g(y(p(p(e,"view",null),"filter",null),!1),t.id),[t.id])};case"problems":return{pane:"problems"}}}function z(e){let t=typeof document>"u"?null:document.querySelector('[data-testid="standing"]');t&&t.getAttribute("aria-expanded")==="true"!==e&&t.click()}function ae(){let{setView:e,seatTalk:t}=m();return(0,q.useCallback)(n=>{t.get().draft&&t.setDraft(null),z(n.to==="problems"),n.to!=="problems"&&e(o=>{let r=_(o,n);return"view"in r?r.view:o})},[e,t])}export{ie as a,z as b,ae as c};
@@ -1 +0,0 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk.XSTXV6FP.js";import"./chunk.G4JJXA63.js";import"./chunk.C5CYZNSJ.js";import"./chunk.JPHNKWTY.js";import"./chunk.26CZTUY4.js";import"./chunk.OAF7TUMI.js";import"./chunk.Q5WEOX3Q.js";import"./chunk.VOAZBHCG.js";import"./chunk.QTMWHE5O.js";import"./chunk.6T2Q6NLO.js";import"./chunk.WVUJXDXZ.js";import"./chunk.OZNW5W4Z.js";import"./chunk.NDADLJE6.js";import"./chunk.AK3IHFCF.js";import"./chunk.HHPGWJDO.js";import"./chunk.42YX6NOY.js";import"./chunk.3VL5WECB.js";import"./chunk.JH6MU6TX.js";import"./chunk.WAFDCOOG.js";import"./chunk.6V2RG5JG.js";import"./chunk.AJZBJBMO.js";export{i as draftAnswer,h as draftFromLens,b as draftSight,l as draftView,a as isDraftFailure,c as judgeLens,d as lensEditOf,f as lensFromSpec,j as recipeDraft,g as recipeOfLens,m as refineDraft,o as runDraftTool,e as takeBackEditOf,k as templateDraft,n as withReaderLenses};
@@ -1 +0,0 @@
1
- import{d as f}from"./chunk.NO52VON3.js";import{a as x,b as S,c as D}from"./chunk.4ALKPNXM.js";import"./chunk.OQ4KFN6W.js";import"./chunk.YNQDVGZM.js";import"./chunk.3R4W2P5X.js";import"./chunk.C5CYZNSJ.js";import"./chunk.JPHNKWTY.js";import"./chunk.XRJBLH4N.js";import{b as h}from"./chunk.34ZMMURV.js";import"./chunk.FGVKJWNS.js";import"./chunk.3SKKIHU3.js";import"./chunk.HJCQ6I3S.js";import"./chunk.O2LK2AO7.js";import"./chunk.26CZTUY4.js";import"./chunk.3JNMSOFG.js";import"./chunk.PKK6FRZR.js";import"./chunk.OAF7TUMI.js";import"./chunk.YV2LJFGS.js";import"./chunk.QNGWEV47.js";import"./chunk.ERXSYPYL.js";import"./chunk.J2ITFGN3.js";import"./chunk.6XMEU2Q2.js";import"./chunk.QIAKO27D.js";import"./chunk.UT6642FC.js";import"./chunk.QTA4ROAK.js";import"./chunk.2CIBWZJG.js";import"./chunk.RRVIXV7W.js";import"./chunk.7BWT5L2L.js";import"./chunk.VSZQXB4Q.js";import"./chunk.RI3PYG5T.js";import"./chunk.UWGWXFWZ.js";import"./chunk.SE5SKFQH.js";import"./chunk.W3S6UXNA.js";import"./chunk.4SJUTBDV.js";import"./chunk.TI4OSTQV.js";import"./chunk.6T2Q6NLO.js";import"./chunk.WVUJXDXZ.js";import"./chunk.OZNW5W4Z.js";import"./chunk.NDADLJE6.js";import"./chunk.AK3IHFCF.js";import"./chunk.HHPGWJDO.js";import"./chunk.42YX6NOY.js";import"./chunk.EYZ7MHBZ.js";import{s as k}from"./chunk.KQT7WAQE.js";import"./chunk.PAVR5TK5.js";import"./chunk.OQDETV4X.js";import"./chunk.3VL5WECB.js";import"./chunk.JH6MU6TX.js";import"./chunk.WAFDCOOG.js";import"./chunk.L4DECHXR.js";import{$ as b,G as V,J as v,R as y,Z as w}from"./chunk.GFF2FB2J.js";import{V as g,dc as u}from"./chunk.6V2RG5JG.js";import{b as p}from"./chunk.AJZBJBMO.js";var i=p(V(),1);var e=p(y(),1);function q({page:a=!1,go:C,onPick:m,onDiscard:G}){let{store:o,seatTalk:s}=w(),d=v(s),K=D(),c=C??K,{keep:N}=x(c),[T,l]=(0,i.useState)(!1);b();let t=d.draft;if((0,i.useEffect)(()=>l(!1),[t]),(0,i.useEffect)(()=>{a||S(!1)},[a]),!t)return null;let L=h(t.drawn),B=o.schema.tryDefinition(t.kind),I=o.graph.nodesOfKind(t.kind).filter(n=>g(B,n)),P=()=>{s.setDraft(null),G?.()};return(0,e.jsxs)("section",{"data-testid":"draft-frame","aria-label":`Draft: ${t.title}`,style:a?{display:"grid",gap:12,minWidth:0}:{position:"absolute",inset:0,zIndex:u("rail"),display:"grid",gridTemplateRows:"auto auto minmax(0, 1fr)",background:"var(--graview-ground, var(--graview-panel))",minHeight:0},children:[(0,e.jsxs)("p",{"data-testid":"draft-line",style:{...z,...a?{}:{padding:"10px 16px"}},children:[a?(0,e.jsx)("span",{children:"Draft"}):(0,e.jsxs)("span",{children:["Draft \u2014 ",(0,e.jsx)("span",{"data-testid":"draft-title",style:{color:"var(--graview-ink)",fontWeight:600},children:t.title})]}),(0,e.jsx)("span",{"aria-hidden":"true",children:"\xB7"}),(0,e.jsx)("button",{type:"button","data-testid":"draft-keep",disabled:T,title:`Keep \u201C${t.title}\u201D as a lens: a place of its own`,onClick:()=>{l(!0),N(t).finally(()=>l(!1))},style:f,children:"Keep as a lens"}),(0,e.jsx)("span",{"aria-hidden":"true",children:"\xB7"}),(0,e.jsx)("button",{type:"button","data-testid":"draft-discard",onClick:P,style:f,children:"Discard"})]}),d.draftNote?(0,e.jsx)("p",{"data-testid":"draft-note",role:"status",style:{margin:0,padding:a?0:"0 16px 8px",fontSize:"0.8125rem",color:"var(--graview-warn)"},children:d.draftNote}):(0,e.jsx)("span",{}),(0,e.jsx)("div",{"data-testid":"draft-lens","data-graview-draft":t.lens.name,style:a?{height:"min(72vh, 760px)",display:"grid",gridTemplateRows:"minmax(0, 1fr)",overflow:"auto",scrollbarGutter:"stable",border:"1px solid var(--graview-edge)",borderRadius:12,background:"var(--graview-panel)"}:{minHeight:0,overflow:"auto",scrollbarGutter:"stable",display:"grid",gridTemplateRows:"minmax(0, 1fr)"},onClick:n=>{let r=n.target?.closest("[data-graview-pick]")?.getAttribute("data-graview-pick");if(!r||!o.graph.getNode(r))return;n.preventDefault();let R=o.graph.getNode(r);m?(s.setDraft(null),m(r)):c({to:"record",id:r,kind:R.kind,label:r,address:"",said:""})},children:(0,e.jsx)(k,{kind:t.kind,view:t.title,children:(0,e.jsx)(L,{nodes:I,label:t.title,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1})})})]})}var z={margin:0,display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"4px 8px",fontSize:"0.875rem",color:"var(--graview-ink-muted)",borderBottom:"1px solid var(--graview-edge)",paddingBottom:8};export{q as DraftFrame};