@kanonak-protocol/sdk 3.29.10 → 3.30.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.
@@ -0,0 +1,116 @@
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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ve(u){return u.replace(/"/g,"&quot;").replace(/&/g,"&amp;")}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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}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};
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-FEYFLIBJ.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).
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-M5P56WR3.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)}
@@ -184,6 +184,22 @@ export declare class LookRenderer {
184
184
  */
185
185
  private hasSvgDerivation;
186
186
  private renderBand;
187
+ /**
188
+ * Render a Timeline band — enumerate the `look.source` class's instances,
189
+ * sort ascending by the `look.orderBy` date property, and emit a
190
+ * chronological sequence of clickable nodes. Each node links to the
191
+ * instance's exact-version URL and shows its order value + key.
192
+ */
193
+ private renderTimeline;
194
+ /**
195
+ * Render the Timeline trajectory chart — a server-rendered inline SVG with
196
+ * one line per tracked sub-resource (aligned by stable key) across the
197
+ * version sequence, plus an HTML legend reporting each series' latest
198
+ * value and its delta from the prior version. The Y axis is fixed 0..1
199
+ * (the metric is read as a [0,1] confidence by default). Each series is
200
+ * themed by `hueBy` when present, else by an evenly spaced palette.
201
+ */
202
+ private renderTrajectoryChart;
187
203
  /**
188
204
  * Render a ResourceGrid band — enumerates every instance of the class
189
205
  * named by `look.source` and emits a grid of cards. Each card shows
@@ -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-FEYFLIBJ.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(`
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-M5P56WR3.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.29.10",
3
+ "version": "3.30.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.29.10",
116
+ "@kanonak-protocol/types": "^3.30.0",
117
117
  "ignore": "^7.0.5",
118
118
  "js-yaml": "^4.1.0",
119
119
  "yaml": "^2.7.0"
@@ -1,113 +0,0 @@
1
- import{a as V}from"./chunk-NIGFQYVA.js";import{a as N}from"./chunk-4YHWMYAZ.js";import{c as O,d,g as K,h as X,i as Z,j as h,k as P,l as b}from"./chunk-W6T7MOKY.js";function ne(u){let e=u.replace(/\r\n/g,`
2
- `).split(`
3
- `),t=[],n=0;for(;n<e.length;){let r=e[n];if(r.trim()===""){n++;continue}let a=/^(\s*)```(\S*)\s*$/.exec(r);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=te(c.join(`
4
- `)),p=i?` class="language-${re(i)}"`:"";t.push(`<pre><code${p}>${l}</code></pre>`);continue}let s=/^(#{1,6})\s+(.*)$/.exec(r);if(s){let i=s[1].length,c=T(s[2].trim());t.push(`<h${i}>${c}</h${i}>`),n++;continue}if(r.includes("|")&&n+1<e.length&&ee(e[n+1])){let i=G(r),c=ge(e[n+1]);n+=2;let l=[];for(;n<e.length&&e[n].trim()!==""&&e[n].includes("|");)l.push(G(e[n])),n++;t.push(he(i,c,l));continue}if(/^\s*[-*]\s+/.test(r)){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>${T(c.join(" ").trim())}</li>`)}t.push(`<ul>
5
- ${i.join(`
6
- `)}
7
- </ul>`);continue}if(/^\s*\d+\.\s+/.test(r)){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>${T(c.join(" ").trim())}</li>`)}t.push(`<ol>
8
- ${i.join(`
9
- `)}
10
- </ol>`);continue}let o=[r];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&&ee(e[n+1]));)o.push(e[n]),n++;t.push(`<p>${T(o.join(" "))}</p>`)}return t.join(`
11
- `)}function ee(u){return u.includes("-")?/^[\s|:-]+$/.test(u):!1}function G(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 ge(u){return G(u).map(e=>{let t=e.startsWith(":"),n=e.endsWith(":");return t&&n?"center":n?"right":t?"left":null})}function he(u,e,t){let n=s=>{let o=e[s];return o?` style="text-align:${o}"`:""},r=u.map((s,o)=>`<th${n(o)}>${T(s)}</th>`).join(""),a=t.map(s=>`<tr>${s.map((i,c)=>`<td${n(c)}>${T(i)}</td>`).join("")}</tr>`).join(`
12
- `);return`<table>
13
- <thead><tr>${r}</tr></thead>
14
- <tbody>
15
- ${a}
16
- </tbody>
17
- </table>`}function T(u){let e=te(u);return e=e.replace(/`([^`\n]+)`/g,(t,n)=>`<code>${n}</code>`),e=e.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(t,n,r)=>`<a href="${re(r)}">${n}</a>`),e=e.replace(/\*\*([^*\n]+)\*\*/g,(t,n)=>`<strong>${n}</strong>`),e=e.replace(/(^|[^*])\*([^*\n]+)\*(?!\*)/g,(t,n,r)=>`${n}<em>${r}</em>`),e=e.replace(/(^|[\s(])_([^_\n]+)_(?=[\s).,;:!?]|$)/g,(t,n,r)=>`${n}<em>${r}</em>`),e}function te(u){return u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function re(u){return u.replace(/"/g,"&quot;").replace(/&/g,"&amp;")}var H={publisher:"kanonak.org",package_:"derivation",name:"look"},M={publisher:"kanonak.org",package_:"derivation",name:"tokens"},j={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},I={publisher:"kanonak.org",package_:"core-rdf",name:"label"},se={publisher:"kanonak.org",package_:"core-rdf",name:"comment"},ke={publisher:"kanonak.org",package_:"look",name:"Hero"},me={publisher:"kanonak.org",package_:"look",name:"PropertyList"},be={publisher:"kanonak.org",package_:"look",name:"BadgeRow"},je={publisher:"kanonak.org",package_:"look",name:"ChipRow"},_e={publisher:"kanonak.org",package_:"look",name:"ReferenceList"},ae={publisher:"kanonak.org",package_:"look",name:"Markdown"},x={publisher:"kanonak.org",package_:"look",name:"NavGroup"},D={publisher:"kanonak.org",package_:"look",name:"NavLink"},oe={publisher:"kanonak.org",package_:"look",name:"target"},$e={publisher:"kanonak.org",package_:"look",name:"ResourceGrid"};var Re={publisher:"kanonak.org",package_:"look",name:"semanticSvg"},ve={publisher:"kanonak.org",package_:"look",name:"tierChip"},Ke={publisher:"kanonak.org",package_:"look",name:"tierIcon"},Se={publisher:"kanonak.org",package_:"look",name:"tierCard"},ye={publisher:"kanonak.org",package_:"look",name:"tierFull"};var W={publisher:"kanonak.org",package_:"look",name:"bands"},Le={publisher:"kanonak.org",package_:"look",name:"title"},Oe={publisher:"kanonak.org",package_:"look",name:"eyebrow"},Ie={publisher:"kanonak.org",package_:"look",name:"subtitle"},ie={publisher:"kanonak.org",package_:"look",name:"badges"},U={publisher:"kanonak.org",package_:"look",name:"source"},Ue={publisher:"kanonak.org",package_:"look",name:"chips"},q={publisher:"kanonak.org",package_:"look",name:"entries"},we={publisher:"kanonak.org",package_:"look",name:"urlForm"},Q=class{constructor(e){this.catalog=e}catalog;findCascadedLook(e){let t=z(e);if(t)return{declaration:t,sourceClass:{publisher:F(e),package_:(e.namespace||"").split("/")[1]?.split("@")[0]??"",name:e.name}};let n=new Set,r=S(e);for(;r.length>0;){let a=r.shift(),s=E(a.subject);if(n.has(s))continue;n.add(s);let o=m(this.catalog,a.subject);if(!o)continue;let i=z(o);if(i)return{declaration:i,sourceClass:{publisher:a.subject.publisher,package_:a.subject.package_,name:a.subject.name}};for(let c of A(o))r.push(c)}if(!n.has(E(j))){let a=m(this.catalog,j);if(a){let s=z(a);if(s)return{declaration:s,sourceClass:{...j}}}}}findCascadedTokens(e){let t=new Map;for(let[a,s]of Y(e))t.has(a)||t.set(a,s);let n=new Set,r=S(e);for(;r.length>0;){let a=r.shift(),s=E(a.subject);if(n.has(s))continue;n.add(s);let o=B(this.catalog,a.subject);if(o.length!==0)for(let i of o){for(let[c,l]of Y(i))t.has(c)||t.set(c,l);for(let c of A(i))r.push(c)}}if(!n.has(E(j))){let a=B(this.catalog,j);for(let s of a)for(let[o,i]of Y(s))t.has(o)||t.set(o,i)}return t}renderSvg(e){let t=k(e,I)??e.name,n=(t.trim().charAt(0)||"?").toUpperCase(),r=`${e.namespace??""}/${e.name}`,a={label:t,firstLetter:n,uri:r},s=this.collectCascadedSvgTiers(e),o=v=>this.applyPlaceholders(v,e,a),i=o(s.tierChip??""),c=o(s.tierIcon??""),l=o(s.tierCard??""),p=o(s.tierFull??""),y=[...this.findCascadedTokens(e)].map(([v,C])=>`--kan-${v}: ${C};`).join(" ");return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400" width="400" height="400" style="${J(y)}">
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">${p}</g>
29
- </svg>`}applyPlaceholders(e,t,n){return e.replace(/\{\{([^}]+)\}\}/g,(r,a)=>{let s=a.trim();if(n[s]!==void 0)return J(n[s]);let o=this.resolvePath(t,s);return o===void 0?`{{${s}}}`:J(o)})}resolvePath(e,t){let n=t.split("/").map(o=>o.trim()).filter(o=>o.length>0);if(n.length===0)return;let r=e;for(let o=0;o<n.length-1;o++){if(!r)return;let i=fe(n[o]),c=pe(r,i);if(!c)return;if(c instanceof h&&c.object instanceof d){let l=m(this.catalog,c.object.subject);if(!l)return;r=l}else if(c instanceof P)r=c.object;else return}if(!r)return;let a=fe(n[n.length-1]),s=pe(r,a);if(s){if(s instanceof K||s instanceof X||s instanceof Z)return String(s.object);if(s instanceof h&&s.object instanceof d){let o=s.object,i=m(this.catalog,o.subject);return i?k(i,I)??o.subject.name:o.subject.name}}}collectCascadedSvgTiers(e){let t={},n=s=>{let o=w(s,Re);if(!(o instanceof P))return;let i=o.object,c=k(i,ve),l=k(i,Ke),p=k(i,Se),g=k(i,ye);t.tierChip===void 0&&c!==void 0&&(t.tierChip=c),t.tierIcon===void 0&&l!==void 0&&(t.tierIcon=l),t.tierCard===void 0&&p!==void 0&&(t.tierCard=p),t.tierFull===void 0&&g!==void 0&&(t.tierFull=g)};n(e);let r=new Set,a=S(e);for(;a.length>0;){let s=a.shift(),o=E(s.subject);if(r.has(o))continue;r.add(o);let i=B(this.catalog,s.subject);for(let c of i){n(c);for(let l of A(c))a.push(l)}}if(!r.has(E(j)))for(let s of B(this.catalog,j))n(s);return t}renderStylesheet(e){let t=this.findCascadedTokens(e),n=[];for(let[s,o]of t)n.push(` --kan-${s}: ${o};`);let r=n.length>0?`:root {
30
- ${n.join(`
31
- `)}
32
- }`:":root { /* no tokens resolved */ }",a=this.findBaseStylesheet(F(e))??"";return`${r}
33
- ${a}`}findBaseStylesheet(e){let t="kanonak.org/site/content",n,r;for(let s of this.catalog){if(!(s instanceof O)||s.name!=="base-stylesheet")continue;let o=s.namespace||"";o.startsWith(`${e}/look-styles@`)?n=s:o.startsWith("kanonak.org/look-styles@")&&(r=s)}let a=n??r;if(a)for(let s of a.statement){let o=s.predicate?.subject;if(!o)continue;if(`${o.publisher}/${o.package_}/${o.name}`===t&&s instanceof K)return s.object}}renderHtml(e){let t=this.findCascadedLook(e);if(!t)return`<!-- LookRenderer: no derivation.look found for ${e.namespace}/${e.name} -->`;let n=ce(t.declaration);if(n.length===0)return"<!-- LookRenderer: look declaration has no bands -->";let r=F(e),a=[];for(let s of n)a.push(this.renderBand(s,e,r));return a.join(`
34
- `)}renderPublisherIndex(e,t,n){let r=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
- `),s=`<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
- ${r}
50
- <main class="kan-main">
51
- ${s}
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===j.publisher&&t.sourceClass.package_===j.package_&&t.sourceClass.name===j.name):!1}renderPackageVersionList(e,t,n){let r=F(n),a=this.renderNavGroup(n,r),s=this.renderBreadcrumb(n,r,{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
- ${s}
73
- <main class="kan-main">
74
- ${i}
75
- </main>
76
- </body>
77
- </html>
78
- `}renderDocument(e,t){let n=this.renderHtml(e),r=this.readPropertyValueText(e,I)??e.name,a=`${e.name}.css`,s=this.hasSvgDerivation(e)?`<figure class="kan-figure"><img src="${f(e.name)}.svg" alt=""></figure>
79
- `:"",o=F(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(r)}</title>
85
- <link rel="stylesheet" href="${f(a)}">
86
- </head>
87
- <body>
88
- ${i}
89
- ${c}
90
- <main class="kan-main">
91
- ${s}${n}
92
- </main>
93
- </body>
94
- </html>
95
- `}hasSvgDerivation(e){let t=new Set,n=S(e);for(;n.length>0;){let r=n.shift(),a=E(r.subject);if(t.has(a))continue;t.add(a);let s=m(this.catalog,r.subject);if(s){for(let o of s.statement)if(o instanceof b&&R(o,"kanonak.org","derivation","derivations")){for(let i of o.object??[])if(i instanceof N)for(let c of i.statement){if(!(c instanceof h)||!R(c,"kanonak.org","derivation","format")||!(c.object instanceof d))continue;let l=c.object.subject;if(l.publisher==="kanonak.org"&&l.package_==="formats"&&l.name==="svg")return!0}}for(let o of A(s))n.push(o)}}return!1}renderBand(e,t,n){let r=ue(e);return r?$(r,ke)?this.renderHero(e,t,n):$(r,me)?this.renderPropertyList(e,t,n):$(r,be)?this.renderBadgeRow(e,t,n):$(r,je)?this.renderChipRow(e,t,n):$(r,_e)?this.renderReferenceList(e,t,n):$(r,ae)?this.renderMarkdown(e,t):$(r,x)?this.renderNavGroup(t,n):$(r,$e)?this.renderResourceGrid(e,n,t):`<!-- LookRenderer: unsupported band ${r.publisher}/${r.package_}/${r.name} -->`:"<!-- LookRenderer: band has no rdf:type -->"}renderResourceGrid(e,t,n){let r=_(e,U);if(!r)return"<!-- LookRenderer.ResourceGrid: no look.source -->";let a=m(this.catalog,r),s=a?S(a).some(c=>{let l=c.subject.name;return l==="ObjectProperty"||l==="DatatypeProperty"||l==="Property"}):!1,o=[];if(s&&n){let c=this.readPropertyValueReferences(n,r);for(let l of c){let p=m(this.catalog,{publisher:l.subject.publisher,package_:l.subject.package_,name:l.subject.name,...l.subject.version?{version:l.subject.version}:{}});p&&o.push(p)}}else o=this.findInstancesOfClass(r);if(o.length===0)return`<!-- LookRenderer.ResourceGrid: no resources for ${r.publisher}/${r.package_}/${r.name} -->`;let i=[];for(let c of o){let l=k(c,I)??c.name,p=k(c,se),g=c.namespace||"",y=g.split("/")[1]?.split("@")[0]??"",v=g.split("@")[1]??"",C=v?this.parseVersion(v):void 0,L=V.formatResourceUrl({publisher:F(c),package_:y,name:c.name,...C?{version:C}:{}},"=",{contextPublisher:t}),de=p?`<p class="kan-resource-card-subtitle">${f(p)}</p>`:"";i.push(`<a class="kan-resource-card" href="${f(L)}"><h3 class="kan-resource-card-title">${f(l)}</h3>${de}</a>`)}return`<section class="kan-resource-grid">
96
- ${i.join(`
97
- `)}
98
- </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 O))continue;S(n).map(s=>s.subject).some(s=>s.publisher===e.publisher&&s.package_===e.package_&&s.name===e.name)&&t.push(n)}return t}renderBreadcrumb(e,t,n){let a=(e.namespace||"").split("/");if(a.length<2)return"";let s=a[0],o=a[1]??"",i=o.split("@")[0]??"",c=o.split("@")[1]??"";if(!s||!i)return"";if(n?.bareOverview)return`<nav class="kan-breadcrumb"><ol>
99
- <li><a href="/">${f(s)}</a></li>
100
- <li aria-current="page">${f(i)}</li>
101
- </ol></nav>`;let l=e.name,g=!!m(this.catalog,{publisher:s,package_:i,name:i}),y=c?`${i}@${c}`:i,v=c?`/${i}/${c}/${i}`:`/${i}/${i}`,C=e.name===i,L=[];return L.push(`<li><a href="/">${f(s)}</a></li>`),C?L.push(`<li aria-current="page">${f(y)}</li>`):(L.push(g?`<li><a href="${f(v)}">${f(y)}</a></li>`:`<li>${f(y)}</li>`),L.push(`<li aria-current="page">${f(l)}</li>`)),`<nav class="kan-breadcrumb"><ol>
102
- ${L.join(`
103
- `)}
104
- </ol></nav>`}renderNavGroup(e,t){let n=this.findNavGroupForPublisher(t);if(!n)return"";let r=w(n,q);if(!(r instanceof b))return"";let a=r.object??[];if(a.length===0)return"";let s=[];for(let o of a){if(!(o instanceof d))continue;let i=m(this.catalog,{publisher:o.subject.publisher,package_:o.subject.package_,name:o.subject.name}),{href:c,label:l}=this.resolveNavEntry(o,i,t),p=`/${e.namespace?.split("/")[1]?.split("@")[0]}/${(e.namespace||"").split("@")[1]}/${e.name}`,g=c===p?' aria-current="page"':"";s.push(`<li><a class="kan-nav-link" href="${f(c)}"${g}>${f(l)}</a></li>`)}return`<nav class="kan-site-nav"><ul>
105
- ${s.join(`
106
- `)}
107
- </ul></nav>`}resolveNavEntry(e,t,n){if(t&&S(t).map(i=>i.subject).some(i=>i.publisher===D.publisher&&i.package_===D.package_&&i.name===D.name)){let i=k(t,I),c=w(t,oe);if(c instanceof h&&c.object instanceof d){let l=c.object,p=this.readLabelForUri({publisher:l.subject.publisher,package_:l.subject.package_,name:l.subject.name});return{href:this.urlForReference(l,oe,n),label:i??p??l.subject.name}}}let r=V.formatResourceUrl({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},"*",{contextPublisher:n}),a=t?k(t,I)??e.subject.name:e.subject.name;return{href:r,label:a}}findNavGroupForPublisher(e){for(let t of this.catalog){if(!(t instanceof O)||!(t.namespace||"").startsWith(`${e}/`))continue;if(S(t).map(s=>s.subject).some(s=>s.publisher===x.publisher&&s.package_===x.package_&&s.name===x.name))return t}}renderMarkdown(e,t){let n=_(e,U);if(!n)return"<!-- LookRenderer.Markdown: no look.source -->";let r=this.readPropertyValueText(t,n);return r?`<section class="kan-markdown">
108
- ${ne(r)}
109
- </section>`:""}renderRawMarkdown(e){let t=this.findCascadedLook(e);if(!t)return;let n=ce(t.declaration),r=[];for(let a of n){let s=ue(a);if(!s||!$(s,ae))continue;let o=_(a,U);if(!o)continue;let i=this.readPropertyValueText(e,o);i&&r.push(i)}return r.length>0?r.join(`
110
-
111
- `):void 0}renderHero(e,t,n){let r=['<header class="kan-hero">'],a=_(e,Oe);if(a){let l=this.readPropertyValueText(t,a);l&&r.push(`<span class="kan-hero-eyebrow">${f(l)}</span>`)}let s=_(e,Le),o="";s&&(o=this.readPropertyValueText(t,s)??""),o||(o=t.name),r.push(`<h1 class="kan-hero-title">${f(o)}</h1>`);let i=_(e,Ie);if(i){let l=this.readPropertyValueText(t,i);l&&r.push(`<p class="kan-hero-subtitle">${f(l)}</p>`)}let c=_(e,ie);if(c){let l=this.readPropertyValueReferences(t,c);if(l.length>0){let p=l.map(g=>this.renderBadge(g,ie,n)).join("");r.push(`<div class="kan-hero-badges">${p}</div>`)}}return r.push("</header>"),r.join(`
112
- `)}renderPropertyList(e,t,n){let r=_(e,U);if(!r)return"<!-- LookRenderer: PropertyList missing look.source -->";let a=this.readLabelForUri(r)??r.name,s=w(t,r),o=this.gatherValueItems(s),i=o.length>0?o.map(c=>`<li>${this.renderInlineValue(c,U,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(`
113
- `)}renderBadgeRow(e,t,n){let r=_(e,U);if(!r)return"<!-- LookRenderer: BadgeRow missing look.source -->";let a=this.readPropertyValueReferences(t,r);return a.length===0?"":`<div class="kan-badge-row">${a.map(o=>this.renderBadge(o,U,n)).join("")}</div>`}renderChipRow(e,t,n){let r=le(e,Ue);if(r.length===0)return"<!-- LookRenderer: ChipRow has no look.chips -->";let a=[];for(let s of r){let o=w(t,s);if(!o)continue;let i=this.readLabelForUri(s)??s.name,c=this.renderStatementInlineValue(o,s,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 r=le(e,q);if(r.length===0)return"<!-- LookRenderer: ReferenceList has no look.entries -->";let a=[];for(let s of r){let o=this.readPropertyValueReferences(t,s);if(o.length===0)continue;let i=this.readLabelForUri(s)??s.name,c=o.map(l=>this.renderReferenceLink(l,q,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 K)return n.object;if(n instanceof h){let r=n.object;return this.readLabelForUri({publisher:r.subject.publisher,package_:r.subject.package_,name:r.subject.name})??r.subject.name}if(n instanceof b)return(n.object??[]).map(a=>a instanceof d?this.readLabelForUri({publisher:a.subject.publisher,package_:a.subject.package_,name:a.subject.name})??a.subject.name:a instanceof N?a.name??"":String(a)).filter(a=>a).join(", ")}}readPropertyValueReferences(e,t){let n=w(e,t);if(!n)return[];if(n instanceof h)return[n.object];if(n instanceof b){let r=[];for(let a of n.object??[])a instanceof d&&r.push(a);return r}return[]}gatherValueItems(e){return e?e instanceof b?e.object??[]:e instanceof h?[e.object]:e instanceof P?[e.object]:e instanceof K?[e.object]:[]:[]}renderInlineValue(e,t,n){return e instanceof d?this.renderReferenceLink(e,t,n):e instanceof N?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 K?f(e.object):e instanceof h?this.renderReferenceLink(e.object,t,n):e instanceof b?(e.object??[]).map(a=>this.renderInlineValue(a,t,n)).filter(a=>a).join(", "):""}renderReferenceLink(e,t,n){let r=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(r)}</a>`}renderBadge(e,t,n){let r=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}),s=this.urlForReference(e,t,n),o=a?` title="${f(a)}"`:"";return`<a class="kan-badge" href="${f(s)}"${o}>${f(r)}</a>`}urlForReference(e,t,n){let r=t?this.getUrlFormForProperty(t):"=";return V.formatResourceUrl({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},r,{contextPublisher:n})}getUrlFormForProperty(e){let t=m(this.catalog,e);if(!t)return"=";let n=k(t,we);return n==="*"||n==="^"||n==="~"||n==="="?n:"="}readLabelForUri(e){let t=m(this.catalog,e);if(t)return k(t,I)}readCommentForUri(e){let t=m(this.catalog,e);if(t)return k(t,se)}};function Y(u){let e=new Map;for(let t of u.statement){if(!(t instanceof P)||!R(t,M.publisher,M.package_,M.name))continue;let n=t.object;for(let r of n.statement){if(!(r instanceof K))continue;let a=r.predicate?.subject?.name;if(!a)continue;let s=r.object;e.has(a)||e.set(a,s)}}return e}function z(u){for(let e of u.statement)if(e instanceof P&&R(e,H.publisher,H.package_,H.name))return e.object}function ce(u){for(let e of u.statement){if(!(e instanceof b)||!R(e,W.publisher,W.package_,W.name))continue;let t=[];for(let n of e.object??[])n instanceof N&&t.push(n);return t}return[]}function ue(u){for(let e of u.statement)if(e instanceof h&&e.predicate?.subject?.name==="type"&&e.object instanceof d){let t=e.object.subject;return{publisher:t.publisher,package_:t.package_,name:t.name}}}function _(u,e){for(let t of u.statement)if(t instanceof h&&R(t,e.publisher,e.package_,e.name)&&t.object instanceof d){let n=t.object.subject;return{publisher:n.publisher,package_:n.package_,name:n.name}}}function le(u,e){for(let t of u.statement){if(!(t instanceof b)||!R(t,e.publisher,e.package_,e.name))continue;let n=[];for(let r of t.object??[])r instanceof d&&n.push({publisher:r.subject.publisher,package_:r.subject.package_,name:r.subject.name});return n}return[]}function w(u,e){for(let t of u.statement)if(R(t,e.publisher,e.package_,e.name))return t}function k(u,e){for(let t of u.statement)if(t instanceof K&&R(t,e.publisher,e.package_,e.name))return t.object}function S(u){let e=[];for(let t of u.statement)if(t instanceof h){if(t.predicate?.subject?.name!=="type")continue;t.object instanceof d&&e.push(t.object)}else if(t instanceof b){if(t.predicate?.subject?.name!=="type")continue;for(let n of t.object??[])n instanceof d&&e.push(n)}return e}function A(u){let e=[];for(let t of u.statement)if(t instanceof h){if(t.predicate?.subject?.name!=="subClassOf")continue;t.object instanceof d&&e.push(t.object)}else if(t instanceof b){if(t.predicate?.subject?.name!=="subClassOf")continue;for(let n of t.object??[])n instanceof d&&e.push(n)}return e}function B(u,e){let t=[];for(let n of u){if(!(n instanceof O)||n.name!==e.name)continue;(n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&t.push(n)}return t}function m(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 r of u)if(r instanceof O&&r.name===e.name&&r.namespace===n)return r}for(let n of u){if(!(n instanceof O)||n.name!==e.name)continue;if((n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))return n}}function R(u,e,t,n){let r=u.predicate?.subject;return r?r.publisher===e&&r.package_===t&&r.name===n:!1}function $(u,e){return u.publisher===e.publisher&&u.package_===e.package_&&u.name===e.name}function E(u){return`${u.publisher}/${u.package_}/${u.name}`}function F(u){let e=u.namespace||"",t=e.indexOf("/");return t>=0?e.substring(0,t):e}function f(u){return u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function fe(u){let e=u.lastIndexOf(".");return e>=0?u.substring(e+1):u}function pe(u,e){for(let t of u.statement)if(t.predicate?.subject?.name===e)return t}function J(u){return u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}export{ne as a,Q as b};