@prefix this: <https://w3id.org/np/RA3TX49K5rlZrrN9cQXThPWAH__tBYRrnopEkOPDIayK8> .
@prefix sub: <https://w3id.org/np/RA3TX49K5rlZrrN9cQXThPWAH__tBYRrnopEkOPDIayK8/> .
@prefix np: <http://www.nanopub.org/nschema#> .
@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#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .

<https://w3id.org/np/RA3TX49K5rlZrrN9cQXThPWAH__tBYRrnopEkOPDIayK8> a np:Nanopublication;
  np:hasAssertion sub:assertion;
  np:hasProvenance sub:provenance;
  np:hasPublicationInfo sub:pubinfo;
  dct:created "2026-06-08T18:39:01Z"^^xsd:dateTime;
  dct:creator orcid:0000-0002-1267-0234;
  dct:license <https://creativecommons.org/licenses/by/4.0/>;
  npx:embeds sub:get-intro-recommendations;
  npx:supersedes <https://w3id.org/np/RAoZLJ-edn0orSDM2utQJpQNz6rMLVsze-GJGvgiVhHyg>;
  nt:wasCreatedFromProvenanceTemplate <https://w3id.org/np/RA7lSq6MuK_TIC6JMSHvLtee3lpLoZDOqLJCLXevnrPoU>;
  nt:wasCreatedFromPubinfoTemplate <https://w3id.org/np/RA0J4vUn_dekg-U1kK3AOEt02p9mT2WO03uGxLDec1jLw>,
    <https://w3id.org/np/RAoTD7udB2KtUuOuAe74tJi1t3VzK0DyWS7rYVAq1GRvw>, <https://w3id.org/np/RAukAcWHRDlkqxk7H2XNSegc1WnHI569INvNr-xdptDGI>;
  nt:wasCreatedFromTemplate <https://w3id.org/np/RAEFAt-QcFK0ZhqfvlsmS10BnzGJA0xwOICZXkO-ai87k> .

sub:get-intro-recommendations a <https://w3id.org/kpxl/grlc/grlc-query>;
  dct:description "Returns recommended introduction actions for a given user, but only when the viewer is that user themselves (owner gate via ?__CURRENTUSER_multi_iri = ?_user_iri). Emits one row per applicable recommendation: 'Create Introduction' when the viewer's local key (?__LOCALPUBKEY_multi) is in none of the user's introductions (localCount=0; carries the local-key bundle to prefill the create action), and 'Get approved' when the local key is in exactly one introduction that is not yet approved (localCount=1 and no loaded AccountState, checked by federating to the trust repo; carries the intro nanopub to link to). No rows for non-owners or logged-out viewers. local_pubkey/short/site_url are action-mapping data (hidden from display).";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get introduction recommendations";
  <https://w3id.org/kpxl/grlc/endpoint> <https://w3id.org/np/l/nanopub-query-1.1/repo/type/77757cabf6184c51c20b8b0fe5dc5e1365b7f628448335184ad54319a0affdfc>;
  <https://w3id.org/kpxl/grlc/sparql> """prefix np: <http://www.nanopub.org/nschema#>
prefix npx: <http://purl.org/nanopub/x/>
prefix npa: <http://purl.org/nanopub/admin/>

select ?recommendation ?intro_np ?local_pubkey ?local_pubkey_short ?site_url
where {
  values ?__CURRENTUSER_multi_iri {}
  filter(?_user_iri = ?__CURRENTUSER_multi_iri)
  {
    values ?__LOCALPUBKEY_multi {}
    values ?__SITEURL_multi {}
    filter(bound(?__LOCALPUBKEY_multi))
    {
      select (count(distinct ?lnp) as ?localCount) where {
        values ?__LOCALPUBKEY_multi {}
        graph npa:graph {
          ?lnp npa:hasValidSignatureForPublicKey ?lk2 .
          filter not exists { ?lnpx npx:invalidates ?lnp ; npa:hasValidSignatureForPublicKey ?lk2 . }
          ?lnp np:hasAssertion ?la .
        }
        graph ?la { ?lkd npx:declaredBy ?_user_iri ; npx:hasPublicKey ?lpubkey . }
        filter(coalesce(str(?lpubkey) = str(?__LOCALPUBKEY_multi), false))
      }
    }
    filter(?localCount = 0)
    bind(coalesce(str(?__LOCALPUBKEY_multi), \"\") as ?local_pubkey)
    bind(if(strlen(?local_pubkey) >= 45, concat(substr(?local_pubkey, 1, 1), \"..\", substr(?local_pubkey, 41, 5), \"..\"), \"\") as ?local_pubkey_short)
    bind(coalesce(str(?__SITEURL_multi), \"\") as ?site_url)
    bind(\"The local key from this site is not part of an introduction yet. Create one to link it to your identity.\" as ?recommendation)
  } union {
    values ?__LOCALPUBKEY_multi {}
    filter(bound(?__LOCALPUBKEY_multi))
    {
      select (count(distinct ?lnp) as ?localCount) (sample(?lnp) as ?localIntroNp) where {
        values ?__LOCALPUBKEY_multi {}
        graph npa:graph {
          ?lnp npa:hasValidSignatureForPublicKey ?lk2 .
          filter not exists { ?lnpx npx:invalidates ?lnp ; npa:hasValidSignatureForPublicKey ?lk2 . }
          ?lnp np:hasAssertion ?la .
        }
        graph ?la { ?lkd npx:declaredBy ?_user_iri ; npx:hasPublicKey ?lpubkey . }
        filter(coalesce(str(?lpubkey) = str(?__LOCALPUBKEY_multi), false))
      }
    }
    filter(?localCount = 1)
    bind(lcase(sha256(str(?__LOCALPUBKEY_multi))) as ?lpkHash)
    filter not exists {
      service <https://w3id.org/np/l/nanopub-query-1.1/repo/trust> {
        graph npa:graph { npa:thisRepo npa:hasCurrentTrustState ?tg . }
        graph ?tg { ?acct npa:agent ?_user_iri ; npa:pubkey ?lpkHash ; npa:trustStatus npa:loaded . }
      }
    }
    bind(\"Your introduction with the local key is not approved yet. Share it so a maintainer can approve it:\" as ?recommendation)
    bind(?localIntroNp as ?intro_np)
  }
}""" .

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

orcid:0000-0002-1267-0234 foaf:name "Tobias Kuhn" .

sub:sig npx:hasAlgorithm "RSA";
  npx:hasPublicKey "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwUtewGCpT5vIfXYE1bmf/Uqu1ojqnWdYxv+ySO80ul8Gu7m8KoyPAwuvaPj0lvPtHrg000qMmkxzKhYknEjq8v7EerxZNYp5B3/3+5ZpuWOYAs78UnQVjbHSmDdmryr4D4VvvNIiUmd0yxci47dTFUj4DvfHnGd6hVe5+goqdcwIDAQAB";
  npx:hasSignature "J4fRrXywYHhfz8RleG095ymnjD8NqNBXU8dCyJIydKJimCPY/n2OvYp6Itcp9kyc4w/ryB/JhxN54Hc9R2ZXdf89Mx5apsAavA9L6Wl9wnrt1ofEtDZbHpMSoLPo3/4G7FJFtAMckKtrmIBM9I+OtcaBk+X4mLpFkOvzmQWE5jA=";
  npx:hasSignatureTarget <https://w3id.org/np/RA3TX49K5rlZrrN9cQXThPWAH__tBYRrnopEkOPDIayK8>;
  npx:signedBy orcid:0000-0002-1267-0234 .

