import{ak as T,ai as C,ah as F,bc as X}from"./index-UvaAT40e.js";function P(_,t){let e={};for(const i of _.results.bindings)e=g(i,e,t);return e}function g(_,t,e){for(const[i,r]of Object.entries(e))if(typeof r=="string"){if(r in _){let s=_[r].value;(s==="true"||s==="false")&&(s=s==="true"),t[i]=s}}else if(Array.isArray(r)){i in t||(t[i]=[]);for(const s of r)if(typeof s=="string"&&_[s]){let c=_[s].value;c&&t[i].push(c)}else{let c=g(_,{},s);Object.keys(c).length>0&&t[i].push(c)}}else i in t||(t[i]={}),g(_,t[i],r),Object.keys(t[i]).length==0&&delete t[i];return t}function H(_){let t=_.match(/Point\((-*\d+.\d+) (-*\d+.\d+)\)/i);return[t[1],t[2]]}const E=`
  BASE <https://db.antiquitatum-thesaurus.eu>
  PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
  PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/> 
  PREFIX owl: <http://www.w3.org/2002/07/owl#>
  PREFIX at: <https://db.antiquitatum-thesaurus.eu/ontology/>
`,u=`
  ?iri crm:P1_is_identified_by ?title .
  ?title crm:P2_has_type <type/preferred_title> .
  ?title crm:P190_has_symbolic_content ?label .
`,D=`
  ?iri crm:P1_is_identified_by ?title .
  ?title crm:P190_has_symbolic_content ?label .
`,b=`
  ?iri rdfs:label ?label .
  FILTER (LANG(?label) = "de") .
  `,f="?iri crm:P1_is_identified_by / crm:P190_has_symbolic_content ?label .",w={object_type:b,classification:b,material:b,technique:b,mode_of_depiction:b,find_place:f,production_place:f,location:f,custody:f,provenance_institution:f,production_person:f,provenance_person:f,find_person:f,modification_person:f,depicted_person:f,depicted_place:f,is_part_of_source_work:u,is_depicted_in:u,depicts:u,is_copy_after:u,has_copy:u,is_based_on:u,is_precursor_for:u,is_related_to:u,is_duplicate_of:u,part_of_module:D,has_version:u,is_version_of:u};function I(_){return _=="object_type"?"?iri crm:P2_has_type <type/object_type> .":_=="classification"?"?iri crm:P2_has_type <type/classification> .":""}const S={object_type:(_,t)=>`
    ${_} crm:P2_has_type ${t} .
  `,classification:(_,t)=>`
    ${_} crm:P2_has_type ${t} .
  `,material:(_,t)=>`${_} crm:P45_consists_of ${t} .`,technique:(_,t)=>`
    ${_} crm:P108i_was_produced_by / crm:P32_used_general_technique ${t} .`,mode_of_depiction:(_,t,e,i)=>`
    ${_} crm:P01i_is_domain_of ?depicts_${e.join("_")}_${i} .
    ?depicts_${e.join("_")}_${i} a crm:PC62_depicts .
    ?depicts_${e.join("_")}_${i} crm:P62.1_mode_of_depiction ${t} .
  `,find_place:(_,t)=>`
    ${_} crm:O19i_was_objectencountered_at / crm:P7_took_place_at ${t} .`,production_place:(_,t)=>`${_} crm:P108i_was_produced_by / crm:P7_took_place_at ${t} .`,location:(_,t)=>`${_} crm:P55_has_current_location ${t} .`,all_places:(_,t)=>`
    ${_} crm:P55_has_current_location
      | ( crm:P108i_was_produced_by / crm:P7_took_place_at )
      | ( crm:O19i_was_objectencountered_at / crm:P7_took_place_at )
    ${t} .
  `,custody:(_,t,e,i)=>`
    ${_} crm:P30i_custody_transferred_through ?transfer_of_custody_${e.join("_")}_${i} . 
    ?transfer_of_custody_${e.join("_")}_${i} crm:P2_has_type <type/acquisition> .
    ?transfer_of_custody_${e.join("_")}_${i} crm:P29_custody_received_by ${t} .
  `,provenance_institution:(_,t,e,i)=>`
    ${_} crm:P30i_custody_transferred_through ?transfer_of_custody_${e.join("_")}_${i} .
    ?transfer_of_custody_${e.join("_")}_${i} crm:P2_has_type <type/provenance> .
    ?transfer_of_custody_${e.join("_")}_${i} crm:P29_custody_received_by ${t} .
  `,all_persons:(_,t,e,i)=>`
    {
      ${_} (crm:P108i_was_produced_by | crm:O19i_was_objectencountered_at | crm:P31i_was_modified_by) / crm:P01i_is_domain_of ?role_${e.join("_")}_${i} .
      ?role_${e.join("_")}_${i} a crm:PC14_carried_out_by .
      ?role_${e.join("_")}_${i} crm:P02_has_range ${t} .
    } UNION {
      ${_} crm:P30i_custody_transferred_through ?transfer_of_custody_${e.join("_")}_${i} .
      ?transfer_of_custody_${e.join("_")}_${i} crm:P2_has_type <type/provenance> .
      ?transfer_of_custody_${e.join("_")}_${i} crm:P29_custody_received_by ${t} .
    } UNION {
      ${_} crm:P62_depicts ${t} .
      ${t} a crm:E21_Person .
    }
  `,production_person:(_,t,e,i)=>`
    ${_} crm:P108i_was_produced_by / crm:P01i_is_domain_of ?role_${e.join("_")}_${i} .
    ?role_${e.join("_")}_${i} a crm:PC14_carried_out_by .
    ?role_${e.join("_")}_${i} crm:P02_has_range ${t} .
  `,provenance_person:(_,t,e,i)=>`
    ${_} crm:P30i_custody_transferred_through ?transfer_of_custody_${e.join("_")}_${i} .
    ?transfer_of_custody_${e.join("_")}_${i} crm:P2_has_type <type/provenance> .
    ?transfer_of_custody_${e.join("_")}_${i} crm:P29_custody_received_by ${t} .
  `,find_person:(_,t,e,i)=>`
    ${_} crm:O19i_was_objectencountered_at / crm:P01i_is_domain_of ?role_${e.join("_")}_${i} . 
    ?role_${e.join("_")}_${i} a crm:PC14_carried_out_by .
    ?role_${e.join("_")}_${i} crm:P02_has_range ${t} .
  `,modification_person:(_,t,e,i)=>`
    ${_} crm:P31i_was_modified_by / crm:P01i_is_domain_of ?role_${e.join("_")}_${i} .
    ?role_${e.join("_")}_${i} a crm:PC14_carried_out_by .
    ?role_${e.join("_")}_${i} crm:P02_has_range ${t} .
  `,depicted_person:(_,t)=>`
    ${_} crm:P62_depicts ${t} .
    ${t} a crm:E21_Person .
  `,depicted_place:(_,t)=>`
    ${_} crm:P62_depicts ${t} .
    ${t} a crm:E53_Place .
  `,is_part_of_source_work:(_,t)=>` ${_} at:is_part_of_source_work ${t} .`,is_part_of_source_work_subQueries:(_,t,e)=>`
    ${_} at:is_part_of_source_work ?object_${e.join("_")} .
  `,depicts:(_,t,e)=>`
    ${_} crm:P01i_is_domain_of ?depicts_${e.join("_")} .
    ?depicts_${e.join("_")} a crm:PC62_depicts .
    ?depicts_${e.join("_")} crm:P02_has_range ${t} .`,depicts_subQueries:(_,t,e)=>`${_} crm:P01i_is_domain_of ?depicts_sub_${e.join("_")} .
    ?depicts_sub_${e.join("_")} a crm:PC62_depicts .
    ?depicts_sub_${e.join("_")} crm:P02_has_range ?object_${e.join("_")} .`,is_depicted_in:(_,t,e)=>`
    ${_} crm:P02i_is_range_of ?depicts_${e.join("_")} .
    ?depicts_${e.join("_")} a crm:PC62_depicts .
    { ?depicts_${e.join("_")} crm:P01_has_domain / at:is_part_of_source_work ${t} . } 
    UNION 
    { FILTER NOT EXISTS { ?depicts_${e.join("_")} crm:P01_has_domain / at:is_part_of_source_work ?father_${e.join("_")} . }
      ?depicts_${e.join("_")} crm:P01_has_domain ${t} .
    }`,is_depicted_in_subQueries:(_,t,e)=>`
    ${_} crm:P02i_is_range_of ?depicts_sub_${e.join("_")} .
    ?depicts_sub_${e.join("_")} a crm:PC62_depicts .
    ?depicts_sub_${e.join("_")} crm:P01_has_domain ?object_${e.join("_")} .`,has_copy:(_,t,e)=>`
    ${_} crm:P02i_is_range_of ?has_copy_${e.join("_")} .
    ?has_copy_${e.join("_")} crm:P16.1_mode_of_use <type/original> .
    ?has_copy_${e.join("_")} crm:P01_has_domain ?domain_${e.join("_")} .
    { ?domain_${e.join("_")} crm:P108_has_produced / at:is_part_of_source_work ${t} . }
     UNION
    {  ?domain_${e.join("_")} crm:P108_has_produced ${t} .
       FILTER NOT EXISTS { ${t} at:is_part_of_source_work ?father_${e.join("_")} . }
    }
  `,has_copy_subQueries:(_,t,e)=>`
    ${_} crm:P02i_is_range_of ?has_copy_sub_${e.join("_")} .
    ?has_copy_sub_${e.join("_")} crm:P16.1_mode_of_use <type/original> .
    ?has_copy_sub_${e.join("_")} crm:P01_has_domain / crm:P108_has_produced ?object_${e.join("_")} .
  `,is_copy_after:(_,t,e)=>`
    ${_} crm:P108i_was_produced_by / crm:P01i_is_domain_of ?copy_after_${e.join("_")} .
    ?copy_after_${e.join("_")} crm:P16.1_mode_of_use <type/original> .
    { ?copy_after_${e.join("_")} crm:P02_has_range / at:is_part_of_source_work ${t} . }
     UNION 
    { FILTER NOT EXISTS { ?copy_after_${e.join("_")} crm:P02_has_range / at:is_part_of_source_work ?father_${e.join("_")} . } 
      ?copy_after_${e.join("_")} crm:P02_has_range ${t} .
    }
  `,is_copy_after_subQueries:(_,t,e)=>`
    ${_} crm:P108i_was_produced_by / crm:P01i_is_domain_of ?copy_after_sub_${e.join("_")} .
    ?copy_after_sub_${e.join("_")} crm:P16.1_mode_of_use <type/original> .
    ?copy_after_sub_${e.join("_")} crm:P02_has_range ?object_${e.join("_")} .
  `,is_based_on:(_,t,e)=>`
    ${_} crm:P108i_was_produced_by / crm:P01i_is_domain_of ?based_on_${e.join("_")} .
    ?based_on_${e.join("_")} crm:P16.1_mode_of_use <type/precursor> .
    { ?based_on_${e.join("_")} crm:P02_has_range / at:is_part_of_source_work ${t} . }
     UNION 
    { FILTER NOT EXISTS { ?based_on_${e.join("_")} crm:P02_has_range / at:is_part_of_source_work ?father_${e.join("_")} . }
      ?based_on_${e.join("_")} crm:P02_has_range ${t} .
    }
  `,is_based_on_subQueries:(_,t,e)=>`
    ${_} crm:P108i_was_produced_by / crm:P01i_is_domain_of ?based_on_sub_${e.join("_")} .
    ?based_on_sub_${e.join("_")} crm:P16.1_mode_of_use <type/precursor> .
    ?based_on_sub_${e.join("_")} crm:P02_has_range ?object_${e.join("_")} .
  `,is_precursor_for:(_,t,e)=>`
    ${_} crm:P02i_is_range_of ?is_precursor_for_${e.join("_")} .
    ?is_precursor_for_${e.join("_")} crm:P16.1_mode_of_use <type/precursor> .
    ?is_precursor_for_${e.join("_")} crm:P01_has_domain ?domain_${e.join("_")} .
    { ?domain_${e.join("_")} crm:P108_has_produced / at:is_part_of_source_work ${t} . }
     UNION
    {  ?domain_${e.join("_")} crm:P108_has_produced ${t} .
      	FILTER NOT EXISTS { ${t} at:is_part_of_source_work ?father_${e.join("_")} . }
    }
  `,is_precursor_for_subQueries:(_,t,e)=>`
    ${_} crm:P02i_is_range_of ?is_precursor_for_sub_${e.join("_")} .
    ?is_precursor_for_sub_${e.join("_")} crm:P16.1_mode_of_use <type/precursor> .
    ?is_precursor_for_sub_${e.join("_")} crm:P01_has_domain / crm:P108_has_produced ?object_${e.join("_")} .
  `,is_related_to:(_,t,e)=>`
    ${_} crm:P01i_is_domain_of ?rel_${e.join("_")} .
    ?rel_${e.join("_")} crm:P130.1_kind_of_similarity <type/1022295> .
    { ?rel_${e.join("_")} crm:P02_has_range / at:is_part_of_source_work ${t} . }
     UNION 
    { FILTER NOT EXISTS { ?rel_${e.join("_")} crm:P02_has_range / at:is_part_of_source_work ?father_${e.join("_")} . }
      ?rel_${e.join("_")} crm:P02_has_range ${t} . 
    }
  `,is_related_to_subQueries:(_,t,e)=>`
    ${_} crm:P01i_is_domain_of ?rel_sub_${e.join("_")} .
    ?rel_sub_${e.join("_")} crm:P130.1_kind_of_similarity <type/1022295> .
    ?rel_sub_${e.join("_")} crm:P02_has_range ?object_${e.join("_")} .
  `,is_duplicate_of:(_,t,e)=>` 
    ${_} crm:P01i_is_domain_of ?rel_${e.join("_")} .
    ?rel_${e.join("_")} crm:P130.1_kind_of_similarity <type/1641767> .
    { ?rel_${e.join("_")} crm:P02_has_range / at:is_part_of_source_work ${t} . }
     UNION 
    { FILTER NOT EXISTS { ?rel_${e.join("_")} crm:P02_has_range / at:is_part_of_source_work ?father_${e.join("_")} . }
      ?rel_${e.join("_")} crm:P02_has_range ${t} . 
    }
  `,is_duplicate_of_subQueries:(_,t,e)=>` 
    ${_} crm:P01i_is_domain_of ?rel_sub_${e.join("_")} .
    ?rel_sub_${e.join("_")} crm:P130.1_kind_of_similarity <type/1641767> .
    ?rel_sub_${e.join("_")} crm:P02_has_range ?object_${e.join("_")} .
  `,part_of_module:(_,t)=>`
    ${_} crm:P46i_forms_part_of ${t} .
    ${t} a crm:E78_Curated_Holding .
  `,has_version:(_,t,e)=>`
    ${_} crm:P01i_is_domain_of ?rel_${e.join("_")} .
    ?rel_${e.join("_")} crm:P130.1_kind_of_similarity <type/object_version> .
    { ?rel_${e.join("_")} crm:P02_has_range / at:is_part_of_source_work ${t} . }
     UNION 
    { FILTER NOT EXISTS { ?rel_${e.join("_")} crm:P02_has_range / at:is_part_of_source_work ?father_${e.join("_")} . }
      ?rel_${e.join("_")} crm:P02_has_range ${t} . 
    }
  `,has_version_subQueries:(_,t,e)=>`
    ${_} crm:P01i_is_domain_of ?rel_sub_${e.join("_")} .
    ?rel_sub_${e.join("_")} crm:P130.1_kind_of_similarity <type/object_version> .
    ?rel_sub_${e.join("_")} crm:P02_has_range ?object_${e.join("_")} .
  `,is_version_of:(_,t,e)=>`
    ${_} crm:P02i_is_range_of ?rel_${e.join("_")} .
    ?rel_${e.join("_")} crm:P130.1_kind_of_similarity <type/object_version> .
    { ?rel_${e.join("_")} crm:P01_has_domain / at:is_part_of_source_work ${t} . }
     UNION 
    { FILTER NOT EXISTS { ?rel_${e.join("_")} crm:P01_has_domain / at:is_part_of_source_work ?father_${e.join("_")} . }
      ?rel_${e.join("_")} crm:P01_has_domain ${t} . 
    }
  `,is_version_of_subQueries:(_,t,e)=>`
    ${_} crm:P02i_is_range_of ?rel_sub_${e.join("_")} .
    ?rel_sub_${e.join("_")} crm:P130.1_kind_of_similarity <type/object_version> .
    ?rel_sub_${e.join("_")} crm:P01_has_domain ?object_${e.join("_")} .
  `};function k(_){return`
  BIND ( IF (exists { ${_} crm:P2_has_type ?iri . ?iri crm:P2_has_type <type/object_type> }, 1, 0) AS ?ot )
  BIND ( IF (exists { ${_} crm:P2_has_type ?iri . ?iri crm:P2_has_type <type/classification> }, 1, 0) AS ?c )
  BIND ( IF (exists { ${_} crm:P45_consists_of ?iri }, 1, 0) as ?m )
  BIND ( IF (exists { ${_} crm:P108i_was_produced_by ?x . ?x crm:P32_used_general_technique ?iri }, 1, 0) AS ?t )
  BIND ( IF (exists { ${_} crm:O19i_was_objectencountered_at ?x . ?x crm:P7_took_place_at ?iri }, 1, 0) AS ?fp )
  BIND ( IF (exists { ${_} crm:P108i_was_produced_by ?x . ?x crm:P7_took_place_at ?iri  }, 1, 0) AS ?pp )
  BIND ( IF (exists { ${_} crm:P55_has_current_location ?iri }, 1, 0) AS ?l )
  BIND ( IF (exists { ${_} crm:P30i_custody_transferred_through ?x . ?x crm:P2_has_type <type/acquisition> . ?x crm:P29_custody_received_by ?iri }, 1, 0) AS ?cu )
  BIND ( IF (exists { ${_} crm:P30i_custody_transferred_through ?x . ?x crm:P2_has_type <type/provenance> . ?x crm:P29_custody_received_by ?iri }, 1, 0) AS ?pi )
  BIND ( IF (exists { ${_} crm:P108i_was_produced_by ?x . ?x crm:P01i_is_domain_of ?y . ?y a crm:PC14_carried_out_by . ?y crm:P02_has_range ?iri }, 1, 0) AS ?ppe )
  BIND ( IF (exists { ${_} crm:P30i_custody_transferred_through ?x . ?x crm:P2_has_type <type/provenance> . ?x crm:P29_custody_received_by ?iri }, 1, 0) AS ?prope )
  BIND ( IF (exists { ${_} crm:O19i_was_objectencountered_at ?x . ?x crm:P01i_is_domain_of ?y . ?y a crm:PC14_carried_out_by . ?y crm:P02_has_range ?iri }, 1, 0) AS ?fpe )
  BIND ( IF (exists { ${_} crm:P31i_was_modified_by ?x . ?x crm:P01i_is_domain_of ?y . ?y a crm:PC14_carried_out_by . ?y crm:P02_has_range ?iri }, 1, 0) AS ?mp )
  BIND ( IF (exists { ${_} crm:P62_depicts ?iri . ?iri a crm:E21_Person }, 1, 0) AS ?dp )
  BIND ( IF (exists { ${_} crm:P62_depicts ?iri . ?iri a crm:E53_Place }, 1, 0) AS ?dpl )
  BIND ( IF (exists { ${_} at:is_part_of_source_work ?iri }, 1, 0) AS ?iposw )
  BIND ( IF (exists { ${_} crm:P02i_is_range_of ?depicts_in . ?depicts_in a crm:PC62_depicts . }, 1, 0) AS ?idi )
  BIND ( IF (exists { ${_} crm:P01i_is_domain_of ?depicts . ?depicts a crm:PC62_depicts . }, 1, 0) AS ?d )
  BIND ( IF (exists { ${_} crm:P108i_was_produced_by ?x . ?x crm:P01i_is_domain_of ?source . ?source crm:P16.1_mode_of_use <type/original> }, 1, 0) AS ?ica ) 
  BIND ( IF (exists { ${_} crm:P02i_is_range_of ?x . ?x crm:P16.1_mode_of_use <type/original> }, 1, 0) AS ?hc )
  BIND ( IF (exists { ${_} crm:P108i_was_produced_by ?x . ?x crm:P01i_is_domain_of ?source . ?source crm:P16.1_mode_of_use <type/precursor> }, 1, 0) AS ?ibo ) 
  BIND ( IF (exists { ${_} crm:P02i_is_range_of ?x . ?x crm:P16.1_mode_of_use <type/precursor> }, 1, 0) AS ?ipo )
  BIND ( IF (exists { ${_} crm:P01i_is_domain_of ?x . ?x crm:P130.1_kind_of_similarity <type/1022295> }, 1, 0) AS ?irt )
  BIND ( IF (exists { ${_} crm:P01i_is_domain_of ?x . ?x crm:P130.1_kind_of_similarity <type/1641767> }, 1, 0) AS ?dub )
  BIND ( IF (exists { ${_} crm:P01i_is_domain_of ?x . ?x crm:P130.1_kind_of_similarity <type/object_version> }, 1, 0) AS ?hve )
  BIND ( IF (exists { ${_} crm:P02i_is_range_of ?x . ?x crm:P130.1_kind_of_similarity <type/object_version> }, 1, 0) AS ?ive )
  BIND ( IF (exists { ${_} crm:P46i_forms_part_of ?x . ?x a crm:E78_Curated_Holding }, 1, 0) AS ?mo )
`}const v={deepToRaw(_){const t=e=>Array.isArray(e)?e.map(i=>t(i)):T(e)||C(e)||F(e)?t(X(e)):e&&typeof e=="object"?Object.keys(e).reduce((i,r)=>(i[r]=t(e[r]),i),{}):e;return t(_)},async fetchAvailableFields({queries:_,fieldIndex:t,signal:e}){let i=structuredClone(this.deepToRaw(_.value)),r=this.fieldIndexToQueryObject(i,t);if(this.toSparql(i)){let s=`
        ${E}
        SELECT
          (MAX(?ot) as ?object_type)
          (MAX(?c) as ?classification)
          (MAX(?m) as ?material)
          (MAX(?t) as ?technique)
          (MAX(?fp) as ?find_place)
          (MAX(?pp) as ?production_place)
          (MAX(?l) as ?location)
          (MAX(?cu) as ?custody)
          (MAX(?pi) as ?provenance_institution)
          (MAX(?ppe) as ?production_person)
          (MAX(?prope) as ?provenance_person)
          (MAX(?fpe) as ?find_person)
          (MAX(?mp) as ?modification_person)
          (MAX(?dp) as ?depicted_person)
          (MAX(?dpl) as ?depicted_place)
          (MAX(?iposw) as ?is_part_of_source_work)
          (MAX(?idi) as ?is_depicted_in)
          (MAX(?d) as ?depicts)
          (MAX(?d) as ?mode_of_depiction)
          (MAX(?ica) as ?is_copy_after)
          (MAX(?hc) as ?has_copy)
          (MAX(?ibo) as ?is_based_on)
          (MAX(?ipo) as ?is_precursor_for)
          (MAX(?irt) as ?is_related_to)
          (MAX(?dub) as ?is_duplicate_of)
          (MAX(?mo) as ?part_of_module)
          (MAX(?hve) as ?has_version)
          (MAX(?ive) as ?is_version_of)
        WHERE {
          ${this.toSparql(i)}
          ${k(r.sparqlVariable)}
        }
      `,c=await d(s,{signal:e}),a=[];for(const[o,n]of Object.entries(c.results.bindings[0]))n.value==1&&a.push(o);return a}else return Object.keys(w)},async fetchOptions({queries:_,fieldIndex:t,signal:e}){let i=structuredClone(this.deepToRaw(_.value)),r=this.fieldIndexToQueryObject(i,t),s=`
      ${E}
      SELECT DISTINCT ?iri ?label WHERE {
        hint:Query hint:optimizer "None" .
        ${this.toSparql(i)}
        ${S[r.field](r.sparqlVariable,"?iri",r.queryIndex,r.rowIndex)}
        ${I(r.field)}
        ${w[r.field]}
      } ORDER BY ?label
    `,c=await d(s,{signal:e}),a=[];for(let o of c.results.bindings)a.push({value:o.iri.value.replace("https://db.antiquitatum-thesaurus.eu/",""),label:o.label.value});return a},fieldIndexToQueryObject(_,t){function e(r,s,c){for(let[a,o]of r.entries()){let n=[...s],p;if(n.length==1?p="?object":p=`?object_${n.join("_")}`,c.length==1&&c[0]==a)return o.iri=void 0,{field:o.field,sparqlVariable:p,queryIndex:s,rowIndex:a};if(o.subQueries&&o.subQueries.length){n.push(a),c&&c[0]==a&&c.shift();let l=e(o.subQueries,n,c);if(l)return l}}}let i=[...t];return e(_,[0],i)},toSparql(_,t){t===void 0&&(t=[0]);let e="";for(let[i,r]of _.entries()){let s=[...t],c;s.length==1?c="?object":c=`?object_${s.join("_")}`;let a=r.field;r.subQueries&&r.subQueries.length>0&&(a=a+"_subQueries",s.push(i));let o;r.iri&&(r.iri.length==1?o=`<${r.iri[0].value}>`:o=`?x_${i} . FILTER (${r.iri.map(n=>`?x_${i} = <${n.value}>`).join(" || ")})`),(o||r.subQueries&&r.subQueries.length>0)&&(e+=S[a](c,o,s,i)+`
`),r.subQueries&&r.subQueries.length&&(e+=this.toSparql(r.subQueries,s,i))}return e}},m=[];for(let _=0;_<256;++_)m.push((_+256).toString(16).slice(1));function L(_,t=0){return(m[_[t+0]]+m[_[t+1]]+m[_[t+2]]+m[_[t+3]]+"-"+m[_[t+4]]+m[_[t+5]]+"-"+m[_[t+6]]+m[_[t+7]]+"-"+m[_[t+8]]+m[_[t+9]]+"-"+m[_[t+10]]+m[_[t+11]]+m[_[t+12]]+m[_[t+13]]+m[_[t+14]]+m[_[t+15]]).toLowerCase()}let $;const B=new Uint8Array(16);function q(){if(!$){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");$=crypto.getRandomValues.bind(crypto)}return $(B)}const M=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),A={randomUUID:M};function U(_,t,e){if(A.randomUUID&&!t&&!_)return A.randomUUID();_=_||{};const i=_.random||(_.rng||q)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,L(i)}const O="/triplestore/sparql";async function d(_,{signal:t}={}){let e=U();try{const i=new Request(`${O}`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/sparql-results+json"},body:new URLSearchParams({query:_})});return await(await fetch(i,{signal:t})).json()}catch(i){if(i.name=="AbortError")throw await fetch(`${O}?cancelQuery&queryId=${e}`,{method:"POST"}),i;console.error("Triplestore error:",i)}}function y(_,t,e,i=""){let r="";if(_)if(_.startsWith("[{"))r=v.toSparql(JSON.parse(_));else{let a="",o=_;o=o.replaceAll('"',"'"),_.includes("+:+")&&(a=`?query ates:field "${_.split("+:+")[0]}" .`,o=_.split("+:+")[1]),r=`
      hint:Query hint:optimizer "None" .
      {
        SERVICE <http://fulltext-search-sparql-service> {
          ates:parameter ates:index "objects" .
          ?query a ates:queryObject .
          ?query ates:query "${o}" .
          ${a}
          ?object ates:output ates:iri .
          ?score ates:output ates:score .
        }
      }
      `}else r="?object a crm:E24_Physical_Human-Made_Thing .";let s="";if(t){typeof t=="string"&&(t=[t]);for(const a of t){let o=a.split("-IS")[0];if(o in h){if(a.includes("-IS_OR-")&&o!=i){let n=a.split("-IS_OR-")[1].split("-OR-");n=n.map(p=>`?${o}_iri = <${h[o].prefix}${p}>`),s+=h[o].filter_query().replaceAll("?iri",`?${o}_iri`),s+=`FILTER (${n.join(" || ")}) .`}else if(a.includes("-IS_AND-")){let n=a.split("-IS_AND-")[1].split("-AND-");for(const[p,l]of n.entries())s+=h[o].filter_query(p).replaceAll(`?iri${p}`,`<${h[o].prefix}${l}>`)}}if(o in j&&o!=i){let n=a.split("-IS-")[1].split(":");const p=R(n[1]),l=R(n[3]);s+=j[o].replaceAll("?timespan",`?${o}_timespan`).replaceAll("?date_start",`?${o}_start`).replaceAll("?date_end",`?${o}_end`),s+=`FILTER (
          ( ?${o}_start <= "${p}"^^xsd:date && ?${o}_end >= "${l}"^^xsd:date)
          ||
          ( ?${o}_start >= "${p}"^^xsd:date && ?${o}_start <= "${l}"^^xsd:date)
          ||
          ( ?${o}_end >= "${p}"^^xsd:date && ?${o}_end <= "${l}"^^xsd:date)
        ).`}}}let c="";return e&&(c=`?object crm:P46i_forms_part_of <object/${e}> .`),r+c+s}const W={async get_resource(_){let t=`
    SELECT * WHERE {
      {
        <${_}> ?p_outgoing ?o_outgoing .
      } UNION 
      {
        ?s_incoming ?p_incoming <${_}> .
      }
    }
    `,e=await d(t),i={properties:[],outgoing_links:[],incoming_links:[]};if(e)for(const r of e.results.bindings)"s_incoming"in r?i.incoming_links.push({link:r.p_incoming,node:r.s_incoming}):r.o_outgoing.type==="literal"?i.properties.push({link:r.p_outgoing,node:r.o_outgoing}):i.outgoing_links.push({link:r.p_outgoing,node:r.o_outgoing});return i},async completion_suggester(_,t){let e=`
      PREFIX ates: <http://at-es/>
      SELECT ?suggestion WHERE {
        hint:Query hint:optimizer "None" .
        SERVICE <http://fulltext-search-sparql-service> {
          ates:parameter ates:index "objects" .
          ?query a ates:completionSuggester .
          ?query ates:prefix "${_}" .
          ?suggestion ates:output ates:suggestion .
        }
      }
    `;return(await d(e,{signal:t})).results.bindings.map(r=>{var s;return(s=r.suggestion)==null?void 0:s.value})},async search({condition:_="",q:t="",qfilter:e="",filter_object_id:i=null,limit:r=60,offset:s=0,sorting:c="",signal:a=null}){let o=`
    BASE <https://db.antiquitatum-thesaurus.eu>
    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
    PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
    PREFIX at: <https://db.antiquitatum-thesaurus.eu/ontology/>
    PREFIX ates: <http://at-es/>
    SELECT DISTINCT ?object WHERE {

      ${_}

      ${y(t,e,i)}

      ${N[c].query}

    } ORDER BY ${N[c].order} LIMIT ${r} OFFSET ${s}
    `,n=await d(o,{signal:a}),l=P(n,{objects:[{iri:"object"}]});return l.objects?l.objects:[]},async get_total_count({condition:_="",q:t="",qfilter:e="",filter_object_id:i=null,signal:r=null}){let s=`
    BASE <https://db.antiquitatum-thesaurus.eu>
    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
    PREFIX at: <https://db.antiquitatum-thesaurus.eu/ontology/>
    PREFIX ates: <http://at-es/>
    SELECT (COUNT(DISTINCT ?object) as ?count) WHERE {

      ${_}

      ${y(t,e,i)}
    }
    `;return+(await d(s,{signal:r})).results.bindings[0].count.value},async get_object_hierarchy({filter_object_id:_=null,signal:t=null}){let e=`
    BASE <https://db.antiquitatum-thesaurus.eu>
    PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
    SELECT ?iri ?title (COUNT(?mid) as ?distance)
    WHERE {
      <object/${_}> crm:P46i_forms_part_of* ?mid .
      ?mid a crm:E24_Physical_Human-Made_Thing .
      ?mid crm:P46i_forms_part_of* ?iri .
      ?iri a crm:E24_Physical_Human-Made_Thing .
      ?iri crm:P1_is_identified_by ?title_iri .
      ?title_iri crm:P2_has_type <type/preferred_title> .
      ?title_iri crm:P190_has_symbolic_content ?title .

    } GROUP BY ?iri ?title ORDER BY DESC(?distance)
    `,i=await d(e,{signal:t}),r=P(i,{path:[{iri:"iri",title:"title"}]});return r.path?r.path.map(s=>({...s,id:s.iri.split("/").slice(-1)[0]})):[]},async get_object_cards_data(_,{signal:t}){let e=_.map((a,o)=>`(<${a.replace("https://db.antiquitatum-thesaurus.eu","")}> ${o})`),i=`
    BASE <https://db.antiquitatum-thesaurus.eu>
    PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
    PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
    PREFIX at: <https://db.antiquitatum-thesaurus.eu/ontology/>

    SELECT
      ?iri ?order ?main_title ?location ?custody 
      (GROUP_CONCAT(DISTINCT ?mt; SEPARATOR=";") AS ?path_title)  
      (COUNT(?child) > 0 AS ?has_children) 
      (GROUP_CONCAT(?thumbnail_urls;separator=";") AS ?thumbnail_url)
    WHERE {
      ?iri crm:P1_is_identified_by ?title .
      ?title crm:P2_has_type <type/preferred_title> .
      ?title crm:P190_has_symbolic_content ?main_title .

      OPTIONAL {
        ?iri crm:P55_has_current_location / crm:P1_is_identified_by /
        crm:P190_has_symbolic_content ?location
      }

      OPTIONAL {
        ?iri crm:P30i_custody_transferred_through ?acquisition .
        ?acquisition crm:P2_has_type <type/acquisition> .
        ?acquisition crm:P29_custody_received_by / crm:P1_is_identified_by / crm:P190_has_symbolic_content ?custody .
      }

      OPTIONAL {
        ?iri crm:P46_is_composed_of ?child .  
      }

      OPTIONAL {
        ?iri crm:P138i_has_representation ?vi . 

        ?vi at:has_sorting_index "1"^^xsd:int ;
            crm:P165i_is_incorporated_in ?image .

        ?image crm:P2_has_type <type/thumbnail> .
        ?image crm:P1_is_identified_by / crm:P190_has_symbolic_content ?thumbnail_urls .
      }

      OPTIONAL {
        { # selecting the breadcrumb path elements for each iri
          SELECT ?iri ?mt (COUNT(?m) as ?distance) 
          WHERE {
            VALUES (?iri ?order) {
              ${e.join(" ")}
            }
            ?iri crm:P46i_forms_part_of* ?m .
            ?m a crm:E24_Physical_Human-Made_Thing .
            ?m crm:P46i_forms_part_of+ ?final . 
            ?final a crm:E24_Physical_Human-Made_Thing .
            ?final crm:P1_is_identified_by ?mi .
            ?mi crm:P2_has_type <type/preferred_title> .
            ?mi crm:P190_has_symbolic_content ?mt .
          } 
          GROUP BY ?mt ?iri 
          ORDER BY DESC(?distance)}
      }
       

      VALUES (?iri ?order) {
        ${e.join(" ")}
      }
    } GROUP BY ?iri ?main_title ?location ?custody ?order ORDER BY ?order
    `,r=await d(i,{signal:t}),c=P(r,{objects:[{iri:"iri",title:"main_title",custody:"custody",location:"location",has_children:"has_children",path:"path_title",images:"thumbnail_url"}]}).objects;return c=c.map(a=>({...a,images:a.images?a.images.split(";").map(o=>({url:o})):[]})),c=c.map(a=>({...a,path:a.path?a.path.split(";").filter(o=>o).map(o=>({title:o})):[]})),c},async get_object_card_data(_){let t=`
    BASE <https://db.antiquitatum-thesaurus.eu>
    PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
    PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
    PREFIX at: <https://db.antiquitatum-thesaurus.eu/ontology/>

    SELECT ?main_title ?location ?custody ?thumbnail_urls ?path_title ?has_children
    WHERE {
      {
        <${_}> crm:P1_is_identified_by ?title .
        ?title crm:P2_has_type <type/preferred_title> .
        ?title crm:P190_has_symbolic_content ?main_title .

        OPTIONAL {
        <${_}> crm:P55_has_current_location / crm:P1_is_identified_by /
          crm:P190_has_symbolic_content ?location
        }

        OPTIONAL {
        <${_}/acquisition>  crm:P29_custody_received_by /
          crm:P1_is_identified_by / crm:P190_has_symbolic_content ?custody
        }
      }
      
      UNION {
        <${_}> crm:P138i_has_representation ?vi . 

        ?vi at:has_sorting_index "1"^^xsd:int ;
            crm:P165i_is_incorporated_in ?image .

        ?image crm:P2_has_type <type/thumbnail> .
        ?image crm:P1_is_identified_by / crm:P190_has_symbolic_content ?thumbnail_urls .
      }

      UNION {
        SELECT ?path_title (COUNT(?mid) as ?distance) WHERE {
          <${_}> crm:P46i_forms_part_of* ?mid .
          ?mid a crm:E24_Physical_Human-Made_Thing .
          ?mid crm:P46i_forms_part_of+ ?final .
          ?final a crm:E24_Physical_Human-Made_Thing .
          ?final crm:P1_is_identified_by ?title_path_iri .
          ?title_path_iri crm:P2_has_type <type/preferred_title> .
          ?title_path_iri crm:P190_has_symbolic_content ?path_title .
        } GROUP BY ?path_title ORDER BY DESC(?distance)
      }

      UNION {
        SELECT (COUNT(?child) > 0 as ?has_children)
        WHERE {
          <${_}> crm:P46_is_composed_of ?child .
        }
      }
    }
    `,e=await d(t);return P(e,{title:"main_title",custody:"custody",location:"location",path:[{title:"path_title"}],images:[{url:"thumbnail_urls"}],has_children:"has_children"})},async get_depicts_data({iri:_=null,signal:t=null}){let e=`
    BASE <https://db.antiquitatum-thesaurus.eu>
    PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
    PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
    PREFIX at: <https://db.antiquitatum-thesaurus.eu/ontology/>

    SELECT ?obj (SAMPLE(?thumbnail_urls) as ?thumbnail) WHERE {
      <${_}> crm:P01i_is_domain_of ?depicts .
      ?depicts a crm:PC62_depicts .
      ?depicts crm:P02_has_range ?obj .
      OPTIONAL { 
        ?obj crm:P108i_was_produced_by ?production .
        ?production crm:P4_has_time-span / crm:P82a_begin_of_the_beginning ?date_from .
        ?production crm:P4_has_time-span / crm:P82b_end_of_the_end ?date_to .
      }

      ?obj crm:P1_is_identified_by ?title_iri .
      ?title_iri crm:P2_has_type <type/preferred_title> .
      ?title_iri crm:P190_has_symbolic_content ?title .
      
      OPTIONAL {
        ?obj crm:P138i_has_representation ?vi . 

        ?vi at:has_sorting_index "1"^^xsd:int ;
            crm:P165i_is_incorporated_in ?image .

        ?image crm:P2_has_type <type/thumbnail> .
        ?image crm:P1_is_identified_by / crm:P190_has_symbolic_content ?thumbnail_urls .
      }
    }
    GROUP BY ?obj
    ORDER BY (bound(?date_to)) (bound(?date_from)) ?date_to ?date_from ?title
    `,i=await d(e,{signal:t}),s=P(i,{objects:[{iri:"obj",images:[{url:"thumbnail"}]}]});return"objects"in s?s.objects:[]},async get_depicted_data({iri:_=null,signal:t=null}){let e=`
    BASE <https://db.antiquitatum-thesaurus.eu>
    PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
    PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
    PREFIX at: <https://db.antiquitatum-thesaurus.eu/ontology/>
    
    SELECT ?obj (SAMPLE(?thumbnail_urls) as ?thumbnail) WHERE {
      ?depicts crm:P02_has_range <${_}> .
      ?depicts a crm:PC62_depicts .
      ?obj crm:P01i_is_domain_of ?depicts .

      ?obj crm:P46i_forms_part_of* ?final .
      ?final a crm:E24_Physical_Human-Made_Thing .
      ?final crm:P108i_was_produced_by ?production .
      ?production crm:P4_has_time-span / crm:P82a_begin_of_the_beginning ?date_from .
      ?production crm:P4_has_time-span / crm:P82b_end_of_the_end ?date_to .
        
      FILTER NOT EXISTS {
        # ignore all following after the first dated final
        ?final crm:P46i_forms_part_of+ ?x .
        ?x a crm:E24_Physical_Human-Made_Thing .
      }
      
      ?obj crm:P1_is_identified_by ?title_iri .
      ?title_iri crm:P2_has_type <type/preferred_title> .
      ?title_iri crm:P190_has_symbolic_content ?title .
      
      OPTIONAL {
        ?obj crm:P138i_has_representation ?vi . 

        ?vi at:has_sorting_index "1"^^xsd:int ;
           crm:P165i_is_incorporated_in ?image .

        ?image crm:P2_has_type <type/thumbnail> .
        ?image crm:P1_is_identified_by / crm:P190_has_symbolic_content ?thumbnail_urls .
      }
    }
    GROUP BY ?obj
    ORDER BY (bound(?date_to)) (bound(?date_from)) ?date_to ?date_from ?title_iri
    `,i=await d(e,{signal:t}),s=P(i,{objects:[{iri:"obj",images:[{url:"thumbnail"}]}]});return"objects"in s?s.objects:[]},async get_term_aggregation({q:_="",qfilter:t="",filter_object_id:e=null,field:i=null,signal:r=null}){let s=`
    BASE <https://db.antiquitatum-thesaurus.eu>
    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
    PREFIX at: <https://db.antiquitatum-thesaurus.eu/ontology/>
    PREFIX ates: <http://at-es/>
    SELECT ?iri ?label (COUNT(DISTINCT ?object) as ?count) WHERE {
      
      ${y(_,t,e,i)}

      ${h[i].aggregation_query}

      ${i=="mode_of_depiction"?'FILTER (LANG(?label) = "de") .':""}

    } GROUP BY ?iri ?label ORDER BY DESC(?count) ?label
    `,c=await d(s,{signal:r}),o=P(c,{results:[{iri:"iri",label:"label",count:"count"}]});return o.results?o.results:[]},async get_date_aggregation({q:_="",qfilter:t="",filter_object_id:e=null,field:i=null,signal:r=null}){let s=`
    BASE <https://db.antiquitatum-thesaurus.eu>
    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
    PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
    PREFIX at: <https://db.antiquitatum-thesaurus.eu/ontology/>
    PREFIX ates: <http://at-es/>
    SELECT ?mid WHERE {
      
      ${y(_,t,e,i)}

      ${j[i]}

      BIND(REPLACE(STR(?date_start), "(\\\\d+)-\\\\d+-\\\\d+", "$1") AS ?year_start)
      BIND(REPLACE(STR(?date_end), "(\\\\d+)-\\\\d+-\\\\d+", "$1") AS ?year_end)
      BIND ( ROUND ((xsd:integer(?year_start) + xsd:integer(?year_end))/2) as ?mid)

    }
    `;return(await d(s,{signal:r})).results.bindings.map(a=>parseInt(a.mid.value))}};function R(_){return _>=0?_.padStart(4,"0"):"-"+_.replace("-","").padStart(4,"0")}let N={relevance:{query:`?object crm:P1_is_identified_by ?title .
    ?title crm:P2_has_type <type/preferred_title> .
    ?title crm:P190_has_symbolic_content ?main_title .
    `,order:"DESC(?score) DESC(?main_title)"},recently_added:{query:`OPTIONAL{
      ?object crm:P67i_is_referred_to_by ?cataloging .
      ?cataloging crm:P2_has_type <type/online_document> .
      ?cataloging crm:P94i_was_created_by / crm:P4_has_time-span / crm:P82b_end_of_the_end ?create_date .
    }
    BIND(bound(?create_date) as ?date_exists)
    `,order:"DESC(?date_exists) DESC(?create_date)"},title:{query:`?object crm:P1_is_identified_by ?title .
    ?title crm:P2_has_type <type/preferred_title> .
    ?title crm:P190_has_symbolic_content ?main_title .
    # fix sorting for e.g. 52, 52+, 52*, 52**
    BIND(REPLACE(?main_title, "[^\\\\d+*]", "") AS ?sort_title_num)
    `,order:"ASC(?sort_title_num)  ASC(?main_title)"},production_date_asc:{query:`
    OPTIONAL {
      ?object at:is_part_of_source_work ?father .
      ?father crm:P108i_was_produced_by ?father_prod .
      ?father_prod crm:P4_has_time-span ?father_prod_timespan . 
      ?father_prod_timespan crm:P82a_begin_of_the_beginning ?father_date_from .
    }
    OPTIONAL {
      ?object crm:P108i_was_produced_by ?prod .
      ?prod crm:P4_has_time-span ?prod_timespan . 
      ?prod_timespan crm:P82a_begin_of_the_beginning ?prod_date_start .
    }
    BIND(bound(?prod_date_start) as ?date_exists)
    ?object crm:P1_is_identified_by ?title .
    ?title crm:P2_has_type <type/preferred_title> .
    ?title crm:P190_has_symbolic_content ?main_title .
    `,order:"DESC(?date_exists) ASC(?father_date_from) ASC(?prod_date_start) ASC(?main_title)"},production_date_desc:{query:`
    OPTIONAL {
      ?object at:is_part_of_source_work ?father .
      ?father crm:P108i_was_produced_by ?father_prod .
      ?father_prod crm:P4_has_time-span ?father_prod_timespan . 
      ?father_prod_timespan crm:P82b_end_of_the_end ?father_date_end .
    }
    OPTIONAL {
      ?object crm:P108i_was_produced_by ?prod .
      ?prod crm:P4_has_time-span ?prod_timespan . 
      ?prod_timespan crm:P82b_end_of_the_end ?prod_date_end .
    }
    BIND(bound(?prod_date_end) as ?date_exists)
    ?object crm:P1_is_identified_by ?title .
    ?title crm:P2_has_type <type/preferred_title> .
    ?title crm:P190_has_symbolic_content ?main_title .
    `,order:"DESC(?date_exists) DESC(?father_date_end) DESC(?prod_date_end) ASC(?main_title)"},find_date_asc:{query:`OPTIONAL {
      ?object crm:O19i_was_objectencountered_at ?find .
      ?find crm:P4_has_time-span ?find_timespan . 
      ?find_timespan crm:P82a_begin_of_the_beginning ?find_date_start .
    }
    BIND(bound(?find_date_start) as ?date_exists)
    ?object crm:P1_is_identified_by ?title .
    ?title crm:P2_has_type <type/preferred_title> .
    ?title crm:P190_has_symbolic_content ?main_title .
    `,order:"DESC(?date_exists) ASC(?find_date_start) ASC(?main_title)"},find_date_desc:{query:`OPTIONAL {
      ?object crm:O19i_was_objectencountered_at ?find .
      ?find crm:P4_has_time-span ?find_timespan . 
      ?find_timespan crm:P82b_end_of_the_end ?find_date_end .
    }
    BIND(bound(?find_date_end) as ?date_exists)
    ?object crm:P1_is_identified_by ?title .
    ?title crm:P2_has_type <type/preferred_title> .
    ?title crm:P190_has_symbolic_content ?main_title .
    `,order:"DESC(?date_exists) DESC(?find_date_end) ASC(?main_title)"}},h={object_type:{aggregation_query:`
      ?object crm:P2_has_type ?iri .
      ?iri crm:P2_has_type <type/object_type> .
      ?iri rdfs:label ?label .
    `,filter_query:(_="")=>`
      ?object crm:P2_has_type ?iri${_} .
    `,prefix:"type/"},classification:{aggregation_query:`
      ?object crm:P2_has_type ?iri .
      ?iri crm:P2_has_type <type/classification> .
      ?iri rdfs:label ?label .
    `,filter_query:(_="")=>`
      ?object crm:P2_has_type ?iri${_} .
    `,prefix:"type/"},material:{aggregation_query:`
      ?object crm:P45_consists_of ?iri .
      ?iri rdfs:label ?label .
    `,filter_query:(_="")=>`
      ?object crm:P45_consists_of ?iri${_} .
    `,prefix:"material/"},technic:{aggregation_query:`
      ?object crm:P108i_was_produced_by ?production .
      ?production crm:P32_used_general_technique ?iri .
      ?iri rdfs:label ?label .
    `,filter_query:(_="")=>`
      ?object crm:P108i_was_produced_by ?production .
      ?production crm:P32_used_general_technique ?iri${_} .
    `,prefix:"type/"},mode_of_depiction:{aggregation_query:`
      ?object crm:P01i_is_domain_of ?depicts .
      ?depicts a crm:PC62_depicts .
    	?depicts crm:P62.1_mode_of_depiction ?iri .
      ?iri rdfs:label ?label .
    `,filter_query:(_="")=>`
      ?object crm:P01i_is_domain_of ?depicts .
      ?depicts a crm:PC62_depicts .
      ?depicts crm:P62.1_mode_of_depiction ?iri${_} .
    `,prefix:"type/"},custody:{aggregation_query:`
      ?object crm:P30i_custody_transferred_through ?transfer_of_custody .
      ?transfer_of_custody crm:P2_has_type <type/acquisition> .
      ?transfer_of_custody crm:P29_custody_received_by ?iri .
      ?iri crm:P1_is_identified_by / crm:P190_has_symbolic_content ?label
    `,filter_query:(_="")=>`
      ?object crm:P30i_custody_transferred_through ?transfer_of_custody${_} .
      ?transfer_of_custody${_} crm:P2_has_type <type/acquisition> .
      ?transfer_of_custody${_} crm:P29_custody_received_by ?iri${_} .
    `,prefix:"actor/"},location:{aggregation_query:`
      ?object crm:P55_has_current_location ?iri .
      ?iri crm:P1_is_identified_by / crm:P190_has_symbolic_content ?label .
    `,filter_query:(_="")=>`
      ?object crm:P55_has_current_location ?iri${_} .
    `,prefix:"place/"},production_person:{aggregation_query:`
      ?object crm:P108i_was_produced_by / crm:P01i_is_domain_of ?pp_role .
      ?pp_role a crm:PC14_carried_out_by .
      ?pp_role crm:P02_has_range ?iri .
      ?iri crm:P1_is_identified_by / crm:P190_has_symbolic_content ?label .
    `,filter_query:(_="")=>`
      ?object crm:P108i_was_produced_by / crm:P01i_is_domain_of ?pp_role${_} .
      ?pp_role${_} a crm:PC14_carried_out_by .
      ?pp_role${_} crm:P02_has_range ?iri${_} .
    `,prefix:"person/"},production_place:{aggregation_query:`
      ?object crm:P108i_was_produced_by ?production .
      ?production crm:P7_took_place_at ?iri .
      ?iri crm:P1_is_identified_by / crm:P190_has_symbolic_content ?label .
    `,filter_query:(_="")=>`
      ?object crm:P108i_was_produced_by ?production .
      ?production crm:P7_took_place_at ?iri${_} .
    `,prefix:"place/"},modification_person:{aggregation_query:`
      ?object crm:P31i_was_modified_by / crm:P01i_is_domain_of ?mp_role .
      ?mp_role a crm:PC14_carried_out_by .
      ?mp_role crm:P02_has_range ?iri .
      ?iri crm:P1_is_identified_by / crm:P190_has_symbolic_content ?label .
    `,filter_query:(_="")=>`
      ?object crm:P31i_was_modified_by / crm:P01i_is_domain_of ?mp_role${_} .
      ?mp_role${_} a crm:PC14_carried_out_by .
      ?mp_role${_} crm:P02_has_range ?iri${_} .
    `,prefix:"person/"},find_place:{aggregation_query:`
      ?object crm:O19i_was_objectencountered_at ?find .
      ?find crm:P7_took_place_at ?iri .
      ?iri crm:P1_is_identified_by / crm:P190_has_symbolic_content ?label .
    `,filter_query:(_="")=>`
      ?object crm:O19i_was_objectencountered_at ?find .
      ?find crm:P7_took_place_at ?iri${_} .
    `,prefix:"place/"},find_person:{aggregation_query:`
      ?object crm:O19i_was_objectencountered_at / crm:P01i_is_domain_of / crm:P02_has_range ?iri .
      ?iri crm:P1_is_identified_by / crm:P190_has_symbolic_content ?label .
    `,filter_query:(_="")=>`
      ?object crm:O19i_was_objectencountered_at / crm:P01i_is_domain_of / crm:P02_has_range ?iri${_} .
    `,prefix:"person/"},provenance_person:{aggregation_query:`
      ?object crm:P30i_custody_transferred_through ?pp_transfer_of_custody .
      ?pp_transfer_of_custody crm:P2_has_type <type/provenance> .
      ?pp_transfer_of_custody crm:P29_custody_received_by ?iri .
      ?iri a crm:E21_Person . 
      ?iri crm:P1_is_identified_by / crm:P190_has_symbolic_content ?label .
    `,filter_query:(_="")=>`
      ?object crm:P30i_custody_transferred_through ?pp_transfer_of_custody${_} .
      ?pp_transfer_of_custody${_} crm:P2_has_type <type/provenance> .
      ?pp_transfer_of_custody${_} crm:P29_custody_received_by ?iri${_} .
      ?iri${_} a crm:E21_Person . 
    `,prefix:"person/"},provenance_institution:{aggregation_query:`
      ?object crm:P30i_custody_transferred_through ?pi_transfer_of_custody .
      ?pi_transfer_of_custody crm:P2_has_type <type/provenance> .
      ?pi_transfer_of_custody crm:P29_custody_received_by ?iri .
      ?iri a crm:E39_Actor . 
      ?iri crm:P1_is_identified_by / crm:P190_has_symbolic_content ?label .
    `,filter_query:(_="")=>`
      ?object crm:P30i_custody_transferred_through ?pi_transfer_of_custody${_} .
      ?pi_transfer_of_custody${_} crm:P2_has_type <type/provenance> .
      ?pi_transfer_of_custody${_} crm:P29_custody_received_by ?iri${_} .
      ?iri${_} a crm:E39_Actor . 
    `,prefix:"actor/"},depicted_person:{aggregation_query:`
      ?object crm:P62_depicts ?iri .
      ?iri a crm:E21_Person .
      ?iri crm:P1_is_identified_by / crm:P190_has_symbolic_content ?label .
    `,filter_query:(_="")=>`
      ?object crm:P62_depicts ?iri${_} .
      ?iri${_} a crm:E21_Person .
    `,prefix:"person/"},depicted_place:{aggregation_query:`
      ?object crm:P62_depicts ?iri .
      ?iri a crm:E53_Place .
      ?iri crm:P1_is_identified_by / crm:P190_has_symbolic_content ?label .
    `,filter_query:(_="")=>`
      ?object crm:P62_depicts ?iri${_} .
      ?iri${_} a crm:E53_Place .
    `,prefix:"place/"},depicted_in_source_work:{aggregation_query:`
      ?object crm:P02i_is_range_of ?depicts .
      ?depicts a crm:PC62_depicts .
      ?depicts crm:P01_has_domain / at:is_part_of_source_work ?iri .
      ?iri crm:P1_is_identified_by ?title .
      ?title crm:P2_has_type <type/preferred_title> .
      ?title crm:P190_has_symbolic_content ?label .
    `,filter_query:(_="")=>`
      ?object crm:P02i_is_range_of / crm:P01_has_domain / at:is_part_of_source_work ?iri${_} .
    `,prefix:"object/"},is_part_of_source_work:{aggregation_query:`
      ?object at:is_part_of_source_work ?iri .
      ?iri crm:P1_is_identified_by ?title .
      ?title crm:P2_has_type <type/preferred_title> .
      ?title crm:P190_has_symbolic_content ?label .
    `,filter_query:(_="")=>`
      ?object at:is_part_of_source_work ?iri${_} .
    `,prefix:"object/"},projects:{aggregation_query:`
      ?object crm:P46i_forms_part_of ?iri .
      ?iri a crm:E78_Curated_Holding .
      ?iri crm:P2_has_type <type/project> .
      ?iri crm:P1_is_identified_by / crm:P190_has_symbolic_content ?label .
    `,filter_query:(_="")=>`
      ?object crm:P46i_forms_part_of ?iri${_} .
    `,prefix:"project/"},modules:{aggregation_query:`
      ?object crm:P46i_forms_part_of ?iri .
      ?iri a crm:E78_Curated_Holding .
      ?iri crm:P2_has_type <type/module> .
      ?iri crm:P1_is_identified_by / crm:P190_has_symbolic_content ?label .
    `,filter_query:(_="")=>`
      ?object crm:P46i_forms_part_of ?iri${_} .
    `,prefix:"module/"}},j={production_dating:`
    ?object crm:P108i_was_produced_by ?production .
    ?production crm:P4_has_time-span ?timespan .
    ?timespan crm:P82a_begin_of_the_beginning ?date_start .
    ?timespan crm:P82b_end_of_the_end ?date_end .
    `,find_dating:`
    ?object crm:O19i_was_objectencountered_at ?find .
    ?find crm:P4_has_time-span ?timespan .
    ?timespan crm:P82a_begin_of_the_beginning ?date_start .
    ?timespan crm:P82b_end_of_the_end ?date_end .
  `,modification_dating:`
    ?object crm:P31i_was_modified_by ?modification .
    ?modification crm:P4_has_time-span ?timespan .
    ?timespan crm:P82a_begin_of_the_beginning ?date_start .
    ?timespan crm:P82b_end_of_the_end ?date_end .
  `,acquisition_dating:`
    ?object crm:P30i_custody_transferred_through ?acquisition .
    ?acquisition crm:P4_has_time-span ?timespan .
    ?timespan crm:P82a_begin_of_the_beginning ?date_start .
    ?timespan crm:P82b_end_of_the_end ?date_end .
  `};export{d as a,P as c,H as p,v as q,W as t};