@kanonak-protocol/sdk 3.19.0 → 3.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canonical/CanonicalHash.d.ts +20 -0
- package/dist/canonical/index.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +22 -22
- package/dist/transformations/index.js +45 -45
- package/dist/transformations/v3/CompiledTransformationV3.d.ts +13 -1
- package/dist/transformations/v3/TransformationUriConstantsV3.d.ts +3 -0
- package/package.json +3 -3
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Kanonak } from '../kanonaks/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Render a parsed kanonak collection into its canonical JSON form.
|
|
4
|
+
*
|
|
5
|
+
* `kanonaks` should be the `SubjectKanonak` instances from a single
|
|
6
|
+
* package — typically the result of `KanonakObjectParser.parseKanonaks`
|
|
7
|
+
* over a `SingleDocumentRepository`. Embedded, reference, and literal
|
|
8
|
+
* kanonaks are walked through subjects' statement trees; they don't
|
|
9
|
+
* count as top-level subjects.
|
|
10
|
+
*
|
|
11
|
+
* Returns the JSON string (no trailing newline). Identical inputs
|
|
12
|
+
* always produce byte-identical output.
|
|
13
|
+
*/
|
|
14
|
+
export declare function canonicalForm(kanonaks: Kanonak[]): string;
|
|
15
|
+
/**
|
|
16
|
+
* SHA-256 of the canonical form, prefixed `sha256:`. The output is
|
|
17
|
+
* 71 characters (`sha256:` + 64 hex digits) and matches the
|
|
18
|
+
* convention used by `kanonak.lock` integrity entries.
|
|
19
|
+
*/
|
|
20
|
+
export declare function canonicalHash(kanonaks: Kanonak[]): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { canonicalForm, canonicalHash } from './CanonicalHash.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -26,3 +26,4 @@ export { loadLockFile, saveLockFile, computeIntegrity, } from './lock/index.js';
|
|
|
26
26
|
export type { LockFile, LockEntry } from './lock/index.js';
|
|
27
27
|
export { findDerivation } from './derivation/index.js';
|
|
28
28
|
export type { DerivationEntityUri, TransformationReferenceTuple, DerivationLookupResult, } from './derivation/index.js';
|
|
29
|
+
export { canonicalForm, canonicalHash } from './canonical/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{a as
|
|
2
|
-
Run 'kanonak logout ${
|
|
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-2SSUPRX3.js";import{a as qe,b as Ye,c as Xe,d as b,e as S,f as i}from"./chunk-BQIWYLBU.js";import{a as Gt}from"./chunk-C2WWLKWE.js";import{a as Te,b as je,c as Ne,d as Fe,e as Le}from"./chunk-3JRHG2JH.js";import{a as Be,b as De,c as Oe,d as Ae}from"./chunk-CNM3SY5S.js";import{a as lt,b as dt,c as ut}from"./chunk-CQLO62JP.js";import{a as Je,b as pt,c as mt,d as ft,e as yt}from"./chunk-VRZUCZEF.js";import{a as Pe,b as Re,c as we,d as $e,e as xe,f as ve,g as Ee,h as Ke}from"./chunk-FQHALFRR.js";import{A as Ut,B as _t,C as Mt,D as zt,a as gt,b as ht,c as kt,d as bt,e as St,f as Ct,g as Pt,h as Rt,i as wt,j as $t,k as xt,l as vt,m as Et,n as Kt,o as Bt,p as It,q as Tt,r as jt,s as Nt,t as Ft,u as Lt,v as Dt,w as Ot,x as At,y as Ht,z as Vt}from"./chunk-L4HXBHJ4.js";import"./chunk-FJ35VIV6.js";import{a as F,b as D,c as Me,d as We}from"./chunk-Z72IKY6C.js";import{a as He,b as j,c as N,d as L,e as Ue,f as _e,g as O,h as A,i as H,j as V,k as U,l as _}from"./chunk-W6T7MOKY.js";import{a as Ie}from"./chunk-MYITGTGJ.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 eo}from"@kanonak-protocol/types/document/models/enums";import{existsSync as dr,readFileSync as ur}from"fs";import{homedir as pr}from"os";import{join as mr}from"path";import{execFile as Wt}from"child_process";import{promisify as Jt}from"util";var C=Jt(Wt),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
|
+
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
|
-
Try unlocking it via Keychain Access.app or running 'security unlock-keychain'.`)}}async store(e,
|
|
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)}
|
|
5
5
|
Ensure the Keychain is unlocked and the CLI has write permission.
|
|
6
|
-
On managed devices, your IT policy may block credential storage.`)}}async remove(e){let
|
|
7
|
-
The credential may not have been fully removed.`)}}async list(){try{let{stdout:e}=await
|
|
8
|
-
`))if(o.includes(`"svce"<blob>="${
|
|
6
|
+
On managed devices, your IT policy may block credential storage.`)}}async remove(e){let r=i(e);try{await C(R,["delete-generic-password","-s",P,"-a",r],{timeout:1e4})}catch(n){if(X(n,44))return;console.warn(` Warning: macOS Keychain delete failed for '${r}': ${w(n)}
|
|
7
|
+
The credential may not have been fully removed.`)}}async list(){try{let{stdout:e}=await C(R,["dump-keychain"],{timeout:1e4}),r=[],n=!1;for(let o of e.split(`
|
|
8
|
+
`))if(o.includes(`"svce"<blob>="${P}"`)&&(n=!0),n&&o.includes('"acct"<blob>=')){let a=o.match(/"acct"<blob>="([^"]+)"/);a&&r.push(a[1]),n=!1}return r}catch(e){return console.warn(` Warning: Could not enumerate Keychain entries: ${w(e)}`),[]}}};function X(t,e){return typeof t=="object"&&t!==null&&"code"in t&&t.code===e}function w(t){return t instanceof Error?t.message:String(t)}import{execFile as qt}from"child_process";import{promisify as Yt}from"util";var Xt=Yt(qt),$="kanonak:",m=class{async get(e){let r=$+i(e),n=`
|
|
9
9
|
${v}
|
|
10
10
|
$target = [Console]::In.ReadLine()
|
|
11
11
|
$ptr = [IntPtr]::Zero
|
|
@@ -18,7 +18,7 @@ try {
|
|
|
18
18
|
[System.Text.Encoding]::Unicode.GetString($bytes)
|
|
19
19
|
} finally {
|
|
20
20
|
[CredMan]::CredFree($ptr)
|
|
21
|
-
}`;try{let{stdout:o}=await
|
|
21
|
+
}`;try{let{stdout:o}=await x(n,r),a=o.trim();return a?JSON.parse(a):null}catch{return null}}async store(e,r){let n=$+i(e),o=JSON.stringify(r),a=`
|
|
22
22
|
${v}
|
|
23
23
|
$target = [Console]::In.ReadLine()
|
|
24
24
|
$json = [Console]::In.ReadLine()
|
|
@@ -35,13 +35,13 @@ try {
|
|
|
35
35
|
if (-not $result) { throw "CredWrite failed" }
|
|
36
36
|
} finally {
|
|
37
37
|
[System.Runtime.InteropServices.Marshal]::FreeHGlobal($cred.CredentialBlob)
|
|
38
|
-
}`;try{await
|
|
39
|
-
${o}`)}catch(s){throw new Error(`Windows Credential Manager write failed: ${String(s)}`)}}async remove(e){let
|
|
38
|
+
}`;try{await x(a,`${n}
|
|
39
|
+
${o}`)}catch(s){throw new Error(`Windows Credential Manager write failed: ${String(s)}`)}}async remove(e){let r=$+i(e),n=`
|
|
40
40
|
${v}
|
|
41
41
|
$target = [Console]::In.ReadLine()
|
|
42
|
-
[CredMan]::CredDelete($target, 1, 0) | Out-Null`;try{await
|
|
42
|
+
[CredMan]::CredDelete($target, 1, 0) | Out-Null`;try{await x(n,r)}catch{}}async list(){let e=`
|
|
43
43
|
${v}
|
|
44
|
-
${
|
|
44
|
+
${Zt}
|
|
45
45
|
$prefix = [Console]::In.ReadLine()
|
|
46
46
|
$count = 0
|
|
47
47
|
$pCreds = [IntPtr]::Zero
|
|
@@ -55,8 +55,8 @@ if ([CredMan]::CredEnumerate($null, 0, [ref]$count, [ref]$pCreds)) {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
[CredMan]::CredFree($pCreds)
|
|
58
|
-
}`;try{let{stdout:
|
|
59
|
-
`).map(
|
|
58
|
+
}`;try{let{stdout:r}=await x(e,$);return r.trim().split(`
|
|
59
|
+
`).map(n=>n.trim()).filter(Boolean)}catch{return[]}}};async function x(t,e){for(let r of["pwsh","powershell"])try{return await Xt(r,["-NoProfile","-NonInteractive","-Command",t],{timeout:15e3,...e!==void 0&&{input:e}})}catch(n){if(r==="powershell")throw n}throw new Error("Neither pwsh nor powershell found")}var v=`
|
|
60
60
|
Add-Type -TypeDefinition @"
|
|
61
61
|
using System;
|
|
62
62
|
using System.Runtime.InteropServices;
|
|
@@ -87,13 +87,13 @@ public class CredMan {
|
|
|
87
87
|
[DllImport("Advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
|
88
88
|
public static extern bool CredEnumerate(string filter, int flags, out int count, out IntPtr credentials);
|
|
89
89
|
}
|
|
90
|
-
"@`,
|
|
91
|
-
`)){let o=
|
|
90
|
+
"@`,Zt="";import{execFile as Qt,spawn as er}from"child_process";import{promisify as tr}from"util";var K=tr(Qt),E="kanonak",f=class{async get(e){let r=i(e);try{let{stdout:n}=await K("secret-tool",["lookup","service",E,"publisher",r],{timeout:1e4}),o=n.trim();return o?JSON.parse(o):null}catch{return null}}async store(e,r){let n=i(e),o=JSON.stringify(r);await new Promise((a,s)=>{let c=er("secret-tool",["store","--label",`Kanonak: ${n}`,"service",E,"publisher",n],{stdio:["pipe","ignore","ignore"],timeout:1e4});c.stdin.write(o),c.stdin.end(),c.on("close",l=>{l===0?a():s(new Error(`secret-tool store exited with code ${l}`))}),c.on("error",s)})}async remove(e){let r=i(e);try{await K("secret-tool",["clear","service",E,"publisher",r],{timeout:1e4})}catch{}}async list(){try{let{stdout:e}=await K("secret-tool",["search","service",E],{timeout:1e4}),r=[];for(let n of e.split(`
|
|
91
|
+
`)){let o=n.match(/attribute\.publisher\s*=\s*(.+)/);o&&r.push(o[1].trim())}return r}catch{return[]}}};async function M(){try{return await K("sh",["-c","command -v secret-tool"],{timeout:5e3}),!0}catch{return!1}}import{existsSync as Z,mkdirSync as Q,readFileSync as ee,writeFileSync as te}from"fs";import{createCipheriv as rr,createDecipheriv as nr,randomBytes as re}from"crypto";import{homedir as or}from"os";import{join as W,dirname as ne}from"path";var ae=W(or(),".config","kanonak"),y=W(ae,"keyring.key"),B=W(ae,"credentials.enc"),oe="aes-256-gcm",z=32,u=12,G=16,g=class{async get(e){let r=this.loadStore(),n=i(e);return r[n]??null}async store(e,r){let n=this.loadStore(),o=i(e);n[o]=r,this.saveStore(n)}async remove(e){let r=this.loadStore(),n=i(e);delete r[n],this.saveStore(r)}async list(){let e=this.loadStore();return Object.keys(e)}loadStore(){if(!Z(B))return{};try{let e=this.getOrCreateKey(),r=ee(B);if(r.length<u+G)return{};let n=r.subarray(0,u),o=r.subarray(u,u+G),a=r.subarray(u+G),s=nr(oe,e,n);s.setAuthTag(o);let c=Buffer.concat([s.update(a),s.final()]);return JSON.parse(c.toString("utf-8"))}catch{return{}}}saveStore(e){let r=this.getOrCreateKey(),n=re(u),o=rr(oe,r,n),a=Buffer.from(JSON.stringify(e),"utf-8"),s=Buffer.concat([o.update(a),o.final()]),c=o.getAuthTag(),l=Buffer.concat([n,c,s]);Q(ne(B),{recursive:!0}),te(B,l,{mode:384})}getOrCreateKey(){if(Z(y)){let r=ee(y);if(r.length!==z)throw new Error(`Credential keyring key is corrupted (expected ${z} bytes, got ${r.length}). Delete ${y} and re-authenticate.`);return r}let e=re(z);return Q(ne(y),{recursive:!0}),te(y,e,{mode:384}),e}};import{execFile as ar}from"child_process";import{promisify as ir}from"util";var sr=ir(ar),ie=3e4,h=class{constructor(e){this.helperPath=e}helperPath;async get(e){let r=i(e);try{let o=(await this.runHelper("get",{publisher:r})).trim();return o?JSON.parse(o):null}catch(n){throw new Error(`Credential helper '${this.helperPath}' failed to read credential for '${r}': ${I(n)}
|
|
92
92
|
Verify the helper binary exists, is executable, and implements the Kanonak credential helper protocol.
|
|
93
|
-
Check the 'credentialHelper' path in ~/.kanonak/config.json.`)}}async store(e,
|
|
94
|
-
Verify the helper binary supports the 'store' action.`)}}async remove(e){let
|
|
95
|
-
Check the 'credentialHelper' path in ~/.kanonak/config.json.`):
|
|
96
|
-
The helper may be waiting for authentication to an external vault.`):
|
|
97
|
-
Using default credential backend. Fix the JSON syntax or delete the file.`),{}}}import{createHash as
|
|
98
|
-
The stored key pair may be corrupted. Run 'kanonak login ${
|
|
99
|
-
`;function
|
|
93
|
+
Check the 'credentialHelper' path in ~/.kanonak/config.json.`)}}async store(e,r){let n=i(e);try{await this.runHelper("store",{publisher:n,credential:r})}catch(o){throw new Error(`Credential helper '${this.helperPath}' failed to store credential for '${n}': ${I(o)}
|
|
94
|
+
Verify the helper binary supports the 'store' action.`)}}async remove(e){let r=i(e);try{await this.runHelper("erase",{publisher:r})}catch(n){console.warn(` Warning: Credential helper '${this.helperPath}' failed to erase credential for '${r}': ${I(n)}`)}}async list(){try{let e=await this.runHelper("list",void 0);return JSON.parse(e.trim())}catch(e){return console.warn(` Warning: Credential helper '${this.helperPath}' failed to list credentials: ${I(e)}`),[]}}async runHelper(e,r){try{let{stdout:n}=await sr(this.helperPath,[e],{...r&&{input:JSON.stringify(r)},timeout:ie});return n}catch(n){throw cr(n)?new Error(`Credential helper not found at '${this.helperPath}'.
|
|
95
|
+
Check the 'credentialHelper' path in ~/.kanonak/config.json.`):lr(n)?new Error(`Credential helper '${this.helperPath}' timed out after ${ie/1e3}s on '${e}'.
|
|
96
|
+
The helper may be waiting for authentication to an external vault.`):n}}};function I(t){return t instanceof Error?t.message:String(t)}function cr(t){return t instanceof Error&&"code"in t&&t.code==="ENOENT"}function lr(t){return t instanceof Error&&"killed"in t&&t.killed}var J=mr(pr(),".kanonak","config.json"),T=class{backend=null;backendReady=null;async getBackend(){if(this.backend)return this.backend;if(this.backendReady)return this.backendReady;this.backendReady=this.resolveBackend();try{return this.backend=await this.backendReady,this.backend}catch(e){throw this.backendReady=null,e}}async getToken(e){let r=fr(e);if(r)return r;let o=await(await this.getBackend()).get(e);return!o||!S(o)?null:o.accessToken??null}async getCredential(e){return(await this.getBackend()).get(e)}async store(e,r){return(await this.getBackend()).store(e,r)}async remove(e){return(await this.getBackend()).remove(e)}async list(){return(await this.getBackend()).list()}async resolveBackend(){let e=yr();return e.credentialHelper?new h(e.credentialHelper):process.platform==="darwin"?new p:process.platform==="win32"?new m:await M()?new f:new g}};function fr(t){let r="KANONAK_TOKEN_"+i(t).replace(/[.\-]/g,"_").toUpperCase();return process.env[r]??null}function yr(){if(!dr(J))return{};try{return JSON.parse(ur(J,"utf-8"))}catch(t){let e=t instanceof Error?t.message:String(t);return console.warn(` Warning: Failed to parse ${J}: ${e}
|
|
97
|
+
Using default credential backend. Fix the JSON syntax or delete the file.`),{}}}import{createHash as gr,createPrivateKey as hr,generateKeyPairSync as kr,randomUUID as br,sign as Sr}from"crypto";function ce(){let{publicKey:t,privateKey:e}=kr("ec",{namedCurve:"P-256"});return{publicKey:t.export({format:"jwk"}),privateKey:e.export({format:"jwk"})}}function k(t,e,r,n,o,a){let s={alg:"ES256",typ:"dpop+jwt",jwk:{kty:e.kty,crv:e.crv,x:e.x,y:e.y}},c={jti:br(),htm:r.toUpperCase(),htu:n,iat:Math.floor(Date.now()/1e3)};return o&&(c.ath=gr("sha256").update(o).digest("base64url")),a&&(c.nonce=a),Cr(s,c,t)}function le(t){return!t||t.length===0?!1:t.some(e=>e.toUpperCase()==="ES256")}function Cr(t,e,r){let n=se(JSON.stringify(t)),o=se(JSON.stringify(e)),a=`${n}.${o}`,s=hr({key:r,format:"jwk"}),l=Sr("SHA256",Buffer.from(a),{key:s,dsaEncoding:"ieee-p1363"}).toString("base64url");return`${a}.${l}`}function se(t){return Buffer.from(t,"utf-8").toString("base64url")}function de(t){let e=new Map;return async(r,n,o="GET")=>{if(!t)return fetch(r,{method:o});let a=await t.getCredential(n);if(!a?.accessToken)return fetch(r,{method:o});b(a)&&console.warn(` Warning: Access token for '${n}' is expired. Run 'kanonak login ${n}' to re-authenticate.`);let s={};if(a.dpopKeyPair){let l=e.get(n);try{let d=k(a.dpopKeyPair.privateKey,a.dpopKeyPair.publicKey,o,r,a.accessToken,l);s.Authorization=`DPoP ${a.accessToken}`,s.DPoP=d}catch(d){let Ce=d instanceof Error?d.message:String(d);console.error(` Error: Failed to create DPoP proof for '${n}': ${Ce}
|
|
98
|
+
The stored key pair may be corrupted. Run 'kanonak login ${n}' to re-authenticate.`),s.Authorization=`Bearer ${a.accessToken}`}}else s.Authorization=`Bearer ${a.accessToken}`;let c=await fetch(r,{method:o,headers:s});if(c.status===401&&a.dpopKeyPair){let l=c.headers.get("DPoP-Nonce");if(l){e.set(n,l);try{let d=k(a.dpopKeyPair.privateKey,a.dpopKeyPair.publicKey,o,r,a.accessToken,l);s.DPoP=d,c=await fetch(r,{method:o,headers:s})}catch{}}}return c}}import{readFileSync as Pr,writeFileSync as Rr,existsSync as wr}from"fs";import{createHash as $r}from"crypto";import ue from"js-yaml";var pe="kanonak.lock",xr=`# This file is generated by Kanonak CLI. Do not edit manually.
|
|
99
|
+
`;function me(t=pe){if(!wr(t))return null;let e=Pr(t,"utf-8"),r=ue.load(e);return!r||typeof r!="object"||r.version!=="1"?null:{version:"1",lastUpdated:r.lastUpdated??new Date().toISOString(),packages:r.packages??{}}}function fe(t,e=pe){t.lastUpdated=new Date().toISOString();let r={};for(let o of Object.keys(t.packages).sort())r[o]=t.packages[o];t.packages=r;let n=ue.dump(t,{lineWidth:-1,sortKeys:!1,quotingType:'"'});Rr(e,xr+n,"utf-8")}function ye(t){return`sha256:${$r("sha256").update(t).digest("hex")}`}import{createHash as vr}from"crypto";function q(t){let e=[];for(let n of t)n instanceof N&&e.push(Er(n));return e.sort((n,o)=>n.uri<o.uri?-1:n.uri>o.uri?1:0),JSON.stringify({subjects:e})}function ge(t){let e=q(t);return`sha256:${vr("sha256").update(e,"utf8").digest("hex")}`}function Er(t){let e=Nr(t),r=Y(t.statement);return{uri:e,statements:r}}function Y(t){let e=[];for(let r of t){let n=Kr(r);n&&e.push(n)}return e.sort((r,n)=>r.predicate<n.predicate?-1:r.predicate>n.predicate?1:0),e}function Kr(t){let e=jr(t);if(!e)return;let r=Br(t);if(r)return Tr(e,r)}function Br(t){if(t instanceof O)return{type:"string",value:t.object};if(t instanceof A)return{type:"number",value:Se(t.object)};if(t instanceof H)return{type:"boolean",value:t.object};if(t instanceof V)return{type:"ref",value:ke(t.object)};if(t instanceof U){let e=t.object;return he(e)}if(t instanceof _)return{type:"list",items:t.object.map(Ir)}}function he(t){let e=Y(t.statement);return t.name&&t.name.length>0?{type:"embedded",name:t.name,statements:e}:{type:"embedded",statements:e}}function Ir(t){if(t instanceof L)return{type:"ref",value:ke(t)};if(t instanceof F)return he(t);if(t instanceof D){let e=t.value;if(typeof e=="string")return{type:"string",value:e};if(typeof e=="number")return{type:"number",value:Se(e)};if(typeof e=="boolean")return{type:"boolean",value:e}}if(t instanceof j)return{type:"embedded",statements:Y(t.statement)};throw new Error(`canonicalForm: list item of unrecognized kind (${t.constructor?.name??typeof t}); add canonicalization support before hashing data that contains it`)}function Tr(t,e){switch(e.type){case"string":return{predicate:t,type:"string",value:e.value};case"number":return{predicate:t,type:"number",value:e.value};case"boolean":return{predicate:t,type:"boolean",value:e.value};case"ref":return{predicate:t,type:"ref",value:e.value};case"embedded":return e.name!==void 0?{predicate:t,type:"embedded",name:e.name,statements:e.statements}:{predicate:t,type:"embedded",statements:e.statements};case"list":return{predicate:t,type:"list",items:e.items}}}function jr(t){let e=t.predicate;if(e)return be(e.subject)}function Nr(t){let e=t.namespace??"",r=t.name??"";return`${e}/${r}`}function ke(t){return be(t.subject)}function be(t){let e=t.version;return e&&typeof e.major=="number"?`${t.publisher}/${t.package_}@${e.major}.${e.minor}.${e.patch}/${t.name}`:`${t.publisher}/${t.package_}/${t.name}`}function Se(t){if(Number.isNaN(t))throw new Error("canonicalForm: NaN cannot be canonicalized");if(!Number.isFinite(t))throw new Error("canonicalForm: \xB1Infinity cannot be canonicalized");return Object.is(t,-0)?"0":String(t)}export{Dt as AmbiguousReferenceRule,H as BooleanStatement,_t as ClassDefinitionRule,Et as ClassHierarchyCycleRule,Ne as CompositeKanonakDocumentRepository,T as CredentialStore,j as DefinedKanonak,Ft as DefinitionPropertyReferenceRule,je as DocumentLocation,Ye as EdgeType,F as EmbeddedKanonak,wt as EmbeddedKanonakTypeRule,U as EmbeddedStatement,Te as FileSystemKanonakDocumentRepository,ct as GitIgnoreFilter,Xe as GraphBuilder,Ae as HttpKanonakDocumentRepository,$t as ImportExistenceRule,Be as InMemoryKanonakDocumentRepository,Nt as InstancePropertyReferenceRule,He as Kanonak,dt as KanonakDocumentPositions,We as KanonakObjectParser,zt as KanonakObjectValidator,Ie as KanonakParser,Ve as KanonakUri,pt as KanonakUriBuilder,nt as KanonakVocabulary,_ as ListStatement,D as LiteralKanonak,Mt as MarkdownLinkRule,Me as MarkdownStatement,jt as NamespaceImportCycleRule,St as NamespacePrefixRule,qe as NodeType,A as NumberStatement,at as OWL_RL_CLASSIFICATION_RULES,At as ObjectPropertyImportRule,Ht as ObjectPropertyValueValidationRule,kt as OntologyValidationError,gt as OntologyValidationResult,Vt as PropertyDomainRule,Kt as PropertyHierarchyCycleRule,lt as PropertyMetadata,Ot as PropertyRangeReferenceRule,Bt as PropertyRangeRequiredRule,Pt as PropertyTypeSpecificityRule,Ut as PropertyValueTypeRule,De as PublisherConfigResolver,Oe as PublisherIndex,ot as RDFS_RULES,st as Reasoner,it as ReasoningResult,L as ReferenceKanonak,V as ReferenceStatement,Le as RepositoryFactory,Ct as ResourceNamingRule,ze as ResourceResolver,Je as ResourceTypeClassifier,_e as ScalarStatement,Ue as Statement,O as StringStatement,It as SubClassOfReferenceRule,Tt as SubPropertyOfReferenceRule,N as SubjectKanonak,Rt as SubjectKanonakTypeRequiredRule,rt as TripleStore,vt as TypeAmbiguityRule,Ge as TypeResolver,xt as UnresolvedReferenceRule,bt as ValidationContext,ht as ValidationSeverity,eo as VersionOperator,Lt as XsdImportRule,q as canonicalForm,ge as canonicalHash,Pe as compareVersions,ye as computeIntegrity,de as createAuthenticatedFetch,k as createDPoPProof,$e as createVersion,Gt as findDerivation,yt as findInstancesByType,ft as formatKanonakAddress,we as formatVersion,ce as generateDPoPKeyPair,Fe as getGlobalCachePath,S as hasValidToken,ve as isCompatibleVersion,b as isExpired,Ee as isMajorCompatible,me as loadLockFile,Qe as makeUriKey,i as normalizeHost,mt as parseKanonakAddress,xe as parseVersionString,ut as parseWithPositions,Ke as pickHighestDocument,fe as saveLockFile,le as serverSupportsDPoP,et as tripleKey,Ze as uriKey,tt as uriTriple,Re as versionsEqual};
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import{b as S,c as
|
|
1
|
+
import{b as S,c as I,d as f,f as q}from"../chunk-2JQMUZWN.js";import{a as Ne}from"../chunk-C2WWLKWE.js";import"../chunk-CQLO62JP.js";import{a as Oe}from"../chunk-FJ35VIV6.js";import{a as R,c as Ce,d as Ue}from"../chunk-Z72IKY6C.js";import{b as K,c as E,d as b,g as L,h as C,i as U,j as V,k as T,l as w}from"../chunk-W6T7MOKY.js";import{a as Re}from"../chunk-MYITGTGJ.js";import"../chunk-IXE5THUW.js";import"../chunk-FUUTGGJS.js";var bt="kanonak.org",wt="document-ast",p=t=>({publisher:bt,package_:wt,name:t}),h={Document:p("Document"),Block:p("Block"),Inline:p("Inline"),StructuredValue:p("StructuredValue"),Heading:p("Heading"),Paragraph:p("Paragraph"),RawBlock:p("RawBlock"),Text:p("Text"),StructuredMap:p("StructuredMap"),StructuredEntry:p("StructuredEntry"),StructuredList:p("StructuredList"),StringScalar:p("StringScalar"),IntegerScalar:p("IntegerScalar"),EscapeHint:p("EscapeHint"),MediaType:p("MediaType"),metadata:p("metadata"),children:p("children"),level:p("level"),inlines:p("inlines"),text:p("text"),entries:p("entries"),key:p("key"),value:p("value"),escapeHint:p("escapeHint"),items:p("items"),stringValue:p("stringValue"),integerValue:p("integerValue"),rawContent:p("rawContent"),mediaType:p("mediaType"),mimeType:p("mimeType"),ESC_RAW:p("esc-raw"),ESC_YAML_SAFE:p("esc-yaml-safe"),ESC_TOML_STRING:p("esc-toml-string"),ESC_TOML_MULTILINE:p("esc-toml-multiline"),ESC_JSON:p("esc-json"),ESC_DYNAMODB_BOOL:p("esc-dynamodb-bool"),ESC_DYNAMODB_NUMBER:p("esc-dynamodb-number"),ESC_DYNAMODB_NULL:p("esc-dynamodb-null"),TEXT_PLAIN:p("text-plain"),TEXT_MARKDOWN:p("text-markdown"),TEXT_HTML:p("text-html"),TEXT_CSS:p("text-css"),APPLICATION_JSON:p("application-json"),TEXT_YAML:p("text-yaml"),IMAGE_SVG_XML:p("image-svg-xml"),ResourceLink:p("ResourceLink"),target:p("target"),linkLabel:p("linkLabel"),PropertyList:p("PropertyList"),propertyEntries:p("propertyEntries"),PropertyEntry:p("PropertyEntry"),propertyKey:p("propertyKey"),propertyValue:p("propertyValue"),Table:p("Table"),tableColumnLabels:p("tableColumnLabels"),tableRows:p("tableRows"),TableRow:p("TableRow"),tableCells:p("tableCells")};function _e(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=St(e.metadata,n),i=vt(e.children),u=["---",...r,"---","",i].join(`
|
|
2
2
|
`);return n?.trailingNewline&&(u.endsWith(`
|
|
3
3
|
`)||(u+=`
|
|
4
|
-
`)),u}};function
|
|
4
|
+
`)),u}};function St(t,e){if(!t)return[];let n=new Map;for(let c of t.entries)n.set(ce(c.key),c);let r=new Map;if(e?.metadataRenames)for(let[c,l]of e.metadataRenames)r.set(ce(c),l);let a=(e?.metadataKeys??t.entries.map(c=>c.key)).map(ce),u=[];for(let c of a){let l=n.get(c);if(!l)continue;let m=r.get(c),g=ce(m??c),k=Me(l.value,l.escapeHint);k!==void 0&&u.push(`${g}: ${k}`)}return u}function ce(t){let e=t.lastIndexOf(".");return e===-1?t:t.substring(e+1)||t}function Me(t,e){switch(t.kind){case"StringScalar":return Et(t.stringValue,e);case"IntegerScalar":return String(t.integerValue);case"StructuredList":{let n=[];for(let r of t.items){let i=Me(r,e);i!==void 0&&n.push(i)}return n.join(", ")}case"StructuredMap":return;default:return}}function Et(t,e){return!e||_e(e,h.ESC_RAW)?t:_e(e,h.ESC_YAML_SAFE)?$t(t):t}function $t(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 vt(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
|
|
11
|
-
`)?r.push(`${
|
|
12
|
-
${u}`):r.push(`${
|
|
9
|
+
`)}function he(t){switch(t.kind){case"Heading":return`${"#".repeat(t.level)} ${le(t.inlines)}`;case"Paragraph":return le(t.inlines);case"RawBlock":return t.rawContent;case"PropertyList":return Ie(t);case"Table":return jt(t);default:return""}}function jt(t){let e=t.tableColumnLabels??[],n=t.tableRows??[];if(e.length===0&&n.length===0)return"";let r=`| ${e.map(ke).join(" | ")} |`,i=`| ${e.map(()=>"---").join(" | ")} |`,a=n.map(u=>`| ${(u.tableCells??[]).map(Vt).join(" | ")} |`);return[r,i,...a].join(`
|
|
10
|
+
`)}function Vt(t){let e=t;return!e||typeof e!="object"||!e.kind?"":e.kind==="Text"||e.kind==="ResourceLink"||e.kind==="Badge"?ke(le([e])):ke(he(e).replace(/\n+/g," "))}function ke(t){return t==null?"":String(t).replace(/\|/g,"\\|")}function Ie(t,e=0){if(!t.propertyEntries||t.propertyEntries.length===0)return"";let n=" ".repeat(e),r=[];for(let i of t.propertyEntries){let a=`${n}**${i.propertyKey}:**`,u=At(i.propertyValue,e+1);u.includes(`
|
|
11
|
+
`)?r.push(`${a}
|
|
12
|
+
${u}`):r.push(`${a} ${u}`)}return r.join(`
|
|
13
13
|
|
|
14
|
-
`)}function
|
|
14
|
+
`)}function At(t,e){if(!t||t.length===0)return"";let n=[],r=[];for(let i of t){let a=i;!a||typeof a!="object"||!a.kind||(a.kind==="Text"||a.kind==="ResourceLink"||a.kind==="Badge"?n.push(le([a])):a.kind==="PropertyList"?r.push(Ie(a,e)):r.push(he(a)))}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
|
|
21
|
-
`);return n?.trailingNewline&&(
|
|
22
|
-
`)||(
|
|
23
|
-
`)),
|
|
20
|
+
`)}`}function le(t){let e=[];for(let n of t)n.kind==="Text"?e.push(n.text):n.kind==="ResourceLink"?e.push(Dt(n)):n.kind==="Badge"&&e.push(Kt(n));return e.join("")}function Dt(t){let e=Fe(t.target);if(!e)return t.linkLabel??"[unresolved link]";let n=I(e),r=t.linkLabel&&t.linkLabel.length>0?t.linkLabel:e.name,i=t.linkTooltip?` "${Pe(t.linkTooltip)}"`:"";return`[${r}](${n}${i})`}function Kt(t){if(!t.badgeTarget)return`*${t.badgeLabel}*`;let e=Fe(t.badgeTarget);if(!e)return`*${t.badgeLabel}*`;let n=I(e),r=t.badgeTooltip?` "${Pe(t.badgeTooltip)}"`:"";return`*[${t.badgeLabel}](${n}${r})*`}function Pe(t){return t==null?"":String(t).replace(/"/g,'\\"')}function Fe(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 Tt(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 i=Bt(e.metadata,n).join(`
|
|
21
|
+
`);return n?.trailingNewline&&(i.endsWith(`
|
|
22
|
+
`)||(i+=`
|
|
23
|
+
`)),i}};function Bt(t,e){if(!t)return[];let n=new Map;for(let a of t.entries)n.set(a.key,a);let r=e?.metadataKeys??t.entries.map(a=>a.key),i=[];for(let a of r){let u=n.get(a);if(!u)continue;let c=e?.metadataRenames.get(a)??a,l=qe(u.value,u.escapeHint);l!==void 0&&i.push(`${c} = ${l}`)}return i}function qe(t,e){switch(t.kind){case"StringScalar":return Lt(t.stringValue,e);case"IntegerScalar":return String(t.integerValue);case"StructuredList":{let n=[];for(let r of t.items){let i=qe(r,e);i!==void 0&&n.push(i)}return`[${n.join(", ")}]`}case"StructuredMap":return;default:return}}function Lt(t,e){return e&&Tt(e,h.ESC_TOML_MULTILINE)?Ct(t):Rt(t)}function Rt(t){return`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n")}"`}function Ct(t){return`"""
|
|
24
24
|
${t.replace(/"""/g,'\\"\\"\\"')}
|
|
25
|
-
"""`}var
|
|
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
|
|
27
|
+
`:r}};function x(t){let e=t.replace(/\r\n/g,`
|
|
28
28
|
`).split(`
|
|
29
|
-
`),n=[],r=0;for(;r<e.length;){let
|
|
30
|
-
`)),k=l?` class="language-${
|
|
29
|
+
`),n=[],r=0;for(;r<e.length;){let i=e[r];if(i.trim()===""){r++;continue}let a=/^(\s*)```(\S*)\s*$/.exec(i);if(a){let l=a[2],m=[];for(r++;r<e.length&&!/^(\s*)```\s*$/.test(e[r]);)m.push(e[r]),r++;r++;let g=He(m.join(`
|
|
30
|
+
`)),k=l?` class="language-${ze(l)}"`:"";n.push(`<pre><code${k}>${g}</code></pre>`);continue}let u=/^(#{1,6})\s+(.*)$/.exec(i);if(u){let l=u[1].length,m=H(u[2].trim());n.push(`<h${l}>${m}</h${l}>`),r++;continue}if(i.includes("|")&&r+1<e.length&&We(e[r+1])){let l=be(i),m=Ut(e[r+1]);r+=2;let g=[];for(;r<e.length&&e[r].trim()!==""&&e[r].includes("|");)g.push(be(e[r])),r++;n.push(Ot(l,m,g));continue}if(/^\s*[-*]\s+/.test(i)){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
31
|
${l.join(`
|
|
32
32
|
`)}
|
|
33
|
-
</ul>`);continue}if(/^\s*\d+\.\s+/.test(
|
|
33
|
+
</ul>`);continue}if(/^\s*\d+\.\s+/.test(i)){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
34
|
${l.join(`
|
|
35
35
|
`)}
|
|
36
|
-
</ol>`);continue}let c=[
|
|
37
|
-
`)}function
|
|
36
|
+
</ol>`);continue}let c=[i];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&&We(e[r+1]));)c.push(e[r]),r++;n.push(`<p>${H(c.join(" "))}</p>`)}return n.join(`
|
|
37
|
+
`)}function We(t){return t.includes("-")?/^[\s|:-]+$/.test(t):!1}function be(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 Ut(t){return be(t).map(e=>{let n=e.startsWith(":"),r=e.endsWith(":");return n&&r?"center":r?"right":n?"left":null})}function Ot(t,e,n){let r=u=>{let c=e[u];return c?` style="text-align:${c}"`:""},i=t.map((u,c)=>`<th${r(c)}>${H(u)}</th>`).join(""),a=n.map(u=>`<tr>${u.map((l,m)=>`<td${r(m)}>${H(l)}</td>`).join("")}</tr>`).join(`
|
|
38
38
|
`);return`<table>
|
|
39
|
-
<thead><tr>${
|
|
39
|
+
<thead><tr>${i}</tr></thead>
|
|
40
40
|
<tbody>
|
|
41
|
-
${
|
|
41
|
+
${a}
|
|
42
42
|
</tbody>
|
|
43
|
-
</table>`}function
|
|
43
|
+
</table>`}function H(t){let e=He(t);return e=e.replace(/`([^`\n]+)`/g,(n,r)=>`<code>${r}</code>`),e=e.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(n,r,i)=>`<a href="${ze(i)}">${r}</a>`),e=e.replace(/\*\*([^*\n]+)\*\*/g,(n,r)=>`<strong>${r}</strong>`),e=e.replace(/(^|[^*])\*([^*\n]+)\*(?!\*)/g,(n,r,i)=>`${r}<em>${i}</em>`),e=e.replace(/(^|[\s(])_([^_\n]+)_(?=[\s).,;:!?]|$)/g,(n,r,i)=>`${r}<em>${i}</em>`),e}function He(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ze(t){return t.replace(/"/g,""").replace(/&/g,"&")}function we(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=Mt(e.children);if(n?.omitWrapper){let c=r.endsWith(`
|
|
44
44
|
`)?r:`${r}
|
|
45
45
|
`;return n.trailingNewline===!1&&c.endsWith(`
|
|
46
|
-
`)?c.slice(0,-1):c}let
|
|
46
|
+
`)?c.slice(0,-1):c}let i=Nt(e.metadata)??"Untitled",a=_t(e.metadata,n),u=`<!DOCTYPE html>
|
|
47
47
|
<html lang="en">
|
|
48
48
|
<head>
|
|
49
49
|
<meta charset="utf-8">
|
|
50
|
-
<title>${
|
|
50
|
+
<title>${O(i)}</title>
|
|
51
51
|
<style>
|
|
52
52
|
body { font-family: -apple-system, Segoe UI, Helvetica, Arial, sans-serif; max-width: 860px; margin: 2rem auto; padding: 0 1rem; color: #222; line-height: 1.55; }
|
|
53
53
|
h1, h2, h3, h4 { line-height: 1.2; }
|
|
@@ -69,39 +69,39 @@ figure.svg-figure svg { max-width: 100%; height: auto; }
|
|
|
69
69
|
</style>
|
|
70
70
|
</head>
|
|
71
71
|
<body>
|
|
72
|
-
${
|
|
72
|
+
${a}${r}
|
|
73
73
|
</body>
|
|
74
74
|
</html>
|
|
75
75
|
`;return n?.trailingNewline===!1&&u.endsWith(`
|
|
76
|
-
`)?u.slice(0,-1):u}};function
|
|
77
|
-
<dd>${l}</dd>`)}return
|
|
78
|
-
${
|
|
76
|
+
`)?u.slice(0,-1):u}};function Nt(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 _t(t,e){if(!t||t.entries.length===0)return"";let n=e?.metadataKeys??t.entries.map(a=>a.key),r=new Map(t.entries.map(a=>[a.key,a])),i=[];for(let a of n){let u=r.get(a);if(!u)continue;let c=e?.metadataRenames.get(a)??a,l=Ge(u.value);l!==void 0&&i.push(` <dt>${O(c)}</dt>
|
|
77
|
+
<dd>${l}</dd>`)}return i.length===0?"":`<dl class="metadata">
|
|
78
|
+
${i.join(`
|
|
79
79
|
`)}
|
|
80
80
|
</dl>
|
|
81
|
-
`}function
|
|
82
|
-
`)}function
|
|
83
|
-
<tr>${e.map(
|
|
81
|
+
`}function Ge(t){switch(t.kind){case"StringScalar":return O(t.stringValue);case"IntegerScalar":return String(t.integerValue);case"StructuredList":{let e=[];for(let n of t.items){let r=Ge(n);r!==void 0&&e.push(`<code>${r}</code>`)}return e.join(", ")}case"StructuredMap":return;default:return}}function Mt(t){let e=[];for(let n of t){let r=Se(n);r&&e.push(r)}return e.join(`
|
|
82
|
+
`)}function Se(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 Ht(t);case"PropertyList":return qt(t);case"Table":return It(t);default:return""}}function It(t){let e=t.tableColumnLabels??[],n=t.tableRows??[],r=e.length>0?`<thead>
|
|
83
|
+
<tr>${e.map(a=>`<th>${O(a)}</th>`).join("")}</tr>
|
|
84
84
|
</thead>
|
|
85
|
-
`:"",
|
|
85
|
+
`:"",i=n.length>0?`<tbody>
|
|
86
86
|
${n.map(Pt).join(`
|
|
87
87
|
`)}
|
|
88
88
|
</tbody>
|
|
89
89
|
`:"";return`<table class="property-table">
|
|
90
|
-
${r}${
|
|
90
|
+
${r}${i}</table>`}function Pt(t){return` <tr>${(t.tableCells??[]).map(r=>`<td>${Ft(r)}</td>`).join("")}</tr>`}function Ft(t){let e=t;return!e||typeof e!="object"||!e.kind?"":e.kind==="Text"||e.kind==="ResourceLink"||e.kind==="Badge"?de([e]):Se(e)}function qt(t){if(!t.propertyEntries||t.propertyEntries.length===0)return"";let e=[];for(let n of t.propertyEntries){let i=`<dt${n.propertyTooltip?` title="${z(n.propertyTooltip)}"`:""}>${O(n.propertyKey)}</dt>`,a=`<dd>${Wt(n.propertyValue)}</dd>`;e.push(i,a)}return`<dl class="property-list">
|
|
91
91
|
${e.join(`
|
|
92
92
|
`)}
|
|
93
|
-
</dl>`}function
|
|
93
|
+
</dl>`}function Wt(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(Se(r)))}return e.join("")}function Ht(t){let e=t.mediaType;return e&&we(e,h.TEXT_MARKDOWN)?x(t.rawContent):e&&we(e,h.TEXT_HTML)?t.rawContent:e&&we(e,h.IMAGE_SVG_XML)?`<figure class="svg-figure">
|
|
94
94
|
${t.rawContent}
|
|
95
|
-
</figure>`:`<pre${e?` class="media-${
|
|
96
|
-
`)&&(
|
|
97
|
-
`),
|
|
95
|
+
</figure>`:`<pre${e?` class="media-${z(e.name)}"`:""}><code>${O(t.rawContent)}</code></pre>`}function de(t){let e=[];for(let n of t)n.kind==="Text"?e.push(O(n.text)):n.kind==="ResourceLink"?e.push(zt(n)):n.kind==="Badge"&&e.push(Gt(n));return e.join("")}function zt(t){let e=Je(t.target);if(!e)return O(t.linkLabel??"[unresolved link]");let n=I(e),r=t.linkLabel&&t.linkLabel.length>0?t.linkLabel:e.name,i=t.linkTooltip?` title="${z(t.linkTooltip)}"`:"";return`<a class="kan-link" href="${z(n)}"${i}>${O(r)}</a>`}function Gt(t){let e=t.badgeTooltip?` title="${z(t.badgeTooltip)}"`:"",n=O(t.badgeLabel);if(!t.badgeTarget)return`<span class="kan-badge"${e}>${n}</span>`;let r=Je(t.badgeTarget);if(!r)return`<span class="kan-badge"${e}>${n}</span>`;let i=I(r);return`<a class="kan-badge" href="${z(i)}"${e}>${n}</a>`}function Je(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 O(t){return t==null?"":String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function z(t){return t==null?"":String(t).replace(/"/g,""").replace(/&/g,"&")}function Jt(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var te=class{backendUri="kanonak.org/transformations/svg";render(e,n){for(let r of e.children)if(r.kind==="RawBlock"&&r.mediaType&&Jt(r.mediaType,h.IMAGE_SVG_XML)){let i=r.rawContent;return n?.trailingNewline&&!i.endsWith(`
|
|
96
|
+
`)&&(i+=`
|
|
97
|
+
`),i}return'<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>'}};function Xt(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var ne=class{backendUri="kanonak.org/transformations/stylesheet";render(e,n){let r=[];for(let a of e.children)a.kind==="RawBlock"&&a.mediaType&&Xt(a.mediaType,h.TEXT_CSS)&&r.push(a.rawContent);let i=r.join(`
|
|
98
98
|
|
|
99
|
-
`);return n?.trailingNewline&&
|
|
100
|
-
`)&&(
|
|
101
|
-
`),
|
|
99
|
+
`);return n?.trailingNewline&&i.length>0&&!i.endsWith(`
|
|
100
|
+
`)&&(i+=`
|
|
101
|
+
`),i}};function Yt(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var re=class{backendUri="kanonak.org/transformations/yaml";render(e,n){let r=[];for(let a of e.children)a.kind==="RawBlock"&&a.mediaType&&Yt(a.mediaType,h.TEXT_YAML)&&r.push(a.rawContent);let i=r.join(`
|
|
102
102
|
|
|
103
|
-
`);return n?.trailingNewline&&
|
|
104
|
-
`)&&(
|
|
105
|
-
`),
|
|
106
|
-
`)&&(
|
|
107
|
-
`),a}};function Je(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]=Xe(u.value,u.escapeHint)}return{M:a}}function Xe(t,e){switch(t.kind){case"StructuredMap":return Je(t);case"StructuredList":return{L:t.items.map(n=>Xe(n,void 0))};case"StringScalar":return Yt(t.stringValue,e??t.escapeHint);case"IntegerScalar":return xt(t.integerValue,e??t.escapeHint)}}function Yt(t,e){if(e&&re(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&&re(e,h.ESC_DYNAMODB_NULL))return{NULL:!0};if(e&&re(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&&re(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&&re(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 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=F(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 Ce(g,this.repository);c=await this.objectParser.parseKanonaks(k),this.cache.set(u,c)}let l=F(c,e);if(l)return l;for(let m of c)if(m instanceof E&&m.name===e.name)return m}};var Zt="kanonak.org",Qt="transformations",tr=3,s=t=>({publisher:Zt,package_:Qt,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"),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 fe(t,e){let n=t.name,r=dn(e),a={catalog:e,depth:0};if(f(t,o.InstanceTransformation))return en(t,n,a,r);if(f(t,o.SetTransformation))return tn(t,n,a,r);throw new y("Subject is not a recognized v3 transformation type \u2014 expected InstanceTransformation or SetTransformation",n)}function en(t,e,n,r){return{kind:"instance",name:t.name,inputPattern:tt(t,e),rule:de(t,o.rule,`${e}.rule`,n),artifactName:de(t,o.artifactName,`${e}.artifactName`,n),outputs:nt(t,`${e}.outputs`),overrides:rt(t,`${e}.formatOverrides`,n),fragments:r}}function tn(t,e,n,r){let a=N(t,o.partitionBy);return{kind:"set",name:t.name,inputPattern:tt(t,e),rule:de(t,o.rule,`${e}.rule`,n),artifactName:de(t,o.artifactName,`${e}.artifactName`,n),outputs:nt(t,`${e}.outputs`),overrides:rt(t,`${e}.formatOverrides`,n),partitionBy:a,fragments:r}}function tt(t,e){let n=oe(t,o.inputPattern);if(!n)throw new y("inputPattern is required",e);return nn(n,`${e}.inputPattern`)}function nn(t,e){let n=N(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($e(u.object.subject));else if(u instanceof w)for(let c of u.object)c instanceof b&&r.push($e(c.subject));let a=[],i=0;for(let u of A(t,o.sortBy))if(u instanceof w)for(let c of u.object)c instanceof O&&a.push(Ye(c,`${e}.sortBy[${i++}]`));else u instanceof K&&a.push(Ye(u.object,`${e}.sortBy[${i++}]`));return{matchesClass:n,requires:r,sortBy:a}}function Ye(t,e){let n=N(t,o.byProperty);if(!n)throw new y("SortKey.byProperty is required",e);let r=N(t,o.order);if(!r)throw new y("SortKey.order is required",e);if(S(r,o.ascending))return{byProperty:n,order:"ascending"};if(S(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 de(t,e,n,r){let a=oe(t,e);if(!a)throw new y("expression is required",n);return G(a,n,r)}function G(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:et(t,o.integerLiteral,e)};if(f(t,o.DecimalLiteral))return{kind:"decimal-literal",value:et(t,o.decimalLiteral,e)};if(f(t,o.BooleanLiteral))return{kind:"boolean-literal",value:pn(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:P(t,o.readProp,e,"readProp")};if(f(t,o.Traverse))return{kind:"traverse",source:d(t,o.traverseSource,`${e}.traverseSource`,n),through:P(t,o.through,e,"through"),step:d(t,o.step,`${e}.step`,n)};if(f(t,o.BuildAstNode))return{kind:"build-ast-node",astClass:P(t,o.astClass,e,"astClass"),set:an(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:rn(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:P(t,o.refTo,e,"refTo")};if(f(t,o.DisplayLabel))return{kind:"display-label",labelTarget:P(t,o.labelTarget,e,"labelTarget"),labelSource:P(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:on(t,e)};if(f(t,o.RenderMarkdown))return{kind:"render-markdown",source:d(t,o.renderSource,`${e}.renderSource`,n),readProp:P(t,o.renderProp,e,"renderProp"),format:sn(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 cn(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:un(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=at(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: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.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=oe(t,e);if(!a)throw new y("child expression is required",n);return G(a,n,r)}function rn(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 w)for(let c of u.object)c instanceof O&&a.push(G(c,`${n}[${i++}]`,r));else u instanceof K&&a.push(G(u.object,`${n}[${i++}]`,r));return a}function an(t,e,n){let r=[],a=0;for(let i of A(t,o.set))if(i instanceof w)for(let u of i.object)u instanceof O&&r.push(xe(u,`${e}[${a++}]`,n));else i instanceof K&&r.push(xe(i.object,`${e}[${a++}]`,n));return r}function xe(t,e,n){return{field:P(t,o.field,e,"field"),value:d(t,o.bindValue,`${e}.bindValue`,n)}}function on(t,e){let n=N(t,o.normKind);if(!n)throw new y("normKind is required",e);if(S(n,o.NORM_TRIM_END))return"trim-end";throw new y(`Unknown NormalizeKind: ${n.publisher}/${n.package_}/${n.name}`,e)}function sn(t,e){let n=N(t,o.renderFormat);if(!n)throw new y("renderFormat is required",e);if(S(n,o.RENDER_HTML))return"html";if(S(n,o.RENDER_MARKDOWN))return"markdown";throw new y(`Unknown RenderFormat: ${n.publisher}/${n.package_}/${n.name}`,e)}var Ze=new Set(["iso-date","iso-datetime","short-date","long-date","year","month-year"]);function un(t,e){let n=z(t,o.dateFormat);if(!n)throw new y("dateFormat is required",e);if(!Ze.has(n))throw new y(`Unknown dateFormat "${n}"; supported: ${[...Ze].join(", ")}`,e);return n}function cn(t,e,n){let r=N(t,o.fragmentRef);if(!r)throw new y("fragmentRef is required",e);if(!fn(n.catalog,r))throw new y(`ExpressionFragment not found: ${r.publisher}/${r.package_}/${r.name}`,e);return{kind:"call-fragment",fragmentKey:ln(r)}}function ln(t){return`${t.publisher}/${t.package_}/${t.name}`}function dn(t){let e=new Map,n=[];for(let r of t){if(!(r instanceof E)||!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),m=`${c}/${l}/${r.name}`;n.push({key:m,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 fn(t,e){for(let n of t)if(!(!(n instanceof E)||n.name!==e.name||!(n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))&&f(n,o.ExpressionFragment))return n}function nt(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 w)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 rt(t,e,n){let r=new Map,a=0;for(let i of A(t,o.formatOverrides))if(i instanceof w){for(let u of i.object)if(u instanceof O){let[c,l]=Qe(u,`${e}[${a++}]`);r.set(c,l)}}else if(i instanceof K){let[u,c]=Qe(i.object,`${e}[${a++}]`);r.set(u,c)}return r}function Qe(t,e){let n=N(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 w)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 w){for(let l of c.object)if(l instanceof O){let m=z(l,o.fromKey),g=z(l,o.toKey);m&&g&&a.set(m,g)}}else if(c instanceof K){let l=c.object,m=z(l,o.fromKey),g=z(l,o.toKey);m&&g&&a.set(m,g)}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 mn(t){return t.predicate?.subject}function A(t,e){let n=[];for(let r of t.statement){let a=mn(r);a&&S(a,e)&&n.push(r)}return n}function oe(t,e){for(let n of A(t,e))if(n instanceof K)return n.object}function N(t,e){for(let n of A(t,e))if(n instanceof V)return $e(n.object.subject)}function z(t,e){for(let n of A(t,e))if(n instanceof B)return n.object}function at(t,e){for(let n of A(t,e))if(n instanceof L)return n.object}function Ee(t,e){for(let n of A(t,e))if(n instanceof R)return n.object}function j(t,e,n){let r=z(t,e);if(r===void 0)throw new y(`${e.name} (string) is required`,n);return r}function et(t,e,n){let r=at(t,e);if(r===void 0)throw new y(`${e.name} (number) is required`,n);return r}function pn(t,e,n){let r=Ee(t,e);if(r===void 0)throw new y(`${e.name} (boolean) is required`,n);return r}function P(t,e,n,r){let a=N(t,e);if(!a)throw new y(`${r} (URI reference) is required`,n);return a}function $e(t){return{publisher:t.publisher,package_:t.package_,name:t.name}}var gn={publisher:"kanonak.org",package_:"core-rdf",name:"label"},C=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 C(`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 it(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 it(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 T))return;let a=kn(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(se(m))}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 E?r.name:r instanceof O?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 E){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 E?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 T))return;let a;for(let u of r.statement){let c=Ve(u);if(c&&S(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"?Z(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;bn.has(u)&&(Array.isArray(i)&&i.every(c=>ot(c))?i=i.map(c=>String(c)).join(""):ot(i)&&(i=String(i))),r[u]=i}return r}case"call-fragment":{let r=this.fragments.get(e.fragmentKey);if(!r)throw new C(`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+=$(i,"Sum");return a}case"min":{let r=await this.evaluateList(e.source,n);if(r.length===0)throw new C("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 C("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 C("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,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,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,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,u);let l=await this.evaluate(e.partitionKey,c),m=ct(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,u);let l=await this.evaluate(e.distinctKey,c),m=ct(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 T?r.statement:[]}case"statement-predicate":{let r=await this.evaluate(e.source,n);if(je(r)){let a=r.predicate;if(a instanceof b)return a}return}case"statement-value":{let r=await this.evaluate(e.source,n);return je(r)?En(r):void 0}case"date-format":{let r=await this.evaluate(e.source,n),a=r==null?"":se(r);return a?Sn(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 C("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,r[i]),u.set(e.secondVar,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,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 st(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(st(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 E}case"is-embedded":return await this.evaluate(e.check,n)instanceof O;case"is-list":{let r=await this.evaluate(e.check,n);return Array.isArray(r)}case"statement-object":{let r=await this.evaluate(e.source,n);if(!je(r))return;let a=r;return a instanceof B||a instanceof L||a instanceof R||a instanceof V||a instanceof K||a instanceof w?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 T)||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 C("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}](${M(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,gn);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,r[i-1]),u.set(e.secondVar,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,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,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 me(t,e){if(t instanceof T)return yn(t,e);if(hn(t))return S(e,o.key)?t.key:S(e,o.members)?t.members:void 0}function yn(t,e){for(let n of t.statement){let r=Ve(n);if(!(!r||!S(r,e))&&(n instanceof B||n instanceof L||n instanceof R||n instanceof V||n instanceof K||n instanceof w))return n.object}}function kn(t,e){let n=[];for(let r of t.statement){let a=Ve(r);if(!(!a||!S(a,e))){if(r instanceof V)n.push(r.object.subject);else if(r instanceof w)for(let i of r.object)i instanceof b&&n.push(i.subject)}}return n}function Ve(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 T)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 it(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 hn(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 C(`${e} requires numeric elements; got ${wn(t)}`)}function ve(t){if(t instanceof E){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 bn=new Set(["stringValue","text","rawContent","key","propertyKey","linkLabel"]);function ot(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function wn(t){return t===void 0?"undefined":t===null?"null":Array.isArray(t)?`array(${t.length})`:typeof t}function Sn(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 st(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=ut(t),c=ut(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 ut(t){if(t instanceof b){let e=t.subject;return{publisher:e.publisher,package_:e.package_,name:e.name}}if(t instanceof E){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 je(t){return t instanceof B||t instanceof L||t instanceof R||t instanceof V||t instanceof K||t instanceof w}function En(t){return t instanceof B||t instanceof L||t instanceof R?String(t.object??""):t instanceof V?t.object?.subject?.name??"":t instanceof K?"[embedded]":t instanceof w?(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 ct(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 T){let e=t.name??"";return`k:${t.namespace??""}/${e}`}return J(t)?`u:${t.publisher}/${t.package_}/${t.name}`:`o:${JSON.stringify(t)}`}var $n={"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"}},I=class extends Error{},ge=class{backends=new Map;constructor(){this.register(new X),this.register(new Y),this.register(new x),this.register(new Q),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 I(`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 I(`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=lt(n.instances,e.inputPattern.requires),u=dt(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);Ae(g,e.name,`input "${l.name}"`);let k=De(await a.evaluate(e.artifactName,m),e.name,`input "${l.name}"`),D=Ke(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=lt(n.instances,e.inputPattern.requires),u=dt(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"),m=Ke(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=Vn(g,u);if(k==null)continue;let D=An(k),v=c.get(D);v||(v={keyValue:k,keyDisplay:Dn(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);Ae(v,e.name,`partition "${k.keyDisplay}"`);let gt=De(await i.evaluate(e.artifactName,D),e.name,`partition "${k.keyDisplay}"`),yt=Ke(e.overrides.get(r.outputFormat),r.runtimeOverride),kt=a.render(v,yt);m.push({fileName:gt,format:r.outputFormat,content:kt,source:{kind:"set",memberCount:k.members.length,partitionKey:k.keyDisplay}})}return m}findBackend(e){let n=$n[e];if(n)return this.backends.get(n.formatUri)}};function lt(t,e){return e.length===0?t:t.filter(n=>{for(let r of e)if(!jn(n,r))return!1;return!0})}function dt(t,e){if(e.length===0)return t;let n=[...t];return n.sort((r,a)=>{for(let i of e){let u=ft(r,i.byProperty),c=ft(a,i.byProperty),l=vn(u,c,i.order);if(l!==0)return l}return 0}),n}function ft(t,e){for(let n of t.statement){let r=Te(n);if(!(!r||!S(r,e))){if(n instanceof B||n instanceof L||n instanceof R)return n.object;if(n instanceof w)throw new I(`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 I(`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 jn(t,e){for(let n of t.statement){let r=Te(n);if(!r||!S(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 Vn(t,e){for(let n of t.statement){let r=Te(n);if(!(!r||!S(r,e))&&(n instanceof B||n instanceof L||n instanceof R||n instanceof V||n instanceof w))return n.object}}function Te(t){return t.predicate?.subject}function An(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 T){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 Dn(t){return t==null?"":typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"?String(t):t instanceof b?t.subject.name:t instanceof T?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 I(`Transformation "${e}" rule did not yield a Document for ${n}. Got: ${mt(t)}`)}function De(t,e,n){if(typeof t=="string")return t;if(Array.isArray(t)&&t.every(Kn))return t.map(r=>String(r)).join("");throw new I(`Transformation "${e}" artifactName did not yield a string for ${n}. Got: ${mt(t)}`)}function Kn(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function mt(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 _=class extends Error{constructor(n,r){super(n);this.cause=r;this.name="RenderError"}cause},pt={publisher:"kanonak.org",package_:"derivation",name:"default"},Be=class{constructor(e,n=new Le,r=new Ue){this.repository=e;this.parser=n;this.objectParser=r}repository;parser;objectParser;runner=new ge;cachedCatalog=void 0;invalidate(){this.cachedCatalog=void 0}async findDerivation(e){let n=await this.getCatalog(),r=F(n,e.resource);if(!(r instanceof E))return;let a=e.variant??pt;return Oe(r,e.format,a,n)}async render(e){let n=await this.findDerivation(e);if(!n)throw new _(`No derivation found for ${q(e.resource)} \u2192 format ${q(e.format)}`+(e.variant?` variant ${q(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=F(n,e.transformation);if(!(r instanceof E))throw new _(`Transformation not found: ${q(e.transformation)}`);let a=F(n,e.input);if(!(a instanceof E))throw new _(`Input resource not found: ${q(e.input)}`);let i=fe(r,n),u=Tn(i.outputs,e.format);if(!u)throw new _(`Transformation ${q(e.transformation)} declares outputs [${[...i.outputs].join(", ")}], none of which corresponds to format ${q(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 _(`Transformation execution failed: ${l.message}`,l)}if(c.length===0)throw new _("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 q(t){return`${t.publisher}/${t.package_}/${t.name}`}function Tn(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,pt as DEFAULT_VARIANT,h as DOCAST,bt as DOCAST_PKG,ht as DOCAST_PUB,ae as DynamoDbBackend,pe as ExpressionEngineV3,C as ExpressionEvalErrorV3,Q as HtmlBackend,x as JsonBackend,X as MarkdownFrontmatterBackend,ie as ReferenceResolver,_ as RenderError,$n as SUPPORTED_FORMATS_V3,ee as SvgBackend,o as TX_V3,Qt as TX_V3_PKG,Zt as TX_V3_PUB,tr as TX_V3_VERSION_MAJOR,Y as TomlBackend,Be as TransformationEngine,y as TransformationLoadErrorV3,I as TransformationRunnerErrorV3,ge as TransformationRunnerV3,ne as YamlBackend,fe as compileTransformationV3,Z as renderMarkdownToHtml};
|
|
103
|
+
`);return n?.trailingNewline&&i.length>0&&!i.endsWith(`
|
|
104
|
+
`)&&(i+=`
|
|
105
|
+
`),i}};function ie(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=Xe(e.metadata,n),i=JSON.stringify(r,null,2);return n?.trailingNewline&&!i.endsWith(`
|
|
106
|
+
`)&&(i+=`
|
|
107
|
+
`),i}};function Xe(t,e){let n=new Map;for(let a of t.entries)n.set(a.key,a);let r=e?.metadataKeys??t.entries.map(a=>a.key),i={};for(let a of r){let u=n.get(a);if(!u)continue;let c=e?.metadataRenames.get(a)??a;i[c]=Ye(u.value,u.escapeHint)}return{M:i}}function Ye(t,e){switch(t.kind){case"StructuredMap":return Xe(t);case"StructuredList":return{L:t.items.map(n=>Ye(n,void 0))};case"StringScalar":return Zt(t.stringValue,e??t.escapeHint);case"IntegerScalar":return Qt(t.integerValue,e??t.escapeHint)}}function Zt(t,e){if(e&&ie(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&&ie(e,h.ESC_DYNAMODB_NULL))return{NULL:!0};if(e&&ie(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 Qt(t,e){if(e&&ie(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&&ie(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=q(n,e);if(r)return r;let i=e.version,a=i&&typeof i.major=="number"?`@${i.major}.${i.minor}.${i.patch}`:"",u=`${e.publisher}/${e.package_}${a}`,c=this.cache.get(u);if(!c){let m=await this.repository.getDocumentsByNamespaceAsync(e.publisher,e.package_);if(m.length===0)return;let g=i&&typeof i.major=="number"?m.find(D=>{let v=D.metadata?.namespace_?.version;return v&&v.major===i.major&&v.minor===i.minor&&v.patch===i.patch})??m[0]:m[0],k=new Oe(g,this.repository);c=await this.objectParser.parseKanonaks(k),this.cache.set(u,c)}let l=q(c,e);if(l)return l;for(let m of c)if(m instanceof E&&m.name===e.name)return m}};var xt="kanonak.org",en="transformations",nr=3,s=t=>({publisher:xt,package_:en,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=fn(e),i={catalog:e,depth:0};if(f(t,o.InstanceTransformation))return tn(t,n,i,r);if(f(t,o.SetTransformation))return nn(t,n,i,r);throw new y("Subject is not a recognized v3 transformation type \u2014 expected InstanceTransformation or SetTransformation",n)}function tn(t,e,n,r){return{kind:"instance",name:t.name,inputPattern:nt(t,e),rule:fe(t,o.rule,`${e}.rule`,n),artifactName:fe(t,o.artifactName,`${e}.artifactName`,n),outputs:rt(t,`${e}.outputs`),overrides:it(t,`${e}.formatOverrides`,n),fragments:r}}function nn(t,e,n,r){let i=_(t,o.partitionBy);return{kind:"set",name:t.name,inputPattern:nt(t,e),rule:fe(t,o.rule,`${e}.rule`,n),artifactName:fe(t,o.artifactName,`${e}.artifactName`,n),outputs:rt(t,`${e}.outputs`),overrides:it(t,`${e}.formatOverrides`,n),partitionBy:i,fragments:r}}function nt(t,e){let n=se(t,o.inputPattern);if(!n)throw new y("inputPattern is required",e);return rn(n,`${e}.inputPattern`)}function rn(t,e){let n=_(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(ve(u.object.subject));else if(u instanceof w)for(let c of u.object)c instanceof b&&r.push(ve(c.subject));let i=[],a=0;for(let u of A(t,o.sortBy))if(u instanceof w)for(let c of u.object)c instanceof R&&i.push(Ze(c,`${e}.sortBy[${a++}]`));else u instanceof T&&i.push(Ze(u.object,`${e}.sortBy[${a++}]`));return{matchesClass:n,requires:r,sortBy:i}}function Ze(t,e){let n=_(t,o.byProperty);if(!n)throw new y("SortKey.byProperty is required",e);let r=_(t,o.order);if(!r)throw new y("SortKey.order is required",e);if(S(r,o.ascending))return{byProperty:n,order:"ascending"};if(S(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 i=se(t,e);if(!i)throw new y("expression is required",n);return J(i,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:tt(t,o.integerLiteral,e)};if(f(t,o.DecimalLiteral))return{kind:"decimal-literal",value:tt(t,o.decimalLiteral,e)};if(f(t,o.BooleanLiteral))return{kind:"boolean-literal",value:gn(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:P(t,o.readProp,e,"readProp")};if(f(t,o.Traverse))return{kind:"traverse",source:d(t,o.traverseSource,`${e}.traverseSource`,n),through:P(t,o.through,e,"through"),step:d(t,o.step,`${e}.step`,n)};if(f(t,o.BuildAstNode))return{kind:"build-ast-node",astClass:P(t,o.astClass,e,"astClass"),set:on(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:an(t,o.elseBuild,`${e}.elseBuild`,n)};if(f(t,o.Concat))return{kind:"concat",parts:Ee(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:P(t,o.refTo,e,"refTo")};if(f(t,o.DisplayLabel))return{kind:"display-label",labelTarget:P(t,o.labelTarget,e,"labelTarget"),labelSource:P(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:sn(t,e)};if(f(t,o.RenderMarkdown))return{kind:"render-markdown",source:d(t,o.renderSource,`${e}.renderSource`,n),readProp:P(t,o.renderProp,e,"renderProp"),format:un(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 ln(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:cn(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=at(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:Ee(t,o.operands,`${e}.operands`,n)};if(f(t,o.Or))return{kind:"or",operands:Ee(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 i=se(t,e);if(!i)throw new y("child expression is required",n);return J(i,n,r)}function an(t,e,n,r){let i=se(t,e);if(i)return J(i,n,r)}function Ee(t,e,n,r){let i=[],a=0;for(let u of A(t,e))if(u instanceof w)for(let c of u.object)c instanceof R&&i.push(J(c,`${n}[${a++}]`,r));else u instanceof T&&i.push(J(u.object,`${n}[${a++}]`,r));return i}function on(t,e,n){let r=[],i=0;for(let a of A(t,o.set))if(a instanceof w)for(let u of a.object)u instanceof R&&r.push(Qe(u,`${e}[${i++}]`,n));else a instanceof T&&r.push(Qe(a.object,`${e}[${i++}]`,n));return r}function Qe(t,e,n){return{field:P(t,o.field,e,"field"),value:d(t,o.bindValue,`${e}.bindValue`,n)}}function sn(t,e){let n=_(t,o.normKind);if(!n)throw new y("normKind is required",e);if(S(n,o.NORM_TRIM_END))return"trim-end";throw new y(`Unknown NormalizeKind: ${n.publisher}/${n.package_}/${n.name}`,e)}function un(t,e){let n=_(t,o.renderFormat);if(!n)throw new y("renderFormat is required",e);if(S(n,o.RENDER_HTML))return"html";if(S(n,o.RENDER_MARKDOWN))return"markdown";throw new y(`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 cn(t,e){let n=G(t,o.dateFormat);if(!n)throw new y("dateFormat is required",e);if(!xe.has(n))throw new y(`Unknown dateFormat "${n}"; supported: ${[...xe].join(", ")}`,e);return n}function ln(t,e,n){let r=_(t,o.fragmentRef);if(!r)throw new y("fragmentRef is required",e);if(!mn(n.catalog,r))throw new y(`ExpressionFragment not found: ${r.publisher}/${r.package_}/${r.name}`,e);return{kind:"call-fragment",fragmentKey:dn(r)}}function dn(t){return`${t.publisher}/${t.package_}/${t.name}`}function fn(t){let e=new Map,n=[];for(let r of t){if(!(r instanceof E)||!f(r,o.ExpressionFragment))continue;let i=se(r,o.body);if(!i)continue;let a=(r.namespace||"").split("@")[0]||"",u=a.indexOf("/");if(u<0)continue;let c=a.substring(0,u),l=a.substring(u+1),m=`${c}/${l}/${r.name}`;n.push({key:m,subject:r,bodyEmb:i,pubPkgName:`${a}/${r.name}`})}for(let r of n){let i=J(r.bodyEmb,`fragment(${r.pubPkgName})`,{catalog:t,depth:0});e.set(r.key,i)}return e}function mn(t,e){for(let n of t)if(!(!(n instanceof E)||n.name!==e.name||!(n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))&&f(n,o.ExpressionFragment))return n}function rt(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 w)for(let i of r.object)i instanceof b&&n.add(i.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,i=0;for(let a of A(t,o.formatOverrides))if(a instanceof w){for(let u of a.object)if(u instanceof R){let[c,l]=et(u,`${e}[${i++}]`);r.set(c,l)}}else if(a instanceof T){let[u,c]=et(a.object,`${e}[${i++}]`);r.set(u,c)}return r}function et(t,e){let n=_(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 L)r.push(c.object);else if(c instanceof w)for(let l of c.object){let m=l.value;typeof m=="string"&&r.push(m)}let i=new Map;for(let c of A(t,o.metadataRenames))if(c instanceof w){for(let l of c.object)if(l instanceof R){let m=G(l,o.fromKey),g=G(l,o.toKey);m&&g&&i.set(m,g)}}else if(c instanceof T){let l=c.object,m=G(l,o.fromKey),g=G(l,o.toKey);m&&g&&i.set(m,g)}let a=$e(t,o.trailingNewline),u=$e(t,o.omitWrapper);return[n.name,{metadataKeys:r.length>0?r:void 0,metadataRenames:i,trailingNewline:a,omitWrapper:u}]}function pn(t){return t.predicate?.subject}function A(t,e){let n=[];for(let r of t.statement){let i=pn(r);i&&S(i,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 _(t,e){for(let n of A(t,e))if(n instanceof V)return ve(n.object.subject)}function G(t,e){for(let n of A(t,e))if(n instanceof L)return n.object}function at(t,e){for(let n of A(t,e))if(n instanceof C)return n.object}function $e(t,e){for(let n of A(t,e))if(n instanceof U)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 tt(t,e,n){let r=at(t,e);if(r===void 0)throw new y(`${e.name} (number) is required`,n);return r}function gn(t,e,n){let r=$e(t,e);if(r===void 0)throw new y(`${e.name} (boolean) is required`,n);return r}function P(t,e,n,r){let i=_(t,e);if(!i)throw new y(`${r} (URI reference) is required`,n);return i}function ve(t){return{publisher:t.publisher,package_:t.package_,name:t.name}}var yn={publisher:"kanonak.org",package_:"core-rdf",name:"label"},N=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 N(`Unbound variable "${e.varName}"`);return n.get(e.varName)}case"concat":{let r=[];for(let i of e.parts){let a=await this.evaluate(i,n);if(a!=null)if(Array.isArray(a))for(let u of a)r.push(u);else r.push(a)}return r}case"fallback":{let r=await this.evaluate(e.primary,n);return ot(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 ot(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 i=hn(r,e.through),a=[];for(let u of i){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&&a.push(ue(m))}return a.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 E?r.name:r instanceof R?r.name??"":void 0}case"uri-publisher":{let r=await this.evaluate(e.source,n);return je(r)?.publisher}case"uri-package":{let r=await this.evaluate(e.source,n);return je(r)?.package_}case"uri-version":{let r=await this.evaluate(e.source,n);return je(r)?.version}case"subject-uri":{let r=await this.evaluate(e.source,n);if(r instanceof E){let i=r.namespace??"",a=r.name??"";return!i||!a?void 0:`${i}/${a}`}if(r instanceof b){let i=r.subject,a=i.version;return a&&typeof a.major=="number"?`${i.publisher}/${i.package_}@${a.major}.${a.minor}.${a.patch}/${i.name}`:`${i.publisher}/${i.package_}/${i.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 E?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),i=r==null?"":ue(r);return e.normKind==="trim-end"?i.replace(/[\s\r\n]+$/u,""):i}case"render-markdown":{let r=await this.evaluate(e.source,n);if(!(r instanceof K))return;let i;for(let u of r.statement){let c=Ae(u);if(c&&S(c,e.readProp)){i=u;break}}if(!(i instanceof Ce)){let u=pe(r,e.readProp);return u==null?void 0:ue(u)}let a=await this.renderMarkdownLinks(i);return e.format==="html"?x(a):a}case"build-ast-node":{let r={kind:e.astClass.name};for(let i of e.set){let a=await this.evaluate(i.value,n);if(a==null||Array.isArray(a)&&a.length===0)continue;let u=i.field.name;wn.has(u)&&(Array.isArray(a)&&a.every(c=>st(c))?a=a.map(c=>String(c)).join(""):st(a)&&(a=String(a))),r[u]=a}return r}case"call-fragment":{let r=this.fragments.get(e.fragmentKey);if(!r)throw new N(`ExpressionFragment ${e.fragmentKey} not found in registry`);return this.evaluate(r,n)}case"join":return(await this.evaluateList(e.source,n)).map(i=>i==null?"":ue(i)).join(e.separator);case"count":return(await this.evaluateList(e.source,n)).length;case"sum":{let r=await this.evaluateList(e.source,n),i=0;for(let a of r)i+=$(a,"Sum");return i}case"min":{let r=await this.evaluateList(e.source,n);if(r.length===0)throw new N("Min on an empty list is undefined; guard with IsSet");let i=$(r[0],"Min");for(let a=1;a<r.length;a++){let u=$(r[a],"Min");u<i&&(i=u)}return i}case"max":{let r=await this.evaluateList(e.source,n);if(r.length===0)throw new N("Max on an empty list is undefined; guard with IsSet");let i=$(r[0],"Max");for(let a=1;a<r.length;a++){let u=$(r[a],"Max");u>i&&(i=u)}return i}case"average":{let r=await this.evaluateList(e.source,n);if(r.length===0)throw new N("Average on an empty list is undefined; guard with IsSet");let i=0;for(let a of r)i+=$(a,"Average");return i/r.length}case"for-each":{let r=await this.evaluateList(e.source,n),i=[];for(let a of r){let u=new Map(n);u.set(e.loopVar,B(a));let c=await this.evaluate(e.emit,u);if(c!=null)if(Array.isArray(c))for(let l of c)i.push(l);else i.push(c)}return i}case"list-map":{let r=await this.evaluateList(e.source,n),i=[];for(let a of r){let u=new Map(n);u.set(e.loopVar,B(a)),i.push(await this.evaluate(e.mapBody,u))}return i}case"filter":{let r=await this.evaluateList(e.source,n),i=[];for(let a of r){let u=new Map(n);u.set(e.loopVar,B(a)),await this.evaluate(e.predicate,u)===!0&&i.push(a)}return i}case"partition-by":{let r=await this.evaluateList(e.source,n),i=new Map,a=[];for(let u of r){let c=new Map(n);c.set(e.loopVar,B(u));let l=await this.evaluate(e.partitionKey,c),m=lt(l),g=i.get(m);g||(g={kind:"Partition",key:l,members:[]},i.set(m,g),a.push(m)),g.members.push(u)}return a.map(u=>i.get(u))}case"distinct-by":{let r=await this.evaluateList(e.source,n),i=new Set,a=[];for(let u of r){let c=new Map(n);c.set(e.loopVar,B(u));let l=await this.evaluate(e.distinctKey,c),m=lt(l);i.has(m)||(i.add(m),a.push(u))}return a}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 i=r.predicate;if(i instanceof b)return i}return}case"statement-value":{let r=await this.evaluate(e.source,n);return Ve(r)?$n(r):void 0}case"date-format":{let r=await this.evaluate(e.source,n),i=r==null?"":ue(r);return i?En(i,e.format):""}case"add":{let r=$(await this.evaluate(e.left,n),"Add"),i=$(await this.evaluate(e.right,n),"Add");return r+i}case"subtract":{let r=$(await this.evaluate(e.left,n),"Subtract"),i=$(await this.evaluate(e.right,n),"Subtract");return r-i}case"multiply":{let r=$(await this.evaluate(e.left,n),"Multiply"),i=$(await this.evaluate(e.right,n),"Multiply");return r*i}case"divide":{let r=$(await this.evaluate(e.left,n),"Divide"),i=$(await this.evaluate(e.right,n),"Divide");if(i===0)throw new N("Divide by zero; guard with When");return r/i}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 i=[];for(let a=0;a+e.windowSize<=r.length;a++){let u=r.slice(a,a+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)i.push(m);else i.push(l)}return i}case"pairwise-map":{let r=await this.evaluateList(e.source,n);if(r.length<2)return[];let i=[];for(let a=0;a+1<r.length;a++){let u=new Map(n);u.set(e.firstVar,B(r[a])),u.set(e.secondVar,B(r[a+1]));let c=await this.evaluate(e.pairBody,u);if(c!=null)if(Array.isArray(c))for(let l of c)i.push(l);else i.push(c)}return i}case"scan":{let r=await this.evaluateList(e.source,n);if(r.length===0)return[];let i=await this.evaluate(e.initialState,n),a=[];for(let u of r){let c=new Map(n);c.set(e.stateVar,i),c.set(e.elementVar,B(u));let l=await this.evaluate(e.accumulate,c);a.push(l),i=l}return a}case"list-item-at":{let r=await this.evaluateList(e.source,n),i=await this.evaluate(e.itemIndex,n);return typeof i!="number"||!Number.isInteger(i)||i<0||i>=r.length?void 0:r[i]}case"equals":{let r=await this.evaluate(e.left,n),i=await this.evaluate(e.right,n);return ut(r,i)}case"greater-than":{let r=await this.evaluate(e.left,n),i=await this.evaluate(e.right,n);return typeof r!="number"||typeof i!="number"?!1:r>i}case"less-than":{let r=await this.evaluate(e.left,n),i=await this.evaluate(e.right,n);return typeof r!="number"||typeof i!="number"?!1:r<i}case"greater-than-or-equal":{let r=await this.evaluate(e.left,n),i=await this.evaluate(e.right,n);return typeof r!="number"||typeof i!="number"?!1:r>=i}case"less-than-or-equal":{let r=await this.evaluate(e.left,n),i=await this.evaluate(e.right,n);return typeof r!="number"||typeof i!="number"?!1:r<=i}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),i=await this.evaluate(e.needle,n);for(let a of r)if(ut(a,i))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 E}case"is-embedded":return await this.evaluate(e.check,n)instanceof R;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 i=r;return i instanceof L||i instanceof C||i instanceof U||i instanceof V||i instanceof T||i instanceof w?i.object:void 0}case"let":{let r=await this.evaluate(e.bindValue,n),i=new Map(n);return i.set(e.bindName,r),this.evaluate(e.body,i)}case"get-statement-by-name":{let r=await this.evaluate(e.inSubject,n),i=await this.evaluate(e.byName,n);if(!(r instanceof K)||typeof i!="string")return;for(let a of r.statement)if(a.predicate?.subject?.name===i)return a;return}default:{let r=e;throw new N("Unknown expression kind")}}}async renderMarkdownLinks(e){let n=e.object,r="",i=0;for(let a of e.links){if(r+=n.slice(i,a.startOffset),a.target){let u=a.target.subject,c=a.displayText??await this.resolveLabel(u)??u.name;r+=`[${c}](${I(u)})`}else r+=a.displayText??a.reference;i=a.endOffset}return r+=n.slice(i),r}async resolveLabel(e){let n=await this.resolver.resolveSubject(e,this.catalog);if(!n)return;let r=pe(n,yn);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 i=[];for(let a=r.length-1;a>=1;a--){let u=new Map(n);u.set(e.firstVar,B(r[a-1])),u.set(e.secondVar,B(r[a]));let c=await this.evaluate(e.pairBody,u);if(c!=null)if(Array.isArray(c))for(let l of c)i.push(l);else i.push(c)}return i}if(e.kind==="for-each"){let r=await this.evaluateList(e.source,n),i=[];for(let a=r.length-1;a>=0;a--){let u=new Map(n);u.set(e.loopVar,B(r[a]));let c=await this.evaluate(e.emit,u);if(c!=null)if(Array.isArray(c))for(let l of c)i.push(l);else i.push(c)}return i}if(e.kind==="list-map"){let r=await this.evaluateList(e.source,n),i=[];for(let a=r.length-1;a>=0;a--){let u=new Map(n);u.set(e.loopVar,B(r[a])),i.push(await this.evaluate(e.mapBody,u))}return i}if(e.kind==="windowed-map"){let r=await this.evaluateList(e.source,n);if(r.length<e.windowSize)return[];let i=[];for(let a=r.length-e.windowSize;a>=0;a--){let u=r.slice(a,a+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)i.push(m);else i.push(l)}return i}}};function pe(t,e){if(t instanceof K)return kn(t,e);if(bn(t))return S(e,o.key)?t.key:S(e,o.members)?t.members:void 0}function kn(t,e){for(let n of t.statement){let r=Ae(n);if(!(!r||!S(r,e))&&(n instanceof L||n instanceof C||n instanceof U||n instanceof V||n instanceof T||n instanceof w))return n.object}}function hn(t,e){let n=[];for(let r of t.statement){let i=Ae(r);if(!(!i||!S(i,e))){if(r instanceof V)n.push(r.object.subject);else if(r instanceof w)for(let a of r.object)a instanceof b&&n.push(a.subject)}}return n}function Ae(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 B(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof K)&&!(t instanceof b)&&!(t instanceof R)&&"value"in t?t.value:t}function ot(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 bn(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 N(`${e} requires numeric elements; got ${Sn(t)}`)}function je(t){if(t instanceof E){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 wn=new Set(["stringValue","text","rawContent","key","propertyKey","linkLabel"]);function st(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function Sn(t){return t===void 0?"undefined":t===null?"null":Array.isArray(t)?`array(${t.length})`:typeof t}function En(t,e){let n=new Date(t);if(isNaN(n.getTime()))return"";let r=n.getUTCFullYear(),i=["January","February","March","April","May","June","July","August","September","October","November","December"][n.getUTCMonth()],a=["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`${a} ${u}`;case"long-date":return`${i} ${u}, ${r}`;case"year":return String(r);case"month-year":return`${i} ${r}`}}function ut(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,i=n??t,a=r??e,u=ct(t),c=ct(e);return u&&c?u.publisher===c.publisher&&u.package_===c.package_&&u.name===c.name:typeof i=="string"&&typeof a=="string"||typeof i=="number"&&typeof a=="number"||typeof i=="boolean"&&typeof a=="boolean"?i===a:!1}function ct(t){if(t instanceof b){let e=t.subject;return{publisher:e.publisher,package_:e.package_,name:e.name}}if(t instanceof E){let e=t.namespace??"",n=e.indexOf("/"),r=e.indexOf("@",n+1);if(n<0)return;let i=e.substring(0,n),a=r>=0?e.substring(n+1,r):e.substring(n+1);return{publisher:i,package_:a,name:t.name??""}}if(X(t))return{publisher:t.publisher,package_:t.package_,name:t.name}}function Ve(t){return t instanceof L||t instanceof C||t instanceof U||t instanceof V||t instanceof T||t instanceof w}function $n(t){return t instanceof L||t instanceof C||t instanceof U?String(t.object??""):t instanceof V?t.object?.subject?.name??"":t instanceof T?"[embedded]":t instanceof w?(t.object??[]).map(n=>{if(n instanceof b)return n.subject.name;let r=n.name;if(r&&r.length>0)return r;let i=n.value;return typeof i=="string"||typeof i=="number"||typeof i=="boolean"?String(i):"[embedded]"}).join(", "):""}function lt(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 vn={"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"}},F=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 ae)}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 F(`Transformation "${r.name}" does not declare output format "${e.outputFormat}". Declared: ${Array.from(r.outputs).join(", ")}`);let i=this.findBackend(e.outputFormat);if(!i)throw new F(`No backend registered for OutputFormat "${e.outputFormat}".`);let a=new oe(e.repository,e.parser,e.objectParser),u=new ge(a,e.allKanonaks,r.fragments);return r.kind==="instance"?this.runInstance(r,e,i,u):this.runSet(r,e,i,u)}async runInstance(e,n,r,i){let a=dt(n.instances,e.inputPattern.requires),u=ft(a,e.inputPattern.sortBy),c=[];for(let l of u){let m=new Map;m.set("input",l);let g=await i.evaluate(e.rule,m);De(g,e.name,`input "${l.name}"`);let k=Ke(await i.evaluate(e.artifactName,m),e.name,`input "${l.name}"`),D=Te(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,i){let a=dt(n.instances,e.inputPattern.requires),u=ft(a,e.inputPattern.sortBy);return e.partitionBy?this.runSetWithPartition(e,u,n,r,i):this.runSetSingle(e,u,n,r,i)}async runSetSingle(e,n,r,i,a){let u=new Map;u.set("inputs",n);let c=await a.evaluate(e.rule,u);De(c,e.name,"set");let l=Ke(await a.evaluate(e.artifactName,u),e.name,"set"),m=Te(e.overrides.get(r.outputFormat),r.runtimeOverride),g=i.render(c,m);return[{fileName:l,format:r.outputFormat,content:g,source:{kind:"set",memberCount:n.length}}]}async runSetWithPartition(e,n,r,i,a){let u=e.partitionBy,c=new Map,l=[];for(let g of n){let k=An(g,u);if(k==null)continue;let D=Dn(k),v=c.get(D);v||(v={keyValue:k,keyDisplay:Kn(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 a.evaluate(e.rule,D);De(v,e.name,`partition "${k.keyDisplay}"`);let yt=Ke(await a.evaluate(e.artifactName,D),e.name,`partition "${k.keyDisplay}"`),kt=Te(e.overrides.get(r.outputFormat),r.runtimeOverride),ht=i.render(v,kt);m.push({fileName:yt,format:r.outputFormat,content:ht,source:{kind:"set",memberCount:k.members.length,partitionKey:k.keyDisplay}})}return m}findBackend(e){let n=vn[e];if(n)return this.backends.get(n.formatUri)}};function dt(t,e){return e.length===0?t:t.filter(n=>{for(let r of e)if(!Vn(n,r))return!1;return!0})}function ft(t,e){if(e.length===0)return t;let n=[...t];return n.sort((r,i)=>{for(let a of e){let u=mt(r,a.byProperty),c=mt(i,a.byProperty),l=jn(u,c,a.order);if(l!==0)return l}return 0}),n}function mt(t,e){for(let n of t.statement){let r=Be(n);if(!(!r||!S(r,e))){if(n instanceof L||n instanceof C||n instanceof U)return n.object;if(n instanceof w)throw new F(`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 F(`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 jn(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 Vn(t,e){for(let n of t.statement){let r=Be(n);if(!r||!S(r,e))continue;let i=n.object;if(i!=null&&!(typeof i=="string"&&i.length===0)&&!(Array.isArray(i)&&i.length===0))return!0}return!1}function An(t,e){for(let n of t.statement){let r=Be(n);if(!(!r||!S(r,e))&&(n instanceof L||n instanceof C||n instanceof U||n instanceof V||n instanceof w))return n.object}}function Be(t){return t.predicate?.subject}function Dn(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 Kn(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 De(t,e,n){if(typeof t!="object"||t===null||t.kind!=="Document")throw new F(`Transformation "${e}" rule did not yield a Document for ${n}. Got: ${pt(t)}`)}function Ke(t,e,n){if(typeof t=="string")return t;if(Array.isArray(t)&&t.every(Tn))return t.map(r=>String(r)).join("");throw new F(`Transformation "${e}" artifactName did not yield a string for ${n}. Got: ${pt(t)}`)}function Tn(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function pt(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 Te(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 i=e?.trailingNewline??t?.trailingNewline;i!==void 0&&(n.trailingNewline=i);let a=e?.omitWrapper??t?.omitWrapper;return a!==void 0&&(n.omitWrapper=a),n}var M=class extends Error{constructor(n,r){super(n);this.cause=r;this.name="RenderError"}cause},gt={publisher:"kanonak.org",package_:"derivation",name:"default"},Le=class{constructor(e,n=new Re,r=new Ue){this.repository=e;this.parser=n;this.objectParser=r}repository;parser;objectParser;runner=new ye;cachedCatalog=void 0;invalidate(){this.cachedCatalog=void 0}async findDerivation(e){let n=await this.getCatalog(),r=q(n,e.resource);if(!(r instanceof E))return;let i=e.variant??gt;return Ne(r,e.format,i,n)}async render(e){let n=await this.findDerivation(e);if(!n)throw new M(`No derivation found for ${W(e.resource)} \u2192 format ${W(e.format)}`+(e.variant?` variant ${W(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=q(n,e.transformation);if(!(r instanceof E))throw new M(`Transformation not found: ${W(e.transformation)}`);let i=q(n,e.input);if(!(i instanceof E))throw new M(`Input resource not found: ${W(e.input)}`);let a=me(r,n),u=Bn(a.outputs,e.format);if(!u)throw new M(`Transformation ${W(e.transformation)} declares outputs [${[...a.outputs].join(", ")}], none of which corresponds to format ${W(e.format)}`);let c;try{c=await this.runner.run({transformation:r,instances:[i],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 M(`Transformation execution failed: ${l.message}`,l)}if(c.length===0)throw new M("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 W(t){return`${t.publisher}/${t.package_}/${t.name}`}function Bn(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,gt as DEFAULT_VARIANT,h as DOCAST,wt as DOCAST_PKG,bt as DOCAST_PUB,ae as DynamoDbBackend,ge as ExpressionEngineV3,N as ExpressionEvalErrorV3,ee as HtmlBackend,Q as JsonBackend,Y as MarkdownFrontmatterBackend,oe as ReferenceResolver,M as RenderError,vn as SUPPORTED_FORMATS_V3,te as SvgBackend,o as TX_V3,en as TX_V3_PKG,xt as TX_V3_PUB,nr as TX_V3_VERSION_MAJOR,Z as TomlBackend,Le as TransformationEngine,y as TransformationLoadErrorV3,F as TransformationRunnerErrorV3,ye as TransformationRunnerV3,re as YamlBackend,me as compileTransformationV3,x as renderMarkdownToHtml};
|
|
@@ -90,7 +90,7 @@ export interface CompiledFormatOverrideV3 {
|
|
|
90
90
|
* doctype + style + metadata <dl>; analogous in other backends). */
|
|
91
91
|
omitWrapper?: boolean | undefined;
|
|
92
92
|
}
|
|
93
|
-
export type CompiledExpressionV3 = CompiledStringLiteralV3 | CompiledIntegerLiteralV3 | CompiledDecimalLiteralV3 | CompiledBooleanLiteralV3 | CompiledVarRefV3 | CompiledPropertyReadV3 | CompiledTraverseV3 | CompiledBuildAstNodeV3 | CompiledWhenV3 | CompiledConcatV3 | CompiledFallbackV3 | CompiledUriNameV3 | CompiledUriPublisherV3 | CompiledUriPackageV3 | CompiledUriVersionV3 | CompiledSubjectUriV3 | CompiledUriLiteralV3 | CompiledDisplayLabelV3 | CompiledResolveRefV3 | CompiledNormalizeV3 | CompiledIsSetV3 | CompiledCallFragmentV3 | CompiledJoinV3 | CompiledCountV3 | CompiledSumV3 | CompiledMinV3 | CompiledMaxV3 | CompiledAverageV3 | CompiledForEachV3 | CompiledListMapV3 | CompiledFilterV3 | CompiledPartitionByV3 | CompiledDistinctByV3 | CompiledAllStatementsV3 | CompiledStatementPredicateV3 | CompiledStatementValueV3 | CompiledDateFormatV3 | CompiledAddV3 | CompiledSubtractV3 | CompiledMultiplyV3 | CompiledDivideV3 | CompiledReverseV3 | CompiledWindowedMapV3 | CompiledPairwiseMapV3 | CompiledScanV3 | CompiledListItemAtV3 | CompiledEqualsV3 | CompiledGreaterThanV3 | CompiledLessThanV3 | CompiledGreaterThanOrEqualV3 | CompiledLessThanOrEqualV3 | CompiledNotV3 | CompiledAndV3 | CompiledOrV3 | CompiledContainsV3 | CompiledAbsV3 | CompiledNegateV3 | CompiledIsReferenceV3 | CompiledIsEmbeddedV3 | CompiledIsListV3 | CompiledStatementObjectV3 | CompiledLetV3 | CompiledGetStatementByNameV3 | CompiledRenderMarkdownV3;
|
|
93
|
+
export type CompiledExpressionV3 = CompiledStringLiteralV3 | CompiledIntegerLiteralV3 | CompiledDecimalLiteralV3 | CompiledBooleanLiteralV3 | CompiledVarRefV3 | CompiledPropertyReadV3 | CompiledTraverseV3 | CompiledBuildAstNodeV3 | CompiledWhenV3 | CompiledConcatV3 | CompiledFallbackV3 | CompiledUriNameV3 | CompiledUriPublisherV3 | CompiledUriPackageV3 | CompiledUriVersionV3 | CompiledSubjectUriV3 | CompiledUriLiteralV3 | CompiledDisplayLabelV3 | CompiledResolveRefV3 | CompiledNormalizeV3 | CompiledIsSetV3 | CompiledCallFragmentV3 | CompiledJoinV3 | CompiledCountV3 | CompiledSumV3 | CompiledMinV3 | CompiledMaxV3 | CompiledAverageV3 | CompiledForEachV3 | CompiledListMapV3 | CompiledFilterV3 | CompiledPartitionByV3 | CompiledDistinctByV3 | CompiledAllStatementsV3 | CompiledStatementPredicateV3 | CompiledStatementValueV3 | CompiledDateFormatV3 | CompiledAddV3 | CompiledSubtractV3 | CompiledMultiplyV3 | CompiledDivideV3 | CompiledReverseV3 | CompiledWindowedMapV3 | CompiledPairwiseMapV3 | CompiledScanV3 | CompiledListItemAtV3 | CompiledEqualsV3 | CompiledGreaterThanV3 | CompiledLessThanV3 | CompiledGreaterThanOrEqualV3 | CompiledLessThanOrEqualV3 | CompiledNotV3 | CompiledAndV3 | CompiledOrV3 | CompiledContainsV3 | CompiledAbsV3 | CompiledNegateV3 | CompiledIsReferenceV3 | CompiledIsEmbeddedV3 | CompiledIsListV3 | CompiledStatementObjectV3 | CompiledIsStringV3 | CompiledIsNumberV3 | CompiledIsBooleanV3 | CompiledLetV3 | CompiledGetStatementByNameV3 | CompiledRenderMarkdownV3;
|
|
94
94
|
export interface CompiledStringLiteralV3 {
|
|
95
95
|
kind: 'string-literal';
|
|
96
96
|
value: string;
|
|
@@ -329,6 +329,18 @@ export interface CompiledStatementObjectV3 {
|
|
|
329
329
|
kind: 'statement-object';
|
|
330
330
|
source: CompiledExpressionV3;
|
|
331
331
|
}
|
|
332
|
+
export interface CompiledIsStringV3 {
|
|
333
|
+
kind: 'is-string';
|
|
334
|
+
check: CompiledExpressionV3;
|
|
335
|
+
}
|
|
336
|
+
export interface CompiledIsNumberV3 {
|
|
337
|
+
kind: 'is-number';
|
|
338
|
+
check: CompiledExpressionV3;
|
|
339
|
+
}
|
|
340
|
+
export interface CompiledIsBooleanV3 {
|
|
341
|
+
kind: 'is-boolean';
|
|
342
|
+
check: CompiledExpressionV3;
|
|
343
|
+
}
|
|
332
344
|
export interface CompiledLetV3 {
|
|
333
345
|
kind: 'let';
|
|
334
346
|
bindName: string;
|
|
@@ -195,6 +195,9 @@ export declare const TX_V3: {
|
|
|
195
195
|
readonly IsEmbedded: EntityUri;
|
|
196
196
|
readonly IsList: EntityUri;
|
|
197
197
|
readonly kindCheck: EntityUri;
|
|
198
|
+
readonly IsString: EntityUri;
|
|
199
|
+
readonly IsNumber: EntityUri;
|
|
200
|
+
readonly IsBoolean: EntityUri;
|
|
198
201
|
readonly StatementObject: EntityUri;
|
|
199
202
|
readonly statementSource: EntityUri;
|
|
200
203
|
readonly Let: EntityUri;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanonak-protocol/sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.20.0",
|
|
4
4
|
"description": "Kanonak Protocol SDK - Document repository and parsing implementations for TypeScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"README.md"
|
|
89
89
|
],
|
|
90
90
|
"scripts": {
|
|
91
|
-
"build": "tsup && tsc --emitDeclarationOnly",
|
|
91
|
+
"build": "npm run clean && tsup && tsc --emitDeclarationOnly",
|
|
92
92
|
"clean": "rimraf dist",
|
|
93
93
|
"typecheck": "tsc --noEmit",
|
|
94
94
|
"test": "jest",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"yaml-parser"
|
|
114
114
|
],
|
|
115
115
|
"dependencies": {
|
|
116
|
-
"@kanonak-protocol/types": "^3.
|
|
116
|
+
"@kanonak-protocol/types": "^3.20.0",
|
|
117
117
|
"ignore": "^7.0.5",
|
|
118
118
|
"js-yaml": "^4.1.0",
|
|
119
119
|
"yaml": "^2.7.0"
|