graview 0.1.25 → 0.1.26
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.
- package/dist/preview/chunk.24X6LFD3.js +6 -0
- package/dist/preview/{chunk.JIXW4WIO.js → chunk.2GFB5FOK.js} +1 -1
- package/dist/preview/chunk.3RT463XY.js +1 -0
- package/dist/preview/{chunk.UOYH2DFX.js → chunk.4INXWGIT.js} +2 -2
- package/dist/preview/{chunk.B57EIGTS.js → chunk.4MAYBFPU.js} +1 -1
- package/dist/preview/chunk.4YY54TMR.js +1 -0
- package/dist/preview/chunk.564EIRAT.js +1 -0
- package/dist/preview/chunk.5CXMUC6R.js +16 -0
- package/dist/preview/{chunk.ORJ3T4IW.js → chunk.6GJF3F7L.js} +1 -1
- package/dist/preview/chunk.6LJ66MB7.js +1 -0
- package/dist/preview/chunk.6MZBFEXW.js +1 -0
- package/dist/preview/chunk.6R4EI47C.js +1 -0
- package/dist/preview/chunk.7OOKA2DK.js +1 -0
- package/dist/preview/chunk.7ZJPJARU.js +1 -0
- package/dist/preview/{chunk.S24R4MRK.js → chunk.AAVCTGAE.js} +3 -3
- package/dist/preview/chunk.AKWBAWQF.js +1 -0
- package/dist/preview/chunk.BK2MJOUN.js +1 -0
- package/dist/preview/chunk.CL7GGNEK.js +1 -0
- package/dist/preview/{chunk.PY42PBMB.js → chunk.D3XF643V.js} +1 -1
- package/dist/preview/{chunk.DEZEXD24.js → chunk.DRIWJRQW.js} +1 -1
- package/dist/preview/chunk.ECG7RM6L.js +1 -0
- package/dist/preview/chunk.ECRZZ3U4.js +1 -0
- package/dist/preview/chunk.HFFEOCYY.js +107 -0
- package/dist/preview/chunk.I5U42VDK.js +3 -0
- package/dist/preview/chunk.IQLDOIWD.js +1 -0
- package/dist/preview/{chunk.DSZ3I557.js → chunk.JIWB6VGT.js} +1 -1
- package/dist/preview/{chunk.YZZGD5OY.js → chunk.KSEKVHJJ.js} +1 -1
- package/dist/preview/chunk.KXWRS6LY.js +1 -0
- package/dist/preview/chunk.LCFCU3I3.js +1 -0
- package/dist/preview/chunk.LEVR7WLB.js +1 -0
- package/dist/preview/{chunk.HQX5FGYT.js → chunk.LHIYFAN5.js} +2 -2
- package/dist/preview/chunk.LLUZMOBZ.js +1 -0
- package/dist/preview/{chunk.6OBXKKB5.js → chunk.LUUT2ZWF.js} +3 -3
- package/dist/preview/chunk.MLQQR57X.js +1 -0
- package/dist/preview/chunk.NIEQZOHX.js +1 -0
- package/dist/preview/{chunk.JCZH55RX.js → chunk.NLFLFIDS.js} +1 -1
- package/dist/preview/{chunk.6DU4XN2F.js → chunk.NQP3DWME.js} +1 -1
- package/dist/preview/{chunk.6UL2JUEH.js → chunk.OBGG4SYF.js} +1 -1
- package/dist/preview/chunk.OBQ4DIFO.js +1 -0
- package/dist/preview/chunk.P7YN4Z3K.js +8 -0
- package/dist/preview/{chunk.SSOTDXRS.js → chunk.PKFL2AR4.js} +1 -1
- package/dist/preview/chunk.PQ2IIC27.js +1 -0
- package/dist/preview/chunk.QFJRXAU3.js +8 -0
- package/dist/preview/chunk.REODVRPZ.js +1 -0
- package/dist/preview/chunk.RH6VRP76.js +1 -0
- package/dist/preview/chunk.SVL6I37U.js +1 -0
- package/dist/preview/chunk.TAW67PZU.js +1 -0
- package/dist/preview/chunk.TUYKH4FG.js +1 -0
- package/dist/preview/chunk.UEEXBS2U.js +1 -0
- package/dist/preview/chunk.UUMXYMOX.js +19 -0
- package/dist/preview/chunk.VW7U4CT5.js +1 -0
- package/dist/preview/chunk.WWWZZAHE.js +1 -0
- package/dist/preview/chunk.XD4Q4FI2.js +1 -0
- package/dist/preview/chunk.XNYBOKLW.js +1 -0
- package/dist/preview/chunk.XOC5BRPU.js +1 -0
- package/dist/preview/chunk.XXNC2AFL.js +1 -0
- package/dist/preview/chunk.YIZ3DJO3.js +1 -0
- package/dist/preview/chunk.YOMW4MKD.js +1 -0
- package/dist/preview/chunk.YXQCEXZX.js +1 -0
- package/dist/preview/chunk.ZLPA5BAW.js +1 -0
- package/dist/preview/chunk.ZOWWWRYA.js +1 -0
- package/dist/preview/page.js +6 -6
- package/package.json +6 -6
- package/dist/preview/chunk.2AJMM7JG.js +0 -1
- package/dist/preview/chunk.2WFEFZAW.js +0 -1
- package/dist/preview/chunk.2YVXTTC2.js +0 -1
- package/dist/preview/chunk.6KJSFIO7.js +0 -1
- package/dist/preview/chunk.6WFN4C46.js +0 -107
- package/dist/preview/chunk.7BAUPTMY.js +0 -1
- package/dist/preview/chunk.A4SJ7EEY.js +0 -1
- package/dist/preview/chunk.ACKTGTOT.js +0 -1
- package/dist/preview/chunk.BJ2Y5F66.js +0 -1
- package/dist/preview/chunk.BYUQOV3O.js +0 -1
- package/dist/preview/chunk.C5N4RTPF.js +0 -1
- package/dist/preview/chunk.CFL2B2Z5.js +0 -1
- package/dist/preview/chunk.DJ72CUS7.js +0 -1
- package/dist/preview/chunk.EA4BZKPG.js +0 -1
- package/dist/preview/chunk.EKZWX6NG.js +0 -1
- package/dist/preview/chunk.F26676IW.js +0 -1
- package/dist/preview/chunk.F2KDFGHR.js +0 -1
- package/dist/preview/chunk.FWV4XAZA.js +0 -1
- package/dist/preview/chunk.G3BOZHKR.js +0 -1
- package/dist/preview/chunk.H4LHHT56.js +0 -8
- package/dist/preview/chunk.I5ELK6JF.js +0 -1
- package/dist/preview/chunk.I6T3FDQS.js +0 -1
- package/dist/preview/chunk.IB6PGEU7.js +0 -1
- package/dist/preview/chunk.JEMQBV6K.js +0 -1
- package/dist/preview/chunk.JW3E4SAC.js +0 -1
- package/dist/preview/chunk.KUTTVYOB.js +0 -16
- package/dist/preview/chunk.LHFEOEYY.js +0 -1
- package/dist/preview/chunk.MJ67MK4R.js +0 -1
- package/dist/preview/chunk.Q5WEOX3Q.js +0 -1
- package/dist/preview/chunk.QOYC424P.js +0 -3
- package/dist/preview/chunk.R6F3YMRK.js +0 -6
- package/dist/preview/chunk.RAE4M3KQ.js +0 -8
- package/dist/preview/chunk.RUFAVEXB.js +0 -1
- package/dist/preview/chunk.RVEMN5WU.js +0 -1
- package/dist/preview/chunk.S56LSUHV.js +0 -1
- package/dist/preview/chunk.T6KID3WO.js +0 -1
- package/dist/preview/chunk.TAOT74FR.js +0 -1
- package/dist/preview/chunk.TTODVIXW.js +0 -1
- package/dist/preview/chunk.U6BWYBPM.js +0 -19
- package/dist/preview/chunk.US4KIJSW.js +0 -1
- package/dist/preview/chunk.WX5CJ7PI.js +0 -1
- package/dist/preview/chunk.WXO3XUNW.js +0 -1
- package/dist/preview/chunk.ZJVIH6IF.js +0 -1
- package/dist/preview/chunk.ZRVDIVYY.js +0 -1
- package/dist/preview/chunk.ZV7ZFH2S.js +0 -1
- /package/dist/preview/{chunk.WWRWXFYR.js → chunk.WVUJXDXZ.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as je,j as Ve,l as Fe,m as Ie}from"./chunk.QFJRXAU3.js";import{a as Be}from"./chunk.6MZBFEXW.js";import{b as Ge,e as G,f as ve}from"./chunk.NIEQZOHX.js";import{b as qe}from"./chunk.3RT463XY.js";import{d as ge,e as We,f as ye,h as _e}from"./chunk.ZOWWWRYA.js";import{b as De}from"./chunk.LEVR7WLB.js";import{a as ze}from"./chunk.7ZJPJARU.js";import{B as Ee,D as Ne,F as He,S as Ke,T as Oe,V as oe,c as Le,da as q,i as I,k as W,l as _,q as j,qa as re,r as Re,x as Pe,y as Me}from"./chunk.SVL6I37U.js";import{O as $e,Oa as ne,Pa as me,Ra as Ae,Sa as Ce,U as Te,V as te}from"./chunk.P7YN4Z3K.js";import{a as U,b as ae}from"./chunk.MRK6QJV5.js";import{b as O}from"./chunk.AJZBJBMO.js";var Je=O(U(),1);function Qe(e,t){try{t.length===0?localStorage.removeItem(ge(e)):localStorage.setItem(ge(e),JSON.stringify(t))}catch{}}function ct(e,t){Qe(e,[...ye(e).filter(r=>r.title!==t.title),t])}function pt(e,t){Qe(e,ye(e).filter(r=>r.title!==t))}function ut(e,t){for(let r of e.places().filter(a=>a.title===t))e.forget?.(r.kind,r.as)}var ft=e=>e===!0?{written:!0}:typeof e=="object"&&e!==null?{written:e.kept===!0,...e.said?{said:e.said}:{}}:{written:!1},Ue=e=>({title:e.title,lens:e.lens,on:e.on,...e.bindings?{bindings:e.bindings}:{},...e.options?{options:e.options}:{}});function mt(e,t){let r=a=>t.some(s=>s.title===a||s.as===ne(a));if(!r(e))return e;for(let a=2;;a++)if(!r(`${e} ${a}`))return`${e} ${a}`}function Ye(e){let{store:t,views:r,brand:a,seatTalk:s,onKeepLens:y}=q(),k=(0,Je.useContext)(qe),S=We(a,t.schema),M=async c=>{let{edit:p}=c;if(c.written&&y)try{await y({op:"remove-lens",title:p.title,on:p.on})}catch{}pt(S,p.title),ut(r,p.title),k?.dismiss(`kept:${p.title}`),s.setTurns(g=>[...g.map(i=>i.kept&&i.kept.edit.title===p.title&&!i.kept.taken?{...i,kept:{...i.kept,taken:!0}}:i),{role:"seat",text:`Took \u201C${p.title}\u201D back out of the places.`}]);let l=te(t.schema,p.on);e({to:"kind",kind:p.on,title:l,address:me(t.schema,p.on),said:`Went to ${l}.`})};return{keep:async c=>{let p=mt(c.edit.title,r.places()),l={...c.edit,title:p},g=!1,i;if(y)try{({written:g,said:i}=ft(await y(l)))}catch{g=!1}g||ct(S,Ue(l)),_e(r,t.schema,[Ue(l)]);let f=r.places(),h=f.find(w=>w.title===p),x=i??(g?`Kept \u201C${p}\u201D as a lens: it is in the places now.`:y?`Kept \u201C${p}\u201D as your own lens. Ask the owner to keep it for everyone.`:`Kept \u201C${p}\u201D as your own lens.`),T={edit:l,written:g};s.setDraft(null),s.setTurns(w=>[...w,{role:"seat",text:x,kept:T}]),s.get().open||k?.notify({kind:"toast",id:`kept:${p}`,sentence:x,timeout:1e4,action:{label:"Take back",onSelect:()=>void M(T)}}),h&&e({to:"picture",kind:h.kind,as:h.as,title:p,address:Ae(h.as,Ce(h,f)?me(t.schema,h.kind).slice(1):void 0),said:`Went to ${p}.`})},takeBack:M}}var Ze=O(U(),1);function gt(e,t){switch(t.to){case"place":return{view:Le("#")};case"picture":return{view:j(He(W(e,"filter",null),t.kind,t.as),[])};case"kind":{let r=Re(_({...I(e,Ee(t.kind)),relation:null},!1),!0);return{view:j(W(W(r,"view",null),"filter",t.filter??null),[])}}case"record":return{view:j(I(_(W(W(e,"view",null),"filter",null),!1),t.id),[t.id])};case"problems":return{pane:"problems"}}}function yt(e){let t=typeof document>"u"?null:document.querySelector('[data-testid="standing"]');t&&t.getAttribute("aria-expanded")==="true"!==e&&t.click()}function Xe(){let{setView:e,seatTalk:t}=q();return(0,Ze.useCallback)(r=>{t.get().draft&&t.setDraft(null),yt(r.to==="problems"),r.to!=="problems"&&e(a=>{let s=gt(a,r);return"view"in s?s.view:a})},[e,t])}var se=O(U(),1),vt=220;function ht(e,t){if(!e||!t||typeof document>"u")return null;let r=e.getBoundingClientRect(),a=document.elementFromPoint(r.left+t.x,r.top+t.y),s=a?.closest("[data-graview-pick]")?.getAttribute("data-graview-pick");return s||(a?.closest("[data-graview-view]")?.getAttribute("data-graview-view")??null)}function et({hover:e=!0}={}){let{store:t,view:r,views:a,pointer:s}=q(),{selection:y}=re(),[k,S]=(0,se.useState)(null);(0,se.useEffect)(()=>{if(!e)return;let l=null,g=!1,i=()=>typeof document<"u"&&document.querySelector("[data-graview-reach]")!==null?document.querySelector("[data-graview-settled]")===null:!1,f=()=>{if(l&&clearTimeout(l),g)return;let w=s.snapshot();if(!w){S(R=>R===null?R:null);return}l=setTimeout(()=>{if(g||i()){f();return}let R=typeof document>"u"?null:document.querySelector("[data-graview-stage]"),C=ht(R,w);S(P=>P===C?P:C)},vt)},h=()=>{g=!0,l&&clearTimeout(l)},x=()=>{g=!1,f()},T=s.subscribe(f);return document.addEventListener("pointerdown",h,!0),document.addEventListener("pointerup",x,!0),document.addEventListener("pointercancel",x,!0),f(),()=>{T(),document.removeEventListener("pointerdown",h,!0),document.removeEventListener("pointerup",x,!0),document.removeEventListener("pointercancel",x,!0),l&&clearTimeout(l)}},[s,e]);let M=l=>{let g=t.graph.getNode(l);if(g)return $e(t.schema.tryDefinition(g.kind),g);let i=je(l,t.schema);if(i)return i;let f=Me(l);if(f)return te(t.schema,f);let h=Ne(l);if(h.length>0){let x=h.map(w=>Te(t.schema,w)),T=x.length===1?x[0]:`${x.slice(0,-1).join(", ")} and ${x.at(-1)}`;return T.charAt(0).toUpperCase()+T.slice(1)}return null},E=y[y.length-1];if(E!==void 0){let l=M(E);if(l)return{id:E,name:y.length>1?`${l} and ${y.length-1} more`:l,because:"selection"}}if(k!=null){let l=M(k);if(l)return{id:k,name:l,because:"hover"}}let c=r.within?.view,p=c?a.places().find(l=>l.as===c||ne(l.title)===c):void 0;if(p)return{id:null,name:p.title,because:"place"};if(r.focusId){let l=M(r.focusId);if(l)return{id:r.focusId,name:l,because:"place"}}return{id:null,name:"the whole thing",because:"place"}}var L=O(U(),1);var D=O(U(),1),$=O(ae(),1),B=(e,t)=>`${e}:${t}`;function tt({answer:e,onReply:t,talk:r}){let[a]=(0,D.useState)(()=>Oe(null)),s=r??a,{turns:y,outcomes:k,busy:S}=oe(s),M=(0,D.useCallback)((c,p)=>s.settle(c,p),[s]);return{turns:y,outcomes:k,busy:S,send:async c=>{let p=c.trim();if(!p||s.get().busy)return;s.setBusy(!0);let l=s.get();s.setTurns(f=>[...f,{role:"person",text:p}]);let g=l.turns.map((f,h)=>{let x=(f.proposals??[]).flatMap((T,w)=>{let R=l.outcomes.get(B(h,w));return R?.state==="applied"?[R.said]:[]});return{role:f.role,text:x.length>0?`${f.text} [applied: ${x.join("; ")}]`:f.text}}),i;try{i=await e(p,{history:g})}catch(f){i={say:`That couldn't be answered: ${f instanceof Error?f.message:String(f)}`,proposals:[]}}s.setTurns(f=>[...f,{role:"seat",text:i.say,proposals:i.proposals,...i.questions?{questions:i.questions}:{},...i.picks?.length?{picks:i.picks}:{},...i.moves?.length?{moves:i.moves}:{},...i.offer?{offer:i.offer}:{},...i.unsure?{unsure:!0}:{},...i.via?{via:i.via}:{}}]),t?.(i),s.setBusy(!1)},settle:M}}var wt=e=>{let t=/^([\s\S]*?)\s*(\((?:[^()]|\([^()]*\))*\))\s*$/.exec(e);return t&&t[1]?{said:t[1],aside:t[2]}:{said:e}};function nt({turns:e,outcomes:t,busy:r,testId:a,empty:s,minHeight:y=64,maxHeight:k="min(46cqh, 400px)",renderProposal:S,renderAfter:M,renderSaid:E,ready:c=()=>!0,onApplyAll:p,applyAllLabel:l="Apply all"}){let g=(0,D.useRef)(null);return(0,D.useEffect)(()=>{g.current?.scrollTo?.({top:g.current.scrollHeight})},[e]),e.length===0&&s===null&&!r?null:(0,$.jsxs)("ol",{ref:g,style:{margin:0,padding:10,listStyle:"none",display:"grid",gap:8,alignContent:"start",maxHeight:k,minHeight:y,overflowY:"auto"},children:[e.length===0?s===null?null:(0,$.jsx)("li",{style:{fontSize:"0.8125rem",color:"var(--graview-ink-muted)",lineHeight:1.5},children:s}):null,e.map((i,f)=>{let h=i.proposals??[],x=h.filter((w,R)=>{let C=B(f,R),P=t.get(C);return P?.state!=="applied"&&P?.state!=="declined"&&c(w,C)}),T=wt(i.text);return(0,$.jsxs)("li",{style:{display:"grid",gap:6,justifyItems:i.role==="person"?"end":"start"},children:[i.role==="person"?(0,$.jsx)("p",{style:{margin:0,maxWidth:"85%",padding:"6px 10px",borderRadius:"12px 12px 4px 12px",fontSize:"0.875rem",lineHeight:1.45,background:"var(--graview-panel-muted)",color:"var(--graview-ink)"},children:i.text}):(0,$.jsxs)("p",{style:{margin:0,fontSize:"0.875rem",lineHeight:1.5,color:"var(--graview-ink)"},children:[E?E(i,T.said):T.said,T.aside?(0,$.jsx)("span",{style:{display:"block",marginTop:2,fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:T.aside}):null,i.via?(0,$.jsx)("span",{"data-testid":`${a}-answered-with-ai`,style:{display:"block",marginTop:2,fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:Ke}):null]}),M?.(i,f),h.map((w,R)=>{let C=B(f,R),P=t.get(C);return P?.state==="applied"||P?.state==="declined"?(0,$.jsx)(ie,{outcome:P,testId:a},C):(0,$.jsxs)("span",{style:{display:"grid",gap:4,justifySelf:"stretch",justifyItems:"start"},children:[S(w,{key:C,turn:f,at:R}),P?(0,$.jsx)(ie,{outcome:P,testId:a}):null]},C)}),p&&x.length>=2?(0,$.jsxs)("button",{type:"button","data-testid":`${a}-apply-all`,onClick:()=>p(f,h),title:"Take these in order; anything still missing is asked for",style:{fontSize:"0.8125rem",justifySelf:"start",fontWeight:600},children:[l," ",x.length]}):null]},f)}),r?(0,$.jsx)("li",{style:{fontSize:"0.8125rem",color:"var(--graview-ink-faint)"},children:"thinking\u2026"}):null]})}function ie({outcome:e,testId:t}){if(e.state==="refused")return(0,$.jsxs)("span",{"data-testid":`${t}-refused`,style:{fontSize:"0.8125rem",color:"var(--graview-warn)"},children:["Refused: ",e.error]});let r=e.state==="applied";return(0,$.jsxs)("span",{"data-testid":`${t}-${e.state}`,style:{fontSize:"0.8125rem",color:r?"var(--graview-ink-muted)":"var(--graview-ink-faint)"},children:[r?(0,$.jsx)("span",{"aria-hidden":"true",style:{color:"var(--graview-accent)"},children:"\u2713 "}):null,r?e.said:(0,$.jsx)("s",{children:e.said})]})}function ot({busy:e,placeholder:t,ariaLabel:r,testId:a,onSend:s}){let[y,k]=(0,D.useState)("");return(0,$.jsxs)("form",{onSubmit:S=>{S.preventDefault(),!(e||y.trim().length===0)&&(s(y),k(""))},style:{display:"flex",gap:6,padding:8,borderTop:"1px solid var(--graview-edge)"},children:[(0,$.jsx)("input",{value:y,onChange:S=>k(S.target.value),placeholder:t,"aria-label":r,"data-testid":`${a}-draft`,style:{flex:1,minWidth:0,font:"inherit",fontSize:"0.875rem",padding:"6px 9px",borderRadius:8,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",color:"var(--graview-ink)"}}),(0,$.jsx)("button",{type:"submit","data-testid":`${a}-send`,disabled:e||y.trim().length===0,style:{fontSize:"0.875rem"},children:"Send"})]})}var v=O(ae(),1),bt=/\b(?:board|kanban|timeline|calendar|gantt|who covers|covers what|coverage|floor plan|layout|draw|chart|(?:list|table) of|as an? (?:list|table|board|calendar|timeline|grid))\b/i,kt=/\b(?:group(?:ed)? by|split by|sort(?:ed)? by|order(?:ed)? by|only|call it|name it|as an? (?:board|kanban|calendar|timeline|list|table|cards|rows|grid|plan|layout)|show all|all of them|clear the filter|no filter)\b/i,St=e=>e.charAt(0).toLowerCase()+e.slice(1),xt=e=>e.to==="record"?e.label:e.to==="problems"?"problems":e.title;function $t(e,t,r){let a=[],s=e;for(let y of t){let k=xt(y),S=k?s.toLowerCase().indexOf(k.toLowerCase()):-1;S<0||(a.push(s.slice(0,S),r(y,s.slice(S,S+k.length))),s=s.slice(S+k.length))}return a.length===0?e:[...a,s]}function Qt({respond:e,onCall:t,onPick:r,testId:a="chat",empty:s,shared:y=!1,composer:k=!0,onMove:S,place:M,onDraft:E}){let{store:c,views:p,view:l,principal:g,setView:i,seatWho:f,noteSeat:h,session:x,ai:T,seatTalk:w,brand:R,app:C}=q(),P=Xe(),le=S??P,{takeBack:rt}=Ye(le),{selection:de}=re(),he=et(),we=f??"chat",z=(0,L.useMemo)(()=>({kind:"agent",id:we,session:x}),[we,x]),ce=(0,L.useRef)(void 0),V=(0,L.useMemo)(()=>Be(c,{author:{...z,...g.roles?{roles:g.roles}:{}},derive:()=>({pins:Ve()}),places:()=>p.places(),via:()=>ce.current,...C?{app:C}:{}}),[c,g,z,p,C]),st=(0,L.useMemo)(()=>e??Ie(T),[e,T]);(0,L.useEffect)(()=>t?V.onCall(t):void 0,[V,t]),De(V);let be=(0,L.useMemo)(()=>({name:R?.name??"app",schema:c.schema,...c.policy?{policy:c.policy}:{}}),[c,R]),it=async o=>{let d=w.get().draft,n=d!==null&&kt.test(o);if(!n&&!bt.test(o))return;let u=await import("./chunk.24X6LFD3.js"),b=e?void 0:Fe(T),m={app:be,sight:u.draftSight(be,Y),...b?{complete:b}:{},...d?{lastGood:d}:{}},A=n&&d?await u.refineDraft(d,o,m):await u.draftView(o,m);if(u.isDraftFailure(A)){let K=A.lastGood??d;return K?(w.setDraft(K,A.failed),E?.(),{say:`${A.failed} The last view stays.`,proposals:[],grounded:!0}):{say:A.failed,proposals:[],grounded:!0}}return w.setDraft(A,null),E?.(),{say:`Here is ${St(A.said)} Ask to change it, or keep it as a lens.`,proposals:[],grounded:!0}},N=tt({...y?{talk:w}:{},answer:async(o,d)=>{let n=await it(o);if(n)return n;let{placesFromViews:u}=await import("./chunk.LLUZMOBZ.js"),b=M??l.within?.view,m=p.arrangement?.(),A=c.today();return st(c,o,{...d,selection:he.id?[he.id]:de,principal:{...z,...g.roles?{roles:g.roles}:{}},places:u(c.schema,p.places(),m?{pages:m}:{}),...b?{place:b}:{},...A?{today:A}:{},...C?{app:C}:{}})},onReply:o=>{let d=o.moves?.[0];d&&le(d);let n=o.questions?.[0];h(n?{type:"asking",author:z,where:n.nodeId??null,say:`${n.nodeLabel?`${n.nodeLabel}: `:""}${n.asks}`,confidence:n.confidence}:{type:"said",author:z,say:o.say});let u=o.proposals.find(b=>!ue(b));if(u){let b=c.permits({name:u.mutation,args:{...u.args}},Y);b.ok||h({type:"refused",author:z,where:Se(u.mutation),say:b.refusal.message})}}}),{outcomes:Q,settle:pe}=N,ke=oe(w);(0,L.useEffect)(()=>{if(!y||ke.pending===null||N.busy)return;let o=w.takePending();o&&N.send(o)},[y,ke.pending,N.busy]);let Y={...z,...g.roles?{roles:g.roles}:{}},ue=o=>c.permits({name:o.mutation,args:{...o.args}},Y).ok,Se=o=>{let d=c.allMutations().find(n=>n.name===o)?.subject?.kinds;return Array.isArray(d)&&d[0]?Pe(d[0]):null},[H,Z]=(0,L.useState)(null),X=async(o,d)=>{let n=Ge(c,o),u=G(c,n),b=V.definitions.find(A=>A.act===n.mutation)?.name??n.mutation;ce.current=N.turns[Number(d.split(":")[0])]?.via;let m=await V.call(b,{...n.args}).finally(()=>{ce.current=void 0});return m.ok?(pe(d,{state:"applied",said:u}),!0):(pe(d,{state:"refused",error:m.error}),h({type:"refused",author:z,where:Se(n.mutation),say:m.error}),!1)},lt=async(o,d)=>{for(let[n,u]of d.entries()){let b=B(o,n);if(Q.get(b)?.state==="applied"||!ue(u))continue;let m=ve(c,u);if(m.length>0){Z({proposal:u,open:m,key:b});return}if(!await X(u,b))return}},ee=(0,L.useRef)(null),fe=(0,L.useRef)(null);(0,L.useLayoutEffect)(()=>{let o=fe.current;if(!o||o.isConnected||document.activeElement!==document.body)return;fe.current=null,(ee.current?.querySelector(`[data-testid="${a}-apply"]:not([disabled])`)??ee.current?.querySelector(`[data-testid="${a}-draft"]`)??ee.current?.closest("[data-testid='seat']")?.querySelector("[data-testid='seat-field']"))?.focus()});let dt=(o,d,n,u)=>{let b=c.permits({name:n.mutation,args:{...n.args}},Y);if(!b.ok)return(0,v.jsxs)("span",{"data-testid":`${a}-withheld`,style:{fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:[(0,v.jsx)("s",{children:G(c,n)})," \u2014 ",b.refusal.message]});let m=ve(c,n),A=(N.turns[o]?.proposals??[]).slice(0,d).filter((xe,F)=>Q.get(B(o,F))?.state!=="applied").find(xe=>m.some(F=>F.kinds&&typeof n.args[F.name]=="string"&&xe.args.label===n.args[F.name])),K=G(c,n);return(0,v.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"4px 10px"},children:[(0,v.jsxs)("span",{style:{fontSize:"0.875rem",color:"var(--graview-ink)"},title:n.why,children:[K,m.length>0&&!A?" \u2026":""]}),(0,v.jsxs)("span",{style:{display:"inline-flex",gap:6},children:[(0,v.jsx)("button",{type:"button","data-testid":`${a}-apply`,"data-graview-asks":m.length>0?m.length:void 0,disabled:A!==void 0,"aria-label":`Do it: ${K}`,onClick:()=>m.length>0?Z({proposal:n,open:m,key:u}):void X(n,u),title:A?`After \u201C${G(c,A)}\u201D`:m.length>0?`${K} \u2014 it asks for ${m.length===1?"one more thing":`${m.length} more things`}`:K,style:J,children:"Do it"}),(0,v.jsx)("button",{type:"button","data-testid":`${a}-decline`,"aria-label":`Not now: ${K}`,onClick:()=>pe(u,{state:"declined",said:K}),style:{...J,color:"var(--graview-ink-muted)"},children:"Not now"})]})]})};return(0,v.jsxs)("div",{"data-testid":`${a}-panel`,ref:ee,onFocus:o=>{fe.current=o.target},style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",alignContent:"start",gap:8,minWidth:0,minHeight:0},children:[N.turns.length===0?s??null:null,(0,v.jsx)(nt,{turns:N.turns,outcomes:Q,busy:N.busy,testId:a,minHeight:0,maxHeight:"none",empty:s!==void 0?null:(0,v.jsxs)(v.Fragment,{children:["Ask what's wrong, ask about anything by name, or say a change in its own words.",de.length>0?" \u201CThis\u201D means what you have selected.":""]}),renderProposal:(o,{key:d,turn:n,at:u})=>dt(n,u,o,d),ready:o=>ue(o),onApplyAll:(o,d)=>void lt(o,d),applyAllLabel:"Do all",renderSaid:(o,d)=>o.moves?.length?$t(d,o.moves,(n,u)=>(0,v.jsx)("button",{type:"button","data-testid":`${a}-went`,title:`Go to ${u}`,onClick:()=>le(n),style:{...at,fontSize:"inherit"},children:u},`${n.address}:${u}`)):d,renderAfter:(o,d)=>[...o.offer?[(0,v.jsx)("button",{type:"button","data-testid":`${a}-offer`,onClick:()=>w.ask(`a list of ${o.offer.draft}`),style:{...J,justifySelf:"start"},children:o.offer.label},`${d}:offer`)]:[],...o.kept&&!o.kept.taken?[(0,v.jsx)("button",{type:"button","data-testid":`${a}-take-back`,onClick:()=>void rt(o.kept),style:{...J,justifySelf:"start"},children:"Take back"},`${d}:take-back`)]:[],...o.picks?.length?[(0,v.jsx)("p",{"data-testid":`${a}-picks`,style:{margin:0,display:"flex",flexWrap:"wrap",gap:"2px 12px"},children:o.picks.map(n=>(0,v.jsx)("button",{type:"button","data-testid":`${a}-pick`,"data-chat-pick":n.id,title:n.why.field==="label"?`Go to ${n.label}`:`${n.why.reading}: ${n.why.fragment}`,onClick:()=>r?r(n.id):i(u=>j(I(_(u,!1),n.id),[n.id])),style:at,children:n.label},n.id))},`${d}:picks`)]:[],...(o.questions??[]).map(n=>{let u=`${d}:q:${n.id}`,b=Q.get(u);return(0,v.jsxs)("div",{"data-testid":`${a}-question`,"data-chat-question-node":n.nodeId,style:{display:"grid",gap:4,justifySelf:"start"},children:[(0,v.jsxs)("span",{style:{fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:[n.nodeLabel?(0,v.jsxs)("strong",{children:[n.nodeLabel,": "]}):null,n.asks,n.because==="split"?" (it could be either)":" (it was not sure)"]}),(0,v.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:n.options.map(m=>(0,v.jsxs)("button",{type:"button","data-testid":`${a}-option`,disabled:!m.call,title:m.call?m.call.why??"Take this answer":"Nothing to do for this answer",onClick:()=>m.call?void X(m.call,u):void 0,style:J,children:[m.value," ",Math.round(m.probability*100),"%"]},m.value))}),b?(0,v.jsx)(ie,{outcome:b,testId:a}):null]},n.id)})]}),H?(0,v.jsx)("div",{"data-testid":`${a}-asking`,children:(0,v.jsx)(ze,{affordance:{id:`chat:${H.proposal.mutation}`,mutation:H.proposal.mutation,label:G(c,H.proposal),provider:"llm",why:H.proposal.why??"Suggested in the conversation.",nodeIds:[],args:H.proposal.args,open:H.open,score:0},onApply:o=>{let d={...H.proposal,args:{...H.proposal.args,...o}};Z(null),X(d,H.key)},onCancel:()=>Z(null)})}):null,k?(0,v.jsx)(ot,{busy:N.busy,placeholder:de.length>0?"Ask about this\u2026":"Ask, or say a change\u2026",ariaLabel:"Ask",testId:a,onSend:o=>y?w.ask(o):void N.send(o)}):null]})}var J={font:"inherit",fontSize:"0.8125rem",minHeight:26,padding:"0 9px",borderRadius:6,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",boxShadow:"none",color:"var(--graview-ink)",cursor:"pointer"},at={font:"inherit",fontSize:"0.875rem",minHeight:24,padding:0,border:0,borderRadius:2,background:"transparent",boxShadow:"none",color:"var(--graview-accent)",textDecoration:"underline",textUnderlineOffset:3,textAlign:"start",cursor:"pointer"};export{Ye as a,yt as b,Xe as c,et as d,Qt as e,J as f,at as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as c,b as d,c as e,d as f,e as g,f as h,g as i}from"./chunk.UUMXYMOX.js";import{a,b}from"./chunk.D3XF643V.js";import"./chunk.NLFLFIDS.js";import"./chunk.6LJ66MB7.js";import"./chunk.SVL6I37U.js";import"./chunk.P7YN4Z3K.js";import"./chunk.MRK6QJV5.js";import"./chunk.AJZBJBMO.js";export{c as ARRANGE_NARROW,h as ArrangeBar,i as arrangementCaption,a as arrangementOf,f as directionWords,e as inSentence,g as preloadArrangeLists,d as sayCondition,b as withArrangement};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as f,d as y}from"./chunk.6LJ66MB7.js";import{_ as m,za as h}from"./chunk.SVL6I37U.js";import{a as k,b as u}from"./chunk.MRK6QJV5.js";import{b as g}from"./chunk.AJZBJBMO.js";var p=g(k(),1);var n=g(u(),1);var w={default:{background:"var(--graview-panel, #ffffff)",color:"var(--graview-ink, #1a1a1a)"},muted:{background:"var(--graview-panel-muted, #f7f5f1)",color:"var(--graview-ink, #1a1a1a)"},warning:{background:"var(--graview-panel-warning, #fdf3ec)",color:"var(--graview-ink, #1a1a1a)"}},R={color:"var(--graview-ink-muted, #55514a)"},N={color:"var(--graview-ink-faint, #625d55)"};function z(e){let[i,t]=(0,p.useState)(!1);return(0,p.useEffect)(()=>{let a=e.current;if(!a||typeof ResizeObserver>"u")return;let o=()=>t(a.scrollHeight>a.clientHeight+1||a.scrollWidth>a.clientWidth+1);o();let d=new ResizeObserver(o);d.observe(a);for(let l of a.children)d.observe(l);return()=>d.disconnect()}),i}function C({level:e,style:i,children:t}){if(e===void 0)return(0,n.jsx)("strong",{style:i,children:t});let a=`h${e}`;return(0,n.jsx)(a,{style:{margin:0,...i},children:t})}function T({title:e,subtitle:i,meta:t,selected:a,tone:o="default",children:d,style:l,fit:s=!1,variant:b,heading:S}){let c=(0,p.useRef)(null),v=z(c),P=m(),r=(b??(P==="fullscreen"?"page":"card"))==="page";return(0,n.jsxs)("div",{"data-graview-primitive":"panel","data-graview-variant":r?"page":"card","data-selected":a||void 0,style:{display:"flex",flexDirection:"column",gap:r?12:"var(--graview-gap, 7px)",height:r||s?"auto":"100%",maxHeight:r?"none":"100%",padding:r?0:"var(--graview-pad, 15px)",boxSizing:"border-box",borderRadius:r?0:"var(--graview-radius, 12px)",border:r?"none":`1px solid ${a?"var(--graview-accent, #2f6f5e)":"var(--graview-edge, #e4e0d8)"}`,boxShadow:r?"none":a?"0 0 0 1px var(--graview-accent-dim), var(--graview-lift-low)":"var(--graview-lift-low)",overflow:r?"visible":"hidden",...w[o],...r?{background:"transparent"}:{},"--graview-panel-bg":w[o].background,...l},children:[o==="warning"?(0,n.jsx)("span",{"data-graview-broken":"",style:y,children:"Implicated in a problem."}):null,e===void 0?null:(0,n.jsxs)("div",{style:{display:"flex",alignItems:"baseline",flexWrap:"wrap",gap:8,minWidth:0},children:[o==="warning"?(0,n.jsx)("span",{"aria-hidden":"true",title:"Implicated in a problem",style:{color:"var(--graview-warn)",flex:"0 0 auto"},children:"\u26A0"}):null,(0,n.jsx)(C,{level:S,style:{fontFamily:"var(--graview-font-display, inherit)",fontSize:r?"1.5625rem":"0.9375rem",lineHeight:r?1.15:1.25,fontWeight:r?600:560,letterSpacing:r?"-0.012em":"0.005em",minWidth:0,overflowWrap:"anywhere"},children:e}),t===void 0?null:(0,n.jsx)("span",{style:{marginLeft:"auto",fontSize:"0.75rem",letterSpacing:"0.08em",textTransform:"uppercase",minWidth:0,overflowWrap:"anywhere",...N},children:t})]}),i===void 0?null:(0,n.jsx)("div",{style:{fontSize:r?"0.90625rem":"0.8125rem",lineHeight:1.5,...R},children:i}),(0,n.jsx)("div",{ref:c,className:r?void 0:"graview-scroll",...v&&!r?{tabIndex:0,role:"region",...typeof e=="string"?{"aria-label":e}:{}}:{},style:{display:"flex",flexDirection:"column",gap:r?22:"var(--graview-gap, 7px)",flex:"1 1 auto",...r?{overflow:"visible"}:{}},"data-graview-overflowing":v&&!r?"":void 0,children:d})]})}function x({label:e,hue:i,selected:t,title:a,pickId:o,emphasis:d}){let l=typeof e=="string"?e:void 0,s=i===void 0?void 0:Math.round(i);return(0,n.jsxs)("span",{"data-graview-primitive":"chip","data-selected":t||void 0,"data-graview-pick":o,"data-graview-emphasis":d,title:a??l,style:{cursor:o?"pointer":void 0,display:"inline-flex",alignItems:"center",alignSelf:"flex-start",minHeight:24,boxSizing:"border-box",padding:"3px 9px",borderRadius:6,fontSize:"0.8125rem",lineHeight:1.5,whiteSpace:"nowrap",maxWidth:"min(28ch, 100%)",overflow:"hidden",letterSpacing:"0.01em",border:`1px solid ${t?"var(--graview-accent)":s===void 0?"var(--graview-edge)":`hsl(${s} 55% var(--graview-tint-lightness) / 0.45)`}`,background:s===void 0?"var(--graview-panel-muted)":`hsl(${s} 55% var(--graview-tint-lightness) / calc(var(--graview-tint-alpha) * 0.65))`,color:"var(--graview-ink, #1a1a1a)",boxShadow:t?"0 0 14px -4px var(--graview-accent)":void 0},children:[s===void 0?null:(0,n.jsx)("span",{"aria-hidden":"true",style:{width:9,height:6,clipPath:"polygon(50% 0, 100% 50%, 50% 100%, 0 50%)",flex:"0 0 auto",marginRight:6,background:`hsl(${s} 55% var(--graview-tint-lightness) / 0.9)`}}),(0,n.jsx)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e})]})}function H({items:e,max:i=8,selectedIds:t=[],pick:a=!1}){let o=e.slice(0,i),d=e.length-o.length;return(0,n.jsxs)("div",{"data-graview-primitive":"roster",style:{display:"flex",flexWrap:"wrap",gap:6,alignContent:"flex-start"},children:[o.map(l=>(0,n.jsx)(x,{label:l.label,...l.hue===void 0?{}:{hue:l.hue},...a?{pickId:l.id}:{},...l.emphasis===void 0?{}:{emphasis:l.emphasis},selected:t.includes(l.id)},l.id)),d>0?(0,n.jsx)(x,{label:`+${d} more`}):null]})}function L({label:e,count:i,items:t,onExpand:a,flagged:o}){return(0,n.jsx)(T,{title:e,meta:o?`\u26A0 ${i}`:i,tone:o?"warning":"muted",style:a?{cursor:"zoom-in"}:void 0,children:t&&t.length>0?(0,n.jsx)(H,{items:t,max:6,pick:!0}):null})}var W=h(f(()=>import("./chunk.ECG7RM6L.js"))),O=W.part((e,i)=>e.drawFiles(i),{quiet:!0});export{T as a,x as b,H as c,L as d,O as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as s,J as k,wa as x,ya as p,za as w}from"./chunk.P7YN4Z3K.js";var j=e=>e.safeParse?.(void 0).success??!1,O=e=>p(e).shape,m=e=>{let r=p(e);if(s(r)?.type!=="literal")return;let o=s(r)?.values;return o&&o.length===1&&typeof o[0]=="string"?o[0]:void 0};function u(e,r){let o=j(r),n=p(r),i=s(n)?.type,g=x(r);if(g)return{control:"node",name:e,optional:o,kinds:g};if(i==="boolean")return{control:"boolean",name:e,optional:o};let b=k(n);if(b)return{control:"file",name:e,optional:o,...b==="image"?{image:!0}:{}};if(i==="object"){let a=n.shape??{};return{control:"group",name:e,optional:o,fields:Object.entries(a).map(([d,c])=>u(d,c))}}if(i==="union"){let a=s(n)?.options??[],d=a.map(l=>O(l));if(d.every(l=>l!==void 0)){let l=Object.keys(d[0]??{}).find(F=>d.every(f=>m(f?.[F])!==void 0));if(l)return{control:"variant",name:e,optional:o,tag:l,options:a.map((F,f)=>({value:m(d[f]?.[l])??"",fields:Object.entries(d[f]??{}).filter(([y])=>y!==l).map(([y,v])=>u(y,v))}))}}let c=a.map(l=>m(l));return c.every(l=>l!==void 0)?{control:"choice",name:e,optional:o,options:c}:{control:"opaque",name:e,optional:o}}if(i==="array"){let a=s(n)?.element;return a!==void 0?{control:"list",name:e,optional:o,item:u(e,a)}:{control:"opaque",name:e,optional:o}}let t=w(r);return t.type==="text"?{control:"text",name:e,optional:o,...t.long?{long:!0}:{}}:t.type==="date"?{control:"date",name:e,optional:o,...t.time?{time:!0}:{}}:t.type==="number"?{control:"number",name:e,optional:o,...t.min===void 0?{}:{min:t.min},...t.max===void 0?{}:{max:t.max},...t.step===void 0?{}:{step:t.step}}:t.type==="choice"?{control:"choice",name:e,optional:o,options:t.options}:{control:"opaque",name:e,optional:o}}function R(e){let r=e.shape;return r?Object.entries(r).map(([o,n])=>u(o,n)):[]}function h(e,r){let o={...r};for(let n of e){let i=r[n.name];i===void 0&&!n.optional&&(n.control==="list"||n.control==="boolean")&&(o[n.name]=n.control==="list"?[]:!1),n.control==="group"&&i!==void 0&&typeof i=="object"&&i!==null&&(o[n.name]=h(n.fields,i))}return o}export{R as a,h as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as U}from"./chunk.BK2MJOUN.js";import{a as T,c as K,f as W,g as D,k as _,l as j,m as X}from"./chunk.NQP3DWME.js";import{c as J}from"./chunk.3RT463XY.js";import{e as Q,g as Y,i as Z}from"./chunk.ZOWWWRYA.js";import{c as z}from"./chunk.6LJ66MB7.js";import{da as G,fa as I,na as V,ua as q}from"./chunk.SVL6I37U.js";import{Nb as N,mb as L,wb as M,xb as O}from"./chunk.P7YN4Z3K.js";import{a as ae,b as $}from"./chunk.MRK6QJV5.js";import{b as F}from"./chunk.AJZBJBMO.js";var o=F(ae(),1);function se(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||O(r)||r.toLowerCase()!==L.toLowerCase()&&(n.includes(r)||n.push(r))}return n}function ee(e){let t=se(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 u=F($(),1);function ge(e,t){let{app:n}=e;return(0,o.useMemo)(()=>{let a=Y(t(n.schema,n.viewSpecs),n),r=e.views?V(a,e.views(n.schema,a)):a;return Z(r,n.schema,Q(e.brand??n.brand,n.schema)),r},[e.views,n.schema,n.viewSpecs,n.lenses,n.pages,n.home])}function ie(e,t){return new N({schema:e.schema,mutations:e.mutations??[],invariants:e.invariants??[],...t?{snapshot:t}:{},...e.policy?{policy:e.policy}:{},...e.intelligence?{intelligence:e.intelligence}:{}})}function ne(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 ce(e,t){let[n,a]=(0,o.useState)(()=>ne(t));return(0,o.useEffect)(()=>{if(!e||typeof document>"u")return;let r=()=>a(ne(t));r();let i=new MutationObserver(r);i.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});let d=typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)"):null;return d?.addEventListener?.("change",r),()=>{i.disconnect(),d?.removeEventListener?.("change",r)}},[e,t]),n}var A=e=>e?e.getBoundingClientRect().height:0;function be(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 d=()=>{let l=[...i.children],b=l.find(v=>v.hasAttribute("data-graview-app-bar")),p=l.find(v=>v.hasAttribute("data-embed-content")),h=p?.querySelector("[data-embed-measure]")??null,c=l.find(v=>v.hasAttribute("data-graview-place-line"));return{strip:b,line:c,content:p,measure:h}},s=-1,f=()=>{let{strip:l,line:b,content:p,measure:h}=d(),c=Math.ceil(A(l)+A(b)+A(h||p));c!==s&&(s=c,a.current?.(c))};if(f(),typeof ResizeObserver>"u")return;let m=new ResizeObserver(f),E=()=>{m.disconnect();let{strip:l,line:b,content:p,measure:h}=d();for(let c of[i,l,b,p,h])c&&m.observe(c)};E();let g=new MutationObserver(()=>{E(),f()});return g.observe(i,{childList:!0}),()=>{m.disconnect(),g.disconnect()}},[e,t,r])}var ve=480,de=0;function Se(e){let{app:t,seed:n,scheme:a="auto",brand:r=t.brand,fonts:i=!0,height:d="100%",label:s}=e,f=(0,o.useRef)(null);q(f);let m=d==="viewport"?"100dvh":d,E=z(typeof m=="string"&&/vh\b/.test(m)),g=(0,o.useMemo)(()=>`graview-embed-${++de}`,[]),l=(0,o.useMemo)(()=>e.store??e.remote?.store??ie(t,n),[e.store,e.remote,t,n]),b=e.presence??e.remote?.presence,p=e.hostContext?.theme,h=ce(a==="auto"&&p===void 0,r?.scheme),c=a==="auto"?p??h:a,v=(0,o.useMemo)(()=>T(c,r,{scope:`.${g}`}),[c,r,g]);K(e.favicon?M(r):void 0),(0,o.useEffect)(()=>{if(!i||typeof document>"u")return;let w=ee(r);if(!w||document.querySelector(`link[href="${w}"]`))return;let y=document.createElement("link");y.rel="stylesheet",y.href=w,document.head.appendChild(y)},[r,i]);let C=(0,o.useRef)(void 0);(0,o.useLayoutEffect)(()=>{let w=f.current,y=C.current;if(C.current=s,!w||!s)return;let oe=S=>{let x=S.getAttribute("aria-label")??"",R=y&&y!==s?x.startsWith(`${y} \xB7 `)?x.slice(y.length+3):x===y?"":x:x;R===s&&(S.getAttribute("role")==="region"||S.tagName==="SECTION"&&!S.hasAttribute("role"))&&S.setAttribute("role","group");let H=R.startsWith(`${s} \xB7 `)||R===s?R:R?`${s} \xB7 ${R}`:s;H!==x&&S.setAttribute("aria-label",H)},B=()=>w.querySelectorAll("aside, nav, main, header, footer, section[aria-label]:not([role]), [role=region], [role=complementary], [role=navigation], [role=search]").forEach(S=>{S.hasAttribute("data-graview-named-by-lens")||oe(S)});B();let P=new MutationObserver(B);return P.observe(w,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["aria-label"]}),()=>P.disconnect()},[s]);let re=E?`${m}`.replace(/([\d.]+)[sdl]?vh\b/g,(w,y)=>`${+y*E/100}px`):m;return{rootRef:f,scope:g,css:v,scheme:c,store:l,presence:b,brand:r,auto:d==="auto",height:re}}function we({rootRef:e,board:t}){let n=(0,o.useCallback)(()=>e.current?.querySelector("[data-embed-content]")??e.current,[e]);return(0,u.jsx)(J,{board:t,anchor:n})}function Ee(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,files:e.files,app:e.app}}function xe({name:e,heading:t,faces:n,at:a,without:r,home:i,reach:d,standing:s,hostActions:f,keeping:m,onFind:E,switch:g}){let{brand:l,store:b,principal:p,views:h}=G();I();let c=r?.has("places")?[]:W({store:b,principal:p,views:h}),v=U();return(0,u.jsx)(_,{brand:l,name:e,description:l?.subtitle,heading:t,faces:n,home:i,places:c,current:a===null?null:D(c,a),reach:d,onFind:E,...g?{switch:g}:{},...n?{scenePlaces:v}:{},tools:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(X,{clean:s}),(0,u.jsx)(j,{...f?{hostActions:f}:{},...m?{keeping:m}:{}})]})})}var Re=e=>e===!1?2:Math.min(e+1,6);function Ae(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}),[]),d=(0,o.useCallback)(s=>{if(a.current){a.current(s);return}r.current=s,n(s)},[]);return{at:t,setAt:n,steering:i,steer:d}}function le(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 k=()=>typeof performance<"u"?performance.now():Date.now();function Fe(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?.(le(a),{module:r.module,face:n.current.face}),[])}function ke(e,t){let n=(0,o.useRef)(null);n.current===null&&(n.current=k());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,k()-(n.current??k())),face:i}))},[])}var te=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,u.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,u.jsx)("span",{children:this.props.content?"This part of the app could not draw.":"Could not draw."}),(0,u.jsx)("button",{type:"button",onClick:()=>this.setState({failed:!1}),style:{padding:"3px 11px",fontSize:"0.8125rem"},children:"Try again"})]}):this.props.children}};export{ge as a,ie as b,be as c,ve as d,Se as e,we as f,Ee as g,xe as h,Re as i,Ae as j,Fe as k,ke as l,te as m};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as te,e as ne,f as ie,g as oe}from"./chunk.WWWZZAHE.js";import{a as Q}from"./chunk.G4JJXA63.js";import{j as X,n as J,o as ee}from"./chunk.QFJRXAU3.js";import"./chunk.UEEXBS2U.js";import"./chunk.6MZBFEXW.js";import"./chunk.ZLPA5BAW.js";import"./chunk.NIEQZOHX.js";import"./chunk.XOC5BRPU.js";import"./chunk.3RT463XY.js";import"./chunk.ZOWWWRYA.js";import"./chunk.LEVR7WLB.js";import"./chunk.WVUJXDXZ.js";import"./chunk.TAW67PZU.js";import"./chunk.YOMW4MKD.js";import"./chunk.DRIWJRQW.js";import"./chunk.KSEKVHJJ.js";import"./chunk.JIWB6VGT.js";import{a as G}from"./chunk.7ZJPJARU.js";import{a as q,d as B}from"./chunk.KXWRS6LY.js";import"./chunk.PKFL2AR4.js";import"./chunk.XNYBOKLW.js";import"./chunk.AHDOKM4O.js";import"./chunk.6R4EI47C.js";import"./chunk.NLFLFIDS.js";import{d as Z}from"./chunk.6LJ66MB7.js";import{V as U,da as C,i as F,l as _,q as Y,ra as V}from"./chunk.SVL6I37U.js";import{O as j,T as P,U as T,Y as N,Z as W,bb as z}from"./chunk.P7YN4Z3K.js";import{a as he,b as K}from"./chunk.MRK6QJV5.js";import{b as O}from"./chunk.AJZBJBMO.js";var M=3;function re(e,n){return n.id?e.graph.getNode(n.id):void 0}function ae(e){return e?/^(?:kind|aggregate):([^:]+)$/.exec(e)?.[1]:void 0}function le(e,n){if(n)return e.find(t=>t.nodeIds.includes(n)||t.subjectId===n)}var ye=e=>{let n=e.trim();if(!n)return n;let t=n.charAt(0).toUpperCase()+n.slice(1);return/[.!?…]$/.test(t)?t:`${t}.`};function de({store:e,subject:n,violations:t,place:i}){let r=re(e,n),o=le(t,r?.id??null);if(o)return ye(o.message);if(r){let l=r.kind;return`${j(e.schema.tryDefinition(l),r)}, ${N(W(e.schema.tryDefinition(l),l))}.`}let c=i?.kind??ae(n.id);if(c){let l=e.graph.nodesOfKind(c).length,g=i?.title??n.name,u=T(e.schema,c),f=P(e.schema,c,l);return g.toLowerCase()===u.toLowerCase()?`${l===1?"There is":"There are"} ${f} here.`:`${g}: ${f}.`}let a=e.schema.kinds.map(l=>({kind:l,count:e.graph.nodesOfKind(l).length})).filter(l=>l.count>0).sort((l,g)=>g.count-l.count).slice(0,3);if(a.length===0)return"Nothing here yet.";let s=a.map(l=>P(e.schema,l.kind,l.count));return`The whole thing: ${s.length===1?s[0]:`${s.slice(0,-1).join(", ")} and ${s[s.length-1]}`}.`}function ce(e){let{store:n,subject:t,violations:i}=e,r=re(n,t),o=[];r&&le(i,r.id)?o.push({ask:`What's wrong with ${t.name}?`,why:"problem"}):i.length>0&&o.push({ask:"What needs attention?",why:"problem"});let c=r?r.kind:e.place?.kind??ae(t.id),a=ve(e,c);if(a)o.push(a);else{let l=ke(e,c);l&&o.push(l)}let s=be(e,c);return s&&o.push(s),o.length<M&&(r?o.push({ask:`Tell me about ${t.name}`,why:"about"}):o.push({ask:"What is here?",why:"here"})),o.slice(0,M)}function ue(e,n){return e.schema.tryDefinition(n)?.fields?.shape??{}}function me(e){let n=e;for(let t=0;t<4&&n;t++){let i=n;if(Array.isArray(i.options)&&i.options.every(r=>typeof r=="string"))return i.options;n=typeof i.unwrap=="function"?i.unwrap():i._def?.innerType}}var se=/^\d{4}-\d{2}-\d{2}/,Se=["due","deadline","date","when"];function ve(e,n){let{store:t}=e,i=e.today;if(!i||!se.test(i))return;let r=new Date(`${i.slice(0,10)}T00:00:00Z`);r.setUTCDate(r.getUTCDate()+6);let o=r.toISOString().slice(0,10),c=[...new Set([...n?[n]:[],...t.schema.kinds])];for(let a of c){let s=Se.find(u=>u in ue(t,a));if(!s||!t.graph.nodesOfKind(a).some(u=>{let f=u[s],S=u.done;return typeof f=="string"&&se.test(f)&&f.slice(0,10)>=i.slice(0,10)&&f.slice(0,10)<=o&&S!==!0}))continue;let g=T(t.schema,a);return{ask:`${Q(g)} due this week`,why:"due"}}}function ke(e,n){let t=e.place?.title,i=(e.places??[]).find(r=>r.kind!==null&&r.picture===!0&&r.title!==t&&r.kind!==n);return i?{ask:`Go to ${i.title}`,why:"go"}:void 0}function be(e,n){let{store:t}=e,i=[...t.schema.kinds].sort((o,c)=>t.graph.nodesOfKind(c).length-t.graph.nodesOfKind(o).length),r=[...new Set([...n?[n]:[],...i])];for(let o of r){if(t.graph.nodesOfKind(o).length<2)continue;let c=ue(t,o),a=Object.keys(c).find(g=>(me(c[g])?.length??0)>=2);if(!a)continue;let s=T(t.schema,o).toLowerCase(),l=a.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").toLowerCase();return{ask:`Show ${s} as a board by ${l}`,why:"draw"}}}function pe(e,{store:n,subject:t}){let i=a=>t.id!==null&&(a.nodeIds.includes(t.id)||Object.values(a.args).includes(t.id)),r=e.filter(a=>a.provider==="invariant"&&i(a)),o=e.filter(a=>a.pinned==="user"&&!r.includes(a));return[...r,...o].sort((a,s)=>Number(a.destructive??!1)-Number(s.destructive??!1)).slice(0,M).map(a=>({affordance:a,label:Ae(a,{store:n,subject:t})}))}var we=e=>/^[a-z0-9]+(?:[-_][a-z0-9]+)+$|^[a-z]+[A-Z][A-Za-z0-9]*$/.test(e);function Ae(e,{store:n,subject:t}){let i=e.label,r=we(i)||i===e.mutation;if(r){let s=i.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").toLowerCase();i=s.charAt(0).toUpperCase()+s.slice(1)}let o=t.id?n.graph.getNode(t.id):void 0,c=o!==void 0&&e.nodeIds.length<=1&&(e.nodeIds[0]??o.id)===o.id;if(c&&/\bit\b/.test(i))return i.replace(/\bit\b/,t.name);let a=n.allMutations().find(s=>s.name===e.mutation);if(e.open.length===0&&a?.describe&&(r||c))try{let s=a.describe(e.args,n.graph);if(s.trim())return s.trim()}catch{}return i}var y=O(he(),1);var p=O(K(),1);function ze({phone:e,side:n,name:t,onClose:i,respond:r,onCall:o,onPick:c,onMove:a,place:s,onDraft:l}){let{seatTalk:g}=C(),u=U(g),f=xe(c),S=[...u.turns].reverse().find(h=>h.role==="seat"),m=e&&u.draft!==null,b=(0,y.useRef)(null),w=(0,y.useRef)(!0);return(0,y.useLayoutEffect)(()=>{let h=b.current;if(!h)return;let A=m?[...h.querySelectorAll("ol > li")].pop():void 0;if(A){let v=A.getBoundingClientRect().top-h.getBoundingClientRect().top+h.scrollTop;h.style.maxHeight=`min(${Math.ceil(h.scrollHeight-v)}px, ${ge})`}let k=w.current?fe.get(g):void 0;w.current=!1,h.scrollTop=k&&k.turns===u.turns.length&&!u.busy?k.top:h.scrollHeight},[u.turns.length,u.busy,m]),(0,p.jsxs)("div",{"data-testid":"seat-panel",...m?{"data-graview-seat-yields":""}:{},style:{display:"grid",gridTemplateRows:"auto minmax(0, 1fr)",gap:4,minHeight:0},children:[(0,p.jsxs)("div",{"data-testid":"seat-top",...e?{onPointerDown:h=>Ce(h,i)}:{},style:{display:"flex",alignItems:"center",justifyContent:e?"center":"flex-end",gap:2,position:"relative",minHeight:28,...e?{touchAction:"none"}:{}},children:[e?(0,p.jsx)("button",{type:"button","data-testid":"seat-grab","aria-label":`Close Ask ${t}`,title:"Close",onClick:i,style:{...E,width:64},children:(0,p.jsx)("span",{"aria-hidden":"true",style:{display:"block",width:36,height:4,margin:"0 auto",borderRadius:2,background:"var(--graview-edge-strong, var(--graview-ink-faint))"}})}):(0,p.jsx)("button",{type:"button","data-testid":"seat-side","aria-label":n==="left"?"Move to the right":"Move to the left",title:n==="left"?"Move to the right":"Move to the left",onClick:()=>g.setSide(n==="left"?"right":"left"),style:E,children:(0,p.jsx)("span",{"aria-hidden":"true",children:"\u21C4"})}),(0,p.jsx)("button",{type:"button","data-testid":"seat-close","aria-label":`Close Ask ${t}`,title:"Close",onClick:i,style:e?{...E,position:"absolute",top:0,right:0}:E,children:(0,p.jsx)("span",{"aria-hidden":"true",children:"\u2715"})})]}),(0,p.jsx)("div",{ref:b,"data-testid":"seat-body",onScroll:h=>void fe.set(g,{top:h.currentTarget.scrollTop,turns:u.turns.length}),style:{minHeight:0,maxHeight:m?ge:e?"calc(70cqh - 96px)":"min(520px, calc(100cqh - 112px))",overflowY:"auto",overflowX:"hidden",padding:"0 4px"},children:(0,p.jsx)(ne,{shared:!0,composer:!1,testId:"seat",onPick:f,...a?{onMove:a}:{},...s?{place:s}:{},...l?{onDraft:l}:{},empty:(0,p.jsx)(Te,{...s?{here:s}:{}}),...r?{respond:r}:{},...o?{onCall:o}:{}})}),(0,p.jsx)("p",{"aria-live":"polite","data-testid":"seat-said",style:Z,children:u.busy?"":S?.text??""})]})}function xe(e){let{setView:n}=C();return(0,y.useCallback)(t=>e?e(t):n(i=>Y(F(_(i,!1),t),[t])),[e,n])}function Te({here:e}){let{store:n,views:t,view:i,seatTalk:r}=C(),o=te({hover:!1}),c=q(n,V()),a=(0,y.useMemo)(()=>c.map(d=>d.line?{...d,message:B(d)}:d),[c]),s=o.id?n.graph.getNode(o.id):void 0,l=e??i.within?.view,g=o.because==="place"&&o.id===null?t.places().find(d=>d.title===o.name):l?t.places().find(d=>d.as===l):void 0,u=n.today(),f={store:n,subject:{id:o.id,name:o.name},violations:a,place:g?{title:g.title,kind:g.kind}:null,places:t.places().map(d=>({title:d.title,kind:d.kind,picture:!0})),...u?{today:u}:{}},S=de(f),m=ce(f),b=(0,y.useMemo)(()=>({pins:X(),...s?{focus:s.id,about:[s.id]}:{}}),[s?.id]),{affordances:w}=J(b),h=s?pe(w,{store:n,subject:{id:o.id,name:o.name}}):[],{apply:A,preview:k}=ee(),[v,$]=(0,y.useState)(null),[D,R]=(0,y.useState)(null),H=(d,x)=>{try{return k(d,x),A(d,x),R(null),!0}catch(I){return R(z(n.schema,n.allMutations(),I)),!1}};return(0,p.jsxs)("div",{"data-testid":"seat-here",style:{display:"grid",gap:10,padding:"2px 2px 6px"},children:[(0,p.jsx)("p",{"data-testid":"seat-where",style:{margin:0,fontSize:"0.9375rem",lineHeight:1.45,color:"var(--graview-ink)"},children:S}),h.length>0?(0,p.jsx)("ul",{"aria-label":"What you can do",style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:6},children:h.map(({affordance:d,label:x})=>(0,p.jsx)("li",{children:(0,p.jsx)("button",{type:"button","data-testid":"seat-act","data-affordance":d.id,"aria-pressed":v?.id===d.id,title:d.why,onClick:()=>d.open.length>0?$(I=>I?.id===d.id?null:d):void H(d),style:{...ie,minHeight:30,textAlign:"start",...d.destructive?{color:"var(--graview-warn)"}:{}},children:x})},d.id))}):null,v?(0,p.jsx)(G,{affordance:v,onApply:d=>{H(v,d)&&$(null)},onCancel:()=>$(null)}):null,D?(0,p.jsx)("p",{"data-testid":"seat-refused",style:{margin:0,fontSize:"0.8125rem",color:"var(--graview-warn)"},children:D}):null,m.length>0?(0,p.jsx)("ul",{"aria-label":"Things to ask",style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:2,justifyItems:"start"},children:m.map(d=>(0,p.jsx)("li",{children:(0,p.jsx)("button",{type:"button","data-testid":"seat-suggestion","data-graview-why":d.why,onClick:()=>r.ask(d.ask),style:oe,children:d.ask})},d.ask))}):null]})}var ge="min(5.5em, 22cqh)",fe=new WeakMap,L={far:64,flick:.5,least:16,tap:6};function Ce(e,n){if(e.button!==0)return;let t=e.currentTarget,i=t.closest('[data-testid="seat"]');if(!i)return;let r=e.pointerId,o=e.clientY,c={y:o,at:e.timeStamp},a=0,s=0;try{t.setPointerCapture(r)}catch{}let l=u=>{if(u.pointerId!==r)return;s=Math.max(0,u.clientY-o);let f=u.timeStamp-c.at;f>0&&(a=(u.clientY-c.y)/f),c={y:u.clientY,at:u.timeStamp},i.style.transition="none",i.style.transform=s>0?`translateY(${s}px)`:""},g=u=>{if(u.pointerId!==r)return;t.removeEventListener("pointermove",l),t.removeEventListener("pointerup",g),t.removeEventListener("pointercancel",g);let f=u.type==="pointerup"&&(s>=L.far||s>=L.least&&a>=L.flick);if(i.style.transition=f?"":"transform 160ms ease-out",i.style.transform="",s>L.tap){let S=m=>{m.preventDefault(),m.stopPropagation()};t.addEventListener("click",S,{capture:!0,once:!0}),setTimeout(()=>t.removeEventListener("click",S,{capture:!0}),0)}f&&n()};t.addEventListener("pointermove",l),t.addEventListener("pointerup",g),t.addEventListener("pointercancel",g)}var E={display:"inline-grid",placeItems:"center",width:28,height:28,padding:0,font:"inherit",fontSize:"0.875rem",lineHeight:1,color:"var(--graview-ink-muted)",background:"transparent",border:"1px solid transparent",borderRadius:6,boxShadow:"none",cursor:"pointer"};export{ze as SeatPanel,xe as useSeatGo};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as x,b as k,c as b,d as E,e as V}from"./chunk.KSEKVHJJ.js";import{g as d}from"./chunk.JIWB6VGT.js";var S=["card","row","page"],O=["good","warn","bad","neutral","accent"],M=["money","percent","date","relative","count"],R=4,w=40,A=["number","money","percent"],N=["card","row"],F=100,$={title:[],headline:[],list:["sort","limit","group","empty","as"],text:["tone"],badge:["tone"],field:["as","currency","label"],image:["as","label"],progress:["label"],group:["direction"],when:["show"],divider:[],figure:["as","currency","label"]},W=Object.keys($),T=`{"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"?}, {"image": "photos", "as"?: "thumb"|"gallery"}, {"progress": {"value": expr, "max": expr}, "label"?}, {"group": [blocks], "direction"?: "row"|"column"}, {"when": expr, "show": [blocks]}, {"divider": true}, {"figure": true}`,D=n=>/^(image|file)$/.test(n?.of??n?.type??"");function tn(n){return Object.fromEntries(Object.entries(n.views??{}).filter(([,e])=>!Array.isArray(e)))}function sn(n){let e=n.views?.home;return Array.isArray(e)?e:void 0}var G={field:()=>!1,relation:()=>!1,figure:!1},z=n=>n.kind??"the home",h=(n,e)=>n!==void 0&&Object.hasOwn(n,e),y=n=>typeof n=="object"&&n!==null&&!Array.isArray(n);function I(n,e,s){let o=x(n);for(let a of o.unknownFunctions)s.findings.push(d("unknown-function",e,`"${a}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let a of o.names){if(s.kind===null){s.findings.push(d("view-name",e,`"${a}" 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}a==="id"||s.spec.field(a)||s.spec.relation(a)||s.findings.push(d("view-name",e,`${s.kind} has no field or relation called "${a}"`))}for(let a of o.edges)s.edges.has(a)||s.findings.push(d("view-edge",e,`"${a}" is not a relation any kind declares`));for(let a of o.sweeps)s.kinds.has(a)||s.findings.push(d("view-kind",e,`"${a}" is not a kind this document declares`))}function m(n,e,s){if(typeof n!="string"||n.length===0||n.length>2e3){s.findings.push(d("view-expression",e,`an expression is a line of the rule language, like "status == 'booked'"`));return}try{I(b(n),e,s)}catch(o){if(!(o instanceof k))throw o;s.findings.push(d("expression",e,`${o.sentence} (at character ${o.at+1})`))}}function j(n,e,s){if(typeof n!="string"||n.length===0||n.length>300){s.findings.push(d("view-template",e,'a template is words with {field} in braces, like "{name}" or "{quote|money}", at most 300 characters'));return}let o;try{o=V(n)}catch(a){if(a instanceof E||a instanceof k){s.findings.push(d("template",e,a.sentence));return}throw a}for(let a of o)a.expr&&I(a.expr,e,s)}function C(n,e,s){if(typeof n=="string"){O.includes(n)||s.findings.push(d("view-tone",e,`"${n}" is not a tone`,`use one of ${O.join(", ")}, or {"expr": "if(status == 'booked', 'good', 'neutral')"}`));return}if(y(n)&&Object.keys(n).length===1&&"expr"in n){m(n.expr,`${e}.expr`,s);return}s.findings.push(d("view-tone",e,'a tone is a word or {"expr": \u2026}',`one of ${O.join(", ")}`))}function v(n,e,s,o){if(!Array.isArray(n)){o.findings.push(d("view-shape",e,"a view is a list of blocks"));return}if(s>R){o.findings.push(d("view-depth",e,`blocks nest at most ${R} deep`,"flatten a group or a condition"));return}n.forEach((a,l)=>H(a,`${e}.${l}`,s,o))}function H(n,e,s,o){if(o.count++,!y(n)){o.findings.push(d("view-block",e,"a block is an object naming what it shows",`one of ${T}`));return}let a=Object.keys(n),l=a.filter(t=>W.includes(t)&&!(t==="group"&&a.includes("list")));if(l.length===0){o.findings.push(d("view-block",e,`${a.length>0?a.map(t=>`"${t}"`).join(", "):"an empty object"} is not a block Graview knows`,`one of ${T}`));return}if(l.length>1){o.findings.push(d("view-block",e,`a block is one thing, and this says ${l.map(t=>`"${t}"`).join(" and ")}`,"split it into two blocks"));return}let r=l[0];for(let t of a)t!==r&&t!="key"&&!$[r].includes(t)&&o.findings.push(d("unknown-key",`${e}.${t}`,`"${t}" is not part of a ${r} block`,$[r].length>0?`a ${r} block may also say ${$[r].map(f=>`"${f}"`).join(", ")}`:`a ${r} block says nothing else`));let i=n[r];switch(r){case"title":case"headline":case"text":case"badge":j(i,`${e}.${r}`,o),"tone"in n&&C(n.tone,`${e}.tone`,o);return;case"image":case"field":{let t=r==="image";if(typeof i!="string"||!(t?o.spec.files?.(i):o.spec.field(i))){let u=typeof i=="string"&&o.spec.relation(i);o.findings.push(d(`view-${r}`,`${e}.${r}`,`${o.kind} has no ${t?"image or file ":""}field ${typeof i=="string"?`"${i}"`:"by that name"}`,u?`"${i}" is a relation; show it with {"text": "{${i}.name}"}`:void 0))}let f=t?["thumb","gallery"]:M;"as"in n&&!f.includes(n.as)&&o.findings.push(d("view-format",`${e}.as`,`"${String(n.as)}" is not a way to show ${t?"pictures":"a field"}`,`use one of ${f.join(", ")}`)),t||L(n,e,o,"field"),"label"in n&&Y(n.label,`${e}.label`,o);return}case"progress":{!y(i)||Object.keys(i).some(t=>t!=="value"&&t!=="max")||!("value"in i)||!("max"in i)?o.findings.push(d("view-progress",`${e}.progress`,'progress is {"value": expression, "max": expression}')):(m(i.value,`${e}.progress.value`,o),m(i.max,`${e}.progress.max`,o)),"label"in n&&j(n.label,`${e}.label`,o);return}case"group":"direction"in n&&n.direction!=="row"&&n.direction!=="column"&&o.findings.push(d("view-direction",`${e}.direction`,`a group runs "row" or "column", not "${String(n.direction)}"`)),v(i,`${e}.group`,s+1,o);return;case"when":m(i,`${e}.when`,o),"show"in n?v(n.show,`${e}.show`,s+1,o):o.findings.push(d("view-when",e,'a condition says what it shows: {"when": expr, "show": [blocks]}'));return;case"figure":if(typeof i=="string")return P(n,e,o);for(let t of["as","currency","label"])t in n&&o.findings.push(d("unknown-key",`${e}.${t}`,`"${t}" belongs to a figure that works a number out; {"figure": true} is the kind's picture`,`write {"figure": "count(all('offer'))", "as": "number"}`));i!==!0?o.findings.push(d("view-block",`${e}.figure`,`a figure is a number worked out, {"figure": "sum(all('offer'), net)", "as": "money"}, or the kind's picture, {"figure": true}`)):o.spec.figure||o.findings.push(d("view-figure",`${e}.figure`,`${z(o)} has no figure to show`,o.kind===null?`work a number out: {"figure": "count(all('offer'))"}`:'give the kind a "figure", or leave this block out'));return;case"list":return X(n,e,o);case"divider":i!==!0&&o.findings.push(d("view-block",`${e}.${r}`,`write {"${r}": true}`));return}}function P(n,e,s){m(n.figure,`${e}.figure`,s),"as"in n&&!A.includes(n.as)&&s.findings.push(d("view-format",`${e}.as`,`"${String(n.as)}" is not a way to say a figure`,`use one of ${A.join(", ")}`)),L(n,e,s,"figure"),"label"in n&&j(n.label,`${e}.label`,s)}function L(n,e,s,o){"currency"in n&&(typeof n.currency!="string"||!/^[A-Z]{3}$/.test(n.currency)?s.findings.push(d("view-currency",`${e}.currency`,'a currency is its three-letter code, like "USD" or "EUR"')):n.as!=="money"&&s.findings.push(d("view-currency",`${e}.currency`,`a currency belongs on a ${o} shown as money`,'add "as": "money"')))}function U(n,e){let s=[...e.kinds],o=(l,r)=>{let i=new Set;for(let t of l){let f=e.vocabulary.namesOf(t)?.targets?.(r);if(f==="*")return s;for(let u of f??[])i.add(u)}return i.size>0?[...i]:void 0},a=l=>{switch(l.t){case"ident":return e.kind!==null&&e.spec.relation(l.name)?o([e.kind],l.name):void 0;case"member":{let r=a(l.object);return r?o(r,l.name):void 0}case"where":return a(l.set);case"call":{let r=l.args[0],i=r?.t==="lit"&&typeof r.value=="string"?r.value:void 0;if(l.fn==="all")return i!==void 0&&e.kinds.has(i)?[i]:void 0;let t=l.args.length===2&&l.args[1]?.t==="lit"&&typeof l.args[1].value=="string"?l.args[1].value:void 0;if(l.fn==="out"&&t!==void 0){let f=a(r);return f?o(f,t):void 0}if(l.fn==="out")return i!==void 0&&e.kind!==null?o([e.kind],i):void 0;if(l.fn==="in"){let f=t??i,u=t!==void 0?a(r):e.kind!==null?[e.kind]:void 0,c=f!==void 0?e.vocabulary.sources(f).filter(g=>{let p=e.vocabulary.namesOf(g)?.targets?.(f);return!u||p==="*"||u.some(K=>p?.includes(K))}):[];return c.length>0?c:void 0}if((l.fn==="sort"||l.fn==="first")&&r)return a(r);if(l.fn==="either"){let f=l.args.map(a);return f.every(u=>u!==void 0)?[...new Set(f.flatMap(u=>u??[]))]:void 0}return}default:return}};return a(n)}function _(n,e,s,o){let a;try{a=b(n)}catch(r){if(!(r instanceof k))throw r;o.findings.push(d("expression",e,`${r.sentence} (at character ${r.at+1})`));return}let l=x(a);for(let r of l.unknownFunctions)o.findings.push(d("unknown-function",e,`"${r}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let r of l.edges)o.edges.has(r)||o.findings.push(d("view-edge",e,`"${r}" is not a relation any kind declares`));if(s)for(let r of l.names)r==="id"||s.some(i=>o.vocabulary.namesOf(i)?.field(r)||o.vocabulary.namesOf(i)?.relation(r))||o.findings.push(d("view-name",e,`${s.join(" and ")} ${s.length===1?"has":"have"} no field or relation called "${r}"`))}function X(n,e,s){let o=n.list;m(o,`${e}.list`,s);let a;if(typeof o=="string")try{a=U(b(o),s)}catch{a=void 0}let l=i=>{if(!a)return[...s.kinds].map(f=>s.vocabulary.namesOf(f)?.choices?.(i)).find(f=>f!==void 0);let t=a.map(f=>s.vocabulary.namesOf(f)?.choices?.(i));return t.every(f=>f!==void 0)?[...new Set(t.flatMap(f=>f??[]))]:void 0},r=a?a.join(" and "):"any kind";if("sort"in n){let i=n.sort;if(typeof i=="string")_(i,`${e}.sort`,a,s);else if(y(i)&&typeof i.by=="string"&&Object.keys(i).every(t=>t==="by"||t==="direction")){let t=i.direction;t!==void 0&&t!=="asc"&&t!=="desc"&&t!=="choices"?s.findings.push(d("list-sort",`${e}.sort.direction`,`a list is sorted "asc", "desc" or "choices", not "${String(t)}"`,'"choices" puts a choice field in the order its choices are declared')):t==="choices"?l(i.by)===void 0&&s.findings.push(d("list-sort",`${e}.sort.by`,`"${i.by}" is not a choice field of ${r}, so it has no declared order`,'sort by a choice field, or say "asc" or "desc"')):_(i.by,`${e}.sort.by`,a,s)}else s.findings.push(d("list-sort",`${e}.sort`,'a sort is a key, like "net", or {"by": key, "direction": "asc" | "desc" | "choices"}'))}if("limit"in n){let i=n.limit;(typeof i!="number"||!Number.isInteger(i)||i<1||i>F)&&s.findings.push(d("list-limit",`${e}.limit`,`a limit is a whole number from 1 to ${F}`))}if("group"in n){let i=n.group,t=typeof i=="string"?i:y(i)&&typeof i.by=="string"?i.by:void 0;if(!(typeof i=="string"||y(i)&&Object.keys(i).every(u=>u==="by"||u==="headings"))||t===void 0)s.findings.push(d("list-group",`${e}.group`,'a group is a choice field, like "type", or {"by": "type", "headings": {"pain": "What hurts"}}'));else{let u=l(t);if(u===void 0&&s.findings.push(d("list-group",`${e}.group`,`"${t}" is not a choice field of ${r}, so it has no choices to group by`,"group by a field whose type is enum")),y(i)&&"headings"in i){let c=i.headings;if(!y(c)||Object.values(c).some(g=>typeof g!="string"||g.length===0||g.length>80))s.findings.push(d("list-group",`${e}.group.headings`,'headings are words per choice, like {"pain": "What hurts"}, at most 80 characters each'));else if(u)for(let g of Object.keys(c))u.includes(g)||s.findings.push(d("list-group",`${e}.group.headings.${g}`,`"${g}" is not one of ${t}'s choices`,`use ${u.join(", ")}`))}}}"empty"in n&&(typeof n.empty!="string"||n.empty.length===0||n.empty.length>200)&&s.findings.push(d("list-empty",`${e}.empty`,"what an empty list says is a sentence, at most 200 characters")),"as"in n&&!N.includes(n.as)&&s.findings.push(d("list-as",`${e}.as`,`a list draws each record as its "card" or its "row", not "${String(n.as)}"`))}function Y(n,e,s){(typeof n!="string"||n.length===0||n.length>60)&&s.findings.push(d("view-label",e,"a label is a few words, at most 60 characters"))}function B(n,e,s,o,a,l,r){let i={kind:null,spec:G,kinds:o,edges:a,vocabulary:s,findings:l,count:0};Array.isArray(n)&&n.length===0&&l.push(d("view-shape",e,`${r} has no blocks`,'give it one: {"headline": "\u2026"}')),v(n,e,1,i),i.count>w&&l.push(d("view-size",e,`${r} has ${i.count} blocks; a view has at most ${w}`,"show less"))}function q(n,e,s,o,a){Array.isArray(n)&&n.forEach((l,r)=>{if(!y(l)||l.name!=="blocks"||!y(l.options)||!("blocks"in l.options))return;let i=[];B(l.options.blocks,`lenses.${r}.options.blocks`,e,s,o,i,`the lens "${String(l.title??r)}"`);for(let t of i)a.push({...t,severity:"warning"})})}function Z(n,e,s,o,a,l,r){let i=[];if(n===void 0)return i;if(!y(n))return i.push(d("view-shape",e,'views are an object of kinds, each with a "card", a "row" or a "page"')),i;for(let[t,f]of Object.entries(n)){if(t==="home"&&Array.isArray(f)){B(f,`${e}.home`,r,o,a,i,"the home");continue}let u=s(t);if(!u){i.push(d("view-kind",`${e}.${t}`,`"${t}" is not a kind this ${l} declares`));continue}if(!y(f)){i.push(d("view-shape",`${e}.${t}`,`a kind's views are {"card": [blocks], "row": [blocks], "page": [blocks]}`));continue}for(let c of Object.keys(f))S.includes(c)||i.push(d("view-slot",`${e}.${t}.${c}`,`"${c}" is not a place a view is drawn`,`use ${S.map(g=>`"${g}"`).join(", ")}`));for(let c of S){let g=f[c];if(g===void 0)continue;let p={kind:t,spec:u,kinds:o,edges:a,vocabulary:r,findings:i,count:0};v(g,`${e}.${t}.${c}`,1,p),p.count>w&&i.push(d("view-size",`${e}.${t}.${c}`,`this ${c} has ${p.count} blocks; a view has at most ${w}`,"show less, or move detail to the page"))}}return i}function rn(n){let e=new Set(Object.keys(n.kinds)),s=new Set(Object.values(n.kinds).flatMap(r=>Object.keys(r.edges??{}))),o=r=>{let i=h(n.kinds,r)?n.kinds[r]:void 0;return i?{field:t=>h(i.fields,t)||h(i.computed,t),relation:t=>h(i.edges,t),figure:i.figure!==void 0,files:t=>h(i.fields,t)&&D(i.fields[t]),choices:t=>h(i.fields,t)&&i.fields[t].type==="enum"?i.fields[t].options:void 0,targets:t=>h(i.edges,t)?i.edges[t].to:void 0}:void 0},a={namesOf:o,sources:r=>Object.keys(n.kinds).filter(i=>h(n.kinds[i].edges,r))},l=Z(n.views,"views",o,e,s,"document",a);return q(n.lenses,a,e,s,l),l}export{O as a,M as b,A as c,F as d,tn as e,sn as f,rn as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as V}from"./chunk.4MAYBFPU.js";import{b as K}from"./chunk.NQP3DWME.js";import{a as ie}from"./chunk.ZOWWWRYA.js";import{l as se,m as G}from"./chunk.LEVR7WLB.js";import{f as _,g as N,h as B}from"./chunk.6R4EI47C.js";import{a as O,d as ae}from"./chunk.6LJ66MB7.js";import{V as ee,da as M,ea as te,fa as ne,qa as oe,sa as re,za as F}from"./chunk.SVL6I37U.js";import{Ab as Z,Fb as z,V as J,W as Q}from"./chunk.P7YN4Z3K.js";import{a as $,b as T}from"./chunk.MRK6QJV5.js";import{b as k}from"./chunk.AJZBJBMO.js";var i=k($(),1);var x=k(T(),1),le=336,w=16,ue=640,I=F(O(()=>import("./chunk.YIZ3DJO3.js"))),fe=I.part((t,n)=>{let s=t.SeatPanel;return(0,x.jsx)(s,{...n})},{what:"The conversation"});function xe({respond:t,onCall:n,onPick:s,start:y="field",onMove:l,place:S,onDraft:v}){let{brand:r,seatTalk:d}=M(),f=ee(d),g=r?.name?.trim()||"this app",h=(0,i.useRef)(null),o=(0,i.useRef)(null),[a,c]=(0,i.useState)(""),[m,P]=(0,i.useState)(!1),C=(0,i.useRef)(null),b=y==="hidden",p=f.open&&!b;(0,i.useEffect)(()=>b?void 0:d.drawn(),[d,b]),(0,i.useLayoutEffect)(()=>{let e=h.current?.parentElement;if(!e)return;let E=()=>P(e.getBoundingClientRect().width<ue);if(E(),typeof ResizeObserver>"u")return;let D=new ResizeObserver(E);return D.observe(e),()=>D.disconnect()},[b]),(0,i.useEffect)(()=>{typeof window<"u"&&window.dispatchEvent(new Event(ie))},[p,f.side,m]),(0,i.useEffect)(()=>{let e=h.current;if(b||p||!e||typeof window>"u")return;let E=(e.closest("[data-graview-embed]")??document.documentElement).style,D=()=>{let Y=e.getBoundingClientRect(),X=e.offsetParent?.getBoundingClientRect(),ce=X?X.bottom-Y.top:Y.height+w;E.setProperty("--graview-foot-room",`${Math.max(0,Math.round(ce+w))}px`)};D();let U=typeof ResizeObserver>"u"?null:new ResizeObserver(D);return U?.observe(e),()=>{U?.disconnect(),E.removeProperty("--graview-foot-room")}},[b,p,m,f.side]),(0,i.useEffect)(()=>{!p||f.pending===null||(j(),o.current?.focus({preventScroll:!0}))},[p,f.pending]);let j=()=>{let e=typeof document>"u"?null:document.activeElement;e instanceof HTMLElement&&e!==document.body&&!h.current?.contains(e)&&(C.current=e)},H=()=>{j(),I.prefetch(),d.setOpen(!0)},q=()=>{d.setOpen(!1);let e=C.current;C.current=null,e?.isConnected&&!(m&&e instanceof HTMLInputElement)&&e.focus({preventScroll:!0}),document.activeElement!==e&&(m?h:o).current?.focus({preventScroll:!0})};if(b)return null;let R=!m&&f.side==="right",pe=m?p?{left:0,right:0,bottom:0,padding:"8px 12px calc(12px + env(safe-area-inset-bottom, 0px))",borderRadius:"12px 12px 0 0",...de}:{left:w,right:w,bottom:`calc(${w}px + env(safe-area-inset-bottom, 0px))`}:p?{[R?"right":"left"]:w/2-1,bottom:w/2-1,width:le+w+2,padding:w/2,borderRadius:12,...de}:{[R?"right":"left"]:w,bottom:w,width:le};return(0,x.jsxs)("section",{ref:h,role:"region","aria-label":`Ask ${g}`,tabIndex:-1,"data-testid":"seat","data-graview-seat":p?"open":"closed","data-graview-seat-side":R?"right":"left","data-graview-seat-shape":m?"phone":"desk","data-graview-foot":"","data-graview-offstage":"",onMouseDown:e=>e.stopPropagation(),onKeyDown:e=>{e.key!=="Escape"||!p||(e.preventDefault(),e.stopPropagation(),q())},style:{position:"absolute",zIndex:z("rail"),boxSizing:"border-box",display:"flex",flexDirection:"column",gap:8,pointerEvents:"auto",outline:"none",...pe},children:[(0,x.jsxs)("h2",{style:{...ae,margin:0},children:["Ask ",g]}),p?(0,x.jsx)(i.Suspense,{fallback:null,children:(0,x.jsx)(fe,{phone:m,side:R?"right":"left",name:g,onClose:q,...t?{respond:t}:{},...n?{onCall:n}:{},...s?{onPick:s}:{},...l?{onMove:l}:{},...S?{place:S}:{},...v?{onDraft:v}:{}})}):null,(0,x.jsx)("form",{onSubmit:e=>{e.preventDefault();let E=a.trim();p||H(),!(!E||f.busy)&&(d.ask(E),c(""))},style:{display:"flex",margin:0},children:(0,x.jsx)("input",{ref:o,"data-testid":"seat-field",type:"text",enterKeyHint:"send",autoComplete:"off",value:a,placeholder:`Ask ${g}\u2026`,"aria-label":`Ask ${g}`,onPointerEnter:()=>I.prefetch(),onFocus:()=>I.prefetch(),onClick:()=>{p||H()},onChange:e=>{c(e.target.value),p||H()},style:{flex:"1 1 auto",minWidth:0,boxSizing:"border-box",height:38,padding:"0 12px",font:"inherit",fontSize:"max(1rem,16px)",color:"var(--graview-ink)",background:"var(--graview-panel)",border:"1px solid var(--graview-edge)",borderRadius:8}})})]})}var de={background:"var(--graview-float)",border:"1px solid var(--graview-edge)",boxShadow:"var(--graview-lift-high)"};var W=k($(),1),L=k(T(),1),me=F(O(()=>import("./chunk.OBQ4DIFO.js"))),ge=me.part((t,n)=>{let s=t.DraftFrame;return(0,L.jsx)(s,{...n})},{what:"The view"});function Te(t){let{seatTalk:n}=M();return(0,W.useSyncExternalStore)(n.subscribe,()=>n.get().draft!==null,()=>!1)?(0,L.jsx)(W.Suspense,{fallback:null,children:(0,L.jsx)(ge,{...t})}):null}function Re(t={}){return t.scope===void 0?V:K(V,t.scope)}var A=k($(),1),u=k(T(),1);function We({inside:t=!1}={}){let{store:n,view:s,emphasis:y,setEmphasis:l}=M(),S=se(),{selection:v,set:r}=oe(),{show:d}=re(),f=ne(),g=(0,A.useMemo)(()=>{let o=new Map;for(let a of n.graph.allEdges()){let c=o.get(a.kind)??{count:0,ends:new Set};c.count+=1;for(let m of[a.from,a.to]){let P=n.graph.getNode(m);P&&c.ends.add(`kind:${P.kind}`)}o.set(a.kind,c)}return[...o.entries()].sort(([a],[c])=>a.localeCompare(c)).map(([a,c])=>({kind:a,count:c.count,ends:[...c.ends]}))},[n,f]);if((0,A.useEffect)(()=>()=>l(null),[l]),!s.overview&&!t||g.length===0)return null;let h=new Set;for(let o of v){if(o.startsWith("kind:")){h.add(o);continue}let a=n.graph.getNode(o);a&&h.add(`kind:${a.kind}`)}return(0,u.jsxs)("section",{"aria-label":"What the lines mean",role:t?"group":void 0,"data-testid":"relation-key",style:t?{display:"grid",gap:1}:{position:"absolute",left:16,top:14,zIndex:z("rail"),display:"grid",gap:1,padding:"8px 10px",borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-low)",maxWidth:he,animation:"graview-settle 380ms 280ms ease backwards"},children:[t?null:(0,u.jsx)("span",{style:{fontSize:"0.75rem",letterSpacing:"0.16em",textTransform:"uppercase",color:"var(--graview-ink-faint)",paddingBottom:2},children:g.length===1?"1 relation":`${g.length} relations`}),g.map(({kind:o,count:a,ends:c})=>{let{connector:m,style:P}=G(S,o),C=ye(n.schema,o),b=y!==null?y===o:h.size===0||c.some(p=>h.has(p));return(0,u.jsxs)("button",{type:"button",title:n.schema.edge(o)?.description===void 0?`${a} of these`:C.words,onMouseEnter:()=>l(o),onMouseLeave:()=>l(null),onFocus:()=>l(o),onBlur:()=>l(null),onClick:()=>{r(c),d(null)},style:{all:"unset",outline:"revert-layer",cursor:"pointer",display:"grid",gridTemplateColumns:"30px 1fr auto",alignItems:"center",gap:8,minHeight:23,padding:"2px 4px",borderRadius:6,opacity:b?1:.4},children:[(0,u.jsx)("svg",{width:"30",height:"8","aria-hidden":"true",style:{display:"block",opacity:m.visible?1:.35},children:(0,u.jsx)("path",{d:"M 1 4 L 29 4",fill:"none",stroke:N(P),strokeWidth:B(P,!0),strokeDasharray:_[P.pattern],strokeLinecap:"round"})}),(0,u.jsxs)("span",{style:{display:"grid",minWidth:0},"data-graview-relation-words":o,children:[(0,u.jsx)("span",{style:{fontSize:"0.8125rem",color:"var(--graview-ink)"},children:C.words}),(0,u.jsx)("span",{style:{fontSize:"0.6875rem",color:"var(--graview-ink-faint)"},children:C.ends})]}),m.visible?null:(0,u.jsx)("span",{"data-graview-quiet":o,style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",fontStyle:"italic"},children:"not drawn"}),(0,u.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",fontVariantNumeric:"tabular-nums"},children:a})]},o)})]})}var he="min(280px, calc(100% - 28px))";function ye(t,n,s){let y=t.edge(n)?.from??[],l=new Map;for(let r of s!==void 0&&y.includes(s)?[s]:y.length>0?y:[""]){let d=Q(t,r,n,"out");l.set(d,[...l.get(d)??[],r])}let S=r=>r==="*"?"anything":J(t,r),v=[...l].map(([r,d])=>{let f=d.flatMap(h=>t.tryDefinition(h)?.edges[n]?.to??[]),g=d[0]&&f.length>0?`${d.map(S).join(", ")} \u2192 ${(f.includes("*")?["*"]:[...new Set(f)]).map(S).join(", ")}`:"";return[r.charAt(0).toUpperCase()+r.slice(1),g]});return{words:v.map(([r])=>r).join(" \xB7 "),ends:v.flatMap(([,r])=>r?[r]:[]).join(" \xB7 ")}}function He({edgeKind:t,kit:n,width:s=30}){let y=te(),l=(0,A.useMemo)(()=>Z(n??y?.brand?.kit),[n,y?.brand?.kit]),{connector:S,style:v}=G(l,t);return(0,u.jsx)("svg",{width:s,height:"8","aria-hidden":"true","data-testid":"relation-mark","data-graview-relation":t,style:{display:"inline-block",verticalAlign:"middle",opacity:S.visible?1:.35},children:(0,u.jsx)("path",{d:`M 1 4 L ${s-1} 4`,fill:"none",stroke:N(v),strokeWidth:B(v,!0),strokeDasharray:_[v.pattern],strokeLinecap:"round"})})}export{xe as a,Te as b,We as c,he as d,He as e,Re as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Aa as j,O as E,Q as N,R as z,T as V,U as Q,W as K,X as U,Y as W,Z as F,wa as X,xa as x}from"./chunk.P7YN4Z3K.js";function Y(){return{name:"insight",derive({store:e,nodes:o,kindSelection:t}){let f=[],k=c=>E(e.schema.tryDefinition(c.kind),c);for(let c of o){if([...e.schema.edgeKinds].reduce((y,n)=>y+e.graph.out(c.id,n).length+e.graph.in(c.id,n).length,0)===0){f.push({id:`insight:island:${c.id}`,text:`${k(c)} is connected to nothing yet`,nodeIds:[c.id]});continue}for(let y of e.schema.edgeKinds){let n=e.graph.in(c.id,y).length;if(n<3)continue;let i=[...e.graph.allEdges()].filter(s=>s.kind===y),l=i.length;l>=4&&n/l>.6&&f.push({id:`insight:load:${c.id}:${y}`,text:`${k(c)} ${cn(e,i,y,n)}`,nodeIds:[c.id]})}}for(let c of t){if(e.graph.nodesOfKind(c).length>0)continue;let w=e.schema.definitions.filter(y=>y.kind!==c).filter(y=>Object.values(y.edges).some(n=>n.to!=="*"&&n.to.includes(c))).map(y=>y.plural??`${y.kind}s`);w.length>0&&f.push({id:`insight:gap:${c}`,text:`Nothing here yet, though ${w.join(" and ")} expect to connect to these`,nodeIds:[]})}return{observations:f}}}}function cn(e,o,t,f){let k=new Set(o.map(i=>e.graph.getNode(i.from)?.kind).filter(i=>i!==void 0)),c=k.size===1?[...k][0]:void 0,w=o.length,y=K(e.schema,c??[...k][0]??"",t,"in"),n=i=>c?V(e.schema,c,i):String(i);return f===w?`${y}: all ${n(f)}`:`${y}: ${f} of the ${n(w)}`}function nn(e){let o=new Map;if(e.length===0)return o;let t=e.slice(-512),f=new Set;for(let c of t)c.undoes&&f.add(c.undoes);let k=e[e.length-1].seq;for(let c of t){if(!c.mutation||f.has(c.id))continue;let w=Math.pow(.5,(k-c.seq)/64);o.set(c.mutation.name,(o.get(c.mutation.name)??0)+w)}return o}function en(e){return 8*(e/(e+1))}var un=100;function tn(){return{name:"invariant",derive({store:e,selection:o,nodes:t,violations:f}){let k=i=>E(e.schema.tryDefinition(i.kind),i),c=new Set(o),w=f.filter(i=>i.nodeIds.some(l=>c.has(l))||i.subjectId!==void 0&&c.has(i.subjectId)),y=[],n=[];w.forEach((i,l)=>{n.push({id:`violation:${i.invariant}:${l}`,text:i.message,nodeIds:i.nodeIds}),i.repairs.forEach((s,g)=>{y.push({id:`invariant:${i.invariant}:${l}:${g}`,label:s.label,provider:"invariant",mutation:s.mutation,args:s.args??{},open:(s.missing??[]).map(a=>{let d=e.allMutations().find(u=>u.name===s.mutation);if(!d)return{name:a};let m=x(d.input).find(u=>u.name===a),v=m?m.kinds.includes("*")?e.graph.allNodes().map(u=>u.id):m.kinds.flatMap(u=>e.graph.nodesOfKind(u).map(p=>p.id)):void 0;return{name:a,shape:j(d.input,a),...m?{kinds:m.kinds}:{},...v?{candidates:v}:{}}}),score:un-g-(s.missing?.length??0),why:i.message,nodeIds:i.nodeIds,...i.subjectId===void 0?{}:{subjectId:i.subjectId}})})});for(let i of t){let l=e.allInvariants().filter(s=>{if(s.scope==="graph")return!1;let g=s.scope;return g.kind!==i.kind?!1:g.match?g.match(i):!0});l.length!==0&&(w.some(s=>s.subjectId===i.id||s.nodeIds.includes(i.id))||n.push({id:`holds:${i.id}`,text:`${k(i)} holds \u2014 nothing currently breaks ${l.length===1?"it":`any of its ${l.length} rules`}`,nodeIds:[i.id]}))}return{affordances:y,observations:n}}}}var B=40;function sn(){return{name:"schema",derive({store:e,selection:o,nodes:t,kindSelection:f,edgeSelection:k}){let c=[];if(t.length===0&&k.length>0){for(let n of k){let i=e.graph.getNode(n.from),l=e.graph.getNode(n.to);if(!(!i||!l))for(let s of e.allMutations()){let g=(s.connects??[]).includes(n.kind),a=(s.severs??[]).includes(n.kind);if(!g&&!a)continue;let d={},m=[],v=x(s.input);for(let p of v){let S=p.kinds.includes("*")||p.kinds.includes(i.kind),A=p.kinds.includes("*")||p.kinds.includes(l.kind),$=S&&!v.some(h=>h!==p&&(h.kinds.includes(i.kind)||h.kinds.includes("*")));S&&!A?d[p.name]=n.from:A&&!S?d[p.name]=n.to:S&&A&&$?d[p.name]=n.from:m.push({name:p.name,kinds:p.kinds,candidates:[n.from,n.to],shape:j(s.input,p.name)})}for(let p of _(s.input,""))p in d||m.some(S=>S.name===p)||m.push({name:p,shape:j(s.input,p)});m.every(p=>p.optional===!0?!0:p.kinds!==void 0?(p.candidates?.length??0)>0:(p.candidates?.length??0)>0||p.shape!==void 0&&p.shape.type!=="unknown")&&(g&&!a&&m.length===0||c.push({id:`schema:edge:${s.name}:${n.kind}:${n.from}:${n.to}`,label:N(s),provider:"schema",mutation:s.name,args:d,open:m,...s.destructive?{destructive:!0}:{},score:(a?62:58)-m.length,why:`this line is "${K(e.schema,e.graph.getNode(n.from)?.kind??"",n.kind,"out")}"`,nodeIds:[n.from,n.to]}))}}return{affordances:c}}if(t.length===0&&f.length>0){let n=new Set(f),i=[];for(let l of e.allMutations()){if(!(l.creates??[]).some(a=>n.has(a)))continue;let s=[];for(let a of x(l.input)){let d=a.kinds.includes("*")?e.graph.allNodes().map(m=>m.id):a.kinds.flatMap(m=>e.graph.nodesOfKind(m).map(v=>v.id));s.push({name:a.name,kinds:a.kinds,candidates:d,shape:j(l.input,a.name),...a.optional?{optional:!0}:{}})}for(let a of _(l.input,""))s.some(d=>d.name===a)||s.push({name:a,shape:j(l.input,a)});if(!s.every(a=>a.optional===!0?!0:a.kinds!==void 0?(a.candidates?.length??0)>0:(a.candidates?.length??0)>0||a.shape!==void 0&&a.shape.type!=="unknown")){let a=s.filter(d=>d.optional!==!0&&d.kinds!==void 0&&!d.kinds.includes("*")&&(d.candidates?.length??0)===0);if(a.length>0){let d=[...new Set(a.flatMap(m=>m.kinds??[]))].map(m=>W(F(e.schema.tryDefinition(m),m)));i.push({id:`schema:waits:${l.name}`,text:`"${l.title??l.name}" cannot begin until there is ${d.length===1?d[0]:`${d.slice(0,-1).join(", ")} and ${d[d.length-1]}`}.`,nodeIds:[]})}continue}c.push({id:`schema:add:${l.name}`,label:N(l),provider:"schema",mutation:l.name,args:{},open:s,score:B-s.length,why:`this makes ${(l.creates??[]).filter(a=>n.has(a)).map(a=>W(F(e.schema.tryDefinition(a),a))).join(", ")}`,nodeIds:[]})}return{affordances:c,observations:i}}if(t.length===0)return{};let w=new Set(t.map(n=>n.kind)),y=(n,i,l)=>{let s=[];for(let g of e.graph.allEdges()){if(!i.includes(g.kind))continue;let a=g.from===n?g.to:g.to===n?g.from:null;if(!a)continue;let d=e.graph.getNode(a);d&&(!l.includes("*")&&!l.includes(d.kind)||s.includes(a)||s.push(a))}return s};for(let n of e.allMutations()){let i=n.subject;if(!i||!(i.kinds==="*"?!0:[...w].every(u=>i.kinds.includes(u))))continue;let s=t.length===1?t[0].id:null,g=n.severs??[],a=n.connects??[];if(s&&g.length>0&&a.length===0&&y(s,g,["*"]).length===0)continue;let d=[];for(let u of x(n.input)){if(u.name===i.arg)continue;let p=u.kinds.includes("*")?e.graph.allNodes().map(S=>S.id):u.kinds.flatMap(S=>e.graph.nodesOfKind(S).map(A=>A.id));if(s&&a.length>0){let S=new Set(y(s,a,u.kinds));p=p.filter(A=>!S.has(A))}else s&&g.length>0&&(p=y(s,g,u.kinds));d.push({name:u.name,kinds:u.kinds,candidates:p.filter(S=>!o.includes(S)),shape:j(n.input,u.name),...u.optional?{optional:!0}:{}})}for(let u of _(n.input,i.arg))d.some(p=>p.name===u)||d.push({name:u,shape:j(n.input,u)});if(d.length===0&&s){let u=fn(n.input,i.arg);if(u.length>0&&!ln(e,n.name,{[i.arg]:s}))for(let p of u){let S=x(n.input).find(A=>A.name===p);d.push({name:p,optional:!0,...S?{kinds:S.kinds}:{},shape:j(n.input,p)})}}if(!d.every(u=>u.optional===!0?!0:u.kinds!==void 0?(u.candidates?.length??0)>0:(u.candidates?.length??0)>0||u.shape!==void 0&&u.shape.type!=="unknown"))continue;let v=t.map(u=>({[i.arg]:u.id}));d.length===0&&!v.some(u=>e.wouldChange({name:n.name,args:u}))||c.push({id:`schema:${n.name}`,label:t.length>1?`${N(n)} (${t.length})`:N(n),provider:"schema",mutation:n.name,args:v[0]??{},open:d,...n.destructive?{destructive:!0}:{},...g.length>0||a.length>0?{ties:!0}:{},...t.length>1?{batch:v}:{},score:B-d.length,why:t.length>1?`all ${t.length} selected nodes are ${[...w].map(u=>Q(e.schema,u).toLowerCase()).join(" or ")}`:`this is ${W(F(e.schema.tryDefinition(t[0].kind),t[0].kind))}`,nodeIds:t.map(u=>u.id)})}if(t.length===1){let n=t[0];for(let i of e.allMutations()){let l=i.subject,s=i.severs??[],g=i.connects??[];if(!l||s.length===0&&g.length===0)continue;let a=l.kinds==="*"?"*":l.kinds;if(a==="*"||a.includes(n.kind))continue;let d=x(i.input),m=d.find(h=>h.name!==l.arg&&(h.kinds.includes("*")||h.kinds.includes(n.kind)));if(!m)continue;let v=a,u=v.includes("*")?e.graph.allNodes().map(h=>h.id):v.flatMap(h=>e.graph.nodesOfKind(h).map(O=>O.id)),p=new Set(y(n.id,g.length>0?g:s,v)),S=g.length>0?u.filter(h=>!p.has(h)):u.filter(h=>p.has(h));if(S.length===0)continue;let A=[{name:l.arg,kinds:v,candidates:S,shape:j(i.input,l.arg)}];for(let h of d){if(h.name===m.name||h.name===l.arg)continue;let O=h.kinds.includes("*")?e.graph.allNodes().map(I=>I.id):h.kinds.flatMap(I=>e.graph.nodesOfKind(I).map(R=>R.id));A.push({name:h.name,kinds:h.kinds,candidates:O,shape:j(i.input,h.name),...h.optional?{optional:!0}:{}})}for(let h of _(i.input,m.name))h===l.arg||A.some(O=>O.name===h)||A.push({name:h,shape:j(i.input,h)});A.every(h=>h.optional===!0?!0:h.kinds!==void 0?(h.candidates?.length??0)>0:(h.candidates?.length??0)>0||h.shape!==void 0&&h.shape.type!=="unknown")&&c.push({id:`schema:tie:${i.name}:${n.id}`,label:i.fromTheOtherEnd??N(i),provider:"schema",mutation:i.name,args:{[m.name]:n.id},open:A,ties:!0,...i.destructive?{destructive:!0}:{},score:B-A.length+2,why:`${s.length>0?"this one is on":"this one could join"} ${A[0].candidates.length===1?"it":"one of these"}`,nodeIds:[n.id]})}}return{affordances:c}}}}function fn(e,o){let t=e.shape;return t?Object.entries(t).filter(([f,k])=>f!==o&&k.safeParse(void 0).success).map(([f])=>f):[]}function ln(e,o,t){try{return e.preview({name:o,args:t}),!0}catch{return!1}}function _(e,o){let t=e.shape;return t?Object.entries(t).filter(([f,k])=>f!==o&&!k.safeParse(void 0).success).map(([f])=>f):[]}var hn=70,gn=80,pn=new Set(["id","kind"]);function on(){return{name:"structure",derive({store:e,nodes:o}){let t=n=>E(e.schema.tryDefinition(n.kind),n);if(o.length<2)return{};let f=[],k=[],c=o.map(n=>n.id);for(let n of e.schema.edgeKinds){let i=mn(o.map(s=>new Set([...e.graph.out(s.id,n).map(g=>g.id),...e.graph.in(s.id,n).map(g=>g.id)])));for(let s of i){let g=e.graph.getNode(s);g&&f.push({id:`shared:${n}:${s}`,text:`all ${o.length} share "${t(g)}" (${z(n).toLowerCase()})`,nodeIds:[...c,s]})}let l=new Map;for(let s of o)for(let g of[...e.graph.out(s.id,n),...e.graph.in(s.id,n)])l.set(g.id,(l.get(g.id)??0)+1);for(let[s,g]of l){if(g!==o.length-1||o.length<3)continue;let a=e.graph.getNode(s);if(!a)continue;let d=o.find(m=>![...e.graph.out(m.id,n),...e.graph.in(m.id,n)].some(v=>v.id===s));if(d){f.push({id:`near-shared:${n}:${s}`,text:`all but "${t(d)}" share "${t(a)}" (${z(n).toLowerCase()})`,nodeIds:[...c,s]});for(let m of e.allMutations()){let v=m.subject;if(!v||v.kinds!=="*"&&!v.kinds.includes(d.kind))continue;let u=kn(m.input,a.kind);u&&k.push({id:`structure:join:${m.name}:${d.id}:${s}`,label:`${N(m)}: bring "${t(d)}" in line with the others`,provider:"structure",mutation:m.name,args:{[v.arg]:d.id,[u]:s},open:[],score:hn,why:`every other selected node is connected to "${t(a)}"`,nodeIds:[d.id,s]})}}}}let w=new Set;for(let n of o)for(let i of Object.keys(n))pn.has(i)||w.add(i);let y=n=>e.schema.definitions.find(i=>i.kind===n);for(let n of[...w].sort()){let i=y(o[0].kind),l=U(i,n).toLowerCase(),s=i?.display?.format?.[n],g=$=>{if(!s)return $;try{return String(s(JSON.parse($)))}catch{return $}},a=o.map($=>$[n]),d=new Map;if(a.forEach(($,h)=>{let O=JSON.stringify($??null),I=d.get(O);I?I.push(o[h]):d.set(O,[o[h]])}),d.size===1){let $=[...d.keys()][0];if($==="null")continue;f.push({id:`agree:${n}`,text:`all ${o.length} share the ${l} ${g($)}`,nodeIds:c});continue}if(o.length<3||d.size!==2)continue;let m=[...d.entries()].sort(($,h)=>h[1].length-$[1].length),[v,u]=m[0],[,p]=m[1];if(p.length!==1||v==="null")continue;let S=p[0],A=JSON.parse(v);f.push({id:`odd-one-out:${n}`,text:`${u.length} share the ${l} ${g(v)}; "${t(S)}" does not`,nodeIds:c});for(let $ of e.allMutations()){let h=$.subject;if(!h||h.kinds!=="*"&&!h.kinds.includes(S.kind))continue;let O=rn($.input);if(!O||!(n in O))continue;let I={[h.arg]:S.id,[n]:A},R=!0;for(let[M,J]of Object.entries(O)){if(M in I||J.safeParse(void 0).success)continue;let D=S[M];if(D===void 0){R=!1;break}I[M]=D}R&&k.push({id:`structure:align:${$.name}:${n}:${S.id}`,label:`Align the ${l} of "${t(S)}" with the other ${u.length}`,provider:"structure",mutation:$.name,args:I,open:[],score:gn,why:`${u.length} of ${o.length} share the ${l} ${g(v)}`,nodeIds:c})}}return{affordances:k,observations:f}}}}function mn(e){if(e.length===0)return[];let[o,...t]=e;return[...o].filter(f=>t.every(k=>k.has(f))).sort()}function rn(e){return e.shape??null}function kn(e,o){let t=rn(e);if(!t)return null;for(let[f]of Object.entries(t)){let k=X(t[f]);if(k&&(k.includes("*")||k.includes(o)))return f}return null}function yn(){return[tn(),on(),sn(),Y()]}function Kn(e,o,t={}){let f=an(),k=t.providers??yn(),c=o.map(r=>e.graph.getNode(r)).filter(r=>r!==void 0),w={store:e,selection:o,nodes:c,kindSelection:t.kindSelection??[],edgeSelection:t.edgeSelection??[],violations:e.violations(t.context),context:t.context??{}},y=[],n=[];for(let r of k){let b=r.derive(w);y.push(...b.affordances??[]),n.push(...b.observations??[])}let i=new Set(e.allMutations().filter(r=>r.pinned).map(r=>r.name)),l=new Set(t.pins?.pinned??[]),s=new Set(t.pins?.unpinned??[]),g=r=>l.has(r.mutation)?"user":i.has(r.mutation)&&!s.has(r.mutation)?"declared":void 0,a=r=>{let b=g(r);return b?{...r,pinned:b}:r},d=new Map;for(let[r,b]of nn(e.log.all()))d.set(r,en(b));let m=r=>r.pinned==="user"?0:r.pinned==="declared"?1:2,v=r=>r.score+(d.get(r.mutation)??0),u=new Map(e.allMutations().map(r=>[r.name,r])),p=new Map,S=r=>{let b=u.get(r.mutation);if(!b)return[];let P=p.get(r.mutation);P||(P=x(b.input).map(T=>T.name),p.set(r.mutation,P));let C=[];for(let T of r.batch??[r.args])for(let H of P){let Z=T[H]??r.args[H];typeof Z=="string"&&C.push(Z)}return C},A=t.focus,$=4,h=r=>r.open.length>0?1:0,O=r=>{if(A===void 0)return $;let b=S(r);return b.length>0?b.includes(A)?I(r,0):$:r.nodeIds.includes(A)||r.subjectId===A?I(r,1):$},I=(r,b)=>r.provider==="invariant"?b:2+h(r),R=bn(y).map(a),M=new Map(R.map((r,b)=>[r,b])),J=R.sort((r,b)=>{let P=Number(r.destructive??!1)-Number(b.destructive??!1);if(P!==0)return P;let C=O(r)-O(b);return C!==0?C:O(r)<2?M.get(r)-M.get(b):+(b.provider==="invariant")-+(r.provider==="invariant")||m(r)-m(b)||v(b)-v(r)||r.id.localeCompare(b.id)}),D=t.principal??{kind:"human"},L=[],G=[];for(let r of J){let b=e.permits({name:r.mutation,args:{...r.args,...r.batch?.[0]??{}}},D);if(b.ok)L.push(r);else{let P=Sn(e,r,D);if(P==="done")continue;P?L.push(P):G.push({...r,refusal:b.refusal})}}let q=L.map((r,b)=>({...r,rank:b})),dn=G.map((r,b)=>({...r,rank:L.length+b}));return{affordances:t.limit===void 0?q:q.slice(0,t.limit),withheld:dn,observations:vn(n),ms:an()-f}}function bn(e){let o=new Map;for(let t of e){let f=[t.mutation,JSON.stringify(t.args),JSON.stringify(t.batch??null)].join("|"),k=o.get(f);(!k||t.score>k.score)&&o.set(f,t)}return[...o.values()]}function vn(e){let o=new Map;for(let t of e)o.set(t.text,t);return[...o.values()]}function an(){return typeof performance<"u"?performance.now():Date.now()}function Wn(e,o,t={},f={}){let k=(o.batch??[o.args]).map(w=>({name:o.mutation,args:{...o.args,...w,...t}})),c=e.allMutations().find(w=>w.name===o.mutation);return e.applyAll(k,{...c?.describe?{}:{intent:o.label},...f.author?{author:f.author}:{}})}function Fn(e,o,t={}){return e.preview({name:o.mutation,args:{...o.args,...t}})}function Sn(e,o,t){let f=e.allMutations().find(n=>n.name===o.mutation)?.subject;if(!f||o.args[f.arg]!==void 0)return;let k=o.open.find(n=>n.name===f.arg);if(!k?.candidates)return;let c=n=>e.permits({name:o.mutation,args:{...o.args,...o.batch?.[0]??{},[f.arg]:n}},t).ok,w=k.candidates.filter(c),y=t.id===void 0?void 0:e.graph.getNode(t.id);return w.length===0?y!==void 0&&(f.kinds==="*"||f.kinds.includes(y.kind))&&c(y.id)?"done":void 0:w.length===1&&w[0]===t.id?{...o,args:{...o.args,[f.arg]:t.id},open:o.open.filter(n=>n!==k)}:{...o,open:o.open.map(n=>n===k?{...n,candidates:w}:n)}}export{Kn as a,Wn as b,Fn as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as g}from"./chunk.6LJ66MB7.js";import{za as w}from"./chunk.SVL6I37U.js";import{Rb as L}from"./chunk.P7YN4Z3K.js";import{a as C,b as V}from"./chunk.MRK6QJV5.js";import{b as u}from"./chunk.AJZBJBMO.js";var E="[data-graview-foot]",N="graview:foot-moved";var D=()=>({width:document.documentElement.clientWidth||innerWidth,height:innerHeight});function z(t,e){let o=D(),r=e?.getBoundingClientRect()??{left:0,top:0,right:o.width,bottom:o.height},i=Math.max(0,r.left),c=Math.min(o.width,r.right),s=Math.max(0,r.top),l=Math.min(o.height,r.bottom),m=Math.max(0,c-i),x=m<640;t.style.translate="none",t.style.top="auto",t.style.right="auto",t.style.maxWidth=`${Math.max(0,Math.min(560,m-2*16))}px`;let p=t.getBoundingClientRect();if(p.width===0&&p.height===0&&t.style.left!=="")return;let y=p.width,A=p.height;t.style.visibility=e&&l-s<A+16?"hidden":"";let h=x?i+(m-y)/2:i+16,f=o.height-l+16,v=[...document.querySelectorAll(E)].filter(n=>n!==t&&!t.contains(n)&&!n.contains(t)).map(n=>n.getBoundingClientRect()).filter(n=>n.width>0&&n.height>0&&n.right>i&&n.left<c&&n.bottom>s&&n.top<l),P=n=>n.bottom-n.top>(l-s)*.4;if(!x)for(let n of v)P(n)&&n.left<=h+1&&n.right+16>h&&n.right+16+y<=c&&(h=n.right+16);let R=v.filter(n=>!P(n));for(let n=!0,b=0;n&&b<R.length+1;b++){n=!1;for(let d of R){let M=o.height-f;d.right>h&&d.left<h+y&&d.bottom>M-A&&d.top<M&&(f=o.height-d.top+16/2,n=!0)}}t.style.left=`${Math.round(h)}px`,t.style.bottom=`calc(${Math.round(f)}px + env(safe-area-inset-bottom, 0px))`}function U(t,e){let o=D(),r=e?.getBoundingClientRect()??{left:0,top:0,right:o.width,bottom:o.height},i=Math.max(0,r.left),c=Math.min(o.width,r.right),s=Math.max(0,c-i);t.style.translate="none",t.style.bottom="auto",t.style.right="auto",t.style.maxWidth=`${Math.max(0,Math.min(560,s-2*16))}px`;let l=t.getBoundingClientRect().width;t.style.left=`${Math.round(i+(s-l)/2)}px`,t.style.top=`${Math.round(Math.max(16/2,r.top+16/2))}px`}var O=t=>`graview:lenses:${t}`,q=(t,e)=>t?.name??e.kinds.join(",");function k(t){try{let e=JSON.parse(localStorage.getItem(O(t))??"[]");return Array.isArray(e)?e.filter(o=>typeof o?.title=="string"&&typeof o.lens=="string"):[]}catch{return[]}}var S=u(C(),1);var a=u(V(),1),G=w(g(()=>import("./chunk.REODVRPZ.js")));function B({lens:t,view:e}){let o=G.current.declaredLensView(t);return(0,a.jsx)(o,{...e})}var K=G.part((t,e)=>(0,a.jsx)(B,{...e}),{what:"This picture"});function $(t){return o=>(0,a.jsx)(S.Suspense,{fallback:null,children:(0,a.jsx)(K,{lens:t,view:o})})}var T=w(g(()=>import("./chunk.PQ2IIC27.js")));function W({blocks:t,view:e}){let o=T.current.homeView(t);return(0,a.jsx)(o,{...e})}var _=T.part((t,e)=>(0,a.jsx)(W,{...e}),{what:"The home"});function F(t){let e=o=>(0,a.jsx)(S.Suspense,{fallback:null,children:(0,a.jsx)(_,{blocks:t,view:o})});return Object.defineProperty(e,Symbol.for("graview.home-blocks"),{value:!0}),e}function tt(t,e){return e.home&&e.home.length>0&&t.home?.(F(e.home)),H(t,e),t.arrange?.(e.pages),t}function H(t,e,o){for(let r of L(e).drawn){if(o&&t.places().some(s=>s.title===r.title))continue;let i=$(r),c={title:r.title,...r.across?{across:r.across}:{},...o?{beside:o}:{}};for(let s of r.kinds)t.register(s,{cardinality:"many",fidelity:"full"},i,c),t.register(s,{cardinality:"many",fidelity:"summary"},i,c)}}function I(t,e,o){o.length>0&&H(t,{schema:e,lenses:o.map(({lens:r,...i})=>({...i,name:r}))},!0)}function et(t,e,o){I(t,e,k(o))}export{N as a,z as b,U as c,O as d,q as e,k as f,tt as g,I as h,et as i};
|