@ulb-darmstadt/shacl-form 2.0.4 → 2.0.6

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