@kanonak-protocol/sdk 3.40.0 → 3.42.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.
@@ -1,116 +0,0 @@
1
- import{a as ce}from"./chunk-NIGFQYVA.js";import{a as se,c as Pe}from"./chunk-SQDXESNM.js";import{c as J,d as E,g as X,h as me,i as Ke,j as A,k as ie,l as D}from"./chunk-W6T7MOKY.js";function Ce(d){let e=d.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=Ae(c.join(`
4
- `)),p=i?` class="language-${Ne(i)}"`:"";t.push(`<pre><code${p}>${l}</code></pre>`);continue}let a=/^(#{1,6})\s+(.*)$/.exec(s);if(a){let i=a[1].length,c=de(a[2].trim());t.push(`<h${i}>${c}</h${i}>`),n++;continue}if(s.includes("|")&&n+1<e.length&&Te(e[n+1])){let i=ye(s),c=nn(e[n+1]);n+=2;let l=[];for(;n<e.length&&e[n].trim()!==""&&e[n].includes("|");)l.push(ye(e[n])),n++;t.push(tn(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>${de(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>${de(c.join(" ").trim())}</li>`)}t.push(`<ol>
8
- ${i.join(`
9
- `)}
10
- </ol>`);continue}let r=[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&&Te(e[n+1]));)r.push(e[n]),n++;t.push(`<p>${de(r.join(" "))}</p>`)}return t.join(`
11
- `)}function Te(d){return d.includes("-")?/^[\s|:-]+$/.test(d):!1}function ye(d){let e=d.trim();return e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&(e=e.slice(0,-1)),e.split("|").map(t=>t.trim())}function nn(d){return ye(d).map(e=>{let t=e.startsWith(":"),n=e.endsWith(":");return t&&n?"center":n?"right":t?"left":null})}function tn(d,e,t){let n=a=>{let r=e[a];return r?` style="text-align:${r}"`:""},s=d.map((a,r)=>`<th${n(r)}>${de(a)}</th>`).join(""),o=t.map(a=>`<tr>${a.map((i,c)=>`<td${n(c)}>${de(i)}</td>`).join("")}</tr>`).join(`
12
- `);return`<table>
13
- <thead><tr>${s}</tr></thead>
14
- <tbody>
15
- ${o}
16
- </tbody>
17
- </table>`}function de(d){let e=Ae(d);return e=e.replace(/`([^`\n]+)`/g,(t,n)=>`<code>${n}</code>`),e=e.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(t,n,s)=>`<a href="${Ne(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 Ae(d){return d.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ne(d){return d.replace(/"/g,"&quot;").replace(/&/g,"&amp;")}var xe={publisher:"kanonak.org",package_:"derivation",name:"look"},Le={publisher:"kanonak.org",package_:"derivation",name:"tokens"},Z={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},N={publisher:"kanonak.org",package_:"core-rdf",name:"label"},be={publisher:"kanonak.org",package_:"core-rdf",name:"comment"},sn={publisher:"kanonak.org",package_:"look",name:"Hero"},an={publisher:"kanonak.org",package_:"look",name:"PropertyList"},rn={publisher:"kanonak.org",package_:"look",name:"BadgeRow"},on={publisher:"kanonak.org",package_:"look",name:"ChipRow"},cn={publisher:"kanonak.org",package_:"look",name:"ReferenceList"},Ve={publisher:"kanonak.org",package_:"look",name:"Markdown"},$e={publisher:"kanonak.org",package_:"look",name:"NavGroup"},Oe={publisher:"kanonak.org",package_:"look",name:"NavLink"},Me={publisher:"kanonak.org",package_:"look",name:"target"},ln={publisher:"kanonak.org",package_:"look",name:"ResourceGrid"},un={publisher:"kanonak.org",package_:"look",name:"Timeline"},dn={publisher:"kanonak.org",package_:"look",name:"VersionDiff"},pn={publisher:"kanonak.org",package_:"look",name:"Figure"},fn={publisher:"kanonak.org",package_:"look",name:"StatRow"},kn={publisher:"kanonak.org",package_:"look",name:"Horizon"},gn={publisher:"kanonak.org",package_:"look",name:"PackageContents"},Se={publisher:"kanonak.org",package_:"core-kanonak",name:"Package"},hn={publisher:"kanonak.org",package_:"look",name:"FeaturedResource"},mn={publisher:"kanonak.org",package_:"look",name:"PublisherPackages"},bn={publisher:"kanonak.org",package_:"look",name:"PublisherView"},$n={publisher:"kanonak.org",package_:"look",name:"Distribution"},jn={publisher:"kanonak.org",package_:"look",name:"alphaPath"},_n={publisher:"kanonak.org",package_:"look",name:"betaPath"},vn={publisher:"kanonak.org",package_:"look",name:"SectionHeading"},Rn={publisher:"kanonak.org",package_:"look",name:"heading"},Sn={publisher:"kanonak.org",package_:"look",name:"note"},Kn={publisher:"kanonak.org",package_:"look",name:"VersionDelta"},yn={publisher:"kanonak.org",package_:"look",name:"stats"},xn={publisher:"kanonak.org",package_:"look",name:"statPath"},Ln={publisher:"kanonak.org",package_:"look",name:"statLabel"},On={publisher:"kanonak.org",package_:"look",name:"labelPath"},wn={publisher:"kanonak.org",package_:"look",name:"badgePath"},He={publisher:"kanonak.org",package_:"look",name:"orderBy"},Be={publisher:"kanonak.org",package_:"look",name:"track"},je={publisher:"kanonak.org",package_:"look",name:"metricPath"},we={publisher:"kanonak.org",package_:"look",name:"hueBy"},De={publisher:"kanonak.org",package_:"look",name:"lowerPath"},Ge={publisher:"kanonak.org",package_:"look",name:"upperPath"},Fn={publisher:"kanonak.org",package_:"look",name:"axisMin"},Un={publisher:"kanonak.org",package_:"look",name:"axisMax"},In={publisher:"kanonak.org",package_:"look",name:"valueLabel"};var En={publisher:"kanonak.org",package_:"look",name:"semanticSvg"},Pn={publisher:"kanonak.org",package_:"look",name:"tierChip"},Tn={publisher:"kanonak.org",package_:"look",name:"tierIcon"},Cn={publisher:"kanonak.org",package_:"look",name:"tierCard"},An={publisher:"kanonak.org",package_:"look",name:"tierFull"};var Fe={publisher:"kanonak.org",package_:"look",name:"bands"},Nn={publisher:"kanonak.org",package_:"look",name:"title"},Vn={publisher:"kanonak.org",package_:"look",name:"eyebrow"},Mn={publisher:"kanonak.org",package_:"look",name:"subtitle"},We={publisher:"kanonak.org",package_:"look",name:"badges"},G={publisher:"kanonak.org",package_:"look",name:"source"},Hn={publisher:"kanonak.org",package_:"look",name:"chips"},Ue={publisher:"kanonak.org",package_:"look",name:"entries"},Bn={publisher:"kanonak.org",package_:"look",name:"urlForm"},Ee=class{constructor(e){this.catalog=e}catalog;findCascadedLook(e){let t=_e(e);if(t)return{declaration:t,sourceClass:{publisher:W(e),package_:(e.namespace||"").split("/")[1]?.split("@")[0]??"",name:e.name}};let n=new Set,s=ae(e);for(;s.length>0;){let o=s.shift(),a=Dn(o.subject),r=le(a);if(n.has(r))continue;n.add(r);let i=re(this.catalog,a);for(let c of i){let l=_e(c);if(l)return{declaration:l,sourceClass:{publisher:a.publisher,package_:a.package_,name:a.name}}}for(let c of i)for(let l of Re(c))s.push(l)}if(!n.has(le(Z)))for(let o of re(this.catalog,Z)){let a=_e(o);if(a)return{declaration:a,sourceClass:{...Z}}}}findCascadedTokens(e){let t=new Map;for(let[o,a]of Ie(e))t.has(o)||t.set(o,a);let n=new Set,s=ae(e);for(;s.length>0;){let o=s.shift(),a=le(o.subject);if(n.has(a))continue;n.add(a);let r=re(this.catalog,o.subject);if(r.length!==0)for(let i of r){for(let[c,l]of Ie(i))t.has(c)||t.set(c,l);for(let c of Re(i))s.push(c)}}if(!n.has(le(Z))){let o=re(this.catalog,Z);for(let a of o)for(let[r,i]of Ie(a))t.has(r)||t.set(r,i)}return t}renderSvg(e){let t=$(e,N)??e.name,n=(t.trim().charAt(0)||"?").toUpperCase(),s=`${e.namespace??""}/${e.name}`,o={label:t,firstLetter:n,uri:s},a=this.collectCascadedSvgTiers(e),r=h=>this.applyPlaceholders(h,e,o),i=r(a.tierChip??""),c=r(a.tierIcon??""),l=r(a.tierCard??""),p=r(a.tierFull??""),g=[...this.findCascadedTokens(e)].map(([h,k])=>`--kan-${h}: ${k};`).join(" ");return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400" width="400" height="400" style="${fe(g)}">
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,(s,o)=>{let a=o.trim();if(n[a]!==void 0)return fe(n[a]);let r=this.resolvePath(t,a);return r===void 0?`{{${a}}}`:fe(r)})}resolvePath(e,t){let n=t.split("/").map(r=>r.trim()).filter(r=>r.length>0);if(n.length===0)return;let s=e;for(let r=0;r<n.length-1;r++){if(!s)return;let i=Je(n[r]),c=Xe(s,i);if(!c)return;if(c instanceof A&&c.object instanceof E){let l=V(this.catalog,c.object.subject);if(!l)return;s=l}else if(c instanceof ie)s=c.object;else return}if(!s)return;let o=Je(n[n.length-1]),a=Xe(s,o);if(a){if(a instanceof X||a instanceof me||a instanceof Ke)return String(a.object);if(a instanceof A&&a.object instanceof E){let r=a.object,i=V(this.catalog,r.subject);return i?$(i,N)??r.subject.name:r.subject.name}}}collectCascadedSvgTiers(e){let t={},n=a=>{let r=Q(a,En);if(!(r instanceof ie))return;let i=r.object,c=$(i,Pn),l=$(i,Tn),p=$(i,Cn),f=$(i,An);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&&f!==void 0&&(t.tierFull=f)};n(e);let s=new Set,o=ae(e);for(;o.length>0;){let a=o.shift(),r=le(a.subject);if(s.has(r))continue;s.add(r);let i=re(this.catalog,a.subject);for(let c of i){n(c);for(let l of Re(c))o.push(l)}}if(!s.has(le(Z)))for(let a of re(this.catalog,Z))n(a);return t}renderStylesheet(e){let t=this.findCascadedTokens(e),n=[];for(let[a,r]of t)n.push(` --kan-${a}: ${r};`);let s=n.length>0?`:root {
30
- ${n.join(`
31
- `)}
32
- }`:":root { /* no tokens resolved */ }",o=this.findBaseStylesheet(W(e))??"";return`${s}
33
- ${o}`}findBaseStylesheet(e){let t="kanonak.org/site/content",n,s;for(let a of this.catalog){if(!(a instanceof J)||a.name!=="base-stylesheet")continue;let r=a.namespace||"";r.startsWith(`${e}/look-styles@`)?n=a:r.startsWith("kanonak.org/look-styles@")&&(s=a)}let o=n??s;if(o)for(let a of o.statement){let r=a.predicate?.subject;if(!r)continue;if(`${r.publisher}/${r.package_}/${r.name}`===t&&a instanceof X)return a.object}}renderHtml(e){let t=this.findCascadedLook(e);if(!t)return`<!-- LookRenderer: no derivation.look found for ${e.namespace}/${e.name} -->`;let n=ze(t.declaration);if(n.length===0)return"<!-- LookRenderer: look declaration has no bands -->";let s=W(e),o=[];for(let a of n)o.push(this.renderBand(a,e,s));return o.join(`
34
- `)}renderPublisherIndex(e,t,n){let s=n?this.renderNavGroup(n,e):"",o=t.map(r=>{let i=r.comment?`<p class="kan-resource-card-subtitle">${u(r.comment)}</p>`:"";return`<a class="kan-resource-card" href="${u(r.href)}"><h3 class="kan-resource-card-title">${u(r.label)}</h3>${i}</a>`}).join(`
35
- `),a=`<header class="kan-hero">
36
- <h1 class="kan-hero-title">${u(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>${u(e)}</title>
46
- <link rel="stylesheet" href="index.css">
47
- </head>
48
- <body>
49
- ${s}
50
- <main class="kan-main">
51
- ${a}
52
- </main>
53
- </body>
54
- </html>
55
- `}renderPublisherIndexStylesheet(e){return e?this.renderStylesheet(e):""}hasDeclaredView(e){let t=this.findCascadedLook(e);return t?!(s=>s.publisher===Z.publisher&&s.package_===Z.package_&&s.name===Z.name||s.publisher===Se.publisher&&s.package_===Se.package_&&s.name===Se.name)(t.sourceClass):!1}renderPackageVersionList(e,t,n){let s=W(n),o=this.renderNavGroup(n,s),a=this.renderBreadcrumb(n,s,{bareOverview:!0}),r=t.map(c=>`<a class="kan-resource-card" href="/${u(e)}/${u(c)}/"><h3 class="kan-resource-card-title">${u(c)}</h3></a>`).join(`
56
- `),i=`<header class="kan-hero">
57
- <span class="kan-hero-eyebrow">PACKAGE</span>
58
- <h1 class="kan-hero-title">${u(e)}</h1>
59
- </header>
60
- <section class="kan-resource-grid">
61
- ${r}
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>${u(e)}</title>
68
- <link rel="stylesheet" href="${u(n.name)}.css">
69
- </head>
70
- <body>
71
- ${o}
72
- ${a}
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,o=t?.rootIndex?"index.css":`${e.name}.css`,a=!t?.rootIndex&&this.hasSvgDerivation(e)?`<figure class="kan-figure"><img src="${u(e.name)}.svg" alt=""></figure>
79
- `:"",r=W(e),i=this.renderNavGroup(e,r),c=t?.rootIndex?"":this.renderBreadcrumb(e,r,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>${u(s)}</title>
85
- <link rel="stylesheet" href="${u(o)}">
86
- </head>
87
- <body>
88
- ${i}
89
- ${c}
90
- <main class="kan-main">
91
- ${a}${n}
92
- </main>
93
- </body>
94
- </html>
95
- `}hasSvgDerivation(e){let t=new Set,n=ae(e);for(;n.length>0;){let s=n.shift(),o=le(s.subject);if(t.has(o))continue;t.add(o);let a=V(this.catalog,s.subject);if(a){for(let r of a.statement)if(r instanceof D&&ee(r,"kanonak.org","derivation","derivations")){for(let i of r.object??[])if(i instanceof se)for(let c of i.statement){if(!(c instanceof A)||!ee(c,"kanonak.org","derivation","format")||!(c.object instanceof E))continue;let l=c.object.subject;if(l.publisher==="kanonak.org"&&l.package_==="formats"&&l.name==="svg")return!0}}for(let r of Re(a))n.push(r)}}return!1}renderBand(e,t,n){let s=ve(e);return s?L(s,sn)?this.renderHero(e,t,n):L(s,an)?this.renderPropertyList(e,t,n):L(s,rn)?this.renderBadgeRow(e,t,n):L(s,on)?this.renderChipRow(e,t,n):L(s,cn)?this.renderReferenceList(e,t,n):L(s,Ve)?this.renderMarkdown(e,t,n):L(s,$e)?this.renderNavGroup(t,n):L(s,ln)?this.renderResourceGrid(e,n,t):L(s,un)?this.renderTimeline(e,n):L(s,dn)?this.renderVersionDiff(e,n):L(s,pn)?this.renderFigure(e,t,n):L(s,fn)?this.renderStatRow(e,t):L(s,kn)?this.renderHorizon(e,t,n):L(s,gn)?this.renderPackageContents(t,n):L(s,hn)?this.renderFeaturedResource(e,n):L(s,mn)?this.renderPublisherPackages(n):L(s,$n)?this.renderDistribution(e,t):L(s,vn)?this.renderSectionHeading(e):L(s,Kn)?this.renderVersionDelta(e,t):`<!-- LookRenderer: unsupported band ${s.publisher}/${s.package_}/${s.name} -->`:"<!-- LookRenderer: band has no rdf:type -->"}collectTrackedSeries(e,t,n,s){let{hueBy:o,lowerPath:a,upperPath:r}=s??{},i=new Map,c=e.length,l=(p,f)=>{let g=this.resolvePath(p,f);return g===void 0?NaN:parseFloat(g)};return e.forEach((p,f)=>{let g=this.readPropertyValueReferences(p,t);for(let h of g){let k=V(this.catalog,{publisher:h.subject.publisher,package_:h.subject.package_,name:h.subject.name,...h.subject.version?{version:h.subject.version}:{}});if(!k)continue;let m=h.subject.name,j=i.get(m);j||(j={key:m,label:$(k,N)??m,points:new Array(c).fill(null),...a?{lower:new Array(c).fill(null)}:{},...r?{upper:new Array(c).fill(null)}:{}},i.set(m,j));let v=l(k,n);if(Number.isFinite(v)&&(j.points[f]=v),a&&j.lower){let _=l(k,a);Number.isFinite(_)&&(j.lower[f]=_)}if(r&&j.upper){let _=l(k,r);Number.isFinite(_)&&(j.upper[f]=_)}if(o){let _=l(k,o);Number.isFinite(_)&&(j.hue=_)}j.lastSubject=k}}),[...i.values()]}hrefForSubject(e,t,n="="){let s=e.namespace||"",o=s.split("/")[1]?.split("@")[0]??"",a=s.split("@")[1]??"",r=a?this.parseVersion(a):void 0;return ce.formatResourceUrl({publisher:W(e),package_:o,name:e.name,...r?{version:r}:{}},n,{contextPublisher:t})}renderVersionDiff(e,t){let n=I(e,G);if(!n)return"<!-- LookRenderer.VersionDiff: no look.source -->";let s=$(e,je),o=I(e,Be);if(!o||!s)return"<!-- LookRenderer.VersionDiff: needs look.track + look.metricPath -->";let a=I(e,He),r=$(e,we),i=this.findInstancesOfClass(n);if(i.length===0)return"<!-- LookRenderer.VersionDiff: no instances -->";let c=g=>a?this.readPropertyValueText(g,a)??"":"",l=i.slice().sort((g,h)=>c(g).localeCompare(c(h))),p=this.collectTrackedSeries(l,o,s,{hueBy:r});return p.length===0?"<!-- LookRenderer.VersionDiff: no tracked series -->":`<section class="kan-vdiff">${p.map((g,h)=>{let k=g.hue!==void 0?g.hue:Math.round(h*360/p.length),m=g.points.filter(R=>R!==null);if(m.length===0)return"";let j=m[0],v=m[m.length-1],_=v-j,F;if(Math.abs(_)>=.005){let R=_>0?"up":"down",O=_>0?"\u25B2":"\u25BC";F=`<span class="kan-vdiff-delta ${R}">${_>0?"+":""}${_.toFixed(2)} ${O}</span>`}else F='<span class="kan-vdiff-delta flat">\u2014</span>';let T=g.lastSubject?`<a href="${u(this.hrefForSubject(g.lastSubject,t))}">${u(g.label)}</a>`:u(g.label);return`<div class="kan-vdiff-row" style="--kan-vdiff-hue:${k}"><span class="kan-vdiff-label">${T}</span><span class="kan-vdiff-start">${j.toFixed(2)}</span>`+this.sparkline(g.points,k)+`<span class="kan-vdiff-end">${v.toFixed(2)}</span>`+F+"</div>"}).join("")}</section>`}sparkline(e,t){let a=`hsl(${t},65%,60%)`,r=e.filter(m=>m!==null);if(r.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(...r),l=Math.max(...r)-i,p=e.length,f=m=>p<=1?132/2:4+m/(p-1)*124,g=m=>l<1e-9?30/2:26-(m-i)/l*22,h=[],k=[];return e.forEach((m,j)=>{if(m===null)return;let v=f(j),_=g(m);h.push(`${v.toFixed(1)},${_.toFixed(1)}`),k.push(`<circle cx="${v.toFixed(1)}" cy="${_.toFixed(1)}" r="2" fill="${a}"/>`)}),`<svg class="kan-vdiff-spark" viewBox="0 0 132 30" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg" role="img"><polyline points="${h.join(" ")}" fill="none" stroke="${a}" stroke-width="1.5" stroke-linejoin="round" stroke-linecap="round"/>`+k.join("")+"</svg>"}svgUrlForSubject(e,t,n="="){return`${this.hrefForSubject(e,t,n)}.svg`}renderFigure(e,t,n){let s=t,o=I(e,G);if(o){let i=V(this.catalog,o);i&&(s=i)}let a=this.svgUrlForSubject(s,n),r=$(s,N)??s.name;return`<figure class="kan-figure"><img class="kan-figure-img" src="${u(a)}" alt="${u(r)}" loading="lazy"/></figure>`}renderStatRow(e,t){let n=Q(e,yn),s=this.gatherValueItems(n).filter(a=>a instanceof se);if(s.length===0)return"<!-- LookRenderer.StatRow: no look.stats -->";let o=[];for(let a of s){let r=$(a,xn);if(!r)continue;let i=this.resolvePath(t,r);if(i===void 0)continue;let c=$(a,Ln)??"";o.push('<div class="kan-stat">'+(c?`<span class="kan-stat-label">${u(c)}</span>`:"")+`<span class="kan-stat-val">${u(i)}</span></div>`)}return o.length===0?"":`<div class="kan-stat-row">${o.join("")}</div>`}renderHorizon(e,t,n){let s=I(e,G);if(!s)return"<!-- LookRenderer.Horizon: no look.source -->";let o=this.gatherValueItems(Q(t,s)).filter(r=>r instanceof se);return o.length===0?"":`<section class="kan-horizon">${o.map(r=>this.renderConditionNode(r,n,0)).join("")}</section>`}renderConditionNode(e,t,n){let s=ve(e),o=s?this.readLabelForUri({publisher:s.publisher,package_:s.package_,name:s.name})??s.name:"Condition",a=[],r=[];for(let f of e.statement){let g=f.predicate?.subject;if(!g||g.name==="type")continue;let h=this.readLabelForUri({publisher:g.publisher,package_:g.package_,name:g.name})??g.name;if(f instanceof X||f instanceof me||f instanceof Ke)a.push(`<div class="kan-cond-field"><span class="kan-cond-key">${u(h)}</span><span class="kan-cond-v">${u(String(f.object))}</span></div>`);else if(f instanceof A&&f.object instanceof E){let k=f.object.subject,m=this.readLabelForUri({publisher:k.publisher,package_:k.package_,name:k.name})??k.name;a.push(`<div class="kan-cond-field"><span class="kan-cond-key">${u(h)}</span><span class="kan-cond-v">${u(m)}</span></div>`)}else if(f instanceof ie)r.push(this.renderConditionNode(f.object,t,n+1));else if(f instanceof D)for(let k of f.object??[])k instanceof se&&r.push(this.renderConditionNode(k,t,n+1))}let i=a.length?`<div class="kan-cond-fields">${a.join("")}</div>`:"",c=r.length?`<div class="kan-cond-children">${r.join("")}</div>`:"",l=r.length>0,p=l?`<span class="kan-cond-op">${u(o)}</span>`:`<div class="kan-cond-type">${u(o)}</div>`;return`<div class="kan-cond ${l?"kan-cond-branch":"kan-cond-leaf"}">${p}${i}${c}</div>`}renderSectionHeading(e){let t=e,n=$(t,Rn);if(!n)return"<!-- LookRenderer.SectionHeading: no look.heading -->";let s=$(t,Sn);return`<div class="kan-section"><h2 class="kan-section-title">${u(n)}</h2>`+(s?`<p class="kan-section-note">${u(s)}</p>`:"")+"</div>"}renderVersionDelta(e,t){let s=$(e,je);if(!s)return"<!-- LookRenderer.VersionDelta: no look.metricPath -->";let o=w=>{let U=this.resolvePath(w,s),z=U===void 0?NaN:parseFloat(U);return Number.isFinite(z)?z:void 0},a=o(t);if(a===void 0)return"";let r=w=>this.parseVersion((w.namespace||"").split("@")[1]??"")??{major:0,minor:0,patch:0},i=(w,U)=>w.major-U.major||w.minor-U.minor||w.patch-U.patch,c={publisher:W(t),package_:(t.namespace||"").split("/")[1]?.split("@")[0]??"",name:t.name},l=r(t),p,f;for(let w of re(this.catalog,c)){let U=r(w);i(U,l)<0&&(!f||i(U,f)>0)&&(p=w,f=U)}if(!p||!f)return'<div class="kan-delta kan-delta-first">First tracked in this version</div>';let g=o(p);if(g===void 0)return"";let h=a-g,k=Math.abs(h)<.005?"flat":h>0?"up":"down",m=k==="up"?"\u25B2":k==="down"?"\u25BC":"\u2014",j=k==="up"?"#34d399":k==="down"?"#f87171":"var(--kan-text-faint)",v=`${f.major}.${f.minor}.${f.patch}`,_=320,F=46,T=14,R=30,O=w=>T+Math.min(1,Math.max(0,w))*(_-2*T),S=O(g),P=O(a),ue=`<svg class="kan-delta-track" viewBox="0 0 ${_} ${F}" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" role="img"><line x1="${T}" y1="${R}" x2="${_-T}" y2="${R}" class="kan-delta-base"/><line x1="${S.toFixed(1)}" y1="${R}" x2="${P.toFixed(1)}" y2="${R}" stroke="${j}" stroke-width="3"/><circle cx="${S.toFixed(1)}" cy="${R}" r="4" class="kan-delta-prev"/><circle cx="${P.toFixed(1)}" cy="${R}" r="5.5" fill="${j}"/><text x="${S.toFixed(1)}" y="${R-9}" text-anchor="middle" class="kan-delta-tick kan-delta-tick-prev">${g.toFixed(2)}</text><text x="${P.toFixed(1)}" y="${R+17}" text-anchor="middle" class="kan-delta-tick">${a.toFixed(2)}</text></svg>`;return`<div class="kan-delta"><div class="kan-delta-head"><span class="kan-delta-vs">vs ${u(v)}</span><span class="kan-delta-badge ${k}">${h>0?"+":""}${h.toFixed(2)} ${m}</span></div>`+ue+"</div>"}renderPackageContents(e,t){let n=e.namespace||"";if(!n)return"";let s=this.catalog.filter(a=>a instanceof J&&a.namespace===n&&a.name!==e.name);return s.length===0?`<!-- LookRenderer.PackageContents: no members in ${n} -->`:(s.sort((a,r)=>{let i=$(a,N)??a.name,c=$(r,N)??r.name;return i.localeCompare(c)}),`<section class="kan-pkg-grid">${s.map(a=>{let r=$(a,N)??a.name,i=$(a,be),c=i?Ze(i,160):"",l=this.hrefForSubject(a,t),p=this.svgUrlForSubject(a,t);return`<a class="kan-pkg-card" href="${u(l)}"><img class="kan-pkg-card-svg" src="${u(p)}" alt="" loading="lazy"/><span class="kan-pkg-card-body"><span class="kan-pkg-card-title">${u(r)}</span>`+(c?`<span class="kan-pkg-card-comment">${u(c)}</span>`:"")+"</span></a>"}).join("")}</section>`)}renderFeaturedResource(e,t){let n=I(e,G);if(!n)return"<!-- LookRenderer.FeaturedResource: no look.source -->";let s=re(this.catalog,n),o=c=>this.parseVersion((c.namespace||"").split("@")[1]??"")??{major:0,minor:0,patch:0},a=s.length>0?s.slice().sort((c,l)=>{let p=o(c),f=o(l);return f.major-p.major||f.minor-p.minor||f.patch-p.patch})[0]:V(this.catalog,n);if(!a)return`<!-- LookRenderer.FeaturedResource: ${n.publisher}/${n.package_}/${n.name} not found -->`;let r=this.renderHtml(a),i=this.hrefForSubject(a,t);return`<section class="kan-featured"><a class="kan-featured-permalink" href="${u(i)}">View full resource \u2192</a>`+r+"</section>"}renderDistribution(e,t){let n=e,s=K=>{let y=$(n,K);if(!y)return;let ne=this.resolvePath(t,y),b=ne===void 0?NaN:parseFloat(ne);return Number.isFinite(b)?b:void 0},o=s(jn),a=s(_n);if(o===void 0||a===void 0||o<=0||a<=0)return"<!-- LookRenderer.Distribution: needs resolvable alphaPath + betaPath (> 0) -->";let r=s(je)??o/(o+a),i=s(De),c=s(Ge),l=s(we),p=l!==void 0?`hsl(${l},65%,60%)`:"var(--kan-accent)",f=K=>Number.isInteger(K)?String(K):K.toFixed(1),g=280,h=168,k={top:14,right:14,bottom:24,left:14},m=g-k.left-k.right,j=h-k.top-k.bottom,v=120,_=1e-4,F=[],T=[],R=0;for(let K=0;K<=v;K++){let y=K/v;y<_?y=_:y>1-_&&(y=1-_);let ne=Math.exp((o-1)*Math.log(y)+(a-1)*Math.log(1-y));F.push(y),T.push(ne),ne>R&&(R=ne)}let O=K=>k.left+Math.min(1,Math.max(0,K))*m,S=K=>k.top+(1-(R>0?K/R:0))*j,P=k.top+j,ue=F.map((K,y)=>`${O(K).toFixed(1)},${S(T[y]).toFixed(1)}`),w=`M${O(0).toFixed(1)},${P.toFixed(1)} L${ue.join(" L")} L${O(1).toFixed(1)},${P.toFixed(1)} Z`,U="";if(i!==void 0&&c!==void 0&&c>i){let K=[`${O(i).toFixed(1)},${P.toFixed(1)}`];for(let y=0;y<=v;y++)F[y]>=i&&F[y]<=c&&K.push(`${O(F[y]).toFixed(1)},${S(T[y]).toFixed(1)}`);K.push(`${O(c).toFixed(1)},${P.toFixed(1)}`),U=`<path d="M${K.join(" L")} Z" fill="${p}" fill-opacity="0.3"/>`}let z=O(r),pe=`<line x1="${z.toFixed(1)}" y1="${k.top.toFixed(1)}" x2="${z.toFixed(1)}" y2="${P.toFixed(1)}" stroke="${p}" stroke-width="1.5" stroke-dasharray="3 3"/><text x="${z.toFixed(1)}" y="${(k.top-3).toFixed(1)}" text-anchor="middle" class="kan-dist-mean">\u03BC ${r.toFixed(2)}</text>`,ke=`<text x="${O(0).toFixed(1)}" y="${(P+15).toFixed(1)}" text-anchor="start" class="kan-dist-axis">0</text><text x="${O(1).toFixed(1)}" y="${(P+15).toFixed(1)}" text-anchor="end" class="kan-dist-axis">1</text>`,ge=`<svg class="kan-dist-svg" viewBox="0 0 ${g} ${h}" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" role="img"><line x1="${k.left}" y1="${P.toFixed(1)}" x2="${(g-k.right).toFixed(1)}" y2="${P.toFixed(1)}" class="kan-dist-base"/><path d="${w}" fill="${p}" fill-opacity="0.12"/>`+U+`<polyline points="${ue.join(" ")}" fill="none" stroke="${p}" stroke-width="2"/>`+pe+ke+"</svg>",he=i!==void 0&&c!==void 0?` \xB7 95% CI [${i.toFixed(2)}\u2013${c.toFixed(2)}]`:"";return`<figure class="kan-dist">${ge}<figcaption class="kan-dist-caption">Beta(${f(o)}, ${f(a)})${he}</figcaption></figure>`}renderPublisherPackages(e){let t=new Map,n=r=>this.parseVersion((r.namespace||"").split("@")[1]??"")??{major:0,minor:0,patch:0},s=(r,i)=>r.major>i.major||r.major===i.major&&(r.minor>i.minor||r.minor===i.minor&&r.patch>i.patch);for(let r of this.catalog){if(!(r instanceof J)||W(r)!==e)continue;let i=(r.namespace||"").split("/")[1]?.split("@")[0]??"";if(!i||r.name!==i)continue;let c=t.get(i);(!c||s(n(r),n(c)))&&t.set(i,r)}let o=[...t.entries()].sort((r,i)=>r[0].localeCompare(i[0]));return o.length===0?"":`<section class="kan-pkg-grid">${o.map(([r,i])=>{let c=$(i,N)??r,l=$(i,be),p=l?Ze(l,160):"",f=this.svgUrlForSubject(i,e);return`<a class="kan-pkg-card" href="/${u(r)}"><img class="kan-pkg-card-svg" src="${u(f)}" alt="" loading="lazy"/><span class="kan-pkg-card-body"><span class="kan-pkg-card-title">${u(c)}</span>`+(p?`<span class="kan-pkg-card-comment">${u(p)}</span>`:"")+"</span></a>"}).join("")}</section>`}findPublisherRootView(e){for(let t of this.catalog){if(!(t instanceof J)||W(t)!==e)continue;let n=_e(t);if(!n)continue;let s=ve(n);if(s&&L(s,bn))return t}}renderTimeline(e,t){let n=I(e,G);if(!n)return"<!-- LookRenderer.Timeline: no look.source -->";let s=I(e,He),o=this.findInstancesOfClass(n);if(o.length===0)return"<!-- LookRenderer.Timeline: no instances -->";let a=p=>s?this.readPropertyValueText(p,s)??"":"",r=o.slice().sort((p,f)=>a(p).localeCompare(a(f))),i=I(e,Be),c=$(e,je);return i&&c?this.renderTrajectoryChart(r,i,c,e,t,a):`<section class="kan-timeline"><ol>
96
- ${r.map(p=>{let f=p.namespace||"",g=f.split("/")[1]?.split("@")[0]??"",h=f.split("@")[1]??"",k=h?this.parseVersion(h):void 0,m=ce.formatResourceUrl({publisher:W(p),package_:g,name:p.name,...k?{version:k}:{}},"=",{contextPublisher:t}),j=a(p),v=j?`<span class="kan-timeline-date">${u(j)}</span>`:"",_=h||p.name;return`<li class="kan-timeline-node"><a href="${u(m)}"><span class="kan-timeline-key">${u(_)}</span>${v}</a></li>`}).join(`
97
- `)}
98
- </ol></section>`}renderTrajectoryChart(e,t,n,s,o,a){let r=s,i=$(r,we),c=$(r,De),l=$(r,Ge),p=$(r,In),f=Ye(r,Fn),g=Ye(r,Un),h=e.length,k=this.collectTrackedSeries(e,t,n,{hueBy:i,lowerPath:c,upperPath:l});if(k.length===0)return"<!-- LookRenderer.Timeline: no tracked series -->";let m=[];for(let b of k){for(let x of b.points)x!==null&&m.push(x);for(let x of b.lower??[])x!==null&&m.push(x);for(let x of b.upper??[])x!==null&&m.push(x)}if(m.length===0)return"<!-- LookRenderer.Timeline: no metric values -->";let j=Math.min(...m),v=Math.max(...m);v-j<1e-9&&(j-=.5,v+=.5);let _=(v-j)*.08,F=f!==void 0?f:j-_,T=g!==void 0?g:v+_;T-F<1e-9&&(T=F+1);let R=1e3,O=440,S={top:28,right:24,bottom:56,left:52},P=R-S.left-S.right,ue=O-S.top-S.bottom,w=b=>h<=1?S.left+P/2:S.left+b/(h-1)*P,U=b=>S.top+(1-(b-F)/(T-F))*ue,z=(b,x)=>b.hue!==void 0?b.hue:Math.round(x*360/k.length),pe=[];for(let b=0;b<5;b++){let x=F+b*(T-F)/4,q=U(x);pe.push(`<line x1="${S.left}" y1="${q.toFixed(1)}" x2="${(R-S.right).toFixed(1)}" y2="${q.toFixed(1)}" class="kan-fan-grid"/>`),pe.push(`<text x="${(S.left-8).toFixed(1)}" y="${(q+4).toFixed(1)}" class="kan-fan-axis" text-anchor="end">${x.toFixed(2)}</text>`)}let ke=[];e.forEach((b,x)=>{let q=this.hrefForSubject(b,o),M=(b.namespace||"").split("@")[1]??"",C=w(x),H=Gn(a(b));ke.push(`<a href="${u(q)}" class="kan-fan-xtick"><line x1="${C.toFixed(1)}" y1="${S.top}" x2="${C.toFixed(1)}" y2="${(O-S.bottom).toFixed(1)}" class="kan-fan-vline"/><text x="${C.toFixed(1)}" y="${(O-S.bottom+20).toFixed(1)}" class="kan-fan-xlabel" text-anchor="middle">${fe(M||b.name)}</text>`+(H?`<text x="${C.toFixed(1)}" y="${(O-S.bottom+36).toFixed(1)}" class="kan-fan-xdate" text-anchor="middle">${fe(H)}</text>`:"")+"</a>")});let ge=[];k.forEach((b,x)=>{if(!b.lower||!b.upper)return;let q=z(b,x),M=[],C=[];for(let B=0;B<h;B++){let oe=b.upper[B],te=b.lower[B];oe==null||te===null||te===void 0||(M.push(`${w(B).toFixed(1)},${U(oe).toFixed(1)}`),C.unshift(`${w(B).toFixed(1)},${U(te).toFixed(1)}`))}let H=M.concat(C);H.length<3||ge.push(`<polygon class="kan-fan-band" points="${H.join(" ")}" fill="hsl(${q},65%,60%)"/>`)});let he=[];k.forEach((b,x)=>{let M=`hsl(${z(b,x)},65%,60%)`,C=[],H=[];b.points.forEach((B,oe)=>{if(B===null)return;let te=w(oe),Y=U(B);C.push(`${te.toFixed(1)},${Y.toFixed(1)}`),H.push(`<circle cx="${te.toFixed(1)}" cy="${Y.toFixed(1)}" r="3.5" fill="${M}"/>`)}),C.length!==0&&he.push(`<g class="kan-fan-series" data-series="${u(b.key)}"><polyline points="${C.join(" ")}" fill="none" stroke="${M}" stroke-width="2" stroke-linejoin="round" stroke-linecap="round"/>`+H.join("")+"</g>")});let K=`<svg class="kan-fan-svg" viewBox="0 0 ${R} ${O}" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" role="img">`+pe.join("")+ke.join("")+ge.join("")+he.join("")+"</svg>",y=p?`${u(p)}=`:"",ne=k.map((b,x)=>{let q=z(b,x),M=b.points.filter(Y=>Y!==null),C=M.length?M[0]:void 0,H=M.length?M[M.length-1]:void 0,B="";if(H!==void 0&&C!==void 0){let Y=H-C;if(Math.abs(Y)>=.005){let Qe=Y>0?"up":"down",en=Y>0?"\u25B2":"\u25BC";B=` <span class="kan-fan-delta ${Qe}">${Y>0?"+":""}${Y.toFixed(2)} ${en}</span>`}else B=' <span class="kan-fan-delta flat">\u2014</span>'}let oe=H!==void 0?`${y}${H.toFixed(2)}`:"\u2014",te=b.lastSubject?`<a href="${u(this.hrefForSubject(b.lastSubject,o))}">${u(b.label)}</a>`:u(b.label);return`<div class="kan-fan-legend-item" style="--kan-fan-hue:${q}"><span class="kan-fan-swatch"></span><span class="kan-fan-legend-label">${te}</span><span class="kan-fan-legend-cur">${oe}${B}</span></div>`});return`<section class="kan-fan"><div class="kan-fan-chart">${K}</div><div class="kan-fan-legend">${ne.join("")}</div></section>`}renderResourceGrid(e,t,n){let s=I(e,G);if(!s)return"<!-- LookRenderer.ResourceGrid: no look.source -->";let o=V(this.catalog,s),a=o?ae(o).some(c=>{let l=c.subject.name;return l==="ObjectProperty"||l==="DatatypeProperty"||l==="Property"}):!1,r=[];if(a&&n){let c=this.readPropertyValueReferences(n,s);for(let l of c){let p=V(this.catalog,{publisher:l.subject.publisher,package_:l.subject.package_,name:l.subject.name,...l.subject.version?{version:l.subject.version}:{}});p&&r.push(p)}}else r=this.findInstancesOfClass(s);if(r.length===0)return`<!-- LookRenderer.ResourceGrid: no resources for ${s.publisher}/${s.package_}/${s.name} -->`;let i=[];for(let c of r){let l=$(c,N)??c.name,p=$(c,be),f=c.namespace||"",g=f.split("/")[1]?.split("@")[0]??"",h=f.split("@")[1]??"",k=h?this.parseVersion(h):void 0,m=ce.formatResourceUrl({publisher:W(c),package_:g,name:c.name,...k?{version:k}:{}},"=",{contextPublisher:t}),j=p?`<p class="kan-resource-card-subtitle">${u(p)}</p>`:"";i.push(`<a class="kan-resource-card" href="${u(m)}"><h3 class="kan-resource-card-title">${u(l)}</h3>${j}</a>`)}return`<section class="kan-resource-grid">
99
- ${i.join(`
100
- `)}
101
- </section>`}parseVersion(e){let t=e.split(".").map(Number);if(!(t.length!==3||t.some(n=>Number.isNaN(n))))return{major:t[0],minor:t[1],patch:t[2]}}findInstancesOfClass(e){let t=[];for(let n of this.catalog){if(!(n instanceof J))continue;ae(n).map(a=>a.subject).some(a=>a.publisher===e.publisher&&a.package_===e.package_&&a.name===e.name)&&t.push(n)}return t}renderBreadcrumb(e,t,n){let o=(e.namespace||"").split("/");if(o.length<2)return"";let a=o[0],r=o[1]??"",i=r.split("@")[0]??"",c=r.split("@")[1]??"";if(!a||!i)return"";if(n?.bareOverview)return`<nav class="kan-breadcrumb"><ol>
102
- <li><a href="/">${u(a)}</a></li>
103
- <li aria-current="page">${u(i)}</li>
104
- </ol></nav>`;let l=e.name,f=!!V(this.catalog,{publisher:a,package_:i,name:i}),g=c?`${i}@${c}`:i,h=c?`/${i}/${c}/${i}`:`/${i}/${i}`,k=e.name===i,m=[];return m.push(`<li><a href="/">${u(a)}</a></li>`),k?m.push(`<li aria-current="page">${u(g)}</li>`):(m.push(f?`<li><a href="${u(h)}">${u(g)}</a></li>`:`<li>${u(g)}</li>`),m.push(`<li aria-current="page">${u(l)}</li>`)),`<nav class="kan-breadcrumb"><ol>
105
- ${m.join(`
106
- `)}
107
- </ol></nav>`}renderNavGroup(e,t){let n=this.findNavGroupForPublisher(t);if(!n)return"";let s=Q(n,Ue);if(!(s instanceof D))return"";let o=s.object??[];if(o.length===0)return"";let a=[];for(let r of o){if(!(r instanceof E))continue;let i=V(this.catalog,{publisher:r.subject.publisher,package_:r.subject.package_,name:r.subject.name}),{href:c,label:l}=this.resolveNavEntry(r,i,t),p=`/${e.namespace?.split("/")[1]?.split("@")[0]}/${(e.namespace||"").split("@")[1]}/${e.name}`,f=c===p?' aria-current="page"':"";a.push(`<li><a class="kan-nav-link" href="${u(c)}"${f}>${u(l)}</a></li>`)}return`<nav class="kan-site-nav"><ul>
108
- ${a.join(`
109
- `)}
110
- </ul></nav>`}resolveNavEntry(e,t,n){if(t&&ae(t).map(i=>i.subject).some(i=>i.publisher===Oe.publisher&&i.package_===Oe.package_&&i.name===Oe.name)){let i=$(t,N),c=Q(t,Me);if(c instanceof A&&c.object instanceof E){let l=c.object,p=this.readLabelForUri({publisher:l.subject.publisher,package_:l.subject.package_,name:l.subject.name});return{href:this.urlForReference(l,Me,n),label:i??p??l.subject.name}}}let s=ce.formatResourceUrl({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},"*",{contextPublisher:n}),o=t?$(t,N)??e.subject.name:e.subject.name;return{href:s,label:o}}findNavGroupForPublisher(e){for(let t of this.catalog){if(!(t instanceof J)||!(t.namespace||"").startsWith(`${e}/`))continue;if(ae(t).map(a=>a.subject).some(a=>a.publisher===$e.publisher&&a.package_===$e.package_&&a.name===$e.name))return t}}renderMarkdown(e,t,n){let s=I(e,G);if(!s)return"<!-- LookRenderer.Markdown: no look.source -->";let o=Q(t,s),a;return o instanceof Pe?a=this.resolveMarkdownLinks(o,n):o instanceof X?a=o.object:a=this.readPropertyValueText(t,s),a?`<section class="kan-markdown">
111
- ${Ce(a)}
112
- </section>`:""}resolveMarkdownLinks(e,t){let n=e.object,s=[...e.links].sort((o,a)=>a.startOffset-o.startOffset);for(let o of s){let a;if(o.target){let r=o.target.subject,i=(o.displayText??this.readLabelForUri({publisher:r.publisher,package_:r.package_,name:r.name})??o.reference).replace(/[[\]]/g,""),c=ce.formatResourceUrl({publisher:r.publisher,package_:r.package_,name:r.name,...r.version?{version:r.version}:{}},"=",{contextPublisher:t});a=`[${i}](${c})`}else a=o.displayText??o.reference;n=n.slice(0,o.startOffset)+a+n.slice(o.endOffset)}return n}renderRawMarkdown(e){let t=this.findCascadedLook(e);if(!t)return;let n=ze(t.declaration),s=[];for(let o of n){let a=ve(o);if(!a||!L(a,Ve))continue;let r=I(o,G);if(!r)continue;let i=this.readPropertyValueText(e,r);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=I(e,Vn);if(o){let l=this.readPropertyValueText(t,o);l&&s.push(`<span class="kan-hero-eyebrow">${u(l)}</span>`)}let a=I(e,Nn),r="";a&&(r=this.readPropertyValueText(t,a)??""),r||(r=t.name),s.push(`<h1 class="kan-hero-title">${u(r)}</h1>`);let i=I(e,Mn);if(i){let l=this.readPropertyValueText(t,i);l&&s.push(`<p class="kan-hero-subtitle">${u(l)}</p>`)}let c=I(e,We);if(c){let l=this.readPropertyValueReferences(t,c);if(l.length>0){let p=l.map(f=>this.renderBadge(f,We,n)).join("");s.push(`<div class="kan-hero-badges">${p}</div>`)}}return s.push("</header>"),s.join(`
115
- `)}renderPropertyList(e,t,n){let s=I(e,G);if(!s)return"<!-- LookRenderer: PropertyList missing look.source -->";let o=this.readLabelForUri(s)??s.name,a=Q(t,s),r=this.gatherValueItems(a),i=r.length>0?r.map(c=>`<li>${this.renderInlineValue(c,G,n)}</li>`).join(""):'<li class="kan-empty">(no values)</li>';return['<section class="kan-property-list">',`<h3 class="kan-property-list-title">${u(o)}</h3>`,`<ul class="kan-property-list-items">${i}</ul>`,"</section>"].join(`
116
- `)}renderBadgeRow(e,t,n){let s=I(e,G);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(r=>this.renderBadge(r,G,n)).join("")}</div>`}renderChipRow(e,t,n){let s=qe(e,Hn);if(s.length===0)return"<!-- LookRenderer: ChipRow has no look.chips -->";let o=[];for(let a of s){let r=Q(t,a);if(!r)continue;let i=this.readLabelForUri(a)??a.name,c=this.renderStatementInlineValue(r,a,n);c&&o.push(`<span class="kan-chip"><span class="kan-chip-key">${u(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=qe(e,Ue);if(s.length===0)return"<!-- LookRenderer: ReferenceList has no look.entries -->";let o=$(e,On),a=$(e,wn),r=[];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 p=c.map(f=>this.renderDetailRow(f,o,a,n)).filter(f=>f).join("");p&&r.push(`<dt>${u(l)}</dt><dd><ul class="kan-ref-rows">${p}</ul></dd>`)}else{let p=c.map(f=>this.renderReferenceLink(f,Ue,n)).join(", ");r.push(`<dt>${u(l)}</dt><dd>${p}</dd>`)}}return r.length===0?"":`<dl class="kan-reference-list">${r.join("")}</dl>`}renderDetailRow(e,t,n,s){let o=V(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 a=this.resolvePath(o,t)??$(o,N)??o.name,r=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">${u(l)}</span>`)}return`<li class="kan-ref-row"><a class="kan-ref-rowlink" href="${u(r)}"><img class="kan-ref-icon" src="${u(i)}" alt="" loading="lazy"/><span class="kan-ref-text">${u(a)}</span>${c}</a></li>`}readPropertyValueText(e,t){let n=Q(e,t);if(n){if(n instanceof X)return n.object;if(n instanceof A){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 D)return(n.object??[]).map(o=>o instanceof E?this.readLabelForUri({publisher:o.subject.publisher,package_:o.subject.package_,name:o.subject.name})??o.subject.name:o instanceof se?o.name??"":String(o)).filter(o=>o).join(", ")}}readPropertyValueReferences(e,t){let n=Q(e,t);if(!n)return[];if(n instanceof A)return[n.object];if(n instanceof D){let s=[];for(let o of n.object??[])o instanceof E&&s.push(o);return s}return[]}gatherValueItems(e){return e?e instanceof D?e.object??[]:e instanceof A?[e.object]:e instanceof ie?[e.object]:e instanceof X?[e.object]:[]:[]}renderInlineValue(e,t,n){return e instanceof E?this.renderReferenceLink(e,t,n):e instanceof se?u(e.name??"(embedded)"):typeof e=="string"?u(e):typeof e=="number"||typeof e=="boolean"?u(String(e)):""}renderStatementInlineValue(e,t,n){return e instanceof X?u(e.object):e instanceof A?this.renderReferenceLink(e.object,t,n):e instanceof D?(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="${u(o)}">${u(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}),a=this.urlForReference(e,t,n),r=o?` title="${u(o)}"`:"";return`<a class="kan-badge" href="${u(a)}"${r}>${u(s)}</a>`}urlForReference(e,t,n){let s=t?this.getUrlFormForProperty(t):"=";return ce.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=V(this.catalog,e);if(!t)return"=";let n=$(t,Bn);return n==="*"||n==="^"||n==="~"||n==="="?n:"="}readLabelForUri(e){let t=V(this.catalog,e);if(t)return $(t,N)}readCommentForUri(e){let t=V(this.catalog,e);if(t)return $(t,be)}};function Ie(d){let e=new Map;for(let t of d.statement){if(!(t instanceof ie)||!ee(t,Le.publisher,Le.package_,Le.name))continue;let n=t.object;for(let s of n.statement){if(!(s instanceof X))continue;let o=s.predicate?.subject?.name;if(!o)continue;let a=s.object;e.has(o)||e.set(o,a)}}return e}function _e(d){for(let e of d.statement)if(e instanceof ie&&ee(e,xe.publisher,xe.package_,xe.name))return e.object}function ze(d){for(let e of d.statement){if(!(e instanceof D)||!ee(e,Fe.publisher,Fe.package_,Fe.name))continue;let t=[];for(let n of e.object??[])n instanceof se&&t.push(n);return t}return[]}function ve(d){for(let e of d.statement)if(e instanceof A&&e.predicate?.subject?.name==="type"&&e.object instanceof E){let t=e.object.subject;return{publisher:t.publisher,package_:t.package_,name:t.name}}}function I(d,e){for(let t of d.statement)if(t instanceof A&&ee(t,e.publisher,e.package_,e.name)&&t.object instanceof E){let n=t.object.subject;return{publisher:n.publisher,package_:n.package_,name:n.name}}}function qe(d,e){for(let t of d.statement){if(!(t instanceof D)||!ee(t,e.publisher,e.package_,e.name))continue;let n=[];for(let s of t.object??[])s instanceof E&&n.push({publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name});return n}return[]}function Q(d,e){for(let t of d.statement)if(ee(t,e.publisher,e.package_,e.name))return t}function $(d,e){for(let t of d.statement)if(t instanceof X&&ee(t,e.publisher,e.package_,e.name))return t.object}function Ye(d,e){for(let t of d.statement)if(t instanceof me&&ee(t,e.publisher,e.package_,e.name))return t.object}function ae(d){let e=[];for(let t of d.statement)if(t instanceof A){if(t.predicate?.subject?.name!=="type")continue;t.object instanceof E&&e.push(t.object)}else if(t instanceof D){if(t.predicate?.subject?.name!=="type")continue;for(let n of t.object??[])n instanceof E&&e.push(n)}return e}function Re(d){let e=[];for(let t of d.statement)if(t instanceof A){if(t.predicate?.subject?.name!=="subClassOf")continue;t.object instanceof E&&e.push(t.object)}else if(t instanceof D){if(t.predicate?.subject?.name!=="subClassOf")continue;for(let n of t.object??[])n instanceof E&&e.push(n)}return e}function re(d,e){let t=[];for(let n of d){if(!(n instanceof J)||n.name!==e.name)continue;(n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&t.push(n)}return t}function V(d,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 d)if(s instanceof J&&s.name===e.name&&s.namespace===n)return s}for(let n of d){if(!(n instanceof J)||n.name!==e.name)continue;if((n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))return n}}function ee(d,e,t,n){let s=d.predicate?.subject;return s?s.publisher===e&&s.package_===t&&s.name===n:!1}function L(d,e){return d.publisher===e.publisher&&d.package_===e.package_&&d.name===e.name}function le(d){return`${d.publisher}/${d.package_}/${d.name}`}function Dn(d){return d.name==="Package"?{...Se}:d}function W(d){let e=d.namespace||"",t=e.indexOf("/");return t>=0?e.substring(0,t):e}function u(d){return d.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Je(d){let e=d.lastIndexOf(".");return e>=0?d.substring(e+1):d}function Xe(d,e){for(let t of d.statement)if(t.predicate?.subject?.name===e)return t}function fe(d){return d.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Ze(d,e){return d.length<=e?d:d.slice(0,e).replace(/\s+\S*$/,"")+"\u2026"}function Gn(d){if(!d)return"";let e=/^(\d{4})-(\d{2})-(\d{2})/.exec(d);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)}`:d}export{Ce as a,Ee as b};
@@ -1,54 +0,0 @@
1
- import{a as me}from"./chunk-FJ35VIV6.js";import{a as se,c as le,d as ye,f as Z}from"./chunk-SQDXESNM.js";import{c as J,k as ae,l as ce}from"./chunk-W6T7MOKY.js";import{a as ie}from"./chunk-7CUTGGH3.js";import{c as A}from"./chunk-FQHALFRR.js";import{a as P,b as V,c as pe}from"./chunk-5ILSX24H.js";var D=class{isValid=!1;errors=[];warnings=[];get totalIssues(){return this.errors.length+this.warnings.length}};var R=(r=>(r.Warning="Warning",r.Error="Error",r))(R||{});var g=class{ruleType="";severity="Error";lineNumber;column;entityName;propertyName;propertyPath;message="";suggestion;actualValue;expectedValue;toString(){let e="";return this.lineNumber!==void 0&&(e+=`Line ${this.lineNumber}: `),this.entityName&&(e+=`[${this.entityName}] `),e+=this.message,e}};var Q=class d{resolvedDocuments=[];currentEntityPath;withPath(e){let r=new d;return r.resolvedDocuments=this.resolvedDocuments,r.currentEntityPath=e,r}};var te=class{constructor(e){this.underlying=e;this.repository=new re(e)}underlying;repository;kanonaksPromise=null;importClosureCache=new Map;classDeclarationsCache=new Map;propertyNamesCache=new Map;allDocumentsPromise=null;getKanonaks(){return this.kanonaksPromise||(this.kanonaksPromise=new Z().parseKanonaks(this.underlying)),this.kanonaksPromise}async getImportClosure(e){let r=this.importClosureCache.get(e);return r||(r=this.computeImportClosure(e),this.importClosureCache.set(e,r),r)}async getClassDeclarations(e){let r=this.classDeclarationsCache.get(e);return r||(r=this.computeClassDeclarations(e),this.classDeclarationsCache.set(e,r),r)}async getPropertyNames(e){let r=this.propertyNamesCache.get(e);return r||(r=this.computePropertyNames(e),this.propertyNamesCache.set(e,r),r)}getAllDocuments(){return this.allDocumentsPromise||(this.allDocumentsPromise=this.underlying.getAllDocumentsAsync()),this.allDocumentsPromise}async computeImportClosure(e){let r=new Set([e]),t=[e],o=await this.buildDocsByIdIndex();for(;t.length>0;){let a=t.shift(),i=o.get(a);if(i?.metadata.imports)for(let[n,c]of Object.entries(i.metadata.imports))for(let s of c){let l=await this.repository.getHighestCompatibleVersionAsync(n,s);if(!l)continue;let p=ee(l);!p||r.has(p)||(r.add(p),t.push(p))}}return r}async buildDocsByIdIndex(){let e=await this.getAllDocuments(),r=new Map;for(let t of e){let o=ee(t);o&&r.set(o,t)}return r}async computeClassDeclarations(e){let r=await this.findDocById(e),t=new Map;if(!r)return t;for(let[o,a]of Object.entries(r.body)){if(!ue(a))continue;let i=a,n=fe(i,"type");if(n==="Class"||n?.endsWith(".Class")){let c=he(i);t.set(o,c)}}return t}async computePropertyNames(e){let r=await this.findDocById(e),t=new Set;if(!r)return t;for(let[o,a]of Object.entries(r.body)){if(!ue(a))continue;let n=fe(a,"type");(n==="ObjectProperty"||n?.endsWith(".ObjectProperty")||n==="DatatypeProperty"||n?.endsWith(".DatatypeProperty")||n==="AnnotationProperty"||n?.endsWith(".AnnotationProperty")||n==="Property"||n?.endsWith(".Property"))&&t.add(o)}return t}async findDocById(e){let r=await this.getAllDocuments();for(let t of r)if(ee(t)===e)return t}};function ee(d){let e=d.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${A(e.version)}`}function ue(d){return typeof d=="object"&&d!==null&&!Array.isArray(d)}function fe(d,e){if(e in d)return de(d[e]);for(let r of Object.keys(d))if(r.endsWith(`.${e}`))return de(d[r])}function de(d){return Array.isArray(d)?d.length>0?String(d[0]):void 0:d==null?void 0:String(d)}function he(d){let e=d.subClassOf;if(e===void 0){for(let r of Object.keys(d))if(r.endsWith(".subClassOf")){e=d[r];break}}return P(e)}var re=class{constructor(e){this.inner=e}inner;highestVersionCache=new Map;byNamespaceCache=new Map;getAllDocumentsAsync(){return this.inner.getAllDocumentsAsync()}getDocumentAsync(e){return this.inner.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,r){let t=`${e}/${r}`,o=this.byNamespaceCache.get(t);return o||(o=this.inner.getDocumentsByNamespaceAsync(e,r),this.byNamespaceCache.set(t,o),o)}getHighestCompatibleVersionAsync(e,r){let t=r.version,o=t?`${t.major}.${t.minor}.${t.patch}`:"",a=`${e}/${r.packageName}@${r.versionOperator}:${o}`,i=this.highestVersionCache.get(a);return i||(i=this.inner.getHighestCompatibleVersionAsync(e,r),this.highestVersionCache.set(a,i),i)}saveDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}deleteDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}clearNamespaceAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}getAllDocumentReferencesAsync(){return this.inner.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.inner.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.inner.getDocumentUriAsync(e)}};var v=class d{static NAMESPACE_PREFIX_PATTERN=/^(rdfs|xsd|owl|rdf|dc|foaf|skos|dct|dcterms|geo|time|prov|schema|og|dbo):/i;ruleName="NamespacePrefix";validate(e){let r=[];for(let[t,o]of Object.entries(e.body))o&&typeof o=="object"&&!Array.isArray(o)&&this.validateEntity(t,o,r);return r}validateEntity(e,r,t){for(let[o,a]of Object.entries(r)){let i=a?.toString()??"";if(i&&d.NAMESPACE_PREFIX_PATTERN.test(i)){let n=this.getSuggestionForPrefixedValue(i),c=e.split(".")[0],s=new g;s.ruleType=this.ruleName,s.severity="Error",s.entityName=c,s.propertyName=e,s.actualValue=o,s.expectedValue=n,s.message=`Invalid namespace prefix '${i}'. Use '${n}' without prefix.`,s.suggestion="Kanonak YAML uses simple type names. Namespace resolution is handled through imports.",t.push(s)}a&&typeof a=="object"&&!Array.isArray(a)&&this.validateEntity(`${e}.${o}`,a,t)}}getSuggestionForPrefixedValue(e){let r=e.toLowerCase();if(r==="rdfs:class"||r==="owl:class")return"Class";if(r==="rdfs:property"||r==="rdf:property")return"DatatypeProperty or ObjectProperty";if(r.startsWith("xsd:"))return e.substring(4);let t=e.indexOf(":");return t>=0?e.substring(t+1):e}};var I=class d{static RESERVED_WORDS=new Set(["kanonak","imports","namespace","type","label","comment","subclassof","domain","range","required","functional"]);static VALID_PROPERTIES=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","required","functional","inverseOf","transitive","symmetric","inverseFunctional"]);static VALID_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_AUGMENTATION_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*\.[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_PROPERTY_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_.]*$/;ruleName="ResourceNaming";validate(e){let r=[],t=e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-");for(let[o,a]of Object.entries(e.body)){let i=d.VALID_AUGMENTATION_PATTERN.test(o);if(!i&&!t&&d.RESERVED_WORDS.has(o.toLowerCase())){let n=new g;n.ruleType=this.ruleName,n.severity="Error",n.entityName=o,n.message=`Entity name '${o}' is a reserved word and cannot be used.`,n.suggestion="Choose a different name that doesn't conflict with Kanonak reserved words.",r.push(n);continue}if(!i&&!d.VALID_NAME_PATTERN.test(o)){let n;/^\d/.test(o)?n="Entity names must start with a letter, not a number.":o.includes(" ")?n="Entity names cannot contain spaces. Use camelCase or underscores instead.":n="Entity names must start with a letter and contain only letters, numbers, and underscores.";let c=new g;c.ruleType=this.ruleName,c.severity="Error",c.entityName=o,c.message=`Invalid entity name '${o}'. ${n}`,c.suggestion=n,r.push(c)}a&&typeof a=="object"&&!Array.isArray(a)&&this.validatePropertyNames(o,a,r)}return r}validatePropertyNames(e,r,t){for(let o of Object.keys(r))if(!d.VALID_PROPERTIES.has(o)&&!d.VALID_PROPERTY_NAME_PATTERN.test(o)){let a=new g;a.ruleType=this.ruleName,a.severity="Warning",a.entityName=e,a.propertyName=o,a.message=`Property name '${o}' in entity '${e}' doesn't follow naming conventions.`,a.suggestion="Property names should start with a letter and contain only letters, numbers, and underscores.",t.push(a)}}};var O=class d{static XSD_TYPES=new Set(["string","integer","int","long","short","byte","decimal","float","double","boolean","bool","datetime","date","time","duration","anyuri","anysimpletype","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte","base64binary","hexbinary"]);ruleName="PropertyTypeSpecificity";validate(e){let r=[];if(e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-"))return r;let t=this.isPropertyDefinedAsClass(e);for(let[o,a]of Object.entries(e.body))if(a&&typeof a=="object"&&!Array.isArray(a)){let i=a,n=i.type;if(n){let c=[];if(Array.isArray(n))for(let s of n){let l=s?.toString();l&&l==="Property"&&!t&&c.push(l)}else{let s=n?.toString();s&&s==="Property"&&!t&&c.push(s)}for(let s of c){let l=this.getPropertyValue(i,"range"),p=this.determinePropertyType(l),y=new g;y.ruleType=this.ruleName,y.severity="Error",y.entityName=o,y.propertyName="type",y.actualValue=s,y.expectedValue=p,y.message=`Invalid property type '${s}'. Use '${p}' instead.`,y.suggestion="Properties should specify their type: DatatypeProperty for data values, ObjectProperty for relationships.",r.push(y)}}}return r}determinePropertyType(e){return!e||e.trim().length===0?"DatatypeProperty or ObjectProperty":d.XSD_TYPES.has(e.toLowerCase())?"DatatypeProperty":/^[A-Z]/.test(e)?"ObjectProperty":"DatatypeProperty or ObjectProperty"}getPropertyValue(e,r){let t=e[r];return t?t.toString():null}isPropertyDefinedAsClass(e){let r=e.body.Property;if(r&&typeof r=="object"&&!Array.isArray(r)){let o=r.type;if(o){let a=o.toString();return a==="Class"||a.endsWith(".Class")}}return!1}};var w=class{get ruleName(){return"SubjectKanonakTypeRequired"}validate(e){let r=[];for(let[t,o]of Object.entries(e.body)){if(typeof o!="object"||o===null||Array.isArray(o)||t.includes("."))continue;let a=o,i="type"in a,n=a.type?.toString().trim();if(!i||!n){let c=new g;c.ruleType=this.ruleName,c.severity="Error",c.entityName=t,c.propertyName="type",c.message=`Subject Kanonak '${t}' must have a 'type' property.`,c.suggestion=`Add a type statement like:
2
- type: Scene
3
-
4
- Only embedded objects can infer type from their parent property's range. Subject Kanonaks (top-level entities) must explicitly declare their type.`,c.expectedValue="A valid class name (Scene, Character, Story, etc.)",r.push(c)}}return r}};var j=class{get ruleName(){return"EmbeddedKanonakType"}async validateAsync(e,r){let t=[],o=new V(r),a=await this.buildPropertyRangeMap(e,o);for(let[i,n]of Object.entries(e.body))typeof n=="object"&&n!==null&&!Array.isArray(n)&&await this.checkEmbeddedTypes(i,n,void 0,a,o,e,t,0);return t}pickRange(e,r,t){if(e.length===0)return;if(e.length===1)return e[0].range;let o=r.indexOf(".");if(o>0){let a=r.substring(0,o),i=e.find(n=>n.declaringAlias===a);if(i)return i.range}if(t){let a=this.localName(t),i=e.find(n=>this.localName(n.domain)===a);if(i)return i.range}return e[0].range}async checkEmbeddedTypes(e,r,t,o,a,i,n,c){if(c>0){let l=r.type;if(l!=null){let p=await this.validateEmbeddedType(e,String(l),t,a,i);p&&n.push(p)}}let s=r.type!==void 0&&r.type!==null?String(r.type):void 0;for(let[l,p]of Object.entries(r)){let y=this.localName(l),m=o.get(y),f=(m!==void 0?this.pickRange(m,l,s):void 0)??t;if(typeof p=="object"&&p!==null)if(Array.isArray(p))for(let b=0;b<p.length;b++){let h=p[b];typeof h=="object"&&h!==null&&!Array.isArray(h)&&await this.checkEmbeddedTypes(`${e}.${l}[${b}]`,h,f,o,a,i,n,c+1)}else await this.checkEmbeddedTypes(`${e}.${l}`,p,f,o,a,i,n,c+1)}}async validateEmbeddedType(e,r,t,o,a){if(r.length===0||!t)return null;let i=this.localName(r),n=this.localName(t);if(n==="Resource"||n==="Class")return null;let c=e.split(".")[0];if(i===n){let l=new g;return l.ruleType=this.ruleName,l.severity="Warning",l.entityName=c,l.propertyName=e,l.actualValue=r,l.expectedValue=t,l.message=`Embedded object at '${e}' declares 'type: ${r}', which equals the parent property's range '${t}'. The declaration is redundant \u2014 the type is already inferred from the property's range.`,l.suggestion=`Remove the 'type: ${r}' line, or keep it if explicitness is preferred over concision.`,l}if(await o.isSubclassOfAsync(r,t,a)||(i!==r||n!==t)&&await o.isSubclassOfAsync(i,n,a))return null;let s=new g;return s.ruleType=this.ruleName,s.severity="Error",s.entityName=c,s.propertyName=e,s.actualValue=r,s.expectedValue=t,s.message=`Embedded object at '${e}' has 'type: ${r}', which is not a subclass of the parent property's range '${t}'.`,s.suggestion=`Either remove the 'type: ${r}' line (so the type is inferred from the property's range '${t}'), or add 'subClassOf: ${t}' to the '${r}' class definition so the relationship holds.`,s}localName(e){let r=e.lastIndexOf(".");return r<0||r===e.length-1?e:e.substring(r+1)}async buildPropertyRangeMap(e,r){let t=new Map,o=await r.buildEntityIndexAsync(e),a=new Map;for(let[i,n]of o){let c=n.entity.type;if(c==null)continue;let s=String(c),l=this.localName(s);if(!(l==="Property"||l==="DatatypeProperty"||l==="ObjectProperty"||l==="AnnotationProperty"))continue;let y=n.entity.range;if(y==null)continue;let m=String(y);if(m.length===0)continue;let u=n.entity.domain,f=u!=null?String(u):"",b=n.uri.toString(),h=a.get(b),k=i.includes(".");(!h||k&&!h.entityName.includes("."))&&a.set(b,{entityName:i,domain:f,range:m})}for(let i of a.values()){let n=this.localName(i.entityName),c=i.entityName.indexOf("."),s=c>0?i.entityName.substring(0,c):void 0,l=t.get(n)??[];l.push({domain:i.domain,range:i.range,declaringAlias:s}),t.set(n,l)}return t}};var E=class{ruleName="ImportExistence";async validateAsync(e,r){let t=[];if(!e.metadata?.imports)return t;let o=await r.getAllDocumentsAsync();for(let[a,i]of Object.entries(e.metadata.imports))for(let n of i)if(!await r.getHighestCompatibleVersionAsync(a,n)){let s=await this.determineImportErrorAsync(r,a,n,o),l=new g;l.ruleType=this.ruleName,l.severity="Error",l.message=s.message,l.suggestion=s.suggestion,l.entityName=`Import: ${a}/${n.packageName}`,l.actualValue=n.toString(),l.expectedValue=s.expectedValue,t.push(l)}return t}async determineImportErrorAsync(e,r,t,o){let a=await e.getDocumentsByNamespaceAsync(r,t.packageName);if(a.length===0){let s=o.filter(m=>m.metadata.namespace_?.publisher===r).map(m=>m.metadata.namespace_.package_).filter((m,u,f)=>f.indexOf(m)===u),l=this.findSimilarPackages(t.packageName,s),p=`Import '${r}/${t.package_}' not found - package does not exist`,y=l.length>0?`Did you mean: ${l.slice(0,3).join(", ")}?`:s.length>0?`Available packages in ${r}: ${s.slice(0,5).join(", ")}`:`No packages found for publisher '${r}'. Verify the publisher name is correct.`;return{message:p,suggestion:y,expectedValue:"Existing package"}}let n=a.filter(s=>s.metadata.namespace_?.version).map(s=>s.metadata.namespace_.version.toString()).sort().join(", "),c=this.getAcceptableVersionRange(t);return{message:`Import '${r}/${t.toString()}' version mismatch - no compatible version found`,suggestion:`Available versions: ${n}. Required: ${c}`,expectedValue:c}}getAcceptableVersionRange(e){switch(e.versionOperator){case 0:return`exactly ${e.version.major}.${e.version.minor}.${e.version.patch}`;case 1:return`${e.version.major}.${e.version.minor}.${e.version.patch} to ${e.version.major}.${e.version.minor}.x`;case 2:return e.version.major===0?`0.${e.version.minor}.x`:`${e.version.major}.x.x`;case 3:return`any version >= ${e.version.major}.${e.version.minor}.${e.version.patch}`;default:return e.toString()}}findSimilarPackages(e,r){if(r.length===0)return[];let t=r.filter(i=>i.toLowerCase().includes(e.toLowerCase())||e.toLowerCase().includes(i.toLowerCase()));if(t.length>0)return t.sort((i,n)=>i.length-n.length);let o=r.map(i=>({package:i,distance:this.levenshteinDistance(e.toLowerCase(),i.toLowerCase())})).sort((i,n)=>i.distance-n.distance),a=Math.max(3,Math.floor(e.length*.4));return o.filter(i=>i.distance<=a).map(i=>i.package)}levenshteinDistance(e,r){if(!e||e.length===0)return r?.length??0;if(!r||r.length===0)return e.length;let t=e.length,o=r.length,a=Array(t+1).fill(null).map(()=>Array(o+1).fill(0));for(let i=0;i<=t;i++)a[i][0]=i;for(let i=0;i<=o;i++)a[0][i]=i;for(let i=1;i<=t;i++)for(let n=1;n<=o;n++){let c=e[i-1]===r[n-1]?0:1;a[i][n]=Math.min(Math.min(a[i-1][n]+1,a[i][n-1]+1),a[i-1][n-1]+c)}return a[t][o]}};var N=class{ruleName="UnresolvedReference";async validateAsync(e,r){let t=[],o=new V(r),a=await o.buildEntityIndexAsync(e),i=new Set;for(let[n,c]of a.entries()){let s=c.entity.type;if(s){let l=s.toString();(l==="ObjectProperty"||l.endsWith(".ObjectProperty"))&&i.add(n)}}for(let[n,c]of Object.entries(e.body)){if(!c||typeof c!="object"||Array.isArray(c))continue;let s=c,l=this.getPropertyValue(s,"type");if(!(!l||l==="Class"||l.endsWith("Property")||l==="AnnotationProperty"))for(let[p,y]of Object.entries(s))p==="type"||p==="label"||p==="comment"||!(i.has(p)||Array.from(i).some(u=>u.endsWith(`.${p}`)))||await this.validateReferenceValue(n,p,y,e,o,t)}return t}async validateReferenceValue(e,r,t,o,a,i){if(t!=null){if(typeof t=="string")await a.resolveEntityAsync(t,o)||i.push(this.createUnresolvedReferenceError(e,r,t));else if(Array.isArray(t))for(let n=0;n<t.length;n++){let c=t[n];typeof c=="string"&&(await a.resolveEntityAsync(c,o)||i.push(this.createUnresolvedReferenceError(e,`${r}[${n}]`,c)))}}}createUnresolvedReferenceError(e,r,t){let o=`The entity '${t}' cannot be found in the current document or any imported namespaces.
5
-
6
- Possible solutions:
7
- \u2022 Add import if the entity is defined in another namespace:
8
- kanonak namespace add-import <publisher>/<package>@<version>
9
- \u2022 Check for typos in the reference name '${t}'
10
- \u2022 Define '${t}' in the current namespace or an appropriate namespace
11
- \u2022 Use 'kanonak search type ${t} --include-imports' to locate the entity`,a=new g;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e,a.propertyName=r,a.actualValue=t,a.message=`Reference to '${t}' could not be resolved`,a.suggestion=o,a.expectedValue="A valid entity reference that exists in the current document or imported namespaces",a}getPropertyValue(e,r){let t=e[r];return t?t.toString():null}};var $=class{ruleName="TypeAmbiguity";async validateAsync(e,r){let t=[],o=new Map,a=[];if(e.metadata?.imports)for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let s=await r.getHighestCompatibleVersionAsync(i,c);if(s){a.push({doc:s,import:c,publisher:i});let l=await this.getTransitiveImportsAsync(r,s,new Set);a.push(...l.map(p=>({doc:p,import:null,publisher:i})))}}for(let{doc:i,import:n}of a){let c=i.metadata?.namespace_?.toString()??"unknown";for(let s of Object.keys(i.body))o.has(s)||o.set(s,[]),o.get(s).push({namespace:c,import:n})}for(let[i,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)){let c=n;this.checkAmbiguousReference(c,"type",o,i,t),this.checkAmbiguousReference(c,"subClassOf",o,i,t),this.checkAmbiguousReference(c,"subPropertyOf",o,i,t),this.checkAmbiguousReference(c,"domain",o,i,t),this.checkAmbiguousReference(c,"range",o,i,t)}return t}checkAmbiguousReference(e,r,t,o,a){let i=e[r];if(!i)return;let n=P(i);for(let c of n){if(c.includes("."))continue;let s=t.get(c);if(s&&s.length>1){let l=s.map(u=>u.namespace).join(", "),p=[];for(let{namespace:u,import:f}of s)if(f?.alias)p.push(`${f.alias}.${c}`);else{let b=u.split("/"),k=b[b.length-1]?.split("@")[0]??"alias";p.push(`${k}.${c}`)}let y=p.length>0?`Use one of: ${p.join(", ")}`:"Consider adding namespace aliases to your imports",m=new g;m.ruleType=this.ruleName,m.severity="Warning",m.entityName=o,m.propertyName=r,m.actualValue=c,m.message=`Type '${c}' is ambiguous. It's defined in: ${l}`,m.suggestion=y,a.push(m)}}}async getTransitiveImportsAsync(e,r,t){let o=[],a=r.metadata?.namespace_?.toString()??"";if(t.has(a))return o;if(t.add(a),r.metadata?.imports)for(let[i,n]of Object.entries(r.metadata.imports))for(let c of n){let s=await e.getHighestCompatibleVersionAsync(i,c);if(s){o.push(s);let l=await this.getTransitiveImportsAsync(e,s,t);o.push(...l)}}return o}};var S=class{ruleName="ClassHierarchyCycle";async validateAsync(e,r){let t=[],o=new Map,a=new Set;await this.buildClassHierarchy(e,r,o,a);for(let[i,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)){let c=n,s=c.type,l=c.subClassOf;if(s?.toString()==="Class"&&l){let p=i,y=this.detectCycle(p,o);if(y){let m=y.join(" \u2192 "),u=new g;u.ruleType=this.ruleName,u.severity="Error",u.message=`Circular class hierarchy detected: ${m}`,u.suggestion="Remove the circular dependency by breaking one of the subClassOf relationships",u.entityName=p,u.propertyName="subClassOf",u.actualValue=m,t.push(u);break}}}return t}async buildClassHierarchy(e,r,t,o){let a=e.metadata?.namespace_?.toString()??"";if(!(a&&o.has(a))){a&&o.add(a);for(let[i,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)){let c=n,s=c.type,l=c.subClassOf;if(s?.toString()==="Class"&&l){let p=P(l);p.length>0&&t.set(i,p)}}if(e.metadata?.imports)for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let s=await r.getHighestCompatibleVersionAsync(i,c);s&&await this.buildClassHierarchy(s,r,t,o)}}}detectCycle(e,r){let t=[],o=new Set;return this.detectCycleRecursive(e,r,t,o)}detectCycleRecursive(e,r,t,o){if(t.includes(e)){let i=t.indexOf(e),n=t.slice(i);return n.push(e),n}if(o.has(e))return null;t.push(e),o.add(e);let a=r.get(e);if(a)for(let i of a){let n=this.detectCycleRecursive(i,r,t,o);if(n)return n}return t.pop(),null}};var C=class{ruleName="PropertyHierarchyCycle";async validateAsync(e,r){let t=[],o=new Map,a=new Set;await this.buildPropertyHierarchy(e,r,o,a);for(let[i,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)&&n.subPropertyOf){let l=i,p=this.detectCycle(l,o);if(p){let y=p.join(" \u2192 "),m=new g;m.ruleType=this.ruleName,m.severity="Error",m.message=`Circular property hierarchy detected: ${y}`,m.suggestion="Remove the circular dependency by breaking one of the subPropertyOf relationships",m.entityName=l,m.propertyName="subPropertyOf",m.actualValue=y,t.push(m);break}}return t}async buildPropertyHierarchy(e,r,t,o){let a=e.metadata?.namespace_?.toString()??"";if(!(a&&o.has(a))){a&&o.add(a);for(let[i,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)){let c=n,s=c.type;if(s){let l=s.toString();if(l==="DatatypeProperty"||l==="ObjectProperty"||l==="AnnotationProperty"){let p=c.subPropertyOf;if(p){let y=P(p);y.length>0&&t.set(i,y)}}}}if(e.metadata?.imports)for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let s=await r.getHighestCompatibleVersionAsync(i,c);s&&await this.buildPropertyHierarchy(s,r,t,o)}}}detectCycle(e,r){let t=[],o=new Set;return this.detectCycleRecursive(e,r,t,o)}detectCycleRecursive(e,r,t,o){if(t.includes(e)){let i=t.indexOf(e),n=t.slice(i);return n.push(e),n}if(o.has(e))return null;t.push(e),o.add(e);let a=r.get(e);if(a)for(let i of a){let n=this.detectCycleRecursive(i,r,t,o);if(n)return n}return t.pop(),null}};var K=class{get ruleName(){return"PropertyRangeRequired"}async validateAsync(e,r){let t=[];for(let[o,a]of Object.entries(e.body)){if(typeof a!="object"||a===null||Array.isArray(a))continue;let i=a,n=i.type?.toString();if(n==="DatatypeProperty"||n==="ObjectProperty"||n?.endsWith(".DatatypeProperty")||n?.endsWith(".ObjectProperty")){let c="range"in i,s=i.range?.toString().trim();if(!c||!s){let l=new g;l.ruleType=this.ruleName,l.severity="Error",l.entityName=o,l.propertyName="range",l.message=`Property '${o}' must have a 'range' defined.`,l.suggestion=n==="DatatypeProperty"?"Add a range like: range: string (or integer, boolean, etc.)":"Add a range like: range: ClassName (the class this property expects)",l.expectedValue=n==="DatatypeProperty"?"A datatype (string, integer, boolean, decimal, etc.)":"A class name (Character, Scene, Story, etc.)",t.push(l)}}}return t}};var T=class{builtInClasses=new Set(["Resource","Class","Datatype","Literal","Thing","Nothing","Property","DatatypeProperty","ObjectProperty","AnnotationProperty","FunctionalProperty","InverseFunctionalProperty","TransitiveProperty","SymmetricProperty"]);get ruleName(){return"SubClassOfReference"}isClassLikeType(e){return e?e==="Class"||e.endsWith(".Class")||e==="Datatype"||e.endsWith(".Datatype"):!1}async validateAsync(e,r){let t=[],o=new Set;for(let[a,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let c=i.type?.toString();this.isClassLikeType(c)&&o.add(a)}for(let[a,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let c=P(i.subClassOf);for(let s=0;s<c.length;s++){let l=c[s];if(this.builtInClasses.has(l)||o.has(l))continue;if(!await this.isClassAvailableInImports(e,r,l)){let y=c.length>1?`[${s}]`:"",m=new g;m.ruleType=this.ruleName,m.severity="Error",m.message=`Class '${l}' referenced in subClassOf${y} is not defined or imported`,m.suggestion=`Define '${l}' as a Class, or import a namespace that contains it`,m.entityName=a,m.propertyName="subClassOf",m.actualValue=l,m.expectedValue="Defined or imported class",t.push(m)}}}return t}async isClassAvailableInImports(e,r,t){if(!e.metadata.imports)return!1;let o=null,a=t;if(t.includes(".")){let i=t.split(".",2);o=i[0],a=i[1]}for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){if(o!==null&&c.alias!==o)continue;let s=await r.getHighestCompatibleVersionAsync(i,c);if(s){let l=o!==null?a:t,p=s.body[l];if(p&&typeof p=="object"&&!Array.isArray(p)){let u=p.type?.toString();if(this.isClassLikeType(u))return!0}let y=new Set;if(await this.isClassAvailableInImportsRecursive(s,r,l,y))return!0}}return!1}async isClassAvailableInImportsRecursive(e,r,t,o){let a=e.metadata.namespace_?.toString()??"";if(a&&o.has(a)||(a&&o.add(a),!e.metadata.imports))return!1;for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let s=await r.getHighestCompatibleVersionAsync(i,c);if(s){let l=s.body[t];if(l&&typeof l=="object"&&!Array.isArray(l)){let y=l.type?.toString();if(this.isClassLikeType(y))return!0}if(await this.isClassAvailableInImportsRecursive(s,r,t,o))return!0}}return!1}};var x=class{builtInProperties=new Set(["type","label","comment","domain","range","subPropertyOf","subClassOf","inverseOf","sameAs","seeAlso","isDefinedBy","functional","required"]);get ruleName(){return"SubPropertyOfReference"}async validateAsync(e,r){let t=[],o=new Set;for(let[a,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let c=i.type?.toString();(c==="DatatypeProperty"||c==="ObjectProperty"||c==="AnnotationProperty")&&o.add(a)}for(let[a,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let c=P(i.subPropertyOf);for(let s=0;s<c.length;s++){let l=c[s];if(this.builtInProperties.has(l)||o.has(l))continue;if(!await this.isPropertyAvailableInImports(e,r,l)){let y=c.length>1?`[${s}]`:"",m=new g;m.ruleType=this.ruleName,m.severity="Error",m.message=`Property '${l}' referenced in subPropertyOf${y} is not defined or imported`,m.suggestion=`Define '${l}' as a DatatypeProperty or ObjectProperty, or import a namespace that contains it`,m.entityName=a,m.propertyName="subPropertyOf",m.actualValue=l,m.expectedValue="Defined or imported property",t.push(m)}}}return t}async isPropertyAvailableInImports(e,r,t){if(!e.metadata.imports)return!1;let o=null,a=t;if(t.includes(".")){let i=t.split(".",2);o=i[0],a=i[1]}for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){if(o!==null&&c.alias!==o)continue;let s=await r.getHighestCompatibleVersionAsync(i,c);if(s){let l=o!==null?a:t,p=s.body[l];if(p&&typeof p=="object"&&!Array.isArray(p)){let u=p.type?.toString();if(u==="DatatypeProperty"||u==="ObjectProperty"||u==="AnnotationProperty")return!0}let y=new Set;if(await this.isPropertyAvailableInImportsRecursive(s,r,l,y))return!0}}return!1}async isPropertyAvailableInImportsRecursive(e,r,t,o){let a=e.metadata.namespace_?.toString()??"";if(a&&o.has(a)||(a&&o.add(a),!e.metadata.imports))return!1;for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let s=await r.getHighestCompatibleVersionAsync(i,c);if(s){let l=s.body[t];if(l&&typeof l=="object"&&!Array.isArray(l)){let y=l.type?.toString();if(y==="DatatypeProperty"||y==="ObjectProperty"||y==="AnnotationProperty")return!0}if(await this.isPropertyAvailableInImportsRecursive(s,r,t,o))return!0}}return!1}};var M=class{get ruleName(){return"NamespaceImportCycle"}async validateAsync(e,r){let t=[],o=e.metadata.namespace_?.toString();if(!o)return t;let a=new Map,i=new Set;await this.buildImportGraph(e,r,a,i);let n=this.detectCycle(o,a);if(n){let c=n.join(" \u2192 "),s=new g;s.ruleType=this.ruleName,s.severity="Error",s.message=`Circular namespace import detected: ${c}`,s.suggestion="Remove one of the imports to break the circular dependency. Circular dependencies prevent proper package resolution.",s.entityName="imports",s.propertyName="imports",s.actualValue=c,t.push(s)}return t}async buildImportGraph(e,r,t,o){let a=e.metadata.namespace_?.toString()??"";if(!(!a||o.has(a))&&(o.add(a),e.metadata.imports)){let i=[];for(let[n,c]of Object.entries(e.metadata.imports))for(let s of c){let l=`${n}/${s.packageName}@${s.version}`;i.push(l);let p=await r.getHighestCompatibleVersionAsync(n,s);p&&await this.buildImportGraph(p,r,t,o)}i.length>0&&t.set(a,i)}}detectCycle(e,r){let t=[],o=new Set;return this.detectCycleRecursive(e,r,t,o)}detectCycleRecursive(e,r,t,o){let a=t.indexOf(e);if(a>=0){let n=t.slice(a);return n.push(e),n}if(o.has(e))return null;t.push(e),o.add(e);let i=r.get(e);if(i)for(let n of i){let c=this.detectCycleRecursive(n,r,t,o);if(c)return c}return t.pop(),null}};var W=class{metadataKeys=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","inverseOf","transitive","symmetric","functional","inverseFunctional"]);get ruleName(){return"InstancePropertyReference"}async validateAsync(e,r,t){let o=[],a=new Set,i=t?await this.closurePropertyNamesViaCache(e,t):void 0,n=t?await this.aliasClosurePropertyNamesViaCache(e,t):void 0;for(let[c,s]of Object.entries(e.body))if(typeof s=="object"&&s!==null&&!Array.isArray(s)){let p=s.type?.toString();this.isPropertyType(p)&&a.add(c)}for(let[c,s]of Object.entries(e.body))if(typeof s=="object"&&s!==null&&!Array.isArray(s)){let l=s,p=l.type?.toString();if(this.isPropertyType(p)||this.isClassType(p))continue;for(let[y,m]of Object.entries(l)){if(!y||this.metadataKeys.has(y))continue;let u=y,f=null;if(y.includes(".")){let h=y.lastIndexOf(".");f=y.substring(0,h),u=y.substring(h+1)}if(a.has(u))continue;if(!await this.isPropertyAvailable(e,r,u,f,i,n)){let h=new g;h.ruleType=this.ruleName,h.severity="Error",h.message=`Property '${y}' is not defined or imported`,h.suggestion=f?`The property '${u}' is not found in the imported namespace with alias '${f}'.
12
- 1. Verify the namespace is imported with the correct alias
13
- 2. Check if the property name is spelled correctly
14
- 3. Ensure the imported namespace version contains this property`:`The property '${y}' is not defined in this namespace or any imported namespace.
15
- 1. Define '${y}' as an ObjectProperty or DatatypeProperty in this namespace, OR
16
- 2. Import the namespace that contains '${y}', OR
17
- 3. Use a qualified reference like 'alias.${y}' if already imported with an alias`,h.entityName=c,h.propertyName=y,h.actualValue=m?.toString(),h.expectedValue="A defined or imported property",o.push(h)}}}return o}isPropertyType(e){return e?e==="ObjectProperty"||e==="DatatypeProperty"||e==="AnnotationProperty"||e==="Property"||e.endsWith(".ObjectProperty")||e.endsWith(".DatatypeProperty")||e.endsWith(".AnnotationProperty")||e.endsWith(".Property"):!1}isClassType(e){return e?e==="Class"||e.endsWith(".Class"):!1}async isPropertyAvailable(e,r,t,o,a,i){if(a!==void 0&&i!==void 0){if(o===null)return a.has(t);let n=i.get(o);return n?n.has(t):!1}return await this.isPropertyAvailableInImports(e,r,t,o)}async closurePropertyNamesViaCache(e,r){let t=new Set,o=ge(e);if(!o)return t;let a=await r.getImportClosure(o);for(let i of a)if(i!==o)for(let n of await r.getPropertyNames(i))t.add(n);return t}async aliasClosurePropertyNamesViaCache(e,r){let t=new Map;if(!e.metadata.imports)return t;for(let[o,a]of Object.entries(e.metadata.imports))for(let i of a){if(!i.alias)continue;let n=await r.repository.getHighestCompatibleVersionAsync(o,i);if(!n)continue;let c=ge(n);if(!c)continue;let s=await r.getImportClosure(c),l=t.get(i.alias)??new Set;for(let p of s)for(let y of await r.getPropertyNames(p))l.add(y);t.set(i.alias,l)}return t}async isPropertyAvailableInImports(e,r,t,o){if(!e.metadata.imports)return!1;for(let[a,i]of Object.entries(e.metadata.imports))for(let n of i){if(o!==null&&n.alias!==o)continue;let c=await r.getHighestCompatibleVersionAsync(a,n);if(c){let s=c.body[t];if(s&&typeof s=="object"&&!Array.isArray(s)){let y=s.type?.toString();if(this.isPropertyType(y))return!0}let l=new Set;if(await this.isPropertyAvailableInImportsRecursive(c,r,t,l))return!0}}return!1}async isPropertyAvailableInImportsRecursive(e,r,t,o){let a=e.metadata.namespace_?.toString()??"";if(a&&o.has(a)||(a&&o.add(a),!e.metadata.imports))return!1;for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let s=await r.getHighestCompatibleVersionAsync(i,c);if(s){let l=s.body[t];if(l&&typeof l=="object"&&!Array.isArray(l)){let y=l.type?.toString();if(this.isPropertyType(y))return!0}if(await this.isPropertyAvailableInImportsRecursive(s,r,t,o))return!0}}return!1}};function ge(d){let e=d.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${A(e.version)}`}var L=class{metadataKeys=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","inverseOf","transitive","symmetric","functional","inverseFunctional"]);get ruleName(){return"DefinitionPropertyReference"}async validateAsync(e,r){let t=[],o=new Set;for(let[a,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let c=i.type?.toString();this.isPropertyType(c)&&o.add(a)}for(let[a,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let n=i,c=n.type?.toString();if(!this.isPropertyType(c)&&!this.isClassType(c))continue;for(let[s,l]of Object.entries(n)){if(!s||this.metadataKeys.has(s))continue;let p=s,y=null;if(s.includes(".")){let u=s.lastIndexOf(".");y=s.substring(0,u),p=s.substring(u+1)}if(o.has(p))continue;if(!await this.isPropertyAvailableInImports(e,r,p,y)){let u=this.isClassType(c)?"class":"property",f=new g;f.ruleType=this.ruleName,f.severity="Error",f.message=`Property '${s}' used on ${u} '${a}' is not defined or imported`,f.suggestion=y?`The property '${p}' is not found in the imported namespace with alias '${y}'.
18
- 1. Verify the namespace is imported with the correct alias
19
- 2. Check if the property name is spelled correctly
20
- 3. Ensure the imported namespace version contains this property`:`The property '${s}' is not defined in this namespace or any imported namespace.
21
- 1. Define '${s}' as an ObjectProperty or DatatypeProperty in this namespace, OR
22
- 2. Import the namespace that contains '${s}', OR
23
- 3. Use a qualified reference like 'alias.${s}' if already imported with an alias`,f.entityName=a,f.propertyName=s,f.actualValue=l?.toString(),f.expectedValue="A defined or imported property",t.push(f)}}}return t}isPropertyType(e){return e?e==="ObjectProperty"||e==="DatatypeProperty"||e==="AnnotationProperty"||e==="Property"||e.endsWith(".ObjectProperty")||e.endsWith(".DatatypeProperty")||e.endsWith(".AnnotationProperty")||e.endsWith(".Property"):!1}isClassType(e){return e?e==="Class"||e.endsWith(".Class"):!1}async isPropertyAvailableInImports(e,r,t,o){if(!e.metadata.imports)return!1;for(let[a,i]of Object.entries(e.metadata.imports))for(let n of i){if(o!==null&&n.alias!==o)continue;let c=await r.getHighestCompatibleVersionAsync(a,n);if(c){let s=c.body[t];if(s&&typeof s=="object"&&!Array.isArray(s)){let y=s.type?.toString();if(this.isPropertyType(y))return!0}let l=new Set;if(await this.isPropertyAvailableInImportsRecursive(c,r,t,l))return!0}}return!1}async isPropertyAvailableInImportsRecursive(e,r,t,o){let a=e.metadata.namespace_?.toString()??"";if(a&&o.has(a)||(a&&o.add(a),!e.metadata.imports))return!1;for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let s=await r.getHighestCompatibleVersionAsync(i,c);if(s){let l=s.body[t];if(l&&typeof l=="object"&&!Array.isArray(l)){let y=l.type?.toString();if(this.isPropertyType(y))return!0}if(await this.isPropertyAvailableInImportsRecursive(s,r,t,o))return!0}}return!1}};var _=class{xsdTypes=new Set(["string","integer","boolean","decimal","float","double","date","dateTime","time","duration","anyURI","base64Binary","hexBinary","long","int","short","byte","unsignedLong","unsignedInt","unsignedShort","unsignedByte","positiveInteger","nonPositiveInteger","negativeInteger","nonNegativeInteger","normalizedString","token","language","Name","NCName","ENTITY","ENTITIES","IDREF","IDREFS","NMTOKEN","NMTOKENS"]);get ruleName(){return"XsdImport"}async validateAsync(e,r){let t=[],o=new Set,a=[];for(let[i,n]of Object.entries(e.body))if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let c=n,s=!1,l=c.type;if(Array.isArray(l)){for(let p of l)if(p?.toString()==="DatatypeProperty"){s=!0;break}}else l?.toString()==="DatatypeProperty"&&(s=!0);if(s){a.push(i);let p=this.getPropertyValue(c,"range");p&&this.xsdTypes.has(p)&&o.add(p)}}if(o.size>0&&!await this.checkXsdImportAsync(e.metadata,r)){let n=Array.from(o).sort().join(", "),c=a.sort().join(", "),s=new g;s.ruleType=this.ruleName,s.severity="Error",s.message=`XSD namespace not imported but XSD types are used: ${n}`,s.suggestion=`Add an XSD import to the imports section. The core XSD types package is 'core-xsd' from publisher 'kanonak.org'. Used by properties: ${c}`,s.entityName="imports",t.push(s)}return t}async checkXsdImportAsync(e,r,t=new Set){if(!e?.imports)return!1;let o=e.namespace_?.toString()??"";if(o&&t.has(o))return!1;o&&t.add(o);for(let[,a]of Object.entries(e.imports))for(let i of a)if(i.packageName==="xsd"||i.packageName.toLowerCase().endsWith("-xsd"))return!0;for(let[a,i]of Object.entries(e.imports))for(let n of i){let c=await r.getHighestCompatibleVersionAsync(a,n);if(c?.metadata&&await this.checkXsdImportAsync(c.metadata,r,t))return!0}return!1}getPropertyValue(e,r){return e[r]?.toString()}};var H=class{get ruleName(){return"AmbiguousReference"}async validateAsync(e,r){let t=[],o=await this.buildEntitySourceMapAsync(e,r),a=await this.buildDatatypePropertyNamesAsync(e,r);for(let[i,n]of Object.entries(e.body))typeof n=="object"&&n!==null&&!Array.isArray(n)&&this.validateEntityReferences(i,n,o,a,e,t);return t}async buildEntitySourceMapAsync(e,r){let t=new Map,o=new Set;for(let a of Object.keys(e.body)){let i=e.metadata.namespace_?.toString()??"";t.has(a)||t.set(a,[]),t.get(a).push(`(local:${i})`)}if(e.metadata.imports)for(let[a,i]of Object.entries(e.metadata.imports))for(let n of i){let c=await r.getHighestCompatibleVersionAsync(a,n);c&&await this.collectEntitiesRecursivelyAsync(c,t,o,r)}return t}async collectEntitiesRecursivelyAsync(e,r,t,o){let a=e.metadata.namespace_?.toString()??"";if(!t.has(a)){t.add(a);for(let i of Object.keys(e.body)){r.has(i)||r.set(i,[]);let n=r.get(i);n.includes(a)||n.push(a)}if(e.metadata.imports)for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let s=await o.getHighestCompatibleVersionAsync(i,c);s&&await this.collectEntitiesRecursivelyAsync(s,r,t,o)}}}async buildDatatypePropertyNamesAsync(e,r){let t=new Set,o=new Set;if(await this.collectDatatypePropertiesAsync(e,t,o,r),e.metadata.imports)for(let[a,i]of Object.entries(e.metadata.imports))for(let n of i){let c=await r.getHighestCompatibleVersionAsync(a,n);c&&await this.collectDatatypePropertiesAsync(c,t,o,r)}return t}async collectDatatypePropertiesAsync(e,r,t,o){let a=e.metadata.namespace_?.toString()??"";if(!t.has(a)){t.add(a);for(let[i,n]of Object.entries(e.body)){if(typeof n!="object"||n===null||Array.isArray(n))continue;let c=n.type;if(typeof c!="string")continue;(c.includes(".")?c.substring(c.lastIndexOf(".")+1):c)==="DatatypeProperty"&&r.add(i)}if(e.metadata.imports)for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let s=await o.getHighestCompatibleVersionAsync(i,c);s&&await this.collectDatatypePropertiesAsync(s,r,t,o)}}}validateEntityReferences(e,r,t,o,a,i){for(let[n,c]of Object.entries(r)){let s=n;if(s&&!s.includes(".")){let l=t.get(s);if(l&&l.length>1&&!l.some(y=>y.startsWith("(local:"))){let y=l.filter(m=>!m.startsWith("(local:"));y.length>1&&i.push(this.createAmbiguityError(e,s,`Property '${s}'`,y,a,!0,s))}}this.validatePropertyValue(e,s,c,t,o,a,i)}}validatePropertyValue(e,r,t,o,a,i,n){if(t==null)return;let c=r&&r.includes(".")?r.substring(r.lastIndexOf(".")+1):r,s=!!c&&a.has(c);if(typeof t=="string"&&!t.includes(".")&&!s){let l=o.get(t);if(l&&l.length>1&&!l.some(y=>y.startsWith("(local:"))){let y=l.filter(m=>!m.startsWith("(local:"));y.length>1&&n.push(this.createAmbiguityError(e,r,`Reference '${t}'`,y,i,!1,t))}}else if(Array.isArray(t))for(let l=0;l<t.length;l++){let p=`${e}.${r}[${l}]`;this.validatePropertyValue(p,r,t[l],o,a,i,n)}else if(typeof t=="object"&&!Array.isArray(t)){let l=r?`${e}.${r}`:e;this.validateEntityReferences(l,t,o,a,i,n)}}createAmbiguityError(e,r,t,o,a,i,n){let c=[];for(let f of o){let b=this.findAliasForNamespace(a,f);if(b){let h=r?.split(".").pop()??r;c.push(`${b}.${h}`)}}let s=c.length>0?`Use one of: ${c.map(f=>`'${f}'`).join(", ")}`:`Add aliases to imports and use qualified names (e.g., 'alias.${r}')`,l=o.map(f=>` \u2022 ${f}`).join(`
24
- `),p=e.split(".")[0],y=e.includes(".")?e:r,m=new g;m.ruleType=this.ruleName,m.severity="Error",m.entityName=p,y&&(m.propertyName=y);let u=n??r;return u&&(m.actualValue=u),m.message=`${t} is ambiguous - defined in multiple imported namespaces`,m.suggestion=`${s}
25
-
26
- Defined in:
27
- ${l}`,m.expectedValue="Unambiguous reference (use namespace alias to disambiguate)",m}findAliasForNamespace(e,r){if(!e.metadata.imports)return null;for(let[t,o]of Object.entries(e.metadata.imports))for(let a of o)if(`${t}/${a.packageName}@${a.version}`===r&&a.alias)return a.alias;return null}};var U=class{builtInClasses=new Set(["Resource","Class","Literal","Thing","Nothing","Property","DatatypeProperty","ObjectProperty","AnnotationProperty"]);primitiveTypes=new Set(["string","integer","int","long","short","byte","decimal","float","double","boolean","bool","dateTime","date","time","duration","anyURI","anySimpleType","nonNegativeInteger","positiveInteger","negativeInteger","nonPositiveInteger","unsignedInt","unsignedLong","unsignedShort","unsignedByte","base64Binary","hexBinary","Literal","Resource"]);get ruleName(){return"PropertyRangeReference"}async validateAsync(e,r){let t=[],o=new Set;for(let[a,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let c=i.type?.toString();this.isValidRangeTargetType(c)&&o.add(a)}for(let[a,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let n=i,c=n.type?.toString();if(c!=="DatatypeProperty"&&c!=="ObjectProperty"&&!c?.endsWith(".DatatypeProperty")&&!c?.endsWith(".ObjectProperty"))continue;let s=n.range;if(!s)continue;let l=[];if(Array.isArray(s))for(let p of s){let y=p?.toString();y&&l.push(y)}else{let p=s?.toString();p&&l.push(p)}if(l.length===0)continue;for(let p of l){if(this.primitiveTypes.has(p)||this.builtInClasses.has(p)||o.has(p))continue;if(!await this.isTypeAvailableInImports(e,r,p)){let m=c?.includes("ObjectProperty")?"ObjectProperty":"DatatypeProperty",u=new g;u.ruleType=this.ruleName,u.severity="Error",u.message=`Property '${a}' has range '${p}' which is not defined or imported`,u.suggestion=m==="ObjectProperty"?`For ObjectProperty:
28
- 1. Define '${p}' as a Class in this namespace, OR
29
- 2. Import the namespace that contains '${p}', OR
30
- 3. Use a qualified reference like 'alias.${p}' if already imported with an alias`:`For DatatypeProperty:
31
- 1. Use a primitive type (string, integer, boolean, dateTime, etc.), OR
32
- 2. If '${p}' should be a class, change property type to ObjectProperty`,u.entityName=a,u.propertyName="range",u.actualValue=p,u.expectedValue=m==="ObjectProperty"?"A defined or imported class name":"A primitive type or defined class",t.push(u)}}}return t}async isTypeAvailableInImports(e,r,t){if(!e.metadata.imports)return!1;let o=null,a=t;if(t.includes(".")){let i=t.split(".",2);o=i[0],a=i[1]}for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){if(o!==null&&c.alias!==o)continue;let s=await r.getHighestCompatibleVersionAsync(i,c);if(s){let l=o!==null?a:t,p=s.body[l];if(p&&typeof p=="object"&&!Array.isArray(p)){let u=p.type?.toString();if(this.isValidRangeTargetType(u))return!0}let y=new Set;if(await this.isTypeAvailableInImportsRecursive(s,r,l,y))return!0}}return!1}async isTypeAvailableInImportsRecursive(e,r,t,o){let a=e.metadata.namespace_?.toString()??"";if(a&&o.has(a)||(a&&o.add(a),!e.metadata.imports))return!1;for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let s=await r.getHighestCompatibleVersionAsync(i,c);if(s){let l=s.body[t];if(l&&typeof l=="object"&&!Array.isArray(l)){let y=l.type?.toString();if(this.isValidRangeTargetType(y))return!0}if(await this.isTypeAvailableInImportsRecursive(s,r,t,o))return!0}}return!1}isValidRangeTargetType(e){return e?e==="Class"||e.endsWith(".Class")||e==="Datatype"||e.endsWith(".Datatype"):!1}};var F=class{xsdTypes=new Set(["string","integer","boolean","decimal","float","double","date","dateTime","time","duration","anyURI","base64Binary","hexBinary","long","int","short","byte","unsignedLong","unsignedInt","unsignedShort","unsignedByte","positiveInteger","nonPositiveInteger","negativeInteger","nonNegativeInteger","normalizedString","token","language","Name","NCName","ENTITY","ENTITIES","IDREF","IDREFS","NMTOKEN","NMTOKENS"]);get ruleName(){return"ObjectPropertyImport"}async validateAsync(e,r){let t=[],o=new Map,a=new V(r);await a.buildEntityIndexAsync(e);for(let[i,n]of Object.entries(e.body))if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let c=n,s=!1,l=c.type;if(Array.isArray(l)){for(let p of l)if(p?.toString()==="ObjectProperty"){s=!0;break}}else l?.toString()==="ObjectProperty"&&(s=!0);if(s){let p=c.range,y=[];if(Array.isArray(p))for(let m of p){let u=m?.toString();u&&y.push(u)}else{let m=p?.toString();m&&y.push(m)}for(let m of y)this.xsdTypes.has(m)||(o.has(m)||o.set(m,[]),o.get(m).push(i))}}for(let[i,n]of o)if(!await a.resolveEntityAsync(i,e))for(let s of n){let l=new g;l.ruleType=this.ruleName,l.severity="Warning",l.message=`ObjectProperty references class '${i}' which may not be imported`,l.suggestion=`Ensure the namespace containing '${i}' is imported, or define '${i}' in this document`,l.entityName=s,l.propertyName="range",l.actualValue=i,t.push(l)}return t}};var B=class{standardProperties=new Set(["type","label","comment","subClassOf","domain","range","subPropertyOf","inverseOf","sameAs","seeAlso","isDefinedBy"]);get ruleName(){return"ObjectPropertyValue"}async validateAsync(e,r){let t=[],o=new V(r),a=new pe(o),i=await o.buildEntityIndexAsync(e),n=await this.buildPropertyMetadataAsync(e,r,o,i);for(let[c,s]of Object.entries(e.body))typeof s=="object"&&s!==null&&!Array.isArray(s)&&await this.scanEntityForObjectProperties(s,c,"",n,o,a,e,t);return t}async scanEntityForObjectProperties(e,r,t,o,a,i,n,c){for(let[s,l]of Object.entries(e)){if(this.standardProperties.has(s))continue;let p,y=await a.resolveEntityAsync(s,n);if(y?.uri){let m=`${y.uri.publisher}/${y.uri.package_}/${y.uri.name}`;p=o.get(m)}if(!p){let m=s,u=s.lastIndexOf(".");u>0&&u<s.length-1&&(m=s.substring(u+1)),p=o.get(m)}if(p&&i.isEffectiveObjectProperty(p.propertyType,p.rangeUri)){let u=t?`${t}.${s}`:s;if(typeof l=="string"&&l.trim().length>0){let f=l.trim();if(f.includes(",")){let h=f.split(",").map(k=>k.trim()).filter(k=>k.length>0);c.push({ruleType:this.ruleName,severity:"Error",message:`Property '${s}' has a comma-separated string value, but ObjectProperty expects a list of references`,suggestion:`Use YAML list format:
33
- ${s}:
34
- - ${h[0]}
35
- ${h.slice(1).map(k=>` - ${k}`).join(`
36
- `)}`,entityName:r,propertyName:s,propertyPath:u,actualValue:f,expectedValue:`A single reference to ${p.range??"an entity"} OR a YAML list`});continue}let b=await a.resolveEntityAsync(f,n);if(b)p.range&&(await this.validateRangeType(b,p.range,a,n)||c.push({ruleType:this.ruleName,severity:"Warning",message:`Property '${s}' expects a ${p.range}, but '${f}' may not be a ${p.range}`,suggestion:`Ensure '${f}' is defined with appropriate type`,entityName:r,propertyName:s,propertyPath:u,actualValue:f,expectedValue:p.range}));else{let h=p.range??"entity";c.push({ruleType:this.ruleName,severity:"Error",message:`Property '${s}' references '${f}' which is not defined or imported`,suggestion:`Define '${f}' or import a namespace that contains it. Expected range: ${h}`,entityName:r,propertyName:s,propertyPath:u,actualValue:f,expectedValue:"Defined or imported entity"})}}else if(typeof l=="object"&&l!==null&&!Array.isArray(l)){let f=t?`${t}.${s}`:s;await this.scanEntityForObjectProperties(l,r,f,o,a,i,n,c)}else if(Array.isArray(l))for(let f=0;f<l.length;f++){let b=l[f];if(typeof b=="string"&&b.trim().length>0){let h=b.trim(),k=await a.resolveEntityAsync(h,n);if(k){if(p.range&&!await this.validateRangeType(k,p.range,a,n)){let G=t?`${t}.${s}[${f}]`:`${s}[${f}]`;c.push({ruleType:this.ruleName,severity:"Warning",message:`Property '${s}' expects a ${p.range}, but '${h}' may not be a ${p.range}`,suggestion:`Ensure '${h}' is defined with appropriate type`,entityName:r,propertyName:`${s}[${f}]`,propertyPath:G,actualValue:h,expectedValue:p.range})}}else{let ne=p.range??"entity",G=t?`${t}.${s}[${f}]`:`${s}[${f}]`;c.push({ruleType:this.ruleName,severity:"Error",message:`Property '${s}' references '${h}' which is not defined or imported`,suggestion:`Define '${h}' or import a namespace that contains it. Expected range: ${ne}`,entityName:r,propertyName:`${s}[${f}]`,propertyPath:G,actualValue:h,expectedValue:"Defined or imported entity"})}}else if(typeof b=="object"&&b!==null&&!Array.isArray(b)){let h=t?`${t}.${s}[${f}]`:`${s}[${f}]`;await this.scanEntityForObjectProperties(b,r,h,o,a,i,n,c)}}}if(typeof l=="object"&&l!==null&&!Array.isArray(l)&&!o.has(s)){let m=t?`${t}.${s}`:s;await this.scanEntityForObjectProperties(l,r,m,o,a,i,n,c)}else if(Array.isArray(l))for(let m=0;m<l.length;m++){let u=l[m];if(typeof u=="object"&&u!==null&&!Array.isArray(u)){let f=t?`${t}.${s}[${m}]`:`${s}[${m}]`;await this.scanEntityForObjectProperties(u,r,f,o,a,i,n,c)}}}}async validateRangeType(e,r,t,o){if(!new Set(["Property","DatatypeProperty","ObjectProperty","AnnotationProperty","Class","Resource"]).has(r))return!0;let i=e.entity.type;if(i){let n=[];if(Array.isArray(i))for(let c of i){let s=c?.toString();s&&s.trim().length>0&&n.push(s)}else{let c=i?.toString();c&&c.trim().length>0&&n.push(c)}for(let c of n){let s=c.includes(".")?c.split(".")[1]:c;if(s===r||r==="Property"&&(s==="DatatypeProperty"||s==="ObjectProperty"||s==="AnnotationProperty")||r==="Class"&&s==="Class"||await t.isSubclassOfAsync(c,r,o))return!0}}return!1}async buildPropertyMetadataAsync(e,r,t,o){let a=new Map;for(let[i,n]of o){let c=n.entity.type;if(c){let s=[];if(Array.isArray(c))for(let y of c){let m=y?.toString();m&&m.trim().length>0&&s.push(m)}else{let y=c?.toString();y&&y.trim().length>0&&s.push(y)}let l=!1,p="Property";for(let y of s){let m=y.includes(".")?y.split(".")[1]:y;if(m==="Property"||m==="DatatypeProperty"||m==="ObjectProperty"||m==="AnnotationProperty"){l=!0,p=y;break}}if(l){let y={propertyType:p},m=n.entity.range;if(m){let u=m?.toString();if(u&&u.trim().length>0){y.range=u;let f=await t.resolveEntityAsync(u,e);f&&(y.rangeUri=f.uri)}}if(a.set(i,y),n.uri){let u=`${n.uri.publisher}/${n.uri.package_}/${n.uri.name}`;a.set(u,y)}}}}return a}};var q=class{standardProperties=new Set(["type","label","comment","subClassOf","domain","range","subPropertyOf","inverseOf","sameAs","seeAlso","isDefinedBy"]);get ruleName(){return"PropertyDomain"}async validateAsync(e,r,t){let o=[],a=new Map;for(let[n,c]of Object.entries(e.body))if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let s=c,l=this.getPropertyValue(s,"type");(l==="DatatypeProperty"||l?.endsWith(".DatatypeProperty")||l==="ObjectProperty"||l?.endsWith(".ObjectProperty")||l==="AnnotationProperty"||l?.endsWith(".AnnotationProperty"))&&a.set(n,s)}let i=t?await this.buildClassHierarchyViaCache(e,t):await this.buildCompleteClassHierarchyAsync(e,r);for(let[n,c]of Object.entries(e.body))if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let s=c,l=this.getPropertyValue(s,"type");if(!l||l==="Class"||l.endsWith(".Class")||l.endsWith("Property")||l==="AnnotationProperty")continue;this.validateEntityProperties(s,n,l,a,i,o)}return o}async buildClassHierarchyViaCache(e,r){let t=new Map,o=be(e);if(!o)return t;let a=await r.getImportClosure(o);for(let i of a){let n=await r.getClassDeclarations(i);for(let[c,s]of n)s.length>0&&t.set(c,s)}return t}async buildCompleteClassHierarchyAsync(e,r){let t=new Map,o=new Set,a=async(n,c)=>{if(!o.has(c)){o.add(c);for(let[s,l]of Object.entries(n.body))if(typeof l=="object"&&l!==null&&!Array.isArray(l)){let p=l,y=this.getPropertyValue(p,"type");if(y==="Class"||y?.endsWith(".Class")){let m=p.subClassOf;if(m===void 0){for(let f of Object.keys(p))if(f.endsWith(".subClassOf")){m=p[f];break}}let u=P(m);u.length>0&&t.set(s,u)}}if(n.metadata.imports)for(let[s,l]of Object.entries(n.metadata.imports))for(let p of l)try{let y=await r.getHighestCompatibleVersionAsync(s,p);if(y){let m=`${s}/${p.packageName}@${p.version}`;await a(y,m)}}catch{}}},i=e.metadata.namespace_?.toString()??"unknown";return await a(e,i),t}validateEntityProperties(e,r,t,o,a,i){for(let[n,c]of Object.entries(e)){if(this.standardProperties.has(n))continue;let s=n,l=n.lastIndexOf(".");l>0&&l<n.length-1&&(s=n.substring(l+1));let p=o.get(s);if(!p)continue;let y=this.getPropertyValue(p,"domain");if(y){if(!this.isTypeCompatibleWithDomain(t,y,a)){let m=r.split(".")[0];i.push({ruleType:this.ruleName,severity:"Error",entityName:m,propertyName:r,actualValue:n,message:`Property '${n}' has domain '${y}' but is used on '${t}' at '${r}'`,suggestion:`Either:
37
- 1. Use this property only on '${y}' instances
38
- 2. Change the property domain to include '${t}'
39
- 3. Create a different property for '${t}'`,expectedValue:`Property used on ${y} or its subclasses`})}if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let m=c,u=this.getPropertyValue(m,"type");if(u){let f=`${r}.${n}`;this.validateEntityProperties(m,f,u,o,a,i)}else{let f=this.getPropertyValue(p,"range");if(f){let b=`${r}.${n}`;this.validateEntityProperties(m,b,f,o,a,i)}}}else if(Array.isArray(c))for(let m=0;m<c.length;m++){let u=c[m];if(typeof u=="object"&&u!==null&&!Array.isArray(u)){let f=u,b=this.getPropertyValue(f,"type");if(b){let h=`${r}.${n}[${m}]`;this.validateEntityProperties(f,h,b,o,a,i)}else{let h=this.getPropertyValue(p,"range");if(h){let k=`${r}.${n}[${m}]`;this.validateEntityProperties(f,k,h,o,a,i)}}}}}}}isTypeCompatibleWithDomain(e,r,t){if(e===r)return!0;let o=new Set,a=[e];for(;a.length>0;){let i=a.shift();if(o.has(i))continue;o.add(i);let n=t.get(i);if(n)for(let c of n){if(c===r)return!0;a.push(c)}}return!1}getPropertyValue(e,r){if(r in e){let t=e[r];return this.extractFirstValue(t)}for(let t of Object.keys(e))if(t.endsWith(`.${r}`)){let o=e[t];return this.extractFirstValue(o)}}extractFirstValue(e){if(Array.isArray(e)){let r=[];for(let t of e)r.push(t?.toString()??"");return r.length>0?r[0]:void 0}return e?.toString()}};function be(d){let e=d.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${A(e.version)}`}var X=class{get ruleName(){return"PropertyValueType"}async validateAsync(e,r){let t=[],o=new Map;for(let[a,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let n=i,c=this.getPropertyValue(n,"type");(c==="DatatypeProperty"||c==="ObjectProperty")&&o.set(a,n)}for(let[a,i]of Object.entries(e.body)){if(typeof i!="object"||i===null||Array.isArray(i))continue;let n=i,c=this.getPropertyValue(n,"type");if(!(!c||c==="Class"||c.endsWith("Property")||c==="AnnotationProperty"))for(let[s,l]of Object.entries(n)){if(s==="type"||s==="label"||s==="comment")continue;let p=s,y=s.lastIndexOf(".");y>0&&y<s.length-1&&(p=s.substring(y+1));let m=o.get(p);if(!m)continue;let u=this.getPropertyValue(m,"type"),f=this.getPropertyValue(m,"range");if(u==="DatatypeProperty"){if(typeof l=="object"&&l!==null&&!Array.isArray(l)||Array.isArray(l))t.push({ruleType:this.ruleName,severity:"Error",entityName:a,propertyName:s,message:`Property '${s}' is a DatatypeProperty with range '${f}' but instance '${a}' has a complex object value`,suggestion:`Either:
40
- 1. Create a class for this data and change '${s}' to an ObjectProperty
41
- 2. Store as a JSON string to keep it as DatatypeProperty
42
- 3. Use separate properties instead of nesting`,expectedValue:`A simple value of type '${f}'`});else if(!this.validateDatatypeValue(f,l)){let b={ruleType:this.ruleName,severity:"Error",entityName:a,propertyName:s,message:`Property '${s}' expects type '${f}' but instance '${a}' has value of type '${this.getValueTypeName(l)}'`,suggestion:`Provide a value of type '${f}'`,toString:()=>""};f&&(b.expectedValue=f),t.push(b)}}else if(u==="ObjectProperty")if(Array.isArray(l))for(let b=0;b<l.length;b++){let h=l[b];typeof h!="string"&&(typeof h!="object"||h===null||Array.isArray(h))&&t.push({ruleType:this.ruleName,severity:"Error",entityName:a,propertyName:`${s}[${b}]`,message:`ObjectProperty '${s}' array item ${b} in instance '${a}' has invalid type '${this.getValueTypeName(h)}'`,suggestion:"Array items must be references (strings) or embedded objects (dictionaries)",expectedValue:"string or object"})}else typeof l!="string"&&(typeof l!="object"||l===null||Array.isArray(l))&&t.push({ruleType:this.ruleName,severity:"Error",entityName:a,propertyName:s,message:`ObjectProperty '${s}' in instance '${a}' has invalid value type '${this.getValueTypeName(l)}'`,suggestion:"Value must be a reference (string), embedded object (dictionary), or array of these",expectedValue:`Reference to ${f} or embedded ${f} object`})}}return t}validateDatatypeValue(e,r){switch(e?.toLowerCase()){case"string":return typeof r=="string";case"integer":case"int":return typeof r=="number"&&Number.isInteger(r);case"decimal":return typeof r=="number";case"boolean":return typeof r=="boolean";case"float":case"double":return typeof r=="number";default:return!0}}getValueTypeName(e){return typeof e=="string"?"string":typeof e=="number"?Number.isInteger(e)?"integer":"decimal":typeof e=="boolean"?"boolean":Array.isArray(e)?"array":typeof e=="object"&&e!==null?"object":e===null?"null":e===void 0?"undefined":typeof e}getPropertyValue(e,r){if(r in e){let t=e[r];if(Array.isArray(t)){let o=[];for(let a of t)o.push(a?.toString()??"");return o.length>0?o[0]:void 0}return t?.toString()}}};var z=class{builtInClasses=new Set(["Resource","Class","Literal","Thing","Nothing","Property","DatatypeProperty","ObjectProperty","AnnotationProperty","FunctionalProperty","InverseFunctionalProperty","TransitiveProperty","SymmetricProperty","Package"]);get ruleName(){return"ClassDefinition"}async validateAsync(e,r){let t=[],o=new Map,a=new Set;for(let[n,c]of Object.entries(e.body))if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let l=c.type;if(l)if(Array.isArray(l))for(let p of l){let y=p?.toString();if(y==="Class"||y&&y.endsWith(".Class")){a.add(n);break}}else{let p=l?.toString();(p==="Class"||p&&p.endsWith(".Class"))&&a.add(n)}}for(let[n,c]of Object.entries(e.body))if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let s=c,l=s.type;if(l)if(Array.isArray(l)){let p=!1;for(let y of l){let m=y?.toString();if(m&&this.isDefinitionType(m)){p=!0;break}}if(!p)for(let y of l){let m=y?.toString();m&&m.trim().length>0&&(o.has(m)||o.set(m,[]),o.get(m).push(n))}}else{let p=l?.toString();p&&p.trim().length>0&&(this.isDefinitionType(p)||(o.has(p)||o.set(p,[]),o.get(p).push(n)))}this.checkNestedTypes(s,n,o,n)}let i=new V(r);for(let[n,c]of o){if(this.builtInClasses.has(n)||a.has(n))continue;let s=await i.resolveEntityAsync(n,e);if(!(s&&this.isClassEntity(s.entity))){let p=Array.from(new Set(c)).sort();for(let y of p)t.push({ruleType:this.ruleName,severity:"Error",message:`Class '${n}' is not defined or imported`,suggestion:`Define '${n}' as a Class in this document, or import a namespace that contains it`,entityName:y,propertyName:"type",actualValue:n,expectedValue:"Defined or imported class"})}}return t}checkNestedTypes(e,r,t,o){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let a=e,i=a.type;if(i){let n=new Set(["Class","DatatypeProperty","ObjectProperty","AnnotationProperty"]);if(Array.isArray(i))for(let c of i){let s=c?.toString();s&&s.trim().length>0&&!n.has(s)&&(t.has(s)||t.set(s,[]),t.get(s).push(o))}else{let c=i?.toString();c&&c.trim().length>0&&!n.has(c)&&(t.has(c)||t.set(c,[]),t.get(c).push(o))}}for(let[n,c]of Object.entries(a))if(n!=="type"){let s=`${o}.${n}`;this.checkNestedTypes(c,r,t,s)}}else if(Array.isArray(e))for(let a=0;a<e.length;a++){let i=`${o}[${a}]`;this.checkNestedTypes(e[a],r,t,i)}}isClassEntity(e){if(!e)return!1;let r=e.type;if(!r)return!1;if(Array.isArray(r))for(let t of r){let o=t?.toString();if(o==="Class"||o&&o.endsWith(".Class"))return!0}else{let t=r?.toString();if(t==="Class"||t&&t.endsWith(".Class"))return!0}return!1}isDefinitionType(e){return!e||e.trim().length===0?!1:new Set(["Class","Property","DatatypeProperty","ObjectProperty","AnnotationProperty"]).has(e)?!0:e.endsWith(".Class")||e.endsWith(".Property")||e.endsWith(".DatatypeProperty")||e.endsWith(".ObjectProperty")||e.endsWith(".AnnotationProperty")}};var Y=class{ruleName="MarkdownLink";async validateAsync(e,r,t){let o=[],a;if(t){let i=await t.getKanonaks(),n=Re(e);a=n?i.filter(c=>c instanceof J&&c.namespace===n):[]}else{let i=new me(e,r);a=await new Z().parseKanonaks(i)}for(let i of a)i instanceof J&&this.checkDefined(i,i.name,o);return o}checkDefined(e,r,t){for(let o of e.statement)if(o instanceof le){let a=o.predicate.subject?.name??"(unknown)";for(let i of o.links)i.target||t.push(this.unresolvedLinkError(r,a,i.reference));for(let i of ye(o.object))t.push(this.malformedLinkError(r,a,i.snippet))}else if(o instanceof ae)this.checkDefined(o.object,r,t);else if(o instanceof ce)for(let a of o.object)a instanceof se&&this.checkDefined(a,r,t)}unresolvedLinkError(e,r,t){let o=new g;return o.ruleType=this.ruleName,o.severity="Warning",o.entityName=e,o.propertyName=r,o.actualValue=t,o.message=`Embedded link [[${t}]] in '${r}' could not be resolved`,o.expectedValue="A reference resolvable through the document's import closure",o.suggestion=`The reference '${t}' inside a markdown value cannot be found in the current document or any imported namespace.
43
-
44
- Possible solutions:
45
- \u2022 Import the package that defines '${t}' so the link can resolve
46
- \u2022 Check for typos in the reference name
47
- \u2022 If the name collides across imports, alias-qualify it: [[alias.${t}]]`,o}malformedLinkError(e,r,t){let o=new g;return o.ruleType=this.ruleName,o.severity="Error",o.entityName=e,o.propertyName=r,o.actualValue=t,o.message=`Malformed embedded reference near '${t}' in '${r}'`,o.expectedValue="A single-line [[reference]] with no internal line break",o.suggestion=`A '[[' in '${r}' does not form a complete [[reference]] link.
48
-
49
- A reference may not span a line break \u2014 the most common cause is wrapping a
50
- long reference across two lines in a block scalar, e.g.:
51
- ... read for [[persistent-energy-
52
- shock]] held ...
53
- which is parsed as literal text, not a link. Keep each [[reference]] on one
54
- line (let the line run long), or check for an unterminated [[.`,o}};function Re(d){let e=d.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${A(e.version)}`}var oe=class{parser;documentRules;repositoryRules;includeWarnings=!0;constructor(e){this.parser=e??new ie,this.documentRules=[new v,new I,new O,new w],this.repositoryRules=[new j,new E,new N,new $,new S,new C,new K,new T,new x,new M,new W,new L,new _,new H,new U,new F,new B,new q,new X,new z,new Y]}async validateAsync(e,r,t){let o=new D;for(let a of this.documentRules)try{let i=a.validate(e);this.addErrorsToResult(o,i)}catch(i){let n=new g;n.ruleType=a.ruleName,n.severity="Error",n.message=`Validation rule '${a.ruleName}' failed: ${i instanceof Error?i.message:String(i)}`,o.errors.push(n)}if(r){let a=[],i=t?.repository??r;for(let n of this.repositoryRules)try{let c=await n.validateAsync(e,i,t);this.addErrorsToResult(o,c)}catch(c){let s=c instanceof Error?c.message:String(c);a.push({ruleName:n.ruleName,cause:s})}if(a.length>0){let n=new Map;for(let{ruleName:c,cause:s}of a){let l=n.get(s);l?l.push(c):n.set(s,[c])}for(let[c,s]of n){let l=new g;l.ruleType=s[0],l.severity="Error",s.length===1?l.message=`Validation rule '${s[0]}' failed: ${c}`:l.message=`${c} (affects ${s.length} rules: ${s.join(", ")})`,o.errors.push(l)}}}return o.isValid=o.errors.length===0,o}async validateYamlAsync(e,r,t){let o=this.parser.parseWithErrors(e);if(!o.isValid){let a=new D;a.isValid=!1;for(let i of o.errors){let n=new g;n.ruleType="ParseError",n.severity="Error",n.lineNumber=i.line,n.column=i.column,n.message=i.message,i.keyName&&(n.entityName=i.keyName),i.errorType==="DuplicateKey"&&(n.suggestion="All property names must be unique across the entire document. Rename one of the duplicate properties to make them unique."),a.errors.push(n)}return a}return await this.validateAsync(o.document,r,t)}addDocumentRule(e){this.documentRules.push(e)}addRepositoryRule(e){this.repositoryRules.push(e)}removeDocumentRule(e){let r=this.documentRules.findIndex(t=>t instanceof e);r>=0&&this.documentRules.splice(r,1)}removeRepositoryRule(e){let r=this.repositoryRules.findIndex(t=>t instanceof e);r>=0&&this.repositoryRules.splice(r,1)}addErrorsToResult(e,r){for(let t of r)t.severity==="Error"?e.errors.push(t):this.includeWarnings&&e.warnings.push(t)}};export{D as a,R as b,g as c,Q as d,te as e,v as f,I as g,O as h,w as i,j,E as k,N as l,$ as m,S as n,C as o,K as p,T as q,x as r,M as s,W as t,L as u,_ as v,H as w,U as x,F as y,B as z,q as A,X as B,z as C,Y as D,oe as E};
@@ -1,10 +0,0 @@
1
- import type { IKanonakDocumentRepository } from '@kanonak-protocol/types/document/models';
2
- import type { KanonakDocument } from '@kanonak-protocol/types/document/models/types';
3
- import { OntologyValidationError } from '../../OntologyValidationError.js';
4
- import type { IRepositoryValidationRule } from './IRepositoryValidationRule.js';
5
- export declare class TypeAmbiguityRule implements IRepositoryValidationRule {
6
- readonly ruleName = "TypeAmbiguity";
7
- validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository): Promise<OntologyValidationError[]>;
8
- private checkAmbiguousReference;
9
- private getTransitiveImportsAsync;
10
- }