graview 0.1.60 → 0.1.61

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 (179) hide show
  1. package/dist/preview/{chunk.ERFT54HT.js → chunk.2AWVQ5SW.js} +1 -1
  2. package/dist/preview/{chunk.LQVAABPS.js → chunk.2LNSENPV.js} +1 -1
  3. package/dist/preview/chunk.2QFKNTAZ.js +1 -0
  4. package/dist/preview/{chunk.ZXOT3IXJ.js → chunk.2WZAFKJ2.js} +1 -1
  5. package/dist/preview/{chunk.VZJWJ5XM.js → chunk.2XSIJH5J.js} +1 -1
  6. package/dist/preview/{chunk.GNBIVVL3.js → chunk.3FUUYYR5.js} +1 -1
  7. package/dist/preview/{chunk.NHUQ2N6J.js → chunk.3HFUO3DC.js} +1 -1
  8. package/dist/preview/chunk.3ICWPRRJ.js +1 -0
  9. package/dist/preview/{chunk.XR6YR6RV.js → chunk.3RW677X6.js} +1 -1
  10. package/dist/preview/{chunk.FBJARKDT.js → chunk.3SMNWZ3M.js} +1 -1
  11. package/dist/preview/{chunk.JPONLMU7.js → chunk.4G32374Q.js} +1 -1
  12. package/dist/preview/{chunk.IGJZ4UH3.js → chunk.4LG34OC2.js} +2 -2
  13. package/dist/preview/{chunk.3ZT5WQYL.js → chunk.4OEWFPH3.js} +1 -1
  14. package/dist/preview/{chunk.UITT6JWW.js → chunk.4STDIZVI.js} +1 -1
  15. package/dist/preview/{chunk.ZP5RT2EK.js → chunk.5POG3G2C.js} +1 -1
  16. package/dist/preview/{chunk.ULL6ZIJJ.js → chunk.5S7IGASX.js} +1 -1
  17. package/dist/preview/chunk.5T53SF2K.js +1 -0
  18. package/dist/preview/{chunk.3MOJF7BA.js → chunk.5X22RKB3.js} +1 -1
  19. package/dist/preview/{chunk.LSY256J4.js → chunk.65KFZV3A.js} +1 -1
  20. package/dist/preview/chunk.66IKLMYX.js +104 -0
  21. package/dist/preview/chunk.6DOOLVT4.js +1 -0
  22. package/dist/preview/{chunk.TLJOZSDD.js → chunk.6HZY5NRX.js} +1 -1
  23. package/dist/preview/{chunk.RQOX5YDW.js → chunk.6SO64TUI.js} +1 -1
  24. package/dist/preview/{chunk.2USDHXB4.js → chunk.6VLCMBRE.js} +1 -1
  25. package/dist/preview/{chunk.ENL2JJ47.js → chunk.747OH3EE.js} +1 -1
  26. package/dist/preview/chunk.7CETF4A6.js +1 -0
  27. package/dist/preview/{chunk.MVWC3VR3.js → chunk.7LZ6JDJA.js} +2 -2
  28. package/dist/preview/{chunk.PI44XMY2.js → chunk.7R727IKU.js} +1 -1
  29. package/dist/preview/chunk.A2ZQASQV.js +1 -0
  30. package/dist/preview/chunk.AVFOTYZR.js +74 -0
  31. package/dist/preview/{chunk.VUBNBTJP.js → chunk.BDTT4ENI.js} +2 -2
  32. package/dist/preview/{chunk.SB2PZKN5.js → chunk.BFDJTWGX.js} +1 -1
  33. package/dist/preview/{chunk.6ZQAR5ZA.js → chunk.BI6DS3PZ.js} +1 -1
  34. package/dist/preview/{chunk.KI37ZEV3.js → chunk.BJI2C3IZ.js} +1 -1
  35. package/dist/preview/{chunk.YFSBVZTG.js → chunk.C634A6ZC.js} +1 -1
  36. package/dist/preview/{chunk.ZYM2SSGW.js → chunk.CRCJ3TAG.js} +1 -1
  37. package/dist/preview/{chunk.WXUFATY5.js → chunk.CUTLO6DA.js} +1 -1
  38. package/dist/preview/chunk.D4TA5XDC.js +4 -0
  39. package/dist/preview/{chunk.HDUO2USQ.js → chunk.D5Q64GA4.js} +1 -1
  40. package/dist/preview/{chunk.RXYNW5QB.js → chunk.DHJI7LIW.js} +1 -1
  41. package/dist/preview/{chunk.6HF6POIX.js → chunk.DHY7KOBV.js} +1 -1
  42. package/dist/preview/chunk.DKXVEVDG.js +1 -0
  43. package/dist/preview/{chunk.NC7FXY2H.js → chunk.DLDP6OWD.js} +1 -1
  44. package/dist/preview/{chunk.H45Q3O4F.js → chunk.DP5DUV6F.js} +1 -1
  45. package/dist/preview/chunk.DXWTM4SH.js +1 -0
  46. package/dist/preview/{chunk.BQIHNT7C.js → chunk.E6RNMWFN.js} +1 -1
  47. package/dist/preview/{chunk.A3ZXDG6V.js → chunk.E7UDVC4V.js} +1 -1
  48. package/dist/preview/{chunk.M4UD4ARP.js → chunk.EN2ABVIP.js} +1 -1
  49. package/dist/preview/{chunk.7MHCGVGM.js → chunk.EVEHSENK.js} +1 -1
  50. package/dist/preview/{chunk.SRVQJZRT.js → chunk.F4VHCQNP.js} +1 -1
  51. package/dist/preview/{chunk.4TCKEG6I.js → chunk.F7IQ4B6A.js} +1 -1
  52. package/dist/preview/chunk.F7PIW2EM.js +5 -0
  53. package/dist/preview/{chunk.GTKJJYQH.js → chunk.FJIXSGYU.js} +1 -1
  54. package/dist/preview/{chunk.HDP3PS7N.js → chunk.FWUG7Y6C.js} +1 -1
  55. package/dist/preview/chunk.G4VMRYS4.js +1 -0
  56. package/dist/preview/{chunk.URWAFZHF.js → chunk.GI6XQF5X.js} +1 -1
  57. package/dist/preview/{chunk.Y5C4RXG7.js → chunk.GIW657OR.js} +1 -1
  58. package/dist/preview/chunk.GPWYWALF.js +1 -0
  59. package/dist/preview/{chunk.YZ7FUKAL.js → chunk.GQNSNJTJ.js} +1 -1
  60. package/dist/preview/chunk.HGVBGSRS.js +6 -0
  61. package/dist/preview/{chunk.VNDKKTED.js → chunk.HOQMD6WQ.js} +1 -1
  62. package/dist/preview/{chunk.TKVLNBRD.js → chunk.HQNE4I4M.js} +1 -1
  63. package/dist/preview/{chunk.A5PDXNY6.js → chunk.HZHNM2KI.js} +1 -1
  64. package/dist/preview/{chunk.TAT2IQUR.js → chunk.IA5ZBMRD.js} +1 -1
  65. package/dist/preview/{chunk.VFOON3Z3.js → chunk.ISRQQVS4.js} +1 -1
  66. package/dist/preview/{chunk.T7LQD67N.js → chunk.ISXNAFRC.js} +2 -2
  67. package/dist/preview/{chunk.QBLKTFF4.js → chunk.JEQO24GS.js} +1 -1
  68. package/dist/preview/{chunk.VWJGQDCE.js → chunk.JHAFQNGC.js} +1 -1
  69. package/dist/preview/chunk.JU3BCCQM.js +1 -0
  70. package/dist/preview/{chunk.5DD62IOW.js → chunk.K2AC536Q.js} +2 -2
  71. package/dist/preview/chunk.K3UOXAZS.js +1 -0
  72. package/dist/preview/{chunk.CC5BJH5A.js → chunk.KRFRREEW.js} +1 -1
  73. package/dist/preview/chunk.LA2DMHZC.js +1 -0
  74. package/dist/preview/chunk.LQAT7FA6.js +3 -0
  75. package/dist/preview/{chunk.UJTE7UAP.js → chunk.LTI5PKTS.js} +1 -1
  76. package/dist/preview/chunk.MBP7VDYM.js +1 -0
  77. package/dist/preview/{chunk.EL5ICOOM.js → chunk.MBPOYZ3J.js} +1 -1
  78. package/dist/preview/chunk.MBU7UH6J.js +1 -0
  79. package/dist/preview/chunk.MH6CCHEX.js +1 -0
  80. package/dist/preview/{chunk.DCHQHKSA.js → chunk.MK72IRIY.js} +1 -1
  81. package/dist/preview/{chunk.VMV464JK.js → chunk.MNRTA2CB.js} +1 -1
  82. package/dist/preview/chunk.MU3XII7I.js +1 -0
  83. package/dist/preview/chunk.MYVED5LU.js +1 -0
  84. package/dist/preview/chunk.N5WDQAIM.js +5 -0
  85. package/dist/preview/{chunk.4MP72LPR.js → chunk.N7T7VB77.js} +1 -1
  86. package/dist/preview/{chunk.QHDCTAD7.js → chunk.NUEPFPRA.js} +1 -1
  87. package/dist/preview/chunk.ODVRO2BJ.js +1 -0
  88. package/dist/preview/{chunk.5YOLUDVO.js → chunk.OVPFROL3.js} +1 -1
  89. package/dist/preview/{chunk.W3W54DSX.js → chunk.PGA5TUSN.js} +1 -1
  90. package/dist/preview/{chunk.TLWT67ON.js → chunk.PJ5AO7CK.js} +1 -1
  91. package/dist/preview/{chunk.TFWIG6LL.js → chunk.PYVWGTQS.js} +1 -1
  92. package/dist/preview/{chunk.7OPM55I2.js → chunk.PZXTSWDH.js} +1 -1
  93. package/dist/preview/chunk.Q5I5M3FR.js +1 -0
  94. package/dist/preview/chunk.QATUGE34.js +1 -0
  95. package/dist/preview/{chunk.PFSYXD6Q.js → chunk.QL77K3D4.js} +1 -1
  96. package/dist/preview/{chunk.7N32AVIJ.js → chunk.R3N73BJO.js} +1 -1
  97. package/dist/preview/{chunk.P6RORYOT.js → chunk.R5547CJ7.js} +1 -1
  98. package/dist/preview/chunk.REH6RXNH.js +1 -0
  99. package/dist/preview/{chunk.UQWTZJBV.js → chunk.RZ5PPQBV.js} +1 -1
  100. package/dist/preview/{chunk.QDSEVPF3.js → chunk.SAYAFOF6.js} +1 -1
  101. package/dist/preview/{chunk.FRYBMS3W.js → chunk.SBLYBRDU.js} +1 -1
  102. package/dist/preview/{chunk.YH63KQ2G.js → chunk.SCGF4ZPP.js} +1 -1
  103. package/dist/preview/{chunk.HUJ6YTWE.js → chunk.SIYBHZDD.js} +1 -1
  104. package/dist/preview/{chunk.KDRLUBVF.js → chunk.SJALH7IX.js} +1 -1
  105. package/dist/preview/{chunk.F6V7RWDK.js → chunk.SKQO467Y.js} +1 -1
  106. package/dist/preview/chunk.SLAZFFCQ.js +1 -0
  107. package/dist/preview/chunk.SLPJWOKC.js +1 -0
  108. package/dist/preview/{chunk.JEYQBH33.js → chunk.TKLYUVMR.js} +1 -1
  109. package/dist/preview/chunk.TMAZNDA6.js +1 -0
  110. package/dist/preview/{chunk.IGVASEZU.js → chunk.U2ISOUM2.js} +1 -1
  111. package/dist/preview/{chunk.VADQ7ZGA.js → chunk.U3JK2DNC.js} +1 -1
  112. package/dist/preview/chunk.U5P23GO7.js +1 -0
  113. package/dist/preview/{chunk.KBVTLNS5.js → chunk.UACSX64H.js} +3 -3
  114. package/dist/preview/{chunk.Z2ERZ4S6.js → chunk.ULHB3RYK.js} +1 -1
  115. package/dist/preview/{chunk.MSWWWLEA.js → chunk.UO544PZH.js} +1 -1
  116. package/dist/preview/{chunk.Y7G3OGDE.js → chunk.UXOBUK3C.js} +1 -1
  117. package/dist/preview/{chunk.BRT27WON.js → chunk.VKHAAH32.js} +1 -1
  118. package/dist/preview/{chunk.3XGA65Y3.js → chunk.VN7I7XIO.js} +1 -1
  119. package/dist/preview/{chunk.CFKZXLXS.js → chunk.VOOOIECX.js} +1 -1
  120. package/dist/preview/chunk.VS6NT5C4.js +1 -0
  121. package/dist/preview/{chunk.67U6M7OV.js → chunk.VUAOCYG2.js} +1 -1
  122. package/dist/preview/{chunk.PNW5K7BW.js → chunk.VX65S2FA.js} +1 -1
  123. package/dist/preview/{chunk.VDMDPZ6U.js → chunk.VYFMUCBT.js} +1 -1
  124. package/dist/preview/{chunk.FFTYMBBT.js → chunk.W5TVQYAI.js} +1 -1
  125. package/dist/preview/{chunk.OLFJH4RK.js → chunk.WD4VPMEE.js} +1 -1
  126. package/dist/preview/{chunk.BXDM3UMN.js → chunk.WICFQROI.js} +1 -1
  127. package/dist/preview/{chunk.NGTRL5U4.js → chunk.WS7LAT4Z.js} +1 -1
  128. package/dist/preview/{chunk.IHBUBZQT.js → chunk.X2I3XH2E.js} +1 -1
  129. package/dist/preview/{chunk.6WHAWOO7.js → chunk.XFSGB6EU.js} +1 -1
  130. package/dist/preview/{chunk.XGASJAV2.js → chunk.XWWSW3ZV.js} +1 -1
  131. package/dist/preview/chunk.XZUHFXME.js +1 -0
  132. package/dist/preview/{chunk.CQT3W2SF.js → chunk.XZWXDQ3N.js} +1 -1
  133. package/dist/preview/{chunk.IOK4GVJC.js → chunk.Y7H5O2SL.js} +1 -1
  134. package/dist/preview/chunk.YGIJDHAV.js +2 -0
  135. package/dist/preview/{chunk.3V4WP7RY.js → chunk.YOT7ESDG.js} +3 -3
  136. package/dist/preview/{chunk.MJVYWLQQ.js → chunk.ZC3FRCJQ.js} +1 -1
  137. package/dist/preview/{chunk.AVBTPSQF.js → chunk.ZJCM62GH.js} +1 -1
  138. package/dist/preview/{chunk.4LR64TPU.js → chunk.ZKAZA6UJ.js} +1 -1
  139. package/dist/preview/{chunk.3UOKUF5Z.js → chunk.ZQHCNFJK.js} +1 -1
  140. package/dist/preview/{chunk.6C2MHWSX.js → chunk.ZVG3DR5G.js} +1 -1
  141. package/dist/preview/chunk.ZYNUMVEC.js +1 -0
  142. package/dist/preview/index.html +50 -50
  143. package/dist/preview/page.js +2 -2
  144. package/package.json +6 -6
  145. package/dist/preview/chunk.2K4TT2BV.js +0 -1
  146. package/dist/preview/chunk.37TVS7CA.js +0 -1
  147. package/dist/preview/chunk.3IZ3ABII.js +0 -1
  148. package/dist/preview/chunk.7TFLRR7D.js +0 -1
  149. package/dist/preview/chunk.7VKSXGTX.js +0 -1
  150. package/dist/preview/chunk.BF6S5UE4.js +0 -1
  151. package/dist/preview/chunk.BLPYNNR4.js +0 -1
  152. package/dist/preview/chunk.BYKD5RLA.js +0 -1
  153. package/dist/preview/chunk.C7OLSEWK.js +0 -1
  154. package/dist/preview/chunk.CMN6BBAD.js +0 -1
  155. package/dist/preview/chunk.D7YSL3NK.js +0 -2
  156. package/dist/preview/chunk.EQXB7LKI.js +0 -1
  157. package/dist/preview/chunk.FLUK3UXF.js +0 -1
  158. package/dist/preview/chunk.G3R4BTI7.js +0 -1
  159. package/dist/preview/chunk.G4YJPKRG.js +0 -5
  160. package/dist/preview/chunk.GLWSVSQL.js +0 -1
  161. package/dist/preview/chunk.I4XQBQRC.js +0 -1
  162. package/dist/preview/chunk.IBOKXVWN.js +0 -1
  163. package/dist/preview/chunk.JJGCTGWA.js +0 -1
  164. package/dist/preview/chunk.KGW75Z5L.js +0 -3
  165. package/dist/preview/chunk.L6AWE76F.js +0 -1
  166. package/dist/preview/chunk.LGEA5257.js +0 -6
  167. package/dist/preview/chunk.LLYRFVIN.js +0 -104
  168. package/dist/preview/chunk.LZIBQ3VX.js +0 -1
  169. package/dist/preview/chunk.MDJWK5W2.js +0 -1
  170. package/dist/preview/chunk.PHJ6WPWH.js +0 -1
  171. package/dist/preview/chunk.QFUMFQJU.js +0 -1
  172. package/dist/preview/chunk.QI4SLPQ4.js +0 -4
  173. package/dist/preview/chunk.TY4GQJKC.js +0 -1
  174. package/dist/preview/chunk.VSCIXAHN.js +0 -5
  175. package/dist/preview/chunk.WC3DENU4.js +0 -67
  176. package/dist/preview/chunk.WQ6RCEUQ.js +0 -1
  177. package/dist/preview/chunk.X6A4VSSD.js +0 -1
  178. package/dist/preview/chunk.XZPKBHJT.js +0 -1
  179. package/dist/preview/chunk.YEBGI6ED.js +0 -1
@@ -1 +0,0 @@
1
- import{a as Ee,b as Ve,c as qe,d as me,e as R,f as ge,h as Be}from"./chunk.7TFLRR7D.js";import{h as Ze,i as We,j as Ye}from"./chunk.6ZQAR5ZA.js";import{a as re,b as ae,c as J,d as Ue,e as X,g as oe,h as He}from"./chunk.PI44XMY2.js";import{c as Ce,h as z,i as Le,j as ue}from"./chunk.KGW75Z5L.js";import{$b as fe,A as De,Ca as Ne,Db as bn,Ja as Te,Ka as te,La as pe,_b as Me,ac as Ke,b as W,bc as _e,c as U,cc as Ie,e as de,f as Re,g as K,h as S,k as G,l as ee,m as _,n as Fe,o as Z,p as N,r as w,s as ne,t as x,tc as Pe,u as A,uc as Ge,v as V,w as I,x as t,y as T,z as Y}from"./chunk.VSCIXAHN.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";var ze=e=>Object.entries(e).map(([o,s])=>[o,Object.keys(te(s?.edges))]),ye=(e,o)=>Ke(e,ze(o));function Je(e){return[...Object.keys(e.acts??{}),...Object.keys(e.kinds).flatMap(o=>Me(o)),..._e(ze(e.kinds))]}var B=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Xe(e){if(!B(e)||!B(e.kinds))return e;let o;try{let f=Object.fromEntries(Object.entries(e.kinds).map(([g,a])=>[g,B(a)&&B(a.edges)?{edges:a.edges}:{}]));o=Je({acts:B(e.acts)?e.acts:{},kinds:f})}catch{return e}let s=new Set(o),n=!1,r=f=>{if(typeof f!="string"||s.has(f))return f;let g=Pe(f,o);return g===void 0?f:(n=!0,g)},l=B(e.policy)&&Array.isArray(e.policy.grants)?{...e.policy,grants:e.policy.grants.map(f=>B(f)&&Array.isArray(f.mutations)?{...f,mutations:f.mutations.map(r)}:f)}:void 0,u=B(e.rules)?Object.fromEntries(Object.entries(e.rules).map(([f,g])=>[f,B(g)&&Array.isArray(g.repairs)?{...g,repairs:g.repairs.map(a=>B(a)?{...a,act:r(a.act)}:a)}:g])):void 0;return n?{...e,...l?{policy:l}:{},...u?{rules:u}:{}}:e}function he(e,o){let s=Ge(e,Je(o));return s&&s!==e?`did you mean "${s}"?`:void 0}var $e="graview-document",we=1,Se=256*1024,se=64*1024,ke=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,be=/^[a-z][A-Za-z0-9]*$/,$n=/^[a-z0-9\u00df-\u00ff'-]+( [a-z0-9\u00df-\u00ff'-]+){0,2}$/,Qe=12,wn=new Set(["id","kind"]),Sn=/^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|[a-z][A-Za-z0-9]*)$/,On=["string","text","number","integer","boolean","date","datetime","enum","list","url","email","image","video","file","app-link","phone","place","duration"];function jn(){let e=$=>$ in Object.prototype,o=Y($=>!e($),"every object already has this name \u2014 choose another"),s=($,L)=>[...$===void 0?[]:[Re($)],...L===void 0?[]:[de(L)]],n=($,L)=>S().check(...s($,L)),r=($,L,Q)=>N($).check(...s(L,Q)),l=$=>S().check(K(ke,`${$} names are kebab-case, lower-case words joined by hyphens like "tool-note" (field and relation names are camelCase, like "supersededBy")`)),u=S().check(K(Sn,'relation names are one camelCase word, like "supersededBy" (kind names are kebab-case, like "tool-note")'),o),f=S().check(K(be,'field names are one word or camelCase, like "dueDate", so rules say them bare (kind names are kebab-case, like "tool-note")'),Y($=>!wn.has($),'a field cannot be called "id" or "kind" \u2014 the framework keeps those; try "type" or "category"'),o),g=n(1,500),a=S().check(de(40),K($n,'an alias is up to three lower-case words, like "supplier"')),i=n(1,2e3),d=n(1,300),h=w({type:V(On),required:t(_()),description:t(g),label:t(n(1,60)),aliases:t(r(a,1,Qe)),options:t(r(n(1,80),1,100)),optionLabels:t(A(n(1,80),n(1,80))),of:t(V(["string","number","date","image","video","file"])),default:t(Z()),unit:t(n(void 0,12)),format:t(V(["money","percent","duration","markdown"])),min:t(G()),max:t(G()),step:t(G()),renamedFrom:t(S().check(K(be))),repeats:t(_()),collaborative:t(_())}).check(De(($,L)=>{$.type==="enum"&&!$.options&&L.addIssue({code:"custom",message:'an enum field lists its "options"',path:["options"]}),$.type!=="enum"&&$.options&&L.addIssue({code:"custom",message:'"options" belongs only on an enum field',path:["options"]});for(let Q of Object.keys($.optionLabels??{}))$.options?.includes(Q)||L.addIssue({code:"custom",message:`"${Q}" is labeled, and is none of the field's options`,path:["optionLabels",Q]});$.type!=="list"&&$.of&&L.addIssue({code:"custom",message:'"of" belongs only on a list field',path:["of"]}),$.repeats&&$.type!=="date"&&$.type!=="datetime"&&L.addIssue({code:"custom",message:'"repeats" belongs only on a date or datetime field',path:["repeats"]})})),m=S().check(K(new RegExp(`${ke.source}|${Ne.source}`),'a relation goes to a kind of this document, like "house", or of another app, like "@nick/house/house"')),p=w({to:x([r(m,1),I("*")]),cardinality:t(V(["one","many"])),description:t(g),inverse:t(n(1,80)),appendOnly:t(_()),renamedFrom:t(S()),tidying:t(I("never"))}),c=x([i,w({expr:i,label:t(n(1,60)),description:t(g),format:t(V(["money","percent","duration"])),unit:t(n(1,12)),hidden:t(_())})]),j=w({noun:t(n(1,40)),plural:t(n(1,40)),aliases:t(r(a,1,Qe)),description:t(g),fields:A(f,h).check(Y($=>Object.keys($).length>0,"a kind has at least one field")),label:t(d),describe:t(d),lifecycle:t(w({field:f,retired:r(x([S(),G(),_()]),1)})),figure:t(n(void 0,2e4)),glance:t(r(f,1,20)),page:t(w({fields:t(r(f,1,40)),groups:t(r(w({title:n(1,60),fields:r(f,1,40)}),1,12))})),edges:t(A(u,p)),computed:t(A(S(),c).check(Y($=>Object.keys($).length<=20,"a kind works out at most 20 computed fields"))),fieldRoles:t(A(S(),S())),renamedFrom:t(S().check(K(ke))),people:t(_()),archives:t(I(!1)),tidying:t(V(["never","no-links"]))}),k=x([S(),G(),_(),Fe(),N(Z()),w({expr:i})]),O=S().check(K(/^\$[A-Za-z][A-Za-z0-9]*$/,'a reference is "$" and a name, like "$subject" or "$new"')),E=x([w({create:l("kind"),as:t(S().check(K(be))),set:t(A(f,k))}),w({set:A(f,k),target:t(O)}),w({connect:u,from:O,to:O}),w({sever:u,from:O,to:O}),w({remove:O})]),b=w({title:t(n(1,80)),description:t(g),fromTheOtherEnd:t(n(1,80)),on:t(x([l("kind"),r(l("kind"),1)])),creates:t(l("kind")),sets:t(A(f,k)),writes:t(r(f,1)),connects:t(u),severs:t(u),setsOther:t(A(f,k)),replaces:t(x([I(!0),r(u,1,10)])),removes:t(I(!0)),args:t(A(f,h)),effects:t(r(E,1,20)),allowedWhen:t(i),refusal:t(d),destructive:t(_())}),F=w({act:l("act"),label:t(n(1,80)),args:t(A(S(),k))}),M=w({title:t(n(1,120)),description:t(g),over:x([I("graph"),l("kind")]),when:t(i),require:i,says:t(d),repairs:t(r(F,void 0,10))}),C=w({roles:x([r(l("role"),1),I("*")]),mutations:x([r(l("act"),1),I("*")]),kinds:t(x([N(l("kind")),I("*")])),describe:t(g),self:t(_()),ownEnd:t(_())}),y=t(r(f,1)),v=w({roles:x([r(l("role"),1),I("*")]),kinds:r(l("kind"),1),own:t(_()),via:t(u),fields:y,hide:y}),D=w({grants:N(C),sees:t(N(v))}),ie=w({accent:t(S().check(K(/^#[0-9a-fA-F]{6}$/,'an accent is a color like "#c2577a"'))),ground:t(x([S().check(K(/^#[0-9a-fA-F]{6}$/,'a ground is a color like "#eef3f8"')),w({light:t(S().check(K(/^#[0-9a-fA-F]{6}$/,'a ground is a color like "#eef3f8"'))),dark:t(S().check(K(/^#[0-9a-fA-F]{6}$/,'a ground is a color like "#101826"')))})])),name:t(n(1,60)),currency:t(S().check(K(/^[A-Z]{3}$/,'a currency is its three-letter code, like "USD" or "EUR"'))),locale:t(n(2,35)),timeZone:t(n(1,64)),logo:t(x([n(1,se),w({src:n(1,se),alt:t(n(1,120))}),w({light:n(1,se),dark:t(n(1,se)),alt:t(n(1,120)),darkFallback:t(I("invert"))})])),favicon:t(x([n(1,se),w({emoji:S()})])),typography:t(w({display:t(n(1,200)),body:t(n(1,200)),mono:t(n(1,200))})),shape:t(w({radius:t(G().check(U(0),W(32))),density:t(G().check(U(.75),W(1.5)))})),accents:t(A(S(),G().check(U(0),W(360)))),scheme:t(V(["light","dark","auto"])),subtitle:t(I(!1))}),q=A(S(),Z()),H=x([n(1,120),w({by:n(1,120),direction:t(V(["asc","desc"]))})]),xe=G().check(ee(),U(1),W(9999)),mn=ne({create:t(_()),options:t(ne({sort:t(H),columnSort:t(H),search:t(r(n(1,120),void 0,40)),filters:t(r(n(1,120),void 0,40)),horizon:t(x([G().check(ee(),U(1),W(200)),ne({years:G().check(ee(),U(1),W(200)),title:n(1,80),from:t(xe),to:t(xe)})]))}))}),gn=w({card:t(N(Z())),row:t(N(Z())),page:t(N(Z()))}),zn=()=>{let $=t(V(["asc","desc"]));return x([n(1,120),w({by:n(1,120),direction:$,then:t(x([n(1,120),w({by:n(1,120),direction:$})]))})])},yn=()=>x([n(1,120),w({by:n(1,120),order:t(r(n(1,80),void 0,40)),closed:t(r(n(1,80),void 0,40))})]),Ae=ne({order:t(N(S())),hide:t(N(S())),first:t(S()),primary:t(r(n(1,80),void 0,40)),scene:t(n(1,40)),pages:t(n(1,40)),lists:t(A(S(),w({filters:t(r(n(1,120),void 0,40)),sort:t(zn()),group:t(yn()),export:t(_())})))}),hn=w({act:l("act"),title:t(n(1,80)),intro:t(g),fields:t(r(f,1,40)),say:t(g),submit:t(n(1,80)),role:t(l("role"))}),kn=w({$schema:t(S()),format:I($e),formatVersion:I(we),name:n(1,80),description:t(g),version:t(G().check(ee(),U(1))),kinds:A(l("kind"),j).check(Y($=>Object.keys($).length>0,"a document declares at least one kind"),Y($=>Object.keys($).length<=40,"a document declares at most 40 kinds")),computed:t(A(S(),c)),acts:t(A(l("act"),b)),rules:t(A(l("rule"),M)),roles:t(N(l("role"))),policy:t(D),modules:t(q),lenses:t(N(mn)),pages:t(Ae),views:t(A(S(),x([gn,N(Z())]))),brand:t(ie),settings:t(N(q)),migrations:t(N(q)),connections:t(A(l("connection"),q)),purpose:t(q),forms:t(A(l("form"),hn)),publishing:t(w({mode:V(["live","on-publish"]),working:r(l("role"),void 0,40),publishers:t(r(l("role"),1,40))}))});return{FieldSpec:h,EdgeSpec:p,ComputedSpec:c,KindSpec:j,ValueSpec:k,EffectSpec:E,ActSpec:b,RepairSpec:F,RuleSpec:M,GrantSpec:C,SightSpec:v,PolicySpec:D,BrandSpec:ie,PagesSpec:Ae,DocumentSpec:kn}}var vn,P=()=>vn??=jn(),Un=T(()=>P().FieldSpec),Zn=T(()=>P().EdgeSpec),Wn=T(()=>P().ComputedSpec),Yn=T(()=>P().KindSpec),Hn=T(()=>P().ValueSpec),Jn=T(()=>P().EffectSpec),Xn=T(()=>P().ActSpec),Qn=T(()=>P().RepairSpec),et=T(()=>P().RuleSpec),nt=T(()=>P().GrantSpec),tt=T(()=>P().SightSpec),ot=T(()=>P().PolicySpec),st=T(()=>P().BrandSpec),it=T(()=>P().PagesSpec),en=T(()=>P().DocumentSpec);var xn={};function nn(e,o=xn,s=we){let{document:n,respelled:r}=Ee(e),l=r.length>0?{respelled:r}:{};if(!n||typeof n!="object"||Array.isArray(n))return{document:n};let u=n;if(u.format!==$e||typeof u.formatVersion!="number"||u.formatVersion>=s)return{document:n,...l};let f=u.formatVersion,g=structuredClone(u);for(let a=f;a<s;a++){let i=o[a];if(!i)throw new Error(`there is no upgrade from format ${a} to ${a+1}`);g={...i(g),formatVersion:a+1}}return{document:g,from:f,...l}}function tn(e,o,s){let n=Object.keys(e).filter(f=>e[f].edges?.[o]!==void 0);if(n.length===0)return;let r=n.map(f=>e[f].edges[o].to),l=r.some(f=>f==="*")?"*":[...new Set(r.flatMap(f=>f))];if(s.length===0||s.some(f=>n.includes(f)))return{reversed:!1,kinds:l};let u=n.filter(f=>{let g=e[f].edges[o].to;return g==="*"||s.every(a=>g.includes(a))});return u.length>0?{reversed:!0,kinds:u}:{reversed:!1,kinds:l}}var rn=(e,o)=>{let s=e?.fields[o];return s!==void 0&&(s.type==="duration"||(s.type==="number"||s.type==="integer")&&s.format==="duration")};function on(e,o,s,n){if(n==="out"){let r=e[o]?.edges?.[s]?.to;return r===void 0?[]:r==="*"?Object.keys(e):r}return Object.entries(e).filter(([,r])=>{let l=r.edges?.[s]?.to;return l!==void 0&&(l==="*"||l.includes(o))}).map(([r])=>r)}function Oe(e,o,s){if(s.t==="ident")return e[o]?.edges?.[s.name]?on(e,o,s.name,"out"):void 0;if(s.t==="where")return Oe(e,o,s.set);if(s.t==="call"&&(s.fn==="out"||s.fn==="in")&&s.args[0]?.t==="lit"&&typeof s.args[0].value=="string")return on(e,o,s.args[0].value,s.fn)}var sn=(e,o,s)=>{let n=o.filter(r=>e[r]?.fields[s]!==void 0);return n.length>0&&n.every(r=>rn(e[r],s))};function an(e,o,s){let n=e.kinds,r=n[o],l=new Map(s),u=new Map,f=(a,i)=>{if(i>8)return!1;switch(a.t){case"ident":return rn(r,a.name)||g(a.name,i+1);case"member":{let d=Oe(n,o,a.object);return d!==void 0&&sn(n,d,a.name)}case"call":{if(a.fn!=="sum"&&a.fn!=="min"&&a.fn!=="max")return!1;let[d,h]=a.args,m=d&&Oe(n,o,d);return m!==void 0&&h?.t==="ident"&&sn(n,m,h.name)}case"binary":return(a.op==="+"||a.op==="-")&&f(a.left,i)&&f(a.right,i);case"unary":return a.op==="-"&&f(a.operand,i);default:return!1}},g=(a,i)=>{if(r?.computed?.[a]===void 0)return!1;if(u.has(a))return u.get(a);u.set(a,!1);let d=l.get(a),h=d!==void 0&&f(d,i);return u.set(a,h),h};return s.map(([a])=>a).filter(a=>g(a,0))}var An={title:["string","text"],rich_text:["string","text"],number:["number","integer"],select:["enum","string"],status:["enum","string"],multi_select:["list"],date:["date","datetime"],checkbox:["boolean"],url:["url","string"],email:["email","string"],phone_number:["phone","string"],people:["string","text","list"]};var cn=new Set(Object.values(An).flat());function ln(e,o){let s=new Map;if(!e||typeof e!="object")return new Map;for(let n of Object.values(e)){if(!n||typeof n!="object"||typeof n.kind!="string")continue;let r=o[n.kind]?.fields;if(!r)continue;let l=[];n.system==="google-calendar"&&n.fields&&typeof n.fields=="object"?l=Object.values(n.fields).filter(f=>typeof f=="string"):n.system==="notion"&&(l=n.properties&&typeof n.properties=="object"?Object.keys(n.properties):Object.keys(r).filter(f=>cn.has(r[f].type)));let u=s.get(n.kind)??new Set;for(let f of l)Object.hasOwn(r,f)&&u.add(f);s.set(n.kind,u)}return new Map([...s].filter(([,n])=>n.size>0).map(([n,r])=>[n,Object.keys(o[n].fields).filter(l=>r.has(l))]))}function dn(e,o,s=`kinds.${e}.page`){let n=o.page;if(!n)return[];let r=[],l=[...Object.keys(o.fields),...Object.keys(o.computed??{})],u=new Set,f=(a,i)=>{l.includes(a)?u.has(a)&&r.push(z("page-field-twice",i,`"${a}" is on ${e}'s page twice; name each field once`)):r.push(z("page-field",i,`${e}'s page is to show "${a}", and ${e} has no field or computed field called that`,`use one of: ${l.join(", ")}`)),u.add(a)};(n.fields??[]).forEach((a,i)=>f(a,`${s}.fields.${i}`));let g=new Set;return(n.groups??[]).forEach((a,i)=>{let d=a.title.trim().toLowerCase();g.has(d)&&r.push(z("page-group-twice",`${s}.groups.${i}.title`,`${e}'s page has two groups called "${a.title}"; give each its own title`)),g.add(d),a.fields.forEach((h,m)=>f(h,`${s}.groups.${i}.fields.${m}`))}),r}function pn(e,o=[]){return Ie({declared:Object.keys(e.fields),paged:[...e.page?.fields??[],...(e.page?.groups??[]).flatMap(s=>s.fields)],must:s=>!!e.fields[s].required&&e.fields[s].default===void 0,naming:o})}var En=new Set(["subject","now","today","me"]);function Rn(e){if((typeof e=="string"?e:JSON.stringify(e??null)).length>Se)return{findings:[z("too-large","",`a document may be at most ${Se/1024} KB`)]};if(typeof e=="string")try{e=JSON.parse(e)}catch(n){return{findings:[z("not-json","",`this is not JSON: ${n.message}`)]}}try{e=nn(e).document}catch(n){return{findings:[z("format","formatVersion",n.message)]}}e=Xe(e);let o=en.safeParse(e);if(!o.success)return{findings:o.error.issues.map(n=>{let r=n.path.map(String).join(".");if(n.code==="unrecognized_keys")return z("unknown-key",r,`${n.keys.map(l=>`"${l}"`).join(", ")} ${n.keys.length===1?"is":"are"} not part of a Graview document here`,"check the spelling against docs/declaration-document.md");if(n.code==="invalid_union"&&/\.effects\.\d+$/.test(r))return z("effect-shape",r,"this effect is not one Graview knows",'an effect is one of {"create": kind, "as"?: name, "set"?: {field: value}}, {"set": {field: value, \u2026}, "target"?: "$ref"}, {"connect"|"sever": relation, "from": "$ref", "to": "$ref"}, {"remove": "$ref"}');if(n.code==="invalid_key"){let l=n.issues?.[0]?.message;return z("shape",r,`the name "${String(n.path.at(-1))}" is not allowed here${l?`: ${l}`:""}`)}return z("shape",r,n.message)})};let s=o.data;return{document:s,findings:Fn(s)}}var le=e=>[e??[]].flat();function fn(e){let o=new Map;for(let[s,n]of Object.entries(e.kinds))for(let[r,l]of Object.entries(te(n.edges))){let u=o.get(r);o.set(r,{name:r,from:[...u?.from??[],s],to:l.to==="*"||u?.to==="*"?"*":[...new Set([...u?.to??[],...l.to])],cardinality:l.cardinality??"many"})}return o}function It(e){let o=new Map;for(let[n,r]of Object.entries(e.kinds)){let l=oe(r),u=pe(r.edges);o.set(n,{fields:new Set([...Object.keys(r.fields),...u.keys()]),edges:new Map(Object.entries(te(r.edges)).map(([f,g])=>[f,g.cardinality??"many"])),...l?{computed:l}:{},...u.size>0?{linked:u}:{}})}let s=oe(e);return s&&o.set(Ce,{computed:s}),o}function un(e,o){let s=[],n=le(e.on),r=(l,u)=>{let f=tn(o.kinds,l,n)?.reversed===!0,[g,a]=f?["$to","$subject"]:["$subject","$to"];return u==="connect"?{connect:l,from:g,to:a}:{sever:l,from:g,to:a}};if(e.creates){let l=o.kinds[e.creates],u={};for(let f of Object.keys(l?.fields??{}))u[f]=`$${f}`;for(let f of e.effects??[])"set"in f&&!("create"in f)&&R(f.target)==="new"&&Object.assign(u,f.set);s.push({create:e.creates,as:"new",set:u})}return e.sets&&s.push({set:e.sets}),e.writes&&!(e.creates&&e.on===void 0)&&s.push({set:Object.fromEntries(e.writes.map(l=>[l,`$${l}`]))}),e.connects&&(e.replaces&&s.push({replace:e.replaces===!0?[e.connects]:[...e.replaces],keep:e.connects}),s.push(r(e.connects,"connect"))),e.severs&&s.push(r(e.severs,"sever")),e.setsOther&&(e.connects||e.severs)&&s.push({set:e.setsOther,target:"$to"}),e.removes&&s.push({remove:"$subject"}),e.effects&&s.push(...e.effects.filter(l=>!(e.creates&&"set"in l&&!("create"in l)&&R(l.target)==="new"))),s}function je(e,o,s){try{let n=J(e),r=re(n);for(let l of r.unknownFunctions)s.push(z("unknown-function",o,`"${l}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));return n}catch(n){if(n instanceof ae){s.push(z("expression",o,n.sentence+` (at character ${n.at+1})`));return}throw n}}function ve(e,o,s){try{return X(e)}catch(n){if(n instanceof Ue||n instanceof ae){s.push(z("template",o,(n instanceof ae,n.sentence)));return}throw n}}function Fn(e){let o=[],s=new Set(Object.keys(e.kinds)),n=fn(e),r=e.acts??{},l=new Set(e.roles??[]),u=(a,i)=>pe(e.kinds[a]?.edges).has(i),f=a=>Object.keys(e.kinds).some(i=>u(i,a));for(let[a,i]of Object.entries(e.kinds)){let d=`kinds.${a}`;for(let[m,p]of Object.entries(i.edges??{})){if(!Te(p)&&p.to!=="*")for(let c of p.to)s.has(c)||o.push(z("edge-target",`${d}.edges.${m}.to`,`"${c}" is not a kind this document declares`));i.fields[m]&&o.push(z("edge-field-clash",`${d}.edges.${m}`,`"${m}" is both a field and a relation of ${a}`,"rename one of them"))}i.lifecycle&&!i.fields[i.lifecycle.field]&&o.push(z("lifecycle-field",`${d}.lifecycle.field`,`${a} has no field "${i.lifecycle.field}"`));let h=m=>i.computed!==void 0&&Object.hasOwn(i.computed,m);for(let m of i.glance??[])!i.fields[m]&&!h(m)&&o.push(z("glance-field",`${d}.glance`,`a glance at ${a} is to say "${m}", and ${a} has no field or computed field called that`,`use one of: ${[...Object.keys(i.fields),...Object.keys(i.computed??{})].join(", ")}`));o.push(...dn(a,i));for(let m of["label","describe"]){let p=i[m];if(!p)continue;let c=ve(p,`${d}.${m}`,o);for(let j of c??[])if(j.expr){for(let k of re(j.expr).names)if(!i.fields[k]){if(h(k)){He(i,k)||o.push(z("template-field",`${d}.${m}`,`${a}'s ${k} is worked out from beyond the record, and a ${m} is said with no graph to read`,`show it in a view instead, or name a computed field worked out from ${a}'s own fields`));continue}o.push(z("template-field",`${d}.${m}`,`${a} has no field "${k}" for its ${m} to show`,m==="label"?"a label can only show the record's own fields and what they work out":void 0))}}}for(let[m,p]of Object.entries(i.fields)){p.default!==void 0&&p.type==="enum"&&!p.options?.includes(String(p.default))&&o.push(z("default-option",`${d}.fields.${m}.default`,`"${String(p.default)}" is not one of ${m}'s options`));let c=`${m}Repeat`;p.repeats&&(i.fields[c]||i.edges?.[c]||i.computed?.[c])&&o.push(z("repeat-clash",`${d}.fields.${m}.repeats`,`${a} already has "${c}", where how ${m} repeats is kept`))}}for(let[a,i]of Object.entries(r)){let d=`acts.${a}`;for(let c of le(i.on))s.has(c)||o.push(z("act-kind",`${d}.on`,`"${c}" is not a kind this document declares`));let h=le(i.on),m=un(i,e);if(i.creates&&i.on===void 0&&i.writes&&s.has(i.creates)){for(let c of i.writes)if(!e.kinds[i.creates].fields[c])if(e.kinds[i.creates].computed?.[c]!==void 0)o.push(z("computed-written",`${d}.writes`,`${i.creates}'s ${c} is worked out, not written: no act can set it`,"write the stored fields it is worked out from"));else{if(u(i.creates,c))continue;o.push(z("act-field",`${d}.writes`,`${i.creates} has no field "${c}"`))}}m.length===0&&o.push(z("act-empty",d,`"${a}" does nothing`,"give it effects or a shorthand such as sets or creates"));let p=new Map;m.forEach((c,j)=>{let k=m.length-(i.effects?.length??0),O=i.effects&&j>=k?`${d}.effects.${j-k}`:d;if("create"in c){if(!s.has(c.create))o.push(z("act-kind",`${O}.create`,`"${c.create}" is not a kind this document declares`));else for(let b of Object.keys(c.set??{}))e.kinds[c.create].fields[b]||(e.kinds[c.create].computed?.[b]!==void 0?o.push(z("computed-written",`${O}.set.${b}`,`${c.create}'s ${b} is worked out, not written: no act can set it`,"set the stored fields it is worked out from")):o.push(z("act-field",`${O}.set.${b}`,`${c.create} has no field "${b}"`)));c.as&&p.set(c.as,c.create)}else if("connect"in c||"sever"in c){let b="connect"in c?c.connect:c.sever;!n.has(b)&&!f(b)&&o.push(z("act-edge",`${O}.${"connect"in c?"connect":"sever"}`,`"${b}" is not a relation any kind declares`)),R(c.from)==="subject"&&h.length===0&&o.push(z("act-subject",`${d}.on`,`"${a}" acts on "$subject" but does not say which kinds it is "on"`))}else if("set"in c){let b=R(c.target??"$subject"),F=b==="subject"?h:p.has(b??"")?[p.get(b)]:[];b==="subject"&&h.length===0&&o.push(z("act-subject",`${d}.on`,`"${a}" changes "$subject" but does not say which kinds it is "on"`));for(let M of Object.keys(c.set))for(let C of F)if(!(!s.has(C)||e.kinds[C].fields[M]))if(e.kinds[C].computed?.[M]!==void 0)o.push(z("computed-written",`${O}.set.${M}`,`${C}'s ${M} is worked out, not written: no act can set it`,"set the stored fields it is worked out from"));else{if(u(C,M))continue;o.push(z("act-field",`${O}.set.${M}`,`${C} has no field "${M}"`))}}else"remove"in c&&R(c.remove)==="subject"&&h.length===0&&o.push(z("act-subject",`${d}.on`,`"${a}" removes "$subject" but does not say which kinds it is "on"`));("set"in c&&c.set?Object.values(c.set):[]).forEach(b=>{b&&typeof b=="object"&&!Array.isArray(b)&&"expr"in b&&je(b.expr,`${O}.set`,o)})}),i.allowedWhen&&je(i.allowedWhen,`${d}.allowedWhen`,o),i.refusal&&ve(i.refusal,`${d}.refusal`,o)}for(let[a,i]of Object.entries(e.rules??{})){let d=`rules.${a}`;i.over!=="graph"&&!s.has(i.over)&&o.push(z("rule-kind",`${d}.over`,`"${i.over}" is not a kind this document declares`));let h=i.over==="graph"?void 0:e.kinds[i.over];for(let m of["when","require"]){let p=i[m];if(!p)continue;let c=je(p,`${d}.${m}`,o);if(!c)continue;let j=re(c);for(let k of j.names)if(i.over==="graph")o.push(z("rule-name",`${d}.${m}`,`"${k}" means nothing in a rule over the whole graph`,`name a kind in "over", or use all('kind')`));else if(h&&!h.fields[k]&&!h.edges?.[k]&&h.computed?.[k]===void 0){let O=Object.keys(h.edges??{}).find(E=>E.includes("-")&&E.split("-").includes(k));o.push(z("rule-name",`${d}.${m}`,`${i.over} has no field or relation called "${k}"`,O?`"${O}" reads as a subtraction in a rule; rename the relation to one camelCase word, like "${O.replace(/-([a-z0-9])/g,(E,b)=>b.toUpperCase())}"`:void 0))}for(let k of j.edges)!n.has(k)&&!f(k)&&o.push(z("rule-edge",`${d}.${m}`,`"${k}" is not a relation any kind declares`));for(let k of j.sweeps)s.has(k)?i.over!=="graph"&&o.push(Le("rule-cost",`${d}.${m}`,`this rule looks at every ${k} for every ${i.over}, which grows slowly as the app grows`,"walk a relation with out()/in() instead of all() where you can")):o.push(z("rule-kind",`${d}.${m}`,`"${k}" is not a kind this document declares`))}i.says&&ve(i.says,`${d}.says`,o),(i.repairs??[]).forEach((m,p)=>{!r[m.act]&&!fe(m.act)&&!ye(m.act,e.kinds)&&o.push(z("repair-act",`${d}.repairs.${p}.act`,`"${m.act}" is not an act this document declares`,he(m.act,e)))})}let g=e.policy;return g&&(g.grants.forEach((a,i)=>{if(a.roles!=="*"&&l.size>0)for(let d of a.roles)l.has(d)||o.push(z("grant-role",`policy.grants.${i}.roles`,`"${d}" is not one of the document's roles`));if(a.mutations!=="*")for(let d of a.mutations)!r[d]&&!fe(d)&&!ye(d,e.kinds)&&o.push(z("grant-act",`policy.grants.${i}.mutations`,`"${d}" is not an act this document declares`,he(d,e)))}),(g.sees??[]).forEach((a,i)=>{for(let d of a.kinds)s.has(d)||o.push(z("sight-kind",`policy.sees.${i}.kinds`,`"${d}" is not a kind this document declares`));if(a.roles!=="*"&&l.size>0)for(let d of a.roles)l.has(d)||o.push(z("sight-role",`policy.sees.${i}.roles`,`"${d}" is not one of the document's roles`))})),o.push(...Ye(e)),o}function Dn(e){return e.label?[...e.label.matchAll(/\{\s*([A-Za-z_][A-Za-z0-9_]*)/g)].map(o=>o[1]):[ge(e)??[]].flat()}function Nn(e,o,s,n){let r=new Map,l=le(e.on),u=new Map,f=new Map;(l.length>0||o.some(p=>"remove"in p&&R(p.remove)==="subject"||"from"in p&&(R(p.from)==="subject"||R(p.to)==="subject")||"set"in p&&!("create"in p)&&R(p.target??"$subject")==="subject"))&&r.set(me,{ref:l.length>0?l:"*",required:!0});let a=e.args??{},i=e.writes?.length===1,d=(p,c)=>c&&p.type===c.type&&p.min===void 0&&p.max===void 0&&p.step===void 0?{...p,...c.min===void 0?{}:{min:c.min},...c.max===void 0?{}:{max:c.max},...c.step===void 0?{}:{step:c.step}}:p,h=(p,c)=>c&&p.type===c.type&&p.format===void 0&&p.unit===void 0?{...d(p,c),...c.format?{format:c.format}:{},...c.unit?{unit:c.unit}:{}}:d(p,c),m=(p,c,j)=>{if(p===me||En.has(p)||u.has(p)||r.has(p))return;let k=a[p]?h(a[p],j):void 0;r.set(p,k?{field:k,optional:!k.required,required:!!k.required}:c())};for(let p of o)if("create"in p){let c=s.kinds[p.create],j=c?pn(c,Dn(c)):[],k=O=>j.includes(O)?j.indexOf(O):j.length;for(let[O,E]of Object.entries(p.set??{}).sort(([b],[F])=>k(b)-k(F))){let b=R(E),F=c?.fields[O];if(b&&F){let M=!!F.required&&F.default===void 0;m(b,()=>({field:F,optional:!M,required:M}),F)}}p.as&&u.set(p.as,p.create)}else if("connect"in p||"sever"in p){let c=n.get("connect"in p?p.connect:p.sever);for(let[j,k]of[["from",p.from],["to",p.to]]){let O=R(k);if(!O)continue;let E=j==="to"?c?.to??"*":c?.from??"*";E!=="*"&&!f.has(O)&&f.set(O,E),m(O,()=>({ref:E,required:!0}))}}else if("set"in p){let c=R(p.target??"$subject"),j=c==="subject"?l[0]:u.get(c??"")??f.get(c??"")?.[0];c&&c!=="subject"&&!u.has(c)&&m(c,()=>({ref:"*",required:!0}));for(let[k,O]of Object.entries(p.set)){let E=R(O);if(!E)continue;let b=j?s.kinds[j]?.fields[k]:void 0;m(E,()=>b?{field:b,optional:!i,required:i}:{any:!0,required:!1},b)}}else if("remove"in p){let c=R(p.remove);c&&m(c,()=>({ref:"*",required:!0}))}for(let[p,c]of Object.entries(a))r.has(p)||r.set(p,{field:c,optional:!c.required,required:!!c.required});return r}function Pt(e,o={}){let s=Rn(e);if(!s.document||ue(s.findings))return{ok:!1,findings:s.findings};let n=s.document,r=[...s.findings];o.previous&&r.push(...Mn(n,o.previous));let l=Tn(n,r);return ue(l.findings)?{ok:!1,findings:l.findings}:Be(l,o)}function ce(e,o){return e.map(s=>{let n=!s.format&&s.expr?.t==="ident"?o?.[s.expr.name]?.format:void 0;return n==="money"||n==="percent"?{...s,format:n}:s})}function Tn(e,o){let s=fn(e),n={},r=ln(e.connections,e.kinds);for(let[i,d]of Object.entries(e.kinds)){let h=ge(d),m=d.label??(h?`{${h}}`:void 0),p=oe(d),c=p?an(e,i,[...p]):[];n[i]={...m?{label:ce(X(m),d.fields)}:{},...d.describe?{describe:ce(X(d.describe),d.fields)}:{},...p?{computed:[...p]}:{},...c.length>0?{durations:c}:{},...r.has(i)?{keptInStep:r.get(i)}:{}}}let l={};for(let[i,d]of Object.entries(e.acts??{})){let h=un(d,e),m=Nn(d,h,e,s),p=d.destructive??h.some(y=>"remove"in y||"sever"in y||"replace"in y),c=[...new Set(h.flatMap(y=>"create"in y?[y.create]:[]))],j=[...new Set(h.flatMap(y=>"connect"in y?[y.connect]:[]))],k=[...new Set(h.flatMap(y=>"sever"in y?[y.sever]:"replace"in y?y.replace:[]))],O=[...new Set(h.flatMap(y=>"set"in y&&!("create"in y)&&R(y.target??"$subject")==="subject"?Object.keys(y.set):[]))],E=new Map;for(let y of h){if(!("connect"in y)&&!("sever"in y))continue;let v=s.get("connect"in y?y.connect:y.sever);for(let[D,ie]of[["from",y.from],["to",y.to]]){let q=R(ie),H=D==="to"?v?.to:v?.from;q&&q!=="subject"&&H&&H!=="*"&&E.set(q,[...new Set([...E.get(q)??[],...H])])}}let b={};for(let y of h){if(!("set"in y)||"create"in y)continue;let v=R(y.target??"$subject");for(let D of v&&v!=="subject"&&E.get(v)||[])b[D]=[...new Set([...b[D]??[],...Object.keys(y.set)])]}let F={};for(let y of h)if(!(!("set"in y)||"create"in y||R(y.target??"$subject")!=="subject"))for(let[v,D]of Object.entries(y.set??{}))typeof D=="string"&&R(D)===void 0||typeof D=="number"||typeof D=="boolean"?F[v]=typeof D=="string"&&D.startsWith("$$")?D.slice(1):D:delete F[v];let M=c.length===0&&h.every(y=>!("set"in y)||!y.set||Object.values(y.set).every(v=>!(v&&typeof v=="object"&&!Array.isArray(v)&&"expr"in v))),C=new Map;for(let y of h)if(!(!("set"in y)||!y.set))for(let v of Object.values(y.set))v&&typeof v=="object"&&!Array.isArray(v)&&"expr"in v&&C.set(v.expr,J(v.expr));l[i]={title:d.title??i.replace(/-/g," "),effects:h,args:[...m],...d.allowedWhen?{guard:J(d.allowedWhen)}:{},...d.refusal?{refusal:ce(X(d.refusal),e.kinds[[d.on??[]].flat()[0]??""]?.fields)}:{},exprs:[...C],destructive:p,idempotent:M,creates:c,connects:j,severs:k,writes:O,writesOther:b,sets:F}}let u={};for(let[i,d]of Object.entries(e.rules??{}))u[i]={title:d.title??i.replace(/-/g," "),require:J(d.require),...d.when?{when:J(d.when)}:{},...d.says?{says:ce(X(d.says),e.kinds[d.over]?.fields)}:{}};let f=Ve(e,o),g=Ze(e),a=We(e);return{format:qe,document:e,findings:o,kinds:n,...e.computed?{facts:[...oe(e)??[]]}:{},edges:[...s].map(([i,{from:d,to:h,cardinality:m}])=>[i,{from:d,to:h,cardinality:m}]),acts:l,rules:u,brand:f,...Object.keys(g).length>0?{viewSpecs:g}:{},...a?{home:a}:{}}}function Gt(e,o,s){let n=/^defineNode\("([^"]+)"\)/.exec(o)?.[1],r=n?s.kinds[n]:void 0;if(!n||!r)return e;let l=Object.keys(r.fields).filter(u=>u!=="label").slice(0,3);return{...e,path:`kinds.${n}.glance`,fix:`Say which: "glance": [${l.map(u=>`"${u}"`).join(", ")}] on kinds.${n} \u2014 the facts a person compares one by, at a glance.`}}function Mn(e,o){let s=[],n=new Set(Object.values(o.kinds).flatMap(r=>Object.keys(r.edges??{})));for(let[r,l]of Object.entries(e.kinds)){let u=l.renamedFrom;u&&!o.kinds[u]&&s.push(z("renamed-from-nothing",`kinds.${r}.renamedFrom`,`${r} says it was ${u}, and the previous version has no kind called ${u}`,"name the kind it was, or drop renamedFrom"));let f=o.kinds[u??r];for(let[g,a]of Object.entries(l.fields)){let i=a.renamedFrom;i&&!f?.fields[i]&&s.push(z("renamed-from-nothing",`kinds.${r}.fields.${g}.renamedFrom`,`${g} says it was ${i}, and the previous ${u??r} has no field called ${i}`,"name the field it was, or drop renamedFrom"))}for(let[g,a]of Object.entries(l.edges??{})){let i=a.renamedFrom;i&&!n.has(i)&&s.push(z("renamed-from-nothing",`kinds.${r}.edges.${g}.renamedFrom`,`${g} says it was ${i}, and the previous version has no relation called ${i}`,"name the relation it was, or drop renamedFrom"))}}return s}export{bn as ActRefusal,Pt as compileDocumentWithoutCheck,un as effectsOf,Gt as inDocumentWords,It as kindShapes,Rn as readDocument};
@@ -1 +0,0 @@
1
- import{a,b}from"./chunk.YEBGI6ED.js";import"./chunk.HDUO2USQ.js";import"./chunk.WC3DENU4.js";import"./chunk.VNDKKTED.js";import"./chunk.4MP72LPR.js";import"./chunk.SDO3U72B.js";import"./chunk.VSCIXAHN.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";export{a as ActivityFilter,b as InteractionRow};
@@ -1,2 +0,0 @@
1
- var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as Ge}from"./chunk.BJUUSIQY.js";import{a as Ke}from"./chunk.ZP5RT2EK.js";import{a as Ve}from"./chunk.6C2MHWSX.js";import{a as Je}from"./chunk.HDUO2USQ.js";import{a as pe}from"./chunk.TY4GQJKC.js";import{c as ue}from"./chunk.WC3DENU4.js";import{E as Oe,G as hn,J as _e,P as We,T as Ue,ba as ze}from"./chunk.4MP72LPR.js";import{Xb as De,ad as He,da as B,fc as fe,ga as ce,hc as Le,ja as W,kd as qe,ma as Ne,md as Be,oa as G,zb as je}from"./chunk.VSCIXAHN.js";import{j as ee}from"./chunk.FQLNBIQ5.js";import{b as xe}from"./chunk.AJZBJBMO.js";var kn=["search-miss","unanswered","refused","tool-invalid"];var _n=new RegExp("[\\u0000-\\u001f\\u007f-\\u009f\\u200b-\\u200f\\u2028-\\u202e\\u2066-\\u2069]","g");var K=e=>e.onBehalfOf?K(e.onBehalfOf):e.id!==void 0?`${e.kind}:${e.id}`:`${e.kind}:?`,ve=e=>e.toLowerCase().replace(/\s+/g," ").replace(/^[\s\p{P}]+|[\s\p{P}]+$/gu,"");var bn=new Set("a an and are at be by can do does for from has have how i in is it me my of on or our the their there this to was we what when where which who why will with you your".split(" "));function ne(e,n,t,i,o){let r=new Map;for(let f of e){let d=n(f);if(d===void 0)continue;let c=r.get(d)??{first:f,people:new Set,times:0,last:f};c.people.add(K(f.by)),c.times+=1,c.last=f,r.set(d,c)}return[...r.entries()].filter(([,f])=>f.people.size>=i).sort(([f,d],[c,a])=>a.people.size-d.people.size||a.times-d.times||f.localeCompare(c)).slice(0,o).map(([f,d])=>({...t(d.last,f),people:d.people.size,times:d.times}))}function wn(e,n={}){let t=Math.max(1,n.minPeople??2),i=n.most??12,o=n.reader?K(n.reader):void 0,r=e.filter(a=>!qe(a.by)&&(o===void 0||K(a.by)!==o)),f=Object.fromEntries(kn.map(a=>{let s=r.filter(u=>u.type===a);return[a,{events:s.length,people:new Set(s.map(u=>K(u.by))).size}]})),d=[],c=new Map;for(let a of r){let s=a.type==="search-miss"?a.words:a.type==="unanswered"?a.question:void 0;if(s!==void 0)for(let u of new Set(ve(s).split(/[^\p{L}\p{N}]+/u))){if(u.length<3||bn.has(u))continue;let g={...a,id:`${a.id}:${u}`};d.push(g),c.set(g,u)}}return{events:r.length,people:new Set(r.map(a=>K(a.by))).size,byType:f,searches:ne(r,a=>a.type==="search-miss"&&ve(a.words)||void 0,(a,s)=>({words:s}),t,i),questions:ne(r,a=>a.type==="unanswered"&&ve(a.question)||void 0,(a,s)=>({question:s}),t,i),words:ne(d,a=>c.get(a),(a,s)=>({word:s}),t,i),refusals:ne(r,a=>a.type==="refused"?`${a.act}|${a.code}`:void 0,a=>({act:a.act,code:a.code}),t,i),tools:ne(r,a=>a.type==="tool-invalid"?`${a.tool}|${a.act??""}`:void 0,a=>{let s=a;return{tool:s.tool,...s.act?{act:s.act}:{},...s.then?{then:s.then}:{}}},1,i)}}var Ye=e=>e.length>3&&e.endsWith("s")&&!e.endsWith("ss")?e.slice(0,-1):e;function An(e){let n=new Set,t=i=>{for(let o of i.toLowerCase().split(/[^\p{L}\p{N}]+/u))o.length>0&&n.add(Ye(o))};for(let i of e.kinds){let o=e.tryDefinition(i);t(i),t(G(o,i)),t(W(e,i));for(let r of[...o?.aliases??[],...Object.values(o?.fieldAliases??{}).flat()])t(r);for(let r of Object.keys(o?.fields?.shape??{}))t(r),t(B(r))}return n}function Qe(e,n,t={}){let i=wn(e,{most:8,...t}),o=An(n),r=i.searches.filter(s=>!s.words.split(/[^\p{L}\p{N}]+/u).some(u=>u.length>0&&o.has(Ye(u)))).map(s=>({words:s.words,people:s.people})),f=i.questions.map(s=>({question:s.question,people:s.people})),d=i.tools.map(s=>({tool:s.tool,...s.act?{act:s.act}:{},...s.then?{then:s.then}:{},times:s.times})),c=s=>`${s} ${s===1?"person":"people"}`;return{said:[...r.length>0?[`Searched for, found nothing, and nothing here is called it: ${r.map(s=>`\u201C${s.words}\u201D (${c(s.people)})`).join(", ")}.`]:[],...f.length>0?[`Asked and not answered: ${f.map(s=>`\u201C${s.question}\u201D (${c(s.people)})`).join(", ")}.`]:[],...d.length>0?[`Tool calls refused as invalid: ${d.map(s=>`${s.tool}${s.act?` (${s.act})`:""} ${s.times===1?"once":`${s.times} times`}${s.then?`, then worked as ${s.then}`:""}`).join("; ")}.`]:[]].join(`
2
- `),unknownWords:r,questions:f,toolMistakes:d}}var Sn=e=>/^(?:aggregate|kind):([^,]+)$/.exec(e)?.[1];function Xe(e,n){let t=e.about??[];if(e.field!==void 0&&e.on!==void 0&&n(e.on))return{on:"field",id:e.on,field:e.field};let i=t.filter(n);if(i.length>1)return{on:"selection",ids:i};if(e.on!==void 0&&n(e.on))return{on:"record",id:e.on};if(i.length===1)return{on:"record",id:i[0]};let o=[e.on,...t].map(r=>r===void 0?void 0:Sn(r)).find(r=>r!==void 0);return e.place!==void 0?{on:"lens",place:e.place,...o?{kind:o}:{}}:o!==void 0?{on:"list",kind:o}:{on:"place",place:"home"}}var Q=e=>e.on==="record"||e.on==="field"?[e.id]:e.on==="selection"?e.ids:e.on==="act"&&e.id!==void 0?[e.id]:[],ye=(e,n)=>e.tryDefinition(n)?.fields?.shape??{},Y=(e,n)=>e.tryDefinition(n)?.edges??{},ge=(e,n)=>new Set(e.tryDefinition(n)?.display?.hide??[]),L=(e,n)=>ce(e.tryDefinition(n.kind),n),$e=(e,n,t)=>Ne(e.tryDefinition(n),t)||B(t),Ce=e=>typeof e=="boolean"?e?"yes":"no":String(e);function me(e,n){let t=e.kindsKeptFrom(n);return new Set(e.schema.kinds.filter(i=>!t.has(i)))}function Re(e,n,t,i){if(!e.permits(n,t).ok)return!1;if(!i)return!0;try{return e.previewAll([n],{author:t}).ops.length>0}catch{return!1}}function he(e,n,t){let i=e,{principal:o}=t,r=t.each??8,f=ee(i)?.store??i,d=f.seenBy(o),c=f.schema,a=me(f,o),s=l=>{let h=d.graph.getNode(l);return h&&a.has(h.kind)?h:void 0},u=f.allMutations(),g=new Map(u.map(l=>[l.name,l])),b=[],C=new Set,A=l=>{C.has(l.id)||(C.add(l.id),b.push(l))},m=l=>l.slice(0,r),x=Q(n).filter(l=>s(l)!==void 0);if(Q(n).length>0&&x.length===0)return{target:n,candidates:[]};let O=x.length===1?s(x[0]):void 0,k=O?.kind??(n.on==="list"?n.kind:n.on==="lens"?n.kind??t.places?.find(l=>l.as===n.place)?.kind:void 0)??(n.on==="selection"?s(x[0])?.kind:void 0);if(k!==void 0&&!a.has(k))return{target:n,candidates:[]};let p=(l,h)=>`act:${l}${Object.keys(h).length>0?`:${Object.values(h).map(R=>String(R)).join(",")}`:""}`,w=(l,h,R,E,$)=>{l.destructive||Object.values(h).some(y=>typeof y=="string"&&f.graph.has(y)&&s(y)===void 0)||Re(f,{name:l.name,args:{...h}},o,E.length===0)&&A({type:"act",id:p(l.name,h),label:R,description:$??l.description??R,mutation:l.name,args:h,asks:E})};if(n.on!=="place"||t.acts)if(t.acts)for(let l of t.acts){let h=g.get(l.mutation);!h||l.destructive||n.on==="act"&&l.mutation!==n.act||w(h,l.args,l.label,(l.open??[]).filter(R=>!R.optional).map(R=>R.name),l.why)}else{let l=O?[O]:[];for(let h of u){if(n.on==="act"&&h.name!==n.act)continue;let R=h.input.shape??{},E=$=>Object.entries(R).filter(([y,v])=>y!==$&&v.safeParse?.(void 0).success===!1).map(([y])=>y);if(h.subject)for(let $ of l)fe(c,h).includes($.kind)&&w(h,{[h.subject.arg]:$.id},`${h.title??B(h.name)}: ${L(c,$)}`,E(h.subject.arg));else k!==void 0&&(h.creates??[]).includes(k)&&w(h,{},h.title??B(h.name),E(void 0))}}let T=b.filter(l=>l.type==="act");b.splice(0,b.length,...m(T));let F=(l,h)=>{let R=Le(c,u).get(l.kind),E=ye(c,l.kind),$=ge(c,l.kind),y=[];for(let[v,j]of Object.entries(E)){if(h!==void 0?v!==h:$.has(v)||l[v]!==void 0)continue;let D=pe(j),J=D?.type==="enum"?D.options??[]:D?.type==="boolean"?[!0,!1]:[];if(J.length===0)continue;let _=(R?.get(v)??[]).map(N=>g.get(N)).find(N=>N?.subject!==void 0&&Re(f,{name:N.name,args:{[N.subject.arg]:l.id,[v]:J.find(Se=>Se!==l[v])??J[0]}},o,!0));if(_?.subject)for(let N of J)l[v]!==N&&y.push({type:"fill",id:`fill:${l.id}:${v}:${Ce(N)}`,label:`${$e(c,l.kind,v)}: ${Ce(N)}`,description:`Set ${$e(c,l.kind,v).toLowerCase()} of ${L(c,l)} to ${Ce(N)}`,record:l.id,field:v,value:N,call:{name:_.name,args:{[_.subject.arg]:l.id,[v]:N}}})}for(let[v,j]of Object.entries(Y(c,l.kind))){if(h!==void 0&&v!==h)continue;let D=j.to==="*"?[...a]:j.to.filter(I=>a.has(I)),J=new Set(d.graph.out(l.id,v).map(I=>I.id)),_=u.find(I=>(I.connects??[]).includes(v)&&I.subject!==void 0&&fe(c,I).includes(l.kind));if(!_?.subject)continue;let N=De(_.input).find(I=>I.name!==_.subject.arg);if(!N)continue;let Se=D.flatMap(I=>N.kinds.length===0||N.kinds.includes(I)?d.graph.nodesOfKind(I):[]).filter(I=>I.id!==l.id&&!J.has(I.id)&&s(I.id)!==void 0);for(let I of m(Se)){let Me={name:_.name,args:{[_.subject.arg]:l.id,[N.name]:I.id}};Re(f,Me,o,!0)&&y.push({type:"fill",id:`fill:${l.id}:${v}:${I.id}`,label:`${B(v)}: ${L(c,I)}`,description:`Link ${L(c,l)} to ${L(c,I)}${j.description?` as ${j.description}`:""}`,record:l.id,field:v,value:I.id,call:Me})}}return y};if(n.on==="field"&&O)for(let l of F(O,n.field))A(l);else if(O&&n.on==="record")for(let l of m(F(O)))A(l);let q=l=>{let h=W(c,l).toLowerCase(),R=[{type:"panel",id:`panel:${l}:list`,label:`A list of ${h}`,description:`Every ${G(c.tryDefinition(l),l).toLowerCase()} this viewer may see, as a list`,panel:{lens:"blocks",kind:l}}],E=ge(c,l);for(let[$,y]of Object.entries(ye(c,l))){if(E.has($))continue;let v=pe(y),j=$e(c,l,$).toLowerCase();if(v?.type==="enum")R.push({type:"panel",id:`panel:${l}:group:${$}`,label:`${V(h)} by ${j}`,description:`A list of ${h} grouped by ${j}`,panel:{lens:"blocks",kind:l,group:$}}),R.push({type:"panel",id:`panel:${l}:columns:${$}`,label:`Columns of ${h} by ${j}`,description:`${V(h)} in a column for each ${j}`,panel:{lens:"columns",kind:l,column:$}});else if(v?.type==="number"||v?.type==="integer"||v?.type==="date"||v?.type==="datetime"){let D=v.type==="date"||v.type==="datetime";R.push({type:"panel",id:`panel:${l}:sort:${$}`,label:`${V(h)} by ${j}`,description:`A list of ${h}, the ${D?"latest":"highest"} ${j} first`,panel:{lens:"blocks",kind:l,sort:{by:$,direction:"desc"}}}),D&&R.push({type:"panel",id:`panel:${l}:calendar:${$}`,label:`A calendar of ${h}`,description:`${V(h)} on a calendar by ${j}`,panel:{lens:"calendar",kind:l,start:$}})}}return R},H=n.on==="place"?[...a]:k!==void 0?[k]:[];for(let l of H)for(let h of m(q(l)))A(h);for(let l of m((t.places??[]).filter(h=>h.kind===void 0?n.on==="place":a.has(h.kind)&&(n.on==="place"||h.kind===k))))n.on==="lens"&&l.as===n.place||A({type:"place",id:`place:${l.as}`,label:l.title,description:`Go to ${l.title}`,place:l.as});if(O){let l=[];for(let[h,R]of Object.entries(Y(c,O.kind)))for(let E of d.graph.out(O.id,h))s(E.id)&&l.push({type:"record",id:`record:${E.id}`,label:L(c,E),description:`${V(R.description??B(h))}: ${L(c,E)}`,record:E.id,relation:h});for(let h of c.kinds)for(let[R,E]of Object.entries(Y(c,h)))if(!(E.to!=="*"&&!E.to.includes(O.kind)))for(let $ of d.graph.in(O.id,R))$.kind===h&&s($.id)&&l.push({type:"record",id:`record:${$.id}`,label:L(c,$),description:`${V(E.inverse??B(R))}: ${L(c,$)}`,record:$.id,relation:R});for(let h of m(l))A(h)}else if(n.on==="list"||n.on==="lens")for(let l of m(k!==void 0?d.graph.nodesOfKind(k):[]))s(l.id)&&A({type:"record",id:`record:${l.id}`,label:L(c,l),description:`Open ${L(c,l)}`,record:l.id});else if(n.on==="selection")for(let l of x){let h=s(l);A({type:"record",id:`record:${l}`,label:L(c,h),description:`Open ${L(c,h)}`,record:l})}return{target:n,candidates:b}}var V=e=>e&&`${e[0].toUpperCase()}${e.slice(1)}`,xn={columns:["board","kanban","column","lane","pipeline","stage","funnel"],board:["board","map","floor","layout","seat","slot"],calendar:["calendar","schedule","date","due","month","week","agenda","deadline","day"],timeline:["timeline","gantt","schedule","roadmap","span"],coverage:["coverage","matrix","grid","gap"],plan:["plan","floor","map","region","area"],blocks:["list","table","summary","overview","dashboard","card"]},On=new Set(["a","an","the","of","for","my","our","me","us","to","with","and","in","on","by","that","which","i","we","want","need","show","open","go","draw","make","new","view","views","panel","panels","page","lens","please","all","every","some","see","can","could","would","like","one","what","is","are","do","does","here","there","how","it","this","these","those"]),te=e=>e.length>3&&e.endsWith("ies")?`${e.slice(0,-3)}y`:e.length>3&&e.endsWith("s")&&!e.endsWith("ss")?e.slice(0,-1):e,Te=e=>e.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").split(/[^a-z0-9]+/).filter(Boolean);function Ze(e,n,t){let i=e,o=ee(i)?.store??i,r=o.schema,f=me(o,t.principal),d=o.seenBy(t.principal),c=Q(n),a=new Set;for(let p of c){let w=d.graph.getNode(p)?.kind;w!==void 0&&f.has(w)&&a.add(w)}if(c.length>0&&a.size===0)return[];if(n.on==="list"&&a.add(n.kind),n.on==="lens"){let p=n.kind??t.places.find(w=>w.as===n.place)?.kind;p!==void 0&&a.add(p)}let s=new Map;for(let p of r.kinds){if(!f.has(p))continue;let w=r.tryDefinition(p);for(let T of[p,G(w,p),W(r,p)])for(let F of Te(T))s.set(te(F),p)}let u=Te(t.said??"").filter(p=>!On.has(p)),g=new Set,b=[];for(let p of u){let w=s.get(te(p));w!==void 0?g.add(w):b.push(te(p))}let C=g.size>0?g:a;if((t.said??"").trim()!==""&&u.length===0)return[];if(C.size===0&&u.length===0)return[];let A=[];t.places.forEach((p,w)=>{if(p.hidden||n.on==="lens"&&p.as===n.place)return;let T=p.over??(p.kind!==void 0?[p.kind]:[]);if(T.length>0&&!T.some(H=>f.has(H)))return;let F=T.some(H=>C.has(H)),q=!F&&(p.reads??[]).some(H=>C.has(H));C.size>0&&!F&&!q||A.push({place:p,own:F,reads:q,at:w})});let m=p=>new Set(Te(p.title).map(te)),x=new Set(b.filter(p=>A.some(({place:w})=>m(w).has(p)))),O=[];for(let{place:p,own:w,reads:T,at:F}of A){let q=m(p),H=new Set((xn[p.lens??""]??[]).map(te)),l=b.filter($=>q.has($)||H.has($)&&!x.has($)).length,h=b.length-l;if(b.length>0&&l===0)continue;let R=!T&&h===0?"full":"partial",E=(w?4:T?2:1)+l*2-h+(R==="full"?1:0);O.push({view:{place:p.as,title:p.title,...p.kind!==void 0?{kind:p.kind}:{},fit:R},score:E,at:F})}return O.filter((p,w)=>!O.slice(0,w).some(T=>T.view.place===p.view.place&&T.view.title===p.view.title)).sort((p,w)=>w.score-p.score||p.at-w.at).slice(0,t.most??3).map(p=>p.view)}var Ee=new WeakMap;function vn(e){let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619)>>>0;return n.toString(36)}function $n(e,n){let t=e,i=ee(t)?.store??t,o=i.schema,r=me(i,n),d=i.allMutations().filter(A=>!A.destructive&&i.permits({name:A.name,args:{}},n).ok!==!1),c=`${[...r].join(",")}|${d.map(A=>A.name).join(",")}`,a=Ee.get(o)?.get(c);if(a)return a;let s=[...r].map(A=>{let m=ge(o,A),x={};for(let[w,T]of Object.entries(ye(o,A))){if(m.has(w))continue;let F=pe(T);F&&(x[w]=F.type==="enum"?`enum:${(F.options??[]).join("|")}`:F.type)}let O={};for(let[w,T]of Object.entries(Y(o,A)))O[w]=T.to==="*"?[...r]:T.to.filter(F=>r.has(F));let k=o.tryDefinition(A),p=Object.entries(k?.fieldAliases??{}).filter(([w,T])=>w in x&&T.length>0);return{kind:A,noun:G(o.tryDefinition(A),A),plural:W(o,A),fields:x,relations:O,...k?.aliases&&k.aliases.length>0?{aliases:k.aliases}:{},...p.length>0?{fieldAliases:Object.fromEntries(p)}:{}}}),u=d.map(A=>({name:A.name,title:A.title??B(A.name),...A.subject?{on:fe(o,A).filter(m=>r.has(m))}:{}})),g={kinds:s,acts:u},b={version:vn(JSON.stringify(g)),...g},C=Ee.get(o)??new Map;return C.set(c,b),Ee.set(o,C),b}var Cn=e=>e.name??e.id??e.kind;function en(e,n,t){let i=e,{principal:o}=t,r=ee(i)?.store??i,f=r.seenBy(o),d=r.schema,c=me(r,o),a=p=>{let w=f.graph.getNode(p);return w&&c.has(w.kind)?w:void 0},s=p=>({id:p.id,kind:p.kind,label:L(d,p)}),u=Q(n),g=u.length===1?a(u[0]):void 0,b=g?Object.fromEntries(Object.keys(ye(d,g.kind)).filter(p=>!ge(d,g.kind).has(p)&&g[p]!==void 0&&p!=="label").map(p=>[p,g[p]])):{},C={on:n.on,...g?{record:{...s(g),fields:b}}:{},...n.on==="field"&&g?{field:n.field}:{},...n.on==="list"&&c.has(n.kind)?{kind:n.kind}:{},...n.on==="lens"?{place:n.place,...n.kind&&c.has(n.kind)?{kind:n.kind}:{}}:{},...n.on==="place"?{place:n.place}:{},...n.on==="act"?{act:n.act}:{}},A=[...new Set([...n.on==="selection"?n.ids:[],...t.selection??[]])].flatMap(p=>{let w=a(p);return w?[s(w)]:[]}),m=[];if(g){for(let p of Object.keys(Y(d,g.kind)))for(let w of f.graph.out(g.id,p))a(w.id)&&m.push({...s(w),relation:p,direction:"out"});for(let p of d.kinds)for(let w of Object.keys(Y(d,p)))for(let T of f.graph.in(g.id,w))T.kind===p&&a(T.id)&&m.push({...s(T),relation:w,direction:"in"})}let x=f.batches().filter(p=>!p.ops.every(je)).slice(-(t.recent??6)).reverse().map(p=>({intent:p.intent,at:p.at,by:Cn(p.author)})),O=(t.purpose?.jobs??[]).filter(p=>Ge(p,o.roles)&&c.has(p.kind)).map(p=>({name:p.name,ask:p.ask,kind:p.kind})),k=t.purpose&&(t.purpose.for!==void 0||O.length>0)?{...t.purpose.for!==void 0?{for:t.purpose.for}:{},jobs:O}:void 0;return{...t.place!==void 0?{place:t.place}:{},target:C,selection:A,neighbors:m.slice(0,24),recent:x,schema:$n(r,o),...k?{purpose:k}:{},...t.friction?{friction:Qe(t.friction,d,{reader:o})}:{}}}function ie(e){if(!e.off)return e.fast??(e.decide?{model:e.name??"decide",decide:e.decide}:void 0)}function U(e){if(e.off)return;if(e.thinking)return e.thinking;let n=e.name??"model";if(e.complete){let t=e.complete;return{model:n,think:({system:i,prompt:o})=>t({prompt:o,system:i})}}if(e.turn){let t=e.turn;return{model:n,think:async({system:i,prompt:o})=>({text:await t({system:i,messages:[{role:"user",content:o}],tools:[],call:async()=>({error:"No tools here."})})})}}}var Pe=(e,n,t)=>e?n/1e6*(e.inputPerMillion??0)+t/1e6*(e.outputPerMillion??0):void 0,Ie=()=>`ai-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;function Rn(e,n,t=[]){let i=o=>{let r=e.graph.getNode(o);return r?ce(e.schema.tryDefinition(r.kind),r):"a record"};switch(n.on){case"record":return i(n.id);case"field":return`${i(n.id)} \xB7 ${n.field}`;case"selection":return`${n.ids.length} records`;case"list":return e.schema.tryDefinition(n.kind)?W(e.schema,n.kind):n.kind;case"lens":case"place":return t.find(o=>o.as===n.place)?.title??(n.place==="home"?"Home":n.place);case"act":return n.act}}var nn=e=>e.type!=="act"||e.asks.length===0,be=(e,n)=>({id:e.id,type:e.type,label:e.label,...n!==void 0?{confidence:n}:{}});function X(e,n){let t=n.interaction??Ie(),i=he(n.store,n.target,{principal:n.principal,...n.acts?{acts:n.acts}:{},...n.places?{places:n.places}:{}}),o=en(n.store,n.target,{principal:n.principal,...n.place?{place:n.place}:{},...n.selection?{selection:n.selection}:{},...n.purpose?{purpose:n.purpose}:{}}),r=[];return{id:t,catalog:i,state:o,entry:{id:t,at:new Date().toISOString(),by:n.by??n.principal,target:n.target,targetLabel:Rn(n.store,n.target,n.places)},usage:r,meter:f=>{r.push(f),e.meter?.({...f,interaction:t})}}}async function oe(e,n,t,i){let o=await e.decide(n,t),{inputTokens:r,outputTokens:f}=o.usage,d=Pe(e.price,r,f);return i({tier:"fast",model:e.model,inputTokens:r,outputTokens:f,...d!==void 0?{costUsd:d}:{}}),o.answers}async function re(e,n,t,i,o){let r=await e.think({system:n,prompt:t,state:i.state,catalog:i.catalog}),f=r.usage?.inputTokens,d=r.usage?.outputTokens,c=r.usage?.costUsd??(f!==void 0?Pe(e.price,f,d??0):void 0);return o({tier:"thinking",model:e.model,...f!==void 0?{inputTokens:f}:{},...d!==void 0?{outputTokens:d}:{},...c!==void 0?{costUsd:c}:{}}),Ve(r.text)}function se(e,n){let t=new Map(e.map((i,o)=>[`c${o+1}`,i]));return{question:{type:"choice",instructions:n,criteria:Object.fromEntries([...t].map(([i,o])=>[i,`${o.label} \u2014 ${o.description}`]))},of:i=>t.get(i)}}function ae(e,n,t){if(e?.type!=="choice")return[];let i=e,o=Object.entries(i.probabilities).sort((r,f)=>f[1]-r[1]);return o.some(([r])=>r===i.choice)||o.unshift([i.choice,i.confidence]),o.flatMap(([r,f])=>{let d=n(r);return d?[{candidate:d,confidence:f}]:[]}).slice(0,t)}var M=(e,n,t,i)=>({interaction:{...e.entry,ask:{kind:t,said:n??""},offered:[],outcome:"failed",failed:i,usage:[...e.usage]},offers:[]}),Z="AI isn't on here.";async function tn(e,n,t=3){let i=X(e,n),o=n.said??"Suggest",r=i.catalog.candidates.filter(nn).slice(0,24);if(r.length===0)return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:[],outcome:"offered",usage:[]},offers:[]};let f=ie(e),d=U(e),c=[];try{if(f){let{question:a,of:s}=se(r,"Which of these would the person most likely want to do next, here?"),u=await oe(f,{...i.state,candidates:r.map(g=>({id:g.id,type:g.type,says:g.description}))},{next:a},i.meter);c=ae(u.next,s,t)}else if(d){let a=await re(d,'You suggest what a person most likely wants to do next in an app. Answer only JSON: {"pick": [candidate ids, best first]}. Pick only ids from the candidates.',JSON.stringify({state:i.state,candidates:r.map(u=>({id:u.id,says:u.description}))}),i,i.meter);c=(Array.isArray(a?.pick)?a.pick.filter(u=>typeof u=="string"):[]).flatMap(u=>r.filter(g=>g.id===u)).slice(0,t).map(u=>({candidate:u}))}else return M(i,o,"suggest",Z)}catch(a){return M(i,o,"suggest",a instanceof Error?a.message:String(a))}return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:c.map(({candidate:a,confidence:s})=>be(a,s)),outcome:"offered",usage:[...i.usage]},offers:c.map(({candidate:a})=>a)}}var Tn=e=>`several:${e}`;async function it(e,n,t=2){let i=X(e,{...n,acts:[]}),o=n.said??"Suggest for the chosen",r=n.target.on==="selection"?n.target.ids.length:1,d=[...n.shared.map(s=>({type:"act",id:Tn(s.id),label:s.label,description:`${s.label}, for all ${r} chosen`,mutation:s.mutation,args:s.args,asks:[]})),...i.catalog.candidates.filter(s=>s.type==="panel"||s.type==="place")].slice(0,24),c=ie(e);if(!c)return M(i,o,"suggest",Z);if(d.length===0)return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:[],outcome:"offered",usage:[]},offers:[]};let a;try{let{question:s,of:u}=se(d,`Which of these would the person most likely want to do next with the ${r} records they chose together?`),g=await oe(c,{...i.state,candidates:d.map(b=>({id:b.id,type:b.type,says:b.description}))},{next:s},i.meter);a=ae(g.next,u,t).filter((b,C)=>C===0||b.confidence>=En)}catch(s){return M(i,o,"suggest",s instanceof Error?s.message:String(s))}return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:a.map(({candidate:s,confidence:u})=>be(s,u)),outcome:"offered",usage:[...i.usage]},offers:a.map(({candidate:s})=>s)}}var En=.25;async function on(e,n){let t=X(e,n),i=n.said??"Fill in",o=t.catalog.candidates.filter(u=>u.type==="fill"),r=new Map;for(let u of o)r.set(u.field,[...r.get(u.field)??[],u]);if(r.size===0)return{interaction:{...t.entry,ask:{kind:"fill",said:i},offered:[],outcome:"offered",usage:[]},offers:[]};let f=ie(e),d=U(e),c=[];try{if(f){let u=[...r].map(([b,C],A)=>({key:`f${A+1}`,field:b,...se(C,`Which value fits "${b}" best for this record?`)})),g=await oe(f,t.state,Object.fromEntries(u.map(b=>[b.key,b.question])),t.meter);for(let b of u){let C=!Pn(n.store,n.target,b.field)&&In(n.store,n.target,b.field)!=="one";c.push(...ae(g[b.key],b.of,C?3:1).filter((A,m)=>m===0||A.confidence>=.4))}}else if(d){let u=await re(d,`You fill in a record's fields in an app. Answer only JSON: {"fills": [candidate ids]}, at most one per field, only ids from the candidates.`,JSON.stringify({state:t.state,candidates:o.map(C=>({id:C.id,says:C.description}))}),t,t.meter),g=Array.isArray(u?.fills)?u.fills.filter(C=>typeof C=="string"):[],b=new Set;for(let C of g){let A=o.find(m=>m.id===C);A?.type==="fill"&&!b.has(A.field)&&(b.add(A.field),c.push({candidate:A}))}}else return M(t,i,"fill",Z)}catch(u){return M(t,i,"fill",u instanceof Error?u.message:String(u))}let a=t.usage.at(-1)?.model,s=de(n.store,{interaction:t.id,target:n.target,basis:i,...a?{model:a}:{},proposals:c.flatMap(({candidate:u,confidence:g})=>u.type==="fill"?[{id:u.id,label:u.label,said:u.description,call:u.call,record:u.record,field:u.field,...g!==void 0?{confidence:g}:{}}]:[])},n.principal);return{interaction:{...t.entry,ask:{kind:"fill",said:i},offered:s.proposals.map(u=>({id:u.id,type:"fill",label:u.label,...u.confidence!==void 0?{confidence:u.confidence}:{}})),outcome:"offered",usage:[...t.usage]},offers:[],...s.proposals.length>0?{ghost:s}:{}}}function Pn(e,n,t){let i=n.on==="record"||n.on==="field"?n.id:void 0,o=i?e.graph.getNode(i)?.kind:void 0,r=(o?e.schema.tryDefinition(o)?.fields?.shape:void 0)??{};return t in r}function In(e,n,t){let i=n.on==="record"||n.on==="field"?n.id:void 0,o=i?e.graph.getNode(i)?.kind:void 0;return o?e.schema.tryDefinition(o)?.edges?.[t]?.cardinality:void 0}async function rn(e,n){let t=X(e,n),i=n.said??"Add one",o=new Set(n.store.allMutations().filter(s=>(s.creates??[]).length>0).map(s=>s.name)),r=t.catalog.candidates.filter(s=>s.type==="act"&&s.asks.length>0&&o.has(s.mutation));if(r.length===0)return M(t,i,"record","Nothing here makes a record.");let f=U(e);if(!f)return M(t,i,"record",Z);let d;try{let s=await re(f,'You propose one new record for an app by filling in an act. Answer only JSON: {"act": a candidate id, "args": {argument: value}}. Use only the candidates, and fill every argument the act asks for with a value that fits the state.',JSON.stringify({ask:i,state:t.state,candidates:r.map(b=>({id:b.id,says:b.description,asks:b.asks}))}),t,t.meter),u=r.find(b=>b.id===s?.act),g=typeof s?.args=="object"&&s.args!==null?s.args:{};u&&(d={act:u,args:Object.fromEntries(Object.entries(g).filter(([b])=>u.asks.includes(b)))})}catch(s){return M(t,i,"record",s instanceof Error?s.message:String(s))}if(!d)return M(t,i,"record","The model named no act this app has here.");let c=t.usage.at(-1)?.model,a=de(n.store,{interaction:t.id,target:n.target,basis:i,...c?{model:c}:{},proposals:[{id:d.act.id,label:d.act.label,said:d.act.description,call:{name:d.act.mutation,args:{...d.act.args,...d.args}}}]},n.principal);return a.proposals.length===0?M(t,i,"record","What the model proposed could not be made here."):{interaction:{...t.entry,ask:{kind:"record",said:i},offered:a.proposals.map(s=>({id:s.id,type:"act",label:s.said})),outcome:"offered",usage:[...t.usage]},offers:[d.act],ghost:a}}async function sn(e,n){let t=X(e,n),i=n.said??"Make a panel",o=t.catalog.candidates.filter(s=>s.type==="panel");if(o.length===0)return M(t,i,"panel","Nothing here can be drawn as a panel.");let r=ie(e),f=U(e),d;try{if(f){let s=await re(f,'You choose a panel to draw in an app. Answer only JSON: {"panel": a candidate id, "title": a short title}. Choose only among the candidates.',JSON.stringify({ask:i,state:t.state,candidates:o.map(g=>({id:g.id,says:g.description}))}),t,t.meter),u=o.find(g=>g.id===s?.panel);u&&(d={panel:u,...typeof s?.title=="string"&&s.title.trim()?{title:s.title.trim().slice(0,60)}:{}})}else if(r){let{question:s,of:u}=se(o,`Which panel answers this best: ${i}`),g=ae((await oe(r,t.state,{panel:s},t.meter)).panel,u,1)[0];g?.candidate.type==="panel"&&(d={panel:g.candidate,confidence:g.confidence})}else return M(t,i,"panel",Z)}catch(s){return M(t,i,"panel",s instanceof Error?s.message:String(s))}if(!d)return M(t,i,"panel","The model named no panel this app can draw.");let c=d.title??d.panel.label,a={title:c,recipe:{...d.panel.panel,title:c}};return{interaction:{...t.entry,ask:{kind:"panel",said:i},offered:[be(d.panel,d.confidence)],outcome:"drawn",panel:a,usage:[...t.usage]},offers:[d.panel],panel:a}}function Fn(e){return e.off?void 0:e.answer}var Mn=`You answer a person's question about what they are looking at in an app, from the state given and nothing else. Answer only JSON: {"answer": one to three short sentences, "pick": [candidate ids that act on the answer, best first, at most three]}. Pick only ids from the candidates, and none when nothing fits. Never say an id to the person.`;async function ot(e,n){let t=X(e,n),i=n.said.trim(),o=t.catalog.candidates.filter(m=>nn(m)||m.type==="panel"||m.type==="place"||m.type==="record").slice(0,32),r=Fn(e),f=U(e),d=ie(e),c="",a=[],s=m=>m.flatMap(x=>o.filter(O=>O.id===x)).slice(0,3).map(x=>({candidate:x}));try{if(r){let m=await r.answer({said:i,target:n.target,targetLabel:t.entry.targetLabel,state:t.state,catalog:{target:t.catalog.target,candidates:o},...n.follows?{follows:n.follows}:{}}),x=m.usage?.inputTokens,O=m.usage?.outputTokens,k=m.usage?.costUsd??(x!==void 0?Pe(r.price,x,O??0):void 0);t.meter({tier:"thinking",model:r.model,...x!==void 0?{inputTokens:x}:{},...O!==void 0?{outputTokens:O}:{},...k!==void 0?{costUsd:k}:{}}),c=typeof m.text=="string"?m.text.trim():"",a=s(m.pick??[])}else if(f){let m=await re(f,Mn,JSON.stringify({ask:i,about:t.entry.targetLabel,...n.follows?{follows:n.follows}:{},state:t.state,candidates:o.map(x=>({id:x.id,says:x.description}))}),t,t.meter);c=typeof m?.answer=="string"?m.answer.trim():"",a=s(Array.isArray(m?.pick)?m.pick:[])}else if(d&&o.length>0){let{question:m,of:x}=se(o,`Which of these best answers, or acts on: ${i}`),O=await oe(d,{...t.state,asked:i,candidates:o.map(k=>({id:k.id,type:k.type,says:k.description}))},{answer:m},t.meter);a=ae(O.answer,x,3),c=a.length>0?`These fit \u201C${i}\u201D.`:""}else return M(t,i,"ask",Z)}catch(m){return M(t,i,"ask",m instanceof Error?m.message:String(m))}if(!c&&a.length===0){let m=n.target.on==="place"||n.target.on==="lens"?n.target.place:void 0,x=n.target.on==="list"||n.target.on==="lens"?n.target.kind:void 0;return Be(n.store,{type:"unanswered",question:i,...m?{place:m}:{},...x?{kind:x}:{}},n.principal),M(t,i,"ask","The AI had no answer to that here.")}let u=t.usage.at(-1)?.model,g=a.flatMap(({candidate:m,confidence:x})=>{let O=ke(m);return O?[{...O,...x!==void 0?{confidence:x}:{}}]:[]}),b=g.length>0?de(n.store,{interaction:t.id,target:n.target,basis:i,...u?{model:u}:{},proposals:g},n.principal):void 0,C=a.map(({candidate:m})=>m).filter(m=>ke(m)===void 0),A=[...C.map(m=>be(m,a.find(x=>x.candidate===m)?.confidence)),...(b?.proposals??[]).map(m=>({id:m.id,type:m.field!==void 0?"fill":"act",label:m.label,...m.confidence!==void 0?{confidence:m.confidence}:{}}))];return{interaction:{...t.entry,ask:{kind:"ask",said:i},offered:A,outcome:"offered",...c?{answer:c}:{},usage:[...t.usage]},offers:C,...b&&b.proposals.length>0?{ghost:b}:{},...c?{answer:c}:{}}}function de(e,n,t){let i=n.proposals.flatMap(o=>{try{let r=e.previewAll([o.call],{author:t}),f=r.ops.map(d=>d.intent).join("; ");return r.ops.length>0?[{...o,said:f||o.said}]:[]}catch{return[]}});return{...n,proposals:i}}function ke(e){if(e.type==="fill")return{id:e.id,label:e.label,said:e.description,call:e.call,record:e.record,field:e.field};if(e.type==="act"&&e.asks.length===0)return{id:e.id,label:e.label,said:e.description,call:{name:e.mutation,args:{...e.args}}}}function an(e,n,t){let i=n.proposals.filter(r=>t.ids===void 0||t.ids.includes(r.id));if(i.length===0)return{ok:!1,refused:"Nothing was chosen."};let o=i.flatMap(r=>r.confidence===void 0?[]:[r.confidence]);try{let f=e.applyAll(i.map(d=>d.call),{author:t.author,via:`ai:${n.interaction}`,intent:n.basis,lineage:{basis:`Asked \u201C${n.basis}\u201D`,...n.model?{model:n.model}:{},...o.length>0?{confidence:Math.min(...o)}:{},interaction:n.interaction}}).ops[0]?.batch;return f?{ok:!0,batch:f,accepted:i.map(d=>d.id)}:{ok:!1,refused:"That changes nothing now."}}catch(r){return{ok:!1,refused:r instanceof Error?r.message:String(r)}}}function dn(e,n,t){let i=e.ask.kind==="suggest"?n.length>0:e.offered.length>0&&e.offered.every(o=>n.includes(o.id));return{...e,outcome:i?"accepted":"partly",accepted:n,batches:[...e.batches??[],t]}}var ln=e=>({...e,outcome:"dismissed"});var P=xe(hn(),1);var S=xe(Ue(),1);function fn(e,n,t){let i=n.on==="selection"?n.ids:n.on==="record"||n.on==="field"?[n.id]:[],o=i.length>0?Ke(e.store,i,{principal:e.principal,...i.length===1?{focus:i[0]}:{}}).affordances.map(r=>({mutation:r.mutation,label:r.label,args:r.args,open:r.open,why:r.why,...r.destructive?{destructive:!0}:{}})):void 0;return{store:e.store,target:n,principal:e.principal,interaction:Ie(),places:e.places,selection:e.selection,...o?{acts:o}:{},...e.place?{place:e.place}:{},...t?{said:t}:{},...e.app.purpose?{purpose:e.app.purpose}:{}}}async function un(e,n,t){let i=await (__graviewPreload(import.meta.url,["./chunk.LGEA5257.js","./chunk.G4JJXA63.js","./chunk.OLFJH4RK.js","./chunk.67U6M7OV.js","./chunk.6C2MHWSX.js","./chunk.XOZU4OFA.js","./chunk.GLWSVSQL.js","./chunk.VFOON3Z3.js","./chunk.WVUJXDXZ.js","./chunk.7VKSXGTX.js","./chunk.TY4GQJKC.js","./chunk.6ZQAR5ZA.js","./chunk.W3W54DSX.js","./chunk.PI44XMY2.js","./chunk.KGW75Z5L.js","./chunk.MSWWWLEA.js","./chunk.UITT6JWW.js","./chunk.A5PDXNY6.js","./chunk.VSCIXAHN.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.QFUMFQJU.js")),o=i.recipeDraft(n.recipe,{app:e.app,sight:i.draftSight(e.app,e.principal)});if(i.isDraftFailure(o))return o.failed;t?.(),e.seatTalk.setDraft(o,null),e.goTo.draft?.(),pn()}function pn(e=180){if(typeof document>"u")return;let n=document.querySelector('[data-testid="draft-keep"]'),t=document.activeElement,i=!t||t===document.body||t.closest?.("[inert]")!==null;if(n){i&&n.focus();return}e>0&&requestAnimationFrame(()=>pn(e-1))}async function le(e,n,t,i,o){let r=fn(e,t,i),f=n==="suggest"?await tn(e.ai,r):n==="fill"?await on(e.ai,r):n==="record"?await rn(e.ai,r):await sn(e.ai,r);if(f.interaction.outcome==="failed")return n!=="suggest"&&e.desk.record(f.interaction),f;let d=c=>{let a={...f.interaction,outcome:"failed",failed:c};return e.desk.record(a),{...f,interaction:a}};if(n==="fill"||n==="record"){if(!f.ghost||f.ghost.proposals.length===0)return d("Nothing here could be filled in.");o?.(),e.desk.setGhost({ghost:f.ghost}),e.desk.record(f.interaction)}if(n==="panel"&&f.panel){let c=await un(e,f.panel,o);if(c)return d(c);e.desk.record(f.interaction)}return f}var Fe=new WeakMap,Nn=64,cn=new WeakMap;function jn(e){let n=cn.get(e);if(!n){let t=n={n:0};cn.set(e,t),e.subscribe(()=>void(t.n+=1))}return n.n}var yn=(e,n)=>{let t=Q(n);return t.length>0?t.map(i=>e.graph.getNode(i)):[jn(e)]},gn=(e,n,t)=>JSON.stringify({target:n,seat:e.principal,by:t}),mn=(e,n,t)=>{let i=yn(e.store,n);return t.schema===e.store.schema&&t.ai===e.ai&&i.length===t.depends.length&&i.every((o,r)=>o===t.depends[r])};function Dn(e,n,t="menu"){let i=Fe.get(e.store)?.get(gn(e,n,t));return i?.result!==void 0&&mn(e,n,i)?i.result:void 0}function Ln(e,n,t){let i=Fe.get(e.store);i||Fe.set(e.store,i=new Map);let o=gn(e,n,t?.by??"menu"),r=i.get(o);if(r&&mn(e,n,r))return r.result?Promise.resolve(r.result):r.asked;let f=t?t.ask():le(e,"suggest",n),d={schema:e.store.schema,ai:e.ai,depends:yn(e.store,n),asked:f};i.delete(o),i.set(o,d),i.size>Nn&&i.delete(i.keys().next().value);let c=i;return f.then(a=>{a.interaction.outcome!=="failed"?d.result=a:c.get(o)===d&&c.delete(o)}),f}async function Hn(e,n,t,i){let o=n.interaction,r=ke(t);if(r){let f=o.usage?.at(-1)?.model,d=o.offered.find(a=>a.id===t.id)?.confidence,c=de(e.store,{interaction:o.id,target:o.target,basis:`${o.ask.said}: ${t.label}`,...f?{model:f}:{},proposals:[{...r,...d!==void 0?{confidence:d}:{}}]},e.principal);if(c.proposals.length===0){let a="That can't be done now.";return e.desk.record({...o,outcome:"failed",failed:a}),a}i?.(),e.desk.setGhost({ghost:c}),e.desk.record(o);return}if(t.type==="panel"){let f=t.label,d={title:f,recipe:{...t.panel,title:f}},c=await un(e,d,i);return e.desk.record(c?{...o,outcome:"failed",failed:c}:{...o,outcome:"drawn",accepted:[t.id],panel:d}),c}i?.(),t.type==="place"?e.goTo.place(t.place):t.type==="record"&&e.goTo.record(t.record),e.desk.record({...o,outcome:"accepted",accepted:[t.id]})}async function yt(e,n){if(n.ask.kind==="ask")return ue(e.desk,{target:n.target,asked:n.ask.said}),null;let t=n.ask.kind==="panel"||n.ask.kind==="record"?n.ask.kind:"fill";return le(e,t,n.target,n.ask.said)}var z={padding:"5px 10px",fontSize:"0.875rem",borderRadius:8,width:"100%",textAlign:"left",borderWidth:1,borderStyle:"solid",borderColor:"transparent",background:"none",boxShadow:"none"},we={margin:0,padding:"4px 10px",fontSize:"0.8125rem",color:"var(--graview-ink-muted)"};function gt({target:e,close:n}){let t=Je(),i=(0,P.useMemo)(()=>Xe(e,y=>t.store.graph.has(y)),[e,t.store]),o=(0,P.useMemo)(()=>{let y=fn(t,i);return he(t.store,i,{principal:t.principal,places:t.places,...y.acts?{acts:y.acts}:{}})},[t,i]),r=o.candidates.some(y=>y.type==="fill"),f=o.candidates.some(y=>y.type==="panel"),d=(0,P.useMemo)(()=>f?Ze(t.store,i,{principal:t.principal,places:t.places,most:1}):[],[f,t,i]),c=(0,P.useMemo)(()=>new Set(t.store.allMutations().filter(y=>(y.creates??[]).length>0).map(y=>y.name)),[t.store]),a=U(t.ai)!==void 0&&o.candidates.some(y=>y.type==="act"&&y.asks.length>0&&c.has(y.mutation)),s=Oe(t.ai),u=Dn(t,i),g=JSON.stringify(i),[b,C]=(0,P.useState)(!1),[A,m]=(0,P.useState)(null),[x,O]=(0,P.useState)(s&&u===void 0);(0,P.useEffect)(()=>{if(u!==void 0||!(s||b))return;let y=!0;return O(!0),Ln(t,i).then(v=>{y&&(m(v),O(!1))}),()=>{y=!1}},[g,b]);let k=u??A,p=(k?.offers??[]).filter(y=>!(y.type==="place"&&d.some(v=>v.place===y.place))).slice(0,Math.max(0,3-d.length)),w=k?.interaction.outcome==="failed"?k.interaction.failed??"The AI could not suggest anything here.":null,T=(0,P.useRef)(!1),F=(0,P.useRef)(null);(0,P.useLayoutEffect)(()=>{k===null||!T.current||(T.current=!1,F.current?.querySelector("button")?.focus())},[k]);let q=(0,P.useRef)(!0);(0,P.useEffect)(()=>()=>{q.current=!1},[]);let[H,l]=(0,P.useState)(!1),[h,R]=(0,P.useState)(null),E=y=>{if(H)return;l(!0),R(null);let v=!1;y(()=>{v=!0,n()}).then(D=>{q.current&&(l(!1),D?R(D):v||n())},D=>{q.current&&(l(!1),R(D instanceof Error?D.message:String(D)))})},$=y=>y.interaction.outcome==="failed"?y.interaction.failed??"The AI could not do that here.":void 0;return(0,S.jsxs)("div",{ref:F,"data-testid":"inline-ai",style:{display:"grid",gap:2},children:[x&&!b?(0,S.jsx)("p",{role:"status","data-testid":"inline-ai-thinking",style:we,children:"Thinking\u2026"}):H?(0,S.jsx)("p",{role:"status","data-testid":"inline-ai-asking",style:we,children:"Asking\u2026"}):h?(0,S.jsx)("p",{role:"alert","data-testid":"inline-ai-failed",style:{...we,color:"var(--graview-warn)"},children:h}):w?(0,S.jsx)("p",{role:"status",style:we,children:w}):null,(0,S.jsxs)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:2},children:[p.map(y=>(0,S.jsx)("li",{children:(0,S.jsxs)("button",{type:"button","data-menu-item":`ai-offer:${y.id}`,"data-ai-offer":y.id,"data-ai-offer-type":y.type,onClick:()=>E(v=>Hn(t,k,y,v)),style:z,children:[y.label,(0,S.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",y.type==="panel"?"a panel":y.type==="place"?"go there":y.type==="record"?"open it":"suggested"]})]})},y.id)),!s&&k===null?(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":"ai-suggest","aria-disabled":b||void 0,onClick:y=>{b||(T.current=document.activeElement===y.currentTarget,C(!0))},style:z,children:b?"Thinking\u2026":"Suggest\u2026"})}):null,r?(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":"ai-fill",onClick:()=>E(async y=>$(await le(t,"fill",i,"Fill in",y))),style:z,children:"Fill in with AI"})}):null,a?(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":"ai-record",onClick:()=>E(async y=>$(await le(t,"record",i,"Add one",y))),style:z,children:"Add one with AI"})}):null,d.map(y=>(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":`ai-open:${y.place}`,"data-ai-existing":y.fit,onClick:()=>{n(),t.goTo.place(y.place),y.fit==="partial"&&ue(t.desk,{target:{on:"lens",place:y.place,...y.kind?{kind:y.kind}:{}}})},style:z,children:y.fit==="full"?`Open ${y.title}`:`Open and adjust ${y.title}`})},y.place)),f?(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":"ai-panel",onClick:()=>E(async y=>$(await le(t,"panel",i,"Draw a panel",y))),style:z,children:d.length>0?"Draw a new view":"Draw a panel"})}):null,(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":"ai-ask",onClick:()=>{let y=document.activeElement;n(),ue(t.desk,{target:i,returnTo:y instanceof HTMLElement&&y!==document.body?y:null})},style:z,children:"Ask about this\u2026"})})]})]})}var Ae={display:"inline-flex",alignItems:"center",minHeight:28,padding:"2px 10px",fontSize:"0.8125rem",borderRadius:8};function mt({placement:e="picture"}){let{store:n,principal:t,aiDesk:i}=ze(),o=We(n,t),{ghost:r,entries:f}=_e(i),[d,c]=(0,P.useState)(new Set);(0,P.useEffect)(()=>c(new Set),[r?.ghost.interaction]);let a=(0,P.useRef)(null),s=(0,P.useRef)(null),u=r?.batch;if((0,P.useEffect)(()=>{u!==void 0&&s.current?.focus()},[u]),!r)return null;let{ghost:g}=r,b=f.find(k=>k.id===g.interaction),C=()=>{let k=g.target.on==="record"||g.target.on==="field"?g.target.id:void 0,p=a.current?.closest("[data-graview-face], main")?.parentElement??document,w=(k?p.querySelector(`[data-graview-view="${CSS.escape(k)}"][tabindex]`):null)??document.querySelector("[data-graview-page-title]")??a.current?.closest("main")??document.querySelector("main");w&&!w.hasAttribute("tabindex")&&w.setAttribute("tabindex","-1"),w?.focus({preventScroll:!0}),i.setGhost(null)},A=g.proposals.filter(k=>!d.has(k.id)).map(k=>k.id),m=()=>{let k=an(o,g,{author:t,ids:A});if(!k.ok){i.setGhost({...r,refused:k.refused});return}b&&i.record(dn(b,k.accepted,k.batch)),i.setGhost({ghost:g,batch:k.batch,took:k.accepted.length,...r.onCard?{onCard:!0}:{}})},x=()=>{b&&r.batch===void 0&&i.record(ln(b)),C()},O=()=>{if(r.batch!==void 0)try{o.undo(r.batch,{author:t}),C()}catch(k){i.setGhost({...r,refused:k instanceof Error?k.message:String(k)})}};return(0,S.jsxs)("section",{ref:a,"data-testid":"ai-ghost","data-interaction":g.interaction,"aria-label":"Proposed by AI",style:{...e==="card"?{position:"static"}:{position:e==="page"?"fixed":"absolute",insetInline:"max(12px, calc(50% - 220px))",bottom:"calc(var(--graview-foot-room, 0px) + 72px)",zIndex:He("toast"),boxShadow:"var(--graview-lift-high)"},display:"grid",gap:8,padding:12,borderRadius:12,border:"1px dashed var(--graview-accent)",background:"var(--graview-float)",fontSize:"0.875rem"},children:[(0,S.jsx)("p",{style:{margin:0,color:"var(--graview-ink-muted)"},children:r.batch!==void 0?`Done: ${r.took===1?"one change":`${r.took} changes`}, as one.`:`Proposed by AI \xB7 ${g.basis}`}),r.batch===void 0?(0,S.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:4},children:g.proposals.map(k=>(0,S.jsx)("li",{"data-ghost-proposal":k.id,children:(0,S.jsxs)("label",{style:{display:"flex",alignItems:"baseline",gap:8,cursor:"pointer"},children:[(0,S.jsx)("input",{type:"checkbox",checked:!d.has(k.id),onChange:p=>{let w=new Set(d);p.target.checked?w.delete(k.id):w.add(k.id),c(w)}}),(0,S.jsx)("span",{style:{fontStyle:"italic",color:"var(--graview-ink)"},children:k.said}),k.confidence!==void 0?(0,S.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[Math.round(k.confidence*100),"% sure"]}):null]})},k.id))}):null,r.refused?(0,S.jsx)("p",{role:"alert",style:{margin:0,color:"var(--graview-warn)"},children:r.refused}):null,(0,S.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:r.batch===void 0?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("button",{type:"button","data-testid":"ghost-accept",disabled:A.length===0,onClick:m,style:Ae,children:A.length===g.proposals.length?"Accept":`Accept ${A.length} of ${g.proposals.length}`}),(0,S.jsx)("button",{type:"button","data-testid":"ghost-dismiss",onClick:x,style:Ae,children:"Dismiss"})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("button",{type:"button",ref:s,"data-testid":"ghost-undo",onClick:O,style:Ae,children:"Undo"}),(0,S.jsx)("button",{type:"button","data-testid":"ghost-close",onClick:C,style:Ae,children:"Close"})]})})]})}export{Xe as a,Q as b,he as c,Ze as d,ie as e,Ie as f,Rn as g,Tn as h,it as i,ot as j,fn as k,un as l,le as m,Dn as n,Ln as o,Hn as p,yt as q,gt as r,mt as s};
@@ -1 +0,0 @@
1
- import"./chunk.WVUJXDXZ.js";import{k as m,m as i}from"./chunk.7VKSXGTX.js";import"./chunk.TY4GQJKC.js";import"./chunk.6ZQAR5ZA.js";import"./chunk.W3W54DSX.js";import"./chunk.PI44XMY2.js";import"./chunk.KGW75Z5L.js";import"./chunk.A5PDXNY6.js";import"./chunk.VSCIXAHN.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";function a(t){let r=new Map;return(s,o)=>{let e=o.kind,n=r.get(e);return n===void 0&&r.set(e,n=i(t,e).length),n===0?{}:m(t,s,o).values}}export{a as computedOn};
@@ -1 +0,0 @@
1
- import{G as l,N as p,U as k,W as y,c}from"./chunk.YFSBVZTG.js";import"./chunk.G4YJPKRG.js";import{b as m}from"./chunk.3UOKUF5Z.js";import"./chunk.Q355UPFG.js";import"./chunk.MVWC3VR3.js";import"./chunk.CC5BJH5A.js";import"./chunk.CFKZXLXS.js";import"./chunk.Y5C4RXG7.js";import"./chunk.7MHCGVGM.js";import"./chunk.FRYBMS3W.js";import"./chunk.LQVAABPS.js";import"./chunk.NGTRL5U4.js";import"./chunk.3MOJF7BA.js";import"./chunk.LZIBQ3VX.js";import"./chunk.YZ7FUKAL.js";import"./chunk.KDRLUBVF.js";import"./chunk.BQIHNT7C.js";import"./chunk.TAT2IQUR.js";import"./chunk.3XGA65Y3.js";import"./chunk.BYKD5RLA.js";import"./chunk.2K4TT2BV.js";import"./chunk.VUBNBTJP.js";import"./chunk.MB7LKKUD.js";import"./chunk.WVUJXDXZ.js";import"./chunk.7VKSXGTX.js";import"./chunk.TY4GQJKC.js";import"./chunk.6ZQAR5ZA.js";import"./chunk.W3W54DSX.js";import"./chunk.PI44XMY2.js";import"./chunk.KGW75Z5L.js";import"./chunk.GZHZLJBF.js";import"./chunk.IOK4GVJC.js";import"./chunk.OJGHDWI6.js";import"./chunk.TLJOZSDD.js";import"./chunk.MSWWWLEA.js";import"./chunk.UITT6JWW.js";import"./chunk.A5PDXNY6.js";import"./chunk.WC3DENU4.js";import"./chunk.VNDKKTED.js";import{G as S,H as s,I as d,T as f,ca as g}from"./chunk.4MP72LPR.js";import"./chunk.SDO3U72B.js";import"./chunk.VSCIXAHN.js";import"./chunk.FQLNBIQ5.js";import{b as n}from"./chunk.AJZBJBMO.js";var u=n(S(),1);var t=n(f(),1);function D({context:a}){let r=l(),h=g(),[w]=(0,u.useState)(()=>s(null)),o=d(h?.seatTalk??w),P=()=>{(window.history.state?.idx??0)>0?r(-1):r("/")};return(0,t.jsxs)(k,{context:a,"data-testid":"draft-page",children:[(0,t.jsx)(y,{context:a,...o.draft?{"data-testid":"draft-title"}:{},children:o.draft?o.draft.title:"Nothing drawn"}),o.draft?(0,t.jsx)(m,{page:!0,go:e=>r(e.address),onPick:e=>{let i=a.store.graph.getNode(e);i&&r(c(a.store.schema,i.kind,e))},onDiscard:P}):(0,t.jsxs)("p",{style:{margin:0,color:"var(--graview-ink-muted)"},children:["Ask for a way of seeing \u2014 \u201Ca board of tasks by status\u201D \u2014 and it is drawn here."," ",(0,t.jsx)(p,{to:"/",style:{color:"var(--graview-accent)"},children:"Home \u2192"})]})]})}export{D as DraftPage};
@@ -1 +0,0 @@
1
- import{a,b}from"./chunk.IGVASEZU.js";import"./chunk.IHBUBZQT.js";import"./chunk.67U6M7OV.js";import"./chunk.ZP5RT2EK.js";import"./chunk.VZJWJ5XM.js";import"./chunk.GLWSVSQL.js";import"./chunk.7VKSXGTX.js";import"./chunk.TY4GQJKC.js";import"./chunk.6ZQAR5ZA.js";import"./chunk.W3W54DSX.js";import"./chunk.PI44XMY2.js";import"./chunk.KGW75Z5L.js";import"./chunk.MSWWWLEA.js";import"./chunk.UITT6JWW.js";import"./chunk.A5PDXNY6.js";import"./chunk.VSCIXAHN.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";export{b as actOnSeveral,a as actsForSeveral};
@@ -1,5 +0,0 @@
1
- var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{o as B}from"./chunk.WC3DENU4.js";import{G as R,Ga as T,J as L,T as a,ba as C}from"./chunk.4MP72LPR.js";import{a as P}from"./chunk.SDO3U72B.js";import{Ud as b,ad as w,fe as A}from"./chunk.VSCIXAHN.js";import{b as i}from"./chunk.AJZBJBMO.js";var I=i(a(),1),H=B.part(e=>(0,I.jsx)(e.ActivityRail,{calls:[]}),{quiet:!0});var x=i(a(),1),O=e=>e.tabIndex>=0&&!e.disabled&&e.getClientRects().length>0;function F(e){if(!e)return!1;if(O(e))return e.focus({preventScroll:!1}),!0;let r=[...e.querySelectorAll("a[href], button, input, select, textarea, [tabindex]")].find(O);return r?(r.focus(),!0):(e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1"),e.focus(),!0)}var E=`.graview-skips{display:contents}
2
- .graview-skip{position:absolute;width:0;height:0;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}
3
- .graview-skip:focus{width:auto;height:auto;overflow:visible;clip-path:none;padding:6px 12px;border-radius:8px;border:1px solid var(--graview-accent);background:var(--graview-float,var(--graview-panel));color:var(--graview-ink);font:inherit;font-size:.875rem;font-weight:600;box-shadow:var(--graview-lift-high);outline:2px solid var(--graview-accent);outline-offset:1px}
4
- .graview-skips[data-place=bar] .graview-skip:focus{position:fixed;left:8px;top:6px;z-index:${w("toast")}}
5
- .graview-skips[data-place=here] .graview-skip:focus{position:static;justify-self:start}`;function M({to:e,place:r="bar"}){return e.length===0?null:(0,x.jsxs)("span",{className:"graview-skips","data-place":r,children:[(0,x.jsx)("style",{children:E}),e.map(o=>(0,x.jsx)("button",{type:"button",className:"graview-skip","data-graview-skip":o.testid,"data-testid":`skip-${o.testid}`,...o.opens?{"data-graview-skip-opens":""}:{},onClick:o.go,children:o.label},o.testid))]})}var d=i(R(),1),h=i(a(),1),N=T(P(()=>(__graviewPreload(import.meta.url,["./chunk.X6A4VSSD.js","./chunk.KDRLUBVF.js","./chunk.PNW5K7BW.js","./chunk.ENL2JJ47.js","./chunk.BQIHNT7C.js","./chunk.3XGA65Y3.js","./chunk.2K4TT2BV.js","./chunk.VZJWJ5XM.js","./chunk.YEBGI6ED.js","./chunk.HDUO2USQ.js","./chunk.GZHZLJBF.js","./chunk.IOK4GVJC.js","./chunk.OJGHDWI6.js","./chunk.TLJOZSDD.js","./chunk.MSWWWLEA.js","./chunk.UITT6JWW.js","./chunk.A5PDXNY6.js","./chunk.WC3DENU4.js","./chunk.VNDKKTED.js","./chunk.4MP72LPR.js","./chunk.SDO3U72B.js","./chunk.VSCIXAHN.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.XZPKBHJT.js")))),j=N.part((e,r)=>{let o=e.RecordInteractions;return(0,h.jsx)(o,{...r})},{quiet:!0});function V(e,r,o){let t=e.target;return(t.on==="record"||t.on==="field"?t.id===r:t.on==="selection"?t.ids.includes(r):t.on==="act"?t.id===r:!1)||e.offered.some(n=>n.id===`record:${r}`||n.id.startsWith(`fill:${r}:`))||(e.batches??[]).some(n=>o(n).includes(r))}function _({id:e,style:r,headingStyle:o,className:t}){let{ai:f,aiDesk:n,store:y}=C(),{entries:u}=L(n),l=f.off===!0;(0,d.useEffect)(()=>{l||n.load()},[n,l]);let S=y.log.length,m=(0,d.useMemo)(()=>{let k=g=>y.log.all().flatMap(v=>v.batch===g?v.writes:[]);return u.filter(g=>V(g,e,k))},[u,e,y,S]);return l||m.length===0?null:(0,h.jsx)(d.Suspense,{fallback:null,children:(0,h.jsx)(j,{entries:m,...r?{style:r}:{},...o?{headingStyle:o}:{},...t?{className:t}:{}})})}var c=i(R(),1);var p=i(a(),1),G={textDecorationLine:"underline",textDecorationColor:"color-mix(in srgb, currentColor 50%, transparent)",textDecorationThickness:1,textUnderlineOffset:"0.2em"};function D({children:e,mark:r="\u2192"}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("span",{style:G,children:e}),(0,p.jsx)("span",{"aria-hidden":"true",children:r})]})}var s=i(a(),1);function Lo({context:e,stop:r,title:o,label:t,style:f,className:n,children:y,...u}){let l=b(e.views?.arrangement?.()),S=y??(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)(D,{mark:"\u2197",children:["In ",l==="Scene"?"the scene":l.replace(/^The /,"the ")]})}),m=t?{"aria-label":t}:{};if(e.overview){let k=e.overview;return(0,s.jsx)("a",{href:r,...u,...m,...o?{title:o}:{},style:f,...n?{className:n}:{},onClick:g=>{g.preventDefault(),k(r)},children:S})}return e.embedded?null:(0,s.jsx)("a",{href:`${e.sceneHref??"/"}${r}`,...u,...m,...o?{title:o}:{},style:f,...n?{className:n}:{},children:S})}function Co(){return(0,s.jsx)("a",{href:"#fresh","data-testid":"start-fresh",title:"Forget every edit made in this browser and return to the example",onClick:e=>{e.preventDefault(),window.location.assign(A(window.location.href))},style:{color:"inherit",display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24},children:"Start fresh"})}function To(e){let r=(0,c.useRef)(0),o=(0,c.useCallback)(t=>e.subscribe(()=>{r.current+=1,t()}),[e]);return(0,c.useSyncExternalStore)(o,()=>r.current,()=>0)}function Io(e){return e===void 0?{}:e==="sm"||e==="md"?{"data-size":e}:{style:{"--graview-control-height":typeof e=="number"?`${e}px`:e}}}var Oo=(e,r)=>r?`${e} ${r}`:e;export{H as a,F as b,M as c,_ as d,D as e,Lo as f,Co as g,To as h,Io as i,Oo as j};
@@ -1 +0,0 @@
1
- import{h,i as E}from"./chunk.UITT6JWW.js";import{a as M,f as z}from"./chunk.A5PDXNY6.js";import{Aa as j,C as y,Gb as N,Ha as O,Hb as k,Sa as P,Ta as D,Wb as T,da as S,db as L,dc as Z,ec as q,fc as K,gc as v,rb as V,sb as I,tb as g,xa as R}from"./chunk.VSCIXAHN.js";var J=n=>n.safeParse?.(void 0).success??!1,C=n=>h(n).shape,A=n=>{let r=h(n);if(y(r)?.type!=="literal")return;let o=y(r)?.values;return o&&o.length===1&&typeof o[0]=="string"?o[0]:void 0};function F(n,r){let o=J(r),e=h(r),t=y(e)?.type,c=T(r);if(c)return{control:"node",name:n,optional:o,kinds:c};let m=O(r);if(m)return{control:"linked",name:n,optional:o,relation:m};if(D(r)){let d=P(n);return{control:"repeat",name:n,optional:o,...d?{of:d}:{}}}if(t==="boolean")return{control:"boolean",name:n,optional:o};let f=R(e);if(f)return{control:"file",name:n,optional:o,...f==="image"?{image:!0}:f==="video"?{video:!0}:{}};if(t==="object"){let d=e.shape??{};return{control:"group",name:n,optional:o,fields:Object.entries(d).map(([a,l])=>F(a,l))}}if(t==="union"){let d=y(e)?.options??[],a=d.map(s=>C(s));if(a.every(s=>s!==void 0)){let s=Object.keys(a[0]??{}).find(u=>a.every(p=>A(p?.[u])!==void 0));if(s)return{control:"variant",name:n,optional:o,tag:s,options:d.map((u,p)=>({value:A(a[p]?.[s])??"",fields:Object.entries(a[p]??{}).filter(([w])=>w!==s).map(([w,B])=>F(w,B))}))}}let l=d.map(s=>A(s));return l.every(s=>s!==void 0)?{control:"choice",name:n,optional:o,options:l}:{control:"opaque",name:n,optional:o}}if(t==="array"){let d=y(e)?.element;return d!==void 0?{control:"list",name:n,optional:o,item:F(n,d)}:{control:"opaque",name:n,optional:o}}let i=E(r);return i.type==="text"?{control:"text",name:n,optional:o,...i.long?{long:!0}:{},...j(e)?{app:!0}:{},...M(e)?{markdown:!0}:{},...i.holds?{holds:i.holds}:{}}:i.type==="number"&&i.duration?{control:"text",name:n,optional:o,holds:"duration"}:i.type==="date"?{control:"date",name:n,optional:o,...i.time?{time:!0}:{},...i.instant?{instant:!0}:{},...i.partial?{partial:!0}:{}}:i.type==="number"?{control:"number",name:n,optional:o,...i.min===void 0?{}:{min:i.min},...i.max===void 0?{}:{max:i.max},...i.step===void 0?{}:{step:i.step},...i.amount?{amount:i.amount}:{}}:i.type==="choice"?{control:"choice",name:n,optional:o,options:i.options}:{control:"opaque",name:n,optional:o}}function H(n){let r=n.shape;return r?Object.entries(r).map(([o,e])=>F(o,e)):[]}function W(n,r){let o={...r};for(let e of n){let t=r[e.name];t===void 0&&!e.optional&&(e.control==="list"||e.control==="boolean")&&(o[e.name]=e.control==="list"?[]:!1),e.control==="text"&&e.holds&&typeof t=="string"&&(o[e.name]=t.trim()===""?void 0:e.holds==="duration"?z(t)??t:t.trim()),e.control==="group"&&t!==void 0&&typeof t=="object"&&t!==null&&(o[e.name]=W(e.fields,t))}return o}function G(n,r){return q(H(r.input),Z(n,r))}var x="visitor";function gn(n,r,o,e){let t=N.keptFrom?.(n,r),c=new Set;if(!t)return c;let m=Object.keys(o.input.shape??{});for(let a of o.creates??[]){let l=t({id:"\0new",kind:a});for(let s of m)l?.(s)&&c.add(s)}let f=e===void 0?void 0:n.graph.getNode(e),i=f&&n.schema.tryDefinition(f.kind),d=f&&t(f);if(i&&d)for(let a of v(o,i))d(a)&&m.includes(a)&&c.add(a);return c}function _(n,r,o,e){let t=new Set,c=r?.sees??[];if(I(o)||!c.some(k))return t;let m=V(o),f=(l,s)=>{let u=c.filter(p=>p.kinds.includes(l)&&g(p,m));return u.some(k)?L.has(s)||u.some(p=>!k(p)||(p.fields===void 0||p.fields.includes(s))&&!p.hide?.includes(s)):!0},i=Object.keys(e.input.shape??{}),d=new Map,a=(l,s)=>d.set(l,d.get(l)===!0||s);for(let l of e.creates??[]){let s=Object.keys(n.tryDefinition(l)?.fields.shape??{});for(let u of i)s.includes(u)&&a(u,f(l,u))}for(let l of K(n,e)){let s=n.tryDefinition(l);if(s)for(let u of v(e,s))i.includes(u)&&a(u,f(l,u))}for(let[l,s]of d)s||t.add(l);return t}var $=(n,r)=>r.title??S(n);function Q(n,r,o){let e=n?.sees;return!e||e.length===0?!0:e.some(t=>t.kinds.includes(o)&&g(t,r)&&!t.own&&!t.via)}function b(n){switch(n.control){case"node":return[n];case"group":return n.fields.flatMap(b);case"variant":return n.options.flatMap(r=>r.fields.flatMap(b));case"list":return b(n.item);default:return[]}}function U(n,r,o,e){return e.has(o.name)?!1:b(o).every(t=>t.kinds.some(c=>c!=="*"&&Q(n,r,c)))}var X=n=>({kind:"human",id:"form:",roles:[n]});function vn(n,r,o=n.mutations??[]){let e=n.forms?.[r];if(!e)return;let t=o.find(a=>a.name===e.act);if(!t)return;let c=e.role??x,m=X(c),f=_(n.schema,n.policy,m,t),i=G(n.schema,t),d=e.fields?e.fields.flatMap(a=>i.find(l=>l.name===a)??[]):i.filter(a=>U(n.policy,m,a,f));return{name:r,title:$(r,e),...e.intro?{intro:e.intro}:{},...e.say?{say:e.say}:{},submit:e.submit??t.title??S(t.name),role:c,act:t,fields:d}}function An(n,r,o){let e=n.forms?.[r];if(!e)throw new Error(`There is no form called "${r}"${n.forms?`: the forms are ${Object.keys(n.forms).join(", ")}`:": the app declares none"}.`);return{kind:"visitor",id:o,name:`a visitor via the ${$(r,e)} form`,roles:[e.role??x]}}function xn(n){return{said:"Received \u2014 thank you.",...n.say?{next:n.say}:{}}}export{H as a,W as b,G as c,gn as d,_ as e,vn as f,An as g,xn as h};
@@ -1 +0,0 @@
1
- import{a as D}from"./chunk.PXQVXBNG.js";import{a as L,f as P,g as N,h as R,i as T}from"./chunk.B3WVCSW5.js";import{Dd as E}from"./chunk.VSCIXAHN.js";var z=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),W=e=>e?._zod?.def;function I(e){let n=W(e);for(;n&&(n.type==="optional"||n.type==="default"||n.type==="nullable"||n.type==="prefault");)n=W(n.innerType);return n}function K(e){if(e?.type==="boolean")return["true","false"];if(e?.type==="enum")return(e.entries?Object.values(e.entries):e.values??[]).filter(n=>typeof n=="string")}var m=e=>e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[-_]/g," ").replace(/^./,n=>n.toUpperCase());function J(e,n,i){let a=e.tryDefinition(n);if(!a)return[];let c=new Set(a.display?.hide??[]),o=[];for(let[s,l]of Object.entries(a.fields.shape??{})){if(s==="id"||s==="kind"||s==="label"||c.has(s))continue;let r=I(l);if(r?.type==="array"||r?.type==="object"||r?.type==="record")continue;let u=K(r);o.push({key:s,label:m(s),...u?{options:u}:{}})}let g=new Map;for(let[s,l]of Object.entries(a.edges??{}))g.set(s,l.to==="*"?[]:[...l.to]);for(let s of e.definitions)if(s.kind!==n)for(let[l,r]of Object.entries(s.edges??{}))!g.has(l)&&(r.to==="*"||r.to.includes(n))&&g.set(l,[s.kind]);let y=[];for(let[s,l]of g){o.push({key:s,label:m(s)});let r=i&&l.length===1&&l[0]!==n?e.tryDefinition(l[0]):void 0;for(let[u,f]of Object.entries(r?.fields.shape??{})){let p=I(f);p?.type==="enum"&&!r?.display?.hide?.includes(u)&&y.push({key:`${s}.${u}`,label:`${m(s)} \xB7 ${m(u)}`,options:K(p)})}}return o.push(...y),o.push({key:"is",label:"Is",options:a.lifecycle?["current","past","any","flagged","clear"]:["flagged","clear"]}),o}var G=e=>e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function q(e,n,i,a={}){if(i==null)return{ok:!0};if(!z(i))return{ok:!1,says:'A filter is an object of a field and the value it keeps, like { where: { stage: "building" } }.'};let c=Object.entries(i);if(c.length===0)return{ok:!0};let o=[];for(let l of n)for(let r of J(e,l,a.through===!0))o.some(u=>u.key===r.key)||o.push(r);let g=n[0]?e.tryDefinition(n[0]):void 0,y=g?g.plural??`${m(g.kind)}s`:"These",s=[];for(let[l,r]of c){let u=o.find(p=>p.key===l);if(!u)return{ok:!1,says:`${y.replace(/^./,p=>p.toUpperCase())} have no field "${l}" to filter by${o.length>0?`; they filter by ${G(o.map(p=>p.key))}`:""}.`};if(typeof r!="string"&&typeof r!="number"&&typeof r!="boolean")return{ok:!1,says:`The filter on "${l}" is ${Array.isArray(r)?"a list":r===null?"null":`a ${typeof r}`}; it keeps one value: a word, a number, or true or false.`};let f=String(r);if(f.trim().length===0)return{ok:!1,says:`The filter on "${l}" keeps nothing; give it a value, or leave "${l}" out.`};if(f.includes(","))return{ok:!1,says:`The filter on "${l}" holds a comma, which an address reads as a second filter; keep one value.`};if(u.options&&u.options.length>0&&!u.options.includes(f))return{ok:!1,says:`${u.label} has no choice "${f}"; its choices are ${G(u.options.map(p=>`"${p}"`))}.`};s.push(`${l}:${f}`)}return{ok:!0,filter:s.join(",")}}var C=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");function F(e,n){let i=e.find(o=>o.as===n);if(i)return i;let a=n.trim().toLowerCase(),c=C(n);return e.find(o=>o.title!==void 0&&o.title.trim().toLowerCase()===a)??(c?e.find(o=>o.as===c||o.title!==void 0&&C(o.title)===c):void 0)}function Q(e){let n=[];for(let i of e){if(typeof i!="object"||i===null)continue;let{as:a,slug:c,title:o,kind:g}=i,y=typeof a=="string"&&a.length>0?a:typeof c=="string"&&c.length>0?c:void 0;!y||n.some(s=>s.as===y)||n.push({as:y,title:typeof o=="string"?o:y,kind:typeof g=="string"?g:""})}return n}var M=e=>` Its places: ${e.map(n=>typeof n=="string"?`"${n}"`:n.title&&n.title!==n.as?`"${n.as}" (${n.title})`:`"${n.as}"`).join(", ")||"none"}.`;var b=e=>`"${e.length>80?`${e.slice(0,79)}\u2026`:e}"`,O=(e,n)=>`${"place"in e?`The place ${b(e.place)}`:`${b(e.record)} is no record this viewer may see and`} is no place of this app: it goes nowhere.${M(n)}`;function S(e){let n={};for(let i of e.split(",")){let a=i.indexOf(":");a>0&&(n[i.slice(0,a).trim()]=i.slice(a+1).trim())}return n}function oe(e,n=new Set){return e.kinds.filter(i=>!n.has(i)).map(i=>({slug:E(e,i).slice(1),kind:i}))}function V(e,n){let i=[...new Set(n.places.map(f=>f.as))],a=n.lists.map(f=>f.slug).filter(f=>!i.includes(f)),c;if(e.section!==void 0&&e.section!==null){if(typeof e.section!="string"||D(e.section).length===0||e.section.length>120)return{ok:!1,says:`The section ${typeof e.section=="string"?b(e.section):"asked for"} names nothing on a page: a section is a heading's words or an element's id, like "shipping-soon". It goes nowhere.`};c=e.section}let o=c!==void 0?{section:c}:{};if("record"in e&&n.sees(e.record))return e.where!==void 0&&e.where!==null?{ok:!1,says:`${b(e.record)} is one record, and a filter narrows a list or a place: it goes nowhere. Go to { place, where } for a list narrowed.`}:{ok:!0,arrival:{record:e.record,...o}};let g="place"in e?e.place:e.record,y=F(n.places,g),s=y?void 0:n.lists.find(f=>f.slug===g||f.kind===g);if(!y&&!s)return{ok:!1,says:`${O(e,n.places.filter((f,p,$)=>$.findIndex(t=>t.as===f.as)===p))}${_(a)}`};let l=y?[y.kind]:[s.kind],r;if(e.where!==void 0&&e.where!==null){if(!n.schema)return{ok:!1,says:`The place ${b(g)} cannot be narrowed here: it goes nowhere.`};let f=q(n.schema,l,e.where,{through:s!==void 0});if(!f.ok)return{ok:!1,says:`The filter on ${b(g)} goes nowhere: ${f.says}`};r=f.filter}let u=r?{filter:r}:{};return{ok:!0,arrival:y?{place:y.as,...u,...o}:{list:s.kind,...u,...o}}}var _=e=>e.length===0?"":` Its lists: ${e.slice(0,8).map(n=>`"${n}"`).join(", ")}${e.length>8?` and ${e.length-8} more`:""}.`,U="http://www.w3.org/1999/xhtml",H="http://www.w3.org/2000/svg",Z=e=>{let n=e;return n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||e.type==="click"&&typeof n.button=="number"&&n.button!==0};function se(e){let n=new WeakSet,i=new WeakSet,a=new WeakMap,c=new WeakMap,o=t=>V(t,{sees:e.sees,places:e.places(),lists:e.lists?.()??[],...e.schema?{schema:e.schema}:{}}),g=t=>{let d=o(t);return d.ok?e.onNavigate?.(d.arrival):e.onLost?.(d.says),d.ok},y=t=>{let d=t.getAttribute("data-record"),h=t.getAttribute("data-place"),k=t.getAttribute("data-filter"),w=t.getAttribute("data-section"),v={...k?{where:S(k)}:{},...w?{section:w}:{}};if(d)return{record:d,...v};if(h)return{place:h,...v}},s=t=>{if(!e.hrefOf)return;let d=y(t),h=d?o(d):void 0;return h?.ok?e.hrefOf(h.arrival):void 0},l=t=>t.hasAttribute("tabindex")?!1:(t.setAttribute("tabindex","0"),n.add(t),!0),r=t=>{n.delete(t)&&t.removeAttribute("tabindex")},u=t=>{i.delete(t)&&t.getAttribute("role")==="link"&&t.removeAttribute("role")},f=t=>{let d=a.get(t);d&&(a.delete(t),t.getAttribute("href")===d.href&&t.removeAttribute("href"),d.target!==null&&!t.hasAttribute("target")&&t.setAttribute("target",d.target))},p=t=>{let d=c.get(t);d&&(c.delete(t),r(d))},$={link(t){if(!N(t,[...t.querySelectorAll("input, select, textarea")].some(L))){if(!t.hasAttribute("data-graview-link"))return;t.removeAttribute("data-graview-link"),u(t),r(t),f(t),p(t);return}t.hasAttribute("data-graview-link")||t.setAttribute("data-graview-link","");let h=t.localName==="a"&&(t.namespaceURI===U||t.namespaceURI===H),k=t.getAttribute("href"),w=a.get(t),v=k!==null&&w?.href!==k,A=h&&!v?s(t):void 0;if(A!==void 0){k!==A&&t.setAttribute("href",A),a.set(t,{href:A,target:w?w.target:t.getAttribute("target")}),t.removeAttribute("target"),u(t),r(t);return}if(v?a.delete(t):f(t),R(t,t.querySelectorAll("a"))){u(t),r(t),p(t);return}if(!t.hasAttribute("role")&&(h||P(t))&&(t.setAttribute("role","link"),i.add(t)),t.localName==="tr"&&t.namespaceURI===U){r(t);let x=[...t.children].find(j=>j.localName==="td"||j.localName==="th");c.get(t)!==x&&p(t),x&&!c.has(t)&&l(x)&&c.set(t,x);return}t.localName!=="button"&&l(t)},refresh(t){for(let d of t.querySelectorAll("[data-record], [data-place], [data-graview-link]"))$.link(d)},pressed(t,d,h){if(t.type!=="click"&&!(t.type==="keydown"&&t.key==="Enter"))return!1;let k=T(d,h,w=>w.hasAttribute("data-graview-link"));return k?(t.stopPropagation(),a.has(k)&&Z(t)||(t.preventDefault(),$.follow(k)),!0):!1},follow(t){let d=y(t);d&&g(d)},go:g};return $}export{Q as a,M as b,b as c,O as d,S as e,oe as f,V as g,se as h};
@@ -1 +0,0 @@
1
- import{k as a,l as b,m as c,n as d,o as e,p as f,q as g,r as h,s as i}from"./chunk.D7YSL3NK.js";import"./chunk.BJUUSIQY.js";import"./chunk.ZP5RT2EK.js";import"./chunk.VZJWJ5XM.js";import"./chunk.6C2MHWSX.js";import"./chunk.XOZU4OFA.js";import"./chunk.GLWSVSQL.js";import"./chunk.HDUO2USQ.js";import"./chunk.TY4GQJKC.js";import"./chunk.MSWWWLEA.js";import"./chunk.UITT6JWW.js";import"./chunk.A5PDXNY6.js";import"./chunk.WC3DENU4.js";import"./chunk.VNDKKTED.js";import"./chunk.4MP72LPR.js";import"./chunk.SDO3U72B.js";import"./chunk.VSCIXAHN.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";export{i as GhostTray,h as InlineAiMenu,g as askAgain,c as askInline,a as askOf,b as drawPanel,d as heldSuggestion,e as suggestOnce,f as takeOffer};
@@ -1 +0,0 @@
1
- import{a as ee,b as H,c as ne}from"./chunk.XR6YR6RV.js";import{B as J,F as Q,H as X,K as Y,g as K,i as G,m as q,p as z,q as W,u as j,v as Z,x as _,z as U}from"./chunk.WC3DENU4.js";import{a as O}from"./chunk.VNDKKTED.js";import{G as ae,Ha as D,Qa as $,T as M,ba as T,da as N,ua as I}from"./chunk.4MP72LPR.js";import{Kc as C}from"./chunk.VSCIXAHN.js";import{b as k}from"./chunk.AJZBJBMO.js";var o=k(ae(),1);var y=k(M(),1),fe=e=>typeof e=="object"?e:{};function he({rootRef:e,firstLook:r,app:n}){let t=(0,o.useCallback)(()=>e.current,[e]);return r?(0,y.jsx)(Y,{firstLook:r,root:t,app:n}):null}function ge(e,r,n){let{app:t}=e,a=(0,o.useMemo)(()=>{let i=Q(r(t.schema,t.viewSpecs),t),d=n?ie(i,n):i,s=e.views?e.views(t.schema,d):i,c=s===d?i:I(i,s);return X(c,t.schema,U(e.brand??t.brand,t.schema)),n?n.register(c):c},[e.views,t.schema,t.viewSpecs,t.lenses,t.pages,t.home,n]);return D(a,e.keptViews)}function ie(e,r){let n={...e,register(t,a,i,d){return d?.name!==r.name&&e.register(t,a,i,d),n},...e.home?{home:(t,a)=>(r.home||e.home(t,a),n)}:{}};return n}var F=e=>e?e.getBoundingClientRect().height:0;function be(e,r,n){let t=(0,o.useRef)(n);t.current=n;let a=n!==void 0;(0,o.useLayoutEffect)(()=>{let i=e.current;if(!i||!a)return;let d=()=>{let m=[...i.children],h=m.find(b=>b.hasAttribute("data-graview-app-bar")),p=m.find(b=>b.hasAttribute("data-embed-content")),g=p?.querySelector("[data-embed-measure]")??null,l=m.find(b=>b.hasAttribute("data-graview-place-line"));return{strip:h,line:l,content:p,measure:g}},s=-1,c=()=>{let{strip:m,line:h,content:p,measure:g}=d(),l=Math.ceil(F(m)+F(h)+F(g||p));l!==s&&(s=l,t.current?.(l))};if(c(),typeof ResizeObserver>"u")return;let u=new ResizeObserver(c),E=()=>{u.disconnect();let{strip:m,line:h,content:p,measure:g}=d();for(let l of[i,m,h,p,g])l&&u.observe(l)};E();let w=new MutationObserver(()=>{E(),c()});return w.observe(i,{childList:!0}),()=>{u.disconnect(),w.disconnect()}},[e,r,a])}var we=480,se=0;function Se(e){let{app:r,seed:n,scheme:t="auto",brand:a=r.brand,fonts:i=!0,height:d="100%",label:s}=e,c=(0,o.useRef)(null);$(c);let u=d==="viewport"?"100dvh":d,E=G(typeof u=="string"&&/vh\b/.test(u)),w=(0,o.useMemo)(()=>`graview-embed-${++se}`,[]),m=(0,o.useMemo)(()=>e.store??e.remote?.store??H(r,n),[e.store,e.remote,r,n]),h=e.presence??e.remote?.presence,p=e.hostContext?.theme,g=ne(t==="auto"&&p===void 0,a?.scheme),l=t==="auto"?p??g:t,b=(0,o.useMemo)(()=>O(l,a,{scope:`.${w}`}),[l,a,w]);K(e.favicon?C(a):void 0),(0,o.useEffect)(()=>{if(!i||typeof document>"u")return;let v=ee(a);if(!v||document.querySelector(`link[href="${v}"]`))return;let f=document.createElement("link");f.rel="stylesheet",f.href=v,document.head.appendChild(f)},[a,i]);let A=(0,o.useRef)(void 0);(0,o.useLayoutEffect)(()=>{let v=c.current,f=A.current;if(A.current=s,!v||!s)return;let oe=S=>{let R=S.getAttribute("aria-label")??"",x=f&&f!==s?R.startsWith(`${f} \xB7 `)?R.slice(f.length+3):R===f?"":R:R;x===s&&(S.getAttribute("role")==="region"||S.tagName==="SECTION"&&!S.hasAttribute("role"))&&S.setAttribute("role","group");let V=x.startsWith(`${s} \xB7 `)||x===s?x:x?`${s} \xB7 ${x}`:s;V!==R&&S.setAttribute("aria-label",V)},B=()=>v.querySelectorAll("aside, nav, main, header, footer, section[aria-label]:not([role]), [role=region], [role=complementary], [role=navigation], [role=search]").forEach(S=>{S.hasAttribute("data-graview-named-by-lens")||oe(S)});B();let P=new MutationObserver(B);return P.observe(v,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["aria-label"]}),()=>P.disconnect()},[s]);let re=E?`${u}`.replace(/([\d.]+)[sdl]?vh\b/g,(v,f)=>`${+f*E/100}px`):u;return{rootRef:c,scope:w,css:b,scheme:l,store:m,presence:h,brand:a,auto:d==="auto",height:re}}function ve({rootRef:e,board:r}){let n=(0,o.useCallback)(()=>e.current?.querySelector("[data-embed-content]")??e.current,[e]);return(0,y.jsx)(q,{board:r,anchor:n})}function Ee(e,r,n){return{brand:n,locale:e.locale,timeZone:e.timeZone,principal:e.principal,seats:e.seats,presence:r,typing:e.remote?.typing,people:e.people,memory:e.memory,presenceTtlMs:e.presenceTtlMs,onKeepLens:e.onKeepLens,ai:e.ai,files:e.files,resolveApp:e.resolveApp,history:e.history,linkedRecords:e.linkedRecords,subscriptions:e.subscriptions,dismissals:e.dismissals,whileAway:e.whileAway,keptViews:e.keptViews,onExport:e.onExport,signIn:e.signIn,menuSections:e.menuSections,app:e.app}}function Re({name:e,heading:r,faces:n,at:t,without:a,home:i,reach:d,standing:s,hostActions:c,keeping:u,onFind:E,switch:w,named:m=!0}){let{brand:h,store:p,principal:g,views:l}=T();N();let b=a?.has("places")?[]:z({store:p,principal:g,views:l}),A=_();return(0,y.jsx)(j,{brand:h,name:e,named:m,description:h?.subtitle,heading:r,faces:n,home:i,places:b,current:t===null?null:W(b,t),reach:d,onFind:E,...w?{switch:w}:{},...n||t===null?{scenePlaces:A}:{},tools:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(J,{clean:s}),(0,y.jsx)(Z,{...c?{hostActions:c}:{},...u?{keeping:u}:{}})]})})}var xe=e=>e===!1?2:Math.min(e+1,6);function Ae(e){let[r,n]=(0,o.useState)(e),t=(0,o.useRef)(void 0),a=(0,o.useRef)(void 0),i=(0,o.useMemo)(()=>({go:t,at:n,pending:a}),[]),d=(0,o.useCallback)(s=>{if(t.current){t.current(s);return}a.current=s,n(s)},[]);return{at:r,setAt:n,steering:i,steer:d}}function de(e){let r=typeof e=="object"&&e!==null?e.name:void 0;return{name:typeof r=="string"&&r.length>0?r:typeof e=="object"?"Error":typeof e}}var L=()=>typeof performance<"u"?performance.now():Date.now();function Fe(e,r){let n=(0,o.useRef)({onError:e,face:r});return n.current={onError:e,face:r},(0,o.useCallback)((t,a)=>n.current.onError?.(de(t),{module:a.module,face:n.current.face}),[])}function ke(e,r){let n=(0,o.useRef)(null);n.current===null&&(n.current=L());let t=(0,o.useRef)({onReady:e,face:r});t.current={onReady:e,face:r};let a=(0,o.useRef)(!1);return(0,o.useCallback)(i=>{a.current||(a.current=!0,t.current.onReady?.({ms:Math.max(0,L()-(n.current??L())),face:i}))},[])}var te=class extends o.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(r,n){console.error(`[graview] ${this.props.module} threw while rendering`,r,n.componentStack),this.props.report(r,{module:this.props.module})}render(){return this.state.failed?(0,y.jsxs)("div",{role:"alert","data-graview-face-error":this.props.module,...this.props.content?{"data-embed-content":""}:{},style:this.props.content?{flex:"1 1 auto",display:"grid",alignContent:"center",justifyItems:"center",gap:8,padding:24,background:"var(--graview-ground)",color:"var(--graview-ink)",fontSize:"0.9375rem"}:{display:"inline-flex",alignItems:"center",gap:6,fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:[(0,y.jsx)("span",{children:this.props.content?"This part of the app could not draw.":"Could not draw."}),(0,y.jsx)("button",{type:"button",onClick:()=>this.setState({failed:!1}),style:{padding:"3px 11px",fontSize:"0.8125rem"},children:"Try again"})]}):this.props.children}};export{fe as a,he as b,ge as c,be as d,we as e,Se as f,ve as g,Ee as h,Re as i,xe as j,Ae as k,Fe as l,ke as m,te as n};
@@ -1,3 +0,0 @@
1
- import{F as j,Fa as X,H as J,I as B,K as F,Na as v,Q as G,Sb as z,T as C,U as Q,V as U,W as P,Ya as nn,Zb as tn,aa as I,ab as en,ca as K,na as Z}from"./chunk.VSCIXAHN.js";var fn=1e4,y=class{constructor(a){this.nodes=a}},on=Symbol.for("@graview/core:far-record"),cn=e=>typeof e=="object"&&e!==null&&e[on]===!0;function pn(e){let a={...e.fields,id:`@${e.address}/${e.kind}:${e.id}`,kind:`@${e.address}/${e.kind}`,label:e.label};return Object.defineProperty(a,on,{value:!0}),a}function Rn(e){let a=`the linked record in ${e.ref.address}`;return e.reason==="denied"?`${a} is not one this viewer may open`:`${a} has not been read`}var gn="",u=class extends Error{constructor(f,c){super(f);this.sentence=f;this.at=c}},W=class extends u{},M=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof y)&&typeof e.id=="string",rn=e=>{let a=new Set;return new y(e.filter(f=>!a.has(f.id)&&a.add(f.id)))},w=e=>e===null?"nothing":e instanceof y?"a set of records":Array.isArray(e)?"a list":M(e)?"a record":typeof e=="string"?"a word":typeof e;function an(e,a){let f=a.budget??fn,c=(n,s)=>{if(f-=n,f<0)throw new W("this rule looks at too much of the graph to judge in one go",s)},d=a.today??F(),b=a.now??new Date().toISOString(),k=new Map,x=new Set,A=a.bindings,H=(n,s,t,o)=>{let l=`${n?.id}\0${s}`;if(k.has(l))return k.get(l);if(x.has(l))throw new u(`"${s}"${n?` of ${Z(n.kind)}`:""} depends on itself`,o);x.add(l);let r=A;A=void 0;try{let i=$(t,n);return k.set(l,i),i}finally{A=r,x.delete(l)}},E=(n,s,t)=>{c(1,t);let o=a.kinds.get(n.kind),l=o?.computed?.get(s);if(l)return H(n,s,l,t);let r=o?.linked?.get(s);if(r){let g=X(Object.hasOwn(n,s)?n[s]:void 0,r);c(g.length,t);let m=a.linked??v(a.graph),h=g.flatMap(N=>{let _=m?m(N):{unread:!0};return"record"in _?[pn(_.record)]:(a.onUnread?.({relation:s,ref:N,reason:"denied"in _?"denied":"unread"}),[])});return r.cardinality==="one"?h[0]??null:new y(h)}let i=Object.hasOwn(n,s);if(o?.fields.has(s)||i){let g=i?nn(n,s,d):void 0;return g===void 0?null:g}let p=o?.edges.get(s);if(p){let g=a.graph.out(n.id,s);return c(g.length,t),p==="one"?g[0]??null:new y(g)}if(s==="id")return n.id;if(cn(n))return null;throw new u(`${Z(n.kind)} has no field or relation called "${s}"`,t)},S=(n,s,t)=>{if(n instanceof y)return n;if(n===null)return new y([]);if(M(n))return new y([n]);throw new u(`${t}(\u2026) needs a set of records, and was given ${w(n)}`,s)},V=(n,s,t)=>{if(n===null)return null;if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);throw new u(`${t}(\u2026) needs a word, and was given ${w(n)}`,s)},D=(n,s,t)=>{let o=V(n,s,t);if(o===null)return null;let l=Date.parse(o.length===10?`${o}T00:00:00Z`:o);if(Number.isNaN(l))throw new u(`${t}(\u2026) needs a date, and "${o}" is not one`,s);return l},O=(n,s)=>M(n)&&M(s)?n.id===s.id:M(n)&&typeof s=="string"?n.id===s:typeof n=="string"&&M(s)?n===s.id:Array.isArray(n)&&Array.isArray(s)?n.length===s.length&&n.every((t,o)=>O(t,s[o])):n===s,R=(n,s,t)=>{if(n===null)return!1;if(typeof n=="boolean")return n;throw new u(`${t} must be true or false, and was ${w(n)}`,s)},T=(n,s)=>$(s,n);function $(n,s){switch(c(1,n.at),n.t){case"lit":return n.value;case"list":return n.items.map(t=>$(t,s));case"ident":{let t=A&&Object.hasOwn(A,n.name)?A[n.name]:void 0;if(t!==void 0)return t;if(s)return E(s,n.name,n.at);throw new u(`"${n.name}" means nothing in a rule over the whole graph`,n.at)}case"member":{let t=$(n.object,s);if(t===null)return null;if(M(t))return E(t,n.name,n.at);throw new u(`".${n.name}" needs a record before it, and was given ${w(t)}`,n.at)}case"unary":{let t=$(n.operand,s);if(n.op==="!")return!R(t,n.at,"what follows not");if(t===null)return null;if(typeof t!="number")throw new u(`"-" needs a number, and was given ${w(t)}`,n.at);return-t}case"where":{let t=S($(n.set,s),n.at,"where");return c(t.nodes.length,n.at),new y(t.nodes.filter(o=>R(T(o,n.filter),n.at,"a where condition")))}case"binary":return ln(n,s);case"call":return un(n,s)}}function ln(n,s){if(n.op==="&&")return R($(n.left,s),n.at,"each side of and")&&R($(n.right,s),n.at,"each side of and");if(n.op==="||")return R($(n.left,s),n.at,"each side of or")||R($(n.right,s),n.at,"each side of or");let t=$(n.left,s),o=$(n.right,s);if(n.op==="&"||n.op==="|"||n.op==="-"&&(t instanceof y||o instanceof y)){let l=S(t,n.at,n.op).nodes,r=S(o,n.at,n.op).nodes;c(l.length+r.length,n.at);let i=new Set(r.map(p=>p.id));return rn(n.op==="|"?[...l,...r]:l.filter(p=>i.has(p.id)===(n.op==="&")))}switch(n.op){case"==":return O(t,o);case"!=":return!O(t,o);case"in":{if(o===null)return!1;if(o instanceof y)return o.nodes.some(l=>O(t,l));if(Array.isArray(o))return o.some(l=>O(t,l));if(typeof o=="string"&&typeof t=="string")return o.includes(t);throw new u(`"in" needs a list or a set on its right, and was given ${w(o)}`,n.at)}case"<":case"<=":case">":case">=":{if(t===null||o===null)return!1;if(!(typeof t=="number"&&typeof o=="number"||typeof t=="string"&&typeof o=="string"))throw new u(`cannot compare ${w(t)} with ${w(o)}`,n.at);return n.op==="<"?t<o:n.op==="<="?t<=o:n.op===">"?t>o:t>=o}default:{if(t===null||o===null)return null;if(n.op==="+"&&(typeof t=="string"||typeof o=="string")){let l=`${V(t,n.at,"+")}${V(o,n.at,"+")}`;if(l.length>1e4)throw new u("that makes a word too long",n.at);return l}if(typeof t!="number"||typeof o!="number")throw new u(`"${n.op}" needs numbers, and was given ${w(t)} and ${w(o)}`,n.at);return(n.op==="/"||n.op==="%")&&o===0?null:n.op==="+"?t+o:n.op==="-"?t-o:n.op==="*"?t*o:n.op==="/"?t/o:t%o}}}function un(n,s){let t=(r,i=r)=>{if(n.args.length<r||n.args.length>i)throw new u(`${n.fn}(\u2026) takes ${r===i?r:`${r} to ${i}`} argument${i===1?"":"s"}`,n.at)},o=r=>$(n.args[r],s),l=r=>{let i=o(r);if(typeof i!="string")throw new u(`${n.fn}(\u2026) needs a quoted name, like ${n.fn}('name')`,n.at);return i};switch(n.fn){case"out":case"in":{t(1,2);let r=(g,m)=>n.fn==="out"?a.graph.out(g,m):a.graph.in(g,m);if(n.args.length===2){let g=S(o(0),n.at,n.fn).nodes,m=l(1);return rn(g.flatMap(h=>{let N=r(h.id,m);return c(N.length+1,n.at),N}))}let i=l(0);if(!s)throw new u(`${n.fn}('${i}') needs a record to start from`,n.at);let p=r(s.id,i);return c(p.length,n.at),new y(p)}case"all":{t(1,2);let r=a.graph.nodesOfKind(l(0),{archived:n.args.length===2?o(1):!1});return c(r.length,n.at),new y(r)}case"archived":return t(0,1),en(n.args.length===1?o(0):s);case"count":return t(1),S(o(0),n.at,"count").nodes.length;case"exists":return t(1),S(o(0),n.at,"exists").nodes.length>0;case"every":case"some":{t(2);let r=S(o(0),n.at,n.fn);c(r.nodes.length,n.at);let i=p=>R(T(p,n.args[1]),n.at,`the condition in ${n.fn}(\u2026)`);return n.fn==="every"?r.nodes.every(i):r.nodes.some(i)}case"sum":case"min":case"max":{t(2);let r=S(o(0),n.at,n.fn);c(r.nodes.length,n.at);let i=n.args[1],p=i.t==="lit"&&typeof i.value=="string"?i.value:void 0,g=i.t==="ident"?`'${i.name}'`:p!==void 0?`'${p}'`:"\u2026",m=r.nodes.map(h=>i.t==="ident"?E(h,i.name,n.at):p!==void 0?E(h,p,n.at):T(h,i)).filter(h=>{if(h===null)return!1;if(typeof h!="number")throw new u(`${n.fn}(\u2026, ${g}) needs a number for each member, and found ${w(h)}`,n.at);return!0});return n.fn==="sum"?m.reduce((h,N)=>h+N,0):m.length===0?null:n.fn==="min"?Math.min(...m):Math.max(...m)}case"fact":{t(1);let r=l(0),i=a.kinds.get(gn)?.computed?.get(r);if(!i)throw new u(`no fact is called "${r}"`,n.at);return H(null,r,i,n.at)}case"first":return t(1),S(o(0),n.at,"first").nodes[0]??null;case"sort":{t(2,3);let r=S(o(0),n.at,"sort"),i=n.args.length===3?o(2):"asc";if(i!=="asc"&&i!=="desc")throw new u("sort(\u2026) goes 'asc' or 'desc'",n.at);let p=r.nodes.length;c(p+p*Math.ceil(Math.log2(p+1)),n.at);let g=r.nodes.map((h,N)=>({node:h,i:N,key:T(h,n.args[1])})),m=i==="desc"?-1:1;return g.sort((h,N)=>Y(h.key,N.key,m,n.at)||h.i-N.i),new y(g.map(h=>h.node))}case"either":{if(n.args.length<1)throw new u("either(\u2026) takes at least one argument",n.at);for(let r=0;r<n.args.length;r++){let i=o(r);if(i!==null&&!(i instanceof y&&i.nodes.length===0))return i}return null}case"present":{t(1);let r=o(0);return r===null||r===""?!1:Array.isArray(r)?r.length>0:r instanceof y?r.nodes.length>0:!0}case"len":{t(1);let r=o(0);if(r===null)return 0;if(typeof r=="string"||Array.isArray(r))return r.length;if(r instanceof y)return r.nodes.length;throw new u(`len(\u2026) needs a word or a list, and was given ${w(r)}`,n.at)}case"contains":case"startsWith":{t(2);let r=o(0),i=o(1);if(r===null||i===null)return!1;if(n.fn==="contains"&&Array.isArray(r))return r.some(m=>O(m,i));let p=V(r,n.at,n.fn),g=V(i,n.at,n.fn);return n.fn==="contains"?p.toLowerCase().includes(g.toLowerCase()):p.startsWith(g)}case"lower":{t(1);let r=V(o(0),n.at,"lower");return r===null?null:r.toLowerCase()}case"today":return t(0),d;case"now":return t(0),b;case"date":{t(1);let r=D(o(0),n.at,"date");return r===null?null:new Date(r).toISOString().slice(0,10)}case"days":case"hours":{t(2);let r=D(o(0),n.at,n.fn),i=D(o(1),n.at,n.fn);if(r===null||i===null)return null;let p=(i-r)/(n.fn==="days"?864e5:36e5);return n.fn==="days"?Math.round(p):p}case"round":{t(1,2);let r=o(0);if(r===null)return null;if(typeof r!="number")throw new u(`round(\u2026) needs a number, and was given ${w(r)}`,n.at);let i=n.args.length===2?o(1):0;if(typeof i!="number"||!Number.isInteger(i)||i<0||i>12)throw new u("round(\u2026, places) takes a whole number of places from 0 to 12",n.at);let p=10**i,g=Math.sign(r)*Math.round(Math.abs(r)*p*(1+Number.EPSILON))/p;return Object.is(g,-0)?0:g}case"if":return t(3),R(o(0),n.at,"the condition in if(\u2026)")?o(1):o(2);default:throw new u(`"${n.fn}" is not a function the rule language knows`,n.at)}}function Y(n,s,t,o){if(n===null||s===null)return n===s?0:n===null?1:-1;if(Array.isArray(n)&&Array.isArray(s)){for(let r=0;r<Math.max(n.length,s.length);r++){let i=Y(n[r]??null,s[r]??null,t,o);if(i!==0)return i}return 0}let l=r=>typeof r=="number"||typeof r=="string"||typeof r=="boolean"?typeof r:w(r);if(l(n)!==l(s)||typeof n=="object"||typeof s=="object")throw new u(`sort(\u2026) cannot put ${w(n)} and ${w(s)} in order`,o);return typeof n=="string"?t*(n<s?-1:n>s?1:0):t*(Number(n)-Number(s))}return $(e,a.subject)}var Mn=["out","in","all","count","exists","every","some","sum","min","max","present","len","contains","startsWith","lower","today","now","date","days","hours","if","first","sort","either","fact","archived","round"];var On=(e,a,f,c)=>({severity:"error",code:e,path:a,message:f,...c?{fix:c}:{}}),Gn=(e,a,f,c,d)=>({severity:"warning",code:e,path:a,message:f,...c?{fix:c}:{},...d&&d.length>0?{edits:d}:{}}),En=e=>e.some(a=>a.severity==="error");function Tn(e){return e.map(a=>`${a.severity==="error"?"\u2717":a.severity==="warning"?"!":"\xB7"} ${a.path||"(document)"}: ${a.message}${a.fix?` \u2014 ${a.fix}`:""}${(a.edits??[]).map(f=>`
2
- edit: ${JSON.stringify(f)}`).join("")}`).join(`
3
- `)}var Un=["money","percent","date","time","datetime","relative","upper","lower","count","words","and","plural","excerpt"],yn={getNode:()=>{},allNodes:()=>[],allEdges:()=>[],nodesOfKind:()=>[],edgesOfKind:()=>[],out:()=>[],in:()=>[],neighbors:()=>[],has:()=>!1};function Pn(e,a,f,c=[],d,b=L){return q(e,a,f,c,d,b)}var hn=(e,a)=>e.capital?I(a):a,mn=new Set(["words","plural","relative"]);function In(e,a){let f=e[0];return!f||f.text!==void 0||!f.format||!mn.has(f.format)?a:/^[a-z][a-z'’-]*(?=\s|$|[,.;:!?])/.test(a)?I(a):a}function wn(e){return e?a=>{let f=e.tryDefinition(a.kind)?.label;return f?f(a):L(a)}:L}var sn=["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],dn=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];function $n(e,a){return!Number.isInteger(e)||e<0||e>99?P(e,a):e<20?sn[e]:e%10===0?dn[e/10]:`${dn[Math.floor(e/10)]}-${sn[e%10]}`}function bn(e){return/[^aeiou]y$/i.test(e)?`${e.slice(0,-1)}ies`:/(s|x|z|ch|sh)$/i.test(e)?`${e}es`:`${e}s`}var L=e=>String(e.name??e.title??e.label??e.id);function q(e,a,f,c=[],d,b=L){if(a==="plural"){let k=e instanceof y?e.nodes.length:Array.isArray(e)?e.length:typeof e=="number"?e:null;return k===null||c[0]===void 0?"\u2014":k===1?c[0]:c[1]??bn(c[0])}if(e===null)return"\u2014";if(e instanceof y)return a==="count"?String(e.nodes.length):a==="and"?K(e.nodes.map(b)):e.nodes.map(b).join(", ");if(Array.isArray(e)){if(a==="count")return String(e.length);let k=e.map(x=>q(x,void 0,f,[],d,b));return a==="and"?K(k):k.join(", ")}if(typeof e=="object")return b(e);switch(a){case"words":return typeof e=="number"?$n(e,d?.locale):String(e);case"money":return typeof e=="number"?z(e,d):String(e);case"percent":return typeof e=="number"?P(e,d?.locale,{style:"percent",maximumFractionDigits:0}):String(e);case"upper":return String(e).toUpperCase();case"lower":return String(e).toLowerCase();case"excerpt":return tn(String(e),Number(c[0])||void 0);case"date":return G(U(String(e),d?.timeZone)??String(e).slice(0,10),d?.locale);case"time":return typeof e=="string"&&j.test(e)?G(e,d?.locale):Q(String(e),d?.locale,d?.timeZone);case"datetime":return typeof e=="string"&&j.test(e)?G(e,d?.locale):C(String(e),d?.locale,d?.timeZone);case"relative":{let k=U(String(e),d?.timeZone),x=k===void 0?Date.parse(String(e)):Date.parse(`${k}T00:00:00Z`);if(Number.isNaN(x))return String(e);let A=Math.round((x-Date.parse(`${f}T00:00:00Z`))/864e5);return A===0?"today":A===1?"tomorrow":A===-1?"yesterday":A>0?`in ${A} days`:`${-A} days ago`}default:return typeof e=="string"&&J.test(e)?G(e,d?.locale):typeof e=="string"&&B.test(e)?C(e,d?.locale,d?.timeZone):String(e)}}function Kn(e,a){let f=a.today??F(),c=a.name??wn(a.graph?.schema);return e.map(d=>{if(d.text!==void 0)return d.text;try{let b=an(d.expr,{graph:a.graph??yn,subject:a.node,kinds:a.kinds,today:f,budget:a.budget??500,...a.bindings?{bindings:a.bindings}:{}});return hn(d,q(b,d.format,f,d.formatArgs,a.money,c))}catch(b){if(b instanceof u)return"\u2014";throw b}}).join("")}export{y as a,Rn as b,gn as c,u as d,W as e,an as f,Mn as g,On as h,Gn as i,En as j,Tn as k,Un as l,yn as m,Pn as n,hn as o,In as p,wn as q,Kn as r};
@@ -1 +0,0 @@
1
- import{b as f}from"./chunk.3V4WP7RY.js";import"./chunk.LLYRFVIN.js";import"./chunk.YFSBVZTG.js";import"./chunk.G4YJPKRG.js";import{l as g}from"./chunk.3UOKUF5Z.js";import"./chunk.Q355UPFG.js";import"./chunk.PXQVXBNG.js";import"./chunk.MVWC3VR3.js";import"./chunk.CC5BJH5A.js";import"./chunk.CFKZXLXS.js";import"./chunk.Y5C4RXG7.js";import"./chunk.7MHCGVGM.js";import"./chunk.FRYBMS3W.js";import"./chunk.LQVAABPS.js";import"./chunk.NGTRL5U4.js";import"./chunk.3MOJF7BA.js";import"./chunk.LZIBQ3VX.js";import"./chunk.YZ7FUKAL.js";import"./chunk.KDRLUBVF.js";import"./chunk.BQIHNT7C.js";import"./chunk.TAT2IQUR.js";import"./chunk.3XGA65Y3.js";import"./chunk.BYKD5RLA.js";import"./chunk.2K4TT2BV.js";import"./chunk.VUBNBTJP.js";import"./chunk.BJUUSIQY.js";import"./chunk.ZP5RT2EK.js";import"./chunk.VZJWJ5XM.js";import"./chunk.XOZU4OFA.js";import"./chunk.GLWSVSQL.js";import"./chunk.MB7LKKUD.js";import"./chunk.WVUJXDXZ.js";import"./chunk.7VKSXGTX.js";import"./chunk.TY4GQJKC.js";import"./chunk.6ZQAR5ZA.js";import"./chunk.W3W54DSX.js";import"./chunk.PI44XMY2.js";import"./chunk.KGW75Z5L.js";import"./chunk.GZHZLJBF.js";import"./chunk.IOK4GVJC.js";import"./chunk.OJGHDWI6.js";import"./chunk.TLJOZSDD.js";import"./chunk.MSWWWLEA.js";import"./chunk.UITT6JWW.js";import"./chunk.A5PDXNY6.js";import"./chunk.WC3DENU4.js";import"./chunk.VNDKKTED.js";import{G as b,T as h}from"./chunk.4MP72LPR.js";import"./chunk.SDO3U72B.js";import{Zd as n}from"./chunk.VSCIXAHN.js";import"./chunk.FQLNBIQ5.js";import{b as t}from"./chunk.AJZBJBMO.js";var m=t(b(),1),a=t(h(),1);function P({store:c,auto:y,brand:i,views:u,presence:s,steering:r,overview:o,scope:d,titleLevel:w=2,quickAsk:l,props:e}){let v=(0,m.useMemo)(()=>g({scope:`.${d}`}),[d]);return(0,a.jsxs)("div",{"data-embed-content":"",style:y?{flex:"0 0 auto",background:"var(--graview-ground)"}:{flex:"1 1 auto",minHeight:0,overflow:"auto",background:"var(--graview-ground)"},children:[(0,a.jsx)("style",{children:v}),(0,a.jsx)("div",{"data-embed-measure":"",style:{display:"flow-root"},children:(0,a.jsx)(f,{context:{store:c,embedded:!0,...e.bar!==!1?{barAbove:!0}:{},...o?{overview:o}:{},titleLevel:w,views:u,settings:e.app.settings??[],app:e.app,...s?{presence:s}:{},...i?{brand:i}:{},...e.locale?{locale:e.locale}:{},...e.timeZone?{timeZone:e.timeZone}:{},...e.principal?{principal:e.principal}:{},...e.seats?{seats:e.seats}:{},...e.people?{people:e.people}:{},...e.subscriptions?{subscriptions:e.subscriptions}:{},dismissals:e.dismissals,whileAway:e.whileAway,...e.signIn?{signIn:e.signIn}:{},...l!==void 0?{quickAsk:l}:{}},...e.pages?{registry:e.pages}:{},...r?{steering:r}:{},...e.routing==="address"?n(e.basePath)===""?{}:{basename:n(e.basePath)}:{initialPath:e.path??"/"},...e.path!==void 0?{path:e.path}:{},...e.hrefOf?{hrefOf:e.hrefOf}:e.routing==="address"?{}:{hrefOf:!1},...e.onNavigate?{onNavigate:e.onNavigate}:{}})})]})}export{P as PagesContent};
@@ -1,6 +0,0 @@
1
- import{a as k}from"./chunk.G4JJXA63.js";import{a as Z}from"./chunk.67U6M7OV.js";import{a as Y}from"./chunk.6C2MHWSX.js";import{a as X}from"./chunk.TY4GQJKC.js";import{c as _}from"./chunk.PI44XMY2.js";import{Kd as T,Md as H,Nd as P,Od as V,rb as J,sb as U}from"./chunk.VSCIXAHN.js";var O=n=>"failed"in n;function fn(n,e){let r=n.schema.kinds,t=n.policy?.sees;if(!t?.length||U(e))return{kinds:r};let o=J(e).roles??[],s=new Set(t.filter(i=>i.roles==="*"||o.some(a=>i.roles.includes(a))).flatMap(i=>i.kinds));return{kinds:r.filter(i=>s.has(i))}}function E(n,e){if(!e)return n;let r=new Set(e.kinds.filter(s=>n.tryDefinition(s)!==void 0));if(r.size===n.kinds.length)return n;let t=new Map,o=s=>{if(r.has(s)){if(!t.has(s)){let i=n.tryDefinition(s),a=Object.fromEntries(Object.entries(i?.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(s,{...i,edges:a})}return t.get(s)}};return{...n,definitions:n.definitions.filter(s=>r.has(s.kind)),kinds:n.kinds.filter(s=>r.has(s)),tryDefinition:o,definition:s=>{let i=o(s);if(!i)throw new Error(`Unknown node kind "${s}"`);return i}}}var gn=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),p=n=>gn(n).replace(/[-_]+/g," ").trim();function x(n){let e=[];for(let t of n.kinds){let o=n.tryDefinition(t);if(!o)continue;let s=o.display?.labels??{},i=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:(s[d]??p(d)).toLowerCase()}}),a=Object.entries(o.edges??{}).map(([d,c])=>({name:d,from:t,to:c.to==="*"?n.kinds.filter(u=>u!==t):c.to,words:p(d)})),l=(o.plural??`${p(t)}s`).toLowerCase();e.push({kind:t,plural:l,noun:(o.noun??p(t)).toLowerCase(),fields:i,roles:o.fieldRoles??{},edges:a})}let r=new Map(e.map(t=>[t.kind,t]));return{schema:n,kinds:e,info:t=>r.get(t)}}var $=(n,e)=>e===void 0?void 0:n.fields.find(r=>r.name===e),R=n=>n?.type==="date"||n?.type==="datetime",K=n=>n?.type==="number"||n?.type==="integer"||n?.type==="duration",rn=n=>` ${n.toLowerCase().replace(/[“”"’‘]/g,"'").replace(/[^\p{L}\p{N}' -]+/gu," ").replace(/\s+/g," ").trim()} `,A=(n,e)=>n.includes(` ${e} `),L=n=>n.endsWith("ies")?`${n.slice(0,-3)}y`:n.endsWith("ses")?n.slice(0,-2):n.endsWith("s")?n.slice(0,-1):n;function yn(n,e){let r=[];for(let t of e.kinds){let o=new Set([t.plural,t.noun,`${t.noun}s`,p(t.kind),`${p(t.kind)}s`]),s=-1;for(let i of o){let a=n.indexOf(` ${i} `);a>=0&&(s<0||a<s)&&(s=a)}s>=0&&r.push({info:t,at:s})}return r.sort((t,o)=>t.at-o.at).map(t=>t.info)}function I(n,e,r){let t=e.trim().toLowerCase();if(t.length===0)return;let o=n.fields.filter(s=>!r||r(s));return o.find(s=>s.words===t||p(s.name)===t||s.name.toLowerCase()===t)??o.find(s=>s.words===L(t)||p(s.name)===L(t))??o.find(s=>t.split(" ").some(i=>i.length>2&&(s.words.split(" ").includes(i)||s.words.split(" ").includes(L(i)))))}function sn(n,e,r){let t=e.trim().toLowerCase();if(t.length!==0)return n.edges.find(o=>o.words===t||o.name.toLowerCase()===t)??n.edges.find(o=>o.to.some(s=>{let i=r.info(s);return i!==void 0&&(i.noun===L(t)||i.plural===t||p(s)===L(t))}))??n.edges.find(o=>t.split(" ").some(s=>s.length>2&&o.words.split(" ").includes(s)))}function z(n){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(n)?.[1]?.trim()}var mn=/\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/,pn=/\bcalendar\b|\bmonth\b|\bagenda\b|\bschedule\b|\bdue\b|\bdeadlines?\b|\bdates?\b|\bwhen\b/,bn=/\btimeline\b|\bover time\b|\bgantt\b|\bspans?\b|\bweek\b/,hn=/\bboard\b|\bkanban\b|\bcolumns?\b|\bpipeline\b|\bstages?\b|\bstatus\b/,wn=/\blaid out\b|\blayout\b|\bseating\b|\bwhere (?:they|it|each) (?:sits?|lies?|stands?)\b|\bfloor\b/,kn=/\bplan\b|\bmap\b|\bregions?\b/,$n=/\blist\b|\btable\b|\bgroup(?:ed)? by\b|\bsort(?:ed)? by\b|\bonly\b|\bjust the\b/;function Sn(n){let e=[];return/\blist\b|\btable\b/.test(n)&&e.push("blocks"),mn.test(n)&&e.push("coverage"),wn.test(n)&&e.push("board"),(/\bfloor plan\b/.test(n)||kn.test(n))&&e.push("plan"),bn.test(n)&&e.push("timeline"),pn.test(n)&&e.push("calendar"),hn.test(n)&&e.push("columns"),$n.test(n)&&!e.includes("blocks")&&e.push("blocks"),e.length===0&&z(n)&&e.push("columns"),e}var on=n=>{let e=r=>r?` and not ${r}`:"";if(/\boverdue\b|\blate\b|\bpast due\b/.test(n))return{cond:(r,t)=>`days(today(), ${r}) < 0${e(t)}`,says:r=>`overdue by ${r.words}`};if(/\btoday\b/.test(n))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(n))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(n))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(n))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(n))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(n))return{range:"quarter",cond:r=>`days(today(), ${r}) >= 0 and days(today(), ${r}) <= 91`,says:r=>`with ${r.words} in the next quarter`}},M=n=>{if(/\bagenda\b|\bin order\b/.test(n))return"agenda";if(/\btoday\b|\bday\b/.test(n))return"day";if(/\bweek\b/.test(n))return"week";if(/\bquarter\b/.test(n))return"quarter";if(/\byears\b/.test(n))return"years";if(/\byear\b/.test(n))return"year";if(/\bmonth\b/.test(n))return"month"},Q=/^(user|person|people|member|staff|gardener|volunteer|owner|agent|employee|worker|team|player|customer|client|contact|party|attendee|guest)s?$/,j=class extends Error{},b=n=>{throw new j(n)};function Dn(n,e){let r=n.fields.filter(s=>s.type==="enum");if(e){let s=I(n,e);if(s&&s.type==="enum")return s;s&&b(`${n.plural}' ${s.words} is not a choice, so it has no columns`)}let t=$(n,n.roles.status??n.roles.column);if(t?.type==="enum")return t;let o=r.find(s=>/^(status|stage|state|phase)$/.test(s.name));return o||(r[0]?r[0]:b(`${n.plural} have no choice field to put in columns`))}function nn(n,e){let r=n.fields.filter(R),t=l=>{let d=$(n,n.roles[l]);return R(d)?d:void 0},s=r.find(l=>A(e,l.words)||A(e,p(l.name)))??t("start")??r.find(l=>/^(due|date|on|at|start|starts|begins|from|sown|when)/i.test(l.name))??r[0];if(!s)return b(`no date field on ${n.plural}`);let i=t("end")??r.find(l=>l!==s&&/^(end|ends|until|to|finish|finished|harvested|due|closes|through)/i.test(l.name)),a=n.fields.find(l=>l.type==="boolean"&&/^(done|finished|complete|completed|closed)$/.test(l.name));return{start:s,...i&&i!==s?{end:i}:{},...a?{done:a}:{}}}function an(n){let e=$(n,n.roles.start),r=$(n,n.roles.end),t=$(n,n.roles.column??n.roles.day??n.roles.columns);if(K(e)&&K(r)&&t?.type==="enum")return{start:e,end:r,column:t}}function vn(n,e,r,t){let o=[];for(let i of n.kinds)for(let a of i.edges)for(let l of a.to){let d=n.info(l);if(!d||d.kind===i.kind)continue;let c=0;e.includes(i)&&(c+=4),e.includes(d)&&(c+=4),(Q.test(d.kind)||Q.test(d.noun))&&(c+=3),t&&(a.words.includes(t)||d.noun===L(t))&&(c+=5),a.words.split(" ").some(u=>u.length>2&&r.includes(` ${u}`))&&(c+=2),o.push({rows:i,across:d,link:a,score:c})}let s=o.sort((i,a)=>a.score-i.score)[0];return s||b(e[0]?`${e[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 dn(n,e,r,t,o){let s=z(t);switch(n){case"columns":{if(s){let i=I(e,s);if(!i||i.type!=="enum"){let a=sn(e,s,r);if(a){let l=r.info(a.to[0]);return{lens:"coverage",kind:e.kind,across:l.kind,link:a.name}}}}return{lens:"columns",kind:e.kind,column:Dn(e,s).name}}case"calendar":{let i=nn(e,t),a=M(t);return{lens:"calendar",kind:e.kind,start:i.start.name,...i.end?{end:i.end.name}:{},...i.done?{done:i.done.name}:{},...a?{range:a}:{}}}case"timeline":{let i=an(e);if(i&&!/\bdates?\b|\bdue\b|\bdeadlines?\b|\bmonths?\b|\byears?\b/.test(t))return{lens:"timeline",kind:e.kind,start:i.start.name,end:i.end.name,column:i.column.name};let a=nn(e,t);return{lens:"calendar",kind:e.kind,start:a.start.name,...a.end?{end:a.end.name}:{},...a.done?{done:a.done.name}:{},range:M(t)??"quarter"}}case"coverage":{let i=vn(r,o,t,s);return{lens:"coverage",kind:i.rows.kind,across:i.across.kind,link:i.link.name}}case"board":{let i=$(e,e.roles.x)??e.fields.find(c=>c.name==="x"),a=$(e,e.roles.y)??e.fields.find(c=>c.name==="y");if(!K(i)||!K(a))return b(`${e.plural} have no x and y to be laid out by`);let d=r.kinds.flatMap(c=>c.edges.filter(u=>u.to.includes(e.kind)&&c.kind!==e.kind))[0]??e.edges[0];return d?{lens:"board",kind:e.kind,x:i.name,y:a.name,fill:d.name,...d.from!==e.kind?{fillFrom:"occupant"}:{}}:b(`nothing is joined to ${e.plural} to fill them`)}case"plan":{let i=$(e,e.roles.outline)??e.fields.find(a=>a.name==="outline");return i?{lens:"plan",kind:e.kind,outline:i.name}:b(`${e.plural} have no outline to draw a plan from`)}case"blocks":{let i={lens:"blocks",kind:e.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]??(s&&!/ sort(?:ed)? by /.test(t)?s:void 0);if(a){let c=I(e,a);if(!c||c.type!=="enum")return b(c?`${e.plural}' ${c.words} is not a choice, so they cannot be grouped by it`:`${e.plural} have nothing called ${a} to group by`);i.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=I(e,l);if(!c)return b(`${e.plural} have nothing called ${l} to sort by`);i.sort={by:c.name,.../\b(newest|latest|desc|descending|most)\b/.test(t)?{direction:"desc"}:{}}}let d=q(e,t);return d.length>0&&(i.where=d),i}}}function q(n,e){let r=[],t=on(e);if(t){let o=n.fields.filter(R),s=$(n,n.roles.start),i=o.find(l=>A(e,l.words))??(R(s)?s:void 0)??o[0];(!i||!R(i))&&b(`no date field on ${n.plural}`);let a=n.fields.find(l=>l.type==="boolean"&&/^(done|finished|complete|completed|closed)$/.test(l.name));r.push({expr:t.cond(i.name,/\boverdue\b|\blate\b|\bpast due\b/.test(e)?a?.name:void 0),says:t.says(i)})}if(/\bonly\b|\bjust\b|\bthat are\b|\bwhich are\b/.test(e)){for(let o of n.fields){if(o.type!=="enum")continue;let s=o.options?.find(i=>A(e,i.toLowerCase())||A(e,p(i)));s&&r.push({expr:`${o.name} == '${s.replace(/'/g,"")}'`,says:`that are ${p(s)}`})}if(/\bnot done\b|\bundone\b|\bunfinished\b|\bopen ones\b|\bstill to do\b/.test(e)){let o=n.fields.find(s=>s.type==="boolean"&&/^(done|finished|complete|completed)$/.test(s.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 Rn(n,e){let r=e.info(n.kind),t=o=>o?$(r,o)?.words??p(o):"";switch(n.lens){case"columns":return{title:`${k(r.plural)} by ${t(n.column)}`,detail:`of ${r.plural} by ${t(n.column)}`};case"calendar":{let o=n.range??"month";if(o==="agenda")return{title:`${k(r.plural)} in date order`,detail:`of ${r.plural} in order of ${t(n.start)}`};let s=o==="years"?"year":o;return{title:`${k(r.plural)} by ${s}`,detail:`of ${r.plural} by ${t(n.start)}, a ${s} at a time`}}case"timeline":return{title:`${k(r.plural)} over the ${t(n.column)}`,detail:`of ${r.plural} from ${t(n.start)} to ${t(n.end)}, by ${t(n.column)}`};case"coverage":{let o=e.info(n.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=[n.where?.map(s=>s.says).join(" and "),n.group?`by ${t(n.group)}`:void 0,n.sort?`in order of ${t(n.sort.by)}`:void 0].filter(s=>!!s);return{title:[k(r.plural),...o].join(" "),detail:[`of ${r.plural}`,...o].join(" ")}}}}function An(n,e){let r={title:e,on:n.kind};switch(n.lens){case"columns":return{name:"columns",...r,bindings:{[n.kind]:{column:n.column}}};case"calendar":return{name:"calendar",...r,bindings:{[n.kind]:{start:n.start,...n.end?{end:n.end}:{},...n.done?{done:n.done}:{}}},...n.range?{options:{range:n.range}}:{}};case"timeline":return{name:"timeline",...r,bindings:{[n.kind]:{start:n.start,end:n.end,column:n.column}}};case"coverage":return{name:"coverage",...r,bindings:{rows:{kind:n.kind},columns:{kind:n.across},link:{edge:n.link}}};case"board":return{name:"board",...r,bindings:{slots:{kind:n.kind},x:{field:n.x,on:"slots"},y:{field:n.y,on:"slots"},fill:{edge:n.fill}},...n.fillFrom?{options:{fillFrom:n.fillFrom}}:{}};case"plan":return{name:"plan",...r,bindings:{regions:{kind:n.kind},outline:{field:n.outline,on:"regions"}}};default:{let t=n.where?.length?` where ${n.where.map(s=>n.where.length>1?`(${s.expr})`:s.expr).join(" and ")}`:"",o={list:`all('${n.kind}')${t}`,as:n.as??"row"};return n.group&&(o.group=n.group),n.sort&&(o.sort=n.sort.direction?{by:n.sort.by,direction:n.sort.direction}:n.sort.by),o.empty="Nothing here yet.",{name:"blocks",...r,options:{blocks:[o]}}}}}function F(n,e){let{app:r}=e,t=s=>s.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,""),o=new Set(["home","overview",...Z(r,e.views?{views:e.views}:{}).map(s=>s.slug),...(r.lenses??[]).flatMap(s=>s.title?[t(s.title)]:[])]);if(!o.has(t(n)))return n;for(let s=2;;s++)if(!o.has(t(`${n} ${s}`)))return`${n} ${s}`}var en={title:[],headline:[],text:["tone"],figure:["as","currency","label"],list:["sort","limit","group","empty","as"],progress:["label"],group:["direction"],when:["show"],divider:[]};function Ln(n,e){if(!Array.isArray(e)||e.length===0)return"it has no blocks to draw";if(e.length>40)return"it has more blocks than a place draws";let r=(i,a)=>{if(typeof i!="string"||i.trim()==="")return`its ${a} says nothing`;try{return _(i)}catch(l){return`its ${a} does not read: ${l instanceof Error?l.message.replace(/ \(at character.*$/,""):String(l)}`}},t=i=>{if(i.t==="where")return t(i.set);if(i.t==="call"&&i.fn==="all"){let a=i.args[0];return a?.t==="lit"&&typeof a.value=="string"?n.info(a.value)??null:void 0}},o=(i,a)=>{switch(i.t){case"lit":return;case"ident":return a&&!a.fields.some(l=>l.name===i.name)&&!a.edges.some(l=>l.name===i.name)?`${a.plural} have nothing called ${i.name}`:void 0;case"member":return o(i.object,a);case"list":return i.items.map(l=>o(l,a)).find(Boolean);case"unary":return o(i.operand,a);case"binary":return o(i.left,a)??o(i.right,a);case"where":{let l=t(i.set);return l===null?"Nothing by that name here":o(i.set,a)??o(i.filter,l??void 0)}case"call":return i.fn==="all"?t(i)===null?"Nothing by that name here":void 0:i.args.map(l=>o(l,a)).find(Boolean)}},s=(i,a)=>{if(a>4)return"its blocks nest deeper than a place draws";for(let l of i){if(!w(l))return"a block is not an object";let d=Object.keys(en).find(g=>g in l);if(!d)return`"${Object.keys(l)[0]??""}" is not a block a place draws`;let c=Object.keys(l).find(g=>g!==d&&g!=="key"&&!en[d].includes(g));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 g=r(u,d);if(typeof g=="string")return g;let m=o(g,void 0);if(m)return m;if(d==="list"){let f=t(g);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 y of["group","sort"]){let h=l[y],S=typeof h=="string"?h:w(h)&&typeof h.by=="string"?h.by:void 0;if(h===void 0)continue;let D=S?f.fields.find(un=>un.name===S):void 0;if(!D)return`${f.plural} have nothing called ${String(S??h)} to ${y} by`;if(y==="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 y=s(f,a+1);if(y)return y}}else if(d==="group"){if(!Array.isArray(u))return"a group block holds a list of blocks";let g=s(u,a+1);if(g)return g}else{if(d!=="divider"&&typeof u!="string")return`a ${d} block says words`;if(typeof u=="string")for(let g of u.matchAll(/\{([^{}]*)\}/g)){let m=g[1].split(/\|(?![|])/)[0],f=r(m,`${d}'s braces`);if(typeof f=="string")return f;let y=o(f,void 0);if(y)return y}}}};return s(e,1)}function N(n,e,r){let t=E(n.schema,r),o=f=>({ok:!1,failed:`Couldn't draw that: ${f.replace(/\.$/,"")}.`});if(!P(e.name)||e.name==="reach")return o(`"${String(e.name)}" is not a picture the seat can draw; it draws ${H.filter(f=>f!=="reach").join(", ")}`);if(typeof e.title!="string"||e.title.trim().length===0||e.title.length>80)return o("it needs a title of a few words");if(typeof e.on!="string"||!t.tryDefinition(e.on))return o("Nothing by that name here");let s=T[e.name],i=e.bindings??{};if(s.binds==="fields")for(let[f,y]of Object.entries(i)){if(!t.tryDefinition(f))return o("Nothing by that name here");let h=Object.keys(t.tryDefinition(f).fields?.shape??{});for(let[S,D]of Object.entries(y??{}))if(typeof D!="string"||!h.includes(D))return o(`${p(f)} has no field "${String(D)}" for its ${S}`);for(let S of s.requiredRoles)if(!(S in(y??{})))return o(`a ${e.name} needs ${p(f)}'s ${S}`)}else if(s.binds==="entities")for(let f of s.requiredRoles){let y=i[f];if(!y)return o(`a ${e.name} needs its ${f}`);if(typeof y.kind=="string"&&!t.tryDefinition(y.kind))return o("Nothing by that name here")}let a={...n,schema:t,lenses:[...n.lenses??[],e]},l=a.lenses.length-1,d=V(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 g=d.undrawn.find(f=>f.index===l);if(g)return o(g.why);let m=d.drawn.find(f=>f.index===l);if(!m)return o("its bindings name something the app does not have");if(m.as==="overview")return o(`"${e.title}" is the scene's own address; give it another title`);if(e.name==="blocks"){let f=Ln(x(t),e.options?.blocks);if(f)return o(f)}return{ok:!0,drawn:m}}function G(n){return{op:"add-lens",title:n.title,lens:n.name,on:n.on,...n.bindings?{bindings:n.bindings}:{},...n.options?{options:n.options}:{}}}function In(n){return{op:"remove-lens",title:n.title,on:n.on}}var w=n=>typeof n=="object"&&n!==null&&!Array.isArray(n);function ln(n){let e=w(n)?n:{},r=String(e.lens??e.name??""),t=e.bindings,o=typeof e.on=="string"?e.on:w(t)&&T[r]?.binds==="fields"?Object.keys(t)[0]??"":"";return{name:r,title:typeof e.title=="string"?e.title.trim():"",on:o,...w(t)?{bindings:t}:{},...w(e.options)?{options:e.options}:{}}}function En(n){let e=o=>w(n.bindings?.[o])?n.bindings[o]:{},r=o=>typeof o=="string"?o:void 0,t=e(n.on);switch(n.name){case"columns":return r(t.column)?{lens:"columns",kind:n.on,column:t.column}:void 0;case"calendar":{let o=r(n.options?.range);return r(t.start)?{lens:"calendar",kind:n.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:n.on,start:t.start,end:t.end,column:t.column}:void 0;case"coverage":{let o=w(n.bindings?.columns)?r(n.bindings.columns.kind):void 0,s=w(n.bindings?.link)?r(n.bindings.link.edge):void 0;return o&&s?{lens:"coverage",kind:n.on,across:o,link:s}:void 0}case"blocks":{let o=n.options?.blocks;if(!Array.isArray(o)||o.length!==1||!w(o[0]))return;let s=o[0],i=new RegExp(`^all\\('${n.on}'\\)(?: where (.+))?$`).exec(String(s.list??""));if(!i)return;let a=s.sort;return{lens:"blocks",kind:n.on,as:s.as==="card"?"card":"row",...typeof s.group=="string"?{group:s.group}:{},...typeof a=="string"?{sort:{by:a}}:w(a)&&typeof a.by=="string"?{sort:{by:a.by,...a.direction==="desc"?{direction:"desc"}:{}}}:{},...i[1]?{where:[{expr:i[1],says:"as asked"}]}:{}}}default:return}}function W(n,e,r,t,o){let s=x(E(n.schema,t)).info(e.on),i=En(e);return{title:e.title,said:`${B[e.name]??"A picture"} of ${s?.plural??p(e.on)}.`,kind:e.on,lens:e,drawn:r,edit:G(e),by:o,asks:[],...i?{recipe:i}:{}}}function tn(n){return{title:n.title,said:n.said,lens:{title:n.lens.title,lens:n.lens.name,on:n.lens.on,...n.lens.bindings?{bindings:n.lens.bindings}:{},...n.lens.options?{options:n.lens.options}:{}},edit:n.edit,by:n.by,check:"It draws, and graview check would take it."}}function C(n,e,r,t,o){let s=Rn(n,e),i=n.title??o??F(s.title,r),a=An(n,i),l=N(r.app,a,r.sight);return l.ok?{title:i,said:`${B[n.lens]} ${s.detail}.`,kind:n.kind,lens:a,drawn:l.drawn,edit:G(a),by:"template",asks:t,recipe:n}:{failed:l.failed,...r.lastGood?{lastGood:r.lastGood}:{}}}function Hn(n,e){let r=x(E(e.app.schema,e.sight)),t=r.info(n.kind);if(!t)return{failed:"Couldn't draw that: Nothing by that name here."};let o=n.lens==="blocks"&&!n.group&&!n.sort&&!n.where?.length&&n.title===void 0;return C(o?{...n,title:F(`Every ${t.noun}`,e)}:n,r,e,[])}function xn(n,e,r,t){if(r.length>0)return r;let o=i=>{switch(n){case"columns":return i.fields.some(a=>a.type==="enum");case"calendar":return i.fields.some(R);case"timeline":return an(i)!==void 0||i.fields.some(R);case"coverage":return i.edges.some(a=>a.to.some(l=>l!==i.kind));case"board":return i.fields.some(a=>a.name==="x")&&i.fields.some(a=>a.name==="y");case"plan":return i.fields.some(a=>a.name==="outline")||i.roles.outline!==void 0;default:return!0}};return[...e.kinds.filter(o)].sort((i,a)=>Number(a.fields.some(l=>A(t,l.words)))-Number(i.fields.some(l=>A(t,l.words))))}function On(n,e){let r=x(E(e.app.schema,e.sight)),t=rn(n),o=Sn(t);if(o.length===0)return;let s=yn(t,r),i;for(let a of o){let l=a==="coverage"?[s[0]??r.kinds[0]].filter(d=>!!d):xn(a,r,s,t);for(let d of l)try{let c=dn(a,d,r,t,s),u=C(c,r,e,[n]);if(!O(u))return u;i??=u.failed}catch(c){if(!(c instanceof j))throw c;i??=`Couldn't draw that: ${c.message}.`}l.length===0&&s.length===0&&(i??=`Couldn't draw that: nothing here has what ${B[a].toLowerCase()} needs.`)}return{failed:i??"Couldn't draw that: Nothing by that name here.",...e.lastGood?{lastGood:e.lastGood}:{}}}async function jn(n,e){let r=e.lastGood?{lastGood:e.lastGood}:{};if(n.trim().length===0)return{failed:"Say what you would like to see, like \u201Ca board of tasks by status\u201D.",...r};let t=On(n,e);if(t&&!O(t))return t;if(!e.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 cn(n,e,void 0);return O(o)&&t?t:o}async function Nn(n,e,r){let t={lastGood:n},o={...r,lastGood:n},s=x(E(r.app.schema,r.sight)),i=rn(e),a=s.info(n.kind),l=[...n.asks,e];if(!a)return{failed:"Couldn't change that: Nothing by that name here.",...t};let d=n.recipe,c=/^ (?:call|name|title) (?:it|this)? ?(.+?) $/.exec(i)??/ (?:call|name) it (.+?) $/.exec(i);try{if(c){let m=e.replace(/^.*?\b(?:call|name|title)\b\s*(?:it|this)?\s*/i,"").replace(/^["“']|["”']$/g,"").trim();if(m.length===0)return{failed:"Couldn't change that: say what to call it.",...t};let f={...n.lens,title:F(m,r)},y=N(r.app,f,r.sight);return y.ok?{...n,title:f.title,lens:f,drawn:y.drawn,edit:G(f),asks:l,...d?{recipe:{...d,title:f.title}}:{}}:{failed:y.failed,...t}}let g=/ as (?:a |an )?(board|kanban|calendar|timeline|list|table|cards|rows|grid|plan|layout)\b/.exec(i);if(g){let m=g[1]==="board"||g[1]==="kanban"?"columns":g[1]==="calendar"?"calendar":g[1]==="timeline"?"timeline":g[1]==="grid"?"coverage":g[1]==="plan"?"plan":g[1]==="layout"?"board":"blocks",f=dn(m,a,s,i,[a]),y=g[1]==="cards"?"card":g[1]==="rows"?"row":void 0,h=m==="blocks"&&d?.lens==="blocks"?{...d,...y?{as:y}:{}}:m==="blocks"&&d?.lens==="columns"?{...f,group:d.column,...y?{as:y}:{}}:f;return C(v(h),s,o,l)}if(d){let m=Kn(d,a,s,i);if(m)return C(m,s,o,l)}}catch(g){if(!(g instanceof j))throw g;return{failed:`Couldn't change that: ${g.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 cn(e,o,n);return O(u)?u:{...u,asks:l}}var v=n=>{let{title:e,...r}=n;return r};function Kn(n,e,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)?z(t):void 0);if(o){let d=I(e,o);if(d?.type==="enum")return n.lens==="blocks"?{...v(n),group:d.name}:{lens:"columns",kind:n.kind,column:d.name};let c=sn(e,o,r);return c?{lens:"coverage",kind:n.kind,across:c.to[0],link:c.name}:b(d?`${e.plural}' ${d.words} is not a choice, so they cannot be grouped by it`:`${e.plural} have nothing called ${o} to group by`)}let s=/ (?:sort(?:ed)?|order(?:ed)?) by ([\p{L}\p{N} -]+?)(?= (?:and|only|with)|\s*$)/u.exec(t)?.[1];if(s){let d=I(e,s);return d?{...n.lens==="blocks"?v(n):{lens:"blocks",kind:n.kind,as:"row",...n.lens==="columns"?{group:n.column}:{}},sort:{by:d.name,.../\b(newest|latest|desc|descending|most)\b/.test(t)?{direction:"desc"}:{}}}:b(`${e.plural} have nothing called ${s} to sort by`)}if(/\b(?:all of them|everything|show all|clear the filter|no filter|without the filter)\b/.test(t)){if(n.lens!=="blocks"||!n.where)return b("it already shows all of them");let{where:d,...c}=v(n);return c}let i=on(t);if(i&&n.lens==="calendar"&&i.range)return{...v(n),range:i.range};if(i&&n.lens==="calendar"&&!i.range)return{lens:"blocks",kind:n.kind,as:"row",sort:{by:n.start},where:q(e,t)};let a=q(e,t);if(a.length>0){let d=n.lens==="blocks"?v(n):{lens:"blocks",kind:n.kind,as:"row",...n.lens==="columns"?{group:n.column}:{}};return{...d,where:[...d.where??[],...a]}}let l=n.lens==="calendar"?M(t):void 0;if(l)return{...v(n),range:l}}function Cn(n){return n.kinds.map(e=>{let r=e.fields.map(s=>`${s.name} (${s.type??"value"}${s.options?`: ${s.options.join(" | ")}`:""})`).join(", "),t=e.edges.map(s=>`${s.name} \u2192 ${s.to.join(" | ")}`).join(", "),o=Object.entries(e.roles).map(([s,i])=>`${s}=${i}`).join(", ");return`- ${e.kind} ("${e.plural}"): ${r}${t?`; relations: ${t}`:""}${o?`; roles: ${o}`:""}`}).join(`
2
- `)}var Fn=['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
- `);function Gn(n,e,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:",Cn(e),"","The lenses you may use (prefer the first four; use blocks only when none of them fits):",Fn,"",r?`The view on screen now:
4
- ${JSON.stringify(r.lens)}
5
- Change it as asked, and keep everything not asked about.`:"",`Asked: ${JSON.stringify(n)}`,'Answer with ONE JSON object: {"title": "<a few words, like Deliverables by status>", "lens": \u2026, "on": \u2026, "bindings"?: \u2026, "options"?: \u2026}. Name only the kinds, fields and relations listed above. If it cannot be drawn from them, answer {"failed": "<one sentence saying why>"}.'].filter(t=>t!=="").join(`
6
- `)}async function cn(n,e,r){let t=e.lastGood?{lastGood:e.lastGood}:{},o=x(E(e.app.schema,e.sight)),s;try{s=(await e.complete({prompt:Gn(n,o,r)})).text}catch{return{failed:"Couldn't draw that: the model did not answer.",...t}}let i=Y(s);if(typeof i!="object"||i===null||Array.isArray(i))return{failed:"Couldn't draw that: the model's answer was not a view.",...t};let a=i;if(typeof a.failed=="string")return{failed:`Couldn't draw that: ${a.failed.replace(/^Couldn't draw that:\s*/i,"").replace(/\.$/,"")}.`,...t};let l=ln(a);if(!P(l.name))return{failed:`Couldn't draw that: "${l.name}" is not a picture the seat can draw.`,...t};let d=l.title?l.title.slice(0,80):r?.title??k(n.trim()).slice(0,80),c={...l,title:r&&r.title===d?d:F(d,e)},u=N(e.app,c,e.sight);return u.ok?{...W(e.app,c,u.drawn,e.sight,"model"),asks:[n]}:{failed:u.failed,...t}}function Vn(n,e,r){let t=[...n.lenses??[]];for(let o of e){let s={name:o.lens,title:o.title,on:o.on,...o.bindings?{bindings:o.bindings}:{},...o.options?{options:o.options}:{}};if(t.some(a=>a.title===s.title))continue;N({...n,lenses:t},s,r).ok&&(t=[...t,s])}return t.length===(n.lenses??[]).length?n:{...n,lenses:t}}async function Xn(n,e,r){let{app:t,drafts:o}=r,s=fn(t,r.principal),i=c=>{let u=ln(c);return{lens:u,verdict:N(t,u,s)}};if(n==="keep_lens"){let{lens:c,verdict:u}=i(e);if(!u.ok)return{ok:!1,error:u.failed,reason:"invalid"};if(!o?.keep)return{ok:!1,error:"This app's declaration cannot be written from here."};let g=G(c),m=await o.keep(g);return m.ok?{ok:!0,data:{kept:g,said:m.said??`Adds \u201C${g.title}\u201D to the places.`,undo:In(g)}}:{ok:!1,error:m.error}}if(e.lens!==void 0){let{lens:c,verdict:u}=i(e.lens);return u.ok?{ok:!0,data:tn(W(t,c,u.drawn,s,"model"))}:{ok:!1,error:u.failed,reason:"invalid"}}let a={app:t,sight:s,...o?.complete?{complete:o.complete}:{},...o?.views?{views:o.views}:{}},l=String(e.ask??""),d;if(e.current!==void 0){let{lens:c,verdict:u}=i(e.current);if(!u.ok)return{ok:!1,error:u.failed,reason:"invalid"};d=await Nn(W(t,c,u.drawn,s,"model"),l,a)}else d=await jn(l,a);return O(d)?{ok:!1,error:d.failed,reason:"invalid"}:{ok:!0,data:tn(d)}}export{O as a,fn as b,N as c,G as d,In as e,ln as f,En as g,W as h,tn as i,Hn as j,On as k,jn as l,Nn as m,Vn as n,Xn as o};
@@ -1,104 +0,0 @@
1
- import{a as L,c as O,d as W,f as I}from"./chunk.2K4TT2BV.js";import{a as ae,b as te}from"./chunk.XOZU4OFA.js";import{b as Z,c as ee,d as ne}from"./chunk.GLWSVSQL.js";import{b as J,c as Q,d as N,j as U,k as X}from"./chunk.MSWWWLEA.js";import{b as V,k as Y,l as _}from"./chunk.UITT6JWW.js";import{G as de,T as B}from"./chunk.4MP72LPR.js";import{Eb as K,da as E,ga as z,md as $,oa as G}from"./chunk.VSCIXAHN.js";import{b as T}from"./chunk.AJZBJBMO.js";var y=T(de(),1),a=T(B(),1),se=`
2
- form:where([data-graview-part="form"]) {
3
- /* A grid item of the section above it and a grid container for the
4
- fields below: both halves are allowed to be narrower than what is in
5
- them, or a big enough text size pushes the page sideways. See the note
6
- on \`column\` in pages.tsx. */
7
- display: grid;
8
- grid-template-columns: minmax(0, 1fr);
9
- min-width: 0;
10
- gap: 12px;
11
- }
12
- label:where([data-graview-part="field"]),
13
- div:where([data-graview-part="field"][data-graview-field="date"]) {
14
- display: grid;
15
- /* A track the width it was given: see the note on \`column\` in pages.tsx. */
16
- grid-template-columns: minmax(0, 1fr);
17
- min-width: 0;
18
- gap: 4px;
19
- }
20
- label:where([data-graview-part="field"][data-graview-field="boolean"]) {
21
- grid-auto-flow: column;
22
- justify-content: start;
23
- align-items: center;
24
- }
25
- span:where([data-graview-part="label"]),
26
- legend:where([data-graview-part="label"]),
27
- p:where([data-graview-part="unasked"]) {
28
- font-size: 0.8125rem;
29
- color: var(--graview-ink-muted);
30
- }
31
- p:where([data-graview-part="unasked"]) { margin: 0; }
32
- input:where([data-graview-part="control"]:not([type="checkbox"])),
33
- select:where([data-graview-part="control"]) {
34
- font: inherit;
35
- /* A TARGET IN EVERY ENGINE, not only in the one it was measured in.
36
- Padding and line height alone came to 24 in Chromium and to 22 in
37
- WebKit, which has its own intrinsic metrics for a \`select\` and rounds
38
- nothing up for anybody. So every picker on the routed face was under
39
- the WCAG 2.2 minimum in the browser iOS ships, and the check that says
40
- so (\`verify-pages\`' \`bigEnoughToHit\`) only ever ran there through
41
- \`pnpm engines\`. */
42
- min-height: 24px;
43
- /* NEVER WIDER THAN ITS FIELD. A select is as wide as its longest option,
44
- and a picker over 320 vehicles ("2027 Mercedes-Benz GLE AMG 53 4MATIC+
45
- Coupe") was 618 pixels on a 390 phone, and the whole page scrolled
46
- sideways. It shrinks to its track and cuts the option inside its box. */
47
- min-width: 0;
48
- max-width: 100%;
49
- text-overflow: ellipsis;
50
- box-sizing: border-box;
51
- padding: 7px 10px;
52
- border-radius: 8px;
53
- border: 1px solid var(--graview-edge);
54
- background: var(--graview-panel);
55
- color: var(--graview-ink);
56
- }
57
- /* A PICKER THAT STILL LOOKS LIKE ONE.
58
- WebKit ignores an author's padding and minimum height on a \`select\`
59
- while the native appearance is on \u2014 so every picker on the routed face
60
- came out 22 pixels tall in the browser iOS ships, under the 24 WCAG 2.2
61
- asks for, while the same element measured 35 in Chromium. Turning the
62
- appearance off is what makes the box the size it was asked to be, and it
63
- takes the platform's chevron with it; the chevron is put back, in the ink
64
- the scheme is already using. */
65
- span:where([data-graview-part="picker"]) {
66
- position: relative;
67
- display: grid;
68
- min-width: 0;
69
- }
70
- span:where([data-graview-part="picker"]) > select:where([data-graview-part="control"]) {
71
- appearance: none;
72
- padding-right: 28px;
73
- }
74
- span:where([data-graview-part="chevron"]) {
75
- position: absolute;
76
- right: 10px;
77
- top: 50%;
78
- transform: translateY(-50%);
79
- font-size: 0.75rem;
80
- line-height: 1;
81
- color: var(--graview-ink-muted);
82
- pointer-events: none;
83
- }
84
- fieldset:where([data-graview-part="group"]) {
85
- display: grid;
86
- gap: 10px;
87
- border: 1px solid var(--graview-edge);
88
- border-radius: 10px;
89
- padding: 12px;
90
- }
91
- fieldset:where([data-graview-part="group"][data-graview-field="list"]) { gap: 8px; }
92
- div:where([data-graview-part="item"]) {
93
- display: flex;
94
- gap: 8px;
95
- align-items: end;
96
- }
97
- button:where([data-graview-part="add"]),
98
- button:where([data-graview-part="submit"]) { justify-self: start; }
99
- p:where([data-graview-part="refused"]) {
100
- margin: 0;
101
- color: var(--graview-warn);
102
- font-size: 0.875rem;
103
- }
104
- `;function pe({title:r,name:e,optional:t,amount:o,value:v,onChange:f}){let s=J(o),[S,g]=(0,y.useState)(()=>typeof v=="number"?Q(v,o):""),A=S.trim()!==""&&N(S,o)===void 0;return(0,a.jsxs)("label",{"data-graview-part":"field","data-graview-field":"number","data-graview-amount":o.format??"unit",children:[(0,a.jsx)("span",{"data-graview-part":"label",children:r}),(0,a.jsxs)("span",{"data-graview-part":"amount",style:{display:"flex",alignItems:"center",gap:6},children:[s.prefix?(0,a.jsx)("span",{"data-graview-part":"amount-symbol","aria-hidden":"true",children:s.prefix}):null,(0,a.jsx)("input",{type:"text",inputMode:"decimal",name:e,required:!t,placeholder:s.placeholder,title:s.hint,"aria-invalid":A||void 0,value:S,onChange:u=>{g(u.target.value),f(N(u.target.value,o))},"data-graview-part":"control",style:{flex:1,minWidth:0}}),s.suffix?(0,a.jsx)("span",{"data-graview-part":"amount-symbol","aria-hidden":"true",children:s.suffix}):null]}),A?(0,a.jsxs)("span",{"data-graview-part":"hint",role:"status",children:["Not an amount ",s.hint,": write it like ",s.prefix??"",s.placeholder,s.suffix?` ${s.suffix}`:""]}):null]})}function re({children:r}){return(0,a.jsxs)("span",{"data-graview-part":"picker",children:[r,(0,a.jsx)("span",{"aria-hidden":"true","data-graview-part":"chevron",children:"\u25BE"})]})}var ue=r=>({label:E(r),option:e=>e}),me={phone:"+1 555 123 4567",place:"An address or a place's name",duration:"1h 30m, 90 or 1:30"};function M({store:r,spec:e,value:t,onChange:o,prefilled:v,open:f,words:s=ue,values:S}){if(e.name in v&&e.control!=="group"&&e.control!=="variant")return null;let g=e.control==="node"&&!e.kinds.includes("*")?e.kinds.map(n=>E(G(r.schema.tryDefinition(n),n))).join(" or "):s(e.name).label,A=!(e.optional||e.control==="boolean"),u=A?(0,a.jsxs)(a.Fragment,{children:[g,(0,a.jsx)("span",{"aria-hidden":"true",children:" *"})]}):g;switch(e.control){case"text":case"date":return e.control==="text"&&e.long?(0,a.jsxs)("label",{"data-graview-part":"field","data-graview-field":"text",children:[(0,a.jsxs)("span",{"data-graview-part":"label",children:[u,e.markdown?(0,a.jsx)("span",{style:{fontWeight:"normal",color:"var(--graview-ink-faint)"},children:" \xB7 Markdown"}):null]}),(0,a.jsx)("textarea",{name:e.name,required:!e.optional,rows:6,value:typeof t=="string"?t:"",onChange:n=>o(n.target.value),"data-graview-part":"control",style:{fieldSizing:"content",minHeight:"7.5em",resize:"vertical",font:"inherit",lineHeight:1.5}})]}):e.control==="date"?(0,a.jsxs)("div",{"data-graview-part":"field","data-graview-field":"date",children:[(0,a.jsx)("span",{"data-graview-part":"label",children:u}),(0,a.jsx)(I,{name:e.name,label:s(e.name).label,required:!e.optional,value:typeof t=="string"&&t!==""?t:void 0,time:e.time===!0,instant:e.instant===!0,partial:e.partial===!0,onChange:o})]}):(0,a.jsxs)("label",{"data-graview-part":"field","data-graview-field":e.control==="text"&&e.holds?e.holds:e.control,children:[(0,a.jsx)("span",{"data-graview-part":"label",children:u}),(0,a.jsx)("input",{type:e.control==="text"&&e.holds==="phone"?"tel":"text",name:e.name,required:!e.optional,...e.control==="text"&&e.app?{placeholder:"@owner/app or https://\u2026"}:{},...e.control==="text"&&e.holds?{placeholder:me[e.holds]}:{},...e.control==="text"&&e.holds==="phone"?{autoComplete:"tel"}:{},value:typeof t=="string"?t:typeof t=="number"?String(t):"",onChange:n=>o(n.target.value),"data-graview-part":"control"})]});case"number":return e.amount?(0,a.jsx)(pe,{title:u,name:e.name,optional:e.optional,amount:e.amount,value:t,onChange:o}):(0,a.jsxs)("label",{"data-graview-part":"field","data-graview-field":e.control,children:[(0,a.jsx)("span",{"data-graview-part":"label",children:u}),(0,a.jsx)("input",{type:"number",name:e.name,required:!e.optional,...e.min===void 0?{}:{min:e.min},...e.max===void 0?{}:{max:e.max},...e.step===void 0?{}:{step:e.step},value:typeof t=="number"?t:"",onChange:n=>o(n.target.value===""?void 0:Number(n.target.value)),"data-graview-part":"control"})]});case"boolean":return(0,a.jsxs)("label",{"data-graview-part":"field","data-graview-field":"boolean",children:[(0,a.jsx)("input",{type:"checkbox",name:e.name,checked:t===!0,onChange:n=>o(n.target.checked),"data-graview-part":"control"}),(0,a.jsx)("span",{"data-graview-part":"label",children:u})]});case"choice":return(0,a.jsxs)("label",{"data-graview-part":"field","data-graview-field":e.control,children:[(0,a.jsx)("span",{"data-graview-part":"label",children:u}),(0,a.jsx)(re,{children:(0,a.jsxs)("select",{name:e.name,required:!e.optional,value:typeof t=="string"?t:"",onChange:n=>o(n.target.value||void 0),"data-graview-part":"control",children:[(0,a.jsx)("option",{value:"",children:"\u2014"}),(e.options??[]).map(n=>(0,a.jsx)("option",{value:n,children:s(e.name).option(n)},n))]})})]});case"node":{let n=f.find(i=>i.name===e.name)?.candidates,m=new Set(Object.values(v).filter(i=>typeof i=="string")),w=(e.kinds.includes("*")?[...r.graph.allNodes()]:e.kinds.flatMap(i=>r.graph.nodesOfKind(i))).filter(i=>!m.has(i.id)),d=n?n.map(i=>r.graph.getNode(i)).filter(i=>i!==void 0):w,b=V(d,i=>r.schema.tryDefinition(i));return(0,a.jsxs)("label",{"data-graview-part":"field","data-graview-field":e.control,children:[(0,a.jsx)("span",{"data-graview-part":"label",children:u}),(0,a.jsx)(re,{children:(0,a.jsxs)("select",{name:e.name,required:!e.optional,value:typeof t=="string"?t:"",onChange:i=>o(i.target.value||void 0),"data-graview-part":"control",children:[(0,a.jsx)("option",{value:"",children:"\u2014"}),d.map(i=>{let F=b.get(i.id);return(0,a.jsxs)("option",{value:i.id,children:[z(r.schema.tryDefinition(i.kind),i),F?` \xB7 ${F}`:""]},i.id)})]})})]})}case"group":{let n=t??{};return(0,a.jsxs)("fieldset",{"data-graview-part":"group","data-graview-field":e.control,children:[(0,a.jsx)("legend",{"data-graview-part":"label",children:u}),e.fields.map(m=>(0,a.jsx)(M,{store:r,spec:m,value:n[m.name],onChange:w=>o({...n,[m.name]:w}),prefilled:v,open:f,words:s},m.name))]})}case"variant":{let n=t??{},m=typeof n[e.tag]=="string"?n[e.tag]:"",w=e.options.find(d=>d.value===m);return(0,a.jsxs)("fieldset",{"data-graview-part":"group","data-graview-field":e.control,children:[(0,a.jsx)("legend",{"data-graview-part":"label",children:u}),(0,a.jsxs)("label",{"data-graview-part":"field","data-graview-field":"choice",children:[(0,a.jsx)("span",{"data-graview-part":"label",children:E(e.tag)}),(0,a.jsxs)("select",{value:m,onChange:d=>o({[e.tag]:d.target.value}),"data-graview-part":"control",children:[(0,a.jsx)("option",{value:"",children:"\u2014"}),e.options.map(d=>(0,a.jsx)("option",{value:d.value,children:E(d.value)},d.value))]})]}),w?.fields.map(d=>(0,a.jsx)(M,{store:r,spec:d,value:n[d.name],onChange:b=>o({...n,[d.name]:b}),prefilled:v,open:f,words:s},d.name))]})}case"file":case"list":{let n=e.control==="file"?e:e.item.control==="file"?e.item:void 0;if(n||e.control==="file")return(0,a.jsx)(L,{as:"control",title:A?`${g} *`:g,value:t,onChange:o,several:n!==e,image:n?.image===!0,video:n?.video===!0,label:g});let m=Array.isArray(t)?t:[];return(0,a.jsxs)("fieldset",{"data-graview-part":"group","data-graview-field":"list",children:[(0,a.jsx)("legend",{"data-graview-part":"label",children:u}),m.map((w,d)=>(0,a.jsxs)("div",{"data-graview-part":"item",children:[(0,a.jsx)("div",{style:{flex:1},children:(0,a.jsx)(M,{store:r,spec:{...e.item,optional:!1},value:w,onChange:b=>o(m.map((i,F)=>F===d?b:i)),prefilled:v,open:f,words:s})}),(0,a.jsx)("button",{type:"button","data-graview-part":"remove",onClick:()=>o(m.filter((b,i)=>i!==d)),children:"remove"})]},d)),(0,a.jsx)("button",{type:"button","data-graview-part":"add",onClick:()=>o([...m,void 0]),children:"add another"})]})}case"linked":return(0,a.jsx)("div",{"data-graview-part":"field","data-graview-field":"linked",children:(0,a.jsx)(O,{relation:e.relation,value:t,onChange:o,label:g})});case"repeat":return(0,a.jsx)(W,{value:t,onChange:o,start:e.of?S?.[e.of]:void 0,label:`${e.of?s(e.of).label:g} repeats`,name:e.name});case"opaque":return(0,a.jsxs)("p",{"data-graview-part":"unasked",children:["\u201C",E(e.name),"\u201D needs a structured answer this form cannot ask for yet."]})}}function ge(r){let e=[...r.querySelectorAll("input:not([type=hidden]), select, textarea")].filter(t=>!t.disabled&&!t.closest("[hidden], [inert], [aria-hidden='true']"));return e.find(t=>t.required&&t.value==="")??e[0]??r.querySelector('button[type="submit"]')}function Fe({store:r,mutation:e,prefilled:t={},open:o=[],onDone:v,principal:f,initial:s,label:S,only:g,autoFocus:A=!1}){let u=()=>ae(e,r.graph,t),[n,m]=(0,y.useState)(u),[w,d]=(0,y.useState)(()=>({...n,...s})),[b,i]=(0,y.useState)(null),F=f??r.seenFor,q=e.subject&&t[e.subject.arg],ie=F?ne(r,F,e,typeof q=="string"?q:void 0):void 0,j=ee(r.schema,e),C=(g===void 0?j:g.flatMap(l=>j.find(p=>p.name===l)??[])).filter(l=>!ie?.has(l.name)),oe=l=>Y(r.schema,e,l),P=X(C.filter(l=>l.control==="date").map(l=>l.name)),D=(0,y.useRef)(void 0),le=(l,p)=>d(c=>{let x={...c,[l.name]:p};if(P&&l.name===P.start&&l.control==="date"){let h=k=>typeof k=="string"&&k!==""?k:void 0,R=h(c[P.start])??D.current;if(h(p)){D.current=h(p);let k=U(R,h(p),h(c[P.end]),{time:l.time===!0,instant:l.instant===!0});k!==void 0&&(x[P.end]=k)}}return x}),H=(0,y.useRef)(null);return(0,y.useEffect)(()=>{if(!A)return;let l=document.activeElement,p=0,c=0,x=()=>{let h=H.current;if(!h)return;let R=document.activeElement;if(R!==l&&R!==document.body&&R!==null&&!h.contains(R)||h.contains(R))return;let k=h.querySelector("[data-graview-when-arriving]")&&c<30?null:ge(h);if(k){k.focus();return}c+=1,c<=30&&(p=requestAnimationFrame(x))};return p=requestAnimationFrame(x),()=>cancelAnimationFrame(p)},[]),(0,a.jsxs)("form",{ref:H,"data-testid":`form-${e.name}`,onSubmit:l=>{l.preventDefault();try{r.apply({name:e.name,args:{...te(Z(C,w),n),...t}},f?{author:f}:{}),i(null);let p=u();m(p),d({...p}),v?.()}catch(p){i(_(r.schema,r.allMutations(),p));let c=e.subject?t[e.subject.arg]:void 0,x=typeof c=="string"?r.graph.getNode(c)?.kind:void 0;$(r,{type:"refused",act:e.name,code:K(p).reason,...x?{kind:x}:{}},f)}},"data-graview-part":"form",children:[(0,a.jsx)("style",{children:se}),C.map(l=>(0,a.jsx)(M,{store:r,spec:l,value:w[l.name],values:w,onChange:p=>le(l,p),prefilled:t,open:o,words:oe},l.name)),b?(0,a.jsx)("p",{"data-testid":"refused","data-graview-part":"refused",role:"alert",children:b}):null,(0,a.jsx)("button",{type:"submit","data-graview-part":"submit",children:S??e.title??e.name})]})}export{Fe as a};