graview 0.1.24 → 0.1.25

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 (75) hide show
  1. package/dist/preview/{chunk.47GRZWQN.js → chunk.2AJMM7JG.js} +1 -1
  2. package/dist/preview/{chunk.2VX6H2LL.js → chunk.2WFEFZAW.js} +1 -1
  3. package/dist/preview/chunk.2YVXTTC2.js +1 -0
  4. package/dist/preview/{chunk.AKOC43TV.js → chunk.6DU4XN2F.js} +1 -1
  5. package/dist/preview/{chunk.RT3XFR6E.js → chunk.6OBXKKB5.js} +2 -2
  6. package/dist/preview/{chunk.7EN53F4Q.js → chunk.6UL2JUEH.js} +1 -1
  7. package/dist/preview/chunk.6WFN4C46.js +107 -0
  8. package/dist/preview/{chunk.Y4R77MKX.js → chunk.7BAUPTMY.js} +1 -1
  9. package/dist/preview/chunk.A4SJ7EEY.js +1 -0
  10. package/dist/preview/{chunk.BNSY25SG.js → chunk.ACKTGTOT.js} +1 -1
  11. package/dist/preview/{chunk.7U7Q3HIS.js → chunk.B57EIGTS.js} +1 -1
  12. package/dist/preview/{chunk.ISAMJ7AK.js → chunk.BJ2Y5F66.js} +1 -1
  13. package/dist/preview/{chunk.3O2QU7LU.js → chunk.BYUQOV3O.js} +1 -1
  14. package/dist/preview/chunk.C5N4RTPF.js +1 -0
  15. package/dist/preview/{chunk.XDPRWUCJ.js → chunk.CFL2B2Z5.js} +1 -1
  16. package/dist/preview/{chunk.UM5IPM22.js → chunk.DEZEXD24.js} +1 -1
  17. package/dist/preview/{chunk.6MCK7K3M.js → chunk.DJ72CUS7.js} +1 -1
  18. package/dist/preview/{chunk.WOTNMTIY.js → chunk.DSZ3I557.js} +1 -1
  19. package/dist/preview/chunk.EA4BZKPG.js +1 -0
  20. package/dist/preview/{chunk.GDIRDJF3.js → chunk.EKZWX6NG.js} +1 -1
  21. package/dist/preview/{chunk.RGXNZ7PN.js → chunk.F26676IW.js} +1 -1
  22. package/dist/preview/{chunk.NRWJ6PLU.js → chunk.F2KDFGHR.js} +1 -1
  23. package/dist/preview/chunk.FWV4XAZA.js +1 -0
  24. package/dist/preview/chunk.G3BOZHKR.js +1 -0
  25. package/dist/preview/{chunk.HH6WIUK3.js → chunk.H4LHHT56.js} +6 -6
  26. package/dist/preview/{chunk.FKQTQ3FV.js → chunk.HQX5FGYT.js} +1 -1
  27. package/dist/preview/{chunk.TWFYXD3P.js → chunk.I5ELK6JF.js} +1 -1
  28. package/dist/preview/{chunk.WEGBBWWK.js → chunk.I6T3FDQS.js} +1 -1
  29. package/dist/preview/{chunk.DQL3WKR3.js → chunk.IB6PGEU7.js} +1 -1
  30. package/dist/preview/{chunk.LW7KV5SL.js → chunk.JCZH55RX.js} +1 -1
  31. package/dist/preview/{chunk.XUXCDUKC.js → chunk.JEMQBV6K.js} +1 -1
  32. package/dist/preview/{chunk.AXACXB4D.js → chunk.JIXW4WIO.js} +1 -1
  33. package/dist/preview/chunk.JW3E4SAC.js +1 -0
  34. package/dist/preview/{chunk.HDEQXJWX.js → chunk.KUTTVYOB.js} +1 -1
  35. package/dist/preview/{chunk.53RZI5PM.js → chunk.LHFEOEYY.js} +1 -1
  36. package/dist/preview/{chunk.D3CYTXNZ.js → chunk.MJ67MK4R.js} +1 -1
  37. package/dist/preview/{chunk.BLAODPYJ.js → chunk.ORJ3T4IW.js} +1 -1
  38. package/dist/preview/{chunk.TDW6QEG4.js → chunk.PY42PBMB.js} +1 -1
  39. package/dist/preview/{chunk.VTBAKTFP.js → chunk.QOYC424P.js} +2 -2
  40. package/dist/preview/{chunk.OXODTBOP.js → chunk.R6F3YMRK.js} +1 -1
  41. package/dist/preview/chunk.RAE4M3KQ.js +8 -0
  42. package/dist/preview/chunk.RUFAVEXB.js +1 -0
  43. package/dist/preview/chunk.RVEMN5WU.js +1 -0
  44. package/dist/preview/{chunk.XDVKD6VX.js → chunk.S24R4MRK.js} +3 -3
  45. package/dist/preview/{chunk.S4FO7Y2Q.js → chunk.S56LSUHV.js} +1 -1
  46. package/dist/preview/{chunk.HAQ4KHRY.js → chunk.SSOTDXRS.js} +1 -1
  47. package/dist/preview/{chunk.TWGB347L.js → chunk.T6KID3WO.js} +1 -1
  48. package/dist/preview/chunk.TAOT74FR.js +1 -0
  49. package/dist/preview/chunk.TTODVIXW.js +1 -0
  50. package/dist/preview/{chunk.XJNXSQT4.js → chunk.U6BWYBPM.js} +1 -1
  51. package/dist/preview/{chunk.KKTHQJ6F.js → chunk.UOYH2DFX.js} +1 -1
  52. package/dist/preview/{chunk.MYCTNK6D.js → chunk.US4KIJSW.js} +1 -1
  53. package/dist/preview/{chunk.42U4UBDE.js → chunk.WX5CJ7PI.js} +1 -1
  54. package/dist/preview/chunk.WXO3XUNW.js +1 -0
  55. package/dist/preview/{chunk.6XBLDV4A.js → chunk.YZZGD5OY.js} +1 -1
  56. package/dist/preview/{chunk.C7KLA2MW.js → chunk.ZJVIH6IF.js} +1 -1
  57. package/dist/preview/{chunk.PRXKRG6O.js → chunk.ZRVDIVYY.js} +1 -1
  58. package/dist/preview/chunk.ZV7ZFH2S.js +1 -0
  59. package/dist/preview/page.js +2 -2
  60. package/package.json +6 -6
  61. package/dist/preview/chunk.2STFOAXA.js +0 -1
  62. package/dist/preview/chunk.33C6VZAD.js +0 -1
  63. package/dist/preview/chunk.3TNQPFIK.js +0 -1
  64. package/dist/preview/chunk.54NSG7BX.js +0 -1
  65. package/dist/preview/chunk.6O67NOZR.js +0 -1
  66. package/dist/preview/chunk.7Q7S7YCA.js +0 -1
  67. package/dist/preview/chunk.EUCXNNCZ.js +0 -107
  68. package/dist/preview/chunk.FRNIWOKD.js +0 -1
  69. package/dist/preview/chunk.H3HRTEW7.js +0 -1
  70. package/dist/preview/chunk.KWSXL3A2.js +0 -1
  71. package/dist/preview/chunk.UEBBASQW.js +0 -1
  72. package/dist/preview/chunk.UIZWVBJ7.js +0 -1
  73. package/dist/preview/chunk.VLNI5U6H.js +0 -1
  74. package/dist/preview/chunk.XCOPECOJ.js +0 -1
  75. package/dist/preview/chunk.ZQ4HFIIS.js +0 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graview",
3
- "version": "0.1.24",
3
+ "version": "0.1.25",
4
4
  "type": "module",
5
5
  "description": "The Graview command line: start a product, check its declaration, write its agent docs, serve its store, preview a document with no product and photograph its places, say whether a product is on one release, host it for an agent over MCP, apply an act to it, sync its seed, install the authoring skills. The tool; @graview/* is the framework.",
6
6
  "keywords": [
@@ -29,11 +29,11 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@graview/core": "0.1.24",
33
- "@graview/guest": "0.1.24",
34
- "@graview/ship": "0.1.24",
35
- "@graview/skills": "0.1.24",
36
- "@graview/tools": "0.1.24"
32
+ "@graview/guest": "0.1.25",
33
+ "@graview/skills": "0.1.25",
34
+ "@graview/ship": "0.1.25",
35
+ "@graview/tools": "0.1.25",
36
+ "@graview/core": "0.1.25"
37
37
  },
38
38
  "engines": {
39
39
  "node": ">=22"
@@ -1 +0,0 @@
1
- import{a as n}from"./chunk.EUCXNNCZ.js";import"./chunk.FKQTQ3FV.js";import"./chunk.RGXNZ7PN.js";import"./chunk.ONDILMIX.js";import{f as s}from"./chunk.VLNI5U6H.js";import"./chunk.GDIRDJF3.js";import"./chunk.Y4R77MKX.js";import"./chunk.FRNIWOKD.js";import"./chunk.42U4UBDE.js";import"./chunk.IKT7JQUW.js";import"./chunk.AKOC43TV.js";import"./chunk.MYCTNK6D.js";import"./chunk.53RZI5PM.js";import"./chunk.XJNXSQT4.js";import"./chunk.VTBAKTFP.js";import"./chunk.7U7Q3HIS.js";import"./chunk.6O67NOZR.js";import"./chunk.WWRWXFYR.js";import"./chunk.ISAMJ7AK.js";import"./chunk.54NSG7BX.js";import"./chunk.6KJSFIO7.js";import"./chunk.UM5IPM22.js";import"./chunk.6XBLDV4A.js";import"./chunk.WOTNMTIY.js";import"./chunk.HAQ4KHRY.js";import"./chunk.PRXKRG6O.js";import"./chunk.AHDOKM4O.js";import"./chunk.TDW6QEG4.js";import"./chunk.LW7KV5SL.js";import"./chunk.2VX6H2LL.js";import"./chunk.ZQ4HFIIS.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};
@@ -1 +0,0 @@
1
- import{a as b,b as c,c as d,d as e,e as f,f as g}from"./chunk.WEGBBWWK.js";import"./chunk.6MCK7K3M.js";import"./chunk.54NSG7BX.js";import"./chunk.6KJSFIO7.js";import"./chunk.6XBLDV4A.js";import"./chunk.WOTNMTIY.js";import{va as a}from"./chunk.ZQ4HFIIS.js";import"./chunk.AJZBJBMO.js";export{a as ActRefusal,e as compileDocumentWithoutCheck,d as effectsOf,f as frameworkPath,g as inDocumentWords,c as kindShapes,b as readDocument};
@@ -1 +0,0 @@
1
- import{a,b,c,d,e,f,g,h,i}from"./chunk.BLAODPYJ.js";import"./chunk.ISAMJ7AK.js";import"./chunk.54NSG7BX.js";import"./chunk.6KJSFIO7.js";import"./chunk.UM5IPM22.js";import"./chunk.6XBLDV4A.js";import"./chunk.WOTNMTIY.js";import"./chunk.ZQ4HFIIS.js";import"./chunk.AJZBJBMO.js";export{f as columnActs,c as columnMoves,b as columnOf,d as columnReach,e as columnSteps,h as describePlace,i as placeText,g as resolveFor,a as statusColumns};
@@ -1 +0,0 @@
1
- import{a as H,b as N,c as C,d as de,e as le}from"./chunk.6XBLDV4A.js";import{g as l}from"./chunk.WOTNMTIY.js";import{B as ce,a as G,b as K,d as te,e as ie,f as O,g as p,j,k as oe,l as R,m as re,n as E,o as b,q as g,r as se,s as w,t as m,u as _,v,w as i,x as F,y as ae}from"./chunk.ZQ4HFIIS.js";var Oe="graview-document",je=1,sn=256*1024,X=64*1024,ue=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,J=/^[a-z][A-Za-z0-9]*$/,Re=new Set(["id","kind"]),Ee=e=>e in Object.prototype,fe=F(e=>!Ee(e),"every object already has this name \u2014 choose another"),pe=(e,n)=>[...e===void 0?[]:[ie(e)],...n===void 0?[]:[te(n)]],f=(e,n)=>p().check(...pe(e,n)),h=(e,n,s)=>b(e).check(...pe(n,s)),z=e=>p().check(O(ue,`${e} names are lower-case words joined by hyphens, like "booked-vendor"`)),Ae=/^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|[a-z][A-Za-z0-9]*)$/,I=p().check(O(Ae,'relation names are one camelCase word, like "tendedBy"'),fe),x=p().check(O(J,'field names are one word or camelCase, like "dueDate" \u2014 rules say them bare'),F(e=>!Re.has(e),'a field cannot be called "id" or "kind" \u2014 the framework keeps those; try "type" or "category"'),fe),A=f(1,500),M=f(1,2e3),q=f(1,300),Fe=["string","text","number","integer","boolean","date","datetime","enum","list","url","email"],ge=g({type:_(Fe),required:i(R()),description:i(A),label:i(f(1,60)),options:i(h(f(1,80),1,100)),of:i(_(["string","number","date"])),default:i(E()),unit:i(f(void 0,12)),format:i(_(["money","percent","duration"])),min:i(j()),max:i(j()),step:i(j()),renamedFrom:i(p().check(O(J)))}).check(ae((e,n)=>{e.type==="enum"&&!e.options&&n.addIssue({code:"custom",message:'an enum field lists its "options"',path:["options"]}),e.type!=="enum"&&e.options&&n.addIssue({code:"custom",message:'"options" belongs only on an enum field',path:["options"]}),e.type!=="list"&&e.of&&n.addIssue({code:"custom",message:'"of" belongs only on a list field',path:["of"]})})),Ve=g({to:w([h(z("kind"),1),v("*")]),cardinality:i(_(["one","many"])),description:i(A),inverse:i(f(1,80)),appendOnly:i(R()),renamedFrom:i(p())}),ye=w([M,g({expr:M,label:i(f(1,60)),description:i(A)})]),Te=g({noun:i(f(1,40)),plural:i(f(1,40)),description:i(A),fields:m(x,ge).check(F(e=>Object.keys(e).length>0,"a kind has at least one field")),label:i(q),describe:i(q),lifecycle:i(g({field:x,retired:h(w([p(),j(),R()]),1)})),figure:i(f(void 0,2e4)),glance:i(h(x,1,20)),page:i(g({fields:i(h(x,1,40)),groups:i(h(g({title:f(1,60),fields:h(x,1,40)}),1,12))})),edges:i(m(I,Ve)),computed:i(m(p(),ye).check(F(e=>Object.keys(e).length<=20,"a kind works out at most 20 computed fields"))),fieldRoles:i(m(p(),p())),renamedFrom:i(p().check(O(ue)))}),B=w([p(),j(),R(),re(),b(E()),g({expr:M})]),D=p().check(O(/^\$[A-Za-z][A-Za-z0-9]*$/,'a reference is "$" and a name, like "$subject" or "$new"')),_e=w([g({create:z("kind"),as:i(p().check(O(J))),set:i(m(x,B))}),g({set:m(x,B),target:i(D)}),g({connect:I,from:D,to:D}),g({sever:I,from:D,to:D}),g({remove:D})]),De=g({title:i(f(1,80)),description:i(A),fromTheOtherEnd:i(f(1,80)),on:i(w([z("kind"),h(z("kind"),1)])),creates:i(z("kind")),sets:i(m(x,B)),writes:i(h(x,1)),connects:i(I),severs:i(I),setsOther:i(m(x,B)),replaces:i(w([v(!0),h(I,1,10)])),removes:i(v(!0)),args:i(m(x,ge)),effects:i(h(_e,1,20)),allowedWhen:i(M),refusal:i(q),destructive:i(R())}),Ie=g({act:z("act"),label:i(f(1,80)),args:i(m(p(),B))}),Me=g({title:i(f(1,120)),description:i(A),over:w([v("graph"),z("kind")]),when:i(M),require:M,says:i(q),repairs:i(h(Ie,void 0,10))}),Le=g({roles:w([h(z("role"),1),v("*")]),mutations:w([h(z("act"),1),v("*")]),kinds:i(w([b(z("kind")),v("*")])),describe:i(A),self:i(R())}),Ke=g({roles:w([h(z("role"),1),v("*")]),kinds:h(z("kind"),1),own:i(R())}),Be=g({grants:b(Le),sees:i(b(Ke))}),Ge=g({accent:i(p().check(O(/^#[0-9a-fA-F]{6}$/,'an accent is a color like "#c2577a"'))),name:i(f(1,60)),currency:i(p().check(O(/^[A-Z]{3}$/,'a currency is its three-letter code, like "USD" or "EUR"'))),locale:i(f(2,35)),logo:i(w([f(1,X),g({src:f(1,X),alt:i(f(1,120))})])),favicon:i(f(1,X)),typography:i(g({display:i(f(1,200)),body:i(f(1,200)),mono:i(f(1,200))})),shape:i(g({radius:i(j().check(K(0),G(32))),density:i(j().check(K(.75),G(1.5)))})),accents:i(m(p(),j().check(K(0),G(360)))),scheme:i(_(["light","dark","auto"]))}),P=m(p(),E()),Ne=g({card:i(b(E())),row:i(b(E())),page:i(b(E()))}),Ce=se({order:i(b(p())),hide:i(b(p())),first:i(p()),primary:i(h(f(1,80),void 0,40)),scene:i(f(1,40)),pages:i(f(1,40))}),an=g({$schema:i(p()),format:v(Oe),formatVersion:v(je),name:f(1,80),description:i(A),version:i(j().check(oe(),K(1))),kinds:m(z("kind"),Te).check(F(e=>Object.keys(e).length>0,"a document declares at least one kind"),F(e=>Object.keys(e).length<=40,"a document declares at most 40 kinds")),computed:i(m(p(),ye)),acts:i(m(z("act"),De)),rules:i(m(z("rule"),Me)),roles:i(b(z("role"))),policy:i(Be),modules:i(P),lenses:i(b(P)),pages:i(Ce),views:i(m(p(),w([Ne,b(E())]))),brand:i(Ge),settings:i(b(P)),migrations:i(b(P))});var W=e=>e?._zod?.def,Pe=/^\^\\d\{4\}-\\d\{2\}-\\d\{2\}\$$/;function qe(e){let n=W(e),s=!0,r;for(let t=0;n&&t<4;t++){if(n.type==="optional"||n.type==="nullable")s=!1;else if(n.type==="default")s=!1,r=n.defaultValue;else break;n=W(n.innerType)}if(!n)return{why:"it is not a zod field"};let c=ce(e),d={...s?{required:!0}:{},...r!==void 0?{default:r}:{},...c?{description:c}:{}},a=(n.checks??[]).map(t=>W(t));switch(n.type){case"string":{let t=n.format;return t==="email"?{spec:{type:"email",...d}}:t==="url"?{spec:{type:"url",...d}}:t==="date"?{spec:{type:"date",...d}}:t==="datetime"?{spec:{type:"datetime",...d}}:a.some(o=>o?.format==="regex"&&Pe.test(String(o?.pattern?.source??"")))?{spec:{type:"date",...d}}:{spec:{type:"string",...d}}}case"number":{let t={};for(let o of a){let u=o?.value;typeof u=="number"&&(o?.check==="greater_than"&&o.inclusive?t.min=Math.max(t.min??u,u):o?.check==="less_than"&&o.inclusive?t.max=Math.min(t.max??u,u):o?.check==="multiple_of"&&(t.step=u))}return{spec:{type:a.some(o=>o?.format==="safeint"||o?.format==="int")?"integer":"number",...t,...d}}}case"boolean":return{spec:{type:"boolean",...d}};case"enum":{let t=Object.keys(n.entries??{});return t.length>0?{spec:{type:"enum",options:t,...d}}:{why:"it is an enum with no options"}}case"array":{let t=W(n.element),o=t?.type==="number"?"number":t?.type==="string"?"string":void 0;return o?{spec:{type:"list",of:o,...d}}:{why:`it is a list of ${String(t?.type??"something")}, and a document lists words, numbers or dates`}}default:return{why:`it is a ${String(n.type)}, which a document has no field type for`}}}function ln(e){let n=qe(e);return"spec"in n?n.spec:void 0}var Q=["card","row","page"],ee=["good","warn","bad","neutral","accent"],me=["money","percent","date","relative","count"],he=4,U=40,be=["number","money","percent"],We=["card","row"],ze=100,Z={title:[],headline:[],list:["sort","limit","group","empty","as"],text:["tone"],badge:["tone"],field:["as","currency","label"],progress:["label"],group:["direction"],when:["show"],divider:[],figure:["as","currency","label"]},Ze=Object.keys(Z),ke=`{"title": "{name}"}, {"headline": "{count(all('offer'))} offers"}, {"figure": expr, "as"?: "number"|"money"|"percent", "currency"?, "label"?}, {"list": expr, "sort"?, "limit"?, "group"?, "empty"?, "as"?: "card"|"row"}, {"text": "\u2026", "tone"?}, {"badge": "{status}", "tone"?}, {"field": "quote", "as"?, "currency"?, "label"?}, {"progress": {"value": expr, "max": expr}, "label"?}, {"group": [blocks], "direction"?: "row"|"column"}, {"when": expr, "show": [blocks]}, {"divider": true}, {"figure": true}`;function hn(e){return Object.fromEntries(Object.entries(e.views??{}).filter(([,n])=>!Array.isArray(n)))}function bn(e){let n=e.views?.home;return Array.isArray(n)?n:void 0}var Ue={field:()=>!1,relation:()=>!1,figure:!1},Ye=e=>e.kind??"the home",V=(e,n)=>e!==void 0&&Object.hasOwn(e,n),S=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function $e(e,n,s){let r=H(e);for(let c of r.unknownFunctions)s.findings.push(l("unknown-function",n,`"${c}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let c of r.names){if(s.kind===null){s.findings.push(l("view-name",n,`"${c}" names nothing here: these blocks are about no one record`,"reach records with all('<kind>'), like count(all('offer')) or first(all('party') where role == 'client').name"));continue}c==="id"||s.spec.field(c)||s.spec.relation(c)||s.findings.push(l("view-name",n,`${s.kind} has no field or relation called "${c}"`))}for(let c of r.edges)s.edges.has(c)||s.findings.push(l("view-edge",n,`"${c}" is not a relation any kind declares`));for(let c of r.sweeps)s.kinds.has(c)||s.findings.push(l("view-kind",n,`"${c}" is not a kind this document declares`))}function L(e,n,s){if(typeof e!="string"||e.length===0||e.length>2e3){s.findings.push(l("view-expression",n,`an expression is a line of the rule language, like "status == 'booked'"`));return}try{$e(C(e),n,s)}catch(r){if(!(r instanceof N))throw r;s.findings.push(l("expression",n,`${r.sentence} (at character ${r.at+1})`))}}function ne(e,n,s){if(typeof e!="string"||e.length===0||e.length>300){s.findings.push(l("view-template",n,'a template is words with {field} in braces, like "{name}" or "{quote|money}", at most 300 characters'));return}let r;try{r=le(e)}catch(c){if(c instanceof de||c instanceof N){s.findings.push(l("template",n,c.sentence));return}throw c}for(let c of r)c.expr&&$e(c.expr,n,s)}function He(e,n,s){if(typeof e=="string"){ee.includes(e)||s.findings.push(l("view-tone",n,`"${e}" is not a tone`,`use one of ${ee.join(", ")}, or {"expr": "if(status == 'booked', 'good', 'neutral')"}`));return}if(S(e)&&Object.keys(e).length===1&&"expr"in e){L(e.expr,`${n}.expr`,s);return}s.findings.push(l("view-tone",n,'a tone is a word or {"expr": \u2026}',`one of ${ee.join(", ")}`))}function Y(e,n,s,r){if(!Array.isArray(e)){r.findings.push(l("view-shape",n,"a view is a list of blocks"));return}if(s>he){r.findings.push(l("view-depth",n,`blocks nest at most ${he} deep`,"flatten a group or a condition"));return}e.forEach((c,d)=>Xe(c,`${n}.${d}`,s,r))}function Xe(e,n,s,r){if(r.count++,!S(e)){r.findings.push(l("view-block",n,"a block is an object naming what it shows",`one of ${ke}`));return}let c=Object.keys(e),d=c.filter(o=>Ze.includes(o)&&!(o==="group"&&c.includes("list")));if(d.length===0){r.findings.push(l("view-block",n,`${c.length>0?c.map(o=>`"${o}"`).join(", "):"an empty object"} is not a block Graview knows`,`one of ${ke}`));return}if(d.length>1){r.findings.push(l("view-block",n,`a block is one thing, and this says ${d.map(o=>`"${o}"`).join(" and ")}`,"split it into two blocks"));return}let a=d[0];for(let o of c)o!==a&&o!="key"&&!Z[a].includes(o)&&r.findings.push(l("unknown-key",`${n}.${o}`,`"${o}" is not part of a ${a} block`,Z[a].length>0?`a ${a} block may also say ${Z[a].map(u=>`"${u}"`).join(", ")}`:`a ${a} block says nothing else`));let t=e[a];switch(a){case"title":case"headline":case"text":case"badge":ne(t,`${n}.${a}`,r),"tone"in e&&He(e.tone,`${n}.tone`,r);return;case"field":{if(typeof t!="string"||!r.spec.field(t)){let o=typeof t=="string"&&r.spec.relation(t);r.findings.push(l("view-field",`${n}.field`,`${r.kind} has no field ${typeof t=="string"?`"${t}"`:"by that name"}`,o?`"${t}" is a relation; show it with {"text": "{${t}.name}"}`:void 0))}"as"in e&&!me.includes(e.as)&&r.findings.push(l("view-format",`${n}.as`,`"${String(e.as)}" is not a way to show a field`,`use one of ${me.join(", ")}`)),Se(e,n,r,"field"),"label"in e&&nn(e.label,`${n}.label`,r);return}case"progress":{!S(t)||Object.keys(t).some(o=>o!=="value"&&o!=="max")||!("value"in t)||!("max"in t)?r.findings.push(l("view-progress",`${n}.progress`,'progress is {"value": expression, "max": expression}')):(L(t.value,`${n}.progress.value`,r),L(t.max,`${n}.progress.max`,r)),"label"in e&&ne(e.label,`${n}.label`,r);return}case"group":"direction"in e&&e.direction!=="row"&&e.direction!=="column"&&r.findings.push(l("view-direction",`${n}.direction`,`a group runs "row" or "column", not "${String(e.direction)}"`)),Y(t,`${n}.group`,s+1,r);return;case"when":L(t,`${n}.when`,r),"show"in e?Y(e.show,`${n}.show`,s+1,r):r.findings.push(l("view-when",n,'a condition says what it shows: {"when": expr, "show": [blocks]}'));return;case"figure":if(typeof t=="string")return Je(e,n,r);for(let o of["as","currency","label"])o in e&&r.findings.push(l("unknown-key",`${n}.${o}`,`"${o}" belongs to a figure that works a number out; {"figure": true} is the kind's picture`,`write {"figure": "count(all('offer'))", "as": "number"}`));t!==!0?r.findings.push(l("view-block",`${n}.figure`,`a figure is a number worked out, {"figure": "sum(all('offer'), net)", "as": "money"}, or the kind's picture, {"figure": true}`)):r.spec.figure||r.findings.push(l("view-figure",`${n}.figure`,`${Ye(r)} has no figure to show`,r.kind===null?`work a number out: {"figure": "count(all('offer'))"}`:'give the kind a "figure", or leave this block out'));return;case"list":return en(e,n,r);case"divider":t!==!0&&r.findings.push(l("view-block",`${n}.${a}`,`write {"${a}": true}`));return}}function Je(e,n,s){L(e.figure,`${n}.figure`,s),"as"in e&&!be.includes(e.as)&&s.findings.push(l("view-format",`${n}.as`,`"${String(e.as)}" is not a way to say a figure`,`use one of ${be.join(", ")}`)),Se(e,n,s,"figure"),"label"in e&&ne(e.label,`${n}.label`,s)}function Se(e,n,s,r){"currency"in e&&(typeof e.currency!="string"||!/^[A-Z]{3}$/.test(e.currency)?s.findings.push(l("view-currency",`${n}.currency`,'a currency is its three-letter code, like "USD" or "EUR"')):e.as!=="money"&&s.findings.push(l("view-currency",`${n}.currency`,`a currency belongs on a ${r} shown as money`,'add "as": "money"')))}function Qe(e,n){let s=[...n.kinds],r=(d,a)=>{let t=new Set;for(let o of d){let u=n.vocabulary.namesOf(o)?.targets?.(a);if(u==="*")return s;for(let y of u??[])t.add(y)}return t.size>0?[...t]:void 0},c=d=>{switch(d.t){case"ident":return n.kind!==null&&n.spec.relation(d.name)?r([n.kind],d.name):void 0;case"member":{let a=c(d.object);return a?r(a,d.name):void 0}case"where":return c(d.set);case"call":{let a=d.args[0],t=a?.t==="lit"&&typeof a.value=="string"?a.value:void 0;if(d.fn==="all")return t!==void 0&&n.kinds.has(t)?[t]:void 0;let o=d.args.length===2&&d.args[1]?.t==="lit"&&typeof d.args[1].value=="string"?d.args[1].value:void 0;if(d.fn==="out"&&o!==void 0){let u=c(a);return u?r(u,o):void 0}if(d.fn==="out")return t!==void 0&&n.kind!==null?r([n.kind],t):void 0;if(d.fn==="in"){let u=o??t,y=o!==void 0?c(a):n.kind!==null?[n.kind]:void 0,k=u!==void 0?n.vocabulary.sources(u).filter($=>{let T=n.vocabulary.namesOf($)?.targets?.(u);return!y||T==="*"||y.some(xe=>T?.includes(xe))}):[];return k.length>0?k:void 0}if((d.fn==="sort"||d.fn==="first")&&a)return c(a);if(d.fn==="either"){let u=d.args.map(c);return u.every(y=>y!==void 0)?[...new Set(u.flatMap(y=>y??[]))]:void 0}return}default:return}};return c(e)}function we(e,n,s,r){let c;try{c=C(e)}catch(a){if(!(a instanceof N))throw a;r.findings.push(l("expression",n,`${a.sentence} (at character ${a.at+1})`));return}let d=H(c);for(let a of d.unknownFunctions)r.findings.push(l("unknown-function",n,`"${a}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let a of d.edges)r.edges.has(a)||r.findings.push(l("view-edge",n,`"${a}" is not a relation any kind declares`));if(s)for(let a of d.names)a==="id"||s.some(t=>r.vocabulary.namesOf(t)?.field(a)||r.vocabulary.namesOf(t)?.relation(a))||r.findings.push(l("view-name",n,`${s.join(" and ")} ${s.length===1?"has":"have"} no field or relation called "${a}"`))}function en(e,n,s){let r=e.list;L(r,`${n}.list`,s);let c;if(typeof r=="string")try{c=Qe(C(r),s)}catch{c=void 0}let d=t=>{if(!c)return[...s.kinds].map(u=>s.vocabulary.namesOf(u)?.choices?.(t)).find(u=>u!==void 0);let o=c.map(u=>s.vocabulary.namesOf(u)?.choices?.(t));return o.every(u=>u!==void 0)?[...new Set(o.flatMap(u=>u??[]))]:void 0},a=c?c.join(" and "):"any kind";if("sort"in e){let t=e.sort;if(typeof t=="string")we(t,`${n}.sort`,c,s);else if(S(t)&&typeof t.by=="string"&&Object.keys(t).every(o=>o==="by"||o==="direction")){let o=t.direction;o!==void 0&&o!=="asc"&&o!=="desc"&&o!=="choices"?s.findings.push(l("list-sort",`${n}.sort.direction`,`a list is sorted "asc", "desc" or "choices", not "${String(o)}"`,'"choices" puts a choice field in the order its choices are declared')):o==="choices"?d(t.by)===void 0&&s.findings.push(l("list-sort",`${n}.sort.by`,`"${t.by}" is not a choice field of ${a}, so it has no declared order`,'sort by a choice field, or say "asc" or "desc"')):we(t.by,`${n}.sort.by`,c,s)}else s.findings.push(l("list-sort",`${n}.sort`,'a sort is a key, like "net", or {"by": key, "direction": "asc" | "desc" | "choices"}'))}if("limit"in e){let t=e.limit;(typeof t!="number"||!Number.isInteger(t)||t<1||t>ze)&&s.findings.push(l("list-limit",`${n}.limit`,`a limit is a whole number from 1 to ${ze}`))}if("group"in e){let t=e.group,o=typeof t=="string"?t:S(t)&&typeof t.by=="string"?t.by:void 0;if(!(typeof t=="string"||S(t)&&Object.keys(t).every(y=>y==="by"||y==="headings"))||o===void 0)s.findings.push(l("list-group",`${n}.group`,'a group is a choice field, like "type", or {"by": "type", "headings": {"pain": "What hurts"}}'));else{let y=d(o);if(y===void 0&&s.findings.push(l("list-group",`${n}.group`,`"${o}" is not a choice field of ${a}, so it has no choices to group by`,"group by a field whose type is enum")),S(t)&&"headings"in t){let k=t.headings;if(!S(k)||Object.values(k).some($=>typeof $!="string"||$.length===0||$.length>80))s.findings.push(l("list-group",`${n}.group.headings`,'headings are words per choice, like {"pain": "What hurts"}, at most 80 characters each'));else if(y)for(let $ of Object.keys(k))y.includes($)||s.findings.push(l("list-group",`${n}.group.headings.${$}`,`"${$}" is not one of ${o}'s choices`,`use ${y.join(", ")}`))}}}"empty"in e&&(typeof e.empty!="string"||e.empty.length===0||e.empty.length>200)&&s.findings.push(l("list-empty",`${n}.empty`,"what an empty list says is a sentence, at most 200 characters")),"as"in e&&!We.includes(e.as)&&s.findings.push(l("list-as",`${n}.as`,`a list draws each record as its "card" or its "row", not "${String(e.as)}"`))}function nn(e,n,s){(typeof e!="string"||e.length===0||e.length>60)&&s.findings.push(l("view-label",n,"a label is a few words, at most 60 characters"))}function ve(e,n,s,r,c,d,a){let t={kind:null,spec:Ue,kinds:r,edges:c,vocabulary:s,findings:d,count:0};Array.isArray(e)&&e.length===0&&d.push(l("view-shape",n,`${a} has no blocks`,'give it one: {"headline": "\u2026"}')),Y(e,n,1,t),t.count>U&&d.push(l("view-size",n,`${a} has ${t.count} blocks; a view has at most ${U}`,"show less"))}function tn(e,n,s,r,c){Array.isArray(e)&&e.forEach((d,a)=>{if(!S(d)||d.name!=="blocks"||!S(d.options)||!("blocks"in d.options))return;let t=[];ve(d.options.blocks,`lenses.${a}.options.blocks`,n,s,r,t,`the lens "${String(d.title??a)}"`);for(let o of t)c.push({...o,severity:"warning"})})}function on(e,n,s,r,c,d,a){let t=[];if(e===void 0)return t;if(!S(e))return t.push(l("view-shape",n,'views are an object of kinds, each with a "card", a "row" or a "page"')),t;for(let[o,u]of Object.entries(e)){if(o==="home"&&Array.isArray(u)){ve(u,`${n}.home`,a,r,c,t,"the home");continue}let y=s(o);if(!y){t.push(l("view-kind",`${n}.${o}`,`"${o}" is not a kind this ${d} declares`));continue}if(!S(u)){t.push(l("view-shape",`${n}.${o}`,`a kind's views are {"card": [blocks], "row": [blocks], "page": [blocks]}`));continue}for(let k of Object.keys(u))Q.includes(k)||t.push(l("view-slot",`${n}.${o}.${k}`,`"${k}" is not a place a view is drawn`,`use ${Q.map($=>`"${$}"`).join(", ")}`));for(let k of Q){let $=u[k];if($===void 0)continue;let T={kind:o,spec:y,kinds:r,edges:c,vocabulary:a,findings:t,count:0};Y($,`${n}.${o}.${k}`,1,T),T.count>U&&t.push(l("view-size",`${n}.${o}.${k}`,`this ${k} has ${T.count} blocks; a view has at most ${U}`,"show less, or move detail to the page"))}}return t}function zn(e){let n=new Set(Object.keys(e.kinds)),s=new Set(Object.values(e.kinds).flatMap(a=>Object.keys(a.edges??{}))),r=a=>{let t=V(e.kinds,a)?e.kinds[a]:void 0;return t?{field:o=>V(t.fields,o)||V(t.computed,o),relation:o=>V(t.edges,o),figure:t.figure!==void 0,choices:o=>V(t.fields,o)&&t.fields[o].type==="enum"?t.fields[o].options:void 0,targets:o=>V(t.edges,o)?t.edges[o].to:void 0}:void 0},c={namesOf:r,sources:a=>Object.keys(e.kinds).filter(t=>V(e.kinds[t].edges,a))},d=on(e.views,"views",r,n,s,"document",c);return tn(e.lenses,c,n,s,d),d}export{Oe as a,je as b,sn as c,an as d,ln as e,ee as f,me as g,be as h,ze as i,hn as j,bn as k,zn as l};
@@ -1 +0,0 @@
1
- import{e as z}from"./chunk.PRXKRG6O.js";import{E as N,R as O,ba as T,ca as m,d as B,ea as b,oa as V,qa as $}from"./chunk.2VX6H2LL.js";import{$a as F,A,ha as D,ja as R,sb as P,tb as j}from"./chunk.ZQ4HFIIS.js";import{a as w,b as K}from"./chunk.MRK6QJV5.js";import{b as y}from"./chunk.AJZBJBMO.js";var G=y(w(),1);var g=y(K(),1);function L(n){let e=n?.hint;return typeof e=="string"&&e.length>0?e:void 0}function J(n){if(n instanceof Error&&n.message)return n.message;let e=String(n);return e==="[object Object]"?"The view threw without a message.":e}var C=class extends G.Component{static contextType=V;state={};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[graview] the ${this.props.view??"view"} of ${this.props.kind} threw while rendering`,e,t.componentStack),this.context?.(e,{module:"@graview/react"})}render(){let{error:e}=this.state;if(!e)return this.props.children;let t=L(e);return(0,g.jsxs)("div",{role:"alert","data-graview-view-error":this.props.kind,style:{display:"flex",flexDirection:"column",gap:"0.375rem",padding:"var(--graview-pad, 12px)",height:"100%",overflow:"auto",boxSizing:"border-box",borderRadius:"var(--graview-radius-sm, 6px)",background:"var(--graview-panel-warning, #fdf3ec)",color:"var(--graview-ink, #1a1a1a)",font:"var(--graview-font-body, 13px/1.45 system-ui)",fontSize:"0.875rem",lineHeight:1.45},children:[(0,g.jsx)("strong",{style:{color:"var(--graview-warn, #b4462a)"},children:this.props.view?`${this.props.view} could not draw`:"This view could not draw"}),(0,g.jsx)("span",{style:{color:"var(--graview-ink-muted, #555)"},children:this.props.kind}),(0,g.jsx)("span",{children:J(e)}),t?(0,g.jsx)("span",{style:{color:"var(--graview-ink-muted, #555)"},children:t}):null]})}};var I=y(w(),1);function Q(){return m().activity}function X(n){let{noteAttention:e,noteSeat:t}=m();(0,I.useEffect)(()=>n.onCall(r=>{let i=n.author??{kind:"agent"},s=r.args?.said;r.phase==="ok"&&typeof s=="string"&&s.length>0&&t({type:"said",author:i,say:s}),!(r.phase!=="ok"||!r.reads||r.reads.length===0)&&e({reads:r.reads,author:i,intent:`read ${r.name}`})}),[n,e,t])}var l=y(w(),1);function Y(n,{units:e,target:t=0,legibleAt:r=260}){let[i,s]=(0,l.useState)(e);(0,l.useEffect)(()=>{let o=n.current;if(o===null||typeof ResizeObserver>"u")return;let a=new ResizeObserver(([c])=>{let u=c?.contentRect.width??0;u>0&&s(u)});return a.observe(o),()=>a.disconnect()},[n]);let d=i/e;return{scale:d,width:i,touchable:d*t>=24,legible:i>=r}}function Z(n="--graview-font-body",e="sans-serif"){let t=(0,l.useRef)(void 0),r=(0,l.useMemo)(()=>{if(typeof getComputedStyle!="function"||typeof document>"u")return e;let i=getComputedStyle(document.documentElement).getPropertyValue(n).trim();return i.length>0?i:e},[n,e]);return(0,l.useMemo)(()=>{t.current===void 0&&(t.current=typeof document>"u"?null:document.createElement("canvas").getContext("2d")??null);let i=t.current;return i===null?O:(s,d)=>{i.font=`${d}px ${r}`;let o=i.measureText(s).width;return o>0?o:O(s,d)}},[r])}function me(n,e,t){let[r,i]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{(document.fonts?.ready??Promise.resolve()).then(()=>i(!0))},[]),(0,l.useMemo)(()=>{let s=n.current,d=r&&s?document.createElement("canvas").getContext("2d"):null;if(d)return d.font=`600 ${.8125*e}px ${getComputedStyle(s).fontFamily}`,d.measureText("M").width>0?o=>d.measureText(o).width:void 0},[r,e,t])}var ee=(0,l.createContext)(void 0);function ne(){return(0,l.useContext)(ee)}function W(n,e){let t=n.graph.getNode(e);if(!t)return[];let r=t.kind,i=n.schema.tryDefinition(r);if(!i)return[];let s=new Map;for(let d of n.allMutations()){let o=d.subject;if(!o||!(o.kinds==="*"||o.kinds.includes(r)))continue;let c=d.input.shape??{};for(let u of F(d,i)){let p=u in c,h=[];for(let f of Object.keys(c)){if(f===o.arg||f===u||te(c[f]))continue;let x=D(d.input).find(v=>v.name===f);h.push({name:f,...x?{kinds:x.kinds}:{},...x?{candidates:x.kinds.includes("*")?n.graph.allNodes().map(v=>v.id):x.kinds.flatMap(v=>n.graph.nodesOfKind(v).map(H=>H.id))}:{},shape:R(d.input,f)})}let E={field:u,mutation:d.name,title:d.title??d.name,shape:p?R(d.input,u):{type:"unknown"},takesValue:p,alternatives:[],open:h,call:f=>({name:d.name,args:p?{[o.arg]:e,[u]:f}:{[o.arg]:e}})};s.set(u,[...s.get(u)??[],E])}}return[...s.values()].map(d=>{let o=[...d.filter(u=>u.takesValue),...d.filter(u=>!u.takesValue)],[a,...c]=o;return{...a,alternatives:c}})}function te(n){let e=A(n)?.type;return e==="optional"||e==="default"||e==="nullable"}var k=y(w(),1);function oe(n){let{store:e,principal:t}=m(),r=b(),i=(0,k.useMemo)(()=>n===null?[]:W(e,n),[e,n,r]),s=(0,k.useCallback)((d,o,a={})=>{let c=d.call(o);e.apply({name:c.name,args:{...c.args,...a}},{author:t})},[e,t]);return{fields:i,commit:s}}var S=y(w(),1);function re(){let n=$();return(0,S.useMemo)(()=>[...new Set(n.flatMap(e=>e.nodeIds))],[n])}function ie(){let n=U(),e=T();return(0,S.useMemo)(()=>{if(!e)return n;let t=e.matched;return t.length===0&&n.length===0?[q]:[...new Set([...n,...t])]},[e,n])}function U(){let{store:n,selection:e}=m(),t=b();return(0,S.useMemo)(()=>{if(e.length===0)return[];let r=new Set(e),i=new Set(r);for(let s of n.graph.allEdges())r.has(s.from)&&i.add(s.to),r.has(s.to)&&i.add(s.from);for(let s of n.violations())if(s.subjectId!==void 0&&r.has(s.subjectId))for(let d of s.nodeIds)i.add(d);return[...i]},[n,e,t])}var q="search:nothing";var _=y(w(),1);function ae(){let{brand:n}=m(),e=n?.kit;return(0,_.useMemo)(()=>P(e),[e])}function se(n,e){let t=j(n,e),r={...t.color!==void 0?{color:t.color}:{},...t.pattern!==void 0?{pattern:t.pattern}:{},...t.width!==void 0?{width:t.width}:{},...t.cap!==void 0?{cap:t.cap}:{},...t.opacity!==void 0?{opacity:t.opacity}:{}};return{connector:t,style:z(e,{[e]:r})}}var M=3;function de(n){let e=B(n),t=e.focusId;if(!t)return null;if(e.within?.view){let[i]=N(t);if(i)return{at:`screen:${i}`,audience:!0}}return{at:t,audience:!1}}function Ae(n,e,t){let r=[],i=new Map,s=new Map,d=0;for(let o of n){let a=de(o.stop),c=a?e(a.at):null;if(!a||!c){o.name&&r.push({kind:"edge",presence:o,point:{x:t-8,y:40+d++*28}});continue}if(!o.name){let f=s.get(a.at);s.set(a.at,{n:(f?.n??0)+1,box:c});continue}let u=i.get(a.at)??[];if(u.push(o),i.set(a.at,u),u.length>M)continue;let p=c,h=u.length-1,E=a.audience?{x:p.x+p.width*.5+(h-1)*26,y:p.y+Math.min(p.height,24)}:{x:p.x+p.width*.5-26-h*22,y:p.y+p.height-4};r.push({kind:"person",presence:o,point:E,at:a.at,index:h,of:u.length,audience:a.audience})}for(let[o,a]of i){if(a.length<=M)continue;let c=e(o);c&&r.push({kind:"count",at:o,point:{x:c.x+c.width*.5+2*26+18,y:c.y+c.height-4},n:a.length-M})}for(let[o,{n:a,box:c}]of s)r.push({kind:"count",at:o,point:{x:c.x+c.width*.5+40,y:c.y+c.height-4},n:a});for(let o of n)if(o.name){if(o.robot?.at&&o.robot.mode!=="docked"){let a=e(o.robot.at);a&&r.push({kind:"robot",presence:o,point:{x:a.x+a.width/2+22,y:a.y+a.height-4},mode:o.robot.mode})}if(o.over){let a=e(o.over);a&&r.push({kind:"over",presence:o,box:a})}}return r}export{Q as a,X as b,Y as c,Z as d,me as e,ee as f,ne as g,oe as h,re as i,ie as j,U as k,ae as l,se as m,Ae as n,C as o};
@@ -1 +0,0 @@
1
- import{a,b}from"./chunk.KKTHQJ6F.js";import"./chunk.BLAODPYJ.js";import"./chunk.HH6WIUK3.js";import"./chunk.GDIRDJF3.js";import"./chunk.Y4R77MKX.js";import"./chunk.FRNIWOKD.js";import"./chunk.42U4UBDE.js";import"./chunk.XJNXSQT4.js";import"./chunk.VTBAKTFP.js";import"./chunk.7U7Q3HIS.js";import"./chunk.6O67NOZR.js";import"./chunk.WWRWXFYR.js";import"./chunk.ISAMJ7AK.js";import"./chunk.54NSG7BX.js";import"./chunk.6KJSFIO7.js";import"./chunk.UM5IPM22.js";import"./chunk.6XBLDV4A.js";import"./chunk.WOTNMTIY.js";import"./chunk.HAQ4KHRY.js";import"./chunk.PRXKRG6O.js";import"./chunk.AHDOKM4O.js";import"./chunk.TDW6QEG4.js";import"./chunk.LW7KV5SL.js";import"./chunk.2VX6H2LL.js";import"./chunk.ZQ4HFIIS.js";import"./chunk.MRK6QJV5.js";import"./chunk.AJZBJBMO.js";export{b as declaredLensView,a as formatFor};
@@ -1,107 +0,0 @@
1
- import{A as he,B as ke,C as Yn,D as Ct,E as pe,F as Jn,G as Qn,H as A,I as We,J as Rt,K as Xn,L as At,M as rt,N as Zn,O as U,P as Y,Q as Lt,a as G,b as fe,c as q,d as Vn,e as xe,f as Fe,g as D,h as se,i as _,j as k,k as j,l as $,m as J,n as et,o as ee,p as Un,q as tt,r as nt,s as I,t as Pe,u as jn,v as at,w as le,x as _n,y as de,z as Pt}from"./chunk.FKQTQ3FV.js";import{a as Ze,c as V}from"./chunk.RGXNZ7PN.js";import{a as Bn,d as Gn,e as qn}from"./chunk.ONDILMIX.js";import{a as Hn,e as zn}from"./chunk.VLNI5U6H.js";import{a as xt}from"./chunk.FRNIWOKD.js";import{a as Ma}from"./chunk.IKT7JQUW.js";import{h as Ln,i as Tn}from"./chunk.AKOC43TV.js";import{e as Mn,i as Kn}from"./chunk.MYCTNK6D.js";import{a as Qe,b as Cn,c as Rn,e as vt,f as An}from"./chunk.53RZI5PM.js";import{f as Fn}from"./chunk.XJNXSQT4.js";import{a as bt,b as On,d as Wn,f as Nn,g as Dn,h as In,k as Xe}from"./chunk.VTBAKTFP.js";import{o as St}from"./chunk.6O67NOZR.js";import{f as Oe}from"./chunk.ISAMJ7AK.js";import{b as $n,c as kt,d as En}from"./chunk.LW7KV5SL.js";import{$ as Sn,C as Ie,W as vn,_ as kn,a as hn,da as oe,ha as bn,ja as Ee,ka as xn,ta as Pn,y as wn}from"./chunk.2VX6H2LL.js";import{Da as sn,Ea as ln,G as $e,Ga as dn,H as je,I as ae,J as Qt,L as re,N as Xt,Nb as wt,Ob as mn,P as Zt,S as en,Sb as yn,T as be,U as tn,Ua as pn,V as nn,Va as cn,Vb as Je,Wb as fn,Xa as gn,Za as Ye,aa as an,ca as _e,oa as ht,pa as rn,ua as on,xb as un}from"./chunk.ZQ4HFIIS.js";import{a as ve,b as z}from"./chunk.MRK6QJV5.js";import{b as O}from"./chunk.AJZBJBMO.js";function ea(e,t,n={}){let a=e.graph.getNode(t);if(!a)return;let i=e.schema.tryDefinition(a.kind),r=s=>ae(e.schema.tryDefinition(s.kind),s),d=new Map;for(let s of e.graph.allEdges()){let l=s.from===t?"out":s.to===t?"in":null;if(!l)continue;let o=l==="out"?s.to:s.from,u=e.graph.getNode(o);if(!u)continue;let g=(l==="out"?i:e.schema.tryDefinition(u.kind))?.edges?.[s.kind],c=l==="in"?g?.inverse??g?.description:g?.description,y=`${s.kind}|${l}|${c??""}`;(d.get(y)??(()=>{let F={edgeKind:s.kind,direction:l,...c?{description:c}:{},targets:[]};return d.set(y,F),F})()).targets.push({id:u.id,kind:u.kind,label:r(u)})}return{id:t,kind:a.kind,label:r(a),fields:tn(Oe(e.schema,e.graph,a),i),violations:ht(e.violations(n.context),[t]),actions:xt(e,[t],{focus:t,...n.principal?{principal:n.principal}:{},...n.context?{context:n.context}:{}}),links:[...d.values()].map(s=>{let l=je(s.targets.flatMap(o=>{let u=e.graph.getNode(o.id);return u?[u]:[]}),o=>e.schema.tryDefinition(o));return{...s,targets:[...s.targets].map(o=>l.has(o.id)?{...o,apart:l.get(o.id)}:o).sort((o,u)=>o.label.localeCompare(u.label))}})}}function Ce(e,t,n={}){return{kind:t,members:e.graph.nodesOfKind(t),actions:xt(e,[],{kindSelection:[t],...n.principal?{principal:n.principal}:{},...n.context?{context:n.context}:{}})}}function ta(e,t){let n=(r,d)=>`${r}|${JSON.stringify(d)}`,a=new Map;for(let r of[...e.affordances,...e.withheld]){if(r.provider!=="invariant")continue;let d=n(r.mutation,r.args);a.has(d)||a.set(d,r.rank??Number.MAX_SAFE_INTEGER)}let i=Number.MAX_SAFE_INTEGER;return[...t].map((r,d)=>({repair:r,declared:d})).sort((r,d)=>(a.get(n(r.repair.mutation,r.repair.args??{}))??i)-(a.get(n(d.repair.mutation,d.repair.args??{}))??i)||r.declared-d.declared).map(r=>r.repair)}function Re(e){let t=e.schema.kinds.map(i=>({kind:i,plural:Zt(e.schema,i),count:e.graph.nodesOfKind(i).length})),n=new Map;for(let i of e.graph.allEdges()){let r=e.graph.getNode(i.from),d=e.graph.getNode(i.to);if(!r||!d)continue;let s=`${i.kind}|${r.kind}|${d.kind}`;n.set(s,(n.get(s)??0)+1)}let a=[];for(let{kind:i}of t){let r=e.schema.tryDefinition(i)?.edges??{};for(let[d,s]of Object.entries(r)){let l=s.to==="*"||s.to===void 0?(()=>{let o=[...n.keys()].filter(u=>u.startsWith(`${d}|${i}|`)).map(u=>u.split("|")[2]);return o.length>0?o:["*"]})():s.to;for(let o of l)a.push({edgeKind:d,from:i,to:o,...s.description?{description:s.description}:{},...s.inverse?{inverse:s.inverse}:{},count:n.get(`${d}|${i}|${o}`)??0})}}return{kinds:t,relations:a}}var Le=O(ve(),1);var Tt=O(ve(),1),S=O(z(),1),$a=`
2
- form:where([data-graview-part="form"]) {
3
- /* A grid item of the section above it and a grid container for the
4
- fields below: both halves are allowed to be narrower than what is in
5
- them, or a big enough text size pushes the page sideways. See the note
6
- on \`column\` in pages.tsx. */
7
- display: grid;
8
- grid-template-columns: minmax(0, 1fr);
9
- min-width: 0;
10
- gap: 12px;
11
- }
12
- label:where([data-graview-part="field"]) {
13
- display: grid;
14
- /* A track the width it was given: see the note on \`column\` in pages.tsx. */
15
- grid-template-columns: minmax(0, 1fr);
16
- min-width: 0;
17
- gap: 4px;
18
- }
19
- label:where([data-graview-part="field"][data-graview-field="boolean"]) {
20
- grid-auto-flow: column;
21
- justify-content: start;
22
- align-items: center;
23
- }
24
- span:where([data-graview-part="label"]),
25
- legend:where([data-graview-part="label"]),
26
- p:where([data-graview-part="unasked"]) {
27
- font-size: 0.8125rem;
28
- color: var(--graview-ink-muted);
29
- }
30
- p:where([data-graview-part="unasked"]) { margin: 0; }
31
- input:where([data-graview-part="control"]:not([type="checkbox"])),
32
- select:where([data-graview-part="control"]) {
33
- font: inherit;
34
- /* A TARGET IN EVERY ENGINE, not only in the one it was measured in.
35
- Padding and line height alone came to 24 in Chromium and to 22 in
36
- WebKit, which has its own intrinsic metrics for a \`select\` and rounds
37
- nothing up for anybody. So every picker on the routed face was under
38
- the WCAG 2.2 minimum in the browser iOS ships, and the check that says
39
- so (\`verify-pages\`' \`bigEnoughToHit\`) only ever ran there through
40
- \`pnpm engines\`. */
41
- min-height: 24px;
42
- /* NEVER WIDER THAN ITS FIELD. A select is as wide as its longest option,
43
- and a picker over 320 vehicles ("2027 Mercedes-Benz GLE AMG 53 4MATIC+
44
- Coupe") was 618 pixels on a 390 phone, and the whole page scrolled
45
- sideways. It shrinks to its track and cuts the option inside its box. */
46
- min-width: 0;
47
- max-width: 100%;
48
- text-overflow: ellipsis;
49
- box-sizing: border-box;
50
- padding: 7px 10px;
51
- border-radius: 8px;
52
- border: 1px solid var(--graview-edge);
53
- background: var(--graview-panel);
54
- color: var(--graview-ink);
55
- }
56
- /* A PICKER THAT STILL LOOKS LIKE ONE.
57
- WebKit ignores an author's padding and minimum height on a \`select\`
58
- while the native appearance is on \u2014 so every picker on the routed face
59
- came out 22 pixels tall in the browser iOS ships, under the 24 WCAG 2.2
60
- asks for, while the same element measured 35 in Chromium. Turning the
61
- appearance off is what makes the box the size it was asked to be, and it
62
- takes the platform's chevron with it; the chevron is put back, in the ink
63
- the scheme is already using. */
64
- span:where([data-graview-part="picker"]) {
65
- position: relative;
66
- display: grid;
67
- min-width: 0;
68
- }
69
- span:where([data-graview-part="picker"]) > select:where([data-graview-part="control"]) {
70
- appearance: none;
71
- padding-right: 28px;
72
- }
73
- span:where([data-graview-part="chevron"]) {
74
- position: absolute;
75
- right: 10px;
76
- top: 50%;
77
- transform: translateY(-50%);
78
- font-size: 0.75rem;
79
- line-height: 1;
80
- color: var(--graview-ink-muted);
81
- pointer-events: none;
82
- }
83
- fieldset:where([data-graview-part="group"]) {
84
- display: grid;
85
- gap: 10px;
86
- border: 1px solid var(--graview-edge);
87
- border-radius: 10px;
88
- padding: 12px;
89
- }
90
- fieldset:where([data-graview-part="group"][data-graview-field="list"]) { gap: 8px; }
91
- div:where([data-graview-part="item"]) {
92
- display: flex;
93
- gap: 8px;
94
- align-items: end;
95
- }
96
- button:where([data-graview-part="add"]),
97
- button:where([data-graview-part="submit"]) { justify-self: start; }
98
- p:where([data-graview-part="refused"]) {
99
- margin: 0;
100
- color: var(--graview-warn);
101
- font-size: 0.875rem;
102
- }
103
- `;function na({children:e}){return(0,S.jsxs)("span",{"data-graview-part":"picker",children:[e,(0,S.jsx)("span",{"aria-hidden":"true","data-graview-part":"chevron",children:"\u25BE"})]})}var Ea=e=>({label:re(e),option:t=>t});function it({store:e,spec:t,value:n,onChange:a,prefilled:i,open:r,words:d=Ea}){if(t.name in i&&t.control!=="group"&&t.control!=="variant")return null;let l=(t.control==="node"&&!t.kinds.includes("*")?t.kinds.map(o=>re(be(e.schema.tryDefinition(o),o))).join(" or "):d(t.name).label)+(t.optional||t.control==="boolean"?"":" *");switch(t.control){case"text":case"date":return t.control==="text"&&t.long?(0,S.jsxs)("label",{"data-graview-part":"field","data-graview-field":"text",children:[(0,S.jsx)("span",{"data-graview-part":"label",children:l}),(0,S.jsx)("textarea",{name:t.name,required:!t.optional,rows:6,value:typeof n=="string"?n:"",onChange:o=>a(o.target.value),"data-graview-part":"control",style:{fieldSizing:"content",minHeight:"7.5em",resize:"vertical",font:"inherit",lineHeight:1.5}})]}):(0,S.jsxs)("label",{"data-graview-part":"field","data-graview-field":t.control,children:[(0,S.jsx)("span",{"data-graview-part":"label",children:l}),(0,S.jsx)("input",{type:t.control==="date"?t.time?"datetime-local":"date":"text",name:t.name,required:!t.optional,value:typeof n=="string"?n:"",onChange:o=>a(o.target.value),"data-graview-part":"control"})]});case"number":return(0,S.jsxs)("label",{"data-graview-part":"field","data-graview-field":t.control,children:[(0,S.jsx)("span",{"data-graview-part":"label",children:l}),(0,S.jsx)("input",{type:"number",name:t.name,required:!t.optional,...t.min===void 0?{}:{min:t.min},...t.max===void 0?{}:{max:t.max},...t.step===void 0?{}:{step:t.step},value:typeof n=="number"?n:"",onChange:o=>a(o.target.value===""?void 0:Number(o.target.value)),"data-graview-part":"control"})]});case"boolean":return(0,S.jsxs)("label",{"data-graview-part":"field","data-graview-field":"boolean",children:[(0,S.jsx)("input",{type:"checkbox",name:t.name,checked:n===!0,onChange:o=>a(o.target.checked),"data-graview-part":"control"}),(0,S.jsx)("span",{"data-graview-part":"label",children:l})]});case"choice":return(0,S.jsxs)("label",{"data-graview-part":"field","data-graview-field":t.control,children:[(0,S.jsx)("span",{"data-graview-part":"label",children:l}),(0,S.jsx)(na,{children:(0,S.jsxs)("select",{name:t.name,required:!t.optional,value:typeof n=="string"?n:"",onChange:o=>a(o.target.value||void 0),"data-graview-part":"control",children:[(0,S.jsx)("option",{value:"",children:"\u2014"}),(t.options??[]).map(o=>(0,S.jsx)("option",{value:o,children:d(t.name).option(o)},o))]})})]});case"node":{let o=r.find(y=>y.name===t.name)?.candidates,u=new Set(Object.values(i).filter(y=>typeof y=="string")),m=(t.kinds.includes("*")?[...e.graph.allNodes()]:t.kinds.flatMap(y=>e.graph.nodesOfKind(y))).filter(y=>!u.has(y.id)),g=o?o.map(y=>e.graph.getNode(y)).filter(y=>y!==void 0):m,c=je(g,y=>e.schema.tryDefinition(y));return(0,S.jsxs)("label",{"data-graview-part":"field","data-graview-field":t.control,children:[(0,S.jsx)("span",{"data-graview-part":"label",children:l}),(0,S.jsx)(na,{children:(0,S.jsxs)("select",{name:t.name,required:!t.optional,value:typeof n=="string"?n:"",onChange:y=>a(y.target.value||void 0),"data-graview-part":"control",children:[(0,S.jsx)("option",{value:"",children:"\u2014"}),g.map(y=>{let P=c.get(y.id);return(0,S.jsxs)("option",{value:y.id,children:[ae(e.schema.tryDefinition(y.kind),y),P?` \xB7 ${P}`:""]},y.id)})]})})]})}case"group":{let o=n??{};return(0,S.jsxs)("fieldset",{"data-graview-part":"group","data-graview-field":t.control,children:[(0,S.jsx)("legend",{"data-graview-part":"label",children:l}),t.fields.map(u=>(0,S.jsx)(it,{store:e,spec:u,value:o[u.name],onChange:m=>a({...o,[u.name]:m}),prefilled:i,open:r,words:d},u.name))]})}case"variant":{let o=n??{},u=typeof o[t.tag]=="string"?o[t.tag]:"",m=t.options.find(g=>g.value===u);return(0,S.jsxs)("fieldset",{"data-graview-part":"group","data-graview-field":t.control,children:[(0,S.jsx)("legend",{"data-graview-part":"label",children:l}),(0,S.jsxs)("label",{"data-graview-part":"field","data-graview-field":"choice",children:[(0,S.jsx)("span",{"data-graview-part":"label",children:re(t.tag)}),(0,S.jsxs)("select",{value:u,onChange:g=>a({[t.tag]:g.target.value}),"data-graview-part":"control",children:[(0,S.jsx)("option",{value:"",children:"\u2014"}),t.options.map(g=>(0,S.jsx)("option",{value:g.value,children:re(g.value)},g.value))]})]}),m?.fields.map(g=>(0,S.jsx)(it,{store:e,spec:g,value:o[g.name],onChange:c=>a({...o,[g.name]:c}),prefilled:i,open:r,words:d},g.name))]})}case"list":{let o=Array.isArray(n)?n:[];return(0,S.jsxs)("fieldset",{"data-graview-part":"group","data-graview-field":"list",children:[(0,S.jsx)("legend",{"data-graview-part":"label",children:l}),o.map((u,m)=>(0,S.jsxs)("div",{"data-graview-part":"item",children:[(0,S.jsx)("div",{style:{flex:1},children:(0,S.jsx)(it,{store:e,spec:{...t.item,optional:!1},value:u,onChange:g=>a(o.map((c,y)=>y===m?g:c)),prefilled:i,open:r,words:d})}),(0,S.jsx)("button",{type:"button","data-graview-part":"remove",onClick:()=>a(o.filter((g,c)=>c!==m)),children:"remove"})]},m)),(0,S.jsx)("button",{type:"button","data-graview-part":"add",onClick:()=>a([...o,void 0]),children:"add another"})]})}case"opaque":return(0,S.jsxs)("p",{"data-graview-part":"unasked",children:["\u201C",re(t.name),"\u201D needs a structured answer this form cannot ask for yet."]})}}function ye({store:e,mutation:t,prefilled:n={},open:a=[],onDone:i,principal:r,initial:d,label:s,only:l}){let[o,u]=(0,Tt.useState)(()=>({...d})),[m,g]=(0,Tt.useState)(null),c=Je(t.input).filter(P=>l===void 0||l.includes(P.name)),y=P=>an(e.schema,t,P);return(0,S.jsxs)("form",{"data-testid":`form-${t.name}`,onSubmit:P=>{P.preventDefault();try{e.apply({name:t.name,args:{...fn(c,o),...n}},r?{author:r}:{}),g(null),u({}),i?.()}catch(F){g(_e(e.schema,e.allMutations(),F))}},"data-graview-part":"form",children:[(0,S.jsx)("style",{children:$a}),c.map(P=>(0,S.jsx)(it,{store:e,spec:P,value:o[P.name],onChange:F=>u(C=>({...C,[P.name]:F})),prefilled:n,open:a,words:y},P.name)),m?(0,S.jsx)("p",{"data-testid":"refused","data-graview-part":"refused",role:"alert",children:m}):null,(0,S.jsx)("button",{type:"submit","data-graview-part":"submit",children:s??t.title??t.name})]})}var b=O(z(),1);function ce(e){let t=e.views;if(!t)return[];let n=new Set(Pe(e.store,e.principal));return t.places().filter(a=>n.has(a.kind))}var Ae=e=>`place:${e.kind}:${e.as}`;function ge(e,t){let n=(e.views?.places()??[]).some(a=>a.as===t.as&&a.kind!==t.kind);return Vn(t.as,n?G(e.store.schema,t.kind):void 0)}function Ke(e,t){let n=e.schema.tryDefinition(t);return e.graph.nodesOfKind(t).filter(a=>$e(n,a))}function Mt(e,t,n){let a=(r,d)=>Xt(e.schema,d,r),i=a(Ke(e,t).length,t);return n?`${i} across ${a(Ke(e,n).length,n)}`:i}function $t({context:e,place:t,chosen:n}){let{store:a,views:i,invariantContext:r}=e,s=i?.resolve(t.kind,{cardinality:"many",fidelity:"full"},t.as)?.view;if(!s)return null;let l=Ke(a,t.kind),o=[...new Set(a.violations(r).flatMap(u=>u.nodeIds))];return(0,b.jsx)(St,{kind:t.kind,view:t.title,children:(0,b.jsx)(s,{nodes:l,label:t.title,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1,...n&&n.length>0?{implicated:n}:{},...o.length>0?{flagged:o}:{}})})}function Oa({store:e,views:t,as:n,invariantContext:a}){V(e);let i={store:e,views:t,...a?{invariantContext:a}:{}},r=t.places().find(d=>d.as===n);return r?(0,b.jsx)($t,{context:i,place:r}):null}function Fa({context:e,kind:t}){let{store:n,views:a,invariantContext:i}=e,r=Ke(n,t),d=n.schema.tryDefinition(t),s=I(n,t),o=a?.resolve(t,{cardinality:"many",fidelity:"full"})?.view,u=[...new Set(n.violations(i).flatMap(y=>y.nodeIds))];if(o&&!Ee(o))return(0,b.jsx)(St,{kind:t,children:(0,b.jsx)(o,{nodes:r,label:s,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1,...u.length>0?{flagged:u}:{}})});let m=a?.resolve(t,{cardinality:"one",fidelity:"summary"})?.view,g=8,c=r.slice(0,g);return(0,b.jsxs)("div",{"data-testid":"kind-sheet",style:m?{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gridAutoRows:"max-content",alignContent:"center",gap:12,padding:24}:{display:"flex",flexWrap:"wrap",alignContent:"center",justifyContent:"center",gap:10,padding:24},children:[c.map(y=>m?(0,b.jsx)(m,{node:y,fidelity:"summary",cardinality:"one",mode:"fullscreen",selected:!1,...u.includes(y.id)?{flagged:[y.id]}:{}},y.id):(0,b.jsx)("span",{style:{fontSize:"1.0625rem",padding:"8px 14px",borderRadius:8,border:"1px solid var(--graview-edge-bright)",background:"var(--graview-ground)",color:"var(--graview-ink)"},children:ae(d,y)},y.id)),r.length>g?(0,b.jsxs)("span",{style:{...k,alignSelf:"center",padding:"0 6px"},children:["+",r.length-g," more ",s.toLowerCase()]}):null]})}function Et(e){let{store:t}=e,n=jn(e),a=[...ce(e)].sort((r,d)=>n.indexOf(r.kind)-n.indexOf(d.kind)),i=new Set(a.map(r=>r.kind));return[...a.map(r=>({key:Ae(r),kind:r.kind,title:r.title,to:ge(e,r),place:r})),...at(e).filter(r=>!i.has(r)).map(r=>({key:`kind:${r}`,kind:r,title:I(t,r),to:`/${G(t.schema,r)}`}))]}var aa=.72,Wa=540,ra=16/10;function Na(e){let t=(0,Le.useRef)(null),[n,a]=(0,Le.useState)(e);return(0,Le.useLayoutEffect)(()=>{let i=t.current;if(!i||typeof ResizeObserver>"u")return;let r=()=>{let s=i.getBoundingClientRect().width;s>0&&a(l=>Math.abs(l-s)<.5?l:s)};r();let d=new ResizeObserver(r);return d.observe(i),()=>d.disconnect()},[]),{ref:t,width:n}}function Ot({context:e,entry:t}){let{store:n,brand:a,principal:i}=e,{ref:r,width:d}=Na(Wa),s=d/aa,l=Ke(n,t.kind),o=n.schema.tryDefinition(t.kind),u=l.length===0?Ce(n,t.kind,{...i?{principal:i}:{},...e.invariantContext?{context:e.invariantContext}:{}}).actions.affordances[0]:void 0,m=t.place!==void 0;return(0,b.jsxs)(A,{to:t.to,"data-testid":m?"place-card":"kind-card",className:"graview-gallery-card",style:{...J,display:"grid",gap:10,alignContent:"start",minWidth:0},children:[(0,b.jsxs)("span",{ref:r,"data-testid":m?"place-picture":"kind-picture","aria-hidden":"true",inert:!0,style:{display:"block",position:"relative",width:"100%",aspectRatio:`${ra}`,overflow:"hidden",borderRadius:12,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",pointerEvents:"none"},children:[(0,b.jsx)("span",{style:{position:"absolute",left:0,top:0,width:s,height:s/ra,display:"grid",gridTemplateRows:"minmax(0, 1fr)",transform:`scale(${aa})`,transformOrigin:"0 0"},children:t.place?(0,b.jsx)($t,{context:e,place:t.place}):(0,b.jsx)(Fa,{context:e,kind:t.kind})}),l.length===0?(0,b.jsx)("span",{"data-testid":"picture-empty",style:{position:"absolute",inset:0,display:"grid",placeContent:"center",justifyItems:"center",gap:2,padding:20,textAlign:"center"},children:(0,b.jsxs)("span",{style:{display:"grid",gap:2,padding:"10px 16px",borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-ground)",color:"var(--graview-ink)"},children:[(0,b.jsxs)("span",{style:{fontFamily:xe,fontWeight:600,fontSize:"1.0625rem"},children:["No ",I(n,t.kind).toLowerCase()," yet"]}),u?(0,b.jsxs)("span",{style:k,children:["Begin with \u201C",u.label,"\u201D"]}):null]})}):null]}),(0,b.jsxs)("span",{style:{display:"grid",gap:2,minWidth:0},children:[(0,b.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[m?null:(0,b.jsx)(ee,{kind:t.kind,brand:a,schema:n.schema,size:8}),(0,b.jsx)("span",{style:{fontFamily:xe,fontSize:"1.25rem",fontWeight:600,lineHeight:1.3,overflowWrap:"anywhere"},children:t.title})]}),(0,b.jsxs)("span",{style:k,children:[t.place?Mt(n,t.place.kind,t.place.across):Mt(n,t.kind),!m&&o?.description?` \xB7 ${o.description}`:null]})]})]})}var ia={display:"grid",gap:"32px 28px",gridTemplateColumns:"repeat(auto-fill, minmax(min(420px, 100%), 1fr))"},Da=`
104
- .graview-gallery-card > span:first-child { transition: border-color 160ms ease, box-shadow 160ms ease; }
105
- .graview-gallery-card:hover > span:first-child,
106
- .graview-gallery-card:focus-visible > span:first-child { border-color: var(--graview-edge-bright); box-shadow: 0 1px 0 var(--graview-edge), 0 10px 30px -18px var(--graview-ink); }
107
- `;function Ft({context:e}){V(e.store);let t=Et(e);return t.length===0?null:(0,b.jsxs)("section",{style:ia,"data-testid":"gallery",children:[(0,b.jsx)("style",{children:Da}),t.map(n=>(0,b.jsx)(Ot,{context:e,entry:n},n.key))]})}function Wt({context:e}){let{store:t}=e;V(t);let n=ce(e),a=Et(e);return(0,b.jsxs)(U,{context:e,style:Fe,children:[(0,b.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,b.jsx)("p",{style:se,children:n.length===0?"None of its own yet":`${n.length} ${n.length===1?"picture":"pictures"}`}),(0,b.jsx)(Y,{context:e,children:"Pictures"}),(0,b.jsx)("p",{style:_,children:n.length===0?"Nothing here has a picture of its own yet, so each kind is drawn as the scene draws it. Title a group view and it appears here by name.":"The ways this installation looks at what it holds \u2014 each one the same picture the scene shows, here as a page."})]}),a.length>0?(0,b.jsx)("div",{style:ia,"data-testid":"places",children:a.map(i=>(0,b.jsx)(Ot,{context:e,entry:i},i.key))}):null]})}function Nt({context:e}){let{store:t,principal:n}=e;V(t);let a=ke(),i=he(),[r]=We(),d=decodeURIComponent(a.as??""),[s,l]=(0,Le.useState)(null),o=r.get("of"),m=ce(e).find(P=>P.as===d&&(!o||G(t.schema,P.kind)===o));if(!m)return(0,b.jsxs)(U,{context:e,children:[(0,b.jsx)(Y,{context:e,children:"No picture is called that."}),(0,b.jsx)("p",{style:_,children:(0,b.jsx)(A,{to:"/places",style:$,children:"The pictures there are \u2192"})})]});let g=I(t,m.kind),y=Ce(t,m.kind,{...n?{principal:n}:{},...e.invariantContext?{context:e.invariantContext}:{}}).actions.affordances.map(P=>({affordance:P,mutation:t.allMutations().find(F=>F.name===P.mutation)})).filter(P=>P.mutation!==void 0);return(0,b.jsxs)(U,{context:e,style:Fe,children:[(0,b.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,b.jsx)(Y,{context:e,children:m.title}),(0,b.jsxs)("p",{style:_,"data-testid":"place-lede",children:[Mt(t,m.kind,m.across),"."]}),(0,b.jsx)("p",{style:{...k,margin:0},children:(0,b.jsxs)(A,{to:`/${G(t.schema,m.kind)}`,style:{...$,...k},"data-testid":"place-as-list",children:["All ",g.toLowerCase()," as a list \u2192"]})})]}),(0,b.jsx)("div",{"data-testid":"place-lens",style:{height:"min(72vh, 760px)",display:"grid",gridTemplateRows:"minmax(0, 1fr)",overflow:"auto",maxWidth:"100%",borderRadius:12,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)"},onClick:P=>{let F=P.target?.closest("[data-graview-pick]"),C=F?.getAttribute("data-graview-pick"),K=F?.getAttribute("data-graview-joins");if(K)try{let X=JSON.parse(K);if(Array.isArray(X)&&X.every(we=>typeof we=="string")){P.preventDefault(),l({at:Ae(m),ids:X});return}}catch{}if(!C)return;let ue=t.graph.getNode(C);ue&&(P.preventDefault(),i(q(t.schema,ue.kind,C)))},children:(0,b.jsx)($t,{context:e,place:m,...s?.at===Ae(m)?{chosen:s.ids}:{}})}),(0,b.jsx)("div",{style:{maxWidth:760,display:"grid",gap:40},children:y.map(({affordance:P,mutation:F})=>(0,b.jsxs)("section",{style:{...j,display:"grid",gap:14},children:[(0,b.jsx)("h2",{style:D,children:F.title??F.name}),F.description?(0,b.jsx)("p",{style:{...k,margin:0,maxWidth:"58ch"},children:F.description}):null,(0,b.jsx)(ye,{store:t,mutation:F,prefilled:P.args,open:P.open,label:P.label,...n?{principal:n}:{}})]},P.id))})]})}var W=O(ve(),1);var Te=O(ve(),1);function oa(e,t,n){let a=Math.max(0,e.left),i=Math.min(t.width,e.right),r=Math.max(0,e.top),d=Math.min(t.height,e.bottom);return{shown:d-r>=n.height+2*16&&i-a>=n.width+2*16,left:Math.round(a),top:Math.round(r),width:Math.round(Math.max(0,i-a)),height:Math.round(Math.max(0,d-r))}}function sa(e,t,n){let a=e.style;a.left=`${t.left}px`,a.top=`${t.top}px`,a.right="auto",a.bottom="auto",a.visibility=n?"":"hidden";let i=e.getBoundingClientRect();i.width!==0&&(a.left=`${Math.round(2*t.left-i.left)}px`,a.top=`${Math.round(2*t.top-i.top)}px`)}var Se=O(z(),1);function la({context:e}){let t=he(),n=oe(),{pathname:a}=de(),[,i,r]=a.split("/"),d=i==="places"&&r?decodeURIComponent(r):void 0,s=(0,Te.useRef)(null);return Ka(s,n!==null),n?(0,Se.jsxs)(Se.Fragment,{children:[(0,Se.jsx)(Ha,{context:e}),(0,Se.jsx)("div",{ref:s,"data-testid":"page-seat",style:{position:"fixed",left:0,top:0,width:"100vw",height:"100dvh",pointerEvents:"none",zIndex:un("rail"),containerType:"size"},children:(0,Se.jsx)(Hn,{onPick:l=>{let o=e.store.graph.getNode(l);o&&t(q(e.store.schema,o.kind,l))},onMove:l=>{if(n.seatTalk.get().draft&&n.seatTalk.setDraft(null),l.to==="place"&&(l.face==="scene"||l.slug==="overview")){e.overview?e.overview("#"):e.embedded||window.location.assign(e.sceneHref??"/");return}t(l.address)},...d?{place:d}:{},onDraft:()=>{a!=="/~draft"&&t("/~draft")}})})]}):null}var Ia={width:160,height:40};function Ka(e,t){let{pathname:n}=de();(0,Te.useLayoutEffect)(()=>{let a=e.current;if(!a)return;let i=a.parentElement?.closest("[data-embed-content]")??null,r=()=>i??document.querySelector("main")??null,d=()=>{let u=r(),m={width:document.documentElement.clientWidth||innerWidth,height:innerHeight},g=u?.getBoundingClientRect()??{left:0,top:0,right:m.width,bottom:m.height},c=oa(i?g:{left:g.left,right:g.right,top:g.top,bottom:Math.max(g.bottom,m.height)},m,Ia);a.style.width=`${c.width}px`,a.style.height=`${c.height}px`,sa(a,c,c.shown)};d(),addEventListener("resize",d),addEventListener("scroll",d,!0);let s=0,l=typeof ResizeObserver=="function"?new ResizeObserver(()=>{cancelAnimationFrame(s),s=requestAnimationFrame(d)}):null,o=r();return o&&l?.observe(o),()=>{cancelAnimationFrame(s),l?.disconnect(),removeEventListener("resize",d),removeEventListener("scroll",d,!0)}},[e,t,n])}function Ha({context:e}){let{store:t}=e,n=oe(),{pathname:a}=de(),i=(0,Te.useRef)(n?.setSelection);return i.current=n?.setSelection,(0,Te.useEffect)(()=>{let r=i.current;if(!r)return;let[,d,s]=a.split("/"),l=(()=>{if(d==="places"){let u=e.views?.places().find(m=>m.as===decodeURIComponent(s??""));return u?[Ie(u.kind)]:[]}let o=d?fe(t.schema,d):void 0;return o&&s?[decodeURIComponent(s)]:o?[wn(o)]:[]})();r(o=>o.length===l.length&&o.every((u,m)=>u===l[m])?o:l)},[a]),null}var te=O(ve(),1);var pa=O(Ma(),1);var Q=O(z(),1);var za=(0,te.lazy)(hn(()=>import("./chunk.XUXCDUKC.js").then(e=>({default:e.TakeBack}))));function Ba({context:e,docked:t,at:n}){let{store:a}=e,i=V(a),[r]=(0,te.useState)(()=>a.batches().length),d=(0,te.useRef)(!1);return d.current||=i>0||!t&&r>0,d.current?(0,Q.jsx)(te.Suspense,{fallback:null,children:(0,Q.jsx)(za,{context:e,docked:t,at:n,since:r})}):null}function Ga(e,t,n){let{store:a,principal:i,embedded:r}=e;(0,te.useEffect)(()=>{if(!n)return;let d=s=>{if(!qn(s))return;let l=s.target,o=l instanceof Node&&t.current?.contains(l),u=l===document.body||l===document.documentElement||l===document;if(!(!o&&!(u&&!r))&&Bn(a,i)){s.preventDefault();try{Gn(a,i)}catch{}}};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[a,i,r,t,n])}function ca({context:e,registry:t,root:n,children:a}){let i=(0,te.useMemo)(Xn,[]),r=t?.without()??new Set;return Ga(e,n,!r.has("undo")),(0,Q.jsxs)(Rt.Provider,{value:i,children:[(0,Q.jsx)(qa,{context:e,placed:i,without:r}),a]})}function qa({context:e,placed:t,without:n}){let[a,i]=(0,te.useState)(!1);(0,te.useLayoutEffect)(()=>i(!0),[]);let r=At(t,"find"),d=At(t,"undo"),s=de(),l=Tn();if(!a)return null;let o=s.pathname.split("/").filter(Boolean),m=(o.length===1?fe(e.store.schema,o[0]):void 0)!==void 0;return(0,Q.jsxs)(Q.Fragment,{children:[!r&&!n.has("find")&&l?(0,pa.createPortal)((0,Q.jsx)(da,{context:e,narrowsLists:m}),l.slot):null,!r&&!n.has("find")&&!l?(0,Q.jsx)("div",{"data-testid":"face-find-bar",style:{display:"flex",alignItems:"center",padding:"8px 16px",borderBottom:"1px solid var(--graview-edge)",background:"var(--graview-bar)",minWidth:0},children:(0,Q.jsx)(da,{context:e,narrowsLists:m})}):null,!d&&!n.has("undo")?(0,Q.jsx)(Ba,{context:e,docked:!0,at:s.pathname+s.search}):null,l?.own&&!n.has("undo")?(0,Q.jsx)(_n,{context:e,own:l.own}):null]})}function da({context:e,narrowsLists:t}){return(0,Q.jsx)(Rt.Provider,{value:null,children:(0,Q.jsx)(Lt,{context:e,narrowsLists:t})})}var T=O(z(),1);function ga(e,t){return t==="*"?{label:"anything",path:null}:{label:I(e,t),path:`/${G(e.schema,t)}`}}function Va({context:e,relation:t}){let{store:n}=e,a=ga(n,t.from),i=ga(n,t.to),r=d=>d.path?(0,T.jsx)(A,{to:d.path,style:{...J,fontWeight:550},children:d.label}):(0,T.jsx)("span",{children:d.label});return(0,T.jsxs)("li",{"data-testid":"relation","data-relation":t.edgeKind,style:{display:"grid",gridTemplateColumns:"30px minmax(0, 1fr) auto",gap:12,alignItems:"baseline"},children:[(0,T.jsx)(zn,{edgeKind:t.edgeKind,...e.brand?.kit?{kit:e.brand.kit}:{}}),(0,T.jsxs)("span",{style:{display:"grid",gap:1},children:[(0,T.jsxs)("span",{children:[r(a)," ",(0,T.jsxs)("span",{style:k,"data-graview-speaks-ids":"",children:[re(t.edgeKind)," \u2192"]})," ",r(i)]}),t.description||t.inverse?(0,T.jsxs)("span",{style:{...k,fontSize:"0.9375rem"},children:[t.description?le(t.description):null,t.description&&t.inverse?" \xB7 ":null,t.inverse?`from the other end, ${t.inverse}`:null]}):null]}),i.path?(0,T.jsx)(A,{to:`${i.path}?with=${encodeURIComponent(t.edgeKind)}`,style:{...$,...k,fontVariantNumeric:"tabular-nums",display:"inline-block",minWidth:24,minHeight:24,textAlign:"center"},title:`The ${i.label.toLowerCase()} that have this`,children:t.count}):(0,T.jsx)("span",{style:{...k,fontVariantNumeric:"tabular-nums"},children:t.count})]})}function ua({context:e,heading:t=!0}){let{store:n}=e,a=new Set(Pe(n,e.principal)),i=Re(n).relations.filter(r=>a.has(r.from)&&(r.to==="*"||a.has(r.to)));return i.length===0?null:(0,T.jsxs)("section",{style:{...j,display:"grid",gap:12},"data-testid":"kind-map",children:[t?(0,T.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap"},children:[(0,T.jsx)("h2",{style:D,children:(0,T.jsx)(A,{to:"/map",style:J,children:"Connections"})}),(0,T.jsx)("span",{style:k,children:i.length===1?"1 relation":`${i.length} relations`})]}):null,(0,T.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:10},children:i.map(r=>(0,T.jsx)(Va,{context:e,relation:r},`${r.edgeKind}|${r.from}|${r.to}`))})]})}function Dt({context:e}){let{store:t}=e;V(t);let n=new Set(Pe(t,e.principal)),a=Re(t),i=a.relations.filter(r=>n.has(r.from));return(0,T.jsxs)(U,{context:e,children:[(0,T.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,T.jsx)("p",{style:se,children:i.length===0?"No relations":`${i.length} ${i.length===1?"relation":"relations"}`}),(0,T.jsx)(Y,{context:e,children:"Connections"}),(0,T.jsx)("p",{style:_,children:i.length===0?"Nothing here is declared to relate to anything else yet.":"The kinds this installation holds, and the relations declared between them \u2014 each in the declaration's own words, with how many of it there are."})]}),(0,T.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"6px 18px"},"data-testid":"map-kinds",children:a.kinds.filter(r=>n.has(r.kind)).map(r=>(0,T.jsxs)("li",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,T.jsx)(ee,{kind:r.kind,brand:e.brand,schema:t.schema,size:7}),(0,T.jsx)(A,{to:`/${G(t.schema,r.kind)}`,style:$,children:r.plural}),(0,T.jsx)("span",{style:k,children:r.count})]},r.kind))}),(0,T.jsx)(ua,{context:e,heading:!1})]})}function ma({context:e}){let n=[...oe()?.robots.values()??[]].filter(i=>i.mode==="asking"&&i.say);if(n.length===0)return null;let{store:a}=e;return(0,T.jsxs)("section",{style:{...j,display:"grid",gap:10},"data-testid":"seat-questions",children:[(0,T.jsx)("h2",{style:D,children:n.length===1?"The seat asked something":`The seat asked ${n.length} things`}),(0,T.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:8},children:n.map(i=>{let r=i.at?a.graph.getNode(i.at):void 0;return(0,T.jsxs)("li",{style:{display:"grid",gap:2},children:[(0,T.jsx)("span",{children:i.say}),r?(0,T.jsxs)(A,{to:q(a.schema,r.kind,r.id),style:{...$,...k},children:[ae(a.schema.tryDefinition(r.kind),r)," \u2192"]}):null]},i.participant)})})]})}var E=O(z(),1);function It({context:e}){let{principal:t}=e,{store:n,brand:a,invariantContext:i}=e;V(n);let r=n.violations(i),d=`${r.length===1?"A rule is broken":"Rules are broken"} \u2014 see what, and what would fix it`,s=[...n.log.all()].slice(-5).reverse(),o=at(e).map(C=>({kind:C,members:n.graph.nodesOfKind(C).filter(K=>$e(n.schema.tryDefinition(C),K))})),u=o.filter(C=>C.members.length>0),m=o.map(C=>({entry:C,creator:n.allMutations().find(K=>(K.creates??[]).includes(C.kind)&&n.permits({name:K.name,args:{}},e.principal).ok)})).find(C=>C.creator!==void 0),g=u.length===0?"Nothing here yet.":`${u.map(C=>`${C.members.length} ${C.members.length===1?C.kind:I(n,C.kind).toLowerCase()}`).join(", ").replace(/, ([^,]*)$/," and $1")}.`,c=e.views?.homeView?.(),y=n.schema.kinds.some(C=>n.graph.nodesOfKind(C).length>0);if(c&&y){let C=a?.subtitle?(0,E.jsx)("p",{style:{...k,margin:0},"data-testid":"app-subtitle",children:a.subtitle}):null,K=c[Symbol.for("graview.home-blocks")]===!0;return(0,E.jsx)(U,{context:e,style:Fe,children:(0,E.jsxs)("div",{style:{display:"grid",gap:12},"data-testid":"home-view",children:[K?null:C,r.length>0?(0,E.jsx)(A,{to:"/problems",style:{...$,color:"var(--graview-warn)"},children:d}):null,(0,E.jsx)(In.Provider,{value:K?C:null,children:(0,E.jsx)(c,{cardinality:"many",fidelity:"full",mode:"fullscreen",selected:!1})})]})})}let P=new Set(Pe(n,e.principal)),F=Re(n).relations.filter(C=>P.has(C.from)&&(C.to==="*"||P.has(C.to)));return(0,E.jsxs)(U,{context:e,style:Fe,children:[(0,E.jsxs)("header",{style:{display:"grid",gap:12},children:[a?.subtitle?(0,E.jsx)("p",{style:{...k,margin:0},"data-testid":"app-subtitle",children:a.subtitle}):null,(0,E.jsx)(Y,{context:e,"data-testid":"standing",children:g}),(0,E.jsxs)("p",{style:{..._,display:"grid",gap:4},"data-testid":"standing-card",children:[u.length===0&&m?(0,E.jsxs)("span",{children:["Begin with \u201C",m.creator?.title??m.creator?.name,"\u201D, under"," ",(0,E.jsx)(A,{to:`/${G(n.schema,m.entry.kind)}`,style:$,children:I(n,m.entry.kind)}),"."]}):null,r.length===0?(0,E.jsx)("span",{children:"All rules hold."}):(0,E.jsx)(A,{to:"/problems",style:{...$,color:"var(--graview-warn)"},children:d})]})]}),(0,E.jsx)(Ft,{context:e}),(0,E.jsxs)("section",{style:{...j,display:"grid",gap:14},"data-testid":"kinds",children:[(0,E.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap"},children:[(0,E.jsx)("h2",{style:D,children:"What is here"}),F.length>0?(0,E.jsxs)(A,{to:"/map",style:{...$,...k,marginLeft:"auto"},"data-testid":"map-link",children:["Connections \xB7 ",F.length===1?"1 relation":`${F.length} relations`," \u2192"]}):null]}),(0,E.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"8px 10px"},children:o.map(({kind:C,members:K})=>(0,E.jsx)("li",{style:{maxWidth:"100%"},children:(0,E.jsxs)(A,{to:`/${G(n.schema,C)}`,style:{...J,flexWrap:"wrap",gap:8,padding:"6px 14px 6px 10px",borderRadius:8,border:"1px solid var(--graview-edge-bright)",background:"var(--graview-panel)"},children:[(0,E.jsx)(ee,{kind:C,brand:a,schema:n.schema,size:7}),(0,E.jsx)("span",{style:{fontWeight:550,overflowWrap:"anywhere"},children:I(n,C)}),(0,E.jsx)("span",{style:{...k,fontVariantNumeric:"tabular-nums"},children:K.length===0?"none yet":K.length})]})},C))})]}),s.length>0?(0,E.jsxs)("section",{style:{...j,display:"grid",gap:10},children:[(0,E.jsx)("h2",{style:D,children:"Recently"}),(0,E.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},children:s.map(C=>(0,E.jsxs)("li",{style:k,children:[(0,E.jsx)("span",{style:{color:"var(--graview-ink)"},children:C.intent})," \u2014 ",tt(C,t,{graph:n.graph,schema:n.schema,...e.seats?{seats:e.seats}:{},...e.people?{people:e.people}:{}})]},C.id))})]}):null]})}var Me=O(ve(),1);var R=O(z(),1);function Kt({context:e}){let{store:t,brand:n,principal:a,invariantContext:i}=e;V(t);let[r]=We(),d=r.get("q")??"",s=typeof i?.today=="string"?i.today:void 0,l=gn(t,d,{...a?{principal:a}:{},places:ce(e),flagged:new Set(t.violations(i).flatMap(c=>c.nodeIds)),...s?{today:s}:{},limit:200}),o=l.hits.filter(c=>c.about==="node"),u=l.hits.filter(c=>c.about==="kind"||c.about==="place"||c.about==="rule"),m=[...new Set(o.map(c=>c.kind))],g=d.trim();return(0,R.jsxs)(U,{context:e,children:[(0,R.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,R.jsx)("p",{style:se,children:"Search"}),(0,R.jsx)(Y,{context:e,"data-testid":"search-heading",children:g.length===0?"Find anything by its name":l.hits.length===0?(0,R.jsxs)(R.Fragment,{children:["Nothing here is called \u201C",g,"\u201D."]}):(0,R.jsxs)(R.Fragment,{children:[Ua(t,l.byKind)," for \u201C",g,"\u201D"]})}),g.length>0?(0,R.jsxs)("p",{style:{...k,margin:0},"data-testid":"search-searched",children:[Ye(t.schema,l.searched),l.conditions.filter(c=>c.key!=="is"&&c.admittedBy.length<l.searched.kinds.length).map(c=>(0,R.jsxs)("span",{children:[" ",c.key,":",c.value," narrows"," ",c.admittedBy.length===0?"nothing here":c.admittedBy.map(y=>I(t,y).toLowerCase()).join(" and "),"."]},`${c.key}:${c.value}`))]}):(0,R.jsxs)("p",{style:_,children:["Type in the box above. Words find the start of words in names and in what each record says;"," ",(0,R.jsx)("code",{children:"done:false"})," and the like narrow as a list does, and ",(0,R.jsx)("code",{children:"is:any"})," includes what is past."]})]}),u.length>0?(0,R.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},"data-testid":"search-named",children:u.map(c=>(0,R.jsx)("li",{"data-testid":"search-hit","data-about":c.about,children:c.about==="kind"?(0,R.jsxs)(A,{to:`/${G(t.schema,c.kind)}`,style:$,children:[c.label,c.count>0?(0,R.jsxs)("span",{style:k,children:[" \xB7 ",c.count," match"]}):null]}):c.about==="place"?(0,R.jsxs)(A,{to:ge(e,c),style:$,children:["Go to ",c.title]}):c.about==="rule"?(0,R.jsxs)(A,{to:"/problems",style:$,children:["The rule \u201C",c.label,"\u201D"]}):null},`${c.about}:${c.about==="rule"?c.name:c.about==="place"?c.as:c.kind}`))}):null,m.map(c=>(0,R.jsxs)("section",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:0,minWidth:0},"data-testid":"search-group","data-kind":c,children:[(0,R.jsxs)("h2",{style:{...D,fontSize:"1.0625rem",marginBottom:4,display:"flex",alignItems:"center",gap:8},children:[(0,R.jsx)(ee,{kind:c,brand:n,schema:t.schema,size:8}),(0,R.jsx)(A,{to:`/${G(t.schema,c)}?${new URLSearchParams({q:g}).toString()}`,style:$,"data-testid":"search-kind-link",children:I(t,c)}),(0,R.jsx)("span",{style:k,children:l.byKind[c]})]}),(0,R.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:0},children:o.filter(y=>y.kind===c).map(y=>(0,R.jsxs)("li",{"data-testid":"search-hit","data-about":"node",style:{display:"grid",gap:2,padding:"12px 0",minWidth:0,borderTop:"1px solid var(--graview-edge)"},children:[(0,R.jsxs)(A,{to:q(t.schema,c,y.id),style:{...J,fontFamily:xe,fontSize:"1.1875rem",fontWeight:600,lineHeight:1.3,overflowWrap:"anywhere"},children:[y.flagged?(0,R.jsx)("span",{style:{color:"var(--graview-warn)"},children:"\u26A0 "}):null,y.label,y.apart?(0,R.jsxs)("span",{style:k,children:[" \xB7 ",y.apart]}):null,y.current?null:(0,R.jsx)("span",{style:k,children:" \xB7 past"})]}),(0,R.jsx)(ot,{why:y.why})]},y.id))})]},c)),g.length>0?(0,R.jsx)(ja,{asked:g}):null,g.length>0&&l.hits.length===0?(0,R.jsx)(fa,{store:t,kinds:l.searched.kinds,words:l.words,...a?{principal:a}:{},...i?{invariantContext:i}:{}}):null]})}function ot({why:e}){return e.field==="label"?null:(0,R.jsxs)("span",{style:k,"data-testid":"search-why",children:[e.reading,": ",e.fragment]})}function Ua(e,t){let n=Object.entries(t).map(([a,i])=>`${i} ${i===1?be(e.schema.tryDefinition(a),a):I(e,a).toLowerCase()}`);return n.length===0?"Found":n.length===1?le(n[0]):le(`${n.slice(0,-1).join(", ")} and ${n[n.length-1]}`)}function ya(e,t,n={}){let a=[];for(let i of t){let r=Ce(e,i,{...n.principal?{principal:n.principal}:{},...n.invariantContext?{context:n.invariantContext}:{}});for(let d of st(e,i,r.actions.affordances))a.some(s=>s.mutation.name===d.mutation.name)||a.push(d)}return a}function st(e,t,n){let a=e.schema.tryDefinition(t)?.fieldRoles?.label,i=[];for(let r of n){let d=e.allMutations().find(o=>o.name===r.mutation);if(!d||!d.creates?.includes(t)||i.some(o=>o.mutation.name===d.name))continue;let s=Je(d.input).map(o=>o.name),l=s.includes("label")?"label":a&&s.includes(a)?a:void 0;!l||r.args[l]!==void 0||i.push({kind:t,affordance:r,mutation:d,arg:l})}return i}function fa({store:e,kinds:t,words:n,principal:a,invariantContext:i}){let r=ya(e,t,{...a?{principal:a}:{},...i?{invariantContext:i}:{}});return r.length===0||n.trim().length===0?null:(0,R.jsx)("div",{style:{display:"grid",gap:24},"data-testid":"search-to-create",children:r.map(({kind:d,affordance:s,mutation:l,arg:o})=>(0,R.jsxs)("section",{style:{...j,display:"grid",gap:14},children:[(0,R.jsxs)("h2",{style:D,children:[le(en(be(e.schema.tryDefinition(d),d)))," called \u201C",n,"\u201D"]}),(0,R.jsx)(ye,{store:e,mutation:l,prefilled:s.args,open:s.open,initial:{[o]:n},...a?{principal:a}:{}})]},`${s.id}|${n}`))})}function ja({asked:e}){let t=oe();return t?(0,R.jsx)(_a,{asked:e,talk:t.seatTalk}):null}function _a({asked:e,talk:t}){let{drawn:n}=vn(t);return n===0?null:(0,R.jsx)("p",{style:{margin:0},children:(0,R.jsxs)("button",{type:"button","data-testid":"search-ask",onClick:()=>t.ask(e),style:{...$,font:"inherit",padding:0,border:0,background:"transparent",cursor:"pointer",textAlign:"start"},children:["Ask: \u2018",e,"\u2019"]})})}var h=O(z(),1),ha=8,wa=40;function Ht({context:e}){let t=ke(),n=fe(e.store.schema,t.slug??"");return n?(0,h.jsx)(va,{context:e,kind:n}):(0,h.jsx)(U,{context:e,children:(0,h.jsx)(Y,{context:e,children:"No such kind of thing here."})})}function va({context:e,kind:t,opening:n,row:a,layout:i="list",description:r,bare:d}){let{store:s,brand:l,invariantContext:o}=e;V(s);let[u,m]=We(),g=s.schema.tryDefinition(t),c=s.graph.nodesOfKind(t),y=Re(s).relations.filter(p=>p.from===t||p.to===t),P=new Set(s.violations(o).flatMap(p=>p.nodeIds)),F=ln(s.schema,t),C=y.map(p=>p.edgeKind),K=Qa(u,F,C),ue=["sort","filter","group","q","by","with","past",...C].some(p=>u.has(p)),X=c.length>=wa,we=g?.fieldRoles?.when,N=ue?K.arrangement:kt(n??Ja(X,we),F).arrangement,ne=pn(N.query??""),f=[...N.filter??[],...ne.conditions].some(p=>p.key==="is"&&(p.value==="past"||p.value==="any"))||sn(g,[...N.filter??[],...ne.conditions]),L=f||!g?.lifecycle?N:{...N,filter:[...N.filter??[],{key:"is",value:"current"}]},Z=En(c,L,{schema:s.schema,graph:s.graph,flagged:P,...typeof o?.today=="string"?{today:o.today}:{}}),B=Z.nodes,ze=g?.lifecycle&&!f?c.filter(p=>$e(g,p)):c,Gt=c.length-ze.length,qt=N.group?.by??null,ba=p=>{let x=new URLSearchParams(u);for(let ie of["sort","filter","group","q","by","with","past",...y.map(Ue=>Ue.edgeKind)])x.delete(ie);let H=$n(p);for(let ie of["sort","filter","group","q"])H[ie]&&x.set(ie,H[ie]);![...x.keys()].some(ie=>["sort","filter","group","q"].includes(ie))&&(n||X||we)&&x.set("sort",""),m(x)},{principal:Vt}=e,ct=Ce(s,t,{...Vt?{principal:Vt}:{},...e.invariantContext?{context:e.invariantContext}:{}}),Ne=ct.actions.affordances.map(p=>({affordance:p,mutation:s.allMutations().find(x=>x.name===p.mutation)})).filter(p=>p.mutation!==void 0),Ut=ct.actions.withheld,jt=ne.words&&B.length===0?Object.fromEntries(st(s,t,ct.actions.affordances).map(p=>[p.mutation.name,p.arg])):{},gt=I(s,t),Be=e.views?.lookup(t,{cardinality:"one",fidelity:"glyph"}),_t=Be!==void 0&&!Ee(Be)?Be:void 0,ut=p=>{let x=ae(g,p);if(a){let De=g?.computed?Oe(s.schema,s.graph,p):p;return(0,h.jsx)("li",{"data-testid":"record-row",style:{minWidth:0},children:a(p,{label:x,href:q(s.schema,t,p.id),flagged:P.has(p.id),glance:nt(De,g,x)})},p.id)}if(_t){let De=Xe(Be,p,s.graph),Aa=g?.computed?Oe(s.schema,s.graph,p):p,La=Object.fromEntries(Object.entries(Aa).filter(([Ta])=>!De?.fields.has(Ta))),Jt=De?nt(La,g,De.title??x):"";return(0,h.jsxs)("li",{"data-testid":"record-row",style:{position:"relative",display:"flex",flexWrap:"wrap",alignItems:"baseline",columnGap:16,rowGap:2,padding:"10px 0",borderTop:"1px solid var(--graview-edge)"},children:[(0,h.jsx)("div",{style:{flex:"1 1 14rem",minWidth:0},children:(0,h.jsx)(_t,{node:p,cardinality:"one",fidelity:"glyph",mode:"fullscreen",selected:!1,...P.has(p.id)?{flagged:[p.id]}:{}})}),Jt?(0,h.jsx)("span",{style:{...k,flex:"0 1 auto",minWidth:0,overflowWrap:"anywhere"},"data-testid":"record-glance",children:Jt}):null,(0,h.jsx)(A,{to:q(s.schema,t,p.id),"aria-label":P.has(p.id)?`${x} \u2014 implicated in a problem`:x,style:{position:"absolute",inset:0,borderRadius:6}})]},p.id)}let H=g?.computed?Oe(s.schema,s.graph,p):p,ie=nt(H,g,x),Ue=ne.words?cn(g,p,ne.words):void 0;return(0,h.jsxs)("li",{style:X?{display:"flex",flexWrap:"wrap",alignItems:"baseline",columnGap:16,rowGap:0,padding:"5px 0",borderTop:"1px solid var(--graview-edge)",overflowWrap:"anywhere"}:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:2,padding:"14px 0",borderTop:"1px solid var(--graview-edge)",overflowWrap:"anywhere"},children:[(0,h.jsxs)(A,{to:q(s.schema,t,p.id),style:X?{...J,flex:"1 1 14rem",minWidth:0,fontSize:"1rem",fontWeight:600,lineHeight:1.35}:{...J,fontFamily:xe,fontSize:"1.25rem",fontWeight:600,lineHeight:1.3},children:[P.has(p.id)?(0,h.jsx)("span",{style:{color:"var(--graview-warn)"},children:"\u26A0 "}):null,x]}),ie?(0,h.jsx)("span",{style:X?{...k,flex:"0 1 auto",minWidth:0,fontSize:"0.875rem"}:k,children:ie}):null,Ue?(0,h.jsx)(ot,{why:Ue}):null]},p.id)},mt=ce(e).filter(p=>p.kind===t),xa=(N.filter??[]).some(p=>p.key!=="is"||p.value!=="any"),Pa=!!(N.sort||N.group||N.query||xa),Ca=ze.length>=ha||ue&&Pa,me=N.sort?F.sorts.find(p=>p.key===N.sort.by):void 0,yt=me?.type==="date"||me!==void 0&&me.key===we,Yt=X&&!Z.grouped&&me&&(me.about==="label"||me.type==="text"||yt)?p=>{let x=me.about==="label"?ae(g,p):p[me.key];if(typeof x!="string"||x.length===0)return yt?"No date":"#";if(yt)return x.slice(0,4);let H=x.trim().charAt(0).toLocaleUpperCase();return/\p{L}/u.test(H)?H:"#"}:void 0,Ge=Yt?B.reduce((p,x)=>{let H=Yt(x);return p.at(-1)?.key===H?p.at(-1).nodes.push(x):p.push({key:H,nodes:[x]}),p},[]):void 0,ft=i==="grid"?{margin:0,padding:0,listStyle:"none",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(100%, 15rem), 1fr))",gap:12}:{margin:0,padding:0,listStyle:"none",display:"grid",gap:a&&i==="list"?6:0},qe=p=>`list-at-${p.replace(/[^\p{L}\p{N}]/gu,"_")}`,Ve=y.map(p=>{let x=p.from===t?p.to:p.from,H=p.from===t?p.description:p.inverse??p.description;return{relation:p,far:x,words:H}}),Ra=new Set(Ve.map(p=>(p.words??"").toLowerCase()).filter((p,x,H)=>p&&H.indexOf(p)!==x));return(0,h.jsxs)(d?Ya:U,{context:e,children:[(0,h.jsxs)("div",{style:{display:"grid",gap:12},children:[(0,h.jsxs)("header",{style:{display:"grid",gap:4},children:[(0,h.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,minWidth:0},children:[(0,h.jsx)(ee,{kind:t,brand:l,schema:s.schema,size:8}),(0,h.jsx)(Y,{context:e,children:gt})]}),r??g?.description?(0,h.jsx)("p",{style:{..._,fontSize:"1.0625rem",lineHeight:1.4},children:r??g?.description}):null,Ve.length>0||mt.length>0?(0,h.jsxs)("p",{style:{...k,margin:0,display:"flex",flexWrap:"wrap",columnGap:18,rowGap:2},"data-testid":"kind-related",children:[Ve.length>0?(0,h.jsxs)("span",{"data-testid":"kind-relations",children:["Related:"," ",Ve.map(({relation:p,far:x,words:H},ie)=>(0,h.jsxs)("span",{"data-relation":p.edgeKind,children:[ie>0?" \xB7 ":null,x==="*"?le(H??re(p.edgeKind)):(0,h.jsx)(A,{to:`/${G(s.schema,x)}`,style:$,title:I(s,x),children:H&&Ra.has(H.toLowerCase())?`${le(H)}: ${I(s,x).toLowerCase()}`:le(H??I(s,x))})]},`${p.edgeKind}|${p.from}|${p.to}`))]}):null,mt.length>0?(0,h.jsxs)("span",{"data-testid":"kind-pictures",children:["Also as:"," ",mt.map((p,x)=>(0,h.jsxs)("span",{children:[x>0?" \xB7 ":null,(0,h.jsx)(A,{to:ge(e,p),style:$,children:p.title})]},Ae(p)))]}):null]}):null]}),K.dropped.length>0?(0,h.jsxs)("p",{style:{...k,margin:0},"data-testid":"list-dropped",children:["This link asked for ",K.dropped.join(", "),", which ",gt.toLowerCase()," cannot be arranged by; the rest is shown."]}):null,ze.length>0?(0,h.jsx)(Fn,{schema:s.schema,graph:s.graph,kind:t,arrangement:N,onChange:ba,kept:{shown:B.length,of:ze.length},noun:{one:be(g,t),many:gt.toLowerCase()},...Ca?{}:{allow:!1},query:e.framed===!0&&e.barAbove!==!0}):null,B.length===0&&ne.words?(0,h.jsxs)("p",{style:{..._,fontSize:"1.0625rem"},"data-testid":"none-yet",children:["Nothing here is called \u201C",ne.words,"\u201D."," ",(0,h.jsx)("span",{style:k,"data-testid":"list-searched",children:Ye(s.schema,{kinds:[t],past:f})})," ",(0,h.jsx)(A,{to:"?",style:$,children:"Show every one"})]}):B.length===0?(0,h.jsxs)("p",{style:{..._,fontSize:"1.0625rem"},"data-testid":"none-yet",children:[N.filter?.length||N.query?"None of them.":"None yet",!N.filter?.length&&!N.query&&Ne.length>0?` \u2014 the first one starts below, with \u201C${Ne[0]?.mutation.title??Ne[0]?.mutation.name}\u201D.`:!N.filter?.length&&!N.query?".":"",N.filter?.length||N.query?(0,h.jsxs)(h.Fragment,{children:[" ",(0,h.jsx)(A,{to:"?",style:$,children:"Show every one"})]}):null]}):Z.grouped&&qt?(0,h.jsx)("div",{style:{display:"grid",gap:18},"data-testid":"records","data-grouped":qt,children:Z.groups.map(p=>(0,h.jsxs)("section",{style:{display:"grid",gap:0},"data-testid":"list-group",children:[(0,h.jsxs)("h2",{style:{...D,fontSize:"1.0625rem",marginBottom:4},children:[p.label," ",(0,h.jsx)("span",{style:k,children:p.nodes.length})]}),(0,h.jsx)("ul",{style:ft,"data-graview-rows":"",children:p.nodes.map(ut)})]},p.key||"-"))}):Ge&&Ge.length>1?(0,h.jsxs)("div",{style:{display:"grid",gap:14},"data-testid":"records","data-sectioned":me?.type==="date"?"year":"letter",children:[(0,h.jsx)("nav",{"aria-label":"Jump to","data-testid":"list-index",style:{...k,display:"flex",flexWrap:"wrap",gap:me?.type==="date"?"0 10px":"0 4px",fontSize:"0.8125rem",lineHeight:1.3},children:Ge.map(p=>(0,h.jsx)("a",{href:`#${qe(p.key)}`,onClick:x=>{x.preventDefault(),document.getElementById(qe(p.key))?.scrollIntoView({block:"start"})},style:{...$,flex:"0 0 auto",minWidth:24,justifyContent:"center",textDecoration:"none"},children:p.key},p.key))}),Ge.map(p=>(0,h.jsxs)("section",{"data-testid":"list-section","aria-labelledby":qe(p.key),style:{display:"grid",gap:0},children:[(0,h.jsx)("h2",{id:qe(p.key),style:{...D,fontSize:"0.9375rem",color:"var(--graview-ink-muted)",marginBottom:2,scrollMarginTop:64},children:p.key}),(0,h.jsx)("ul",{style:ft,"data-graview-rows":"",children:p.nodes.map(ut)})]},p.key))]}):(0,h.jsx)("ul",{style:ft,"data-testid":"records","data-graview-rows":"",children:B.map(ut)}),Gt>0?(0,h.jsxs)(A,{to:Xa(u,"filter","is:any"),style:{...$,...k,justifySelf:"start"},"data-testid":"past-link",children:["+",Gt," past"]}):null,Ne.length>0?(0,h.jsx)("div",{style:{display:"grid",gap:6},"data-testid":"beginnings",children:Ne.map(({affordance:p,mutation:x})=>{let H=!!(jt[x.name]&&B.length===0);return(0,h.jsx)(Za,{name:x.name,title:x.title??x.name,description:x.description,open:B.length===0,children:(0,h.jsx)(ye,{store:s,mutation:x,prefilled:p.args,open:p.open,...H?{initial:{[jt[x.name]]:ne.words}}:{},...e.principal?{principal:e.principal}:{}},H?`${x.name}|${ne.words}`:x.name)},p.id)})}):null]}),Ut.length>0?(0,h.jsx)("ul",{style:{...j,margin:0,padding:0,listStyle:"none",display:"grid",gap:4},"data-testid":"withheld",children:Ut.map(p=>(0,h.jsxs)("li",{style:k,children:[(0,h.jsx)("s",{children:p.label})," \u2014 ",p.refusal.message]},p.id))}):null]})}function Ya({children:e}){return(0,h.jsx)("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:40,minWidth:0},children:e})}var Ja=(e,t)=>t?{sort:{by:t,direction:"desc"}}:e?{sort:{by:"label",direction:"asc"}}:{};function Qa(e,t,n){let a=dn({...e.get("sort")?{sort:e.get("sort")}:{},...e.get("filter")?{filter:e.get("filter")}:{},...e.get("group")?{group:e.get("group")}:{},...e.get("q")?{q:e.get("q")}:{}}),i=[...a.filter??[]],r=e.get("by"),d=a.group??(r?{by:r}:void 0);for(let l of n){let o=e.get(l);o&&i.push({key:l,value:o})}let s=e.get("with");return s&&i.push({key:s,value:"*"}),e.get("past")==="1"&&!i.some(l=>l.key==="is")&&i.push({key:"is",value:"any"}),kt({...a.sort?{sort:a.sort}:{},...a.query?{query:a.query}:{},...i.length>0?{filter:i}:{},...d?{group:d}:{}},t)}function Xa(e,t,n){let a=new URLSearchParams(e);return a.set(t,n),a.delete("past"),`?${a.toString()}`}function Za({name:e,title:t,description:n,open:a,children:i}){let[r,d]=(0,Me.useState)(a),s=(0,Me.useRef)(null),l=(0,Me.useRef)(null),o=`begin-${(0,Me.useId)().replace(/:/g,"")}`;return(0,h.jsxs)("div",{"data-testid":`act-${e}`,style:{display:"grid",gap:10},children:[(0,h.jsxs)("button",{ref:s,type:"button","data-testid":`act-open-${e}`,"aria-expanded":r,"aria-controls":o,onClick:()=>{d(!r),r||requestAnimationFrame(()=>l.current?.querySelector("input, select, textarea, button")?.focus())},style:{...J,justifySelf:"start",minHeight:32,padding:"0 2px",border:0,background:"none",font:"inherit",fontSize:"0.9375rem",fontWeight:600,color:"var(--graview-ink)",cursor:"pointer"},children:[(0,h.jsx)("span",{"aria-hidden":"true",style:{marginRight:6},children:r?"\u2212":"+"}),t]}),(0,h.jsxs)("div",{ref:l,id:o,hidden:!r,onKeyDown:u=>{u.key==="Escape"&&(u.preventDefault(),d(!1),s.current?.focus())},style:r?{display:"grid",gap:12,padding:"4px 0 12px"}:void 0,children:[n?(0,h.jsx)("p",{style:{...k,margin:0,maxWidth:"58ch"},children:n}):null,i]})]})}var pt=O(ve(),1);var He=O(ve(),1);var M=O(z(),1);function zt({context:e}){let{store:t,brand:n,invariantContext:a,principal:i}=e;V(t);let r=t.violations(a),d=t.allInvariants(),s=Qe(t,r),l=Cn(t.schema,d);return(0,M.jsxs)(U,{context:e,children:[(0,M.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,M.jsx)(Y,{context:e,children:r.length===0?"All rules hold":"What is broken"}),(0,M.jsx)("p",{style:_,"data-testid":"problems-count",children:r.length===0?"Every declared rule is satisfied by what is here.":rn(r)})]}),(0,M.jsx)(ma,{context:e}),s.map((o,u)=>{let m=o.nodeIds[0],g=m?t.graph.getNode(m):void 0;return(0,M.jsxs)("section",{style:{display:"grid",gap:10,padding:"16px 18px",borderLeft:"3px solid var(--graview-warn)",background:"var(--graview-panel-warning)",borderRadius:"0 var(--graview-radius, 12px) var(--graview-radius, 12px) 0"},children:[o.line?null:(0,M.jsx)(lt,{violation:o,schema:t.schema,...n?{brand:n}:{}}),g?(0,M.jsxs)("p",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:8},children:[(0,M.jsx)(ee,{kind:g.kind,brand:n,schema:t.schema,size:7}),(0,M.jsx)(A,{to:q(t.schema,g.kind,g.id),style:$,children:ae(t.schema.tryDefinition(g.kind),g)})]}):null,o.line?(0,M.jsx)(lt,{violation:o,schema:t.schema,...n?{brand:n}:{}}):null,(0,M.jsx)(dt,{store:t,repairs:o.repairs,...i?{principal:i}:{}})]},u)}),d.length>0?(0,M.jsxs)("section",{style:{...j,display:"grid",gap:12},"data-testid":"rules",children:[(0,M.jsx)("h2",{style:D,children:"The rules"}),(0,M.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:10},children:d.map(o=>{let u=r.filter(c=>c.invariant===o.name).length,m=l.get(o.name),g=o.label??o.name;return(0,M.jsxs)("li",{"data-graview-rule":o.name,style:{display:"grid",gap:2},children:[(0,M.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",columnGap:12,rowGap:2},children:[m?(0,M.jsx)(vt,{line:m,schema:t.schema,...n?{brand:n}:{},style:{flex:"1 1 18rem"}}):(0,M.jsx)("span",{style:{flex:"1 1 18rem",fontWeight:550},children:g}),(0,M.jsx)("span",{style:{...k,fontSize:"0.875rem",color:u>0?"var(--graview-warn)":"var(--graview-ink-faint)"},children:u===0?"holds":`broken in ${u} ${u===1?"place":"places"}`})]}),m&&g.trim().length>0?(0,M.jsx)("span",{style:{...k,fontSize:"0.875rem"},children:g}):null]},o.name)})})]}):null]})}function lt({violation:e,schema:t,brand:n}){if(!e.line)return(0,M.jsx)("p",{style:{margin:0,color:"var(--graview-warn)",fontWeight:550},children:e.message});let a=An(e);return(0,M.jsxs)("div",{style:{display:"grid",gap:2},"data-testid":"problem-line",title:Rn(e),children:[(0,M.jsx)(vt,{line:e.line,schema:t,...n?{brand:n}:{},lead:"none",style:{color:"var(--graview-warn)",fontSize:"1.0625rem"}}),a?(0,M.jsx)("span",{style:{...k,fontSize:"0.875rem"},children:a}):null]})}function dt({store:e,repairs:t,principal:n}){let[a,i]=(0,He.useState)(null),[r,d]=(0,He.useState)(null),s=(0,He.useRef)([]);if(t.length===0)return null;let l=a===null?null:t[a],o=l&&(l.missing??[]).length>0?e.allMutations().find(u=>u.name===l.mutation):void 0;return(0,M.jsxs)("div",{style:{display:"grid",gap:10},"data-testid":"repairs",children:[(0,M.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:t.map((u,m)=>{let g=(u.missing??[]).length>0,c=e.permits({name:u.mutation,args:{...u.args}},n);return c.ok?(0,M.jsx)("button",{ref:y=>{s.current[m]=y},type:"button","data-graview-repair":u.mutation,"data-graview-asks":g||void 0,"aria-expanded":g?a===m:void 0,onClick:()=>{if(d(null),g){i(a===m?null:m);return}i(null);try{e.apply({name:u.mutation,args:{...u.args}},n?{author:n}:{})}catch(y){d(_e(e.schema,e.allMutations(),y))}},style:et,children:g?`${u.label} \u2026`:u.label},m):(0,M.jsxs)("p",{"data-testid":"withheld","data-withheld":c.refusal.wouldNeed.join(",")||"nobody",style:{margin:0,fontSize:"0.875rem",color:"var(--graview-ink-muted)"},children:[(0,M.jsx)("s",{children:u.label})," \u2014 ",c.refusal.message]},m)})}),o&&l?(0,M.jsx)(ye,{store:e,mutation:o,prefilled:{...l.args},only:l.missing??[],label:l.label,onDone:()=>{let u=a;i(null),requestAnimationFrame(()=>{let m=u===null?null:s.current[u];if(m?.isConnected){m.focus();return}let g=document.querySelector("[data-graview-page-title]")??document.querySelector("main h1, main h2");g&&(g.hasAttribute("tabindex")||(g.tabIndex=-1),g.focus())})},...n?{principal:n}:{}}):null,l&&!o&&(l.missing??[]).length>0?(0,M.jsxs)("p",{"data-testid":"refused",role:"alert",style:{margin:0,color:"var(--graview-warn)",fontSize:"0.875rem"},children:["\u201C",l.label,"\u201D names ",l.mutation,", which this app does not declare."]}):null,r?(0,M.jsx)("p",{"data-testid":"refused",role:"alert",style:{margin:0,color:"var(--graview-warn)",fontSize:"0.875rem"},children:r}):null]})}var w=O(z(),1),er=[];function Bt({context:e}){let{store:t,brand:n,principal:a,invariantContext:i}=e;V(t);let r=oe()!==null,d=ke(),s=decodeURIComponent(d.id??""),l=ea(t,s,{...a?{principal:a}:{},...i?{context:i}:{}}),o=Qe(t,l?.violations??er),[u,m]=(0,pt.useState)(null),g=(0,pt.useRef)(null);if(!l)return(0,w.jsx)(U,{context:e,children:(0,w.jsx)(Y,{context:e,children:"Nothing lives at this address."})});let c=t.graph.getNode(s),y=t.schema.tryDefinition(l.kind),P=y?.describe&&c?Qt(y,c):null,F=[...t.log.all()].filter(f=>!on(f)&&(f.writes.includes(s)||f.reads.includes(s))).slice(-8).reverse(),C=l.actions.affordances.filter(f=>f.provider!=="invariant"),K=e.views?.lookup(l.kind,{cardinality:"one",fidelity:"full"}),ue=K!==void 0&&!Ee(K)?K:void 0,X=ue&&c?Xe(K,c,t.graph):void 0,we=X?l.fields.filter(f=>!X.fields.has(f.key)):l.fields,N=X?l.links.flatMap(f=>{let L=f.targets.filter(Z=>!X.records.has(Z.id));return L.length>0?[{...f,targets:L}]:[]}):l.links,ne=ue!==void 0&&xn(K);return(0,w.jsxs)(U,{context:e,children:[(0,w.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,w.jsxs)("p",{style:{...se,display:"flex",alignItems:"center",gap:8},children:[(0,w.jsx)(ee,{kind:l.kind,brand:n,schema:t.schema,size:8}),(0,w.jsx)(A,{to:`/${G(t.schema,l.kind)}`,style:J,children:I(t,l.kind)})]}),(0,w.jsx)(Y,{context:e,children:r&&c?.label===l.label?(0,w.jsx)(bt,{nodeId:s,field:"label",value:l.label}):l.label}),P&&P!==l.label?(0,w.jsx)("p",{style:_,children:P}):null,(0,w.jsx)(Ze,{context:e,stop:`#focus=${encodeURIComponent(s)}`,style:{...$,...k},"data-testid":"spatial-link"}),ce(e).some(f=>f.kind===l.kind||f.across===l.kind)?(0,w.jsxs)("p",{style:{...k,margin:0},"data-testid":"seen-in",children:["Seen in:"," ",ce(e).filter(f=>f.kind===l.kind||f.across===l.kind).map((f,L)=>(0,w.jsxs)("span",{children:[L>0?" \xB7 ":null,(0,w.jsx)(A,{to:ge(e,f),style:$,children:f.title})," ",(0,w.jsx)(Ze,{context:e,stop:`#view=${encodeURIComponent(f.as)}`,style:{...$,...k,display:"inline-block",minWidth:24,textAlign:"center"},title:`${f.title}, in the scene`,children:"\u2197"})]},Ae(f)))]}):null]}),ue&&c?(0,w.jsx)("section",{"data-testid":"record-view",style:{display:"grid",minWidth:0},children:(0,w.jsx)(Wn,{children:(0,w.jsx)(ue,{node:c,cardinality:"one",fidelity:"full",mode:"fullscreen",selected:!1,...l.violations.length>0?{flagged:[s]}:{}})})}):null,l.violations.length>0?(0,w.jsx)("section",{"data-testid":"record-violations",style:{display:"grid",gap:12,padding:"16px 18px",borderLeft:"3px solid var(--graview-warn)",background:"var(--graview-panel-warning)",borderRadius:"0 var(--graview-radius, 12px) var(--graview-radius, 12px) 0"},children:o.map((f,L)=>(0,w.jsxs)("div",{style:{display:"grid",gap:8},children:[(0,w.jsx)(lt,{violation:f,schema:t.schema,...n?{brand:n}:{}}),(0,w.jsx)(dt,{store:t,repairs:ta(l.actions,f.repairs),...a?{principal:a}:{}})]},L))}):null,!ne&&we.length>0?(0,w.jsxs)("section",{style:{...j,display:"grid",gap:14},"data-testid":"record-fields",children:[(0,w.jsx)("h2",{style:D,children:"The facts"}),nn(y,we).map((f,L)=>{let Z=(0,w.jsx)("dl",{style:{margin:0,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"14px 24px"},children:f.fields.map(B=>B.long?(0,w.jsx)(On,{nodeId:s,field:B.key,label:B.label,value:B.value,style:{gridColumn:"1 / -1",gap:4},labelStyle:{...se,fontSize:"0.75rem"},valueStyle:{fontSize:"1.0625rem",lineHeight:1.6}},B.key):(0,w.jsxs)("div",{style:{display:"grid",gap:2,minWidth:0,alignContent:"start"},children:[(0,w.jsx)("dt",{style:{...se,fontSize:"0.75rem"},children:B.label}),(0,w.jsx)("dd",{style:{margin:0,fontSize:"1.125rem",overflowWrap:"anywhere",minWidth:0},children:r?(0,w.jsx)(bt,{nodeId:s,field:B.key,value:B.value,stored:B.stored}):B.value})]},B.key))});return f.title?(0,w.jsxs)("section",{style:{display:"grid",gap:10,minWidth:0},children:[(0,w.jsx)("h3",{"data-graview-field-group":f.title,style:{...D,fontSize:"1.0625rem"},children:f.title}),Z]},L):(0,w.jsx)("div",{children:Z},L)})]}):null,(ne?[]:N).map(f=>(0,w.jsxs)("section",{style:{...j,display:"grid",gap:10},children:[(0,w.jsx)("p",{style:se,children:Un(t,f)}),f.description?(0,w.jsx)("h2",{style:D,children:le(f.description)}):(0,w.jsxs)("h2",{style:D,"aria-label":re(f.edgeKind),children:[f.direction==="in"?"\u2190 ":"\u2192 ",re(f.edgeKind)]}),(0,w.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"6px 18px"},children:f.targets.map(L=>(0,w.jsxs)("li",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,w.jsx)(ee,{kind:L.kind,brand:n,schema:t.schema,size:7}),(0,w.jsxs)(A,{to:q(t.schema,L.kind,L.id),style:{...$,fontSize:"1.125rem"},children:[L.label,L.apart?(0,w.jsxs)("span",{style:k,children:[" \xB7 ",L.apart]}):null]})]},L.id))}),(f.direction==="out"&&t.schema.edge(f.edgeKind)?.cardinality==="one"?[]:[...new Set(f.targets.map(L=>L.kind))]).map(L=>(0,w.jsxs)(A,{to:`/${G(t.schema,L)}?${encodeURIComponent(f.edgeKind)}=${encodeURIComponent(s)}`,style:{...$,...k},"data-testid":"related-all",children:["Sort and filter ",f.description??`these ${I(t,L).toLowerCase()}`,f.targets.some(Z=>Z.kind!==L)?` (${I(t,L).toLowerCase()})`:""," \u2192"]},L))]},`${f.edgeKind}|${f.direction}|${f.description??""}`)),!ne&&(C.length>0||l.actions.withheld.length>0)?(0,w.jsxs)("section",{style:{...j,display:"grid",gap:14},"data-testid":"record-actions",children:[(0,w.jsx)("h2",{style:D,ref:g,tabIndex:-1,children:"What can be done"}),(0,w.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:C.map(f=>{let L=u===f.id;return(0,w.jsx)("button",{type:"button","data-affordance":f.id,"data-rank":f.rank,"aria-expanded":L,onClick:()=>m(L?null:f.id),style:{...et,...L?{borderColor:"var(--graview-accent)",color:"var(--graview-accent)"}:{}},children:f.label},f.id)})}),C.map(f=>{if(u!==f.id)return null;let L=t.allMutations().find(Z=>Z.name===f.mutation);return L?(0,w.jsxs)("div",{style:{display:"grid",gap:10,padding:18,border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)"},children:[(0,w.jsx)("h3",{style:{...D,fontSize:"1.1875rem"},children:f.label}),L.description?(0,w.jsx)("p",{style:{...k,margin:0},children:L.description}):null,(0,w.jsx)(ye,{store:t,mutation:L,prefilled:f.args,open:f.open,label:f.label,onDone:()=>{m(null);let Z=f.id;requestAnimationFrame(()=>{(g.current?.parentElement?.querySelector(`[data-affordance="${Z.replace(/["\\]/g,"\\$&")}"]`)??g.current)?.focus()})},...a?{principal:a}:{}})]},f.id):null}),l.actions.withheld.length>0?(0,w.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:4},children:l.actions.withheld.map(f=>(0,w.jsxs)("li",{style:k,children:[(0,w.jsx)("s",{children:f.label})," \u2014 ",f.refusal.message]},f.id))}):null]}):null,F.length>0?(0,w.jsxs)("section",{style:{...j,display:"grid",gap:10},"data-testid":"record-history",children:[(0,w.jsx)("h2",{style:D,children:"What has happened"}),(0,w.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},children:F.map(f=>(0,w.jsxs)("li",{style:k,children:[(0,w.jsx)("span",{style:{color:"var(--graview-ink)"},children:f.intent})," \u2014 ",tt(f,a,{graph:t.graph,schema:t.schema,...e.seats?{seats:e.seats}:{},...e.people?{people:e.people}:{}})]},f.id))})]}):null]})}var v=O(z(),1),tr=(0,W.lazy)(()=>import("./chunk.TWFYXD3P.js").then(e=>({default:e.DraftPage})));function nr({context:e,children:t}){let n=he(),a=e.store.schema,i=(0,W.useMemo)(()=>({href:r=>q(a,r.kind,r.id),go:r=>n(q(a,r.kind,r.id))}),[a,n]);return(0,v.jsx)(Nn.Provider,{value:i,children:(0,v.jsx)(Dn.Provider,{value:(e.titleLevel??(e.framed&&!e.barAbove?1:2))-1,children:t})})}function ar({steering:e}){let t=de(),n=he(),a=`${t.pathname}${t.search}`;return(0,W.useLayoutEffect)(()=>e.at(a),[a,e]),(0,W.useLayoutEffect)(()=>{let i=d=>{d!==a&&n(d)};e.go.current=i;let r=e.pending?.current;return r!==void 0&&(e.pending.current=void 0,i(r)),()=>{e.go.current===i&&(e.go.current=void 0)}},[a,n,e]),null}function rr({context:e,to:t}){let{pathname:n}=de(),a=oe(),i=(t??a)?.sayWhere,r=ir(e,n);return(0,W.useEffect)(()=>(i?.(r),()=>i?.(null)),[i,r]),null}function ir(e,t){let[n="",a,i]=t.split("/").filter(Boolean).map(d=>{try{return decodeURIComponent(d)}catch{return d}});if(i!==void 0)return"#";if(n==="places"&&a!==void 0){if(a===wt)return"#overview=1";let d=e.views?.places().find(s=>s.as===a);return d?`#focus=${encodeURIComponent(Ie(d.kind))}&view=${encodeURIComponent(d.as)}`:"#"}let r=fe(e.store.schema,n);return r?`#focus=${encodeURIComponent(a??Ie(r))}`:"#"}function or({onNavigate:e,path:t}){let n=de(),a=Pt(),i=he(),r=`${n.pathname}${n.search}`,d=(0,W.useRef)(e);d.current=e;let s=(0,W.useRef)(null);(0,W.useEffect)(()=>{let o=s.current;s.current=r,o!==null&&(r===o&&a!=="PUSH"||d.current?.(r,a==="POP"?"pop":a==="REPLACE"?"replace":"push"))},[n.key]);let l=(0,W.useRef)(t);return(0,W.useEffect)(()=>{t===void 0||t===l.current||(l.current=t,t!==r&&i(t))},[t]),null}function ka({context:e,registry:t,page:n}){let a=ke(),i=fe(e.store.schema,a.slug??""),r=n==="list"?Ht:Bt,s=(i?t?.lookup(i,n):void 0)??r;return(0,v.jsx)(s,{context:e})}function sr({context:e,registry:t,children:n}){let a=(0,W.useRef)(null);return Pn(a),(0,v.jsx)("div",{ref:a,"data-graview-face":"pages",style:{display:"contents"},children:(0,v.jsx)(ca,{context:e,registry:t,root:a,children:n})})}function lr(){let{pathname:e}=de(),t=Pt(),n=(0,W.useRef)(null);(0,W.useLayoutEffect)(()=>{if(t!=="POP"){for(let r=n.current?.parentElement;r;r=r.parentElement){let{overflowY:d}=getComputedStyle(r);if((d==="auto"||d==="scroll")&&r.scrollHeight>r.clientHeight){r.scrollTop=0;return}}window.scrollTo(0,0)}},[e]);let a=(0,W.useRef)(e),i=(0,W.useRef)(!1);return(0,W.useEffect)(()=>{if(!i.current&&e===a.current)return;i.current=!0;let r=document.activeElement;if(r!==null&&r!==document.body&&r!==document.documentElement)return;let d=n.current?.closest("main")??document.querySelector("main"),l=n.current?.closest("[data-graview-face]")?.querySelector("[data-graview-page-title]")??d?.querySelector("h1, h2")??null??d??null;l&&(l.hasAttribute("tabindex")||l.setAttribute("tabindex","-1"),l.focus({preventScroll:!0}))},[e]),(0,v.jsx)("span",{ref:n,hidden:!0,"data-graview-scroll-reset":""})}function dr({context:e,children:t}){let n=he(),a=(0,W.useMemo)(()=>({record:i=>{let r=e.store.graph.getNode(i);r&&n(q(e.store.schema,r.kind,i))},place:i=>{let r=e.views?.places().find(d=>d.as===i);r&&n(ge(e,r))}}),[e,n]);return(0,v.jsx)(bn.Provider,{value:a,children:t})}function pr({context:e,Home:t}){let i=de().key==="default"?yn(e.views?.arrangement?.()?.first,e.store.schema,e.views?.places()??[]):void 0,r=i?.to==="place"?ge(e,i.place):i?.to==="kind"?`/${G(e.store.schema,i.kind)}`:void 0;return r?(0,v.jsx)(Ct,{to:r,replace:!0}):(0,v.jsx)(t,{context:e})}function Sa({context:e,registry:t}){let n=t?.lookupSurface("shell"),a=n!==void 0,i=a&&(t?.without().has("bar")??!1),r=a&&!i&&!e.embedded?{...e,barAbove:!0}:e,d=y=>n===void 0?(0,v.jsx)(rt,{context:e,children:y}):i?(0,v.jsx)(n,{context:e,children:y}):(0,v.jsx)(rt,{context:e,children:(0,v.jsx)(n,{context:r,children:y})}),s=t?.lookupSurface("home")??It,l=t?.lookupSurface("problems")??zt,o=a?{...r,framed:!0}:e,[u,m]=(0,W.useState)(null),g=(0,W.useMemo)(()=>({onFind:m,find:!(t?.without().has("find")??!1),places:!(t?.without().has("places")??!1)}),[t]),c=(0,v.jsx)(sr,{context:e,registry:t,children:(0,v.jsx)(dr,{context:e,children:d((0,v.jsx)(v.Fragment,{children:(0,v.jsxs)(nr,{context:o,children:[(0,v.jsx)(lr,{}),(0,v.jsxs)(Jn,{children:[(t?.routes()??[]).map(({path:y,component:P})=>(0,v.jsx)(pe,{path:y,element:(0,v.jsx)(P,{context:o})},y)),(0,v.jsx)(pe,{path:"/",element:(0,v.jsx)(pr,{context:o,Home:s})}),(0,v.jsx)(pe,{path:"/problems",element:(0,v.jsx)(l,{context:o})}),(0,v.jsx)(pe,{path:"/~draft",element:(0,v.jsx)(W.Suspense,{fallback:null,children:(0,v.jsx)(tr,{context:o})})}),(0,v.jsx)(pe,{path:"/search",element:(0,v.jsx)(Kt,{context:o})}),(0,v.jsx)(pe,{path:"/map",element:(0,v.jsx)(Dt,{context:o})}),(0,v.jsx)(pe,{path:"/places",element:(0,v.jsx)(Wt,{context:o})}),ce(o).some(y=>y.as===wt)?null:(0,v.jsx)(pe,{path:mn,element:(0,v.jsx)(Ct,{to:"/",replace:!0})}),(0,v.jsx)(pe,{path:"/places/:as",element:(0,v.jsx)(Nt,{context:o})}),(0,v.jsx)(pe,{path:"/:slug",element:(0,v.jsx)(ka,{context:o,registry:t,page:"list"})}),(0,v.jsx)(pe,{path:"/:slug/:id",element:(0,v.jsx)(ka,{context:o,registry:t,page:"record"})})]})]})}))})});return e.embedded||!a||i?c:(0,v.jsx)(Zn.Provider,{value:g,children:(0,v.jsx)(Ln.Provider,{value:u,children:c})})}function cr({context:e,registry:t,basename:n,initialPath:a,onNavigate:i,path:r,steering:d}){(0,W.useState)(()=>e.views?Kn(e.views,e.store.schema,Mn(e.brand,e.store.schema)):void 0);let s=oe(),l=e.store.seenBy(e.principal??{kind:"human"}),o=l===e.store?e:{...e,store:l};kn(e.store,e.principal);let u=(0,v.jsxs)(v.Fragment,{children:[i||r!==void 0?(0,v.jsx)(or,{onNavigate:i,path:r}):null,d?(0,v.jsx)(ar,{steering:d}):null,o.presence||s?(0,v.jsx)(rr,{context:o,to:s}):null,(0,v.jsx)(Sa,{context:o,...t?{registry:t}:{}})]}),m=o.views?(0,v.jsxs)(Sn,{store:o.store,views:o.views,...o.principal?{principal:o.principal}:{},...o.brand?{brand:o.brand}:{},...o.settings?{settings:o.settings}:{},...o.presence&&!s?{presence:o.presence}:{},...o.people?{people:o.people}:{},...o.onKeepLens?{onKeepLens:o.onKeepLens}:{},...o.ai?{ai:o.ai}:{},...o.app?{app:o.app}:{},children:[u,(0,v.jsx)(la,{context:o})]}):u;if(a!==void 0){let g=n===void 0?a:`${n.replace(/\/$/,"")}${a}`;return(0,v.jsx)(Yn,{initialEntries:[g],...n===void 0?{}:{basename:n},children:m})}return(0,v.jsx)(Qn,{...n===void 0?{}:{basename:n},children:m})}export{Oa as a,cr as b};
@@ -1 +0,0 @@
1
- import{e as ge}from"./chunk.ISAMJ7AK.js";import{Cb as he,I as _,K as M,L as J,La as G,N as re,O as se,Q as W,R as ae,S as B,T as K,W as de,Xa as pe,ga as ce,ha as P,ia as le,ja as j,ka as ue,wa as fe}from"./chunk.ZQ4HFIIS.js";function me(e){let t=new Set;for(let n=e;n;n=n.onBehalfOf)n.id!==void 0&&t.add(`${n.kind}:${n.id}`);return t}function F(e,t){let n=me(t),u=p=>{if(p.kind==="rule")return!1;let d=me(p);if(d.size===0)return!1;for(let g of d)if(n.has(g))return!1;return!0},f,c=()=>{if(f)return f;f=new Map;for(let p of e.log.live()){if(p.undoes!==void 0)continue;let d=u(p.author)?p.author:void 0;for(let g of p.primitives){g.op==="remove-node"&&f.delete(g.node.id);let s=g.op==="add-node"?g.node.id:g.op==="patch-node"?g.id:void 0;if(s===void 0)continue;let a=g.op==="add-node"?Object.keys(g.node):Object.keys(g.after),h=f.get(s);(g.op==="add-node"||!h)&&f.set(s,h=new Map);for(let y of a)y==="id"||y==="kind"||(d?h.set(y,d):h.delete(y))}}return f},S=e.schema,v=new Map,i=(p,d)=>{let g=`${p}\0${d}`,s=v.get(g);if(s===void 0){let a=S.tryDefinition(p)?.fields?.shape;s=a!==void 0&&d in a&&le(a[d]).type==="text",v.set(g,s)}return s},l=p=>e.graph.getNode(p)?.kind;return{prose:i,say:p=>de(p,{graph:e.graph,schema:S}),fieldBy(p,d){let g=l(p);if(!(g===void 0||!i(g,d)))return c().get(p)?.get(d)},recordBy(p){let d=l(p),g=c().get(p);if(d===void 0||!g)return;let s;for(let[a,h]of g)i(d,a)&&(s=h);return s}}}var E=(e,t,n)=>({untrusted:!0,authoredBy:n.say(t),text:e});function z(e,t){let n;for(let[u,f]of Object.entries(e)){if(typeof f!="string"||u==="id"||u==="kind")continue;let c=t.fieldBy(e.id,u);c&&(n??={...e},n[u]=E(f,c,t))}return n??e}function ye(e,t,n){let u=f=>{if(Array.isArray(f))return f.map(u);if(f!==null&&typeof f=="object"&&"id"in f&&"label"in f){let c=f,S=n.recordBy(c.id);return S?{...c,label:E(c.label,S,n)}:c}if(typeof f=="string"){let c=n.recordBy(e);return c?E(f,c,n):f}return f};return Object.fromEntries(Object.entries(t).map(([f,c])=>[f,u(c)]))}function ke(e,t){return{...e,nodes:e.nodes.map(n=>z(n,t))}}function we(e,t){return{...e,hits:e.hits.map(n=>{if(n.about!=="node")return n;let u=t.recordBy(n.id);if(!u)return n;let f=t.prose(n.kind,n.why.field)?t.fieldBy(n.id,n.why.field):u;return{...n,label:E(n.label,u,t),...n.apart!==void 0?{apart:E(n.apart,u,t)}:{},why:f?{...n.why,fragment:E(n.why.fragment,f,t)}:n.why}})}}function be(){return{name:"insight",derive({store:e,nodes:t,kindSelection:n}){let u=[],f=c=>_(e.schema.tryDefinition(c.kind),c);for(let c of t){if([...e.schema.edgeKinds].reduce((v,i)=>v+e.graph.out(c.id,i).length+e.graph.in(c.id,i).length,0)===0){u.push({id:`insight:island:${c.id}`,text:`${f(c)} is connected to nothing yet`,nodeIds:[c.id]});continue}for(let v of e.schema.edgeKinds){let i=e.graph.in(c.id,v).length;if(i<3)continue;let l=[...e.graph.allEdges()].filter(d=>d.kind===v),p=l.length;p>=4&&i/p>.6&&u.push({id:`insight:load:${c.id}:${v}`,text:`${f(c)} ${Ee(e,l,v,i)}`,nodeIds:[c.id]})}}for(let c of n){if(e.graph.nodesOfKind(c).length>0)continue;let S=e.schema.definitions.filter(v=>v.kind!==c).filter(v=>Object.values(v.edges).some(i=>i.to!=="*"&&i.to.includes(c))).map(v=>v.plural??`${v.kind}s`);S.length>0&&u.push({id:`insight:gap:${c}`,text:`Nothing here yet, though ${S.join(" and ")} expect to connect to these`,nodeIds:[]})}return{observations:u}}}}function Ee(e,t,n,u){let f=new Set(t.map(l=>e.graph.getNode(l.from)?.kind).filter(l=>l!==void 0)),c=f.size===1?[...f][0]:void 0,S=t.length,v=W(e.schema,c??[...f][0]??"",n,"in"),i=l=>c?re(e.schema,c,l):String(l);return u===S?`${v}: all ${i(u)}`:`${v}: ${u} of the ${i(S)}`}function ve(e){let t=new Map;if(e.length===0)return t;let n=e.slice(-512),u=new Set;for(let c of n)c.undoes&&u.add(c.undoes);let f=e[e.length-1].seq;for(let c of n){if(!c.mutation||u.has(c.id))continue;let S=Math.pow(.5,(f-c.seq)/64);t.set(c.mutation.name,(t.get(c.mutation.name)??0)+S)}return t}function Se(e){return 8*(e/(e+1))}var Ce=100;function Ae(){return{name:"invariant",derive({store:e,selection:t,nodes:n,violations:u}){let f=l=>_(e.schema.tryDefinition(l.kind),l),c=new Set(t),S=u.filter(l=>l.nodeIds.some(p=>c.has(p))||l.subjectId!==void 0&&c.has(l.subjectId)),v=[],i=[];S.forEach((l,p)=>{i.push({id:`violation:${l.invariant}:${p}`,text:l.message,nodeIds:l.nodeIds}),l.repairs.forEach((d,g)=>{v.push({id:`invariant:${l.invariant}:${p}:${g}`,label:d.label,provider:"invariant",mutation:d.mutation,args:d.args??{},open:(d.missing??[]).map(s=>{let a=e.allMutations().find(o=>o.name===d.mutation);if(!a)return{name:s};let h=P(a.input).find(o=>o.name===s),y=h?h.kinds.includes("*")?e.graph.allNodes().map(o=>o.id):h.kinds.flatMap(o=>e.graph.nodesOfKind(o).map(r=>r.id)):void 0;return{name:s,shape:j(a.input,s),...h?{kinds:h.kinds}:{},...y?{candidates:y}:{}}}),score:Ce-g-(d.missing?.length??0),why:l.message,nodeIds:l.nodeIds,...l.subjectId===void 0?{}:{subjectId:l.subjectId}})})});for(let l of n){let p=e.allInvariants().filter(d=>{if(d.scope==="graph")return!1;let g=d.scope;return g.kind!==l.kind?!1:g.match?g.match(l):!0});p.length!==0&&(S.some(d=>d.subjectId===l.id||d.nodeIds.includes(l.id))||i.push({id:`holds:${l.id}`,text:`${f(l)} holds \u2014 nothing currently breaks ${p.length===1?"it":`any of its ${p.length} rules`}`,nodeIds:[l.id]}))}return{affordances:v,observations:i}}}}var Z=40;function $e(){return{name:"schema",derive({store:e,selection:t,nodes:n,kindSelection:u,edgeSelection:f}){let c=[];if(n.length===0&&f.length>0){for(let i of f){let l=e.graph.getNode(i.from),p=e.graph.getNode(i.to);if(!(!l||!p))for(let d of e.allMutations()){let g=(d.connects??[]).includes(i.kind),s=(d.severs??[]).includes(i.kind);if(!g&&!s)continue;let a={},h=[],y=P(d.input);for(let r of y){let w=r.kinds.includes("*")||r.kinds.includes(l.kind),b=r.kinds.includes("*")||r.kinds.includes(p.kind),A=w&&!y.some(k=>k!==r&&(k.kinds.includes(l.kind)||k.kinds.includes("*")));w&&!b?a[r.name]=i.from:b&&!w?a[r.name]=i.to:w&&b&&A?a[r.name]=i.from:h.push({name:r.name,kinds:r.kinds,candidates:[i.from,i.to],shape:j(d.input,r.name)})}for(let r of q(d.input,""))r in a||h.some(w=>w.name===r)||h.push({name:r,shape:j(d.input,r)});h.every(r=>r.optional===!0?!0:r.kinds!==void 0?(r.candidates?.length??0)>0:(r.candidates?.length??0)>0||r.shape!==void 0&&r.shape.type!=="unknown")&&(g&&!s&&h.length===0||c.push({id:`schema:edge:${d.name}:${i.kind}:${i.from}:${i.to}`,label:M(d),provider:"schema",mutation:d.name,args:a,open:h,...d.destructive?{destructive:!0}:{},score:(s?62:58)-h.length,why:`this line is "${W(e.schema,e.graph.getNode(i.from)?.kind??"",i.kind,"out")}"`,nodeIds:[i.from,i.to]}))}}return{affordances:c}}if(n.length===0&&u.length>0){let i=new Set(u),l=[];for(let p of e.allMutations()){if(!(p.creates??[]).some(s=>i.has(s)))continue;let d=[];for(let s of P(p.input)){let a=s.kinds.includes("*")?e.graph.allNodes().map(h=>h.id):s.kinds.flatMap(h=>e.graph.nodesOfKind(h).map(y=>y.id));d.push({name:s.name,kinds:s.kinds,candidates:a,shape:j(p.input,s.name),...s.optional?{optional:!0}:{}})}for(let s of q(p.input,""))d.some(a=>a.name===s)||d.push({name:s,shape:j(p.input,s)});if(!d.every(s=>s.optional===!0?!0:s.kinds!==void 0?(s.candidates?.length??0)>0:(s.candidates?.length??0)>0||s.shape!==void 0&&s.shape.type!=="unknown")){let s=d.filter(a=>a.optional!==!0&&a.kinds!==void 0&&!a.kinds.includes("*")&&(a.candidates?.length??0)===0);if(s.length>0){let a=[...new Set(s.flatMap(h=>h.kinds??[]))].map(h=>B(K(e.schema.tryDefinition(h),h)));l.push({id:`schema:waits:${p.name}`,text:`"${p.title??p.name}" cannot begin until there is ${a.length===1?a[0]:`${a.slice(0,-1).join(", ")} and ${a[a.length-1]}`}.`,nodeIds:[]})}continue}c.push({id:`schema:add:${p.name}`,label:M(p),provider:"schema",mutation:p.name,args:{},open:d,score:Z-d.length,why:`this makes ${(p.creates??[]).filter(s=>i.has(s)).map(s=>B(K(e.schema.tryDefinition(s),s))).join(", ")}`,nodeIds:[]})}return{affordances:c,observations:l}}if(n.length===0)return{};let S=new Set(n.map(i=>i.kind)),v=(i,l,p)=>{let d=[];for(let g of e.graph.allEdges()){if(!l.includes(g.kind))continue;let s=g.from===i?g.to:g.to===i?g.from:null;if(!s)continue;let a=e.graph.getNode(s);a&&(!p.includes("*")&&!p.includes(a.kind)||d.includes(s)||d.push(s))}return d};for(let i of e.allMutations()){let l=i.subject;if(!l||!(l.kinds==="*"?!0:[...S].every(o=>l.kinds.includes(o))))continue;let d=n.length===1?n[0].id:null,g=i.severs??[],s=i.connects??[];if(d&&g.length>0&&s.length===0&&v(d,g,["*"]).length===0)continue;let a=[];for(let o of P(i.input)){if(o.name===l.arg)continue;let r=o.kinds.includes("*")?e.graph.allNodes().map(w=>w.id):o.kinds.flatMap(w=>e.graph.nodesOfKind(w).map(b=>b.id));if(d&&s.length>0){let w=new Set(v(d,s,o.kinds));r=r.filter(b=>!w.has(b))}else d&&g.length>0&&(r=v(d,g,o.kinds));a.push({name:o.name,kinds:o.kinds,candidates:r.filter(w=>!t.includes(w)),shape:j(i.input,o.name),...o.optional?{optional:!0}:{}})}for(let o of q(i.input,l.arg))a.some(r=>r.name===o)||a.push({name:o,shape:j(i.input,o)});if(a.length===0&&d){let o=He(i.input,l.arg);if(o.length>0&&!Le(e,i.name,{[l.arg]:d}))for(let r of o){let w=P(i.input).find(b=>b.name===r);a.push({name:r,optional:!0,...w?{kinds:w.kinds}:{},shape:j(i.input,r)})}}if(!a.every(o=>o.optional===!0?!0:o.kinds!==void 0?(o.candidates?.length??0)>0:(o.candidates?.length??0)>0||o.shape!==void 0&&o.shape.type!=="unknown"))continue;let y=n.map(o=>({[l.arg]:o.id}));a.length===0&&!y.some(o=>e.wouldChange({name:i.name,args:o}))||c.push({id:`schema:${i.name}`,label:n.length>1?`${M(i)} (${n.length})`:M(i),provider:"schema",mutation:i.name,args:y[0]??{},open:a,...i.destructive?{destructive:!0}:{},...g.length>0||s.length>0?{ties:!0}:{},...n.length>1?{batch:y}:{},score:Z-a.length,why:n.length>1?`all ${n.length} selected nodes are ${[...S].map(o=>se(e.schema,o).toLowerCase()).join(" or ")}`:`this is ${B(K(e.schema.tryDefinition(n[0].kind),n[0].kind))}`,nodeIds:n.map(o=>o.id)})}if(n.length===1){let i=n[0];for(let l of e.allMutations()){let p=l.subject,d=l.severs??[],g=l.connects??[];if(!p||d.length===0&&g.length===0)continue;let s=p.kinds==="*"?"*":p.kinds;if(s==="*"||s.includes(i.kind))continue;let a=P(l.input),h=a.find(k=>k.name!==p.arg&&(k.kinds.includes("*")||k.kinds.includes(i.kind)));if(!h)continue;let y=s,o=y.includes("*")?e.graph.allNodes().map(k=>k.id):y.flatMap(k=>e.graph.nodesOfKind(k).map(R=>R.id)),r=new Set(v(i.id,g.length>0?g:d,y)),w=g.length>0?o.filter(k=>!r.has(k)):o.filter(k=>r.has(k));if(w.length===0)continue;let b=[{name:p.arg,kinds:y,candidates:w,shape:j(l.input,p.arg)}];for(let k of a){if(k.name===h.name||k.name===p.arg)continue;let R=k.kinds.includes("*")?e.graph.allNodes().map(x=>x.id):k.kinds.flatMap(x=>e.graph.nodesOfKind(x).map(O=>O.id));b.push({name:k.name,kinds:k.kinds,candidates:R,shape:j(l.input,k.name),...k.optional?{optional:!0}:{}})}for(let k of q(l.input,h.name))k===p.arg||b.some(R=>R.name===k)||b.push({name:k,shape:j(l.input,k)});b.every(k=>k.optional===!0?!0:k.kinds!==void 0?(k.candidates?.length??0)>0:(k.candidates?.length??0)>0||k.shape!==void 0&&k.shape.type!=="unknown")&&c.push({id:`schema:tie:${l.name}:${i.id}`,label:l.fromTheOtherEnd??M(l),provider:"schema",mutation:l.name,args:{[h.name]:i.id},open:b,ties:!0,...l.destructive?{destructive:!0}:{},score:Z-b.length+2,why:`${d.length>0?"this one is on":"this one could join"} ${b[0].candidates.length===1?"it":"one of these"}`,nodeIds:[i.id]})}}return{affordances:c}}}}function He(e,t){let n=e.shape;return n?Object.entries(n).filter(([u,f])=>u!==t&&f.safeParse(void 0).success).map(([u])=>u):[]}function Le(e,t,n){try{return e.preview({name:t,args:n}),!0}catch{return!1}}function q(e,t){let n=e.shape;return n?Object.entries(n).filter(([u,f])=>u!==t&&!f.safeParse(void 0).success).map(([u])=>u):[]}var We=70,Be=80,Ke=new Set(["id","kind"]);function Oe(){return{name:"structure",derive({store:e,nodes:t}){let n=i=>_(e.schema.tryDefinition(i.kind),i);if(t.length<2)return{};let u=[],f=[],c=t.map(i=>i.id);for(let i of e.schema.edgeKinds){let l=Ge(t.map(d=>new Set([...e.graph.out(d.id,i).map(g=>g.id),...e.graph.in(d.id,i).map(g=>g.id)])));for(let d of l){let g=e.graph.getNode(d);g&&u.push({id:`shared:${i}:${d}`,text:`all ${t.length} share "${n(g)}" (${J(i).toLowerCase()})`,nodeIds:[...c,d]})}let p=new Map;for(let d of t)for(let g of[...e.graph.out(d.id,i),...e.graph.in(d.id,i)])p.set(g.id,(p.get(g.id)??0)+1);for(let[d,g]of p){if(g!==t.length-1||t.length<3)continue;let s=e.graph.getNode(d);if(!s)continue;let a=t.find(h=>![...e.graph.out(h.id,i),...e.graph.in(h.id,i)].some(y=>y.id===d));if(a){u.push({id:`near-shared:${i}:${d}`,text:`all but "${n(a)}" share "${n(s)}" (${J(i).toLowerCase()})`,nodeIds:[...c,d]});for(let h of e.allMutations()){let y=h.subject;if(!y||y.kinds!=="*"&&!y.kinds.includes(a.kind))continue;let o=Fe(h.input,s.kind);o&&f.push({id:`structure:join:${h.name}:${a.id}:${d}`,label:`${M(h)}: bring "${n(a)}" in line with the others`,provider:"structure",mutation:h.name,args:{[y.arg]:a.id,[o]:d},open:[],score:We,why:`every other selected node is connected to "${n(s)}"`,nodeIds:[a.id,d]})}}}}let S=new Set;for(let i of t)for(let l of Object.keys(i))Ke.has(l)||S.add(l);let v=i=>e.schema.definitions.find(l=>l.kind===i);for(let i of[...S].sort()){let l=v(t[0].kind),p=ae(l,i).toLowerCase(),d=l?.display?.format?.[i],g=A=>{if(!d)return A;try{return String(d(JSON.parse(A)))}catch{return A}},s=t.map(A=>A[i]),a=new Map;if(s.forEach((A,k)=>{let R=JSON.stringify(A??null),x=a.get(R);x?x.push(t[k]):a.set(R,[t[k]])}),a.size===1){let A=[...a.keys()][0];if(A==="null")continue;u.push({id:`agree:${i}`,text:`all ${t.length} share the ${p} ${g(A)}`,nodeIds:c});continue}if(t.length<3||a.size!==2)continue;let h=[...a.entries()].sort((A,k)=>k[1].length-A[1].length),[y,o]=h[0],[,r]=h[1];if(r.length!==1||y==="null")continue;let w=r[0],b=JSON.parse(y);u.push({id:`odd-one-out:${i}`,text:`${o.length} share the ${p} ${g(y)}; "${n(w)}" does not`,nodeIds:c});for(let A of e.allMutations()){let k=A.subject;if(!k||k.kinds!=="*"&&!k.kinds.includes(w.kind))continue;let R=Re(A.input);if(!R||!(i in R))continue;let x={[k.arg]:w.id,[i]:b},O=!0;for(let[D,U]of Object.entries(R)){if(D in x||U.safeParse(void 0).success)continue;let C=w[D];if(C===void 0){O=!1;break}x[D]=C}O&&f.push({id:`structure:align:${A.name}:${i}:${w.id}`,label:`Align the ${p} of "${n(w)}" with the other ${o.length}`,provider:"structure",mutation:A.name,args:x,open:[],score:Be,why:`${o.length} of ${t.length} share the ${p} ${g(y)}`,nodeIds:c})}}return{affordances:f,observations:u}}}}function Ge(e){if(e.length===0)return[];let[t,...n]=e;return[...t].filter(u=>n.every(f=>f.has(u))).sort()}function Re(e){return e.shape??null}function Fe(e,t){let n=Re(e);if(!n)return null;for(let[u]of Object.entries(n)){let f=ce(n[u]);if(f&&(f.includes("*")||f.includes(t)))return u}return null}function qe(){return[Ae(),Oe(),$e(),be()]}function je(e,t,n={}){let u=xe(),f=n.providers??qe(),c=t.map(m=>e.graph.getNode(m)).filter(m=>m!==void 0),S={store:e,selection:t,nodes:c,kindSelection:n.kindSelection??[],edgeSelection:n.edgeSelection??[],violations:e.violations(n.context),context:n.context??{}},v=[],i=[];for(let m of f){let $=m.derive(S);v.push(...$.affordances??[]),i.push(...$.observations??[])}let l=new Set(e.allMutations().filter(m=>m.pinned).map(m=>m.name)),p=new Set(n.pins?.pinned??[]),d=new Set(n.pins?.unpinned??[]),g=m=>p.has(m.mutation)?"user":l.has(m.mutation)&&!d.has(m.mutation)?"declared":void 0,s=m=>{let $=g(m);return $?{...m,pinned:$}:m},a=new Map;for(let[m,$]of ve(e.log.all()))a.set(m,Se($));let h=m=>m.pinned==="user"?0:m.pinned==="declared"?1:2,y=m=>m.score+(a.get(m.mutation)??0),o=new Map(e.allMutations().map(m=>[m.name,m])),r=new Map,w=m=>{let $=o.get(m.mutation);if(!$)return[];let N=r.get(m.mutation);N||(N=P($.input).map(V=>V.name),r.set(m.mutation,N));let H=[];for(let V of m.batch??[m.args])for(let ie of N){let oe=V[ie]??m.args[ie];typeof oe=="string"&&H.push(oe)}return H},b=n.focus,A=4,k=m=>m.open.length>0?1:0,R=m=>{if(b===void 0)return A;let $=w(m);return $.length>0?$.includes(b)?x(m,0):A:m.nodeIds.includes(b)||m.subjectId===b?x(m,1):A},x=(m,$)=>m.provider==="invariant"?$:2+k(m),O=Ue(v).map(s),D=new Map(O.map((m,$)=>[m,$])),U=O.sort((m,$)=>{let N=Number(m.destructive??!1)-Number($.destructive??!1);if(N!==0)return N;let H=R(m)-R($);return H!==0?H:R(m)<2?D.get(m)-D.get($):+($.provider==="invariant")-+(m.provider==="invariant")||h(m)-h($)||y($)-y(m)||m.id.localeCompare($.id)}),C=n.principal??{kind:"human"},L=[],ne=[];for(let m of U){let $=e.permits({name:m.mutation,args:{...m.args,...m.batch?.[0]??{}}},C);if($.ok)L.push(m);else{let N=ze(e,m,C);if(N==="done")continue;N?L.push(N):ne.push({...m,refusal:$.refusal})}}let te=L.map((m,$)=>({...m,rank:$})),_e=ne.map((m,$)=>({...m,rank:L.length+$}));return{affordances:n.limit===void 0?te:te.slice(0,n.limit),withheld:_e,observations:Ve(i),ms:xe()-u}}function Ue(e){let t=new Map;for(let n of e){let u=[n.mutation,JSON.stringify(n.args),JSON.stringify(n.batch??null)].join("|"),f=t.get(u);(!f||n.score>f.score)&&t.set(u,n)}return[...t.values()]}function Ve(e){let t=new Map;for(let n of e)t.set(n.text,n);return[...t.values()]}function xe(){return typeof performance<"u"?performance.now():Date.now()}function Je(e,t,n={},u={}){let f=(t.batch??[t.args]).map(S=>({name:t.mutation,args:{...t.args,...S,...n}})),c=e.allMutations().find(S=>S.name===t.mutation);return e.applyAll(f,{...c?.describe?{}:{intent:t.label},...u.author?{author:u.author}:{}})}function Rn(e,t,n={}){return e.preview({name:t.mutation,args:{...t.args,...n}})}function ze(e,t,n){let u=e.allMutations().find(i=>i.name===t.mutation)?.subject;if(!u||t.args[u.arg]!==void 0)return;let f=t.open.find(i=>i.name===u.arg);if(!f?.candidates)return;let c=i=>e.permits({name:t.mutation,args:{...t.args,...t.batch?.[0]??{},[u.arg]:i}},n).ok,S=f.candidates.filter(c),v=n.id===void 0?void 0:e.graph.getNode(n.id);return S.length===0?v!==void 0&&(u.kinds==="*"||u.kinds.includes(v.kind))&&c(v.id)?"done":void 0:S.length===1&&S[0]===n.id?{...t,args:{...t.args,[u.arg]:n.id},open:t.open.filter(i=>i!==f)}:{...t,open:t.open.map(i=>i===f?{...i,candidates:S}:i)}}var Pe,Ze=()=>Pe??=import("./chunk.3TNQPFIK.js").catch(e=>{throw Pe=void 0,e}),Xe=()=>import("./chunk.KWSXL3A2.js").catch(()=>{}),Ye=async()=>{(await Xe())?.judgeWithLines()},Ne,Qe=()=>Ne??=import("./chunk.OXODTBOP.js").catch(e=>{throw Ne=void 0,e}),T=e=>({title:e,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}),X=[{name:"search_graph",title:"Find by name",description:"Find things by name: records whose name or readable fields carry the words, and the kinds, places and rules the words name \u2014 each with why it matched. Reach for this before get_graph when you know what something is called. Words match the start of words, case and accents aside; key:value tokens narrow as a list's filter does (done:false, is:any for past records, kind:<kind>). Pass subject (a node id) to get the acts you may run on it as hits too.",inputSchema:{type:"object",properties:{query:{type:"string",description:"Words, with optional key:value conditions."},limit:{type:"number",description:"Most hits to return; 20 when unsaid."},subject:{type:"string",description:"A node id whose acts to include."}},required:["query"],additionalProperties:!1},mutating:!1,annotations:T("Find by name")},{name:"get_graph",title:"Read the whole graph",description:"Read the whole graph: every node with its fields, and every edge. Start here when you need the shape of the domain rather than one thing in it.",inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:T("Read the whole graph")},{name:"get_node",title:"Read one node",description:"Read one node, its edges, and the violations that implicate it, with its computed values: read-only fields worked out from what you can see, which no act sets. Use this to check a thing before you change it.",inputSchema:{type:"object",properties:{id:{type:"string",description:"A node's id, or its name."}},required:["id"],additionalProperties:!1},mutating:!1,annotations:T("Read one node")},{name:"get_violations",title:"List the problems",description:"List every invariant violation the graph currently has, with the repairs that would resolve each one. Read this before proposing work: a rule that is already broken is more urgent than anything you could add.",inputSchema:{type:"object",properties:{context:{type:"object",description:"Evaluation context, e.g. { weekStart }."}},additionalProperties:!1},mutating:!1,annotations:T("List the problems")},{name:"get_affordances",title:"Ask what can be done",description:"Ask what can legally be done with a selection, ranked. Prefer these over composing a mutation by hand: they are derived from the schema, the invariants and the shape of the graph, so they cannot name an action that does not exist.",inputSchema:{type:"object",properties:{selection:{type:"array",items:{type:"string"},description:"Node ids."},context:{type:"object"}},required:["selection"],additionalProperties:!1},mutating:!1,annotations:T("Ask what can be done")},{name:"describe_place",title:"Say what a place shows",description:`Say what one place of the app shows you, as a person in your seat would see it: its headings, its figures as drawn, its lists with each record's title and what its card or row says, the headings a list is grouped under, what an empty list says, and any block that could not be worked out. Pass a place's slug ("home", a lens's address like "the-offers", a kind's like "offers") or a record's id, and width 390 for a phone. Use it after a change to check what somebody now sees, instead of guessing.`,inputSchema:{type:"object",properties:{place:{type:"string",description:`"home", a place's slug, or a record's id.`},width:{type:"number",description:"The screen's width in CSS pixels; 390 is a phone, 1440 when unsaid."}},required:["place"],additionalProperties:!1},mutating:!1,annotations:T("Say what a place shows")},{name:"preview_mutation",title:"Try an act without applying it",description:"Try a mutation without applying it: get back the diff it would produce and any invariant it would break. Do this when you are unsure, rather than applying and undoing.",inputSchema:{type:"object",properties:{mutation:{type:"string"},args:{type:"object"}},required:["mutation","args"],additionalProperties:!1},mutating:!1,annotations:T("Try an act without applying it")},{name:"undo_batch",title:"Undo a batch",description:"Undo one batch of operations. Fails, naming the blocking operation, when a later operation read what it wrote.",inputSchema:{type:"object",properties:{batch:{type:"string"},include:{type:"array",items:{type:"string"}}},required:["batch"],additionalProperties:!1},mutating:!0,annotations:{title:"Undo a batch",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1}}],Y={type:"object",description:"A lens, as draft_view returns one.",properties:{title:{type:"string"},lens:{type:"string"},on:{type:"string"},bindings:{type:"object"},options:{type:"object"}},required:["title","lens","on"]},Q={name:"draft_view",title:"Draw a view",description:'Draw a view of the data from words ("a board of tasks by status", "who covers what") as a lens the app could keep; or check a lens you wrote (lens); or change the one on screen (current, with ask: "only this month"). Returns the lens and its add-lens edit, or one sentence saying why not. Writes nothing.',inputSchema:{type:"object",properties:{ask:{type:"string",description:"What to see, in words."},lens:Y,current:Y},additionalProperties:!1},mutating:!1,annotations:T("Draw a view")},De={name:"keep_lens",title:"Keep a view as a lens",description:"Keep a lens draft_view drew as one of the app's places: checked again, then written as the add-lens edit. Returns the remove-lens edit that takes it back.",inputSchema:{...Y,additionalProperties:!1},mutating:!0,annotations:{title:"Keep a view as a lens",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}};function en(e,t){return e===void 0?[]:e==="keep"&&!t?[Q,De]:[Q]}var nn="An argument that names a record takes its id or its name.",Te=[...X.map(e=>e.name),Q.name,De.name],Ie=64;function I(e){let{line:t,...n}=e;return n}function Me(e){return{...e,...e.introduces?{introduces:e.introduces.map(I)}:{},...e.resolves?{resolves:e.resolves.map(I)}:{},...e.violationsAfter?{violationsAfter:e.violationsAfter.map(I)}:{}}}function tn(e){let t=e.normalize("NFKD").replace(/\p{M}/gu,"").replace(/[^A-Za-z0-9_-]/g,"_");return t.length===0&&(t="act"),/^[A-Za-z_]/.test(t)||(t=`act_${t}`),t.slice(0,Ie)}function on(e){let t=new Set(Te),n=new Map;for(let u of e){let f=tn(u),c=f;for(let S=2;t.has(c);S+=1)c=`${f.slice(0,Ie-`_${S}`.length)}_${S}`;t.add(c),n.set(u,c)}return n}function rn(e,t){let n=ue(e),u=M(e),f=n.nodeRefs.length>0?`${n.description}${/[.!?]$/.test(n.description)?"":"."} ${nn}`:n.description;return{name:t,title:u,description:f,inputSchema:n.inputSchema,mutating:!0,annotations:{title:u,readOnlyHint:!1,destructiveHint:e.destructive===!0||(e.severs?.length??0)>0,idempotentHint:e.idempotent===!0,openWorldHint:!1},act:e.name}}function ee(e){if(e===null||typeof e!="object")return JSON.stringify(e)??"null";if(Array.isArray(e))return`[${e.map(ee).join(",")}]`;let t=e;return`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${ee(t[n])}`).join(",")}}`}function sn(e){return`sha256:${he(ee(e))}`}function an(e,t,n,u){let f=on(e.map(v=>v.name)),c=en(u,n);return{definitions:n?[...X.filter(v=>!v.mutating),...c]:[...X,...c,...e.filter(v=>t.has(v.name)).map(v=>rn(v,f.get(v.name)))],names:f}}function Cn(e,t={}){let n=t.author??{kind:"agent"},u=e.allMutations(),f=new Set(e.permittedMutations(n).map(s=>s.name)),{definitions:c,names:S}=an(u,f,t.readOnly===!0,t.drafts?t.drafts.keep?"keep":"draw":void 0),v=sn(c),i=s=>{if(!Te.includes(s)){for(let[a,h]of S)if(h===s)return a;return S.has(s)?s:void 0}},l=(s,a)=>{let h=u.find(r=>r.name===s);if(!h)return{args:a,resolved:[]};let y={...a},o=[];for(let r of P(h.input)){let w=y[r.name];if(typeof w!="string"||w.trim()==="")continue;let b=e.resolveRef(r,w,n);if(!b.ok){let A=b.reason==="none"?` Nothing was changed. Use search_graph to look it up, then pass its id as ${r.name}.`:" Nothing was changed.";return{ok:!1,error:`${b.message}${A}`,argument:r.name,candidates:b.candidates}}b.by!=="id"&&(y[r.name]=b.id,o.push({argument:r.name,given:w,id:b.id,label:b.label}))}return{args:y,resolved:o}},p=async(s,a)=>{try{await Ye();let h=c.find(o=>o.name===s)??c.find(o=>o.act===s);if(!h){let o=i(s);if(o){let r=e.permits({name:o,args:a},n);if(!r.ok)return{ok:!1,error:r.refusal.message,reason:"forbidden"}}return{ok:!1,error:`Unknown tool "${s}". Available: ${c.map(r=>r.name).join(", ")}`}}if(h.mutating&&t.readOnly)return{ok:!1,error:`"${s}" changes the graph, and this seat is read-only.`,reason:"forbidden"};if(h.act!==void 0){let o=l(h.act,a);if("ok"in o)return o;let r=G(e,n,e.apply({name:h.act,args:o.args},{...t.author?{author:t.author}:{},...dn(t.via)}));return{ok:!0,data:{batch:r.batch,intent:r.intent,introduces:r.introduces.map(I),resolves:r.resolves.map(I),...o.resolved.length>0?{resolved:o.resolved}:{}},diff:r.diff}}let y=e.seenBy(n);switch(h.name){case"search_graph":{let o=typeof t.places=="function"?t.places():t.places,r=typeof a.subject=="string"?a.subject:void 0,w=pe(y,String(a.query??""),{principal:n,limit:typeof a.limit=="number"?a.limit:20,...o?{places:o}:{},...r?{subject:r,from:[r]}:{}});return{ok:!0,data:we(w,F(y,n)),reads:w.hits.flatMap(b=>b.about==="node"?[b.id]:[])}}case"get_graph":{let o=y.graph.snapshot();return{ok:!0,data:ke(o,F(y,n)),reads:o.nodes.map(r=>r.id)}}case"get_node":{let o=String(a.id??""),r=o,w;if(!y.graph.getNode(o)){let O=o.trim()===""?void 0:e.resolveRef({name:"id",kinds:["*"]},o,n);if(O?.ok)r=O.id,w={argument:"id",given:o,id:r,label:O.label};else return O?.reason==="ambiguous"?{ok:!1,error:O.message,argument:"id",candidates:O.candidates}:{ok:!1,error:`No node "${o}".`}}let b=y.graph.getNode(r),A=y.graph.outEdges(r),k=y.graph.inEdges(r),R=F(y,n),x=ge(y.schema,y.graph,b);return{ok:!0,data:{node:z(b,R),...Object.keys(x.values).length>0?{computed:ye(r,x.values,R)}:{},...Object.keys(x.refused).length>0?{uncomputed:x.refused}:{},out:A,in:k,violations:y.violations().filter(O=>O.nodeIds.includes(r)).map(I),...w?{resolved:[w]}:{}},reads:[r,...A.map(O=>O.to),...k.map(O=>O.from)]}}case"describe_place":{let o=t.app??{name:"",schema:e.schema},r=typeof a.width=="number"&&Number.isFinite(a.width)&&a.width>0?a.width:1440,{describePlace:w}=await Ze(),b=w(e,n,String(a.place??""),{app:o,width:r});if(!b.ok)return{ok:!1,error:`${b.error} The places are: ${b.places.join(", ")}.`};let A=new Set,k=R=>{for(let x of R)for(let O of x.groups??[])for(let D of O.items)A.add(D.id),k(D.parts)};return k(b.description.parts),{ok:!0,data:b.description,reads:[...A]}}case"draft_view":case"keep_lens":{let o=t.app??{name:"",schema:e.schema};return(await Qe()).runDraftTool(h.name,a,{app:o,principal:n,...t.drafts?{drafts:t.drafts}:{}})}case"get_violations":{let o=y.violations(a.context);return{ok:!0,data:o.map(I),reads:[...new Set(o.flatMap(r=>r.nodeIds))]}}case"get_affordances":{let o=a.selection??[];return{ok:!0,data:je(y,o,{...typeof t.derive=="function"?t.derive():t.derive,...t.author?{principal:t.author}:{},...a.context?{context:a.context}:{}}),reads:o.filter(w=>y.graph.has(w))}}case"preview_mutation":{let o=String(a.mutation),r=i(o)??o,w=l(r,a.args??{});if("ok"in w)return w;let b=e.missingFor({name:r,args:w.args},n);if(b)return{ok:!1,error:b.message,reason:"missing"};let A=G(e,n,e.preview({name:r,args:w.args},void 0,{author:n})),k=Me(A);return{ok:!0,data:w.resolved.length>0?{...k,resolved:w.resolved}:k}}case"undo_batch":{let o=String(a.batch),r=a.include??[],w=y.canUndo([o,...r]);if(!w.ok)return{ok:!1,error:w.message};let b=G(e,n,e.undo([o,...r],{...t.author?{author:t.author}:{}}));return{ok:!0,data:Me(b),diff:b.diff}}default:return{ok:!1,error:`Unknown tool "${s}".`}}}catch(h){let{reason:y,wouldNeed:o}=fe(h);return{ok:!1,error:h instanceof Error?h.message:String(h),reason:y,...o?{wouldNeed:o}:{}}}},d=new Set,g=s=>{for(let a of d)a(s)};return{definitions:c,hash:v,...t.author?{author:t.author}:{},onDiff(s){return e.subscribe(s)},onCall(s){return d.add(s),()=>d.delete(s)},async call(s,a){let h=(c.find(r=>r.name===s)??c.find(r=>r.act===s))?.mutating??!1,y={name:s,args:a,mutating:h,at:new Date().toISOString()};return g({...y,phase:"running"}),(r=>(g(r.ok?{...y,phase:"ok",...!h&&r.reads?{reads:r.reads}:{}}:{...y,phase:"failed",error:r.error}),r))(await p(s,a))}}}function dn(e){let t=typeof e=="function"?e():e;return t?{via:t}:{}}export{je as a,Je as b,Rn as c,Cn as d};
@@ -1 +0,0 @@
1
- import{c as a,l as o}from"./chunk.VTBAKTFP.js";import"./chunk.7U7Q3HIS.js";import"./chunk.6O67NOZR.js";import"./chunk.WWRWXFYR.js";import"./chunk.ISAMJ7AK.js";import"./chunk.54NSG7BX.js";import"./chunk.6KJSFIO7.js";import"./chunk.UM5IPM22.js";import"./chunk.6XBLDV4A.js";import"./chunk.WOTNMTIY.js";import"./chunk.HAQ4KHRY.js";import"./chunk.PRXKRG6O.js";import"./chunk.AHDOKM4O.js";import"./chunk.TDW6QEG4.js";import"./chunk.LW7KV5SL.js";import{la as n}from"./chunk.2VX6H2LL.js";import"./chunk.ZQ4HFIIS.js";import"./chunk.MRK6QJV5.js";import"./chunk.AJZBJBMO.js";var w=new WeakMap;function p(e,i){let t=w.get(e);t||w.set(e,t=new Map);let r=t.get(i);return r||t.set(i,r=o(a(e,n(e)),e,i)),r}export{p as frameworkViews};
@@ -1 +0,0 @@
1
- import{a as it}from"./chunk.UM5IPM22.js";import{f as st}from"./chunk.6XBLDV4A.js";import{a as M,e as q,n as at}from"./chunk.WOTNMTIY.js";import{$ as nt,C as Y,D as G,Db as ot,I as T,L as V,Ma as rt,O as Q,R as X,T as k,_ as tt,na as et}from"./chunk.ZQ4HFIIS.js";import"./chunk.AJZBJBMO.js";function _(t){let e=[],n=!0;for(let r of t){if(r.text.length===0)continue;let a=r.as==="close"||r.text===","||r.text===":"||r.text.startsWith("'")||n;e.push({part:r,space:!a}),n=r.as==="open"}return e}function D(t,e){return _(t).map(({part:n,space:r})=>`${r?" ":""}${e?n.said??n.text:n.text}`).join("")}function ht(t){return D(t,!1)}function xt(t){return D(t,!0)}function lt(t,e=!1){let n=e?t.said:t.text;return t.record!==void 0?`${t.record} \u2014 ${n}`:n}function J(t){let e=u=>_(u).map(({part:o,space:s})=>({...o,space:s})),n=e(t.parts),r=t.when&&t.when.length>0?e(t.when):void 0,a=u=>`${D(n,u)}${r?`, when ${D(r,u)}`:""}`;return{...t,parts:n,...r?{when:r}:{},text:a(!1),said:a(!0)}}function bt(t,e=!1){return t.line?lt(t.line,e):t.message}var ut=60,L=t=>({text:t,as:"name"}),d=(t,e)=>e===void 0?{text:t,as:"word"}:{text:t,as:"word",said:e},P=(t,e)=>e===void 0||e===t?{text:t,as:"value"}:{text:t,as:"value",said:e},b=(t,e)=>({text:t,as:"op",said:e}),R={text:"(",as:"open"},w={text:")",as:"close"},N={text:"\u2014",as:"value",said:"empty"},K={">=":["\u2265","at least"],"<=":["\u2264","at most"],"<":["<","less than"],">":[">","more than"],"==":["=","is"],"!=":["\u2260","is not"]},z={">=":"<","<=":">","<":">=",">":"<=","==":"!=","!=":"=="},Rt={"+":["+","plus"],"-":["\u2212","minus"],"*":["\xD7","times"],"/":["\xF7","divided by"],"%":["mod","modulo"]},ct=t=>t.t==="binary"&&t.op in K;function F(t){return t.length>1&&t[1]===t[1].toUpperCase()&&/[A-Z]/.test(t[1])?t:t.charAt(0).toLowerCase()+t.slice(1)}function dt(t){let{schema:e}=t,n=i=>i===null?void 0:e.tryDefinition(i),r=(i,c)=>{let y=n(i)?.edges;return y&&Object.hasOwn(y,c)?y[c]:void 0},a=(i,c)=>{let y=r(i,c)?.to;return Array.isArray(y)&&y.length===1?y[0]:null},u=(i,c)=>{let y=(e.edge(c)?.from??[]).filter(S=>{let $=r(S,c)?.to;return i===null||$==="*"||Array.isArray($)&&$.includes(i)});return y.length===1?y[0]:null},o=(i,c)=>r(i,c)?V(c).toLowerCase():F(X(n(i),c)),s=i=>F(Q(e,i)),p=i=>F(st(e).get(i)?.label??V(i)),x=i=>F(k(n(i),i)),l=(i,c)=>{let y=i===null?void 0:t.formatOf?.(i,c);if(y?.format)return y;let S=t.said?.get(c);return S?{...y,format:S}:y},m=i=>T(e.tryDefinition(i.kind),i),g=(i,c)=>{if(i==null)return N;if(i instanceof M){if(i.nodes.length===0)return N;let v=i.nodes.slice(0,3).map(m),H=i.nodes.length-v.length;return P(H>0?`${v.join(", ")} and ${H} more`:v.length>1?`${v.slice(0,-1).join(", ")} and ${v[v.length-1]}`:v[0])}if(Array.isArray(i))return P(`{${i.map(v=>g(v,c).text).join(", ")}}`,i.map(v=>g(v,c).text).join(" or "));if(typeof i=="object")return P(m(i));if(typeof i=="boolean")return P(i?"yes":"no");let y=c?.format??(c?l(c.kind,c.key):void 0);if(typeof i=="number"){if(y?.format==="money")return P(at(i,{...t.money,...y.unit&&/^[A-Z]{3}$/.test(y.unit)?{currency:y.unit}:{}}));if(y?.format==="percent")return P(`${Math.round(i*100)}%`);let v=i.toLocaleString("en-US",{maximumFractionDigits:2});return P(y?.unit&&!/^[A-Z]{3}$/.test(y.unit)?`${v} ${y.unit}`:v)}if(Y.test(i)||y?.format==="date")return P(G(i.slice(0,10)));let S=c&&c.kind!==null?n(c.kind)?.display?.format?.[c.key]:void 0;if(S)return P(S(i));let $=i.length>ut?`${i.slice(0,ut-1).trimEnd()}\u2026`:i;return P(/^[a-z][a-z0-9]*([-_][a-z0-9]+)*$/.test($)?$.replace(/[-_]+/g," "):$)};return{definition:n,relation:r,farOf:a,nearOf:u,fieldName:o,plural:s,noun:x,factName:p,formatOf:l,valueWords:g}}function E(t,e,n){if(t.t==="ident")return{kind:e,key:t.name};if(t.t==="member")return{kind:O(t.object,e,n),key:t.name};if(t.t==="call"&&(t.fn==="sum"||t.fn==="min"||t.fn==="max")&&t.args.length===2){let r=O(t.args[0],e,n),a=t.args[1];if(a.t==="ident")return{kind:r,key:a.name};if(a.t==="lit"&&typeof a.value=="string")return{kind:r,key:a.value}}if(t.t==="binary"&&(t.op==="+"||t.op==="-"))return E(t.left,e,n)??E(t.right,e,n);if(t.t==="call"&&t.fn==="if"&&t.args.length===3)return E(t.args[1],e,n)??E(t.args[2],e,n)}function O(t,e,n){switch(t.t){case"ident":return n.relation(e,t.name)?n.farOf(e,t.name):null;case"member":return n.farOf(O(t.object,e,n),t.name);case"where":return O(t.set,e,n);case"binary":return t.op==="|"||t.op==="&"||t.op==="-"?O(t.left,e,n):null;case"call":{let r=a=>{let u=t.args[a];return u?.t==="lit"&&typeof u.value=="string"?u.value:void 0};return t.fn==="all"?r(0)??null:t.fn==="out"?t.args.length===2?n.farOf(O(t.args[0],e,n),r(1)??""):n.farOf(e,r(0)??""):t.fn==="in"?t.args.length===2?n.nearOf(O(t.args[0],e,n),r(1)??""):n.nearOf(e,r(0)??""):(t.fn==="first"||t.fn==="sort")&&t.args[0]?O(t.args[0],e,n):null}default:return null}}function A(t){return t.t==="binary"?t.op==="||"?B(t)?4:1:t.op==="&&"?2:t.op in K||t.op==="in"?4:t.op==="+"||t.op==="-"?5:t.op==="*"||t.op==="/"||t.op==="%"?6:4.5:t.t==="unary"&&t.op==="!"?3:t.t==="where"?3.5:9}var W=t=>t.t==="lit",h=(t,e)=>t.t==="call"&&t.fn===e;function C(t,e){return t.t==="binary"&&t.op===e?[...C(t.left,e),...C(t.right,e)]:[t]}function B(t){if(t.t!=="binary"||t.op!=="||")return;let e=[];e.push(...C(t,"||"));let n,r=[];for(let a of e){if(a.t!=="binary"||a.op!=="=="||!W(a.right)||typeof a.right.value!="string"||n&&JSON.stringify(ft(n))!==JSON.stringify(ft(a.left)))return;n=a.left,r.push(a.right)}return n?{subject:n,values:r}:void 0}var ft=t=>JSON.parse(JSON.stringify(t,(e,n)=>e==="at"?void 0:n));function f(t,e,n,r){let a=(u,o,s=e)=>A(u)<o?[R,...f(u,s,n),w]:f(u,s,n);switch(t.t){case"lit":return[n.valueWords(t.value,r)];case"list":return[n.valueWords(t.items.map(u=>u.t==="lit"?u.value:null),r)];case"ident":return[L(n.fieldName(e,t.name))];case"member":{let u=h(t.object,"first")&&t.object.args[0]&&h(t.object.args[0],"all"),o=O(t.object,e,n);if(u&&o)return e!==null&&n.fieldName(e,t.name)===n.fieldName(o,t.name)&&n.definition(e)?.fields?.shape&&Object.prototype.hasOwnProperty.call(n.definition(e).fields.shape,t.name)?[L(`${n.noun(o)}'s ${n.fieldName(o,t.name)}`)]:[L(n.fieldName(o,t.name))];let s=f(t.object,e,n),p=s[s.length-1];return s.length===1&&p?.as==="name"?[L(`${p.text}'s ${n.fieldName(o,t.name)}`)]:[...s,d("'s"),L(n.fieldName(o,t.name))]}case"unary":return t.op==="-"?[b("\u2212","minus"),...a(t.operand,7)]:I(t.operand,e,n);case"where":{let u=O(t.set,e,n),o=f(t.filter,u,n),s=o.every(p=>p.as==="name"||p.as==="word"&&p.text==="not");return[...a(t.set,4),...s?[]:[d("with")],...A(t.filter)<=2?[R,...o,w]:o]}case"binary":return pt(t,e,n);case"call":return wt(t,e,n)}}function I(t,e,n){return ct(t)?pt({...t,op:z[t.op]},e,n):h(t,"present")||h(t,"exists")?[...f(t.args[0],e,n),b("=","is"),N]:t.t==="ident"?[d("not"),L(n.fieldName(e,t.name))]:[d("not"),R,...f(t,e,n),w]}function pt(t,e,n){let r=(o,s)=>A(o)<s?[R,...f(o,e,n),w]:f(o,e,n);if(t.op==="&&"||t.op==="||"){let o=B(t);if(o){let p=E(o.subject,e,n);return[...f(o.subject,e,n),b("\u2208","is one of"),n.valueWords(o.values.map(x=>x.value),p)]}let s=t.op==="&&"?2:1;return[...r(t.left,s),d(t.op==="&&"?"and":"or"),...r(t.right,s+.5)]}if(t.op in K){if(W(t.right)&&typeof t.right.value=="boolean"&&(t.op==="=="||t.op==="!="))return t.op==="=="===t.right.value?f(t.left,e,n):I(t.left,e,n);let[o,s]=K[t.op],p=E(t.left,e,n),x=E(t.right,e,n);return[...j(t.left,e,n,x),b(o,s),...j(t.right,e,n,p)]}if(t.op==="in")return[...r(t.left,5),b("\u2208","is one of"),...j(t.right,e,n,E(t.left,e,n))];let a=Rt[t.op];if(a){let o=A(t);return[...r(t.left,o),b(a[0],a[1]),...r(t.right,o+.5)]}let u={"|":"or","&":"and also","-":"except"};return[...r(t.left,5),d(u[t.op]??t.op),...r(t.right,5)]}function j(t,e,n,r){return t.t==="lit"||t.t==="list"?f(t,e,n,r):A(t)<5?[R,...f(t,e,n),w]:f(t,e,n)}function wt(t,e,n){let r=o=>t.args[o],a=o=>{let s=t.args[o];return s?.t==="lit"&&typeof s.value=="string"?s.value:void 0},u=o=>{let s=r(o);return A(s)<9&&s.t!=="where"?[R,...f(s,e,n),w]:f(s,e,n)};switch(t.fn){case"out":{let o=a(t.args.length-1)??"",s=L(V(o).toLowerCase());return t.args.length===2?[s,d("of"),...u(0)]:[s]}case"in":{let o=a(t.args.length-1)??"",s=t.args.length===2?n.nearOf(O(r(0),e,n),o):n.nearOf(e,o),p=L(s?n.plural(s):V(o).toLowerCase());return t.args.length===2?[p,d("of"),...u(0)]:[p]}case"all":{let o=a(0);return[L(o?n.plural(o):"everything")]}case"fact":{let o=a(0);return[L(o?n.factName(o):"fact")]}case"count":return[d("number of"),...u(0)];case"exists":return[...u(0),b("\u2260","is not"),N];case"present":return[...f(r(0),e,n),b("\u2260","is not"),N];case"some":case"every":{let o=O(r(0),e,n),s=r(1);return[...t.fn==="some"?[d("some")]:[],...u(0),d(t.fn==="some"?"with":"all with"),...A(s)<=2?[R,...f(s,o,n),w]:f(s,o,n)]}case"sum":case"min":case"max":{let o=O(r(0),e,n),s=r(1),p=s.t==="lit"&&typeof s.value=="string"?[L(n.fieldName(o,s.value))]:A(s)<9?[R,...f(s,o,n),w]:f(s,o,n);return[d(t.fn==="sum"?"total":t.fn==="min"?"least":"most"),...p,d("of"),...u(0)]}case"first":{let o=r(0);if(h(o,"all")){let s=o.args[0]?.value;if(typeof s=="string")return[L(`the ${n.noun(s)}`)]}return[d("first of"),...u(0)]}case"sort":return[...u(0),d("by"),...f(r(1),O(r(0),e,n),n)];case"len":return[d("length of"),...f(r(0),e,n)];case"lower":return f(r(0),e,n);case"contains":case"startsWith":return[...f(r(0),e,n),d(t.fn==="contains"?"contains":"starts with"),...j(r(1),e,n,E(r(0),e,n))];case"today":return[P("today")];case"now":return[P("now")];case"date":return W(r(0))&&typeof r(0).value=="string"?[P(G(String(r(0).value)))]:f(r(0),e,n);case"days":case"hours":{let o=t.fn,[s,p]=[r(0),r(1)];return h(p,"today")||h(p,"now")?[d(`${o} since`),...f(s,e,n)]:h(s,"today")||h(s,"now")?[d(`${o} until`),...f(p,e,n)]:[d(`${o} from`),...f(s,e,n),d("to"),...f(p,e,n)]}case"if":return[R,...f(r(1),e,n),d("if"),...f(r(0),e,n),d(","),d("else"),...f(r(2),e,n),w];case"either":return t.args.flatMap((o,s)=>s===0?f(o,e,n):[d(","),d("else"),...f(o,e,n)]);default:return[d(t.fn),R,...t.args.flatMap((o,s)=>s===0?f(o,e,n):[d(","),...f(o,e,n)]),w]}}function U(t,e){let n=dt(e),r=t.over==="graph"?null:t.over;return J({...r===null?{}:{kind:r},parts:f(t.require,r,n),...t.when?{when:f(t.when,r,n)}:{}})}function Z(t,e,n){let r=dt(e),a=t.over==="graph"?null:t.over,u=n.subject,o=l=>{try{return q(l,{...n,budget:2e3})}catch{return}},s=(l,m)=>{let g=j(l,a,r,m);if(l.t==="lit"||l.t==="list"||h(l,"today")||h(l,"now")||h(l,"date"))return g;let i=o(l);if(i===void 0)return g;let c=E(l,a,r),y=r.valueWords(i,c?{...c,format:r.formatOf(c.kind,c.key)??(m?r.formatOf(m.kind,m.key):void 0)}:m);return i instanceof M?[...g,d(":"),y]:[...g,y]},p=l=>{if(l.t==="binary"&&l.op==="&&"){let m=[];m.push(...C(l,"&&"));let g=m.filter(i=>o(i)!==!0);return(g.length>0?g:m).flatMap((i,c)=>[...c>0?[d("and")]:[],...A(i)<=2?[R,...p(i),w]:p(i)])}if(l.t==="binary"&&l.op==="||"){let m=B(l);if(m){let i=E(m.subject,a,r);return[...s(m.subject),b("\u2209","is not one of"),r.valueWords(m.values.map(c=>c.value),i)]}let g=[];return g.push(...C(l,"||")),g.flatMap((i,c)=>[...c>0?[d("and")]:[],...A(i)<=2?[R,...p(i),w]:p(i)])}if(l.t==="binary"&&l.op in K){if(W(l.right)&&typeof l.right.value=="boolean"&&(l.op==="=="||l.op==="!="))return l.op==="=="===l.right.value?I(l.left,a,r):f(l.left,a,r);let m=z[l.op],[g,i]=K[m],c=E(l.left,a,r),y=E(l.right,a,r);if(W(l.right)&&l.right.value===null)return[...m==="=="?j(l.left,a,r,y):s(l.left,y),b(g,i),N];let S=m==="=="&&(W(l.right)||W(l.left));return[...S?j(l.left,a,r,y):s(l.left,y),b(g,i),...S?j(l.right,a,r,c):s(l.right,c)]}if(l.t==="binary"&&l.op==="in")return[...s(l.left),b("\u2209","is not one of"),...j(l.right,a,r,E(l.left,a,r))];if(l.t==="unary"&&l.op==="!"){let m=l.operand;return ct(m)?p({...m,op:z[m.op]}):h(m,"present")||h(m,"exists")?[...s(m.args[0]),b("\u2260","is not"),N]:m.t==="ident"?f(m,a,r):[d("not"),R,...I(m,a,r),w]}if(h(l,"present")||h(l,"exists"))return[...f(l.args[0],a,r),b("=","is"),N];if(h(l,"some"))return[...f(l,a,r).slice(1),b("=","is"),N];if(h(l,"every")&&l.args.length===2){let m=o(l.args[0]);if(m instanceof M){let g=m.nodes.filter(i=>{try{return q(l.args[1],{...n,subject:i,budget:2e3})!==!0}catch{return!0}});return[...f(l,a,r),d(","),d("not"),r.valueWords(new M(g))]}}return l.t==="ident"?[d("not"),L(r.fieldName(a,l.name))]:[d("not"),R,...f(l,a,r),w]},x;try{x=p(t.require)}catch{x=[d("not"),R,...f(t.require,a,r),w]}return J({...a===null?{}:{kind:a},parts:x,...u?{record:T(e.schema.tryDefinition(u.kind),u)}:{}})}function mt(t){let e=new Map;for(let n of t??[])n.expr?.t==="ident"&&n.format&&(n.format==="money"||n.format==="percent"||n.format==="date")&&e.set(n.expr.name,n.format);return e}function vt(t){return(e,n)=>{let r=t[e]?.fields?.[n],a=r?.format??(r?.type==="date"?"date":void 0);return a||r?.unit?{...a?{format:a}:{},...r?.unit?{unit:r.unit}:{}}:void 0}}function gt(t,e){return{schema:e,said:mt(t.says),...t.declared?{formatOf:vt(t.declared)}:{},...t.money?{money:t.money}:{}}}function qt(t,e){return t.shape?U(t.shape,gt(t.shape,e)):void 0}var yt=new WeakMap;function Ot(t,e){let n=new Map(t.allInvariants().map(r=>[r.name,r]));return e.map(r=>{let a=Lt(r),u=n.get(a.invariant)?.shape;if(!u||a.status&&a.status!=="violated")return a;let o=a.subjectId?t.graph.getNode(a.subjectId):void 0;if(u.over!=="graph"&&!o)return a;let s=u.kinds;s||(s=yt.get(t.schema),s||yt.set(t.schema,s=it(t.schema)));try{let p=u.today?.()??t.today?.()??new Date().toISOString().slice(0,10),x=Z(u,gt(u,t.schema),{graph:t.graph,subject:o??null,kinds:s,today:p});return{...a,line:x,...u.says?{}:{message:`${a.message} \u2014 ${x.text}`}}}catch{return a}})}function Et(){et((t,e,n)=>Ot({graph:t,schema:t.schema,allInvariants:()=>e},n)),rt(Pt)}function Pt(t,e,n,r){let a=e.graph,u=nt.from(t.schema,a.snapshot(),{validate:!1});for(let x of n?[...r].reverse().map(tt):r)try{u.applyPrimitives([x],{restoring:!0})}catch{}let o=x=>t.violations(void 0,x),s=o(n?u:a),p=o(n?a:u);return{...ot(t.allInvariants(),s,p),violationsAfter:p}}function Lt(t){if(!t.line)return t;let{line:e,...n}=t,r=` \u2014 ${e.text}`;return n.message.endsWith(r)?{...n,message:n.message.slice(0,-r.length)}:n}Et();export{Z as brokenLineOf,Et as judgeWithLines,Pt as judgedForASeat,bt as problemWords,qt as ruleLine,U as ruleLineOf,lt as ruleLineWords,_ as ruleSpacing,xt as ruleSpoken,ht as ruleText,Lt as unlined,Ot as withLines};
@@ -1 +0,0 @@
1
- import{j as n}from"./chunk.VTBAKTFP.js";import"./chunk.7U7Q3HIS.js";import"./chunk.6O67NOZR.js";import"./chunk.WWRWXFYR.js";import{a as p}from"./chunk.ISAMJ7AK.js";import"./chunk.54NSG7BX.js";import"./chunk.6KJSFIO7.js";import"./chunk.UM5IPM22.js";import"./chunk.6XBLDV4A.js";import"./chunk.WOTNMTIY.js";import"./chunk.HAQ4KHRY.js";import"./chunk.PRXKRG6O.js";import"./chunk.AHDOKM4O.js";import"./chunk.TDW6QEG4.js";import"./chunk.LW7KV5SL.js";import"./chunk.2VX6H2LL.js";import"./chunk.ZQ4HFIIS.js";import{b as m}from"./chunk.MRK6QJV5.js";import{b as t}from"./chunk.AJZBJBMO.js";var i=t(m(),1),a=new WeakMap;function l(o){let e=a.get(o);if(!e){let r=p(o);e=c=>c.mode==="fullscreen"?(0,i.jsx)(n,{blocks:r,slot:"home",heading:2,firstHeading:1}):(0,i.jsx)(n,{blocks:r,slot:"home",heading:3,firstHeading:2}),a.set(o,e)}return e}export{l as homeView};
@@ -1 +0,0 @@
1
- import{a as D}from"./chunk.TWGB347L.js";import{a as O,c as V,f as q,g as K,k as z,l as W,m as U}from"./chunk.AKOC43TV.js";import{c as j}from"./chunk.D3CYTXNZ.js";import{e as _,g as J,i as Q}from"./chunk.MYCTNK6D.js";import{ca as T,ea as $,ma as G,ta as I}from"./chunk.2VX6H2LL.js";import{Fb as H,eb as P,ob as L,pb as M}from"./chunk.ZQ4HFIIS.js";import{a as ne,b as N}from"./chunk.MRK6QJV5.js";import{b as A}from"./chunk.AJZBJBMO.js";var o=A(ne(),1);function te(e){let t=[e?.typography?.body,e?.typography?.display,e?.typography?.mono],n=[];for(let a of t){let r=a?.split(",")[0]?.trim().replace(/^["']|["']$/g,"");!r||M(r)||r.toLowerCase()!==P.toLowerCase()&&(n.includes(r)||n.push(r))}return n}function X(e){let t=te(e);return t.length===0?null:`https://fonts.googleapis.com/css2?${t.map(a=>`family=${encodeURIComponent(a).replace(/%20/g,"+")}:wght@400;500;600;700`).join("&")}&display=swap`}var p=A(N(),1);function pe(e,t){let{app:n}=e;return(0,o.useMemo)(()=>{let a=J(t(n.schema,n.viewSpecs),n),r=e.views?G(a,e.views(n.schema,a)):a;return Q(r,n.schema,_(e.brand??n.brand,n.schema)),r},[e.views,n.schema,n.viewSpecs,n.lenses,n.pages,n.home])}function re(e,t){return new H({schema:e.schema,mutations:e.mutations??[],invariants:e.invariants??[],...t?{snapshot:t}:{},...e.policy?{policy:e.policy}:{},...e.intelligence?{intelligence:e.intelligence}:{}})}function Y(e){if(typeof document>"u")return e==="dark"?"dark":"light";let t=document.documentElement.dataset.theme;return t==="dark"||t==="light"?t:e==="dark"||e==="light"?e:typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function oe(e,t){let[n,a]=(0,o.useState)(()=>Y(t));return(0,o.useEffect)(()=>{if(!e||typeof document>"u")return;let r=()=>a(Y(t));r();let i=new MutationObserver(r);i.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});let u=typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)"):null;return u?.addEventListener?.("change",r),()=>{i.disconnect(),u?.removeEventListener?.("change",r)}},[e,t]),n}var R=e=>e?e.getBoundingClientRect().height:0;function ye(e,t,n){let a=(0,o.useRef)(n);a.current=n;let r=n!==void 0;(0,o.useLayoutEffect)(()=>{let i=e.current;if(!i||!r)return;let u=()=>{let l=[...i.children],g=l.find(c=>c.hasAttribute("data-graview-app-bar")),m=l.find(c=>c.hasAttribute("data-embed-content")),h=m?.querySelector("[data-embed-measure]")??null,d=l.find(c=>c.hasAttribute("data-graview-place-line"));return{strip:g,line:d,content:m,measure:h}},s=-1,y=()=>{let{strip:l,line:g,content:m,measure:h}=u(),d=Math.ceil(R(l)+R(g)+R(h||m));d!==s&&(s=d,a.current?.(d))};if(y(),typeof ResizeObserver>"u")return;let f=new ResizeObserver(y),w=()=>{f.disconnect();let{strip:l,line:g,content:m,measure:h}=u();for(let d of[i,l,g,m,h])d&&f.observe(d)};w();let v=new MutationObserver(()=>{w(),y()});return v.observe(i,{childList:!0}),()=>{f.disconnect(),v.disconnect()}},[e,t,r])}var fe=480,ae=0;function he(e){let{app:t,seed:n,scheme:a="auto",brand:r=t.brand,fonts:i=!0,height:u="100%",label:s}=e,y=(0,o.useRef)(null);I(y);let f=(0,o.useMemo)(()=>`graview-embed-${++ae}`,[]),w=(0,o.useMemo)(()=>e.store??e.remote?.store??re(t,n),[e.store,e.remote,t,n]),v=e.presence??e.remote?.presence,l=e.hostContext?.theme,g=oe(a==="auto"&&l===void 0,r?.scheme),m=a==="auto"?l??g:a,h=(0,o.useMemo)(()=>O(m,r,{scope:`.${f}`}),[m,r,f]);V(e.favicon?L(r):void 0),(0,o.useEffect)(()=>{if(!i||typeof document>"u")return;let c=X(r);if(!c||document.querySelector(`link[href="${c}"]`))return;let b=document.createElement("link");b.rel="stylesheet",b.href=c,document.head.appendChild(b)},[r,i]);let d=(0,o.useRef)(void 0);return(0,o.useLayoutEffect)(()=>{let c=y.current,b=d.current;if(d.current=s,!c||!s)return;let ee=S=>{let E=S.getAttribute("aria-label")??"",x=b&&b!==s?E.startsWith(`${b} \xB7 `)?E.slice(b.length+3):E===b?"":E:E;x===s&&(S.getAttribute("role")==="region"||S.tagName==="SECTION"&&!S.hasAttribute("role"))&&S.setAttribute("role","group");let B=x.startsWith(`${s} \xB7 `)||x===s?x:x?`${s} \xB7 ${x}`:s;B!==E&&S.setAttribute("aria-label",B)},k=()=>c.querySelectorAll("aside, nav, main, header, footer, section[aria-label]:not([role]), [role=region], [role=complementary], [role=navigation], [role=search]").forEach(S=>{S.hasAttribute("data-graview-named-by-lens")||ee(S)});k();let C=new MutationObserver(k);return C.observe(c,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["aria-label"]}),()=>C.disconnect()},[s]),{rootRef:y,scope:f,css:h,scheme:m,store:w,presence:v,brand:r,auto:u==="auto",height:u}}function ge({rootRef:e,board:t}){let n=(0,o.useCallback)(()=>e.current?.querySelector("[data-embed-content]")??e.current,[e]);return(0,p.jsx)(j,{board:t,anchor:n})}function be(e,t,n){return{brand:n,principal:e.principal,seats:e.seats,presence:t,people:e.people,memory:e.memory,presenceTtlMs:e.presenceTtlMs,onKeepLens:e.onKeepLens,ai:e.ai,app:e.app}}function Se({name:e,heading:t,faces:n,at:a,without:r,home:i,reach:u,standing:s,hostActions:y,keeping:f,onFind:w,switch:v}){let{brand:l,store:g,principal:m,views:h}=T();$();let d=r?.has("places")?[]:q({store:g,principal:m,views:h}),c=D();return(0,p.jsx)(z,{brand:l,name:e,description:l?.subtitle,heading:t,faces:n,home:i,places:d,current:a===null?null:K(d,a),reach:u,onFind:w,...v?{switch:v}:{},...n?{scenePlaces:c}:{},tools:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(U,{clean:s}),(0,p.jsx)(W,{...y?{hostActions:y}:{},...f?{keeping:f}:{}})]})})}var ve=e=>e===!1?2:Math.min(e+1,6);function we(e){let[t,n]=(0,o.useState)(e),a=(0,o.useRef)(void 0),r=(0,o.useRef)(void 0),i=(0,o.useMemo)(()=>({go:a,at:n,pending:r}),[]),u=(0,o.useCallback)(s=>{if(a.current){a.current(s);return}r.current=s,n(s)},[]);return{at:t,setAt:n,steering:i,steer:u}}function se(e){let t=typeof e=="object"&&e!==null?e.name:void 0;return{name:typeof t=="string"&&t.length>0?t:typeof e=="object"?"Error":typeof e}}var F=()=>typeof performance<"u"?performance.now():Date.now();function Ee(e,t){let n=(0,o.useRef)({onError:e,face:t});return n.current={onError:e,face:t},(0,o.useCallback)((a,r)=>n.current.onError?.(se(a),{module:r.module,face:n.current.face}),[])}function xe(e,t){let n=(0,o.useRef)(null);n.current===null&&(n.current=F());let a=(0,o.useRef)({onReady:e,face:t});a.current={onReady:e,face:t};let r=(0,o.useRef)(!1);return(0,o.useCallback)(i=>{r.current||(r.current=!0,a.current.onReady?.({ms:Math.max(0,F()-(n.current??F())),face:i}))},[])}var Z=class extends o.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(t,n){console.error(`[graview] ${this.props.module} threw while rendering`,t,n.componentStack),this.props.report(t,{module:this.props.module})}render(){return this.state.failed?(0,p.jsxs)("div",{role:"alert","data-graview-face-error":this.props.module,...this.props.content?{"data-embed-content":""}:{},style:this.props.content?{flex:"1 1 auto",display:"grid",alignContent:"center",justifyItems:"center",gap:8,padding:24,background:"var(--graview-ground)",color:"var(--graview-ink)",fontSize:"0.9375rem"}:{display:"inline-flex",alignItems:"center",gap:6,fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:[(0,p.jsx)("span",{children:this.props.content?"This part of the app could not draw.":"Could not draw."}),(0,p.jsx)("button",{type:"button",onClick:()=>this.setState({failed:!1}),style:{padding:"3px 11px",fontSize:"0.8125rem"},children:"Try again"})]}):this.props.children}};export{pe as a,re as b,ye as c,fe as d,he as e,ge as f,be as g,Se as h,ve as i,we as j,Ee as k,xe as l,Z as m};