@ulb-darmstadt/shacl-form 3.1.1 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,84 @@
1
+ import{DataFactory as e,Literal as t,NamedNode as n,Store as r,StreamParser as i,Writer as a}from"n3";import{RdfXmlParser as o}from"rdfxml-streaming-parser";import s from"jsonld";import{RokitButton as c,RokitCollapsible as l,RokitDialog as u}from"@ro-kit/ui-widgets";import{v4 as d}from"uuid";var f=`http://www.w3.org/ns/shacl#`,p=`http://datashapes.org/dash#`,m=`http://www.w3.org/2001/XMLSchema#`,h=`http://www.w3.org/1999/02/22-rdf-syntax-ns#`,ee=`http://www.w3.org/2000/01/rdf-schema#`,te=`http://www.w3.org/ns/oa#`,ne=`http://purl.org/dc/terms/`,g=e.namedNode(`loaded-shapes`),_=e.namedNode(`loaded-data`),v=e.namedNode(`http://www.w3.org/1999/02/22-rdf-syntax-ns#type`),y=e.namedNode(`http://www.w3.org/1999/02/22-rdf-syntax-ns#langString`),b=e.namedNode(`http://purl.org/dc/terms/conformsTo`),re=e.namedNode(`http://www.w3.org/2000/01/rdf-schema#subClassOf`),x=e.namedNode(`http://www.w3.org/2002/07/owl#imports`),ie=e.namedNode(`http://www.w3.org/2004/02/skos/core#broader`),ae=e.namedNode(`http://www.w3.org/2004/02/skos/core#narrower`),oe=e.namedNode(`http://www.w3.org/ns/shacl#NodeShape`),se=e.namedNode(`http://www.w3.org/ns/shacl#IRI`),S=e.namedNode(`http://www.w3.org/ns/shacl#property`),C=e.namedNode(`http://www.w3.org/ns/shacl#class`),ce=e.namedNode(`http://www.w3.org/ns/shacl#node`),w=e.namedNode(`http://www.w3.org/ns/shacl#targetClass`),le=e.namedNode(`http://www.w3.org/ns/shacl#nodeKind`),ue=e.namedNode(`http://www.w3.org/2001/XMLSchema#string`),de=e.namedNode(`http://www.w3.org/2001/XMLSchema#boolean`),fe=new Set([`http://www.w3.org/2001/XMLSchema#integer`,`http://www.w3.org/2001/XMLSchema#int`,`http://www.w3.org/2001/XMLSchema#short`,`http://www.w3.org/2001/XMLSchema#byte`,`http://www.w3.org/2001/XMLSchema#unsignedInt`,`http://www.w3.org/2001/XMLSchema#unsignedShort`,`http://www.w3.org/2001/XMLSchema#unsignedByte`,`http://www.w3.org/2001/XMLSchema#long`,`http://www.w3.org/2001/XMLSchema#unsignedLong`,`http://www.w3.org/2001/XMLSchema#float`,`http://www.w3.org/2001/XMLSchema#double`,`http://www.w3.org/2001/XMLSchema#decimal`,`http://www.w3.org/2001/XMLSchema#date`,`http://www.w3.org/2001/XMLSchema#dateTime`]),pe=new Set([`http://www.w3.org/2001/XMLSchema#integer`,`http://www.w3.org/2001/XMLSchema#int`,`http://www.w3.org/2001/XMLSchema#short`,`http://www.w3.org/2001/XMLSchema#byte`,`http://www.w3.org/2001/XMLSchema#unsignedInt`,`http://www.w3.org/2001/XMLSchema#unsignedShort`,`http://www.w3.org/2001/XMLSchema#unsignedByte`,`http://www.w3.org/2001/XMLSchema#long`,`http://www.w3.org/2001/XMLSchema#unsignedLong`,`http://www.w3.org/2001/XMLSchema#float`,`http://www.w3.org/2001/XMLSchema#double`,`http://www.w3.org/2001/XMLSchema#decimal`]),me=new Set([`http://www.w3.org/2001/XMLSchema#float`,`http://www.w3.org/2001/XMLSchema#double`,`http://www.w3.org/2001/XMLSchema#decimal`]);function T(e,t,n=f,r){let i=``,a=he(e,t,n,r);return a&&(i=a.value),i}function he(e,t,n=f,r){let i,a=n+t;if(r?.length){for(let t of r)for(let n of e)if(n.predicate.value===a){if(n.object.id.endsWith(`@${t}`))return n.object;n.object.id.indexOf(`@`)<0?i=n.object:i||=n.object}}else for(let t of e)if(t.predicate.value===a)return t.object;return i}function ge(e){e.querySelector(`.editor`)?.focus()}function E(e,t){return T(e,`prefLabel`,`http://www.w3.org/2004/02/skos/core#`,t)||T(e,`label`,`http://www.w3.org/2000/01/rdf-schema#`,t)||T(e,`title`,`http://purl.org/dc/terms/`,t)||T(e,`name`,`http://xmlns.com/foaf/0.1/`,t)}function D(e,t,n){let r=[];for(let i of e)r.push({value:i,label:E(t.getQuads(i,null,null,null),n),children:[]});return r}function O(e,t){for(let n in t){let r=t[n];e.startsWith(r)&&(e=e.slice(r.length))}return e}function _e(e,t,n,r,i=new Set){for(let a of t.owlImports)i.has(a.id)||(i.add(a.id),r.push(...n.getSubjects(v,e,a)));t.parent&&_e(e,t.parent,n,r,i)}function k(e,t){if(t.in){let e=t.config.lists[t.in];return D(e?.length?e:[],t.config.store,t.config.languages)}else{let n=t.config.store.getSubjects(v,e,g);n.push(...t.config.store.getSubjects(v,e,_)),_e(e,t,t.config.store,n);let r=new Map,i=new Map;for(let e of n)r.set(e.id,{value:e,label:E(t.config.store.getQuads(e,null,null,null),t.config.languages),children:[]});for(let e of n){for(let n of t.config.store.getObjects(e,ie,null))r.has(n.id)&&i.set(e.id,n.id);for(let n of t.config.store.getObjects(e,ae,null))r.has(n.id)&&i.set(n.id,e.id);for(let n of t.config.store.getObjects(e,re,null))r.has(n.id)&&i.set(e.id,n.id)}for(let[e,t]of i.entries())r.get(t)?.children?.push(r.get(e));let a=[];for(let[e,t]of r.entries())i.has(e)||a.push(t);for(let n of t.config.store.getSubjects(re,e,null))a.push(...k(n,t));return a}}function A(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol===`http:`||t.protocol===`https:`}function j(e,t,n){if(t===void 0)return n;if(n===void 0)return t;let r=e.indexOf(t.language);if(r<0)return n;let i=e.indexOf(n.language);return i<0||i>r?t:n}function ve(e,t){let n;for(let r of t)n=j(e,n,r);return n?n.value:``}var M=/^(-?\d{4,}-\d{2}-\d{2})(Z|[+-]\d{2}:\d{2})?$/,ye=/^(-?\d{4,}-\d{2}-\d{2})T(\d{2}:\d{2})(?::(\d{2})(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?$/,be=/^(-?\d{4,}-\d{2}-\d{2}T\d{2}:\d{2})(?::(\d{2})(\.\d+)?)?$/;function xe(e){let t=e.match(M);if(!t){let t=e.match(ye);return t?{value:t[1],suffix:t[5]||``}:void 0}return{value:t[1],suffix:t[2]||``}}function Se(e){let t=e.match(ye);if(!t){let t=e.match(M);return t?{value:`${t[1]}T00:00:00`,suffix:t[2]||``}:void 0}return{value:`${t[1]}T${t[2]}:${t[3]||`00`}`,suffix:t[5]||``}}function Ce(e,t=``){let n=e.match(M);return n?`${n[1]}${t}`:e}function we(e,t=``){let n=e.match(be);return n?`${n[1]}:${n[2]||`00`}${n[3]||``}${t}`:e}function Te(e){let t=new Set;for(let n of e.getObjects(null,C,g))t.add(n.value);for(let n of e.getObjects(null,w,g))t.add(n.value);return t}function Ee(e,t){return e instanceof Set?[...t].filter(t=>!e.has(t)):[...t].filter(t=>!e.includes(t))}function De(e,{remove:t=!1,ignoreErrors:n=!1}={}){let r={},i=n?()=>!0:(e,t)=>{throw Error(`${e.value} ${t}`)},a=e.getQuads(null,h+`rest`,h+`nil`,null),o=t?[...a]:[];return a.forEach(n=>{let a=[],s=!1,c,l,u=n.graph,d=n.subject;for(;d&&!s;){let t=e.getQuads(null,null,d,null),n=e.getQuads(d,null,null,null).filter(e=>!e.predicate.equals(v)),r,f=null,p=null,m=null;for(let e=0;e<n.length&&!s;e++)r=n[e],r.graph.equals(u)?c?s=i(d,`has non-list arcs out`):r.predicate.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#first`?f?s=i(d,`has multiple rdf:first arcs`):o.push(f=r):r.predicate.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#rest`?p?s=i(d,`has multiple rdf:rest arcs`):o.push(p=r):t.length?s=i(d,`can't be subject and object`):(c=r,l=`subject`):s=i(d,`not confined to single graph`);for(let e=0;e<t.length&&!s;++e)r=t[e],c?s=i(d,`can't have coreferences`):r.predicate.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#rest`?m?s=i(d,`has incoming rdf:rest arcs`):m=r:(c=r,l=`object`);f?a.unshift(f.object):s=i(d,`has no list head`),d=m&&m.subject}s?t=!1:c&&(r[c[l].value]=a)}),t&&e.removeQuads(o),r}var N={},P={};async function F(e){return`rdf`in e?L(e.rdf):e.rdfUrlResolver?L(await e.rdfUrlResolver(e.url)):I(e.url,e.proxy)}async function I(e,t){return e in N||(N[e]=(async()=>{let n=e;t&&(n=t+encodeURIComponent(e));let r=await fetch(n,{headers:{Accept:`text/turtle, application/trig, application/n-triples, application/n-quads, text/n3, application/ld+json`}});return r.ok?L(await r.text()):(console.warn(`failed fetching RDF from`,e),[])})()),N[e]}async function L(t){if(!t.trim())return[];let n=Oe(t);if(n===`json`)try{t=await s.toRDF(JSON.parse(t),{format:`application/n-quads`})}catch(e){console.error(e)}let r=[];return await new Promise((a,s)=>{let c=n===`xml`?new o:new i;c.on(`data`,t=>{r.push(e.quad(t.subject,t.predicate,t.object,t.graph))}).on(`error`,e=>{s(e)}).on(`prefix`,(e,t)=>{e&&(P[e]=t)}).on(`end`,()=>{a(null)}),c.write(t),c.end()}),r}function Oe(e){return/^\s*[\\[{]/.test(e)?`json`:/^\s*<\?xml/.test(e)?`xml`:`ttl`}var ke={[`${f}name`]:(e,t)=>{let n=t;e.name=j(e.config.languages,e.name,n)},[`${f}description`]:(e,t)=>{let n=t;e.description=j(e.config.languages,e.description,n)},[`${f}path`]:(e,t)=>{e.path=t.value},[`${f}group`]:(e,t)=>{e.group=t.id},[`${f}datatype`]:(e,t)=>{e.datatype=t},[`${f}nodeKind`]:(e,t)=>{e.nodeKind=t},[`${f}minCount`]:(e,t)=>{e.minCount=parseInt(t.value)},[`${f}maxCount`]:(e,t)=>{e.maxCount=parseInt(t.value)},[`${f}minLength`]:(e,t)=>{e.minLength=parseInt(t.value)},[`${f}maxLength`]:(e,t)=>{e.maxLength=parseInt(t.value)},[`${f}minInclusive`]:(e,t)=>{e.minInclusive=parseInt(t.value)},[`${f}maxInclusive`]:(e,t)=>{e.maxInclusive=parseInt(t.value)},[`${f}minExclusive`]:(e,t)=>{e.minExclusive=parseInt(t.value)},[`${f}maxExclusive`]:(e,t)=>{e.maxExclusive=parseInt(t.value)},[`${f}pattern`]:(e,t)=>{e.pattern=t.value},[`${f}order`]:(e,t)=>{e.order=parseInt(t.value)},[`${p}singleLine`]:(e,t)=>{e.singleLine=t.value===`true`},[`${p}readonly`]:(e,t)=>{e.readonly=t.value===`true`},[`${te}styleClass`]:(e,t)=>{e.cssClass=t.value},[`${f}in`]:(e,t)=>{e.in=t.value},[`${f}languageIn`]:(e,t)=>{e.languageIn=e.config.lists[t.value],e.datatype=y},[`${f}defaultValue`]:(e,t)=>{e.defaultValue=t},[`${f}hasValue`]:(e,t)=>{e.hasValue=t},[`${f}node`]:(e,t)=>{e.node=t,e.nodeShapes.add(e.config.getNodeTemplate(t,e))},[`${f}and`]:(e,t)=>{e.and=t.value;let n=e.config.lists[e.and];if(n?.length)for(let t of n)e.nodeShapes.add(e.config.getNodeTemplate(t,e))},[`${f}qualifiedValueShape`]:(e,t)=>{let n=e.config.getNodeTemplate(t,e);e.qualifiedValueShape=n,e.nodeShapes.add(n)},[`${f}qualifiedMinCount`]:(e,t)=>{e.qualifiedMinCount=parseInt(t.value)},[`${f}qualifiedMaxCount`]:(e,t)=>{e.qualifiedMaxCount=parseInt(t.value)},[x.id]:(e,t)=>{e.owlImports.add(t)},[C.id]:(e,t)=>{e.class=t;let n=e.config.store.getSubjects(w,t,null);n.length>0&&(e.node=n[0])},[`${f}or`]:(e,t)=>{let n=e.config.lists[t.value];n?.length?e.or=n:console.error(`list for sh:or not found:`,t.value,`existing lists:`,e.config.lists)},[`${f}xone`]:(e,t)=>{let n=e.config.lists[t.value];n?.length?e.xone=n:console.error(`list for sh:xone not found:`,t.value,`existing lists:`,e.config.lists)}},Ae=class{constructor(e,t){this.label=``,this.nodeShapes=new Set,this.owlImports=new Set,this.id=e,this.parent=t,this.config=t.config,this.config.registerPropertyTemplate(this),B(this,this.config.store.getQuads(e,null,null,null))}};function R(e){return Math.max(e.minCount??0,e.qualifiedMinCount??0)}function je(e){return Math.min(e.maxCount??2**53-1,e.qualifiedMaxCount??2**53-1)}function z(e){let t=Object.assign({},e);return t.nodeShapes=new Set(e.nodeShapes),t.owlImports=new Set(e.owlImports),e.languageIn&&(t.languageIn=[...e.languageIn]),e.or&&(t.or=[...e.or]),e.xone&&(t.xone=[...e.xone]),t}function B(e,t){for(let n of t)ke[n.predicate.id]?.call(e,e,n.object);return e.label=e.name?.value||E(t,e.config.languages),e.label||=e.path?O(e.path,P):`unknown`,e}function Me(e,t){let n=t,r=e;for(let e in t)if(e!==`parent`&&e!==`config`&&e!==`id`){let t=n[e];if(t!==void 0&&t!==``)if(Array.isArray(t)){let n=r[e];Array.isArray(n)?n.push(...t):r[e]=[...t]}else if(t instanceof Set&&t.size){let n=r[e];r[e]=new Set([...n instanceof Set?n:[],...t])}else r[e]=t}}var Ne=`modulepreload`,Pe=function(e){return`/`+e},Fe={},V=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Pe(t,n),t=s(t),t in Fe)return;Fe[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Ne,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function H(e,t,n){let r=document.createElement(`div`);r.classList.add(`shacl-or-constraint`),r.setAttribute(`part`,`constraint`);let i=[];if(t instanceof $){let a=[],o=!1;e.length&&(o=n.store.countQuads(e[0],S,null,null)>0);for(let r=0;r<e.length;r++)if(o){let o=n.store.getObjects(e[r],S,null),s=[],c=``;for(let e of o){let r=new K(n.getPropertyTemplate(e,t.template),t);s.push(r),c+=(c.length>0?` / `:``)+r.template.label}a.push(s),i.push({label:c,value:r.toString()})}else{let o=e[r],s=new K(n.getPropertyTemplate(o,t.template),t);a.push([s]),i.push({label:s.template.label,value:r.toString()})}let s=n.theme.createListEditor(`Please choose`,null,!1,i);s.setAttribute(`part`,`constraint-editor`);let c=s.querySelector(`.editor`);c.onchange=async()=>{if(c.value){let e=a[parseInt(c.value)];if(n.queryMode){let{activateNodeConstraintOption:t}=await V(async()=>{let{activateNodeConstraintOption:e}=await import(`./mode-BriAnl-6.js`);return{activateNodeConstraintOption:e}},[]);await t(e,r);return}let i;if(e.length){for(let n of e)await n.bindValues(t.nodeId,!1);i=e[0],r.replaceWith(e[0]),i.updateControls()}for(let t=1;t<e.length;t++)i.after(e[t]),i=e[t],i.updateControls()}},r.appendChild(s)}else{let a=[];for(let t=0;t<e.length;t++){let r=n.store.getQuads(e[t],null,null,null);if(r.length){a.push(r);let e=E(r,n.languages);for(let t of r)t.predicate.equals(ce)&&(e=E(n.store.getQuads(t.object,null,null,null),n.languages));i.push({label:e||O(r[0].predicate.value,P)+` = `+O(r[0].object.value,P),value:t.toString()})}}let o=n.theme.createListEditor(t.template.label+`?`,null,!1,i,t.template);o.setAttribute(`part`,`constraint-editor`);let s=o.querySelector(`.editor`);s.onchange=async()=>{if(s.value){let e=B(z(t.template),a[parseInt(s.value)]);if(n.queryMode){let{activatePropertyConstraintOption:n}=await V(async()=>{let{activatePropertyConstraintOption:e}=await import(`./mode-BriAnl-6.js`);return{activatePropertyConstraintOption:e}},[]);await n(e,t,r);return}let i=await q(e,void 0,!0),o=i.querySelector(`:scope > label`);o&&o.classList.add(`persistent`),r.replaceWith(i)}},r.appendChild(o)}return r}function Ie(e,t,n){if(t.termType===`Literal`){let r=t.datatype;for(let t of e){let e=n.store.getQuads(t,null,null,null);for(let t of e)if(t.predicate.value===`http://www.w3.org/ns/shacl#datatype`&&t.object.equals(r))return e}}else{let r=n.store.getObjects(t,v,null);for(let t of e){let e=n.store.getQuads(t,null,null,null);for(let t of e)if(r.length>0){if(t.predicate.value===`http://www.w3.org/ns/shacl#node`){for(let i of r)if(n.store.getQuads(t.object,w,i,null).length>0)return e}if(t.predicate.equals(C)){for(let n of r)if(t.object.equals(n))return e}}else if(t.predicate.equals(le)&&t.object.equals(se))return e}}return console.error(`couldn't resolve sh:or/sh:xone on property for value`,t),[]}function Le(e,t,n){for(let r of e){let e=!1,i=n.store.getObjects(r,S,null);for(let r of i){let i=n.store.getObjects(r,`${f}path`,null);for(let r of i)if(e=n.store.countQuads(t,r,null,null)>0,e)break}if(e)return i}return console.error(`couldn't resolve sh:or/sh:xone on node for value`,t),[]}var Re=`:host {
2
+ --shacl-font-family: inherit;
3
+ --shacl-font-size: 14px;
4
+ --shacl-text-color: #333;
5
+ --shacl-muted-color: #555;
6
+ --shacl-border-color: #DDD;
7
+ --shacl-bg: #FFF;
8
+ --shacl-row-alt-bg: #F8F8F8;
9
+ --shacl-error-color: #C00;
10
+ --shacl-label-width: 8em;
11
+ }
12
+ form { display:block; --label-width: var(--shacl-label-width, 8em); --caret-size: 10px; font-family: var(--shacl-font-family); font-size: var(--shacl-font-size); color: var(--shacl-text-color); background-color: var(--shacl-bg); }
13
+ form.mode-edit { padding-left: 1em; }
14
+ form, form * { box-sizing: border-box; }
15
+ shacl-node, .collapsible::part(content) { display: flex; flex-direction: column; width: 100%; position: relative; }
16
+ shacl-node .remove-button { margin-top: 1px; }
17
+ shacl-node .add-button-wrapper { display: flex; width: 100%; justify-content: flex-end; gap: 20px; padding-right: 24px; color: var(--shacl-muted-color); font-size: 14px; }
18
+ shacl-node .add-button::part(button)::before { content: '+ ' }
19
+ shacl-node .link-button::part(button)::before { content: '🔗 '; font-size: 10px; }
20
+ shacl-node h1 { font-size: 16px; border-bottom: 1px solid #AAA; margin-top: 4px; color: var(--shacl-muted-color); }
21
+ shacl-property:not(:has(>.collapsible)), shacl-property>.collapsible::part(content) { display: flex; flex-direction: column; align-items: end; position: relative; }
22
+ shacl-property:not(.may-add) > .add-button-wrapper, shacl-property:not(.may-add) > .collapsible > .add-button-wrapper { display: none; }
23
+ shacl-property:not(.may-remove) > .property-instance > .remove-button-wrapper > .remove-button:not(.persistent) { visibility: hidden; }
24
+ shacl-property:not(.may-remove) > .collapsible > .property-instance > .remove-button-wrapper > .remove-button:not(.persistent) { visibility: hidden; }
25
+ shacl-property:not(.may-remove) > .shacl-or-constraint > .remove-button-wrapper > .remove-button:not(.persistent) { visibility: hidden; }
26
+ .mode-view .shacl-group:not(:has(shacl-property)) { display: none; }
27
+ .property-instance, .shacl-or-constraint { display: flex; align-items: flex-start; padding: 4px 0; width: 100%; position: relative; }
28
+ .shacl-or-constraint > div { display: flex; align-items: flex-start; }
29
+ .shacl-or-constraint > div:first-child { flex-grow: 1 }
30
+ .shacl-or-constraint label { display: inline-block; word-break: break-word; width: var(--label-width); line-height: 1em; padding-top: 0.15em; padding-right: 1em; flex-shrink: 0; position: relative; }
31
+ .property-instance label[title] { cursor: help; text-decoration: underline dashed #AAA; }
32
+ .property-instance.linked label:after, label.linked:after { content: '\\1F517'; font-size: 0.6em; position: absolute; top: 3px; right: 3px; }
33
+ .mode-edit .property-instance label.required::before, .add-button-wrapper.required > .add-button::before, .add-button-wrapper.required > .link-button::before { color: var(--shacl-error-color); content: '\\2736'; font-size: 0.6rem; position: absolute; left: -1.4em; }
34
+ .mode-edit .add-button-wrapper.required > .add-button::before, .add-button-wrapper.required > .link-button::before { left: -0.5em; }
35
+ .mode-edit .property-instance label.required::before { top: 0.15rem; }
36
+ .property-instance.valid::before { content: ''; position: absolute; left: calc(var(--label-width) - 1em); top:0.5em; width: 0.9em; height: 0.9em; background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 1024 1024" fill="green" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M866.133333 258.133333L362.666667 761.6l-204.8-204.8L98.133333 618.666667 362.666667 881.066667l563.2-563.2z"/></svg>'); }
37
+ .editor:not([type='checkbox']) { flex-grow: 1; }
38
+ textarea.editor { resize: vertical; }
39
+ .lang-chooser { border: 0; background-color: #e9e9ed; padding: 2px 4px; align-self: flex-start; }
40
+ .validation-error { position: absolute; left: calc(var(--label-width) - 1em); color: var(--shacl-error-color); cursor: help; }
41
+ .validation-error::before { content: '\\26a0' }
42
+ .validation-error.node { left: -1em; }
43
+ .invalid > .editor { border-color: red !important; }
44
+ .ml-0 { margin-left: 0 !important; }
45
+ .pr-0 { padding-right: 0 !important; }
46
+ .mode-view .property-instance:not(:first-child) > label { visibility: hidden; }
47
+ .mode-view .property-instance label { width: var(--label-width); }
48
+
49
+ .d-flex { display: flex; }
50
+ .lang { opacity: 0.65; font-size: 0.6em; }
51
+ a, a:visited { color: inherit; }
52
+ h3 { margin-top: 0; }
53
+
54
+ .fadeIn, .fadeOut { animation: fadeIn 0.2s ease-out; }
55
+ .fadeOut { animation-direction: reverse; animation-timing-function: ease-out;}
56
+ @keyframes fadeIn {
57
+ 0% { opacity: 0; transform: scaleY(0.8); }
58
+ 100% { opacity: 1; transform: scaleY(1); }
59
+ }
60
+ .collapsible::part(label) { font-weight: 600; }
61
+ .collapsible > .property-instance:nth-child(even) { background-color: var(--shacl-row-alt-bg); }
62
+ .collapsible > .property-instance > shacl-node > h1 { display: none; }
63
+ .ref-link { cursor: pointer; }
64
+ .ref-link:hover { text-decoration: underline; }
65
+ .node-id-display { color: var(--shacl-muted-color); font-size: 11px; }
66
+ /* hierarchy colors */
67
+ .colorize { --hierarchy-color-width: 3px; padding: 0 1px 0 calc(1px + var(--hierarchy-color-width)); align-self: stretch; position: relative; }
68
+ .colorize::before {
69
+ content: '';
70
+ position: absolute;
71
+ width: var(--hierarchy-color-width);
72
+ top: 0; bottom: 0; left: 0;
73
+ --index: mod(var(--hierarchy-level), var(--hierarchy-colors-length));
74
+ background: linear-gradient(var(--hierarchy-colors)) no-repeat 0 calc(var(--index) * 100% / (var(--hierarchy-colors-length) - 1)) / 100% calc(1px * infinity);
75
+ }
76
+ .property-instance:not(:has(shacl-node)) > .colorize::before { background: 0; }
77
+ .colorize:not(:has(.remove-button)) { padding-left: calc(8px + var(--hierarchy-color-width)); }
78
+ .mode-view .property-instance > .colorize { order: -1; }
79
+ .link-option { padding: 10px; }
80
+ .link-option:hover { background-color: #F5F5F5; cursor: pointer; }
81
+ rokit-dialog.link-chooser::part(dialog) { min-height: min(434px, 90vh); width: min(90vw, 600px); }
82
+ rokit-select::part(facet-count)::after { content: attr(data-count); color: var(--shacl-muted-color); display: inline-block; font-family: monospace; margin-left: 7px; font-size: 12px; }
83
+ `,ze=class{constructor(e){this.dense=!0;let t=Re;e&&(t+=`
84
+ `+e),this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(t)}apply(e){}setDense(e){this.dense=e}createViewer(e,r,i){let a=document.createElement(`div`),o=document.createElement(`label`);o.textContent=`${e}:`,i.description&&o.setAttribute(`title`,i.description.value),a.appendChild(o);let s=r.value,c=null;if(r instanceof n){let e=i.config.store.getQuads(s,null,null,null);if(e.length){let t=E(e,i.config.languages);t&&(s=t)}}else r instanceof t&&(r.language?(c=document.createElement(`span`),c.classList.add(`lang`),c.innerText=`@${r.language}`):r.datatype.value===`http://www.w3.org/2001/XMLSchema#date`?s=new Date(Date.parse(r.value)).toDateString():r.datatype.value===`http://www.w3.org/2001/XMLSchema#dateTime`&&(s=new Date(Date.parse(r.value)).toLocaleString()));let l;return A(r.value)?(l=document.createElement(`a`),l.setAttribute(`href`,r.value)):l=document.createElement(`div`),l.classList.add(`d-flex`),l.innerText=s,c&&l.appendChild(c),a.appendChild(l),a}};function Be(e,n,r){if(r){let r=R(e)>0;if(e.class&&!e.hasValue)return e.config.theme.createListEditor(e.label,n,r,k(e.class,e),e);if(e.in){let t=e.config.lists[e.in];if(t?.length){let i=D(t,e.config.store,e.config.languages);return e.config.theme.createListEditor(e.label,n,r,i,e)}else console.error(`list not found:`,e.in,`existing lists:`,e.config.lists)}if(e.datatype?.equals(y)||e.languageIn?.length||e.datatype===void 0&&n instanceof t&&n.language)return e.config.theme.createLangStringEditor(e.label,n,r,e);switch(e.datatype?.value.replace(m,``)){case`integer`:case`float`:case`double`:case`decimal`:return e.config.theme.createNumberEditor(e.label,n,r,e);case`date`:case`dateTime`:return e.config.theme.createDateEditor(e.label,n,r,e);case`boolean`:return e.config.theme.createBooleanEditor(e.label,n,r,e);case`base64Binary`:return e.config.theme.createFileEditor(e.label,n,r,e)}return e.config.theme.createTextEditor(e.label,n,r,e)}else return n?e.config.theme.createViewer(e.label,n,e):document.createElement(`div`)}function Ve(e,t,n){if(t===`application/ld+json`)return He(e);{let r=new a({format:t,prefixes:n});r.addQuads(e);let i=``;return r.end((e,t)=>{e&&console.error(e),i=t}),i}}function He(e){let n=[];for(let r of e){let e={"@id":r.subject.id};if(r.predicate===v)e[`@type`]=r.object.id;else{let n=r.object.value;r.object instanceof t?r.object.language?n={"@language":r.object.language,"@value":r.object.value}:r.object.datatype&&r.object.datatype.value!==`http://www.w3.org/2001/XMLSchema##string`&&(n={"@type":r.object.datatype.value,"@value":r.object.value}):n={"@id":r.object.id},e[r.predicate.value]=n}n.push(e)}return JSON.stringify(n)}function Ue(t){let r=t.shaclDatatype,i=t.dataset.value||t.value;if((t.type===`file`||t.getAttribute(`type`)===`file`)&&t.binaryData)i=t.binaryData;else if(t.type===`checkbox`||t.getAttribute(`type`)===`checkbox`)return t.checked||parseInt(t.dataset.minCount||`0`)>0?e.literal(t.checked?`true`:`false`,r):void 0;if(i){if(i.startsWith(`<`)&&i.endsWith(`>`)&&i.indexOf(`:`)>-1)return e.namedNode(i.substring(1,i.length-1));if(t.dataset.class||t.dataset.nodeKind===`http://www.w3.org/ns/shacl#IRI`)return e.namedNode(i);if(t.dataset.link)return JSON.parse(t.dataset.link);if(t.dataset.lang)r=t.dataset.lang;else if(r instanceof n&&me.has(r.value)){let e=We(i);if(e===void 0)return;i=e}else t.type===`number`?i=parseFloat(i):t.type===`datetime-local`?i=we(i,t.dataset.xsdTemporalSuffix):t.type===`date`&&r instanceof n&&r.value===`http://www.w3.org/2001/XMLSchema#date`&&(i=Ce(i,t.dataset.xsdTemporalSuffix));if((!r||r instanceof n&&ue.equals(r))&&typeof i==`string`){let t=i.split(`^^`);t.length===2&&t[0].startsWith(`"`)&&t[0].endsWith(`"`)&&t[1].split(`:`).length===2?(i=t[0].substring(1,t[0].length-1),r=e.namedNode(t[1])):(t=i.split(`@`),t.length===2&&t[0].startsWith(`"`)&&t[0].endsWith(`"`)?(i=t[0].substring(1,t[0].length-1),r=t[1]):i.startsWith(`"`)&&i.endsWith(`"`)&&(i=i.substring(1,i.length-1)))}return e.literal(i,r)}}function We(e){let t=e.replace(`,`,`.`);return/^[-+]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][-+]?[0-9]+)?$/.test(t)?t:void 0}var U={};function Ge(e){e.predicate===void 0&&e.datatype===void 0?console.warn(`not registering plugin because it does neither define "predicate" nor "datatype"`,e):U[`${e.predicate}^${e.datatype}`]=e}function Ke(){return Object.entries(U).map(e=>e[1])}function qe(e,t){let n=U[`${e}^${t}`];return n||(n=U[`${e}^undefined`],n)?n:U[`undefined^${t}`]}var Je=class{constructor(e,t){this.predicate=e.predicate,this.datatype=e.datatype,t&&(this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(t))}createViewer(e,t){return e.config.theme.createViewer(e.label,t,e)}};function Ye(e){let t=new Set;for(let n of e.getQuads(null,b,null,_))n.subject.termType===`NamedNode`&&t.add(n.subject.value);if(t.size===1)return t.values().next().value}function Xe(t,n){let r=e.namedNode(n);for(let e of t.getObjects(r,b,_))if(e.termType===`NamedNode`&&t.getQuads(e,v,oe,null).length>0)return e}async function Ze(e){let t={store:new r,importedUrls:[],atts:e},n=[];if(e.shapes?n.push(W(F({rdf:e.shapes}),t,g)):e.shapesUrl&&n.push(W(F({url:e.shapesUrl,proxy:t.atts.proxy,rdfUrlResolver:t.atts.rdfUrlResolver}),t,g)),e.values?n.push(W(F({rdf:e.values}),t,_)):e.valuesUrl&&n.push(W(F({url:e.valuesUrl,proxy:t.atts.proxy,rdfUrlResolver:t.atts.rdfUrlResolver}),t,_)),await Promise.all(n),e.classInstanceProvider)try{let n=Te(t.store),r=await e.classInstanceProvider(n);r&&await W(F({rdf:r}),t,g)}catch(e){console.error(`failed loading class instances`,e)}if(e.valuesSubject||=Ye(t.store)||null,e.valuesSubject&&t.store.countQuads(null,null,null,g)===0){let n=[...t.store.getObjects(e.valuesSubject,v,_),...t.store.getObjects(e.valuesSubject,b,_)],r=[];for(let e of n){let n=Qe(e.value);!n&&e.value.startsWith(`urn:`)&&t.atts.proxy&&(n=e.value),n&&t.importedUrls.indexOf(n)<0&&(t.importedUrls.push(n),r.push(W(F({url:n,proxy:t.atts.proxy,rdfUrlResolver:t.atts.rdfUrlResolver}),t,g)))}try{await Promise.allSettled(r)}catch(e){console.warn(e)}}return t.store}async function W(t,n,r){let i=await t,a=[];for(let t of i){let i=r;if(n.atts.valuesSubject&&_.equals(r)&&t.graph.id&&t.graph.id!==n.atts.valuesSubject&&(i=t.graph),n.store.add(e.quad(t.subject,t.predicate,t.object,i)),n.atts.loadOwlImports&&x.equals(t.predicate)){let r=Qe(t.object.value);r&&n.importedUrls.indexOf(r)<0&&(n.importedUrls.push(r),a.push(W(F({url:r,proxy:n.atts.proxy,rdfUrlResolver:n.atts.rdfUrlResolver}),n,e.namedNode(r))))}}await Promise.allSettled(a)}function Qe(e){if(A(e))return e;let t=e.split(`:`);if(t.length===2){let n=P[t[0]];if(n&&(e=e.replace(`${t[0]}:`,n),A(e)))return e}return null}async function $e(e){if(e.template.nodeShapes.size===0)return;let t=e.template.config.resourceLinkProvider;if((!t||t&&!t.lazyLoad)&&(await rt(e.template),tt(e).length===0))return;let n=e.template.config.theme.createButton(e.template.label,!1);n.title=`Link existing `+e.template.label,n.classList.add(`link-button`),n.setAttribute(`text`,``);let r=n.getAttribute(`part`);return n.setAttribute(`part`,`${r?r+` `:``}link-button`),n.addEventListener(`click`,async()=>{t?.lazyLoad&&(n.classList.add(`loading`),await rt(e.template),n.classList.remove(`loading`));let r=tt(e);if(r.length===0)n.innerText=`No linkable resources found`,n.setAttribute(`disabled`,``),setTimeout(()=>n.remove(),2e3);else{let t=e.template.config.form.querySelector(`#dialog`);t||(t=new u,t.classList.add(`link-chooser`),t.closable=!0,e.template.config.form.appendChild(t)),t.title=`Link existing `+e.template.label,et(t,e,r),t.open=!0}}),n}function et(e,t,n){let r=document.createElement(`div`);for(let i of n){let n=document.createElement(`div`);n.classList.add(`link-option`),n.title=`Link this resource`,n.innerText=i.label||i.value,n.addEventListener(`click`,()=>{nt(i.value,t),e.open=!1}),r.appendChild(n)}e.replaceChildren(r)}function tt(t){let n=[];if(t.template.config.resourceLinkProvider){for(let r of t.template.nodeShapes)if(t.template.config.providedConformingResourceIds[r.id.value])for(let i of t.template.config.providedConformingResourceIds[r.id.value])t.querySelector(`:scope > .property-instance > shacl-node[data-node-id='${i}'], :scope > .collapsible > .property-instance > shacl-node[data-node-id='${i}']`)===null&&n.push({value:i,label:t.template.config.providedResourceLabels[i]||E(t.template.config.store.getQuads(e.namedNode(i),null,null,null),t.template.config.languages),children:[]})}return n}async function nt(t,n){let r=e.namedNode(t);if(n.template.config.providedResources[t]?.length>0){let e={store:n.template.config.store,importedUrls:[],atts:{loadOwlImports:!1}};await W(F({rdf:n.template.config.providedResources[t]}),e,g),n.template.config.providedResources[t]=``}let i=await q(n.template,r,!0,!0);n.container.insertBefore(i,n.querySelector(`:scope > .add-button-wrapper`)),await n.updateControls()}async function rt(e){let t=e.config.resourceLinkProvider;if(!t)return;let n=new Set(Array.from(e.nodeShapes).map(e=>e.id.value));if(n.size===0)return;let r=Ee(Object.keys(e.config.providedConformingResourceIds),n);if(r.length!==0)try{let n=await t.listConformingResources(r,e);if(n){for(let t of Object.keys(n)){let r=new Set(n[t]);e.config.providedConformingResourceIds[t]=r,await it(r,!1,e.config)}for(let t of r)e.config.providedConformingResourceIds[t]||(e.config.providedConformingResourceIds[t]=new Set)}}catch(e){console.error(`failed loading conforming resources`,e)}}async function it(e,t,n){if(n.resourceLinkProvider&&e.size>0){let r=[];for(let t of e)n.providedResources[t]||r.push(t);if(r.length===0)return[];try{let e=await n.resourceLinkProvider.loadResources(r);if(e){let r={store:n.store,importedUrls:[],atts:{loadOwlImports:!1}};for(let i of e){n.providedResources[i.resourceId]=i.resourceRDF;let e=await F({rdf:i.resourceRDF});n.providedResourceLabels[i.resourceId]=E(e.filter(e=>e.subject.value===i.resourceId),n.languages),t&&await W(Promise.resolve(e),r,g)}return e}for(let e of r)n.providedResources[e]||(n.providedResources[e]=``)}catch(e){console.error(`failed loading resources`,e)}}return[]}async function at(e){let t=new Set;for(let n of e.store.getQuads(null,null,null,_))ot(n.object,e.store)&&t.add(n.object.value);await it(t,!0,e)}function ot(e,t){return e.termType===`NamedNode`&&t.countQuads(e,null,null,null)===0}var G=`:scope > .add-button-wrapper, :scope > .collapsible > .add-button-wrapper`,st=`:scope > .property-instance, :scope > .shacl-or-constraint, :scope > shacl-node, :scope > .collapsible > .property-instance`,K=class extends HTMLElement{constructor(e,t){if(super(),this.template=e,this.parent=t,this.container=this,this.setAttribute(`part`,`property`),this.template.nodeShapes.size&&this.template.config.attributes.collapse!==null&&(this.template.maxCount===void 0||this.template.maxCount>1)){let t=new l;t.classList.add(`collapsible`,`shacl-group`),t.open=e.config.attributes.collapse===`open`,t.label=this.template.label,t.setAttribute(`part`,`collapsible`),this.container=t,this.appendChild(this.container)}this.template.order!==void 0&&(this.style.order=`${this.template.order}`),this.template.cssClass&&this.classList.add(this.template.cssClass),e.config.editMode&&!t.linked&&this.addEventListener(`change`,async()=>{await this.updateControls()})}async bindValues(e,t){if(this.template.path){let n=!1;if(e){let r=this.template.config.store.getQuads(e,this.template.path,null,this.parent.linked?null:_);t&&(r=await this.filterValidValues(r,e));for(let e of r)this.parent.linked||this.template.config.store.delete(e),await this.addPropertyInstance(e.object,!_.equals(e.graph)||this.template.config.providedResources[e.object.value]!==void 0,this.template.config.providedResources[e.object.value]!==void 0),this.template.hasValue&&e.object.equals(this.template.hasValue)&&(n=!0)}this.template.config.editMode&&this.template.hasValue&&!n&&!this.parent.linked&&await this.addPropertyInstance(this.template.hasValue)}}async initializeQuery(){let{initializeQueryProperty:e}=await V(async()=>{let{initializeQueryProperty:e}=await import(`./mode-BriAnl-6.js`);return{initializeQueryProperty:e}},[]);await e(this)}async addPropertyInstance(e,t,n=!1){let r;if(this.template.or?.length||this.template.xone?.length){let t=this.template.or?.length?this.template.or:this.template.xone,n=!1;if(e){let i=Ie(t,e,this.template.config);i.length&&(r=await q(B(z(this.template),i),e,!this.parent.linked,this.parent.linked,this.parent),n=!0)}!n&&this.template.config.editMode&&(r=H(t,this,this.template.config),ct(r,``,this.template.config.theme.dense,this.template.config.hierarchyColorsStyleSheet!==void 0))}else r=await q(this.template,e,n,t||this.parent.linked,this.parent);return r&&this.container.insertBefore(r,this.querySelector(G)),r}async updateControls(){this.template.config.editMode&&!this.parent.linked&&!this.querySelector(G)&&this.container.appendChild(await this.createAddControls());let e=R(this.template),t=this.template.nodeShapes.size===0,n=this.querySelector(`:scope > .add-button-wrapper > .link-button, :scope > .collapsible > .add-button-wrapper > .link-button`)===null,r=t||!this.hasRecursiveNodeShape(),i=this.instanceCount();i===0&&r&&(t||n&&e>0)&&(await this.addPropertyInstance(),i=1),t||this.querySelector(G)?.classList.toggle(`required`,i<e);let a;a=e>0?i>e:!t||i>1;let o=i<je(this.template);this.classList.toggle(`may-remove`,a),this.classList.toggle(`may-add`,o)}instanceCount(){return this.querySelectorAll(st).length}hasRecursiveNodeShape(){let e=new Set;this.parent.ancestorShapeIds.forEach(t=>e.add(t)),e.add(this.parent.template.id.value);for(let t of this.template.nodeShapes)if(e.has(t.id.value))return!0;return!1}toRDF(t,n){let r=e.namedNode(this.template.path);for(let e of this.querySelectorAll(`:scope > .property-instance, :scope > .collapsible > .property-instance`))if(e.firstChild instanceof $){let i=e.firstChild.toRDF(t);t.addQuad(n,r,i,this.template.config.valuesGraphId)}else if(this.template.config.editMode)for(let i of e.querySelectorAll(`:scope > .editor`)){let e=Ue(i);e&&t.addQuad(n,r,e,this.template.config.valuesGraphId)}else{let i=Ue(e);i&&t.addQuad(n,r,i,this.template.config.valuesGraphId)}}async filterValidValues(e,t){let n=this.template.id,r=[t];if(this.template.qualifiedValueShape){n=this.template.qualifiedValueShape.id,r=[];for(let t of e)r.push(t.object)}let i=await this.template.config.validator.validate({dataset:this.template.config.store,terms:r},[{terms:[n]}]),a=new Set;for(let e of i.results){let t=this.template.qualifiedValueShape?e.focusNode:e.value;t?.ptrs?.length&&a.add(t.ptrs[0]._term.id)}return e.filter(e=>!a.has(e.object.id))}async createAddControls(){let e=document.createElement(`div`);e.classList.add(`add-button-wrapper`),e.setAttribute(`part`,`add-controls`);let t=await $e(this);t&&e.appendChild(t);let n=this.template.config.theme.createButton(this.template.label,!1);n.title=`Add `+this.template.label,n.classList.add(`add-button`),n.setAttribute(`text`,``);let r=n.getAttribute(`part`);return n.setAttribute(`part`,`${r?r+` `:``}add-button`),n.addEventListener(`click`,async()=>{let e=await this.addPropertyInstance();e&&(e.classList.add(`fadeIn`),await this.updateControls(),setTimeout(()=>{ge(e),e.classList.remove(`fadeIn`)},200))}),e.appendChild(n),e}};async function q(e,n,r=!1,i=!1,a){let o;if(e.nodeShapes.size){o=document.createElement(`div`),o.classList.add(`property-instance`),o.setAttribute(`part`,`property-instance`);let t=new Set(a?.ancestorShapeIds??[]);a&&t.add(a.template.id.value);for(let r of e.nodeShapes){let a=new $(r,n,e.nodeKind,e.label,i,t);o.appendChild(a),await a.ready}}else{let t=qe(e.path,e.datatype?.value);o=t?e.config.editMode&&!i?t.createEditor(e,n):t.createViewer(e,n):Be(e,n||null,e.config.editMode&&!i),o.childNodes.length>0&&(o.classList.add(`property-instance`),o.setAttribute(`part`,`property-instance`)),i&&o.classList.add(`linked`)}return e.config.editMode&&(!i||r)?ct(o,e.label,e.config.theme.dense,e.config.hierarchyColorsStyleSheet!==void 0,r):e.config.hierarchyColorsStyleSheet!==void 0&&o.appendChild(J(!0)),n&&!e.config.editMode&&(n instanceof t?(o.dataset.value=n.value,n.language.length>0?o.dataset.lang=n.language:o.shaclDatatype=n.datatype):o.dataset.value=`<`+n.value+`>`),o.dataset.path=e.path,o}function ct(e,t,n,r,i=!1){let a=J(r),o=new c;o.classList.add(`remove-button`,`clear`),o.title=`Remove `+t,o.dense=n,o.icon=!0;let s=o.getAttribute(`part`);o.setAttribute(`part`,`${s?s+` `:``}remove-button`),o.addEventListener(`click`,()=>{e.classList.remove(`fadeIn`),e.classList.add(`fadeOut`),setTimeout(()=>{let t=e.parentElement;e.remove(),t?.dispatchEvent(new Event(`change`,{bubbles:!0,cancelable:!0}))},200)}),i&&o.classList.add(`persistent`),a.appendChild(o),e.appendChild(a)}function J(e){let t=document.createElement(`div`);return t.className=`remove-button-wrapper`,t.setAttribute(`part`,`remove-controls`),e&&t.classList.add(`colorize`),t}window.customElements.define(`shacl-property`,K);function lt(e,t){let n=e,r=t.store.getQuads(e,null,null,null),i=T(r,`label`,ee,t.languages);i&&(n=i);let a;if(t.attributes.collapse!==null)a=new l,a.classList.add(`collapsible`),a.open=t.attributes.collapse===`open`,a.label=n,a.setAttribute(`part`,`group collapsible`);else{a=document.createElement(`div`);let e=document.createElement(`h1`);e.innerText=n,e.setAttribute(`part`,`group-title`),a.appendChild(e),a.setAttribute(`part`,`group`)}a.dataset.subject=e,a.classList.add(`shacl-group`);let o=T(r,`order`);return o&&(a.style.order=o),a}var ut={[`${f}node`]:(e,t)=>{e.extendedShapes.add(new Y(t,e.config,e))},[`${f}and`]:(e,t)=>{for(let n of e.config.lists[t.value])e.extendedShapes.add(new Y(n,e.config,e))},[`${f}property`]:(e,t)=>{let n=e.config.getPropertyTemplate(t,e);if(n.path){let t=e.properties[n.path];if(t||(t=[],e.properties[n.path]=t),n.qualifiedValueShape)t.push(n);else{let r;for(let t=0;t<e.properties[n.path].length&&!r;t++)e.properties[n.path][t].qualifiedValueShape||(r=e.properties[n.path][t]);r?Me(r,n):t.push(n)}}},[`${f}nodeKind`]:(e,t)=>{e.nodeKind=t},[`${f}targetClass`]:(e,t)=>{e.targetClass=t},[`${f}or`]:(e,t)=>{e.or=e.config.lists[t.value]},[`${f}xone`]:(e,t)=>{e.xone=e.config.lists[t.value]},[x.id]:(e,t)=>{e.owlImports.add(t)},[`${ne}title`]:(e,t)=>{let n=t;e.label=j(e.config.languages,e.label,n)},[`${ee}label`]:(e,t)=>{let n=t;e.label=j(e.config.languages,e.label,n)}},Y=class{constructor(e,t,n){this.extendedShapes=new Set,this.properties={},this.owlImports=new Set,this.merged=!1,this.id=e,this.config=t,this.parent=n,t.registerNodeTemplate(this),dt(this,this.config.store.getQuads(e,null,null,null))}};function dt(e,t){for(let n of t)ut[n.predicate.id]?.call(e,e,n.object);return e}function ft(e){if(!e.merged){e.merged=!0;for(let t of Object.values(e.properties))for(let n of t){let[t,r]=Q(e,n.path),i=t.some(e=>e.qualifiedValueShape!==void 0),a=pt(t),o=i?a:r;if(t.length>1&&o){let e=t[t.length-1];for(let n=t.length-2;n>=0;n--){let r=t[n],i=a?e.qualifiedValueShape:void 0;delete r.parent.properties[r.path],Me(e,r),i&&e.nodeShapes.delete(i)}mt(e)}}}}function pt(e){if(e.length<2)return!1;for(let t=0;t<e.length-1;t++){let n=e[t],r=e[t+1];if(!n.qualifiedValueShape||!r.qualifiedValueShape||!X(n.parent,r.parent)||!X(n.qualifiedValueShape,r.qualifiedValueShape))return!1}return!0}function X(e,t){let n=[...e.extendedShapes],r=new Set;for(;n.length;){let e=n.pop();if(e.id.equals(t.id))return!0;r.has(e)||(r.add(e),n.push(...e.extendedShapes))}return!1}function mt(e){for(let t of[`xone`,`or`]){let n=e[t];if(!n?.length)continue;let r=n.filter(t=>ht(t,e));r.length>0&&r.length<n.length&&(r.length===1?(e[t]=void 0,B(e,e.config.store.getQuads(r[0],null,null,null))):e[t]=r)}}function ht(e,t){let n=t.config.store.getQuads(e,null,null,null);return Z(n,`http://www.w3.org/ns/shacl#datatype`,t.datatype)&&Z(n,C.id,t.class)&&Z(n,`http://www.w3.org/ns/shacl#nodeKind`,t.nodeKind)}function Z(e,t,n){if(!n)return!0;let r=!1;for(let i of e)if(i.predicate.value===t&&(r=!0,i.object.equals(n)))return!0;return!r}function Q(e,t,n=new Set,r=[],i=!1){if(!n.has(e.id.value)){n.add(e.id.value);let a=e.properties[t];if(a?.length===1){r.push(a[0]),i||=a[0].maxCount===1;for(let e of a[0].nodeShapes){let[a,o]=Q(e,t,n,r,i);i||=o}}for(let a of e.extendedShapes){let[e,o]=Q(a,t,n,r,i);i||=o}}return[r,i]}var $=class t extends HTMLElement{constructor(n,r,i,a,o,s=new Set,c){super(),this.template=n,this.linked=o??!1,this.ancestorShapeIds=s,this.queryContext=c,this.setAttribute(`part`,`node`);let l=r;l||=(!i&&n.nodeKind&&(i=n.nodeKind),i===void 0&&n.config.attributes.valuesNamespace||i?.value===`http://www.w3.org/ns/shacl#IRI`?e.namedNode(n.config.attributes.valuesNamespace+d()):e.blankNode(d())),this.nodeId=l;let u=JSON.stringify([n.id,r]);if(r&&n.config.renderedNodes.has(u)){a||=`Link`;let e=document.createElement(`label`);e.innerText=a,e.classList.add(`linked`),this.appendChild(e);let t=this.getAttribute(`part`);this.setAttribute(`part`,`${t?t+` `:``}linked-node`),this.dataset.nodeId=this.nodeId.id;let n=document.createElement(`a`),i=r.termType===`BlankNode`?`_:`+r.value:r.value;n.innerText=i,n.classList.add(`ref-link`),n.onclick=()=>{this.template.config.form.querySelector(`shacl-node[data-node-id='${i}']:not([part~='linked-node'])`)?.scrollIntoView()},this.appendChild(n),this.style.flexDirection=`row`,this.ready=Promise.resolve()}else{r&&n.config.renderedNodes.add(u);let e=this.ancestorShapeIds,i=this.template.id.value,s=this.queryContext;if(this.dataset.nodeId=this.nodeId.id,this.template.config.attributes.showNodeIds!==null){let e=document.createElement(`div`);e.innerText=`id: ${this.nodeId.id}`,e.classList.add(`node-id-display`),this.appendChild(e)}ft(n),this.ready=(async()=>{let c=new Set(e);c.add(i);for(let[e,t]of Object.entries(n.properties))for(let e of t)await this.addPropertyInstance(e,r,t.length>1);for(let e of n.extendedShapes){let n=new t(e,r,void 0,void 0,o,c,s);this.prepend(n),await n.ready}if(n.or?.length&&await this.tryResolve(n.or,r,n.config),n.xone?.length&&await this.tryResolve(n.xone,r,n.config),a){let e=document.createElement(`h1`);e.innerText=a,e.setAttribute(`part`,`node-title`),this.prepend(e)}})()}}toRDF(t,n,r=``){if(n||=this.nodeId,!this.linked){for(let e of this.querySelectorAll(`:scope > shacl-node, :scope > .shacl-group > shacl-node, :scope > shacl-property, :scope > .shacl-group > shacl-property`))e.toRDF(t,n);this.template.targetClass&&t.addQuad(n,v,this.template.targetClass,this.template.config.valuesGraphId),r&&t.addQuad(n,e.namedNode(r),this.template.id,this.template.config.valuesGraphId)}return n}async addPropertyInstance(e,t,n){let r=null;if(e.group)if(e.config.groups.indexOf(e.group)>-1){let t=this.querySelector(`:scope > .shacl-group[data-subject='${e.group}']`);t||(t=lt(e.group,e.config),this.appendChild(t)),r=t}else console.warn(`ignoring unknown group reference`,e.group,`existing groups:`,e.config.groups);let i=new K(e,this);e.config.queryMode?await i.initializeQuery():await i.bindValues(t,n),(e.config.editMode||e.config.queryMode||i.instanceCount()>0)&&(r?r.appendChild(i):this.appendChild(i),e.config.queryMode||await i.updateControls())}async tryResolve(e,t,n){let r=!1;if(t){let i=Le(e,t,n);if(i.length){for(let e of i)await this.addPropertyInstance(n.getPropertyTemplate(e,this.template),t);r=!0}}r||this.appendChild(H(e,this,n))}};window.customElements.define(`shacl-node`,$);function gt(e){return e.datatype!==void 0&&fe.has(e.datatype)}export{D as A,pe as B,ke as C,L as D,F as E,Se as F,se as G,m as H,xe as I,g as J,oe as K,_ as L,ve as M,k as N,P as O,E as P,b as R,z as S,I as T,y as U,f as V,v as W,de as Y,ze as _,K as a,Ae as b,Xe as c,Ze as d,Je as f,Ve as g,Ge as h,ft as i,De as j,N as k,Ye as l,Ke as m,$ as n,J as o,qe as p,w as q,Y as r,at as s,gt as t,W as u,H as v,B as w,R as x,V as y,me as z};
package/dist/bundle.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import './form';
2
2
  import './plugins/file-upload';
3
3
  import './plugins/leaflet';
4
- export * from './form';
5
- export * from './plugins/file-upload';
6
- export * from './plugins/leaflet';
4
+ export * from './form.js';
5
+ export * from './plugins/file-upload.js';
6
+ export * from './plugins/leaflet.js';