@prefix this: <https://w3id.org/np/RAWxyEV4PJHr0BZyDZCUgoU6uMT9kyKm4c2jt9AEwJVEI> .
@prefix sub: <https://w3id.org/np/RAWxyEV4PJHr0BZyDZCUgoU6uMT9kyKm4c2jt9AEwJVEI/> .
@prefix np: <http://www.nanopub.org/nschema#> .
@prefix grlc: <https://w3id.org/kpxl/grlc/> .
@prefix dct: <http://purl.org/dc/terms/> .
@prefix nt: <https://w3id.org/np/o/ntemplate/> .
@prefix npx: <http://purl.org/nanopub/x/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix orcid: <https://orcid.org/> .
@prefix prov: <http://www.w3.org/ns/prov#> .

<https://w3id.org/np/RAWxyEV4PJHr0BZyDZCUgoU6uMT9kyKm4c2jt9AEwJVEI> a np:Nanopublication;
  np:hasAssertion sub:assertion;
  np:hasProvenance sub:provenance;
  np:hasPublicationInfo sub:pubinfo;
  dct:created "2026-07-16T06:49:04Z"^^xsd:dateTime;
  dct:creator orcid:0000-0002-1267-0234;
  dct:license <https://creativecommons.org/licenses/by/4.0/>;
  npx:embeds sub:get-faqs;
  npx:supersedes <https://w3id.org/np/RAhUrDrKt1MclIQXc7eCQPIv2G0pd6Mo5_nNVtmdOyMc8>;
  rdfs:label "Get FAQ entries of an entity";
  nt:wasCreatedFromProvenanceTemplate <https://w3id.org/np/RA7lSq6MuK_TIC6JMSHvLtee3lpLoZDOqLJCLXevnrPoU>;
  nt:wasCreatedFromPubinfoTemplate <https://w3id.org/np/RACJ58Gvyn91LqCKIO9zu1eijDQIeEff28iyDrJgjSJF8>,
    <https://w3id.org/np/RAMEgudZsQ1bh1fZhfYnkthqH6YSXpghSE_DEN1I-6eAI>, <https://w3id.org/np/RARW4MsFkHuwjycNElvEVtuMjpf4yWDL10-0C5l2MqqRQ>,
    <https://w3id.org/np/RAoTD7udB2KtUuOuAe74tJi1t3VzK0DyWS7rYVAq1GRvw>, <https://w3id.org/np/RAukAcWHRDlkqxk7H2XNSegc1WnHI569INvNr-xdptDGI>;
  nt:wasCreatedFromTemplate <https://w3id.org/np/RAEFAt-QcFK0ZhqfvlsmS10BnzGJA0xwOICZXkO-ai87k> .

sub:get-faqs a grlc:grlc-query;
  dct:description "This query returns the answered FAQ entries (questions and answers) of an entity, including source nanopub and date. Only entries published by an admin, maintainer, or member of the space that maintains the entity are returned; the maintaining space and its validated member public-key hashes are resolved server-side from the spaces repo (/repo/spaces), observers excluded. Entries currently typed as gen:UnansweredQuestion (placeholder stubs) are excluded. When several member-published nanopubs declare the same FAQ entry, only the most recent one is returned.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get FAQ entries of an entity";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/88a3271eb4f952262a674b6765824830ecb6c5a9ae10f1fd8caa4fc21cdccad7>;
  grlc:sparql """prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix schema: <http://schema.org/>
prefix gen: <https://w3id.org/kpxl/gen/terms/>

select ?title ?content ?date ?faq (?np as ?override_target) ?np where {
  service <https://w3id.org/np/l/nanopub-query-1.1/repo/spaces> {
    select (group_concat(?mpk; separator=\" \") as ?memberPubkeys) where {
      graph npa:graph { npa:thisRepo npa:hasCurrentSpaceState ?stateG . }
      values ?_resource_multi_iri {}
      graph ?stateG {
        ?_resource_multi_iri npa:isMaintainedBy? ?space .
        ?ri a gen:RoleInstantiation ; npa:forSpace ?space ; npa:forAgent ?agent ;
            npa:hasRoleType ?rt .
        filter(?rt in (gen:AdminRole, gen:MaintainerRole, gen:MemberRole))
        ?acct a npa:AccountState ; npa:agent ?agent ; npa:pubkey ?mpk .
      }
    }
  }
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np dct:created ?date .
    ?np np:hasAssertion ?a .
  }
  filter(contains(?memberPubkeys, ?pubkey))
  graph ?a {
    ?faq rdf:type schema:Question .
    ?faq rdfs:label ?title .
    ?faq gen:hasContent ?content .
    values ?_resource_multi_iri {}
    ?faq dct:isPartOf ?_resource_multi_iri .
    filter not exists { ?faq rdf:type gen:UnansweredQuestion }
    optional { ?faq gen:hasPositionString ?position }
  }
  filter not exists {
    graph npa:graph {
      ?np2 npa:hasValidSignatureForPublicKeyHash ?pubkey2 .
      filter not exists { ?npx2 npx:invalidates ?np2 ; npa:hasValidSignatureForPublicKeyHash ?pubkey2 . }
      ?np2 dct:created ?date2 .
      ?np2 np:hasAssertion ?a2 .
      filter (?date2 > ?date)
    }
    filter(contains(?memberPubkeys, ?pubkey2))
    graph ?a2 {
      ?faq rdf:type schema:Question .
    }
  }
}
order by ?position ?title""" .

sub:assertion prov:wasAttributedTo orcid:0000-0002-1267-0234 .

sub:sig npx:hasAlgorithm "RSA";
  npx:hasPublicKey "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwUtewGCpT5vIfXYE1bmf/Uqu1ojqnWdYxv+ySO80ul8Gu7m8KoyPAwuvaPj0lvPtHrg000qMmkxzKhYknEjq8v7EerxZNYp5B3/3+5ZpuWOYAs78UnQVjbHSmDdmryr4D4VvvNIiUmd0yxci47dTFUj4DvfHnGd6hVe5+goqdcwIDAQAB";
  npx:hasSignature "n3G/AQ/X5QEEZp+CcPXIH+ArCASQsukgCC3UvsaXyeQcUvWxrGhAX6iMNsPq2Ge2d9xqLv9Cmk7lLb6716Qok1tTQB3Pq1LPfPBr03X2c65axPaRoQQkpTtQ/4Uvub2LrIHF6epu/gjbcCz4xQBfvHJvSxSGmWfOZgj/rHLBznY=";
  npx:hasSignatureTarget <https://w3id.org/np/RAWxyEV4PJHr0BZyDZCUgoU6uMT9kyKm4c2jt9AEwJVEI>;
  npx:signedBy orcid:0000-0002-1267-0234 .

