@ulb-darmstadt/shacl-form 3.2.1 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # SHACL Form Generator
2
- An HTML5 web component to edit and view [RDF](https://www.w3.org/RDF/) data that conform to [SHACL shapes](https://www.w3.org/TR/shacl/).
2
+ An HTML5 web component to edit, view and query [RDF](https://www.w3.org/RDF/) data that conform to [SHACL shapes](https://www.w3.org/TR/shacl/).
3
3
 
4
4
  ## [See demo here](https://ulb-darmstadt.github.io/shacl-form/)
5
5
 
@@ -89,6 +89,7 @@ data-values-url | When `data-values` is not set, load RDF triples from this URL
89
89
  data-values-subject | Subject (IRI or blank node id) for generated data. If not set, a blank node with a new UUID is created. If `data-values` or `data-values-url` is set, this id is used to find the root node in the data graph. When exactly one `dcterms:conformsTo` statement exists in the loaded data graph, its subject is used automatically. For the selected subject, a `dcterms:conformsTo` object that is a known `sh:NodeShape` is used as the root shape before falling back to `rdf:type` / `sh:targetClass`
90
90
  data-values-namespace | RDF namespace used when generating new RDF subjects. Default is empty, which yields blank nodes
91
91
  data-values-graph | If set, serialization creates a named graph with this IRI
92
+ data-preserve-unmapped-values | If set, `toRDF()` overlays the current form values onto the complete original values dataset instead of returning only SHACL-managed values. Removed form values are replaced, unrelated triples and named graphs are retained, and blank-node subgraphs orphaned by an edit are removed
92
93
  data-language | Language for `langString` values (e.g. in `sh:name` or `rdfs:label`). Default is [`navigator.language`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/language) with fallback to [`navigator.languages`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/languages)
93
94
  data-loading | Text displayed while the component initializes. Default is `"Loading..."`
94
95
  data-ignore-owl-imports | By default, `owl:imports` URLs are fetched and merged into the shapes graph. Set this attribute to disable that behavior
@@ -112,6 +113,11 @@ toRDF(graph?: Store): Store
112
113
  ```
113
114
  Writes the current form values into the given graph. If no graph is provided, a new [N3 Store](https://github.com/rdfjs/N3.js#storing) is created.
114
115
 
116
+ When `data-preserve-unmapped-values` is set, the original values dataset is added
117
+ to the destination graph first. Original values managed by rendered SHACL fields
118
+ are replaced with their current form values, while unmapped triples are retained.
119
+ The default remains projection-only serialization.
120
+
115
121
  ```typescript
116
122
  serialize(format?: string, graph?: Store): string
117
123
  ```
@@ -178,7 +184,7 @@ In edit mode, `<shacl-form>` validates the constructed data graph using [shacl-e
178
184
 
179
185
  ### Query mode
180
186
 
181
- See the [query mode guide](./src/query/query-mode.md)
187
+ See the [query mode guide](./src/query/query-mode.md) and the [demo](https://ulb-darmstadt.github.io/shacl-form/#query-mode).
182
188
 
183
189
  ### Additional RDF for the shapes graph
184
190
 
@@ -246,11 +252,11 @@ Besides `data-shapes` and `data-shapes-url`, `shacl-form` can enrich the shapes
246
252
  })
247
253
  ```
248
254
 
249
- This returns instances of `http://example.org/Material`, which populate the "Artwork material" dropdown. In a real application, the callback would often call an API or triple store.
255
+ returns instances of `http://example.org/Material`, which populate the "Artwork material" dropdown. In a real application, the callback would often call an API or triple store.
250
256
 
251
257
  ### Use of SHACL sh:class
252
258
 
253
- When a property shape has an `sh:class`, `shacl-form` scans all available graphs for matching instances so users can choose from them. `rdfs:subClassOf` is also considered when building the list of class instances.
259
+ When a property shape has an `sh:class`, `shacl-form` scans the shapes, data, and current-values graphs plus any `owl:imports` graphs visible in that shape subtree. Imports declared on sibling subtrees remain isolated. `rdfs:subClassOf` is also considered when building the list of class instances.
254
260
 
255
261
  `shacl-form` also supports class instance hierarchies modelled with `skos:broader` and/or `skos:narrower`. This is illustrated by the "Subject classification" property in the [example](https://ulb-darmstadt.github.io/shacl-form/#edit-mode).
256
262
 
@@ -278,6 +284,33 @@ When binding an existing data graph to the form, the constraint is resolved base
278
284
  - For RDF literals, an `sh:or` option with a matching `sh:datatype` is chosen
279
285
  - For blank nodes or named nodes, the `rdf:type` is matched with a node shape having a corresponding `sh:targetClass` or with a property shape having a corresponding `sh:class`. If there is no `rdf:type` but a `sh:nodeKind` of `sh:IRI`, the node id is used as the value
280
286
 
287
+ ### SHACL alternative paths
288
+
289
+ `<shacl-form>` supports `sh:alternativePath` lists whose members are predicate IRIs:
290
+
291
+ ```turtle
292
+ sh:property [
293
+ sh:path [ sh:alternativePath ( schema:name foaf:name ) ] ;
294
+ sh:name "Name"
295
+ ] .
296
+ ```
297
+
298
+ Values using any listed predicate are displayed in the same property and retain
299
+ their original predicates when serialized. When adding a value, the form first
300
+ asks which predicate to use. Predicate-specific plugins are resolved against
301
+ that selected or loaded predicate. Query mode represents the alternatives as a
302
+ single union path without showing the predicate chooser.
303
+
304
+ An alternative property may be accompanied by one direct-path sibling property
305
+ for each listed predicate. When those siblings do not define independent
306
+ cardinality constraints, they are treated as branch descriptors: only the
307
+ alternative chooser is initially rendered, and the selected sibling supplies
308
+ editor constraints such as `sh:nodeKind`, `sh:datatype`, and its label. Siblings
309
+ with their own cardinality remain independent properties.
310
+
311
+ Nested sequence, inverse, and repetition paths inside `sh:alternativePath` are
312
+ not currently supported.
313
+
281
314
  ### Linking existing data
282
315
 
283
316
  When a node shape has a `sh:targetClass` and any available graph contains instances of that class, those instances can be linked in the corresponding SHACL property. The generated data graph contains only a reference to the linked instance, not its full triples.
@@ -300,6 +333,8 @@ The RDF returned by `loadResources(...)` can use any of the [supported formats](
300
333
 
301
334
  The provider supports both eager loading during initialization and lazy loading when the user opens the link dialog. See [here](https://github.com/ULB-Darmstadt/rdf-store/blob/main/frontend/src/editor.ts#L10) for an example implementation.
302
335
 
336
+ For properties with `sh:or` or `sh:xone` node-shape alternatives, first choose the type of node to use. The selected branch then provides separate controls for creating a new node or linking a compatible node. Link candidates combine nodes already rendered elsewhere in the form with resources supplied by `ResourceLinkProvider`.
337
+
303
338
  ### SHACL shape inheritance
304
339
 
305
340
  SHACL defines two ways of inheriting shapes: [sh:and](https://www.w3.org/TR/shacl/#AndConstraintComponent) and [sh:node](https://www.w3.org/TR/shacl/#NodeConstraintComponent). `<shacl-form>` supports both. In [this example](https://ulb-darmstadt.github.io/shacl-form/#edit-mode), node shape `example:ArchitectureModelDataset` extends `example:Dataset` by defining:
@@ -0,0 +1,13 @@
1
+ import{$ as e,F as t,I as n,K as r,N as i,Q as a,U as o,a as s,b as c,ft as l,h as u,k as d,lt as f,m as p,n as m,nt as h,o as g,p as _,t as v,v as y}from"./query-Y4qLEXu3.js";function b(e,t){let n=document.createElement(`div`),r=!!(t.in||t.class||t.datatype?.equals(f));n.classList.add(`query-editor`),n.dataset.queryFieldId=e.id,n.setAttribute(`part`,`query-editor`);let i=document.createElement(`label`);i.textContent=t.label,t.description&&(i.title=t.description.value),n.appendChild(i);let a=document.createElement(`div`);a.classList.add(`query-controls`),n.appendChild(a);let o,s=k(t),c,l=(e=``)=>{let n=document.createElement(`div`);n.classList.add(`query-value-row`);let r=new p;r.classList.add(`editor`,`query-choice`),r.clearable=!0,r.dense=t.config.theme.dense,r.placeholder=``,r.setAttribute(`exportparts`,`facet-count`);let i=document.createElement(`ul`);for(let e of s){let t=document.createElement(`li`);if(t.dataset.value=P(e.term),t.textContent=e.label,e.count!==void 0){let n=document.createElement(`span`);n.classList.add(`facet-count`),n.setAttribute(`part`,`facet-count`),n.dataset.count=String(e.count),t.append(` `,n)}i.appendChild(t)}return r.appendChild(i),r.value=e,n.appendChild(r),n},d=(e=[])=>{a.replaceChildren(),a.appendChild(l(e[0]??``))},m=(e,n=``)=>{let r=new u;return r.classList.add(`editor`,`query-range-bound`),r.type=N(t),r.label=e,r.clearable=!0,r.dense=t.config.theme.dense,r.value=n,r},g=e=>{a.replaceChildren();let n=x(t,o);n&&n[0]<n[1]&&(c=n);let r=O(n,e&&c);if(!r||r[0]===r[1]){a.append(m(`Minimum`,e?.min?.value),m(`Maximum`,e?.max?.value));return}let i=new y;i.classList.add(`editor`,`query-range-slider`),i.dense=t.config.theme.dense,i.clearable=!0,i.range=``,i.setAttribute(`range`,``),i.min=String(r[0]),i.max=String(r[1]),i.step=String(S(t,r)),i.labelFormatter=e=>C(e,t);let s=e?.min?w(e.min,t):r[0],l=e?.max?w(e.max,t):r[1];i.value=JSON.stringify([D(s??r[0],r[0],r[1]),D(l??r[1],r[0],r[1])]),i.dataset.active=e?.min||e?.max?`true`:`false`,i.addEventListener(`change`,()=>{i.dataset.active=`true`}),a.appendChild(i)};return n.getQueryCriteria=()=>{if(v(e)){let n=a.querySelector(`rokit-slider`);if(n){if(n.dataset.active!==`true`)return[];let r=E(n.value);return r?[{field:e,operator:`range`,min:T(r[0],t),max:T(r[1],t)}]:[]}let r=a.querySelectorAll(`rokit-input`),i=j(r[0]?.value,t),o=j(r[1]?.value,t);return i||o?[{field:e,operator:`range`,min:i,max:o}]:[]}if(r)return Array.from(a.querySelectorAll(`rokit-select`)).flatMap(t=>{if(!t.value)return[];let n=s.find(e=>P(e.term)===t.value)?.term;return n?[{field:e,operator:`equals`,value:n}]:[]});let n=M(t)&&!t.class&&!t.nodeKind?.value.endsWith(`#IRI`)?`contains`:`equals`;return Array.from(a.querySelectorAll(`.query-value-row`)).flatMap(r=>{let i=r.querySelector(`.query-value`),a=r.querySelector(`.query-language`)?.value,o=j(i?.value,t,a);return o?[{field:e,operator:n,value:o}]:[]})},n.setQueryFacet=i=>{let c=n.getQueryCriteria();if(o=i,r&&o?.buckets){let e=new Map(k(t).map(e=>[P(e.term),e])),n=new Map(c.flatMap(e=>e.value?[[P(e.value),e.value]]:[]));s=o.buckets.flatMap(n=>{let r=e.get(P(n.value));return t.in&&!r?[]:[{term:n.value,label:n.label??r?.label??n.value.value,count:n.count}]});for(let[t,r]of n)s.some(e=>P(e.term)===t)||s.push({term:r,label:e.get(t)?.label??r.value,count:0});d([...n.keys()])}else if(v(e)){let e=c[0];g(e?{min:e.min,max:e.max}:void 0)}else if(!i)for(let e of a.querySelectorAll(`.query-value`))e.value=``},v(e)?g():r?d():(a.replaceChildren(),a.appendChild((()=>{let e=document.createElement(`div`);e.classList.add(`query-value-row`);let r=new u;r.classList.add(`editor`,`query-value`),r.type=N(t),r.clearable=!0,r.dense=t.config.theme.dense;let i;if(r.addEventListener(`input`,()=>{clearTimeout(i),i=setTimeout(()=>{n.dispatchEvent(new Event(`change`,{bubbles:!0}))},300)}),e.appendChild(r),t.datatype?.equals(h)){let n=t.languageIn?.length?document.createElement(`select`):document.createElement(`input`);if(n.classList.add(`lang-chooser`,`query-language`),n.title=`Language of the text`,n.setAttribute(`aria-label`,`Language of the text`),n instanceof HTMLSelectElement)for(let e of t.languageIn??[]){let t=document.createElement(`option`);t.value=e.value,t.textContent=e.value,n.appendChild(t)}else n.maxLength=35,n.placeholder=`lang?`,n.value=t.config.languages.find(e=>e.length>0)??``;e.appendChild(n)}return e})())),n}function x(e,t){let n=t?.min?w(t.min,e):void 0,r=t?.max?w(t.max,e):void 0,i=e.minInclusive??(e.minExclusive===void 0?void 0:e.minExclusive+1),a=e.maxInclusive??(e.maxExclusive===void 0?void 0:e.maxExclusive-1),o=n===void 0?i:i===void 0?n:Math.max(n,i),s=r===void 0?a:a===void 0?r:Math.min(r,a);return o!==void 0&&s!==void 0&&Number.isFinite(o)&&Number.isFinite(s)&&o<=s?[o,s]:void 0}function S(e,t){return e.datatype?.value===`http://www.w3.org/2001/XMLSchema#integer`?1:e.datatype?.value===`http://www.w3.org/2001/XMLSchema#date`?86400:e.datatype?.value===`http://www.w3.org/2001/XMLSchema#dateTime`?1:Math.max((t[1]-t[0])/1e3,2**-52)}function C(e,t){return t.datatype?.value===`http://www.w3.org/2001/XMLSchema#date`?_(e,!0):t.datatype?.value===`http://www.w3.org/2001/XMLSchema#dateTime`?_(e):String(Math.round(e*1e3)/1e3)}function w(e,t){if(t.datatype?.value===`http://www.w3.org/2001/XMLSchema#date`||t.datatype?.value===`http://www.w3.org/2001/XMLSchema#dateTime`){let t=Date.parse(e.value);return Number.isFinite(t)?t/1e3:void 0}let n=Number(e.value);return Number.isFinite(n)?n:void 0}function T(e,t){let n=t.datatype;return n?.value===`http://www.w3.org/2001/XMLSchema#date`?l.literal(_(e,!0),n):n?.value===`http://www.w3.org/2001/XMLSchema#dateTime`?l.literal(_(e),n):l.literal(String(e),n)}function E(e){try{let t=JSON.parse(e);return Array.isArray(t)&&t.length===2&&t.every(Number.isFinite)?[Number(t[0]),Number(t[1])]:void 0}catch{return}}function D(e,t,n){return Math.min(n,Math.max(t,e))}function O(e,t){return e&&e[0]<e[1]?e:t||e}function k(e){if(e.datatype?.equals(f))return[{term:l.literal(`true`,f),label:`true`},{term:l.literal(`false`,f),label:`false`}];let t=[];return e.in?t=o(e.config.lists[e.in]??[],e.config.store,e.config.languages):e.class&&(t=r(e.class,e)),A(t)}function A(e){return e.flatMap(e=>[...typeof e.value==`string`?[]:[{term:e.value,label:e.label||e.value.value}],...A(e.children??[])])}function j(e,t,n){if(e)return t.class||t.nodeKind?.value.endsWith(`#IRI`)?l.namedNode(e):t.datatype?.equals(h)?n?l.literal(e,n):void 0:t.datatype?l.literal(e,t.datatype):l.literal(e)}function M(e){return!e.datatype||e.datatype.value===`http://www.w3.org/2001/XMLSchema#string`||e.datatype.equals(h)}function N(e){let t=e.datatype?.value;return[`http://www.w3.org/2001/XMLSchema#integer`,`http://www.w3.org/2001/XMLSchema#float`,`http://www.w3.org/2001/XMLSchema#double`,`http://www.w3.org/2001/XMLSchema#decimal`].includes(t??``)?`number`:t===`http://www.w3.org/2001/XMLSchema#date`?`date`:t===`http://www.w3.org/2001/XMLSchema#dateTime`?`datetime-local`:`text`}function P(e){if(e.termType===`Literal`){let t=e;return`${e.termType}:${e.value}:${t.language}:${t.datatype?.value}`}return`${e.termType}:${e.value}`}var F=`form.mode-query { padding: 0; }
2
+ :host([loading]) form.mode-query > shacl-node { display: none; }
3
+ .mode-query shacl-property.query-unavailable { display: none; }
4
+ .mode-query .shacl-group:not(:has(shacl-property:not(.query-unavailable))), .mode-query shacl-node:not(:has(shacl-property:not(.query-unavailable))) { display: none; }
5
+ .query-editor { display: flex; align-items: center; width: 100%; padding: 3px 0; }
6
+ .query-editor > label { width: var(--label-width); flex-shrink: 0; padding-right: 1em; word-break: break-word; }
7
+ .query-controls { display: flex; flex: 1; min-width: 0; }
8
+ .query-controls > rokit-input, .query-controls > rokit-slider, .query-value-row > rokit-input, .query-value-row > rokit-select { min-height: 28px; width: 100%; flex-grow: 1; }
9
+ .query-value-row { display: flex; flex: 1; width: 100%; min-width: 0; gap: 4px; }
10
+ .query-language { min-height: 28px; flex: 0 0 auto; }
11
+ .query-range-slider[data-active='false'] { opacity: 0.7; }
12
+ .query-facet-error .query-editor > label { color: var(--shacl-error-color); }
13
+ `,I=0,L=class{constructor(e){this.stylesheet=new CSSStyleSheet,this.facetRequest=0,this.facetsApplied=!1,this.host=e,this.stylesheet.replaceSync(F),e.config.queryFacetProvider&&this.setFacetsPending(!0)}async initialize(){await this.emitQueryAndRefreshFacets()}handleChange(){this.emitQueryAndRefreshFacets()}getQuery(){let e=this.host.shape;return e?{rootShapeId:e.template.id.value,targetClass:e.template.targetClass?.value,criteria:Array.from(this.host.form.querySelectorAll(`.query-editor`)).flatMap(e=>e.getQueryCriteria())}:{rootShapeId:``,criteria:[]}}refreshFacets(){this.host.shape&&this.requestFacets(this.getQuery())}dispose(){this.facetAbortController?.abort(),this.setFacetsPending(!1),this.host.classList.remove(`query-facets-empty`)}async emitQueryAndRefreshFacets(){if(!this.host.shape)return;let e=this.getQuery();this.host.dispatchEvent(new CustomEvent(`query`,{bubbles:!0,composed:!0,detail:e})),await this.requestFacets(e)}async requestFacets(e){let t=this.host.config.queryFacetProvider;if(!t)return;this.facetAbortController?.abort();let n=new AbortController;this.facetAbortController=n;let r=++this.facetRequest;this.facetsApplied||this.setFacetsPending(!0);try{let i=Array.from(this.host.form.querySelectorAll(`.query-editor`)).map(e=>e.queryField),a=await t.getFacets({query:e,fields:i,signal:n.signal});if(n.signal.aborted||r!==this.facetRequest)return;this.applyFacets(a),this.facetsApplied=!0,this.setFacetsPending(!1)}catch(e){if(n.signal.aborted)return;this.setFacetsPending(!1),this.host.dispatchEvent(new CustomEvent(`queryerror`,{bubbles:!0,composed:!0,detail:e}))}}applyFacets(e){let t=new Map(e.map(e=>[e.fieldId,e]));for(let e of Array.from(this.host.form.querySelectorAll(`.query-editor`))){let n=t.get(e.queryField.id),r=e.getQueryCriteria().length>0;e.setQueryFacet(n);let i=e.closest(`shacl-property`);i?.classList.toggle(`query-unavailable`,n?.count===0&&!r),i?.classList.toggle(`query-facet-error`,n?.error===!0)}let n=Array.from(this.host.form.querySelectorAll(`shacl-property`)).reverse();for(let e of n){if(e.querySelector(`:scope > .query-editor, :scope > .collapsible > .query-editor`))continue;let t=Array.from(e.querySelectorAll(`.query-editor`)).some(e=>!e.closest(`shacl-property`)?.classList.contains(`query-unavailable`));e.classList.toggle(`query-unavailable`,!t)}let r=Array.from(this.host.form.querySelectorAll(`.query-editor`)).some(e=>!e.closest(`shacl-property`)?.classList.contains(`query-unavailable`));this.host.classList.toggle(`query-facets-empty`,!r)}setFacetsPending(e){this.host.toggleAttribute(`loading`,e);let t=this.host.form.querySelector(`[part~="loading"]`);if(!e)t?.remove();else if(!t){let e=document.createElement(`div`);e.setAttribute(`part`,`loading`),e.textContent=this.host.config.attributes.loading,this.host.form.prepend(e)}}};async function R(e){let t=e.template;if(t.or?.length||t.xone?.length){let n=H(t);if(n){e.container.appendChild(z(n,e.parent));return}let r=t.or?.length?t.or:t.xone;e.container.appendChild(d(r,e,t.config));return}if(!t.nodeShapes.size){e.container.appendChild(z(t,e.parent));return}for(let r of t.nodeShapes){let i=new Set(e.parent.ancestorShapeIds);if(i.add(e.parent.template.id.value),i.has(r.id.value))continue;let a=e.parent.queryContext??{path:[],shapePath:[]},o=new m(r,void 0,t.nodeKind,t.label,!1,i,{path:[...a.path,n(t)],shapePath:[...a.shapePath,U(t)]}),s=document.createElement(`div`);s.classList.add(`property-instance`,`query-structure`),s.setAttribute(`part`,`property-instance`),t.config.hierarchyColorsStyleSheet!==void 0&&s.appendChild(g(!0)),s.appendChild(o),e.container.appendChild(s),await o.ready}}function z(e,t){let r=t.queryContext??{path:[],shapePath:[]},i={id:`qf${(I++).toString(36)}`,path:[...r.path,n(e)],shapePath:[...r.shapePath,U(e)],datatype:e.datatype?.value},a=c(e.path,e.datatype?.value)?.createQueryEditor?.(i,e)??b(i,e);return a.queryField=i,a.classList.add(`property-instance`,`query-editor`),a.dataset.path=e.path,a}async function B(e,t){if(!e.length)return;for(let t of e)await t.initializeQuery();let n=e[0];t.replaceWith(n);for(let t=1;t<e.length;t++)n.after(e[t]),n=e[t];n.dispatchEvent(new Event(`change`,{bubbles:!0}))}async function V(e,t,n){e.or=void 0,e.xone=void 0;let r=new s(e,t.parent);await r.initializeQuery(),n.replaceWith(r),r.dispatchEvent(new Event(`change`,{bubbles:!0}))}function H(n){let r=n.or??n.xone;if(!r?.length)return;let o=r.map(e=>{let r=i(n);return r.or=void 0,r.xone=void 0,t(r,n.config.store.getQuads(e,null,null,null)),r.nodeShapes.size===0?r.datatype:void 0});if(o.some(t=>!t||!e.has(t.value)))return;let s=i(n);return s.or=void 0,s.xone=void 0,s.datatype=o.find(e=>e&&a.has(e.value))??o[0],s}function U(e){return e.qualifiedValueShape||e.pathAlternatives?e.id.value:e.path}export{L as QueryModeController,B as activateNodeConstraintOption,V as activatePropertyConstraintOption,R as initializeQueryProperty};
@@ -0,0 +1,13 @@
1
+ import{D as e,L as t,O as n,P as r,T as i,U as a,W as o,a as s,et as c,n as l,o as u,p as d,q as f,t as p,x as m}from"./query-DOX-ExQB.js";import{DataFactory as h}from"n3";import{RokitInput as g,RokitSelect as _,RokitSlider as v,epochToDate as y}from"@ro-kit/ui-widgets";function b(e,t){let n=document.createElement(`div`),r=!!(t.in||t.class||t.datatype?.equals(c));n.classList.add(`query-editor`),n.dataset.queryFieldId=e.id,n.setAttribute(`part`,`query-editor`);let i=document.createElement(`label`);i.textContent=t.label,t.description&&(i.title=t.description.value),n.appendChild(i);let a=document.createElement(`div`);a.classList.add(`query-controls`),n.appendChild(a);let o,s=k(t),l,u=(e=``)=>{let n=document.createElement(`div`);n.classList.add(`query-value-row`);let r=new _;r.classList.add(`editor`,`query-choice`),r.clearable=!0,r.dense=t.config.theme.dense,r.placeholder=``,r.setAttribute(`exportparts`,`facet-count`);let i=document.createElement(`ul`);for(let e of s){let t=document.createElement(`li`);if(t.dataset.value=P(e.term),t.textContent=e.label,e.count!==void 0){let n=document.createElement(`span`);n.classList.add(`facet-count`),n.setAttribute(`part`,`facet-count`),n.dataset.count=String(e.count),t.append(` `,n)}i.appendChild(t)}return r.appendChild(i),r.value=e,n.appendChild(r),n},d=(e=[])=>{a.replaceChildren(),a.appendChild(u(e[0]??``))},m=(e,n=``)=>{let r=new g;return r.classList.add(`editor`,`query-range-bound`),r.type=N(t),r.label=e,r.clearable=!0,r.dense=t.config.theme.dense,r.value=n,r},h=e=>{a.replaceChildren();let n=x(t,o);n&&n[0]<n[1]&&(l=n);let r=O(n,e&&l);if(!r||r[0]===r[1]){a.append(m(`Minimum`,e?.min?.value),m(`Maximum`,e?.max?.value));return}let i=new v;i.classList.add(`editor`,`query-range-slider`),i.dense=t.config.theme.dense,i.clearable=!0,i.range=``,i.setAttribute(`range`,``),i.min=String(r[0]),i.max=String(r[1]),i.step=String(S(t,r)),i.labelFormatter=e=>C(e,t);let s=e?.min?w(e.min,t):r[0],c=e?.max?w(e.max,t):r[1];i.value=JSON.stringify([D(s??r[0],r[0],r[1]),D(c??r[1],r[0],r[1])]),i.dataset.active=e?.min||e?.max?`true`:`false`,i.addEventListener(`change`,()=>{i.dataset.active=`true`}),a.appendChild(i)};return n.getQueryCriteria=()=>{if(p(e)){let n=a.querySelector(`rokit-slider`);if(n){if(n.dataset.active!==`true`)return[];let r=E(n.value);return r?[{field:e,operator:`range`,min:T(r[0],t),max:T(r[1],t)}]:[]}let r=a.querySelectorAll(`rokit-input`),i=j(r[0]?.value,t),o=j(r[1]?.value,t);return i||o?[{field:e,operator:`range`,min:i,max:o}]:[]}if(r)return Array.from(a.querySelectorAll(`rokit-select`)).flatMap(t=>{if(!t.value)return[];let n=s.find(e=>P(e.term)===t.value)?.term;return n?[{field:e,operator:`equals`,value:n}]:[]});let n=M(t)&&!t.class&&!t.nodeKind?.value.endsWith(`#IRI`)?`contains`:`equals`;return Array.from(a.querySelectorAll(`.query-value-row`)).flatMap(r=>{let i=r.querySelector(`.query-value`),a=r.querySelector(`.query-language`)?.value,o=j(i?.value,t,a);return o?[{field:e,operator:n,value:o}]:[]})},n.setQueryFacet=i=>{let c=n.getQueryCriteria();if(o=i,r&&o?.buckets){let e=new Map(k(t).map(e=>[P(e.term),e])),n=new Map(c.flatMap(e=>e.value?[[P(e.value),e.value]]:[]));s=o.buckets.flatMap(n=>{let r=e.get(P(n.value));return t.in&&!r?[]:[{term:n.value,label:n.label??r?.label??n.value.value,count:n.count}]});for(let[t,r]of n)s.some(e=>P(e.term)===t)||s.push({term:r,label:e.get(t)?.label??r.value,count:0});d([...n.keys()])}else if(p(e)){let e=c[0];h(e?{min:e.min,max:e.max}:void 0)}else if(!i)for(let e of a.querySelectorAll(`.query-value`))e.value=``},p(e)?h():r?d():(a.replaceChildren(),a.appendChild((()=>{let e=document.createElement(`div`);e.classList.add(`query-value-row`);let r=new g;r.classList.add(`editor`,`query-value`),r.type=N(t),r.clearable=!0,r.dense=t.config.theme.dense;let i;if(r.addEventListener(`input`,()=>{clearTimeout(i),i=setTimeout(()=>{n.dispatchEvent(new Event(`change`,{bubbles:!0}))},300)}),e.appendChild(r),t.datatype?.equals(f)){let n=t.languageIn?.length?document.createElement(`select`):document.createElement(`input`);if(n.classList.add(`lang-chooser`,`query-language`),n.title=`Language of the text`,n.setAttribute(`aria-label`,`Language of the text`),n instanceof HTMLSelectElement)for(let e of t.languageIn??[]){let t=document.createElement(`option`);t.value=e.value,t.textContent=e.value,n.appendChild(t)}else n.maxLength=35,n.placeholder=`lang?`,n.value=t.config.languages.find(e=>e.length>0)??``;e.appendChild(n)}return e})())),n}function x(e,t){let n=t?.min?w(t.min,e):void 0,r=t?.max?w(t.max,e):void 0,i=e.minInclusive??(e.minExclusive===void 0?void 0:e.minExclusive+1),a=e.maxInclusive??(e.maxExclusive===void 0?void 0:e.maxExclusive-1),o=n===void 0?i:i===void 0?n:Math.max(n,i),s=r===void 0?a:a===void 0?r:Math.min(r,a);return o!==void 0&&s!==void 0&&Number.isFinite(o)&&Number.isFinite(s)&&o<=s?[o,s]:void 0}function S(e,t){return e.datatype?.value===`http://www.w3.org/2001/XMLSchema#integer`?1:e.datatype?.value===`http://www.w3.org/2001/XMLSchema#date`?86400:e.datatype?.value===`http://www.w3.org/2001/XMLSchema#dateTime`?1:Math.max((t[1]-t[0])/1e3,2**-52)}function C(e,t){return t.datatype?.value===`http://www.w3.org/2001/XMLSchema#date`?y(e,!0):t.datatype?.value===`http://www.w3.org/2001/XMLSchema#dateTime`?y(e):String(Math.round(e*1e3)/1e3)}function w(e,t){if(t.datatype?.value===`http://www.w3.org/2001/XMLSchema#date`||t.datatype?.value===`http://www.w3.org/2001/XMLSchema#dateTime`){let t=Date.parse(e.value);return Number.isFinite(t)?t/1e3:void 0}let n=Number(e.value);return Number.isFinite(n)?n:void 0}function T(e,t){let n=t.datatype;return n?.value===`http://www.w3.org/2001/XMLSchema#date`?h.literal(y(e,!0),n):n?.value===`http://www.w3.org/2001/XMLSchema#dateTime`?h.literal(y(e),n):h.literal(String(e),n)}function E(e){try{let t=JSON.parse(e);return Array.isArray(t)&&t.length===2&&t.every(Number.isFinite)?[Number(t[0]),Number(t[1])]:void 0}catch{return}}function D(e,t,n){return Math.min(n,Math.max(t,e))}function O(e,t){return e&&e[0]<e[1]?e:t||e}function k(e){if(e.datatype?.equals(c))return[{term:h.literal(`true`,c),label:`true`},{term:h.literal(`false`,c),label:`false`}];let n=[];return e.in?n=r(e.config.lists[e.in]??[],e.config.store,e.config.languages):e.class&&(n=t(e.class,e)),A(n)}function A(e){return e.flatMap(e=>[...typeof e.value==`string`?[]:[{term:e.value,label:e.label||e.value.value}],...A(e.children??[])])}function j(e,t,n){if(e)return t.class||t.nodeKind?.value.endsWith(`#IRI`)?h.namedNode(e):t.datatype?.equals(f)?n?h.literal(e,n):void 0:t.datatype?h.literal(e,t.datatype):h.literal(e)}function M(e){return!e.datatype||e.datatype.value===`http://www.w3.org/2001/XMLSchema#string`||e.datatype.equals(f)}function N(e){let t=e.datatype?.value;return[`http://www.w3.org/2001/XMLSchema#integer`,`http://www.w3.org/2001/XMLSchema#float`,`http://www.w3.org/2001/XMLSchema#double`,`http://www.w3.org/2001/XMLSchema#decimal`].includes(t??``)?`number`:t===`http://www.w3.org/2001/XMLSchema#date`?`date`:t===`http://www.w3.org/2001/XMLSchema#dateTime`?`datetime-local`:`text`}function P(e){if(e.termType===`Literal`){let t=e;return`${e.termType}:${e.value}:${t.language}:${t.datatype?.value}`}return`${e.termType}:${e.value}`}var F=`form.mode-query { padding: 0; }
2
+ :host([loading]) form.mode-query > shacl-node { display: none; }
3
+ .mode-query shacl-property.query-unavailable { display: none; }
4
+ .mode-query .shacl-group:not(:has(shacl-property:not(.query-unavailable))), .mode-query shacl-node:not(:has(shacl-property:not(.query-unavailable))) { display: none; }
5
+ .query-editor { display: flex; align-items: center; width: 100%; padding: 3px 0; }
6
+ .query-editor > label { width: var(--label-width); flex-shrink: 0; padding-right: 1em; word-break: break-word; }
7
+ .query-controls { display: flex; flex: 1; min-width: 0; }
8
+ .query-controls > rokit-input, .query-controls > rokit-slider, .query-value-row > rokit-input, .query-value-row > rokit-select { min-height: 28px; width: 100%; flex-grow: 1; }
9
+ .query-value-row { display: flex; flex: 1; width: 100%; min-width: 0; gap: 4px; }
10
+ .query-language { min-height: 28px; flex: 0 0 auto; }
11
+ .query-range-slider[data-active='false'] { opacity: 0.7; }
12
+ .query-facet-error .query-editor > label { color: var(--shacl-error-color); }
13
+ `,I=0,L=class{constructor(e){this.stylesheet=new CSSStyleSheet,this.facetRequest=0,this.facetsApplied=!1,this.host=e,this.stylesheet.replaceSync(F),e.config.queryFacetProvider&&this.setFacetsPending(!0)}async initialize(){await this.emitQueryAndRefreshFacets()}handleChange(){this.emitQueryAndRefreshFacets()}getQuery(){let e=this.host.shape;return e?{rootShapeId:e.template.id.value,targetClass:e.template.targetClass?.value,criteria:Array.from(this.host.form.querySelectorAll(`.query-editor`)).flatMap(e=>e.getQueryCriteria())}:{rootShapeId:``,criteria:[]}}refreshFacets(){this.host.shape&&this.requestFacets(this.getQuery())}dispose(){this.facetAbortController?.abort(),this.setFacetsPending(!1),this.host.classList.remove(`query-facets-empty`)}async emitQueryAndRefreshFacets(){if(!this.host.shape)return;let e=this.getQuery();this.host.dispatchEvent(new CustomEvent(`query`,{bubbles:!0,composed:!0,detail:e})),await this.requestFacets(e)}async requestFacets(e){let t=this.host.config.queryFacetProvider;if(!t)return;this.facetAbortController?.abort();let n=new AbortController;this.facetAbortController=n;let r=++this.facetRequest;this.facetsApplied||this.setFacetsPending(!0);try{let i=Array.from(this.host.form.querySelectorAll(`.query-editor`)).map(e=>e.queryField),a=await t.getFacets({query:e,fields:i,signal:n.signal});if(n.signal.aborted||r!==this.facetRequest)return;this.applyFacets(a),this.facetsApplied=!0,this.setFacetsPending(!1)}catch(e){if(n.signal.aborted)return;this.setFacetsPending(!1),this.host.dispatchEvent(new CustomEvent(`queryerror`,{bubbles:!0,composed:!0,detail:e}))}}applyFacets(e){let t=new Map(e.map(e=>[e.fieldId,e]));for(let e of Array.from(this.host.form.querySelectorAll(`.query-editor`))){let n=t.get(e.queryField.id),r=e.getQueryCriteria().length>0;e.setQueryFacet(n);let i=e.closest(`shacl-property`);i?.classList.toggle(`query-unavailable`,n?.count===0&&!r),i?.classList.toggle(`query-facet-error`,n?.error===!0)}let n=Array.from(this.host.form.querySelectorAll(`shacl-property`)).reverse();for(let e of n){if(e.querySelector(`:scope > .query-editor, :scope > .collapsible > .query-editor`))continue;let t=Array.from(e.querySelectorAll(`.query-editor`)).some(e=>!e.closest(`shacl-property`)?.classList.contains(`query-unavailable`));e.classList.toggle(`query-unavailable`,!t)}let r=Array.from(this.host.form.querySelectorAll(`.query-editor`)).some(e=>!e.closest(`shacl-property`)?.classList.contains(`query-unavailable`));this.host.classList.toggle(`query-facets-empty`,!r)}setFacetsPending(e){this.host.toggleAttribute(`loading`,e);let t=this.host.form.querySelector(`[part~="loading"]`);if(!e)t?.remove();else if(!t){let e=document.createElement(`div`);e.setAttribute(`part`,`loading`),e.textContent=this.host.config.attributes.loading,this.host.form.prepend(e)}}};async function R(e){let t=e.template;if(t.or?.length||t.xone?.length){let n=H(t);if(n){e.container.appendChild(z(n,e.parent));return}let r=t.or?.length?t.or:t.xone;e.container.appendChild(m(r,e,t.config));return}if(!t.nodeShapes.size){e.container.appendChild(z(t,e.parent));return}for(let r of t.nodeShapes){let i=new Set(e.parent.ancestorShapeIds);if(i.add(e.parent.template.id.value),i.has(r.id.value))continue;let a=e.parent.queryContext??{path:[],shapePath:[]},o=new l(r,void 0,t.nodeKind,t.label,!1,i,{path:[...a.path,n(t)],shapePath:[...a.shapePath,U(t)]}),s=document.createElement(`div`);s.classList.add(`property-instance`,`query-structure`),s.setAttribute(`part`,`property-instance`),t.config.hierarchyColorsStyleSheet!==void 0&&s.appendChild(u(!0)),s.appendChild(o),e.container.appendChild(s),await o.ready}}function z(e,t){let r=t.queryContext??{path:[],shapePath:[]},i={id:`qf${(I++).toString(36)}`,path:[...r.path,n(e)],shapePath:[...r.shapePath,U(e)],datatype:e.datatype?.value},a=d(e.path,e.datatype?.value)?.createQueryEditor?.(i,e)??b(i,e);return a.queryField=i,a.classList.add(`property-instance`,`query-editor`),a.dataset.path=e.path,a}async function B(e,t){if(!e.length)return;for(let t of e)await t.initializeQuery();let n=e[0];t.replaceWith(n);for(let t=1;t<e.length;t++)n.after(e[t]),n=e[t];n.dispatchEvent(new Event(`change`,{bubbles:!0}))}async function V(e,t,n){e.or=void 0,e.xone=void 0;let r=new s(e,t.parent);await r.initializeQuery(),n.replaceWith(r),r.dispatchEvent(new Event(`change`,{bubbles:!0}))}function H(t){let n=t.or??t.xone;if(!n?.length)return;let r=n.map(n=>{let r=i(t);return r.or=void 0,r.xone=void 0,e(r,t.config.store.getQuads(n,null,null,null)),r.nodeShapes.size===0?r.datatype:void 0});if(r.some(e=>!e||!o.has(e.value)))return;let s=i(t);return s.or=void 0,s.xone=void 0,s.datatype=r.find(e=>e&&a.has(e.value))??r[0],s}function U(e){return e.qualifiedValueShape||e.pathAlternatives?e.id.value:e.path}export{L as QueryModeController,B as activateNodeConstraintOption,V as activatePropertyConstraintOption,R as initializeQueryProperty};
@@ -0,0 +1,91 @@
1
+ import{BlankNode as e,DataFactory as t,Literal as n,NamedNode as r,Store as i,StreamParser as a,Writer as o,termFromId as s,termToId as c}from"n3";import{RdfXmlParser as l}from"rdfxml-streaming-parser";import u from"jsonld";import{RokitButton as d,RokitCollapsible as f,RokitDialog as p}from"@ro-kit/ui-widgets";import{v4 as m}from"uuid";var h=`http://www.w3.org/ns/shacl#`,ee=`http://datashapes.org/dash#`,te=`http://www.w3.org/2001/XMLSchema#`,ne=`http://www.w3.org/1999/02/22-rdf-syntax-ns#`,re=`http://www.w3.org/2000/01/rdf-schema#`,ie=`http://www.w3.org/ns/oa#`,ae=`http://purl.org/dc/terms/`,g=t.namedNode(`loaded-shapes`),_=t.namedNode(`loaded-data`),v=t.namedNode(`http://www.w3.org/1999/02/22-rdf-syntax-ns#type`),y=t.namedNode(`http://www.w3.org/1999/02/22-rdf-syntax-ns#langString`),b=t.namedNode(`http://purl.org/dc/terms/conformsTo`),oe=t.namedNode(`http://www.w3.org/2000/01/rdf-schema#subClassOf`),x=t.namedNode(`http://www.w3.org/2002/07/owl#imports`),se=t.namedNode(`http://www.w3.org/2004/02/skos/core#broader`),ce=t.namedNode(`http://www.w3.org/2004/02/skos/core#narrower`),le=t.namedNode(`http://www.w3.org/ns/shacl#NodeShape`),ue=t.namedNode(`http://www.w3.org/ns/shacl#IRI`),S=t.namedNode(`http://www.w3.org/ns/shacl#property`),C=t.namedNode(`http://www.w3.org/ns/shacl#class`),de=t.namedNode(`http://www.w3.org/ns/shacl#node`),fe=t.namedNode(`http://www.w3.org/ns/shacl#message`),w=t.namedNode(`http://www.w3.org/ns/shacl#targetClass`),pe=t.namedNode(`http://www.w3.org/ns/shacl#nodeKind`),me=t.namedNode(`http://www.w3.org/2001/XMLSchema#string`),he=t.namedNode(`http://www.w3.org/2001/XMLSchema#boolean`),ge=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`]),_e=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`]),ve=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=h,r){let i=``,a=ye(e,t,n,r);return a&&(i=a.value),i}function ye(e,t,n=h,r){let i,a=n+t;if(r?.length){for(let t of r)for(let n of e)if(n.predicate.value===a){if(n.object.id.endsWith(`@${t}`))return n.object;n.object.id.indexOf(`@`)<0?i=n.object:i||=n.object}}else for(let t of e)if(t.predicate.value===a)return t.object;return i}function be(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 xe(e,n,r=new Map){r.set(g.id,g),r.set(_.id,_);let i=e.config.valuesGraphId??t.defaultGraph();r.set(i.id,i);for(let t of e.owlImports)Se(t,n,r);return e.parent&&xe(e.parent,n,r),[...r.values()]}function Se(e,t,n){if(!n.has(e.id)){n.set(e.id,e);for(let r of t.getObjects(null,x,e))r.termType===`NamedNode`&&Se(r,t,n)}}function Ce(e,t,n,r){return r.flatMap(r=>e.getSubjects(t,n,r))}function k(e,t,n,r){return r.flatMap(r=>e.getObjects(t,n,r))}function A(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=xe(t,t.config.store),r=Ce(t.config.store,v,e,n),i=new Map,a=new Map;for(let e of r)i.set(e.id,{value:e,label:E(t.config.store.getQuads(e,null,null,null),t.config.languages),children:[]});for(let e of r){for(let r of k(t.config.store,e,se,n))i.has(r.id)&&a.set(e.id,r.id);for(let r of k(t.config.store,e,ce,n))i.has(r.id)&&a.set(r.id,e.id);for(let r of k(t.config.store,e,oe,n))i.has(r.id)&&a.set(e.id,r.id)}for(let[e,t]of a.entries())i.get(t)?.children?.push(i.get(e));let o=[];for(let[e,t]of i.entries())a.has(e)||o.push(t);for(let r of Ce(t.config.store,oe,e,n))o.push(...A(r,t));return o}}function j(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol===`http:`||t.protocol===`https:`}function M(e,t,n){if(t===void 0)return n;if(n===void 0)return t;let r=e.indexOf(t.language);if(r<0)return n;let i=e.indexOf(n.language);return i<0||i>r?t:n}function we(e,t){let n;for(let r of t)n=M(e,n,r);return n?n.value:``}var N=/^(-?\d{4,}-\d{2}-\d{2})(Z|[+-]\d{2}:\d{2})?$/,Te=/^(-?\d{4,}-\d{2}-\d{2})T(\d{2}:\d{2})(?::(\d{2})(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?$/,Ee=/^(-?\d{4,}-\d{2}-\d{2}T\d{2}:\d{2})(?::(\d{2})(\.\d+)?)?$/;function De(e){let t=e.match(N);if(!t){let t=e.match(Te);return t?{value:t[1],suffix:t[5]||``}:void 0}return{value:t[1],suffix:t[2]||``}}function Oe(e){let t=e.match(Te);if(!t){let t=e.match(N);return t?{value:`${t[1]}T00:00:00`,suffix:t[2]||``}:void 0}return{value:`${t[1]}T${t[2]}:${t[3]||`00`}`,suffix:t[5]||``}}function ke(e,t=``){let n=e.match(N);return n?`${n[1]}${t}`:e}function Ae(e,t=``){let n=e.match(Ee);return n?`${n[1]}:${n[2]||`00`}${n[3]||``}${t}`:e}function je(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 Me(e,t){return e instanceof Set?[...t].filter(t=>!e.has(t)):[...t].filter(t=>!e.includes(t))}function Ne(e,{remove:t=!1,ignoreErrors:n=!1}={}){let r={},i=n?()=>!0:(e,t)=>{throw Error(`${e.value} ${t}`)},a=e.getQuads(null,ne+`rest`,ne+`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 P={},F={};async function I(e){return`rdf`in e?L(e.rdf):e.rdfUrlResolver?L(await e.rdfUrlResolver(e.url)):Pe(e.url,e.proxy)}async function Pe(e,t){return e in P||(P[e]=(async()=>{let n=e;t&&(n=t+encodeURIComponent(e));let r=await fetch(n,{headers:{Accept:`text/turtle, application/trig, application/n-triples, application/n-quads, text/n3, application/ld+json`}});return r.ok?L(await r.text()):(console.warn(`failed fetching RDF from`,e),[])})()),P[e]}async function L(e){if(!e.trim())return[];let n=Fe(e);if(n===`json`)try{e=await u.toRDF(JSON.parse(e),{format:`application/n-quads`})}catch(e){console.error(e)}let r=[];return await new Promise((i,o)=>{let s=n===`xml`?new l:new a;s.on(`data`,e=>{r.push(t.quad(e.subject,e.predicate,e.object,e.graph))}).on(`error`,e=>{o(e)}).on(`prefix`,(e,t)=>{e&&(F[e]=t)}).on(`end`,()=>{i(null)}),s.write(e),s.end()}),r}function Fe(e){return/^\s*[\\[{]/.test(e)?`json`:/^\s*<\?xml/.test(e)?`xml`:`ttl`}var Ie={[`${h}name`]:(e,t)=>{let n=t;e.name=M(e.config.languages,e.name,n)},[`${h}description`]:(e,t)=>{let n=t;e.description=M(e.config.languages,e.description,n)},[`${h}path`]:(e,t)=>{if(t.termType===`NamedNode`){e.path=t.value;return}let n=e.config.store.getQuads(t,null,null,null),r=n.filter(e=>e.predicate.value===`${h}alternativePath`);if(n.length!==1||r.length!==1){console.warn(`ignoring unsupported or malformed SHACL property path`,t.value);return}let i=e.config.lists[r[0].object.value];if(!i||i.length<2||i.some(e=>e.termType!==`NamedNode`)){console.warn(`ignoring sh:alternativePath without at least two predicate IRI members`,t.value);return}e.pathAlternatives=i.map(e=>e.value),e.path=e.pathAlternatives[0]},[`${h}group`]:(e,t)=>{e.group=t.id},[`${h}datatype`]:(e,t)=>{e.datatype=t},[`${h}nodeKind`]:(e,t)=>{e.nodeKind=t},[`${h}minCount`]:(e,t)=>{e.minCount=parseInt(t.value)},[`${h}maxCount`]:(e,t)=>{e.maxCount=parseInt(t.value)},[`${h}minLength`]:(e,t)=>{e.minLength=parseInt(t.value)},[`${h}maxLength`]:(e,t)=>{e.maxLength=parseInt(t.value)},[`${h}minInclusive`]:(e,t)=>{e.minInclusive=parseInt(t.value)},[`${h}maxInclusive`]:(e,t)=>{e.maxInclusive=parseInt(t.value)},[`${h}minExclusive`]:(e,t)=>{e.minExclusive=parseInt(t.value)},[`${h}maxExclusive`]:(e,t)=>{e.maxExclusive=parseInt(t.value)},[`${h}pattern`]:(e,t)=>{e.pattern=t.value},[`${h}order`]:(e,t)=>{e.order=parseInt(t.value)},[`${ee}singleLine`]:(e,t)=>{e.singleLine=t.value===`true`},[`${ee}readonly`]:(e,t)=>{e.readonly=t.value===`true`},[`${ie}styleClass`]:(e,t)=>{e.cssClass=t.value},[`${h}in`]:(e,t)=>{e.in=t.value},[`${h}languageIn`]:(e,t)=>{e.languageIn=e.config.lists[t.value],e.datatype=y},[`${h}defaultValue`]:(e,t)=>{e.defaultValue=t},[`${h}hasValue`]:(e,t)=>{e.hasValue=t},[`${h}node`]:(e,t)=>{e.node=t,e.nodeShapes.add(e.config.getNodeTemplate(t,e))},[`${h}and`]:(e,t)=>{e.and=t.value;let n=e.config.lists[e.and];if(n?.length)for(let t of n)e.nodeShapes.add(e.config.getNodeTemplate(t,e))},[`${h}qualifiedValueShape`]:(e,t)=>{let n=e.config.getNodeTemplate(t,e);e.qualifiedValueShape=n,e.nodeShapes.add(n)},[`${h}qualifiedMinCount`]:(e,t)=>{e.qualifiedMinCount=parseInt(t.value)},[`${h}qualifiedMaxCount`]:(e,t)=>{e.qualifiedMaxCount=parseInt(t.value)},[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])},[`${h}or`]:(e,t)=>{let n=e.config.lists[t.value];n?.length?e.or=n:console.error(`list for sh:or not found:`,t.value,`existing lists:`,e.config.lists)},[`${h}xone`]:(e,t)=>{let n=e.config.lists[t.value];n?.length?e.xone=n:console.error(`list for sh:xone not found:`,t.value,`existing lists:`,e.config.lists)}},Le=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 Re(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.pathAlternatives&&(t.pathAlternatives=[...e.pathAlternatives]),e.pathAlternativeBranches&&(t.pathAlternativeBranches={...e.pathAlternativeBranches}),e.or&&(t.or=[...e.or]),e.xone&&(t.xone=[...e.xone]),t}function B(e,t){for(let n of t)Ie[n.predicate.id]?.call(e,e,n.object);return e.label=e.name?.value||E(t,e.config.languages),e.label||=e.pathAlternatives?e.pathAlternatives.map(e=>O(e,F)).join(` / `):e.path?O(e.path,F):`unknown`,e}function V(e,t,n=!1){let r=t,i=e,a=Be(e),o=Be(t),s=a&&U(t),c=o&&U(e);s&&(e.nodeShapes.clear(),e.node=void 0);for(let a in t)if(a!==`parent`&&a!==`config`&&a!==`id`){let o=r[a];if(o!==void 0&&o!==``){if(a===`label`)continue;if(a===`name`||a===`description`||a===`group`||a===`order`)(n||i[a]===void 0||i[a]===``)&&(i[a]=o);else if(a===`minCount`)e.minCount=Math.max(e.minCount??0,t.minCount);else if(a===`maxCount`)e.maxCount=Math.min(e.maxCount??2**53-1,t.maxCount);else if(a===`qualifiedMinCount`)e.qualifiedMinCount=Math.max(e.qualifiedMinCount??0,t.qualifiedMinCount);else if(a===`qualifiedMaxCount`)e.qualifiedMaxCount=Math.min(e.qualifiedMaxCount??2**53-1,t.qualifiedMaxCount);else if(a===`nodeShapes`&&c)continue;else if(a===`node`&&c)continue;else if(a===`pathAlternatives`)continue;else if(Array.isArray(o)){let e=i[a];Array.isArray(e)?e.push(...o):i[a]=[...o]}else if(o instanceof Set&&o.size){let e=i[a];i[a]=new Set([...e instanceof Set?e:[],...o])}else i[a]=o}}e.name&&(e.label=e.name.value)}function H(e){return e.pathAlternatives?`alternative:${JSON.stringify(e.pathAlternatives)}`:e.path}function ze(e){return e.pathAlternatives?[...e.pathAlternatives]:e.path}function Be(e){return e.nodeShapes.size>0&&e.qualifiedValueShape===void 0&&e.name===void 0&&e.description===void 0&&!U(e)}function U(e){return e.in!==void 0||e.datatype!==void 0||e.languageIn!==void 0||e.class!==void 0||e.hasValue!==void 0||e.defaultValue!==void 0}var Ve=(function(){let e=typeof document<`u`&&document.createElement(`link`).relList;return e&&e.supports&&e.supports(`modulepreload`)?`modulepreload`:`preload`})(),He=function(e){return`/`+e},Ue={},W=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=He(t,n),t=s(t),t in Ue)return;Ue[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`:Ve,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 G(e,t,n,r,i){let a=document.createElement(`div`);a.classList.add(`shacl-or-constraint`),a.setAttribute(`part`,`constraint`);let o=[];if(t instanceof $){let r=[],i=!1;e.length&&(i=n.store.countQuads(e[0],S,null,null)>0);for(let a=0;a<e.length;a++)if(i){let i=n.store.getObjects(e[a],S,null),s=[],c=``;for(let e of i){let r=new X(n.getPropertyTemplate(e,t.template),t);s.push(r),c+=(c.length>0?` / `:``)+r.template.label}r.push(s),o.push({label:c,value:a.toString()})}else{let i=e[a],s=new X(n.getPropertyTemplate(i,t.template),t);r.push([s]),o.push({label:s.template.label,value:a.toString()})}let s=n.theme.createListEditor(`Please choose`,null,!1,o);s.setAttribute(`part`,`constraint-editor`);let c=s.querySelector(`.editor`);c.onchange=async()=>{if(c.value){let e=r[parseInt(c.value)];if(n.queryMode){let{activateNodeConstraintOption:t}=await W(async()=>{let{activateNodeConstraintOption:e}=await import(`./mode-C_BqcQqf.js`);return{activateNodeConstraintOption:e}},[]);await t(e,a);return}let i;if(e.length){for(let n of e)await n.bindValues(t.nodeId,!1);i=e[0],a.replaceWith(e[0]),i.updateControls()}for(let t=1;t<e.length;t++)i.after(e[t]),i=e[t],i.updateControls()}},a.appendChild(s)}else{let s=[];for(let t=0;t<e.length;t++){let r=n.store.getQuads(e[t],null,null,null);if(r.length){s.push(r);let e=E(r,n.languages);for(let t of r)t.predicate.equals(de)&&(e||=E(n.store.getQuads(t.object,null,null,null),n.languages));o.push({label:e||O(r[0].predicate.value,F)+` = `+O(r[0].object.value,F),value:(s.length-1).toString()})}}let c=n.theme.createListEditor(t.template.label+`?`,null,!1,o,t.template);c.setAttribute(`part`,`constraint-editor`);let l=c.querySelector(`.editor`);l.onchange=async()=>{if(l.value){let e=B(z(i??t.template),s[parseInt(l.value)]);if(e.or=void 0,e.xone=void 0,n.queryMode){let{activatePropertyConstraintOption:n}=await W(async()=>{let{activatePropertyConstraintOption:e}=await import(`./mode-C_BqcQqf.js`);return{activatePropertyConstraintOption:e}},[]);await n(e,t,a);return}if(r||Re(t.template)>1){let n=await Z(e,void 0,!0,!1,t.parent);n.dataset.path=t.template.path,r&&(n.dataset.predicate=r),a.replaceWith(n),n.dispatchEvent(new Event(`change`,{bubbles:!0,cancelable:!0}));return}e.pathAlternatives=void 0;let o=new X(e,t.parent);t.replaceWith(o),await o.updateControls()}},a.appendChild(c)}return a}function We(e,t,n,r=!1){let i=document.createElement(`div`);i.classList.add(`alternative-path-constraint`),i.setAttribute(`part`,`constraint`),i.dataset.path=e.template.path;let a=e.template.pathAlternatives.map((e,t)=>({label:O(e,F),value:t.toString()})),o=e.template.config.theme.createListEditor(`${e.template.label}: path`,null,!1,a,e.template);o.setAttribute(`part`,`constraint-editor`);let s=o.querySelector(`.editor`);return s.onchange=async()=>{if(s.value===``)return;let r=e.template.pathAlternatives[parseInt(s.value)],a=await e.addPropertyInstance(t,n,!0,r,!1);a&&(i.replaceWith(a),a.dispatchEvent(new Event(`change`,{bubbles:!0,cancelable:!0})))},i.appendChild(o),Et(i,e.template.label,e.template.config.theme.dense,e.template.config.hierarchyColorsStyleSheet!==void 0,r),i}function Ge(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(pe)&&t.object.equals(ue))return e}}return console.error(`couldn't resolve sh:or/sh:xone on property for value`,t),[]}function Ke(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,`${h}path`,null);for(let r of i)if(e=n.store.countQuads(t,r,null,null)>0,e)break}if(e)return i}return console.error(`couldn't resolve sh:or/sh:xone on node for value`,t),[]}var qe=`: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),
26
+ shacl-property:not(.may-remove) > .alternative-path-constraint > .remove-button-wrapper > .remove-button:not(.persistent),
27
+ shacl-property:not(.may-remove) > .collapsible > .alternative-path-constraint > .remove-button-wrapper > .remove-button:not(.persistent) { visibility: hidden; }
28
+ .mode-view .shacl-group:not(:has(shacl-property)) { display: none; }
29
+ .property-instance, .shacl-or-constraint, .alternative-path-constraint { display: flex; align-items: center; padding: 4px 0; width: 100%; position: relative; }
30
+ .shacl-or-constraint > div, .alternative-path-constraint > div { display: flex; align-items: flex-start; }
31
+ .shacl-or-constraint > div:first-child, .alternative-path-constraint > div:first-child { flex-grow: 1 }
32
+ .shacl-or-constraint label, .alternative-path-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; }
33
+ .property-instance label[title] { cursor: help; text-decoration: underline dashed #AAA; }
34
+ .property-instance.linked label:after, label.linked:after { content: '\\1F517'; font-size: 0.6em; position: absolute; top: 3px; right: 3px; }
35
+ .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; }
36
+ .mode-edit .add-button-wrapper.required > .add-button::before, .add-button-wrapper.required > .link-button::before { left: -0.5em; }
37
+ .property-instance.valid::before { content: ''; position: absolute; left: calc(var(--label-width) - 1em); top: 50%; transform: translateY(-50%); 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>'); }
38
+ .editor:not([type='checkbox']) { flex-grow: 1; }
39
+ textarea.editor { resize: vertical; }
40
+ .lang-chooser { border: 0; background-color: #e9e9ed; padding: 2px 4px; align-self: flex-start; }
41
+ .validation-error { position: absolute; left: calc(var(--label-width) - 1em); top: 50%; transform: translateY(-50%); color: var(--shacl-error-color); cursor: help; }
42
+ .validation-error::before { content: '\\26a0' }
43
+ .validation-error.node { left: -1em; top: calc(4px + 0.45em); transform: none; }
44
+ .property-instance:has(> .editor:is(textarea, rokit-textarea)).valid::before,
45
+ .property-instance:has(> .editor:is(textarea, rokit-textarea)) > .validation-error {
46
+ top: calc(4px + 0.45em);
47
+ transform: none;
48
+ }
49
+ .invalid > .editor { border-color: red !important; }
50
+ .ml-0 { margin-left: 0 !important; }
51
+ .pr-0 { padding-right: 0 !important; }
52
+ .mode-view .property-instance:not(:first-child) > label { visibility: hidden; }
53
+ .mode-view .property-instance label { width: var(--label-width); }
54
+
55
+ .d-flex { display: flex; }
56
+ .lang { opacity: 0.65; font-size: 0.6em; }
57
+ a, a:visited { color: inherit; }
58
+ h3 { margin-top: 0; }
59
+
60
+ .fadeIn, .fadeOut { animation: fadeIn 0.2s ease-out; }
61
+ .fadeOut { animation-direction: reverse; animation-timing-function: ease-out;}
62
+ @keyframes fadeIn {
63
+ 0% { opacity: 0; transform: scaleY(0.8); }
64
+ 100% { opacity: 1; transform: scaleY(1); }
65
+ }
66
+ .collapsible::part(label) { font-weight: 600; }
67
+ .collapsible > .property-instance:nth-child(even) { background-color: var(--shacl-row-alt-bg); }
68
+ .collapsible > .property-instance > shacl-node > h1 { display: none; }
69
+ .ref-link { cursor: pointer; }
70
+ .ref-link:hover { text-decoration: underline; }
71
+ .node-id-display { color: var(--shacl-muted-color); font-size: 11px; }
72
+ /* hierarchy colors */
73
+ .colorize { --hierarchy-color-width: 3px; padding: 0 1px 0 calc(1px + var(--hierarchy-color-width)); align-self: stretch; position: relative; }
74
+ .colorize::before {
75
+ content: '';
76
+ position: absolute;
77
+ width: var(--hierarchy-color-width);
78
+ top: 0; bottom: 0; left: 0;
79
+ --index: mod(var(--hierarchy-level), var(--hierarchy-colors-length));
80
+ background: linear-gradient(var(--hierarchy-colors)) no-repeat 0 calc(var(--index) * 100% / (var(--hierarchy-colors-length) - 1)) / 100% calc(1px * infinity);
81
+ }
82
+ .property-instance:not(:has(shacl-node)) > .colorize::before { background: 0; }
83
+ .colorize:not(:has(.remove-button)) { padding-left: calc(8px + var(--hierarchy-color-width)); }
84
+ .mode-view .property-instance > .colorize { order: -1; }
85
+ .link-option { padding: 10px; }
86
+ .link-option:hover { background-color: #F5F5F5; cursor: pointer; }
87
+ rokit-dialog.link-chooser::part(dialog) { min-height: min(434px, 90vh); width: min(90vw, 600px); }
88
+ rokit-select::part(facet-count) { color: var(--shacl-muted-color); }
89
+ rokit-select::part(facet-count)::after { content: attr(data-count); color: inherit; display: inline-block; font-family: monospace; margin-left: 7px; font-size: 12px; }
90
+ `,Je=class{constructor(e){this.dense=!0;let t=qe;e&&(t+=`
91
+ `+e),this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(t)}apply(e){}setDense(e){this.dense=e}createViewer(e,t,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=t.value,c=null;if(t instanceof r){let e=i.config.store.getQuads(s,null,null,null);if(e.length){let t=E(e,i.config.languages);t&&(s=t)}}else t instanceof n&&(t.language?(c=document.createElement(`span`),c.classList.add(`lang`),c.innerText=`@${t.language}`):t.datatype.value===`http://www.w3.org/2001/XMLSchema#date`?s=new Date(Date.parse(t.value)).toDateString():t.datatype.value===`http://www.w3.org/2001/XMLSchema#dateTime`&&(s=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=s,c&&l.appendChild(c),a.appendChild(l),a}};function Ye(e,t,r){if(r){let r=R(e)>0;if(e.class&&!e.hasValue)return e.config.theme.createListEditor(e.label,t,r,A(e.class,e),e);if(e.in){let n=e.config.lists[e.in];if(n?.length){let i=D(n,e.config.store,e.config.languages);return e.config.theme.createListEditor(e.label,t,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&&t instanceof n&&t.language)return e.config.theme.createLangStringEditor(e.label,t,r,e);switch(e.datatype?.value.replace(te,``)){case`integer`:case`float`:case`double`:case`decimal`:return e.config.theme.createNumberEditor(e.label,t,r,e);case`date`:case`dateTime`:return e.config.theme.createDateEditor(e.label,t,r,e);case`boolean`:return e.config.theme.createBooleanEditor(e.label,t,r,e);case`base64Binary`:return e.config.theme.createFileEditor(e.label,t,r,e)}return e.config.theme.createTextEditor(e.label,t,r,e)}else return t?e.config.theme.createViewer(e.label,t,e):document.createElement(`div`)}function Xe(e,t){e.rdfTerm=t??void 0,e.rdfTermState=t?nt(e):void 0}function Ze(e,t){e.rdfTerms=new Map;for(let n of t)e.rdfTerms.set(Qe(n),n)}function Qe(e){return c(e)}function $e(e){let t=e.rdfTerms?.get(e.value);if(t)return t;if(!(!e.rdfTerm||!rt(e.rdfTermState,nt(e))))return e.rdfTerm}function K(i){let a=$e(i);if(a)return a;let o=i.shaclDatatype,s=i.dataset.value||i.value;if((i.type===`file`||i.getAttribute(`type`)===`file`)&&i.binaryData)s=i.binaryData;else if(i.type===`checkbox`||i.getAttribute(`type`)===`checkbox`)return i.checked||parseInt(i.dataset.minCount||`0`)>0?t.literal(i.checked?`true`:`false`,o):void 0;if(!s)return;let c=i.dataset.nodeKind,l=et(s);if(i.dataset.link)return t.fromTerm(JSON.parse(i.dataset.link));if(i.dataset.class)return l instanceof r||l instanceof e?l:t.namedNode(s);if(c===`http://www.w3.org/ns/shacl#IRI`)return l instanceof r?l:t.namedNode(s);if(c===`http://www.w3.org/ns/shacl#BlankNode`)return l instanceof e?l:t.blankNode(s);if(c===`http://www.w3.org/ns/shacl#BlankNodeOrIRI`)return l instanceof r||l instanceof e?l:t.namedNode(s);if(l instanceof r||l instanceof e||l instanceof n&&!i.dataset.lang&&(!o||o instanceof r&&me.equals(o)))return l;if(i.dataset.lang)o=i.dataset.lang;else if(o instanceof r&&ve.has(o.value)){let e=tt(s);if(e===void 0)return;s=e}else i.type===`number`?s=parseFloat(s):i.type===`datetime-local`?s=Ae(s,i.dataset.xsdTemporalSuffix):i.type===`date`&&o instanceof r&&o.value===`http://www.w3.org/2001/XMLSchema#date`&&(s=ke(s,i.dataset.xsdTemporalSuffix));return t.literal(s,o)}function et(i){let a=i;if(i.startsWith(`<`)&&i.endsWith(`>`))a=i.slice(1,-1);else if(!i.startsWith(`_:`)&&!i.startsWith(`"`))return;let o=s(a,t);return o instanceof r||o instanceof e||o instanceof n?o:void 0}function tt(e){let t=e.replace(`,`,`.`);return/^[-+]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][-+]?[0-9]+)?$/.test(t)?t:void 0}function nt(e){return{value:e.value,language:e.dataset.lang,checked:e.checked,binaryData:e.binaryData}}function rt(e,t){return e?.value===t.value&&e.language===t.language&&e.checked===t.checked&&e.binaryData===t.binaryData}function it(e,t,n){if(t===`application/ld+json`)return at(e);{let r=new o({format:t,prefixes:n});r.addQuads(e);let i=``;return r.end((e,t)=>{e&&console.error(e),i=t}),i}}function at(e){let t=[];for(let r of e){let e={"@id":r.subject.id};if(r.predicate===v)e[`@type`]=r.object.id;else{let t=r.object.value;r.object instanceof n?r.object.language?t={"@language":r.object.language,"@value":r.object.value}:r.object.datatype&&r.object.datatype.value!==`http://www.w3.org/2001/XMLSchema##string`&&(t={"@type":r.object.datatype.value,"@value":r.object.value}):t={"@id":r.object.id},e[r.predicate.value]=t}t.push(e)}return JSON.stringify(t)}var q={};function ot(e){e.predicate===void 0&&e.datatype===void 0?console.warn(`not registering plugin because it does neither define "predicate" nor "datatype"`,e):q[`${e.predicate}^${e.datatype}`]=e}function st(){return Object.entries(q).map(e=>e[1])}function ct(e,t){let n=q[`${e}^${t}`];return n||(n=q[`${e}^undefined`],n)?n:q[`undefined^${t}`]}var lt=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 ut(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 dt(e,n){let r=t.namedNode(n);for(let t of e.getObjects(r,b,_))if(t.termType===`NamedNode`&&e.getQuads(t,v,le,null).length>0)return t}async function ft(e,t){let n={store:new i,importedUrls:[],atts:e},r=[];if(e.shapes?r.push(J(I({rdf:e.shapes}),n,g)):e.shapesUrl&&r.push(J(I({url:e.shapesUrl,proxy:n.atts.proxy,rdfUrlResolver:n.atts.rdfUrlResolver}),n,g)),e.values?r.push(J(I({rdf:e.values}),n,_,t)):e.valuesUrl&&r.push(J(I({url:e.valuesUrl,proxy:n.atts.proxy,rdfUrlResolver:n.atts.rdfUrlResolver}),n,_,t)),await Promise.all(r),e.classInstanceProvider)try{let t=je(n.store),r=await e.classInstanceProvider(t);r&&await J(I({rdf:r}),n,g)}catch(e){console.error(`failed loading class instances`,e)}if(e.valuesSubject||=ut(n.store)||null,e.valuesSubject&&n.store.countQuads(null,null,null,g)===0){let t=[...n.store.getObjects(e.valuesSubject,v,_),...n.store.getObjects(e.valuesSubject,b,_)],r=[];for(let e of t){let t=pt(e.value);!t&&e.value.startsWith(`urn:`)&&n.atts.proxy&&(t=e.value),t&&n.importedUrls.indexOf(t)<0&&(n.importedUrls.push(t),r.push(J(I({url:t,proxy:n.atts.proxy,rdfUrlResolver:n.atts.rdfUrlResolver}),n,g)))}try{await Promise.allSettled(r)}catch(e){console.warn(e)}}return n.store}async function J(e,n,r,i){let a=await e,o=[];for(let e of a){i?.add(e);let a=r;if(n.atts.valuesSubject&&_.equals(r)&&e.graph.id&&e.graph.id!==n.atts.valuesSubject&&(a=e.graph),n.store.add(t.quad(e.subject,e.predicate,e.object,a)),n.atts.loadOwlImports&&x.equals(e.predicate)){let r=pt(e.object.value);r&&n.importedUrls.indexOf(r)<0&&(n.importedUrls.push(r),o.push(J(I({url:r,proxy:n.atts.proxy,rdfUrlResolver:n.atts.rdfUrlResolver}),n,t.namedNode(r))))}}await Promise.allSettled(o)}function pt(e){if(j(e))return e;let t=e.split(`:`);if(t.length===2){let n=F[t[0]];if(n&&(e=e.replace(`${t[0]}:`,n),j(e)))return e}return null}async function mt(e){if(e.template.nodeShapes.size===0)return;let t=e.template.config.resourceLinkProvider;if((!t||t&&!t.lazyLoad)&&(await yt(e.template),gt(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 yt(e.template),n.classList.remove(`loading`));let r=gt(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 p,t.classList.add(`link-chooser`),t.closable=!0,e.template.config.form.appendChild(t)),t.title=`Link existing `+e.template.label,ht(t,e,r),t.open=!0}}),n}function ht(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.value,n.addEventListener(`click`,async()=>{await _t(i,t),e.open=!1}),r.appendChild(n)}e.replaceChildren(r)}function gt(e){let n=e.template.config,r=vt(e.template),a=new Set(Array.from(e.querySelectorAll(`:scope > .property-instance > shacl-node, :scope > .collapsible > .property-instance > shacl-node`)).map(e=>e.nodeId.id)),o=new Map;for(let t of n.form.querySelectorAll(`shacl-node:not([part~="linked-node"])`)){if(!r.has(t.template.id.value)||a.has(t.nodeId.id))continue;let s=new i;t.toRDF(s),o.set(t.nodeId.id,{value:t.nodeId,label:E([...s.getQuads(t.nodeId,null,null,null),...n.store.getQuads(t.nodeId,null,null,null)],n.languages)||n.providedResourceLabels[t.nodeId.value],template:e.template})}if(n.resourceLinkProvider)for(let i of r)for(let r of n.providedConformingResourceIds[i]??[]){let i=t.namedNode(r);!a.has(i.id)&&!o.has(i.id)&&o.set(i.id,{value:i,label:n.providedResourceLabels[r]||E(n.store.getQuads(i,null,null,null),n.languages),template:e.template})}return[...o.values()]}async function _t(e,t){let n=e.value.value;if(e.value.termType===`NamedNode`&&e.template.config.providedResources[n]?.length>0){let t={store:e.template.config.store,importedUrls:[],atts:{loadOwlImports:!1}};await J(I({rdf:e.template.config.providedResources[n]}),t,g),e.template.config.providedResources[n]=``}let r=await Z(e.template,e.value,!0,!0);t.container.insertBefore(r,t.querySelector(`:scope > .add-button-wrapper`)),await t.updateControls()}function vt(e){return new Set(Array.from(e.nodeShapes,e=>e.id.value))}async function yt(e){let t=e.config.resourceLinkProvider;if(!t)return;let n=vt(e);if(n.size===0)return;let r=Me(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 bt(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 bt(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 I({rdf:i.resourceRDF});n.providedResourceLabels[i.resourceId]=E(e.filter(e=>e.subject.value===i.resourceId),n.languages),t&&await J(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 xt(e){let t=new Set;for(let n of e.store.getQuads(null,null,null,_))St(n.object,e.store)&&t.add(n.object.value);await bt(t,!0,e)}function St(e,t){return e.termType===`NamedNode`&&t.countQuads(e,null,null,null)===0}var Y=`:scope > .add-button-wrapper, :scope > .collapsible > .add-button-wrapper`,Ct=`:scope > .property-instance, :scope > .shacl-or-constraint, :scope > .alternative-path-constraint, :scope > shacl-node, :scope > .collapsible > .property-instance, :scope > .collapsible > .alternative-path-constraint`,X=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 f;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.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.pathAlternatives??[this.template.path]).flatMap(t=>this.template.config.store.getQuads(e,t,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,e.predicate.value),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 W(async()=>{let{initializeQueryProperty:e}=await import(`./mode-C_BqcQqf.js`);return{initializeQueryProperty:e}},[]);await e(this)}async addPropertyInstance(e,t,n=!1,r,i=!0){let a;if(this.template.pathAlternatives&&!r)this.template.config.editMode&&(a=We(this,e,t,n));else{let i=r?this.template.pathAlternativeBranches?.[r]:void 0,o=r&&(r!==this.template.path||i)?z(this.template):this.template;if(r&&(o.path=r),i&&(V(o,i,!0),o.label=i.name?.value||i.label||o.label),o.or?.length||o.xone?.length){let t=o.or?.length?o.or:o.xone,i=!1;if(e){let n=Ge(t,e,o.config);n.length&&(a=await Z(B(z(o),n),e,!this.parent.linked,this.parent.linked,this.parent),i=!0)}!i&&o.config.editMode&&(a=G(t,this,o.config,r,o),Et(a,``,o.config.theme.dense,o.config.hierarchyColorsStyleSheet!==void 0,n))}else a=await Z(o,e,n,t||this.parent.linked,this.parent)}return a&&(a.dataset.path=this.template.path,r&&(a.dataset.predicate=r),i&&this.container.insertBefore(a,this.querySelector(Y))),a}async updateControls(){this.template.config.editMode&&!this.parent.linked&&!this.querySelector(Y)&&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(Y)?.classList.toggle(`required`,i<e);let a;a=e>0?i>e:!t||i>1;let o=i<Re(this.template);this.classList.toggle(`may-remove`,a),this.classList.toggle(`may-add`,o)}instanceCount(){return this.querySelectorAll(Ct).length}refreshClassInstances(){if(!(!this.template.class||this.template.hasValue||!this.template.config.editMode))for(let e of this.querySelectorAll(`:scope > .property-instance, :scope > .collapsible > .property-instance`)){let t=e.querySelector(`:scope > .editor`);if(!t||t.dataset.class!==this.template.class.value)continue;let n=K(t),r=A(this.template.class,this.template);n&&!wt(r,n)&&r.push({value:n,children:[]});let i=Tt(r);if(t.dataset.classInstances===i)continue;let a=this.template.config.theme.createListEditor(this.template.label,n??null,R(this.template)>0,r,this.template).querySelector(`.editor`);a.dataset.classInstances=i,t.replaceWith(a)}}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(e,n){for(let r of this.querySelectorAll(`:scope > .property-instance, :scope > .collapsible > .property-instance`)){let i=t.namedNode(r.dataset.predicate??this.template.path);if(r.firstChild instanceof $){let t=r.firstChild.toRDF(e);e.addQuad(n,i,t,this.template.config.valuesGraphId)}else if(this.template.config.editMode)for(let t of r.querySelectorAll(`:scope > .editor`)){let r=K(t);r&&e.addQuad(n,i,r,this.template.config.valuesGraphId)}else{let t=K(r);t&&e.addQuad(n,i,t,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 mt(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(),this.template.nodeShapes.size&&this.dispatchEvent(new Event(`change`,{bubbles:!0,cancelable:!0})),setTimeout(()=>{be(e),e.classList.remove(`fadeIn`)},200))}),e.appendChild(n),e}};function wt(e,t){return e.some(e=>typeof e.value!=`string`&&e.value.equals(t)||wt(e.children??[],t))}function Tt(e){return JSON.stringify(e.map(e=>[typeof e.value==`string`?e.value:`${e.value.termType}:${e.value.value}`,e.label,Tt(e.children??[])]))}async function Z(e,t,n=!1,r=!1,i){let a;if(e.nodeShapes.size){a=document.createElement(`div`),a.classList.add(`property-instance`),a.setAttribute(`part`,`property-instance`);let n=new Set(i?.ancestorShapeIds??[]);i&&n.add(i.template.id.value);for(let i of e.nodeShapes){let o=new $(i,t,e.nodeKind,e.label,r,n);a.appendChild(o),await o.ready}}else{let n=ct(e.path,e.datatype?.value);a=n?e.config.editMode&&!r?n.createEditor(e,t):n.createViewer(e,t):Ye(e,t||null,e.config.editMode&&!r),a.childNodes.length>0&&(a.classList.add(`property-instance`),a.setAttribute(`part`,`property-instance`)),r&&a.classList.add(`linked`)}return e.config.editMode&&(!r||n)?Et(a,e.label,e.config.theme.dense,e.config.hierarchyColorsStyleSheet!==void 0,n):e.config.hierarchyColorsStyleSheet!==void 0&&a.appendChild(Dt(!0)),t&&!e.config.editMode&&Xe(a,t),a.dataset.path=e.path,a}function Et(e,t,n,r,i=!1){let a=Dt(r),o=new d;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 Dt(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`,X);function Ot(e,t){let n=e,r=t.store.getQuads(e,null,null,null),i=T(r,`label`,re,t.languages);i&&(n=i);let a;if(t.attributes.collapse!==null)a=new f,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=parseInt(T(r,`order`)??``)||0;return{element:a,order:o}}var kt={[`${h}node`]:(e,t)=>{e.extendedShapes.add(new At(t,e.config,e))},[`${h}and`]:(e,t)=>{for(let n of e.config.lists[t.value])e.extendedShapes.add(new At(n,e.config,e))},[`${h}property`]:(e,t)=>{let n=e.config.getPropertyTemplate(t,e),r=H(n);if(r){let t=e.properties[r];if(t||(t=[],e.properties[r]=t),n.qualifiedValueShape)t.push(n);else{let i;for(let t=0;t<e.properties[r].length&&!i;t++)e.properties[r][t].qualifiedValueShape||(i=e.properties[r][t]);i?V(i,n):t.push(n)}}},[`${h}nodeKind`]:(e,t)=>{e.nodeKind=t},[`${h}targetClass`]:(e,t)=>{e.targetClass=t},[`${h}or`]:(e,t)=>{e.or=e.config.lists[t.value]},[`${h}xone`]:(e,t)=>{e.xone=e.config.lists[t.value]},[x.id]:(e,t)=>{e.owlImports.add(t)},[`${ae}title`]:(e,t)=>{let n=t;e.label=M(e.config.languages,e.label,n)},[`${re}label`]:(e,t)=>{let n=t;e.label=M(e.config.languages,e.label,n)}},At=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),jt(this,this.config.store.getQuads(e,null,null,null))}};function jt(e,t){for(let n of t)kt[n.predicate.id]?.call(e,e,n.object);return Mt(e),e}function Mt(e){let t=Object.values(e.properties).flat().filter(e=>e.pathAlternatives?.length),n=new Set;for(let r of t){let t={};r.pathAlternatives.every(n=>{let r=e.properties[n];return r?.length!==1||Nt(r[0])?!1:(t[n]=r[0],!0)})&&(r.pathAlternativeBranches=t,r.pathAlternatives.forEach(e=>n.add(e)))}for(let t of n)delete e.properties[t]}function Nt(e){return e.minCount!==void 0||e.maxCount!==void 0||e.qualifiedMinCount!==void 0||e.qualifiedMaxCount!==void 0||e.qualifiedValueShape!==void 0}function Pt(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,H(n)),i=t.some(e=>e.qualifiedValueShape!==void 0),a=Ft(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[H(r)],V(e,r,!0),i&&e.nodeShapes.delete(i)}Lt(e)}}}}function Ft(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||!It(n.parent,r.parent)||!It(n.qualifiedValueShape,r.qualifiedValueShape))return!1}return!0}function It(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 Lt(e){for(let t of[`xone`,`or`]){let n=e[t];if(!n?.length)continue;let r=n.filter(t=>Rt(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 Rt(e,t){let n=t.config.store.getQuads(e,null,null,null);return zt(n,`http://www.w3.org/ns/shacl#datatype`,t.datatype)&&zt(n,C.id,t.class)&&zt(n,`http://www.w3.org/ns/shacl#nodeKind`,t.nodeKind)}function zt(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 e extends HTMLElement{constructor(n,r,a,o,s,c=new Set,l){super(),this.template=n,this.linked=s??!1,this.ancestorShapeIds=c,this.queryContext=l,this.setAttribute(`part`,`node`);let u=r;u||=(!a&&n.nodeKind&&(a=n.nodeKind),a===void 0&&n.config.attributes.valuesNamespace||a?.value===`http://www.w3.org/ns/shacl#IRI`?t.namedNode(n.config.attributes.valuesNamespace+m()):t.blankNode(m())),this.nodeId=u;let d=JSON.stringify([n.id,this.nodeId]);if(r&&n.config.renderedNodes.has(d)){o||=`Link`;let e=document.createElement(`label`);e.innerText=o,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`),a=r.termType===`BlankNode`?`_:`+r.value:r.value,s=Array.from(this.template.config.form.querySelectorAll(`shacl-node:not([part~="linked-node"])`)).find(e=>e.nodeId.equals(r)),c=new i;s?.toRDF(c),n.innerText=E([...c.getQuads(r,null,null,null),...this.template.config.store.getQuads(r,null,null,null)],this.template.config.languages)||a,n.classList.add(`ref-link`),n.onclick=()=>{this.template.config.form.querySelector(`shacl-node[data-node-id='${a}']:not([part~='linked-node'])`)?.scrollIntoView()},this.appendChild(n),this.style.flexDirection=`row`,this.ready=Promise.resolve()}else{n.config.renderedNodes.add(d);let t=this.ancestorShapeIds,i=this.template.id.value,a=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)}Pt(n),this.ready=(async()=>{let c=new Set(t);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 t of n.extendedShapes){let n=new e(t,r,void 0,void 0,s,c,a);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),o){let e=document.createElement(`h1`);e.innerText=o,e.setAttribute(`part`,`node-title`),this.prepend(e)}})()}}toRDF(e,n,r=``){if(n||=this.nodeId,!this.linked){for(let t of this.querySelectorAll(`:scope > shacl-node, :scope > .shacl-group > shacl-node, :scope > shacl-property, :scope > .shacl-group > shacl-property`))t.toRDF(e,n);this.template.targetClass&&e.addQuad(n,v,this.template.targetClass,this.template.config.valuesGraphId),r&&e.addQuad(n,t.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}']`);if(!t){let n=Ot(e.group,e.config);t=n.element,Vt(this,t,n.order)}r=t}else console.warn(`ignoring unknown group reference`,e.group,`existing groups:`,e.config.groups);let i=new X(e,this);e.config.queryMode?await i.initializeQuery():await i.bindValues(t,n),(e.config.editMode||e.config.queryMode||i.instanceCount()>0)&&(Vt(r||this,i,e.order),e.config.queryMode||await i.updateControls())}async tryResolve(e,t,n){let r=!1;if(t){let i=Ke(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(G(e,this,n))}},Bt=new WeakMap;function Vt(e,t,n=0){Bt.set(t,n);let r=Array.from(e.children).find(e=>e!==t&&(Bt.get(e)??0)>n);e.insertBefore(t,r??null)}window.customElements.define(`shacl-node`,$);function Ht(e){return e.datatype!==void 0&&ge.has(e.datatype)}export{g as $,I as A,De as B,Le as C,B as D,Ie as E,Ne as F,h as G,b as H,we as I,v as J,te as K,A as L,F as M,P as N,ze as O,D as P,w as Q,E as R,W as S,z as T,ve as U,_ as V,_e as W,le as X,ue as Y,fe as Z,Xe as _,X as a,Je as b,dt as c,ft as d,he as et,lt as f,it as g,ot as h,Pt as i,L as j,Pe as k,ut as l,st as m,$ as n,Dt as o,ct as p,y as q,At as r,xt as s,Ht as t,J as u,Ze as v,R as w,G as x,Qe as y,Oe as z};