@kanonak-protocol/sdk 5.33.0 → 5.35.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 (42) hide show
  1. package/dist/browser.d.ts +2 -0
  2. package/dist/browser.js +1 -1
  3. package/dist/{chunk-EVMSO7HJ.js → chunk-26SO3A4B.js} +1 -1
  4. package/dist/{chunk-PRXC2HZ3.js → chunk-2Y6R3K5A.js} +1 -1
  5. package/dist/chunk-54D47DLS.js +1 -0
  6. package/dist/chunk-AVVLDZAZ.js +68 -0
  7. package/dist/chunk-D7QLWVPK.js +155 -0
  8. package/dist/chunk-JHQPXEMA.js +1 -0
  9. package/dist/chunk-MQBWSCNY.js +1 -0
  10. package/dist/{chunk-PXS6XZ3V.js → chunk-O35Y6QUW.js} +1 -1
  11. package/dist/{chunk-BS7RRG7D.js → chunk-VEGFYZXG.js} +1 -1
  12. package/dist/chunk-ZYDJUGIA.js +1 -0
  13. package/dist/index.d.ts +2 -0
  14. package/dist/index.js +1 -1
  15. package/dist/kanonaks/EmbeddedKanonak.d.ts +13 -0
  16. package/dist/look/LookRenderer.d.ts +10 -5
  17. package/dist/parsing/index.js +1 -1
  18. package/dist/producer/index.js +1 -1
  19. package/dist/reasoning/index.js +1 -1
  20. package/dist/resolution/TypeDirectedResolver.d.ts +12 -2
  21. package/dist/resolution/index.js +1 -1
  22. package/dist/search/index.js +1 -1
  23. package/dist/server/index.js +1 -1
  24. package/dist/shacl/ConformanceEvaluator.d.ts +13 -3
  25. package/dist/shacl/ShapesModel.d.ts +28 -0
  26. package/dist/shacl/lowering.d.ts +3 -2
  27. package/dist/shacl/uris.d.ts +7 -0
  28. package/dist/transformations/index.js +1 -1
  29. package/dist/uri-helpers/PropertyValues.d.ts +74 -0
  30. package/dist/uri-helpers/UriHelpers.d.ts +37 -5
  31. package/dist/uri-helpers/index.d.ts +4 -2
  32. package/dist/uri-helpers/index.js +1 -1
  33. package/dist/validation/index.js +1 -1
  34. package/dist/validation/rules/repository/PropertyDomainRule.d.ts +6 -0
  35. package/dist/validation/rules/repository/ShaclShapeRule.d.ts +13 -0
  36. package/package.json +2 -2
  37. package/dist/chunk-7UYXTYXC.js +0 -1
  38. package/dist/chunk-C63WFML4.js +0 -68
  39. package/dist/chunk-CJMVIOZX.js +0 -1
  40. package/dist/chunk-HENE47QG.js +0 -155
  41. package/dist/chunk-L2J7WD7E.js +0 -1
  42. package/dist/chunk-PVUBHIU2.js +0 -1
@@ -0,0 +1 @@
1
+ import{B as j,C as W,c as B,d as G,o as b,p as X,r as Y,s as H,w as q,x as M}from"./chunk-54D47DLS.js";import{a as _}from"./chunk-FUUTGGJS.js";import{b as I}from"./chunk-F67UH4FD.js";var Q=class{cache=new Map;repository;logger;constructor(e,n){this.repository=e,this.logger=n}async resolveEntityAsync(e,n){let r=n.metadata?.namespace_?.toString()??"unknown",s=this.cache.get(r);if(s){let i=s.get(e);if(i)return i}let a=await this.buildEntityIndexAsyncInternal(n,new Set,"",new Map);return this.cache.set(r,a),a.get(e)??null}async resolveAllEntitiesAsync(e,n){let r=await this.buildAllEntitiesIndexAsync(n,new Set,"");if(e.includes(".")){let s=e.split("."),a=s[0],i=s[1],u=await this.findDocumentForAlias(n,a);return u?await this.resolveAllEntitiesAsync(i,u):[]}return r.filter(s=>s.entityName===e)}async buildAllEntitiesIndexAsync(e,n,r){let s=[],a=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building ALL entities index for namespace: ${a}`),n.has(a))return this.logger?.debug?.(`Skipping ${a} - already visited (circular import prevention)`),s;n.add(a);let i=r.length===0?a:`${r} \u2192 ${a}`;for(let[u,c]of Object.entries(e.body))if(!u.includes(".")&&c&&typeof c=="object"&&!Array.isArray(c)){if(!e.metadata.namespace_)continue;let g=e.metadata.namespace_.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};s.push({entityName:u,uri:new _(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,u,g),entity:c,definedInNamespace:a,isImported:r.length>0,importPath:i})}if(this.logger?.debug?.(`Collected ${s.length} entities from ${a}`),e.metadata?.imports){let u=Object.values(e.metadata.imports).reduce((c,g)=>c+g.length,0);this.logger?.debug?.(`Processing ${u} import(s) for ${a}`);for(let[c,g]of Object.entries(e.metadata.imports))for(let m of g)if(!I(m))try{this.logger?.debug?.(`Resolving import: ${c}/${m.packageName}`);let d=await this.repository.getHighestCompatibleVersionAsync(c,m);if(d){this.logger?.debug?.(`Successfully loaded import: ${d.metadata?.namespace_?.toString()}`);let k=await this.buildAllEntitiesIndexAsync(d,n,i);s.push(...k),this.logger?.debug?.(`Added ${k.length} entities from import ${d.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${c}/${m.packageName}`)}catch(d){let k=d;throw this.logger?.error?.(`Failed to process import ${c}/${m.packageName} for namespace ${a}. Error: ${k.message}`,k),new Error(`Failed to process import ${c}/${m.packageName} for namespace ${a}. See inner exception for details.`,{cause:d})}}return s}async buildEntityIndexAsync(e){return await this.buildEntityIndexAsyncInternal(e,new Set,"",new Map)}async buildEntityIndexAsyncInternal(e,n,r,s){let a=new Map,i=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building entity index for namespace: ${i}`),n.has(i))return this.logger?.debug?.(`Skipping ${i} - circular import in progress`),a;let u=s.get(i);if(u)return u;n.add(i);let c=r.length===0?i:`${r} \u2192 ${i}`,g=0;for(let[m,d]of Object.entries(e.body))if(!m.includes(".")&&d&&typeof d=="object"&&!Array.isArray(d)){if(!e.metadata.namespace_)continue;if(!a.has(m)){let k=e.metadata.namespace_.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};a.set(m,{entityName:m,uri:new _(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,m,k),entity:d,definedInNamespace:i,isImported:r.length>0,importPath:c}),g++}}if(this.logger?.debug?.(`Indexed ${g} entities from ${i}`),e.metadata?.imports){let m=Object.values(e.metadata.imports).reduce((d,k)=>d+k.length,0);this.logger?.debug?.(`Processing ${m} import(s) for ${i}`);for(let[d,k]of Object.entries(e.metadata.imports))for(let S of k)if(!I(S))try{this.logger?.debug?.(`Resolving import: ${d}/${S.packageName}`);let P=await this.repository.getHighestCompatibleVersionAsync(d,S);if(P){this.logger?.debug?.(`Successfully loaded import: ${P.metadata?.namespace_?.toString()}`);let U=await this.buildEntityIndexAsyncInternal(P,n,c,s),v=0;for(let[x,C]of U.entries()){let h=a.get(x);if(!h)a.set(x,C),v++;else if(h.isImported&&C.isImported&&(h.uri.publisher!==C.uri.publisher||h.uri.package_!==C.uri.package_)){let E=h.isAmbiguous?h:{...h,isAmbiguous:!0,ambiguousNamespaces:[h.definedInNamespace]};E.ambiguousNamespaces.includes(C.definedInNamespace)||E.ambiguousNamespaces.push(C.definedInNamespace),a.set(x,E),this.logger?.warn?.(`Ambiguous reference '${x}': defined in ${E.ambiguousNamespaces.join(", ")}`)}if(S.alias&&!x.includes(".")){let E=`${S.alias}.${x}`;a.has(E)||(a.set(E,C),v++)}}this.logger?.debug?.(`Merged ${v} entities from import ${P.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${d}/${S.packageName}`)}catch(P){let U=P;throw this.logger?.error?.(`Failed to process import ${d}/${S.packageName} for namespace ${i}. Error: ${U.message}`,U),new Error(`Failed to process import ${d}/${S.packageName} for namespace ${i}. See inner exception for details.`,{cause:P})}}return n.delete(i),s.set(i,a),a}async findDocumentForAlias(e,n){if(!e.metadata?.imports)return null;for(let[r,s]of Object.entries(e.metadata.imports))for(let a of s)if(!I(a)){if(a.alias===n)return await this.repository.getHighestCompatibleVersionAsync(r,a);if(!a.alias&&a.packageName===n)return await this.repository.getHighestCompatibleVersionAsync(r,a)}return null}clearCache(){this.cache.clear()}clearCacheForDocument(e){this.cache.delete(e)}};var z=class t{static KNOWN_XSD_DATATYPES=new Set(["string","integer","int","boolean","decimal","float","double","date","datetime","time","duration","anyuri","base64binary","hexbinary","long","short","byte","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte"]);resourceResolver;constructor(e){this.resourceResolver=e}isXsdDatatype(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-xsd"&&t.KNOWN_XSD_DATATYPES.has(e.name.toLowerCase()):!1}isLiteralType(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-rdf"&&e.name==="Literal":!1}isMarkdownDatatype(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-prose"&&e.name==="Markdown":!1}isSubstitutableDatatype(e){return t.isSubstitutableDatatypeUri(e)}static isSubstitutableDatatypeUri(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-prose"&&(e.name==="SubstitutableString"||e.name==="Markdown"):!1}isKnownXsdDatatypeName(e){let n=e.includes(".")?e.split(".")[1]:e;return t.KNOWN_XSD_DATATYPES.has(n.toLowerCase())}async isClassTypeAsync(e,n){if(this.isKnownXsdDatatypeName(e))return!1;let r=await this.resourceResolver.resolveEntityAsync(e,n);if(r){let s=r.entity.type;if(s){let a=String(s);return a==="Class"||a==="rdfs.Class"||a.endsWith(".Class")}}return!0}getPropertyTypeClassification(e){if(!e||e.trim().length===0)return"Property";switch(e.includes(".")?e.split(".")[1]:e){case"DatatypeProperty":return"DatatypeProperty";case"ObjectProperty":return"ObjectProperty";case"AnnotationProperty":return"AnnotationProperty";case"Property":return"Property";default:return"Property"}}isEffectiveDatatypeProperty(e,n){return!!(e==="DatatypeProperty"||e==="Property"&&this.isXsdDatatype(n)||e==="Property"&&this.isLiteralType(n))}isEffectiveObjectProperty(e,n){return!!(e==="ObjectProperty"||e==="Property"&&n&&!this.isXsdDatatype(n)&&!this.isLiteralType(n))}};function J(t){if(!t||t.trim().length===0)throw new Error("Kanonak address string cannot be null or empty");let e=t.trim(),n=e.split("/");if(n.length===1){let r=n[0];if(!r)throw new Error(`Invalid Kanonak address: "${t}". Expected publisher, publisher/package[@version], or publisher/package[@version]/name.`);if(r.includes("@"))throw new Error(`Invalid Kanonak address: "${t}". A bare publisher cannot carry an @version qualifier \u2014 versions belong to packages.`);return{kind:"publisher",publisher:r}}if(n.length===2){let[r,s]=n;if(!r||!s)throw new Error(`Invalid Kanonak address: "${t}". Expected publisher/package[@version].`);let a=s.indexOf("@");if(a===-1)return{kind:"package",publisher:r,package_:s};let i=s.substring(0,a),u=s.substring(a+1);if(!i||!u)throw new Error(`Invalid Kanonak address: "${t}". Expected publisher/package[@version].`);let c=ae(u);return{kind:"package",publisher:r,package_:i,version:c}}return{kind:"resource",uri:_.parse(e)}}function He(t){switch(t.kind){case"publisher":return t.publisher;case"package":return t.version?`${t.publisher}/${t.package_}@${t.version.major}.${t.version.minor}.${t.version.patch}`:`${t.publisher}/${t.package_}`;case"resource":return t.uri.toString()}}function ae(t){let e=t.split(".").map(Number);return se(e[0]||0,e[1]||0,e[2]||0)}function se(t,e,n){return{major:t,minor:e,patch:n,toString:()=>`${t}.${e}.${n}`,equals:r=>!r||typeof r!="object"?!1:r.major===t&&r.minor===e&&r.patch===n,getHashCode:()=>t<<20|e<<10|n,compareTo:r=>t!==r.major?t-r.major:e!==r.minor?e-r.minor:n-r.patch}}function Ne(t){return`${t.publisher}/${t.package_}/${t.name}`}function y(t,e,n){return`${t}/${e}/${n}`}function Te(t){return`${t.s}|${t.p}|${ie(t.o)}`}function ie(t){switch(t.kind){case"uri":return`u:${t.key}`;case"literal":return`l:${t.datatype}:${t.lexical}`;case"blank":return`b:${t.id}`}}function $e(t,e,n){return{s:t,p:e,o:{kind:"uri",key:n}}}var pe="kanonak.org",ce="core-shacl",o=t=>({publisher:pe,package_:ce,name:t}),D=o("Shape"),N=o("NodeShape"),T=o("PropertyShape"),Me=o("targetClass"),je=o("property"),we=o("path"),Le=o("minCount"),Ve=o("maxCount"),Fe=o("datatype"),Be=o("class"),Ge=o("in"),Xe=o("pattern"),Ye=o("flags"),qe=o("minLength"),We=o("maxLength"),Qe=o("minInclusive"),ze=o("maxInclusive"),Je=o("message"),Ze=o("targetNode"),et=o("targetSubjectsOf"),tt=o("targetObjectsOf"),nt=o("closed"),rt=o("ignoredProperties"),ot=o("nodeKind"),at=o("IRI"),st=o("BlankNode"),it=o("Literal"),pt=o("severity"),ct=o("Violation"),lt=o("Warning"),ut=o("Info"),yt=o("ValidationReport"),dt=o("conforms"),mt=o("result"),gt=o("ValidationResult"),ft=o("focusNode"),kt=o("resultPath"),bt=o("resultMessage"),St=o("resultSeverity"),ht=o("sourceShape"),_t=o("value"),Pt=o("sourceConstraintComponent"),Ct=o("MinCountConstraintComponent"),Et=o("MaxCountConstraintComponent"),Kt=o("DatatypeConstraintComponent"),At=o("ClassConstraintComponent"),xt=o("InConstraintComponent"),Rt=o("PatternConstraintComponent"),Ot=o("MinLengthConstraintComponent"),Ut=o("MaxLengthConstraintComponent"),It=o("MinInclusiveConstraintComponent"),Ht=o("MaxInclusiveConstraintComponent"),Dt=o("NodeKindConstraintComponent"),Nt=o("ClosedConstraintComponent"),Tt=o("hasValue"),$t=o("qualifiedValueShape"),vt=o("qualifiedMinCount"),Mt=o("qualifiedMaxCount"),jt=o("HasValueConstraintComponent"),wt=o("QualifiedMinCountConstraintComponent"),Lt=o("QualifiedMaxCountConstraintComponent");var l="kanonak.org",p="core-rdf",f="core-owl",ee="core-kanonak",L=new Map([["type",p],["subClassOf",p],["subPropertyOf",p],["domain",p],["range",p],["label",p],["comment",p],["seeAlso",p],["isDefinedBy",p],["member",p],["Resource",p],["Class",p],["Property",p],["Datatype",p],["Literal",p],["List",p],["ObjectProperty",f],["DatatypeProperty",f],["AnnotationProperty",f],["Thing",f],["Nothing",f],["Package",ee]]),le=new Set(["type","subClassOf","subPropertyOf","domain","range"]);function Gt(t){return L.has(t)}function Xt(t){let e=L.get(t);return e?{publisher:l,package_:e}:void 0}function V(t,e,n){if(!t||!t.name)return;let r=L.get(t.name);if(!r)return;let s=()=>{t.publisher=l,t.package_=r,n&&(t.version=n.get(r))};if(le.has(t.name)){let a=t.publisher===l&&t.package_===r;t.publisher=l,t.package_=r,!a&&n&&(t.version=n.get(r));return}t.publisher===l&&t.package_===r||t.publisher&&t.publisher.length>0&&(!e||e(t))||s()}var Z=class{type=y(l,p,"type");subClassOf=y(l,p,"subClassOf");subPropertyOf=y(l,p,"subPropertyOf");domain=y(l,p,"domain");range=y(l,p,"range");label=y(l,p,"label");comment=y(l,p,"comment");resource=y(l,p,"Resource");class_=y(l,p,"Class");datatype=y(l,p,"Datatype");literal=y(l,p,"Literal");equivalentClass=y(l,f,"equivalentClass");equivalentProperty=y(l,f,"equivalentProperty");inverseOf=y(l,f,"inverseOf");sameAs=y(l,f,"sameAs");transitiveProperty=y(l,f,"TransitiveProperty");symmetricProperty=y(l,f,"SymmetricProperty");objectProperty=y(l,f,"ObjectProperty");datatypeProperty=y(l,f,"DatatypeProperty");annotationProperty=y(l,f,"AnnotationProperty");package_=y(l,ee,"Package");shape=w(D);nodeShape=w(N);propertyShape=w(T)};function w(t){return y(t.publisher,t.package_,t.name)}var ue=new Set(["kanonak.org/core-rdf","kanonak.org/core-owl","kanonak.org/core-xsd","kanonak.org/core-kanonak"]);function R(t){let e=t;if(e.entity&&typeof e.entity=="object"){let n=e.entity.type;if(typeof n=="string"){let s={publisher:"",package_:"",name:n.includes(".")?n.substring(n.lastIndexOf(".")+1):n};return V(s),{publisher:s.publisher,package_:s.package_,name:s.name}}}return ne(t)[0]??null}function ne(t){let e=t;if(e.entity&&typeof e.entity=="object"){let n=R(t);return n?[n]:[]}return Array.isArray(e.statement)?Y(t).map(n=>{let r={publisher:n.publisher??"",package_:n.package_??"",name:n.name};return V(r),{publisher:r.publisher,package_:r.package_,name:r.name}}):[]}var ye=[D,N,T];function O(t,e){return ue.has(`${t}/${e}`)}var de=new Set(["Property","ObjectProperty","DatatypeProperty","AnnotationProperty"]);function F(t){if(O(t.publisher,t.package_))return de.has(t.name)?t.name:void 0}var te=class t{static getTypeUri(e){return R(e)}static isCoreOntologyType(e){return O(e.publisher,e.package_)}static hasCoreType(e,n){return ne(e).some(r=>O(r.publisher,r.package_)&&r.name===n)}static isClassType(e){return t.hasCoreType(e,"Class")}static isDatatypeType(e){return t.hasCoreType(e,"Datatype")}static isDatatypePropertyType(e){return t.hasCoreType(e,"DatatypeProperty")}static isObjectPropertyType(e){return t.hasCoreType(e,"ObjectProperty")}static isAnnotationPropertyType(e){return t.hasCoreType(e,"AnnotationProperty")}static isGenericPropertyType(e){return t.hasCoreType(e,"Property")}static isAnyPropertyType(e){let n=R(e);return!n||!O(n.publisher,n.package_)?!1:n.name==="Property"||n.name==="DatatypeProperty"||n.name==="ObjectProperty"||n.name==="AnnotationProperty"}static isShapeType(e){let n=R(e);return n?ye.some(r=>X(n,r)):!1}static isSchemaDefinitionType(e){if(t.isShapeType(e))return!0;let n=R(e);return!n||!O(n.publisher,n.package_)?!1:n.name==="Class"||n.name==="Property"||n.name==="DatatypeProperty"||n.name==="ObjectProperty"||n.name==="AnnotationProperty"||n.name==="Datatype"}static isInstanceOfKnownClass(e,n){if(t.isSchemaDefinitionType(e))return!1;let r=R(e);return r?n.has(r.name):!1}};var K="kanonak.org",A="core-rdf",me={publisher:K,package_:A,name:"domain"},ge={publisher:K,package_:A,name:"range"},fe={publisher:K,package_:A,name:"subClassOf"},ke={publisher:K,package_:A,name:"type"},be={publisher:K,package_:A,name:"label"},Se={publisher:K,package_:A,name:"comment"},he=new _(K,A,"Resource");function _e(t){try{let e=J(`${t.namespace}/${t.name}`);return e.kind==="resource"?e.uri:void 0}catch{return}}function oe(t,e){let n=[],r=new Set,s="version"in e?e.version:void 0,a=[new _(e.publisher,e.package_,e.name,s??void 0)];for(;a.length>0;){let i=a.shift(),u=b(i);if(r.has(u))continue;r.add(u),n.push(i);let c=Pe(t,i);c&&a.push(...H(c,fe))}return n}function Pe(t,e){return e.version&&typeof e.version.major=="number"?q(t,e)??M(t,e)[0]:M(t,e)[0]}function $(t,e){let n;for(let r of Ae(e)){let s=Ce(t,r);if(s){if(s!=="Property")return s;n??=s}}return n}function Ce(t,e){let n=F(e);if(n)return n;let r=re.get(t);r||(r=new Map,re.set(t,r));let s=e.version,a=s&&typeof s.major=="number"?`${b(e)}@${s.major}.${s.minor}.${s.patch}`:b(e),i=r.get(a);if(i!==void 0)return i??void 0;let u;for(let c of oe(t,e)){let g=F(c);if(g){if(g!=="Property"){u=g;break}u??="Property"}}return r.set(a,u??null),u}var re=new WeakMap;function an(t,e){return $(t,e)!==void 0}function sn(t,e){return $(t,e)==="ObjectProperty"}function pn(t,e){return $(t,e)==="DatatypeProperty"}function Ee(t,e){let n=new Set([b(he)]);for(let r of oe(t,e))n.add(b(r));return n}function Ke(t,e){let n=Ee(t,e),r=[],s=new Set;for(let a of t){if(!(a instanceof B))continue;let i=$(t,a);if(!i)continue;let u=H(a,me);if(!u.some(m=>n.has(b(m))))continue;let c=_e(a);if(!c)continue;let g=b(c);s.has(g)||(s.add(g),r.push({uri:c,label:j(a,be),comment:j(a,Se),kind:i==="ObjectProperty"?"object":i==="DatatypeProperty"?"datatype":"other",range:W(a,ge),domains:u}))}return r}function cn(t,e,n){let r=Ke(t,e).find(s=>b(s.uri)===b(n));return r?{ok:!0,descriptor:r}:{ok:!1,message:`Property ${n.publisher}/${n.package_}/${n.name} is not in scope for ${e.publisher}/${e.package_}/${e.name}.`}}function Ae(t){let e=H(t,ke);return e.length>0?e:t instanceof G&&t.rangeType?[t.rangeType]:[]}export{Q as a,z as b,J as c,He as d,Ne as e,y as f,Te as g,ie as h,$e as i,pe as j,ce as k,D as l,N as m,T as n,Me as o,je as p,we as q,Le as r,Ve as s,Fe as t,Be as u,Ge as v,Xe as w,Ye as x,qe as y,We as z,Qe as A,ze as B,Je as C,Ze as D,et as E,tt as F,nt as G,rt as H,ot as I,at as J,st as K,it as L,pt as M,ct as N,lt as O,ut as P,Ct as Q,Et as R,Kt as S,At as T,xt as U,Rt as V,Ot as W,Ut as X,It as Y,Ht as Z,Dt as _,Nt as $,Tt as aa,$t as ba,vt as ca,Mt as da,jt as ea,wt as fa,Lt as ga,Gt as ha,Xt as ia,V as ja,Z as ka,F as la,te as ma,_e as na,oe as oa,$ as pa,an as qa,sn as ra,pn as sa,Ke as ta,cn as ua,Ae as va};
@@ -1,2 +1,2 @@
1
- import{e as R}from"./chunk-BZ3YTI3C.js";import{c as F,m as G}from"./chunk-PVUBHIU2.js";import{fa as S,ia as j}from"./chunk-7UYXTYXC.js";import{c as N}from"./chunk-CJMVIOZX.js";var z=(r=>(r.Class="Class",r.DatatypeProperty="DatatypeProperty",r.ObjectProperty="ObjectProperty",r.AnnotationProperty="AnnotationProperty",r.Instance="Instance",r.Datatype="Datatype",r.Shape="Shape",r.Unknown="Unknown",r))(z||{}),L=(r=>(r.InstanceOf="instanceOf",r.SubClassOf="subClassOf",r.Domain="domain",r.Range="range",r.ObjectRelationship="objectRelationship",r.SubPropertyOf="subPropertyOf",r.PropertyValue="propertyValue",r.EmbeddedLink="embeddedLink",r))(L||{}),$=class{static async buildFromRepository(e,n){let i=await new G().parseKanonaks(e),s=await e.getAllDocumentsAsync(),p=[],a=[],r=new Set,d=new Set,y=new Map;for(let f of i){let c=f;if(c.name&&(S.isClassType(c)&&r.add(c.name),f instanceof N)){let l=j(i,f);(l==="ObjectProperty"||l==="Property")&&d.add(c.name)}}for(let f of s)for(let[c,l]of Object.entries(f.body))d.has(c)&&l?.range&&typeof l.range=="string"&&y.set(c,l.range);let g=new Map;for(let f of i){let c=f;c.name&&g.set(c.name,c)}for(let f of s){let c=f.metadata.namespace_,l=c?`${c.publisher}/${c.package_}`:"",m=c?.version?`${c.version.major}.${c.version.minor}.${c.version.patch}`:"",O=U(f);for(let[h,u]of Object.entries(f.body)){if(!u||typeof u!="object")continue;let b=g.get(h),k="Unknown";if(b){let T=b,A=b instanceof N?j(i,b):void 0;S.isClassType(T)?k="Class":A==="ObjectProperty"?k="ObjectProperty":A==="DatatypeProperty"?k="DatatypeProperty":A==="AnnotationProperty"?k="AnnotationProperty":S.isDatatypeType(T)?k="Datatype":A==="Property"?k="ObjectProperty":S.isShapeType(T)?k="Shape":S.isInstanceOfKnownClass(T,r)&&(k="Instance")}let P=l&&m?`${l}/${h}@${m}`:h,I={};for(let[T,A]of Object.entries(u))T!=="type"&&(typeof A!="object"||A===null)&&(I[T]=A);p.push({id:P,label:u.label??h,type:k,namespace:l,properties:I}),K(P,u,k,r,d,a,l,m,O,n),D(P,u,d,y,p,a,l,m,O),Q(P,b,a)}}return{nodes:p,edges:a}}static buildFromDocument(e,n){let o=[],i=[],s=e.metadata.namespace_,p=s?.version?`${s.version.major}.${s.version.minor}.${s.version.patch}`:"",a=s?`${s.publisher}/${s.package_}`:"",r=new Set,d=new Set,y=new Map,g=U(e);for(let[l,m]of Object.entries(e.body)){let O=m?.type;O&&(Y(O,g)&&r.add(l),J(O,g)&&(d.add(l),m.range&&typeof m.range=="string"&&y.set(l,m.range)))}for(let[l,m]of Object.entries(e.body)){if(!m||typeof m!="object")continue;let O=m.type,h=X(O,l,r,g),u=a&&p?`${a}/${l}@${p}`:l,b={};for(let[k,P]of Object.entries(m))k!=="type"&&(typeof P!="object"||P===null)&&(b[k]=P);o.push({id:u,label:m.label??l,type:h,namespace:a,properties:b}),K(u,m,h,r,d,i,a,p,g,n),D(u,m,d,y,o,i,a,p,g)}let f=new Set(o.map(l=>l.id)),c=i.filter(l=>f.has(l.source)&&f.has(l.target));return{nodes:o,edges:c}}};function U(t,e){let n=new Map;if(t.metadata?.imports)for(let[o,i]of Object.entries(t.metadata.imports))for(let s of i){let p=s.alias??s.packageName,a=s.version,r=`${a.major}.${a.minor}.${a.patch}`;n.set(p,{publisher:o,package_:s.packageName,version:r})}return n}var B={"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"},W=new Set(["kanonak.org/core-owl/ObjectProperty","kanonak.org/core-owl/DatatypeProperty","kanonak.org/core-owl/AnnotationProperty","kanonak.org/core-rdf/Property"]);function M(t,e){if(t.includes(".")){let n=t.indexOf("."),o=t.substring(0,n),i=t.substring(n+1),s=e.get(o);if(s)return`${s.publisher}/${s.package_}/${i}`}return null}function Y(t,e){let n=M(t,e);return n?B[n]==="Class":!1}function J(t,e){let n=M(t,e);return n?W.has(n):!1}function X(t,e,n,o){if(!t||t==="Package")return"Unknown";let i=M(t,o);if(i){let p=B[i];if(p)return p;let a=i.split("/").pop()?.split("@")[0]??"";return n.has(a)?"Instance":"Unknown"}let s=t.split(".").pop()??t;return n.has(s)?"Instance":"Unknown"}var V=new Set(["type","label","comment","version","publisher","imports","license","match","alias","package"]);function K(t,e,n,o,i,s,p,a,r,d){let y=e.type,g=e.subClassOf;if(g){let h=Array.isArray(g)?g:[g];for(let u of h)typeof u=="string"&&s.push({source:t,target:v(u,p,a,r),type:"subClassOf",label:"subClassOf"})}let f=e.subPropertyOf;if(f){let h=Array.isArray(f)?f:[f];for(let u of h)typeof u=="string"&&s.push({source:t,target:v(u,p,a,r),type:"subPropertyOf",label:"subPropertyOf"})}let c=e.domain,l=e.range;if(d?.includePropertyEdges){let h=[[c,"domain","domain"],[l,"range","range"]];for(let[u,b,k]of h)if(u!=null)for(let P of Array.isArray(u)?u:[u])typeof P=="string"&&s.push({source:t,target:v(P,p,a,r),type:b,label:k})}if(n==="Instance"&&y){let h=y.split(".").pop()??y;s.push({source:t,target:v(h,p,a,r),type:"instanceOf",label:"type"})}if(n==="Instance")for(let[h,u]of Object.entries(e)){if(V.has(h)||!i.has(h))continue;let b=Array.isArray(u)?u:[u];for(let k of b)typeof k=="string"&&Z(k)&&s.push({source:t,target:v(k,p,a,r),type:"propertyValue",label:h,propertyId:v(h,p,a,r)})}if((n==="ObjectProperty"||n==="DatatypeProperty"||c&&l)&&c&&l){let h=typeof c=="string"?c:null,u=typeof l=="string"?l:null;h&&u&&s.push({source:v(h,p,a,r),target:v(u,p,a,r),type:"objectRelationship",label:e.label??t.split("/").pop()??"",propertyId:t})}}function D(t,e,n,o,i,s,p,a,r){for(let[d,y]of Object.entries(e)){if(V.has(d)||typeof y!="object"||y===null||Array.isArray(y))continue;let g=y,f=`${t}/${d}`,c=o.get(d),l=c?c.split(".").pop()??c:"Unknown",m={};for(let[h,u]of Object.entries(g))(typeof u!="object"||u===null)&&(m[h]=u);i.push({id:f,label:`${l} (embedded)`,type:"Instance",namespace:p,properties:m});let O=p&&a?`${p}/${d}@${a}`:d;s.push({source:t,target:f,type:"propertyValue",label:d,propertyId:n.has(d)?O:void 0}),c&&s.push({source:f,target:v(l,p,a,r),type:"instanceOf",label:"type (inferred)"}),D(f,g,n,o,i,s,p,a,r)}}function Q(t,e,n){let o=e?.statement;if(Array.isArray(o))for(let i of o){if(!(i instanceof F))continue;let s=i.predicate?.subject?.name??"";for(let p of i.links){let a=p.target?.subject;if(!a)continue;let r=a.version,d=r&&typeof r.major=="number"?`@${r.major}.${r.minor}.${r.patch}`:"";n.push({source:t,target:`${a.publisher}/${a.package_}/${a.name}${d}`,type:"embeddedLink",label:s})}}}function Z(t){return!(!t||t.includes(" ")||t.includes(`
1
+ import{e as R}from"./chunk-BZ3YTI3C.js";import{a as F,k as G}from"./chunk-JHQPXEMA.js";import{ma as S,pa as j}from"./chunk-MQBWSCNY.js";import{c as N}from"./chunk-54D47DLS.js";var z=(r=>(r.Class="Class",r.DatatypeProperty="DatatypeProperty",r.ObjectProperty="ObjectProperty",r.AnnotationProperty="AnnotationProperty",r.Instance="Instance",r.Datatype="Datatype",r.Shape="Shape",r.Unknown="Unknown",r))(z||{}),L=(r=>(r.InstanceOf="instanceOf",r.SubClassOf="subClassOf",r.Domain="domain",r.Range="range",r.ObjectRelationship="objectRelationship",r.SubPropertyOf="subPropertyOf",r.PropertyValue="propertyValue",r.EmbeddedLink="embeddedLink",r))(L||{}),$=class{static async buildFromRepository(e,n){let i=await new G().parseKanonaks(e),s=await e.getAllDocumentsAsync(),p=[],a=[],r=new Set,d=new Set,y=new Map;for(let f of i){let c=f;if(c.name&&(S.isClassType(c)&&r.add(c.name),f instanceof N)){let l=j(i,f);(l==="ObjectProperty"||l==="Property")&&d.add(c.name)}}for(let f of s)for(let[c,l]of Object.entries(f.body))d.has(c)&&l?.range&&typeof l.range=="string"&&y.set(c,l.range);let g=new Map;for(let f of i){let c=f;c.name&&g.set(c.name,c)}for(let f of s){let c=f.metadata.namespace_,l=c?`${c.publisher}/${c.package_}`:"",m=c?.version?`${c.version.major}.${c.version.minor}.${c.version.patch}`:"",O=U(f);for(let[h,u]of Object.entries(f.body)){if(!u||typeof u!="object")continue;let b=g.get(h),k="Unknown";if(b){let T=b,A=b instanceof N?j(i,b):void 0;S.isClassType(T)?k="Class":A==="ObjectProperty"?k="ObjectProperty":A==="DatatypeProperty"?k="DatatypeProperty":A==="AnnotationProperty"?k="AnnotationProperty":S.isDatatypeType(T)?k="Datatype":A==="Property"?k="ObjectProperty":S.isShapeType(T)?k="Shape":S.isInstanceOfKnownClass(T,r)&&(k="Instance")}let P=l&&m?`${l}/${h}@${m}`:h,I={};for(let[T,A]of Object.entries(u))T!=="type"&&(typeof A!="object"||A===null)&&(I[T]=A);p.push({id:P,label:u.label??h,type:k,namespace:l,properties:I}),K(P,u,k,r,d,a,l,m,O,n),D(P,u,d,y,p,a,l,m,O),Q(P,b,a)}}return{nodes:p,edges:a}}static buildFromDocument(e,n){let o=[],i=[],s=e.metadata.namespace_,p=s?.version?`${s.version.major}.${s.version.minor}.${s.version.patch}`:"",a=s?`${s.publisher}/${s.package_}`:"",r=new Set,d=new Set,y=new Map,g=U(e);for(let[l,m]of Object.entries(e.body)){let O=m?.type;O&&(Y(O,g)&&r.add(l),J(O,g)&&(d.add(l),m.range&&typeof m.range=="string"&&y.set(l,m.range)))}for(let[l,m]of Object.entries(e.body)){if(!m||typeof m!="object")continue;let O=m.type,h=X(O,l,r,g),u=a&&p?`${a}/${l}@${p}`:l,b={};for(let[k,P]of Object.entries(m))k!=="type"&&(typeof P!="object"||P===null)&&(b[k]=P);o.push({id:u,label:m.label??l,type:h,namespace:a,properties:b}),K(u,m,h,r,d,i,a,p,g,n),D(u,m,d,y,o,i,a,p,g)}let f=new Set(o.map(l=>l.id)),c=i.filter(l=>f.has(l.source)&&f.has(l.target));return{nodes:o,edges:c}}};function U(t,e){let n=new Map;if(t.metadata?.imports)for(let[o,i]of Object.entries(t.metadata.imports))for(let s of i){let p=s.alias??s.packageName,a=s.version,r=`${a.major}.${a.minor}.${a.patch}`;n.set(p,{publisher:o,package_:s.packageName,version:r})}return n}var B={"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"},W=new Set(["kanonak.org/core-owl/ObjectProperty","kanonak.org/core-owl/DatatypeProperty","kanonak.org/core-owl/AnnotationProperty","kanonak.org/core-rdf/Property"]);function M(t,e){if(t.includes(".")){let n=t.indexOf("."),o=t.substring(0,n),i=t.substring(n+1),s=e.get(o);if(s)return`${s.publisher}/${s.package_}/${i}`}return null}function Y(t,e){let n=M(t,e);return n?B[n]==="Class":!1}function J(t,e){let n=M(t,e);return n?W.has(n):!1}function X(t,e,n,o){if(!t||t==="Package")return"Unknown";let i=M(t,o);if(i){let p=B[i];if(p)return p;let a=i.split("/").pop()?.split("@")[0]??"";return n.has(a)?"Instance":"Unknown"}let s=t.split(".").pop()??t;return n.has(s)?"Instance":"Unknown"}var V=new Set(["type","label","comment","version","publisher","imports","license","match","alias","package"]);function K(t,e,n,o,i,s,p,a,r,d){let y=e.type,g=e.subClassOf;if(g){let h=Array.isArray(g)?g:[g];for(let u of h)typeof u=="string"&&s.push({source:t,target:v(u,p,a,r),type:"subClassOf",label:"subClassOf"})}let f=e.subPropertyOf;if(f){let h=Array.isArray(f)?f:[f];for(let u of h)typeof u=="string"&&s.push({source:t,target:v(u,p,a,r),type:"subPropertyOf",label:"subPropertyOf"})}let c=e.domain,l=e.range;if(d?.includePropertyEdges){let h=[[c,"domain","domain"],[l,"range","range"]];for(let[u,b,k]of h)if(u!=null)for(let P of Array.isArray(u)?u:[u])typeof P=="string"&&s.push({source:t,target:v(P,p,a,r),type:b,label:k})}if(n==="Instance"&&y){let h=y.split(".").pop()??y;s.push({source:t,target:v(h,p,a,r),type:"instanceOf",label:"type"})}if(n==="Instance")for(let[h,u]of Object.entries(e)){if(V.has(h)||!i.has(h))continue;let b=Array.isArray(u)?u:[u];for(let k of b)typeof k=="string"&&Z(k)&&s.push({source:t,target:v(k,p,a,r),type:"propertyValue",label:h,propertyId:v(h,p,a,r)})}if((n==="ObjectProperty"||n==="DatatypeProperty"||c&&l)&&c&&l){let h=typeof c=="string"?c:null,u=typeof l=="string"?l:null;h&&u&&s.push({source:v(h,p,a,r),target:v(u,p,a,r),type:"objectRelationship",label:e.label??t.split("/").pop()??"",propertyId:t})}}function D(t,e,n,o,i,s,p,a,r){for(let[d,y]of Object.entries(e)){if(V.has(d)||typeof y!="object"||y===null||Array.isArray(y))continue;let g=y,f=`${t}/${d}`,c=o.get(d),l=c?c.split(".").pop()??c:"Unknown",m={};for(let[h,u]of Object.entries(g))(typeof u!="object"||u===null)&&(m[h]=u);i.push({id:f,label:`${l} (embedded)`,type:"Instance",namespace:p,properties:m});let O=p&&a?`${p}/${d}@${a}`:d;s.push({source:t,target:f,type:"propertyValue",label:d,propertyId:n.has(d)?O:void 0}),c&&s.push({source:f,target:v(l,p,a,r),type:"instanceOf",label:"type (inferred)"}),D(f,g,n,o,i,s,p,a,r)}}function Q(t,e,n){let o=e?.statement;if(Array.isArray(o))for(let i of o){if(!(i instanceof F))continue;let s=i.predicate?.subject?.name??"";for(let p of i.links){let a=p.target?.subject;if(!a)continue;let r=a.version,d=r&&typeof r.major=="number"?`@${r.major}.${r.minor}.${r.patch}`:"";n.push({source:t,target:`${a.publisher}/${a.package_}/${a.name}${d}`,type:"embeddedLink",label:s})}}}function Z(t){return!(!t||t.includes(" ")||t.includes(`
2
2
  `)||t.startsWith("http://")||t.startsWith("https://")||/^\d{4}-\d{2}/.test(t)||/^\d+(\.\d+)?$/.test(t))}function v(t,e,n,o){if(t.includes("@")&&t.includes("/"))return t;if(t.includes(".")){let i=t.indexOf("."),s=t.substring(0,i),p=t.substring(i+1);if(o){let a=o.get(s);if(a)return`${a.publisher}/${a.package_}/${p}@${a.version}`}return e&&n?`${e}/${p}@${n}`:p}return e&&n?`${e}/${t}@${n}`:t}function _(t){let e=t.replace(/^https?:\/\//,"").replace(/^git:\/\//,"").replace(/\/+$/,"").trim();if(!e)throw new Error("Publisher host cannot be empty");return e}var ee="key_thumbprint",E=class{cache=new Map;prCache=new Map;async discoverProtectedResource(e){let n=_(e);if(this.prCache.has(n))return this.prCache.get(n);let o=`https://${n}/.well-known/oauth-protected-resource`,i=await te(o),s=i&&Array.isArray(i.authorization_servers)?i.authorization_servers.filter(a=>typeof a=="string"):[],p=s.length>0?s:null;return this.prCache.set(n,p),p}async discover(e){let n=_(e);if(this.cache.has(n))return this.cache.get(n);let o=`https://${n}/.well-known/oauth-authorization-server`,i=await this.tryEndpoint(o);if(!i){let s=`https://${n}/.well-known/openid-configuration`;i=await this.tryEndpoint(s)}return this.cache.set(n,i),i}async supportsOAuth(e){return await this.discover(e)!==null}static supportsPkceS256(e){return e.codeChallengeMethodsSupported?.some(n=>n.toUpperCase()==="S256")??!1}static supportsDynamicRegistration(e){return!!e.registrationEndpoint}static supportsAuthorizationCode(e){return e.responseTypesSupported?.some(n=>n.toLowerCase()==="code")??!1}static supportsEnrollment(e){return!!e.enrollmentEndpoint}static supportsSession(e){return!!e.sessionEndpoint}async tryEndpoint(e){let n;try{n=await fetch(e)}catch(i){let s=i instanceof Error?i.message:String(i);return s.includes("ENOTFOUND")||s.includes("ECONNREFUSED")?(console.error(` OAuth discovery: ${e} \u2014 host unreachable (${s})`),console.error(" If the server is behind a VPN, ensure you are connected.")):s.includes("CERT")||s.includes("SSL")||s.includes("TLS")?(console.error(` OAuth discovery: ${e} \u2014 TLS error (${s})`),console.error(" If using a custom CA certificate, set NODE_EXTRA_CA_CERTS=/path/to/ca.pem")):console.error(` OAuth discovery: ${e} \u2014 network error: ${s}`),null}if(!n.ok)return n.status===404||(n.status===403?(console.error(` OAuth discovery: ${e} \u2014 HTTP 403 Forbidden`),console.error(" Access may be blocked by a firewall, proxy, or WAF.")):n.status>=500&&(console.error(` OAuth discovery: ${e} \u2014 HTTP ${n.status} server error`),console.error(" The authorization server returned an internal error. Contact your IDP administrator."))),null;let o;try{o=await n.json()}catch{return console.error(` OAuth discovery: ${e} \u2014 response is not valid JSON`),console.error(" The endpoint may be returning HTML instead of JSON. Check IDP configuration."),null}return{issuer:C(o.issuer),authorizationEndpoint:C(o.authorization_endpoint),tokenEndpoint:C(o.token_endpoint),registrationEndpoint:C(o.registration_endpoint),revocationEndpoint:C(o.revocation_endpoint),scopesSupported:w(o.scopes_supported),responseTypesSupported:w(o.response_types_supported),grantTypesSupported:w(o.grant_types_supported),codeChallengeMethodsSupported:w(o.code_challenge_methods_supported),tokenEndpointAuthMethodsSupported:w(o.token_endpoint_auth_methods_supported),dpopSigningAlgValuesSupported:w(o.dpop_signing_alg_values_supported),enrollmentEndpoint:C(o.enrollment_endpoint),enrollmentIssuanceProtocols:w(o.enrollment_issuance_protocols),enrollmentKeyTypes:w(o.enrollment_key_types),enrollmentScopesSupported:w(o.enrollment_scopes_supported),enrollmentConsentBindingParam:C(o.enrollment_consent_binding_param),sessionEndpoint:C(o.session_endpoint),sessionEndpointAuthMethod:C(o.session_endpoint_auth_method)}}};async function te(t){try{let e=await fetch(t);return e.ok?await e.json():null}catch{return null}}function C(t){return typeof t=="string"?t:null}function w(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):null}function H(t){let e=t.headers.get("WWW-Authenticate")??void 0,n=t.headers.get("DPoP-Nonce")??void 0;if(!e&&!n)return;let o={wwwAuthenticate:e??""};if(n&&(o.nonce=n),e){let i=e.match(/acr_values\s*=\s*"([^"]*)"/i);i&&(o.acrValues=i[1])}return o}function ne(t){try{return new URL(t).host}catch{return null}}function re(t,e={}){let n=e.discovery??new E,o=new Map,i=new Map,s=async r=>{let d=o.get(r);if(d!==void 0)return d;let y=null,g=await n.discoverProtectedResource(r).catch(()=>null);return g&&g.length>0&&(y=ne(g[0])),o.set(r,y),y},p=async(r,d)=>{if(!t)return null;if(!(d.forceRefresh||d.challenge)&&i.has(r))return i.get(r);let g=await t.resolve(r,d).catch(()=>null);return i.set(r,g),g},a=async(r,d,y,g)=>{let f=await s(d);if(!f)return{res:await R(r,{method:y,redirect:"manual"}),authed:!1};let c=await p(f,{method:y,url:r,...g}),l=c?.headers??{};return{res:await R(r,{method:y,redirect:"manual",headers:l}),authed:!!c}};return async(r,d,y="GET")=>{let g=await a(r,d,y,{});if((g.res.status===401||g.res.status===403)&&g.authed){let f=H(g.res),c={forceRefresh:f===void 0};return f&&(c.challenge=f),(await a(r,d,y,c)).res}return g.res}}var q="KANONAK_TOKEN";function oe(){return typeof process<"u"&&process.env?process.env:{}}function se(t){return`${q}_${t.toUpperCase().replace(/[^A-Z0-9]+/g,"_")}`}var x=class{tokens;env;constructor(e={}){this.tokens=e.tokens??{},this.env=e.env??oe()}async resolve(e,n){let o=_(e),i=this.tokens[o]??this.env[se(o)]??this.env[q];return i?{headers:{Authorization:`Bearer ${i}`}}:null}};export{z as a,L as b,$ as c,_ as d,ee as e,E as f,H as g,re as h,x as i};
@@ -1,2 +1,2 @@
1
- import{l as V}from"./chunk-PVUBHIU2.js";import{a as E}from"./chunk-HF5FJBS2.js";var L=class{propertyUri;propertyType;range;rangeUri;isImported;definedInNamespace};import{parseDocument as O,LineCounter as R,isMap as h,isPair as f,isScalar as g,isSeq as I}from"yaml";var K=class i{entities=new Map;entityBlocks=new Map;properties=new Map;propertyValues=new Map;valueListItems=new Map;importPackages=new Map;nestedKeys=new Map;nestedValues=new Map;static fromContent(e){let t=new i,n=new R,r=O(e,{lineCounter:n});if(r.errors.length>0||!h(r.contents))return t;N(r.contents,[],n,t);for(let o of r.contents.items){if(!f(o)||!g(o.key))continue;let a=String(o.key.value),u=o.key.range;if(!u)continue;t.entities.set(a,d(u,n));let s=o.value,c=s&&typeof s=="object"&&"range"in s?s.range:void 0;if(c?t.entityBlocks.set(a,d([u[0],u[1],c[2]],n)):t.entityBlocks.set(a,d(u,n)),h(o.value)){let k=new Map,m=new Map,l=new Map;for(let P of o.value.items){if(!f(P)||!g(P.key))continue;let b=String(P.key.value),p=P.key.range;p&&k.set(b,d(p,n));let S=P.value;if(S&&typeof S=="object"&&"range"in S&&Array.isArray(S.range)){let v=S.range;m.set(b,d(v,n))}if(I(S)){let v=[];for(let M of S.items)M&&typeof M=="object"&&"range"in M&&Array.isArray(M.range)&&v.push(d(M.range,n));v.length>0&&l.set(b,v)}}k.size>0&&t.properties.set(a,k),m.size>0&&t.propertyValues.set(a,m),l.size>0&&t.valueListItems.set(a,l);let y=j(o.value,n);y.length>0&&t.importPackages.set(a,y)}}return t}getEntityPosition(e){return this.entities.get(e)}getEntityBlockPosition(e){return this.entityBlocks.get(e)}findEntityAtPosition(e,t){for(let[n,r]of this.entityBlocks)if(w(r,e,t))return n}findPropertyAtPosition(e,t){let n=this.findEntityAtPosition(e,t);if(!n)return;let r=this.properties.get(n),o=this.propertyValues.get(n);if(!r&&!o)return{entityName:n};let a,u;if(o)for(let[s,c]of o)w(c,e,t)&&(!u||C(c,u))&&(a=s,u=c);if(r)for(let[s,c]of r)w(c,e,t)&&(!u||C(c,u))&&(a=s,u=c);return a?{entityName:n,propertyName:a}:{entityName:n}}getPropertyPosition(e,t){return this.properties.get(e)?.get(t)}getPropertyValuePosition(e,t){return this.propertyValues.get(e)?.get(t)}getImportPackages(e){return this.importPackages.get(e)??[]}getAllImportPackages(){let e=[];for(let[t,n]of this.importPackages)for(let r of n)e.push({entityName:t,entry:r});return e}findPropertySourceName(e,t){let n=this.properties.get(e);if(n){if(n.has(t))return t;for(let r of n.keys()){let o=r.lastIndexOf(".");if((o===-1?r:r.substring(o+1))===t)return r}}}getListItemPosition(e,t,n){let r=this.valueListItems.get(e)?.get(t);if(!(!r||n<0||n>=r.length))return r[n]}getNodeKeyPosition(e){return this.nestedKeys.get(JSON.stringify(e))}getNodeValuePosition(e){return this.nestedValues.get(JSON.stringify(e))}setNestedKeyPosition(e,t){this.nestedKeys.set(e,t)}setNestedValuePosition(e,t){this.nestedValues.set(e,t)}getMostSpecificPosition(e,t,n){if(e){if(t!==void 0){if(n!==void 0){let a=this.getListItemPosition(e,t,n);if(a)return a}let r=this.getPropertyValuePosition(e,t);if(r)return r;let o=this.getPropertyPosition(e,t);if(o)return o}return this.getEntityPosition(e)}}};function j(i,e){let t=[];if(!h(i))return t;let n=i.items.find(r=>f(r)&&g(r.key)&&String(r.key.value)==="imports");if(!n||!f(n)||!I(n.value))return t;for(let r of n.value.items){if(!h(r))continue;let o=r.items.find(s=>f(s)&&g(s.key)&&String(s.key.value)==="publisher");if(!o||!f(o)||!g(o.value))continue;let a=String(o.value.value),u=r.items.find(s=>f(s)&&g(s.key)&&String(s.key.value)==="packages");if(!(!u||!f(u)||!I(u.value)))for(let s of u.value.items){if(!h(s))continue;let c=s.items.find(p=>f(p)&&g(p.key)&&String(p.key.value)==="package");if(!c||!f(c)||!g(c.value)||!c.value.range)continue;let k=String(c.value.value),m=s.items.find(p=>f(p)&&g(p.key)&&String(p.key.value)==="version"),l=m&&f(m)&&g(m.value)?String(m.value.value):"",y=s.items.find(p=>f(p)&&g(p.key)&&String(p.key.value)==="alias"),P=y&&f(y)&&g(y.value)?String(y.value.value):void 0,b=P!==void 0?{publisher:a,package_:k,version:l,alias:P,position:d(c.value.range,e)}:{publisher:a,package_:k,version:l,position:d(c.value.range,e)};t.push(b)}}return t}function w(i,e,t){return!(e<i.line||e>i.endLine||e===i.line&&t<i.column||e===i.endLine&&t>i.endColumn)}function C(i,e){let t=i.endLine-i.line,n=e.endLine-e.line;if(t!==n)return t<n;let r=i.endLine===i.line?i.endColumn-i.column:Number.MAX_SAFE_INTEGER,o=e.endLine===e.line?e.endColumn-e.column:Number.MAX_SAFE_INTEGER;return r<o}function N(i,e,t,n){if(h(i)){for(let r of i.items){if(!f(r)||!g(r.key))continue;let o=String(r.key.value),a=[...e,o],u=JSON.stringify(a);r.key.range&&n.setNestedKeyPosition(u,d(r.key.range,t));let s=r.value,c=D(s);c&&n.setNestedValuePosition(u,d(c,t)),N(s,a,t,n)}return}if(I(i)){for(let r=0;r<i.items.length;r++){let o=i.items[r],a=[...e,r],u=JSON.stringify(a),s=D(o);s&&n.setNestedValuePosition(u,d(s,t)),N(o,a,t,n)}return}}function D(i){if(!i||typeof i!="object"||!("range"in i))return;let e=i.range;return Array.isArray(e)&&e.length>=3?e:void 0}function d(i,e){let t=e.linePos(i[0]),n=e.linePos(i[2]);return{line:t.line-1,column:t.col-1,endLine:n.line-1,endColumn:n.col-1}}function x(i,e){let n=(e??new E).parse(i),r=K.fromContent(i);return{document:n,positions:r}}function W(i,e,t,n,r){if(e<n.line||e>n.endLine||e===n.line&&t<n.column||e===n.endLine&&t>=n.endColumn)return;let o=A(r,n.line,n.column),a=A(r,n.endLine,n.endColumn);if(o<0||a<0)return;let u=r.substring(o,a),s=V(u);if(s.length!==i.links.length)return;let c=e-n.line,k=e===n.line?t-n.column:t,m=A(u,c,k);if(!(m<0))for(let l=0;l<s.length;l++){let y=s[l];if(m>=y.startOffset&&m<y.endOffset)return i.links[l]}}function A(i,e,t){let n=0,r=0;for(let o=0;o<i.length;o++){if(n===e)return Math.min(r+t,i.length);i[o]===`
1
+ import{j as V}from"./chunk-JHQPXEMA.js";import{a as E}from"./chunk-HF5FJBS2.js";var L=class{propertyUri;propertyType;range;rangeUri;isImported;definedInNamespace};import{parseDocument as O,LineCounter as R,isMap as h,isPair as f,isScalar as g,isSeq as I}from"yaml";var K=class i{entities=new Map;entityBlocks=new Map;properties=new Map;propertyValues=new Map;valueListItems=new Map;importPackages=new Map;nestedKeys=new Map;nestedValues=new Map;static fromContent(e){let t=new i,n=new R,r=O(e,{lineCounter:n});if(r.errors.length>0||!h(r.contents))return t;N(r.contents,[],n,t);for(let o of r.contents.items){if(!f(o)||!g(o.key))continue;let a=String(o.key.value),u=o.key.range;if(!u)continue;t.entities.set(a,d(u,n));let s=o.value,c=s&&typeof s=="object"&&"range"in s?s.range:void 0;if(c?t.entityBlocks.set(a,d([u[0],u[1],c[2]],n)):t.entityBlocks.set(a,d(u,n)),h(o.value)){let k=new Map,m=new Map,l=new Map;for(let P of o.value.items){if(!f(P)||!g(P.key))continue;let b=String(P.key.value),p=P.key.range;p&&k.set(b,d(p,n));let S=P.value;if(S&&typeof S=="object"&&"range"in S&&Array.isArray(S.range)){let v=S.range;m.set(b,d(v,n))}if(I(S)){let v=[];for(let M of S.items)M&&typeof M=="object"&&"range"in M&&Array.isArray(M.range)&&v.push(d(M.range,n));v.length>0&&l.set(b,v)}}k.size>0&&t.properties.set(a,k),m.size>0&&t.propertyValues.set(a,m),l.size>0&&t.valueListItems.set(a,l);let y=j(o.value,n);y.length>0&&t.importPackages.set(a,y)}}return t}getEntityPosition(e){return this.entities.get(e)}getEntityBlockPosition(e){return this.entityBlocks.get(e)}findEntityAtPosition(e,t){for(let[n,r]of this.entityBlocks)if(w(r,e,t))return n}findPropertyAtPosition(e,t){let n=this.findEntityAtPosition(e,t);if(!n)return;let r=this.properties.get(n),o=this.propertyValues.get(n);if(!r&&!o)return{entityName:n};let a,u;if(o)for(let[s,c]of o)w(c,e,t)&&(!u||C(c,u))&&(a=s,u=c);if(r)for(let[s,c]of r)w(c,e,t)&&(!u||C(c,u))&&(a=s,u=c);return a?{entityName:n,propertyName:a}:{entityName:n}}getPropertyPosition(e,t){return this.properties.get(e)?.get(t)}getPropertyValuePosition(e,t){return this.propertyValues.get(e)?.get(t)}getImportPackages(e){return this.importPackages.get(e)??[]}getAllImportPackages(){let e=[];for(let[t,n]of this.importPackages)for(let r of n)e.push({entityName:t,entry:r});return e}findPropertySourceName(e,t){let n=this.properties.get(e);if(n){if(n.has(t))return t;for(let r of n.keys()){let o=r.lastIndexOf(".");if((o===-1?r:r.substring(o+1))===t)return r}}}getListItemPosition(e,t,n){let r=this.valueListItems.get(e)?.get(t);if(!(!r||n<0||n>=r.length))return r[n]}getNodeKeyPosition(e){return this.nestedKeys.get(JSON.stringify(e))}getNodeValuePosition(e){return this.nestedValues.get(JSON.stringify(e))}setNestedKeyPosition(e,t){this.nestedKeys.set(e,t)}setNestedValuePosition(e,t){this.nestedValues.set(e,t)}getMostSpecificPosition(e,t,n){if(e){if(t!==void 0){if(n!==void 0){let a=this.getListItemPosition(e,t,n);if(a)return a}let r=this.getPropertyValuePosition(e,t);if(r)return r;let o=this.getPropertyPosition(e,t);if(o)return o}return this.getEntityPosition(e)}}};function j(i,e){let t=[];if(!h(i))return t;let n=i.items.find(r=>f(r)&&g(r.key)&&String(r.key.value)==="imports");if(!n||!f(n)||!I(n.value))return t;for(let r of n.value.items){if(!h(r))continue;let o=r.items.find(s=>f(s)&&g(s.key)&&String(s.key.value)==="publisher");if(!o||!f(o)||!g(o.value))continue;let a=String(o.value.value),u=r.items.find(s=>f(s)&&g(s.key)&&String(s.key.value)==="packages");if(!(!u||!f(u)||!I(u.value)))for(let s of u.value.items){if(!h(s))continue;let c=s.items.find(p=>f(p)&&g(p.key)&&String(p.key.value)==="package");if(!c||!f(c)||!g(c.value)||!c.value.range)continue;let k=String(c.value.value),m=s.items.find(p=>f(p)&&g(p.key)&&String(p.key.value)==="version"),l=m&&f(m)&&g(m.value)?String(m.value.value):"",y=s.items.find(p=>f(p)&&g(p.key)&&String(p.key.value)==="alias"),P=y&&f(y)&&g(y.value)?String(y.value.value):void 0,b=P!==void 0?{publisher:a,package_:k,version:l,alias:P,position:d(c.value.range,e)}:{publisher:a,package_:k,version:l,position:d(c.value.range,e)};t.push(b)}}return t}function w(i,e,t){return!(e<i.line||e>i.endLine||e===i.line&&t<i.column||e===i.endLine&&t>i.endColumn)}function C(i,e){let t=i.endLine-i.line,n=e.endLine-e.line;if(t!==n)return t<n;let r=i.endLine===i.line?i.endColumn-i.column:Number.MAX_SAFE_INTEGER,o=e.endLine===e.line?e.endColumn-e.column:Number.MAX_SAFE_INTEGER;return r<o}function N(i,e,t,n){if(h(i)){for(let r of i.items){if(!f(r)||!g(r.key))continue;let o=String(r.key.value),a=[...e,o],u=JSON.stringify(a);r.key.range&&n.setNestedKeyPosition(u,d(r.key.range,t));let s=r.value,c=D(s);c&&n.setNestedValuePosition(u,d(c,t)),N(s,a,t,n)}return}if(I(i)){for(let r=0;r<i.items.length;r++){let o=i.items[r],a=[...e,r],u=JSON.stringify(a),s=D(o);s&&n.setNestedValuePosition(u,d(s,t)),N(o,a,t,n)}return}}function D(i){if(!i||typeof i!="object"||!("range"in i))return;let e=i.range;return Array.isArray(e)&&e.length>=3?e:void 0}function d(i,e){let t=e.linePos(i[0]),n=e.linePos(i[2]);return{line:t.line-1,column:t.col-1,endLine:n.line-1,endColumn:n.col-1}}function x(i,e){let n=(e??new E).parse(i),r=K.fromContent(i);return{document:n,positions:r}}function W(i,e,t,n,r){if(e<n.line||e>n.endLine||e===n.line&&t<n.column||e===n.endLine&&t>=n.endColumn)return;let o=A(r,n.line,n.column),a=A(r,n.endLine,n.endColumn);if(o<0||a<0)return;let u=r.substring(o,a),s=V(u);if(s.length!==i.links.length)return;let c=e-n.line,k=e===n.line?t-n.column:t,m=A(u,c,k);if(!(m<0))for(let l=0;l<s.length;l++){let y=s[l];if(m>=y.startOffset&&m<y.endOffset)return i.links[l]}}function A(i,e,t){let n=0,r=0;for(let o=0;o<i.length;o++){if(n===e)return Math.min(r+t,i.length);i[o]===`
2
2
  `&&(n++,r=o+1)}return n===e?Math.min(r+t,i.length):-1}export{L as a,K as b,x as c,W as d};
@@ -0,0 +1 @@
1
+ import{c as j,d as D,e as m,i as R,l as p,m as K,n as k}from"./chunk-54D47DLS.js";import{c as b,g as u}from"./chunk-QILEJIFU.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};
package/dist/index.d.ts CHANGED
@@ -42,3 +42,5 @@ export { canonicalForm, canonicalHash, CANONICAL_FORM_VERSION, Carrier, carrierO
42
42
  export type { CanonicalInput, CanonicalInputSubject, CanonicalInputStatement, CanonicalInputValue, } from './canonical/index.js';
43
43
  export { buildOntologyModel } from './introspection/index.js';
44
44
  export type { OntologyModel, ClassDef, PropertyDef, ClassRef, TypeRef, EnumDef, EnumMember, BuildOntologyModelOptions, } from './introspection/index.js';
45
+ export { valuesOf, referenceUris, typeReferenceUris } from './uri-helpers/index.js';
46
+ export type { PropertyValue } from './uri-helpers/index.js';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as Do,b as Ho,c as To,d as Fo,e as D}from"./chunk-EVMSO7HJ.js";import{a as Kn,b as xn,c as Cn}from"./chunk-V3DH67P3.js";import{a as Ao,b as $o,c as Mo,d as qt,e as Xt,f as Yt,g as Jt,h as Qt,i as Zt}from"./chunk-PXS6XZ3V.js";import{a as er}from"./chunk-L2J7WD7E.js";import{a as Ft,b as Bt,c as Wt,d as H,e as Gt,f as zt,g as ge,h as nr,i as or,j as tr,k as rr,l as ar}from"./chunk-PRXC2HZ3.js";import{a as Zn,b as eo,c as no,d as oo,e as to,f as ko,g as ho,h as So,i as go}from"./chunk-IS3AQKB4.js";import{a as ro,b as ao,c as io,d as so,e as co,f as uo,h as lo,i as ve,j as Le,k as _e,l as Ie,m as po,n as mo}from"./chunk-BZ3YTI3C.js";import{a as Wo,b as Go,c as zo,d as qo}from"./chunk-BS7RRG7D.js";import{a as Xo}from"./chunk-XK24CN3C.js";import{a as fo}from"./chunk-SC5M74NM.js";import{A as Kt,B as xt,C as Ct,D as Pt,E as vt,F as Lt,G as Ut,H as At,I as $t,J as Mt,K as Dt,L as Ht,M as Tt,a as Jo,b as Qo,c as Zo,d as et,e as nt,f as ot,g as tt,h as rt,i as at,j as it,k as st,l as ct,m as ut,n as lt,o as pt,p as dt,q as ft,r as mt,s as kt,t as ht,u as St,v as gt,w as yt,x as bt,y as Rt,z as Et}from"./chunk-C63WFML4.js";import"./chunk-KIBR3HAT.js";import{c as bn,d as _t,e as It,g as wt,h as Vt,k as Nt,m as Se,o as Rn,p as En,r as jt,s as Ot}from"./chunk-HENE47QG.js";import"./chunk-QHABFCRC.js";import{a as ie}from"./chunk-6VIUXP4N.js";import{a as v,b as $,c as pe,i as I,j as he,k as Oo,l as Uo,m as N}from"./chunk-PVUBHIU2.js";import{a as A}from"./chunk-HF5FJBS2.js";import{a as Yo}from"./chunk-PEJALHXK.js";import{$ as ke,A as Ge,B as ze,C as qe,D as Xe,E as Ye,F as Je,G as Qe,H as Ze,I as en,J as nn,K as on,L as tn,M as me,N as rn,O as an,P as sn,Q as cn,R as un,S as ln,T as pn,U as dn,V as fn,W as mn,X as kn,Y as hn,Z as Sn,_ as gn,a as xo,b as Co,c as Po,d as vo,da as wo,e as M,f as Lo,fa as Vo,g as _o,ga as h,ha as Y,i as Io,j as z,k as q,l as Ne,m as X,ma as No,n as je,na as jo,o as Oe,oa as J,p as Ue,q as Ae,r as $e,s as Me,t as De,u as He,v as fe,w as Te,x as Fe,y as Be,z as We}from"./chunk-7UYXTYXC.js";import{A as de,B as _,C as yn,a as yo,b as bo,c as R,d as g,e as Eo,f as Ko,g as se,h as ce,i as ue,j as B,k as le,l as W,m as c,r as we,t as K,w as Ve,x as L,y as G,z as k}from"./chunk-CJMVIOZX.js";import{a as Ro}from"./chunk-FUUTGGJS.js";import"./chunk-F67UH4FD.js";import{a as Bn,b as Wn,c as F,d as Gn,e as U,f as zn,g as qn,h as Xn,i as Yn,j as Jn,k as Qn}from"./chunk-QILEJIFU.js";import{a as Bo}from"./chunk-ODIECDN7.js";async function Pn(e){let n=await new N().parseKanonaks(e),r=await new D().reason(e);return{kind:"merged",catalog:n,reasoning:r}}function vn(e,n){return{kind:"merged",catalog:e,reasoning:n}}async function Ln(e,n){let r=n??new ie(new A);return{kind:"standalone",catalog:await new N().parseKanonaks(new yn(e,r))}}function j(e){return typeof e=="number"?e:void 0}function ir(e){if(!e)return;let n=c(e);if(n===c(nn))return"IRI";if(n===c(on))return"BlankNode";if(n===c(tn))return"Literal"}function _n(e){if(!e)return;let n=c(e);if(n===c(rn))return"Violation";if(n===c(an))return"Warning";if(n===c(sn))return"Info"}function ye(e,n){let r=k(e,n);if(r)return[r];let o=[];for(let t of _(e,n))t instanceof g&&o.push(t.subject);return o}function sr(e,n){let r=k(e,Ae);if(!r)return;let o={path:r},t=j(L(e,$e)),a=j(L(e,Me));t!==void 0&&(o.minCount=t),a!==void 0&&(o.maxCount=a);let s=j(L(e,Be)),i=j(L(e,We));s!==void 0&&(o.minLength=s),i!==void 0&&(o.maxLength=i);let u=j(L(e,Ge)),d=j(L(e,ze));u!==void 0&&(o.minInclusive=u),d!==void 0&&(o.maxInclusive=d);let p=G(e,Te);if(p!==void 0){let b=G(e,Fe);o.pattern=b!==void 0?{regex:p,flags:b}:{regex:p}}if(Ve(e,fe)){let b=[],w=[];for(let V of _(e,fe))V instanceof $?b.push(V.value):V instanceof g&&w.push(V.subject);b.length>0&&(o.inValues=b),w.length>0&&(o.inRefs=w)}let S=k(e,De);S&&(o.datatype=S);let y=k(e,He);y&&(o.classRef=y);let l=ir(k(e,en));l&&(o.nodeKind=l);let f=G(e,qe);f!==void 0&&(o.message=f);let m=_n(k(e,me))??n;return m&&(o.severity=m),o}function Q(e){let n=[];for(let r of e){if(!(r instanceof R)||!we(r,X))continue;let o=_n(k(r,me)),t={name:r.name,uri:h(r),targetClass:k(r,Oe),targetNodes:ye(r,Xe),targetSubjectsOf:ye(r,Ye),targetObjectsOf:ye(r,Je),closed:L(r,Qe)===!0,ignoredProperties:[],severity:o,properties:[]};for(let a of _(r,Ze))a instanceof g&&t.ignoredProperties.push(a.subject);for(let a of _(r,Ue)){let s;if(a instanceof v?s=a:a instanceof g&&(s=K(e,a.subject)),!s)continue;let i=sr(s,o);i&&t.properties.push(i)}n.push(t)}return n}var x="kanonak.org/transformations",Z="values";var ee="allowed",C=e=>({type:`${x}/VarRef`,varName:e}),be=e=>({type:`${x}/IntegerLiteral`,integerLiteral:e}),cr=e=>({type:`${x}/DecimalLiteral`,decimalLiteral:e}),In=e=>Number.isInteger(e)?be(e):cr(e),wn=e=>({type:`${x}/Count`,source:e}),Vn=(e,n)=>({type:`${x}/GreaterThanOrEqual`,compareLeft:e,compareRight:n}),Nn=(e,n)=>({type:`${x}/LessThanOrEqual`,compareLeft:e,compareRight:n});function Re(e,n){if(!n||n.length===0)return e;let r=new Set(["i","m","s"]),o=[...new Set(n.split(""))];if(o.filter(a=>!r.has(a)).length>0)throw new Error(`sh:flags '${n}' is outside the pinned regex subset (supported: i, m, s)`);return`(?${o.sort().join("")})${e}`}function ne(e){let n=[];return e.minCount!==void 0&&n.push({component:"minCount",per:"node",expr:Vn(wn(C(Z)),be(e.minCount))}),e.maxCount!==void 0&&n.push({component:"maxCount",per:"node",expr:Nn(wn(C(Z)),be(e.maxCount))}),(e.inValues!==void 0||e.inRefs!==void 0)&&n.push({component:"in",per:"value",expr:{type:`${x}/Contains`,haystack:C(ee),needle:C("v")}}),e.pattern!==void 0&&n.push({component:"pattern",per:"value",expr:{type:`${x}/Matches`,matchSource:C("v"),pattern:Re(e.pattern.regex,e.pattern.flags)}}),e.minLength!==void 0&&n.push({component:"minLength",per:"value",expr:{type:`${x}/Matches`,matchSource:C("v"),pattern:`(?s)^.{${e.minLength},}$`}}),e.maxLength!==void 0&&n.push({component:"maxLength",per:"value",expr:{type:`${x}/Matches`,matchSource:C("v"),pattern:`(?s)^.{0,${e.maxLength}}$`}}),e.minInclusive!==void 0&&n.push({component:"minInclusive",per:"value",expr:Vn(C("v"),In(e.minInclusive))}),e.maxInclusive!==void 0&&n.push({component:"maxInclusive",per:"value",expr:Nn(C("v"),In(e.maxInclusive))}),n}import{evaluate as lr,ExpressionError as pr}from"@kanonak-protocol/expression";function Un(e,n){let r=dr(n)?n:Q(n),o=[];for(let t of r)for(let a of fr(e,t))hr(e,t,a,o);return{conforms:!o.some(t=>t.severity==="Violation"),results:o}}function dr(e){return e.length>0&&!(e[0]instanceof Object&&"statement"in e[0])&&typeof e[0].name=="string"&&"properties"in e[0]}function oe(e){let n=e.predicate;return n instanceof g?n:void 0}function fr(e,n){let r=new Map,o=e.catalog.filter(a=>a instanceof R),t=a=>{let s=h(a);r.set(s?c(s):`${a.namespace}/${a.name}`,a)};if(n.targetClass){let a=c(n.targetClass);if(e.reasoning){let s=new Set(e.reasoning.getInstancesOfClass(n.targetClass));for(let i of o){let u=h(i);u&&s.has(c(u))&&t(i)}}else for(let s of o)J(s).some(u=>c(u)===a||Y(e.catalog,u).some(d=>c(d)===a))&&t(s)}for(let a of n.targetNodes){let s=K(e.catalog,a);s instanceof R&&t(s)}for(let a of n.targetSubjectsOf){let s=c(a);for(let i of o)i.statement.some(u=>{let d=oe(u);return d&&c(d.subject)===s})&&t(i)}for(let a of n.targetObjectsOf){let s=c(a);for(let i of o)for(let u of i.statement){let d=oe(u);if(!(!d||c(d.subject)!==s))for(let p of mr(u)){let S=K(e.catalog,p);S instanceof R&&t(S)}}}return[...r.values()]}function mr(e){return e instanceof B?[e.object.subject]:e instanceof W?(e.object??[]).filter(n=>n instanceof g).map(n=>n.subject):[]}function kr(e,n,r){let o=[];for(let t of e.statement){let a=oe(t);if(!(!a||c(a.subject)!==n)){if(t instanceof se||t instanceof pe)o.push({kernel:t.object,kind:"string",literal:t.object});else if(t instanceof ce)o.push({kernel:t.object,kind:"number",literal:t.object});else if(t instanceof ue)o.push({kernel:t.object?1:0,kind:"boolean",literal:t.object});else if(t instanceof B)o.push({kernel:{ref:c(t.object.subject)},kind:"reference",ref:t.object.subject});else if(t instanceof le)o.push(jn(t.object,r,o.length));else if(t instanceof W){for(let s of t.object??[])if(s instanceof g)o.push({kernel:{ref:c(s.subject)},kind:"reference",ref:s.subject});else if(s instanceof v)o.push(jn(s,r,o.length));else if(s instanceof $){let i=s.value;typeof i=="boolean"?o.push({kernel:i?1:0,kind:"boolean",literal:i}):o.push({kernel:i,kind:typeof i=="number"?"number":"string",literal:i})}}}}return o}function jn(e,n,r){let o=e.name&&e.name.length>0?e.name:String(r);return{kernel:{ref:`${n}#${o}`},kind:"embedded"}}function hr(e,n,r,o){let t=h(r),a=t?c(t):`${r.namespace}/${r.name}`;for(let s of n.properties)gr(e,n,r,a,t,s,o);n.closed&&Kr(n,r,a,t,o)}function Ee(e,n,r,o,t,a={},s){return{focusNode:n,focusUri:r,constraintComponent:o,severity:s??An(e),message:t,sourceShape:e.name,sourceShapeUri:e.uri,...a}}function An(e){return e.severity??"Violation"}var Sr={minCount:cn,maxCount:un,in:dn,pattern:fn,minLength:mn,maxLength:kn,minInclusive:hn,maxInclusive:Sn};function gr(e,n,r,o,t,a,s){let i=c(a.path),u=kr(r,i,o),d=a.severity??An(n),p=a.path.name,S=[...(a.inValues??[]).map(l=>typeof l=="boolean"?l?1:0:l),...(a.inRefs??[]).map(l=>({ref:c(l)}))],y=(l,f,m)=>{s.push(Ee(n,o,t,l,a.message??f,{resultPath:a.path,value:m?.literal,valueRef:m?.ref},d))};for(let l of ne(a)){let f=Sr[l.component];if(l.per==="node"){On(l,{[Z]:u.map(b=>b.kernel),[ee]:S})||y(f,l.component==="minCount"?`'${p}' has ${u.length} value(s); minCount is ${a.minCount}.`:`'${p}' has ${u.length} value(s); maxCount is ${a.maxCount}.`);continue}for(let m of u){if((l.component==="pattern"||l.component==="minLength"||l.component==="maxLength")&&m.kind!=="string"){y(f,`'${p}' value is not a string; ${l.component} applies to string values.`,m);continue}On(l,{v:m.kernel,[ee]:S})||y(f,yr(l,p,a,m),m)}}if(a.nodeKind)for(let l of u)br(a.nodeKind,l)||y(gn,`'${p}' value is ${l.kind}; nodeKind requires ${a.nodeKind}.`,l);if(a.datatype)for(let l of u){let f=Rr(a.datatype,l);f&&y(ln,`'${p}' ${f}`,l)}if(a.classRef)for(let l of u){let f=Er(e,a.classRef,l);f&&y(pn,`'${p}' ${f}`,l)}}function yr(e,n,r,o){let t=o.ref?c(o.ref):JSON.stringify(o.literal);switch(e.component){case"in":return`'${n}' value ${t} is not in the permitted set.`;case"pattern":return`'${n}' value ${t} does not match pattern ${r.pattern?.regex}.`;case"minLength":return`'${n}' value ${t} is shorter than minLength ${r.minLength}.`;case"maxLength":return`'${n}' value ${t} is longer than maxLength ${r.maxLength}.`;case"minInclusive":return`'${n}' value ${t} is below minInclusive ${r.minInclusive} (or not numeric).`;case"maxInclusive":return`'${n}' value ${t} is above maxInclusive ${r.maxInclusive} (or not numeric).`;default:return`'${n}' value ${t} violates ${e.component}.`}}function On(e,n){let r=o=>{let t=o.varName;if(o.type==="kanonak.org/transformations/VarRef"&&typeof t=="string"&&t in n)return n[t];throw new pr(`Conformance lowering produced an unexpected leaf '${o.type}'`)};return lr(e.expr,void 0,r)===1}function br(e,n){switch(e){case"IRI":return n.kind==="reference";case"BlankNode":return n.kind==="embedded";case"Literal":return n.kind==="string"||n.kind==="number"||n.kind==="boolean"}}function Rr(e,n){if(n.kind==="reference"||n.kind==="embedded")return`value is a ${n.kind}; sh:datatype requires a literal of ${e.name}.`;let r=he(e);if(r!==void 0)switch(r){case I.Boolean:return n.kind==="boolean"?void 0:`value is not a boolean (${e.name}).`;case I.Integer:return n.kind!=="number"?`value is not a number (${e.name}).`:Number.isInteger(n.literal)?void 0:`value is not an integer (${e.name}).`;case I.Decimal:case I.Double:case I.Float:return n.kind==="number"?void 0:`value is not a number (${e.name}).`;default:return n.kind==="string"?void 0:`value is not a string-carried literal (${e.name}).`}}function Er(e,n,r){if(r.kind!=="reference"||!r.ref)return`value is not a reference; sh:class requires an instance of ${n.name}.`;let o=c(n);if(e.reasoning)return e.reasoning.isInstanceOf(r.ref,n)?void 0:`value ${c(r.ref)} is not an instance of ${n.name}.`;let t=K(e.catalog,r.ref);return t instanceof R?J(t).some(s=>c(s)===o||Y(e.catalog,s).some(i=>c(i)===o))?void 0:`value ${c(r.ref)} is not an instance of ${n.name}.`:`value ${c(r.ref)} does not resolve in this scope (sh:class ${n.name}).`}function Kr(e,n,r,o,t){let a=new Set([...e.properties.map(i=>c(i.path)),...e.ignoredProperties.map(i=>c(i))]),s=new Set;for(let i of n.statement){let u=oe(i);if(!u)continue;let d=c(u.subject);a.has(d)||s.has(d)||(s.add(d),t.push(Ee(e,r,o,ke,`'${n.name}' carries undeclared property '${u.subject.name}' (closed shape).`,{resultPath:u.subject})))}for(let i of n.unresolvedPredicates)s.has(i.key)||(s.add(i.key),t.push(Ee(e,r,o,ke,`'${n.name}' carries unresolvable property '${i.key}' (closed shape).`,{value:i.key})))}var xr="1.1.0";async function $n(e){let n=new H(e.repository),r=n.imports(),o=r.ensure(z,q,xr,"sh"),t=(i,u)=>i&&i.version&&typeof i.version.major=="number"?`${r.ensure(i.publisher,i.package_,U(i.version),i.package_)}.${i.name}`:u,a={},s=[];return e.result.results.forEach((i,u)=>{let d=`result-${u+1}`;s.push(d);let p={type:`${o}.ValidationResult`,[`${o}.focusNode`]:t(i.focusUri,i.focusNode),[`${o}.resultMessage`]:i.message,[`${o}.resultSeverity`]:`${o}.${i.severity}`,[`${o}.sourceConstraintComponent`]:`${o}.${i.constraintComponent.name}`};i.resultPath&&(p[`${o}.resultPath`]=t(i.resultPath,c(i.resultPath))),i.sourceShapeUri&&(p[`${o}.sourceShape`]=t(i.sourceShapeUri,i.sourceShape)),i.valueRef?p[`${o}.value`]=t(i.valueRef,c(i.valueRef)):i.value!==void 0&&(p[`${o}.value`]=i.value),a[d]=p}),a.report={type:`${o}.ValidationReport`,[`${o}.conforms`]:e.result.conforms,...s.length>0?{[`${o}.result`]:s}:{}},n.buildContentAddressed({publisher:e.publisher,book:r,body:a,...e.header!==void 0?{header:e.header}:{},contentHashProperty:"contentHash"})}import{VersionOperator as ci}from"@kanonak-protocol/types/document/models/enums";var E="kanonak.org",P="view",Mn="core-kanonak",Cr={publisher:E,package_:P,name:"rootView"},Pr={publisher:E,package_:P,name:"bind"},vr={publisher:E,package_:P,name:"produces"},Lr={publisher:E,package_:P,name:"projections"},_r={publisher:E,package_:P,name:"where"},Ir={publisher:E,package_:P,name:"value"},wr={publisher:E,package_:P,name:"as"},te=class{constructor(n,r=new A){this.repository=n;this.parser=r;this.objectParser=new N(this.parser),this.builder=new H(this.repository,this.parser,this.objectParser)}repository;parser;objectParser;builder;async materialize(n,r={}){let o=await this.objectParser.parseKanonaks(this.repository),t=this.resolveView(o,n),a=k(t,Pr);if(!a)throw new Error(`View ${t.namespace}/${t.name} declares no view.bind; cannot materialize.`);let s=k(t,vr);if(!s)throw new Error(`View ${t.namespace}/${t.name} is a selection view (no view.produces). In-graph materialization of selection views is not yet supported \u2014 declare a view.produces output class to reshape the result.`);let i=Vr(t),u=Dn(o,E,Mn),d=Dn(o,E,P),p=this.builder.imports(),S=p.ensure(E,Mn,u,"ck"),y=p.ensure(E,P,d,"v"),l=p.ref(s),f=new En(this.repository,this.parser,this.objectParser),m=new Rn(f,o),b=this.readProjections(o,t),w=Or(t,_r),V=this.findInstances(o,a,await this.reason(r)),Ke={},Tn=new Set;for(let T of V){if(!await this.passesWhere(m,o,w,T))continue;let ae={type:l};for(let Ce of b){let Fn=await this.evaluateValue(m,o,Ce.value,T),Pe=this.builder.serializeValue(Hn(Fn),p);Pe!==void 0&&(ae[p.ref(Ce.as)]=Pe)}let xe=h(T);xe&&(ae[`${y}.derivedFrom`]=p.ref(xe)),Ke[this.rowName(T,Tn)]=ae}let re={};r.resolvedAt&&(re[`${S}.resolvedAt`]=r.resolvedAt),r.invocationId&&(re[`${S}.id`]=r.invocationId);let O=await this.builder.buildContentAddressed({publisher:i,book:p,body:Ke,contentHashProperty:`${S}.contentHash`,header:re});return{yaml:O.yaml,contentHash:O.contentHash,packageName:O.packageName,publisher:O.publisher,rowCount:O.resourceCount}}resolveView(n,r){let o=K(n,r);if(!o)throw new Error(`View ${r.publisher}/${r.package_}/${r.name} not found in the catalog.`);let t=k(o,Cr);if(t){let a=K(n,t);if(!a)throw new Error(`ViewPackage ${r.name} names rootView ${t.name}, which is not in the catalog.`);return a}return o}readProjections(n,r){let o=[];for(let t of _(r,Lr)){let a=t instanceof v?t:t instanceof g?K(n,t.subject):void 0;if(!a)continue;let s=de(a,Ir),i=k(a,wr);s&&i&&o.push({value:s,as:i})}return o}async reason(n){return new D({profile:n.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(n,r,o){let t=jr(n),a=[],s=new Set;for(let i of o.getInstancesOfClass(r)){if(s.has(i))continue;s.add(i);let u=t.get(i);u&&a.push(u)}return a.sort((i,u)=>{let d=M(h(i)),p=M(h(u));return d<p?-1:d>p?1:0}),a}async passesWhere(n,r,o,t){for(let a of o){let s=await this.evaluateValue(n,r,a,t);if(!Ur(s))return!1}return!0}async evaluateValue(n,r,o,t){let a=bn(o,"view-projection",{catalog:r,depth:0}),s=new Map([["input",t]]);return n.evaluate(a,s)}rowName(n,r){let o=ge(n.name)||"row",t=o,a=2;for(;r.has(t);)t=`${o}-${a++}`;return r.add(t),t}};function Hn(e){return Se(e)?e.value:Array.isArray(e)?e.map(Hn):e}function Vr(e){let n=h(e);if(!n)throw new Error(`Could not derive a publisher from view ${e.namespace}/${e.name}.`);return n.publisher}function Dn(e,n,r){let o=Nr(e,n,r);if(!o)throw new Error(`Package ${n}/${r} is not in the catalog; it must be importable to materialize a view.`);return o}function Nr(e,n,r){let o;for(let t of e){if(!(t instanceof R))continue;let a=h(t);!a||a.publisher!==n||a.package_!==r||!a.version||(!o||F(a.version,o)>0)&&(o=a.version)}return o?U(o):void 0}function jr(e){let n=new Map,r=new Map;for(let o of e){if(!(o instanceof R))continue;let t=h(o);if(!t||!t.version)continue;let a=M(t),s=r.get(a);(!s||F(t.version,s)>0)&&(r.set(a,t.version),n.set(a,o))}return n}function Or(e,n){let r=de(e,n);return r?[r]:_(e,n).filter(o=>o instanceof v)}function Ur(e){return e===!0?!0:e===!1||e===void 0||e===null?!1:typeof e=="string"?e.length>0:typeof e=="number"?e!==0:Se(e)?e.value.length>0:Array.isArray(e)?e.length>0:!!e}export{gt as AmbiguousReferenceRule,ue as BooleanStatement,Wt as CANONICAL_FORM_VERSION,I as Carrier,xt as ClassDefinitionRule,pt as ClassHierarchyCycleRule,no as CompositeKanonakDocumentRepository,Xt as DEFAULT_CONSENT_BINDING_PARAM,bo as DefinedKanonak,Ht as DiamondNameClashRule,Pt as DisplayLensScopeRule,eo as DocumentLocation,$o as EdgeType,v as EmbeddedKanonak,ct as EmbeddedKanonakTypeRule,le as EmbeddedStatement,rr as EntitlementDeniedError,ar as EntitlementProducer,Zn as FileSystemKanonakDocumentRepository,Bo as GitIgnoreFilter,Mo as GraphBuilder,mo as HttpKanonakDocumentRepository,ve as INTEGRITY_PREFIX,zt as ImportBook,ut as ImportExistenceRule,ie as InMemoryKanonakDocumentRepository,ro as KANONAK_USER_AGENT,yo as Kanonak,Go as KanonakDocumentPositions,N as KanonakObjectParser,Tt as KanonakObjectValidator,A as KanonakParser,Ro as KanonakUri,Xo as KanonakUriBuilder,Yo as KanonakUrlResolver,wo as KanonakVocabulary,It as LINE_STYLES,ot as LinkTargetRule,W as ListStatement,$ as LiteralKanonak,ko as LocalFirstRepository,ho as LockAwareRepository,At as LookBandPathRule,jt as LookRenderer,vt as LookSemanticSvgPathRule,Ct as MarkdownLinkRule,pe as MarkdownStatement,ht as NamespaceImportCycleRule,tt as NamespacePrefixRule,Ao as NodeType,ce as NumberStatement,Yt as OAuthDiscovery,To as OWL_RL_CLASSIFICATION_RULES,bt as ObjectPropertyValueValidationRule,Zo as OntologyValidationError,Jo as OntologyValidationResult,Dt as OwlOneOfRule,H as PackageBuilder,st as PackageHeaderRule,nr as ProducerRepository,Rt as PropertyDomainRule,dt as PropertyHierarchyCycleRule,Et as PropertyKindRangeConsistencyRule,Wo as PropertyMetadata,yt as PropertyRangeReferenceRule,ft as PropertyRangeRequiredRule,at as PropertyTypeSpecificityRule,lo as PublisherConfigResolver,po as PublisherIndex,Ho as RDFS_RULES,D as Reasoner,Fo as ReasoningResult,g as ReferenceKanonak,B as ReferenceStatement,to as RepositoryFactory,Kt as ReservedNameShadowRule,rt as ResourceNamingRule,xo as ResourceResolver,Vo as ResourceTypeClassifier,q as SHACL_PACKAGE,z as SHACL_PUBLISHER,X as SH_NODE_SHAPE,je as SH_PROPERTY_SHAPE,Ne as SH_SHAPE,Ko as ScalarStatement,Ut as SequenceNarrativeRule,Mt as ShaclShapeRule,Eo as Statement,se as StringStatement,mt as SubClassOfReferenceRule,kt as SubPropertyOfReferenceRule,R as SubjectKanonak,it as SubjectKanonakTypeRequiredRule,Zt as TokenCredentialProvider,Do as TripleStore,Lt as TxExpressionCompilesRule,$t as TxExpressionPathRule,Co as TypeResolver,St as UnresolvedPredicateRule,lt as UnresolvedReferenceRule,nt as ValidationCache,et as ValidationContext,Qo as ValidationSeverity,ci as VersionOperator,te as ViewMaterializer,or as allowAllPolicy,so as assertHttpsUrl,fo as assertPackageIdentity,go as buildLocalFirstRepository,Nt as buildOntologyModel,$n as buildReportPackageAsync,Q as buildShapesModel,Ft as canonicalForm,Bt as canonicalHash,he as carrierOf,So as collectKanonakFiles,F as compareVersions,Cn as computeIntegrity,Ie as computeIntegrityAsync,Gt as contentAddressedName,J as contextTypesOf,Qt as createCredentialedFetch,zn as createVersion,Un as evaluateConformance,Uo as extractMarkdownLinks,er as findDerivation,Oo as findMalformedReferences,qo as findMarkdownLinkAt,Re as foldFlagsIntoPattern,vo as formatKanonakAddress,U as formatVersion,oo as getGlobalCachePath,io as getKanonakUserAgent,Xn as isCompatibleVersion,Yn as isMajorCompatible,co as kanonakFetch,Kn as loadLockFile,ne as lowerConstraint,Lo as makeUriKey,tr as noopMeter,qt as normalizeHost,Jt as parseAuthChallenge,Po as parseKanonakAddress,Le as parseLockFile,qn as parseVersionString,zo as parseWithPositions,Qn as pickHighestDocument,No as propertiesInScope,wt as readSequenceConnectors,_t as resolveDisplayValue,jo as resolvePropertyStep,ge as sanitizeName,Jn as satisfiesVersionOperator,xn as saveLockFile,vn as scopeFromCatalog,Ln as scopeFromDocumentAsync,Pn as scopeFromRepositoryAsync,_e as serializeLockFile,uo as setKanonakFetchRetries,ao as setKanonakUserAgent,h as subjectUri,Y as superClassChain,Ot as supportedBandKeys,_o as tripleKey,M as uriKey,Io as uriTriple,Bn as versionOperatorFromChar,Wn as versionOperatorToChar,Gn as versionsEqual,Vt as walkSequence};
1
+ import{a as it,b as st,c as ct,d as ut,e as B}from"./chunk-26SO3A4B.js";import{a as In,b as Vn,c as Ln}from"./chunk-V3DH67P3.js";import{a as tt,b as rt,c as at,d as mr,e as hr,f as kr,g as Sr,h as yr,i as gr}from"./chunk-O35Y6QUW.js";import{a as br}from"./chunk-ZYDJUGIA.js";import{a as ur,b as dr,c as lr,d as G,e as pr,f as fr,g as xe,h as Er,i as Rr,j as Cr,k as Kr,l as xr}from"./chunk-2Y6R3K5A.js";import{a as lo,b as po,c as fo,d as mo,e as ho,f as _o,g as Po,h as vo,i as Io}from"./chunk-IS3AQKB4.js";import{a as ko,b as So,c as yo,d as go,e as bo,f as Eo,h as Ro,i as Ae,j as $e,k as Me,l as je,m as Co,n as xo}from"./chunk-BZ3YTI3C.js";import{a as lt,b as pt,c as ft,d as mt}from"./chunk-VEGFYZXG.js";import{a as ht}from"./chunk-XK24CN3C.js";import{a as Ko}from"./chunk-SC5M74NM.js";import{A as Tt,B as qt,C as Wt,D as Bt,E as Gt,F as zt,G as or,H as tr,I as rr,J as ar,K as ir,L as sr,M as cr,a as St,b as yt,c as gt,d as bt,e as Et,f as Rt,g as Ct,h as Kt,i as xt,j as _t,k as Pt,l as vt,m as It,n as Vt,o as Lt,p as Nt,q as Ot,r as wt,s as Ut,t as At,u as $t,v as Mt,w as jt,x as Dt,y as Ft,z as Ht}from"./chunk-AVVLDZAZ.js";import"./chunk-KIBR3HAT.js";import{c as _n,d as Qt,e as Xt,g as Yt,h as Jt,k as Zt,m as Ke,o as Pn,p as vn,r as er,s as nr}from"./chunk-D7QLWVPK.js";import"./chunk-QHABFCRC.js";import{a as fe}from"./chunk-6VIUXP4N.js";import{a as Ho,g as L,h as Ce,i as nt,j as ot,k as A}from"./chunk-JHQPXEMA.js";import{a as j}from"./chunk-HF5FJBS2.js";import{a as kt}from"./chunk-PEJALHXK.js";import{$ as ge,A as Ye,B as Je,C as Ze,D as en,E as nn,F as on,G as tn,H as rn,I as an,J as sn,K as cn,L as un,M as ye,N as dn,O as ln,P as pn,Q as fn,R as mn,S as hn,T as kn,U as Sn,V as yn,W as gn,X as bn,Y as En,Z as Rn,_ as Cn,a as To,aa as Kn,b as qo,ba as ae,c as Wo,ca as be,d as Bo,da as Ee,e as F,ea as ie,f as zo,fa as T,g as Qo,ga as q,i as Xo,j as oe,k as te,ka as Yo,l as De,m as H,ma as Jo,n as re,na as k,o as Fe,oa as Re,p as He,q as ke,r as Te,s as qe,t as We,ta as Zo,u as Be,ua as et,v as Se,va as U,w as Ge,x as ze,y as Qe,z as Xe}from"./chunk-MQBWSCNY.js";import{A as C,B as ne,C as h,D,E as he,F as W,G as xn,a as Vo,b as Lo,c as S,d as N,e as v,f as Oo,g as wo,h as Uo,i as Ao,j as $o,k as Mo,l as jo,m as Do,n as Fo,o as l,r as Go,s as O,t as me,u as ee,w as x,z as w}from"./chunk-54D47DLS.js";import{a as No}from"./chunk-FUUTGGJS.js";import"./chunk-F67UH4FD.js";import{a as no,b as oo,c as Z,d as to,e as V,f as ro,g as ao,h as io,i as so,j as co,k as uo}from"./chunk-QILEJIFU.js";import{a as dt}from"./chunk-ODIECDN7.js";async function Nn(n){let e=await new A().parseKanonaks(n),t=await new B().reason(n);return{kind:"merged",catalog:e,reasoning:t}}function On(n,e){return{kind:"merged",catalog:n,reasoning:e}}async function wn(n,e){let t=e??new fe(new j);return{kind:"standalone",catalog:await new A().parseKanonaks(new xn(n,t))}}function I(n){return typeof n=="number"?n:void 0}function _r(n){if(!n)return;let e=l(n);if(e===l(sn))return"IRI";if(e===l(cn))return"BlankNode";if(e===l(un))return"Literal"}function An(n){if(!n)return;let e=l(n);if(e===l(dn))return"Violation";if(e===l(ln))return"Warning";if(e===l(pn))return"Info"}function $n(n,e,t,o){let r=h(e,ke);if(!r)return;let a={path:r},u=I(C(e,Te)),s=I(C(e,qe));u!==void 0&&(a.minCount=u),s!==void 0&&(a.maxCount=s);let i=I(C(e,Qe)),d=I(C(e,Xe));i!==void 0&&(a.minLength=i),d!==void 0&&(a.maxLength=d);let c=I(C(e,Ye)),p=I(C(e,Je));c!==void 0&&(a.minInclusive=c),p!==void 0&&(a.maxInclusive=p);let f=ne(e,Ge);if(f!==void 0){let m=ne(e,ze);a.pattern=m!==void 0?{regex:f,flags:m}:{regex:f}}if(w(e,Se)){let m=[],P=[];for(let{item:y}of me(e,Se))"literal"in y?m.push(y.value):y instanceof v&&P.push(y.subject);m.length>0&&(a.inValues=m),P.length>0&&(a.inRefs=P)}let R=h(e,We);R&&(a.datatype=R);let $=h(e,Be);$&&(a.classRef=$);let M=_r(h(e,an));M&&(a.nodeKind=M);let Q=h(e,Kn);if(Q&&(a.hasValue=Q),w(e,ae)||w(e,be)||w(e,Ee)){let m={},P=I(C(e,be)),y=I(C(e,Ee));P!==void 0&&(m.minCount=P),y!==void 0&&(m.maxCount=y);let K=Pr(n,e,o);"problem"in K?m.problem=K.problem:m.shape=K.shape,a.qualified=m}let X=ne(e,Ze);X!==void 0&&(a.message=X);let Y=An(h(e,ye))??t;return Y&&(a.severity=Y),a}function Pr(n,e,t){let o=D(e,ae);if(o)return Un(n,o,void 0,t);let r=h(e,ae);if(!r)return{problem:"sh:qualifiedValueShape is missing"};let a=l(r);if(t.has(a))return{problem:`sh:qualifiedValueShape '${r.name}' leads back to itself (a cycle through named shapes)`};let u=x(n,r);return u?Un(n,u,a,t):{problem:`sh:qualifiedValueShape '${r.name}' does not resolve`}}function Un(n,e,t,o){let r=t?new Set([...o,t]):o,a=ee(e,H);if((ee(e,re)||w(e,ke))&&!a){let i=$n(n,e,void 0,r);return i?{shape:{kind:"property",constraint:i}}:{problem:"the qualified property shape has no sh:path"}}return e instanceof S&&!a?{problem:`sh:qualifiedValueShape '${e.name}' is not a shape`}:{shape:{kind:"node",shape:Mn(n,e,r)}}}function Mn(n,e,t){let o=An(h(e,ye)),r={name:e instanceof S?e.name:"(inline shape)",uri:e instanceof S?k(e):void 0,targetClass:h(e,Fe),targetNodes:O(e,en),targetSubjectsOf:O(e,nn),targetObjectsOf:O(e,on),closed:C(e,tn)===!0,ignoredProperties:[],severity:o,properties:[]};r.ignoredProperties.push(...O(e,rn));for(let{item:a}of me(e,He)){let u;if(a instanceof N?u=a:a instanceof v&&(u=x(n,a.subject)),!u)continue;let s=$n(n,u,o,t);s&&r.properties.push(s)}return r}function se(n){let e=[];for(let t of n){if(!(t instanceof S)||!ee(t,H))continue;let o=k(t);e.push(Mn(n,t,new Set(o?[l(o)]:[])))}return e}var b="kanonak.org/transformations",z="values";var ce="allowed",Pe="expected",g=n=>({type:`${b}/VarRef`,varName:n}),_e=n=>({type:`${b}/IntegerLiteral`,integerLiteral:n}),vr=n=>({type:`${b}/DecimalLiteral`,decimalLiteral:n}),jn=n=>Number.isInteger(n)?_e(n):vr(n),Dn=n=>({type:`${b}/Count`,source:n}),Fn=(n,e)=>({type:`${b}/GreaterThanOrEqual`,compareLeft:n,compareRight:e}),Hn=(n,e)=>({type:`${b}/LessThanOrEqual`,compareLeft:n,compareRight:e});function ve(n,e){if(!e||e.length===0)return n;let t=new Set(["i","m","s"]),o=[...new Set(e.split(""))];if(o.filter(a=>!t.has(a)).length>0)throw new Error(`sh:flags '${e}' is outside the pinned regex subset (supported: i, m, s)`);return`(?${o.sort().join("")})${n}`}function ue(n){let e=[];return n.minCount!==void 0&&e.push({component:"minCount",per:"node",expr:Fn(Dn(g(z)),_e(n.minCount))}),n.maxCount!==void 0&&e.push({component:"maxCount",per:"node",expr:Hn(Dn(g(z)),_e(n.maxCount))}),n.hasValue!==void 0&&e.push({component:"hasValue",per:"node",expr:{type:`${b}/Contains`,haystack:g(z),needle:g(Pe)}}),(n.inValues!==void 0||n.inRefs!==void 0)&&e.push({component:"in",per:"value",expr:{type:`${b}/Contains`,haystack:g(ce),needle:g("v")}}),n.pattern!==void 0&&e.push({component:"pattern",per:"value",expr:{type:`${b}/Matches`,matchSource:g("v"),pattern:ve(n.pattern.regex,n.pattern.flags)}}),n.minLength!==void 0&&e.push({component:"minLength",per:"value",expr:{type:`${b}/Matches`,matchSource:g("v"),pattern:`(?s)^.{${n.minLength},}$`}}),n.maxLength!==void 0&&e.push({component:"maxLength",per:"value",expr:{type:`${b}/Matches`,matchSource:g("v"),pattern:`(?s)^.{0,${n.maxLength}}$`}}),n.minInclusive!==void 0&&e.push({component:"minInclusive",per:"value",expr:Fn(g("v"),jn(n.minInclusive))}),n.maxInclusive!==void 0&&e.push({component:"maxInclusive",per:"value",expr:Hn(g("v"),jn(n.maxInclusive))}),e}import{evaluate as Vr,ExpressionError as Lr}from"@kanonak-protocol/expression";function qn(n,e){let t=Nr(e)?e:se(e),o=[],r=n.catalog.filter(s=>s instanceof S).map(de),a=new Map;for(let s of r)Wn(s,n.catalog,a);let u={scope:n,membership:new Ie(n),embeddedFocus:a};for(let s of t)for(let i of wr(u,s,r))Bn(u,s,i,o);return{conforms:!o.some(s=>s.severity==="Violation"),results:o}}function Nr(n){return n.length>0&&!(n[0]instanceof Object&&"statement"in n[0])&&typeof n[0].name=="string"&&"properties"in n[0]}function Le(n){let e=n.predicate;return e instanceof v?e:void 0}function de(n){let e=k(n);return{node:n,key:e?l(e):`${n.namespace}/${n.name}`,uri:e,label:n.name}}function Ne(n,e){return{node:n,key:e,label:e.includes("#")?e.slice(e.indexOf("#")):e}}function Or(n){let e=new Map;for(let t of n.statement){let o=Le(t);o&&!e.has(l(o.subject))&&e.set(l(o.subject),o.subject)}return[...e.values()]}function Wn(n,e,t){if(n.node)for(let o of Or(n.node))for(let r of W(n.node,o,e,n.key)){if(r.kind!=="embedded"||t.has(r.node))continue;let a=Ne(r.node,r.address);t.set(r.node,a),Wn(a,e,t)}}var Ie=class{constructor(e){this.scope=e}scope;ancestors=new Map;isInstance(e,t){let o=l(t);return e.some(r=>l(r)===o||this.ancestorsOf(r).has(o))}ancestorsOf(e){let t=e.version&&typeof e.version.major=="number"?`${l(e)}@${V(e.version)}`:l(e),o=this.ancestors.get(t);return o||(o=this.scope.reasoning?new Set(this.scope.reasoning.getSuperclasses(e)):new Set(Re(this.scope.catalog,e).map(r=>l(r))),this.ancestors.set(t,o)),o}};function wr(n,e,t){let{scope:o}=n,r=new Map,a=s=>{r.set(s.key,s)},u=()=>[...t,...n.embeddedFocus.values()];if(e.targetClass){let s=e.targetClass;if(o.reasoning){let i=new Set(o.reasoning.getInstancesOfClass(s));for(let d of t)d.uri&&i.has(l(d.uri))&&a(d)}else for(let i of t)n.membership.isInstance(U(i.node),s)&&a(i);for(let i of n.embeddedFocus.values())n.membership.isInstance(U(i.node),s)&&a(i)}for(let s of e.targetNodes){let i=x(o.catalog,s);i instanceof S&&a(de(i))}for(let s of e.targetSubjectsOf){let i=l(s);for(let d of u())d.node.statement.some(c=>{let p=Le(c);return p&&l(p.subject)===i})&&a(d)}for(let s of e.targetObjectsOf)for(let i of u())for(let d of W(i.node,s,o.catalog,i.key))d.kind==="subject"?a(de(d.node)):d.kind==="embedded"&&a(n.embeddedFocus.get(d.node)??Ne(d.node,d.address));return[...r.values()]}function Ur(n,e,t){return e.node?W(e.node,t,n.scope.catalog,e.key).map(o=>Ar(n,o)):[]}function Ar(n,e){switch(e.kind){case"subject":return{kernel:{ref:l(e.uri)},kind:"reference",ref:e.uri,subject:e.node};case"unresolved":return{kernel:{ref:l(e.uri)},kind:"reference",ref:e.uri};case"embedded":{let t=n.embeddedFocus.get(e.node)??Ne(e.node,e.address);return{kernel:{ref:t.key},kind:"embedded",embedded:t}}case"literal":return typeof e.value=="boolean"?{kernel:e.value?1:0,kind:"boolean",literal:e.value}:{kernel:e.value,kind:typeof e.value=="number"?"number":"string",literal:e.value}}}function Bn(n,e,t,o){for(let r of e.properties)zn(n,e,t,r,o);e.closed&&Gr(e,t,o)}function Ve(n,e,t,o,r={},a){return{focusNode:e.key,focusUri:e.uri,constraintComponent:t,severity:a??Gn(n),message:o,sourceShape:n.name,sourceShapeUri:n.uri,...r}}function Gn(n){return n.severity??"Violation"}var $r={minCount:fn,maxCount:mn,hasValue:ie,in:Sn,pattern:yn,minLength:gn,maxLength:bn,minInclusive:En,maxInclusive:Rn};function zn(n,e,t,o,r){let a=Ur(n,t,o.path),u=o.severity??Gn(e),s=o.path.name,i=[...(o.inValues??[]).map(c=>typeof c=="boolean"?c?1:0:c),...(o.inRefs??[]).map(c=>({ref:l(c)}))],d=(c,p,f)=>{let R=Ve(e,t,c,o.message??p,{resultPath:o.path,value:f?.literal,valueRef:f?.ref},u);return r.push(R),R};for(let c of ue(o)){let p=$r[c.component];if(c.per==="node"){let f={[z]:a.map(R=>R.kernel),[ce]:i};o.hasValue&&(f[Pe]={ref:l(o.hasValue)}),Tn(c,f)||d(p,Mr(c,s,o,a.length));continue}for(let f of a){if((c.component==="pattern"||c.component==="minLength"||c.component==="maxLength")&&f.kind!=="string"){d(p,`'${s}' value is not a string; ${c.component} applies to string values.`,f);continue}Tn(c,{v:f.kernel,[ce]:i})||d(p,Tr(c,s,o,f),f)}}if(o.nodeKind)for(let c of a)qr(o.nodeKind,c)||d(Cn,`'${s}' value is ${c.kind}; nodeKind requires ${o.nodeKind}.`,c);if(o.datatype)for(let c of a){let p=Wr(o.datatype,c);p&&d(hn,`'${s}' ${p}`,c)}if(o.classRef)for(let c of a){let p=Br(n,o.classRef,c);p&&d(kn,`'${s}' ${p}`,c)}o.qualified&&jr(n,o,a,s,d)}function Mr(n,e,t,o){switch(n.component){case"minCount":return`'${e}' has ${o} value(s); minCount is ${t.minCount}.`;case"maxCount":return`'${e}' has ${o} value(s); maxCount is ${t.maxCount}.`;case"hasValue":return`'${e}' has no value equal to ${t.hasValue?l(t.hasValue):"(unset)"}.`;default:return`'${e}' violates ${n.component}.`}}function jr(n,e,t,o,r){let a=e.qualified,u=a.maxCount!==void 0?q:T,s=(d,c)=>{Qn.add(r(u,d,c))};if(!a.shape){s(`'${o}' qualified value shape cannot be evaluated: ${a.problem??"it could not be built"}.`);return}let i=0;for(let d of t){let c=d.ref?l(d.ref):d.embedded?d.embedded.label:JSON.stringify(d.literal),p=Dr(n,d);if(!p){s(`'${o}' value ${c} does not resolve in this scope; whether it conforms to the qualified shape cannot be decided.`,d);continue}let f=Hr(n,a.shape,p);if(f.kind==="undecided"){s(`'${o}' value ${c}: whether it conforms to the qualified shape cannot be decided \u2014 ${f.reason}`,d);continue}f.kind==="conforms"&&i++}a.minCount!==void 0&&i<a.minCount&&r(T,`'${o}' has ${i} value(s) that conform to the qualified shape; qualifiedMinCount is ${a.minCount}.`),a.maxCount!==void 0&&i>a.maxCount&&r(q,`'${o}' has ${i} value(s) that conform to the qualified shape; qualifiedMaxCount is ${a.maxCount}.`)}function Dr(n,e){switch(e.kind){case"reference":return e.subject?de(e.subject):void 0;case"embedded":return e.embedded;default:{let t=JSON.stringify(e.literal);return{key:t,label:t}}}}var Fr={name:"(qualified value shape)",targetNodes:[],targetSubjectsOf:[],targetObjectsOf:[],closed:!1,ignoredProperties:[],properties:[]},Qn=new WeakSet;function Hr(n,e,t){let o=[];e.kind==="property"?zn(n,Fr,t,e.constraint,o):Bn(n,e.shape,t,o);let r=o.find(a=>Qn.has(a));return r?{kind:"undecided",reason:r.message}:o.length===0?{kind:"conforms"}:{kind:"fails"}}function Tr(n,e,t,o){let r=o.ref?l(o.ref):o.embedded?o.embedded.label:JSON.stringify(o.literal);switch(n.component){case"in":return`'${e}' value ${r} is not in the permitted set.`;case"pattern":return`'${e}' value ${r} does not match pattern ${t.pattern?.regex}.`;case"minLength":return`'${e}' value ${r} is shorter than minLength ${t.minLength}.`;case"maxLength":return`'${e}' value ${r} is longer than maxLength ${t.maxLength}.`;case"minInclusive":return`'${e}' value ${r} is below minInclusive ${t.minInclusive} (or not numeric).`;case"maxInclusive":return`'${e}' value ${r} is above maxInclusive ${t.maxInclusive} (or not numeric).`;default:return`'${e}' value ${r} violates ${n.component}.`}}function Tn(n,e){let t=o=>{let r=o.varName;if(o.type==="kanonak.org/transformations/VarRef"&&typeof r=="string"&&r in e)return e[r];throw new Lr(`Conformance lowering produced an unexpected leaf '${o.type}'`)};return Vr(n.expr,void 0,t)===1}function qr(n,e){switch(n){case"IRI":return e.kind==="reference";case"BlankNode":return e.kind==="embedded";case"Literal":return e.kind==="string"||e.kind==="number"||e.kind==="boolean"}}function Wr(n,e){if(e.kind==="reference"||e.kind==="embedded")return`value is a ${e.kind}; sh:datatype requires a literal of ${n.name}.`;let t=Ce(n);if(t!==void 0)switch(t){case L.Boolean:return e.kind==="boolean"?void 0:`value is not a boolean (${n.name}).`;case L.Integer:return e.kind!=="number"?`value is not a number (${n.name}).`:Number.isInteger(e.literal)?void 0:`value is not an integer (${n.name}).`;case L.Decimal:case L.Double:case L.Float:return e.kind==="number"?void 0:`value is not a number (${n.name}).`;default:return e.kind==="string"?void 0:`value is not a string-carried literal (${n.name}).`}}function Br(n,e,t){if(t.kind==="embedded"&&t.embedded?.node){let r=U(t.embedded.node);return r.length===0?`value ${t.embedded.label} has no type; sh:class requires an instance of ${e.name}.`:n.membership.isInstance(r,e)?void 0:`value ${t.embedded.label} is not an instance of ${e.name}.`}if(t.kind!=="reference"||!t.ref)return`value is not a reference; sh:class requires an instance of ${e.name}.`;if(n.scope.reasoning)return n.scope.reasoning.isInstanceOf(t.ref,e)?void 0:`value ${l(t.ref)} is not an instance of ${e.name}.`;let o=t.subject;return o?n.membership.isInstance(U(o),e)?void 0:`value ${l(t.ref)} is not an instance of ${e.name}.`:`value ${l(t.ref)} does not resolve in this scope (sh:class ${e.name}).`}function Gr(n,e,t){if(!e.node)return;let o=new Set([...n.properties.map(a=>l(a.path)),...n.ignoredProperties.map(a=>l(a))]),r=new Set;for(let a of e.node.statement){let u=Le(a);if(!u)continue;let s=l(u.subject);o.has(s)||r.has(s)||(r.add(s),t.push(Ve(n,e,ge,`'${e.label}' carries undeclared property '${u.subject.name}' (closed shape).`,{resultPath:u.subject})))}for(let a of e.node.unresolvedPredicates)r.has(a.key)||(r.add(a.key),t.push(Ve(n,e,ge,`'${e.label}' carries unresolvable property '${a.key}' (closed shape).`,{value:a.key})))}var zr="1.1.0",Qr=new Set([ie,T,q].map(n=>n.name));async function Xn(n){let e=new G(n.repository),t=e.imports(),o=n.result.results.some(i=>Qr.has(i.constraintComponent.name))?"1.2.0":zr,r=t.ensure(oe,te,o,"sh"),a=(i,d)=>i&&i.version&&typeof i.version.major=="number"?`${t.ensure(i.publisher,i.package_,V(i.version),i.package_)}.${i.name}`:d,u={},s=[];return n.result.results.forEach((i,d)=>{let c=`result-${d+1}`;s.push(c);let p={type:`${r}.ValidationResult`,[`${r}.focusNode`]:a(i.focusUri,i.focusNode),[`${r}.resultMessage`]:i.message,[`${r}.resultSeverity`]:`${r}.${i.severity}`,[`${r}.sourceConstraintComponent`]:`${r}.${i.constraintComponent.name}`};i.resultPath&&(p[`${r}.resultPath`]=a(i.resultPath,l(i.resultPath))),i.sourceShapeUri&&(p[`${r}.sourceShape`]=a(i.sourceShapeUri,i.sourceShape)),i.valueRef?p[`${r}.value`]=a(i.valueRef,l(i.valueRef)):i.value!==void 0&&(p[`${r}.value`]=i.value),u[c]=p}),u.report={type:`${r}.ValidationReport`,[`${r}.conforms`]:n.result.conforms,...s.length>0?{[`${r}.result`]:s}:{}},e.buildContentAddressed({publisher:n.publisher,book:t,body:u,...n.header!==void 0?{header:n.header}:{},contentHashProperty:"contentHash"})}import{VersionOperator as Ki}from"@kanonak-protocol/types/document/models/enums";var E="kanonak.org",_="view",Yn="core-kanonak",Xr={publisher:E,package_:_,name:"rootView"},Yr={publisher:E,package_:_,name:"bind"},Jr={publisher:E,package_:_,name:"produces"},Zr={publisher:E,package_:_,name:"projections"},ea={publisher:E,package_:_,name:"where"},na={publisher:E,package_:_,name:"value"},oa={publisher:E,package_:_,name:"as"},le=class{constructor(e,t=new j){this.repository=e;this.parser=t;this.objectParser=new A(this.parser),this.builder=new G(this.repository,this.parser,this.objectParser)}repository;parser;objectParser;builder;async materialize(e,t={}){let o=await this.objectParser.parseKanonaks(this.repository),r=this.resolveView(o,e),a=h(r,Yr);if(!a)throw new Error(`View ${r.namespace}/${r.name} declares no view.bind; cannot materialize.`);let u=h(r,Jr);if(!u)throw new Error(`View ${r.namespace}/${r.name} is a selection view (no view.produces). In-graph materialization of selection views is not yet supported \u2014 declare a view.produces output class to reshape the result.`);let s=ta(r),i=Jn(o,E,Yn),d=Jn(o,E,_),c=this.builder.imports(),p=c.ensure(E,Yn,i,"ck"),f=c.ensure(E,_,d,"v"),R=c.ref(u),$=new vn(this.repository,this.parser,this.objectParser),M=new Pn($,o),Q=this.readProjections(o,r),X=ia(r,ea),Y=this.findInstances(o,a,await this.reason(t)),m={},P=new Set;for(let J of Y){if(!await this.passesWhere(M,o,X,J))continue;let pe={type:R};for(let we of Q){let eo=await this.evaluateValue(M,o,we.value,J),Ue=this.builder.serializeValue(Zn(eo),c);Ue!==void 0&&(pe[c.ref(we.as)]=Ue)}let Oe=k(J);Oe&&(pe[`${f}.derivedFrom`]=c.ref(Oe)),m[this.rowName(J,P)]=pe}let y={};t.resolvedAt&&(y[`${p}.resolvedAt`]=t.resolvedAt),t.invocationId&&(y[`${p}.id`]=t.invocationId);let K=await this.builder.buildContentAddressed({publisher:s,book:c,body:m,contentHashProperty:`${p}.contentHash`,header:y});return{yaml:K.yaml,contentHash:K.contentHash,packageName:K.packageName,publisher:K.publisher,rowCount:K.resourceCount}}resolveView(e,t){let o=x(e,t);if(!o)throw new Error(`View ${t.publisher}/${t.package_}/${t.name} not found in the catalog.`);let r=h(o,Xr);if(r){let a=x(e,r);if(!a)throw new Error(`ViewPackage ${t.name} names rootView ${r.name}, which is not in the catalog.`);return a}return o}readProjections(e,t){let o=[];for(let r of he(t,Zr)){let a=r instanceof N?r:r instanceof v?x(e,r.subject):void 0;if(!a)continue;let u=D(a,na),s=h(a,oa);u&&s&&o.push({value:u,as:s})}return o}async reason(e){return new B({profile:e.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(e,t,o){let r=aa(e),a=[],u=new Set;for(let s of o.getInstancesOfClass(t)){if(u.has(s))continue;u.add(s);let i=r.get(s);i&&a.push(i)}return a.sort((s,i)=>{let d=F(k(s)),c=F(k(i));return d<c?-1:d>c?1:0}),a}async passesWhere(e,t,o,r){for(let a of o){let u=await this.evaluateValue(e,t,a,r);if(!sa(u))return!1}return!0}async evaluateValue(e,t,o,r){let a=_n(o,"view-projection",{catalog:t,depth:0}),u=new Map([["input",r]]);return e.evaluate(a,u)}rowName(e,t){let o=xe(e.name)||"row",r=o,a=2;for(;t.has(r);)r=`${o}-${a++}`;return t.add(r),r}};function Zn(n){return Ke(n)?n.value:Array.isArray(n)?n.map(Zn):n}function ta(n){let e=k(n);if(!e)throw new Error(`Could not derive a publisher from view ${n.namespace}/${n.name}.`);return e.publisher}function Jn(n,e,t){let o=ra(n,e,t);if(!o)throw new Error(`Package ${e}/${t} is not in the catalog; it must be importable to materialize a view.`);return o}function ra(n,e,t){let o;for(let r of n){if(!(r instanceof S))continue;let a=k(r);!a||a.publisher!==e||a.package_!==t||!a.version||(!o||Z(a.version,o)>0)&&(o=a.version)}return o?V(o):void 0}function aa(n){let e=new Map,t=new Map;for(let o of n){if(!(o instanceof S))continue;let r=k(o);if(!r||!r.version)continue;let a=F(r),u=t.get(a);(!u||Z(r.version,u)>0)&&(t.set(a,r.version),e.set(a,o))}return e}function ia(n,e){let t=D(n,e);return t?[t]:he(n,e).filter(o=>o instanceof N)}function sa(n){return n===!0?!0:n===!1||n===void 0||n===null?!1:typeof n=="string"?n.length>0:typeof n=="number"?n!==0:Ke(n)?n.value.length>0:Array.isArray(n)?n.length>0:!!n}export{Mt as AmbiguousReferenceRule,Mo as BooleanStatement,lr as CANONICAL_FORM_VERSION,L as Carrier,qt as ClassDefinitionRule,Lt as ClassHierarchyCycleRule,fo as CompositeKanonakDocumentRepository,hr as DEFAULT_CONSENT_BINDING_PARAM,Lo as DefinedKanonak,sr as DiamondNameClashRule,Bt as DisplayLensScopeRule,po as DocumentLocation,rt as EdgeType,N as EmbeddedKanonak,vt as EmbeddedKanonakTypeRule,Do as EmbeddedStatement,Kr as EntitlementDeniedError,xr as EntitlementProducer,lo as FileSystemKanonakDocumentRepository,dt as GitIgnoreFilter,at as GraphBuilder,xo as HttpKanonakDocumentRepository,Ae as INTEGRITY_PREFIX,fr as ImportBook,It as ImportExistenceRule,fe as InMemoryKanonakDocumentRepository,ko as KANONAK_USER_AGENT,Vo as Kanonak,pt as KanonakDocumentPositions,A as KanonakObjectParser,cr as KanonakObjectValidator,j as KanonakParser,No as KanonakUri,ht as KanonakUriBuilder,kt as KanonakUrlResolver,Yo as KanonakVocabulary,Xt as LINE_STYLES,Rt as LinkTargetRule,Fo as ListStatement,Oo as LiteralKanonak,_o as LocalFirstRepository,Po as LockAwareRepository,tr as LookBandPathRule,er as LookRenderer,Gt as LookSemanticSvgPathRule,Wt as MarkdownLinkRule,Ho as MarkdownStatement,At as NamespaceImportCycleRule,Ct as NamespacePrefixRule,tt as NodeType,$o as NumberStatement,kr as OAuthDiscovery,ct as OWL_RL_CLASSIFICATION_RULES,Dt as ObjectPropertyValueValidationRule,gt as OntologyValidationError,St as OntologyValidationResult,ir as OwlOneOfRule,G as PackageBuilder,Pt as PackageHeaderRule,Er as ProducerRepository,Ft as PropertyDomainRule,Nt as PropertyHierarchyCycleRule,Ht as PropertyKindRangeConsistencyRule,lt as PropertyMetadata,jt as PropertyRangeReferenceRule,Ot as PropertyRangeRequiredRule,xt as PropertyTypeSpecificityRule,Ro as PublisherConfigResolver,Co as PublisherIndex,st as RDFS_RULES,B as Reasoner,ut as ReasoningResult,v as ReferenceKanonak,jo as ReferenceStatement,ho as RepositoryFactory,Tt as ReservedNameShadowRule,Kt as ResourceNamingRule,To as ResourceResolver,Jo as ResourceTypeClassifier,te as SHACL_PACKAGE,oe as SHACL_PUBLISHER,H as SH_NODE_SHAPE,re as SH_PROPERTY_SHAPE,De as SH_SHAPE,Uo as ScalarStatement,or as SequenceNarrativeRule,ar as ShaclShapeRule,wo as Statement,Ao as StringStatement,wt as SubClassOfReferenceRule,Ut as SubPropertyOfReferenceRule,S as SubjectKanonak,_t as SubjectKanonakTypeRequiredRule,gr as TokenCredentialProvider,it as TripleStore,zt as TxExpressionCompilesRule,rr as TxExpressionPathRule,qo as TypeResolver,$t as UnresolvedPredicateRule,Vt as UnresolvedReferenceRule,Et as ValidationCache,bt as ValidationContext,yt as ValidationSeverity,Ki as VersionOperator,le as ViewMaterializer,Rr as allowAllPolicy,go as assertHttpsUrl,Ko as assertPackageIdentity,Io as buildLocalFirstRepository,Zt as buildOntologyModel,Xn as buildReportPackageAsync,se as buildShapesModel,ur as canonicalForm,dr as canonicalHash,Ce as carrierOf,vo as collectKanonakFiles,Z as compareVersions,Ln as computeIntegrity,je as computeIntegrityAsync,pr as contentAddressedName,U as contextTypesOf,yr as createCredentialedFetch,ro as createVersion,qn as evaluateConformance,ot as extractMarkdownLinks,br as findDerivation,nt as findMalformedReferences,mt as findMarkdownLinkAt,ve as foldFlagsIntoPattern,Bo as formatKanonakAddress,V as formatVersion,mo as getGlobalCachePath,yo as getKanonakUserAgent,io as isCompatibleVersion,so as isMajorCompatible,bo as kanonakFetch,In as loadLockFile,ue as lowerConstraint,zo as makeUriKey,Cr as noopMeter,mr as normalizeHost,Sr as parseAuthChallenge,Wo as parseKanonakAddress,$e as parseLockFile,ao as parseVersionString,ft as parseWithPositions,uo as pickHighestDocument,Zo as propertiesInScope,Yt as readSequenceConnectors,O as referenceUris,Qt as resolveDisplayValue,et as resolvePropertyStep,xe as sanitizeName,co as satisfiesVersionOperator,Vn as saveLockFile,On as scopeFromCatalog,wn as scopeFromDocumentAsync,Nn as scopeFromRepositoryAsync,Me as serializeLockFile,Eo as setKanonakFetchRetries,So as setKanonakUserAgent,k as subjectUri,Re as superClassChain,nr as supportedBandKeys,Qo as tripleKey,Go as typeReferenceUris,F as uriKey,Xo as uriTriple,W as valuesOf,no as versionOperatorFromChar,oo as versionOperatorToChar,to as versionsEqual,Jt as walkSequence};
@@ -1,4 +1,5 @@
1
1
  import { DefinedKanonak } from './DefinedKanonak.js';
2
+ import type { KanonakUri } from '../resolution/KanonakUri.js';
2
3
  export declare class EmbeddedKanonak extends DefinedKanonak {
3
4
  /**
4
5
  * Optional source label for this embedded kanonak. Populated when
@@ -16,4 +17,16 @@ export declare class EmbeddedKanonak extends DefinedKanonak {
16
17
  * into a positional list of anonymous embeddeds.
17
18
  */
18
19
  name?: string;
20
+ /**
21
+ * The range of the property this embedded is a value of, resolved in the
22
+ * property's defining scope. An embedded normally omits `type:` because the
23
+ * range already says what it is (the embedding convention), so this is the
24
+ * type it has when it declares none — read through `contextTypesOf`, the one
25
+ * accessor for a node's types, never re-derived by a consumer.
26
+ *
27
+ * A parse-time fact carried on the object, NOT a statement: it adds nothing
28
+ * to the graph an author wrote, so no content hash or serialization changes.
29
+ * Absent when the property's range did not resolve.
30
+ */
31
+ rangeType?: KanonakUri;
19
32
  }
@@ -730,6 +730,7 @@ export declare class LookRenderer {
730
730
  */
731
731
  private renderDetails;
732
732
  private detailRows;
733
+ /** All of a property's values on a node, as one Details cell. */
733
734
  private detailValue;
734
735
  /**
735
736
  * A relational value in the Details sheet: the target's chip-tier
@@ -1067,12 +1068,16 @@ export declare class LookRenderer {
1067
1068
  */
1068
1069
  private readPropertyValueReferences;
1069
1070
  /**
1070
- * Gather the items from a statement value for list-style rendering.
1071
- * Returns the raw IStatement objects (callers dispatch per item).
1071
+ * Every value of a property on a node, as the items the band renderers
1072
+ * dispatch on: a reference or an embedded value as itself, a literal as its
1073
+ * value. Read across EVERY statement for the property and every authored
1074
+ * form (the SDK's one statement walk, `rawValuesOf` — typescript#123), so a
1075
+ * value asserted by a second document renders, and a literal list item
1076
+ * renders as its value.
1072
1077
  */
1073
- private gatherValueItems;
1078
+ private valueItems;
1074
1079
  /**
1075
- * Render one item (from gatherValueItems) as inline HTML — anchor
1080
+ * Render one item (from valueItems) as inline HTML — anchor
1076
1081
  * for references, escaped text for scalars, a nested definition list
1077
1082
  * for embedded resources. slotUri is the look slot the item came from
1078
1083
  * (used for urlForm). `depth` bounds recursion into nested embeddeds.
@@ -1085,7 +1090,7 @@ export declare class LookRenderer {
1085
1090
  * nested definition list, lists as comma-joined items. `depth` bounds
1086
1091
  * recursion into nested embeddeds.
1087
1092
  */
1088
- private renderStatementInlineValue;
1093
+ private renderValuesInline;
1089
1094
  /**
1090
1095
  * Render an embedded (anonymous) resource as a nested definition list of
1091
1096
  * its `predicate → value` pairs. Embedded vs named is purely a
@@ -1 +1 @@
1
- import{a as c,b as d,c as e,d as f}from"../chunk-BS7RRG7D.js";import{m as b}from"../chunk-PVUBHIU2.js";import{a}from"../chunk-HF5FJBS2.js";import"../chunk-7UYXTYXC.js";import"../chunk-CJMVIOZX.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{d as KanonakDocumentPositions,b as KanonakObjectParser,a as KanonakParser,c as PropertyMetadata,f as findMarkdownLinkAt,e as parseWithPositions};
1
+ import{a as c,b as d,c as e,d as f}from"../chunk-VEGFYZXG.js";import{k as b}from"../chunk-JHQPXEMA.js";import{a}from"../chunk-HF5FJBS2.js";import"../chunk-MQBWSCNY.js";import"../chunk-54D47DLS.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{d as KanonakDocumentPositions,b as KanonakObjectParser,a as KanonakParser,c as PropertyMetadata,f as findMarkdownLinkAt,e as parseWithPositions};
@@ -1 +1 @@
1
- import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h,l as i}from"../chunk-PRXC2HZ3.js";import"../chunk-QHABFCRC.js";import"../chunk-PVUBHIU2.js";import"../chunk-HF5FJBS2.js";import"../chunk-7UYXTYXC.js";import"../chunk-CJMVIOZX.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{h as EntitlementDeniedError,i as EntitlementProducer,c as ImportBook,a as PackageBuilder,e as ProducerRepository,f as allowAllPolicy,b as contentAddressedName,g as noopMeter,d as sanitizeName};
1
+ import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h,l as i}from"../chunk-2Y6R3K5A.js";import"../chunk-QHABFCRC.js";import"../chunk-JHQPXEMA.js";import"../chunk-HF5FJBS2.js";import"../chunk-MQBWSCNY.js";import"../chunk-54D47DLS.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{h as EntitlementDeniedError,i as EntitlementProducer,c as ImportBook,a as PackageBuilder,e as ProducerRepository,f as allowAllPolicy,b as contentAddressedName,g as noopMeter,d as sanitizeName};
@@ -1 +1 @@
1
- import{a as g,b as h,c as i,d as j,e as k}from"../chunk-EVMSO7HJ.js";import"../chunk-PVUBHIU2.js";import"../chunk-HF5FJBS2.js";import{ca as e,da as f,e as a,f as b,g as c,i as d}from"../chunk-7UYXTYXC.js";import"../chunk-CJMVIOZX.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{f as KanonakVocabulary,i as OWL_RL_CLASSIFICATION_RULES,h as RDFS_RULES,k as Reasoner,j as ReasoningResult,g as TripleStore,e as canonicalizeBuiltinUri,b as makeUriKey,c as tripleKey,a as uriKey,d as uriTriple};
1
+ import{a as g,b as h,c as i,d as j,e as k}from"../chunk-26SO3A4B.js";import"../chunk-JHQPXEMA.js";import"../chunk-HF5FJBS2.js";import{e as a,f as b,g as c,i as d,ja as e,ka as f}from"../chunk-MQBWSCNY.js";import"../chunk-54D47DLS.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{f as KanonakVocabulary,i as OWL_RL_CLASSIFICATION_RULES,h as RDFS_RULES,k as Reasoner,j as ReasoningResult,g as TripleStore,e as canonicalizeBuiltinUri,b as makeUriKey,c as tripleKey,a as uriKey,d as uriTriple};
@@ -1,5 +1,6 @@
1
1
  import type { Kanonak } from '../kanonaks/Kanonak.js';
2
2
  import { SubjectKanonak } from '../kanonaks/SubjectKanonak.js';
3
+ import type { DefinedKanonak } from '../kanonaks/DefinedKanonak.js';
3
4
  import { KanonakUri } from './KanonakUri.js';
4
5
  import { type PropertyClassKind } from './ResourceTypeClassifier.js';
5
6
  import { type EntityUri } from '../uri-helpers/index.js';
@@ -80,5 +81,14 @@ export interface StepResolution {
80
81
  * descriptor on success, or a diagnostic message on failure.
81
82
  */
82
83
  export declare function resolvePropertyStep(catalog: Kanonak[], classUri: EntityUri, propertyUri: EntityUri): StepResolution;
83
- /** The type URIs declared on an instance — the completion context. */
84
- export declare function contextTypesOf(instance: SubjectKanonak): KanonakUri[];
84
+ /**
85
+ * The types of a node — THE accessor for "what is this an instance of".
86
+ *
87
+ * The types it declares with `type:`; for an embedded value that declares
88
+ * none, the range of the property it is a value of (recorded by the parser
89
+ * as `EmbeddedKanonak.rangeType`). That is the embedding convention made
90
+ * readable: an embedded omits `type:` precisely because the range already
91
+ * says it, and an explicit type only ever narrows the range. A consumer asks
92
+ * here instead of re-deriving the range itself.
93
+ */
94
+ export declare function contextTypesOf(instance: DefinedKanonak): KanonakUri[];
@@ -1 +1 @@
1
- import{a as F}from"../chunk-XK24CN3C.js";import{a as o}from"../chunk-SC5M74NM.js";import{a as G}from"../chunk-PEJALHXK.js";import{a as q,b as r,c as s,d as t,ea as u,fa as v,ga as w,ha as x,ia as y,ja as z,ka as A,la as B,ma as C,na as D,oa as E}from"../chunk-7UYXTYXC.js";import"../chunk-CJMVIOZX.js";import{a as p}from"../chunk-FUUTGGJS.js";import{a as l,b as m,c as n}from"../chunk-F67UH4FD.js";import{a,b,c,d,e,f,g,h,i,j,k}from"../chunk-QILEJIFU.js";export{l as IMPORT_MODES,p as KanonakUri,F as KanonakUriBuilder,G as KanonakUrlResolver,q as ResourceResolver,v as ResourceTypeClassifier,r as TypeResolver,o as assertPackageIdentity,c as compareVersions,E as contextTypesOf,u as corePropertyClassOf,f as createVersion,t as formatKanonakAddress,e as formatVersion,h as isCompatibleVersion,B as isDatatypePropertySubject,m as isLinkImport,i as isMajorCompatible,A as isObjectPropertySubject,z as isPropertySubject,n as linkedPackages,s as parseKanonakAddress,g as parseVersionString,k as pickHighestDocument,C as propertiesInScope,y as propertyClassOf,D as resolvePropertyStep,j as satisfiesVersionOperator,w as subjectUri,x as superClassChain,a as versionOperatorFromChar,b as versionOperatorToChar,d as versionsEqual};
1
+ import{a as F}from"../chunk-XK24CN3C.js";import{a as o}from"../chunk-SC5M74NM.js";import{a as G}from"../chunk-PEJALHXK.js";import{a as q,b as r,c as s,d as t,la as u,ma as v,na as w,oa as x,pa as y,qa as z,ra as A,sa as B,ta as C,ua as D,va as E}from"../chunk-MQBWSCNY.js";import"../chunk-54D47DLS.js";import{a as p}from"../chunk-FUUTGGJS.js";import{a as l,b as m,c as n}from"../chunk-F67UH4FD.js";import{a,b,c,d,e,f,g,h,i,j,k}from"../chunk-QILEJIFU.js";export{l as IMPORT_MODES,p as KanonakUri,F as KanonakUriBuilder,G as KanonakUrlResolver,q as ResourceResolver,v as ResourceTypeClassifier,r as TypeResolver,o as assertPackageIdentity,c as compareVersions,E as contextTypesOf,u as corePropertyClassOf,f as createVersion,t as formatKanonakAddress,e as formatVersion,h as isCompatibleVersion,B as isDatatypePropertySubject,m as isLinkImport,i as isMajorCompatible,A as isObjectPropertySubject,z as isPropertySubject,n as linkedPackages,s as parseKanonakAddress,g as parseVersionString,k as pickHighestDocument,C as propertiesInScope,y as propertyClassOf,D as resolvePropertyStep,j as satisfiesVersionOperator,w as subjectUri,x as superClassChain,a as versionOperatorFromChar,b as versionOperatorToChar,d as versionsEqual};
@@ -1,4 +1,4 @@
1
- import"../chunk-XK24CN3C.js";import"../chunk-SC5M74NM.js";import{d as g}from"../chunk-HENE47QG.js";import"../chunk-QHABFCRC.js";import"../chunk-6VIUXP4N.js";import"../chunk-PVUBHIU2.js";import"../chunk-HF5FJBS2.js";import"../chunk-PEJALHXK.js";import{ga as m,oa as S}from"../chunk-7UYXTYXC.js";import{c as v,m as p,t as E}from"../chunk-CJMVIOZX.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import{c as x}from"../chunk-QILEJIFU.js";import{homedir as P}from"os";import{join as d}from"path";import{existsSync as M,mkdirSync as D,readFileSync as j,writeFileSync as O}from"fs";import{createHash as C}from"crypto";import{pathToFileURL as B}from"url";var h="Xenova/all-MiniLM-L6-v2",w="q8",b=32;async function F(r){let{pipeline:e,env:t}=r.transformers;t.cacheDir=r.modelCacheDir??d(P(),".kanonak","models");let n=await e("feature-extraction",h,{dtype:w});return async s=>(await n(s,{pooling:"mean",normalize:!0})).tolist()}async function z(r){let e=d(r,"node_modules","@huggingface","transformers"),t=JSON.parse(j(d(e,"package.json"),"utf-8")),n=I(t);if(!n)throw new Error(`@huggingface/transformers at ${e} exposes no resolvable ESM entry.`);let s=await import(B(d(e,n)).href);return typeof s.pipeline=="function"?s:s.default}function I(r){let e=r.exports,t=n=>typeof n=="string"?n:n?.default;return typeof e=="string"?e:t(e?.node?.import)??t(e?.import)??t(e?.default)??r.module??r.main}var y=null;async function U(){return y||(y=(async()=>{let r;try{r=await import("@huggingface/transformers")}catch(e){throw new Error(`Semantic search requires the embedding runtime, which is an optional dependency.
1
+ import"../chunk-XK24CN3C.js";import"../chunk-SC5M74NM.js";import{d as g}from"../chunk-D7QLWVPK.js";import"../chunk-QHABFCRC.js";import"../chunk-6VIUXP4N.js";import"../chunk-JHQPXEMA.js";import"../chunk-HF5FJBS2.js";import"../chunk-PEJALHXK.js";import{na as m,va as S}from"../chunk-MQBWSCNY.js";import{c as v,o as p,w as E}from"../chunk-54D47DLS.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import{c as x}from"../chunk-QILEJIFU.js";import{homedir as P}from"os";import{join as d}from"path";import{existsSync as M,mkdirSync as D,readFileSync as j,writeFileSync as O}from"fs";import{createHash as C}from"crypto";import{pathToFileURL as B}from"url";var h="Xenova/all-MiniLM-L6-v2",w="q8",b=32;async function F(r){let{pipeline:e,env:t}=r.transformers;t.cacheDir=r.modelCacheDir??d(P(),".kanonak","models");let n=await e("feature-extraction",h,{dtype:w});return async s=>(await n(s,{pooling:"mean",normalize:!0})).tolist()}async function z(r){let e=d(r,"node_modules","@huggingface","transformers"),t=JSON.parse(j(d(e,"package.json"),"utf-8")),n=I(t);if(!n)throw new Error(`@huggingface/transformers at ${e} exposes no resolvable ESM entry.`);let s=await import(B(d(e,n)).href);return typeof s.pipeline=="function"?s:s.default}function I(r){let e=r.exports,t=n=>typeof n=="string"?n:n?.default;return typeof e=="string"?e:t(e?.node?.import)??t(e?.import)??t(e?.default)??r.module??r.main}var y=null;async function U(){return y||(y=(async()=>{let r;try{r=await import("@huggingface/transformers")}catch(e){throw new Error(`Semantic search requires the embedding runtime, which is an optional dependency.
2
2
  Install it with:
3
3
  npm install @huggingface/transformers
4
4
  (underlying import error: ${e.message})`)}return F({transformers:r})})()),y}function H(r,e){let t=0;for(let n=0;n<r.length;n++)t+=r[n]*e[n];return t}function R(r,e){return e?r.version?e.version?x(r.version,e.version)>0:!0:!1:!0}function K(r,e){let t=g(r,e),n=[t.label],s=S(e);if(s.length>0){let i=E(r,s[0]),a=i?g(r,i).label:s[0].name;a&&n.push(`\u2014 a ${a}.`)}return t.summary&&n.push(t.summary),n.join(" ")}function q(r){let e=new Map;for(let t of r){if(!(t instanceof v))continue;let n=m(t);if(!n)continue;let s=p(n),i=e.get(s);(!i||R(n,m(i)))&&e.set(s,t)}return[...e.values()].sort((t,n)=>{let s=m(t)?p(m(t)):t.name,i=m(n)?p(m(n)):n.name;return s.localeCompare(i)})}var k=class{entries=[];embedder;constructor(e={}){this.embedder=e.embedder}resolveEmbedder(){return this.embedder?Promise.resolve(this.embedder):U()}get size(){return this.entries.length}async build(e,t={}){let n=q(e);if(t.include&&(n=n.filter(t.include)),n.length===0)return this.entries=[],{size:0,cached:!1};let s=n.map(o=>K(e,o)),i=t.cacheDir,a;if(i){let o=C("sha256").update(h+"|"+w+`
@@ -1,4 +1,4 @@
1
- import{c as Pe}from"../chunk-V3DH67P3.js";import{a as be,d as X,f as Se,h as ee}from"../chunk-IS3AQKB4.js";import{e as ve,g as $e,m as U,n as Z}from"../chunk-BZ3YTI3C.js";import"../chunk-XK24CN3C.js";import"../chunk-SC5M74NM.js";import{a as H,b as G}from"../chunk-KIBR3HAT.js";import{r as te}from"../chunk-HENE47QG.js";import"../chunk-QHABFCRC.js";import{a as ye}from"../chunk-6VIUXP4N.js";import{m as oe}from"../chunk-PVUBHIU2.js";import{a as O}from"../chunk-HF5FJBS2.js";import{a as xe}from"../chunk-PEJALHXK.js";import{c as Re}from"../chunk-7UYXTYXC.js";import{c as we,u as re}from"../chunk-CJMVIOZX.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import{c as V,e as E,f as W,g as ke}from"../chunk-QILEJIFU.js";import{readFileSync as de,writeFileSync as Ie,mkdirSync as Me}from"fs";import{join as se}from"path";import Fe from"js-yaml";var _e=[{publisher:"kanonak.org",package_:"core-kanonak"},{publisher:"kanonak.org",package_:"site"},{publisher:"kanonak.org",package_:"link"},{publisher:"kanonak.org",package_:"look-tokens"},{publisher:"kanonak.org",package_:"look-styles"},{publisher:"kanonak.org",package_:"look"},{publisher:"kanonak.org",package_:"universal-look"}];function q(o){return _e}function C(o){return`${o.publisher}/${o.package_}`}function z(o,e=[]){let c={"kanonak.org/look-styles":"pages render UNSTYLED \u2014 generated CSS stops at the :root token block","kanonak.org/look-tokens":"the :root block loses the universal design-token floor (colors, fonts, spacing)","kanonak.org/universal-look":"resources without their own look render as an empty HTML comment","kanonak.org/look":"band vocabulary (Hero, PropertyList, \u2026) is unresolvable \u2014 declared looks cannot render","kanonak.org/site":"the site vocabulary (content, navigation) is unresolvable \u2014 the base stylesheet cannot bind","kanonak.org/core-kanonak":"the Package/Publisher classes are unresolvable \u2014 package and publisher pages degrade","kanonak.org/link":"link vocabulary is unresolvable \u2014 cross-reference styling degrades"},r=[];for(let t of o)if(t.origin==="missing"){let a=C(t),u=c[a]??"whatever this package contributes to rendering is lost";r.push(`Render-stack package ${a} is MISSING (${t.reason??"unknown reason"}) \u2014 ${u}. Fix: kanonak install ${a} (as the user running the render), or restore network access to ${t.publisher}.`)}else t.resolvedButNotInCatalog&&r.push(`Render-stack package ${C(t)} resolved (${t.origin}) but is NOT in the parsed catalog \u2014 this is a closure-scoping bug; please report it.`);for(let t of e)r.push(`Import edge ${t.fromNamespace} \u2192 ${t.publisher}/${t.packageName} ${t.constraint} did NOT resolve (${t.reason==="no-compatible-version"?"no compatible version in the repository":"resolution threw"}) \u2014 every statement ${t.fromNamespace} authors against ${t.publisher}/${t.packageName} entities is dropped from the parse as an unresolved predicate (a look declaration loses its bands and pages render empty; see typescript#91). Fix: add a ${t.constraint}-compatible version of ${t.publisher}/${t.packageName} to the workspace or cache (kanonak install ${t.publisher}/${t.packageName}), or bump the import in ${t.fromNamespace}.`);return r}function ne(o){let{publisher:e,availablePublishers:c,catalog:r,lookRenderer:t,localNamespaces:a,rawByNsKey:u,renderStack:d,producers:k,lockSource:y,configSource:s}=o,l=new Map,f=new Map,p=new Map,m=new Set;for(let S of r){if(!(S instanceof we))continue;let w=S.namespace||"";if(!a.has(w))continue;l.set(`${w}/${S.name}`,S);let P=w.split("/")[1]??"",[_,F]=P.split("@");if(!_||!F)continue;let D=ke(F);D&&(m.has(P)||(m.add(P),f.has(_)||f.set(_,[]),f.get(_).push({verStr:F,version:D})),S.name===_&&p.set(P,S))}for(let S of f.values())S.sort((w,P)=>V(P.version,w.version));return{publisher:e,availablePublishers:c,catalog:r,lookRenderer:t,localNamespaces:a,rawByNsKey:u,bySubject:l,pkgVersions:f,pkgSelfByVer:p,renderStack:d,...k?{producers:k}:{},...y?{lockSource:y}:{},...s?{configSource:s}:{}}}async function pe(o,e={}){let c=new O,r=new ye(c),t=[],a=[];for(let i of ee(o)){let h;try{h=de(i,"utf-8")}catch{continue}let n;try{n=c.parse(h).metadata?.namespace_}catch{continue}if(!n?.version)continue;let g=n.version;a.push({publisher:n.publisher,package_:n.package_,verStr:E(g),version:g,source:h})}a.sort((i,h)=>V(h.version,i.version));for(let i of a)await r.saveDocumentAsync(c.parse(i.source),`${i.publisher}/${i.package_}@${i.verStr}`),t.push({publisher:i.publisher,package_:i.package_,verStr:i.verStr,source:i.source});let u=[...new Set(t.map(i=>i.publisher))].sort(),d=e.publisher;if(d){if(!u.includes(d))throw new Error(`Publisher "${d}" not found in workspace. Available: ${u.join(", ")||"(none)"}`)}else if(u.length===1)d=u[0];else throw u.length===0?new Error(`No Kanonak packages found under ${o}`):new Error(`Workspace has multiple publishers (${u.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let k=new Set,y=new Map;for(let i of t)i.publisher===d&&(k.add(`${i.publisher}/${i.package_}@${i.verStr}`),y.set(`${i.package_}@${i.verStr}`,i.source));let s=X(),l=new be(s,!0,c),f={};e.httpCache&&(f.getFromCache=e.httpCache.getFromCache,f.onFetch=e.httpCache.onFetch),e.fetchFn&&(f.fetchFn=e.fetchFn);let p=e.repository??new Se(r,l,new Z(f)),m=e.log??(()=>{}),S=q(void 0),w=[],P=i=>i.map(h=>h.metadata.namespace_?.version).filter(h=>h!==void 0).sort((h,n)=>V(n,h)).map(E);if(!e.repository){m(`[render-stack] resolving ${S.length} ambient look-stack package(s); cache: ${s}`);let i=e.fetchFn?new U({fetchFn:e.fetchFn}):new U;for(let h of S){let n=C(h),g=await r.getDocumentsByNamespaceAsync(h.publisher,h.package_);if(g.length>0){let v=P(g);w.push({...h,origin:"workspace",versions:v}),m(`[render-stack] ${n} \u2014 workspace (${v.join(", ")})`);continue}let b=await l.getDocumentsByNamespaceAsync(h.publisher,h.package_);if(b.length>0){let v=P(b);w.push({...h,origin:"cache",versions:v}),m(`[render-stack] ${n} \u2014 cache (${v.join(", ")})`);continue}try{let $=(await i.getLock(h.publisher))?.packages[`${h.publisher}/${h.package_}`];if(!$){let j=`publisher ${h.publisher} reachable but its lock does not pin ${h.package_}`;w.push({...h,origin:"missing",reason:j}),m(`[render-stack] ${n} \u2014 MISSING: ${j}`);continue}let I=$.version,T=$.resolved,Q=await(e.fetchFn?e.fetchFn(T,h.publisher):ve(T));if(!Q.ok){let j=`fetch ${T} failed: HTTP ${Q.status} ${Q.statusText}`;w.push({...h,origin:"missing",reason:j}),m(`[render-stack] ${n} \u2014 MISSING: ${j}`);continue}let fe=await Q.text();await r.saveDocumentAsync(c.parse(fe),`${h.publisher}/${h.package_}@${I}`);try{let j=se(s,h.publisher);Me(j,{recursive:!0}),Ie(se(j,`${h.package_}@${I}.kan.yml`),fe,"utf-8"),w.push({...h,origin:"fetched",versions:[I]}),m(`[render-stack] ${n}@${I} \u2014 fetched from ${T}, installed to cache`)}catch(j){w.push({...h,origin:"fetched",versions:[I]}),m(`[render-stack] ${n}@${I} \u2014 fetched from ${T}, but cache ${s} is NOT WRITABLE (${j.message}); usable for this load only \u2014 every load will re-fetch it`)}}catch(v){let $=`fetch failed: ${v.message}`;w.push({...h,origin:"missing",reason:$}),m(`[render-stack] ${n} \u2014 MISSING: ${$}`)}}}let _=(await r.getAllDocumentsAsync()).filter(i=>i.metadata.namespace_?.publisher===d);for(let i of S)_.push(...await p.getDocumentsByNamespaceAsync(i.publisher,i.package_));let F=[],D=await H(_,p,{onUnresolvedEdge:i=>F.push(i)}),A=p;if(!e.repository){for(let i of S)D.add(C(i));A=new G(p,D)}let B=await new oe(c).parseKanonaks(A),ce=new te(B),le=(i,h)=>re(B,{publisher:i,package_:h,name:h}).length>0,N;if(e.repository){N=[];for(let i of S){let h=await p.getDocumentsByNamespaceAsync(i.publisher,i.package_);N.push(h.length>0?{...i,origin:"repository",versions:P(h)}:{...i,origin:"missing",reason:"not present in the caller-supplied repository"})}}else N=w.map(i=>i.origin==="missing"||le(i.publisher,i.package_)?i:{...i,resolvedButNotInCatalog:!0});let Y=z(N,F);for(let i of Y)m(`[render-stack] WARNING: ${i}`);let J={contractSource:"universal-default",cachePath:s,packages:N,warnings:Y},K;try{K=de(se(o,"kanonak.lock"),"utf-8")}catch{K=De(d,t,c)}let L;try{L=de(se(o,".well-known","kanonak.json"),"utf-8")}catch{L=void 0}return ne({publisher:d,availablePublishers:u,catalog:B,lookRenderer:ce,localNamespaces:k,rawByNsKey:y,renderStack:J,...K?{lockSource:K}:{},...L?{configSource:L}:{}})}function De(o,e,c){let r=new Map;for(let a of e)a.publisher===o&&(r.has(a.package_)||r.set(a.package_,{verStr:a.verStr,source:a.source}));if(r.size===0)return;let t={};for(let a of[...r.keys()].sort()){let{verStr:u,source:d}=r.get(a),k={},y;try{y=c.parse(d).metadata?.imports}catch{y=void 0}for(let l of y?.[o]??[]){let f=r.get(l.packageName);f&&(k[`${o}/${l.packageName}`]=f.verStr)}let s={};for(let l of Object.keys(k).sort())s[l]=k[l];t[`${o}/${a}`]={version:u,resolved:`https://${o}/${a}/${u}.kan.yml`,integrity:Pe(d),dependencies:s}}return Fe.dump({version:"1",lastUpdated:"",packages:t},{lineWidth:-1,sortKeys:!1,quotingType:'"'})}import{existsSync as Ee,readFileSync as Ke,writeFileSync as Ve,mkdirSync as Ae}from"fs";import{join as je}from"path";async function ue(o,e={}){let c=new O,r=Re(o),t=r.kind==="resource"?r.uri.publisher:r.publisher,a=e.log??(()=>{}),u=e.cacheRoot??X(),d=(n,g,b)=>je(u,n,`${g}@${b}.kan.yml`),k=new Set,y=new Set,s=new Map,l=new Z({getFromCache:(n,g,b)=>{let v=d(n,g,b),$=Ee(v)?Ke(v,"utf-8"):null;return $!==null&&k.add(`${n}/${g}`),$},onFetch:(n,g,b,v)=>{y.add(`${n}/${g}`);try{let $=je(u,n);Ae($,{recursive:!0}),Ve(d(n,g,b),v,"utf-8")}catch($){s.set(`${n}/${g}`,$.message),a(`[render] fetched ${n}/${g}@${b} but cache ${u} is NOT WRITABLE (${$.message}); usable for this load only \u2014 every load will re-fetch it`)}},...e.fetchFn?{fetchFn:e.fetchFn}:{}}),f=new U(e.fetchFn?{fetchFn:e.fetchFn}:void 0),p;if(r.kind==="resource"){let n=r.uri.version;p=[n?{package_:r.uri.package_,version:`${n.major}.${n.minor}.${n.patch}`}:{package_:r.uri.package_}]}else if(r.kind==="package"){let n=r.version;p=[n?{package_:r.package_,version:`${n.major}.${n.minor}.${n.patch}`}:{package_:r.package_}]}else p=((await f.getConfig(t)).featured_packages??[]).map(g=>({package_:g}));let m=async(n,g,b)=>{try{let v=b?c.buildImport(g,"=",b,n):c.buildImport(g,"*","0.0.0",n),$=await l.getHighestCompatibleVersionAsync(n,v);return $?{doc:$}:{doc:null,error:`${n} did not resolve ${g}${b?`@${b}`:""} (not in its index, or unreachable)`}}catch(v){return{doc:null,error:v.message}}},S=[],w=[];for(let n of p){let{doc:g,error:b}=await m(t,n.package_,n.version);g?S.push(g):b&&w.push(b)}if(S.length===0)throw new Error(`Could not fetch any package for address "${o}" from publisher "${t}".`+(w.length>0?` Reasons: ${w.join("; ")}`:""));let P=q(),_="universal-default",F=n=>n.map(g=>g.metadata.namespace_?.version).filter(g=>g!==void 0).sort((g,b)=>V(b,g)).map(E);a(`[render-stack] resolving ${P.length} ambient look-stack package(s) (contract: ${_}); cache: ${u}`);let D=[],A=[];for(let n of P){let g=C(n),{doc:b,error:v}=await m(n.publisher,n.package_,void 0);if(b){D.push(b);let $=F([b]),I=y.has(g)?"fetched":k.has(g)?"cache":"fetched";A.push({...n,origin:I,versions:$}),a(`[render-stack] ${g} \u2014 ${I} (${$.join(", ")})`+(s.has(g)?" [cache write FAILED \u2014 will re-fetch next load]":""))}else A.push({...n,origin:"missing",reason:v??"unresolved"}),a(`[render-stack] ${g} \u2014 MISSING: ${v??"unresolved"}`)}let B=[],ce=await H([...S,...D],l,{onUnresolvedEdge:n=>B.push(n)}),le=new G(l,ce),N=await new oe(c).parseKanonaks(le),Y=new te(N),J=A.map(n=>n.origin==="missing"||re(N,{publisher:n.publisher,package_:n.package_,name:n.package_}).length>0?n:{...n,resolvedButNotInCatalog:!0}),K=z(J,B);for(let n of K)a(`[render-stack] WARNING: ${n}`);let L={contractSource:_,cachePath:u,packages:J,warnings:K},i=new Set,h=new Map;for(let n of await l.getAllDocumentsAsync()){let g=n.metadata.namespace_;if(!g?.version||g.publisher!==t)continue;let b=E(g.version),v=`${g.publisher}/${g.package_}@${b}`;i.add(v);let $=await l.getDocumentContentAsync(v);$!==null&&h.set(`${g.package_}@${b}`,$)}return ne({publisher:t,availablePublishers:[t],catalog:N,lookRenderer:Y,localNamespaces:i,rawByNsKey:h,renderStack:L})}import{VersionOperator as ie}from"@kanonak-protocol/types/document/models/enums";function ae(o){let{lookRenderer:e,publisher:c,renderStack:r,catalog:t}=o,a=e.explainStylesheet(e.publisherSubject(c)),u=[...a.tokens.entries()].map(([p,m])=>({name:p,value:m.value,source:`${m.sourceNamespace}/${m.sourceName}`,level:m.level})),d=a.baseStylesheet,k={present:d.css!==void 0,...d.sourceNamespace!==void 0?{source:d.sourceNamespace}:{},...d.scope!==void 0?{scope:d.scope}:{},...d.css!==void 0?{bytes:d.css.length}:{},...d.problem!==void 0?{problem:d.problem}:{},candidates:d.candidates},y=new Map;for(let p of t){let m=p.namespace;m&&y.set(m,(y.get(m)??0)+1)}let s=[...y.entries()].map(([p,m])=>({namespace:p,resources:m})).sort((p,m)=>p.namespace.localeCompare(m.namespace)),l=e.expressionFailures().map(p=>({carrier:p.carrier,reason:p.reason})),f=l.map(p=>`Expression carrier "${p.carrier}" did not compile: ${p.reason} Consequence: that value renders as nothing (and a parent operation consuming it may drop its whole tier). Fix: use a tx.Expression node class the runner implements, or remove the carrier.`);return{publisher:c,renderStack:{contractSource:r.contractSource,cachePath:r.cachePath,packages:r.packages.map(p=>({package_:C(p),origin:p.origin,...p.versions!==void 0?{versions:p.versions}:{},...p.reason!==void 0?{reason:p.reason}:{},...p.resolvedButNotInCatalog!==void 0?{resolvedButNotInCatalog:p.resolvedButNotInCatalog}:{}}))},stylesheet:{tokens:u,baseStylesheet:k,...a.look?{look:{sourceClass:`${a.look.sourceClass.publisher}/${a.look.sourceClass.package_}/${a.look.sourceClass.name}`}}:{}},expressionCarriers:l,catalog:s,warnings:[...r.warnings,...a.warnings.filter(p=>!r.warnings.includes(p)),...f]}}function Be(o){return o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ge(o){let e=Be,c=o.warnings.length===0,r=o.expressionCarriers.map(s=>`<tr><td><code>${e(s.carrier)}</code></td><td>${e(s.reason)}</td></tr>`).join(`
1
+ import{c as Pe}from"../chunk-V3DH67P3.js";import{a as be,d as X,f as Se,h as ee}from"../chunk-IS3AQKB4.js";import{e as ve,g as $e,m as U,n as Z}from"../chunk-BZ3YTI3C.js";import"../chunk-XK24CN3C.js";import"../chunk-SC5M74NM.js";import{a as H,b as G}from"../chunk-KIBR3HAT.js";import{r as te}from"../chunk-D7QLWVPK.js";import"../chunk-QHABFCRC.js";import{a as ye}from"../chunk-6VIUXP4N.js";import{k as oe}from"../chunk-JHQPXEMA.js";import{a as O}from"../chunk-HF5FJBS2.js";import{a as xe}from"../chunk-PEJALHXK.js";import{c as Re}from"../chunk-MQBWSCNY.js";import{c as we,x as re}from"../chunk-54D47DLS.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import{c as V,e as E,f as W,g as ke}from"../chunk-QILEJIFU.js";import{readFileSync as de,writeFileSync as Ie,mkdirSync as Me}from"fs";import{join as se}from"path";import Fe from"js-yaml";var _e=[{publisher:"kanonak.org",package_:"core-kanonak"},{publisher:"kanonak.org",package_:"site"},{publisher:"kanonak.org",package_:"link"},{publisher:"kanonak.org",package_:"look-tokens"},{publisher:"kanonak.org",package_:"look-styles"},{publisher:"kanonak.org",package_:"look"},{publisher:"kanonak.org",package_:"universal-look"}];function q(o){return _e}function C(o){return`${o.publisher}/${o.package_}`}function z(o,e=[]){let c={"kanonak.org/look-styles":"pages render UNSTYLED \u2014 generated CSS stops at the :root token block","kanonak.org/look-tokens":"the :root block loses the universal design-token floor (colors, fonts, spacing)","kanonak.org/universal-look":"resources without their own look render as an empty HTML comment","kanonak.org/look":"band vocabulary (Hero, PropertyList, \u2026) is unresolvable \u2014 declared looks cannot render","kanonak.org/site":"the site vocabulary (content, navigation) is unresolvable \u2014 the base stylesheet cannot bind","kanonak.org/core-kanonak":"the Package/Publisher classes are unresolvable \u2014 package and publisher pages degrade","kanonak.org/link":"link vocabulary is unresolvable \u2014 cross-reference styling degrades"},r=[];for(let t of o)if(t.origin==="missing"){let a=C(t),u=c[a]??"whatever this package contributes to rendering is lost";r.push(`Render-stack package ${a} is MISSING (${t.reason??"unknown reason"}) \u2014 ${u}. Fix: kanonak install ${a} (as the user running the render), or restore network access to ${t.publisher}.`)}else t.resolvedButNotInCatalog&&r.push(`Render-stack package ${C(t)} resolved (${t.origin}) but is NOT in the parsed catalog \u2014 this is a closure-scoping bug; please report it.`);for(let t of e)r.push(`Import edge ${t.fromNamespace} \u2192 ${t.publisher}/${t.packageName} ${t.constraint} did NOT resolve (${t.reason==="no-compatible-version"?"no compatible version in the repository":"resolution threw"}) \u2014 every statement ${t.fromNamespace} authors against ${t.publisher}/${t.packageName} entities is dropped from the parse as an unresolved predicate (a look declaration loses its bands and pages render empty; see typescript#91). Fix: add a ${t.constraint}-compatible version of ${t.publisher}/${t.packageName} to the workspace or cache (kanonak install ${t.publisher}/${t.packageName}), or bump the import in ${t.fromNamespace}.`);return r}function ne(o){let{publisher:e,availablePublishers:c,catalog:r,lookRenderer:t,localNamespaces:a,rawByNsKey:u,renderStack:d,producers:k,lockSource:y,configSource:s}=o,l=new Map,f=new Map,p=new Map,m=new Set;for(let S of r){if(!(S instanceof we))continue;let w=S.namespace||"";if(!a.has(w))continue;l.set(`${w}/${S.name}`,S);let P=w.split("/")[1]??"",[_,F]=P.split("@");if(!_||!F)continue;let D=ke(F);D&&(m.has(P)||(m.add(P),f.has(_)||f.set(_,[]),f.get(_).push({verStr:F,version:D})),S.name===_&&p.set(P,S))}for(let S of f.values())S.sort((w,P)=>V(P.version,w.version));return{publisher:e,availablePublishers:c,catalog:r,lookRenderer:t,localNamespaces:a,rawByNsKey:u,bySubject:l,pkgVersions:f,pkgSelfByVer:p,renderStack:d,...k?{producers:k}:{},...y?{lockSource:y}:{},...s?{configSource:s}:{}}}async function pe(o,e={}){let c=new O,r=new ye(c),t=[],a=[];for(let i of ee(o)){let h;try{h=de(i,"utf-8")}catch{continue}let n;try{n=c.parse(h).metadata?.namespace_}catch{continue}if(!n?.version)continue;let g=n.version;a.push({publisher:n.publisher,package_:n.package_,verStr:E(g),version:g,source:h})}a.sort((i,h)=>V(h.version,i.version));for(let i of a)await r.saveDocumentAsync(c.parse(i.source),`${i.publisher}/${i.package_}@${i.verStr}`),t.push({publisher:i.publisher,package_:i.package_,verStr:i.verStr,source:i.source});let u=[...new Set(t.map(i=>i.publisher))].sort(),d=e.publisher;if(d){if(!u.includes(d))throw new Error(`Publisher "${d}" not found in workspace. Available: ${u.join(", ")||"(none)"}`)}else if(u.length===1)d=u[0];else throw u.length===0?new Error(`No Kanonak packages found under ${o}`):new Error(`Workspace has multiple publishers (${u.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let k=new Set,y=new Map;for(let i of t)i.publisher===d&&(k.add(`${i.publisher}/${i.package_}@${i.verStr}`),y.set(`${i.package_}@${i.verStr}`,i.source));let s=X(),l=new be(s,!0,c),f={};e.httpCache&&(f.getFromCache=e.httpCache.getFromCache,f.onFetch=e.httpCache.onFetch),e.fetchFn&&(f.fetchFn=e.fetchFn);let p=e.repository??new Se(r,l,new Z(f)),m=e.log??(()=>{}),S=q(void 0),w=[],P=i=>i.map(h=>h.metadata.namespace_?.version).filter(h=>h!==void 0).sort((h,n)=>V(n,h)).map(E);if(!e.repository){m(`[render-stack] resolving ${S.length} ambient look-stack package(s); cache: ${s}`);let i=e.fetchFn?new U({fetchFn:e.fetchFn}):new U;for(let h of S){let n=C(h),g=await r.getDocumentsByNamespaceAsync(h.publisher,h.package_);if(g.length>0){let v=P(g);w.push({...h,origin:"workspace",versions:v}),m(`[render-stack] ${n} \u2014 workspace (${v.join(", ")})`);continue}let b=await l.getDocumentsByNamespaceAsync(h.publisher,h.package_);if(b.length>0){let v=P(b);w.push({...h,origin:"cache",versions:v}),m(`[render-stack] ${n} \u2014 cache (${v.join(", ")})`);continue}try{let $=(await i.getLock(h.publisher))?.packages[`${h.publisher}/${h.package_}`];if(!$){let j=`publisher ${h.publisher} reachable but its lock does not pin ${h.package_}`;w.push({...h,origin:"missing",reason:j}),m(`[render-stack] ${n} \u2014 MISSING: ${j}`);continue}let I=$.version,T=$.resolved,Q=await(e.fetchFn?e.fetchFn(T,h.publisher):ve(T));if(!Q.ok){let j=`fetch ${T} failed: HTTP ${Q.status} ${Q.statusText}`;w.push({...h,origin:"missing",reason:j}),m(`[render-stack] ${n} \u2014 MISSING: ${j}`);continue}let fe=await Q.text();await r.saveDocumentAsync(c.parse(fe),`${h.publisher}/${h.package_}@${I}`);try{let j=se(s,h.publisher);Me(j,{recursive:!0}),Ie(se(j,`${h.package_}@${I}.kan.yml`),fe,"utf-8"),w.push({...h,origin:"fetched",versions:[I]}),m(`[render-stack] ${n}@${I} \u2014 fetched from ${T}, installed to cache`)}catch(j){w.push({...h,origin:"fetched",versions:[I]}),m(`[render-stack] ${n}@${I} \u2014 fetched from ${T}, but cache ${s} is NOT WRITABLE (${j.message}); usable for this load only \u2014 every load will re-fetch it`)}}catch(v){let $=`fetch failed: ${v.message}`;w.push({...h,origin:"missing",reason:$}),m(`[render-stack] ${n} \u2014 MISSING: ${$}`)}}}let _=(await r.getAllDocumentsAsync()).filter(i=>i.metadata.namespace_?.publisher===d);for(let i of S)_.push(...await p.getDocumentsByNamespaceAsync(i.publisher,i.package_));let F=[],D=await H(_,p,{onUnresolvedEdge:i=>F.push(i)}),A=p;if(!e.repository){for(let i of S)D.add(C(i));A=new G(p,D)}let B=await new oe(c).parseKanonaks(A),ce=new te(B),le=(i,h)=>re(B,{publisher:i,package_:h,name:h}).length>0,N;if(e.repository){N=[];for(let i of S){let h=await p.getDocumentsByNamespaceAsync(i.publisher,i.package_);N.push(h.length>0?{...i,origin:"repository",versions:P(h)}:{...i,origin:"missing",reason:"not present in the caller-supplied repository"})}}else N=w.map(i=>i.origin==="missing"||le(i.publisher,i.package_)?i:{...i,resolvedButNotInCatalog:!0});let Y=z(N,F);for(let i of Y)m(`[render-stack] WARNING: ${i}`);let J={contractSource:"universal-default",cachePath:s,packages:N,warnings:Y},K;try{K=de(se(o,"kanonak.lock"),"utf-8")}catch{K=De(d,t,c)}let L;try{L=de(se(o,".well-known","kanonak.json"),"utf-8")}catch{L=void 0}return ne({publisher:d,availablePublishers:u,catalog:B,lookRenderer:ce,localNamespaces:k,rawByNsKey:y,renderStack:J,...K?{lockSource:K}:{},...L?{configSource:L}:{}})}function De(o,e,c){let r=new Map;for(let a of e)a.publisher===o&&(r.has(a.package_)||r.set(a.package_,{verStr:a.verStr,source:a.source}));if(r.size===0)return;let t={};for(let a of[...r.keys()].sort()){let{verStr:u,source:d}=r.get(a),k={},y;try{y=c.parse(d).metadata?.imports}catch{y=void 0}for(let l of y?.[o]??[]){let f=r.get(l.packageName);f&&(k[`${o}/${l.packageName}`]=f.verStr)}let s={};for(let l of Object.keys(k).sort())s[l]=k[l];t[`${o}/${a}`]={version:u,resolved:`https://${o}/${a}/${u}.kan.yml`,integrity:Pe(d),dependencies:s}}return Fe.dump({version:"1",lastUpdated:"",packages:t},{lineWidth:-1,sortKeys:!1,quotingType:'"'})}import{existsSync as Ee,readFileSync as Ke,writeFileSync as Ve,mkdirSync as Ae}from"fs";import{join as je}from"path";async function ue(o,e={}){let c=new O,r=Re(o),t=r.kind==="resource"?r.uri.publisher:r.publisher,a=e.log??(()=>{}),u=e.cacheRoot??X(),d=(n,g,b)=>je(u,n,`${g}@${b}.kan.yml`),k=new Set,y=new Set,s=new Map,l=new Z({getFromCache:(n,g,b)=>{let v=d(n,g,b),$=Ee(v)?Ke(v,"utf-8"):null;return $!==null&&k.add(`${n}/${g}`),$},onFetch:(n,g,b,v)=>{y.add(`${n}/${g}`);try{let $=je(u,n);Ae($,{recursive:!0}),Ve(d(n,g,b),v,"utf-8")}catch($){s.set(`${n}/${g}`,$.message),a(`[render] fetched ${n}/${g}@${b} but cache ${u} is NOT WRITABLE (${$.message}); usable for this load only \u2014 every load will re-fetch it`)}},...e.fetchFn?{fetchFn:e.fetchFn}:{}}),f=new U(e.fetchFn?{fetchFn:e.fetchFn}:void 0),p;if(r.kind==="resource"){let n=r.uri.version;p=[n?{package_:r.uri.package_,version:`${n.major}.${n.minor}.${n.patch}`}:{package_:r.uri.package_}]}else if(r.kind==="package"){let n=r.version;p=[n?{package_:r.package_,version:`${n.major}.${n.minor}.${n.patch}`}:{package_:r.package_}]}else p=((await f.getConfig(t)).featured_packages??[]).map(g=>({package_:g}));let m=async(n,g,b)=>{try{let v=b?c.buildImport(g,"=",b,n):c.buildImport(g,"*","0.0.0",n),$=await l.getHighestCompatibleVersionAsync(n,v);return $?{doc:$}:{doc:null,error:`${n} did not resolve ${g}${b?`@${b}`:""} (not in its index, or unreachable)`}}catch(v){return{doc:null,error:v.message}}},S=[],w=[];for(let n of p){let{doc:g,error:b}=await m(t,n.package_,n.version);g?S.push(g):b&&w.push(b)}if(S.length===0)throw new Error(`Could not fetch any package for address "${o}" from publisher "${t}".`+(w.length>0?` Reasons: ${w.join("; ")}`:""));let P=q(),_="universal-default",F=n=>n.map(g=>g.metadata.namespace_?.version).filter(g=>g!==void 0).sort((g,b)=>V(b,g)).map(E);a(`[render-stack] resolving ${P.length} ambient look-stack package(s) (contract: ${_}); cache: ${u}`);let D=[],A=[];for(let n of P){let g=C(n),{doc:b,error:v}=await m(n.publisher,n.package_,void 0);if(b){D.push(b);let $=F([b]),I=y.has(g)?"fetched":k.has(g)?"cache":"fetched";A.push({...n,origin:I,versions:$}),a(`[render-stack] ${g} \u2014 ${I} (${$.join(", ")})`+(s.has(g)?" [cache write FAILED \u2014 will re-fetch next load]":""))}else A.push({...n,origin:"missing",reason:v??"unresolved"}),a(`[render-stack] ${g} \u2014 MISSING: ${v??"unresolved"}`)}let B=[],ce=await H([...S,...D],l,{onUnresolvedEdge:n=>B.push(n)}),le=new G(l,ce),N=await new oe(c).parseKanonaks(le),Y=new te(N),J=A.map(n=>n.origin==="missing"||re(N,{publisher:n.publisher,package_:n.package_,name:n.package_}).length>0?n:{...n,resolvedButNotInCatalog:!0}),K=z(J,B);for(let n of K)a(`[render-stack] WARNING: ${n}`);let L={contractSource:_,cachePath:u,packages:J,warnings:K},i=new Set,h=new Map;for(let n of await l.getAllDocumentsAsync()){let g=n.metadata.namespace_;if(!g?.version||g.publisher!==t)continue;let b=E(g.version),v=`${g.publisher}/${g.package_}@${b}`;i.add(v);let $=await l.getDocumentContentAsync(v);$!==null&&h.set(`${g.package_}@${b}`,$)}return ne({publisher:t,availablePublishers:[t],catalog:N,lookRenderer:Y,localNamespaces:i,rawByNsKey:h,renderStack:L})}import{VersionOperator as ie}from"@kanonak-protocol/types/document/models/enums";function ae(o){let{lookRenderer:e,publisher:c,renderStack:r,catalog:t}=o,a=e.explainStylesheet(e.publisherSubject(c)),u=[...a.tokens.entries()].map(([p,m])=>({name:p,value:m.value,source:`${m.sourceNamespace}/${m.sourceName}`,level:m.level})),d=a.baseStylesheet,k={present:d.css!==void 0,...d.sourceNamespace!==void 0?{source:d.sourceNamespace}:{},...d.scope!==void 0?{scope:d.scope}:{},...d.css!==void 0?{bytes:d.css.length}:{},...d.problem!==void 0?{problem:d.problem}:{},candidates:d.candidates},y=new Map;for(let p of t){let m=p.namespace;m&&y.set(m,(y.get(m)??0)+1)}let s=[...y.entries()].map(([p,m])=>({namespace:p,resources:m})).sort((p,m)=>p.namespace.localeCompare(m.namespace)),l=e.expressionFailures().map(p=>({carrier:p.carrier,reason:p.reason})),f=l.map(p=>`Expression carrier "${p.carrier}" did not compile: ${p.reason} Consequence: that value renders as nothing (and a parent operation consuming it may drop its whole tier). Fix: use a tx.Expression node class the runner implements, or remove the carrier.`);return{publisher:c,renderStack:{contractSource:r.contractSource,cachePath:r.cachePath,packages:r.packages.map(p=>({package_:C(p),origin:p.origin,...p.versions!==void 0?{versions:p.versions}:{},...p.reason!==void 0?{reason:p.reason}:{},...p.resolvedButNotInCatalog!==void 0?{resolvedButNotInCatalog:p.resolvedButNotInCatalog}:{}}))},stylesheet:{tokens:u,baseStylesheet:k,...a.look?{look:{sourceClass:`${a.look.sourceClass.publisher}/${a.look.sourceClass.package_}/${a.look.sourceClass.name}`}}:{}},expressionCarriers:l,catalog:s,warnings:[...r.warnings,...a.warnings.filter(p=>!r.warnings.includes(p)),...f]}}function Be(o){return o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ge(o){let e=Be,c=o.warnings.length===0,r=o.expressionCarriers.map(s=>`<tr><td><code>${e(s.carrier)}</code></td><td>${e(s.reason)}</td></tr>`).join(`
2
2
  `),t=o.warnings.length===0?'<p class="ok">\u2713 No problems detected \u2014 the render stack is fully resolved and pages should be styled.</p>':o.warnings.map(s=>`<div class="warn">\u26A0 ${e(s)}</div>`).join(`
3
3
  `),a=o.renderStack.packages.map(s=>{let l=s.origin!=="missing"&&!s.resolvedButNotInCatalog,f=s.origin==="missing"?'<span class="bad">MISSING</span>':s.resolvedButNotInCatalog?`<span class="bad">${e(s.origin)} (not in catalog)</span>`:`<span class="good">${e(s.origin)}</span>`,p=s.reason?e(s.reason):e((s.versions??[]).join(", "));return`<tr class="${l?"":"row-bad"}"><td><code>${e(s.package_)}</code></td><td>${f}</td><td>${p}</td></tr>`}).join(`
4
4
  `),u=o.stylesheet.baseStylesheet,d=u.present?`<p><span class="good">\u2713 present</span> \u2014 <code>${e(u.source??"")}</code> (${u.bytes} bytes, ${e(u.scope??"")})</p>`:`<p><span class="bad">\u2717 MISSING</span>${u.problem?` \u2014 ${e(u.problem)}`:""}${u.candidates.length>0?`<br>candidates considered: ${u.candidates.map(s=>`<code>${e(s)}</code>`).join(", ")}`:""}</p><p>Without the base stylesheet, generated CSS stops at the <code>:root</code> token block and pages appear unstyled.</p>`,k=o.stylesheet.tokens.map(s=>`<tr><td><code>--kan-${e(s.name)}</code></td><td><code>${e(s.value)}</code></td><td><code>${e(s.source)}</code></td><td>${e(s.level)}</td></tr>`).join(`
@@ -16,15 +16,25 @@ import { type ShaclNodeShapeModel, type ShaclSeverity } from './ShapesModel.js';
16
16
  * HOST PROJECTIONS: `sh:datatype` (the typed statement + the canonical
17
17
  * layer's carrier routing), `sh:class` (resolution + type closure),
18
18
  * `sh:nodeKind` (statement kind), `sh:closed` (the focus node's predicate
19
- * set vs. the shape's declared paths, over the scope).
19
+ * set vs. the shape's declared paths, over the scope), and the qualified
20
+ * value shape (nested shape evaluation per value node, then a count).
21
+ *
22
+ * A focus node is any node in the scope: a top-level subject, or an embedded
23
+ * value — an instance of its declared type or, when it declares none, of the
24
+ * range of the property it is a value of (typescript#119). An embedded focus
25
+ * node is addressed under its subject with the protocol's fragment path
26
+ * (`…/box#parts[0]`).
20
27
  *
21
28
  * Every finding names its focus node, path, offending value, and constraint
22
29
  * component — the material a ValidationReport is assembled from.
23
30
  */
24
31
  export interface ShaclFinding {
25
- /** Canonical URI key of the focus node (`publisher/package/name`). */
32
+ /**
33
+ * Canonical key of the focus node: `publisher/package/name` for a subject,
34
+ * `<subject key>#<property path>` for an embedded value.
35
+ */
26
36
  focusNode: string;
27
- /** The focus node's full URI when it carries a resolvable version. */
37
+ /** The focus node's full URI when it is a subject carrying a resolvable version. */
28
38
  focusUri?: KanonakUri | undefined;
29
39
  /** The constrained property, for property-level findings. */
30
40
  resultPath?: KanonakUri | undefined;
@@ -32,9 +32,37 @@ export interface ShaclPropertyConstraint {
32
32
  datatype?: KanonakUri | undefined;
33
33
  classRef?: KanonakUri | undefined;
34
34
  nodeKind?: ShaclNodeKind | undefined;
35
+ /** `sh:hasValue` — a named individual at least one value must equal. */
36
+ hasValue?: KanonakUri | undefined;
37
+ /** `sh:qualifiedValueShape` with its `sh:qualifiedMinCount` / `sh:qualifiedMaxCount` bounds. */
38
+ qualified?: ShaclQualifiedConstraint | undefined;
35
39
  message?: string | undefined;
36
40
  severity?: ShaclSeverity | undefined;
37
41
  }
42
+ /**
43
+ * The shape a qualified constraint checks each value against: a property
44
+ * shape (it has a path; the value is its focus node) or a node shape (its
45
+ * property constraints and closedness; its targets play no part).
46
+ */
47
+ export type ShaclQualifiedShape = {
48
+ kind: 'property';
49
+ constraint: ShaclPropertyConstraint;
50
+ } | {
51
+ kind: 'node';
52
+ shape: ShaclNodeShapeModel;
53
+ };
54
+ export interface ShaclQualifiedConstraint {
55
+ /**
56
+ * The shape each value is checked against. Absent when it could not be
57
+ * built — a reference that names no shape, or a cycle through named shapes —
58
+ * and then `problem` says why and evaluation fails closed: a count the
59
+ * evaluator cannot compute is never reported as satisfied.
60
+ */
61
+ shape?: ShaclQualifiedShape | undefined;
62
+ problem?: string | undefined;
63
+ minCount?: number | undefined;
64
+ maxCount?: number | undefined;
65
+ }
38
66
  export interface ShaclNodeShapeModel {
39
67
  /** The shape's local name (diagnostics + `sh:sourceShape`). */
40
68
  name: string;
@@ -8,10 +8,11 @@ export interface LoweredExprNode {
8
8
  export declare const LOWERED_VALUES_VAR = "values";
9
9
  export declare const LOWERED_VALUE_VAR = "v";
10
10
  export declare const LOWERED_ALLOWED_VAR = "allowed";
11
+ export declare const LOWERED_EXPECTED_VAR = "expected";
11
12
  export interface LoweredCheck {
12
13
  /** Which constraint this check enforces (the report's discriminant). */
13
- component: 'minCount' | 'maxCount' | 'in' | 'pattern' | 'minLength' | 'maxLength' | 'minInclusive' | 'maxInclusive';
14
- /** `node` = once per focus node (binds `values`); `value` = once per value (binds `v`, and `allowed` for `in`). */
14
+ component: 'minCount' | 'maxCount' | 'hasValue' | 'in' | 'pattern' | 'minLength' | 'maxLength' | 'minInclusive' | 'maxInclusive';
15
+ /** `node` = once per focus node (binds `values`, and `expected` for `hasValue`); `value` = once per value (binds `v`, and `allowed` for `in`). */
15
16
  per: 'node' | 'value';
16
17
  expr: LoweredExprNode;
17
18
  }
@@ -63,3 +63,10 @@ export declare const SH_COMP_MIN_INCLUSIVE: EntityUri;
63
63
  export declare const SH_COMP_MAX_INCLUSIVE: EntityUri;
64
64
  export declare const SH_COMP_NODE_KIND: EntityUri;
65
65
  export declare const SH_COMP_CLOSED: EntityUri;
66
+ export declare const SH_HAS_VALUE: EntityUri;
67
+ export declare const SH_QUALIFIED_VALUE_SHAPE: EntityUri;
68
+ export declare const SH_QUALIFIED_MIN_COUNT: EntityUri;
69
+ export declare const SH_QUALIFIED_MAX_COUNT: EntityUri;
70
+ export declare const SH_COMP_HAS_VALUE: EntityUri;
71
+ export declare const SH_COMP_QUALIFIED_MIN_COUNT: EntityUri;
72
+ export declare const SH_COMP_QUALIFIED_MAX_COUNT: EntityUri;