graview 0.1.33 → 0.1.35

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 (144) hide show
  1. package/dist/preview/{chunk.CWHRDBOF.js → chunk.2OBIO5Y6.js} +1 -1
  2. package/dist/preview/{chunk.K5ME5GCG.js → chunk.2QQAOJET.js} +1 -1
  3. package/dist/preview/{chunk.4HZ7QTXZ.js → chunk.2YGQVI6T.js} +1 -1
  4. package/dist/preview/{chunk.COQKECUH.js → chunk.3C4RJIJU.js} +1 -1
  5. package/dist/preview/{chunk.TAQ764IQ.js → chunk.3H4NVUWV.js} +1 -1
  6. package/dist/preview/{chunk.UATVTXZY.js → chunk.3P4IIXIT.js} +1 -1
  7. package/dist/preview/chunk.3QXHII5W.js +1 -0
  8. package/dist/preview/chunk.4J75WRDG.js +1 -0
  9. package/dist/preview/{chunk.MAF7C3VM.js → chunk.4K5QCJFH.js} +1 -1
  10. package/dist/preview/chunk.4NZBMZC7.js +117 -0
  11. package/dist/preview/{chunk.ULRW47RP.js → chunk.52QAIGCD.js} +1 -1
  12. package/dist/preview/{chunk.D75KC3LL.js → chunk.577PGFUT.js} +1 -1
  13. package/dist/preview/{chunk.RCKTBOY2.js → chunk.5B7NWF7C.js} +1 -1
  14. package/dist/preview/{chunk.EBGAYL32.js → chunk.5EAQDBBE.js} +1 -1
  15. package/dist/preview/{chunk.XBJYQNVE.js → chunk.5FZQI2US.js} +1 -1
  16. package/dist/preview/chunk.5MCC54VM.js +1 -0
  17. package/dist/preview/{chunk.QVVJRSRM.js → chunk.5VB7DJTL.js} +1 -1
  18. package/dist/preview/chunk.656N5BHG.js +1 -0
  19. package/dist/preview/{chunk.5UL7YDUD.js → chunk.6J7DR7XQ.js} +1 -1
  20. package/dist/preview/{chunk.EF3XNU4O.js → chunk.6K2HASOH.js} +1 -1
  21. package/dist/preview/chunk.6P7P2AW7.js +1 -0
  22. package/dist/preview/chunk.747GGBPR.js +2 -0
  23. package/dist/preview/{chunk.T5VG5A6V.js → chunk.A3F7MFDR.js} +1 -1
  24. package/dist/preview/chunk.AEHPDVLQ.js +1 -0
  25. package/dist/preview/chunk.AINNENYD.js +6 -0
  26. package/dist/preview/{chunk.4HNG4UXT.js → chunk.APNN6BKF.js} +1 -1
  27. package/dist/preview/{chunk.AR3DCDHU.js → chunk.B2KITMSD.js} +1 -1
  28. package/dist/preview/{chunk.5T5XGILP.js → chunk.BGW7XTMH.js} +1 -1
  29. package/dist/preview/chunk.BL6VDLAW.js +1 -0
  30. package/dist/preview/{chunk.XNJEFUF7.js → chunk.CDMV6L5I.js} +1 -1
  31. package/dist/preview/chunk.CHJZ7LST.js +27 -0
  32. package/dist/preview/{chunk.H7EPE74C.js → chunk.D4WQEBWV.js} +1 -1
  33. package/dist/preview/chunk.DLT3EE4D.js +1 -0
  34. package/dist/preview/{chunk.GV2CQVKV.js → chunk.DMNXYMLC.js} +1 -1
  35. package/dist/preview/{chunk.IWQCOGHW.js → chunk.DNDHDDM6.js} +2 -2
  36. package/dist/preview/{chunk.EJPI3ST6.js → chunk.DPP7ITTU.js} +1 -1
  37. package/dist/preview/{chunk.LXBOVRFI.js → chunk.DQ5HAB3N.js} +1 -1
  38. package/dist/preview/chunk.DTR5I4BI.js +1 -0
  39. package/dist/preview/{chunk.MWGGV7DE.js → chunk.DUUARGPE.js} +1 -1
  40. package/dist/preview/{chunk.3TVXGJTU.js → chunk.EAM4NAQH.js} +1 -1
  41. package/dist/preview/{chunk.DYSPCGXX.js → chunk.EQWOQOFJ.js} +1 -1
  42. package/dist/preview/{chunk.FWTIUYXH.js → chunk.FBY5IUGU.js} +1 -1
  43. package/dist/preview/chunk.FHXXYWL3.js +1 -0
  44. package/dist/preview/{chunk.HLTRQU4Y.js → chunk.FIVLFXFB.js} +1 -1
  45. package/dist/preview/{chunk.UGFJKSHU.js → chunk.FSAHO3LV.js} +1 -1
  46. package/dist/preview/{chunk.JQU5GEU3.js → chunk.FUQVNXLB.js} +1 -1
  47. package/dist/preview/{chunk.TMVCTBAD.js → chunk.FVPOSGNG.js} +5 -5
  48. package/dist/preview/{chunk.4MERAWS2.js → chunk.FX6GH57T.js} +1 -1
  49. package/dist/preview/{chunk.CDP2XL66.js → chunk.G2ZPQUXM.js} +1 -1
  50. package/dist/preview/{chunk.CX3KL2C5.js → chunk.GCGITEON.js} +1 -1
  51. package/dist/preview/{chunk.3HXN4BOY.js → chunk.GCVO6N26.js} +1 -1
  52. package/dist/preview/{chunk.3K6YSVHC.js → chunk.GF7LA4QG.js} +1 -1
  53. package/dist/preview/{chunk.CN3UEF5N.js → chunk.GMOTRAKJ.js} +1 -1
  54. package/dist/preview/{chunk.UNL2HIF2.js → chunk.GO4QBFED.js} +1 -1
  55. package/dist/preview/{chunk.UHUGOTUU.js → chunk.H243UV3Z.js} +1 -1
  56. package/dist/preview/{chunk.G5NZVPJU.js → chunk.HPD5ZDZH.js} +1 -1
  57. package/dist/preview/{chunk.3TY5NFLY.js → chunk.IHFNLKXV.js} +1 -1
  58. package/dist/preview/{chunk.RIJUCHP4.js → chunk.IX6RNGAT.js} +1 -1
  59. package/dist/preview/{chunk.PIP6Z563.js → chunk.JAPYJ53U.js} +1 -1
  60. package/dist/preview/{chunk.5H4VXLZF.js → chunk.JLMLKDVX.js} +1 -1
  61. package/dist/preview/chunk.JMQ6YLQX.js +1 -0
  62. package/dist/preview/{chunk.J25KOSNW.js → chunk.KWCML3BF.js} +1 -1
  63. package/dist/preview/{chunk.ASCLIM2P.js → chunk.KYH4QIVI.js} +1 -1
  64. package/dist/preview/{chunk.HAIG6NVX.js → chunk.LAF6GTBN.js} +1 -1
  65. package/dist/preview/{chunk.E2YEOMPH.js → chunk.LIIC25G6.js} +1 -1
  66. package/dist/preview/{chunk.GYICGZMG.js → chunk.LRRVBM4F.js} +2 -2
  67. package/dist/preview/{chunk.I6FPNX43.js → chunk.LWSTEZIP.js} +1 -1
  68. package/dist/preview/chunk.M5HADQPP.js +1 -0
  69. package/dist/preview/{chunk.6UGEYZAC.js → chunk.MVN6H65Q.js} +1 -1
  70. package/dist/preview/chunk.O36ZDLWC.js +1 -0
  71. package/dist/preview/{chunk.GO4XBWJO.js → chunk.OEDCAHII.js} +1 -1
  72. package/dist/preview/{chunk.3NDH3EDN.js → chunk.OZ5KJLA2.js} +1 -1
  73. package/dist/preview/{chunk.QYZNAUIR.js → chunk.PJ2DF6C7.js} +1 -1
  74. package/dist/preview/{chunk.47STJVRV.js → chunk.PKKA6JWA.js} +1 -1
  75. package/dist/preview/{chunk.PBSMLINK.js → chunk.PPUAPAWR.js} +1 -1
  76. package/dist/preview/chunk.PQPTYNW2.js +1 -0
  77. package/dist/preview/{chunk.SYAEBGDC.js → chunk.PW7YH6JV.js} +1 -1
  78. package/dist/preview/{chunk.OC6IWRQ3.js → chunk.Q7TP4RFE.js} +1 -1
  79. package/dist/preview/chunk.QRMWFEEH.js +1 -0
  80. package/dist/preview/{chunk.UZGRRDHD.js → chunk.QU356VB2.js} +1 -1
  81. package/dist/preview/chunk.QVKKXMNK.js +1 -0
  82. package/dist/preview/{chunk.3AGY4QVS.js → chunk.QVUL2FSI.js} +1 -1
  83. package/dist/preview/chunk.RHYA742Q.js +1 -0
  84. package/dist/preview/{chunk.6YCBYL2Y.js → chunk.RIW7SQH4.js} +1 -1
  85. package/dist/preview/{chunk.NTF7FVB2.js → chunk.RTB4MMF6.js} +1 -1
  86. package/dist/preview/{chunk.NRAYZY3X.js → chunk.SBBNIYVB.js} +1 -1
  87. package/dist/preview/{chunk.7GKUVQVF.js → chunk.SD33BD7A.js} +1 -1
  88. package/dist/preview/{chunk.2NIOHEMX.js → chunk.SECORXDP.js} +1 -1
  89. package/dist/preview/{chunk.AOSMJKLH.js → chunk.TIBZZ2WY.js} +1 -1
  90. package/dist/preview/chunk.TPX6AVJL.js +1 -0
  91. package/dist/preview/{chunk.VG3O4LWB.js → chunk.TWWFWHK3.js} +1 -1
  92. package/dist/preview/chunk.U2PYW5MS.js +1 -0
  93. package/dist/preview/{chunk.BNV77BQZ.js → chunk.U5EJSTST.js} +3 -3
  94. package/dist/preview/{chunk.EKPRNDUV.js → chunk.UHQD3NTK.js} +1 -1
  95. package/dist/preview/chunk.UWIYKGYK.js +25 -0
  96. package/dist/preview/{chunk.UBFNZMUX.js → chunk.VMGWYCXU.js} +1 -1
  97. package/dist/preview/{chunk.JDUJDAGA.js → chunk.VWHMYPLL.js} +1 -1
  98. package/dist/preview/{chunk.R6K6GF5R.js → chunk.VZHV25JE.js} +1 -1
  99. package/dist/preview/chunk.WQBDTLPZ.js +1 -0
  100. package/dist/preview/{chunk.MNP4JI33.js → chunk.X7W27IRI.js} +4 -4
  101. package/dist/preview/{chunk.YIR7PPF3.js → chunk.XSYBNUXF.js} +1 -1
  102. package/dist/preview/{chunk.JOOQUWLT.js → chunk.Y5Z4ZDTO.js} +2 -2
  103. package/dist/preview/chunk.YT2CYCVT.js +1 -0
  104. package/dist/preview/{chunk.B2GLDIAS.js → chunk.Z7ZCR4LN.js} +1 -1
  105. package/dist/preview/{chunk.CAVBSL27.js → chunk.ZE4CTZQ3.js} +1 -1
  106. package/dist/preview/chunk.ZFWV4JAJ.js +1 -0
  107. package/dist/preview/chunk.ZHXX22AT.js +3 -0
  108. package/dist/preview/chunk.ZKXK22AH.js +1 -0
  109. package/dist/preview/chunk.ZQNLC33L.js +1 -0
  110. package/dist/preview/{chunk.OKRNJXTV.js → chunk.ZSW74NVJ.js} +1 -1
  111. package/dist/preview/{chunk.7T7NZZTC.js → chunk.ZZTDQKM2.js} +1 -1
  112. package/dist/preview/index.html +42 -42
  113. package/dist/preview/page.js +2 -2
  114. package/package.json +6 -6
  115. package/dist/preview/chunk.26LLZN3C.js +0 -1
  116. package/dist/preview/chunk.2WPZXIRP.js +0 -2
  117. package/dist/preview/chunk.4HRAQNJO.js +0 -27
  118. package/dist/preview/chunk.52W7WYME.js +0 -1
  119. package/dist/preview/chunk.63GXY2ME.js +0 -1
  120. package/dist/preview/chunk.67TPUXAY.js +0 -1
  121. package/dist/preview/chunk.6QWV5MVH.js +0 -25
  122. package/dist/preview/chunk.AKFKM4SW.js +0 -3
  123. package/dist/preview/chunk.BHXGM3PV.js +0 -1
  124. package/dist/preview/chunk.BQ3JHEHV.js +0 -1
  125. package/dist/preview/chunk.CIPS2OGR.js +0 -1
  126. package/dist/preview/chunk.DAZ2VSRD.js +0 -1
  127. package/dist/preview/chunk.ERIT3R6N.js +0 -1
  128. package/dist/preview/chunk.EYTBDMTW.js +0 -1
  129. package/dist/preview/chunk.GBRRGTIH.js +0 -1
  130. package/dist/preview/chunk.H7BST3XO.js +0 -1
  131. package/dist/preview/chunk.IDVAR5HM.js +0 -1
  132. package/dist/preview/chunk.KSES5U5B.js +0 -1
  133. package/dist/preview/chunk.LR3VDXPI.js +0 -1
  134. package/dist/preview/chunk.N6OX4NEQ.js +0 -1
  135. package/dist/preview/chunk.PHKSMUIA.js +0 -1
  136. package/dist/preview/chunk.SHPXD6FC.js +0 -1
  137. package/dist/preview/chunk.SHTJZ6UX.js +0 -1
  138. package/dist/preview/chunk.UVR2Z5ZC.js +0 -1
  139. package/dist/preview/chunk.WAZ7OGBD.js +0 -1
  140. package/dist/preview/chunk.XANVHJQ4.js +0 -1
  141. package/dist/preview/chunk.XKABS745.js +0 -1
  142. package/dist/preview/chunk.XMC7YDWT.js +0 -1
  143. package/dist/preview/chunk.Y2SFUALD.js +0 -117
  144. package/dist/preview/chunk.Y6ZNFQK3.js +0 -6
@@ -1 +1 @@
1
- import{a as y,b as h}from"./chunk.E2YEOMPH.js";import"./chunk.D75KC3LL.js";import"./chunk.FWTIUYXH.js";import"./chunk.MAF7C3VM.js";import{oc as b}from"./chunk.MNP4JI33.js";import"./chunk.AJZBJBMO.js";var k=(d,i)=>({id:i.id,said:h(d,i),when:i.when,...i.alsoMine?{alsoMine:!0}:{}});async function A(d,i,t){let a=b(t.principal);if(a.id===void 0)return{ok:!1,error:"This seat acts for nobody the app knows by id, so there is nobody to tell. Nothing was kept."};let r=t.store.seenBy(a),p=async()=>(await t.subscriptions.list(a.id)).filter(n=>n.app===t.app);if(d==="list_subscriptions")return{ok:!0,data:{subscriptions:(await p()).map(n=>k(r,n))}};if(d==="unsubscribe"){let n=String(i.id??"");return(await p()).some(g=>g.id===n)?(await t.subscriptions.remove(n),{ok:!0,data:{removed:n}}):{ok:!1,error:`No subscription "${n}" of yours. list_subscriptions says which there are.`}}let o=String(i.on??""),c=n=>typeof i[n]=="string"&&i[n].trim()!==""?i[n].trim():void 0,e=c("record");if(e!==void 0&&!r.graph.getNode(e)){let n=t.store.resolveRef({name:"record",kinds:["*"]},e,a);if(!n.ok)return{ok:!1,error:`${n.message} Nothing was kept.`};e=n.id}let s=c("kind")??(e!==void 0&&o!=="act"?r.graph.getNode(e)?.kind:void 0),f=c("act"),m=c("condition"),u=o==="act"?{on:o,...f!==void 0?{act:f}:{},...e!==void 0?{record:e}:{}}:o==="created"&&s!==void 0?{on:o,kind:s}:o==="changed"?{on:o,...s!==void 0&&e===void 0?{kind:s}:{},...e!==void 0?{record:e}:{}}:o==="reaches"&&s!==void 0?{on:o,kind:s,condition:m??"",...e!==void 0?{record:e}:{}}:void 0;if(!u)return{ok:!1,error:'Say what to be told of: on is "act", "created", "changed" or "reaches", with a kind (or a record) for all but act. Nothing was kept.'};let l=y({schema:r.schema,allMutations:()=>t.store.allMutations(),graph:r.graph},u);if(l)return{ok:!1,error:`${l} Nothing was kept.`};let S=await t.subscriptions.add({who:a,app:t.app,when:u,...i.alsoMine===!0?{alsoMine:!0}:{}});return{ok:!0,data:{subscription:k(r,S)}}}export{A as runSubscriptionTool};
1
+ import{a as y,b as h}from"./chunk.LIIC25G6.js";import"./chunk.577PGFUT.js";import"./chunk.FBY5IUGU.js";import"./chunk.4K5QCJFH.js";import{pc as b}from"./chunk.X7W27IRI.js";import"./chunk.AJZBJBMO.js";var k=(d,i)=>({id:i.id,said:h(d,i),when:i.when,...i.alsoMine?{alsoMine:!0}:{}});async function A(d,i,t){let a=b(t.principal);if(a.id===void 0)return{ok:!1,error:"This seat acts for nobody the app knows by id, so there is nobody to tell. Nothing was kept."};let r=t.store.seenBy(a),p=async()=>(await t.subscriptions.list(a.id)).filter(n=>n.app===t.app);if(d==="list_subscriptions")return{ok:!0,data:{subscriptions:(await p()).map(n=>k(r,n))}};if(d==="unsubscribe"){let n=String(i.id??"");return(await p()).some(g=>g.id===n)?(await t.subscriptions.remove(n),{ok:!0,data:{removed:n}}):{ok:!1,error:`No subscription "${n}" of yours. list_subscriptions says which there are.`}}let o=String(i.on??""),c=n=>typeof i[n]=="string"&&i[n].trim()!==""?i[n].trim():void 0,e=c("record");if(e!==void 0&&!r.graph.getNode(e)){let n=t.store.resolveRef({name:"record",kinds:["*"]},e,a);if(!n.ok)return{ok:!1,error:`${n.message} Nothing was kept.`};e=n.id}let s=c("kind")??(e!==void 0&&o!=="act"?r.graph.getNode(e)?.kind:void 0),f=c("act"),m=c("condition"),u=o==="act"?{on:o,...f!==void 0?{act:f}:{},...e!==void 0?{record:e}:{}}:o==="created"&&s!==void 0?{on:o,kind:s}:o==="changed"?{on:o,...s!==void 0&&e===void 0?{kind:s}:{},...e!==void 0?{record:e}:{}}:o==="reaches"&&s!==void 0?{on:o,kind:s,condition:m??"",...e!==void 0?{record:e}:{}}:void 0;if(!u)return{ok:!1,error:'Say what to be told of: on is "act", "created", "changed" or "reaches", with a kind (or a record) for all but act. Nothing was kept.'};let l=y({schema:r.schema,allMutations:()=>t.store.allMutations(),graph:r.graph},u);if(l)return{ok:!1,error:`${l} Nothing was kept.`};let S=await t.subscriptions.add({who:a,app:t.app,when:u,...i.alsoMine===!0?{alsoMine:!0}:{}});return{ok:!0,data:{subscription:k(r,S)}}}export{A as runSubscriptionTool};
@@ -0,0 +1,25 @@
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{Aa as Pn,Gc as _n,I as kn,La as Rn,Lb as Tn,Uc as Vn,Zc as De,_c as lt,fc as Mn,qc as On,sc as In,ua as An,vc as Cn,ya as st}from"./chunk.X7W27IRI.js";import{a as He,b as D}from"./chunk.AJZBJBMO.js";var to=He(v=>{"use strict";var mt=Symbol.for("react.transitional.element"),mr=Symbol.for("react.portal"),gr=Symbol.for("react.fragment"),hr=Symbol.for("react.strict_mode"),Sr=Symbol.for("react.profiler"),wr=Symbol.for("react.consumer"),vr=Symbol.for("react.context"),br=Symbol.for("react.forward_ref"),xr=Symbol.for("react.suspense"),Er=Symbol.for("react.memo"),Yn=Symbol.for("react.lazy"),kr=Symbol.for("react.activity"),$n=Symbol.iterator;function Ar(e){return e===null||typeof e!="object"?null:(e=$n&&e[$n]||e["@@iterator"],typeof e=="function"?e:null)}var Xn={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Jn=Object.assign,Zn={};function ye(e,t,n){this.props=e,this.context=t,this.refs=Zn,this.updater=n||Xn}ye.prototype.isReactComponent={};ye.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};ye.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Qn(){}Qn.prototype=ye.prototype;function gt(e,t,n){this.props=e,this.context=t,this.refs=Zn,this.updater=n||Xn}var ht=gt.prototype=new Qn;ht.constructor=gt;Jn(ht,ye.prototype);ht.isPureReactComponent=!0;var qn=Array.isArray;function yt(){}var O={H:null,A:null,T:null,S:null},eo=Object.prototype.hasOwnProperty;function St(e,t,n){var o=n.ref;return{$$typeof:mt,type:e,key:t,ref:o!==void 0?o:null,props:n}}function Pr(e,t){return St(e.type,t,e.props)}function wt(e){return typeof e=="object"&&e!==null&&e.$$typeof===mt}function Rr(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var zn=/\/+/g;function pt(e,t){return typeof e=="object"&&e!==null&&e.key!=null?Rr(""+e.key):t.toString(36)}function Tr(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch(typeof e.status=="string"?e.then(yt,yt):(e.status="pending",e.then(function(t){e.status==="pending"&&(e.status="fulfilled",e.value=t)},function(t){e.status==="pending"&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}function pe(e,t,n,o,r){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var a=!1;if(e===null)a=!0;else switch(i){case"bigint":case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case mt:case mr:a=!0;break;case Yn:return a=e._init,pe(a(e._payload),t,n,o,r)}}if(a)return r=r(e),a=o===""?"."+pt(e,0):o,qn(r)?(n="",a!=null&&(n=a.replace(zn,"$&/")+"/"),pe(r,t,n,"",function(u){return u})):r!=null&&(wt(r)&&(r=Pr(r,n+(r.key==null||e&&e.key===r.key?"":(""+r.key).replace(zn,"$&/")+"/")+a)),t.push(r)),1;a=0;var d=o===""?".":o+":";if(qn(e))for(var s=0;s<e.length;s++)o=e[s],i=d+pt(o,s),a+=pe(o,t,n,i,r);else if(s=Ar(e),typeof s=="function")for(e=s.call(e),s=0;!(o=e.next()).done;)o=o.value,i=d+pt(o,s++),a+=pe(o,t,n,i,r);else if(i==="object"){if(typeof e.then=="function")return pe(Tr(e),t,n,o,r);throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.")}return a}function $e(e,t,n){if(e==null)return e;var o=[],r=0;return pe(e,o,"","",function(i){return t.call(n,i,r++)}),o}function Mr(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var Un=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Or={map:$e,forEach:function(e,t,n){$e(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return $e(e,function(){t++}),t},toArray:function(e){return $e(e,function(t){return t})||[]},only:function(e){if(!wt(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};v.Activity=kr;v.Children=Or;v.Component=ye;v.Fragment=gr;v.Profiler=Sr;v.PureComponent=gt;v.StrictMode=hr;v.Suspense=xr;v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=O;v.__COMPILER_RUNTIME={__proto__:null,c:function(e){return O.H.useMemoCache(e)}};v.cache=function(e){return function(){return e.apply(null,arguments)}};v.cacheSignal=function(){return null};v.cloneElement=function(e,t,n){if(e==null)throw Error("The argument must be a React element, but you passed "+e+".");var o=Jn({},e.props),r=e.key;if(t!=null)for(i in t.key!==void 0&&(r=""+t.key),t)!eo.call(t,i)||i==="key"||i==="__self"||i==="__source"||i==="ref"&&t.ref===void 0||(o[i]=t[i]);var i=arguments.length-2;if(i===1)o.children=n;else if(1<i){for(var a=Array(i),d=0;d<i;d++)a[d]=arguments[d+2];o.children=a}return St(e.type,r,o)};v.createContext=function(e){return e={$$typeof:vr,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:wr,_context:e},e};v.createElement=function(e,t,n){var o,r={},i=null;if(t!=null)for(o in t.key!==void 0&&(i=""+t.key),t)eo.call(t,o)&&o!=="key"&&o!=="__self"&&o!=="__source"&&(r[o]=t[o]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var d=Array(a),s=0;s<a;s++)d[s]=arguments[s+2];r.children=d}if(e&&e.defaultProps)for(o in a=e.defaultProps,a)r[o]===void 0&&(r[o]=a[o]);return St(e,i,r)};v.createRef=function(){return{current:null}};v.forwardRef=function(e){return{$$typeof:br,render:e}};v.isValidElement=wt;v.lazy=function(e){return{$$typeof:Yn,_payload:{_status:-1,_result:e},_init:Mr}};v.memo=function(e,t){return{$$typeof:Er,type:e,compare:t===void 0?null:t}};v.startTransition=function(e){var t=O.T,n={};O.T=n;try{var o=e(),r=O.S;r!==null&&r(n,o),typeof o=="object"&&o!==null&&typeof o.then=="function"&&o.then(yt,Un)}catch(i){Un(i)}finally{t!==null&&n.types!==null&&(t.types=n.types),O.T=t}};v.unstable_useCacheRefresh=function(){return O.H.useCacheRefresh()};v.use=function(e){return O.H.use(e)};v.useActionState=function(e,t,n){return O.H.useActionState(e,t,n)};v.useCallback=function(e,t){return O.H.useCallback(e,t)};v.useContext=function(e){return O.H.useContext(e)};v.useDebugValue=function(){};v.useDeferredValue=function(e,t){return O.H.useDeferredValue(e,t)};v.useEffect=function(e,t){return O.H.useEffect(e,t)};v.useEffectEvent=function(e){return O.H.useEffectEvent(e)};v.useId=function(){return O.H.useId()};v.useImperativeHandle=function(e,t,n){return O.H.useImperativeHandle(e,t,n)};v.useInsertionEffect=function(e,t){return O.H.useInsertionEffect(e,t)};v.useLayoutEffect=function(e,t){return O.H.useLayoutEffect(e,t)};v.useMemo=function(e,t){return O.H.useMemo(e,t)};v.useOptimistic=function(e,t){return O.H.useOptimistic(e,t)};v.useReducer=function(e,t,n){return O.H.useReducer(e,t,n)};v.useRef=function(e){return O.H.useRef(e)};v.useState=function(e){return O.H.useState(e)};v.useSyncExternalStore=function(e,t,n){return O.H.useSyncExternalStore(e,t,n)};v.useTransition=function(){return O.H.useTransition()};v.version="19.2.8"});var W=He((ra,no)=>{"use strict";no.exports=to()});var fo=He(Ue=>{"use strict";var Wr=Symbol.for("react.transitional.element"),Fr=Symbol.for("react.fragment");function co(e,t,n){var o=null;if(n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),"key"in t){n={};for(var r in t)r!=="key"&&(n[r]=t[r])}else n=t;return t=n.ref,{$$typeof:Wr,type:e,key:o,ref:t!==void 0?t:null,props:n}}Ue.Fragment=Fr;Ue.jsx=co;Ue.jsxs=co});var Ie=He((fa,po)=>{"use strict";po.exports=fo()});function Hn(e){let t,n=!1,o,r,i=0;return()=>{if(n)return Promise.resolve(t);if(o)return o;let a=i>0&&r!==void 0?dr(r):e();i+=1;let d=a.then(s=>(t=s,n=!0,o=void 0,s),s=>{throw o=void 0,r??=ur(s),s});return o=d,d}}var Ln=0;function dr(e){return Ln+=1,import(`${e}${e.includes("?")?"&":"?"}retry=${Ln}`)}function ur(e,t=import.meta.url){let n=e instanceof Error?e.message:typeof e=="string"?e:"",o=/^(?:Failed to fetch|error loading) dynamically imported module: ([a-z]+:\/\/[^\s"'<>]+)/.exec(n)?.[1]?.replace(/[.,;:)\]]+$/,""),r=i=>i.split("/",3).join("/");return o&&r(o)===r(t)?o:void 0}var ue={focusId:null,relation:null,expanded:[],pins:{}},Ne=e=>{let t=Number(e);return Number.isFinite(t)?t:null};function ee(e){let t=new URLSearchParams;e.focusId&&t.set("focus",e.focusId),e.relation&&t.set("relation",e.relation),e.overview&&t.set("overview","1"),e.zoom&&t.set("zoom","1"),e.past&&t.set("past","1"),e.shown&&e.shown.length>0&&t.set("show",[...e.shown].sort().join(",")),e.selection!==void 0&&e.selection.length>0&&t.set("sel",[...e.selection].sort().join(",")),e.expanded.length>0&&t.set("expand",[...e.expanded].sort().join(","));for(let o of Object.keys(e.pins).sort()){let r=e.pins[o];t.set(`pin.${o}`,`${je(r.x)},${je(r.y)}`)}e.pan&&(e.pan.x!==0||e.pan.y!==0)&&t.set("pan",`${je(e.pan.x)},${je(e.pan.y)}`);for(let o of Object.keys(e.within??{}).sort()){let r=e.within[o];r.length>0&&t.set(`in.${o}`,r)}e.q&&e.q.trim().length>0&&t.set("q",e.q);let n=t.toString();return n?`#${n}`:"#"}function cr(e){return e&&e.startsWith("agg:")?`aggregate:${e.slice(4)}`:e}function Ge(e){let t=e.includes("#")?e.slice(e.indexOf("#")+1):e,n=new URLSearchParams(t),o=Object.create(null);for(let[h,p]of n){if(!h.startsWith("pin."))continue;let[g,b]=p.split(","),k=g===void 0?null:Ne(g),m=b===void 0?null:Ne(b);k===null||m===null||(o[h.slice(4)]={x:k,y:m})}let r=Object.create(null);for(let[h,p]of n)!h.startsWith("in.")||p.length===0||(r[h.slice(3)]=p);let i=n.get("view");i&&i.length>0&&r.view===void 0&&(r.view=i);let a=n.get("pan")?.split(",")??[],d=a[0]===void 0?null:Ne(a[0]),s=a[1]===void 0?null:Ne(a[1]),u=(n.get("sel")??"").split(",").filter(h=>h.length>0).sort(),f=n.get("overview")==="1";return{...u.length>0?{selection:u}:{},...f?{overview:!0}:{},...n.get("zoom")==="1"?{zoom:!0}:{},...n.get("past")==="1"?{past:!0}:{},...n.get("show")?{shown:[...new Set(n.get("show").split(",").filter(Boolean))].sort()}:{},...d!==null&&s!==null?{pan:{x:d,y:s}}:{},...Object.keys(r).length>0?{within:r}:{},...n.get("q")?.trim()?{q:n.get("q")}:{},focusId:cr(n.get("focus")),relation:n.get("relation"),expanded:(n.get("expand")??"").split(",").filter(h=>h.length>0&&(f||!h.startsWith("kind:"))).sort(),pins:o}}function Wi(e){let t=Ge(e);return ee(t)==="#"?{...t,overview:!0}:t}function Fi(e){let t=ee(e);return t==="#overview=1"?"":t}function je(e){return Math.round(e*100)/100}function Nn(e,t){return ee(e)===ee(t)}var Dn="edge:";function jn(e){if(!e.startsWith(Dn))return null;let t=e.slice(Dn.length).split(":");if(t.length!==3)return null;let[n,o,r]=t;if(!n||!o||!r)return null;try{return{kind:decodeURIComponent(n),from:decodeURIComponent(o),to:decodeURIComponent(r)}}catch{return null}}function dt(e){let{pan:t,...n}=e;return{...n,pins:{}}}function q(e,t){if(t===e.focusId)return{...e,focusId:t};let n=dt(e);return{...n.within?.q!==void 0?ae(n,"q",null):n,focusId:t}}function Gn(e,t){return{...e,relation:t}}function ae(e,t,n){let o={...e.within??{}};if(n===null?delete o[t]:o[t]=n,Object.keys(o).length===0){let{within:r,...i}=e;return i}return{...e,within:o}}function ce(e,t){if(t!==e.overview&&(e=dt(e)),!t){let n=e.expanded.filter(o=>!o.startsWith("kind:"));return{...e,overview:!1,expanded:n}}return{...e,overview:t}}function We(e,t){if(t.length===0){let{selection:n,...o}=e;return o}return{...e,selection:[...t]}}function Me(e,t){if(t!==(e.zoom===!0)&&(e=dt(e)),!t){let{zoom:n,...o}=e;return o}return{...e,zoom:!0}}function Fe(e,t){let n=new Set(e.expanded);return n.has(t)?n.delete(t):n.add(t),{...e,expanded:[...n].sort()}}var Be="aggregate:",Ke="kind:";function ut(e){return`${Ke}${e}`}function fe(e){return e.startsWith(Ke)?e.slice(Ke.length):null}var $i="kinds:beyond";function fr(e){let t=fe(e);return t?[t]:se(e)}function te(...e){return`${Be}${[...e].sort().join("+")}`}function Wn(e){return e.startsWith(Be)}function se(e){return!Wn(e)||e.includes("|")?[]:e.slice(Be.length).split("+").filter(Boolean)}function Fn(e,t,n={}){let o=fe(t);if(o!==null&&e.overview&&n.ownPicture!==!0)return Fe(e,t);let r=o!==null?te(o):t;if(e.zoom&&e.focusId===r&&!(o!==null&&n.carry))return Me(e,!1);if(o!==null&&n.carry){let i=ce({...q(e,r),relation:null},!1);return ae(Me(i,!0),"q",n.carry)}return Me({...q(e,r),relation:null},!0)}function pr(e,t,n){return ae(ce(q(e,te(t)),!1),"view",n)}function qi(e,t){return e.id<t.id?-1:e.id>t.id?1:0}var Kn="aggregate:";function ct(e){return e.startsWith(Kn)&&e.includes("|")}var Bn=e=>e?.off===!0,yr=e=>e!==void 0&&!Bn(e)&&(e.fast!==void 0||e.thinking!==void 0||e.answer!==void 0||e.decide!==void 0||e.complete!==void 0||e.turn!==void 0),ft={};var oo=D(W(),1),Ir={turns:[],outcomes:new Map,busy:!1,pending:null,draft:null,draftNote:null},ro=e=>`graview:seat:${e}`;function Cr(e){if(!e)return{};try{let t=sessionStorage.getItem(e);if(!t)return{};let n=JSON.parse(t);return{...Array.isArray(n.turns)?{turns:n.turns}:{},...Array.isArray(n.outcomes)?{outcomes:new Map(n.outcomes)}:{},...n.draft?.drawn?{draft:n.draft}:{}}}catch{return{}}}function _r(e,t){if(e)try{sessionStorage.setItem(e,JSON.stringify({turns:t.turns.slice(-40),outcomes:[...t.outcomes],draft:t.draft}))}catch{}}function vt(e){let t=e===null?null:ro(e),n={...Ir,...Cr(t)},o=new Set,r=(i,a=!0)=>{n=i,a&&_r(t,n);for(let d of[...o])d()};return{get:()=>n,subscribe(i){return o.add(i),()=>void o.delete(i)},setTurns:i=>r({...n,turns:i(n.turns)}),settle:(i,a)=>r({...n,outcomes:new Map(n.outcomes).set(i,a)}),setBusy:i=>r({...n,busy:i},!1),ask:i=>r({...n,pending:i.trim()||null}),takePending(){let i=n.pending;return i!==null&&r({...n,pending:null},!1),i},setDraft:(i,a=null)=>r({...n,draft:i,draftNote:a})}}function Vr(e){return(0,oo.useSyncExternalStore)(e.subscribe,e.get,e.get)}var ao=D(W(),1),Lr={entries:[],ghost:null,loaded:!1};function io(e,t){let n=new Map(e.map(o=>[o.id,o]));for(let o of t)n.set(o.id,{...n.get(o.id),...o});return[...n.values()].sort((o,r)=>o.at<r.at?1:o.at>r.at?-1:0)}function bt(e){let t=Lr,n=new Set,o=r=>{t=r;for(let i of[...n])i()};return{get:()=>t,subscribe:r=>(n.add(r),()=>n.delete(r)),record:r=>{o({...t,entries:io(t.entries,[r])}),Promise.resolve(e()?.keep?.(r)).catch(i=>{console.warn("The host did not keep an AI interaction:",i)})},setGhost:r=>o({...t,ghost:r}),load:()=>{if(t.loaded)return;o({...t,loaded:!0});let r=e()?.load;r&&Promise.resolve(r()).then(i=>o({...t,entries:io(t.entries,i)})).catch(i=>{console.warn("The host's AI interactions could not be read:",i)})}}}function Hr(e){return(0,ao.useSyncExternalStore)(e.subscribe,e.get,e.get)}function so(e){return e?.closest?.("[data-graview-pick]")?.getAttribute("data-graview-pick")??null}var qe=D(W(),1),ze=(0,qe.createContext)(void 0),Dr=()=>(0,qe.useContext)(ze);var A=D(W(),1),Oe=(0,A.createContext)(null);function uo(){return(0,A.useContext)(Oe)}function Nr(e,t){let n=uo(),o=(0,A.useMemo)(()=>n?n.live.seenBy(t):e,[n,e,t]),r=(0,A.useRef)(0),i=(0,A.useCallback)(a=>o.subscribe(()=>{r.current+=1,a()}),[o]);return(0,A.useSyncExternalStore)(i,()=>r.current,()=>0),o}var jr=Hn(()=>(__graviewPreload(import.meta.url,["./chunk.TI4OSTQV.js","./chunk.AJZBJBMO.js"]),import("./chunk.WQBDTLPZ.js"))),lo,Gr=400;function xt(e,t,n){let o=(0,A.useContext)(Oe),r=o!==null&&o.owns(e,t),[i,a]=(0,A.useState)(null),[d,s]=(0,A.useState)(lo);(0,A.useEffect)(()=>{if(d||r||i===null)return;let E=!0;return jr().then(R=>{lo=R,E&&s(R)},()=>{}),()=>{E=!1}},[d,r,i]);let[u,f]=(0,A.useState)(0),h=(0,A.useMemo)(()=>r||i===null||i>=e.log.length||!d?void 0:d.askDeclaration(n,i),[r,e,i,n,d,u]),p=h&&"waiting"in h?h.waiting:void 0,[g,b]=(0,A.useState)(void 0);(0,A.useEffect)(()=>{if(!p)return;let E=!0,R=setTimeout(()=>E&&b(p),Gr);return p.then(()=>E&&f(_=>_+1)),()=>{E=!1,clearTimeout(R)}},[p]);let k=p!==void 0&&g!==p,m=(0,A.useMemo)(()=>{if(r||i===null||i>=e.log.length||!d||k)return null;try{let E=d.pastAt(e,i,n);return{seq:i,at:E.past?.at,store:E}}catch{return null}},[r,e,i,n,d,k,u]),w=(0,A.useRef)(null),y=k?w.current:m;(0,A.useEffect)(()=>{w.current=y},[y]);let x=(0,A.useCallback)(E=>a(E===null?null:E>=e.log.length?Number.POSITIVE_INFINITY:E),[e]),P=(0,A.useCallback)((E,R)=>[e,y?.store].some(_=>_!==void 0&&(_===E||_.seenBy(R)===E)),[e,y]),G=i!==null,I=(0,A.useMemo)(()=>({past:y,open:G,show:x,live:e,host:n,owns:P}),[y,G,x,e,n,P]);return r?o:I}var yo=e=>`graview:setting:${e}`;function mo(){return localStorage}function go(e,t){try{let n=(t??mo()).getItem(yo(e.name));if(n!==null&&e.options.some(o=>o.value===n))return n}catch{}return e.initial}function ho(e,t,n){try{(n??mo()).setItem(yo(e.name),t)}catch{}}function So(e,t){if(typeof document>"u")return;let n=document.documentElement;if(e.honored==="root-font-size"){n.style.fontSize=t===e.initial?"":t;return}let o=`graview${e.name.replace(/-([a-z0-9])/g,(r,i)=>i.toUpperCase()).replace(/^[a-z]/,r=>r.toUpperCase())}`;t===e.initial?delete n.dataset[o]:n.dataset[o]=t}var L=D(W(),1);function Et(e){return De(e)}var Kr=12,Br=4;function $r(e,t,n){let o=Et(t);return e.get(o)??{participant:o,who:t.id??t.kind,at:null,mode:"docked",since:n,trail:[]}}var Ye=(e,t)=>t===null||e[e.length-1]===t?e:[...e,t].slice(-Kr);function wo(e,t){let n=e.filter(r=>r.length>0);if(n.length===0)return null;if(n.length<=Br)return n[0];let o=new Set(n.map(r=>t(r)).filter(r=>r!==void 0));return o.size===1?ut([...o][0]):n[0]}function kt(e,t,n){let o=new Map(e);if(t.type==="rest"){for(let[a,d]of e)d.mode!=="asking"&&d.mode!=="docked"&&t.at-d.since>=t.holdMs&&o.set(a,{...d,mode:"docked",at:null,trail:[],say:void 0,confidence:void 0});return o}if(t.author.kind!=="agent")return o;let r=$r(e,t.author,t.at),i=a=>o.set(r.participant,{...r,...a,since:t.at});switch(t.type){case"read":{let a=wo(t.ids,n);return i({at:a,mode:"reading",trail:Ye(r.trail,a)}),o}case"about-to-write":case"write":{let a=wo(t.ids,n);return i({at:a,mode:"writing",trail:Ye(r.trail,a),say:void 0,confidence:void 0}),o}case"refused":return i({at:t.where,mode:"refused",say:t.say,confidence:void 0,trail:Ye(r.trail,t.where)}),o;case"asking":return i({at:t.where??r.at,mode:"asking",say:t.say,...t.confidence!==void 0?{confidence:t.confidence}:{confidence:void 0},trail:Ye(r.trail,t.where)}),o;case"said":return i({say:t.say,...t.confidence!==void 0?{confidence:t.confidence}:{confidence:void 0},...t.caption?{caption:t.caption}:{}}),o;case"over":return i({over:t.over}),o;case"home":return i({at:null,mode:"docked",trail:[],say:void 0,confidence:void 0,over:null}),o;default:return o}}var vo="graview:session";function bo(e){let t=()=>typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID().slice(0,8):Math.random().toString(36).slice(2,10);try{let n=e??sessionStorage,o=n.getItem(vo);if(o)return o;let r=t();return n.setItem(vo,r),r}catch{return t()}}var At={name:"share-where",title:"Where you are",description:"Whether the others here see which stop you are on.",honored:"root-attribute",options:[{value:"shared",label:"Shown"},{value:"private",label:"Hidden"}],initial:"shared"},Pt={name:"share-over",title:"What you point at",description:"Whether the others see the thing under your pointer, outlined in your color.",honored:"root-attribute",options:[{value:"private",label:"Kept to yourself"},{value:"shared",label:"Outlined for others"}],initial:"private"},xo=[At,Pt],zr=800;function Eo(e){let{channel:t,store:n,view:o,principal:r,session:i,robots:a,seatWho:d,settingValues:s,setView:u,ttlMs:f=1e4,people:h,seats:p}=e,[g,b]=(0,L.useState)(()=>new Map),[k,m]=(0,L.useState)(null),[w,y]=(0,L.useState)(null),[x,P]=(0,L.useState)(null),G=typeof r.id=="string"&&r.id.length>0,I=G&&(s[At.name]??At.initial)==="shared",E=I&&(s[Pt.name]??Pt.initial)==="shared",R=Et({kind:r.kind,...r.id?{id:r.id}:{},session:i}),_=G?Rn(r,{graph:n.graph,schema:n.schema,...p?{seats:p}:{},...h?{people:h}:{}}):"",C=d?a.get(`agent:${d}:${i}`):void 0,N=(0,L.useMemo)(()=>!t||!I?null:{participant:R,kind:r.kind,name:_,...r.onBehalfOf?.id?{onBehalfOf:r.onBehalfOf.id,...r.onBehalfOf.name?{onBehalfOfName:r.onBehalfOf.name}:{}}:{},hue:Tn(r.id??"nobody"),stop:x??ee(o),...E?{over:k}:{},...C?{robot:{at:C.at,mode:C.mode}}:{},at:new Date().toISOString()},[t,I,E,R,_,r.id,r.kind,r.onBehalfOf?.id,r.onBehalfOf?.name,o,x,k,C?.at,C?.mode]);(0,L.useEffect)(()=>{if(!t||!N)return;t.here(N);let V=setInterval(()=>t.here({...N,at:new Date().toISOString()}),zr);return()=>clearInterval(V)},[t,N]),(0,L.useEffect)(()=>t?t.onWho(K=>b(lt(new Map,K,Date.now(),f))):void 0,[t,f]);let ve=g.size>0;(0,L.useEffect)(()=>{if(!ve)return;let V=setInterval(()=>{b(K=>{let B=lt(K,[],Date.now(),f);return B.size===K.size?K:B})},Math.max(250,Math.min(1e3,f/4)));return()=>clearInterval(V)},[ve,f]),(0,L.useEffect)(()=>{if(!t||typeof window>"u")return;let V=()=>t.leave();return window.addEventListener("pagehide",V),()=>window.removeEventListener("pagehide",V)},[t]),(0,L.useEffect)(()=>{if(!E||typeof document>"u")return;let V=null,K=B=>{let J=so(B.target);J!==V&&(V=J,m(J))};return document.addEventListener("pointermove",K,{passive:!0}),()=>document.removeEventListener("pointermove",K)},[E]);let oe=(0,L.useRef)(null),z=w?g.get(w)??null:null,be=(0,L.useCallback)(V=>{oe.current=null,y(V)},[]);return(0,L.useEffect)(()=>{if(w){if(!z){y(null);return}z.stop!==oe.current?.stop&&(oe.current={stop:z.stop,at:Date.now()},u(Ge(z.stop)))}},[w,z,u]),(0,L.useEffect)(()=>{let V=oe.current;!w||V===null||Date.now()-V.at<400||Nn(o,Ge(V.stop))||y(null)},[o,w]),(0,L.useEffect)(()=>{if(!w||typeof document>"u")return;let V=K=>{K.key==="Escape"&&y(null)};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[w]),(0,L.useMemo)(()=>({who:g,sharing:N?{participant:R,name:_}:null,following:z,follow:be,sayWhere:P}),[g,N,R,_,z,be])}var Y=D(W(),1);function ko(e){return De(e.author)}function Ur(e,t){return e.length>1?"co-edited":t==="rule"?"rule":t==="agent"?"autonomous":"directed"}function Ao(e,t,n,o,r){let i=new Map;for(let[s,u]of e)o-u.at<r&&i.set(s,u);let a=new Set(n.flatMap(s=>s.nodeIds)),d=(s,u,f)=>{let h=i.get(s),p=h?.participants.includes(ko(u))?h.participants:[...h?.participants??[],ko(u)];i.set(s,{at:o,manner:Ur(p,u.author.kind),intent:u.intent,wrote:(h?.wrote??!1)||(f.wrote??!1),read:(h?.read??!1)||(f.read??!1),broke:(h?.broke??!1)||a.has(s),participants:p})};for(let s of t){for(let u of s.writes)d(u,s,{wrote:!0});for(let u of s.reads)s.writes.includes(u)||d(u,s,{read:!0})}for(let s of n)for(let u of s.nodeIds){let f=i.get(u);i.set(u,{at:o,manner:f?.manner??"rule",intent:f?.intent??s.message,wrote:f?.wrote??!1,read:f?.read??!1,broke:!0,participants:f?.participants??["rule::"]})}return i}var Yr=2600;function Po(e,t=Yr){let[n,o]=(0,Y.useState)(()=>new Map),r=(0,Y.useRef)(n);r.current=n;let i=(0,Y.useRef)(null),a=(0,Y.useCallback)(s=>{r.current=s,o(s),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{r.current=new Map,o(new Map)},t)},[t]);(0,Y.useEffect)(()=>{let s=e.violations(),u=e.subscribe((f,h)=>{let p=e.violations(),g=Cn(e.allInvariants(),s,p).introduces;s=p,a(Ao(r.current,h,g.map(b=>({nodeIds:b.nodeIds,message:b.message})),Date.now(),t))});return()=>{u(),i.current&&clearTimeout(i.current)}},[e,t,a]);let d=(0,Y.useCallback)(s=>{s.reads.length!==0&&a(Ao(r.current,[Xr(s)],[],Date.now(),t))},[t,a]);return{activity:n,noteAttention:d}}function Xr(e){return{id:`attention:${e.intent}`,seq:-1,batch:"attention",author:e.author,intent:e.intent,mutation:null,primitives:[],inverse:[],reads:e.reads,writes:[],at:new Date().toISOString()}}var l=D(W(),1);function Ro(){let e=null,t=new Set,n=new Set,o=r=>{for(let i of n)i(r)};return{subscribe(r){return t.add(r),t.size===1&&o(!0),()=>{t.delete(r),t.size===0&&(e=null,o(!1))}},snapshot:()=>e,set(r){if(!(e===r||e&&r&&e.x===r.x&&e.y===r.y)){e=r;for(let i of t)i()}},get listeners(){return t.size},onActive(r){return n.add(r),()=>void n.delete(r)}}}var Xe=D(W(),1),Jr=e=>e.definitions.some(t=>An(t).size>0);function To(e,t,n){let[o,r]=(0,Xe.useState)(void 0),i=(n.roles??[]).join("\0");return(0,Xe.useEffect)(()=>{if(!t||!Jr(e.schema)){r(void 0);return}let a=!0,d=!1,s=e.graph,u=()=>{d||(d=!0,queueMicrotask(()=>{d=!1,a&&e.reread()}))},f=Pn(t,{kind:n.kind,...n.id===void 0?{}:{id:n.id},...n.roles?{roles:n.roles}:{}},u);return st(s,f.read),r(f),e.reread(),()=>{a=!1,st(s,void 0)}},[e,t,n.kind,n.id,i]),o}function Mo(){let e=!1,t=new Set;return{moving:()=>e,set(n){if(n!==e){e=n;for(let o of t)o()}},subscribe(n){return t.add(n),()=>t.delete(n)}}}var le=D(Ie(),1),Ce=(0,l.createContext)(null),_o=(0,l.createContext)("scene");function Zr({mode:e,children:t}){return(0,le.jsx)(_o.Provider,{value:e,children:t})}function Qr(){return(0,l.useContext)(_o)}var Vo={kind:"human"},ei=[],ti=[],ni=[],Rt=[];function Lo(e,t){let n=(0,l.useId)();(0,l.useEffect)(()=>{if(!globalThis.__graviewWatch)return;let o=t??Vo,r=()=>In(e,o,n);r();let i,a=e.subscribe(()=>{clearTimeout(i),i=setTimeout(r,250)});return()=>{clearTimeout(i),a(),globalThis.__graviewWatch?.unseen?.({words:[],from:n,gone:!0})}},[e,t,n])}var oi={off:!0};function ri({store:e,views:t,initialView:n,scheme:o="dark",initialSelection:r,principal:i,seats:a=ei,onSeat:d,people:s=ti,memory:u,presenceTtlMs:f,app:h,settings:p=h?.settings??ni,presence:g,brand:b,locale:k,onKeepLens:m,providers:w,ai:y,files:x,resolveApp:P,history:G,linkedRecords:I,menuSections:E,subscriptions:R,signIn:_,view:C,onViewChange:N,children:ve}){let oe=(0,l.useContext)(Ce),z=E??oe?.menuSections,be=_??oe?.signIn,[V,K]=(0,l.useState)(null),B=V??i??a[0]?.principal??Vo,J=xt(e,B,G),Ft=J.past&&J.live===e?J.past.store:e,H=(0,l.useMemo)(()=>Ft.seenBy(B),[Ft,B]);Lo(e,B);let[re]=(0,l.useState)(()=>bo(u)),[Kt,Jo]=(0,l.useState)(!1),Bt=(0,l.useCallback)(()=>Jo(!0),[]),ie=(0,l.useMemo)(()=>g?[...p,...xo]:p,[p,g]),[tt]=(0,l.useState)(()=>n??It(t,e.schema)),[Zo,$t]=(0,l.useState)(()=>We(tt??ue,r??tt?.selection??[])),xe=(0,l.useRef)(tt??ue).current,[qt,Qo]=(0,l.useState)(null),[zt,er]=(0,l.useState)(null),Z=(0,l.useContext)(Ce),[Ut]=(0,l.useState)(()=>Z?.seatTalk??vt(b?.name??e.schema.kinds.join(","))),nt=y??Z?.ai??ft,Ve=(0,l.useMemo)(()=>nt.off?oi:nt,[nt]),Yt=(0,l.useRef)(Ve.interactions);Yt.current=Ve.interactions;let[Xt]=(0,l.useState)(()=>Z?.aiDesk??bt(()=>Yt.current)),[tr]=(0,l.useState)(()=>Z?.subscriptions??On()),Jt=R??Z?.subscriptions??tr,ot=m??Z?.onKeepLens,rt=h??Z?.app,Le=k??Z?.locale,nr=b?.locale??rt?.brand?.locale;kn({reader:Le,app:nr});let Zt=(0,l.useRef)(null),Qt=(0,l.useCallback)(c=>{Zt.current=c},[]),en=(0,l.useCallback)(c=>Zt.current?.whereIs(c)??null,[]),[tn]=(0,l.useState)(()=>Ro()),[nn]=(0,l.useState)(()=>Mo()),[it,or]=(0,l.useState)(null),[Ee,on]=(0,l.useState)(()=>new Map),ke=(0,l.useRef)(Ee);ke.current=Ee;let Ae=(0,l.useRef)(null),at=(0,l.useCallback)(c=>H.graph.getNode(c)?.kind,[H]),Q=(0,l.useCallback)(c=>{let S=kt(ke.current,c,at);ke.current=S,on(S),Ae.current&&clearTimeout(Ae.current),[...S.values()].some(M=>M.mode!=="docked"&&M.mode!=="asking")&&(Ae.current=setTimeout(()=>{let M=kt(ke.current,{type:"rest",at:Date.now(),holdMs:Ot},at);ke.current=M,on(M)},Ot+20))},[at]),rn=(0,l.useCallback)(c=>Q({...c,at:c.at??Date.now()}),[Q]),an=(0,l.useCallback)(c=>{or(c),c&&Q({type:"home",author:{kind:"agent",id:c,session:re},at:Date.now()})},[Q,re]);(0,l.useEffect)(()=>H.subscribe((c,S)=>{for(let T of S)T.author.kind==="agent"&&Q({type:"write",author:T.author,ids:T.writes,at:Date.now()})}),[H,Q]),(0,l.useEffect)(()=>()=>{Ae.current&&clearTimeout(Ae.current)},[]);let U=(0,l.useMemo)(()=>({...B,session:re}),[B,re]),sn=To(H,I,U),ln=(0,l.useCallback)(c=>{K(c),d?.(c)},[d]),[Pe,rr]=(0,l.useState)(()=>Object.fromEntries(ie.map(c=>[c.name,go(c,u)])));(0,l.useEffect)(()=>{for(let c of ie)So(c,Pe[c.name]??c.initial)},[ie,Pe]);let dn=(0,l.useCallback)((c,S)=>{let T=ie.find(M=>M.name===c);!T||!T.options.some(M=>M.value===S)||(ho(T,S,u),rr(M=>({...M,[c]:S})))},[ie,u]),[un,ir]=(0,l.useState)(null),{activity:cn,noteAttention:fn}=Po(H),pn=(0,l.useCallback)(c=>{fn(c),Q({type:"read",author:c.author,ids:c.reads,at:Date.now()})},[fn,Q]),de=(0,l.useCallback)(c=>{if(fe(c)!==null||se(c).length>0||ct(c))return!0;let S=jn(c);return S?H.graph.allEdges().some(T=>T.kind===S.kind&&T.from===S.from&&T.to===S.to):H.graph.getNode(c)!==void 0},[H]),yn=(0,l.useCallback)(c=>{let S=c.selection??Rt,T=S.filter(de),M=T.length===S.length?c:We(c,T);return M.focusId!==null&&!de(M.focusId)&&(M=q(M,null)),M},[de]),Re=(0,l.useCallback)(c=>{let S=yn(c),T=Co(H,U,S.shown);if(S.focusId!==null&&T.size>0){let M=se(S.focusId),En=H.graph.getNode(S.focusId);(M.length>0?M.every(lr=>T.has(lr)):En?T.has(En.kind):!1)&&(S={...S,focusId:null})}if(!S.overview&&S.focusId===null){let M=xe.focusId!==null&&!de(xe.focusId)?It(t,e.schema)??{...ue,overview:!0}:xe;M.focusId!==null&&de(M.focusId)?S={...S,focusId:M.focusId}:M.overview===!0&&(S={...S,overview:!0})}return S},[yn,de,H,xe,U,t,e.schema]),$=Re(C??Zo),mn=(0,l.useMemo)(()=>Co(H,U,$.shown),[H,U,$.shown]),gn=(0,l.useMemo)(()=>[...H.modules.administered.entries()].map(([c,S])=>{let T=H.mayAdminister(c,U);return{name:c,...S.description?{description:S.description}:{},kinds:S.kinds??[],canShow:T,shown:T&&($.shown??[]).includes(c)}}),[H,U,$.shown]),Te=(0,l.useCallback)(c=>{let S=T=>Re(typeof c=="function"?c(T):c);if(C!==void 0){N?.(S(C));return}N&&N(S($)),$t(T=>S(T))},[$,N,C,Re]);(0,l.useEffect)(()=>{C===void 0&&$t(c=>{let S=Re(c);return S===c?c:S})},[$,C,Re]);let hn=$.selection??Rt,Sn=(0,l.useCallback)(c=>{Te(S=>We(S,typeof c=="function"?c(S.selection??Rt):c))},[Te]),{who:wn,following:vn,follow:bn,sayWhere:ar,sharing:xn}=Eo({channel:g,store:H,view:$,principal:U,session:re,robots:Ee,seatWho:it,settingValues:Pe,setView:Te,seats:a,people:s,...f!==void 0?{ttlMs:f}:{}}),sr=(0,l.useMemo)(()=>({store:H,scheme:o,views:t,view:$,setView:Te,homeView:xe,selection:hn,setSelection:Sn,menuAt:qt,setMenuAt:Qo,whereIs:en,pointer:tn,motion:nn,registerScene:Qt,robots:Ee,noteSeat:rn,seatWho:it,registerSeatWho:an,actsDoor:zt,registerActsDoor:er,seatTalk:Ut,aiDesk:Xt,...u?{memory:u}:{},who:wn,following:vn,follow:bn,sayWhere:ar,sharing:xn,session:re,ai:Ve,resolveApp:P,linkedRecords:I,menuSections:z,subscriptions:Jt,signIn:be,linkedReads:sn,movedByHand:Kt,noteMoved:Bt,emphasis:un,setEmphasis:ir,activity:cn,noteAttention:pn,principal:U,seats:a,people:s,takeSeat:ln,settings:ie,settingValues:Pe,chooseSetting:dn,hiddenKinds:mn,administered:gn,...w?{providers:w}:{},...b?{brand:b}:{},...ot?{onKeepLens:ot}:{},app:rt,...Le?{locale:Le}:{}}),[H,o,t,$,Te,hn,Sn,qt,en,tn,nn,Qt,Ee,rn,it,an,zt,Ut,Xt,u,wn,vn,bn,xn,re,Ve,P,I,z,Jt,be,sn,Kt,Bt,un,cn,pn,U,a,s,ln,ie,Pe,dn,mn,gn,w,b,ot,rt,Le]);return(0,le.jsx)(Ce.Provider,{value:sr,children:(0,le.jsx)(Oe.Provider,{value:J,children:(0,le.jsx)(di,{children:x?(0,le.jsx)(ze.Provider,{value:x,children:ve}):ve})})})}var Ho=(0,l.createContext)(null),Tt,Mt=new Set,ii=e=>(Mt.add(e),()=>void Mt.delete(e)),Oo=()=>Tt;function ai(e){if(!Tt){Tt=e;for(let t of[...Mt])t()}}var si=300;function li(e){let t=0;return async(n,o)=>{let r=++t;return await new Promise(i=>setTimeout(i,si)),r===t?e(n,o):[]}}function di({children:e}){let{store:t,view:n,views:o,principal:r,hiddenKinds:i,selection:a,ai:d}=ne(),s=Je(),u=n.q,f=n.focusId,h=!!(u&&u.trim().length>0),p=(0,l.useSyncExternalStore)(ii,Oo,Oo),g=(0,l.useMemo)(()=>h&&p?{flagged:new Set(t.violations().flatMap(x=>x.nodeIds)),touched:p.touchWeights(t.log.all())}:null,[t,s,h,p]),b=f?t.graph.getNode(f)?.kind??fe(f)??(se(f).length===1?se(f)[0]:void 0):void 0,k=(0,l.useMemo)(()=>d.near&&li(d.near),[d.near]),m=(0,l.useMemo)(()=>!u||!g||!p?null:p.search(t,u,{...b?{inKind:b}:{},principal:r,places:o.places(),kinds:t.schema.kinds.filter(x=>!i.has(x)),from:[...a,...f&&t.graph.has(f)?[f]:[]],flagged:g.flagged,touched:g.touched,limit:200,rank:k}),[t,u,r,o,i,a,f,b,g,k]),[w,y]=(0,l.useState)();return(0,l.useEffect)(()=>void m?.later?.then(x=>y([m,x])),[m]),(0,le.jsx)(Ho.Provider,{value:w?.[0]===m?w[1]:m,children:e})}var Io=new WeakMap;function Fa(e){let t=Io.get(e);return t||Io.set(e,t=new Set(e.matched)),t}function ui(){return(0,l.useContext)(Ho)}function ne(){let e=(0,l.useContext)(Ce);if(!e)throw new Error("useGraview must be used inside a <GraviewProvider>.");return e}function Ct(){return(0,l.useContext)(Ce)??null}function Je(){let{store:e}=ne(),t=(0,l.useRef)(null),n=(0,l.useRef)(null),o=(0,l.useCallback)(()=>(n.current!==e&&(n.current=e,t.current=null),t.current??=e.graph.allNodes(),t.current),[e]),r=(0,l.useCallback)(i=>e.subscribe(()=>{t.current=null,i()}),[e]);return(0,l.useSyncExternalStore)(r,o,o)}function ci(e){let{store:t}=ne(),n=(0,l.useCallback)(r=>t.subscribe(r),[t]),o=(0,l.useCallback)(()=>e===null?void 0:t.graph.getNode(e),[t,e]);return(0,l.useSyncExternalStore)(n,o,o)}function Co(e,t,n){let o=new Set(e.modules.disabledKinds);for(let r of e.kindsKeptFrom(t))o.add(r);for(let[r,i]of e.modules.administered)if(!(e.mayAdminister(r,t)&&(n??[]).includes(r)))for(let a of i.kinds??[])o.add(a);return o}var Ot=2600;var Do=new WeakSet,fi=e=>Do.has(e),pi=e=>void Do.add(e);function It(e,t){let n=Vn(e.arrangement?.()?.first,t,e.places());if(!(!n||n.to==="home"))return n.to==="place"?{...ue,focusId:te(n.place.kind),within:{view:n.place.as}}:{...ue,focusId:te(n.kind)}}var No=D(W(),1),yi=(0,No.createContext)(!1);var Ze=Symbol.for("graview.default-view");function jo(e){return Object.defineProperty(e,Ze,{value:!0,enumerable:!1}),e}function Go(e){return typeof e=="function"&&e[Ze]===!0}var _t=Symbol.for("graview.replaces-page");function Wo(e){return typeof e=="function"&&e[_t]===!0}function gi(e){return _n(e)}function hi(e,t){if(t===e)return e;for(let r of t.registrations())e.register(r.kind,r,r.view,r);let n=t.arrangement?.();n&&e.arrange?.(n);let o=t.homeView?.();return o&&e.home?.(o),e}var ge=D(W(),1);function Si(){let{selection:e,setSelection:t}=ne();return(0,ge.useMemo)(()=>({selection:e,set:n=>t(n),clear:()=>t([]),toggle:n=>t(o=>o.includes(n)?o.filter(r=>r!==n):[...o,n]),isSelected:n=>e.includes(n)}),[e,t])}function wi(){let{store:e}=ne(),t=Je();return(0,ge.useMemo)(()=>vi(e),[e,t])}var Fo=new WeakMap;function vi(e){let t=Fo.get(e);if(!t){let n={violations:null};e.subscribe(()=>{n.violations=null}),Fo.set(e,n),t=n}return t.violations??=e.violations(),t.violations}function bi(){let{view:e,setView:t}=ne();return(0,ge.useMemo)(()=>({view:e,url:ee(e),focus:n=>t(o=>q(o,n)),show:n=>t(o=>Gn(o,n)),toggle:n=>t(o=>Fe(o,n)),go:n=>t(n)}),[e,t])}var me={at:0,depth:0,listeners:new Set,tell(){for(let e of this.listeners)e()}};typeof window<"u"&&window.addEventListener("popstate",e=>{let t=e.state;me.at=typeof t?.graview=="number"?t.graview:0,me.at>me.depth&&(me.depth=me.at),me.tell()});var j=D(W(),1),Lt={profile:{trigger:"profile-button",pane:"profile",opens:"press",focus:"into",drawn:["shell","embed"]},problems:{trigger:"standing",pane:"problems",opens:"press",focus:"into",drawn:["shell","embed"]},places:{trigger:"app-places-open",pane:"app-places",opens:"press",focus:"into",drawn:["embed"]},here:{trigger:"here-open",pane:"here-list",opens:"press",focus:"into",drawn:["shell","embed","pages"]},suggested:{trigger:"suggested-button",pane:"suggested",opens:"press",focus:"into",drawn:["shell","embed","pages"]},activity:{trigger:"activity-button",pane:"activity",opens:"press",focus:"into",drawn:["shell","embed","pages"]},find:{trigger:"find-box",pane:"find-strip",opens:"typing",focus:"stays",drawn:["shell"]},districts:{trigger:"beyond-more",pane:"beyond-list",opens:"press",focus:"into",drawn:["shell","embed"]},acts:{trigger:null,pane:"context-menu",opens:"context-menu",focus:"into",drawn:["shell","embed","pages"]},arrange:{trigger:"arrange-add",pane:"arrange-list",opens:"press",focus:"into",drawn:["pages"]},"studio-ask":{trigger:"studio-agent",pane:"studio-agent-panel",opens:"press",focus:"into",drawn:["studio"]}},xi={position:"fixed",inset:"auto",margin:0,zIndex:Mn("popover"),boxSizing:"border-box"},Qe=6,he=8,Ei=e=>typeof e.showPopover=="function";function et(e){try{return e.matches(":popover-open")}catch{return!1}}function ki(e){if(typeof e=="function"){let o=e();return o?{left:o.x,right:o.x,top:o.y,bottom:o.y}:null}let t=e.current;if(!t||!t.isConnected)return null;let n=t.getBoundingClientRect();return{left:n.left,right:n.right,top:n.top,bottom:n.bottom}}function Ht(e,t,n={}){let o=ki(t);if(!o)return;let r={width:document.documentElement.clientWidth||innerWidth,height:innerHeight},i=e.dataset.graviewDesignedHeight??=e.style.maxHeight;e.style.maxHeight=i;let a=e.getBoundingClientRect(),d=r.height-o.bottom-Qe-he,s=o.top-Qe-he,u=a.height<=d||d>=s,f=Math.max(96,Math.floor(u?d:s)),h=Math.min(a.height,f);a.height>f&&(e.style.maxHeight=i?`min(${i}, ${f}px)`:`${f}px`);let p=a.width,g=n.align==="start"?o.left:o.right-p,b=typeof t=="function"?null:t.current?.closest("[data-graview-embed]")?.getBoundingClientRect();b&&p<=b.right-b.left&&(g<b.left?g=o.left+p<=b.right?o.left:b.left:g+p>b.right&&(g=o.right-p>=b.left?o.right-p:b.right-p));let k=p>=r.width-2*he?Math.max(0,(r.width-p)/2):Math.max(he,Math.min(g,r.width-he-p)),m=u?o.bottom+Qe:Math.max(he,o.top-Qe-h);e.style.left=`${Math.round(k)}px`,e.style.top=`${Math.round(m)}px`}function Ko(e,t,n,o={}){let r=o.align??"end";(0,j.useLayoutEffect)(()=>{let i=e.current;if(!t||!i)return;if(Ei(i)&&!et(i))try{i.showPopover(),Pi()}catch{}let a=0,d=u=>{u?.target instanceof Node&&i.contains(u.target)||(cancelAnimationFrame(a),a=requestAnimationFrame(()=>Ht(i,n,{align:r})))};Ht(i,n,{align:r}),addEventListener("resize",d),addEventListener("scroll",d,!0);let s=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>d());return s?.observe(i),()=>{if(cancelAnimationFrame(a),removeEventListener("resize",d),removeEventListener("scroll",d,!0),s?.disconnect(),i.isConnected&&et(i))try{i.hidePopover()}catch{}}},[t,e,r])}var Dt=new Set;function Ai(e){return Dt.add(e),()=>Dt.delete(e)}function Pi(){for(let e of Dt)if(!(!e.isConnected||!et(e)))try{e.hidePopover(),e.showPopover()}catch{}}var Se=null,Ri='button:not([disabled]), [href], input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex="-1"])';function Ti(e){for(let t of e.querySelectorAll(Ri))if(t.closest("[hidden]")===null&&getComputedStyle(t).visibility!=="hidden")return t;return e}var Vt=()=>{let e=document.activeElement;return e===null||e===document.body};function Mi(e,t={}){let{at:n,returnTo:o,onOpenChange:r}=t,i=t.popover!==!1,[a,d]=(0,j.useState)(!1),s=t.open??a,u=(0,j.useRef)(null),f=(0,j.useRef)(null),h=(0,j.useCallback)(y=>{u.current=y},[]),p=(0,j.useCallback)(y=>{f.current=y},[]),g=`graview-popover-${(0,j.useId)().replace(/:/g,"")}`,b=(0,j.useRef)({onOpenChange:r,returnTo:o,controlled:t.open!==void 0});b.current={onOpenChange:r,returnTo:o,controlled:t.open!==void 0};let k=(0,j.useCallback)(y=>{b.current.controlled||d(y),b.current.onOpenChange?.(y)},[]),m=(0,j.useCallback)(()=>{(document.querySelector(`[aria-controls="${g}"]`)??u.current??b.current.returnTo?.()??null)?.focus({preventScroll:!0})},[g]),w=(0,j.useCallback)(y=>{let x=f.current,P=typeof document>"u"?null:document.activeElement,G=P===null||P===document.body||x!==null&&x.contains(P);k(!1),!(!y||!G)&&(m(),requestAnimationFrame(()=>{Vt()&&m()}))},[k,m]);return Ko(f,i&&s,n??u,t.align?{align:t.align}:{}),(0,j.useEffect)(()=>{if(!i||!s)return;let y={name:e,close:()=>w(!1)};if(Se&&Se.close!==y.close&&Se.close(),Se=y,Lt[e].focus==="into"){let R=f.current;R&&!R.contains(document.activeElement)&&Ti(R).focus({preventScroll:!0})}let x=R=>{R.key==="Escape"&&w(!0)},P=R=>{let _=R.target;if(!(_ instanceof Node))return;let C=f.current;if(C?.contains(_)||u.current?.contains(_))return;let N=_ instanceof Element?_.closest('[role="dialog"], [role="alertdialog"]'):null;N&&!(C&&N.contains(C))||(w(!1),Lt[e].focus==="into"&&requestAnimationFrame(()=>{(Vt()||C!==null&&C.contains(document.activeElement))&&m()}))},G=null,I=null,E=R=>{let _=R.target;if(!(_ instanceof Element))return;let C=f.current,N=_.closest('[role="dialog"], [role="alertdialog"]');!N||C&&(C.contains(N)||N.contains(C))||(G=N,w(!1))};return document.addEventListener("keydown",x),document.addEventListener("pointerdown",P,!0),document.addEventListener("focusin",E),()=>{document.removeEventListener("keydown",x),document.removeEventListener("pointerdown",P,!0),document.removeEventListener("focusin",E);let R=G;R&&typeof MutationObserver<"u"&&(I?.disconnect(),I=new MutationObserver(()=>{R.isConnected||(I?.disconnect(),requestAnimationFrame(()=>{(Vt()||document.activeElement.closest("[hidden]")!==null)&&m()}))}),I.observe(document.body,{childList:!0,subtree:!0}),setTimeout(()=>I?.disconnect(),10*6e4)),Se?.close===y.close&&(Se=null)}},[i,s,e,w,m]),{open:s,setOpen:y=>y?k(!0):w(!0),toggle:()=>s?w(!0):k(!0),trigger:{ref:h,"aria-expanded":s,"aria-controls":g,"data-graview-popover-trigger":e},pane:{ref:p,id:g,popover:"manual",tabIndex:-1,"data-graview-popover":e,"data-graview-overlay":""}}}var F=D(W(),1),X=D(Ie(),1),Nt=new Set,Bo=!1;function jt(){for(let e of[...Nt])e()}function Oi(){Bo||typeof window>"u"||(Bo=!0,window.addEventListener("online",jt))}function Ii(e){let t,n=!1,o=!1,r,i=0,a=new Set,d=()=>{i+=1;for(let p of[...a])p()},s=p=>(a.add(p),()=>void a.delete(p)),u=()=>i,f=()=>void h().catch(()=>{});function h(){if(n)return Promise.resolve(t);if(r)return r;let p=e().then(g=>(t=g,n=!0,o=!1,r=void 0,Nt.delete(f),d(),g),g=>{throw r=void 0,o=!0,Nt.add(f),Oi(),d(),g});return p.catch(()=>{}),r=p,p}return{load:h,prefetch:f,get current(){return t},get failed(){return o},part(p,g={}){let b=g.what??"This part";function k(y){(0,F.useSyncExternalStore)(s,u,u);let x=(0,F.useRef)(null),P=(0,F.useRef)(null),G=(0,F.useRef)(!1);return(0,F.useEffect)(()=>{o&&r===void 0&&f()},[]),n&&typeof document<"u"&&x.current!==null&&document.activeElement===x.current&&(G.current=!0),(0,F.useLayoutEffect)(()=>{if(!(!n||!G.current)){G.current=!1;for(let I=P.current?.nextElementSibling??null;I!==null;I=I.nextElementSibling){let E=I.matches($o)?I:I.querySelector($o);if(E instanceof HTMLElement){E.focus();return}}}}),n?(0,X.jsxs)(X.Fragment,{children:[G.current?(0,X.jsx)("span",{ref:P,hidden:!0}):null,p(t,y)]}):g.quiet?null:(0,X.jsx)(Ci,{what:b,button:x,...g.as?{as:g.as}:{}})}let m=(0,F.lazy)(()=>h().then(()=>({default:k}),()=>({default:k})));function w(y){let[x]=(0,F.useState)(()=>n||o);return(0,F.createElement)(x?k:m,y)}return w}}}var $o="button,a[href],input,select,textarea,[tabindex]:not([tabindex='-1'])";function Ci({what:e,button:t,as:n="p"}){let r=typeof navigator<"u"&&navigator.onLine===!1?`${e} will load when you're back online.`:`${e} didn't load.`;return(0,X.jsxs)(n,{"data-testid":"lazy-part-missing",style:{margin:0,fontSize:"0.875rem",color:"var(--graview-ink-muted)"},children:[(0,X.jsx)("span",{role:"status",children:r})," ",(0,X.jsx)("button",{ref:t,type:"button","data-testid":"lazy-part-retry",onClick:jt,style:{font:"inherit",fontWeight:600,color:"var(--graview-ink)",background:"none",border:"1px solid var(--graview-edge)",borderRadius:6,padding:"2px 10px"},children:"Try again"})]})}var we=D(W(),1);var qo=(0,we.createContext)(null);function _i(){let e=(0,we.useContext)(qo),t=Ct(),n=(o,r,i)=>t?.setView(a=>ae(ae(ce(q(a,te(o)),!1),"view",r),"filter",i?.filter??null));return(0,we.useMemo)(()=>e??{record:o=>{t&&(t.setView(r=>q(ce(r,!1),o)),t.setSelection([o]))},place:(o,r)=>{let i=t?.views.places().find(a=>a.as===o);i&&n(i.kind,i.as,r)},list:(o,r)=>n(o,null,r)},[e,t])}var zo=D(W(),1),Vi=(0,zo.createContext)(!1);var Uo=D(W(),1),Li=(0,Uo.createContext)(null);var Yo=D(W(),1),Gt='button:not([disabled]), a[href], input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex="-1"])',Wt=e=>e instanceof HTMLElement&&(e.matches(Gt)||e.hasAttribute("tabindex")),_e=e=>typeof e.checkVisibility=="function"?e.checkVisibility():e.getClientRects().length>0;function Hi(e,t){let n=s=>s.replace(/["\\]/g,"\\$&"),o=t.getAttribute("data-testid"),r=t.getAttribute("data-graview-pick"),i=t.getAttribute("aria-label"),a=o?`[data-testid="${n(o)}"]`:r?`[data-graview-pick="${n(r)}"]`:i?`${t.tagName.toLowerCase()}[aria-label="${n(i)}"]`:null;if(!a)return null;let d=e.querySelector(a);return d&&Wt(d)&&_e(d)?d:null}var Di=e=>e.isConnected&&Wt(e)&&!e.matches(":disabled")&&e instanceof HTMLElement&&_e(e);function Xo(e,t){let n=t?Hi(e,t):null;if(n)return n;let o=e.querySelector("[data-graview-view][tabindex]");if(o&&_e(o))return o;for(let r of e.querySelectorAll(Gt))if(_e(r))return r;return Wt(e)&&_e(e)?e:null}function Ni(e){(0,Yo.useEffect)(()=>{let t=e.current;if(!t||typeof MutationObserver>"u")return;let n=[],o=m=>{let w=m.target;if(w instanceof Element){n=[];for(let y=w;y&&y!==t.parentElement;y=y.parentElement)n.push(y)}},r=!1,i=!1,a=t.ownerDocument,d=()=>!i&&a.defaultView!==null,s=(m,w)=>void setTimeout(()=>d()&&w(),m),u=m=>void requestAnimationFrame(()=>d()&&m()),f=m=>{if(r=!1,i)return;let w=a.activeElement;if(!(!(w===null||w===a.body||w===a.documentElement)||n.length===0)){if(Di(n[0])){m&&n[0]instanceof HTMLElement&&n[0].focus({preventScroll:!0});return}for(let x of n.slice(1)){if(!x.isConnected)continue;let P=Xo(x,n[0]);if(P){P.focus({preventScroll:!0}),n=[];return}}}},h=(m,w=Date.now()+2500)=>{s(100,()=>{f(m);let y=a.activeElement;(y===null||y===a.body||y===a.documentElement)&&n.length>0&&Date.now()<w&&h(m,w)})},p=()=>{r||n.length===0||(r=!0,s(60,()=>u(()=>{f(!1),h(!1)})))},g=m=>{if(!(m instanceof KeyboardEvent&&!["Enter"," ","Escape"].includes(m.key))){if(!(m instanceof KeyboardEvent)){let w=m.target instanceof Element?m.target.closest(Gt):null,y=a.activeElement,x=y===null||y===a.body||y===a.documentElement;if(w&&x&&t.contains(w)){n=[];for(let P=w;P&&P!==t.parentElement;P=P.parentElement)n.push(P);s(150,()=>u(()=>{f(!1),h(!1)}));return}}!(m instanceof KeyboardEvent)&&!(m.target instanceof Node&&n[0]?.contains(m.target))||s(150,()=>u(()=>{f(!0),h(!0)}))}},b=new MutationObserver(()=>{n.length>0&&!n[0].isConnected&&p()}),k=m=>{m.relatedTarget===null&&p()};return t.addEventListener("focusin",o),t.addEventListener("focusout",k),t.addEventListener("click",g),t.addEventListener("keydown",g),b.observe(t,{childList:!0,subtree:!0}),()=>{i=!0,t.removeEventListener("focusin",o),t.removeEventListener("focusout",k),t.removeEventListener("click",g),t.removeEventListener("keydown",g),b.disconnect()}},[e])}export{Hn as a,ue as b,ee as c,Ge as d,Wi as e,Fi as f,Nn as g,Dn as h,jn as i,dt as j,q as k,Gn as l,ae as m,ce as n,We as o,Me as p,Fe as q,Be as r,ut as s,fe as t,$i as u,fr as v,te as w,Wn as x,se as y,Fn as z,pr as A,qi as B,Kn as C,ct as D,yr as E,W as F,vt as G,Vr as H,Hr as I,so as J,ze as K,Dr as L,Oe as M,uo as N,Nr as O,xt as P,Ie as Q,Zr as R,Qr as S,Lo as T,ri as U,ai as V,Fa as W,ui as X,ne as Y,Ct as Z,Je as _,ci as $,fi as aa,pi as ba,It as ca,qo as da,_i as ea,yi as fa,jo as ga,Go as ha,Wo as ia,gi as ja,hi as ka,Vi as la,Li as ma,Si as na,wi as oa,bi as pa,me as qa,Ni as ra,xi as sa,et as ta,Ko as ua,Ai as va,Mi as wa,Ii as xa};
2
+ /*! Bundled license information:
3
+
4
+ react/cjs/react.production.js:
5
+ (**
6
+ * @license React
7
+ * react.production.js
8
+ *
9
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
10
+ *
11
+ * This source code is licensed under the MIT license found in the
12
+ * LICENSE file in the root directory of this source tree.
13
+ *)
14
+
15
+ react/cjs/react-jsx-runtime.production.js:
16
+ (**
17
+ * @license React
18
+ * react-jsx-runtime.production.js
19
+ *
20
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
21
+ *
22
+ * This source code is licensed under the MIT license found in the
23
+ * LICENSE file in the root directory of this source tree.
24
+ *)
25
+ */
@@ -1,4 +1,4 @@
1
- import{a as k}from"./chunk.G4JJXA63.js";import{a as Q}from"./chunk.UZGRRDHD.js";import{a as Y}from"./chunk.OKRNJXTV.js";import{a as X}from"./chunk.PBSMLINK.js";import{c as _}from"./chunk.FWTIUYXH.js";import{$a as q,Hc as G,Ic as H,Jc as P,Kc as J,ab as z}from"./chunk.MNP4JI33.js";var O=e=>"failed"in e;function ue(e,n){let r=e.schema.kinds,t=e.policy?.sees;if(!t?.length||z(n))return{kinds:r};let o=q(n).roles??[],i=new Set(t.filter(s=>s.roles==="*"||o.some(a=>s.roles.includes(a))).flatMap(s=>s.kinds));return{kinds:r.filter(s=>i.has(s))}}function L(e,n){if(!n)return e;let r=new Set(n.kinds.filter(i=>e.tryDefinition(i)!==void 0));if(r.size===e.kinds.length)return e;let t=new Map,o=i=>{if(r.has(i)){if(!t.has(i)){let s=e.tryDefinition(i),a=Object.fromEntries(Object.entries(s?.edges??{}).flatMap(([l,d])=>{if(d.to==="*")return[[l,d]];let c=d.to.filter(u=>r.has(u));return c.length>0?[[l,{...d,to:c}]]:[]}));t.set(i,{...s,edges:a})}return t.get(i)}};return{...e,definitions:e.definitions.filter(i=>r.has(i.kind)),kinds:e.kinds.filter(i=>r.has(i)),tryDefinition:o,definition:i=>{let s=o(i);if(!s)throw new Error(`Unknown node kind "${i}"`);return s}}}var fe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),y=e=>fe(e).replace(/[-_]+/g," ").trim();function I(e){let n=[];for(let t of e.kinds){let o=e.tryDefinition(t);if(!o)continue;let i=o.display?.labels??{},s=Object.entries(o.fields?.shape??{}).filter(([d])=>d!=="id"&&d!=="kind").map(([d,c])=>{let u=X(c);return{name:d,type:u?.type,...u?.options?{options:u.options}:{},words:(i[d]??y(d)).toLowerCase()}}),a=Object.entries(o.edges??{}).map(([d,c])=>({name:d,from:t,to:c.to==="*"?e.kinds.filter(u=>u!==t):c.to,words:y(d)})),l=(o.plural??`${y(t)}s`).toLowerCase();n.push({kind:t,plural:l,noun:(o.noun??y(t)).toLowerCase(),fields:s,roles:o.fieldRoles??{},edges:a})}let r=new Map(n.map(t=>[t.kind,t]));return{schema:e,kinds:n,info:t=>r.get(t)}}var $=(e,n)=>n===void 0?void 0:e.fields.find(r=>r.name===n),R=e=>e?.type==="date"||e?.type==="datetime",N=e=>e?.type==="number"||e?.type==="integer"||e?.type==="duration",re=e=>` ${e.toLowerCase().replace(/[“”"’‘]/g,"'").replace(/[^\p{L}\p{N}' -]+/gu," ").replace(/\s+/g," ").trim()} `,E=(e,n)=>e.includes(` ${n} `),x=e=>e.endsWith("ies")?`${e.slice(0,-3)}y`:e.endsWith("ses")?e.slice(0,-2):e.endsWith("s")?e.slice(0,-1):e;function pe(e,n){let r=[];for(let t of n.kinds){let o=new Set([t.plural,t.noun,`${t.noun}s`,y(t.kind),`${y(t.kind)}s`]),i=-1;for(let s of o){let a=e.indexOf(` ${s} `);a>=0&&(i<0||a<i)&&(i=a)}i>=0&&r.push({info:t,at:i})}return r.sort((t,o)=>t.at-o.at).map(t=>t.info)}function v(e,n,r){let t=n.trim().toLowerCase();if(t.length===0)return;let o=e.fields.filter(i=>!r||r(i));return o.find(i=>i.words===t||y(i.name)===t||i.name.toLowerCase()===t)??o.find(i=>i.words===x(t)||y(i.name)===x(t))??o.find(i=>t.split(" ").some(s=>s.length>2&&(i.words.split(" ").includes(s)||i.words.split(" ").includes(x(s)))))}function oe(e,n,r){let t=n.trim().toLowerCase();if(t.length!==0)return e.edges.find(o=>o.words===t||o.name.toLowerCase()===t)??e.edges.find(o=>o.to.some(i=>{let s=r.info(i);return s!==void 0&&(s.noun===x(t)||s.plural===t||y(i)===x(t))}))??e.edges.find(o=>t.split(" ").some(i=>i.length>2&&o.words.split(" ").includes(i)))}function U(e){return/ (?:grouped |group |split |sorted |organi[sz]ed )?by ([\p{L}\p{N}' -]+?)(?= (?:and|with|for|in|on|only|where|from|this|that|as|sorted|grouped) |\s*$)/u.exec(e)?.[1]?.trim()}var me=/\bwho\b.*\b(covers?|cover|tends?|owns?|handles?|does|works? on|looks? after|is on|is assigned|staffs?|runs?)\b|\bcoverage\b|\bmatrix\b|\bwho covers\b/,ge=/\bcalendar\b|\bmonth\b|\bagenda\b|\bschedule\b|\bdue\b|\bdeadlines?\b|\bdates?\b|\bwhen\b/,ye=/\btimeline\b|\bover time\b|\bgantt\b|\bspans?\b|\bweek\b/,he=/\bboard\b|\bkanban\b|\bcolumns?\b|\bpipeline\b|\bstages?\b|\bstatus\b/,be=/\blaid out\b|\blayout\b|\bseating\b|\bwhere (?:they|it|each) (?:sits?|lies?|stands?)\b|\bfloor\b/,we=/\bplan\b|\bmap\b|\bregions?\b/,ke=/\blist\b|\btable\b|\bgroup(?:ed)? by\b|\bsort(?:ed)? by\b|\bonly\b|\bjust the\b/;function $e(e){let n=[];return/\blist\b|\btable\b/.test(e)&&n.push("blocks"),me.test(e)&&n.push("coverage"),be.test(e)&&n.push("board"),(/\bfloor plan\b/.test(e)||we.test(e))&&n.push("plan"),ye.test(e)&&n.push("timeline"),ge.test(e)&&n.push("calendar"),he.test(e)&&n.push("columns"),ke.test(e)&&!n.includes("blocks")&&n.push("blocks"),n.length===0&&U(e)&&n.push("columns"),n}var se=e=>{let n=r=>r?` and not ${r}`:"";if(/\boverdue\b|\blate\b|\bpast due\b/.test(e))return{cond:(r,t)=>`days(today(), ${r}) < 0${n(t)}`,says:r=>`overdue by ${r.words}`};if(/\btoday\b/.test(e))return{range:"day",cond:r=>`days(today(), ${r}) == 0`,says:r=>`with ${r.words} today`};if(/\bthis week\b|\bnext 7 days\b|\bnext week\b/.test(e))return{range:"week",cond:r=>`days(today(), ${r}) >= 0 and days(today(), ${r}) <= 6`,says:r=>`with ${r.words} in the next week`};if(/\bthis month\b|\bnext 30 days\b|\bnext month\b/.test(e))return{range:"month",cond:r=>`days(today(), ${r}) >= 0 and days(today(), ${r}) <= 30`,says:r=>`with ${r.words} in the next month`};if(/\blast month\b|\bpast month\b/.test(e))return{range:"month",cond:r=>`days(today(), ${r}) >= -30 and days(today(), ${r}) <= 0`,says:r=>`with ${r.words} in the last month`};if(/\bthis year\b/.test(e))return{range:"year",cond:r=>`days(today(), ${r}) >= 0 and days(today(), ${r}) <= 365`,says:r=>`with ${r.words} in the next year`};if(/\bquarter\b/.test(e))return{range:"quarter",cond:r=>`days(today(), ${r}) >= 0 and days(today(), ${r}) <= 91`,says:r=>`with ${r.words} in the next quarter`}},M=e=>{if(/\bagenda\b|\bin order\b/.test(e))return"agenda";if(/\btoday\b|\bday\b/.test(e))return"day";if(/\bweek\b/.test(e))return"week";if(/\bquarter\b/.test(e))return"quarter";if(/\byears\b/.test(e))return"years";if(/\byear\b/.test(e))return"year";if(/\bmonth\b/.test(e))return"month"},Z=/^(user|person|people|member|staff|gardener|volunteer|owner|agent|employee|worker|team|player|customer|client|contact|party|attendee|guest)s?$/,j=class extends Error{},h=e=>{throw new j(e)};function Se(e,n){let r=e.fields.filter(i=>i.type==="enum");if(n){let i=v(e,n);if(i&&i.type==="enum")return i;i&&h(`${e.plural}' ${i.words} is not a choice, so it has no columns`)}let t=$(e,e.roles.status??e.roles.column);if(t?.type==="enum")return t;let o=r.find(i=>/^(status|stage|state|phase)$/.test(i.name));return o||(r[0]?r[0]:h(`${e.plural} have no choice field to put in columns`))}function ee(e,n){let r=e.fields.filter(R),t=l=>{let d=$(e,e.roles[l]);return R(d)?d:void 0},i=r.find(l=>E(n,l.words)||E(n,y(l.name)))??t("start")??r.find(l=>/^(due|date|on|at|start|starts|begins|from|sown|when)/i.test(l.name))??r[0];if(!i)return h(`no date field on ${e.plural}`);let s=t("end")??r.find(l=>l!==i&&/^(end|ends|until|to|finish|finished|harvested|due|closes|through)/i.test(l.name)),a=e.fields.find(l=>l.type==="boolean"&&/^(done|finished|complete|completed|closed)$/.test(l.name));return{start:i,...s&&s!==i?{end:s}:{},...a?{done:a}:{}}}function ie(e){let n=$(e,e.roles.start),r=$(e,e.roles.end),t=$(e,e.roles.column??e.roles.day??e.roles.columns);if(N(n)&&N(r)&&t?.type==="enum")return{start:n,end:r,column:t}}function De(e,n,r,t){let o=[];for(let s of e.kinds)for(let a of s.edges)for(let l of a.to){let d=e.info(l);if(!d||d.kind===s.kind)continue;let c=0;n.includes(s)&&(c+=4),n.includes(d)&&(c+=4),(Z.test(d.kind)||Z.test(d.noun))&&(c+=3),t&&(a.words.includes(t)||d.noun===x(t))&&(c+=5),a.words.split(" ").some(u=>u.length>2&&r.includes(` ${u}`))&&(c+=2),o.push({rows:s,across:d,link:a,score:c})}let i=o.sort((s,a)=>a.score-s.score)[0];return i||h(n[0]?`${n[0].plural} are joined to nothing else, so there is no who-covers-what to draw`:"nothing here is joined to anything else, so there is no who-covers-what to draw")}function ae(e,n,r,t,o){let i=U(t);switch(e){case"columns":{if(i){let s=v(n,i);if(!s||s.type!=="enum"){let a=oe(n,i,r);if(a){let l=r.info(a.to[0]);return{lens:"coverage",kind:n.kind,across:l.kind,link:a.name}}}}return{lens:"columns",kind:n.kind,column:Se(n,i).name}}case"calendar":{let s=ee(n,t),a=M(t);return{lens:"calendar",kind:n.kind,start:s.start.name,...s.end?{end:s.end.name}:{},...s.done?{done:s.done.name}:{},...a?{range:a}:{}}}case"timeline":{let s=ie(n);if(s&&!/\bdates?\b|\bdue\b|\bdeadlines?\b|\bmonths?\b|\byears?\b/.test(t))return{lens:"timeline",kind:n.kind,start:s.start.name,end:s.end.name,column:s.column.name};let a=ee(n,t);return{lens:"calendar",kind:n.kind,start:a.start.name,...a.end?{end:a.end.name}:{},...a.done?{done:a.done.name}:{},range:M(t)??"quarter"}}case"coverage":{let s=De(r,o,t,i);return{lens:"coverage",kind:s.rows.kind,across:s.across.kind,link:s.link.name}}case"board":{let s=$(n,n.roles.x)??n.fields.find(c=>c.name==="x"),a=$(n,n.roles.y)??n.fields.find(c=>c.name==="y");if(!N(s)||!N(a))return h(`${n.plural} have no x and y to be laid out by`);let d=r.kinds.flatMap(c=>c.edges.filter(u=>u.to.includes(n.kind)&&c.kind!==n.kind))[0]??n.edges[0];return d?{lens:"board",kind:n.kind,x:s.name,y:a.name,fill:d.name,...d.from!==n.kind?{fillFrom:"occupant"}:{}}:h(`nothing is joined to ${n.plural} to fill them`)}case"plan":{let s=$(n,n.roles.outline)??n.fields.find(a=>a.name==="outline");return s?{lens:"plan",kind:n.kind,outline:s.name}:h(`${n.plural} have no outline to draw a plan from`)}case"blocks":{let s={lens:"blocks",kind:n.kind,as:/\bcards?\b/.test(t)?"card":"row"},a=/ group(?:ed)? by ([\p{L}\p{N} -]+?)(?= (?:and|only|sorted|with)|\s*$)/u.exec(t)?.[1]??(i&&!/ sort(?:ed)? by /.test(t)?i:void 0);if(a){let c=v(n,a);if(!c||c.type!=="enum")return h(c?`${n.plural}' ${c.words} is not a choice, so they cannot be grouped by it`:`${n.plural} have nothing called ${a} to group by`);s.group=c.name}let l=/ sort(?:ed)? by ([\p{L}\p{N} -]+?)(?= (?:and|only|grouped|with)|\s*$)/u.exec(t)?.[1];if(l){let c=v(n,l);if(!c)return h(`${n.plural} have nothing called ${l} to sort by`);s.sort={by:c.name,.../\b(newest|latest|desc|descending|most)\b/.test(t)?{direction:"desc"}:{}}}let d=V(n,t);return d.length>0&&(s.where=d),s}}}function V(e,n){let r=[],t=se(n);if(t){let o=e.fields.filter(R),i=$(e,e.roles.start),s=o.find(l=>E(n,l.words))??(R(i)?i:void 0)??o[0];(!s||!R(s))&&h(`no date field on ${e.plural}`);let a=e.fields.find(l=>l.type==="boolean"&&/^(done|finished|complete|completed|closed)$/.test(l.name));r.push({expr:t.cond(s.name,/\boverdue\b|\blate\b|\bpast due\b/.test(n)?a?.name:void 0),says:t.says(s)})}if(/\bonly\b|\bjust\b|\bthat are\b|\bwhich are\b/.test(n)){for(let o of e.fields){if(o.type!=="enum")continue;let i=o.options?.find(s=>E(n,s.toLowerCase())||E(n,y(s)));i&&r.push({expr:`${o.name} == '${i.replace(/'/g,"")}'`,says:`that are ${y(i)}`})}if(/\bnot done\b|\bundone\b|\bunfinished\b|\bopen ones\b|\bstill to do\b/.test(n)){let o=e.fields.find(i=>i.type==="boolean"&&/^(done|finished|complete|completed)$/.test(i.name));o&&r.push({expr:`not ${o.name}`,says:`not ${o.words}`})}}return r}var B={columns:"A board",calendar:"A calendar",timeline:"A timeline",coverage:"A grid",board:"A layout",plan:"A plan",blocks:"A list",reach:"A picture"};function Ae(e,n){let r=n.info(e.kind),t=o=>o?$(r,o)?.words??y(o):"";switch(e.lens){case"columns":return{title:`${k(r.plural)} by ${t(e.column)}`,detail:`of ${r.plural} by ${t(e.column)}`};case"calendar":{let o=e.range??"month";if(o==="agenda")return{title:`${k(r.plural)} in date order`,detail:`of ${r.plural} in order of ${t(e.start)}`};let i=o==="years"?"year":o;return{title:`${k(r.plural)} by ${i}`,detail:`of ${r.plural} by ${t(e.start)}, a ${i} at a time`}}case"timeline":return{title:`${k(r.plural)} over the ${t(e.column)}`,detail:`of ${r.plural} from ${t(e.start)} to ${t(e.end)}, by ${t(e.column)}`};case"coverage":{let o=n.info(e.across);return{title:`${k(r.plural)} by ${o.noun}`,detail:`of which ${o.noun} covers which ${r.noun}`}}case"board":return{title:`${k(r.plural)} where they stand`,detail:`of ${r.plural} where they stand`};case"plan":return{title:`${k(r.plural)} on a plan`,detail:`of ${r.plural}`};default:{let o=[e.where?.map(i=>i.says).join(" and "),e.group?`by ${t(e.group)}`:void 0,e.sort?`in order of ${t(e.sort.by)}`:void 0].filter(i=>!!i);return{title:[k(r.plural),...o].join(" "),detail:[`of ${r.plural}`,...o].join(" ")}}}}function Re(e,n){let r={title:n,on:e.kind};switch(e.lens){case"columns":return{name:"columns",...r,bindings:{[e.kind]:{column:e.column}}};case"calendar":return{name:"calendar",...r,bindings:{[e.kind]:{start:e.start,...e.end?{end:e.end}:{},...e.done?{done:e.done}:{}}},...e.range?{options:{range:e.range}}:{}};case"timeline":return{name:"timeline",...r,bindings:{[e.kind]:{start:e.start,end:e.end,column:e.column}}};case"coverage":return{name:"coverage",...r,bindings:{rows:{kind:e.kind},columns:{kind:e.across},link:{edge:e.link}}};case"board":return{name:"board",...r,bindings:{slots:{kind:e.kind},x:{field:e.x,on:"slots"},y:{field:e.y,on:"slots"},fill:{edge:e.fill}},...e.fillFrom?{options:{fillFrom:e.fillFrom}}:{}};case"plan":return{name:"plan",...r,bindings:{regions:{kind:e.kind},outline:{field:e.outline,on:"regions"}}};default:{let t=e.where?.length?` where ${e.where.map(i=>e.where.length>1?`(${i.expr})`:i.expr).join(" and ")}`:"",o={list:`all('${e.kind}')${t}`,as:e.as??"row"};return e.group&&(o.group=e.group),e.sort&&(o.sort=e.sort.direction?{by:e.sort.by,direction:e.sort.direction}:e.sort.by),o.empty="Nothing here yet.",{name:"blocks",...r,options:{blocks:[o]}}}}}function C(e,n){let r=o=>o.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,""),t=new Set(["home","overview",...Q(n).map(o=>o.slug),...(n.lenses??[]).flatMap(o=>o.title?[r(o.title)]:[])]);if(!t.has(r(e)))return e;for(let o=2;;o++)if(!t.has(r(`${e} ${o}`)))return`${e} ${o}`}var ne={title:[],headline:[],text:["tone"],figure:["as","currency","label"],list:["sort","limit","group","empty","as"],progress:["label"],group:["direction"],when:["show"],divider:[]};function Ee(e,n){if(!Array.isArray(n)||n.length===0)return"it has no blocks to draw";if(n.length>40)return"it has more blocks than a place draws";let r=(s,a)=>{if(typeof s!="string"||s.trim()==="")return`its ${a} says nothing`;try{return _(s)}catch(l){return`its ${a} does not read: ${l instanceof Error?l.message.replace(/ \(at character.*$/,""):String(l)}`}},t=s=>{if(s.t==="where")return t(s.set);if(s.t==="call"&&s.fn==="all"){let a=s.args[0];return a?.t==="lit"&&typeof a.value=="string"?e.info(a.value)??null:void 0}},o=(s,a)=>{switch(s.t){case"lit":return;case"ident":return a&&!a.fields.some(l=>l.name===s.name)&&!a.edges.some(l=>l.name===s.name)?`${a.plural} have nothing called ${s.name}`:void 0;case"member":return o(s.object,a);case"list":return s.items.map(l=>o(l,a)).find(Boolean);case"unary":return o(s.operand,a);case"binary":return o(s.left,a)??o(s.right,a);case"where":{let l=t(s.set);return l===null?"Nothing by that name here":o(s.set,a)??o(s.filter,l??void 0)}case"call":return s.fn==="all"?t(s)===null?"Nothing by that name here":void 0:s.args.map(l=>o(l,a)).find(Boolean)}},i=(s,a)=>{if(a>4)return"its blocks nest deeper than a place draws";for(let l of s){if(!w(l))return"a block is not an object";let d=Object.keys(ne).find(p=>p in l);if(!d)return`"${Object.keys(l)[0]??""}" is not a block a place draws`;let c=Object.keys(l).find(p=>p!==d&&p!=="key"&&!ne[d].includes(p));if(c)return`a ${d} block takes no "${c}"`;let u=l[d];if(d==="list"||d==="figure"||d==="when"){if(d==="figure"&&u===!0)continue;let p=r(u,d);if(typeof p=="string")return p;let g=o(p,void 0);if(g)return g;if(d==="list"){let f=t(p);if(f==null)return f===null?"Nothing by that name here":"its list does not say which records it lists, like all('task')";for(let m of["group","sort"]){let b=l[m],S=typeof b=="string"?b:w(b)&&typeof b.by=="string"?b.by:void 0;if(b===void 0)continue;let D=S?f.fields.find(ce=>ce.name===S):void 0;if(!D)return`${f.plural} have nothing called ${String(S??b)} to ${m} by`;if(m==="group"&&D.type!=="enum")return`${f.plural}' ${D.words} is not a choice, so they cannot be grouped by it`}}if(d==="when"){let f=l.show;if(!Array.isArray(f))return"a when block shows a list of blocks";let m=i(f,a+1);if(m)return m}}else if(d==="group"){if(!Array.isArray(u))return"a group block holds a list of blocks";let p=i(u,a+1);if(p)return p}else{if(d!=="divider"&&typeof u!="string")return`a ${d} block says words`;if(typeof u=="string")for(let p of u.matchAll(/\{([^{}]*)\}/g)){let g=p[1].split(/\|(?![|])/)[0],f=r(g,`${d}'s braces`);if(typeof f=="string")return f;let m=o(f,void 0);if(m)return m}}}};return i(n,1)}function T(e,n,r){let t=L(e.schema,r),o=f=>({ok:!1,failed:`Couldn't draw that: ${f.replace(/\.$/,"")}.`});if(!P(n.name)||n.name==="reach")return o(`"${String(n.name)}" is not a picture the seat can draw; it draws ${H.filter(f=>f!=="reach").join(", ")}`);if(typeof n.title!="string"||n.title.trim().length===0||n.title.length>80)return o("it needs a title of a few words");if(typeof n.on!="string"||!t.tryDefinition(n.on))return o("Nothing by that name here");let i=G[n.name],s=n.bindings??{};if(i.binds==="fields")for(let[f,m]of Object.entries(s)){if(!t.tryDefinition(f))return o("Nothing by that name here");let b=Object.keys(t.tryDefinition(f).fields?.shape??{});for(let[S,D]of Object.entries(m??{}))if(typeof D!="string"||!b.includes(D))return o(`${y(f)} has no field "${String(D)}" for its ${S}`);for(let S of i.requiredRoles)if(!(S in(m??{})))return o(`a ${n.name} needs ${y(f)}'s ${S}`)}else if(i.binds==="entities")for(let f of i.requiredRoles){let m=s[f];if(!m)return o(`a ${n.name} needs its ${f}`);if(typeof m.kind=="string"&&!t.tryDefinition(m.kind))return o("Nothing by that name here")}let a={...e,schema:t,lenses:[...e.lenses??[],n]},l=a.lenses.length-1,d=J(a),c=`lenses.${l}`,u=d.findings.find(f=>f.path===c||f.path.startsWith(`${c}.`));if(u)return o(u.message.replace(/^"[^"]*" /,"it "));let p=d.undrawn.find(f=>f.index===l);if(p)return o(p.why);let g=d.drawn.find(f=>f.index===l);if(!g)return o("its bindings name something the app does not have");if(g.as==="overview")return o(`"${n.title}" is the scene's own address; give it another title`);if(n.name==="blocks"){let f=Ee(I(t),n.options?.blocks);if(f)return o(f)}return{ok:!0,drawn:g}}function K(e){return{op:"add-lens",title:e.title,lens:e.name,on:e.on,...e.bindings?{bindings:e.bindings}:{},...e.options?{options:e.options}:{}}}function xe(e){return{op:"remove-lens",title:e.title,on:e.on}}var w=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function de(e){let n=w(e)?e:{},r=String(n.lens??n.name??""),t=n.bindings,o=typeof n.on=="string"?n.on:w(t)&&G[r]?.binds==="fields"?Object.keys(t)[0]??"":"";return{name:r,title:typeof n.title=="string"?n.title.trim():"",on:o,...w(t)?{bindings:t}:{},...w(n.options)?{options:n.options}:{}}}function ve(e){let n=o=>w(e.bindings?.[o])?e.bindings[o]:{},r=o=>typeof o=="string"?o:void 0,t=n(e.on);switch(e.name){case"columns":return r(t.column)?{lens:"columns",kind:e.on,column:t.column}:void 0;case"calendar":{let o=r(e.options?.range);return r(t.start)?{lens:"calendar",kind:e.on,start:t.start,...r(t.end)?{end:t.end}:{},...r(t.done)?{done:t.done}:{},...o?{range:o}:{}}:void 0}case"timeline":return r(t.start)&&r(t.end)&&r(t.column)?{lens:"timeline",kind:e.on,start:t.start,end:t.end,column:t.column}:void 0;case"coverage":{let o=w(e.bindings?.columns)?r(e.bindings.columns.kind):void 0,i=w(e.bindings?.link)?r(e.bindings.link.edge):void 0;return o&&i?{lens:"coverage",kind:e.on,across:o,link:i}:void 0}case"blocks":{let o=e.options?.blocks;if(!Array.isArray(o)||o.length!==1||!w(o[0]))return;let i=o[0],s=new RegExp(`^all\\('${e.on}'\\)(?: where (.+))?$`).exec(String(i.list??""));if(!s)return;let a=i.sort;return{lens:"blocks",kind:e.on,as:i.as==="card"?"card":"row",...typeof i.group=="string"?{group:i.group}:{},...typeof a=="string"?{sort:{by:a}}:w(a)&&typeof a.by=="string"?{sort:{by:a.by,...a.direction==="desc"?{direction:"desc"}:{}}}:{},...s[1]?{where:[{expr:s[1],says:"as asked"}]}:{}}}default:return}}function W(e,n,r,t,o){let i=I(L(e.schema,t)).info(n.on),s=ve(n);return{title:n.title,said:`${B[n.name]??"A picture"} of ${i?.plural??y(n.on)}.`,kind:n.on,lens:n,drawn:r,edit:K(n),by:o,asks:[],...s?{recipe:s}:{}}}function te(e){return{title:e.title,said:e.said,lens:{title:e.lens.title,lens:e.lens.name,on:e.lens.on,...e.lens.bindings?{bindings:e.lens.bindings}:{},...e.lens.options?{options:e.lens.options}:{}},edit:e.edit,by:e.by,check:"It draws, and graview check would take it."}}function F(e,n,r,t,o){let i=Ae(e,n),s=e.title??o??C(i.title,r.app),a=Re(e,s),l=T(r.app,a,r.sight);return l.ok?{title:s,said:`${B[e.lens]} ${i.detail}.`,kind:e.kind,lens:a,drawn:l.drawn,edit:K(a),by:"template",asks:t,recipe:e}:{failed:l.failed,...r.lastGood?{lastGood:r.lastGood}:{}}}function Ye(e,n){let r=I(L(n.app.schema,n.sight)),t=r.info(e.kind);if(!t)return{failed:"Couldn't draw that: Nothing by that name here."};let o=e.lens==="blocks"&&!e.group&&!e.sort&&!e.where?.length&&e.title===void 0;return F(o?{...e,title:C(`Every ${t.noun}`,n.app)}:e,r,n,[])}function Le(e,n,r,t){if(r.length>0)return r;let o=s=>{switch(e){case"columns":return s.fields.some(a=>a.type==="enum");case"calendar":return s.fields.some(R);case"timeline":return ie(s)!==void 0||s.fields.some(R);case"coverage":return s.edges.some(a=>a.to.some(l=>l!==s.kind));case"board":return s.fields.some(a=>a.name==="x")&&s.fields.some(a=>a.name==="y");case"plan":return s.fields.some(a=>a.name==="outline")||s.roles.outline!==void 0;default:return!0}};return[...n.kinds.filter(o)].sort((s,a)=>Number(a.fields.some(l=>E(t,l.words)))-Number(s.fields.some(l=>E(t,l.words))))}function Ie(e,n){let r=I(L(n.app.schema,n.sight)),t=re(e),o=$e(t);if(o.length===0)return;let i=pe(t,r),s;for(let a of o){let l=a==="coverage"?[i[0]??r.kinds[0]].filter(d=>!!d):Le(a,r,i,t);for(let d of l)try{let c=ae(a,d,r,t,i),u=F(c,r,n,[e]);if(!O(u))return u;s??=u.failed}catch(c){if(!(c instanceof j))throw c;s??=`Couldn't draw that: ${c.message}.`}l.length===0&&i.length===0&&(s??=`Couldn't draw that: nothing here has what ${B[a].toLowerCase()} needs.`)}return{failed:s??"Couldn't draw that: Nothing by that name here.",...n.lastGood?{lastGood:n.lastGood}:{}}}async function Oe(e,n){let r=n.lastGood?{lastGood:n.lastGood}:{};if(e.trim().length===0)return{failed:"Say what you would like to see, like \u201Ca board of tasks by status\u201D.",...r};let t=Ie(e,n);if(t&&!O(t))return t;if(!n.complete)return t??{failed:"Couldn't draw that: drawing freely needs AI, which isn't on here. Ask for a board, a calendar, a timeline, a list or who covers what.",...r};let o=await le(e,n,void 0);return O(o)&&t?t:o}async function je(e,n,r){let t={lastGood:e},o={...r,lastGood:e},i=I(L(r.app.schema,r.sight)),s=re(n),a=i.info(e.kind),l=[...e.asks,n];if(!a)return{failed:"Couldn't change that: Nothing by that name here.",...t};let d=e.recipe,c=/^ (?:call|name|title) (?:it|this)? ?(.+?) $/.exec(s)??/ (?:call|name) it (.+?) $/.exec(s);try{if(c){let g=n.replace(/^.*?\b(?:call|name|title)\b\s*(?:it|this)?\s*/i,"").replace(/^["“']|["”']$/g,"").trim();if(g.length===0)return{failed:"Couldn't change that: say what to call it.",...t};let f={...e.lens,title:C(g,r.app)},m=T(r.app,f,r.sight);return m.ok?{...e,title:f.title,lens:f,drawn:m.drawn,edit:K(f),asks:l,...d?{recipe:{...d,title:f.title}}:{}}:{failed:m.failed,...t}}let p=/ as (?:a |an )?(board|kanban|calendar|timeline|list|table|cards|rows|grid|plan|layout)\b/.exec(s);if(p){let g=p[1]==="board"||p[1]==="kanban"?"columns":p[1]==="calendar"?"calendar":p[1]==="timeline"?"timeline":p[1]==="grid"?"coverage":p[1]==="plan"?"plan":p[1]==="layout"?"board":"blocks",f=ae(g,a,i,s,[a]),m=p[1]==="cards"?"card":p[1]==="rows"?"row":void 0,b=g==="blocks"&&d?.lens==="blocks"?{...d,...m?{as:m}:{}}:g==="blocks"&&d?.lens==="columns"?{...f,group:d.column,...m?{as:m}:{}}:f;return F(A(b),i,o,l)}if(d){let g=Te(d,a,i,s);if(g)return F(g,i,o,l)}}catch(p){if(!(p instanceof j))throw p;return{failed:`Couldn't change that: ${p.message}.`,...t}}if(!r.complete)return{failed:"Couldn't change that: changing it freely needs AI, which isn't on here. Try \u201Cgroup by status\u201D, \u201Conly this month\u201D or \u201Cas a calendar\u201D.",...t};let u=await le(n,o,e);return O(u)?u:{...u,asks:l}}var A=e=>{let{title:n,...r}=e;return r};function Te(e,n,r,t){let o=/ (?:group(?:ed)?|split|organi[sz]ed?|put them|columns) by ([\p{L}\p{N} -]+?)(?= (?:and|only|with)|\s*$)/u.exec(t)?.[1]??(/^ by /.test(t)?U(t):void 0);if(o){let d=v(n,o);if(d?.type==="enum")return e.lens==="blocks"?{...A(e),group:d.name}:{lens:"columns",kind:e.kind,column:d.name};let c=oe(n,o,r);return c?{lens:"coverage",kind:e.kind,across:c.to[0],link:c.name}:h(d?`${n.plural}' ${d.words} is not a choice, so they cannot be grouped by it`:`${n.plural} have nothing called ${o} to group by`)}let i=/ (?:sort(?:ed)?|order(?:ed)?) by ([\p{L}\p{N} -]+?)(?= (?:and|only|with)|\s*$)/u.exec(t)?.[1];if(i){let d=v(n,i);return d?{...e.lens==="blocks"?A(e):{lens:"blocks",kind:e.kind,as:"row",...e.lens==="columns"?{group:e.column}:{}},sort:{by:d.name,.../\b(newest|latest|desc|descending|most)\b/.test(t)?{direction:"desc"}:{}}}:h(`${n.plural} have nothing called ${i} to sort by`)}if(/\b(?:all of them|everything|show all|clear the filter|no filter|without the filter)\b/.test(t)){if(e.lens!=="blocks"||!e.where)return h("it already shows all of them");let{where:d,...c}=A(e);return c}let s=se(t);if(s&&e.lens==="calendar"&&s.range)return{...A(e),range:s.range};if(s&&e.lens==="calendar"&&!s.range)return{lens:"blocks",kind:e.kind,as:"row",sort:{by:e.start},where:V(n,t)};let a=V(n,t);if(a.length>0){let d=e.lens==="blocks"?A(e):{lens:"blocks",kind:e.kind,as:"row",...e.lens==="columns"?{group:e.column}:{}};return{...d,where:[...d.where??[],...a]}}let l=e.lens==="calendar"?M(t):void 0;if(l)return{...A(e),range:l}}function Ne(e){return e.kinds.map(n=>{let r=n.fields.map(i=>`${i.name} (${i.type??"value"}${i.options?`: ${i.options.join(" | ")}`:""})`).join(", "),t=n.edges.map(i=>`${i.name} \u2192 ${i.to.join(" | ")}`).join(", "),o=Object.entries(n.roles).map(([i,s])=>`${i}=${s}`).join(", ");return`- ${n.kind} ("${n.plural}"): ${r}${t?`; relations: ${t}`:""}${o?`; roles: ${o}`:""}`}).join(`
1
+ import{a as k}from"./chunk.G4JJXA63.js";import{a as Q}from"./chunk.QU356VB2.js";import{a as Y}from"./chunk.ZSW74NVJ.js";import{a as X}from"./chunk.PPUAPAWR.js";import{c as _}from"./chunk.FBY5IUGU.js";import{$a as q,Ic as G,Jc as H,Kc as P,Lc as J,ab as z}from"./chunk.X7W27IRI.js";var O=e=>"failed"in e;function ue(e,n){let r=e.schema.kinds,t=e.policy?.sees;if(!t?.length||z(n))return{kinds:r};let o=q(n).roles??[],i=new Set(t.filter(s=>s.roles==="*"||o.some(a=>s.roles.includes(a))).flatMap(s=>s.kinds));return{kinds:r.filter(s=>i.has(s))}}function L(e,n){if(!n)return e;let r=new Set(n.kinds.filter(i=>e.tryDefinition(i)!==void 0));if(r.size===e.kinds.length)return e;let t=new Map,o=i=>{if(r.has(i)){if(!t.has(i)){let s=e.tryDefinition(i),a=Object.fromEntries(Object.entries(s?.edges??{}).flatMap(([l,d])=>{if(d.to==="*")return[[l,d]];let c=d.to.filter(u=>r.has(u));return c.length>0?[[l,{...d,to:c}]]:[]}));t.set(i,{...s,edges:a})}return t.get(i)}};return{...e,definitions:e.definitions.filter(i=>r.has(i.kind)),kinds:e.kinds.filter(i=>r.has(i)),tryDefinition:o,definition:i=>{let s=o(i);if(!s)throw new Error(`Unknown node kind "${i}"`);return s}}}var fe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),y=e=>fe(e).replace(/[-_]+/g," ").trim();function I(e){let n=[];for(let t of e.kinds){let o=e.tryDefinition(t);if(!o)continue;let i=o.display?.labels??{},s=Object.entries(o.fields?.shape??{}).filter(([d])=>d!=="id"&&d!=="kind").map(([d,c])=>{let u=X(c);return{name:d,type:u?.type,...u?.options?{options:u.options}:{},words:(i[d]??y(d)).toLowerCase()}}),a=Object.entries(o.edges??{}).map(([d,c])=>({name:d,from:t,to:c.to==="*"?e.kinds.filter(u=>u!==t):c.to,words:y(d)})),l=(o.plural??`${y(t)}s`).toLowerCase();n.push({kind:t,plural:l,noun:(o.noun??y(t)).toLowerCase(),fields:s,roles:o.fieldRoles??{},edges:a})}let r=new Map(n.map(t=>[t.kind,t]));return{schema:e,kinds:n,info:t=>r.get(t)}}var $=(e,n)=>n===void 0?void 0:e.fields.find(r=>r.name===n),R=e=>e?.type==="date"||e?.type==="datetime",N=e=>e?.type==="number"||e?.type==="integer"||e?.type==="duration",re=e=>` ${e.toLowerCase().replace(/[“”"’‘]/g,"'").replace(/[^\p{L}\p{N}' -]+/gu," ").replace(/\s+/g," ").trim()} `,E=(e,n)=>e.includes(` ${n} `),x=e=>e.endsWith("ies")?`${e.slice(0,-3)}y`:e.endsWith("ses")?e.slice(0,-2):e.endsWith("s")?e.slice(0,-1):e;function pe(e,n){let r=[];for(let t of n.kinds){let o=new Set([t.plural,t.noun,`${t.noun}s`,y(t.kind),`${y(t.kind)}s`]),i=-1;for(let s of o){let a=e.indexOf(` ${s} `);a>=0&&(i<0||a<i)&&(i=a)}i>=0&&r.push({info:t,at:i})}return r.sort((t,o)=>t.at-o.at).map(t=>t.info)}function v(e,n,r){let t=n.trim().toLowerCase();if(t.length===0)return;let o=e.fields.filter(i=>!r||r(i));return o.find(i=>i.words===t||y(i.name)===t||i.name.toLowerCase()===t)??o.find(i=>i.words===x(t)||y(i.name)===x(t))??o.find(i=>t.split(" ").some(s=>s.length>2&&(i.words.split(" ").includes(s)||i.words.split(" ").includes(x(s)))))}function oe(e,n,r){let t=n.trim().toLowerCase();if(t.length!==0)return e.edges.find(o=>o.words===t||o.name.toLowerCase()===t)??e.edges.find(o=>o.to.some(i=>{let s=r.info(i);return s!==void 0&&(s.noun===x(t)||s.plural===t||y(i)===x(t))}))??e.edges.find(o=>t.split(" ").some(i=>i.length>2&&o.words.split(" ").includes(i)))}function U(e){return/ (?:grouped |group |split |sorted |organi[sz]ed )?by ([\p{L}\p{N}' -]+?)(?= (?:and|with|for|in|on|only|where|from|this|that|as|sorted|grouped) |\s*$)/u.exec(e)?.[1]?.trim()}var me=/\bwho\b.*\b(covers?|cover|tends?|owns?|handles?|does|works? on|looks? after|is on|is assigned|staffs?|runs?)\b|\bcoverage\b|\bmatrix\b|\bwho covers\b/,ge=/\bcalendar\b|\bmonth\b|\bagenda\b|\bschedule\b|\bdue\b|\bdeadlines?\b|\bdates?\b|\bwhen\b/,ye=/\btimeline\b|\bover time\b|\bgantt\b|\bspans?\b|\bweek\b/,he=/\bboard\b|\bkanban\b|\bcolumns?\b|\bpipeline\b|\bstages?\b|\bstatus\b/,be=/\blaid out\b|\blayout\b|\bseating\b|\bwhere (?:they|it|each) (?:sits?|lies?|stands?)\b|\bfloor\b/,we=/\bplan\b|\bmap\b|\bregions?\b/,ke=/\blist\b|\btable\b|\bgroup(?:ed)? by\b|\bsort(?:ed)? by\b|\bonly\b|\bjust the\b/;function $e(e){let n=[];return/\blist\b|\btable\b/.test(e)&&n.push("blocks"),me.test(e)&&n.push("coverage"),be.test(e)&&n.push("board"),(/\bfloor plan\b/.test(e)||we.test(e))&&n.push("plan"),ye.test(e)&&n.push("timeline"),ge.test(e)&&n.push("calendar"),he.test(e)&&n.push("columns"),ke.test(e)&&!n.includes("blocks")&&n.push("blocks"),n.length===0&&U(e)&&n.push("columns"),n}var se=e=>{let n=r=>r?` and not ${r}`:"";if(/\boverdue\b|\blate\b|\bpast due\b/.test(e))return{cond:(r,t)=>`days(today(), ${r}) < 0${n(t)}`,says:r=>`overdue by ${r.words}`};if(/\btoday\b/.test(e))return{range:"day",cond:r=>`days(today(), ${r}) == 0`,says:r=>`with ${r.words} today`};if(/\bthis week\b|\bnext 7 days\b|\bnext week\b/.test(e))return{range:"week",cond:r=>`days(today(), ${r}) >= 0 and days(today(), ${r}) <= 6`,says:r=>`with ${r.words} in the next week`};if(/\bthis month\b|\bnext 30 days\b|\bnext month\b/.test(e))return{range:"month",cond:r=>`days(today(), ${r}) >= 0 and days(today(), ${r}) <= 30`,says:r=>`with ${r.words} in the next month`};if(/\blast month\b|\bpast month\b/.test(e))return{range:"month",cond:r=>`days(today(), ${r}) >= -30 and days(today(), ${r}) <= 0`,says:r=>`with ${r.words} in the last month`};if(/\bthis year\b/.test(e))return{range:"year",cond:r=>`days(today(), ${r}) >= 0 and days(today(), ${r}) <= 365`,says:r=>`with ${r.words} in the next year`};if(/\bquarter\b/.test(e))return{range:"quarter",cond:r=>`days(today(), ${r}) >= 0 and days(today(), ${r}) <= 91`,says:r=>`with ${r.words} in the next quarter`}},M=e=>{if(/\bagenda\b|\bin order\b/.test(e))return"agenda";if(/\btoday\b|\bday\b/.test(e))return"day";if(/\bweek\b/.test(e))return"week";if(/\bquarter\b/.test(e))return"quarter";if(/\byears\b/.test(e))return"years";if(/\byear\b/.test(e))return"year";if(/\bmonth\b/.test(e))return"month"},Z=/^(user|person|people|member|staff|gardener|volunteer|owner|agent|employee|worker|team|player|customer|client|contact|party|attendee|guest)s?$/,j=class extends Error{},h=e=>{throw new j(e)};function Se(e,n){let r=e.fields.filter(i=>i.type==="enum");if(n){let i=v(e,n);if(i&&i.type==="enum")return i;i&&h(`${e.plural}' ${i.words} is not a choice, so it has no columns`)}let t=$(e,e.roles.status??e.roles.column);if(t?.type==="enum")return t;let o=r.find(i=>/^(status|stage|state|phase)$/.test(i.name));return o||(r[0]?r[0]:h(`${e.plural} have no choice field to put in columns`))}function ee(e,n){let r=e.fields.filter(R),t=l=>{let d=$(e,e.roles[l]);return R(d)?d:void 0},i=r.find(l=>E(n,l.words)||E(n,y(l.name)))??t("start")??r.find(l=>/^(due|date|on|at|start|starts|begins|from|sown|when)/i.test(l.name))??r[0];if(!i)return h(`no date field on ${e.plural}`);let s=t("end")??r.find(l=>l!==i&&/^(end|ends|until|to|finish|finished|harvested|due|closes|through)/i.test(l.name)),a=e.fields.find(l=>l.type==="boolean"&&/^(done|finished|complete|completed|closed)$/.test(l.name));return{start:i,...s&&s!==i?{end:s}:{},...a?{done:a}:{}}}function ie(e){let n=$(e,e.roles.start),r=$(e,e.roles.end),t=$(e,e.roles.column??e.roles.day??e.roles.columns);if(N(n)&&N(r)&&t?.type==="enum")return{start:n,end:r,column:t}}function De(e,n,r,t){let o=[];for(let s of e.kinds)for(let a of s.edges)for(let l of a.to){let d=e.info(l);if(!d||d.kind===s.kind)continue;let c=0;n.includes(s)&&(c+=4),n.includes(d)&&(c+=4),(Z.test(d.kind)||Z.test(d.noun))&&(c+=3),t&&(a.words.includes(t)||d.noun===x(t))&&(c+=5),a.words.split(" ").some(u=>u.length>2&&r.includes(` ${u}`))&&(c+=2),o.push({rows:s,across:d,link:a,score:c})}let i=o.sort((s,a)=>a.score-s.score)[0];return i||h(n[0]?`${n[0].plural} are joined to nothing else, so there is no who-covers-what to draw`:"nothing here is joined to anything else, so there is no who-covers-what to draw")}function ae(e,n,r,t,o){let i=U(t);switch(e){case"columns":{if(i){let s=v(n,i);if(!s||s.type!=="enum"){let a=oe(n,i,r);if(a){let l=r.info(a.to[0]);return{lens:"coverage",kind:n.kind,across:l.kind,link:a.name}}}}return{lens:"columns",kind:n.kind,column:Se(n,i).name}}case"calendar":{let s=ee(n,t),a=M(t);return{lens:"calendar",kind:n.kind,start:s.start.name,...s.end?{end:s.end.name}:{},...s.done?{done:s.done.name}:{},...a?{range:a}:{}}}case"timeline":{let s=ie(n);if(s&&!/\bdates?\b|\bdue\b|\bdeadlines?\b|\bmonths?\b|\byears?\b/.test(t))return{lens:"timeline",kind:n.kind,start:s.start.name,end:s.end.name,column:s.column.name};let a=ee(n,t);return{lens:"calendar",kind:n.kind,start:a.start.name,...a.end?{end:a.end.name}:{},...a.done?{done:a.done.name}:{},range:M(t)??"quarter"}}case"coverage":{let s=De(r,o,t,i);return{lens:"coverage",kind:s.rows.kind,across:s.across.kind,link:s.link.name}}case"board":{let s=$(n,n.roles.x)??n.fields.find(c=>c.name==="x"),a=$(n,n.roles.y)??n.fields.find(c=>c.name==="y");if(!N(s)||!N(a))return h(`${n.plural} have no x and y to be laid out by`);let d=r.kinds.flatMap(c=>c.edges.filter(u=>u.to.includes(n.kind)&&c.kind!==n.kind))[0]??n.edges[0];return d?{lens:"board",kind:n.kind,x:s.name,y:a.name,fill:d.name,...d.from!==n.kind?{fillFrom:"occupant"}:{}}:h(`nothing is joined to ${n.plural} to fill them`)}case"plan":{let s=$(n,n.roles.outline)??n.fields.find(a=>a.name==="outline");return s?{lens:"plan",kind:n.kind,outline:s.name}:h(`${n.plural} have no outline to draw a plan from`)}case"blocks":{let s={lens:"blocks",kind:n.kind,as:/\bcards?\b/.test(t)?"card":"row"},a=/ group(?:ed)? by ([\p{L}\p{N} -]+?)(?= (?:and|only|sorted|with)|\s*$)/u.exec(t)?.[1]??(i&&!/ sort(?:ed)? by /.test(t)?i:void 0);if(a){let c=v(n,a);if(!c||c.type!=="enum")return h(c?`${n.plural}' ${c.words} is not a choice, so they cannot be grouped by it`:`${n.plural} have nothing called ${a} to group by`);s.group=c.name}let l=/ sort(?:ed)? by ([\p{L}\p{N} -]+?)(?= (?:and|only|grouped|with)|\s*$)/u.exec(t)?.[1];if(l){let c=v(n,l);if(!c)return h(`${n.plural} have nothing called ${l} to sort by`);s.sort={by:c.name,.../\b(newest|latest|desc|descending|most)\b/.test(t)?{direction:"desc"}:{}}}let d=V(n,t);return d.length>0&&(s.where=d),s}}}function V(e,n){let r=[],t=se(n);if(t){let o=e.fields.filter(R),i=$(e,e.roles.start),s=o.find(l=>E(n,l.words))??(R(i)?i:void 0)??o[0];(!s||!R(s))&&h(`no date field on ${e.plural}`);let a=e.fields.find(l=>l.type==="boolean"&&/^(done|finished|complete|completed|closed)$/.test(l.name));r.push({expr:t.cond(s.name,/\boverdue\b|\blate\b|\bpast due\b/.test(n)?a?.name:void 0),says:t.says(s)})}if(/\bonly\b|\bjust\b|\bthat are\b|\bwhich are\b/.test(n)){for(let o of e.fields){if(o.type!=="enum")continue;let i=o.options?.find(s=>E(n,s.toLowerCase())||E(n,y(s)));i&&r.push({expr:`${o.name} == '${i.replace(/'/g,"")}'`,says:`that are ${y(i)}`})}if(/\bnot done\b|\bundone\b|\bunfinished\b|\bopen ones\b|\bstill to do\b/.test(n)){let o=e.fields.find(i=>i.type==="boolean"&&/^(done|finished|complete|completed)$/.test(i.name));o&&r.push({expr:`not ${o.name}`,says:`not ${o.words}`})}}return r}var B={columns:"A board",calendar:"A calendar",timeline:"A timeline",coverage:"A grid",board:"A layout",plan:"A plan",blocks:"A list",reach:"A picture"};function Ae(e,n){let r=n.info(e.kind),t=o=>o?$(r,o)?.words??y(o):"";switch(e.lens){case"columns":return{title:`${k(r.plural)} by ${t(e.column)}`,detail:`of ${r.plural} by ${t(e.column)}`};case"calendar":{let o=e.range??"month";if(o==="agenda")return{title:`${k(r.plural)} in date order`,detail:`of ${r.plural} in order of ${t(e.start)}`};let i=o==="years"?"year":o;return{title:`${k(r.plural)} by ${i}`,detail:`of ${r.plural} by ${t(e.start)}, a ${i} at a time`}}case"timeline":return{title:`${k(r.plural)} over the ${t(e.column)}`,detail:`of ${r.plural} from ${t(e.start)} to ${t(e.end)}, by ${t(e.column)}`};case"coverage":{let o=n.info(e.across);return{title:`${k(r.plural)} by ${o.noun}`,detail:`of which ${o.noun} covers which ${r.noun}`}}case"board":return{title:`${k(r.plural)} where they stand`,detail:`of ${r.plural} where they stand`};case"plan":return{title:`${k(r.plural)} on a plan`,detail:`of ${r.plural}`};default:{let o=[e.where?.map(i=>i.says).join(" and "),e.group?`by ${t(e.group)}`:void 0,e.sort?`in order of ${t(e.sort.by)}`:void 0].filter(i=>!!i);return{title:[k(r.plural),...o].join(" "),detail:[`of ${r.plural}`,...o].join(" ")}}}}function Re(e,n){let r={title:n,on:e.kind};switch(e.lens){case"columns":return{name:"columns",...r,bindings:{[e.kind]:{column:e.column}}};case"calendar":return{name:"calendar",...r,bindings:{[e.kind]:{start:e.start,...e.end?{end:e.end}:{},...e.done?{done:e.done}:{}}},...e.range?{options:{range:e.range}}:{}};case"timeline":return{name:"timeline",...r,bindings:{[e.kind]:{start:e.start,end:e.end,column:e.column}}};case"coverage":return{name:"coverage",...r,bindings:{rows:{kind:e.kind},columns:{kind:e.across},link:{edge:e.link}}};case"board":return{name:"board",...r,bindings:{slots:{kind:e.kind},x:{field:e.x,on:"slots"},y:{field:e.y,on:"slots"},fill:{edge:e.fill}},...e.fillFrom?{options:{fillFrom:e.fillFrom}}:{}};case"plan":return{name:"plan",...r,bindings:{regions:{kind:e.kind},outline:{field:e.outline,on:"regions"}}};default:{let t=e.where?.length?` where ${e.where.map(i=>e.where.length>1?`(${i.expr})`:i.expr).join(" and ")}`:"",o={list:`all('${e.kind}')${t}`,as:e.as??"row"};return e.group&&(o.group=e.group),e.sort&&(o.sort=e.sort.direction?{by:e.sort.by,direction:e.sort.direction}:e.sort.by),o.empty="Nothing here yet.",{name:"blocks",...r,options:{blocks:[o]}}}}}function C(e,n){let r=o=>o.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,""),t=new Set(["home","overview",...Q(n).map(o=>o.slug),...(n.lenses??[]).flatMap(o=>o.title?[r(o.title)]:[])]);if(!t.has(r(e)))return e;for(let o=2;;o++)if(!t.has(r(`${e} ${o}`)))return`${e} ${o}`}var ne={title:[],headline:[],text:["tone"],figure:["as","currency","label"],list:["sort","limit","group","empty","as"],progress:["label"],group:["direction"],when:["show"],divider:[]};function Ee(e,n){if(!Array.isArray(n)||n.length===0)return"it has no blocks to draw";if(n.length>40)return"it has more blocks than a place draws";let r=(s,a)=>{if(typeof s!="string"||s.trim()==="")return`its ${a} says nothing`;try{return _(s)}catch(l){return`its ${a} does not read: ${l instanceof Error?l.message.replace(/ \(at character.*$/,""):String(l)}`}},t=s=>{if(s.t==="where")return t(s.set);if(s.t==="call"&&s.fn==="all"){let a=s.args[0];return a?.t==="lit"&&typeof a.value=="string"?e.info(a.value)??null:void 0}},o=(s,a)=>{switch(s.t){case"lit":return;case"ident":return a&&!a.fields.some(l=>l.name===s.name)&&!a.edges.some(l=>l.name===s.name)?`${a.plural} have nothing called ${s.name}`:void 0;case"member":return o(s.object,a);case"list":return s.items.map(l=>o(l,a)).find(Boolean);case"unary":return o(s.operand,a);case"binary":return o(s.left,a)??o(s.right,a);case"where":{let l=t(s.set);return l===null?"Nothing by that name here":o(s.set,a)??o(s.filter,l??void 0)}case"call":return s.fn==="all"?t(s)===null?"Nothing by that name here":void 0:s.args.map(l=>o(l,a)).find(Boolean)}},i=(s,a)=>{if(a>4)return"its blocks nest deeper than a place draws";for(let l of s){if(!w(l))return"a block is not an object";let d=Object.keys(ne).find(p=>p in l);if(!d)return`"${Object.keys(l)[0]??""}" is not a block a place draws`;let c=Object.keys(l).find(p=>p!==d&&p!=="key"&&!ne[d].includes(p));if(c)return`a ${d} block takes no "${c}"`;let u=l[d];if(d==="list"||d==="figure"||d==="when"){if(d==="figure"&&u===!0)continue;let p=r(u,d);if(typeof p=="string")return p;let g=o(p,void 0);if(g)return g;if(d==="list"){let f=t(p);if(f==null)return f===null?"Nothing by that name here":"its list does not say which records it lists, like all('task')";for(let m of["group","sort"]){let b=l[m],S=typeof b=="string"?b:w(b)&&typeof b.by=="string"?b.by:void 0;if(b===void 0)continue;let D=S?f.fields.find(ce=>ce.name===S):void 0;if(!D)return`${f.plural} have nothing called ${String(S??b)} to ${m} by`;if(m==="group"&&D.type!=="enum")return`${f.plural}' ${D.words} is not a choice, so they cannot be grouped by it`}}if(d==="when"){let f=l.show;if(!Array.isArray(f))return"a when block shows a list of blocks";let m=i(f,a+1);if(m)return m}}else if(d==="group"){if(!Array.isArray(u))return"a group block holds a list of blocks";let p=i(u,a+1);if(p)return p}else{if(d!=="divider"&&typeof u!="string")return`a ${d} block says words`;if(typeof u=="string")for(let p of u.matchAll(/\{([^{}]*)\}/g)){let g=p[1].split(/\|(?![|])/)[0],f=r(g,`${d}'s braces`);if(typeof f=="string")return f;let m=o(f,void 0);if(m)return m}}}};return i(n,1)}function T(e,n,r){let t=L(e.schema,r),o=f=>({ok:!1,failed:`Couldn't draw that: ${f.replace(/\.$/,"")}.`});if(!P(n.name)||n.name==="reach")return o(`"${String(n.name)}" is not a picture the seat can draw; it draws ${H.filter(f=>f!=="reach").join(", ")}`);if(typeof n.title!="string"||n.title.trim().length===0||n.title.length>80)return o("it needs a title of a few words");if(typeof n.on!="string"||!t.tryDefinition(n.on))return o("Nothing by that name here");let i=G[n.name],s=n.bindings??{};if(i.binds==="fields")for(let[f,m]of Object.entries(s)){if(!t.tryDefinition(f))return o("Nothing by that name here");let b=Object.keys(t.tryDefinition(f).fields?.shape??{});for(let[S,D]of Object.entries(m??{}))if(typeof D!="string"||!b.includes(D))return o(`${y(f)} has no field "${String(D)}" for its ${S}`);for(let S of i.requiredRoles)if(!(S in(m??{})))return o(`a ${n.name} needs ${y(f)}'s ${S}`)}else if(i.binds==="entities")for(let f of i.requiredRoles){let m=s[f];if(!m)return o(`a ${n.name} needs its ${f}`);if(typeof m.kind=="string"&&!t.tryDefinition(m.kind))return o("Nothing by that name here")}let a={...e,schema:t,lenses:[...e.lenses??[],n]},l=a.lenses.length-1,d=J(a),c=`lenses.${l}`,u=d.findings.find(f=>f.path===c||f.path.startsWith(`${c}.`));if(u)return o(u.message.replace(/^"[^"]*" /,"it "));let p=d.undrawn.find(f=>f.index===l);if(p)return o(p.why);let g=d.drawn.find(f=>f.index===l);if(!g)return o("its bindings name something the app does not have");if(g.as==="overview")return o(`"${n.title}" is the scene's own address; give it another title`);if(n.name==="blocks"){let f=Ee(I(t),n.options?.blocks);if(f)return o(f)}return{ok:!0,drawn:g}}function K(e){return{op:"add-lens",title:e.title,lens:e.name,on:e.on,...e.bindings?{bindings:e.bindings}:{},...e.options?{options:e.options}:{}}}function xe(e){return{op:"remove-lens",title:e.title,on:e.on}}var w=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function de(e){let n=w(e)?e:{},r=String(n.lens??n.name??""),t=n.bindings,o=typeof n.on=="string"?n.on:w(t)&&G[r]?.binds==="fields"?Object.keys(t)[0]??"":"";return{name:r,title:typeof n.title=="string"?n.title.trim():"",on:o,...w(t)?{bindings:t}:{},...w(n.options)?{options:n.options}:{}}}function ve(e){let n=o=>w(e.bindings?.[o])?e.bindings[o]:{},r=o=>typeof o=="string"?o:void 0,t=n(e.on);switch(e.name){case"columns":return r(t.column)?{lens:"columns",kind:e.on,column:t.column}:void 0;case"calendar":{let o=r(e.options?.range);return r(t.start)?{lens:"calendar",kind:e.on,start:t.start,...r(t.end)?{end:t.end}:{},...r(t.done)?{done:t.done}:{},...o?{range:o}:{}}:void 0}case"timeline":return r(t.start)&&r(t.end)&&r(t.column)?{lens:"timeline",kind:e.on,start:t.start,end:t.end,column:t.column}:void 0;case"coverage":{let o=w(e.bindings?.columns)?r(e.bindings.columns.kind):void 0,i=w(e.bindings?.link)?r(e.bindings.link.edge):void 0;return o&&i?{lens:"coverage",kind:e.on,across:o,link:i}:void 0}case"blocks":{let o=e.options?.blocks;if(!Array.isArray(o)||o.length!==1||!w(o[0]))return;let i=o[0],s=new RegExp(`^all\\('${e.on}'\\)(?: where (.+))?$`).exec(String(i.list??""));if(!s)return;let a=i.sort;return{lens:"blocks",kind:e.on,as:i.as==="card"?"card":"row",...typeof i.group=="string"?{group:i.group}:{},...typeof a=="string"?{sort:{by:a}}:w(a)&&typeof a.by=="string"?{sort:{by:a.by,...a.direction==="desc"?{direction:"desc"}:{}}}:{},...s[1]?{where:[{expr:s[1],says:"as asked"}]}:{}}}default:return}}function W(e,n,r,t,o){let i=I(L(e.schema,t)).info(n.on),s=ve(n);return{title:n.title,said:`${B[n.name]??"A picture"} of ${i?.plural??y(n.on)}.`,kind:n.on,lens:n,drawn:r,edit:K(n),by:o,asks:[],...s?{recipe:s}:{}}}function te(e){return{title:e.title,said:e.said,lens:{title:e.lens.title,lens:e.lens.name,on:e.lens.on,...e.lens.bindings?{bindings:e.lens.bindings}:{},...e.lens.options?{options:e.lens.options}:{}},edit:e.edit,by:e.by,check:"It draws, and graview check would take it."}}function F(e,n,r,t,o){let i=Ae(e,n),s=e.title??o??C(i.title,r.app),a=Re(e,s),l=T(r.app,a,r.sight);return l.ok?{title:s,said:`${B[e.lens]} ${i.detail}.`,kind:e.kind,lens:a,drawn:l.drawn,edit:K(a),by:"template",asks:t,recipe:e}:{failed:l.failed,...r.lastGood?{lastGood:r.lastGood}:{}}}function Ye(e,n){let r=I(L(n.app.schema,n.sight)),t=r.info(e.kind);if(!t)return{failed:"Couldn't draw that: Nothing by that name here."};let o=e.lens==="blocks"&&!e.group&&!e.sort&&!e.where?.length&&e.title===void 0;return F(o?{...e,title:C(`Every ${t.noun}`,n.app)}:e,r,n,[])}function Le(e,n,r,t){if(r.length>0)return r;let o=s=>{switch(e){case"columns":return s.fields.some(a=>a.type==="enum");case"calendar":return s.fields.some(R);case"timeline":return ie(s)!==void 0||s.fields.some(R);case"coverage":return s.edges.some(a=>a.to.some(l=>l!==s.kind));case"board":return s.fields.some(a=>a.name==="x")&&s.fields.some(a=>a.name==="y");case"plan":return s.fields.some(a=>a.name==="outline")||s.roles.outline!==void 0;default:return!0}};return[...n.kinds.filter(o)].sort((s,a)=>Number(a.fields.some(l=>E(t,l.words)))-Number(s.fields.some(l=>E(t,l.words))))}function Ie(e,n){let r=I(L(n.app.schema,n.sight)),t=re(e),o=$e(t);if(o.length===0)return;let i=pe(t,r),s;for(let a of o){let l=a==="coverage"?[i[0]??r.kinds[0]].filter(d=>!!d):Le(a,r,i,t);for(let d of l)try{let c=ae(a,d,r,t,i),u=F(c,r,n,[e]);if(!O(u))return u;s??=u.failed}catch(c){if(!(c instanceof j))throw c;s??=`Couldn't draw that: ${c.message}.`}l.length===0&&i.length===0&&(s??=`Couldn't draw that: nothing here has what ${B[a].toLowerCase()} needs.`)}return{failed:s??"Couldn't draw that: Nothing by that name here.",...n.lastGood?{lastGood:n.lastGood}:{}}}async function Oe(e,n){let r=n.lastGood?{lastGood:n.lastGood}:{};if(e.trim().length===0)return{failed:"Say what you would like to see, like \u201Ca board of tasks by status\u201D.",...r};let t=Ie(e,n);if(t&&!O(t))return t;if(!n.complete)return t??{failed:"Couldn't draw that: drawing freely needs AI, which isn't on here. Ask for a board, a calendar, a timeline, a list or who covers what.",...r};let o=await le(e,n,void 0);return O(o)&&t?t:o}async function je(e,n,r){let t={lastGood:e},o={...r,lastGood:e},i=I(L(r.app.schema,r.sight)),s=re(n),a=i.info(e.kind),l=[...e.asks,n];if(!a)return{failed:"Couldn't change that: Nothing by that name here.",...t};let d=e.recipe,c=/^ (?:call|name|title) (?:it|this)? ?(.+?) $/.exec(s)??/ (?:call|name) it (.+?) $/.exec(s);try{if(c){let g=n.replace(/^.*?\b(?:call|name|title)\b\s*(?:it|this)?\s*/i,"").replace(/^["“']|["”']$/g,"").trim();if(g.length===0)return{failed:"Couldn't change that: say what to call it.",...t};let f={...e.lens,title:C(g,r.app)},m=T(r.app,f,r.sight);return m.ok?{...e,title:f.title,lens:f,drawn:m.drawn,edit:K(f),asks:l,...d?{recipe:{...d,title:f.title}}:{}}:{failed:m.failed,...t}}let p=/ as (?:a |an )?(board|kanban|calendar|timeline|list|table|cards|rows|grid|plan|layout)\b/.exec(s);if(p){let g=p[1]==="board"||p[1]==="kanban"?"columns":p[1]==="calendar"?"calendar":p[1]==="timeline"?"timeline":p[1]==="grid"?"coverage":p[1]==="plan"?"plan":p[1]==="layout"?"board":"blocks",f=ae(g,a,i,s,[a]),m=p[1]==="cards"?"card":p[1]==="rows"?"row":void 0,b=g==="blocks"&&d?.lens==="blocks"?{...d,...m?{as:m}:{}}:g==="blocks"&&d?.lens==="columns"?{...f,group:d.column,...m?{as:m}:{}}:f;return F(A(b),i,o,l)}if(d){let g=Te(d,a,i,s);if(g)return F(g,i,o,l)}}catch(p){if(!(p instanceof j))throw p;return{failed:`Couldn't change that: ${p.message}.`,...t}}if(!r.complete)return{failed:"Couldn't change that: changing it freely needs AI, which isn't on here. Try \u201Cgroup by status\u201D, \u201Conly this month\u201D or \u201Cas a calendar\u201D.",...t};let u=await le(n,o,e);return O(u)?u:{...u,asks:l}}var A=e=>{let{title:n,...r}=e;return r};function Te(e,n,r,t){let o=/ (?:group(?:ed)?|split|organi[sz]ed?|put them|columns) by ([\p{L}\p{N} -]+?)(?= (?:and|only|with)|\s*$)/u.exec(t)?.[1]??(/^ by /.test(t)?U(t):void 0);if(o){let d=v(n,o);if(d?.type==="enum")return e.lens==="blocks"?{...A(e),group:d.name}:{lens:"columns",kind:e.kind,column:d.name};let c=oe(n,o,r);return c?{lens:"coverage",kind:e.kind,across:c.to[0],link:c.name}:h(d?`${n.plural}' ${d.words} is not a choice, so they cannot be grouped by it`:`${n.plural} have nothing called ${o} to group by`)}let i=/ (?:sort(?:ed)?|order(?:ed)?) by ([\p{L}\p{N} -]+?)(?= (?:and|only|with)|\s*$)/u.exec(t)?.[1];if(i){let d=v(n,i);return d?{...e.lens==="blocks"?A(e):{lens:"blocks",kind:e.kind,as:"row",...e.lens==="columns"?{group:e.column}:{}},sort:{by:d.name,.../\b(newest|latest|desc|descending|most)\b/.test(t)?{direction:"desc"}:{}}}:h(`${n.plural} have nothing called ${i} to sort by`)}if(/\b(?:all of them|everything|show all|clear the filter|no filter|without the filter)\b/.test(t)){if(e.lens!=="blocks"||!e.where)return h("it already shows all of them");let{where:d,...c}=A(e);return c}let s=se(t);if(s&&e.lens==="calendar"&&s.range)return{...A(e),range:s.range};if(s&&e.lens==="calendar"&&!s.range)return{lens:"blocks",kind:e.kind,as:"row",sort:{by:e.start},where:V(n,t)};let a=V(n,t);if(a.length>0){let d=e.lens==="blocks"?A(e):{lens:"blocks",kind:e.kind,as:"row",...e.lens==="columns"?{group:e.column}:{}};return{...d,where:[...d.where??[],...a]}}let l=e.lens==="calendar"?M(t):void 0;if(l)return{...A(e),range:l}}function Ne(e){return e.kinds.map(n=>{let r=n.fields.map(i=>`${i.name} (${i.type??"value"}${i.options?`: ${i.options.join(" | ")}`:""})`).join(", "),t=n.edges.map(i=>`${i.name} \u2192 ${i.to.join(" | ")}`).join(", "),o=Object.entries(n.roles).map(([i,s])=>`${i}=${s}`).join(", ");return`- ${n.kind} ("${n.plural}"): ${r}${t?`; relations: ${t}`:""}${o?`; roles: ${o}`:""}`}).join(`
2
2
  `)}var Fe=['columns \u2014 a board, records in columns by one choice field: {"lens": "columns", "on": K, "bindings": {K: {"column": "<enum field>"}}}','calendar \u2014 records on a calendar by a date: {"lens": "calendar", "on": K, "bindings": {K: {"start": "<date field>", "end"?: "<date field>", "done"?: "<boolean field>"}}, "options": {"range"?: "day" | "week" | "month" | "quarter" | "year" | "agenda"}}','timeline \u2014 minutes of a day in columns: {"lens": "timeline", "on": K, "bindings": {K: {"start": "<number field>", "end": "<number field>", "column": "<enum field>"}}}','coverage \u2014 who covers what, a grid of two kinds joined by a relation: {"lens": "coverage", "on": K, "bindings": {"rows": {"kind": K}, "columns": {"kind": J}, "link": {"edge": "<relation of K to J>"}}}',`blocks \u2014 anything else, as blocks: {"lens": "blocks", "on": K, "options": {"blocks": [{"headline": "words"}, {"list": "all('K') where <condition>", "group"?: "<enum field>", "sort"?: "<field>" | {"by": "<field>", "direction": "desc"}, "as"?: "row" | "card", "empty"?: "words"}, {"figure": "count(all('K'))", "label": "words"}]}}. Conditions read a record's own fields: status == 'open', not done, days(today(), due) <= 7.`].join(`
3
3
  `);function Ce(e,n,r){return["You draw a view of an app's data as JSON \u2014 never code. The app's kinds, their fields (with types) and relations:",Ne(n),"","The lenses you may use (prefer the first four; use blocks only when none of them fits):",Fe,"",r?`The view on screen now:
4
4
  ${JSON.stringify(r.lens)}
@@ -1 +1 @@
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 q,g as Z,h as ee}from"./chunk.LR3VDXPI.js";import{a as Q,b as X}from"./chunk.COQKECUH.js";import{b}from"./chunk.EJPI3ST6.js";import{d as D}from"./chunk.3K6YSVHC.js";import{a as K}from"./chunk.UT6642FC.js";import{h as A}from"./chunk.B2GLDIAS.js";import{m as J}from"./chunk.JOOQUWLT.js";import{F,I as P,N as L,O as T,Q as U,Y as m,a as $,ea as G,sa as V,wa as Y,xa as _}from"./chunk.6QWV5MVH.js";import{La as z,X as B,Z as E,fb as R}from"./chunk.MNP4JI33.js";import{b as W}from"./chunk.AJZBJBMO.js";var u=W(F(),1);var te=W(F(),1);function ne(){let{ai:i,aiDesk:n}=m(),{entries:a}=P(n),r=i.off===!0;return(0,te.useEffect)(()=>{r||n.load()},[n,r]),r?[]:a}var e=W(U(),1),ae=_($(()=>(__graviewPreload(import.meta.url,["./chunk.NTF7FVB2.js","./chunk.5UL7YDUD.js","./chunk.JOOQUWLT.js","./chunk.6QWV5MVH.js","./chunk.MNP4JI33.js","./chunk.AJZBJBMO.js"]),import("./chunk.EYTBDMTW.js")))),pe=ae.part((i,n)=>(0,e.jsx)(i.InteractionRow,{...n}),{quiet:!0,as:"li"}),ge=ae.part((i,n)=>(0,e.jsx)(i.ActivityFilter,{...n}),{quiet:!0,as:"div"}),ie=(i,n)=>({intent:n.intent,author:n.author.kind,...n.author.id?{authorId:n.author.id}:{},by:n.author,...n.ops[0]?.via?{via:n.ops[0].via}:{},...n.lineage?{basis:K(n.lineage)}:{},touched:[...new Set(n.ops.filter(a=>!R(a)).flatMap(a=>a.writes))],...he(i,n.ops.filter(a=>!R(a))),batch:n.id,at:n.at,...n.lineage?.interaction?{interaction:n.lineage.interaction}:{},seq:n.ops.at(-1).seq+1,...n.ops.every(R)?{withheld:!0}:{}});function ue(i=4){let{store:n,principal:a}=m(),r=T(n,a),d=r.log.length;return(0,u.useMemo)(()=>Q(r.batches(),s=>r.log.get(s)).reverse().slice(0,i).map(s=>{if("batch"in s)return ie(r,s.batch);let o=[...s.digest.batches].reverse().map(l=>ie(r,l));return{intent:X(s.digest,new Date().toISOString().slice(0,10)),author:s.digest.author.kind,...s.digest.author.id?{authorId:s.digest.author.id}:{},by:s.digest.author,touched:[...new Set(o.flatMap(l=>l.touched))],batch:"",...o[0]?.at?{at:o[0].at}:{},seq:o[0]?.seq??0,digest:o}}),[r,d,i])}function he(i,n){let a={};for(let r of n)for(let d of r.primitives)d.op==="remove-node"&&d.node&&(a[d.node.id]=B(i.schema.tryDefinition(d.node.kind),d.node));return Object.keys(a).length>0?{removed:a}:{}}function ce({change:i}){let{store:n,principal:a,seats:r,people:d}=m();return(0,e.jsxs)("strong",{style:{fontWeight:600},children:[i.author==="human"&&i.by?.onBehalfOf===void 0&&(i.authorId===void 0||a.id===void 0||i.authorId===a.id)?"you":z(i.by??{kind:i.author,id:i.authorId},{graph:n.graph,schema:n.schema,seats:r,people:d}),A(i.via)?(0,e.jsxs)("span",{style:{fontWeight:400,color:"var(--graview-ink-muted)"},children:[", ",A(i.via)]}):null]})}function ye({change:i,goes:n}){let{store:a}=m(),[r,d]=(0,u.useState)(!1),s=i.digest??[];return(0,e.jsxs)("li",{"data-testid":"activity-digest",style:{display:"grid",gap:5,lineHeight:1.45},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[(0,e.jsxs)("span",{style:{minWidth:0},children:[(0,e.jsx)(ce,{change:i})," ",(0,e.jsx)("span",{style:{color:"var(--graview-ink-muted)"},children:i.intent})]}),(0,e.jsx)("button",{type:"button","data-testid":"digest-toggle","aria-expanded":r,onClick:()=>d(o=>!o),style:{marginLeft:"auto",flex:"0 0 auto",display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24,padding:"1px 8px",fontSize:"0.75rem"},children:r?"Hide":"Show each"})]}),r?(0,e.jsx)("ol",{"data-testid":"digest-changes",style:{margin:0,padding:"0 0 0 10px",listStyle:"none",display:"grid",gap:6,borderLeft:"1px solid var(--graview-edge)"},children:s.map(o=>(0,e.jsxs)("li",{"data-testid":"digest-change",style:{display:"grid",gap:3},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[(0,e.jsxs)("span",{style:{minWidth:0},children:[(0,e.jsx)("span",{style:{color:"var(--graview-ink-muted)"},children:o.intent}),o.basis?(0,e.jsxs)("span",{"data-graview-lineage":"",style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",o.basis]}):null]}),o.withheld?null:(0,e.jsx)(M,{batch:o.batch})]}),o.touched.length>0?(0,e.jsx)("div",{"data-touched":o.touched.join(" "),style:{display:"flex",flexWrap:"wrap",gap:4},children:o.touched.slice(0,4).map(l=>(0,e.jsx)(O,{id:l,label:a.graph.has(l)?b(a,l):o.removed?.[l]??b(a,l),go:n(l)},l))}):null]},o.batch))}):null]})}function M({batch:i}){let{store:n,principal:a,noteSeat:r}=m(),d=T(n,a),s=L()?.open??!1,o=d.log.length,[l,v]=(0,u.useState)(null),c=(0,u.useMemo)(()=>d.canUndo(i),[d,i,o]);if(s||!c.ok&&c.ops.length===0)return null;let w=!c.ok,k=w?c.includeBatches:[];return(0,e.jsxs)("span",{style:{marginLeft:"auto",flex:"0 0 auto",display:"grid",justifyItems:"end",gap:2},children:[(0,e.jsx)("button",{type:"button","data-testid":"undo-turn",title:w?`${c.message} \u2014 undo those too`:"Take this back, keeping everything since",onClick:()=>{v(null);try{let f=d.log.all().find(x=>x.batch===i&&x.author.kind==="agent");d.undo(w?[i,...k]:i,{author:a}),f&&r({type:"home",author:f.author})}catch(f){v(f instanceof Error?f.message:String(f))}},style:{display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24,padding:"1px 8px",fontSize:"0.75rem",...w?{borderColor:"var(--graview-warn)",color:"var(--graview-warn)"}:{}},children:w?`undo +${k.length}`:"undo"}),l?(0,e.jsx)("span",{"data-testid":"undo-refused",role:"alert",style:{fontSize:"0.75rem",lineHeight:1.4,color:"var(--graview-warn)",maxWidth:260,textAlign:"right"},children:l}):null]})}function fe({seq:i,intent:n}){let a=L();if(!a)return null;let r=a.past?.seq===i;return(0,e.jsx)("button",{type:"button","data-testid":"show-past","aria-label":`Show the app as it was after \u201C${n}\u201D`,title:"Show the app as it was here","aria-pressed":r,onPointerEnter:q,onFocus:q,onClick:()=>a.show(i),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",minHeight:24,minWidth:24,padding:"1px 6px",fontSize:"0.75rem",flex:"0 0 auto"},children:(0,e.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",children:[(0,e.jsx)("path",{d:"M2.5 8 a5.5 5.5 0 1 0 1.6-3.9",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),(0,e.jsx)("path",{d:"M2 2.5 V5.5 H5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,e.jsx)("path",{d:"M8 5 V8 L10 9.25",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})})}function me(){let i=()=>{let n=new URL(window.location.href);return n.searchParams.set("fresh","1"),n.toString()};return(0,e.jsx)("a",{href:"#fresh","data-testid":"start-fresh",title:"Forget every edit made in this browser and return to the example",onClick:n=>{n.preventDefault(),window.location.assign(i())},style:{display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24,fontSize:"0.8125rem",color:"var(--graview-ink-muted)",textDecoration:"underline",textDecorationColor:"var(--graview-edge-bright)",textUnderlineOffset:3},children:"Start fresh"})}function O({id:i,label:n,go:a}){return a?(0,e.jsx)("button",{type:"button","data-testid":"activity-record","data-record":i,title:`Go to ${n}`,onClick:()=>a(i),style:{all:"unset",display:"inline-flex",cursor:"pointer",borderRadius:7},className:"graview-activity-record",children:(0,e.jsx)(D,{label:n})}):(0,e.jsx)(D,{label:n})}function Oe({calls:i,seat:n,remembers:a=!1}){let r=ue(),{store:d,principal:s,seats:o,people:l}=m(),v=ne(),[c,w]=(0,u.useState)("all"),[k,f]=(0,u.useState)(!1),x=t=>t!==void 0&&(t.id===s.id||t.onBehalfOf?.id===s.id)&&s.id!==void 0,re=new Set(v.map(t=>t.id)),oe=r.filter(t=>!(t.interaction!==void 0&&re.has(t.interaction))&&(!k||x(t.by))),se=v.filter(t=>!k||x(t.by)).slice(0,4),I=[...c==="ai"?[]:oe.map(t=>({at:t.at??"",change:t})),...c==="changes"?[]:se.map(t=>({at:t.at,entry:t}))].sort((t,h)=>t.at<h.at?1:t.at>h.at?-1:0),y=T(d,s),H=i.some(t=>t.phase==="running"),de=Z(),S=Y("activity"),N=S.open,le=G(),j=L(),C=t=>y.graph.has(t)?h=>{S.setOpen(!1),j?.past&&j.show(null),le.record(h)}:null;return n===void 0&&i.length===0&&r.length===0&&v.length===0&&!a&&de===0?null:(0,e.jsxs)("div",{style:{position:"relative"},children:[(0,e.jsxs)("button",{type:"button","data-testid":"activity-button",...S.trigger,onClick:S.toggle,title:H?"An agent is working":"What has happened",style:{display:"inline-flex",alignItems:"center",gap:6,minHeight:30,padding:"0 8px",borderRadius:8,border:"1px solid transparent",background:"transparent",boxShadow:"none",fontSize:"0.875rem",whiteSpace:"nowrap",color:H?"var(--graview-accent)":"var(--graview-ink-muted)"},children:[H?(0,e.jsx)("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:999,background:"var(--graview-accent)"}}):null,r.length>0?r.length:"",(0,e.jsxs)("svg",{className:"graview-activity-mark",width:"15",height:"15",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",style:{display:"var(--graview-activity-mark, none)"},children:[(0,e.jsx)("circle",{cx:"8",cy:"8",r:"5.75",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),(0,e.jsx)("path",{d:"M8 4.75 V8 L10.25 9.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),(0,e.jsx)("span",{className:"graview-activity-word",children:" Activity"})]}),!N&&n!==void 0?(0,e.jsx)("div",{hidden:!0,"data-testid":"agent-seat-seated",children:n}):null,N?(0,e.jsxs)("section",{...S.pane,"aria-label":"Activity","data-testid":"activity","data-graview-offstage":"",style:{...V,width:300,maxHeight:"min(52cqh, 460px)",overflow:"auto",display:"flex",flexDirection:"column",gap:9,padding:12,borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)"},children:[(0,e.jsx)("h2",{style:{...J,margin:0},children:"Activity"}),n!==void 0?(0,e.jsxs)("div",{"data-testid":"agent-seat-row",style:{display:"grid",gap:5,paddingBottom:i.length>0||I.length>0?9:0,...i.length>0||I.length>0?{borderBottom:"1px solid var(--graview-edge)"}:{}},children:[(0,e.jsx)("span",{style:{fontSize:"0.75rem",letterSpacing:"0.14em",textTransform:"uppercase",color:"var(--graview-ink-faint)"},children:"The agent's seat"}),n]}):null,i.length>0?(0,e.jsx)("ol",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:7},children:i.slice(0,6).map((t,h)=>(0,e.jsxs)("li",{style:{display:"grid",gap:2,fontSize:"0.8125rem",lineHeight:1.45},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[(0,e.jsx)("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:999,flex:"0 0 auto",background:t.phase==="running"?"var(--graview-accent)":t.phase==="failed"?"var(--graview-warn)":"var(--graview-edge-bright)"}}),(0,e.jsxs)("span",{style:{color:"var(--graview-ink)"},children:[t.mutating?"changed":"read"," \xB7"," ",y.allMutations().find(p=>p.name===t.name)?.title??E(t.name)]})]}),!t.mutating&&t.reads&&t.reads.length>0?(0,e.jsxs)("div",{"data-testid":"activity-reads",style:{display:"flex",flexWrap:"wrap",gap:4,paddingLeft:12},children:[[...new Set(t.reads)].slice(0,3).map(p=>(0,e.jsx)(O,{id:p,label:b(y,p),go:C(p)},p)),new Set(t.reads).size>3?(0,e.jsxs)("span",{style:{color:"var(--graview-ink-muted)"},children:["+",new Set(t.reads).size-3]}):null]}):Object.values(t.args).some(p=>typeof p=="string")?(0,e.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4,paddingLeft:12},children:Object.entries(t.args).filter(p=>typeof p[1]=="string").slice(0,3).map(([p,g])=>(0,e.jsx)(O,{id:g,label:b(y,g),go:C(g)},p))}):null,t.error?(0,e.jsx)("div",{style:{paddingLeft:12,color:"var(--graview-warn)"},children:t.error}):null]},`${t.at}:${h}`))}):null,v.length>0?(0,e.jsx)(u.Suspense,{fallback:null,children:(0,e.jsx)(ge,{shows:c,onShows:w,mine:k,onMine:f})}):null,I.length>0?(0,e.jsx)("ol",{"data-testid":"diff-log",style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6,fontSize:"0.8125rem"},children:I.map(({change:t,entry:h},p)=>h!==void 0?(0,e.jsx)(u.Suspense,{fallback:null,children:(0,e.jsx)(pe,{entry:h,undo:g=>(0,e.jsx)(M,{batch:g})})},`ai:${h.id}`):t.digest?(0,e.jsx)(ye,{change:t,goes:C},`digest:${t.digest[0]?.batch??p}`):t.withheld?(0,e.jsx)("li",{"data-testid":"withheld-change",style:{display:"grid",gap:3,lineHeight:1.45},children:(0,e.jsx)("span",{"data-touched":"",style:{color:"var(--graview-ink-muted)",fontStyle:"italic"},children:t.intent})},`change:${p}`):(0,e.jsxs)("li",{"data-batch":t.batch,style:{display:"grid",gap:3,lineHeight:1.45},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[(0,e.jsxs)("span",{style:{minWidth:0},children:[(0,e.jsxs)("strong",{style:{fontWeight:600},children:[t.author==="human"&&t.by?.onBehalfOf===void 0&&(t.authorId===void 0||s.id===void 0||t.authorId===s.id)?"you":z(t.by??{kind:t.author,id:t.authorId},{graph:y.graph,schema:y.schema,seats:o,people:l}),A(t.via)?(0,e.jsxs)("span",{style:{fontWeight:400,color:"var(--graview-ink-muted)"},children:[", ",A(t.via)]}):null]})," ",(0,e.jsx)("span",{style:{color:"var(--graview-ink-muted)"},children:t.intent}),t.basis?(0,e.jsxs)("span",{"data-graview-lineage":"",style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",t.basis]}):null]}),t.batch?(0,e.jsx)(fe,{seq:t.seq,intent:t.intent}):null,t.batch?(0,e.jsx)(M,{batch:t.batch}):null]}),(0,e.jsx)("div",{"data-touched":t.touched.join(" "),style:{display:"flex",flexWrap:"wrap",gap:4},children:t.touched.slice(0,4).map(g=>(0,e.jsx)(O,{id:g,label:y.graph.has(g)?b(y,g):t.removed?.[g]??b(y,g),go:C(g)},g))})]},`change:${p}`))}):null,(0,e.jsx)(ee,{style:{paddingTop:8,borderTop:"1px solid var(--graview-edge)"}}),a?(0,e.jsxs)("div",{"data-testid":"remembered",style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:10,paddingTop:8,borderTop:"1px solid var(--graview-edge)",fontSize:"0.8125rem",color:"var(--graview-ink-faint)"},children:[(0,e.jsx)("span",{children:"Remembered in this browser"}),(0,e.jsx)(me,{})]}):null]}):null]})}export{M as a,Oe as b};
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 q,g as Z,h as ee}from"./chunk.DLT3EE4D.js";import{a as Q,b as X}from"./chunk.3C4RJIJU.js";import{b}from"./chunk.DPP7ITTU.js";import{d as D}from"./chunk.GF7LA4QG.js";import{a as K}from"./chunk.UT6642FC.js";import{h as A}from"./chunk.Z7ZCR4LN.js";import{m as J}from"./chunk.Y5Z4ZDTO.js";import{F,I as P,N as L,O as T,Q as U,Y as m,a as $,ea as G,sa as V,wa as Y,xa as _}from"./chunk.UWIYKGYK.js";import{La as z,X as B,Z as E,fb as R}from"./chunk.X7W27IRI.js";import{b as W}from"./chunk.AJZBJBMO.js";var u=W(F(),1);var te=W(F(),1);function ne(){let{ai:i,aiDesk:n}=m(),{entries:a}=P(n),r=i.off===!0;return(0,te.useEffect)(()=>{r||n.load()},[n,r]),r?[]:a}var e=W(U(),1),ae=_($(()=>(__graviewPreload(import.meta.url,["./chunk.RTB4MMF6.js","./chunk.6J7DR7XQ.js","./chunk.Y5Z4ZDTO.js","./chunk.UWIYKGYK.js","./chunk.X7W27IRI.js","./chunk.AJZBJBMO.js"]),import("./chunk.4J75WRDG.js")))),pe=ae.part((i,n)=>(0,e.jsx)(i.InteractionRow,{...n}),{quiet:!0,as:"li"}),ge=ae.part((i,n)=>(0,e.jsx)(i.ActivityFilter,{...n}),{quiet:!0,as:"div"}),ie=(i,n)=>({intent:n.intent,author:n.author.kind,...n.author.id?{authorId:n.author.id}:{},by:n.author,...n.ops[0]?.via?{via:n.ops[0].via}:{},...n.lineage?{basis:K(n.lineage)}:{},touched:[...new Set(n.ops.filter(a=>!R(a)).flatMap(a=>a.writes))],...he(i,n.ops.filter(a=>!R(a))),batch:n.id,at:n.at,...n.lineage?.interaction?{interaction:n.lineage.interaction}:{},seq:n.ops.at(-1).seq+1,...n.ops.every(R)?{withheld:!0}:{}});function ue(i=4){let{store:n,principal:a}=m(),r=T(n,a),d=r.log.length;return(0,u.useMemo)(()=>Q(r.batches(),s=>r.log.get(s)).reverse().slice(0,i).map(s=>{if("batch"in s)return ie(r,s.batch);let o=[...s.digest.batches].reverse().map(l=>ie(r,l));return{intent:X(s.digest,new Date().toISOString().slice(0,10)),author:s.digest.author.kind,...s.digest.author.id?{authorId:s.digest.author.id}:{},by:s.digest.author,touched:[...new Set(o.flatMap(l=>l.touched))],batch:"",...o[0]?.at?{at:o[0].at}:{},seq:o[0]?.seq??0,digest:o}}),[r,d,i])}function he(i,n){let a={};for(let r of n)for(let d of r.primitives)d.op==="remove-node"&&d.node&&(a[d.node.id]=B(i.schema.tryDefinition(d.node.kind),d.node));return Object.keys(a).length>0?{removed:a}:{}}function ce({change:i}){let{store:n,principal:a,seats:r,people:d}=m();return(0,e.jsxs)("strong",{style:{fontWeight:600},children:[i.author==="human"&&i.by?.onBehalfOf===void 0&&(i.authorId===void 0||a.id===void 0||i.authorId===a.id)?"you":z(i.by??{kind:i.author,id:i.authorId},{graph:n.graph,schema:n.schema,seats:r,people:d}),A(i.via)?(0,e.jsxs)("span",{style:{fontWeight:400,color:"var(--graview-ink-muted)"},children:[", ",A(i.via)]}):null]})}function ye({change:i,goes:n}){let{store:a}=m(),[r,d]=(0,u.useState)(!1),s=i.digest??[];return(0,e.jsxs)("li",{"data-testid":"activity-digest",style:{display:"grid",gap:5,lineHeight:1.45},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[(0,e.jsxs)("span",{style:{minWidth:0},children:[(0,e.jsx)(ce,{change:i})," ",(0,e.jsx)("span",{style:{color:"var(--graview-ink-muted)"},children:i.intent})]}),(0,e.jsx)("button",{type:"button","data-testid":"digest-toggle","aria-expanded":r,onClick:()=>d(o=>!o),style:{marginLeft:"auto",flex:"0 0 auto",display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24,padding:"1px 8px",fontSize:"0.75rem"},children:r?"Hide":"Show each"})]}),r?(0,e.jsx)("ol",{"data-testid":"digest-changes",style:{margin:0,padding:"0 0 0 10px",listStyle:"none",display:"grid",gap:6,borderLeft:"1px solid var(--graview-edge)"},children:s.map(o=>(0,e.jsxs)("li",{"data-testid":"digest-change",style:{display:"grid",gap:3},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[(0,e.jsxs)("span",{style:{minWidth:0},children:[(0,e.jsx)("span",{style:{color:"var(--graview-ink-muted)"},children:o.intent}),o.basis?(0,e.jsxs)("span",{"data-graview-lineage":"",style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",o.basis]}):null]}),o.withheld?null:(0,e.jsx)(M,{batch:o.batch})]}),o.touched.length>0?(0,e.jsx)("div",{"data-touched":o.touched.join(" "),style:{display:"flex",flexWrap:"wrap",gap:4},children:o.touched.slice(0,4).map(l=>(0,e.jsx)(O,{id:l,label:a.graph.has(l)?b(a,l):o.removed?.[l]??b(a,l),go:n(l)},l))}):null]},o.batch))}):null]})}function M({batch:i}){let{store:n,principal:a,noteSeat:r}=m(),d=T(n,a),s=L()?.open??!1,o=d.log.length,[l,v]=(0,u.useState)(null),c=(0,u.useMemo)(()=>d.canUndo(i),[d,i,o]);if(s||!c.ok&&c.ops.length===0)return null;let w=!c.ok,k=w?c.includeBatches:[];return(0,e.jsxs)("span",{style:{marginLeft:"auto",flex:"0 0 auto",display:"grid",justifyItems:"end",gap:2},children:[(0,e.jsx)("button",{type:"button","data-testid":"undo-turn",title:w?`${c.message} \u2014 undo those too`:"Take this back, keeping everything since",onClick:()=>{v(null);try{let f=d.log.all().find(x=>x.batch===i&&x.author.kind==="agent");d.undo(w?[i,...k]:i,{author:a}),f&&r({type:"home",author:f.author})}catch(f){v(f instanceof Error?f.message:String(f))}},style:{display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24,padding:"1px 8px",fontSize:"0.75rem",...w?{borderColor:"var(--graview-warn)",color:"var(--graview-warn)"}:{}},children:w?`undo +${k.length}`:"undo"}),l?(0,e.jsx)("span",{"data-testid":"undo-refused",role:"alert",style:{fontSize:"0.75rem",lineHeight:1.4,color:"var(--graview-warn)",maxWidth:260,textAlign:"right"},children:l}):null]})}function fe({seq:i,intent:n}){let a=L();if(!a)return null;let r=a.past?.seq===i;return(0,e.jsx)("button",{type:"button","data-testid":"show-past","aria-label":`Show the app as it was after \u201C${n}\u201D`,title:"Show the app as it was here","aria-pressed":r,onPointerEnter:q,onFocus:q,onClick:()=>a.show(i),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",minHeight:24,minWidth:24,padding:"1px 6px",fontSize:"0.75rem",flex:"0 0 auto"},children:(0,e.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",children:[(0,e.jsx)("path",{d:"M2.5 8 a5.5 5.5 0 1 0 1.6-3.9",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),(0,e.jsx)("path",{d:"M2 2.5 V5.5 H5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,e.jsx)("path",{d:"M8 5 V8 L10 9.25",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})})}function me(){let i=()=>{let n=new URL(window.location.href);return n.searchParams.set("fresh","1"),n.toString()};return(0,e.jsx)("a",{href:"#fresh","data-testid":"start-fresh",title:"Forget every edit made in this browser and return to the example",onClick:n=>{n.preventDefault(),window.location.assign(i())},style:{display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24,fontSize:"0.8125rem",color:"var(--graview-ink-muted)",textDecoration:"underline",textDecorationColor:"var(--graview-edge-bright)",textUnderlineOffset:3},children:"Start fresh"})}function O({id:i,label:n,go:a}){return a?(0,e.jsx)("button",{type:"button","data-testid":"activity-record","data-record":i,title:`Go to ${n}`,onClick:()=>a(i),style:{all:"unset",display:"inline-flex",cursor:"pointer",borderRadius:7},className:"graview-activity-record",children:(0,e.jsx)(D,{label:n})}):(0,e.jsx)(D,{label:n})}function Oe({calls:i,seat:n,remembers:a=!1}){let r=ue(),{store:d,principal:s,seats:o,people:l}=m(),v=ne(),[c,w]=(0,u.useState)("all"),[k,f]=(0,u.useState)(!1),x=t=>t!==void 0&&(t.id===s.id||t.onBehalfOf?.id===s.id)&&s.id!==void 0,re=new Set(v.map(t=>t.id)),oe=r.filter(t=>!(t.interaction!==void 0&&re.has(t.interaction))&&(!k||x(t.by))),se=v.filter(t=>!k||x(t.by)).slice(0,4),I=[...c==="ai"?[]:oe.map(t=>({at:t.at??"",change:t})),...c==="changes"?[]:se.map(t=>({at:t.at,entry:t}))].sort((t,h)=>t.at<h.at?1:t.at>h.at?-1:0),y=T(d,s),H=i.some(t=>t.phase==="running"),de=Z(),S=Y("activity"),N=S.open,le=G(),j=L(),C=t=>y.graph.has(t)?h=>{S.setOpen(!1),j?.past&&j.show(null),le.record(h)}:null;return n===void 0&&i.length===0&&r.length===0&&v.length===0&&!a&&de===0?null:(0,e.jsxs)("div",{style:{position:"relative"},children:[(0,e.jsxs)("button",{type:"button","data-testid":"activity-button",...S.trigger,onClick:S.toggle,title:H?"An agent is working":"What has happened",style:{display:"inline-flex",alignItems:"center",gap:6,minHeight:30,padding:"0 8px",borderRadius:8,border:"1px solid transparent",background:"transparent",boxShadow:"none",fontSize:"0.875rem",whiteSpace:"nowrap",color:H?"var(--graview-accent)":"var(--graview-ink-muted)"},children:[H?(0,e.jsx)("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:999,background:"var(--graview-accent)"}}):null,r.length>0?r.length:"",(0,e.jsxs)("svg",{className:"graview-activity-mark",width:"15",height:"15",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",style:{display:"var(--graview-activity-mark, none)"},children:[(0,e.jsx)("circle",{cx:"8",cy:"8",r:"5.75",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),(0,e.jsx)("path",{d:"M8 4.75 V8 L10.25 9.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),(0,e.jsx)("span",{className:"graview-activity-word",children:" Activity"})]}),!N&&n!==void 0?(0,e.jsx)("div",{hidden:!0,"data-testid":"agent-seat-seated",children:n}):null,N?(0,e.jsxs)("section",{...S.pane,"aria-label":"Activity","data-testid":"activity","data-graview-offstage":"",style:{...V,width:300,maxHeight:"min(52cqh, 460px)",overflow:"auto",display:"flex",flexDirection:"column",gap:9,padding:12,borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)"},children:[(0,e.jsx)("h2",{style:{...J,margin:0},children:"Activity"}),n!==void 0?(0,e.jsxs)("div",{"data-testid":"agent-seat-row",style:{display:"grid",gap:5,paddingBottom:i.length>0||I.length>0?9:0,...i.length>0||I.length>0?{borderBottom:"1px solid var(--graview-edge)"}:{}},children:[(0,e.jsx)("span",{style:{fontSize:"0.75rem",letterSpacing:"0.14em",textTransform:"uppercase",color:"var(--graview-ink-faint)"},children:"The agent's seat"}),n]}):null,i.length>0?(0,e.jsx)("ol",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:7},children:i.slice(0,6).map((t,h)=>(0,e.jsxs)("li",{style:{display:"grid",gap:2,fontSize:"0.8125rem",lineHeight:1.45},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[(0,e.jsx)("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:999,flex:"0 0 auto",background:t.phase==="running"?"var(--graview-accent)":t.phase==="failed"?"var(--graview-warn)":"var(--graview-edge-bright)"}}),(0,e.jsxs)("span",{style:{color:"var(--graview-ink)"},children:[t.mutating?"changed":"read"," \xB7"," ",y.allMutations().find(p=>p.name===t.name)?.title??E(t.name)]})]}),!t.mutating&&t.reads&&t.reads.length>0?(0,e.jsxs)("div",{"data-testid":"activity-reads",style:{display:"flex",flexWrap:"wrap",gap:4,paddingLeft:12},children:[[...new Set(t.reads)].slice(0,3).map(p=>(0,e.jsx)(O,{id:p,label:b(y,p),go:C(p)},p)),new Set(t.reads).size>3?(0,e.jsxs)("span",{style:{color:"var(--graview-ink-muted)"},children:["+",new Set(t.reads).size-3]}):null]}):Object.values(t.args).some(p=>typeof p=="string")?(0,e.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4,paddingLeft:12},children:Object.entries(t.args).filter(p=>typeof p[1]=="string").slice(0,3).map(([p,g])=>(0,e.jsx)(O,{id:g,label:b(y,g),go:C(g)},p))}):null,t.error?(0,e.jsx)("div",{style:{paddingLeft:12,color:"var(--graview-warn)"},children:t.error}):null]},`${t.at}:${h}`))}):null,v.length>0?(0,e.jsx)(u.Suspense,{fallback:null,children:(0,e.jsx)(ge,{shows:c,onShows:w,mine:k,onMine:f})}):null,I.length>0?(0,e.jsx)("ol",{"data-testid":"diff-log",style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6,fontSize:"0.8125rem"},children:I.map(({change:t,entry:h},p)=>h!==void 0?(0,e.jsx)(u.Suspense,{fallback:null,children:(0,e.jsx)(pe,{entry:h,undo:g=>(0,e.jsx)(M,{batch:g})})},`ai:${h.id}`):t.digest?(0,e.jsx)(ye,{change:t,goes:C},`digest:${t.digest[0]?.batch??p}`):t.withheld?(0,e.jsx)("li",{"data-testid":"withheld-change",style:{display:"grid",gap:3,lineHeight:1.45},children:(0,e.jsx)("span",{"data-touched":"",style:{color:"var(--graview-ink-muted)",fontStyle:"italic"},children:t.intent})},`change:${p}`):(0,e.jsxs)("li",{"data-batch":t.batch,style:{display:"grid",gap:3,lineHeight:1.45},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[(0,e.jsxs)("span",{style:{minWidth:0},children:[(0,e.jsxs)("strong",{style:{fontWeight:600},children:[t.author==="human"&&t.by?.onBehalfOf===void 0&&(t.authorId===void 0||s.id===void 0||t.authorId===s.id)?"you":z(t.by??{kind:t.author,id:t.authorId},{graph:y.graph,schema:y.schema,seats:o,people:l}),A(t.via)?(0,e.jsxs)("span",{style:{fontWeight:400,color:"var(--graview-ink-muted)"},children:[", ",A(t.via)]}):null]})," ",(0,e.jsx)("span",{style:{color:"var(--graview-ink-muted)"},children:t.intent}),t.basis?(0,e.jsxs)("span",{"data-graview-lineage":"",style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",t.basis]}):null]}),t.batch?(0,e.jsx)(fe,{seq:t.seq,intent:t.intent}):null,t.batch?(0,e.jsx)(M,{batch:t.batch}):null]}),(0,e.jsx)("div",{"data-touched":t.touched.join(" "),style:{display:"flex",flexWrap:"wrap",gap:4},children:t.touched.slice(0,4).map(g=>(0,e.jsx)(O,{id:g,label:y.graph.has(g)?b(y,g):t.removed?.[g]??b(y,g),go:C(g)},g))})]},`change:${p}`))}):null,(0,e.jsx)(ee,{style:{paddingTop:8,borderTop:"1px solid var(--graview-edge)"}}),a?(0,e.jsxs)("div",{"data-testid":"remembered",style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:10,paddingTop:8,borderTop:"1px solid var(--graview-edge)",fontSize:"0.8125rem",color:"var(--graview-ink-faint)"},children:[(0,e.jsx)("span",{children:"Remembered in this browser"}),(0,e.jsx)(me,{})]}):null]}):null]})}export{M as a,Oe as b};