@kanonak-protocol/sdk 3.30.0 → 3.32.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-OKB3OVYM.js +116 -0
- package/dist/index.js +1 -1
- package/dist/look/LookRenderer.d.ts +76 -2
- package/dist/transformations/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-M5P56WR3.js +0 -116
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import{a as ne}from"./chunk-NIGFQYVA.js";import{a as G}from"./chunk-4YHWMYAZ.js";import{c as X,d as R,g as B,h as oe,i as de,j as w,k as Z,l as E}from"./chunk-W6T7MOKY.js";function Oe(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-${Ue(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&&Le(e[n+1])){let i=pe(s),c=Je(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(Xe(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 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&&Le(e[n+1]));)a.push(e[n]),n++;t.push(`<p>${te(a.join(" "))}</p>`)}return t.join(`
|
|
11
|
+
`)}function Le(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 Je(u){return pe(u).map(e=>{let t=e.startsWith(":"),n=e.endsWith(":");return t&&n?"center":n?"right":t?"left":null})}function Xe(u,e,t){let n=r=>{let a=e[r];return a?` style="text-align:${a}"`:""},s=u.map((r,a)=>`<th${n(a)}>${te(r)}</th>`).join(""),o=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
|
+
${o}
|
|
16
|
+
</tbody>
|
|
17
|
+
</table>`}function te(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="${Ue(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 Ue(u){return u.replace(/"/g,""").replace(/&/g,"&")}var ke={publisher:"kanonak.org",package_:"derivation",name:"look"},ge={publisher:"kanonak.org",package_:"derivation",name:"tokens"},A={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},V={publisher:"kanonak.org",package_:"core-rdf",name:"label"},Ie={publisher:"kanonak.org",package_:"core-rdf",name:"comment"},Ze={publisher:"kanonak.org",package_:"look",name:"Hero"},Qe={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"},xe={publisher:"kanonak.org",package_:"look",name:"Markdown"},ie={publisher:"kanonak.org",package_:"look",name:"NavGroup"},he={publisher:"kanonak.org",package_:"look",name:"NavLink"},Fe={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"},on={publisher:"kanonak.org",package_:"look",name:"Figure"},cn={publisher:"kanonak.org",package_:"look",name:"StatRow"},ln={publisher:"kanonak.org",package_:"look",name:"Horizon"},un={publisher:"kanonak.org",package_:"look",name:"stats"},fn={publisher:"kanonak.org",package_:"look",name:"statPath"},dn={publisher:"kanonak.org",package_:"look",name:"statLabel"},pn={publisher:"kanonak.org",package_:"look",name:"labelPath"},kn={publisher:"kanonak.org",package_:"look",name:"badgePath"},Ee={publisher:"kanonak.org",package_:"look",name:"orderBy"},Te={publisher:"kanonak.org",package_:"look",name:"track"},Pe={publisher:"kanonak.org",package_:"look",name:"metricPath"},Ce={publisher:"kanonak.org",package_:"look",name:"hueBy"},gn={publisher:"kanonak.org",package_:"look",name:"lowerPath"},hn={publisher:"kanonak.org",package_:"look",name:"upperPath"},mn={publisher:"kanonak.org",package_:"look",name:"axisMin"},bn={publisher:"kanonak.org",package_:"look",name:"axisMax"},jn={publisher:"kanonak.org",package_:"look",name:"valueLabel"};var _n={publisher:"kanonak.org",package_:"look",name:"semanticSvg"},$n={publisher:"kanonak.org",package_:"look",name:"tierChip"},vn={publisher:"kanonak.org",package_:"look",name:"tierIcon"},Rn={publisher:"kanonak.org",package_:"look",name:"tierCard"},Kn={publisher:"kanonak.org",package_:"look",name:"tierFull"};var me={publisher:"kanonak.org",package_:"look",name:"bands"},Sn={publisher:"kanonak.org",package_:"look",name:"title"},yn={publisher:"kanonak.org",package_:"look",name:"eyebrow"},Ln={publisher:"kanonak.org",package_:"look",name:"subtitle"},Ne={publisher:"kanonak.org",package_:"look",name:"badges"},T={publisher:"kanonak.org",package_:"look",name:"source"},On={publisher:"kanonak.org",package_:"look",name:"chips"},be={publisher:"kanonak.org",package_:"look",name:"entries"},wn={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 o=s.shift(),r=Q(o.subject);if(n.has(r))continue;n.add(r);let a=y(this.catalog,o.subject);if(!a)continue;let i=_e(a);if(i)return{declaration:i,sourceClass:{publisher:o.subject.publisher,package_:o.subject.package_,name:o.subject.name}};for(let c of ce(a))s.push(c)}if(!n.has(Q(A))){let o=y(this.catalog,A);if(o){let r=_e(o);if(r)return{declaration:r,sourceClass:{...A}}}}}findCascadedTokens(e){let t=new Map;for(let[o,r]of je(e))t.has(o)||t.set(o,r);let n=new Set,s=W(e);for(;s.length>0;){let o=s.shift(),r=Q(o.subject);if(n.has(r))continue;n.add(r);let a=le(this.catalog,o.subject);if(a.length!==0)for(let i of a){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(Q(A))){let o=le(this.catalog,A);for(let r of o)for(let[a,i]of je(r))t.has(a)||t.set(a,i)}return t}renderSvg(e){let t=j(e,V)??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??""),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,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=Me(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 o=Be(n[n.length-1]),r=Me(s,o);if(r){if(r instanceof B||r instanceof oe||r instanceof de)return String(r.object);if(r instanceof w&&r.object instanceof R){let a=r.object,i=y(this.catalog,a.subject);return i?j(i,V)??a.subject.name:a.subject.name}}}collectCascadedSvgTiers(e){let t={},n=r=>{let a=M(r,_n);if(!(a instanceof Z))return;let i=a.object,c=j(i,$n),l=j(i,vn),d=j(i,Rn),k=j(i,Kn);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,o=W(e);for(;o.length>0;){let r=o.shift(),a=Q(r.subject);if(s.has(a))continue;s.add(a);let i=le(this.catalog,r.subject);for(let c of i){n(c);for(let l of ce(c))o.push(l)}}if(!s.has(Q(A)))for(let r of le(this.catalog,A))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(q(e))??"";return`${s}
|
|
33
|
+
${o}`}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 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=Ae(t.declaration);if(n.length===0)return"<!-- LookRenderer: look declaration has no bands -->";let s=q(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===A.publisher&&t.sourceClass.package_===A.package_&&t.sourceClass.name===A.name):!1}renderPackageVersionList(e,t,n){let s=q(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,V)??e.name,o=`${e.name}.css`,r=this.hasSvgDerivation(e)?`<figure class="kan-figure"><img src="${f(e.name)}.svg" alt=""></figure>
|
|
79
|
+
`:"",a=q(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=W(e);for(;n.length>0;){let s=n.shift(),o=Q(s.subject);if(t.has(o))continue;t.add(o);let r=y(this.catalog,s.subject);if(r){for(let a of r.statement)if(a instanceof E&&H(a,"kanonak.org","derivation","derivations")){for(let i of a.object??[])if(i instanceof G)for(let c of i.statement){if(!(c instanceof w)||!H(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 ce(r))n.push(a)}}return!1}renderBand(e,t,n){let s=$e(e);return s?U(s,Ze)?this.renderHero(e,t,n):U(s,Qe)?this.renderPropertyList(e,t,n):U(s,en)?this.renderBadgeRow(e,t,n):U(s,nn)?this.renderChipRow(e,t,n):U(s,tn)?this.renderReferenceList(e,t,n):U(s,xe)?this.renderMarkdown(e,t):U(s,ie)?this.renderNavGroup(t,n):U(s,sn)?this.renderResourceGrid(e,n,t):U(s,rn)?this.renderTimeline(e,n):U(s,an)?this.renderVersionDiff(e,n):U(s,on)?this.renderFigure(e,t,n):U(s,cn)?this.renderStatRow(e,t):U(s,ln)?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:o,lowerPath:r,upperPath:a}=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,V)??h,points:new Array(c).fill(null),...r?{lower:new Array(c).fill(null)}:{},...a?{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(a&&_.upper){let $=l(b,a);Number.isFinite($)&&(_.upper[k]=$)}if(o){let $=l(b,o);Number.isFinite($)&&(_.hue=$)}_.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 ne.formatResourceUrl({publisher:q(e),package_:o,name:e.name,...a?{version:a}:{}},n,{contextPublisher:t})}renderVersionDiff(e,t){let n=K(e,T);if(!n)return"<!-- LookRenderer.VersionDiff: no look.source -->";let s=j(e,Pe),o=K(e,Te);if(!o||!s)return"<!-- LookRenderer.VersionDiff: needs look.track + look.metricPath -->";let r=K(e,Ee),a=j(e,Ce),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,o,s,{hueBy:a});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 ee=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">${ee}</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%)`,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,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,o=K(e,T);if(o){let i=y(this.catalog,o);i&&(s=i)}let r=this.svgUrlForSubject(s,n),a=j(s,V)??s.name;return`<figure class="kan-figure"><img class="kan-figure-img" src="${f(r)}" alt="${f(a)}" loading="lazy"/></figure>`}renderStatRow(e,t){let n=M(e,un),s=this.gatherValueItems(n).filter(r=>r instanceof G);if(s.length===0)return"<!-- LookRenderer.StatRow: no look.stats -->";let o=[];for(let r of s){let a=j(r,fn);if(!a)continue;let i=this.resolvePath(t,a);if(i===void 0)continue;let c=j(r,dn)??"";o.push('<div class="kan-stat">'+(c?`<span class="kan-stat-label">${f(c)}</span>`:"")+`<span class="kan-stat-val">${f(i)}</span></div>`)}return o.length===0?"":`<div class="kan-stat-row">${o.join("")}</div>`}renderHorizon(e,t,n){let s=K(e,T);if(!s)return"<!-- LookRenderer.Horizon: no look.source -->";let o=this.gatherValueItems(M(t,s)).filter(a=>a instanceof G);return o.length===0?"":`<section class="kan-horizon">${o.map(a=>this.renderConditionNode(a,n,0)).join("")}</section>`}renderConditionNode(e,t,n){let s=$e(e),o=s?this.readLabelForUri({publisher:s.publisher,package_:s.package_,name:s.name})??s.name:"Condition",r=[],a=[];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 B||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)a.push(this.renderConditionNode(l.object,t,n+1));else if(l instanceof E)for(let p of l.object??[])p instanceof G&&a.push(this.renderConditionNode(p,t,n+1))}let i=r.length?`<div class="kan-cond-fields">${r.join("")}</div>`:"",c=a.length?`<div class="kan-cond-children">${a.join("")}</div>`:"";return`<div class="kan-cond"><div class="kan-cond-type">${f(o)}</div>${i}${c}</div>`}renderTimeline(e,t){let n=K(e,T);if(!n)return"<!-- LookRenderer.Timeline: no look.source -->";let s=K(e,Ee),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,k)=>r(d).localeCompare(r(k))),i=K(e,Te),c=j(e,Pe);return i&&c?this.renderTrajectoryChart(a,i,c,e,t,r):`<section class="kan-timeline"><ol>
|
|
96
|
+
${a.map(d=>{let k=d.namespace||"",p=k.split("/")[1]?.split("@")[0]??"",m=k.split("@")[1]??"",b=m?this.parseVersion(m):void 0,h=ne.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,o,r){let a=s,i=j(a,Ce),c=j(a,gn),l=j(a,hn),d=j(a,jn),k=He(a,mn),p=He(a,bn),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:_-$,ee=p!==void 0?p:S+$;ee-P<1e-9&&(ee=P+1);let z=1e3,Y=440,L={top:28,right:24,bottom:56,left:52},Re=z-L.left-L.right,De=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)/(ee-P))*De,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*(ee-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,o),I=(g.namespace||"").split("@")[1]??"",O=re(v),x=Un(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 Ge=`<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>",We=d?`${f(d)}=`:"",qe=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 ze=N>0?"up":"down",Ye=N>0?"\u25B2":"\u25BC";F=` <span class="kan-fan-delta ${ze}">${N>0?"+":""}${N.toFixed(2)} ${Ye}</span>`}else F=' <span class="kan-fan-delta flat">\u2014</span>'}let J=x!==void 0?`${We}${x.toFixed(2)}`:"\u2014",D=g.lastSubject?`<a href="${f(this.hrefForSubject(g.lastSubject,o))}">${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">${Ge}</div><div class="kan-fan-legend">${qe.join("")}</div></section>`}renderResourceGrid(e,t,n){let s=K(e,T);if(!s)return"<!-- LookRenderer.ResourceGrid: no look.source -->";let o=y(this.catalog,s),r=o?W(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=y(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=j(c,V)??c.name,d=j(c,Ie),k=c.namespace||"",p=k.split("/")[1]?.split("@")[0]??"",m=k.split("@")[1]??"",b=m?this.parseVersion(m):void 0,h=ne.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 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,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=M(n,be);if(!(s instanceof E))return"";let o=s.object??[];if(o.length===0)return"";let r=[];for(let a of o){if(!(a instanceof R))continue;let i=y(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}`,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,V),c=M(t,Fe);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,Fe,n),label:i??d??l.subject.name}}}let s=ne.formatResourceUrl({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},"*",{contextPublisher:n}),o=t?j(t,V)??e.subject.name:e.subject.name;return{href:s,label:o}}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){let n=K(e,T);if(!n)return"<!-- LookRenderer.Markdown: no look.source -->";let s=this.readPropertyValueText(t,n);return s?`<section class="kan-markdown">
|
|
111
|
+
${Oe(s)}
|
|
112
|
+
</section>`:""}renderRawMarkdown(e){let t=this.findCascadedLook(e);if(!t)return;let n=Ae(t.declaration),s=[];for(let o of n){let r=$e(o);if(!r||!U(r,xe))continue;let a=K(o,T);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,yn);if(o){let l=this.readPropertyValueText(t,o);l&&s.push(`<span class="kan-hero-eyebrow">${f(l)}</span>`)}let r=K(e,Sn),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,Ln);if(i){let l=this.readPropertyValueText(t,i);l&&s.push(`<p class="kan-hero-subtitle">${f(l)}</p>`)}let c=K(e,Ne);if(c){let l=this.readPropertyValueReferences(t,c);if(l.length>0){let d=l.map(k=>this.renderBadge(k,Ne,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 o=this.readLabelForUri(s)??s.name,r=M(t,s),a=this.gatherValueItems(r),i=a.length>0?a.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(o)}</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 o=this.readPropertyValueReferences(t,s);return o.length===0?"":`<div class="kan-badge-row">${o.map(a=>this.renderBadge(a,T,n)).join("")}</div>`}renderChipRow(e,t,n){let s=Ve(e,On);if(s.length===0)return"<!-- LookRenderer: ChipRow has no look.chips -->";let o=[];for(let r of s){let a=M(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=Ve(e,be);if(s.length===0)return"<!-- LookRenderer: ReferenceList has no look.entries -->";let o=j(e,pn),r=j(e,kn),a=[];for(let i of s){let c=this.readPropertyValueReferences(t,i);if(c.length===0)continue;let l=this.readLabelForUri(i)??i.name;if(o){let d=c.map(k=>this.renderDetailRow(k,o,r,n)).filter(k=>k).join("");d&&a.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(", ");a.push(`<dt>${f(l)}</dt><dd>${d}</dd>`)}}return a.length===0?"":`<dl class="kan-reference-list">${a.join("")}</dl>`}renderDetailRow(e,t,n,s){let o=y(this.catalog,{publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name,...e.subject.version?{version:e.subject.version}:{}});if(!o)return"";let r=this.resolvePath(o,t)??j(o,V)??o.name,a=this.hrefForSubject(o,s),i=this.svgUrlForSubject(o,s),c="";if(n){let l=this.resolvePath(o,n);l&&(c=`<span class="kan-ref-badge">${f(l)}</span>`)}return`<li class="kan-ref-row"><a class="kan-ref-rowlink" href="${f(a)}"><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=M(e,t);if(n){if(n instanceof B)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(o=>o instanceof R?this.readLabelForUri({publisher:o.subject.publisher,package_:o.subject.package_,name:o.subject.name})??o.subject.name:o instanceof G?o.name??"":String(o)).filter(o=>o).join(", ")}}readPropertyValueReferences(e,t){let n=M(e,t);if(!n)return[];if(n instanceof w)return[n.object];if(n instanceof E){let s=[];for(let o of n.object??[])o instanceof R&&s.push(o);return s}return[]}gatherValueItems(e){return e?e instanceof E?e.object??[]:e instanceof w?[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 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 B?f(e.object):e instanceof w?this.renderReferenceLink(e.object,t,n):e instanceof E?(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 ne.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,wn);return n==="*"||n==="^"||n==="~"||n==="="?n:"="}readLabelForUri(e){let t=y(this.catalog,e);if(t)return j(t,V)}readCommentForUri(e){let t=y(this.catalog,e);if(t)return j(t,Ie)}};function je(u){let e=new Map;for(let t of u.statement){if(!(t instanceof Z)||!H(t,ge.publisher,ge.package_,ge.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 _e(u){for(let e of u.statement)if(e instanceof Z&&H(e,ke.publisher,ke.package_,ke.name))return e.object}function Ae(u){for(let e of u.statement){if(!(e instanceof E)||!H(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&&H(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 Ve(u,e){for(let t of u.statement){if(!(t instanceof E)||!H(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 M(u,e){for(let t of u.statement)if(H(t,e.publisher,e.package_,e.name))return t}function j(u,e){for(let t of u.statement)if(t instanceof B&&H(t,e.publisher,e.package_,e.name))return t.object}function He(u,e){for(let t of u.statement)if(t instanceof oe&&H(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 H(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 Q(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 Me(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 Un(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{Oe 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-OKB3OVYM.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)}
|
|
@@ -190,13 +190,80 @@ export declare class LookRenderer {
|
|
|
190
190
|
* chronological sequence of clickable nodes. Each node links to the
|
|
191
191
|
* instance's exact-version URL and shows its order value + key.
|
|
192
192
|
*/
|
|
193
|
+
/**
|
|
194
|
+
* Follow a `track` property's referenced sub-resources across a sorted
|
|
195
|
+
* sequence of source instances, aligning them by stable resource key.
|
|
196
|
+
* Returns one TrackedSeries per distinct key, with `points[i]` set to
|
|
197
|
+
* the `metricPath` value resolved on that key's sub-resource in the
|
|
198
|
+
* i-th instance (null when absent / unresolvable). The optional `hueBy`
|
|
199
|
+
* path supplies each series' hue. Shared by the Timeline trajectory
|
|
200
|
+
* chart and the VersionDiff trend rows.
|
|
201
|
+
*/
|
|
202
|
+
private collectTrackedSeries;
|
|
203
|
+
/**
|
|
204
|
+
* Build a resource URL from a parsed SubjectKanonak (namespace
|
|
205
|
+
* `publisher/package@version`), applying the given URL form.
|
|
206
|
+
*/
|
|
207
|
+
private hrefForSubject;
|
|
208
|
+
/**
|
|
209
|
+
* Render a VersionDiff band — the "Changes" trend rows. Same inputs as
|
|
210
|
+
* the Timeline trajectory mode (`source` + `orderBy` + `track` +
|
|
211
|
+
* `metricPath`, optional `hueBy`), but one compact row per tracked key:
|
|
212
|
+
* the (linked) label, the first value, a small autoscaled sparkline of
|
|
213
|
+
* the metric across the version sequence, the latest value, and a
|
|
214
|
+
* total-change delta badge (latest − first).
|
|
215
|
+
*/
|
|
216
|
+
private renderVersionDiff;
|
|
217
|
+
/**
|
|
218
|
+
* A small inline-SVG sparkline for one series, autoscaled to the
|
|
219
|
+
* series' own [min,max] so small moves are visible. Flat series render
|
|
220
|
+
* a centered baseline. Nulls break the line.
|
|
221
|
+
*/
|
|
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;
|
|
193
257
|
private renderTimeline;
|
|
194
258
|
/**
|
|
195
259
|
* Render the Timeline trajectory chart — a server-rendered inline SVG with
|
|
196
260
|
* one line per tracked sub-resource (aligned by stable key) across the
|
|
197
261
|
* version sequence, plus an HTML legend reporting each series' latest
|
|
198
|
-
* value and its
|
|
199
|
-
*
|
|
262
|
+
* value and its change from the first version. Ontology-neutral: the Y
|
|
263
|
+
* axis autoscales to the data unless the band declares `axisMin`/
|
|
264
|
+
* `axisMax`; the legend value carries an optional `valueLabel` prefix;
|
|
265
|
+
* and when the band declares `lowerPath`/`upperPath`, a shaded envelope
|
|
266
|
+
* is drawn between those two metric paths per series. Each series is
|
|
200
267
|
* themed by `hueBy` when present, else by an evenly spaced palette.
|
|
201
268
|
*/
|
|
202
269
|
private renderTrajectoryChart;
|
|
@@ -270,6 +337,13 @@ export declare class LookRenderer {
|
|
|
270
337
|
private renderBadgeRow;
|
|
271
338
|
private renderChipRow;
|
|
272
339
|
private renderReferenceList;
|
|
340
|
+
/**
|
|
341
|
+
* Render one referenced resource as a detail row: its chip-tier
|
|
342
|
+
* SemanticSvg icon, the text resolved from `labelPath` (falling back to
|
|
343
|
+
* rdfs.label), and an optional badge resolved from `badgePath`. The whole
|
|
344
|
+
* row links to the resource (exact-version pin, per the entries slot).
|
|
345
|
+
*/
|
|
346
|
+
private renderDetailRow;
|
|
273
347
|
/**
|
|
274
348
|
* Read a property's value off an instance and return it as a single
|
|
275
349
|
* 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-OKB3OVYM.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.32.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.32.0",
|
|
117
117
|
"ignore": "^7.0.5",
|
|
118
118
|
"js-yaml": "^4.1.0",
|
|
119
119
|
"yaml": "^2.7.0"
|
package/dist/chunk-M5P56WR3.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import{a as D}from"./chunk-NIGFQYVA.js";import{a as Q}from"./chunk-4YHWMYAZ.js";import{c as G,d as j,g as P,h as me,i as be,j as K,k as Y,l as x}from"./chunk-W6T7MOKY.js";function _e(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=$e(c.join(`
|
|
4
|
-
`)),d=i?` class="language-${ve(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=J(r[2].trim());t.push(`<h${i}>${c}</h${i}>`),n++;continue}if(s.includes("|")&&n+1<e.length&&je(e[n+1])){let i=re(s),c=Ce(e[n+1]);n+=2;let l=[];for(;n<e.length&&e[n].trim()!==""&&e[n].includes("|");)l.push(re(e[n])),n++;t.push(Te(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>${J(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>${J(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&&je(e[n+1]));)o.push(e[n]),n++;t.push(`<p>${J(o.join(" "))}</p>`)}return t.join(`
|
|
11
|
-
`)}function je(u){return u.includes("-")?/^[\s|:-]+$/.test(u):!1}function re(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 Ce(u){return re(u).map(e=>{let t=e.startsWith(":"),n=e.endsWith(":");return t&&n?"center":n?"right":t?"left":null})}function Te(u,e,t){let n=r=>{let o=e[r];return o?` style="text-align:${o}"`:""},s=u.map((r,o)=>`<th${n(o)}>${J(r)}</th>`).join(""),a=t.map(r=>`<tr>${r.map((i,c)=>`<td${n(c)}>${J(i)}</td>`).join("")}</tr>`).join(`
|
|
12
|
-
`);return`<table>
|
|
13
|
-
<thead><tr>${s}</tr></thead>
|
|
14
|
-
<tbody>
|
|
15
|
-
${a}
|
|
16
|
-
</tbody>
|
|
17
|
-
</table>`}function J(u){let e=$e(u);return e=e.replace(/`([^`\n]+)`/g,(t,n)=>`<code>${n}</code>`),e=e.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(t,n,s)=>`<a href="${ve(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 $e(u){return u.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ve(u){return u.replace(/"/g,""").replace(/&/g,"&")}var ae={publisher:"kanonak.org",package_:"derivation",name:"look"},oe={publisher:"kanonak.org",package_:"derivation",name:"tokens"},E={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},N={publisher:"kanonak.org",package_:"core-rdf",name:"label"},Re={publisher:"kanonak.org",package_:"core-rdf",name:"comment"},Pe={publisher:"kanonak.org",package_:"look",name:"Hero"},Ne={publisher:"kanonak.org",package_:"look",name:"PropertyList"},Ve={publisher:"kanonak.org",package_:"look",name:"BadgeRow"},Ae={publisher:"kanonak.org",package_:"look",name:"ChipRow"},Be={publisher:"kanonak.org",package_:"look",name:"ReferenceList"},ye={publisher:"kanonak.org",package_:"look",name:"Markdown"},ee={publisher:"kanonak.org",package_:"look",name:"NavGroup"},ie={publisher:"kanonak.org",package_:"look",name:"NavLink"},Ke={publisher:"kanonak.org",package_:"look",name:"target"},Me={publisher:"kanonak.org",package_:"look",name:"ResourceGrid"},He={publisher:"kanonak.org",package_:"look",name:"Timeline"},Ge={publisher:"kanonak.org",package_:"look",name:"orderBy"},De={publisher:"kanonak.org",package_:"look",name:"track"},We={publisher:"kanonak.org",package_:"look",name:"metricPath"},qe={publisher:"kanonak.org",package_:"look",name:"hueBy"};var Ye={publisher:"kanonak.org",package_:"look",name:"semanticSvg"},Je={publisher:"kanonak.org",package_:"look",name:"tierChip"},ze={publisher:"kanonak.org",package_:"look",name:"tierIcon"},Qe={publisher:"kanonak.org",package_:"look",name:"tierCard"},Xe={publisher:"kanonak.org",package_:"look",name:"tierFull"};var ce={publisher:"kanonak.org",package_:"look",name:"bands"},Ze={publisher:"kanonak.org",package_:"look",name:"title"},en={publisher:"kanonak.org",package_:"look",name:"eyebrow"},nn={publisher:"kanonak.org",package_:"look",name:"subtitle"},Se={publisher:"kanonak.org",package_:"look",name:"badges"},V={publisher:"kanonak.org",package_:"look",name:"source"},tn={publisher:"kanonak.org",package_:"look",name:"chips"},ue={publisher:"kanonak.org",package_:"look",name:"entries"},sn={publisher:"kanonak.org",package_:"look",name:"urlForm"},de=class{constructor(e){this.catalog=e}catalog;findCascadedLook(e){let t=fe(e);if(t)return{declaration:t,sourceClass:{publisher:C(e),package_:(e.namespace||"").split("/")[1]?.split("@")[0]??"",name:e.name}};let n=new Set,s=A(e);for(;s.length>0;){let a=s.shift(),r=q(a.subject);if(n.has(r))continue;n.add(r);let o=S(this.catalog,a.subject);if(!o)continue;let i=fe(o);if(i)return{declaration:i,sourceClass:{publisher:a.subject.publisher,package_:a.subject.package_,name:a.subject.name}};for(let c of ne(o))s.push(c)}if(!n.has(q(E))){let a=S(this.catalog,E);if(a){let r=fe(a);if(r)return{declaration:r,sourceClass:{...E}}}}}findCascadedTokens(e){let t=new Map;for(let[a,r]of le(e))t.has(a)||t.set(a,r);let n=new Set,s=A(e);for(;s.length>0;){let a=s.shift(),r=q(a.subject);if(n.has(r))continue;n.add(r);let o=te(this.catalog,a.subject);if(o.length!==0)for(let i of o){for(let[c,l]of le(i))t.has(c)||t.set(c,l);for(let c of ne(i))s.push(c)}}if(!n.has(q(E))){let a=te(this.catalog,E);for(let r of a)for(let[o,i]of le(r))t.has(o)||t.set(o,i)}return t}renderSvg(e){let t=_(e,N)??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=$=>this.applyPlaceholders($,e,a),i=o(r.tierChip??""),c=o(r.tierIcon??""),l=o(r.tierCard??""),d=o(r.tierFull??""),h=[...this.findCascadedTokens(e)].map(([$,I])=>`--kan-${$}: ${I};`).join(" ");return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400" width="400" height="400" style="${X(h)}">
|
|
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 X(n[r]);let o=this.resolvePath(t,r);return o===void 0?`{{${r}}}`:X(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=Ue(n[o]),c=we(s,i);if(!c)return;if(c instanceof K&&c.object instanceof j){let l=S(this.catalog,c.object.subject);if(!l)return;s=l}else if(c instanceof Y)s=c.object;else return}if(!s)return;let a=Ue(n[n.length-1]),r=we(s,a);if(r){if(r instanceof P||r instanceof me||r instanceof be)return String(r.object);if(r instanceof K&&r.object instanceof j){let o=r.object,i=S(this.catalog,o.subject);return i?_(i,N)??o.subject.name:o.subject.name}}}collectCascadedSvgTiers(e){let t={},n=r=>{let o=W(r,Ye);if(!(o instanceof Y))return;let i=o.object,c=_(i,Je),l=_(i,ze),d=_(i,Qe),g=_(i,Xe);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,a=A(e);for(;a.length>0;){let r=a.shift(),o=q(r.subject);if(s.has(o))continue;s.add(o);let i=te(this.catalog,r.subject);for(let c of i){n(c);for(let l of ne(c))a.push(l)}}if(!s.has(q(E)))for(let r of te(this.catalog,E))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(C(e))??"";return`${s}
|
|
33
|
-
${a}`}findBaseStylesheet(e){let t="kanonak.org/site/content",n,s;for(let r of this.catalog){if(!(r instanceof G)||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 P)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=Le(t.declaration);if(n.length===0)return"<!-- LookRenderer: look declaration has no bands -->";let s=C(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===E.publisher&&t.sourceClass.package_===E.package_&&t.sourceClass.name===E.name):!1}renderPackageVersionList(e,t,n){let s=C(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,N)??e.name,a=`${e.name}.css`,r=this.hasSvgDerivation(e)?`<figure class="kan-figure"><img src="${f(e.name)}.svg" alt=""></figure>
|
|
79
|
-
`:"",o=C(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=A(e);for(;n.length>0;){let s=n.shift(),a=q(s.subject);if(t.has(a))continue;t.add(a);let r=S(this.catalog,s.subject);if(r){for(let o of r.statement)if(o instanceof x&&T(o,"kanonak.org","derivation","derivations")){for(let i of o.object??[])if(i instanceof Q)for(let c of i.statement){if(!(c instanceof K)||!T(c,"kanonak.org","derivation","format")||!(c.object instanceof j))continue;let l=c.object.subject;if(l.publisher==="kanonak.org"&&l.package_==="formats"&&l.name==="svg")return!0}}for(let o of ne(r))n.push(o)}}return!1}renderBand(e,t,n){let s=Oe(e);return s?F(s,Pe)?this.renderHero(e,t,n):F(s,Ne)?this.renderPropertyList(e,t,n):F(s,Ve)?this.renderBadgeRow(e,t,n):F(s,Ae)?this.renderChipRow(e,t,n):F(s,Be)?this.renderReferenceList(e,t,n):F(s,ye)?this.renderMarkdown(e,t):F(s,ee)?this.renderNavGroup(t,n):F(s,Me)?this.renderResourceGrid(e,n,t):F(s,He)?this.renderTimeline(e,n):`<!-- LookRenderer: unsupported band ${s.publisher}/${s.package_}/${s.name} -->`:"<!-- LookRenderer: band has no rdf:type -->"}renderTimeline(e,t){let n=O(e,V);if(!n)return"<!-- LookRenderer.Timeline: no look.source -->";let s=O(e,Ge),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,g)=>r(d).localeCompare(r(g))),i=O(e,De),c=_(e,We);return i&&c?this.renderTrajectoryChart(o,i,c,e,t,r):`<section class="kan-timeline"><ol>
|
|
96
|
-
${o.map(d=>{let g=d.namespace||"",h=g.split("/")[1]?.split("@")[0]??"",$=g.split("@")[1]??"",I=$?this.parseVersion($):void 0,L=D.formatResourceUrl({publisher:C(d),package_:h,name:d.name,...I?{version:I}:{}},"=",{contextPublisher:t}),B=r(d),Z=B?`<span class="kan-timeline-date">${f(B)}</span>`:"",z=$||d.name;return`<li class="kan-timeline-node"><a href="${f(L)}"><span class="kan-timeline-key">${f(z)}</span>${Z}</a></li>`}).join(`
|
|
97
|
-
`)}
|
|
98
|
-
</ol></section>`}renderTrajectoryChart(e,t,n,s,a,r){let o=_(s,qe),i=new Map,c=e.length;e.forEach((p,R)=>{let M=this.readPropertyValueReferences(p,t);for(let k of M){let m=S(this.catalog,{publisher:k.subject.publisher,package_:k.subject.package_,name:k.subject.name,...k.subject.version?{version:k.subject.version}:{}});if(!m)continue;let y=k.subject.name,v=i.get(y);v||(v={key:y,label:_(m,N)??y,points:new Array(c).fill(null)},i.set(y,v));let U=this.resolvePath(m,n),w=U===void 0?NaN:parseFloat(U);if(Number.isFinite(w)&&(v.points[R]=w),o){let b=this.resolvePath(m,o),H=b===void 0?NaN:parseFloat(b);Number.isFinite(H)&&(v.hue=H)}v.lastSubject=m}});let l=[...i.values()];if(l.length===0)return"<!-- LookRenderer.Timeline: no tracked series -->";let d=1e3,g=440,h={top:28,right:24,bottom:56,left:52},$=d-h.left-h.right,I=g-h.top-h.bottom,L=p=>c<=1?h.left+$/2:h.left+p/(c-1)*$,B=p=>h.top+(1-p)*I,Z=(p,R)=>p.hue!==void 0?p.hue:Math.round(R*360/l.length),z=[];for(let p of[0,.25,.5,.75,1]){let R=B(p);z.push(`<line x1="${h.left}" y1="${R.toFixed(1)}" x2="${(d-h.right).toFixed(1)}" y2="${R.toFixed(1)}" class="kan-fan-grid"/>`),z.push(`<text x="${(h.left-8).toFixed(1)}" y="${(R+4).toFixed(1)}" class="kan-fan-axis" text-anchor="end">${p.toFixed(2)}</text>`)}let pe=[];e.forEach((p,R)=>{let M=p.namespace||"",k=M.split("/")[1]?.split("@")[0]??"",m=M.split("@")[1]??"",y=m?this.parseVersion(m):void 0,v=D.formatResourceUrl({publisher:C(p),package_:k,name:p.name,...y?{version:y}:{}},"=",{contextPublisher:a}),U=L(R),w=rn(r(p));pe.push(`<a href="${f(v)}" class="kan-fan-xtick"><line x1="${U.toFixed(1)}" y1="${h.top}" x2="${U.toFixed(1)}" y2="${(g-h.bottom).toFixed(1)}" class="kan-fan-vline"/><text x="${U.toFixed(1)}" y="${(g-h.bottom+20).toFixed(1)}" class="kan-fan-xlabel" text-anchor="middle">${X(m||p.name)}</text>`+(w?`<text x="${U.toFixed(1)}" y="${(g-h.bottom+36).toFixed(1)}" class="kan-fan-xdate" text-anchor="middle">${X(w)}</text>`:"")+"</a>")});let ge=[];l.forEach((p,R)=>{let k=`hsl(${Z(p,R)},65%,60%)`,m=[],y=[];p.points.forEach((v,U)=>{if(v===null)return;let w=L(U),b=B(v);m.push(`${w.toFixed(1)},${b.toFixed(1)}`),y.push(`<circle cx="${w.toFixed(1)}" cy="${b.toFixed(1)}" r="3.5" fill="${k}"/>`)}),m.length!==0&&ge.push(`<g class="kan-fan-series" data-series="${f(p.key)}"><polyline points="${m.join(" ")}" fill="none" stroke="${k}" stroke-width="2" stroke-linejoin="round" stroke-linecap="round"/>`+y.join("")+"</g>")});let xe=`<svg class="kan-fan-svg" viewBox="0 0 ${d} ${g}" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" role="img">`+z.join("")+pe.join("")+ge.join("")+"</svg>",Ee=l.map((p,R)=>{let M=Z(p,R),k=p.points.filter(b=>b!==null),m=k.length?k[k.length-1]:void 0,y=k.length>=2?k[k.length-2]:void 0,v="";if(m!==void 0&&y!==void 0){let b=m-y;if(Math.abs(b)>=.005){let H=b>0?"up":"down",se=b>0?"\u25B2":"\u25BC";v=` <span class="kan-fan-delta ${H}">${b>0?"+":""}${b.toFixed(2)} ${se}</span>`}else v=' <span class="kan-fan-delta flat">\u2014</span>'}let U=m!==void 0?`\u03BC=${m.toFixed(2)}`:"\u2014",w=f(p.label);if(p.lastSubject){let b=p.lastSubject,H=b.namespace||"",se=H.split("/")[1]?.split("@")[0]??"",he=H.split("@")[1]??"",ke=he?this.parseVersion(he):void 0,Fe=D.formatResourceUrl({publisher:C(b),package_:se,name:b.name,...ke?{version:ke}:{}},"=",{contextPublisher:a});w=`<a href="${f(Fe)}">${f(p.label)}</a>`}return`<div class="kan-fan-legend-item" style="--kan-fan-hue:${M}"><span class="kan-fan-swatch"></span><span class="kan-fan-legend-label">${w}</span><span class="kan-fan-legend-cur">${U}${v}</span></div>`});return`<section class="kan-fan"><div class="kan-fan-chart">${xe}</div><div class="kan-fan-legend">${Ee.join("")}</div></section>`}renderResourceGrid(e,t,n){let s=O(e,V);if(!s)return"<!-- LookRenderer.ResourceGrid: no look.source -->";let a=S(this.catalog,s),r=a?A(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=S(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=_(c,N)??c.name,d=_(c,Re),g=c.namespace||"",h=g.split("/")[1]?.split("@")[0]??"",$=g.split("@")[1]??"",I=$?this.parseVersion($):void 0,L=D.formatResourceUrl({publisher:C(c),package_:h,name:c.name,...I?{version:I}:{}},"=",{contextPublisher:t}),B=d?`<p class="kan-resource-card-subtitle">${f(d)}</p>`:"";i.push(`<a class="kan-resource-card" href="${f(L)}"><h3 class="kan-resource-card-title">${f(l)}</h3>${B}</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 G))continue;A(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,g=!!S(this.catalog,{publisher:r,package_:i,name:i}),h=c?`${i}@${c}`:i,$=c?`/${i}/${c}/${i}`:`/${i}/${i}`,I=e.name===i,L=[];return L.push(`<li><a href="/">${f(r)}</a></li>`),I?L.push(`<li aria-current="page">${f(h)}</li>`):(L.push(g?`<li><a href="${f($)}">${f(h)}</a></li>`:`<li>${f(h)}</li>`),L.push(`<li aria-current="page">${f(l)}</li>`)),`<nav class="kan-breadcrumb"><ol>
|
|
105
|
-
${L.join(`
|
|
106
|
-
`)}
|
|
107
|
-
</ol></nav>`}renderNavGroup(e,t){let n=this.findNavGroupForPublisher(t);if(!n)return"";let s=W(n,ue);if(!(s instanceof x))return"";let a=s.object??[];if(a.length===0)return"";let r=[];for(let o of a){if(!(o instanceof j))continue;let i=S(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}`,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&&A(t).map(i=>i.subject).some(i=>i.publisher===ie.publisher&&i.package_===ie.package_&&i.name===ie.name)){let i=_(t,N),c=W(t,Ke);if(c instanceof K&&c.object instanceof j){let l=c.object,d=this.readLabelForUri({publisher:l.subject.publisher,package_:l.subject.package_,name:l.subject.name});return{href:this.urlForReference(l,Ke,n),label:i??d??l.subject.name}}}let s=D.formatResourceUrl({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},"*",{contextPublisher:n}),a=t?_(t,N)??e.subject.name:e.subject.name;return{href:s,label:a}}findNavGroupForPublisher(e){for(let t of this.catalog){if(!(t instanceof G)||!(t.namespace||"").startsWith(`${e}/`))continue;if(A(t).map(r=>r.subject).some(r=>r.publisher===ee.publisher&&r.package_===ee.package_&&r.name===ee.name))return t}}renderMarkdown(e,t){let n=O(e,V);if(!n)return"<!-- LookRenderer.Markdown: no look.source -->";let s=this.readPropertyValueText(t,n);return s?`<section class="kan-markdown">
|
|
111
|
-
${_e(s)}
|
|
112
|
-
</section>`:""}renderRawMarkdown(e){let t=this.findCascadedLook(e);if(!t)return;let n=Le(t.declaration),s=[];for(let a of n){let r=Oe(a);if(!r||!F(r,ye))continue;let o=O(a,V);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=O(e,en);if(a){let l=this.readPropertyValueText(t,a);l&&s.push(`<span class="kan-hero-eyebrow">${f(l)}</span>`)}let r=O(e,Ze),o="";r&&(o=this.readPropertyValueText(t,r)??""),o||(o=t.name),s.push(`<h1 class="kan-hero-title">${f(o)}</h1>`);let i=O(e,nn);if(i){let l=this.readPropertyValueText(t,i);l&&s.push(`<p class="kan-hero-subtitle">${f(l)}</p>`)}let c=O(e,Se);if(c){let l=this.readPropertyValueReferences(t,c);if(l.length>0){let d=l.map(g=>this.renderBadge(g,Se,n)).join("");s.push(`<div class="kan-hero-badges">${d}</div>`)}}return s.push("</header>"),s.join(`
|
|
115
|
-
`)}renderPropertyList(e,t,n){let s=O(e,V);if(!s)return"<!-- LookRenderer: PropertyList missing look.source -->";let a=this.readLabelForUri(s)??s.name,r=W(t,s),o=this.gatherValueItems(r),i=o.length>0?o.map(c=>`<li>${this.renderInlineValue(c,V,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=O(e,V);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,V,n)).join("")}</div>`}renderChipRow(e,t,n){let s=Ie(e,tn);if(s.length===0)return"<!-- LookRenderer: ChipRow has no look.chips -->";let a=[];for(let r of s){let o=W(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=Ie(e,ue);if(s.length===0)return"<!-- LookRenderer: ReferenceList has no look.entries -->";let a=[];for(let r of s){let o=this.readPropertyValueReferences(t,r);if(o.length===0)continue;let i=this.readLabelForUri(r)??r.name,c=o.map(l=>this.renderReferenceLink(l,ue,n)).join(", ");a.push(`<dt>${f(i)}</dt><dd>${c}</dd>`)}return a.length===0?"":`<dl class="kan-reference-list">${a.join("")}</dl>`}readPropertyValueText(e,t){let n=W(e,t);if(n){if(n instanceof P)return n.object;if(n instanceof K){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 x)return(n.object??[]).map(a=>a instanceof j?this.readLabelForUri({publisher:a.subject.publisher,package_:a.subject.package_,name:a.subject.name})??a.subject.name:a instanceof Q?a.name??"":String(a)).filter(a=>a).join(", ")}}readPropertyValueReferences(e,t){let n=W(e,t);if(!n)return[];if(n instanceof K)return[n.object];if(n instanceof x){let s=[];for(let a of n.object??[])a instanceof j&&s.push(a);return s}return[]}gatherValueItems(e){return e?e instanceof x?e.object??[]:e instanceof K?[e.object]:e instanceof Y?[e.object]:e instanceof P?[e.object]:[]:[]}renderInlineValue(e,t,n){return e instanceof j?this.renderReferenceLink(e,t,n):e instanceof Q?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 P?f(e.object):e instanceof K?this.renderReferenceLink(e.object,t,n):e instanceof x?(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 D.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=S(this.catalog,e);if(!t)return"=";let n=_(t,sn);return n==="*"||n==="^"||n==="~"||n==="="?n:"="}readLabelForUri(e){let t=S(this.catalog,e);if(t)return _(t,N)}readCommentForUri(e){let t=S(this.catalog,e);if(t)return _(t,Re)}};function le(u){let e=new Map;for(let t of u.statement){if(!(t instanceof Y)||!T(t,oe.publisher,oe.package_,oe.name))continue;let n=t.object;for(let s of n.statement){if(!(s instanceof P))continue;let a=s.predicate?.subject?.name;if(!a)continue;let r=s.object;e.has(a)||e.set(a,r)}}return e}function fe(u){for(let e of u.statement)if(e instanceof Y&&T(e,ae.publisher,ae.package_,ae.name))return e.object}function Le(u){for(let e of u.statement){if(!(e instanceof x)||!T(e,ce.publisher,ce.package_,ce.name))continue;let t=[];for(let n of e.object??[])n instanceof Q&&t.push(n);return t}return[]}function Oe(u){for(let e of u.statement)if(e instanceof K&&e.predicate?.subject?.name==="type"&&e.object instanceof j){let t=e.object.subject;return{publisher:t.publisher,package_:t.package_,name:t.name}}}function O(u,e){for(let t of u.statement)if(t instanceof K&&T(t,e.publisher,e.package_,e.name)&&t.object instanceof j){let n=t.object.subject;return{publisher:n.publisher,package_:n.package_,name:n.name}}}function Ie(u,e){for(let t of u.statement){if(!(t instanceof x)||!T(t,e.publisher,e.package_,e.name))continue;let n=[];for(let s of t.object??[])s instanceof j&&n.push({publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name});return n}return[]}function W(u,e){for(let t of u.statement)if(T(t,e.publisher,e.package_,e.name))return t}function _(u,e){for(let t of u.statement)if(t instanceof P&&T(t,e.publisher,e.package_,e.name))return t.object}function A(u){let e=[];for(let t of u.statement)if(t instanceof K){if(t.predicate?.subject?.name!=="type")continue;t.object instanceof j&&e.push(t.object)}else if(t instanceof x){if(t.predicate?.subject?.name!=="type")continue;for(let n of t.object??[])n instanceof j&&e.push(n)}return e}function ne(u){let e=[];for(let t of u.statement)if(t instanceof K){if(t.predicate?.subject?.name!=="subClassOf")continue;t.object instanceof j&&e.push(t.object)}else if(t instanceof x){if(t.predicate?.subject?.name!=="subClassOf")continue;for(let n of t.object??[])n instanceof j&&e.push(n)}return e}function te(u,e){let t=[];for(let n of u){if(!(n instanceof G)||n.name!==e.name)continue;(n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&t.push(n)}return t}function S(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 G&&s.name===e.name&&s.namespace===n)return s}for(let n of u){if(!(n instanceof G)||n.name!==e.name)continue;if((n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))return n}}function T(u,e,t,n){let s=u.predicate?.subject;return s?s.publisher===e&&s.package_===t&&s.name===n:!1}function F(u,e){return u.publisher===e.publisher&&u.package_===e.package_&&u.name===e.name}function q(u){return`${u.publisher}/${u.package_}/${u.name}`}function C(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 Ue(u){let e=u.lastIndexOf(".");return e>=0?u.substring(e+1):u}function we(u,e){for(let t of u.statement)if(t.predicate?.subject?.name===e)return t}function X(u){return u.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function rn(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{_e as a,de as b};
|