@kanonak-protocol/sdk 3.77.0 → 4.0.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.
Files changed (43) hide show
  1. package/dist/browser.js +1 -1
  2. package/dist/canonical/CanonicalHash.d.ts +8 -0
  3. package/dist/canonical/Datatypes.d.ts +98 -0
  4. package/dist/canonical/index.d.ts +2 -1
  5. package/dist/{chunk-RVOMWGIN.js → chunk-4OSNT57C.js} +1 -1
  6. package/dist/{chunk-KXVSGB6Q.js → chunk-6I4BYZVA.js} +1 -1
  7. package/dist/{chunk-Z5ELOT2C.js → chunk-NC3FSY3R.js} +1 -1
  8. package/dist/{chunk-XQS5LDSO.js → chunk-PBNVHBS3.js} +1 -1
  9. package/dist/chunk-T3JR2SV6.js +1 -0
  10. package/dist/chunk-V3YPCUA6.js +84 -0
  11. package/dist/chunk-VNKX52D5.js +2 -0
  12. package/dist/chunk-WUAKDYY6.js +1 -0
  13. package/dist/{chunk-IOMNZBK4.js → chunk-XYEY6HUC.js} +1 -1
  14. package/dist/{chunk-LKBG2MK6.js → chunk-YCV4H6H5.js} +1 -1
  15. package/dist/{chunk-PJMOM5H7.js → chunk-YI5GLYMB.js} +1 -1
  16. package/dist/{chunk-ATH6636H.js → chunk-YWUKDEZA.js} +1 -1
  17. package/dist/{chunk-XWRVENU6.js → chunk-ZRMF5QLN.js} +1 -1
  18. package/dist/chunk-ZYAABYDS.js +1 -0
  19. package/dist/index.d.ts +3 -2
  20. package/dist/index.js +26 -26
  21. package/dist/kanonaks/LiteralKanonak.d.ts +4 -0
  22. package/dist/parsing/KanonakObjectParser.d.ts +13 -0
  23. package/dist/parsing/index.js +1 -1
  24. package/dist/reasoning/index.js +1 -1
  25. package/dist/repositories/browser.js +1 -1
  26. package/dist/repositories/index.js +1 -1
  27. package/dist/resolution/index.js +1 -1
  28. package/dist/search/index.js +1 -1
  29. package/dist/server/index.js +1 -1
  30. package/dist/statements/ScalarStatement.d.ts +14 -0
  31. package/dist/transformations/index.js +1 -1
  32. package/dist/uri-helpers/index.js +1 -1
  33. package/dist/validation/IKanonakObjectValidator.d.ts +6 -0
  34. package/dist/validation/KanonakObjectValidator.d.ts +20 -2
  35. package/dist/validation/index.d.ts +1 -1
  36. package/dist/validation/index.js +1 -1
  37. package/dist/validation/rules/repository/DiamondNameClashRule.d.ts +8 -0
  38. package/package.json +2 -2
  39. package/dist/chunk-CG43Z65M.js +0 -2
  40. package/dist/chunk-IUZZDC2U.js +0 -1
  41. package/dist/chunk-NPEGVH4R.js +0 -84
  42. package/dist/chunk-TJPQETHV.js +0 -1
  43. package/dist/chunk-W6T7MOKY.js +0 -1
package/dist/browser.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a as fe,b as ge,c as me,d as C,e as E,f as d,g as Ye}from"./chunk-CG43Z65M.js";import{a as Qe}from"./chunk-RVOMWGIN.js";import"./chunk-QHABFCRC.js";import{b as L,c as W,d as F}from"./chunk-LKBG2MK6.js";import{a as H}from"./chunk-4NO7MHS7.js";import{a as Pe,b as we,c as he}from"./chunk-PJMOM5H7.js";import{a as ke,b as be}from"./chunk-PEUTCG3B.js";import"./chunk-PEJALHXK.js";import"./chunk-SC5M74NM.js";import{A as We,B as Fe,C as Ge,L as Xe,a as Ke,b as xe,c as Se,d as Re,f as De,g as Be,h as Ce,i as Ee,j as je,k as ve,l as _e,m as Ie,n as Ae,o as Te,p as Oe,q as Ve,r as $e,s as Ue,t as Me,u as ze,v as Ne,w as Je,x as He,y as qe,z as Le}from"./chunk-NPEGVH4R.js";import"./chunk-SHDHMKMJ.js";import{a as Y,c as le,f as pe}from"./chunk-IUZZDC2U.js";import{a as q}from"./chunk-TJPQETHV.js";import{a as ye}from"./chunk-Z5ELOT2C.js";import"./chunk-XQS5LDSO.js";import{b as ue,c as de}from"./chunk-IOMNZBK4.js";import{a as G,b as X,c as Q,d as ee,e as re,f as te,g as ne,h as oe,i as se,j as ie,k as ae,l as ce}from"./chunk-W6T7MOKY.js";import{a as Z}from"./chunk-FUUTGGJS.js";import{c as O,d as V,e as $,f as U,g as M,h as z,i as N,j as J}from"./chunk-2ACBWC7K.js";var j="kanonak-credentials",u="credentials",Ze=1,g=class{async get(r){let e=d(r),t=await h();return new Promise((o,a)=>{let s=t.transaction(u,"readonly"),i=s.objectStore(u).get(e);i.onsuccess=()=>o(i.result??null),i.onerror=()=>a(new Error(`IndexedDB read failed for '${e}': ${i.error?.message}`)),s.oncomplete=()=>t.close()})}async store(r,e){let t=d(r),o=await h();return new Promise((a,s)=>{let l=o.transaction(u,"readwrite"),c=l.objectStore(u).put(e,t);c.onsuccess=()=>a(),c.onerror=()=>s(new Error(`IndexedDB write failed for '${t}': ${c.error?.message}`)),l.oncomplete=()=>o.close()})}async remove(r){let e=d(r),t=await h();return new Promise((o,a)=>{let s=t.transaction(u,"readwrite"),i=s.objectStore(u).delete(e);i.onsuccess=()=>o(),i.onerror=()=>a(new Error(`IndexedDB delete failed for '${e}': ${i.error?.message}`)),s.oncomplete=()=>t.close()})}async list(){let r=await h();return new Promise((e,t)=>{let o=r.transaction(u,"readonly"),s=o.objectStore(u).getAllKeys();s.onsuccess=()=>e(s.result??[]),s.onerror=()=>t(new Error(`IndexedDB list failed: ${s.error?.message}`)),o.oncomplete=()=>r.close()})}};function h(){return new Promise((n,r)=>{let e=indexedDB.open(j,Ze);e.onupgradeneeded=()=>{let t=e.result;t.objectStoreNames.contains(u)||t.createObjectStore(u)},e.onsuccess=()=>n(e.result),e.onerror=()=>r(new Error(`Failed to open IndexedDB '${j}': ${e.error?.message}
1
+ import{a as fe,b as ge,c as me,d as C,e as E,f as d,g as Ye}from"./chunk-VNKX52D5.js";import{a as Qe}from"./chunk-4OSNT57C.js";import"./chunk-QHABFCRC.js";import{b as L,c as W,d as F}from"./chunk-YCV4H6H5.js";import{a as H}from"./chunk-4NO7MHS7.js";import{a as Pe,b as we,c as he}from"./chunk-YI5GLYMB.js";import{a as ke,b as be}from"./chunk-PEUTCG3B.js";import"./chunk-PEJALHXK.js";import"./chunk-SC5M74NM.js";import{A as We,B as Fe,C as Ge,L as Xe,a as Ke,b as xe,c as Se,d as Re,f as De,g as Be,h as Ce,i as Ee,j as je,k as ve,l as _e,m as Ie,n as Ae,o as Te,p as Oe,q as Ve,r as $e,s as Ue,t as Me,u as ze,v as Ne,w as Je,x as He,y as qe,z as Le}from"./chunk-V3YPCUA6.js";import"./chunk-SHDHMKMJ.js";import{a as Y,c as le,w as pe}from"./chunk-WUAKDYY6.js";import{a as q}from"./chunk-ZYAABYDS.js";import{a as ye}from"./chunk-NC3FSY3R.js";import"./chunk-PBNVHBS3.js";import{b as ue,c as de}from"./chunk-XYEY6HUC.js";import{a as G,b as X,c as Q,d as ee,e as re,f as te,g as ne,h as oe,i as se,j as ie,k as ae,l as ce}from"./chunk-T3JR2SV6.js";import{a as Z}from"./chunk-FUUTGGJS.js";import{c as O,d as V,e as $,f as U,g as M,h as z,i as N,j as J}from"./chunk-2ACBWC7K.js";var j="kanonak-credentials",u="credentials",Ze=1,g=class{async get(r){let e=d(r),t=await h();return new Promise((o,a)=>{let s=t.transaction(u,"readonly"),i=s.objectStore(u).get(e);i.onsuccess=()=>o(i.result??null),i.onerror=()=>a(new Error(`IndexedDB read failed for '${e}': ${i.error?.message}`)),s.oncomplete=()=>t.close()})}async store(r,e){let t=d(r),o=await h();return new Promise((a,s)=>{let l=o.transaction(u,"readwrite"),c=l.objectStore(u).put(e,t);c.onsuccess=()=>a(),c.onerror=()=>s(new Error(`IndexedDB write failed for '${t}': ${c.error?.message}`)),l.oncomplete=()=>o.close()})}async remove(r){let e=d(r),t=await h();return new Promise((o,a)=>{let s=t.transaction(u,"readwrite"),i=s.objectStore(u).delete(e);i.onsuccess=()=>o(),i.onerror=()=>a(new Error(`IndexedDB delete failed for '${e}': ${i.error?.message}`)),s.oncomplete=()=>t.close()})}async list(){let r=await h();return new Promise((e,t)=>{let o=r.transaction(u,"readonly"),s=o.objectStore(u).getAllKeys();s.onsuccess=()=>e(s.result??[]),s.onerror=()=>t(new Error(`IndexedDB list failed: ${s.error?.message}`)),o.oncomplete=()=>r.close()})}};function h(){return new Promise((n,r)=>{let e=indexedDB.open(j,Ze);e.onupgradeneeded=()=>{let t=e.result;t.objectStoreNames.contains(u)||t.createObjectStore(u)},e.onsuccess=()=>n(e.result),e.onerror=()=>r(new Error(`Failed to open IndexedDB '${j}': ${e.error?.message}
2
2
  Credential storage requires IndexedDB support in your browser.`))})}async function _(){let n=await crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),r=await crypto.subtle.exportKey("jwk",n.publicKey);return{signingKey:n.privateKey,publicKeyJwk:r}}async function k(){let n=await crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},!0,["sign"]),r=await crypto.subtle.exportKey("jwk",n.publicKey),e=await crypto.subtle.exportKey("jwk",n.privateKey);return{keys:{signingKey:n.privateKey,publicKeyJwk:r},dpopKeyPair:{publicKey:r,privateKey:e}}}async function b(n){return{signingKey:await crypto.subtle.importKey("jwk",n.privateKey,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),publicKeyJwk:n.publicKey}}async function K(n,r,e,t,o){let a={alg:"ES256",typ:"dpop+jwt",jwk:{kty:n.publicKeyJwk.kty,crv:n.publicKeyJwk.crv,x:n.publicKeyJwk.x,y:n.publicKeyJwk.y}},s={jti:crypto.randomUUID(),htm:r.toUpperCase(),htu:e,iat:Math.floor(Date.now()/1e3)};return t&&(s.ath=await rr(t)),o&&(s.nonce=o),await er(a,s,n.signingKey)}function x(n){return!n||n.length===0?!1:n.some(r=>r.toUpperCase()==="ES256")}async function er(n,r,e){let t=v(JSON.stringify(n)),o=v(JSON.stringify(r)),a=new TextEncoder().encode(`${t}.${o}`),s=await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},e,a),l=D(s);return`${t}.${o}.${l}`}async function rr(n){let r=new TextEncoder().encode(n),e=await crypto.subtle.digest("SHA-256",r);return D(e)}function v(n){let r=new TextEncoder().encode(n);return D(r.buffer)}function D(n){let r=new Uint8Array(n),e="";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}var tr=300*1e3,S=class{credentialBackend;callbackUrl;constructor(r){this.credentialBackend=new g,this.callbackUrl=r??`${window.location.origin}/browser/callback.html`}async authorize(r){let e=d(r),t=await this.discover(e);if(!t)return{success:!1,error:`No OAuth discovery endpoint found for '${e}'.`};if(!t.authorizationEndpoint||!t.tokenEndpoint)return{success:!1,error:`OAuth metadata incomplete for '${e}'.`};let o=x(t.dpopSigningAlgValuesSupported),a=null,s=null;if(o){let f=await k();a=f.keys,s=f.dpopKeyPair}let l=await this.credentialBackend.get(e),i=l?.clientId??null,c=l?.clientSecret??null;if(!i&&t.registrationEndpoint){let f=await this.registerClient(t.registrationEndpoint);if(!f)return{success:!1,error:`Dynamic client registration failed for '${e}'.`};i=f.clientId,c=f.clientSecret??null}if(!i)return{success:!1,error:`No OAuth client credentials for '${e}'.`};let m=nr(),p=await or(m),R=sr(),A=ir(t.authorizationEndpoint,i,this.callbackUrl,R,p),y=await this.openAuthPopup(A,R);if(!y)return{success:!1,error:"Authorization timed out or was cancelled."};if(y.error)return{success:!1,error:`Authorization failed: ${y.error}`};if(!y.code)return{success:!1,error:"No authorization code received."};if(y.state!==R)return{success:!1,error:"State mismatch \u2014 possible CSRF attack."};let P=await this.exchangeCode(t.tokenEndpoint,i,c,y.code,this.callbackUrl,m,a);if(!P)return{success:!1,error:"Token exchange failed."};let T={clientId:i,clientSecret:c,accessToken:P.accessToken??null,refreshToken:P.refreshToken??null,expiresAt:P.expiresIn?new Date(Date.now()+P.expiresIn*1e3).toISOString():null,tokenEndpoint:t.tokenEndpoint,dpopKeyPair:s};return await this.credentialBackend.store(e,T),{success:!0,host:e}}async getCredentialWithKeys(r){let e=await this.credentialBackend.get(r);if(!e)return null;let t=null;return e.dpopKeyPair&&(t=await b(e.dpopKeyPair)),{credential:e,dpopKeys:t}}async logout(r){let e=d(r);return await this.credentialBackend.remove(e),{success:!0,host:e}}async listAuthenticated(){return this.credentialBackend.list()}async discover(r){for(let e of[`https://${r}/.well-known/oauth-authorization-server`,`https://${r}/.well-known/openid-configuration`])try{let t=await fetch(e);if(!t.ok)continue;let o=await t.json();return{issuer:w(o.issuer),authorizationEndpoint:w(o.authorization_endpoint),tokenEndpoint:w(o.token_endpoint),registrationEndpoint:w(o.registration_endpoint),revocationEndpoint:w(o.revocation_endpoint),dpopSigningAlgValuesSupported:I(o.dpop_signing_alg_values_supported),codeChallengeMethodsSupported:I(o.code_challenge_methods_supported)}}catch{continue}return null}async registerClient(r){try{let e=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:"Kanonak Browser",redirect_uris:[this.callbackUrl],grant_types:["authorization_code","refresh_token"],response_types:["code"],token_endpoint_auth_method:"none"})});if(!e.ok)return null;let t=await e.json(),o=t.client_id;return o?{clientId:o,clientSecret:t.client_secret}:null}catch{return null}}openAuthPopup(r,e){return new Promise(t=>{let o=window.open(r,"kanonak-auth","width=500,height=700,menubar=no,toolbar=no,location=yes,status=no");if(!o){t(null);return}let a=setTimeout(()=>{i(),t(null)},tr),s=c=>{c.origin===window.location.origin&&(!c.data||c.data.type!=="kanonak-auth-callback"||(i(),t({code:c.data.code??void 0,state:c.data.state??void 0,error:c.data.error??void 0})))},l=setInterval(()=>{o.closed&&(i(),t(null))},500),i=()=>{clearTimeout(a),clearInterval(l),window.removeEventListener("message",s);try{o.close()}catch{}};window.addEventListener("message",s)})}async exchangeCode(r,e,t,o,a,s,l){let i=new URLSearchParams({grant_type:"authorization_code",client_id:e,code:o,redirect_uri:a,code_verifier:s});t&&i.set("client_secret",t);let c={"Content-Type":"application/x-www-form-urlencoded"};l&&(c.DPoP=await K(l,"POST",r));try{let m=await fetch(r,{method:"POST",headers:c,body:i.toString()});if(!m.ok)return null;let p=await m.json();return{accessToken:p.access_token,refreshToken:p.refresh_token,expiresIn:typeof p.expires_in=="number"?p.expires_in:void 0}}catch{return null}}};function nr(){let n=new Uint8Array(32);return crypto.getRandomValues(n),B(n.buffer)}async function or(n){let r=new TextEncoder().encode(n),e=await crypto.subtle.digest("SHA-256",r);return B(e)}function sr(){let n=new Uint8Array(16);return crypto.getRandomValues(n),B(n.buffer)}function ir(n,r,e,t,o){let a=new URLSearchParams({client_id:r,response_type:"code",redirect_uri:e,state:t,code_challenge:o,code_challenge_method:"S256"});return`${n}?${a}`}function B(n){let r=new Uint8Array(n),e="";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function w(n){return typeof n=="string"?n:null}function I(n){return Array.isArray(n)?n.filter(r=>typeof r=="string"):null}export{Ne as AmbiguousReferenceRule,se as BooleanStatement,g as BrowserCredentialBackend,S as BrowserOAuthFlow,Fe as ClassDefinitionRule,Ie as ClassHierarchyCycleRule,X as DefinedKanonak,Me as DefinitionPropertyReferenceRule,ge as EdgeType,Y as EmbeddedKanonak,je as EmbeddedKanonakTypeRule,ae as EmbeddedStatement,me as GraphBuilder,F as HttpKanonakDocumentRepository,ve as ImportExistenceRule,H as InMemoryKanonakDocumentRepository,Ue as InstancePropertyReferenceRule,G as Kanonak,we as KanonakDocumentPositions,pe as KanonakObjectParser,Xe as KanonakObjectValidator,q as KanonakParser,Z as KanonakUri,ke as KanonakUriBuilder,ce as ListStatement,Ge as MarkdownLinkRule,le as MarkdownStatement,$e as NamespaceImportCycleRule,De as NamespacePrefixRule,fe as NodeType,oe as NumberStatement,He as ObjectPropertyImportRule,qe as ObjectPropertyValueValidationRule,Se as OntologyValidationError,Ke as OntologyValidationResult,Le as PropertyDomainRule,Ae as PropertyHierarchyCycleRule,Pe as PropertyMetadata,Je as PropertyRangeReferenceRule,Te as PropertyRangeRequiredRule,Ce as PropertyTypeSpecificityRule,We as PropertyValueTypeRule,L as PublisherConfigResolver,W as PublisherIndex,ee as ReferenceKanonak,ie as ReferenceStatement,Be as ResourceNamingRule,ue as ResourceResolver,ye as ResourceTypeClassifier,te as ScalarStatement,re as Statement,ne as StringStatement,Oe as SubClassOfReferenceRule,Ve as SubPropertyOfReferenceRule,Q as SubjectKanonak,Ee as SubjectKanonakTypeRequiredRule,de as TypeResolver,_e as UnresolvedReferenceRule,Re as ValidationContext,xe as ValidationSeverity,ze as XsdImportRule,x as browserServerSupportsDPoP,Ye as buildOntologyModel,O as compareVersions,K as createBrowserDPoPProof,U as createVersion,Qe as findDerivation,be as findInstancesByType,$ as formatVersion,k as generateBrowserDPoPKeyPair,_ as generateBrowserDPoPKeys,E as hasValidToken,b as importDPoPKeys,z as isCompatibleVersion,C as isExpired,N as isMajorCompatible,d as normalizeHost,M as parseVersionString,he as parseWithPositions,J as pickHighestDocument,V as versionsEqual};
@@ -1,4 +1,12 @@
1
1
  import { type Kanonak } from '../kanonaks/index.js';
2
+ /**
3
+ * The frozen canonical-form version. Content addresses are permanent, so the
4
+ * rules in this module are pinned to this version and evolve only by minting a
5
+ * NEW version, never by editing in place. It is NOT part of the hashed bytes
6
+ * (so historical hashes stay valid); it stamps the golden-vector fixture file
7
+ * and lets a consumer record which form produced an address.
8
+ */
9
+ export declare const CANONICAL_FORM_VERSION = "1";
2
10
  /**
3
11
  * Render a parsed kanonak collection into its canonical JSON form.
4
12
  *
@@ -0,0 +1,98 @@
1
+ import type { EntityUri } from '../uri-helpers/index.js';
2
+ /**
3
+ * The closed set of canonical-form carriers (v1). A datatype maps to exactly
4
+ * one carrier; the carrier determines both the canonical lexical rule and the
5
+ * tag that participates in identity.
6
+ */
7
+ export declare enum Carrier {
8
+ Integer = "integer",
9
+ Decimal = "decimal",
10
+ Double = "double",
11
+ Float = "float",
12
+ Boolean = "boolean",
13
+ String = "string",
14
+ AnyUri = "anyURI",
15
+ LangString = "langString",
16
+ DateTime = "dateTime",
17
+ Date = "date",
18
+ Time = "time",
19
+ HexBinary = "hexBinary",
20
+ Base64Binary = "base64Binary"
21
+ }
22
+ /**
23
+ * The carrier for a datatype, or `undefined` if the datatype is outside the v1
24
+ * canonicalized set. A literal of an out-of-set datatype is canonicalized as a
25
+ * byte-preserved raw token (the untyped/`$extra` tier), never guessed into a
26
+ * carrier.
27
+ */
28
+ export declare function carrierOf(datatype: EntityUri): Carrier | undefined;
29
+ /**
30
+ * Canonical `xsd:integer` (and every derived integer): optional `-`, digits
31
+ * with no leading zeros, `0` for zero, never `-0`, never a leading `+`.
32
+ * Backed by `BigInt` so values beyond 2^53 (e.g. epoch-nanoseconds) are exact.
33
+ */
34
+ export declare function canonicalInteger(raw: string): string;
35
+ /**
36
+ * Canonical `xsd:decimal`: value-based minimal form. Optional `-`, integer part
37
+ * with no leading zeros (`0` if zero), then `.`+fraction only when the fraction
38
+ * is non-zero, with no trailing zeros. `1.10 → 1.1`, `1.00 → 1`, `0.10 → 0.1`,
39
+ * `-0 → 0`, `-0.00 → 0`. Pure string arithmetic — never parsed to a double.
40
+ */
41
+ export declare function canonicalDecimal(raw: string): string;
42
+ /** Canonical `xsd:double` — shortest round-tripping decimal; INF / -INF / NaN. */
43
+ export declare function canonicalDouble(raw: string): string;
44
+ /**
45
+ * Canonical `xsd:float` — like {@link canonicalDouble} but the value is first
46
+ * rounded to IEEE single precision (`Math.fround`). NOTE: exact cross-language
47
+ * agreement on shortest-float32 strings is a known sharp edge to lock against
48
+ * the golden vectors; representative values agree.
49
+ */
50
+ export declare function canonicalFloat(raw: string): string;
51
+ /** Canonical `xsd:boolean`: `true` / `false`. Accepts the `1`/`0` lexicals. */
52
+ export declare function canonicalBoolean(raw: string): string;
53
+ /** Canonical string value: Unicode NFC. No whitespace collapse (that's a facet). */
54
+ export declare function canonicalString(raw: string): string;
55
+ /** Canonical `xsd:anyURI`: NFC (distinct carrier/tag from string, same lexical rule). */
56
+ export declare function canonicalAnyUri(raw: string): string;
57
+ /**
58
+ * Canonical `rdf:langString`: NFC value + BCP 47 canonical-CASE language tag
59
+ * (language lowercase, script titlecase, region uppercase) — `"hi"@EN-us`
60
+ * becomes `("hi", "en-US")`. Case only; no IANA registry / preferred-value
61
+ * substitution. Returns the pair; the canonical form serializes both.
62
+ */
63
+ export declare function canonicalLangString(value: string, lang: string): {
64
+ value: string;
65
+ lang: string;
66
+ };
67
+ /** BCP 47 canonical case by subtag position. */
68
+ export declare function canonicalLanguageTag(tag: string): string;
69
+ /** Canonical `xsd:hexBinary`: uppercase hex digits, even length. */
70
+ export declare function canonicalHexBinary(raw: string): string;
71
+ /**
72
+ * Canonical `xsd:base64Binary`: RFC 4648 standard alphabet, canonical padding,
73
+ * no line breaks. Decodes (tolerating XSD-permitted internal whitespace) then
74
+ * re-encodes, so any padding/line-wrap variant of the same bytes collapses.
75
+ */
76
+ export declare function canonicalBase64(raw: string): string;
77
+ /**
78
+ * Canonical `xsd:dateTime`. Offset-bearing → shifted to UTC `Z` (instant
79
+ * equality, so `13:00:00+01:00` and `12:00:00Z` collide). Timezone-less →
80
+ * floating: canonical lexical form, no `Z`, distinct from any zoned instant.
81
+ * Fractional seconds are preserved at arbitrary precision (only trailing zeros
82
+ * trimmed) and never participate in the offset shift.
83
+ */
84
+ export declare function canonicalDateTime(raw: string): string;
85
+ /**
86
+ * Canonical `xsd:date`: lexical only — canonical year width + canonical
87
+ * timezone spelling, NO UTC shift (a date is not an instant; shifting could
88
+ * cross midnight). Timezone-less stays distinct from a zoned date.
89
+ */
90
+ export declare function canonicalDate(raw: string): string;
91
+ /**
92
+ * Canonical `xsd:time`: lexical only — arbitrary-precision fractional seconds,
93
+ * canonical timezone spelling, NO UTC shift. `24:00:00` normalizes to
94
+ * `00:00:00` (XSD value-space equivalence within a day).
95
+ */
96
+ export declare function canonicalTime(raw: string): string;
97
+ /** Canonical lexical form of a raw token under a carrier. Throws on malformed input. */
98
+ export declare function canonicalScalarLexical(carrier: Carrier, raw: string): string;
@@ -1 +1,2 @@
1
- export { canonicalForm, canonicalHash } from './CanonicalHash.js';
1
+ export { canonicalForm, canonicalHash, CANONICAL_FORM_VERSION } from './CanonicalHash.js';
2
+ export { Carrier, carrierOf, canonicalInteger, canonicalDecimal, canonicalDouble, canonicalFloat, canonicalBoolean, canonicalString, canonicalAnyUri, canonicalLangString, canonicalLanguageTag, canonicalHexBinary, canonicalBase64, canonicalDateTime, canonicalDate, canonicalTime, canonicalScalarLexical, } from './Datatypes.js';
@@ -1 +1 @@
1
- import{a as D}from"./chunk-IUZZDC2U.js";import{c as j,d as m,g as R,j as p,k as K,l as k}from"./chunk-W6T7MOKY.js";import{c as b,g as u}from"./chunk-2ACBWC7K.js";function F(a,e,n,t){let i=g(a);if(i.length>0){let s=v(i,e,n);return s?{transformation:s.transformation,source:"instance"}:void 0}let r=new Set,o=O(a);for(;o.length>0;){let s=o.shift(),f=_(s.subject);if(r.has(f))continue;r.add(f);let l=S(t,s.subject);if(l.length===0)continue;let U=l.flatMap(g),h=v(U,e,n);if(h)return{transformation:h.transformation,source:{publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name}};for(let T of l)for(let P of $(T))o.push(P)}let c={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"};if(!r.has(_(c))){let s=S(t,c).flatMap(g),f=v(s,e,n);if(f)return{transformation:f.transformation,source:c}}}function g(a){let e=[];for(let n of a.statement)if(n instanceof k&&d(n,"kanonak.org","derivation","derivations"))for(let t of n.object??[]){if(!(t instanceof D))continue;let i=x(t);i&&e.push(i)}return e}function v(a,e,n){let t=a.filter(o=>E(o.format,e)&&E(o.variant,n));if(t.length<=1)return t[0];let i=t[0].transformation,r=t[0];for(let o of t){let c=o.transformation;if(c.publisher!==i.publisher||c.package_!==i.package_||c.name!==i.name)continue;let s=u(r.transformation.version),f=u(c.version);s&&f&&b(f,s)>0&&(r=o)}return r}function x(a){let e,n,t;for(let i of a.statement)i instanceof p?d(i,"kanonak.org","derivation","format")?e=y(i):d(i,"kanonak.org","derivation","variant")&&(n=y(i)):i instanceof K&&d(i,"kanonak.org","derivation","transformation")&&(t=C(i.object));if(!(!e||!t))return n||(n={publisher:"kanonak.org",package_:"derivation",name:"default"}),{format:e,variant:n,transformation:t}}function C(a){let e,n,t,i;for(let r of a.statement){if(!(r instanceof R))continue;let o=r.predicate?.subject?.name;o==="publisher"?e=r.object:o==="package"?n=r.object:o==="version"?t=r.object:o==="name"&&(i=r.object)}if(!(!e||!n||!t||!i))return{publisher:e,package_:n,version:t,name:i}}function O(a){let e=[];for(let n of a.statement)n instanceof p&&n.predicate?.subject?.name==="type"&&n.object instanceof m&&e.push(n.object);return e}function $(a){let e=[];for(let n of a.statement)if(n instanceof p){if(n.predicate?.subject?.name!=="subClassOf")continue;n.object instanceof m&&e.push(n.object)}else if(n instanceof k){if(n.predicate?.subject?.name!=="subClassOf")continue;for(let t of n.object??[])t instanceof m&&e.push(t)}return e}function S(a,e){let n=[];for(let t of a){if(!(t instanceof j)||t.name!==e.name)continue;(t.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&n.push(t)}return n.sort((t,i)=>{let r=u((t.namespace||"").split("@")[1]??""),o=u((i.namespace||"").split("@")[1]??"");return!r||!o?0:b(o,r)}),n}function d(a,e,n,t){let i=a.predicate?.subject;return i?i.publisher===e&&i.package_===n&&i.name===t:!1}function y(a){let e=a.object.subject;return{publisher:e.publisher,package_:e.package_,name:e.name}}function E(a,e){return a.publisher===e.publisher&&a.package_===e.package_&&a.name===e.name}function _(a){return`${a.publisher}/${a.package_}/${a.name}`}export{F as a};
1
+ import{a as D}from"./chunk-WUAKDYY6.js";import{c as j,d as m,g as R,j as p,k as K,l as k}from"./chunk-T3JR2SV6.js";import{c as b,g as u}from"./chunk-2ACBWC7K.js";function F(a,e,n,t){let i=g(a);if(i.length>0){let s=v(i,e,n);return s?{transformation:s.transformation,source:"instance"}:void 0}let r=new Set,o=O(a);for(;o.length>0;){let s=o.shift(),f=_(s.subject);if(r.has(f))continue;r.add(f);let l=S(t,s.subject);if(l.length===0)continue;let U=l.flatMap(g),h=v(U,e,n);if(h)return{transformation:h.transformation,source:{publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name}};for(let T of l)for(let P of $(T))o.push(P)}let c={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"};if(!r.has(_(c))){let s=S(t,c).flatMap(g),f=v(s,e,n);if(f)return{transformation:f.transformation,source:c}}}function g(a){let e=[];for(let n of a.statement)if(n instanceof k&&d(n,"kanonak.org","derivation","derivations"))for(let t of n.object??[]){if(!(t instanceof D))continue;let i=x(t);i&&e.push(i)}return e}function v(a,e,n){let t=a.filter(o=>E(o.format,e)&&E(o.variant,n));if(t.length<=1)return t[0];let i=t[0].transformation,r=t[0];for(let o of t){let c=o.transformation;if(c.publisher!==i.publisher||c.package_!==i.package_||c.name!==i.name)continue;let s=u(r.transformation.version),f=u(c.version);s&&f&&b(f,s)>0&&(r=o)}return r}function x(a){let e,n,t;for(let i of a.statement)i instanceof p?d(i,"kanonak.org","derivation","format")?e=y(i):d(i,"kanonak.org","derivation","variant")&&(n=y(i)):i instanceof K&&d(i,"kanonak.org","derivation","transformation")&&(t=C(i.object));if(!(!e||!t))return n||(n={publisher:"kanonak.org",package_:"derivation",name:"default"}),{format:e,variant:n,transformation:t}}function C(a){let e,n,t,i;for(let r of a.statement){if(!(r instanceof R))continue;let o=r.predicate?.subject?.name;o==="publisher"?e=r.object:o==="package"?n=r.object:o==="version"?t=r.object:o==="name"&&(i=r.object)}if(!(!e||!n||!t||!i))return{publisher:e,package_:n,version:t,name:i}}function O(a){let e=[];for(let n of a.statement)n instanceof p&&n.predicate?.subject?.name==="type"&&n.object instanceof m&&e.push(n.object);return e}function $(a){let e=[];for(let n of a.statement)if(n instanceof p){if(n.predicate?.subject?.name!=="subClassOf")continue;n.object instanceof m&&e.push(n.object)}else if(n instanceof k){if(n.predicate?.subject?.name!=="subClassOf")continue;for(let t of n.object??[])t instanceof m&&e.push(t)}return e}function S(a,e){let n=[];for(let t of a){if(!(t instanceof j)||t.name!==e.name)continue;(t.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&n.push(t)}return n.sort((t,i)=>{let r=u((t.namespace||"").split("@")[1]??""),o=u((i.namespace||"").split("@")[1]??"");return!r||!o?0:b(o,r)}),n}function d(a,e,n,t){let i=a.predicate?.subject;return i?i.publisher===e&&i.package_===n&&i.name===t:!1}function y(a){let e=a.object.subject;return{publisher:e.publisher,package_:e.package_,name:e.name}}function E(a,e){return a.publisher===e.publisher&&a.package_===e.package_&&a.name===e.name}function _(a){return`${a.publisher}/${a.package_}/${a.name}`}export{F as a};
@@ -1 +1 @@
1
- import{a as j,b as x,f as _}from"./chunk-IUZZDC2U.js";import{d as l,e as u,f as b,g as $,h as s,j as h}from"./chunk-IOMNZBK4.js";import{c as S,d as O,g as I,h as T,i as g,j as v,k as L,l as q}from"./chunk-W6T7MOKY.js";var d=class{all=new Set;byPIdx=new Map;bySPIdx=new Map;byPOIdx=new Map;tripleList=[];add(e){let t=b(e);return this.all.has(t)?!1:(this.all.add(t),this.tripleList.push(e),P(this.byPIdx,e.p,e),P(this.bySPIdx,`${e.s}|${e.p}`,e),e.o.kind==="uri"&&P(this.byPOIdx,`${e.p}|${e.o.key}`,e),!0)}has(e){return this.all.has(b(e))}size(){return this.tripleList.length}snapshot(){return this.tripleList.slice()}byPredicate(e){let t=this.byPIdx.get(e);return t?t.slice():[]}bySubjectPredicate(e,t){let r=this.bySPIdx.get(`${e}|${t}`);return r?r.slice():[]}byPredicateObject(e,t){let r=this.byPOIdx.get(`${e}|${t}`);return r?r.slice():[]}subjectsWithPredicateObject(e,t){let r=this.byPOIdx.get(`${e}|${t}`);if(!r)return[];let n=new Set;for(let a of r)n.add(a.s);return Array.from(n)}uriObjectsOf(e,t){let r=this.bySPIdx.get(`${e}|${t}`);if(!r)return[];let n=new Set;for(let a of r)a.o.kind==="uri"&&n.add(a.o.key);return Array.from(n)}hasUri(e,t,r){return this.all.has(`${e}|${t}|u:${r}`)}hasTriple(e,t,r){return this.all.has(`${e}|${t}|${$(r)}`)}};function P(o,e,t){let r=o.get(e);r?r.push(t):o.set(e,[t])}var w={name:"rdfs2",apply(o,e){let t=!1;for(let r of o.byPredicate(e.domain)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;for(let i of o.byPredicate(n))o.add(s(i.s,e.type,a))&&(t=!0)}return t}},C={name:"rdfs3",apply(o,e){let t=!1;for(let r of o.byPredicate(e.range)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;for(let i of o.byPredicate(n))i.o.kind==="uri"&&o.add(s(i.o.key,e.type,a))&&(t=!0)}return t}},A={name:"rdfs5",apply(o,e){let t=!1;for(let r of o.byPredicate(e.subPropertyOf)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;for(let i of o.bySubjectPredicate(a,e.subPropertyOf))i.o.kind==="uri"&&o.add(s(n,e.subPropertyOf,i.o.key))&&(t=!0)}return t}},V={name:"rdfs7",apply(o,e){let t=!1;for(let r of o.byPredicate(e.subPropertyOf)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.byPredicate(n)){let f={s:i.s,p:a,o:i.o};o.add(f)&&(t=!0)}}return t}},W={name:"rdfs9",apply(o,e){let t=!1;for(let r of o.byPredicate(e.subClassOf)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.byPredicateObject(e.type,n))o.add(s(i.s,e.type,a))&&(t=!0)}return t}},F={name:"rdfs11",apply(o,e){let t=!1;for(let r of o.byPredicate(e.subClassOf)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;for(let i of o.bySubjectPredicate(a,e.subClassOf))i.o.kind==="uri"&&o.add(s(n,e.subClassOf,i.o.key))&&(t=!0)}return t}},k=[w,C,A,V,W,F];var N={name:"prp-trp",apply(o,e){let t=!1,r=o.subjectsWithPredicateObject(e.type,e.transitiveProperty);for(let n of r){let a=o.byPredicate(n);for(let i of a){if(i.o.kind!=="uri")continue;let f=i.o.key;for(let c of o.bySubjectPredicate(f,n))c.o.kind==="uri"&&i.s!==c.o.key&&o.add(s(i.s,n,c.o.key))&&(t=!0)}}return t}},D={name:"prp-symp",apply(o,e){let t=!1,r=o.subjectsWithPredicateObject(e.type,e.symmetricProperty);for(let n of r)for(let a of o.byPredicate(n))a.o.kind==="uri"&&o.add(s(a.o.key,n,a.s))&&(t=!0);return t}},z={name:"prp-inv1",apply(o,e){let t=!1;for(let r of o.byPredicate(e.inverseOf)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;for(let i of o.byPredicate(n))i.o.kind==="uri"&&o.add(s(i.o.key,a,i.s))&&(t=!0)}return t}},B={name:"prp-inv2",apply(o,e){let t=!1;for(let r of o.byPredicate(e.inverseOf)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;for(let i of o.byPredicate(a))i.o.kind==="uri"&&o.add(s(i.o.key,n,i.s))&&(t=!0)}return t}},M={name:"prp-eqp1",apply(o,e){let t=!1;for(let r of o.byPredicate(e.equivalentProperty)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.byPredicate(n))o.add({s:i.s,p:a,o:i.o})&&(t=!0)}return t}},G={name:"prp-eqp2",apply(o,e){let t=!1;for(let r of o.byPredicate(e.equivalentProperty)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.byPredicate(a))o.add({s:i.s,p:n,o:i.o})&&(t=!0)}return t}},H={name:"cax-eqc1",apply(o,e){let t=!1;for(let r of o.byPredicate(e.equivalentClass)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.byPredicateObject(e.type,n))o.add(s(i.s,e.type,a))&&(t=!0)}return t}},J={name:"cax-eqc2",apply(o,e){let t=!1;for(let r of o.byPredicate(e.equivalentClass)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.byPredicateObject(e.type,a))o.add(s(i.s,e.type,n))&&(t=!0)}return t}},Q={name:"eq-rep-s",apply(o,e){let t=!1;for(let r of o.byPredicate(e.sameAs)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a){for(let i of o.snapshot())i.s===n&&o.add({s:a,p:i.p,o:i.o})&&(t=!0);for(let i of o.snapshot())i.s===a&&o.add({s:n,p:i.p,o:i.o})&&(t=!0)}}return t}},X={name:"eq-rep-o",apply(o,e){let t=!1;for(let r of o.byPredicate(e.sameAs)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.snapshot())i.o.kind==="uri"&&(i.o.key===n?o.add(s(i.s,i.p,a))&&(t=!0):i.o.key===a&&o.add(s(i.s,i.p,n))&&(t=!0))}return t}},K=[N,D,z,B,M,G,H,J,Q,X];var y=class{constructor(e,t){this.store=e;this.vocabulary=t}store;vocabulary;getInstancesOfClass(e){let t=p(e);return this.store.subjectsWithPredicateObject(this.vocabulary.type,t)}getSubclasses(e){let t=p(e);return this.store.subjectsWithPredicateObject(this.vocabulary.subClassOf,t).filter(n=>n!==t)}getSuperclasses(e){let t=p(e);return this.store.uriObjectsOf(t,this.vocabulary.subClassOf).filter(r=>r!==t)}getTypesOfIndividual(e){return this.store.uriObjectsOf(p(e),this.vocabulary.type)}isInstanceOf(e,t){return this.store.hasUri(p(e),this.vocabulary.type,p(t))}triples(){return this.store.snapshot()}size(){return this.store.size()}};function p(o){return typeof o=="string"?o:u(o.publisher,o.package_,o.name)}var R=class{vocabulary;profile;maxIterations;constructor(e={}){this.vocabulary=e.vocabulary??new h,this.profile=e.profile??"owl-rl-classification",this.maxIterations=e.maxIterations??100}async reason(e){let t=new d,n=await new _().parseKanonaks(e),a=new U;for(let c of n)if(c instanceof S){let m=Y(c);if(!m)continue;for(let E of c.statement)this.emitStatement(m,E,t,a)}let i=[...k];this.profile==="owl-rl-classification"&&i.push(...K);let f=0;for(;f<this.maxIterations;){let c=!1;for(let m of i)m.apply(t,this.vocabulary)&&(c=!0);if(!c)break;f++}return new y(t,this.vocabulary)}emitStatement(e,t,r,n){let a=Z(t);if(a){if(t instanceof I){r.add({s:e,p:a,o:{kind:"literal",lexical:t.object,datatype:"string"}});return}if(t instanceof T){r.add({s:e,p:a,o:{kind:"literal",lexical:String(t.object),datatype:"number"}});return}if(t instanceof g){r.add({s:e,p:a,o:{kind:"literal",lexical:String(t.object),datatype:"boolean"}});return}if(t instanceof v){let i=l(t.object.subject);r.add(s(e,a,i));return}if(t instanceof L){let i=n.next();r.add({s:e,p:a,o:{kind:"blank",id:i}}),this.emitEmbedded(i,t.object,r,n);return}if(t instanceof q){for(let i of t.object??[])this.emitListItem(e,a,i,r,n);return}}}emitListItem(e,t,r,n,a){if(r instanceof O)n.add(s(e,t,l(r.subject)));else if(r instanceof j){let i=a.next();n.add({s:e,p:t,o:{kind:"blank",id:i}}),this.emitEmbedded(i,r,n,a)}else if(r instanceof x){let i=typeof r.value=="number"?"number":typeof r.value=="boolean"?"boolean":"string";n.add({s:e,p:t,o:{kind:"literal",lexical:String(r.value),datatype:i}})}}emitEmbedded(e,t,r,n){let a=`_:${e}`;for(let i of t.statement)this.emitStatement(a,i,r,n)}},U=class{counter=0;next(){return`b${this.counter++}`}};function Y(o){let e=o.namespace??"",t=e.indexOf("@"),r=t===-1?e:e.substring(0,t),n=r.indexOf("/");if(n===-1)return null;let a=r.substring(0,n),i=r.substring(n+1);return!a||!i||!o.name?null:u(a,i,o.name)}function Z(o){let e=o.predicate;return e?.subject?l(e.subject):null}export{d as a,k as b,K as c,y as d,R as e};
1
+ import{a as j,b as x,w as _}from"./chunk-WUAKDYY6.js";import{d as l,e as u,f as b,g as $,h as s,j as h}from"./chunk-XYEY6HUC.js";import{c as S,d as O,g as I,h as T,i as g,j as v,k as L,l as q}from"./chunk-T3JR2SV6.js";var d=class{all=new Set;byPIdx=new Map;bySPIdx=new Map;byPOIdx=new Map;tripleList=[];add(e){let t=b(e);return this.all.has(t)?!1:(this.all.add(t),this.tripleList.push(e),P(this.byPIdx,e.p,e),P(this.bySPIdx,`${e.s}|${e.p}`,e),e.o.kind==="uri"&&P(this.byPOIdx,`${e.p}|${e.o.key}`,e),!0)}has(e){return this.all.has(b(e))}size(){return this.tripleList.length}snapshot(){return this.tripleList.slice()}byPredicate(e){let t=this.byPIdx.get(e);return t?t.slice():[]}bySubjectPredicate(e,t){let r=this.bySPIdx.get(`${e}|${t}`);return r?r.slice():[]}byPredicateObject(e,t){let r=this.byPOIdx.get(`${e}|${t}`);return r?r.slice():[]}subjectsWithPredicateObject(e,t){let r=this.byPOIdx.get(`${e}|${t}`);if(!r)return[];let n=new Set;for(let a of r)n.add(a.s);return Array.from(n)}uriObjectsOf(e,t){let r=this.bySPIdx.get(`${e}|${t}`);if(!r)return[];let n=new Set;for(let a of r)a.o.kind==="uri"&&n.add(a.o.key);return Array.from(n)}hasUri(e,t,r){return this.all.has(`${e}|${t}|u:${r}`)}hasTriple(e,t,r){return this.all.has(`${e}|${t}|${$(r)}`)}};function P(o,e,t){let r=o.get(e);r?r.push(t):o.set(e,[t])}var w={name:"rdfs2",apply(o,e){let t=!1;for(let r of o.byPredicate(e.domain)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;for(let i of o.byPredicate(n))o.add(s(i.s,e.type,a))&&(t=!0)}return t}},C={name:"rdfs3",apply(o,e){let t=!1;for(let r of o.byPredicate(e.range)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;for(let i of o.byPredicate(n))i.o.kind==="uri"&&o.add(s(i.o.key,e.type,a))&&(t=!0)}return t}},A={name:"rdfs5",apply(o,e){let t=!1;for(let r of o.byPredicate(e.subPropertyOf)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;for(let i of o.bySubjectPredicate(a,e.subPropertyOf))i.o.kind==="uri"&&o.add(s(n,e.subPropertyOf,i.o.key))&&(t=!0)}return t}},V={name:"rdfs7",apply(o,e){let t=!1;for(let r of o.byPredicate(e.subPropertyOf)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.byPredicate(n)){let f={s:i.s,p:a,o:i.o};o.add(f)&&(t=!0)}}return t}},W={name:"rdfs9",apply(o,e){let t=!1;for(let r of o.byPredicate(e.subClassOf)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.byPredicateObject(e.type,n))o.add(s(i.s,e.type,a))&&(t=!0)}return t}},F={name:"rdfs11",apply(o,e){let t=!1;for(let r of o.byPredicate(e.subClassOf)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;for(let i of o.bySubjectPredicate(a,e.subClassOf))i.o.kind==="uri"&&o.add(s(n,e.subClassOf,i.o.key))&&(t=!0)}return t}},k=[w,C,A,V,W,F];var N={name:"prp-trp",apply(o,e){let t=!1,r=o.subjectsWithPredicateObject(e.type,e.transitiveProperty);for(let n of r){let a=o.byPredicate(n);for(let i of a){if(i.o.kind!=="uri")continue;let f=i.o.key;for(let c of o.bySubjectPredicate(f,n))c.o.kind==="uri"&&i.s!==c.o.key&&o.add(s(i.s,n,c.o.key))&&(t=!0)}}return t}},D={name:"prp-symp",apply(o,e){let t=!1,r=o.subjectsWithPredicateObject(e.type,e.symmetricProperty);for(let n of r)for(let a of o.byPredicate(n))a.o.kind==="uri"&&o.add(s(a.o.key,n,a.s))&&(t=!0);return t}},z={name:"prp-inv1",apply(o,e){let t=!1;for(let r of o.byPredicate(e.inverseOf)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;for(let i of o.byPredicate(n))i.o.kind==="uri"&&o.add(s(i.o.key,a,i.s))&&(t=!0)}return t}},B={name:"prp-inv2",apply(o,e){let t=!1;for(let r of o.byPredicate(e.inverseOf)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;for(let i of o.byPredicate(a))i.o.kind==="uri"&&o.add(s(i.o.key,n,i.s))&&(t=!0)}return t}},M={name:"prp-eqp1",apply(o,e){let t=!1;for(let r of o.byPredicate(e.equivalentProperty)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.byPredicate(n))o.add({s:i.s,p:a,o:i.o})&&(t=!0)}return t}},G={name:"prp-eqp2",apply(o,e){let t=!1;for(let r of o.byPredicate(e.equivalentProperty)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.byPredicate(a))o.add({s:i.s,p:n,o:i.o})&&(t=!0)}return t}},H={name:"cax-eqc1",apply(o,e){let t=!1;for(let r of o.byPredicate(e.equivalentClass)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.byPredicateObject(e.type,n))o.add(s(i.s,e.type,a))&&(t=!0)}return t}},J={name:"cax-eqc2",apply(o,e){let t=!1;for(let r of o.byPredicate(e.equivalentClass)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.byPredicateObject(e.type,a))o.add(s(i.s,e.type,n))&&(t=!0)}return t}},Q={name:"eq-rep-s",apply(o,e){let t=!1;for(let r of o.byPredicate(e.sameAs)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a){for(let i of o.snapshot())i.s===n&&o.add({s:a,p:i.p,o:i.o})&&(t=!0);for(let i of o.snapshot())i.s===a&&o.add({s:n,p:i.p,o:i.o})&&(t=!0)}}return t}},X={name:"eq-rep-o",apply(o,e){let t=!1;for(let r of o.byPredicate(e.sameAs)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.snapshot())i.o.kind==="uri"&&(i.o.key===n?o.add(s(i.s,i.p,a))&&(t=!0):i.o.key===a&&o.add(s(i.s,i.p,n))&&(t=!0))}return t}},K=[N,D,z,B,M,G,H,J,Q,X];var y=class{constructor(e,t){this.store=e;this.vocabulary=t}store;vocabulary;getInstancesOfClass(e){let t=p(e);return this.store.subjectsWithPredicateObject(this.vocabulary.type,t)}getSubclasses(e){let t=p(e);return this.store.subjectsWithPredicateObject(this.vocabulary.subClassOf,t).filter(n=>n!==t)}getSuperclasses(e){let t=p(e);return this.store.uriObjectsOf(t,this.vocabulary.subClassOf).filter(r=>r!==t)}getTypesOfIndividual(e){return this.store.uriObjectsOf(p(e),this.vocabulary.type)}isInstanceOf(e,t){return this.store.hasUri(p(e),this.vocabulary.type,p(t))}triples(){return this.store.snapshot()}size(){return this.store.size()}};function p(o){return typeof o=="string"?o:u(o.publisher,o.package_,o.name)}var R=class{vocabulary;profile;maxIterations;constructor(e={}){this.vocabulary=e.vocabulary??new h,this.profile=e.profile??"owl-rl-classification",this.maxIterations=e.maxIterations??100}async reason(e){let t=new d,n=await new _().parseKanonaks(e),a=new U;for(let c of n)if(c instanceof S){let m=Y(c);if(!m)continue;for(let E of c.statement)this.emitStatement(m,E,t,a)}let i=[...k];this.profile==="owl-rl-classification"&&i.push(...K);let f=0;for(;f<this.maxIterations;){let c=!1;for(let m of i)m.apply(t,this.vocabulary)&&(c=!0);if(!c)break;f++}return new y(t,this.vocabulary)}emitStatement(e,t,r,n){let a=Z(t);if(a){if(t instanceof I){r.add({s:e,p:a,o:{kind:"literal",lexical:t.object,datatype:"string"}});return}if(t instanceof T){r.add({s:e,p:a,o:{kind:"literal",lexical:String(t.object),datatype:"number"}});return}if(t instanceof g){r.add({s:e,p:a,o:{kind:"literal",lexical:String(t.object),datatype:"boolean"}});return}if(t instanceof v){let i=l(t.object.subject);r.add(s(e,a,i));return}if(t instanceof L){let i=n.next();r.add({s:e,p:a,o:{kind:"blank",id:i}}),this.emitEmbedded(i,t.object,r,n);return}if(t instanceof q){for(let i of t.object??[])this.emitListItem(e,a,i,r,n);return}}}emitListItem(e,t,r,n,a){if(r instanceof O)n.add(s(e,t,l(r.subject)));else if(r instanceof j){let i=a.next();n.add({s:e,p:t,o:{kind:"blank",id:i}}),this.emitEmbedded(i,r,n,a)}else if(r instanceof x){let i=typeof r.value=="number"?"number":typeof r.value=="boolean"?"boolean":"string";n.add({s:e,p:t,o:{kind:"literal",lexical:String(r.value),datatype:i}})}}emitEmbedded(e,t,r,n){let a=`_:${e}`;for(let i of t.statement)this.emitStatement(a,i,r,n)}},U=class{counter=0;next(){return`b${this.counter++}`}};function Y(o){let e=o.namespace??"",t=e.indexOf("@"),r=t===-1?e:e.substring(0,t),n=r.indexOf("/");if(n===-1)return null;let a=r.substring(0,n),i=r.substring(n+1);return!a||!i||!o.name?null:u(a,i,o.name)}function Z(o){let e=o.predicate;return e?.subject?l(e.subject):null}export{d as a,k as b,K as c,y as d,R as e};
@@ -1 +1 @@
1
- import{a as u,f as _,j as g,k as d,m as j}from"./chunk-XQS5LDSO.js";import{i as m}from"./chunk-IOMNZBK4.js";import{c as U,d as S}from"./chunk-W6T7MOKY.js";import{a as b}from"./chunk-FUUTGGJS.js";var $=new Set(["kanonak.org/core-rdf","kanonak.org/core-owl","kanonak.org/core-xsd","kanonak.org/core-kanonak"]);function i(r){let n=r;if(n.entity&&typeof n.entity=="object"){let e=n.entity.type;if(typeof e=="string"){let a={publisher:"",package_:"",name:e.includes(".")?e.substring(e.lastIndexOf(".")+1):e};return m(a),{publisher:a.publisher,package_:a.package_,name:a.name}}}if(n.statement&&Array.isArray(n.statement)){for(let e of n.statement)if(e.predicate?.subject?.name==="type"&&e.object?.subject){let t=e.object.subject,a={publisher:t.publisher??"",package_:t.package_??"",name:t.name};return m(a),{publisher:a.publisher,package_:a.package_,name:a.name}}}return null}function c(r,n){return $.has(`${r}/${n}`)}var y=class r{static getTypeUri(n){return i(n)}static isCoreOntologyType(n){return c(n.publisher,n.package_)}static isClassType(n){let e=i(n);return e?c(e.publisher,e.package_)&&e.name==="Class":!1}static isDatatypeType(n){let e=i(n);return e?c(e.publisher,e.package_)&&e.name==="Datatype":!1}static isDatatypePropertyType(n){let e=i(n);return e?c(e.publisher,e.package_)&&e.name==="DatatypeProperty":!1}static isObjectPropertyType(n){let e=i(n);return e?c(e.publisher,e.package_)&&e.name==="ObjectProperty":!1}static isAnnotationPropertyType(n){let e=i(n);return e?c(e.publisher,e.package_)&&e.name==="AnnotationProperty":!1}static isGenericPropertyType(n){let e=i(n);return e?c(e.publisher,e.package_)&&e.name==="Property":!1}static isAnyPropertyType(n){let e=i(n);return!e||!c(e.publisher,e.package_)?!1:e.name==="Property"||e.name==="DatatypeProperty"||e.name==="ObjectProperty"||e.name==="AnnotationProperty"}static isSchemaDefinitionType(n){let e=i(n);return!e||!c(e.publisher,e.package_)?!1:e.name==="Class"||e.name==="Property"||e.name==="DatatypeProperty"||e.name==="ObjectProperty"||e.name==="AnnotationProperty"||e.name==="Datatype"}static isInstanceOfKnownClass(n,e){if(r.isSchemaDefinitionType(n))return!1;let t=i(n);return t?e.has(t.name):!1}};function P(r){if(!r||r.trim().length===0)throw new Error("Kanonak address string cannot be null or empty");let n=r.trim(),e=n.split("/");if(e.length===1){let t=e[0];if(!t)throw new Error(`Invalid Kanonak address: "${r}". Expected publisher, publisher/package[@version], or publisher/package[@version]/name.`);if(t.includes("@"))throw new Error(`Invalid Kanonak address: "${r}". A bare publisher cannot carry an @version qualifier \u2014 versions belong to packages.`);return{kind:"publisher",publisher:t}}if(e.length===2){let[t,a]=e;if(!t||!a)throw new Error(`Invalid Kanonak address: "${r}". Expected publisher/package[@version].`);let o=a.indexOf("@");if(o===-1)return{kind:"package",publisher:t,package_:a};let s=a.substring(0,o),p=a.substring(o+1);if(!s||!p)throw new Error(`Invalid Kanonak address: "${r}". Expected publisher/package[@version].`);let f=A(p);return{kind:"package",publisher:t,package_:s,version:f}}return{kind:"resource",uri:b.parse(n)}}function G(r){switch(r.kind){case"publisher":return r.publisher;case"package":return r.version?`${r.publisher}/${r.package_}@${r.version.major}.${r.version.minor}.${r.version.patch}`:`${r.publisher}/${r.package_}`;case"resource":return r.uri.toString()}}function A(r){let n=r.split(".").map(Number);return w(n[0]||0,n[1]||0,n[2]||0)}function w(r,n,e){return{major:r,minor:n,patch:e,toString:()=>`${r}.${n}.${e}`,equals:t=>!t||typeof t!="object"?!1:t.major===r&&t.minor===n&&t.patch===e,getHashCode:()=>r<<20|n<<10|e,compareTo:t=>r!==t.major?r-t.major:n!==t.minor?n-t.minor:e-t.patch}}var k="kanonak.org",l="core-rdf",T={publisher:k,package_:l,name:"domain"},C={publisher:k,package_:l,name:"range"},R={publisher:k,package_:l,name:"subClassOf"},v={publisher:k,package_:l,name:"type"},x={publisher:k,package_:l,name:"label"},D={publisher:k,package_:l,name:"comment"},O=new b(k,l,"Resource"),I=r=>r;function V(r){try{let n=P(`${r.namespace}/${r.name}`);return n.kind==="resource"?n.uri:void 0}catch{return}}function h(r,n){let e=d(r,n);if(e)return[e];let t=[];for(let a of j(r,n))a instanceof S&&t.push(a.subject);return t}function N(r,n){let e=[],t=new Set,a=[new b(n.publisher,n.package_,n.name)];for(;a.length>0;){let o=a.shift(),s=u(o);if(t.has(s))continue;t.add(s),e.push(o);let p=_(r,o);p&&a.push(...h(p,R))}return e}function B(r,n){let e=new Set([u(O)]);for(let t of N(r,n))e.add(u(t));return e}function F(r,n){let e=B(r,n),t=[],a=new Set;for(let o of r){if(!(o instanceof U))continue;let s=I(o);if(!y.isAnyPropertyType(s))continue;let p=h(o,T);if(!p.some(E=>e.has(u(E))))continue;let f=V(o);if(!f)continue;let K=u(f);a.has(K)||(a.add(K),t.push({uri:f,label:g(o,x),comment:g(o,D),kind:y.isObjectPropertyType(s)?"object":y.isDatatypePropertyType(s)?"datatype":"other",range:d(o,C),domains:p}))}return t}function Z(r,n,e){let t=F(r,n).find(a=>u(a.uri)===u(e));return t?{ok:!0,descriptor:t}:{ok:!1,message:`Property ${e.publisher}/${e.package_}/${e.name} is not in scope for ${n.publisher}/${n.package_}/${n.name}.`}}function ee(r){return h(r,v)}export{y as a,P as b,G as c,V as d,N as e,F as f,Z as g,ee as h};
1
+ import{a as u,f as _,j as g,k as d,m as j}from"./chunk-PBNVHBS3.js";import{i as m}from"./chunk-XYEY6HUC.js";import{c as U,d as S}from"./chunk-T3JR2SV6.js";import{a as b}from"./chunk-FUUTGGJS.js";var $=new Set(["kanonak.org/core-rdf","kanonak.org/core-owl","kanonak.org/core-xsd","kanonak.org/core-kanonak"]);function i(r){let n=r;if(n.entity&&typeof n.entity=="object"){let e=n.entity.type;if(typeof e=="string"){let a={publisher:"",package_:"",name:e.includes(".")?e.substring(e.lastIndexOf(".")+1):e};return m(a),{publisher:a.publisher,package_:a.package_,name:a.name}}}if(n.statement&&Array.isArray(n.statement)){for(let e of n.statement)if(e.predicate?.subject?.name==="type"&&e.object?.subject){let t=e.object.subject,a={publisher:t.publisher??"",package_:t.package_??"",name:t.name};return m(a),{publisher:a.publisher,package_:a.package_,name:a.name}}}return null}function c(r,n){return $.has(`${r}/${n}`)}var y=class r{static getTypeUri(n){return i(n)}static isCoreOntologyType(n){return c(n.publisher,n.package_)}static isClassType(n){let e=i(n);return e?c(e.publisher,e.package_)&&e.name==="Class":!1}static isDatatypeType(n){let e=i(n);return e?c(e.publisher,e.package_)&&e.name==="Datatype":!1}static isDatatypePropertyType(n){let e=i(n);return e?c(e.publisher,e.package_)&&e.name==="DatatypeProperty":!1}static isObjectPropertyType(n){let e=i(n);return e?c(e.publisher,e.package_)&&e.name==="ObjectProperty":!1}static isAnnotationPropertyType(n){let e=i(n);return e?c(e.publisher,e.package_)&&e.name==="AnnotationProperty":!1}static isGenericPropertyType(n){let e=i(n);return e?c(e.publisher,e.package_)&&e.name==="Property":!1}static isAnyPropertyType(n){let e=i(n);return!e||!c(e.publisher,e.package_)?!1:e.name==="Property"||e.name==="DatatypeProperty"||e.name==="ObjectProperty"||e.name==="AnnotationProperty"}static isSchemaDefinitionType(n){let e=i(n);return!e||!c(e.publisher,e.package_)?!1:e.name==="Class"||e.name==="Property"||e.name==="DatatypeProperty"||e.name==="ObjectProperty"||e.name==="AnnotationProperty"||e.name==="Datatype"}static isInstanceOfKnownClass(n,e){if(r.isSchemaDefinitionType(n))return!1;let t=i(n);return t?e.has(t.name):!1}};function P(r){if(!r||r.trim().length===0)throw new Error("Kanonak address string cannot be null or empty");let n=r.trim(),e=n.split("/");if(e.length===1){let t=e[0];if(!t)throw new Error(`Invalid Kanonak address: "${r}". Expected publisher, publisher/package[@version], or publisher/package[@version]/name.`);if(t.includes("@"))throw new Error(`Invalid Kanonak address: "${r}". A bare publisher cannot carry an @version qualifier \u2014 versions belong to packages.`);return{kind:"publisher",publisher:t}}if(e.length===2){let[t,a]=e;if(!t||!a)throw new Error(`Invalid Kanonak address: "${r}". Expected publisher/package[@version].`);let o=a.indexOf("@");if(o===-1)return{kind:"package",publisher:t,package_:a};let s=a.substring(0,o),p=a.substring(o+1);if(!s||!p)throw new Error(`Invalid Kanonak address: "${r}". Expected publisher/package[@version].`);let f=A(p);return{kind:"package",publisher:t,package_:s,version:f}}return{kind:"resource",uri:b.parse(n)}}function G(r){switch(r.kind){case"publisher":return r.publisher;case"package":return r.version?`${r.publisher}/${r.package_}@${r.version.major}.${r.version.minor}.${r.version.patch}`:`${r.publisher}/${r.package_}`;case"resource":return r.uri.toString()}}function A(r){let n=r.split(".").map(Number);return w(n[0]||0,n[1]||0,n[2]||0)}function w(r,n,e){return{major:r,minor:n,patch:e,toString:()=>`${r}.${n}.${e}`,equals:t=>!t||typeof t!="object"?!1:t.major===r&&t.minor===n&&t.patch===e,getHashCode:()=>r<<20|n<<10|e,compareTo:t=>r!==t.major?r-t.major:n!==t.minor?n-t.minor:e-t.patch}}var k="kanonak.org",l="core-rdf",T={publisher:k,package_:l,name:"domain"},C={publisher:k,package_:l,name:"range"},R={publisher:k,package_:l,name:"subClassOf"},v={publisher:k,package_:l,name:"type"},x={publisher:k,package_:l,name:"label"},D={publisher:k,package_:l,name:"comment"},O=new b(k,l,"Resource"),I=r=>r;function V(r){try{let n=P(`${r.namespace}/${r.name}`);return n.kind==="resource"?n.uri:void 0}catch{return}}function h(r,n){let e=d(r,n);if(e)return[e];let t=[];for(let a of j(r,n))a instanceof S&&t.push(a.subject);return t}function N(r,n){let e=[],t=new Set,a=[new b(n.publisher,n.package_,n.name)];for(;a.length>0;){let o=a.shift(),s=u(o);if(t.has(s))continue;t.add(s),e.push(o);let p=_(r,o);p&&a.push(...h(p,R))}return e}function B(r,n){let e=new Set([u(O)]);for(let t of N(r,n))e.add(u(t));return e}function F(r,n){let e=B(r,n),t=[],a=new Set;for(let o of r){if(!(o instanceof U))continue;let s=I(o);if(!y.isAnyPropertyType(s))continue;let p=h(o,T);if(!p.some(E=>e.has(u(E))))continue;let f=V(o);if(!f)continue;let K=u(f);a.has(K)||(a.add(K),t.push({uri:f,label:g(o,x),comment:g(o,D),kind:y.isObjectPropertyType(s)?"object":y.isDatatypePropertyType(s)?"datatype":"other",range:d(o,C),domains:p}))}return t}function Z(r,n,e){let t=F(r,n).find(a=>u(a.uri)===u(e));return t?{ok:!0,descriptor:t}:{ok:!1,message:`Property ${e.publisher}/${e.package_}/${e.name} is not in scope for ${n.publisher}/${n.package_}/${n.name}.`}}function ee(r){return h(r,v)}export{y as a,P as b,G as c,V as d,N as e,F as f,Z as g,ee as h};
@@ -1 +1 @@
1
- import{b as y,c as s,g as l,h as g,i as b,j as u,k,l as K}from"./chunk-W6T7MOKY.js";import{c as d,g as m}from"./chunk-2ACBWC7K.js";function S(t){return`${t.publisher}/${t.package_}/${t.name}`}function f(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}function U(t){let e=t.version;return e&&typeof e.major=="number"?`https://${t.publisher}/${t.package_}/${e.major}.${e.minor}.${e.patch}/${t.name}`:`https://${t.publisher}/${t.package_}/${t.name}`}function h(t,e){if(!(t instanceof y))return!1;for(let n of t.statement)if(n.predicate?.subject?.name==="type"&&n instanceof u){let r=n.object;if(f(r.subject,e))return!0}return!1}function j(t,e){let n=[];for(let o of t)o instanceof s&&h(o,e)&&n.push(o);return n}function E(t,e){let n=e.version,o=n&&typeof n.major=="number"?`${e.publisher}/${e.package_}@${n.major}.${n.minor}.${n.patch}`:void 0;for(let r of t){if(!(r instanceof s)||r.name!==e.name)continue;let a=r.namespace||"";if(o!==void 0){if(a===o)return r}else if(a.startsWith(`${e.publisher}/${e.package_}@`))return r}}function $(t,e){let n=[];for(let o of t){if(!(o instanceof s)||o.name!==e.name)continue;(o.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&n.push(o)}return n.sort((o,r)=>{let a=m((o.namespace||"").split("@")[1]??""),c=m((r.namespace||"").split("@")[1]??"");return a?c?d(c,a):-1:c?1:0}),n}function i(t,e){for(let n of t.statement){let o=n.predicate;if(o?.subject&&f(o.subject,e))return n}}function x(t,e){return i(t,e)!==void 0}function D(t,e){let n=i(t,e);if(n&&(n instanceof l||n instanceof g||n instanceof b))return n.object}function A(t,e){let n=D(t,e);return typeof n=="string"?n:void 0}function R(t,e){let n=i(t,e);if(n instanceof u)return n.object.subject}function P(t,e){let n=i(t,e);if(n instanceof k)return n.object}function v(t,e){let n=i(t,e);return n instanceof K?n.object??[]:[]}var p=class{constructor(e,n){this.doc=e;this.broader=n}doc;broader;async getAllDocumentsAsync(){return[this.doc]}async getDocumentAsync(e){return this.broader.getDocumentAsync(e)}async getDocumentsByNamespaceAsync(e,n){return this.broader.getDocumentsByNamespaceAsync(e,n)}async getHighestCompatibleVersionAsync(e,n){return this.broader.getHighestCompatibleVersionAsync(e,n)}async saveDocumentAsync(){throw new Error("SingleDocumentRepository is read-only")}async deleteDocumentAsync(){throw new Error("SingleDocumentRepository is read-only")}async clearNamespaceAsync(){throw new Error("SingleDocumentRepository is read-only")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(e){return this.broader.getDocumentContentAsync(e)}async getDocumentUriAsync(e){return this.broader.getDocumentUriAsync(e)}};export{S as a,f as b,U as c,h as d,j as e,E as f,$ as g,x as h,D as i,A as j,R as k,P as l,v as m,p as n};
1
+ import{b as y,c as s,g as l,h as g,i as b,j as u,k,l as K}from"./chunk-T3JR2SV6.js";import{c as d,g as m}from"./chunk-2ACBWC7K.js";function S(t){return`${t.publisher}/${t.package_}/${t.name}`}function f(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}function U(t){let e=t.version;return e&&typeof e.major=="number"?`https://${t.publisher}/${t.package_}/${e.major}.${e.minor}.${e.patch}/${t.name}`:`https://${t.publisher}/${t.package_}/${t.name}`}function h(t,e){if(!(t instanceof y))return!1;for(let n of t.statement)if(n.predicate?.subject?.name==="type"&&n instanceof u){let r=n.object;if(f(r.subject,e))return!0}return!1}function j(t,e){let n=[];for(let o of t)o instanceof s&&h(o,e)&&n.push(o);return n}function E(t,e){let n=e.version,o=n&&typeof n.major=="number"?`${e.publisher}/${e.package_}@${n.major}.${n.minor}.${n.patch}`:void 0;for(let r of t){if(!(r instanceof s)||r.name!==e.name)continue;let a=r.namespace||"";if(o!==void 0){if(a===o)return r}else if(a.startsWith(`${e.publisher}/${e.package_}@`))return r}}function $(t,e){let n=[];for(let o of t){if(!(o instanceof s)||o.name!==e.name)continue;(o.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&n.push(o)}return n.sort((o,r)=>{let a=m((o.namespace||"").split("@")[1]??""),c=m((r.namespace||"").split("@")[1]??"");return a?c?d(c,a):-1:c?1:0}),n}function i(t,e){for(let n of t.statement){let o=n.predicate;if(o?.subject&&f(o.subject,e))return n}}function x(t,e){return i(t,e)!==void 0}function D(t,e){let n=i(t,e);if(n&&(n instanceof l||n instanceof g||n instanceof b))return n.object}function A(t,e){let n=D(t,e);return typeof n=="string"?n:void 0}function R(t,e){let n=i(t,e);if(n instanceof u)return n.object.subject}function P(t,e){let n=i(t,e);if(n instanceof k)return n.object}function v(t,e){let n=i(t,e);return n instanceof K?n.object??[]:[]}var p=class{constructor(e,n){this.doc=e;this.broader=n}doc;broader;async getAllDocumentsAsync(){return[this.doc]}async getDocumentAsync(e){return this.broader.getDocumentAsync(e)}async getDocumentsByNamespaceAsync(e,n){return this.broader.getDocumentsByNamespaceAsync(e,n)}async getHighestCompatibleVersionAsync(e,n){return this.broader.getHighestCompatibleVersionAsync(e,n)}async saveDocumentAsync(){throw new Error("SingleDocumentRepository is read-only")}async deleteDocumentAsync(){throw new Error("SingleDocumentRepository is read-only")}async clearNamespaceAsync(){throw new Error("SingleDocumentRepository is read-only")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(e){return this.broader.getDocumentContentAsync(e)}async getDocumentUriAsync(e){return this.broader.getDocumentUriAsync(e)}};export{S as a,f as b,U as c,h as d,j as e,E as f,$ as g,x as h,D as i,A as j,R as k,P as l,v as m,p as n};
@@ -0,0 +1 @@
1
+ import{a as c}from"./chunk-FUUTGGJS.js";var m=class{};var p=class extends m{statement=[]};var i=class extends p{namespace;name;icon};var a=class e extends m{subject;static parse(o){let n=new e;return n.subject=c.parse(o),n}};var r=class{predicate;object};var s=class extends r{carrier;lexical};var f=class e extends s{static parse(o,n){let t=new e;return t.predicate=a.parse(o),t.object=n,t}};var k=class e extends s{static parse(o,n){let t=new e;return t.predicate=a.parse(o),t.object=n,t}};var x=class extends s{};var d=class e extends r{static parse(o,n){let t=new e;return t.predicate=a.parse(o),t.object=a.parse(n),t}};var l=class extends r{};var b=class extends r{};export{m as a,p as b,i as c,a as d,r as e,s as f,f as g,k as h,x as i,d as j,l as k,b as l};
@@ -0,0 +1,84 @@
1
+ import{d as _}from"./chunk-SHDHMKMJ.js";import{a as D,b as je,c as ze,u as Ge,w as A}from"./chunk-WUAKDYY6.js";import{a as Be}from"./chunk-ZYAABYDS.js";import{a as B,d as W,e as Ze,f as Je,g as T,h as Qe}from"./chunk-NC3FSY3R.js";import{a as C,d as E,f as x,h as Ne,i as w,j as L,k as V,l as O,m as S,n as M}from"./chunk-PBNVHBS3.js";import{a as N,b as U,c as Ye}from"./chunk-XYEY6HUC.js";import{c as I,d as H,k as Xe,l as qe}from"./chunk-T3JR2SV6.js";import{a as Fe}from"./chunk-FUUTGGJS.js";import{e as P}from"./chunk-2ACBWC7K.js";var q=class{isValid=!1;errors=[];warnings=[];get totalIssues(){return this.errors.length+this.warnings.length}};var b=(n=>(n.Warning="Warning",n.Error="Error",n))(b||{});var g=class{ruleType="";severity="Error";lineNumber;column;entityName;propertyName;propertyPath;message="";suggestion;actualValue;expectedValue;toString(){let e="";return this.lineNumber!==void 0&&(e+=`Line ${this.lineNumber}: `),this.entityName&&(e+=`[${this.entityName}] `),e+=this.message,e}};var _e=class y{resolvedDocuments=[];currentEntityPath;withPath(e){let n=new y;return n.resolvedDocuments=this.resolvedDocuments,n.currentEntityPath=e,n}};var Oe=class{constructor(e){this.underlying=e;this.repository=new Le(e)}underlying;repository;kanonaksPromise=null;importClosureCache=new Map;classDeclarationsCache=new Map;propertyNamesCache=new Map;allDocumentsPromise=null;getKanonaks(){return this.kanonaksPromise||(this.kanonaksPromise=new A().parseKanonaks(this.underlying)),this.kanonaksPromise}async getImportClosure(e){let n=this.importClosureCache.get(e);return n||(n=this.computeImportClosure(e),this.importClosureCache.set(e,n),n)}async getClassDeclarations(e){let n=this.classDeclarationsCache.get(e);return n||(n=this.computeClassDeclarations(e),this.classDeclarationsCache.set(e,n),n)}async getPropertyNames(e){let n=this.propertyNamesCache.get(e);return n||(n=this.computePropertyNames(e),this.propertyNamesCache.set(e,n),n)}getAllDocuments(){return this.allDocumentsPromise||(this.allDocumentsPromise=this.underlying.getAllDocumentsAsync()),this.allDocumentsPromise}async computeImportClosure(e){let n=new Set([e]),t=[e],o=await this.buildDocsByIdIndex();for(;t.length>0;){let s=t.shift(),r=o.get(s);if(r?.metadata.imports)for(let[i,a]of Object.entries(r.metadata.imports))for(let c of a){let p=await this.repository.getHighestCompatibleVersionAsync(i,c);if(!p)continue;let l=Ue(p);!l||n.has(l)||(n.add(l),t.push(l))}}return n}async buildDocsByIdIndex(){let e=await this.getAllDocuments(),n=new Map;for(let t of e){let o=Ue(t);o&&n.set(o,t)}return n}async computeClassDeclarations(e){let n=await this.findDocById(e),t=new Map;if(!n)return t;for(let[o,s]of Object.entries(n.body)){if(!et(s))continue;let r=s,i=tt(r,"type");if(i==="Class"||i?.endsWith(".Class")){let a=ft(r);t.set(o,a)}}return t}async computePropertyNames(e){let n=await this.findDocById(e),t=new Set;if(!n)return t;for(let[o,s]of Object.entries(n.body)){if(!et(s))continue;let i=tt(s,"type");(i==="ObjectProperty"||i?.endsWith(".ObjectProperty")||i==="DatatypeProperty"||i?.endsWith(".DatatypeProperty")||i==="AnnotationProperty"||i?.endsWith(".AnnotationProperty")||i==="Property"||i?.endsWith(".Property"))&&t.add(o)}return t}async findDocById(e){let n=await this.getAllDocuments();for(let t of n)if(Ue(t)===e)return t}};function Ue(y){let e=y.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}function et(y){return typeof y=="object"&&y!==null&&!Array.isArray(y)}function tt(y,e){if(e in y)return nt(y[e]);for(let n of Object.keys(y))if(n.endsWith(`.${e}`))return nt(y[n])}function nt(y){return Array.isArray(y)?y.length>0?String(y[0]):void 0:y==null?void 0:String(y)}function ft(y){let e=y.subClassOf;if(e===void 0){for(let n of Object.keys(y))if(n.endsWith(".subClassOf")){e=y[n];break}}return N(e)}var Le=class{constructor(e){this.inner=e}inner;highestVersionCache=new Map;byNamespaceCache=new Map;getAllDocumentsAsync(){return this.inner.getAllDocumentsAsync()}getDocumentAsync(e){return this.inner.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,n){let t=`${e}/${n}`,o=this.byNamespaceCache.get(t);return o||(o=this.inner.getDocumentsByNamespaceAsync(e,n),this.byNamespaceCache.set(t,o),o)}getHighestCompatibleVersionAsync(e,n){let t=n.version,o=t?`${t.major}.${t.minor}.${t.patch}`:"",s=`${e}/${n.packageName}@${n.versionOperator}:${o}`,r=this.highestVersionCache.get(s);return r||(r=this.inner.getHighestCompatibleVersionAsync(e,n),this.highestVersionCache.set(s,r),r)}saveDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}deleteDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}clearNamespaceAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}getAllDocumentReferencesAsync(){return this.inner.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.inner.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.inner.getDocumentUriAsync(e)}};var z=class y{static NAMESPACE_PREFIX_PATTERN=/^(rdfs|xsd|owl|rdf|dc|foaf|skos|dct|dcterms|geo|time|prov|schema|og|dbo):/i;ruleName="NamespacePrefix";validate(e){let n=[];for(let[t,o]of Object.entries(e.body))o&&typeof o=="object"&&!Array.isArray(o)&&this.validateEntity(t,o,n);return n}validateEntity(e,n,t){for(let[o,s]of Object.entries(n)){let r=s?.toString()??"";if(r&&y.NAMESPACE_PREFIX_PATTERN.test(r)){let i=this.getSuggestionForPrefixedValue(r),a=e.split(".")[0],c=new g;c.ruleType=this.ruleName,c.severity="Error",c.entityName=a,c.propertyName=e,c.actualValue=o,c.expectedValue=i,c.message=`Invalid namespace prefix '${r}'. Use '${i}' without prefix.`,c.suggestion="Kanonak YAML uses simple type names. Namespace resolution is handled through imports.",t.push(c)}s&&typeof s=="object"&&!Array.isArray(s)&&this.validateEntity(`${e}.${o}`,s,t)}}getSuggestionForPrefixedValue(e){let n=e.toLowerCase();if(n==="rdfs:class"||n==="owl:class")return"Class";if(n==="rdfs:property"||n==="rdf:property")return"DatatypeProperty or ObjectProperty";if(n.startsWith("xsd:"))return e.substring(4);let t=e.indexOf(":");return t>=0?e.substring(t+1):e}};var Y=class y{static RESERVED_WORDS=new Set(["kanonak","imports","namespace","type","label","comment","subclassof","domain","range","required","functional"]);static VALID_PROPERTIES=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","required","functional","inverseOf","transitive","symmetric","inverseFunctional"]);static VALID_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_AUGMENTATION_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*\.[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_PROPERTY_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_.]*$/;ruleName="ResourceNaming";validate(e){let n=[],t=e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-");for(let[o,s]of Object.entries(e.body)){let r=y.VALID_AUGMENTATION_PATTERN.test(o);if(!r&&!t&&y.RESERVED_WORDS.has(o.toLowerCase())){let i=new g;i.ruleType=this.ruleName,i.severity="Error",i.entityName=o,i.message=`Entity name '${o}' is a reserved word and cannot be used.`,i.suggestion="Choose a different name that doesn't conflict with Kanonak reserved words.",n.push(i);continue}if(!r&&!y.VALID_NAME_PATTERN.test(o)){let i;/^\d/.test(o)?i="Entity names must start with a letter, not a number.":o.includes(" ")?i="Entity names cannot contain spaces. Use camelCase or underscores instead.":i="Entity names must start with a letter and contain only letters, numbers, and underscores.";let a=new g;a.ruleType=this.ruleName,a.severity="Error",a.entityName=o,a.message=`Invalid entity name '${o}'. ${i}`,a.suggestion=i,n.push(a)}s&&typeof s=="object"&&!Array.isArray(s)&&this.validatePropertyNames(o,s,n)}return n}validatePropertyNames(e,n,t){for(let o of Object.keys(n))if(!y.VALID_PROPERTIES.has(o)&&!y.VALID_PROPERTY_NAME_PATTERN.test(o)){let s=new g;s.ruleType=this.ruleName,s.severity="Warning",s.entityName=e,s.propertyName=o,s.message=`Property name '${o}' in entity '${e}' doesn't follow naming conventions.`,s.suggestion="Property names should start with a letter and contain only letters, numbers, and underscores.",t.push(s)}}};var G=class y{static XSD_TYPES=new Set(["string","integer","int","long","short","byte","decimal","float","double","boolean","bool","datetime","date","time","duration","anyuri","anysimpletype","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte","base64binary","hexbinary"]);ruleName="PropertyTypeSpecificity";validate(e){let n=[];if(e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-"))return n;let t=this.isPropertyDefinedAsClass(e);for(let[o,s]of Object.entries(e.body))if(s&&typeof s=="object"&&!Array.isArray(s)){let r=s,i=r.type;if(i){let a=[];if(Array.isArray(i))for(let c of i){let p=c?.toString();p&&p==="Property"&&!t&&a.push(p)}else{let c=i?.toString();c&&c==="Property"&&!t&&a.push(c)}for(let c of a){let p=this.getPropertyValue(r,"range"),l=this.determinePropertyType(p),m=new g;m.ruleType=this.ruleName,m.severity="Error",m.entityName=o,m.propertyName="type",m.actualValue=c,m.expectedValue=l,m.message=`Invalid property type '${c}'. Use '${l}' instead.`,m.suggestion="Properties should specify their type: DatatypeProperty for data values, ObjectProperty for relationships.",n.push(m)}}}return n}determinePropertyType(e){return!e||e.trim().length===0?"DatatypeProperty or ObjectProperty":y.XSD_TYPES.has(e.toLowerCase())?"DatatypeProperty":/^[A-Z]/.test(e)?"ObjectProperty":"DatatypeProperty or ObjectProperty"}getPropertyValue(e,n){let t=e[n];return t?t.toString():null}isPropertyDefinedAsClass(e){let n=e.body.Property;if(n&&typeof n=="object"&&!Array.isArray(n)){let o=n.type;if(o){let s=o.toString();return s==="Class"||s.endsWith(".Class")}}return!1}};var Z=class{get ruleName(){return"SubjectKanonakTypeRequired"}validate(e){let n=[];for(let[t,o]of Object.entries(e.body)){if(typeof o!="object"||o===null||Array.isArray(o)||t.includes("."))continue;let s=o,r="type"in s,i=s.type?.toString().trim();if(!r||!i){let a=new g;a.ruleType=this.ruleName,a.severity="Error",a.entityName=t,a.propertyName="type",a.message=`Subject Kanonak '${t}' must have a 'type' property.`,a.suggestion=`Add a type statement like:
2
+ type: Scene
3
+
4
+ Only embedded objects can infer type from their parent property's range. Subject Kanonaks (top-level entities) must explicitly declare their type.`,a.expectedValue="A valid class name (Scene, Character, Story, etc.)",n.push(a)}}return n}};var J=class{get ruleName(){return"EmbeddedKanonakType"}async validateAsync(e,n){let t=[],o=new U(n),s=await this.buildPropertyRangeMap(e,o);for(let[r,i]of Object.entries(e.body))typeof i=="object"&&i!==null&&!Array.isArray(i)&&await this.checkEmbeddedTypes(r,i,void 0,s,o,e,t,0);return t}pickRange(e,n,t){if(e.length===0)return;if(e.length===1)return e[0].range;let o=n.indexOf(".");if(o>0){let s=n.substring(0,o),r=e.find(i=>i.declaringAlias===s);if(r)return r.range}if(t){let s=this.localName(t),r=e.find(i=>this.localName(i.domain)===s);if(r)return r.range}return e[0].range}async checkEmbeddedTypes(e,n,t,o,s,r,i,a){if(a>0){let p=n.type;if(p!=null){let l=await this.validateEmbeddedType(e,String(p),t,s,r);l&&i.push(l)}}let c=n.type!==void 0&&n.type!==null?String(n.type):void 0;for(let[p,l]of Object.entries(n)){let m=this.localName(p),u=o.get(m),d=(u!==void 0?this.pickRange(u,p,c):void 0)??t;if(typeof l=="object"&&l!==null)if(Array.isArray(l))for(let k=0;k<l.length;k++){let h=l[k];typeof h=="object"&&h!==null&&!Array.isArray(h)&&await this.checkEmbeddedTypes(`${e}.${p}[${k}]`,h,d,o,s,r,i,a+1)}else await this.checkEmbeddedTypes(`${e}.${p}`,l,d,o,s,r,i,a+1)}}async validateEmbeddedType(e,n,t,o,s){if(n.length===0||!t)return null;let r=this.localName(n),i=this.localName(t);if(i==="Resource"||i==="Class")return null;let a=e.split(".")[0];if(r===i){let p=new g;return p.ruleType=this.ruleName,p.severity="Warning",p.entityName=a,p.propertyName=e,p.actualValue=n,p.expectedValue=t,p.message=`Embedded object at '${e}' declares 'type: ${n}', which equals the parent property's range '${t}'. The declaration is redundant \u2014 the type is already inferred from the property's range.`,p.suggestion=`Remove the 'type: ${n}' line, or keep it if explicitness is preferred over concision.`,p}if(await o.isSubclassOfAsync(n,t,s)||(r!==n||i!==t)&&await o.isSubclassOfAsync(r,i,s))return null;let c=new g;return c.ruleType=this.ruleName,c.severity="Error",c.entityName=a,c.propertyName=e,c.actualValue=n,c.expectedValue=t,c.message=`Embedded object at '${e}' has 'type: ${n}', which is not a subclass of the parent property's range '${t}'.`,c.suggestion=`Either remove the 'type: ${n}' line (so the type is inferred from the property's range '${t}'), or add 'subClassOf: ${t}' to the '${n}' class definition so the relationship holds.`,c}localName(e){let n=e.lastIndexOf(".");return n<0||n===e.length-1?e:e.substring(n+1)}async buildPropertyRangeMap(e,n){let t=new Map,o=await n.buildEntityIndexAsync(e),s=new Map;for(let[r,i]of o){let a=i.entity.type;if(a==null)continue;let c=String(a),p=this.localName(c);if(!(p==="Property"||p==="DatatypeProperty"||p==="ObjectProperty"||p==="AnnotationProperty"))continue;let m=i.entity.range;if(m==null)continue;let u=String(m);if(u.length===0)continue;let f=i.entity.domain,d=f!=null?String(f):"",k=i.uri.toString(),h=s.get(k),v=r.includes(".");(!h||v&&!h.entityName.includes("."))&&s.set(k,{entityName:r,domain:d,range:u})}for(let r of s.values()){let i=this.localName(r.entityName),a=r.entityName.indexOf("."),c=a>0?r.entityName.substring(0,a):void 0,p=t.get(i)??[];p.push({domain:r.domain,range:r.range,declaringAlias:c}),t.set(i,p)}return t}};import{VersionOperator as Te}from"@kanonak-protocol/types/document/models/enums";var Q=class{ruleName="ImportExistence";async validateAsync(e,n){let t=[];if(!e.metadata?.imports)return t;let o=await n.getAllDocumentsAsync();for(let[s,r]of Object.entries(e.metadata.imports))for(let i of r)if(!await n.getHighestCompatibleVersionAsync(s,i)){let c=await this.determineImportErrorAsync(n,s,i,o),p=new g;p.ruleType=this.ruleName,p.severity="Error",p.message=c.message,p.suggestion=c.suggestion,p.entityName=`Import: ${s}/${i.packageName}`,p.actualValue=i.toString(),p.expectedValue=c.expectedValue,t.push(p)}return t}async determineImportErrorAsync(e,n,t,o){let s=await e.getDocumentsByNamespaceAsync(n,t.packageName);if(s.length===0){let c=o.filter(u=>u.metadata.namespace_?.publisher===n).map(u=>u.metadata.namespace_.package_).filter((u,f,d)=>d.indexOf(u)===f),p=this.findSimilarPackages(t.packageName,c),l=`Import '${n}/${t.package_}' not found - package does not exist`,m=p.length>0?`Did you mean: ${p.slice(0,3).join(", ")}?`:c.length>0?`Available packages in ${n}: ${c.slice(0,5).join(", ")}`:`No packages found for publisher '${n}'. Verify the publisher name is correct.`;return{message:l,suggestion:m,expectedValue:"Existing package"}}let i=s.filter(c=>c.metadata.namespace_?.version).map(c=>c.metadata.namespace_.version.toString()).sort().join(", "),a=this.getAcceptableVersionRange(t);return{message:`Import '${n}/${t.toString()}' version mismatch - no compatible version found`,suggestion:`Available versions: ${i}. Required: ${a}`,expectedValue:a}}getAcceptableVersionRange(e){switch(e.versionOperator){case Te.Exact:return`exactly ${e.version.major}.${e.version.minor}.${e.version.patch}`;case Te.Compatible:return`${e.version.major}.${e.version.minor}.${e.version.patch} to ${e.version.major}.${e.version.minor}.x`;case Te.Major:return e.version.major===0?`0.${e.version.minor}.x`:`${e.version.major}.x.x`;case Te.Any:return`any version >= ${e.version.major}.${e.version.minor}.${e.version.patch}`;default:return e.toString()}}findSimilarPackages(e,n){if(n.length===0)return[];let t=n.filter(r=>r.toLowerCase().includes(e.toLowerCase())||e.toLowerCase().includes(r.toLowerCase()));if(t.length>0)return t.sort((r,i)=>r.length-i.length);let o=n.map(r=>({package:r,distance:this.levenshteinDistance(e.toLowerCase(),r.toLowerCase())})).sort((r,i)=>r.distance-i.distance),s=Math.max(3,Math.floor(e.length*.4));return o.filter(r=>r.distance<=s).map(r=>r.package)}levenshteinDistance(e,n){if(!e||e.length===0)return n?.length??0;if(!n||n.length===0)return e.length;let t=e.length,o=n.length,s=Array(t+1).fill(null).map(()=>Array(o+1).fill(0));for(let r=0;r<=t;r++)s[r][0]=r;for(let r=0;r<=o;r++)s[0][r]=r;for(let r=1;r<=t;r++)for(let i=1;i<=o;i++){let a=e[r-1]===n[i-1]?0:1;s[r][i]=Math.min(Math.min(s[r-1][i]+1,s[r][i-1]+1),s[r-1][i-1]+a)}return s[t][o]}};var ee=class{ruleName="UnresolvedReference";async validateAsync(e,n){let t=[],o=new U(n),s=await o.buildEntityIndexAsync(e),r=new Set;for(let[i,a]of s.entries()){let c=a.entity.type;if(c){let p=c.toString();(p==="ObjectProperty"||p.endsWith(".ObjectProperty"))&&r.add(i)}}for(let[i,a]of Object.entries(e.body)){if(!a||typeof a!="object"||Array.isArray(a))continue;let c=a,p=this.getPropertyValue(c,"type");if(!(!p||p==="Class"||p.endsWith("Property")||p==="AnnotationProperty"))for(let[l,m]of Object.entries(c))l==="type"||l==="label"||l==="comment"||!(r.has(l)||Array.from(r).some(f=>f.endsWith(`.${l}`)))||await this.validateReferenceValue(i,l,m,e,o,t)}return t}async validateReferenceValue(e,n,t,o,s,r){if(t!=null){if(typeof t=="string")await s.resolveEntityAsync(t,o)||r.push(this.createUnresolvedReferenceError(e,n,t));else if(Array.isArray(t))for(let i=0;i<t.length;i++){let a=t[i];typeof a=="string"&&(await s.resolveEntityAsync(a,o)||r.push(this.createUnresolvedReferenceError(e,`${n}[${i}]`,a)))}}}createUnresolvedReferenceError(e,n,t){let o=`The entity '${t}' cannot be found in the current document or any imported namespaces.
5
+
6
+ Possible solutions:
7
+ \u2022 Add import if the entity is defined in another namespace:
8
+ kanonak namespace add-import <publisher>/<package>@<version>
9
+ \u2022 Check for typos in the reference name '${t}'
10
+ \u2022 Define '${t}' in the current namespace or an appropriate namespace
11
+ \u2022 Use 'kanonak search type ${t} --include-imports' to locate the entity`,s=new g;return s.ruleType=this.ruleName,s.severity="Error",s.entityName=e,s.propertyName=n,s.actualValue=t,s.message=`Reference to '${t}' could not be resolved`,s.suggestion=o,s.expectedValue="A valid entity reference that exists in the current document or imported namespaces",s}getPropertyValue(e,n){let t=e[n];return t?t.toString():null}};var te=class{ruleName="ClassHierarchyCycle";async validateAsync(e,n){let t=[],o=new Map,s=new Set;await this.buildClassHierarchy(e,n,o,s);for(let[r,i]of Object.entries(e.body))if(i&&typeof i=="object"&&!Array.isArray(i)){let a=i,c=a.type,p=a.subClassOf;if(c?.toString()==="Class"&&p){let l=r,m=this.detectCycle(l,o);if(m){let u=m.join(" \u2192 "),f=new g;f.ruleType=this.ruleName,f.severity="Error",f.message=`Circular class hierarchy detected: ${u}`,f.suggestion="Remove the circular dependency by breaking one of the subClassOf relationships",f.entityName=l,f.propertyName="subClassOf",f.actualValue=u,t.push(f);break}}}return t}async buildClassHierarchy(e,n,t,o){let s=e.metadata?.namespace_?.toString()??"";if(!(s&&o.has(s))){s&&o.add(s);for(let[r,i]of Object.entries(e.body))if(i&&typeof i=="object"&&!Array.isArray(i)){let a=i,c=a.type,p=a.subClassOf;if(c?.toString()==="Class"&&p){let l=N(p);l.length>0&&t.set(r,l)}}if(e.metadata?.imports)for(let[r,i]of Object.entries(e.metadata.imports))for(let a of i){let c=await n.getHighestCompatibleVersionAsync(r,a);c&&await this.buildClassHierarchy(c,n,t,o)}}}detectCycle(e,n){let t=[],o=new Set;return this.detectCycleRecursive(e,n,t,o)}detectCycleRecursive(e,n,t,o){if(t.includes(e)){let r=t.indexOf(e),i=t.slice(r);return i.push(e),i}if(o.has(e))return null;t.push(e),o.add(e);let s=n.get(e);if(s)for(let r of s){let i=this.detectCycleRecursive(r,n,t,o);if(i)return i}return t.pop(),null}};var ne=class{ruleName="PropertyHierarchyCycle";async validateAsync(e,n){let t=[],o=new Map,s=new Set;await this.buildPropertyHierarchy(e,n,o,s);for(let[r,i]of Object.entries(e.body))if(i&&typeof i=="object"&&!Array.isArray(i)&&i.subPropertyOf){let p=r,l=this.detectCycle(p,o);if(l){let m=l.join(" \u2192 "),u=new g;u.ruleType=this.ruleName,u.severity="Error",u.message=`Circular property hierarchy detected: ${m}`,u.suggestion="Remove the circular dependency by breaking one of the subPropertyOf relationships",u.entityName=p,u.propertyName="subPropertyOf",u.actualValue=m,t.push(u);break}}return t}async buildPropertyHierarchy(e,n,t,o){let s=e.metadata?.namespace_?.toString()??"";if(!(s&&o.has(s))){s&&o.add(s);for(let[r,i]of Object.entries(e.body))if(i&&typeof i=="object"&&!Array.isArray(i)){let a=i,c=a.type;if(c){let p=c.toString();if(p==="DatatypeProperty"||p==="ObjectProperty"||p==="AnnotationProperty"){let l=a.subPropertyOf;if(l){let m=N(l);m.length>0&&t.set(r,m)}}}}if(e.metadata?.imports)for(let[r,i]of Object.entries(e.metadata.imports))for(let a of i){let c=await n.getHighestCompatibleVersionAsync(r,a);c&&await this.buildPropertyHierarchy(c,n,t,o)}}}detectCycle(e,n){let t=[],o=new Set;return this.detectCycleRecursive(e,n,t,o)}detectCycleRecursive(e,n,t,o){if(t.includes(e)){let r=t.indexOf(e),i=t.slice(r);return i.push(e),i}if(o.has(e))return null;t.push(e),o.add(e);let s=n.get(e);if(s)for(let r of s){let i=this.detectCycleRecursive(r,n,t,o);if(i)return i}return t.pop(),null}};var oe=class{get ruleName(){return"PropertyRangeRequired"}async validateAsync(e,n){let t=[];for(let[o,s]of Object.entries(e.body)){if(typeof s!="object"||s===null||Array.isArray(s))continue;let r=s,i=r.type?.toString();if(i==="DatatypeProperty"||i==="ObjectProperty"||i?.endsWith(".DatatypeProperty")||i?.endsWith(".ObjectProperty")){let a="range"in r,c=r.range?.toString().trim();if(!a||!c){let p=new g;p.ruleType=this.ruleName,p.severity="Error",p.entityName=o,p.propertyName="range",p.message=`Property '${o}' must have a 'range' defined.`,p.suggestion=i==="DatatypeProperty"?"Add a range like: range: string (or integer, boolean, etc.)":"Add a range like: range: ClassName (the class this property expects)",p.expectedValue=i==="DatatypeProperty"?"A datatype (string, integer, boolean, decimal, etc.)":"A class name (Character, Scene, Story, etc.)",t.push(p)}}}return t}};var re=class{builtInClasses=new Set(["Resource","Class","Datatype","Literal","Thing","Nothing","Property","DatatypeProperty","ObjectProperty","AnnotationProperty","FunctionalProperty","InverseFunctionalProperty","TransitiveProperty","SymmetricProperty"]);get ruleName(){return"SubClassOfReference"}isClassLikeType(e){return e?e==="Class"||e.endsWith(".Class")||e==="Datatype"||e.endsWith(".Datatype"):!1}async validateAsync(e,n){let t=[],o=new Set;for(let[s,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let a=r.type?.toString();this.isClassLikeType(a)&&o.add(s)}for(let[s,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let a=N(r.subClassOf);for(let c=0;c<a.length;c++){let p=a[c];if(this.builtInClasses.has(p)||o.has(p))continue;if(!await this.isClassAvailableInImports(e,n,p)){let m=a.length>1?`[${c}]`:"",u=new g;u.ruleType=this.ruleName,u.severity="Error",u.message=`Class '${p}' referenced in subClassOf${m} is not defined or imported`,u.suggestion=`Define '${p}' as a Class, or import a namespace that contains it`,u.entityName=s,u.propertyName="subClassOf",u.actualValue=p,u.expectedValue="Defined or imported class",t.push(u)}}}return t}async isClassAvailableInImports(e,n,t){if(!e.metadata.imports)return!1;let o=null,s=t;if(t.includes(".")){let r=t.split(".",2);o=r[0],s=r[1]}for(let[r,i]of Object.entries(e.metadata.imports))for(let a of i){if(o!==null&&a.alias!==o)continue;let c=await n.getHighestCompatibleVersionAsync(r,a);if(c){let p=o!==null?s:t,l=c.body[p];if(l&&typeof l=="object"&&!Array.isArray(l)){let f=l.type?.toString();if(this.isClassLikeType(f))return!0}let m=new Set;if(await this.isClassAvailableInImportsRecursive(c,n,p,m))return!0}}return!1}async isClassAvailableInImportsRecursive(e,n,t,o){let s=e.metadata.namespace_?.toString()??"";if(s&&o.has(s)||(s&&o.add(s),!e.metadata.imports))return!1;for(let[r,i]of Object.entries(e.metadata.imports))for(let a of i){let c=await n.getHighestCompatibleVersionAsync(r,a);if(c){let p=c.body[t];if(p&&typeof p=="object"&&!Array.isArray(p)){let m=p.type?.toString();if(this.isClassLikeType(m))return!0}if(await this.isClassAvailableInImportsRecursive(c,n,t,o))return!0}}return!1}};var ie=class{builtInProperties=new Set(["type","label","comment","domain","range","subPropertyOf","subClassOf","inverseOf","sameAs","seeAlso","isDefinedBy","functional","required"]);get ruleName(){return"SubPropertyOfReference"}async validateAsync(e,n){let t=[],o=new Set;for(let[s,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let a=r.type?.toString();(a==="DatatypeProperty"||a==="ObjectProperty"||a==="AnnotationProperty")&&o.add(s)}for(let[s,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let a=N(r.subPropertyOf);for(let c=0;c<a.length;c++){let p=a[c];if(this.builtInProperties.has(p)||o.has(p))continue;if(!await this.isPropertyAvailableInImports(e,n,p)){let m=a.length>1?`[${c}]`:"",u=new g;u.ruleType=this.ruleName,u.severity="Error",u.message=`Property '${p}' referenced in subPropertyOf${m} is not defined or imported`,u.suggestion=`Define '${p}' as a DatatypeProperty or ObjectProperty, or import a namespace that contains it`,u.entityName=s,u.propertyName="subPropertyOf",u.actualValue=p,u.expectedValue="Defined or imported property",t.push(u)}}}return t}async isPropertyAvailableInImports(e,n,t){if(!e.metadata.imports)return!1;let o=null,s=t;if(t.includes(".")){let r=t.split(".",2);o=r[0],s=r[1]}for(let[r,i]of Object.entries(e.metadata.imports))for(let a of i){if(o!==null&&a.alias!==o)continue;let c=await n.getHighestCompatibleVersionAsync(r,a);if(c){let p=o!==null?s:t,l=c.body[p];if(l&&typeof l=="object"&&!Array.isArray(l)){let f=l.type?.toString();if(f==="DatatypeProperty"||f==="ObjectProperty"||f==="AnnotationProperty")return!0}let m=new Set;if(await this.isPropertyAvailableInImportsRecursive(c,n,p,m))return!0}}return!1}async isPropertyAvailableInImportsRecursive(e,n,t,o){let s=e.metadata.namespace_?.toString()??"";if(s&&o.has(s)||(s&&o.add(s),!e.metadata.imports))return!1;for(let[r,i]of Object.entries(e.metadata.imports))for(let a of i){let c=await n.getHighestCompatibleVersionAsync(r,a);if(c){let p=c.body[t];if(p&&typeof p=="object"&&!Array.isArray(p)){let m=p.type?.toString();if(m==="DatatypeProperty"||m==="ObjectProperty"||m==="AnnotationProperty")return!0}if(await this.isPropertyAvailableInImportsRecursive(c,n,t,o))return!0}}return!1}};var se=class{get ruleName(){return"NamespaceImportCycle"}async validateAsync(e,n){let t=[],o=e.metadata.namespace_?.toString();if(!o)return t;let s=new Map,r=new Set;await this.buildImportGraph(e,n,s,r);let i=this.detectCycle(o,s);if(i){let a=i.join(" \u2192 "),c=new g;c.ruleType=this.ruleName,c.severity="Error",c.message=`Circular namespace import detected: ${a}`,c.suggestion="Remove one of the imports to break the circular dependency. Circular dependencies prevent proper package resolution.",c.entityName="imports",c.propertyName="imports",c.actualValue=a,t.push(c)}return t}async buildImportGraph(e,n,t,o){let s=e.metadata.namespace_?.toString()??"";if(!(!s||o.has(s))&&(o.add(s),e.metadata.imports)){let r=[];for(let[i,a]of Object.entries(e.metadata.imports))for(let c of a){let p=`${i}/${c.packageName}@${c.version}`;r.push(p);let l=await n.getHighestCompatibleVersionAsync(i,c);l&&await this.buildImportGraph(l,n,t,o)}r.length>0&&t.set(s,r)}}detectCycle(e,n){let t=[],o=new Set;return this.detectCycleRecursive(e,n,t,o)}detectCycleRecursive(e,n,t,o){let s=t.indexOf(e);if(s>=0){let i=t.slice(s);return i.push(e),i}if(o.has(e))return null;t.push(e),o.add(e);let r=n.get(e);if(r)for(let i of r){let a=this.detectCycleRecursive(i,n,t,o);if(a)return a}return t.pop(),null}};var ae=class{metadataKeys=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","inverseOf","transitive","symmetric","functional","inverseFunctional"]);get ruleName(){return"InstancePropertyReference"}async validateAsync(e,n,t){let o=[],s=new Set,r=t?await this.closurePropertyNamesViaCache(e,t):void 0,i=t?await this.aliasClosurePropertyNamesViaCache(e,t):void 0;for(let[a,c]of Object.entries(e.body))if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let l=c.type?.toString();this.isPropertyType(l)&&s.add(a)}for(let[a,c]of Object.entries(e.body))if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let p=c,l=p.type?.toString();if(this.isPropertyType(l)||this.isClassType(l))continue;for(let[m,u]of Object.entries(p)){if(!m||this.metadataKeys.has(m))continue;let f=m,d=null;if(m.includes(".")){let h=m.lastIndexOf(".");d=m.substring(0,h),f=m.substring(h+1)}if(s.has(f))continue;if(!await this.isPropertyAvailable(e,n,f,d,r,i)){let h=new g;h.ruleType=this.ruleName,h.severity="Error",h.message=`Property '${m}' is not defined or imported`,h.suggestion=d?`The property '${f}' is not found in the imported namespace with alias '${d}'.
12
+ 1. Verify the namespace is imported with the correct alias
13
+ 2. Check if the property name is spelled correctly
14
+ 3. Ensure the imported namespace version contains this property`:`The property '${m}' is not defined in this namespace or any imported namespace.
15
+ 1. Define '${m}' as an ObjectProperty or DatatypeProperty in this namespace, OR
16
+ 2. Import the namespace that contains '${m}', OR
17
+ 3. Use a qualified reference like 'alias.${m}' if already imported with an alias`,h.entityName=a,h.propertyName=m,h.actualValue=u?.toString(),h.expectedValue="A defined or imported property",o.push(h)}}}return o}isPropertyType(e){return e?e==="ObjectProperty"||e==="DatatypeProperty"||e==="AnnotationProperty"||e==="Property"||e.endsWith(".ObjectProperty")||e.endsWith(".DatatypeProperty")||e.endsWith(".AnnotationProperty")||e.endsWith(".Property"):!1}isClassType(e){return e?e==="Class"||e.endsWith(".Class"):!1}async isPropertyAvailable(e,n,t,o,s,r){if(s!==void 0&&r!==void 0){if(o===null)return s.has(t);let i=r.get(o);return i?i.has(t):!1}return await this.isPropertyAvailableInImports(e,n,t,o)}async closurePropertyNamesViaCache(e,n){let t=new Set,o=ot(e);if(!o)return t;let s=await n.getImportClosure(o);for(let r of s)if(r!==o)for(let i of await n.getPropertyNames(r))t.add(i);return t}async aliasClosurePropertyNamesViaCache(e,n){let t=new Map;if(!e.metadata.imports)return t;for(let[o,s]of Object.entries(e.metadata.imports))for(let r of s){if(!r.alias)continue;let i=await n.repository.getHighestCompatibleVersionAsync(o,r);if(!i)continue;let a=ot(i);if(!a)continue;let c=await n.getImportClosure(a),p=t.get(r.alias)??new Set;for(let l of c)for(let m of await n.getPropertyNames(l))p.add(m);t.set(r.alias,p)}return t}async isPropertyAvailableInImports(e,n,t,o){if(!e.metadata.imports)return!1;for(let[s,r]of Object.entries(e.metadata.imports))for(let i of r){if(o!==null&&i.alias!==o)continue;let a=await n.getHighestCompatibleVersionAsync(s,i);if(a){let c=a.body[t];if(c&&typeof c=="object"&&!Array.isArray(c)){let m=c.type?.toString();if(this.isPropertyType(m))return!0}let p=new Set;if(await this.isPropertyAvailableInImportsRecursive(a,n,t,p))return!0}}return!1}async isPropertyAvailableInImportsRecursive(e,n,t,o){let s=e.metadata.namespace_?.toString()??"";if(s&&o.has(s)||(s&&o.add(s),!e.metadata.imports))return!1;for(let[r,i]of Object.entries(e.metadata.imports))for(let a of i){let c=await n.getHighestCompatibleVersionAsync(r,a);if(c){let p=c.body[t];if(p&&typeof p=="object"&&!Array.isArray(p)){let m=p.type?.toString();if(this.isPropertyType(m))return!0}if(await this.isPropertyAvailableInImportsRecursive(c,n,t,o))return!0}}return!1}};function ot(y){let e=y.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}var ce=class{metadataKeys=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","inverseOf","transitive","symmetric","functional","inverseFunctional"]);get ruleName(){return"DefinitionPropertyReference"}async validateAsync(e,n){let t=[],o=new Set;for(let[s,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let a=r.type?.toString();this.isPropertyType(a)&&o.add(s)}for(let[s,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let i=r,a=i.type?.toString();if(!this.isPropertyType(a)&&!this.isClassType(a))continue;for(let[c,p]of Object.entries(i)){if(!c||this.metadataKeys.has(c))continue;let l=c,m=null;if(c.includes(".")){let f=c.lastIndexOf(".");m=c.substring(0,f),l=c.substring(f+1)}if(o.has(l))continue;if(!await this.isPropertyAvailableInImports(e,n,l,m)){let f=this.isClassType(a)?"class":"property",d=new g;d.ruleType=this.ruleName,d.severity="Error",d.message=`Property '${c}' used on ${f} '${s}' is not defined or imported`,d.suggestion=m?`The property '${l}' is not found in the imported namespace with alias '${m}'.
18
+ 1. Verify the namespace is imported with the correct alias
19
+ 2. Check if the property name is spelled correctly
20
+ 3. Ensure the imported namespace version contains this property`:`The property '${c}' is not defined in this namespace or any imported namespace.
21
+ 1. Define '${c}' as an ObjectProperty or DatatypeProperty in this namespace, OR
22
+ 2. Import the namespace that contains '${c}', OR
23
+ 3. Use a qualified reference like 'alias.${c}' if already imported with an alias`,d.entityName=s,d.propertyName=c,d.actualValue=p?.toString(),d.expectedValue="A defined or imported property",t.push(d)}}}return t}isPropertyType(e){return e?e==="ObjectProperty"||e==="DatatypeProperty"||e==="AnnotationProperty"||e==="Property"||e.endsWith(".ObjectProperty")||e.endsWith(".DatatypeProperty")||e.endsWith(".AnnotationProperty")||e.endsWith(".Property"):!1}isClassType(e){return e?e==="Class"||e.endsWith(".Class"):!1}async isPropertyAvailableInImports(e,n,t,o){if(!e.metadata.imports)return!1;for(let[s,r]of Object.entries(e.metadata.imports))for(let i of r){if(o!==null&&i.alias!==o)continue;let a=await n.getHighestCompatibleVersionAsync(s,i);if(a){let c=a.body[t];if(c&&typeof c=="object"&&!Array.isArray(c)){let m=c.type?.toString();if(this.isPropertyType(m))return!0}let p=new Set;if(await this.isPropertyAvailableInImportsRecursive(a,n,t,p))return!0}}return!1}async isPropertyAvailableInImportsRecursive(e,n,t,o){let s=e.metadata.namespace_?.toString()??"";if(s&&o.has(s)||(s&&o.add(s),!e.metadata.imports))return!1;for(let[r,i]of Object.entries(e.metadata.imports))for(let a of i){let c=await n.getHighestCompatibleVersionAsync(r,a);if(c){let p=c.body[t];if(p&&typeof p=="object"&&!Array.isArray(p)){let m=p.type?.toString();if(this.isPropertyType(m))return!0}if(await this.isPropertyAvailableInImportsRecursive(c,n,t,o))return!0}}return!1}};var pe=class{xsdTypes=new Set(["string","integer","boolean","decimal","float","double","date","dateTime","time","duration","anyURI","base64Binary","hexBinary","long","int","short","byte","unsignedLong","unsignedInt","unsignedShort","unsignedByte","positiveInteger","nonPositiveInteger","negativeInteger","nonNegativeInteger","normalizedString","token","language","Name","NCName","ENTITY","ENTITIES","IDREF","IDREFS","NMTOKEN","NMTOKENS"]);get ruleName(){return"XsdImport"}async validateAsync(e,n){let t=[],o=new Set,s=[];for(let[r,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let a=i,c=!1,p=a.type;if(Array.isArray(p)){for(let l of p)if(l?.toString()==="DatatypeProperty"){c=!0;break}}else p?.toString()==="DatatypeProperty"&&(c=!0);if(c){s.push(r);let l=this.getPropertyValue(a,"range");l&&this.xsdTypes.has(l)&&o.add(l)}}if(o.size>0&&!await this.checkXsdImportAsync(e.metadata,n)){let i=Array.from(o).sort().join(", "),a=s.sort().join(", "),c=new g;c.ruleType=this.ruleName,c.severity="Error",c.message=`XSD namespace not imported but XSD types are used: ${i}`,c.suggestion=`Add an XSD import to the imports section. The core XSD types package is 'core-xsd' from publisher 'kanonak.org'. Used by properties: ${a}`,c.entityName="imports",t.push(c)}return t}async checkXsdImportAsync(e,n,t=new Set){if(!e?.imports)return!1;let o=e.namespace_?.toString()??"";if(o&&t.has(o))return!1;o&&t.add(o);for(let[,s]of Object.entries(e.imports))for(let r of s)if(r.packageName==="xsd"||r.packageName.toLowerCase().endsWith("-xsd"))return!0;for(let[s,r]of Object.entries(e.imports))for(let i of r){let a=await n.getHighestCompatibleVersionAsync(s,i);if(a?.metadata&&await this.checkXsdImportAsync(a.metadata,n,t))return!0}return!1}getPropertyValue(e,n){return e[n]?.toString()}};var le=class{get ruleName(){return"AmbiguousReference"}async validateAsync(e,n){let t=[],{entitySources:o,importPaths:s}=await this.buildEntitySourceMapAsync(e,n),r=await this.buildDatatypePropertyNamesAsync(e,n);for(let[i,a]of Object.entries(e.body))typeof a=="object"&&a!==null&&!Array.isArray(a)&&this.validateEntityReferences(i,a,o,s,r,e,t);return t}async buildEntitySourceMapAsync(e,n){let t=new Map,o=new Set,s=new Map;for(let r of Object.keys(e.body)){let i=e.metadata.namespace_?.toString()??"";t.has(r)||t.set(r,[]),t.get(r).push(`(local:${i})`)}if(e.metadata.imports)for(let[r,i]of Object.entries(e.metadata.imports))for(let a of i){let c=await n.getHighestCompatibleVersionAsync(r,a);if(c){let p=c.metadata.namespace_?.toString()??"";await this.collectEntitiesRecursivelyAsync(c,t,o,s,[p],n)}}return{entitySources:t,importPaths:s}}async collectEntitiesRecursivelyAsync(e,n,t,o,s,r){let i=e.metadata.namespace_?.toString()??"";if(!t.has(i)){t.add(i),o.has(i)||o.set(i,s);for(let a of Object.keys(e.body)){n.has(a)||n.set(a,[]);let c=n.get(a);c.includes(i)||c.push(i)}if(e.metadata.imports)for(let[a,c]of Object.entries(e.metadata.imports))for(let p of c){let l=await r.getHighestCompatibleVersionAsync(a,p);if(l){let m=l.metadata.namespace_?.toString()??"";await this.collectEntitiesRecursivelyAsync(l,n,t,o,[...s,m],r)}}}}async buildDatatypePropertyNamesAsync(e,n){let t=new Set,o=new Set;if(await this.collectDatatypePropertiesAsync(e,t,o,n),e.metadata.imports)for(let[s,r]of Object.entries(e.metadata.imports))for(let i of r){let a=await n.getHighestCompatibleVersionAsync(s,i);a&&await this.collectDatatypePropertiesAsync(a,t,o,n)}return t}async collectDatatypePropertiesAsync(e,n,t,o){let s=e.metadata.namespace_?.toString()??"";if(!t.has(s)){t.add(s);for(let[r,i]of Object.entries(e.body)){if(typeof i!="object"||i===null||Array.isArray(i))continue;let a=i.type;if(typeof a!="string")continue;(a.includes(".")?a.substring(a.lastIndexOf(".")+1):a)==="DatatypeProperty"&&n.add(r)}if(e.metadata.imports)for(let[r,i]of Object.entries(e.metadata.imports))for(let a of i){let c=await o.getHighestCompatibleVersionAsync(r,a);c&&await this.collectDatatypePropertiesAsync(c,n,t,o)}}}validateEntityReferences(e,n,t,o,s,r,i){for(let[a,c]of Object.entries(n)){let p=a;if(p&&!p.includes(".")){let l=t.get(p);if(l&&l.length>1&&!l.some(u=>u.startsWith("(local:"))){let u=l.filter(f=>!f.startsWith("(local:"));u.length>1&&i.push(this.createAmbiguityError(e,p,`Property '${p}'`,u,o,r,!0,p))}}this.validatePropertyValue(e,p,c,t,o,s,r,i)}}validatePropertyValue(e,n,t,o,s,r,i,a){if(t==null)return;let c=n&&n.includes(".")?n.substring(n.lastIndexOf(".")+1):n,p=!!c&&r.has(c);if(typeof t=="string"&&!t.includes(".")&&!p){let l=o.get(t);if(l&&l.length>1&&!l.some(u=>u.startsWith("(local:"))){let u=l.filter(f=>!f.startsWith("(local:"));u.length>1&&a.push(this.createAmbiguityError(e,n,`Reference '${t}'`,u,s,i,!1,t))}}else if(Array.isArray(t))for(let l=0;l<t.length;l++){let m=`${e}.${n}[${l}]`;this.validatePropertyValue(m,n,t[l],o,s,r,i,a)}else if(typeof t=="object"&&!Array.isArray(t)){let l=n?`${e}.${n}`:e;this.validateEntityReferences(l,t,o,s,r,i,a)}}createAmbiguityError(e,n,t,o,s,r,i,a){let c=[];for(let k of o){let h=this.findAliasForNamespace(r,k);if(h){let v=n?.split(".").pop()??n;c.push(`${h}.${v}`)}}let p=c.length>0?`Use one of: ${c.map(k=>`'${k}'`).join(", ")}`:`Add aliases to imports and use qualified names (e.g., 'alias.${n}')`,l=o.map(k=>{let h=s.get(k);return!h||h.length===0?` \u2022 ${k}`:h.length===1?` \u2022 ${k} (direct import)`:` \u2022 ${k}
24
+ imported via: ${h.join(" \u2192 ")}`}).join(`
25
+ `),m=e.split(".")[0],u=e.includes(".")?e:n,f=new g;f.ruleType=this.ruleName,f.severity="Error",f.entityName=m,u&&(f.propertyName=u);let d=a??n;return d&&(f.actualValue=d),f.message=`${t} is ambiguous - defined in multiple imported namespaces`,f.suggestion=`${p}
26
+
27
+ Defined in:
28
+ ${l}`,f.expectedValue="Unambiguous reference (use namespace alias to disambiguate)",f}findAliasForNamespace(e,n){if(!e.metadata.imports)return null;for(let[t,o]of Object.entries(e.metadata.imports))for(let s of o)if(`${t}/${s.packageName}@${s.version}`===n&&s.alias)return s.alias;return null}};var ye=class{builtInClasses=new Set(["Resource","Class","Literal","Thing","Nothing","Property","DatatypeProperty","ObjectProperty","AnnotationProperty"]);primitiveTypes=new Set(["string","integer","int","long","short","byte","decimal","float","double","boolean","bool","dateTime","date","time","duration","anyURI","anySimpleType","nonNegativeInteger","positiveInteger","negativeInteger","nonPositiveInteger","unsignedInt","unsignedLong","unsignedShort","unsignedByte","base64Binary","hexBinary","Literal","Resource"]);get ruleName(){return"PropertyRangeReference"}async validateAsync(e,n){let t=[],o=new Set;for(let[s,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let a=r.type?.toString();this.isValidRangeTargetType(a)&&o.add(s)}for(let[s,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let i=r,a=i.type?.toString();if(a!=="DatatypeProperty"&&a!=="ObjectProperty"&&!a?.endsWith(".DatatypeProperty")&&!a?.endsWith(".ObjectProperty"))continue;let c=i.range;if(!c)continue;let p=[];if(Array.isArray(c))for(let l of c){let m=l?.toString();m&&p.push(m)}else{let l=c?.toString();l&&p.push(l)}if(p.length===0)continue;for(let l of p){if(this.primitiveTypes.has(l)||this.builtInClasses.has(l)||o.has(l))continue;if(!await this.isTypeAvailableInImports(e,n,l)){let u=a?.includes("ObjectProperty")?"ObjectProperty":"DatatypeProperty",f=new g;f.ruleType=this.ruleName,f.severity="Error",f.message=`Property '${s}' has range '${l}' which is not defined or imported`,f.suggestion=u==="ObjectProperty"?`For ObjectProperty:
29
+ 1. Define '${l}' as a Class in this namespace, OR
30
+ 2. Import the namespace that contains '${l}', OR
31
+ 3. Use a qualified reference like 'alias.${l}' if already imported with an alias`:`For DatatypeProperty:
32
+ 1. Use a primitive type (string, integer, boolean, dateTime, etc.), OR
33
+ 2. If '${l}' should be a class, change property type to ObjectProperty`,f.entityName=s,f.propertyName="range",f.actualValue=l,f.expectedValue=u==="ObjectProperty"?"A defined or imported class name":"A primitive type or defined class",t.push(f)}}}return t}async isTypeAvailableInImports(e,n,t){if(!e.metadata.imports)return!1;let o=null,s=t;if(t.includes(".")){let r=t.split(".",2);o=r[0],s=r[1]}for(let[r,i]of Object.entries(e.metadata.imports))for(let a of i){if(o!==null&&a.alias!==o)continue;let c=await n.getHighestCompatibleVersionAsync(r,a);if(c){let p=o!==null?s:t,l=c.body[p];if(l&&typeof l=="object"&&!Array.isArray(l)){let f=l.type?.toString();if(this.isValidRangeTargetType(f))return!0}let m=new Set;if(await this.isTypeAvailableInImportsRecursive(c,n,p,m))return!0}}return!1}async isTypeAvailableInImportsRecursive(e,n,t,o){let s=e.metadata.namespace_?.toString()??"";if(s&&o.has(s)||(s&&o.add(s),!e.metadata.imports))return!1;for(let[r,i]of Object.entries(e.metadata.imports))for(let a of i){let c=await n.getHighestCompatibleVersionAsync(r,a);if(c){let p=c.body[t];if(p&&typeof p=="object"&&!Array.isArray(p)){let m=p.type?.toString();if(this.isValidRangeTargetType(m))return!0}if(await this.isTypeAvailableInImportsRecursive(c,n,t,o))return!0}}return!1}isValidRangeTargetType(e){return e?e==="Class"||e.endsWith(".Class")||e==="Datatype"||e.endsWith(".Datatype"):!1}};var me=class{xsdTypes=new Set(["string","integer","boolean","decimal","float","double","date","dateTime","time","duration","anyURI","base64Binary","hexBinary","long","int","short","byte","unsignedLong","unsignedInt","unsignedShort","unsignedByte","positiveInteger","nonPositiveInteger","negativeInteger","nonNegativeInteger","normalizedString","token","language","Name","NCName","ENTITY","ENTITIES","IDREF","IDREFS","NMTOKEN","NMTOKENS"]);get ruleName(){return"ObjectPropertyImport"}async validateAsync(e,n){let t=[],o=new Map,s=new U(n);await s.buildEntityIndexAsync(e);for(let[r,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let a=i,c=!1,p=a.type;if(Array.isArray(p)){for(let l of p)if(l?.toString()==="ObjectProperty"){c=!0;break}}else p?.toString()==="ObjectProperty"&&(c=!0);if(c){let l=a.range,m=[];if(Array.isArray(l))for(let u of l){let f=u?.toString();f&&m.push(f)}else{let u=l?.toString();u&&m.push(u)}for(let u of m)this.xsdTypes.has(u)||(o.has(u)||o.set(u,[]),o.get(u).push(r))}}for(let[r,i]of o)if(!await s.resolveEntityAsync(r,e))for(let c of i){let p=new g;p.ruleType=this.ruleName,p.severity="Warning",p.message=`ObjectProperty references class '${r}' which may not be imported`,p.suggestion=`Ensure the namespace containing '${r}' is imported, or define '${r}' in this document`,p.entityName=c,p.propertyName="range",p.actualValue=r,t.push(p)}return t}};var ue=class{standardProperties=new Set(["type","label","comment","subClassOf","domain","range","subPropertyOf","inverseOf","sameAs","seeAlso","isDefinedBy"]);get ruleName(){return"ObjectPropertyValue"}async validateAsync(e,n){let t=[],o=new U(n),s=new Ye(o),r=await o.buildEntityIndexAsync(e),i=await this.buildPropertyMetadataAsync(e,n,o,r);for(let[a,c]of Object.entries(e.body))typeof c=="object"&&c!==null&&!Array.isArray(c)&&await this.scanEntityForObjectProperties(c,a,"",i,o,s,e,t);return t}async scanEntityForObjectProperties(e,n,t,o,s,r,i,a){for(let[c,p]of Object.entries(e)){if(this.standardProperties.has(c))continue;let l,m=await s.resolveEntityAsync(c,i);if(m?.uri){let u=`${m.uri.publisher}/${m.uri.package_}/${m.uri.name}`;l=o.get(u)}if(!l){let u=c,f=c.lastIndexOf(".");f>0&&f<c.length-1&&(u=c.substring(f+1)),l=o.get(u)}if(l&&r.isEffectiveObjectProperty(l.propertyType,l.rangeUri)){let f=t?`${t}.${c}`:c;if(typeof p=="string"&&p.trim().length>0){let d=p.trim();if(d.includes(",")){let h=d.split(",").map(v=>v.trim()).filter(v=>v.length>0);a.push({ruleType:this.ruleName,severity:"Error",message:`Property '${c}' has a comma-separated string value, but ObjectProperty expects a list of references`,suggestion:`Use YAML list format:
34
+ ${c}:
35
+ - ${h[0]}
36
+ ${h.slice(1).map(v=>` - ${v}`).join(`
37
+ `)}`,entityName:n,propertyName:c,propertyPath:f,actualValue:d,expectedValue:`A single reference to ${l.range??"an entity"} OR a YAML list`});continue}let k=await s.resolveEntityAsync(d,i);if(k)l.range&&(await this.validateRangeType(k,l.range,s,i)||a.push({ruleType:this.ruleName,severity:"Warning",message:`Property '${c}' expects a ${l.range}, but '${d}' may not be a ${l.range}`,suggestion:`Ensure '${d}' is defined with appropriate type`,entityName:n,propertyName:c,propertyPath:f,actualValue:d,expectedValue:l.range}));else{let h=l.range??"entity";a.push({ruleType:this.ruleName,severity:"Error",message:`Property '${c}' references '${d}' which is not defined or imported`,suggestion:`Define '${d}' or import a namespace that contains it. Expected range: ${h}`,entityName:n,propertyName:c,propertyPath:f,actualValue:d,expectedValue:"Defined or imported entity"})}}else if(typeof p=="object"&&p!==null&&!Array.isArray(p)){let d=t?`${t}.${c}`:c;await this.scanEntityForObjectProperties(p,n,d,o,s,r,i,a)}else if(Array.isArray(p))for(let d=0;d<p.length;d++){let k=p[d];if(typeof k=="string"&&k.trim().length>0){let h=k.trim(),v=await s.resolveEntityAsync(h,i);if(v){if(l.range&&!await this.validateRangeType(v,l.range,s,i)){let we=t?`${t}.${c}[${d}]`:`${c}[${d}]`;a.push({ruleType:this.ruleName,severity:"Warning",message:`Property '${c}' expects a ${l.range}, but '${h}' may not be a ${l.range}`,suggestion:`Ensure '${h}' is defined with appropriate type`,entityName:n,propertyName:`${c}[${d}]`,propertyPath:we,actualValue:h,expectedValue:l.range})}}else{let K=l.range??"entity",we=t?`${t}.${c}[${d}]`:`${c}[${d}]`;a.push({ruleType:this.ruleName,severity:"Error",message:`Property '${c}' references '${h}' which is not defined or imported`,suggestion:`Define '${h}' or import a namespace that contains it. Expected range: ${K}`,entityName:n,propertyName:`${c}[${d}]`,propertyPath:we,actualValue:h,expectedValue:"Defined or imported entity"})}}else if(typeof k=="object"&&k!==null&&!Array.isArray(k)){let h=t?`${t}.${c}[${d}]`:`${c}[${d}]`;await this.scanEntityForObjectProperties(k,n,h,o,s,r,i,a)}}}if(typeof p=="object"&&p!==null&&!Array.isArray(p)&&!o.has(c)){let u=t?`${t}.${c}`:c;await this.scanEntityForObjectProperties(p,n,u,o,s,r,i,a)}else if(Array.isArray(p))for(let u=0;u<p.length;u++){let f=p[u];if(typeof f=="object"&&f!==null&&!Array.isArray(f)){let d=t?`${t}.${c}[${u}]`:`${c}[${u}]`;await this.scanEntityForObjectProperties(f,n,d,o,s,r,i,a)}}}}async validateRangeType(e,n,t,o){if(!new Set(["Property","DatatypeProperty","ObjectProperty","AnnotationProperty","Class","Resource"]).has(n))return!0;let r=e.entity.type;if(r){let i=[];if(Array.isArray(r))for(let a of r){let c=a?.toString();c&&c.trim().length>0&&i.push(c)}else{let a=r?.toString();a&&a.trim().length>0&&i.push(a)}for(let a of i){let c=a.includes(".")?a.split(".")[1]:a;if(c===n||n==="Property"&&(c==="DatatypeProperty"||c==="ObjectProperty"||c==="AnnotationProperty")||n==="Class"&&c==="Class"||await t.isSubclassOfAsync(a,n,o))return!0}}return!1}async buildPropertyMetadataAsync(e,n,t,o){let s=new Map;for(let[r,i]of o){let a=i.entity.type;if(a){let c=[];if(Array.isArray(a))for(let m of a){let u=m?.toString();u&&u.trim().length>0&&c.push(u)}else{let m=a?.toString();m&&m.trim().length>0&&c.push(m)}let p=!1,l="Property";for(let m of c){let u=m.includes(".")?m.split(".")[1]:m;if(u==="Property"||u==="DatatypeProperty"||u==="ObjectProperty"||u==="AnnotationProperty"){p=!0,l=m;break}}if(p){let m={propertyType:l},u=i.entity.range;if(u){let f=u?.toString();if(f&&f.trim().length>0){m.range=f;let d=await t.resolveEntityAsync(f,e);d&&(m.rangeUri=d.uri)}}if(s.set(r,m),i.uri){let f=`${i.uri.publisher}/${i.uri.package_}/${i.uri.name}`;s.set(f,m)}}}}return s}};var fe=class{standardProperties=new Set(["type","label","comment","subClassOf","domain","range","subPropertyOf","inverseOf","sameAs","seeAlso","isDefinedBy"]);get ruleName(){return"PropertyDomain"}async validateAsync(e,n,t){let o=[],s=new Map;for(let[i,a]of Object.entries(e.body))if(typeof a=="object"&&a!==null&&!Array.isArray(a)){let c=a,p=this.getPropertyValue(c,"type");(p==="DatatypeProperty"||p?.endsWith(".DatatypeProperty")||p==="ObjectProperty"||p?.endsWith(".ObjectProperty")||p==="AnnotationProperty"||p?.endsWith(".AnnotationProperty"))&&s.set(i,c)}let r=t?await this.buildClassHierarchyViaCache(e,t):await this.buildCompleteClassHierarchyAsync(e,n);for(let[i,a]of Object.entries(e.body))if(typeof a=="object"&&a!==null&&!Array.isArray(a)){let c=a,p=this.getPropertyValue(c,"type");if(!p||p==="Class"||p.endsWith(".Class")||p.endsWith("Property")||p==="AnnotationProperty")continue;this.validateEntityProperties(c,i,p,s,r,o)}return o}async buildClassHierarchyViaCache(e,n){let t=new Map,o=dt(e);if(!o)return t;let s=await n.getImportClosure(o);for(let r of s){let i=await n.getClassDeclarations(r);for(let[a,c]of i)c.length>0&&t.set(a,c)}return t}async buildCompleteClassHierarchyAsync(e,n){let t=new Map,o=new Set,s=async(i,a)=>{if(!o.has(a)){o.add(a);for(let[c,p]of Object.entries(i.body))if(typeof p=="object"&&p!==null&&!Array.isArray(p)){let l=p,m=this.getPropertyValue(l,"type");if(m==="Class"||m?.endsWith(".Class")){let u=l.subClassOf;if(u===void 0){for(let d of Object.keys(l))if(d.endsWith(".subClassOf")){u=l[d];break}}let f=N(u);f.length>0&&t.set(c,f)}}if(i.metadata.imports)for(let[c,p]of Object.entries(i.metadata.imports))for(let l of p)try{let m=await n.getHighestCompatibleVersionAsync(c,l);if(m){let u=`${c}/${l.packageName}@${l.version}`;await s(m,u)}}catch{}}},r=e.metadata.namespace_?.toString()??"unknown";return await s(e,r),t}validateEntityProperties(e,n,t,o,s,r){for(let[i,a]of Object.entries(e)){if(this.standardProperties.has(i))continue;let c=i,p=i.lastIndexOf(".");p>0&&p<i.length-1&&(c=i.substring(p+1));let l=o.get(c);if(!l)continue;let m=this.getPropertyValue(l,"domain");if(m){if(!this.isTypeCompatibleWithDomain(t,m,s)){let u=n.split(".")[0];r.push({ruleType:this.ruleName,severity:"Error",entityName:u,propertyName:n,actualValue:i,message:`Property '${i}' has domain '${m}' but is used on '${t}' at '${n}'`,suggestion:`Either:
38
+ 1. Use this property only on '${m}' instances
39
+ 2. Change the property domain to include '${t}'
40
+ 3. Create a different property for '${t}'`,expectedValue:`Property used on ${m} or its subclasses`})}if(typeof a=="object"&&a!==null&&!Array.isArray(a)){let u=a,f=this.getPropertyValue(u,"type");if(f){let d=`${n}.${i}`;this.validateEntityProperties(u,d,f,o,s,r)}else{let d=this.getPropertyValue(l,"range");if(d){let k=`${n}.${i}`;this.validateEntityProperties(u,k,d,o,s,r)}}}else if(Array.isArray(a))for(let u=0;u<a.length;u++){let f=a[u];if(typeof f=="object"&&f!==null&&!Array.isArray(f)){let d=f,k=this.getPropertyValue(d,"type");if(k){let h=`${n}.${i}[${u}]`;this.validateEntityProperties(d,h,k,o,s,r)}else{let h=this.getPropertyValue(l,"range");if(h){let v=`${n}.${i}[${u}]`;this.validateEntityProperties(d,v,h,o,s,r)}}}}}}}isTypeCompatibleWithDomain(e,n,t){if(e===n)return!0;let o=new Set,s=[e];for(;s.length>0;){let r=s.shift();if(o.has(r))continue;o.add(r);let i=t.get(r);if(i)for(let a of i){if(a===n)return!0;s.push(a)}}return!1}getPropertyValue(e,n){if(n in e){let t=e[n];return this.extractFirstValue(t)}for(let t of Object.keys(e))if(t.endsWith(`.${n}`)){let o=e[t];return this.extractFirstValue(o)}}extractFirstValue(e){if(Array.isArray(e)){let n=[];for(let t of e)n.push(t?.toString()??"");return n.length>0?n[0]:void 0}return e?.toString()}};function dt(y){let e=y.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}var de=class{get ruleName(){return"PropertyValueType"}async validateAsync(e,n){let t=[],o=new Map;for(let[s,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let i=r,a=this.getPropertyValue(i,"type");(a==="DatatypeProperty"||a==="ObjectProperty")&&o.set(s,i)}for(let[s,r]of Object.entries(e.body)){if(typeof r!="object"||r===null||Array.isArray(r))continue;let i=r,a=this.getPropertyValue(i,"type");if(!(!a||a==="Class"||a.endsWith("Property")||a==="AnnotationProperty"))for(let[c,p]of Object.entries(i)){if(c==="type"||c==="label"||c==="comment")continue;let l=c,m=c.lastIndexOf(".");m>0&&m<c.length-1&&(l=c.substring(m+1));let u=o.get(l);if(!u)continue;let f=this.getPropertyValue(u,"type"),d=this.getPropertyValue(u,"range");if(f==="DatatypeProperty"){if(typeof p=="object"&&p!==null&&!Array.isArray(p)||Array.isArray(p))t.push({ruleType:this.ruleName,severity:"Error",entityName:s,propertyName:c,message:`Property '${c}' is a DatatypeProperty with range '${d}' but instance '${s}' has a complex object value`,suggestion:`Either:
41
+ 1. Create a class for this data and change '${c}' to an ObjectProperty
42
+ 2. Store as a JSON string to keep it as DatatypeProperty
43
+ 3. Use separate properties instead of nesting`,expectedValue:`A simple value of type '${d}'`});else if(!this.validateDatatypeValue(d,p)){let k={ruleType:this.ruleName,severity:"Error",entityName:s,propertyName:c,message:`Property '${c}' expects type '${d}' but instance '${s}' has value of type '${this.getValueTypeName(p)}'`,suggestion:`Provide a value of type '${d}'`,toString:()=>""};d&&(k.expectedValue=d),t.push(k)}}else if(f==="ObjectProperty")if(Array.isArray(p))for(let k=0;k<p.length;k++){let h=p[k];typeof h!="string"&&(typeof h!="object"||h===null||Array.isArray(h))&&t.push({ruleType:this.ruleName,severity:"Error",entityName:s,propertyName:`${c}[${k}]`,message:`ObjectProperty '${c}' array item ${k} in instance '${s}' has invalid type '${this.getValueTypeName(h)}'`,suggestion:"Array items must be references (strings) or embedded objects (dictionaries)",expectedValue:"string or object"})}else typeof p!="string"&&(typeof p!="object"||p===null||Array.isArray(p))&&t.push({ruleType:this.ruleName,severity:"Error",entityName:s,propertyName:c,message:`ObjectProperty '${c}' in instance '${s}' has invalid value type '${this.getValueTypeName(p)}'`,suggestion:"Value must be a reference (string), embedded object (dictionary), or array of these",expectedValue:`Reference to ${d} or embedded ${d} object`})}}return t}validateDatatypeValue(e,n){switch(e?.toLowerCase()){case"string":return typeof n=="string";case"integer":case"int":return typeof n=="number"&&Number.isInteger(n);case"decimal":return typeof n=="number";case"boolean":return typeof n=="boolean";case"float":case"double":return typeof n=="number";default:return!0}}getValueTypeName(e){return typeof e=="string"?"string":typeof e=="number"?Number.isInteger(e)?"integer":"decimal":typeof e=="boolean"?"boolean":Array.isArray(e)?"array":typeof e=="object"&&e!==null?"object":e===null?"null":e===void 0?"undefined":typeof e}getPropertyValue(e,n){if(n in e){let t=e[n];if(Array.isArray(t)){let o=[];for(let s of t)o.push(s?.toString()??"");return o.length>0?o[0]:void 0}return t?.toString()}}};var ge=class{builtInClasses=new Set(["Resource","Class","Literal","Thing","Nothing","Property","DatatypeProperty","ObjectProperty","AnnotationProperty","FunctionalProperty","InverseFunctionalProperty","TransitiveProperty","SymmetricProperty","Package"]);get ruleName(){return"ClassDefinition"}async validateAsync(e,n){let t=[],o=new Map,s=new Set;for(let[i,a]of Object.entries(e.body))if(typeof a=="object"&&a!==null&&!Array.isArray(a)){let p=a.type;if(p)if(Array.isArray(p))for(let l of p){let m=l?.toString();if(m==="Class"||m&&m.endsWith(".Class")){s.add(i);break}}else{let l=p?.toString();(l==="Class"||l&&l.endsWith(".Class"))&&s.add(i)}}for(let[i,a]of Object.entries(e.body))if(typeof a=="object"&&a!==null&&!Array.isArray(a)){let c=a,p=c.type;if(p)if(Array.isArray(p)){let l=!1;for(let m of p){let u=m?.toString();if(u&&this.isDefinitionType(u)){l=!0;break}}if(!l)for(let m of p){let u=m?.toString();u&&u.trim().length>0&&(o.has(u)||o.set(u,[]),o.get(u).push(i))}}else{let l=p?.toString();l&&l.trim().length>0&&(this.isDefinitionType(l)||(o.has(l)||o.set(l,[]),o.get(l).push(i)))}this.checkNestedTypes(c,i,o,i)}let r=new U(n);for(let[i,a]of o){if(this.builtInClasses.has(i)||s.has(i))continue;let c=await r.resolveEntityAsync(i,e);if(!(c&&this.isClassEntity(c.entity))){let l=Array.from(new Set(a)).sort();for(let m of l)t.push({ruleType:this.ruleName,severity:"Error",message:`Class '${i}' is not defined or imported`,suggestion:`Define '${i}' as a Class in this document, or import a namespace that contains it`,entityName:m,propertyName:"type",actualValue:i,expectedValue:"Defined or imported class"})}}return t}checkNestedTypes(e,n,t,o){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let s=e,r=s.type;if(r){let i=new Set(["Class","DatatypeProperty","ObjectProperty","AnnotationProperty"]);if(Array.isArray(r))for(let a of r){let c=a?.toString();c&&c.trim().length>0&&!i.has(c)&&(t.has(c)||t.set(c,[]),t.get(c).push(o))}else{let a=r?.toString();a&&a.trim().length>0&&!i.has(a)&&(t.has(a)||t.set(a,[]),t.get(a).push(o))}}for(let[i,a]of Object.entries(s))if(i!=="type"){let c=`${o}.${i}`;this.checkNestedTypes(a,n,t,c)}}else if(Array.isArray(e))for(let s=0;s<e.length;s++){let r=`${o}[${s}]`;this.checkNestedTypes(e[s],n,t,r)}}isClassEntity(e){if(!e)return!1;let n=e.type;if(!n)return!1;if(Array.isArray(n))for(let t of n){let o=t?.toString();if(o==="Class"||o&&o.endsWith(".Class"))return!0}else{let t=n?.toString();if(t==="Class"||t&&t.endsWith(".Class"))return!0}return!1}isDefinitionType(e){return!e||e.trim().length===0?!1:new Set(["Class","Property","DatatypeProperty","ObjectProperty","AnnotationProperty"]).has(e)?!0:e.endsWith(".Class")||e.endsWith(".Property")||e.endsWith(".DatatypeProperty")||e.endsWith(".ObjectProperty")||e.endsWith(".AnnotationProperty")}};var he=class{ruleName="MarkdownLink";async validateAsync(e,n,t){let o=[],s;if(t){let r=await t.getKanonaks(),i=gt(e);s=i?r.filter(a=>a instanceof I&&a.namespace===i):[]}else{let r=new M(e,n);s=await new A().parseKanonaks(r)}for(let r of s)r instanceof I&&this.checkDefined(r,r.name,o);return o}checkDefined(e,n,t){for(let o of e.statement)if(o instanceof ze){let s=o.predicate.subject?.name??"(unknown)";for(let r of o.links)r.target||t.push(this.unresolvedLinkError(n,s,r.reference));for(let r of Ge(o.object))t.push(this.malformedLinkError(n,s,r.snippet))}else if(o instanceof Xe)this.checkDefined(o.object,n,t);else if(o instanceof qe)for(let s of o.object)s instanceof D&&this.checkDefined(s,n,t)}unresolvedLinkError(e,n,t){let o=new g;return o.ruleType=this.ruleName,o.severity="Error",o.entityName=e,o.propertyName=n,o.actualValue=t,o.message=`Embedded link [[${t}]] in '${n}' could not be resolved`,o.expectedValue="A reference resolvable through the document's import closure",o.suggestion=`The reference '${t}' inside a markdown value cannot be found in the current document or any imported namespace.
44
+
45
+ Possible solutions:
46
+ \u2022 Import the package that defines '${t}' so the link can resolve
47
+ \u2022 Check for typos in the reference name
48
+ \u2022 If the name collides across imports, alias-qualify it: [[alias.${t}]]`,o}malformedLinkError(e,n,t){let o=new g;return o.ruleType=this.ruleName,o.severity="Error",o.entityName=e,o.propertyName=n,o.actualValue=t,o.message=`Malformed embedded reference near '${t}' in '${n}'`,o.expectedValue="A single-line [[reference]] with no internal line break",o.suggestion=`A '[[' in '${n}' does not form a complete [[reference]] link.
49
+
50
+ A reference may not span a line break \u2014 the most common cause is wrapping a
51
+ long reference across two lines in a block scalar, e.g.:
52
+ ... read for [[persistent-energy-
53
+ shock]] held ...
54
+ which is parsed as literal text, not a link. Keep each [[reference]] on one
55
+ line (let the line run long), or check for an unterminated [[.`,o}};function gt(y){let e=y.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}var rt="kanonak.org",it="look",ht={publisher:rt,package_:it,name:"displayLabel"},kt={publisher:rt,package_:it,name:"displaySummary"},ke=class{ruleName="DisplayLensScope";async validateAsync(e,n,t){let o=[],s;t?s=await t.getKanonaks():s=await new A().parseKanonaks(new M(e,n));let r=bt(e);if(!r)return o;for(let i of s)i instanceof I&&i.namespace===r&&(this.checkLens(s,i,ht,"displayLabel",o),this.checkLens(s,i,kt,"displaySummary",o));return o}checkLens(e,n,t,o,s){let r=V(n,t);if(!r)return;let i=[],a=W(n);if(a&&i.push(a),i.push(...Qe(n)),i.length===0)return;i.some(p=>T(e,p,r).ok)||s.push(this.scopeError(n.name,o,r.name))}scopeError(e,n,t){let o=new g;return o.ruleType=this.ruleName,o.severity="Error",o.entityName=e,o.propertyName=n,o.actualValue=t,o.message=`${n} points at '${t}', which is not a property in scope for '${e}'`,o.expectedValue="A property whose domain is this resource's class, an ancestor, or rdfs.Resource",o.suggestion=`'${t}' resolves, but its domain does not cover '${e}', so the lens would silently fall back to the resource's name at render time.
56
+
57
+ Possible solutions:
58
+ \u2022 Point ${n} at a property declared on this class (or an ancestor / rdfs.Resource)
59
+ \u2022 Set the property's domain to this class if it should apply here
60
+ \u2022 Use rdfs.label / rdfs.comment for the universal default`,o}};function bt(y){let e=y.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}function F(y,e,n){let t=[];return Se(y,n,{input:e},t),t}function Se(y,e,n,t){if(E(e,_.VarRef)){let r=L(e,_.varName);return r?n[r]:void 0}if(E(e,_.PropertyRead)){let r=O(e,_.readSource),i=r?Se(y,r,n,t):void 0,a=V(e,_.readProp);if(!i||!a)return;let c=T(y,i,a);if(!c.ok){t.push({contextClass:i,propertyUri:a,via:"PropertyRead"});return}return c.descriptor?.range}if(E(e,_.Traverse)){let r=O(e,_.traverseSource),i=r?Se(y,r,n,t):void 0,a=V(e,_.through),c;if(i&&a){let l=T(y,i,a);l.ok?c=l.descriptor?.range:t.push({contextClass:i,propertyUri:a,via:"Traverse"})}let p=O(e,_.step);return p?Se(y,p,{...n,input:c},t):void 0}let o=L(e,_.loopVar),s=o?{...n,[o]:void 0}:n;for(let r of Rt(e))Se(y,r,s,t)}function Rt(y){let e=[];for(let n of y.statement){let t=n.object;if(t instanceof D)e.push(t);else if(Array.isArray(t))for(let o of t)o instanceof D&&e.push(o)}return e}var $e="kanonak.org",Ke="look",vt={publisher:$e,package_:Ke,name:"semanticSvg"},Pt={publisher:$e,package_:Ke,name:"tierChip"},Vt={publisher:$e,package_:Ke,name:"tierIcon"},It={publisher:$e,package_:Ke,name:"tierCard"},Dt={publisher:$e,package_:Ke,name:"tierFull"},At=[Pt,Vt,It,Dt],be=class{ruleName="LookSemanticSvgPath";async validateAsync(e,n,t){let o=[],s;t?s=await t.getKanonaks():s=await new A().parseKanonaks(new M(e,n));let r=Et(e);if(!r)return o;for(let i of s)i instanceof I&&i.namespace===r&&this.checkSemanticSvg(s,i,o);return o}checkSemanticSvg(e,n,t){let o=O(n,vt);if(!o)return;let s=W(n);if(s)for(let r of At){let i=O(o,r);if(i)for(let a of F(e,s,i))t.push(this.toError(n.name,r.name,a))}}toError(e,n,t){let o=`${t.propertyUri.publisher}/${t.propertyUri.package_}/${t.propertyUri.name}`,s=t.contextClass.name,r=s===e?`'${e}' (the class this SemanticSvg is declared on)`:`'${s}', reached by traversal from '${e}' (the class this SemanticSvg is declared on)`,i=new g;return i.ruleType=this.ruleName,i.severity="Error",i.entityName=e,i.propertyName=`look.semanticSvg.${n}`,i.actualValue=o,i.message=`tx.${t.via} reads property '${t.propertyUri.name}' off the rendered instance, but its domain is not in scope for ${r}. The read would silently return undefined at render time.`,i.expectedValue=`A property whose domain is '${s}', an ancestor, or rdfs.Resource`,i.suggestion=`Property '${o}' is not in scope for '${s}'.
61
+
62
+ Possible solutions:
63
+ \u2022 Read a property declared on '${s}' (or an ancestor / rdfs.Resource)
64
+ \u2022 If the property should apply to '${s}', adjust its domain
65
+ \u2022 If the value comes from a pre-computed env binding, use tx.VarRef instead of PropertyRead`,i}};function Et(y){let e=y.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}var Ot="kanonak.org",R=(y,e)=>({publisher:Ot,package_:y,name:e}),St=R("derivation","look"),$t=R("look","bands"),Kt=R("look","Distribution"),Ct=R("look","StatRow"),wt=R("look","VersionDelta"),jt=R("look","Timeline"),Nt=R("look","VersionDiff"),Tt=R("look","TimePlot"),xt=R("look","ReferenceList"),_t=R("look","Diagram"),Ut=R("look","alphaPath"),Lt=R("look","betaPath"),Me=R("look","metricPath"),st=R("look","lowerPath"),at=R("look","upperPath"),ct=R("look","hueBy"),Mt=R("look","statPath"),Wt=R("look","laneBy"),pt=R("look","labelPath"),Ht=R("look","badgePath"),Bt=R("look","mapPath"),Ft=R("look","nodeNote"),Xt=R("look","edgeValue"),qt=R("look","stats"),zt=R("look","facets"),Yt=R("look","channels"),Gt=R("look","track"),Zt=R("look","source"),Jt=R("look","relation"),Qt=R("look","entries"),Ce=class{ruleName="LookBandPath";async validateAsync(e,n,t){let o=[],s;t?s=await t.getKanonaks():s=await new A().parseKanonaks(new M(e,n));let r=tn(e);if(!r)return o;for(let i of s)i instanceof I&&i.namespace===r&&this.checkDeclaration(s,i,o);return o}checkDeclaration(e,n,t){let o=O(n,St);if(!o)return;let s=W(n);if(!s)return;let r=S(o,$t).filter(i=>i instanceof D);for(let i of r)for(let a of this.carriersOf(e,i,s))for(let c of F(e,a.context,a.expr))t.push(this.toError(n.name,a.slot,c))}carriersOf(e,n,t){let o=[],s=(r,i)=>{let a=O(n,r);a&&o.push({slot:`look.${r.name}`,context:i,expr:a})};if(E(n,Kt))for(let r of[Ut,Lt,Me,st,at,ct])s(r,t);if(E(n,wt)&&s(Me,t),E(n,Ct)){let r=S(n,qt).filter(i=>i instanceof D);for(let i of r){let a=O(i,Mt);a&&o.push({slot:"look.stats[].statPath",context:t,expr:a})}}if(E(n,jt)||E(n,Nt)){let r=this.rangeOf(e,t,V(n,Gt));if(r)for(let i of[Me,st,at,ct])s(i,r)}if(E(n,Tt)){let r=this.rangeOf(e,t,V(n,Zt));if(r)for(let i of[Wt,pt])s(i,r)}if(E(n,xt))for(let r of S(n,Qt)){let i=r instanceof D?void 0:en(r),a=this.rangeOf(e,t,i);if(a)for(let c of[pt,Ht])s(c,a)}if(E(n,_t)){let r=S(n,zt).filter(i=>i instanceof D);for(let i of r){let a=this.rangeOf(e,t,V(i,Jt));if(!a)continue;let c=O(i,Ft);c&&o.push({slot:"look.facets[].nodeNote",context:a,expr:c});let p=O(i,Xt);p&&o.push({slot:"look.facets[].edgeValue",context:a,expr:p});let l=S(i,Yt).filter(m=>m instanceof D);for(let m of l){let u=O(m,Bt);u&&o.push({slot:"look.facets[].channels[].mapPath",context:a,expr:u})}}}return o}rangeOf(e,n,t){if(!t)return;let o=T(e,n,t);return o.ok?o.descriptor?.range:void 0}toError(e,n,t){let o=`${t.propertyUri.publisher}/${t.propertyUri.package_}/${t.propertyUri.name}`,s=t.contextClass.name,r=new g;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=n,r.actualValue=o,r.message=`tx.${t.via} reads property '${t.propertyUri.name}', but its domain is not in scope for '${s}' (the class this band carrier is evaluated against). The read would silently return undefined at render time and the band would render empty.`,r.expectedValue=`A property whose domain is '${s}', an ancestor, or rdfs.Resource`,r.suggestion=`Property '${o}' is not in scope for '${s}'.
66
+
67
+ Possible solutions:
68
+ \u2022 Read a property declared on '${s}' (or an ancestor / rdfs.Resource)
69
+ \u2022 If the property should apply to '${s}', adjust its domain
70
+ \u2022 If the path is wrong, correct the tx.PropertyRead/tx.Traverse chain`,r}};function en(y){let e=y.subject;return e&&typeof e.name=="string"?e:void 0}function tn(y){let e=y.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}var ve="kanonak.org",Pe="view",nn={publisher:ve,package_:Pe,name:"bind"},on={publisher:ve,package_:Pe,name:"produces"},rn={publisher:ve,package_:Pe,name:"projections"},sn={publisher:ve,package_:Pe,name:"where"},an={publisher:ve,package_:Pe,name:"value"},cn={publisher:ve,package_:Pe,name:"as"},Re=class{ruleName="TxExpressionPath";async validateAsync(e,n,t){let o=[],s;t?s=await t.getKanonaks():s=await new A().parseKanonaks(new M(e,n));let r=yn(e);if(!r)return o;for(let i of s)i instanceof I&&i.namespace===r&&this.checkView(s,i,o);return o}checkView(e,n,t){let o=V(n,nn);if(!o)return;let s=V(n,on),r=0;for(let a of ln(e,S(n,rn))){let c=O(a,an);if(c)for(let l of F(e,o,c))t.push(this.toError(n.name,`view.projections[${r}].value`,o,l));let p=V(a,cn);p&&s&&(T(e,s,p).ok||t.push(this.asError(n.name,r,s,p))),r+=1}let i=0;for(let a of pn(n,sn)){for(let c of F(e,o,a))t.push(this.toError(n.name,`view.where[${i}]`,o,c));i+=1}}asError(e,n,t,o){let s=`${o.publisher}/${o.package_}/${o.name}`,r=new g;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=`view.projections[${n}].as`,r.actualValue=s,r.message=`Projection stores its value under property '${o.name}', but that property's domain is not in scope for the view's produces class '${t.name}'. The materialized result instance could not carry this value.`,r.expectedValue=`A property whose domain is '${t.name}', an ancestor, or rdfs.Resource`,r.suggestion=`Property '${s}' is not in scope for produces class '${t.name}'.
71
+
72
+ Possible solutions:
73
+ \u2022 Use an output property whose domain covers '${t.name}'
74
+ \u2022 Define a new property in the ViewPackage with domain '${t.name}' and the right range
75
+ \u2022 If the value belongs on a different output class, adjust the view's produces`,r}toError(e,n,t,o){let s=`${o.propertyUri.publisher}/${o.propertyUri.package_}/${o.propertyUri.name}`,r=o.contextClass.name,i=r===t.name?`the view's bound class '${t.name}'`:`'${r}', reached by traversal from the view's bound class '${t.name}'`,a=new g;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e,a.propertyName=n,a.actualValue=s,a.message=`tx.${o.via} reads property '${o.propertyUri.name}', but its domain is not in scope for ${i}. The read would silently return undefined when the view materializes.`,a.expectedValue=`A property whose domain is '${r}', an ancestor, or rdfs.Resource`,a.suggestion=`Property '${s}' is not in scope for '${r}'.
76
+
77
+ Possible solutions:
78
+ \u2022 Read a property declared on '${r}' (or an ancestor / rdfs.Resource)
79
+ \u2022 If the property should apply to '${r}', adjust its domain
80
+ \u2022 If the path is wrong, correct the tx.PropertyRead/tx.Traverse chain`,a}};function pn(y,e){let n=O(y,e);return n?[n]:S(y,e).filter(t=>t instanceof D)}function ln(y,e){let n=[];for(let t of e)if(t instanceof D)n.push(t);else if(t instanceof H){let o=x(y,t.subject);o&&n.push(o)}return n}function yn(y){let e=y.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}var xe="kanonak.org",mn="core-shacl",$=y=>({publisher:xe,package_:mn,name:y}),un=$("NodeShape"),fn=$("PropertyShape"),dn=$("targetClass"),gn=$("property"),hn=$("path"),kn=$("minCount"),bn=$("maxCount"),Rn=$("datatype"),vn=$("class"),lt=$("in"),Pn=$("pattern"),Vn=$("flags"),In=$("minLength"),Dn=$("maxLength"),An=$("minInclusive"),En=$("maxInclusive"),On=new Set(["decimal","integer","int","long","short","byte","float","double","nonNegativeInteger","positiveInteger","negativeInteger","nonPositiveInteger","unsignedInt","unsignedLong","unsignedShort","unsignedByte"]),We=y=>y,Ie=class{ruleName="ShaclShape";async validateAsync(e,n,t){let o=[],s=t?await t.getKanonaks():await new A().parseKanonaks(n),r=Sn(e);if(!r)return o;let i=new Set;for(let a of s){if(!(a instanceof I)||a.namespace!==r||!E(a,un))continue;let c=V(a,dn);c?this.resolvesToClass(s,c)||o.push(this.err(a.name,"targetClass","Error",`NodeShape '${a.name}' sh:targetClass '${c.name}' does not resolve to a class.`,"Reference a defined or imported rdfs.Class.",X(c))):o.push(this.err(a.name,"targetClass","Error",`NodeShape '${a.name}' has no sh:targetClass; it constrains nothing.`,"Add sh:targetClass naming the class this shape applies to."));for(let p of S(a,gn)){let l;if(p instanceof D)l=p;else if(p instanceof H){let m=x(s,p.subject);m&&(l=m,i.add(C(p.subject)))}l&&this.checkPropertyShape(s,a.name,l,c??void 0,o)}}for(let a of s){if(!(a instanceof I)||a.namespace!==r||!E(a,fn))continue;let c=W(a);c&&i.has(C(c))||this.checkPropertyShape(s,a.name,a,void 0,o)}return o}checkPropertyShape(e,n,t,o,s){let r=V(t,hn);if(!r){s.push(this.err(n,"property.path","Error",`A PropertyShape on '${n}' has no sh:path; a PropertyShape must name the property it constrains.`,"Add sh:path naming a property."));return}let i=x(e,r),a=i?B.isAnyPropertyType(We(i)):!1;a?o&&(T(e,o,r).ok||s.push(this.err(n,"property.path","Warning",`sh:path '${r.name}' is not in scope for sh:targetClass '${o.name}'; the constraint would never bind a value.`,`Constrain a property whose domain is '${o.name}', an ancestor, or rdfs.Resource.`,X(r)))):s.push(this.err(n,"property.path","Error",`sh:path '${r.name}' on '${n}' does not resolve to a property.`,"Reference a defined or imported property.",X(r)));let c=V(t,Rn),p=V(t,vn);c&&p&&s.push(this.err(n,"property","Error",`A PropertyShape on '${n}' sets both sh:datatype and sh:class; a value is a literal or a node, not both.`,"Keep sh:datatype (literal values) or sh:class (node values), not both.")),c&&!this.resolvesToDatatype(e,c)&&s.push(this.err(n,"datatype","Error",`sh:datatype '${c.name}' on '${n}' does not resolve to a datatype.`,"Reference an xsd datatype or rdfs.Datatype.",X(c))),p&&!this.resolvesToClass(e,p)&&s.push(this.err(n,"class","Error",`sh:class '${p.name}' on '${n}' does not resolve to a class.`,"Reference a defined or imported rdfs.Class.",X(p)));let l=Ve(w(t,kn)),m=Ve(w(t,bn));this.checkOrder(n,"minCount",l,"maxCount",m,s);let u=Ve(w(t,In)),f=Ve(w(t,Dn));this.checkOrder(n,"minLength",u,"maxLength",f,s);let d=Ve(w(t,An)),k=Ve(w(t,En));this.checkOrder(n,"minInclusive",d,"maxInclusive",k,s);let h=L(t,Pn);if(h!==void 0){let v=L(t,Vn);try{new RegExp(h,v)}catch{s.push(this.err(n,"pattern","Error",`sh:pattern on '${n}' is not a valid regular expression`+(v!==void 0?` (with flags '${v}')`:"")+`: ${h}`,"Provide a valid regular expression and flags.",h))}}if(Ne(t,lt)&&S(t,lt).length===0&&s.push(this.err(n,"in","Error",`sh:in on '${n}' is empty; an enumeration must list at least one permitted value.`,"List the permitted literal values, or remove sh:in.")),a&&o){let K=T(e,o,r).descriptor;K&&((h!==void 0||u!==void 0||f!==void 0)&&K.kind==="object"&&s.push(this.err(n,"pattern/minLength/maxLength","Warning",`String facets on '${n}' apply to '${r.name}', which is an object property; string facets constrain literal values.`,"Apply string facets to a datatype property, or use sh:class for node values.",X(r))),(d!==void 0||k!==void 0)&&!this.isNumericDatatypeRange(K.range)&&s.push(this.err(n,"minInclusive/maxInclusive","Warning",`Numeric bounds on '${n}' apply to '${r.name}', whose range is not a numeric datatype.`,"Apply numeric bounds to a numeric datatype property.",X(r))))}}checkOrder(e,n,t,o,s,r){t!==void 0&&s!==void 0&&t>s&&r.push(this.err(e,`${n}/${o}`,"Error",`${n} (${t}) exceeds ${o} (${s}) on '${e}'.`,`Set ${n} <= ${o}.`))}resolvesToClass(e,n){let t=x(e,n);return t?B.isClassType(We(t)):!1}resolvesToDatatype(e,n){if(n.publisher===xe&&n.package_==="core-rdf"&&n.name==="Literal")return!0;let t=x(e,n);return t?B.isDatatypeType(We(t)):!1}isNumericDatatypeRange(e){return!e||e.publisher===xe&&e.package_==="core-rdf"&&e.name==="Literal"?!0:e.publisher===xe&&e.package_==="core-xsd"&&On.has(e.name)}err(e,n,t,o,s,r){let i=new g;return i.ruleType=this.ruleName,i.severity=t,i.entityName=e,i.propertyName=n,i.message=o,i.suggestion=s,r!==void 0&&(i.actualValue=r),i}};function Ve(y){return typeof y=="number"?y:void 0}function X(y){return`${y.publisher}/${y.package_}/${y.name}`}function Sn(y){let e=y.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}var yt={publisher:"kanonak.org",package_:"core-owl",name:"oneOf"},$n=y=>y,De=class{ruleName="OwlOneOf";async validateAsync(e,n,t){let o=[],s=t?await t.getKanonaks():await new A().parseKanonaks(n),r=Kn(e);if(!r)return o;for(let i of s){if(!(i instanceof I)||i.namespace!==r||!Ne(i,yt))continue;let a=S(i,yt);if(a.length===0){o.push(this.err(i.name,"Warning",`owl:oneOf on '${i.name}' is empty; a closed enumeration must list at least one individual.`,"List the individuals that make up the enumeration, or remove owl:oneOf."));continue}for(let c of a)if(c instanceof je)o.push(this.err(i.name,"Error",`owl:oneOf member '${String(c.value)}' on '${i.name}' is not a named individual; a class enumeration is of individuals (a misspelled or unimported individual reads as a literal). For a closed set of literal VALUES, constrain a property with sh:in instead.`,"Reference a defined or imported individual, or move literal value sets to a property sh:in.",String(c.value)));else if(c instanceof H){let p=x(s,c.subject);p&&B.isSchemaDefinitionType($n(p))&&o.push(this.err(i.name,"Error",`owl:oneOf member '${c.subject.name}' on '${i.name}' is a class/property/datatype, not an individual.`,"List named individuals (instances), not schema definitions.",`${c.subject.publisher}/${c.subject.package_}/${c.subject.name}`))}}return o}err(e,n,t,o,s){let r=new g;return r.ruleType=this.ruleName,r.severity=n,r.entityName=e,r.propertyName="oneOf",r.message=t,r.suggestion=o,s!==void 0&&(r.actualValue=s),r}};function Kn(y){let e=y.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}var Cn="kanonak.org",wn="core-shacl",j=y=>({publisher:Cn,package_:wn,name:y}),jn=j("NodeShape"),Nn=j("targetClass"),Tn=j("property"),xn=j("path"),_n=j("minCount"),Un=j("maxCount"),Ln=j("in"),Mn=j("pattern"),Wn=j("flags"),Hn=j("minLength"),Bn=j("maxLength"),Fn=j("minInclusive"),Xn=j("maxInclusive"),qn=j("message");function Ae(y){return typeof y=="number"?y:void 0}function zn(y){let e={},n=Ae(w(y,_n)),t=Ae(w(y,Un));n!==void 0&&(e.minCount=n),t!==void 0&&(e.maxCount=t);let o=Ae(w(y,Hn)),s=Ae(w(y,Bn));o!==void 0&&(e.minLength=o),s!==void 0&&(e.maxLength=s);let r=Ae(w(y,Fn)),i=Ae(w(y,Xn));r!==void 0&&(e.minInclusive=r),i!==void 0&&(e.maxInclusive=i);let a=L(y,Mn);if(a!==void 0){let l=L(y,Wn);e.pattern=l!==void 0?{regex:a,flags:l}:{regex:a}}let c=S(y,Ln).filter(l=>l instanceof je).map(l=>l.value);c.length>0&&(e.enumValues=c);let p=L(y,qn);return p!==void 0&&(e.message=p),e}function Yn(y,e){let n=[];for(let t of S(e,Tn))if(t instanceof D)n.push(t);else if(t instanceof H){let o=x(y,t.subject);o&&n.push(o)}return n}function mt(y){let e=new Map;for(let n of y){if(!(n instanceof I)||!E(n,jn))continue;let t=V(n,Nn);if(!t)continue;let o=C(t);for(let s of Yn(y,n)){let r=V(s,xn);if(!r)continue;let i={pathKey:C(r),constraints:zn(s)},a=e.get(o);a?a.push(i):e.set(o,[i])}}return e}function Gn(y,e){e.minCount!==void 0&&(y.minCount=e.minCount),e.maxCount!==void 0&&(y.maxCount=e.maxCount),e.minLength!==void 0&&(y.minLength=e.minLength),e.maxLength!==void 0&&(y.maxLength=e.maxLength),e.minInclusive!==void 0&&(y.minInclusive=e.minInclusive),e.maxInclusive!==void 0&&(y.maxInclusive=e.maxInclusive),e.pattern!==void 0&&(y.pattern=e.pattern),e.enumValues!==void 0&&(y.enumValues=e.enumValues),e.message!==void 0&&(y.message=e.message)}function ut(y,e,n){let t=C(n),o=!1,s={};for(let r=e.length-1;r>=0;r--){let i=y.get(C(e[r]));if(i)for(let a of i)a.pathKey===t&&(o=!0,Gn(s,a.constraints))}if(o)return s.cardinality=s.maxCount===1?"single":"list",s.required=(s.minCount??0)>=1,s}var Zn=y=>y,Jn=new Fe("kanonak.org","core-rdf","Resource"),Ee=class{ruleName="DiamondNameClash";async validateAsync(e,n,t){let o=[],s=t?await t.getKanonaks():await new A().parseKanonaks(n),r=Qn(e);if(!r)return o;let i=mt(s);for(let a of s){if(!(a instanceof I)||a.namespace!==r||!B.isClassType(Zn(a)))continue;let c=W(a);if(!c)continue;let p=Ze(s,c),l=C(c),m=new Set(p.map(f=>C(f)));m.delete(l),m.delete(C(Jn));let u=new Map;for(let f of Je(s,c)){if(!f.domains.some(h=>m.has(C(h))))continue;let k=u.get(f.uri.name);k?k.push(f):u.set(f.uri.name,[f])}for(let[f,d]of u){if(d.length<2)continue;let k=K=>ut(i,p,K.uri)?.cardinality,h=new Set(d.map(K=>K.range?C(K.range):void 0).filter(K=>K!==void 0)),v=new Set(d.map(k).filter(K=>K!==void 0));h.size<=1&&v.size<=1||o.push(this.toError(a.name,f,d,k))}}return o}toError(e,n,t,o){let s=a=>{let c=`${a.uri.publisher}/${a.uri.package_}/${a.uri.name}`,p=a.range?`${a.range.publisher}/${a.range.package_}/${a.range.name}`:"no range",l=o(a);return`${c} (range ${p}${l?`, ${l}`:""})`},r=t.map(s).join("; "),i=new g;return i.ruleType=this.ruleName,i.severity="Error",i.entityName=e,i.propertyName=n,i.actualValue=r,i.message=`Class '${e}' inherits ${t.length} distinct properties named '${n}' with incompatible range or cardinality: ${r}. The generated interface would multiply-inherit '${n}' with conflicting types and could not compile.`,i.suggestion=`Disambiguate the diamond name-clash on '${n}':
81
+ \u2022 rename one of the properties, or
82
+ \u2022 re-domain one so it is not inherited by '${e}', or
83
+ \u2022 restructure the hierarchy so '${e}' inherits only one '${n}', or
84
+ \u2022 make the ranges/cardinalities compatible (identical) if they are meant to be the same property.`,i}};function Qn(y){let e=y.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}var He=class{parser;documentRules;repositoryRules;includeWarnings=!0;constructor(e){this.parser=e??new Be,this.documentRules=[new z,new Y,new G,new Z],this.repositoryRules=[new J,new Q,new ee,new te,new ne,new oe,new re,new ie,new se,new ae,new ce,new pe,new le,new ye,new me,new ue,new fe,new de,new ge,new he,new ke,new be,new Ce,new Re,new Ie,new De,new Ee]}async validateAsync(e,n,t){let o=new q;for(let s of this.documentRules)try{let r=s.validate(e);this.addErrorsToResult(o,r)}catch(r){let i=new g;i.ruleType=s.ruleName,i.severity="Error",i.message=`Validation rule '${s.ruleName}' failed: ${r instanceof Error?r.message:String(r)}`,o.errors.push(i)}if(n){let s=[],r=t?.repository??n;for(let i of this.repositoryRules)try{let a=await i.validateAsync(e,r,t);this.addErrorsToResult(o,a)}catch(a){let c=a instanceof Error?a.message:String(a);s.push({ruleName:i.ruleName,cause:c})}if(s.length>0){let i=new Map;for(let{ruleName:a,cause:c}of s){let p=i.get(c);p?p.push(a):i.set(c,[a])}for(let[a,c]of i){let p=new g;p.ruleType=c[0],p.severity="Error",c.length===1?p.message=`Validation rule '${c[0]}' failed: ${a}`:p.message=`${a} (affects ${c.length} rules: ${c.join(", ")})`,o.errors.push(p)}}}return o.isValid=o.errors.length===0,o}async validateDocumentsAsync(e,n){let t=new Oe(n),o=[];for(let s of e){let r=await this.validateAsync(s,t.repository,t);o.push({document:s,result:r})}return o}async validateYamlAsync(e,n,t){let o=this.parser.parseWithErrors(e);if(!o.isValid){let s=new q;s.isValid=!1;for(let r of o.errors){let i=new g;i.ruleType="ParseError",i.severity="Error",i.lineNumber=r.line,i.column=r.column,i.message=r.message,r.keyName&&(i.entityName=r.keyName),r.errorType==="DuplicateKey"&&(i.suggestion="All property names must be unique across the entire document. Rename one of the duplicate properties to make them unique."),s.errors.push(i)}return s}return await this.validateAsync(o.document,n,t)}addDocumentRule(e){this.documentRules.push(e)}addRepositoryRule(e){this.repositoryRules.push(e)}removeDocumentRule(e){let n=this.documentRules.findIndex(t=>t instanceof e);n>=0&&this.documentRules.splice(n,1)}removeRepositoryRule(e){let n=this.repositoryRules.findIndex(t=>t instanceof e);n>=0&&this.repositoryRules.splice(n,1)}addErrorsToResult(e,n){for(let t of n)t.severity==="Error"?e.errors.push(t):this.includeWarnings&&e.warnings.push(t)}};export{q as a,b,g as c,_e as d,Oe as e,z as f,Y as g,G as h,Z as i,J as j,Q as k,ee as l,te as m,ne as n,oe as o,re as p,ie as q,se as r,ae as s,ce as t,pe as u,le as v,ye as w,me as x,ue as y,fe as z,de as A,ge as B,he as C,ke as D,be as E,Re as F,Ie as G,De as H,mt as I,ut as J,Ee as K,He as L};
@@ -0,0 +1,2 @@
1
+ import{I as W,J as X}from"./chunk-V3YPCUA6.js";import{b as B,c as V,w}from"./chunk-WUAKDYY6.js";import{a as b,d as K,e as q,f as z}from"./chunk-NC3FSY3R.js";import{a as D,f as E,h as F,j as N,k as Y,m as v}from"./chunk-PBNVHBS3.js";import{c as G,d as x}from"./chunk-T3JR2SV6.js";import{a as L}from"./chunk-FUUTGGJS.js";import{d as U}from"./chunk-2ACBWC7K.js";var Q=(t=>(t.Class="Class",t.DatatypeProperty="DatatypeProperty",t.ObjectProperty="ObjectProperty",t.AnnotationProperty="AnnotationProperty",t.Instance="Instance",t.Datatype="Datatype",t.Unknown="Unknown",t))(Q||{}),Z=(p=>(p.InstanceOf="instanceOf",p.SubClassOf="subClassOf",p.Domain="domain",p.Range="range",p.ObjectRelationship="objectRelationship",p.SubPropertyOf="subPropertyOf",p.PropertyValue="propertyValue",p.EmbeddedLink="embeddedLink",p))(Z||{}),I=class{static async buildFromRepository(e){let a=await new w().parseKanonaks(e),o=await e.getAllDocumentsAsync(),s=[],i=[],t=new Set,p=new Set,g=new Map;for(let u of a){let l=u;l.name&&(b.isClassType(l)&&t.add(l.name),(b.isObjectPropertyType(l)||b.isGenericPropertyType(l))&&p.add(l.name))}for(let u of o)for(let[l,f]of Object.entries(u.body))p.has(l)&&f?.range&&typeof f.range=="string"&&g.set(l,f.range);let y=new Map;for(let u of a){let l=u;l.name&&y.set(l.name,l)}for(let u of o){let l=u.metadata.namespace_,f=l?`${l.publisher}/${l.package_}`:"",c=l?.version?`${l.version.major}.${l.version.minor}.${l.version.patch}`:"",d=H(u);for(let[k,m]of Object.entries(u.body)){if(!m||typeof m!="object")continue;let P=y.get(k),h="Unknown";if(P){let T=P;b.isClassType(T)?h="Class":b.isObjectPropertyType(T)?h="ObjectProperty":b.isDatatypePropertyType(T)?h="DatatypeProperty":b.isAnnotationPropertyType(T)?h="AnnotationProperty":b.isDatatypeType(T)?h="Datatype":b.isGenericPropertyType(T)?h="ObjectProperty":b.isInstanceOfKnownClass(T,t)&&(h="Instance")}let j=f&&c?`${f}/${k}@${c}`:k,A={};for(let[T,$]of Object.entries(m))T!=="type"&&(typeof $!="object"||$===null)&&(A[T]=$);s.push({id:j,label:m.label??k,type:h,namespace:f,properties:A}),J(j,m,h,t,p,i,f,c,d),_(j,m,p,g,s,i,f,c,d),ue(j,P,i)}}return{nodes:s,edges:i}}static buildFromDocument(e){let r=[],a=[],o=e.metadata.namespace_,s=o?.version?`${o.version.major}.${o.version.minor}.${o.version.patch}`:"",i=o?`${o.publisher}/${o.package_}`:"",t=new Set,p=new Set,g=new Map,y=H(e);for(let[f,c]of Object.entries(e.body)){let d=c?.type;d&&(pe(d,y)&&t.add(f),ce(d,y)&&(p.add(f),c.range&&typeof c.range=="string"&&g.set(f,c.range)))}for(let[f,c]of Object.entries(e.body)){if(!c||typeof c!="object")continue;let d=c.type,k=le(d,f,t,y),m=i&&s?`${i}/${f}@${s}`:f,P={};for(let[h,j]of Object.entries(c))h!=="type"&&(typeof j!="object"||j===null)&&(P[h]=j);r.push({id:m,label:c.label??f,type:k,namespace:i,properties:P}),J(m,c,k,t,p,a,i,s,y),_(m,c,p,g,r,a,i,s,y)}let u=new Set(r.map(f=>f.id)),l=a.filter(f=>u.has(f.source)&&u.has(f.target));return{nodes:r,edges:l}}};function H(n,e){let r=new Map;if(n.metadata?.imports)for(let[a,o]of Object.entries(n.metadata.imports))for(let s of o){let i=s.alias??s.packageName,t=s.version,p=`${t.major}.${t.minor}.${t.patch}`;r.set(i,{publisher:a,package_:s.packageName,version:p})}return r}var ee={"kanonak.org/core-rdf/Class":"Class","kanonak.org/core-owl/Class":"Class","kanonak.org/core-rdfs/Class":"Class","kanonak.org/core-owl/ObjectProperty":"ObjectProperty","kanonak.org/core-owl/DatatypeProperty":"DatatypeProperty","kanonak.org/core-owl/AnnotationProperty":"AnnotationProperty","kanonak.org/core-rdf/Property":"ObjectProperty","kanonak.org/core-rdfs/Datatype":"Datatype"},ie=new Set(["kanonak.org/core-owl/ObjectProperty","kanonak.org/core-owl/DatatypeProperty","kanonak.org/core-owl/AnnotationProperty","kanonak.org/core-rdf/Property"]);function M(n,e){if(n.includes(".")){let r=n.indexOf("."),a=n.substring(0,r),o=n.substring(r+1),s=e.get(a);if(s)return`${s.publisher}/${s.package_}/${o}`}return null}function pe(n,e){let r=M(n,e);return r?ee[r]==="Class":!1}function ce(n,e){let r=M(n,e);return r?ie.has(r):!1}function le(n,e,r,a){if(!n||n==="Package")return"Unknown";let o=M(n,a);if(o){let i=ee[o];if(i)return i;let t=o.split("/").pop()?.split("@")[0]??"";return r.has(t)?"Instance":"Unknown"}let s=n.split(".").pop()??n;return r.has(s)?"Instance":"Unknown"}var ne=new Set(["type","label","comment","version","publisher","imports","license","match","alias","package"]);function J(n,e,r,a,o,s,i,t,p){let g=e.type,y=e.subClassOf;if(y){let c=Array.isArray(y)?y:[y];for(let d of c)typeof d=="string"&&s.push({source:n,target:O(d,i,t,p),type:"subClassOf",label:"subClassOf"})}let u=e.subPropertyOf;if(u){let c=Array.isArray(u)?u:[u];for(let d of c)typeof d=="string"&&s.push({source:n,target:O(d,i,t,p),type:"subPropertyOf",label:"subPropertyOf"})}if(r==="Instance"&&g){let c=g.split(".").pop()??g;s.push({source:n,target:O(c,i,t,p),type:"instanceOf",label:"type"})}if(r==="Instance")for(let[c,d]of Object.entries(e)){if(ne.has(c)||!o.has(c))continue;let k=Array.isArray(d)?d:[d];for(let m of k)typeof m=="string"&&fe(m)&&s.push({source:n,target:O(m,i,t,p),type:"propertyValue",label:c,propertyId:O(c,i,t,p)})}let l=r==="ObjectProperty"||r==="DatatypeProperty",f=e.domain&&e.range;if((l||f)&&e.domain&&e.range){let c=typeof e.domain=="string"?e.domain:null,d=typeof e.range=="string"?e.range:null;c&&d&&s.push({source:O(c,i,t,p),target:O(d,i,t,p),type:"objectRelationship",label:e.label??n.split("/").pop()??"",propertyId:n})}}function _(n,e,r,a,o,s,i,t,p){for(let[g,y]of Object.entries(e)){if(ne.has(g)||typeof y!="object"||y===null||Array.isArray(y))continue;let u=y,l=`${n}/${g}`,f=a.get(g),c=f?f.split(".").pop()??f:"Unknown",d={};for(let[m,P]of Object.entries(u))(typeof P!="object"||P===null)&&(d[m]=P);o.push({id:l,label:`${c} (embedded)`,type:"Instance",namespace:i,properties:d});let k=i&&t?`${i}/${g}@${t}`:g;s.push({source:n,target:l,type:"propertyValue",label:g,propertyId:r.has(g)?k:void 0}),f&&s.push({source:l,target:O(c,i,t,p),type:"instanceOf",label:"type (inferred)"}),_(l,u,r,a,o,s,i,t,p)}}function ue(n,e,r){let a=e?.statement;if(Array.isArray(a))for(let o of a){if(!(o instanceof V))continue;let s=o.predicate?.subject?.name??"";for(let i of o.links){let t=i.target?.subject;if(!t)continue;let p=t.version,g=p&&typeof p.major=="number"?`@${p.major}.${p.minor}.${p.patch}`:"";r.push({source:n,target:`${t.publisher}/${t.package_}/${t.name}${g}`,type:"embeddedLink",label:s})}}}function fe(n){return!(!n||n.includes(" ")||n.includes(`
2
+ `)||n.startsWith("http://")||n.startsWith("https://")||/^\d{4}-\d{2}/.test(n)||/^\d+(\.\d+)?$/.test(n))}function O(n,e,r,a){if(n.includes("@")&&n.includes("/"))return n;if(n.includes(".")){let o=n.indexOf("."),s=n.substring(0,o),i=n.substring(o+1);if(a){let t=a.get(s);if(t)return`${t.publisher}/${t.package_}/${i}@${t.version}`}return e&&r?`${e}/${i}@${r}`:i}return e&&r?`${e}/${n}@${r}`:n}function de(n){if(!n.expiresAt)return!1;let e=new Date(n.expiresAt),r=300*1e3;return e.getTime()<=Date.now()+r}function Re(n){return!!n.accessToken&&!de(n)}function Se(n){let e=n.replace(/^https?:\/\//,"").replace(/^git:\/\//,"").replace(/\/+$/,"").trim();if(!e)throw new Error("Publisher host cannot be empty");return e}var C="kanonak.org",S="core-rdf",re="core-xsd",te={publisher:C,package_:S,name:"subClassOf"},oe={publisher:C,package_:S,name:"label"},ye={publisher:C,package_:S,name:"comment"},se={publisher:C,package_:"core-owl",name:"oneOf"},ae=n=>n;function ge(n){let e=Y(n,te);if(e)return[e];let r=[];for(let a of v(n,te))a instanceof x&&r.push(a.subject);return r}function me(n,e,r){if(e.publisher===C&&e.package_===S&&e.name==="Literal")return{kind:"datatype",uri:e};let o=E(n,e);if(o){let s=ae(o);if(b.isDatatypeType(s))return{kind:"datatype",uri:e};if(b.isClassType(s))return{kind:"class",uri:K(o)??e,localName:o.name}}return e.publisher===C&&e.package_===re?{kind:"datatype",uri:e}:r==="datatype"?{kind:"datatype",uri:e}:{kind:"class",uri:e,localName:e.name}}function be(n,e,r){if(!e.range)throw new Error(`Property ${e.uri.publisher}/${e.uri.package_}/${e.uri.name} has no rdfs.range; every property must declare a range. Validate the ontology before introspecting it.`);let a=me(n,e.range,e.kind),o=e.kind==="object"?"object":e.kind==="datatype"?"datatype":a.kind==="class"?"object":"datatype";return{uri:e.uri,localName:e.uri.name,kind:o,range:a,...e.label!==void 0?{label:e.label}:{},...e.comment!==void 0?{comment:e.comment}:{},...r??{}}}var R=n=>new L(C,re,n);function ke(n){return typeof n=="boolean"?R("boolean"):typeof n=="number"?Number.isInteger(n)?R("integer"):R("decimal"):R("string")}function he(n,e){let r=[];for(let a of v(e,se))if(a instanceof x){let o=E(n,a.subject),s=(o?K(o):void 0)??a.subject,i=o?N(o,oe):void 0;r.push({kind:"individual",uri:s,localName:s.name,...i!==void 0?{label:i}:{}})}else a instanceof B&&r.push({kind:"literal",value:a.value,datatype:ke(a.value)});return r}function Pe(n,e,r,a){let o=q(n,e),s=D(e);return z(n,e).filter(t=>r?!0:t.domains.some(p=>D(p)===s)).map(t=>be(n,t,X(a,o,t.uri)))}async function Te(n,e,r){let a=n.metadata?.namespace_;if(!a)throw new Error("buildOntologyModel: document has no namespace (publisher/package/version).");let o=r?.includeInherited??!1,s=await new w().parseKanonaks(e),i=W(s),t=[],p=[],g=new Set;for(let y of s){if(!(y instanceof G)||!b.isClassType(ae(y)))continue;let u=K(y);if(!u||u.publisher!==a.publisher||u.package_!==a.package_||u.version&&a.version&&!U(u.version,a.version))continue;let l=D(u);if(g.has(l))continue;g.add(l);let f=ge(y).map(k=>({uri:k,localName:k.name})),c=N(y,oe),d=N(y,ye);t.push({uri:u,localName:u.name,superClasses:f,properties:Pe(s,u,o,i),...c!==void 0?{label:c}:{},...d!==void 0?{comment:d}:{}}),F(y,se)&&p.push({uri:u,localName:u.name,members:he(s,y),...c!==void 0?{label:c}:{},...d!==void 0?{comment:d}:{}})}return{classes:t,enums:p}}export{Q as a,Z as b,I as c,de as d,Re as e,Se as f,Te as g};