graview 0.1.25 → 0.1.27

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 (113) hide show
  1. package/dist/preview/chunk.4JXWQO6Y.js +1 -0
  2. package/dist/preview/chunk.4R7LDCDO.js +1 -0
  3. package/dist/preview/chunk.4W24TPMR.js +1 -0
  4. package/dist/preview/{chunk.SSOTDXRS.js → chunk.5BN2ARQ2.js} +1 -1
  5. package/dist/preview/chunk.6LJ66MB7.js +1 -0
  6. package/dist/preview/chunk.6R4EI47C.js +1 -0
  7. package/dist/preview/{chunk.JIXW4WIO.js → chunk.7CO6VP6F.js} +1 -1
  8. package/dist/preview/chunk.7QTBDACG.js +1 -0
  9. package/dist/preview/chunk.7SVIRYBB.js +1 -0
  10. package/dist/preview/chunk.7THQFY52.js +1 -0
  11. package/dist/preview/chunk.AS35X6KA.js +1 -0
  12. package/dist/preview/{chunk.UOYH2DFX.js → chunk.ATLUMYAJ.js} +2 -2
  13. package/dist/preview/{chunk.6DU4XN2F.js → chunk.CW7BMVBG.js} +1 -1
  14. package/dist/preview/chunk.DG2UE7PJ.js +1 -0
  15. package/dist/preview/chunk.DG2WKNMX.js +1 -0
  16. package/dist/preview/chunk.DQ5OWYLQ.js +1 -0
  17. package/dist/preview/chunk.DY2FFBWF.js +1 -0
  18. package/dist/preview/chunk.E3SZ7T75.js +1 -0
  19. package/dist/preview/chunk.EVTZE2OZ.js +1 -0
  20. package/dist/preview/chunk.FS5K4AVA.js +8 -0
  21. package/dist/preview/chunk.FTBKJ5RZ.js +16 -0
  22. package/dist/preview/chunk.GHMICJIB.js +1 -0
  23. package/dist/preview/chunk.HO6JR7VY.js +1 -0
  24. package/dist/preview/{chunk.DEZEXD24.js → chunk.HPD3DSTP.js} +1 -1
  25. package/dist/preview/chunk.I5KD54S6.js +1 -0
  26. package/dist/preview/chunk.IXVSJJQH.js +20 -0
  27. package/dist/preview/chunk.IZDKEFPJ.js +1 -0
  28. package/dist/preview/chunk.J36GTQTV.js +1 -0
  29. package/dist/preview/chunk.KAKX5TZN.js +3 -0
  30. package/dist/preview/chunk.LHAAZQNQ.js +19 -0
  31. package/dist/preview/chunk.LQZ2VQWN.js +107 -0
  32. package/dist/preview/chunk.MHJJEGQO.js +1 -0
  33. package/dist/preview/chunk.MNPNW4BQ.js +1 -0
  34. package/dist/preview/chunk.NKIFVPS3.js +1 -0
  35. package/dist/preview/chunk.NQNQPPPM.js +1 -0
  36. package/dist/preview/{chunk.6UL2JUEH.js → chunk.OA5BVKJH.js} +1 -1
  37. package/dist/preview/chunk.OHGJ5BZ4.js +2 -0
  38. package/dist/preview/chunk.OYULDOQP.js +1 -0
  39. package/dist/preview/{chunk.PY42PBMB.js → chunk.PHY3AH3L.js} +1 -1
  40. package/dist/preview/chunk.Q7544RCB.js +1 -0
  41. package/dist/preview/{chunk.JCZH55RX.js → chunk.QZWN46V6.js} +1 -1
  42. package/dist/preview/chunk.RUC4HFVC.js +1 -0
  43. package/dist/preview/chunk.S5JWZIVE.js +1 -0
  44. package/dist/preview/chunk.SHDYLMZE.js +2 -0
  45. package/dist/preview/chunk.T2EZ5MTH.js +1 -0
  46. package/dist/preview/chunk.TMPV4HLQ.js +1 -0
  47. package/dist/preview/{chunk.HQX5FGYT.js → chunk.TX2GOL65.js} +2 -2
  48. package/dist/preview/{chunk.S24R4MRK.js → chunk.U5ZUXGWM.js} +3 -3
  49. package/dist/preview/chunk.UMMN5Z6V.js +1 -0
  50. package/dist/preview/chunk.UPGDSOBY.js +1 -0
  51. package/dist/preview/chunk.V57P4LIZ.js +1 -0
  52. package/dist/preview/{chunk.YZZGD5OY.js → chunk.VD6FJ6KJ.js} +1 -1
  53. package/dist/preview/{chunk.B57EIGTS.js → chunk.VFICMX5G.js} +1 -1
  54. package/dist/preview/chunk.VMD4PDYJ.js +1 -0
  55. package/dist/preview/chunk.VMEX2KZ4.js +8 -0
  56. package/dist/preview/chunk.XDHBV5K5.js +1 -0
  57. package/dist/preview/chunk.YO7UFBJP.js +1 -0
  58. package/dist/preview/chunk.YV2RTNPU.js +6 -0
  59. package/dist/preview/chunk.ZD5HGRPR.js +1 -0
  60. package/dist/preview/chunk.ZKM4P7US.js +1 -0
  61. package/dist/preview/chunk.ZMMMKTAG.js +1 -0
  62. package/dist/preview/chunk.ZNIJONZN.js +1 -0
  63. package/dist/preview/page.js +6 -6
  64. package/package.json +6 -6
  65. package/dist/preview/chunk.2AJMM7JG.js +0 -1
  66. package/dist/preview/chunk.2WFEFZAW.js +0 -1
  67. package/dist/preview/chunk.2YVXTTC2.js +0 -1
  68. package/dist/preview/chunk.6KJSFIO7.js +0 -1
  69. package/dist/preview/chunk.6OBXKKB5.js +0 -20
  70. package/dist/preview/chunk.6WFN4C46.js +0 -107
  71. package/dist/preview/chunk.7BAUPTMY.js +0 -1
  72. package/dist/preview/chunk.A4SJ7EEY.js +0 -1
  73. package/dist/preview/chunk.ACKTGTOT.js +0 -1
  74. package/dist/preview/chunk.BJ2Y5F66.js +0 -1
  75. package/dist/preview/chunk.BYUQOV3O.js +0 -1
  76. package/dist/preview/chunk.C5N4RTPF.js +0 -1
  77. package/dist/preview/chunk.CFL2B2Z5.js +0 -1
  78. package/dist/preview/chunk.DJ72CUS7.js +0 -1
  79. package/dist/preview/chunk.DSZ3I557.js +0 -2
  80. package/dist/preview/chunk.EA4BZKPG.js +0 -1
  81. package/dist/preview/chunk.EKZWX6NG.js +0 -1
  82. package/dist/preview/chunk.F26676IW.js +0 -1
  83. package/dist/preview/chunk.F2KDFGHR.js +0 -1
  84. package/dist/preview/chunk.FWV4XAZA.js +0 -1
  85. package/dist/preview/chunk.G3BOZHKR.js +0 -1
  86. package/dist/preview/chunk.H4LHHT56.js +0 -8
  87. package/dist/preview/chunk.I5ELK6JF.js +0 -1
  88. package/dist/preview/chunk.I6T3FDQS.js +0 -1
  89. package/dist/preview/chunk.IB6PGEU7.js +0 -1
  90. package/dist/preview/chunk.JEMQBV6K.js +0 -1
  91. package/dist/preview/chunk.JW3E4SAC.js +0 -1
  92. package/dist/preview/chunk.KUTTVYOB.js +0 -16
  93. package/dist/preview/chunk.LHFEOEYY.js +0 -1
  94. package/dist/preview/chunk.MJ67MK4R.js +0 -1
  95. package/dist/preview/chunk.ORJ3T4IW.js +0 -2
  96. package/dist/preview/chunk.Q5WEOX3Q.js +0 -1
  97. package/dist/preview/chunk.QOYC424P.js +0 -3
  98. package/dist/preview/chunk.R6F3YMRK.js +0 -6
  99. package/dist/preview/chunk.RAE4M3KQ.js +0 -8
  100. package/dist/preview/chunk.RUFAVEXB.js +0 -1
  101. package/dist/preview/chunk.RVEMN5WU.js +0 -1
  102. package/dist/preview/chunk.S56LSUHV.js +0 -1
  103. package/dist/preview/chunk.T6KID3WO.js +0 -1
  104. package/dist/preview/chunk.TAOT74FR.js +0 -1
  105. package/dist/preview/chunk.TTODVIXW.js +0 -1
  106. package/dist/preview/chunk.U6BWYBPM.js +0 -19
  107. package/dist/preview/chunk.US4KIJSW.js +0 -1
  108. package/dist/preview/chunk.WX5CJ7PI.js +0 -1
  109. package/dist/preview/chunk.WXO3XUNW.js +0 -1
  110. package/dist/preview/chunk.ZJVIH6IF.js +0 -1
  111. package/dist/preview/chunk.ZRVDIVYY.js +0 -1
  112. package/dist/preview/chunk.ZV7ZFH2S.js +0 -1
  113. /package/dist/preview/{chunk.WWRWXFYR.js → chunk.WVUJXDXZ.js} +0 -0
@@ -0,0 +1,2 @@
1
+ import{D as U,E as F,F as D,Z as _}from"./chunk.VMEX2KZ4.js";var B=1e4,g=class{constructor(i){this.nodes=i}},J="",c=class extends Error{constructor(f,l){super(f);this.sentence=f;this.at=l}},C=class extends c{},V=t=>t!==null&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof g)&&typeof t.id=="string",P=t=>{let i=new Set;return new g(t.filter(f=>!i.has(f.id)&&i.add(f.id)))},p=t=>t===null?"nothing":t instanceof g?"a set of records":Array.isArray(t)?"a list":V(t)?"a record":typeof t=="string"?"a word":typeof t;function W(t,i){let f=i.budget??B,l=(n,s)=>{if(f-=n,f<0)throw new C("this rule looks at too much of the graph to judge in one go",s)},b=i.today??F(),A=i.now??new Date().toISOString(),w=new Map,T=new Set,G=i.bindings,I=(n,s,e,o)=>{let u=`${n?.id}\0${s}`;if(w.has(u))return w.get(u);if(T.has(u))throw new c(`"${s}"${n?` of ${_(n.kind)}`:""} depends on itself`,o);T.add(u);let r=G;G=void 0;try{let a=h(e,n);return w.set(u,a),a}finally{G=r,T.delete(u)}},M=(n,s,e)=>{l(1,e);let o=i.kinds.get(n.kind),u=o?.computed?.get(s);if(u)return I(n,s,u,e);let r=Object.hasOwn(n,s);if(o?.fields.has(s)||r){let d=r?n[s]:void 0;return d===void 0?null:d}let a=o?.edges.get(s);if(a){let d=i.graph.out(n.id,s);return l(d.length,e),a==="one"?d[0]??null:new g(d)}if(s==="id")return n.id;throw new c(`${_(n.kind)} has no field or relation called "${s}"`,e)},x=(n,s,e)=>{if(n instanceof g)return n;if(n===null)return new g([]);if(V(n))return new g([n]);throw new c(`${e}(\u2026) needs a set of records, and was given ${p(n)}`,s)},k=(n,s,e)=>{if(n===null)return null;if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);throw new c(`${e}(\u2026) needs a word, and was given ${p(n)}`,s)},O=(n,s,e)=>{let o=k(n,s,e);if(o===null)return null;let u=Date.parse(o.length===10?`${o}T00:00:00Z`:o);if(Number.isNaN(u))throw new c(`${e}(\u2026) needs a date, and "${o}" is not one`,s);return u},E=(n,s)=>V(n)&&V(s)?n.id===s.id:V(n)&&typeof s=="string"?n.id===s:typeof n=="string"&&V(s)?n===s.id:Array.isArray(n)&&Array.isArray(s)?n.length===s.length&&n.every((e,o)=>E(e,s[o])):n===s,N=(n,s,e)=>{if(n===null)return!1;if(typeof n=="boolean")return n;throw new c(`${e} must be true or false, and was ${p(n)}`,s)},R=(n,s)=>h(s,n);function h(n,s){switch(l(1,n.at),n.t){case"lit":return n.value;case"list":return n.items.map(e=>h(e,s));case"ident":{let e=G&&Object.hasOwn(G,n.name)?G[n.name]:void 0;if(e!==void 0)return e;if(s)return M(s,n.name,n.at);throw new c(`"${n.name}" means nothing in a rule over the whole graph`,n.at)}case"member":{let e=h(n.object,s);if(e===null)return null;if(V(e))return M(e,n.name,n.at);throw new c(`".${n.name}" needs a record before it, and was given ${p(e)}`,n.at)}case"unary":{let e=h(n.operand,s);if(n.op==="!")return!N(e,n.at,"what follows not");if(e===null)return null;if(typeof e!="number")throw new c(`"-" needs a number, and was given ${p(e)}`,n.at);return-e}case"where":{let e=x(h(n.set,s),n.at,"where");return l(e.nodes.length,n.at),new g(e.nodes.filter(o=>N(R(o,n.filter),n.at,"a where condition")))}case"binary":return H(n,s);case"call":return Y(n,s)}}function H(n,s){if(n.op==="&&")return N(h(n.left,s),n.at,"each side of and")&&N(h(n.right,s),n.at,"each side of and");if(n.op==="||")return N(h(n.left,s),n.at,"each side of or")||N(h(n.right,s),n.at,"each side of or");let e=h(n.left,s),o=h(n.right,s);if(n.op==="&"||n.op==="|"||n.op==="-"&&(e instanceof g||o instanceof g)){let u=x(e,n.at,n.op).nodes,r=x(o,n.at,n.op).nodes;l(u.length+r.length,n.at);let a=new Set(r.map(d=>d.id));return P(n.op==="|"?[...u,...r]:u.filter(d=>a.has(d.id)===(n.op==="&")))}switch(n.op){case"==":return E(e,o);case"!=":return!E(e,o);case"in":{if(o===null)return!1;if(o instanceof g)return o.nodes.some(u=>E(e,u));if(Array.isArray(o))return o.some(u=>E(e,u));if(typeof o=="string"&&typeof e=="string")return o.includes(e);throw new c(`"in" needs a list or a set on its right, and was given ${p(o)}`,n.at)}case"<":case"<=":case">":case">=":{if(e===null||o===null)return!1;if(!(typeof e=="number"&&typeof o=="number"||typeof e=="string"&&typeof o=="string"))throw new c(`cannot compare ${p(e)} with ${p(o)}`,n.at);return n.op==="<"?e<o:n.op==="<="?e<=o:n.op===">"?e>o:e>=o}default:{if(e===null||o===null)return null;if(n.op==="+"&&(typeof e=="string"||typeof o=="string")){let u=`${k(e,n.at,"+")}${k(o,n.at,"+")}`;if(u.length>1e4)throw new c("that makes a word too long",n.at);return u}if(typeof e!="number"||typeof o!="number")throw new c(`"${n.op}" needs numbers, and was given ${p(e)} and ${p(o)}`,n.at);return(n.op==="/"||n.op==="%")&&o===0?null:n.op==="+"?e+o:n.op==="-"?e-o:n.op==="*"?e*o:n.op==="/"?e/o:e%o}}}function Y(n,s){let e=(r,a=r)=>{if(n.args.length<r||n.args.length>a)throw new c(`${n.fn}(\u2026) takes ${r===a?r:`${r} to ${a}`} argument${a===1?"":"s"}`,n.at)},o=r=>h(n.args[r],s),u=r=>{let a=o(r);if(typeof a!="string")throw new c(`${n.fn}(\u2026) needs a quoted name, like ${n.fn}('name')`,n.at);return a};switch(n.fn){case"out":case"in":{e(1,2);let r=($,m)=>n.fn==="out"?i.graph.out($,m):i.graph.in($,m);if(n.args.length===2){let $=x(o(0),n.at,n.fn).nodes,m=u(1);return P($.flatMap(y=>{let S=r(y.id,m);return l(S.length+1,n.at),S}))}let a=u(0);if(!s)throw new c(`${n.fn}('${a}') needs a record to start from`,n.at);let d=r(s.id,a);return l(d.length,n.at),new g(d)}case"all":{e(1);let r=i.graph.nodesOfKind(u(0));return l(r.length,n.at),new g(r)}case"count":return e(1),x(o(0),n.at,"count").nodes.length;case"exists":return e(1),x(o(0),n.at,"exists").nodes.length>0;case"every":case"some":{e(2);let r=x(o(0),n.at,n.fn);l(r.nodes.length,n.at);let a=d=>N(R(d,n.args[1]),n.at,`the condition in ${n.fn}(\u2026)`);return n.fn==="every"?r.nodes.every(a):r.nodes.some(a)}case"sum":case"min":case"max":{e(2);let r=x(o(0),n.at,n.fn);l(r.nodes.length,n.at);let a=n.args[1],d=a.t==="lit"&&typeof a.value=="string"?a.value:void 0,$=a.t==="ident"?`'${a.name}'`:d!==void 0?`'${d}'`:"\u2026",m=r.nodes.map(y=>a.t==="ident"?M(y,a.name,n.at):d!==void 0?M(y,d,n.at):R(y,a)).filter(y=>{if(y===null)return!1;if(typeof y!="number")throw new c(`${n.fn}(\u2026, ${$}) needs a number for each member, and found ${p(y)}`,n.at);return!0});return n.fn==="sum"?m.reduce((y,S)=>y+S,0):m.length===0?null:n.fn==="min"?Math.min(...m):Math.max(...m)}case"fact":{e(1);let r=u(0),a=i.kinds.get(J)?.computed?.get(r);if(!a)throw new c(`no fact is called "${r}"`,n.at);return I(null,r,a,n.at)}case"first":return e(1),x(o(0),n.at,"first").nodes[0]??null;case"sort":{e(2,3);let r=x(o(0),n.at,"sort"),a=n.args.length===3?o(2):"asc";if(a!=="asc"&&a!=="desc")throw new c("sort(\u2026) goes 'asc' or 'desc'",n.at);let d=r.nodes.length;l(d+d*Math.ceil(Math.log2(d+1)),n.at);let $=r.nodes.map((y,S)=>({node:y,i:S,key:R(y,n.args[1])})),m=a==="desc"?-1:1;return $.sort((y,S)=>L(y.key,S.key,m,n.at)||y.i-S.i),new g($.map(y=>y.node))}case"either":{if(n.args.length<1)throw new c("either(\u2026) takes at least one argument",n.at);for(let r=0;r<n.args.length;r++){let a=o(r);if(a!==null&&!(a instanceof g&&a.nodes.length===0))return a}return null}case"present":{e(1);let r=o(0);return r===null||r===""?!1:Array.isArray(r)?r.length>0:r instanceof g?r.nodes.length>0:!0}case"len":{e(1);let r=o(0);if(r===null)return 0;if(typeof r=="string"||Array.isArray(r))return r.length;if(r instanceof g)return r.nodes.length;throw new c(`len(\u2026) needs a word or a list, and was given ${p(r)}`,n.at)}case"contains":case"startsWith":{e(2);let r=o(0),a=o(1);if(r===null||a===null)return!1;if(n.fn==="contains"&&Array.isArray(r))return r.some(m=>E(m,a));let d=k(r,n.at,n.fn),$=k(a,n.at,n.fn);return n.fn==="contains"?d.toLowerCase().includes($.toLowerCase()):d.startsWith($)}case"lower":{e(1);let r=k(o(0),n.at,"lower");return r===null?null:r.toLowerCase()}case"today":return e(0),b;case"now":return e(0),A;case"date":{e(1);let r=O(o(0),n.at,"date");return r===null?null:new Date(r).toISOString().slice(0,10)}case"days":case"hours":{e(2);let r=O(o(0),n.at,n.fn),a=O(o(1),n.at,n.fn);if(r===null||a===null)return null;let d=(a-r)/(n.fn==="days"?864e5:36e5);return n.fn==="days"?Math.round(d):d}case"if":return e(3),N(o(0),n.at,"the condition in if(\u2026)")?o(1):o(2);default:throw new c(`"${n.fn}" is not a function the rule language knows`,n.at)}}function L(n,s,e,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 a=L(n[r]??null,s[r]??null,e,o);if(a!==0)return a}return 0}let u=r=>typeof r=="number"||typeof r=="string"||typeof r=="boolean"?typeof r:p(r);if(u(n)!==u(s)||typeof n=="object"||typeof s=="object")throw new c(`sort(\u2026) cannot put ${p(n)} and ${p(s)} in order`,o);return typeof n=="string"?e*(n<s?-1:n>s?1:0):e*(Number(n)-Number(s))}return h(t,i.subject)}var rn=["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"];var sn=(t,i,f,l)=>({severity:"error",code:t,path:i,message:f,...l?{fix:l}:{}}),an=(t,i,f,l)=>({severity:"warning",code:t,path:i,message:f,...l?{fix:l}:{}}),ln=t=>t.some(i=>i.severity==="error");function un(t){return t.map(i=>`${i.severity==="error"?"\u2717":i.severity==="warning"?"!":"\xB7"} ${i.path||"(document)"}: ${i.message}${i.fix?` \u2014 ${i.fix}`:""}`).join(`
2
+ `)}var gn=["money","percent","date","relative","upper","lower","count","words","and","plural"],Q={getNode:()=>{},allNodes:()=>[],allEdges:()=>[],nodesOfKind:()=>[],edgesOfKind:()=>[],out:()=>[],in:()=>[],neighbors:()=>[],has:()=>!1};function yn(t,i,f,l=[],b){return K(t,i,f,l,b)}function X(t,i={}){let f=Number.isInteger(t),l={maximumFractionDigits:f?0:2,minimumFractionDigits:f?0:2};try{return new Intl.NumberFormat(i.locale??"en-US",i.currency?{style:"currency",currency:i.currency,...l}:l).format(t)}catch{return t.toLocaleString("en-US",l)}}var q=["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],Z=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];function v(t){return!Number.isInteger(t)||t<0||t>99?t.toLocaleString("en-US",{maximumFractionDigits:2}):t<20?q[t]:t%10===0?Z[t/10]:`${Z[Math.floor(t/10)]}-${q[t%10]}`}function z(t){return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function nn(t){return/[^aeiou]y$/i.test(t)?`${t.slice(0,-1)}ies`:/(s|x|z|ch|sh)$/i.test(t)?`${t}es`:`${t}s`}var j=t=>String(t.name??t.title??t.label??t.id);function K(t,i,f,l=[],b){if(i==="plural"){let A=t instanceof g?t.nodes.length:Array.isArray(t)?t.length:typeof t=="number"?t:null;return A===null||l[0]===void 0?"\u2014":A===1?l[0]:l[1]??nn(l[0])}if(t===null)return"\u2014";if(t instanceof g)return i==="count"?String(t.nodes.length):i==="and"?z(t.nodes.map(j)):t.nodes.map(j).join(", ");if(Array.isArray(t)){if(i==="count")return String(t.length);let A=t.map(w=>K(w,void 0,f,[],b));return i==="and"?z(A):A.join(", ")}if(typeof t=="object")return j(t);switch(i){case"words":return typeof t=="number"?v(t):String(t);case"money":return typeof t=="number"?X(t,b):String(t);case"percent":return typeof t=="number"?`${Math.round(t*100)}%`:String(t);case"upper":return String(t).toUpperCase();case"lower":return String(t).toLowerCase();case"date":return D(String(t).slice(0,10));case"relative":{let A=Date.parse(String(t).length===10?`${t}T00:00:00Z`:String(t));if(Number.isNaN(A))return String(t);let w=Math.round((A-Date.parse(`${f}T00:00:00Z`))/864e5);return w===0?"today":w===1?"tomorrow":w===-1?"yesterday":w>0?`in ${w} days`:`${-w} days ago`}default:return typeof t=="string"&&U.test(t)?D(t):String(t)}}function pn(t,i){let f=i.today??F();return t.map(l=>{if(l.text!==void 0)return l.text;try{let b=W(l.expr,{graph:i.graph??Q,subject:i.node,kinds:i.kinds,today:f,budget:i.budget??500,...i.bindings?{bindings:i.bindings}:{}});return K(b,l.format,f,l.formatArgs,i.money)}catch(b){if(b instanceof c)return"\u2014";throw b}}).join("")}export{g as a,J as b,c,C as d,W as e,rn as f,sn as g,an as h,ln as i,un as j,gn as k,Q as l,yn as m,X as n,pn as o};
@@ -0,0 +1 @@
1
+ import{$b as Yt,Gb as zt,Jb as qt,Kb as Ut,Mb as $t,Ua as Gt,Ya as Kt,Za as Bt,ba as Ft,ec as Se,fc as Ke,mb as jt}from"./chunk.VMEX2KZ4.js";import{a as F,b as ve}from"./chunk.MRK6QJV5.js";import{b as C}from"./chunk.AJZBJBMO.js";var te={focusId:null,relation:null,expanded:[],pins:{}},be=e=>{let t=Number(e);return Number.isFinite(t)?t:null};function U(e){let t=new URLSearchParams;e.focusId&&t.set("focus",e.focusId),e.relation&&t.set("relation",e.relation),e.overview&&t.set("overview","1"),e.zoom&&t.set("zoom","1"),e.past&&t.set("past","1"),e.shown&&e.shown.length>0&&t.set("show",[...e.shown].sort().join(",")),e.selection!==void 0&&e.selection.length>0&&t.set("sel",[...e.selection].sort().join(",")),e.expanded.length>0&&t.set("expand",[...e.expanded].sort().join(","));for(let o of Object.keys(e.pins).sort()){let r=e.pins[o];t.set(`pin.${o}`,`${xe(r.x)},${xe(r.y)}`)}e.pan&&(e.pan.x!==0||e.pan.y!==0)&&t.set("pan",`${xe(e.pan.x)},${xe(e.pan.y)}`);for(let o of Object.keys(e.within??{}).sort()){let r=e.within[o];r.length>0&&t.set(`in.${o}`,r)}e.q&&e.q.trim().length>0&&t.set("q",e.q);let n=t.toString();return n?`#${n}`:"#"}function $n(e){return e&&e.startsWith("agg:")?`aggregate:${e.slice(4)}`:e}function Ee(e){let t=e.includes("#")?e.slice(e.indexOf("#")+1):e,n=new URLSearchParams(t),o=Object.create(null);for(let[g,p]of n){if(!g.startsWith("pin."))continue;let[m,S]=p.split(","),k=m===void 0?null:be(m),h=S===void 0?null:be(S);k===null||h===null||(o[g.slice(4)]={x:k,y:h})}let r=Object.create(null);for(let[g,p]of n)!g.startsWith("in.")||p.length===0||(r[g.slice(3)]=p);let i=n.get("view");i&&i.length>0&&r.view===void 0&&(r.view=i);let a=n.get("pan")?.split(",")??[],u=a[0]===void 0?null:be(a[0]),l=a[1]===void 0?null:be(a[1]),c=(n.get("sel")??"").split(",").filter(g=>g.length>0).sort(),f=n.get("overview")==="1";return{...c.length>0?{selection:c}:{},...f?{overview:!0}:{},...n.get("zoom")==="1"?{zoom:!0}:{},...n.get("past")==="1"?{past:!0}:{},...n.get("show")?{shown:[...new Set(n.get("show").split(",").filter(Boolean))].sort()}:{},...u!==null&&l!==null?{pan:{x:u,y:l}}:{},...Object.keys(r).length>0?{within:r}:{},...n.get("q")?.trim()?{q:n.get("q")}:{},focusId:$n(n.get("focus")),relation:n.get("relation"),expanded:(n.get("expand")??"").split(",").filter(g=>g.length>0&&(f||!g.startsWith("kind:"))).sort(),pins:o}}function rr(e){let t=Ee(e);return U(t)==="#"?{...t,overview:!0}:t}function ir(e){let t=U(e);return t==="#overview=1"?"":t}function xe(e){return Math.round(e*100)/100}function Qt(e,t){return U(e)===U(t)}var Be="edge:";function ar(e,t,n){let o=r=>encodeURIComponent(r);return`${Be}${o(e)}:${o(t)}:${o(n)}`}function Xt(e){if(!e.startsWith(Be))return null;let t=e.slice(Be.length).split(":");if(t.length!==3)return null;let[n,o,r]=t;if(!n||!o||!r)return null;try{return{kind:decodeURIComponent(n),from:decodeURIComponent(o),to:decodeURIComponent(r)}}catch{return null}}function Re(e){let{pan:t,...n}=e;return{...n,pins:{}}}function $(e,t){if(t===e.focusId)return{...e,focusId:t};let n=Re(e);return{...n.within?.q!==void 0?ge(n,"q",null):n,focusId:t}}function Jt(e,t){return{...e,relation:t}}function ge(e,t,n){let o={...e.within??{}};if(n===null?delete o[t]:o[t]=n,Object.keys(o).length===0){let{within:r,...i}=e;return i}return{...e,within:o}}function je(e,t){if(t!==e.overview&&(e=Re(e)),!t){let n=e.expanded.filter(o=>!o.startsWith("kind:"));return{...e,overview:!1,expanded:n}}return{...e,overview:t}}function sr(e,t,n){let o=new Set(e.shown??[]);if(n?o.add(t):o.delete(t),o.size===0){let{shown:r,...i}=e;return i}return{...e,shown:[...o].sort()}}function Yn(e,t){if(t===null||t.trim().length===0){let{q:n,...o}=e;return o}return{...e,q:t}}function lr(e){let t=e.q!==void 0&&e.within?.q===e.q;return Yn(t?ge(e,"q",null):e,null)}function dr(e,t){if(!t){let{past:n,...o}=e;return o}return{...e,past:!0}}function Pe(e,t){if(t.length===0){let{selection:n,...o}=e;return o}return{...e,selection:[...t]}}function me(e,t){if(t!==(e.zoom===!0)&&(e=Re(e)),!t){let{zoom:n,...o}=e;return o}return{...e,zoom:!0}}function Me(e,t){let n=new Set(e.expanded);return n.has(t)?n.delete(t):n.add(t),{...e,expanded:[...n].sort()}}function cr(e,t){if(t===null||t.x===0&&t.y===0){let{pan:n,...o}=e;return o}return{...e,pan:t}}function ur(e){return Re(e)}function pr(e,t,n){let o={...e.pins};return n===null?delete o[t]:o[t]=n,{...e,pins:o}}var ke="aggregate:",Ae="kind:";function ze(e){return`${Ae}${e}`}function ne(e){return e.startsWith(Ae)?e.slice(Ae.length):null}var gr="kinds:beyond";function Qn(e){let t=ne(e);return t?[t]:X(e)}function oe(...e){return`${ke}${[...e].sort().join("+")}`}function Zt(e){return e.startsWith(ke)}function X(e){return!Zt(e)||e.includes("|")?[]:e.slice(ke.length).split("+").filter(Boolean)}function en(e,t,n={}){let o=ne(t);if(o!==null&&e.overview&&n.ownPicture!==!0)return Me(e,t);let r=o!==null?oe(o):t;if(e.zoom&&e.focusId===r&&!(o!==null&&n.carry))return me(e,!1);if(o!==null&&n.carry){let i=je({...$(e,r),relation:null},!1);return ge(me(i,!0),"q",n.carry)}return me({...$(e,r),relation:null},!0)}function Xn(e,t,n){return ge(je($(e,oe(t)),!1),"view",n)}function mr(e,t){return e.id<t.id?-1:e.id>t.id?1:0}var tn="aggregate:";function qe(e){return e.startsWith(tn)&&e.includes("|")}function Jn(e,t){let n=0,o=138;for(let r of e.split(" ")){let i=t(r),a=o+t(" ")+i;if(a<=138)o=a;else{let u=Math.ceil(i/138)||1;n+=u,o=i-(u-1)*138}}return n}var Zn=16.25,Ue=27,eo=(e,t)=>{let n=Math.ceil(e.length*7.1/138);return t?Math.max(Ue,Math.ceil(Math.max(n,Jn(e,t))*Zn)+6):Math.max(Ue,n*16+6)};function to(e,t,n){return e.length===0?0:10+e.reduce((o,r)=>o+eo(r,n),0)+(e.length-1)*2}var nn=27,on=8,no=4,rn=64,oo=e=>Math.max(1,Math.min(on,e)),ro=e=>e*nn+rn;var io=(e,t)=>e.length*t*.58;var $e=C(F(),1),ao={turns:[],outcomes:new Map,busy:!1,open:!1,side:"left",pending:null,drawn:0,draft:null,draftNote:null},an=e=>`graview:seat:${e}`;function so(e){if(!e)return{};try{let t=sessionStorage.getItem(e);if(!t)return{};let n=JSON.parse(t);return{...Array.isArray(n.turns)?{turns:n.turns}:{},...Array.isArray(n.outcomes)?{outcomes:new Map(n.outcomes)}:{},...typeof n.open=="boolean"?{open:n.open}:{},...n.side==="left"||n.side==="right"?{side:n.side}:{},...n.draft?.drawn?{draft:n.draft}:{}}}catch{return{}}}function lo(e,t){if(e)try{sessionStorage.setItem(e,JSON.stringify({turns:t.turns.slice(-40),outcomes:[...t.outcomes],open:t.open,side:t.side,draft:t.draft}))}catch{}}function Ye(e){let t=e===null?null:an(e),n={...ao,...so(t)},o=new Set,r=(i,a=!0)=>{n=i,a&&lo(t,n);for(let u of[...o])u()};return{get:()=>n,subscribe(i){return o.add(i),()=>void o.delete(i)},setTurns:i=>r({...n,turns:i(n.turns)}),settle:(i,a)=>r({...n,outcomes:new Map(n.outcomes).set(i,a)}),setBusy:i=>r({...n,busy:i},!1),setOpen:i=>{n.open!==i&&r({...n,open:i})},setSide:i=>{n.side!==i&&r({...n,side:i})},ask:i=>r({...n,open:!0,pending:i.trim()||null}),takePending(){let i=n.pending;return i!==null&&r({...n,pending:null},!1),i},drawn(){return r({...n,drawn:n.drawn+1},!1),()=>r({...n,drawn:Math.max(0,n.drawn-1)},!1)},setDraft:(i,a=null)=>r({...n,draft:i,draftNote:a})}}function co(e){let t=()=>e.get().drawn>0;return(0,$e.useSyncExternalStore)(e.subscribe,t,t)}function uo(e){return(0,$e.useSyncExternalStore)(e.subscribe,e.get,e.get)}var Te=C(F(),1),Oe=(0,Te.createContext)(void 0),po=()=>(0,Te.useContext)(Oe);var Qe={};var fo="I can answer about what's in this app. Open questions need AI, which isn't on here.",yo="Answered with AI";var sn=e=>`graview:setting:${e}`;function ln(){return localStorage}function dn(e,t){try{let n=(t??ln()).getItem(sn(e.name));if(n!==null&&e.options.some(o=>o.value===n))return n}catch{}return e.initial}function cn(e,t,n){try{(n??ln()).setItem(sn(e.name),t)}catch{}}function un(e,t){if(typeof document>"u")return;let n=document.documentElement;if(e.honored==="root-font-size"){n.style.fontSize=t===e.initial?"":t;return}let o=`graview${e.name.replace(/-([a-z0-9])/g,(r,i)=>i.toUpperCase()).replace(/^[a-z]/,r=>r.toUpperCase())}`;t===e.initial?delete n.dataset[o]:n.dataset[o]=t}var O=C(F(),1);function pn(e){return e?.closest?.("[data-graview-pick]")?.getAttribute("data-graview-pick")??null}function Xe(e){return Se(e)}var go=12,mo=4;function ho(e,t,n){let o=Xe(t);return e.get(o)??{participant:o,who:t.id??t.kind,at:null,mode:"docked",since:n,trail:[]}}var Ve=(e,t)=>t===null||e[e.length-1]===t?e:[...e,t].slice(-go);function fn(e,t){let n=e.filter(r=>r.length>0);if(n.length===0)return null;if(n.length<=mo)return n[0];let o=new Set(n.map(r=>t(r)).filter(r=>r!==void 0));return o.size===1?ze([...o][0]):n[0]}function Je(e,t,n){let o=new Map(e);if(t.type==="rest"){for(let[a,u]of e)u.mode!=="asking"&&u.mode!=="docked"&&t.at-u.since>=t.holdMs&&o.set(a,{...u,mode:"docked",at:null,trail:[],say:void 0,confidence:void 0});return o}if(t.author.kind!=="agent")return o;let r=ho(e,t.author,t.at),i=a=>o.set(r.participant,{...r,...a,since:t.at});switch(t.type){case"read":{let a=fn(t.ids,n);return i({at:a,mode:"reading",trail:Ve(r.trail,a)}),o}case"about-to-write":case"write":{let a=fn(t.ids,n);return i({at:a,mode:"writing",trail:Ve(r.trail,a),say:void 0,confidence:void 0}),o}case"refused":return i({at:t.where,mode:"refused",say:t.say,confidence:void 0,trail:Ve(r.trail,t.where)}),o;case"asking":return i({at:t.where??r.at,mode:"asking",say:t.say,...t.confidence!==void 0?{confidence:t.confidence}:{confidence:void 0},trail:Ve(r.trail,t.where)}),o;case"said":return i({say:t.say,...t.confidence!==void 0?{confidence:t.confidence}:{confidence:void 0},...t.caption?{caption:t.caption}:{}}),o;case"over":return i({over:t.over}),o;case"home":return i({at:null,mode:"docked",trail:[],say:void 0,confidence:void 0,over:null}),o;default:return o}}var yn="graview:session";function gn(e){let t=()=>typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID().slice(0,8):Math.random().toString(36).slice(2,10);try{let n=e??sessionStorage,o=n.getItem(yn);if(o)return o;let r=t();return n.setItem(yn,r),r}catch{return t()}}var Ze={name:"share-where",title:"Where you are",description:"Whether the others here see which stop you are on.",honored:"root-attribute",options:[{value:"shared",label:"Shown"},{value:"private",label:"Hidden"}],initial:"shared"},et={name:"share-over",title:"What you point at",description:"Whether the others see the thing under your pointer, outlined in your color.",honored:"root-attribute",options:[{value:"private",label:"Kept to yourself"},{value:"shared",label:"Outlined for others"}],initial:"private"},mn=[Ze,et],So=800;function hn(e){let{channel:t,store:n,view:o,principal:r,session:i,robots:a,seatWho:u,settingValues:l,setView:c,ttlMs:f=1e4,people:g,seats:p}=e,[m,S]=(0,O.useState)(()=>new Map),[k,h]=(0,O.useState)(null),[v,w]=(0,O.useState)(null),[x,R]=(0,O.useState)(null),N=typeof r.id=="string"&&r.id.length>0,V=N&&(l[Ze.name]??Ze.initial)==="shared",W=V&&(l[et.name]??et.initial)==="shared",M=Xe({kind:r.kind,...r.id?{id:r.id}:{},session:i}),b=N?Ft(r,{graph:n.graph,schema:n.schema,...p?{seats:p}:{},...g?{people:g}:{}}):"",A=u?a.get(`agent:${u}:${i}`):void 0,L=(0,O.useMemo)(()=>!t||!V?null:{participant:M,kind:r.kind,name:b,...r.onBehalfOf?.id?{onBehalfOf:r.onBehalfOf.id,...r.onBehalfOf.name?{onBehalfOfName:r.onBehalfOf.name}:{}}:{},hue:jt(r.id??"nobody"),stop:x??U(o),...W?{over:k}:{},...A?{robot:{at:A.at,mode:A.mode}}:{},at:new Date().toISOString()},[t,V,W,M,b,r.id,r.kind,r.onBehalfOf?.id,r.onBehalfOf?.name,o,x,k,A?.at,A?.mode]);(0,O.useEffect)(()=>{if(!t||!L)return;t.here(L);let T=setInterval(()=>t.here({...L,at:new Date().toISOString()}),So);return()=>clearInterval(T)},[t,L]),(0,O.useEffect)(()=>t?t.onWho(D=>S(Ke(new Map,D,Date.now(),f))):void 0,[t,f]);let we=m.size>0;(0,O.useEffect)(()=>{if(!we)return;let T=setInterval(()=>{S(D=>{let K=Ke(D,[],Date.now(),f);return K.size===D.size?D:K})},Math.max(250,Math.min(1e3,f/4)));return()=>clearInterval(T)},[we,f]),(0,O.useEffect)(()=>{if(!t||typeof window>"u")return;let T=()=>t.leave();return window.addEventListener("pagehide",T),()=>window.removeEventListener("pagehide",T)},[t]),(0,O.useEffect)(()=>{if(!W||typeof document>"u")return;let T=null,D=K=>{let Z=pn(K.target);Z!==T&&(T=Z,h(Z))};return document.addEventListener("pointermove",D,{passive:!0}),()=>document.removeEventListener("pointermove",D)},[W]);let Q=(0,O.useRef)(null),H=v?m.get(v)??null:null,J=(0,O.useCallback)(T=>{Q.current=null,w(T)},[]);return(0,O.useEffect)(()=>{if(v){if(!H){w(null);return}H.stop!==Q.current?.stop&&(Q.current={stop:H.stop,at:Date.now()},c(Ee(H.stop)))}},[v,H,c]),(0,O.useEffect)(()=>{let T=Q.current;!v||T===null||Date.now()-T.at<400||Qt(o,Ee(T.stop))||w(null)},[o,v]),(0,O.useEffect)(()=>{if(!v||typeof document>"u")return;let T=D=>{D.key==="Escape"&&w(null)};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[v]),(0,O.useMemo)(()=>({who:m,sharing:L?{participant:M,name:b}:null,following:H,follow:J,sayWhere:R}),[m,L,M,b,H,J])}var B=C(F(),1);function wn(e){return Se(e.author)}function vo(e,t){return e.length>1?"co-edited":t==="rule"?"rule":t==="agent"?"autonomous":"directed"}function Sn(e,t,n,o,r){let i=new Map;for(let[l,c]of e)o-c.at<r&&i.set(l,c);let a=new Set(n.flatMap(l=>l.nodeIds)),u=(l,c,f)=>{let g=i.get(l),p=g?.participants.includes(wn(c))?g.participants:[...g?.participants??[],wn(c)];i.set(l,{at:o,manner:vo(p,c.author.kind),intent:c.intent,wrote:(g?.wrote??!1)||(f.wrote??!1),read:(g?.read??!1)||(f.read??!1),broke:(g?.broke??!1)||a.has(l),participants:p})};for(let l of t){for(let c of l.writes)u(c,l,{wrote:!0});for(let c of l.reads)l.writes.includes(c)||u(c,l,{read:!0})}for(let l of n)for(let c of l.nodeIds){let f=i.get(c);i.set(c,{at:o,manner:f?.manner??"rule",intent:f?.intent??l.message,wrote:f?.wrote??!1,read:f?.read??!1,broke:!0,participants:f?.participants??["rule::"]})}return i}var bo=2600;function vn(e,t=bo){let[n,o]=(0,B.useState)(()=>new Map),r=(0,B.useRef)(n);r.current=n;let i=(0,B.useRef)(null),a=(0,B.useCallback)(l=>{r.current=l,o(l),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{r.current=new Map,o(new Map)},t)},[t]);(0,B.useEffect)(()=>{let l=e.violations(),c=e.subscribe((f,g)=>{let p=e.violations(),m=$t(e.allInvariants(),l,p).introduces;l=p,a(Sn(r.current,g,m.map(S=>({nodeIds:S.nodeIds,message:S.message})),Date.now(),t))});return()=>{c(),i.current&&clearTimeout(i.current)}},[e,t,a]);let u=(0,B.useCallback)(l=>{l.reads.length!==0&&a(Sn(r.current,[xo(l)],[],Date.now(),t))},[t,a]);return{activity:n,noteAttention:u}}function xo(e){return{id:`attention:${e.intent}`,seq:-1,batch:"attention",author:e.author,intent:e.intent,mutation:null,primitives:[],inverse:[],reads:e.reads,writes:[],at:new Date().toISOString()}}var s=C(F(),1);function bn(){let e=null,t=new Set,n=new Set,o=r=>{for(let i of n)i(r)};return{subscribe(r){return t.add(r),t.size===1&&o(!0),()=>{t.delete(r),t.size===0&&(e=null,o(!1))}},snapshot:()=>e,set(r){if(!(e===r||e&&r&&e.x===r.x&&e.y===r.y)){e=r;for(let i of t)i()}},get listeners(){return t.size},onActive(r){return n.add(r),()=>void n.delete(r)}}}function xn(){let e=!1,t=new Set;return{moving:()=>e,set(n){if(n!==e){e=n;for(let o of t)o()}},subscribe(n){return t.add(n),()=>t.delete(n)}}}var re=C(ve(),1),Ie=(0,s.createContext)(null),Pn=(0,s.createContext)("scene");function Eo({mode:e,children:t}){return(0,re.jsx)(Pn.Provider,{value:e,children:t})}function Ro(){return(0,s.useContext)(Pn)}var Mn={kind:"human"},Po=[],Mo=[],Ao=[],tt=[];function An(e,t){let n=(0,s.useId)();(0,s.useEffect)(()=>{if(!globalThis.__graviewWatch)return;let o=t??Mn,r=()=>{qt(e,o,n),Ut(e)};r();let i,a=e.subscribe(()=>{clearTimeout(i),i=setTimeout(r,250)});return()=>{clearTimeout(i),a(),globalThis.__graviewWatch?.unseen?.({words:[],from:n,gone:!0})}},[e,t,n])}function ko({store:e,views:t,initialView:n,scheme:o="dark",initialSelection:r,principal:i,seats:a=Po,onSeat:u,people:l=Mo,memory:c,presenceTtlMs:f,app:g,settings:p=g?.settings??Ao,presence:m,brand:S,onKeepLens:k,providers:h,ai:v=Qe,files:w,view:x,onViewChange:R,children:N}){let[V,W]=(0,s.useState)(null),M=V??i??a[0]?.principal??Mn,b=(0,s.useMemo)(()=>e.seenBy(M),[e,M]);An(e,M);let[A]=(0,s.useState)(()=>gn(c)),[L,we]=(0,s.useState)(!1),Q=(0,s.useCallback)(()=>we(!0),[]),H=(0,s.useMemo)(()=>m?[...p,...mn]:p,[p,m]),[J]=(0,s.useState)(()=>n??ot(t,e.schema)),[T,D]=(0,s.useState)(()=>Pe(J??te,r??J?.selection??[])),K=(0,s.useRef)(J??te).current,[Z,Fn]=(0,s.useState)(null),[ft,Gn]=(0,s.useState)(null),De=(0,s.useContext)(Ie),[yt]=(0,s.useState)(()=>De?.seatTalk??Ye(S?.name??e.schema.kinds.join(","))),We=k??De?.onKeepLens,gt=g??De?.app,mt=(0,s.useRef)(null),ht=(0,s.useCallback)(d=>{mt.current=d},[]),wt=(0,s.useCallback)(d=>mt.current?.whereIs(d)??null,[]),[St]=(0,s.useState)(()=>bn()),[vt]=(0,s.useState)(()=>xn()),[Fe,Kn]=(0,s.useState)(null),[de,bt]=(0,s.useState)(()=>new Map),ce=(0,s.useRef)(de);ce.current=de;let ue=(0,s.useRef)(null),Ge=(0,s.useCallback)(d=>b.graph.getNode(d)?.kind,[b]),q=(0,s.useCallback)(d=>{let y=Je(ce.current,d,Ge);ce.current=y,bt(y),ue.current&&clearTimeout(ue.current),[...y.values()].some(P=>P.mode!=="docked"&&P.mode!=="asking")&&(ue.current=setTimeout(()=>{let P=Je(ce.current,{type:"rest",at:Date.now(),holdMs:nt},Ge);ce.current=P,bt(P)},nt+20))},[Ge]),xt=(0,s.useCallback)(d=>q({...d,at:d.at??Date.now()}),[q]),Et=(0,s.useCallback)(d=>{Kn(d),d&&q({type:"home",author:{kind:"agent",id:d,session:A},at:Date.now()})},[q,A]);(0,s.useEffect)(()=>b.subscribe((d,y)=>{for(let E of y)E.author.kind==="agent"&&q({type:"write",author:E.author,ids:E.writes,at:Date.now()})}),[b,q]),(0,s.useEffect)(()=>()=>{ue.current&&clearTimeout(ue.current)},[]);let z=(0,s.useMemo)(()=>({...M,session:A}),[M,A]),Rt=(0,s.useCallback)(d=>{W(d),u?.(d)},[u]),[pe,Bn]=(0,s.useState)(()=>Object.fromEntries(H.map(d=>[d.name,dn(d,c)])));(0,s.useEffect)(()=>{for(let d of H)un(d,pe[d.name]??d.initial)},[H,pe]);let Pt=(0,s.useCallback)((d,y)=>{let E=H.find(P=>P.name===d);!E||!E.options.some(P=>P.value===y)||(cn(E,y,c),Bn(P=>({...P,[d]:y})))},[H,c]),[Mt,jn]=(0,s.useState)(null),{activity:At,noteAttention:kt}=vn(b),Tt=(0,s.useCallback)(d=>{kt(d),q({type:"read",author:d.author,ids:d.reads,at:Date.now()})},[kt,q]),ee=(0,s.useCallback)(d=>{if(ne(d)!==null||X(d).length>0||qe(d))return!0;let y=Xt(d);return y?b.graph.allEdges().some(E=>E.kind===y.kind&&E.from===y.from&&E.to===y.to):b.graph.getNode(d)!==void 0},[b]),Ot=(0,s.useCallback)(d=>{let y=d.selection??tt,E=y.filter(ee),P=E.length===y.length?d:Pe(d,E);return P.focusId!==null&&!ee(P.focusId)&&(P=$(P,null)),P},[ee]),fe=(0,s.useCallback)(d=>{let y=Ot(d),E=Rn(b,z,y.shown);if(y.focusId!==null&&E.size>0){let P=X(y.focusId),Wt=b.graph.getNode(y.focusId);(P.length>0?P.every(Un=>E.has(Un)):Wt?E.has(Wt.kind):!1)&&(y={...y,focusId:null})}if(!y.overview&&y.focusId===null){let P=K.focusId!==null&&!ee(K.focusId)?ot(t,e.schema)??{...te,overview:!0}:K;P.focusId!==null&&ee(P.focusId)?y={...y,focusId:P.focusId}:P.overview===!0&&(y={...y,overview:!0})}return y},[Ot,ee,b,K,z,t,e.schema]),G=fe(x??T),Vt=(0,s.useMemo)(()=>Rn(b,z,G.shown),[b,z,G.shown]),It=(0,s.useMemo)(()=>[...b.modules.administered.entries()].map(([d,y])=>{let E=b.mayAdminister(d,z);return{name:d,...y.description?{description:y.description}:{},kinds:y.kinds??[],canShow:E,shown:E&&(G.shown??[]).includes(d)}}),[b,z,G.shown]),ye=(0,s.useCallback)(d=>{let y=E=>fe(typeof d=="function"?d(E):d);if(x!==void 0){R?.(y(x));return}R&&R(y(G)),D(E=>y(E))},[G,R,x,fe]);(0,s.useEffect)(()=>{x===void 0&&D(d=>{let y=fe(d);return y===d?d:y})},[G,x,fe]);let Lt=G.selection??tt,Ct=(0,s.useCallback)(d=>{ye(y=>Pe(y,typeof d=="function"?d(y.selection??tt):d))},[ye]),{who:_t,following:Nt,follow:Ht,sayWhere:zn,sharing:Dt}=hn({channel:m,store:b,view:G,principal:z,session:A,robots:de,seatWho:Fe,settingValues:pe,setView:ye,seats:a,people:l,...f!==void 0?{ttlMs:f}:{}}),qn=(0,s.useMemo)(()=>({store:b,scheme:o,views:t,view:G,setView:ye,homeView:K,selection:Lt,setSelection:Ct,menuAt:Z,setMenuAt:Fn,whereIs:wt,pointer:St,motion:vt,registerScene:ht,robots:de,noteSeat:xt,seatWho:Fe,registerSeatWho:Et,actsDoor:ft,registerActsDoor:Gn,seatTalk:yt,...c?{memory:c}:{},who:_t,following:Nt,follow:Ht,sayWhere:zn,sharing:Dt,session:A,ai:v,movedByHand:L,noteMoved:Q,emphasis:Mt,setEmphasis:jn,activity:At,noteAttention:Tt,principal:z,seats:a,people:l,takeSeat:Rt,settings:H,settingValues:pe,chooseSetting:Pt,hiddenKinds:Vt,administered:It,...h?{providers:h}:{},...S?{brand:S}:{},...We?{onKeepLens:We}:{},app:gt}),[b,o,t,G,ye,Lt,Ct,Z,wt,St,vt,ht,de,xt,Fe,Et,ft,yt,c,_t,Nt,Ht,Dt,A,v,L,Q,Mt,At,Tt,z,a,l,Rt,H,pe,Pt,Vt,It,h,S,We,gt]);return(0,re.jsx)(Ie.Provider,{value:qn,children:(0,re.jsx)(To,{children:w?(0,re.jsx)(Oe.Provider,{value:w,children:N}):N})})}var kn=(0,s.createContext)(null);function To({children:e}){let{store:t,view:n,views:o,principal:r,hiddenKinds:i,selection:a}=Y(),u=Le(),l=n.q,c=n.focusId,f=!!(l&&l.trim().length>0),g=(0,s.useMemo)(()=>f?{flagged:new Set(t.violations().flatMap(S=>S.nodeIds)),touched:Kt(t.log.all())}:null,[t,u,f]),p=c?t.graph.getNode(c)?.kind??ne(c)??(X(c).length===1?X(c)[0]:void 0):void 0,m=(0,s.useMemo)(()=>!l||!g?null:Bt(t,l,{...p?{inKind:p}:{},principal:r,places:o.places(),kinds:t.schema.kinds.filter(S=>!i.has(S)),from:[...a,...c&&t.graph.has(c)?[c]:[]],flagged:g.flagged,touched:g.touched,limit:200}),[t,l,r,o,i,a,c,p,g]);return(0,re.jsx)(kn.Provider,{value:m,children:e})}var En=new WeakMap;function ri(e){let t=En.get(e);return t||En.set(e,t=new Set(e.matched)),t}function Oo(){return(0,s.useContext)(kn)}function Y(){let e=(0,s.useContext)(Ie);if(!e)throw new Error("useGraview must be used inside a <GraviewProvider>.");return e}function Vo(){return(0,s.useContext)(Ie)??null}function Le(){let{store:e}=Y(),t=(0,s.useRef)(null),n=(0,s.useRef)(null),o=(0,s.useCallback)(()=>(n.current!==e&&(n.current=e,t.current=null),t.current??=e.graph.allNodes(),t.current),[e]),r=(0,s.useCallback)(i=>e.subscribe(()=>{t.current=null,i()}),[e]);return(0,s.useSyncExternalStore)(r,o,o)}function Io(e){let{store:t}=Y(),n=(0,s.useCallback)(r=>t.subscribe(r),[t]),o=(0,s.useCallback)(()=>e===null?void 0:t.graph.getNode(e),[t,e]);return(0,s.useSyncExternalStore)(n,o,o)}function Rn(e,t,n){let o=new Set(e.modules.disabledKinds);for(let r of e.kindsKeptFrom(t))o.add(r);for(let[r,i]of e.modules.administered)if(!(e.mayAdminister(r,t)&&(n??[]).includes(r)))for(let a of i.kinds??[])o.add(a);return o}var nt=2600;function ot(e,t){let n=Yt(e.arrangement?.()?.first,t,e.places());if(!(!n||n.to==="home"))return n.to==="place"?{...te,focusId:oe(n.place.kind),within:{view:n.place.as}}:{...te,focusId:oe(n.kind)}}var Ce=Symbol.for("graview.default-view");function Tn(e){return Object.defineProperty(e,Ce,{value:!0,enumerable:!1}),e}function On(e){return typeof e=="function"&&e[Ce]===!0}var rt=Symbol.for("graview.replaces-page");function Vn(e){return typeof e=="function"&&e[rt]===!0}function Co(e){return Gt(e)}function _o(e,t){if(t===e)return e;for(let r of t.registrations()){let i={...r.title?{title:r.title}:{},...r.across?{across:r.across}:{},...r.beside?{beside:!0}:{}};e.register(r.kind,{cardinality:r.cardinality,fidelity:r.fidelity},r.view,i)}let n=t.arrangement?.();n&&e.arrange?.(n);let o=t.homeView?.();return o&&e.home?.(o),e}var ae=C(F(),1);function No(){let{selection:e,setSelection:t}=Y();return(0,ae.useMemo)(()=>({selection:e,set:n=>t(n),clear:()=>t([]),toggle:n=>t(o=>o.includes(n)?o.filter(r=>r!==n):[...o,n]),isSelected:n=>e.includes(n)}),[e,t])}function Ho(){let{store:e}=Y(),t=Le();return(0,ae.useMemo)(()=>Do(e),[e,t])}var In=new WeakMap;function Do(e){let t=In.get(e);if(!t){let n={violations:null};e.subscribe(()=>{n.violations=null}),In.set(e,n),t=n}return t.violations??=e.violations(),t.violations}function Wo(){let{view:e,setView:t}=Y();return(0,ae.useMemo)(()=>({view:e,url:U(e),focus:n=>t(o=>$(o,n)),show:n=>t(o=>Jt(o,n)),toggle:n=>t(o=>Me(o,n)),go:n=>t(n)}),[e,t])}var ie={at:0,depth:0,listeners:new Set,tell(){for(let e of this.listeners)e()}};typeof window<"u"&&window.addEventListener("popstate",e=>{let t=e.state;ie.at=typeof t?.graview=="number"?t.graview:0,ie.at>ie.depth&&(ie.depth=ie.at),ie.tell()});var I=C(F(),1),at={profile:{trigger:"profile-button",pane:"profile",opens:"press",focus:"into",drawn:["shell","embed"]},problems:{trigger:"standing",pane:"problems",opens:"press",focus:"into",drawn:["shell","embed"]},places:{trigger:"app-places-open",pane:"app-places",opens:"press",focus:"into",drawn:["embed"]},here:{trigger:"here-open",pane:"here-list",opens:"press",focus:"into",drawn:["shell","embed","pages"]},activity:{trigger:"activity-button",pane:"activity",opens:"press",focus:"into",drawn:["shell","embed","pages"]},find:{trigger:"find-box",pane:"find-strip",opens:"typing",focus:"stays",drawn:["shell"]},districts:{trigger:"beyond-more",pane:"beyond-list",opens:"press",focus:"into",drawn:["shell","embed"]},acts:{trigger:null,pane:"context-menu",opens:"context-menu",focus:"into",drawn:["shell","embed"]},arrange:{trigger:"arrange-add",pane:"arrange-list",opens:"press",focus:"into",drawn:["pages"]},"studio-ask":{trigger:"studio-agent",pane:"studio-agent-panel",opens:"press",focus:"into",drawn:["studio"]}},Fo={position:"fixed",inset:"auto",margin:0,zIndex:zt("popover"),boxSizing:"border-box"},_e=6,se=8,Go=e=>typeof e.showPopover=="function";function Ne(e){try{return e.matches(":popover-open")}catch{return!1}}function Ko(e){if(typeof e=="function"){let o=e();return o?{left:o.x,right:o.x,top:o.y,bottom:o.y}:null}let t=e.current;if(!t||!t.isConnected)return null;let n=t.getBoundingClientRect();return{left:n.left,right:n.right,top:n.top,bottom:n.bottom}}function st(e,t,n={}){let o=Ko(t);if(!o)return;let r={width:document.documentElement.clientWidth||innerWidth,height:innerHeight},i=e.dataset.graviewDesignedHeight??=e.style.maxHeight;e.style.maxHeight=i;let a=e.getBoundingClientRect(),u=r.height-o.bottom-_e-se,l=o.top-_e-se,c=a.height<=u||u>=l,f=Math.max(96,Math.floor(c?u:l)),g=Math.min(a.height,f);a.height>f&&(e.style.maxHeight=i?`min(${i}, ${f}px)`:`${f}px`);let p=a.width,m=n.align==="start"?o.left:o.right-p,S=typeof t=="function"?null:t.current?.closest("[data-graview-embed]")?.getBoundingClientRect();S&&p<=S.right-S.left&&(m<S.left?m=o.left+p<=S.right?o.left:S.left:m+p>S.right&&(m=o.right-p>=S.left?o.right-p:S.right-p));let k=p>=r.width-2*se?Math.max(0,(r.width-p)/2):Math.max(se,Math.min(m,r.width-se-p)),h=c?o.bottom+_e:Math.max(se,o.top-_e-g);e.style.left=`${Math.round(k)}px`,e.style.top=`${Math.round(h)}px`}function Ln(e,t,n,o={}){let r=o.align??"end";(0,I.useLayoutEffect)(()=>{let i=e.current;if(!t||!i)return;if(Go(i)&&!Ne(i))try{i.showPopover(),jo()}catch{}let a=0,u=c=>{c?.target instanceof Node&&i.contains(c.target)||(cancelAnimationFrame(a),a=requestAnimationFrame(()=>st(i,n,{align:r})))};st(i,n,{align:r}),addEventListener("resize",u),addEventListener("scroll",u,!0);let l=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>u());return l?.observe(i),()=>{if(cancelAnimationFrame(a),removeEventListener("resize",u),removeEventListener("scroll",u,!0),l?.disconnect(),i.isConnected&&Ne(i))try{i.hidePopover()}catch{}}},[t,e,r])}var lt=new Set;function Bo(e){return lt.add(e),()=>lt.delete(e)}function jo(){for(let e of lt)if(!(!e.isConnected||!Ne(e)))try{e.hidePopover(),e.showPopover()}catch{}}var le=null,zo='button:not([disabled]), [href], input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex="-1"])';function qo(e){for(let t of e.querySelectorAll(zo))if(t.closest("[hidden]")===null&&getComputedStyle(t).visibility!=="hidden")return t;return e}var it=()=>{let e=document.activeElement;return e===null||e===document.body};function Uo(e,t={}){let{at:n,returnTo:o,onOpenChange:r}=t,i=t.popover!==!1,[a,u]=(0,I.useState)(!1),l=t.open??a,c=(0,I.useRef)(null),f=(0,I.useRef)(null),g=(0,I.useCallback)(w=>{c.current=w},[]),p=(0,I.useCallback)(w=>{f.current=w},[]),m=`graview-popover-${(0,I.useId)().replace(/:/g,"")}`,S=(0,I.useRef)({onOpenChange:r,returnTo:o,controlled:t.open!==void 0});S.current={onOpenChange:r,returnTo:o,controlled:t.open!==void 0};let k=(0,I.useCallback)(w=>{S.current.controlled||u(w),S.current.onOpenChange?.(w)},[]),h=(0,I.useCallback)(()=>{(document.querySelector(`[aria-controls="${m}"]`)??c.current??S.current.returnTo?.()??null)?.focus({preventScroll:!0})},[m]),v=(0,I.useCallback)(w=>{let x=f.current,R=typeof document>"u"?null:document.activeElement,N=R===null||R===document.body||x!==null&&x.contains(R);k(!1),!(!w||!N)&&(h(),requestAnimationFrame(()=>{it()&&h()}))},[k,h]);return Ln(f,i&&l,n??c,t.align?{align:t.align}:{}),(0,I.useEffect)(()=>{if(!i||!l)return;let w={name:e,close:()=>v(!1)};if(le&&le.close!==w.close&&le.close(),le=w,at[e].focus==="into"){let M=f.current;M&&!M.contains(document.activeElement)&&qo(M).focus({preventScroll:!0})}let x=M=>{M.key==="Escape"&&v(!0)},R=M=>{let b=M.target;if(!(b instanceof Node))return;let A=f.current;if(A?.contains(b)||c.current?.contains(b))return;let L=b instanceof Element?b.closest('[role="dialog"], [role="alertdialog"]'):null;L&&!(A&&L.contains(A))||(v(!1),at[e].focus==="into"&&requestAnimationFrame(()=>{(it()||A!==null&&A.contains(document.activeElement))&&h()}))},N=null,V=null,W=M=>{let b=M.target;if(!(b instanceof Element))return;let A=f.current,L=b.closest('[role="dialog"], [role="alertdialog"]');!L||A&&(A.contains(L)||L.contains(A))||(N=L,v(!1))};return document.addEventListener("keydown",x),document.addEventListener("pointerdown",R,!0),document.addEventListener("focusin",W),()=>{document.removeEventListener("keydown",x),document.removeEventListener("pointerdown",R,!0),document.removeEventListener("focusin",W);let M=N;M&&typeof MutationObserver<"u"&&(V?.disconnect(),V=new MutationObserver(()=>{M.isConnected||(V?.disconnect(),requestAnimationFrame(()=>{(it()||document.activeElement.closest("[hidden]")!==null)&&h()}))}),V.observe(document.body,{childList:!0,subtree:!0}),setTimeout(()=>V?.disconnect(),10*6e4)),le?.close===w.close&&(le=null)}},[i,l,e,v,h]),{open:l,setOpen:w=>w?k(!0):v(!0),toggle:()=>l?v(!0):k(!0),trigger:{ref:g,"aria-expanded":l,"aria-controls":m,"data-graview-popover-trigger":e},pane:{ref:p,id:m,popover:"manual",tabIndex:-1,"data-graview-popover":e,"data-graview-overlay":""}}}var _=C(F(),1),j=C(ve(),1),dt=new Set,Cn=!1;function ct(){for(let e of[...dt])e()}function $o(){Cn||typeof window>"u"||(Cn=!0,window.addEventListener("online",ct))}function Yo(e){let t,n=!1,o=!1,r,i=0,a=new Set,u=()=>{i+=1;for(let p of[...a])p()},l=p=>(a.add(p),()=>void a.delete(p)),c=()=>i,f=()=>void g().catch(()=>{});function g(){if(n)return Promise.resolve(t);if(r)return r;let p=e().then(m=>(t=m,n=!0,o=!1,r=void 0,dt.delete(f),u(),m),m=>{throw r=void 0,o=!0,dt.add(f),$o(),u(),m});return p.catch(()=>{}),r=p,p}return{load:g,prefetch:f,get current(){return t},get failed(){return o},part(p,m={}){let S=m.what??"This part";function k(w){(0,_.useSyncExternalStore)(l,c,c);let x=(0,_.useRef)(null),R=(0,_.useRef)(null),N=(0,_.useRef)(!1);return(0,_.useEffect)(()=>{o&&r===void 0&&f()},[]),n&&typeof document<"u"&&x.current!==null&&document.activeElement===x.current&&(N.current=!0),(0,_.useLayoutEffect)(()=>{if(!(!n||!N.current)){N.current=!1;for(let V=R.current?.nextElementSibling??null;V!==null;V=V.nextElementSibling){let W=V.matches(_n)?V:V.querySelector(_n);if(W instanceof HTMLElement){W.focus();return}}}}),n?(0,j.jsxs)(j.Fragment,{children:[N.current?(0,j.jsx)("span",{ref:R,hidden:!0}):null,p(t,w)]}):m.quiet?null:(0,j.jsx)(Qo,{what:S,button:x,...m.as?{as:m.as}:{}})}let h=(0,_.lazy)(()=>g().then(()=>({default:k}),()=>({default:k})));function v(w){let[x]=(0,_.useState)(()=>n||o);return(0,_.createElement)(x?k:h,w)}return v}}}var _n="button,a[href],input,select,textarea,[tabindex]:not([tabindex='-1'])";function Qo({what:e,button:t,as:n="p"}){let r=typeof navigator<"u"&&navigator.onLine===!1?`${e} will load when you're back online.`:`${e} didn't load.`;return(0,j.jsxs)(n,{"data-testid":"lazy-part-missing",style:{margin:0,fontSize:"0.875rem",color:"var(--graview-ink-muted)"},children:[(0,j.jsx)("span",{role:"status",children:r})," ",(0,j.jsx)("button",{ref:t,type:"button","data-testid":"lazy-part-retry",onClick:ct,style:{font:"inherit",fontWeight:600,color:"var(--graview-ink)",background:"none",border:"1px solid var(--graview-edge)",borderRadius:6,padding:"2px 10px"},children:"Try again"})]})}var He=C(F(),1);var Xo=(0,He.createContext)(null);var Nn=C(F(),1),Jo=(0,Nn.createContext)(!1);var Hn=C(F(),1),Zo=(0,Hn.createContext)(null);var Dn=C(F(),1),ut='button:not([disabled]), a[href], input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex="-1"])',pt=e=>e instanceof HTMLElement&&(e.matches(ut)||e.hasAttribute("tabindex")),he=e=>typeof e.checkVisibility=="function"?e.checkVisibility():e.getClientRects().length>0;function er(e,t){let n=l=>l.replace(/["\\]/g,"\\$&"),o=t.getAttribute("data-testid"),r=t.getAttribute("data-graview-pick"),i=t.getAttribute("aria-label"),a=o?`[data-testid="${n(o)}"]`:r?`[data-graview-pick="${n(r)}"]`:i?`${t.tagName.toLowerCase()}[aria-label="${n(i)}"]`:null;if(!a)return null;let u=e.querySelector(a);return u&&pt(u)&&he(u)?u:null}var tr=e=>e.isConnected&&pt(e)&&!e.matches(":disabled")&&e instanceof HTMLElement&&he(e);function Wn(e,t){let n=t?er(e,t):null;if(n)return n;let o=e.querySelector("[data-graview-view][tabindex]");if(o&&he(o))return o;for(let r of e.querySelectorAll(ut))if(he(r))return r;return pt(e)&&he(e)?e:null}function nr(e){(0,Dn.useEffect)(()=>{let t=e.current;if(!t||typeof MutationObserver>"u")return;let n=[],o=h=>{let v=h.target;if(v instanceof Element){n=[];for(let w=v;w&&w!==t.parentElement;w=w.parentElement)n.push(w)}},r=!1,i=!1,a=t.ownerDocument,u=()=>!i&&a.defaultView!==null,l=(h,v)=>void setTimeout(()=>u()&&v(),h),c=h=>void requestAnimationFrame(()=>u()&&h()),f=h=>{if(r=!1,i)return;let v=a.activeElement;if(!(!(v===null||v===a.body||v===a.documentElement)||n.length===0)){if(tr(n[0])){h&&n[0]instanceof HTMLElement&&n[0].focus({preventScroll:!0});return}for(let x of n.slice(1)){if(!x.isConnected)continue;let R=Wn(x,n[0]);if(R){R.focus({preventScroll:!0}),n=[];return}}}},g=(h,v=Date.now()+2500)=>{l(100,()=>{f(h);let w=a.activeElement;(w===null||w===a.body||w===a.documentElement)&&n.length>0&&Date.now()<v&&g(h,v)})},p=()=>{r||n.length===0||(r=!0,l(60,()=>c(()=>{f(!1),g(!1)})))},m=h=>{if(!(h instanceof KeyboardEvent&&!["Enter"," ","Escape"].includes(h.key))){if(!(h instanceof KeyboardEvent)){let v=h.target instanceof Element?h.target.closest(ut):null,w=a.activeElement,x=w===null||w===a.body||w===a.documentElement;if(v&&x&&t.contains(v)){n=[];for(let R=v;R&&R!==t.parentElement;R=R.parentElement)n.push(R);l(150,()=>c(()=>{f(!1),g(!1)}));return}}!(h instanceof KeyboardEvent)&&!(h.target instanceof Node&&n[0]?.contains(h.target))||l(150,()=>c(()=>{f(!0),g(!0)}))}},S=new MutationObserver(()=>{n.length>0&&!n[0].isConnected&&p()}),k=h=>{h.relatedTarget===null&&p()};return t.addEventListener("focusin",o),t.addEventListener("focusout",k),t.addEventListener("click",m),t.addEventListener("keydown",m),S.observe(t,{childList:!0,subtree:!0}),()=>{i=!0,t.removeEventListener("focusin",o),t.removeEventListener("focusout",k),t.removeEventListener("click",m),t.removeEventListener("keydown",m),S.disconnect()}},[e])}export{te as a,U as b,Ee as c,rr as d,ir as e,Qt as f,ar as g,Xt as h,$ as i,Jt as j,ge as k,je as l,sr as m,Yn as n,lr as o,dr as p,Pe as q,me as r,Me as s,cr as t,ur as u,pr as v,ke as w,ze as x,ne as y,gr as z,Qn as A,oe as B,Zt as C,X as D,en as E,Xn as F,mr as G,tn as H,qe as I,Ue as J,to as K,nn as L,no as M,rn as N,oo as O,ro as P,io as Q,fo as R,yo as S,Ye as T,co as U,uo as V,pn as W,Oe as X,po as Y,Eo as Z,Ro as _,An as $,ko as aa,ri as ba,Oo as ca,Y as da,Vo as ea,Le as fa,Io as ga,ot as ha,Xo as ia,Tn as ja,On as ka,Vn as la,Co as ma,_o as na,Jo as oa,Zo as pa,No as qa,Ho as ra,Wo as sa,ie as ta,nr as ua,Fo as va,Ne as wa,Bo as xa,Uo as ya,Yo as za};
@@ -1 +1 @@
1
- import{b as a}from"./chunk.JCZH55RX.js";import{l as i}from"./chunk.2WFEFZAW.js";import{Ba as o}from"./chunk.RAE4M3KQ.js";function p(r){let t=r.within??{};return o({...t.sort?{sort:t.sort}:{},...t.filter?{filter:t.filter}:{},...t.group?{group:t.group}:{},...t.q?{q:t.q}:{}})}function s(r,t){let m=a(t),e=r;for(let n of["sort","filter","group","q"])e=i(e,n,m[n]??null);return e}export{p as a,s as b};
1
+ import{b as a}from"./chunk.QZWN46V6.js";import{k as i}from"./chunk.OYULDOQP.js";import{Ia as o}from"./chunk.VMEX2KZ4.js";function p(r){let t=r.within??{};return o({...t.sort?{sort:t.sort}:{},...t.filter?{filter:t.filter}:{},...t.group?{group:t.group}:{},...t.q?{q:t.q}:{}})}function s(r,t){let m=a(t),e=r;for(let n of["sort","filter","group","q"])e=i(e,n,m[n]??null);return e}export{p as a,s as b};
@@ -0,0 +1 @@
1
+ import{h as ae}from"./chunk.XDHBV5K5.js";import"./chunk.WVUJXDXZ.js";import{b as $,c as ne}from"./chunk.UMMN5Z6V.js";import"./chunk.DG2WKNMX.js";import"./chunk.HPD3DSTP.js";import"./chunk.VD6FJ6KJ.js";import"./chunk.OHGJ5BZ4.js";import"./chunk.6R4EI47C.js";import{Y as X,da as ee,ga as te}from"./chunk.OYULDOQP.js";import{Fb as Y,H as J,I as v,J as j,Y as Q}from"./chunk.VMEX2KZ4.js";import{a as we,b as Z}from"./chunk.MRK6QJV5.js";import{b as B}from"./chunk.AJZBJBMO.js";var g=B(we(),1);async function re(e,i){let r=await createImageBitmap(e);try{let l=Math.min(1,i/Math.max(r.width,r.height)),o=document.createElement("canvas");o.width=Math.max(1,Math.round(r.width*l)),o.height=Math.max(1,Math.round(r.height*l));let s=o.getContext("2d");if(s===null)throw new Error("This browser will not give us a canvas to resize with.");return s.drawImage(r,0,0,o.width,o.height),o}finally{r.close()}}var t=B(Z(),1),ve=2048,$e=.85;function H(e){return e<1e3?`${e} bytes`:e<1e6?`${Math.round(e/1e3)} KB`:`${(e/1e6).toFixed(e<1e7?1:0)} MB`}function O(e){if(e.type==="application/pdf")return"PDF";let i=/\.([a-z0-9]{2,5})$/i.exec(e.name??"")?.[1];return i?i.toUpperCase():(e.type.split("/")[1]??e.type).replace(/^x-|^vnd\./,"").split(/[.+-]/)[0].toUpperCase()}function ue(e){let i=[...new Set(e.map(r=>r==="image/*"?"pictures":r==="*/*"||r==="*"?"any file":`${O({type:r})} files`))];return i.length<=1?i[0]??"no files":`${i.slice(0,-1).join(", ")} and ${i[i.length-1]}`}function ce(e,i){if(e.length===0)return!0;let r=`${i.split("/")[0]}/*`;return e.some(l=>l==="*"||l==="*/*"||l===i||l===r)}var ie=/^image\/hei[cf]$|\.hei[cf]$/i,le=e=>ie.test(e.type)||ie.test(e.name);async function Fe(e,i,r){let l=e.name||(r.camera?"photo.jpg":"file"),o=e.type||(le({type:"",name:l})?"image/heic":"application/octet-stream"),s=le({type:o,name:l}),d=o.startsWith("image/")||s;if(r.image&&!d)return{refused:`\u201C${l}\u201D isn\u2019t a picture.`};if(s||d&&/^image\/(jpeg|webp)$/.test(o)&&(r.camera||e.size>i.maxBytes||e.size>15e5))try{let a=await re(e,ve),f=await new Promise(y=>a.toBlob(y,"image/jpeg",$e));if(f)return oe({blob:f,name:s?l.replace(/\.hei[cf]$/i,"")+".jpg":l,type:"image/jpeg",width:a.width,height:a.height},i)}catch{if(s&&!ce(i.kinds,o))return{refused:`\u201C${l}\u201D is a HEIC photo, which this browser can\u2019t turn into a JPEG and this host doesn\u2019t take. Save it as a JPEG and try again.`}}let c={};if(d&&!s)try{let a=await createImageBitmap(e);c={width:a.width,height:a.height},a.close()}catch{}return oe({blob:e,name:l,type:o,...c},i)}function oe(e,i){return ce(i.kinds,e.type)?e.blob.size>i.maxBytes?{refused:`\u201C${e.name}\u201D is ${H(e.blob.size)}; this host takes files up to ${H(i.maxBytes)}.`}:e:{refused:`\u201C${e.name}\u201D is a ${O(e)} file; this host takes ${ue(i.kinds)}.`}}async function ke(e,i,r){let l;try{l=await i.upload(e.blob,e.name)}catch(s){let d=s instanceof Error&&s.message.trim()?s.message.trim():"the host refused it";return{refused:`\u201C${e.name}\u201D wasn\u2019t kept: ${d}`}}return J(l)?r&&!v(l)?{refused:`\u201C${e.name}\u201D isn\u2019t a picture.`}:{...l,...l.width===void 0&&e.width?{width:e.width}:{},...l.height===void 0&&e.height?{height:e.height}:{}}:{refused:`The host\u2019s answer for \u201C${e.name}\u201D isn\u2019t a file a record can keep.`}}var F="var(--graview-radius, 8px)",S={color:"var(--graview-ink-muted)",fontSize:"0.8125rem"};function _({file:e,size:i=56,style:r}){return(0,t.jsx)("img",{src:e.href,alt:$(e),width:i,height:i,loading:"lazy",decoding:"async","data-graview-thumb":e.href,style:{width:i,height:i,objectFit:"cover",borderRadius:F,display:"block",flex:"none",background:"var(--graview-edge)",...r}})}function N({files:e,label:i}){let r=e.filter(v),l=e.filter(a=>!v(a)),[o,s]=(0,g.useState)(null),d=(0,g.useRef)(null),m=(0,g.useRef)(null);(0,g.useEffect)(()=>{let a=d.current;o!==null&&a&&!a.open&&a.showModal?.()},[o]);let c=o===null?void 0:r[o];return(0,t.jsxs)("div",{style:{display:"grid",gap:10,minWidth:0},children:[r.length>0?(0,t.jsx)("ul",{"data-graview-gallery":"","aria-label":i,style:{listStyle:"none",margin:0,padding:0,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(96px, 1fr))",gap:8},children:r.map((a,f)=>(0,t.jsx)("li",{style:{minWidth:0},children:(0,t.jsx)("button",{type:"button","aria-label":`Open ${$(a)} full size`,onClick:y=>{m.current=y.currentTarget,s(f)},style:{padding:0,border:0,background:"none",cursor:"zoom-in",display:"block",width:"100%",borderRadius:F},children:(0,t.jsx)("img",{src:a.href,alt:$(a),loading:"lazy",decoding:"async",style:{width:"100%",aspectRatio:"1",objectFit:"cover",borderRadius:F,display:"block",background:"var(--graview-edge)"}})})},a.href))}):null,l.length>0?(0,t.jsx)("ul",{"data-graview-documents":"",style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:10},children:l.map(a=>(0,t.jsxs)("li",{"data-graview-document":a.type,style:{display:"grid",gap:6,minWidth:0},children:[a.type==="application/pdf"?(0,t.jsx)("object",{data:a.href,type:"application/pdf","aria-label":$(a),style:{width:"100%",height:420,border:"1px solid var(--graview-edge)",borderRadius:F},children:(0,t.jsxs)("p",{style:{margin:0,padding:12},children:["This browser shows no PDF here: ",(0,t.jsxs)("a",{href:a.href,download:a.name,children:["download ",a.name]}),"."]})}):null,(0,t.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",gap:"2px 10px",alignItems:"baseline",minWidth:0,overflowWrap:"anywhere"},children:[(0,t.jsx)("a",{href:a.href,download:a.name,...a.type==="application/pdf"?{target:"_blank",rel:"noopener"}:{},children:a.name}),(0,t.jsxs)("span",{style:S,children:[O(a)," \xB7 ",H(a.bytes)]})]}),a.caption?(0,t.jsx)("span",{style:S,children:a.caption}):null]},a.href))}):null,c?(0,t.jsx)("dialog",{ref:d,"data-graview-full":c.href,"aria-label":$(c),onClose:()=>{s(null),m.current?.focus()},onClick:a=>{a.target===a.currentTarget&&a.currentTarget.close()},style:{padding:0,border:0,borderRadius:F,maxWidth:"min(96vw, 1600px)",maxHeight:"94vh",background:"var(--graview-panel)",color:"var(--graview-ink)"},children:(0,t.jsxs)("figure",{style:{margin:0,display:"grid",gap:8,padding:10},children:[(0,t.jsx)("img",{src:c.href,alt:$(c),style:{maxWidth:"100%",maxHeight:"80vh",objectFit:"contain",display:"block",margin:"0 auto"}}),(0,t.jsxs)("figcaption",{style:{display:"flex",gap:12,alignItems:"center",justifyContent:"space-between"},children:[(0,t.jsx)("span",{children:c.caption??c.name}),(0,t.jsx)("form",{method:"dialog",style:{margin:0},children:(0,t.jsx)("button",{type:"submit",autoFocus:!0,children:"Close"})})]})]})}):null]})}function ge({value:e,onChange:i,several:r,image:l,label:o,thumbs:s=!0}){let d=X(),m=(0,g.useId)(),c=(0,g.useRef)(null),a=(0,g.useRef)(null),[f,y]=(0,g.useState)(null),[k,D]=(0,g.useState)(null),[U,E]=(0,g.useState)([]),[I,L]=(0,g.useState)(!1),C=d?l?d.kinds.filter(n=>n.startsWith("image/")||n==="*"||n==="*/*"):d.kinds:[],A=d?d.kinds.length===0||C.some(n=>n.startsWith("image/")||n.startsWith("*")):!1,P=!!d&&(!l||A),G=l?r?"pictures":"a picture":r?"files":"a file",q=l?C.length>0?C.join(","):"image/*":d?.kinds.join(",")||void 0,me=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,V=(0,g.useRef)(e);V.current=e;let K=(0,g.useRef)(null),W=(0,g.useRef)(null);(0,g.useEffect)(()=>{let n=W.current;if(!n||n.from===e)return;W.current=null;let u=K.current?.children,h=u?.[Math.min(n.at,u.length-1)];((n.what==="move"?h?.querySelector("[data-graview-file-move]"):null)??h?.querySelector("[data-graview-file-remove]")??c.current?.parentElement?.querySelector("[data-graview-file-choose]"))?.focus()});let T=async(n,u)=>{if(!d||n.length===0)return;let h=r?n:n.slice(0,1),p=[],w=[];h.length<n.length&&w.push(`${o} holds one ${l?"picture":"file"}, so ${n.slice(1).map(b=>`\u201C${b.name||"the photo"}\u201D`).join(", ")} ${n.length>2?"were":"was"} left out.`),E([]),D(null);for(let b of h){y(`Sending ${b.name||"the photo"}\u2026`);let z=await Fe(b,d,{image:l,camera:u==="camera"});if("refused"in z){w.push(z.refused);continue}let x=await ke(z,d,l);"refused"in x?w.push(x.refused):[...r?V.current:[],...p].some(be=>be.href===x.href)?w.push(`\u201C${x.name}\u201D is already here.`):p.push(x)}if(y(null),E(w),p.length!==0)try{i(r?[...V.current,...p]:p.slice(-1)),D(`Added ${p.map(b=>b.name).join(", ")}.`)}catch(b){E([...w,b instanceof Error?b.message:String(b)])}},R=(n,u,h)=>{try{W.current=h?{...h,from:e}:null,i(n),D(u)}catch(p){W.current=null,E([p instanceof Error?p.message:String(p)])}},M=n=>n?Array.from(n):[],ye=n=>{let u=M(n.clipboardData?.files);!P||u.length===0||(n.preventDefault(),T(u,"pasted"))},fe=n=>{L(!1),P&&(n.preventDefault(),T(M(n.dataTransfer?.files),"dropped"))};return(0,t.jsxs)("div",{role:"group","aria-labelledby":`${m}-label`,"data-graview-file-editor":"","data-graview-dropping":I?"":void 0,onPaste:ye,onDragOver:n=>{P&&(n.preventDefault(),L(!0))},onDragLeave:()=>L(!1),onDrop:fe,style:{display:"grid",gap:8,minWidth:0,padding:I?6:0,outline:I?"2px dashed var(--graview-accent)":"none",borderRadius:F},children:[(0,t.jsx)("span",{id:`${m}-label`,style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap"},children:o}),e.length>0&&(r||e.length>1)?(0,t.jsx)("ul",{ref:K,style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:6},children:e.map((n,u)=>(0,t.jsxs)("li",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap",minWidth:0},children:[s&&v(n)?(0,t.jsx)(_,{file:n,size:40}):null,(0,t.jsx)("span",{style:{flex:"1 1 8rem",minWidth:0,overflowWrap:"anywhere"},children:n.name}),(0,t.jsx)(de,{file:n,onCaption:h=>R(e.map((p,w)=>w===u?se(p,h):p),h?`${n.name} now says \u201C${h}\u201D.`:`${n.name} says its name again.`)}),r&&u>0?(0,t.jsx)("button",{type:"button","data-graview-file-move":"","aria-label":`Move ${n.name} earlier`,onClick:()=>R(e.map((h,p)=>p===u-1?n:p===u?e[u-1]:h),`Moved ${n.name} earlier.`,{at:u-1,what:"move"}),children:"\u2191"}):null,r?(0,t.jsx)("button",{type:"button","data-graview-file-remove":"","aria-label":`Remove ${n.name}`,onClick:()=>R(e.filter((h,p)=>p!==u),`Removed ${n.name}.`,{at:u,what:"remove"}),children:"Remove"}):null]},`${u}:${n.href}`))}):e.length===1?(0,t.jsx)(de,{file:e[0],onCaption:n=>R([se(e[0],n)],n?`${e[0].name} now says \u201C${n}\u201D.`:`${e[0].name} says its name again.`)}):null,P?(0,t.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:8,alignItems:"center"},children:[(0,t.jsx)("input",{ref:c,type:"file",hidden:!0,multiple:r,...q?{accept:q}:{},"data-graview-file-input":"","aria-label":`Choose ${G}`,onChange:n=>{let u=M(n.currentTarget.files);n.currentTarget.value="",T(u,"picked")}}),(0,t.jsx)("button",{type:"button",disabled:f!==null,onClick:()=>c.current?.click(),"data-graview-file-choose":"",children:e.length>0&&!r?`Replace ${l?"the picture":"the file"}`:`Choose ${G}`}),A?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("input",{ref:a,type:"file",hidden:!0,accept:"image/*",capture:"environment","data-graview-photo-input":"","aria-label":"Take a photo",onChange:n=>{let u=M(n.currentTarget.files);n.currentTarget.value="",T(u,"camera")}}),me?(0,t.jsx)("button",{type:"button",disabled:f!==null,onClick:()=>a.current?.click(),children:"Take a photo"}):null]}):null,(0,t.jsxs)("span",{style:S,"data-graview-file-takes":"",children:["or drop or paste ",r?"them":"it"," here \xB7 ",d.kinds.length>0?ue(C.length>0?C:d.kinds):"any file",", up to ",H(d.maxBytes)]})]}):(0,t.jsx)("p",{style:{...S,margin:0},"data-graview-file-none":"",children:d?"This host doesn\u2019t take pictures, so none can be added here.":"This host doesn\u2019t take files, so none can be added here."}),(0,t.jsx)("p",{"aria-live":"polite",style:{...S,margin:0,minHeight:f||k?void 0:0},"data-graview-file-status":"",children:f??k??""}),U.length>0?(0,t.jsx)("div",{role:"alert","data-graview-file-refused":"",style:{color:"var(--graview-warn)",fontSize:"0.875rem",display:"grid",gap:2},children:U.map((n,u)=>(0,t.jsx)("p",{style:{margin:0},children:n},u))}):null]})}var se=(e,i)=>{let{caption:r,...l}=e;return i?{...l,caption:i}:l};function de({file:e,onCaption:i}){let[r,l]=(0,g.useState)(e.caption??"");(0,g.useEffect)(()=>l(e.caption??""),[e.caption]);let o=()=>{let s=r.trim().slice(0,500);s!==(e.caption??"")&&i(s)};return(0,t.jsx)("input",{type:"text",value:r,placeholder:v(e)?"What it shows":"What it is","aria-label":`What ${e.name} ${v(e)?"shows":"is"}`,"data-graview-file-caption":e.href,onChange:s=>l(s.target.value),onBlur:o,onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),o())},style:{flex:"1 1 10rem",minWidth:0,font:"inherit",fontSize:"0.875rem",minHeight:24}})}function pe({field:e,label:i,labelStyle:r,valueStyle:l,style:o,children:s}){return(0,t.jsxs)("div",{"data-graview-files":e,style:{display:"grid",gap:6,minWidth:0,gridColumn:"1 / -1",...o},children:[(0,t.jsx)("dt",{style:r,children:i}),(0,t.jsx)("dd",{style:{margin:0,minWidth:0,display:"grid",gap:10,...l},children:s})]})}function he(e){let{nodeId:i,field:r,label:l,files:o}=e,{fields:s,commit:d}=ae(i),m=s.find(y=>y.field===r&&y.takesValue),c=m?.shape,a=c?.type==="several"?c.of:c,f=c?.type==="several";return o.length===0&&a?.type!=="file"?null:(0,t.jsxs)(pe,{...e,children:[(0,t.jsx)(N,{files:o,label:l}),m&&a?.type==="file"?(0,t.jsx)(ge,{value:o,thumbs:!1,several:f,image:a.image===!0,label:l,onChange:y=>{let k=f?y:y[y.length-1];k!==void 0&&d(m,k)}}):null]})}function Re(e){switch(e.as){case"field":return e.read?e.files.length>0?(0,t.jsx)(pe,{...e,children:(0,t.jsx)(N,{files:e.files,label:e.label})}):null:(0,t.jsx)(he,{...e});case"unfilled":return(0,t.jsx)(Ce,{...e});case"thumb":return(0,t.jsx)(_,{...e});case"block":return e.files.length>0?(0,t.jsx)("span",{className:"graview-spec-image","data-graview-field":e.field,"data-graview-image":e.view,style:{display:"block",minWidth:0,...e.view==="gallery"?{position:"relative",zIndex:Y.raised}:{}},children:e.view==="thumb"?(0,t.jsx)(_,{file:e.files[0],size:72}):(0,t.jsx)(N,{files:e.files,label:e.label})}):null;case"control":{let i=(0,t.jsx)(ge,{value:j(e.value),several:e.several,image:e.image,label:e.label,onChange:r=>e.onChange(e.several?r:r[r.length-1])});return e.title===void 0?i:(0,t.jsxs)("fieldset",{"data-graview-part":"group","data-graview-field":e.several?"files":"file",children:[(0,t.jsx)("legend",{"data-graview-part":"label",children:e.title}),i]})}}}function Ce({nodeId:e,skip:i,labels:r,labelStyle:l,style:o}){let{store:s}=ee(),d=te(e),m=d?s.schema.tryDefinition(d.kind):void 0,c=ne(m).filter(a=>!i.includes(a)&&!(m?.display?.hide??[]).includes(a)&&j(d?.[a]).length===0);return c.length===0?null:(0,t.jsx)("dl",{style:{margin:0,display:"grid",gap:14,minWidth:0},children:c.map(a=>(0,t.jsx)(he,{nodeId:e,field:a,label:r?.[a]??Q(m,a),files:[],...l?{labelStyle:l}:{},...o?{style:o}:{}},a))})}export{ge as FilesEditor,ve as SEND_EDGE,Re as drawFiles,ue as kindsWords,Fe as prepare,ke as send,H as sizeWords,ce as takes,O as typeWords};
@@ -1 +1 @@
1
- import{Aa as W,Ca as T,Da as A,Ea as h,Fa as k,I as x,J as R,M as O,Pa as j,Qa as B,va as G,wa as F,xa as v,za as q}from"./chunk.RAE4M3KQ.js";function L(e,r){return e===void 0||e===!0?!0:e===!1?!1:e[r]!==!1}function V(e){let r={};return e.query&&e.query.trim().length>0&&(r.q=e.query),e.sort&&(r.sort=e.sort.direction==="desc"?`${e.sort.by}:desc`:e.sort.by),e.filter?.length&&(r.filter=e.filter.map(o=>`${o.key}:${o.value}`).join(",")),e.group&&(r.group=e.group.bucket?`${e.group.by}:${e.group.bucket}`:e.group.by),r}function Y(e,r){let o=[],i={};if(e.query&&(i.query=e.query),e.sort&&(r.sorts.some(l=>l.key===e.sort.by)?i.sort=e.sort:o.push(`sort ${e.sort.by}`)),e.filter){let l=e.filter.filter(p=>r.filters.find(a=>a.key===p.key)?!0:(o.push(`filter ${p.key}`),!1));l.length>0&&(i.filter=l)}return e.group&&(r.groups.some(l=>l.key===e.group.by)?i.group=e.group:o.push(`group ${e.group.by}`)),{arrangement:i,dropped:o}}function N(e,r){return R(e.schema.tryDefinition(r.kind),A(r))}var z=(e,r)=>e==null?r==null?0:1:r==null?-1:typeof e=="number"&&typeof r=="number"?e-r:typeof e=="boolean"&&typeof r=="boolean"?e===r?0:e?1:-1:String(e).localeCompare(String(r),void 0,{numeric:!0,sensitivity:"base"});function I(e,r,o){if(o==="label")return N(e,r);let i=e.schema.tryDefinition(r.kind);return i&&o in(i.fields.shape??{})?T(r)[o]:h(e.graph,r.id,o).map(p=>N(e,p)).sort()[0]}var P=/^(\d{4})-(\d{2})-(\d{2})/;function U(e,r){let o=P.exec(e);if(!o)return;let[,i,l,p]=o;if(r==="day")return`${i}-${l}-${p}`;if(r==="month")return`${i}-${l}-01`;if(r==="year")return`${i}-01-01`;if(r==="decade")return`${String(Number(i)-Number(i)%10).padStart(4,"0")}-01-01`;let s=new Date(Date.UTC(Number(i),Number(l)-1,Number(p))),a=(s.getUTCDay()+6)%7;return s.setUTCDate(s.getUTCDate()-a),s.toISOString().slice(0,10)}var Q=["January","February","March","April","May","June","July","August","September","October","November","December"];function _(e,r){return r==="month"?`${Q[Number(e.slice(5,7))-1]} ${e.slice(0,4)}`:r==="week"?`Week of ${e}`:r==="year"?e.slice(0,4):r==="decade"?`The ${e.slice(0,4)}s`:e}function K(e,r){let{words:o,conditions:i}=j(r);if(o.length===0&&i.length===0)return()=>!0;let l=new Map,p=s=>{let a=l.get(s);return a||(a=new Set(q(e.schema,s).filters.map(u=>u.key)),l.set(s,a)),a};return s=>{let a=p(s.kind),u=i.filter(g=>a.has(g.key));return u.every(g=>k(e,s,g))?o.length>0?B(e.schema.tryDefinition(s.kind),A(s),o)!==void 0:u.length>0:!1}}function X(e,r,o){let i=r.query?.trim(),l=i?e.filter(K(o,i)):e,p=r.filter?.length?l.filter(n=>r.filter.every(f=>k(o,n,f))):[...l],s=r.sort,a=s?p.map((n,f)=>({node:n,index:f,value:I(o,n,s.by)})).sort((n,f)=>{let t=z(n.value,f.value),d=s.direction==="desc"&&t!==0&&n.value!==void 0&&f.value!==void 0?-t:t;return d!==0?d:n.index-f.index}).map(n=>n.node):p,u=r.group;if(!u)return{nodes:a,groups:[{key:"",label:"",nodes:a}],grouped:!1};let g=new Map,c=(n,f,t)=>{let d=g.get(n)??{label:f,nodes:[]};d.nodes.push(t),g.set(n,d)},$=a[0],m=$?o.schema.tryDefinition($.kind):void 0,C=m?.fields.shape??{},E=m?G(m,u.by):O(u.by),b=u.by in C,y=b?F(C[u.by]):void 0,H=v(o.schema,$?.kind??"").find(n=>n.key===u.by)?.label,S=b?`No ${E.toLowerCase()}`:`Without ${(H??O(u.by)).toLowerCase()}`,M=b?new Map:x([...new Map(a.flatMap(n=>h(o.graph,n.id,u.by)).map(n=>[n.id,n])).values()].map(A),n=>o.schema.tryDefinition(n));for(let n of a){if(b){let t=T(n)[u.by];if(t==null||t==="")c("",S,n);else if(y==="date"){let d=u.bucket??"day",D=U(String(t),d);D?c(D,_(D,d),n):c("",S,n)}else if(y==="boolean")c(t?"1":"0",t?"Yes":"No",n);else{let d=m?.display?.format?.[u.by];c(String(t),d?d(t):String(t),n)}continue}let f=h(o.graph,n.id,u.by).map(t=>({id:t.id,label:M.has(t.id)?`${N(o,t)} \xB7 ${M.get(t.id)}`:N(o,t)})).sort((t,d)=>t.label.localeCompare(d.label));f.length===0?c("",S,n):c(f.map(t=>t.id).join(","),f.map(t=>t.label).join(", "),n)}let w=y==="choice"?W(C[u.by]):void 0,J=[...g.entries()].sort(([n,f],[t,d])=>n===""?1:t===""?-1:w?w.indexOf(n)-w.indexOf(t):y==="boolean"?t.localeCompare(n):y==="date"?n.localeCompare(t):f.label.localeCompare(d.label)).map(([n,f])=>({key:n,label:f.label,nodes:f.nodes}));return{nodes:a,groups:J,grouped:!0}}export{L as a,V as b,Y as c,X as d};
1
+ import{Ca as G,Da as F,Ea as v,Ga as q,Ha as W,Ja as T,Ka as A,La as h,Ma as k,O as x,P as R,S as O,Wa as j,Xa as B}from"./chunk.VMEX2KZ4.js";function L(e,r){return e===void 0||e===!0?!0:e===!1?!1:e[r]!==!1}function V(e){let r={};return e.query&&e.query.trim().length>0&&(r.q=e.query),e.sort&&(r.sort=e.sort.direction==="desc"?`${e.sort.by}:desc`:e.sort.by),e.filter?.length&&(r.filter=e.filter.map(o=>`${o.key}:${o.value}`).join(",")),e.group&&(r.group=e.group.bucket?`${e.group.by}:${e.group.bucket}`:e.group.by),r}function Y(e,r){let o=[],i={};if(e.query&&(i.query=e.query),e.sort&&(r.sorts.some(l=>l.key===e.sort.by)?i.sort=e.sort:o.push(`sort ${e.sort.by}`)),e.filter){let l=e.filter.filter(p=>r.filters.find(a=>a.key===p.key)?!0:(o.push(`filter ${p.key}`),!1));l.length>0&&(i.filter=l)}return e.group&&(r.groups.some(l=>l.key===e.group.by)?i.group=e.group:o.push(`group ${e.group.by}`)),{arrangement:i,dropped:o}}function N(e,r){return R(e.schema.tryDefinition(r.kind),A(r))}var z=(e,r)=>e==null?r==null?0:1:r==null?-1:typeof e=="number"&&typeof r=="number"?e-r:typeof e=="boolean"&&typeof r=="boolean"?e===r?0:e?1:-1:String(e).localeCompare(String(r),void 0,{numeric:!0,sensitivity:"base"});function I(e,r,o){if(o==="label")return N(e,r);let i=e.schema.tryDefinition(r.kind);return i&&o in(i.fields.shape??{})?T(r)[o]:h(e.graph,r.id,o).map(p=>N(e,p)).sort()[0]}var P=/^(\d{4})-(\d{2})-(\d{2})/;function U(e,r){let o=P.exec(e);if(!o)return;let[,i,l,p]=o;if(r==="day")return`${i}-${l}-${p}`;if(r==="month")return`${i}-${l}-01`;if(r==="year")return`${i}-01-01`;if(r==="decade")return`${String(Number(i)-Number(i)%10).padStart(4,"0")}-01-01`;let s=new Date(Date.UTC(Number(i),Number(l)-1,Number(p))),a=(s.getUTCDay()+6)%7;return s.setUTCDate(s.getUTCDate()-a),s.toISOString().slice(0,10)}var Q=["January","February","March","April","May","June","July","August","September","October","November","December"];function _(e,r){return r==="month"?`${Q[Number(e.slice(5,7))-1]} ${e.slice(0,4)}`:r==="week"?`Week of ${e}`:r==="year"?e.slice(0,4):r==="decade"?`The ${e.slice(0,4)}s`:e}function K(e,r){let{words:o,conditions:i}=j(r);if(o.length===0&&i.length===0)return()=>!0;let l=new Map,p=s=>{let a=l.get(s);return a||(a=new Set(q(e.schema,s).filters.map(u=>u.key)),l.set(s,a)),a};return s=>{let a=p(s.kind),u=i.filter(g=>a.has(g.key));return u.every(g=>k(e,s,g))?o.length>0?B(e.schema.tryDefinition(s.kind),A(s),o)!==void 0:u.length>0:!1}}function X(e,r,o){let i=r.query?.trim(),l=i?e.filter(K(o,i)):e,p=r.filter?.length?l.filter(n=>r.filter.every(f=>k(o,n,f))):[...l],s=r.sort,a=s?p.map((n,f)=>({node:n,index:f,value:I(o,n,s.by)})).sort((n,f)=>{let t=z(n.value,f.value),d=s.direction==="desc"&&t!==0&&n.value!==void 0&&f.value!==void 0?-t:t;return d!==0?d:n.index-f.index}).map(n=>n.node):p,u=r.group;if(!u)return{nodes:a,groups:[{key:"",label:"",nodes:a}],grouped:!1};let g=new Map,c=(n,f,t)=>{let d=g.get(n)??{label:f,nodes:[]};d.nodes.push(t),g.set(n,d)},$=a[0],m=$?o.schema.tryDefinition($.kind):void 0,C=m?.fields.shape??{},E=m?G(m,u.by):O(u.by),b=u.by in C,y=b?F(C[u.by]):void 0,H=v(o.schema,$?.kind??"").find(n=>n.key===u.by)?.label,S=b?`No ${E.toLowerCase()}`:`Without ${(H??O(u.by)).toLowerCase()}`,M=b?new Map:x([...new Map(a.flatMap(n=>h(o.graph,n.id,u.by)).map(n=>[n.id,n])).values()].map(A),n=>o.schema.tryDefinition(n));for(let n of a){if(b){let t=T(n)[u.by];if(t==null||t==="")c("",S,n);else if(y==="date"){let d=u.bucket??"day",D=U(String(t),d);D?c(D,_(D,d),n):c("",S,n)}else if(y==="boolean")c(t?"1":"0",t?"Yes":"No",n);else{let d=m?.display?.format?.[u.by];c(String(t),d?d(t):String(t),n)}continue}let f=h(o.graph,n.id,u.by).map(t=>({id:t.id,label:M.has(t.id)?`${N(o,t)} \xB7 ${M.get(t.id)}`:N(o,t)})).sort((t,d)=>t.label.localeCompare(d.label));f.length===0?c("",S,n):c(f.map(t=>t.id).join(","),f.map(t=>t.label).join(", "),n)}let w=y==="choice"?W(C[u.by]):void 0,J=[...g.entries()].sort(([n,f],[t,d])=>n===""?1:t===""?-1:w?w.indexOf(n)-w.indexOf(t):y==="boolean"?t.localeCompare(n):y==="date"?n.localeCompare(t):f.label.localeCompare(d.label)).map(([n,f])=>({key:n,label:f.label,nodes:f.nodes}));return{nodes:a,groups:J,grouped:!0}}export{L as a,V as b,Y as c,X as d};
@@ -0,0 +1 @@
1
+ import{a as n}from"./chunk.LQZ2VQWN.js";import"./chunk.TX2GOL65.js";import"./chunk.T2EZ5MTH.js";import"./chunk.ONDILMIX.js";import{f as s}from"./chunk.AS35X6KA.js";import"./chunk.I5KD54S6.js";import"./chunk.NQNQPPPM.js";import"./chunk.KAKX5TZN.js";import"./chunk.VFICMX5G.js";import"./chunk.IKT7JQUW.js";import"./chunk.CW7BMVBG.js";import"./chunk.IZDKEFPJ.js";import"./chunk.XDHBV5K5.js";import"./chunk.WVUJXDXZ.js";import"./chunk.UMMN5Z6V.js";import"./chunk.DG2WKNMX.js";import"./chunk.HPD3DSTP.js";import"./chunk.VD6FJ6KJ.js";import"./chunk.OHGJ5BZ4.js";import"./chunk.7QTBDACG.js";import"./chunk.5BN2ARQ2.js";import"./chunk.4W24TPMR.js";import"./chunk.AHDOKM4O.js";import"./chunk.6R4EI47C.js";import"./chunk.LHAAZQNQ.js";import"./chunk.PHY3AH3L.js";import"./chunk.QZWN46V6.js";import"./chunk.6LJ66MB7.js";import"./chunk.OYULDOQP.js";import"./chunk.VMEX2KZ4.js";import{a as y,b as i}from"./chunk.MRK6QJV5.js";import{b as r}from"./chunk.AJZBJBMO.js";var c=r(y(),1),e=r(i(),1);function v({store:d,views:t,as:a,scope:o}){let l=(0,c.useMemo)(()=>s({scope:`.${o}`}),[o]);return(0,e.jsxs)("div",{"data-testid":"embed-picture","data-embed-content":"",tabIndex:0,"aria-label":t.places().find(m=>m.as===a)?.title??"The picture",style:{flex:"1 1 auto",minHeight:0,display:"grid",gridTemplateRows:"minmax(0, 1fr)",overflow:"auto",background:"var(--graview-ground)",color:"var(--graview-ink)",fontFamily:"var(--graview-font-body, system-ui)"},children:[(0,e.jsx)("style",{children:l}),(0,e.jsx)(n,{store:d,views:t,as:a})]})}export{v as PictureFace};
@@ -0,0 +1 @@
1
+ import{a as he,b as Oe,c as xe,d as ce,e as v,f as Ee,h as Fe}from"./chunk.MHJJEGQO.js";import{e as Re,f as De,g as Me}from"./chunk.DG2WKNMX.js";import{a as ne,b as te,c as L,d as Ae,e as W,g as X,h as Te}from"./chunk.VD6FJ6KJ.js";import{b as Se,g as u,h as ve,i as ae}from"./chunk.OHGJ5BZ4.js";import{a as ee,b as Y,d as ye,e as $e,f as C,h as k,k as G,l as be,m as _,n as ke,o as q,p as F,r as w,ra as We,s as we,t as R,u as O,v as U,w as T,x as n,y as V,z as je}from"./chunk.VMEX2KZ4.js";import"./chunk.AJZBJBMO.js";var le="graview-document",pe=1,fe=256*1024,de=64*1024,Pe=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,ue=/^[a-z][A-Za-z0-9]*$/,Ze=new Set(["id","kind"]),Je=e=>e in Object.prototype,Ke=V(e=>!Je(e),"every object already has this name \u2014 choose another"),Ce=(e,t)=>[...e===void 0?[]:[$e(e)],...t===void 0?[]:[ye(t)]],b=(e,t)=>k().check(...Ce(e,t)),x=(e,t,i)=>F(e).check(...Ce(t,i)),A=e=>k().check(C(Pe,`${e} names are lower-case words joined by hyphens, like "booked-vendor"`)),Ye=/^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|[a-z][A-Za-z0-9]*)$/,B=k().check(C(Ye,'relation names are one camelCase word, like "tendedBy"'),Ke),P=k().check(C(ue,'field names are one word or camelCase, like "dueDate" \u2014 rules say them bare'),V(e=>!Ze.has(e),'a field cannot be called "id" or "kind" \u2014 the framework keeps those; try "type" or "category"'),Ke),I=b(1,500),J=b(1,2e3),se=b(1,300),Xe=["string","text","number","integer","boolean","date","datetime","enum","list","url","email","image","file"],Ge=w({type:U(Xe),required:n(_()),description:n(I),label:n(b(1,60)),options:n(x(b(1,80),1,100)),of:n(U(["string","number","date","image","file"])),default:n(q()),unit:n(b(void 0,12)),format:n(U(["money","percent","duration"])),min:n(G()),max:n(G()),step:n(G()),renamedFrom:n(k().check(C(ue)))}).check(je((e,t)=>{e.type==="enum"&&!e.options&&t.addIssue({code:"custom",message:'an enum field lists its "options"',path:["options"]}),e.type!=="enum"&&e.options&&t.addIssue({code:"custom",message:'"options" belongs only on an enum field',path:["options"]}),e.type!=="list"&&e.of&&t.addIssue({code:"custom",message:'"of" belongs only on a list field',path:["of"]})})),He=w({to:R([x(A("kind"),1),T("*")]),cardinality:n(U(["one","many"])),description:n(I),inverse:n(b(1,80)),appendOnly:n(_()),renamedFrom:n(k())}),_e=R([J,w({expr:J,label:n(b(1,60)),description:n(I)})]),Qe=w({noun:n(b(1,40)),plural:n(b(1,40)),description:n(I),fields:O(P,Ge).check(V(e=>Object.keys(e).length>0,"a kind has at least one field")),label:n(se),describe:n(se),lifecycle:n(w({field:P,retired:x(R([k(),G(),_()]),1)})),figure:n(b(void 0,2e4)),glance:n(x(P,1,20)),page:n(w({fields:n(x(P,1,40)),groups:n(x(w({title:b(1,60),fields:x(P,1,40)}),1,12))})),edges:n(O(B,He)),computed:n(O(k(),_e).check(V(e=>Object.keys(e).length<=20,"a kind works out at most 20 computed fields"))),fieldRoles:n(O(k(),k())),renamedFrom:n(k().check(C(Pe))),people:n(_())}),H=R([k(),G(),_(),ke(),F(q()),w({expr:J})]),Z=k().check(C(/^\$[A-Za-z][A-Za-z0-9]*$/,'a reference is "$" and a name, like "$subject" or "$new"')),en=R([w({create:A("kind"),as:n(k().check(C(ue))),set:n(O(P,H))}),w({set:O(P,H),target:n(Z)}),w({connect:B,from:Z,to:Z}),w({sever:B,from:Z,to:Z}),w({remove:Z})]),nn=w({title:n(b(1,80)),description:n(I),fromTheOtherEnd:n(b(1,80)),on:n(R([A("kind"),x(A("kind"),1)])),creates:n(A("kind")),sets:n(O(P,H)),writes:n(x(P,1)),connects:n(B),severs:n(B),setsOther:n(O(P,H)),replaces:n(R([T(!0),x(B,1,10)])),removes:n(T(!0)),args:n(O(P,Ge)),effects:n(x(en,1,20)),allowedWhen:n(J),refusal:n(se),destructive:n(_())}),tn=w({act:A("act"),label:n(b(1,80)),args:n(O(k(),H))}),on=w({title:n(b(1,120)),description:n(I),over:R([T("graph"),A("kind")]),when:n(J),require:J,says:n(se),repairs:n(x(tn,void 0,10))}),sn=w({roles:R([x(A("role"),1),T("*")]),mutations:R([x(A("act"),1),T("*")]),kinds:n(R([F(A("kind")),T("*")])),describe:n(I),self:n(_()),ownEnd:n(_())}),rn=w({roles:R([x(A("role"),1),T("*")]),kinds:x(A("kind"),1),own:n(_()),via:n(B)}),an=w({grants:F(sn),sees:n(F(rn))}),cn=w({accent:n(k().check(C(/^#[0-9a-fA-F]{6}$/,'an accent is a color like "#c2577a"'))),name:n(b(1,60)),currency:n(k().check(C(/^[A-Z]{3}$/,'a currency is its three-letter code, like "USD" or "EUR"'))),locale:n(b(2,35)),logo:n(R([b(1,de),w({src:b(1,de),alt:n(b(1,120))})])),favicon:n(b(1,de)),typography:n(w({display:n(b(1,200)),body:n(b(1,200)),mono:n(b(1,200))})),shape:n(w({radius:n(G().check(Y(0),ee(32))),density:n(G().check(Y(.75),ee(1.5)))})),accents:n(O(k(),G().check(Y(0),ee(360)))),scheme:n(U(["light","dark","auto"]))}),oe=O(k(),q()),dn=w({card:n(F(q())),row:n(F(q())),page:n(F(q()))}),ln=we({order:n(F(k())),hide:n(F(k())),first:n(k()),primary:n(x(b(1,80),void 0,40)),scene:n(b(1,40)),pages:n(b(1,40))}),qe=w({$schema:n(k()),format:T(le),formatVersion:T(pe),name:b(1,80),description:n(I),version:n(G().check(be(),Y(1))),kinds:O(A("kind"),Qe).check(V(e=>Object.keys(e).length>0,"a document declares at least one kind"),V(e=>Object.keys(e).length<=40,"a document declares at most 40 kinds")),computed:n(O(k(),_e)),acts:n(O(A("act"),nn)),rules:n(O(A("rule"),on)),roles:n(F(A("role"))),policy:n(an),modules:n(oe),lenses:n(F(oe)),pages:n(ln),views:n(O(k(),R([dn,F(q())]))),brand:n(cn),settings:n(F(oe)),migrations:n(F(oe))});var pn={};function Ie(e,t=pn,i=pe){let{document:a,respelled:p}=he(e),f=p.length>0?{respelled:p}:{};if(!a||typeof a!="object"||Array.isArray(a))return{document:a};let m=a;if(m.format!==le||typeof m.formatVersion!="number"||m.formatVersion>=i)return{document:a,...f};let c=m.formatVersion,r=structuredClone(m);for(let s=c;s<i;s++){let d=t[s];if(!d)throw new Error(`there is no upgrade from format ${s} to ${s+1}`);r={...d(r),formatVersion:s+1}}return{document:r,from:c,...f}}function Ne(e,t,i){let a=Object.keys(e).filter(c=>e[c].edges?.[t]!==void 0);if(a.length===0)return;let p=a.map(c=>e[c].edges[t].to),f=p.some(c=>c==="*")?"*":[...new Set(p.flatMap(c=>c))];if(i.length===0||i.some(c=>a.includes(c)))return{reversed:!1,kinds:f};let m=a.filter(c=>{let r=e[c].edges[t].to;return r==="*"||i.every(s=>r.includes(s))});return m.length>0?{reversed:!0,kinds:m}:{reversed:!1,kinds:f}}function Ve(e,t,i=`kinds.${e}.page`){let a=t.page;if(!a)return[];let p=[],f=[...Object.keys(t.fields),...Object.keys(t.computed??{})],m=new Set,c=(s,d)=>{f.includes(s)?m.has(s)&&p.push(u("page-field-twice",d,`"${s}" is on ${e}'s page twice; name each field once`)):p.push(u("page-field",d,`${e}'s page is to show "${s}", and ${e} has no field or computed field called that`,`use one of: ${f.join(", ")}`)),m.add(s)};(a.fields??[]).forEach((s,d)=>c(s,`${i}.fields.${d}`));let r=new Set;return(a.groups??[]).forEach((s,d)=>{let l=s.title.trim().toLowerCase();r.has(l)&&p.push(u("page-group-twice",`${i}.groups.${d}.title`,`${e}'s page has two groups called "${s.title}"; give each its own title`)),r.add(l),s.fields.forEach((y,o)=>c(y,`${i}.groups.${d}.fields.${o}`))}),p}var fn=new Set(["subject","now","today","me"]);function un(e){if((typeof e=="string"?e:JSON.stringify(e??null)).length>fe)return{findings:[u("too-large","",`a document may be at most ${fe/1024} KB`)]};if(typeof e=="string")try{e=JSON.parse(e)}catch(a){return{findings:[u("not-json","",`this is not JSON: ${a.message}`)]}}try{e=Ie(e).document}catch(a){return{findings:[u("format","formatVersion",a.message)]}}let t=qe.safeParse(e);if(!t.success)return{findings:t.error.issues.map(a=>{let p=a.path.map(String).join(".");if(a.code==="unrecognized_keys")return u("unknown-key",p,`${a.keys.map(f=>`"${f}"`).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(p))return u("effect-shape",p,"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 f=a.issues?.[0]?.message;return u("shape",p,`the name "${String(a.path.at(-1))}" is not allowed here${f?`: ${f}`:""}`)}return u("shape",p,a.message)})};let i=t.data;return{document:i,findings:mn(i)}}var re=e=>[e??[]].flat();function Be(e){let t=new Map;for(let[i,a]of Object.entries(e.kinds))for(let[p,f]of Object.entries(a.edges??{})){let m=t.get(p);t.set(p,{name:p,from:[...m?.from??[],i],to:f.to==="*"||m?.to==="*"?"*":[...new Set([...m?.to??[],...f.to])],cardinality:f.cardinality??"many"})}return t}function qn(e){let t=new Map;for(let[a,p]of Object.entries(e.kinds)){let f=X(p);t.set(a,{fields:new Set(Object.keys(p.fields)),edges:new Map(Object.entries(p.edges??{}).map(([m,c])=>[m,c.cardinality??"many"])),...f?{computed:f}:{}})}let i=X(e);return i&&t.set(Se,{computed:i}),t}function Ue(e,t){let i=[],a=re(e.on),p=(f,m)=>{let c=Ne(t.kinds,f,a)?.reversed===!0,[r,s]=c?["$to","$subject"]:["$subject","$to"];return m==="connect"?{connect:f,from:r,to:s}:{sever:f,from:r,to:s}};if(e.creates){let f=t.kinds[e.creates],m={};for(let c of Object.keys(f?.fields??{}))m[c]=`$${c}`;for(let c of e.effects??[])"set"in c&&!("create"in c)&&v(c.target)==="new"&&Object.assign(m,c.set);i.push({create:e.creates,as:"new",set:m})}return e.sets&&i.push({set:e.sets}),e.writes&&!(e.creates&&e.on===void 0)&&i.push({set:Object.fromEntries(e.writes.map(f=>[f,`$${f}`]))}),e.connects&&(e.replaces&&i.push({replace:e.replaces===!0?[e.connects]:[...e.replaces],keep:e.connects}),i.push(p(e.connects,"connect"))),e.severs&&i.push(p(e.severs,"sever")),e.setsOther&&(e.connects||e.severs)&&i.push({set:e.setsOther,target:"$to"}),e.removes&&i.push({remove:"$subject"}),e.effects&&i.push(...e.effects.filter(f=>!(e.creates&&"set"in f&&!("create"in f)&&v(f.target)==="new"))),i}function me(e,t,i){try{let a=L(e),p=ne(a);for(let f of p.unknownFunctions)i.push(u("unknown-function",t,`"${f}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));return a}catch(a){if(a instanceof te){i.push(u("expression",t,a.sentence+` (at character ${a.at+1})`));return}throw a}}function ge(e,t,i){try{return W(e)}catch(a){if(a instanceof Ae||a instanceof te){i.push(u("template",t,(a instanceof te,a.sentence)));return}throw a}}function mn(e){let t=[],i=new Set(Object.keys(e.kinds)),a=Be(e),p=e.acts??{},f=new Set(e.roles??[]);for(let[c,r]of Object.entries(e.kinds)){let s=`kinds.${c}`;for(let[l,y]of Object.entries(r.edges??{})){if(y.to!=="*")for(let o of y.to)i.has(o)||t.push(u("edge-target",`${s}.edges.${l}.to`,`"${o}" is not a kind this document declares`));r.fields[l]&&t.push(u("edge-field-clash",`${s}.edges.${l}`,`"${l}" is both a field and a relation of ${c}`,"rename one of them"))}r.lifecycle&&!r.fields[r.lifecycle.field]&&t.push(u("lifecycle-field",`${s}.lifecycle.field`,`${c} has no field "${r.lifecycle.field}"`));let d=l=>r.computed!==void 0&&Object.hasOwn(r.computed,l);for(let l of r.glance??[])!r.fields[l]&&!d(l)&&t.push(u("glance-field",`${s}.glance`,`a glance at ${c} is to say "${l}", and ${c} has no field or computed field called that`,`use one of: ${[...Object.keys(r.fields),...Object.keys(r.computed??{})].join(", ")}`));t.push(...Ve(c,r));for(let l of["label","describe"]){let y=r[l];if(!y)continue;let o=ge(y,`${s}.${l}`,t);for(let z of o??[])if(z.expr){for(let $ of ne(z.expr).names)if(!r.fields[$]){if(d($)){Te(r,$)||t.push(u("template-field",`${s}.${l}`,`${c}'s ${$} is worked out from beyond the record, and a ${l} is said with no graph to read`,`show it in a view instead, or name a computed field worked out from ${c}'s own fields`));continue}t.push(u("template-field",`${s}.${l}`,`${c} has no field "${$}" for its ${l} to show`,l==="label"?"a label can only show the record's own fields and what they work out":void 0))}}}for(let[l,y]of Object.entries(r.fields))y.default!==void 0&&y.type==="enum"&&!y.options?.includes(String(y.default))&&t.push(u("default-option",`${s}.fields.${l}.default`,`"${String(y.default)}" is not one of ${l}'s options`))}for(let[c,r]of Object.entries(p)){let s=`acts.${c}`;for(let o of re(r.on))i.has(o)||t.push(u("act-kind",`${s}.on`,`"${o}" is not a kind this document declares`));let d=re(r.on),l=Ue(r,e);if(r.creates&&r.on===void 0&&r.writes&&i.has(r.creates))for(let o of r.writes)e.kinds[r.creates].fields[o]||(e.kinds[r.creates].computed?.[o]!==void 0?t.push(u("computed-written",`${s}.writes`,`${r.creates}'s ${o} is worked out, not written: no act can set it`,"write the stored fields it is worked out from")):t.push(u("act-field",`${s}.writes`,`${r.creates} has no field "${o}"`)));l.length===0&&t.push(u("act-empty",s,`"${c}" does nothing`,"give it effects or a shorthand such as sets or creates"));let y=new Map;l.forEach((o,z)=>{let $=l.length-(r.effects?.length??0),j=r.effects&&z>=$?`${s}.effects.${z-$}`:s;if("create"in o){if(!i.has(o.create))t.push(u("act-kind",`${j}.create`,`"${o.create}" is not a kind this document declares`));else for(let h of Object.keys(o.set??{}))e.kinds[o.create].fields[h]||(e.kinds[o.create].computed?.[h]!==void 0?t.push(u("computed-written",`${j}.set.${h}`,`${o.create}'s ${h} is worked out, not written: no act can set it`,"set the stored fields it is worked out from")):t.push(u("act-field",`${j}.set.${h}`,`${o.create} has no field "${h}"`)));o.as&&y.set(o.as,o.create)}else if("connect"in o||"sever"in o){let h="connect"in o?o.connect:o.sever;a.has(h)||t.push(u("act-edge",`${j}.${"connect"in o?"connect":"sever"}`,`"${h}" is not a relation any kind declares`)),v(o.from)==="subject"&&d.length===0&&t.push(u("act-subject",`${s}.on`,`"${c}" acts on "$subject" but does not say which kinds it is "on"`))}else if("set"in o){let h=v(o.target??"$subject"),M=h==="subject"?d:y.has(h??"")?[y.get(h)]:[];h==="subject"&&d.length===0&&t.push(u("act-subject",`${s}.on`,`"${c}" changes "$subject" but does not say which kinds it is "on"`));for(let K of Object.keys(o.set))for(let N of M)!i.has(N)||e.kinds[N].fields[K]||(e.kinds[N].computed?.[K]!==void 0?t.push(u("computed-written",`${j}.set.${K}`,`${N}'s ${K} is worked out, not written: no act can set it`,"set the stored fields it is worked out from")):t.push(u("act-field",`${j}.set.${K}`,`${N} has no field "${K}"`)))}else"remove"in o&&v(o.remove)==="subject"&&d.length===0&&t.push(u("act-subject",`${s}.on`,`"${c}" removes "$subject" but does not say which kinds it is "on"`));("set"in o&&o.set?Object.values(o.set):[]).forEach(h=>{h&&typeof h=="object"&&!Array.isArray(h)&&"expr"in h&&me(h.expr,`${j}.set`,t)})}),r.allowedWhen&&me(r.allowedWhen,`${s}.allowedWhen`,t),r.refusal&&ge(r.refusal,`${s}.refusal`,t)}for(let[c,r]of Object.entries(e.rules??{})){let s=`rules.${c}`;r.over!=="graph"&&!i.has(r.over)&&t.push(u("rule-kind",`${s}.over`,`"${r.over}" is not a kind this document declares`));let d=r.over==="graph"?void 0:e.kinds[r.over];for(let l of["when","require"]){let y=r[l];if(!y)continue;let o=me(y,`${s}.${l}`,t);if(!o)continue;let z=ne(o);for(let $ of z.names)if(r.over==="graph")t.push(u("rule-name",`${s}.${l}`,`"${$}" means nothing in a rule over the whole graph`,`name a kind in "over", or use all('kind')`));else if(d&&!d.fields[$]&&!d.edges?.[$]&&d.computed?.[$]===void 0){let j=Object.keys(d.edges??{}).find(E=>E.includes("-")&&E.split("-").includes($));t.push(u("rule-name",`${s}.${l}`,`${r.over} has no field or relation called "${$}"`,j?`"${j}" reads as a subtraction in a rule; rename the relation to one camelCase word, like "${j.replace(/-([a-z0-9])/g,(E,h)=>h.toUpperCase())}"`:void 0))}for(let $ of z.edges)a.has($)||t.push(u("rule-edge",`${s}.${l}`,`"${$}" is not a relation any kind declares`));for(let $ of z.sweeps)i.has($)?r.over!=="graph"&&t.push(ve("rule-cost",`${s}.${l}`,`this rule looks at every ${$} for every ${r.over}, which grows slowly as the app grows`,"walk a relation with out()/in() instead of all() where you can")):t.push(u("rule-kind",`${s}.${l}`,`"${$}" is not a kind this document declares`))}r.says&&ge(r.says,`${s}.says`,t),(r.repairs??[]).forEach((l,y)=>{!p[l.act]&&!/^(edit|remove)-/.test(l.act)&&t.push(u("repair-act",`${s}.repairs.${y}.act`,`"${l.act}" is not an act this document declares`))})}let m=e.policy;return m&&(m.grants.forEach((c,r)=>{if(c.roles!=="*"&&f.size>0)for(let s of c.roles)f.has(s)||t.push(u("grant-role",`policy.grants.${r}.roles`,`"${s}" is not one of the document's roles`));if(c.mutations!=="*")for(let s of c.mutations)!p[s]&&!/^(edit|remove)-/.test(s)&&t.push(u("grant-act",`policy.grants.${r}.mutations`,`"${s}" is not an act this document declares`))}),(m.sees??[]).forEach((c,r)=>{for(let s of c.kinds)i.has(s)||t.push(u("sight-kind",`policy.sees.${r}.kinds`,`"${s}" is not a kind this document declares`));if(c.roles!=="*"&&f.size>0)for(let s of c.roles)f.has(s)||t.push(u("sight-role",`policy.sees.${r}.roles`,`"${s}" is not one of the document's roles`))})),t.push(...Me(e)),t}function gn(e,t,i,a){let p=new Map,f=re(e.on),m=new Map,c=new Map;(f.length>0||t.some(o=>"remove"in o&&v(o.remove)==="subject"||"from"in o&&(v(o.from)==="subject"||v(o.to)==="subject")||"set"in o&&!("create"in o)&&v(o.target??"$subject")==="subject"))&&p.set(ce,{ref:f.length>0?f:"*",required:!0});let s=e.args??{},d=e.writes?.length===1,l=(o,z)=>z&&o.type===z.type&&o.min===void 0&&o.max===void 0&&o.step===void 0?{...o,...z.min===void 0?{}:{min:z.min},...z.max===void 0?{}:{max:z.max},...z.step===void 0?{}:{step:z.step}}:o,y=(o,z,$)=>{if(o===ce||fn.has(o)||m.has(o)||p.has(o))return;let j=s[o]?l(s[o],$):void 0;p.set(o,j?{field:j,optional:!j.required,required:!!j.required}:z())};for(let o of t)if("create"in o){let z=i.kinds[o.create];for(let[$,j]of Object.entries(o.set??{})){let E=v(j),h=z?.fields[$];if(E&&h){let M=!!h.required&&h.default===void 0;y(E,()=>({field:h,optional:!M,required:M}),h)}}o.as&&m.set(o.as,o.create)}else if("connect"in o||"sever"in o){let z=a.get("connect"in o?o.connect:o.sever);for(let[$,j]of[["from",o.from],["to",o.to]]){let E=v(j);if(!E)continue;let h=$==="to"?z?.to??"*":z?.from??"*";h!=="*"&&!c.has(E)&&c.set(E,h),y(E,()=>({ref:h,required:!0}))}}else if("set"in o){let z=v(o.target??"$subject"),$=z==="subject"?f[0]:m.get(z??"")??c.get(z??"")?.[0];z&&z!=="subject"&&!m.has(z)&&y(z,()=>({ref:"*",required:!0}));for(let[j,E]of Object.entries(o.set)){let h=v(E);if(!h)continue;let M=$?i.kinds[$]?.fields[j]:void 0;y(h,()=>M?{field:M,optional:!d,required:d}:{any:!0,required:!1},M)}}else if("remove"in o){let z=v(o.remove);z&&y(z,()=>({ref:"*",required:!0}))}for(let[o,z]of Object.entries(s))p.has(o)||p.set(o,{field:z,optional:!z.required,required:!!z.required});return p}function In(e,t={}){let i=un(e);if(!i.document||ae(i.findings))return{ok:!1,findings:i.findings};let a=i.document,p=[...i.findings];t.previous&&p.push(...hn(a,t.previous));let f=zn(a,p);return ae(f.findings)?{ok:!1,findings:f.findings}:Fe(f,t)}function zn(e,t){let i=Be(e),a={};for(let[s,d]of Object.entries(e.kinds)){let l=Ee(d),y=d.label??(l?`{${l}}`:void 0),o=X(d);a[s]={...y?{label:W(y)}:{},...d.describe?{describe:W(d.describe)}:{},...o?{computed:[...o]}:{}}}let p={};for(let[s,d]of Object.entries(e.acts??{})){let l=Ue(d,e),y=gn(d,l,e,i),o=d.destructive??l.some(g=>"remove"in g||"sever"in g||"replace"in g),z=[...new Set(l.flatMap(g=>"create"in g?[g.create]:[]))],$=[...new Set(l.flatMap(g=>"connect"in g?[g.connect]:[]))],j=[...new Set(l.flatMap(g=>"sever"in g?[g.sever]:"replace"in g?g.replace:[]))],E=[...new Set(l.flatMap(g=>"set"in g&&!("create"in g)&&v(g.target??"$subject")==="subject"?Object.keys(g.set):[]))],h=new Map;for(let g of l){if(!("connect"in g)&&!("sever"in g))continue;let S=i.get("connect"in g?g.connect:g.sever);for(let[D,Le]of[["from",g.from],["to",g.to]]){let Q=v(Le),ie=D==="to"?S?.to:S?.from;Q&&Q!=="subject"&&ie&&ie!=="*"&&h.set(Q,[...new Set([...h.get(Q)??[],...ie])])}}let M={};for(let g of l){if(!("set"in g)||"create"in g)continue;let S=v(g.target??"$subject");for(let D of S&&S!=="subject"&&h.get(S)||[])M[D]=[...new Set([...M[D]??[],...Object.keys(g.set)])]}let K={};for(let g of l)if(!(!("set"in g)||"create"in g||v(g.target??"$subject")!=="subject"))for(let[S,D]of Object.entries(g.set??{}))typeof D=="string"&&v(D)===void 0||typeof D=="number"||typeof D=="boolean"?K[S]=typeof D=="string"&&D.startsWith("$$")?D.slice(1):D:delete K[S];let N=z.length===0&&l.every(g=>!("set"in g)||!g.set||Object.values(g.set).every(S=>!(S&&typeof S=="object"&&!Array.isArray(S)&&"expr"in S))),ze=new Map;for(let g of l)if(!(!("set"in g)||!g.set))for(let S of Object.values(g.set))S&&typeof S=="object"&&!Array.isArray(S)&&"expr"in S&&ze.set(S.expr,L(S.expr));p[s]={title:d.title??s.replace(/-/g," "),effects:l,args:[...y],...d.allowedWhen?{guard:L(d.allowedWhen)}:{},...d.refusal?{refusal:W(d.refusal)}:{},exprs:[...ze],destructive:o,idempotent:N,creates:z,connects:$,severs:j,writes:E,writesOther:M,sets:K}}let f={};for(let[s,d]of Object.entries(e.rules??{}))f[s]={title:d.title??s.replace(/-/g," "),require:L(d.require),...d.when?{when:L(d.when)}:{},...d.says?{says:W(d.says)}:{}};let m=Oe(e,t),c=Re(e),r=De(e);return{format:xe,document:e,findings:t,kinds:a,...e.computed?{facts:[...X(e)??[]]}:{},edges:[...i].map(([s,{from:d,to:l,cardinality:y}])=>[s,{from:d,to:l,cardinality:y}]),acts:p,rules:f,brand:m,...Object.keys(c).length>0?{viewSpecs:c}:{},...r?{home:r}:{}}}function Nn(e,t){let i=e.split(/[\s:·]/).find(a=>a.length>0)??e;return t.kinds[i]?`kinds.${i}`:t.acts?.[i]?`acts.${i}`:t.rules?.[i]?`rules.${i}`:e}function Vn(e,t,i){let a=/^defineNode\("([^"]+)"\)/.exec(t)?.[1],p=a?i.kinds[a]:void 0;if(!a||!p)return e;let f=Object.keys(p.fields).filter(m=>m!=="label").slice(0,3);return{...e,path:`kinds.${a}.glance`,fix:`Say which: "glance": [${f.map(m=>`"${m}"`).join(", ")}] on kinds.${a} \u2014 the facts a person compares one by, at a glance.`}}function hn(e,t){let i=[],a=new Set(Object.values(t.kinds).flatMap(p=>Object.keys(p.edges??{})));for(let[p,f]of Object.entries(e.kinds)){let m=f.renamedFrom;m&&!t.kinds[m]&&i.push(u("renamed-from-nothing",`kinds.${p}.renamedFrom`,`${p} says it was ${m}, and the previous version has no kind called ${m}`,"name the kind it was, or drop renamedFrom"));let c=t.kinds[m??p];for(let[r,s]of Object.entries(f.fields)){let d=s.renamedFrom;d&&!c?.fields[d]&&i.push(u("renamed-from-nothing",`kinds.${p}.fields.${r}.renamedFrom`,`${r} says it was ${d}, and the previous ${m??p} has no field called ${d}`,"name the field it was, or drop renamedFrom"))}for(let[r,s]of Object.entries(f.edges??{})){let d=s.renamedFrom;d&&!a.has(d)&&i.push(u("renamed-from-nothing",`kinds.${p}.edges.${r}.renamedFrom`,`${r} says it was ${d}, and the previous version has no relation called ${d}`,"name the relation it was, or drop renamedFrom"))}}return i}export{We as ActRefusal,In as compileDocumentWithoutCheck,Ue as effectsOf,Nn as frameworkPath,Vn as inDocumentWords,qn as kindShapes,un as readDocument};
@@ -0,0 +1,2 @@
1
+ import{e as ye,f as he,i as be,j as J,k as we}from"./chunk.UMMN5Z6V.js";import{f as ge}from"./chunk.VD6FJ6KJ.js";import{$ as H,B as z,E as ne,Ib as ue,N as E,P as T,Ra as ie,S as te,Sb as pe,T as re,U as X,V as oe,Y as _,_b as me,aa as se,ac as fe,gb as ae,hb as q,ib as le,ub as de,wb as ce}from"./chunk.VMEX2KZ4.js";function Re(t,r,n){let s=t.tryDefinition(r)?.fields.shape,e=z(s?.[n]),l=!1,i=!1;for(;e&&(e.type==="optional"||e.type==="default"||e.type==="nullable"||e.type==="prefault");)(e.type==="optional"||e.type==="nullable")&&(l=!0),(e.type==="default"||e.type==="prefault")&&(i=!0),e=z(e.innerType);if(e?.type!=="enum")return;let y=(e.entries?Object.values(e.entries):e.values??[]).filter(u=>typeof u=="string");return y.length>0?{values:y,empty:l&&!i}:void 0}function L(t,r,n){let s=Re(t,r,n);if(!s)return[];let e=t.tryDefinition(r),l=s.values.map(i=>({value:i,label:re(e,n,i)}));return s.empty&&l.push({value:null,label:`No ${_(e,n).toLowerCase()}`}),l}function U(t,r,n){let s=t[r];return typeof s=="string"&&n.some(e=>e.value===s)?s:null}function Q(t,r,n,s,e=L(t.schema,n.kind,s)){let l=xe(t.schema,t.allMutations(),n.kind,s,e),i=U(n,s,e),y=[];for(let{value:u,by:A,acts:O}of l)if(u!==i)for(let $ of O){let B=A==="step"?{[$.subject.arg]:n.id}:{[$.subject.arg]:n.id,[s]:u},R={name:$.name,args:B};if($.input.safeParse(B).success&&t.permits(R,r).ok){try{ae(t.graph,$,B)}catch{continue}y.push({to:u,call:R,title:$.title??$.name});break}}return y}function xe(t,r,n,s,e=L(t,n,s)){let l=ve(t,r,n,s),i=$e(t,r,n,s);return e.flatMap(y=>{if(y.value===null)return[];let u=l.filter(A=>A.sets?.[s]===y.value);return[{value:y.value,label:y.label,by:u.length>0?"step":i.length>0?"value":"none",acts:u.length>0?u:i}]})}function ve(t,r,n,s){return r.filter(e=>e.subject!==void 0&&e.derived===void 0&&typeof e.sets?.[s]=="string"&&q(t,e).includes(n))}function $e(t,r,n,s){let e=t.tryDefinition(n);return e?r.filter(l=>{if(!l.subject||!q(t,l).includes(n)||!le(l,e).includes(s))return!1;let i=l.input.shape;return i!==void 0&&s in i}).sort((l,i)=>+(l.derived!==void 0)-+(i.derived!==void 0)):[]}var Y=(t,r)=>r&&t[r]!==void 0?String(t[r]):"";function Ae(t,r,n){let s=d=>t.tryDefinition(d)?r.nodesOfKind(d).filter(k=>E(t.tryDefinition(d),k)):[],e=s(n.rows),l=s(n.columns),i=new Set(e.map(d=>d.id)),y=new Set(l.map(d=>d.id)),u=r.allEdges(),A=[],O=n.link;if(typeof O=="string"){let d=p=>t.tryDefinition(p)?.edges?.[O]?.to,k=(d(n.columns)??[]).some(p=>p===n.rows||p==="*"),w=(d(n.rows)??[]).some(p=>p===n.columns||p==="*"),D=k||!w;for(let p of u){if(p.kind!==O)continue;let m=D?p.to:p.from,o=D?p.from:p.to;i.has(m)&&y.has(o)&&A.push({rowId:m,columnId:o,via:[]})}}else{let d=new Map(O.path.map(w=>[w,new Map]));for(let w of u){let D=d.get(w.kind);if(!D)continue;let p=D.get(w.from);p?p.push(w.to):D.set(w.from,[w.to]);let m=D.get(w.to);m?m.push(w.from):D.set(w.to,[w.from])}let k=new Set;for(let w of l){let D=[{id:w.id,via:[]}];for(let p of O.path){let m=[],o=new Set;for(let f of D)for(let P of d.get(p).get(f.id)??[])o.has(`${f.id}|${P}`)||(o.add(`${f.id}|${P}`),m.push({id:P,via:[...f.via,f.id]}));D=m}for(let p of D){let m=`${p.id}|${w.id}`;!i.has(p.id)||k.has(m)||(k.add(m),A.push({rowId:p.id,columnId:w.id,via:p.via.slice(1)}))}}}let $=n.groupOrder??[],B=d=>$.indexOf(d)===-1?$.length:$.indexOf(d),R=e.map(d=>{let k=d;return{node:d,label:String(k.label??T(t.tryDefinition(d.kind),d)),group:Y(k,n.rowGroup),ref:Y(k,n.rowRef)}}).sort((d,k)=>B(d.group)-B(k.group)||(d.ref<k.ref?-1:d.ref>k.ref?1:0)),N=l.map(d=>({node:d,label:T(t.tryDefinition(d.kind),d),group:Y(d,n.columnGroup)})).sort((d,k)=>d.group<k.group?-1:d.group>k.group?1:d.node.id<k.node.id?-1:d.node.id>k.node.id?1:0);return{rows:R,columns:N,cells:A}}function ke(t,r,n){let{rows:s,columns:e,cells:l}=Ae(t,r,n),i=(o,f)=>X(t,o,f),y=o=>X(t,o,1).replace(/^1 /,""),u=o=>({id:o.id,kind:o.kind,title:T(t.tryDefinition(o.kind),o),parts:[]}),A=o=>{let f=r.getNode(o);if(!f)return null;let P=t.tryDefinition(f.kind),M=T(P,f),K=H(f,P,{limit:3,said:[M],glance:!0}).map(I=>I.alone.startsWith(I.label)?`${I.label.toLowerCase()}${I.alone.slice(I.label.length)}`:I.alone);return[M,...K].join(", ")},O=typeof n.link=="string"?[]:n.link.path.slice(0,-1).flatMap((o,f,P)=>{let M=ue(t,n.columns,P.slice(0,f+1));return M.ok?[...M.reached]:[]}),$=[{t:"text",text:`${i(n.rows,s.length)} against ${i(n.columns,e.length)}${O.length>0?`, through ${[...new Set(O)].map(o=>i(o,2).replace(/^2 /,"")).join(" and ")}`:""}${e.length>0?`: ${e.map(o=>o.label).join(", ")}`:""}.`}],B=new Map(e.map(o=>[o.node.id,o.label])),R=new Map(e.map((o,f)=>[o.node.id,f])),N=new Map,d=new Map;for(let o of l){let f=N.get(o.rowId);f?f.push(o):N.set(o.rowId,[o]);let P=d.get(o.columnId);P?P.add(o.rowId):d.set(o.columnId,new Set([o.rowId]))}for(let o of s){let P=[...N.get(o.node.id)??[]].sort((M,K)=>R.get(M.columnId)-R.get(K.columnId)).map(M=>{let K=M.via.map(A).filter(I=>I!==null);return`${B.get(M.columnId)}${K.length>0?` (${K.join("; ")})`:""}`});$.push({t:"field",label:o.label,text:P.length>0?P.join(", "):"none"})}$.push({t:"list",as:"name",columns:1,groups:e.map(o=>{let f=d.get(o.node.id)??new Set,P=s.filter(M=>f.has(M.node.id)).map(M=>u(M.node));return{heading:`${o.label} (${P.length})`,items:P}})});let k=new Set(l.map(o=>o.rowId)),w=new Set(l.map(o=>o.columnId)),D=s.filter(o=>!k.has(o.node.id)),p=e.filter(o=>!w.has(o.node.id)),m=n.rows===n.columns;return D.length>0&&$.push({t:"text",text:`${m?`${D.length} with none across`:`${i(n.rows,D.length)} with no ${y(n.columns)}`}: ${D.map(o=>o.label).join(", ")}.`}),p.length>0&&$.push({t:"text",text:`${m?`${p.length} with none down`:`${i(n.columns,p.length)} on no ${y(n.rows)}`}: ${p.map(o=>o.label).join(", ")}.`}),$}function Z(t,r,n,s={}){let{app:e,blocks:l=n?e?.viewSpecs?.[n.kind]?.[s.slot??"page"]:e?.home}=s;if(!l?.length)return[];let i=s.firstHeading??(n||s.blocks?void 0:1),y=we(t,r,n,{...s,money:s.money??e?.brand,firstHeading:i});return n&&!y.node?[]:he(typeof l[0]?.t=="string"?l:ye(l),y)}var Ce=240,Se=10,je=1160,Me=40,Oe=640,Be=3,Ie=t=>Math.max(1,Math.floor((Math.min(t,je)-Me+Se)/(Ce+Se)));function Ge(t,r,n,s){let{app:e}=s,l=s.width??1440,i=s.today??ne(),y=t.seenBy(r),u=y.schema,A=y.graph,O=fe(e),$=typeof n=="string"?n.trim():n.slug,B=typeof n=="string"?O.find(a=>a.slug===$||a.title===$||a.address===$):O.find(a=>a.slug===n.slug&&a.kind===n.kind)??n,R=!B&&typeof n=="string"?A.getNode($):void 0;if(!B&&!R)return{ok:!1,error:`"${$}" is not a place this app has, nor a record this seat can see.`,places:O.map(a=>a.slug)};let N=[],d=e.viewSpecs??{},k=Ie(l),w=(a,h)=>Z(y,null,a,{app:e,today:i,...h}),D=(a,h,b)=>{let g=u.tryDefinition(a.kind),S=T(g,a);if(h==="name")return{id:a.id,kind:a.kind,title:S,parts:[]};if(d[a.kind]?.[h]){let j=w(a,{slot:h}),[F,...v]=j,C=F?.t==="title";return{id:a.id,kind:a.kind,title:C?F.text:S,parts:p(C?v:j,b,`views.${a.kind}.${h}`,` (${a.id})`,C?1:0)}}if(h==="row")return{id:a.id,kind:a.kind,title:S,parts:[]};let c=g?.computed?J(u,A,a):a,G=H(c,g,{limit:3,said:[S],glance:!0});return{id:a.id,kind:a.kind,title:S,parts:G.map(j=>({t:"text",text:j.alone}))}};function p(a,h,b,g="",S=0){let x=[];return a.forEach((c,G)=>{let j=`${b}.${G+S}`;switch("problem"in c&&c.problem&&N.push({at:`${j}${g}`,says:c.problem}),c.t){case"title":x.push({t:"heading",level:3,text:c.text});return;case"text":x.push({t:"text",text:c.text,...c.tone?{tone:c.tone}:{}});return;case"badge":x.push({t:"badge",text:c.text});return;case"field":case"image":x.push({t:"field",label:c.label,text:c.text});return;case"progress":x.push({t:"progress",label:c.label,text:c.text});return;case"group":x.push(...p(c.blocks,h,`${j}.group`,g));return;case"when":x.push(...p(c.blocks,h,`${j}.show`,g));return;case"divider":case"figure":return;case"headline":x.push({t:"heading",level:c.level,text:c.text});return;case"number":x.push({t:"figure",text:c.text,...c.label?{label:c.label}:{}});return;case"list":{if(c.failed){x.push({t:"text",text:"\u2014"});return}if(c.members.length===0){c.empty&&x.push({t:"list",as:c.as,columns:1,groups:[],empty:c.empty});return}let F=h+1,v=F>Be?"name":c.as,C=(c.groups??[{value:null,members:c.members}]).map(W=>({..."heading"in W&&W.heading?{heading:W.heading}:{},items:W.members.map(Pe=>D(Pe,v,F))}));x.push({t:"list",as:v,columns:v==="card"?k:1,groups:C,...c.more>0?{more:c.more}:{}});return}}}),x}let m=[],o,f,P;if(R){f="record";let a=u.tryDefinition(R.kind),h=T(a,R);P={slug:R.id,title:h,kind:R.kind,address:ie(u,R.kind,R.id)},d[R.kind]?.page&&m.push(...p(w(R,{slot:"page"}),1,`views.${R.kind}.page`));let g=a?.computed?J(u,A,R):R;for(let S of se(a,H(g,a,{said:[h]}))){S.title&&m.push({t:"heading",level:2,text:S.title});for(let x of S.fields)m.push({t:"field",label:x.label,text:x.value})}}else{let a=B;P={slug:a.slug,title:a.title,kind:a.kind,address:a.address};let h=a.lens?pe(e).drawn.find(b=>b.as===a.slug&&(a.kind===null||b.kinds.includes(a.kind))):void 0;if(a.kind===null){let b=e.brand,g=b?.name??e.name,S=b?.logo&&ce(b.logo)?b.logo:void 0;if(o={name:g,...b?.subtitle?{subtitle:b.subtitle}:{},...S?{logo:{alt:b?.logoAlt??g,...de(S)?{drawn:"inline SVG"}:{drawn:"image",src:S}}}:{}},e.home)f="blocks",m=p(w(null,{}),0,"views.home");else{f="derived";let x=new Set(e.pages?.hide??[]),c=me(u.kinds,e.pages?.order).filter(G=>!x.has(G));m.push({t:"heading",level:1,text:e.name??"Home"});for(let G of c){let j=A.nodesOfKind(G).filter(F=>E(u.tryDefinition(G),F)).length;j>0&&m.push({t:"text",text:`${j} ${V(u,G,j)}`})}}}else if(h?.lens==="blocks")f="lens:blocks",m=p(w(null,{blocks:h.options.blocks??[]}),0,`lenses.${h.index}.options.blocks`);else if(h?.lens==="columns"){f="lens:columns";let b=h.options.bindings??{};for(let g of Object.keys(b)){let S=b[g]?.column;if(!S)continue;let x=L(u,g,S),c=A.nodesOfKind(g).filter(v=>E(u.tryDefinition(g),v));Object.keys(b).length>1&&m.push({t:"heading",level:2,text:V(u,g,2).replace(/^./,v=>v.toUpperCase())}),m.push({t:"text",text:`${c.length} ${V(u,g,c.length)} in columns by ${_(u.tryDefinition(g),S).toLowerCase()}.`});let G=x.map(v=>({column:v,items:c.filter(C=>U(C,S,x)===v.value).map(C=>D(C,"card",1))})).filter(({column:v,items:C})=>v.value!==null||C.length>0).map(({column:v,items:C})=>({heading:`${v.label} (${C.length})`,items:C}));m.push({t:"list",as:"card",columns:1,groups:G});let j=new Map;for(let v of c)for(let C of Q(t,r,v,S,x))j.set(C.to,(j.get(C.to)??new Set).add(`"${C.title}"`));let F=x.filter(v=>v.value!==null&&j.has(v.value)).map(v=>`to ${v.label} by ${[...j.get(v.value)].join(" or ")}`);m.push({t:"text",text:F.length>0?`Moves: ${F.join("; ")}.`:"Moves: none for this seat."})}}else if(h?.lens==="coverage")f="lens:coverage",m=ke(u,A,h.options);else if(h){f=`lens:${h.lens}`;let b=h.kinds.flatMap(g=>A.nodesOfKind(g).filter(S=>E(u.tryDefinition(g),S)));m.push({t:"text",text:`A ${h.lens} of ${b.length} ${h.kinds.map(g=>V(u,g,b.length)).join(" and ")}.`}),m.push({t:"list",as:"name",columns:1,groups:[{items:b.map(g=>D(g,"name",1))}]})}else{f="derived";let b=A.nodesOfKind(a.kind).filter(g=>E(u.tryDefinition(a.kind),g));m.push({t:"heading",level:1,text:a.title}),b.length===0?m.push({t:"list",as:"row",columns:1,groups:[],empty:`No ${V(u,a.kind,0)} yet.`}):m.push({t:"list",as:"row",columns:1,groups:[{items:b.map(g=>D(g,"row",1))}]})}}let M=r.kind==="system"?"the system":(r.roles??[]).length>0?(r.roles??[]).join(", "):r.kind,K=l<Oe?"phone":"wide",I=P.kind===null?Fe(u,A):[],ee={...o?{masthead:o}:{},...I.length>0?{facts:I}:{},place:P,seat:M,width:l,variant:K,drawnBy:f,parts:m,problems:N};return{ok:!0,description:{...ee,text:De(ee)}}}function Fe(t,r){let n=be(t,r,null),s=e=>Array.isArray(e)?e.map(s).join(", "):e===null?"nothing":typeof e=="boolean"?e?"yes":"no":typeof e=="object"?e.label:String(e);return[...ge(t)].map(([e,l])=>{let i=l.label??te(e);return Object.hasOwn(n.values,e)?{name:e,label:i,value:s(n.values[e])}:{name:e,label:i,refused:n.refused[e]??"it could not be worked out"}})}function V(t,r,n){let s=t.tryDefinition(r);if(n===1)return s?.noun??r;let e=oe(t,r);return e.charAt(0).toLowerCase()+e.slice(1)}function De(t){let r=[`${t.place.title} (${t.place.address}) \u2014 as ${t.seat}, ${t.width} wide (${t.variant}).`],n=t.masthead;n&&r.push(`Masthead: ${n.logo?`the logo ("${n.logo.alt}", ${n.logo.drawn==="image"?n.logo.src:"inline SVG"}), `:""}${n.name}${n.subtitle?` \u2014 ${n.subtitle}`:""}`);let s=(e,l)=>{for(let i of e)switch(i.t){case"heading":r.push(`${l}${"#".repeat(i.level)} ${i.text}`);break;case"text":r.push(`${l}${i.text}`);break;case"badge":r.push(`${l}[${i.text}]`);break;case"field":case"progress":r.push(`${l}${i.label}: ${i.text}`);break;case"figure":r.push(`${l}${i.text}${i.label?` \u2014 ${i.label}`:""}`);break;case"list":if(i.groups.length===0){i.empty&&r.push(`${l}(${i.empty})`);break}for(let y of i.groups){y.heading&&r.push(`${l}${y.heading}:`);for(let u of y.items)r.push(`${l}${y.heading?" ":""}- ${u.title}`),s(u.parts,`${l}${y.heading?" ":" "}`)}i.as==="card"&&i.columns>1&&r.push(`${l}(cards, ${i.columns} across)`),i.more&&r.push(`${l}and ${i.more} more`);break}};if(s(t.parts,""),t.facts){r.push("Facts of the whole graph (what fact('<name>') reads):");for(let e of t.facts)r.push(`- ${e.label} (${e.name}): ${e.value??`not worked out \u2014 ${e.refused}`}`)}if(t.problems.length>0){r.push("Problems:");for(let e of t.problems)r.push(`- ${e.at}: ${e.says}`)}return r.join(`
2
+ `)}export{L as a,U as b,Q as c,xe as d,ve as e,$e as f,Z as g,Ge as h,De as i};
@@ -0,0 +1 @@
1
+ import{d as f}from"./chunk.CW7BMVBG.js";import{Yb as c}from"./chunk.VMEX2KZ4.js";import{a as S,b as s}from"./chunk.MRK6QJV5.js";import{b as a}from"./chunk.AJZBJBMO.js";var m=a(s(),1),u=f.part(e=>(0,m.jsx)(e.ActivityRail,{calls:[]}),{quiet:!0});var o=a(S(),1),l=a(s(),1);function Ye({context:e,stop:r,title:t,style:n,className:i,children:g,...p}){let d=c(e.views?.arrangement?.()),y=g??`In ${d==="Scene"?"the scene":d.replace(/^The /,"the ")} \u2197`;if(e.overview){let h=e.overview;return(0,l.jsx)("a",{href:r,...p,...t?{title:t}:{},style:n,...i?{className:i}:{},onClick:x=>{x.preventDefault(),h(r)},children:y})}return e.embedded?null:(0,l.jsx)("a",{href:`${e.sceneHref??"/"}${r}`,...p,...t?{title:t}:{},style:n,...i?{className:i}:{},children:y})}function qe(){return(0,l.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();let r=new URL(window.location.href);r.searchParams.set("fresh","1"),window.location.assign(r.toString())},style:{color:"inherit",display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24},children:"Start fresh"})}function ze(e){let r=(0,o.useRef)(0),t=(0,o.useCallback)(n=>e.subscribe(()=>{r.current+=1,n()}),[e]);return(0,o.useSyncExternalStore)(t,()=>r.current,()=>0)}export{u as a,Ye as b,qe as c,ze as d};
@@ -0,0 +1 @@
1
+ import{e as B}from"./chunk.4W24TPMR.js";import{A as M,da as _,h as q}from"./chunk.OYULDOQP.js";import{O as H,P as L,S as R,X as K,_ as T,ab as j}from"./chunk.VMEX2KZ4.js";import{a as J,b as G}from"./chunk.MRK6QJV5.js";import{b as $}from"./chunk.AJZBJBMO.js";var i=$(J(),1),a=$(G(),1);function ae({affordance:r,onApply:o,onCancel:u}){let{store:l}=_(),[y,m]=(0,i.useState)({}),[f,x]=(0,i.useState)(""),[A,F]=(0,i.useState)(U),W=(0,i.useId)(),O=(0,i.useRef)(null),v=r.open.filter(e=>!(e.name in y)),s=v[0];if((0,i.useEffect)(()=>x(""),[s?.name]),(0,i.useEffect)(()=>{O.current?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[s?.name]),(0,i.useLayoutEffect)(()=>{let e=O.current,n=typeof document>"u"?null:document.activeElement;if(!e||n&&n!==document.body&&!e.contains(n))return;let p=e.querySelector("form input, [role=group] button:not([disabled])");p&&p!==n&&p.focus()},[s?.name]),!s)return null;let h=e=>{let n={...y,[s.name]:e};if(r.open.filter(c=>!(c.name in n)).length===0){let c=o(Object.fromEntries(Object.entries(n).filter(([,E])=>E!==void 0)));c&&c.length>0&&m(Object.fromEntries(Object.entries(n).filter(([E])=>!c.includes(E))))}else m(n)},N=s.optional?(0,a.jsx)("button",{type:"button",onClick:()=>h(void 0),style:{fontSize:"0.8125rem"},children:"Skip"}):null,t=s.shape??{type:"unknown"},d=Q(s,t),g=j(l.schema,l.allMutations().find(e=>e.name===r.mutation),s.name),[z,V]=(0,i.useState)(""),I=(0,i.useMemo)(()=>{let e=d.map(n=>l.graph.getNode(n)).filter(n=>n!==void 0);return H(e,n=>l.schema.tryDefinition(n))},[d,l]),C=e=>{let n=Z(l,t,e),p=t.type==="choice"||t.type==="several"&&t.of.type==="choice"?g.option(e):n,c=I.get(e);return c?`${p} \xB7 ${c}`:p},w=(0,i.useMemo)(()=>{let e=z.trim().toLowerCase();return e===""?d:d.filter(n=>C(n).toLowerCase().includes(e))},[d,z,l,t,I]),b=t.type==="several",P=t.type==="file"?t:t.type==="several"&&t.of.type==="file"?t.of:void 0,D=b&&d.length===0,k=s.kinds&&s.kinds.length>0&&!s.kinds.includes("*")?s.kinds.map(e=>R(T(l.schema.tryDefinition(e),e))).join(" or "):g.label,Y=r.open.length>1?`${k} \xB7 ${r.open.length-v.length+1} of ${r.open.length}`:k;return(0,a.jsxs)("div",{ref:O,"data-graview-asking":r.id,style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:4,padding:"5px 0 2px"},children:[r.open.length>1||d.length>0?(0,a.jsx)("span",{id:W,style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:Y}):null,d.length>S?(0,a.jsx)("input",{type:"search",value:z,onChange:e=>V(e.target.value),placeholder:`Filter ${d.length}\u2026`,"aria-label":`Filter ${k}`,"data-testid":"ask-filter",style:{font:"inherit",fontSize:"0.8125rem",minWidth:0,padding:"3px 7px"}}):null,P?(0,a.jsxs)("div",{style:{display:"grid",gap:4},children:[(0,a.jsx)(B,{as:"control",value:void 0,onChange:h,several:b,image:P.image===!0,label:g.label}),N]}):d.length>0?(0,a.jsxs)("div",{role:"group","aria-labelledby":W,style:{display:"flex",flexWrap:"wrap",gap:4},children:[w.slice(0,S).map(e=>{let n=A.includes(e);return(0,a.jsx)("button",{type:"button","aria-label":`${k}: ${C(e)}`,...b?{"aria-pressed":n}:{},style:{padding:"3px 9px",fontSize:"0.8125rem",...n?{borderColor:"var(--graview-accent)",color:"var(--graview-accent)"}:{}},onClick:()=>b?F(p=>p.includes(e)?p.filter(c=>c!==e):[...p,e]):h(t.type==="boolean"?e==="yes":e),children:C(e)},e)}),w.length>S?(0,a.jsxs)("span",{"data-testid":"ask-more",style:{alignSelf:"center",fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:[w.length-S," more \u2014 type to narrow"]}):null,w.length===0?(0,a.jsxs)("span",{"data-testid":"ask-none",style:{alignSelf:"center",fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:["None of the ",d.length," match that."]}):null,b?(0,a.jsx)("button",{type:"button",disabled:A.length===0,style:{fontSize:"0.8125rem"},onClick:()=>{let e=A;F(U),h(e)},children:v.length>1?"Next":"Apply"}):null,N]}):(0,a.jsxs)("form",{style:{display:"flex",flexWrap:"wrap",gap:4},onSubmit:e=>{if(e.preventDefault(),D){h(f.split(/[,\n]/).map(n=>n.trim()).filter(Boolean));return}f.trim().length!==0&&h(t.type==="number"?Number(f):f)},children:[t.type==="text"&&t.long?(0,a.jsx)("textarea",{autoFocus:!0,name:s.name,"aria-label":g.label,placeholder:g.label,value:f,rows:4,onChange:e=>x(e.target.value),onKeyDown:e=>{e.key==="Escape"?u():e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},style:{flex:"1 1 100%",minWidth:0,font:"inherit",fontSize:"0.875rem",lineHeight:1.45,padding:"5px 8px",borderRadius:7,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",color:"var(--graview-ink)",resize:"vertical",fieldSizing:"content",minHeight:"5.5em",maxHeight:"40vh"}}):(0,a.jsx)("input",{autoFocus:!0,type:t.type==="date"?t.time?"datetime-local":"date":t.type==="number"?"number":"text",name:s.name,"aria-label":g.label,placeholder:D?`${g.label}, separated by commas`:g.label,value:f,...t.type==="number"&&t.min!==void 0?{min:t.min}:{},...t.type==="number"&&t.max!==void 0?{max:t.max}:{},...t.type==="number"&&t.step!==void 0?{step:t.step}:{},onChange:e=>x(e.target.value),onKeyDown:e=>{e.key==="Escape"&&u()},style:{flex:1,minWidth:0,font:"inherit",fontSize:"0.875rem",padding:"5px 8px",borderRadius:7,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",color:"var(--graview-ink)"}}),(0,a.jsx)("button",{type:"submit",disabled:!D&&f.trim().length===0,style:{fontSize:"0.8125rem"},children:v.length>1?"Next":"Apply"}),N]})]})}var U=[],S=10;function Q(r,o){return r.candidates&&r.candidates.length>0?r.candidates:o.type==="choice"?o.options:o.type==="several"&&o.of.type==="choice"?o.of.options:o.type==="boolean"?X:[]}var X=["yes","no"];function Z(r,o,u){return o.type==="boolean"||o.type==="choice"||o.type==="several"&&o.of.type==="choice"?u:ee(r,u)}function ee(r,o){let u=q(o);if(u){let m=K(r.schema,r.graph.getNode(u.from)?.kind??"",u.kind,"out");return m.charAt(0).toUpperCase()+m.slice(1)}let l=M(o);if(l.length>0)return l.map(m=>r.schema.tryDefinition(m)?.plural??`${m}s`).join(" + ");let y=r.graph.getNode(o);return y?L(r.schema.tryDefinition(y.kind),y):o}export{ae as a,ee as b};