@digitalculture/ochre-sdk 0.11.17 → 0.11.19

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitalculture/ochre-sdk",
3
- "version": "0.11.17",
3
+ "version": "0.11.19",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Node.js library for working with OCHRE (Online Cultural and Historical Research Environment) data",
@@ -43,16 +43,15 @@
43
43
  "zod": "^4.1.12"
44
44
  },
45
45
  "devDependencies": {
46
- "@antfu/eslint-config": "^6.0.0",
47
- "@arethetypeswrong/cli": "^0.18.2",
48
- "@changesets/cli": "^2.29.7",
49
- "@types/node": "^24.9.1",
46
+ "@antfu/eslint-config": "^6.1.0",
47
+ "@types/node": "^24.9.2",
48
+ "bumpp": "^10.3.1",
50
49
  "eslint": "^9.38.0",
51
50
  "prettier": "^3.6.2",
52
51
  "terser": "^5.44.0",
53
- "tsdown": "^0.15.9",
52
+ "tsdown": "^0.15.11",
54
53
  "typescript": "^5.9.3",
55
- "vitest": "^4.0.3"
54
+ "vitest": "^4.0.4"
56
55
  },
57
56
  "scripts": {
58
57
  "dev": "tsdown src/index.ts --watch",
@@ -64,8 +63,6 @@
64
63
  "check-types": "tsc --noEmit",
65
64
  "check-exports": "attw --pack .",
66
65
  "test": "vitest run",
67
- "ci": "pnpm run build && pnpm run lint && pnpm run format && pnpm run check-types && pnpm run check-exports",
68
- "changeset": "changeset add",
69
- "release": "changeset version && changeset publish"
66
+ "release": "bumpp"
70
67
  }
71
68
  }
package/dist/index.cjs DELETED
@@ -1,16 +0,0 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`zod`);c=s(c);const l=c.z.uuid({error:`Invalid UUID provided`}),u=c.z.object({type:c.z.enum([`traditional`,`digital-collection`,`plum`,`cedar`,`elm`,`maple`,`oak`,`palm`],{error:`Invalid website type`}),status:c.z.enum([`development`,`preview`,`production`],{error:`Invalid website status`}),privacy:c.z.enum([`public`,`password`,`private`],{error:`Invalid website privacy`})}),d=c.z.enum([`annotated-document`,`annotated-image`,`audio-player`,`bibliography`,`button`,`collection`,`empty-space`,`entries`,`iframe`,`iiif-viewer`,`image`,`image-gallery`,`map`,`network-graph`,`query`,`search-bar`,`table`,`text`,`timeline`,`video`],{error:`Invalid component`}),f=c.z.enum([`resource`,`spatialUnit`,`concept`,`period`,`bibliography`,`person`,`propertyValue`,`set`,`tree`]),p=c.z.enum([`string`,`integer`,`decimal`,`boolean`,`date`,`dateTime`,`time`,`coordinate`,`IDREF`]),m=c.z.object({uuid:c.z.uuid({error:`Invalid UUID`}),filter:c.z.string().optional(),page:c.z.number().positive({error:`Page must be positive`}),perPage:c.z.number().positive({error:`Per page must be positive`})}).strict(),h=c.z.string().transform(e=>e.split(` `)).pipe(c.z.array(c.z.enum([`bold`,`italic`,`underline`]))),g=c.z.string().transform(e=>e.split(` `)).pipe(c.z.array(c.z.enum([`newline`,`trailing`,`leading`]))),_=c.z.email({error:`Invalid email`}),v={includeNestedProperties:!1};function y(e,t,n=v){let{includeNestedProperties:r}=n,i=e.find(e=>e.uuid===t);if(i)return i;if(r){for(let n of e)if(n.properties.length>0){let e=y(n.properties,t,{includeNestedProperties:r});if(e)return e}}return null}function b(e,t,n=v){let{includeNestedProperties:r}=n,i=e.find(e=>e.uuid===t);if(i)return i.values.map(e=>e.content);if(r){for(let n of e)if(n.properties.length>0){let e=b(n.properties,t,{includeNestedProperties:r});if(e)return e}}return null}function x(e,t,n=v){let{includeNestedProperties:r}=n,i=b(e,t,{includeNestedProperties:r});if(i!==null&&i.length>0)return i[0];if(r){for(let n of e)if(n.properties.length>0){let e=x(n.properties,t,{includeNestedProperties:r});if(e!==null)return e}}return null}function S(e,t,n=v){let{includeNestedProperties:r}=n,i=e.find(e=>e.label===t);if(i)return i;if(r){for(let n of e)if(n.properties.length>0){let e=S(n.properties,t,{includeNestedProperties:r});if(e)return e}}return null}function C(e,t,n=v){let{includeNestedProperties:r}=n,i=e.find(e=>e.label===t);if(i)return i.values.map(e=>e.content);if(r){for(let n of e)if(n.properties.length>0){let e=C(n.properties,t,{includeNestedProperties:r});if(e)return e}}return null}function w(e,t,n=v){let{includeNestedProperties:r}=n,i=C(e,t,{includeNestedProperties:r});if(i!==null&&i.length>0)return i[0];if(r){for(let n of e)if(n.properties.length>0){let e=w(n.properties,t,{includeNestedProperties:r});if(e!==null)return e}}return null}function T(e,t=v){let{includeNestedProperties:n}=t,r=[];for(let t of e)if(!r.some(e=>e.uuid===t.uuid)&&(r.push(t),t.properties.length>0&&n)){let e=T(t.properties,{includeNestedProperties:!0});for(let t of e)r.some(e=>e.uuid===t.uuid)||r.push(t)}return r}function E(e,t=v){let{includeNestedProperties:n}=t,r=[];for(let t of e)if(!r.includes(t.label)&&(r.push(t.label),t.properties.length>0&&n)){let e=E(t.properties,{includeNestedProperties:!0});for(let t of e)r.includes(t)||r.push(t)}return r}function D(e,t,n=v){let{includeNestedProperties:r}=n;if(t.label.toLocaleLowerCase(`en-US`)===`all fields`||e.label.toLocaleLowerCase(`en-US`)===t.label.toLocaleLowerCase(`en-US`)){let n=e.values.some(e=>e.content===null?!1:typeof e.content==`string`?typeof t.value==`string`?e.content.toLocaleLowerCase(`en-US`).includes(t.value.toLocaleLowerCase(`en-US`)):!1:typeof e.content==`number`?typeof t.value==`number`?e.content===t.value:!1:typeof e.content==`boolean`&&typeof t.value==`boolean`?e.content===t.value:!1);return!n&&r&&(n=e.properties.some(e=>D(e,t,{includeNestedProperties:!0}))),n}return!1}const O=`f1c131b6-1498-48a4-95bf-a9edae9fd518`,k=`b9ca2732-78f4-416e-b77f-dae7647e68a9`,ee=`3e6f86ab-df81-45ae-8257-e2867357df56`,te=`e1647bef-d801-4100-bdde-d081c422f763`;function ne(e,t){return e.find(e=>e.lang===t)??null}function A(e){let t=e.split(` `),n=[];for(let e of t){let t=e.replaceAll(/(?<=\s|^)[([{]+|[)\]}]+(?=\s|$)/g,``).replaceAll(/[!),:;?\]]/g,``).replace(/\.$/,``),r=e.indexOf(t),i=e.slice(0,r),a=e.slice(r+t.length);if(_.safeParse(t).success){n.push(`${i}<ExternalLink href="mailto:${t}">${t}</ExternalLink>${a}`);continue}n.push(e)}return n.join(` `)}function j(e,t){let n=e,r=h.safeParse(t);if(!r.success)return console.warn(`Invalid render options string provided: “${t}”`),e;for(let e of r.data)switch(e){case`bold`:n=`**${n}**`;break;case`italic`:n=`*${n}*`;break;case`underline`:n=`_${n}_`;break}return n.replaceAll(`&#39;`,`'`)}function M(e,t){let n=e,r=g.safeParse(t);if(!r.success)return console.warn(`Invalid whitespace string provided: “${t}”`),e;for(let e of r.data)switch(e){case`newline`:n=`<br />\n${n}`;break;case`trailing`:n=`${n} `;break;case`leading`:n=` ${n}`;break}return n.replaceAll(`&#39;`,`'`)}function N(e){return String(e).replaceAll(`&#39;`,`'`).replaceAll(`{`,String.raw`\{`).replaceAll(`}`,String.raw`\}`)}function P(e){let t=``;switch(typeof e.string){case`string`:case`number`:case`boolean`:t=N(e.string);break;case`object`:{let n=Array.isArray(e.string)?e.string:[e.string];for(let e of n)if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)t+=N(e);else if(`string`in e)t+=F(e);else{let n=e.content==null?``:e.rend==null?N(e.content):j(N(e.content),e.rend),r=e.whitespace==null?n:M(n,e.whitespace);t+=r}break}default:t=``;break}return t}function F(e){if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return A(N(e));if(`whitespace`in e&&!(`content`in e)&&!(`string`in e))return e.whitespace===`newline`?`
2
- `:M(``,e.whitespace);if(`links`in e){let t=``;t=typeof e.string==`object`?I(e.string):N(e.string).replaceAll(`<`,String.raw`\<`).replaceAll(`{`,String.raw`\{`);let n=Array.isArray(e.links)?e.links:[e.links];for(let r of n)if(`resource`in r){let n=Array.isArray(r.resource)?r.resource[0]:r.resource,i=null;switch(n.content!=null&&(i=N(n.content).replaceAll(`<`,String.raw`\<`).replaceAll(`{`,String.raw`\{`)),n.type){case`image`:return n.rend===`inline`?`<InlineImage uuid="${n.uuid}" ${i===null?``:`content="${i}"`} height={${n.height?.toString()??`null`}} width={${n.width?.toString()??`null`}} />`:n.publicationDateTime==null?`<TooltipSpan${i===null?``:` content="${i}"`}>${t}</TooltipSpan>`:`<InternalLink uuid="${n.uuid}">${t}</InternalLink>`;case`internalDocument`:if(`properties`in e&&e.properties!=null){let r=Array.isArray(e.properties.property)?e.properties.property[0]:e.properties.property;if(r!=null){let e=r.label.uuid,i=typeof r.value==`object`&&`uuid`in r.value&&r.value.uuid!=null?r.value.uuid:null;return e===O&&i===k&&(r.property==null?null:Array.isArray(r.property)?r.property[0]:r.property)!=null?`<Annotation type="hover-card" uuid="${n.uuid}">${t}</Annotation>`:`<InternalLink uuid="${n.uuid}" properties="${e}"${i===null?``:` value="${i}"`}>${t}</InternalLink>`}else return`<InternalLink uuid="${n.uuid}">${t}</InternalLink>`}else return`<InternalLink uuid="${n.uuid}">${t}</InternalLink>`;case`externalDocument`:return n.publicationDateTime==null?`<TooltipSpan${i===null?``:` content="${i}"`}>${t}</TooltipSpan>`:`<ExternalLink href="https:\\/\\/ochre.lib.uchicago.edu/ochre?uuid=${n.uuid}&load" ${i===null?``:`content="${i}"`}>${t}</ExternalLink>`;case`webpage`:return`<ExternalLink href="${n.href}" ${i===null?``:`content="${i}"`}>${t}</ExternalLink>`;default:return``}}else if(`concept`in r){let e=Array.isArray(r.concept)?r.concept[0]:r.concept;return e.publicationDateTime==null?`<TooltipSpan>${t}</TooltipSpan>`:`<InternalLink uuid="${e.uuid}">${t}</InternalLink>`}else if(`set`in r){let e=Array.isArray(r.set)?r.set[0]:r.set;return e.publicationDateTime==null?`<TooltipSpan>${t}</TooltipSpan>`:`<InternalLink uuid="${e.uuid}">${t}</InternalLink>`}else if(`person`in r){let e=Array.isArray(r.person)?r.person[0]:r.person,n=e.identification?[`string`,`number`,`boolean`].includes(typeof e.identification.label)?N(e.identification.label):I(e.identification.label):null;return e.publicationDateTime==null?`<TooltipSpan${n===null?``:` content="${n}"`}>${t}</TooltipSpan>`:`<InternalLink uuid="${e.uuid}">${t}</InternalLink>`}else if(`bibliography`in r){let e=Array.isArray(r.bibliography)?r.bibliography[0]:r.bibliography;return e.publicationDateTime==null?`<TooltipSpan>${t}</TooltipSpan>`:`<InternalLink uuid="${e.uuid}">${t}</InternalLink>`}else if(`properties`in e&&e.properties!=null){let n=Array.isArray(e.properties.property)?e.properties.property[0]:e.properties.property;if(n!=null){let e=n.label.uuid,r=typeof n.value==`object`&&`uuid`in n.value&&n.value.uuid!=null?n.value.uuid:null;if(e===O&&r===k){let e=n.property==null?null:Array.isArray(n.property)?n.property[0]:n.property;if(e!=null&&(typeof e.value==`object`&&`uuid`in e.value&&e.value.uuid!=null?e.value.uuid:null)===`3e6f86ab-df81-45ae-8257-e2867357df56`&&e.property!=null){let n=`default`,r=`md`,i=[],a=Array.isArray(e.property)?e.property:[e.property];if(a.length>0){let e=a.find(e=>e.label.uuid===te);if(e!=null){let t=N(e.value.content),i=e.property==null?null:Array.isArray(e.property)?e.property[0]:e.property;i!=null&&(r=N(i.value.content)),n=t}let t=a.filter(e=>e.label.uuid!==te);t.length>0&&(i=t.map(e=>({label:N(e.label.content),value:N(e.value.content)})))}return`<Annotation type="text-styling" variant="${n}" size="${r}"${i.length>0?` cssStyles={{default: ${JSON.stringify(i)}, tablet: [], mobile: []}}`:``}>${t}</Annotation>`}}}}}let t=``;if(`string`in e){let n=Array.isArray(e.string)?e.string:[e.string];for(let e of n)t+=F(e);return`whitespace`in e&&e.whitespace!=null&&(t=M(A(t),e.whitespace)),t.replaceAll(`&#39;`,`'`)}else t=N(e.content),e.rend!=null&&(t=j(A(t),e.rend)),e.whitespace!=null&&(t=M(A(t),e.whitespace));return t}function I(e,t=`eng`){switch(typeof e.content){case`string`:case`number`:case`boolean`:return e.rend==null?N(e.content):j(N(e.content),e.rend);case`object`:if(Array.isArray(e.content)){let n=ne(e.content,t);if(n)return P(n);{let n=e.content[0];if(!n)throw Error(`No string item found for language “${t}” in the following content:\n${JSON.stringify(e.content)}.`);return P(n)}}else return P(e.content);default:return String(e.content)}}function re(e){let t=e.find(e=>f.safeParse(e).success);if(!t){let t=e.find(e=>![`uuid`,`uuidBelongsTo`,`belongsTo`,`publicationDateTime`,`metadata`,`languages`].includes(e));throw Error(`Invalid OCHRE data; found unexpected "${t}" key`)}return f.parse(t)}function L(e){try{let t={label:[`string`,`number`,`boolean`].includes(typeof e.label)?N(e.label):I(e.label),abbreviation:``,code:e.code??null};for(let n of Object.keys(e).filter(e=>e!==`label`&&e!==`code`))t[n]=typeof e[n]==`string`?N(e[n]):I(e[n]);return t}catch(e){return console.error(e),{label:``,abbreviation:``,code:null}}}function ie(e){return e==null?[`eng`]:Array.isArray(e)?e.map(e=>I(e)):[I(e)]}function ae(e){let t={label:``,abbreviation:``,code:null};if(e.item)if(e.item.label||e.item.abbreviation){let n=``,r=``,i=null;e.item.label&&(n=I(e.item.label)),e.item.abbreviation&&(r=I(e.item.abbreviation)),e.item.identification.code&&(i=e.item.identification.code),t={label:n,abbreviation:r,code:i}}else t=L(e.item.identification);let n=null,r=e.project?.identification?L(e.project.identification):null;return r&&(n={...r,website:e.project?.identification.website??null}),{project:n?{identification:n}:null,item:e.item?{identification:t,category:e.item.category,type:e.item.type,maxLength:e.item.maxLength??null}:null,dataset:I(e.dataset),publisher:I(e.publisher),languages:ie(e.language),identifier:I(e.identifier),description:I(e.description)}}function R(e){return{uuid:e.uuid,publicationDateTime:e.publicationDateTime==null?null:new Date(e.publicationDateTime),number:e.n,content:N(e.content)}}function z(e){return{nodes:(Array.isArray(e.context)?e.context:[e.context]).map(e=>{let t=[];if(`spatialUnit`in e&&e.spatialUnit){let n=Array.isArray(e.spatialUnit)?e.spatialUnit:[e.spatialUnit];for(let e of n)t.push(R(e))}return{tree:R(e.tree),project:R(e.project),spatialUnit:t}}),displayPath:e.displayPath}}function B(e){return typeof e.license==`string`?null:{content:e.license.content,url:e.license.target}}function oe(e){return{uuid:e.uuid,category:`person`,publicationDateTime:e.publicationDateTime==null?null:new Date(e.publicationDateTime),type:e.type??null,number:e.n??null,context:e.context?z(e.context):null,date:e.date??null,identification:e.identification?L(e.identification):null,availability:e.availability?B(e.availability):null,image:e.image?W(e.image):null,address:e.address?{country:e.address.country??null,city:e.address.city??null,state:e.address.state??null}:null,description:e.description?typeof e.description==`string`||typeof e.description==`number`||typeof e.description==`boolean`?N(e.description):I(e.description):null,coordinates:K(e.coordinates),content:e.content==null?null:N(e.content),notes:e.notes?G(Array.isArray(e.notes.note)?e.notes.note:[e.notes.note]):[],events:e.events?ue(Array.isArray(e.events.event)?e.events.event:[e.events.event]):[],properties:e.properties?q(Array.isArray(e.properties.property)?e.properties.property:[e.properties.property]):[],bibliographies:e.bibliographies?Y(Array.isArray(e.bibliographies.bibliography)?e.bibliographies.bibliography:[e.bibliographies.bibliography]):[]}}function V(e){let t=[];for(let n of e)t.push(oe(n));return t}function se(e){let t=`resource`in e?e.resource:`spatialUnit`in e?e.spatialUnit:`concept`in e?e.concept:`set`in e?e.set:`tree`in e?e.tree:`person`in e?e.person:`bibliography`in e?e.bibliography:`propertyValue`in e?e.propertyValue:null;if(!t)throw Error(`Invalid link provided: ${JSON.stringify(e,null,2)}`);let n=Array.isArray(t)?t:[t],r=[];for(let t of n){let n={category:`resource`in e?`resource`:`spatialUnit`in e?`spatialUnit`:`concept`in e?`concept`:`set`in e?`set`:`person`in e?`person`:`tree`in e?`tree`:`bibliography`in e?`bibliography`:`propertyValue`in e?`propertyValue`:null,content:`content`in t?t.content==null?null:N(t.content):null,href:`href`in t&&t.href!=null?t.href:null,fileFormat:`fileFormat`in t&&t.fileFormat!=null?t.fileFormat:null,fileSize:`fileSize`in t&&t.fileSize!=null?t.fileSize:null,uuid:t.uuid??null,type:t.type??null,identification:t.identification?L(t.identification):null,description:`description`in t&&t.description!=null?I(t.description):null,image:null,bibliographies:`bibliography`in e?Y(Array.isArray(e.bibliography)?e.bibliography:[e.bibliography]):null,publicationDateTime:t.publicationDateTime==null?null:new Date(t.publicationDateTime)};`height`in t&&t.height!=null&&t.width!=null&&t.heightPreview!=null&&t.widthPreview!=null&&(n.image={isInline:t.rend===`inline`,isPrimary:t.isPrimary??!1,heightPreview:t.heightPreview,widthPreview:t.widthPreview,height:t.height,width:t.width}),r.push(n)}return r}function H(e){let t=[];for(let n of e)t.push(...se(n));return t}function U(e,t=`eng`){let n=``,r=Array.isArray(e)?e.find(e=>e.lang===t):e;if(typeof r.string==`string`||typeof r.string==`number`||typeof r.string==`boolean`)n+=A(N(r.string));else{let e=Array.isArray(r.string)?r.string:[r.string];for(let t of e)n+=F(t)}return n}function W(e){return{publicationDateTime:e.publicationDateTime==null?null:new Date(e.publicationDateTime),identification:e.identification?L(e.identification):null,url:e.href??(e.htmlImgSrcPrefix==null&&e.content!=null?N(e.content):null),htmlPrefix:e.htmlImgSrcPrefix??null,content:e.htmlImgSrcPrefix!=null&&e.content!=null?N(e.content):null,widthPreview:e.widthPreview??null,heightPreview:e.heightPreview??null,width:e.width??null,height:e.height??null}}function G(e,t=`eng`){let n=[];for(let r of e){if(typeof r==`string`){if(r===``)continue;n.push({number:-1,title:null,date:null,authors:[],content:r});continue}let e=``,i=r.content==null?[]:Array.isArray(r.content)?r.content:[r.content];if(i.length===0)continue;let a=i.find(e=>e.lang===t);if(!a&&(a=i[0],!a))throw Error(`Note does not have a valid content item: ${JSON.stringify(r,null,2)}`);e=typeof a.string==`string`||typeof a.string==`number`||typeof a.string==`boolean`?A(N(a.string)):A(U(a)),n.push({number:r.noteNo,title:a.title==null?null:N(a.title),date:r.date??null,authors:r.authors?V(Array.isArray(r.authors.author)?r.authors.author:[r.authors.author]):[],content:e})}return n}function K(e){if(e==null)return[];let t=[],n=Array.isArray(e.coord)?e.coord:[e.coord];for(let e of n){let n=`source`in e&&e.source?e.source.context===`self`?{context:`self`,uuid:e.source.label.uuid,label:I(e.source.label)}:e.source.context===`related`?{context:`related`,uuid:e.source.label.uuid,label:I(e.source.label),value:I(e.source.value)}:{context:`inherited`,uuid:e.source.label.uuid,item:{uuid:e.source.item.label.uuid,label:I(e.source.item.label)},label:I(e.source.label)}:null;switch(e.type){case`point`:t.push({type:e.type,latitude:e.latitude,longitude:e.longitude,altitude:e.altitude??null,source:n});break;case`plane`:t.push({type:e.type,minimum:{latitude:e.minimum.latitude,longitude:e.minimum.longitude},maximum:{latitude:e.maximum.latitude,longitude:e.maximum.longitude},source:n});break}}return t}function ce(e){return{number:e.observationNo,date:e.date??null,observers:e.observers==null?[]:typeof e.observers==`string`||typeof e.observers==`number`||typeof e.observers==`boolean`?N(e.observers).split(`;`).map(e=>e.trim()):V(Array.isArray(e.observers)?e.observers:[e.observers]),notes:e.notes?G(Array.isArray(e.notes.note)?e.notes.note:[e.notes.note]):[],links:e.links?H(Array.isArray(e.links)?e.links:[e.links]):[],properties:e.properties?q(Array.isArray(e.properties.property)?e.properties.property:[e.properties.property]):[],bibliographies:e.bibliographies?Y(Array.isArray(e.bibliographies.bibliography)?e.bibliographies.bibliography:[e.bibliographies.bibliography]):[]}}function le(e){let t=[];for(let n of e)t.push(ce(n));return t}function ue(e){let t=[];for(let n of e)t.push({date:n.dateTime==null?null:new Date(n.dateTime),label:I(n.label),location:n.location?{uuid:n.location.uuid,content:I(n.location)}:null,agent:n.agent?{uuid:n.agent.uuid,content:I(n.agent)}:null,comment:n.comment?I(n.comment):null,value:n.value?N(n.value):null});return t}function de(e,t=`eng`){let n=(`value`in e&&e.value?Array.isArray(e.value)?e.value:[e.value]:[]).map(e=>{let t=null,n=null;if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return t=N(e),{content:t,label:null,dataType:`string`,isUncertain:!1,category:`value`,type:null,uuid:null,publicationDateTime:null,unit:null,href:null,slug:null};{let r=`string`;if(e.dataType!=null){let{data:t,error:n}=p.safeParse(e.dataType);if(n)throw Error(`Invalid property value content type: "${e.dataType}"`);r=t}switch(r){case`integer`:case`decimal`:case`time`:e.rawValue==null?(t=Number(e.content),n=null):(t=Number(e.rawValue),n=e.content?I({content:e.content}):null);break;case`boolean`:e.rawValue==null?(t=e.content===!0,n=null):(t=e.rawValue===`true`,n=e.content?I({content:e.content}):null);break;default:`slug`in e&&e.slug!=null?t=N(e.slug):e.content!=null&&(e.rawValue==null?(t=I({content:e.content}),n=null):(t=N(e.rawValue),n=e.content?I({content:e.content}):null));break}return{content:t,dataType:r,isUncertain:e.isUncertain??!1,label:n,category:e.category??null,type:e.type??null,uuid:e.uuid??null,publicationDateTime:e.publicationDateTime==null?null:new Date(e.publicationDateTime),unit:e.unit??null,href:e.href??null,slug:e.slug??null}}});return{uuid:e.label.uuid,label:I(e.label,t).replace(/\s*\.{3}$/,``).trim(),values:n,comment:e.comment==null?null:I(e.comment),properties:e.property?q(Array.isArray(e.property)?e.property:[e.property]):[]}}function q(e,t=`eng`){let n=[];for(let r of e)n.push(de(r,t));return n}function fe(e){let t=[];for(let n of e)t.push({date:n.date,number:n.interpretationNo,properties:n.properties?q(Array.isArray(n.properties.property)?n.properties.property:[n.properties.property]):[],bibliographies:n.bibliographies?Y(Array.isArray(n.bibliographies.bibliography)?n.bibliographies.bibliography:[n.bibliographies.bibliography]):[]});return t}function pe(e){let t={area:[],width:e.width,height:e.height},n=Array.isArray(e.area)?e.area:[e.area];for(let e of n)t.area.push({uuid:e.uuid,publicationDateTime:e.publicationDateTime==null?null:new Date(e.publicationDateTime),type:e.type,title:N(e.title),shape:e.shape===`rect`?`rectangle`:e.shape===`circle`?`circle`:`polygon`,coords:e.coords.split(`,`).map(e=>Number.parseInt(e)),slug:e.slug?N(e.slug):null});return t}function me(e){return{uuid:e.uuid,category:`period`,publicationDateTime:e.publicationDateTime==null?null:new Date(e.publicationDateTime),type:e.type??null,number:e.n??null,identification:L(e.identification),description:e.description?I(e.description):null}}function J(e){let t=[];for(let n of e)t.push(me(n));return t}function he(e){let t=null;e.source?.resource&&(t={uuid:e.source.resource.uuid,publicationDateTime:e.source.resource.publicationDateTime?new Date(e.source.resource.publicationDateTime):null,type:e.source.resource.type,identification:L(e.source.resource.identification)});let n=null,r=null;if(e.citationFormatSpan)try{n=JSON.parse(`"${e.citationFormatSpan}"`).replaceAll(`&lt;`,`<`).replaceAll(`&gt;`,`>`)}catch{n=e.citationFormatSpan}if(e.referenceFormatDiv)try{r=JSON.parse(`"${e.referenceFormatDiv}"`).replaceAll(`&lt;`,`<`).replaceAll(`&gt;`,`>`)}catch{r=e.referenceFormatDiv}return{uuid:e.uuid??null,zoteroId:e.zoteroId??null,category:`bibliography`,publicationDateTime:e.publicationDateTime==null?null:new Date(e.publicationDateTime),type:e.type??null,number:e.n??null,identification:e.identification?L(e.identification):null,projectIdentification:e.project?.identification?L(e.project.identification):null,context:e.context?z(e.context):null,citation:{details:e.citationDetails??null,format:e.citationFormat??null,short:n,long:r},publicationInfo:{publishers:e.publicationInfo?.publishers?V(Array.isArray(e.publicationInfo.publishers.publishers.person)?e.publicationInfo.publishers.publishers.person:[e.publicationInfo.publishers.publishers.person]):[],startDate:e.publicationInfo?.startDate?new Date(e.publicationInfo.startDate.year,e.publicationInfo.startDate.month,e.publicationInfo.startDate.day):null},entryInfo:e.entryInfo?{startIssue:N(e.entryInfo.startIssue),startVolume:N(e.entryInfo.startVolume)}:null,source:{resource:t,documentUrl:e.sourceDocument?`https://ochre.lib.uchicago.edu/ochre?uuid=${e.sourceDocument.uuid}&load`:null},periods:e.periods?J(Array.isArray(e.periods.period)?e.periods.period:[e.periods.period]):[],authors:e.authors?V(Array.isArray(e.authors.person)?e.authors.person:[e.authors.person]):[],properties:e.properties?q(Array.isArray(e.properties.property)?e.properties.property:[e.properties.property]):[]}}function Y(e){let t=[];for(let n of e)t.push(he(n));return t}function ge(e){return{uuid:e.uuid,category:`propertyValue`,number:e.n,publicationDateTime:e.publicationDateTime?new Date(e.publicationDateTime):null,context:e.context?z(e.context):null,availability:e.availability?B(e.availability):null,identification:L(e.identification),date:e.date??null,creators:e.creators?V(Array.isArray(e.creators.creator)?e.creators.creator:[e.creators.creator]):[],description:e.description?typeof e.description==`string`||typeof e.description==`number`||typeof e.description==`boolean`?N(e.description):I(e.description):``,notes:e.notes?G(Array.isArray(e.notes.note)?e.notes.note:[e.notes.note]):[],links:e.links?H(Array.isArray(e.links)?e.links:[e.links]):[]}}function _e(e){let t=[];for(let n of e)t.push(ge(n));return t}function ve(e,t,n){if(typeof e.items==`string`)throw TypeError(`Invalid OCHRE data: Tree has no items`);let r=[];e.creators&&(r=V(Array.isArray(e.creators.creator)?e.creators.creator:[e.creators.creator]));let i=null;e.date!=null&&(i=e.date);let a=n??re(Object.keys(e.items)),o=[];switch(a){case`resource`:if(!(`resource`in e.items))throw Error(`Invalid OCHRE data: Tree has no resources`);o=X(Array.isArray(e.items.resource)?e.items.resource:[e.items.resource]);break;case`spatialUnit`:if(!(`spatialUnit`in e.items))throw Error(`Invalid OCHRE data: Tree has no spatial units`);o=Se(Array.isArray(e.items.spatialUnit)?e.items.spatialUnit:[e.items.spatialUnit]);break;case`concept`:if(!(`concept`in e.items))throw Error(`Invalid OCHRE data: Tree has no concepts`);o=Te(Array.isArray(e.items.concept)?e.items.concept:[e.items.concept]);break;case`period`:if(!(`period`in e.items))throw Error(`Invalid OCHRE data: Tree has no periods`);o=J(Array.isArray(e.items.period)?e.items.period:[e.items.period]);break;case`bibliography`:if(!(`bibliography`in e.items))throw Error(`Invalid OCHRE data: Tree has no bibliographies`);o=Y(Array.isArray(e.items.bibliography)?e.items.bibliography:[e.items.bibliography]);break;case`person`:if(!(`person`in e.items))throw Error(`Invalid OCHRE data: Tree has no persons`);o=V(Array.isArray(e.items.person)?e.items.person:[e.items.person]);break;case`propertyValue`:if(!(`propertyValue`in e.items))throw Error(`Invalid OCHRE data: Tree has no property values`);o=_e(Array.isArray(e.items.propertyValue)?e.items.propertyValue:[e.items.propertyValue]);break;case`set`:{if(!(`set`in e.items))throw Error(`Invalid OCHRE data: Tree has no sets`);let t=[];for(let r of Array.isArray(e.items.set)?e.items.set:[e.items.set])t.push(ye(r,n));o=t;break}default:throw Error(`Invalid OCHRE data: Tree has no items or is malformed`)}return{uuid:e.uuid,category:`tree`,publicationDateTime:new Date(e.publicationDateTime),identification:L(e.identification),creators:r,license:B(e.availability),date:i,type:e.type,number:e.n,items:o,properties:e.properties?q(Array.isArray(e.properties.property)?e.properties.property:[e.properties.property]):[]}}function ye(e,t){if(typeof e.items==`string`)throw TypeError(`Invalid OCHRE data: Set has no items`);let n=t??re(Object.keys(e.items)),r=[];switch(n){case`resource`:if(!(`resource`in e.items))throw Error(`Invalid OCHRE data: Set has no resources`);r=X(Array.isArray(e.items.resource)?e.items.resource:[e.items.resource]);break;case`spatialUnit`:if(!(`spatialUnit`in e.items))throw Error(`Invalid OCHRE data: Set has no spatial units`);r=Se(Array.isArray(e.items.spatialUnit)?e.items.spatialUnit:[e.items.spatialUnit]);break;case`concept`:if(!(`concept`in e.items))throw Error(`Invalid OCHRE data: Set has no concepts`);r=Te(Array.isArray(e.items.concept)?e.items.concept:[e.items.concept]);break;case`period`:if(!(`period`in e.items))throw Error(`Invalid OCHRE data: Set has no periods`);r=J(Array.isArray(e.items.period)?e.items.period:[e.items.period]);break;case`bibliography`:if(!(`bibliography`in e.items))throw Error(`Invalid OCHRE data: Set has no bibliographies`);r=Y(Array.isArray(e.items.bibliography)?e.items.bibliography:[e.items.bibliography]);break;case`person`:if(!(`person`in e.items))throw Error(`Invalid OCHRE data: Set has no persons`);r=V(Array.isArray(e.items.person)?e.items.person:[e.items.person]);break;case`propertyValue`:if(!(`propertyValue`in e.items))throw Error(`Invalid OCHRE data: Set has no property values`);r=_e(Array.isArray(e.items.propertyValue)?e.items.propertyValue:[e.items.propertyValue]);break;default:throw Error(`Invalid OCHRE data: Set has no items or is malformed`)}return{uuid:e.uuid,category:`set`,itemCategory:t,publicationDateTime:e.publicationDateTime?new Date(e.publicationDateTime):null,date:e.date??null,license:B(e.availability),identification:L(e.identification),isSuppressingBlanks:e.suppressBlanks??!1,description:e.description?[`string`,`number`,`boolean`].includes(typeof e.description)?N(e.description):I(e.description):``,creators:e.creators?V(Array.isArray(e.creators.creator)?e.creators.creator:[e.creators.creator]):[],type:e.type,number:e.n,items:r}}function be(e){return{uuid:e.uuid,category:`resource`,publicationDateTime:e.publicationDateTime?new Date(e.publicationDateTime):null,type:e.type,number:e.n,fileFormat:e.fileFormat??null,fileSize:e.fileSize??null,context:`context`in e&&e.context?z(e.context):null,license:`availability`in e&&e.availability?B(e.availability):null,copyright:`copyright`in e&&e.copyright!=null?I(e.copyright):null,watermark:`watermark`in e&&e.watermark!=null?I(e.watermark):null,identification:L(e.identification),date:e.date??null,image:e.image?W(e.image):null,creators:e.creators?V(Array.isArray(e.creators.creator)?e.creators.creator:[e.creators.creator]):[],notes:e.notes?G(Array.isArray(e.notes.note)?e.notes.note:[e.notes.note]):[],description:e.description?[`string`,`number`,`boolean`].includes(typeof e.description)?N(e.description):I(e.description):``,coordinates:e.coordinates?K(e.coordinates):[],document:e.document&&`content`in e.document?U(e.document.content):null,href:e.href??null,imageMap:e.imagemap?pe(e.imagemap):null,periods:e.periods?J(Array.isArray(e.periods.period)?e.periods.period:[e.periods.period]):[],links:e.links?H(Array.isArray(e.links)?e.links:[e.links]):[],reverseLinks:e.reverseLinks?H(Array.isArray(e.reverseLinks)?e.reverseLinks:[e.reverseLinks]):[],properties:e.properties?q(Array.isArray(e.properties.property)?e.properties.property:[e.properties.property]):[],bibliographies:e.bibliographies?Y(Array.isArray(e.bibliographies.bibliography)?e.bibliographies.bibliography:[e.bibliographies.bibliography]):[],resources:e.resource?X(Array.isArray(e.resource)?e.resource:[e.resource]):[]}}function X(e){let t=[],n=Array.isArray(e)?e:[e];for(let e of n)t.push(be(e));return t}function xe(e){return{uuid:e.uuid,category:`spatialUnit`,publicationDateTime:e.publicationDateTime==null?null:new Date(e.publicationDateTime),number:e.n,context:`context`in e&&e.context?z(e.context):null,license:`availability`in e&&e.availability?B(e.availability):null,identification:L(e.identification),image:e.image?W(e.image):null,description:e.description?[`string`,`number`,`boolean`].includes(typeof e.description)?N(e.description):I(e.description):``,coordinates:K(e.coordinates),mapData:e.mapData??null,observations:`observations`in e&&e.observations?le(Array.isArray(e.observations.observation)?e.observations.observation:[e.observations.observation]):e.observation?[ce(e.observation)]:[],events:`events`in e&&e.events?ue(Array.isArray(e.events.event)?e.events.event:[e.events.event]):[],properties:`properties`in e&&e.properties?q(Array.isArray(e.properties.property)?e.properties.property:[e.properties.property]):[],bibliographies:e.bibliographies?Y(Array.isArray(e.bibliographies.bibliography)?e.bibliographies.bibliography:[e.bibliographies.bibliography]):[]}}function Se(e){let t=[],n=Array.isArray(e)?e:[e];for(let e of n)t.push(xe(e));return t}function Ce(e){return{uuid:e.uuid,category:`concept`,publicationDateTime:e.publicationDateTime?new Date(e.publicationDateTime):null,number:e.n,license:`availability`in e&&e.availability?B(e.availability):null,context:`context`in e&&e.context?z(e.context):null,identification:L(e.identification),image:e.image?W(e.image):null,description:e.description?I(e.description):null,interpretations:e.interpretations?fe(Array.isArray(e.interpretations.interpretation)?e.interpretations.interpretation:[e.interpretations.interpretation]):[],properties:e.properties?q(Array.isArray(e.properties.property)?e.properties.property:[e.properties.property]):[],bibliographies:e.bibliographies?Y(Array.isArray(e.bibliographies.bibliography)?e.bibliographies.bibliography:[e.bibliographies.bibliography]):[]}}const we=(e,t)=>{let n=[];for(let r of e)if((r.properties?q(Array.isArray(r.properties.property)?r.properties.property:[r.properties.property]):[]).find(e=>e.label===`presentation`&&e.values[0].content===t))switch(t){case`element`:{let e=Z(r);n.push(e);break}case`page`:{let e=Oe(r);e&&n.push(e);break}case`block`:{let e=Q(r);e&&n.push(e);break}}return n};function Te(e){let t=[],n=Array.isArray(e)?e:[e];for(let e of n)t.push(Ce(e));return t}function Ee(e,t){let n=e.values[0].content,{data:r}=d.safeParse(n),i={component:r},a=t.links?H(Array.isArray(t.links)?t.links:[t.links]):[];switch(r){case`annotated-document`:{let e=a.find(e=>e.type===`internalDocument`);if(!e)throw Error(`Document link not found for the following component: “${r}”`);i.documentId=e.uuid;break}case`annotated-image`:{let t=a.filter(e=>e.type===`image`||e.type===`IIIF`);if(t.length===0)throw Error(`Image link not found for the following component: “${r}”`);let n=w(e.properties,`filter-displayed`)===!0,o=w(e.properties,`options-displayed`)!==!1,s=w(e.properties,`annotation-highlights-displayed`)!==!1,c=w(e.properties,`annotation-tooltips-displayed`)!==!1;i.imageUuid=t[0].uuid,i.isFilterDisplayed=n,i.isOptionsDisplayed=o,i.isAnnotationHighlightsDisplayed=s,i.isAnnotationTooltipsDisplayed=c;break}case`audio-player`:{let t=a.find(e=>e.type===`audio`);if(!t)throw Error(`Audio link not found for the following component: “${r}”`);let n=!1,o=w(e.properties,`speed-controls-displayed`);o!==null&&(n=o===!0);let s=!1,c=w(e.properties,`volume-controls-displayed`);c!==null&&(s=c===!0);let l=!1,u=w(e.properties,`seek-bar-displayed`);u!==null&&(l=u===!0),i.audioId=t.uuid,i.isSpeedControlsDisplayed=n,i.isVolumeControlsDisplayed=s,i.isSeekBarDisplayed=l;break}case`bibliography`:{let t=a.filter(e=>e.category!==`bibliography`),n=a.find(e=>e.category===`bibliography`);if(t.length===0&&n?.bibliographies==null)throw Error(`No links found for the following component: “${r}”`);let o=w(e.properties,`layout`);o??=`long`;let s=!0,c=w(e.properties,`source-document-displayed`);c!==null&&(s=c===!0),i.itemUuids=t.map(e=>e.uuid).filter(e=>e!==null),i.bibliographies=n?.bibliographies??[],i.layout=o,i.isSourceDocumentDisplayed=s;break}case`button`:{let n=w(e.properties,`variant`);n??=`default`;let o=!1,s=S(e.properties,`navigate-to`),c=s?.values[0]?.href??s?.values[0]?.slug??null;if(c===null){let t=S(e.properties,`link-to`);if(c=t?.values[0]?.href??t?.values[0]?.slug??null,c===null)throw Error(`Properties “navigate-to” or “link-to” not found for the following component: “${r}”`);o=!0}let l=null,u=w(e.properties,`start-icon`);u!==null&&(l=u);let d=null,f=w(e.properties,`end-icon`);f!==null&&(d=f);let p=null,m=a.find(e=>e.type===`image`||e.type===`IIIF`);m!=null&&(p={url:`https://ochre.lib.uchicago.edu/ochre?uuid=${m.uuid}&load`,label:m.identification?.label??null,width:m.image?.width??0,height:m.image?.height??0,description:m.description??null}),i.variant=n,i.href=c,i.isExternal=o,i.label=t.document&&`content`in t.document?U(t.document.content):null,i.startIcon=l,i.endIcon=d,i.image=p;break}case`collection`:{let t=a.find(e=>e.category===`set`);if(!t)throw Error(`Collection link not found for the following component: “${r}”`);let n=w(e.properties,`variant`);n??=`full`;let o=w(e.properties,`item-variant`);o??=`detailed`;let s=w(e.properties,`pagination-variant`);s??=`default`;let c=!1,l=w(e.properties,`sort-displayed`);l!==null&&(c=l===!0);let u=!1,d=w(e.properties,`filter-displayed`);d!==null&&(u=d===!0);let f=w(e.properties,`filter-sort`);f??=`default`;let p=w(e.properties,`layout`);p??=`image-start`,i.collectionId=t.uuid,i.variant=n,i.itemVariant=o,i.paginationVariant=s,i.isSortDisplayed=c,i.isFilterDisplayed=u,i.filterSort=f,i.layout=p;break}case`empty-space`:{let t=w(e.properties,`height`),n=w(e.properties,`width`);i.height=t,i.width=n;break}case`entries`:{let t=a.find(e=>e.category===`tree`||e.category===`set`);if(!t)throw Error(`Entries link not found for the following component: “${r}”`);let n=w(e.properties,`variant`);n??=`entry`;let o=!1,s=w(e.properties,`filter-displayed`);s!==null&&(o=s===!0),i.entriesId=t.uuid,i.variant=n,i.isFilterDisplayed=o;break}case`iframe`:{let t=a.find(e=>e.type===`webpage`)?.href;if(!t)throw Error(`URL not found for the following component: “${r}”`);let n=w(e.properties,`height`),o=w(e.properties,`width`);i.href=t,i.height=n,i.width=o;break}case`iiif-viewer`:{let t=a.find(e=>e.type===`IIIF`);if(!t)throw Error(`Manifest link not found for the following component: “${r}”`);let n=w(e.properties,`variant`);n??=`universal-viewer`,i.IIIFId=t.uuid,i.variant=n;break}case`image`:{if(a.length===0)throw Error(`No links found for the following component: “${r}”`);let t=w(e.properties,`quality`);t??=`high`;let n=[];for(let e of a)n.push({url:`https://ochre.lib.uchicago.edu/ochre?uuid=${e.uuid}${t===`high`&&(e.type===`image`||e.type===`IIIF`)?`&load`:`&preview`}`,label:e.identification?.label??null,width:e.image?.width??0,height:e.image?.height??0,description:e.description??null});let o=w(e.properties,`variant`);o??=`default`;let s=w(e.properties,`layout-caption`);s??=`bottom`;let c=null,l=w(e.properties,`width`);l!==null&&(typeof l==`number`?c=l:typeof l==`string`&&(c=Number.parseFloat(l)));let u=null,d=w(e.properties,`height`);d!==null&&(typeof d==`number`?u=d:typeof d==`string`&&(u=Number.parseFloat(d)));let f=!0,p=w(e.properties,`is-full-width`);p!==null&&(f=p===!0);let m=!0,h=w(e.properties,`is-full-height`);h!==null&&(m=h===!0);let g=w(e.properties,`caption-source`);g??=`name`;let _=w(e.properties,`alt-text-source`);_??=`name`;let v=!1,y=w(e.properties,`is-transparent`);y!==null&&(v=y===!0);let b=!1,x=w(e.properties,`is-cover`);x!==null&&(b=x===!0);let C=S(e.properties,`variant`),T=null;if(n.length>1){let e=5;if(C?.values[0].content===`carousel`){let t=w(C.properties,`seconds-per-image`);t!==null&&(typeof t==`number`?e=t:typeof t==`string`&&(e=Number.parseFloat(t)))}T={secondsPerImage:e}}let E=null;if(C?.values[0].content===`hero`){let e=w(C.properties,`background-image-displayed`),t=w(C.properties,`document-displayed`),n=w(C.properties,`link-displayed`);E={isBackgroundImageDisplayed:e!==!1,isDocumentDisplayed:t!==!1,isLinkDisplayed:n!==!1}}i.images=n,i.variant=o,i.width=c,i.height=u,i.isFullWidth=f,i.isFullHeight=m,i.imageQuality=t,i.captionLayout=s,i.captionSource=g,i.altTextSource=_,i.isTransparentBackground=v,i.isCover=b,i.carouselOptions=T,i.heroOptions=E;break}case`image-gallery`:{let t=a.find(e=>e.category===`tree`||e.category===`set`);if(!t)throw Error(`Image gallery link not found for the following component: “${r}”`);let n=w(e.properties,`filter-displayed`)===!0;i.galleryId=t.uuid,i.isFilterDisplayed=n;break}case`map`:{let t=a.find(e=>e.category===`set`||e.category===`tree`);if(!t)throw Error(`Map link not found for the following component: “${r}”`);let n=!0,o=w(e.properties,`is-interactive`);o!==null&&(n=o===!0);let s=!1,c=w(e.properties,`is-clustered`);c!==null&&(s=c===!0);let l=!1,u=w(e.properties,`is-using-pins`);u!==null&&(l=u===!0);let d=null,f=w(e.properties,`custom-basemap`);f!==null&&(d=f);let p=!1,m=w(e.properties,`controls-displayed`);m!==null&&(p=m===!0);let h=!1,g=w(e.properties,`is-full-height`);g!==null&&(h=g===!0),i.mapId=t.uuid,i.isInteractive=n,i.isClustered=s,i.isUsingPins=l,i.customBasemap=d,i.isControlsDisplayed=p,i.isFullHeight=h;break}case`network-graph`:break;case`query`:{let t=[],n=e.properties;if(n.length===0)throw Error(`Query properties not found for the following component: “${r}”`);for(let e of n){let n=e.properties,i=w(n,`query-prompt`);if(i===null)throw Error(`Query prompt not found for the following component: “${r}”`);let a=n.find(e=>e.label===`use-property`)?.values.map(e=>e.uuid).filter(e=>e!==null)??[],o=w(n,`start-icon`),s=w(n,`end-icon`);t.push({label:String(i),propertyUuids:a,startIcon:o===null?null:String(o),endIcon:s===null?null:String(s)})}i.queries=t;break}case`table`:{let e=a.find(e=>e.category===`set`);if(!e)throw Error(`Table link not found for the following component: “${r}”`);i.tableId=e.uuid;break}case`search-bar`:{let t=w(e.properties,`variant`);t??=`default`;let n=w(e.properties,`placeholder-text`),r=w(e.properties,`base-query`);i.variant=t,i.placeholder=n===null?null:String(n),i.baseQuery=r===null?null:String(r).replaceAll(String.raw`\{`,`{`).replaceAll(String.raw`\}`,`}`);break}case`text`:{let n=t.document&&`content`in t.document?U(t.document.content):null;if(!n)throw Error(`Content not found for the following component: “${r}”`);let a=`block`,o,s=S(e.properties,`variant`);if(s!==null)if(a=s.values[0].content,a===`paragraph`||a===`label`||a===`heading`||a===`display`){let e=w(s.properties,`size`);o={name:a,size:e===null?`md`:e}}else o={name:a};else o={name:a};i.variant=o,i.content=n;break}case`timeline`:{let e=a.find(e=>e.category===`tree`);if(!e)throw Error(`Timeline link not found for the following component: “${r}”`);i.timelineId=e.uuid;break}case`video`:{let t=a.find(e=>e.type===`video`);if(!t)throw Error(`Video link not found for the following component: “${r}”`);let n=w(e.properties,`chapters-displayed`);n??=!0,i.videoId=t.uuid,i.isChaptersDislayed=n===!0;break}default:console.warn(`Invalid or non-implemented component name “${String(n)}” for the following element: “${I(t.identification.label)}”`);break}return i}function De(e,t,n={}){let r=e.find(e=>e.label===`presentation`&&e.values[0].content===`title`)?.properties,i=`default`,a=n.isNameDisplayed??!1,o=!1,s=!1,c=!1,l=n.isCountDisplayed??!1;if(r){let e=w(r,`variant`);e&&(i=e),a=w(r,`name-displayed`)===!0,o=w(r,`description-displayed`)===!0,s=w(r,`date-displayed`)===!0,c=w(r,`creators-displayed`)===!0,l=w(r,`count-displayed`)===!0}return{label:t.label,variant:i,properties:{isNameDisplayed:a,isDescriptionDisplayed:o,isDateDisplayed:s,isCreatorsDisplayed:c,isCountDisplayed:l}}}function Z(e){let t=L(e.identification),n=(e.properties?.property?q(Array.isArray(e.properties.property)?e.properties.property:[e.properties.property]):[]).find(e=>e.label===`presentation`);if(!n)throw Error(`Presentation property not found for element “${t.label}”`);let r=n.properties.find(e=>e.label===`component`);if(!r)throw Error(`Component for element “${t.label}” not found`);let i=Ee(r,e),a=e.properties?.property?q(Array.isArray(e.properties.property)?e.properties.property:[e.properties.property]):[],o=a.find(e=>e.label===`presentation`&&e.values[0].content===`css`)?.properties??[],s=[];for(let e of o){let t=e.values[0].content;s.push({label:e.label,value:t})}let c=a.find(e=>e.label===`presentation`&&e.values[0].content===`css-tablet`)?.properties??[],l=[];for(let e of c){let t=e.values[0].content;l.push({label:e.label,value:t})}let u=a.find(e=>e.label===`presentation`&&e.values[0].content===`css-mobile`)?.properties??[],d=[];for(let e of u){let t=e.values[0].content;d.push({label:e.label,value:t})}let f=De(a,t,{isNameDisplayed:[`annotated-image`,`annotated-document`,`collection`].includes(i.component),isCountDisplayed:i.component===`collection`&&i.variant===`full`});return{uuid:e.uuid,type:`element`,title:f,cssStyles:{default:s,tablet:l,mobile:d},...i}}function Oe(e){let t=e.properties?q(Array.isArray(e.properties.property)?e.properties.property:[e.properties.property]):[];if(t.length===0||t.find(e=>e.label===`presentation`)?.values[0]?.content!==`page`)return null;let n=L(e.identification),r=e.slug;if(r===void 0)throw Error(`Slug not found for page “${n.label}”`);let i=(e.links?H(Array.isArray(e.links)?e.links:[e.links]):[]).find(e=>e.type===`image`||e.type===`IIIF`),a=e.resource?Array.isArray(e.resource)?e.resource:[e.resource]:[],o=[];for(let e of a){let t=w(e.properties?q(Array.isArray(e.properties.property)?e.properties.property:[e.properties.property]):[],`presentation`);if(t!=null)switch(t){case`element`:{let t=Z(e);o.push(t);break}case`block`:{let t=Q(e);t&&o.push(t);break}}}let s=e.resource?we(Array.isArray(e.resource)?e.resource:[e.resource],`page`):[],c=!0,l=`default`,u=`default`,d=!0,f=!1,p=t.find(e=>e.label===`presentation`&&e.values[0]?.content===`page`)?.properties;if(p){let e=p.find(e=>e.label===`header`)?.values[0];e&&(c=e.content===!0);let t=p.find(e=>e.label===`width`)?.values[0];t&&(l=t.content);let n=p.find(e=>e.label===`variant`)?.values[0];n&&(u=n.content);let r=p.find(e=>e.label===`sidebar-visible`)?.values[0];r&&(d=r.content===!0);let i=p.find(e=>e.label===`breadcrumbs-visible`)?.values[0];i&&(f=i.content===!0)}let m=t.find(e=>e.label===`presentation`&&e.values[0]?.content===`css`)?.properties,h=[];if(m)for(let e of m)h.push({label:e.label,value:e.values[0].content});let g=t.find(e=>e.label===`presentation`&&e.values[0]?.content===`css-tablet`)?.properties,_=[];if(g)for(let e of g)_.push({label:e.label,value:e.values[0].content});let v=t.find(e=>e.label===`presentation`&&e.values[0]?.content===`css-mobile`)?.properties,y=[];if(v)for(let e of v)y.push({label:e.label,value:e.values[0].content});return{title:n.label,slug:r,items:o,properties:{displayedInHeader:c,width:l,variant:u,backgroundImageUrl:i?`https://ochre.lib.uchicago.edu/ochre?uuid=${i.uuid}&load`:null,isSidebarDisplayed:d,isBreadcrumbsDisplayed:f,cssStyles:{default:h,tablet:_,mobile:y}},webpages:s}}function ke(e){let t=[],n=Array.isArray(e)?e:[e];for(let e of n){let n=Oe(e);n&&t.push(n)}return t}function Ae(e){let t=null,n=[],r={label:``,variant:`default`,properties:{isNameDisplayed:!1,isDescriptionDisplayed:!1,isDateDisplayed:!1,isCreatorsDisplayed:!1,isCountDisplayed:!1}},i=`start`,a=`default`,o=[],s=[],c=[],l=e.find(e=>(e.properties?q(Array.isArray(e.properties.property)?e.properties.property:[e.properties.property]):[]).some(e=>e.label===`presentation`&&e.values[0]?.content===`element`&&e.properties[0]?.label===`component`&&e.properties[0].values[0]?.content===`sidebar`));if(l){r.label=typeof l.identification.label==`string`||typeof l.identification.label==`number`||typeof l.identification.label==`boolean`?N(l.identification.label):I(l.identification.label);let e=l.properties?q(Array.isArray(l.properties.property)?l.properties.property:[l.properties.property]):[],t=e.find(e=>e.label===`presentation`&&e.values[0]?.content===`element`)?.properties.find(e=>e.label===`component`&&e.values[0]?.content===`sidebar`)?.properties??[],u=t.find(e=>e.label===`layout`);u&&(i=u.values[0].content);let d=t.find(e=>e.label===`layout-mobile`);d&&(a=d.values[0].content);let f=e.find(e=>e.label===`presentation`&&e.values[0].content===`css`)?.properties??[];for(let e of f){let t=e.values[0].content;o.push({label:e.label,value:t})}let p=e.find(e=>e.label===`presentation`&&e.values[0].content===`css-tablet`)?.properties??[];for(let e of p){let t=e.values[0].content;s.push({label:e.label,value:t})}let m=e.find(e=>e.label===`presentation`&&e.values[0].content===`css-mobile`)?.properties??[];for(let e of m){let t=e.values[0].content;c.push({label:e.label,value:t})}let h=e.find(e=>e.label===`presentation`&&e.values[0].content===`title`)?.properties;if(h){let e=w(h,`variant`);e&&(r.variant=e),r.properties.isNameDisplayed=w(h,`name-displayed`)===!0,r.properties.isDescriptionDisplayed=w(h,`description-displayed`)===!0,r.properties.isDateDisplayed=w(h,`date-displayed`)===!0,r.properties.isCreatorsDisplayed=w(h,`creators-displayed`)===!0,r.properties.isCountDisplayed=w(h,`count-displayed`)===!0}let g=l.resource?Array.isArray(l.resource)?l.resource:[l.resource]:[];for(let e of g){let t=Z(e);n.push(t)}}return n.length>0&&(t={elements:n,title:r,layout:i,mobileLayout:a,cssStyles:{default:o,tablet:s,mobile:c}}),t}function je(e){let t=Z(e),n=e.resource?Array.isArray(e.resource)?e.resource:[e.resource]:[],r=[];for(let e of n){let t=w(e.properties?q(Array.isArray(e.properties.property)?e.properties.property:[e.properties.property]):[],`presentation`);if(t!=null)switch(t){case`element`:{let t=Z(e);r.push(t);break}case`block`:{let t=Q(e);t&&r.push(t);break}}}return{...t,items:r}}function Q(e){let t=e.properties?q(Array.isArray(e.properties.property)?e.properties.property:[e.properties.property]):[],n={uuid:e.uuid,type:`block`,title:De(t,L(e.identification)),items:[],properties:{default:{layout:`vertical`,spacing:void 0,gap:void 0,alignItems:`start`,justifyContent:`stretch`},mobile:null,tablet:null},cssStyles:{default:[],tablet:[],mobile:[]}},r=t.find(e=>e.label===`presentation`&&e.values[0]?.content===`block`)?.properties;if(r){let e=r.find(e=>e.label===`layout`)?.values[0];if(e&&(n.properties.default.layout=e.content),n.properties.default.layout===`accordion`){let e=r.find(e=>e.label===`accordion-enabled`)?.values[0];e?n.properties.default.isAccordionEnabled=e.content===!0:n.properties.default.isAccordionEnabled=!0;let t=r.find(e=>e.label===`accordion-expanded`)?.values[0];t?n.properties.default.isAccordionExpandedByDefault=t.content===!0:n.properties.default.isAccordionExpandedByDefault=!1;let i=r.find(e=>e.label===`accordion-sidebar-displayed`)?.values[0];i?n.properties.default.isAccordionSidebarDisplayed=i.content===!0:n.properties.default.isAccordionSidebarDisplayed=!1}let t=r.find(e=>e.label===`spacing`)?.values[0];t&&(n.properties.default.spacing=t.content);let i=r.find(e=>e.label===`gap`)?.values[0];i&&(n.properties.default.gap=i.content);let a=r.find(e=>e.label===`align-items`)?.values[0];a&&(n.properties.default.alignItems=a.content);let o=r.find(e=>e.label===`justify-content`)?.values[0];o&&(n.properties.default.justifyContent=o.content);let s=r.find(e=>e.label===`overwrite-tablet`);if(s){let e=s.properties,t={},r=e.find(e=>e.label===`layout`)?.values[0];if(r&&(t.layout=r.content),t.layout===`accordion`||n.properties.default.layout===`accordion`){let n=e.find(e=>e.label===`accordion-enabled`)?.values[0];n&&(t.isAccordionEnabled=n.content===!0);let r=e.find(e=>e.label===`accordion-expanded`)?.values[0];r&&(t.isAccordionExpandedByDefault=r.content===!0);let i=e.find(e=>e.label===`accordion-sidebar-displayed`)?.values[0];i&&(t.isAccordionSidebarDisplayed=i.content===!0)}let i=e.find(e=>e.label===`spacing`)?.values[0];i&&(t.spacing=i.content);let a=e.find(e=>e.label===`gap`)?.values[0];a&&(t.gap=a.content);let o=e.find(e=>e.label===`align-items`)?.values[0];o&&(t.alignItems=o.content);let c=e.find(e=>e.label===`justify-content`)?.values[0];c&&(t.justifyContent=c.content),n.properties.tablet=t}let c=r.find(e=>e.label===`overwrite-mobile`);if(c){let e=c.properties,t={},r=e.find(e=>e.label===`layout`)?.values[0];if(r&&(t.layout=r.content),t.layout===`accordion`||n.properties.default.layout===`accordion`){let n=e.find(e=>e.label===`accordion-enabled`)?.values[0];n&&(t.isAccordionEnabled=n.content===!0);let r=e.find(e=>e.label===`accordion-expanded`)?.values[0];r&&(t.isAccordionExpandedByDefault=r.content===!0);let i=e.find(e=>e.label===`accordion-sidebar-displayed`)?.values[0];i&&(t.isAccordionSidebarDisplayed=i.content===!0)}let i=e.find(e=>e.label===`spacing`)?.values[0];i&&(t.spacing=i.content);let a=e.find(e=>e.label===`gap`)?.values[0];a&&(t.gap=a.content);let o=e.find(e=>e.label===`align-items`)?.values[0];o&&(t.alignItems=o.content);let s=e.find(e=>e.label===`justify-content`)?.values[0];s&&(t.justifyContent=s.content),n.properties.mobile=t}}let i=e.resource?Array.isArray(e.resource)?e.resource:[e.resource]:[];if(n.properties.default.layout===`accordion`){let e=[];for(let t of i){let n=t.properties?q(Array.isArray(t.properties.property)?t.properties.property:[t.properties.property]):[],r=w(n,`presentation`);if(r!==`element`)throw Error(`Accordion only accepts elements, but got “${r}” for the following resource: “${I(t.identification.label)}”`);let i=(n.find(e=>e.label===`presentation`)?.properties.find(e=>e.label===`component`))?.values[0]?.content;if(i!==`text`)throw Error(`Accordion only accepts text components, but got “${i}” for the following resource: “${I(t.identification.label)}”`);let a=je(t);e.push(a)}n.items=e}else{let e=[];for(let t of i){let n=w(t.properties?q(Array.isArray(t.properties.property)?t.properties.property:[t.properties.property]):[],`presentation`);if(n!=null)switch(n){case`element`:{let n=Z(t);e.push(n);break}case`block`:{let n=Q(t);n&&e.push(n);break}}}n.items=e}let a=t.find(e=>e.label===`presentation`&&e.values[0]?.content===`css`)?.properties;if(a)for(let e of a)n.cssStyles.default.push({label:e.label,value:e.values[0].content});let o=t.find(e=>e.label===`presentation`&&e.values[0]?.content===`css-tablet`)?.properties;if(o)for(let e of o)n.cssStyles.tablet.push({label:e.label,value:e.values[0].content});let s=t.find(e=>e.label===`presentation`&&e.values[0]?.content===`css-mobile`)?.properties;if(s)for(let e of s)n.cssStyles.mobile.push({label:e.label,value:e.values[0].content});return n}function Me(e){let t=q(e).find(e=>e.label===`presentation`)?.properties;if(!t)throw Error(`Presentation property not found`);let n=t.find(e=>e.label===`webUI`)?.values[0]?.content;n??=`traditional`;let r=t.find(e=>e.label===`status`)?.values[0]?.content;r??=`development`;let i=t.find(e=>e.label===`privacy`)?.values[0]?.content;i??=`public`;let a=u.safeParse({type:n,status:r,privacy:i});if(!a.success)throw Error(`Invalid website properties: ${a.error.message}`);let o=null,s=t.find(e=>e.label===`contact`);if(s){let[e,t]=(s.values[0]?.content).split(`;`);o={name:e,email:t??null}}let c=t.find(e=>e.label===`logo`)?.values[0]?.uuid??null,l=!0,d=`default`,f=`start`,p=!0,m=!0,h=!1,g=`universal-viewer`,_=!0,v=null,y=t.find(e=>e.label===`navbar-visible`)?.values[0];y&&(l=y.content===!0);let b=t.find(e=>e.label===`navbar-variant`)?.values[0];b&&(d=b.content);let x=t.find(e=>e.label===`navbar-alignment`)?.values[0];x&&(f=x.content);let S=t.find(e=>e.label===`navbar-project-visible`)?.values[0];S&&(p=S.content===!0);let C=t.find(e=>e.label===`footer-visible`)?.values[0];C&&(m=C.content===!0);let w=t.find(e=>e.label===`sidebar-visible`)?.values[0];w&&(h=w.content===!0);let T=t.find(e=>e.label===`iiif-viewer`)?.values[0];T&&(g=T.content);let E=t.find(e=>e.label===`supports-theme-toggle`)?.values[0];E&&(_=E.content===!0);let D=t.find(e=>e.label===`default-theme`)?.values[0];D&&(v=D.content);let{type:O,status:k,privacy:ee}=a.data;return{type:O,privacy:ee,status:k,contact:o,isHeaderDisplayed:l,headerVariant:d,headerAlignment:f,isHeaderProjectDisplayed:p,isFooterDisplayed:m,isSidebarDisplayed:h,iiifViewer:g,supportsThemeToggle:_,defaultTheme:v,logoUrl:c===null?null:`https://ochre.lib.uchicago.edu/ochre?uuid=${c}&load`}}function $(e){let t=[];for(let n of e){let e=Array.isArray(n.context)?n.context:[n.context];for(let n of e){let e=Array.isArray(n.levels.level)?n.levels.level:[n.levels.level],r=``,i=e.map(e=>{let t=``,n=null;if(typeof e==`string`){let r=e.split(`, `);t=r[0],n=r[1]===`null`?null:r[1]}else{let i=e.content.split(`, `);r=e.dataType,t=i[0],n=i[1]===`null`?null:i[1]}return{variableUuid:t,valueUuid:n}});t.push({context:i,type:r,identification:L(n.identification)})}}return t}function Ne(e,t,n){if(!e.properties)throw Error(`Website properties not found`);let r=Me(Array.isArray(e.properties.property)?e.properties.property:[e.properties.property]);if(typeof e.items==`string`||!(`resource`in e.items))throw Error(`Website pages not found`);let i=Array.isArray(e.items.resource)?e.items.resource:[e.items.resource],a=ke(i),o=Ae(i),s={contexts:{flatten:[],filter:[],sort:[],detail:[],download:[],label:[],suppress:[]}};if(e.websiteOptions){let t=e.websiteOptions.flattenContexts==null?[]:Array.isArray(e.websiteOptions.flattenContexts)?e.websiteOptions.flattenContexts:[e.websiteOptions.flattenContexts],n=e.websiteOptions.suppressContexts==null?[]:Array.isArray(e.websiteOptions.suppressContexts)?e.websiteOptions.suppressContexts:[e.websiteOptions.suppressContexts],r=e.websiteOptions.filterContexts==null?[]:Array.isArray(e.websiteOptions.filterContexts)?e.websiteOptions.filterContexts:[e.websiteOptions.filterContexts],i=e.websiteOptions.sortContexts==null?[]:Array.isArray(e.websiteOptions.sortContexts)?e.websiteOptions.sortContexts:[e.websiteOptions.sortContexts],a=e.websiteOptions.detailContexts==null?[]:Array.isArray(e.websiteOptions.detailContexts)?e.websiteOptions.detailContexts:[e.websiteOptions.detailContexts],o=e.websiteOptions.downloadContexts==null?[]:Array.isArray(e.websiteOptions.downloadContexts)?e.websiteOptions.downloadContexts:[e.websiteOptions.downloadContexts],c=e.websiteOptions.labelContexts==null?[]:Array.isArray(e.websiteOptions.labelContexts)?e.websiteOptions.labelContexts:[e.websiteOptions.labelContexts];s={contexts:{flatten:$(t),filter:$(r),sort:$(i),detail:$(a),download:$(o),label:$(c),suppress:$(n)}}}return{uuid:e.uuid,publicationDateTime:e.publicationDateTime?new Date(e.publicationDateTime):null,identification:L(e.identification),project:{name:N(t),website:n===null?null:N(n)},creators:e.creators?V(Array.isArray(e.creators.creator)?e.creators.creator:[e.creators.creator]):[],license:B(e.availability),sidebar:o,pages:a,properties:r,searchOptions:{filters:e.searchOptions?.filterUuids==null?[]:(Array.isArray(e.searchOptions.filterUuids.uuid)?e.searchOptions.filterUuids.uuid:[e.searchOptions.filterUuids.uuid]).map(e=>({uuid:e.content,type:e.type})),attributeFilters:{bibliographies:e.searchOptions?.filterUuids?.filterBibliography??!1,periods:e.searchOptions?.filterUuids?.filterPeriods??!1},scopes:e.searchOptions?.scopes==null?[]:(Array.isArray(e.searchOptions.scopes.scope)?e.searchOptions.scopes.scope:[e.searchOptions.scopes.scope]).map(e=>({uuid:e.uuid.content,type:e.uuid.type,identification:L(e.identification)}))},globalOptions:s}}async function Pe(e,t,n,r,i){try{let{uuid:a,filter:o,page:s,perPage:c}=m.parse({uuid:e,filter:t,page:n,perPage:r}),l=await(i??fetch)(`https://ochre.lib.uchicago.edu/ochre?xquery=${encodeURIComponent(`
3
- for $q in input()/ochre[@uuid='${a}']
4
- let $filtered := $q//items/resource[contains(lower-case(identification/label), lower-case('${o}'))]
5
- let $maxLength := count($filtered)
6
- return <gallery maxLength='{$maxLength}'>
7
- {$q/metadata/project}
8
- {$q/metadata/item}
9
- {$filtered[position() >= ${((s-1)*c+1).toString()} and position() < ${(s*c+1).toString()}]}
10
- </gallery>
11
- `)}&format=json`);if(!l.ok)throw Error(`Error fetching gallery items, please try again later.`);let u=await l.json();if(!(`gallery`in u.result))throw Error(`Failed to fetch gallery`);return{item:{identification:L(u.result.gallery.item.identification),projectIdentification:L(u.result.gallery.project.identification),resources:X(u.result.gallery.resource?Array.isArray(u.result.gallery.resource)?u.result.gallery.resource:[u.result.gallery.resource]:[]),maxLength:u.result.gallery.maxLength},error:null}}catch(e){return console.error(e),{item:null,error:e instanceof Error?e.message:`Failed to fetch gallery`}}}async function Fe(e,t){try{let n=l.parse(e),r=await(t??fetch)(`https://ochre.lib.uchicago.edu/ochre?uuid=${n}&format=json&lang="*"`);if(!r.ok)throw Error(`Failed to fetch OCHRE data`);let i=await r.json();if(!(`ochre`in i))throw Error(`Invalid OCHRE data: API response missing 'ochre' key`);return[null,i]}catch(e){return[e instanceof Error?e.message:`Unknown error`,null]}}async function Ie(e,t,n,r){try{let[i,a]=await Fe(e,r);if(i!==null)throw Error(i);let o=re(Object.keys(a.ochre)),s;switch(o){case`resource`:if(!(`resource`in a.ochre))throw Error(`Invalid OCHRE data: API response missing 'resource' key`);s=be(a.ochre.resource);break;case`spatialUnit`:if(!(`spatialUnit`in a.ochre))throw Error(`Invalid OCHRE data: API response missing 'spatialUnit' key`);s=xe(a.ochre.spatialUnit);break;case`concept`:if(!(`concept`in a.ochre))throw Error(`Invalid OCHRE data: API response missing 'concept' key`);s=Ce(a.ochre.concept);break;case`period`:if(!(`period`in a.ochre))throw Error(`Invalid OCHRE data: API response missing 'period' key`);s=me(a.ochre.period);break;case`bibliography`:if(!(`bibliography`in a.ochre))throw Error(`Invalid OCHRE data: API response missing 'bibliography' key`);s=he(a.ochre.bibliography);break;case`person`:if(!(`person`in a.ochre))throw Error(`Invalid OCHRE data: API response missing 'person' key`);s=oe(a.ochre.person);break;case`propertyValue`:if(!(`propertyValue`in a.ochre))throw Error(`Invalid OCHRE data: API response missing 'propertyValue' key`);s=ge(a.ochre.propertyValue);break;case`set`:if(!(`set`in a.ochre))throw Error(`Invalid OCHRE data: API response missing 'set' key`);s=ye(a.ochre.set,n);break;case`tree`:if(!(`tree`in a.ochre))throw Error(`Invalid OCHRE data: API response missing 'tree' key`);s=ve(a.ochre.tree,t,n);break;default:throw Error(`Invalid category`)}return{error:null,metadata:ae(a.ochre.metadata),belongsTo:{uuid:a.ochre.uuidBelongsTo,abbreviation:N(a.ochre.belongsTo)},item:s,category:t}}catch(e){return{error:e instanceof Error?e.message:`Unknown error`,metadata:void 0,belongsTo:void 0,item:void 0,category:void 0}}}const Le=`0c0aae37-7246-495b-9547-e25dbf5b99a3`,Re=`30054cb2-909a-4f34-8db9-8fe7369d691d`,ze=`e28e29af-b663-c0ac-ceb6-11a688fca0dd`;function Be(e){return/^[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12}$/i.test(e)}const Ve=c.z.object({property:c.z.string().refine(Be),category:c.z.object({uuid:c.z.string().refine(Be),content:c.z.string()}),value:c.z.object({uuid:c.z.string().refine(Be).optional(),category:c.z.string().optional(),type:c.z.string().optional(),dataType:c.z.string(),publicationDateTime:c.z.iso.datetime().optional(),content:c.z.string().optional(),rawValue:c.z.string().optional()})}),He=c.z.object({result:c.z.object({item:c.z.union([Ve,c.z.array(Ve)])})});function Ue(e,t){let n=``;e.length>0&&(n=`[properties/property[label/@uuid="30054cb2-909a-4f34-8db9-8fe7369d691d"][value[${e.map(e=>`@uuid="${e}"`).join(` or `)}]]]`);let r=t.map(e=>`@uuid="${e}"`).join(` or `);return`for $q in input()/ochre[@uuidBelongsTo="0c0aae37-7246-495b-9547-e25dbf5b99a3"]/*${n}/properties//property[label[${r}]]
12
- return <item>
13
- <property>{xs:string($q/label/@uuid)}</property>
14
- <value> {$q/*[2]/@*} {$q/*[2]/content[1]/string/text()} </value>
15
- <category> {$q/ancestor::node()[local-name(.)="properties"]/../@uuid} {local-name($q/ancestor::node()[local-name(.)="properties"]/../self::node())} </category>
16
- </item>`}async function We(e,t,n){try{let r=Ue(e,t),i=await(n??fetch)(`https://ochre.lib.uchicago.edu/ochre?xquery=${encodeURIComponent(r)}&format=json`);if(!i.ok)throw Error(`OCHRE API responded with status: ${i.status}`);let a=await i.json(),o=He.parse(a),s=Array.isArray(o.result.item)?o.result.item:[o.result.item],c={};for(let e of s){let t=e.category.uuid,n=e.value.uuid,r=e.value.rawValue??e.value.content??``;r in c?c[r].resultUuids.push(t):c[r]={value:{uuid:n??null,category:e.value.category??null,type:e.value.type??null,dataType:e.value.dataType,publicationDateTime:e.value.publicationDateTime??null,content:e.value.rawValue??e.value.content??``,label:e.value.rawValue!=null&&e.value.content!=null?e.value.content:null},resultUuids:[t]}}return{items:Object.values(c).filter(e=>e.value.uuid!==`e28e29af-b663-c0ac-ceb6-11a688fca0dd`).toSorted((e,t)=>{let n=e.value.label??e.value.content,r=t.value.label??t.value.content;return n.localeCompare(r,`en-US`)}),error:null}}catch(e){return console.error(e),{items:null,error:e instanceof Error?e.message:`Failed to fetch property query`}}}async function Ge(e,t){try{let n=l.parse(e),r=await(t??fetch)(`https://ochre.lib.uchicago.edu/ochre?xquery=${encodeURIComponent(`for $q in input()/ochre[@uuid='${n}']/metadata return ($q/item, $q/project)`)}&format=json`);if(!r.ok)throw Error(`Failed to fetch metadata`);let i=await r.json(),a={...L(i.result.project.identification),website:i.result.project.identification.website??null};return{item:{item:{uuid:e,name:L(i.result.item.identification).label,type:i.result.item.type},project:{name:a.label,website:a.website??null}},error:null}}catch(e){return{item:null,error:e instanceof Error?e.message:`Unknown error`}}}const Ke={"uchicago-node":`60a1e386-7e53-4e14-b8cf-fb4ed953d57e`,"uchicago-node-staging":`62b60a47-fad5-49d7-a06a-2fa059f6e79a`,"guerrilla-television":`fad1e1bd-989d-4159-b195-4c32adc5cdc7`,"mapping-chicagoland":`8db5e83e-0c06-48b7-b4ac-a060d9bb5689`,"hannah-papanek":`20b2c919-021f-4774-b2c3-2f1ae5b910e7`,mepa:`85ddaa5a-535b-4809-8714-855d2d812a3e`,ssmc:`8ff977dd-d440-40f5-ad93-8ad7e2d39e74`,"sosc-core-at-smart":`db26c953-9b2a-4691-a909-5e8726b531d7`};async function qe(e,t){try{let n=Ke[e.toLocaleLowerCase(`en-US`)],r=await(t??fetch)(n==null?`https://ochre.lib.uchicago.edu/ochre?xquery=for $q in input()/ochre[tree[@type='lesson'][identification/abbreviation='${e.toLocaleLowerCase(`en-US`)}']] return $q&format=json`:`https://ochre.lib.uchicago.edu/ochre?uuid=${n}&format=json`);if(!r.ok)throw Error(`Failed to fetch website`);let i=await r.json(),a=`result`in i&&!Array.isArray(i.result)?i.result:`result`in i?null:i;if(a==null||!(`tree`in a.ochre))throw Error(`Failed to fetch website`);let o=a.ochre.metadata.project?.identification?L(a.ochre.metadata.project.identification):null;return[null,Ne(a.ochre.tree,o?.label??``,a.ochre.metadata.project?.identification.website??null)]}catch(e){return console.error(e),[e instanceof Error?e.message:`Unknown error`,null]}}exports.fetchByUuidMetadata=Ge,exports.fetchGallery=Pe,exports.fetchItem=Ie,exports.fetchPropertyQuery=We,exports.fetchWebsite=qe,exports.filterProperties=D,exports.getPropertyByLabel=S,exports.getPropertyByUuid=y,exports.getPropertyValueByLabel=w,exports.getPropertyValueByUuid=x,exports.getPropertyValuesByLabel=C,exports.getPropertyValuesByUuid=b,exports.getUniqueProperties=T,exports.getUniquePropertyLabels=E;