@ulb-darmstadt/shacl-form 2.0.0-rc12 → 2.0.0-rc14

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
@@ -24,6 +24,7 @@ export declare class ElementAttributes {
24
24
  proxy: string | null;
25
25
  ignoreOwlImports: string | null;
26
26
  collapse: string | null;
27
+ hierarchyColors: string | null;
27
28
  submitButton: string | null;
28
29
  generateNodeShapeReference: string | null;
29
30
  showNodeIds: string | null;
@@ -41,6 +42,7 @@ export declare class Config {
41
42
  form: HTMLElement;
42
43
  renderedNodes: Set<string>;
43
44
  valuesGraphId: NamedNode | undefined;
45
+ hierarchyColorsStyleSheet: CSSStyleSheet | undefined;
44
46
  private _store;
45
47
  private _theme;
46
48
  private _nodeTemplates;
@@ -55,6 +57,7 @@ export declare class Config {
55
57
  registerPropertyTemplate(template: ShaclPropertyTemplate): void;
56
58
  getNodeTemplate(id: Term, parent: ShaclNodeTemplate | ShaclPropertyTemplate): ShaclNodeTemplate;
57
59
  getPropertyTemplate(id: Term, parent: ShaclNodeTemplate): ShaclPropertyTemplate;
60
+ get nodeTemplates(): ShaclNodeTemplate[];
58
61
  get theme(): Theme;
59
62
  set theme(theme: Theme);
60
63
  get store(): Store;
@@ -11,6 +11,7 @@ export declare const PREFIX_FOAF = "http://xmlns.com/foaf/0.1/";
11
11
  export declare const SHAPES_GRAPH: import("n3").NamedNode<"loaded-shapes">;
12
12
  export declare const DATA_GRAPH: import("n3").NamedNode<"loaded-data">;
13
13
  export declare const RDF_PREDICATE_TYPE: import("n3").NamedNode<string>;
14
+ export declare const RDF_OBJECT_LANG_STRING: import("n3").NamedNode<string>;
14
15
  export declare const DCTERMS_PREDICATE_CONFORMS_TO: import("n3").NamedNode<string>;
15
16
  export declare const RDFS_PREDICATE_SUBCLASS_OF: import("n3").NamedNode<string>;
16
17
  export declare const OWL_PREDICATE_IMPORTS: import("n3").NamedNode<string>;
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import{DataFactory as f,Literal as C,NamedNode as T,Writer as ye,Store as W,StreamParser as we,Quad as Se}from"n3";import{RokitCollapsible as X,RokitSelect as ue,RokitButton as Ee,RokitInput as F,RokitTextArea as xe}from"@ro-kit/ui-widgets";import{v4 as ie}from"uuid";import{RdfXmlParser as Ce}from"rdfxml-streaming-parser";import{toRDF as Le}from"jsonld";import{Validator as oe}from"shacl-engine";const d="http://www.w3.org/ns/shacl#",ae="http://datashapes.org/dash#",E="http://www.w3.org/2001/XMLSchema#",S="http://www.w3.org/1999/02/22-rdf-syntax-ns#",J="http://www.w3.org/2000/01/rdf-schema#",Y="http://www.w3.org/2004/02/skos/core#",Te="http://www.w3.org/2002/07/owl#",Ie="http://www.w3.org/ns/oa#",je="http://purl.org/dc/terms/",Re="http://xmlns.com/foaf/0.1/",I=f.namedNode("loaded-shapes"),v=f.namedNode("loaded-data"),m=f.namedNode(S+"type"),z=f.namedNode(je+"conformsTo"),re=f.namedNode(J+"subClassOf"),Z=f.namedNode(Te+"imports"),De=f.namedNode(Y+"broader"),Pe=f.namedNode(Y+"narrower"),q=f.namedNode(d+"NodeShape"),$e=f.namedNode(d+"IRI"),U=f.namedNode(d+"property"),ee=f.namedNode(d+"class");f.namedNode(d+"node");const k=f.namedNode(d+"targetClass"),Ne=f.namedNode(d+"nodeKind"),Ae=f.namedNode(E+"string");function j(s,e,t=d,i){let n="";const o=_e(s,e,t,i);return o&&(n=o.value),n}function _e(s,e,t=d,i){let n;const o=t+e;if(i?.length){for(const a of i)for(const r of s)if(r.predicate.value===o){if(r.object.id.endsWith(`@${a}`))return r.object;r.object.id.indexOf("@")<0?n=r.object:n||(n=r.object)}}else for(const a of s)if(a.predicate.value===o)return a.object;return n}function Oe(s){s.querySelector(".editor")?.focus()}function D(s,e){return j(s,"prefLabel",Y,e)||j(s,"label",J,e)||j(s,"name",Re,e)}function he(s,e,t){const i=[];for(const n of s)i.push({value:n,label:D(e.getQuads(n,null,null,null),t),children:[]});return i}function G(s,e){for(const t in e)s=s.replace(e[t],"");return s}function fe(s,e,t,i,n=new Set){for(const o of e.owlImports)n.has(o.id)||(n.add(o.id),i.push(...t.getSubjects(m,s,o)));e.parent&&fe(s,e.parent,t,i,n)}function te(s,e){if(e.in){const t=e.config.lists[e.in];return he(t?.length?t:[],e.config.store,e.config.languages)}else{const t=e.config.store.getSubjects(m,s,I);t.push(...e.config.store.getSubjects(m,s,v)),fe(s,e,e.config.store,t);const i=new Map,n=new Map;for(const a of t)i.set(a.id,{value:a,label:D(e.config.store.getQuads(a,null,null,null),e.config.languages),children:[]});for(const a of t){for(const r of e.config.store.getObjects(a,De,null))i.has(r.id)&&n.set(a.id,r.id);for(const r of e.config.store.getObjects(a,Pe,null))i.has(r.id)&&n.set(r.id,a.id);for(const r of e.config.store.getObjects(a,re,null))i.has(r.id)&&n.set(a.id,r.id)}for(const[a,r]of n.entries())i.get(r)?.children?.push(i.get(a));const o=[];for(const[a,r]of i.entries())n.has(a)||o.push(r);for(const a of e.config.store.getSubjects(re,s,null))o.push(...te(a,e));return o}}function K(s){let e;try{e=new URL(s)}catch{return!1}return e.protocol==="http:"||e.protocol==="https:"}function le(s,e,t){if(e===void 0)return t;if(t===void 0)return e;const i=s.indexOf(e.language);if(i<0)return t;const n=s.indexOf(t.language);return n<0||n>i?e:t}function ke(s,{remove:e=!1,ignoreErrors:t=!1}={}){const i={},n=t?(()=>!0):((r,l)=>{throw new Error(`${r.value} ${l}`)}),o=s.getQuads(null,S+"rest",S+"nil",null),a=e?[...o]:[];return o.forEach(r=>{const l=[];let c=!1,u,h;const g=r.graph;let p=r.subject;for(;p&&!c;){const w=s.getQuads(null,null,p,null),x=s.getQuads(p,null,null,null).filter(y=>!y.predicate.equals(m));let b,P=null,ne=null,$=null;for(let y=0;y<x.length&&!c;y++)b=x[y],b.graph.equals(g)?u?c=n(p,"has non-list arcs out"):b.predicate.value===S+"first"?P?c=n(p,"has multiple rdf:first arcs"):a.push(P=b):b.predicate.value===S+"rest"?ne?c=n(p,"has multiple rdf:rest arcs"):a.push(ne=b):w.length?c=n(p,"can't be subject and object"):(u=b,h="subject"):c=n(p,"not confined to single graph");for(let y=0;y<w.length&&!c;++y)b=w[y],u?c=n(p,"can't have coreferences"):b.predicate.value===S+"rest"?$?c=n(p,"has incoming rdf:rest arcs"):$=b:(u=b,h="object");P?l.unshift(P.object):c=n(p,"has no list head"),p=$&&$.subject}c?e=!1:u&&(i[u[h].value]=l)}),e&&s.removeQuads(a),i}const Fe={[`${d}name`]:(s,e)=>{const t=e;s.name=le(s.config.languages,s.name,t)},[`${d}description`]:(s,e)=>{const t=e;s.description=le(s.config.languages,s.description,t)},[`${d}path`]:(s,e)=>{s.path=e.value},[`${d}group`]:(s,e)=>{s.group=e.id},[`${d}datatype`]:(s,e)=>{s.datatype=e},[`${d}nodeKind`]:(s,e)=>{s.nodeKind=e},[`${d}minCount`]:(s,e)=>{s.minCount=parseInt(e.value)},[`${d}maxCount`]:(s,e)=>{s.maxCount=parseInt(e.value)},[`${d}minLength`]:(s,e)=>{s.minLength=parseInt(e.value)},[`${d}maxLength`]:(s,e)=>{s.maxLength=parseInt(e.value)},[`${d}minInclusive`]:(s,e)=>{s.minInclusive=parseInt(e.value)},[`${d}maxInclusive`]:(s,e)=>{s.maxInclusive=parseInt(e.value)},[`${d}minExclusive`]:(s,e)=>{s.minExclusive=parseInt(e.value)},[`${d}maxExclusive`]:(s,e)=>{s.maxExclusive=parseInt(e.value)},[`${d}pattern`]:(s,e)=>{s.pattern=e.value},[`${d}order`]:(s,e)=>{s.order=parseInt(e.value)},[`${ae}singleLine`]:(s,e)=>{s.singleLine=e.value==="true"},[`${ae}readonly`]:(s,e)=>{s.readonly=e.value==="true"},[`${Ie}styleClass`]:(s,e)=>{s.cssClass=e.value},[`${d}in`]:(s,e)=>{s.in=e.value},[`${d}languageIn`]:(s,e)=>{s.languageIn=s.config.lists[e.value],s.datatype=f.namedNode(S+"langString")},[`${d}defaultValue`]:(s,e)=>{s.defaultValue=e},[`${d}hasValue`]:(s,e)=>{s.hasValue=e},[`${d}node`]:(s,e)=>{s.node=e,s.nodeShapes.add(s.config.getNodeTemplate(e,s))},[`${d}and`]:(s,e)=>{s.and=e.value;const t=s.config.lists[s.and];if(t?.length)for(const i of t)s.nodeShapes.add(s.config.getNodeTemplate(i,s))},[`${d}qualifiedValueShape`]:(s,e)=>{const t=s.config.getNodeTemplate(e,s);s.qualifiedValueShape=t,s.nodeShapes.add(t)},[`${d}qualifiedMinCount`]:(s,e)=>{s.minCount=parseInt(e.value)},[`${d}qualifiedMaxCount`]:(s,e)=>{s.maxCount=parseInt(e.value)},[Z.id]:(s,e)=>{s.owlImports.add(e)},[ee.id]:(s,e)=>{s.class=e;const t=s.config.store.getSubjects(k,e,null);t.length>0&&(s.node=t[0])},[`${d}or`]:(s,e)=>{const t=s.config.lists[e.value];t?.length?s.or=t:console.error("list for sh:or not found:",e.value,"existing lists:",s.config.lists)},[`${d}xone`]:(s,e)=>{const t=s.config.lists[e.value];t?.length?s.xone=t:console.error("list for sh:xone not found:",e.value,"existing lists:",s.config.lists)}};class M{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),se(this,this.config.store.getQuads(e,null,null,null))}}function pe(s){const e=Object.assign({},s);return e.nodeShapes=new Set(s.nodeShapes),e.owlImports=new Set(s.owlImports),s.languageIn&&(e.languageIn=[...s.languageIn]),s.or&&(e.or=[...s.or]),s.xone&&(e.xone=[...s.xone]),e}function se(s,e){for(const t of e)Fe[t.predicate.id]?.call(s,s,t.object);return s.label=s.name?.value||D(e,s.config.languages),s.label||(s.label=s.path?G(s.path,s.config.prefixes):"unknown"),s}function ge(s,e){const t=e,i=s;for(const n in e)n!=="parent"&&n!=="config"&&n!=="id"&&t[n]!==void 0&&t[n]!==""&&(Array.isArray(t[n])?i[n].push(...t[n]):t[n]instanceof Set&&t[n].size?i[n]=new Set([...i[n],...t[n]]):i[n]=t[n])}function me(s,e,t){const i=document.createElement("div");i.classList.add("shacl-or-constraint");const n=[];if(e instanceof L){const o=[];let a=!1;s.length&&(a=t.store.countQuads(s[0],U,null,null)>0);for(let c=0;c<s.length;c++)if(a){const u=t.store.getObjects(s[c],U,null),h=[];let g="";for(const p of u){const w=t.getPropertyTemplate(p,e.template),x=new _(w,e);h.push(x),g+=(g.length>1?" / ":"")+x.template.label}o.push(h),n.push({label:g,value:c.toString()})}else{const u=s[c],h=t.getPropertyTemplate(u,e.template),g=new _(h,e);o.push([g]),n.push({label:g.template.label,value:c.toString()})}const r=t.theme.createListEditor("Please choose",null,!1,n),l=r.querySelector(".editor");l.onchange=()=>{if(l.value){const c=o[parseInt(l.value)];let u;c.length&&(u=c[0],i.replaceWith(c[0]));for(let h=1;h<c.length;h++)u.after(c[h]),u=c[h]}},i.appendChild(r)}else{const o=[];for(let l=0;l<s.length;l++){const c=t.store.getQuads(s[l],null,null,null);c.length&&(o.push(c),n.push({label:D(c,t.languages)||G(c[0].predicate.value,t.prefixes)+" = "+G(c[0].object.value,t.prefixes),value:l.toString()}))}const a=t.theme.createListEditor(e.template.label+"?",null,!1,n,e.template),r=a.querySelector(".editor");r.onchange=()=>{if(r.value){const l=se(pe(e.template),o[parseInt(r.value)]);i.replaceWith(N(l,void 0,!0))}},i.appendChild(a)}return i}function qe(s,e,t){if(e instanceof C){const i=e.datatype;for(const n of s){const o=t.store.getQuads(n,null,null,null);for(const a of o)if(a.predicate.value===`${d}datatype`&&a.object.equals(i))return o}}else{const i=t.store.getObjects(e,m,null);for(const n of s){const o=t.store.getQuads(n,null,null,null);for(const a of o)if(i.length>0){if(a.predicate.value===`${d}node`){for(const r of i)if(t.store.getQuads(a.object,k,r,null).length>0)return o}if(a.predicate.equals(ee)){for(const r of i)if(a.object.equals(r))return o}}else if(a.predicate.equals(Ne)&&a.object.equals($e))return o}}return console.error("couldn't resolve sh:or/sh:xone on property for value",e),[]}function Ve(s,e,t){for(const i of s){let n=!1;const o=t.store.getObjects(i,U,null);for(const a of o){const r=t.store.getObjects(a,`${d}path`,null);for(const l of r)if(n=t.store.countQuads(e,l,null,null)>0,n)break}if(n)return o}return console.error("couldn't resolve sh:or/sh:xone on node for value",e),[]}const Qe=`form { display:block; --label-width: 8em; --caret-size: 10px; }
1
+ import{DataFactory as f,Literal as S,NamedNode as I,Writer as ye,Store as H,StreamParser as we,Quad as Se}from"n3";import{RokitCollapsible as K,RokitSelect as de,RokitButton as Ee,RokitInput as k,RokitTextArea as xe}from"@ro-kit/ui-widgets";import{v4 as se}from"uuid";import{RdfXmlParser as Ce}from"rdfxml-streaming-parser";import{toRDF as Le}from"jsonld";import{Validator as ne}from"shacl-engine";const d="http://www.w3.org/ns/shacl#",ie="http://datashapes.org/dash#",E="http://www.w3.org/2001/XMLSchema#",C="http://www.w3.org/1999/02/22-rdf-syntax-ns#",W="http://www.w3.org/2000/01/rdf-schema#",X="http://www.w3.org/2004/02/skos/core#",Te="http://www.w3.org/2002/07/owl#",Ie="http://www.w3.org/ns/oa#",je="http://purl.org/dc/terms/",Re="http://xmlns.com/foaf/0.1/",j=f.namedNode("loaded-shapes"),v=f.namedNode("loaded-data"),m=f.namedNode(C+"type"),he=f.namedNode(C+"langString"),B=f.namedNode(je+"conformsTo"),oe=f.namedNode(W+"subClassOf"),J=f.namedNode(Te+"imports"),De=f.namedNode(X+"broader"),$e=f.namedNode(X+"narrower"),F=f.namedNode(d+"NodeShape"),ue=f.namedNode(d+"IRI"),z=f.namedNode(d+"property"),Y=f.namedNode(d+"class");f.namedNode(d+"node");const _=f.namedNode(d+"targetClass"),Pe=f.namedNode(d+"nodeKind"),Ne=f.namedNode(E+"string");function R(s,e,t=d,i){let n="";const o=Ae(s,e,t,i);return o&&(n=o.value),n}function Ae(s,e,t=d,i){let n;const o=t+e;if(i?.length){for(const a of i)for(const r of s)if(r.predicate.value===o){if(r.object.id.endsWith(`@${a}`))return r.object;r.object.id.indexOf("@")<0?n=r.object:n||(n=r.object)}}else for(const a of s)if(a.predicate.value===o)return a.object;return n}function Oe(s){s.querySelector(".editor")?.focus()}function T(s,e){return R(s,"prefLabel",X,e)||R(s,"label",W,e)||R(s,"name",Re,e)}function fe(s,e,t){const i=[];for(const n of s)i.push({value:n,label:T(e.getQuads(n,null,null,null),t),children:[]});return i}function M(s,e){for(const t in e)s=s.replace(e[t],"");return s}function pe(s,e,t,i,n=new Set){for(const o of e.owlImports)n.has(o.id)||(n.add(o.id),i.push(...t.getSubjects(m,s,o)));e.parent&&pe(s,e.parent,t,i,n)}function Z(s,e){if(e.in){const t=e.config.lists[e.in];return fe(t?.length?t:[],e.config.store,e.config.languages)}else{const t=e.config.store.getSubjects(m,s,j);t.push(...e.config.store.getSubjects(m,s,v)),pe(s,e,e.config.store,t);const i=new Map,n=new Map;for(const a of t)i.set(a.id,{value:a,label:T(e.config.store.getQuads(a,null,null,null),e.config.languages),children:[]});for(const a of t){for(const r of e.config.store.getObjects(a,De,null))i.has(r.id)&&n.set(a.id,r.id);for(const r of e.config.store.getObjects(a,$e,null))i.has(r.id)&&n.set(r.id,a.id);for(const r of e.config.store.getObjects(a,oe,null))i.has(r.id)&&n.set(a.id,r.id)}for(const[a,r]of n.entries())i.get(r)?.children?.push(i.get(a));const o=[];for(const[a,r]of i.entries())n.has(a)||o.push(r);for(const a of e.config.store.getSubjects(oe,s,null))o.push(...Z(a,e));return o}}function G(s){let e;try{e=new URL(s)}catch{return!1}return e.protocol==="http:"||e.protocol==="https:"}function ae(s,e,t){if(e===void 0)return t;if(t===void 0)return e;const i=s.indexOf(e.language);if(i<0)return t;const n=s.indexOf(t.language);return n<0||n>i?e:t}function _e(s,{remove:e=!1,ignoreErrors:t=!1}={}){const i={},n=t?(()=>!0):((r,l)=>{throw new Error(`${r.value} ${l}`)}),o=s.getQuads(null,C+"rest",C+"nil",null),a=e?[...o]:[];return o.forEach(r=>{const l=[];let c=!1,u,h;const g=r.graph;let p=r.subject;for(;p&&!c;){const w=s.getQuads(null,null,p,null),x=s.getQuads(p,null,null,null).filter(y=>!y.predicate.equals(m));let b,$=null,te=null,P=null;for(let y=0;y<x.length&&!c;y++)b=x[y],b.graph.equals(g)?u?c=n(p,"has non-list arcs out"):b.predicate.value===C+"first"?$?c=n(p,"has multiple rdf:first arcs"):a.push($=b):b.predicate.value===C+"rest"?te?c=n(p,"has multiple rdf:rest arcs"):a.push(te=b):w.length?c=n(p,"can't be subject and object"):(u=b,h="subject"):c=n(p,"not confined to single graph");for(let y=0;y<w.length&&!c;++y)b=w[y],u?c=n(p,"can't have coreferences"):b.predicate.value===C+"rest"?P?c=n(p,"has incoming rdf:rest arcs"):P=b:(u=b,h="object");$?l.unshift($.object):c=n(p,"has no list head"),p=P&&P.subject}c?e=!1:u&&(i[u[h].value]=l)}),e&&s.removeQuads(a),i}const ke={[`${d}name`]:(s,e)=>{const t=e;s.name=ae(s.config.languages,s.name,t)},[`${d}description`]:(s,e)=>{const t=e;s.description=ae(s.config.languages,s.description,t)},[`${d}path`]:(s,e)=>{s.path=e.value},[`${d}group`]:(s,e)=>{s.group=e.id},[`${d}datatype`]:(s,e)=>{s.datatype=e},[`${d}nodeKind`]:(s,e)=>{s.nodeKind=e},[`${d}minCount`]:(s,e)=>{s.minCount=parseInt(e.value)},[`${d}maxCount`]:(s,e)=>{s.maxCount=parseInt(e.value)},[`${d}minLength`]:(s,e)=>{s.minLength=parseInt(e.value)},[`${d}maxLength`]:(s,e)=>{s.maxLength=parseInt(e.value)},[`${d}minInclusive`]:(s,e)=>{s.minInclusive=parseInt(e.value)},[`${d}maxInclusive`]:(s,e)=>{s.maxInclusive=parseInt(e.value)},[`${d}minExclusive`]:(s,e)=>{s.minExclusive=parseInt(e.value)},[`${d}maxExclusive`]:(s,e)=>{s.maxExclusive=parseInt(e.value)},[`${d}pattern`]:(s,e)=>{s.pattern=e.value},[`${d}order`]:(s,e)=>{s.order=parseInt(e.value)},[`${ie}singleLine`]:(s,e)=>{s.singleLine=e.value==="true"},[`${ie}readonly`]:(s,e)=>{s.readonly=e.value==="true"},[`${Ie}styleClass`]:(s,e)=>{s.cssClass=e.value},[`${d}in`]:(s,e)=>{s.in=e.value},[`${d}languageIn`]:(s,e)=>{s.languageIn=s.config.lists[e.value],s.datatype=he},[`${d}defaultValue`]:(s,e)=>{s.defaultValue=e},[`${d}hasValue`]:(s,e)=>{s.hasValue=e},[`${d}node`]:(s,e)=>{s.node=e,s.nodeShapes.add(s.config.getNodeTemplate(e,s))},[`${d}and`]:(s,e)=>{s.and=e.value;const t=s.config.lists[s.and];if(t?.length)for(const i of t)s.nodeShapes.add(s.config.getNodeTemplate(i,s))},[`${d}qualifiedValueShape`]:(s,e)=>{const t=s.config.getNodeTemplate(e,s);s.qualifiedValueShape=t,s.nodeShapes.add(t)},[`${d}qualifiedMinCount`]:(s,e)=>{s.minCount=parseInt(e.value)},[`${d}qualifiedMaxCount`]:(s,e)=>{s.maxCount=parseInt(e.value)},[J.id]:(s,e)=>{s.owlImports.add(e)},[Y.id]:(s,e)=>{s.class=e;const t=s.config.store.getSubjects(_,e,null);t.length>0&&(s.node=t[0])},[`${d}or`]:(s,e)=>{const t=s.config.lists[e.value];t?.length?s.or=t:console.error("list for sh:or not found:",e.value,"existing lists:",s.config.lists)},[`${d}xone`]:(s,e)=>{const t=s.config.lists[e.value];t?.length?s.xone=t:console.error("list for sh:xone not found:",e.value,"existing lists:",s.config.lists)}};class re{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),ee(this,this.config.store.getQuads(e,null,null,null))}}function ge(s){const e=Object.assign({},s);return e.nodeShapes=new Set(s.nodeShapes),e.owlImports=new Set(s.owlImports),s.languageIn&&(e.languageIn=[...s.languageIn]),s.or&&(e.or=[...s.or]),s.xone&&(e.xone=[...s.xone]),e}function ee(s,e){for(const t of e)ke[t.predicate.id]?.call(s,s,t.object);return s.label=s.name?.value||T(e,s.config.languages),s.label||(s.label=s.path?M(s.path,s.config.prefixes):"unknown"),s}function me(s,e){const t=e,i=s;for(const n in e)n!=="parent"&&n!=="config"&&n!=="id"&&t[n]!==void 0&&t[n]!==""&&(Array.isArray(t[n])?i[n].push(...t[n]):t[n]instanceof Set&&t[n].size?i[n]=new Set([...i[n],...t[n]]):i[n]=t[n])}function be(s,e,t){const i=document.createElement("div");i.classList.add("shacl-or-constraint");const n=[];if(e instanceof L){const o=[];let a=!1;s.length&&(a=t.store.countQuads(s[0],z,null,null)>0);for(let c=0;c<s.length;c++)if(a){const u=t.store.getObjects(s[c],z,null),h=[];let g="";for(const p of u){const w=t.getPropertyTemplate(p,e.template),x=new A(w,e);h.push(x),g+=(g.length>1?" / ":"")+x.template.label}o.push(h),n.push({label:g,value:c.toString()})}else{const u=s[c],h=t.getPropertyTemplate(u,e.template),g=new A(h,e);o.push([g]),n.push({label:g.template.label,value:c.toString()})}const r=t.theme.createListEditor("Please choose",null,!1,n),l=r.querySelector(".editor");l.onchange=()=>{if(l.value){const c=o[parseInt(l.value)];let u;c.length&&(u=c[0],i.replaceWith(c[0]));for(let h=1;h<c.length;h++)u.after(c[h]),u=c[h]}},i.appendChild(r)}else{const o=[];for(let l=0;l<s.length;l++){const c=t.store.getQuads(s[l],null,null,null);c.length&&(o.push(c),n.push({label:T(c,t.languages)||M(c[0].predicate.value,t.prefixes)+" = "+M(c[0].object.value,t.prefixes),value:l.toString()}))}const a=t.theme.createListEditor(e.template.label+"?",null,!1,n,e.template),r=a.querySelector(".editor");r.onchange=()=>{if(r.value){const l=ee(ge(e.template),o[parseInt(r.value)]);i.replaceWith(N(l,void 0,!0))}},i.appendChild(a)}return i}function Fe(s,e,t){if(e instanceof S){const i=e.datatype;for(const n of s){const o=t.store.getQuads(n,null,null,null);for(const a of o)if(a.predicate.value===`${d}datatype`&&a.object.equals(i))return o}}else{const i=t.store.getObjects(e,m,null);for(const n of s){const o=t.store.getQuads(n,null,null,null);for(const a of o)if(i.length>0){if(a.predicate.value===`${d}node`){for(const r of i)if(t.store.getQuads(a.object,_,r,null).length>0)return o}if(a.predicate.equals(Y)){for(const r of i)if(a.object.equals(r))return o}}else if(a.predicate.equals(Pe)&&a.object.equals(ue))return o}}return console.error("couldn't resolve sh:or/sh:xone on property for value",e),[]}function qe(s,e,t){for(const i of s){let n=!1;const o=t.store.getObjects(i,z,null);for(const a of o){const r=t.store.getObjects(a,`${d}path`,null);for(const l of r)if(n=t.store.countQuads(e,l,null,null)>0,n)break}if(n)return o}return console.error("couldn't resolve sh:or/sh:xone on node for value",e),[]}const Ve=`form { display:block; --label-width: 8em; --caret-size: 10px; }
2
2
  form.mode-edit { padding-left: 1em; }
3
3
  form, form * { box-sizing: border-box; }
4
4
  shacl-node, .collapsible::part(content) { display: flex; flex-direction: column; width: 100%; position: relative; }
5
- shacl-node .remove-button { margin-left: 4px; margin-top: 1px; }
5
+ shacl-node .remove-button { margin-top: 1px; }
6
6
  shacl-node .add-button { color: #555; background-color: transparent; margin: 4px 24px 0 0; border: 0; }
7
7
  shacl-node .add-button:hover { color:#222; }
8
8
  shacl-node .add-button:focus { box-shadow: none; }
@@ -47,17 +47,30 @@ a, a:visited { color: inherit; }
47
47
  .collapsible > .property-instance > shacl-node > h1 { display: none; }
48
48
  .ref-link { cursor: pointer; }
49
49
  .ref-link:hover { text-decoration: underline; }
50
- .node-id-display { color: #999; font-size: 11px; }`;class Be{constructor(e){this.dense=!0;let t=Qe;e&&(t+=`
51
- `+e),this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(t)}apply(e){}setDense(e){this.dense=e}createViewer(e,t,i){const n=document.createElement("div"),o=document.createElement("label");o.innerHTML=e+":",i.description&&o.setAttribute("title",i.description.value),n.appendChild(o);let a=t.value,r=null;if(t instanceof T){const c=i.config.store.getQuads(a,null,null,null);if(c.length){const u=D(c,i.config.languages);u&&(a=u)}}else t instanceof C&&(t.language?(r=document.createElement("span"),r.classList.add("lang"),r.innerText=`@${t.language}`):t.datatype.value===`${E}date`?a=new Date(Date.parse(t.value)).toDateString():t.datatype.value===`${E}dateTime`&&(a=new Date(Date.parse(t.value)).toLocaleString()));let l;return K(t.value)?(l=document.createElement("a"),l.setAttribute("href",t.value)):l=document.createElement("div"),l.classList.add("d-flex"),l.innerText=a,r&&l.appendChild(r),n.appendChild(l),n}}function ze(s,e,t){if(t){const i=s.minCount!==void 0&&s.minCount>0;if(s.class&&!s.hasValue)return s.config.theme.createListEditor(s.label,e,i,te(s.class,s),s);if(s.in){const n=s.config.lists[s.in];if(n?.length){const o=he(n,s.config.store,s.config.languages);return s.config.theme.createListEditor(s.label,e,i,o,s)}else console.error("list not found:",s.in,"existing lists:",s.config.lists)}if(s.datatype?.value===`${S}langString`||s.languageIn?.length)return s.config.theme.createLangStringEditor(s.label,e,i,s);switch(s.datatype?.value.replace(E,"")){case"integer":case"float":case"double":case"decimal":return s.config.theme.createNumberEditor(s.label,e,i,s);case"date":case"dateTime":return s.config.theme.createDateEditor(s.label,e,i,s);case"boolean":return s.config.theme.createBooleanEditor(s.label,e,i,s);case"base64Binary":return s.config.theme.createFileEditor(s.label,e,i,s)}return s.config.theme.createTextEditor(s.label,e,i,s)}else{if(e)return s.config.theme.createViewer(s.label,e,s);const i=document.createElement("div");return i.innerHTML="No value",i}}function Ue(s,e,t){if(e==="application/ld+json")return Ge(s);{const i=new ye({format:e,prefixes:t});i.addQuads(s);let n="";return i.end((o,a)=>{o&&console.error(o),n=a}),n}}function Ge(s){const e=[];for(const t of s){const i={"@id":t.subject.id};if(t.predicate===m)i["@type"]=t.object.id;else{let n=t.object.value;t.object instanceof C?t.object.language?n={"@language":t.object.language,"@value":t.object.value}:t.object.datatype&&t.object.datatype.value!==`${E}#string`&&(n={"@type":t.object.datatype.value,"@value":t.object.value}):n={"@id":t.object.id},i[t.predicate.value]=n}e.push(i)}return JSON.stringify(e)}function Ke(s){let e=s.shaclDatatype,t=s.value;if(t){if(t.startsWith("<")&&t.endsWith(">")&&t.indexOf(":")>-1)return f.namedNode(t.substring(1,t.length-1));if(s.dataset.class||s.dataset.nodeKind===d+"IRI")return f.namedNode(t);if(s.dataset.link)return JSON.parse(s.dataset.link);if(s.dataset.lang?e=s.dataset.lang:s.type==="number"?t=parseFloat(t):s.type==="file"&&s.binaryData?t=s.binaryData:s.type==="datetime-local"&&(t=new Date(t).toISOString().slice(0,19)),(!e||e instanceof T&&Ae.equals(e))&&typeof t=="string"){let i=t.split("^^");i.length===2&&i[0].startsWith('"')&&i[0].endsWith('"')&&i[1].split(":").length===2?(t=i[0].substring(1,i[0].length-1),e=f.namedNode(i[1])):(i=t.split("@"),i.length===2&&i[0].startsWith('"')&&i[0].endsWith('"')?(t=i[0].substring(1,i[0].length-1),e=i[1]):t.startsWith('"')&&t.endsWith('"')&&(t=t.substring(1,t.length-1)))}return f.literal(t,e)}else if((s.type==="checkbox"||s.getAttribute("type")==="checkbox")&&(s.checked||parseInt(s.dataset.minCount||"0")>0))return f.literal(s.checked?"true":"false",e)}const R={};function Me(s){s.predicate===void 0&&s.datatype===void 0?console.warn('not registering plugin because it does neither define "predicate" nor "datatype"',s):R[`${s.predicate}^${s.datatype}`]=s}function He(){return Object.entries(R).map(s=>s[1])}function We(s,e){let t=R[`${s}^${e}`];return t||(t=R[`${s}^undefined`],t)?t:R[`undefined^${e}`]}class dt{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)}}class _ extends HTMLElement{constructor(e,t,i){if(super(),this.template=e,this.parent=t,this.container=this,this.template.nodeShapes.size&&this.template.config.attributes.collapse!==null&&(this.template.maxCount===void 0||this.template.maxCount>1)){const n=new X;n.classList.add("collapsible","shacl-group"),n.open=e.config.attributes.collapse==="open",n.label=this.template.label,this.container=n,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.addButton=this.createAddButton(),this.container.appendChild(this.addButton),this.addEventListener("change",()=>{this.updateControls()})),(async()=>{if(e.path){let n=[];i&&(n=e.config.store.getQuads(i,e.path,null,t.linked?null:v),n=await this.filterValidValues(n,i));let o=!1;for(const a of n)this.addPropertyInstance(a.object),e.hasValue&&a.object.equals(e.hasValue)&&(o=!0);e.config.editMode&&(e.hasValue&&!o&&!t.linked&&this.addPropertyInstance(e.hasValue),this.updateControls())}})()}addPropertyInstance(e){let t;if(this.template.or?.length||this.template.xone?.length){const i=this.template.or?.length?this.template.or:this.template.xone;let n=!1;if(e){const o=qe(i,e,this.template.config);if(o.length){const a=se(pe(this.template),o);t=N(a,e,!0),n=!0}}n||(t=me(i,this,this.template.config),be(t,"",this.template.config.theme.dense))}else{let i=!1;if(e&&!(e instanceof C)){const n=this.getRdfClassToLinkOrCreate();n&&this.template.config.store.countQuads(e,m,n,v)===0&&(i=!0)}t=N(this.template,e,void 0,i||this.parent.linked)}return this.addButton?this.container.insertBefore(t,this.addButton):this.container.appendChild(t),t}updateControls(){let e=this.instanceCount();e===0&&(this.template.nodeShapes.size===0||this.template.minCount!==void 0&&this.template.minCount>0)&&(this.addPropertyInstance(),e=this.instanceCount());let t;this.template.minCount!==void 0?t=e>this.template.minCount:t=this.template.nodeShapes.size>0||e>1;const i=this.template.maxCount===void 0||e<this.template.maxCount;this.classList.toggle("may-remove",t),this.classList.toggle("may-add",i)}instanceCount(){return this.querySelectorAll(":scope > .property-instance, :scope > .shacl-or-constraint, :scope > shacl-node, :scope > .collapsible > .property-instance").length}toRDF(e,t){const i=f.namedNode(this.template.path);for(const n of this.querySelectorAll(":scope > .property-instance, :scope > .collapsible > .property-instance"))if(n.firstChild instanceof L){const o=n.firstChild.toRDF(e);e.addQuad(t,i,o,this.template.config.valuesGraphId)}else for(const o of n.querySelectorAll(":scope > .editor")){const a=Ke(o);a&&e.addQuad(t,i,a,this.template.config.valuesGraphId)}}getRdfClassToLinkOrCreate(){if(this.template.class&&this.template.nodeShapes.size)return this.template.class;for(const e of this.template.nodeShapes)if(e.targetClass)return e.targetClass}async filterValidValues(e,t){let i=this.template.id,n=[t];if(this.template.qualifiedValueShape){i=this.template.qualifiedValueShape.id,n=[];for(const r of e)n.push(r.object)}const o=await this.template.config.validator.validate({dataset:this.template.config.store,terms:n},[{terms:[i]}]),a=[];for(const r of o.results){const l=this.template.qualifiedValueShape?r.focusNode:r.value;l?.ptrs?.length&&a.push(l.ptrs[0]._term.id)}return e.filter(r=>a.indexOf(r.object.id)===-1)}createAddButton(){const e=new ue;e.dense=this.template.config.theme.dense,e.label="+ "+this.template.label,e.title="Add "+this.template.label,e.autoGrowLabelWidth=!0,e.classList.add("add-button");let t=[],i=this.getRdfClassToLinkOrCreate();if(i&&(t=te(i,this.template)),t.length===0)e.emptyMessage="",e.inputMinWidth=0,e.addEventListener("click",n=>{e.blur();const o=this.addPropertyInstance();o.classList.add("fadeIn"),this.updateControls(),setTimeout(()=>{Oe(o),o.classList.remove("fadeIn")},200)});else{const n=document.createElement("ul"),o=document.createElement("li");o.innerHTML="&#xFF0B; Create new "+this.template.label+"...",o.dataset.value="new",o.classList.add("large"),n.appendChild(o);const a=document.createElement("li");a.classList.add("divider"),n.appendChild(a);const r=document.createElement("li");r.classList.add("header"),r.innerText="Or link existing:",n.appendChild(r);for(const l of t){const c=document.createElement("li"),u=typeof l.value=="string"?l.value:l.value.value;c.innerText=l.label?l.label:u,c.dataset.value=JSON.stringify(l.value),n.appendChild(c)}e.appendChild(n),e.collapsibleWidth="250px",e.collapsibleOrientationLeft="",e.addEventListener("change",()=>{if(e.value==="new")this.addPropertyInstance();else{const l=JSON.parse(e.value);this.container.insertBefore(N(this.template,l,!0,!0),e)}e.value=""})}return e}}function N(s,e,t=!1,i=!1){let n;if(s.nodeShapes.size){n=document.createElement("div"),n.classList.add("property-instance");for(const o of s.nodeShapes)n.appendChild(new L(o,e,s.nodeKind,s.label,i))}else{const o=We(s.path,s.datatype?.value);o?s.config.editMode&&!i?n=o.createEditor(s,e):n=o.createViewer(s,e):n=ze(s,e||null,s.config.editMode&&!i),n.classList.add("property-instance"),i&&n.classList.add("linked")}return s.config.editMode&&be(n,s.label,s.config.theme.dense,t),n.dataset.path=s.path,n}function be(s,e,t,i=!1){const n=new Ee;n.classList.add("remove-button","clear"),n.title="Remove "+e,n.dense=t,n.icon=!0,n.addEventListener("click",o=>{s.classList.remove("fadeIn"),s.classList.add("fadeOut"),setTimeout(()=>{const a=s.parentElement;s.remove(),a?.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))},200)}),i&&n.classList.add("persistent"),s.appendChild(n)}window.customElements.define("shacl-property",_);function Xe(s,e){let t=s;const i=e.store.getQuads(s,null,null,null),n=j(i,"label",J,e.languages);n&&(t=n);let o;if(e.attributes.collapse!==null)o=new X,o.classList.add("collapsible"),o.open=e.attributes.collapse==="open",o.label=t;else{o=document.createElement("div");const r=document.createElement("h1");r.innerText=t,o.appendChild(r)}o.dataset.subject=s,o.classList.add("shacl-group");const a=j(i,"order");return a&&(o.style.order=a),o}class L extends HTMLElement{constructor(e,t,i,n,o){super(),this.template=e,this.linked=o||!1;let a=t;a||(!i&&e.nodeKind&&(i=e.nodeKind),i===void 0&&e.config.attributes.valuesNamespace||i?.value===`${d}IRI`?a=f.namedNode(e.config.attributes.valuesNamespace+ie()):a=f.blankNode(ie())),this.nodeId=a;const r=JSON.stringify([e.id,t]);if(t&&e.config.renderedNodes.has(r)){n=n||"Link";const l=document.createElement("label");l.innerText=n,l.classList.add("linked"),this.appendChild(l);const c=document.createElement("a");let u=t.termType==="BlankNode"?"_:"+t.value:t.value;c.innerText=u,c.classList.add("ref-link"),c.onclick=()=>{this.template.config.form.querySelector(`shacl-node[data-node-id='${u}']`)?.scrollIntoView()},this.appendChild(c),this.style.flexDirection="row"}else{if(t&&e.config.renderedNodes.add(r),this.dataset.nodeId=this.nodeId.id,this.template.config.attributes.showNodeIds!==null){const l=document.createElement("div");l.innerText=`id: ${this.nodeId.id}`,l.classList.add("node-id-display"),this.appendChild(l)}for(const l of this.template.extendedShapes)this.prepend(new L(l,t));this.template.or?.length&&this.tryResolve(this.template.or,t,e.config),this.template.xone?.length&&this.tryResolve(this.template.xone,t,e.config);for(const[l,c]of Object.entries(this.template.properties))for(const u of c)this.addPropertyInstance(u,t);if(n){const l=document.createElement("h1");l.innerText=n,this.prepend(l)}}}toRDF(e,t,i=null){if(t||(t=this.nodeId),!this.linked){for(const n of this.querySelectorAll(":scope > shacl-node, :scope > .shacl-group > shacl-node, :scope > shacl-property, :scope > .shacl-group > shacl-property"))n.toRDF(e,t);this.template.targetClass&&e.addQuad(t,m,this.template.targetClass,this.template.config.valuesGraphId),i&&e.addQuad(t,f.namedNode(i),this.template.id,this.template.config.valuesGraphId)}return t}addPropertyInstance(e,t){let i=this;if(e.group)if(e.config.groups.indexOf(e.group)>-1){let o=this.querySelector(`:scope > .shacl-group[data-subject='${e.group}']`);o||(o=Xe(e.group,e.config),this.appendChild(o)),i=o}else console.warn("ignoring unknown group reference",e.group,"existing groups:",e.config.groups);const n=new _(e,this,t);setTimeout(()=>{(e.config.editMode||n.instanceCount()>0)&&i.appendChild(n)})}tryResolve(e,t,i){let n=!1;if(t){const o=Ve(e,t,i);if(o.length){for(const a of o)this.addPropertyInstance(i.getPropertyTemplate(a,this.template),t);n=!0}}n||this.appendChild(me(e,this,i))}}window.customElements.define("shacl-node",L);const V={},Q={};class Je{constructor(e){this.loadedExternalUrls=[],this.loadedClasses=[],this.config=e}async loadGraphs(){this.loadedExternalUrls=[],this.loadedClasses=[];const e=[],t=new W;if(e.push(this.importRDF(this.config.attributes.shapes?this.config.attributes.shapes:this.config.attributes.shapesUrl?this.fetchRDF(this.config.attributes.shapesUrl):"",t,I)),e.push(this.importRDF(this.config.attributes.values?this.config.attributes.values:this.config.attributes.valuesUrl?this.fetchRDF(this.config.attributes.valuesUrl):"",t,v)),await Promise.all(e),t.countQuads(null,null,null,I)===0&&this.config.attributes.valuesSubject){const i=[...t.getObjects(this.config.attributes.valuesSubject,z,v)],n=[];for(const o of i){const a=this.toURL(o.value);a&&this.loadedExternalUrls.indexOf(a)<0&&(this.loadedExternalUrls.push(a),n.push(this.importRDF(this.fetchRDF(a),t,I)))}try{await Promise.allSettled(n)}catch(o){console.warn(o)}}this.config.store=t}async importRDF(e,t,i){const n=async o=>{const a=[];await new Promise((r,l)=>{const c=ce(o)==="xml"?new Ce:new we;c.on("data",u=>{if(t.add(new Se(u.subject,u.predicate,u.object,i)),this.config.attributes.ignoreOwlImports===null&&Z.equals(u.predicate)){const h=this.toURL(u.object.value);h&&this.loadedExternalUrls.indexOf(h)<0&&(this.loadedExternalUrls.push(h),a.push(this.importRDF(this.fetchRDF(h),t,f.namedNode(h))))}if(this.config.classInstanceProvider&&(ee.equals(u.predicate)||k.equals(u.predicate))){const h=u.object.value;if(this.loadedClasses.indexOf(h)<0){let g;h in Q?g=Q[h]:(g=this.config.classInstanceProvider(h),Q[h]=g),this.loadedClasses.push(h),a.push(this.importRDF(g,t,i))}}}).on("error",u=>{console.warn("failed parsing RDF",i?.id,", reason:",u.message),l(u)}).on("prefix",(u,h)=>{u&&(this.config.prefixes[u]=h)}).on("end",()=>{r(null)}),c.write(o),c.end()});try{await Promise.allSettled(a)}catch(r){console.warn(r)}};if(e instanceof Promise&&(e=await e),e){if(ce(e)==="json")try{e=await Le(JSON.parse(e),{format:"application/n-quads"})}catch(o){console.error(o)}await n(e)}}toURL(e){if(K(e))return e;if(this.config.prefixes){const t=e.split(":");if(t.length===2){const i=this.config.prefixes[t[0]];if(i&&(e=e.replace(`${t[0]}:`,i),K(e)))return e}}return null}async fetchRDF(e){if(e in V)return V[e];let t=e;this.config.attributes.proxy&&(t=this.config.attributes.proxy+encodeURIComponent(e));const i=fetch(t,{headers:{Accept:"text/turtle, application/trig, application/n-triples, application/n-quads, text/n3, application/ld+json"}}).then(n=>n.text());return V[e]=i,i}}function ce(s){return/^\s*\{/.test(s)?"json":/^\s*<\?xml/.test(s)?"xml":"ttl"}const Ye=`
50
+ .node-id-display { color: #999; font-size: 11px; }
51
+ /* hierarchy colors */
52
+ .remove-button-wrapper { padding: 0 1px 0 calc(1px + var(--hierarchy-color-width)); align-self: stretch; position: relative; }
53
+ .remove-button-wrapper.colorize::before {
54
+ content: '';
55
+ position: absolute;
56
+ width: var(--hierarchy-color-width);
57
+ top: 0; bottom: 0; left: 0;
58
+ --index: mod(var(--hierarchy-level), var(--hierarchy-colors-length));
59
+ background: linear-gradient(var(--hierarchy-colors)) no-repeat 0 calc(var(--index) * 100% / (var(--hierarchy-colors-length) - 1)) / 100% calc(1px * infinity);
60
+ }
61
+ .property-instance:not(:has(shacl-node)) > .remove-button-wrapper.colorize::before { background: 0; }
62
+ `;class Qe{constructor(e){this.dense=!0;let t=Ve;e&&(t+=`
63
+ `+e),this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(t)}apply(e){}setDense(e){this.dense=e}createViewer(e,t,i){const n=document.createElement("div"),o=document.createElement("label");o.innerHTML=e+":",i.description&&o.setAttribute("title",i.description.value),n.appendChild(o);let a=t.value,r=null;if(t instanceof I){const c=i.config.store.getQuads(a,null,null,null);if(c.length){const u=T(c,i.config.languages);u&&(a=u)}}else t instanceof S&&(t.language?(r=document.createElement("span"),r.classList.add("lang"),r.innerText=`@${t.language}`):t.datatype.value===`${E}date`?a=new Date(Date.parse(t.value)).toDateString():t.datatype.value===`${E}dateTime`&&(a=new Date(Date.parse(t.value)).toLocaleString()));let l;return G(t.value)?(l=document.createElement("a"),l.setAttribute("href",t.value)):l=document.createElement("div"),l.classList.add("d-flex"),l.innerText=a,r&&l.appendChild(r),n.appendChild(l),n}}function Be(s,e,t){if(t){const i=s.minCount!==void 0&&s.minCount>0;if(s.class&&!s.hasValue)return s.config.theme.createListEditor(s.label,e,i,Z(s.class,s),s);if(s.in){const n=s.config.lists[s.in];if(n?.length){const o=fe(n,s.config.store,s.config.languages);return s.config.theme.createListEditor(s.label,e,i,o,s)}else console.error("list not found:",s.in,"existing lists:",s.config.lists)}if(s.datatype?.equals(he)||s.languageIn?.length||s.datatype===void 0&&e instanceof S&&e.language)return s.config.theme.createLangStringEditor(s.label,e,i,s);switch(s.datatype?.value.replace(E,"")){case"integer":case"float":case"double":case"decimal":return s.config.theme.createNumberEditor(s.label,e,i,s);case"date":case"dateTime":return s.config.theme.createDateEditor(s.label,e,i,s);case"boolean":return s.config.theme.createBooleanEditor(s.label,e,i,s);case"base64Binary":return s.config.theme.createFileEditor(s.label,e,i,s)}return s.config.theme.createTextEditor(s.label,e,i,s)}else{if(e)return s.config.theme.createViewer(s.label,e,s);const i=document.createElement("div");return i.innerHTML="No value",i}}function ze(s,e,t){if(e==="application/ld+json")return Me(s);{const i=new ye({format:e,prefixes:t});i.addQuads(s);let n="";return i.end((o,a)=>{o&&console.error(o),n=a}),n}}function Me(s){const e=[];for(const t of s){const i={"@id":t.subject.id};if(t.predicate===m)i["@type"]=t.object.id;else{let n=t.object.value;t.object instanceof S?t.object.language?n={"@language":t.object.language,"@value":t.object.value}:t.object.datatype&&t.object.datatype.value!==`${E}#string`&&(n={"@type":t.object.datatype.value,"@value":t.object.value}):n={"@id":t.object.id},i[t.predicate.value]=n}e.push(i)}return JSON.stringify(e)}function Ge(s){let e=s.shaclDatatype,t=s.dataset.value||s.value;if(t){if(t.startsWith("<")&&t.endsWith(">")&&t.indexOf(":")>-1)return f.namedNode(t.substring(1,t.length-1));if(s.dataset.class||s.dataset.nodeKind===d+"IRI")return f.namedNode(t);if(s.dataset.link)return JSON.parse(s.dataset.link);if(s.dataset.lang?e=s.dataset.lang:s.type==="number"?t=parseFloat(t):s.type==="file"&&s.binaryData?t=s.binaryData:s.type==="datetime-local"&&(t=new Date(t).toISOString().slice(0,19)),(!e||e instanceof I&&Ne.equals(e))&&typeof t=="string"){let i=t.split("^^");i.length===2&&i[0].startsWith('"')&&i[0].endsWith('"')&&i[1].split(":").length===2?(t=i[0].substring(1,i[0].length-1),e=f.namedNode(i[1])):(i=t.split("@"),i.length===2&&i[0].startsWith('"')&&i[0].endsWith('"')?(t=i[0].substring(1,i[0].length-1),e=i[1]):t.startsWith('"')&&t.endsWith('"')&&(t=t.substring(1,t.length-1)))}return f.literal(t,e)}else if((s.type==="checkbox"||s.getAttribute("type")==="checkbox")&&(s.checked||parseInt(s.dataset.minCount||"0")>0))return f.literal(s.checked?"true":"false",e)}const D={};function Ue(s){s.predicate===void 0&&s.datatype===void 0?console.warn('not registering plugin because it does neither define "predicate" nor "datatype"',s):D[`${s.predicate}^${s.datatype}`]=s}function He(){return Object.entries(D).map(s=>s[1])}function Ke(s,e){let t=D[`${s}^${e}`];return t||(t=D[`${s}^undefined`],t)?t:D[`undefined^${e}`]}class ht{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)}}class A extends HTMLElement{constructor(e,t,i){if(super(),this.template=e,this.parent=t,this.container=this,this.template.nodeShapes.size&&this.template.config.attributes.collapse!==null&&(this.template.maxCount===void 0||this.template.maxCount>1)){const n=new K;n.classList.add("collapsible","shacl-group"),n.open=e.config.attributes.collapse==="open",n.label=this.template.label,this.container=n,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.addButton=this.createAddButton(),this.container.appendChild(this.addButton),this.addEventListener("change",()=>{this.updateControls()})),(async()=>{if(e.path){let n=[];i&&(n=e.config.store.getQuads(i,e.path,null,t.linked?null:v),n=await this.filterValidValues(n,i));let o=!1;for(const a of n)this.addPropertyInstance(a.object),e.hasValue&&a.object.equals(e.hasValue)&&(o=!0);e.config.editMode&&(e.hasValue&&!o&&!t.linked&&this.addPropertyInstance(e.hasValue),this.updateControls())}})()}addPropertyInstance(e){let t;if(this.template.or?.length||this.template.xone?.length){const i=this.template.or?.length?this.template.or:this.template.xone;let n=!1;if(e){const o=Fe(i,e,this.template.config);if(o.length){const a=ee(ge(this.template),o);t=N(a,e,!0),n=!0}}n||(t=be(i,this,this.template.config),ve(t,"",this.template.config.theme.dense,this.template.config.hierarchyColorsStyleSheet!==void 0))}else{let i=!1;if(e&&!(e instanceof S)){const n=this.getRdfClassToLinkOrCreate();n&&this.template.config.store.countQuads(e,m,n,v)===0&&(i=!0)}t=N(this.template,e,void 0,i||this.parent.linked)}return this.addButton?this.container.insertBefore(t,this.addButton):this.container.appendChild(t),t}updateControls(){let e=this.instanceCount();e===0&&(this.template.nodeShapes.size===0||this.template.minCount!==void 0&&this.template.minCount>0)&&(this.addPropertyInstance(),e=this.instanceCount());let t;this.template.minCount!==void 0?t=e>this.template.minCount:t=this.template.nodeShapes.size>0||e>1;const i=this.template.maxCount===void 0||e<this.template.maxCount;this.classList.toggle("may-remove",t),this.classList.toggle("may-add",i)}instanceCount(){return this.querySelectorAll(":scope > .property-instance, :scope > .shacl-or-constraint, :scope > shacl-node, :scope > .collapsible > .property-instance").length}toRDF(e,t){const i=f.namedNode(this.template.path);for(const n of this.querySelectorAll(":scope > .property-instance, :scope > .collapsible > .property-instance"))if(n.firstChild instanceof L){const o=n.firstChild.toRDF(e);e.addQuad(t,i,o,this.template.config.valuesGraphId)}else for(const o of n.querySelectorAll(":scope > .editor")){const a=Ge(o);a&&e.addQuad(t,i,a,this.template.config.valuesGraphId)}}getRdfClassToLinkOrCreate(){if(this.template.class&&this.template.nodeShapes.size)return this.template.class;for(const e of this.template.nodeShapes)if(e.targetClass)return e.targetClass}async filterValidValues(e,t){let i=this.template.id,n=[t];if(this.template.qualifiedValueShape){i=this.template.qualifiedValueShape.id,n=[];for(const r of e)n.push(r.object)}const o=await this.template.config.validator.validate({dataset:this.template.config.store,terms:n},[{terms:[i]}]),a=[];for(const r of o.results){const l=this.template.qualifiedValueShape?r.focusNode:r.value;l?.ptrs?.length&&a.push(l.ptrs[0]._term.id)}return e.filter(r=>a.indexOf(r.object.id)===-1)}createAddButton(){const e=new de;e.dense=this.template.config.theme.dense,e.label="+ "+this.template.label,e.title="Add "+this.template.label,e.autoGrowLabelWidth=!0,e.classList.add("add-button");let t=[],i=this.getRdfClassToLinkOrCreate();if(i&&(t=Z(i,this.template)),t.length===0)e.emptyMessage="",e.inputMinWidth=0,e.addEventListener("click",n=>{e.blur();const o=this.addPropertyInstance();o.classList.add("fadeIn"),this.updateControls(),setTimeout(()=>{Oe(o),o.classList.remove("fadeIn")},200)});else{const n=document.createElement("ul"),o=document.createElement("li");o.innerHTML="&#xFF0B; Create new "+this.template.label+"...",o.dataset.value="new",o.classList.add("large"),n.appendChild(o);const a=document.createElement("li");a.classList.add("divider"),n.appendChild(a);const r=document.createElement("li");r.classList.add("header"),r.innerText="Or link existing:",n.appendChild(r);for(const l of t){const c=document.createElement("li"),u=typeof l.value=="string"?l.value:l.value.value;c.innerText=l.label?l.label:u,c.dataset.value=JSON.stringify(l.value),n.appendChild(c)}e.appendChild(n),e.collapsibleWidth="250px",e.collapsibleOrientationLeft="",e.addEventListener("change",()=>{if(e.value==="new")this.addPropertyInstance();else{const l=JSON.parse(e.value);this.container.insertBefore(N(this.template,l,!0,!0),e)}e.value=""})}return e}}function N(s,e,t=!1,i=!1){let n;if(s.nodeShapes.size){n=document.createElement("div"),n.classList.add("property-instance");for(const o of s.nodeShapes)n.appendChild(new L(o,e,s.nodeKind,s.label,i))}else{const o=Ke(s.path,s.datatype?.value);o?s.config.editMode&&!i?n=o.createEditor(s,e):n=o.createViewer(s,e):n=Be(s,e||null,s.config.editMode&&!i),n.classList.add("property-instance"),i&&n.classList.add("linked")}return s.config.editMode&&ve(n,s.label,s.config.theme.dense,s.config.hierarchyColorsStyleSheet!==void 0,t),n.dataset.path=s.path,n}function ve(s,e,t,i,n=!1){const o=document.createElement("div");o.className="remove-button-wrapper",i&&o.classList.add("colorize");const a=new Ee;a.classList.add("remove-button","clear"),a.title="Remove "+e,a.dense=t,a.icon=!0,a.addEventListener("click",r=>{s.classList.remove("fadeIn"),s.classList.add("fadeOut"),setTimeout(()=>{const l=s.parentElement;s.remove(),l?.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))},200)}),n&&a.classList.add("persistent"),o.appendChild(a),s.appendChild(o)}window.customElements.define("shacl-property",A);function We(s,e){let t=s;const i=e.store.getQuads(s,null,null,null),n=R(i,"label",W,e.languages);n&&(t=n);let o;if(e.attributes.collapse!==null)o=new K,o.classList.add("collapsible"),o.open=e.attributes.collapse==="open",o.label=t;else{o=document.createElement("div");const r=document.createElement("h1");r.innerText=t,o.appendChild(r)}o.dataset.subject=s,o.classList.add("shacl-group");const a=R(i,"order");return a&&(o.style.order=a),o}class L extends HTMLElement{constructor(e,t,i,n,o){super(),this.template=e,this.linked=o||!1;let a=t;a||(!i&&e.nodeKind&&(i=e.nodeKind),i===void 0&&e.config.attributes.valuesNamespace||i?.value===`${d}IRI`?a=f.namedNode(e.config.attributes.valuesNamespace+se()):a=f.blankNode(se())),this.nodeId=a;const r=JSON.stringify([e.id,t]);if(t&&e.config.renderedNodes.has(r)){n=n||"Link";const l=document.createElement("label");l.innerText=n,l.classList.add("linked"),this.appendChild(l);const c=document.createElement("a");let u=t.termType==="BlankNode"?"_:"+t.value:t.value;c.innerText=u,c.classList.add("ref-link"),c.onclick=()=>{this.template.config.form.querySelector(`shacl-node[data-node-id='${u}']`)?.scrollIntoView()},this.appendChild(c),this.style.flexDirection="row"}else{if(t&&e.config.renderedNodes.add(r),this.dataset.nodeId=this.nodeId.id,this.template.config.attributes.showNodeIds!==null){const l=document.createElement("div");l.innerText=`id: ${this.nodeId.id}`,l.classList.add("node-id-display"),this.appendChild(l)}for(const l of this.template.extendedShapes)this.prepend(new L(l,t));this.template.or?.length&&this.tryResolve(this.template.or,t,e.config),this.template.xone?.length&&this.tryResolve(this.template.xone,t,e.config);for(const[l,c]of Object.entries(this.template.properties))for(const u of c)this.addPropertyInstance(u,t);if(n){const l=document.createElement("h1");l.innerText=n,this.prepend(l)}}}toRDF(e,t,i=null){if(t||(t=this.nodeId),!this.linked){for(const n of this.querySelectorAll(":scope > shacl-node, :scope > .shacl-group > shacl-node, :scope > shacl-property, :scope > .shacl-group > shacl-property"))n.toRDF(e,t);this.template.targetClass&&e.addQuad(t,m,this.template.targetClass,this.template.config.valuesGraphId),i&&e.addQuad(t,f.namedNode(i),this.template.id,this.template.config.valuesGraphId)}return t}addPropertyInstance(e,t){let i=this;if(e.group)if(e.config.groups.indexOf(e.group)>-1){let o=this.querySelector(`:scope > .shacl-group[data-subject='${e.group}']`);o||(o=We(e.group,e.config),this.appendChild(o)),i=o}else console.warn("ignoring unknown group reference",e.group,"existing groups:",e.config.groups);const n=new A(e,this,t);setTimeout(()=>{(e.config.editMode||n.instanceCount()>0)&&i.appendChild(n)})}tryResolve(e,t,i){let n=!1;if(t){const o=qe(e,t,i);if(o.length){for(const a of o)this.addPropertyInstance(i.getPropertyTemplate(a,this.template),t);n=!0}}n||this.appendChild(be(e,this,i))}}window.customElements.define("shacl-node",L);const q={},V={};class Xe{constructor(e){this.loadedExternalUrls=[],this.loadedClasses=[],this.config=e}async loadGraphs(){this.loadedExternalUrls=[],this.loadedClasses=[];const e=[],t=new H;if(e.push(this.importRDF(this.config.attributes.shapes?this.config.attributes.shapes:this.config.attributes.shapesUrl?this.fetchRDF(this.config.attributes.shapesUrl):"",t,j)),e.push(this.importRDF(this.config.attributes.values?this.config.attributes.values:this.config.attributes.valuesUrl?this.fetchRDF(this.config.attributes.valuesUrl):"",t,v)),await Promise.all(e),t.countQuads(null,null,null,j)===0&&this.config.attributes.valuesSubject){const i=[...t.getObjects(this.config.attributes.valuesSubject,B,v)],n=[];for(const o of i){const a=this.toURL(o.value);a&&this.loadedExternalUrls.indexOf(a)<0&&(this.loadedExternalUrls.push(a),n.push(this.importRDF(this.fetchRDF(a),t,j)))}try{await Promise.allSettled(n)}catch(o){console.warn(o)}}this.config.store=t}async importRDF(e,t,i){const n=async o=>{const a=[];await new Promise((r,l)=>{const c=le(o)==="xml"?new Ce:new we;c.on("data",u=>{if(t.add(new Se(u.subject,u.predicate,u.object,i)),this.config.attributes.ignoreOwlImports===null&&J.equals(u.predicate)){const h=this.toURL(u.object.value);h&&this.loadedExternalUrls.indexOf(h)<0&&(this.loadedExternalUrls.push(h),a.push(this.importRDF(this.fetchRDF(h),t,f.namedNode(h))))}if(this.config.classInstanceProvider&&(Y.equals(u.predicate)||_.equals(u.predicate))){const h=u.object.value;if(this.loadedClasses.indexOf(h)<0){let g;h in V?g=V[h]:(g=this.config.classInstanceProvider(h),V[h]=g),this.loadedClasses.push(h),a.push(this.importRDF(g,t,i))}}}).on("error",u=>{console.warn("failed parsing RDF",i?.id,", reason:",u.message),l(u)}).on("prefix",(u,h)=>{u&&(this.config.prefixes[u]=h)}).on("end",()=>{r(null)}),c.write(o),c.end()});try{await Promise.allSettled(a)}catch(r){console.warn(r)}};if(e instanceof Promise&&(e=await e),e){if(le(e)==="json")try{e=await Le(JSON.parse(e),{format:"application/n-quads"})}catch(o){console.error(o)}await n(e)}}toURL(e){if(G(e))return e;if(this.config.prefixes){const t=e.split(":");if(t.length===2){const i=this.config.prefixes[t[0]];if(i&&(e=e.replace(`${t[0]}:`,i),G(e)))return e}}return null}async fetchRDF(e){if(e in q)return q[e];let t=e;this.config.attributes.proxy&&(t=this.config.attributes.proxy+encodeURIComponent(e));const i=fetch(t,{headers:{Accept:"text/turtle, application/trig, application/n-triples, application/n-quads, text/n3, application/ld+json"}}).then(n=>n.text());return q[e]=i,i}}function le(s){return/^\s*\{/.test(s)?"json":/^\s*<\?xml/.test(s)?"xml":"ttl"}const Je=`
52
64
  .editor:not([type='checkbox']) { border: 1px solid #DDD; }
53
65
  .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; }
54
66
  .property-instance:not(:first-child) > label:not(.persistent) { visibility: hidden; max-height: 0; }
55
67
  .mode-edit .property-instance label { width: var(--label-width); }
56
- `;class Ze extends Be{constructor(e){super(e||Ye),this.idCtr=0}createDefaultTemplate(e,t,i,n,o){n.id=`e${this.idCtr++}`,n.classList.add("editor"),o?.datatype?n.shaclDatatype=o.datatype:t instanceof C&&(n.shaclDatatype=t.datatype),o?.minCount!==void 0&&(n.dataset.minCount=String(o.minCount)),o?.class&&(n.dataset.class=o.class.value),o?.nodeKind?n.dataset.nodeKind=o.nodeKind.value:t instanceof T&&(n.dataset.nodeKind=d+"IRI"),(o?.hasValue&&t||o?.readonly)&&(n.disabled=!0),n.value=t?.value||o?.defaultValue?.value||"";const a=document.createElement("label");a.htmlFor=n.id,a.innerText=e,o?.description&&a.setAttribute("title",o.description.value);const r=o?.description?o.description.value:o?.pattern?o.pattern:null;r&&n.setAttribute("placeholder",r),i&&(n.setAttribute("required","true"),a.classList.add("required"));const l=document.createElement("div");return l.appendChild(a),l.appendChild(n),l}createDateEditor(e,t,i,n){const o=new F;n.datatype?.value===E+"dateTime"?(o.type="datetime-local",o.setAttribute("step","1")):o.type="date",o.clearable=!0,o.dense=this.dense,o.classList.add("pr-0");const a=this.createDefaultTemplate(e,null,i,o,n);if(t)try{let r=new Date(t.value).toISOString();n.datatype?.value===E+"dateTime"?r=r.slice(0,19):r=r.slice(0,10),o.value=r}catch(r){console.error(r,t)}return a}createTextEditor(e,t,i,n){let o;return n.singleLine===!1?(o=new xe,o.resize="auto"):o=new F,o.dense=this.dense,n.pattern&&(o.pattern=n.pattern),n.minLength&&(o.minLength=n.minLength),n.maxLength&&(o.maxLength=n.maxLength),this.createDefaultTemplate(e,t,i,o,n)}createLangStringEditor(e,t,i,n){const o=this.createTextEditor(e,t,i,n),a=o.querySelector(":scope .editor");let r;if(n.languageIn?.length){r=document.createElement("select");for(const l of n.languageIn){const c=document.createElement("option");c.innerText=l.value,r.appendChild(c)}}else r=document.createElement("input"),r.maxLength=5,r.size=5,r.placeholder="lang?";return r.title="Language of the text",r.classList.add("lang-chooser"),r.slot="suffix",r.addEventListener("change",l=>{l.stopPropagation(),a&&(a.dataset.lang=r.value,a.dispatchEvent(new Event("change",{bubbles:!0})))}),t instanceof C&&(r.value=t.language),a.dataset.lang=r.value,a.appendChild(r),o}createBooleanEditor(e,t,i,n){const o=document.createElement("input");o.type="checkbox",o.classList.add("ml-0");const a=this.createDefaultTemplate(e,null,i,o,n);return o.removeAttribute("required"),a.querySelector(":scope label")?.classList.remove("required"),t instanceof C&&(o.checked=t.value==="true"),a}createFileEditor(e,t,i,n){const o=document.createElement("input");return o.type="file",o.addEventListener("change",a=>{if(o.files?.length){a.stopPropagation();const r=new FileReader;r.readAsDataURL(o.files[0]),r.onload=()=>{o.binaryData=btoa(r.result),o.parentElement?.dispatchEvent(new Event("change",{bubbles:!0}))}}else o.binaryData=void 0}),this.createDefaultTemplate(e,t,i,o,n)}createNumberEditor(e,t,i,n){const o=new F;o.type="number",o.clearable=!0,o.dense=this.dense,o.classList.add("pr-0");const a=n.minInclusive!==void 0?n.minInclusive:n.minExclusive!==void 0?n.minExclusive+1:void 0,r=n.maxInclusive!==void 0?n.maxInclusive:n.maxExclusive!==void 0?n.maxExclusive-1:void 0;return a!==void 0&&(o.min=String(a)),r!==void 0&&(o.max=String(r)),n.datatype?.value!==E+"integer"&&(o.step="0.1"),this.createDefaultTemplate(e,t,i,o,n)}createListEditor(e,t,i,n,o){const a=new ue;a.clearable=!0,a.dense=this.dense;const r=this.createDefaultTemplate(e,null,i,a,o),l=document.createElement("ul");let c=!0;const u=(h,g)=>{const p=document.createElement("li");if(typeof h.value=="string"?(p.dataset.value=h.value,p.innerText=h.label?h.label:h.value):(p.dataset.value=h.value.id,h.value instanceof T&&(p.dataset.value="<"+p.dataset.value+">"),p.innerText=h.label?h.label:h.value.value),g.appendChild(p),h.children?.length){c=!1;const w=document.createElement("ul");p.appendChild(w);for(const x of h.children)u(x,w)}};for(const h of n)u(h,l);return c||(a.collapse=!0),a.appendChild(l),t&&(a.value=t.id,t instanceof T&&(a.value="<"+a.value+">")),r}createButton(e,t){const i=document.createElement("rokit-button");return i.innerHTML=e,i}}const et={[`${d}node`]:(s,e)=>{s.extendedShapes.add(new O(e,s.config,s))},[`${d}and`]:(s,e)=>{for(const t of s.config.lists[e.value])s.extendedShapes.add(new O(t,s.config,s))},[`${d}property`]:(s,e)=>{const t=s.config.getPropertyTemplate(e,s);if(t.path){let i=s.properties[t.path];if(i||(i=[],s.properties[t.path]=i),t.qualifiedValueShape)i.push(t);else{let n;for(let o=0;o<s.properties[t.path].length&&!n;o++)s.properties[t.path][o].qualifiedValueShape||(n=s.properties[t.path][o]);n?ge(n,t):i.push(t)}}},[`${d}nodeKind`]:(s,e)=>{s.nodeKind=e},[`${d}targetClass`]:(s,e)=>{s.targetClass=e},[`${d}or`]:(s,e)=>{s.or=s.config.lists[e.value]},[`${d}xone`]:(s,e)=>{s.xone=s.config.lists[e.value]},[Z.id]:(s,e)=>{s.owlImports.add(e)}};class O{constructor(e,t,i){this.extendedShapes=new Set,this.properties={},this.owlImports=new Set,this.id=e,this.config=t,this.parent=i,t.registerNodeTemplate(this),tt(this,this.config.store.getQuads(e,null,null,null))}}function tt(s,e){for(const t of e)et[t.predicate.id]?.call(s,s,t.object);return s}function H(s){for(const e of Object.values(s.properties))for(const t of e)if(t.qualifiedValueShape)H(t.qualifiedValueShape);else{const[i,n]=A(t,t.path);if(i.length>1&&n){const o=i[i.length-1];for(let a=i.length-2;a>=0;a--){const r=i[a];delete r.parent.properties[r.path],ge(o,r)}}}for(const e of s.extendedShapes)H(e)}function A(s,e,t=[],i=!1,n=new Set){const o=ve(s.id,s.parent);if(n.has(o))return[t,i];n.add(o),!s.qualifiedValueShape&&s.path===e&&(t.push(s),i=i||s.maxCount===1);for(const a of s.nodeShapes){for(const r of Object.values(a.properties))for(const l of r){const[c,u]=A(l,e,t,i,n);i=i||u}for(const r of a.extendedShapes)for(const[l,c]of Object.entries(r.properties))for(const u of c){const[h,g]=A(u,e,t,i,n);i=i||g}}for(const a of s.parent.extendedShapes)for(const[r,l]of Object.entries(a.properties))for(const c of l){const[u,h]=A(c,e,t,i,n);i=i||h}return[t,i]}function ve(s,e){let t=s.value;return e&&(e instanceof M?t+="*"+e.id.value:t+="*"+ve(e.id,e.parent)),t}class B{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.submitButton=null,this.generateNodeShapeReference=null,this.showNodeIds=null,this.dense="true"}}class de{constructor(e){this.attributes=new B,this.loader=new Je(this),this.prefixes={},this.editMode=!0,this.lists={},this.groups=[],this.renderedNodes=new Set,this._store=new W,this._nodeTemplates={},this._propertyTemplates={},this.validator=new oe(this._store,{details:!0,factory:f}),this.form=e,this._theme=new Ze,this.languages=[...new Set(navigator.languages.flatMap(t=>t.length>2?[t.toLocaleLowerCase(),t.substring(0,2)]:t)),""]}reset(){this.lists={},this.groups=[],this.renderedNodes.clear(),this._nodeTemplates={},this._propertyTemplates={}}updateAttributes(e){const t=new B;if(Object.keys(t).forEach(i=>{const n=e.dataset[i];n!==void 0&&(t[i]=n)}),this.editMode=t.view===null,this.theme.setDense(t.dense==="true"),this.attributes=t,this.attributes.valueSubject&&!this.attributes.valuesSubject&&(this.attributes.valuesSubject=this.attributes.valueSubject),t.language){const i=this.languages.indexOf(t.language);i>-1&&this.languages.splice(i,1),this.languages.unshift(t.language)}t.valuesGraph&&(this.valuesGraphId=f.namedNode(t.valuesGraph))}static dataAttributes(){const e=new B;return Object.keys(e).map(t=>(t=t.replace(/[A-Z]/g,i=>"-"+i.toLowerCase()),"data-"+t))}buildTemplateKey(e,t){let i=e.value;return t&&(t instanceof M?i+="*"+t.id.value:i+="*"+this.buildTemplateKey(t.id,t.parent)),i}registerNodeTemplate(e){this._nodeTemplates[this.buildTemplateKey(e.id,e.parent)]=e}registerPropertyTemplate(e){this._propertyTemplates[this.buildTemplateKey(e.id,e.parent)]=e}getNodeTemplate(e,t){const i=this.buildTemplateKey(e,t);let n=this._nodeTemplates[i];return n||(n=new O(e,this,t)),n}getPropertyTemplate(e,t){const i=this.buildTemplateKey(e,t);let n=this._propertyTemplates[i];return n||(n=new M(e,t)),n}get theme(){return this._theme}set theme(e){this._theme=e,e.setDense(this.attributes.dense==="true")}get store(){return this._store}set store(e){this._store=e,this.lists=ke(e,{ignoreErrors:!0}),this.groups=[],e.forSubjects(t=>{this.groups.push(t.id)},m,`${d}PropertyGroup`,null),this.validator=new oe(e,{details:!0,factory:f})}}const st=50;class nt extends HTMLElement{constructor(){super(),this.shape=null,this.attachShadow({mode:"open"}),this.form=document.createElement("form"),this.config=new de(this.form),this.form.addEventListener("change",e=>{e.stopPropagation(),this.config.editMode&&this.validate(!0).then(t=>{this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!1,composed:!0,detail:{valid:t.conforms,report:t}}))}).catch(t=>{console.warn(t)})})}static get observedAttributes(){return de.dataAttributes()}connectedCallback(){this.shadowRoot.prepend(this.form)}attributeChangedCallback(){this.config.updateAttributes(this),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(),await this.config.loader.loadGraphs(),this.form.replaceChildren();const e=this.findRootShaclShapeSubject();if(e){this.form.classList.forEach(n=>{this.form.classList.remove(n)}),this.form.classList.toggle("mode-edit",this.config.editMode),this.form.classList.toggle("mode-view",!this.config.editMode),this.config.theme.apply(this.form);const t=[this.config.theme.stylesheet];for(const n of He())n.stylesheet&&t.push(n.stylesheet);this.shadowRoot.adoptedStyleSheets=t;const i=new O(e,this.config);if(H(i),this.shape=new L(i,this.config.attributes.valuesSubject?f.namedNode(this.config.attributes.valuesSubject):void 0),this.form.appendChild(this.shape),this.config.editMode){if(this.config.attributes.submitButton!==null){const n=this.config.theme.createButton(this.config.attributes.submitButton||"Submit",!0);n.addEventListener("click",o=>{o.preventDefault(),this.form.reportValidity()&&this.validate().then(a=>{if(a?.conforms)this.dispatchEvent(new Event("submit",{bubbles:!0,cancelable:!0}));else{let r=this.form.querySelector(":scope .invalid > .editor");r?r.focus():this.form.querySelector(":scope .invalid")?.scrollIntoView()}})}),this.form.appendChild(n)}setTimeout(()=>{this.config.attributes.valuesSubject&&this.removeFromDataGraph(f.namedNode(this.config.attributes.valuesSubject)),this.validate(!0)})}}else if(this.config.store.countQuads(null,null,null,I)>0)throw new Error("shacl root node shape not found")}catch(e){console.error(e);const t=document.createElement("div");t.innerText=String(e),this.form.replaceChildren(t)}this.removeAttribute("loading")},st)}serialize(e="text/turtle",t=this.toRDF()){const i=t.getQuads(null,null,null,null);return Ue(i,e,this.config.prefixes)}toRDF(e=new W){return this.shape?.toRDF(e,void 0,this.config.attributes.generateNodeShapeReference),e}registerPlugin(e){Me(e),this.initialize()}setTheme(e){this.config.theme=e,this.initialize()}setClassInstanceProvider(e){this.config.classInstanceProvider=e,this.initialize()}async validate(e=!1){for(const t of this.form.querySelectorAll(":scope .validation-error"))t.remove();for(const t of this.form.querySelectorAll(":scope .property-instance"))t.classList.remove("invalid"),t.querySelector(":scope > .editor")?.value?t.classList.add("valid"):t.classList.remove("valid");if(this.config.store.deleteGraph(this.config.valuesGraphId||""),!this.shape)return{conforms:!0};this.shape.toRDF(this.config.store,void 0,this.config.attributes.generateNodeShapeReference);try{const t=await this.config.validator.validate({dataset:this.config.store,terms:[this.shape.nodeId]},[{terms:[this.shape.template.id]}]);for(const i of t.results)if(i.focusNode?.ptrs?.length)for(const n of i.focusNode.ptrs){const o=n._term;if(i.path?.length){const a=i.path[0].predicates[0];let r=this.form.querySelectorAll(`
68
+ `;class Ye extends Qe{constructor(e){super(e||Je),this.idCtr=0}createDefaultTemplate(e,t,i,n,o){if(n.id=`e${this.idCtr++}`,n.classList.add("editor"),o?.datatype?n.shaclDatatype=o.datatype:t instanceof S&&(n.shaclDatatype=t.datatype),o?.minCount!==void 0&&(n.dataset.minCount=String(o.minCount)),o?.class&&(n.dataset.class=o.class.value),o?.nodeKind)n.dataset.nodeKind=o.nodeKind.value;else if(t&&(t instanceof I||o?.nodeKind?.equals(ue))&&(n.dataset.nodeKind=d+"IRI",o)){const c=T(o.config.store.getQuads(t,null,null,null),o.config.languages);c&&(n.dataset.value="<"+t.value+">",t=f.literal(c))}(o?.hasValue&&t||o?.readonly)&&(n.disabled=!0),n.value=t?.value||o?.defaultValue?.value||"";const a=document.createElement("label");a.htmlFor=n.id,a.innerText=e,o?.description&&a.setAttribute("title",o.description.value);const r=o?.description?o.description.value:o?.pattern?o.pattern:null;r&&n.setAttribute("placeholder",r),i&&(n.setAttribute("required","true"),a.classList.add("required"));const l=document.createElement("div");return l.appendChild(a),l.appendChild(n),l}createDateEditor(e,t,i,n){const o=new k;n.datatype?.value===E+"dateTime"?(o.type="datetime-local",o.setAttribute("step","1")):o.type="date",o.clearable=!0,o.dense=this.dense,o.classList.add("pr-0");const a=this.createDefaultTemplate(e,null,i,o,n);if(t)try{let r=new Date(t.value).toISOString();n.datatype?.value===E+"dateTime"?r=r.slice(0,19):r=r.slice(0,10),o.value=r}catch(r){console.error(r,t)}return a}createTextEditor(e,t,i,n){let o;return n.singleLine===!1?(o=new xe,o.resize="auto"):o=new k,o.dense=this.dense,n.pattern&&(o.pattern=n.pattern),n.minLength&&(o.minLength=n.minLength),n.maxLength&&(o.maxLength=n.maxLength),this.createDefaultTemplate(e,t,i,o,n)}createLangStringEditor(e,t,i,n){const o=this.createTextEditor(e,t,i,n),a=o.querySelector(":scope .editor");let r;if(n.languageIn?.length){r=document.createElement("select");for(const l of n.languageIn){const c=document.createElement("option");c.innerText=l.value,r.appendChild(c)}}else r=document.createElement("input"),r.maxLength=5,r.size=5,r.placeholder="lang?";return r.title="Language of the text",r.classList.add("lang-chooser"),r.slot="suffix",r.addEventListener("change",l=>{l.stopPropagation(),a&&(a.dataset.lang=r.value,a.dispatchEvent(new Event("change",{bubbles:!0})))}),t instanceof S&&(r.value=t.language),a.dataset.lang=r.value,a.appendChild(r),o}createBooleanEditor(e,t,i,n){const o=document.createElement("input");o.type="checkbox",o.classList.add("ml-0");const a=this.createDefaultTemplate(e,null,i,o,n);return o.removeAttribute("required"),a.querySelector(":scope label")?.classList.remove("required"),t instanceof S&&(o.checked=t.value==="true"),a}createFileEditor(e,t,i,n){const o=document.createElement("input");return o.type="file",o.addEventListener("change",a=>{if(o.files?.length){a.stopPropagation();const r=new FileReader;r.readAsDataURL(o.files[0]),r.onload=()=>{o.binaryData=btoa(r.result),o.parentElement?.dispatchEvent(new Event("change",{bubbles:!0}))}}else o.binaryData=void 0}),this.createDefaultTemplate(e,t,i,o,n)}createNumberEditor(e,t,i,n){const o=new k;o.type="number",o.clearable=!0,o.dense=this.dense,o.classList.add("pr-0");const a=n.minInclusive!==void 0?n.minInclusive:n.minExclusive!==void 0?n.minExclusive+1:void 0,r=n.maxInclusive!==void 0?n.maxInclusive:n.maxExclusive!==void 0?n.maxExclusive-1:void 0;return a!==void 0&&(o.min=String(a)),r!==void 0&&(o.max=String(r)),n.datatype?.value!==E+"integer"&&(o.step="0.1"),this.createDefaultTemplate(e,t,i,o,n)}createListEditor(e,t,i,n,o){const a=new de;a.clearable=!0,a.dense=this.dense;const r=this.createDefaultTemplate(e,null,i,a,o),l=document.createElement("ul");let c=!0;const u=(h,g)=>{const p=document.createElement("li");if(typeof h.value=="string"?(p.dataset.value=h.value,p.innerText=h.label?h.label:h.value):(p.dataset.value=h.value.id,h.value instanceof I&&(p.dataset.value="<"+p.dataset.value+">"),p.innerText=h.label?h.label:h.value.value),g.appendChild(p),h.children?.length){c=!1;const w=document.createElement("ul");p.appendChild(w);for(const x of h.children)u(x,w)}};for(const h of n)u(h,l);return c||(a.collapse=!0),a.appendChild(l),t&&(a.value=t.id,t instanceof I&&(a.value="<"+a.value+">")),r}createButton(e,t){const i=document.createElement("rokit-button");return i.innerHTML=e,i}}const Ze={[`${d}node`]:(s,e)=>{s.extendedShapes.add(new O(e,s.config,s))},[`${d}and`]:(s,e)=>{for(const t of s.config.lists[e.value])s.extendedShapes.add(new O(t,s.config,s))},[`${d}property`]:(s,e)=>{const t=s.config.getPropertyTemplate(e,s);if(t.path){let i=s.properties[t.path];if(i||(i=[],s.properties[t.path]=i),t.qualifiedValueShape)i.push(t);else{let n;for(let o=0;o<s.properties[t.path].length&&!n;o++)s.properties[t.path][o].qualifiedValueShape||(n=s.properties[t.path][o]);n?me(n,t):i.push(t)}}},[`${d}nodeKind`]:(s,e)=>{s.nodeKind=e},[`${d}targetClass`]:(s,e)=>{s.targetClass=e},[`${d}or`]:(s,e)=>{s.or=s.config.lists[e.value]},[`${d}xone`]:(s,e)=>{s.xone=s.config.lists[e.value]},[J.id]:(s,e)=>{s.owlImports.add(e)}};class O{constructor(e,t,i){this.extendedShapes=new Set,this.properties={},this.owlImports=new Set,this.id=e,this.config=t,this.parent=i,t.registerNodeTemplate(this),et(this,this.config.store.getQuads(e,null,null,null))}}function et(s,e){for(const t of e)Ze[t.predicate.id]?.call(s,s,t.object);return s}function tt(s){for(const e of Object.values(s.properties))for(const t of e){const[i,n]=U(s,t.path);if(i.length>1&&n){const o=i[i.length-1];for(let a=i.length-2;a>=0;a--){const r=i[a];delete r.parent.properties[r.path],me(o,r)}}}}function U(s,e,t=new Set,i=[],n=!1){if(!t.has(s.id.value)){t.add(s.id.value);const o=s.properties[e];if(o?.length===1){i.push(o[0]),n=n||o[0].maxCount===1;for(const a of o[0].nodeShapes){const[r,l]=U(a,e,t,i,n);n=n||l}}for(const a of s.extendedShapes){const[r,l]=U(a,e,t,i,n);n=n||l}}return[i,n]}class Q{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=null,this.showNodeIds=null,this.dense="true"}}const st="#003273, #4c93d7, #f85e9a, #87001f";class ce{constructor(e){this.attributes=new Q,this.loader=new Xe(this),this.prefixes={},this.editMode=!0,this.lists={},this.groups=[],this.renderedNodes=new Set,this._store=new H,this._nodeTemplates={},this._propertyTemplates={},this.validator=new ne(this._store,{details:!0,factory:f}),this.form=e,this._theme=new Ye,this.languages=[...new Set(navigator.languages.flatMap(t=>t.length>2?[t.toLocaleLowerCase(),t.substring(0,2)]:t)),""]}reset(){this.lists={},this.groups=[],this.renderedNodes.clear(),this._nodeTemplates={},this._propertyTemplates={}}updateAttributes(e){const t=new Q;if(Object.keys(t).forEach(i=>{const n=e.dataset[i];n!==void 0&&(t[i]=n)}),this.editMode=t.view===null,this.theme.setDense(t.dense==="true"),this.attributes=t,this.attributes.valueSubject&&!this.attributes.valuesSubject&&(this.attributes.valuesSubject=this.attributes.valueSubject),t.language){const i=this.languages.indexOf(t.language);i>-1&&this.languages.splice(i,1),this.languages.unshift(t.language)}if(t.valuesGraph&&(this.valuesGraphId=f.namedNode(t.valuesGraph)),t.hierarchyColors!=null){const i=t.hierarchyColors.length?t.hierarchyColors:st;let n=`:host { --hierarchy-colors: ${i}; --hierarchy-colors-length: ${i.split(",").length}; --hierarchy-color-width: 3px }`;for(let o=8;o>=0;o--){let a=`shacl-property { --hierarchy-level: ${o} }`;for(let r=0;r<o;r++)a="shacl-property "+a;n=n+`
69
+ `+a}this.hierarchyColorsStyleSheet=new CSSStyleSheet,this.hierarchyColorsStyleSheet.replaceSync(n)}}static dataAttributes(){const e=new Q;return Object.keys(e).map(t=>(t=t.replace(/[A-Z]/g,i=>"-"+i.toLowerCase()),"data-"+t))}buildTemplateKey(e,t){let i=e.value;return t&&(t instanceof re?i+="*"+t.id.value:i+="*"+this.buildTemplateKey(t.id,t.parent)),i}registerNodeTemplate(e){this._nodeTemplates[this.buildTemplateKey(e.id,e.parent)]=e}registerPropertyTemplate(e){this._propertyTemplates[this.buildTemplateKey(e.id,e.parent)]=e}getNodeTemplate(e,t){const i=this.buildTemplateKey(e,t);let n=this._nodeTemplates[i];return n||(n=new O(e,this,t)),n}getPropertyTemplate(e,t){const i=this.buildTemplateKey(e,t);let n=this._propertyTemplates[i];return n||(n=new re(e,t)),n}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(e){this._store=e,this.lists=_e(e,{ignoreErrors:!0}),this.groups=[],e.forSubjects(t=>{this.groups.push(t.id)},m,`${d}PropertyGroup`,null),this.validator=new ne(e,{details:!0,factory:f})}}const nt=50;class it extends HTMLElement{constructor(){super(),this.shape=null,this.attachShadow({mode:"open"}),this.form=document.createElement("form"),this.config=new ce(this.form),this.form.addEventListener("change",e=>{e.stopPropagation(),this.config.editMode&&this.validate(!0).then(t=>{this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!1,composed:!0,detail:{valid:t.conforms,report:t}}))}).catch(t=>{console.warn(t)})})}static get observedAttributes(){return ce.dataAttributes()}connectedCallback(){this.shadowRoot.prepend(this.form)}attributeChangedCallback(){this.config.updateAttributes(this),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(),await this.config.loader.loadGraphs(),this.form.replaceChildren();const e=this.findRootShaclShapeSubject();if(e){this.form.classList.forEach(n=>{this.form.classList.remove(n)}),this.form.classList.toggle("mode-edit",this.config.editMode),this.form.classList.toggle("mode-view",!this.config.editMode),this.config.theme.apply(this.form);const t=[this.config.theme.stylesheet];this.config.hierarchyColorsStyleSheet&&t.push(this.config.hierarchyColorsStyleSheet);for(const n of He())n.stylesheet&&t.push(n.stylesheet);this.shadowRoot.adoptedStyleSheets=t;const i=new O(e,this.config);for(const n of this.config.nodeTemplates)tt(n);if(this.shape=new L(i,this.config.attributes.valuesSubject?f.namedNode(this.config.attributes.valuesSubject):void 0),this.form.appendChild(this.shape),this.config.editMode){if(this.config.attributes.submitButton!==null){const n=this.config.theme.createButton(this.config.attributes.submitButton||"Submit",!0);n.addEventListener("click",o=>{o.preventDefault(),this.form.reportValidity()&&this.validate().then(a=>{if(a?.conforms)this.dispatchEvent(new Event("submit",{bubbles:!0,cancelable:!0}));else{let r=this.form.querySelector(":scope .invalid > .editor");r?r.focus():this.form.querySelector(":scope .invalid")?.scrollIntoView()}})}),this.form.appendChild(n)}setTimeout(()=>{this.config.attributes.valuesSubject&&this.removeFromDataGraph(f.namedNode(this.config.attributes.valuesSubject)),this.validate(!0)})}}else if(this.config.store.countQuads(null,null,null,j)>0)throw new Error("shacl root node shape not found")}catch(e){console.error(e);const t=document.createElement("div");t.innerText=String(e),this.form.replaceChildren(t)}this.removeAttribute("loading")},nt)}serialize(e="text/turtle",t=this.toRDF()){const i=t.getQuads(null,null,null,null);return ze(i,e,this.config.prefixes)}toRDF(e=new H){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()}async validate(e=!1){for(const t of this.form.querySelectorAll(":scope .validation-error"))t.remove();for(const t of this.form.querySelectorAll(":scope .property-instance"))t.classList.remove("invalid"),t.querySelector(":scope > .editor")?.value?t.classList.add("valid"):t.classList.remove("valid");if(this.config.store.deleteGraph(this.config.valuesGraphId||""),!this.shape)return{conforms:!0};this.shape.toRDF(this.config.store,void 0,this.config.attributes.generateNodeShapeReference);try{const t=await this.config.validator.validate({dataset:this.config.store,terms:[this.shape.nodeId]},[{terms:[this.shape.template.id]}]);for(const i of t.results)if(i.focusNode?.ptrs?.length)for(const n of i.focusNode.ptrs){const o=n._term;if(i.path?.length){const a=i.path[0].predicates[0];let r=this.form.querySelectorAll(`
57
70
  :scope shacl-node[data-node-id='${o.id}'] > shacl-property > .property-instance[data-path='${a.id}'] > .editor,
58
71
  :scope shacl-node[data-node-id='${o.id}'] > shacl-property > .shacl-group > .property-instance[data-path='${a.id}'] > .editor,
59
72
  :scope shacl-node[data-node-id='${o.id}'] > .shacl-group > shacl-property > .property-instance[data-path='${a.id}'] > .editor,
60
73
  :scope shacl-node[data-node-id='${o.id}'] > .shacl-group > shacl-property > .shacl-group > .property-instance[data-path='${a.id}'] > .editor`);r.length===0&&(r=this.form.querySelectorAll(`
61
74
  :scope [data-node-id='${o.id}'] > shacl-property > .property-instance[data-path='${a.id}'],
62
- :scope [data-node-id='${o.id}'] > shacl-property > .shacl-group > .property-instance[data-path='${a.id}']`));for(const l of r)if(l.classList.contains("editor")){if(!e||l.value){let c=l.parentElement;c.classList.add("invalid"),c.classList.remove("valid"),c.appendChild(this.createValidationErrorDisplay(i));do c instanceof X&&(c.open=!0),c=c.parentElement;while(c)}}else e||(l.classList.add("invalid"),l.classList.remove("valid"),l.appendChild(this.createValidationErrorDisplay(i,"node")))}else e||this.form.querySelector(`:scope [data-node-id='${o.id}']`)?.prepend(this.createValidationErrorDisplay(i,"node"))}return t}catch(t){return console.error(t),!1}}createValidationErrorDisplay(e,t){const i=document.createElement("span");if(i.classList.add("validation-error"),t&&i.classList.add(t),e)if(e.message?.length>0)for(const n of e.message)i.title+=n.value+`
63
- `;else i.title=e.sourceConstraintComponent?.value;return i}findRootShaclShapeSubject(){if(this.config.attributes.shapeSubject){const e=f.namedNode(this.config.attributes.shapeSubject);if(this.config.store.getQuads(e,m,q,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,v)>0){const t=f.namedNode(this.config.attributes.valuesSubject),i=[...this.config.store.getQuads(t,m,null,v),...this.config.store.getQuads(t,z,null,v)];if(i.length===0)console.warn(`value subject '${this.config.attributes.valuesSubject}' has neither ${m.id} nor ${z.id} statement`);else for(const o of i)if(this.config.store.getQuads(o.object,m,q,null).length>0)return o.object;const n=this.config.store.getObjects(t,m,v);for(const o of n)for(const a of this.config.store.getQuads(null,k,o,null))return a.subject}const e=this.config.store.getQuads(null,m,q,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){this.config.attributes.valuesSubject;for(const t of this.config.store.getQuads(e,null,null,v))this.config.store.delete(t),(t.object.termType==="NamedNode"||t.object.termType==="BlankNode")&&this.removeFromDataGraph(t.object)}}window.customElements.define("shacl-form",nt);export{de as Config,Je as Loader,dt as Plugin,nt as ShaclForm,Be as Theme,D as findLabel,st as initTimeout,Me as registerPlugin};
75
+ :scope [data-node-id='${o.id}'] > shacl-property > .shacl-group > .property-instance[data-path='${a.id}']`));for(const l of r)if(l.classList.contains("editor")){if(!e||l.value){let c=l.parentElement;c.classList.add("invalid"),c.classList.remove("valid"),c.appendChild(this.createValidationErrorDisplay(i));do c instanceof K&&(c.open=!0),c=c.parentElement;while(c)}}else e||(l.classList.add("invalid"),l.classList.remove("valid"),l.appendChild(this.createValidationErrorDisplay(i,"node")))}else e||this.form.querySelector(`:scope [data-node-id='${o.id}']`)?.prepend(this.createValidationErrorDisplay(i,"node"))}return t}catch(t){return console.error(t),!1}}createValidationErrorDisplay(e,t){const i=document.createElement("span");if(i.classList.add("validation-error"),t&&i.classList.add(t),e)if(e.message?.length>0)for(const n of e.message)i.title+=n.value+`
76
+ `;else i.title=e.sourceConstraintComponent?.value;return i}findRootShaclShapeSubject(){if(this.config.attributes.shapeSubject){const e=f.namedNode(this.config.attributes.shapeSubject);if(this.config.store.getQuads(e,m,F,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,v)>0){const t=f.namedNode(this.config.attributes.valuesSubject),i=[...this.config.store.getQuads(t,m,null,v),...this.config.store.getQuads(t,B,null,v)];if(i.length===0)console.warn(`value subject '${this.config.attributes.valuesSubject}' has neither ${m.id} nor ${B.id} statement`);else for(const o of i)if(this.config.store.getQuads(o.object,m,F,null).length>0)return o.object;const n=this.config.store.getObjects(t,m,v);for(const o of n)for(const a of this.config.store.getQuads(null,_,o,null))return a.subject}const e=this.config.store.getQuads(null,m,F,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){this.config.attributes.valuesSubject;for(const t of this.config.store.getQuads(e,null,null,v))this.config.store.delete(t),(t.object.termType==="NamedNode"||t.object.termType==="BlankNode")&&this.removeFromDataGraph(t.object)}}window.customElements.define("shacl-form",it);export{ce as Config,Xe as Loader,ht as Plugin,it as ShaclForm,Qe as Theme,T as findLabel,nt as initTimeout,Ue as registerPlugin};
@@ -1,4 +1,4 @@
1
- import*as d from"leaflet";import"leaflet-editable/src/Leaflet.Editable.js";import E from"leaflet/dist/leaflet.css?raw";import D from"leaflet.fullscreen/Control.FullScreen.css?raw";import"leaflet.fullscreen/Control.FullScreen.js";import{P as O}from"./assets/plugin-VN3CfgGe.js";import{DataFactory as c}from"n3";const l="http://www.w3.org/ns/shacl#",S="http://www.w3.org/2001/XMLSchema#",M="http://www.w3.org/1999/02/22-rdf-syntax-ns#",w="http://www.w3.org/2000/01/rdf-schema#",h="http://www.w3.org/2004/02/skos/core#",R="http://www.w3.org/2002/07/owl#",x="http://purl.org/dc/terms/",T="http://xmlns.com/foaf/0.1/",k=c.namedNode("loaded-shapes"),P=c.namedNode("loaded-data"),g=c.namedNode(M+"type");c.namedNode(x+"conformsTo");const f=c.namedNode(w+"subClassOf");c.namedNode(R+"imports");const F=c.namedNode(h+"broader"),z=c.namedNode(h+"narrower");c.namedNode(l+"NodeShape");c.namedNode(l+"IRI");c.namedNode(l+"property");c.namedNode(l+"class");c.namedNode(l+"node");c.namedNode(l+"targetClass");c.namedNode(l+"nodeKind");c.namedNode(S+"string");function u(t,o,i=l,e){let n="";const s=v(t,o,i,e);return s&&(n=s.value),n}function v(t,o,i=l,e){let n;const s=i+o;if(e?.length){for(const a of e)for(const r of t)if(r.predicate.value===s){if(r.object.id.endsWith(`@${a}`))return r.object;r.object.id.indexOf("@")<0?n=r.object:n||(n=r.object)}}else for(const a of t)if(a.predicate.value===s)return a.object;return n}function b(t,o){return u(t,"prefLabel",h,o)||u(t,"label",w,o)||u(t,"name",T,o)}function y(t,o,i){const e=[];for(const n of t)e.push({value:n,label:b(o.getQuads(n,null,null,null),i),children:[]});return e}function m(t,o,i,e,n=new Set){for(const s of o.owlImports)n.has(s.id)||(n.add(s.id),e.push(...i.getSubjects(g,t,s)));o.parent&&m(t,o.parent,i,e,n)}function I(t,o){if(o.in){const i=o.config.lists[o.in];return y(i?.length?i:[],o.config.store,o.config.languages)}else{const i=o.config.store.getSubjects(g,t,k);i.push(...o.config.store.getSubjects(g,t,P)),m(t,o,o.config.store,i);const e=new Map,n=new Map;for(const a of i)e.set(a.id,{value:a,label:b(o.config.store.getQuads(a,null,null,null),o.config.languages),children:[]});for(const a of i){for(const r of o.config.store.getObjects(a,F,null))e.has(r.id)&&n.set(a.id,r.id);for(const r of o.config.store.getObjects(a,z,null))e.has(r.id)&&n.set(r.id,a.id);for(const r of o.config.store.getObjects(a,f,null))e.has(r.id)&&n.set(a.id,r.id)}for(const[a,r]of n.entries())e.get(r)?.children?.push(e.get(a));const s=[];for(const[a,r]of e.entries())n.has(a)||s.push(r);for(const a of o.config.store.getSubjects(f,t,null))s.push(...I(a,o));return s}}function B(t,o,i){{const e=t.minCount!==void 0&&t.minCount>0;if(t.class&&!t.hasValue)return t.config.theme.createListEditor(t.label,o,e,I(t.class,t),t);if(t.in){const n=t.config.lists[t.in];if(n?.length){const s=y(n,t.config.store,t.config.languages);return t.config.theme.createListEditor(t.label,o,e,s,t)}else console.error("list not found:",t.in,"existing lists:",t.config.lists)}if(t.datatype?.value===`${M}langString`||t.languageIn?.length)return t.config.theme.createLangStringEditor(t.label,o,e,t);switch(t.datatype?.value.replace(S,"")){case"integer":case"float":case"double":case"decimal":return t.config.theme.createNumberEditor(t.label,o,e,t);case"date":case"dateTime":return t.config.theme.createDateEditor(t.label,o,e,t);case"boolean":return t.config.theme.createBooleanEditor(t.label,o,e,t);case"base64Binary":return t.config.theme.createFileEditor(t.label,o,e,t)}return t.config.theme.createTextEditor(t.label,o,e,t)}}const U=`
1
+ import*as c from"leaflet";import"leaflet-editable/src/Leaflet.Editable.js";import E from"leaflet/dist/leaflet.css?raw";import D from"leaflet.fullscreen/Control.FullScreen.css?raw";import"leaflet.fullscreen/Control.FullScreen.js";import{P as R}from"./assets/plugin-VN3CfgGe.js";import{DataFactory as d,Literal as O}from"n3";const l="http://www.w3.org/ns/shacl#",S="http://www.w3.org/2001/XMLSchema#",M="http://www.w3.org/1999/02/22-rdf-syntax-ns#",w="http://www.w3.org/2000/01/rdf-schema#",h="http://www.w3.org/2004/02/skos/core#",x="http://www.w3.org/2002/07/owl#",T="http://purl.org/dc/terms/",k="http://xmlns.com/foaf/0.1/",P=d.namedNode("loaded-shapes"),F=d.namedNode("loaded-data"),g=d.namedNode(M+"type"),z=d.namedNode(M+"langString");d.namedNode(T+"conformsTo");const f=d.namedNode(w+"subClassOf");d.namedNode(x+"imports");const v=d.namedNode(h+"broader"),B=d.namedNode(h+"narrower");d.namedNode(l+"NodeShape");d.namedNode(l+"IRI");d.namedNode(l+"property");d.namedNode(l+"class");d.namedNode(l+"node");d.namedNode(l+"targetClass");d.namedNode(l+"nodeKind");d.namedNode(S+"string");function u(t,o,i=l,e){let n="";const s=U(t,o,i,e);return s&&(n=s.value),n}function U(t,o,i=l,e){let n;const s=i+o;if(e?.length){for(const a of e)for(const r of t)if(r.predicate.value===s){if(r.object.id.endsWith(`@${a}`))return r.object;r.object.id.indexOf("@")<0?n=r.object:n||(n=r.object)}}else for(const a of t)if(a.predicate.value===s)return a.object;return n}function b(t,o){return u(t,"prefLabel",h,o)||u(t,"label",w,o)||u(t,"name",k,o)}function y(t,o,i){const e=[];for(const n of t)e.push({value:n,label:b(o.getQuads(n,null,null,null),i),children:[]});return e}function m(t,o,i,e,n=new Set){for(const s of o.owlImports)n.has(s.id)||(n.add(s.id),e.push(...i.getSubjects(g,t,s)));o.parent&&m(t,o.parent,i,e,n)}function I(t,o){if(o.in){const i=o.config.lists[o.in];return y(i?.length?i:[],o.config.store,o.config.languages)}else{const i=o.config.store.getSubjects(g,t,P);i.push(...o.config.store.getSubjects(g,t,F)),m(t,o,o.config.store,i);const e=new Map,n=new Map;for(const a of i)e.set(a.id,{value:a,label:b(o.config.store.getQuads(a,null,null,null),o.config.languages),children:[]});for(const a of i){for(const r of o.config.store.getObjects(a,v,null))e.has(r.id)&&n.set(a.id,r.id);for(const r of o.config.store.getObjects(a,B,null))e.has(r.id)&&n.set(r.id,a.id);for(const r of o.config.store.getObjects(a,f,null))e.has(r.id)&&n.set(a.id,r.id)}for(const[a,r]of n.entries())e.get(r)?.children?.push(e.get(a));const s=[];for(const[a,r]of e.entries())n.has(a)||s.push(r);for(const a of o.config.store.getSubjects(f,t,null))s.push(...I(a,o));return s}}function Y(t,o,i){{const e=t.minCount!==void 0&&t.minCount>0;if(t.class&&!t.hasValue)return t.config.theme.createListEditor(t.label,o,e,I(t.class,t),t);if(t.in){const n=t.config.lists[t.in];if(n?.length){const s=y(n,t.config.store,t.config.languages);return t.config.theme.createListEditor(t.label,o,e,s,t)}else console.error("list not found:",t.in,"existing lists:",t.config.lists)}if(t.datatype?.equals(z)||t.languageIn?.length||t.datatype===void 0&&o instanceof O&&o.language)return t.config.theme.createLangStringEditor(t.label,o,e,t);switch(t.datatype?.value.replace(S,"")){case"integer":case"float":case"double":case"decimal":return t.config.theme.createNumberEditor(t.label,o,e,t);case"date":case"dateTime":return t.config.theme.createDateEditor(t.label,o,e,t);case"boolean":return t.config.theme.createBooleanEditor(t.label,o,e,t);case"base64Binary":return t.config.theme.createFileEditor(t.label,o,e,t)}return t.config.theme.createTextEditor(t.label,o,e,t)}}const H=`
2
2
  #shaclMapDialog .closeButton { position: absolute; right: 0; top: 0; z-index: 1; padding: 6px 8px; cursor: pointer; border: 0; background-color: #FFFA; font-size: 24px; z-index: 1000; }
3
3
  #shaclMapDialog { padding: 0; width:90vw; height: 90vh; margin: auto; }
4
4
  #shaclMapDialog::backdrop { background-color: #0007; }
@@ -7,11 +7,11 @@ import*as d from"leaflet";import"leaflet-editable/src/Leaflet.Editable.js";impor
7
7
  .leaflet-container { min-height: 300px; }
8
8
  .fullscreen-icon { background-image: url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMjYgNTIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIwLjYgMzYuN0gxNmEuOS45IDAgMCAxLS44LS44di00LjVjMC0uMi4yLS40LjQtLjRoMS40Yy4zIDAgLjUuMi41LjR2M2gzYy4yIDAgLjQuMi40LjV2MS40YzAgLjItLjIuNC0uNC40em0tOS45LS44di00LjVjMC0uMi0uMi0uNC0uNC0uNEg4LjljLS4zIDAtLjUuMi0uNS40djNoLTNjLS4yIDAtLjQuMi0uNC41djEuNGMwIC4yLjIuNC40LjRIMTBjLjQgMCAuOC0uNC44LS44em0wIDEwLjdWNDJjMC0uNC0uNC0uOC0uOC0uOEg1LjRjLS4yIDAtLjQuMi0uNC40djEuNGMwIC4zLjIuNS40LjVoM3YzYzAgLjIuMi40LjUuNGgxLjRjLjIgMCAuNC0uMi40LS40em02LjkgMHYtM2gzYy4yIDAgLjQtLjIuNC0uNXYtMS40YzAtLjItLjItLjQtLjQtLjRIMTZjLS40IDAtLjguNC0uOC44djQuNWMwIC4yLjIuNC40LjRoMS40Yy4zIDAgLjUtLjIuNS0uNHpNNSAxMC4zVjUuOWMwLS41LjQtLjkuOS0uOWg0LjRjLjIgMCAuNC4yLjQuNFY3YzAgLjItLjIuNC0uNC40aC0zdjNjMCAuMi0uMi40LS40LjRINS40YS40LjQgMCAwIDEtLjQtLjR6bTEwLjMtNC45VjdjMCAuMi4yLjQuNC40aDN2M2MwIC4yLjIuNC40LjRoMS41Yy4yIDAgLjQtLjIuNC0uNFY1LjljMC0uNS0uNC0uOS0uOS0uOWgtNC40Yy0uMiAwLS40LjItLjQuNHptNS4zIDkuOUgxOWMtLjIgMC0uNC4yLS40LjR2M2gtM2MtLjIgMC0uNC4yLS40LjR2MS41YzAgLjIuMi40LjQuNGg0LjRjLjUgMCAuOS0uNC45LS45di00LjRjMC0uMi0uMi0uNC0uNC0uNHptLTkuOSA1LjNWMTljMC0uMi0uMi0uNC0uNC0uNGgtM3YtM2MwLS4yLS4yLS40LS40LS40SDUuNGMtLjIgMC0uNC4yLS40LjR2NC40YzAgLjUuNC45LjkuOWg0LjRjLjIgMCAuNC0uMi40LS40eiIgZmlsbD0iY3VycmVudENvbG9yIi8+PC9zdmc+); }
9
9
  #shaclMapDialogContainer { width:100%; height: 100%; }
10
- `,Y=`
10
+ `,Q=`
11
11
  <dialog id="shaclMapDialog" onclick="event.target==this && this.close()">
12
12
  <div id="shaclMapDialogContainer"></div>
13
13
  <div class="hint">&#x24D8; Draw a polygon or marker, then close dialog</div>
14
14
  <button class="closeButton" type="button" onclick="this.parentElement.close()">&#x2715;</button>
15
- </dialog>`,L={lng:8.657238961696038,lat:49.87627570549512},p='&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',C="https://tile.openstreetmap.de/{z}/{x}/{y}.png",j=d.icon({iconUrl:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=",shadowUrl:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAQAAAACach9AAACMUlEQVR4Ae3ShY7jQBAE0Aoz/f9/HTMzhg1zrdKUrJbdx+Kd2nD8VNudfsL/Th///dyQN2TH6f3y/BGpC379rV+S+qqetBOxImNQXL8JCAr2V4iMQXHGNJxeCfZXhSRBcQMfvkOWUdtfzlLgAENmZDcmo2TVmt8OSM2eXxBp3DjHSMFutqS7SbmemzBiR+xpKCNUIRkdkkYxhAkyGoBvyQFEJEefwSmmvBfJuJ6aKqKWnAkvGZOaZXTUgFqYULWNSHUckZuR1HIIimUExutRxwzOLROIG4vKmCKQt364mIlhSyzAf1m9lHZHJZrlAOMMztRRiKimp/rpdJDc9Awry5xTZCte7FHtuS8wJgeYGrex28xNTd086Dik7vUMscQOa8y4DoGtCCSkAKlNwpgNtphjrC6MIHUkR6YWxxs6Sc5xqn222mmCRFzIt8lEdKx+ikCtg91qS2WpwVfBelJCiQJwvzixfI9cxZQWgiSJelKnwBElKYtDOb2MFbhmUigbReQBV0Cg4+qMXSxXSyGUn4UbF8l+7qdSGnTC0XLCmahIgUHLhLOhpVCtw4CzYXvLQWQbJNmxoCsOKAxSgBJno75avolkRw8iIAFcsdc02e9iyCd8tHwmeSSoKTowIgvscSGZUOA7PuCN5b2BX9mQM7S0wYhMNU74zgsPBj3HU7wguAfnxxjFQGBE6pwN+GjME9zHY7zGp8wVxMShYX9NXvEWD3HbwJf4giO4CFIQxXScH1/TM+04kkBiAAAAAElFTkSuQmCC",iconSize:[25,41],shadowSize:[41,41],iconAnchor:[12,41],shadowAnchor:[14,41],popupAnchor:[-3,-76]});class K extends O{constructor(o){super(o,E+`
15
+ </dialog>`,L={lng:8.657238961696038,lat:49.87627570549512},p='&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',C="https://tile.openstreetmap.de/{z}/{x}/{y}.png",j=c.icon({iconUrl:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=",shadowUrl:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAQAAAACach9AAACMUlEQVR4Ae3ShY7jQBAE0Aoz/f9/HTMzhg1zrdKUrJbdx+Kd2nD8VNudfsL/Th///dyQN2TH6f3y/BGpC379rV+S+qqetBOxImNQXL8JCAr2V4iMQXHGNJxeCfZXhSRBcQMfvkOWUdtfzlLgAENmZDcmo2TVmt8OSM2eXxBp3DjHSMFutqS7SbmemzBiR+xpKCNUIRkdkkYxhAkyGoBvyQFEJEefwSmmvBfJuJ6aKqKWnAkvGZOaZXTUgFqYULWNSHUckZuR1HIIimUExutRxwzOLROIG4vKmCKQt364mIlhSyzAf1m9lHZHJZrlAOMMztRRiKimp/rpdJDc9Awry5xTZCte7FHtuS8wJgeYGrex28xNTd086Dik7vUMscQOa8y4DoGtCCSkAKlNwpgNtphjrC6MIHUkR6YWxxs6Sc5xqn222mmCRFzIt8lEdKx+ikCtg91qS2WpwVfBelJCiQJwvzixfI9cxZQWgiSJelKnwBElKYtDOb2MFbhmUigbReQBV0Cg4+qMXSxXSyGUn4UbF8l+7qdSGnTC0XLCmahIgUHLhLOhpVCtw4CzYXvLQWQbJNmxoCsOKAxSgBJno75avolkRw8iIAFcsdc02e9iyCd8tHwmeSSoKTowIgvscSGZUOA7PuCN5b2BX9mQM7S0wYhMNU74zgsPBj3HU7wguAfnxxjFQGBE6pwN+GjME9zHY7zGp8wVxMShYX9NXvEWD3HbwJf4giO4CFIQxXScH1/TM+04kkBiAAAAAElFTkSuQmCC",iconSize:[25,41],shadowSize:[41,41],iconAnchor:[12,41],shadowAnchor:[14,41],popupAnchor:[-3,-76]});class J extends R{constructor(o){super(o,E+`
16
16
  `+D+`
17
- `+U)}initEditMode(o){o.insertAdjacentHTML("beforeend",Y);const i=o.querySelector("#shaclMapDialogContainer");this.map=d.map(i,{fullscreenControl:!0,editable:!0,layers:[d.tileLayer(C)],zoom:5,maxBounds:A,center:L}),this.map.attributionControl.addAttribution(p);const e=d.Control.extend({options:{position:"topleft",callback:null,kind:"",html:""},onAdd:function(s){let a=d.DomUtil.create("div","leaflet-control leaflet-bar"),r=d.DomUtil.create("a","",a);return r.href="#",r.title="Create a new "+this.options.kind,r.innerHTML=this.options.html,d.DomEvent.on(r,"click",d.DomEvent.stop).on(r,"click",()=>{window.LAYER=this.options.callback.call(s.editTools)},this),a}});this.map.addControl(new(e.extend({options:{callback:()=>{this.displayedShape?.remove(),this.displayedShape=this.map?.editTools.startPolygon()},kind:"polygon",html:"▰"}}))),this.map.addControl(new(e.extend({options:{callback:()=>{this.displayedShape?.remove(),this.displayedShape=this.map?.editTools.startMarker(void 0,{icon:j})},kind:"marker",html:"•"}}))),this.map.on("editable:drawing:end",()=>{this.saveChanges()}),this.map.on("editable:vertex:dragend",()=>{this.saveChanges()});const n=o.querySelector("#shaclMapDialog");return n.addEventListener("close",()=>{const s=document.body.style.top;document.body.style.position="",document.body.style.top="",window.scrollTo(0,parseInt(s||"0")*-1),this.currentEditor&&this.createdGeometry&&(this.currentEditor.value=H(this.createdGeometry),this.currentEditor.dispatchEvent(new Event("change",{bubbles:!0})))}),n}createEditor(o,i){let e=o.config.form.querySelector("#shaclMapDialog");e||(e=this.initEditMode(o.config.form));const n=o.config.theme.createButton("Open&#160;map...",!1);n.style.marginLeft="5px",n.classList.add("open-map-button"),n.onclick=()=>{this.currentEditor=s.querySelector(".editor"),this.createdGeometry=void 0,this.displayedShape?.remove(),this.drawAndZoomToGeometry(N(this.currentEditor.value||""),this.map),document.body.style.top=`-${window.scrollY}px`,document.body.style.position="fixed",e.showModal()};const s=B(o,i||null);return s.appendChild(n),s}createViewer(o,i){const e=document.createElement("div"),n=N(i.value);if(n?.coordinates?.length){const s=d.map(e,{fullscreenControl:!0,layers:[d.tileLayer(C)],zoom:5,center:L,maxBounds:A});s.attributionControl.addAttribution(p),this.drawAndZoomToGeometry(n,s)}return e}drawAndZoomToGeometry(o,i){if(setTimeout(()=>{i.invalidateSize()}),o?.type==="Point"){const e={lng:o.coordinates[0],lat:o.coordinates[1]};this.displayedShape=d.marker(e,{icon:j}).addTo(i),i.setView(e,15,{animate:!1})}else if(o?.type==="Polygon"){const e=o.coordinates[0].map(s=>({lng:s[0],lat:s[1]})),n=d.polygon(e).addTo(i);this.displayedShape=n,i.fitBounds(n.getBounds(),{animate:!1}),setTimeout(()=>{i.fitBounds(n.getBounds(),{animate:!1}),i.setView(n.getCenter(),void 0,{animate:!1})},1)}else i.setZoom(5)}saveChanges(){if(this.displayedShape instanceof d.Marker){const o=this.displayedShape.getLatLng();this.createdGeometry={type:"Point",coordinates:[o.lng,o.lat]}}else if(this.displayedShape instanceof d.Polygon){const o=this.displayedShape.getLatLngs();o[0][0].equals(o[0][o[0].length-1])||o[0].push(o[0][0]),this.createdGeometry={type:"Polygon",coordinates:[o[0].map(i=>[i.lng,i.lat])]}}else this.createdGeometry=void 0}}const A=[[-90,-180],[90,180]];function N(t){const o=t.match(/^POINT\((.*)\)$/);if(o?.length==2){const e=o[1].split(" ");if(e.length===2)return{type:"Point",coordinates:[parseFloat(e[0]),parseFloat(e[1])]}}const i=t.match(/^POLYGON[(]{2}(.*)[)]{2}$/);if(i?.length==2){const e=i[1].split(",");if(e.length>2){const n=[],s=[];n.push(s);for(const a of e){const r=a.split(" ");r.length===2&&s.push([parseFloat(r[0]),parseFloat(r[1])])}return{type:"Polygon",coordinates:n}}}}function H(t){return t.type==="Point"?`POINT(${t.coordinates.join(" ")})`:t.type==="Polygon"?`POLYGON((${t.coordinates[0].map(o=>o.join(" ")).join(",")}))`:""}export{K as LeafletPlugin,H as geometryToWkt,N as wktToGeometry,A as worldBounds};
17
+ `+H)}initEditMode(o){o.insertAdjacentHTML("beforeend",Q);const i=o.querySelector("#shaclMapDialogContainer");this.map=c.map(i,{fullscreenControl:!0,editable:!0,layers:[c.tileLayer(C)],zoom:5,maxBounds:A,center:L}),this.map.attributionControl.addAttribution(p);const e=c.Control.extend({options:{position:"topleft",callback:null,kind:"",html:""},onAdd:function(s){let a=c.DomUtil.create("div","leaflet-control leaflet-bar"),r=c.DomUtil.create("a","",a);return r.href="#",r.title="Create a new "+this.options.kind,r.innerHTML=this.options.html,c.DomEvent.on(r,"click",c.DomEvent.stop).on(r,"click",()=>{window.LAYER=this.options.callback.call(s.editTools)},this),a}});this.map.addControl(new(e.extend({options:{callback:()=>{this.displayedShape?.remove(),this.displayedShape=this.map?.editTools.startPolygon()},kind:"polygon",html:"▰"}}))),this.map.addControl(new(e.extend({options:{callback:()=>{this.displayedShape?.remove(),this.displayedShape=this.map?.editTools.startMarker(void 0,{icon:j})},kind:"marker",html:"•"}}))),this.map.on("editable:drawing:end",()=>{this.saveChanges()}),this.map.on("editable:vertex:dragend",()=>{this.saveChanges()});const n=o.querySelector("#shaclMapDialog");return n.addEventListener("close",()=>{const s=document.body.style.top;document.body.style.position="",document.body.style.top="",window.scrollTo(0,parseInt(s||"0")*-1),this.currentEditor&&this.createdGeometry&&(this.currentEditor.value=G(this.createdGeometry),this.currentEditor.dispatchEvent(new Event("change",{bubbles:!0})))}),n}createEditor(o,i){let e=o.config.form.querySelector("#shaclMapDialog");e||(e=this.initEditMode(o.config.form));const n=o.config.theme.createButton("Open&#160;map...",!1);n.style.marginLeft="5px",n.classList.add("open-map-button"),n.onclick=()=>{this.currentEditor=s.querySelector(".editor"),this.createdGeometry=void 0,this.displayedShape?.remove(),this.drawAndZoomToGeometry(N(this.currentEditor.value||""),this.map),document.body.style.top=`-${window.scrollY}px`,document.body.style.position="fixed",e.showModal()};const s=Y(o,i||null);return s.appendChild(n),s}createViewer(o,i){const e=document.createElement("div"),n=N(i.value);if(n?.coordinates?.length){const s=c.map(e,{fullscreenControl:!0,layers:[c.tileLayer(C)],zoom:5,center:L,maxBounds:A});s.attributionControl.addAttribution(p),this.drawAndZoomToGeometry(n,s)}return e}drawAndZoomToGeometry(o,i){if(setTimeout(()=>{i.invalidateSize()}),o?.type==="Point"){const e={lng:o.coordinates[0],lat:o.coordinates[1]};this.displayedShape=c.marker(e,{icon:j}).addTo(i),i.setView(e,15,{animate:!1})}else if(o?.type==="Polygon"){const e=o.coordinates[0].map(s=>({lng:s[0],lat:s[1]})),n=c.polygon(e).addTo(i);this.displayedShape=n,i.fitBounds(n.getBounds(),{animate:!1}),setTimeout(()=>{i.fitBounds(n.getBounds(),{animate:!1}),i.setView(n.getCenter(),void 0,{animate:!1})},1)}else i.setZoom(5)}saveChanges(){if(this.displayedShape instanceof c.Marker){const o=this.displayedShape.getLatLng();this.createdGeometry={type:"Point",coordinates:[o.lng,o.lat]}}else if(this.displayedShape instanceof c.Polygon){const o=this.displayedShape.getLatLngs();o[0][0].equals(o[0][o[0].length-1])||o[0].push(o[0][0]),this.createdGeometry={type:"Polygon",coordinates:[o[0].map(i=>[i.lng,i.lat])]}}else this.createdGeometry=void 0}}const A=[[-90,-180],[90,180]];function N(t){const o=t.match(/^POINT\((.*)\)$/);if(o?.length==2){const e=o[1].split(" ");if(e.length===2)return{type:"Point",coordinates:[parseFloat(e[0]),parseFloat(e[1])]}}const i=t.match(/^POLYGON[(]{2}(.*)[)]{2}$/);if(i?.length==2){const e=i[1].split(",");if(e.length>2){const n=[],s=[];n.push(s);for(const a of e){const r=a.split(" ");r.length===2&&s.push([parseFloat(r[0]),parseFloat(r[1])])}return{type:"Polygon",coordinates:n}}}}function G(t){return t.type==="Point"?`POINT(${t.coordinates.join(" ")})`:t.type==="Polygon"?`POLYGON((${t.coordinates[0].map(o=>o.join(" ")).join(",")}))`:""}export{J as LeafletPlugin,G as geometryToWkt,N as wktToGeometry,A as worldBounds};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ulb-darmstadt/shacl-form",
3
- "version": "2.0.0-rc12",
3
+ "version": "2.0.0-rc14",
4
4
  "description": "SHACL form generator",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",