graview 0.1.36 → 0.1.37

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 (169) hide show
  1. package/dist/preview/{chunk.T47DLH5Z.js → chunk.24E4R4ZH.js} +1 -1
  2. package/dist/preview/{chunk.DSP62QYK.js → chunk.2JF254FO.js} +1 -1
  3. package/dist/preview/chunk.2TDB4D6Y.js +1 -0
  4. package/dist/preview/{chunk.YNE5QR7Q.js → chunk.3IVVXVG7.js} +1 -1
  5. package/dist/preview/{chunk.WJ2TWU2I.js → chunk.3KJQXYCA.js} +1 -1
  6. package/dist/preview/chunk.3V2M3S4U.js +1 -0
  7. package/dist/preview/{chunk.WHTQHU3M.js → chunk.4NCXMVPY.js} +1 -1
  8. package/dist/preview/chunk.57XTDW57.js +1 -0
  9. package/dist/preview/chunk.5CLFTXP3.js +1 -0
  10. package/dist/preview/chunk.5EXYDBAL.js +88 -0
  11. package/dist/preview/chunk.5JPRRV47.js +1 -0
  12. package/dist/preview/{chunk.ZVMIHXVK.js → chunk.67PVRVAC.js} +1 -1
  13. package/dist/preview/{chunk.FERBNBDE.js → chunk.6DYZBDWT.js} +1 -1
  14. package/dist/preview/chunk.6SK2K72G.js +1 -0
  15. package/dist/preview/{chunk.TGEF6TMM.js → chunk.74DXEKUV.js} +1 -1
  16. package/dist/preview/chunk.76QUEWYD.js +1 -0
  17. package/dist/preview/{chunk.QDHUDLJB.js → chunk.7MMNMZLF.js} +1 -1
  18. package/dist/preview/chunk.7OLVQ2FZ.js +1 -0
  19. package/dist/preview/{chunk.MXJS67W4.js → chunk.7UQOXYJX.js} +1 -1
  20. package/dist/preview/{chunk.ER5ILWKY.js → chunk.AHC4EXLW.js} +2 -2
  21. package/dist/preview/{chunk.ZWZ5SEXT.js → chunk.AWRS6TUN.js} +1 -1
  22. package/dist/preview/{chunk.H4T56OXM.js → chunk.AZ333RB3.js} +1 -1
  23. package/dist/preview/{chunk.HZPTBPJY.js → chunk.BA3REPV5.js} +1 -1
  24. package/dist/preview/{chunk.5PU3RWYY.js → chunk.BRBY5WJT.js} +2 -2
  25. package/dist/preview/{chunk.6KMXLUOS.js → chunk.BXWO6ILK.js} +1 -1
  26. package/dist/preview/chunk.CGQLE7JW.js +1 -0
  27. package/dist/preview/chunk.CV4CBHFT.js +1 -0
  28. package/dist/preview/chunk.CYPTJNES.js +1 -0
  29. package/dist/preview/{chunk.ACXA55GW.js → chunk.D2ILIAND.js} +1 -1
  30. package/dist/preview/chunk.DLCFCMKX.js +1 -0
  31. package/dist/preview/chunk.DMUUYZ37.js +1 -0
  32. package/dist/preview/chunk.DNNL7F3P.js +25 -0
  33. package/dist/preview/chunk.EHT4HBH5.js +35 -0
  34. package/dist/preview/chunk.EKUAI5YL.js +1 -0
  35. package/dist/preview/chunk.ELY2RMGE.js +19 -0
  36. package/dist/preview/{chunk.6ZZZBDEG.js → chunk.ENEOGGFM.js} +1 -1
  37. package/dist/preview/chunk.ENJKCSNX.js +1 -0
  38. package/dist/preview/chunk.FEPYKPZE.js +1 -0
  39. package/dist/preview/{chunk.ET76FISZ.js → chunk.FFW6XWHB.js} +1 -1
  40. package/dist/preview/{chunk.ZEW2OOZ5.js → chunk.FGYCYLUS.js} +1 -1
  41. package/dist/preview/{chunk.ITXIFDQ7.js → chunk.G7S7GLDK.js} +1 -1
  42. package/dist/preview/chunk.GMZAQGH7.js +1 -0
  43. package/dist/preview/chunk.GXPBRYSR.js +1 -0
  44. package/dist/preview/{chunk.42WJ6VJZ.js → chunk.H4LFJPDV.js} +1 -1
  45. package/dist/preview/chunk.HBBVVALN.js +5 -0
  46. package/dist/preview/{chunk.NWYOLGQ3.js → chunk.HCK4Y6C5.js} +1 -1
  47. package/dist/preview/chunk.HSRGYZOR.js +1 -0
  48. package/dist/preview/chunk.HYAKRLPT.js +4 -0
  49. package/dist/preview/chunk.IHBIRAC4.js +2 -0
  50. package/dist/preview/chunk.IWK5QL6P.js +1 -0
  51. package/dist/preview/{chunk.WQBDTLPZ.js → chunk.J2CR4RRH.js} +1 -1
  52. package/dist/preview/chunk.J2HQEUYA.js +1 -0
  53. package/dist/preview/{chunk.R45BF6JV.js → chunk.JBRXGPPM.js} +1 -1
  54. package/dist/preview/chunk.JDRM6XXD.js +2 -0
  55. package/dist/preview/chunk.JFLUVZNW.js +1 -0
  56. package/dist/preview/chunk.KAWP4RNR.js +1 -0
  57. package/dist/preview/{chunk.OF34OZ4V.js → chunk.KSXB4LDF.js} +1 -1
  58. package/dist/preview/{chunk.FUR4IHWG.js → chunk.LJE5J3JK.js} +1 -1
  59. package/dist/preview/chunk.LPJY6V5D.js +1 -0
  60. package/dist/preview/chunk.LVLAS5GL.js +1 -0
  61. package/dist/preview/{chunk.7CO7S6QM.js → chunk.LVNAB2BW.js} +1 -1
  62. package/dist/preview/{chunk.XRCGADKC.js → chunk.LYJXX6BU.js} +1 -1
  63. package/dist/preview/{chunk.CUCNT7MG.js → chunk.MJLUAGEV.js} +1 -1
  64. package/dist/preview/chunk.MKPJKZAP.js +1 -0
  65. package/dist/preview/chunk.MMBMVHIG.js +1 -0
  66. package/dist/preview/chunk.NNNVB6RV.js +1 -0
  67. package/dist/preview/chunk.NOZEHLWG.js +2 -0
  68. package/dist/preview/{chunk.SG23JC6D.js → chunk.NV6IZJKA.js} +1 -1
  69. package/dist/preview/{chunk.RKHEZ6KZ.js → chunk.NWHFFOXW.js} +1 -1
  70. package/dist/preview/chunk.NZJZIYDK.js +1 -0
  71. package/dist/preview/chunk.O6KNGFWH.js +1 -0
  72. package/dist/preview/chunk.PMK73A53.js +1 -0
  73. package/dist/preview/chunk.PQPZZ7ZW.js +117 -0
  74. package/dist/preview/{chunk.Y3IJDWNS.js → chunk.QJYALCIW.js} +1 -1
  75. package/dist/preview/chunk.QMZUKAPJ.js +1 -0
  76. package/dist/preview/{chunk.GUDKPK42.js → chunk.QNGFBJWP.js} +1 -1
  77. package/dist/preview/{chunk.LMVCWYYG.js → chunk.QOXTBRKE.js} +1 -1
  78. package/dist/preview/{chunk.BZ5VLPKB.js → chunk.QXARGANF.js} +6 -6
  79. package/dist/preview/{chunk.P75TPZWT.js → chunk.QYWBQ5NX.js} +1 -1
  80. package/dist/preview/{chunk.EDSPYKR4.js → chunk.RPOYSIVQ.js} +1 -1
  81. package/dist/preview/{chunk.HPX3F7XX.js → chunk.SNKOPWAD.js} +1 -1
  82. package/dist/preview/{chunk.EBLKEQ7O.js → chunk.SZMWJHU2.js} +1 -1
  83. package/dist/preview/{chunk.KU6NIMQX.js → chunk.TN4GY6LW.js} +1 -1
  84. package/dist/preview/{chunk.O3OALXCI.js → chunk.TRLVFHFT.js} +2 -2
  85. package/dist/preview/chunk.TSI4O3GH.js +1 -0
  86. package/dist/preview/chunk.TX5QIZEP.js +1 -0
  87. package/dist/preview/{chunk.UJR3Y7MP.js → chunk.TXS4I326.js} +1 -1
  88. package/dist/preview/chunk.U4URQDC5.js +1 -0
  89. package/dist/preview/chunk.UCVZG7S4.js +1 -0
  90. package/dist/preview/{chunk.LA7535VO.js → chunk.UPBUF7KR.js} +1 -1
  91. package/dist/preview/{chunk.DANDYIB5.js → chunk.UR5TT4JH.js} +1 -1
  92. package/dist/preview/{chunk.OREMUXB5.js → chunk.UV2TSAB4.js} +1 -1
  93. package/dist/preview/{chunk.IMRCAU4T.js → chunk.UVLPVHID.js} +1 -1
  94. package/dist/preview/chunk.VUKHDZNI.js +1 -0
  95. package/dist/preview/{chunk.S6GJGTJE.js → chunk.VW6WGFL6.js} +1 -1
  96. package/dist/preview/chunk.VX7MGVP5.js +1 -0
  97. package/dist/preview/{chunk.WGI5G6NM.js → chunk.WLV2QYTS.js} +1 -1
  98. package/dist/preview/{chunk.GOCUBIRW.js → chunk.WNKRXL3O.js} +1 -1
  99. package/dist/preview/chunk.WNMLA4YW.js +1 -0
  100. package/dist/preview/{chunk.T2CN7UTZ.js → chunk.WVEKYJSI.js} +2 -2
  101. package/dist/preview/{chunk.2B4WVCVV.js → chunk.X2OLXTRL.js} +1 -1
  102. package/dist/preview/{chunk.J3TEJBI5.js → chunk.XS3SAH6U.js} +1 -1
  103. package/dist/preview/chunk.XWJ2MRQF.js +1 -0
  104. package/dist/preview/{chunk.D6RDTUX3.js → chunk.Y44TR4WG.js} +1 -1
  105. package/dist/preview/{chunk.OXZRGP53.js → chunk.YAXOIJVH.js} +1 -1
  106. package/dist/preview/chunk.YFW5BF6J.js +1 -0
  107. package/dist/preview/chunk.YNJOLOFG.js +1 -0
  108. package/dist/preview/{chunk.6QDFBCV4.js → chunk.YW2BZ2LH.js} +2 -2
  109. package/dist/preview/chunk.YX354FRV.js +1 -0
  110. package/dist/preview/{chunk.QTITRX5Q.js → chunk.ZB7GV3IT.js} +1 -1
  111. package/dist/preview/{chunk.KBJG5SI2.js → chunk.ZOT4V66Q.js} +1 -1
  112. package/dist/preview/chunk.ZYPCE2LZ.js +1 -0
  113. package/dist/preview/index.html +42 -42
  114. package/dist/preview/page.js +5 -5
  115. package/package.json +6 -6
  116. package/dist/preview/chunk.272ZJXQP.js +0 -1
  117. package/dist/preview/chunk.27TLAVRR.js +0 -19
  118. package/dist/preview/chunk.2A2DLMT3.js +0 -1
  119. package/dist/preview/chunk.3PT55HXT.js +0 -1
  120. package/dist/preview/chunk.3SM2CHKF.js +0 -1
  121. package/dist/preview/chunk.3ZIOAPI5.js +0 -1
  122. package/dist/preview/chunk.4B73P2WA.js +0 -2
  123. package/dist/preview/chunk.4GXXD4NG.js +0 -1
  124. package/dist/preview/chunk.4Q56V7GS.js +0 -1
  125. package/dist/preview/chunk.4STIUIT6.js +0 -1
  126. package/dist/preview/chunk.53IKY7UP.js +0 -1
  127. package/dist/preview/chunk.56BPXB6E.js +0 -1
  128. package/dist/preview/chunk.64MJ5FRL.js +0 -1
  129. package/dist/preview/chunk.6II4BONS.js +0 -25
  130. package/dist/preview/chunk.6W7J76TK.js +0 -1
  131. package/dist/preview/chunk.7G3B5QPH.js +0 -1
  132. package/dist/preview/chunk.7TBSVQSH.js +0 -1
  133. package/dist/preview/chunk.7YQYWOZR.js +0 -1
  134. package/dist/preview/chunk.AAZFVCSP.js +0 -2
  135. package/dist/preview/chunk.ACEYGWMO.js +0 -1
  136. package/dist/preview/chunk.CE3NOADH.js +0 -1
  137. package/dist/preview/chunk.CNJENUPC.js +0 -1
  138. package/dist/preview/chunk.CRPT3ZT3.js +0 -1
  139. package/dist/preview/chunk.E77K6KBX.js +0 -1
  140. package/dist/preview/chunk.EQIGKXIG.js +0 -1
  141. package/dist/preview/chunk.F5BCCGFK.js +0 -5
  142. package/dist/preview/chunk.FQKH67BP.js +0 -1
  143. package/dist/preview/chunk.FWBQVPMI.js +0 -1
  144. package/dist/preview/chunk.GXLAZGYT.js +0 -1
  145. package/dist/preview/chunk.GZLYTPE7.js +0 -1
  146. package/dist/preview/chunk.IB32NOV5.js +0 -2
  147. package/dist/preview/chunk.JLXQ6ZLI.js +0 -1
  148. package/dist/preview/chunk.JZMA2AV7.js +0 -1
  149. package/dist/preview/chunk.K5NJTE3F.js +0 -35
  150. package/dist/preview/chunk.LNNFNJKN.js +0 -1
  151. package/dist/preview/chunk.M4FQ7SSM.js +0 -1
  152. package/dist/preview/chunk.NJ62C2GU.js +0 -1
  153. package/dist/preview/chunk.NNCTJSD3.js +0 -1
  154. package/dist/preview/chunk.O6ROFVFD.js +0 -88
  155. package/dist/preview/chunk.OFJH7LDC.js +0 -1
  156. package/dist/preview/chunk.OH5BBE2B.js +0 -1
  157. package/dist/preview/chunk.OZR5NI4J.js +0 -1
  158. package/dist/preview/chunk.PWOVXARZ.js +0 -1
  159. package/dist/preview/chunk.Q63RPNUS.js +0 -1
  160. package/dist/preview/chunk.QEALNWWL.js +0 -117
  161. package/dist/preview/chunk.QLMUGC7R.js +0 -1
  162. package/dist/preview/chunk.R7LRJS6B.js +0 -4
  163. package/dist/preview/chunk.SSRP5SBR.js +0 -1
  164. package/dist/preview/chunk.VHWUGSFW.js +0 -1
  165. package/dist/preview/chunk.W42P7NOL.js +0 -1
  166. package/dist/preview/chunk.XBTZXWJX.js +0 -1
  167. package/dist/preview/chunk.ZDNJK2SX.js +0 -1
  168. package/dist/preview/chunk.ZNS3LYJU.js +0 -1
  169. package/dist/preview/chunk.ZSSOTIFL.js +0 -1
@@ -1 +0,0 @@
1
- import{a as S,b as $,c as w,d as R,e as V}from"./chunk.2B4WVCVV.js";import{h as l,i as F}from"./chunk.AAZFVCSP.js";import{xa as b,ya as A}from"./chunk.F5BCCGFK.js";var O=["card","row","page"],E=["good","warn","bad","neutral","accent"],P=["money","percent","date","relative","count"],_=4,T=40,I=120,L=["number","money","percent"],B=["large"],H=["card","row"],M=1e3,ue=100;function U(e){let n=/^\s*(out|in)\(\s*['"]([A-Za-z][A-Za-z0-9_-]*)['"]\s*\)\s*$/.exec(e);return n?{edge:n[2],way:n[1]}:/^[A-Za-z][A-Za-z0-9_-]*$/.test(e)?{edge:e}:void 0}var v={title:[],headline:[],list:["sort","limit","group","empty","as"],text:["tone"],badge:["tone"],field:["as","currency","label"],image:["as","label"],progress:["label"],group:["direction"],when:["show"],divider:[],figure:["as","currency","label","emphasis"]},C=Object.keys(v),G=`{"title": "{name}"}, {"headline": "{count(all('offer'))} offers"}, {"figure": expr, "as"?: "number"|"money"|"percent", "currency"?, "label"?, "emphasis"?: "large"}, {"list": expr, "sort"?, "limit"?, "group"?, "empty"?, "as"?: "card"|"row"}, {"text": "\u2026", "tone"?}, {"badge": "{status}", "tone"?}, {"field": "quote", "as"?, "currency"?, "label"?}, {"image": "photos", "as"?: "thumb"|"gallery"}, {"progress": {"value": expr, "max": expr}, "label"?}, {"group": [blocks], "direction"?: "row"|"column"}, {"when": expr, "show": [blocks]}, {"divider": true}, {"figure": true}`,Z=e=>/^(image|file)$/.test(e?.of??e?.type??"");function fe(e){return Object.fromEntries(Object.entries(e.views??{}).filter(([,n])=>!Array.isArray(n)))}function ce(e){let n=e.views?.home;return Array.isArray(n)?n:void 0}var X={field:()=>!1,relation:()=>!1,figure:!1},Y=e=>e.kind??"the home",p=(e,n)=>e!==void 0&&Object.hasOwn(e,n),g=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function z(e,n,o){let t=S(e);for(let d of t.unknownFunctions)o.findings.push(l("unknown-function",n,`"${d}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let d of t.names){if(o.kind===null){o.findings.push(l("view-name",n,`"${d}" names nothing here: these blocks are about no one record`,"reach records with all('<kind>'), like count(all('offer')) or first(all('party') where role == 'client').name"));continue}d==="id"||o.spec.field(d)||o.spec.relation(d)||o.findings.push(l("view-name",n,`${o.kind} has no field or relation called "${d}"`))}for(let d of t.edges)o.edges.has(d)||o.findings.push(l("view-edge",n,`"${d}" is not a relation any kind declares`));for(let d of t.sweeps)o.kinds.has(d)||o.findings.push(l("view-kind",n,`"${d}" is not a kind this document declares`))}function k(e,n,o){if(typeof e!="string"||e.length===0||e.length>2e3){o.findings.push(l("view-expression",n,`an expression is a line of the rule language, like "status == 'booked'"`));return}try{z(w(e),n,o)}catch(t){if(!(t instanceof $))throw t;o.findings.push(l("expression",n,`${t.sentence} (at character ${t.at+1})`))}}function j(e,n,o,t=!1){if(typeof e!="string"||e.length===0||e.length>300){o.findings.push(l("view-template",n,'a template is words with {field} in braces, like "{name}" or "{quote|money}", at most 300 characters'));return}let d;try{d=V(e)}catch(a){if(a instanceof R||a instanceof $){o.findings.push(l("template",n,a.sentence));return}throw a}for(let a of d)if(a.expr&&(z(a.expr,n,o),t&&!a.format&&a.expr.t==="ident"&&(o.slot==="card"||o.slot==="row")&&o.spec.prose?.(a.expr.name))){let r=a.expr.name;o.findings.push(F("view-whole-text",n,`${o.kind} ${o.slot} shows ${r} whole; it will be clamped. Use {${r}|excerpt} or move it to the page.`,`write {${r}|excerpt}, or {${r}|excerpt: 80} for fewer characters`))}}function q(e,n,o){if(typeof e=="string"){E.includes(e)||o.findings.push(l("view-tone",n,`"${e}" is not a tone`,`use one of ${E.join(", ")}, or {"expr": "if(status == 'booked', 'good', 'neutral')"}`));return}if(g(e)&&Object.keys(e).length===1&&"expr"in e){k(e.expr,`${n}.expr`,o);return}o.findings.push(l("view-tone",n,'a tone is a word or {"expr": \u2026}',`one of ${E.join(", ")}`))}function x(e,n,o,t){if(!Array.isArray(e)){t.findings.push(l("view-shape",n,"a view is a list of blocks"));return}if(o>_){t.findings.push(l("view-depth",n,`blocks nest at most ${_} deep`,"flatten a group or a condition"));return}e.forEach((d,a)=>J(d,`${n}.${a}`,o,t))}function J(e,n,o,t){if(o===1&&t.count++,t.all++,!g(e)){t.findings.push(l("view-block",n,"a block is an object naming what it shows",`one of ${G}`));return}let d=Object.keys(e),a=d.filter(s=>C.includes(s)&&!(s==="group"&&d.includes("list")));if(a.length===0){t.findings.push(l("view-block",n,`${d.length>0?d.map(s=>`"${s}"`).join(", "):"an empty object"} is not a block Graview knows`,`one of ${G}`));return}if(a.length>1){t.findings.push(l("view-block",n,`a block is one thing, and this says ${a.map(s=>`"${s}"`).join(" and ")}`,"split it into two blocks"));return}let r=a[0];for(let s of d)s!==r&&s!="key"&&!v[r].includes(s)&&t.findings.push(l("unknown-key",`${n}.${s}`,`"${s}" is not part of a ${r} block`,v[r].length>0?`a ${r} block may also say ${v[r].map(u=>`"${u}"`).join(", ")}`:`a ${r} block says nothing else`));let i=e[r];switch(r){case"title":case"headline":case"text":case"badge":j(i,`${n}.${r}`,t,r==="text"),"tone"in e&&q(e.tone,`${n}.tone`,t);return;case"image":case"field":{let s=r==="image";if(typeof i!="string"||!(s?t.spec.files?.(i):t.spec.field(i))){let f=typeof i=="string"&&t.spec.relation(i);t.findings.push(l(`view-${r}`,`${n}.${r}`,`${t.kind} has no ${s?"image or file ":""}field ${typeof i=="string"?`"${i}"`:"by that name"}`,f?`"${i}" is a relation; show it with {"text": "{${i}.name}"}`:void 0))}let u=s?["thumb","gallery"]:P;"as"in e&&!u.includes(e.as)&&t.findings.push(l("view-format",`${n}.as`,`"${String(e.as)}" is not a way to show ${s?"pictures":"a field"}`,`use one of ${u.join(", ")}`)),s||N(e,n,t,"field"),"label"in e&&ie(e.label,`${n}.label`,t);return}case"progress":{!g(i)||Object.keys(i).some(s=>s!=="value"&&s!=="max")||!("value"in i)||!("max"in i)?t.findings.push(l("view-progress",`${n}.progress`,'progress is {"value": expression, "max": expression}')):(k(i.value,`${n}.progress.value`,t),k(i.max,`${n}.progress.max`,t)),"label"in e&&j(e.label,`${n}.label`,t);return}case"group":"direction"in e&&e.direction!=="row"&&e.direction!=="column"&&t.findings.push(l("view-direction",`${n}.direction`,`a group runs "row" or "column", not "${String(e.direction)}"`)),x(i,`${n}.group`,o+1,t);return;case"when":k(i,`${n}.when`,t),"show"in e?x(e.show,`${n}.show`,o+1,t):t.findings.push(l("view-when",n,'a condition says what it shows: {"when": expr, "show": [blocks]}'));return;case"figure":if(typeof i=="string")return Q(e,n,t);for(let s of["as","currency","label","emphasis"])s in e&&t.findings.push(l("unknown-key",`${n}.${s}`,`"${s}" belongs to a figure that works a number out; {"figure": true} is the kind's picture`,`write {"figure": "count(all('offer'))", "as": "number"}`));i!==!0?t.findings.push(l("view-block",`${n}.figure`,`a figure is a number worked out, {"figure": "sum(all('offer'), net)", "as": "money"}, or the kind's picture, {"figure": true}`)):t.spec.figure||t.findings.push(l("view-figure",`${n}.figure`,`${Y(t)} has no figure to show`,t.kind===null?`work a number out: {"figure": "count(all('offer'))"}`:'give the kind a "figure", or leave this block out'));return;case"list":return ne(e,n,t);case"divider":i!==!0&&t.findings.push(l("view-block",`${n}.${r}`,`write {"${r}": true}`));return}}function Q(e,n,o){k(e.figure,`${n}.figure`,o),"as"in e&&!L.includes(e.as)&&o.findings.push(l("view-format",`${n}.as`,`"${String(e.as)}" is not a way to say a figure`,`use one of ${L.join(", ")}`)),N(e,n,o,"figure"),"label"in e&&j(e.label,`${n}.label`,o),"emphasis"in e&&!B.includes(e.emphasis)&&o.findings.push(l("view-emphasis",`${n}.emphasis`,`"${String(e.emphasis)}" is not how loudly a figure is said`,`use ${B.map(t=>`"${t}"`).join(", ")}, or leave it out for the figure's own size`))}function N(e,n,o,t){"currency"in e&&(typeof e.currency!="string"||!/^[A-Z]{3}$/.test(e.currency)?o.findings.push(l("view-currency",`${n}.currency`,'a currency is its three-letter code, like "USD" or "EUR"')):e.as!=="money"&&o.findings.push(l("view-currency",`${n}.currency`,`a currency belongs on a ${t} shown as money`,'add "as": "money"')))}function ee(e,n){let o=[...n.kinds],t=(a,r)=>{let i=new Set;for(let s of a){let u=n.vocabulary.namesOf(s)?.targets?.(r);if(u==="*")return o;for(let f of u??[])i.add(f)}return i.size>0?[...i]:void 0},d=a=>{switch(a.t){case"ident":return n.kind!==null&&n.spec.relation(a.name)?t([n.kind],a.name):void 0;case"member":{let r=d(a.object);return r?t(r,a.name):void 0}case"where":return d(a.set);case"call":{let r=a.args[0],i=r?.t==="lit"&&typeof r.value=="string"?r.value:void 0;if(a.fn==="all")return i!==void 0&&n.kinds.has(i)?[i]:void 0;let s=a.args.length===2&&a.args[1]?.t==="lit"&&typeof a.args[1].value=="string"?a.args[1].value:void 0;if(a.fn==="out"&&s!==void 0){let u=d(r);return u?t(u,s):void 0}if(a.fn==="out")return i!==void 0&&n.kind!==null?t([n.kind],i):void 0;if(a.fn==="in"){let u=s??i,f=s!==void 0?d(r):n.kind!==null?[n.kind]:void 0,c=u!==void 0?n.vocabulary.sources(u).filter(m=>{let y=n.vocabulary.namesOf(m)?.targets?.(u);return!f||y==="*"||f.some(h=>y?.includes(h))}):[];return c.length>0?c:void 0}if((a.fn==="sort"||a.fn==="first")&&r)return d(r);if(a.fn==="either"){let u=a.args.map(d);return u.every(f=>f!==void 0)?[...new Set(u.flatMap(f=>f??[]))]:void 0}return}default:return}};return d(e)}function K(e,n,o,t){let d;try{d=w(e)}catch(r){if(!(r instanceof $))throw r;t.findings.push(l("expression",n,`${r.sentence} (at character ${r.at+1})`));return}let a=S(d);for(let r of a.unknownFunctions)t.findings.push(l("unknown-function",n,`"${r}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let r of a.edges)t.edges.has(r)||t.findings.push(l("view-edge",n,`"${r}" is not a relation any kind declares`));if(o)for(let r of a.names)r==="id"||o.some(i=>t.vocabulary.namesOf(i)?.field(r)||t.vocabulary.namesOf(i)?.relation(r))||t.findings.push(l("view-name",n,`${o.join(" and ")} ${o.length===1?"has":"have"} no field or relation called "${r}"`))}function ne(e,n,o){let t=e.list;k(t,`${n}.list`,o);let d;if(typeof t=="string")try{d=ee(w(t),o)}catch{d=void 0}let a=i=>{if(!d)return[...o.kinds].map(u=>o.vocabulary.namesOf(u)?.choices?.(i)).find(u=>u!==void 0);let s=d.map(u=>o.vocabulary.namesOf(u)?.choices?.(i));return s.every(u=>u!==void 0)?[...new Set(s.flatMap(u=>u??[]))]:void 0},r=d?d.join(" and "):"any kind";if("sort"in e){let i=e.sort;if(typeof i=="string")K(i,`${n}.sort`,d,o);else if(g(i)&&typeof i.by=="string"&&Object.keys(i).every(s=>s==="by"||s==="direction")){let s=i.direction;s!==void 0&&s!=="asc"&&s!=="desc"&&s!=="choices"?o.findings.push(l("list-sort",`${n}.sort.direction`,`a list is sorted "asc", "desc" or "choices", not "${String(s)}"`,'"choices" puts a choice field in the order its choices are declared')):s==="choices"?a(i.by)===void 0&&o.findings.push(l("list-sort",`${n}.sort.by`,`"${i.by}" is not a choice field of ${r}, so it has no declared order`,'sort by a choice field, or say "asc" or "desc"')):K(i.by,`${n}.sort.by`,d,o)}else o.findings.push(l("list-sort",`${n}.sort`,'a sort is a key, like "net", or {"by": key, "direction": "asc" | "desc" | "choices"}'))}if("limit"in e){let i=e.limit;(typeof i!="number"||!Number.isInteger(i)||i<1||i>M)&&o.findings.push(l("list-limit",`${n}.limit`,`a limit is a whole number from 1 to ${M}`))}if("group"in e){let i=e.group,s=typeof i=="string"?i:g(i)&&typeof i.by=="string"?i.by:void 0;if(!(typeof i=="string"||g(i)&&Object.keys(i).every(f=>f==="by"||f==="headings"))||s===void 0)o.findings.push(l("list-group",`${n}.group`,'a group is a choice field, like "type", or {"by": "type", "headings": {"pain": "What hurts"}} \u2014 or a relation, like "inGenre", a heading per linked record'));else{let f=a(s),c=f===void 0?U(s):void 0,m=c!==void 0&&(c.way!==void 0?o.edges.has(c.edge):d?d.every(y=>o.vocabulary.namesOf(y)?.relation(c.edge)):o.edges.has(c.edge));if(f===void 0&&!m&&o.findings.push(l("list-group",`${n}.group`,`"${s}" is not a choice field or a relation of ${r}, so it has nothing to group by`,'group by a field whose type is enum, or by a relation of the kind listed, like "inGenre"')),g(i)&&"headings"in i){let y=i.headings;if(!g(y)||Object.values(y).some(h=>typeof h!="string"||h.length===0||h.length>80))o.findings.push(l("list-group",`${n}.group.headings`,'headings are words per choice, like {"pain": "What hurts"}, at most 80 characters each'));else if(f)for(let h of Object.keys(y))f.includes(h)||o.findings.push(l("list-group",`${n}.group.headings.${h}`,`"${h}" is not one of ${s}'s choices`,`use ${f.join(", ")}`))}}}"empty"in e&&(typeof e.empty!="string"||e.empty.length===0||e.empty.length>200)&&o.findings.push(l("list-empty",`${n}.empty`,"what an empty list says is a sentence, at most 200 characters")),"as"in e&&!H.includes(e.as)&&o.findings.push(l("list-as",`${n}.as`,`a list draws each record as its "card" or its "row", not "${String(e.as)}"`))}function ie(e,n,o){(typeof e!="string"||e.length===0||e.length>60)&&o.findings.push(l("view-label",n,"a label is a few words, at most 60 characters"))}function W(e,n,o,t,d,a,r){let i={kind:null,spec:X,kinds:t,edges:d,vocabulary:o,findings:a,count:0,all:0};Array.isArray(e)&&e.length===0&&a.push(l("view-shape",n,`${r} has no blocks`,'give it one: {"headline": "\u2026"}')),x(e,n,1,i),D(i,n,r,"show less")}function D(e,n,o,t){e.count>T?e.findings.push(l("view-size",n,`${o} has ${e.count} blocks at its top; a view has at most ${T} there, a group or a condition counting as one`,`${t}, or gather some into a group`)):e.all>I&&e.findings.push(l("view-size",n,`${o} has ${e.all} blocks counting the ones inside its groups and conditions; a view has at most ${I} in all`,t))}function oe(e,n,o,t,d){Array.isArray(e)&&e.forEach((a,r)=>{if(!g(a)||a.name!=="blocks"||!g(a.options)||!("blocks"in a.options))return;let i=[];W(a.options.blocks,`lenses.${r}.options.blocks`,n,o,t,i,`the lens "${String(a.title??r)}"`);for(let s of i)d.push({...s,severity:"warning"})})}function te(e,n,o,t,d,a,r){let i=[];if(e===void 0)return i;if(!g(e))return i.push(l("view-shape",n,'views are an object of kinds, each with a "card", a "row" or a "page"')),i;for(let[s,u]of Object.entries(e)){if(s==="home"&&Array.isArray(u)){W(u,`${n}.home`,r,t,d,i,"the home");continue}let f=o(s);if(!f){i.push(l("view-kind",`${n}.${s}`,`"${s}" is not a kind this ${a} declares`));continue}if(!g(u)){i.push(l("view-shape",`${n}.${s}`,`a kind's views are {"card": [blocks], "row": [blocks], "page": [blocks]}`));continue}for(let c of Object.keys(u))O.includes(c)||i.push(l("view-slot",`${n}.${s}.${c}`,`"${c}" is not a place a view is drawn`,`use ${O.map(m=>`"${m}"`).join(", ")}`));for(let c of O){let m=u[c];if(m===void 0)continue;let y={kind:s,spec:f,kinds:t,edges:d,vocabulary:r,findings:i,count:0,all:0,slot:c};x(m,`${n}.${s}.${c}`,1,y),D(y,`${n}.${s}.${c}`,`this ${c}`,"show less, or move detail to the page")}}return i}function ge(e){let n=new Set(Object.keys(e.kinds)),o=new Set(Object.values(e.kinds).flatMap(r=>Object.keys(b(r.edges)))),t=r=>{let i=p(e.kinds,r)?e.kinds[r]:void 0;return i?{field:s=>p(i.fields,s)||p(i.computed,s)||A(i.edges).has(s),relation:s=>p(b(i.edges),s),figure:i.figure!==void 0,files:s=>p(i.fields,s)&&Z(i.fields[s]),choices:s=>p(i.fields,s)&&i.fields[s].type==="enum"?i.fields[s].options:void 0,targets:s=>p(b(i.edges),s)?i.edges[s].to:void 0,prose:s=>p(i.fields,s)&&i.fields[s].type==="text"}:void 0},d={namesOf:t,sources:r=>Object.keys(e.kinds).filter(i=>p(e.kinds[i].edges,r))},a=te(e.views,"views",t,n,o,"document",d);return oe(e.lenses,d,n,o,a),a}export{E as a,P as b,L as c,B as d,M as e,ue as f,U as g,fe as h,ce as i,ge as j};
@@ -1 +0,0 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk.6KMXLUOS.js";import"./chunk.G4JJXA63.js";import"./chunk.LA7535VO.js";import"./chunk.ZEW2OOZ5.js";import"./chunk.ACEYGWMO.js";import"./chunk.3PT55HXT.js";import"./chunk.Q5WEOX3Q.js";import"./chunk.CRPT3ZT3.js";import"./chunk.LNNFNJKN.js";import"./chunk.EBLKEQ7O.js";import"./chunk.WVUJXDXZ.js";import"./chunk.VHWUGSFW.js";import"./chunk.P75TPZWT.js";import"./chunk.6W7J76TK.js";import"./chunk.FUR4IHWG.js";import"./chunk.2B4WVCVV.js";import"./chunk.AAZFVCSP.js";import"./chunk.GZLYTPE7.js";import"./chunk.4B73P2WA.js";import"./chunk.IMRCAU4T.js";import"./chunk.F5BCCGFK.js";import"./chunk.AJZBJBMO.js";export{i as draftAnswer,h as draftFromLens,b as draftSight,l as draftView,a as isDraftFailure,c as judgeLens,d as lensEditOf,f as lensFromSpec,j as recipeDraft,g as recipeOfLens,m as refineDraft,o as runDraftTool,e as takeBackEditOf,k as templateDraft,n as withReaderLenses};
@@ -1 +0,0 @@
1
- import{a as c,b as d,c as e,d as f,e as g,f as h,g as i,h as j,i as k,j as l,k as m,l as n,m as o,n as p}from"./chunk.27TLAVRR.js";import{a,b}from"./chunk.OREMUXB5.js";import"./chunk.ZDNJK2SX.js";import"./chunk.ZSSOTIFL.js";import"./chunk.GZLYTPE7.js";import"./chunk.4B73P2WA.js";import"./chunk.IMRCAU4T.js";import"./chunk.BZ5VLPKB.js";import"./chunk.6II4BONS.js";import"./chunk.F5BCCGFK.js";import"./chunk.AJZBJBMO.js";export{j as ARRANGE_NARROW,o as ArrangeBar,e as CHIP_FIELDS,d as MANY_AT_THE_FAR_END,c as TYPED_FROM,p as arrangementCaption,a as arrangementOf,i as chipOffers,m as directionWords,g as farCount,f as farCounts,l as inSentence,h as offeredFilters,n as preloadArrangeLists,k as sayCondition,b as withArrangement};
@@ -1 +0,0 @@
1
- import{b as on,c as rn}from"./chunk.UT6642FC.js";import{e as N}from"./chunk.GZLYTPE7.js";import{c as B}from"./chunk.IMRCAU4T.js";import{$ as en,Hb as V,Kb as Q,Na as H,X as F,Y as K,Z as q,_ as nn,ca as tn,da as J,ea as T,wb as sn,xb as E}from"./chunk.F5BCCGFK.js";function an(){return{name:"insight",derive({store:n,nodes:r,kindSelection:t}){let l=[],v=f=>F(n.schema.tryDefinition(f.kind),f);for(let f of r){if([...n.schema.edgeKinds].reduce((c,S)=>c+n.graph.out(f.id,S).length+n.graph.in(f.id,S).length,0)===0){l.push({id:`insight:island:${f.id}`,text:`${v(f)} is connected to nothing yet`,nodeIds:[f.id]});continue}for(let c of n.schema.edgeKinds){let S=n.graph.in(f.id,c).length;if(S<3)continue;let s=[...n.graph.allEdges()].filter(a=>a.kind===c),e=s.length;e>=4&&S/e>.6&&l.push({id:`insight:load:${f.id}:${c}`,text:`${v(f)} ${mn(n,s,c,S)}`,nodeIds:[f.id]})}}for(let f of t){if(n.graph.nodesOfKind(f).length>0)continue;let A=n.schema.definitions.filter(c=>c.kind!==f).filter(c=>Object.values(c.edges).some(S=>S.to!=="*"&&S.to.includes(f))).map(c=>c.plural??`${c.kind}s`);A.length>0&&l.push({id:`insight:gap:${f}`,text:`Nothing here yet, though ${A.join(" and ")} expect to connect to these`,nodeIds:[]})}return{observations:l}}}}function mn(n,r,t,l){let v=new Set(r.map(s=>n.graph.getNode(s.from)?.kind).filter(s=>s!==void 0)),f=v.size===1?[...v][0]:void 0,A=r.length,c=B(n.schema,f??[...v][0]??"",t,"in"),S=s=>f?nn(n.schema,f,s):String(s);return l===A?`${c}: all ${S(l)}`:`${c}: ${l} of the ${S(A)}`}function dn(n){let r=new Map;if(n.length===0)return r;let t=n.slice(-512),l=new Set;for(let f of t)f.undoes&&l.add(f.undoes);let v=n[n.length-1].seq;for(let f of t){if(!f.mutation||l.has(f.id))continue;let A=Math.pow(.5,(v-f.seq)/64);r.set(f.mutation.name,(r.get(f.mutation.name)??0)+A)}return r}function cn(n){return 8*(n/(n+1))}var pn=100;function un(){return{name:"invariant",derive({store:n,selection:r,nodes:t,violations:l}){let v=s=>F(n.schema.tryDefinition(s.kind),s),f=new Set(r),A=l.filter(s=>s.nodeIds.some(e=>f.has(e))||s.subjectId!==void 0&&f.has(s.subjectId)),c=[],S=[];A.forEach((s,e)=>{S.push({id:`violation:${s.invariant}:${e}`,text:s.message,nodeIds:s.nodeIds}),s.repairs.forEach((a,h)=>{c.push({id:`invariant:${s.invariant}:${e}:${h}`,label:a.label,provider:"invariant",mutation:a.mutation,args:a.args??{},open:(a.missing??[]).map(k=>{let d=n.allMutations().find(p=>p.name===a.mutation);if(!d)return{name:k};let o=E(d.input).find(p=>p.name===k),m=o?o.kinds.includes("*")?n.graph.allNodes().map(p=>p.id):o.kinds.flatMap(p=>n.graph.nodesOfKind(p).map($=>$.id)):void 0;return{name:k,shape:N(d.input,k),...o?{kinds:o.kinds}:{},...m?{candidates:m}:{}}}),score:pn-h-(a.missing?.length??0),why:s.message,nodeIds:s.nodeIds,...s.subjectId===void 0?{}:{subjectId:s.subjectId}})})});for(let s of t){let e=n.allInvariants().filter(a=>{if(a.scope==="graph")return!1;let h=a.scope;return h.kind!==s.kind?!1:h.match?h.match(s):!0});e.length!==0&&(A.some(a=>a.subjectId===s.id||a.nodeIds.includes(s.id))||S.push({id:`holds:${s.id}`,text:`${v(s)} holds \u2014 nothing currently breaks ${e.length===1?"it":`any of its ${e.length} rules`}`,nodeIds:[s.id]}))}return{affordances:c,observations:S}}}}var U=40;function fn(){return{name:"schema",derive({store:n,selection:r,nodes:t,kindSelection:l,edgeSelection:v,principal:f}){let A=(e,a)=>f!==void 0&&!n.permits({name:e,args:a},f).ok,c=[];if(t.length===0&&v.length>0){for(let e of v){let a=n.graph.getNode(e.from),h=n.graph.getNode(e.to);if(!a||!h)continue;let k=rn(n,e);k?.provisional&&c.push({id:`schema:edge:${V}:${e.kind}:${e.from}:${e.to}`,label:"Keep this link",provider:"schema",mutation:V,args:{kind:e.kind,from:e.from,to:e.to},open:[],score:64,why:on(k),nodeIds:[e.from,e.to]});for(let d of n.allMutations()){let o=(d.connects??[]).includes(e.kind),m=(d.severs??[]).includes(e.kind);if(!o&&!m)continue;let p={},$=[],j=E(d.input);for(let g of j){let w=g.kinds.includes("*")||g.kinds.includes(a.kind),P=g.kinds.includes("*")||g.kinds.includes(h.kind),y=w&&!j.some(I=>I!==g&&(I.kinds.includes(a.kind)||I.kinds.includes("*")));w&&!P?p[g.name]=e.from:P&&!w?p[g.name]=e.to:w&&P&&y?p[g.name]=e.from:$.push({name:g.name,kinds:g.kinds,candidates:[e.from,e.to],shape:N(d.input,g.name)})}for(let g of G(d.input,""))g in p||$.some(w=>w.name===g)||$.push({name:g,shape:N(d.input,g)});$.every(g=>g.optional===!0?!0:g.kinds!==void 0?(g.candidates?.length??0)>0:(g.candidates?.length??0)>0||g.shape!==void 0&&g.shape.type!=="unknown")&&(o&&!m&&$.length===0||c.push({id:`schema:edge:${d.name}:${e.kind}:${e.from}:${e.to}`,label:K(d),provider:"schema",mutation:d.name,args:p,open:$,...d.destructive?{destructive:!0}:{},score:(m?62:58)-$.length,why:`this line is "${B(n.schema,n.graph.getNode(e.from)?.kind??"",e.kind,"out")}"`,nodeIds:[e.from,e.to]}))}}return{affordances:c}}if(t.length===0&&l.length>0){let e=new Set(l),a=[];for(let h of n.allMutations()){if(!(h.creates??[]).some(o=>e.has(o)))continue;let k=[];for(let o of E(h.input)){let m=o.kinds.includes("*")?n.graph.allNodes().map(p=>p.id):o.kinds.flatMap(p=>n.graph.nodesOfKind(p).map($=>$.id));k.push({name:o.name,kinds:o.kinds,candidates:m,shape:N(h.input,o.name),...o.optional?{optional:!0}:{}})}for(let o of G(h.input,""))k.some(m=>m.name===o)||k.push({name:o,shape:N(h.input,o)});if(!k.every(o=>o.optional===!0?!0:o.kinds!==void 0?(o.candidates?.length??0)>0:(o.candidates?.length??0)>0||o.shape!==void 0&&o.shape.type!=="unknown")&&!A(h.name,{})){let o=k.filter(m=>m.optional!==!0&&m.kinds!==void 0&&!m.kinds.includes("*")&&(m.candidates?.length??0)===0);if(o.length>0){let m=[...new Set(o.flatMap(p=>p.kinds??[]))].map(p=>J(T(n.schema.tryDefinition(p),p)));a.push({id:`schema:waits:${h.name}`,text:`"${h.title??h.name}" cannot begin until there is ${m.length===1?m[0]:`${m.slice(0,-1).join(", ")} and ${m[m.length-1]}`}.`,nodeIds:[]})}continue}c.push({id:`schema:add:${h.name}`,label:K(h),provider:"schema",mutation:h.name,args:{},open:k,score:U-k.length,why:`this makes ${(h.creates??[]).filter(o=>e.has(o)).map(o=>J(T(n.schema.tryDefinition(o),o))).join(", ")}`,nodeIds:[]})}return{affordances:c,observations:a}}if(t.length===0)return{};let S=new Set(t.map(e=>e.kind)),s=(e,a,h)=>{let k=[];for(let d of n.graph.allEdges()){if(!a.includes(d.kind))continue;let o=d.from===e?d.to:d.to===e?d.from:null;if(!o)continue;let m=n.graph.getNode(o);m&&(!h.includes("*")&&!h.includes(m.kind)||k.includes(o)||k.push(o))}return k};for(let e of n.allMutations()){let a=e.subject;if(!a||!(a.kinds==="*"?!0:[...S].every(u=>a.kinds.includes(u))))continue;let k=e.derived?.act;if((k==="archive"||k==="merge")&&t.some(u=>H(u))||k==="unarchive"&&!t.some(u=>H(u))||k==="leave-alone"&&t.every(u=>Q(n,u.id))||k==="allow-tidying"&&!t.some(u=>Q(n,u.id)))continue;let d=t.length===1?t[0].id:null,o=e.severs??[],m=e.connects??[];if(d&&o.length>0&&m.length===0&&s(d,o,["*"]).length===0)continue;let p=[];for(let u of E(e.input)){if(u.name===a.arg)continue;let g=u.kinds.includes("*")?n.graph.allNodes().map(w=>w.id):u.kinds.flatMap(w=>n.graph.nodesOfKind(w).map(P=>P.id));if(d&&m.length>0){let w=new Set(s(d,m,u.kinds));g=g.filter(P=>!w.has(P))}else d&&o.length>0&&(g=s(d,o,u.kinds));p.push({name:u.name,kinds:u.kinds,candidates:g.filter(w=>!r.includes(w)),shape:N(e.input,u.name),...u.optional?{optional:!0}:{}})}for(let u of G(e.input,a.arg))p.some(g=>g.name===u)||p.push({name:u,shape:N(e.input,u)});if(p.length===0&&d){let u=kn(e.input,a.arg);if(u.length>0&&!yn(n,e.name,{[a.arg]:d}))for(let g of u){let w=E(e.input).find(P=>P.name===g);p.push({name:g,optional:!0,...w?{kinds:w.kinds}:{},shape:N(e.input,g)})}}if(!p.every(u=>u.optional===!0?!0:u.kinds!==void 0?(u.candidates?.length??0)>0:(u.candidates?.length??0)>0||u.shape!==void 0&&u.shape.type!=="unknown")&&!A(e.name,d?{[a.arg]:d}:{}))continue;let j=t.map(u=>({[a.arg]:u.id}));p.length===0&&!j.some(u=>n.wouldChange({name:e.name,args:u}))||c.push({id:`schema:${e.name}`,label:t.length>1?`${K(e)} (${t.length})`:K(e),provider:"schema",mutation:e.name,args:j[0]??{},open:p,...e.destructive?{destructive:!0}:{},...e.derived?.act==="archive"||e.derived?.act==="merge"||e.derived?.act==="leave-alone"||e.derived?.act==="allow-tidying"?{setsAside:!0}:{},...o.length>0||m.length>0?{ties:!0}:{},...t.length>1?{batch:j}:{},score:U-p.length,why:t.length>1?`all ${t.length} selected nodes are ${[...S].map(u=>en(n.schema,u).toLowerCase()).join(" or ")}`:`this is ${J(T(n.schema.tryDefinition(t[0].kind),t[0].kind))}`,nodeIds:t.map(u=>u.id)})}if(t.length===1){let e=t[0];for(let a of n.allMutations()){let h=a.subject,k=a.severs??[],d=a.connects??[];if(!h||k.length===0&&d.length===0)continue;let o=h.kinds==="*"?"*":h.kinds;if(o==="*"||o.includes(e.kind))continue;let m=E(a.input),p=m.find(y=>y.name!==h.arg&&(y.kinds.includes("*")||y.kinds.includes(e.kind)));if(!p)continue;let $=o,j=$.includes("*")?n.graph.allNodes().map(y=>y.id):$.flatMap(y=>n.graph.nodesOfKind(y).map(I=>I.id)),u=new Set(s(e.id,d.length>0?d:k,$)),g=d.length>0?j.filter(y=>!u.has(y)):j.filter(y=>u.has(y));if(g.length===0)continue;let w=[{name:h.arg,kinds:$,candidates:g,shape:N(a.input,h.arg)}];for(let y of m){if(y.name===p.name||y.name===h.arg)continue;let I=y.kinds.includes("*")?n.graph.allNodes().map(D=>D.id):y.kinds.flatMap(D=>n.graph.nodesOfKind(D).map(O=>O.id));w.push({name:y.name,kinds:y.kinds,candidates:I,shape:N(a.input,y.name),...y.optional?{optional:!0}:{}})}for(let y of G(a.input,p.name))y===h.arg||w.some(I=>I.name===y)||w.push({name:y,shape:N(a.input,y)});w.every(y=>y.optional===!0?!0:y.kinds!==void 0?(y.candidates?.length??0)>0:(y.candidates?.length??0)>0||y.shape!==void 0&&y.shape.type!=="unknown")&&c.push({id:`schema:tie:${a.name}:${e.id}`,label:a.fromTheOtherEnd??K(a),provider:"schema",mutation:a.name,args:{[p.name]:e.id},open:w,ties:!0,...a.destructive?{destructive:!0}:{},score:U-w.length+2,why:`${k.length>0?"this one is on":"this one could join"} ${w[0].candidates.length===1?"it":"one of these"}`,nodeIds:[e.id]})}}return{affordances:c}}}}function kn(n,r){let t=n.shape;return t?Object.entries(t).filter(([l,v])=>l!==r&&v.safeParse(void 0).success).map(([l])=>l):[]}function yn(n,r,t){try{return n.preview({name:r,args:t}),!0}catch{return!1}}function G(n,r){let t=n.shape;return t?Object.entries(t).filter(([l,v])=>l!==r&&!v.safeParse(void 0).success).map(([l])=>l):[]}var vn=70,bn=80,Sn=new Set(["id","kind"]);function ln(){return{name:"structure",derive({store:n,nodes:r}){let t=c=>F(n.schema.tryDefinition(c.kind),c);if(r.length<2)return{};let l=[],v=[],f=r.map(c=>c.id);for(let c of n.schema.edgeKinds){let S=wn(r.map(e=>new Set([...n.graph.out(e.id,c).map(a=>a.id),...n.graph.in(e.id,c).map(a=>a.id)])));for(let e of S){let a=n.graph.getNode(e);a&&l.push({id:`shared:${c}:${e}`,text:`all ${r.length} share "${t(a)}" (${q(c).toLowerCase()})`,nodeIds:[...f,e]})}let s=new Map;for(let e of r)for(let a of[...n.graph.out(e.id,c),...n.graph.in(e.id,c)])s.set(a.id,(s.get(a.id)??0)+1);for(let[e,a]of s){if(a!==r.length-1||r.length<3||f.includes(e))continue;let h=n.graph.getNode(e);if(!h)continue;let k=r.find(d=>![...n.graph.out(d.id,c),...n.graph.in(d.id,c)].some(o=>o.id===e));if(k){l.push({id:`near-shared:${c}:${e}`,text:`all but "${t(k)}" share "${t(h)}" (${q(c).toLowerCase()})`,nodeIds:[...f,e]});for(let d of n.allMutations()){let o=d.subject;if(!o||o.kinds!=="*"&&!o.kinds.includes(k.kind))continue;let m=An(d.input,h.kind);m&&v.push({id:`structure:join:${d.name}:${k.id}:${e}`,label:`${K(d)}: bring "${t(k)}" in line with the others`,provider:"structure",mutation:d.name,args:{[o.arg]:k.id,[m]:e},open:[],score:vn,why:`every other selected node is connected to "${t(h)}"`,nodeIds:[k.id,e]})}}}}let A=new Map;for(let c of r)A.set(c.kind,[...A.get(c.kind)??[],c]);for(let[c,S]of A){if(S.length<2)continue;let s=S,e=S.map(d=>d.id),a=A.size>1?`${c}:`:"",h=new Set;for(let d of s)for(let o of Object.keys(d))Sn.has(o)||h.add(o);let k=d=>n.schema.definitions.find(o=>o.kind===d);for(let d of[...h].sort()){let o=k(s[0].kind),m=tn(o,d).toLowerCase(),p=o?.display?.format?.[d],$=O=>{if(!p)return O;try{return String(p(JSON.parse(O)))}catch{return O}},j=s.map(O=>O[d]),u=new Map;if(j.forEach((O,R)=>{let L=JSON.stringify(O??null),x=u.get(L);x?x.push(s[R]):u.set(L,[s[R]])}),u.size===1){let O=[...u.keys()][0];if(O==="null")continue;l.push({id:`agree:${a}${d}`,text:`all ${s.length} share the ${m} ${$(O)}`,nodeIds:e});continue}if(s.length<3||u.size!==2)continue;let g=[...u.entries()].sort((O,R)=>R[1].length-O[1].length),[w,P]=g[0],[,y]=g[1];if(y.length!==1||w==="null")continue;let I=y[0],D=JSON.parse(w);l.push({id:`odd-one-out:${a}${d}`,text:`${P.length} share the ${m} ${$(w)}; "${t(I)}" does not`,nodeIds:e});for(let O of n.allMutations()){let R=O.subject;if(!R||R.kinds!=="*"&&!R.kinds.includes(I.kind))continue;let L=hn(O.input);if(!L||!(d in L))continue;let x={[R.arg]:I.id,[d]:D},_=!0;for(let[C,Z]of Object.entries(L)){if(C in x||Z.safeParse(void 0).success)continue;let i=I[C];if(i===void 0){_=!1;break}x[C]=i}!_||!O.input.safeParse(x).success||v.push({id:`structure:align:${O.name}:${d}:${I.id}`,label:`Align the ${m} of "${t(I)}" with the other ${P.length}`,provider:"structure",mutation:O.name,args:x,open:[],score:bn,why:`${P.length} of ${s.length} share the ${m} ${$(w)}`,nodeIds:e})}}}return{affordances:v,observations:l}}}}function wn(n){if(n.length===0)return[];let[r,...t]=n;return[...r].filter(l=>t.every(v=>v.has(l))).sort()}function hn(n){return n.shape??null}function An(n,r){let t=hn(n);if(!t)return null;for(let[l]of Object.entries(t)){let v=sn(t[l]);if(v&&(v.includes("*")||v.includes(r)))return l}return null}function $n(){return[un(),ln(),fn(),an()]}function Hn(n,r,t={}){let l=gn(),v=t.providers??$n(),f=r.map(i=>n.graph.getNode(i)).filter(i=>i!==void 0),A={store:n,selection:r,nodes:f,kindSelection:t.kindSelection??[],edgeSelection:t.edgeSelection??[],violations:n.violations(t.context),context:t.context??{},principal:t.principal??{kind:"human"}},c=[],S=[];for(let i of v){let b=i.derive(A);c.push(...b.affordances??[]),S.push(...b.observations??[])}let s=new Set(n.allMutations().filter(i=>i.pinned).map(i=>i.name)),e=new Set(t.pins?.pinned??[]),a=new Set(t.pins?.unpinned??[]),h=i=>e.has(i.mutation)?"user":s.has(i.mutation)&&!a.has(i.mutation)?"declared":void 0,k=i=>{let b=h(i);return b?{...i,pinned:b}:i},d=new Map;for(let[i,b]of dn(n.log.all()))d.set(i,cn(b));let o=i=>i.pinned==="user"?0:i.pinned==="declared"?1:2,m=i=>i.score+(d.get(i.mutation)??0),p=new Map(n.allMutations().map(i=>[i.name,i])),$=new Map,j=i=>{let b=p.get(i.mutation);if(!b)return[];let M=$.get(i.mutation);M||(M=E(b.input).map(W=>W.name),$.set(i.mutation,M));let z=[];for(let W of i.batch??[i.args])for(let X of M){let Y=W[X]??i.args[X];typeof Y=="string"&&z.push(Y)}return z},u=t.focus,g=4,w=i=>i.open.length>0?1:0,P=i=>{if(u===void 0)return g;let b=j(i);return b.length>0?b.includes(u)?y(i,0):g:i.nodeIds.includes(u)||i.subjectId===u?y(i,1):g},y=(i,b)=>i.provider==="invariant"?b:2+w(i),I=i=>i.setsAside?1:0,D=On(c).map(k),O=new Map(D.map((i,b)=>[i,b])),R=D.sort((i,b)=>{let M=Number(i.destructive??!1)-Number(b.destructive??!1);if(M!==0)return M;let z=I(i)-I(b);if(z!==0)return z;let W=P(i)-P(b);return W!==0?W:P(i)<2?O.get(i)-O.get(b):+(b.provider==="invariant")-+(i.provider==="invariant")||o(i)-o(b)||m(b)-m(i)||i.id.localeCompare(b.id)}),L=t.principal??{kind:"human"},x=[],_=[];for(let i of R){let b=n.permits({name:i.mutation,args:{...i.args,...i.batch?.[0]??{}}},L);if(b.ok)x.push(i);else{let M=Pn(n,i,L);if(M==="done")continue;M?x.push(M):_.push({...i,refusal:b.refusal})}}let C=x.map((i,b)=>({...i,rank:b})),Z=_.map((i,b)=>({...i,rank:x.length+b}));return{affordances:t.limit===void 0?C:C.slice(0,t.limit),withheld:Z,observations:In(S),ms:gn()-l}}function On(n){let r=new Map;for(let t of n){let l=[t.mutation,JSON.stringify(t.args),JSON.stringify(t.batch??null)].join("|"),v=r.get(l);(!v||t.score>v.score)&&r.set(l,t)}return[...r.values()]}function In(n){let r=new Map;for(let t of n)r.set(t.text,t);return[...r.values()]}function gn(){return typeof performance<"u"?performance.now():Date.now()}function Vn(n,r,t={},l={}){let v=(r.batch??[r.args]).map(A=>({name:r.mutation,args:{...r.args,...A,...t}})),f=n.allMutations().find(A=>A.name===r.mutation);return n.applyAll(v,{...f?.describe?{}:{intent:r.label},...l.author?{author:l.author}:{}})}function Qn(n,r,t={}){return n.preview({name:r.mutation,args:{...r.args,...t}})}function Pn(n,r,t){let l=n.allMutations().find(s=>s.name===r.mutation)?.subject,v=l!==void 0&&r.args[l.arg]===void 0,f=v?r.open.find(s=>s.name===l.arg):r.open.find(s=>s.name!==l?.arg&&s.candidates);if(!f?.candidates)return;let A=s=>n.permits({name:r.mutation,args:{...r.args,...r.batch?.[0]??{},[f.name]:s}},t).ok,c=f.candidates.filter(A),S=t.id===void 0?void 0:n.graph.getNode(t.id);if(c.length===0){let s=v?l.kinds:"*";return S!==void 0&&(s==="*"||s.includes(S.kind))&&A(S.id)?"done":void 0}return c.length===1&&c[0]===t.id?{...r,args:{...r.args,[f.name]:t.id},open:r.open.filter(s=>s!==f)}:{...r,open:r.open.map(s=>s===f?{...s,candidates:c}:s)}}export{Hn as a,Vn as b,Qn as c};
@@ -1,2 +0,0 @@
1
- import{Aa as J,E as q,F as Z,H as T,K as _,L as H,La as Q,N as C,Na as X,T as Y,U as j,da as U,sa as B,sb as K,zb as v}from"./chunk.F5BCCGFK.js";var dn=1e4,c=class{constructor(s){this.nodes=s}},en=Symbol.for("@graview/core:far-record"),ln=e=>typeof e=="object"&&e!==null&&e[en]===!0;function un(e){let s={...e.fields,id:`@${e.address}/${e.kind}:${e.id}`,kind:`@${e.address}/${e.kind}`,label:e.label};return Object.defineProperty(s,en,{value:!0}),s}function kn(e){let s=`the linked record in ${e.ref.address}`;return e.reason==="denied"?`${s} is not one this viewer may open`:`${s} has not been read`}var fn="",u=class extends Error{constructor(p,l){super(p);this.sentence=p;this.at=l}},P=class extends u{},R=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof c)&&typeof e.id=="string",nn=e=>{let s=new Set;return new c(e.filter(p=>!s.has(p.id)&&s.add(p.id)))},w=e=>e===null?"nothing":e instanceof c?"a set of records":Array.isArray(e)?"a list":R(e)?"a record":typeof e=="string"?"a word":typeof e;function rn(e,s){let p=s.budget??dn,l=(n,a)=>{if(p-=n,p<0)throw new P("this rule looks at too much of the graph to judge in one go",a)},h=s.today??T(),b=s.now??new Date().toISOString(),A=new Map,k=new Set,V=s.bindings,z=(n,a,r,o)=>{let d=`${n?.id}\0${a}`;if(A.has(d))return A.get(d);if(k.has(d))throw new u(`"${a}"${n?` of ${U(n.kind)}`:""} depends on itself`,o);k.add(d);let t=V;V=void 0;try{let i=$(r,n);return A.set(d,i),i}finally{V=t,k.delete(d)}},E=(n,a,r)=>{l(1,r);let o=s.kinds.get(n.kind),d=o?.computed?.get(a);if(d)return z(n,a,d,r);let t=o?.linked?.get(a);if(t){let y=B(Object.hasOwn(n,a)?n[a]:void 0,t);l(y.length,r);let m=s.linked??J(s.graph),g=y.flatMap(x=>{let D=m?m(x):{unread:!0};return"record"in D?[un(D.record)]:(s.onUnread?.({relation:a,ref:x,reason:"denied"in D?"denied":"unread"}),[])});return t.cardinality==="one"?g[0]??null:new c(g)}let i=Object.hasOwn(n,a);if(o?.fields.has(a)||i){let y=i?Q(n,a,h):void 0;return y===void 0?null:y}let f=o?.edges.get(a);if(f){let y=s.graph.out(n.id,a);return l(y.length,r),f==="one"?y[0]??null:new c(y)}if(a==="id")return n.id;if(ln(n))return null;throw new u(`${U(n.kind)} has no field or relation called "${a}"`,r)},N=(n,a,r)=>{if(n instanceof c)return n;if(n===null)return new c([]);if(R(n))return new c([n]);throw new u(`${r}(\u2026) needs a set of records, and was given ${w(n)}`,a)},G=(n,a,r)=>{if(n===null)return null;if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);throw new u(`${r}(\u2026) needs a word, and was given ${w(n)}`,a)},L=(n,a,r)=>{let o=G(n,a,r);if(o===null)return null;let d=Date.parse(o.length===10?`${o}T00:00:00Z`:o);if(Number.isNaN(d))throw new u(`${r}(\u2026) needs a date, and "${o}" is not one`,a);return d},M=(n,a)=>R(n)&&R(a)?n.id===a.id:R(n)&&typeof a=="string"?n.id===a:typeof n=="string"&&R(a)?n===a.id:Array.isArray(n)&&Array.isArray(a)?n.length===a.length&&n.every((r,o)=>M(r,a[o])):n===a,S=(n,a,r)=>{if(n===null)return!1;if(typeof n=="boolean")return n;throw new u(`${r} must be true or false, and was ${w(n)}`,a)},O=(n,a)=>$(a,n);function $(n,a){switch(l(1,n.at),n.t){case"lit":return n.value;case"list":return n.items.map(r=>$(r,a));case"ident":{let r=V&&Object.hasOwn(V,n.name)?V[n.name]:void 0;if(r!==void 0)return r;if(a)return E(a,n.name,n.at);throw new u(`"${n.name}" means nothing in a rule over the whole graph`,n.at)}case"member":{let r=$(n.object,a);if(r===null)return null;if(R(r))return E(r,n.name,n.at);throw new u(`".${n.name}" needs a record before it, and was given ${w(r)}`,n.at)}case"unary":{let r=$(n.operand,a);if(n.op==="!")return!S(r,n.at,"what follows not");if(r===null)return null;if(typeof r!="number")throw new u(`"-" needs a number, and was given ${w(r)}`,n.at);return-r}case"where":{let r=N($(n.set,a),n.at,"where");return l(r.nodes.length,n.at),new c(r.nodes.filter(o=>S(O(o,n.filter),n.at,"a where condition")))}case"binary":return an(n,a);case"call":return sn(n,a)}}function an(n,a){if(n.op==="&&")return S($(n.left,a),n.at,"each side of and")&&S($(n.right,a),n.at,"each side of and");if(n.op==="||")return S($(n.left,a),n.at,"each side of or")||S($(n.right,a),n.at,"each side of or");let r=$(n.left,a),o=$(n.right,a);if(n.op==="&"||n.op==="|"||n.op==="-"&&(r instanceof c||o instanceof c)){let d=N(r,n.at,n.op).nodes,t=N(o,n.at,n.op).nodes;l(d.length+t.length,n.at);let i=new Set(t.map(f=>f.id));return nn(n.op==="|"?[...d,...t]:d.filter(f=>i.has(f.id)===(n.op==="&")))}switch(n.op){case"==":return M(r,o);case"!=":return!M(r,o);case"in":{if(o===null)return!1;if(o instanceof c)return o.nodes.some(d=>M(r,d));if(Array.isArray(o))return o.some(d=>M(r,d));if(typeof o=="string"&&typeof r=="string")return o.includes(r);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(r===null||o===null)return!1;if(!(typeof r=="number"&&typeof o=="number"||typeof r=="string"&&typeof o=="string"))throw new u(`cannot compare ${w(r)} with ${w(o)}`,n.at);return n.op==="<"?r<o:n.op==="<="?r<=o:n.op===">"?r>o:r>=o}default:{if(r===null||o===null)return null;if(n.op==="+"&&(typeof r=="string"||typeof o=="string")){let d=`${G(r,n.at,"+")}${G(o,n.at,"+")}`;if(d.length>1e4)throw new u("that makes a word too long",n.at);return d}if(typeof r!="number"||typeof o!="number")throw new u(`"${n.op}" needs numbers, and was given ${w(r)} and ${w(o)}`,n.at);return(n.op==="/"||n.op==="%")&&o===0?null:n.op==="+"?r+o:n.op==="-"?r-o:n.op==="*"?r*o:n.op==="/"?r/o:r%o}}}function sn(n,a){let r=(t,i=t)=>{if(n.args.length<t||n.args.length>i)throw new u(`${n.fn}(\u2026) takes ${t===i?t:`${t} to ${i}`} argument${i===1?"":"s"}`,n.at)},o=t=>$(n.args[t],a),d=t=>{let i=o(t);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":{r(1,2);let t=(y,m)=>n.fn==="out"?s.graph.out(y,m):s.graph.in(y,m);if(n.args.length===2){let y=N(o(0),n.at,n.fn).nodes,m=d(1);return nn(y.flatMap(g=>{let x=t(g.id,m);return l(x.length+1,n.at),x}))}let i=d(0);if(!a)throw new u(`${n.fn}('${i}') needs a record to start from`,n.at);let f=t(a.id,i);return l(f.length,n.at),new c(f)}case"all":{r(1,2);let t=s.graph.nodesOfKind(d(0),{archived:n.args.length===2?o(1):!1});return l(t.length,n.at),new c(t)}case"archived":return r(0,1),X(n.args.length===1?o(0):a);case"count":return r(1),N(o(0),n.at,"count").nodes.length;case"exists":return r(1),N(o(0),n.at,"exists").nodes.length>0;case"every":case"some":{r(2);let t=N(o(0),n.at,n.fn);l(t.nodes.length,n.at);let i=f=>S(O(f,n.args[1]),n.at,`the condition in ${n.fn}(\u2026)`);return n.fn==="every"?t.nodes.every(i):t.nodes.some(i)}case"sum":case"min":case"max":{r(2);let t=N(o(0),n.at,n.fn);l(t.nodes.length,n.at);let i=n.args[1],f=i.t==="lit"&&typeof i.value=="string"?i.value:void 0,y=i.t==="ident"?`'${i.name}'`:f!==void 0?`'${f}'`:"\u2026",m=t.nodes.map(g=>i.t==="ident"?E(g,i.name,n.at):f!==void 0?E(g,f,n.at):O(g,i)).filter(g=>{if(g===null)return!1;if(typeof g!="number")throw new u(`${n.fn}(\u2026, ${y}) needs a number for each member, and found ${w(g)}`,n.at);return!0});return n.fn==="sum"?m.reduce((g,x)=>g+x,0):m.length===0?null:n.fn==="min"?Math.min(...m):Math.max(...m)}case"fact":{r(1);let t=d(0),i=s.kinds.get(fn)?.computed?.get(t);if(!i)throw new u(`no fact is called "${t}"`,n.at);return z(null,t,i,n.at)}case"first":return r(1),N(o(0),n.at,"first").nodes[0]??null;case"sort":{r(2,3);let t=N(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 f=t.nodes.length;l(f+f*Math.ceil(Math.log2(f+1)),n.at);let y=t.nodes.map((g,x)=>({node:g,i:x,key:O(g,n.args[1])})),m=i==="desc"?-1:1;return y.sort((g,x)=>W(g.key,x.key,m,n.at)||g.i-x.i),new c(y.map(g=>g.node))}case"either":{if(n.args.length<1)throw new u("either(\u2026) takes at least one argument",n.at);for(let t=0;t<n.args.length;t++){let i=o(t);if(i!==null&&!(i instanceof c&&i.nodes.length===0))return i}return null}case"present":{r(1);let t=o(0);return t===null||t===""?!1:Array.isArray(t)?t.length>0:t instanceof c?t.nodes.length>0:!0}case"len":{r(1);let t=o(0);if(t===null)return 0;if(typeof t=="string"||Array.isArray(t))return t.length;if(t instanceof c)return t.nodes.length;throw new u(`len(\u2026) needs a word or a list, and was given ${w(t)}`,n.at)}case"contains":case"startsWith":{r(2);let t=o(0),i=o(1);if(t===null||i===null)return!1;if(n.fn==="contains"&&Array.isArray(t))return t.some(m=>M(m,i));let f=G(t,n.at,n.fn),y=G(i,n.at,n.fn);return n.fn==="contains"?f.toLowerCase().includes(y.toLowerCase()):f.startsWith(y)}case"lower":{r(1);let t=G(o(0),n.at,"lower");return t===null?null:t.toLowerCase()}case"today":return r(0),h;case"now":return r(0),b;case"date":{r(1);let t=L(o(0),n.at,"date");return t===null?null:new Date(t).toISOString().slice(0,10)}case"days":case"hours":{r(2);let t=L(o(0),n.at,n.fn),i=L(o(1),n.at,n.fn);if(t===null||i===null)return null;let f=(i-t)/(n.fn==="days"?864e5:36e5);return n.fn==="days"?Math.round(f):f}case"if":return r(3),S(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 W(n,a,r,o){if(n===null||a===null)return n===a?0:n===null?1:-1;if(Array.isArray(n)&&Array.isArray(a)){for(let t=0;t<Math.max(n.length,a.length);t++){let i=W(n[t]??null,a[t]??null,r,o);if(i!==0)return i}return 0}let d=t=>typeof t=="number"||typeof t=="string"||typeof t=="boolean"?typeof t:w(t);if(d(n)!==d(a)||typeof n=="object"||typeof a=="object")throw new u(`sort(\u2026) cannot put ${w(n)} and ${w(a)} in order`,o);return typeof n=="string"?r*(n<a?-1:n>a?1:0):r*(Number(n)-Number(a))}return $(e,s.subject)}var xn=["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"];var Sn=(e,s,p,l)=>({severity:"error",code:e,path:s,message:p,...l?{fix:l}:{}}),Rn=(e,s,p,l)=>({severity:"warning",code:e,path:s,message:p,...l?{fix:l}:{}}),Vn=e=>e.some(s=>s.severity==="error");function Gn(e){return e.map(s=>`${s.severity==="error"?"\u2717":s.severity==="warning"?"!":"\xB7"} ${s.path||"(document)"}: ${s.message}${s.fix?` \u2014 ${s.fix}`:""}`).join(`
2
- `)}var Dn=["money","percent","date","relative","upper","lower","count","words","and","plural","excerpt"],cn={getNode:()=>{},allNodes:()=>[],allEdges:()=>[],nodesOfKind:()=>[],edgesOfKind:()=>[],out:()=>[],in:()=>[],neighbors:()=>[],has:()=>!1};function _n(e,s,p,l=[],h,b=F){return I(e,s,p,l,h,b)}var pn=(e,s)=>e.capital?Y(s):s;function yn(e){return e?s=>{let p=e.tryDefinition(s.kind)?.label;return p?p(s):F(s)}:F}var tn=["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],on=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];function gn(e,s){return!Number.isInteger(e)||e<0||e>99?C(e,s):e<20?tn[e]:e%10===0?on[e/10]:`${on[Math.floor(e/10)]}-${tn[e%10]}`}function hn(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 F=e=>String(e.name??e.title??e.label??e.id);function I(e,s,p,l=[],h,b=F){if(s==="plural"){let A=e instanceof c?e.nodes.length:Array.isArray(e)?e.length:typeof e=="number"?e:null;return A===null||l[0]===void 0?"\u2014":A===1?l[0]:l[1]??hn(l[0])}if(e===null)return"\u2014";if(e instanceof c)return s==="count"?String(e.nodes.length):s==="and"?j(e.nodes.map(b)):e.nodes.map(b).join(", ");if(Array.isArray(e)){if(s==="count")return String(e.length);let A=e.map(k=>I(k,void 0,p,[],h,b));return s==="and"?j(A):A.join(", ")}if(typeof e=="object")return b(e);switch(s){case"words":return typeof e=="number"?gn(e,h?.locale):String(e);case"money":return typeof e=="number"?K(e,h):String(e);case"percent":return typeof e=="number"?C(e,h?.locale,{style:"percent",maximumFractionDigits:0}):String(e);case"upper":return String(e).toUpperCase();case"lower":return String(e).toLowerCase();case"excerpt":return v(String(e),Number(l[0])||void 0);case"date":return _(String(e).slice(0,10),h?.locale);case"relative":{let A=Date.parse(String(e).length===10?`${e}T00:00:00Z`:String(e));if(Number.isNaN(A))return String(e);let k=Math.round((A-Date.parse(`${p}T00:00:00Z`))/864e5);return k===0?"today":k===1?"tomorrow":k===-1?"yesterday":k>0?`in ${k} days`:`${-k} days ago`}default:return typeof e=="string"&&q.test(e)?_(e,h?.locale):typeof e=="string"&&Z.test(e)?H(e,h?.locale):String(e)}}function Cn(e,s){let p=s.today??T(),l=s.name??yn(s.graph?.schema);return e.map(h=>{if(h.text!==void 0)return h.text;try{let b=rn(h.expr,{graph:s.graph??cn,subject:s.node,kinds:s.kinds,today:p,budget:s.budget??500,...s.bindings?{bindings:s.bindings}:{}});return pn(h,I(b,h.format,p,h.formatArgs,s.money,l))}catch(b){if(b instanceof u)return"\u2014";throw b}}).join("")}export{c as a,kn as b,fn as c,u as d,P as e,rn as f,xn as g,Sn as h,Rn as i,Vn as j,Gn as k,Dn as l,cn as m,_n as n,pn as o,yn as p,Cn as q};
@@ -1 +0,0 @@
1
- import{a as f}from"./chunk.3PT55HXT.js";import{X as d}from"./chunk.F5BCCGFK.js";function w(n){let o=n.indexOf("{"),r=n.indexOf("["),t=r!==-1&&(o===-1||r<o)?r:o;if(t===-1)return;let e=n[t],a=e==="["?"]":"}",i=0,c=!1,l=!1;for(let s=t;s<n.length;s++){let u=n[s];if(c){l?l=!1:u==="\\"?l=!0:u==='"'&&(c=!1);continue}if(u==='"')c=!0;else if(u===e)i+=1;else if(u===a&&(i-=1,i===0))try{return JSON.parse(n.slice(t,s+1))}catch{return}}}function v(n,o){let r;try{r=n.mutation(o.mutation)}catch{return o}let t={...o.args},e=!1;for(let a of f(r.input)){if(a.control!=="node")continue;let i=t[a.name];if(typeof i!="string"||i.length===0||n.graph.getNode(i))continue;let c=i.trim().toLowerCase(),l=[...n.graph.allNodes()].filter(s=>(a.kinds.includes("*")||a.kinds.includes(s.kind))&&d(n.schema.tryDefinition(s.kind),s).trim().toLowerCase()===c);l.length===1&&(t[a.name]=l[0].id,e=!0)}return e?{...o,args:t}:o}function P(n,o,r){let t=r===void 0?null:new Set(r),e=[];for(let a of o){if(typeof a.mutation!="string")continue;let i=!0;try{n.mutation(a.mutation)}catch{i=!1}i?t&&!t.has(a.mutation)&&e.push({proposal:a,why:"not-allowed"}):e.push({proposal:a,why:"unknown"})}return e}function x(n,o,r){let t=r===void 0?null:new Set(r);return o.filter(e=>{if(typeof e.mutation!="string"||t&&!t.has(e.mutation))return!1;try{n.mutation(e.mutation)}catch{return!1}return e.args!==null&&typeof e.args=="object"})}export{w as a,v as b,P as c,x as d};
@@ -1 +0,0 @@
1
- import{f as a,g as b,h as c,i as d,j as e,k as f,l as g,m as h,n as i}from"./chunk.ER5ILWKY.js";import"./chunk.7YQYWOZR.js";import"./chunk.ACEYGWMO.js";import"./chunk.3PT55HXT.js";import"./chunk.D6RDTUX3.js";import"./chunk.UT6642FC.js";import"./chunk.TI4OSTQV.js";import"./chunk.P75TPZWT.js";import"./chunk.GZLYTPE7.js";import"./chunk.4B73P2WA.js";import"./chunk.IMRCAU4T.js";import"./chunk.BZ5VLPKB.js";import"./chunk.6II4BONS.js";import"./chunk.F5BCCGFK.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{j as a,k as o}from"./chunk.4STIUIT6.js";import"./chunk.WHTQHU3M.js";import"./chunk.KU6NIMQX.js";import"./chunk.Y3IJDWNS.js";import"./chunk.OFJH7LDC.js";import"./chunk.5PU3RWYY.js";import"./chunk.OREMUXB5.js";import"./chunk.ZDNJK2SX.js";import"./chunk.ZSSOTIFL.js";import"./chunk.CUCNT7MG.js";import"./chunk.2A2DLMT3.js";import"./chunk.E77K6KBX.js";import"./chunk.WVUJXDXZ.js";import"./chunk.VHWUGSFW.js";import"./chunk.P75TPZWT.js";import"./chunk.6W7J76TK.js";import"./chunk.FUR4IHWG.js";import"./chunk.2B4WVCVV.js";import"./chunk.AAZFVCSP.js";import"./chunk.GZHZLJBF.js";import"./chunk.PWOVXARZ.js";import"./chunk.SG23JC6D.js";import"./chunk.OJGHDWI6.js";import"./chunk.GZLYTPE7.js";import"./chunk.4B73P2WA.js";import"./chunk.IMRCAU4T.js";import"./chunk.BZ5VLPKB.js";import{ja as n}from"./chunk.6II4BONS.js";import"./chunk.F5BCCGFK.js";import"./chunk.AJZBJBMO.js";var w=new WeakMap;function s(e,i){let t=w.get(e);t||w.set(e,t=new Map);let r=t.get(i);return r||t.set(i,r=a(o(e,n(e)),e,i)),r}export{s as frameworkViews};
@@ -1 +0,0 @@
1
- import{a as Se,b as Me,c as Ke,d as me,e as D,f as Pe,h as Ce}from"./chunk.LNNFNJKN.js";import{h as Ne,i as _e,j as Ie}from"./chunk.6W7J76TK.js";import{a as oe,b as se,c as Z,d as Ge,e as Y,g as ee,h as qe}from"./chunk.2B4WVCVV.js";import{c as Re,h as g,i as Te,j as ue}from"./chunk.AAZFVCSP.js";import{b as L,c as q,e as Oe,f as xe,g as G,h as v,k as K,l as X,m as C,n as Ee,o as V,p as T,pa as Fe,r as k,s as Q,t as x,u as F,v as I,w as P,wa as De,x as n,xa as pe,y as U,ya as fe,z as Ae}from"./chunk.F5BCCGFK.js";function ge(e){let o=/^(edit|remove|archive|unarchive|merge|leave-alone|allow-tidying|skip|detach|split)-(.+)$/.exec(e);return o?{act:o[1],kind:o[2]}:void 0}var he="graview-document",ye=1,be=256*1024,ze=64*1024,ke=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,$e=/^[a-z][A-Za-z0-9]*$/,cn=new Set(["id","kind"]),dn=e=>e in Object.prototype,Ue=U(e=>!dn(e),"every object already has this name \u2014 choose another"),We=(e,o)=>[...e===void 0?[]:[xe(e)],...o===void 0?[]:[Oe(o)]],h=(e,o)=>v().check(...We(e,o)),E=(e,o,r)=>T(e).check(...We(o,r)),R=e=>v().check(G(ke,`${e} names are kebab-case, lower-case words joined by hyphens like "tool-note" (field and relation names are camelCase, like "supersededBy")`)),ln=/^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|[a-z][A-Za-z0-9]*)$/,W=v().check(G(ln,'relation names are one camelCase word, like "supersededBy" (kind names are kebab-case, like "tool-note")'),Ue),N=v().check(G($e,'field names are one word or camelCase, like "dueDate", so rules say them bare (kind names are kebab-case, like "tool-note")'),U(e=>!cn.has(e),'a field cannot be called "id" or "kind" \u2014 the framework keeps those; try "type" or "category"'),Ue),B=h(1,500),H=h(1,2e3),ie=h(1,300),pn=["string","text","number","integer","boolean","date","datetime","enum","list","url","email","image","file","app-link","phone","place","duration"],Ze=k({type:I(pn),required:n(C()),description:n(B),label:n(h(1,60)),options:n(E(h(1,80),1,100)),of:n(I(["string","number","date","image","file"])),default:n(V()),unit:n(h(void 0,12)),format:n(I(["money","percent","duration","markdown"])),min:n(K()),max:n(K()),step:n(K()),renamedFrom:n(v().check(G($e))),repeats:n(C())}).check(Ae((e,o)=>{e.type==="enum"&&!e.options&&o.addIssue({code:"custom",message:'an enum field lists its "options"',path:["options"]}),e.type!=="enum"&&e.options&&o.addIssue({code:"custom",message:'"options" belongs only on an enum field',path:["options"]}),e.type!=="list"&&e.of&&o.addIssue({code:"custom",message:'"of" belongs only on a list field',path:["of"]}),e.repeats&&e.type!=="date"&&e.type!=="datetime"&&o.addIssue({code:"custom",message:'"repeats" belongs only on a date or datetime field',path:["repeats"]})})),fn=v().check(G(new RegExp(`${ke.source}|${Fe.source}`),'a relation goes to a kind of this document, like "house", or of another app, like "@nick/house/house"')),un=k({to:x([E(fn,1),P("*")]),cardinality:n(I(["one","many"])),description:n(B),inverse:n(h(1,80)),appendOnly:n(C()),renamedFrom:n(v()),tidying:n(P("never"))}),Ye=x([H,k({expr:H,label:n(h(1,60)),description:n(B)})]),mn=k({noun:n(h(1,40)),plural:n(h(1,40)),description:n(B),fields:F(N,Ze).check(U(e=>Object.keys(e).length>0,"a kind has at least one field")),label:n(ie),describe:n(ie),lifecycle:n(k({field:N,retired:E(x([v(),K(),C()]),1)})),figure:n(h(void 0,2e4)),glance:n(E(N,1,20)),page:n(k({fields:n(E(N,1,40)),groups:n(E(k({title:h(1,60),fields:E(N,1,40)}),1,12))})),edges:n(F(W,un)),computed:n(F(v(),Ye).check(U(e=>Object.keys(e).length<=20,"a kind works out at most 20 computed fields"))),fieldRoles:n(F(v(),v())),renamedFrom:n(v().check(G(ke))),people:n(C()),archives:n(P(!1)),tidying:n(I(["never","no-links"]))}),ne=x([v(),K(),C(),Ee(),T(V()),k({expr:H})]),J=v().check(G(/^\$[A-Za-z][A-Za-z0-9]*$/,'a reference is "$" and a name, like "$subject" or "$new"')),gn=x([k({create:R("kind"),as:n(v().check(G($e))),set:n(F(N,ne))}),k({set:F(N,ne),target:n(J)}),k({connect:W,from:J,to:J}),k({sever:W,from:J,to:J}),k({remove:J})]),zn=k({title:n(h(1,80)),description:n(B),fromTheOtherEnd:n(h(1,80)),on:n(x([R("kind"),E(R("kind"),1)])),creates:n(R("kind")),sets:n(F(N,ne)),writes:n(E(N,1)),connects:n(W),severs:n(W),setsOther:n(F(N,ne)),replaces:n(x([P(!0),E(W,1,10)])),removes:n(P(!0)),args:n(F(N,Ze)),effects:n(E(gn,1,20)),allowedWhen:n(H),refusal:n(ie),destructive:n(C())}),hn=k({act:R("act"),label:n(h(1,80)),args:n(F(v(),ne))}),yn=k({title:n(h(1,120)),description:n(B),over:x([P("graph"),R("kind")]),when:n(H),require:H,says:n(ie),repairs:n(E(hn,void 0,10))}),bn=k({roles:x([E(R("role"),1),P("*")]),mutations:x([E(R("act"),1),P("*")]),kinds:n(x([T(R("kind")),P("*")])),describe:n(B),self:n(C()),ownEnd:n(C())}),Ve=n(E(R("field"),1)),kn=k({roles:x([E(R("role"),1),P("*")]),kinds:E(R("kind"),1),own:n(C()),via:n(W),fields:Ve,hide:Ve}),$n=k({grants:T(bn),sees:n(T(kn))}),wn=k({accent:n(v().check(G(/^#[0-9a-fA-F]{6}$/,'an accent is a color like "#c2577a"'))),name:n(h(1,60)),currency:n(v().check(G(/^[A-Z]{3}$/,'a currency is its three-letter code, like "USD" or "EUR"'))),locale:n(h(2,35)),logo:n(x([h(1,ze),k({src:h(1,ze),alt:n(h(1,120))})])),favicon:n(x([h(1,ze),k({emoji:v()})])),typography:n(k({display:n(h(1,200)),body:n(h(1,200)),mono:n(h(1,200))})),shape:n(k({radius:n(K().check(q(0),L(32))),density:n(K().check(q(.75),L(1.5)))})),accents:n(F(v(),K().check(q(0),L(360)))),scheme:n(I(["light","dark","auto"]))}),re=F(v(),V()),Be=x([h(1,120),k({by:h(1,120),direction:n(I(["asc","desc"]))})]),Le=K().check(X(),q(1),L(9999)),vn=Q({create:n(C()),options:n(Q({sort:n(Be),columnSort:n(Be),horizon:n(x([K().check(X(),q(1),L(200)),Q({years:K().check(X(),q(1),L(200)),title:h(1,80),from:n(Le),to:n(Le)})]))}))}),jn=k({card:n(T(V())),row:n(T(V())),page:n(T(V()))}),Sn=()=>{let e=n(I(["asc","desc"]));return x([h(1,120),k({by:h(1,120),direction:e,then:n(x([h(1,120),k({by:h(1,120),direction:e})]))})])},On=()=>x([h(1,120),k({by:h(1,120),order:n(E(h(1,80),void 0,40)),closed:n(E(h(1,80),void 0,40))})]),xn=Q({order:n(T(v())),hide:n(T(v())),first:n(v()),primary:n(E(h(1,80),void 0,40)),scene:n(h(1,40)),pages:n(h(1,40)),lists:n(F(v(),k({filters:n(E(h(1,120),void 0,40)),sort:n(Sn()),group:n(On())})))}),Je=k({$schema:n(v()),format:P(he),formatVersion:P(ye),name:h(1,80),description:n(B),version:n(K().check(X(),q(1))),kinds:F(R("kind"),mn).check(U(e=>Object.keys(e).length>0,"a document declares at least one kind"),U(e=>Object.keys(e).length<=40,"a document declares at most 40 kinds")),computed:n(F(v(),Ye)),acts:n(F(R("act"),zn)),rules:n(F(R("rule"),yn)),roles:n(T(R("role"))),policy:n($n),modules:n(re),lenses:n(T(vn)),pages:n(xn),views:n(F(v(),x([jn,T(V())]))),brand:n(wn),settings:n(T(re)),migrations:n(T(re)),connections:n(F(R("connection"),re))});var En={};function He(e,o=En,r=ye){let{document:a,respelled:l}=Se(e),p=l.length>0?{respelled:l}:{};if(!a||typeof a!="object"||Array.isArray(a))return{document:a};let u=a;if(u.format!==he||typeof u.formatVersion!="number"||u.formatVersion>=r)return{document:a,...p};let z=u.formatVersion,$=structuredClone(u);for(let s=z;s<r;s++){let t=o[s];if(!t)throw new Error(`there is no upgrade from format ${s} to ${s+1}`);$={...t($),formatVersion:s+1}}return{document:$,from:z,...p}}function Xe(e,o,r){let a=Object.keys(e).filter(z=>e[z].edges?.[o]!==void 0);if(a.length===0)return;let l=a.map(z=>e[z].edges[o].to),p=l.some(z=>z==="*")?"*":[...new Set(l.flatMap(z=>z))];if(r.length===0||r.some(z=>a.includes(z)))return{reversed:!1,kinds:p};let u=a.filter(z=>{let $=e[z].edges[o].to;return $==="*"||r.every(s=>$.includes(s))});return u.length>0?{reversed:!0,kinds:u}:{reversed:!1,kinds:p}}var nn=(e,o)=>{let r=e?.fields[o];return r!==void 0&&(r.type==="duration"||(r.type==="number"||r.type==="integer")&&r.format==="duration")};function Qe(e,o,r,a){if(a==="out"){let l=e[o]?.edges?.[r]?.to;return l===void 0?[]:l==="*"?Object.keys(e):l}return Object.entries(e).filter(([,l])=>{let p=l.edges?.[r]?.to;return p!==void 0&&(p==="*"||p.includes(o))}).map(([l])=>l)}function we(e,o,r){if(r.t==="ident")return e[o]?.edges?.[r.name]?Qe(e,o,r.name,"out"):void 0;if(r.t==="where")return we(e,o,r.set);if(r.t==="call"&&(r.fn==="out"||r.fn==="in")&&r.args[0]?.t==="lit"&&typeof r.args[0].value=="string")return Qe(e,o,r.args[0].value,r.fn)}var en=(e,o,r)=>{let a=o.filter(l=>e[l]?.fields[r]!==void 0);return a.length>0&&a.every(l=>nn(e[l],r))};function tn(e,o,r){let a=e.kinds,l=a[o],p=new Map(r),u=new Map,z=(s,t)=>{if(t>8)return!1;switch(s.t){case"ident":return nn(l,s.name)||$(s.name,t+1);case"member":{let d=we(a,o,s.object);return d!==void 0&&en(a,d,s.name)}case"call":{if(s.fn!=="sum"&&s.fn!=="min"&&s.fn!=="max")return!1;let[d,w]=s.args,f=d&&we(a,o,d);return f!==void 0&&w?.t==="ident"&&en(a,f,w.name)}case"binary":return(s.op==="+"||s.op==="-")&&z(s.left,t)&&z(s.right,t);case"unary":return s.op==="-"&&z(s.operand,t);default:return!1}},$=(s,t)=>{if(l?.computed?.[s]===void 0)return!1;if(u.has(s))return u.get(s);u.set(s,!1);let d=p.get(s),w=d!==void 0&&z(d,t);return u.set(s,w),w};return r.map(([s])=>s).filter(s=>$(s,0))}function on(e,o,r=`kinds.${e}.page`){let a=o.page;if(!a)return[];let l=[],p=[...Object.keys(o.fields),...Object.keys(o.computed??{})],u=new Set,z=(s,t)=>{p.includes(s)?u.has(s)&&l.push(g("page-field-twice",t,`"${s}" is on ${e}'s page twice; name each field once`)):l.push(g("page-field",t,`${e}'s page is to show "${s}", and ${e} has no field or computed field called that`,`use one of: ${p.join(", ")}`)),u.add(s)};(a.fields??[]).forEach((s,t)=>z(s,`${r}.fields.${t}`));let $=new Set;return(a.groups??[]).forEach((s,t)=>{let d=s.title.trim().toLowerCase();$.has(d)&&l.push(g("page-group-twice",`${r}.groups.${t}.title`,`${e}'s page has two groups called "${s.title}"; give each its own title`)),$.add(d),s.fields.forEach((w,f)=>z(w,`${r}.groups.${t}.fields.${f}`))}),l}var An=new Set(["subject","now","today","me"]);function Fn(e){if((typeof e=="string"?e:JSON.stringify(e??null)).length>be)return{findings:[g("too-large","",`a document may be at most ${be/1024} KB`)]};if(typeof e=="string")try{e=JSON.parse(e)}catch(a){return{findings:[g("not-json","",`this is not JSON: ${a.message}`)]}}try{e=He(e).document}catch(a){return{findings:[g("format","formatVersion",a.message)]}}let o=Je.safeParse(e);if(!o.success)return{findings:o.error.issues.map(a=>{let l=a.path.map(String).join(".");if(a.code==="unrecognized_keys")return g("unknown-key",l,`${a.keys.map(p=>`"${p}"`).join(", ")} ${a.keys.length===1?"is":"are"} not part of a Graview document here`,"check the spelling against docs/declaration-document.md");if(a.code==="invalid_union"&&/\.effects\.\d+$/.test(l))return g("effect-shape",l,"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(a.code==="invalid_key"){let p=a.issues?.[0]?.message;return g("shape",l,`the name "${String(a.path.at(-1))}" is not allowed here${p?`: ${p}`:""}`)}return g("shape",l,a.message)})};let r=o.data;return{document:r,findings:Dn(r)}}var ce=e=>[e??[]].flat();function sn(e){let o=new Map;for(let[r,a]of Object.entries(e.kinds))for(let[l,p]of Object.entries(pe(a.edges))){let u=o.get(l);o.set(l,{name:l,from:[...u?.from??[],r],to:p.to==="*"||u?.to==="*"?"*":[...new Set([...u?.to??[],...p.to])],cardinality:p.cardinality??"many"})}return o}function lt(e){let o=new Map;for(let[a,l]of Object.entries(e.kinds)){let p=ee(l),u=fe(l.edges);o.set(a,{fields:new Set([...Object.keys(l.fields),...u.keys()]),edges:new Map(Object.entries(pe(l.edges)).map(([z,$])=>[z,$.cardinality??"many"])),...p?{computed:p}:{},...u.size>0?{linked:u}:{}})}let r=ee(e);return r&&o.set(Re,{computed:r}),o}function rn(e,o){let r=[],a=ce(e.on),l=(p,u)=>{let z=Xe(o.kinds,p,a)?.reversed===!0,[$,s]=z?["$to","$subject"]:["$subject","$to"];return u==="connect"?{connect:p,from:$,to:s}:{sever:p,from:$,to:s}};if(e.creates){let p=o.kinds[e.creates],u={};for(let z of Object.keys(p?.fields??{}))u[z]=`$${z}`;for(let z of e.effects??[])"set"in z&&!("create"in z)&&D(z.target)==="new"&&Object.assign(u,z.set);r.push({create:e.creates,as:"new",set:u})}return e.sets&&r.push({set:e.sets}),e.writes&&!(e.creates&&e.on===void 0)&&r.push({set:Object.fromEntries(e.writes.map(p=>[p,`$${p}`]))}),e.connects&&(e.replaces&&r.push({replace:e.replaces===!0?[e.connects]:[...e.replaces],keep:e.connects}),r.push(l(e.connects,"connect"))),e.severs&&r.push(l(e.severs,"sever")),e.setsOther&&(e.connects||e.severs)&&r.push({set:e.setsOther,target:"$to"}),e.removes&&r.push({remove:"$subject"}),e.effects&&r.push(...e.effects.filter(p=>!(e.creates&&"set"in p&&!("create"in p)&&D(p.target)==="new"))),r}function ve(e,o,r){try{let a=Z(e),l=oe(a);for(let p of l.unknownFunctions)r.push(g("unknown-function",o,`"${p}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));return a}catch(a){if(a instanceof se){r.push(g("expression",o,a.sentence+` (at character ${a.at+1})`));return}throw a}}function je(e,o,r){try{return Y(e)}catch(a){if(a instanceof Ge||a instanceof se){r.push(g("template",o,(a instanceof se,a.sentence)));return}throw a}}function Dn(e){let o=[],r=new Set(Object.keys(e.kinds)),a=sn(e),l=e.acts??{},p=new Set(e.roles??[]),u=(s,t)=>fe(e.kinds[s]?.edges).has(t),z=s=>Object.keys(e.kinds).some(t=>u(t,s));for(let[s,t]of Object.entries(e.kinds)){let d=`kinds.${s}`;for(let[f,c]of Object.entries(t.edges??{})){if(!De(c)&&c.to!=="*")for(let i of c.to)r.has(i)||o.push(g("edge-target",`${d}.edges.${f}.to`,`"${i}" is not a kind this document declares`));t.fields[f]&&o.push(g("edge-field-clash",`${d}.edges.${f}`,`"${f}" is both a field and a relation of ${s}`,"rename one of them"))}t.lifecycle&&!t.fields[t.lifecycle.field]&&o.push(g("lifecycle-field",`${d}.lifecycle.field`,`${s} has no field "${t.lifecycle.field}"`));let w=f=>t.computed!==void 0&&Object.hasOwn(t.computed,f);for(let f of t.glance??[])!t.fields[f]&&!w(f)&&o.push(g("glance-field",`${d}.glance`,`a glance at ${s} is to say "${f}", and ${s} has no field or computed field called that`,`use one of: ${[...Object.keys(t.fields),...Object.keys(t.computed??{})].join(", ")}`));o.push(...on(s,t));for(let f of["label","describe"]){let c=t[f];if(!c)continue;let i=je(c,`${d}.${f}`,o);for(let A of i??[])if(A.expr){for(let y of oe(A.expr).names)if(!t.fields[y]){if(w(y)){qe(t,y)||o.push(g("template-field",`${d}.${f}`,`${s}'s ${y} is worked out from beyond the record, and a ${f} is said with no graph to read`,`show it in a view instead, or name a computed field worked out from ${s}'s own fields`));continue}o.push(g("template-field",`${d}.${f}`,`${s} has no field "${y}" for its ${f} to show`,f==="label"?"a label can only show the record's own fields and what they work out":void 0))}}}for(let[f,c]of Object.entries(t.fields)){c.default!==void 0&&c.type==="enum"&&!c.options?.includes(String(c.default))&&o.push(g("default-option",`${d}.fields.${f}.default`,`"${String(c.default)}" is not one of ${f}'s options`));let i=`${f}Repeat`;c.repeats&&(t.fields[i]||t.edges?.[i]||t.computed?.[i])&&o.push(g("repeat-clash",`${d}.fields.${f}.repeats`,`${s} already has "${i}", where how ${f} repeats is kept`))}}for(let[s,t]of Object.entries(l)){let d=`acts.${s}`;for(let i of ce(t.on))r.has(i)||o.push(g("act-kind",`${d}.on`,`"${i}" is not a kind this document declares`));let w=ce(t.on),f=rn(t,e);if(t.creates&&t.on===void 0&&t.writes&&r.has(t.creates)){for(let i of t.writes)if(!e.kinds[t.creates].fields[i])if(e.kinds[t.creates].computed?.[i]!==void 0)o.push(g("computed-written",`${d}.writes`,`${t.creates}'s ${i} is worked out, not written: no act can set it`,"write the stored fields it is worked out from"));else{if(u(t.creates,i))continue;o.push(g("act-field",`${d}.writes`,`${t.creates} has no field "${i}"`))}}f.length===0&&o.push(g("act-empty",d,`"${s}" does nothing`,"give it effects or a shorthand such as sets or creates"));let c=new Map;f.forEach((i,A)=>{let y=f.length-(t.effects?.length??0),j=t.effects&&A>=y?`${d}.effects.${A-y}`:d;if("create"in i){if(!r.has(i.create))o.push(g("act-kind",`${j}.create`,`"${i.create}" is not a kind this document declares`));else for(let b of Object.keys(i.set??{}))e.kinds[i.create].fields[b]||(e.kinds[i.create].computed?.[b]!==void 0?o.push(g("computed-written",`${j}.set.${b}`,`${i.create}'s ${b} is worked out, not written: no act can set it`,"set the stored fields it is worked out from")):o.push(g("act-field",`${j}.set.${b}`,`${i.create} has no field "${b}"`)));i.as&&c.set(i.as,i.create)}else if("connect"in i||"sever"in i){let b="connect"in i?i.connect:i.sever;!a.has(b)&&!z(b)&&o.push(g("act-edge",`${j}.${"connect"in i?"connect":"sever"}`,`"${b}" is not a relation any kind declares`)),D(i.from)==="subject"&&w.length===0&&o.push(g("act-subject",`${d}.on`,`"${s}" acts on "$subject" but does not say which kinds it is "on"`))}else if("set"in i){let b=D(i.target??"$subject"),de=b==="subject"?w:c.has(b??"")?[c.get(b)]:[];b==="subject"&&w.length===0&&o.push(g("act-subject",`${d}.on`,`"${s}" changes "$subject" but does not say which kinds it is "on"`));for(let _ of Object.keys(i.set))for(let m of de)if(!(!r.has(m)||e.kinds[m].fields[_]))if(e.kinds[m].computed?.[_]!==void 0)o.push(g("computed-written",`${j}.set.${_}`,`${m}'s ${_} is worked out, not written: no act can set it`,"set the stored fields it is worked out from"));else{if(u(m,_))continue;o.push(g("act-field",`${j}.set.${_}`,`${m} has no field "${_}"`))}}else"remove"in i&&D(i.remove)==="subject"&&w.length===0&&o.push(g("act-subject",`${d}.on`,`"${s}" removes "$subject" but does not say which kinds it is "on"`));("set"in i&&i.set?Object.values(i.set):[]).forEach(b=>{b&&typeof b=="object"&&!Array.isArray(b)&&"expr"in b&&ve(b.expr,`${j}.set`,o)})}),t.allowedWhen&&ve(t.allowedWhen,`${d}.allowedWhen`,o),t.refusal&&je(t.refusal,`${d}.refusal`,o)}for(let[s,t]of Object.entries(e.rules??{})){let d=`rules.${s}`;t.over!=="graph"&&!r.has(t.over)&&o.push(g("rule-kind",`${d}.over`,`"${t.over}" is not a kind this document declares`));let w=t.over==="graph"?void 0:e.kinds[t.over];for(let f of["when","require"]){let c=t[f];if(!c)continue;let i=ve(c,`${d}.${f}`,o);if(!i)continue;let A=oe(i);for(let y of A.names)if(t.over==="graph")o.push(g("rule-name",`${d}.${f}`,`"${y}" means nothing in a rule over the whole graph`,`name a kind in "over", or use all('kind')`));else if(w&&!w.fields[y]&&!w.edges?.[y]&&w.computed?.[y]===void 0){let j=Object.keys(w.edges??{}).find(S=>S.includes("-")&&S.split("-").includes(y));o.push(g("rule-name",`${d}.${f}`,`${t.over} has no field or relation called "${y}"`,j?`"${j}" reads as a subtraction in a rule; rename the relation to one camelCase word, like "${j.replace(/-([a-z0-9])/g,(S,b)=>b.toUpperCase())}"`:void 0))}for(let y of A.edges)!a.has(y)&&!z(y)&&o.push(g("rule-edge",`${d}.${f}`,`"${y}" is not a relation any kind declares`));for(let y of A.sweeps)r.has(y)?t.over!=="graph"&&o.push(Te("rule-cost",`${d}.${f}`,`this rule looks at every ${y} for every ${t.over}, which grows slowly as the app grows`,"walk a relation with out()/in() instead of all() where you can")):o.push(g("rule-kind",`${d}.${f}`,`"${y}" is not a kind this document declares`))}t.says&&je(t.says,`${d}.says`,o),(t.repairs??[]).forEach((f,c)=>{!l[f.act]&&!ge(f.act)&&o.push(g("repair-act",`${d}.repairs.${c}.act`,`"${f.act}" is not an act this document declares`))})}let $=e.policy;return $&&($.grants.forEach((s,t)=>{if(s.roles!=="*"&&p.size>0)for(let d of s.roles)p.has(d)||o.push(g("grant-role",`policy.grants.${t}.roles`,`"${d}" is not one of the document's roles`));if(s.mutations!=="*")for(let d of s.mutations)!l[d]&&!ge(d)&&o.push(g("grant-act",`policy.grants.${t}.mutations`,`"${d}" is not an act this document declares`))}),($.sees??[]).forEach((s,t)=>{for(let d of s.kinds)r.has(d)||o.push(g("sight-kind",`policy.sees.${t}.kinds`,`"${d}" is not a kind this document declares`));if(s.roles!=="*"&&p.size>0)for(let d of s.roles)p.has(d)||o.push(g("sight-role",`policy.sees.${t}.roles`,`"${d}" is not one of the document's roles`))})),o.push(...Ie(e)),o}function Rn(e,o,r,a){let l=new Map,p=ce(e.on),u=new Map,z=new Map;(p.length>0||o.some(c=>"remove"in c&&D(c.remove)==="subject"||"from"in c&&(D(c.from)==="subject"||D(c.to)==="subject")||"set"in c&&!("create"in c)&&D(c.target??"$subject")==="subject"))&&l.set(me,{ref:p.length>0?p:"*",required:!0});let s=e.args??{},t=e.writes?.length===1,d=(c,i)=>i&&c.type===i.type&&c.min===void 0&&c.max===void 0&&c.step===void 0?{...c,...i.min===void 0?{}:{min:i.min},...i.max===void 0?{}:{max:i.max},...i.step===void 0?{}:{step:i.step}}:c,w=(c,i)=>i&&c.type===i.type&&c.format===void 0&&c.unit===void 0?{...d(c,i),...i.format?{format:i.format}:{},...i.unit?{unit:i.unit}:{}}:d(c,i),f=(c,i,A)=>{if(c===me||An.has(c)||u.has(c)||l.has(c))return;let y=s[c]?w(s[c],A):void 0;l.set(c,y?{field:y,optional:!y.required,required:!!y.required}:i())};for(let c of o)if("create"in c){let i=r.kinds[c.create];for(let[A,y]of Object.entries(c.set??{})){let j=D(y),S=i?.fields[A];if(j&&S){let b=!!S.required&&S.default===void 0;f(j,()=>({field:S,optional:!b,required:b}),S)}}c.as&&u.set(c.as,c.create)}else if("connect"in c||"sever"in c){let i=a.get("connect"in c?c.connect:c.sever);for(let[A,y]of[["from",c.from],["to",c.to]]){let j=D(y);if(!j)continue;let S=A==="to"?i?.to??"*":i?.from??"*";S!=="*"&&!z.has(j)&&z.set(j,S),f(j,()=>({ref:S,required:!0}))}}else if("set"in c){let i=D(c.target??"$subject"),A=i==="subject"?p[0]:u.get(i??"")??z.get(i??"")?.[0];i&&i!=="subject"&&!u.has(i)&&f(i,()=>({ref:"*",required:!0}));for(let[y,j]of Object.entries(c.set)){let S=D(j);if(!S)continue;let b=A?r.kinds[A]?.fields[y]:void 0;f(S,()=>b?{field:b,optional:!t,required:t}:{any:!0,required:!1},b)}}else if("remove"in c){let i=D(c.remove);i&&f(i,()=>({ref:"*",required:!0}))}for(let[c,i]of Object.entries(s))l.has(c)||l.set(c,{field:i,optional:!i.required,required:!!i.required});return l}function pt(e,o={}){let r=Fn(e);if(!r.document||ue(r.findings))return{ok:!1,findings:r.findings};let a=r.document,l=[...r.findings];o.previous&&l.push(...Mn(a,o.previous));let p=Tn(a,l);return ue(p.findings)?{ok:!1,findings:p.findings}:Ce(p,o)}function ae(e,o){return e.map(r=>{let a=!r.format&&r.expr?.t==="ident"?o?.[r.expr.name]?.format:void 0;return a==="money"||a==="percent"?{...r,format:a}:r})}function Tn(e,o){let r=sn(e),a={};for(let[s,t]of Object.entries(e.kinds)){let d=Pe(t),w=t.label??(d?`{${d}}`:void 0),f=ee(t),c=f?tn(e,s,[...f]):[];a[s]={...w?{label:ae(Y(w),t.fields)}:{},...t.describe?{describe:ae(Y(t.describe),t.fields)}:{},...f?{computed:[...f]}:{},...c.length>0?{durations:c}:{}}}let l={};for(let[s,t]of Object.entries(e.acts??{})){let d=rn(t,e),w=Rn(t,d,e,r),f=t.destructive??d.some(m=>"remove"in m||"sever"in m||"replace"in m),c=[...new Set(d.flatMap(m=>"create"in m?[m.create]:[]))],i=[...new Set(d.flatMap(m=>"connect"in m?[m.connect]:[]))],A=[...new Set(d.flatMap(m=>"sever"in m?[m.sever]:"replace"in m?m.replace:[]))],y=[...new Set(d.flatMap(m=>"set"in m&&!("create"in m)&&D(m.target??"$subject")==="subject"?Object.keys(m.set):[]))],j=new Map;for(let m of d){if(!("connect"in m)&&!("sever"in m))continue;let O=r.get("connect"in m?m.connect:m.sever);for(let[M,an]of[["from",m.from],["to",m.to]]){let te=D(an),le=M==="to"?O?.to:O?.from;te&&te!=="subject"&&le&&le!=="*"&&j.set(te,[...new Set([...j.get(te)??[],...le])])}}let S={};for(let m of d){if(!("set"in m)||"create"in m)continue;let O=D(m.target??"$subject");for(let M of O&&O!=="subject"&&j.get(O)||[])S[M]=[...new Set([...S[M]??[],...Object.keys(m.set)])]}let b={};for(let m of d)if(!(!("set"in m)||"create"in m||D(m.target??"$subject")!=="subject"))for(let[O,M]of Object.entries(m.set??{}))typeof M=="string"&&D(M)===void 0||typeof M=="number"||typeof M=="boolean"?b[O]=typeof M=="string"&&M.startsWith("$$")?M.slice(1):M:delete b[O];let de=c.length===0&&d.every(m=>!("set"in m)||!m.set||Object.values(m.set).every(O=>!(O&&typeof O=="object"&&!Array.isArray(O)&&"expr"in O))),_=new Map;for(let m of d)if(!(!("set"in m)||!m.set))for(let O of Object.values(m.set))O&&typeof O=="object"&&!Array.isArray(O)&&"expr"in O&&_.set(O.expr,Z(O.expr));l[s]={title:t.title??s.replace(/-/g," "),effects:d,args:[...w],...t.allowedWhen?{guard:Z(t.allowedWhen)}:{},...t.refusal?{refusal:ae(Y(t.refusal),e.kinds[[t.on??[]].flat()[0]??""]?.fields)}:{},exprs:[..._],destructive:f,idempotent:de,creates:c,connects:i,severs:A,writes:y,writesOther:S,sets:b}}let p={};for(let[s,t]of Object.entries(e.rules??{}))p[s]={title:t.title??s.replace(/-/g," "),require:Z(t.require),...t.when?{when:Z(t.when)}:{},...t.says?{says:ae(Y(t.says),e.kinds[t.over]?.fields)}:{}};let u=Me(e,o),z=Ne(e),$=_e(e);return{format:Ke,document:e,findings:o,kinds:a,...e.computed?{facts:[...ee(e)??[]]}:{},edges:[...r].map(([s,{from:t,to:d,cardinality:w}])=>[s,{from:t,to:d,cardinality:w}]),acts:l,rules:p,brand:u,...Object.keys(z).length>0?{viewSpecs:z}:{},...$?{home:$}:{}}}function ft(e,o,r){let a=/^defineNode\("([^"]+)"\)/.exec(o)?.[1],l=a?r.kinds[a]:void 0;if(!a||!l)return e;let p=Object.keys(l.fields).filter(u=>u!=="label").slice(0,3);return{...e,path:`kinds.${a}.glance`,fix:`Say which: "glance": [${p.map(u=>`"${u}"`).join(", ")}] on kinds.${a} \u2014 the facts a person compares one by, at a glance.`}}function Mn(e,o){let r=[],a=new Set(Object.values(o.kinds).flatMap(l=>Object.keys(l.edges??{})));for(let[l,p]of Object.entries(e.kinds)){let u=p.renamedFrom;u&&!o.kinds[u]&&r.push(g("renamed-from-nothing",`kinds.${l}.renamedFrom`,`${l} says it was ${u}, and the previous version has no kind called ${u}`,"name the kind it was, or drop renamedFrom"));let z=o.kinds[u??l];for(let[$,s]of Object.entries(p.fields)){let t=s.renamedFrom;t&&!z?.fields[t]&&r.push(g("renamed-from-nothing",`kinds.${l}.fields.${$}.renamedFrom`,`${$} says it was ${t}, and the previous ${u??l} has no field called ${t}`,"name the field it was, or drop renamedFrom"))}for(let[$,s]of Object.entries(p.edges??{})){let t=s.renamedFrom;t&&!a.has(t)&&r.push(g("renamed-from-nothing",`kinds.${l}.edges.${$}.renamedFrom`,`${$} says it was ${t}, and the previous version has no relation called ${t}`,"name the relation it was, or drop renamedFrom"))}}return r}export{Fn as a,lt as b,rn as c,pt as d,ft as e};
@@ -1 +0,0 @@
1
- var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{F as k,Q as n,a as t,xa as o}from"./chunk.6II4BONS.js";import{b as p}from"./chunk.AJZBJBMO.js";var f=o(t(()=>(__graviewPreload(import.meta.url,["./chunk.WVUJXDXZ.js","./chunk.VHWUGSFW.js","./chunk.P75TPZWT.js","./chunk.6W7J76TK.js","./chunk.FUR4IHWG.js","./chunk.2B4WVCVV.js","./chunk.AAZFVCSP.js","./chunk.GZHZLJBF.js","./chunk.PWOVXARZ.js","./chunk.SG23JC6D.js","./chunk.OJGHDWI6.js","./chunk.GZLYTPE7.js","./chunk.4B73P2WA.js","./chunk.IMRCAU4T.js","./chunk.BZ5VLPKB.js","./chunk.6II4BONS.js","./chunk.F5BCCGFK.js","./chunk.AJZBJBMO.js"]),import("./chunk.56BPXB6E.js")))),y=f.part((e,r)=>e.drawFiles(r),{quiet:!0});var d=o(t(()=>(__graviewPreload(import.meta.url,["./chunk.GZHZLJBF.js","./chunk.PWOVXARZ.js","./chunk.SG23JC6D.js","./chunk.OJGHDWI6.js","./chunk.GZLYTPE7.js","./chunk.4B73P2WA.js","./chunk.IMRCAU4T.js","./chunk.BZ5VLPKB.js","./chunk.6II4BONS.js","./chunk.F5BCCGFK.js","./chunk.AJZBJBMO.js"]),import("./chunk.QTITRX5Q.js")))),I=d.part((e,r)=>e.drawLinkedRecord(r),{quiet:!0}),w=d.part((e,r)=>e.drawLinkedPicker(r),{what:"Picking a linked record"});var s=p(n(),1),m=o(t(()=>(__graviewPreload(import.meta.url,["./chunk.GZHZLJBF.js","./chunk.PWOVXARZ.js","./chunk.SG23JC6D.js","./chunk.OJGHDWI6.js","./chunk.GZLYTPE7.js","./chunk.4B73P2WA.js","./chunk.IMRCAU4T.js","./chunk.BZ5VLPKB.js","./chunk.6II4BONS.js","./chunk.F5BCCGFK.js","./chunk.AJZBJBMO.js"]),import("./chunk.ITXIFDQ7.js")))),E=m.part((e,r)=>(0,s.jsx)(e.RepeatPicker,{...r}),{quiet:!0}),W=m.part((e,r)=>(0,s.jsx)(e.RepeatEditor,{...r}),{quiet:!0});var a=p(k(),1),i=p(n(),1),c=o(t(()=>(__graviewPreload(import.meta.url,["./chunk.GZLYTPE7.js","./chunk.4B73P2WA.js","./chunk.IMRCAU4T.js","./chunk.BZ5VLPKB.js","./chunk.6II4BONS.js","./chunk.F5BCCGFK.js","./chunk.AJZBJBMO.js"]),import("./chunk.6ZZZBDEG.js")))),l=c.part((e,r)=>(0,i.jsx)(e.WhenInput,{...r}),{quiet:!0});function M(e){return(0,i.jsx)(a.Suspense,{fallback:(0,i.jsx)("span",{"data-graview-when-arriving":"",style:{display:"inline-block",minHeight:24}}),children:(0,i.jsx)(l,{...e})})}var N=()=>c.load().then(()=>{},()=>{});export{y as a,I as b,w as c,E as d,W as e,M as f,N as g};
@@ -1 +0,0 @@
1
- import{a,b}from"./chunk.TGEF6TMM.js";import"./chunk.D6RDTUX3.js";import"./chunk.BZ5VLPKB.js";import"./chunk.6II4BONS.js";import"./chunk.F5BCCGFK.js";import"./chunk.AJZBJBMO.js";export{a as ActivityFilter,b as InteractionRow};