@kanonak-protocol/sdk 3.31.0 → 3.33.0
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/chunk-PBJBNJUS.js +116 -0
- package/dist/index.js +1 -1
- package/dist/look/LookRenderer.d.ts +51 -0
- package/dist/transformations/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-DNV7ES5F.js +0 -116
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import{a as Q}from"./chunk-NIGFQYVA.js";import{a as G,c as Le}from"./chunk-4YHWMYAZ.js";import{c as X,d as R,g as A,h as oe,i as de,j as w,k as Z,l as E}from"./chunk-W6T7MOKY.js";function we(u){let e=u.replace(/\r\n/g,`
|
|
2
|
+
`).split(`
|
|
3
|
+
`),t=[],n=0;for(;n<e.length;){let s=e[n];if(s.trim()===""){n++;continue}let a=/^(\s*)```(\S*)\s*$/.exec(s);if(a){let i=a[2],c=[];for(n++;n<e.length&&!/^(\s*)```\s*$/.test(e[n]);)c.push(e[n]),n++;n++;let l=Ue(c.join(`
|
|
4
|
+
`)),d=i?` class="language-${Ie(i)}"`:"";t.push(`<pre><code${d}>${l}</code></pre>`);continue}let r=/^(#{1,6})\s+(.*)$/.exec(s);if(r){let i=r[1].length,c=te(r[2].trim());t.push(`<h${i}>${c}</h${i}>`),n++;continue}if(s.includes("|")&&n+1<e.length&&Oe(e[n+1])){let i=pe(s),c=Xe(e[n+1]);n+=2;let l=[];for(;n<e.length&&e[n].trim()!==""&&e[n].includes("|");)l.push(pe(e[n])),n++;t.push(Ze(i,c,l));continue}if(/^\s*[-*]\s+/.test(s)){let i=[];for(;n<e.length&&/^\s*[-*]\s+/.test(e[n]);){let c=[e[n].replace(/^\s*[-*]\s+/,"")];for(n++;n<e.length&&e[n].trim()!==""&&!/^\s*[-*]\s+/.test(e[n])&&!/^\s*\d+\.\s+/.test(e[n]);)c.push(e[n]),n++;n<e.length&&e[n].trim()===""&&n++,i.push(`<li>${te(c.join(" ").trim())}</li>`)}t.push(`<ul>
|
|
5
|
+
${i.join(`
|
|
6
|
+
`)}
|
|
7
|
+
</ul>`);continue}if(/^\s*\d+\.\s+/.test(s)){let i=[];for(;n<e.length&&/^\s*\d+\.\s+/.test(e[n]);){let c=[e[n].replace(/^\s*\d+\.\s+/,"")];for(n++;n<e.length&&e[n].trim()!==""&&!/^\s*\d+\.\s+/.test(e[n])&&!/^\s*[-*]\s+/.test(e[n]);)c.push(e[n]),n++;n<e.length&&e[n].trim()===""&&n++,i.push(`<li>${te(c.join(" ").trim())}</li>`)}t.push(`<ol>
|
|
8
|
+
${i.join(`
|
|
9
|
+
`)}
|
|
10
|
+
</ol>`);continue}let o=[s];for(n++;n<e.length&&e[n].trim()!==""&&!/^(#{1,6})\s+/.test(e[n])&&!/^(\s*)```/.test(e[n])&&!/^\s*[-*]\s+/.test(e[n])&&!/^\s*\d+\.\s+/.test(e[n])&&!(e[n].includes("|")&&n+1<e.length&&Oe(e[n+1]));)o.push(e[n]),n++;t.push(`<p>${te(o.join(" "))}</p>`)}return t.join(`
|
|
11
|
+
`)}function Oe(u){return u.includes("-")?/^[\s|:-]+$/.test(u):!1}function pe(u){let e=u.trim();return e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&(e=e.slice(0,-1)),e.split("|").map(t=>t.trim())}function Xe(u){return pe(u).map(e=>{let t=e.startsWith(":"),n=e.endsWith(":");return t&&n?"center":n?"right":t?"left":null})}function Ze(u,e,t){let n=r=>{let o=e[r];return o?` style="text-align:${o}"`:""},s=u.map((r,o)=>`<th${n(o)}>${te(r)}</th>`).join(""),a=t.map(r=>`<tr>${r.map((i,c)=>`<td${n(c)}>${te(i)}</td>`).join("")}</tr>`).join(`
|
|
12
|
+
`);return`<table>
|
|
13
|
+
<thead><tr>${s}</tr></thead>
|
|
14
|
+
<tbody>
|
|
15
|
+
${a}
|
|
16
|
+
</tbody>
|
|
17
|
+
</table>`}function te(u){let e=Ue(u);return e=e.replace(/`([^`\n]+)`/g,(t,n)=>`<code>${n}</code>`),e=e.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(t,n,s)=>`<a href="${Ie(s)}">${n}</a>`),e=e.replace(/\*\*([^*\n]+)\*\*/g,(t,n)=>`<strong>${n}</strong>`),e=e.replace(/(^|[^*])\*([^*\n]+)\*(?!\*)/g,(t,n,s)=>`${n}<em>${s}</em>`),e=e.replace(/(^|[\s(])_([^_\n]+)_(?=[\s).,;:!?]|$)/g,(t,n,s)=>`${n}<em>${s}</em>`),e}function Ue(u){return u.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ie(u){return u.replace(/"/g,""").replace(/&/g,"&")}var ke={publisher:"kanonak.org",package_:"derivation",name:"look"},ge={publisher:"kanonak.org",package_:"derivation",name:"tokens"},V={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},M={publisher:"kanonak.org",package_:"core-rdf",name:"label"},xe={publisher:"kanonak.org",package_:"core-rdf",name:"comment"},Qe={publisher:"kanonak.org",package_:"look",name:"Hero"},en={publisher:"kanonak.org",package_:"look",name:"PropertyList"},nn={publisher:"kanonak.org",package_:"look",name:"BadgeRow"},tn={publisher:"kanonak.org",package_:"look",name:"ChipRow"},sn={publisher:"kanonak.org",package_:"look",name:"ReferenceList"},Fe={publisher:"kanonak.org",package_:"look",name:"Markdown"},ie={publisher:"kanonak.org",package_:"look",name:"NavGroup"},he={publisher:"kanonak.org",package_:"look",name:"NavLink"},Ee={publisher:"kanonak.org",package_:"look",name:"target"},rn={publisher:"kanonak.org",package_:"look",name:"ResourceGrid"},an={publisher:"kanonak.org",package_:"look",name:"Timeline"},on={publisher:"kanonak.org",package_:"look",name:"VersionDiff"},cn={publisher:"kanonak.org",package_:"look",name:"Figure"},ln={publisher:"kanonak.org",package_:"look",name:"StatRow"},un={publisher:"kanonak.org",package_:"look",name:"Horizon"},fn={publisher:"kanonak.org",package_:"look",name:"stats"},dn={publisher:"kanonak.org",package_:"look",name:"statPath"},pn={publisher:"kanonak.org",package_:"look",name:"statLabel"},kn={publisher:"kanonak.org",package_:"look",name:"labelPath"},gn={publisher:"kanonak.org",package_:"look",name:"badgePath"},Te={publisher:"kanonak.org",package_:"look",name:"orderBy"},Pe={publisher:"kanonak.org",package_:"look",name:"track"},Ce={publisher:"kanonak.org",package_:"look",name:"metricPath"},Ne={publisher:"kanonak.org",package_:"look",name:"hueBy"},hn={publisher:"kanonak.org",package_:"look",name:"lowerPath"},mn={publisher:"kanonak.org",package_:"look",name:"upperPath"},bn={publisher:"kanonak.org",package_:"look",name:"axisMin"},jn={publisher:"kanonak.org",package_:"look",name:"axisMax"},_n={publisher:"kanonak.org",package_:"look",name:"valueLabel"};var $n={publisher:"kanonak.org",package_:"look",name:"semanticSvg"},vn={publisher:"kanonak.org",package_:"look",name:"tierChip"},Rn={publisher:"kanonak.org",package_:"look",name:"tierIcon"},Kn={publisher:"kanonak.org",package_:"look",name:"tierCard"},Sn={publisher:"kanonak.org",package_:"look",name:"tierFull"};var me={publisher:"kanonak.org",package_:"look",name:"bands"},yn={publisher:"kanonak.org",package_:"look",name:"title"},Ln={publisher:"kanonak.org",package_:"look",name:"eyebrow"},On={publisher:"kanonak.org",package_:"look",name:"subtitle"},Ae={publisher:"kanonak.org",package_:"look",name:"badges"},T={publisher:"kanonak.org",package_:"look",name:"source"},wn={publisher:"kanonak.org",package_:"look",name:"chips"},be={publisher:"kanonak.org",package_:"look",name:"entries"},Un={publisher:"kanonak.org",package_:"look",name:"urlForm"},ve=class{constructor(e){this.catalog=e}catalog;findCascadedLook(e){let t=_e(e);if(t)return{declaration:t,sourceClass:{publisher:q(e),package_:(e.namespace||"").split("/")[1]?.split("@")[0]??"",name:e.name}};let n=new Set,s=W(e);for(;s.length>0;){let a=s.shift(),r=ee(a.subject);if(n.has(r))continue;n.add(r);let o=y(this.catalog,a.subject);if(!o)continue;let i=_e(o);if(i)return{declaration:i,sourceClass:{publisher:a.subject.publisher,package_:a.subject.package_,name:a.subject.name}};for(let c of ce(o))s.push(c)}if(!n.has(ee(V))){let a=y(this.catalog,V);if(a){let r=_e(a);if(r)return{declaration:r,sourceClass:{...V}}}}}findCascadedTokens(e){let t=new Map;for(let[a,r]of je(e))t.has(a)||t.set(a,r);let n=new Set,s=W(e);for(;s.length>0;){let a=s.shift(),r=ee(a.subject);if(n.has(r))continue;n.add(r);let o=le(this.catalog,a.subject);if(o.length!==0)for(let i of o){for(let[c,l]of je(i))t.has(c)||t.set(c,l);for(let c of ce(i))s.push(c)}}if(!n.has(ee(V))){let a=le(this.catalog,V);for(let r of a)for(let[o,i]of je(r))t.has(o)||t.set(o,i)}return t}renderSvg(e){let t=j(e,M)??e.name,n=(t.trim().charAt(0)||"?").toUpperCase(),s=`${e.namespace??""}/${e.name}`,a={label:t,firstLetter:n,uri:s},r=this.collectCascadedSvgTiers(e),o=m=>this.applyPlaceholders(m,e,a),i=o(r.tierChip??""),c=o(r.tierIcon??""),l=o(r.tierCard??""),d=o(r.tierFull??""),p=[...this.findCascadedTokens(e)].map(([m,b])=>`--kan-${m}: ${b};`).join(" ");return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400" width="400" height="400" style="${se(p)}">
|
|
18
|
+
<style>
|
|
19
|
+
.tier-chip,.tier-icon,.tier-card{display:none}
|
|
20
|
+
.tier-full{display:block}
|
|
21
|
+
@media (max-width:400px){.tier-full{display:none}.tier-card{display:block}}
|
|
22
|
+
@media (max-width:160px){.tier-card{display:none}.tier-icon{display:block}}
|
|
23
|
+
@media (max-width:60px){.tier-icon{display:none}.tier-chip{display:block}}
|
|
24
|
+
</style>
|
|
25
|
+
<g class="tier-chip">${i}</g>
|
|
26
|
+
<g class="tier-icon">${c}</g>
|
|
27
|
+
<g class="tier-card">${l}</g>
|
|
28
|
+
<g class="tier-full">${d}</g>
|
|
29
|
+
</svg>`}applyPlaceholders(e,t,n){return e.replace(/\{\{([^}]+)\}\}/g,(s,a)=>{let r=a.trim();if(n[r]!==void 0)return se(n[r]);let o=this.resolvePath(t,r);return o===void 0?`{{${r}}}`:se(o)})}resolvePath(e,t){let n=t.split("/").map(o=>o.trim()).filter(o=>o.length>0);if(n.length===0)return;let s=e;for(let o=0;o<n.length-1;o++){if(!s)return;let i=Be(n[o]),c=De(s,i);if(!c)return;if(c instanceof w&&c.object instanceof R){let l=y(this.catalog,c.object.subject);if(!l)return;s=l}else if(c instanceof Z)s=c.object;else return}if(!s)return;let a=Be(n[n.length-1]),r=De(s,a);if(r){if(r instanceof A||r instanceof oe||r instanceof de)return String(r.object);if(r instanceof w&&r.object instanceof R){let o=r.object,i=y(this.catalog,o.subject);return i?j(i,M)??o.subject.name:o.subject.name}}}collectCascadedSvgTiers(e){let t={},n=r=>{let o=H(r,$n);if(!(o instanceof Z))return;let i=o.object,c=j(i,vn),l=j(i,Rn),d=j(i,Kn),k=j(i,Sn);t.tierChip===void 0&&c!==void 0&&(t.tierChip=c),t.tierIcon===void 0&&l!==void 0&&(t.tierIcon=l),t.tierCard===void 0&&d!==void 0&&(t.tierCard=d),t.tierFull===void 0&&k!==void 0&&(t.tierFull=k)};n(e);let s=new Set,a=W(e);for(;a.length>0;){let r=a.shift(),o=ee(r.subject);if(s.has(o))continue;s.add(o);let i=le(this.catalog,r.subject);for(let c of i){n(c);for(let l of ce(c))a.push(l)}}if(!s.has(ee(V)))for(let r of le(this.catalog,V))n(r);return t}renderStylesheet(e){let t=this.findCascadedTokens(e),n=[];for(let[r,o]of t)n.push(` --kan-${r}: ${o};`);let s=n.length>0?`:root {
|
|
30
|
+
${n.join(`
|
|
31
|
+
`)}
|
|
32
|
+
}`:":root { /* no tokens resolved */ }",a=this.findBaseStylesheet(q(e))??"";return`${s}
|
|
33
|
+
${a}`}findBaseStylesheet(e){let t="kanonak.org/site/content",n,s;for(let r of this.catalog){if(!(r instanceof X)||r.name!=="base-stylesheet")continue;let o=r.namespace||"";o.startsWith(`${e}/look-styles@`)?n=r:o.startsWith("kanonak.org/look-styles@")&&(s=r)}let a=n??s;if(a)for(let r of a.statement){let o=r.predicate?.subject;if(!o)continue;if(`${o.publisher}/${o.package_}/${o.name}`===t&&r instanceof A)return r.object}}renderHtml(e){let t=this.findCascadedLook(e);if(!t)return`<!-- LookRenderer: no derivation.look found for ${e.namespace}/${e.name} -->`;let n=Ve(t.declaration);if(n.length===0)return"<!-- LookRenderer: look declaration has no bands -->";let s=q(e),a=[];for(let r of n)a.push(this.renderBand(r,e,s));return a.join(`
|
|
34
|
+
`)}renderPublisherIndex(e,t,n){let s=n?this.renderNavGroup(n,e):"",a=t.map(o=>{let i=o.comment?`<p class="kan-resource-card-subtitle">${f(o.comment)}</p>`:"";return`<a class="kan-resource-card" href="${f(o.href)}"><h3 class="kan-resource-card-title">${f(o.label)}</h3>${i}</a>`}).join(`
|
|
35
|
+
`),r=`<header class="kan-hero">
|
|
36
|
+
<h1 class="kan-hero-title">${f(e)}</h1>
|
|
37
|
+
</header>
|
|
38
|
+
<section class="kan-resource-grid">
|
|
39
|
+
${a}
|
|
40
|
+
</section>`;return`<!doctype html>
|
|
41
|
+
<html lang="en">
|
|
42
|
+
<head>
|
|
43
|
+
<meta charset="utf-8">
|
|
44
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
45
|
+
<title>${f(e)}</title>
|
|
46
|
+
<link rel="stylesheet" href="index.css">
|
|
47
|
+
</head>
|
|
48
|
+
<body>
|
|
49
|
+
${s}
|
|
50
|
+
<main class="kan-main">
|
|
51
|
+
${r}
|
|
52
|
+
</main>
|
|
53
|
+
</body>
|
|
54
|
+
</html>
|
|
55
|
+
`}renderPublisherIndexStylesheet(e){return e?this.renderStylesheet(e):""}hasDeclaredView(e){let t=this.findCascadedLook(e);return t?!(t.sourceClass.publisher===V.publisher&&t.sourceClass.package_===V.package_&&t.sourceClass.name===V.name):!1}renderPackageVersionList(e,t,n){let s=q(n),a=this.renderNavGroup(n,s),r=this.renderBreadcrumb(n,s,{bareOverview:!0}),o=t.map(c=>`<a class="kan-resource-card" href="/${f(e)}/${f(c)}/"><h3 class="kan-resource-card-title">${f(c)}</h3></a>`).join(`
|
|
56
|
+
`),i=`<header class="kan-hero">
|
|
57
|
+
<span class="kan-hero-eyebrow">PACKAGE</span>
|
|
58
|
+
<h1 class="kan-hero-title">${f(e)}</h1>
|
|
59
|
+
</header>
|
|
60
|
+
<section class="kan-resource-grid">
|
|
61
|
+
${o}
|
|
62
|
+
</section>`;return`<!doctype html>
|
|
63
|
+
<html lang="en">
|
|
64
|
+
<head>
|
|
65
|
+
<meta charset="utf-8">
|
|
66
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
67
|
+
<title>${f(e)}</title>
|
|
68
|
+
<link rel="stylesheet" href="${f(n.name)}.css">
|
|
69
|
+
</head>
|
|
70
|
+
<body>
|
|
71
|
+
${a}
|
|
72
|
+
${r}
|
|
73
|
+
<main class="kan-main">
|
|
74
|
+
${i}
|
|
75
|
+
</main>
|
|
76
|
+
</body>
|
|
77
|
+
</html>
|
|
78
|
+
`}renderDocument(e,t){let n=this.renderHtml(e),s=this.readPropertyValueText(e,M)??e.name,a=`${e.name}.css`,r=this.hasSvgDerivation(e)?`<figure class="kan-figure"><img src="${f(e.name)}.svg" alt=""></figure>
|
|
79
|
+
`:"",o=q(e),i=this.renderNavGroup(e,o),c=this.renderBreadcrumb(e,o,t);return`<!doctype html>
|
|
80
|
+
<html lang="en">
|
|
81
|
+
<head>
|
|
82
|
+
<meta charset="utf-8">
|
|
83
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
84
|
+
<title>${f(s)}</title>
|
|
85
|
+
<link rel="stylesheet" href="${f(a)}">
|
|
86
|
+
</head>
|
|
87
|
+
<body>
|
|
88
|
+
${i}
|
|
89
|
+
${c}
|
|
90
|
+
<main class="kan-main">
|
|
91
|
+
${r}${n}
|
|
92
|
+
</main>
|
|
93
|
+
</body>
|
|
94
|
+
</html>
|
|
95
|
+
`}hasSvgDerivation(e){let t=new Set,n=W(e);for(;n.length>0;){let s=n.shift(),a=ee(s.subject);if(t.has(a))continue;t.add(a);let r=y(this.catalog,s.subject);if(r){for(let o of r.statement)if(o instanceof E&&B(o,"kanonak.org","derivation","derivations")){for(let i of o.object??[])if(i instanceof G)for(let c of i.statement){if(!(c instanceof w)||!B(c,"kanonak.org","derivation","format")||!(c.object instanceof R))continue;let l=c.object.subject;if(l.publisher==="kanonak.org"&&l.package_==="formats"&&l.name==="svg")return!0}}for(let o of ce(r))n.push(o)}}return!1}renderBand(e,t,n){let s=$e(e);return s?U(s,Qe)?this.renderHero(e,t,n):U(s,en)?this.renderPropertyList(e,t,n):U(s,nn)?this.renderBadgeRow(e,t,n):U(s,tn)?this.renderChipRow(e,t,n):U(s,sn)?this.renderReferenceList(e,t,n):U(s,Fe)?this.renderMarkdown(e,t,n):U(s,ie)?this.renderNavGroup(t,n):U(s,rn)?this.renderResourceGrid(e,n,t):U(s,an)?this.renderTimeline(e,n):U(s,on)?this.renderVersionDiff(e,n):U(s,cn)?this.renderFigure(e,t,n):U(s,ln)?this.renderStatRow(e,t):U(s,un)?this.renderHorizon(e,t,n):`<!-- LookRenderer: unsupported band ${s.publisher}/${s.package_}/${s.name} -->`:"<!-- LookRenderer: band has no rdf:type -->"}collectTrackedSeries(e,t,n,s){let{hueBy:a,lowerPath:r,upperPath:o}=s??{},i=new Map,c=e.length,l=(d,k)=>{let p=this.resolvePath(d,k);return p===void 0?NaN:parseFloat(p)};return e.forEach((d,k)=>{let p=this.readPropertyValueReferences(d,t);for(let m of p){let b=y(this.catalog,{publisher:m.subject.publisher,package_:m.subject.package_,name:m.subject.name,...m.subject.version?{version:m.subject.version}:{}});if(!b)continue;let h=m.subject.name,_=i.get(h);_||(_={key:h,label:j(b,M)??h,points:new Array(c).fill(null),...r?{lower:new Array(c).fill(null)}:{},...o?{upper:new Array(c).fill(null)}:{}},i.set(h,_));let S=l(b,n);if(Number.isFinite(S)&&(_.points[k]=S),r&&_.lower){let $=l(b,r);Number.isFinite($)&&(_.lower[k]=$)}if(o&&_.upper){let $=l(b,o);Number.isFinite($)&&(_.upper[k]=$)}if(a){let $=l(b,a);Number.isFinite($)&&(_.hue=$)}_.lastSubject=b}}),[...i.values()]}hrefForSubject(e,t,n="="){let s=e.namespace||"",a=s.split("/")[1]?.split("@")[0]??"",r=s.split("@")[1]??"",o=r?this.parseVersion(r):void 0;return Q.formatResourceUrl({publisher:q(e),package_:a,name:e.name,...o?{version:o}:{}},n,{contextPublisher:t})}renderVersionDiff(e,t){let n=K(e,T);if(!n)return"<!-- LookRenderer.VersionDiff: no look.source -->";let s=j(e,Ce),a=K(e,Pe);if(!a||!s)return"<!-- LookRenderer.VersionDiff: needs look.track + look.metricPath -->";let r=K(e,Te),o=j(e,Ne),i=this.findInstancesOfClass(n);if(i.length===0)return"<!-- LookRenderer.VersionDiff: no instances -->";let c=p=>r?this.readPropertyValueText(p,r)??"":"",l=i.slice().sort((p,m)=>c(p).localeCompare(c(m))),d=this.collectTrackedSeries(l,a,s,{hueBy:o});return d.length===0?"<!-- LookRenderer.VersionDiff: no tracked series -->":`<section class="kan-vdiff">${d.map((p,m)=>{let b=p.hue!==void 0?p.hue:Math.round(m*360/d.length),h=p.points.filter(z=>z!==null);if(h.length===0)return"";let _=h[0],S=h[h.length-1],$=S-_,P;if(Math.abs($)>=.005){let z=$>0?"up":"down",Y=$>0?"\u25B2":"\u25BC";P=`<span class="kan-vdiff-delta ${z}">${$>0?"+":""}${$.toFixed(2)} ${Y}</span>`}else P='<span class="kan-vdiff-delta flat">\u2014</span>';let ne=p.lastSubject?`<a href="${f(this.hrefForSubject(p.lastSubject,t))}">${f(p.label)}</a>`:f(p.label);return`<div class="kan-vdiff-row" style="--kan-vdiff-hue:${b}"><span class="kan-vdiff-label">${ne}</span><span class="kan-vdiff-start">${_.toFixed(2)}</span>`+this.sparkline(p.points,b)+`<span class="kan-vdiff-end">${S.toFixed(2)}</span>`+P+"</div>"}).join("")}</section>`}sparkline(e,t){let r=`hsl(${t},65%,60%)`,o=e.filter(h=>h!==null);if(o.length===0)return'<svg class="kan-vdiff-spark" viewBox="0 0 132 30" xmlns="http://www.w3.org/2000/svg"></svg>';let i=Math.min(...o),l=Math.max(...o)-i,d=e.length,k=h=>d<=1?132/2:4+h/(d-1)*124,p=h=>l<1e-9?30/2:26-(h-i)/l*22,m=[],b=[];return e.forEach((h,_)=>{if(h===null)return;let S=k(_),$=p(h);m.push(`${S.toFixed(1)},${$.toFixed(1)}`),b.push(`<circle cx="${S.toFixed(1)}" cy="${$.toFixed(1)}" r="2" fill="${r}"/>`)}),`<svg class="kan-vdiff-spark" viewBox="0 0 132 30" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg" role="img"><polyline points="${m.join(" ")}" fill="none" stroke="${r}" stroke-width="1.5" stroke-linejoin="round" stroke-linecap="round"/>`+b.join("")+"</svg>"}svgUrlForSubject(e,t,n="="){return`${this.hrefForSubject(e,t,n)}.svg`}renderFigure(e,t,n){let s=t,a=K(e,T);if(a){let i=y(this.catalog,a);i&&(s=i)}let r=this.svgUrlForSubject(s,n),o=j(s,M)??s.name;return`<figure class="kan-figure"><img class="kan-figure-img" src="${f(r)}" alt="${f(o)}" loading="lazy"/></figure>`}renderStatRow(e,t){let n=H(e,fn),s=this.gatherValueItems(n).filter(r=>r instanceof G);if(s.length===0)return"<!-- LookRenderer.StatRow: no look.stats -->";let a=[];for(let r of s){let o=j(r,dn);if(!o)continue;let i=this.resolvePath(t,o);if(i===void 0)continue;let c=j(r,pn)??"";a.push('<div class="kan-stat">'+(c?`<span class="kan-stat-label">${f(c)}</span>`:"")+`<span class="kan-stat-val">${f(i)}</span></div>`)}return a.length===0?"":`<div class="kan-stat-row">${a.join("")}</div>`}renderHorizon(e,t,n){let s=K(e,T);if(!s)return"<!-- LookRenderer.Horizon: no look.source -->";let a=this.gatherValueItems(H(t,s)).filter(o=>o instanceof G);return a.length===0?"":`<section class="kan-horizon">${a.map(o=>this.renderConditionNode(o,n,0)).join("")}</section>`}renderConditionNode(e,t,n){let s=$e(e),a=s?this.readLabelForUri({publisher:s.publisher,package_:s.package_,name:s.name})??s.name:"Condition",r=[],o=[];for(let l of e.statement){let d=l.predicate?.subject;if(!d||d.name==="type")continue;let k=this.readLabelForUri({publisher:d.publisher,package_:d.package_,name:d.name})??d.name;if(l instanceof A||l instanceof oe||l instanceof de)r.push(`<div class="kan-cond-field"><span class="kan-cond-key">${f(k)}</span><span class="kan-cond-v">${f(String(l.object))}</span></div>`);else if(l instanceof w&&l.object instanceof R){let p=l.object.subject,m=this.readLabelForUri({publisher:p.publisher,package_:p.package_,name:p.name})??p.name;r.push(`<div class="kan-cond-field"><span class="kan-cond-key">${f(k)}</span><span class="kan-cond-v">${f(m)}</span></div>`)}else if(l instanceof Z)o.push(this.renderConditionNode(l.object,t,n+1));else if(l instanceof E)for(let p of l.object??[])p instanceof G&&o.push(this.renderConditionNode(p,t,n+1))}let i=r.length?`<div class="kan-cond-fields">${r.join("")}</div>`:"",c=o.length?`<div class="kan-cond-children">${o.join("")}</div>`:"";return`<div class="kan-cond"><div class="kan-cond-type">${f(a)}</div>${i}${c}</div>`}renderTimeline(e,t){let n=K(e,T);if(!n)return"<!-- LookRenderer.Timeline: no look.source -->";let s=K(e,Te),a=this.findInstancesOfClass(n);if(a.length===0)return"<!-- LookRenderer.Timeline: no instances -->";let r=d=>s?this.readPropertyValueText(d,s)??"":"",o=a.slice().sort((d,k)=>r(d).localeCompare(r(k))),i=K(e,Pe),c=j(e,Ce);return i&&c?this.renderTrajectoryChart(o,i,c,e,t,r):`<section class="kan-timeline"><ol>
|
|
96
|
+
${o.map(d=>{let k=d.namespace||"",p=k.split("/")[1]?.split("@")[0]??"",m=k.split("@")[1]??"",b=m?this.parseVersion(m):void 0,h=Q.formatResourceUrl({publisher:q(d),package_:p,name:d.name,...b?{version:b}:{}},"=",{contextPublisher:t}),_=r(d),S=_?`<span class="kan-timeline-date">${f(_)}</span>`:"",$=m||d.name;return`<li class="kan-timeline-node"><a href="${f(h)}"><span class="kan-timeline-key">${f($)}</span>${S}</a></li>`}).join(`
|
|
97
|
+
`)}
|
|
98
|
+
</ol></section>`}renderTrajectoryChart(e,t,n,s,a,r){let o=s,i=j(o,Ne),c=j(o,hn),l=j(o,mn),d=j(o,_n),k=He(o,bn),p=He(o,jn),m=e.length,b=this.collectTrackedSeries(e,t,n,{hueBy:i,lowerPath:c,upperPath:l});if(b.length===0)return"<!-- LookRenderer.Timeline: no tracked series -->";let h=[];for(let g of b){for(let v of g.points)v!==null&&h.push(v);for(let v of g.lower??[])v!==null&&h.push(v);for(let v of g.upper??[])v!==null&&h.push(v)}if(h.length===0)return"<!-- LookRenderer.Timeline: no metric values -->";let _=Math.min(...h),S=Math.max(...h);S-_<1e-9&&(_-=.5,S+=.5);let $=(S-_)*.08,P=k!==void 0?k:_-$,ne=p!==void 0?p:S+$;ne-P<1e-9&&(ne=P+1);let z=1e3,Y=440,L={top:28,right:24,bottom:56,left:52},Re=z-L.left-L.right,Ge=Y-L.top-L.bottom,re=g=>m<=1?L.left+Re/2:L.left+g/(m-1)*Re,ae=g=>L.top+(1-(g-P)/(ne-P))*Ge,ue=(g,v)=>g.hue!==void 0?g.hue:Math.round(v*360/b.length),fe=[];for(let g=0;g<5;g++){let v=P+g*(ne-P)/4,C=ae(v);fe.push(`<line x1="${L.left}" y1="${C.toFixed(1)}" x2="${(z-L.right).toFixed(1)}" y2="${C.toFixed(1)}" class="kan-fan-grid"/>`),fe.push(`<text x="${(L.left-8).toFixed(1)}" y="${(C+4).toFixed(1)}" class="kan-fan-axis" text-anchor="end">${v.toFixed(2)}</text>`)}let Ke=[];e.forEach((g,v)=>{let C=this.hrefForSubject(g,a),I=(g.namespace||"").split("@")[1]??"",O=re(v),x=In(r(g));Ke.push(`<a href="${f(C)}" class="kan-fan-xtick"><line x1="${O.toFixed(1)}" y1="${L.top}" x2="${O.toFixed(1)}" y2="${(Y-L.bottom).toFixed(1)}" class="kan-fan-vline"/><text x="${O.toFixed(1)}" y="${(Y-L.bottom+20).toFixed(1)}" class="kan-fan-xlabel" text-anchor="middle">${se(I||g.name)}</text>`+(x?`<text x="${O.toFixed(1)}" y="${(Y-L.bottom+36).toFixed(1)}" class="kan-fan-xdate" text-anchor="middle">${se(x)}</text>`:"")+"</a>")});let Se=[];b.forEach((g,v)=>{if(!g.lower||!g.upper)return;let C=ue(g,v),I=[],O=[];for(let F=0;F<m;F++){let J=g.upper[F],D=g.lower[F];J==null||D===null||D===void 0||(I.push(`${re(F).toFixed(1)},${ae(J).toFixed(1)}`),O.unshift(`${re(F).toFixed(1)},${ae(D).toFixed(1)}`))}let x=I.concat(O);x.length<3||Se.push(`<polygon class="kan-fan-band" points="${x.join(" ")}" fill="hsl(${C},65%,60%)"/>`)});let ye=[];b.forEach((g,v)=>{let I=`hsl(${ue(g,v)},65%,60%)`,O=[],x=[];g.points.forEach((F,J)=>{if(F===null)return;let D=re(J),N=ae(F);O.push(`${D.toFixed(1)},${N.toFixed(1)}`),x.push(`<circle cx="${D.toFixed(1)}" cy="${N.toFixed(1)}" r="3.5" fill="${I}"/>`)}),O.length!==0&&ye.push(`<g class="kan-fan-series" data-series="${f(g.key)}"><polyline points="${O.join(" ")}" fill="none" stroke="${I}" stroke-width="2" stroke-linejoin="round" stroke-linecap="round"/>`+x.join("")+"</g>")});let We=`<svg class="kan-fan-svg" viewBox="0 0 ${z} ${Y}" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" role="img">`+fe.join("")+Ke.join("")+Se.join("")+ye.join("")+"</svg>",qe=d?`${f(d)}=`:"",ze=b.map((g,v)=>{let C=ue(g,v),I=g.points.filter(N=>N!==null),O=I.length?I[0]:void 0,x=I.length?I[I.length-1]:void 0,F="";if(x!==void 0&&O!==void 0){let N=x-O;if(Math.abs(N)>=.005){let Ye=N>0?"up":"down",Je=N>0?"\u25B2":"\u25BC";F=` <span class="kan-fan-delta ${Ye}">${N>0?"+":""}${N.toFixed(2)} ${Je}</span>`}else F=' <span class="kan-fan-delta flat">\u2014</span>'}let J=x!==void 0?`${qe}${x.toFixed(2)}`:"\u2014",D=g.lastSubject?`<a href="${f(this.hrefForSubject(g.lastSubject,a))}">${f(g.label)}</a>`:f(g.label);return`<div class="kan-fan-legend-item" style="--kan-fan-hue:${C}"><span class="kan-fan-swatch"></span><span class="kan-fan-legend-label">${D}</span><span class="kan-fan-legend-cur">${J}${F}</span></div>`});return`<section class="kan-fan"><div class="kan-fan-chart">${We}</div><div class="kan-fan-legend">${ze.join("")}</div></section>`}renderResourceGrid(e,t,n){let s=K(e,T);if(!s)return"<!-- LookRenderer.ResourceGrid: no look.source -->";let a=y(this.catalog,s),r=a?W(a).some(c=>{let l=c.subject.name;return l==="ObjectProperty"||l==="DatatypeProperty"||l==="Property"}):!1,o=[];if(r&&n){let c=this.readPropertyValueReferences(n,s);for(let l of c){let d=y(this.catalog,{publisher:l.subject.publisher,package_:l.subject.package_,name:l.subject.name,...l.subject.version?{version:l.subject.version}:{}});d&&o.push(d)}}else o=this.findInstancesOfClass(s);if(o.length===0)return`<!-- LookRenderer.ResourceGrid: no resources for ${s.publisher}/${s.package_}/${s.name} -->`;let i=[];for(let c of o){let l=j(c,M)??c.name,d=j(c,xe),k=c.namespace||"",p=k.split("/")[1]?.split("@")[0]??"",m=k.split("@")[1]??"",b=m?this.parseVersion(m):void 0,h=Q.formatResourceUrl({publisher:q(c),package_:p,name:c.name,...b?{version:b}:{}},"=",{contextPublisher:t}),_=d?`<p class="kan-resource-card-subtitle">${f(d)}</p>`:"";i.push(`<a class="kan-resource-card" href="${f(h)}"><h3 class="kan-resource-card-title">${f(l)}</h3>${_}</a>`)}return`<section class="kan-resource-grid">
|
|
99
|
+
${i.join(`
|
|
100
|
+
`)}
|
|
101
|
+
</section>`}parseVersion(e){let t=e.split(".").map(Number);if(!(t.length!==3||t.some(n=>Number.isNaN(n))))return{major:t[0],minor:t[1],patch:t[2]}}findInstancesOfClass(e){let t=[];for(let n of this.catalog){if(!(n instanceof X))continue;W(n).map(r=>r.subject).some(r=>r.publisher===e.publisher&&r.package_===e.package_&&r.name===e.name)&&t.push(n)}return t}renderBreadcrumb(e,t,n){let a=(e.namespace||"").split("/");if(a.length<2)return"";let r=a[0],o=a[1]??"",i=o.split("@")[0]??"",c=o.split("@")[1]??"";if(!r||!i)return"";if(n?.bareOverview)return`<nav class="kan-breadcrumb"><ol>
|
|
102
|
+
<li><a href="/">${f(r)}</a></li>
|
|
103
|
+
<li aria-current="page">${f(i)}</li>
|
|
104
|
+
</ol></nav>`;let l=e.name,k=!!y(this.catalog,{publisher:r,package_:i,name:i}),p=c?`${i}@${c}`:i,m=c?`/${i}/${c}/${i}`:`/${i}/${i}`,b=e.name===i,h=[];return h.push(`<li><a href="/">${f(r)}</a></li>`),b?h.push(`<li aria-current="page">${f(p)}</li>`):(h.push(k?`<li><a href="${f(m)}">${f(p)}</a></li>`:`<li>${f(p)}</li>`),h.push(`<li aria-current="page">${f(l)}</li>`)),`<nav class="kan-breadcrumb"><ol>
|
|
105
|
+
${h.join(`
|
|
106
|
+
`)}
|
|
107
|
+
</ol></nav>`}renderNavGroup(e,t){let n=this.findNavGroupForPublisher(t);if(!n)return"";let s=H(n,be);if(!(s instanceof E))return"";let a=s.object??[];if(a.length===0)return"";let r=[];for(let o of a){if(!(o instanceof R))continue;let i=y(this.catalog,{publisher:o.subject.publisher,package_:o.subject.package_,name:o.subject.name}),{href:c,label:l}=this.resolveNavEntry(o,i,t),d=`/${e.namespace?.split("/")[1]?.split("@")[0]}/${(e.namespace||"").split("@")[1]}/${e.name}`,k=c===d?' aria-current="page"':"";r.push(`<li><a class="kan-nav-link" href="${f(c)}"${k}>${f(l)}</a></li>`)}return`<nav class="kan-site-nav"><ul>
|
|
108
|
+
${r.join(`
|
|
109
|
+
`)}
|
|
110
|
+
</ul></nav>`}resolveNavEntry(e,t,n){if(t&&W(t).map(i=>i.subject).some(i=>i.publisher===he.publisher&&i.package_===he.package_&&i.name===he.name)){let i=j(t,M),c=H(t,Ee);if(c instanceof w&&c.object instanceof R){let l=c.object,d=this.readLabelForUri({publisher:l.subject.publisher,package_:l.subject.package_,name:l.subject.name});return{href:this.urlForReference(l,Ee,n),label:i??d??l.subject.name}}}let s=Q.formatResourceUrl({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},"*",{contextPublisher:n}),a=t?j(t,M)??e.subject.name:e.subject.name;return{href:s,label:a}}findNavGroupForPublisher(e){for(let t of this.catalog){if(!(t instanceof X)||!(t.namespace||"").startsWith(`${e}/`))continue;if(W(t).map(r=>r.subject).some(r=>r.publisher===ie.publisher&&r.package_===ie.package_&&r.name===ie.name))return t}}renderMarkdown(e,t,n){let s=K(e,T);if(!s)return"<!-- LookRenderer.Markdown: no look.source -->";let a=H(t,s),r;return a instanceof Le?r=this.resolveMarkdownLinks(a,n):a instanceof A?r=a.object:r=this.readPropertyValueText(t,s),r?`<section class="kan-markdown">
|
|
111
|
+
${we(r)}
|
|
112
|
+
</section>`:""}resolveMarkdownLinks(e,t){let n=e.object,s=[...e.links].sort((a,r)=>r.startOffset-a.startOffset);for(let a of s){let r;if(a.target){let o=a.target.subject,i=(a.displayText??this.readLabelForUri({publisher:o.publisher,package_:o.package_,name:o.name})??a.reference).replace(/[[\]]/g,""),c=Q.formatResourceUrl({publisher:o.publisher,package_:o.package_,name:o.name,...o.version?{version:o.version}:{}},"=",{contextPublisher:t});r=`[${i}](${c})`}else r=a.displayText??a.reference;n=n.slice(0,a.startOffset)+r+n.slice(a.endOffset)}return n}renderRawMarkdown(e){let t=this.findCascadedLook(e);if(!t)return;let n=Ve(t.declaration),s=[];for(let a of n){let r=$e(a);if(!r||!U(r,Fe))continue;let o=K(a,T);if(!o)continue;let i=this.readPropertyValueText(e,o);i&&s.push(i)}return s.length>0?s.join(`
|
|
113
|
+
|
|
114
|
+
`):void 0}renderHero(e,t,n){let s=['<header class="kan-hero">'],a=K(e,Ln);if(a){let l=this.readPropertyValueText(t,a);l&&s.push(`<span class="kan-hero-eyebrow">${f(l)}</span>`)}let r=K(e,yn),o="";r&&(o=this.readPropertyValueText(t,r)??""),o||(o=t.name),s.push(`<h1 class="kan-hero-title">${f(o)}</h1>`);let i=K(e,On);if(i){let l=this.readPropertyValueText(t,i);l&&s.push(`<p class="kan-hero-subtitle">${f(l)}</p>`)}let c=K(e,Ae);if(c){let l=this.readPropertyValueReferences(t,c);if(l.length>0){let d=l.map(k=>this.renderBadge(k,Ae,n)).join("");s.push(`<div class="kan-hero-badges">${d}</div>`)}}return s.push("</header>"),s.join(`
|
|
115
|
+
`)}renderPropertyList(e,t,n){let s=K(e,T);if(!s)return"<!-- LookRenderer: PropertyList missing look.source -->";let a=this.readLabelForUri(s)??s.name,r=H(t,s),o=this.gatherValueItems(r),i=o.length>0?o.map(c=>`<li>${this.renderInlineValue(c,T,n)}</li>`).join(""):'<li class="kan-empty">(no values)</li>';return['<section class="kan-property-list">',`<h3 class="kan-property-list-title">${f(a)}</h3>`,`<ul class="kan-property-list-items">${i}</ul>`,"</section>"].join(`
|
|
116
|
+
`)}renderBadgeRow(e,t,n){let s=K(e,T);if(!s)return"<!-- LookRenderer: BadgeRow missing look.source -->";let a=this.readPropertyValueReferences(t,s);return a.length===0?"":`<div class="kan-badge-row">${a.map(o=>this.renderBadge(o,T,n)).join("")}</div>`}renderChipRow(e,t,n){let s=Me(e,wn);if(s.length===0)return"<!-- LookRenderer: ChipRow has no look.chips -->";let a=[];for(let r of s){let o=H(t,r);if(!o)continue;let i=this.readLabelForUri(r)??r.name,c=this.renderStatementInlineValue(o,r,n);c&&a.push(`<span class="kan-chip"><span class="kan-chip-key">${f(i)}</span> <span class="kan-chip-val">${c}</span></span>`)}return a.length===0?"":`<div class="kan-chip-row">${a.join("")}</div>`}renderReferenceList(e,t,n){let s=Me(e,be);if(s.length===0)return"<!-- LookRenderer: ReferenceList has no look.entries -->";let a=j(e,kn),r=j(e,gn),o=[];for(let i of s){let c=this.readPropertyValueReferences(t,i);if(c.length===0)continue;let l=this.readLabelForUri(i)??i.name;if(a){let d=c.map(k=>this.renderDetailRow(k,a,r,n)).filter(k=>k).join("");d&&o.push(`<dt>${f(l)}</dt><dd><ul class="kan-ref-rows">${d}</ul></dd>`)}else{let d=c.map(k=>this.renderReferenceLink(k,be,n)).join(", ");o.push(`<dt>${f(l)}</dt><dd>${d}</dd>`)}}return o.length===0?"":`<dl class="kan-reference-list">${o.join("")}</dl>`}renderDetailRow(e,t,n,s){let a=y(this.catalog,{publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name,...e.subject.version?{version:e.subject.version}:{}});if(!a)return"";let r=this.resolvePath(a,t)??j(a,M)??a.name,o=this.hrefForSubject(a,s),i=this.svgUrlForSubject(a,s),c="";if(n){let l=this.resolvePath(a,n);l&&(c=`<span class="kan-ref-badge">${f(l)}</span>`)}return`<li class="kan-ref-row"><a class="kan-ref-rowlink" href="${f(o)}"><img class="kan-ref-icon" src="${f(i)}" alt="" loading="lazy"/><span class="kan-ref-text">${f(r)}</span>${c}</a></li>`}readPropertyValueText(e,t){let n=H(e,t);if(n){if(n instanceof A)return n.object;if(n instanceof w){let s=n.object;return this.readLabelForUri({publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name})??s.subject.name}if(n instanceof E)return(n.object??[]).map(a=>a instanceof R?this.readLabelForUri({publisher:a.subject.publisher,package_:a.subject.package_,name:a.subject.name})??a.subject.name:a instanceof G?a.name??"":String(a)).filter(a=>a).join(", ")}}readPropertyValueReferences(e,t){let n=H(e,t);if(!n)return[];if(n instanceof w)return[n.object];if(n instanceof E){let s=[];for(let a of n.object??[])a instanceof R&&s.push(a);return s}return[]}gatherValueItems(e){return e?e instanceof E?e.object??[]:e instanceof w?[e.object]:e instanceof Z?[e.object]:e instanceof A?[e.object]:[]:[]}renderInlineValue(e,t,n){return e instanceof R?this.renderReferenceLink(e,t,n):e instanceof G?f(e.name??"(embedded)"):typeof e=="string"?f(e):typeof e=="number"||typeof e=="boolean"?f(String(e)):""}renderStatementInlineValue(e,t,n){return e instanceof A?f(e.object):e instanceof w?this.renderReferenceLink(e.object,t,n):e instanceof E?(e.object??[]).map(a=>this.renderInlineValue(a,t,n)).filter(a=>a).join(", "):""}renderReferenceLink(e,t,n){let s=this.readLabelForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name})??e.subject.name,a=this.urlForReference(e,t,n);return`<a class="kan-link" href="${f(a)}">${f(s)}</a>`}renderBadge(e,t,n){let s=this.readLabelForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name})??e.subject.name,a=this.readCommentForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name}),r=this.urlForReference(e,t,n),o=a?` title="${f(a)}"`:"";return`<a class="kan-badge" href="${f(r)}"${o}>${f(s)}</a>`}urlForReference(e,t,n){let s=t?this.getUrlFormForProperty(t):"=";return Q.formatResourceUrl({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},s,{contextPublisher:n})}getUrlFormForProperty(e){let t=y(this.catalog,e);if(!t)return"=";let n=j(t,Un);return n==="*"||n==="^"||n==="~"||n==="="?n:"="}readLabelForUri(e){let t=y(this.catalog,e);if(t)return j(t,M)}readCommentForUri(e){let t=y(this.catalog,e);if(t)return j(t,xe)}};function je(u){let e=new Map;for(let t of u.statement){if(!(t instanceof Z)||!B(t,ge.publisher,ge.package_,ge.name))continue;let n=t.object;for(let s of n.statement){if(!(s instanceof A))continue;let a=s.predicate?.subject?.name;if(!a)continue;let r=s.object;e.has(a)||e.set(a,r)}}return e}function _e(u){for(let e of u.statement)if(e instanceof Z&&B(e,ke.publisher,ke.package_,ke.name))return e.object}function Ve(u){for(let e of u.statement){if(!(e instanceof E)||!B(e,me.publisher,me.package_,me.name))continue;let t=[];for(let n of e.object??[])n instanceof G&&t.push(n);return t}return[]}function $e(u){for(let e of u.statement)if(e instanceof w&&e.predicate?.subject?.name==="type"&&e.object instanceof R){let t=e.object.subject;return{publisher:t.publisher,package_:t.package_,name:t.name}}}function K(u,e){for(let t of u.statement)if(t instanceof w&&B(t,e.publisher,e.package_,e.name)&&t.object instanceof R){let n=t.object.subject;return{publisher:n.publisher,package_:n.package_,name:n.name}}}function Me(u,e){for(let t of u.statement){if(!(t instanceof E)||!B(t,e.publisher,e.package_,e.name))continue;let n=[];for(let s of t.object??[])s instanceof R&&n.push({publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name});return n}return[]}function H(u,e){for(let t of u.statement)if(B(t,e.publisher,e.package_,e.name))return t}function j(u,e){for(let t of u.statement)if(t instanceof A&&B(t,e.publisher,e.package_,e.name))return t.object}function He(u,e){for(let t of u.statement)if(t instanceof oe&&B(t,e.publisher,e.package_,e.name))return t.object}function W(u){let e=[];for(let t of u.statement)if(t instanceof w){if(t.predicate?.subject?.name!=="type")continue;t.object instanceof R&&e.push(t.object)}else if(t instanceof E){if(t.predicate?.subject?.name!=="type")continue;for(let n of t.object??[])n instanceof R&&e.push(n)}return e}function ce(u){let e=[];for(let t of u.statement)if(t instanceof w){if(t.predicate?.subject?.name!=="subClassOf")continue;t.object instanceof R&&e.push(t.object)}else if(t instanceof E){if(t.predicate?.subject?.name!=="subClassOf")continue;for(let n of t.object??[])n instanceof R&&e.push(n)}return e}function le(u,e){let t=[];for(let n of u){if(!(n instanceof X)||n.name!==e.name)continue;(n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&t.push(n)}return t}function y(u,e){let t="version"in e?e.version:void 0;if(t){let n=`${e.publisher}/${e.package_}@${t.major}.${t.minor}.${t.patch}`;for(let s of u)if(s instanceof X&&s.name===e.name&&s.namespace===n)return s}for(let n of u){if(!(n instanceof X)||n.name!==e.name)continue;if((n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))return n}}function B(u,e,t,n){let s=u.predicate?.subject;return s?s.publisher===e&&s.package_===t&&s.name===n:!1}function U(u,e){return u.publisher===e.publisher&&u.package_===e.package_&&u.name===e.name}function ee(u){return`${u.publisher}/${u.package_}/${u.name}`}function q(u){let e=u.namespace||"",t=e.indexOf("/");return t>=0?e.substring(0,t):e}function f(u){return u.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Be(u){let e=u.lastIndexOf(".");return e>=0?u.substring(e+1):u}function De(u,e){for(let t of u.statement)if(t.predicate?.subject?.name===e)return t}function se(u){return u.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function In(u){if(!u)return"";let e=/^(\d{4})-(\d{2})-(\d{2})/.exec(u);return e?`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][parseInt(e[2],10)-1]??e[2]} ${parseInt(e[3],10)}`:u}export{we as a,ve as b};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Ze,b as Qe,c as et,d as tt,e as rt,f as nt,g as ot,h as at,i as it,j as st}from"./chunk-2BQ6SOU6.js";import{b as Yt}from"./chunk-
|
|
1
|
+
import{a as Ze,b as Qe,c as et,d as tt,e as rt,f as nt,g as ot,h as at,i as it,j as st}from"./chunk-2BQ6SOU6.js";import{b as Yt}from"./chunk-PBJBNJUS.js";import{a as qe,b as Ye,c as Xe,d as b,e as S,f as i}from"./chunk-REH5YNFQ.js";import{a as qt}from"./chunk-2VCFHCFN.js";import{a as Te,b as je,c as Le,d as Fe,e as Ne}from"./chunk-5AH6GIPO.js";import{a as Be,b as De,c as Oe,d as Ae}from"./chunk-VQFL5C7Q.js";import{a as lt,b as dt,c as ut,d as pt}from"./chunk-IIP6J4EP.js";import{a as Je,b as mt,c as ft,d as yt,e as ht}from"./chunk-4TJZIM7A.js";import{a as gt}from"./chunk-NIGFQYVA.js";import{A as Mt,B as zt,C as Gt,D as Wt,E as Jt,a as kt,b as bt,c as St,d as Ct,e as Pt,f as Rt,g as wt,h as xt,i as $t,j as vt,k as Et,l as Kt,m as Bt,n as It,o as Tt,p as jt,q as Lt,r as Ft,s as Nt,t as Dt,u as Ot,v as At,w as Ut,x as Vt,y as Ht,z as _t}from"./chunk-A2JTW3ON.js";import"./chunk-FJ35VIV6.js";import{a as F,b as D,c as Me,e as We}from"./chunk-4YHWMYAZ.js";import{a as Ue,b as j,c as L,d as N,e as He,f as _e,g as O,h as A,i as U,j as V,k as H,l as _}from"./chunk-W6T7MOKY.js";import{a as Ie}from"./chunk-7CUTGGH3.js";import{a as Pe,b as Re,c as we,d as xe,e as $e,f as ve,g as Ee,h as Ke}from"./chunk-FQHALFRR.js";import{b as ze,c as Ge}from"./chunk-5ILSX24H.js";import{a as Ve}from"./chunk-FUUTGGJS.js";import{a as ct}from"./chunk-ODIECDN7.js";import{VersionOperator as oo}from"@kanonak-protocol/types/document/models/enums";import{existsSync as fr,readFileSync as yr}from"fs";import{homedir as gr}from"os";import{join as hr}from"path";import{execFile as Xt}from"child_process";import{promisify as Zt}from"util";var C=Zt(Xt),P="kanonak",R="/usr/bin/security",p=class{async get(e){let r=i(e);try{let{stdout:n}=await C(R,["find-generic-password","-s",P,"-a",r,"-w"],{timeout:1e4});try{return JSON.parse(n.trim())}catch{throw new Error(`Stored credential for '${r}' is corrupted (not valid JSON).
|
|
2
2
|
Run 'kanonak logout ${r}' then 'kanonak login ${r}' to fix.`)}}catch(n){if(X(n,44))return null;throw new Error(`macOS Keychain read failed for '${r}': ${w(n)}
|
|
3
3
|
The Keychain may be locked or inaccessible.
|
|
4
4
|
Try unlocking it via Keychain Access.app or running 'security unlock-keychain'.`)}}async store(e,r){let n=i(e),o=JSON.stringify(r);try{await C(R,["add-generic-password","-s",P,"-a",n,"-U","-w",o],{timeout:1e4})}catch(a){throw new Error(`macOS Keychain write failed for '${n}': ${w(a)}
|
|
@@ -220,6 +220,40 @@ export declare class LookRenderer {
|
|
|
220
220
|
* a centered baseline. Nulls break the line.
|
|
221
221
|
*/
|
|
222
222
|
private sparkline;
|
|
223
|
+
/** The `.svg` URL for a resource (its resource URL + ".svg" extension). */
|
|
224
|
+
private svgUrlForSubject;
|
|
225
|
+
/**
|
|
226
|
+
* Render a Figure band — embeds a resource's SemanticSvg at full tier as
|
|
227
|
+
* a page figure. Defaults to the page instance's own svg (a resource's
|
|
228
|
+
* visual identity on its own page); `look.source` embeds a referenced
|
|
229
|
+
* resource's svg instead. The responsive 4-tier svg shows the full tier
|
|
230
|
+
* at the figure's rendered width.
|
|
231
|
+
*/
|
|
232
|
+
private renderFigure;
|
|
233
|
+
/**
|
|
234
|
+
* Render a StatRow band — a strip of labeled stats. `look.stats` is a
|
|
235
|
+
* list of Stat specs, each with a `statLabel` and a `statPath` (the same
|
|
236
|
+
* `/`-separated path DSL as metricPath) resolved against the page
|
|
237
|
+
* instance. Stats whose path doesn't resolve are omitted. Ontology-
|
|
238
|
+
* neutral: the publisher supplies both the labels and the paths.
|
|
239
|
+
*/
|
|
240
|
+
private renderStatRow;
|
|
241
|
+
/**
|
|
242
|
+
* Render a Horizon band — the instance's structured condition tree
|
|
243
|
+
* (e.g. an invalidationCondition). `look.source` is the property holding
|
|
244
|
+
* the condition embedded(s). Rendering is fully generic: each node shows
|
|
245
|
+
* its type's rdfs.label, then its scalar fields and references (resolved
|
|
246
|
+
* to their labels), recursing into nested embedded operands. The
|
|
247
|
+
* readable phrasing comes entirely from the data's own labels, so the
|
|
248
|
+
* SDK stays ontology-neutral.
|
|
249
|
+
*/
|
|
250
|
+
private renderHorizon;
|
|
251
|
+
/**
|
|
252
|
+
* Recursively render one node of a structured condition (or any nested
|
|
253
|
+
* embedded) tree: the node's type label, its scalar/reference fields,
|
|
254
|
+
* and its nested embedded children (e.g. operands, after/then).
|
|
255
|
+
*/
|
|
256
|
+
private renderConditionNode;
|
|
223
257
|
private renderTimeline;
|
|
224
258
|
/**
|
|
225
259
|
* Render the Timeline trajectory chart — a server-rendered inline SVG with
|
|
@@ -290,6 +324,16 @@ export declare class LookRenderer {
|
|
|
290
324
|
* prose block without bleeding into other bands.
|
|
291
325
|
*/
|
|
292
326
|
private renderMarkdown;
|
|
327
|
+
/**
|
|
328
|
+
* Replace every `[[reference]]` placeholder in a MarkdownStatement's value
|
|
329
|
+
* with a standard markdown link `[label](url)` pointing at the resolved
|
|
330
|
+
* target's Kanonak URL. Spans are spliced right-to-left so offsets stay
|
|
331
|
+
* valid. Label = the author's display text, else the target's rdfs.label,
|
|
332
|
+
* else the raw reference. Unresolved links (validation would flag them)
|
|
333
|
+
* degrade to their display text. The exact-version pin (`=`) keeps a
|
|
334
|
+
* narrative link pointing at the precise resource version it cited.
|
|
335
|
+
*/
|
|
336
|
+
private resolveMarkdownLinks;
|
|
293
337
|
/**
|
|
294
338
|
* Return the raw markdown text for an instance — concatenation of every
|
|
295
339
|
* `look.Markdown` band's source property value (no HTML rendering). Used
|
|
@@ -303,6 +347,13 @@ export declare class LookRenderer {
|
|
|
303
347
|
private renderBadgeRow;
|
|
304
348
|
private renderChipRow;
|
|
305
349
|
private renderReferenceList;
|
|
350
|
+
/**
|
|
351
|
+
* Render one referenced resource as a detail row: its chip-tier
|
|
352
|
+
* SemanticSvg icon, the text resolved from `labelPath` (falling back to
|
|
353
|
+
* rdfs.label), and an optional badge resolved from `badgePath`. The whole
|
|
354
|
+
* row links to the resource (exact-version pin, per the entries slot).
|
|
355
|
+
*/
|
|
356
|
+
private renderDetailRow;
|
|
306
357
|
/**
|
|
307
358
|
* Read a property's value off an instance and return it as a single
|
|
308
359
|
* piece of text. Strings render verbatim. References resolve to the
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as E,c as F,d as f,f as M}from"../chunk-2JQMUZWN.js";import{a as X,b as ye}from"../chunk-
|
|
1
|
+
import{b as E,c as F,d as f,f as M}from"../chunk-2JQMUZWN.js";import{a as X,b as ye}from"../chunk-PBJBNJUS.js";import{a as Oe}from"../chunk-2VCFHCFN.js";import"../chunk-IIP6J4EP.js";import"../chunk-NIGFQYVA.js";import{a as Ue}from"../chunk-FJ35VIV6.js";import{a as C,c as Re,e as Ce}from"../chunk-4YHWMYAZ.js";import{b as K,c as w,d as b,g as L,h as U,i as O,j,k as T,l as S}from"../chunk-W6T7MOKY.js";import{a as Le}from"../chunk-7CUTGGH3.js";import"../chunk-5ILSX24H.js";import"../chunk-FUUTGGJS.js";var gt="kanonak.org",yt="document-ast",m=t=>({publisher:gt,package_:yt,name:t}),k={Document:m("Document"),Block:m("Block"),Inline:m("Inline"),StructuredValue:m("StructuredValue"),Heading:m("Heading"),Paragraph:m("Paragraph"),RawBlock:m("RawBlock"),Text:m("Text"),StructuredMap:m("StructuredMap"),StructuredEntry:m("StructuredEntry"),StructuredList:m("StructuredList"),StringScalar:m("StringScalar"),IntegerScalar:m("IntegerScalar"),EscapeHint:m("EscapeHint"),MediaType:m("MediaType"),metadata:m("metadata"),children:m("children"),level:m("level"),inlines:m("inlines"),text:m("text"),entries:m("entries"),key:m("key"),value:m("value"),escapeHint:m("escapeHint"),items:m("items"),stringValue:m("stringValue"),integerValue:m("integerValue"),rawContent:m("rawContent"),mediaType:m("mediaType"),mimeType:m("mimeType"),ESC_RAW:m("esc-raw"),ESC_YAML_SAFE:m("esc-yaml-safe"),ESC_TOML_STRING:m("esc-toml-string"),ESC_TOML_MULTILINE:m("esc-toml-multiline"),ESC_JSON:m("esc-json"),ESC_DYNAMODB_BOOL:m("esc-dynamodb-bool"),ESC_DYNAMODB_NUMBER:m("esc-dynamodb-number"),ESC_DYNAMODB_NULL:m("esc-dynamodb-null"),TEXT_PLAIN:m("text-plain"),TEXT_MARKDOWN:m("text-markdown"),TEXT_HTML:m("text-html"),TEXT_CSS:m("text-css"),APPLICATION_JSON:m("application-json"),TEXT_YAML:m("text-yaml"),IMAGE_SVG_XML:m("image-svg-xml"),ResourceLink:m("ResourceLink"),target:m("target"),linkLabel:m("linkLabel"),PropertyList:m("PropertyList"),propertyEntries:m("propertyEntries"),PropertyEntry:m("PropertyEntry"),propertyKey:m("propertyKey"),propertyValue:m("propertyValue"),Table:m("Table"),tableColumnLabels:m("tableColumnLabels"),tableRows:m("tableRows"),TableRow:m("TableRow"),tableCells:m("tableCells")};function Ne(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var Y=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(e,n){let r=kt(e.metadata,n),a=wt(e.children),u=["---",...r,"---","",a].join(`
|
|
2
2
|
`);return n?.trailingNewline&&(u.endsWith(`
|
|
3
3
|
`)||(u+=`
|
|
4
4
|
`)),u}};function kt(t,e){if(!t)return[];let n=new Map;for(let c of t.entries)n.set(ue(c.key),c);let r=new Map;if(e?.metadataRenames)for(let[c,l]of e.metadataRenames)r.set(ue(c),l);let i=(e?.metadataKeys??t.entries.map(c=>c.key)).map(ue),u=[];for(let c of i){let l=n.get(c);if(!l)continue;let p=r.get(c),y=ue(p??c),h=Ie(l.value,l.escapeHint);h!==void 0&&u.push(`${y}: ${h}`)}return u}function ue(t){let e=t.lastIndexOf(".");return e===-1?t:t.substring(e+1)||t}function Ie(t,e){switch(t.kind){case"StringScalar":return ht(t.stringValue,e);case"IntegerScalar":return String(t.integerValue);case"StructuredList":{let n=[];for(let r of t.items){let a=Ie(r,e);a!==void 0&&n.push(a)}return n.join(", ")}case"StructuredMap":return;default:return}}function ht(t,e){return!e||Ne(e,k.ESC_RAW)?t:Ne(e,k.ESC_YAML_SAFE)?bt(t):t}function bt(t){return t.includes(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanonak-protocol/sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.33.0",
|
|
4
4
|
"description": "Kanonak Protocol SDK - Document repository and parsing implementations for TypeScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"yaml-parser"
|
|
114
114
|
],
|
|
115
115
|
"dependencies": {
|
|
116
|
-
"@kanonak-protocol/types": "^3.
|
|
116
|
+
"@kanonak-protocol/types": "^3.33.0",
|
|
117
117
|
"ignore": "^7.0.5",
|
|
118
118
|
"js-yaml": "^4.1.0",
|
|
119
119
|
"yaml": "^2.7.0"
|
package/dist/chunk-DNV7ES5F.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import{a as ee}from"./chunk-NIGFQYVA.js";import{a as te}from"./chunk-4YHWMYAZ.js";import{c as J,d as R,g as B,h as fe,i as Ke,j as U,k as Z,l as F}from"./chunk-W6T7MOKY.js";function Le(u){let e=u.replace(/\r\n/g,`
|
|
2
|
-
`).split(`
|
|
3
|
-
`),t=[],n=0;for(;n<e.length;){let s=e[n];if(s.trim()===""){n++;continue}let o=/^(\s*)```(\S*)\s*$/.exec(s);if(o){let i=o[2],c=[];for(n++;n<e.length&&!/^(\s*)```\s*$/.test(e[n]);)c.push(e[n]),n++;n++;let l=we(c.join(`
|
|
4
|
-
`)),d=i?` class="language-${Oe(i)}"`:"";t.push(`<pre><code${d}>${l}</code></pre>`);continue}let r=/^(#{1,6})\s+(.*)$/.exec(s);if(r){let i=r[1].length,c=ne(r[2].trim());t.push(`<h${i}>${c}</h${i}>`),n++;continue}if(s.includes("|")&&n+1<e.length&&Se(e[n+1])){let i=de(s),c=Xe(e[n+1]);n+=2;let l=[];for(;n<e.length&&e[n].trim()!==""&&e[n].includes("|");)l.push(de(e[n])),n++;t.push(ze(i,c,l));continue}if(/^\s*[-*]\s+/.test(s)){let i=[];for(;n<e.length&&/^\s*[-*]\s+/.test(e[n]);){let c=[e[n].replace(/^\s*[-*]\s+/,"")];for(n++;n<e.length&&e[n].trim()!==""&&!/^\s*[-*]\s+/.test(e[n])&&!/^\s*\d+\.\s+/.test(e[n]);)c.push(e[n]),n++;n<e.length&&e[n].trim()===""&&n++,i.push(`<li>${ne(c.join(" ").trim())}</li>`)}t.push(`<ul>
|
|
5
|
-
${i.join(`
|
|
6
|
-
`)}
|
|
7
|
-
</ul>`);continue}if(/^\s*\d+\.\s+/.test(s)){let i=[];for(;n<e.length&&/^\s*\d+\.\s+/.test(e[n]);){let c=[e[n].replace(/^\s*\d+\.\s+/,"")];for(n++;n<e.length&&e[n].trim()!==""&&!/^\s*\d+\.\s+/.test(e[n])&&!/^\s*[-*]\s+/.test(e[n]);)c.push(e[n]),n++;n<e.length&&e[n].trim()===""&&n++,i.push(`<li>${ne(c.join(" ").trim())}</li>`)}t.push(`<ol>
|
|
8
|
-
${i.join(`
|
|
9
|
-
`)}
|
|
10
|
-
</ol>`);continue}let a=[s];for(n++;n<e.length&&e[n].trim()!==""&&!/^(#{1,6})\s+/.test(e[n])&&!/^(\s*)```/.test(e[n])&&!/^\s*[-*]\s+/.test(e[n])&&!/^\s*\d+\.\s+/.test(e[n])&&!(e[n].includes("|")&&n+1<e.length&&Se(e[n+1]));)a.push(e[n]),n++;t.push(`<p>${ne(a.join(" "))}</p>`)}return t.join(`
|
|
11
|
-
`)}function Se(u){return u.includes("-")?/^[\s|:-]+$/.test(u):!1}function de(u){let e=u.trim();return e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&(e=e.slice(0,-1)),e.split("|").map(t=>t.trim())}function Xe(u){return de(u).map(e=>{let t=e.startsWith(":"),n=e.endsWith(":");return t&&n?"center":n?"right":t?"left":null})}function ze(u,e,t){let n=r=>{let a=e[r];return a?` style="text-align:${a}"`:""},s=u.map((r,a)=>`<th${n(a)}>${ne(r)}</th>`).join(""),o=t.map(r=>`<tr>${r.map((i,c)=>`<td${n(c)}>${ne(i)}</td>`).join("")}</tr>`).join(`
|
|
12
|
-
`);return`<table>
|
|
13
|
-
<thead><tr>${s}</tr></thead>
|
|
14
|
-
<tbody>
|
|
15
|
-
${o}
|
|
16
|
-
</tbody>
|
|
17
|
-
</table>`}function ne(u){let e=we(u);return e=e.replace(/`([^`\n]+)`/g,(t,n)=>`<code>${n}</code>`),e=e.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(t,n,s)=>`<a href="${Oe(s)}">${n}</a>`),e=e.replace(/\*\*([^*\n]+)\*\*/g,(t,n)=>`<strong>${n}</strong>`),e=e.replace(/(^|[^*])\*([^*\n]+)\*(?!\*)/g,(t,n,s)=>`${n}<em>${s}</em>`),e=e.replace(/(^|[\s(])_([^_\n]+)_(?=[\s).,;:!?]|$)/g,(t,n,s)=>`${n}<em>${s}</em>`),e}function we(u){return u.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Oe(u){return u.replace(/"/g,""").replace(/&/g,"&")}var pe={publisher:"kanonak.org",package_:"derivation",name:"look"},he={publisher:"kanonak.org",package_:"derivation",name:"tokens"},N={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},H={publisher:"kanonak.org",package_:"core-rdf",name:"label"},Ie={publisher:"kanonak.org",package_:"core-rdf",name:"comment"},Qe={publisher:"kanonak.org",package_:"look",name:"Hero"},Ze={publisher:"kanonak.org",package_:"look",name:"PropertyList"},en={publisher:"kanonak.org",package_:"look",name:"BadgeRow"},nn={publisher:"kanonak.org",package_:"look",name:"ChipRow"},tn={publisher:"kanonak.org",package_:"look",name:"ReferenceList"},Ue={publisher:"kanonak.org",package_:"look",name:"Markdown"},oe={publisher:"kanonak.org",package_:"look",name:"NavGroup"},ke={publisher:"kanonak.org",package_:"look",name:"NavLink"},xe={publisher:"kanonak.org",package_:"look",name:"target"},sn={publisher:"kanonak.org",package_:"look",name:"ResourceGrid"},rn={publisher:"kanonak.org",package_:"look",name:"Timeline"},an={publisher:"kanonak.org",package_:"look",name:"VersionDiff"},Fe={publisher:"kanonak.org",package_:"look",name:"orderBy"},Ee={publisher:"kanonak.org",package_:"look",name:"track"},Pe={publisher:"kanonak.org",package_:"look",name:"metricPath"},Te={publisher:"kanonak.org",package_:"look",name:"hueBy"},on={publisher:"kanonak.org",package_:"look",name:"lowerPath"},cn={publisher:"kanonak.org",package_:"look",name:"upperPath"},un={publisher:"kanonak.org",package_:"look",name:"axisMin"},ln={publisher:"kanonak.org",package_:"look",name:"axisMax"},fn={publisher:"kanonak.org",package_:"look",name:"valueLabel"};var dn={publisher:"kanonak.org",package_:"look",name:"semanticSvg"},pn={publisher:"kanonak.org",package_:"look",name:"tierChip"},hn={publisher:"kanonak.org",package_:"look",name:"tierIcon"},kn={publisher:"kanonak.org",package_:"look",name:"tierCard"},gn={publisher:"kanonak.org",package_:"look",name:"tierFull"};var ge={publisher:"kanonak.org",package_:"look",name:"bands"},mn={publisher:"kanonak.org",package_:"look",name:"title"},bn={publisher:"kanonak.org",package_:"look",name:"eyebrow"},jn={publisher:"kanonak.org",package_:"look",name:"subtitle"},Ce={publisher:"kanonak.org",package_:"look",name:"badges"},A={publisher:"kanonak.org",package_:"look",name:"source"},$n={publisher:"kanonak.org",package_:"look",name:"chips"},me={publisher:"kanonak.org",package_:"look",name:"entries"},_n={publisher:"kanonak.org",package_:"look",name:"urlForm"},$e=class{constructor(e){this.catalog=e}catalog;findCascadedLook(e){let t=je(e);if(t)return{declaration:t,sourceClass:{publisher:G(e),package_:(e.namespace||"").split("/")[1]?.split("@")[0]??"",name:e.name}};let n=new Set,s=D(e);for(;s.length>0;){let o=s.shift(),r=z(o.subject);if(n.has(r))continue;n.add(r);let a=x(this.catalog,o.subject);if(!a)continue;let i=je(a);if(i)return{declaration:i,sourceClass:{publisher:o.subject.publisher,package_:o.subject.package_,name:o.subject.name}};for(let c of ie(a))s.push(c)}if(!n.has(z(N))){let o=x(this.catalog,N);if(o){let r=je(o);if(r)return{declaration:r,sourceClass:{...N}}}}}findCascadedTokens(e){let t=new Map;for(let[o,r]of be(e))t.has(o)||t.set(o,r);let n=new Set,s=D(e);for(;s.length>0;){let o=s.shift(),r=z(o.subject);if(n.has(r))continue;n.add(r);let a=ce(this.catalog,o.subject);if(a.length!==0)for(let i of a){for(let[c,l]of be(i))t.has(c)||t.set(c,l);for(let c of ie(i))s.push(c)}}if(!n.has(z(N))){let o=ce(this.catalog,N);for(let r of o)for(let[a,i]of be(r))t.has(a)||t.set(a,i)}return t}renderSvg(e){let t=v(e,H)??e.name,n=(t.trim().charAt(0)||"?").toUpperCase(),s=`${e.namespace??""}/${e.name}`,o={label:t,firstLetter:n,uri:s},r=this.collectCascadedSvgTiers(e),a=m=>this.applyPlaceholders(m,e,o),i=a(r.tierChip??""),c=a(r.tierIcon??""),l=a(r.tierCard??""),d=a(r.tierFull??""),k=[...this.findCascadedTokens(e)].map(([m,b])=>`--kan-${m}: ${b};`).join(" ");return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400" width="400" height="400" style="${se(k)}">
|
|
18
|
-
<style>
|
|
19
|
-
.tier-chip,.tier-icon,.tier-card{display:none}
|
|
20
|
-
.tier-full{display:block}
|
|
21
|
-
@media (max-width:400px){.tier-full{display:none}.tier-card{display:block}}
|
|
22
|
-
@media (max-width:160px){.tier-card{display:none}.tier-icon{display:block}}
|
|
23
|
-
@media (max-width:60px){.tier-icon{display:none}.tier-chip{display:block}}
|
|
24
|
-
</style>
|
|
25
|
-
<g class="tier-chip">${i}</g>
|
|
26
|
-
<g class="tier-icon">${c}</g>
|
|
27
|
-
<g class="tier-card">${l}</g>
|
|
28
|
-
<g class="tier-full">${d}</g>
|
|
29
|
-
</svg>`}applyPlaceholders(e,t,n){return e.replace(/\{\{([^}]+)\}\}/g,(s,o)=>{let r=o.trim();if(n[r]!==void 0)return se(n[r]);let a=this.resolvePath(t,r);return a===void 0?`{{${r}}}`:se(a)})}resolvePath(e,t){let n=t.split("/").map(a=>a.trim()).filter(a=>a.length>0);if(n.length===0)return;let s=e;for(let a=0;a<n.length-1;a++){if(!s)return;let i=Be(n[a]),c=He(s,i);if(!c)return;if(c instanceof U&&c.object instanceof R){let l=x(this.catalog,c.object.subject);if(!l)return;s=l}else if(c instanceof Z)s=c.object;else return}if(!s)return;let o=Be(n[n.length-1]),r=He(s,o);if(r){if(r instanceof B||r instanceof fe||r instanceof Ke)return String(r.object);if(r instanceof U&&r.object instanceof R){let a=r.object,i=x(this.catalog,a.subject);return i?v(i,H)??a.subject.name:a.subject.name}}}collectCascadedSvgTiers(e){let t={},n=r=>{let a=X(r,dn);if(!(a instanceof Z))return;let i=a.object,c=v(i,pn),l=v(i,hn),d=v(i,kn),g=v(i,gn);t.tierChip===void 0&&c!==void 0&&(t.tierChip=c),t.tierIcon===void 0&&l!==void 0&&(t.tierIcon=l),t.tierCard===void 0&&d!==void 0&&(t.tierCard=d),t.tierFull===void 0&&g!==void 0&&(t.tierFull=g)};n(e);let s=new Set,o=D(e);for(;o.length>0;){let r=o.shift(),a=z(r.subject);if(s.has(a))continue;s.add(a);let i=ce(this.catalog,r.subject);for(let c of i){n(c);for(let l of ie(c))o.push(l)}}if(!s.has(z(N)))for(let r of ce(this.catalog,N))n(r);return t}renderStylesheet(e){let t=this.findCascadedTokens(e),n=[];for(let[r,a]of t)n.push(` --kan-${r}: ${a};`);let s=n.length>0?`:root {
|
|
30
|
-
${n.join(`
|
|
31
|
-
`)}
|
|
32
|
-
}`:":root { /* no tokens resolved */ }",o=this.findBaseStylesheet(G(e))??"";return`${s}
|
|
33
|
-
${o}`}findBaseStylesheet(e){let t="kanonak.org/site/content",n,s;for(let r of this.catalog){if(!(r instanceof J)||r.name!=="base-stylesheet")continue;let a=r.namespace||"";a.startsWith(`${e}/look-styles@`)?n=r:a.startsWith("kanonak.org/look-styles@")&&(s=r)}let o=n??s;if(o)for(let r of o.statement){let a=r.predicate?.subject;if(!a)continue;if(`${a.publisher}/${a.package_}/${a.name}`===t&&r instanceof B)return r.object}}renderHtml(e){let t=this.findCascadedLook(e);if(!t)return`<!-- LookRenderer: no derivation.look found for ${e.namespace}/${e.name} -->`;let n=Ne(t.declaration);if(n.length===0)return"<!-- LookRenderer: look declaration has no bands -->";let s=G(e),o=[];for(let r of n)o.push(this.renderBand(r,e,s));return o.join(`
|
|
34
|
-
`)}renderPublisherIndex(e,t,n){let s=n?this.renderNavGroup(n,e):"",o=t.map(a=>{let i=a.comment?`<p class="kan-resource-card-subtitle">${f(a.comment)}</p>`:"";return`<a class="kan-resource-card" href="${f(a.href)}"><h3 class="kan-resource-card-title">${f(a.label)}</h3>${i}</a>`}).join(`
|
|
35
|
-
`),r=`<header class="kan-hero">
|
|
36
|
-
<h1 class="kan-hero-title">${f(e)}</h1>
|
|
37
|
-
</header>
|
|
38
|
-
<section class="kan-resource-grid">
|
|
39
|
-
${o}
|
|
40
|
-
</section>`;return`<!doctype html>
|
|
41
|
-
<html lang="en">
|
|
42
|
-
<head>
|
|
43
|
-
<meta charset="utf-8">
|
|
44
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
45
|
-
<title>${f(e)}</title>
|
|
46
|
-
<link rel="stylesheet" href="index.css">
|
|
47
|
-
</head>
|
|
48
|
-
<body>
|
|
49
|
-
${s}
|
|
50
|
-
<main class="kan-main">
|
|
51
|
-
${r}
|
|
52
|
-
</main>
|
|
53
|
-
</body>
|
|
54
|
-
</html>
|
|
55
|
-
`}renderPublisherIndexStylesheet(e){return e?this.renderStylesheet(e):""}hasDeclaredView(e){let t=this.findCascadedLook(e);return t?!(t.sourceClass.publisher===N.publisher&&t.sourceClass.package_===N.package_&&t.sourceClass.name===N.name):!1}renderPackageVersionList(e,t,n){let s=G(n),o=this.renderNavGroup(n,s),r=this.renderBreadcrumb(n,s,{bareOverview:!0}),a=t.map(c=>`<a class="kan-resource-card" href="/${f(e)}/${f(c)}/"><h3 class="kan-resource-card-title">${f(c)}</h3></a>`).join(`
|
|
56
|
-
`),i=`<header class="kan-hero">
|
|
57
|
-
<span class="kan-hero-eyebrow">PACKAGE</span>
|
|
58
|
-
<h1 class="kan-hero-title">${f(e)}</h1>
|
|
59
|
-
</header>
|
|
60
|
-
<section class="kan-resource-grid">
|
|
61
|
-
${a}
|
|
62
|
-
</section>`;return`<!doctype html>
|
|
63
|
-
<html lang="en">
|
|
64
|
-
<head>
|
|
65
|
-
<meta charset="utf-8">
|
|
66
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
67
|
-
<title>${f(e)}</title>
|
|
68
|
-
<link rel="stylesheet" href="${f(n.name)}.css">
|
|
69
|
-
</head>
|
|
70
|
-
<body>
|
|
71
|
-
${o}
|
|
72
|
-
${r}
|
|
73
|
-
<main class="kan-main">
|
|
74
|
-
${i}
|
|
75
|
-
</main>
|
|
76
|
-
</body>
|
|
77
|
-
</html>
|
|
78
|
-
`}renderDocument(e,t){let n=this.renderHtml(e),s=this.readPropertyValueText(e,H)??e.name,o=`${e.name}.css`,r=this.hasSvgDerivation(e)?`<figure class="kan-figure"><img src="${f(e.name)}.svg" alt=""></figure>
|
|
79
|
-
`:"",a=G(e),i=this.renderNavGroup(e,a),c=this.renderBreadcrumb(e,a,t);return`<!doctype html>
|
|
80
|
-
<html lang="en">
|
|
81
|
-
<head>
|
|
82
|
-
<meta charset="utf-8">
|
|
83
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
84
|
-
<title>${f(s)}</title>
|
|
85
|
-
<link rel="stylesheet" href="${f(o)}">
|
|
86
|
-
</head>
|
|
87
|
-
<body>
|
|
88
|
-
${i}
|
|
89
|
-
${c}
|
|
90
|
-
<main class="kan-main">
|
|
91
|
-
${r}${n}
|
|
92
|
-
</main>
|
|
93
|
-
</body>
|
|
94
|
-
</html>
|
|
95
|
-
`}hasSvgDerivation(e){let t=new Set,n=D(e);for(;n.length>0;){let s=n.shift(),o=z(s.subject);if(t.has(o))continue;t.add(o);let r=x(this.catalog,s.subject);if(r){for(let a of r.statement)if(a instanceof F&&V(a,"kanonak.org","derivation","derivations")){for(let i of a.object??[])if(i instanceof te)for(let c of i.statement){if(!(c instanceof U)||!V(c,"kanonak.org","derivation","format")||!(c.object instanceof R))continue;let l=c.object.subject;if(l.publisher==="kanonak.org"&&l.package_==="formats"&&l.name==="svg")return!0}}for(let a of ie(r))n.push(a)}}return!1}renderBand(e,t,n){let s=Ve(e);return s?E(s,Qe)?this.renderHero(e,t,n):E(s,Ze)?this.renderPropertyList(e,t,n):E(s,en)?this.renderBadgeRow(e,t,n):E(s,nn)?this.renderChipRow(e,t,n):E(s,tn)?this.renderReferenceList(e,t,n):E(s,Ue)?this.renderMarkdown(e,t):E(s,oe)?this.renderNavGroup(t,n):E(s,sn)?this.renderResourceGrid(e,n,t):E(s,rn)?this.renderTimeline(e,n):E(s,an)?this.renderVersionDiff(e,n):`<!-- LookRenderer: unsupported band ${s.publisher}/${s.package_}/${s.name} -->`:"<!-- LookRenderer: band has no rdf:type -->"}collectTrackedSeries(e,t,n,s){let{hueBy:o,lowerPath:r,upperPath:a}=s??{},i=new Map,c=e.length,l=(d,g)=>{let k=this.resolvePath(d,g);return k===void 0?NaN:parseFloat(k)};return e.forEach((d,g)=>{let k=this.readPropertyValueReferences(d,t);for(let m of k){let b=x(this.catalog,{publisher:m.subject.publisher,package_:m.subject.package_,name:m.subject.name,...m.subject.version?{version:m.subject.version}:{}});if(!b)continue;let h=m.subject.name,j=i.get(h);j||(j={key:h,label:v(b,H)??h,points:new Array(c).fill(null),...r?{lower:new Array(c).fill(null)}:{},...a?{upper:new Array(c).fill(null)}:{}},i.set(h,j));let y=l(b,n);if(Number.isFinite(y)&&(j.points[g]=y),r&&j.lower){let $=l(b,r);Number.isFinite($)&&(j.lower[g]=$)}if(a&&j.upper){let $=l(b,a);Number.isFinite($)&&(j.upper[g]=$)}if(o){let $=l(b,o);Number.isFinite($)&&(j.hue=$)}j.lastSubject=b}}),[...i.values()]}hrefForSubject(e,t,n="="){let s=e.namespace||"",o=s.split("/")[1]?.split("@")[0]??"",r=s.split("@")[1]??"",a=r?this.parseVersion(r):void 0;return ee.formatResourceUrl({publisher:G(e),package_:o,name:e.name,...a?{version:a}:{}},n,{contextPublisher:t})}renderVersionDiff(e,t){let n=K(e,A);if(!n)return"<!-- LookRenderer.VersionDiff: no look.source -->";let s=v(e,Pe),o=K(e,Ee);if(!o||!s)return"<!-- LookRenderer.VersionDiff: needs look.track + look.metricPath -->";let r=K(e,Fe),a=v(e,Te),i=this.findInstancesOfClass(n);if(i.length===0)return"<!-- LookRenderer.VersionDiff: no instances -->";let c=k=>r?this.readPropertyValueText(k,r)??"":"",l=i.slice().sort((k,m)=>c(k).localeCompare(c(m))),d=this.collectTrackedSeries(l,o,s,{hueBy:a});return d.length===0?"<!-- LookRenderer.VersionDiff: no tracked series -->":`<section class="kan-vdiff">${d.map((k,m)=>{let b=k.hue!==void 0?k.hue:Math.round(m*360/d.length),h=k.points.filter(W=>W!==null);if(h.length===0)return"";let j=h[0],y=h[h.length-1],$=y-j,P;if(Math.abs($)>=.005){let W=$>0?"up":"down",q=$>0?"\u25B2":"\u25BC";P=`<span class="kan-vdiff-delta ${W}">${$>0?"+":""}${$.toFixed(2)} ${q}</span>`}else P='<span class="kan-vdiff-delta flat">\u2014</span>';let Q=k.lastSubject?`<a href="${f(this.hrefForSubject(k.lastSubject,t))}">${f(k.label)}</a>`:f(k.label);return`<div class="kan-vdiff-row" style="--kan-vdiff-hue:${b}"><span class="kan-vdiff-label">${Q}</span><span class="kan-vdiff-start">${j.toFixed(2)}</span>`+this.sparkline(k.points,b)+`<span class="kan-vdiff-end">${y.toFixed(2)}</span>`+P+"</div>"}).join("")}</section>`}sparkline(e,t){let r=`hsl(${t},65%,60%)`,a=e.filter(h=>h!==null);if(a.length===0)return'<svg class="kan-vdiff-spark" viewBox="0 0 132 30" xmlns="http://www.w3.org/2000/svg"></svg>';let i=Math.min(...a),l=Math.max(...a)-i,d=e.length,g=h=>d<=1?132/2:4+h/(d-1)*124,k=h=>l<1e-9?30/2:26-(h-i)/l*22,m=[],b=[];return e.forEach((h,j)=>{if(h===null)return;let y=g(j),$=k(h);m.push(`${y.toFixed(1)},${$.toFixed(1)}`),b.push(`<circle cx="${y.toFixed(1)}" cy="${$.toFixed(1)}" r="2" fill="${r}"/>`)}),`<svg class="kan-vdiff-spark" viewBox="0 0 132 30" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg" role="img"><polyline points="${m.join(" ")}" fill="none" stroke="${r}" stroke-width="1.5" stroke-linejoin="round" stroke-linecap="round"/>`+b.join("")+"</svg>"}renderTimeline(e,t){let n=K(e,A);if(!n)return"<!-- LookRenderer.Timeline: no look.source -->";let s=K(e,Fe),o=this.findInstancesOfClass(n);if(o.length===0)return"<!-- LookRenderer.Timeline: no instances -->";let r=d=>s?this.readPropertyValueText(d,s)??"":"",a=o.slice().sort((d,g)=>r(d).localeCompare(r(g))),i=K(e,Ee),c=v(e,Pe);return i&&c?this.renderTrajectoryChart(a,i,c,e,t,r):`<section class="kan-timeline"><ol>
|
|
96
|
-
${a.map(d=>{let g=d.namespace||"",k=g.split("/")[1]?.split("@")[0]??"",m=g.split("@")[1]??"",b=m?this.parseVersion(m):void 0,h=ee.formatResourceUrl({publisher:G(d),package_:k,name:d.name,...b?{version:b}:{}},"=",{contextPublisher:t}),j=r(d),y=j?`<span class="kan-timeline-date">${f(j)}</span>`:"",$=m||d.name;return`<li class="kan-timeline-node"><a href="${f(h)}"><span class="kan-timeline-key">${f($)}</span>${y}</a></li>`}).join(`
|
|
97
|
-
`)}
|
|
98
|
-
</ol></section>`}renderTrajectoryChart(e,t,n,s,o,r){let a=s,i=v(a,Te),c=v(a,on),l=v(a,cn),d=v(a,fn),g=Me(a,un),k=Me(a,ln),m=e.length,b=this.collectTrackedSeries(e,t,n,{hueBy:i,lowerPath:c,upperPath:l});if(b.length===0)return"<!-- LookRenderer.Timeline: no tracked series -->";let h=[];for(let p of b){for(let _ of p.points)_!==null&&h.push(_);for(let _ of p.lower??[])_!==null&&h.push(_);for(let _ of p.upper??[])_!==null&&h.push(_)}if(h.length===0)return"<!-- LookRenderer.Timeline: no metric values -->";let j=Math.min(...h),y=Math.max(...h);y-j<1e-9&&(j-=.5,y+=.5);let $=(y-j)*.08,P=g!==void 0?g:j-$,Q=k!==void 0?k:y+$;Q-P<1e-9&&(Q=P+1);let W=1e3,q=440,S={top:28,right:24,bottom:56,left:52},_e=W-S.left-S.right,De=q-S.top-S.bottom,re=p=>m<=1?S.left+_e/2:S.left+p/(m-1)*_e,ae=p=>S.top+(1-(p-P)/(Q-P))*De,ue=(p,_)=>p.hue!==void 0?p.hue:Math.round(_*360/b.length),le=[];for(let p=0;p<5;p++){let _=P+p*(Q-P)/4,T=ae(_);le.push(`<line x1="${S.left}" y1="${T.toFixed(1)}" x2="${(W-S.right).toFixed(1)}" y2="${T.toFixed(1)}" class="kan-fan-grid"/>`),le.push(`<text x="${(S.left-8).toFixed(1)}" y="${(T+4).toFixed(1)}" class="kan-fan-axis" text-anchor="end">${_.toFixed(2)}</text>`)}let ve=[];e.forEach((p,_)=>{let T=this.hrefForSubject(p,o),w=(p.namespace||"").split("@")[1]??"",L=re(_),O=vn(r(p));ve.push(`<a href="${f(T)}" class="kan-fan-xtick"><line x1="${L.toFixed(1)}" y1="${S.top}" x2="${L.toFixed(1)}" y2="${(q-S.bottom).toFixed(1)}" class="kan-fan-vline"/><text x="${L.toFixed(1)}" y="${(q-S.bottom+20).toFixed(1)}" class="kan-fan-xlabel" text-anchor="middle">${se(w||p.name)}</text>`+(O?`<text x="${L.toFixed(1)}" y="${(q-S.bottom+36).toFixed(1)}" class="kan-fan-xdate" text-anchor="middle">${se(O)}</text>`:"")+"</a>")});let Re=[];b.forEach((p,_)=>{if(!p.lower||!p.upper)return;let T=ue(p,_),w=[],L=[];for(let I=0;I<m;I++){let Y=p.upper[I],M=p.lower[I];Y==null||M===null||M===void 0||(w.push(`${re(I).toFixed(1)},${ae(Y).toFixed(1)}`),L.unshift(`${re(I).toFixed(1)},${ae(M).toFixed(1)}`))}let O=w.concat(L);O.length<3||Re.push(`<polygon class="kan-fan-band" points="${O.join(" ")}" fill="hsl(${T},65%,60%)"/>`)});let ye=[];b.forEach((p,_)=>{let w=`hsl(${ue(p,_)},65%,60%)`,L=[],O=[];p.points.forEach((I,Y)=>{if(I===null)return;let M=re(Y),C=ae(I);L.push(`${M.toFixed(1)},${C.toFixed(1)}`),O.push(`<circle cx="${M.toFixed(1)}" cy="${C.toFixed(1)}" r="3.5" fill="${w}"/>`)}),L.length!==0&&ye.push(`<g class="kan-fan-series" data-series="${f(p.key)}"><polyline points="${L.join(" ")}" fill="none" stroke="${w}" stroke-width="2" stroke-linejoin="round" stroke-linecap="round"/>`+O.join("")+"</g>")});let Ge=`<svg class="kan-fan-svg" viewBox="0 0 ${W} ${q}" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" role="img">`+le.join("")+ve.join("")+Re.join("")+ye.join("")+"</svg>",We=d?`${f(d)}=`:"",qe=b.map((p,_)=>{let T=ue(p,_),w=p.points.filter(C=>C!==null),L=w.length?w[0]:void 0,O=w.length?w[w.length-1]:void 0,I="";if(O!==void 0&&L!==void 0){let C=O-L;if(Math.abs(C)>=.005){let Ye=C>0?"up":"down",Je=C>0?"\u25B2":"\u25BC";I=` <span class="kan-fan-delta ${Ye}">${C>0?"+":""}${C.toFixed(2)} ${Je}</span>`}else I=' <span class="kan-fan-delta flat">\u2014</span>'}let Y=O!==void 0?`${We}${O.toFixed(2)}`:"\u2014",M=p.lastSubject?`<a href="${f(this.hrefForSubject(p.lastSubject,o))}">${f(p.label)}</a>`:f(p.label);return`<div class="kan-fan-legend-item" style="--kan-fan-hue:${T}"><span class="kan-fan-swatch"></span><span class="kan-fan-legend-label">${M}</span><span class="kan-fan-legend-cur">${Y}${I}</span></div>`});return`<section class="kan-fan"><div class="kan-fan-chart">${Ge}</div><div class="kan-fan-legend">${qe.join("")}</div></section>`}renderResourceGrid(e,t,n){let s=K(e,A);if(!s)return"<!-- LookRenderer.ResourceGrid: no look.source -->";let o=x(this.catalog,s),r=o?D(o).some(c=>{let l=c.subject.name;return l==="ObjectProperty"||l==="DatatypeProperty"||l==="Property"}):!1,a=[];if(r&&n){let c=this.readPropertyValueReferences(n,s);for(let l of c){let d=x(this.catalog,{publisher:l.subject.publisher,package_:l.subject.package_,name:l.subject.name,...l.subject.version?{version:l.subject.version}:{}});d&&a.push(d)}}else a=this.findInstancesOfClass(s);if(a.length===0)return`<!-- LookRenderer.ResourceGrid: no resources for ${s.publisher}/${s.package_}/${s.name} -->`;let i=[];for(let c of a){let l=v(c,H)??c.name,d=v(c,Ie),g=c.namespace||"",k=g.split("/")[1]?.split("@")[0]??"",m=g.split("@")[1]??"",b=m?this.parseVersion(m):void 0,h=ee.formatResourceUrl({publisher:G(c),package_:k,name:c.name,...b?{version:b}:{}},"=",{contextPublisher:t}),j=d?`<p class="kan-resource-card-subtitle">${f(d)}</p>`:"";i.push(`<a class="kan-resource-card" href="${f(h)}"><h3 class="kan-resource-card-title">${f(l)}</h3>${j}</a>`)}return`<section class="kan-resource-grid">
|
|
99
|
-
${i.join(`
|
|
100
|
-
`)}
|
|
101
|
-
</section>`}parseVersion(e){let t=e.split(".").map(Number);if(!(t.length!==3||t.some(n=>Number.isNaN(n))))return{major:t[0],minor:t[1],patch:t[2]}}findInstancesOfClass(e){let t=[];for(let n of this.catalog){if(!(n instanceof J))continue;D(n).map(r=>r.subject).some(r=>r.publisher===e.publisher&&r.package_===e.package_&&r.name===e.name)&&t.push(n)}return t}renderBreadcrumb(e,t,n){let o=(e.namespace||"").split("/");if(o.length<2)return"";let r=o[0],a=o[1]??"",i=a.split("@")[0]??"",c=a.split("@")[1]??"";if(!r||!i)return"";if(n?.bareOverview)return`<nav class="kan-breadcrumb"><ol>
|
|
102
|
-
<li><a href="/">${f(r)}</a></li>
|
|
103
|
-
<li aria-current="page">${f(i)}</li>
|
|
104
|
-
</ol></nav>`;let l=e.name,g=!!x(this.catalog,{publisher:r,package_:i,name:i}),k=c?`${i}@${c}`:i,m=c?`/${i}/${c}/${i}`:`/${i}/${i}`,b=e.name===i,h=[];return h.push(`<li><a href="/">${f(r)}</a></li>`),b?h.push(`<li aria-current="page">${f(k)}</li>`):(h.push(g?`<li><a href="${f(m)}">${f(k)}</a></li>`:`<li>${f(k)}</li>`),h.push(`<li aria-current="page">${f(l)}</li>`)),`<nav class="kan-breadcrumb"><ol>
|
|
105
|
-
${h.join(`
|
|
106
|
-
`)}
|
|
107
|
-
</ol></nav>`}renderNavGroup(e,t){let n=this.findNavGroupForPublisher(t);if(!n)return"";let s=X(n,me);if(!(s instanceof F))return"";let o=s.object??[];if(o.length===0)return"";let r=[];for(let a of o){if(!(a instanceof R))continue;let i=x(this.catalog,{publisher:a.subject.publisher,package_:a.subject.package_,name:a.subject.name}),{href:c,label:l}=this.resolveNavEntry(a,i,t),d=`/${e.namespace?.split("/")[1]?.split("@")[0]}/${(e.namespace||"").split("@")[1]}/${e.name}`,g=c===d?' aria-current="page"':"";r.push(`<li><a class="kan-nav-link" href="${f(c)}"${g}>${f(l)}</a></li>`)}return`<nav class="kan-site-nav"><ul>
|
|
108
|
-
${r.join(`
|
|
109
|
-
`)}
|
|
110
|
-
</ul></nav>`}resolveNavEntry(e,t,n){if(t&&D(t).map(i=>i.subject).some(i=>i.publisher===ke.publisher&&i.package_===ke.package_&&i.name===ke.name)){let i=v(t,H),c=X(t,xe);if(c instanceof U&&c.object instanceof R){let l=c.object,d=this.readLabelForUri({publisher:l.subject.publisher,package_:l.subject.package_,name:l.subject.name});return{href:this.urlForReference(l,xe,n),label:i??d??l.subject.name}}}let s=ee.formatResourceUrl({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},"*",{contextPublisher:n}),o=t?v(t,H)??e.subject.name:e.subject.name;return{href:s,label:o}}findNavGroupForPublisher(e){for(let t of this.catalog){if(!(t instanceof J)||!(t.namespace||"").startsWith(`${e}/`))continue;if(D(t).map(r=>r.subject).some(r=>r.publisher===oe.publisher&&r.package_===oe.package_&&r.name===oe.name))return t}}renderMarkdown(e,t){let n=K(e,A);if(!n)return"<!-- LookRenderer.Markdown: no look.source -->";let s=this.readPropertyValueText(t,n);return s?`<section class="kan-markdown">
|
|
111
|
-
${Le(s)}
|
|
112
|
-
</section>`:""}renderRawMarkdown(e){let t=this.findCascadedLook(e);if(!t)return;let n=Ne(t.declaration),s=[];for(let o of n){let r=Ve(o);if(!r||!E(r,Ue))continue;let a=K(o,A);if(!a)continue;let i=this.readPropertyValueText(e,a);i&&s.push(i)}return s.length>0?s.join(`
|
|
113
|
-
|
|
114
|
-
`):void 0}renderHero(e,t,n){let s=['<header class="kan-hero">'],o=K(e,bn);if(o){let l=this.readPropertyValueText(t,o);l&&s.push(`<span class="kan-hero-eyebrow">${f(l)}</span>`)}let r=K(e,mn),a="";r&&(a=this.readPropertyValueText(t,r)??""),a||(a=t.name),s.push(`<h1 class="kan-hero-title">${f(a)}</h1>`);let i=K(e,jn);if(i){let l=this.readPropertyValueText(t,i);l&&s.push(`<p class="kan-hero-subtitle">${f(l)}</p>`)}let c=K(e,Ce);if(c){let l=this.readPropertyValueReferences(t,c);if(l.length>0){let d=l.map(g=>this.renderBadge(g,Ce,n)).join("");s.push(`<div class="kan-hero-badges">${d}</div>`)}}return s.push("</header>"),s.join(`
|
|
115
|
-
`)}renderPropertyList(e,t,n){let s=K(e,A);if(!s)return"<!-- LookRenderer: PropertyList missing look.source -->";let o=this.readLabelForUri(s)??s.name,r=X(t,s),a=this.gatherValueItems(r),i=a.length>0?a.map(c=>`<li>${this.renderInlineValue(c,A,n)}</li>`).join(""):'<li class="kan-empty">(no values)</li>';return['<section class="kan-property-list">',`<h3 class="kan-property-list-title">${f(o)}</h3>`,`<ul class="kan-property-list-items">${i}</ul>`,"</section>"].join(`
|
|
116
|
-
`)}renderBadgeRow(e,t,n){let s=K(e,A);if(!s)return"<!-- LookRenderer: BadgeRow missing look.source -->";let o=this.readPropertyValueReferences(t,s);return o.length===0?"":`<div class="kan-badge-row">${o.map(a=>this.renderBadge(a,A,n)).join("")}</div>`}renderChipRow(e,t,n){let s=Ae(e,$n);if(s.length===0)return"<!-- LookRenderer: ChipRow has no look.chips -->";let o=[];for(let r of s){let a=X(t,r);if(!a)continue;let i=this.readLabelForUri(r)??r.name,c=this.renderStatementInlineValue(a,r,n);c&&o.push(`<span class="kan-chip"><span class="kan-chip-key">${f(i)}</span> <span class="kan-chip-val">${c}</span></span>`)}return o.length===0?"":`<div class="kan-chip-row">${o.join("")}</div>`}renderReferenceList(e,t,n){let s=Ae(e,me);if(s.length===0)return"<!-- LookRenderer: ReferenceList has no look.entries -->";let o=[];for(let r of s){let a=this.readPropertyValueReferences(t,r);if(a.length===0)continue;let i=this.readLabelForUri(r)??r.name,c=a.map(l=>this.renderReferenceLink(l,me,n)).join(", ");o.push(`<dt>${f(i)}</dt><dd>${c}</dd>`)}return o.length===0?"":`<dl class="kan-reference-list">${o.join("")}</dl>`}readPropertyValueText(e,t){let n=X(e,t);if(n){if(n instanceof B)return n.object;if(n instanceof U){let s=n.object;return this.readLabelForUri({publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name})??s.subject.name}if(n instanceof F)return(n.object??[]).map(o=>o instanceof R?this.readLabelForUri({publisher:o.subject.publisher,package_:o.subject.package_,name:o.subject.name})??o.subject.name:o instanceof te?o.name??"":String(o)).filter(o=>o).join(", ")}}readPropertyValueReferences(e,t){let n=X(e,t);if(!n)return[];if(n instanceof U)return[n.object];if(n instanceof F){let s=[];for(let o of n.object??[])o instanceof R&&s.push(o);return s}return[]}gatherValueItems(e){return e?e instanceof F?e.object??[]:e instanceof U?[e.object]:e instanceof Z?[e.object]:e instanceof B?[e.object]:[]:[]}renderInlineValue(e,t,n){return e instanceof R?this.renderReferenceLink(e,t,n):e instanceof te?f(e.name??"(embedded)"):typeof e=="string"?f(e):typeof e=="number"||typeof e=="boolean"?f(String(e)):""}renderStatementInlineValue(e,t,n){return e instanceof B?f(e.object):e instanceof U?this.renderReferenceLink(e.object,t,n):e instanceof F?(e.object??[]).map(o=>this.renderInlineValue(o,t,n)).filter(o=>o).join(", "):""}renderReferenceLink(e,t,n){let s=this.readLabelForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name})??e.subject.name,o=this.urlForReference(e,t,n);return`<a class="kan-link" href="${f(o)}">${f(s)}</a>`}renderBadge(e,t,n){let s=this.readLabelForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name})??e.subject.name,o=this.readCommentForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name}),r=this.urlForReference(e,t,n),a=o?` title="${f(o)}"`:"";return`<a class="kan-badge" href="${f(r)}"${a}>${f(s)}</a>`}urlForReference(e,t,n){let s=t?this.getUrlFormForProperty(t):"=";return ee.formatResourceUrl({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},s,{contextPublisher:n})}getUrlFormForProperty(e){let t=x(this.catalog,e);if(!t)return"=";let n=v(t,_n);return n==="*"||n==="^"||n==="~"||n==="="?n:"="}readLabelForUri(e){let t=x(this.catalog,e);if(t)return v(t,H)}readCommentForUri(e){let t=x(this.catalog,e);if(t)return v(t,Ie)}};function be(u){let e=new Map;for(let t of u.statement){if(!(t instanceof Z)||!V(t,he.publisher,he.package_,he.name))continue;let n=t.object;for(let s of n.statement){if(!(s instanceof B))continue;let o=s.predicate?.subject?.name;if(!o)continue;let r=s.object;e.has(o)||e.set(o,r)}}return e}function je(u){for(let e of u.statement)if(e instanceof Z&&V(e,pe.publisher,pe.package_,pe.name))return e.object}function Ne(u){for(let e of u.statement){if(!(e instanceof F)||!V(e,ge.publisher,ge.package_,ge.name))continue;let t=[];for(let n of e.object??[])n instanceof te&&t.push(n);return t}return[]}function Ve(u){for(let e of u.statement)if(e instanceof U&&e.predicate?.subject?.name==="type"&&e.object instanceof R){let t=e.object.subject;return{publisher:t.publisher,package_:t.package_,name:t.name}}}function K(u,e){for(let t of u.statement)if(t instanceof U&&V(t,e.publisher,e.package_,e.name)&&t.object instanceof R){let n=t.object.subject;return{publisher:n.publisher,package_:n.package_,name:n.name}}}function Ae(u,e){for(let t of u.statement){if(!(t instanceof F)||!V(t,e.publisher,e.package_,e.name))continue;let n=[];for(let s of t.object??[])s instanceof R&&n.push({publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name});return n}return[]}function X(u,e){for(let t of u.statement)if(V(t,e.publisher,e.package_,e.name))return t}function v(u,e){for(let t of u.statement)if(t instanceof B&&V(t,e.publisher,e.package_,e.name))return t.object}function Me(u,e){for(let t of u.statement)if(t instanceof fe&&V(t,e.publisher,e.package_,e.name))return t.object}function D(u){let e=[];for(let t of u.statement)if(t instanceof U){if(t.predicate?.subject?.name!=="type")continue;t.object instanceof R&&e.push(t.object)}else if(t instanceof F){if(t.predicate?.subject?.name!=="type")continue;for(let n of t.object??[])n instanceof R&&e.push(n)}return e}function ie(u){let e=[];for(let t of u.statement)if(t instanceof U){if(t.predicate?.subject?.name!=="subClassOf")continue;t.object instanceof R&&e.push(t.object)}else if(t instanceof F){if(t.predicate?.subject?.name!=="subClassOf")continue;for(let n of t.object??[])n instanceof R&&e.push(n)}return e}function ce(u,e){let t=[];for(let n of u){if(!(n instanceof J)||n.name!==e.name)continue;(n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&t.push(n)}return t}function x(u,e){let t="version"in e?e.version:void 0;if(t){let n=`${e.publisher}/${e.package_}@${t.major}.${t.minor}.${t.patch}`;for(let s of u)if(s instanceof J&&s.name===e.name&&s.namespace===n)return s}for(let n of u){if(!(n instanceof J)||n.name!==e.name)continue;if((n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))return n}}function V(u,e,t,n){let s=u.predicate?.subject;return s?s.publisher===e&&s.package_===t&&s.name===n:!1}function E(u,e){return u.publisher===e.publisher&&u.package_===e.package_&&u.name===e.name}function z(u){return`${u.publisher}/${u.package_}/${u.name}`}function G(u){let e=u.namespace||"",t=e.indexOf("/");return t>=0?e.substring(0,t):e}function f(u){return u.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Be(u){let e=u.lastIndexOf(".");return e>=0?u.substring(e+1):u}function He(u,e){for(let t of u.statement)if(t.predicate?.subject?.name===e)return t}function se(u){return u.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function vn(u){if(!u)return"";let e=/^(\d{4})-(\d{2})-(\d{2})/.exec(u);return e?`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][parseInt(e[2],10)-1]??e[2]} ${parseInt(e[3],10)}`:u}export{Le as a,$e as b};
|