@kitelev/exocortex-cli 16.80.1 → 16.80.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +507 -783
  2. package/dist/index.js +3 -3
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // @kitelev/exocortex-cli v16.80.1
2
+ // @kitelev/exocortex-cli v16.80.3
3
3
  // CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more
4
4
  // License: MIT
5
5
 
@@ -372,7 +372,7 @@ LIMIT ${this.config.defaultLimit}`,s="\u041D\u0435 \u0443\u0434\u0430\u043B\u043
372
372
  `,i=this.composePrefixes(t),s=this.serializePrefixes(i,r),o=this.nTriplesSerializer.serialize(e,{newline:r}).trimEnd();return s?o?`${s}${r}${r}${o}${r}`:`${s}${r}`:o?`${o}${r}`:""}serializePrefixes(e,t){let r=Object.entries(e);return r.length===0?"":r.map(([i,s])=>`@prefix ${i}: <${s}> .`).join(t)}composePrefixes(e){return e.includeDefaultPrefixes??!0?{...JB,...e.prefixes??{}}:{...e.prefixes??{}}}serializeTriplesOnly(e,t){return this.nTriplesSerializer.serializeChunk(e,t).trimEnd()}};Bm.TurtleSerializer=j1});var $C=S(Vm=>{"use strict";Object.defineProperty(Vm,"__esModule",{value:!0});Vm.JSONLDSerializer=void 0;var MC=Ie(),jC=Ut(),ZB=Ue(),Ol=Qt(),eV={rdf:Ol.Namespace.RDF.iri.value,rdfs:Ol.Namespace.RDFS.iri.value,owl:Ol.Namespace.OWL.iri.value,xsd:Ol.Namespace.XSD.iri.value,exo:Ol.Namespace.EXO.iri.value,ems:Ol.Namespace.EMS.iri.value},$1=class{static{a(this,"JSONLDSerializer")}toDocument(e,t={}){let r={...eV,...t.context??{}},i=new Map;for(let s of e){let o=this.subjectToId(s.subject),c=this.compactIri(s.predicate.value,r),l=this.objectToJSONLD(s.object,r),u=i.get(o)??{"@id":o},f=u[c];f===void 0?u[c]=l:Array.isArray(f)?f.push(l):u[c]=[f,l],i.set(o,u)}return{"@context":r,"@graph":Array.from(i.values())}}serialize(e,t={}){let r=this.toDocument(e,t),i=t.pretty?t.indent??2:void 0;return JSON.stringify(r,null,i)}subjectToId(e){return e instanceof MC.IRI?e.value:e instanceof jC.BlankNode?`_:${e.id}`:String(e)}compactIri(e,t){for(let[r,i]of Object.entries(t))if(e.startsWith(i)){let s=e.slice(i.length);if(s.length>0)return`${r}:${s}`}return e}objectToJSONLD(e,t){if(e instanceof MC.IRI)return{"@id":e.value};if(e instanceof jC.BlankNode)return{"@id":`_:${e.id}`};if(e instanceof ZB.Literal){let r={"@value":e.value};return e.datatype?r["@type"]=this.compactIri(e.datatype.value,t):e.language&&(r["@language"]=e.language,e.hasDirection()&&e.direction&&(r["@direction"]=e.direction)),r}return e}};Vm.JSONLDSerializer=$1});var V1=S(Gm=>{"use strict";Object.defineProperty(Gm,"__esModule",{value:!0});Gm.NTriplesParser=void 0;var tV=Gn(),UC=Ie(),U1=Ue(),rV=Ut(),Fl=Qt(),nV={rdf:Fl.Namespace.RDF.iri.value,rdfs:Fl.Namespace.RDFS.iri.value,owl:Fl.Namespace.OWL.iri.value,xsd:Fl.Namespace.XSD.iri.value,exo:Fl.Namespace.EXO.iri.value,ems:Fl.Namespace.EMS.iri.value},B1=class{static{a(this,"NTriplesParser")}parse(e,t={}){let r={prefixes:{...nV,...t.prefixes??{}},strict:t.strict??!1},i=[];return e.split(/\r?\n/).forEach((o,c)=>{let l=o.trim();!l||l.startsWith("#")||i.push(this.parseLine(l,c+1,r))}),i}parseLine(e,t,r){if(!e.endsWith("."))throw new Error(`Invalid RDF statement at line ${t}: missing '.' terminator`);let s=e.slice(0,-1).trim(),o=this.parseSubject(s,t,r);s=o.rest.trim();let c=this.parsePredicate(s,t,r);s=c.rest.trim();let l=this.parseObject(s,t,r);if(s=l.rest.trim(),s.length>0)throw new Error(`Unexpected tokens after object at line ${t}`);return new tV.Triple(o.node,c.node,l.node)}parseSubject(e,t,r){return e.startsWith("<")?this.consumeIRI(e,t,r):e.startsWith("_:")?this.consumeBlankNode(e,t):this.consumePrefixedName(e,t,r)}parsePredicate(e,t,r){return e.startsWith("<")?this.consumeIRI(e,t,r):this.consumePrefixedName(e,t,r)}parseObject(e,t,r){return e.startsWith("<")?this.consumeIRI(e,t,r):e.startsWith("_:")?this.consumeBlankNode(e,t):e.startsWith('"')?this.consumeLiteral(e,t,r):this.consumePrefixedName(e,t,r)}consumePrefixedName(e,t,r){let i=e.match(/^([a-zA-Z_][\w-]*):([^\s]+)(?:\s+(.*))?$/);if(!i)throw new Error(`Invalid token at line ${t}: ${e}`);let[,s,o,c]=i,l=r.prefixes[s];if(!l)throw new Error(`Unknown prefix "${s}" at line ${t}`);return{node:new UC.IRI(`${l}${o}`),rest:(c??"").trimStart()}}consumeIRI(e,t,r){let i=this.findClosingBracket(e,"<",">");if(i===-1)throw new Error(`Invalid IRI at line ${t}`);let s=e.slice(1,i),o=new UC.IRI(s),c=e.slice(i+1).trimStart();return{node:o,rest:c}}consumeBlankNode(e,t){let r=e.match(/^_:(\w+)(?:\s+(.*))?$/);if(!r)throw new Error(`Invalid blank node identifier at line ${t}`);let[,i,s]=r;return{node:new rV.BlankNode(i),rest:(s??"").trimStart()}}consumeLiteral(e,t,r){let{value:i,rest:s}=this.consumeQuotedString(e,t),o=s.trimStart();if(o.startsWith("^^")){o=o.slice(2).trimStart();let c=o.startsWith("<")?this.consumeIRI(o,t,r):this.consumePrefixedName(o,t,r);return{node:new U1.Literal(i,c.node),rest:c.rest}}if(o.startsWith("@")){let c=o.match(/^@([a-zA-Z-]+)(?:\s+(.*))?$/);if(!c)throw new Error(`Invalid language tag at line ${t}`);let[,l,u]=c;return{node:new U1.Literal(i,void 0,l),rest:(u??"").trimStart()}}return{node:new U1.Literal(i),rest:o}}consumeQuotedString(e,t){if(!e.startsWith('"'))throw new Error(`Expected quoted string at line ${t}`);let r="";for(let i=1;i<e.length;i++){let s=e[i];if(s==="\\"){if(i+1>=e.length)throw new Error(`Invalid escape sequence at line ${t}`);let o=e[i+1];switch(o){case"t":r+=" ",i+=1;break;case"b":r+="\b",i+=1;break;case"n":r+=`
373
373
  `,i+=1;break;case"r":r+="\r",i+=1;break;case"f":r+="\f",i+=1;break;case'"':r+='"',i+=1;break;case"\\":r+="\\",i+=1;break;case"u":{let c=e.slice(i+2,i+6);if(c.length!==4||!/^[0-9a-fA-F]{4}$/.test(c))throw new Error(`Invalid \\u escape at line ${t}`);r+=String.fromCharCode(parseInt(c,16)),i+=5;break}case"U":{let c=e.slice(i+2,i+10);if(c.length!==8||!/^[0-9a-fA-F]{8}$/.test(c))throw new Error(`Invalid \\U escape at line ${t}`);r+=String.fromCodePoint(parseInt(c,16)),i+=9;break}default:throw new Error(`Unknown escape sequence \\${o} at line ${t}`)}continue}if(s==='"'){let o=e.slice(i+1);return{value:r,rest:o}}r+=s}throw new Error(`Unterminated string literal at line ${t}`)}findClosingBracket(e,t,r){let i=0;for(let s=0;s<e.length;s++){let o=e[s];if(o===t){i++;continue}if(o===r&&(i--,i===0))return s}return-1}};Gm.NTriplesParser=B1});var BC=S(qm=>{"use strict";Object.defineProperty(qm,"__esModule",{value:!0});qm.TurtleParser=void 0;var Dl=Qt(),iV=V1(),sV={rdf:Dl.Namespace.RDF.iri.value,rdfs:Dl.Namespace.RDFS.iri.value,owl:Dl.Namespace.OWL.iri.value,xsd:Dl.Namespace.XSD.iri.value,exo:Dl.Namespace.EXO.iri.value,ems:Dl.Namespace.EMS.iri.value},oV=/^@prefix\s+([a-zA-Z_][\w-]*):\s*<([^>]+)>\s*\.$/,G1=class{static{a(this,"TurtleParser")}constructor(){this.nTriplesParser=new iV.NTriplesParser}parse(e,t={}){let r={...sV,...t.prefixes??{}},i=this.collectStatements(e),s=[];return i.forEach(({statement:o,lineNumber:c})=>{if(this.isPrefixStatement(o)){let u=o.match(oV);if(!u)throw new Error(`Invalid prefix declaration at line ${c}`);let[,f,d]=u;r[f]=d;return}if(o.includes(";")||o.includes(","))throw new Error(`Complex Turtle statements with ';' or ',' are not supported (line ${c})`);let l=this.normalizeShortcuts(o);s.push(this.nTriplesParser.parseLine(l,c,{prefixes:r,strict:!1}))}),s}collectStatements(e){let t=e.split(/\r?\n/),r=[],i="",s=0;if(t.forEach((o,c)=>{let l=o.trim();!l||l.startsWith("#")||(i||(s=c+1),i=i?`${i} ${l}`:l,l.endsWith(".")&&(r.push({statement:i,lineNumber:s}),i=""))}),i)throw new Error(`Unterminated Turtle statement near line ${s}`);return r}isPrefixStatement(e){return e.startsWith("@prefix")}normalizeShortcuts(e){return e.includes(" a ")?e.replace(/\sa\s/g," rdf:type "):e}};qm.TurtleParser=G1});var VC=S(Wm=>{"use strict";Object.defineProperty(Wm,"__esModule",{value:!0});Wm.RDFSerializer=void 0;var Ll=Gn(),tc=Ie(),rc=Ue(),q1=Ut(),_s=Qt(),aV=kC(),cV=M1(),lV=$C(),uV=BC(),fV=V1(),dV=1024,hV=`
374
374
  `,pV={rdf:_s.Namespace.RDF.iri.value,rdfs:_s.Namespace.RDFS.iri.value,owl:_s.Namespace.OWL.iri.value,xsd:_s.Namespace.XSD.iri.value,exo:_s.Namespace.EXO.iri.value,ems:_s.Namespace.EMS.iri.value},W1=class{static{a(this,"RDFSerializer")}constructor(e){this.store=e,this.turtleSerializer=new aV.TurtleSerializer,this.nTriplesSerializer=new cV.NTriplesSerializer,this.jsonldSerializer=new lV.JSONLDSerializer,this.turtleParser=new uV.TurtleParser,this.nTriplesParser=new fV.NTriplesParser}async serialize(e,t={}){let r=await this.store.match();return this.serializeTriples(r,e,t)}serializeTriples(e,t,r={}){switch(t){case"turtle":return this.turtleSerializer.serialize(e,{prefixes:r.prefixes,includeDefaultPrefixes:r.includeDefaultPrefixes,newline:r.newline});case"n-triples":return this.nTriplesSerializer.serialize(e,{newline:r.newline});case"json-ld":return this.jsonldSerializer.serialize(e,{context:r.prefixes,pretty:r.pretty,indent:r.indent});default:throw new Error(`Unsupported serialization format: ${t}`)}}stream(e,t={}){let r=t.newline??hV,i=t.batchSize??dV,s=t.includeDefaultPrefixes,o=t.prefixes,c=this,l=!1,u=[],f=[],d=0,h=a(async()=>{if(!l){if(f=await c.store.match(),e==="json-ld"){let g=c.jsonldSerializer.toDocument(f,{context:o,pretty:!1});u.push(...c.buildJsonLdChunks(g))}else if(e==="turtle"){let g=c.turtleSerializer.serializePrefixes(c.composePrefixes(o,s),r);g&&u.push(`${g}${r}${r}`)}l=!0}},"ensureInitialized");return{async next(){if(await h(),u.length>0)return{value:u.shift(),done:!1};if(e==="json-ld")return{value:void 0,done:!0};if(d>=f.length)return{value:void 0,done:!0};let g=f.slice(d,d+i);d+=g.length;let y="";if(e==="turtle"){let v=c.turtleSerializer.serializeTriplesOnly(g,r);v&&(y=`${v}${r}`)}else e==="n-triples"&&(y=c.nTriplesSerializer.serializeChunk(g,r));return y?{value:y,done:!1}:this.next()},async return(){return u=[],f=[],d=0,{value:void 0,done:!0}},[Symbol.asyncIterator](){return this}}}async load(e,t,r={}){let i=this.parse(e,t,r);return r.mode!=="append"&&await this.store.clear(),await this.store.addAll(i),i.length}parse(e,t,r={}){switch(t){case"turtle":return this.turtleParser.parse(e,this.buildTurtleParseOptions(r));case"n-triples":return this.nTriplesParser.parse(e,this.buildNTriplesParseOptions(r));case"json-ld":return this.parseJsonLd(e,r);default:throw new Error(`Unsupported serialization format: ${t}`)}}buildTurtleParseOptions(e){return{prefixes:this.composePrefixes(e.prefixes,!0),strict:e.strict}}buildNTriplesParseOptions(e){return{prefixes:this.composePrefixes(e.prefixes,!0),strict:e.strict}}composePrefixes(e,t){return t??!0?{...pV,...e??{}}:{...e??{}}}parseJsonLd(e,t){let r;try{r=JSON.parse(e)}catch(u){throw new Error(`Invalid JSON-LD document: ${u.message}`)}let i=this.composePrefixes(t.prefixes,!0),s=this.extractContext(r),o={...i,...s},c=this.extractGraph(r),l=[];return c.forEach((u,f)=>{if(!u||typeof u!="object"||Array.isArray(u))throw new Error(`Invalid JSON-LD node at index ${f}`);let d=this.parseSubjectFromNode(u,o,f),h=Object.entries(u);for(let[p,g]of h){if(p==="@id"||p==="@context")continue;if(p==="@type"){this.collectTypeTriples(d,g,l,o);continue}let y=this.expandTerm(p,o),v=new tc.IRI(y);this.collectTriplesForValue(d,v,g,l,o)}}),l}extractContext(e){if(!e||typeof e!="object"||Array.isArray(e))return{};let t=e["@context"];if(!t||typeof t!="object"||Array.isArray(t))return{};let r={};return Object.entries(t).forEach(([i,s])=>{typeof s=="string"&&(r[i]=s)}),r}extractGraph(e){if(Array.isArray(e))return e;if(!e||typeof e!="object")return[];let t=e["@graph"];return Array.isArray(t)?t:[e]}parseSubjectFromNode(e,t,r){let i=e["@id"];if(typeof i=="string"){if(i.startsWith("_:"))return new q1.BlankNode(i.slice(2));if(this.isAbsoluteIri(i))return new tc.IRI(i);let s=this.expandTerm(i,t);return new tc.IRI(s)}return new q1.BlankNode(`jsonld_${r}`)}collectTypeTriples(e,t,r,i){let s=_s.Namespace.RDF.term("type");(Array.isArray(t)?t:[t]).forEach(c=>{if(typeof c!="string")throw new Error("Invalid @type value in JSON-LD node");let l=this.expandTerm(c,i);r.push(new Ll.Triple(e,s,new tc.IRI(l)))})}collectTriplesForValue(e,t,r,i,s){if(r!=null){if(Array.isArray(r)){r.forEach(o=>this.collectTriplesForValue(e,t,o,i,s));return}if(typeof r=="object"){let o=r;if(typeof o["@id"]=="string"){let c=this.parseIdNode(o["@id"],s);i.push(new Ll.Triple(e,t,c));return}if(o["@value"]!==void 0){let c=this.parseLiteralObject(o,s);i.push(new Ll.Triple(e,t,c));return}}if(typeof r=="string"){i.push(new Ll.Triple(e,t,new rc.Literal(r)));return}if(typeof r=="number"){let o=Number.isInteger(r)?_s.Namespace.XSD.term("integer"):_s.Namespace.XSD.term("decimal");i.push(new Ll.Triple(e,t,new rc.Literal(r.toString(),o)));return}if(typeof r=="boolean"){let o=_s.Namespace.XSD.term("boolean");i.push(new Ll.Triple(e,t,new rc.Literal(r.toString(),o)));return}throw new Error("Unsupported JSON-LD value encountered")}}parseIdNode(e,t){if(e.startsWith("_:"))return new q1.BlankNode(e.slice(2));if(this.isAbsoluteIri(e))return new tc.IRI(e);let r=this.expandTerm(e,t);return new tc.IRI(r)}parseLiteralObject(e,t){let r=e["@value"];if(typeof r!="string")throw new Error("JSON-LD literal values must be strings");if(typeof e["@language"]=="string"){let i=e["@direction"];return i==="ltr"||i==="rtl"?new rc.Literal(r,void 0,e["@language"],i):new rc.Literal(r,void 0,e["@language"])}if(typeof e["@type"]=="string"){let i=this.expandTerm(e["@type"],t);return new rc.Literal(r,new tc.IRI(i))}return new rc.Literal(r)}expandTerm(e,t){if(this.isAbsoluteIri(e))return e;let r=e.indexOf(":");if(r>0){let s=e.slice(0,r),o=e.slice(r+1),c=t[s];if(!c)throw new Error(`Unknown prefix "${s}" in JSON-LD document`);return`${c}${o}`}let i=t["@vocab"];if(i)return`${i}${e}`;throw new Error(`Unable to expand JSON-LD term "${e}"`)}isAbsoluteIri(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)}buildJsonLdChunks(e){let t=[],r=JSON.stringify(e["@context"]);return t.push(`{"@context":${r},"@graph":[`),e["@graph"].forEach((i,s)=>{let o=JSON.stringify(i);s>0?t.push(`,${o}`):t.push(o)}),t.push(`]}
375
- `),t}};Wm.RDFSerializer=W1});var z1=S(yo=>{"use strict";Object.defineProperty(yo,"__esModule",{value:!0});yo.OBSIDIAN_VAULT_SCHEME=void 0;yo.vaultPathToIRI=mV;yo.iriToVaultPath=gV;yo.OBSIDIAN_VAULT_SCHEME="obsidian://vault/";function mV(n){let e=n.startsWith("./")?n.slice(2):n;return`${yo.OBSIDIAN_VAULT_SCHEME}${encodeURI(e)}`}a(mV,"vaultPathToIRI");function gV(n){if(!n.startsWith(yo.OBSIDIAN_VAULT_SCHEME))return null;let e=n.slice(yo.OBSIDIAN_VAULT_SCHEME.length);try{return decodeURI(e)}catch{return null}}a(gV,"iriToVaultPath")});var K1=S(zm=>{"use strict";Object.defineProperty(zm,"__esModule",{value:!0});zm.RDFVocabularyMapper=void 0;var or=Gn(),GC=Ie(),te=Qt(),H1=class{static{a(this,"RDFVocabularyMapper")}constructor(){this.propertyMappings=new Map([["exo__Instance_class",te.Namespace.RDF.term("type")],["exo__Asset_isDefinedBy",te.Namespace.RDFS.term("isDefinedBy")],["exo__Class_superClass",te.Namespace.RDFS.term("subClassOf")],["exo__Property_range",te.Namespace.RDFS.term("range")],["exo__Property_domain",te.Namespace.RDFS.term("domain")],["exo__Property_superProperty",te.Namespace.RDFS.term("subPropertyOf")]])}generateClassHierarchyTriples(){let e=[];return e.push(new or.Triple(te.Namespace.EXO.term("Asset"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.RDFS.term("Resource"))),e.push(new or.Triple(te.Namespace.EXO.term("Class"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.RDFS.term("Class"))),e.push(new or.Triple(te.Namespace.EXO.term("Property"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.RDF.term("Property"))),e.push(new or.Triple(te.Namespace.EMS.term("Task"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.EXO.term("Asset"))),e.push(new or.Triple(te.Namespace.EMS.term("Project"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.EXO.term("Asset"))),e.push(new or.Triple(te.Namespace.EMS.term("Area"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.EXO.term("Asset"))),e.push(new or.Triple(te.Namespace.EMS.term("Workflow"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.EXO.term("Asset"))),e.push(new or.Triple(te.Namespace.EMS.term("WorkflowState"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.EXO.term("Asset"))),e.push(new or.Triple(te.Namespace.EMS.term("WorkflowTransition"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.EXO.term("Asset"))),e.push(new or.Triple(te.Namespace.EXOCMD.term("Command"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.EXO.term("Asset"))),e.push(new or.Triple(te.Namespace.EXOCMD.term("Precondition"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.EXO.term("Asset"))),e.push(new or.Triple(te.Namespace.EXOCMD.term("Grounding"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.EXO.term("Asset"))),e.push(new or.Triple(te.Namespace.EXOCMD.term("CommandBinding"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.EXO.term("Asset"))),e}generatePropertyHierarchyTriples(){let e=[];return e.push(new or.Triple(te.Namespace.EXO.term("Instance_class"),te.Namespace.RDFS.term("subPropertyOf"),te.Namespace.RDF.term("type"))),e.push(new or.Triple(te.Namespace.EXO.term("Asset_isDefinedBy"),te.Namespace.RDFS.term("subPropertyOf"),te.Namespace.RDFS.term("isDefinedBy"))),e.push(new or.Triple(te.Namespace.EXO.term("Class_superClass"),te.Namespace.RDFS.term("subPropertyOf"),te.Namespace.RDFS.term("subClassOf"))),e.push(new or.Triple(te.Namespace.EXO.term("Property_range"),te.Namespace.RDFS.term("subPropertyOf"),te.Namespace.RDFS.term("range"))),e.push(new or.Triple(te.Namespace.EXO.term("Property_domain"),te.Namespace.RDFS.term("subPropertyOf"),te.Namespace.RDFS.term("domain"))),e.push(new or.Triple(te.Namespace.EXO.term("Property_superProperty"),te.Namespace.RDFS.term("subPropertyOf"),te.Namespace.RDFS.term("subPropertyOf"))),e}generateMappedTriple(e,t,r){let i=this.propertyMappings.get(t);if(!i)return null;let s;if(r instanceof GC.IRI)s=r;else{let o=r.match(/^(ems|exo|exocmd)__(.+)$/);if(o){let[,c,l]=o;s=(c==="ems"?te.Namespace.EMS:c==="exocmd"?te.Namespace.EXOCMD:te.Namespace.EXO).term(l)}else s=new GC.IRI(r)}return new or.Triple(e,i,s)}hasMappingFor(e){return this.propertyMappings.has(e)}};zm.RDFVocabularyMapper=H1});var qC=S(Km=>{"use strict";Object.defineProperty(Km,"__esModule",{value:!0});Km.RDFSInferenceEngine=void 0;var yV=Gn(),Hm=Ie(),Q1=class{static{a(this,"RDFSInferenceEngine")}async materialize(e){let t=await e.predicates(),r=t.find(d=>d.value.includes("Class_superClass")),i=t.find(d=>d.value.includes("Instance_class"));if(!r||!i)return 0;let s=await this.buildDirectParentMap(e,r);if(s.size===0)return 0;let o=this.computeAllAncestors(s),c=await e.count(),l=await e.match(void 0,i),u=[];for(let d of l)if(d.object instanceof Hm.IRI){let h=o.get(d.object.value);if(h)for(let p of h)u.push(new yV.Triple(d.subject,i,new Hm.IRI(p)))}return u.length>0&&await e.addAll(u),await e.count()-c}async buildDirectParentMap(e,t){let r=await e.match(void 0,t),i=new Map;for(let s of r)if(s.subject instanceof Hm.IRI&&s.object instanceof Hm.IRI){let o=s.subject.value,c=s.object.value;i.has(o)||i.set(o,new Set),i.get(o).add(c)}return i}computeAllAncestors(e){let t=new Map;for(let r of e.keys())t.has(r)||t.set(r,this.computeAncestorsBFS(r,e));return t}computeAncestorsBFS(e,t){let r=new Set,i=new Set,s=[],o=t.get(e);if(o)for(let c of o)s.push(c);for(;s.length>0;){let c=s.shift();if(i.has(c))continue;i.add(c),r.add(c);let l=t.get(c);if(l)for(let u of l)i.has(u)||s.push(u)}return r}};Km.RDFSInferenceEngine=Q1});var J1=S(nc=>{"use strict";var _V=nc&&nc.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(o=n[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s};Object.defineProperty(nc,"__esModule",{value:!0});nc.NonInheritablePropertyRegistry=void 0;var bV=Le(),WC=Ie(),zC=Ue(),X1=Qt(),Y1=class{static{a(this,"NonInheritablePropertyRegistry")}constructor(){this.nonInheritableIRIs=new Set,this.initialized=!1}async initialize(e){this.nonInheritableIRIs.clear();try{let t=await e.predicates(),r=t.find(c=>c.value.includes("Instance_class"));if(!r){this.initialized=!0;return}let i=await this.findNonInheritableClassIRI(e,t);if(!i){this.initialized=!0;return}let s=await e.match(void 0,r,i);if(s.length===0){this.initialized=!0;return}let o=t.find(c=>c.value.includes("Asset_label"));if(!o){this.initialized=!0;return}for(let c of s){let l=await e.match(c.subject,o,void 0);for(let u of l)if(u.object instanceof zC.Literal){let f=u.object.value,d=this.propertyKeyToIRI(f);d&&this.nonInheritableIRIs.add(d)}}}catch{}this.initialized=!0}isNonInheritable(e){return this.nonInheritableIRIs.has(e)}get size(){return this.nonInheritableIRIs.size}get isInitialized(){return this.initialized}async findNonInheritableClassIRI(e,t){let r=t.find(o=>o.value.includes("Asset_label"));if(!r)return null;let i=await e.match(void 0,r,new zC.Literal("exo__NonInheritableProperty"));if(i.length>0&&i[0].subject instanceof WC.IRI)return i[0].subject;let s=t.find(o=>o.value.includes("Instance_class"));if(s){let o=await e.match(void 0,s,void 0);for(let c of o)if(c.object instanceof WC.IRI&&c.object.value.includes("NonInheritableProperty"))return c.object}return null}propertyKeyToIRI(e){return e.startsWith("exo__")?X1.Namespace.EXO.term(e.substring(5)).value:e.startsWith("ems__")?X1.Namespace.EMS.term(e.substring(5)).value:e.startsWith("exocmd__")?X1.Namespace.EXOCMD.term(e.substring(8)).value:null}};nc.NonInheritablePropertyRegistry=Y1;nc.NonInheritablePropertyRegistry=Y1=_V([(0,bV.injectable)()],Y1)});var tv=S(ic=>{"use strict";var SV=ic&&ic.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(o=n[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s};Object.defineProperty(ic,"__esModule",{value:!0});ic.PropertyCardinalityRegistry=void 0;var wV=Le(),HC=Ie(),KC=Ue(),Z1=Qt(),ev=class{static{a(this,"PropertyCardinalityRegistry")}constructor(){this.multiValuedIRIs=new Set,this.initialized=!1}async initialize(e){this.multiValuedIRIs.clear();try{let t=await e.predicates(),r=t.find(c=>c.value.includes("Property_cardinality"));if(!r){this.initialized=!0;return}let i=await this.findMultipleCardinalityIRI(e,t);if(!i){this.initialized=!0;return}let s=await e.match(void 0,r,i);if(s.length===0){this.initialized=!0;return}let o=t.find(c=>c.value.includes("Asset_label"));if(!o){this.initialized=!0;return}for(let c of s){let l=await e.match(c.subject,o,void 0);for(let u of l)if(u.object instanceof KC.Literal){let f=u.object.value,d=this.propertyKeyToIRI(f);d&&this.multiValuedIRIs.add(d)}}}catch{}this.initialized=!0}isMultiValued(e){return this.multiValuedIRIs.has(e)}get size(){return this.multiValuedIRIs.size}get isInitialized(){return this.initialized}async findMultipleCardinalityIRI(e,t){let r=t.find(o=>o.value.includes("Asset_label"));if(!r)return null;let i=await e.match(void 0,r,new KC.Literal("exo__PropertyCardinalityMultiple"));if(i.length>0&&i[0].subject instanceof HC.IRI)return i[0].subject;let s=t.find(o=>o.value.includes("Instance_class"));if(s){let o=await e.match(void 0,s,void 0);for(let c of o)if(c.object instanceof HC.IRI&&c.object.value.includes("PropertyCardinalityMultiple"))return c.object}return null}propertyKeyToIRI(e){return e.startsWith("exo__")?Z1.Namespace.EXO.term(e.substring(5)).value:e.startsWith("ems__")?Z1.Namespace.EMS.term(e.substring(5)).value:e.startsWith("exocmd__")?Z1.Namespace.EXOCMD.term(e.substring(8)).value:null}};ic.PropertyCardinalityRegistry=ev;ic.PropertyCardinalityRegistry=ev=SV([(0,wV.injectable)()],ev)});var iv=S(Er=>{"use strict";var vV=Er&&Er.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(o=n[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},EV=Er&&Er.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Er,"__esModule",{value:!0});Er.PrototypeChainMaterializer=Er.MAX_PROTOTYPE_DEPTH=Er.INFERRED_GRAPH=void 0;Er.inferredGraphForDepth=rv;var TV=Le(),QC=Gn(),Yo=Ie(),AV=J1(),IV=tv();Er.INFERRED_GRAPH=new Yo.IRI("https://exocortex.my/ontology/exo#inferred");var xV="https://exocortex.my/ontology/exo#inferred/";function rv(n){return new Yo.IRI(`${xV}${n}`)}a(rv,"inferredGraphForDepth");Er.MAX_PROTOTYPE_DEPTH=10;var nv=class{static{a(this,"PrototypeChainMaterializer")}constructor(e,t){this.registry=e,this.cardinalityRegistry=t??null}async materialize(e){let r=(await e.predicates()).find(c=>c.value.includes("Asset_prototype"));if(!r)return 0;let i=await e.match(void 0,r,void 0);if(i.length===0)return 0;let s=new Map;for(let c of i)if(c.subject instanceof Yo.IRI&&c.object instanceof Yo.IRI){let l=c.subject.value,u=c.object.value;l!==u&&s.set(l,c.object)}if(s.size===0)return 0;let o=0;for(let[c]of s){let l=new Yo.IRI(c),u=this.resolveChain(c,s);if(u.length===0)continue;let f=await e.match(l,void 0,void 0),d=new Set,h=new Map;for(let p of f)if(d.add(p.predicate.value),this.isMultiValued(p.predicate.value)){let g=p.object instanceof Yo.IRI?p.object.value:String(p.object),y=h.get(p.predicate.value);y||(y=new Set,h.set(p.predicate.value,y)),y.add(g)}for(let p=0;p<u.length;p++){let g=u[p],y=p+1,v=new Yo.IRI(g),_=await e.match(v,void 0,void 0),E=new Set;if(e.matchInGraph){let T=await e.matchInGraph(v,void 0,void 0,Er.INFERRED_GRAPH);for(let O of T)E.add(O.predicate.value)}for(let T of _){let O=T.predicate.value;if(this.registry.isNonInheritable(O)||E.has(O))continue;if(d.has(O)&&this.isMultiValued(O)){let D=T.object instanceof Yo.IRI?T.object.value:String(T.object);if(h.get(O)?.has(D))continue;let le=h.get(O);le||(le=new Set,h.set(O,le)),le.add(D);let F=new QC.Triple(l,T.predicate,T.object);await e.add(F),e.addToGraph&&(await e.addToGraph(F,Er.INFERRED_GRAPH),await e.addToGraph(F,rv(y))),o++;continue}if(d.has(O))continue;let N=new QC.Triple(l,T.predicate,T.object);await e.add(N),e.addToGraph&&(await e.addToGraph(N,Er.INFERRED_GRAPH),await e.addToGraph(N,rv(y))),d.add(O),o++}}}return o}isMultiValued(e){return this.cardinalityRegistry?this.cardinalityRegistry.isMultiValued(e):!1}resolveChain(e,t){let r=[],i=new Set;i.add(e);let s=[],o=t.get(e);for(o&&s.push(o.value);s.length>0&&r.length<Er.MAX_PROTOTYPE_DEPTH;){let c=s.shift();if(c===void 0)break;if(i.has(c))continue;i.add(c),r.push(c);let l=t.get(c);l&&!i.has(l.value)&&s.push(l.value)}return r}};Er.PrototypeChainMaterializer=nv;Er.PrototypeChainMaterializer=nv=vV([(0,TV.injectable)(),EV("design:paramtypes",[AV.NonInheritablePropertyRegistry,IV.PropertyCardinalityRegistry])],nv)});var YC=S(Xm=>{"use strict";Object.defineProperty(Xm,"__esModule",{value:!0});Xm.IRICanonicalizer=void 0;var XC=Ie(),RV=Ue(),CV=Ut(),PV=Gn(),sv=/^obsidian:\/\/vault\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i,Qm=class n{static{a(this,"IRICanonicalizer")}static extractSynthAUid(e){let t=sv.exec(e);return t?t[1].toLowerCase():null}static canonicalize(e,t){if(t.size===0)return{triples:e,remapCount:0,uniqueRemapCount:0};let r=new Map,i=new Set,s=0;return{triples:e.map(c=>{let l=n.remapIfSynthA(c.subject,t,r,i),u=n.remapIfSynthA(c.object,t,r,i);return l===c.subject&&u===c.object?c:(s++,new PV.Triple(l,c.predicate,u))}),remapCount:s,uniqueRemapCount:i.size}}static remapIfSynthA(e,t,r,i){if(e instanceof RV.Literal||e instanceof CV.BlankNode||!(e instanceof XC.IRI))return e;let s=sv.exec(e.value);if(!s)return e;let o=s[1].toLowerCase(),c=t.get(o);if(!c||c===e.value)return e;i.add(o);let l=r.get(c);return l||(l=new XC.IRI(c),r.set(c,l)),l}};Xm.IRICanonicalizer=Qm;Qm.SYNTH_A_IRI_PATTERN=sv});var av=S(ov=>{"use strict";Object.defineProperty(ov,"__esModule",{value:!0});ov.derivePath=FV;var OV="assetspaces",JC=/^[A-Za-z0-9._-]+$/;function FV(n){if(typeof n!="string")return null;let e=n.trim();if(e.length===0||/^file:\/\//i.test(e))return null;e=e.replace(/\/+$/,""),e=e.replace(/\.git$/i,"");let t=null;if(!e.includes("://")){let o=/^[^/@\s]+@[^/:\s]+:(.+)$/.exec(e);o&&(t=o[1])}if(t===null){let o=e.replace(/^[a-z][a-z0-9+.-]*:\/\//i,"");o=o.replace(/^[^/@]+@/,"");let c=o.indexOf("/");if(c<0)return null;t=o.slice(c+1)}let r=t.split("/").filter(o=>o.length>0);if(r.length<2)return null;let i=r[0],s=r[1];return i==="."||i===".."||s==="."||s===".."||!JC.test(i)||!JC.test(s)?null:`${OV}/${i}/${s}`}a(FV,"derivePath")});var lv=S(Bi=>{"use strict";Object.defineProperty(Bi,"__esModule",{value:!0});Bi.FILE_SPACE_CLASS_UID=void 0;Bi.frontmatterDeclaresFileSpace=LV;Bi.discoverFileSpaceExclusions=kV;var DV=av();Bi.FILE_SPACE_CLASS_UID="aad8913e-5e9f-4047-879d-93cc46befd52";var ZC=/\[\[([^\]|]+)(?:\|[^\]]*)?\]\]/g,cv=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function t3(n){let e=Array.isArray(n)?n:[n],t=[];for(let r of e){if(typeof r!="string")continue;ZC.lastIndex=0;let i;for(;(i=ZC.exec(r))!==null;)t.push(i[1].trim())}return t}a(t3,"wikilinkTargets");function LV(n){return n?t3(n.exo__Instance_class).some(e=>cv.test(e)&&e.toLowerCase()===Bi.FILE_SPACE_CLASS_UID):!1}a(LV,"frontmatterDeclaresFileSpace");function e3(n,e){try{return n.getFrontmatter(e)}catch{return null}}a(e3,"readFrontmatterSafe");function NV(n){let e=n.exo__AssetSpace_source;if(typeof e=="string"&&e.length>0)return e;let t=n.exo__AssetSpace_git;return typeof t=="string"&&t.length>0?t:null}a(NV,"readSource");function kV(n){let e=[],t=[],r=[],i=new Map,s=a((c,l)=>{if(cv.test(c))return c.toLowerCase()===Bi.FILE_SPACE_CLASS_UID;let u=n.getFirstLinkpathDest(c,l);if(u==null)return!1;let f=i.get(u.path);if(f!==void 0)return f;let h=e3(n,u)?.exo__Asset_uid,p=typeof h=="string"&&h.toLowerCase()===Bi.FILE_SPACE_CLASS_UID;return i.set(u.path,p),p},"isFileSpaceClassRef"),o=a(c=>c.some(l=>cv.test(l)&&l.toLowerCase()===Bi.FILE_SPACE_CLASS_UID),"hasUuidFormRef");for(let c of n.getAllFiles()){let l=e3(n,c);if(!l)continue;let u=t3(l.exo__Instance_class);if(!u.some(p=>s(p,c.path)))continue;t.push(c.path),o(u)||r.push(`FileSpace declaration ${c.path} references the class via a label-form link only \u2014 the sync layer will not pick it up; use the UUID-form wikilink [[${Bi.FILE_SPACE_CLASS_UID}]] (UID-canon)`);let f=NV(l);if(f===null){r.push(`FileSpace declaration ${c.path} has no exo__AssetSpace_source/_git \u2014 mount path underivable, content NOT excluded from the index`);continue}let d=(0,DV.derivePath)(f);if(d===null){r.push(`FileSpace declaration ${c.path}: cannot derive mount path from source "${f}" \u2014 content NOT excluded from the index`);continue}let h=`${d}/`;c.path.startsWith(h)&&r.push(`FileSpace declaration ${c.path} lies INSIDE its own mount ${h} \u2014 it will be excluded from the index together with the content; move the declaration outside the mount folder`),e.push(h)}return{prefixes:e,declarationPaths:t,warnings:r}}a(kV,"discoverFileSpaceExclusions")});var r3=S(zn=>{"use strict";var MV=zn&&zn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(o=n[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},jV=zn&&zn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(zn,"__esModule",{value:!0});zn.LazyAssetGraphLoader=zn.MAX_LAZY_DEPTH=void 0;var $V=Le(),UV=Ie(),uv=Qt();zn.MAX_LAZY_DEPTH=10;var fv=class{static{a(this,"LazyAssetGraphLoader")}constructor(e,t,r){this.converter=e,this.fileResolver=t,this.store=r,this.loadedIRIs=new Set,this.instanceClassPredicate=uv.Namespace.EXO.term("Instance_class"),this.superClassPredicate=uv.Namespace.EXO.term("Class_superClass"),this.prototypePredicate=uv.Namespace.EXO.term("Asset_prototype")}async ensureFileLoaded(e,t=0){if(t>=zn.MAX_LAZY_DEPTH)return;let r=this.converter.notePathToIRI(e.path).value;if(!this.loadedIRIs.has(r)){this.loadedIRIs.add(r);try{let i=await this.converter.convertNote(e);if(!this.loadedIRIs.has(r)||(await this.store.addAll(i),!this.loadedIRIs.has(r)))return;await this.walkClassAndPrototypeRelations(i,t+1)}catch(i){throw this.loadedIRIs.delete(r),i}}}async ensureLoadedByIRI(e,t=0){if(t>=zn.MAX_LAZY_DEPTH||this.loadedIRIs.has(e.value))return;let r=this.fileResolver.resolveByIRI(e);r!==null&&await this.ensureFileLoaded(r,t)}isLoaded(e){return this.loadedIRIs.has(e.value)}forget(e){this.loadedIRIs.delete(e.value)}clearAll(){this.loadedIRIs.clear()}get loadedCount(){return this.loadedIRIs.size}clearForTests(){this.loadedIRIs.clear()}async walkClassAndPrototypeRelations(e,t){let r=[];for(let i of e){if(!(i.object instanceof UV.IRI))continue;let s=i.predicate.value;(s===this.instanceClassPredicate.value||s===this.superClassPredicate.value||s===this.prototypePredicate.value)&&r.push(i.object)}for(let i of r)await this.ensureLoadedByIRI(i,t)}};zn.LazyAssetGraphLoader=fv;zn.LazyAssetGraphLoader=fv=MV([(0,$V.injectable)(),jV("design:paramtypes",[Object,Object,Object])],fv)});var hv=S(gr=>{"use strict";var BV=gr&&gr.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(o=n[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},VV=gr&&gr.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(gr,"__esModule",{value:!0});gr.SourceAnnotator=gr.DEPTH_VARIABLE=gr.SOURCE_VARIABLE=void 0;var GV=Le(),Nl=Ue(),qV=Ie(),Ym=iv();gr.SOURCE_VARIABLE="_source";gr.DEPTH_VARIABLE="_depth";var dv=class{static{a(this,"SourceAnnotator")}constructor(e){this.tripleStore=e}async annotate(e,t,r,i){if(!this.tripleStore.matchInGraph)return e.map(o=>{let c=o.clone();return c.set(gr.SOURCE_VARIABLE,new Nl.Literal("own")),c});let s=[];for(let o of e){let c=o.get(t),l=o.get(r),u=o.get(i),f=o.clone();if(!c||!l||!u)f.set(gr.SOURCE_VARIABLE,new Nl.Literal("own"));else{let d=await this.determineSource(c,l,u);f.set(gr.SOURCE_VARIABLE,new Nl.Literal(d))}s.push(f)}return s}async annotateSingle(e,t,r,i){return(await this.annotate([e],t,r,i))[0]}async determineSource(e,t,r){return this.tripleStore.matchInGraph&&(await this.tripleStore.matchInGraph(e,t,r,Ym.INFERRED_GRAPH)).length>0?"inherited":"own"}async getInheritanceDepth(e,t,r){if(!this.tripleStore.matchInGraph)return 0;for(let i=1;i<=Ym.MAX_PROTOTYPE_DEPTH;i++){let s=(0,Ym.inferredGraphForDepth)(i);if((await this.tripleStore.matchInGraph(e,t,r,s)).length>0)return i}return 0}async annotateBySubject(e,t){if(!this.tripleStore.matchInGraph)return e.map(s=>{let o=s.clone();return o.set(gr.SOURCE_VARIABLE,new Nl.Literal("own")),o});let r=[],i=new Map;for(let s of e){let o=s.get(t),c=s.clone();if(!o||!(o instanceof qV.IRI))c.set(gr.SOURCE_VARIABLE,new Nl.Literal("own"));else{let l=o.value;if(!i.has(l)){let f=await this.tripleStore.matchInGraph(o,void 0,void 0,Ym.INFERRED_GRAPH);i.set(l,f.length>0?"inherited":"own")}let u=i.get(l)??"own";c.set(gr.SOURCE_VARIABLE,new Nl.Literal(u))}r.push(c)}return r}};gr.SourceAnnotator=dv;gr.SourceAnnotator=dv=BV([(0,GV.injectable)(),VV("design:paramtypes",[Object])],dv)});var gv=S(Hn=>{"use strict";var WV=Hn&&Hn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(o=n[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},zV=Hn&&Hn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},n3=Hn&&Hn.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Hn,"__esModule",{value:!0});Hn.NoteToRDFConverter=void 0;Hn.normaliseExcludedFolders=a3;Hn.isPathExcluded=c3;var pv=Le(),yr=Gn(),_o=Ie(),mn=Ue(),i3=Ut(),Yt=Qt(),s3=Vt(),HV=K1(),KV=Gc(),mv=z1(),Nn=rb(),QV=lv(),o3=new Set(["archived","draft","pinned","aliases"]);function a3(n){return Array.isArray(n)?n.map(e=>String(e).replace(/\\/g,"/").trim()).filter(e=>e.length>0).map(e=>e.endsWith("/")?e:`${e}/`):[]}a(a3,"normaliseExcludedFolders");function c3(n,e){if(e.length===0)return!1;let t=n.replace(/\\/g,"/");for(let r of e)if(t.startsWith(r))return!0;return!1}a(c3,"isPathExcluded");function XV(n){if(!n)return"";let e=n.replace(/\\/g,"/");for(;e.startsWith("/");)e=e.slice(1);for(;e.endsWith("/");)e=e.slice(0,-1);return e.length>0?`${e}/`:""}a(XV,"normaliseSubjectIriPrefix");var kl=class{static{a(this,"NoteToRDFConverter")}constructor(e,t=KV.NullLogger,r={}){this.vault=e,this.logger=t,this.BODY_WIKILINK_PATTERN=/(?<!!)\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g,this.pendingExtraTriples=[],this.vocabularyMapper=new HV.RDFVocabularyMapper,this.subjectIriPrefix=XV(r.subjectIriPrefix)}async convertNote(e){let t=this.vault.getFrontmatter(e);if(!t)return[];let r=this.notePathToIRI(e.path),i=Yt.Namespace.EXO.term("Asset_filename"),s=new yr.Triple(r,i,new mn.Literal(e.basename));if(Nn.Exo003Parser.isExo003Format(t)){let o=await this.convertExo003Note(e,t);return[s,...o]}return this.convertLegacyNote(e,t,s)}async convertLegacyNote(e,t,r){this.pendingExtraTriples=[];let i=[r],s=this.notePathToIRI(e.path);for(let[f,d]of Object.entries(t)){let h=o3.has(f)?`exo__Asset_${f}`:f;if(!this.isExocortexProperty(h))continue;let p=this.propertyKeyToIRI(h),g=Array.isArray(d)?d:[d];for(let y of g)if(!((f==="exo__Asset_label"||o3.has(f))&&(y==null||typeof y=="string"&&y.trim()==="")))if(f==="exo__Instance_class"){let v=this.valueToClassURI(y);i.push(new yr.Triple(s,p,v))}else{let v=await this.valueToRDFObject(y,e,p);for(let _ of v)if(i.push(new yr.Triple(s,p,_)),this.vocabularyMapper.hasMappingFor(f)&&_ instanceof _o.IRI){let E=this.vocabularyMapper.generateMappedTriple(s,f,_);E&&i.push(E)}}if(f==="exo__Instance_class")for(let y of g){let v=this.valueToClassURI(y);if(v instanceof _o.IRI){let _=Yt.Namespace.RDF.term("type");i.push(new yr.Triple(s,_,v))}}if(f==="exo__Asset_label"){let y=Yt.Namespace.RDFS.term("label");for(let v of g)typeof v=="string"&&v.length>0&&i.push(new yr.Triple(s,y,new mn.Literal(v)))}}let o="exo__Instance_class"in t||"exo__Asset_uid"in t,c=t.exo__Asset_label,l="exo__Asset_label"in t&&c!==null&&c!==void 0&&!(typeof c=="string"&&c.trim()==="")&&!(Array.isArray(c)&&c.length===0);if(o&&!l){let f=Yt.Namespace.RDFS.term("label"),d=Yt.Namespace.EXO.term("Asset_label"),h=new mn.Literal(e.basename);i.push(new yr.Triple(s,f,h)),i.push(new yr.Triple(s,d,h))}i.push(...this.pendingExtraTriples),this.pendingExtraTriples=[];let u=await this.convertBodyWikilinks(e,s);return i.push(...u),i}async convertExo003Note(e,t){let r=Nn.Exo003Parser.parse(t);if(!r.success||!r.metadata)return[];let i=r.metadata,s=[];switch(i.metadata){case Nn.Exo003MetadataType.Namespace:break;case Nn.Exo003MetadataType.Anchor:s.push(...this.convertExo003Anchor(e,i));break;case Nn.Exo003MetadataType.BlankNode:s.push(...this.convertExo003BlankNode(e,i));break;case Nn.Exo003MetadataType.Statement:s.push(...this.convertExo003Statement(e,i));break;case Nn.Exo003MetadataType.Body:s.push(...await this.convertExo003Body(e,i));break}return s}convertExo003Anchor(e,t){let r=this.notePathToIRI(e.path),i=new _o.IRI(t.uri);return[new yr.Triple(r,Yt.Namespace.OWL.term("sameAs"),i),new yr.Triple(i,Yt.Namespace.OWL.term("sameAs"),r)]}convertExo003BlankNode(e,t){let r=this.notePathToIRI(e.path),i=t.uri.replace(/[^a-zA-Z0-9_-]/g,"_");return[new yr.Triple(r,Yt.Namespace.OWL.term("sameAs"),new i3.BlankNode(i))]}convertExo003Statement(e,t){let r=[];try{let i=this.createExo003ReferenceResolver(e),s=Nn.Exo003Parser.toTriple(t,i);r.push(s);let o=this.notePathToIRI(e.path);r.push(new yr.Triple(o,Yt.Namespace.RDF.term("value"),s.subject))}catch{}return r}async convertExo003Body(e,t){let r=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),o=this.createExo003ReferenceResolver(e),c=o(t.subject),l=o(t.predicate);if(c.type==="literal")throw new Error("Body subject cannot be a literal");if(l.type!=="iri")throw new Error("Body predicate must be an IRI");let u=c.type==="iri"?new _o.IRI(c.value):new i3.BlankNode(c.value),f=new _o.IRI(l.value),d=Nn.Exo003Parser.toLiteral(t,s.trim());r.push(new yr.Triple(u,f,d));let h=this.notePathToIRI(e.path);r.push(new yr.Triple(h,Yt.Namespace.RDF.term("value"),u))}catch{}return r}createExo003ReferenceResolver(e){return t=>{let r=this.extractWikilink(t),i=r||t,s=this.vault.getFirstLinkpathDest(i,e.path);if(s){let o=this.vault.getFrontmatter(s);if(o&&Nn.Exo003Parser.isExo003Format(o)){let c=Nn.Exo003Parser.parse(o);if(c.success&&c.metadata){let l=c.metadata;if(l.metadata===Nn.Exo003MetadataType.Anchor||l.metadata===Nn.Exo003MetadataType.Namespace)return{type:"iri",value:l.uri};if(l.metadata===Nn.Exo003MetadataType.BlankNode)return{type:"blank",value:l.uri.replace(/[^a-zA-Z0-9_-]/g,"_")}}}return{type:"iri",value:this.notePathToIRI(s.path).value}}return!r&&t.includes("://")?{type:"iri",value:t}:{type:"literal",value:t}}}async convertVault(e={}){return(await this.convertVaultWithValidation({strict:!1,excludedFolders:e.excludedFolders})).triples}async convertVaultWithValidation(e={}){let t=this.vault.getAllFiles(),r=[],i=[],s=e.strict??!1,o=(0,QV.discoverFileSpaceExclusions)(this.vault);for(let u of o.warnings)this.logger.warn(`FileSpace discovery: ${u}`);let c=[...a3(e.excludedFolders),...o.prefixes],l=c.length===0?t:t.filter(u=>!c3(u.path,c));for(let u of l)try{let f=this.vault.getFrontmatter(u),d=f?this.validateExocortexAsset(f,u.basename):null;if(d){if(s)throw new Error(`Invariant violation in "${u.path}": ${d.message}`);i.push({path:u.path,reason:`Invariant violation: ${d.message}`}),this.logger.warn(`Skipping file with invariant violation: ${u.path}`,{code:d.code,property:d.property,reason:d.message});continue}let h=await this.convertNote(u);r.push(...h)}catch(f){let d=f instanceof Error?f.message:String(f);if(s)throw new Error(`Invalid IRI for file "${u.path}": ${d}`);i.push({path:u.path,reason:`Invalid IRI: ${d}`}),this.logger.warn(`Skipping file with invalid IRI: ${u.path}`,{reason:d})}return{triples:r,skippedFiles:i,summary:{total:l.length,indexed:l.length-i.length,skipped:i.length},fileSpaces:o}}static inferLabelFromBasename(e){return Yt.Namespace.fromPropertyKey(e)!==null?e:null}validateExocortexAsset(e,t){let r=a(d=>d==null?!0:typeof d=="string"?d.trim()==="":Array.isArray(d)?d.length===0||d.every(r):!1,"isEmpty");if(!("exo__Instance_class"in e||"exo__Asset_uid"in e))return null;let s=["exo__Asset_uid","exo__Instance_class"];for(let d of s){if(!(d in e))return{code:"MISSING_PROPERTY",property:d,message:`Required property "${d}" is missing`};if(r(e[d]))return{code:"EMPTY_PROPERTY",property:d,message:`Required property "${d}" is empty`}}let o=["ems__Effort_status","ems__Effort_parent","ems__Effort_lockedBy","ems__Effort_lockExpires","exo__Asset_updatedAt","ems__Effort_startTimestamp"];for(let d of o)if(d in e&&r(e[d]))return{code:"EMPTY_OPTIONAL_PROPERTY",property:d,message:`Optional property "${d}" is present but empty`};let c=e.exo__Instance_class,l=Array.isArray(c)?c:[c],u=null,f=!1;for(let d of l){if(typeof d!="string")continue;let h=this.removeQuotes(d),g=(this.extractWikilink(h)??h).trim();/^[a-z][a-zA-Z0-9]*__/.test(g)&&/[\s()]/.test(g)?u||(u={candidate:d}):f=!0}return u&&!f?{code:"INVALID_INSTANCE_CLASS_IRI",property:"exo__Instance_class",message:`Invalid Instance_class IRI: "${u.candidate}"`}:null}async validateVault(){let e=this.vault.getAllFiles(),t=[];for(let r of e){let i=(0,mv.vaultPathToIRI)(r.path);_o.IRI.isValidIRI(i)||t.push({path:r.path,reason:`Path "${r.path}" cannot be converted to a valid IRI`})}return t}notePathToIRI(e){return new _o.IRI((0,mv.vaultPathToIRI)(`${this.subjectIriPrefix}${e}`))}synthesizeWikilinkTargetIRI(e){return new _o.IRI((0,mv.vaultPathToIRI)(e))}isExocortexProperty(e){return Yt.Namespace.fromPropertyKey(e)!==null}propertyKeyToIRI(e){let t=Yt.Namespace.fromPropertyKey(e);if(!t)throw new Error(`Invalid property key: ${e}`);return t.namespace.term(t.localName)}emitTypeTripleForEnumInstance(e,t){let r=this.vault.getFrontmatter(t);if(!r)return;let i=r.exo__Instance_class,s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return;let o=this.valueToClassURI(s);o instanceof _o.IRI&&(this.pendingExtraTriples.push(new yr.Triple(e,Yt.Namespace.RDF.term("type"),o)),this.pendingExtraTriples.push(new yr.Triple(e,Yt.Namespace.EXO.term("Instance_class"),o)))}async valueToRDFObject(e,t,r){if(typeof e=="string"){let i=this.removeQuotes(e),s=this.extractWikilink(i);if(s){let o=this.vault.getFirstLinkpathDest(s,t.path);if(o){let l=this.notePathToIRI(o.path),u=s.includes("|")?s.split("|")[0]:s;if(this.isUUID(u)){let d=new mn.Literal(u);if(r?.value.endsWith("#Grounding_targetValueRef")||r?.value.endsWith("#Grounding_targetValueSubstitution")||r?.value.endsWith("#Grounding_targetClass")||r?.value.endsWith("#Grounding_type")||r?.value.endsWith("#PropertyDefault_value"))return[l];let p=this.expandClassValue(o.basename);if(p)return this.emitTypeTripleForEnumInstance(p,o),[p];let g=this.vault.getFrontmatter(o);if(g){let E=g.exo__Asset_label;if(typeof E=="string"){let T=this.expandClassValue(E);if(T)return this.emitTypeTripleForEnumInstance(T,o),[T]}}let y=r?.value.endsWith("#Asset_prototype")||r?.value.endsWith("/Asset_prototype"),v=(process.env.EXOCORTEX_DUAL_STORAGE_PREDICATES??"").split(",").map(E=>E.trim()).filter(Boolean),_=v.length>0&&v.some(E=>r?.value.endsWith(`#${E}`));return y||_?[l,d]:[l]}let f=this.expandClassValue(o.basename);return f?(this.emitTypeTripleForEnumInstance(f,o),[f]):[l]}if(this.isClassReference(s)){let l=this.expandClassValue(s);if(l)return[l]}let c=s.includes("|")?s.split("|")[0]:s;return this.isUUID(c)?[this.synthesizeWikilinkTargetIRI(`${c}.md`)]:[new mn.Literal(i)]}if(this.isClassReference(i)){let o=this.expandClassValue(i);if(o)return[o]}return this.isISO8601DateTime(i)?[new mn.Literal(i,Yt.Namespace.XSD.term("dateTime"))]:[new mn.Literal(i)]}return typeof e=="boolean"?[new mn.Literal(e.toString())]:typeof e=="number"?[new mn.Literal(e.toString(),Yt.Namespace.XSD.term("decimal"))]:e instanceof Date?[new mn.Literal(e.toISOString(),Yt.Namespace.XSD.term("dateTime"))]:[new mn.Literal(String(e))]}isISO8601DateTime(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?(Z|[+-]\d{2}:\d{2})?$/.test(e)}removeQuotes(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.substring(1,t.length-1):e}extractWikilink(e){let t=e.match(/^\[\[([^\]]+)\]\]$/);if(!t)return null;let r=t[1];return r.includes("|")?r.split("|")[0]:r}extractWikilinkAlias(e){let t=e.match(/^\[\[([^\]]+)\]\]$/);if(!t)return null;let r=t[1],i=r.indexOf("|");return i>=0?r.substring(i+1).trim():null}valueToClassURI(e){if(typeof e!="string")return new mn.Literal(String(e));let t=this.removeQuotes(e),i=this.extractWikilink(t)||t,s=this.expandClassValue(i);if(s)return s;let o=this.extractWikilinkAlias(t);if(o){let c=this.expandClassValue(o);if(c)return c}if(this.isUUID(i)){let c=this.vault.getFirstLinkpathDest(i,"");if(c){let l=this.expandClassValue(c.basename);if(l)return l;let u=this.vault.getFrontmatter(c);if(u){let f=u.exo__Asset_label;if(typeof f=="string"){let d=this.expandClassValue(f);if(d)return d}}return this.notePathToIRI(c.path)}}return new mn.Literal(t)}isClassReference(e){return/\s/.test(e)?!1:Yt.Namespace.fromPropertyKey(e)!==null}isUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}expandClassValue(e){let t=this.removeQuotes(e),r=Yt.Namespace.fromPropertyKey(t);return!r||/[\s()]/.test(r.localName)?null:r.namespace.term(r.localName)}extractBodyContent(e){let t=/^---\r?\n[\s\S]*?\r?\n---\r?\n?/;return e.replace(t,"")}extractBodyWikilinks(e){let t=new Set,r,i=new RegExp(this.BODY_WIKILINK_PATTERN.source,"g");for(;(r=i.exec(e))!==null;)r[1]&&t.add(r[1]);return Array.from(t)}async convertBodyWikilinks(e,t){let r=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),o=this.extractBodyWikilinks(s),c=Yt.Namespace.EXO.term("Asset_bodyLink");for(let l of o){let u=this.vault.getFirstLinkpathDest(l,e.path);if(u){let f=this.notePathToIRI(u.path);r.push(new yr.Triple(t,c,f))}else if(this.isClassReference(l)){let f=this.expandClassValue(l);f?r.push(new yr.Triple(t,c,f)):r.push(new yr.Triple(t,c,new mn.Literal(l)))}else r.push(new yr.Triple(t,c,new mn.Literal(l)))}}catch{}return r}};Hn.NoteToRDFConverter=kl;kl.SkippedFileInfo=class{constructor(n,e){this.path=n,this.reason=e}};kl.VaultValidationResult=class{constructor(n,e,t){this.triples=n,this.skippedFiles=e,this.summary=t}};kl.VaultValidationOptions=class{constructor(n=!1){this.strict=n}};Hn.NoteToRDFConverter=kl=WV([(0,pv.injectable)(),n3(0,(0,pv.inject)(s3.DI_TOKENS.IVaultAdapter)),n3(1,(0,pv.inject)(s3.DI_TOKENS.ILogger)),zV("design:paramtypes",[Object,Object,Object])],kl)});var _v=S(Jm=>{"use strict";Object.defineProperty(Jm,"__esModule",{value:!0});Jm.FilterContainsOptimizer=void 0;var YV=Ie(),JV=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i,yv=class{static{a(this,"FilterContainsOptimizer")}constructor(){this.tripleStore=null,this.lastOptimizationHints=[]}setTripleStore(e){this.tripleStore=e}getLastOptimizationHints(){return this.lastOptimizationHints}clearHints(){this.lastOptimizationHints=[]}async optimize(e){return this.clearHints(),this.optimizeRecursive(e)}optimizeSync(e,t){return this.clearHints(),this.optimizeSyncRecursive(e,t)}async optimizeRecursive(e){return e.type==="filter"?this.optimizeFilter(e):e.type==="join"?{type:"join",left:await this.optimizeRecursive(e.left),right:await this.optimizeRecursive(e.right)}:e.type==="leftjoin"?{...e,left:await this.optimizeRecursive(e.left),right:await this.optimizeRecursive(e.right)}:e.type==="union"?{type:"union",left:await this.optimizeRecursive(e.left),right:await this.optimizeRecursive(e.right)}:e.type==="minus"?{...e,left:await this.optimizeRecursive(e.left),right:await this.optimizeRecursive(e.right)}:e.type==="project"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="orderby"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="slice"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="distinct"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="reduced"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="group"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="extend"?{...e,input:await this.optimizeRecursive(e.input)}:e}optimizeSyncRecursive(e,t){return e.type==="filter"?this.optimizeFilterSync(e,t):e.type==="join"?{type:"join",left:this.optimizeSyncRecursive(e.left,t),right:this.optimizeSyncRecursive(e.right,t)}:e.type==="leftjoin"?{...e,left:this.optimizeSyncRecursive(e.left,t),right:this.optimizeSyncRecursive(e.right,t)}:e.type==="union"?{type:"union",left:this.optimizeSyncRecursive(e.left,t),right:this.optimizeSyncRecursive(e.right,t)}:e.type==="minus"?{...e,left:this.optimizeSyncRecursive(e.left,t),right:this.optimizeSyncRecursive(e.right,t)}:e.type==="project"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="orderby"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="slice"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="distinct"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="reduced"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="group"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="extend"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e}async optimizeFilter(e){let t=this.detectContainsUUIDPattern(e.expression);if(!t)return{type:"filter",expression:e.expression,input:await this.optimizeRecursive(e.input)};let r=[];return this.tripleStore&&(r=await this.findSubjectsContainingUUID(t.uuid)),this.rewriteFilter(e,t,r)}optimizeFilterSync(e,t){let r=this.detectContainsUUIDPattern(e.expression);if(!r)return{type:"filter",expression:e.expression,input:this.optimizeSyncRecursive(e.input,t)};let i=t?t.filter(s=>s.includes(r.uuid)):[];return this.rewriteFilter(e,r,i)}rewriteFilter(e,t,r){if(this.lastOptimizationHints.push({type:"uuid-index-lookup",originalPattern:`FILTER(CONTAINS(STR(?${t.variable}), "${t.uuid}"))`,suggestedRewrite:r.length===1?`VALUES ?${t.variable} { <${r[0]}> }`:r.length>1?`VALUES ?${t.variable} { ${r.map(i=>`<${i}>`).join(" ")} }`:"No matching URIs found for UUID",estimatedSpeedup:r.length>0?"O(n) \u2192 O(1)":"N/A",matchedUri:r.length===1?r[0]:void 0}),r.length===0)return{type:"filter",expression:e.expression,input:this.optimizeSyncRecursive(e.input)};if(r.length===1){let i=this.injectSubjectConstraint(e.input,t.variable,r[0]);if(i!==e.input)return i}return this.createValuesJoin(e,t,r)}detectContainsUUIDPattern(e){if(e.type==="function"||e.type==="functionCall"){let t=e;if((typeof t.function=="string"?t.function.toLowerCase():t.function?.value?.toLowerCase()??"")==="contains"&&t.args.length===2)return this.analyzeContainsArgs(t.args[0],t.args[1],e)}if(e.type==="logical"&&e.operator==="&&")for(let t of e.operands){let r=this.detectContainsUUIDPattern(t);if(r)return r}return null}analyzeContainsArgs(e,t,r){let i=null;if(e.type==="function"||e.type==="functionCall"){let s=e;if((typeof s.function=="string"?s.function.toLowerCase():s.function?.value?.toLowerCase()??"")==="str"&&s.args.length===1){let c=s.args[0];c.type==="variable"&&(i=c.name)}}if(!i&&e.type==="variable"&&(i=e.name),!i)return null;if(t.type==="literal"){let c=String(t.value).match(JV);if(c)return{variable:i,uuid:c[0].toLowerCase(),originalExpression:r}}return null}async findSubjectsContainingUUID(e){if(!this.tripleStore)return[];if(this.tripleStore.findSubjectsByUUID)return(await this.tripleStore.findSubjectsByUUID(e)).map(s=>s.value);let t=await this.tripleStore.subjects(),r=[];for(let i of t)i instanceof YV.IRI&&i.value.toLowerCase().includes(e.toLowerCase())&&r.push(i.value);return r}injectSubjectConstraint(e,t,r){if(e.type==="bgp"){let i=e.triples.map(o=>o.subject.type==="variable"&&o.subject.value===t?{...o,subject:{type:"iri",value:r}}:o);if(i.some((o,c)=>o.subject!==e.triples[c].subject))return{type:"bgp",triples:i}}if(e.type==="join"){let i=this.injectSubjectConstraint(e.left,t,r),s=this.injectSubjectConstraint(e.right,t,r);if(i!==e.left||s!==e.right)return{type:"join",left:i,right:s}}if(e.type==="filter"){let i=this.injectSubjectConstraint(e.input,t,r);if(i!==e.input)return{...e,input:i}}return e}createValuesJoin(e,t,r){return{type:"join",left:{type:"values",variables:[t.variable],bindings:r.map(o=>({[t.variable]:{type:"iri",value:o}}))},right:this.optimizeSyncRecursive(e.input)}}analyzeQuery(e){let t=[];return this.analyzeRecursive(e,t),t}analyzeRecursive(e,t){if(e.type==="filter"){let r=this.detectContainsUUIDPattern(e.expression);r&&t.push({type:"uuid-index-lookup",originalPattern:`FILTER(CONTAINS(STR(?${r.variable}), "${r.uuid}"))`,suggestedRewrite:`Use --optimize flag or rewrite as VALUES ?${r.variable} { <uri-containing-uuid> }`,estimatedSpeedup:"O(n) \u2192 O(1) with UUID index lookup"}),this.analyzeRecursive(e.input,t);return}e.type==="join"?(this.analyzeRecursive(e.left,t),this.analyzeRecursive(e.right,t)):e.type==="leftjoin"?(this.analyzeRecursive(e.left,t),this.analyzeRecursive(e.right,t)):e.type==="union"?(this.analyzeRecursive(e.left,t),this.analyzeRecursive(e.right,t)):e.type==="minus"?(this.analyzeRecursive(e.left,t),this.analyzeRecursive(e.right,t)):e.type==="project"?this.analyzeRecursive(e.input,t):e.type==="orderby"?this.analyzeRecursive(e.input,t):e.type==="slice"?this.analyzeRecursive(e.input,t):e.type==="distinct"?this.analyzeRecursive(e.input,t):e.type==="reduced"?this.analyzeRecursive(e.input,t):e.type==="group"?this.analyzeRecursive(e.input,t):e.type==="extend"&&this.analyzeRecursive(e.input,t)}};Jm.FilterContainsOptimizer=yv});var l3=S(Zm=>{"use strict";Object.defineProperty(Zm,"__esModule",{value:!0});Zm.AlgebraOptimizer=void 0;var ZV=_v(),bv=class{static{a(this,"AlgebraOptimizer")}constructor(){this.stats=new Map,this.tripleStore=null,this.filterContainsOptimizer=new ZV.FilterContainsOptimizer}setTripleStore(e){this.tripleStore=e,this.filterContainsOptimizer.setTripleStore(e)}getOptimizationHints(){return this.filterContainsOptimizer.getLastOptimizationHints()}analyzeQuery(e){return this.filterContainsOptimizer.analyzeQuery(e)}optimize(e){let t=e;return t=this.eliminateEmptyBGPInFilterJoin(t),t=this.filterPushDown(t),t=this.joinReordering(t),t}async optimizeAsync(e){let t=e;return t=this.eliminateEmptyBGPInFilterJoin(t),this.tripleStore&&(t=await this.filterContainsOptimizer.optimize(t)),t=this.filterPushDown(t),t=this.joinReordering(t),t}optimizeWithSubjects(e,t){let r=e;return r=this.eliminateEmptyBGPInFilterJoin(r),r=this.filterContainsOptimizer.optimizeSync(r,t),r=this.filterPushDown(r),r=this.joinReordering(r),r}eliminateEmptyBGPInFilterJoin(e){if(e.type==="join"){if(e.left.type==="filter"){let t=e.left;if(t.input.type==="bgp"&&t.input.triples.length===0)return{type:"filter",expression:t.expression,input:this.eliminateEmptyBGPInFilterJoin(e.right)}}if(e.right.type==="filter"){let t=e.right;if(t.input.type==="bgp"&&t.input.triples.length===0)return{type:"filter",expression:t.expression,input:this.eliminateEmptyBGPInFilterJoin(e.left)}}return{type:"join",left:this.eliminateEmptyBGPInFilterJoin(e.left),right:this.eliminateEmptyBGPInFilterJoin(e.right)}}return e.type==="filter"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e.type==="leftjoin"?{...e,left:this.eliminateEmptyBGPInFilterJoin(e.left),right:this.eliminateEmptyBGPInFilterJoin(e.right)}:e.type==="union"?{...e,left:this.eliminateEmptyBGPInFilterJoin(e.left),right:this.eliminateEmptyBGPInFilterJoin(e.right)}:e.type==="minus"?{...e,left:this.eliminateEmptyBGPInFilterJoin(e.left),right:this.eliminateEmptyBGPInFilterJoin(e.right)}:e.type==="project"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e.type==="orderby"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e.type==="slice"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e.type==="distinct"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e}filterPushDown(e){return e.type==="filter"?this.pushDownFilter(e):e.type==="join"?{type:"join",left:this.filterPushDown(e.left),right:this.filterPushDown(e.right)}:e.type==="leftjoin"?{...e,left:this.filterPushDown(e.left),right:this.filterPushDown(e.right)}:e.type==="union"?{type:"union",left:this.filterPushDown(e.left),right:this.filterPushDown(e.right)}:e.type==="minus"?{...e,left:this.filterPushDown(e.left),right:this.filterPushDown(e.right)}:e.type==="project"?{...e,input:this.filterPushDown(e.input)}:e.type==="orderby"?{...e,input:this.filterPushDown(e.input)}:e.type==="slice"?{...e,input:this.filterPushDown(e.input)}:e.type==="distinct"?{...e,input:this.filterPushDown(e.input)}:e}pushDownFilter(e){let t=e.input;if(t.type==="join"){let r=this.getFilterVariables(e.expression),i=this.getOperationVariables(t.left),s=this.getOperationVariables(t.right),o=r.every(l=>i.has(l)),c=r.every(l=>s.has(l));return o&&!c?{type:"join",left:{type:"filter",expression:e.expression,input:this.filterPushDown(t.left)},right:this.filterPushDown(t.right)}:c&&!o?{type:"join",left:this.filterPushDown(t.left),right:{type:"filter",expression:e.expression,input:this.filterPushDown(t.right)}}:{type:"filter",expression:e.expression,input:{type:"join",left:this.filterPushDown(t.left),right:this.filterPushDown(t.right)}}}return t.type==="union"?{type:"union",left:{type:"filter",expression:e.expression,input:this.filterPushDown(t.left)},right:{type:"filter",expression:e.expression,input:this.filterPushDown(t.right)}}:{type:"filter",expression:e.expression,input:this.filterPushDown(t)}}getFilterVariables(e){let t=[];if(e.type==="variable")t.push(e.name);else if(e.type==="comparison")t.push(...this.getFilterVariables(e.left)),t.push(...this.getFilterVariables(e.right));else if(e.type==="logical")for(let r of e.operands)t.push(...this.getFilterVariables(r));else if(e.type==="function")for(let r of e.args)t.push(...this.getFilterVariables(r));return Array.from(new Set(t))}getOperationVariables(e){let t=new Set;if(e.type==="bgp")for(let r of e.triples)r.subject.type==="variable"&&t.add(r.subject.value),r.predicate.type==="variable"&&t.add(r.predicate.value),r.object.type==="variable"&&t.add(r.object.value);else if(e.type==="join"){let r=this.getOperationVariables(e.left),i=this.getOperationVariables(e.right);return new Set([...r,...i])}else{if(e.type==="filter")return this.getOperationVariables(e.input);if(e.type==="leftjoin"){let r=this.getOperationVariables(e.left),i=this.getOperationVariables(e.right);return new Set([...r,...i])}else if(e.type==="union"){let r=this.getOperationVariables(e.left),i=this.getOperationVariables(e.right);return new Set([...r,...i])}else{if(e.type==="minus")return this.getOperationVariables(e.left);if(e.type==="project")return new Set(e.variables)}}return t}joinReordering(e){return e.type==="join"?this.reorderJoin(e):e.type==="filter"?{...e,input:this.joinReordering(e.input)}:e.type==="leftjoin"?{...e,left:this.joinReordering(e.left),right:this.joinReordering(e.right)}:e.type==="union"?{...e,left:this.joinReordering(e.left),right:this.joinReordering(e.right)}:e.type==="minus"?{...e,left:this.joinReordering(e.left),right:this.joinReordering(e.right)}:e.type==="project"?{...e,input:this.joinReordering(e.input)}:e.type==="orderby"?{...e,input:this.joinReordering(e.input)}:e.type==="slice"?{...e,input:this.joinReordering(e.input)}:e.type==="distinct"?{...e,input:this.joinReordering(e.input)}:e}reorderJoin(e){let t=this.isConstrained(e.left),r=this.isConstrained(e.right);if(r&&!t)return{type:"join",left:this.joinReordering(e.right),right:this.joinReordering(e.left)};if(t&&!r)return{type:"join",left:this.joinReordering(e.left),right:this.joinReordering(e.right)};let i=this.estimateCost(e.left);return this.estimateCost(e.right)<i?{type:"join",left:this.joinReordering(e.right),right:this.joinReordering(e.left)}:{type:"join",left:this.joinReordering(e.left),right:this.joinReordering(e.right)}}isConstrained(e){return e.type==="values"?!0:e.type==="bgp"?e.triples.some(t=>t.object.type!=="variable"||t.subject.type!=="variable"):e.type==="filter"?this.isConstrained(e.input):e.type==="join"?this.isConstrained(e.left)||this.isConstrained(e.right):e.type==="union"?this.isConstrained(e.left)&&this.isConstrained(e.right):!1}estimateCost(e){if(e.type==="bgp"){let t=0;for(let r of e.triples){let i=10;r.subject.type==="variable"&&(i*=10),r.predicate.type==="variable"&&(i*=20),r.object.type==="variable"&&(i*=5),t+=i}return t}if(e.type==="filter")return this.estimateCost(e.input)*.3;if(e.type==="join"){let t=this.estimateCost(e.left),r=this.estimateCost(e.right);return e.left.type==="values"||e.right.type==="values"?Math.min(t,r)*2:t*r}if(e.type==="leftjoin")return this.estimateCost(e.left)+this.estimateCost(e.right)*.5;if(e.type==="union")return this.estimateCost(e.left)+this.estimateCost(e.right);if(e.type==="values"){let t=e.bindings;return Array.isArray(t)?t.length*5:10}return e.type==="minus"?this.estimateCost(e.left)+this.estimateCost(e.right)*.3:100}setStatistics(e,t){this.stats.set(e,t)}getStatistics(e){return this.stats.get(e)}};Zm.AlgebraOptimizer=bv});var u3=S(eg=>{"use strict";Object.defineProperty(eg,"__esModule",{value:!0});eg.AlgebraSerializer=void 0;var Sv=class{static{a(this,"AlgebraSerializer")}toString(e,t=0){let r=" ".repeat(t);switch(e.type){case"bgp":return`${r}BGP [
375
+ `),t}};Wm.RDFSerializer=W1});var z1=S(yo=>{"use strict";Object.defineProperty(yo,"__esModule",{value:!0});yo.OBSIDIAN_VAULT_SCHEME=void 0;yo.vaultPathToIRI=mV;yo.iriToVaultPath=gV;yo.OBSIDIAN_VAULT_SCHEME="obsidian://vault/";function mV(n){let e=n.startsWith("./")?n.slice(2):n;return`${yo.OBSIDIAN_VAULT_SCHEME}${encodeURI(e)}`}a(mV,"vaultPathToIRI");function gV(n){if(!n.startsWith(yo.OBSIDIAN_VAULT_SCHEME))return null;let e=n.slice(yo.OBSIDIAN_VAULT_SCHEME.length);try{return decodeURI(e)}catch{return null}}a(gV,"iriToVaultPath")});var K1=S(zm=>{"use strict";Object.defineProperty(zm,"__esModule",{value:!0});zm.RDFVocabularyMapper=void 0;var or=Gn(),GC=Ie(),te=Qt(),H1=class{static{a(this,"RDFVocabularyMapper")}constructor(){this.propertyMappings=new Map([["exo__Instance_class",te.Namespace.RDF.term("type")],["exo__Asset_isDefinedBy",te.Namespace.RDFS.term("isDefinedBy")],["exo__Class_superClass",te.Namespace.RDFS.term("subClassOf")],["exo__Property_range",te.Namespace.RDFS.term("range")],["exo__Property_domain",te.Namespace.RDFS.term("domain")],["exo__Property_superProperty",te.Namespace.RDFS.term("subPropertyOf")]])}generateClassHierarchyTriples(){let e=[];return e.push(new or.Triple(te.Namespace.EXO.term("Asset"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.RDFS.term("Resource"))),e.push(new or.Triple(te.Namespace.EXO.term("Class"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.RDFS.term("Class"))),e.push(new or.Triple(te.Namespace.EXO.term("Property"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.RDF.term("Property"))),e.push(new or.Triple(te.Namespace.EMS.term("Task"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.EXO.term("Asset"))),e.push(new or.Triple(te.Namespace.EMS.term("Project"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.EXO.term("Asset"))),e.push(new or.Triple(te.Namespace.EMS.term("Area"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.EXO.term("Asset"))),e.push(new or.Triple(te.Namespace.EMS.term("Workflow"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.EXO.term("Asset"))),e.push(new or.Triple(te.Namespace.EMS.term("WorkflowState"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.EXO.term("Asset"))),e.push(new or.Triple(te.Namespace.EMS.term("WorkflowTransition"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.EXO.term("Asset"))),e.push(new or.Triple(te.Namespace.EXOCMD.term("Command"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.EXO.term("Asset"))),e.push(new or.Triple(te.Namespace.EXOCMD.term("Precondition"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.EXO.term("Asset"))),e.push(new or.Triple(te.Namespace.EXOCMD.term("Grounding"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.EXO.term("Asset"))),e.push(new or.Triple(te.Namespace.EXOCMD.term("CommandBinding"),te.Namespace.RDFS.term("subClassOf"),te.Namespace.EXO.term("Asset"))),e}generatePropertyHierarchyTriples(){let e=[];return e.push(new or.Triple(te.Namespace.EXO.term("Instance_class"),te.Namespace.RDFS.term("subPropertyOf"),te.Namespace.RDF.term("type"))),e.push(new or.Triple(te.Namespace.EXO.term("Asset_isDefinedBy"),te.Namespace.RDFS.term("subPropertyOf"),te.Namespace.RDFS.term("isDefinedBy"))),e.push(new or.Triple(te.Namespace.EXO.term("Class_superClass"),te.Namespace.RDFS.term("subPropertyOf"),te.Namespace.RDFS.term("subClassOf"))),e.push(new or.Triple(te.Namespace.EXO.term("Property_range"),te.Namespace.RDFS.term("subPropertyOf"),te.Namespace.RDFS.term("range"))),e.push(new or.Triple(te.Namespace.EXO.term("Property_domain"),te.Namespace.RDFS.term("subPropertyOf"),te.Namespace.RDFS.term("domain"))),e.push(new or.Triple(te.Namespace.EXO.term("Property_superProperty"),te.Namespace.RDFS.term("subPropertyOf"),te.Namespace.RDFS.term("subPropertyOf"))),e}generateMappedTriple(e,t,r){let i=this.propertyMappings.get(t);if(!i)return null;let s;if(r instanceof GC.IRI)s=r;else{let o=r.match(/^(ems|exo|exocmd)__(.+)$/);if(o){let[,c,l]=o;s=(c==="ems"?te.Namespace.EMS:c==="exocmd"?te.Namespace.EXOCMD:te.Namespace.EXO).term(l)}else s=new GC.IRI(r)}return new or.Triple(e,i,s)}hasMappingFor(e){return this.propertyMappings.has(e)}};zm.RDFVocabularyMapper=H1});var qC=S(Km=>{"use strict";Object.defineProperty(Km,"__esModule",{value:!0});Km.RDFSInferenceEngine=void 0;var yV=Gn(),Hm=Ie(),Q1=class{static{a(this,"RDFSInferenceEngine")}async materialize(e){let t=await e.predicates(),r=t.find(d=>d.value.includes("Class_superClass")),i=t.find(d=>d.value.includes("Instance_class"));if(!r||!i)return 0;let s=await this.buildDirectParentMap(e,r);if(s.size===0)return 0;let o=this.computeAllAncestors(s),c=await e.count(),l=await e.match(void 0,i),u=[];for(let d of l)if(d.object instanceof Hm.IRI){let h=o.get(d.object.value);if(h)for(let p of h)u.push(new yV.Triple(d.subject,i,new Hm.IRI(p)))}return u.length>0&&await e.addAll(u),await e.count()-c}async buildDirectParentMap(e,t){let r=await e.match(void 0,t),i=new Map;for(let s of r)if(s.subject instanceof Hm.IRI&&s.object instanceof Hm.IRI){let o=s.subject.value,c=s.object.value;i.has(o)||i.set(o,new Set),i.get(o).add(c)}return i}computeAllAncestors(e){let t=new Map;for(let r of e.keys())t.has(r)||t.set(r,this.computeAncestorsBFS(r,e));return t}computeAncestorsBFS(e,t){let r=new Set,i=new Set,s=[],o=t.get(e);if(o)for(let c of o)s.push(c);for(;s.length>0;){let c=s.shift();if(i.has(c))continue;i.add(c),r.add(c);let l=t.get(c);if(l)for(let u of l)i.has(u)||s.push(u)}return r}};Km.RDFSInferenceEngine=Q1});var J1=S(nc=>{"use strict";var _V=nc&&nc.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(o=n[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s};Object.defineProperty(nc,"__esModule",{value:!0});nc.NonInheritablePropertyRegistry=void 0;var bV=Le(),WC=Ie(),zC=Ue(),X1=Qt(),Y1=class{static{a(this,"NonInheritablePropertyRegistry")}constructor(){this.nonInheritableIRIs=new Set,this.initialized=!1}async initialize(e){this.nonInheritableIRIs.clear();try{let t=await e.predicates(),r=t.find(c=>c.value.includes("Instance_class"));if(!r){this.initialized=!0;return}let i=await this.findNonInheritableClassIRI(e,t);if(!i){this.initialized=!0;return}let s=await e.match(void 0,r,i);if(s.length===0){this.initialized=!0;return}let o=t.find(c=>c.value.includes("Asset_label"));if(!o){this.initialized=!0;return}for(let c of s){let l=await e.match(c.subject,o,void 0);for(let u of l)if(u.object instanceof zC.Literal){let f=u.object.value,d=this.propertyKeyToIRI(f);d&&this.nonInheritableIRIs.add(d)}}}catch{}this.initialized=!0}isNonInheritable(e){return this.nonInheritableIRIs.has(e)}get size(){return this.nonInheritableIRIs.size}get isInitialized(){return this.initialized}async findNonInheritableClassIRI(e,t){let r=t.find(o=>o.value.includes("Asset_label"));if(!r)return null;let i=await e.match(void 0,r,new zC.Literal("exo__NonInheritableProperty"));if(i.length>0&&i[0].subject instanceof WC.IRI)return i[0].subject;let s=t.find(o=>o.value.includes("Instance_class"));if(s){let o=await e.match(void 0,s,void 0);for(let c of o)if(c.object instanceof WC.IRI&&c.object.value.includes("NonInheritableProperty"))return c.object}return null}propertyKeyToIRI(e){return e.startsWith("exo__")?X1.Namespace.EXO.term(e.substring(5)).value:e.startsWith("ems__")?X1.Namespace.EMS.term(e.substring(5)).value:e.startsWith("exocmd__")?X1.Namespace.EXOCMD.term(e.substring(8)).value:null}};nc.NonInheritablePropertyRegistry=Y1;nc.NonInheritablePropertyRegistry=Y1=_V([(0,bV.injectable)()],Y1)});var tv=S(ic=>{"use strict";var SV=ic&&ic.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(o=n[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s};Object.defineProperty(ic,"__esModule",{value:!0});ic.PropertyCardinalityRegistry=void 0;var wV=Le(),HC=Ie(),KC=Ue(),Z1=Qt(),ev=class{static{a(this,"PropertyCardinalityRegistry")}constructor(){this.multiValuedIRIs=new Set,this.initialized=!1}async initialize(e){this.multiValuedIRIs.clear();try{let t=await e.predicates(),r=t.find(c=>c.value.includes("Property_cardinality"));if(!r){this.initialized=!0;return}let i=await this.findMultipleCardinalityIRI(e,t);if(!i){this.initialized=!0;return}let s=await e.match(void 0,r,i);if(s.length===0){this.initialized=!0;return}let o=t.find(c=>c.value.includes("Asset_label"));if(!o){this.initialized=!0;return}for(let c of s){let l=await e.match(c.subject,o,void 0);for(let u of l)if(u.object instanceof KC.Literal){let f=u.object.value,d=this.propertyKeyToIRI(f);d&&this.multiValuedIRIs.add(d)}}}catch{}this.initialized=!0}isMultiValued(e){return this.multiValuedIRIs.has(e)}get size(){return this.multiValuedIRIs.size}get isInitialized(){return this.initialized}async findMultipleCardinalityIRI(e,t){let r=t.find(o=>o.value.includes("Asset_label"));if(!r)return null;let i=await e.match(void 0,r,new KC.Literal("exo__PropertyCardinalityMultiple"));if(i.length>0&&i[0].subject instanceof HC.IRI)return i[0].subject;let s=t.find(o=>o.value.includes("Instance_class"));if(s){let o=await e.match(void 0,s,void 0);for(let c of o)if(c.object instanceof HC.IRI&&c.object.value.includes("PropertyCardinalityMultiple"))return c.object}return null}propertyKeyToIRI(e){return e.startsWith("exo__")?Z1.Namespace.EXO.term(e.substring(5)).value:e.startsWith("ems__")?Z1.Namespace.EMS.term(e.substring(5)).value:e.startsWith("exocmd__")?Z1.Namespace.EXOCMD.term(e.substring(8)).value:null}};ic.PropertyCardinalityRegistry=ev;ic.PropertyCardinalityRegistry=ev=SV([(0,wV.injectable)()],ev)});var iv=S(Er=>{"use strict";var vV=Er&&Er.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(o=n[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},EV=Er&&Er.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Er,"__esModule",{value:!0});Er.PrototypeChainMaterializer=Er.MAX_PROTOTYPE_DEPTH=Er.INFERRED_GRAPH=void 0;Er.inferredGraphForDepth=rv;var TV=Le(),QC=Gn(),Yo=Ie(),AV=J1(),IV=tv();Er.INFERRED_GRAPH=new Yo.IRI("https://exocortex.my/ontology/exo#inferred");var xV="https://exocortex.my/ontology/exo#inferred/";function rv(n){return new Yo.IRI(`${xV}${n}`)}a(rv,"inferredGraphForDepth");Er.MAX_PROTOTYPE_DEPTH=10;var nv=class{static{a(this,"PrototypeChainMaterializer")}constructor(e,t){this.registry=e,this.cardinalityRegistry=t??null}async materialize(e){let r=(await e.predicates()).find(c=>c.value.includes("Asset_prototype"));if(!r)return 0;let i=await e.match(void 0,r,void 0);if(i.length===0)return 0;let s=new Map;for(let c of i)if(c.subject instanceof Yo.IRI&&c.object instanceof Yo.IRI){let l=c.subject.value,u=c.object.value;l!==u&&s.set(l,c.object)}if(s.size===0)return 0;let o=0;for(let[c]of s){let l=new Yo.IRI(c),u=this.resolveChain(c,s);if(u.length===0)continue;let f=await e.match(l,void 0,void 0),d=new Set,h=new Map;for(let p of f)if(d.add(p.predicate.value),this.isMultiValued(p.predicate.value)){let g=p.object instanceof Yo.IRI?p.object.value:String(p.object),y=h.get(p.predicate.value);y||(y=new Set,h.set(p.predicate.value,y)),y.add(g)}for(let p=0;p<u.length;p++){let g=u[p],y=p+1,v=new Yo.IRI(g),_=await e.match(v,void 0,void 0),E=new Set;if(e.matchInGraph){let T=await e.matchInGraph(v,void 0,void 0,Er.INFERRED_GRAPH);for(let O of T)E.add(O.predicate.value)}for(let T of _){let O=T.predicate.value;if(this.registry.isNonInheritable(O)||E.has(O))continue;if(d.has(O)&&this.isMultiValued(O)){let D=T.object instanceof Yo.IRI?T.object.value:String(T.object);if(h.get(O)?.has(D))continue;let le=h.get(O);le||(le=new Set,h.set(O,le)),le.add(D);let F=new QC.Triple(l,T.predicate,T.object);await e.add(F),e.addToGraph&&(await e.addToGraph(F,Er.INFERRED_GRAPH),await e.addToGraph(F,rv(y))),o++;continue}if(d.has(O))continue;let N=new QC.Triple(l,T.predicate,T.object);await e.add(N),e.addToGraph&&(await e.addToGraph(N,Er.INFERRED_GRAPH),await e.addToGraph(N,rv(y))),d.add(O),o++}}}return o}isMultiValued(e){return this.cardinalityRegistry?this.cardinalityRegistry.isMultiValued(e):!1}resolveChain(e,t){let r=[],i=new Set;i.add(e);let s=[],o=t.get(e);for(o&&s.push(o.value);s.length>0&&r.length<Er.MAX_PROTOTYPE_DEPTH;){let c=s.shift();if(c===void 0)break;if(i.has(c))continue;i.add(c),r.push(c);let l=t.get(c);l&&!i.has(l.value)&&s.push(l.value)}return r}};Er.PrototypeChainMaterializer=nv;Er.PrototypeChainMaterializer=nv=vV([(0,TV.injectable)(),EV("design:paramtypes",[AV.NonInheritablePropertyRegistry,IV.PropertyCardinalityRegistry])],nv)});var YC=S(Xm=>{"use strict";Object.defineProperty(Xm,"__esModule",{value:!0});Xm.IRICanonicalizer=void 0;var XC=Ie(),RV=Ue(),CV=Ut(),PV=Gn(),sv=/^obsidian:\/\/vault\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i,Qm=class n{static{a(this,"IRICanonicalizer")}static extractSynthAUid(e){let t=sv.exec(e);return t?t[1].toLowerCase():null}static canonicalize(e,t){if(t.size===0)return{triples:e,remapCount:0,uniqueRemapCount:0};let r=new Map,i=new Set,s=0;return{triples:e.map(c=>{let l=n.remapIfSynthA(c.subject,t,r,i),u=n.remapIfSynthA(c.object,t,r,i);return l===c.subject&&u===c.object?c:(s++,new PV.Triple(l,c.predicate,u))}),remapCount:s,uniqueRemapCount:i.size}}static remapIfSynthA(e,t,r,i){if(e instanceof RV.Literal||e instanceof CV.BlankNode||!(e instanceof XC.IRI))return e;let s=sv.exec(e.value);if(!s)return e;let o=s[1].toLowerCase(),c=t.get(o);if(!c||c===e.value)return e;i.add(o);let l=r.get(c);return l||(l=new XC.IRI(c),r.set(c,l)),l}};Xm.IRICanonicalizer=Qm;Qm.SYNTH_A_IRI_PATTERN=sv});var av=S(ov=>{"use strict";Object.defineProperty(ov,"__esModule",{value:!0});ov.derivePath=FV;var OV="assetspaces",JC=/^[A-Za-z0-9._-]+$/;function FV(n){if(typeof n!="string")return null;let e=n.trim();if(e.length===0||/^file:\/\//i.test(e))return null;e=e.replace(/\/+$/,""),e=e.replace(/\.git$/i,"");let t=null;if(!e.includes("://")){let o=/^[^/@\s]+@[^/:\s]+:(.+)$/.exec(e);o&&(t=o[1])}if(t===null){let o=e.replace(/^[a-z][a-z0-9+.-]*:\/\//i,"");o=o.replace(/^[^/@]+@/,"");let c=o.indexOf("/");if(c<0)return null;t=o.slice(c+1)}let r=t.split("/").filter(o=>o.length>0);if(r.length<2)return null;let i=r[0],s=r[1];return i==="."||i===".."||s==="."||s===".."||!JC.test(i)||!JC.test(s)?null:`${OV}/${i}/${s}`}a(FV,"derivePath")});var lv=S(Bi=>{"use strict";Object.defineProperty(Bi,"__esModule",{value:!0});Bi.FILE_SPACE_CLASS_UID=void 0;Bi.frontmatterDeclaresFileSpace=LV;Bi.discoverFileSpaceExclusions=kV;var DV=av();Bi.FILE_SPACE_CLASS_UID="aad8913e-5e9f-4047-879d-93cc46befd52";var ZC=/\[\[([^\]|]+)(?:\|[^\]]*)?\]\]/g,cv=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function t3(n){let e=Array.isArray(n)?n:[n],t=[];for(let r of e){if(typeof r!="string")continue;ZC.lastIndex=0;let i;for(;(i=ZC.exec(r))!==null;)t.push(i[1].trim())}return t}a(t3,"wikilinkTargets");function LV(n){return n?t3(n.exo__Instance_class).some(e=>cv.test(e)&&e.toLowerCase()===Bi.FILE_SPACE_CLASS_UID):!1}a(LV,"frontmatterDeclaresFileSpace");function e3(n,e){try{return n.getFrontmatter(e)}catch{return null}}a(e3,"readFrontmatterSafe");function NV(n){let e=n.exo__AssetSpace_source;if(typeof e=="string"&&e.length>0)return e;let t=n.exo__AssetSpace_git;return typeof t=="string"&&t.length>0?t:null}a(NV,"readSource");function kV(n){let e=[],t=[],r=[],i=new Map,s=a((c,l)=>{if(cv.test(c))return c.toLowerCase()===Bi.FILE_SPACE_CLASS_UID;let u=n.getFirstLinkpathDest(c,l);if(u==null)return!1;let f=i.get(u.path);if(f!==void 0)return f;let h=e3(n,u)?.exo__Asset_uid,p=typeof h=="string"&&h.toLowerCase()===Bi.FILE_SPACE_CLASS_UID;return i.set(u.path,p),p},"isFileSpaceClassRef"),o=a(c=>c.some(l=>cv.test(l)&&l.toLowerCase()===Bi.FILE_SPACE_CLASS_UID),"hasUuidFormRef");for(let c of n.getAllFiles()){let l=e3(n,c);if(!l)continue;let u=t3(l.exo__Instance_class);if(!u.some(p=>s(p,c.path)))continue;t.push(c.path),o(u)||r.push(`FileSpace declaration ${c.path} references the class via a label-form link only \u2014 the sync layer will not pick it up; use the UUID-form wikilink [[${Bi.FILE_SPACE_CLASS_UID}]] (UID-canon)`);let f=NV(l);if(f===null){r.push(`FileSpace declaration ${c.path} has no exo__AssetSpace_source/_git \u2014 mount path underivable, content NOT excluded from the index`);continue}let d=(0,DV.derivePath)(f);if(d===null){r.push(`FileSpace declaration ${c.path}: cannot derive mount path from source "${f}" \u2014 content NOT excluded from the index`);continue}let h=`${d}/`;c.path.startsWith(h)&&r.push(`FileSpace declaration ${c.path} lies INSIDE its own mount ${h} \u2014 it will be excluded from the index together with the content; move the declaration outside the mount folder`),e.push(h)}return{prefixes:e,declarationPaths:t,warnings:r}}a(kV,"discoverFileSpaceExclusions")});var r3=S(zn=>{"use strict";var MV=zn&&zn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(o=n[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},jV=zn&&zn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(zn,"__esModule",{value:!0});zn.LazyAssetGraphLoader=zn.MAX_LAZY_DEPTH=void 0;var $V=Le(),UV=Ie(),uv=Qt();zn.MAX_LAZY_DEPTH=10;var fv=class{static{a(this,"LazyAssetGraphLoader")}constructor(e,t,r){this.converter=e,this.fileResolver=t,this.store=r,this.loadedIRIs=new Set,this.instanceClassPredicate=uv.Namespace.EXO.term("Instance_class"),this.superClassPredicate=uv.Namespace.EXO.term("Class_superClass"),this.prototypePredicate=uv.Namespace.EXO.term("Asset_prototype")}async ensureFileLoaded(e,t=0){if(t>=zn.MAX_LAZY_DEPTH)return;let r=this.converter.notePathToIRI(e.path).value;if(!this.loadedIRIs.has(r)){this.loadedIRIs.add(r);try{let i=await this.converter.convertNote(e);if(!this.loadedIRIs.has(r)||(await this.store.addAll(i),!this.loadedIRIs.has(r)))return;await this.walkClassAndPrototypeRelations(i,t+1)}catch(i){throw this.loadedIRIs.delete(r),i}}}async ensureLoadedByIRI(e,t=0){if(t>=zn.MAX_LAZY_DEPTH||this.loadedIRIs.has(e.value))return;let r=this.fileResolver.resolveByIRI(e);r!==null&&await this.ensureFileLoaded(r,t)}isLoaded(e){return this.loadedIRIs.has(e.value)}forget(e){this.loadedIRIs.delete(e.value)}clearAll(){this.loadedIRIs.clear()}get loadedCount(){return this.loadedIRIs.size}clearForTests(){this.loadedIRIs.clear()}async walkClassAndPrototypeRelations(e,t){let r=[];for(let i of e){if(!(i.object instanceof UV.IRI))continue;let s=i.predicate.value;(s===this.instanceClassPredicate.value||s===this.superClassPredicate.value||s===this.prototypePredicate.value)&&r.push(i.object)}for(let i of r)await this.ensureLoadedByIRI(i,t)}};zn.LazyAssetGraphLoader=fv;zn.LazyAssetGraphLoader=fv=MV([(0,$V.injectable)(),jV("design:paramtypes",[Object,Object,Object])],fv)});var hv=S(gr=>{"use strict";var BV=gr&&gr.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(o=n[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},VV=gr&&gr.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(gr,"__esModule",{value:!0});gr.SourceAnnotator=gr.DEPTH_VARIABLE=gr.SOURCE_VARIABLE=void 0;var GV=Le(),Nl=Ue(),qV=Ie(),Ym=iv();gr.SOURCE_VARIABLE="_source";gr.DEPTH_VARIABLE="_depth";var dv=class{static{a(this,"SourceAnnotator")}constructor(e){this.tripleStore=e}async annotate(e,t,r,i){if(!this.tripleStore.matchInGraph)return e.map(o=>{let c=o.clone();return c.set(gr.SOURCE_VARIABLE,new Nl.Literal("own")),c});let s=[];for(let o of e){let c=o.get(t),l=o.get(r),u=o.get(i),f=o.clone();if(!c||!l||!u)f.set(gr.SOURCE_VARIABLE,new Nl.Literal("own"));else{let d=await this.determineSource(c,l,u);f.set(gr.SOURCE_VARIABLE,new Nl.Literal(d))}s.push(f)}return s}async annotateSingle(e,t,r,i){return(await this.annotate([e],t,r,i))[0]}async determineSource(e,t,r){return this.tripleStore.matchInGraph&&(await this.tripleStore.matchInGraph(e,t,r,Ym.INFERRED_GRAPH)).length>0?"inherited":"own"}async getInheritanceDepth(e,t,r){if(!this.tripleStore.matchInGraph)return 0;for(let i=1;i<=Ym.MAX_PROTOTYPE_DEPTH;i++){let s=(0,Ym.inferredGraphForDepth)(i);if((await this.tripleStore.matchInGraph(e,t,r,s)).length>0)return i}return 0}async annotateBySubject(e,t){if(!this.tripleStore.matchInGraph)return e.map(s=>{let o=s.clone();return o.set(gr.SOURCE_VARIABLE,new Nl.Literal("own")),o});let r=[],i=new Map;for(let s of e){let o=s.get(t),c=s.clone();if(!o||!(o instanceof qV.IRI))c.set(gr.SOURCE_VARIABLE,new Nl.Literal("own"));else{let l=o.value;if(!i.has(l)){let f=await this.tripleStore.matchInGraph(o,void 0,void 0,Ym.INFERRED_GRAPH);i.set(l,f.length>0?"inherited":"own")}let u=i.get(l)??"own";c.set(gr.SOURCE_VARIABLE,new Nl.Literal(u))}r.push(c)}return r}};gr.SourceAnnotator=dv;gr.SourceAnnotator=dv=BV([(0,GV.injectable)(),VV("design:paramtypes",[Object])],dv)});var gv=S(Hn=>{"use strict";var WV=Hn&&Hn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(o=n[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},zV=Hn&&Hn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},n3=Hn&&Hn.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Hn,"__esModule",{value:!0});Hn.NoteToRDFConverter=void 0;Hn.normaliseExcludedFolders=a3;Hn.isPathExcluded=c3;var pv=Le(),yr=Gn(),_o=Ie(),mn=Ue(),i3=Ut(),Yt=Qt(),s3=Vt(),HV=K1(),KV=Gc(),mv=z1(),Nn=rb(),QV=lv(),o3=new Set(["archived","draft","pinned","aliases"]);function a3(n){return Array.isArray(n)?n.map(e=>String(e).replace(/\\/g,"/").trim()).filter(e=>e.length>0).map(e=>e.endsWith("/")?e:`${e}/`):[]}a(a3,"normaliseExcludedFolders");function c3(n,e){if(e.length===0)return!1;let t=n.replace(/\\/g,"/");for(let r of e)if(t.startsWith(r))return!0;return!1}a(c3,"isPathExcluded");function XV(n){if(!n)return"";let e=n.replace(/\\/g,"/");for(;e.startsWith("/");)e=e.slice(1);for(;e.endsWith("/");)e=e.slice(0,-1);return e.length>0?`${e}/`:""}a(XV,"normaliseSubjectIriPrefix");var kl=class{static{a(this,"NoteToRDFConverter")}constructor(e,t=KV.NullLogger,r={}){this.vault=e,this.logger=t,this.BODY_WIKILINK_PATTERN=/(?<!!)\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g,this.pendingExtraTriples=[],this.vocabularyMapper=new HV.RDFVocabularyMapper,this.subjectIriPrefix=XV(r.subjectIriPrefix)}async convertNote(e){let t=this.vault.getFrontmatter(e);if(!t)return[];let r=this.notePathToIRI(e.path),i=Yt.Namespace.EXO.term("Asset_filename"),s=new yr.Triple(r,i,new mn.Literal(e.basename));if(Nn.Exo003Parser.isExo003Format(t)){let o=await this.convertExo003Note(e,t);return[s,...o]}return this.convertLegacyNote(e,t,s)}async convertLegacyNote(e,t,r){this.pendingExtraTriples=[];let i=[r],s=this.notePathToIRI(e.path);for(let[f,d]of Object.entries(t)){let h=o3.has(f)?`exo__Asset_${f}`:f;if(!this.isExocortexProperty(h))continue;let p=this.propertyKeyToIRI(h),g=Array.isArray(d)?d:[d];for(let y of g)if(!((f==="exo__Asset_label"||o3.has(f))&&(y==null||typeof y=="string"&&y.trim()==="")))if(f==="exo__Instance_class"){let v=this.valueToClassURI(y);i.push(new yr.Triple(s,p,v))}else{let v=await this.valueToRDFObject(y,e,p);for(let _ of v)if(i.push(new yr.Triple(s,p,_)),this.vocabularyMapper.hasMappingFor(f)&&_ instanceof _o.IRI){let E=this.vocabularyMapper.generateMappedTriple(s,f,_);E&&i.push(E)}}if(f==="exo__Instance_class")for(let y of g){let v=this.valueToClassURI(y);if(v instanceof _o.IRI){let _=Yt.Namespace.RDF.term("type");i.push(new yr.Triple(s,_,v))}}if(f==="exo__Asset_label"){let y=Yt.Namespace.RDFS.term("label");for(let v of g)typeof v=="string"&&v.length>0&&i.push(new yr.Triple(s,y,new mn.Literal(v)))}}let o="exo__Instance_class"in t||"exo__Asset_uid"in t,c=t.exo__Asset_label,l="exo__Asset_label"in t&&c!==null&&c!==void 0&&!(typeof c=="string"&&c.trim()==="")&&!(Array.isArray(c)&&c.length===0);if(o&&!l){let f=Yt.Namespace.RDFS.term("label"),d=Yt.Namespace.EXO.term("Asset_label"),h=new mn.Literal(e.basename);i.push(new yr.Triple(s,f,h)),i.push(new yr.Triple(s,d,h))}i.push(...this.pendingExtraTriples),this.pendingExtraTriples=[];let u=await this.convertBodyWikilinks(e,s);return i.push(...u),i}async convertExo003Note(e,t){let r=Nn.Exo003Parser.parse(t);if(!r.success||!r.metadata)return[];let i=r.metadata,s=[];switch(i.metadata){case Nn.Exo003MetadataType.Namespace:break;case Nn.Exo003MetadataType.Anchor:s.push(...this.convertExo003Anchor(e,i));break;case Nn.Exo003MetadataType.BlankNode:s.push(...this.convertExo003BlankNode(e,i));break;case Nn.Exo003MetadataType.Statement:s.push(...this.convertExo003Statement(e,i));break;case Nn.Exo003MetadataType.Body:s.push(...await this.convertExo003Body(e,i));break}return s}convertExo003Anchor(e,t){let r=this.notePathToIRI(e.path),i=new _o.IRI(t.uri);return[new yr.Triple(r,Yt.Namespace.OWL.term("sameAs"),i),new yr.Triple(i,Yt.Namespace.OWL.term("sameAs"),r)]}convertExo003BlankNode(e,t){let r=this.notePathToIRI(e.path),i=t.uri.replace(/[^a-zA-Z0-9_-]/g,"_");return[new yr.Triple(r,Yt.Namespace.OWL.term("sameAs"),new i3.BlankNode(i))]}convertExo003Statement(e,t){let r=[];try{let i=this.createExo003ReferenceResolver(e),s=Nn.Exo003Parser.toTriple(t,i);r.push(s);let o=this.notePathToIRI(e.path);r.push(new yr.Triple(o,Yt.Namespace.RDF.term("value"),s.subject))}catch{}return r}async convertExo003Body(e,t){let r=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),o=this.createExo003ReferenceResolver(e),c=o(t.subject),l=o(t.predicate);if(c.type==="literal")throw new Error("Body subject cannot be a literal");if(l.type!=="iri")throw new Error("Body predicate must be an IRI");let u=c.type==="iri"?new _o.IRI(c.value):new i3.BlankNode(c.value),f=new _o.IRI(l.value),d=Nn.Exo003Parser.toLiteral(t,s.trim());r.push(new yr.Triple(u,f,d));let h=this.notePathToIRI(e.path);r.push(new yr.Triple(h,Yt.Namespace.RDF.term("value"),u))}catch{}return r}createExo003ReferenceResolver(e){return t=>{let r=this.extractWikilink(t),i=r||t,s=this.vault.getFirstLinkpathDest(i,e.path);if(s){let o=this.vault.getFrontmatter(s);if(o&&Nn.Exo003Parser.isExo003Format(o)){let c=Nn.Exo003Parser.parse(o);if(c.success&&c.metadata){let l=c.metadata;if(l.metadata===Nn.Exo003MetadataType.Anchor||l.metadata===Nn.Exo003MetadataType.Namespace)return{type:"iri",value:l.uri};if(l.metadata===Nn.Exo003MetadataType.BlankNode)return{type:"blank",value:l.uri.replace(/[^a-zA-Z0-9_-]/g,"_")}}}return{type:"iri",value:this.notePathToIRI(s.path).value}}return!r&&t.includes("://")?{type:"iri",value:t}:{type:"literal",value:t}}}async convertVault(e={}){return(await this.convertVaultWithValidation({strict:!1,excludedFolders:e.excludedFolders})).triples}async convertVaultWithValidation(e={}){let t=this.vault.getAllFiles(),r=[],i=[],s=e.strict??!1,o=0,c=0,l=(0,QV.discoverFileSpaceExclusions)(this.vault);for(let d of l.warnings)this.logger.warn(`FileSpace discovery: ${d}`);let u=[...a3(e.excludedFolders),...l.prefixes],f=u.length===0?t:t.filter(d=>!c3(d.path,u));for(let d of f)try{let h=this.vault.getFrontmatter(d),p=h?this.validateExocortexAsset(h,d.basename):null;if(p){if(s)throw new Error(`Invariant violation in "${d.path}": ${p.message}`);i.push({path:d.path,reason:`Invariant violation: ${p.message}`}),o++,this.logger.info(`Skipping file with invariant violation: ${d.path}`,{code:p.code,property:p.property,reason:p.message});continue}let g=await this.convertNote(d);r.push(...g)}catch(h){let p=h instanceof Error?h.message:String(h);if(s)throw new Error(`Invalid IRI for file "${d.path}": ${p}`);i.push({path:d.path,reason:`Invalid IRI: ${p}`}),c++,this.logger.info(`Skipping file with invalid IRI: ${d.path}`,{reason:p})}return o>0&&this.logger.warn(`Skipped ${o} file${o===1?"":"s"} with invariant violations during indexing (paths in developer console)`,{count:o}),c>0&&this.logger.warn(`Skipped ${c} file${c===1?"":"s"} with invalid IRI during indexing (paths in developer console)`,{count:c}),{triples:r,skippedFiles:i,summary:{total:f.length,indexed:f.length-i.length,skipped:i.length},fileSpaces:l}}static inferLabelFromBasename(e){return Yt.Namespace.fromPropertyKey(e)!==null?e:null}validateExocortexAsset(e,t){let r=a(d=>d==null?!0:typeof d=="string"?d.trim()==="":Array.isArray(d)?d.length===0||d.every(r):!1,"isEmpty");if(!("exo__Instance_class"in e||"exo__Asset_uid"in e))return null;let s=["exo__Asset_uid","exo__Instance_class"];for(let d of s){if(!(d in e))return{code:"MISSING_PROPERTY",property:d,message:`Required property "${d}" is missing`};if(r(e[d]))return{code:"EMPTY_PROPERTY",property:d,message:`Required property "${d}" is empty`}}let o=["ems__Effort_status","ems__Effort_parent","ems__Effort_lockedBy","ems__Effort_lockExpires","exo__Asset_updatedAt","ems__Effort_startTimestamp"];for(let d of o)if(d in e&&r(e[d]))return{code:"EMPTY_OPTIONAL_PROPERTY",property:d,message:`Optional property "${d}" is present but empty`};let c=e.exo__Instance_class,l=Array.isArray(c)?c:[c],u=null,f=!1;for(let d of l){if(typeof d!="string")continue;let h=this.removeQuotes(d),g=(this.extractWikilink(h)??h).trim();/^[a-z][a-zA-Z0-9]*__/.test(g)&&/[\s()]/.test(g)?u||(u={candidate:d}):f=!0}return u&&!f?{code:"INVALID_INSTANCE_CLASS_IRI",property:"exo__Instance_class",message:`Invalid Instance_class IRI: "${u.candidate}"`}:null}async validateVault(){let e=this.vault.getAllFiles(),t=[];for(let r of e){let i=(0,mv.vaultPathToIRI)(r.path);_o.IRI.isValidIRI(i)||t.push({path:r.path,reason:`Path "${r.path}" cannot be converted to a valid IRI`})}return t}notePathToIRI(e){return new _o.IRI((0,mv.vaultPathToIRI)(`${this.subjectIriPrefix}${e}`))}synthesizeWikilinkTargetIRI(e){return new _o.IRI((0,mv.vaultPathToIRI)(e))}isExocortexProperty(e){return Yt.Namespace.fromPropertyKey(e)!==null}propertyKeyToIRI(e){let t=Yt.Namespace.fromPropertyKey(e);if(!t)throw new Error(`Invalid property key: ${e}`);return t.namespace.term(t.localName)}emitTypeTripleForEnumInstance(e,t){let r=this.vault.getFrontmatter(t);if(!r)return;let i=r.exo__Instance_class,s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return;let o=this.valueToClassURI(s);o instanceof _o.IRI&&(this.pendingExtraTriples.push(new yr.Triple(e,Yt.Namespace.RDF.term("type"),o)),this.pendingExtraTriples.push(new yr.Triple(e,Yt.Namespace.EXO.term("Instance_class"),o)))}async valueToRDFObject(e,t,r){if(typeof e=="string"){let i=this.removeQuotes(e),s=this.extractWikilink(i);if(s){let o=this.vault.getFirstLinkpathDest(s,t.path);if(o){let l=this.notePathToIRI(o.path),u=s.includes("|")?s.split("|")[0]:s;if(this.isUUID(u)){let d=new mn.Literal(u);if(r?.value.endsWith("#Grounding_targetValueRef")||r?.value.endsWith("#Grounding_targetValueSubstitution")||r?.value.endsWith("#Grounding_targetClass")||r?.value.endsWith("#Grounding_type")||r?.value.endsWith("#PropertyDefault_value"))return[l];let p=this.expandClassValue(o.basename);if(p)return this.emitTypeTripleForEnumInstance(p,o),[p];let g=this.vault.getFrontmatter(o);if(g){let E=g.exo__Asset_label;if(typeof E=="string"){let T=this.expandClassValue(E);if(T)return this.emitTypeTripleForEnumInstance(T,o),[T]}}let y=r?.value.endsWith("#Asset_prototype")||r?.value.endsWith("/Asset_prototype"),v=(process.env.EXOCORTEX_DUAL_STORAGE_PREDICATES??"").split(",").map(E=>E.trim()).filter(Boolean),_=v.length>0&&v.some(E=>r?.value.endsWith(`#${E}`));return y||_?[l,d]:[l]}let f=this.expandClassValue(o.basename);return f?(this.emitTypeTripleForEnumInstance(f,o),[f]):[l]}if(this.isClassReference(s)){let l=this.expandClassValue(s);if(l)return[l]}let c=s.includes("|")?s.split("|")[0]:s;return this.isUUID(c)?[this.synthesizeWikilinkTargetIRI(`${c}.md`)]:[new mn.Literal(i)]}if(this.isClassReference(i)){let o=this.expandClassValue(i);if(o)return[o]}return this.isISO8601DateTime(i)?[new mn.Literal(i,Yt.Namespace.XSD.term("dateTime"))]:[new mn.Literal(i)]}return typeof e=="boolean"?[new mn.Literal(e.toString())]:typeof e=="number"?[new mn.Literal(e.toString(),Yt.Namespace.XSD.term("decimal"))]:e instanceof Date?[new mn.Literal(e.toISOString(),Yt.Namespace.XSD.term("dateTime"))]:[new mn.Literal(String(e))]}isISO8601DateTime(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?(Z|[+-]\d{2}:\d{2})?$/.test(e)}removeQuotes(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.substring(1,t.length-1):e}extractWikilink(e){let t=e.match(/^\[\[([^\]]+)\]\]$/);if(!t)return null;let r=t[1];return r.includes("|")?r.split("|")[0]:r}extractWikilinkAlias(e){let t=e.match(/^\[\[([^\]]+)\]\]$/);if(!t)return null;let r=t[1],i=r.indexOf("|");return i>=0?r.substring(i+1).trim():null}valueToClassURI(e){if(typeof e!="string")return new mn.Literal(String(e));let t=this.removeQuotes(e),i=this.extractWikilink(t)||t,s=this.expandClassValue(i);if(s)return s;let o=this.extractWikilinkAlias(t);if(o){let c=this.expandClassValue(o);if(c)return c}if(this.isUUID(i)){let c=this.vault.getFirstLinkpathDest(i,"");if(c){let l=this.expandClassValue(c.basename);if(l)return l;let u=this.vault.getFrontmatter(c);if(u){let f=u.exo__Asset_label;if(typeof f=="string"){let d=this.expandClassValue(f);if(d)return d}}return this.notePathToIRI(c.path)}}return new mn.Literal(t)}isClassReference(e){return/\s/.test(e)?!1:Yt.Namespace.fromPropertyKey(e)!==null}isUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}expandClassValue(e){let t=this.removeQuotes(e),r=Yt.Namespace.fromPropertyKey(t);return!r||/[\s()]/.test(r.localName)?null:r.namespace.term(r.localName)}extractBodyContent(e){let t=/^---\r?\n[\s\S]*?\r?\n---\r?\n?/;return e.replace(t,"")}extractBodyWikilinks(e){let t=new Set,r,i=new RegExp(this.BODY_WIKILINK_PATTERN.source,"g");for(;(r=i.exec(e))!==null;)r[1]&&t.add(r[1]);return Array.from(t)}async convertBodyWikilinks(e,t){let r=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),o=this.extractBodyWikilinks(s),c=Yt.Namespace.EXO.term("Asset_bodyLink");for(let l of o){let u=this.vault.getFirstLinkpathDest(l,e.path);if(u){let f=this.notePathToIRI(u.path);r.push(new yr.Triple(t,c,f))}else if(this.isClassReference(l)){let f=this.expandClassValue(l);f?r.push(new yr.Triple(t,c,f)):r.push(new yr.Triple(t,c,new mn.Literal(l)))}else r.push(new yr.Triple(t,c,new mn.Literal(l)))}}catch{}return r}};Hn.NoteToRDFConverter=kl;kl.SkippedFileInfo=class{constructor(n,e){this.path=n,this.reason=e}};kl.VaultValidationResult=class{constructor(n,e,t){this.triples=n,this.skippedFiles=e,this.summary=t}};kl.VaultValidationOptions=class{constructor(n=!1){this.strict=n}};Hn.NoteToRDFConverter=kl=WV([(0,pv.injectable)(),n3(0,(0,pv.inject)(s3.DI_TOKENS.IVaultAdapter)),n3(1,(0,pv.inject)(s3.DI_TOKENS.ILogger)),zV("design:paramtypes",[Object,Object,Object])],kl)});var _v=S(Jm=>{"use strict";Object.defineProperty(Jm,"__esModule",{value:!0});Jm.FilterContainsOptimizer=void 0;var YV=Ie(),JV=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i,yv=class{static{a(this,"FilterContainsOptimizer")}constructor(){this.tripleStore=null,this.lastOptimizationHints=[]}setTripleStore(e){this.tripleStore=e}getLastOptimizationHints(){return this.lastOptimizationHints}clearHints(){this.lastOptimizationHints=[]}async optimize(e){return this.clearHints(),this.optimizeRecursive(e)}optimizeSync(e,t){return this.clearHints(),this.optimizeSyncRecursive(e,t)}async optimizeRecursive(e){return e.type==="filter"?this.optimizeFilter(e):e.type==="join"?{type:"join",left:await this.optimizeRecursive(e.left),right:await this.optimizeRecursive(e.right)}:e.type==="leftjoin"?{...e,left:await this.optimizeRecursive(e.left),right:await this.optimizeRecursive(e.right)}:e.type==="union"?{type:"union",left:await this.optimizeRecursive(e.left),right:await this.optimizeRecursive(e.right)}:e.type==="minus"?{...e,left:await this.optimizeRecursive(e.left),right:await this.optimizeRecursive(e.right)}:e.type==="project"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="orderby"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="slice"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="distinct"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="reduced"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="group"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="extend"?{...e,input:await this.optimizeRecursive(e.input)}:e}optimizeSyncRecursive(e,t){return e.type==="filter"?this.optimizeFilterSync(e,t):e.type==="join"?{type:"join",left:this.optimizeSyncRecursive(e.left,t),right:this.optimizeSyncRecursive(e.right,t)}:e.type==="leftjoin"?{...e,left:this.optimizeSyncRecursive(e.left,t),right:this.optimizeSyncRecursive(e.right,t)}:e.type==="union"?{type:"union",left:this.optimizeSyncRecursive(e.left,t),right:this.optimizeSyncRecursive(e.right,t)}:e.type==="minus"?{...e,left:this.optimizeSyncRecursive(e.left,t),right:this.optimizeSyncRecursive(e.right,t)}:e.type==="project"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="orderby"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="slice"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="distinct"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="reduced"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="group"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="extend"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e}async optimizeFilter(e){let t=this.detectContainsUUIDPattern(e.expression);if(!t)return{type:"filter",expression:e.expression,input:await this.optimizeRecursive(e.input)};let r=[];return this.tripleStore&&(r=await this.findSubjectsContainingUUID(t.uuid)),this.rewriteFilter(e,t,r)}optimizeFilterSync(e,t){let r=this.detectContainsUUIDPattern(e.expression);if(!r)return{type:"filter",expression:e.expression,input:this.optimizeSyncRecursive(e.input,t)};let i=t?t.filter(s=>s.includes(r.uuid)):[];return this.rewriteFilter(e,r,i)}rewriteFilter(e,t,r){if(this.lastOptimizationHints.push({type:"uuid-index-lookup",originalPattern:`FILTER(CONTAINS(STR(?${t.variable}), "${t.uuid}"))`,suggestedRewrite:r.length===1?`VALUES ?${t.variable} { <${r[0]}> }`:r.length>1?`VALUES ?${t.variable} { ${r.map(i=>`<${i}>`).join(" ")} }`:"No matching URIs found for UUID",estimatedSpeedup:r.length>0?"O(n) \u2192 O(1)":"N/A",matchedUri:r.length===1?r[0]:void 0}),r.length===0)return{type:"filter",expression:e.expression,input:this.optimizeSyncRecursive(e.input)};if(r.length===1){let i=this.injectSubjectConstraint(e.input,t.variable,r[0]);if(i!==e.input)return i}return this.createValuesJoin(e,t,r)}detectContainsUUIDPattern(e){if(e.type==="function"||e.type==="functionCall"){let t=e;if((typeof t.function=="string"?t.function.toLowerCase():t.function?.value?.toLowerCase()??"")==="contains"&&t.args.length===2)return this.analyzeContainsArgs(t.args[0],t.args[1],e)}if(e.type==="logical"&&e.operator==="&&")for(let t of e.operands){let r=this.detectContainsUUIDPattern(t);if(r)return r}return null}analyzeContainsArgs(e,t,r){let i=null;if(e.type==="function"||e.type==="functionCall"){let s=e;if((typeof s.function=="string"?s.function.toLowerCase():s.function?.value?.toLowerCase()??"")==="str"&&s.args.length===1){let c=s.args[0];c.type==="variable"&&(i=c.name)}}if(!i&&e.type==="variable"&&(i=e.name),!i)return null;if(t.type==="literal"){let c=String(t.value).match(JV);if(c)return{variable:i,uuid:c[0].toLowerCase(),originalExpression:r}}return null}async findSubjectsContainingUUID(e){if(!this.tripleStore)return[];if(this.tripleStore.findSubjectsByUUID)return(await this.tripleStore.findSubjectsByUUID(e)).map(s=>s.value);let t=await this.tripleStore.subjects(),r=[];for(let i of t)i instanceof YV.IRI&&i.value.toLowerCase().includes(e.toLowerCase())&&r.push(i.value);return r}injectSubjectConstraint(e,t,r){if(e.type==="bgp"){let i=e.triples.map(o=>o.subject.type==="variable"&&o.subject.value===t?{...o,subject:{type:"iri",value:r}}:o);if(i.some((o,c)=>o.subject!==e.triples[c].subject))return{type:"bgp",triples:i}}if(e.type==="join"){let i=this.injectSubjectConstraint(e.left,t,r),s=this.injectSubjectConstraint(e.right,t,r);if(i!==e.left||s!==e.right)return{type:"join",left:i,right:s}}if(e.type==="filter"){let i=this.injectSubjectConstraint(e.input,t,r);if(i!==e.input)return{...e,input:i}}return e}createValuesJoin(e,t,r){return{type:"join",left:{type:"values",variables:[t.variable],bindings:r.map(o=>({[t.variable]:{type:"iri",value:o}}))},right:this.optimizeSyncRecursive(e.input)}}analyzeQuery(e){let t=[];return this.analyzeRecursive(e,t),t}analyzeRecursive(e,t){if(e.type==="filter"){let r=this.detectContainsUUIDPattern(e.expression);r&&t.push({type:"uuid-index-lookup",originalPattern:`FILTER(CONTAINS(STR(?${r.variable}), "${r.uuid}"))`,suggestedRewrite:`Use --optimize flag or rewrite as VALUES ?${r.variable} { <uri-containing-uuid> }`,estimatedSpeedup:"O(n) \u2192 O(1) with UUID index lookup"}),this.analyzeRecursive(e.input,t);return}e.type==="join"?(this.analyzeRecursive(e.left,t),this.analyzeRecursive(e.right,t)):e.type==="leftjoin"?(this.analyzeRecursive(e.left,t),this.analyzeRecursive(e.right,t)):e.type==="union"?(this.analyzeRecursive(e.left,t),this.analyzeRecursive(e.right,t)):e.type==="minus"?(this.analyzeRecursive(e.left,t),this.analyzeRecursive(e.right,t)):e.type==="project"?this.analyzeRecursive(e.input,t):e.type==="orderby"?this.analyzeRecursive(e.input,t):e.type==="slice"?this.analyzeRecursive(e.input,t):e.type==="distinct"?this.analyzeRecursive(e.input,t):e.type==="reduced"?this.analyzeRecursive(e.input,t):e.type==="group"?this.analyzeRecursive(e.input,t):e.type==="extend"&&this.analyzeRecursive(e.input,t)}};Jm.FilterContainsOptimizer=yv});var l3=S(Zm=>{"use strict";Object.defineProperty(Zm,"__esModule",{value:!0});Zm.AlgebraOptimizer=void 0;var ZV=_v(),bv=class{static{a(this,"AlgebraOptimizer")}constructor(){this.stats=new Map,this.tripleStore=null,this.filterContainsOptimizer=new ZV.FilterContainsOptimizer}setTripleStore(e){this.tripleStore=e,this.filterContainsOptimizer.setTripleStore(e)}getOptimizationHints(){return this.filterContainsOptimizer.getLastOptimizationHints()}analyzeQuery(e){return this.filterContainsOptimizer.analyzeQuery(e)}optimize(e){let t=e;return t=this.eliminateEmptyBGPInFilterJoin(t),t=this.filterPushDown(t),t=this.joinReordering(t),t}async optimizeAsync(e){let t=e;return t=this.eliminateEmptyBGPInFilterJoin(t),this.tripleStore&&(t=await this.filterContainsOptimizer.optimize(t)),t=this.filterPushDown(t),t=this.joinReordering(t),t}optimizeWithSubjects(e,t){let r=e;return r=this.eliminateEmptyBGPInFilterJoin(r),r=this.filterContainsOptimizer.optimizeSync(r,t),r=this.filterPushDown(r),r=this.joinReordering(r),r}eliminateEmptyBGPInFilterJoin(e){if(e.type==="join"){if(e.left.type==="filter"){let t=e.left;if(t.input.type==="bgp"&&t.input.triples.length===0)return{type:"filter",expression:t.expression,input:this.eliminateEmptyBGPInFilterJoin(e.right)}}if(e.right.type==="filter"){let t=e.right;if(t.input.type==="bgp"&&t.input.triples.length===0)return{type:"filter",expression:t.expression,input:this.eliminateEmptyBGPInFilterJoin(e.left)}}return{type:"join",left:this.eliminateEmptyBGPInFilterJoin(e.left),right:this.eliminateEmptyBGPInFilterJoin(e.right)}}return e.type==="filter"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e.type==="leftjoin"?{...e,left:this.eliminateEmptyBGPInFilterJoin(e.left),right:this.eliminateEmptyBGPInFilterJoin(e.right)}:e.type==="union"?{...e,left:this.eliminateEmptyBGPInFilterJoin(e.left),right:this.eliminateEmptyBGPInFilterJoin(e.right)}:e.type==="minus"?{...e,left:this.eliminateEmptyBGPInFilterJoin(e.left),right:this.eliminateEmptyBGPInFilterJoin(e.right)}:e.type==="project"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e.type==="orderby"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e.type==="slice"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e.type==="distinct"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e}filterPushDown(e){return e.type==="filter"?this.pushDownFilter(e):e.type==="join"?{type:"join",left:this.filterPushDown(e.left),right:this.filterPushDown(e.right)}:e.type==="leftjoin"?{...e,left:this.filterPushDown(e.left),right:this.filterPushDown(e.right)}:e.type==="union"?{type:"union",left:this.filterPushDown(e.left),right:this.filterPushDown(e.right)}:e.type==="minus"?{...e,left:this.filterPushDown(e.left),right:this.filterPushDown(e.right)}:e.type==="project"?{...e,input:this.filterPushDown(e.input)}:e.type==="orderby"?{...e,input:this.filterPushDown(e.input)}:e.type==="slice"?{...e,input:this.filterPushDown(e.input)}:e.type==="distinct"?{...e,input:this.filterPushDown(e.input)}:e}pushDownFilter(e){let t=e.input;if(t.type==="join"){let r=this.getFilterVariables(e.expression),i=this.getOperationVariables(t.left),s=this.getOperationVariables(t.right),o=r.every(l=>i.has(l)),c=r.every(l=>s.has(l));return o&&!c?{type:"join",left:{type:"filter",expression:e.expression,input:this.filterPushDown(t.left)},right:this.filterPushDown(t.right)}:c&&!o?{type:"join",left:this.filterPushDown(t.left),right:{type:"filter",expression:e.expression,input:this.filterPushDown(t.right)}}:{type:"filter",expression:e.expression,input:{type:"join",left:this.filterPushDown(t.left),right:this.filterPushDown(t.right)}}}return t.type==="union"?{type:"union",left:{type:"filter",expression:e.expression,input:this.filterPushDown(t.left)},right:{type:"filter",expression:e.expression,input:this.filterPushDown(t.right)}}:{type:"filter",expression:e.expression,input:this.filterPushDown(t)}}getFilterVariables(e){let t=[];if(e.type==="variable")t.push(e.name);else if(e.type==="comparison")t.push(...this.getFilterVariables(e.left)),t.push(...this.getFilterVariables(e.right));else if(e.type==="logical")for(let r of e.operands)t.push(...this.getFilterVariables(r));else if(e.type==="function")for(let r of e.args)t.push(...this.getFilterVariables(r));return Array.from(new Set(t))}getOperationVariables(e){let t=new Set;if(e.type==="bgp")for(let r of e.triples)r.subject.type==="variable"&&t.add(r.subject.value),r.predicate.type==="variable"&&t.add(r.predicate.value),r.object.type==="variable"&&t.add(r.object.value);else if(e.type==="join"){let r=this.getOperationVariables(e.left),i=this.getOperationVariables(e.right);return new Set([...r,...i])}else{if(e.type==="filter")return this.getOperationVariables(e.input);if(e.type==="leftjoin"){let r=this.getOperationVariables(e.left),i=this.getOperationVariables(e.right);return new Set([...r,...i])}else if(e.type==="union"){let r=this.getOperationVariables(e.left),i=this.getOperationVariables(e.right);return new Set([...r,...i])}else{if(e.type==="minus")return this.getOperationVariables(e.left);if(e.type==="project")return new Set(e.variables)}}return t}joinReordering(e){return e.type==="join"?this.reorderJoin(e):e.type==="filter"?{...e,input:this.joinReordering(e.input)}:e.type==="leftjoin"?{...e,left:this.joinReordering(e.left),right:this.joinReordering(e.right)}:e.type==="union"?{...e,left:this.joinReordering(e.left),right:this.joinReordering(e.right)}:e.type==="minus"?{...e,left:this.joinReordering(e.left),right:this.joinReordering(e.right)}:e.type==="project"?{...e,input:this.joinReordering(e.input)}:e.type==="orderby"?{...e,input:this.joinReordering(e.input)}:e.type==="slice"?{...e,input:this.joinReordering(e.input)}:e.type==="distinct"?{...e,input:this.joinReordering(e.input)}:e}reorderJoin(e){let t=this.isConstrained(e.left),r=this.isConstrained(e.right);if(r&&!t)return{type:"join",left:this.joinReordering(e.right),right:this.joinReordering(e.left)};if(t&&!r)return{type:"join",left:this.joinReordering(e.left),right:this.joinReordering(e.right)};let i=this.estimateCost(e.left);return this.estimateCost(e.right)<i?{type:"join",left:this.joinReordering(e.right),right:this.joinReordering(e.left)}:{type:"join",left:this.joinReordering(e.left),right:this.joinReordering(e.right)}}isConstrained(e){return e.type==="values"?!0:e.type==="bgp"?e.triples.some(t=>t.object.type!=="variable"||t.subject.type!=="variable"):e.type==="filter"?this.isConstrained(e.input):e.type==="join"?this.isConstrained(e.left)||this.isConstrained(e.right):e.type==="union"?this.isConstrained(e.left)&&this.isConstrained(e.right):!1}estimateCost(e){if(e.type==="bgp"){let t=0;for(let r of e.triples){let i=10;r.subject.type==="variable"&&(i*=10),r.predicate.type==="variable"&&(i*=20),r.object.type==="variable"&&(i*=5),t+=i}return t}if(e.type==="filter")return this.estimateCost(e.input)*.3;if(e.type==="join"){let t=this.estimateCost(e.left),r=this.estimateCost(e.right);return e.left.type==="values"||e.right.type==="values"?Math.min(t,r)*2:t*r}if(e.type==="leftjoin")return this.estimateCost(e.left)+this.estimateCost(e.right)*.5;if(e.type==="union")return this.estimateCost(e.left)+this.estimateCost(e.right);if(e.type==="values"){let t=e.bindings;return Array.isArray(t)?t.length*5:10}return e.type==="minus"?this.estimateCost(e.left)+this.estimateCost(e.right)*.3:100}setStatistics(e,t){this.stats.set(e,t)}getStatistics(e){return this.stats.get(e)}};Zm.AlgebraOptimizer=bv});var u3=S(eg=>{"use strict";Object.defineProperty(eg,"__esModule",{value:!0});eg.AlgebraSerializer=void 0;var Sv=class{static{a(this,"AlgebraSerializer")}toString(e,t=0){let r=" ".repeat(t);switch(e.type){case"bgp":return`${r}BGP [
376
376
  ${e.triples.map(u=>`${r} ${this.tripleToString(u)}`).join(`
377
377
  `)}
378
378
  ${r}]`;case"filter":return`${r}Filter(
@@ -828,7 +828,7 @@ Next steps:
828
828
  `),process.stdout.write(` File: ${e.file}
829
829
  `),process.stdout.write(` Commit: ${e.sha}
830
830
  `),process.stdout.write(` URL: ${e.url}
831
- `)),process.exit(0)}catch(e){let t=e instanceof Error?e:new Error(String(e)),r=new Mu;t.message=r.redact(t.message),t.stack&&(t.stack=r.redact(t.stack)),re.handle(t)}})}a(Tne,"restPushCommand");function j4(n){let e=new oe;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"16.80.1"),e.addCommand(i4()),e.addCommand(p4()),e.addCommand(LN()),e.addCommand(MN()),e.addCommand(dk()),e.addCommand(BN()),e.addCommand(VN()),e.addCommand(HN()),e.addCommand(mk()),e.addCommand(vk()),e.addCommand(Ak()),e.addCommand(Ik()),e.addCommand(Rk()),e.addCommand($k()),e.addCommand(Uk()),e.addCommand(Hk()),e.addCommand(n4()),e.addCommand(v4()),e.addCommand(C4()),e.addCommand(P4()),e.addCommand(F4()),e.addCommand(M4()),e}a(j4,"createProgram");j4().parse();0&&(module.exports={createProgram});
831
+ `)),process.exit(0)}catch(e){let t=e instanceof Error?e:new Error(String(e)),r=new Mu;t.message=r.redact(t.message),t.stack&&(t.stack=r.redact(t.stack)),re.handle(t)}})}a(Tne,"restPushCommand");function j4(n){let e=new oe;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"16.80.3"),e.addCommand(i4()),e.addCommand(p4()),e.addCommand(LN()),e.addCommand(MN()),e.addCommand(dk()),e.addCommand(BN()),e.addCommand(VN()),e.addCommand(HN()),e.addCommand(mk()),e.addCommand(vk()),e.addCommand(Ak()),e.addCommand(Ik()),e.addCommand(Rk()),e.addCommand($k()),e.addCommand(Uk()),e.addCommand(Hk()),e.addCommand(n4()),e.addCommand(v4()),e.addCommand(C4()),e.addCommand(P4()),e.addCommand(F4()),e.addCommand(M4()),e}a(j4,"createProgram");j4().parse();0&&(module.exports={createProgram});
832
832
  /*! Bundled license information:
833
833
 
834
834
  reflect-metadata/Reflect.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitelev/exocortex-cli",
3
- "version": "16.80.1",
3
+ "version": "16.80.3",
4
4
  "description": "CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more",
5
5
  "main": "dist/index.js",
6
6
  "bin": {