graview 0.1.33 → 0.1.34

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 (141) hide show
  1. package/dist/preview/{chunk.7GKUVQVF.js → chunk.2UPGH6FT.js} +1 -1
  2. package/dist/preview/{chunk.I6FPNX43.js → chunk.2YCFK5HU.js} +1 -1
  3. package/dist/preview/{chunk.4HZ7QTXZ.js → chunk.2YGQVI6T.js} +1 -1
  4. package/dist/preview/{chunk.3K6YSVHC.js → chunk.34CYK2DF.js} +1 -1
  5. package/dist/preview/{chunk.3TVXGJTU.js → chunk.35KI7XYV.js} +1 -1
  6. package/dist/preview/{chunk.COQKECUH.js → chunk.3C4RJIJU.js} +1 -1
  7. package/dist/preview/{chunk.TAQ764IQ.js → chunk.3H4NVUWV.js} +1 -1
  8. package/dist/preview/{chunk.K5ME5GCG.js → chunk.3MWBWSYF.js} +1 -1
  9. package/dist/preview/{chunk.MAF7C3VM.js → chunk.4K5QCJFH.js} +1 -1
  10. package/dist/preview/{chunk.ULRW47RP.js → chunk.52QAIGCD.js} +1 -1
  11. package/dist/preview/{chunk.D75KC3LL.js → chunk.577PGFUT.js} +1 -1
  12. package/dist/preview/{chunk.EBGAYL32.js → chunk.5EAQDBBE.js} +1 -1
  13. package/dist/preview/{chunk.4MERAWS2.js → chunk.6A62UVAE.js} +1 -1
  14. package/dist/preview/{chunk.7T7NZZTC.js → chunk.6FBQP336.js} +1 -1
  15. package/dist/preview/{chunk.EF3XNU4O.js → chunk.6K2HASOH.js} +1 -1
  16. package/dist/preview/chunk.6P7P2AW7.js +1 -0
  17. package/dist/preview/{chunk.LXBOVRFI.js → chunk.6VRJII5M.js} +1 -1
  18. package/dist/preview/{chunk.VG3O4LWB.js → chunk.6XO4PECH.js} +1 -1
  19. package/dist/preview/{chunk.GYICGZMG.js → chunk.7HPPJVIV.js} +2 -2
  20. package/dist/preview/{chunk.PIP6Z563.js → chunk.7JNDZWD6.js} +1 -1
  21. package/dist/preview/{chunk.6UGEYZAC.js → chunk.7MTX33WD.js} +1 -1
  22. package/dist/preview/{chunk.ASCLIM2P.js → chunk.7VUPKOKC.js} +1 -1
  23. package/dist/preview/{chunk.AR3DCDHU.js → chunk.7WHWD5YJ.js} +1 -1
  24. package/dist/preview/{chunk.3NDH3EDN.js → chunk.7X2ZO5BD.js} +1 -1
  25. package/dist/preview/{chunk.XNJEFUF7.js → chunk.AHCI7ZDO.js} +1 -1
  26. package/dist/preview/{chunk.4HNG4UXT.js → chunk.APNN6BKF.js} +1 -1
  27. package/dist/preview/{chunk.XBJYQNVE.js → chunk.B2WRXGFI.js} +1 -1
  28. package/dist/preview/{chunk.HLTRQU4Y.js → chunk.B6VI576I.js} +1 -1
  29. package/dist/preview/{chunk.NTF7FVB2.js → chunk.BU2DSZ2L.js} +1 -1
  30. package/dist/preview/{chunk.T5VG5A6V.js → chunk.CNMITOKP.js} +1 -1
  31. package/dist/preview/chunk.CPW465TM.js +1 -0
  32. package/dist/preview/{chunk.47STJVRV.js → chunk.CZRX2FDI.js} +1 -1
  33. package/dist/preview/{chunk.GV2CQVKV.js → chunk.DMNXYMLC.js} +1 -1
  34. package/dist/preview/{chunk.IWQCOGHW.js → chunk.DNDHDDM6.js} +2 -2
  35. package/dist/preview/{chunk.MWGGV7DE.js → chunk.DUUARGPE.js} +1 -1
  36. package/dist/preview/chunk.E7EQ2VTE.js +1 -0
  37. package/dist/preview/{chunk.UHUGOTUU.js → chunk.ETWVQ3A2.js} +1 -1
  38. package/dist/preview/{chunk.BNV77BQZ.js → chunk.F6WYSDSI.js} +3 -3
  39. package/dist/preview/{chunk.FWTIUYXH.js → chunk.FBY5IUGU.js} +1 -1
  40. package/dist/preview/{chunk.UATVTXZY.js → chunk.FCRFQ7ZW.js} +1 -1
  41. package/dist/preview/chunk.FRS3S7DN.js +1 -0
  42. package/dist/preview/{chunk.UGFJKSHU.js → chunk.FSAHO3LV.js} +1 -1
  43. package/dist/preview/{chunk.JQU5GEU3.js → chunk.FUQVNXLB.js} +1 -1
  44. package/dist/preview/{chunk.JDUJDAGA.js → chunk.G64AREGA.js} +1 -1
  45. package/dist/preview/{chunk.CN3UEF5N.js → chunk.GMOTRAKJ.js} +1 -1
  46. package/dist/preview/chunk.GNSAKLP2.js +1 -0
  47. package/dist/preview/{chunk.RCKTBOY2.js → chunk.HCDKSDIS.js} +1 -1
  48. package/dist/preview/chunk.HH6P4BLT.js +1 -0
  49. package/dist/preview/{chunk.AOSMJKLH.js → chunk.HJ56Q6WB.js} +1 -1
  50. package/dist/preview/chunk.HP3ZEDCD.js +117 -0
  51. package/dist/preview/{chunk.G5NZVPJU.js → chunk.HPD5ZDZH.js} +1 -1
  52. package/dist/preview/chunk.HPEGQN6E.js +1 -0
  53. package/dist/preview/chunk.HUKAVTMX.js +1 -0
  54. package/dist/preview/chunk.HWITWOP3.js +3 -0
  55. package/dist/preview/{chunk.3TY5NFLY.js → chunk.IHFNLKXV.js} +1 -1
  56. package/dist/preview/{chunk.2NIOHEMX.js → chunk.JQDYGI6G.js} +1 -1
  57. package/dist/preview/chunk.JZBBGY4B.js +1 -0
  58. package/dist/preview/chunk.KA3KI4UA.js +1 -0
  59. package/dist/preview/{chunk.HAIG6NVX.js → chunk.LAF6GTBN.js} +1 -1
  60. package/dist/preview/{chunk.UNL2HIF2.js → chunk.LCFDM7XY.js} +1 -1
  61. package/dist/preview/{chunk.E2YEOMPH.js → chunk.LIIC25G6.js} +1 -1
  62. package/dist/preview/chunk.M5HADQPP.js +1 -0
  63. package/dist/preview/chunk.MWJUZG3C.js +6 -0
  64. package/dist/preview/chunk.OMMKD2NU.js +2 -0
  65. package/dist/preview/{chunk.JOOQUWLT.js → chunk.PNVR3CXR.js} +2 -2
  66. package/dist/preview/{chunk.PBSMLINK.js → chunk.PPUAPAWR.js} +1 -1
  67. package/dist/preview/{chunk.SYAEBGDC.js → chunk.PW7YH6JV.js} +1 -1
  68. package/dist/preview/{chunk.OC6IWRQ3.js → chunk.Q7TP4RFE.js} +1 -1
  69. package/dist/preview/{chunk.CIPS2OGR.js → chunk.QPAUQJON.js} +1 -1
  70. package/dist/preview/{chunk.UZGRRDHD.js → chunk.QU356VB2.js} +1 -1
  71. package/dist/preview/chunk.QVKKXMNK.js +1 -0
  72. package/dist/preview/{chunk.3AGY4QVS.js → chunk.QVUL2FSI.js} +1 -1
  73. package/dist/preview/chunk.RH45AW2W.js +1 -0
  74. package/dist/preview/{chunk.6YCBYL2Y.js → chunk.RIW7SQH4.js} +1 -1
  75. package/dist/preview/{chunk.H7EPE74C.js → chunk.RN3EZVV4.js} +1 -1
  76. package/dist/preview/{chunk.3HXN4BOY.js → chunk.RYEAMM73.js} +1 -1
  77. package/dist/preview/{chunk.YIR7PPF3.js → chunk.SIH6RCAI.js} +1 -1
  78. package/dist/preview/{chunk.NRAYZY3X.js → chunk.T2L4NPSB.js} +1 -1
  79. package/dist/preview/{chunk.TMVCTBAD.js → chunk.T3M4FALL.js} +5 -5
  80. package/dist/preview/{chunk.CX3KL2C5.js → chunk.TCSZZAYB.js} +1 -1
  81. package/dist/preview/chunk.TPX6AVJL.js +1 -0
  82. package/dist/preview/{chunk.5UL7YDUD.js → chunk.U5ACEYAN.js} +1 -1
  83. package/dist/preview/{chunk.5T5XGILP.js → chunk.UA5UYINM.js} +1 -1
  84. package/dist/preview/{chunk.GO4XBWJO.js → chunk.UCIQIPBQ.js} +1 -1
  85. package/dist/preview/{chunk.EKPRNDUV.js → chunk.UHQD3NTK.js} +1 -1
  86. package/dist/preview/{chunk.RIJUCHP4.js → chunk.VKH3ZPPQ.js} +1 -1
  87. package/dist/preview/{chunk.UBFNZMUX.js → chunk.VMGWYCXU.js} +1 -1
  88. package/dist/preview/chunk.VOFUIWAX.js +27 -0
  89. package/dist/preview/{chunk.DYSPCGXX.js → chunk.VSOB2QEK.js} +1 -1
  90. package/dist/preview/{chunk.R6K6GF5R.js → chunk.VZHV25JE.js} +1 -1
  91. package/dist/preview/chunk.WAB6ZS2V.js +1 -0
  92. package/dist/preview/chunk.WLBXBNNH.js +1 -0
  93. package/dist/preview/chunk.WPCGHGDA.js +1 -0
  94. package/dist/preview/{chunk.QYZNAUIR.js → chunk.WYEYYCBH.js} +1 -1
  95. package/dist/preview/{chunk.MNP4JI33.js → chunk.X7W27IRI.js} +4 -4
  96. package/dist/preview/{chunk.J25KOSNW.js → chunk.XK4FVT2X.js} +1 -1
  97. package/dist/preview/{chunk.CWHRDBOF.js → chunk.XXMYKBLT.js} +1 -1
  98. package/dist/preview/{chunk.CDP2XL66.js → chunk.XZYJRNRY.js} +1 -1
  99. package/dist/preview/chunk.YCIX53AR.js +1 -0
  100. package/dist/preview/chunk.YEYY273R.js +1 -0
  101. package/dist/preview/{chunk.EJPI3ST6.js → chunk.YJCT3DV2.js} +1 -1
  102. package/dist/preview/chunk.YT2CYCVT.js +1 -0
  103. package/dist/preview/{chunk.B2GLDIAS.js → chunk.Z7ZCR4LN.js} +1 -1
  104. package/dist/preview/{chunk.CAVBSL27.js → chunk.ZE4CTZQ3.js} +1 -1
  105. package/dist/preview/chunk.ZFWV4JAJ.js +1 -0
  106. package/dist/preview/{chunk.5H4VXLZF.js → chunk.ZJX6ZKKM.js} +1 -1
  107. package/dist/preview/chunk.ZPQKAJRI.js +1 -0
  108. package/dist/preview/{chunk.OKRNJXTV.js → chunk.ZSW74NVJ.js} +1 -1
  109. package/dist/preview/chunk.ZTD2CNC3.js +25 -0
  110. package/dist/preview/{chunk.QVVJRSRM.js → chunk.ZTFW7RKP.js} +1 -1
  111. package/dist/preview/index.html +42 -42
  112. package/dist/preview/page.js +2 -2
  113. package/package.json +6 -6
  114. package/dist/preview/chunk.26LLZN3C.js +0 -1
  115. package/dist/preview/chunk.2WPZXIRP.js +0 -2
  116. package/dist/preview/chunk.4HRAQNJO.js +0 -27
  117. package/dist/preview/chunk.52W7WYME.js +0 -1
  118. package/dist/preview/chunk.63GXY2ME.js +0 -1
  119. package/dist/preview/chunk.67TPUXAY.js +0 -1
  120. package/dist/preview/chunk.6QWV5MVH.js +0 -25
  121. package/dist/preview/chunk.AKFKM4SW.js +0 -3
  122. package/dist/preview/chunk.BHXGM3PV.js +0 -1
  123. package/dist/preview/chunk.BQ3JHEHV.js +0 -1
  124. package/dist/preview/chunk.DAZ2VSRD.js +0 -1
  125. package/dist/preview/chunk.ERIT3R6N.js +0 -1
  126. package/dist/preview/chunk.EYTBDMTW.js +0 -1
  127. package/dist/preview/chunk.GBRRGTIH.js +0 -1
  128. package/dist/preview/chunk.H7BST3XO.js +0 -1
  129. package/dist/preview/chunk.IDVAR5HM.js +0 -1
  130. package/dist/preview/chunk.KSES5U5B.js +0 -1
  131. package/dist/preview/chunk.LR3VDXPI.js +0 -1
  132. package/dist/preview/chunk.N6OX4NEQ.js +0 -1
  133. package/dist/preview/chunk.PHKSMUIA.js +0 -1
  134. package/dist/preview/chunk.SHTJZ6UX.js +0 -1
  135. package/dist/preview/chunk.UVR2Z5ZC.js +0 -1
  136. package/dist/preview/chunk.WAZ7OGBD.js +0 -1
  137. package/dist/preview/chunk.XANVHJQ4.js +0 -1
  138. package/dist/preview/chunk.XKABS745.js +0 -1
  139. package/dist/preview/chunk.XMC7YDWT.js +0 -1
  140. package/dist/preview/chunk.Y2SFUALD.js +0 -117
  141. package/dist/preview/chunk.Y6ZNFQK3.js +0 -6
@@ -1,3 +0,0 @@
1
- var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as Ee}from"./chunk.XANVHJQ4.js";import{a as Ne}from"./chunk.OKRNJXTV.js";import{a as je}from"./chunk.5UL7YDUD.js";import{a as X}from"./chunk.TI4OSTQV.js";import{a as Z}from"./chunk.PBSMLINK.js";import{e as pe}from"./chunk.JOOQUWLT.js";import{F as Ze,I as ve,O as Ie,Q as Re,Y as Me}from"./chunk.6QWV5MVH.js";import{$ as G,Bb as Pe,X as Y,Z as L,ca as Ce,ea as fe,ec as Te,fb as Oe,wb as $e,zb as V}from"./chunk.MNP4JI33.js";import{b as ce}from"./chunk.AJZBJBMO.js";var en=n=>/^(?:aggregate|kind):([^,]+)$/.exec(n)?.[1];function De(n,e){let t=n.about??[];if(n.field!==void 0&&n.on!==void 0&&e(n.on))return{on:"field",id:n.on,field:n.field};let i=t.filter(e);if(i.length>1)return{on:"selection",ids:i};if(n.on!==void 0&&e(n.on))return{on:"record",id:n.on};if(i.length===1)return{on:"record",id:i[0]};let r=[n.on,...t].map(o=>o===void 0?void 0:en(o)).find(o=>o!==void 0);return n.place!==void 0?{on:"lens",place:n.place,...r?{kind:r}:{}}:r!==void 0?{on:"list",kind:r}:{on:"place",place:"home"}}var me=n=>n.on==="record"||n.on==="field"?[n.id]:n.on==="selection"?n.ids:n.on==="act"&&n.id!==void 0?[n.id]:[],ee=(n,e)=>n.tryDefinition(e)?.fields?.shape??{},B=(n,e)=>n.tryDefinition(e)?.edges??{},ne=(n,e)=>new Set(n.tryDefinition(e)?.display?.hide??[]),E=(n,e)=>Y(n.tryDefinition(e.kind),e),ue=(n,e,t)=>Ce(n.tryDefinition(e),t)||L(t),ye=n=>typeof n=="boolean"?n?"yes":"no":String(n);function ke(n,e){let t=n.kindsKeptFrom(e);return new Set(n.schema.kinds.filter(i=>!t.has(i)))}function ge(n,e,t,i){if(!n.permits(e,t).ok)return!1;if(!i)return!0;try{return n.previewAll([e],{author:t}).ops.length>0}catch{return!1}}function te(n,e,t){let i=n,{principal:r}=t,o=t.each??8,u=X(i)?.store??i,d=u.seenBy(r),l=u.schema,m=ke(u,r),c=a=>{let g=d.graph.getNode(a);return g&&m.has(g.kind)?g:void 0},f=u.allMutations(),y=new Map(f.map(a=>[a.name,a])),b=[],x=new Set,k=a=>{x.has(a.id)||(x.add(a.id),b.push(a))},s=a=>a.slice(0,o),S=me(e).filter(a=>c(a)!==void 0);if(me(e).length>0&&S.length===0)return{target:e,candidates:[]};let h=S.length===1?c(S[0]):void 0,p=h?.kind??(e.on==="list"?e.kind:e.on==="lens"?e.kind??t.places?.find(a=>a.as===e.place)?.kind:void 0)??(e.on==="selection"?c(S[0])?.kind:void 0);if(p!==void 0&&!m.has(p))return{target:e,candidates:[]};let M=(a,g)=>`act:${a}${Object.keys(g).length>0?`:${Object.values(g).map(O=>String(O)).join(",")}`:""}`,P=(a,g,O,T,C)=>{a.destructive||Object.values(g).some(N=>typeof N=="string"&&u.graph.has(N)&&c(N)===void 0)||ge(u,{name:a.name,args:{...g}},r,T.length===0)&&k({type:"act",id:M(a.name,g),label:O,description:C??a.description??O,mutation:a.name,args:g,asks:T})};if(e.on!=="place"||t.acts)if(t.acts)for(let a of t.acts){let g=y.get(a.mutation);!g||a.destructive||e.on==="act"&&a.mutation!==e.act||P(g,a.args,a.label,(a.open??[]).filter(O=>!O.optional).map(O=>O.name),a.why)}else{let a=h?[h]:[];for(let g of f){if(e.on==="act"&&g.name!==e.act)continue;let O=g.input.shape??{},T=C=>Object.entries(O).filter(([N,w])=>N!==C&&w.safeParse?.(void 0).success===!1).map(([N])=>N);if(g.subject)for(let C of a)V(l,g).includes(C.kind)&&P(g,{[g.subject.arg]:C.id},`${g.title??L(g.name)}: ${E(l,C)}`,T(g.subject.arg));else p!==void 0&&(g.creates??[]).includes(p)&&P(g,{},g.title??L(g.name),T(void 0))}}let Ye=b.filter(a=>a.type==="act");b.splice(0,b.length,...s(Ye));let we=(a,g)=>{let O=Pe(l,f).get(a.kind),T=ee(l,a.kind),C=ne(l,a.kind),N=[];for(let[w,j]of Object.entries(T)){if(g!==void 0?w!==g:C.has(w)||a[w]!==void 0)continue;let H=Z(j),J=H?.type==="enum"?H.options??[]:H?.type==="boolean"?[!0,!1]:[];if(J.length===0)continue;let D=(O?.get(w)??[]).map(v=>y.get(v)).find(v=>v?.subject!==void 0&&ge(u,{name:v.name,args:{[v.subject.arg]:a.id,[w]:J.find(le=>le!==a[w])??J[0]}},r,!0));if(D?.subject)for(let v of J)a[w]!==v&&N.push({type:"fill",id:`fill:${a.id}:${w}:${ye(v)}`,label:`${ue(l,a.kind,w)}: ${ye(v)}`,description:`Set ${ue(l,a.kind,w).toLowerCase()} of ${E(l,a)} to ${ye(v)}`,record:a.id,field:w,value:v,call:{name:D.name,args:{[D.subject.arg]:a.id,[w]:v}}})}for(let[w,j]of Object.entries(B(l,a.kind))){if(g!==void 0&&w!==g)continue;let H=j.to==="*"?[...m]:j.to.filter($=>m.has($)),J=new Set(d.graph.out(a.id,w).map($=>$.id)),D=f.find($=>($.connects??[]).includes(w)&&$.subject!==void 0&&V(l,$).includes(a.kind));if(!D?.subject)continue;let v=$e(D.input).find($=>$.name!==D.subject.arg);if(!v)continue;let le=H.flatMap($=>v.kinds.length===0||v.kinds.includes($)?d.graph.nodesOfKind($):[]).filter($=>$.id!==a.id&&!J.has($.id)&&c($.id)!==void 0);for(let $ of s(le)){let xe={name:D.name,args:{[D.subject.arg]:a.id,[v.name]:$.id}};ge(u,xe,r,!0)&&N.push({type:"fill",id:`fill:${a.id}:${w}:${$.id}`,label:`${L(w)}: ${E(l,$)}`,description:`Link ${E(l,a)} to ${E(l,$)}${j.description?` as ${j.description}`:""}`,record:a.id,field:w,value:$.id,call:xe})}}return N};if(e.on==="field"&&h)for(let a of we(h,e.field))k(a);else if(h&&e.on==="record")for(let a of s(we(h)))k(a);let Ve=a=>{let g=G(l,a).toLowerCase(),O=[{type:"panel",id:`panel:${a}:list`,label:`A list of ${g}`,description:`Every ${fe(l.tryDefinition(a),a).toLowerCase()} this viewer may see, as a list`,panel:{lens:"blocks",kind:a}}],T=ne(l,a);for(let[C,N]of Object.entries(ee(l,a))){if(T.has(C))continue;let w=Z(N),j=ue(l,a,C).toLowerCase();if(w?.type==="enum")O.push({type:"panel",id:`panel:${a}:group:${C}`,label:`${U(g)} by ${j}`,description:`A list of ${g} grouped by ${j}`,panel:{lens:"blocks",kind:a,group:C}}),O.push({type:"panel",id:`panel:${a}:columns:${C}`,label:`Columns of ${g} by ${j}`,description:`${U(g)} in a column for each ${j}`,panel:{lens:"columns",kind:a,column:C}});else if(w?.type==="number"||w?.type==="integer"||w?.type==="date"||w?.type==="datetime"){let H=w.type==="date"||w.type==="datetime";O.push({type:"panel",id:`panel:${a}:sort:${C}`,label:`${U(g)} by ${j}`,description:`A list of ${g}, the ${H?"latest":"highest"} ${j} first`,panel:{lens:"blocks",kind:a,sort:{by:C,direction:"desc"}}}),H&&O.push({type:"panel",id:`panel:${a}:calendar:${C}`,label:`A calendar of ${g}`,description:`${U(g)} on a calendar by ${j}`,panel:{lens:"calendar",kind:a,start:C}})}}return O},Xe=e.on==="place"?[...m]:p!==void 0?[p]:[];for(let a of Xe)for(let g of s(Ve(a)))k(g);for(let a of s((t.places??[]).filter(g=>g.kind===void 0?e.on==="place":m.has(g.kind)&&(e.on==="place"||g.kind===p))))e.on==="lens"&&a.as===e.place||k({type:"place",id:`place:${a.as}`,label:a.title,description:`Go to ${a.title}`,place:a.as});if(h){let a=[];for(let[g,O]of Object.entries(B(l,h.kind)))for(let T of d.graph.out(h.id,g))c(T.id)&&a.push({type:"record",id:`record:${T.id}`,label:E(l,T),description:`${U(O.description??L(g))}: ${E(l,T)}`,record:T.id,relation:g});for(let g of l.kinds)for(let[O,T]of Object.entries(B(l,g)))if(!(T.to!=="*"&&!T.to.includes(h.kind)))for(let C of d.graph.in(h.id,O))C.kind===g&&c(C.id)&&a.push({type:"record",id:`record:${C.id}`,label:E(l,C),description:`${U(T.inverse??L(O))}: ${E(l,C)}`,record:C.id,relation:O});for(let g of s(a))k(g)}else if(e.on==="list"||e.on==="lens")for(let a of s(p!==void 0?d.graph.nodesOfKind(p):[]))c(a.id)&&k({type:"record",id:`record:${a.id}`,label:E(l,a),description:`Open ${E(l,a)}`,record:a.id});else if(e.on==="selection")for(let a of S){let g=c(a);k({type:"record",id:`record:${a}`,label:E(l,g),description:`Open ${E(l,g)}`,record:a})}return{target:e,candidates:b}}var U=n=>n&&`${n[0].toUpperCase()}${n.slice(1)}`,he=new WeakMap;function nn(n){let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619)>>>0;return e.toString(36)}function tn(n,e){let t=n,i=X(t)?.store??t,r=i.schema,o=ke(i,e),d=i.allMutations().filter(k=>!k.destructive&&i.permits({name:k.name,args:{}},e).ok!==!1),l=`${[...o].join(",")}|${d.map(k=>k.name).join(",")}`,m=he.get(r)?.get(l);if(m)return m;let c=[...o].map(k=>{let s=ne(r,k),S={};for(let[p,M]of Object.entries(ee(r,k))){if(s.has(p))continue;let P=Z(M);P&&(S[p]=P.type==="enum"?`enum:${(P.options??[]).join("|")}`:P.type)}let h={};for(let[p,M]of Object.entries(B(r,k)))h[p]=M.to==="*"?[...o]:M.to.filter(P=>o.has(P));return{kind:k,noun:fe(r.tryDefinition(k),k),plural:G(r,k),fields:S,relations:h}}),f=d.map(k=>({name:k.name,title:k.title??L(k.name),...k.subject?{on:V(r,k).filter(s=>o.has(s))}:{}})),y={kinds:c,acts:f},b={version:nn(JSON.stringify(y)),...y},x=he.get(r)??new Map;return x.set(l,b),he.set(r,x),b}var on=n=>n.name??n.id??n.kind;function He(n,e,t){let i=n,{principal:r}=t,o=X(i)?.store??i,u=o.seenBy(r),d=o.schema,l=ke(o,r),m=h=>{let p=u.graph.getNode(h);return p&&l.has(p.kind)?p:void 0},c=h=>({id:h.id,kind:h.kind,label:E(d,h)}),f=me(e),y=f.length===1?m(f[0]):void 0,b=y?Object.fromEntries(Object.keys(ee(d,y.kind)).filter(h=>!ne(d,y.kind).has(h)&&y[h]!==void 0&&h!=="label").map(h=>[h,y[h]])):{},x={on:e.on,...y?{record:{...c(y),fields:b}}:{},...e.on==="field"&&y?{field:e.field}:{},...e.on==="list"&&l.has(e.kind)?{kind:e.kind}:{},...e.on==="lens"?{place:e.place,...e.kind&&l.has(e.kind)?{kind:e.kind}:{}}:{},...e.on==="place"?{place:e.place}:{},...e.on==="act"?{act:e.act}:{}},k=[...new Set([...e.on==="selection"?e.ids:[],...t.selection??[]])].flatMap(h=>{let p=m(h);return p?[c(p)]:[]}),s=[];if(y){for(let h of Object.keys(B(d,y.kind)))for(let p of u.graph.out(y.id,h))m(p.id)&&s.push({...c(p),relation:h,direction:"out"});for(let h of d.kinds)for(let p of Object.keys(B(d,h)))for(let M of u.graph.in(y.id,p))M.kind===h&&m(M.id)&&s.push({...c(M),relation:p,direction:"in"})}let S=u.batches().filter(h=>!h.ops.every(Oe)).slice(-(t.recent??6)).reverse().map(h=>({intent:h.intent,at:h.at,by:on(h.author)}));return{...t.place!==void 0?{place:t.place}:{},target:x,selection:k,neighbors:s.slice(0,24),recent:S,schema:tn(o,r)}}function oe(n){if(!n.off)return n.fast??(n.decide?{model:n.name??"decide",decide:n.decide}:void 0)}function F(n){if(n.off)return;if(n.thinking)return n.thinking;let e=n.name??"model";if(n.complete){let t=n.complete;return{model:e,think:async({system:i,prompt:r})=>({text:await t(`${i}
2
-
3
- ${r}`)})}}if(n.turn){let t=n.turn;return{model:e,think:async({system:i,prompt:r})=>({text:await t({system:i,messages:[{role:"user",content:r}],tools:[],call:async()=>({error:"No tools here."})})})}}}var be=(n,e,t)=>n?e/1e6*(n.inputPerMillion??0)+t/1e6*(n.outputPerMillion??0):void 0,Ae=()=>`ai-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;function rn(n,e,t=[]){let i=r=>{let o=n.graph.getNode(r);return o?Y(n.schema.tryDefinition(o.kind),o):"a record"};switch(e.on){case"record":return i(e.id);case"field":return`${i(e.id)} \xB7 ${e.field}`;case"selection":return`${e.ids.length} records`;case"list":return n.schema.tryDefinition(e.kind)?G(n.schema,e.kind):e.kind;case"lens":case"place":return t.find(r=>r.as===e.place)?.title??(e.place==="home"?"Home":e.place);case"act":return e.act}}var Le=n=>n.type!=="act"||n.asks.length===0,Se=(n,e)=>({id:n.id,type:n.type,label:n.label,...e!==void 0?{confidence:e}:{}});function W(n,e){let t=e.interaction??Ae(),i=te(e.store,e.target,{principal:e.principal,...e.acts?{acts:e.acts}:{},...e.places?{places:e.places}:{}}),r=He(e.store,e.target,{principal:e.principal,...e.place?{place:e.place}:{},...e.selection?{selection:e.selection}:{}}),o=[];return{id:t,catalog:i,state:r,entry:{id:t,at:new Date().toISOString(),by:e.by??e.principal,target:e.target,targetLabel:rn(e.store,e.target,e.places)},usage:o,meter:u=>{o.push(u),n.meter?.({...u,interaction:t})}}}async function re(n,e,t,i){let r=await n.decide(e,t),{inputTokens:o,outputTokens:u}=r.usage,d=be(n.price,o,u);return i({tier:"fast",model:n.model,inputTokens:o,outputTokens:u,...d!==void 0?{costUsd:d}:{}}),r.answers}async function q(n,e,t,i,r){let o=await n.think({system:e,prompt:t,state:i.state,catalog:i.catalog}),u=o.usage?.inputTokens,d=o.usage?.outputTokens,l=o.usage?.costUsd??(u!==void 0?be(n.price,u,d??0):void 0);return r({tier:"thinking",model:n.model,...u!==void 0?{inputTokens:u}:{},...d!==void 0?{outputTokens:d}:{},...l!==void 0?{costUsd:l}:{}}),Ne(o.text)}function ae(n,e){let t=new Map(n.map((i,r)=>[`c${r+1}`,i]));return{question:{type:"choice",instructions:e,criteria:Object.fromEntries([...t].map(([i,r])=>[i,`${r.label} \u2014 ${r.description}`]))},of:i=>t.get(i)}}function se(n,e,t){if(n?.type!=="choice")return[];let i=n,r=Object.entries(i.probabilities).sort((o,u)=>u[1]-o[1]);return r.some(([o])=>o===i.choice)||r.unshift([i.choice,i.confidence]),r.flatMap(([o,u])=>{let d=e(o);return d?[{candidate:d,confidence:u}]:[]}).slice(0,t)}var I=(n,e,t,i)=>({interaction:{...n.entry,ask:{kind:t,said:e??""},offered:[],outcome:"failed",failed:i,usage:[...n.usage]},offers:[]}),z="AI isn't on here.";async function Fe(n,e,t=3){let i=W(n,e),r=e.said??"Suggest",o=i.catalog.candidates.filter(Le).slice(0,24);if(o.length===0)return{interaction:{...i.entry,ask:{kind:"suggest",said:r},offered:[],outcome:"offered",usage:[]},offers:[]};let u=oe(n),d=F(n),l=[];try{if(u){let{question:m,of:c}=ae(o,"Which of these would the person most likely want to do next, here?"),f=await re(u,{...i.state,candidates:o.map(y=>({id:y.id,type:y.type,says:y.description}))},{next:m},i.meter);l=se(f.next,c,t)}else if(d){let m=await q(d,'You suggest what a person most likely wants to do next in an app. Answer only JSON: {"pick": [candidate ids, best first]}. Pick only ids from the candidates.',JSON.stringify({state:i.state,candidates:o.map(f=>({id:f.id,says:f.description}))}),i,i.meter);l=(Array.isArray(m?.pick)?m.pick.filter(f=>typeof f=="string"):[]).flatMap(f=>o.filter(y=>y.id===f)).slice(0,t).map(f=>({candidate:f}))}else return I(i,r,"suggest",z)}catch(m){return I(i,r,"suggest",m instanceof Error?m.message:String(m))}return{interaction:{...i.entry,ask:{kind:"suggest",said:r},offered:l.map(({candidate:m,confidence:c})=>Se(m,c)),outcome:"offered",usage:[...i.usage]},offers:l.map(({candidate:m})=>m)}}async function Je(n,e){let t=W(n,e),i=e.said??"Fill in",r=t.catalog.candidates.filter(f=>f.type==="fill"),o=new Map;for(let f of r)o.set(f.field,[...o.get(f.field)??[],f]);if(o.size===0)return{interaction:{...t.entry,ask:{kind:"fill",said:i},offered:[],outcome:"offered",usage:[]},offers:[]};let u=oe(n),d=F(n),l=[];try{if(u){let f=[...o].map(([b,x],k)=>({key:`f${k+1}`,field:b,...ae(x,`Which value fits "${b}" best for this record?`)})),y=await re(u,t.state,Object.fromEntries(f.map(b=>[b.key,b.question])),t.meter);for(let b of f){let x=!an(e.store,e.target,b.field)&&sn(e.store,e.target,b.field)!=="one";l.push(...se(y[b.key],b.of,x?3:1).filter((k,s)=>s===0||k.confidence>=.4))}}else if(d){let f=await q(d,`You fill in a record's fields in an app. Answer only JSON: {"fills": [candidate ids]}, at most one per field, only ids from the candidates.`,JSON.stringify({state:t.state,candidates:r.map(x=>({id:x.id,says:x.description}))}),t,t.meter),y=Array.isArray(f?.fills)?f.fills.filter(x=>typeof x=="string"):[],b=new Set;for(let x of y){let k=r.find(s=>s.id===x);k?.type==="fill"&&!b.has(k.field)&&(b.add(k.field),l.push({candidate:k}))}}else return I(t,i,"fill",z)}catch(f){return I(t,i,"fill",f instanceof Error?f.message:String(f))}let m=t.usage.at(-1)?.model,c=_(e.store,{interaction:t.id,target:e.target,basis:i,...m?{model:m}:{},proposals:l.flatMap(({candidate:f,confidence:y})=>f.type==="fill"?[{id:f.id,label:f.label,said:f.description,call:f.call,record:f.record,field:f.field,...y!==void 0?{confidence:y}:{}}]:[])},e.principal);return{interaction:{...t.entry,ask:{kind:"fill",said:i},offered:c.proposals.map(f=>({id:f.id,type:"fill",label:f.label,...f.confidence!==void 0?{confidence:f.confidence}:{}})),outcome:"offered",usage:[...t.usage]},offers:[],...c.proposals.length>0?{ghost:c}:{}}}function an(n,e,t){let i=e.on==="record"||e.on==="field"?e.id:void 0,r=i?n.graph.getNode(i)?.kind:void 0,o=(r?n.schema.tryDefinition(r)?.fields?.shape:void 0)??{};return t in o}function sn(n,e,t){let i=e.on==="record"||e.on==="field"?e.id:void 0,r=i?n.graph.getNode(i)?.kind:void 0;return r?n.schema.tryDefinition(r)?.edges?.[t]?.cardinality:void 0}async function Ue(n,e){let t=W(n,e),i=e.said??"Add one",r=new Set(e.store.allMutations().filter(c=>(c.creates??[]).length>0).map(c=>c.name)),o=t.catalog.candidates.filter(c=>c.type==="act"&&c.asks.length>0&&r.has(c.mutation));if(o.length===0)return I(t,i,"record","Nothing here makes a record.");let u=F(n);if(!u)return I(t,i,"record",z);let d;try{let c=await q(u,'You propose one new record for an app by filling in an act. Answer only JSON: {"act": a candidate id, "args": {argument: value}}. Use only the candidates, and fill every argument the act asks for with a value that fits the state.',JSON.stringify({ask:i,state:t.state,candidates:o.map(b=>({id:b.id,says:b.description,asks:b.asks}))}),t,t.meter),f=o.find(b=>b.id===c?.act),y=typeof c?.args=="object"&&c.args!==null?c.args:{};f&&(d={act:f,args:Object.fromEntries(Object.entries(y).filter(([b])=>f.asks.includes(b)))})}catch(c){return I(t,i,"record",c instanceof Error?c.message:String(c))}if(!d)return I(t,i,"record","The model named no act this app has here.");let l=t.usage.at(-1)?.model,m=_(e.store,{interaction:t.id,target:e.target,basis:i,...l?{model:l}:{},proposals:[{id:d.act.id,label:d.act.label,said:d.act.description,call:{name:d.act.mutation,args:{...d.act.args,...d.args}}}]},e.principal);return m.proposals.length===0?I(t,i,"record","What the model proposed could not be made here."):{interaction:{...t.entry,ask:{kind:"record",said:i},offered:m.proposals.map(c=>({id:c.id,type:"act",label:c.said})),outcome:"offered",usage:[...t.usage]},offers:[d.act],ghost:m}}async function Be(n,e){let t=W(n,e),i=e.said??"Make a panel",r=t.catalog.candidates.filter(c=>c.type==="panel");if(r.length===0)return I(t,i,"panel","Nothing here can be drawn as a panel.");let o=oe(n),u=F(n),d;try{if(u){let c=await q(u,'You choose a panel to draw in an app. Answer only JSON: {"panel": a candidate id, "title": a short title}. Choose only among the candidates.',JSON.stringify({ask:i,state:t.state,candidates:r.map(y=>({id:y.id,says:y.description}))}),t,t.meter),f=r.find(y=>y.id===c?.panel);f&&(d={panel:f,...typeof c?.title=="string"&&c.title.trim()?{title:c.title.trim().slice(0,60)}:{}})}else if(o){let{question:c,of:f}=ae(r,`Which panel answers this best: ${i}`),y=se((await re(o,t.state,{panel:c},t.meter)).panel,f,1)[0];y?.candidate.type==="panel"&&(d={panel:y.candidate,confidence:y.confidence})}else return I(t,i,"panel",z)}catch(c){return I(t,i,"panel",c instanceof Error?c.message:String(c))}if(!d)return I(t,i,"panel","The model named no panel this app can draw.");let l=d.title??d.panel.label,m={title:l,recipe:{...d.panel.panel,title:l}};return{interaction:{...t.entry,ask:{kind:"panel",said:i},offered:[Se(d.panel,d.confidence)],outcome:"drawn",panel:m,usage:[...t.usage]},offers:[d.panel],panel:m}}function dn(n){return n.off?void 0:n.answer}var ln=`You answer a person's question about what they are looking at in an app, from the state given and nothing else. Answer only JSON: {"answer": one to three short sentences, "pick": [candidate ids that act on the answer, best first, at most three]}. Pick only ids from the candidates, and none when nothing fits. Never say an id to the person.`;async function wn(n,e){let t=W(n,e),i=e.said.trim(),r=t.catalog.candidates.filter(s=>Le(s)||s.type==="panel"||s.type==="place"||s.type==="record").slice(0,32),o=dn(n),u=F(n),d=oe(n),l="",m=[],c=s=>s.flatMap(S=>r.filter(h=>h.id===S)).slice(0,3).map(S=>({candidate:S}));try{if(o){let s=await o.answer({said:i,target:e.target,targetLabel:t.entry.targetLabel,state:t.state,catalog:{target:t.catalog.target,candidates:r},...e.follows?{follows:e.follows}:{}}),S=s.usage?.inputTokens,h=s.usage?.outputTokens,p=s.usage?.costUsd??(S!==void 0?be(o.price,S,h??0):void 0);t.meter({tier:"thinking",model:o.model,...S!==void 0?{inputTokens:S}:{},...h!==void 0?{outputTokens:h}:{},...p!==void 0?{costUsd:p}:{}}),l=typeof s.text=="string"?s.text.trim():"",m=c(s.pick??[])}else if(u){let s=await q(u,ln,JSON.stringify({ask:i,about:t.entry.targetLabel,...e.follows?{follows:e.follows}:{},state:t.state,candidates:r.map(S=>({id:S.id,says:S.description}))}),t,t.meter);l=typeof s?.answer=="string"?s.answer.trim():"",m=c(Array.isArray(s?.pick)?s.pick:[])}else if(d&&r.length>0){let{question:s,of:S}=ae(r,`Which of these best answers, or acts on: ${i}`),h=await re(d,{...t.state,asked:i,candidates:r.map(p=>({id:p.id,type:p.type,says:p.description}))},{answer:s},t.meter);m=se(h.answer,S,3),l=m.length>0?`These fit \u201C${i}\u201D.`:""}else return I(t,i,"ask",z)}catch(s){return I(t,i,"ask",s instanceof Error?s.message:String(s))}if(!l&&m.length===0)return I(t,i,"ask","The AI had no answer to that here.");let f=t.usage.at(-1)?.model,y=m.flatMap(({candidate:s,confidence:S})=>{let h=ie(s);return h?[{...h,...S!==void 0?{confidence:S}:{}}]:[]}),b=y.length>0?_(e.store,{interaction:t.id,target:e.target,basis:i,...f?{model:f}:{},proposals:y},e.principal):void 0,x=m.map(({candidate:s})=>s).filter(s=>ie(s)===void 0),k=[...x.map(s=>Se(s,m.find(S=>S.candidate===s)?.confidence)),...(b?.proposals??[]).map(s=>({id:s.id,type:s.field!==void 0?"fill":"act",label:s.label,...s.confidence!==void 0?{confidence:s.confidence}:{}}))];return{interaction:{...t.entry,ask:{kind:"ask",said:i},offered:k,outcome:"offered",...l?{answer:l}:{},usage:[...t.usage]},offers:x,...b&&b.proposals.length>0?{ghost:b}:{},...l?{answer:l}:{}}}function _(n,e,t){let i=e.proposals.flatMap(r=>{try{let o=n.previewAll([r.call],{author:t}),u=o.ops.map(d=>d.intent).join("; ");return o.ops.length>0?[{...r,said:u||r.said}]:[]}catch{return[]}});return{...e,proposals:i}}function ie(n){if(n.type==="fill")return{id:n.id,label:n.label,said:n.description,call:n.call,record:n.record,field:n.field};if(n.type==="act"&&n.asks.length===0)return{id:n.id,label:n.label,said:n.description,call:{name:n.mutation,args:{...n.args}}}}function Ge(n,e,t){let i=e.proposals.filter(o=>t.ids===void 0||t.ids.includes(o.id));if(i.length===0)return{ok:!1,refused:"Nothing was chosen."};let r=i.flatMap(o=>o.confidence===void 0?[]:[o.confidence]);try{let u=n.applyAll(i.map(d=>d.call),{author:t.author,via:`ai:${e.interaction}`,intent:e.basis,lineage:{basis:`Asked \u201C${e.basis}\u201D`,...e.model?{model:e.model}:{},...r.length>0?{confidence:Math.min(...r)}:{},interaction:e.interaction}}).ops[0]?.batch;return u?{ok:!0,batch:u,accepted:i.map(d=>d.id)}:{ok:!1,refused:"That changes nothing now."}}catch(o){return{ok:!1,refused:o instanceof Error?o.message:String(o)}}}function We(n,e,t){let i=n.ask.kind==="suggest"?e.length>0:n.offered.length>0&&n.offered.every(r=>e.includes(r.id));return{...n,outcome:i?"accepted":"partly",accepted:e,batches:[...n.batches??[],t]}}var qe=n=>({...n,outcome:"dismissed"});var R=ce(Ze(),1);var A=ce(Re(),1);function _e(n,e,t){let i=e.on==="selection"?e.ids:e.on==="record"||e.on==="field"?[e.id]:[],r=i.length>0?Ee(n.store,i,{principal:n.principal,...i.length===1?{focus:i[0]}:{}}).affordances.map(o=>({mutation:o.mutation,label:o.label,args:o.args,open:o.open,why:o.why,...o.destructive?{destructive:!0}:{}})):void 0;return{store:n.store,target:e,principal:n.principal,interaction:Ae(),places:n.places,selection:n.selection,...r?{acts:r}:{},...n.place?{place:n.place}:{},...t?{said:t}:{}}}async function Ke(n,e){let t=await (__graviewPreload(import.meta.url,["./chunk.UBFNZMUX.js","./chunk.G4JJXA63.js","./chunk.HAIG6NVX.js","./chunk.UZGRRDHD.js","./chunk.OKRNJXTV.js","./chunk.CAVBSL27.js","./chunk.Q5WEOX3Q.js","./chunk.GV2CQVKV.js","./chunk.4HZ7QTXZ.js","./chunk.G5NZVPJU.js","./chunk.WVUJXDXZ.js","./chunk.ULRW47RP.js","./chunk.PBSMLINK.js","./chunk.3TY5NFLY.js","./chunk.D75KC3LL.js","./chunk.FWTIUYXH.js","./chunk.MAF7C3VM.js","./chunk.B2GLDIAS.js","./chunk.6YCBYL2Y.js","./chunk.UGFJKSHU.js","./chunk.MNP4JI33.js","./chunk.AJZBJBMO.js"]),import("./chunk.XKABS745.js")),i=t.recipeDraft(e.recipe,{app:n.app,sight:t.draftSight(n.app,n.principal)});if(t.isDraftFailure(i))return i.failed;n.seatTalk.setDraft(i,null),n.goTo.draft?.(),Qe()}function Qe(n=180){if(typeof document>"u")return;let e=document.querySelector('[data-testid="draft-keep"]'),t=document.activeElement,i=!t||t===document.body||t.closest?.("[inert]")!==null;if(e){i&&e.focus();return}n>0&&requestAnimationFrame(()=>Qe(n-1))}function cn(n,e,t){!t.ghost||t.ghost.proposals.length===0||(n.desk.setGhost({ghost:t.ghost}),n.desk.record(e))}async function Q(n,e,t,i){let r=_e(n,t,i),o=e==="suggest"?await Fe(n.ai,r):e==="fill"?await Je(n.ai,r):e==="record"?await Ue(n.ai,r):await Be(n.ai,r);if(o.interaction.outcome==="failed")return e!=="suggest"&&n.desk.record(o.interaction),o;if((e==="fill"||e==="record")&&(o.ghost?cn(n,o.interaction,o):n.desk.record({...o.interaction,outcome:"failed",failed:"Nothing here could be filled in."})),e==="panel"&&o.panel){let u=await Ke(n,o.panel);n.desk.record(u?{...o.interaction,outcome:"failed",failed:u}:o.interaction)}return o}async function fn(n,e,t){let i=e.interaction,r=ie(t);if(r){let o=i.usage?.at(-1)?.model,u=i.offered.find(l=>l.id===t.id)?.confidence,d=_(n.store,{interaction:i.id,target:i.target,basis:`${i.ask.said}: ${t.label}`,...o?{model:o}:{},proposals:[{...r,...u!==void 0?{confidence:u}:{}}]},n.principal);if(d.proposals.length===0){n.desk.record({...i,outcome:"failed",failed:"That can't be done now."});return}n.desk.setGhost({ghost:d}),n.desk.record(i);return}if(t.type==="panel"){let o=t.label,u={title:o,recipe:{...t.panel,title:o}},d=await Ke(n,u);n.desk.record(d?{...i,outcome:"failed",failed:d}:{...i,outcome:"drawn",accepted:[t.id],panel:u});return}t.type==="place"?n.goTo.place(t.place):t.type==="record"&&n.goTo.record(t.record),n.desk.record({...i,outcome:"accepted",accepted:[t.id]})}async function Mn(n,e){if(e.ask.kind==="ask")return pe(n.desk,{target:e.target,asked:e.ask.said}),null;let t=e.ask.kind==="panel"||e.ask.kind==="record"?e.ask.kind:"fill";return Q(n,t,e.target,e.ask.said)}var K={padding:"5px 10px",fontSize:"0.875rem",borderRadius:8,width:"100%",textAlign:"left",borderWidth:1,borderStyle:"solid",borderColor:"transparent",background:"none",boxShadow:"none"},ze={margin:0,padding:"4px 10px",fontSize:"0.8125rem",color:"var(--graview-ink-muted)"};function jn({target:n,close:e}){let t=je(),i=(0,R.useMemo)(()=>De(n,s=>t.store.graph.has(s)),[n,t.store]),r=(0,R.useMemo)(()=>{let s=_e(t,i);return te(t.store,i,{principal:t.principal,places:t.places,...s.acts?{acts:s.acts}:{}})},[t,i]),o=r.candidates.some(s=>s.type==="fill"),u=r.candidates.some(s=>s.type==="panel"),d=(0,R.useMemo)(()=>new Set(t.store.allMutations().filter(s=>(s.creates??[]).length>0).map(s=>s.name)),[t.store]),l=F(t.ai)!==void 0&&r.candidates.some(s=>s.type==="act"&&s.asks.length>0&&d.has(s.mutation)),[m,c]=(0,R.useState)(null),[f,y]=(0,R.useState)(!0),[b,x]=(0,R.useState)(null);(0,R.useEffect)(()=>{let s=!0;return y(!0),Q(t,"suggest",i).then(S=>{s&&(c(S),y(!1),S.interaction.outcome==="failed"&&x(S.interaction.failed??"The AI could not suggest anything here."))}),()=>{s=!1}},[i]);let k=s=>{e(),s()};return(0,A.jsxs)("div",{"data-testid":"inline-ai",style:{display:"grid",gap:2},children:[f?(0,A.jsx)("p",{role:"status","data-testid":"inline-ai-thinking",style:ze,children:"Thinking\u2026"}):b?(0,A.jsx)("p",{role:"status",style:ze,children:b}):null,(0,A.jsxs)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:2},children:[(m?.offers??[]).map(s=>(0,A.jsx)("li",{children:(0,A.jsxs)("button",{type:"button","data-menu-item":`ai-offer:${s.id}`,"data-ai-offer":s.id,"data-ai-offer-type":s.type,onClick:()=>k(()=>fn(t,m,s)),style:K,children:[s.label,(0,A.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",s.type==="panel"?"a panel":s.type==="place"?"go there":s.type==="record"?"open it":"suggested"]})]})},s.id)),o?(0,A.jsx)("li",{children:(0,A.jsx)("button",{type:"button","data-menu-item":"ai-fill",onClick:()=>k(()=>Q(t,"fill",i,"Fill in")),style:K,children:"Fill in with AI"})}):null,l?(0,A.jsx)("li",{children:(0,A.jsx)("button",{type:"button","data-menu-item":"ai-record",onClick:()=>k(()=>Q(t,"record",i,"Add one")),style:K,children:"Add one with AI"})}):null,u?(0,A.jsx)("li",{children:(0,A.jsx)("button",{type:"button","data-menu-item":"ai-panel",onClick:()=>k(()=>Q(t,"panel",i,"Draw a panel")),style:K,children:"Draw a panel"})}):null,(0,A.jsx)("li",{children:(0,A.jsx)("button",{type:"button","data-menu-item":"ai-ask",onClick:()=>{let s=document.activeElement;e(),pe(t.desk,{target:i,returnTo:s instanceof HTMLElement&&s!==document.body?s:null})},style:K,children:"Ask about this\u2026"})})]})]})}var de={display:"inline-flex",alignItems:"center",minHeight:28,padding:"2px 10px",fontSize:"0.8125rem",borderRadius:8};function En({placement:n="picture"}){let{store:e,principal:t,aiDesk:i}=Me(),r=Ie(e,t),{ghost:o,entries:u}=ve(i),[d,l]=(0,R.useState)(new Set);(0,R.useEffect)(()=>l(new Set),[o?.ghost.interaction]);let m=(0,R.useRef)(null),c=(0,R.useRef)(null),f=o?.batch;if((0,R.useEffect)(()=>{f!==void 0&&c.current?.focus()},[f]),!o)return null;let{ghost:y}=o,b=u.find(p=>p.id===y.interaction),x=()=>{let p=y.target.on==="record"||y.target.on==="field"?y.target.id:void 0,M=m.current?.closest("[data-graview-face], main")?.parentElement??document,P=(p?M.querySelector(`[data-graview-view="${CSS.escape(p)}"][tabindex]`):null)??document.querySelector("[data-graview-page-title]")??m.current?.closest("main")??document.querySelector("main");P&&!P.hasAttribute("tabindex")&&P.setAttribute("tabindex","-1"),P?.focus({preventScroll:!0}),i.setGhost(null)},k=y.proposals.filter(p=>!d.has(p.id)).map(p=>p.id),s=()=>{let p=Ge(r,y,{author:t,ids:k});if(!p.ok){i.setGhost({...o,refused:p.refused});return}b&&i.record(We(b,p.accepted,p.batch)),i.setGhost({ghost:y,batch:p.batch,took:p.accepted.length,...o.onCard?{onCard:!0}:{}})},S=()=>{b&&o.batch===void 0&&i.record(qe(b)),x()},h=()=>{if(o.batch!==void 0)try{r.undo(o.batch,{author:t}),x()}catch(p){i.setGhost({...o,refused:p instanceof Error?p.message:String(p)})}};return(0,A.jsxs)("section",{ref:m,"data-testid":"ai-ghost","data-interaction":y.interaction,"aria-label":"Proposed by AI",style:{...n==="card"?{position:"static"}:{position:n==="page"?"fixed":"absolute",insetInline:"max(12px, calc(50% - 220px))",bottom:"calc(var(--graview-foot-room, 0px) + 72px)",zIndex:Te("toast"),boxShadow:"var(--graview-lift-high)"},display:"grid",gap:8,padding:12,borderRadius:12,border:"1px dashed var(--graview-accent)",background:"var(--graview-float)",fontSize:"0.875rem"},children:[(0,A.jsx)("p",{style:{margin:0,color:"var(--graview-ink-muted)"},children:o.batch!==void 0?`Done: ${o.took===1?"one change":`${o.took} changes`}, as one.`:`Proposed by AI \xB7 ${y.basis}`}),o.batch===void 0?(0,A.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:4},children:y.proposals.map(p=>(0,A.jsx)("li",{"data-ghost-proposal":p.id,children:(0,A.jsxs)("label",{style:{display:"flex",alignItems:"baseline",gap:8,cursor:"pointer"},children:[(0,A.jsx)("input",{type:"checkbox",checked:!d.has(p.id),onChange:M=>{let P=new Set(d);M.target.checked?P.delete(p.id):P.add(p.id),l(P)}}),(0,A.jsx)("span",{style:{fontStyle:"italic",color:"var(--graview-ink)"},children:p.said}),p.confidence!==void 0?(0,A.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[Math.round(p.confidence*100),"% sure"]}):null]})},p.id))}):null,o.refused?(0,A.jsx)("p",{role:"alert",style:{margin:0,color:"var(--graview-warn)"},children:o.refused}):null,(0,A.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:o.batch===void 0?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("button",{type:"button","data-testid":"ghost-accept",disabled:k.length===0,onClick:s,style:de,children:k.length===y.proposals.length?"Accept":`Accept ${k.length} of ${y.proposals.length}`}),(0,A.jsx)("button",{type:"button","data-testid":"ghost-dismiss",onClick:S,style:de,children:"Dismiss"})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("button",{type:"button",ref:c,"data-testid":"ghost-undo",onClick:h,style:de,children:"Undo"}),(0,A.jsx)("button",{type:"button","data-testid":"ghost-close",onClick:x,style:de,children:"Close"})]})})]})}export{De as a,me as b,te as c,rn as d,wn as e,_e as f,Ke as g,Q as h,fn as i,Mn as j,jn as k,En as l};
@@ -1 +0,0 @@
1
- import{D as l,K as p,R as k,S as y,c}from"./chunk.3NDH3EDN.js";import"./chunk.63GXY2ME.js";import"./chunk.UGFDSE37.js";import{b as m}from"./chunk.67TPUXAY.js";import"./chunk.Y6ZNFQK3.js";import"./chunk.NRAYZY3X.js";import"./chunk.RIJUCHP4.js";import"./chunk.TAQ764IQ.js";import"./chunk.YIR7PPF3.js";import"./chunk.3HXN4BOY.js";import"./chunk.GYICGZMG.js";import"./chunk.UHUGOTUU.js";import"./chunk.47STJVRV.js";import"./chunk.EBGAYL32.js";import"./chunk.DAZ2VSRD.js";import"./chunk.J25KOSNW.js";import"./chunk.LR3VDXPI.js";import"./chunk.CWHRDBOF.js";import"./chunk.3K6YSVHC.js";import"./chunk.SHTJZ6UX.js";import"./chunk.MB7LKKUD.js";import"./chunk.WVUJXDXZ.js";import"./chunk.ULRW47RP.js";import"./chunk.PBSMLINK.js";import"./chunk.3TY5NFLY.js";import"./chunk.D75KC3LL.js";import"./chunk.FWTIUYXH.js";import"./chunk.MAF7C3VM.js";import"./chunk.GZHZLJBF.js";import"./chunk.XMC7YDWT.js";import"./chunk.6UGEYZAC.js";import"./chunk.OJGHDWI6.js";import"./chunk.B2GLDIAS.js";import"./chunk.6YCBYL2Y.js";import"./chunk.UGFJKSHU.js";import"./chunk.JOOQUWLT.js";import{F as S,G as s,H as d,Q as f,Z as g}from"./chunk.6QWV5MVH.js";import"./chunk.MNP4JI33.js";import{b as n}from"./chunk.AJZBJBMO.js";var u=n(S(),1);var t=n(f(),1);function D({context:a}){let r=l(),h=g(),[w]=(0,u.useState)(()=>s(null)),o=d(h?.seatTalk??w),P=()=>{(window.history.state?.idx??0)>0?r(-1):r("/")};return(0,t.jsxs)(k,{context:a,"data-testid":"draft-page",children:[(0,t.jsx)(y,{context:a,...o.draft?{"data-testid":"draft-title"}:{},children:o.draft?o.draft.title:"Nothing drawn"}),o.draft?(0,t.jsx)(m,{page:!0,go:e=>r(e.address),onPick:e=>{let i=a.store.graph.getNode(e);i&&r(c(a.store.schema,i.kind,e))},onDiscard:P}):(0,t.jsxs)("p",{style:{margin:0,color:"var(--graview-ink-muted)"},children:["Ask for a way of seeing \u2014 \u201Ca board of tasks by status\u201D \u2014 and it is drawn here."," ",(0,t.jsx)(p,{to:"/",style:{color:"var(--graview-accent)"},children:"Home \u2192"})]})]})}export{D as DraftPage};
@@ -1 +0,0 @@
1
- import{a as b,b as c,c as d,d as e,e as f}from"./chunk.GV2CQVKV.js";import"./chunk.4HZ7QTXZ.js";import"./chunk.3TY5NFLY.js";import"./chunk.FWTIUYXH.js";import"./chunk.MAF7C3VM.js";import{ib as a}from"./chunk.MNP4JI33.js";import"./chunk.AJZBJBMO.js";export{a as ActRefusal,e as compileDocumentWithoutCheck,d as effectsOf,f as inDocumentWords,c as kindShapes,b as readDocument};
@@ -1 +0,0 @@
1
- import{d as ie}from"./chunk.B2GLDIAS.js";import{b as Te,d as Ce}from"./chunk.6YCBYL2Y.js";import{e as je}from"./chunk.UGFJKSHU.js";import{$ as Ae,Ac as Re,Cc as De,Dc as We,H as be,Ib as te,Ka as we,Ma as E,T as R,U as ke,Vc as Me,W as B,X as L,Y as xe,Z as v,aa as Ne,gc as re,kc as Se,lc as ve,yc as Oe}from"./chunk.MNP4JI33.js";function oe(n,e){return n.display?.labels?.[e]??v(e)}function ae(n){let e=ie(n);switch(e.type){case"text":case"date":case"number":case"boolean":case"choice":return e.type;default:return}}function Ye(n,e){let t=new Map,r=n.tryDefinition(e);for(let[o,i]of Object.entries(r?.edges??{}))t.set(o,{key:o,label:i.description?R(i.description):v(o),about:"edge",far:i.to==="*"?[...n.kinds]:[...i.to]});for(let o of n.definitions)if(o.kind!==e)for(let[i,d]of Object.entries(o.edges??{}))t.has(i)||d.to!=="*"&&!d.to.includes(e)||t.set(i,{key:i,label:d.inverse?R(d.inverse):v(i),about:"edge",far:[o.kind]});return[...t.values()]}var Je=["current","past","any","flagged","clear"];function Ie(n,e){let t=n?.lifecycle;if(!t||t.retired==="date")return!1;let r=t.retired.map(String);return e.some(o=>o.key===t.field&&r.includes(o.value))}function Fe(n,e){let t=n.tryDefinition(e);if(!t)return{kind:e,sorts:[],filters:[],groups:[]};let r=new Set(t.display?.hide??[]),o=t.fields.shape??{},i=[{key:"label",label:"Name",about:"label",type:"text"}],d=[],f=[];for(let[g,p]of Object.entries(o)){if(g==="id"||g==="kind"||g==="label"||r.has(g))continue;let A=ae(p);if(!A)continue;let O=oe(t,g),N=A==="choice"?Be(p):A==="boolean"?["true","false"]:void 0,w={key:g,label:O,about:"field",type:A,...N?{options:N}:{}};i.push(w),d.push(w),(A==="boolean"||A==="choice")&&f.push(w),A==="date"&&f.push({...w,buckets:["day","week","month","year","decade"]})}for(let g of Ye(n,e))i.push(g),d.push(g),f.push(g);let l={key:"is",label:t.lifecycle?"Standing and currency":"Standing",about:"is",type:"choice",options:t.lifecycle?[...Je]:["flagged","clear"]};d.push(l);let y=t.fieldRoles?.order,u=y&&(y in o||y==="label")?{by:y,direction:"asc"}:void 0;return{kind:e,sorts:i,filters:d,groups:f,...u?{natural:u}:{}}}function vn(n,e){let t=[];for(let o of e.filters){let i=o.about==="edge"&&o.far?.length===1?n.tryDefinition(o.far[0]):void 0;if(!(!i||i.kind===e.kind))for(let[d,f]of Object.entries(i.fields.shape??{}))ae(f)!=="choice"||i.display?.hide?.includes(d)||t.push({key:`${o.key}.${d}`,label:`${o.label} \xB7 ${oe(i,d)}`,about:"via",type:"choice",options:Be(f),far:[i.kind]})}if(t.length===0)return e;let r=e.filters.filter(o=>o.about!=="is");return{...e,filters:[...r,...t,...e.filters.filter(o=>o.about==="is")]}}function On(n,e){let t=n.tryDefinition(e.kind),r=Object.entries(t?.computed??{});if(!t||r.length===0)return e;let o=r.filter(([i])=>!e.sorts.some(d=>d.key===i)).map(([i,d])=>({key:i,label:(typeof d=="object"?d.label:void 0)??oe(t,i),about:"field",type:"number"}));return{...e,sorts:[...e.sorts,...o]}}function Be(n){let e=ie(n);return e.type==="choice"?e.options:[]}var $e=n=>n,Pe=n=>n;function Ze(n,e,t){let r=new Map;for(let o of[...n.out(e,t),...n.in(e,t)])r.set(o.id,o);return[...r.values()]}function se(n,e,t){let r=n.schema.tryDefinition(e.kind);if(t.key==="is")switch(t.value){case"current":return B(r,Pe(e),n.today);case"past":return!B(r,Pe(e),n.today);case"any":return!0;case"flagged":return n.flagged?.has(e.id)??!1;case"clear":return!(n.flagged?.has(e.id)??!1);default:return!0}let o=r?.fields.shape??{};if(t.key in o){let l=we($e(e),t.key,n.today??be()),y=ae(o[t.key]);if(y==="date"){let[u,g]=t.value.split(":");if(typeof l!="string"||!g)return!1;let p=l.slice(0,10);return u==="before"?p<g:u==="after"?p>g:p===g}if(y==="boolean")return String(l)===t.value;if(y==="number"){let u=t.value.lastIndexOf(":"),g=u>0?t.value.slice(0,u):"",p=Number(t.value.slice(u+1));if(g==="at-most"||g==="at-least")return typeof l!="number"||!Number.isFinite(p)?!1:g==="at-most"?l<=p:l>=p}return String(l)===t.value}let[i,d]=t.key.split("."),f=Ze(n.graph,e.id,i);return d?f.some(l=>String($e(l)[d])===t.value):t.value==="*"?f.length>0:t.value==="none"?f.length===0:f.some(l=>l.id===t.value)}var en=5;function _e(n){return n.normalize("NFD").replace(/\p{M}+/gu,"").toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").trim()}function de(n){return _e(n).replace(/ /g,"")}var _=new Map,nn=5e4;function K(n){let e=_.get(n);if(e===void 0){_.size>=nn&&_.clear();let t=_e(n);e={tokens:t.split(" ").filter(Boolean),whole:t.replace(/ /g,"")},_.set(n,e)}return e}var D=n=>[...K(n).tokens];function j(n,e){if(e.length===0)return;let{whole:t,tokens:r}=K(n),o=e.join("");if(t.length===0)return;if(t===o)return"exact";if(e.every(d=>r.some(f=>f.startsWith(d))))return t.startsWith(o)?"prefix":e.every(d=>r.includes(d))?"word":"part"}function q(n,e,t=48){let r=n.replace(/\s+/g," ").trim();if(r.length<=t)return r;let o=e[0],i=r.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase(),d=o?i.search(new RegExp(`(^|[^\\p{L}\\p{N}])${tn(o)}`,"u")):-1,f=d<0?0:d+(i[d]&&/[\p{L}\p{N}]/u.test(i[d])?0:1),l=Math.max(0,f-Math.floor(t/3));if(l>0){let u=r.lastIndexOf(" ",l);l=u<0?0:u+1}let y=Math.min(r.length,l+t);if(y<r.length){let u=r.indexOf(" ",y);y=u<0||u-y>16?y:u}return`${l>0?"\u2026":""}${r.slice(l,y).trim()}${y<r.length?"\u2026":""}`}var tn=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),rn=/^([\p{L}][\p{L}\p{N}_-]*):(\S+)$/u;function on(n){let e=[],t=[];for(let r of n.trim().split(/\s+/).filter(Boolean)){let o=rn.exec(r);o?t.push({key:o[1],value:o[2]}):e.push(r)}return{words:e.join(" "),conditions:t}}var Le=new WeakMap;function G(n,e){let t=Le.get(e);if(t&&t.definition===n)return t.texts;let r=an(n,e);return Le.set(e,{definition:n,texts:r}),r}function an(n,e){let t=L(n,e),r=[{field:"label",reading:"Name",text:t}];for(let o of Ce(e,n,{limit:Number.POSITIVE_INFINITY}))o.key==="label"||o.value===t||typeof e[o.key]!="boolean"&&r.push({field:o.key,reading:o.label,text:o.markdown?je(o.value):o.value});return r}var T={exact:0,prefix:1,word:2,part:3,field:4,near:5},ze=new Set(["a","an","the","of","and","or","for","to","in","on","at","by","with","my","our","is"]);function Ee(n){let e=n;e.length>4&&e.endsWith("ies")?e=`${e.slice(0,-3)}y`:e.length>4&&/(ss|x|ch|sh|z)es$/.test(e)?e=e.slice(0,-2):e.length>3&&e.endsWith("s")&&!/(ss|us|is)$/.test(e)&&(e=e.slice(0,-1));for(let t of["ing","ed"])if(e.length>t.length+2&&e.endsWith(t)){e=e.slice(0,-t.length),/([b-df-hj-km-np-rtv-z])\1$/.test(e)&&(e=e.slice(0,-1));break}return e.length>3&&e.endsWith("e")?e.slice(0,-1):e}function Ke(n,e,t){if(Math.abs(n.length-e.length)>t)return t+1;let r=[],o=Array.from({length:e.length+1},(i,d)=>d);for(let i=1;i<=n.length;i++){let d=[i],f=i;for(let l=1;l<=e.length;l++){let y=Math.min(o[l]+1,d[l-1]+1,o[l-1]+(n[i-1]===e[l-1]?0:1));i>1&&l>1&&n[i-1]===e[l-2]&&n[i-2]===e[l-1]&&(y=Math.min(y,r[l-2]+1)),d[l]=y,y<f&&(f=y)}if(f>t)return t+1;r=o,o=d}return o[e.length]}var z=new Map;function sn(n,e){let t=z.get(n);t||(z.size>=64&&z.clear(),z.set(n,t=new Map));let r=t.get(e);return r===void 0&&(r=dn(n,e)??null,t.set(e,r)),r??void 0}function dn(n,e){if(/\d/.test(n))return;let t=Ee(n);if(t.length>=3&&(Ee(e)===t||t.length>=4&&e.startsWith(t)))return"stem";let r=n.length<4?0:n.length<=7?1:2;if(r!==0){if(Ke(n,e,r)<=r)return"spelling";if(n.length>=5){for(let o=n.length-r;o<=n.length+r;o++)if(o<e.length&&Ke(n,e.slice(0,o),r)<=r)return"spelling"}}}function ln(n,e){let t=e.length>1?e.filter(o=>!ze.has(o)):e;if(t.length===0)return;let r;for(let o of t){let i;for(let d of n){for(let f of K(d.text).tokens){if(f.startsWith(o)){i={text:d,matched:f};break}let l=i?void 0:sn(o,f);l&&(i={text:d,matched:f,by:l})}if(i&&!i.by)break}if(!i)return;i.by&&!r&&(r={text:i.text,asked:o,matched:i.matched,by:i.by})}if(r)return{field:r.text.field,reading:r.text.reading,fragment:q(r.text.text,[r.matched]),strength:"near",asked:r.asked,matched:r.matched,by:r.by}}var cn=80;function fn(n,e,t){let r=D(e).filter(d=>!ze.has(d)).join(" ")||e,o=t===void 0?[]:D(t),i=o.length>0&&n.find(d=>o.every(f=>K(d.text).tokens.some(l=>l.startsWith(f))))||n[0];return{field:i.field,reading:i.reading,fragment:q(i.text,o),strength:"near",asked:r,matched:(t??i.text).slice(0,cn),by:"meaning"}}function He(n,e,t){let r=D(t);if(r.length===0)return;let o=G(n,e),[i,...d]=o,f=j(i.text,r);if(f)return{field:"label",reading:i.reading,fragment:q(i.text,r),strength:f};let l=p=>A=>K(A.text).tokens.some(O=>O.startsWith(p));if(!r.every(p=>o.some(l(p))))return;let y=D(i.text),u=r.find(p=>!y.some(A=>A.startsWith(p)))??r[0],g=d.find(l(u));return{field:g.field,reading:g.reading,fragment:q(g.text,[u]),strength:"field"}}var un=512,gn=64;function yn(n){let e=new Map;if(n.length===0)return e;let t=n.slice(-un),r=n[n.length-1].seq;for(let o of t){let i=Math.pow(.5,(r-o.seq)/gn);for(let d of o.writes)e.set(d,(e.get(d)??0)+i)}return e}var ce=(n,e)=>Ae({tryDefinition:()=>n},e),le=(n,e)=>Re({tryDefinition:()=>n},e);function hn(n,e,t){let r=n.tryDefinition(e),o=[{field:"plural",text:ce(r,e)},{field:"kind",text:v(e)},...r?.noun?[{field:"noun",text:r.noun}]:[]],i;for(let d of o){let f=j(d.text,t);f&&(!i||T[f]<T[i.strength])&&(i={strength:f,...d})}return i}var pn,mn=(n,e)=>(pn??=new Intl.Collator(void 0,{sensitivity:"base",numeric:!0})).compare(n,e),Ge=(n,e)=>(n.nearly??0)-(e.nearly??0)||(n.archived??0)-(e.archived??0)||n.tier-e.tier||n.inKind-e.inKind||n.near-e.near||n.past-e.past||n.touched-e.touched||n.flagged-e.flagged||mn(n.name,e.name)||(n.id<e.id?-1:n.id>e.id?1:0);function En(n,e,t={}){let r=n.schema,o=on(e),i=D(o.words),d=t.principal??{kind:"human"},f=n.kindsKeptFrom(d),l=n.modules.disabledKinds,y=o.conditions.filter(a=>a.key==="kind").map(a=>a.value),u=o.conditions.filter(a=>a.key==="is").map(a=>a.value),g=u.includes("any")||u.includes("past"),p=u.includes("past")&&!u.includes("any")&&!u.includes("current"),A=u.includes("archived")?!0:t.archived??"all",O=(a,s)=>{let c=de(s),h=r.tryDefinition(a);return de(a)===c||de(ce(h,a))===c},N=r.kinds.filter(a=>!f.has(a)&&!l.has(a)&&(t.kinds===void 0||t.kinds.includes(a))&&(y.length===0||y.some(s=>O(a,s)))),W=o.conditions.filter(a=>a.key!=="kind").map(a=>({...a,admittedBy:N.filter(s=>Fe(r,s).filters.some(c=>c.key===a.key))})),Q=W.filter(a=>a.key!=="is"),C=u.filter(a=>a==="flagged"||a==="clear"||a==="past"||a==="archived"),U={kinds:N,past:g},qe={hits:[],words:o.words,conditions:W,searched:U,byKind:{},total:0,matched:[]};if(i.length===0&&Q.length===0&&C.length===0)return qe;let V=t.today,$=t.flagged??new Set(n.violations().flatMap(a=>a.nodeIds)),Qe=t.touched??yn(n.log.all()),X=new Set;for(let a of t.from??[]){X.add(a);for(let s of n.graph.neighbors(a))X.add(s.id)}let fe=Se(n,d)?ve(n,d):void 0,Y=re.keptFrom?.(n,d)&&n.seenBy(d).graph,J=a=>Me(a,t.basePath===void 0?{}:{basePath:t.basePath}),ue={schema:r,graph:n.graph,flagged:$,...V?{today:V}:{}},S=[],P={},I=[],Z=[],H=(a,s,c,h,m,b)=>{let x=L(c,a);P[s]=(P[s]??0)+1,S.push({hit:{about:"node",id:a.id,kind:s,label:x,why:m,current:h,flagged:$.has(a.id),address:J(`${le(c,s)}/${encodeURIComponent(a.id)}`),...b===void 0?{}:{near:!0},...E(a)?{archived:!0}:{}},...b===void 0?{}:{nearly:2-b},tier:T[m.strength],inKind:s===t.inKind?0:1,near:X.has(a.id)?0:1,past:h?0:1,archived:E(a)?1:0,touched:-(Qe.get(a.id)??0),flagged:$.has(a.id)?0:1,name:x,id:a.id})};for(let a of N){let s=r.tryDefinition(a),c=W.filter(m=>m.key!=="is"&&m.admittedBy.includes(a));if(i.length===0&&c.length===0&&C.length===0)continue;let h=Ie(s,c);for(let m of n.graph.nodesOfKind(a,{archived:A})){if(fe&&!fe(m.id))continue;let b=Y?Y.getNode(m.id):m;if(!b)continue;let x=B(s,b,V);if(!g&&!h&&!x){if(i.length>0&&u.length===0&&c.every(k=>se(ue,b,k))){let k=He(s,b,o.words);k&&Z.push({node:b,kind:a,definition:s,why:k})}continue}if(p&&x||!c.every(k=>se(ue,b,k))||u.includes("flagged")&&!$.has(b.id)||u.includes("clear")&&$.has(b.id))continue;let M=i.length>0?He(s,b,o.words):c[0]?{field:c[0].key,reading:v(c[0].key),fragment:`${c[0].key}:${c[0].value}`,strength:"field"}:{field:"is",reading:"Is",fragment:`is:${C[0]}`,strength:"field"};M?H(b,a,s,x,M):i.length>0&&I.push({node:b,kind:a,definition:s,current:x})}}let ge=!1;if(Z.length>0&&S.length===0){ge=!0;for(let a of Z)H(a.node,a.kind,a.definition,!1,a.why)}let ye=t.near!==!1&&i.length>0&&S.length<en&&I.length>0,ee=new Set;if(ye)for(let a of I){let s=ln(G(a.definition,a.node),i);s&&(ee.add(a.node.id),H(a.node,a.kind,a.definition,a.current,s,s.by==="stem"?.9:.8))}let Ue=a=>a==="exact"||a==="prefix"?-1:T[a],ne=(a,s,c,h)=>({hit:a,tier:Ue(s),inKind:1,near:1,past:0,touched:0,flagged:1,name:c,id:h});if(i.length>0){for(let s of N){let c=hn(r,s,i);if(!c)continue;let h=Ne(r,s),m={field:c.field,reading:c.field==="plural"?"Plural":"Kind",fragment:c.text,strength:c.strength};S.push(ne({about:"kind",kind:s,label:h,why:m,count:P[s]??0,address:J(le(r.tryDefinition(s),s))},c.strength,h,`kind:${s}`))}let a=t.places??[];for(let s of Oe(a.filter(c=>N.includes(c.kind)))){if(s.across&&f.has(s.across))continue;let c=j(s.title,i);if(!c)continue;let h={field:"title",reading:"Title",fragment:s.title,strength:c},m=We(s,a)?le(r.tryDefinition(s.kind),s.kind).slice(1):void 0,b=J(De(s.as,m));S.push(ne({about:"place",kind:s.kind,title:s.title,as:s.as,why:h,address:b},c,s.title,`place:${s.kind}:${s.as}`))}for(let s of n.allInvariants()){let c=s.scope==="graph"?void 0:s.scope.kind;if(c&&!N.includes(c))continue;let h=s.label??v(s.name),m=j(h,i),b=m?void 0:j(v(s.name),i),x=m??b;if(!x)continue;let M={field:m?"label":"name",reading:m?"Rule":"Name",fragment:m?h:s.name,strength:x};S.push(ne({about:"rule",name:s.name,label:h,...c?{kind:c}:{},why:M},x,h,`rule:${s.name}`))}}let he=()=>{S.sort(Ge);let a=t.limit??50,s=S.slice(0,a).map(k=>k.hit),c=s.flatMap(k=>k.about==="node"?[(Y||n.graph).getNode(k.id)]:[]).filter(Boolean),h=Te(c,k=>r.tryDefinition(k)),m=s.map(k=>k.about==="node"&&h.has(k.id)?{...k,apart:h.get(k.id)}:k),b=Object.values(P).reduce((k,Xe)=>k+Xe,0),x=S.flatMap(k=>k.hit.about==="node"?[k.hit.id]:[]),M=t.subject&&N.includes(String(n.graph.getNode(t.subject)?.kind))?bn(n,t.subject,o.words,{principal:d}):[];return{hits:[...m,...M],words:o.words,conditions:W,searched:ge?{...U,past:!0}:U,byKind:{...P},total:b,matched:x}},F=he(),pe=t.rank;if(!ye||!pe)return F;let me=I.filter(a=>!ee.has(a.node.id)).map(({node:a,kind:s,definition:c})=>({id:a.id,kind:s,label:L(c,a),texts:G(c,a)}));if(me.length===0)return F;let Ve=(async()=>{let a;try{a=await pe(o.words,me)}catch{return F}let s=new Map(I.filter(h=>!ee.has(h.node.id)).map(h=>[h.node.id,h])),c=!1;for(let{id:h,score:m,matched:b}of Array.isArray(a)?a:[]){let x=s.get(h);!x||!(m>0)||(s.delete(h),c=!0,H(x.node,x.kind,x.definition,x.current,fn(G(x.definition,x.node),o.words,typeof b=="string"?b:void 0),Math.min(1,m)))}return c?he():F})();return{...F,later:Ve}}function bn(n,e,t,r={}){let o=r.principal??{kind:"human"},i=(re.keptFrom?.(n,o)?n.seenBy(o):n).graph.getNode(e);if(!i)return[];if(n.kindsKeptFrom(o).has(i.kind))return[];let d=D(t),f=L(n.schema.tryDefinition(i.kind),i),l=[];for(let u of n.allMutations()){let g=u.subject;if(!g||g.kinds!=="*"&&!g.kinds.includes(i.kind))continue;let p=u.derived?.act;if((p==="archive"||p==="merge")&&E(i)||p==="unarchive"&&!E(i)||p==="leave-alone"&&te(i)||p==="allow-tidying"&&!te(i)||!n.permits({name:u.name,args:{[g.arg]:i.id}},o).ok)continue;let A=xe(u),O=D(A),N=d.filter(Q=>O.some(C=>C.startsWith(Q))),w=N.length>0?j(A,N):void 0,W=w?{field:"title",reading:"Act",fragment:A,strength:w}:{field:"subject",reading:"On",fragment:f,strength:"field"};l.push({hit:{about:"act",name:u.name,title:A,subject:i.id,why:W,destructive:u.destructive===!0},tier:w?T[w]:T.field+1,inKind:0,near:0,past:u.destructive?1:0,touched:0,flagged:u.pinned?0:1,name:A,id:`act:${u.name}`})}l.sort(Ge);let y=l.map(u=>u.hit);return r.limit===void 0?y:y.slice(0,r.limit)}function Kn(n,e){let t=e.kinds.map((i,d)=>{let f=ce(n.tryDefinition(i),i);return d===0?f:f.toLowerCase()}),r=ke(t)||"Nothing";return e.kinds.some(i=>n.tryDefinition(i)?.lifecycle)?e.past?`${R(r)}, past ones included.`:`${R(r)}, current ones; add is:any for past ones.`:`${R(r)}.`}export{oe as a,ae as b,Ye as c,Ie as d,Fe as e,vn as f,On as g,Be as h,$e as i,Pe as j,Ze as k,se as l,de as m,on as n,He as o,yn as p,En as q,bn as r,Kn as s};
@@ -1 +0,0 @@
1
- import{j as a,k as o}from"./chunk.NRAYZY3X.js";import"./chunk.RIJUCHP4.js";import"./chunk.TAQ764IQ.js";import"./chunk.YIR7PPF3.js";import"./chunk.3HXN4BOY.js";import"./chunk.GYICGZMG.js";import"./chunk.47STJVRV.js";import"./chunk.EBGAYL32.js";import"./chunk.DAZ2VSRD.js";import"./chunk.CWHRDBOF.js";import"./chunk.3K6YSVHC.js";import"./chunk.SHTJZ6UX.js";import"./chunk.WVUJXDXZ.js";import"./chunk.ULRW47RP.js";import"./chunk.PBSMLINK.js";import"./chunk.3TY5NFLY.js";import"./chunk.D75KC3LL.js";import"./chunk.FWTIUYXH.js";import"./chunk.MAF7C3VM.js";import"./chunk.GZHZLJBF.js";import"./chunk.XMC7YDWT.js";import"./chunk.6UGEYZAC.js";import"./chunk.OJGHDWI6.js";import"./chunk.B2GLDIAS.js";import"./chunk.6YCBYL2Y.js";import"./chunk.UGFJKSHU.js";import"./chunk.JOOQUWLT.js";import{ja as n}from"./chunk.6QWV5MVH.js";import"./chunk.MNP4JI33.js";import"./chunk.AJZBJBMO.js";var w=new WeakMap;function s(e,i){let t=w.get(e);t||w.set(e,t=new Map);let r=t.get(i);return r||t.set(i,r=a(o(e,n(e)),e,i)),r}export{s as frameworkViews};
@@ -1 +0,0 @@
1
- import{a,b}from"./chunk.NTF7FVB2.js";import"./chunk.5UL7YDUD.js";import"./chunk.JOOQUWLT.js";import"./chunk.6QWV5MVH.js";import"./chunk.MNP4JI33.js";import"./chunk.AJZBJBMO.js";export{a as ActivityFilter,b as InteractionRow};
@@ -1 +0,0 @@
1
- import{b as c}from"./chunk.Y2SFUALD.js";import"./chunk.3NDH3EDN.js";import"./chunk.63GXY2ME.js";import"./chunk.UGFDSE37.js";import{j as m}from"./chunk.67TPUXAY.js";import"./chunk.Y6ZNFQK3.js";import"./chunk.NRAYZY3X.js";import"./chunk.RIJUCHP4.js";import"./chunk.TAQ764IQ.js";import"./chunk.YIR7PPF3.js";import"./chunk.3HXN4BOY.js";import"./chunk.GYICGZMG.js";import"./chunk.UHUGOTUU.js";import"./chunk.47STJVRV.js";import"./chunk.EBGAYL32.js";import"./chunk.DAZ2VSRD.js";import"./chunk.XANVHJQ4.js";import"./chunk.CAVBSL27.js";import"./chunk.J25KOSNW.js";import"./chunk.LR3VDXPI.js";import"./chunk.CWHRDBOF.js";import"./chunk.3K6YSVHC.js";import"./chunk.SHTJZ6UX.js";import"./chunk.UT6642FC.js";import"./chunk.MB7LKKUD.js";import"./chunk.WVUJXDXZ.js";import"./chunk.ULRW47RP.js";import"./chunk.PBSMLINK.js";import"./chunk.3TY5NFLY.js";import"./chunk.D75KC3LL.js";import"./chunk.FWTIUYXH.js";import"./chunk.MAF7C3VM.js";import"./chunk.GZHZLJBF.js";import"./chunk.XMC7YDWT.js";import"./chunk.6UGEYZAC.js";import"./chunk.OJGHDWI6.js";import"./chunk.B2GLDIAS.js";import"./chunk.6YCBYL2Y.js";import"./chunk.UGFJKSHU.js";import"./chunk.JOOQUWLT.js";import{F as S,Q as g}from"./chunk.6QWV5MVH.js";import{Uc as n}from"./chunk.MNP4JI33.js";import{b as t}from"./chunk.AJZBJBMO.js";var y=t(S(),1),a=t(g(),1);function R({store:h,auto:f,brand:i,views:u,presence:r,steering:o,overview:s,scope:d,titleLevel:v=2,quickAsk:l,props:e}){let b=(0,y.useMemo)(()=>m({scope:`.${d}`}),[d]);return(0,a.jsxs)("div",{"data-embed-content":"",style:f?{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:b}),(0,a.jsx)("div",{"data-embed-measure":"",style:{display:"flow-root"},children:(0,a.jsx)(c,{context:{store:h,embedded:!0,...e.bar!==!1?{barAbove:!0}:{},...s?{overview:s}:{},titleLevel:v,views:u,settings:e.app.settings??[],...r?{presence:r}:{},...i?{brand:i}:{},...e.locale?{locale:e.locale}:{},...e.principal?{principal:e.principal}:{},...e.seats?{seats:e.seats}:{},...e.people?{people:e.people}:{},...e.subscriptions?{subscriptions:e.subscriptions}:{},...l!==void 0?{quickAsk:l}:{}},...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{R as PagesContent};
@@ -1 +0,0 @@
1
- import{a,b}from"./chunk.4HRAQNJO.js";import"./chunk.Y6ZNFQK3.js";import"./chunk.BNV77BQZ.js";import"./chunk.SYAEBGDC.js";import"./chunk.NRAYZY3X.js";import"./chunk.RIJUCHP4.js";import"./chunk.TAQ764IQ.js";import"./chunk.YIR7PPF3.js";import"./chunk.3HXN4BOY.js";import"./chunk.GYICGZMG.js";import"./chunk.UHUGOTUU.js";import"./chunk.47STJVRV.js";import"./chunk.EBGAYL32.js";import"./chunk.DAZ2VSRD.js";import"./chunk.HJCQ6I3S.js";import"./chunk.MWGGV7DE.js";import"./chunk.JQU5GEU3.js";import"./chunk.HAIG6NVX.js";import"./chunk.UZGRRDHD.js";import"./chunk.XANVHJQ4.js";import"./chunk.CWHRDBOF.js";import"./chunk.3K6YSVHC.js";import"./chunk.SHTJZ6UX.js";import"./chunk.UT6642FC.js";import"./chunk.G5NZVPJU.js";import"./chunk.WVUJXDXZ.js";import"./chunk.ULRW47RP.js";import"./chunk.PBSMLINK.js";import"./chunk.3TY5NFLY.js";import"./chunk.D75KC3LL.js";import"./chunk.FWTIUYXH.js";import"./chunk.MAF7C3VM.js";import"./chunk.GZHZLJBF.js";import"./chunk.XMC7YDWT.js";import"./chunk.6UGEYZAC.js";import"./chunk.OJGHDWI6.js";import"./chunk.B2GLDIAS.js";import"./chunk.6YCBYL2Y.js";import"./chunk.UGFJKSHU.js";import"./chunk.JOOQUWLT.js";import"./chunk.6QWV5MVH.js";import"./chunk.MNP4JI33.js";import"./chunk.AJZBJBMO.js";export{b as declaredLensView,a as formatFor};
@@ -1 +0,0 @@
1
- import{a,b,c,d,e,f,g,h,i}from"./chunk.SYAEBGDC.js";import"./chunk.UZGRRDHD.js";import"./chunk.ULRW47RP.js";import"./chunk.PBSMLINK.js";import"./chunk.3TY5NFLY.js";import"./chunk.D75KC3LL.js";import"./chunk.FWTIUYXH.js";import"./chunk.MAF7C3VM.js";import"./chunk.6YCBYL2Y.js";import"./chunk.UGFJKSHU.js";import"./chunk.MNP4JI33.js";import"./chunk.AJZBJBMO.js";export{f as columnActs,c as columnMoves,b as columnOf,d as columnReach,e as columnSteps,h as describePlace,i as placeText,g as resolveFor,a as statusColumns};
@@ -1 +0,0 @@
1
- import{f as a,g as b,h as c,i as d,j as e,k as f,l as g}from"./chunk.AKFKM4SW.js";import"./chunk.XANVHJQ4.js";import"./chunk.OKRNJXTV.js";import"./chunk.CAVBSL27.js";import"./chunk.5UL7YDUD.js";import"./chunk.UT6642FC.js";import"./chunk.TI4OSTQV.js";import"./chunk.PBSMLINK.js";import"./chunk.B2GLDIAS.js";import"./chunk.6YCBYL2Y.js";import"./chunk.UGFJKSHU.js";import"./chunk.JOOQUWLT.js";import"./chunk.6QWV5MVH.js";import"./chunk.MNP4JI33.js";import"./chunk.AJZBJBMO.js";export{g as GhostTray,f as InlineAiMenu,e as askAgain,c as askInline,a as askOf,b as drawPanel,d as takeOffer};
@@ -1 +0,0 @@
1
- var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{s as P}from"./chunk.XMC7YDWT.js";import{F as A,N as M,Q as y,Y as m,Z as w,a as p,t as b,x as g,xa as S,y as T}from"./chunk.6QWV5MVH.js";import{b as d}from"./chunk.AJZBJBMO.js";var x=d(A(),1),h=d(y(),1),C=S(p(()=>(__graviewPreload(import.meta.url,["./chunk.JOOQUWLT.js","./chunk.6QWV5MVH.js","./chunk.MNP4JI33.js","./chunk.AJZBJBMO.js"]),import("./chunk.UNL2HIF2.js")))),O=C.part((e,n)=>(0,h.jsx)(e.Timeline,{...n}),{what:"The timeline"}),q=()=>C.prefetch();function H({face:e}){return M()?.open?(0,h.jsx)(x.Suspense,{fallback:null,children:(0,h.jsx)(O,{face:e})}):null}var i=d(A(),1),u=d(y(),1),v=new WeakMap,I=e=>{let n=v.get(e);return n||v.set(e,n={ask:null,doors:[],listeners:new Set}),n},k=e=>{for(let n of e.listeners)n()};function N(e,n){let o=I(e);o.ask=n,k(o)}var E=S(p(()=>(__graviewPreload(import.meta.url,["./chunk.E2YEOMPH.js","./chunk.D75KC3LL.js","./chunk.FWTIUYXH.js","./chunk.MAF7C3VM.js","./chunk.JOOQUWLT.js","./chunk.6QWV5MVH.js","./chunk.MNP4JI33.js","./chunk.AJZBJBMO.js"]),import("./chunk.H7EPE74C.js")))),B=E.part((e,n)=>{let o=e.NotifySheet;return(0,u.jsx)(o,{...n})},{what:"Notify me"}),W=E.part((e,n)=>{let o=e.NotifiedList;return(0,u.jsx)(o,{...n})},{quiet:!0}),D=e=>(e.onBehalfOf??e).id!==void 0;function L(e,n,o){let c=a=>o.tryDefinition(a)?.noun??a.replace(/[-_]+/g," "),t=e.on!==void 0?e.on:e.about.length===1?e.about[0]:void 0;if(e.act!==void 0){let a=t!==void 0&&n(t)!==void 0?t:void 0;return{label:"Notify me when someone does this\u2026",choices:[{on:"act",act:e.act,...a!==void 0?{record:a}:{}},...a!==void 0?[{on:"act",act:e.act}]:[]]}}if(t===void 0)return null;let r=n(t);if(r!==void 0)return{label:"Notify me when this changes\u2026",choices:[{on:"changed",record:t},{on:"act",record:t},{on:"reaches",kind:r,condition:"",record:t}]};let s=b(t)!==null?[b(t)]:g(t)?T(t):[];if(s.length!==1||!o.kinds.includes(s[0]))return null;let l=s[0],f=c(l);return{label:`Notify me when ${/^[aeiou]/i.test(f)?"an":"a"} ${f} is added\u2026`,choices:[{on:"created",kind:l},{on:"changed",kind:l},{on:"reaches",kind:l,condition:""}]}}function F(){let{store:e,principal:n,subscriptions:o}=m(),c=D(n);return(0,i.useMemo)(()=>c?t=>{let r=L(t,l=>e.graph.getNode(l)?.kind,e.schema);return r?{id:"notify",items:[{id:"notify-me",label:r.label,run:()=>N(o,{choices:r.choices,returnTo:t.element??null})}]}:null}:null,[c,e,o])}var z=[];function U({children:e}){let n=F(),o=(0,i.useMemo)(()=>n?[n]:z,[n]);return(0,u.jsx)(P,{sections:o,children:e})}function V(){let{subscriptions:e}=m(),n=(0,i.useId)(),o=I(e);(0,i.useEffect)(()=>(o.doors.push(n),k(o),()=>{o.doors.splice(o.doors.indexOf(n),1),k(o)}),[o,n]);let c=(0,i.useMemo)(()=>s=>(o.listeners.add(s),()=>void o.listeners.delete(s)),[o]),t=(0,i.useSyncExternalStore)(c,()=>o.ask,()=>null),r=(0,i.useSyncExternalStore)(c,()=>o.doors[0]===n,()=>!1);return!t||!r?null:(0,u.jsx)(i.Suspense,{fallback:null,children:(0,u.jsx)(B,{ask:t,close:()=>N(e,null)})})}function X({choices:e,label:n="Notify me",style:o,className:c,testId:t="notify-me"}){let{principal:r,subscriptions:s}=m();return D(r)?(0,u.jsx)("button",{type:"button","data-testid":t,className:c,onClick:l=>N(s,{choices:e,returnTo:l.currentTarget}),style:o,children:n}):null}function G(){let e=w(),n=e?.subscriptions,o=e?(e.principal.onBehalfOf??e.principal).id:void 0,[c,t]=(0,i.useState)(0);return(0,i.useEffect)(()=>{if(o===void 0||!n)return;let r=!0,s=()=>void Promise.resolve(n.list(o)).then(f=>r&&t(f.length),()=>r&&t(0));s();let l=n.onChange?.(s);return()=>{r=!1,l?.()}},[n,o]),c}function Y({style:e}){return G()===0?null:(0,u.jsx)(i.Suspense,{fallback:null,children:(0,u.jsx)(W,{...e?{style:e}:{}})})}export{q as a,H as b,F as c,U as d,V as e,X as f,G as g,Y as h};
@@ -1 +0,0 @@
1
- import{q as re}from"./chunk.DAZ2VSRD.js";import{a as j,b as C,c as J,d as te,e as ne,f as R,g as ie,i as ae,l as oe}from"./chunk.AKFKM4SW.js";import{a as X,b as Z,c as ee}from"./chunk.XANVHJQ4.js";import"./chunk.OKRNJXTV.js";import"./chunk.CAVBSL27.js";import{a as _}from"./chunk.5UL7YDUD.js";import"./chunk.UT6642FC.js";import"./chunk.TI4OSTQV.js";import"./chunk.PBSMLINK.js";import"./chunk.B2GLDIAS.js";import"./chunk.6YCBYL2Y.js";import"./chunk.UGFJKSHU.js";import{m as V}from"./chunk.JOOQUWLT.js";import{F as ge,I as Q,Q as Y,Y as U}from"./chunk.6QWV5MVH.js";import{$ as N,ec as B}from"./chunk.MNP4JI33.js";import{b as L}from"./chunk.AJZBJBMO.js";var a=L(ge(),1);var l=L(Y(),1),fe=new Set(["show","go","to","open","the","a","an","me"]),de=o=>o.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,""),D=(o,c)=>{let r=de(o);return c.every(t=>r.includes(t))},se=o=>o&&`${o[0].toLowerCase()}${o.slice(1)}`,I={act:4,show:3,place:3,record:4},he=360,h=12;function Ie({face:o,opening:c,close:r}){let t=_(),{setMenuAt:y}=U(),i=(0,a.useMemo)(()=>c.target??j(c.pointed??{about:[]},e=>t.store.graph.has(e)),[c,t.store]),g=(0,a.useMemo)(()=>te(t.store,i,t.places),[t.store,i,t.places]),[p,v]=(0,a.useState)(""),[b,m]=(0,a.useState)(-1),[s,E]=(0,a.useState)(null),[A,P]=(0,a.useState)(null),T=(0,a.useRef)(null),O=(0,a.useRef)(null),M=(0,a.useId)(),W=(0,a.useRef)(!0),{ghost:z}=Q(t.desk);(0,a.useEffect)(()=>()=>{W.current=!1;let e=t.desk.get().ghost;e?.onCard&&t.desk.setGhost({...e,onCard:!1})},[t.desk]);let $=(0,a.useMemo)(()=>{let e=R(t,i);return J(t.store,i,{principal:t.principal,places:t.places,...e.acts?{acts:e.acts}:{}})},[t,i]),G=(0,a.useMemo)(()=>{let e=C(i);if(e.length===0)return[];let n=new Set($.candidates.flatMap(d=>d.type==="act"?[d.mutation]:[]));return X(t.store,e,{principal:t.principal,...e.length===1?{focus:e[0]}:{}}).affordances.filter(d=>!d.destructive&&n.has(d.mutation))},[t.store,t.principal,i,$]),q=(0,a.useCallback)(()=>{let e=c.returnTo,n=le(T.current,i,o);r(),requestAnimationFrame(()=>{if(e?.isConnected&&!e.closest("[inert]"))return e.focus({preventScroll:!0});let d=(n&&n.tabIndex>=0?n:null)??document.querySelector("[data-graview-page-title]")??document.querySelector("main");d&&d.tabIndex<0&&!d.hasAttribute("tabindex")&&d.setAttribute("tabindex","-1"),d?.focus({preventScroll:!0})})},[c.returnTo,i,o,r]),K=(0,a.useCallback)(e=>{if(e.open.length>0){let n=T.current?.getBoundingClientRect();r(),y({x:n?.left??0,y:n?.top??0,on:e.args.id??C(i)[0],about:C(i)});return}try{ee(t.store,e,{}),Z(t.store,e,{},{author:t.principal}),q()}catch(n){P(n instanceof Error?n.message:String(n))}},[t.store,t.principal,r,q,y,i]),H=(0,a.useCallback)(async e=>{let n=e.trim();if(!n)return;let d=s?.result?.answer?{said:s.said,answer:s.result.answer}:void 0;v(""),m(-1),P(null),E({said:n,result:null});let S=await ne(t.ai,{...R(t,i,n),said:n,...d?{follows:d}:{}});t.desk.record(S.interaction),S.ghost&&S.ghost.proposals.length>0&&t.desk.setGhost({ghost:S.ghost,onCard:!0}),W.current&&E({said:n,result:S})},[s,t,i]),F=(0,a.useRef)(c.asked);(0,a.useEffect)(()=>{let e=F.current;F.current=void 0,e&&H(e)},[]);let k=(0,a.useMemo)(()=>{let e=p.trim();if(!e&&s)return[];let n=de(e).split(/\s+/).filter(f=>f&&!fe.has(f)),d=/^show\b/i.test(e),S=/^(go|open)\b/i.test(e),x=[];if(!d&&!S)for(let f of G.filter(u=>D(u.label,n)).slice(0,I.act))x.push({id:`act:${f.id}`,kind:"act",label:f.label,hint:f.open.length>0?"asks more":"do it",take:()=>K(f)});if(!S){let f=$.candidates.filter(u=>u.type==="panel");for(let u of f.filter(ue=>D(`show ${ue.label}`,n)).slice(0,I.show))x.push({id:u.id,kind:"show",label:`Show ${se(u.label)}`,hint:"a panel",take:()=>{r(),ie(t,{title:u.label,recipe:{...u.panel,title:u.label}})}})}if(!d){for(let f of t.places.filter(u=>D(u.title,n)).slice(0,I.place))x.push({id:`place:${f.as}`,kind:"place",label:`Go to ${f.title}`,take:()=>(r(),t.goTo.place(f.as))});if(n.length>0){let f=re(t.store,e.replace(/^(go to|open)\s+/i,""),{principal:t.principal,from:C(i),limit:I.record}).hits;for(let u of f)u.about==="node"&&x.push({id:`record:${u.id}`,kind:"record",label:u.label,hint:N(t.store.schema,u.kind),take:()=>(r(),t.goTo.record(u.id))})}}return e&&x.push({id:"ask",kind:"ask",label:e,take:()=>void H(e)}),x},[p,G,$,t,i,K,H,r,s]);(0,a.useEffect)(()=>m(p.trim()?0:-1),[p]),(0,a.useLayoutEffect)(()=>{let e=T.current;if(!e)return;if(typeof e.showPopover=="function")try{e.showPopover()}catch{}O.current?.focus({preventScroll:!0});let n=0,d=()=>{me(e,le(e,i,o)),n=requestAnimationFrame(d)};return d(),()=>cancelAnimationFrame(n)},[i,o]),(0,a.useEffect)(()=>{if(s)return;let e=n=>{n.target instanceof Node&&T.current?.contains(n.target)||r()};return document.addEventListener("pointerdown",e,!0),()=>document.removeEventListener("pointerdown",e,!0)},[s,r]);let ce=e=>{if(e.key==="ArrowDown"&&k.length>0)e.preventDefault(),m(n=>Math.min(k.length-1,n+1));else if(e.key==="ArrowUp"&&k.length>0)e.preventDefault(),m(n=>Math.max(0,n-1));else if(e.key==="Enter"){e.preventDefault();let n=k[b];n?n.take():p.trim()&&H(p)}},w=s?.result??null,pe=k[b];return(0,l.jsxs)("section",{ref:T,popover:"manual",role:"region","aria-label":s?`Answer about ${g}`:`Ask about ${g}`,"data-testid":"quick-ask","data-quick-ask":s?"answer":"bar","data-quick-ask-face":o,"data-graview-offstage":"","data-graview-overlay":"",onKeyDown:e=>{e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),q())},onMouseDown:e=>e.stopPropagation(),style:ke,children:[(0,l.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[(0,l.jsxs)("p",{"data-testid":"quick-ask-about",style:{margin:0,flex:"1 1 auto",minWidth:0,fontSize:"0.75rem",color:"var(--graview-ink-muted)",overflowWrap:"anywhere"},children:["About ",g]}),(0,l.jsx)("button",{type:"button","data-testid":"quick-ask-close","aria-label":"Close",title:"Close",onClick:q,style:we,children:(0,l.jsx)("span",{"aria-hidden":"true",children:"\u2715"})})]}),s?(0,l.jsxs)("div",{"data-testid":"quick-answer",style:{display:"grid",gap:8},children:[(0,l.jsxs)("p",{"data-testid":"quick-answer-asked",style:{margin:0,fontSize:"0.8125rem",color:"var(--graview-ink-muted)",fontStyle:"italic",overflowWrap:"anywhere"},children:["\u201C",s.said,"\u201D"]}),(0,l.jsx)("p",{"data-testid":"quick-answer-text","aria-live":"polite",style:{margin:0,fontSize:"0.9375rem",lineHeight:1.45,color:w?.interaction.outcome==="failed"?"var(--graview-warn)":"var(--graview-ink)",overflowWrap:"anywhere"},children:w===null?"Thinking\u2026":w.interaction.outcome==="failed"?w.interaction.failed??"The AI could not answer that here.":w.answer??""}),w&&w.offers.length>0?(0,l.jsx)("ul",{"aria-label":"What acts on it",style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:6},children:w.offers.map(e=>(0,l.jsx)("li",{children:(0,l.jsx)("button",{type:"button","data-testid":"quick-answer-offer","data-ai-offer":e.id,"data-ai-offer-type":e.type,onClick:()=>{r(),ae(t,w,e)},style:ve,children:e.type==="panel"?`Show ${se(e.label)}`:e.type==="place"?`Go to ${e.label}`:e.label})},e.id))}):null,z?.onCard&&z.ghost.interaction===w?.interaction.id?(0,l.jsx)(oe,{placement:"card"}):null]}):null,(0,l.jsxs)("div",{style:{display:"grid",gap:4},children:[(0,l.jsx)("input",{ref:O,type:"text",role:"combobox","data-testid":"quick-ask-input","aria-label":s?`Ask a follow-up about ${g}`:`Ask about ${g}, or go somewhere`,"aria-expanded":k.length>0,"aria-controls":M,"aria-autocomplete":"list",...pe?{"aria-activedescendant":`${M}-${b}`}:{},autoComplete:"off",enterKeyHint:"go",placeholder:s?"Ask a follow-up\u2026":"Ask, or go to\u2026",value:p,readOnly:s!==null&&w===null,"aria-busy":s!==null&&w===null,onChange:e=>v(e.target.value),onKeyDown:ce,style:be}),(0,l.jsx)("div",{id:M,role:"listbox","aria-label":p.trim()?`What \u201C${p.trim()}\u201D finds here`:"What can be done here",hidden:k.length===0,style:{display:k.length===0?"none":"grid",gap:1,maxHeight:280,overflowY:"auto"},children:k.map((e,n)=>(0,l.jsx)("div",{id:`${M}-${n}`,role:"option","aria-selected":n===b,"data-testid":"quick-ask-option","data-quick-ask-kind":e.kind,"data-quick-ask-row":e.id,onMouseEnter:()=>m(n),onMouseDown:d=>d.preventDefault(),onClick:e.take,style:{...ye,background:n===b?"var(--graview-panel-muted)":"transparent",...e.kind==="ask"?{borderTop:"1px solid var(--graview-edge)",marginTop:2}:{}},children:e.kind==="ask"?(0,l.jsxs)("span",{children:["Ask: ",(0,l.jsxs)("span",{style:{fontWeight:600},children:["\u2018",e.label,"\u2019"]})]}):(0,l.jsxs)("span",{children:[e.label,e.hint?(0,l.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",e.hint]}):null]})},e.id))})]}),A?(0,l.jsx)("p",{role:"alert","data-testid":"quick-ask-refused",style:{margin:0,fontSize:"0.8125rem",color:"var(--graview-warn)"},children:A}):null,(0,l.jsx)("span",{style:V,"aria-live":"polite",children:k.length>0&&p.trim()?`${k.length} ${k.length===1?"way":"ways"} to go on`:""})]})}function le(o,c,r){let t=o?.closest("[data-graview-embed]")??document,y=c.on==="list"?[`aggregate:${c.kind}`,`kind:${c.kind}`]:c.on==="lens"&&c.kind?[`aggregate:${c.kind}`]:C(c);for(let i of y)for(let g of t.querySelectorAll(`[data-graview-view="${CSS.escape(i)}"], [data-graview-pick="${CSS.escape(i)}"]`)){if(o?.contains(g))continue;let p=g.getBoundingClientRect();if(p.width>0&&p.height>0)return g}return r==="pages"?t.querySelector("main [data-graview-page-title]")??t.querySelector("main h1"):null}function me(o,c){let r={width:document.documentElement.clientWidth||innerWidth,height:innerHeight},t=Math.min(he,r.width-2*h),y=o.getBoundingClientRect().height,i=c?.getBoundingClientRect(),g,p,v,b=A=>Math.max(h,Math.min(A,r.height-y-h));if(i&&i.width>0&&i.bottom>0&&i.top<r.height)if(i.right+h+t<=r.width-h)g=i.right+h,p=b(i.top),v="right";else if(i.left-h-t>=h)g=i.left-h-t,p=b(i.top),v="left";else{g=Math.max(h,Math.min(i.left,r.width-t-h));let A=i.bottom+h;p=A+y<=r.height-h?A:b(i.top-h-y),v=A+y<=r.height-h?"below":"above"}else g=(r.width-t)/2,p=b(72),v="top";let m=o.style,s={left:`${Math.round(g)}px`,top:`${Math.round(p)}px`,width:`${Math.round(t)}px`};m.left!==s.left&&(m.left=s.left),m.top!==s.top&&(m.top=s.top),m.width!==s.width&&(m.width=s.width);let E=c?.getAttribute("data-graview-view")??c?.getAttribute("data-graview-pick")??(c?"page":"");o.getAttribute("data-quick-ask-beside")!==E&&o.setAttribute("data-quick-ask-beside",E),o.getAttribute("data-quick-ask-side")!==v&&o.setAttribute("data-quick-ask-side",v)}var ke={position:"fixed",inset:"auto",margin:0,zIndex:B("popover"),boxSizing:"border-box",display:"grid",gap:10,padding:12,borderRadius:12,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",color:"var(--graview-ink)",boxShadow:"var(--graview-lift-high)",maxHeight:"calc(100dvh - 24px)",overflowY:"auto",fontSize:"0.875rem"},we={display:"inline-grid",placeItems:"center",width:28,height:28,padding:0,font:"inherit",fontSize:"0.875rem",lineHeight:1,color:"var(--graview-ink-muted)",background:"transparent",border:"1px solid transparent",borderRadius:6,boxShadow:"none",cursor:"pointer"},be={boxSizing:"border-box",width:"100%",height:36,padding:"0 10px",font:"inherit",fontSize:"max(1rem,16px)",color:"var(--graview-ink)",background:"var(--graview-panel)",border:"1px solid var(--graview-edge)",borderRadius:8},ye={display:"flex",alignItems:"center",minHeight:30,padding:"4px 8px",borderRadius:6,cursor:"pointer",overflowWrap:"anywhere"},ve={display:"inline-flex",alignItems:"center",minHeight:30,padding:"2px 10px",font:"inherit",fontSize:"0.8125rem",borderRadius:8};export{Ie as QuickAskCard};
@@ -1 +0,0 @@
1
- import{h as n}from"./chunk.NRAYZY3X.js";import"./chunk.RIJUCHP4.js";import"./chunk.TAQ764IQ.js";import"./chunk.YIR7PPF3.js";import"./chunk.3HXN4BOY.js";import"./chunk.GYICGZMG.js";import"./chunk.47STJVRV.js";import"./chunk.EBGAYL32.js";import"./chunk.DAZ2VSRD.js";import"./chunk.CWHRDBOF.js";import"./chunk.3K6YSVHC.js";import"./chunk.SHTJZ6UX.js";import"./chunk.WVUJXDXZ.js";import{d as p}from"./chunk.ULRW47RP.js";import"./chunk.PBSMLINK.js";import"./chunk.3TY5NFLY.js";import"./chunk.D75KC3LL.js";import"./chunk.FWTIUYXH.js";import"./chunk.MAF7C3VM.js";import"./chunk.GZHZLJBF.js";import"./chunk.XMC7YDWT.js";import"./chunk.6UGEYZAC.js";import"./chunk.OJGHDWI6.js";import"./chunk.B2GLDIAS.js";import"./chunk.6YCBYL2Y.js";import"./chunk.UGFJKSHU.js";import"./chunk.JOOQUWLT.js";import{Q as m}from"./chunk.6QWV5MVH.js";import"./chunk.MNP4JI33.js";import{b as t}from"./chunk.AJZBJBMO.js";var i=t(m(),1),a=new WeakMap;function s(o){let e=a.get(o);if(!e){let r=p(o);e=c=>c.mode==="fullscreen"?(0,i.jsx)(n,{blocks:r,slot:"home",heading:2,firstHeading:1}):(0,i.jsx)(n,{blocks:r,slot:"home",heading:3,firstHeading:2}),a.set(o,e)}return e}export{s as homeView};
@@ -1 +0,0 @@
1
- var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{F as k,Q as n,a as t,xa as o}from"./chunk.6QWV5MVH.js";import{b as p}from"./chunk.AJZBJBMO.js";var f=o(t(()=>(__graviewPreload(import.meta.url,["./chunk.WVUJXDXZ.js","./chunk.ULRW47RP.js","./chunk.PBSMLINK.js","./chunk.3TY5NFLY.js","./chunk.D75KC3LL.js","./chunk.FWTIUYXH.js","./chunk.MAF7C3VM.js","./chunk.GZHZLJBF.js","./chunk.XMC7YDWT.js","./chunk.6UGEYZAC.js","./chunk.OJGHDWI6.js","./chunk.B2GLDIAS.js","./chunk.6YCBYL2Y.js","./chunk.UGFJKSHU.js","./chunk.JOOQUWLT.js","./chunk.6QWV5MVH.js","./chunk.MNP4JI33.js","./chunk.AJZBJBMO.js"]),import("./chunk.CIPS2OGR.js")))),y=f.part((e,r)=>e.drawFiles(r),{quiet:!0});var d=o(t(()=>(__graviewPreload(import.meta.url,["./chunk.GZHZLJBF.js","./chunk.XMC7YDWT.js","./chunk.6UGEYZAC.js","./chunk.OJGHDWI6.js","./chunk.B2GLDIAS.js","./chunk.6YCBYL2Y.js","./chunk.UGFJKSHU.js","./chunk.JOOQUWLT.js","./chunk.6QWV5MVH.js","./chunk.MNP4JI33.js","./chunk.AJZBJBMO.js"]),import("./chunk.LXBOVRFI.js")))),I=d.part((e,r)=>e.drawLinkedRecord(r),{quiet:!0}),w=d.part((e,r)=>e.drawLinkedPicker(r),{what:"Picking a linked record"});var s=p(n(),1),m=o(t(()=>(__graviewPreload(import.meta.url,["./chunk.GZHZLJBF.js","./chunk.XMC7YDWT.js","./chunk.6UGEYZAC.js","./chunk.OJGHDWI6.js","./chunk.B2GLDIAS.js","./chunk.6YCBYL2Y.js","./chunk.UGFJKSHU.js","./chunk.JOOQUWLT.js","./chunk.6QWV5MVH.js","./chunk.MNP4JI33.js","./chunk.AJZBJBMO.js"]),import("./chunk.4MERAWS2.js")))),E=m.part((e,r)=>(0,s.jsx)(e.RepeatPicker,{...r}),{quiet:!0}),W=m.part((e,r)=>(0,s.jsx)(e.RepeatEditor,{...r}),{quiet:!0});var a=p(k(),1),i=p(n(),1),c=o(t(()=>(__graviewPreload(import.meta.url,["./chunk.B2GLDIAS.js","./chunk.6YCBYL2Y.js","./chunk.UGFJKSHU.js","./chunk.JOOQUWLT.js","./chunk.6QWV5MVH.js","./chunk.MNP4JI33.js","./chunk.AJZBJBMO.js"]),import("./chunk.QVVJRSRM.js")))),l=c.part((e,r)=>(0,i.jsx)(e.WhenInput,{...r}),{quiet:!0});function M(e){return(0,i.jsx)(a.Suspense,{fallback:(0,i.jsx)("span",{"data-graview-when-arriving":"",style:{display:"inline-block",minHeight:24}}),children:(0,i.jsx)(l,{...e})})}var N=()=>c.load().then(()=>{},()=>{});export{y as a,I as b,w as c,E as d,W as e,M as f,N as g};
@@ -1 +0,0 @@
1
- import{a as n}from"./chunk.Y2SFUALD.js";import"./chunk.3NDH3EDN.js";import"./chunk.63GXY2ME.js";import"./chunk.UGFDSE37.js";import{j as s}from"./chunk.67TPUXAY.js";import"./chunk.Y6ZNFQK3.js";import"./chunk.NRAYZY3X.js";import"./chunk.RIJUCHP4.js";import"./chunk.TAQ764IQ.js";import"./chunk.YIR7PPF3.js";import"./chunk.3HXN4BOY.js";import"./chunk.GYICGZMG.js";import"./chunk.UHUGOTUU.js";import"./chunk.47STJVRV.js";import"./chunk.EBGAYL32.js";import"./chunk.DAZ2VSRD.js";import"./chunk.XANVHJQ4.js";import"./chunk.CAVBSL27.js";import"./chunk.J25KOSNW.js";import"./chunk.LR3VDXPI.js";import"./chunk.CWHRDBOF.js";import"./chunk.3K6YSVHC.js";import"./chunk.SHTJZ6UX.js";import"./chunk.UT6642FC.js";import"./chunk.MB7LKKUD.js";import"./chunk.WVUJXDXZ.js";import"./chunk.ULRW47RP.js";import"./chunk.PBSMLINK.js";import"./chunk.3TY5NFLY.js";import"./chunk.D75KC3LL.js";import"./chunk.FWTIUYXH.js";import"./chunk.MAF7C3VM.js";import"./chunk.GZHZLJBF.js";import"./chunk.XMC7YDWT.js";import"./chunk.6UGEYZAC.js";import"./chunk.OJGHDWI6.js";import"./chunk.B2GLDIAS.js";import"./chunk.6YCBYL2Y.js";import"./chunk.UGFJKSHU.js";import"./chunk.JOOQUWLT.js";import{F as y,Q as i}from"./chunk.6QWV5MVH.js";import"./chunk.MNP4JI33.js";import{b as r}from"./chunk.AJZBJBMO.js";var c=r(y(),1),e=r(i(),1);function v({store:d,views:t,as:a,scope:o}){let l=(0,c.useMemo)(()=>s({scope:`.${o}`}),[o]);return(0,e.jsxs)("div",{"data-testid":"embed-picture","data-embed-content":"",tabIndex:0,"aria-label":t.places().find(m=>m.as===a)?.title??"The picture",style:{flex:"1 1 auto",minHeight:0,display:"grid",gridTemplateRows:"minmax(0, 1fr)",overflow:"auto",background:"var(--graview-ground)",color:"var(--graview-ink)",fontFamily:"var(--graview-font-body, system-ui)"},children:[(0,e.jsx)("style",{children:l}),(0,e.jsx)(n,{store:d,views:t,as:a})]})}export{v as PictureFace};
@@ -1 +0,0 @@
1
- import{a as c,b as d,c as e,d as f,e as g,f as h,g as i,h as j,i as k,j as l,k as m,l as n,m as o,n as p}from"./chunk.UHUGOTUU.js";import{a,b}from"./chunk.47STJVRV.js";import"./chunk.EBGAYL32.js";import"./chunk.DAZ2VSRD.js";import"./chunk.B2GLDIAS.js";import"./chunk.6YCBYL2Y.js";import"./chunk.UGFJKSHU.js";import"./chunk.JOOQUWLT.js";import"./chunk.6QWV5MVH.js";import"./chunk.MNP4JI33.js";import"./chunk.AJZBJBMO.js";export{j as ARRANGE_NARROW,o as ArrangeBar,e as CHIP_FIELDS,d as MANY_AT_THE_FAR_END,c as TYPED_FROM,p as arrangementCaption,a as arrangementOf,i as chipOffers,m as directionWords,g as farCount,f as farCounts,l as inSentence,h as offeredFilters,n as preloadArrangeLists,k as sayCondition,b as withArrangement};
@@ -1 +0,0 @@
1
- import{b as sn,c as on}from"./chunk.UT6642FC.js";import{e as j}from"./chunk.B2GLDIAS.js";import{c as J}from"./chunk.UGFJKSHU.js";import{$ as nn,Gb as G,Jb as q,Ma as B,X as D,Y as M,Z as z,_ as Y,ca as en,da as F,ea as _,vb as tn,wb as R}from"./chunk.MNP4JI33.js";function rn(){return{name:"insight",derive({store:n,nodes:i,kindSelection:t}){let g=[],b=l=>D(n.schema.tryDefinition(l.kind),l);for(let l of i){if([...n.schema.edgeKinds].reduce((y,c)=>y+n.graph.out(l.id,c).length+n.graph.in(l.id,c).length,0)===0){g.push({id:`insight:island:${l.id}`,text:`${b(l)} is connected to nothing yet`,nodeIds:[l.id]});continue}for(let y of n.schema.edgeKinds){let c=n.graph.in(l.id,y).length;if(c<3)continue;let r=[...n.graph.allEdges()].filter(s=>s.kind===y),e=r.length;e>=4&&c/e>.6&&g.push({id:`insight:load:${l.id}:${y}`,text:`${b(l)} ${mn(n,r,y,c)}`,nodeIds:[l.id]})}}for(let l of t){if(n.graph.nodesOfKind(l).length>0)continue;let A=n.schema.definitions.filter(y=>y.kind!==l).filter(y=>Object.values(y.edges).some(c=>c.to!=="*"&&c.to.includes(l))).map(y=>y.plural??`${y.kind}s`);A.length>0&&g.push({id:`insight:gap:${l}`,text:`Nothing here yet, though ${A.join(" and ")} expect to connect to these`,nodeIds:[]})}return{observations:g}}}}function mn(n,i,t,g){let b=new Set(i.map(r=>n.graph.getNode(r.from)?.kind).filter(r=>r!==void 0)),l=b.size===1?[...b][0]:void 0,A=i.length,y=J(n.schema,l??[...b][0]??"",t,"in"),c=r=>l?Y(n.schema,l,r):String(r);return g===A?`${y}: all ${c(g)}`:`${y}: ${g} of the ${c(A)}`}function an(n){let i=new Map;if(n.length===0)return i;let t=n.slice(-512),g=new Set;for(let l of t)l.undoes&&g.add(l.undoes);let b=n[n.length-1].seq;for(let l of t){if(!l.mutation||g.has(l.id))continue;let A=Math.pow(.5,(b-l.seq)/64);i.set(l.mutation.name,(i.get(l.mutation.name)??0)+A)}return i}function dn(n){return 8*(n/(n+1))}var pn=100;function cn(){return{name:"invariant",derive({store:n,selection:i,nodes:t,violations:g}){let b=r=>D(n.schema.tryDefinition(r.kind),r),l=new Set(i),A=g.filter(r=>r.nodeIds.some(e=>l.has(e))||r.subjectId!==void 0&&l.has(r.subjectId)),y=[],c=[];A.forEach((r,e)=>{c.push({id:`violation:${r.invariant}:${e}`,text:r.message,nodeIds:r.nodeIds}),r.repairs.forEach((s,f)=>{y.push({id:`invariant:${r.invariant}:${e}:${f}`,label:s.label,provider:"invariant",mutation:s.mutation,args:s.args??{},open:(s.missing??[]).map(v=>{let u=n.allMutations().find(p=>p.name===s.mutation);if(!u)return{name:v};let a=R(u.input).find(p=>p.name===v),m=a?a.kinds.includes("*")?n.graph.allNodes().map(p=>p.id):a.kinds.flatMap(p=>n.graph.nodesOfKind(p).map($=>$.id)):void 0;return{name:v,shape:j(u.input,v),...a?{kinds:a.kinds}:{},...m?{candidates:m}:{}}}),score:pn-f-(s.missing?.length??0),why:r.message,nodeIds:r.nodeIds,...r.subjectId===void 0?{}:{subjectId:r.subjectId}})})});for(let r of t){let e=n.allInvariants().filter(s=>{if(s.scope==="graph")return!1;let f=s.scope;return f.kind!==r.kind?!1:f.match?f.match(r):!0});e.length!==0&&(A.some(s=>s.subjectId===r.id||s.nodeIds.includes(r.id))||c.push({id:`holds:${r.id}`,text:`${b(r)} holds \u2014 nothing currently breaks ${e.length===1?"it":`any of its ${e.length} rules`}`,nodeIds:[r.id]}))}return{affordances:y,observations:c}}}}var H=40;function un(){return{name:"schema",derive({store:n,selection:i,nodes:t,kindSelection:g,edgeSelection:b,principal:l}){let A=(e,s)=>l!==void 0&&!n.permits({name:e,args:s},l).ok,y=[];if(t.length===0&&b.length>0){for(let e of b){let s=n.graph.getNode(e.from),f=n.graph.getNode(e.to);if(!s||!f)continue;let v=on(n,e);v?.provisional&&y.push({id:`schema:edge:${G}:${e.kind}:${e.from}:${e.to}`,label:"Keep this link",provider:"schema",mutation:G,args:{kind:e.kind,from:e.from,to:e.to},open:[],score:64,why:sn(v),nodeIds:[e.from,e.to]});for(let u of n.allMutations()){let a=(u.connects??[]).includes(e.kind),m=(u.severs??[]).includes(e.kind);if(!a&&!m)continue;let p={},$=[],I=R(u.input);for(let d of I){let S=d.kinds.includes("*")||d.kinds.includes(s.kind),O=d.kinds.includes("*")||d.kinds.includes(f.kind),k=S&&!I.some(P=>P!==d&&(P.kinds.includes(s.kind)||P.kinds.includes("*")));S&&!O?p[d.name]=e.from:O&&!S?p[d.name]=e.to:S&&O&&k?p[d.name]=e.from:$.push({name:d.name,kinds:d.kinds,candidates:[e.from,e.to],shape:j(u.input,d.name)})}for(let d of T(u.input,""))d in p||$.some(S=>S.name===d)||$.push({name:d,shape:j(u.input,d)});$.every(d=>d.optional===!0?!0:d.kinds!==void 0?(d.candidates?.length??0)>0:(d.candidates?.length??0)>0||d.shape!==void 0&&d.shape.type!=="unknown")&&(a&&!m&&$.length===0||y.push({id:`schema:edge:${u.name}:${e.kind}:${e.from}:${e.to}`,label:M(u),provider:"schema",mutation:u.name,args:p,open:$,...u.destructive?{destructive:!0}:{},score:(m?62:58)-$.length,why:`this line is "${J(n.schema,n.graph.getNode(e.from)?.kind??"",e.kind,"out")}"`,nodeIds:[e.from,e.to]}))}}return{affordances:y}}if(t.length===0&&g.length>0){let e=new Set(g),s=[];for(let f of n.allMutations()){if(!(f.creates??[]).some(a=>e.has(a)))continue;let v=[];for(let a of R(f.input)){let m=a.kinds.includes("*")?n.graph.allNodes().map(p=>p.id):a.kinds.flatMap(p=>n.graph.nodesOfKind(p).map($=>$.id));v.push({name:a.name,kinds:a.kinds,candidates:m,shape:j(f.input,a.name),...a.optional?{optional:!0}:{}})}for(let a of T(f.input,""))v.some(m=>m.name===a)||v.push({name:a,shape:j(f.input,a)});if(!v.every(a=>a.optional===!0?!0:a.kinds!==void 0?(a.candidates?.length??0)>0:(a.candidates?.length??0)>0||a.shape!==void 0&&a.shape.type!=="unknown")&&!A(f.name,{})){let a=v.filter(m=>m.optional!==!0&&m.kinds!==void 0&&!m.kinds.includes("*")&&(m.candidates?.length??0)===0);if(a.length>0){let m=[...new Set(a.flatMap(p=>p.kinds??[]))].map(p=>F(_(n.schema.tryDefinition(p),p)));s.push({id:`schema:waits:${f.name}`,text:`"${f.title??f.name}" cannot begin until there is ${m.length===1?m[0]:`${m.slice(0,-1).join(", ")} and ${m[m.length-1]}`}.`,nodeIds:[]})}continue}y.push({id:`schema:add:${f.name}`,label:M(f),provider:"schema",mutation:f.name,args:{},open:v,score:H-v.length,why:`this makes ${(f.creates??[]).filter(a=>e.has(a)).map(a=>F(_(n.schema.tryDefinition(a),a))).join(", ")}`,nodeIds:[]})}return{affordances:y,observations:s}}if(t.length===0)return{};let c=new Set(t.map(e=>e.kind)),r=(e,s,f)=>{let v=[];for(let u of n.graph.allEdges()){if(!s.includes(u.kind))continue;let a=u.from===e?u.to:u.to===e?u.from:null;if(!a)continue;let m=n.graph.getNode(a);m&&(!f.includes("*")&&!f.includes(m.kind)||v.includes(a)||v.push(a))}return v};for(let e of n.allMutations()){let s=e.subject;if(!s||!(s.kinds==="*"?!0:[...c].every(h=>s.kinds.includes(h))))continue;let v=e.derived?.act;if((v==="archive"||v==="merge")&&t.some(h=>B(h))||v==="unarchive"&&!t.some(h=>B(h))||v==="leave-alone"&&t.every(h=>q(n,h.id))||v==="allow-tidying"&&!t.some(h=>q(n,h.id)))continue;let u=t.length===1?t[0].id:null,a=e.severs??[],m=e.connects??[];if(u&&a.length>0&&m.length===0&&r(u,a,["*"]).length===0)continue;let p=[];for(let h of R(e.input)){if(h.name===s.arg)continue;let d=h.kinds.includes("*")?n.graph.allNodes().map(S=>S.id):h.kinds.flatMap(S=>n.graph.nodesOfKind(S).map(O=>O.id));if(u&&m.length>0){let S=new Set(r(u,m,h.kinds));d=d.filter(O=>!S.has(O))}else u&&a.length>0&&(d=r(u,a,h.kinds));p.push({name:h.name,kinds:h.kinds,candidates:d.filter(S=>!i.includes(S)),shape:j(e.input,h.name),...h.optional?{optional:!0}:{}})}for(let h of T(e.input,s.arg))p.some(d=>d.name===h)||p.push({name:h,shape:j(e.input,h)});if(p.length===0&&u){let h=kn(e.input,s.arg);if(h.length>0&&!yn(n,e.name,{[s.arg]:u}))for(let d of h){let S=R(e.input).find(O=>O.name===d);p.push({name:d,optional:!0,...S?{kinds:S.kinds}:{},shape:j(e.input,d)})}}if(!p.every(h=>h.optional===!0?!0:h.kinds!==void 0?(h.candidates?.length??0)>0:(h.candidates?.length??0)>0||h.shape!==void 0&&h.shape.type!=="unknown")&&!A(e.name,u?{[s.arg]:u}:{}))continue;let I=t.map(h=>({[s.arg]:h.id}));p.length===0&&!I.some(h=>n.wouldChange({name:e.name,args:h}))||y.push({id:`schema:${e.name}`,label:t.length>1?`${M(e)} (${t.length})`:M(e),provider:"schema",mutation:e.name,args:I[0]??{},open:p,...e.destructive?{destructive:!0}:{},...e.derived?.act==="archive"||e.derived?.act==="merge"||e.derived?.act==="leave-alone"||e.derived?.act==="allow-tidying"?{setsAside:!0}:{},...a.length>0||m.length>0?{ties:!0}:{},...t.length>1?{batch:I}:{},score:H-p.length,why:t.length>1?`all ${t.length} selected nodes are ${[...c].map(h=>nn(n.schema,h).toLowerCase()).join(" or ")}`:`this is ${F(_(n.schema.tryDefinition(t[0].kind),t[0].kind))}`,nodeIds:t.map(h=>h.id)})}if(t.length===1){let e=t[0];for(let s of n.allMutations()){let f=s.subject,v=s.severs??[],u=s.connects??[];if(!f||v.length===0&&u.length===0)continue;let a=f.kinds==="*"?"*":f.kinds;if(a==="*"||a.includes(e.kind))continue;let m=R(s.input),p=m.find(k=>k.name!==f.arg&&(k.kinds.includes("*")||k.kinds.includes(e.kind)));if(!p)continue;let $=a,I=$.includes("*")?n.graph.allNodes().map(k=>k.id):$.flatMap(k=>n.graph.nodesOfKind(k).map(P=>P.id)),h=new Set(r(e.id,u.length>0?u:v,$)),d=u.length>0?I.filter(k=>!h.has(k)):I.filter(k=>h.has(k));if(d.length===0)continue;let S=[{name:f.arg,kinds:$,candidates:d,shape:j(s.input,f.arg)}];for(let k of m){if(k.name===p.name||k.name===f.arg)continue;let P=k.kinds.includes("*")?n.graph.allNodes().map(N=>N.id):k.kinds.flatMap(N=>n.graph.nodesOfKind(N).map(E=>E.id));S.push({name:k.name,kinds:k.kinds,candidates:P,shape:j(s.input,k.name),...k.optional?{optional:!0}:{}})}for(let k of T(s.input,p.name))k===f.arg||S.some(P=>P.name===k)||S.push({name:k,shape:j(s.input,k)});S.every(k=>k.optional===!0?!0:k.kinds!==void 0?(k.candidates?.length??0)>0:(k.candidates?.length??0)>0||k.shape!==void 0&&k.shape.type!=="unknown")&&y.push({id:`schema:tie:${s.name}:${e.id}`,label:s.fromTheOtherEnd??M(s),provider:"schema",mutation:s.name,args:{[p.name]:e.id},open:S,ties:!0,...s.destructive?{destructive:!0}:{},score:H-S.length+2,why:`${v.length>0?"this one is on":"this one could join"} ${S[0].candidates.length===1?"it":"one of these"}`,nodeIds:[e.id]})}}return{affordances:y}}}}function kn(n,i){let t=n.shape;return t?Object.entries(t).filter(([g,b])=>g!==i&&b.safeParse(void 0).success).map(([g])=>g):[]}function yn(n,i,t){try{return n.preview({name:i,args:t}),!0}catch{return!1}}function T(n,i){let t=n.shape;return t?Object.entries(t).filter(([g,b])=>g!==i&&!b.safeParse(void 0).success).map(([g])=>g):[]}var vn=70,bn=80,Sn=new Set(["id","kind"]);function fn(){return{name:"structure",derive({store:n,nodes:i}){let t=c=>D(n.schema.tryDefinition(c.kind),c);if(i.length<2)return{};let g=[],b=[],l=i.map(c=>c.id);for(let c of n.schema.edgeKinds){let r=wn(i.map(s=>new Set([...n.graph.out(s.id,c).map(f=>f.id),...n.graph.in(s.id,c).map(f=>f.id)])));for(let s of r){let f=n.graph.getNode(s);f&&g.push({id:`shared:${c}:${s}`,text:`all ${i.length} share "${t(f)}" (${z(c).toLowerCase()})`,nodeIds:[...l,s]})}let e=new Map;for(let s of i)for(let f of[...n.graph.out(s.id,c),...n.graph.in(s.id,c)])e.set(f.id,(e.get(f.id)??0)+1);for(let[s,f]of e){if(f!==i.length-1||i.length<3)continue;let v=n.graph.getNode(s);if(!v)continue;let u=i.find(a=>![...n.graph.out(a.id,c),...n.graph.in(a.id,c)].some(m=>m.id===s));if(u){g.push({id:`near-shared:${c}:${s}`,text:`all but "${t(u)}" share "${t(v)}" (${z(c).toLowerCase()})`,nodeIds:[...l,s]});for(let a of n.allMutations()){let m=a.subject;if(!m||m.kinds!=="*"&&!m.kinds.includes(u.kind))continue;let p=An(a.input,v.kind);p&&b.push({id:`structure:join:${a.name}:${u.id}:${s}`,label:`${M(a)}: bring "${t(u)}" in line with the others`,provider:"structure",mutation:a.name,args:{[m.arg]:u.id,[p]:s},open:[],score:vn,why:`every other selected node is connected to "${t(v)}"`,nodeIds:[u.id,s]})}}}}let A=new Set;for(let c of i)for(let r of Object.keys(c))Sn.has(r)||A.add(r);let y=c=>n.schema.definitions.find(r=>r.kind===c);for(let c of[...A].sort()){let r=y(i[0].kind),e=en(r,c).toLowerCase(),s=r?.display?.format?.[c],f=d=>{if(!s)return d;try{return String(s(JSON.parse(d)))}catch{return d}},v=i.map(d=>d[c]),u=new Map;if(v.forEach((d,S)=>{let O=JSON.stringify(d??null),k=u.get(O);k?k.push(i[S]):u.set(O,[i[S]])}),u.size===1){let d=[...u.keys()][0];if(d==="null")continue;g.push({id:`agree:${c}`,text:`all ${i.length} share the ${e} ${f(d)}`,nodeIds:l});continue}if(i.length<3||u.size!==2)continue;let a=[...u.entries()].sort((d,S)=>S[1].length-d[1].length),[m,p]=a[0],[,$]=a[1];if($.length!==1||m==="null")continue;let I=$[0],h=JSON.parse(m);g.push({id:`odd-one-out:${c}`,text:`${p.length} share the ${e} ${f(m)}; "${t(I)}" does not`,nodeIds:l});for(let d of n.allMutations()){let S=d.subject;if(!S||S.kinds!=="*"&&!S.kinds.includes(I.kind))continue;let O=ln(d.input);if(!O||!(c in O))continue;let k={[S.arg]:I.id,[c]:h},P=!0;for(let[N,E]of Object.entries(O)){if(N in k||E.safeParse(void 0).success)continue;let K=I[N];if(K===void 0){P=!1;break}k[N]=K}P&&b.push({id:`structure:align:${d.name}:${c}:${I.id}`,label:`Align the ${e} of "${t(I)}" with the other ${p.length}`,provider:"structure",mutation:d.name,args:k,open:[],score:bn,why:`${p.length} of ${i.length} share the ${e} ${f(m)}`,nodeIds:l})}}return{affordances:b,observations:g}}}}function wn(n){if(n.length===0)return[];let[i,...t]=n;return[...i].filter(g=>t.every(b=>b.has(g))).sort()}function ln(n){return n.shape??null}function An(n,i){let t=ln(n);if(!t)return null;for(let[g]of Object.entries(t)){let b=tn(t[g]);if(b&&(b.includes("*")||b.includes(i)))return g}return null}function $n(){return[cn(),fn(),un(),rn()]}function Zn(n,i,t={}){let g=hn(),b=t.providers??$n(),l=i.map(o=>n.graph.getNode(o)).filter(o=>o!==void 0),A={store:n,selection:i,nodes:l,kindSelection:t.kindSelection??[],edgeSelection:t.edgeSelection??[],violations:n.violations(t.context),context:t.context??{},principal:t.principal??{kind:"human"}},y=[],c=[];for(let o of b){let w=o.derive(A);y.push(...w.affordances??[]),c.push(...w.observations??[])}let r=new Set(n.allMutations().filter(o=>o.pinned).map(o=>o.name)),e=new Set(t.pins?.pinned??[]),s=new Set(t.pins?.unpinned??[]),f=o=>e.has(o.mutation)?"user":r.has(o.mutation)&&!s.has(o.mutation)?"declared":void 0,v=o=>{let w=f(o);return w?{...o,pinned:w}:o},u=new Map;for(let[o,w]of an(n.log.all()))u.set(o,dn(w));let a=o=>o.pinned==="user"?0:o.pinned==="declared"?1:2,m=o=>o.score+(u.get(o.mutation)??0),p=new Map(n.allMutations().map(o=>[o.name,o])),$=new Map,I=o=>{let w=p.get(o.mutation);if(!w)return[];let x=$.get(o.mutation);x||(x=R(w.input).map(L=>L.name),$.set(o.mutation,x));let C=[];for(let L of o.batch??[o.args])for(let U of x){let X=L[U]??o.args[U];typeof X=="string"&&C.push(X)}return C},h=t.focus,d=4,S=o=>o.open.length>0?1:0,O=o=>{if(h===void 0)return d;let w=I(o);return w.length>0?w.includes(h)?k(o,0):d:o.nodeIds.includes(h)||o.subjectId===h?k(o,1):d},k=(o,w)=>o.provider==="invariant"?w:2+S(o),P=o=>o.setsAside?1:0,N=On(y).map(v),E=new Map(N.map((o,w)=>[o,w])),K=N.sort((o,w)=>{let x=Number(o.destructive??!1)-Number(w.destructive??!1);if(x!==0)return x;let C=P(o)-P(w);if(C!==0)return C;let L=O(o)-O(w);return L!==0?L:O(o)<2?E.get(o)-E.get(w):+(w.provider==="invariant")-+(o.provider==="invariant")||a(o)-a(w)||m(w)-m(o)||o.id.localeCompare(w.id)}),Z=t.principal??{kind:"human"},W=[],V=[];for(let o of K){let w=n.permits({name:o.mutation,args:{...o.args,...o.batch?.[0]??{}}},Z);if(w.ok)W.push(o);else{let x=Pn(n,o,Z);if(x==="done")continue;x?W.push(x):V.push({...o,refusal:w.refusal})}}let Q=W.map((o,w)=>({...o,rank:w})),gn=V.map((o,w)=>({...o,rank:W.length+w}));return{affordances:t.limit===void 0?Q:Q.slice(0,t.limit),withheld:gn,observations:In(c),ms:hn()-g}}function On(n){let i=new Map;for(let t of n){let g=[t.mutation,JSON.stringify(t.args),JSON.stringify(t.batch??null)].join("|"),b=i.get(g);(!b||t.score>b.score)&&i.set(g,t)}return[...i.values()]}function In(n){let i=new Map;for(let t of n)i.set(t.text,t);return[...i.values()]}function hn(){return typeof performance<"u"?performance.now():Date.now()}function Vn(n,i,t={},g={}){let b=(i.batch??[i.args]).map(A=>({name:i.mutation,args:{...i.args,...A,...t}})),l=n.allMutations().find(A=>A.name===i.mutation);return n.applyAll(b,{...l?.describe?{}:{intent:i.label},...g.author?{author:g.author}:{}})}function Qn(n,i,t={}){return n.preview({name:i.mutation,args:{...i.args,...t}})}function Pn(n,i,t){let g=n.allMutations().find(r=>r.name===i.mutation)?.subject,b=g!==void 0&&i.args[g.arg]===void 0,l=b?i.open.find(r=>r.name===g.arg):i.open.find(r=>r.name!==g?.arg&&r.candidates);if(!l?.candidates)return;let A=r=>n.permits({name:i.mutation,args:{...i.args,...i.batch?.[0]??{},[l.name]:r}},t).ok,y=l.candidates.filter(A),c=t.id===void 0?void 0:n.graph.getNode(t.id);if(y.length===0){let r=b?g.kinds:"*";return c!==void 0&&(r==="*"||r.includes(c.kind))&&A(c.id)?"done":void 0}return y.length===1&&y[0]===t.id?{...i,args:{...i.args,[l.name]:t.id},open:i.open.filter(r=>r!==l)}:{...i,open:i.open.map(r=>r===l?{...r,candidates:y}:r)}}export{Zn as a,Vn as b,Qn as c};
@@ -1 +0,0 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk.UBFNZMUX.js";import"./chunk.G4JJXA63.js";import"./chunk.HAIG6NVX.js";import"./chunk.UZGRRDHD.js";import"./chunk.OKRNJXTV.js";import"./chunk.CAVBSL27.js";import"./chunk.Q5WEOX3Q.js";import"./chunk.GV2CQVKV.js";import"./chunk.4HZ7QTXZ.js";import"./chunk.G5NZVPJU.js";import"./chunk.WVUJXDXZ.js";import"./chunk.ULRW47RP.js";import"./chunk.PBSMLINK.js";import"./chunk.3TY5NFLY.js";import"./chunk.D75KC3LL.js";import"./chunk.FWTIUYXH.js";import"./chunk.MAF7C3VM.js";import"./chunk.B2GLDIAS.js";import"./chunk.6YCBYL2Y.js";import"./chunk.UGFJKSHU.js";import"./chunk.MNP4JI33.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{l as P}from"./chunk.OJGHDWI6.js";import{e as C}from"./chunk.B2GLDIAS.js";import{F as x,Q as k,Y as w,Z as B,_ as W,d as I,ma as G,y as V}from"./chunk.6QWV5MVH.js";import{$b as _,Ab as N,B as D,ac as L,gc as j,wb as F}from"./chunk.MNP4JI33.js";import{b as m}from"./chunk.AJZBJBMO.js";function H(n,e){let t=n.graph.getNode(e);if(!t)return[];let i=t.kind,a=n.schema.tryDefinition(i);if(!a)return[];let d=n.seenFor,c=d?j.keptFrom?.(n,d)?.(t):void 0,o=new Map;for(let r of n.allMutations()){let s=r.subject;if(!s||!(s.kinds==="*"||s.kinds.includes(i)))continue;let u=r.input.shape??{};for(let l of N(r,a)){if(c?.(l))continue;let b=l in u,M=[];for(let y of Object.keys(u)){if(y===s.arg||y===l||J(u[y]))continue;let v=F(r.input).find(S=>S.name===y);M.push({name:y,...v?{kinds:v.kinds}:{},...v?{candidates:v.kinds.includes("*")?n.graph.allNodes().map(S=>S.id):v.kinds.flatMap(S=>n.graph.nodesOfKind(S).map(Q=>Q.id))}:{},shape:C(r.input,y)})}let Y={field:l,mutation:r.name,title:r.title??r.name,shape:b?C(r.input,l):{type:"unknown"},takesValue:b,alternatives:[],open:M,call:y=>({name:r.name,args:b?{[s.arg]:e,[l]:y}:{[s.arg]:e}})};o.set(l,[...o.get(l)??[],Y])}}return[...o.values()].map(r=>{let s=[...r.filter(l=>l.takesValue),...r.filter(l=>!l.takesValue)],[f,...u]=s;return{...f,alternatives:u}})}function J(n){let e=D(n)?.type;return e==="optional"||e==="default"||e==="nullable"}var R=m(x(),1);function we(n){let{store:e,principal:t}=w(),i=W(),a=(0,R.useMemo)(()=>n===null?[]:H(e,n),[e,n,i]),d=(0,R.useCallback)((c,o,r={})=>{let s=c.call(o);e.apply({name:s.name,args:{...s.args,...r}},{author:t})},[e,t]);return{fields:a,commit:d}}var K=m(x(),1);function Ye(){let{brand:n}=w(),e=n?.kit;return(0,K.useMemo)(()=>_(e),[e])}function Qe(n,e){let t=L(n,e),i={...t.color!==void 0?{color:t.color}:{},...t.pattern!==void 0?{pattern:t.pattern}:{},...t.width!==void 0?{width:t.width}:{},...t.cap!==void 0?{cap:t.cap}:{},...t.opacity!==void 0?{opacity:t.opacity}:{}};return{connector:t,style:P(e,{[e]:i})}}var $=m(x(),1);var g=m(k(),1);function X(n){let e=n?.hint;return typeof e=="string"&&e.length>0?e:void 0}function Z(n){if(n instanceof Error&&n.message)return n.message;let e=String(n);return e==="[object Object]"?"The view threw without a message.":e}var U=class extends $.Component{static contextType=G;state={};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[graview] the ${this.props.view??"view"} of ${this.props.kind} threw while rendering`,e,t.componentStack),this.context?.(e,{module:"@graview/react"})}render(){let{error:e}=this.state;if(!e)return this.props.children;let t=X(e);return(0,g.jsxs)("div",{role:"alert","data-graview-view-error":this.props.kind,style:{display:"flex",flexDirection:"column",gap:"0.375rem",padding:"var(--graview-pad, 12px)",height:"100%",overflow:"auto",boxSizing:"border-box",borderRadius:"var(--graview-radius-sm, 6px)",background:"var(--graview-panel-warning, #fdf3ec)",color:"var(--graview-ink, #1a1a1a)",font:"var(--graview-font-body, 13px/1.45 system-ui)",fontSize:"0.875rem",lineHeight:1.45},children:[(0,g.jsx)("strong",{style:{color:"var(--graview-warn, #b4462a)"},children:this.props.view?`${this.props.view} could not draw`:"This view could not draw"}),(0,g.jsx)("span",{style:{color:"var(--graview-ink-muted, #555)"},children:this.props.kind}),(0,g.jsx)("span",{children:Z(e)}),t?(0,g.jsx)("span",{style:{color:"var(--graview-ink-muted, #555)"},children:t}):null]})}};var h=m(x(),1);var z=m(k(),1),A=(0,h.createContext)([]);function nn({sections:n,children:e}){let t=(0,h.useContext)(A),i=(0,h.useMemo)(()=>[...t,...n.filter(a=>!t.includes(a))],[t,n]);return(0,z.jsx)(A.Provider,{value:i,children:e})}function tn(n){let e=(0,h.useContext)(A),t=B()?.menuSections,i=t?[...e,...t.filter(d=>!e.includes(d))]:e;if(n===null||i.length===0)return{start:[],end:[]};let a=i.flatMap(d=>{try{let c=d(n);return c&&((c.items?.length??0)>0||c.render)?[c]:[]}catch{return[]}});return{start:a.filter(d=>d.at==="start"),end:a.filter(d=>d.at!=="start")}}var ee=m(x(),1);function an(){return w().activity}var O=(n,e)=>n.length*e*.58;var ne=156,te=2,E=ne-18,re=7.1,oe=16;function ie(n,e){let t=0,i=E;for(let a of n.split(" ")){let d=e(a),c=i+e(" ")+d;if(c<=E)i=c;else{let o=Math.ceil(d/E)||1;t+=o,i=d-(o-1)*E}}return t}var ae=16.25,q=27,se=(n,e)=>{let t=Math.ceil(n.length*re/E);return e?Math.max(q,Math.ceil(Math.max(t,ie(n,e))*ae)+6):Math.max(q,t*oe+6)};function cn(n,e,t){return n.length===0?0:10+n.reduce((i,a)=>i+se(a,t),0)+(n.length-1)*te}var de=27,ce=8,ln=4,le=64,un=n=>Math.max(1,Math.min(ce,n)),pn=n=>n*de+le;var p=m(x(),1);function gn(n,{units:e,target:t=0,legibleAt:i=260}){let[a,d]=(0,p.useState)(e);(0,p.useEffect)(()=>{let o=n.current;if(o===null||typeof ResizeObserver>"u")return;let r=new ResizeObserver(([s])=>{let f=s?.contentRect.width??0;f>0&&d(f)});return r.observe(o),()=>r.disconnect()},[n]);let c=a/e;return{scale:c,width:a,touchable:c*t>=24,legible:a>=i}}function hn(n="--graview-font-body",e="sans-serif"){let t=(0,p.useRef)(void 0),i=(0,p.useMemo)(()=>{if(typeof getComputedStyle!="function"||typeof document>"u")return e;let a=getComputedStyle(document.documentElement).getPropertyValue(n).trim();return a.length>0?a:e},[n,e]);return(0,p.useMemo)(()=>{t.current===void 0&&(t.current=typeof document>"u"?null:document.createElement("canvas").getContext("2d")??null);let a=t.current;return a===null?O:(d,c)=>{a.font=`${c}px ${i}`;let o=a.measureText(d).width;return o>0?o:O(d,c)}},[i])}var xn=(0,p.createContext)(void 0);var T=3;function ue(n){let e=I(n),t=e.focusId;if(!t)return null;if(e.within?.view){let[a]=V(t);if(a)return{at:`screen:${a}`,audience:!0}}return{at:t,audience:!1}}var pe=102,fe=32;function vn(n,e,t){let i=[],a=new Map,d=new Map,c=0;for(let o of n){let r=ue(o.stop),s=r?e(r.at):null;if(!r||!s){o.name&&i.push({kind:"edge",presence:o,point:{x:t-8,y:pe+c++*fe}});continue}if(!o.name){let M=d.get(r.at);d.set(r.at,{n:(M?.n??0)+1,box:s});continue}let f=a.get(r.at)??[];if(f.push(o),a.set(r.at,f),f.length>T)continue;let u=s,l=f.length-1,b=r.audience?{x:u.x+u.width*.5+(l-1)*26,y:u.y+Math.min(u.height,24)}:{x:u.x+u.width*.5-26-l*26,y:u.y+u.height-4};i.push({kind:"person",presence:o,point:b,at:r.at,index:l,of:f.length,audience:r.audience})}for(let[o,r]of a){if(r.length<=T)continue;let s=e(o);s&&i.push({kind:"count",at:o,point:{x:s.x+s.width*.5+2*26+18,y:s.y+s.height-4},n:r.length-T})}for(let[o,{n:r,box:s}]of d)i.push({kind:"count",at:o,point:{x:s.x+s.width*.5+40,y:s.y+s.height-4},n:r});for(let o of n)if(o.name){if(o.robot?.at&&o.robot.mode!=="docked"){let r=e(o.robot.at);r&&i.push({kind:"robot",presence:o,point:{x:r.x+r.width/2+22,y:r.y+r.height-4},mode:o.robot.mode})}if(o.over){let r=e(o.over);r&&i.push({kind:"over",presence:o,box:r})}}return i}export{an as a,O as b,ne as c,te as d,q as e,cn as f,de as g,ln as h,le as i,un as j,pn as k,gn as l,hn as m,we as n,Ye as o,Qe as p,vn as q,U as r,nn as s,tn as t};