@ulb-darmstadt/shacl-form 3.0.5 → 3.0.7

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/form.d.ts CHANGED
@@ -26,9 +26,6 @@ export declare class ShaclForm extends HTMLElement {
26
26
  toRDF(graph?: Store<import("@rdfjs/types").Quad, import("n3").Quad, import("@rdfjs/types").Quad, import("@rdfjs/types").Quad>): Store;
27
27
  registerPlugin(plugin: Plugin): void;
28
28
  setTheme(theme: Theme): void;
29
- /**
30
- * @deprecated Use setDataProvider() instead
31
- */
32
29
  setClassInstanceProvider(provider: ClassInstanceProvider): void;
33
30
  setResourceLinkProvider(provider: ResourceLinkProvider): void;
34
31
  validate(ignoreEmptyValues?: boolean): Promise<ValidationReport>;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{DataFactory as e,Literal as t,NamedNode as n,Store as r,StreamParser as i,Writer as a}from"n3";import{RdfXmlParser as o}from"rdfxml-streaming-parser";import s from"jsonld";import{RokitButton as c,RokitCollapsible as l,RokitDialog as u,RokitInput as d,RokitSelect as f,RokitTextArea as p}from"@ro-kit/ui-widgets";import{v4 as m}from"uuid";import{Validator as ee}from"shacl-engine";var h=`http://www.w3.org/ns/shacl#`,te=`http://datashapes.org/dash#`,g=`http://www.w3.org/2001/XMLSchema#`,_=`http://www.w3.org/1999/02/22-rdf-syntax-ns#`,v=`http://www.w3.org/2000/01/rdf-schema#`,ne=`http://www.w3.org/2004/02/skos/core#`,re=`http://www.w3.org/2002/07/owl#`,ie=`http://www.w3.org/ns/oa#`,y=`http://purl.org/dc/terms/`,b=e.namedNode(`loaded-shapes`),x=e.namedNode(`loaded-data`),S=e.namedNode(_+`type`),ae=e.namedNode(_+`langString`),C=e.namedNode(y+`conformsTo`),oe=e.namedNode(v+`subClassOf`),w=e.namedNode(re+`imports`),se=e.namedNode(ne+`broader`),ce=e.namedNode(ne+`narrower`),T=e.namedNode(h+`NodeShape`),le=e.namedNode(h+`IRI`),E=e.namedNode(h+`property`),D=e.namedNode(h+`class`),ue=e.namedNode(h+`node`),O=e.namedNode(h+`targetClass`),de=e.namedNode(h+`nodeKind`),fe=e.namedNode(g+`string`),pe=e.namedNode(g+`boolean`);function k(e,t,n=h,r){let i=``,a=me(e,t,n,r);return a&&(i=a.value),i}function me(e,t,n=h,r){let i,a=n+t;if(r?.length){for(let t of r)for(let n of e)if(n.predicate.value===a){if(n.object.id.endsWith(`@${t}`))return n.object;n.object.id.indexOf(`@`)<0?i=n.object:i||=n.object}}else for(let t of e)if(t.predicate.value===a)return t.object;return i}function he(e){e.querySelector(`.editor`)?.focus()}function A(e,t){return k(e,`prefLabel`,`http://www.w3.org/2004/02/skos/core#`,t)||k(e,`label`,`http://www.w3.org/2000/01/rdf-schema#`,t)||k(e,`title`,`http://purl.org/dc/terms/`,t)||k(e,`name`,`http://xmlns.com/foaf/0.1/`,t)}function ge(e,t,n){let r=[];for(let i of e)r.push({value:i,label:A(t.getQuads(i,null,null,null),n),children:[]});return r}function j(e,t){for(let n in t){let r=t[n];e.startsWith(r)&&(e=e.slice(r.length))}return e}function _e(e,t,n,r,i=new Set){for(let a of t.owlImports)i.has(a.id)||(i.add(a.id),r.push(...n.getSubjects(S,e,a)));t.parent&&_e(e,t.parent,n,r,i)}function ve(e,t){if(t.in){let e=t.config.lists[t.in];return ge(e?.length?e:[],t.config.store,t.config.languages)}else{let n=t.config.store.getSubjects(S,e,b);n.push(...t.config.store.getSubjects(S,e,x)),_e(e,t,t.config.store,n);let r=new Map,i=new Map;for(let e of n)r.set(e.id,{value:e,label:A(t.config.store.getQuads(e,null,null,null),t.config.languages),children:[]});for(let e of n){for(let n of t.config.store.getObjects(e,se,null))r.has(n.id)&&i.set(e.id,n.id);for(let n of t.config.store.getObjects(e,ce,null))r.has(n.id)&&i.set(n.id,e.id);for(let n of t.config.store.getObjects(e,oe,null))r.has(n.id)&&i.set(e.id,n.id)}for(let[e,t]of i.entries())r.get(t)?.children?.push(r.get(e));let a=[];for(let[e,t]of r.entries())i.has(e)||a.push(t);for(let n of t.config.store.getSubjects(oe,e,null))a.push(...ve(n,t));return a}}function M(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol===`http:`||t.protocol===`https:`}function N(e,t,n){if(t===void 0)return n;if(n===void 0)return t;let r=e.indexOf(t.language);if(r<0)return n;let i=e.indexOf(n.language);return i<0||i>r?t:n}function ye(e,t){let n;for(let r of t)n=N(e,n,r);return n?n.value:``}function be(e){let t=new Set;for(let n of e.getObjects(null,D,b))t.add(n.value);for(let n of e.getObjects(null,O,b))t.add(n.value);return t}function xe(e,t){return e instanceof Set?[...t].filter(t=>!e.has(t)):[...t].filter(t=>!e.includes(t))}function Se(e,{remove:t=!1,ignoreErrors:n=!1}={}){let r={},i=n?(()=>!0):((e,t)=>{throw Error(`${e.value} ${t}`)}),a=e.getQuads(null,_+`rest`,_+`nil`,null),o=t?[...a]:[];return a.forEach(n=>{let a=[],s=!1,c,l,u=n.graph,d=n.subject;for(;d&&!s;){let t=e.getQuads(null,null,d,null),n=e.getQuads(d,null,null,null).filter(e=>!e.predicate.equals(S)),r,f=null,p=null,m=null;for(let e=0;e<n.length&&!s;e++)r=n[e],r.graph.equals(u)?c?s=i(d,`has non-list arcs out`):r.predicate.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#first`?f?s=i(d,`has multiple rdf:first arcs`):o.push(f=r):r.predicate.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#rest`?p?s=i(d,`has multiple rdf:rest arcs`):o.push(p=r):t.length?s=i(d,`can't be subject and object`):(c=r,l=`subject`):s=i(d,`not confined to single graph`);for(let e=0;e<t.length&&!s;++e)r=t[e],c?s=i(d,`can't have coreferences`):r.predicate.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#rest`?m?s=i(d,`has incoming rdf:rest arcs`):m=r:(c=r,l=`object`);f?a.unshift(f.object):s=i(d,`has no list head`),d=m&&m.subject}s?t=!1:c&&(r[c[l].value]=a)}),t&&e.removeQuads(o),r}var P={},F={};function I(e){let t=new Set;for(let n of e.getQuads(null,C,null,x))n.subject.termType===`NamedNode`&&t.add(n.subject.value);if(t.size===1)return t.values().next().value}function Ce(t,n){let r=e.namedNode(n);for(let e of t.getObjects(r,C,x))if(e.termType===`NamedNode`&&t.getQuads(e,S,T,null).length>0)return e}async function we(e){let t={store:new r,importedUrls:[],atts:e},n=[];if(e.shapes?n.push(L(z(e.shapes),t,b)):e.shapesUrl&&n.push(L(R(e.shapesUrl,t.atts.proxy),t,b)),e.values?n.push(L(z(e.values),t,x)):e.valuesUrl&&n.push(L(R(e.valuesUrl,t.atts.proxy),t,x)),await Promise.all(n),e.classInstanceProvider)try{let n=be(t.store),r=await e.classInstanceProvider(n);r&&await L(z(r),t,b)}catch(e){console.error(`failed loading class instances`,e)}if(e.valuesSubject||=I(t.store)||null,e.valuesSubject&&t.store.countQuads(null,null,null,b)===0){let n=[...t.store.getObjects(e.valuesSubject,S,x),...t.store.getObjects(e.valuesSubject,C,x)],r=[];for(let e of n){let n=Te(e.value);!n&&e.value.startsWith(`urn:`)&&t.atts.proxy&&(n=e.value),n&&t.importedUrls.indexOf(n)<0&&(t.importedUrls.push(n),r.push(L(R(n,t.atts.proxy),t,b)))}try{await Promise.allSettled(r)}catch(e){console.warn(e)}}return t.store}async function L(t,n,r){let i=await t,a=[];for(let t of i){let i=r;if(n.atts.valuesSubject&&x.equals(r)&&t.graph.id&&t.graph.id!==n.atts.valuesSubject&&(i=t.graph),n.store.add(e.quad(t.subject,t.predicate,t.object,i)),n.atts.loadOwlImports&&w.equals(t.predicate)){let r=Te(t.object.value);r&&n.importedUrls.indexOf(r)<0&&(n.importedUrls.push(r),a.push(L(R(r,n.atts.proxy),n,e.namedNode(r))))}}await Promise.allSettled(a)}async function R(e,t){return e in P||(P[e]=(async()=>{let n=e;t&&(n=t+encodeURIComponent(e));let r=await fetch(n,{headers:{Accept:`text/turtle, application/trig, application/n-triples, application/n-quads, text/n3, application/ld+json`}});return r.ok?z(await r.text()):(console.warn(`failed fetching RDF from`,e),[])})()),P[e]}async function z(t){if(!t.trim())return[];let n=Ee(t);if(n===`json`)try{t=await s.toRDF(JSON.parse(t),{format:`application/n-quads`})}catch(e){console.error(e)}let r=[];return await new Promise((a,s)=>{let c=n===`xml`?new o:new i;c.on(`data`,t=>{r.push(e.quad(t.subject,t.predicate,t.object,t.graph))}).on(`error`,e=>{s(e)}).on(`prefix`,(e,t)=>{e&&(F[e]=t)}).on(`end`,()=>{a(null)}),c.write(t),c.end()}),r}function Te(e){if(M(e))return e;let t=e.split(`:`);if(t.length===2){let n=F[t[0]];if(n&&(e=e.replace(`${t[0]}:`,n),M(e)))return e}return null}function Ee(e){return/^\s*[\\[{]/.test(e)?`json`:/^\s*<\?xml/.test(e)?`xml`:`ttl`}var De={[`${h}name`]:(e,t)=>{let n=t;e.name=N(e.config.languages,e.name,n)},[`${h}description`]:(e,t)=>{let n=t;e.description=N(e.config.languages,e.description,n)},[`${h}path`]:(e,t)=>{e.path=t.value},[`${h}group`]:(e,t)=>{e.group=t.id},[`${h}datatype`]:(e,t)=>{e.datatype=t},[`${h}nodeKind`]:(e,t)=>{e.nodeKind=t},[`${h}minCount`]:(e,t)=>{e.minCount=parseInt(t.value)},[`${h}maxCount`]:(e,t)=>{e.maxCount=parseInt(t.value)},[`${h}minLength`]:(e,t)=>{e.minLength=parseInt(t.value)},[`${h}maxLength`]:(e,t)=>{e.maxLength=parseInt(t.value)},[`${h}minInclusive`]:(e,t)=>{e.minInclusive=parseInt(t.value)},[`${h}maxInclusive`]:(e,t)=>{e.maxInclusive=parseInt(t.value)},[`${h}minExclusive`]:(e,t)=>{e.minExclusive=parseInt(t.value)},[`${h}maxExclusive`]:(e,t)=>{e.maxExclusive=parseInt(t.value)},[`${h}pattern`]:(e,t)=>{e.pattern=t.value},[`${h}order`]:(e,t)=>{e.order=parseInt(t.value)},[`${te}singleLine`]:(e,t)=>{e.singleLine=t.value===`true`},[`${te}readonly`]:(e,t)=>{e.readonly=t.value===`true`},[`${ie}styleClass`]:(e,t)=>{e.cssClass=t.value},[`${h}in`]:(e,t)=>{e.in=t.value},[`${h}languageIn`]:(e,t)=>{e.languageIn=e.config.lists[t.value],e.datatype=ae},[`${h}defaultValue`]:(e,t)=>{e.defaultValue=t},[`${h}hasValue`]:(e,t)=>{e.hasValue=t},[`${h}node`]:(e,t)=>{e.node=t,e.nodeShapes.add(e.config.getNodeTemplate(t,e))},[`${h}and`]:(e,t)=>{e.and=t.value;let n=e.config.lists[e.and];if(n?.length)for(let t of n)e.nodeShapes.add(e.config.getNodeTemplate(t,e))},[`${h}qualifiedValueShape`]:(e,t)=>{let n=e.config.getNodeTemplate(t,e);e.qualifiedValueShape=n,e.nodeShapes.add(n)},[`${h}qualifiedMinCount`]:(e,t)=>{e.qualifiedMinCount=parseInt(t.value)},[`${h}qualifiedMaxCount`]:(e,t)=>{e.qualifiedMaxCount=parseInt(t.value)},[w.id]:(e,t)=>{e.owlImports.add(t)},[D.id]:(e,t)=>{e.class=t;let n=e.config.store.getSubjects(O,t,null);n.length>0&&(e.node=n[0])},[`${h}or`]:(e,t)=>{let n=e.config.lists[t.value];n?.length?e.or=n:console.error(`list for sh:or not found:`,t.value,`existing lists:`,e.config.lists)},[`${h}xone`]:(e,t)=>{let n=e.config.lists[t.value];n?.length?e.xone=n:console.error(`list for sh:xone not found:`,t.value,`existing lists:`,e.config.lists)}},B=class{constructor(e,t){this.label=``,this.nodeShapes=new Set,this.owlImports=new Set,this.id=e,this.parent=t,this.config=t.config,this.config.registerPropertyTemplate(this),H(this,this.config.store.getQuads(e,null,null,null))}};function V(e){return Math.max(e.minCount??0,e.qualifiedMinCount??0)}function Oe(e){return Math.min(e.maxCount??2**53-1,e.qualifiedMaxCount??2**53-1)}function ke(e){let t=Object.assign({},e);return t.nodeShapes=new Set(e.nodeShapes),t.owlImports=new Set(e.owlImports),e.languageIn&&(t.languageIn=[...e.languageIn]),e.or&&(t.or=[...e.or]),e.xone&&(t.xone=[...e.xone]),t}function H(e,t){for(let n of t)De[n.predicate.id]?.call(e,e,n.object);return e.label=e.name?.value||A(t,e.config.languages),e.label||=e.path?j(e.path,F):`unknown`,e}function Ae(e,t){let n=t,r=e;for(let e in t)if(e!==`parent`&&e!==`config`&&e!==`id`){let t=n[e];if(t!==void 0&&t!==``)if(Array.isArray(t)){let n=r[e];Array.isArray(n)?n.push(...t):r[e]=[...t]}else if(t instanceof Set&&t.size){let n=r[e];r[e]=new Set([...n instanceof Set?n:[],...t])}else r[e]=t}}function je(e,t,n){let r=document.createElement(`div`);r.classList.add(`shacl-or-constraint`),r.setAttribute(`part`,`constraint`);let i=[];if(t instanceof q){let a=[],o=!1;e.length&&(o=n.store.countQuads(e[0],E,null,null)>0);for(let r=0;r<e.length;r++)if(o){let o=n.store.getObjects(e[r],E,null),s=[],c=``;for(let e of o){let r=new G(n.getPropertyTemplate(e,t.template),t);s.push(r),c+=(c.length>0?` / `:``)+r.template.label}a.push(s),i.push({label:c,value:r.toString()})}else{let o=e[r],s=new G(n.getPropertyTemplate(o,t.template),t);a.push([s]),i.push({label:s.template.label,value:r.toString()})}let s=n.theme.createListEditor(`Please choose`,null,!1,i);s.setAttribute(`part`,`constraint-editor`);let c=s.querySelector(`.editor`);c.onchange=()=>{if(c.value){let e=a[parseInt(c.value)],t;e.length&&(t=e[0],r.replaceWith(e[0]),t.updateControls());for(let n=1;n<e.length;n++)t.after(e[n]),t=e[n],t.updateControls()}},r.appendChild(s)}else{let a=[];for(let t=0;t<e.length;t++){let r=n.store.getQuads(e[t],null,null,null);if(r.length){a.push(r);let e=A(r,n.languages);for(let t of r)t.predicate.equals(ue)&&(e=A(n.store.getQuads(t.object,null,null,null),n.languages));i.push({label:e||j(r[0].predicate.value,F)+` = `+j(r[0].object.value,F),value:t.toString()})}}let o=n.theme.createListEditor(t.template.label+`?`,null,!1,i,t.template);o.setAttribute(`part`,`constraint-editor`);let s=o.querySelector(`.editor`);s.onchange=async()=>{if(s.value){let e=await K(H(ke(t.template),a[parseInt(s.value)]),void 0,!0),n=e.querySelector(`:scope > label`);n&&n.classList.add(`persistent`),r.replaceWith(e)}},r.appendChild(o)}return r}function Me(e,t,n){if(t.termType===`Literal`){let r=t.datatype;for(let t of e){let e=n.store.getQuads(t,null,null,null);for(let t of e)if(t.predicate.value===`http://www.w3.org/ns/shacl#datatype`&&t.object.equals(r))return e}}else{let r=n.store.getObjects(t,S,null);for(let t of e){let e=n.store.getQuads(t,null,null,null);for(let t of e)if(r.length>0){if(t.predicate.value===`http://www.w3.org/ns/shacl#node`){for(let i of r)if(n.store.getQuads(t.object,O,i,null).length>0)return e}if(t.predicate.equals(D)){for(let n of r)if(t.object.equals(n))return e}}else if(t.predicate.equals(de)&&t.object.equals(le))return e}}return console.error(`couldn't resolve sh:or/sh:xone on property for value`,t),[]}function Ne(e,t,n){for(let r of e){let e=!1,i=n.store.getObjects(r,E,null);for(let r of i){let i=n.store.getObjects(r,`${h}path`,null);for(let r of i)if(e=n.store.countQuads(t,r,null,null)>0,e)break}if(e)return i}return console.error(`couldn't resolve sh:or/sh:xone on node for value`,t),[]}var Pe=`:host {
1
+ import{DataFactory as e,Literal as t,NamedNode as n,Store as r,StreamParser as i,Writer as a}from"n3";import{RdfXmlParser as o}from"rdfxml-streaming-parser";import s from"jsonld";import{RokitButton as c,RokitCollapsible as l,RokitDialog as u,RokitInput as d,RokitSelect as f,RokitTextArea as p}from"@ro-kit/ui-widgets";import{v4 as m}from"uuid";import{Validator as ee}from"shacl-engine";var h=`http://www.w3.org/ns/shacl#`,te=`http://datashapes.org/dash#`,g=`http://www.w3.org/2001/XMLSchema#`,_=`http://www.w3.org/1999/02/22-rdf-syntax-ns#`,v=`http://www.w3.org/2000/01/rdf-schema#`,ne=`http://www.w3.org/2004/02/skos/core#`,re=`http://www.w3.org/2002/07/owl#`,ie=`http://www.w3.org/ns/oa#`,ae=`http://purl.org/dc/terms/`,y=e.namedNode(`loaded-shapes`),b=e.namedNode(`loaded-data`),x=e.namedNode(_+`type`),oe=e.namedNode(_+`langString`),S=e.namedNode(ae+`conformsTo`),se=e.namedNode(v+`subClassOf`),C=e.namedNode(re+`imports`),ce=e.namedNode(ne+`broader`),le=e.namedNode(ne+`narrower`),w=e.namedNode(h+`NodeShape`),ue=e.namedNode(h+`IRI`),T=e.namedNode(h+`property`),E=e.namedNode(h+`class`),de=e.namedNode(h+`node`),D=e.namedNode(h+`targetClass`),fe=e.namedNode(h+`nodeKind`),pe=e.namedNode(g+`string`),me=e.namedNode(g+`boolean`);function O(e,t,n=h,r){let i=``,a=he(e,t,n,r);return a&&(i=a.value),i}function he(e,t,n=h,r){let i,a=n+t;if(r?.length){for(let t of r)for(let n of e)if(n.predicate.value===a){if(n.object.id.endsWith(`@${t}`))return n.object;n.object.id.indexOf(`@`)<0?i=n.object:i||=n.object}}else for(let t of e)if(t.predicate.value===a)return t.object;return i}function ge(e){e.querySelector(`.editor`)?.focus()}function k(e,t){return O(e,`prefLabel`,`http://www.w3.org/2004/02/skos/core#`,t)||O(e,`label`,`http://www.w3.org/2000/01/rdf-schema#`,t)||O(e,`title`,`http://purl.org/dc/terms/`,t)||O(e,`name`,`http://xmlns.com/foaf/0.1/`,t)}function _e(e,t,n){let r=[];for(let i of e)r.push({value:i,label:k(t.getQuads(i,null,null,null),n),children:[]});return r}function A(e,t){for(let n in t){let r=t[n];e.startsWith(r)&&(e=e.slice(r.length))}return e}function ve(e,t,n,r,i=new Set){for(let a of t.owlImports)i.has(a.id)||(i.add(a.id),r.push(...n.getSubjects(x,e,a)));t.parent&&ve(e,t.parent,n,r,i)}function ye(e,t){if(t.in){let e=t.config.lists[t.in];return _e(e?.length?e:[],t.config.store,t.config.languages)}else{let n=t.config.store.getSubjects(x,e,y);n.push(...t.config.store.getSubjects(x,e,b)),ve(e,t,t.config.store,n);let r=new Map,i=new Map;for(let e of n)r.set(e.id,{value:e,label:k(t.config.store.getQuads(e,null,null,null),t.config.languages),children:[]});for(let e of n){for(let n of t.config.store.getObjects(e,ce,null))r.has(n.id)&&i.set(e.id,n.id);for(let n of t.config.store.getObjects(e,le,null))r.has(n.id)&&i.set(n.id,e.id);for(let n of t.config.store.getObjects(e,se,null))r.has(n.id)&&i.set(e.id,n.id)}for(let[e,t]of i.entries())r.get(t)?.children?.push(r.get(e));let a=[];for(let[e,t]of r.entries())i.has(e)||a.push(t);for(let n of t.config.store.getSubjects(se,e,null))a.push(...ye(n,t));return a}}function j(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol===`http:`||t.protocol===`https:`}function M(e,t,n){if(t===void 0)return n;if(n===void 0)return t;let r=e.indexOf(t.language);if(r<0)return n;let i=e.indexOf(n.language);return i<0||i>r?t:n}function be(e,t){let n;for(let r of t)n=M(e,n,r);return n?n.value:``}var N=/^(-?\d{4,}-\d{2}-\d{2})(Z|[+-]\d{2}:\d{2})?$/,xe=/^(-?\d{4,}-\d{2}-\d{2})T(\d{2}:\d{2})(?::(\d{2})(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?$/,Se=/^(-?\d{4,}-\d{2}-\d{2}T\d{2}:\d{2})(?::(\d{2})(\.\d+)?)?$/;function Ce(e){let t=e.match(N);if(!t){let t=e.match(xe);return t?{value:t[1],suffix:t[5]||``}:void 0}return{value:t[1],suffix:t[2]||``}}function we(e){let t=e.match(xe);if(!t){let t=e.match(N);return t?{value:`${t[1]}T00:00:00`,suffix:t[2]||``}:void 0}return{value:`${t[1]}T${t[2]}:${t[3]||`00`}`,suffix:t[5]||``}}function Te(e,t=``){let n=e.match(N);return n?`${n[1]}${t}`:e}function Ee(e,t=``){let n=e.match(Se);return n?`${n[1]}:${n[2]||`00`}${n[3]||``}${t}`:e}function De(e){let t=new Set;for(let n of e.getObjects(null,E,y))t.add(n.value);for(let n of e.getObjects(null,D,y))t.add(n.value);return t}function Oe(e,t){return e instanceof Set?[...t].filter(t=>!e.has(t)):[...t].filter(t=>!e.includes(t))}function ke(e,{remove:t=!1,ignoreErrors:n=!1}={}){let r={},i=n?(()=>!0):((e,t)=>{throw Error(`${e.value} ${t}`)}),a=e.getQuads(null,_+`rest`,_+`nil`,null),o=t?[...a]:[];return a.forEach(n=>{let a=[],s=!1,c,l,u=n.graph,d=n.subject;for(;d&&!s;){let t=e.getQuads(null,null,d,null),n=e.getQuads(d,null,null,null).filter(e=>!e.predicate.equals(x)),r,f=null,p=null,m=null;for(let e=0;e<n.length&&!s;e++)r=n[e],r.graph.equals(u)?c?s=i(d,`has non-list arcs out`):r.predicate.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#first`?f?s=i(d,`has multiple rdf:first arcs`):o.push(f=r):r.predicate.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#rest`?p?s=i(d,`has multiple rdf:rest arcs`):o.push(p=r):t.length?s=i(d,`can't be subject and object`):(c=r,l=`subject`):s=i(d,`not confined to single graph`);for(let e=0;e<t.length&&!s;++e)r=t[e],c?s=i(d,`can't have coreferences`):r.predicate.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#rest`?m?s=i(d,`has incoming rdf:rest arcs`):m=r:(c=r,l=`object`);f?a.unshift(f.object):s=i(d,`has no list head`),d=m&&m.subject}s?t=!1:c&&(r[c[l].value]=a)}),t&&e.removeQuads(o),r}var P={},F={};function I(e){let t=new Set;for(let n of e.getQuads(null,S,null,b))n.subject.termType===`NamedNode`&&t.add(n.subject.value);if(t.size===1)return t.values().next().value}function L(t,n){let r=e.namedNode(n);for(let e of t.getObjects(r,S,b))if(e.termType===`NamedNode`&&t.getQuads(e,x,w,null).length>0)return e}async function Ae(e){let t={store:new r,importedUrls:[],atts:e},n=[];if(e.shapes?n.push(R(B(e.shapes),t,y)):e.shapesUrl&&n.push(R(z(e.shapesUrl,t.atts.proxy),t,y)),e.values?n.push(R(B(e.values),t,b)):e.valuesUrl&&n.push(R(z(e.valuesUrl,t.atts.proxy),t,b)),await Promise.all(n),e.classInstanceProvider)try{let n=De(t.store),r=await e.classInstanceProvider(n);r&&await R(B(r),t,y)}catch(e){console.error(`failed loading class instances`,e)}if(e.valuesSubject||=I(t.store)||null,e.valuesSubject&&t.store.countQuads(null,null,null,y)===0){let n=[...t.store.getObjects(e.valuesSubject,x,b),...t.store.getObjects(e.valuesSubject,S,b)],r=[];for(let e of n){let n=je(e.value);!n&&e.value.startsWith(`urn:`)&&t.atts.proxy&&(n=e.value),n&&t.importedUrls.indexOf(n)<0&&(t.importedUrls.push(n),r.push(R(z(n,t.atts.proxy),t,y)))}try{await Promise.allSettled(r)}catch(e){console.warn(e)}}return t.store}async function R(t,n,r){let i=await t,a=[];for(let t of i){let i=r;if(n.atts.valuesSubject&&b.equals(r)&&t.graph.id&&t.graph.id!==n.atts.valuesSubject&&(i=t.graph),n.store.add(e.quad(t.subject,t.predicate,t.object,i)),n.atts.loadOwlImports&&C.equals(t.predicate)){let r=je(t.object.value);r&&n.importedUrls.indexOf(r)<0&&(n.importedUrls.push(r),a.push(R(z(r,n.atts.proxy),n,e.namedNode(r))))}}await Promise.allSettled(a)}async function z(e,t){return e in P||(P[e]=(async()=>{let n=e;t&&(n=t+encodeURIComponent(e));let r=await fetch(n,{headers:{Accept:`text/turtle, application/trig, application/n-triples, application/n-quads, text/n3, application/ld+json`}});return r.ok?B(await r.text()):(console.warn(`failed fetching RDF from`,e),[])})()),P[e]}async function B(t){if(!t.trim())return[];let n=Me(t);if(n===`json`)try{t=await s.toRDF(JSON.parse(t),{format:`application/n-quads`})}catch(e){console.error(e)}let r=[];return await new Promise((a,s)=>{let c=n===`xml`?new o:new i;c.on(`data`,t=>{r.push(e.quad(t.subject,t.predicate,t.object,t.graph))}).on(`error`,e=>{s(e)}).on(`prefix`,(e,t)=>{e&&(F[e]=t)}).on(`end`,()=>{a(null)}),c.write(t),c.end()}),r}function je(e){if(j(e))return e;let t=e.split(`:`);if(t.length===2){let n=F[t[0]];if(n&&(e=e.replace(`${t[0]}:`,n),j(e)))return e}return null}function Me(e){return/^\s*[\\[{]/.test(e)?`json`:/^\s*<\?xml/.test(e)?`xml`:`ttl`}var Ne={[`${h}name`]:(e,t)=>{let n=t;e.name=M(e.config.languages,e.name,n)},[`${h}description`]:(e,t)=>{let n=t;e.description=M(e.config.languages,e.description,n)},[`${h}path`]:(e,t)=>{e.path=t.value},[`${h}group`]:(e,t)=>{e.group=t.id},[`${h}datatype`]:(e,t)=>{e.datatype=t},[`${h}nodeKind`]:(e,t)=>{e.nodeKind=t},[`${h}minCount`]:(e,t)=>{e.minCount=parseInt(t.value)},[`${h}maxCount`]:(e,t)=>{e.maxCount=parseInt(t.value)},[`${h}minLength`]:(e,t)=>{e.minLength=parseInt(t.value)},[`${h}maxLength`]:(e,t)=>{e.maxLength=parseInt(t.value)},[`${h}minInclusive`]:(e,t)=>{e.minInclusive=parseInt(t.value)},[`${h}maxInclusive`]:(e,t)=>{e.maxInclusive=parseInt(t.value)},[`${h}minExclusive`]:(e,t)=>{e.minExclusive=parseInt(t.value)},[`${h}maxExclusive`]:(e,t)=>{e.maxExclusive=parseInt(t.value)},[`${h}pattern`]:(e,t)=>{e.pattern=t.value},[`${h}order`]:(e,t)=>{e.order=parseInt(t.value)},[`${te}singleLine`]:(e,t)=>{e.singleLine=t.value===`true`},[`${te}readonly`]:(e,t)=>{e.readonly=t.value===`true`},[`${ie}styleClass`]:(e,t)=>{e.cssClass=t.value},[`${h}in`]:(e,t)=>{e.in=t.value},[`${h}languageIn`]:(e,t)=>{e.languageIn=e.config.lists[t.value],e.datatype=oe},[`${h}defaultValue`]:(e,t)=>{e.defaultValue=t},[`${h}hasValue`]:(e,t)=>{e.hasValue=t},[`${h}node`]:(e,t)=>{e.node=t,e.nodeShapes.add(e.config.getNodeTemplate(t,e))},[`${h}and`]:(e,t)=>{e.and=t.value;let n=e.config.lists[e.and];if(n?.length)for(let t of n)e.nodeShapes.add(e.config.getNodeTemplate(t,e))},[`${h}qualifiedValueShape`]:(e,t)=>{let n=e.config.getNodeTemplate(t,e);e.qualifiedValueShape=n,e.nodeShapes.add(n)},[`${h}qualifiedMinCount`]:(e,t)=>{e.qualifiedMinCount=parseInt(t.value)},[`${h}qualifiedMaxCount`]:(e,t)=>{e.qualifiedMaxCount=parseInt(t.value)},[C.id]:(e,t)=>{e.owlImports.add(t)},[E.id]:(e,t)=>{e.class=t;let n=e.config.store.getSubjects(D,t,null);n.length>0&&(e.node=n[0])},[`${h}or`]:(e,t)=>{let n=e.config.lists[t.value];n?.length?e.or=n:console.error(`list for sh:or not found:`,t.value,`existing lists:`,e.config.lists)},[`${h}xone`]:(e,t)=>{let n=e.config.lists[t.value];n?.length?e.xone=n:console.error(`list for sh:xone not found:`,t.value,`existing lists:`,e.config.lists)}},V=class{constructor(e,t){this.label=``,this.nodeShapes=new Set,this.owlImports=new Set,this.id=e,this.parent=t,this.config=t.config,this.config.registerPropertyTemplate(this),U(this,this.config.store.getQuads(e,null,null,null))}};function H(e){return Math.max(e.minCount??0,e.qualifiedMinCount??0)}function Pe(e){return Math.min(e.maxCount??2**53-1,e.qualifiedMaxCount??2**53-1)}function Fe(e){let t=Object.assign({},e);return t.nodeShapes=new Set(e.nodeShapes),t.owlImports=new Set(e.owlImports),e.languageIn&&(t.languageIn=[...e.languageIn]),e.or&&(t.or=[...e.or]),e.xone&&(t.xone=[...e.xone]),t}function U(e,t){for(let n of t)Ne[n.predicate.id]?.call(e,e,n.object);return e.label=e.name?.value||k(t,e.config.languages),e.label||=e.path?A(e.path,F):`unknown`,e}function Ie(e,t){let n=t,r=e;for(let e in t)if(e!==`parent`&&e!==`config`&&e!==`id`){let t=n[e];if(t!==void 0&&t!==``)if(Array.isArray(t)){let n=r[e];Array.isArray(n)?n.push(...t):r[e]=[...t]}else if(t instanceof Set&&t.size){let n=r[e];r[e]=new Set([...n instanceof Set?n:[],...t])}else r[e]=t}}function Le(e,t,n){let r=document.createElement(`div`);r.classList.add(`shacl-or-constraint`),r.setAttribute(`part`,`constraint`);let i=[];if(t instanceof X){let a=[],o=!1;e.length&&(o=n.store.countQuads(e[0],T,null,null)>0);for(let r=0;r<e.length;r++)if(o){let o=n.store.getObjects(e[r],T,null),s=[],c=``;for(let e of o){let r=new K(n.getPropertyTemplate(e,t.template),t);s.push(r),c+=(c.length>0?` / `:``)+r.template.label}a.push(s),i.push({label:c,value:r.toString()})}else{let o=e[r],s=new K(n.getPropertyTemplate(o,t.template),t);a.push([s]),i.push({label:s.template.label,value:r.toString()})}let s=n.theme.createListEditor(`Please choose`,null,!1,i);s.setAttribute(`part`,`constraint-editor`);let c=s.querySelector(`.editor`);c.onchange=async()=>{if(c.value){let e=a[parseInt(c.value)],n;if(e.length){for(let n of e)await n.bindValues(t.nodeId,!1);n=e[0],r.replaceWith(e[0]),n.updateControls()}for(let t=1;t<e.length;t++)n.after(e[t]),n=e[t],n.updateControls()}},r.appendChild(s)}else{let a=[];for(let t=0;t<e.length;t++){let r=n.store.getQuads(e[t],null,null,null);if(r.length){a.push(r);let e=k(r,n.languages);for(let t of r)t.predicate.equals(de)&&(e=k(n.store.getQuads(t.object,null,null,null),n.languages));i.push({label:e||A(r[0].predicate.value,F)+` = `+A(r[0].object.value,F),value:t.toString()})}}let o=n.theme.createListEditor(t.template.label+`?`,null,!1,i,t.template);o.setAttribute(`part`,`constraint-editor`);let s=o.querySelector(`.editor`);s.onchange=async()=>{if(s.value){let e=await q(U(Fe(t.template),a[parseInt(s.value)]),void 0,!0),n=e.querySelector(`:scope > label`);n&&n.classList.add(`persistent`),r.replaceWith(e)}},r.appendChild(o)}return r}function Re(e,t,n){if(t.termType===`Literal`){let r=t.datatype;for(let t of e){let e=n.store.getQuads(t,null,null,null);for(let t of e)if(t.predicate.value===`http://www.w3.org/ns/shacl#datatype`&&t.object.equals(r))return e}}else{let r=n.store.getObjects(t,x,null);for(let t of e){let e=n.store.getQuads(t,null,null,null);for(let t of e)if(r.length>0){if(t.predicate.value===`http://www.w3.org/ns/shacl#node`){for(let i of r)if(n.store.getQuads(t.object,D,i,null).length>0)return e}if(t.predicate.equals(E)){for(let n of r)if(t.object.equals(n))return e}}else if(t.predicate.equals(fe)&&t.object.equals(ue))return e}}return console.error(`couldn't resolve sh:or/sh:xone on property for value`,t),[]}function ze(e,t,n){for(let r of e){let e=!1,i=n.store.getObjects(r,T,null);for(let r of i){let i=n.store.getObjects(r,`${h}path`,null);for(let r of i)if(e=n.store.countQuads(t,r,null,null)>0,e)break}if(e)return i}return console.error(`couldn't resolve sh:or/sh:xone on node for value`,t),[]}var Be=`:host {
2
2
  --shacl-font-family: inherit;
3
3
  --shacl-font-size: 14px;
4
4
  --shacl-text-color: #333;
@@ -79,19 +79,19 @@ h3 { margin-top: 0; }
79
79
  .link-option { padding: 10px; }
80
80
  .link-option:hover { background-color: #F5F5F5; cursor: pointer; }
81
81
  rokit-dialog.link-chooser::part(dialog) { min-height: min(434px, 90vh); width: min(90vw, 600px); }
82
- `,Fe=class{constructor(e){this.dense=!0;let t=Pe;e&&(t+=`
83
- `+e),this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(t)}apply(e){}setDense(e){this.dense=e}createViewer(e,r,i){let a=document.createElement(`div`),o=document.createElement(`label`);o.textContent=`${e}:`,i.description&&o.setAttribute(`title`,i.description.value),a.appendChild(o);let s=r.value,c=null;if(r instanceof n){let e=i.config.store.getQuads(s,null,null,null);if(e.length){let t=A(e,i.config.languages);t&&(s=t)}}else r instanceof t&&(r.language?(c=document.createElement(`span`),c.classList.add(`lang`),c.innerText=`@${r.language}`):r.datatype.value===`http://www.w3.org/2001/XMLSchema#date`?s=new Date(Date.parse(r.value)).toDateString():r.datatype.value===`http://www.w3.org/2001/XMLSchema#dateTime`&&(s=new Date(Date.parse(r.value)).toLocaleString()));let l;return M(r.value)?(l=document.createElement(`a`),l.setAttribute(`href`,r.value)):l=document.createElement(`div`),l.classList.add(`d-flex`),l.innerText=s,c&&l.appendChild(c),a.appendChild(l),a}};function Ie(e,n,r){if(r){let r=V(e)>0;if(e.class&&!e.hasValue)return e.config.theme.createListEditor(e.label,n,r,ve(e.class,e),e);if(e.in){let t=e.config.lists[e.in];if(t?.length){let i=ge(t,e.config.store,e.config.languages);return e.config.theme.createListEditor(e.label,n,r,i,e)}else console.error(`list not found:`,e.in,`existing lists:`,e.config.lists)}if(e.datatype?.equals(ae)||e.languageIn?.length||e.datatype===void 0&&n instanceof t&&n.language)return e.config.theme.createLangStringEditor(e.label,n,r,e);switch(e.datatype?.value.replace(g,``)){case`integer`:case`float`:case`double`:case`decimal`:return e.config.theme.createNumberEditor(e.label,n,r,e);case`date`:case`dateTime`:return e.config.theme.createDateEditor(e.label,n,r,e);case`boolean`:return e.config.theme.createBooleanEditor(e.label,n,r,e);case`base64Binary`:return e.config.theme.createFileEditor(e.label,n,r,e)}return e.config.theme.createTextEditor(e.label,n,r,e)}else return n?e.config.theme.createViewer(e.label,n,e):document.createElement(`div`)}function Le(e,t,n){if(t===`application/ld+json`)return Re(e);{let r=new a({format:t,prefixes:n});r.addQuads(e);let i=``;return r.end((e,t)=>{e&&console.error(e),i=t}),i}}function Re(e){let n=[];for(let r of e){let e={"@id":r.subject.id};if(r.predicate===S)e[`@type`]=r.object.id;else{let n=r.object.value;r.object instanceof t?r.object.language?n={"@language":r.object.language,"@value":r.object.value}:r.object.datatype&&r.object.datatype.value!==`http://www.w3.org/2001/XMLSchema##string`&&(n={"@type":r.object.datatype.value,"@value":r.object.value}):n={"@id":r.object.id},e[r.predicate.value]=n}n.push(e)}return JSON.stringify(n)}function ze(t){let r=t.shaclDatatype,i=t.dataset.value||t.value;if(t.type===`checkbox`||t.getAttribute(`type`)===`checkbox`){if(t.checked||parseInt(t.dataset.minCount||`0`)>0)return e.literal(t.checked?`true`:`false`,r)}else if(i){if(i.startsWith(`<`)&&i.endsWith(`>`)&&i.indexOf(`:`)>-1)return e.namedNode(i.substring(1,i.length-1));if(t.dataset.class||t.dataset.nodeKind===`http://www.w3.org/ns/shacl#IRI`)return e.namedNode(i);if(t.dataset.link)return JSON.parse(t.dataset.link);if(t.dataset.lang?r=t.dataset.lang:t.type===`number`?i=parseFloat(i):t.type===`file`&&t.binaryData?i=t.binaryData:t.type===`datetime-local`&&(i=new Date(i).toISOString().slice(0,19)),(!r||r instanceof n&&fe.equals(r))&&typeof i==`string`){let t=i.split(`^^`);t.length===2&&t[0].startsWith(`"`)&&t[0].endsWith(`"`)&&t[1].split(`:`).length===2?(i=t[0].substring(1,t[0].length-1),r=e.namedNode(t[1])):(t=i.split(`@`),t.length===2&&t[0].startsWith(`"`)&&t[0].endsWith(`"`)?(i=t[0].substring(1,t[0].length-1),r=t[1]):i.startsWith(`"`)&&i.endsWith(`"`)&&(i=i.substring(1,i.length-1)))}return e.literal(i,r)}}var U={};function Be(e){e.predicate===void 0&&e.datatype===void 0?console.warn(`not registering plugin because it does neither define "predicate" nor "datatype"`,e):U[`${e.predicate}^${e.datatype}`]=e}function Ve(){return Object.entries(U).map(e=>e[1])}function He(e,t){let n=U[`${e}^${t}`];return n||(n=U[`${e}^undefined`],n)?n:U[`undefined^${t}`]}var Ue=class{constructor(e,t){this.predicate=e.predicate,this.datatype=e.datatype,t&&(this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(t))}createViewer(e,t){return e.config.theme.createViewer(e.label,t,e)}};async function We(e){if(e.template.nodeShapes.size===0)return;let t=e.template.config.resourceLinkProvider;if((!t||t&&!t.lazyLoad)&&(await Je(e.template),Ke(e).length===0))return;let n=e.template.config.theme.createButton(e.template.label,!1);n.title=`Link existing `+e.template.label,n.classList.add(`link-button`),n.setAttribute(`text`,``);let r=n.getAttribute(`part`);return n.setAttribute(`part`,`${r?r+` `:``}link-button`),n.addEventListener(`click`,async()=>{t?.lazyLoad&&(n.classList.add(`loading`),await Je(e.template),n.classList.remove(`loading`));let r=Ke(e);if(r.length===0)n.innerText=`No linkable resources found`,n.setAttribute(`disabled`,``),setTimeout(()=>n.remove(),2e3);else{let t=e.template.config.form.querySelector(`#dialog`);t||(t=new u,t.classList.add(`link-chooser`),t.closable=!0,e.template.config.form.appendChild(t)),t.title=`Link existing `+e.template.label,Ge(t,e,r),t.open=!0}}),n}function Ge(e,t,n){let r=document.createElement(`div`);for(let i of n){let n=document.createElement(`div`);n.classList.add(`link-option`),n.title=`Link this resource`,n.innerText=i.label||i.value,n.addEventListener(`click`,()=>{qe(i.value,t),e.open=!1}),r.appendChild(n)}e.replaceChildren(r)}function Ke(t){let n=[];if(t.template.config.resourceLinkProvider){for(let r of t.template.nodeShapes)if(t.template.config.providedConformingResourceIds[r.id.value])for(let i of t.template.config.providedConformingResourceIds[r.id.value])t.querySelector(`:scope > .property-instance > shacl-node[data-node-id='${i}'], :scope > .collapsible > .property-instance > shacl-node[data-node-id='${i}']`)===null&&n.push({value:i,label:A(t.template.config.store.getQuads(e.namedNode(i),null,null,null),t.template.config.languages),children:[]})}return n}async function qe(t,n){let r=e.namedNode(t);if(Ze(r,n.template.config.store)){if(n.template.config.providedResources[t]?.length>0){let e={store:n.template.config.store,importedUrls:[],atts:{loadOwlImports:!1}};await L(z(n.template.config.providedResources[t]),e,b),n.template.config.providedResources[t]=``}let e=await K(n.template,r,!0,!0);n.container.insertBefore(e,n.querySelector(`:scope > .add-button-wrapper`)),await n.updateControls()}}async function Je(e){let t=e.config.resourceLinkProvider;if(!t)return;let n=new Set(Array.from(e.nodeShapes).map(e=>e.id.value));if(n.size===0)return;let r=xe(Object.keys(e.config.providedConformingResourceIds),n);if(r.length!==0)try{let n=await t.listConformingResources(r,e);if(n){for(let t of Object.keys(n)){let r=new Set(n[t]);e.config.providedConformingResourceIds[t]=r,await Ye(r,!1,e.config)}for(let t of r)e.config.providedConformingResourceIds[t]||(e.config.providedConformingResourceIds[t]=new Set)}}catch(e){console.error(`failed loading conforming resources`,e)}}async function Ye(e,t,n){if(n.resourceLinkProvider&&e.size>0){let r=[];for(let t of e)n.providedResources[t]||r.push(t);if(r.length===0)return[];try{let e=await n.resourceLinkProvider.loadResources(r);if(e){let r={store:n.store,importedUrls:[],atts:{loadOwlImports:!1}};for(let i of e)n.providedResources[i.resourceId]=i.resourceRDF,t&&await L(z(i.resourceRDF),r,b);return e}for(let e of r)n.providedResources[e]||(n.providedResources[e]=``)}catch(e){console.error(`failed loading resources`,e)}}return[]}async function Xe(e){let t=new Set;for(let n of e.store.getQuads(null,null,null,x))Ze(n.object,e.store)&&t.add(n.object.value);await Ye(t,!0,e)}function Ze(e,t){return e.termType===`NamedNode`&&t.countQuads(e,null,null,null)===0}var W=`:scope > .add-button-wrapper, :scope > .collapsible > .add-button-wrapper`,Qe=`:scope > .property-instance, :scope > .shacl-or-constraint, :scope > shacl-node, :scope > .collapsible > .property-instance`,G=class extends HTMLElement{constructor(e,t){if(super(),this.template=e,this.parent=t,this.container=this,this.setAttribute(`part`,`property`),this.template.nodeShapes.size&&this.template.config.attributes.collapse!==null&&(this.template.maxCount===void 0||this.template.maxCount>1)){let t=new l;t.classList.add(`collapsible`,`shacl-group`),t.open=e.config.attributes.collapse===`open`,t.label=this.template.label,t.setAttribute(`part`,`collapsible`),this.container=t,this.appendChild(this.container)}this.template.order!==void 0&&(this.style.order=`${this.template.order}`),this.template.cssClass&&this.classList.add(this.template.cssClass),e.config.editMode&&!t.linked&&this.addEventListener(`change`,async()=>{await this.updateControls()})}async bindValues(e,t){if(this.template.path){let n=!1;if(e){let r=this.template.config.store.getQuads(e,this.template.path,null,this.parent.linked?null:x);t&&(r=await this.filterValidValues(r,e));for(let e of r)this.parent.linked||this.template.config.store.delete(e),await this.addPropertyInstance(e.object,!x.equals(e.graph)||this.template.config.providedResources[e.object.value]!==void 0,this.template.config.providedResources[e.object.value]!==void 0),this.template.hasValue&&e.object.equals(this.template.hasValue)&&(n=!0)}this.template.config.editMode&&this.template.hasValue&&!n&&!this.parent.linked&&await this.addPropertyInstance(this.template.hasValue)}}async addPropertyInstance(e,t,n=!1){let r;if(this.template.or?.length||this.template.xone?.length){let t=this.template.or?.length?this.template.or:this.template.xone,n=!1;if(e){let i=Me(t,e,this.template.config);i.length&&(r=await K(H(ke(this.template),i),e,!this.parent.linked,this.parent.linked,this.parent),n=!0)}!n&&this.template.config.editMode&&(r=je(t,this,this.template.config),$e(r,``,this.template.config.theme.dense,this.template.config.hierarchyColorsStyleSheet!==void 0))}else r=await K(this.template,e,n,t||this.parent.linked,this.parent);return r&&this.container.insertBefore(r,this.querySelector(W)),r}async updateControls(){this.template.config.editMode&&!this.parent.linked&&!this.querySelector(W)&&this.container.appendChild(await this.createAddControls());let e=V(this.template),t=this.template.nodeShapes.size===0,n=this.querySelector(`:scope > .add-button-wrapper > .link-button, :scope > .collapsible > .add-button-wrapper > .link-button`)===null,r=t||!this.hasRecursiveNodeShape(),i=this.instanceCount();i===0&&r&&(t||n&&e>0)&&(await this.addPropertyInstance(),i=1),t||this.querySelector(W)?.classList.toggle(`required`,i<e);let a;a=e>0?i>e:!t||i>1;let o=i<Oe(this.template);this.classList.toggle(`may-remove`,a),this.classList.toggle(`may-add`,o)}instanceCount(){return this.querySelectorAll(Qe).length}hasRecursiveNodeShape(){let e=new Set;this.parent.ancestorShapeIds.forEach(t=>e.add(t)),e.add(this.parent.template.id.value);for(let t of this.template.nodeShapes)if(e.has(t.id.value))return!0;return!1}toRDF(t,n){let r=e.namedNode(this.template.path);for(let e of this.querySelectorAll(`:scope > .property-instance, :scope > .collapsible > .property-instance`))if(e.firstChild instanceof q){let i=e.firstChild.toRDF(t);t.addQuad(n,r,i,this.template.config.valuesGraphId)}else if(this.template.config.editMode)for(let i of e.querySelectorAll(`:scope > .editor`)){let e=ze(i);e&&t.addQuad(n,r,e,this.template.config.valuesGraphId)}else{let i=ze(e);i&&t.addQuad(n,r,i,this.template.config.valuesGraphId)}}async filterValidValues(e,t){let n=this.template.id,r=[t];if(this.template.qualifiedValueShape){n=this.template.qualifiedValueShape.id,r=[];for(let t of e)r.push(t.object)}let i=await this.template.config.validator.validate({dataset:this.template.config.store,terms:r},[{terms:[n]}]),a=new Set;for(let e of i.results){let t=this.template.qualifiedValueShape?e.focusNode:e.value;t?.ptrs?.length&&a.add(t.ptrs[0]._term.id)}return e.filter(e=>!a.has(e.object.id))}async createAddControls(){let e=document.createElement(`div`);e.classList.add(`add-button-wrapper`),e.setAttribute(`part`,`add-controls`);let t=await We(this);t&&e.appendChild(t);let n=this.template.config.theme.createButton(this.template.label,!1);n.title=`Add `+this.template.label,n.classList.add(`add-button`),n.setAttribute(`text`,``);let r=n.getAttribute(`part`);return n.setAttribute(`part`,`${r?r+` `:``}add-button`),n.addEventListener(`click`,async()=>{let e=await this.addPropertyInstance();e&&(e.classList.add(`fadeIn`),await this.updateControls(),setTimeout(()=>{he(e),e.classList.remove(`fadeIn`)},200))}),e.appendChild(n),e}};async function K(e,n,r=!1,i=!1,a){let o;if(e.nodeShapes.size){o=document.createElement(`div`),o.classList.add(`property-instance`),o.setAttribute(`part`,`property-instance`);let t=new Set(a?.ancestorShapeIds??[]);a&&t.add(a.template.id.value);for(let r of e.nodeShapes){let a=new q(r,n,e.nodeKind,e.label,i,t);o.appendChild(a),await a.ready}}else{let t=He(e.path,e.datatype?.value);o=t?e.config.editMode&&!i?t.createEditor(e,n):t.createViewer(e,n):Ie(e,n||null,e.config.editMode&&!i),o.childNodes.length>0&&(o.classList.add(`property-instance`),o.setAttribute(`part`,`property-instance`)),i&&o.classList.add(`linked`)}return e.config.editMode&&(!i||r)?$e(o,e.label,e.config.theme.dense,e.config.hierarchyColorsStyleSheet!==void 0,r):e.config.hierarchyColorsStyleSheet!==void 0&&o.appendChild(et(!0)),n&&!e.config.editMode&&(n instanceof t?(o.dataset.value=n.value,n.language.length>0?o.dataset.lang=n.language:o.shaclDatatype=n.datatype):o.dataset.value=`<`+n.value+`>`),o.dataset.path=e.path,o}function $e(e,t,n,r,i=!1){let a=et(r),o=new c;o.classList.add(`remove-button`,`clear`),o.title=`Remove `+t,o.dense=n,o.icon=!0;let s=o.getAttribute(`part`);o.setAttribute(`part`,`${s?s+` `:``}remove-button`),o.addEventListener(`click`,()=>{e.classList.remove(`fadeIn`),e.classList.add(`fadeOut`),setTimeout(()=>{let t=e.parentElement;e.remove(),t?.dispatchEvent(new Event(`change`,{bubbles:!0,cancelable:!0}))},200)}),i&&o.classList.add(`persistent`),a.appendChild(o),e.appendChild(a)}function et(e){let t=document.createElement(`div`);return t.className=`remove-button-wrapper`,t.setAttribute(`part`,`remove-controls`),e&&t.classList.add(`colorize`),t}window.customElements.define(`shacl-property`,G);function tt(e,t){let n=e,r=t.store.getQuads(e,null,null,null),i=k(r,`label`,v,t.languages);i&&(n=i);let a;if(t.attributes.collapse!==null)a=new l,a.classList.add(`collapsible`),a.open=t.attributes.collapse===`open`,a.label=n,a.setAttribute(`part`,`group collapsible`);else{a=document.createElement(`div`);let e=document.createElement(`h1`);e.innerText=n,e.setAttribute(`part`,`group-title`),a.appendChild(e),a.setAttribute(`part`,`group`)}a.dataset.subject=e,a.classList.add(`shacl-group`);let o=k(r,`order`);return o&&(a.style.order=o),a}var q=class t extends HTMLElement{constructor(n,r,i,a,o,s=new Set){super(),this.template=n,this.linked=o??!1,this.ancestorShapeIds=s,this.setAttribute(`part`,`node`);let c=r;c||=(!i&&n.nodeKind&&(i=n.nodeKind),i===void 0&&n.config.attributes.valuesNamespace||i?.value===`http://www.w3.org/ns/shacl#IRI`?e.namedNode(n.config.attributes.valuesNamespace+m()):e.blankNode(m())),this.nodeId=c;let l=JSON.stringify([n.id,r]);if(r&&n.config.renderedNodes.has(l)){a||=`Link`;let e=document.createElement(`label`);e.innerText=a,e.classList.add(`linked`),this.appendChild(e);let t=this.getAttribute(`part`);this.setAttribute(`part`,`${t?t+` `:``}linked-node`);let n=document.createElement(`a`),i=r.termType===`BlankNode`?`_:`+r.value:r.value;n.innerText=i,n.classList.add(`ref-link`),n.onclick=()=>{this.template.config.form.querySelector(`shacl-node[data-node-id='${i}']`)?.scrollIntoView()},this.appendChild(n),this.style.flexDirection=`row`,this.ready=Promise.resolve()}else{r&&n.config.renderedNodes.add(l);let e=this.ancestorShapeIds,i=this.template.id.value;if(this.dataset.nodeId=this.nodeId.id,this.template.config.attributes.showNodeIds!==null){let e=document.createElement(`div`);e.innerText=`id: ${this.nodeId.id}`,e.classList.add(`node-id-display`),this.appendChild(e)}this.ready=(async()=>{let s=new Set(e);s.add(i);for(let[e,t]of Object.entries(n.properties))for(let e of t)await this.addPropertyInstance(e,r,t.length>1);for(let e of n.extendedShapes){let n=new t(e,r,void 0,void 0,o,s);this.prepend(n),await n.ready}if(n.or?.length&&await this.tryResolve(n.or,r,n.config),n.xone?.length&&await this.tryResolve(n.xone,r,n.config),a){let e=document.createElement(`h1`);e.innerText=a,e.setAttribute(`part`,`node-title`),this.prepend(e)}})()}}toRDF(t,n,r=``){if(n||=this.nodeId,!this.linked){for(let e of this.querySelectorAll(`:scope > shacl-node, :scope > .shacl-group > shacl-node, :scope > shacl-property, :scope > .shacl-group > shacl-property`))e.toRDF(t,n);this.template.targetClass&&t.addQuad(n,S,this.template.targetClass,this.template.config.valuesGraphId),r&&t.addQuad(n,e.namedNode(r),this.template.id,this.template.config.valuesGraphId)}return n}async addPropertyInstance(e,t,n){let r=null;if(e.group)if(e.config.groups.indexOf(e.group)>-1){let t=this.querySelector(`:scope > .shacl-group[data-subject='${e.group}']`);t||(t=tt(e.group,e.config),this.appendChild(t)),r=t}else console.warn(`ignoring unknown group reference`,e.group,`existing groups:`,e.config.groups);let i=new G(e,this);await i.bindValues(t,n),(e.config.editMode||i.instanceCount()>0)&&(r?r.appendChild(i):this.appendChild(i),await i.updateControls())}async tryResolve(e,t,n){let r=!1;if(t){let i=Ne(e,t,n);if(i.length){for(let e of i)await this.addPropertyInstance(n.getPropertyTemplate(e,this.template),t);r=!0}}r||this.appendChild(je(e,this,n))}};window.customElements.define(`shacl-node`,q);var nt=`
82
+ `,Ve=class{constructor(e){this.dense=!0;let t=Be;e&&(t+=`
83
+ `+e),this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(t)}apply(e){}setDense(e){this.dense=e}createViewer(e,r,i){let a=document.createElement(`div`),o=document.createElement(`label`);o.textContent=`${e}:`,i.description&&o.setAttribute(`title`,i.description.value),a.appendChild(o);let s=r.value,c=null;if(r instanceof n){let e=i.config.store.getQuads(s,null,null,null);if(e.length){let t=k(e,i.config.languages);t&&(s=t)}}else r instanceof t&&(r.language?(c=document.createElement(`span`),c.classList.add(`lang`),c.innerText=`@${r.language}`):r.datatype.value===`http://www.w3.org/2001/XMLSchema#date`?s=new Date(Date.parse(r.value)).toDateString():r.datatype.value===`http://www.w3.org/2001/XMLSchema#dateTime`&&(s=new Date(Date.parse(r.value)).toLocaleString()));let l;return j(r.value)?(l=document.createElement(`a`),l.setAttribute(`href`,r.value)):l=document.createElement(`div`),l.classList.add(`d-flex`),l.innerText=s,c&&l.appendChild(c),a.appendChild(l),a}};function He(e,n,r){if(r){let r=H(e)>0;if(e.class&&!e.hasValue)return e.config.theme.createListEditor(e.label,n,r,ye(e.class,e),e);if(e.in){let t=e.config.lists[e.in];if(t?.length){let i=_e(t,e.config.store,e.config.languages);return e.config.theme.createListEditor(e.label,n,r,i,e)}else console.error(`list not found:`,e.in,`existing lists:`,e.config.lists)}if(e.datatype?.equals(oe)||e.languageIn?.length||e.datatype===void 0&&n instanceof t&&n.language)return e.config.theme.createLangStringEditor(e.label,n,r,e);switch(e.datatype?.value.replace(g,``)){case`integer`:case`float`:case`double`:case`decimal`:return e.config.theme.createNumberEditor(e.label,n,r,e);case`date`:case`dateTime`:return e.config.theme.createDateEditor(e.label,n,r,e);case`boolean`:return e.config.theme.createBooleanEditor(e.label,n,r,e);case`base64Binary`:return e.config.theme.createFileEditor(e.label,n,r,e)}return e.config.theme.createTextEditor(e.label,n,r,e)}else return n?e.config.theme.createViewer(e.label,n,e):document.createElement(`div`)}function Ue(e,t,n){if(t===`application/ld+json`)return We(e);{let r=new a({format:t,prefixes:n});r.addQuads(e);let i=``;return r.end((e,t)=>{e&&console.error(e),i=t}),i}}function We(e){let n=[];for(let r of e){let e={"@id":r.subject.id};if(r.predicate===x)e[`@type`]=r.object.id;else{let n=r.object.value;r.object instanceof t?r.object.language?n={"@language":r.object.language,"@value":r.object.value}:r.object.datatype&&r.object.datatype.value!==`http://www.w3.org/2001/XMLSchema##string`&&(n={"@type":r.object.datatype.value,"@value":r.object.value}):n={"@id":r.object.id},e[r.predicate.value]=n}n.push(e)}return JSON.stringify(n)}function Ge(t){let r=t.shaclDatatype,i=t.dataset.value||t.value;if((t.type===`file`||t.getAttribute(`type`)===`file`)&&t.binaryData)i=t.binaryData;else if((t.type===`checkbox`||t.getAttribute(`type`)===`checkbox`)&&(t.checked||parseInt(t.dataset.minCount||`0`)>0))return e.literal(t.checked?`true`:`false`,r);if(i){if(i.startsWith(`<`)&&i.endsWith(`>`)&&i.indexOf(`:`)>-1)return e.namedNode(i.substring(1,i.length-1));if(t.dataset.class||t.dataset.nodeKind===`http://www.w3.org/ns/shacl#IRI`)return e.namedNode(i);if(t.dataset.link)return JSON.parse(t.dataset.link);if(t.dataset.lang?r=t.dataset.lang:t.type===`number`?i=parseFloat(i):t.type===`datetime-local`?i=Ee(i,t.dataset.xsdTemporalSuffix):t.type===`date`&&r instanceof n&&r.value===`http://www.w3.org/2001/XMLSchema#date`&&(i=Te(i,t.dataset.xsdTemporalSuffix)),(!r||r instanceof n&&pe.equals(r))&&typeof i==`string`){let t=i.split(`^^`);t.length===2&&t[0].startsWith(`"`)&&t[0].endsWith(`"`)&&t[1].split(`:`).length===2?(i=t[0].substring(1,t[0].length-1),r=e.namedNode(t[1])):(t=i.split(`@`),t.length===2&&t[0].startsWith(`"`)&&t[0].endsWith(`"`)?(i=t[0].substring(1,t[0].length-1),r=t[1]):i.startsWith(`"`)&&i.endsWith(`"`)&&(i=i.substring(1,i.length-1)))}return e.literal(i,r)}}var W={};function Ke(e){e.predicate===void 0&&e.datatype===void 0?console.warn(`not registering plugin because it does neither define "predicate" nor "datatype"`,e):W[`${e.predicate}^${e.datatype}`]=e}function qe(){return Object.entries(W).map(e=>e[1])}function Je(e,t){let n=W[`${e}^${t}`];return n||(n=W[`${e}^undefined`],n)?n:W[`undefined^${t}`]}var Ye=class{constructor(e,t){this.predicate=e.predicate,this.datatype=e.datatype,t&&(this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(t))}createViewer(e,t){return e.config.theme.createViewer(e.label,t,e)}};async function Xe(e){if(e.template.nodeShapes.size===0)return;let t=e.template.config.resourceLinkProvider;if((!t||t&&!t.lazyLoad)&&(await et(e.template),Qe(e).length===0))return;let n=e.template.config.theme.createButton(e.template.label,!1);n.title=`Link existing `+e.template.label,n.classList.add(`link-button`),n.setAttribute(`text`,``);let r=n.getAttribute(`part`);return n.setAttribute(`part`,`${r?r+` `:``}link-button`),n.addEventListener(`click`,async()=>{t?.lazyLoad&&(n.classList.add(`loading`),await et(e.template),n.classList.remove(`loading`));let r=Qe(e);if(r.length===0)n.innerText=`No linkable resources found`,n.setAttribute(`disabled`,``),setTimeout(()=>n.remove(),2e3);else{let t=e.template.config.form.querySelector(`#dialog`);t||(t=new u,t.classList.add(`link-chooser`),t.closable=!0,e.template.config.form.appendChild(t)),t.title=`Link existing `+e.template.label,Ze(t,e,r),t.open=!0}}),n}function Ze(e,t,n){let r=document.createElement(`div`);for(let i of n){let n=document.createElement(`div`);n.classList.add(`link-option`),n.title=`Link this resource`,n.innerText=i.label||i.value,n.addEventListener(`click`,()=>{$e(i.value,t),e.open=!1}),r.appendChild(n)}e.replaceChildren(r)}function Qe(t){let n=[];if(t.template.config.resourceLinkProvider){for(let r of t.template.nodeShapes)if(t.template.config.providedConformingResourceIds[r.id.value])for(let i of t.template.config.providedConformingResourceIds[r.id.value])t.querySelector(`:scope > .property-instance > shacl-node[data-node-id='${i}'], :scope > .collapsible > .property-instance > shacl-node[data-node-id='${i}']`)===null&&n.push({value:i,label:k(t.template.config.store.getQuads(e.namedNode(i),null,null,null),t.template.config.languages),children:[]})}return n}async function $e(t,n){let r=e.namedNode(t);if(rt(r,n.template.config.store)){if(n.template.config.providedResources[t]?.length>0){let e={store:n.template.config.store,importedUrls:[],atts:{loadOwlImports:!1}};await R(B(n.template.config.providedResources[t]),e,y),n.template.config.providedResources[t]=``}let e=await q(n.template,r,!0,!0);n.container.insertBefore(e,n.querySelector(`:scope > .add-button-wrapper`)),await n.updateControls()}}async function et(e){let t=e.config.resourceLinkProvider;if(!t)return;let n=new Set(Array.from(e.nodeShapes).map(e=>e.id.value));if(n.size===0)return;let r=Oe(Object.keys(e.config.providedConformingResourceIds),n);if(r.length!==0)try{let n=await t.listConformingResources(r,e);if(n){for(let t of Object.keys(n)){let r=new Set(n[t]);e.config.providedConformingResourceIds[t]=r,await tt(r,!1,e.config)}for(let t of r)e.config.providedConformingResourceIds[t]||(e.config.providedConformingResourceIds[t]=new Set)}}catch(e){console.error(`failed loading conforming resources`,e)}}async function tt(e,t,n){if(n.resourceLinkProvider&&e.size>0){let r=[];for(let t of e)n.providedResources[t]||r.push(t);if(r.length===0)return[];try{let e=await n.resourceLinkProvider.loadResources(r);if(e){let r={store:n.store,importedUrls:[],atts:{loadOwlImports:!1}};for(let i of e)n.providedResources[i.resourceId]=i.resourceRDF,t&&await R(B(i.resourceRDF),r,y);return e}for(let e of r)n.providedResources[e]||(n.providedResources[e]=``)}catch(e){console.error(`failed loading resources`,e)}}return[]}async function nt(e){let t=new Set;for(let n of e.store.getQuads(null,null,null,b))rt(n.object,e.store)&&t.add(n.object.value);await tt(t,!0,e)}function rt(e,t){return e.termType===`NamedNode`&&t.countQuads(e,null,null,null)===0}var G=`:scope > .add-button-wrapper, :scope > .collapsible > .add-button-wrapper`,it=`:scope > .property-instance, :scope > .shacl-or-constraint, :scope > shacl-node, :scope > .collapsible > .property-instance`,K=class extends HTMLElement{constructor(e,t){if(super(),this.template=e,this.parent=t,this.container=this,this.setAttribute(`part`,`property`),this.template.nodeShapes.size&&this.template.config.attributes.collapse!==null&&(this.template.maxCount===void 0||this.template.maxCount>1)){let t=new l;t.classList.add(`collapsible`,`shacl-group`),t.open=e.config.attributes.collapse===`open`,t.label=this.template.label,t.setAttribute(`part`,`collapsible`),this.container=t,this.appendChild(this.container)}this.template.order!==void 0&&(this.style.order=`${this.template.order}`),this.template.cssClass&&this.classList.add(this.template.cssClass),e.config.editMode&&!t.linked&&this.addEventListener(`change`,async()=>{await this.updateControls()})}async bindValues(e,t){if(this.template.path){let n=!1;if(e){let r=this.template.config.store.getQuads(e,this.template.path,null,this.parent.linked?null:b);t&&(r=await this.filterValidValues(r,e));for(let e of r)this.parent.linked||this.template.config.store.delete(e),await this.addPropertyInstance(e.object,!b.equals(e.graph)||this.template.config.providedResources[e.object.value]!==void 0,this.template.config.providedResources[e.object.value]!==void 0),this.template.hasValue&&e.object.equals(this.template.hasValue)&&(n=!0)}this.template.config.editMode&&this.template.hasValue&&!n&&!this.parent.linked&&await this.addPropertyInstance(this.template.hasValue)}}async addPropertyInstance(e,t,n=!1){let r;if(this.template.or?.length||this.template.xone?.length){let t=this.template.or?.length?this.template.or:this.template.xone,n=!1;if(e){let i=Re(t,e,this.template.config);i.length&&(r=await q(U(Fe(this.template),i),e,!this.parent.linked,this.parent.linked,this.parent),n=!0)}!n&&this.template.config.editMode&&(r=Le(t,this,this.template.config),at(r,``,this.template.config.theme.dense,this.template.config.hierarchyColorsStyleSheet!==void 0))}else r=await q(this.template,e,n,t||this.parent.linked,this.parent);return r&&this.container.insertBefore(r,this.querySelector(G)),r}async updateControls(){this.template.config.editMode&&!this.parent.linked&&!this.querySelector(G)&&this.container.appendChild(await this.createAddControls());let e=H(this.template),t=this.template.nodeShapes.size===0,n=this.querySelector(`:scope > .add-button-wrapper > .link-button, :scope > .collapsible > .add-button-wrapper > .link-button`)===null,r=t||!this.hasRecursiveNodeShape(),i=this.instanceCount();i===0&&r&&(t||n&&e>0)&&(await this.addPropertyInstance(),i=1),t||this.querySelector(G)?.classList.toggle(`required`,i<e);let a;a=e>0?i>e:!t||i>1;let o=i<Pe(this.template);this.classList.toggle(`may-remove`,a),this.classList.toggle(`may-add`,o)}instanceCount(){return this.querySelectorAll(it).length}hasRecursiveNodeShape(){let e=new Set;this.parent.ancestorShapeIds.forEach(t=>e.add(t)),e.add(this.parent.template.id.value);for(let t of this.template.nodeShapes)if(e.has(t.id.value))return!0;return!1}toRDF(t,n){let r=e.namedNode(this.template.path);for(let e of this.querySelectorAll(`:scope > .property-instance, :scope > .collapsible > .property-instance`))if(e.firstChild instanceof X){let i=e.firstChild.toRDF(t);t.addQuad(n,r,i,this.template.config.valuesGraphId)}else if(this.template.config.editMode)for(let i of e.querySelectorAll(`:scope > .editor`)){let e=Ge(i);e&&t.addQuad(n,r,e,this.template.config.valuesGraphId)}else{let i=Ge(e);i&&t.addQuad(n,r,i,this.template.config.valuesGraphId)}}async filterValidValues(e,t){let n=this.template.id,r=[t];if(this.template.qualifiedValueShape){n=this.template.qualifiedValueShape.id,r=[];for(let t of e)r.push(t.object)}let i=await this.template.config.validator.validate({dataset:this.template.config.store,terms:r},[{terms:[n]}]),a=new Set;for(let e of i.results){let t=this.template.qualifiedValueShape?e.focusNode:e.value;t?.ptrs?.length&&a.add(t.ptrs[0]._term.id)}return e.filter(e=>!a.has(e.object.id))}async createAddControls(){let e=document.createElement(`div`);e.classList.add(`add-button-wrapper`),e.setAttribute(`part`,`add-controls`);let t=await Xe(this);t&&e.appendChild(t);let n=this.template.config.theme.createButton(this.template.label,!1);n.title=`Add `+this.template.label,n.classList.add(`add-button`),n.setAttribute(`text`,``);let r=n.getAttribute(`part`);return n.setAttribute(`part`,`${r?r+` `:``}add-button`),n.addEventListener(`click`,async()=>{let e=await this.addPropertyInstance();e&&(e.classList.add(`fadeIn`),await this.updateControls(),setTimeout(()=>{ge(e),e.classList.remove(`fadeIn`)},200))}),e.appendChild(n),e}};async function q(e,n,r=!1,i=!1,a){let o;if(e.nodeShapes.size){o=document.createElement(`div`),o.classList.add(`property-instance`),o.setAttribute(`part`,`property-instance`);let t=new Set(a?.ancestorShapeIds??[]);a&&t.add(a.template.id.value);for(let r of e.nodeShapes){let a=new X(r,n,e.nodeKind,e.label,i,t);o.appendChild(a),await a.ready}}else{let t=Je(e.path,e.datatype?.value);o=t?e.config.editMode&&!i?t.createEditor(e,n):t.createViewer(e,n):He(e,n||null,e.config.editMode&&!i),o.childNodes.length>0&&(o.classList.add(`property-instance`),o.setAttribute(`part`,`property-instance`)),i&&o.classList.add(`linked`)}return e.config.editMode&&(!i||r)?at(o,e.label,e.config.theme.dense,e.config.hierarchyColorsStyleSheet!==void 0,r):e.config.hierarchyColorsStyleSheet!==void 0&&o.appendChild(ot(!0)),n&&!e.config.editMode&&(n instanceof t?(o.dataset.value=n.value,n.language.length>0?o.dataset.lang=n.language:o.shaclDatatype=n.datatype):o.dataset.value=`<`+n.value+`>`),o.dataset.path=e.path,o}function at(e,t,n,r,i=!1){let a=ot(r),o=new c;o.classList.add(`remove-button`,`clear`),o.title=`Remove `+t,o.dense=n,o.icon=!0;let s=o.getAttribute(`part`);o.setAttribute(`part`,`${s?s+` `:``}remove-button`),o.addEventListener(`click`,()=>{e.classList.remove(`fadeIn`),e.classList.add(`fadeOut`),setTimeout(()=>{let t=e.parentElement;e.remove(),t?.dispatchEvent(new Event(`change`,{bubbles:!0,cancelable:!0}))},200)}),i&&o.classList.add(`persistent`),a.appendChild(o),e.appendChild(a)}function ot(e){let t=document.createElement(`div`);return t.className=`remove-button-wrapper`,t.setAttribute(`part`,`remove-controls`),e&&t.classList.add(`colorize`),t}window.customElements.define(`shacl-property`,K);function st(e,t){let n=e,r=t.store.getQuads(e,null,null,null),i=O(r,`label`,v,t.languages);i&&(n=i);let a;if(t.attributes.collapse!==null)a=new l,a.classList.add(`collapsible`),a.open=t.attributes.collapse===`open`,a.label=n,a.setAttribute(`part`,`group collapsible`);else{a=document.createElement(`div`);let e=document.createElement(`h1`);e.innerText=n,e.setAttribute(`part`,`group-title`),a.appendChild(e),a.setAttribute(`part`,`group`)}a.dataset.subject=e,a.classList.add(`shacl-group`);let o=O(r,`order`);return o&&(a.style.order=o),a}var ct={[`${h}node`]:(e,t)=>{e.extendedShapes.add(new J(t,e.config,e))},[`${h}and`]:(e,t)=>{for(let n of e.config.lists[t.value])e.extendedShapes.add(new J(n,e.config,e))},[`${h}property`]:(e,t)=>{let n=e.config.getPropertyTemplate(t,e);if(n.path){let t=e.properties[n.path];if(t||(t=[],e.properties[n.path]=t),n.qualifiedValueShape)t.push(n);else{let r;for(let t=0;t<e.properties[n.path].length&&!r;t++)e.properties[n.path][t].qualifiedValueShape||(r=e.properties[n.path][t]);r?Ie(r,n):t.push(n)}}},[`${h}nodeKind`]:(e,t)=>{e.nodeKind=t},[`${h}targetClass`]:(e,t)=>{e.targetClass=t},[`${h}or`]:(e,t)=>{e.or=e.config.lists[t.value]},[`${h}xone`]:(e,t)=>{e.xone=e.config.lists[t.value]},[C.id]:(e,t)=>{e.owlImports.add(t)},[`${ae}title`]:(e,t)=>{let n=t;e.label=M(e.config.languages,e.label,n)},[`${v}label`]:(e,t)=>{let n=t;e.label=M(e.config.languages,e.label,n)}},J=class{constructor(e,t,n){this.extendedShapes=new Set,this.properties={},this.owlImports=new Set,this.merged=!1,this.id=e,this.config=t,this.parent=n,t.registerNodeTemplate(this),lt(this,this.config.store.getQuads(e,null,null,null))}};function lt(e,t){for(let n of t)ct[n.predicate.id]?.call(e,e,n.object);return e}function ut(e){if(!e.merged){e.merged=!0;for(let t of Object.values(e.properties))for(let n of t){let[t,r]=Y(e,n.path);if(t.length>1&&r){let e=t[t.length-1];for(let n=t.length-2;n>=0;n--){let r=t[n];delete r.parent.properties[r.path],Ie(e,r)}}}}}function Y(e,t,n=new Set,r=[],i=!1){if(!n.has(e.id.value)){n.add(e.id.value);let a=e.properties[t];if(a?.length===1){r.push(a[0]),i||=a[0].maxCount===1;for(let e of a[0].nodeShapes){let[a,o]=Y(e,t,n,r,i);i||=o}}for(let a of e.extendedShapes){let[e,o]=Y(a,t,n,r,i);i||=o}}return[r,i]}var X=class t extends HTMLElement{constructor(n,r,i,a,o,s=new Set){super(),this.template=n,this.linked=o??!1,this.ancestorShapeIds=s,this.setAttribute(`part`,`node`);let c=r;c||=(!i&&n.nodeKind&&(i=n.nodeKind),i===void 0&&n.config.attributes.valuesNamespace||i?.value===`http://www.w3.org/ns/shacl#IRI`?e.namedNode(n.config.attributes.valuesNamespace+m()):e.blankNode(m())),this.nodeId=c;let l=JSON.stringify([n.id,r]);if(r&&n.config.renderedNodes.has(l)){a||=`Link`;let e=document.createElement(`label`);e.innerText=a,e.classList.add(`linked`),this.appendChild(e);let t=this.getAttribute(`part`);this.setAttribute(`part`,`${t?t+` `:``}linked-node`);let n=document.createElement(`a`),i=r.termType===`BlankNode`?`_:`+r.value:r.value;n.innerText=i,n.classList.add(`ref-link`),n.onclick=()=>{this.template.config.form.querySelector(`shacl-node[data-node-id='${i}']`)?.scrollIntoView()},this.appendChild(n),this.style.flexDirection=`row`,this.ready=Promise.resolve()}else{r&&n.config.renderedNodes.add(l);let e=this.ancestorShapeIds,i=this.template.id.value;if(this.dataset.nodeId=this.nodeId.id,this.template.config.attributes.showNodeIds!==null){let e=document.createElement(`div`);e.innerText=`id: ${this.nodeId.id}`,e.classList.add(`node-id-display`),this.appendChild(e)}ut(n),this.ready=(async()=>{let s=new Set(e);s.add(i);for(let[e,t]of Object.entries(n.properties))for(let e of t)await this.addPropertyInstance(e,r,t.length>1);for(let e of n.extendedShapes){let n=new t(e,r,void 0,void 0,o,s);this.prepend(n),await n.ready}if(n.or?.length&&await this.tryResolve(n.or,r,n.config),n.xone?.length&&await this.tryResolve(n.xone,r,n.config),a){let e=document.createElement(`h1`);e.innerText=a,e.setAttribute(`part`,`node-title`),this.prepend(e)}})()}}toRDF(t,n,r=``){if(n||=this.nodeId,!this.linked){for(let e of this.querySelectorAll(`:scope > shacl-node, :scope > .shacl-group > shacl-node, :scope > shacl-property, :scope > .shacl-group > shacl-property`))e.toRDF(t,n);this.template.targetClass&&t.addQuad(n,x,this.template.targetClass,this.template.config.valuesGraphId),r&&t.addQuad(n,e.namedNode(r),this.template.id,this.template.config.valuesGraphId)}return n}async addPropertyInstance(e,t,n){let r=null;if(e.group)if(e.config.groups.indexOf(e.group)>-1){let t=this.querySelector(`:scope > .shacl-group[data-subject='${e.group}']`);t||(t=st(e.group,e.config),this.appendChild(t)),r=t}else console.warn(`ignoring unknown group reference`,e.group,`existing groups:`,e.config.groups);let i=new K(e,this);await i.bindValues(t,n),(e.config.editMode||i.instanceCount()>0)&&(r?r.appendChild(i):this.appendChild(i),await i.updateControls())}async tryResolve(e,t,n){let r=!1;if(t){let i=ze(e,t,n);if(i.length){for(let e of i)await this.addPropertyInstance(n.getPropertyTemplate(e,this.template),t);r=!0}}r||this.appendChild(Le(e,this,n))}};window.customElements.define(`shacl-node`,X);var dt=`
84
84
  .editor:not([type='checkbox']) { border: 1px solid var(--shacl-border-color, #DDD); }
85
85
  .property-instance label { display: inline-flex; word-break: break-word; line-height: 1em; padding-top: 0.15em; padding-right: 1em; flex-shrink: 0; position: relative; }
86
86
  .property-instance:not(:first-child) > label:not(.persistent) { visibility: hidden; max-height: 0; }
87
87
  .mode-edit .property-instance label { width: var(--label-width); }
88
- `,J=class extends Fe{constructor(e){super(e||nt),this.idCtr=0}createDefaultTemplate(r,i,a,o,s){if(o.id=`e${this.idCtr++}`,o.classList.add(`editor`),o.setAttribute(`part`,`editor`),s?.datatype?o.shaclDatatype=s.datatype:i instanceof t&&(o.shaclDatatype=i.datatype),s&&V(s)>0&&(o.dataset.minCount=String(V(s))),s?.class&&(o.dataset.class=s.class.value),s?.nodeKind)o.dataset.nodeKind=s.nodeKind.value;else if(i&&(i instanceof n||s?.nodeKind?.equals(le))&&(o.dataset.nodeKind=h+`IRI`,s)){let t=A(s.config.store.getQuads(i,null,null,null),s.config.languages);t&&(o.dataset.value=`<`+i.value+`>`,i=e.literal(t))}(s?.hasValue&&i||s?.readonly)&&(o.disabled=!0),s?.datatype?.equals(pe)?o.checked=i?.value===`true`||s?.defaultValue?.value===`true`:o.value=i?.value||s?.defaultValue?.value||``;let c=document.createElement(`label`);c.htmlFor=o.id,c.innerText=r,c.setAttribute(`part`,`label`),s?.description&&c.setAttribute(`title`,s.description.value);let l=s?.description?s.description.value:s?.pattern?s.pattern:null;l&&o.setAttribute(`placeholder`,l),a&&(o.setAttribute(`required`,`true`),c.classList.add(`required`));let u=document.createElement(`div`);return u.setAttribute(`part`,`field`),u.appendChild(c),u.appendChild(o),u}createDateEditor(e,t,n,r){let i=new d;r.datatype?.value===`http://www.w3.org/2001/XMLSchema#dateTime`?(i.type=`datetime-local`,i.setAttribute(`step`,`1`)):i.type=`date`,i.clearable=!0,i.dense=this.dense,i.classList.add(`pr-0`);let a=this.createDefaultTemplate(e,null,n,i,r);if(t)try{let e=new Date(t.value).toISOString();e=r.datatype?.value===`http://www.w3.org/2001/XMLSchema#dateTime`?e.slice(0,19):e.slice(0,10),i.value=e}catch(e){console.error(e,t)}return a}createTextEditor(e,t,n,r){let i;return r.singleLine===!1?(i=new p,i.resize=`auto`):i=new d,i.dense=this.dense,r.pattern&&(i.pattern=r.pattern),r.minLength&&(i.minLength=r.minLength),r.maxLength&&(i.maxLength=r.maxLength),this.createDefaultTemplate(e,t,n,i,r)}createLangStringEditor(e,n,r,i){let a=this.createTextEditor(e,n,r,i),o=a.querySelector(`:scope .editor`),s;if(i.languageIn?.length){s=document.createElement(`select`);for(let e of i.languageIn){let t=document.createElement(`option`);t.innerText=e.value,s.appendChild(t)}}else s=document.createElement(`input`),s.maxLength=5,s.size=5,s.placeholder=`lang?`;return s.title=`Language of the text`,s.classList.add(`lang-chooser`),s.setAttribute(`part`,`lang-chooser`),s.slot=`suffix`,o.addEventListener(`change`,()=>{s.required=o.value!==``}),s.addEventListener(`change`,e=>{e.stopPropagation(),o&&(o.dataset.lang=s.value,o.dispatchEvent(new Event(`change`,{bubbles:!0})))}),n instanceof t&&(s.value=n.language),o.dataset.lang=s.value,o.appendChild(s),a}createBooleanEditor(e,n,r,i){let a=document.createElement(`input`);a.type=`checkbox`,a.classList.add(`ml-0`);let o=this.createDefaultTemplate(e,null,r,a,i);return a.removeAttribute(`required`),o.querySelector(`:scope label`)?.classList.remove(`required`),n instanceof t&&(a.checked=n.value===`true`),o}createFileEditor(e,t,n,r){let i=document.createElement(`input`);return i.type=`file`,i.addEventListener(`change`,e=>{if(i.files?.length){e.stopPropagation();let t=new FileReader;t.readAsDataURL(i.files[0]),t.onload=()=>{i.binaryData=btoa(t.result),i.parentElement?.dispatchEvent(new Event(`change`,{bubbles:!0}))}}else i.binaryData=void 0}),this.createDefaultTemplate(e,t,n,i,r)}createNumberEditor(e,t,n,r){let i=new d;i.type=`number`,i.clearable=!0,i.dense=this.dense,i.classList.add(`pr-0`);let a=r.minInclusive===void 0?r.minExclusive===void 0?void 0:r.minExclusive+1:r.minInclusive,o=r.maxInclusive===void 0?r.maxExclusive===void 0?void 0:r.maxExclusive-1:r.maxInclusive;return a!==void 0&&(i.min=String(a)),o!==void 0&&(i.max=String(o)),r.datatype?.value!==`http://www.w3.org/2001/XMLSchema#integer`&&(i.step=`any`),this.createDefaultTemplate(e,t,n,i,r)}createListEditor(e,t,r,i,a){let o=new f;o.clearable=!0,o.dense=this.dense;let s=this.createDefaultTemplate(e,null,r,o,a),c=document.createElement(`ul`),l=!0,u=(e,t)=>{let r=document.createElement(`li`);if(typeof e.value==`string`?(r.dataset.value=e.value,r.innerText=e.label?e.label:e.value):(r.dataset.value=e.value.id,e.value instanceof n&&(r.dataset.value=`<`+r.dataset.value+`>`),r.innerText=e.label?e.label:e.value.value),t.appendChild(r),e.children?.length){l=!1;let t=document.createElement(`ul`);r.appendChild(t);for(let n of e.children)u(n,t)}};for(let e of i)u(e,c);return l||(o.collapse=!0),o.appendChild(c),t=t??a?.defaultValue??null,t&&(o.value=t.id,t instanceof n&&(o.value=`<`+o.value+`>`)),s}createButton(e,t){let n=new c;return n.dense=this.dense,n.innerHTML=e,t?(n.setAttribute(`primary`,``),n.setAttribute(`part`,`button primary`)):n.setAttribute(`part`,`button`),n}},rt={[`${h}node`]:(e,t)=>{e.extendedShapes.add(new Y(t,e.config,e))},[`${h}and`]:(e,t)=>{for(let n of e.config.lists[t.value])e.extendedShapes.add(new Y(n,e.config,e))},[`${h}property`]:(e,t)=>{let n=e.config.getPropertyTemplate(t,e);if(n.path){let t=e.properties[n.path];if(t||(t=[],e.properties[n.path]=t),n.qualifiedValueShape)t.push(n);else{let r;for(let t=0;t<e.properties[n.path].length&&!r;t++)e.properties[n.path][t].qualifiedValueShape||(r=e.properties[n.path][t]);r?Ae(r,n):t.push(n)}}},[`${h}nodeKind`]:(e,t)=>{e.nodeKind=t},[`${h}targetClass`]:(e,t)=>{e.targetClass=t},[`${h}or`]:(e,t)=>{e.or=e.config.lists[t.value]},[`${h}xone`]:(e,t)=>{e.xone=e.config.lists[t.value]},[w.id]:(e,t)=>{e.owlImports.add(t)},[`${y}title`]:(e,t)=>{let n=t;e.label=N(e.config.languages,e.label,n)},[`${v}label`]:(e,t)=>{let n=t;e.label=N(e.config.languages,e.label,n)}},Y=class{constructor(e,t,n){this.extendedShapes=new Set,this.properties={},this.owlImports=new Set,this.id=e,this.config=t,this.parent=n,t.registerNodeTemplate(this),it(this,this.config.store.getQuads(e,null,null,null))}};function it(e,t){for(let n of t)rt[n.predicate.id]?.call(e,e,n.object);return e}function at(e){for(let t of Object.values(e.properties))for(let n of t){let[t,r]=X(e,n.path);if(t.length>1&&r){let e=t[t.length-1];for(let n=t.length-2;n>=0;n--){let r=t[n];delete r.parent.properties[r.path],Ae(e,r)}}}}function X(e,t,n=new Set,r=[],i=!1){if(!n.has(e.id.value)){n.add(e.id.value);let a=e.properties[t];if(a?.length===1){r.push(a[0]),i||=a[0].maxCount===1;for(let e of a[0].nodeShapes){let[a,o]=X(e,t,n,r,i);i||=o}}for(let a of e.extendedShapes){let[e,o]=X(a,t,n,r,i);i||=o}}return[r,i]}var Z=class{constructor(){this.shapes=null,this.shapesUrl=null,this.shapeSubject=null,this.values=null,this.valuesUrl=null,this.valueSubject=null,this.valuesSubject=null,this.valuesNamespace=``,this.valuesGraph=null,this.view=null,this.language=null,this.loading=`Loading…`,this.proxy=null,this.ignoreOwlImports=null,this.collapse=null,this.hierarchyColors=null,this.submitButton=null,this.generateNodeShapeReference=C.value,this.showNodeIds=null,this.showRootShapeLabel=null,this.dense=`true`,this.useShadowRoot=`true`}},ot=`#4c93d785, #f85e9a85, #00327385, #87001f85`,Q=class{constructor(t){this.attributes=new Z,this.editMode=!0,this.lists={},this.groups=[],this.renderedNodes=new Set,this._store=new r,this._nodeTemplates={},this._propertyTemplates={},this.validator=new ee(this._store,{details:!0,factory:e}),this.providedConformingResourceIds={},this.providedResources={},this.form=t,this._theme=new J,this.languages=[...new Set(navigator.languages.flatMap(e=>e.length>2?[e.toLocaleLowerCase(),e.substring(0,2)]:e)),``]}reset(){this.lists={},this.groups=[],this.renderedNodes.clear(),this.providedConformingResourceIds={},this.providedResources={},this._nodeTemplates={},this._propertyTemplates={}}updateAttributes(t){let n=new Z;if(Object.keys(n).forEach(e=>{let r=t.dataset[e];r!==void 0&&(n[e]=r)}),this.editMode=n.view===null,this.theme.setDense(n.dense===`true`),this.attributes=n,this.attributes.valueSubject&&!this.attributes.valuesSubject&&(this.attributes.valuesSubject=this.attributes.valueSubject),n.language){let e=this.languages.indexOf(n.language);e>-1&&this.languages.splice(e,1),this.languages.unshift(n.language)}if(n.valuesGraph&&(this.valuesGraphId=e.namedNode(n.valuesGraph)),n.hierarchyColors!=null){let e=n.hierarchyColors.length?n.hierarchyColors:ot,t=`:host { --hierarchy-colors: ${e}; --hierarchy-colors-length: ${e.split(`,`).length} }`;for(let e=8;e>=0;e--){let n=`shacl-property { --hierarchy-level: ${e} }`;for(let t=0;t<e;t++)n=`shacl-property `+n;t=t+`
89
- `+n}this.hierarchyColorsStyleSheet=new CSSStyleSheet,this.hierarchyColorsStyleSheet.replaceSync(t)}}static dataAttributes(){let e=new Z;return Object.keys(e).map(e=>(e=e.replace(/[A-Z]/g,e=>`-`+e.toLowerCase()),`data-`+e))}buildTemplateKey(e,t){let n=e.value;return t&&(t instanceof B?n+=`*`+t.id.value:n+=`*`+this.buildTemplateKey(t.id,t.parent)),n}registerNodeTemplate(e){this._nodeTemplates[this.buildTemplateKey(e.id,e.parent)]=e}registerPropertyTemplate(e){this._propertyTemplates[this.buildTemplateKey(e.id,e.parent)]=e}getNodeTemplateIds(){let e=new Set;for(let t of Object.values(this._nodeTemplates))e.add(t.id.value);return e}getNodeTemplate(e,t){let n=this.buildTemplateKey(e,t),r=this._nodeTemplates[n];return r||=new Y(e,this,t),r}getPropertyTemplate(e,t){let n=this.buildTemplateKey(e,t),r=this._propertyTemplates[n];return r||=new B(e,t),r}get nodeTemplates(){return Object.values(this._nodeTemplates)}get theme(){return this._theme}set theme(e){this._theme=e,e.setDense(this.attributes.dense===`true`)}get store(){return this._store}set store(t){this._store=t,this.lists=Se(t,{ignoreErrors:!0}),this.groups=[],t.forSubjects(e=>{this.groups.push(e.id)},S,`${h}PropertyGroup`,null),this.validator=new ee(t,{details:!0,factory:e})}},st=200,$=class extends HTMLElement{static get observedAttributes(){return Q.dataAttributes()}constructor(){super(),this.shape=null,this.styleElement=null,this.form=document.createElement(`form`),this.form.setAttribute(`part`,`form`),this.config=new Q(this.form),this.form.addEventListener(`change`,e=>{e.stopPropagation(),this.config.editMode&&this.validate(!0).then(e=>{this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,cancelable:!1,composed:!0,detail:{valid:e.conforms,report:e}}))}).catch(e=>{console.warn(e)})})}connectedCallback(){this.config.updateAttributes(this),this.ensureRenderRoot(),this.initialize()}attributeChangedCallback(){this.config.updateAttributes(this),this.ensureRenderRoot(),this.initialize()}initialize(){clearTimeout(this.initDebounceTimeout),this.setAttribute(`loading`,``),this.form.replaceChildren(document.createTextNode(this.config.attributes.loading)),this.initDebounceTimeout=setTimeout(async()=>{try{this.config.reset(),this.config.store=await we({shapes:this.config.attributes.shapes,shapesUrl:this.config.attributes.shapesUrl,values:this.config.attributes.values,valuesUrl:this.config.attributes.valuesUrl,valuesSubject:this.config.attributes.valuesSubject,loadOwlImports:this.config.attributes.ignoreOwlImports===null,classInstanceProvider:this.config.classInstanceProvider,proxy:this.config.attributes.proxy}),this.config.resourceLinkProvider&&await Xe(this.config),this.config.attributes.valuesSubject||(this.config.attributes.valuesSubject=I(this.config.store)||null),this.form.replaceChildren();let t=this.findRootShaclShapeSubject();if(t){this.form.classList.forEach(e=>{this.form.classList.remove(e)}),this.form.classList.toggle(`mode-edit`,this.config.editMode),this.form.classList.toggle(`mode-view`,!this.config.editMode),this.config.theme.apply(this.form);let n=[this.config.theme.stylesheet];this.config.hierarchyColorsStyleSheet&&n.push(this.config.hierarchyColorsStyleSheet);for(let e of Ve())e.stylesheet&&n.push(e.stylesheet);this.applyStyles(n);let r=new Y(t,this.config);for(let e of this.config.nodeTemplates)at(e);if(this.shape=new q(r,this.config.attributes.valuesSubject?e.namedNode(this.config.attributes.valuesSubject):void 0),this.form.appendChild(this.shape),this.config.attributes.showRootShapeLabel!==null&&r.label){let e=document.createElement(`h3`);e.innerText=r.label.value,this.form.prepend(e)}if(this.config.editMode){if(this.config.attributes.submitButton!==null){let e=this.config.theme.createButton(this.config.attributes.submitButton||`Submit`,!0);e.classList.add(`submit-button`);let t=e.getAttribute(`part`);e.setAttribute(`part`,`${t?t+` `:``}submit-button`),e.addEventListener(`click`,e=>{e.preventDefault(),this.form.reportValidity()&&this.validate().then(e=>{if(e?.conforms)this.dispatchEvent(new Event(`submit`,{bubbles:!0,cancelable:!0}));else{let e=this.form.querySelector(`:scope .invalid > .editor`);e?e.focus():this.form.querySelector(`:scope .invalid`)?.scrollIntoView()}})}),this.form.appendChild(e)}(async()=>{await this.shape?.ready,this.config.attributes.valuesSubject&&this.removeFromDataGraph(e.namedNode(this.config.attributes.valuesSubject)),this.validate(!0)})()}}else if(this.config.store.countQuads(null,null,null,b)>0)throw Error(`shacl root node shape not found`)}catch(e){console.error(e);let t=document.createElement(`div`);t.innerText=String(e),this.form.replaceChildren(t)}this.removeAttribute(`loading`),await this.shape?.ready,this.dispatchEvent(new Event(`ready`))},200)}ensureRenderRoot(){this.config.attributes.useShadowRoot===`false`?(this.shadowRoot?.contains(this.form)&&this.shadowRoot.removeChild(this.form),this.contains(this.form)||this.prepend(this.form)):(this.shadowRoot||this.attachShadow({mode:`open`}),this.shadowRoot.contains(this.form)||this.shadowRoot.prepend(this.form))}applyStyles(e){if(this.config.attributes.useShadowRoot!==`false`&&this.shadowRoot){this.shadowRoot.adoptedStyleSheets=e,this.styleElement&&=(this.styleElement.remove(),null);return}let t=e.map(e=>Array.from(e.cssRules).map(e=>e.cssText).join(`
88
+ `,ft=class extends Ve{constructor(e){super(e||dt),this.idCtr=0}createDefaultTemplate(r,i,a,o,s){if(o.id=`e${this.idCtr++}`,o.classList.add(`editor`),o.setAttribute(`part`,`editor`),s?.datatype?o.shaclDatatype=s.datatype:i instanceof t&&(o.shaclDatatype=i.datatype),s&&H(s)>0&&(o.dataset.minCount=String(H(s))),s?.class&&(o.dataset.class=s.class.value),s?.nodeKind)o.dataset.nodeKind=s.nodeKind.value;else if(i&&(i instanceof n||s?.nodeKind?.equals(ue))&&(o.dataset.nodeKind=h+`IRI`,s)){let t=k(s.config.store.getQuads(i,null,null,null),s.config.languages);t&&(o.dataset.value=`<`+i.value+`>`,i=e.literal(t))}(s?.hasValue&&i||s?.readonly)&&(o.disabled=!0);let c=i?.value||s?.defaultValue?.value||``;s?.datatype?.equals(me)?o.checked=i?.value===`true`||s?.defaultValue?.value===`true`:o.type===`file`?o.binaryData=c||void 0:o.value=c;let l=document.createElement(`label`);l.htmlFor=o.id,l.innerText=r,l.setAttribute(`part`,`label`),s?.description&&l.setAttribute(`title`,s.description.value);let u=s?.description?s.description.value:s?.pattern?s.pattern:null;u&&o.setAttribute(`placeholder`,u),a&&(o.setAttribute(`required`,`true`),l.classList.add(`required`));let d=document.createElement(`div`);return d.setAttribute(`part`,`field`),d.appendChild(l),d.appendChild(o),d}createDateEditor(e,t,n,r){let i=new d;r.datatype?.value===`http://www.w3.org/2001/XMLSchema#dateTime`?(i.type=`datetime-local`,i.setAttribute(`step`,`1`)):i.type=`date`,i.clearable=!0,i.dense=this.dense,i.classList.add(`pr-0`);let a=this.createDefaultTemplate(e,null,n,i,r);if(t){let e=r.datatype?.value===`http://www.w3.org/2001/XMLSchema#dateTime`?we(t.value):Ce(t.value);e?(i.value=e.value,e.suffix&&(i.dataset.xsdTemporalSuffix=e.suffix)):console.error(`unable to parse xsd date literal`,t)}return a}createTextEditor(e,t,n,r){let i;return r.singleLine===!1?(i=new p,i.resize=`auto`):i=new d,i.dense=this.dense,r.pattern&&(i.pattern=r.pattern),r.minLength&&(i.minLength=r.minLength),r.maxLength&&(i.maxLength=r.maxLength),this.createDefaultTemplate(e,t,n,i,r)}createLangStringEditor(e,n,r,i){let a=this.createTextEditor(e,n,r,i),o=a.querySelector(`:scope .editor`),s;if(i.languageIn?.length){s=document.createElement(`select`);for(let e of i.languageIn){let t=document.createElement(`option`);t.innerText=e.value,s.appendChild(t)}}else s=document.createElement(`input`),s.maxLength=5,s.size=5,s.placeholder=`lang?`;return s.title=`Language of the text`,s.classList.add(`lang-chooser`),s.setAttribute(`part`,`lang-chooser`),s.slot=`suffix`,o.addEventListener(`change`,()=>{s.required=o.value!==``}),s.addEventListener(`change`,e=>{e.stopPropagation(),o&&(o.dataset.lang=s.value,o.dispatchEvent(new Event(`change`,{bubbles:!0})))}),n instanceof t&&(s.value=n.language),o.dataset.lang=s.value,o.appendChild(s),a}createBooleanEditor(e,n,r,i){let a=document.createElement(`input`);a.type=`checkbox`,a.classList.add(`ml-0`);let o=this.createDefaultTemplate(e,null,r,a,i);return a.removeAttribute(`required`),o.querySelector(`:scope label`)?.classList.remove(`required`),n instanceof t&&(a.checked=n.value===`true`),o}createFileEditor(e,t,n,r){let i=document.createElement(`input`);return i.type=`file`,i.addEventListener(`change`,e=>{if(i.files?.length){e.stopPropagation();let t=new FileReader;t.readAsDataURL(i.files[0]),t.onload=()=>{i.binaryData=btoa(t.result),i.parentElement?.dispatchEvent(new Event(`change`,{bubbles:!0}))}}else i.binaryData=void 0}),this.createDefaultTemplate(e,t,n,i,r)}createNumberEditor(e,t,n,r){let i=new d;i.type=`number`,i.clearable=!0,i.dense=this.dense,i.classList.add(`pr-0`);let a=r.minInclusive===void 0?r.minExclusive===void 0?void 0:r.minExclusive+1:r.minInclusive,o=r.maxInclusive===void 0?r.maxExclusive===void 0?void 0:r.maxExclusive-1:r.maxInclusive;return a!==void 0&&(i.min=String(a)),o!==void 0&&(i.max=String(o)),r.datatype?.value!==`http://www.w3.org/2001/XMLSchema#integer`&&(i.step=`any`),this.createDefaultTemplate(e,t,n,i,r)}createListEditor(e,t,r,i,a){let o=new f;o.clearable=!0,o.dense=this.dense;let s=this.createDefaultTemplate(e,null,r,o,a),c=document.createElement(`ul`),l=!0,u=(e,t)=>{let r=document.createElement(`li`);if(typeof e.value==`string`?(r.dataset.value=e.value,r.innerText=e.label?e.label:e.value):(r.dataset.value=e.value.id,e.value instanceof n&&(r.dataset.value=`<`+r.dataset.value+`>`),r.innerText=e.label?e.label:e.value.value),t.appendChild(r),e.children?.length){l=!1;let t=document.createElement(`ul`);r.appendChild(t);for(let n of e.children)u(n,t)}};for(let e of i)u(e,c);return l||(o.collapse=!0),o.appendChild(c),t=t??a?.defaultValue??null,t&&(o.value=t.id,t instanceof n&&(o.value=`<`+o.value+`>`)),s}createButton(e,t){let n=new c;return n.dense=this.dense,n.innerHTML=e,t?(n.setAttribute(`primary`,``),n.setAttribute(`part`,`button primary`)):n.setAttribute(`part`,`button`),n}},Z=class{constructor(){this.shapes=null,this.shapesUrl=null,this.shapeSubject=null,this.values=null,this.valuesUrl=null,this.valueSubject=null,this.valuesSubject=null,this.valuesNamespace=``,this.valuesGraph=null,this.view=null,this.language=null,this.loading=`Loading…`,this.proxy=null,this.ignoreOwlImports=null,this.collapse=null,this.hierarchyColors=null,this.submitButton=null,this.generateNodeShapeReference=S.value,this.showNodeIds=null,this.showRootShapeLabel=null,this.dense=`true`,this.useShadowRoot=`true`}},pt=`#4c93d785, #f85e9a85, #00327385, #87001f85`,Q=class{constructor(t){this.attributes=new Z,this.editMode=!0,this.lists={},this.groups=[],this.renderedNodes=new Set,this._store=new r,this._nodeTemplates={},this._propertyTemplates={},this.validator=new ee(this._store,{details:!0,factory:e}),this.providedConformingResourceIds={},this.providedResources={},this.form=t,this._theme=new ft,this.languages=[...new Set(navigator.languages.flatMap(e=>e.length>2?[e.toLocaleLowerCase(),e.substring(0,2)]:e)),``]}reset(){this.lists={},this.groups=[],this.renderedNodes.clear(),this.providedConformingResourceIds={},this.providedResources={},this._nodeTemplates={},this._propertyTemplates={}}updateAttributes(t){let n=new Z;if(Object.keys(n).forEach(e=>{let r=t.dataset[e];r!==void 0&&(n[e]=r)}),this.editMode=n.view===null,this.theme.setDense(n.dense===`true`),this.attributes=n,this.attributes.valueSubject&&!this.attributes.valuesSubject&&(this.attributes.valuesSubject=this.attributes.valueSubject),n.language){let e=this.languages.indexOf(n.language);e>-1&&this.languages.splice(e,1),this.languages.unshift(n.language)}if(n.valuesGraph&&(this.valuesGraphId=e.namedNode(n.valuesGraph)),n.hierarchyColors!=null){let e=n.hierarchyColors.length?n.hierarchyColors:pt,t=`:host { --hierarchy-colors: ${e}; --hierarchy-colors-length: ${e.split(`,`).length} }`;for(let e=8;e>=0;e--){let n=`shacl-property { --hierarchy-level: ${e} }`;for(let t=0;t<e;t++)n=`shacl-property `+n;t=t+`
89
+ `+n}this.hierarchyColorsStyleSheet=new CSSStyleSheet,this.hierarchyColorsStyleSheet.replaceSync(t)}}static dataAttributes(){let e=new Z;return Object.keys(e).map(e=>(e=e.replace(/[A-Z]/g,e=>`-`+e.toLowerCase()),`data-`+e))}buildTemplateKey(e,t){let n=e.value;return t&&(t instanceof V?n+=`*`+t.id.value:n+=`*`+this.buildTemplateKey(t.id,t.parent)),n}registerNodeTemplate(e){this._nodeTemplates[this.buildTemplateKey(e.id,e.parent)]=e}registerPropertyTemplate(e){this._propertyTemplates[this.buildTemplateKey(e.id,e.parent)]=e}getNodeTemplateIds(){let e=new Set;for(let t of Object.values(this._nodeTemplates))e.add(t.id.value);return e}getNodeTemplate(e,t){let n=this.buildTemplateKey(e,t),r=this._nodeTemplates[n];return r||=new J(e,this,t),r}getPropertyTemplate(e,t){let n=this.buildTemplateKey(e,t),r=this._propertyTemplates[n];return r||=new V(e,t),r}get nodeTemplates(){return Object.values(this._nodeTemplates)}get theme(){return this._theme}set theme(e){this._theme=e,e.setDense(this.attributes.dense===`true`)}get store(){return this._store}set store(t){this._store=t,this.lists=ke(t,{ignoreErrors:!0}),this.groups=[],t.forSubjects(e=>{this.groups.push(e.id)},x,`${h}PropertyGroup`,null),this.validator=new ee(t,{details:!0,factory:e})}},mt=200,$=class extends HTMLElement{static get observedAttributes(){return Q.dataAttributes()}constructor(){super(),this.shape=null,this.styleElement=null,this.form=document.createElement(`form`),this.form.setAttribute(`part`,`form`),this.config=new Q(this.form),this.form.addEventListener(`change`,e=>{e.stopPropagation(),this.config.editMode&&this.validate(!0).then(e=>{this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,cancelable:!1,composed:!0,detail:{valid:e.conforms,report:e}}))}).catch(e=>{console.warn(e)})})}connectedCallback(){this.config.updateAttributes(this),this.ensureRenderRoot(),this.initialize()}attributeChangedCallback(){this.config.updateAttributes(this),this.ensureRenderRoot(),this.initialize()}initialize(){clearTimeout(this.initDebounceTimeout),this.setAttribute(`loading`,``),this.form.replaceChildren(document.createTextNode(this.config.attributes.loading)),this.initDebounceTimeout=setTimeout(async()=>{try{this.config.reset(),this.config.store=await Ae({shapes:this.config.attributes.shapes,shapesUrl:this.config.attributes.shapesUrl,values:this.config.attributes.values,valuesUrl:this.config.attributes.valuesUrl,valuesSubject:this.config.attributes.valuesSubject,loadOwlImports:this.config.attributes.ignoreOwlImports===null,classInstanceProvider:this.config.classInstanceProvider,proxy:this.config.attributes.proxy}),this.config.resourceLinkProvider&&await nt(this.config),this.config.attributes.valuesSubject||(this.config.attributes.valuesSubject=I(this.config.store)||null),this.form.replaceChildren();let t=this.findRootShaclShapeSubject();if(t){this.form.classList.forEach(e=>{this.form.classList.remove(e)}),this.form.classList.toggle(`mode-edit`,this.config.editMode),this.form.classList.toggle(`mode-view`,!this.config.editMode),this.config.theme.apply(this.form);let n=[this.config.theme.stylesheet];this.config.hierarchyColorsStyleSheet&&n.push(this.config.hierarchyColorsStyleSheet);for(let e of qe())e.stylesheet&&n.push(e.stylesheet);this.applyStyles(n);let r=new J(t,this.config);for(let e of this.config.nodeTemplates)ut(e);if(this.shape=new X(r,this.config.attributes.valuesSubject?e.namedNode(this.config.attributes.valuesSubject):void 0),this.form.appendChild(this.shape),this.config.attributes.showRootShapeLabel!==null&&r.label){let e=document.createElement(`h3`);e.innerText=r.label.value,this.form.prepend(e)}if(this.config.editMode){if(this.config.attributes.submitButton!==null){let e=this.config.theme.createButton(this.config.attributes.submitButton||`Submit`,!0);e.classList.add(`submit-button`);let t=e.getAttribute(`part`);e.setAttribute(`part`,`${t?t+` `:``}submit-button`),e.addEventListener(`click`,e=>{e.preventDefault(),this.form.reportValidity()&&this.validate().then(e=>{if(e?.conforms)this.dispatchEvent(new Event(`submit`,{bubbles:!0,cancelable:!0}));else{let e=this.form.querySelector(`:scope .invalid > .editor`);e?e.focus():this.form.querySelector(`:scope .invalid`)?.scrollIntoView()}})}),this.form.appendChild(e)}(async()=>{await this.shape?.ready,this.config.attributes.valuesSubject&&this.removeFromDataGraph(e.namedNode(this.config.attributes.valuesSubject)),this.validate(!0)})()}}else if(this.config.store.countQuads(null,null,null,y)>0)throw Error(`shacl root node shape not found`)}catch(e){console.error(e);let t=document.createElement(`div`);t.innerText=String(e),this.form.replaceChildren(t)}this.removeAttribute(`loading`),await this.shape?.ready,this.dispatchEvent(new Event(`ready`))},200)}ensureRenderRoot(){this.config.attributes.useShadowRoot===`false`?(this.shadowRoot?.contains(this.form)&&this.shadowRoot.removeChild(this.form),this.contains(this.form)||this.prepend(this.form)):(this.shadowRoot||this.attachShadow({mode:`open`}),this.shadowRoot.contains(this.form)||this.shadowRoot.prepend(this.form))}applyStyles(e){if(this.config.attributes.useShadowRoot!==`false`&&this.shadowRoot){this.shadowRoot.adoptedStyleSheets=e,this.styleElement&&=(this.styleElement.remove(),null);return}let t=e.map(e=>Array.from(e.cssRules).map(e=>e.cssText).join(`
90
90
  `).replace(/:host\b/g,`shacl-form`)).join(`
91
- `);this.styleElement||(this.styleElement=document.createElement(`style`),this.prepend(this.styleElement)),this.styleElement.textContent=t}serialize(e=`text/turtle`,t=this.toRDF()){return Le(t.getQuads(null,null,null,null),e,F)}toRDF(e=new r){return this.shape?.toRDF(e,void 0,this.config.attributes.generateNodeShapeReference),e}registerPlugin(e){Be(e),this.initialize()}setTheme(e){this.config.theme=e,this.initialize()}setClassInstanceProvider(e){this.config.classInstanceProvider=e,this.initialize()}setResourceLinkProvider(e){this.config.resourceLinkProvider=e,this.initialize()}async validate(e=!1){for(let e of this.form.querySelectorAll(`:scope .validation-error`))e.remove();for(let e of this.form.querySelectorAll(`:scope .property-instance`))e.classList.remove(`invalid`),e.querySelector(`:scope > .editor`)?.value?e.classList.add(`valid`):e.classList.remove(`valid`);for(let e of this.form.querySelectorAll(`.add-button-wrapper`))e.classList.remove(`invalid`,`validation-error`);if(!this.shape)return{conforms:!0,results:[]};if(!e){let e=this.form.querySelectorAll(`.add-button-wrapper.required`);for(let t of e)t.classList.add(`invalid`),t.after(this.createValidationErrorDisplay(`Value is required`,`node`));if(e.length>0)return{conforms:!1,results:[]}}let t=this.shape;return new Promise(n=>{this.config.store.deleteGraph(this.config.valuesGraphId||``).on(`end`,async()=>{t.toRDF(this.config.store,void 0,this.config.attributes.generateNodeShapeReference);try{let r=await this.config.validator.validate({dataset:this.config.store,terms:[t.nodeId]},[{terms:[t.template.id]}]);for(let t of r.results)if(t.focusNode?.ptrs?.length)for(let n of t.focusNode.ptrs){let r=n._term;if(t.path?.length){let n=t.path[0].predicates[0],i=this.form.querySelectorAll(`
91
+ `);this.styleElement||(this.styleElement=document.createElement(`style`),this.prepend(this.styleElement)),this.styleElement.textContent=t}serialize(e=`text/turtle`,t=this.toRDF()){return Ue(t.getQuads(null,null,null,null),e,F)}toRDF(e=new r){return this.shape?.toRDF(e,void 0,this.config.attributes.generateNodeShapeReference),e}registerPlugin(e){Ke(e),this.initialize()}setTheme(e){this.config.theme=e,this.initialize()}setClassInstanceProvider(e){this.config.classInstanceProvider=e,this.initialize()}setResourceLinkProvider(e){this.config.resourceLinkProvider=e,this.initialize()}async validate(e=!1){for(let e of this.form.querySelectorAll(`:scope .validation-error`))e.remove();for(let e of this.form.querySelectorAll(`:scope .property-instance`))e.classList.remove(`invalid`),e.querySelector(`:scope > .editor`)?.value?e.classList.add(`valid`):e.classList.remove(`valid`);for(let e of this.form.querySelectorAll(`.add-button-wrapper`))e.classList.remove(`invalid`,`validation-error`);if(!this.shape)return{conforms:!0,results:[]};if(!e){let e=this.form.querySelectorAll(`.add-button-wrapper.required`);for(let t of e)t.classList.add(`invalid`),t.after(this.createValidationErrorDisplay(`Value is required`,`node`));if(e.length>0)return{conforms:!1,results:[]}}let t=this.shape;return new Promise(n=>{this.config.store.deleteGraph(this.config.valuesGraphId||``).on(`end`,async()=>{t.toRDF(this.config.store,void 0,this.config.attributes.generateNodeShapeReference);try{let r=await this.config.validator.validate({dataset:this.config.store,terms:[t.nodeId]},[{terms:[t.template.id]}]);for(let t of r.results)if(t.focusNode?.ptrs?.length)for(let n of t.focusNode.ptrs){let r=n._term;if(t.path?.length){let n=t.path[0].predicates[0],i=this.form.querySelectorAll(`
92
92
  :scope shacl-node[data-node-id='${r.id}'] > shacl-property > .property-instance[data-path='${n.id}'] > .editor,
93
93
  :scope shacl-node[data-node-id='${r.id}'] > shacl-property > .shacl-group > .property-instance[data-path='${n.id}'] > .editor,
94
94
  :scope shacl-node[data-node-id='${r.id}'] > .shacl-group > shacl-property > .property-instance[data-path='${n.id}'] > .editor,
95
95
  :scope shacl-node[data-node-id='${r.id}'] > .shacl-group > shacl-property > .shacl-group > .property-instance[data-path='${n.id}'] > .editor`);i.length===0&&(i=this.form.querySelectorAll(`
96
96
  :scope [data-node-id='${r.id}'] > shacl-property > .property-instance[data-path='${n.id}'],
97
- :scope [data-node-id='${r.id}'] > shacl-property > .shacl-group > .property-instance[data-path='${n.id}']`));for(let n of i)if(n.classList.contains(`editor`)){if(!e||n.value){let e=n.parentElement;e.classList.add(`invalid`),e.classList.remove(`valid`),e.appendChild(this.createValidationErrorDisplay(t));do e instanceof l&&(e.open=!0),e=e.parentElement;while(e)}}else e||(n.classList.add(`invalid`),n.classList.remove(`valid`),n.appendChild(this.createValidationErrorDisplay(t,`node`)))}else e||this.form.querySelector(`:scope [data-node-id='${r.id}']`)?.prepend(this.createValidationErrorDisplay(t,`node`))}n(r)}catch(e){console.error(e),n({conforms:!1,results:[]})}})})}createValidationErrorDisplay(e,t){let n=document.createElement(`span`);n.classList.add(`validation-error`),t&&n.classList.add(t);let r=typeof e==`object`&&e?e:null;return r?r.message?.length?n.title+=ye(this.config.languages,r.message):r.sourceConstraintComponent?.value&&(n.title=r.sourceConstraintComponent.value):typeof e==`string`&&(n.title=e),n}findRootShaclShapeSubject(){if(this.config.attributes.shapeSubject){let t=e.namedNode(this.config.attributes.shapeSubject);if(this.config.store.getQuads(t,S,T,null).length===0){console.warn(`shapes graph does not contain requested node shape ${this.config.attributes.shapeSubject}`);return}else return t}else{if(this.config.attributes.valuesSubject&&this.config.store.countQuads(null,null,null,x)>0){let t=e.namedNode(this.config.attributes.valuesSubject),n=Ce(this.config.store,this.config.attributes.valuesSubject),r=this.config.store.getQuads(t,S,null,x);if(r.length===0&&console.warn(`value subject '${this.config.attributes.valuesSubject}' has neither ${S.id} nor ${C.id} statement`),n)return n;for(let e of r)if(this.config.store.getQuads(e.object,S,T,null).length>0)return e.object;let i=this.config.store.getObjects(t,S,x);for(let e of i)for(let t of this.config.store.getQuads(null,O,e,null))return t.subject}let t=this.config.store.getQuads(null,S,T,null);if(t.length==0){console.warn(`shapes graph does not contain any node shapes`);return}return t.length>1&&(console.warn(`shapes graph contains`,t.length,`node shapes. choosing first found which is`,t[0].subject.value),console.info(`hint: set the node shape to use with element attribute "data-shape-subject"`)),t[0].subject}}removeFromDataGraph(e){for(let t of this.config.store.getQuads(e,null,null,x))this.config.store.delete(t),(t.object.termType===`NamedNode`||t.object.termType===`BlankNode`)&&this.removeFromDataGraph(t.object)}};window.customElements.define(`shacl-form`,$);export{Q as Config,J as DefaultTheme,Ue as Plugin,$ as ShaclForm,B as ShaclPropertyTemplate,Fe as Theme,R as fetchRDF,Ce as findConformsToShapeSubject,I as findConformsToValuesSubject,A as findLabel,L as importRDF,st as initTimeout,we as loadGraphs,z as parseRDF,F as prefixes,De as propertyMappers,P as rdfCache,Be as registerPlugin};
97
+ :scope [data-node-id='${r.id}'] > shacl-property > .shacl-group > .property-instance[data-path='${n.id}']`));for(let n of i)if(n.classList.contains(`editor`)){if(!e||n.value){let e=n.parentElement;e.classList.add(`invalid`),e.classList.remove(`valid`),e.appendChild(this.createValidationErrorDisplay(t));do e instanceof l&&(e.open=!0),e=e.parentElement;while(e)}}else e||(n.classList.add(`invalid`),n.classList.remove(`valid`),n.appendChild(this.createValidationErrorDisplay(t,`node`)))}else e||this.form.querySelector(`:scope [data-node-id='${r.id}']`)?.prepend(this.createValidationErrorDisplay(t,`node`))}n(r)}catch(e){console.error(e),n({conforms:!1,results:[]})}})})}createValidationErrorDisplay(e,t){let n=document.createElement(`span`);n.classList.add(`validation-error`),t&&n.classList.add(t);let r=typeof e==`object`&&e?e:null;return r?r.message?.length?n.title+=be(this.config.languages,r.message):r.sourceConstraintComponent?.value&&(n.title=r.sourceConstraintComponent.value):typeof e==`string`&&(n.title=e),n}findRootShaclShapeSubject(){if(this.config.attributes.shapeSubject){let t=e.namedNode(this.config.attributes.shapeSubject);if(this.config.store.getQuads(t,x,w,null).length===0){console.warn(`shapes graph does not contain requested node shape ${this.config.attributes.shapeSubject}`);return}else return t}else{if(this.config.attributes.valuesSubject&&this.config.store.countQuads(null,null,null,b)>0){let t=e.namedNode(this.config.attributes.valuesSubject),n=L(this.config.store,this.config.attributes.valuesSubject),r=this.config.store.getQuads(t,x,null,b);if(r.length===0&&console.warn(`value subject '${this.config.attributes.valuesSubject}' has neither ${x.id} nor ${S.id} statement`),n)return n;for(let e of r)if(this.config.store.getQuads(e.object,x,w,null).length>0)return e.object;let i=this.config.store.getObjects(t,x,b);for(let e of i)for(let t of this.config.store.getQuads(null,D,e,null))return t.subject}let t=this.config.store.getQuads(null,x,w,null);if(t.length==0){console.warn(`shapes graph does not contain any node shapes`);return}return t.length>1&&(console.warn(`shapes graph contains`,t.length,`node shapes. choosing first found which is`,t[0].subject.value),console.info(`hint: set the node shape to use with element attribute "data-shape-subject"`)),t[0].subject}}removeFromDataGraph(e){for(let t of this.config.store.getQuads(e,null,null,b))this.config.store.delete(t),(t.object.termType===`NamedNode`||t.object.termType===`BlankNode`)&&this.removeFromDataGraph(t.object)}};window.customElements.define(`shacl-form`,$);export{Q as Config,ft as DefaultTheme,Ye as Plugin,$ as ShaclForm,V as ShaclPropertyTemplate,Ve as Theme,z as fetchRDF,L as findConformsToShapeSubject,I as findConformsToValuesSubject,k as findLabel,R as importRDF,mt as initTimeout,Ae as loadGraphs,B as parseRDF,F as prefixes,Ne as propertyMappers,P as rdfCache,Ke as registerPlugin};
@@ -13,6 +13,7 @@ export declare class ShaclNodeTemplate {
13
13
  extendedShapes: Set<ShaclNodeTemplate>;
14
14
  properties: Record<string, ShaclPropertyTemplate[]>;
15
15
  owlImports: Set<NamedNode>;
16
+ merged: boolean;
16
17
  config: Config;
17
18
  constructor(id: Term, config: Config, parent?: ShaclNodeTemplate | ShaclPropertyTemplate);
18
19
  }
package/dist/util.d.ts CHANGED
@@ -12,6 +12,16 @@ export declare function findInstancesOf(clazz: NamedNode, template: ShaclPropert
12
12
  export declare function isURL(input: string): boolean;
13
13
  export declare function prioritizeByLanguage(languages: string[], text1?: Literal, text2?: Literal): Literal | undefined;
14
14
  export declare function findBestMatchingLiteral(languages: string[], literals: Literal[]): string;
15
+ export declare function formatXsdDateValueForInput(value: string): {
16
+ value: string;
17
+ suffix: string;
18
+ } | undefined;
19
+ export declare function formatXsdDateTimeValueForInput(value: string): {
20
+ value: string;
21
+ suffix: string;
22
+ } | undefined;
23
+ export declare function serializeXsdDateValue(value: string, suffix?: string): string;
24
+ export declare function serializeXsdDateTimeValue(value: string, suffix?: string): string;
15
25
  export declare function findAllClasses(store: Store): Set<string>;
16
26
  export declare function filterOutExistingItems(existing: Set<string> | string[], items: Set<string>): string[];
17
27
  export declare function extractLists(store: Store, { remove, ignoreErrors }?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ulb-darmstadt/shacl-form",
3
- "version": "3.0.5",
3
+ "version": "3.0.7",
4
4
  "description": "SHACL form generator",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -53,18 +53,18 @@
53
53
  "@types/mapbox__mapbox-gl-draw": "^1.4.9",
54
54
  "@types/mocha": "^10.0.10",
55
55
  "@types/n3": "^1.26.1",
56
- "@typescript-eslint/eslint-plugin": "^8.58.0",
57
- "@typescript-eslint/parser": "^8.58.0",
56
+ "@typescript-eslint/eslint-plugin": "^8.59.2",
57
+ "@typescript-eslint/parser": "^8.59.2",
58
58
  "@web/test-runner": "^0.20.2",
59
59
  "@web/test-runner-chrome": "^0.18.1",
60
60
  "@web/test-runner-puppeteer": "^0.18.0",
61
- "eslint": "^10.2.0",
62
- "puppeteer": "^24.40.0",
61
+ "eslint": "^10.3.0",
62
+ "puppeteer": "^24.43.0",
63
63
  "rdf-isomorphic": "^2.0.1",
64
64
  "rimraf": "^6.1.3",
65
65
  "rollup-plugin-peer-deps-external": "^2.2.4",
66
- "typescript": "^6.0.2",
67
- "vite": "^8.0.5"
66
+ "typescript": "^6.0.3",
67
+ "vite": "^8.0.11"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "@ro-kit/ui-widgets": "^1.0.44",