@kanonak-protocol/sdk 3.27.1 → 3.27.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-JAU6JAPI.js +200 -0
- package/dist/index.js +1 -1
- package/dist/look/LookRenderer.d.ts +34 -0
- package/dist/transformations/index.d.ts +1 -1
- package/dist/transformations/index.js +21 -37
- package/package.json +2 -2
- package/dist/chunk-7C5JUPYB.js +0 -165
- /package/dist/{transformations/backends/SimpleMarkdownRenderer.d.ts → markdown/MarkdownRenderer.d.ts} +0 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import{a as B}from"./chunk-NIGFQYVA.js";import{a as v}from"./chunk-R2V7IXWN.js";import{c as L,d as p,g as j,j as d,k as x,l as g}from"./chunk-W6T7MOKY.js";function H(a){let e=a.replace(/\r\n/g,`
|
|
2
|
+
`).split(`
|
|
3
|
+
`),t=[],n=0;for(;n<e.length;){let r=e[n];if(r.trim()===""){n++;continue}let o=/^(\s*)```(\S*)\s*$/.exec(r);if(o){let c=o[2],u=[];for(n++;n<e.length&&!/^(\s*)```\s*$/.test(e[n]);)u.push(e[n]),n++;n++;let l=M(u.join(`
|
|
4
|
+
`)),S=c?` class="language-${A(c)}"`:"";t.push(`<pre><code${S}>${l}</code></pre>`);continue}let s=/^(#{1,6})\s+(.*)$/.exec(r);if(s){let c=s[1].length,u=R(s[2].trim());t.push(`<h${c}>${u}</h${c}>`),n++;continue}if(r.includes("|")&&n+1<e.length&&V(e[n+1])){let c=w(r),u=X(e[n+1]);n+=2;let l=[];for(;n<e.length&&e[n].trim()!==""&&e[n].includes("|");)l.push(w(e[n])),n++;t.push(Z(c,u,l));continue}if(/^\s*[-*]\s+/.test(r)){let c=[];for(;n<e.length&&/^\s*[-*]\s+/.test(e[n]);){let u=[e[n].replace(/^\s*[-*]\s+/,"")];for(n++;n<e.length&&e[n].trim()!==""&&!/^\s*[-*]\s+/.test(e[n])&&!/^\s*\d+\.\s+/.test(e[n]);)u.push(e[n]),n++;n<e.length&&e[n].trim()===""&&n++,c.push(`<li>${R(u.join(" ").trim())}</li>`)}t.push(`<ul>
|
|
5
|
+
${c.join(`
|
|
6
|
+
`)}
|
|
7
|
+
</ul>`);continue}if(/^\s*\d+\.\s+/.test(r)){let c=[];for(;n<e.length&&/^\s*\d+\.\s+/.test(e[n]);){let u=[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]);)u.push(e[n]),n++;n<e.length&&e[n].trim()===""&&n++,c.push(`<li>${R(u.join(" ").trim())}</li>`)}t.push(`<ol>
|
|
8
|
+
${c.join(`
|
|
9
|
+
`)}
|
|
10
|
+
</ol>`);continue}let i=[r];for(n++;n<e.length&&e[n].trim()!==""&&!/^(#{1,6})\s+/.test(e[n])&&!/^(\s*)```/.test(e[n])&&!/^\s*[-*]\s+/.test(e[n])&&!/^\s*\d+\.\s+/.test(e[n])&&!(e[n].includes("|")&&n+1<e.length&&V(e[n+1]));)i.push(e[n]),n++;t.push(`<p>${R(i.join(" "))}</p>`)}return t.join(`
|
|
11
|
+
`)}function V(a){return a.includes("-")?/^[\s|:-]+$/.test(a):!1}function w(a){let e=a.trim();return e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&(e=e.slice(0,-1)),e.split("|").map(t=>t.trim())}function X(a){return w(a).map(e=>{let t=e.startsWith(":"),n=e.endsWith(":");return t&&n?"center":n?"right":t?"left":null})}function Z(a,e,t){let n=s=>{let i=e[s];return i?` style="text-align:${i}"`:""},r=a.map((s,i)=>`<th${n(i)}>${R(s)}</th>`).join(""),o=t.map(s=>`<tr>${s.map((c,u)=>`<td${n(u)}>${R(c)}</td>`).join("")}</tr>`).join(`
|
|
12
|
+
`);return`<table>
|
|
13
|
+
<thead><tr>${r}</tr></thead>
|
|
14
|
+
<tbody>
|
|
15
|
+
${o}
|
|
16
|
+
</tbody>
|
|
17
|
+
</table>`}function R(a){let e=M(a);return e=e.replace(/`([^`\n]+)`/g,(t,n)=>`<code>${n}</code>`),e=e.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(t,n,r)=>`<a href="${A(r)}">${n}</a>`),e=e.replace(/\*\*([^*\n]+)\*\*/g,(t,n)=>`<strong>${n}</strong>`),e=e.replace(/(^|[^*])\*([^*\n]+)\*(?!\*)/g,(t,n,r)=>`${n}<em>${r}</em>`),e=e.replace(/(^|[\s(])_([^_\n]+)_(?=[\s).,;:!?]|$)/g,(t,n,r)=>`${n}<em>${r}</em>`),e}function M(a){return a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function A(a){return a.replace(/"/g,""").replace(/&/g,"&")}var U={publisher:"kanonak.org",package_:"derivation",name:"look"},O={publisher:"kanonak.org",package_:"derivation",name:"tokens"},y={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},D={publisher:"kanonak.org",package_:"core-rdf",name:"label"},ee={publisher:"kanonak.org",package_:"core-rdf",name:"comment"},ne={publisher:"kanonak.org",package_:"look",name:"Hero"},te={publisher:"kanonak.org",package_:"look",name:"PropertyList"},re={publisher:"kanonak.org",package_:"look",name:"BadgeRow"},oe={publisher:"kanonak.org",package_:"look",name:"ChipRow"},ae={publisher:"kanonak.org",package_:"look",name:"ReferenceList"},N={publisher:"kanonak.org",package_:"look",name:"Markdown"},I={publisher:"kanonak.org",package_:"look",name:"bands"},se={publisher:"kanonak.org",package_:"look",name:"title"},ie={publisher:"kanonak.org",package_:"look",name:"eyebrow"},ce={publisher:"kanonak.org",package_:"look",name:"subtitle"},W={publisher:"kanonak.org",package_:"look",name:"badges"},_={publisher:"kanonak.org",package_:"look",name:"source"},ue={publisher:"kanonak.org",package_:"look",name:"chips"},z={publisher:"kanonak.org",package_:"look",name:"entries"},le={publisher:"kanonak.org",package_:"look",name:"urlForm"},C=class{constructor(e){this.catalog=e}catalog;findCascadedLook(e){let t=new Set,n=P(e);for(;n.length>0;){let r=n.shift(),o=K(r.subject);if(t.has(o))continue;t.add(o);let s=h(this.catalog,r.subject);if(!s)continue;let i=q(s);if(i)return{declaration:i,sourceClass:{publisher:r.subject.publisher,package_:r.subject.package_,name:r.subject.name}};for(let c of F(s))n.push(c)}if(!t.has(K(y))){let r=h(this.catalog,y);if(r){let o=q(r);if(o)return{declaration:o,sourceClass:{...y}}}}}findCascadedTokens(e){let t=new Map;for(let[o,s]of E(e))t.has(o)||t.set(o,s);let n=new Set,r=P(e);for(;r.length>0;){let o=r.shift(),s=K(o.subject);if(n.has(s))continue;n.add(s);let i=h(this.catalog,o.subject);if(i){for(let[c,u]of E(i))t.has(c)||t.set(c,u);for(let c of F(i))r.push(c)}}if(!n.has(K(y))){let o=h(this.catalog,y);if(o)for(let[s,i]of E(o))t.has(s)||t.set(s,i)}return t}renderStylesheet(e){let t=this.findCascadedTokens(e),n=[];for(let[o,s]of t)n.push(` --kan-${o}: ${s};`);return`${n.length>0?`:root {
|
|
18
|
+
${n.join(`
|
|
19
|
+
`)}
|
|
20
|
+
}`:":root { /* no tokens resolved */ }"}
|
|
21
|
+
${pe}`}renderHtml(e){let t=this.findCascadedLook(e);if(!t)return`<!-- LookRenderer: no derivation.look found for ${e.namespace}/${e.name} -->`;let n=G(t.declaration);if(n.length===0)return"<!-- LookRenderer: look declaration has no bands -->";let r=fe(e),o=[];for(let s of n)o.push(this.renderBand(s,e,r));return o.join(`
|
|
22
|
+
`)}renderDocument(e){let t=this.renderHtml(e),n=this.readPropertyValueText(e,D)??e.name,r=`${e.name}.css`,o=this.hasSvgDerivation(e)?`<figure class="kan-figure"><img src="${f(e.name)}.svg" alt=""></figure>
|
|
23
|
+
`:"";return`<!doctype html>
|
|
24
|
+
<html lang="en">
|
|
25
|
+
<head>
|
|
26
|
+
<meta charset="utf-8">
|
|
27
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
28
|
+
<title>${f(n)}</title>
|
|
29
|
+
<link rel="stylesheet" href="${f(r)}">
|
|
30
|
+
</head>
|
|
31
|
+
<body>
|
|
32
|
+
<main class="kan-main">
|
|
33
|
+
${o}${t}
|
|
34
|
+
</main>
|
|
35
|
+
</body>
|
|
36
|
+
</html>
|
|
37
|
+
`}hasSvgDerivation(e){let t=new Set,n=P(e);for(;n.length>0;){let r=n.shift(),o=K(r.subject);if(t.has(o))continue;t.add(o);let s=h(this.catalog,r.subject);if(s){for(let i of s.statement)if(i instanceof g&&k(i,"kanonak.org","derivation","derivations")){for(let c of i.object??[])if(c instanceof v)for(let u of c.statement){if(!(u instanceof d)||!k(u,"kanonak.org","derivation","format")||!(u.object instanceof p))continue;let l=u.object.subject;if(l.publisher==="kanonak.org"&&l.package_==="formats"&&l.name==="svg")return!0}}for(let i of F(s))n.push(i)}}return!1}renderBand(e,t,n){let r=Y(e);return r?b(r,ne)?this.renderHero(e,t,n):b(r,te)?this.renderPropertyList(e,t,n):b(r,re)?this.renderBadgeRow(e,t,n):b(r,oe)?this.renderChipRow(e,t,n):b(r,ae)?this.renderReferenceList(e,t,n):b(r,N)?this.renderMarkdown(e,t):`<!-- LookRenderer: unsupported band ${r.publisher}/${r.package_}/${r.name} -->`:"<!-- LookRenderer: band has no rdf:type -->"}renderMarkdown(e,t){let n=m(e,_);if(!n)return"<!-- LookRenderer.Markdown: no look.source -->";let r=this.readPropertyValueText(t,n);return r?`<section class="kan-markdown">
|
|
38
|
+
${H(r)}
|
|
39
|
+
</section>`:""}renderRawMarkdown(e){let t=this.findCascadedLook(e);if(!t)return;let n=G(t.declaration),r=[];for(let o of n){let s=Y(o);if(!s||!b(s,N))continue;let i=m(o,_);if(!i)continue;let c=this.readPropertyValueText(e,i);c&&r.push(c)}return r.length>0?r.join(`
|
|
40
|
+
|
|
41
|
+
`):void 0}renderHero(e,t,n){let r=['<header class="kan-hero">'],o=m(e,ie);if(o){let l=this.readPropertyValueText(t,o);l&&r.push(`<span class="kan-hero-eyebrow">${f(l)}</span>`)}let s=m(e,se),i="";s&&(i=this.readPropertyValueText(t,s)??""),i||(i=t.name),r.push(`<h1 class="kan-hero-title">${f(i)}</h1>`);let c=m(e,ce);if(c){let l=this.readPropertyValueText(t,c);l&&r.push(`<p class="kan-hero-subtitle">${f(l)}</p>`)}let u=m(e,W);if(u){let l=this.readPropertyValueReferences(t,u);if(l.length>0){let S=l.map(Q=>this.renderBadge(Q,W,n)).join("");r.push(`<div class="kan-hero-badges">${S}</div>`)}}return r.push("</header>"),r.join(`
|
|
42
|
+
`)}renderPropertyList(e,t,n){let r=m(e,_);if(!r)return"<!-- LookRenderer: PropertyList missing look.source -->";let o=this.readLabelForUri(r)??r.name,s=$(t,r),i=this.gatherValueItems(s),c=i.length>0?i.map(u=>`<li>${this.renderInlineValue(u,_,n)}</li>`).join(""):'<li class="kan-empty">(no values)</li>';return['<section class="kan-property-list">',`<h3 class="kan-property-list-title">${f(o)}</h3>`,`<ul class="kan-property-list-items">${c}</ul>`,"</section>"].join(`
|
|
43
|
+
`)}renderBadgeRow(e,t,n){let r=m(e,_);if(!r)return"<!-- LookRenderer: BadgeRow missing look.source -->";let o=this.readPropertyValueReferences(t,r);return o.length===0?"":`<div class="kan-badge-row">${o.map(i=>this.renderBadge(i,_,n)).join("")}</div>`}renderChipRow(e,t,n){let r=J(e,ue);if(r.length===0)return"<!-- LookRenderer: ChipRow has no look.chips -->";let o=[];for(let s of r){let i=$(t,s);if(!i)continue;let c=this.readLabelForUri(s)??s.name,u=this.renderStatementInlineValue(i,s,n);u&&o.push(`<span class="kan-chip"><span class="kan-chip-key">${f(c)}</span> <span class="kan-chip-val">${u}</span></span>`)}return o.length===0?"":`<div class="kan-chip-row">${o.join("")}</div>`}renderReferenceList(e,t,n){let r=J(e,z);if(r.length===0)return"<!-- LookRenderer: ReferenceList has no look.entries -->";let o=[];for(let s of r){let i=this.readPropertyValueReferences(t,s);if(i.length===0)continue;let c=this.readLabelForUri(s)??s.name,u=i.map(l=>this.renderReferenceLink(l,z,n)).join(", ");o.push(`<dt>${f(c)}</dt><dd>${u}</dd>`)}return o.length===0?"":`<dl class="kan-reference-list">${o.join("")}</dl>`}readPropertyValueText(e,t){let n=$(e,t);if(n){if(n instanceof j)return n.object;if(n instanceof d){let r=n.object;return this.readLabelForUri({publisher:r.subject.publisher,package_:r.subject.package_,name:r.subject.name})??r.subject.name}if(n instanceof g)return(n.object??[]).map(o=>o instanceof p?this.readLabelForUri({publisher:o.subject.publisher,package_:o.subject.package_,name:o.subject.name})??o.subject.name:o instanceof v?o.name??"":String(o)).filter(o=>o).join(", ")}}readPropertyValueReferences(e,t){let n=$(e,t);if(!n)return[];if(n instanceof d)return[n.object];if(n instanceof g){let r=[];for(let o of n.object??[])o instanceof p&&r.push(o);return r}return[]}gatherValueItems(e){return e?e instanceof g?e.object??[]:e instanceof d?[e.object]:e instanceof x?[e.object]:e instanceof j?[e.object]:[]:[]}renderInlineValue(e,t,n){return e instanceof p?this.renderReferenceLink(e,t,n):e instanceof v?f(e.name??"(embedded)"):typeof e=="string"?f(e):typeof e=="number"||typeof e=="boolean"?f(String(e)):""}renderStatementInlineValue(e,t,n){return e instanceof j?f(e.object):e instanceof d?this.renderReferenceLink(e.object,t,n):e instanceof g?(e.object??[]).map(o=>this.renderInlineValue(o,t,n)).filter(o=>o).join(", "):""}renderReferenceLink(e,t,n){let r=this.readLabelForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name})??e.subject.name,o=this.urlForReference(e,t,n);return`<a class="kan-link" href="${f(o)}">${f(r)}</a>`}renderBadge(e,t,n){let r=this.readLabelForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name})??e.subject.name,o=this.readCommentForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name}),s=this.urlForReference(e,t,n),i=o?` title="${f(o)}"`:"";return`<a class="kan-badge" href="${f(s)}"${i}>${f(r)}</a>`}urlForReference(e,t,n){let r=t?this.getUrlFormForProperty(t):"=";return B.formatResourceUrl({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},r,{contextPublisher:n})}getUrlFormForProperty(e){let t=h(this.catalog,e);if(!t)return"=";let n=T(t,le);return n==="*"||n==="^"||n==="~"||n==="="?n:"="}readLabelForUri(e){let t=h(this.catalog,e);if(t)return T(t,D)}readCommentForUri(e){let t=h(this.catalog,e);if(t)return T(t,ee)}};function E(a){let e=new Map;for(let t of a.statement){if(!(t instanceof x)||!k(t,O.publisher,O.package_,O.name))continue;let n=t.object;for(let r of n.statement){if(!(r instanceof j))continue;let o=r.predicate?.subject?.name;if(!o)continue;let s=r.object;e.set(o,s)}return e}return e}function q(a){for(let e of a.statement)if(e instanceof x&&k(e,U.publisher,U.package_,U.name))return e.object}function G(a){for(let e of a.statement){if(!(e instanceof g)||!k(e,I.publisher,I.package_,I.name))continue;let t=[];for(let n of e.object??[])n instanceof v&&t.push(n);return t}return[]}function Y(a){for(let e of a.statement)if(e instanceof d&&e.predicate?.subject?.name==="type"&&e.object instanceof p){let t=e.object.subject;return{publisher:t.publisher,package_:t.package_,name:t.name}}}function m(a,e){for(let t of a.statement)if(t instanceof d&&k(t,e.publisher,e.package_,e.name)&&t.object instanceof p){let n=t.object.subject;return{publisher:n.publisher,package_:n.package_,name:n.name}}}function J(a,e){for(let t of a.statement){if(!(t instanceof g)||!k(t,e.publisher,e.package_,e.name))continue;let n=[];for(let r of t.object??[])r instanceof p&&n.push({publisher:r.subject.publisher,package_:r.subject.package_,name:r.subject.name});return n}return[]}function $(a,e){for(let t of a.statement)if(k(t,e.publisher,e.package_,e.name))return t}function T(a,e){for(let t of a.statement)if(t instanceof j&&k(t,e.publisher,e.package_,e.name))return t.object}function P(a){let e=[];for(let t of a.statement)if(t instanceof d){if(t.predicate?.subject?.name!=="type")continue;t.object instanceof p&&e.push(t.object)}else if(t instanceof g){if(t.predicate?.subject?.name!=="type")continue;for(let n of t.object??[])n instanceof p&&e.push(n)}return e}function F(a){let e=[];for(let t of a.statement)if(t instanceof d){if(t.predicate?.subject?.name!=="subClassOf")continue;t.object instanceof p&&e.push(t.object)}else if(t instanceof g){if(t.predicate?.subject?.name!=="subClassOf")continue;for(let n of t.object??[])n instanceof p&&e.push(n)}return e}function h(a,e){let t="version"in e?e.version:void 0;if(t){let n=`${e.publisher}/${e.package_}@${t.major}.${t.minor}.${t.patch}`;for(let r of a)if(r instanceof L&&r.name===e.name&&r.namespace===n)return r}for(let n of a){if(!(n instanceof L)||n.name!==e.name)continue;if((n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))return n}}function k(a,e,t,n){let r=a.predicate?.subject;return r?r.publisher===e&&r.package_===t&&r.name===n:!1}function b(a,e){return a.publisher===e.publisher&&a.package_===e.package_&&a.name===e.name}function K(a){return`${a.publisher}/${a.package_}/${a.name}`}function fe(a){let e=a.namespace||"",t=e.indexOf("/");return t>=0?e.substring(0,t):e}function f(a){return a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var pe=`
|
|
44
|
+
* { box-sizing: border-box; }
|
|
45
|
+
body {
|
|
46
|
+
background: var(--kan-bg);
|
|
47
|
+
color: var(--kan-text);
|
|
48
|
+
font-family: var(--kan-font-body);
|
|
49
|
+
line-height: var(--kan-line-height-body);
|
|
50
|
+
margin: 0;
|
|
51
|
+
}
|
|
52
|
+
a { color: var(--kan-accent); text-decoration: none; }
|
|
53
|
+
a:hover { color: var(--kan-accent-hover); text-decoration: underline; }
|
|
54
|
+
|
|
55
|
+
/* Hero band */
|
|
56
|
+
.kan-hero {
|
|
57
|
+
padding: 32px 0 24px;
|
|
58
|
+
border-bottom: 1px solid var(--kan-border);
|
|
59
|
+
margin-bottom: 32px;
|
|
60
|
+
}
|
|
61
|
+
.kan-hero-eyebrow {
|
|
62
|
+
font-family: var(--kan-font-mono);
|
|
63
|
+
font-size: 11px;
|
|
64
|
+
color: var(--kan-accent);
|
|
65
|
+
letter-spacing: 0.18em;
|
|
66
|
+
text-transform: uppercase;
|
|
67
|
+
margin-bottom: 12px;
|
|
68
|
+
display: block;
|
|
69
|
+
}
|
|
70
|
+
.kan-hero-title {
|
|
71
|
+
font-family: var(--kan-font-display);
|
|
72
|
+
font-size: 32px;
|
|
73
|
+
font-weight: 600;
|
|
74
|
+
letter-spacing: -0.015em;
|
|
75
|
+
margin: 0 0 12px;
|
|
76
|
+
line-height: var(--kan-line-height-heading);
|
|
77
|
+
color: var(--kan-text);
|
|
78
|
+
}
|
|
79
|
+
.kan-hero-subtitle {
|
|
80
|
+
font-size: 17px;
|
|
81
|
+
color: var(--kan-text-dim);
|
|
82
|
+
font-weight: 300;
|
|
83
|
+
line-height: 1.55;
|
|
84
|
+
margin: 0 0 16px;
|
|
85
|
+
}
|
|
86
|
+
.kan-hero-badges {
|
|
87
|
+
display: flex;
|
|
88
|
+
flex-wrap: wrap;
|
|
89
|
+
gap: 6px;
|
|
90
|
+
margin-top: 12px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* PropertyList band */
|
|
94
|
+
.kan-property-list {
|
|
95
|
+
margin: 24px 0;
|
|
96
|
+
}
|
|
97
|
+
.kan-property-list-title {
|
|
98
|
+
font-family: var(--kan-font-mono);
|
|
99
|
+
font-size: 11px;
|
|
100
|
+
letter-spacing: 0.18em;
|
|
101
|
+
text-transform: uppercase;
|
|
102
|
+
color: var(--kan-text-dim);
|
|
103
|
+
margin: 0 0 12px;
|
|
104
|
+
font-weight: 600;
|
|
105
|
+
}
|
|
106
|
+
.kan-property-list-items {
|
|
107
|
+
list-style: none;
|
|
108
|
+
padding: 0;
|
|
109
|
+
margin: 0;
|
|
110
|
+
display: flex;
|
|
111
|
+
flex-direction: column;
|
|
112
|
+
gap: 6px;
|
|
113
|
+
}
|
|
114
|
+
.kan-property-list-items > li {
|
|
115
|
+
color: var(--kan-text);
|
|
116
|
+
}
|
|
117
|
+
.kan-property-list-items > li.kan-empty {
|
|
118
|
+
color: var(--kan-text-faint);
|
|
119
|
+
font-style: italic;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* BadgeRow band */
|
|
123
|
+
.kan-badge-row {
|
|
124
|
+
display: flex;
|
|
125
|
+
flex-wrap: wrap;
|
|
126
|
+
gap: 6px;
|
|
127
|
+
margin: 16px 0;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/* Badge (used by Hero badges + BadgeRow) */
|
|
131
|
+
.kan-badge {
|
|
132
|
+
display: inline-block;
|
|
133
|
+
padding: 2px 8px;
|
|
134
|
+
background: var(--kan-badge-bg);
|
|
135
|
+
color: var(--kan-badge-fg);
|
|
136
|
+
border-radius: var(--kan-radius-sm);
|
|
137
|
+
font-size: 11px;
|
|
138
|
+
font-weight: 500;
|
|
139
|
+
text-decoration: none;
|
|
140
|
+
letter-spacing: 0.02em;
|
|
141
|
+
}
|
|
142
|
+
.kan-badge:hover {
|
|
143
|
+
filter: brightness(1.1);
|
|
144
|
+
text-decoration: none;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/* ChipRow band */
|
|
148
|
+
.kan-chip-row {
|
|
149
|
+
display: flex;
|
|
150
|
+
flex-wrap: wrap;
|
|
151
|
+
gap: 8px;
|
|
152
|
+
margin: 16px 0;
|
|
153
|
+
}
|
|
154
|
+
.kan-chip {
|
|
155
|
+
display: inline-flex;
|
|
156
|
+
align-items: center;
|
|
157
|
+
gap: 6px;
|
|
158
|
+
padding: 5px 10px;
|
|
159
|
+
background: var(--kan-bg-card);
|
|
160
|
+
border: 1px solid var(--kan-border);
|
|
161
|
+
border-radius: var(--kan-radius-sm);
|
|
162
|
+
font-family: var(--kan-font-mono);
|
|
163
|
+
font-size: 11px;
|
|
164
|
+
text-transform: uppercase;
|
|
165
|
+
letter-spacing: 0.04em;
|
|
166
|
+
}
|
|
167
|
+
.kan-chip-key { color: var(--kan-text-faint); }
|
|
168
|
+
.kan-chip-val { color: var(--kan-text); font-weight: 500; }
|
|
169
|
+
|
|
170
|
+
/* ReferenceList band */
|
|
171
|
+
dl.kan-reference-list {
|
|
172
|
+
display: grid;
|
|
173
|
+
grid-template-columns: max-content 1fr;
|
|
174
|
+
gap: 8px 16px;
|
|
175
|
+
margin: 16px 0;
|
|
176
|
+
padding: 16px 18px;
|
|
177
|
+
background: var(--kan-bg-card);
|
|
178
|
+
border: 1px solid var(--kan-border);
|
|
179
|
+
border-radius: var(--kan-radius);
|
|
180
|
+
}
|
|
181
|
+
dl.kan-reference-list dt {
|
|
182
|
+
font-family: var(--kan-font-mono);
|
|
183
|
+
font-size: 11px;
|
|
184
|
+
text-transform: uppercase;
|
|
185
|
+
letter-spacing: 0.1em;
|
|
186
|
+
color: var(--kan-text-faint);
|
|
187
|
+
align-self: center;
|
|
188
|
+
}
|
|
189
|
+
dl.kan-reference-list dd { margin: 0; align-self: center; }
|
|
190
|
+
|
|
191
|
+
/* Link (used by reference values across bands) */
|
|
192
|
+
.kan-link {
|
|
193
|
+
color: var(--kan-accent);
|
|
194
|
+
text-decoration: none;
|
|
195
|
+
}
|
|
196
|
+
.kan-link:hover {
|
|
197
|
+
color: var(--kan-accent-hover);
|
|
198
|
+
text-decoration: underline;
|
|
199
|
+
}
|
|
200
|
+
`.trim();export{H as a,C as b};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Ze,b as Qe,c as et,d as tt,e as rt,f as nt,g as ot,h as at,i as it,j as st}from"./chunk-NYXIGTTH.js";import{
|
|
1
|
+
import{a as Ze,b as Qe,c as et,d as tt,e as rt,f as nt,g as ot,h as at,i as it,j as st}from"./chunk-NYXIGTTH.js";import{b as Yt}from"./chunk-JAU6JAPI.js";import{a as qe,b as Ye,c as Xe,d as b,e as S,f as i}from"./chunk-VLBP5CHO.js";import{a as qt}from"./chunk-ROCCA4BY.js";import{a as Te,b as je,c as Le,d as Fe,e as Ne}from"./chunk-AZSZXLEH.js";import{a as Be,b as De,c as Oe,d as Ae}from"./chunk-AV4AVTI6.js";import{a as lt,b as dt,c as ut,d as pt}from"./chunk-63NJ25ZX.js";import{a as Je,b as mt,c as ft,d as yt,e as ht}from"./chunk-4TJZIM7A.js";import{a as gt}from"./chunk-NIGFQYVA.js";import{A as Mt,B as zt,C as Gt,D as Wt,E as Jt,a as kt,b as bt,c as St,d as Ct,e as Pt,f as Rt,g as wt,h as xt,i as $t,j as vt,k as Et,l as Kt,m as Bt,n as It,o as Tt,p as jt,q as Lt,r as Ft,s as Nt,t as Dt,u as Ot,v as At,w as Ut,x as Vt,y as Ht,z as _t}from"./chunk-PB2RWBJN.js";import"./chunk-FJ35VIV6.js";import{a as F,b as D,c as Me,e as We}from"./chunk-R2V7IXWN.js";import{a as Ue,b as j,c as L,d as N,e as He,f as _e,g as O,h as A,i as U,j as V,k as H,l as _}from"./chunk-W6T7MOKY.js";import{a as Ie}from"./chunk-MYITGTGJ.js";import{a as Pe,b as Re,c as we,d as xe,e as $e,f as ve,g as Ee,h as Ke}from"./chunk-FQHALFRR.js";import{b as ze,c as Ge}from"./chunk-IXE5THUW.js";import{a as Ve}from"./chunk-FUUTGGJS.js";import{a as ct}from"./chunk-ODIECDN7.js";import{VersionOperator as oo}from"@kanonak-protocol/types/document/models/enums";import{existsSync as fr,readFileSync as yr}from"fs";import{homedir as gr}from"os";import{join as hr}from"path";import{execFile as Xt}from"child_process";import{promisify as Zt}from"util";var C=Zt(Xt),P="kanonak",R="/usr/bin/security",p=class{async get(e){let r=i(e);try{let{stdout:n}=await C(R,["find-generic-password","-s",P,"-a",r,"-w"],{timeout:1e4});try{return JSON.parse(n.trim())}catch{throw new Error(`Stored credential for '${r}' is corrupted (not valid JSON).
|
|
2
2
|
Run 'kanonak logout ${r}' then 'kanonak login ${r}' to fix.`)}}catch(n){if(X(n,44))return null;throw new Error(`macOS Keychain read failed for '${r}': ${w(n)}
|
|
3
3
|
The Keychain may be locked or inaccessible.
|
|
4
4
|
Try unlocking it via Keychain Access.app or running 'security unlock-keychain'.`)}}async store(e,r){let n=i(e),o=JSON.stringify(r);try{await C(R,["add-generic-password","-s",P,"-a",n,"-U","-w",o],{timeout:1e4})}catch(a){throw new Error(`macOS Keychain write failed for '${n}': ${w(a)}
|
|
@@ -75,7 +75,41 @@ export declare class LookRenderer {
|
|
|
75
75
|
* Render the instance as body-only HTML using its cascaded look.
|
|
76
76
|
*/
|
|
77
77
|
renderHtml(instance: SubjectKanonak): string;
|
|
78
|
+
/**
|
|
79
|
+
* Render the instance as a standalone HTML document — `<!doctype html>`
|
|
80
|
+
* with `<head>` (title, viewport, stylesheet link) wrapping the body
|
|
81
|
+
* bands from `renderHtml`. The stylesheet href points at
|
|
82
|
+
* `${instance.name}.css` (paired output of `renderStylesheet`).
|
|
83
|
+
*
|
|
84
|
+
* If the instance's class chain declares a `derivation.derivations`
|
|
85
|
+
* binding for `formats.svg`, an `<img src="${instance.name}.svg">`
|
|
86
|
+
* figure is inserted at the top of the body so per-resource visuals
|
|
87
|
+
* appear without authors needing a custom look.Figure band.
|
|
88
|
+
*/
|
|
89
|
+
renderDocument(instance: SubjectKanonak): string;
|
|
90
|
+
/**
|
|
91
|
+
* True if the instance's class chain declares a `derivation.derivations`
|
|
92
|
+
* binding whose `derivation.format` is `kanonak.org/formats/svg`. Used by
|
|
93
|
+
* `renderDocument` to decide whether to emit an `<img>` figure.
|
|
94
|
+
*/
|
|
95
|
+
private hasSvgDerivation;
|
|
78
96
|
private renderBand;
|
|
97
|
+
/**
|
|
98
|
+
* Render a Markdown band — reads the property identified by
|
|
99
|
+
* `look.source` from the instance and pipes its string value through
|
|
100
|
+
* the SDK's minimal CommonMark renderer. Wraps the result in a
|
|
101
|
+
* `<section class="kan-markdown">` so stylesheets can target the
|
|
102
|
+
* prose block without bleeding into other bands.
|
|
103
|
+
*/
|
|
104
|
+
private renderMarkdown;
|
|
105
|
+
/**
|
|
106
|
+
* Return the raw markdown text for an instance — concatenation of every
|
|
107
|
+
* `look.Markdown` band's source property value (no HTML rendering). Used
|
|
108
|
+
* by publishers that expose a `.md` URL form for agents. Returns
|
|
109
|
+
* undefined when the cascaded look has no Markdown bands or when no
|
|
110
|
+
* value is present on the instance.
|
|
111
|
+
*/
|
|
112
|
+
renderRawMarkdown(instance: SubjectKanonak): string | undefined;
|
|
79
113
|
private renderHero;
|
|
80
114
|
private renderPropertyList;
|
|
81
115
|
private renderBadgeRow;
|
|
@@ -19,4 +19,4 @@ export { CssBackend } from './backends/CssBackend.js';
|
|
|
19
19
|
export { YamlBackend } from './backends/YamlBackend.js';
|
|
20
20
|
export { DynamoDbBackend } from './backends/DynamoDbBackend.js';
|
|
21
21
|
export type { DynamoDbAttributeValue } from './backends/DynamoDbBackend.js';
|
|
22
|
-
export { renderMarkdownToHtml } from '
|
|
22
|
+
export { renderMarkdownToHtml } from '../markdown/MarkdownRenderer.js';
|
|
@@ -1,49 +1,33 @@
|
|
|
1
|
-
import{b as E,c as F,d as f,f as M}from"../chunk-2JQMUZWN.js";import{a as
|
|
1
|
+
import{b as E,c as F,d as f,f as M}from"../chunk-2JQMUZWN.js";import{a as X,b as ye}from"../chunk-JAU6JAPI.js";import{a as Oe}from"../chunk-ROCCA4BY.js";import"../chunk-63NJ25ZX.js";import"../chunk-NIGFQYVA.js";import{a as Ue}from"../chunk-FJ35VIV6.js";import{a as C,c as Re,e as Ce}from"../chunk-R2V7IXWN.js";import{b as K,c as w,d as b,g as L,h as U,i as O,j,k as T,l as S}from"../chunk-W6T7MOKY.js";import{a as Le}from"../chunk-MYITGTGJ.js";import"../chunk-IXE5THUW.js";import"../chunk-FUUTGGJS.js";var gt="kanonak.org",yt="document-ast",m=t=>({publisher:gt,package_:yt,name:t}),k={Document:m("Document"),Block:m("Block"),Inline:m("Inline"),StructuredValue:m("StructuredValue"),Heading:m("Heading"),Paragraph:m("Paragraph"),RawBlock:m("RawBlock"),Text:m("Text"),StructuredMap:m("StructuredMap"),StructuredEntry:m("StructuredEntry"),StructuredList:m("StructuredList"),StringScalar:m("StringScalar"),IntegerScalar:m("IntegerScalar"),EscapeHint:m("EscapeHint"),MediaType:m("MediaType"),metadata:m("metadata"),children:m("children"),level:m("level"),inlines:m("inlines"),text:m("text"),entries:m("entries"),key:m("key"),value:m("value"),escapeHint:m("escapeHint"),items:m("items"),stringValue:m("stringValue"),integerValue:m("integerValue"),rawContent:m("rawContent"),mediaType:m("mediaType"),mimeType:m("mimeType"),ESC_RAW:m("esc-raw"),ESC_YAML_SAFE:m("esc-yaml-safe"),ESC_TOML_STRING:m("esc-toml-string"),ESC_TOML_MULTILINE:m("esc-toml-multiline"),ESC_JSON:m("esc-json"),ESC_DYNAMODB_BOOL:m("esc-dynamodb-bool"),ESC_DYNAMODB_NUMBER:m("esc-dynamodb-number"),ESC_DYNAMODB_NULL:m("esc-dynamodb-null"),TEXT_PLAIN:m("text-plain"),TEXT_MARKDOWN:m("text-markdown"),TEXT_HTML:m("text-html"),TEXT_CSS:m("text-css"),APPLICATION_JSON:m("application-json"),TEXT_YAML:m("text-yaml"),IMAGE_SVG_XML:m("image-svg-xml"),ResourceLink:m("ResourceLink"),target:m("target"),linkLabel:m("linkLabel"),PropertyList:m("PropertyList"),propertyEntries:m("propertyEntries"),PropertyEntry:m("PropertyEntry"),propertyKey:m("propertyKey"),propertyValue:m("propertyValue"),Table:m("Table"),tableColumnLabels:m("tableColumnLabels"),tableRows:m("tableRows"),TableRow:m("TableRow"),tableCells:m("tableCells")};function Ne(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var Y=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(e,n){let r=kt(e.metadata,n),a=wt(e.children),u=["---",...r,"---","",a].join(`
|
|
2
2
|
`);return n?.trailingNewline&&(u.endsWith(`
|
|
3
3
|
`)||(u+=`
|
|
4
|
-
`)),u}};function
|
|
4
|
+
`)),u}};function kt(t,e){if(!t)return[];let n=new Map;for(let c of t.entries)n.set(ue(c.key),c);let r=new Map;if(e?.metadataRenames)for(let[c,l]of e.metadataRenames)r.set(ue(c),l);let i=(e?.metadataKeys??t.entries.map(c=>c.key)).map(ue),u=[];for(let c of i){let l=n.get(c);if(!l)continue;let p=r.get(c),y=ue(p??c),h=Ie(l.value,l.escapeHint);h!==void 0&&u.push(`${y}: ${h}`)}return u}function ue(t){let e=t.lastIndexOf(".");return e===-1?t:t.substring(e+1)||t}function Ie(t,e){switch(t.kind){case"StringScalar":return ht(t.stringValue,e);case"IntegerScalar":return String(t.integerValue);case"StructuredList":{let n=[];for(let r of t.items){let a=Ie(r,e);a!==void 0&&n.push(a)}return n.join(", ")}case"StructuredMap":return;default:return}}function ht(t,e){return!e||Ne(e,k.ESC_RAW)?t:Ne(e,k.ESC_YAML_SAFE)?bt(t):t}function bt(t){return t.includes(`
|
|
5
5
|
`)?`|-
|
|
6
6
|
${t.replace(/\n/g,`
|
|
7
|
-
`).trimEnd()}`:/[:#\[\]{}&*!|>'"%@`,]/.test(t)?`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:t}function
|
|
7
|
+
`).trimEnd()}`:/[:#\[\]{}&*!|>'"%@`,]/.test(t)?`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:t}function wt(t){let e=[];for(let n of t){let r=he(n);r&&e.push(r)}return e.join(`
|
|
8
8
|
|
|
9
|
-
`)}function
|
|
10
|
-
`)}function
|
|
9
|
+
`)}function he(t){switch(t.kind){case"Heading":return`${"#".repeat(t.level)} ${ce(t.inlines)}`;case"Paragraph":return ce(t.inlines);case"RawBlock":return t.rawContent;case"PropertyList":return Me(t);case"Table":return St(t);default:return""}}function St(t){let e=t.tableColumnLabels??[],n=t.tableRows??[];if(e.length===0&&n.length===0)return"";let r=`| ${e.map(ke).join(" | ")} |`,a=`| ${e.map(()=>"---").join(" | ")} |`,i=n.map(u=>`| ${(u.tableCells??[]).map(Et).join(" | ")} |`);return[r,a,...i].join(`
|
|
10
|
+
`)}function Et(t){let e=t;return!e||typeof e!="object"||!e.kind?"":e.kind==="Text"||e.kind==="ResourceLink"||e.kind==="Badge"?ke(ce([e])):ke(he(e).replace(/\n+/g," "))}function ke(t){return t==null?"":String(t).replace(/\|/g,"\\|")}function Me(t,e=0){if(!t.propertyEntries||t.propertyEntries.length===0)return"";let n=" ".repeat(e),r=[];for(let a of t.propertyEntries){let i=`${n}**${a.propertyKey}:**`,u=vt(a.propertyValue,e+1);u.includes(`
|
|
11
11
|
`)?r.push(`${i}
|
|
12
12
|
${u}`):r.push(`${i} ${u}`)}return r.join(`
|
|
13
13
|
|
|
14
|
-
`)}function
|
|
14
|
+
`)}function vt(t,e){if(!t||t.length===0)return"";let n=[],r=[];for(let a of t){let i=a;!i||typeof i!="object"||!i.kind||(i.kind==="Text"||i.kind==="ResourceLink"||i.kind==="Badge"?n.push(ce([i])):i.kind==="PropertyList"?r.push(Me(i,e)):r.push(he(i)))}return r.length===0?n.join(""):n.length===0?r.join(`
|
|
15
15
|
|
|
16
16
|
`):`${n.join("")}
|
|
17
17
|
|
|
18
18
|
${r.join(`
|
|
19
19
|
|
|
20
|
-
`)}`}function
|
|
20
|
+
`)}`}function ce(t){let e=[];for(let n of t)n.kind==="Text"?e.push(n.text):n.kind==="ResourceLink"?e.push($t(n)):n.kind==="Badge"&&e.push(Vt(n));return e.join("")}function $t(t){let e=Pe(t.target);if(!e)return t.linkLabel??"[unresolved link]";let n=F(e),r=t.linkLabel&&t.linkLabel.length>0?t.linkLabel:e.name,a=t.linkTooltip?` "${_e(t.linkTooltip)}"`:"";return`[${r}](${n}${a})`}function Vt(t){if(!t.badgeTarget)return`*${t.badgeLabel}*`;let e=Pe(t.badgeTarget);if(!e)return`*${t.badgeLabel}*`;let n=F(e),r=t.badgeTooltip?` "${_e(t.badgeTooltip)}"`:"";return`*[${t.badgeLabel}](${n}${r})*`}function _e(t){return t==null?"":String(t).replace(/"/g,'\\"')}function Pe(t){if(!t||typeof t!="object")return;let e=t;if(e.subject&&e.subject.publisher&&e.subject.package_&&e.subject.name){let r={publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name};return e.subject.version&&(r.version=e.subject.version),r}let n=t;if(typeof n.namespace=="string"&&typeof n.name=="string"&&n.name.length>0){let r=/^([^/]+)\/([^@]+)@(\d+)\.(\d+)\.(\d+)$/.exec(n.namespace);if(r)return{publisher:r[1],package_:r[2],name:n.name,version:{major:Number(r[3]),minor:Number(r[4]),patch:Number(r[5])}}}}function jt(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var Z=class{backendUri="kanonak.org/transformations/toml";render(e,n){let a=At(e.metadata,n).join(`
|
|
21
21
|
`);return n?.trailingNewline&&(a.endsWith(`
|
|
22
22
|
`)||(a+=`
|
|
23
|
-
`)),a}};function
|
|
23
|
+
`)),a}};function At(t,e){if(!t)return[];let n=new Map;for(let i of t.entries)n.set(i.key,i);let r=e?.metadataKeys??t.entries.map(i=>i.key),a=[];for(let i of r){let u=n.get(i);if(!u)continue;let c=e?.metadataRenames.get(i)??i,l=Fe(u.value,u.escapeHint);l!==void 0&&a.push(`${c} = ${l}`)}return a}function Fe(t,e){switch(t.kind){case"StringScalar":return Dt(t.stringValue,e);case"IntegerScalar":return String(t.integerValue);case"StructuredList":{let n=[];for(let r of t.items){let a=Fe(r,e);a!==void 0&&n.push(a)}return`[${n.join(", ")}]`}case"StructuredMap":return;default:return}}function Dt(t,e){return e&&jt(e,k.ESC_TOML_MULTILINE)?Tt(t):Kt(t)}function Kt(t){return`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n")}"`}function Tt(t){return`"""
|
|
24
24
|
${t.replace(/"""/g,'\\"\\"\\"')}
|
|
25
25
|
"""`}var Q=class{backendUri="kanonak.org/transformations/json";render(e,n){let r=JSON.stringify(e,null,2);return n?.trailingNewline&&!r.endsWith(`
|
|
26
26
|
`)?r+`
|
|
27
|
-
`:r}};function
|
|
28
|
-
`).split(`
|
|
29
|
-
`),n=[],r=0;for(;r<e.length;){let a=e[r];if(a.trim()===""){r++;continue}let i=/^(\s*)```(\S*)\s*$/.exec(a);if(i){let l=i[2],m=[];for(r++;r<e.length&&!/^(\s*)```\s*$/.test(e[r]);)m.push(e[r]),r++;r++;let g=ze(m.join(`
|
|
30
|
-
`)),k=l?` class="language-${Ge(l)}"`:"";n.push(`<pre><code${k}>${g}</code></pre>`);continue}let u=/^(#{1,6})\s+(.*)$/.exec(a);if(u){let l=u[1].length,m=H(u[2].trim());n.push(`<h${l}>${m}</h${l}>`),r++;continue}if(a.includes("|")&&r+1<e.length&&He(e[r+1])){let l=we(a),m=Ot(e[r+1]);r+=2;let g=[];for(;r<e.length&&e[r].trim()!==""&&e[r].includes("|");)g.push(we(e[r])),r++;n.push(Nt(l,m,g));continue}if(/^\s*[-*]\s+/.test(a)){let l=[];for(;r<e.length&&/^\s*[-*]\s+/.test(e[r]);){let m=[e[r].replace(/^\s*[-*]\s+/,"")];for(r++;r<e.length&&e[r].trim()!==""&&!/^\s*[-*]\s+/.test(e[r])&&!/^\s*\d+\.\s+/.test(e[r]);)m.push(e[r]),r++;r<e.length&&e[r].trim()===""&&r++,l.push(`<li>${H(m.join(" ").trim())}</li>`)}n.push(`<ul>
|
|
31
|
-
${l.join(`
|
|
32
|
-
`)}
|
|
33
|
-
</ul>`);continue}if(/^\s*\d+\.\s+/.test(a)){let l=[];for(;r<e.length&&/^\s*\d+\.\s+/.test(e[r]);){let m=[e[r].replace(/^\s*\d+\.\s+/,"")];for(r++;r<e.length&&e[r].trim()!==""&&!/^\s*\d+\.\s+/.test(e[r])&&!/^\s*[-*]\s+/.test(e[r]);)m.push(e[r]),r++;r<e.length&&e[r].trim()===""&&r++,l.push(`<li>${H(m.join(" ").trim())}</li>`)}n.push(`<ol>
|
|
34
|
-
${l.join(`
|
|
35
|
-
`)}
|
|
36
|
-
</ol>`);continue}let c=[a];for(r++;r<e.length&&e[r].trim()!==""&&!/^(#{1,6})\s+/.test(e[r])&&!/^(\s*)```/.test(e[r])&&!/^\s*[-*]\s+/.test(e[r])&&!/^\s*\d+\.\s+/.test(e[r])&&!(e[r].includes("|")&&r+1<e.length&&He(e[r+1]));)c.push(e[r]),r++;n.push(`<p>${H(c.join(" "))}</p>`)}return n.join(`
|
|
37
|
-
`)}function He(t){return t.includes("-")?/^[\s|:-]+$/.test(t):!1}function we(t){let e=t.trim();return e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&(e=e.slice(0,-1)),e.split("|").map(n=>n.trim())}function Ot(t){return we(t).map(e=>{let n=e.startsWith(":"),r=e.endsWith(":");return n&&r?"center":r?"right":n?"left":null})}function Nt(t,e,n){let r=u=>{let c=e[u];return c?` style="text-align:${c}"`:""},a=t.map((u,c)=>`<th${r(c)}>${H(u)}</th>`).join(""),i=n.map(u=>`<tr>${u.map((l,m)=>`<td${r(m)}>${H(l)}</td>`).join("")}</tr>`).join(`
|
|
38
|
-
`);return`<table>
|
|
39
|
-
<thead><tr>${a}</tr></thead>
|
|
40
|
-
<tbody>
|
|
41
|
-
${i}
|
|
42
|
-
</tbody>
|
|
43
|
-
</table>`}function H(t){let e=ze(t);return e=e.replace(/`([^`\n]+)`/g,(n,r)=>`<code>${r}</code>`),e=e.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(n,r,a)=>`<a href="${Ge(a)}">${r}</a>`),e=e.replace(/\*\*([^*\n]+)\*\*/g,(n,r)=>`<strong>${r}</strong>`),e=e.replace(/(^|[^*])\*([^*\n]+)\*(?!\*)/g,(n,r,a)=>`${r}<em>${a}</em>`),e=e.replace(/(^|[\s(])_([^_\n]+)_(?=[\s).,;:!?]|$)/g,(n,r,a)=>`${r}<em>${a}</em>`),e}function ze(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ge(t){return t.replace(/"/g,""").replace(/&/g,"&")}function Se(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var ee=class{backendUri="kanonak.org/transformations/html";render(e,n){let r=It(e.children);if(n?.omitWrapper){let c=r.endsWith(`
|
|
27
|
+
`:r}};function be(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var x=class{backendUri="kanonak.org/transformations/html";render(e,n){let r=Rt(e.children);if(n?.omitWrapper){let c=r.endsWith(`
|
|
44
28
|
`)?r:`${r}
|
|
45
29
|
`;return n.trailingNewline===!1&&c.endsWith(`
|
|
46
|
-
`)?c.slice(0,-1):c}let a=
|
|
30
|
+
`)?c.slice(0,-1):c}let a=Bt(e.metadata)??"Untitled",i=Lt(e.metadata,n),u=`<!DOCTYPE html>
|
|
47
31
|
<html lang="en">
|
|
48
32
|
<head>
|
|
49
33
|
<meta charset="utf-8">
|
|
@@ -73,35 +57,35 @@ ${i}${r}
|
|
|
73
57
|
</body>
|
|
74
58
|
</html>
|
|
75
59
|
`;return n?.trailingNewline===!1&&u.endsWith(`
|
|
76
|
-
`)?u.slice(0,-1):u}};function
|
|
60
|
+
`)?u.slice(0,-1):u}};function Bt(t){if(t){for(let e of t.entries)if((e.key==="title"||e.key==="name")&&e.value.kind==="StringScalar")return e.value.stringValue}}function Lt(t,e){if(!t||t.entries.length===0)return"";let n=e?.metadataKeys??t.entries.map(i=>i.key),r=new Map(t.entries.map(i=>[i.key,i])),a=[];for(let i of n){let u=r.get(i);if(!u)continue;let c=e?.metadataRenames.get(i)??i,l=qe(u.value);l!==void 0&&a.push(` <dt>${N(c)}</dt>
|
|
77
61
|
<dd>${l}</dd>`)}return a.length===0?"":`<dl class="metadata">
|
|
78
62
|
${a.join(`
|
|
79
63
|
`)}
|
|
80
64
|
</dl>
|
|
81
|
-
`}function
|
|
82
|
-
`)}function
|
|
65
|
+
`}function qe(t){switch(t.kind){case"StringScalar":return N(t.stringValue);case"IntegerScalar":return String(t.integerValue);case"StructuredList":{let e=[];for(let n of t.items){let r=qe(n);r!==void 0&&e.push(`<code>${r}</code>`)}return e.join(", ")}case"StructuredMap":return;default:return}}function Rt(t){let e=[];for(let n of t){let r=we(n);r&&e.push(r)}return e.join(`
|
|
66
|
+
`)}function we(t){switch(t.kind){case"Heading":{let e=Math.max(1,Math.min(6,t.level));return`<h${e}>${de(t.inlines)}</h${e}>`}case"Paragraph":return`<p>${de(t.inlines)}</p>`;case"RawBlock":return Mt(t);case"PropertyList":return Nt(t);case"Table":return Ct(t);default:return""}}function Ct(t){let e=t.tableColumnLabels??[],n=t.tableRows??[],r=e.length>0?`<thead>
|
|
83
67
|
<tr>${e.map(i=>`<th>${N(i)}</th>`).join("")}</tr>
|
|
84
68
|
</thead>
|
|
85
69
|
`:"",a=n.length>0?`<tbody>
|
|
86
|
-
${n.map(
|
|
70
|
+
${n.map(Ut).join(`
|
|
87
71
|
`)}
|
|
88
72
|
</tbody>
|
|
89
73
|
`:"";return`<table class="property-table">
|
|
90
|
-
${r}${a}</table>`}function
|
|
74
|
+
${r}${a}</table>`}function Ut(t){return` <tr>${(t.tableCells??[]).map(r=>`<td>${Ot(r)}</td>`).join("")}</tr>`}function Ot(t){let e=t;return!e||typeof e!="object"||!e.kind?"":e.kind==="Text"||e.kind==="ResourceLink"||e.kind==="Badge"?de([e]):we(e)}function Nt(t){if(!t.propertyEntries||t.propertyEntries.length===0)return"";let e=[];for(let n of t.propertyEntries){let a=`<dt${n.propertyTooltip?` title="${H(n.propertyTooltip)}"`:""}>${N(n.propertyKey)}</dt>`,i=`<dd>${It(n.propertyValue)}</dd>`;e.push(a,i)}return`<dl class="property-list">
|
|
91
75
|
${e.join(`
|
|
92
76
|
`)}
|
|
93
|
-
</dl>`}function
|
|
77
|
+
</dl>`}function It(t){if(!t||t.length===0)return"";let e=[];for(let n of t){let r=n;!r||typeof r!="object"||!r.kind||(r.kind==="Text"||r.kind==="ResourceLink"||r.kind==="Badge"?e.push(de([r])):e.push(we(r)))}return e.join("")}function Mt(t){let e=t.mediaType;return e&&be(e,k.TEXT_MARKDOWN)?X(t.rawContent):e&&be(e,k.TEXT_HTML)?t.rawContent:e&&be(e,k.IMAGE_SVG_XML)?`<figure class="svg-figure">
|
|
94
78
|
${t.rawContent}
|
|
95
|
-
</figure>`:`<pre${e?` class="media-${
|
|
79
|
+
</figure>`:`<pre${e?` class="media-${H(e.name)}"`:""}><code>${N(t.rawContent)}</code></pre>`}function de(t){let e=[];for(let n of t)n.kind==="Text"?e.push(N(n.text)):n.kind==="ResourceLink"?e.push(_t(n)):n.kind==="Badge"&&e.push(Pt(n));return e.join("")}function _t(t){let e=We(t.target);if(!e)return N(t.linkLabel??"[unresolved link]");let n=F(e),r=t.linkLabel&&t.linkLabel.length>0?t.linkLabel:e.name,a=t.linkTooltip?` title="${H(t.linkTooltip)}"`:"";return`<a class="kan-link" href="${H(n)}"${a}>${N(r)}</a>`}function Pt(t){let e=t.badgeTooltip?` title="${H(t.badgeTooltip)}"`:"",n=N(t.badgeLabel);if(!t.badgeTarget)return`<span class="kan-badge"${e}>${n}</span>`;let r=We(t.badgeTarget);if(!r)return`<span class="kan-badge"${e}>${n}</span>`;let a=F(r);return`<a class="kan-badge" href="${H(a)}"${e}>${n}</a>`}function We(t){if(!t||typeof t!="object")return;let e=t;if(e.subject&&e.subject.publisher&&e.subject.package_&&e.subject.name){let r={publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name};return e.subject.version&&(r.version=e.subject.version),r}let n=t;if(typeof n.namespace=="string"&&typeof n.name=="string"&&n.name.length>0){let r=/^([^/]+)\/([^@]+)@(\d+)\.(\d+)\.(\d+)$/.exec(n.namespace);if(r)return{publisher:r[1],package_:r[2],name:n.name,version:{major:Number(r[3]),minor:Number(r[4]),patch:Number(r[5])}}}}function N(t){return t==null?"":String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function H(t){return t==null?"":String(t).replace(/"/g,""").replace(/&/g,"&")}function Ft(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var ee=class{backendUri="kanonak.org/transformations/svg";render(e,n){for(let r of e.children)if(r.kind==="RawBlock"&&r.mediaType&&Ft(r.mediaType,k.IMAGE_SVG_XML)){let a=r.rawContent;return n?.trailingNewline&&!a.endsWith(`
|
|
96
80
|
`)&&(a+=`
|
|
97
|
-
`),a}return'<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>'}};function
|
|
81
|
+
`),a}return'<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>'}};function qt(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var te=class{backendUri="kanonak.org/transformations/stylesheet";render(e,n){let r=[];for(let i of e.children)i.kind==="RawBlock"&&i.mediaType&&qt(i.mediaType,k.TEXT_CSS)&&r.push(i.rawContent);let a=r.join(`
|
|
98
82
|
|
|
99
83
|
`);return n?.trailingNewline&&a.length>0&&!a.endsWith(`
|
|
100
84
|
`)&&(a+=`
|
|
101
|
-
`),a}};function
|
|
85
|
+
`),a}};function Wt(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var ne=class{backendUri="kanonak.org/transformations/yaml";render(e,n){let r=[];for(let i of e.children)i.kind==="RawBlock"&&i.mediaType&&Wt(i.mediaType,k.TEXT_YAML)&&r.push(i.rawContent);let a=r.join(`
|
|
102
86
|
|
|
103
87
|
`);return n?.trailingNewline&&a.length>0&&!a.endsWith(`
|
|
104
88
|
`)&&(a+=`
|
|
105
|
-
`),a}};function
|
|
89
|
+
`),a}};function re(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var ae=class{backendUri="kanonak.org/transformations/dynamodb-json";render(e,n){if(!e.metadata)throw new Error("dynamodb-json backend: Document has no `metadata` channel. This backend serializes Document.metadata into DynamoDB attribute-value JSON \u2014 the transformation must populate that channel. (No silent empty artifact.)");let r=He(e.metadata,n),a=JSON.stringify(r,null,2);return n?.trailingNewline&&!a.endsWith(`
|
|
106
90
|
`)&&(a+=`
|
|
107
|
-
`),a}};function Ye(t,e){let n=new Map;for(let i of t.entries)n.set(i.key,i);let r=e?.metadataKeys??t.entries.map(i=>i.key),a={};for(let i of r){let u=n.get(i);if(!u)continue;let c=e?.metadataRenames.get(i)??i;a[c]=Ze(u.value,u.escapeHint)}return{M:a}}function Ze(t,e){switch(t.kind){case"StructuredMap":return Ye(t);case"StructuredList":return{L:t.items.map(n=>Ze(n,void 0))};case"StringScalar":return Qt(t.stringValue,e??t.escapeHint);case"IntegerScalar":return xt(t.integerValue,e??t.escapeHint)}}function Qt(t,e){if(e&&ae(e,h.ESC_DYNAMODB_BOOL)){if(t==="true")return{BOOL:!0};if(t==="false")return{BOOL:!1};throw new Error(`dynamodb-json backend: a StringScalar hinted esc-dynamodb-bool must have the value "true" or "false"; got ${JSON.stringify(t)}.`)}if(e&&ae(e,h.ESC_DYNAMODB_NULL))return{NULL:!0};if(e&&ae(e,h.ESC_DYNAMODB_NUMBER)){if(t.trim()===""||Number.isNaN(Number(t)))throw new Error(`dynamodb-json backend: a StringScalar hinted esc-dynamodb-number must hold a numeric literal; got ${JSON.stringify(t)}.`);return{N:t}}return{S:t}}function xt(t,e){if(e&&ae(e,h.ESC_DYNAMODB_BOOL))throw new Error(`dynamodb-json backend: esc-dynamodb-bool cannot apply to an IntegerScalar (value ${t}). Use a StringScalar "true"/"false".`);if(e&&ae(e,h.ESC_DYNAMODB_NULL))throw new Error(`dynamodb-json backend: esc-dynamodb-null cannot apply to an IntegerScalar (value ${t}). Use a StringScalar hinted esc-dynamodb-null.`);return{N:String(t)}}var oe=class{constructor(e,n,r){this.repository=e;this.parser=n;this.objectParser=r}repository;parser;objectParser;cache=new Map;async resolveSubject(e,n){let r=M(n,e);if(r)return r;let a=e.version,i=a&&typeof a.major=="number"?`@${a.major}.${a.minor}.${a.patch}`:"",u=`${e.publisher}/${e.package_}${i}`,c=this.cache.get(u);if(!c){let m=await this.repository.getDocumentsByNamespaceAsync(e.publisher,e.package_);if(m.length===0)return;let g=a&&typeof a.major=="number"?m.find(D=>{let v=D.metadata?.namespace_?.version;return v&&v.major===a.major&&v.minor===a.minor&&v.patch===a.patch})??m[0]:m[0],k=new Ne(g,this.repository);c=await this.objectParser.parseKanonaks(k),this.cache.set(u,c)}let l=M(c,e);if(l)return l;for(let m of c)if(m instanceof w&&m.name===e.name)return m}};var en="kanonak.org",tn="transformations",ir=3,s=t=>({publisher:en,package_:tn,name:t}),o={Transformation:s("Transformation"),InstanceTransformation:s("InstanceTransformation"),SetTransformation:s("SetTransformation"),inputPattern:s("inputPattern"),rule:s("rule"),artifactName:s("artifactName"),outputs:s("outputs"),formatOverrides:s("formatOverrides"),partitionBy:s("partitionBy"),InputPattern:s("InputPattern"),matchesClass:s("matchesClass"),requires:s("requires"),sortBy:s("sortBy"),SortKey:s("SortKey"),byProperty:s("byProperty"),order:s("order"),SortOrder:s("SortOrder"),ascending:s("ascending"),descending:s("descending"),OutputFormat:s("OutputFormat"),backendUri:s("backendUri"),FormatOverride:s("FormatOverride"),formatTarget:s("formatTarget"),metadataKeys:s("metadataKeys"),metadataRenames:s("metadataRenames"),trailingNewline:s("trailingNewline"),omitWrapper:s("omitWrapper"),RenameEntry:s("RenameEntry"),fromKey:s("fromKey"),toKey:s("toKey"),FMT_MARKDOWN_FRONTMATTER:s("markdown-with-frontmatter"),FMT_PLAIN_MARKDOWN:s("plain-markdown"),FMT_TOML:s("toml"),FMT_JSON:s("json"),FMT_HTML:s("html"),FMT_SVG:s("svg"),Expression:s("Expression"),ListSourcedExpression:s("ListSourcedExpression"),ListAggregate:s("ListAggregate"),IteratingExpression:s("IteratingExpression"),BuildAstNode:s("BuildAstNode"),astClass:s("astClass"),set:s("set"),AstFieldBinding:s("AstFieldBinding"),field:s("field"),bindValue:s("bindValue"),When:s("When"),condition:s("condition"),thenBuild:s("thenBuild"),elseBuild:s("elseBuild"),Concat:s("Concat"),parts:s("parts"),Fallback:s("Fallback"),primary:s("primary"),alternate:s("alternate"),StringLiteral:s("StringLiteral"),stringLiteral:s("stringLiteral"),IntegerLiteral:s("IntegerLiteral"),integerLiteral:s("integerLiteral"),DecimalLiteral:s("DecimalLiteral"),decimalLiteral:s("decimalLiteral"),BooleanLiteral:s("BooleanLiteral"),booleanLiteral:s("booleanLiteral"),VarRef:s("VarRef"),varName:s("varName"),PropertyRead:s("PropertyRead"),readSource:s("readSource"),readProp:s("readProp"),Traverse:s("Traverse"),traverseSource:s("traverseSource"),through:s("through"),step:s("step"),UriName:s("UriName"),uriNameOf:s("uriNameOf"),UriPublisher:s("UriPublisher"),uriPublisherOf:s("uriPublisherOf"),UriPackage:s("UriPackage"),uriPackageOf:s("uriPackageOf"),UriVersion:s("UriVersion"),uriVersionOf:s("uriVersionOf"),SubjectUri:s("SubjectUri"),subjectOf:s("subjectOf"),UriLiteral:s("UriLiteral"),refTo:s("refTo"),DisplayLabel:s("DisplayLabel"),labelTarget:s("labelTarget"),labelSource:s("labelSource"),ResolveRef:s("ResolveRef"),resolveSource:s("resolveSource"),Normalize:s("Normalize"),normSource:s("normSource"),normKind:s("normKind"),NormalizeKind:s("NormalizeKind"),NORM_TRIM_END:s("trim-end"),IsSet:s("IsSet"),checkExpr:s("checkExpr"),ExpressionFragment:s("ExpressionFragment"),body:s("body"),CallFragment:s("CallFragment"),fragmentRef:s("fragmentRef"),source:s("source"),Join:s("Join"),separator:s("separator"),Count:s("Count"),Sum:s("Sum"),Min:s("Min"),Max:s("Max"),Average:s("Average"),loopVar:s("loopVar"),ForEach:s("ForEach"),emit:s("emit"),ListMap:s("ListMap"),mapBody:s("mapBody"),Filter:s("Filter"),predicate:s("predicate"),PartitionBy:s("PartitionBy"),partitionKey:s("partitionKey"),DistinctBy:s("DistinctBy"),distinctKey:s("distinctKey"),Partition:s("Partition"),key:s("key"),members:s("members"),AllStatements:s("AllStatements"),statementsOf:s("statementsOf"),StatementPredicate:s("StatementPredicate"),predicateOf:s("predicateOf"),StatementValue:s("StatementValue"),valueOf:s("valueOf"),DateFormat:s("DateFormat"),dateSource:s("dateSource"),dateFormat:s("dateFormat"),BinaryArithmetic:s("BinaryArithmetic"),arithLeft:s("arithLeft"),arithRight:s("arithRight"),Add:s("Add"),Subtract:s("Subtract"),Multiply:s("Multiply"),Divide:s("Divide"),Reverse:s("Reverse"),WindowedMap:s("WindowedMap"),windowSize:s("windowSize"),windowVar:s("windowVar"),windowBody:s("windowBody"),PairwiseMap:s("PairwiseMap"),firstVar:s("firstVar"),secondVar:s("secondVar"),pairBody:s("pairBody"),Scan:s("Scan"),initialState:s("initialState"),stateVar:s("stateVar"),elementVar:s("elementVar"),accumulate:s("accumulate"),ListItemAt:s("ListItemAt"),itemIndex:s("itemIndex"),BinaryComparison:s("BinaryComparison"),compareLeft:s("compareLeft"),compareRight:s("compareRight"),Equals:s("Equals"),GreaterThan:s("GreaterThan"),LessThan:s("LessThan"),GreaterThanOrEqual:s("GreaterThanOrEqual"),LessThanOrEqual:s("LessThanOrEqual"),Not:s("Not"),operand:s("operand"),BooleanLogic:s("BooleanLogic"),operands:s("operands"),And:s("And"),Or:s("Or"),Contains:s("Contains"),haystack:s("haystack"),needle:s("needle"),UnaryNumericOp:s("UnaryNumericOp"),value:s("value"),Abs:s("Abs"),Negate:s("Negate"),KindPredicate:s("KindPredicate"),IsReference:s("IsReference"),IsEmbedded:s("IsEmbedded"),IsList:s("IsList"),kindCheck:s("kindCheck"),IsString:s("IsString"),IsNumber:s("IsNumber"),IsBoolean:s("IsBoolean"),StatementObject:s("StatementObject"),statementSource:s("statementSource"),Let:s("Let"),letName:s("letName"),letValue:s("letValue"),letBody:s("letBody"),GetStatementByName:s("GetStatementByName"),inSubject:s("inSubject"),byName:s("byName"),RenderMarkdown:s("RenderMarkdown"),renderSource:s("renderSource"),renderProp:s("renderProp"),renderFormat:s("renderFormat"),RenderFormat:s("RenderFormat"),RENDER_HTML:s("render-html"),RENDER_MARKDOWN:s("render-markdown")};var y=class extends Error{constructor(n,r){super(`${n} (at ${r})`);this.path=r}path};function me(t,e){let n=t.name,r=mn(e),a={catalog:e,depth:0};if(f(t,o.InstanceTransformation))return nn(t,n,a,r);if(f(t,o.SetTransformation))return rn(t,n,a,r);throw new y("Subject is not a recognized v3 transformation type \u2014 expected InstanceTransformation or SetTransformation",n)}function nn(t,e,n,r){return{kind:"instance",name:t.name,inputPattern:rt(t,e),rule:fe(t,o.rule,`${e}.rule`,n),artifactName:fe(t,o.artifactName,`${e}.artifactName`,n),outputs:at(t,`${e}.outputs`),overrides:it(t,`${e}.formatOverrides`,n),fragments:r}}function rn(t,e,n,r){let a=I(t,o.partitionBy);return{kind:"set",name:t.name,inputPattern:rt(t,e),rule:fe(t,o.rule,`${e}.rule`,n),artifactName:fe(t,o.artifactName,`${e}.artifactName`,n),outputs:at(t,`${e}.outputs`),overrides:it(t,`${e}.formatOverrides`,n),partitionBy:a,fragments:r}}function rt(t,e){let n=se(t,o.inputPattern);if(!n)throw new y("inputPattern is required",e);return an(n,`${e}.inputPattern`)}function an(t,e){let n=I(t,o.matchesClass);if(!n)throw new y("matchesClass is required",e);let r=[];for(let u of A(t,o.requires))if(u instanceof V)r.push(je(u.object.subject));else if(u instanceof S)for(let c of u.object)c instanceof b&&r.push(je(c.subject));let a=[],i=0;for(let u of A(t,o.sortBy))if(u instanceof S)for(let c of u.object)c instanceof C&&a.push(Qe(c,`${e}.sortBy[${i++}]`));else u instanceof T&&a.push(Qe(u.object,`${e}.sortBy[${i++}]`));return{matchesClass:n,requires:r,sortBy:a}}function Qe(t,e){let n=I(t,o.byProperty);if(!n)throw new y("SortKey.byProperty is required",e);let r=I(t,o.order);if(!r)throw new y("SortKey.order is required",e);if(E(r,o.ascending))return{byProperty:n,order:"ascending"};if(E(r,o.descending))return{byProperty:n,order:"descending"};throw new y(`SortKey.order must reference tx.ascending or tx.descending; got ${r.publisher}/${r.package_}/${r.name}`,e)}function fe(t,e,n,r){let a=se(t,e);if(!a)throw new y("expression is required",n);return J(a,n,r)}function J(t,e,n){if(f(t,o.StringLiteral))return{kind:"string-literal",value:j(t,o.stringLiteral,e)};if(f(t,o.IntegerLiteral))return{kind:"integer-literal",value:nt(t,o.integerLiteral,e)};if(f(t,o.DecimalLiteral))return{kind:"decimal-literal",value:nt(t,o.decimalLiteral,e)};if(f(t,o.BooleanLiteral))return{kind:"boolean-literal",value:yn(t,o.booleanLiteral,e)};if(f(t,o.VarRef))return{kind:"var-ref",varName:j(t,o.varName,e)};if(f(t,o.PropertyRead))return{kind:"property-read",source:d(t,o.readSource,`${e}.readSource`,n),readProp:q(t,o.readProp,e,"readProp")};if(f(t,o.Traverse))return{kind:"traverse",source:d(t,o.traverseSource,`${e}.traverseSource`,n),through:q(t,o.through,e,"through"),step:d(t,o.step,`${e}.step`,n)};if(f(t,o.BuildAstNode))return{kind:"build-ast-node",astClass:q(t,o.astClass,e,"astClass"),set:sn(t,`${e}.set`,n)};if(f(t,o.When))return{kind:"when",condition:d(t,o.condition,`${e}.condition`,n),thenBuild:d(t,o.thenBuild,`${e}.thenBuild`,n),elseBuild:on(t,o.elseBuild,`${e}.elseBuild`,n)};if(f(t,o.Concat))return{kind:"concat",parts:$e(t,o.parts,`${e}.parts`,n)};if(f(t,o.Fallback))return{kind:"fallback",primary:d(t,o.primary,`${e}.primary`,n),alternate:d(t,o.alternate,`${e}.alternate`,n)};if(f(t,o.UriName))return{kind:"uri-name",source:d(t,o.uriNameOf,`${e}.uriNameOf`,n)};if(f(t,o.UriPublisher))return{kind:"uri-publisher",source:d(t,o.uriPublisherOf,`${e}.uriPublisherOf`,n)};if(f(t,o.UriPackage))return{kind:"uri-package",source:d(t,o.uriPackageOf,`${e}.uriPackageOf`,n)};if(f(t,o.UriVersion))return{kind:"uri-version",source:d(t,o.uriVersionOf,`${e}.uriVersionOf`,n)};if(f(t,o.SubjectUri))return{kind:"subject-uri",source:d(t,o.subjectOf,`${e}.subjectOf`,n)};if(f(t,o.UriLiteral))return{kind:"uri-literal",refTo:q(t,o.refTo,e,"refTo")};if(f(t,o.DisplayLabel))return{kind:"display-label",labelTarget:q(t,o.labelTarget,e,"labelTarget"),labelSource:q(t,o.labelSource,e,"labelSource")};if(f(t,o.ResolveRef))return{kind:"resolve-ref",source:d(t,o.resolveSource,`${e}.resolveSource`,n)};if(f(t,o.Normalize))return{kind:"normalize",source:d(t,o.normSource,`${e}.normSource`,n),normKind:un(t,e)};if(f(t,o.RenderMarkdown))return{kind:"render-markdown",source:d(t,o.renderSource,`${e}.renderSource`,n),readProp:q(t,o.renderProp,e,"renderProp"),format:cn(t,e)};if(f(t,o.IsSet))return{kind:"is-set",check:d(t,o.checkExpr,`${e}.checkExpr`,n)};if(f(t,o.CallFragment))return dn(t,e,n);if(f(t,o.Join))return{kind:"join",source:d(t,o.source,`${e}.source`,n),separator:j(t,o.separator,e)};if(f(t,o.Count))return{kind:"count",source:d(t,o.source,`${e}.source`,n)};if(f(t,o.Sum))return{kind:"sum",source:d(t,o.source,`${e}.source`,n)};if(f(t,o.Min))return{kind:"min",source:d(t,o.source,`${e}.source`,n)};if(f(t,o.Max))return{kind:"max",source:d(t,o.source,`${e}.source`,n)};if(f(t,o.Average))return{kind:"average",source:d(t,o.source,`${e}.source`,n)};if(f(t,o.ForEach))return{kind:"for-each",source:d(t,o.source,`${e}.source`,n),loopVar:j(t,o.loopVar,e),emit:d(t,o.emit,`${e}.emit`,n)};if(f(t,o.ListMap))return{kind:"list-map",source:d(t,o.source,`${e}.source`,n),loopVar:j(t,o.loopVar,e),mapBody:d(t,o.mapBody,`${e}.mapBody`,n)};if(f(t,o.Filter))return{kind:"filter",source:d(t,o.source,`${e}.source`,n),loopVar:j(t,o.loopVar,e),predicate:d(t,o.predicate,`${e}.predicate`,n)};if(f(t,o.PartitionBy))return{kind:"partition-by",source:d(t,o.source,`${e}.source`,n),loopVar:j(t,o.loopVar,e),partitionKey:d(t,o.partitionKey,`${e}.partitionKey`,n)};if(f(t,o.DistinctBy))return{kind:"distinct-by",source:d(t,o.source,`${e}.source`,n),loopVar:j(t,o.loopVar,e),distinctKey:d(t,o.distinctKey,`${e}.distinctKey`,n)};if(f(t,o.AllStatements))return{kind:"all-statements",source:d(t,o.statementsOf,`${e}.statementsOf`,n)};if(f(t,o.StatementPredicate))return{kind:"statement-predicate",source:d(t,o.predicateOf,`${e}.predicateOf`,n)};if(f(t,o.StatementValue))return{kind:"statement-value",source:d(t,o.valueOf,`${e}.valueOf`,n)};if(f(t,o.DateFormat))return{kind:"date-format",source:d(t,o.dateSource,`${e}.dateSource`,n),format:ln(t,e)};if(f(t,o.Add))return{kind:"add",left:d(t,o.arithLeft,`${e}.arithLeft`,n),right:d(t,o.arithRight,`${e}.arithRight`,n)};if(f(t,o.Subtract))return{kind:"subtract",left:d(t,o.arithLeft,`${e}.arithLeft`,n),right:d(t,o.arithRight,`${e}.arithRight`,n)};if(f(t,o.Multiply))return{kind:"multiply",left:d(t,o.arithLeft,`${e}.arithLeft`,n),right:d(t,o.arithRight,`${e}.arithRight`,n)};if(f(t,o.Divide))return{kind:"divide",left:d(t,o.arithLeft,`${e}.arithLeft`,n),right:d(t,o.arithRight,`${e}.arithRight`,n)};if(f(t,o.Reverse))return{kind:"reverse",source:d(t,o.source,`${e}.source`,n)};if(f(t,o.WindowedMap)){let r=ot(t,o.windowSize);if(r===void 0||!Number.isInteger(r)||r<1)throw new y("windowSize must be a positive integer",`${e}.windowSize`);return{kind:"windowed-map",source:d(t,o.source,`${e}.source`,n),windowSize:r,windowVar:j(t,o.windowVar,e),windowBody:d(t,o.windowBody,`${e}.windowBody`,n)}}if(f(t,o.PairwiseMap))return{kind:"pairwise-map",source:d(t,o.source,`${e}.source`,n),firstVar:j(t,o.firstVar,e),secondVar:j(t,o.secondVar,e),pairBody:d(t,o.pairBody,`${e}.pairBody`,n)};if(f(t,o.Scan))return{kind:"scan",source:d(t,o.source,`${e}.source`,n),initialState:d(t,o.initialState,`${e}.initialState`,n),stateVar:j(t,o.stateVar,e),elementVar:j(t,o.elementVar,e),accumulate:d(t,o.accumulate,`${e}.accumulate`,n)};if(f(t,o.ListItemAt))return{kind:"list-item-at",source:d(t,o.source,`${e}.source`,n),itemIndex:d(t,o.itemIndex,`${e}.itemIndex`,n)};if(f(t,o.Equals))return{kind:"equals",left:d(t,o.compareLeft,`${e}.compareLeft`,n),right:d(t,o.compareRight,`${e}.compareRight`,n)};if(f(t,o.GreaterThan))return{kind:"greater-than",left:d(t,o.compareLeft,`${e}.compareLeft`,n),right:d(t,o.compareRight,`${e}.compareRight`,n)};if(f(t,o.LessThan))return{kind:"less-than",left:d(t,o.compareLeft,`${e}.compareLeft`,n),right:d(t,o.compareRight,`${e}.compareRight`,n)};if(f(t,o.GreaterThanOrEqual))return{kind:"greater-than-or-equal",left:d(t,o.compareLeft,`${e}.compareLeft`,n),right:d(t,o.compareRight,`${e}.compareRight`,n)};if(f(t,o.LessThanOrEqual))return{kind:"less-than-or-equal",left:d(t,o.compareLeft,`${e}.compareLeft`,n),right:d(t,o.compareRight,`${e}.compareRight`,n)};if(f(t,o.Not))return{kind:"not",operand:d(t,o.operand,`${e}.operand`,n)};if(f(t,o.And))return{kind:"and",operands:$e(t,o.operands,`${e}.operands`,n)};if(f(t,o.Or))return{kind:"or",operands:$e(t,o.operands,`${e}.operands`,n)};if(f(t,o.Contains))return{kind:"contains",haystack:d(t,o.haystack,`${e}.haystack`,n),needle:d(t,o.needle,`${e}.needle`,n)};if(f(t,o.Abs))return{kind:"abs",value:d(t,o.value,`${e}.value`,n)};if(f(t,o.Negate))return{kind:"negate",value:d(t,o.value,`${e}.value`,n)};if(f(t,o.IsReference))return{kind:"is-reference",check:d(t,o.kindCheck,`${e}.kindCheck`,n)};if(f(t,o.IsEmbedded))return{kind:"is-embedded",check:d(t,o.kindCheck,`${e}.kindCheck`,n)};if(f(t,o.IsList))return{kind:"is-list",check:d(t,o.kindCheck,`${e}.kindCheck`,n)};if(f(t,o.IsString))return{kind:"is-string",check:d(t,o.kindCheck,`${e}.kindCheck`,n)};if(f(t,o.IsNumber))return{kind:"is-number",check:d(t,o.kindCheck,`${e}.kindCheck`,n)};if(f(t,o.IsBoolean))return{kind:"is-boolean",check:d(t,o.kindCheck,`${e}.kindCheck`,n)};if(f(t,o.StatementObject))return{kind:"statement-object",source:d(t,o.statementSource,`${e}.statementSource`,n)};if(f(t,o.Let))return{kind:"let",bindName:j(t,o.letName,e),bindValue:d(t,o.letValue,`${e}.letValue`,n),body:d(t,o.letBody,`${e}.letBody`,n)};if(f(t,o.GetStatementByName))return{kind:"get-statement-by-name",inSubject:d(t,o.inSubject,`${e}.inSubject`,n),byName:d(t,o.byName,`${e}.byName`,n)};throw new y("Expression is not of a recognized v3 type \u2014 embedded has no matching subclass of tx.Expression",e)}function d(t,e,n,r){let a=se(t,e);if(!a)throw new y("child expression is required",n);return J(a,n,r)}function on(t,e,n,r){let a=se(t,e);if(a)return J(a,n,r)}function $e(t,e,n,r){let a=[],i=0;for(let u of A(t,e))if(u instanceof S)for(let c of u.object)c instanceof C&&a.push(J(c,`${n}[${i++}]`,r));else u instanceof T&&a.push(J(u.object,`${n}[${i++}]`,r));return a}function sn(t,e,n){let r=[],a=0;for(let i of A(t,o.set))if(i instanceof S)for(let u of i.object)u instanceof C&&r.push(xe(u,`${e}[${a++}]`,n));else i instanceof T&&r.push(xe(i.object,`${e}[${a++}]`,n));return r}function xe(t,e,n){return{field:q(t,o.field,e,"field"),value:d(t,o.bindValue,`${e}.bindValue`,n)}}function un(t,e){let n=I(t,o.normKind);if(!n)throw new y("normKind is required",e);if(E(n,o.NORM_TRIM_END))return"trim-end";throw new y(`Unknown NormalizeKind: ${n.publisher}/${n.package_}/${n.name}`,e)}function cn(t,e){let n=I(t,o.renderFormat);if(!n)throw new y("renderFormat is required",e);if(E(n,o.RENDER_HTML))return"html";if(E(n,o.RENDER_MARKDOWN))return"markdown";throw new y(`Unknown RenderFormat: ${n.publisher}/${n.package_}/${n.name}`,e)}var et=new Set(["iso-date","iso-datetime","short-date","long-date","year","month-year"]);function ln(t,e){let n=G(t,o.dateFormat);if(!n)throw new y("dateFormat is required",e);if(!et.has(n))throw new y(`Unknown dateFormat "${n}"; supported: ${[...et].join(", ")}`,e);return n}function dn(t,e,n){let r=I(t,o.fragmentRef);if(!r)throw new y("fragmentRef is required",e);if(!pn(n.catalog,r))throw new y(`ExpressionFragment not found: ${r.publisher}/${r.package_}/${r.name}`,e);return{kind:"call-fragment",fragmentKey:fn(r)}}function fn(t){return`${t.publisher}/${t.package_}/${t.name}`}function mn(t){let e=new Map,n=[];for(let r of t){if(!(r instanceof w)||!f(r,o.ExpressionFragment))continue;let a=se(r,o.body);if(!a)continue;let i=(r.namespace||"").split("@")[0]||"",u=i.indexOf("/");if(u<0)continue;let c=i.substring(0,u),l=i.substring(u+1),m=`${c}/${l}/${r.name}`;n.push({key:m,subject:r,bodyEmb:a,pubPkgName:`${i}/${r.name}`})}for(let r of n){let a=J(r.bodyEmb,`fragment(${r.pubPkgName})`,{catalog:t,depth:0});e.set(r.key,a)}return e}function pn(t,e){for(let n of t)if(!(!(n instanceof w)||n.name!==e.name||!(n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))&&f(n,o.ExpressionFragment))return n}function at(t,e){let n=new Set;for(let r of A(t,o.outputs))if(r instanceof V)n.add(r.object.subject.name);else if(r instanceof S)for(let a of r.object)a instanceof b&&n.add(a.subject.name);if(n.size===0)throw new y("outputs is required (at least one OutputFormat)",e);return n}function it(t,e,n){let r=new Map,a=0;for(let i of A(t,o.formatOverrides))if(i instanceof S){for(let u of i.object)if(u instanceof C){let[c,l]=tt(u,`${e}[${a++}]`);r.set(c,l)}}else if(i instanceof T){let[u,c]=tt(i.object,`${e}[${a++}]`);r.set(u,c)}return r}function tt(t,e){let n=I(t,o.formatTarget);if(!n)throw new y("formatTarget is required",e);let r=[];for(let c of A(t,o.metadataKeys))if(c instanceof B)r.push(c.object);else if(c instanceof S)for(let l of c.object){let m=l.value;typeof m=="string"&&r.push(m)}let a=new Map;for(let c of A(t,o.metadataRenames))if(c instanceof S){for(let l of c.object)if(l instanceof C){let m=G(l,o.fromKey),g=G(l,o.toKey);m&&g&&a.set(m,g)}}else if(c instanceof T){let l=c.object,m=G(l,o.fromKey),g=G(l,o.toKey);m&&g&&a.set(m,g)}let i=ve(t,o.trailingNewline),u=ve(t,o.omitWrapper);return[n.name,{metadataKeys:r.length>0?r:void 0,metadataRenames:a,trailingNewline:i,omitWrapper:u}]}function gn(t){return t.predicate?.subject}function A(t,e){let n=[];for(let r of t.statement){let a=gn(r);a&&E(a,e)&&n.push(r)}return n}function se(t,e){for(let n of A(t,e))if(n instanceof T)return n.object}function I(t,e){for(let n of A(t,e))if(n instanceof V)return je(n.object.subject)}function G(t,e){for(let n of A(t,e))if(n instanceof B)return n.object}function ot(t,e){for(let n of A(t,e))if(n instanceof U)return n.object}function ve(t,e){for(let n of A(t,e))if(n instanceof O)return n.object}function j(t,e,n){let r=G(t,e);if(r===void 0)throw new y(`${e.name} (string) is required`,n);return r}function nt(t,e,n){let r=ot(t,e);if(r===void 0)throw new y(`${e.name} (number) is required`,n);return r}function yn(t,e,n){let r=ve(t,e);if(r===void 0)throw new y(`${e.name} (boolean) is required`,n);return r}function q(t,e,n,r){let a=I(t,e);if(!a)throw new y(`${r} (URI reference) is required`,n);return a}function je(t){return{publisher:t.publisher,package_:t.package_,name:t.name}}var kn={publisher:"kanonak.org",package_:"core-rdf",name:"label"},_=class extends Error{},ge=class{constructor(e,n,r=new Map){this.resolver=e;this.catalog=n;this.fragments=r}resolver;catalog;fragments;async evaluate(e,n){switch(e.kind){case"string-literal":return e.value;case"integer-literal":return e.value;case"decimal-literal":return e.value;case"boolean-literal":return e.value;case"uri-literal":return{...e.refTo};case"var-ref":{if(!n.has(e.varName))throw new _(`Unbound variable "${e.varName}"`);return n.get(e.varName)}case"concat":{let r=[];for(let a of e.parts){let i=await this.evaluate(a,n);if(i!=null)if(Array.isArray(i))for(let u of i)r.push(u);else r.push(i)}return r}case"fallback":{let r=await this.evaluate(e.primary,n);return st(r)?r:this.evaluate(e.alternate,n)}case"when":return await this.evaluate(e.condition,n)===!0?this.evaluate(e.thenBuild,n):e.elseBuild?this.evaluate(e.elseBuild,n):void 0;case"is-set":{let r=await this.evaluate(e.check,n);return st(r)}case"property-read":{let r=await this.evaluate(e.source,n);return pe(r,e.readProp)}case"traverse":{let r=await this.evaluate(e.source,n);if(!(r instanceof K))return;let a=bn(r,e.through),i=[];for(let u of a){let c=await this.resolver.resolveSubject(u,this.catalog);if(!c)continue;let l=new Map(n);l.set("input",c);let m=await this.evaluate(e.step,l);m!=null&&i.push(ue(m))}return i.join("")}case"uri-name":{let r=await this.evaluate(e.source,n);return X(r)?r.name:r instanceof b?r.subject.name:r instanceof w?r.name:r instanceof C?r.name??"":void 0}case"uri-publisher":{let r=await this.evaluate(e.source,n);return Ve(r)?.publisher}case"uri-package":{let r=await this.evaluate(e.source,n);return Ve(r)?.package_}case"uri-version":{let r=await this.evaluate(e.source,n);return Ve(r)?.version}case"subject-uri":{let r=await this.evaluate(e.source,n);if(r instanceof w){let a=r.namespace??"",i=r.name??"";return!a||!i?void 0:`${a}/${i}`}if(r instanceof b){let a=r.subject,i=a.version;return i&&typeof i.major=="number"?`${a.publisher}/${a.package_}@${i.major}.${i.minor}.${i.patch}/${a.name}`:`${a.publisher}/${a.package_}/${a.name}`}return}case"display-label":{let r=await this.resolver.resolveSubject({...e.labelTarget},this.catalog);return r?pe(r,e.labelSource):void 0}case"resolve-ref":{let r=await this.evaluate(e.source,n);return r instanceof w?r:r instanceof b?await this.resolver.resolveSubject(r.subject,this.catalog):X(r)?await this.resolver.resolveSubject(r,this.catalog):void 0}case"normalize":{let r=await this.evaluate(e.source,n),a=r==null?"":ue(r);return e.normKind==="trim-end"?a.replace(/[\s\r\n]+$/u,""):a}case"render-markdown":{let r=await this.evaluate(e.source,n);if(!(r instanceof K))return;let a;for(let u of r.statement){let c=De(u);if(c&&E(c,e.readProp)){a=u;break}}if(!(a instanceof Ue)){let u=pe(r,e.readProp);return u==null?void 0:ue(u)}let i=await this.renderMarkdownLinks(a);return e.format==="html"?x(i):i}case"build-ast-node":{let r={kind:e.astClass.name};for(let a of e.set){let i=await this.evaluate(a.value,n);if(i==null||Array.isArray(i)&&i.length===0)continue;let u=a.field.name;Sn.has(u)&&(Array.isArray(i)&&i.every(c=>ut(c))?i=i.map(c=>String(c)).join(""):ut(i)&&(i=String(i))),r[u]=i}return r}case"call-fragment":{let r=this.fragments.get(e.fragmentKey);if(!r)throw new _(`ExpressionFragment ${e.fragmentKey} not found in registry`);return this.evaluate(r,n)}case"join":return(await this.evaluateList(e.source,n)).map(a=>a==null?"":ue(a)).join(e.separator);case"count":return(await this.evaluateList(e.source,n)).length;case"sum":{let r=await this.evaluateList(e.source,n),a=0;for(let i of r)a+=$(i,"Sum");return a}case"min":{let r=await this.evaluateList(e.source,n);if(r.length===0)throw new _("Min on an empty list is undefined; guard with IsSet");let a=$(r[0],"Min");for(let i=1;i<r.length;i++){let u=$(r[i],"Min");u<a&&(a=u)}return a}case"max":{let r=await this.evaluateList(e.source,n);if(r.length===0)throw new _("Max on an empty list is undefined; guard with IsSet");let a=$(r[0],"Max");for(let i=1;i<r.length;i++){let u=$(r[i],"Max");u>a&&(a=u)}return a}case"average":{let r=await this.evaluateList(e.source,n);if(r.length===0)throw new _("Average on an empty list is undefined; guard with IsSet");let a=0;for(let i of r)a+=$(i,"Average");return a/r.length}case"for-each":{let r=await this.evaluateList(e.source,n),a=[];for(let i of r){let u=new Map(n);u.set(e.loopVar,L(i));let c=await this.evaluate(e.emit,u);if(c!=null)if(Array.isArray(c))for(let l of c)a.push(l);else a.push(c)}return a}case"list-map":{let r=await this.evaluateList(e.source,n),a=[];for(let i of r){let u=new Map(n);u.set(e.loopVar,L(i)),a.push(await this.evaluate(e.mapBody,u))}return a}case"filter":{let r=await this.evaluateList(e.source,n),a=[];for(let i of r){let u=new Map(n);u.set(e.loopVar,L(i)),await this.evaluate(e.predicate,u)===!0&&a.push(i)}return a}case"partition-by":{let r=await this.evaluateList(e.source,n),a=new Map,i=[];for(let u of r){let c=new Map(n);c.set(e.loopVar,L(u));let l=await this.evaluate(e.partitionKey,c),m=dt(l),g=a.get(m);g||(g={kind:"Partition",key:l,members:[]},a.set(m,g),i.push(m)),g.members.push(u)}return i.map(u=>a.get(u))}case"distinct-by":{let r=await this.evaluateList(e.source,n),a=new Set,i=[];for(let u of r){let c=new Map(n);c.set(e.loopVar,L(u));let l=await this.evaluate(e.distinctKey,c),m=dt(l);a.has(m)||(a.add(m),i.push(u))}return i}case"all-statements":{let r=await this.evaluate(e.source,n);return r instanceof K?r.statement:[]}case"statement-predicate":{let r=await this.evaluate(e.source,n);if(Ae(r)){let a=r.predicate;if(a instanceof b)return a}return}case"statement-value":{let r=await this.evaluate(e.source,n);return Ae(r)?vn(r):void 0}case"date-format":{let r=await this.evaluate(e.source,n),a=r==null?"":ue(r);return a?$n(a,e.format):""}case"add":{let r=$(await this.evaluate(e.left,n),"Add"),a=$(await this.evaluate(e.right,n),"Add");return r+a}case"subtract":{let r=$(await this.evaluate(e.left,n),"Subtract"),a=$(await this.evaluate(e.right,n),"Subtract");return r-a}case"multiply":{let r=$(await this.evaluate(e.left,n),"Multiply"),a=$(await this.evaluate(e.right,n),"Multiply");return r*a}case"divide":{let r=$(await this.evaluate(e.left,n),"Divide"),a=$(await this.evaluate(e.right,n),"Divide");if(a===0)throw new _("Divide by zero; guard with When");return r/a}case"reverse":{if(e.source.kind==="reverse")return this.evaluate(e.source.source,n);let r=await this.evaluateReverseIterator(e.source,n);return r!==void 0?r:[...await this.evaluateList(e.source,n)].reverse()}case"windowed-map":{let r=await this.evaluateList(e.source,n);if(r.length<e.windowSize)return[];let a=[];for(let i=0;i+e.windowSize<=r.length;i++){let u=r.slice(i,i+e.windowSize),c=new Map(n);c.set(e.windowVar,u);let l=await this.evaluate(e.windowBody,c);if(l!=null)if(Array.isArray(l))for(let m of l)a.push(m);else a.push(l)}return a}case"pairwise-map":{let r=await this.evaluateList(e.source,n);if(r.length<2)return[];let a=[];for(let i=0;i+1<r.length;i++){let u=new Map(n);u.set(e.firstVar,L(r[i])),u.set(e.secondVar,L(r[i+1]));let c=await this.evaluate(e.pairBody,u);if(c!=null)if(Array.isArray(c))for(let l of c)a.push(l);else a.push(c)}return a}case"scan":{let r=await this.evaluateList(e.source,n);if(r.length===0)return[];let a=await this.evaluate(e.initialState,n),i=[];for(let u of r){let c=new Map(n);c.set(e.stateVar,a),c.set(e.elementVar,L(u));let l=await this.evaluate(e.accumulate,c);i.push(l),a=l}return i}case"list-item-at":{let r=await this.evaluateList(e.source,n),a=await this.evaluate(e.itemIndex,n);return typeof a!="number"||!Number.isInteger(a)||a<0||a>=r.length?void 0:r[a]}case"equals":{let r=await this.evaluate(e.left,n),a=await this.evaluate(e.right,n);return ct(r,a)}case"greater-than":{let r=await this.evaluate(e.left,n),a=await this.evaluate(e.right,n);return typeof r!="number"||typeof a!="number"?!1:r>a}case"less-than":{let r=await this.evaluate(e.left,n),a=await this.evaluate(e.right,n);return typeof r!="number"||typeof a!="number"?!1:r<a}case"greater-than-or-equal":{let r=await this.evaluate(e.left,n),a=await this.evaluate(e.right,n);return typeof r!="number"||typeof a!="number"?!1:r>=a}case"less-than-or-equal":{let r=await this.evaluate(e.left,n),a=await this.evaluate(e.right,n);return typeof r!="number"||typeof a!="number"?!1:r<=a}case"not":{let r=await this.evaluate(e.operand,n);return r===!0?!1:r===!1?!0:void 0}case"and":{for(let r of e.operands)if(await this.evaluate(r,n)!==!0)return!1;return!0}case"or":{for(let r of e.operands)if(await this.evaluate(r,n)===!0)return!0;return!1}case"contains":{let r=await this.evaluateList(e.haystack,n),a=await this.evaluate(e.needle,n);for(let i of r)if(ct(i,a))return!0;return!1}case"abs":{let r=$(await this.evaluate(e.value,n),"Abs");return Math.abs(r)}case"negate":return-$(await this.evaluate(e.value,n),"Negate");case"is-reference":{let r=await this.evaluate(e.check,n);return r instanceof b||r instanceof w}case"is-embedded":return await this.evaluate(e.check,n)instanceof C;case"is-list":{let r=await this.evaluate(e.check,n);return Array.isArray(r)}case"is-string":return typeof await this.evaluate(e.check,n)=="string";case"is-number":return typeof await this.evaluate(e.check,n)=="number";case"is-boolean":return typeof await this.evaluate(e.check,n)=="boolean";case"statement-object":{let r=await this.evaluate(e.source,n);if(!Ae(r))return;let a=r;return a instanceof B||a instanceof U||a instanceof O||a instanceof V||a instanceof T||a instanceof S?a.object:void 0}case"let":{let r=await this.evaluate(e.bindValue,n),a=new Map(n);return a.set(e.bindName,r),this.evaluate(e.body,a)}case"get-statement-by-name":{let r=await this.evaluate(e.inSubject,n),a=await this.evaluate(e.byName,n);if(!(r instanceof K)||typeof a!="string")return;for(let i of r.statement)if(i.predicate?.subject?.name===a)return i;return}default:{let r=e;throw new _("Unknown expression kind")}}}async renderMarkdownLinks(e){let n=e.object,r="",a=0;for(let i of e.links){if(r+=n.slice(a,i.startOffset),i.target){let u=i.target.subject,c=i.displayText??await this.resolveLabel(u)??u.name;r+=`[${c}](${F(u)})`}else r+=i.displayText??i.reference;a=i.endOffset}return r+=n.slice(a),r}async resolveLabel(e){let n=await this.resolver.resolveSubject(e,this.catalog);if(!n)return;let r=pe(n,kn);return typeof r=="string"?r:void 0}async evaluateList(e,n){let r=await this.evaluate(e,n);return r==null?[]:Array.isArray(r)?r:[r]}async evaluateReverseIterator(e,n){if(e.kind==="pairwise-map"){let r=await this.evaluateList(e.source,n);if(r.length<2)return[];let a=[];for(let i=r.length-1;i>=1;i--){let u=new Map(n);u.set(e.firstVar,L(r[i-1])),u.set(e.secondVar,L(r[i]));let c=await this.evaluate(e.pairBody,u);if(c!=null)if(Array.isArray(c))for(let l of c)a.push(l);else a.push(c)}return a}if(e.kind==="for-each"){let r=await this.evaluateList(e.source,n),a=[];for(let i=r.length-1;i>=0;i--){let u=new Map(n);u.set(e.loopVar,L(r[i]));let c=await this.evaluate(e.emit,u);if(c!=null)if(Array.isArray(c))for(let l of c)a.push(l);else a.push(c)}return a}if(e.kind==="list-map"){let r=await this.evaluateList(e.source,n),a=[];for(let i=r.length-1;i>=0;i--){let u=new Map(n);u.set(e.loopVar,L(r[i])),a.push(await this.evaluate(e.mapBody,u))}return a}if(e.kind==="windowed-map"){let r=await this.evaluateList(e.source,n);if(r.length<e.windowSize)return[];let a=[];for(let i=r.length-e.windowSize;i>=0;i--){let u=r.slice(i,i+e.windowSize),c=new Map(n);c.set(e.windowVar,u);let l=await this.evaluate(e.windowBody,c);if(l!=null)if(Array.isArray(l))for(let m of l)a.push(m);else a.push(l)}return a}}};function pe(t,e){if(t instanceof K)return hn(t,e);if(wn(t))return E(e,o.key)?t.key:E(e,o.members)?t.members:void 0}function hn(t,e){for(let n of t.statement){let r=De(n);if(!(!r||!E(r,e))&&(n instanceof B||n instanceof U||n instanceof O||n instanceof V||n instanceof T||n instanceof S))return n.object}}function bn(t,e){let n=[];for(let r of t.statement){let a=De(r);if(!(!a||!E(a,e))){if(r instanceof V)n.push(r.object.subject);else if(r instanceof S)for(let i of r.object)i instanceof b&&n.push(i.subject)}}return n}function De(t){return t.predicate?.subject}function ue(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(t instanceof K)return t.name??"";if(t instanceof b)return t.subject.name;if(X(t))return t.name;let e=t.value;return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function L(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof K)&&!(t instanceof b)&&!(t instanceof C)&&"value"in t?t.value:t}function st(t){return t==null?!1:typeof t=="string"||Array.isArray(t)?t.length>0:typeof t=="boolean"?t===!0:!0}function X(t){return typeof t=="object"&&t!==null&&typeof t.publisher=="string"&&typeof t.package_=="string"&&typeof t.name=="string"}function wn(t){return typeof t=="object"&&t!==null&&t.kind==="Partition"&&Array.isArray(t.members)}function $(t,e){if(typeof t=="number"&&Number.isFinite(t))return t;throw new _(`${e} requires numeric elements; got ${En(t)}`)}function Ve(t){if(t instanceof w){let e=t.namespace??"",n=e.indexOf("/"),r=e.indexOf("@",n+1);return n<0||r<0?void 0:{publisher:e.substring(0,n),package_:e.substring(n+1,r),version:e.substring(r+1),name:t.name??""}}if(t instanceof b){let e=t.subject,n=e.version;return{publisher:e.publisher,package_:e.package_,version:n&&typeof n.major=="number"?`${n.major}.${n.minor}.${n.patch}`:"",name:e.name}}if(X(t))return{publisher:t.publisher,package_:t.package_,version:"",name:t.name}}var Sn=new Set(["stringValue","text","rawContent","key","propertyKey","linkLabel"]);function ut(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function En(t){return t===void 0?"undefined":t===null?"null":Array.isArray(t)?`array(${t.length})`:typeof t}function $n(t,e){let n=new Date(t);if(isNaN(n.getTime()))return"";let r=n.getUTCFullYear(),a=["January","February","March","April","May","June","July","August","September","October","November","December"][n.getUTCMonth()],i=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][n.getUTCMonth()],u=n.getUTCDate(),c=(l,m=2)=>String(l).padStart(m,"0");switch(e){case"iso-date":return`${r}-${c(n.getUTCMonth()+1)}-${c(u)}`;case"iso-datetime":return`${r}-${c(n.getUTCMonth()+1)}-${c(u)}T${c(n.getUTCHours())}:${c(n.getUTCMinutes())}:${c(n.getUTCSeconds())}Z`;case"short-date":return`${i} ${u}`;case"long-date":return`${a} ${u}, ${r}`;case"year":return String(r);case"month-year":return`${a} ${r}`}}function ct(t,e){if(t==null||e===void 0||e===null)return!1;if(t===e)return!0;let n=typeof t=="object"&&"value"in t?t.value:void 0,r=typeof e=="object"&&"value"in e?e.value:void 0,a=n??t,i=r??e,u=lt(t),c=lt(e);return u&&c?u.publisher===c.publisher&&u.package_===c.package_&&u.name===c.name:typeof a=="string"&&typeof i=="string"||typeof a=="number"&&typeof i=="number"||typeof a=="boolean"&&typeof i=="boolean"?a===i:!1}function lt(t){if(t instanceof b){let e=t.subject;return{publisher:e.publisher,package_:e.package_,name:e.name}}if(t instanceof w){let e=t.namespace??"",n=e.indexOf("/"),r=e.indexOf("@",n+1);if(n<0)return;let a=e.substring(0,n),i=r>=0?e.substring(n+1,r):e.substring(n+1);return{publisher:a,package_:i,name:t.name??""}}if(X(t))return{publisher:t.publisher,package_:t.package_,name:t.name}}function Ae(t){return t instanceof B||t instanceof U||t instanceof O||t instanceof V||t instanceof T||t instanceof S}function vn(t){return t instanceof B||t instanceof U||t instanceof O?String(t.object??""):t instanceof V?t.object?.subject?.name??"":t instanceof T?"[embedded]":t instanceof S?(t.object??[]).map(n=>{if(n instanceof b)return n.subject.name;let r=n.name;if(r&&r.length>0)return r;let a=n.value;return typeof a=="string"||typeof a=="number"||typeof a=="boolean"?String(a):"[embedded]"}).join(", "):""}function dt(t){if(t===void 0)return"\0undef";if(t===null)return"\0null";if(typeof t=="string")return`s:${t}`;if(typeof t=="number")return`n:${t}`;if(typeof t=="boolean")return`b:${t}`;if(t instanceof b){let e=t.subject;return`r:${e.publisher}/${e.package_}/${e.name}`}if(t instanceof K){let e=t.name??"";return`k:${t.namespace??""}/${e}`}return X(t)?`u:${t.publisher}/${t.package_}/${t.name}`:`o:${JSON.stringify(t)}`}var jn={"markdown-with-frontmatter":{formatUri:"kanonak.org/transformations/markdown-with-frontmatter",extension:".md"},"plain-markdown":{formatUri:"kanonak.org/transformations/plain-markdown",extension:".md"},toml:{formatUri:"kanonak.org/transformations/toml",extension:".toml"},json:{formatUri:"kanonak.org/transformations/json",extension:".json"},html:{formatUri:"kanonak.org/transformations/html",extension:".html"},svg:{formatUri:"kanonak.org/transformations/svg",extension:".svg"},stylesheet:{formatUri:"kanonak.org/transformations/stylesheet",extension:".css"},yaml:{formatUri:"kanonak.org/transformations/yaml",extension:".yaml"},"dynamodb-json":{formatUri:"kanonak.org/transformations/dynamodb-json",extension:".json"}},W=class extends Error{},ye=class{backends=new Map;constructor(){this.register(new Y),this.register(new Z),this.register(new Q),this.register(new ee),this.register(new te),this.register(new ne),this.register(new re),this.register(new ie)}register(e){this.backends.set(e.backendUri,e)}async run(e){let n=e.transformationKanonaks??e.allKanonaks,r=me(e.transformation,n);if(!r.outputs.has(e.outputFormat))throw new W(`Transformation "${r.name}" does not declare output format "${e.outputFormat}". Declared: ${Array.from(r.outputs).join(", ")}`);let a=this.findBackend(e.outputFormat);if(!a)throw new W(`No backend registered for OutputFormat "${e.outputFormat}".`);let i=new oe(e.repository,e.parser,e.objectParser),u=new ge(i,e.allKanonaks,r.fragments);return r.kind==="instance"?this.runInstance(r,e,a,u):this.runSet(r,e,a,u)}async runInstance(e,n,r,a){let i=ft(n.instances,e.inputPattern.requires),u=mt(i,e.inputPattern.sortBy),c=[];for(let l of u){let m=new Map;m.set("input",l);let g=await a.evaluate(e.rule,m);Ke(g,e.name,`input "${l.name}"`);let k=Te(await a.evaluate(e.artifactName,m),e.name,`input "${l.name}"`),D=Le(e.overrides.get(n.outputFormat),n.runtimeOverride),v=r.render(g,D);c.push({fileName:k,format:n.outputFormat,content:v,source:{kind:"instance",sourceName:l.name}})}return c}async runSet(e,n,r,a){let i=ft(n.instances,e.inputPattern.requires),u=mt(i,e.inputPattern.sortBy);return e.partitionBy?this.runSetWithPartition(e,u,n,r,a):this.runSetSingle(e,u,n,r,a)}async runSetSingle(e,n,r,a,i){let u=new Map;u.set("inputs",n);let c=await i.evaluate(e.rule,u);Ke(c,e.name,"set");let l=Te(await i.evaluate(e.artifactName,u),e.name,"set"),m=Le(e.overrides.get(r.outputFormat),r.runtimeOverride),g=a.render(c,m);return[{fileName:l,format:r.outputFormat,content:g,source:{kind:"set",memberCount:n.length}}]}async runSetWithPartition(e,n,r,a,i){let u=e.partitionBy,c=new Map,l=[];for(let g of n){let k=Dn(g,u);if(k==null)continue;let D=Kn(k),v=c.get(D);v||(v={keyValue:k,keyDisplay:Tn(k),members:[]},c.set(D,v),l.push(D)),v.members.push(g)}let m=[];for(let g of l){let k=c.get(g),D=new Map;D.set("inputs",k.members),D.set("key",k.keyValue);let v=await i.evaluate(e.rule,D);Ke(v,e.name,`partition "${k.keyDisplay}"`);let kt=Te(await i.evaluate(e.artifactName,D),e.name,`partition "${k.keyDisplay}"`),ht=Le(e.overrides.get(r.outputFormat),r.runtimeOverride),bt=a.render(v,ht);m.push({fileName:kt,format:r.outputFormat,content:bt,source:{kind:"set",memberCount:k.members.length,partitionKey:k.keyDisplay}})}return m}findBackend(e){let n=jn[e];if(n)return this.backends.get(n.formatUri)}};function ft(t,e){return e.length===0?t:t.filter(n=>{for(let r of e)if(!An(n,r))return!1;return!0})}function mt(t,e){if(e.length===0)return t;let n=[...t];return n.sort((r,a)=>{for(let i of e){let u=pt(r,i.byProperty),c=pt(a,i.byProperty),l=Vn(u,c,i.order);if(l!==0)return l}return 0}),n}function pt(t,e){for(let n of t.statement){let r=Be(n);if(!(!r||!E(r,e))){if(n instanceof B||n instanceof U||n instanceof O)return n.object;if(n instanceof S)throw new W(`Sort property "${e.name}" on instance "${t.name??"?"}" resolves to a list \u2014 list-typed properties are not sortable. Use a scalar property.`);if(n instanceof V)throw new W(`Sort property "${e.name}" on instance "${t.name??"?"}" resolves to a reference \u2014 reference-typed properties don't have a natural total order. Use a scalar property.`)}}}function Vn(t,e,n){if(t===void 0&&e===void 0)return 0;if(t===void 0)return n==="ascending"?1:-1;if(e===void 0)return n==="ascending"?-1:1;let r;return typeof t=="number"&&typeof e=="number"?r=t-e:r=String(t).localeCompare(String(e)),n==="ascending"?r:-r}function An(t,e){for(let n of t.statement){let r=Be(n);if(!r||!E(r,e))continue;let a=n.object;if(a!=null&&!(typeof a=="string"&&a.length===0)&&!(Array.isArray(a)&&a.length===0))return!0}return!1}function Dn(t,e){for(let n of t.statement){let r=Be(n);if(!(!r||!E(r,e))&&(n instanceof B||n instanceof U||n instanceof O||n instanceof V||n instanceof S))return n.object}}function Be(t){return t.predicate?.subject}function Kn(t){if(t===void 0)return" undef";if(t===null)return" null";if(typeof t=="string")return`s:${t}`;if(typeof t=="number")return`n:${t}`;if(typeof t=="boolean")return`b:${t}`;if(t instanceof b){let e=t.subject;return`r:${e.publisher}/${e.package_}/${e.name}`}if(t instanceof K){let e=t.name??"";return`k:${t.namespace??""}/${e}`}if(typeof t=="object"&&t!==null&&typeof t.name=="string"&&typeof t.publisher=="string"){let e=t;return`u:${e.publisher}/${e.package_}/${e.name}`}return`o:${JSON.stringify(t)}`}function Tn(t){return t==null?"":typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"?String(t):t instanceof b?t.subject.name:t instanceof K?t.name??"":typeof t=="object"&&t!==null&&typeof t.name=="string"?t.name:""}function Ke(t,e,n){if(typeof t!="object"||t===null||t.kind!=="Document")throw new W(`Transformation "${e}" rule did not yield a Document for ${n}. Got: ${gt(t)}`)}function Te(t,e,n){if(typeof t=="string")return t;if(Array.isArray(t)&&t.every(Ln))return t.map(r=>String(r)).join("");throw new W(`Transformation "${e}" artifactName did not yield a string for ${n}. Got: ${gt(t)}`)}function Ln(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function gt(t){if(t===void 0)return"undefined";if(t===null)return"null";if(Array.isArray(t))return`array(${t.length})`;if(typeof t=="object"){let e=t.kind;return e?`object(kind=${e})`:"object"}return typeof t}function Le(t,e){if(!t&&!e)return;let n={metadataRenames:e?.metadataRenames??t?.metadataRenames??new Map},r=e?.metadataKeys??t?.metadataKeys;r!==void 0&&(n.metadataKeys=r);let a=e?.trailingNewline??t?.trailingNewline;a!==void 0&&(n.trailingNewline=a);let i=e?.omitWrapper??t?.omitWrapper;return i!==void 0&&(n.omitWrapper=i),n}var R=class extends Error{constructor(n,r){super(n);this.cause=r;this.name="RenderError"}cause},yt={publisher:"kanonak.org",package_:"derivation",name:"default"},Re=class{constructor(e,n=new Ce,r=new Oe){this.repository=e;this.parser=n;this.objectParser=r}repository;parser;objectParser;runner=new ye;cachedCatalog=void 0;invalidate(){this.cachedCatalog=void 0}async renderViaLook(e){let n=await this.getCatalog(),r=M(n,e.resource);if(!(r instanceof w))throw new R(`Resource not found: ${P(e.resource)}`);let a=new ke(n),i;if(e.format.name==="html")i=a.renderHtml(r);else if(e.format.name==="stylesheet")i=a.renderStylesheet(r);else throw new R(`LookRenderer does not support format ${P(e.format)} \u2014 only formats.html and formats.stylesheet are implemented in v0.1.`);return{content:i,format:e.format,filename:r.name}}async findDerivation(e){let n=await this.getCatalog(),r=M(n,e.resource);if(!(r instanceof w))return;let a=e.variant??yt;return _e(r,e.format,a,n)}async render(e){if(e.format.name==="html"||e.format.name==="stylesheet"){let a=await this.getCatalog(),i=M(a,e.resource);if(i instanceof w){let c=new ke(a).findCascadedLook(i);if(c&&!Rn(c.sourceClass)){let l=await this.findDerivation(e);if(!l||Bn(l))return this.renderViaLook({resource:e.resource,format:e.format})}}}let n=await this.findDerivation(e);if(!n)throw new R(`No derivation found for ${P(e.resource)} \u2192 format ${P(e.format)}`+(e.variant?` variant ${P(e.variant)}`:""));let r={transformation:{publisher:n.transformation.publisher,package_:n.transformation.package_,name:n.transformation.name},input:e.resource,format:e.format};return e.omitWrapper!==void 0&&(r.omitWrapper=e.omitWrapper),this.runTransformation(r)}async runTransformation(e){let n=await this.getCatalog(),r=M(n,e.transformation);if(!(r instanceof w))throw new R(`Transformation not found: ${P(e.transformation)}`);let a=M(n,e.input);if(!(a instanceof w))throw new R(`Input resource not found: ${P(e.input)}`);let i=me(r,n),u=Cn(i.outputs,e.format);if(!u)throw new R(`Transformation ${P(e.transformation)} declares outputs [${[...i.outputs].join(", ")}], none of which corresponds to format ${P(e.format)}`);let c;try{c=await this.runner.run({transformation:r,instances:[a],allKanonaks:n,repository:this.repository,parser:this.parser,objectParser:this.objectParser,outputFormat:u,...e.omitWrapper!==void 0?{runtimeOverride:{metadataRenames:new Map,omitWrapper:e.omitWrapper}}:{}})}catch(l){throw new R(`Transformation execution failed: ${l.message}`,l)}if(c.length===0)throw new R("Transformation produced no artifacts");return{content:c[0].content,format:e.format,filename:c[0].fileName}}async getCatalog(){return this.cachedCatalog||(this.cachedCatalog=await this.objectParser.parseKanonaks(this.repository)),this.cachedCatalog}};function P(t){return`${t.publisher}/${t.package_}/${t.name}`}function Bn(t){return typeof t.source=="string"?!1:t.source.publisher==="kanonak.org"&&t.source.package_==="core-rdf"&&t.source.name==="Resource"}function Rn(t){return t.publisher==="kanonak.org"&&t.package_==="core-rdf"&&t.name==="Resource"}function Cn(t,e){let n=e.name;if(t.has(n))return n;for(let r of t)if(r.startsWith(n+"-")||r===n)return r}export{ne as CssBackend,yt as DEFAULT_VARIANT,h as DOCAST,St as DOCAST_PKG,wt as DOCAST_PUB,ie as DynamoDbBackend,ge as ExpressionEngineV3,_ as ExpressionEvalErrorV3,ee as HtmlBackend,Q as JsonBackend,Y as MarkdownFrontmatterBackend,oe as ReferenceResolver,R as RenderError,jn as SUPPORTED_FORMATS_V3,te as SvgBackend,o as TX_V3,tn as TX_V3_PKG,en as TX_V3_PUB,ir as TX_V3_VERSION_MAJOR,Z as TomlBackend,Re as TransformationEngine,y as TransformationLoadErrorV3,W as TransformationRunnerErrorV3,ye as TransformationRunnerV3,re as YamlBackend,me as compileTransformationV3,x as renderMarkdownToHtml};
|
|
91
|
+
`),a}};function He(t,e){let n=new Map;for(let i of t.entries)n.set(i.key,i);let r=e?.metadataKeys??t.entries.map(i=>i.key),a={};for(let i of r){let u=n.get(i);if(!u)continue;let c=e?.metadataRenames.get(i)??i;a[c]=ze(u.value,u.escapeHint)}return{M:a}}function ze(t,e){switch(t.kind){case"StructuredMap":return He(t);case"StructuredList":return{L:t.items.map(n=>ze(n,void 0))};case"StringScalar":return Ht(t.stringValue,e??t.escapeHint);case"IntegerScalar":return zt(t.integerValue,e??t.escapeHint)}}function Ht(t,e){if(e&&re(e,k.ESC_DYNAMODB_BOOL)){if(t==="true")return{BOOL:!0};if(t==="false")return{BOOL:!1};throw new Error(`dynamodb-json backend: a StringScalar hinted esc-dynamodb-bool must have the value "true" or "false"; got ${JSON.stringify(t)}.`)}if(e&&re(e,k.ESC_DYNAMODB_NULL))return{NULL:!0};if(e&&re(e,k.ESC_DYNAMODB_NUMBER)){if(t.trim()===""||Number.isNaN(Number(t)))throw new Error(`dynamodb-json backend: a StringScalar hinted esc-dynamodb-number must hold a numeric literal; got ${JSON.stringify(t)}.`);return{N:t}}return{S:t}}function zt(t,e){if(e&&re(e,k.ESC_DYNAMODB_BOOL))throw new Error(`dynamodb-json backend: esc-dynamodb-bool cannot apply to an IntegerScalar (value ${t}). Use a StringScalar "true"/"false".`);if(e&&re(e,k.ESC_DYNAMODB_NULL))throw new Error(`dynamodb-json backend: esc-dynamodb-null cannot apply to an IntegerScalar (value ${t}). Use a StringScalar hinted esc-dynamodb-null.`);return{N:String(t)}}var ie=class{constructor(e,n,r){this.repository=e;this.parser=n;this.objectParser=r}repository;parser;objectParser;cache=new Map;async resolveSubject(e,n){let r=M(n,e);if(r)return r;let a=e.version,i=a&&typeof a.major=="number"?`@${a.major}.${a.minor}.${a.patch}`:"",u=`${e.publisher}/${e.package_}${i}`,c=this.cache.get(u);if(!c){let p=await this.repository.getDocumentsByNamespaceAsync(e.publisher,e.package_);if(p.length===0)return;let y=a&&typeof a.major=="number"?p.find(D=>{let $=D.metadata?.namespace_?.version;return $&&$.major===a.major&&$.minor===a.minor&&$.patch===a.patch})??p[0]:p[0],h=new Ue(y,this.repository);c=await this.objectParser.parseKanonaks(h),this.cache.set(u,c)}let l=M(c,e);if(l)return l;for(let p of c)if(p instanceof w&&p.name===e.name)return p}};var Gt="kanonak.org",Jt="transformations",Zn=3,s=t=>({publisher:Gt,package_:Jt,name:t}),o={Transformation:s("Transformation"),InstanceTransformation:s("InstanceTransformation"),SetTransformation:s("SetTransformation"),inputPattern:s("inputPattern"),rule:s("rule"),artifactName:s("artifactName"),outputs:s("outputs"),formatOverrides:s("formatOverrides"),partitionBy:s("partitionBy"),InputPattern:s("InputPattern"),matchesClass:s("matchesClass"),requires:s("requires"),sortBy:s("sortBy"),SortKey:s("SortKey"),byProperty:s("byProperty"),order:s("order"),SortOrder:s("SortOrder"),ascending:s("ascending"),descending:s("descending"),OutputFormat:s("OutputFormat"),backendUri:s("backendUri"),FormatOverride:s("FormatOverride"),formatTarget:s("formatTarget"),metadataKeys:s("metadataKeys"),metadataRenames:s("metadataRenames"),trailingNewline:s("trailingNewline"),omitWrapper:s("omitWrapper"),RenameEntry:s("RenameEntry"),fromKey:s("fromKey"),toKey:s("toKey"),FMT_MARKDOWN_FRONTMATTER:s("markdown-with-frontmatter"),FMT_PLAIN_MARKDOWN:s("plain-markdown"),FMT_TOML:s("toml"),FMT_JSON:s("json"),FMT_HTML:s("html"),FMT_SVG:s("svg"),Expression:s("Expression"),ListSourcedExpression:s("ListSourcedExpression"),ListAggregate:s("ListAggregate"),IteratingExpression:s("IteratingExpression"),BuildAstNode:s("BuildAstNode"),astClass:s("astClass"),set:s("set"),AstFieldBinding:s("AstFieldBinding"),field:s("field"),bindValue:s("bindValue"),When:s("When"),condition:s("condition"),thenBuild:s("thenBuild"),elseBuild:s("elseBuild"),Concat:s("Concat"),parts:s("parts"),Fallback:s("Fallback"),primary:s("primary"),alternate:s("alternate"),StringLiteral:s("StringLiteral"),stringLiteral:s("stringLiteral"),IntegerLiteral:s("IntegerLiteral"),integerLiteral:s("integerLiteral"),DecimalLiteral:s("DecimalLiteral"),decimalLiteral:s("decimalLiteral"),BooleanLiteral:s("BooleanLiteral"),booleanLiteral:s("booleanLiteral"),VarRef:s("VarRef"),varName:s("varName"),PropertyRead:s("PropertyRead"),readSource:s("readSource"),readProp:s("readProp"),Traverse:s("Traverse"),traverseSource:s("traverseSource"),through:s("through"),step:s("step"),UriName:s("UriName"),uriNameOf:s("uriNameOf"),UriPublisher:s("UriPublisher"),uriPublisherOf:s("uriPublisherOf"),UriPackage:s("UriPackage"),uriPackageOf:s("uriPackageOf"),UriVersion:s("UriVersion"),uriVersionOf:s("uriVersionOf"),SubjectUri:s("SubjectUri"),subjectOf:s("subjectOf"),UriLiteral:s("UriLiteral"),refTo:s("refTo"),DisplayLabel:s("DisplayLabel"),labelTarget:s("labelTarget"),labelSource:s("labelSource"),ResolveRef:s("ResolveRef"),resolveSource:s("resolveSource"),Normalize:s("Normalize"),normSource:s("normSource"),normKind:s("normKind"),NormalizeKind:s("NormalizeKind"),NORM_TRIM_END:s("trim-end"),IsSet:s("IsSet"),checkExpr:s("checkExpr"),ExpressionFragment:s("ExpressionFragment"),body:s("body"),CallFragment:s("CallFragment"),fragmentRef:s("fragmentRef"),source:s("source"),Join:s("Join"),separator:s("separator"),Count:s("Count"),Sum:s("Sum"),Min:s("Min"),Max:s("Max"),Average:s("Average"),loopVar:s("loopVar"),ForEach:s("ForEach"),emit:s("emit"),ListMap:s("ListMap"),mapBody:s("mapBody"),Filter:s("Filter"),predicate:s("predicate"),PartitionBy:s("PartitionBy"),partitionKey:s("partitionKey"),DistinctBy:s("DistinctBy"),distinctKey:s("distinctKey"),Partition:s("Partition"),key:s("key"),members:s("members"),AllStatements:s("AllStatements"),statementsOf:s("statementsOf"),StatementPredicate:s("StatementPredicate"),predicateOf:s("predicateOf"),StatementValue:s("StatementValue"),valueOf:s("valueOf"),DateFormat:s("DateFormat"),dateSource:s("dateSource"),dateFormat:s("dateFormat"),BinaryArithmetic:s("BinaryArithmetic"),arithLeft:s("arithLeft"),arithRight:s("arithRight"),Add:s("Add"),Subtract:s("Subtract"),Multiply:s("Multiply"),Divide:s("Divide"),Reverse:s("Reverse"),WindowedMap:s("WindowedMap"),windowSize:s("windowSize"),windowVar:s("windowVar"),windowBody:s("windowBody"),PairwiseMap:s("PairwiseMap"),firstVar:s("firstVar"),secondVar:s("secondVar"),pairBody:s("pairBody"),Scan:s("Scan"),initialState:s("initialState"),stateVar:s("stateVar"),elementVar:s("elementVar"),accumulate:s("accumulate"),ListItemAt:s("ListItemAt"),itemIndex:s("itemIndex"),BinaryComparison:s("BinaryComparison"),compareLeft:s("compareLeft"),compareRight:s("compareRight"),Equals:s("Equals"),GreaterThan:s("GreaterThan"),LessThan:s("LessThan"),GreaterThanOrEqual:s("GreaterThanOrEqual"),LessThanOrEqual:s("LessThanOrEqual"),Not:s("Not"),operand:s("operand"),BooleanLogic:s("BooleanLogic"),operands:s("operands"),And:s("And"),Or:s("Or"),Contains:s("Contains"),haystack:s("haystack"),needle:s("needle"),UnaryNumericOp:s("UnaryNumericOp"),value:s("value"),Abs:s("Abs"),Negate:s("Negate"),KindPredicate:s("KindPredicate"),IsReference:s("IsReference"),IsEmbedded:s("IsEmbedded"),IsList:s("IsList"),kindCheck:s("kindCheck"),IsString:s("IsString"),IsNumber:s("IsNumber"),IsBoolean:s("IsBoolean"),StatementObject:s("StatementObject"),statementSource:s("statementSource"),Let:s("Let"),letName:s("letName"),letValue:s("letValue"),letBody:s("letBody"),GetStatementByName:s("GetStatementByName"),inSubject:s("inSubject"),byName:s("byName"),RenderMarkdown:s("RenderMarkdown"),renderSource:s("renderSource"),renderProp:s("renderProp"),renderFormat:s("renderFormat"),RenderFormat:s("RenderFormat"),RENDER_HTML:s("render-html"),RENDER_MARKDOWN:s("render-markdown")};var g=class extends Error{constructor(n,r){super(`${n} (at ${r})`);this.path=r}path};function fe(t,e){let n=t.name,r=on(e),a={catalog:e,depth:0};if(f(t,o.InstanceTransformation))return Xt(t,n,a,r);if(f(t,o.SetTransformation))return Yt(t,n,a,r);throw new g("Subject is not a recognized v3 transformation type \u2014 expected InstanceTransformation or SetTransformation",n)}function Xt(t,e,n,r){return{kind:"instance",name:t.name,inputPattern:Qe(t,e),rule:le(t,o.rule,`${e}.rule`,n),artifactName:le(t,o.artifactName,`${e}.artifactName`,n),outputs:xe(t,`${e}.outputs`),overrides:et(t,`${e}.formatOverrides`,n),fragments:r}}function Yt(t,e,n,r){let a=_(t,o.partitionBy);return{kind:"set",name:t.name,inputPattern:Qe(t,e),rule:le(t,o.rule,`${e}.rule`,n),artifactName:le(t,o.artifactName,`${e}.artifactName`,n),outputs:xe(t,`${e}.outputs`),overrides:et(t,`${e}.formatOverrides`,n),partitionBy:a,fragments:r}}function Qe(t,e){let n=oe(t,o.inputPattern);if(!n)throw new g("inputPattern is required",e);return Zt(n,`${e}.inputPattern`)}function Zt(t,e){let n=_(t,o.matchesClass);if(!n)throw new g("matchesClass is required",e);let r=[];for(let u of A(t,o.requires))if(u instanceof j)r.push(ve(u.object.subject));else if(u instanceof S)for(let c of u.object)c instanceof b&&r.push(ve(c.subject));let a=[],i=0;for(let u of A(t,o.sortBy))if(u instanceof S)for(let c of u.object)c instanceof C&&a.push(Ge(c,`${e}.sortBy[${i++}]`));else u instanceof T&&a.push(Ge(u.object,`${e}.sortBy[${i++}]`));return{matchesClass:n,requires:r,sortBy:a}}function Ge(t,e){let n=_(t,o.byProperty);if(!n)throw new g("SortKey.byProperty is required",e);let r=_(t,o.order);if(!r)throw new g("SortKey.order is required",e);if(E(r,o.ascending))return{byProperty:n,order:"ascending"};if(E(r,o.descending))return{byProperty:n,order:"descending"};throw new g(`SortKey.order must reference tx.ascending or tx.descending; got ${r.publisher}/${r.package_}/${r.name}`,e)}function le(t,e,n,r){let a=oe(t,e);if(!a)throw new g("expression is required",n);return G(a,n,r)}function G(t,e,n){if(f(t,o.StringLiteral))return{kind:"string-literal",value:V(t,o.stringLiteral,e)};if(f(t,o.IntegerLiteral))return{kind:"integer-literal",value:Ze(t,o.integerLiteral,e)};if(f(t,o.DecimalLiteral))return{kind:"decimal-literal",value:Ze(t,o.decimalLiteral,e)};if(f(t,o.BooleanLiteral))return{kind:"boolean-literal",value:cn(t,o.booleanLiteral,e)};if(f(t,o.VarRef))return{kind:"var-ref",varName:V(t,o.varName,e)};if(f(t,o.PropertyRead))return{kind:"property-read",source:d(t,o.readSource,`${e}.readSource`,n),readProp:q(t,o.readProp,e,"readProp")};if(f(t,o.Traverse))return{kind:"traverse",source:d(t,o.traverseSource,`${e}.traverseSource`,n),through:q(t,o.through,e,"through"),step:d(t,o.step,`${e}.step`,n)};if(f(t,o.BuildAstNode))return{kind:"build-ast-node",astClass:q(t,o.astClass,e,"astClass"),set:xt(t,`${e}.set`,n)};if(f(t,o.When))return{kind:"when",condition:d(t,o.condition,`${e}.condition`,n),thenBuild:d(t,o.thenBuild,`${e}.thenBuild`,n),elseBuild:Qt(t,o.elseBuild,`${e}.elseBuild`,n)};if(f(t,o.Concat))return{kind:"concat",parts:Se(t,o.parts,`${e}.parts`,n)};if(f(t,o.Fallback))return{kind:"fallback",primary:d(t,o.primary,`${e}.primary`,n),alternate:d(t,o.alternate,`${e}.alternate`,n)};if(f(t,o.UriName))return{kind:"uri-name",source:d(t,o.uriNameOf,`${e}.uriNameOf`,n)};if(f(t,o.UriPublisher))return{kind:"uri-publisher",source:d(t,o.uriPublisherOf,`${e}.uriPublisherOf`,n)};if(f(t,o.UriPackage))return{kind:"uri-package",source:d(t,o.uriPackageOf,`${e}.uriPackageOf`,n)};if(f(t,o.UriVersion))return{kind:"uri-version",source:d(t,o.uriVersionOf,`${e}.uriVersionOf`,n)};if(f(t,o.SubjectUri))return{kind:"subject-uri",source:d(t,o.subjectOf,`${e}.subjectOf`,n)};if(f(t,o.UriLiteral))return{kind:"uri-literal",refTo:q(t,o.refTo,e,"refTo")};if(f(t,o.DisplayLabel))return{kind:"display-label",labelTarget:q(t,o.labelTarget,e,"labelTarget"),labelSource:q(t,o.labelSource,e,"labelSource")};if(f(t,o.ResolveRef))return{kind:"resolve-ref",source:d(t,o.resolveSource,`${e}.resolveSource`,n)};if(f(t,o.Normalize))return{kind:"normalize",source:d(t,o.normSource,`${e}.normSource`,n),normKind:en(t,e)};if(f(t,o.RenderMarkdown))return{kind:"render-markdown",source:d(t,o.renderSource,`${e}.renderSource`,n),readProp:q(t,o.renderProp,e,"renderProp"),format:tn(t,e)};if(f(t,o.IsSet))return{kind:"is-set",check:d(t,o.checkExpr,`${e}.checkExpr`,n)};if(f(t,o.CallFragment))return rn(t,e,n);if(f(t,o.Join))return{kind:"join",source:d(t,o.source,`${e}.source`,n),separator:V(t,o.separator,e)};if(f(t,o.Count))return{kind:"count",source:d(t,o.source,`${e}.source`,n)};if(f(t,o.Sum))return{kind:"sum",source:d(t,o.source,`${e}.source`,n)};if(f(t,o.Min))return{kind:"min",source:d(t,o.source,`${e}.source`,n)};if(f(t,o.Max))return{kind:"max",source:d(t,o.source,`${e}.source`,n)};if(f(t,o.Average))return{kind:"average",source:d(t,o.source,`${e}.source`,n)};if(f(t,o.ForEach))return{kind:"for-each",source:d(t,o.source,`${e}.source`,n),loopVar:V(t,o.loopVar,e),emit:d(t,o.emit,`${e}.emit`,n)};if(f(t,o.ListMap))return{kind:"list-map",source:d(t,o.source,`${e}.source`,n),loopVar:V(t,o.loopVar,e),mapBody:d(t,o.mapBody,`${e}.mapBody`,n)};if(f(t,o.Filter))return{kind:"filter",source:d(t,o.source,`${e}.source`,n),loopVar:V(t,o.loopVar,e),predicate:d(t,o.predicate,`${e}.predicate`,n)};if(f(t,o.PartitionBy))return{kind:"partition-by",source:d(t,o.source,`${e}.source`,n),loopVar:V(t,o.loopVar,e),partitionKey:d(t,o.partitionKey,`${e}.partitionKey`,n)};if(f(t,o.DistinctBy))return{kind:"distinct-by",source:d(t,o.source,`${e}.source`,n),loopVar:V(t,o.loopVar,e),distinctKey:d(t,o.distinctKey,`${e}.distinctKey`,n)};if(f(t,o.AllStatements))return{kind:"all-statements",source:d(t,o.statementsOf,`${e}.statementsOf`,n)};if(f(t,o.StatementPredicate))return{kind:"statement-predicate",source:d(t,o.predicateOf,`${e}.predicateOf`,n)};if(f(t,o.StatementValue))return{kind:"statement-value",source:d(t,o.valueOf,`${e}.valueOf`,n)};if(f(t,o.DateFormat))return{kind:"date-format",source:d(t,o.dateSource,`${e}.dateSource`,n),format:nn(t,e)};if(f(t,o.Add))return{kind:"add",left:d(t,o.arithLeft,`${e}.arithLeft`,n),right:d(t,o.arithRight,`${e}.arithRight`,n)};if(f(t,o.Subtract))return{kind:"subtract",left:d(t,o.arithLeft,`${e}.arithLeft`,n),right:d(t,o.arithRight,`${e}.arithRight`,n)};if(f(t,o.Multiply))return{kind:"multiply",left:d(t,o.arithLeft,`${e}.arithLeft`,n),right:d(t,o.arithRight,`${e}.arithRight`,n)};if(f(t,o.Divide))return{kind:"divide",left:d(t,o.arithLeft,`${e}.arithLeft`,n),right:d(t,o.arithRight,`${e}.arithRight`,n)};if(f(t,o.Reverse))return{kind:"reverse",source:d(t,o.source,`${e}.source`,n)};if(f(t,o.WindowedMap)){let r=tt(t,o.windowSize);if(r===void 0||!Number.isInteger(r)||r<1)throw new g("windowSize must be a positive integer",`${e}.windowSize`);return{kind:"windowed-map",source:d(t,o.source,`${e}.source`,n),windowSize:r,windowVar:V(t,o.windowVar,e),windowBody:d(t,o.windowBody,`${e}.windowBody`,n)}}if(f(t,o.PairwiseMap))return{kind:"pairwise-map",source:d(t,o.source,`${e}.source`,n),firstVar:V(t,o.firstVar,e),secondVar:V(t,o.secondVar,e),pairBody:d(t,o.pairBody,`${e}.pairBody`,n)};if(f(t,o.Scan))return{kind:"scan",source:d(t,o.source,`${e}.source`,n),initialState:d(t,o.initialState,`${e}.initialState`,n),stateVar:V(t,o.stateVar,e),elementVar:V(t,o.elementVar,e),accumulate:d(t,o.accumulate,`${e}.accumulate`,n)};if(f(t,o.ListItemAt))return{kind:"list-item-at",source:d(t,o.source,`${e}.source`,n),itemIndex:d(t,o.itemIndex,`${e}.itemIndex`,n)};if(f(t,o.Equals))return{kind:"equals",left:d(t,o.compareLeft,`${e}.compareLeft`,n),right:d(t,o.compareRight,`${e}.compareRight`,n)};if(f(t,o.GreaterThan))return{kind:"greater-than",left:d(t,o.compareLeft,`${e}.compareLeft`,n),right:d(t,o.compareRight,`${e}.compareRight`,n)};if(f(t,o.LessThan))return{kind:"less-than",left:d(t,o.compareLeft,`${e}.compareLeft`,n),right:d(t,o.compareRight,`${e}.compareRight`,n)};if(f(t,o.GreaterThanOrEqual))return{kind:"greater-than-or-equal",left:d(t,o.compareLeft,`${e}.compareLeft`,n),right:d(t,o.compareRight,`${e}.compareRight`,n)};if(f(t,o.LessThanOrEqual))return{kind:"less-than-or-equal",left:d(t,o.compareLeft,`${e}.compareLeft`,n),right:d(t,o.compareRight,`${e}.compareRight`,n)};if(f(t,o.Not))return{kind:"not",operand:d(t,o.operand,`${e}.operand`,n)};if(f(t,o.And))return{kind:"and",operands:Se(t,o.operands,`${e}.operands`,n)};if(f(t,o.Or))return{kind:"or",operands:Se(t,o.operands,`${e}.operands`,n)};if(f(t,o.Contains))return{kind:"contains",haystack:d(t,o.haystack,`${e}.haystack`,n),needle:d(t,o.needle,`${e}.needle`,n)};if(f(t,o.Abs))return{kind:"abs",value:d(t,o.value,`${e}.value`,n)};if(f(t,o.Negate))return{kind:"negate",value:d(t,o.value,`${e}.value`,n)};if(f(t,o.IsReference))return{kind:"is-reference",check:d(t,o.kindCheck,`${e}.kindCheck`,n)};if(f(t,o.IsEmbedded))return{kind:"is-embedded",check:d(t,o.kindCheck,`${e}.kindCheck`,n)};if(f(t,o.IsList))return{kind:"is-list",check:d(t,o.kindCheck,`${e}.kindCheck`,n)};if(f(t,o.IsString))return{kind:"is-string",check:d(t,o.kindCheck,`${e}.kindCheck`,n)};if(f(t,o.IsNumber))return{kind:"is-number",check:d(t,o.kindCheck,`${e}.kindCheck`,n)};if(f(t,o.IsBoolean))return{kind:"is-boolean",check:d(t,o.kindCheck,`${e}.kindCheck`,n)};if(f(t,o.StatementObject))return{kind:"statement-object",source:d(t,o.statementSource,`${e}.statementSource`,n)};if(f(t,o.Let))return{kind:"let",bindName:V(t,o.letName,e),bindValue:d(t,o.letValue,`${e}.letValue`,n),body:d(t,o.letBody,`${e}.letBody`,n)};if(f(t,o.GetStatementByName))return{kind:"get-statement-by-name",inSubject:d(t,o.inSubject,`${e}.inSubject`,n),byName:d(t,o.byName,`${e}.byName`,n)};throw new g("Expression is not of a recognized v3 type \u2014 embedded has no matching subclass of tx.Expression",e)}function d(t,e,n,r){let a=oe(t,e);if(!a)throw new g("child expression is required",n);return G(a,n,r)}function Qt(t,e,n,r){let a=oe(t,e);if(a)return G(a,n,r)}function Se(t,e,n,r){let a=[],i=0;for(let u of A(t,e))if(u instanceof S)for(let c of u.object)c instanceof C&&a.push(G(c,`${n}[${i++}]`,r));else u instanceof T&&a.push(G(u.object,`${n}[${i++}]`,r));return a}function xt(t,e,n){let r=[],a=0;for(let i of A(t,o.set))if(i instanceof S)for(let u of i.object)u instanceof C&&r.push(Je(u,`${e}[${a++}]`,n));else i instanceof T&&r.push(Je(i.object,`${e}[${a++}]`,n));return r}function Je(t,e,n){return{field:q(t,o.field,e,"field"),value:d(t,o.bindValue,`${e}.bindValue`,n)}}function en(t,e){let n=_(t,o.normKind);if(!n)throw new g("normKind is required",e);if(E(n,o.NORM_TRIM_END))return"trim-end";throw new g(`Unknown NormalizeKind: ${n.publisher}/${n.package_}/${n.name}`,e)}function tn(t,e){let n=_(t,o.renderFormat);if(!n)throw new g("renderFormat is required",e);if(E(n,o.RENDER_HTML))return"html";if(E(n,o.RENDER_MARKDOWN))return"markdown";throw new g(`Unknown RenderFormat: ${n.publisher}/${n.package_}/${n.name}`,e)}var Xe=new Set(["iso-date","iso-datetime","short-date","long-date","year","month-year"]);function nn(t,e){let n=z(t,o.dateFormat);if(!n)throw new g("dateFormat is required",e);if(!Xe.has(n))throw new g(`Unknown dateFormat "${n}"; supported: ${[...Xe].join(", ")}`,e);return n}function rn(t,e,n){let r=_(t,o.fragmentRef);if(!r)throw new g("fragmentRef is required",e);if(!sn(n.catalog,r))throw new g(`ExpressionFragment not found: ${r.publisher}/${r.package_}/${r.name}`,e);return{kind:"call-fragment",fragmentKey:an(r)}}function an(t){return`${t.publisher}/${t.package_}/${t.name}`}function on(t){let e=new Map,n=[];for(let r of t){if(!(r instanceof w)||!f(r,o.ExpressionFragment))continue;let a=oe(r,o.body);if(!a)continue;let i=(r.namespace||"").split("@")[0]||"",u=i.indexOf("/");if(u<0)continue;let c=i.substring(0,u),l=i.substring(u+1),p=`${c}/${l}/${r.name}`;n.push({key:p,subject:r,bodyEmb:a,pubPkgName:`${i}/${r.name}`})}for(let r of n){let a=G(r.bodyEmb,`fragment(${r.pubPkgName})`,{catalog:t,depth:0});e.set(r.key,a)}return e}function sn(t,e){for(let n of t)if(!(!(n instanceof w)||n.name!==e.name||!(n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))&&f(n,o.ExpressionFragment))return n}function xe(t,e){let n=new Set;for(let r of A(t,o.outputs))if(r instanceof j)n.add(r.object.subject.name);else if(r instanceof S)for(let a of r.object)a instanceof b&&n.add(a.subject.name);if(n.size===0)throw new g("outputs is required (at least one OutputFormat)",e);return n}function et(t,e,n){let r=new Map,a=0;for(let i of A(t,o.formatOverrides))if(i instanceof S){for(let u of i.object)if(u instanceof C){let[c,l]=Ye(u,`${e}[${a++}]`);r.set(c,l)}}else if(i instanceof T){let[u,c]=Ye(i.object,`${e}[${a++}]`);r.set(u,c)}return r}function Ye(t,e){let n=_(t,o.formatTarget);if(!n)throw new g("formatTarget is required",e);let r=[];for(let c of A(t,o.metadataKeys))if(c instanceof L)r.push(c.object);else if(c instanceof S)for(let l of c.object){let p=l.value;typeof p=="string"&&r.push(p)}let a=new Map;for(let c of A(t,o.metadataRenames))if(c instanceof S){for(let l of c.object)if(l instanceof C){let p=z(l,o.fromKey),y=z(l,o.toKey);p&&y&&a.set(p,y)}}else if(c instanceof T){let l=c.object,p=z(l,o.fromKey),y=z(l,o.toKey);p&&y&&a.set(p,y)}let i=Ee(t,o.trailingNewline),u=Ee(t,o.omitWrapper);return[n.name,{metadataKeys:r.length>0?r:void 0,metadataRenames:a,trailingNewline:i,omitWrapper:u}]}function un(t){return t.predicate?.subject}function A(t,e){let n=[];for(let r of t.statement){let a=un(r);a&&E(a,e)&&n.push(r)}return n}function oe(t,e){for(let n of A(t,e))if(n instanceof T)return n.object}function _(t,e){for(let n of A(t,e))if(n instanceof j)return ve(n.object.subject)}function z(t,e){for(let n of A(t,e))if(n instanceof L)return n.object}function tt(t,e){for(let n of A(t,e))if(n instanceof U)return n.object}function Ee(t,e){for(let n of A(t,e))if(n instanceof O)return n.object}function V(t,e,n){let r=z(t,e);if(r===void 0)throw new g(`${e.name} (string) is required`,n);return r}function Ze(t,e,n){let r=tt(t,e);if(r===void 0)throw new g(`${e.name} (number) is required`,n);return r}function cn(t,e,n){let r=Ee(t,e);if(r===void 0)throw new g(`${e.name} (boolean) is required`,n);return r}function q(t,e,n,r){let a=_(t,e);if(!a)throw new g(`${r} (URI reference) is required`,n);return a}function ve(t){return{publisher:t.publisher,package_:t.package_,name:t.name}}var dn={publisher:"kanonak.org",package_:"core-rdf",name:"label"},I=class extends Error{},pe=class{constructor(e,n,r=new Map){this.resolver=e;this.catalog=n;this.fragments=r}resolver;catalog;fragments;async evaluate(e,n){switch(e.kind){case"string-literal":return e.value;case"integer-literal":return e.value;case"decimal-literal":return e.value;case"boolean-literal":return e.value;case"uri-literal":return{...e.refTo};case"var-ref":{if(!n.has(e.varName))throw new I(`Unbound variable "${e.varName}"`);return n.get(e.varName)}case"concat":{let r=[];for(let a of e.parts){let i=await this.evaluate(a,n);if(i!=null)if(Array.isArray(i))for(let u of i)r.push(u);else r.push(i)}return r}case"fallback":{let r=await this.evaluate(e.primary,n);return nt(r)?r:this.evaluate(e.alternate,n)}case"when":return await this.evaluate(e.condition,n)===!0?this.evaluate(e.thenBuild,n):e.elseBuild?this.evaluate(e.elseBuild,n):void 0;case"is-set":{let r=await this.evaluate(e.check,n);return nt(r)}case"property-read":{let r=await this.evaluate(e.source,n);return me(r,e.readProp)}case"traverse":{let r=await this.evaluate(e.source,n);if(!(r instanceof K))return;let a=fn(r,e.through),i=[];for(let u of a){let c=await this.resolver.resolveSubject(u,this.catalog);if(!c)continue;let l=new Map(n);l.set("input",c);let p=await this.evaluate(e.step,l);p!=null&&i.push(se(p))}return i.join("")}case"uri-name":{let r=await this.evaluate(e.source,n);return J(r)?r.name:r instanceof b?r.subject.name:r instanceof w?r.name:r instanceof C?r.name??"":void 0}case"uri-publisher":{let r=await this.evaluate(e.source,n);return $e(r)?.publisher}case"uri-package":{let r=await this.evaluate(e.source,n);return $e(r)?.package_}case"uri-version":{let r=await this.evaluate(e.source,n);return $e(r)?.version}case"subject-uri":{let r=await this.evaluate(e.source,n);if(r instanceof w){let a=r.namespace??"",i=r.name??"";return!a||!i?void 0:`${a}/${i}`}if(r instanceof b){let a=r.subject,i=a.version;return i&&typeof i.major=="number"?`${a.publisher}/${a.package_}@${i.major}.${i.minor}.${i.patch}/${a.name}`:`${a.publisher}/${a.package_}/${a.name}`}return}case"display-label":{let r=await this.resolver.resolveSubject({...e.labelTarget},this.catalog);return r?me(r,e.labelSource):void 0}case"resolve-ref":{let r=await this.evaluate(e.source,n);return r instanceof w?r:r instanceof b?await this.resolver.resolveSubject(r.subject,this.catalog):J(r)?await this.resolver.resolveSubject(r,this.catalog):void 0}case"normalize":{let r=await this.evaluate(e.source,n),a=r==null?"":se(r);return e.normKind==="trim-end"?a.replace(/[\s\r\n]+$/u,""):a}case"render-markdown":{let r=await this.evaluate(e.source,n);if(!(r instanceof K))return;let a;for(let u of r.statement){let c=je(u);if(c&&E(c,e.readProp)){a=u;break}}if(!(a instanceof Re)){let u=me(r,e.readProp);return u==null?void 0:se(u)}let i=await this.renderMarkdownLinks(a);return e.format==="html"?X(i):i}case"build-ast-node":{let r={kind:e.astClass.name};for(let a of e.set){let i=await this.evaluate(a.value,n);if(i==null||Array.isArray(i)&&i.length===0)continue;let u=a.field.name;pn.has(u)&&(Array.isArray(i)&&i.every(c=>rt(c))?i=i.map(c=>String(c)).join(""):rt(i)&&(i=String(i))),r[u]=i}return r}case"call-fragment":{let r=this.fragments.get(e.fragmentKey);if(!r)throw new I(`ExpressionFragment ${e.fragmentKey} not found in registry`);return this.evaluate(r,n)}case"join":return(await this.evaluateList(e.source,n)).map(a=>a==null?"":se(a)).join(e.separator);case"count":return(await this.evaluateList(e.source,n)).length;case"sum":{let r=await this.evaluateList(e.source,n),a=0;for(let i of r)a+=v(i,"Sum");return a}case"min":{let r=await this.evaluateList(e.source,n);if(r.length===0)throw new I("Min on an empty list is undefined; guard with IsSet");let a=v(r[0],"Min");for(let i=1;i<r.length;i++){let u=v(r[i],"Min");u<a&&(a=u)}return a}case"max":{let r=await this.evaluateList(e.source,n);if(r.length===0)throw new I("Max on an empty list is undefined; guard with IsSet");let a=v(r[0],"Max");for(let i=1;i<r.length;i++){let u=v(r[i],"Max");u>a&&(a=u)}return a}case"average":{let r=await this.evaluateList(e.source,n);if(r.length===0)throw new I("Average on an empty list is undefined; guard with IsSet");let a=0;for(let i of r)a+=v(i,"Average");return a/r.length}case"for-each":{let r=await this.evaluateList(e.source,n),a=[];for(let i of r){let u=new Map(n);u.set(e.loopVar,B(i));let c=await this.evaluate(e.emit,u);if(c!=null)if(Array.isArray(c))for(let l of c)a.push(l);else a.push(c)}return a}case"list-map":{let r=await this.evaluateList(e.source,n),a=[];for(let i of r){let u=new Map(n);u.set(e.loopVar,B(i)),a.push(await this.evaluate(e.mapBody,u))}return a}case"filter":{let r=await this.evaluateList(e.source,n),a=[];for(let i of r){let u=new Map(n);u.set(e.loopVar,B(i)),await this.evaluate(e.predicate,u)===!0&&a.push(i)}return a}case"partition-by":{let r=await this.evaluateList(e.source,n),a=new Map,i=[];for(let u of r){let c=new Map(n);c.set(e.loopVar,B(u));let l=await this.evaluate(e.partitionKey,c),p=ot(l),y=a.get(p);y||(y={kind:"Partition",key:l,members:[]},a.set(p,y),i.push(p)),y.members.push(u)}return i.map(u=>a.get(u))}case"distinct-by":{let r=await this.evaluateList(e.source,n),a=new Set,i=[];for(let u of r){let c=new Map(n);c.set(e.loopVar,B(u));let l=await this.evaluate(e.distinctKey,c),p=ot(l);a.has(p)||(a.add(p),i.push(u))}return i}case"all-statements":{let r=await this.evaluate(e.source,n);return r instanceof K?r.statement:[]}case"statement-predicate":{let r=await this.evaluate(e.source,n);if(Ve(r)){let a=r.predicate;if(a instanceof b)return a}return}case"statement-value":{let r=await this.evaluate(e.source,n);return Ve(r)?kn(r):void 0}case"date-format":{let r=await this.evaluate(e.source,n),a=r==null?"":se(r);return a?yn(a,e.format):""}case"add":{let r=v(await this.evaluate(e.left,n),"Add"),a=v(await this.evaluate(e.right,n),"Add");return r+a}case"subtract":{let r=v(await this.evaluate(e.left,n),"Subtract"),a=v(await this.evaluate(e.right,n),"Subtract");return r-a}case"multiply":{let r=v(await this.evaluate(e.left,n),"Multiply"),a=v(await this.evaluate(e.right,n),"Multiply");return r*a}case"divide":{let r=v(await this.evaluate(e.left,n),"Divide"),a=v(await this.evaluate(e.right,n),"Divide");if(a===0)throw new I("Divide by zero; guard with When");return r/a}case"reverse":{if(e.source.kind==="reverse")return this.evaluate(e.source.source,n);let r=await this.evaluateReverseIterator(e.source,n);return r!==void 0?r:[...await this.evaluateList(e.source,n)].reverse()}case"windowed-map":{let r=await this.evaluateList(e.source,n);if(r.length<e.windowSize)return[];let a=[];for(let i=0;i+e.windowSize<=r.length;i++){let u=r.slice(i,i+e.windowSize),c=new Map(n);c.set(e.windowVar,u);let l=await this.evaluate(e.windowBody,c);if(l!=null)if(Array.isArray(l))for(let p of l)a.push(p);else a.push(l)}return a}case"pairwise-map":{let r=await this.evaluateList(e.source,n);if(r.length<2)return[];let a=[];for(let i=0;i+1<r.length;i++){let u=new Map(n);u.set(e.firstVar,B(r[i])),u.set(e.secondVar,B(r[i+1]));let c=await this.evaluate(e.pairBody,u);if(c!=null)if(Array.isArray(c))for(let l of c)a.push(l);else a.push(c)}return a}case"scan":{let r=await this.evaluateList(e.source,n);if(r.length===0)return[];let a=await this.evaluate(e.initialState,n),i=[];for(let u of r){let c=new Map(n);c.set(e.stateVar,a),c.set(e.elementVar,B(u));let l=await this.evaluate(e.accumulate,c);i.push(l),a=l}return i}case"list-item-at":{let r=await this.evaluateList(e.source,n),a=await this.evaluate(e.itemIndex,n);return typeof a!="number"||!Number.isInteger(a)||a<0||a>=r.length?void 0:r[a]}case"equals":{let r=await this.evaluate(e.left,n),a=await this.evaluate(e.right,n);return at(r,a)}case"greater-than":{let r=await this.evaluate(e.left,n),a=await this.evaluate(e.right,n);return typeof r!="number"||typeof a!="number"?!1:r>a}case"less-than":{let r=await this.evaluate(e.left,n),a=await this.evaluate(e.right,n);return typeof r!="number"||typeof a!="number"?!1:r<a}case"greater-than-or-equal":{let r=await this.evaluate(e.left,n),a=await this.evaluate(e.right,n);return typeof r!="number"||typeof a!="number"?!1:r>=a}case"less-than-or-equal":{let r=await this.evaluate(e.left,n),a=await this.evaluate(e.right,n);return typeof r!="number"||typeof a!="number"?!1:r<=a}case"not":{let r=await this.evaluate(e.operand,n);return r===!0?!1:r===!1?!0:void 0}case"and":{for(let r of e.operands)if(await this.evaluate(r,n)!==!0)return!1;return!0}case"or":{for(let r of e.operands)if(await this.evaluate(r,n)===!0)return!0;return!1}case"contains":{let r=await this.evaluateList(e.haystack,n),a=await this.evaluate(e.needle,n);for(let i of r)if(at(i,a))return!0;return!1}case"abs":{let r=v(await this.evaluate(e.value,n),"Abs");return Math.abs(r)}case"negate":return-v(await this.evaluate(e.value,n),"Negate");case"is-reference":{let r=await this.evaluate(e.check,n);return r instanceof b||r instanceof w}case"is-embedded":return await this.evaluate(e.check,n)instanceof C;case"is-list":{let r=await this.evaluate(e.check,n);return Array.isArray(r)}case"is-string":return typeof await this.evaluate(e.check,n)=="string";case"is-number":return typeof await this.evaluate(e.check,n)=="number";case"is-boolean":return typeof await this.evaluate(e.check,n)=="boolean";case"statement-object":{let r=await this.evaluate(e.source,n);if(!Ve(r))return;let a=r;return a instanceof L||a instanceof U||a instanceof O||a instanceof j||a instanceof T||a instanceof S?a.object:void 0}case"let":{let r=await this.evaluate(e.bindValue,n),a=new Map(n);return a.set(e.bindName,r),this.evaluate(e.body,a)}case"get-statement-by-name":{let r=await this.evaluate(e.inSubject,n),a=await this.evaluate(e.byName,n);if(!(r instanceof K)||typeof a!="string")return;for(let i of r.statement)if(i.predicate?.subject?.name===a)return i;return}default:{let r=e;throw new I("Unknown expression kind")}}}async renderMarkdownLinks(e){let n=e.object,r="",a=0;for(let i of e.links){if(r+=n.slice(a,i.startOffset),i.target){let u=i.target.subject,c=i.displayText??await this.resolveLabel(u)??u.name;r+=`[${c}](${F(u)})`}else r+=i.displayText??i.reference;a=i.endOffset}return r+=n.slice(a),r}async resolveLabel(e){let n=await this.resolver.resolveSubject(e,this.catalog);if(!n)return;let r=me(n,dn);return typeof r=="string"?r:void 0}async evaluateList(e,n){let r=await this.evaluate(e,n);return r==null?[]:Array.isArray(r)?r:[r]}async evaluateReverseIterator(e,n){if(e.kind==="pairwise-map"){let r=await this.evaluateList(e.source,n);if(r.length<2)return[];let a=[];for(let i=r.length-1;i>=1;i--){let u=new Map(n);u.set(e.firstVar,B(r[i-1])),u.set(e.secondVar,B(r[i]));let c=await this.evaluate(e.pairBody,u);if(c!=null)if(Array.isArray(c))for(let l of c)a.push(l);else a.push(c)}return a}if(e.kind==="for-each"){let r=await this.evaluateList(e.source,n),a=[];for(let i=r.length-1;i>=0;i--){let u=new Map(n);u.set(e.loopVar,B(r[i]));let c=await this.evaluate(e.emit,u);if(c!=null)if(Array.isArray(c))for(let l of c)a.push(l);else a.push(c)}return a}if(e.kind==="list-map"){let r=await this.evaluateList(e.source,n),a=[];for(let i=r.length-1;i>=0;i--){let u=new Map(n);u.set(e.loopVar,B(r[i])),a.push(await this.evaluate(e.mapBody,u))}return a}if(e.kind==="windowed-map"){let r=await this.evaluateList(e.source,n);if(r.length<e.windowSize)return[];let a=[];for(let i=r.length-e.windowSize;i>=0;i--){let u=r.slice(i,i+e.windowSize),c=new Map(n);c.set(e.windowVar,u);let l=await this.evaluate(e.windowBody,c);if(l!=null)if(Array.isArray(l))for(let p of l)a.push(p);else a.push(l)}return a}}};function me(t,e){if(t instanceof K)return ln(t,e);if(mn(t))return E(e,o.key)?t.key:E(e,o.members)?t.members:void 0}function ln(t,e){for(let n of t.statement){let r=je(n);if(!(!r||!E(r,e))&&(n instanceof L||n instanceof U||n instanceof O||n instanceof j||n instanceof T||n instanceof S))return n.object}}function fn(t,e){let n=[];for(let r of t.statement){let a=je(r);if(!(!a||!E(a,e))){if(r instanceof j)n.push(r.object.subject);else if(r instanceof S)for(let i of r.object)i instanceof b&&n.push(i.subject)}}return n}function je(t){return t.predicate?.subject}function se(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(t instanceof K)return t.name??"";if(t instanceof b)return t.subject.name;if(J(t))return t.name;let e=t.value;return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function B(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof K)&&!(t instanceof b)&&!(t instanceof C)&&"value"in t?t.value:t}function nt(t){return t==null?!1:typeof t=="string"||Array.isArray(t)?t.length>0:typeof t=="boolean"?t===!0:!0}function J(t){return typeof t=="object"&&t!==null&&typeof t.publisher=="string"&&typeof t.package_=="string"&&typeof t.name=="string"}function mn(t){return typeof t=="object"&&t!==null&&t.kind==="Partition"&&Array.isArray(t.members)}function v(t,e){if(typeof t=="number"&&Number.isFinite(t))return t;throw new I(`${e} requires numeric elements; got ${gn(t)}`)}function $e(t){if(t instanceof w){let e=t.namespace??"",n=e.indexOf("/"),r=e.indexOf("@",n+1);return n<0||r<0?void 0:{publisher:e.substring(0,n),package_:e.substring(n+1,r),version:e.substring(r+1),name:t.name??""}}if(t instanceof b){let e=t.subject,n=e.version;return{publisher:e.publisher,package_:e.package_,version:n&&typeof n.major=="number"?`${n.major}.${n.minor}.${n.patch}`:"",name:e.name}}if(J(t))return{publisher:t.publisher,package_:t.package_,version:"",name:t.name}}var pn=new Set(["stringValue","text","rawContent","key","propertyKey","linkLabel"]);function rt(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function gn(t){return t===void 0?"undefined":t===null?"null":Array.isArray(t)?`array(${t.length})`:typeof t}function yn(t,e){let n=new Date(t);if(isNaN(n.getTime()))return"";let r=n.getUTCFullYear(),a=["January","February","March","April","May","June","July","August","September","October","November","December"][n.getUTCMonth()],i=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][n.getUTCMonth()],u=n.getUTCDate(),c=(l,p=2)=>String(l).padStart(p,"0");switch(e){case"iso-date":return`${r}-${c(n.getUTCMonth()+1)}-${c(u)}`;case"iso-datetime":return`${r}-${c(n.getUTCMonth()+1)}-${c(u)}T${c(n.getUTCHours())}:${c(n.getUTCMinutes())}:${c(n.getUTCSeconds())}Z`;case"short-date":return`${i} ${u}`;case"long-date":return`${a} ${u}, ${r}`;case"year":return String(r);case"month-year":return`${a} ${r}`}}function at(t,e){if(t==null||e===void 0||e===null)return!1;if(t===e)return!0;let n=typeof t=="object"&&"value"in t?t.value:void 0,r=typeof e=="object"&&"value"in e?e.value:void 0,a=n??t,i=r??e,u=it(t),c=it(e);return u&&c?u.publisher===c.publisher&&u.package_===c.package_&&u.name===c.name:typeof a=="string"&&typeof i=="string"||typeof a=="number"&&typeof i=="number"||typeof a=="boolean"&&typeof i=="boolean"?a===i:!1}function it(t){if(t instanceof b){let e=t.subject;return{publisher:e.publisher,package_:e.package_,name:e.name}}if(t instanceof w){let e=t.namespace??"",n=e.indexOf("/"),r=e.indexOf("@",n+1);if(n<0)return;let a=e.substring(0,n),i=r>=0?e.substring(n+1,r):e.substring(n+1);return{publisher:a,package_:i,name:t.name??""}}if(J(t))return{publisher:t.publisher,package_:t.package_,name:t.name}}function Ve(t){return t instanceof L||t instanceof U||t instanceof O||t instanceof j||t instanceof T||t instanceof S}function kn(t){return t instanceof L||t instanceof U||t instanceof O?String(t.object??""):t instanceof j?t.object?.subject?.name??"":t instanceof T?"[embedded]":t instanceof S?(t.object??[]).map(n=>{if(n instanceof b)return n.subject.name;let r=n.name;if(r&&r.length>0)return r;let a=n.value;return typeof a=="string"||typeof a=="number"||typeof a=="boolean"?String(a):"[embedded]"}).join(", "):""}function ot(t){if(t===void 0)return"\0undef";if(t===null)return"\0null";if(typeof t=="string")return`s:${t}`;if(typeof t=="number")return`n:${t}`;if(typeof t=="boolean")return`b:${t}`;if(t instanceof b){let e=t.subject;return`r:${e.publisher}/${e.package_}/${e.name}`}if(t instanceof K){let e=t.name??"";return`k:${t.namespace??""}/${e}`}return J(t)?`u:${t.publisher}/${t.package_}/${t.name}`:`o:${JSON.stringify(t)}`}var hn={"markdown-with-frontmatter":{formatUri:"kanonak.org/transformations/markdown-with-frontmatter",extension:".md"},"plain-markdown":{formatUri:"kanonak.org/transformations/plain-markdown",extension:".md"},toml:{formatUri:"kanonak.org/transformations/toml",extension:".toml"},json:{formatUri:"kanonak.org/transformations/json",extension:".json"},html:{formatUri:"kanonak.org/transformations/html",extension:".html"},svg:{formatUri:"kanonak.org/transformations/svg",extension:".svg"},stylesheet:{formatUri:"kanonak.org/transformations/stylesheet",extension:".css"},yaml:{formatUri:"kanonak.org/transformations/yaml",extension:".yaml"},"dynamodb-json":{formatUri:"kanonak.org/transformations/dynamodb-json",extension:".json"}},W=class extends Error{},ge=class{backends=new Map;constructor(){this.register(new Y),this.register(new Z),this.register(new Q),this.register(new x),this.register(new ee),this.register(new te),this.register(new ne),this.register(new ae)}register(e){this.backends.set(e.backendUri,e)}async run(e){let n=e.transformationKanonaks??e.allKanonaks,r=fe(e.transformation,n);if(!r.outputs.has(e.outputFormat))throw new W(`Transformation "${r.name}" does not declare output format "${e.outputFormat}". Declared: ${Array.from(r.outputs).join(", ")}`);let a=this.findBackend(e.outputFormat);if(!a)throw new W(`No backend registered for OutputFormat "${e.outputFormat}".`);let i=new ie(e.repository,e.parser,e.objectParser),u=new pe(i,e.allKanonaks,r.fragments);return r.kind==="instance"?this.runInstance(r,e,a,u):this.runSet(r,e,a,u)}async runInstance(e,n,r,a){let i=st(n.instances,e.inputPattern.requires),u=ut(i,e.inputPattern.sortBy),c=[];for(let l of u){let p=new Map;p.set("input",l);let y=await a.evaluate(e.rule,p);Ae(y,e.name,`input "${l.name}"`);let h=De(await a.evaluate(e.artifactName,p),e.name,`input "${l.name}"`),D=Ke(e.overrides.get(n.outputFormat),n.runtimeOverride),$=r.render(y,D);c.push({fileName:h,format:n.outputFormat,content:$,source:{kind:"instance",sourceName:l.name}})}return c}async runSet(e,n,r,a){let i=st(n.instances,e.inputPattern.requires),u=ut(i,e.inputPattern.sortBy);return e.partitionBy?this.runSetWithPartition(e,u,n,r,a):this.runSetSingle(e,u,n,r,a)}async runSetSingle(e,n,r,a,i){let u=new Map;u.set("inputs",n);let c=await i.evaluate(e.rule,u);Ae(c,e.name,"set");let l=De(await i.evaluate(e.artifactName,u),e.name,"set"),p=Ke(e.overrides.get(r.outputFormat),r.runtimeOverride),y=a.render(c,p);return[{fileName:l,format:r.outputFormat,content:y,source:{kind:"set",memberCount:n.length}}]}async runSetWithPartition(e,n,r,a,i){let u=e.partitionBy,c=new Map,l=[];for(let y of n){let h=Sn(y,u);if(h==null)continue;let D=En(h),$=c.get(D);$||($={keyValue:h,keyDisplay:vn(h),members:[]},c.set(D,$),l.push(D)),$.members.push(y)}let p=[];for(let y of l){let h=c.get(y),D=new Map;D.set("inputs",h.members),D.set("key",h.keyValue);let $=await i.evaluate(e.rule,D);Ae($,e.name,`partition "${h.keyDisplay}"`);let ft=De(await i.evaluate(e.artifactName,D),e.name,`partition "${h.keyDisplay}"`),mt=Ke(e.overrides.get(r.outputFormat),r.runtimeOverride),pt=a.render($,mt);p.push({fileName:ft,format:r.outputFormat,content:pt,source:{kind:"set",memberCount:h.members.length,partitionKey:h.keyDisplay}})}return p}findBackend(e){let n=hn[e];if(n)return this.backends.get(n.formatUri)}};function st(t,e){return e.length===0?t:t.filter(n=>{for(let r of e)if(!wn(n,r))return!1;return!0})}function ut(t,e){if(e.length===0)return t;let n=[...t];return n.sort((r,a)=>{for(let i of e){let u=ct(r,i.byProperty),c=ct(a,i.byProperty),l=bn(u,c,i.order);if(l!==0)return l}return 0}),n}function ct(t,e){for(let n of t.statement){let r=Te(n);if(!(!r||!E(r,e))){if(n instanceof L||n instanceof U||n instanceof O)return n.object;if(n instanceof S)throw new W(`Sort property "${e.name}" on instance "${t.name??"?"}" resolves to a list \u2014 list-typed properties are not sortable. Use a scalar property.`);if(n instanceof j)throw new W(`Sort property "${e.name}" on instance "${t.name??"?"}" resolves to a reference \u2014 reference-typed properties don't have a natural total order. Use a scalar property.`)}}}function bn(t,e,n){if(t===void 0&&e===void 0)return 0;if(t===void 0)return n==="ascending"?1:-1;if(e===void 0)return n==="ascending"?-1:1;let r;return typeof t=="number"&&typeof e=="number"?r=t-e:r=String(t).localeCompare(String(e)),n==="ascending"?r:-r}function wn(t,e){for(let n of t.statement){let r=Te(n);if(!r||!E(r,e))continue;let a=n.object;if(a!=null&&!(typeof a=="string"&&a.length===0)&&!(Array.isArray(a)&&a.length===0))return!0}return!1}function Sn(t,e){for(let n of t.statement){let r=Te(n);if(!(!r||!E(r,e))&&(n instanceof L||n instanceof U||n instanceof O||n instanceof j||n instanceof S))return n.object}}function Te(t){return t.predicate?.subject}function En(t){if(t===void 0)return" undef";if(t===null)return" null";if(typeof t=="string")return`s:${t}`;if(typeof t=="number")return`n:${t}`;if(typeof t=="boolean")return`b:${t}`;if(t instanceof b){let e=t.subject;return`r:${e.publisher}/${e.package_}/${e.name}`}if(t instanceof K){let e=t.name??"";return`k:${t.namespace??""}/${e}`}if(typeof t=="object"&&t!==null&&typeof t.name=="string"&&typeof t.publisher=="string"){let e=t;return`u:${e.publisher}/${e.package_}/${e.name}`}return`o:${JSON.stringify(t)}`}function vn(t){return t==null?"":typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"?String(t):t instanceof b?t.subject.name:t instanceof K?t.name??"":typeof t=="object"&&t!==null&&typeof t.name=="string"?t.name:""}function Ae(t,e,n){if(typeof t!="object"||t===null||t.kind!=="Document")throw new W(`Transformation "${e}" rule did not yield a Document for ${n}. Got: ${dt(t)}`)}function De(t,e,n){if(typeof t=="string")return t;if(Array.isArray(t)&&t.every($n))return t.map(r=>String(r)).join("");throw new W(`Transformation "${e}" artifactName did not yield a string for ${n}. Got: ${dt(t)}`)}function $n(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function dt(t){if(t===void 0)return"undefined";if(t===null)return"null";if(Array.isArray(t))return`array(${t.length})`;if(typeof t=="object"){let e=t.kind;return e?`object(kind=${e})`:"object"}return typeof t}function Ke(t,e){if(!t&&!e)return;let n={metadataRenames:e?.metadataRenames??t?.metadataRenames??new Map},r=e?.metadataKeys??t?.metadataKeys;r!==void 0&&(n.metadataKeys=r);let a=e?.trailingNewline??t?.trailingNewline;a!==void 0&&(n.trailingNewline=a);let i=e?.omitWrapper??t?.omitWrapper;return i!==void 0&&(n.omitWrapper=i),n}var R=class extends Error{constructor(n,r){super(n);this.cause=r;this.name="RenderError"}cause},lt={publisher:"kanonak.org",package_:"derivation",name:"default"},Be=class{constructor(e,n=new Le,r=new Ce){this.repository=e;this.parser=n;this.objectParser=r}repository;parser;objectParser;runner=new ge;cachedCatalog=void 0;invalidate(){this.cachedCatalog=void 0}async renderViaLook(e){let n=await this.getCatalog(),r=M(n,e.resource);if(!(r instanceof w))throw new R(`Resource not found: ${P(e.resource)}`);let a=new ye(n),i;if(e.format.name==="html")i=a.renderHtml(r);else if(e.format.name==="stylesheet")i=a.renderStylesheet(r);else throw new R(`LookRenderer does not support format ${P(e.format)} \u2014 only formats.html and formats.stylesheet are implemented in v0.1.`);return{content:i,format:e.format,filename:r.name}}async findDerivation(e){let n=await this.getCatalog(),r=M(n,e.resource);if(!(r instanceof w))return;let a=e.variant??lt;return Oe(r,e.format,a,n)}async render(e){if(e.format.name==="html"||e.format.name==="stylesheet"){let a=await this.getCatalog(),i=M(a,e.resource);if(i instanceof w){let c=new ye(a).findCascadedLook(i);if(c&&!jn(c.sourceClass)){let l=await this.findDerivation(e);if(!l||Vn(l))return this.renderViaLook({resource:e.resource,format:e.format})}}}let n=await this.findDerivation(e);if(!n)throw new R(`No derivation found for ${P(e.resource)} \u2192 format ${P(e.format)}`+(e.variant?` variant ${P(e.variant)}`:""));let r={transformation:{publisher:n.transformation.publisher,package_:n.transformation.package_,name:n.transformation.name},input:e.resource,format:e.format};return e.omitWrapper!==void 0&&(r.omitWrapper=e.omitWrapper),this.runTransformation(r)}async runTransformation(e){let n=await this.getCatalog(),r=M(n,e.transformation);if(!(r instanceof w))throw new R(`Transformation not found: ${P(e.transformation)}`);let a=M(n,e.input);if(!(a instanceof w))throw new R(`Input resource not found: ${P(e.input)}`);let i=fe(r,n),u=An(i.outputs,e.format);if(!u)throw new R(`Transformation ${P(e.transformation)} declares outputs [${[...i.outputs].join(", ")}], none of which corresponds to format ${P(e.format)}`);let c;try{c=await this.runner.run({transformation:r,instances:[a],allKanonaks:n,repository:this.repository,parser:this.parser,objectParser:this.objectParser,outputFormat:u,...e.omitWrapper!==void 0?{runtimeOverride:{metadataRenames:new Map,omitWrapper:e.omitWrapper}}:{}})}catch(l){throw new R(`Transformation execution failed: ${l.message}`,l)}if(c.length===0)throw new R("Transformation produced no artifacts");return{content:c[0].content,format:e.format,filename:c[0].fileName}}async getCatalog(){return this.cachedCatalog||(this.cachedCatalog=await this.objectParser.parseKanonaks(this.repository)),this.cachedCatalog}};function P(t){return`${t.publisher}/${t.package_}/${t.name}`}function Vn(t){return typeof t.source=="string"?!1:t.source.publisher==="kanonak.org"&&t.source.package_==="core-rdf"&&t.source.name==="Resource"}function jn(t){return t.publisher==="kanonak.org"&&t.package_==="core-rdf"&&t.name==="Resource"}function An(t,e){let n=e.name;if(t.has(n))return n;for(let r of t)if(r.startsWith(n+"-")||r===n)return r}export{te as CssBackend,lt as DEFAULT_VARIANT,k as DOCAST,yt as DOCAST_PKG,gt as DOCAST_PUB,ae as DynamoDbBackend,pe as ExpressionEngineV3,I as ExpressionEvalErrorV3,x as HtmlBackend,Q as JsonBackend,Y as MarkdownFrontmatterBackend,ie as ReferenceResolver,R as RenderError,hn as SUPPORTED_FORMATS_V3,ee as SvgBackend,o as TX_V3,Jt as TX_V3_PKG,Gt as TX_V3_PUB,Zn as TX_V3_VERSION_MAJOR,Z as TomlBackend,Be as TransformationEngine,g as TransformationLoadErrorV3,W as TransformationRunnerErrorV3,ge as TransformationRunnerV3,ne as YamlBackend,fe as compileTransformationV3,X as renderMarkdownToHtml};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanonak-protocol/sdk",
|
|
3
|
-
"version": "3.27.
|
|
3
|
+
"version": "3.27.3",
|
|
4
4
|
"description": "Kanonak Protocol SDK - Document repository and parsing implementations for TypeScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"yaml-parser"
|
|
114
114
|
],
|
|
115
115
|
"dependencies": {
|
|
116
|
-
"@kanonak-protocol/types": "^3.27.
|
|
116
|
+
"@kanonak-protocol/types": "^3.27.3",
|
|
117
117
|
"ignore": "^7.0.5",
|
|
118
118
|
"js-yaml": "^4.1.0",
|
|
119
119
|
"yaml": "^2.7.0"
|
package/dist/chunk-7C5JUPYB.js
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import{a as $}from"./chunk-NIGFQYVA.js";import{a as _}from"./chunk-R2V7IXWN.js";import{c as S,d as p,g as m,j as d,k as v,l as k}from"./chunk-W6T7MOKY.js";var L={publisher:"kanonak.org",package_:"derivation",name:"look"},U={publisher:"kanonak.org",package_:"derivation",name:"tokens"},j={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},M={publisher:"kanonak.org",package_:"core-rdf",name:"label"},N={publisher:"kanonak.org",package_:"core-rdf",name:"comment"},z={publisher:"kanonak.org",package_:"look",name:"Hero"},A={publisher:"kanonak.org",package_:"look",name:"PropertyList"},W={publisher:"kanonak.org",package_:"look",name:"BadgeRow"},q={publisher:"kanonak.org",package_:"look",name:"ChipRow"},G={publisher:"kanonak.org",package_:"look",name:"ReferenceList"},O={publisher:"kanonak.org",package_:"look",name:"bands"},Y={publisher:"kanonak.org",package_:"look",name:"title"},J={publisher:"kanonak.org",package_:"look",name:"eyebrow"},Q={publisher:"kanonak.org",package_:"look",name:"subtitle"},F={publisher:"kanonak.org",package_:"look",name:"badges"},y={publisher:"kanonak.org",package_:"look",name:"source"},X={publisher:"kanonak.org",package_:"look",name:"chips"},P={publisher:"kanonak.org",package_:"look",name:"entries"},Z={publisher:"kanonak.org",package_:"look",name:"urlForm"},w=class{constructor(e){this.catalog=e}catalog;findCascadedLook(e){let n=new Set,t=B(e);for(;t.length>0;){let r=t.shift(),a=x(r.subject);if(n.has(a))continue;n.add(a);let s=g(this.catalog,r.subject);if(!s)continue;let i=C(s);if(i)return{declaration:i,sourceClass:{publisher:r.subject.publisher,package_:r.subject.package_,name:r.subject.name}};for(let c of V(s))t.push(c)}if(!n.has(x(j))){let r=g(this.catalog,j);if(r){let a=C(r);if(a)return{declaration:a,sourceClass:{...j}}}}}findCascadedTokens(e){let n=new Map;for(let[a,s]of I(e))n.has(a)||n.set(a,s);let t=new Set,r=B(e);for(;r.length>0;){let a=r.shift(),s=x(a.subject);if(t.has(s))continue;t.add(s);let i=g(this.catalog,a.subject);if(i){for(let[c,f]of I(i))n.has(c)||n.set(c,f);for(let c of V(i))r.push(c)}}if(!t.has(x(j))){let a=g(this.catalog,j);if(a)for(let[s,i]of I(a))n.has(s)||n.set(s,i)}return n}renderStylesheet(e){let n=this.findCascadedTokens(e),t=[];for(let[a,s]of n)t.push(` --kan-${a}: ${s};`);return`${t.length>0?`:root {
|
|
2
|
-
${t.join(`
|
|
3
|
-
`)}
|
|
4
|
-
}`:":root { /* no tokens resolved */ }"}
|
|
5
|
-
${re}`}renderHtml(e){let n=this.findCascadedLook(e);if(!n)return`<!-- LookRenderer: no derivation.look found for ${e.namespace}/${e.name} -->`;let t=ee(n.declaration);if(t.length===0)return"<!-- LookRenderer: look declaration has no bands -->";let r=te(e),a=[];for(let s of t)a.push(this.renderBand(s,e,r));return a.join(`
|
|
6
|
-
`)}renderBand(e,n,t){let r=ne(e);return r?R(r,z)?this.renderHero(e,n,t):R(r,A)?this.renderPropertyList(e,n,t):R(r,W)?this.renderBadgeRow(e,n,t):R(r,q)?this.renderChipRow(e,n,t):R(r,G)?this.renderReferenceList(e,n,t):`<!-- LookRenderer: unsupported band ${r.publisher}/${r.package_}/${r.name} -->`:"<!-- LookRenderer: band has no rdf:type -->"}renderHero(e,n,t){let r=['<header class="kan-hero">'],a=h(e,J);if(a){let l=this.readPropertyValueText(n,a);l&&r.push(`<span class="kan-hero-eyebrow">${u(l)}</span>`)}let s=h(e,Y),i="";s&&(i=this.readPropertyValueText(n,s)??""),i||(i=n.name),r.push(`<h1 class="kan-hero-title">${u(i)}</h1>`);let c=h(e,Q);if(c){let l=this.readPropertyValueText(n,c);l&&r.push(`<p class="kan-hero-subtitle">${u(l)}</p>`)}let f=h(e,F);if(f){let l=this.readPropertyValueReferences(n,f);if(l.length>0){let H=l.map(D=>this.renderBadge(D,F,t)).join("");r.push(`<div class="kan-hero-badges">${H}</div>`)}}return r.push("</header>"),r.join(`
|
|
7
|
-
`)}renderPropertyList(e,n,t){let r=h(e,y);if(!r)return"<!-- LookRenderer: PropertyList missing look.source -->";let a=this.readLabelForUri(r)??r.name,s=K(n,r),i=this.gatherValueItems(s),c=i.length>0?i.map(f=>`<li>${this.renderInlineValue(f,y,t)}</li>`).join(""):'<li class="kan-empty">(no values)</li>';return['<section class="kan-property-list">',`<h3 class="kan-property-list-title">${u(a)}</h3>`,`<ul class="kan-property-list-items">${c}</ul>`,"</section>"].join(`
|
|
8
|
-
`)}renderBadgeRow(e,n,t){let r=h(e,y);if(!r)return"<!-- LookRenderer: BadgeRow missing look.source -->";let a=this.readPropertyValueReferences(n,r);return a.length===0?"":`<div class="kan-badge-row">${a.map(i=>this.renderBadge(i,y,t)).join("")}</div>`}renderChipRow(e,n,t){let r=T(e,X);if(r.length===0)return"<!-- LookRenderer: ChipRow has no look.chips -->";let a=[];for(let s of r){let i=K(n,s);if(!i)continue;let c=this.readLabelForUri(s)??s.name,f=this.renderStatementInlineValue(i,s,t);f&&a.push(`<span class="kan-chip"><span class="kan-chip-key">${u(c)}</span> <span class="kan-chip-val">${f}</span></span>`)}return a.length===0?"":`<div class="kan-chip-row">${a.join("")}</div>`}renderReferenceList(e,n,t){let r=T(e,P);if(r.length===0)return"<!-- LookRenderer: ReferenceList has no look.entries -->";let a=[];for(let s of r){let i=this.readPropertyValueReferences(n,s);if(i.length===0)continue;let c=this.readLabelForUri(s)??s.name,f=i.map(l=>this.renderReferenceLink(l,P,t)).join(", ");a.push(`<dt>${u(c)}</dt><dd>${f}</dd>`)}return a.length===0?"":`<dl class="kan-reference-list">${a.join("")}</dl>`}readPropertyValueText(e,n){let t=K(e,n);if(t){if(t instanceof m)return t.object;if(t instanceof d){let r=t.object;return this.readLabelForUri({publisher:r.subject.publisher,package_:r.subject.package_,name:r.subject.name})??r.subject.name}if(t instanceof k)return(t.object??[]).map(a=>a instanceof p?this.readLabelForUri({publisher:a.subject.publisher,package_:a.subject.package_,name:a.subject.name})??a.subject.name:a instanceof _?a.name??"":String(a)).filter(a=>a).join(", ")}}readPropertyValueReferences(e,n){let t=K(e,n);if(!t)return[];if(t instanceof d)return[t.object];if(t instanceof k){let r=[];for(let a of t.object??[])a instanceof p&&r.push(a);return r}return[]}gatherValueItems(e){return e?e instanceof k?e.object??[]:e instanceof d?[e.object]:e instanceof v?[e.object]:e instanceof m?[e.object]:[]:[]}renderInlineValue(e,n,t){return e instanceof p?this.renderReferenceLink(e,n,t):e instanceof _?u(e.name??"(embedded)"):typeof e=="string"?u(e):typeof e=="number"||typeof e=="boolean"?u(String(e)):""}renderStatementInlineValue(e,n,t){return e instanceof m?u(e.object):e instanceof d?this.renderReferenceLink(e.object,n,t):e instanceof k?(e.object??[]).map(a=>this.renderInlineValue(a,n,t)).filter(a=>a).join(", "):""}renderReferenceLink(e,n,t){let r=this.readLabelForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name})??e.subject.name,a=this.urlForReference(e,n,t);return`<a class="kan-link" href="${u(a)}">${u(r)}</a>`}renderBadge(e,n,t){let r=this.readLabelForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name})??e.subject.name,a=this.readCommentForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name}),s=this.urlForReference(e,n,t),i=a?` title="${u(a)}"`:"";return`<a class="kan-badge" href="${u(s)}"${i}>${u(r)}</a>`}urlForReference(e,n,t){let r=n?this.getUrlFormForProperty(n):"=";return $.formatResourceUrl({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},r,{contextPublisher:t})}getUrlFormForProperty(e){let n=g(this.catalog,e);if(!n)return"=";let t=E(n,Z);return t==="*"||t==="^"||t==="~"||t==="="?t:"="}readLabelForUri(e){let n=g(this.catalog,e);if(n)return E(n,M)}readCommentForUri(e){let n=g(this.catalog,e);if(n)return E(n,N)}};function I(o){let e=new Map;for(let n of o.statement){if(!(n instanceof v)||!b(n,U.publisher,U.package_,U.name))continue;let t=n.object;for(let r of t.statement){if(!(r instanceof m))continue;let a=r.predicate?.subject?.name;if(!a)continue;let s=r.object;e.set(a,s)}return e}return e}function C(o){for(let e of o.statement)if(e instanceof v&&b(e,L.publisher,L.package_,L.name))return e.object}function ee(o){for(let e of o.statement){if(!(e instanceof k)||!b(e,O.publisher,O.package_,O.name))continue;let n=[];for(let t of e.object??[])t instanceof _&&n.push(t);return n}return[]}function ne(o){for(let e of o.statement)if(e instanceof d&&e.predicate?.subject?.name==="type"&&e.object instanceof p){let n=e.object.subject;return{publisher:n.publisher,package_:n.package_,name:n.name}}}function h(o,e){for(let n of o.statement)if(n instanceof d&&b(n,e.publisher,e.package_,e.name)&&n.object instanceof p){let t=n.object.subject;return{publisher:t.publisher,package_:t.package_,name:t.name}}}function T(o,e){for(let n of o.statement){if(!(n instanceof k)||!b(n,e.publisher,e.package_,e.name))continue;let t=[];for(let r of n.object??[])r instanceof p&&t.push({publisher:r.subject.publisher,package_:r.subject.package_,name:r.subject.name});return t}return[]}function K(o,e){for(let n of o.statement)if(b(n,e.publisher,e.package_,e.name))return n}function E(o,e){for(let n of o.statement)if(n instanceof m&&b(n,e.publisher,e.package_,e.name))return n.object}function B(o){let e=[];for(let n of o.statement)if(n instanceof d){if(n.predicate?.subject?.name!=="type")continue;n.object instanceof p&&e.push(n.object)}else if(n instanceof k){if(n.predicate?.subject?.name!=="type")continue;for(let t of n.object??[])t instanceof p&&e.push(t)}return e}function V(o){let e=[];for(let n of o.statement)if(n instanceof d){if(n.predicate?.subject?.name!=="subClassOf")continue;n.object instanceof p&&e.push(n.object)}else if(n instanceof k){if(n.predicate?.subject?.name!=="subClassOf")continue;for(let t of n.object??[])t instanceof p&&e.push(t)}return e}function g(o,e){let n="version"in e?e.version:void 0;if(n){let t=`${e.publisher}/${e.package_}@${n.major}.${n.minor}.${n.patch}`;for(let r of o)if(r instanceof S&&r.name===e.name&&r.namespace===t)return r}for(let t of o){if(!(t instanceof S)||t.name!==e.name)continue;if((t.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))return t}}function b(o,e,n,t){let r=o.predicate?.subject;return r?r.publisher===e&&r.package_===n&&r.name===t:!1}function R(o,e){return o.publisher===e.publisher&&o.package_===e.package_&&o.name===e.name}function x(o){return`${o.publisher}/${o.package_}/${o.name}`}function te(o){let e=o.namespace||"",n=e.indexOf("/");return n>=0?e.substring(0,n):e}function u(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var re=`
|
|
9
|
-
* { box-sizing: border-box; }
|
|
10
|
-
body {
|
|
11
|
-
background: var(--kan-bg);
|
|
12
|
-
color: var(--kan-text);
|
|
13
|
-
font-family: var(--kan-font-body);
|
|
14
|
-
line-height: var(--kan-line-height-body);
|
|
15
|
-
margin: 0;
|
|
16
|
-
}
|
|
17
|
-
a { color: var(--kan-accent); text-decoration: none; }
|
|
18
|
-
a:hover { color: var(--kan-accent-hover); text-decoration: underline; }
|
|
19
|
-
|
|
20
|
-
/* Hero band */
|
|
21
|
-
.kan-hero {
|
|
22
|
-
padding: 32px 0 24px;
|
|
23
|
-
border-bottom: 1px solid var(--kan-border);
|
|
24
|
-
margin-bottom: 32px;
|
|
25
|
-
}
|
|
26
|
-
.kan-hero-eyebrow {
|
|
27
|
-
font-family: var(--kan-font-mono);
|
|
28
|
-
font-size: 11px;
|
|
29
|
-
color: var(--kan-accent);
|
|
30
|
-
letter-spacing: 0.18em;
|
|
31
|
-
text-transform: uppercase;
|
|
32
|
-
margin-bottom: 12px;
|
|
33
|
-
display: block;
|
|
34
|
-
}
|
|
35
|
-
.kan-hero-title {
|
|
36
|
-
font-family: var(--kan-font-display);
|
|
37
|
-
font-size: 32px;
|
|
38
|
-
font-weight: 600;
|
|
39
|
-
letter-spacing: -0.015em;
|
|
40
|
-
margin: 0 0 12px;
|
|
41
|
-
line-height: var(--kan-line-height-heading);
|
|
42
|
-
color: var(--kan-text);
|
|
43
|
-
}
|
|
44
|
-
.kan-hero-subtitle {
|
|
45
|
-
font-size: 17px;
|
|
46
|
-
color: var(--kan-text-dim);
|
|
47
|
-
font-weight: 300;
|
|
48
|
-
line-height: 1.55;
|
|
49
|
-
margin: 0 0 16px;
|
|
50
|
-
}
|
|
51
|
-
.kan-hero-badges {
|
|
52
|
-
display: flex;
|
|
53
|
-
flex-wrap: wrap;
|
|
54
|
-
gap: 6px;
|
|
55
|
-
margin-top: 12px;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/* PropertyList band */
|
|
59
|
-
.kan-property-list {
|
|
60
|
-
margin: 24px 0;
|
|
61
|
-
}
|
|
62
|
-
.kan-property-list-title {
|
|
63
|
-
font-family: var(--kan-font-mono);
|
|
64
|
-
font-size: 11px;
|
|
65
|
-
letter-spacing: 0.18em;
|
|
66
|
-
text-transform: uppercase;
|
|
67
|
-
color: var(--kan-text-dim);
|
|
68
|
-
margin: 0 0 12px;
|
|
69
|
-
font-weight: 600;
|
|
70
|
-
}
|
|
71
|
-
.kan-property-list-items {
|
|
72
|
-
list-style: none;
|
|
73
|
-
padding: 0;
|
|
74
|
-
margin: 0;
|
|
75
|
-
display: flex;
|
|
76
|
-
flex-direction: column;
|
|
77
|
-
gap: 6px;
|
|
78
|
-
}
|
|
79
|
-
.kan-property-list-items > li {
|
|
80
|
-
color: var(--kan-text);
|
|
81
|
-
}
|
|
82
|
-
.kan-property-list-items > li.kan-empty {
|
|
83
|
-
color: var(--kan-text-faint);
|
|
84
|
-
font-style: italic;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/* BadgeRow band */
|
|
88
|
-
.kan-badge-row {
|
|
89
|
-
display: flex;
|
|
90
|
-
flex-wrap: wrap;
|
|
91
|
-
gap: 6px;
|
|
92
|
-
margin: 16px 0;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/* Badge (used by Hero badges + BadgeRow) */
|
|
96
|
-
.kan-badge {
|
|
97
|
-
display: inline-block;
|
|
98
|
-
padding: 2px 8px;
|
|
99
|
-
background: var(--kan-badge-bg);
|
|
100
|
-
color: var(--kan-badge-fg);
|
|
101
|
-
border-radius: var(--kan-radius-sm);
|
|
102
|
-
font-size: 11px;
|
|
103
|
-
font-weight: 500;
|
|
104
|
-
text-decoration: none;
|
|
105
|
-
letter-spacing: 0.02em;
|
|
106
|
-
}
|
|
107
|
-
.kan-badge:hover {
|
|
108
|
-
filter: brightness(1.1);
|
|
109
|
-
text-decoration: none;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/* ChipRow band */
|
|
113
|
-
.kan-chip-row {
|
|
114
|
-
display: flex;
|
|
115
|
-
flex-wrap: wrap;
|
|
116
|
-
gap: 8px;
|
|
117
|
-
margin: 16px 0;
|
|
118
|
-
}
|
|
119
|
-
.kan-chip {
|
|
120
|
-
display: inline-flex;
|
|
121
|
-
align-items: center;
|
|
122
|
-
gap: 6px;
|
|
123
|
-
padding: 5px 10px;
|
|
124
|
-
background: var(--kan-bg-card);
|
|
125
|
-
border: 1px solid var(--kan-border);
|
|
126
|
-
border-radius: var(--kan-radius-sm);
|
|
127
|
-
font-family: var(--kan-font-mono);
|
|
128
|
-
font-size: 11px;
|
|
129
|
-
text-transform: uppercase;
|
|
130
|
-
letter-spacing: 0.04em;
|
|
131
|
-
}
|
|
132
|
-
.kan-chip-key { color: var(--kan-text-faint); }
|
|
133
|
-
.kan-chip-val { color: var(--kan-text); font-weight: 500; }
|
|
134
|
-
|
|
135
|
-
/* ReferenceList band */
|
|
136
|
-
dl.kan-reference-list {
|
|
137
|
-
display: grid;
|
|
138
|
-
grid-template-columns: max-content 1fr;
|
|
139
|
-
gap: 8px 16px;
|
|
140
|
-
margin: 16px 0;
|
|
141
|
-
padding: 16px 18px;
|
|
142
|
-
background: var(--kan-bg-card);
|
|
143
|
-
border: 1px solid var(--kan-border);
|
|
144
|
-
border-radius: var(--kan-radius);
|
|
145
|
-
}
|
|
146
|
-
dl.kan-reference-list dt {
|
|
147
|
-
font-family: var(--kan-font-mono);
|
|
148
|
-
font-size: 11px;
|
|
149
|
-
text-transform: uppercase;
|
|
150
|
-
letter-spacing: 0.1em;
|
|
151
|
-
color: var(--kan-text-faint);
|
|
152
|
-
align-self: center;
|
|
153
|
-
}
|
|
154
|
-
dl.kan-reference-list dd { margin: 0; align-self: center; }
|
|
155
|
-
|
|
156
|
-
/* Link (used by reference values across bands) */
|
|
157
|
-
.kan-link {
|
|
158
|
-
color: var(--kan-accent);
|
|
159
|
-
text-decoration: none;
|
|
160
|
-
}
|
|
161
|
-
.kan-link:hover {
|
|
162
|
-
color: var(--kan-accent-hover);
|
|
163
|
-
text-decoration: underline;
|
|
164
|
-
}
|
|
165
|
-
`.trim();export{w as a};
|
|
File without changes
|