@ulb-darmstadt/shacl-form 3.1.0 → 3.2.0

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.
package/dist/config.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { NamedNode, Store } from 'n3';
2
2
  import { Term } from '@rdfjs/types';
3
- import { ClassInstanceProvider, RdfUrlResolver, ResourceLinkProvider } from './plugin';
4
- import { Theme } from './theme';
5
- import { ShaclNodeTemplate } from './node-template';
6
- import { ShaclPropertyTemplate } from './property-template';
3
+ import { ClassInstanceProvider, RdfUrlResolver, ResourceLinkProvider } from './plugin.js';
4
+ import type { QueryFacetProvider } from './query/index.js';
5
+ import { Theme } from './theme.js';
6
+ import { ShaclNodeTemplate } from './node-template.js';
7
+ import { ShaclPropertyTemplate } from './property-template.js';
7
8
  export declare class ElementAttributes {
8
9
  shapes: string | null;
9
10
  shapesUrl: string | null;
@@ -17,7 +18,11 @@ export declare class ElementAttributes {
17
18
  valuesSubject: string | null;
18
19
  valuesNamespace: string;
19
20
  valuesGraph: string | null;
21
+ /**
22
+ * @deprecated Use mode='view' instead
23
+ */
20
24
  view: string | null;
25
+ mode: string | null;
21
26
  language: string | null;
22
27
  loading: string;
23
28
  proxy: string | null;
@@ -36,7 +41,8 @@ export declare class Config {
36
41
  classInstanceProvider: ClassInstanceProvider | undefined;
37
42
  rdfUrlResolver: RdfUrlResolver | undefined;
38
43
  resourceLinkProvider: ResourceLinkProvider | undefined;
39
- editMode: boolean;
44
+ queryFacetProvider: QueryFacetProvider | undefined;
45
+ mode: 'edit' | 'view' | 'query';
40
46
  languages: string[];
41
47
  lists: Record<string, Term[]>;
42
48
  groups: string[];
@@ -51,6 +57,7 @@ export declare class Config {
51
57
  validator: any;
52
58
  providedConformingResourceIds: Record<string, Set<string>>;
53
59
  providedResources: Record<string, string>;
60
+ providedResourceLabels: Record<string, string>;
54
61
  constructor(form: HTMLElement);
55
62
  reset(): void;
56
63
  updateAttributes(elem: HTMLElement): void;
@@ -65,5 +72,7 @@ export declare class Config {
65
72
  get theme(): Theme;
66
73
  set theme(theme: Theme);
67
74
  get store(): Store;
75
+ get editMode(): boolean;
76
+ get queryMode(): boolean;
68
77
  set store(store: Store);
69
78
  }
@@ -26,3 +26,6 @@ export declare const SHACL_PREDICATE_TARGET_CLASS: import("n3").NamedNode<string
26
26
  export declare const SHACL_PREDICATE_NODE_KIND: import("n3").NamedNode<string>;
27
27
  export declare const XSD_DATATYPE_STRING: import("n3").NamedNode<string>;
28
28
  export declare const XSD_DATATYPE_BOOLEAN: import("n3").NamedNode<string>;
29
+ export declare const RANGE_DATATYPES: Set<string>;
30
+ export declare const NUMERIC_DATATYPES: Set<string>;
31
+ export declare const FRACTIONAL_DATATYPES: Set<string>;
@@ -1,8 +1,8 @@
1
1
  import { Quad } from 'n3';
2
2
  import { Term } from '@rdfjs/types';
3
- import { ShaclNode } from "./node";
4
- import { ShaclProperty } from "./property";
5
- import { Config } from './config';
3
+ import { ShaclNode } from './node.js';
4
+ import { ShaclProperty } from './property.js';
5
+ import { Config } from './config.js';
6
6
  export declare function createShaclOrConstraint(options: Term[], context: ShaclNode | ShaclProperty, config: Config): HTMLElement;
7
7
  export declare function resolveShaclOrConstraintOnProperty(subjects: Term[], value: Term, config: Config): Quad[];
8
8
  export declare function resolveShaclOrConstraintOnNode(subjects: Term[], value: Term, config: Config): Term[];
package/dist/exports.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- export type { InputListEntry, Editor } from './theme';
2
- export type { ClassInstanceProvider, RdfUrlResolver, ResourceLinkProvider } from './plugin';
3
- export { Theme } from './theme';
4
- export { DefaultTheme } from './theme.default';
5
- export { Config } from './config';
6
- export { Plugin, registerPlugin } from './plugin';
7
- export { findLabel } from './util';
8
- export { mappers as propertyMappers, ShaclPropertyTemplate } from './property-template';
9
- export * from './graph-loader';
10
- export * from './rdf-loader';
1
+ export type { InputListEntry, Editor } from './theme.js';
2
+ export type { ClassInstanceProvider, RdfUrlResolver, ResourceLinkProvider } from './plugin.js';
3
+ export { Theme } from './theme.js';
4
+ export { DefaultTheme } from './theme.default.js';
5
+ export { Config } from './config.js';
6
+ export { Plugin, registerPlugin } from './plugin.js';
7
+ export { findLabel } from './util.js';
8
+ export { mappers as propertyMappers, ShaclPropertyTemplate } from './property-template.js';
9
+ export * from './query/index.js';
10
+ export * from './graph-loader.js';
11
+ export * from './rdf-loader.js';
package/dist/form.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { ShaclNode } from './node';
2
- import { Config } from './config';
3
- import { ClassInstanceProvider, RdfUrlResolver, ResourceLinkProvider, Plugin } from './plugin';
1
+ import { ShaclNode } from './node.js';
2
+ import { Config } from './config.js';
3
+ import { ClassInstanceProvider, RdfUrlResolver, ResourceLinkProvider, Plugin } from './plugin.js';
4
4
  import { Store } from 'n3';
5
- import { Theme } from './theme';
6
- export * from './exports';
5
+ import { Theme } from './theme.js';
6
+ import type { Query, QueryFacetProvider } from './query/index.js';
7
+ export * from './exports.js';
7
8
  export declare const initTimeout = 200;
8
9
  export interface ValidationReport {
9
10
  conforms: boolean;
@@ -16,20 +17,25 @@ export declare class ShaclForm extends HTMLElement {
16
17
  form: HTMLFormElement;
17
18
  initDebounceTimeout: ReturnType<typeof setTimeout> | undefined;
18
19
  private styleElement;
20
+ private queryController?;
19
21
  constructor();
20
22
  connectedCallback(): void;
21
23
  attributeChangedCallback(): void;
22
24
  private initialize;
23
25
  private ensureRenderRoot;
24
26
  private applyStyles;
25
- serialize(format?: string, graph?: Store<import("@rdfjs/types").Quad, import("n3").Quad, import("@rdfjs/types").Quad, import("@rdfjs/types").Quad>): string;
27
+ serialize(format?: string, graph?: Store): string;
26
28
  toRDF(graph?: Store<import("@rdfjs/types").Quad, import("n3").Quad, import("@rdfjs/types").Quad, import("@rdfjs/types").Quad>): Store;
27
29
  registerPlugin(plugin: Plugin): void;
28
30
  setTheme(theme: Theme): void;
29
31
  setClassInstanceProvider(provider: ClassInstanceProvider): void;
30
32
  setRdfUrlResolver(provider: RdfUrlResolver): void;
31
33
  setResourceLinkProvider(provider: ResourceLinkProvider): void;
34
+ setQueryFacetProvider(provider: QueryFacetProvider): void;
35
+ getQuery(): Query;
36
+ refreshQueryFacets(): void;
32
37
  validate(ignoreEmptyValues?: boolean): Promise<ValidationReport>;
38
+ private assertNotQueryMode;
33
39
  private createValidationErrorDisplay;
34
40
  private findRootShaclShapeSubject;
35
41
  private removeFromDataGraph;
@@ -1,6 +1,6 @@
1
1
  import { Store, Quad, NamedNode } from 'n3';
2
- import { ClassInstanceProvider, RdfUrlResolver } from './plugin';
3
- export { rdfCache, prefixes, fetchRDF, parseRDF } from './rdf-loader';
2
+ import { ClassInstanceProvider, RdfUrlResolver } from './plugin.js';
3
+ export { rdfCache, prefixes, fetchRDF, parseRDF } from './rdf-loader.js';
4
4
  export interface LoaderAttributes {
5
5
  loadOwlImports: boolean;
6
6
  proxy?: string | null;
package/dist/group.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { Config } from './config';
1
+ import { Config } from './config.js';
2
2
  export declare function createShaclGroup(groupSubject: string, config: Config): HTMLElement;
package/dist/index.js CHANGED
@@ -1,97 +1,16 @@
1
- import{DataFactory as e,Literal as t,NamedNode as n,Store as r,StreamParser as i,Writer as a}from"n3";import{RdfXmlParser as o}from"rdfxml-streaming-parser";import s from"jsonld";import{RokitButton as c,RokitCollapsible as l,RokitDialog as u,RokitInput as d,RokitSelect as f,RokitTextArea as p}from"@ro-kit/ui-widgets";import{v4 as m}from"uuid";import{Validator as ee}from"shacl-engine";var h=`http://www.w3.org/ns/shacl#`,te=`http://datashapes.org/dash#`,ne=`http://www.w3.org/2001/XMLSchema#`,re=`http://www.w3.org/1999/02/22-rdf-syntax-ns#`,ie=`http://www.w3.org/2000/01/rdf-schema#`,ae=`http://www.w3.org/ns/oa#`,oe=`http://purl.org/dc/terms/`,g=e.namedNode(`loaded-shapes`),_=e.namedNode(`loaded-data`),v=e.namedNode(`http://www.w3.org/1999/02/22-rdf-syntax-ns#type`),se=e.namedNode(`http://www.w3.org/1999/02/22-rdf-syntax-ns#langString`),y=e.namedNode(`http://purl.org/dc/terms/conformsTo`),ce=e.namedNode(`http://www.w3.org/2000/01/rdf-schema#subClassOf`),b=e.namedNode(`http://www.w3.org/2002/07/owl#imports`),le=e.namedNode(`http://www.w3.org/2004/02/skos/core#broader`),ue=e.namedNode(`http://www.w3.org/2004/02/skos/core#narrower`),x=e.namedNode(`http://www.w3.org/ns/shacl#NodeShape`),S=e.namedNode(`http://www.w3.org/ns/shacl#IRI`),C=e.namedNode(`http://www.w3.org/ns/shacl#property`),w=e.namedNode(`http://www.w3.org/ns/shacl#class`),de=e.namedNode(`http://www.w3.org/ns/shacl#node`),T=e.namedNode(`http://www.w3.org/ns/shacl#targetClass`),fe=e.namedNode(`http://www.w3.org/ns/shacl#nodeKind`),pe=e.namedNode(`http://www.w3.org/2001/XMLSchema#string`),me=e.namedNode(`http://www.w3.org/2001/XMLSchema#boolean`);function E(e,t,n=h,r){let i=``,a=he(e,t,n,r);return a&&(i=a.value),i}function he(e,t,n=h,r){let i,a=n+t;if(r?.length){for(let t of r)for(let n of e)if(n.predicate.value===a){if(n.object.id.endsWith(`@${t}`))return n.object;n.object.id.indexOf(`@`)<0?i=n.object:i||=n.object}}else for(let t of e)if(t.predicate.value===a)return t.object;return i}function ge(e){e.querySelector(`.editor`)?.focus()}function D(e,t){return E(e,`prefLabel`,`http://www.w3.org/2004/02/skos/core#`,t)||E(e,`label`,`http://www.w3.org/2000/01/rdf-schema#`,t)||E(e,`title`,`http://purl.org/dc/terms/`,t)||E(e,`name`,`http://xmlns.com/foaf/0.1/`,t)}function _e(e,t,n){let r=[];for(let i of e)r.push({value:i,label:D(t.getQuads(i,null,null,null),n),children:[]});return r}function O(e,t){for(let n in t){let r=t[n];e.startsWith(r)&&(e=e.slice(r.length))}return e}function ve(e,t,n,r,i=new Set){for(let a of t.owlImports)i.has(a.id)||(i.add(a.id),r.push(...n.getSubjects(v,e,a)));t.parent&&ve(e,t.parent,n,r,i)}function ye(e,t){if(t.in){let e=t.config.lists[t.in];return _e(e?.length?e:[],t.config.store,t.config.languages)}else{let n=t.config.store.getSubjects(v,e,g);n.push(...t.config.store.getSubjects(v,e,_)),ve(e,t,t.config.store,n);let r=new Map,i=new Map;for(let e of n)r.set(e.id,{value:e,label:D(t.config.store.getQuads(e,null,null,null),t.config.languages),children:[]});for(let e of n){for(let n of t.config.store.getObjects(e,le,null))r.has(n.id)&&i.set(e.id,n.id);for(let n of t.config.store.getObjects(e,ue,null))r.has(n.id)&&i.set(n.id,e.id);for(let n of t.config.store.getObjects(e,ce,null))r.has(n.id)&&i.set(e.id,n.id)}for(let[e,t]of i.entries())r.get(t)?.children?.push(r.get(e));let a=[];for(let[e,t]of r.entries())i.has(e)||a.push(t);for(let n of t.config.store.getSubjects(ce,e,null))a.push(...ye(n,t));return a}}function k(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol===`http:`||t.protocol===`https:`}function A(e,t,n){if(t===void 0)return n;if(n===void 0)return t;let r=e.indexOf(t.language);if(r<0)return n;let i=e.indexOf(n.language);return i<0||i>r?t:n}function be(e,t){let n;for(let r of t)n=A(e,n,r);return n?n.value:``}var j=/^(-?\d{4,}-\d{2}-\d{2})(Z|[+-]\d{2}:\d{2})?$/,M=/^(-?\d{4,}-\d{2}-\d{2})T(\d{2}:\d{2})(?::(\d{2})(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?$/,xe=/^(-?\d{4,}-\d{2}-\d{2}T\d{2}:\d{2})(?::(\d{2})(\.\d+)?)?$/;function Se(e){let t=e.match(j);if(!t){let t=e.match(M);return t?{value:t[1],suffix:t[5]||``}:void 0}return{value:t[1],suffix:t[2]||``}}function Ce(e){let t=e.match(M);if(!t){let t=e.match(j);return t?{value:`${t[1]}T00:00:00`,suffix:t[2]||``}:void 0}return{value:`${t[1]}T${t[2]}:${t[3]||`00`}`,suffix:t[5]||``}}function we(e,t=``){let n=e.match(j);return n?`${n[1]}${t}`:e}function Te(e,t=``){let n=e.match(xe);return n?`${n[1]}:${n[2]||`00`}${n[3]||``}${t}`:e}function Ee(e){let t=new Set;for(let n of e.getObjects(null,w,g))t.add(n.value);for(let n of e.getObjects(null,T,g))t.add(n.value);return t}function De(e,t){return e instanceof Set?[...t].filter(t=>!e.has(t)):[...t].filter(t=>!e.includes(t))}function Oe(e,{remove:t=!1,ignoreErrors:n=!1}={}){let r={},i=n?(()=>!0):((e,t)=>{throw Error(`${e.value} ${t}`)}),a=e.getQuads(null,re+`rest`,re+`nil`,null),o=t?[...a]:[];return a.forEach(n=>{let a=[],s=!1,c,l,u=n.graph,d=n.subject;for(;d&&!s;){let t=e.getQuads(null,null,d,null),n=e.getQuads(d,null,null,null).filter(e=>!e.predicate.equals(v)),r,f=null,p=null,m=null;for(let e=0;e<n.length&&!s;e++)r=n[e],r.graph.equals(u)?c?s=i(d,`has non-list arcs out`):r.predicate.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#first`?f?s=i(d,`has multiple rdf:first arcs`):o.push(f=r):r.predicate.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#rest`?p?s=i(d,`has multiple rdf:rest arcs`):o.push(p=r):t.length?s=i(d,`can't be subject and object`):(c=r,l=`subject`):s=i(d,`not confined to single graph`);for(let e=0;e<t.length&&!s;++e)r=t[e],c?s=i(d,`can't have coreferences`):r.predicate.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#rest`?m?s=i(d,`has incoming rdf:rest arcs`):m=r:(c=r,l=`object`);f?a.unshift(f.object):s=i(d,`has no list head`),d=m&&m.subject}s?t=!1:c&&(r[c[l].value]=a)}),t&&e.removeQuads(o),r}var N={},P={};async function F(e){return`rdf`in e?L(e.rdf):e.rdfUrlResolver?L(await e.rdfUrlResolver(e.url)):I(e.url,e.proxy)}async function I(e,t){return e in N||(N[e]=(async()=>{let n=e;t&&(n=t+encodeURIComponent(e));let r=await fetch(n,{headers:{Accept:`text/turtle, application/trig, application/n-triples, application/n-quads, text/n3, application/ld+json`}});return r.ok?L(await r.text()):(console.warn(`failed fetching RDF from`,e),[])})()),N[e]}async function L(t){if(!t.trim())return[];let n=ke(t);if(n===`json`)try{t=await s.toRDF(JSON.parse(t),{format:`application/n-quads`})}catch(e){console.error(e)}let r=[];return await new Promise((a,s)=>{let c=n===`xml`?new o:new i;c.on(`data`,t=>{r.push(e.quad(t.subject,t.predicate,t.object,t.graph))}).on(`error`,e=>{s(e)}).on(`prefix`,(e,t)=>{e&&(P[e]=t)}).on(`end`,()=>{a(null)}),c.write(t),c.end()}),r}function ke(e){return/^\s*[\\[{]/.test(e)?`json`:/^\s*<\?xml/.test(e)?`xml`:`ttl`}var Ae={[`${h}name`]:(e,t)=>{let n=t;e.name=A(e.config.languages,e.name,n)},[`${h}description`]:(e,t)=>{let n=t;e.description=A(e.config.languages,e.description,n)},[`${h}path`]:(e,t)=>{e.path=t.value},[`${h}group`]:(e,t)=>{e.group=t.id},[`${h}datatype`]:(e,t)=>{e.datatype=t},[`${h}nodeKind`]:(e,t)=>{e.nodeKind=t},[`${h}minCount`]:(e,t)=>{e.minCount=parseInt(t.value)},[`${h}maxCount`]:(e,t)=>{e.maxCount=parseInt(t.value)},[`${h}minLength`]:(e,t)=>{e.minLength=parseInt(t.value)},[`${h}maxLength`]:(e,t)=>{e.maxLength=parseInt(t.value)},[`${h}minInclusive`]:(e,t)=>{e.minInclusive=parseInt(t.value)},[`${h}maxInclusive`]:(e,t)=>{e.maxInclusive=parseInt(t.value)},[`${h}minExclusive`]:(e,t)=>{e.minExclusive=parseInt(t.value)},[`${h}maxExclusive`]:(e,t)=>{e.maxExclusive=parseInt(t.value)},[`${h}pattern`]:(e,t)=>{e.pattern=t.value},[`${h}order`]:(e,t)=>{e.order=parseInt(t.value)},[`${te}singleLine`]:(e,t)=>{e.singleLine=t.value===`true`},[`${te}readonly`]:(e,t)=>{e.readonly=t.value===`true`},[`${ae}styleClass`]:(e,t)=>{e.cssClass=t.value},[`${h}in`]:(e,t)=>{e.in=t.value},[`${h}languageIn`]:(e,t)=>{e.languageIn=e.config.lists[t.value],e.datatype=se},[`${h}defaultValue`]:(e,t)=>{e.defaultValue=t},[`${h}hasValue`]:(e,t)=>{e.hasValue=t},[`${h}node`]:(e,t)=>{e.node=t,e.nodeShapes.add(e.config.getNodeTemplate(t,e))},[`${h}and`]:(e,t)=>{e.and=t.value;let n=e.config.lists[e.and];if(n?.length)for(let t of n)e.nodeShapes.add(e.config.getNodeTemplate(t,e))},[`${h}qualifiedValueShape`]:(e,t)=>{let n=e.config.getNodeTemplate(t,e);e.qualifiedValueShape=n,e.nodeShapes.add(n)},[`${h}qualifiedMinCount`]:(e,t)=>{e.qualifiedMinCount=parseInt(t.value)},[`${h}qualifiedMaxCount`]:(e,t)=>{e.qualifiedMaxCount=parseInt(t.value)},[b.id]:(e,t)=>{e.owlImports.add(t)},[w.id]:(e,t)=>{e.class=t;let n=e.config.store.getSubjects(T,t,null);n.length>0&&(e.node=n[0])},[`${h}or`]:(e,t)=>{let n=e.config.lists[t.value];n?.length?e.or=n:console.error(`list for sh:or not found:`,t.value,`existing lists:`,e.config.lists)},[`${h}xone`]:(e,t)=>{let n=e.config.lists[t.value];n?.length?e.xone=n:console.error(`list for sh:xone not found:`,t.value,`existing lists:`,e.config.lists)}},R=class{constructor(e,t){this.label=``,this.nodeShapes=new Set,this.owlImports=new Set,this.id=e,this.parent=t,this.config=t.config,this.config.registerPropertyTemplate(this),B(this,this.config.store.getQuads(e,null,null,null))}};function z(e){return Math.max(e.minCount??0,e.qualifiedMinCount??0)}function je(e){return Math.min(e.maxCount??2**53-1,e.qualifiedMaxCount??2**53-1)}function Me(e){let t=Object.assign({},e);return t.nodeShapes=new Set(e.nodeShapes),t.owlImports=new Set(e.owlImports),e.languageIn&&(t.languageIn=[...e.languageIn]),e.or&&(t.or=[...e.or]),e.xone&&(t.xone=[...e.xone]),t}function B(e,t){for(let n of t)Ae[n.predicate.id]?.call(e,e,n.object);return e.label=e.name?.value||D(t,e.config.languages),e.label||=e.path?O(e.path,P):`unknown`,e}function Ne(e,t){let n=t,r=e;for(let e in t)if(e!==`parent`&&e!==`config`&&e!==`id`){let t=n[e];if(t!==void 0&&t!==``)if(Array.isArray(t)){let n=r[e];Array.isArray(n)?n.push(...t):r[e]=[...t]}else if(t instanceof Set&&t.size){let n=r[e];r[e]=new Set([...n instanceof Set?n:[],...t])}else r[e]=t}}function Pe(e,t,n){let r=document.createElement(`div`);r.classList.add(`shacl-or-constraint`),r.setAttribute(`part`,`constraint`);let i=[];if(t instanceof X){let a=[],o=!1;e.length&&(o=n.store.countQuads(e[0],C,null,null)>0);for(let r=0;r<e.length;r++)if(o){let o=n.store.getObjects(e[r],C,null),s=[],c=``;for(let e of o){let r=new G(n.getPropertyTemplate(e,t.template),t);s.push(r),c+=(c.length>0?` / `:``)+r.template.label}a.push(s),i.push({label:c,value:r.toString()})}else{let o=e[r],s=new G(n.getPropertyTemplate(o,t.template),t);a.push([s]),i.push({label:s.template.label,value:r.toString()})}let s=n.theme.createListEditor(`Please choose`,null,!1,i);s.setAttribute(`part`,`constraint-editor`);let c=s.querySelector(`.editor`);c.onchange=async()=>{if(c.value){let e=a[parseInt(c.value)],n;if(e.length){for(let n of e)await n.bindValues(t.nodeId,!1);n=e[0],r.replaceWith(e[0]),n.updateControls()}for(let t=1;t<e.length;t++)n.after(e[t]),n=e[t],n.updateControls()}},r.appendChild(s)}else{let a=[];for(let t=0;t<e.length;t++){let r=n.store.getQuads(e[t],null,null,null);if(r.length){a.push(r);let e=D(r,n.languages);for(let t of r)t.predicate.equals(de)&&(e=D(n.store.getQuads(t.object,null,null,null),n.languages));i.push({label:e||O(r[0].predicate.value,P)+` = `+O(r[0].object.value,P),value:t.toString()})}}let o=n.theme.createListEditor(t.template.label+`?`,null,!1,i,t.template);o.setAttribute(`part`,`constraint-editor`);let s=o.querySelector(`.editor`);s.onchange=async()=>{if(s.value){let e=await K(B(Me(t.template),a[parseInt(s.value)]),void 0,!0),n=e.querySelector(`:scope > label`);n&&n.classList.add(`persistent`),r.replaceWith(e)}},r.appendChild(o)}return r}function Fe(e,t,n){if(t.termType===`Literal`){let r=t.datatype;for(let t of e){let e=n.store.getQuads(t,null,null,null);for(let t of e)if(t.predicate.value===`http://www.w3.org/ns/shacl#datatype`&&t.object.equals(r))return e}}else{let r=n.store.getObjects(t,v,null);for(let t of e){let e=n.store.getQuads(t,null,null,null);for(let t of e)if(r.length>0){if(t.predicate.value===`http://www.w3.org/ns/shacl#node`){for(let i of r)if(n.store.getQuads(t.object,T,i,null).length>0)return e}if(t.predicate.equals(w)){for(let n of r)if(t.object.equals(n))return e}}else if(t.predicate.equals(fe)&&t.object.equals(S))return e}}return console.error(`couldn't resolve sh:or/sh:xone on property for value`,t),[]}function Ie(e,t,n){for(let r of e){let e=!1,i=n.store.getObjects(r,C,null);for(let r of i){let i=n.store.getObjects(r,`${h}path`,null);for(let r of i)if(e=n.store.countQuads(t,r,null,null)>0,e)break}if(e)return i}return console.error(`couldn't resolve sh:or/sh:xone on node for value`,t),[]}var Le=`:host {
2
- --shacl-font-family: inherit;
3
- --shacl-font-size: 14px;
4
- --shacl-text-color: #333;
5
- --shacl-muted-color: #555;
6
- --shacl-border-color: #DDD;
7
- --shacl-bg: #FFF;
8
- --shacl-row-alt-bg: #F8F8F8;
9
- --shacl-error-color: #C00;
10
- --shacl-label-width: 8em;
11
- }
12
- form { display:block; --label-width: var(--shacl-label-width, 8em); --caret-size: 10px; font-family: var(--shacl-font-family); font-size: var(--shacl-font-size); color: var(--shacl-text-color); background-color: var(--shacl-bg); }
13
- form.mode-edit { padding-left: 1em; }
14
- form, form * { box-sizing: border-box; }
15
- shacl-node, .collapsible::part(content) { display: flex; flex-direction: column; width: 100%; position: relative; }
16
- shacl-node .remove-button { margin-top: 1px; }
17
- shacl-node .add-button-wrapper { display: flex; width: 100%; justify-content: flex-end; gap: 20px; padding-right: 24px; color: var(--shacl-muted-color); font-size: 14px; }
18
- shacl-node .add-button::part(button)::before { content: '+ ' }
19
- shacl-node .link-button::part(button)::before { content: '🔗 '; font-size: 10px; }
20
- shacl-node h1 { font-size: 16px; border-bottom: 1px solid #AAA; margin-top: 4px; color: var(--shacl-muted-color); }
21
- shacl-property:not(:has(>.collapsible)), shacl-property>.collapsible::part(content) { display: flex; flex-direction: column; align-items: end; position: relative; }
22
- shacl-property:not(.may-add) > .add-button-wrapper, shacl-property:not(.may-add) > .collapsible > .add-button-wrapper { display: none; }
23
- shacl-property:not(.may-remove) > .property-instance > .remove-button-wrapper > .remove-button:not(.persistent) { visibility: hidden; }
24
- shacl-property:not(.may-remove) > .collapsible > .property-instance > .remove-button-wrapper > .remove-button:not(.persistent) { visibility: hidden; }
25
- shacl-property:not(.may-remove) > .shacl-or-constraint > .remove-button-wrapper > .remove-button:not(.persistent) { visibility: hidden; }
26
- .mode-view .shacl-group:not(:has(shacl-property)) { display: none; }
27
- .property-instance, .shacl-or-constraint { display: flex; align-items: flex-start; padding: 4px 0; width: 100%; position: relative; }
28
- .shacl-or-constraint > div { display: flex; align-items: flex-start; }
29
- .shacl-or-constraint > div:first-child { flex-grow: 1 }
30
- .shacl-or-constraint label { display: inline-block; word-break: break-word; width: var(--label-width); line-height: 1em; padding-top: 0.15em; padding-right: 1em; flex-shrink: 0; position: relative; }
31
- .property-instance label[title] { cursor: help; text-decoration: underline dashed #AAA; }
32
- .property-instance.linked label:after, label.linked:after { content: '\\1F517'; font-size: 0.6em; position: absolute; top: 3px; right: 3px; }
33
- .mode-edit .property-instance label.required::before, .add-button-wrapper.required > .add-button::before, .add-button-wrapper.required > .link-button::before { color: var(--shacl-error-color); content: '\\2736'; font-size: 0.6rem; position: absolute; left: -1.4em; }
34
- .mode-edit .add-button-wrapper.required > .add-button::before, .add-button-wrapper.required > .link-button::before { left: -0.5em; }
35
- .mode-edit .property-instance label.required::before { top: 0.15rem; }
36
- .property-instance.valid::before { content: ''; position: absolute; left: calc(var(--label-width) - 1em); top:0.5em; width: 0.9em; height: 0.9em; background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 1024 1024" fill="green" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M866.133333 258.133333L362.666667 761.6l-204.8-204.8L98.133333 618.666667 362.666667 881.066667l563.2-563.2z"/></svg>'); }
37
- .editor:not([type='checkbox']) { flex-grow: 1; }
38
- textarea.editor { resize: vertical; }
39
- .lang-chooser { border: 0; background-color: #e9e9ed; padding: 2px 4px; align-self: flex-start; }
40
- .validation-error { position: absolute; left: calc(var(--label-width) - 1em); color: var(--shacl-error-color); cursor: help; }
41
- .validation-error::before { content: '\\26a0' }
42
- .validation-error.node { left: -1em; }
43
- .invalid > .editor { border-color: red !important; }
44
- .ml-0 { margin-left: 0 !important; }
45
- .pr-0 { padding-right: 0 !important; }
46
- .mode-view .property-instance:not(:first-child) > label { visibility: hidden; }
47
- .mode-view .property-instance label { width: var(--label-width); }
48
-
49
- .d-flex { display: flex; }
50
- .lang { opacity: 0.65; font-size: 0.6em; }
51
- a, a:visited { color: inherit; }
52
- h3 { margin-top: 0; }
53
-
54
- .fadeIn, .fadeOut { animation: fadeIn 0.2s ease-out; }
55
- .fadeOut { animation-direction: reverse; animation-timing-function: ease-out;}
56
- @keyframes fadeIn {
57
- 0% { opacity: 0; transform: scaleY(0.8); }
58
- 100% { opacity: 1; transform: scaleY(1); }
59
- }
60
- .collapsible::part(label) { font-weight: 600; }
61
- .collapsible > .property-instance:nth-child(even) { background-color: var(--shacl-row-alt-bg); }
62
- .collapsible > .property-instance > shacl-node > h1 { display: none; }
63
- .ref-link { cursor: pointer; }
64
- .ref-link:hover { text-decoration: underline; }
65
- .node-id-display { color: var(--shacl-muted-color); font-size: 11px; }
66
- /* hierarchy colors */
67
- .colorize { --hierarchy-color-width: 3px; padding: 0 1px 0 calc(1px + var(--hierarchy-color-width)); align-self: stretch; position: relative; }
68
- .colorize::before {
69
- content: '';
70
- position: absolute;
71
- width: var(--hierarchy-color-width);
72
- top: 0; bottom: 0; left: 0;
73
- --index: mod(var(--hierarchy-level), var(--hierarchy-colors-length));
74
- background: linear-gradient(var(--hierarchy-colors)) no-repeat 0 calc(var(--index) * 100% / (var(--hierarchy-colors-length) - 1)) / 100% calc(1px * infinity);
75
- }
76
- .property-instance:not(:has(shacl-node)) > .colorize::before { background: 0; }
77
- .colorize:not(:has(.remove-button)) { padding-left: calc(8px + var(--hierarchy-color-width)); }
78
- .mode-view .property-instance > .colorize { order: -1; }
79
- .link-option { padding: 10px; }
80
- .link-option:hover { background-color: #F5F5F5; cursor: pointer; }
81
- rokit-dialog.link-chooser::part(dialog) { min-height: min(434px, 90vh); width: min(90vw, 600px); }
82
- `,Re=class{constructor(e){this.dense=!0;let t=Le;e&&(t+=`
83
- `+e),this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(t)}apply(e){}setDense(e){this.dense=e}createViewer(e,r,i){let a=document.createElement(`div`),o=document.createElement(`label`);o.textContent=`${e}:`,i.description&&o.setAttribute(`title`,i.description.value),a.appendChild(o);let s=r.value,c=null;if(r instanceof n){let e=i.config.store.getQuads(s,null,null,null);if(e.length){let t=D(e,i.config.languages);t&&(s=t)}}else r instanceof t&&(r.language?(c=document.createElement(`span`),c.classList.add(`lang`),c.innerText=`@${r.language}`):r.datatype.value===`http://www.w3.org/2001/XMLSchema#date`?s=new Date(Date.parse(r.value)).toDateString():r.datatype.value===`http://www.w3.org/2001/XMLSchema#dateTime`&&(s=new Date(Date.parse(r.value)).toLocaleString()));let l;return k(r.value)?(l=document.createElement(`a`),l.setAttribute(`href`,r.value)):l=document.createElement(`div`),l.classList.add(`d-flex`),l.innerText=s,c&&l.appendChild(c),a.appendChild(l),a}};function ze(e,n,r){if(r){let r=z(e)>0;if(e.class&&!e.hasValue)return e.config.theme.createListEditor(e.label,n,r,ye(e.class,e),e);if(e.in){let t=e.config.lists[e.in];if(t?.length){let i=_e(t,e.config.store,e.config.languages);return e.config.theme.createListEditor(e.label,n,r,i,e)}else console.error(`list not found:`,e.in,`existing lists:`,e.config.lists)}if(e.datatype?.equals(se)||e.languageIn?.length||e.datatype===void 0&&n instanceof t&&n.language)return e.config.theme.createLangStringEditor(e.label,n,r,e);switch(e.datatype?.value.replace(ne,``)){case`integer`:case`float`:case`double`:case`decimal`:return e.config.theme.createNumberEditor(e.label,n,r,e);case`date`:case`dateTime`:return e.config.theme.createDateEditor(e.label,n,r,e);case`boolean`:return e.config.theme.createBooleanEditor(e.label,n,r,e);case`base64Binary`:return e.config.theme.createFileEditor(e.label,n,r,e)}return e.config.theme.createTextEditor(e.label,n,r,e)}else return n?e.config.theme.createViewer(e.label,n,e):document.createElement(`div`)}function Be(e,t,n){if(t===`application/ld+json`)return Ve(e);{let r=new a({format:t,prefixes:n});r.addQuads(e);let i=``;return r.end((e,t)=>{e&&console.error(e),i=t}),i}}function Ve(e){let n=[];for(let r of e){let e={"@id":r.subject.id};if(r.predicate===v)e[`@type`]=r.object.id;else{let n=r.object.value;r.object instanceof t?r.object.language?n={"@language":r.object.language,"@value":r.object.value}:r.object.datatype&&r.object.datatype.value!==`http://www.w3.org/2001/XMLSchema##string`&&(n={"@type":r.object.datatype.value,"@value":r.object.value}):n={"@id":r.object.id},e[r.predicate.value]=n}n.push(e)}return JSON.stringify(n)}function He(t){let r=t.shaclDatatype,i=t.dataset.value||t.value;if((t.type===`file`||t.getAttribute(`type`)===`file`)&&t.binaryData)i=t.binaryData;else if((t.type===`checkbox`||t.getAttribute(`type`)===`checkbox`)&&(t.checked||parseInt(t.dataset.minCount||`0`)>0))return e.literal(t.checked?`true`:`false`,r);if(i){if(i.startsWith(`<`)&&i.endsWith(`>`)&&i.indexOf(`:`)>-1)return e.namedNode(i.substring(1,i.length-1));if(t.dataset.class||t.dataset.nodeKind===`http://www.w3.org/ns/shacl#IRI`)return e.namedNode(i);if(t.dataset.link)return JSON.parse(t.dataset.link);if(t.dataset.lang?r=t.dataset.lang:t.type===`number`?i=parseFloat(i):t.type===`datetime-local`?i=Te(i,t.dataset.xsdTemporalSuffix):t.type===`date`&&r instanceof n&&r.value===`http://www.w3.org/2001/XMLSchema#date`&&(i=we(i,t.dataset.xsdTemporalSuffix)),(!r||r instanceof n&&pe.equals(r))&&typeof i==`string`){let t=i.split(`^^`);t.length===2&&t[0].startsWith(`"`)&&t[0].endsWith(`"`)&&t[1].split(`:`).length===2?(i=t[0].substring(1,t[0].length-1),r=e.namedNode(t[1])):(t=i.split(`@`),t.length===2&&t[0].startsWith(`"`)&&t[0].endsWith(`"`)?(i=t[0].substring(1,t[0].length-1),r=t[1]):i.startsWith(`"`)&&i.endsWith(`"`)&&(i=i.substring(1,i.length-1)))}return e.literal(i,r)}}var V={};function Ue(e){e.predicate===void 0&&e.datatype===void 0?console.warn(`not registering plugin because it does neither define "predicate" nor "datatype"`,e):V[`${e.predicate}^${e.datatype}`]=e}function We(){return Object.entries(V).map(e=>e[1])}function Ge(e,t){let n=V[`${e}^${t}`];return n||(n=V[`${e}^undefined`],n)?n:V[`undefined^${t}`]}var Ke=class{constructor(e,t){this.predicate=e.predicate,this.datatype=e.datatype,t&&(this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(t))}createViewer(e,t){return e.config.theme.createViewer(e.label,t,e)}};function H(e){let t=new Set;for(let n of e.getQuads(null,y,null,_))n.subject.termType===`NamedNode`&&t.add(n.subject.value);if(t.size===1)return t.values().next().value}function qe(t,n){let r=e.namedNode(n);for(let e of t.getObjects(r,y,_))if(e.termType===`NamedNode`&&t.getQuads(e,v,x,null).length>0)return e}async function Je(e){let t={store:new r,importedUrls:[],atts:e},n=[];if(e.shapes?n.push(U(F({rdf:e.shapes}),t,g)):e.shapesUrl&&n.push(U(F({url:e.shapesUrl,proxy:t.atts.proxy,rdfUrlResolver:t.atts.rdfUrlResolver}),t,g)),e.values?n.push(U(F({rdf:e.values}),t,_)):e.valuesUrl&&n.push(U(F({url:e.valuesUrl,proxy:t.atts.proxy,rdfUrlResolver:t.atts.rdfUrlResolver}),t,_)),await Promise.all(n),e.classInstanceProvider)try{let n=Ee(t.store),r=await e.classInstanceProvider(n);r&&await U(F({rdf:r}),t,g)}catch(e){console.error(`failed loading class instances`,e)}if(e.valuesSubject||=H(t.store)||null,e.valuesSubject&&t.store.countQuads(null,null,null,g)===0){let n=[...t.store.getObjects(e.valuesSubject,v,_),...t.store.getObjects(e.valuesSubject,y,_)],r=[];for(let e of n){let n=Ye(e.value);!n&&e.value.startsWith(`urn:`)&&t.atts.proxy&&(n=e.value),n&&t.importedUrls.indexOf(n)<0&&(t.importedUrls.push(n),r.push(U(F({url:n,proxy:t.atts.proxy,rdfUrlResolver:t.atts.rdfUrlResolver}),t,g)))}try{await Promise.allSettled(r)}catch(e){console.warn(e)}}return t.store}async function U(t,n,r){let i=await t,a=[];for(let t of i){let i=r;if(n.atts.valuesSubject&&_.equals(r)&&t.graph.id&&t.graph.id!==n.atts.valuesSubject&&(i=t.graph),n.store.add(e.quad(t.subject,t.predicate,t.object,i)),n.atts.loadOwlImports&&b.equals(t.predicate)){let r=Ye(t.object.value);r&&n.importedUrls.indexOf(r)<0&&(n.importedUrls.push(r),a.push(U(F({url:r,proxy:n.atts.proxy,rdfUrlResolver:n.atts.rdfUrlResolver}),n,e.namedNode(r))))}}await Promise.allSettled(a)}function Ye(e){if(k(e))return e;let t=e.split(`:`);if(t.length===2){let n=P[t[0]];if(n&&(e=e.replace(`${t[0]}:`,n),k(e)))return e}return null}async function Xe(e){if(e.template.nodeShapes.size===0)return;let t=e.template.config.resourceLinkProvider;if((!t||t&&!t.lazyLoad)&&(await et(e.template),Qe(e).length===0))return;let n=e.template.config.theme.createButton(e.template.label,!1);n.title=`Link existing `+e.template.label,n.classList.add(`link-button`),n.setAttribute(`text`,``);let r=n.getAttribute(`part`);return n.setAttribute(`part`,`${r?r+` `:``}link-button`),n.addEventListener(`click`,async()=>{t?.lazyLoad&&(n.classList.add(`loading`),await et(e.template),n.classList.remove(`loading`));let r=Qe(e);if(r.length===0)n.innerText=`No linkable resources found`,n.setAttribute(`disabled`,``),setTimeout(()=>n.remove(),2e3);else{let t=e.template.config.form.querySelector(`#dialog`);t||(t=new u,t.classList.add(`link-chooser`),t.closable=!0,e.template.config.form.appendChild(t)),t.title=`Link existing `+e.template.label,Ze(t,e,r),t.open=!0}}),n}function Ze(e,t,n){let r=document.createElement(`div`);for(let i of n){let n=document.createElement(`div`);n.classList.add(`link-option`),n.title=`Link this resource`,n.innerText=i.label||i.value,n.addEventListener(`click`,()=>{$e(i.value,t),e.open=!1}),r.appendChild(n)}e.replaceChildren(r)}function Qe(t){let n=[];if(t.template.config.resourceLinkProvider){for(let r of t.template.nodeShapes)if(t.template.config.providedConformingResourceIds[r.id.value])for(let i of t.template.config.providedConformingResourceIds[r.id.value])t.querySelector(`:scope > .property-instance > shacl-node[data-node-id='${i}'], :scope > .collapsible > .property-instance > shacl-node[data-node-id='${i}']`)===null&&n.push({value:i,label:D(t.template.config.store.getQuads(e.namedNode(i),null,null,null),t.template.config.languages),children:[]})}return n}async function $e(t,n){let r=e.namedNode(t);if(rt(r,n.template.config.store)){if(n.template.config.providedResources[t]?.length>0){let e={store:n.template.config.store,importedUrls:[],atts:{loadOwlImports:!1}};await U(F({rdf:n.template.config.providedResources[t]}),e,g),n.template.config.providedResources[t]=``}let e=await K(n.template,r,!0,!0);n.container.insertBefore(e,n.querySelector(`:scope > .add-button-wrapper`)),await n.updateControls()}}async function et(e){let t=e.config.resourceLinkProvider;if(!t)return;let n=new Set(Array.from(e.nodeShapes).map(e=>e.id.value));if(n.size===0)return;let r=De(Object.keys(e.config.providedConformingResourceIds),n);if(r.length!==0)try{let n=await t.listConformingResources(r,e);if(n){for(let t of Object.keys(n)){let r=new Set(n[t]);e.config.providedConformingResourceIds[t]=r,await tt(r,!1,e.config)}for(let t of r)e.config.providedConformingResourceIds[t]||(e.config.providedConformingResourceIds[t]=new Set)}}catch(e){console.error(`failed loading conforming resources`,e)}}async function tt(e,t,n){if(n.resourceLinkProvider&&e.size>0){let r=[];for(let t of e)n.providedResources[t]||r.push(t);if(r.length===0)return[];try{let e=await n.resourceLinkProvider.loadResources(r);if(e){let r={store:n.store,importedUrls:[],atts:{loadOwlImports:!1}};for(let i of e)n.providedResources[i.resourceId]=i.resourceRDF,t&&await U(F({rdf:i.resourceRDF}),r,g);return e}for(let e of r)n.providedResources[e]||(n.providedResources[e]=``)}catch(e){console.error(`failed loading resources`,e)}}return[]}async function nt(e){let t=new Set;for(let n of e.store.getQuads(null,null,null,_))rt(n.object,e.store)&&t.add(n.object.value);await tt(t,!0,e)}function rt(e,t){return e.termType===`NamedNode`&&t.countQuads(e,null,null,null)===0}var W=`:scope > .add-button-wrapper, :scope > .collapsible > .add-button-wrapper`,it=`:scope > .property-instance, :scope > .shacl-or-constraint, :scope > shacl-node, :scope > .collapsible > .property-instance`,G=class extends HTMLElement{constructor(e,t){if(super(),this.template=e,this.parent=t,this.container=this,this.setAttribute(`part`,`property`),this.template.nodeShapes.size&&this.template.config.attributes.collapse!==null&&(this.template.maxCount===void 0||this.template.maxCount>1)){let t=new l;t.classList.add(`collapsible`,`shacl-group`),t.open=e.config.attributes.collapse===`open`,t.label=this.template.label,t.setAttribute(`part`,`collapsible`),this.container=t,this.appendChild(this.container)}this.template.order!==void 0&&(this.style.order=`${this.template.order}`),this.template.cssClass&&this.classList.add(this.template.cssClass),e.config.editMode&&!t.linked&&this.addEventListener(`change`,async()=>{await this.updateControls()})}async bindValues(e,t){if(this.template.path){let n=!1;if(e){let r=this.template.config.store.getQuads(e,this.template.path,null,this.parent.linked?null:_);t&&(r=await this.filterValidValues(r,e));for(let e of r)this.parent.linked||this.template.config.store.delete(e),await this.addPropertyInstance(e.object,!_.equals(e.graph)||this.template.config.providedResources[e.object.value]!==void 0,this.template.config.providedResources[e.object.value]!==void 0),this.template.hasValue&&e.object.equals(this.template.hasValue)&&(n=!0)}this.template.config.editMode&&this.template.hasValue&&!n&&!this.parent.linked&&await this.addPropertyInstance(this.template.hasValue)}}async addPropertyInstance(e,t,n=!1){let r;if(this.template.or?.length||this.template.xone?.length){let t=this.template.or?.length?this.template.or:this.template.xone,n=!1;if(e){let i=Fe(t,e,this.template.config);i.length&&(r=await K(B(Me(this.template),i),e,!this.parent.linked,this.parent.linked,this.parent),n=!0)}!n&&this.template.config.editMode&&(r=Pe(t,this,this.template.config),at(r,``,this.template.config.theme.dense,this.template.config.hierarchyColorsStyleSheet!==void 0))}else r=await K(this.template,e,n,t||this.parent.linked,this.parent);return r&&this.container.insertBefore(r,this.querySelector(W)),r}async updateControls(){this.template.config.editMode&&!this.parent.linked&&!this.querySelector(W)&&this.container.appendChild(await this.createAddControls());let e=z(this.template),t=this.template.nodeShapes.size===0,n=this.querySelector(`:scope > .add-button-wrapper > .link-button, :scope > .collapsible > .add-button-wrapper > .link-button`)===null,r=t||!this.hasRecursiveNodeShape(),i=this.instanceCount();i===0&&r&&(t||n&&e>0)&&(await this.addPropertyInstance(),i=1),t||this.querySelector(W)?.classList.toggle(`required`,i<e);let a;a=e>0?i>e:!t||i>1;let o=i<je(this.template);this.classList.toggle(`may-remove`,a),this.classList.toggle(`may-add`,o)}instanceCount(){return this.querySelectorAll(it).length}hasRecursiveNodeShape(){let e=new Set;this.parent.ancestorShapeIds.forEach(t=>e.add(t)),e.add(this.parent.template.id.value);for(let t of this.template.nodeShapes)if(e.has(t.id.value))return!0;return!1}toRDF(t,n){let r=e.namedNode(this.template.path);for(let e of this.querySelectorAll(`:scope > .property-instance, :scope > .collapsible > .property-instance`))if(e.firstChild instanceof X){let i=e.firstChild.toRDF(t);t.addQuad(n,r,i,this.template.config.valuesGraphId)}else if(this.template.config.editMode)for(let i of e.querySelectorAll(`:scope > .editor`)){let e=He(i);e&&t.addQuad(n,r,e,this.template.config.valuesGraphId)}else{let i=He(e);i&&t.addQuad(n,r,i,this.template.config.valuesGraphId)}}async filterValidValues(e,t){let n=this.template.id,r=[t];if(this.template.qualifiedValueShape){n=this.template.qualifiedValueShape.id,r=[];for(let t of e)r.push(t.object)}let i=await this.template.config.validator.validate({dataset:this.template.config.store,terms:r},[{terms:[n]}]),a=new Set;for(let e of i.results){let t=this.template.qualifiedValueShape?e.focusNode:e.value;t?.ptrs?.length&&a.add(t.ptrs[0]._term.id)}return e.filter(e=>!a.has(e.object.id))}async createAddControls(){let e=document.createElement(`div`);e.classList.add(`add-button-wrapper`),e.setAttribute(`part`,`add-controls`);let t=await Xe(this);t&&e.appendChild(t);let n=this.template.config.theme.createButton(this.template.label,!1);n.title=`Add `+this.template.label,n.classList.add(`add-button`),n.setAttribute(`text`,``);let r=n.getAttribute(`part`);return n.setAttribute(`part`,`${r?r+` `:``}add-button`),n.addEventListener(`click`,async()=>{let e=await this.addPropertyInstance();e&&(e.classList.add(`fadeIn`),await this.updateControls(),setTimeout(()=>{ge(e),e.classList.remove(`fadeIn`)},200))}),e.appendChild(n),e}};async function K(e,n,r=!1,i=!1,a){let o;if(e.nodeShapes.size){o=document.createElement(`div`),o.classList.add(`property-instance`),o.setAttribute(`part`,`property-instance`);let t=new Set(a?.ancestorShapeIds??[]);a&&t.add(a.template.id.value);for(let r of e.nodeShapes){let a=new X(r,n,e.nodeKind,e.label,i,t);o.appendChild(a),await a.ready}}else{let t=Ge(e.path,e.datatype?.value);o=t?e.config.editMode&&!i?t.createEditor(e,n):t.createViewer(e,n):ze(e,n||null,e.config.editMode&&!i),o.childNodes.length>0&&(o.classList.add(`property-instance`),o.setAttribute(`part`,`property-instance`)),i&&o.classList.add(`linked`)}return e.config.editMode&&(!i||r)?at(o,e.label,e.config.theme.dense,e.config.hierarchyColorsStyleSheet!==void 0,r):e.config.hierarchyColorsStyleSheet!==void 0&&o.appendChild(ot(!0)),n&&!e.config.editMode&&(n instanceof t?(o.dataset.value=n.value,n.language.length>0?o.dataset.lang=n.language:o.shaclDatatype=n.datatype):o.dataset.value=`<`+n.value+`>`),o.dataset.path=e.path,o}function at(e,t,n,r,i=!1){let a=ot(r),o=new c;o.classList.add(`remove-button`,`clear`),o.title=`Remove `+t,o.dense=n,o.icon=!0;let s=o.getAttribute(`part`);o.setAttribute(`part`,`${s?s+` `:``}remove-button`),o.addEventListener(`click`,()=>{e.classList.remove(`fadeIn`),e.classList.add(`fadeOut`),setTimeout(()=>{let t=e.parentElement;e.remove(),t?.dispatchEvent(new Event(`change`,{bubbles:!0,cancelable:!0}))},200)}),i&&o.classList.add(`persistent`),a.appendChild(o),e.appendChild(a)}function ot(e){let t=document.createElement(`div`);return t.className=`remove-button-wrapper`,t.setAttribute(`part`,`remove-controls`),e&&t.classList.add(`colorize`),t}window.customElements.define(`shacl-property`,G);function st(e,t){let n=e,r=t.store.getQuads(e,null,null,null),i=E(r,`label`,ie,t.languages);i&&(n=i);let a;if(t.attributes.collapse!==null)a=new l,a.classList.add(`collapsible`),a.open=t.attributes.collapse===`open`,a.label=n,a.setAttribute(`part`,`group collapsible`);else{a=document.createElement(`div`);let e=document.createElement(`h1`);e.innerText=n,e.setAttribute(`part`,`group-title`),a.appendChild(e),a.setAttribute(`part`,`group`)}a.dataset.subject=e,a.classList.add(`shacl-group`);let o=E(r,`order`);return o&&(a.style.order=o),a}var ct={[`${h}node`]:(e,t)=>{e.extendedShapes.add(new q(t,e.config,e))},[`${h}and`]:(e,t)=>{for(let n of e.config.lists[t.value])e.extendedShapes.add(new q(n,e.config,e))},[`${h}property`]:(e,t)=>{let n=e.config.getPropertyTemplate(t,e);if(n.path){let t=e.properties[n.path];if(t||(t=[],e.properties[n.path]=t),n.qualifiedValueShape)t.push(n);else{let r;for(let t=0;t<e.properties[n.path].length&&!r;t++)e.properties[n.path][t].qualifiedValueShape||(r=e.properties[n.path][t]);r?Ne(r,n):t.push(n)}}},[`${h}nodeKind`]:(e,t)=>{e.nodeKind=t},[`${h}targetClass`]:(e,t)=>{e.targetClass=t},[`${h}or`]:(e,t)=>{e.or=e.config.lists[t.value]},[`${h}xone`]:(e,t)=>{e.xone=e.config.lists[t.value]},[b.id]:(e,t)=>{e.owlImports.add(t)},[`${oe}title`]:(e,t)=>{let n=t;e.label=A(e.config.languages,e.label,n)},[`${ie}label`]:(e,t)=>{let n=t;e.label=A(e.config.languages,e.label,n)}},q=class{constructor(e,t,n){this.extendedShapes=new Set,this.properties={},this.owlImports=new Set,this.merged=!1,this.id=e,this.config=t,this.parent=n,t.registerNodeTemplate(this),lt(this,this.config.store.getQuads(e,null,null,null))}};function lt(e,t){for(let n of t)ct[n.predicate.id]?.call(e,e,n.object);return e}function J(e){if(!e.merged){e.merged=!0;for(let t of Object.values(e.properties))for(let n of t){let[t,r]=Y(e,n.path);if(t.length>1&&r){let e=t[t.length-1];for(let n=t.length-2;n>=0;n--){let r=t[n];delete r.parent.properties[r.path],Ne(e,r)}}}}}function Y(e,t,n=new Set,r=[],i=!1){if(!n.has(e.id.value)){n.add(e.id.value);let a=e.properties[t];if(a?.length===1){r.push(a[0]),i||=a[0].maxCount===1;for(let e of a[0].nodeShapes){let[a,o]=Y(e,t,n,r,i);i||=o}}for(let a of e.extendedShapes){let[e,o]=Y(a,t,n,r,i);i||=o}}return[r,i]}var X=class t extends HTMLElement{constructor(n,r,i,a,o,s=new Set){super(),this.template=n,this.linked=o??!1,this.ancestorShapeIds=s,this.setAttribute(`part`,`node`);let c=r;c||=(!i&&n.nodeKind&&(i=n.nodeKind),i===void 0&&n.config.attributes.valuesNamespace||i?.value===`http://www.w3.org/ns/shacl#IRI`?e.namedNode(n.config.attributes.valuesNamespace+m()):e.blankNode(m())),this.nodeId=c;let l=JSON.stringify([n.id,r]);if(r&&n.config.renderedNodes.has(l)){a||=`Link`;let e=document.createElement(`label`);e.innerText=a,e.classList.add(`linked`),this.appendChild(e);let t=this.getAttribute(`part`);this.setAttribute(`part`,`${t?t+` `:``}linked-node`);let n=document.createElement(`a`),i=r.termType===`BlankNode`?`_:`+r.value:r.value;n.innerText=i,n.classList.add(`ref-link`),n.onclick=()=>{this.template.config.form.querySelector(`shacl-node[data-node-id='${i}']`)?.scrollIntoView()},this.appendChild(n),this.style.flexDirection=`row`,this.ready=Promise.resolve()}else{r&&n.config.renderedNodes.add(l);let e=this.ancestorShapeIds,i=this.template.id.value;if(this.dataset.nodeId=this.nodeId.id,this.template.config.attributes.showNodeIds!==null){let e=document.createElement(`div`);e.innerText=`id: ${this.nodeId.id}`,e.classList.add(`node-id-display`),this.appendChild(e)}J(n),this.ready=(async()=>{let s=new Set(e);s.add(i);for(let[e,t]of Object.entries(n.properties))for(let e of t)await this.addPropertyInstance(e,r,t.length>1);for(let e of n.extendedShapes){let n=new t(e,r,void 0,void 0,o,s);this.prepend(n),await n.ready}if(n.or?.length&&await this.tryResolve(n.or,r,n.config),n.xone?.length&&await this.tryResolve(n.xone,r,n.config),a){let e=document.createElement(`h1`);e.innerText=a,e.setAttribute(`part`,`node-title`),this.prepend(e)}})()}}toRDF(t,n,r=``){if(n||=this.nodeId,!this.linked){for(let e of this.querySelectorAll(`:scope > shacl-node, :scope > .shacl-group > shacl-node, :scope > shacl-property, :scope > .shacl-group > shacl-property`))e.toRDF(t,n);this.template.targetClass&&t.addQuad(n,v,this.template.targetClass,this.template.config.valuesGraphId),r&&t.addQuad(n,e.namedNode(r),this.template.id,this.template.config.valuesGraphId)}return n}async addPropertyInstance(e,t,n){let r=null;if(e.group)if(e.config.groups.indexOf(e.group)>-1){let t=this.querySelector(`:scope > .shacl-group[data-subject='${e.group}']`);t||(t=st(e.group,e.config),this.appendChild(t)),r=t}else console.warn(`ignoring unknown group reference`,e.group,`existing groups:`,e.config.groups);let i=new G(e,this);await i.bindValues(t,n),(e.config.editMode||i.instanceCount()>0)&&(r?r.appendChild(i):this.appendChild(i),await i.updateControls())}async tryResolve(e,t,n){let r=!1;if(t){let i=Ie(e,t,n);if(i.length){for(let e of i)await this.addPropertyInstance(n.getPropertyTemplate(e,this.template),t);r=!0}}r||this.appendChild(Pe(e,this,n))}};window.customElements.define(`shacl-node`,X);var ut=`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mode-BriAnl-6.js","assets/query-DLp_5-vp.js"])))=>i.map(i=>d[i]);
2
+ import{C as e,D as t,E as n,F as r,G as i,I as a,J as o,K as s,L as c,M as l,O as u,P as d,R as f,T as p,V as m,W as h,Y as g,_,b as v,c as y,d as b,f as x,g as S,h as C,i as w,j as T,k as E,l as D,m as O,n as k,q as A,r as j,s as M,t as ee,u as N,x as P,y as F,z as I}from"./assets/query-DLp_5-vp.js";import{DataFactory as L,Literal as R,NamedNode as z,Store as B}from"n3";import{RokitButton as V,RokitCollapsible as H,RokitInput as U,RokitSelect as W,RokitTextArea as G}from"@ro-kit/ui-widgets";import{Validator as K}from"shacl-engine";var q=`
84
3
  .editor:not([type='checkbox']) { border: 1px solid var(--shacl-border-color, #DDD); }
85
4
  .property-instance label { display: inline-flex; word-break: break-word; line-height: 1em; padding-top: 0.15em; padding-right: 1em; flex-shrink: 0; position: relative; }
86
5
  .property-instance:not(:first-child) > label:not(.persistent) { visibility: hidden; max-height: 0; }
87
6
  .mode-edit .property-instance label { width: var(--label-width); }
88
- `,dt=class extends Re{constructor(e){super(e||ut),this.idCtr=0}createDefaultTemplate(r,i,a,o,s){if(o.id=`e${this.idCtr++}`,o.classList.add(`editor`),o.setAttribute(`part`,`editor`),s?.datatype?o.shaclDatatype=s.datatype:i instanceof t&&(o.shaclDatatype=i.datatype),s&&z(s)>0&&(o.dataset.minCount=String(z(s))),s?.class&&(o.dataset.class=s.class.value),s?.nodeKind)o.dataset.nodeKind=s.nodeKind.value;else if(i&&(i instanceof n||s?.nodeKind?.equals(S))&&(o.dataset.nodeKind=h+`IRI`,s)){let t=D(s.config.store.getQuads(i,null,null,null),s.config.languages);t&&(o.dataset.value=`<`+i.value+`>`,i=e.literal(t))}(s?.hasValue&&i||s?.readonly)&&(o.disabled=!0);let c=i?.value||s?.defaultValue?.value||``;s?.datatype?.equals(me)?o.checked=i?.value===`true`||s?.defaultValue?.value===`true`:o.type===`file`?o.binaryData=c||void 0:o.value=c;let l=document.createElement(`label`);l.htmlFor=o.id,l.innerText=r,l.setAttribute(`part`,`label`),s?.description&&l.setAttribute(`title`,s.description.value);let u=s?.description?s.description.value:s?.pattern?s.pattern:null;u&&o.setAttribute(`placeholder`,u),a&&(o.setAttribute(`required`,`true`),l.classList.add(`required`));let d=document.createElement(`div`);return d.setAttribute(`part`,`field`),d.appendChild(l),d.appendChild(o),d}createDateEditor(e,t,n,r){let i=new d;r.datatype?.value===`http://www.w3.org/2001/XMLSchema#dateTime`?(i.type=`datetime-local`,i.setAttribute(`step`,`1`)):i.type=`date`,i.clearable=!0,i.dense=this.dense,i.classList.add(`pr-0`);let a=this.createDefaultTemplate(e,null,n,i,r);if(t){let e=r.datatype?.value===`http://www.w3.org/2001/XMLSchema#dateTime`?Ce(t.value):Se(t.value);e?(i.value=e.value,e.suffix&&(i.dataset.xsdTemporalSuffix=e.suffix)):console.error(`unable to parse xsd date literal`,t)}return a}createTextEditor(e,t,n,r){let i;return r.singleLine===!1?(i=new p,i.resize=`auto`):i=new d,i.dense=this.dense,r.pattern&&(i.pattern=r.pattern),r.minLength&&(i.minLength=r.minLength),r.maxLength&&(i.maxLength=r.maxLength),this.createDefaultTemplate(e,t,n,i,r)}createLangStringEditor(e,n,r,i){let a=this.createTextEditor(e,n,r,i),o=a.querySelector(`:scope .editor`),s;if(i.languageIn?.length){s=document.createElement(`select`);for(let e of i.languageIn){let t=document.createElement(`option`);t.innerText=e.value,s.appendChild(t)}}else s=document.createElement(`input`),s.maxLength=5,s.size=5,s.placeholder=`lang?`;return s.title=`Language of the text`,s.classList.add(`lang-chooser`),s.setAttribute(`part`,`lang-chooser`),s.slot=`suffix`,o.addEventListener(`change`,()=>{s.required=o.value!==``}),s.addEventListener(`change`,e=>{e.stopPropagation(),o&&(o.dataset.lang=s.value,o.dispatchEvent(new Event(`change`,{bubbles:!0})))}),n instanceof t&&(s.value=n.language),o.dataset.lang=s.value,o.appendChild(s),a}createBooleanEditor(e,n,r,i){let a=document.createElement(`input`);a.type=`checkbox`,a.classList.add(`ml-0`);let o=this.createDefaultTemplate(e,null,r,a,i);return a.removeAttribute(`required`),o.querySelector(`:scope label`)?.classList.remove(`required`),n instanceof t&&(a.checked=n.value===`true`),o}createFileEditor(e,t,n,r){let i=document.createElement(`input`);return i.type=`file`,i.addEventListener(`change`,e=>{if(i.files?.length){e.stopPropagation();let t=new FileReader;t.readAsDataURL(i.files[0]),t.onload=()=>{i.binaryData=btoa(t.result),i.parentElement?.dispatchEvent(new Event(`change`,{bubbles:!0}))}}else i.binaryData=void 0}),this.createDefaultTemplate(e,t,n,i,r)}createNumberEditor(e,t,n,r){let i=new d;i.type=`number`,i.clearable=!0,i.dense=this.dense,i.classList.add(`pr-0`);let a=r.minInclusive===void 0?r.minExclusive===void 0?void 0:r.minExclusive+1:r.minInclusive,o=r.maxInclusive===void 0?r.maxExclusive===void 0?void 0:r.maxExclusive-1:r.maxInclusive;return a!==void 0&&(i.min=String(a)),o!==void 0&&(i.max=String(o)),r.datatype?.value!==`http://www.w3.org/2001/XMLSchema#integer`&&(i.step=`any`),this.createDefaultTemplate(e,t,n,i,r)}createListEditor(e,t,r,i,a){let o=new f;o.clearable=!0,o.dense=this.dense;let s=this.createDefaultTemplate(e,null,r,o,a),c=document.createElement(`ul`),l=!0,u=(e,t)=>{let r=document.createElement(`li`);if(typeof e.value==`string`?(r.dataset.value=e.value,r.innerText=e.label?e.label:e.value):(r.dataset.value=e.value.id,e.value instanceof n&&(r.dataset.value=`<`+r.dataset.value+`>`),r.innerText=e.label?e.label:e.value.value),t.appendChild(r),e.children?.length){l=!1;let t=document.createElement(`ul`);r.appendChild(t);for(let n of e.children)u(n,t)}};for(let e of i)u(e,c);return l||(o.collapse=!0),o.appendChild(c),t=t??a?.defaultValue??null,t&&(o.value=t.id,t instanceof n&&(o.value=`<`+o.value+`>`)),s}createButton(e,t){let n=new c;return n.dense=this.dense,n.innerHTML=e,t?(n.setAttribute(`primary`,``),n.setAttribute(`part`,`button primary`)):n.setAttribute(`part`,`button`),n}},Z=class{constructor(){this.shapes=null,this.shapesUrl=null,this.shapeSubject=null,this.values=null,this.valuesUrl=null,this.valueSubject=null,this.valuesSubject=null,this.valuesNamespace=``,this.valuesGraph=null,this.view=null,this.language=null,this.loading=`Loading…`,this.proxy=null,this.ignoreOwlImports=null,this.collapse=null,this.hierarchyColors=null,this.submitButton=null,this.generateNodeShapeReference=y.value,this.showNodeIds=null,this.showRootShapeLabel=null,this.dense=`true`,this.useShadowRoot=`true`}},ft=`#4c93d785, #f85e9a85, #00327385, #87001f85`,Q=class{constructor(t){this.attributes=new Z,this.editMode=!0,this.lists={},this.groups=[],this.renderedNodes=new Set,this._store=new r,this._nodeTemplates={},this._propertyTemplates={},this.validator=new ee(this._store,{details:!0,factory:e}),this.providedConformingResourceIds={},this.providedResources={},this.form=t,this._theme=new dt,this.languages=[...new Set(navigator.languages.flatMap(e=>e.length>2?[e.toLocaleLowerCase(),e.substring(0,2)]:e)),``]}reset(){this.lists={},this.groups=[],this.renderedNodes.clear(),this.providedConformingResourceIds={},this.providedResources={},this._nodeTemplates={},this._propertyTemplates={}}updateAttributes(t){let n=new Z;if(Object.keys(n).forEach(e=>{let r=t.dataset[e];r!==void 0&&(n[e]=r)}),this.editMode=n.view===null,this.theme.setDense(n.dense===`true`),this.attributes=n,this.attributes.valueSubject&&!this.attributes.valuesSubject&&(this.attributes.valuesSubject=this.attributes.valueSubject),n.language){let e=this.languages.indexOf(n.language);e>-1&&this.languages.splice(e,1),this.languages.unshift(n.language)}if(n.valuesGraph&&(this.valuesGraphId=e.namedNode(n.valuesGraph)),n.hierarchyColors!=null){let e=n.hierarchyColors.length?n.hierarchyColors:ft,t=`:host { --hierarchy-colors: ${e}; --hierarchy-colors-length: ${e.split(`,`).length} }`;for(let e=8;e>=0;e--){let n=`shacl-property { --hierarchy-level: ${e} }`;for(let t=0;t<e;t++)n=`shacl-property `+n;t=t+`
89
- `+n}this.hierarchyColorsStyleSheet=new CSSStyleSheet,this.hierarchyColorsStyleSheet.replaceSync(t)}}static dataAttributes(){let e=new Z;return Object.keys(e).map(e=>(e=e.replace(/[A-Z]/g,e=>`-`+e.toLowerCase()),`data-`+e))}buildTemplateKey(e,t){let n=e.value;return t&&(t instanceof R?n+=`*`+t.id.value:n+=`*`+this.buildTemplateKey(t.id,t.parent)),n}registerNodeTemplate(e){this._nodeTemplates[this.buildTemplateKey(e.id,e.parent)]=e}registerPropertyTemplate(e){this._propertyTemplates[this.buildTemplateKey(e.id,e.parent)]=e}getNodeTemplateIds(){let e=new Set;for(let t of Object.values(this._nodeTemplates))e.add(t.id.value);return e}getNodeTemplate(e,t){let n=this.buildTemplateKey(e,t),r=this._nodeTemplates[n];return r||=new q(e,this,t),r}getPropertyTemplate(e,t){let n=this.buildTemplateKey(e,t),r=this._propertyTemplates[n];return r||=new R(e,t),r}get nodeTemplates(){return Object.values(this._nodeTemplates)}get theme(){return this._theme}set theme(e){this._theme=e,e.setDense(this.attributes.dense===`true`)}get store(){return this._store}set store(t){this._store=t,this.lists=Oe(t,{ignoreErrors:!0}),this.groups=[],t.forSubjects(e=>{this.groups.push(e.id)},v,`${h}PropertyGroup`,null),this.validator=new ee(t,{details:!0,factory:e})}},pt=200,$=class extends HTMLElement{static get observedAttributes(){return Q.dataAttributes()}constructor(){super(),this.shape=null,this.styleElement=null,this.form=document.createElement(`form`),this.form.setAttribute(`part`,`form`),this.config=new Q(this.form),this.form.addEventListener(`change`,e=>{e.stopPropagation(),this.config.editMode&&this.validate(!0).then(e=>{this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,cancelable:!1,composed:!0,detail:{valid:e.conforms,report:e}}))}).catch(e=>{console.warn(e)})})}connectedCallback(){this.config.updateAttributes(this),this.ensureRenderRoot(),this.initialize()}attributeChangedCallback(){this.config.updateAttributes(this),this.ensureRenderRoot(),this.initialize()}initialize(){clearTimeout(this.initDebounceTimeout),this.setAttribute(`loading`,``),this.form.replaceChildren(document.createTextNode(this.config.attributes.loading)),this.initDebounceTimeout=setTimeout(async()=>{try{this.config.reset(),this.config.store=await Je({shapes:this.config.attributes.shapes,shapesUrl:this.config.attributes.shapesUrl,values:this.config.attributes.values,valuesUrl:this.config.attributes.valuesUrl,valuesSubject:this.config.attributes.valuesSubject,loadOwlImports:this.config.attributes.ignoreOwlImports===null,classInstanceProvider:this.config.classInstanceProvider,rdfUrlResolver:this.config.rdfUrlResolver,proxy:this.config.attributes.proxy}),this.config.resourceLinkProvider&&await nt(this.config),this.config.attributes.valuesSubject||(this.config.attributes.valuesSubject=H(this.config.store)||null),this.form.replaceChildren();let t=this.findRootShaclShapeSubject();if(t){this.form.classList.forEach(e=>{this.form.classList.remove(e)}),this.form.classList.toggle(`mode-edit`,this.config.editMode),this.form.classList.toggle(`mode-view`,!this.config.editMode),this.config.theme.apply(this.form);let n=[this.config.theme.stylesheet];this.config.hierarchyColorsStyleSheet&&n.push(this.config.hierarchyColorsStyleSheet);for(let e of We())e.stylesheet&&n.push(e.stylesheet);this.applyStyles(n);let r=new q(t,this.config);for(let e of this.config.nodeTemplates)J(e);if(this.shape=new X(r,this.config.attributes.valuesSubject?e.namedNode(this.config.attributes.valuesSubject):void 0),this.form.appendChild(this.shape),this.config.attributes.showRootShapeLabel!==null&&r.label){let e=document.createElement(`h3`);e.innerText=r.label.value,this.form.prepend(e)}if(this.config.editMode){if(this.config.attributes.submitButton!==null){let e=this.config.theme.createButton(this.config.attributes.submitButton||`Submit`,!0);e.classList.add(`submit-button`);let t=e.getAttribute(`part`);e.setAttribute(`part`,`${t?t+` `:``}submit-button`),e.addEventListener(`click`,e=>{e.preventDefault(),this.form.reportValidity()&&this.validate().then(e=>{if(e?.conforms)this.dispatchEvent(new Event(`submit`,{bubbles:!0,cancelable:!0}));else{let e=this.form.querySelector(`:scope .invalid > .editor`);e?e.focus():this.form.querySelector(`:scope .invalid`)?.scrollIntoView()}})}),this.form.appendChild(e)}(async()=>{await this.shape?.ready,this.config.attributes.valuesSubject&&this.removeFromDataGraph(e.namedNode(this.config.attributes.valuesSubject)),this.validate(!0)})()}}else if(this.config.store.countQuads(null,null,null,g)>0)throw Error(`shacl root node shape not found`)}catch(e){console.error(e);let t=document.createElement(`div`);t.innerText=String(e),this.form.replaceChildren(t)}this.removeAttribute(`loading`),await this.shape?.ready,this.dispatchEvent(new Event(`ready`))},200)}ensureRenderRoot(){this.config.attributes.useShadowRoot===`false`?(this.shadowRoot?.contains(this.form)&&this.shadowRoot.removeChild(this.form),this.contains(this.form)||this.prepend(this.form)):(this.shadowRoot||this.attachShadow({mode:`open`}),this.shadowRoot.contains(this.form)||this.shadowRoot.prepend(this.form))}applyStyles(e){if(this.config.attributes.useShadowRoot!==`false`&&this.shadowRoot){this.shadowRoot.adoptedStyleSheets=e,this.styleElement&&=(this.styleElement.remove(),null);return}let t=e.map(e=>Array.from(e.cssRules).map(e=>e.cssText).join(`
7
+ `,J=class extends _{constructor(e){super(e||q),this.idCtr=0}createDefaultTemplate(e,t,n,r,a){if(r.id=`e${this.idCtr++}`,r.classList.add(`editor`),r.setAttribute(`part`,`editor`),a?.datatype?r.shaclDatatype=a.datatype:t instanceof R&&(r.shaclDatatype=t.datatype),a&&P(a)>0&&(r.dataset.minCount=String(P(a))),a?.class&&(r.dataset.class=a.class.value),a?.nodeKind)r.dataset.nodeKind=a.nodeKind.value;else if(t&&(t instanceof z||a?.nodeKind?.equals(i))&&(r.dataset.nodeKind=m+`IRI`,a)){let e=d(a.config.store.getQuads(t,null,null,null),a.config.languages);e&&(r.dataset.value=`<`+t.value+`>`,t=L.literal(e))}(a?.hasValue&&t||a?.readonly)&&(r.disabled=!0);let o=t?.value||a?.defaultValue?.value||``;a?.datatype?.equals(g)?r.checked=t?.value===`true`||a?.defaultValue?.value===`true`:r.type===`file`?r.binaryData=o||void 0:r.value=o;let s=document.createElement(`label`);s.htmlFor=r.id,s.innerText=e,s.setAttribute(`part`,`label`),a?.description&&s.setAttribute(`title`,a.description.value);let c=a?.description?a.description.value:a?.pattern?a.pattern:null;c&&r.setAttribute(`placeholder`,c),n&&(r.setAttribute(`required`,`true`),s.classList.add(`required`));let l=document.createElement(`div`);return l.setAttribute(`part`,`field`),l.appendChild(s),l.appendChild(r),l}createDateEditor(e,t,n,i){let o=new U;i.datatype?.value===`http://www.w3.org/2001/XMLSchema#dateTime`?(o.type=`datetime-local`,o.setAttribute(`step`,`1`)):o.type=`date`,o.clearable=!0,o.dense=this.dense,o.classList.add(`pr-0`);let s=this.createDefaultTemplate(e,null,n,o,i);if(t){let e=i.datatype?.value===`http://www.w3.org/2001/XMLSchema#dateTime`?r(t.value):a(t.value);e?(o.value=e.value,e.suffix&&(o.dataset.xsdTemporalSuffix=e.suffix)):console.error(`unable to parse xsd date literal`,t)}return s}createTextEditor(e,t,n,r){let i;return r.singleLine===!1?(i=new G,i.resize=`auto`):i=new U,i.dense=this.dense,r.pattern&&(i.pattern=r.pattern),r.minLength&&(i.minLength=r.minLength),r.maxLength&&(i.maxLength=r.maxLength),this.createDefaultTemplate(e,t,n,i,r)}createLangStringEditor(e,t,n,r){let i=this.createTextEditor(e,t,n,r),a=i.querySelector(`:scope .editor`),o;if(r.languageIn?.length){o=document.createElement(`select`);for(let e of r.languageIn){let t=document.createElement(`option`);t.innerText=e.value,o.appendChild(t)}}else o=document.createElement(`input`),o.maxLength=5,o.size=5,o.placeholder=`lang?`;return o.title=`Language of the text`,o.classList.add(`lang-chooser`),o.setAttribute(`part`,`lang-chooser`),o.slot=`suffix`,a.addEventListener(`change`,()=>{o.required=a.value!==``}),o.addEventListener(`change`,e=>{e.stopPropagation(),a&&(a.dataset.lang=o.value,a.dispatchEvent(new Event(`change`,{bubbles:!0})))}),t instanceof R&&(o.value=t.language),a.dataset.lang=o.value,a.appendChild(o),i}createBooleanEditor(e,t,n,r){let i=document.createElement(`input`);i.type=`checkbox`,i.classList.add(`ml-0`);let a=this.createDefaultTemplate(e,null,n,i,r);return i.removeAttribute(`required`),a.querySelector(`:scope label`)?.classList.remove(`required`),t instanceof R&&(i.checked=t.value===`true`),a}createFileEditor(e,t,n,r){let i=document.createElement(`input`);return i.type=`file`,i.addEventListener(`change`,e=>{if(i.files?.length){e.stopPropagation();let t=new FileReader;t.readAsDataURL(i.files[0]),t.onload=()=>{i.binaryData=btoa(t.result),i.parentElement?.dispatchEvent(new Event(`change`,{bubbles:!0}))}}else i.binaryData=void 0}),this.createDefaultTemplate(e,t,n,i,r)}createNumberEditor(e,t,n,r){let i=new U,a=I.has(r.datatype?.value??``);i.type=a?`text`:`number`,a&&(i.pattern=r.datatype?.value===`http://www.w3.org/2001/XMLSchema#decimal`?`[+\\-]?(?:[0-9]+(?:[.,][0-9]*)?|[.,][0-9]+)`:`[+\\-]?(?:[0-9]+(?:[.,][0-9]*)?|[.,][0-9]+)(?:[eE][+\\-]?[0-9]+)?`,i.updateComplete.then(()=>{i.inputElement.inputMode=`decimal`})),i.clearable=!0,i.dense=this.dense,i.classList.add(`pr-0`);let o=r.minInclusive===void 0?r.minExclusive===void 0?void 0:r.minExclusive+1:r.minInclusive,s=r.maxInclusive===void 0?r.maxExclusive===void 0?void 0:r.maxExclusive-1:r.maxInclusive;return o!==void 0&&(i.min=String(o)),s!==void 0&&(i.max=String(s)),!a&&r.datatype?.value!==`http://www.w3.org/2001/XMLSchema#integer`&&(i.step=`any`),this.createDefaultTemplate(e,t,n,i,r)}createListEditor(e,t,n,r,i){let a=new W;a.clearable=!0,a.dense=this.dense;let o=this.createDefaultTemplate(e,null,n,a,i),s=document.createElement(`ul`),c=!0,l=(e,t)=>{let n=document.createElement(`li`);if(typeof e.value==`string`?(n.dataset.value=e.value,n.innerText=e.label?e.label:e.value):(n.dataset.value=e.value.id,e.value instanceof z&&(n.dataset.value=`<`+n.dataset.value+`>`),n.innerText=e.label?e.label:e.value.value),t.appendChild(n),e.children?.length){c=!1;let t=document.createElement(`ul`);n.appendChild(t);for(let n of e.children)l(n,t)}};for(let e of r)l(e,s);return c||(a.collapse=!0),a.appendChild(s),t=t??i?.defaultValue??null,t&&(a.value=t.id,t instanceof z&&(a.value=`<`+a.value+`>`)),o}createButton(e,t){let n=new V;return n.dense=this.dense,n.innerHTML=e,t?(n.setAttribute(`primary`,``),n.setAttribute(`part`,`button primary`)):n.setAttribute(`part`,`button`),n}},Y=class{constructor(){this.shapes=null,this.shapesUrl=null,this.shapeSubject=null,this.values=null,this.valuesUrl=null,this.valueSubject=null,this.valuesSubject=null,this.valuesNamespace=``,this.valuesGraph=null,this.view=null,this.mode=null,this.language=null,this.loading=`Loading…`,this.proxy=null,this.ignoreOwlImports=null,this.collapse=null,this.hierarchyColors=null,this.submitButton=null,this.generateNodeShapeReference=f.value,this.showNodeIds=null,this.showRootShapeLabel=null,this.dense=`true`,this.useShadowRoot=`true`}},X=`#4c93d785, #f85e9a85, #00327385, #87001f85`,Z=class{constructor(e){this.attributes=new Y,this.mode=`edit`,this.lists={},this.groups=[],this.renderedNodes=new Set,this._store=new B,this._nodeTemplates={},this._propertyTemplates={},this.validator=new K(this._store,{details:!0,factory:L}),this.providedConformingResourceIds={},this.providedResources={},this.providedResourceLabels={},this.form=e,this._theme=new J,this.languages=[...new Set(navigator.languages.flatMap(e=>e.length>2?[e.toLocaleLowerCase(),e.substring(0,2)]:e)),``]}reset(){this.lists={},this.groups=[],this.renderedNodes.clear(),this.providedConformingResourceIds={},this.providedResources={},this.providedResourceLabels={},this._nodeTemplates={},this._propertyTemplates={}}updateAttributes(e){let t=new Y;if(Object.keys(t).forEach(n=>{let r=e.dataset[n];r!==void 0&&(t[n]=r)}),t.mode!==null&&![`edit`,`view`,`query`].includes(t.mode))throw Error(`invalid shacl-form mode: ${t.mode}`);if(this.mode=t.mode??(t.view===null?`edit`:`view`),this.theme.setDense(t.dense===`true`),this.attributes=t,this.attributes.valueSubject&&!this.attributes.valuesSubject&&(this.attributes.valuesSubject=this.attributes.valueSubject),t.language){let e=this.languages.indexOf(t.language);e>-1&&this.languages.splice(e,1),this.languages.unshift(t.language)}if(t.valuesGraph&&(this.valuesGraphId=L.namedNode(t.valuesGraph)),t.hierarchyColors!=null){let e=t.hierarchyColors.length?t.hierarchyColors:X,n=`:host { --hierarchy-colors: ${e}; --hierarchy-colors-length: ${e.split(`,`).length} }`;for(let e=8;e>=0;e--){let t=`shacl-property { --hierarchy-level: ${e} }`;for(let n=0;n<e;n++)t=`shacl-property `+t;n=n+`
8
+ `+t}this.hierarchyColorsStyleSheet=new CSSStyleSheet,this.hierarchyColorsStyleSheet.replaceSync(n)}}static dataAttributes(){let e=new Y;return Object.keys(e).map(e=>(e=e.replace(/[A-Z]/g,e=>`-`+e.toLowerCase()),`data-`+e))}buildTemplateKey(e,t){let n=e.value;return t&&(t instanceof v?n+=`*`+t.id.value:n+=`*`+this.buildTemplateKey(t.id,t.parent)),n}registerNodeTemplate(e){this._nodeTemplates[this.buildTemplateKey(e.id,e.parent)]=e}registerPropertyTemplate(e){this._propertyTemplates[this.buildTemplateKey(e.id,e.parent)]=e}getNodeTemplateIds(){let e=new Set;for(let t of Object.values(this._nodeTemplates))e.add(t.id.value);return e}getNodeTemplate(e,t){let n=this.buildTemplateKey(e,t),r=this._nodeTemplates[n];return r||=new j(e,this,t),r}getPropertyTemplate(e,t){let n=this.buildTemplateKey(e,t),r=this._propertyTemplates[n];return r||=new v(e,t),r}get nodeTemplates(){return Object.values(this._nodeTemplates)}get theme(){return this._theme}set theme(e){this._theme=e,e.setDense(this.attributes.dense===`true`)}get store(){return this._store}get editMode(){return this.mode===`edit`}get queryMode(){return this.mode===`query`}set store(e){this._store=e,this.lists=T(e,{ignoreErrors:!0}),this.groups=[],e.forSubjects(e=>{this.groups.push(e.id)},h,`${m}PropertyGroup`,null),this.validator=new K(e,{details:!0,factory:L})}},Q=200,$=class extends HTMLElement{static get observedAttributes(){return Z.dataAttributes()}constructor(){super(),this.shape=null,this.styleElement=null,this.form=document.createElement(`form`),this.form.setAttribute(`part`,`form`),this.config=new Z(this.form),this.form.addEventListener(`change`,e=>{e.stopPropagation(),this.config.queryMode?this.queryController?.handleChange():this.config.editMode&&this.validate(!0).then(e=>{this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,cancelable:!1,composed:!0,detail:{valid:e.conforms,report:e}}))}).catch(e=>{console.warn(e)})})}connectedCallback(){this.config.updateAttributes(this),this.ensureRenderRoot(),this.initialize()}attributeChangedCallback(){this.config.updateAttributes(this),this.ensureRenderRoot(),this.initialize()}initialize(){clearTimeout(this.initDebounceTimeout),this.queryController?.dispose(),this.queryController=void 0,this.setAttribute(`loading`,``),this.form.replaceChildren(document.createTextNode(this.config.attributes.loading)),this.initDebounceTimeout=setTimeout(async()=>{try{this.config.reset(),this.config.store=await b({shapes:this.config.attributes.shapes,shapesUrl:this.config.attributes.shapesUrl,values:this.config.attributes.values,valuesUrl:this.config.attributes.valuesUrl,valuesSubject:this.config.attributes.valuesSubject,loadOwlImports:this.config.attributes.ignoreOwlImports===null,classInstanceProvider:this.config.classInstanceProvider,rdfUrlResolver:this.config.rdfUrlResolver,proxy:this.config.attributes.proxy}),this.config.resourceLinkProvider&&await M(this.config),this.config.attributes.valuesSubject||(this.config.attributes.valuesSubject=D(this.config.store)||null),this.form.replaceChildren();let e=this.findRootShaclShapeSubject();if(e){if(this.form.classList.forEach(e=>{this.form.classList.remove(e)}),this.form.classList.toggle(`mode-edit`,this.config.editMode),this.form.classList.toggle(`mode-view`,this.config.mode===`view`),this.form.classList.toggle(`mode-query`,this.config.queryMode),this.config.queryMode){let{QueryModeController:e}=await F(async()=>{let{QueryModeController:e}=await import(`./assets/mode-BriAnl-6.js`);return{QueryModeController:e}},__vite__mapDeps([0,1]));this.queryController=new e(this)}this.config.theme.apply(this.form);let t=[this.config.theme.stylesheet];this.config.hierarchyColorsStyleSheet&&t.push(this.config.hierarchyColorsStyleSheet),this.queryController&&t.push(this.queryController.stylesheet);for(let e of O())e.stylesheet&&t.push(e.stylesheet);this.applyStyles(t);let n=new j(e,this.config);for(let e of this.config.nodeTemplates)w(e);if(this.shape=new k(n,this.config.attributes.valuesSubject?L.namedNode(this.config.attributes.valuesSubject):void 0),this.form.appendChild(this.shape),this.config.attributes.showRootShapeLabel!==null&&n.label){let e=document.createElement(`h3`);e.innerText=n.label.value,this.form.prepend(e)}if(this.config.editMode){if(this.config.attributes.submitButton!==null){let e=this.config.theme.createButton(this.config.attributes.submitButton||`Submit`,!0);e.classList.add(`submit-button`);let t=e.getAttribute(`part`);e.setAttribute(`part`,`${t?t+` `:``}submit-button`),e.addEventListener(`click`,e=>{e.preventDefault(),this.form.reportValidity()&&this.validate().then(e=>{if(e?.conforms)this.dispatchEvent(new Event(`submit`,{bubbles:!0,cancelable:!0}));else{let e=this.form.querySelector(`:scope .invalid > .editor`);e?e.focus():this.form.querySelector(`:scope .invalid`)?.scrollIntoView()}})}),this.form.appendChild(e)}(async()=>{await this.shape?.ready,this.config.attributes.valuesSubject&&this.removeFromDataGraph(L.namedNode(this.config.attributes.valuesSubject)),this.validate(!0)})()}else this.config.queryMode&&(await this.shape.ready,await this.queryController?.initialize())}else if(this.config.store.countQuads(null,null,null,o)>0)throw Error(`shacl root node shape not found`)}catch(e){console.error(e);let t=document.createElement(`div`);t.innerText=String(e),this.form.replaceChildren(t)}this.removeAttribute(`loading`),await this.shape?.ready,this.dispatchEvent(new Event(`ready`))},200)}ensureRenderRoot(){this.config.attributes.useShadowRoot===`false`?(this.shadowRoot?.contains(this.form)&&this.shadowRoot.removeChild(this.form),this.contains(this.form)||this.prepend(this.form)):(this.shadowRoot||this.attachShadow({mode:`open`}),this.shadowRoot.contains(this.form)||this.shadowRoot.prepend(this.form))}applyStyles(e){if(this.config.attributes.useShadowRoot!==`false`&&this.shadowRoot){this.shadowRoot.adoptedStyleSheets=e,this.styleElement&&=(this.styleElement.remove(),null);return}let t=e.map(e=>Array.from(e.cssRules).map(e=>e.cssText).join(`
90
9
  `).replace(/:host\b/g,`shacl-form`)).join(`
91
- `);this.styleElement||(this.styleElement=document.createElement(`style`),this.prepend(this.styleElement)),this.styleElement.textContent=t}serialize(e=`text/turtle`,t=this.toRDF()){return Be(t.getQuads(null,null,null,null),e,P)}toRDF(e=new r){return this.shape?.toRDF(e,void 0,this.config.attributes.generateNodeShapeReference),e}registerPlugin(e){Ue(e),this.initialize()}setTheme(e){this.config.theme=e,this.initialize()}setClassInstanceProvider(e){this.config.classInstanceProvider=e,this.initialize()}setRdfUrlResolver(e){this.config.rdfUrlResolver=e,this.initialize()}setResourceLinkProvider(e){this.config.resourceLinkProvider=e,this.initialize()}async validate(e=!1){for(let e of this.form.querySelectorAll(`:scope .validation-error`))e.remove();for(let e of this.form.querySelectorAll(`:scope .property-instance`))e.classList.remove(`invalid`),e.querySelector(`:scope > .editor`)?.value?e.classList.add(`valid`):e.classList.remove(`valid`);for(let e of this.form.querySelectorAll(`.add-button-wrapper`))e.classList.remove(`invalid`,`validation-error`);if(!this.shape)return{conforms:!0,results:[]};if(!e){let e=this.form.querySelectorAll(`.add-button-wrapper.required`);for(let t of e)t.classList.add(`invalid`),t.after(this.createValidationErrorDisplay(`Value is required`,`node`));if(e.length>0)return{conforms:!1,results:[]}}let t=this.shape;return new Promise(n=>{this.config.store.deleteGraph(this.config.valuesGraphId||``).on(`end`,async()=>{t.toRDF(this.config.store,void 0,this.config.attributes.generateNodeShapeReference);try{let r=await this.config.validator.validate({dataset:this.config.store,terms:[t.nodeId]},[{terms:[t.template.id]}]);for(let t of r.results)if(t.focusNode?.ptrs?.length)for(let n of t.focusNode.ptrs){let r=n._term;if(t.path?.length){let n=t.path[0].predicates[0],i=this.form.querySelectorAll(`
10
+ `);this.styleElement||(this.styleElement=document.createElement(`style`),this.prepend(this.styleElement)),this.styleElement.textContent=t}serialize(e=`text/turtle`,t){return this.assertNotQueryMode(`serialize`),t??=this.toRDF(),S(t.getQuads(null,null,null,null),e,u)}toRDF(e=new B){return this.assertNotQueryMode(`toRDF`),this.shape?.toRDF(e,void 0,this.config.attributes.generateNodeShapeReference),e}registerPlugin(e){C(e),this.initialize()}setTheme(e){this.config.theme=e,this.initialize()}setClassInstanceProvider(e){this.config.classInstanceProvider=e,this.initialize()}setRdfUrlResolver(e){this.config.rdfUrlResolver=e,this.initialize()}setResourceLinkProvider(e){this.config.resourceLinkProvider=e,this.initialize()}setQueryFacetProvider(e){this.config.queryFacetProvider=e,this.queryController?.refreshFacets()}getQuery(){return this.shape?this.queryController?.getQuery()??{rootShapeId:this.shape.template.id.value,targetClass:this.shape.template.targetClass?.value,criteria:[]}:{rootShapeId:``,criteria:[]}}refreshQueryFacets(){this.queryController?.refreshFacets()}async validate(e=!1){this.assertNotQueryMode(`validate`);for(let e of this.form.querySelectorAll(`:scope .validation-error`))e.remove();for(let e of this.form.querySelectorAll(`:scope .property-instance`))e.classList.remove(`invalid`),e.querySelector(`:scope > .editor`)?.value?e.classList.add(`valid`):e.classList.remove(`valid`);for(let e of this.form.querySelectorAll(`.add-button-wrapper`))e.classList.remove(`invalid`,`validation-error`);if(!this.shape)return{conforms:!0,results:[]};if(!e){let e=this.form.querySelectorAll(`.add-button-wrapper.required`);for(let t of e)t.classList.add(`invalid`),t.after(this.createValidationErrorDisplay(`Value is required`,`node`));if(e.length>0)return{conforms:!1,results:[]}}let t=this.shape;return new Promise(n=>{this.config.store.deleteGraph(this.config.valuesGraphId||``).on(`end`,async()=>{t.toRDF(this.config.store,void 0,this.config.attributes.generateNodeShapeReference);try{let r=await this.config.validator.validate({dataset:this.config.store,terms:[t.nodeId]},[{terms:[t.template.id]}]);for(let t of r.results)if(t.focusNode?.ptrs?.length)for(let n of t.focusNode.ptrs){let r=n._term;if(t.path?.length){let n=t.path[0].predicates[0],i=this.form.querySelectorAll(`
92
11
  :scope shacl-node[data-node-id='${r.id}'] > shacl-property > .property-instance[data-path='${n.id}'] > .editor,
93
12
  :scope shacl-node[data-node-id='${r.id}'] > shacl-property > .shacl-group > .property-instance[data-path='${n.id}'] > .editor,
94
13
  :scope shacl-node[data-node-id='${r.id}'] > .shacl-group > shacl-property > .property-instance[data-path='${n.id}'] > .editor,
95
14
  :scope shacl-node[data-node-id='${r.id}'] > .shacl-group > shacl-property > .shacl-group > .property-instance[data-path='${n.id}'] > .editor`);i.length===0&&(i=this.form.querySelectorAll(`
96
15
  :scope [data-node-id='${r.id}'] > shacl-property > .property-instance[data-path='${n.id}'],
97
- :scope [data-node-id='${r.id}'] > shacl-property > .shacl-group > .property-instance[data-path='${n.id}']`));for(let n of i)if(n.classList.contains(`editor`)){if(!e||n.value){let e=n.parentElement;e.classList.add(`invalid`),e.classList.remove(`valid`),e.appendChild(this.createValidationErrorDisplay(t));do e instanceof l&&(e.open=!0),e=e.parentElement;while(e)}}else e||(n.classList.add(`invalid`),n.classList.remove(`valid`),n.appendChild(this.createValidationErrorDisplay(t,`node`)))}else e||this.form.querySelector(`:scope [data-node-id='${r.id}']`)?.prepend(this.createValidationErrorDisplay(t,`node`))}n(r)}catch(e){console.error(e),n({conforms:!1,results:[]})}})})}createValidationErrorDisplay(e,t){let n=document.createElement(`span`);n.classList.add(`validation-error`),t&&n.classList.add(t);let r=typeof e==`object`&&e?e:null;return r?r.message?.length?n.title+=be(this.config.languages,r.message):r.sourceConstraintComponent?.value&&(n.title=r.sourceConstraintComponent.value):typeof e==`string`&&(n.title=e),n}findRootShaclShapeSubject(){if(this.config.attributes.shapeSubject){let t=e.namedNode(this.config.attributes.shapeSubject);if(this.config.store.getQuads(t,v,x,null).length===0){console.warn(`shapes graph does not contain requested node shape ${this.config.attributes.shapeSubject}`);return}else return t}else{if(this.config.attributes.valuesSubject&&this.config.store.countQuads(null,null,null,_)>0){let t=e.namedNode(this.config.attributes.valuesSubject),n=qe(this.config.store,this.config.attributes.valuesSubject),r=this.config.store.getQuads(t,v,null,_);if(r.length===0&&console.warn(`value subject '${this.config.attributes.valuesSubject}' has neither ${v.id} nor ${y.id} statement`),n)return n;for(let e of r)if(this.config.store.getQuads(e.object,v,x,null).length>0)return e.object;let i=this.config.store.getObjects(t,v,_);for(let e of i)for(let t of this.config.store.getQuads(null,T,e,null))return t.subject}let t=this.config.store.getQuads(null,v,x,null);if(t.length==0){console.warn(`shapes graph does not contain any node shapes`);return}return t.length>1&&(console.warn(`shapes graph contains`,t.length,`node shapes. choosing first found which is`,t[0].subject.value),console.info(`hint: set the node shape to use with element attribute "data-shape-subject"`)),t[0].subject}}removeFromDataGraph(e){for(let t of this.config.store.getQuads(e,null,null,_))this.config.store.delete(t),(t.object.termType===`NamedNode`||t.object.termType===`BlankNode`)&&this.removeFromDataGraph(t.object)}};window.customElements.define(`shacl-form`,$);export{Q as Config,dt as DefaultTheme,Ke as Plugin,$ as ShaclForm,R as ShaclPropertyTemplate,Re as Theme,I as fetchRDF,qe as findConformsToShapeSubject,H as findConformsToValuesSubject,D as findLabel,U as importRDF,pt as initTimeout,Je as loadGraphs,F as loadRDF,L as parseRDF,P as prefixes,Ae as propertyMappers,N as rdfCache,Ue as registerPlugin};
16
+ :scope [data-node-id='${r.id}'] > shacl-property > .shacl-group > .property-instance[data-path='${n.id}']`));for(let n of i)if(n.classList.contains(`editor`)){if(!e||n.value){let e=n.parentElement;e.classList.add(`invalid`),e.classList.remove(`valid`),e.appendChild(this.createValidationErrorDisplay(t));do e instanceof H&&(e.open=!0),e=e.parentElement;while(e)}}else e||(n.classList.add(`invalid`),n.classList.remove(`valid`),n.appendChild(this.createValidationErrorDisplay(t,`node`)))}else e||this.form.querySelector(`:scope [data-node-id='${r.id}']:not([part~='linked-node'])`)?.prepend(this.createValidationErrorDisplay(t,`node`))}n(r)}catch(e){console.error(e),n({conforms:!1,results:[]})}})})}assertNotQueryMode(e){if(this.config.queryMode)throw Error(`${e}() is not available in query mode; use getQuery()`)}createValidationErrorDisplay(e,t){let n=document.createElement(`span`);n.classList.add(`validation-error`),t&&n.classList.add(t);let r=typeof e==`object`&&e?e:null;return r?r.message?.length?n.title+=l(this.config.languages,r.message):r.sourceConstraintComponent?.value&&(n.title=r.sourceConstraintComponent.value):typeof e==`string`&&(n.title=e),n}findRootShaclShapeSubject(){if(this.config.attributes.shapeSubject){let e=L.namedNode(this.config.attributes.shapeSubject);if(this.config.store.getQuads(e,h,s,null).length===0){console.warn(`shapes graph does not contain requested node shape ${this.config.attributes.shapeSubject}`);return}else return e}else{if(this.config.attributes.valuesSubject&&this.config.store.countQuads(null,null,null,c)>0){let e=L.namedNode(this.config.attributes.valuesSubject),t=y(this.config.store,this.config.attributes.valuesSubject),n=this.config.store.getQuads(e,h,null,c);if(n.length===0&&console.warn(`value subject '${this.config.attributes.valuesSubject}' has neither ${h.id} nor ${f.id} statement`),t)return t;for(let e of n)if(this.config.store.getQuads(e.object,h,s,null).length>0)return e.object;let r=this.config.store.getObjects(e,h,c);for(let e of r)for(let t of this.config.store.getQuads(null,A,e,null))return t.subject}let e=this.config.store.getQuads(null,h,s,null);if(e.length==0){console.warn(`shapes graph does not contain any node shapes`);return}return e.length>1&&(console.warn(`shapes graph contains`,e.length,`node shapes. choosing first found which is`,e[0].subject.value),console.info(`hint: set the node shape to use with element attribute "data-shape-subject"`)),e[0].subject}}removeFromDataGraph(e){for(let t of this.config.store.getQuads(e,null,null,c))this.config.store.delete(t),(t.object.termType===`NamedNode`||t.object.termType===`BlankNode`)&&this.removeFromDataGraph(t.object)}};window.customElements.define(`shacl-form`,$);export{Z as Config,J as DefaultTheme,x as Plugin,$ as ShaclForm,v as ShaclPropertyTemplate,_ as Theme,p as fetchRDF,y as findConformsToShapeSubject,D as findConformsToValuesSubject,d as findLabel,N as importRDF,Q as initTimeout,ee as isRangeQueryField,b as loadGraphs,n as loadRDF,t as parseRDF,u as prefixes,e as propertyMappers,E as rdfCache,C as registerPlugin};
package/dist/linker.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { Config } from "./config";
2
- import { ShaclProperty } from "./property";
3
- import { ShaclPropertyTemplate } from "./property-template";
4
- import { InputListEntry } from "./theme";
1
+ import { Config } from './config.js';
2
+ import { ShaclProperty } from './property.js';
3
+ import { ShaclPropertyTemplate } from './property-template.js';
4
+ import { InputListEntry } from './theme.js';
5
5
  export declare function createLinker(property: ShaclProperty): Promise<HTMLElement | undefined>;
6
6
  export declare function findLinkCandidates(property: ShaclProperty): InputListEntry[];
7
7
  export declare function loadConformingResources(property: ShaclPropertyTemplate): Promise<void>;
@@ -1,7 +1,7 @@
1
1
  import type { Literal, NamedNode, Quad } from 'n3';
2
2
  import { Term } from '@rdfjs/types';
3
- import { Config } from './config';
4
- import { ShaclPropertyTemplate } from './property-template';
3
+ import { Config } from './config.js';
4
+ import { ShaclPropertyTemplate } from './property-template.js';
5
5
  export declare class ShaclNodeTemplate {
6
6
  id: Term;
7
7
  label?: Literal | undefined;
package/dist/node.d.ts CHANGED
@@ -1,16 +1,21 @@
1
1
  import { BlankNode, NamedNode, Store } from 'n3';
2
2
  import { Term } from '@rdfjs/types';
3
- import { Config } from './config';
4
- import { ShaclNodeTemplate } from './node-template';
5
- import { ShaclPropertyTemplate } from './property-template';
3
+ import { Config } from './config.js';
4
+ import { ShaclNodeTemplate } from './node-template.js';
5
+ import { ShaclPropertyTemplate } from './property-template.js';
6
6
  export declare class ShaclNode extends HTMLElement {
7
7
  nodeId: NamedNode | BlankNode;
8
8
  template: ShaclNodeTemplate;
9
9
  linked: boolean;
10
10
  ready: Promise<void>;
11
11
  ancestorShapeIds: Set<string>;
12
- constructor(template: ShaclNodeTemplate, valueSubject: NamedNode | BlankNode | undefined, nodeKind?: NamedNode, label?: string, linked?: boolean, ancestorShapeIds?: Set<string>);
12
+ queryContext?: QueryPathContext;
13
+ constructor(template: ShaclNodeTemplate, valueSubject: NamedNode | BlankNode | undefined, nodeKind?: NamedNode, label?: string, linked?: boolean, ancestorShapeIds?: Set<string>, queryContext?: QueryPathContext);
13
14
  toRDF(graph: Store, subject?: NamedNode | BlankNode, generateNodeShapeReference?: string): (NamedNode | BlankNode);
14
15
  addPropertyInstance(template: ShaclPropertyTemplate, valueSubject: NamedNode | BlankNode | undefined, multiValuedPath?: boolean): Promise<void>;
15
16
  tryResolve(options: Term[], valueSubject: NamedNode | BlankNode | undefined, config: Config): Promise<void>;
16
17
  }
18
+ export type QueryPathContext = {
19
+ path: string[];
20
+ shapePath: string[];
21
+ };
package/dist/plugin.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { ShaclPropertyTemplate } from './property-template';
1
+ import { ShaclPropertyTemplate } from './property-template.js';
2
2
  import { Term } from '@rdfjs/types';
3
+ import type { QueryEditor, QueryField } from './query/index.js';
3
4
  export declare function registerPlugin(plugin: Plugin): void;
4
5
  export declare function listPlugins(): Plugin[];
5
6
  export declare function findPlugin(predicate: string | undefined, datatype: string | undefined): Plugin | undefined;
@@ -13,6 +14,7 @@ export declare abstract class Plugin {
13
14
  stylesheet: CSSStyleSheet | undefined;
14
15
  constructor(options: PluginOptions, css?: string);
15
16
  abstract createEditor(template: ShaclPropertyTemplate, value?: Term): HTMLElement;
17
+ createQueryEditor?(field: QueryField, template: ShaclPropertyTemplate): QueryEditor;
16
18
  createViewer(template: ShaclPropertyTemplate, value: Term): HTMLElement;
17
19
  }
18
20
  export type ClassInstanceProvider = (classes: Set<string>) => Promise<string>;
@@ -1,5 +1,5 @@
1
- import { Plugin, PluginOptions } from '../plugin';
2
- import { ShaclPropertyTemplate } from '../property-template';
1
+ import { Plugin, PluginOptions } from '../plugin.js';
2
+ import { ShaclPropertyTemplate } from '../property-template.js';
3
3
  export declare class FileUploadPlugin extends Plugin {
4
4
  onChange: (event: Event) => void;
5
5
  fileType: string | undefined;
@@ -1,11 +1,13 @@
1
1
  import * as L from 'leaflet';
2
2
  import 'leaflet-editable/src/Leaflet.Editable.js';
3
- import 'leaflet.fullscreen/Control.FullScreen.js';
3
+ import 'leaflet.fullscreen';
4
4
  import { Term } from '@rdfjs/types';
5
5
  import { Point, Polygon } from 'geojson';
6
- import { Plugin, PluginOptions } from '../plugin';
7
- import { Editor } from '../theme';
8
- import { ShaclPropertyTemplate } from '../property-template';
6
+ import 'leaflet.heat/dist/leaflet-heat.js';
7
+ import { Plugin, PluginOptions } from '../plugin.js';
8
+ import { Editor } from '../theme.js';
9
+ import { ShaclPropertyTemplate } from '../property-template.js';
10
+ import type { QueryEditor, QueryField } from '../query/index.js';
9
11
  export declare class LeafletPlugin extends Plugin {
10
12
  map: L.Map | undefined;
11
13
  currentEditor: Editor | undefined;
@@ -14,6 +16,7 @@ export declare class LeafletPlugin extends Plugin {
14
16
  constructor(options: PluginOptions);
15
17
  initEditMode(form: HTMLElement): HTMLDialogElement;
16
18
  createEditor(template: ShaclPropertyTemplate, value?: Term): HTMLElement;
19
+ createQueryEditor(field: QueryField, template: ShaclPropertyTemplate): QueryEditor;
17
20
  createViewer(_: ShaclPropertyTemplate, value: Term): HTMLElement;
18
21
  drawAndZoomToGeometry(geometry: Geometry | undefined, map: L.Map): void;
19
22
  saveChanges(): void;