@kitelev/exocortex-cli 15.55.19 → 15.55.20

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 (2) hide show
  1. package/dist/index.js +3 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // @kitelev/exocortex-cli v15.55.19
2
+ // @kitelev/exocortex-cli v15.55.20
3
3
  // CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more
4
4
  // License: MIT
5
5
 
@@ -298,7 +298,7 @@ LIMIT ${this.config.defaultLimit}`,s="\u041D\u0435 \u0443\u0434\u0430\u043B\u043
298
298
  `,i=this.composePrefixes(t),s=this.serializePrefixes(i,r),a=this.nTriplesSerializer.serialize(e,{newline:r}).trimEnd();return s?a?`${s}${r}${r}${a}${r}`:`${s}${r}`:a?`${a}${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?{...g6,...e.prefixes??{}}:{...e.prefixes??{}}}serializeTriplesOnly(e,t){return this.nTriplesSerializer.serializeChunk(e,t).trimEnd()}};tp.TurtleSerializer=n2});var O3=v(rp=>{"use strict";Object.defineProperty(rp,"__esModule",{value:!0});rp.JSONLDSerializer=void 0;var C3=Fe(),P3=jt(),y6=Xe(),Pc=pn(),_6={rdf:Pc.Namespace.RDF.iri.value,rdfs:Pc.Namespace.RDFS.iri.value,owl:Pc.Namespace.OWL.iri.value,xsd:Pc.Namespace.XSD.iri.value,exo:Pc.Namespace.EXO.iri.value,ems:Pc.Namespace.EMS.iri.value},i2=class{static{o(this,"JSONLDSerializer")}toDocument(e,t={}){let r={..._6,...t.context??{}},i=new Map;for(let s of e){let a=this.subjectToId(s.subject),c=this.compactIri(s.predicate.value,r),l=this.objectToJSONLD(s.object,r),u=i.get(a)??{"@id":a},f=u[c];f===void 0?u[c]=l:Array.isArray(f)?f.push(l):u[c]=[f,l],i.set(a,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 C3.IRI?e.value:e instanceof P3.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 C3.IRI)return{"@id":e.value};if(e instanceof P3.BlankNode)return{"@id":`_:${e.id}`};if(e instanceof y6.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}};rp.JSONLDSerializer=i2});var o2=v(np=>{"use strict";Object.defineProperty(np,"__esModule",{value:!0});np.NTriplesParser=void 0;var v6=Ui(),R3=Fe(),s2=Xe(),b6=jt(),Oc=pn(),S6={rdf:Oc.Namespace.RDF.iri.value,rdfs:Oc.Namespace.RDFS.iri.value,owl:Oc.Namespace.OWL.iri.value,xsd:Oc.Namespace.XSD.iri.value,exo:Oc.Namespace.EXO.iri.value,ems:Oc.Namespace.EMS.iri.value},a2=class{static{o(this,"NTriplesParser")}parse(e,t={}){let r={prefixes:{...S6,...t.prefixes??{}},strict:t.strict??!1},i=[];return e.split(/\r?\n/).forEach((a,c)=>{let l=a.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(),a=this.parseSubject(s,t,r);s=a.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 v6.Triple(a.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,a,c]=i,l=r.prefixes[s];if(!l)throw new Error(`Unknown prefix "${s}" at line ${t}`);return{node:new R3.IRI(`${l}${a}`),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),a=new R3.IRI(s),c=e.slice(i+1).trimStart();return{node:a,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 b6.BlankNode(i),rest:(s??"").trimStart()}}consumeLiteral(e,t,r){let{value:i,rest:s}=this.consumeQuotedString(e,t),a=s.trimStart();if(a.startsWith("^^")){a=a.slice(2).trimStart();let c=a.startsWith("<")?this.consumeIRI(a,t,r):this.consumePrefixedName(a,t,r);return{node:new s2.Literal(i,c.node),rest:c.rest}}if(a.startsWith("@")){let c=a.match(/^@([a-zA-Z-]+)(?:\s+(.*))?$/);if(!c)throw new Error(`Invalid language tag at line ${t}`);let[,l,u]=c;return{node:new s2.Literal(i,void 0,l),rest:(u??"").trimStart()}}return{node:new s2.Literal(i),rest:a}}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 a=e[i+1];switch(a){case"t":r+=" ",i+=1;break;case"b":r+="\b",i+=1;break;case"n":r+=`
299
299
  `,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 \\${a} at line ${t}`)}continue}if(s==='"'){let a=e.slice(i+1);return{value:r,rest:a}}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 a=e[s];if(a===t){i++;continue}if(a===r&&(i--,i===0))return s}return-1}};np.NTriplesParser=a2});var I3=v(ip=>{"use strict";Object.defineProperty(ip,"__esModule",{value:!0});ip.TurtleParser=void 0;var Rc=pn(),w6=o2(),E6={rdf:Rc.Namespace.RDF.iri.value,rdfs:Rc.Namespace.RDFS.iri.value,owl:Rc.Namespace.OWL.iri.value,xsd:Rc.Namespace.XSD.iri.value,exo:Rc.Namespace.EXO.iri.value,ems:Rc.Namespace.EMS.iri.value},T6=/^@prefix\s+([a-zA-Z_][\w-]*):\s*<([^>]+)>\s*\.$/,c2=class{static{o(this,"TurtleParser")}constructor(){this.nTriplesParser=new w6.NTriplesParser}parse(e,t={}){let r={...E6,...t.prefixes??{}},i=this.collectStatements(e),s=[];return i.forEach(({statement:a,lineNumber:c})=>{if(this.isPrefixStatement(a)){let u=a.match(T6);if(!u)throw new Error(`Invalid prefix declaration at line ${c}`);let[,f,d]=u;r[f]=d;return}if(a.includes(";")||a.includes(","))throw new Error(`Complex Turtle statements with ';' or ',' are not supported (line ${c})`);let l=this.normalizeShortcuts(a);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((a,c)=>{let l=a.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}};ip.TurtleParser=c2});var D3=v(sp=>{"use strict";Object.defineProperty(sp,"__esModule",{value:!0});sp.RDFSerializer=void 0;var Ic=Ui(),uo=Fe(),fo=Xe(),l2=jt(),Xi=pn(),A6=x3(),x6=r2(),C6=O3(),P6=I3(),O6=o2(),R6=1024,I6=`
300
300
  `,D6={rdf:Xi.Namespace.RDF.iri.value,rdfs:Xi.Namespace.RDFS.iri.value,owl:Xi.Namespace.OWL.iri.value,xsd:Xi.Namespace.XSD.iri.value,exo:Xi.Namespace.EXO.iri.value,ems:Xi.Namespace.EMS.iri.value},u2=class{static{o(this,"RDFSerializer")}constructor(e){this.store=e,this.turtleSerializer=new A6.TurtleSerializer,this.nTriplesSerializer=new x6.NTriplesSerializer,this.jsonldSerializer=new C6.JSONLDSerializer,this.turtleParser=new P6.TurtleParser,this.nTriplesParser=new O6.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??I6,i=t.batchSize??R6,s=t.includeDefaultPrefixes,a=t.prefixes,c=this,l=!1,u=[],f=[],d=0,h=o(async()=>{if(!l){if(f=await c.store.match(),e==="json-ld"){let _=c.jsonldSerializer.toDocument(f,{context:a,pretty:!1});u.push(...c.buildJsonLdChunks(_))}else if(e==="turtle"){let _=c.turtleSerializer.serializePrefixes(c.composePrefixes(a,s),r);_&&u.push(`${_}${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 _=f.slice(d,d+i);d+=_.length;let b="";if(e==="turtle"){let E=c.turtleSerializer.serializeTriplesOnly(_,r);E&&(b=`${E}${r}`)}else e==="n-triples"&&(b=c.nTriplesSerializer.serializeChunk(_,r));return b?{value:b,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?{...D6,...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),a={...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,a,f),h=Object.entries(u);for(let[p,_]of h){if(p==="@id"||p==="@context")continue;if(p==="@type"){this.collectTypeTriples(d,_,l,a);continue}let b=this.expandTerm(p,a),E=new uo.IRI(b);this.collectTriplesForValue(d,E,_,l,a)}}),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 l2.BlankNode(i.slice(2));if(this.isAbsoluteIri(i))return new uo.IRI(i);let s=this.expandTerm(i,t);return new uo.IRI(s)}return new l2.BlankNode(`jsonld_${r}`)}collectTypeTriples(e,t,r,i){let s=Xi.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 Ic.Triple(e,s,new uo.IRI(l)))})}collectTriplesForValue(e,t,r,i,s){if(r!=null){if(Array.isArray(r)){r.forEach(a=>this.collectTriplesForValue(e,t,a,i,s));return}if(typeof r=="object"){let a=r;if(typeof a["@id"]=="string"){let c=this.parseIdNode(a["@id"],s);i.push(new Ic.Triple(e,t,c));return}if(a["@value"]!==void 0){let c=this.parseLiteralObject(a,s);i.push(new Ic.Triple(e,t,c));return}}if(typeof r=="string"){i.push(new Ic.Triple(e,t,new fo.Literal(r)));return}if(typeof r=="number"){let a=Number.isInteger(r)?Xi.Namespace.XSD.term("integer"):Xi.Namespace.XSD.term("decimal");i.push(new Ic.Triple(e,t,new fo.Literal(r.toString(),a)));return}if(typeof r=="boolean"){let a=Xi.Namespace.XSD.term("boolean");i.push(new Ic.Triple(e,t,new fo.Literal(r.toString(),a)));return}throw new Error("Unsupported JSON-LD value encountered")}}parseIdNode(e,t){if(e.startsWith("_:"))return new l2.BlankNode(e.slice(2));if(this.isAbsoluteIri(e))return new uo.IRI(e);let r=this.expandTerm(e,t);return new uo.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 fo.Literal(r,void 0,e["@language"],i):new fo.Literal(r,void 0,e["@language"])}if(typeof e["@type"]=="string"){let i=this.expandTerm(e["@type"],t);return new fo.Literal(r,new uo.IRI(i))}return new fo.Literal(r)}expandTerm(e,t){if(this.isAbsoluteIri(e))return e;let r=e.indexOf(":");if(r>0){let s=e.slice(0,r),a=e.slice(r+1),c=t[s];if(!c)throw new Error(`Unknown prefix "${s}" in JSON-LD document`);return`${c}${a}`}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 a=JSON.stringify(i);s>0?t.push(`,${a}`):t.push(a)}),t.push(`]}
301
- `),t}};sp.RDFSerializer=u2});var d2=v(ap=>{"use strict";Object.defineProperty(ap,"__esModule",{value:!0});ap.RDFVocabularyMapper=void 0;var Ht=Ui(),F3=Fe(),z=pn(),f2=class{static{o(this,"RDFVocabularyMapper")}constructor(){this.propertyMappings=new Map([["exo__Instance_class",z.Namespace.RDF.term("type")],["exo__Asset_isDefinedBy",z.Namespace.RDFS.term("isDefinedBy")],["exo__Class_superClass",z.Namespace.RDFS.term("subClassOf")],["exo__Property_range",z.Namespace.RDFS.term("range")],["exo__Property_domain",z.Namespace.RDFS.term("domain")],["exo__Property_superProperty",z.Namespace.RDFS.term("subPropertyOf")]])}generateClassHierarchyTriples(){let e=[];return e.push(new Ht.Triple(z.Namespace.EXO.term("Asset"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.RDFS.term("Resource"))),e.push(new Ht.Triple(z.Namespace.EXO.term("Class"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.RDFS.term("Class"))),e.push(new Ht.Triple(z.Namespace.EXO.term("Property"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.RDF.term("Property"))),e.push(new Ht.Triple(z.Namespace.EMS.term("Task"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.EXO.term("Asset"))),e.push(new Ht.Triple(z.Namespace.EMS.term("Project"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.EXO.term("Asset"))),e.push(new Ht.Triple(z.Namespace.EMS.term("Area"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.EXO.term("Asset"))),e.push(new Ht.Triple(z.Namespace.EMS.term("Workflow"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.EXO.term("Asset"))),e.push(new Ht.Triple(z.Namespace.EMS.term("WorkflowState"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.EXO.term("Asset"))),e.push(new Ht.Triple(z.Namespace.EMS.term("WorkflowTransition"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.EXO.term("Asset"))),e.push(new Ht.Triple(z.Namespace.EXOCMD.term("Command"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.EXO.term("Asset"))),e.push(new Ht.Triple(z.Namespace.EXOCMD.term("Precondition"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.EXO.term("Asset"))),e.push(new Ht.Triple(z.Namespace.EXOCMD.term("Grounding"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.EXO.term("Asset"))),e.push(new Ht.Triple(z.Namespace.EXOCMD.term("CommandBinding"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.EXO.term("Asset"))),e}generatePropertyHierarchyTriples(){let e=[];return e.push(new Ht.Triple(z.Namespace.EXO.term("Instance_class"),z.Namespace.RDFS.term("subPropertyOf"),z.Namespace.RDF.term("type"))),e.push(new Ht.Triple(z.Namespace.EXO.term("Asset_isDefinedBy"),z.Namespace.RDFS.term("subPropertyOf"),z.Namespace.RDFS.term("isDefinedBy"))),e.push(new Ht.Triple(z.Namespace.EXO.term("Class_superClass"),z.Namespace.RDFS.term("subPropertyOf"),z.Namespace.RDFS.term("subClassOf"))),e.push(new Ht.Triple(z.Namespace.EXO.term("Property_range"),z.Namespace.RDFS.term("subPropertyOf"),z.Namespace.RDFS.term("range"))),e.push(new Ht.Triple(z.Namespace.EXO.term("Property_domain"),z.Namespace.RDFS.term("subPropertyOf"),z.Namespace.RDFS.term("domain"))),e.push(new Ht.Triple(z.Namespace.EXO.term("Property_superProperty"),z.Namespace.RDFS.term("subPropertyOf"),z.Namespace.RDFS.term("subPropertyOf"))),e}generateMappedTriple(e,t,r){let i=this.propertyMappings.get(t);if(!i)return null;let s;if(r instanceof F3.IRI)s=r;else{let a=r.match(/^(ems|exo|exocmd)__(.+)$/);if(a){let[,c,l]=a;s=(c==="ems"?z.Namespace.EMS:c==="exocmd"?z.Namespace.EXOCMD:z.Namespace.EXO).term(l)}else s=new F3.IRI(r)}return new Ht.Triple(e,i,s)}hasMappingFor(e){return this.propertyMappings.has(e)}};ap.RDFVocabularyMapper=f2});var N3=v(cp=>{"use strict";Object.defineProperty(cp,"__esModule",{value:!0});cp.RDFSInferenceEngine=void 0;var F6=Ui(),op=Fe(),h2=class{static{o(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 a=this.computeAllAncestors(s),c=await e.count(),l=await e.match(void 0,i),u=[];for(let d of l)if(d.object instanceof op.IRI){let h=a.get(d.object.value);if(h)for(let p of h)u.push(new F6.Triple(d.subject,i,new op.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 op.IRI&&s.object instanceof op.IRI){let a=s.subject.value,c=s.object.value;i.has(a)||i.set(a,new Set),i.get(a).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=[],a=t.get(e);if(a)for(let c of a)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}};cp.RDFSInferenceEngine=h2});var m2=v(Si=>{"use strict";var N6=Si&&Si.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;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--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},k6=Si&&Si.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},k3=Si&&Si.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Si,"__esModule",{value:!0});Si.NoteToRDFConverter=void 0;var p2=we(),yn=Ui(),Dc=Fe(),Pn=Xe(),L3=jt(),sn=pn(),M3=yt(),L6=d2(),M6=fu(),_n=xy(),Fc=class{static{o(this,"NoteToRDFConverter")}constructor(e,t=M6.NullLogger){this.vault=e,this.logger=t,this.OBSIDIAN_VAULT_SCHEME="obsidian://vault/",this.BODY_WIKILINK_PATTERN=/(?<!!)\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g,this.vocabularyMapper=new L6.RDFVocabularyMapper}async convertNote(e){let t=this.vault.getFrontmatter(e);return t?_n.Exo003Parser.isExo003Format(t)?this.convertExo003Note(e,t):this.convertLegacyNote(e,t):[]}async convertLegacyNote(e,t){let r=[],i=this.notePathToIRI(e.path),s=sn.Namespace.EXO.term("Asset_fileName");r.push(new yn.Triple(i,s,new Pn.Literal(e.basename)));for(let[c,l]of Object.entries(t)){if(!this.isExocortexProperty(c))continue;let u=this.propertyKeyToIRI(c),f=Array.isArray(l)?l:[l];for(let d of f)if(c==="exo__Instance_class"){let h=this.valueToClassURI(d);r.push(new yn.Triple(i,u,h))}else{let h=await this.valueToRDFObject(d,e);for(let p of h)if(r.push(new yn.Triple(i,u,p)),this.vocabularyMapper.hasMappingFor(c)&&p instanceof Dc.IRI){let _=this.vocabularyMapper.generateMappedTriple(i,c,p);_&&r.push(_)}}if(c==="exo__Instance_class")for(let d of f){let h=this.expandClassValue(d);if(h){let p=sn.Namespace.RDF.term("type");r.push(new yn.Triple(i,p,h))}}}let a=await this.convertBodyWikilinks(e,i);return r.push(...a),r}async convertExo003Note(e,t){let r=_n.Exo003Parser.parse(t);if(!r.success||!r.metadata)return[];let i=r.metadata,s=[];switch(i.metadata){case _n.Exo003MetadataType.Namespace:break;case _n.Exo003MetadataType.Anchor:s.push(...this.convertExo003Anchor(e,i));break;case _n.Exo003MetadataType.BlankNode:s.push(...this.convertExo003BlankNode(e,i));break;case _n.Exo003MetadataType.Statement:s.push(...this.convertExo003Statement(e,i));break;case _n.Exo003MetadataType.Body:s.push(...await this.convertExo003Body(e,i));break}return s}convertExo003Anchor(e,t){let r=this.notePathToIRI(e.path),i=new Dc.IRI(t.uri);return[new yn.Triple(r,sn.Namespace.OWL.term("sameAs"),i),new yn.Triple(i,sn.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 yn.Triple(r,sn.Namespace.OWL.term("sameAs"),new L3.BlankNode(i))]}convertExo003Statement(e,t){let r=[];try{let i=this.createExo003ReferenceResolver(e),s=_n.Exo003Parser.toTriple(t,i);r.push(s);let a=this.notePathToIRI(e.path);r.push(new yn.Triple(a,sn.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),a=this.createExo003ReferenceResolver(e),c=a(t.subject),l=a(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 Dc.IRI(c.value):new L3.BlankNode(c.value),f=new Dc.IRI(l.value),d=_n.Exo003Parser.toLiteral(t,s.trim());r.push(new yn.Triple(u,f,d));let h=this.notePathToIRI(e.path);r.push(new yn.Triple(h,sn.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 a=this.vault.getFrontmatter(s);if(a&&_n.Exo003Parser.isExo003Format(a)){let c=_n.Exo003Parser.parse(a);if(c.success&&c.metadata){let l=c.metadata;if(l.metadata===_n.Exo003MetadataType.Anchor||l.metadata===_n.Exo003MetadataType.Namespace)return{type:"iri",value:l.uri};if(l.metadata===_n.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(){return(await this.convertVaultWithValidation({strict:!1})).triples}async convertVaultWithValidation(e={}){let t=this.vault.getAllFiles(),r=[],i=[],s=e.strict??!1;for(let a of t)try{let c=await this.convertNote(a);r.push(...c)}catch(c){let l=c instanceof Error?c.message:String(c);if(s)throw new Error(`Invalid IRI for file "${a.path}": ${l}`);i.push({path:a.path,reason:`Invalid IRI: ${l}`}),this.logger.warn(`Skipping file with invalid IRI: ${a.path}`,{reason:l})}return{triples:r,skippedFiles:i,summary:{total:t.length,indexed:t.length-i.length,skipped:i.length}}}async validateVault(){let e=this.vault.getAllFiles(),t=[];for(let r of e){let i=encodeURI(r.path),s=`${this.OBSIDIAN_VAULT_SCHEME}${i}`;Dc.IRI.isValidIRI(s)||t.push({path:r.path,reason:`Path "${r.path}" cannot be converted to a valid IRI`})}return t}notePathToIRI(e){let t=encodeURI(e);return new Dc.IRI(`${this.OBSIDIAN_VAULT_SCHEME}${t}`)}isExocortexProperty(e){return e.startsWith("exo__")||e.startsWith("ems__")}propertyKeyToIRI(e){if(e.startsWith("exo__")){let t=e.substring(5);return sn.Namespace.EXO.term(t)}if(e.startsWith("ems__")){let t=e.substring(5);return sn.Namespace.EMS.term(t)}throw new Error(`Invalid property key: ${e}`)}async valueToRDFObject(e,t){if(typeof e=="string"){let r=this.removeQuotes(e),i=this.extractWikilink(r);if(i){let s=this.vault.getFirstLinkpathDest(i,t.path);if(s){let a=this.notePathToIRI(s.path);if(this.isUUID(i)){let c=new Pn.Literal(i);return[a,c]}return[a]}if(this.isClassReference(i)){let a=this.expandClassValue(i);if(a)return[a]}return[new Pn.Literal(r)]}if(this.isClassReference(r)){let s=this.expandClassValue(r);if(s)return[s]}return this.isISO8601DateTime(r)?[new Pn.Literal(r,sn.Namespace.XSD.term("dateTime"))]:[new Pn.Literal(r)]}return typeof e=="boolean"?[new Pn.Literal(e.toString())]:typeof e=="number"?[new Pn.Literal(e.toString(),sn.Namespace.XSD.term("decimal"))]:e instanceof Date?[new Pn.Literal(e.toISOString(),sn.Namespace.XSD.term("dateTime"))]:[new Pn.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(/^\[\[([^\]]+)\]\]$/);return t?t[1]:null}valueToClassURI(e){if(typeof e!="string")return new Pn.Literal(String(e));let t=this.removeQuotes(e),i=this.extractWikilink(t)||t,s=this.expandClassValue(i);return s||new Pn.Literal(t)}isClassReference(e){return(e.startsWith("ems__")||e.startsWith("exo__"))&&!/\s/.test(e)}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);if(t.startsWith("ems__")){let r=t.substring(5);return sn.Namespace.EMS.term(r)}if(t.startsWith("exo__")){let r=t.substring(5);return sn.Namespace.EXO.term(r)}return null}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),a=this.extractBodyWikilinks(s),c=sn.Namespace.EXO.term("Asset_bodyLink");for(let l of a){let u=this.vault.getFirstLinkpathDest(l,e.path);if(u){let f=this.notePathToIRI(u.path);r.push(new yn.Triple(t,c,f))}else if(this.isClassReference(l)){let f=this.expandClassValue(l);f?r.push(new yn.Triple(t,c,f)):r.push(new yn.Triple(t,c,new Pn.Literal(l)))}else r.push(new yn.Triple(t,c,new Pn.Literal(l)))}}catch{}return r}};Si.NoteToRDFConverter=Fc;Fc.SkippedFileInfo=class{constructor(n,e){this.path=n,this.reason=e}};Fc.VaultValidationResult=class{constructor(n,e,t){this.triples=n,this.skippedFiles=e,this.summary=t}};Fc.VaultValidationOptions=class{constructor(n=!1){this.strict=n}};Si.NoteToRDFConverter=Fc=N6([(0,p2.injectable)(),k3(0,(0,p2.inject)(M3.DI_TOKENS.IVaultAdapter)),k3(1,(0,p2.inject)(M3.DI_TOKENS.ILogger)),k6("design:paramtypes",[Object,Object])],Fc)});var y2=v(lp=>{"use strict";Object.defineProperty(lp,"__esModule",{value:!0});lp.FilterContainsOptimizer=void 0;var j6=Fe(),$6=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i,g2=class{static{o(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($6);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 j6.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(a=>a.subject.type==="variable"&&a.subject.value===t?{...a,subject:{type:"iri",value:r}}:a);if(i.some((a,c)=>a.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(a=>({[t.variable]:{type:"iri",value:a}}))},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)}};lp.FilterContainsOptimizer=g2});var j3=v(up=>{"use strict";Object.defineProperty(up,"__esModule",{value:!0});up.AlgebraOptimizer=void 0;var V6=y2(),_2=class{static{o(this,"AlgebraOptimizer")}constructor(){this.stats=new Map,this.tripleStore=null,this.filterContainsOptimizer=new V6.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),a=r.every(l=>i.has(l)),c=r.every(l=>s.has(l));return a&&!c?{type:"join",left:{type:"filter",expression:e.expression,input:this.filterPushDown(t.left)},right:this.filterPushDown(t.right)}:c&&!a?{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)}};up.AlgebraOptimizer=_2});var $3=v(fp=>{"use strict";Object.defineProperty(fp,"__esModule",{value:!0});fp.AlgebraSerializer=void 0;var v2=class{static{o(this,"AlgebraSerializer")}toString(e,t=0){let r=" ".repeat(t);switch(e.type){case"bgp":return`${r}BGP [
301
+ `),t}};sp.RDFSerializer=u2});var d2=v(ap=>{"use strict";Object.defineProperty(ap,"__esModule",{value:!0});ap.RDFVocabularyMapper=void 0;var Ht=Ui(),F3=Fe(),z=pn(),f2=class{static{o(this,"RDFVocabularyMapper")}constructor(){this.propertyMappings=new Map([["exo__Instance_class",z.Namespace.RDF.term("type")],["exo__Asset_isDefinedBy",z.Namespace.RDFS.term("isDefinedBy")],["exo__Class_superClass",z.Namespace.RDFS.term("subClassOf")],["exo__Property_range",z.Namespace.RDFS.term("range")],["exo__Property_domain",z.Namespace.RDFS.term("domain")],["exo__Property_superProperty",z.Namespace.RDFS.term("subPropertyOf")]])}generateClassHierarchyTriples(){let e=[];return e.push(new Ht.Triple(z.Namespace.EXO.term("Asset"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.RDFS.term("Resource"))),e.push(new Ht.Triple(z.Namespace.EXO.term("Class"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.RDFS.term("Class"))),e.push(new Ht.Triple(z.Namespace.EXO.term("Property"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.RDF.term("Property"))),e.push(new Ht.Triple(z.Namespace.EMS.term("Task"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.EXO.term("Asset"))),e.push(new Ht.Triple(z.Namespace.EMS.term("Project"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.EXO.term("Asset"))),e.push(new Ht.Triple(z.Namespace.EMS.term("Area"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.EXO.term("Asset"))),e.push(new Ht.Triple(z.Namespace.EMS.term("Workflow"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.EXO.term("Asset"))),e.push(new Ht.Triple(z.Namespace.EMS.term("WorkflowState"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.EXO.term("Asset"))),e.push(new Ht.Triple(z.Namespace.EMS.term("WorkflowTransition"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.EXO.term("Asset"))),e.push(new Ht.Triple(z.Namespace.EXOCMD.term("Command"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.EXO.term("Asset"))),e.push(new Ht.Triple(z.Namespace.EXOCMD.term("Precondition"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.EXO.term("Asset"))),e.push(new Ht.Triple(z.Namespace.EXOCMD.term("Grounding"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.EXO.term("Asset"))),e.push(new Ht.Triple(z.Namespace.EXOCMD.term("CommandBinding"),z.Namespace.RDFS.term("subClassOf"),z.Namespace.EXO.term("Asset"))),e}generatePropertyHierarchyTriples(){let e=[];return e.push(new Ht.Triple(z.Namespace.EXO.term("Instance_class"),z.Namespace.RDFS.term("subPropertyOf"),z.Namespace.RDF.term("type"))),e.push(new Ht.Triple(z.Namespace.EXO.term("Asset_isDefinedBy"),z.Namespace.RDFS.term("subPropertyOf"),z.Namespace.RDFS.term("isDefinedBy"))),e.push(new Ht.Triple(z.Namespace.EXO.term("Class_superClass"),z.Namespace.RDFS.term("subPropertyOf"),z.Namespace.RDFS.term("subClassOf"))),e.push(new Ht.Triple(z.Namespace.EXO.term("Property_range"),z.Namespace.RDFS.term("subPropertyOf"),z.Namespace.RDFS.term("range"))),e.push(new Ht.Triple(z.Namespace.EXO.term("Property_domain"),z.Namespace.RDFS.term("subPropertyOf"),z.Namespace.RDFS.term("domain"))),e.push(new Ht.Triple(z.Namespace.EXO.term("Property_superProperty"),z.Namespace.RDFS.term("subPropertyOf"),z.Namespace.RDFS.term("subPropertyOf"))),e}generateMappedTriple(e,t,r){let i=this.propertyMappings.get(t);if(!i)return null;let s;if(r instanceof F3.IRI)s=r;else{let a=r.match(/^(ems|exo|exocmd)__(.+)$/);if(a){let[,c,l]=a;s=(c==="ems"?z.Namespace.EMS:c==="exocmd"?z.Namespace.EXOCMD:z.Namespace.EXO).term(l)}else s=new F3.IRI(r)}return new Ht.Triple(e,i,s)}hasMappingFor(e){return this.propertyMappings.has(e)}};ap.RDFVocabularyMapper=f2});var N3=v(cp=>{"use strict";Object.defineProperty(cp,"__esModule",{value:!0});cp.RDFSInferenceEngine=void 0;var F6=Ui(),op=Fe(),h2=class{static{o(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 a=this.computeAllAncestors(s),c=await e.count(),l=await e.match(void 0,i),u=[];for(let d of l)if(d.object instanceof op.IRI){let h=a.get(d.object.value);if(h)for(let p of h)u.push(new F6.Triple(d.subject,i,new op.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 op.IRI&&s.object instanceof op.IRI){let a=s.subject.value,c=s.object.value;i.has(a)||i.set(a,new Set),i.get(a).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=[],a=t.get(e);if(a)for(let c of a)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}};cp.RDFSInferenceEngine=h2});var m2=v(Si=>{"use strict";var N6=Si&&Si.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;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--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},k6=Si&&Si.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},k3=Si&&Si.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Si,"__esModule",{value:!0});Si.NoteToRDFConverter=void 0;var p2=we(),yn=Ui(),Dc=Fe(),Pn=Xe(),L3=jt(),sn=pn(),M3=yt(),L6=d2(),M6=fu(),_n=xy(),Fc=class{static{o(this,"NoteToRDFConverter")}constructor(e,t=M6.NullLogger){this.vault=e,this.logger=t,this.OBSIDIAN_VAULT_SCHEME="obsidian://vault/",this.BODY_WIKILINK_PATTERN=/(?<!!)\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g,this.vocabularyMapper=new L6.RDFVocabularyMapper}async convertNote(e){let t=this.vault.getFrontmatter(e);return t?_n.Exo003Parser.isExo003Format(t)?this.convertExo003Note(e,t):this.convertLegacyNote(e,t):[]}async convertLegacyNote(e,t){let r=[],i=this.notePathToIRI(e.path),s=sn.Namespace.EXO.term("Asset_fileName");r.push(new yn.Triple(i,s,new Pn.Literal(e.basename)));for(let[c,l]of Object.entries(t)){if(!this.isExocortexProperty(c))continue;let u=this.propertyKeyToIRI(c),f=Array.isArray(l)?l:[l];for(let d of f)if(c==="exo__Instance_class"){let h=this.valueToClassURI(d);r.push(new yn.Triple(i,u,h))}else{let h=await this.valueToRDFObject(d,e);for(let p of h)if(r.push(new yn.Triple(i,u,p)),this.vocabularyMapper.hasMappingFor(c)&&p instanceof Dc.IRI){let _=this.vocabularyMapper.generateMappedTriple(i,c,p);_&&r.push(_)}}if(c==="exo__Instance_class")for(let d of f){let h=this.expandClassValue(d);if(h){let p=sn.Namespace.RDF.term("type");r.push(new yn.Triple(i,p,h))}}}let a=await this.convertBodyWikilinks(e,i);return r.push(...a),r}async convertExo003Note(e,t){let r=_n.Exo003Parser.parse(t);if(!r.success||!r.metadata)return[];let i=r.metadata,s=[];switch(i.metadata){case _n.Exo003MetadataType.Namespace:break;case _n.Exo003MetadataType.Anchor:s.push(...this.convertExo003Anchor(e,i));break;case _n.Exo003MetadataType.BlankNode:s.push(...this.convertExo003BlankNode(e,i));break;case _n.Exo003MetadataType.Statement:s.push(...this.convertExo003Statement(e,i));break;case _n.Exo003MetadataType.Body:s.push(...await this.convertExo003Body(e,i));break}return s}convertExo003Anchor(e,t){let r=this.notePathToIRI(e.path),i=new Dc.IRI(t.uri);return[new yn.Triple(r,sn.Namespace.OWL.term("sameAs"),i),new yn.Triple(i,sn.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 yn.Triple(r,sn.Namespace.OWL.term("sameAs"),new L3.BlankNode(i))]}convertExo003Statement(e,t){let r=[];try{let i=this.createExo003ReferenceResolver(e),s=_n.Exo003Parser.toTriple(t,i);r.push(s);let a=this.notePathToIRI(e.path);r.push(new yn.Triple(a,sn.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),a=this.createExo003ReferenceResolver(e),c=a(t.subject),l=a(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 Dc.IRI(c.value):new L3.BlankNode(c.value),f=new Dc.IRI(l.value),d=_n.Exo003Parser.toLiteral(t,s.trim());r.push(new yn.Triple(u,f,d));let h=this.notePathToIRI(e.path);r.push(new yn.Triple(h,sn.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 a=this.vault.getFrontmatter(s);if(a&&_n.Exo003Parser.isExo003Format(a)){let c=_n.Exo003Parser.parse(a);if(c.success&&c.metadata){let l=c.metadata;if(l.metadata===_n.Exo003MetadataType.Anchor||l.metadata===_n.Exo003MetadataType.Namespace)return{type:"iri",value:l.uri};if(l.metadata===_n.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(){return(await this.convertVaultWithValidation({strict:!1})).triples}async convertVaultWithValidation(e={}){let t=this.vault.getAllFiles(),r=[],i=[],s=e.strict??!1;for(let a of t)try{let c=await this.convertNote(a);r.push(...c)}catch(c){let l=c instanceof Error?c.message:String(c);if(s)throw new Error(`Invalid IRI for file "${a.path}": ${l}`);i.push({path:a.path,reason:`Invalid IRI: ${l}`}),this.logger.warn(`Skipping file with invalid IRI: ${a.path}`,{reason:l})}return{triples:r,skippedFiles:i,summary:{total:t.length,indexed:t.length-i.length,skipped:i.length}}}async validateVault(){let e=this.vault.getAllFiles(),t=[];for(let r of e){let i=encodeURI(r.path),s=`${this.OBSIDIAN_VAULT_SCHEME}${i}`;Dc.IRI.isValidIRI(s)||t.push({path:r.path,reason:`Path "${r.path}" cannot be converted to a valid IRI`})}return t}notePathToIRI(e){let t=encodeURI(e);return new Dc.IRI(`${this.OBSIDIAN_VAULT_SCHEME}${t}`)}isExocortexProperty(e){return e.startsWith("exo__")||e.startsWith("ems__")}propertyKeyToIRI(e){if(e.startsWith("exo__")){let t=e.substring(5);return sn.Namespace.EXO.term(t)}if(e.startsWith("ems__")){let t=e.substring(5);return sn.Namespace.EMS.term(t)}throw new Error(`Invalid property key: ${e}`)}async valueToRDFObject(e,t){if(typeof e=="string"){let r=this.removeQuotes(e),i=this.extractWikilink(r);if(i){let s=this.vault.getFirstLinkpathDest(i,t.path);if(s){let a=this.notePathToIRI(s.path),c=i.includes("|")?i.split("|")[0]:i;if(this.isUUID(c)){let l=new Pn.Literal(c);return[a,l]}return[a]}if(this.isClassReference(i)){let a=this.expandClassValue(i);if(a)return[a]}return[new Pn.Literal(r)]}if(this.isClassReference(r)){let s=this.expandClassValue(r);if(s)return[s]}return this.isISO8601DateTime(r)?[new Pn.Literal(r,sn.Namespace.XSD.term("dateTime"))]:[new Pn.Literal(r)]}return typeof e=="boolean"?[new Pn.Literal(e.toString())]:typeof e=="number"?[new Pn.Literal(e.toString(),sn.Namespace.XSD.term("decimal"))]:e instanceof Date?[new Pn.Literal(e.toISOString(),sn.Namespace.XSD.term("dateTime"))]:[new Pn.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(/^\[\[([^\]]+)\]\]$/);return t?t[1]:null}valueToClassURI(e){if(typeof e!="string")return new Pn.Literal(String(e));let t=this.removeQuotes(e),i=this.extractWikilink(t)||t,s=this.expandClassValue(i);return s||new Pn.Literal(t)}isClassReference(e){return(e.startsWith("ems__")||e.startsWith("exo__"))&&!/\s/.test(e)}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);if(t.startsWith("ems__")){let r=t.substring(5);return sn.Namespace.EMS.term(r)}if(t.startsWith("exo__")){let r=t.substring(5);return sn.Namespace.EXO.term(r)}return null}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),a=this.extractBodyWikilinks(s),c=sn.Namespace.EXO.term("Asset_bodyLink");for(let l of a){let u=this.vault.getFirstLinkpathDest(l,e.path);if(u){let f=this.notePathToIRI(u.path);r.push(new yn.Triple(t,c,f))}else if(this.isClassReference(l)){let f=this.expandClassValue(l);f?r.push(new yn.Triple(t,c,f)):r.push(new yn.Triple(t,c,new Pn.Literal(l)))}else r.push(new yn.Triple(t,c,new Pn.Literal(l)))}}catch{}return r}};Si.NoteToRDFConverter=Fc;Fc.SkippedFileInfo=class{constructor(n,e){this.path=n,this.reason=e}};Fc.VaultValidationResult=class{constructor(n,e,t){this.triples=n,this.skippedFiles=e,this.summary=t}};Fc.VaultValidationOptions=class{constructor(n=!1){this.strict=n}};Si.NoteToRDFConverter=Fc=N6([(0,p2.injectable)(),k3(0,(0,p2.inject)(M3.DI_TOKENS.IVaultAdapter)),k3(1,(0,p2.inject)(M3.DI_TOKENS.ILogger)),k6("design:paramtypes",[Object,Object])],Fc)});var y2=v(lp=>{"use strict";Object.defineProperty(lp,"__esModule",{value:!0});lp.FilterContainsOptimizer=void 0;var j6=Fe(),$6=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i,g2=class{static{o(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($6);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 j6.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(a=>a.subject.type==="variable"&&a.subject.value===t?{...a,subject:{type:"iri",value:r}}:a);if(i.some((a,c)=>a.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(a=>({[t.variable]:{type:"iri",value:a}}))},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)}};lp.FilterContainsOptimizer=g2});var j3=v(up=>{"use strict";Object.defineProperty(up,"__esModule",{value:!0});up.AlgebraOptimizer=void 0;var V6=y2(),_2=class{static{o(this,"AlgebraOptimizer")}constructor(){this.stats=new Map,this.tripleStore=null,this.filterContainsOptimizer=new V6.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),a=r.every(l=>i.has(l)),c=r.every(l=>s.has(l));return a&&!c?{type:"join",left:{type:"filter",expression:e.expression,input:this.filterPushDown(t.left)},right:this.filterPushDown(t.right)}:c&&!a?{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)}};up.AlgebraOptimizer=_2});var $3=v(fp=>{"use strict";Object.defineProperty(fp,"__esModule",{value:!0});fp.AlgebraSerializer=void 0;var v2=class{static{o(this,"AlgebraSerializer")}toString(e,t=0){let r=" ".repeat(t);switch(e.type){case"bgp":return`${r}BGP [
302
302
  ${e.triples.map(u=>`${r} ${this.tripleToString(u)}`).join(`
303
303
  `)}
304
304
  ${r}]`;case"filter":return`${r}Filter(
@@ -648,7 +648,7 @@ ${Cr.dump(i,{lineWidth:-1})}---
648
648
  \u{1F50D} Dry-run: command "${l.name}" on "${t.target}"
649
649
  `),console.log(" Precondition: passed \u2705"),console.log(" Grounding (would execute):"),$b(l.grounding," ");return}let h=new Bt.ServiceRegistry,p=new Dt(i),b=await new Bt.GroundingExecutor(p,p,h).execute(l.grounding,u,t.target);if(r==="json"){let E=Z.success({command:l.name,target:t.target,preconditionPassed:!0,executed:!0,success:b.success,...b.error&&{error:b.error},...l.successMessage&&b.success&&{message:l.successMessage}});console.log(JSON.stringify(E,null,2))}else if(b.success){let E=l.successMessage??`Command "${l.name}" executed successfully.`;console.log(`\u2705 ${E}`)}else console.log(`\u274C Command "${l.name}" failed: ${b.error}`),process.exitCode=5}catch(i){k.handle(i)}}),n.command("validate").description("Validate all dynamic command definitions in vault").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--output <type>","Response format: text|json","text").action(async e=>{let t=e.output||"text";k.setFormat(t);try{let r=(0,ls.resolve)(e.vault);if(!(0,cs.existsSync)(r))throw new Oe(r);let i=qG(r);if(t==="json"){let s=Z.success({totalCommands:Mb(r).length,totalIssues:i.reduce((a,c)=>a+c.issues.length,0),commandsWithIssues:i.length,issues:i});console.log(JSON.stringify(s,null,2))}else{let s=Mb(r);if(i.length===0)console.log(`\u2705 All ${s.length} dynamic command(s) are valid.`);else{let a=i.reduce((c,l)=>c+l.issues.length,0);console.log(`\u274C Found ${a} issue(s) in ${i.length} command(s) out of ${s.length} total:
650
650
  `);for(let c of i){console.log(` \u{1F4C4} ${c.label} (${c.uid}):`);for(let l of c.issues)console.log(` \u2022 ${l}`);console.log()}process.exitCode=5}}}catch(r){k.handle(r)}}),n}o(tI,"dynamicCommandCommand");function Mb(n){let e=[],t=[];Vb(n,t);for(let{filePath:r,fm:i}of t){if(!El(i,"exocmd__Command"))continue;let s=i.exo__Asset_uid??"",a=i.exo__Asset_label??rI(r),c=i.exocmd__Command_category,l=i.exocmd__Command_icon,u=!!i.exocmd__Command_precondition,f=i.exocmd__Command_grounding,d;if(f){let h=rg(String(f)),p=t.find(_=>_.fm.exo__Asset_uid===h&&El(_.fm,"exocmd__Grounding"));p&&(d=p.fm.exocmd__Grounding_type)}e.push({filePath:r,uid:s,label:a,category:c,icon:l,hasPrecondition:u,groundingType:d})}return e}o(Mb,"scanCommands");async function BG(n,e){let{tripleStore:t}=await jb(n),r=new Bt.CommandResolver(t),i=await r.findBindings(),s=new Set;for(let c of i)s.add(c.commandRef);let a=[];for(let c of s){let l=await r.loadCommand(c);l&&a.push({filePath:"",uid:l.id,label:l.name,category:l.category,icon:l.icon,hasPrecondition:!!l.precondition,groundingType:l.grounding.type})}return a}o(BG,"listCommandsForTarget");function qG(n){let e=[],t=[];Vb(n,t);let r=new Map;for(let i of t){let s=i.fm.exo__Asset_uid;s&&r.set(s,i)}for(let{filePath:i,fm:s}of t){if(!El(s,"exocmd__Command"))continue;let a=s.exo__Asset_uid??"",c=s.exo__Asset_label??rI(i),l=[];a||l.push("Missing exo__Asset_uid"),s.exo__Asset_label||l.push("Missing exo__Asset_label");let u=s.exocmd__Command_grounding;if(!u)l.push("Missing exocmd__Command_grounding (required)");else{let h=rg(String(u)),p=r.get(h);if(!p)l.push(`Grounding reference "${h}" not found in vault`);else if(!El(p.fm,"exocmd__Grounding"))l.push(`Grounding reference "${h}" is not an exocmd__Grounding asset`);else{let _=p.fm,b=_.exocmd__Grounding_type;b?(Object.values(Bt.GroundingType).includes(b)||l.push(`Grounding "${h}" has invalid type "${b}"`),(b===Bt.GroundingType.PROPERTY_SET||b===Bt.GroundingType.PROPERTY_DELETE)&&!_.exocmd__Grounding_targetProperty&&l.push(`Grounding "${h}" (${b}) missing targetProperty`),b===Bt.GroundingType.PROPERTY_SET&&!_.exocmd__Grounding_targetValue&&l.push(`Grounding "${h}" (property_set) missing targetValue`)):l.push(`Grounding "${h}" missing exocmd__Grounding_type`)}}let f=s.exocmd__Command_precondition;if(f){let h=rg(String(f)),p=r.get(h);p?El(p.fm,"exocmd__Precondition")?p.fm.exocmd__Precondition_sparqlAsk||l.push(`Precondition "${h}" missing sparqlAsk`):l.push(`Precondition reference "${h}" is not an exocmd__Precondition asset`):l.push(`Precondition reference "${h}" not found in vault`)}t.some(h=>El(h.fm,"exocmd__CommandBinding")?rg(String(h.fm.exocmd__CommandBinding_command??""))===a:!1)||l.push("No CommandBinding references this command (command will be unused)"),l.length>0&&e.push({uid:a,label:c,filePath:i,issues:l})}return e}o(qG,"validateCommands");async function jb(n){let e=new Wr(n),r=await new Bt.NoteToRDFConverter(e).convertVault(),i=new Bt.InMemoryTripleStore;return await i.addAll(r),{tripleStore:i}}o(jb,"buildTripleStore");function $b(n,e){if(console.log(`${e}ID: ${n.id}`),console.log(`${e}Label: ${n.label}`),console.log(`${e}Type: ${n.type}`),n.targetProperty&&console.log(`${e}Target property: ${n.targetProperty}`),n.targetValue!==void 0&&console.log(`${e}Target value: ${n.targetValue}`),n.sparqlUpdate&&console.log(`${e}SPARQL UPDATE: ${n.sparqlUpdate}`),n.steps&&n.steps.length>0){console.log(`${e}Steps (${n.steps.length}):`);for(let t=0;t<n.steps.length;t++)console.log(`${e} Step ${t+1}:`),$b(n.steps[t],e+" ")}}o($b,"printGrounding");function Vb(n,e){let t;try{t=(0,cs.readdirSync)(n,{withFileTypes:!0})}catch{return}for(let r of t){let i=(0,ls.join)(n,r.name);if(r.isDirectory()){if(r.name.startsWith(".")||r.name==="node_modules")continue;Vb(i,e)}else if(r.name.endsWith(".md"))try{let s=(0,cs.readFileSync)(i,"utf-8"),a=UG.parse(s);a.exists&&e.push({filePath:i,fm:WG(a.content)})}catch{}}}o(Vb,"collectParsedFiles");function WG(n){let e={},t=n.split(`
651
- `),r="",i=null;for(let s of t){if(s.match(/^\s+-\s+/)&&r){let c=s.replace(/^\s+-\s+/,"").trim();i||(i=[]),i.push(c),e[r]=i;continue}let a=s.match(/^([a-zA-Z0-9_]+):\s*(.*)/);if(a){r=a[1],i=null;let c=a[2].trim();if((c.startsWith('"')&&c.endsWith('"')||c.startsWith("'")&&c.endsWith("'"))&&(c=c.slice(1,-1)),c==="true"?c=!0:c==="false"&&(c=!1),c===""){e[r]=[],i=e[r];continue}e[r]=c}}return e}o(WG,"parseYamlFrontmatter");function El(n,e){let t=n.exo__Instance_class;if(!t)return!1;let r=Array.isArray(t)?t:[t];for(let i of r){if(typeof i!="string")continue;let s=i.match(/\[\[([^|\]]+)/);if((s?s[1]:i)===e)return!0}return!1}o(El,"hasClass");function rg(n){return typeof n!="string"?"":n.replace(/["'[\]]/g,"").trim()}o(rg,"normalizeWikilink");function rI(n){return(0,ls.basename)(n,".md")}o(rI,"extractLabelFromFilename");var Dr=new qe;Dr.name("exocortex").description("CLI tool for Exocortex knowledge management system").version("15.55.19");var Ub=Dr.command("sparql").description("SPARQL query execution and cache management");Ub.addCommand(iO());Ub.addCommand(cO());Ub.addCommand(lO());Dr.addCommand(yR());Dr.addCommand(bR());Dr.addCommand(SR());Dr.addCommand(ER());Dr.addCommand(TR());Dr.addCommand(OR());Dr.addCommand(FR());Dr.addCommand(LR());Dr.addCommand($R());Dr.addCommand(WR());Dr.addCommand(zR());Dr.addCommand(QR());Dr.addCommand(KR());Dr.addCommand(tI());Dr.parse();
651
+ `),r="",i=null;for(let s of t){if(s.match(/^\s+-\s+/)&&r){let c=s.replace(/^\s+-\s+/,"").trim();i||(i=[]),i.push(c),e[r]=i;continue}let a=s.match(/^([a-zA-Z0-9_]+):\s*(.*)/);if(a){r=a[1],i=null;let c=a[2].trim();if((c.startsWith('"')&&c.endsWith('"')||c.startsWith("'")&&c.endsWith("'"))&&(c=c.slice(1,-1)),c==="true"?c=!0:c==="false"&&(c=!1),c===""){e[r]=[],i=e[r];continue}e[r]=c}}return e}o(WG,"parseYamlFrontmatter");function El(n,e){let t=n.exo__Instance_class;if(!t)return!1;let r=Array.isArray(t)?t:[t];for(let i of r){if(typeof i!="string")continue;let s=i.match(/\[\[([^|\]]+)/);if((s?s[1]:i)===e)return!0}return!1}o(El,"hasClass");function rg(n){return typeof n!="string"?"":n.replace(/["'[\]]/g,"").trim()}o(rg,"normalizeWikilink");function rI(n){return(0,ls.basename)(n,".md")}o(rI,"extractLabelFromFilename");var Dr=new qe;Dr.name("exocortex").description("CLI tool for Exocortex knowledge management system").version("15.55.20");var Ub=Dr.command("sparql").description("SPARQL query execution and cache management");Ub.addCommand(iO());Ub.addCommand(cO());Ub.addCommand(lO());Dr.addCommand(yR());Dr.addCommand(bR());Dr.addCommand(SR());Dr.addCommand(ER());Dr.addCommand(TR());Dr.addCommand(OR());Dr.addCommand(FR());Dr.addCommand(LR());Dr.addCommand($R());Dr.addCommand(WR());Dr.addCommand(zR());Dr.addCommand(QR());Dr.addCommand(KR());Dr.addCommand(tI());Dr.parse();
652
652
  /*! Bundled license information:
653
653
 
654
654
  reflect-metadata/Reflect.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitelev/exocortex-cli",
3
- "version": "15.55.19",
3
+ "version": "15.55.20",
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": {