sanity-plugin-taxonomy-manager 4.7.0 → 4.7.2

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.
@@ -1,6 +1,6 @@
1
- import{useFormValue as e,set as n,useDocumentStore as t,useClient as i,isPublishedId as r,useDataset as o,useGetFormValue as c,usePerspective as s,isDraftId as a,isVersionId as d,unset as l,defineField as p,defineType as h,defineArrayMember as m,useSchema as u,getPublishedId as f,Preview as g,definePlugin as y}from"sanity";import{usePaneRouter as b,structureTool as C}from"sanity/structure";import{jsxs as w,jsx as v,Fragment as _}from"react/jsx-runtime";import{GenerateIcon as I,InfoOutlineIcon as x,TrashIcon as k,AddCircleIcon as V,ErrorOutlineIcon as T,ToggleArrowRightIcon as S,AddIcon as N,WarningOutlineIcon as z,EditIcon as E,DocumentsIcon as H}from"@sanity/icons";import{Stack as L,Text as O,useToast as $,Button as P,Card as M,Flex as R,Box as A,Tooltip as D,Dialog as B,Label as F,Badge as Z,Inline as U,TextInput as j,TextArea as q,Spinner as K,Container as G,Grid as W}from"@sanity/ui";import{useCallback as Y,useState as Q,useRef as X,useEffect as J,useMemo as ee,createContext as ne,useContext as te}from"react";import{customAlphabet as ie,nanoid as re}from"nanoid";import{isVersionId as oe,getVersionNameFromId as ce,getVersionId as se,DocumentId as ae,getDraftId as de,getPublishedId as le}from"@sanity/id-utils";import{styled as pe,css as he}from"styled-components";import me from"react-fast-compare";import{distinctUntilChanged as ue,catchError as fe}from"rxjs/operators";import{RouterContext as ge}from"sanity/router";import{AiOutlineTags as ye,AiOutlineTag as be}from"react-icons/ai";function Ce(e){const n=e?.pattern||"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",t=e?.length||6;return(e?.prefix||"")+ie(n,t)()}const we=e=>{const{onChange:t,ident:i}=e,r=$(),o=Y(()=>{const e=Ce(i);t(n(e)),r.push({status:"success",title:"Identifier created.",closable:!0})},[t,r,i]);/* @__PURE__ */
2
- return v(L,{space:2,children:/* @__PURE__ */v(P,{icon:I,mode:"ghost",width:"fill",onClick:o,text:"Generate identifier"})})};we.defaultProps={ident:void 0};var ve=Object.defineProperty,_e=Object.getOwnPropertySymbols,Ie=Object.prototype.hasOwnProperty,xe=Object.prototype.propertyIsEnumerable,ke=(e,n,t)=>n in e?ve(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,Ve=(e,n)=>{for(var t in n||(n={}))Ie.call(n,t)&&ke(e,t,n[t]);if(_e)for(var t of _e(n))xe.call(n,t)&&ke(e,t,n[t]);return e};const Te={tone:"primary"};function Se(e){const{title:n,description:t,icon:i,tone:r,children:o}=Ve(Ve({},Te),e);/* @__PURE__ */
3
- return v(M,{tone:r,padding:4,radius:3,border:!0,children:/* @__PURE__ */w(R,{children:[i?"display icon":null,o||/* @__PURE__ */v(A,{flex:1,children:/* @__PURE__ */w(L,{space:4,children:[n?/* @__PURE__ */v(O,{weight:"semibold",children:n}):null,t?/* @__PURE__ */v(O,{size:2,children:t}):null]})})]})})}var Ne=Object.defineProperty,ze=Object.getOwnPropertySymbols,Ee=Object.prototype.hasOwnProperty,He=Object.prototype.propertyIsEnumerable,Le=(e,n,t)=>n in e?Ne(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,Oe=(e,n)=>{for(var t in n||(n={}))Ee.call(n,t)&&Le(e,t,n[t]);if(ze)for(var t of ze(n))He.call(n,t)&&Le(e,t,n[t]);return e};pe((e={})=>/* @__PURE__ */v(M,Oe({as:"table"},e)))(()=>he`
1
+ import{useFormValue as e,set as t,useDocumentStore as n,useClient as i,isPublishedId as r,useDataset as o,useGetFormValue as c,usePerspective as s,isDraftId as a,FormField as d,isVersionId as l,unset as p,defineField as h,defineType as m,defineArrayMember as u,useSchema as f,getPublishedId as g,Preview as y,definePlugin as b}from"sanity";import{usePaneRouter as C,structureTool as w}from"sanity/structure";import{jsxs as v,jsx as _,Fragment as I}from"react/jsx-runtime";import{GenerateIcon as x,InfoOutlineIcon as k,TrashIcon as V,AddCircleIcon as T,ErrorOutlineIcon as S,ToggleArrowRightIcon as N,AddIcon as z,WarningOutlineIcon as E,EditIcon as H,DocumentsIcon as L}from"@sanity/icons";import{Stack as O,Text as $,useToast as P,Button as M,Card as R,Flex as A,Box as D,Tooltip as B,Dialog as F,Label as Z,Badge as U,Inline as j,TextInput as q,TextArea as K,Spinner as G,Container as W,Grid as Q}from"@sanity/ui";import{useCallback as Y,useState as X,useRef as J,useEffect as ee,useMemo as te,createContext as ne,useContext as ie}from"react";import{customAlphabet as re,nanoid as oe}from"nanoid";import{isVersionId as ce,getVersionNameFromId as se,getVersionId as ae,DocumentId as de,getDraftId as le,getPublishedId as pe}from"@sanity/id-utils";import{styled as he,css as me}from"styled-components";import ue from"react-fast-compare";import{distinctUntilChanged as fe,catchError as ge}from"rxjs/operators";import{RouterContext as ye}from"sanity/router";import{AiOutlineTags as be,AiOutlineTag as Ce}from"react-icons/ai";function we(e){const t=e?.pattern||"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",n=e?.length||6;return(e?.prefix||"")+re(t,n)()}const ve=e=>{const{onChange:n,ident:i}=e,r=P(),o=Y(()=>{const e=we(i);n(t(e)),r.push({status:"success",title:"Identifier created.",closable:!0})},[n,r,i]);/* @__PURE__ */
2
+ return _(O,{space:2,children:/* @__PURE__ */_(M,{icon:x,mode:"ghost",width:"fill",onClick:o,text:"Generate identifier"})})};ve.defaultProps={ident:void 0};var _e=Object.defineProperty,Ie=Object.getOwnPropertySymbols,xe=Object.prototype.hasOwnProperty,ke=Object.prototype.propertyIsEnumerable,Ve=(e,t,n)=>t in e?_e(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Te=(e,t)=>{for(var n in t||(t={}))xe.call(t,n)&&Ve(e,n,t[n]);if(Ie)for(var n of Ie(t))ke.call(t,n)&&Ve(e,n,t[n]);return e};const Se={tone:"primary"};function Ne(e){const{title:t,description:n,icon:i,tone:r,children:o}=Te(Te({},Se),e);/* @__PURE__ */
3
+ return _(R,{tone:r,padding:4,radius:3,border:!0,children:/* @__PURE__ */v(A,{children:[i?"display icon":null,o||/* @__PURE__ */_(D,{flex:1,children:/* @__PURE__ */v(O,{space:4,children:[t?/* @__PURE__ */_($,{weight:"semibold",children:t}):null,n?/* @__PURE__ */_($,{size:2,children:n}):null]})})]})})}var ze=Object.defineProperty,Ee=Object.getOwnPropertySymbols,He=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable,Oe=(e,t,n)=>t in e?ze(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$e=(e,t)=>{for(var n in t||(t={}))He.call(t,n)&&Oe(e,n,t[n]);if(Ee)for(var n of Ee(t))Le.call(t,n)&&Oe(e,n,t[n]);return e};he((e={})=>/* @__PURE__ */_(R,$e({as:"table"},e)))(()=>me`
4
4
  display: table;
5
5
  width: 100%;
6
6
  border-collapse: collapse;
@@ -9,178 +9,174 @@ return v(M,{tone:r,padding:4,radius:3,border:!0,children:/* @__PURE__ */w(R,{chi
9
9
  display: table;
10
10
  border-collapse: collapse;
11
11
  }
12
- `),pe((e={})=>/* @__PURE__ */v(M,Oe({as:"tr"},e)))(()=>he`
12
+ `),he((e={})=>/* @__PURE__ */_(R,$e({as:"tr"},e)))(()=>me`
13
13
  display: table-row;
14
14
 
15
15
  &:not([hidden]) {
16
16
  display: table-row;
17
17
  }
18
- `),pe((e={})=>/* @__PURE__ */v(M,Oe({as:"td"},e)))(()=>he`
18
+ `),he((e={})=>/* @__PURE__ */_(R,$e({as:"td"},e)))(()=>me`
19
19
  display: table-cell;
20
20
 
21
21
  &:not([hidden]) {
22
22
  display: table-cell;
23
23
  }
24
- `);const $e={},Pe={apiVersion:"v2023-05-01"};function Me(e){const n=ee(()=>JSON.stringify(e||{}),[e]);return ee(()=>JSON.parse(n),[n])}function Re(e,{params:n=$e,options:i=Pe,initialValue:r=null}){const[o,c]=Q(!0),[s,a]=Q(!1),[d,l]=Q(r),p=Me(n),h=Me(i),m=X(null),u=t();return J(()=>{if(e&&!s&&!m.current)try{m.current=u.listenQuery(e,p,h).pipe(ue(me),fe(e=>(console.error(e),a(e),c(!1),l(null),e))).subscribe(e=>{l(n=>me(n,e)?n:e),c(!1),a(!1)})}catch(e){console.error(e),c(!1),a(e)}return s&&m.current&&m.current.unsubscribe(),()=>{var e;m.current&&(null==(e=m?.current)||e.unsubscribe(),m.current=null)}},[e,s,p,h,u]),{data:d,loading:o,error:s}}const Ae=ne(null),De=ne({editControls:!1}),Be=ne(void 0),Fe=(e=1)=>{let n="^.^.concepts[]._ref",t=1;for(;e>t;)n=`^.${n}`,t++;return e>6?"":`"childConcepts": *[_id in ${n} && ^._id in broader[]._ref]|order(prefLabel)\n {\n "id": _id,\n "level": ${e},\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${Fe(e+1)||""}\n }`};var Ze,Ue=new Uint8Array(16);function je(){if(!Ze&&!(Ze=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ze(Ue)}for(var qe=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,Ke=[],Ge=0;Ge<256;++Ge)Ke.push((Ge+256).toString(16).substr(1));function We(e,n,t){var i=(e=e||{}).random||(e.rng||je)();return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=(Ke[e[n+0]]+Ke[e[n+1]]+Ke[e[n+2]]+Ke[e[n+3]]+"-"+Ke[e[n+4]]+Ke[e[n+5]]+"-"+Ke[e[n+6]]+Ke[e[n+7]]+"-"+Ke[e[n+8]]+Ke[e[n+9]]+"-"+Ke[e[n+10]]+Ke[e[n+11]]+Ke[e[n+12]]+Ke[e[n+13]]+Ke[e[n+14]]+Ke[e[n+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&qe.test(e)}(t))throw TypeError("Stringified UUID is invalid");return t}(i)}let Ye;function Qe(e){const n=$(),t=i({apiVersion:"2025-02-19"}),o=function(){const e=te(ge),{routerPanesState:n,groupIndex:t}=b();return Y(i=>{if(!e||!i)return;const r=[...n];r.splice(t+1,t+1,[{id:i,params:{type:"skosConcept"}}]);const o=e.resolvePathFromState({panes:r});e.navigateUrl({path:o})},[e,n,t])}(),c=Ye?.ident,s=e.displayed.baseIri;return Y((i,a)=>{const{id:d,_originalId:l=""}=a||{},p=oe(e.displayed._id),h=p?ce(e.displayed._id):void 0,m=p?se(ae(e.displayed._id),h):de(ae(e.displayed._id)),u=p?se(ae(We()),h):de(ae(We())),f={_id:u,_type:"skosConcept",conceptId:Ce(c),prefLabel:"",baseIri:s,broader:[],related:[]};if(d){const e=r(ae(l));f.broader=[{_key:We(),_ref:le(ae(d)),_type:"reference",_weak:!e,_strengthenOnPublish:e?void 0:{type:"skosConcept",template:{id:"skosConcept"}}}]}const g={_ref:le(u),_type:"reference",_key:We(),_strengthenOnPublish:{type:"skosConcept",template:{id:"skosConcept"}},_weak:!0};t.transaction().createIfNotExists({...e.displayed,_id:m}).create(f).patch(m,e=>"topConcept"===i?e.setIfMissing({topConcepts:[]}).append("topConcepts",[g]):e.setIfMissing({concepts:[]}).append("concepts",[g])).commit({autoGenerateArrayKeys:!0}).then(e=>{n.push({closable:!0,status:"success",title:"Created new concept"}),o(u)}).catch(e=>{n.push({closable:!0,status:"error",title:"Error creating concept",description:e instanceof Error?e.message:"Unknown error occurred"})})},[e.displayed,c,s,t,n,o])}function Xe(e){const n=$(),t=i({apiVersion:"2025-02-19"});return Y((i,r,o)=>{const c="topConcept"==r?"topConcepts":"concepts",s=oe(e.displayed._id),a=s?ce(e.displayed._id):void 0,d=s?se(ae(e.displayed._id),a):de(ae(e.displayed._id));t.transaction().createIfNotExists({...e.displayed,_id:d}).patch(d,e=>e.unset([`${c}[_ref=="${i}"]`])).commit().then(e=>{n.push({closable:!0,status:"success",title:(o?`"${o}"`:"Concept")+" removed from scheme"})}).catch(e=>{n.push({closable:!0,status:"error",title:"Error removing concept",description:e instanceof Error?e.message:"Unknown error occurred"})})},[t,e.displayed,n])}function Je(e){const n=i({apiVersion:"vX"}),t=o(),r=c(),[s,a]=Q([]),[d,l]=Q(null),p=Y(e=>{const n=[],t=e.map(e=>{const t=r([e]);return"string"==typeof t&&""!==t.trim()?t:(n.push(e),"")});if(1===n.length)throw new Error(`Please fill out the ${n[0]} field to enable match scores.`);if(n.length>1)throw new Error(`The following fields must be filled out to enable match scores: ${n.join(", ")}`);return t.filter(Boolean).join(" ")},[r]),h=Y(async(e,i,r)=>{const o=await n.request({url:`/embeddings-index/query/${t}/${i}`,method:"POST",body:{query:e,maxResults:r}});a(o)},[n,t]);return{conceptRecs:s,recsError:d,triggerEmbeddingsSearch:Y(()=>{if(l(null),!e)return;const{indexName:n,fieldReferences:t,maxResults:i=3}=e;try{const e=p(t);h(e,n,i).catch(e=>console.error("Error with embeddings index fetch: ",e))}catch(e){const n=e instanceof Error?e.message:"One or more required fields are empty";l(n)}},[p,e,h])}}const en=({title:e,message:n})=>/* @__PURE__ */w(L,{space:2,children:[
25
- /* @__PURE__ */v(F,{size:1,children:e}),
26
- /* @__PURE__ */v(O,{size:2,muted:!0,style:{whiteSpace:"pre-wrap"},children:n})]}),nn=({concept:e})=>{const[n,t]=Q(!1),i=Y(()=>t(!1),[]),r=Y(()=>t(!0),[]);return e&&(e.definition||e.example||e.scopeNote)?/* @__PURE__ */w(_,{children:[
27
- /* @__PURE__ */v(D,{delay:{open:750},content:/* @__PURE__ */v(A,{padding:1,sizing:"content",children:/* @__PURE__ */v(O,{muted:!0,size:1,children:"View concept details"})}),fallbackPlacements:["right","left"],placement:"top",portal:!0,children:/* @__PURE__ */v(P,{icon:x,mode:"bleed",onClick:r,tone:"default"})}),n&&/* @__PURE__ */v(B,{header:e.prefLabel,id:"dialog-example",onClose:i,zOffset:1e3,width:1,children:/* @__PURE__ */v(A,{padding:4,paddingTop:2,paddingBottom:5,children:/* @__PURE__ */w(L,{space:4,children:[e.definition&&/* @__PURE__ */v(en,{title:"Definition",message:e.definition}),e.example&&/* @__PURE__ */v(en,{title:"Examples",message:e.example}),e.scopeNote&&/* @__PURE__ */v(en,{title:"Scope Notes",message:e.scopeNote})]})})})]}):null};function tn({concept:e,topConcept:n=!1,orphan:t=!1}){const i=te(ge),{routerPanesState:r,groupIndex:o}=b(),{id:c,prefLabel:s}=e??{},a=s||"[new concept]",d=Y(()=>{if(!i||!c)return;const e=[...r];e.splice(o+1,o+1,[{id:c,params:{type:"skosConcept"}}]);const n=i.resolvePathFromState({panes:e});i.navigateUrl({path:n})},[c,i,r,o]);/* @__PURE__ */
28
- return v(D,{delay:{open:750},content:/* @__PURE__ */v(A,{padding:1,sizing:"content",children:/* @__PURE__ */v(O,{muted:!0,size:1,children:`View "${s}"`})}),fallbackPlacements:["right","left"],placement:"top",children:/* @__PURE__ */v(P,{mode:"bleed",paddingLeft:0,onClick:d,width:"fill",justify:"flex-start",children:/* @__PURE__ */w(O,{size:2,weight:n?"bold":"regular",textOverflow:"ellipsis",children:[a,(n||t)&&/* @__PURE__ */v(Z,{fontSize:0,marginLeft:3,style:{verticalAlign:"middle"},children:n?"top concept":"orphan"})]})})})}const rn=({action:e,handler:n})=>{const t={add:{message:"Add a child concept below this concept",icon:V,tone:"positive"},remove:{message:"Remove this concept from this scheme",icon:k,tone:"critical"}};/* @__PURE__ */
29
- return v(D,{delay:{open:750},content:/* @__PURE__ */v(A,{padding:1,sizing:"content",children:/* @__PURE__ */v(O,{muted:!0,size:1,children:t[e].message})}),fallbackPlacements:["right","left"],placement:"top",children:/* @__PURE__ */v(P,{icon:t[e].icon,mode:"bleed",onClick:n,tone:t[e].tone,"aria-label":"Remove this concept from this scheme"})})};function on({concept:e,topConcept:n=!1,orphan:t=!1,selectConcept:i}){const{prefLabel:r,id:o,_originalId:c,score:s}=e??{},a=r||"[new concept]",d=Y(()=>{i&&i({_ref:o,_type:"reference",_originalId:c})},[o,c,i]);/* @__PURE__ */
30
- return v(_,{children:i&&/* @__PURE__ */v(D,{delay:{open:750},content:/* @__PURE__ */v(A,{padding:1,sizing:"content",children:/* @__PURE__ */w(O,{muted:!0,size:1,children:[`Select "${r}"`,s&&` (${(100*s).toFixed(1)}% resource match)`]})}),fallbackPlacements:["right","left","bottom"],placement:"top",portal:!0,children:/* @__PURE__ */v(P,{mode:"bleed",paddingLeft:0,onClick:d,width:"fill",justify:"flex-start",children:/* @__PURE__ */w(O,{size:2,weight:n?"bold":"regular",textOverflow:"ellipsis",children:[a,(n||t)&&/* @__PURE__ */v(Z,{fontSize:0,marginLeft:3,style:{verticalAlign:"middle"},children:n?"top concept":"orphan"}),s&&/* @__PURE__ */v(Z,{fontSize:0,marginLeft:3,style:{verticalAlign:"middle"},children:`${(100*s).toFixed(1)}%`})]})})})})}const cn=({message:e,title:n,type:t})=>{const[i,r]=Q(!1),o=Y(()=>r(!1),[]),c=Y(()=>r(!0),[]);/* @__PURE__ */
31
- return w(_,{children:[
32
- /* @__PURE__ */v(D,{delay:{open:750},content:/* @__PURE__ */v(A,{padding:1,sizing:"content",children:/* @__PURE__ */v(O,{muted:!0,size:1,children:n})}),fallbackPlacements:["right","left"],placement:"top",portal:!0,children:/* @__PURE__ */v(P,{icon:"error"==t?T:x,mode:"bleed",onClick:c,tone:{info:"default",warn:"caution",error:"critical"}[t]})}),i&&/* @__PURE__ */v(B,{header:n,id:"dialog-example",onClose:o,zOffset:1e3,width:1,children:/* @__PURE__ */v(A,{padding:4,paddingBottom:5,children:/* @__PURE__ */v(O,{children:e})})})]})};function sn(e,n){void 0===n&&(n={});var t=n.insertAt;if(e&&!(typeof document>"u")){var i=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===t&&i.firstChild?i.insertBefore(r,i.firstChild):i.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}function an({handler:e,visibility:n}){/* @__PURE__ */
33
- return v(P,{icon:S,mode:"bleed","aria-expanded":"open"==n,onClick:e,className:"ToggleButton-module_toggleButton__4X-Gs"})}sn(".ToggleButton-module_toggleButton__4X-Gs[aria-expanded='true'] svg {\n rotate: 90deg;\n}\n");const dn=({concept:e,selectConcept:n,inputComponent:t=!1})=>{const i=te(Ae)||{},r=te(Be),{globalVisibility:{treeVisibility:o}={treeVisibility:"open"}}=te(De)||{},c=Qe(i),s=Xe(i),a=Y(()=>{c("concept",e)},[e,c]),d=Y(()=>{s(e.id,"concept",e?.prefLabel)},[e.id,e?.prefLabel,s]),[l,p]=Q("closed"===o&&e.hasMatchingDescendant?"open":o||"open"),h=Y(()=>{"open"==l?p("closed"):"closed"==l&&p("open")},[l]);/* @__PURE__ */
34
- return w(A,{className:l,children:[
35
- /* @__PURE__ */w(R,{align:"center",justify:"space-between",wrap:"nowrap",children:[
36
- /* @__PURE__ */w(R,{align:"center",gap:0,flex:1,style:{minWidth:0},children:[e?.childConcepts&&e.childConcepts.length>0&&/* @__PURE__ */v(an,{handler:h,visibility:l}),!e?.prefLabel&&/* @__PURE__ */v(A,{flex:1,marginLeft:e?.childConcepts&&0!=e.childConcepts.length?0:5,children:/* @__PURE__ */v(tn,{concept:e})}),e?.prefLabel&&/* @__PURE__ */v(A,{flex:1,marginLeft:e?.childConcepts&&0!=e.childConcepts.length?0:5,children:t?/* @__PURE__ */v(on,{concept:e,selectConcept:n}):/* @__PURE__ */v(tn,{concept:e})})]}),t&&/* @__PURE__ */v(nn,{concept:e}),!t&&"published"!==r&&e?.level&&e.level<5&&/* @__PURE__ */w(U,{children:[
37
- /* @__PURE__ */v(rn,{action:"add",handler:a}),
38
- /* @__PURE__ */v(rn,{action:"remove",handler:d})]}),!t&&"published"!==r&&0==e.childConcepts?.length&&5==e.level&&/* @__PURE__ */w(U,{children:[
39
- /* @__PURE__ */v(cn,{type:"warn",title:"Taxonomy Manager structure notice",message:"This concept is at the maximum Taxonomy Manager hierarchy depth of 5 levels. Additional child terms are not shown in the hierarchy tree."}),
40
- /* @__PURE__ */v(rn,{action:"remove",handler:d})]}),e?.childConcepts&&e?.childConcepts?.length>0&&5==e.level&&/* @__PURE__ */w(U,{children:[
41
- /* @__PURE__ */v(cn,{type:"error",title:"Taxonomy Manager structure warning",message:"This concept has unlisted child concepts. The maximum validated hierarchy depth is 5 levels."}),!t&&"published"!==r&&/* @__PURE__ */v(rn,{action:"remove",handler:d})]})]}),e?.childConcepts&&e.childConcepts.length>0&&e?.level&&e.level<5&&/* @__PURE__ */v(ln,{concepts:e.childConcepts,selectConcept:n,inputComponent:t,childVisibility:l})]})},ln=({concepts:e,inputComponent:n=!1,selectConcept:t,childVisibility:i})=>
42
- /* @__PURE__ */v(A,{marginLeft:4,marginTop:2,display:"closed"==i?"none":"block",children:/* @__PURE__ */v(L,{space:3,children:e.map(e=>/* @__PURE__ */v(dn,{concept:e,selectConcept:t,inputComponent:n},e.id))})}),pn=({concept:e,treeVisibility:n,inputComponent:t,selectConcept:i})=>{const r=te(Ae)||{},o=te(Be),c=!!r.displayed?.topConcepts?.length&&!t,s=Qe(r),a=Xe(r),[d,l]=Q("closed"===n&&e.hasMatchingDescendant?"open":n),p=Y(()=>{"open"==d?l("closed"):"closed"==d&&l("open")},[d]),h=Y(()=>{s("concept",e)},[e,s]),m=Y(()=>{a(e.id,"concept",e?.prefLabel)},[e.id,e?.prefLabel,a]);/* @__PURE__ */
43
- return w(A,{className:d,children:[
44
- /* @__PURE__ */w(R,{align:"center",justify:"space-between",wrap:"nowrap",children:[
45
- /* @__PURE__ */w(R,{align:"center",gap:0,flex:1,style:{minWidth:0},children:[e?.childConcepts&&e.childConcepts.length>0&&/* @__PURE__ */v(an,{handler:p,visibility:d}),!e?.prefLabel&&/* @__PURE__ */v(A,{flex:1,marginLeft:e?.childConcepts&&0!=e.childConcepts.length?0:5,children:/* @__PURE__ */v(tn,{concept:e,orphan:c})}),e?.prefLabel&&/* @__PURE__ */v(A,{flex:1,marginLeft:e?.childConcepts&&0!=e.childConcepts.length?0:5,children:t?/* @__PURE__ */v(on,{concept:e,selectConcept:i,orphan:c}):/* @__PURE__ */v(tn,{concept:e,orphan:c})})]}),t&&/* @__PURE__ */v(nn,{concept:e}),!t&&"published"!==o&&/* @__PURE__ */w(U,{children:[
46
- /* @__PURE__ */v(rn,{action:"add",handler:h}),
47
- /* @__PURE__ */v(rn,{action:"remove",handler:m})]})]}),e?.childConcepts&&e.childConcepts.length>0&&/* @__PURE__ */v(ln,{concepts:e.childConcepts,selectConcept:i,inputComponent:t,childVisibility:d})]})},hn=({document:e})=>{const[n,t]=Q(!1),[r,o]=Q(""),[c,s]=Q(""),a=Y(()=>t(!1),[]),d=Y(()=>t(!0),[]),l=Y(e=>{o(e.currentTarget.value)},[]),p=Y(e=>{s(e.currentTarget.value)},[]),h=function(){const e=$(),n=i({apiVersion:"2021-10-21"});return Y((t,i,r)=>{const o=t.displayed?._id,c=t.displayed?.baseIri,s=t.displayed?.schemeId,a={_id:`drafts.${o}`,_type:"skosConceptScheme",schemeId:s,baseIri:c,title:i,description:r||""};n.createIfNotExists(a).then(n=>r?e.push({closable:!0,status:"success",title:"Title and Description added."}):e.push({closable:!0,status:"success",title:"Title added."})).catch(n=>{e.push({closable:!0,status:"error",title:"There has been an error",description:n.message})})},[n,e])}(),m=Y(()=>{h(e,r,c)},[h,c,e,r]);/* @__PURE__ */
48
- return w("div",{style:{marginTop:"2rem"},children:[
49
- /* @__PURE__ */v(M,{padding:[3,3,4],radius:2,shadow:1,tone:"primary",children:/* @__PURE__ */w(L,{space:6,children:[
50
- /* @__PURE__ */w(L,{space:4,children:[
51
- /* @__PURE__ */v(F,{size:4,children:"New Concept Scheme"}),
52
- /* @__PURE__ */v(O,{size:2,children:'To start using hierarchy view taxonomy builder, first give your concept scheme a name and optional description. You can also use the "Editor" tab to add concepts to the tree manually.'})]}),
53
- /* @__PURE__ */v(P,{tone:"primary",fontSize:2,icon:N,onClick:d,text:"Add Title"})]})}),n&&/* @__PURE__ */v(B,{header:"Title & Description",id:"title-description",onClose:a,zOffset:1e3,width:1,children:/* @__PURE__ */v(A,{padding:4,children:/* @__PURE__ */w(L,{space:4,children:[
54
- /* @__PURE__ */w(L,{space:2,children:[
55
- /* @__PURE__ */v(F,{size:1,children:"Title"}),
56
- /* @__PURE__ */v(O,{size:1,muted:!0,children:"Describe the concept scheme in one or two words."})]}),
57
- /* @__PURE__ */v(j,{fontSize:2,onChange:l,padding:3,placeholder:"",value:r}),
58
- /* @__PURE__ */w(L,{space:2,children:[
59
- /* @__PURE__ */v(F,{size:1,children:"Description (optional)"}),
60
- /* @__PURE__ */v(O,{size:1,muted:!0,children:"Describe the intended use of this concept scheme."})]}),
61
- /* @__PURE__ */v(q,{fontSize:2,onChange:p,padding:3,placeholder:"",value:c,rows:3}),
62
- /* @__PURE__ */v(P,{tone:"primary",fontSize:2,onClick:m,text:"Save"})]})})})]})},mn=()=>/* @__PURE__ */v("div",{style:{marginTop:"2rem"},children:/* @__PURE__ */v(M,{padding:[3,3,4],radius:2,shadow:1,tone:"primary",children:/* @__PURE__ */w(L,{space:4,children:[
63
- /* @__PURE__ */v(F,{size:4,children:"No Concepts"}),
64
- /* @__PURE__ */v(O,{size:2,children:"There are not yet any concepts assigned to this scheme. To create a multi-level hierarchy with specific entry points, create Top Concepts first, then add child concepts to them. To create a flat list of concepts, create Concepts directly."})]})})}),un=({concept:e,treeVisibility:n,inputComponent:t,selectConcept:i})=>{const r=te(Ae)||{},o=te(Be),c=Qe(r),s=Xe(r),[a,d]=Q("closed"===n&&e.hasMatchingDescendant?"open":n),l=Y(()=>{"open"==a?d("closed"):"closed"==a&&d("open")},[a]),p=Y(()=>{c("concept",e)},[e,c]),h=Y(()=>{s(e?.id,"topConcept",e?.prefLabel)},[e?.id,e?.prefLabel,s]);/* @__PURE__ */
65
- return w(A,{className:a,children:[
66
- /* @__PURE__ */w(R,{align:"center",justify:"space-between",wrap:"nowrap",children:[
67
- /* @__PURE__ */w(R,{align:"center",gap:0,flex:1,style:{minWidth:0},children:[e?.childConcepts&&e.childConcepts.length>0&&/* @__PURE__ */v(an,{handler:l,visibility:a}),!e?.prefLabel&&/* @__PURE__ */v(A,{flex:1,marginLeft:e?.childConcepts&&0!=e.childConcepts.length?0:5,children:/* @__PURE__ */v(tn,{concept:e,topConcept:!0})}),e?.prefLabel&&/* @__PURE__ */v(A,{flex:1,marginLeft:e?.childConcepts&&0!=e.childConcepts.length?0:5,children:t?/* @__PURE__ */v(on,{concept:e,selectConcept:i,topConcept:!0}):/* @__PURE__ */v(tn,{concept:e,topConcept:!0})})]}),t&&/* @__PURE__ */v(nn,{concept:e}),!t&&"published"!==o&&/* @__PURE__ */w(U,{children:[
68
- /* @__PURE__ */v(rn,{action:"add",handler:p}),
69
- /* @__PURE__ */v(rn,{action:"remove",handler:h})]})]}),e?.childConcepts&&e.childConcepts.length>0&&/* @__PURE__ */v(ln,{concepts:e.childConcepts,selectConcept:i,inputComponent:t,childVisibility:a})]})},fn=({concepts:e,inputComponent:n,selectConcept:t})=>{const{globalVisibility:{treeId:i,treeVisibility:r}={treeId:"default",treeVisibility:"open"}}=te(De)||{};return e?.topConcepts?.length||e?.concepts?.length?/* @__PURE__ */v(A,{paddingTop:4,children:/* @__PURE__ */w(L,{space:3,style:{listStyle:"none",paddingLeft:"0",marginBlockStart:"0"},children:[e.topConcepts?.map(e=>/* @__PURE__ */v(un,{concept:e,treeVisibility:r,inputComponent:n,selectConcept:t},`${e?.id}+${i}`)),e.concepts?.filter(e=>e?.isOrphan).map(e=>/* @__PURE__ */v(pn,{concept:e,treeVisibility:r,inputComponent:n,selectConcept:t},`${e.id}+${i}`))]})}):/* @__PURE__ */v(mn,{})},gn=({branchId:e="",selectConcept:n,inputComponent:t,expanded:i,conceptRecs:r,recsError:o})=>{const c=te(Ae)||{},s=le(c.displayed?._id),a=te(Be),d=i?"open":"closed",{data:l,loading:p,error:h}=Re({fetch:`\n select($branchId != null => \n *[_id == $id][0] {\n _updatedAt,\n "concepts": concepts[$branchId in @->broader[]->.conceptId]->|order(prefLabel) {\n "id": _id,\n "level": 0,\n "isOrphan": true,\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${Fe()||""}\n }\n },\n *[_id == $id][0] {\n _updatedAt,\n "topConcepts":topConcepts[]->|order(prefLabel){\n "id": _id,\n "level": 0,\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${Fe()||""}\n }, \n "concepts": concepts[]->|order(prefLabel){\n "id": _id,\n "level": 0,\n "isOrphan": \n coalesce(\n !array::intersects(\n broader[]._ref, (\n coalesce(^.concepts[]._ref, []) + coalesce(^.topConcepts[]._ref, [])\n )\n ), \n true),\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${Fe()||""}\n }\n }\n )`,listen:'*[_type == "skosConcept" || _id == $id]'},{params:{id:s,branchId:e},options:{perspective:void 0===a?"drafts":[a]}}),m=ee(()=>{const e=/* @__PURE__ */new Map;if(Array.isArray(r))for(const n of r)e.set(n.value.documentId,n.score);return e},[r]),u=ee(()=>re(6),[m]),f=Y(function e(n,t){const i=le(n.id),r=t.get(i),o=n.childConcepts?.map(n=>e(n,t)),c=o?.some(e=>void 0!==e.score||e.hasMatchingDescendant)??!1;return{...n,...void 0===r?{}:{score:r},...c?{hasMatchingDescendant:!0}:{},...o?{childConcepts:o}:{}}},[]),g=ee(()=>!l||0===m.size||o?l:{topConcepts:l.topConcepts?.map(e=>f(e,m)),concepts:l.concepts?.map(e=>f(e,m))},[f,l,m,o]);return p?/* @__PURE__ */v(A,{padding:5,children:/* @__PURE__ */w(R,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[
70
- /* @__PURE__ */v(K,{muted:!0}),
71
- /* @__PURE__ */v(O,{muted:!0,size:1,children:"Loading hierarchy…"})]})}):h?(console.warn(h),/* @__PURE__ */v(A,{padding:4,children:/* @__PURE__ */v(M,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */v(O,{size:1,children:"There was a problem loading terms. Please check the scheme configuration and try again."})})})):l?/* @__PURE__ */v(De.Provider,{value:{globalVisibility:{treeId:u,treeVisibility:d}},children:/* @__PURE__ */w(A,{padding:4,paddingTop:0,children:[o&&/* @__PURE__ */v(M,{marginTop:2,padding:3,radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */v(O,{size:2,children:o})}),
72
- /* @__PURE__ */v(fn,{concepts:g,inputComponent:t||!1,selectConcept:n||(()=>{})})]})}):/* @__PURE__ */v(A,{padding:4,children:/* @__PURE__ */v(M,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */v(O,{size:1,children:"This configuration does not have any terms associated with it. Please check the scheme and branch supplied and try again."})})})};function yn(){/* @__PURE__ */
73
- return v("svg",{"data-sanity-icon":!0,width:"25",height:"25",viewBox:"0 0 25 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:/* @__PURE__ */v("path",{d:"M5.5 6.5V5.9H4.9V6.5H5.5ZM11.5 6.5H12.1V5.9H11.5V6.5ZM5.5 9H4.9V9.6H5.5V9ZM11.5 9V9.6H12.1V9H11.5ZM13.5 11V10.4H12.9V11H13.5ZM19.5 11H20.1V10.4H19.5V11ZM13.5 13.5H12.9V14.1H13.5V13.5ZM19.5 13.5V14.1H20.1V13.5H19.5ZM13.5 16V15.4H12.9V16H13.5ZM19.5 16H20.1V15.4H19.5V16ZM13.5 18.5H12.9V19.1H13.5V18.5ZM19.5 18.5V19.1H20.1V18.5H19.5ZM5.5 7.1H11.5V5.9H5.5V7.1ZM6.1 9V6.5H4.9V9H6.1ZM11.5 8.4H5.5V9.6H11.5V8.4ZM10.9 6.5V9H12.1V6.5H10.9ZM13.5 11.6H19.5V10.4H13.5V11.6ZM14.1 13.5V11H12.9V13.5H14.1ZM19.5 12.9H13.5V14.1H19.5V12.9ZM18.9 11V13.5H20.1V11H18.9ZM13.5 16.6H19.5V15.4H13.5V16.6ZM14.1 18.5V16H12.9V18.5H14.1ZM19.5 17.9H13.5V19.1H19.5V17.9ZM18.9 16V18.5H20.1V16H18.9ZM8 17.85H13.5V16.65H8V17.85ZM8 12.85H13.5V11.65H8V12.85ZM7.9 9.5V17.85H9.1V9.5H7.9Z",fill:"currentColor"})})}const bn=({inputComponent:e=!1,selectConcept:n})=>{const t=te(Ae)||{},i=le(t.displayed?._id),r=te(Be),o=Qe(t),c=Y(()=>{o("topConcept")},[o]),s=Y(()=>{o("concept")},[o]),[a,d]=Q({treeId:re(6),treeVisibility:"open"}),l=Y(()=>{d({treeId:re(6),treeVisibility:"open"})},[]),p=Y(()=>{d({treeId:re(6),treeVisibility:"closed"})},[]),{data:h,loading:m,error:u}=Re({fetch:`*[_id == $id][0] {\n _updatedAt,\n "topConcepts": topConcepts[]->|order(prefLabel) {\n "id": _id,\n "level": 0,\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${Fe()||""}\n },\n "concepts": concepts[]->|order(prefLabel) {\n "id": _id,\n "level": 0,\n "isOrphan": \n coalesce(\n !array::intersects(\n broader[]._ref, (\n coalesce(^.concepts[]._ref, []) + coalesce(^.topConcepts[]._ref, [])\n )\n ),\n true),\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${Fe()||""}\n }\n }`,listen:'*[_type == "skosConcept" || _type == "skosConceptScheme" ]'},{params:{id:i},options:{perspective:void 0===r?"drafts":[r]}});return m?/* @__PURE__ */v(A,{padding:4,paddingTop:6,children:/* @__PURE__ */w(R,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",children:[
74
- /* @__PURE__ */v(K,{muted:!0}),
75
- /* @__PURE__ */v(O,{muted:!0,size:1,children:"Loading hierarchy…"})]})}):u?(console.error(u),/* @__PURE__ */v("div",{children:"Error here"})):h?/* @__PURE__ */v(De.Provider,{value:{globalVisibility:a},children:/* @__PURE__ */v(A,{padding:4,children:/* @__PURE__ */w(_,{children:[
76
- /* @__PURE__ */v(L,{space:4,children:/* @__PURE__ */v(M,{borderBottom:!0,paddingBottom:1,display:"flex",flex:1,children:/* @__PURE__ */w(R,{justify:"space-between",flex:1,children:[
77
- /* @__PURE__ */v(M,{children:(h.topConcepts?.filter(e=>(e?.childConcepts?.length??0)>0).length>0||h.concepts?.filter(e=>(e?.childConcepts?.length??0)>0).length>0)&&/* @__PURE__ */w(U,{space:1,children:[
78
- /* @__PURE__ */v(P,{text:"Collapse",paddingY:2,mode:"bleed",onClick:p}),
79
- /* @__PURE__ */v(O,{weight:"semibold",muted:!0,size:1,children:"|"}),
80
- /* @__PURE__ */v(P,{text:"Expand",paddingY:2,mode:"bleed",onClick:l})]})}),
81
- /* @__PURE__ */v(M,{children:"published"!==r&&/* @__PURE__ */w(U,{space:1,children:[
82
- /* @__PURE__ */v(P,{text:"Add Top Concept",icon:V,mode:"bleed",tone:"positive",paddingY:2,onClick:c}),
83
- /* @__PURE__ */v(P,{text:"Add Concept",icon:V,mode:"bleed",tone:"positive",paddingY:2,onClick:s})]})})]})})}),
84
- /* @__PURE__ */v(fn,{concepts:h,inputComponent:e,selectConcept:n||(()=>{})})]})})}):/* @__PURE__ */v(hn,{document:t})},Cn=({document:e,branchId:n,inputComponent:t=!1,selectConcept:i,expanded:r,conceptRecs:o,recsError:c})=>{const{selectedPerspectiveName:a}=s();/* @__PURE__ */
85
- return v(Ae.Provider,{value:e||{},children:/* @__PURE__ */v(Be.Provider,{value:a,children:t?/* @__PURE__ */v(gn,{inputComponent:t,branchId:n,selectConcept:i,expanded:r,conceptRecs:o,recsError:c}):/* @__PURE__ */w(G,{width:1,children:[e?.displayed?.description&&/* @__PURE__ */v(A,{padding:4,paddingTop:6,children:/* @__PURE__ */v(L,{space:4,children:/* @__PURE__ */w(L,{space:2,children:[
86
- /* @__PURE__ */v(O,{size:1,weight:"semibold",children:"Description"}),
87
- /* @__PURE__ */v(O,{size:2,muted:!0,children:e?.displayed.description})]})})}),
88
- /* @__PURE__ */v(bn,{inputComponent:t,branchId:n})]})})})};function wn(n){const t=i({apiVersion:"vX"}),r=e(["_id"]),{name:o,title:c,value:d,embeddingsIndex:l}=n,{conceptRecs:p,recsError:h,triggerEmbeddingsSearch:m}=Je(l),u=oe(r),f=a(r),{selectedPerspectiveName:g}=s(),[y,b]=Q(!0),[C,_]=Q(!0),[I,x]=Q(!1),[k,V]=Q(void 0),[T,S]=Q(),{schemeId:N,branchId:z=null}=T?.params||{},{filter:E}=n.schemaType.options;J(()=>{(async function(){try{const e=await E({getClient:()=>t});S(e),_(!1)}catch(e){console.error("Error fetching filter values: ",e)}})().catch(e=>console.error("Error fetching filter values: ",e))},[E,t]),J(()=>{N&&t.fetch('{"displayed": *[schemeId == $schemeId][0]}',{schemeId:N}).then(e=>{e?.displayed&&(V(e),b(!1))}).catch(e=>console.warn(e))},[t,N]);const H=Y(()=>{x(!0),m()},[m]),$=Y(()=>{x(!1)},[]),D=Y(e=>{(a(e?._originalId)||oe(e?._originalId))&&(e._strengthenOnPublish={type:"skosConcept",template:{id:"skosConcept"}},e._weak=!0),delete e._originalId,f||u?t.patch(r).set({[o]:e}).commit().then(()=>x(!1)).catch(e=>console.error(e)):t.fetch("*[_id == $id][0]",{id:r}).then(n=>{n._id=`drafts.${n._id}`,n[o]=e,t.create(n).catch(e=>console.error("Error creating draft: ",e))}).then(()=>x(!1)).catch(e=>console.error(e))},[t,r,f,u,o]);if(!n.schemaType.options?.filter)/* @__PURE__ */return w(L,{space:3,children:[n.renderDefault(n),
89
- /* @__PURE__ */v(A,{padding:4,children:/* @__PURE__ */v(M,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */w(O,{size:1,children:["The ",
90
- /* @__PURE__ */v("code",{children:"ReferenceHierarchyInput()"})," component must be used with an accompanying"," ",
91
- /* @__PURE__ */v("code",{children:"schemeFilter()"})," or ",
92
- /* @__PURE__ */v("code",{children:"branchFilter()"}),". Please add an appropriate filter to the configuration for the ",c," field."]})})})]});if(0===n.schemaType.options?.filter.length)/* @__PURE__ */
93
- return w(L,{space:3,children:[n.renderDefault(n),
94
- /* @__PURE__ */v(A,{padding:4,children:/* @__PURE__ */v(M,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */w(O,{size:1,children:["There was a problem loading your filter settings. Please check the"," ",
95
- /* @__PURE__ */v("code",{children:"schemeFilter()"})," or ",
96
- /* @__PURE__ */v("code",{children:"branchFilter()"})," configuration for the"," ",c," field."]})})})]});if(y||C)/* @__PURE__ */
97
- return v(A,{padding:5,children:/* @__PURE__ */w(R,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[
98
- /* @__PURE__ */v(K,{muted:!0}),
99
- /* @__PURE__ */v(O,{muted:!0,size:1,children:"Loading input component…"})]})});const F="published"===g;/* @__PURE__ */
100
- return w(L,{space:4,children:[T?.browseOnly?d?n.renderDefault(n):/* @__PURE__ */w(L,{space:2,children:[
101
- /* @__PURE__ */v(A,{paddingY:3,children:/* @__PURE__ */v(O,{size:1,weight:"medium",children:c})}),
102
- /* @__PURE__ */v(M,{padding:3,radius:2,border:!0,children:/* @__PURE__ */v(O,{muted:!0,align:"center",size:1,children:"No items"})})]}):n.renderDefault(n),
103
- /* @__PURE__ */v(W,{columns:1,gap:3,children:/* @__PURE__ */v(P,{disabled:F,icon:yn,text:"Browse taxonomy tree",mode:"ghost",onClick:H})}),I&&k&&/* @__PURE__ */v(B,{header:c,id:"concept-select-dialog",onClose:$,zOffset:900,width:1,children:/* @__PURE__ */v(A,{padding:10,children:/* @__PURE__ */v(Cn,{document:k,branchId:z,inputComponent:!0,selectConcept:D,expanded:T?.expanded,conceptRecs:p,recsError:h})})})]})}function vn(n){const t=i({apiVersion:"2025-02-19"}),r=e(["_id"]),{name:o,title:c,value:l=[],embeddingsIndex:p}=n,h=d(r),m=a(r),{selectedPerspectiveName:u}=s(),[f,g]=Q(!0),[y,b]=Q(!0),[C,_]=Q(!1),[I,x]=Q({}),[k,V]=Q(),{schemeId:T,branchId:S=null}=k?.params||{},{filter:N}=n.schemaType.of[0].options,{conceptRecs:z,recsError:E,triggerEmbeddingsSearch:H}=Je(p),D=$();J(()=>{(async function(){try{const e=await N({getClient:()=>t});V(e),b(!1)}catch(e){console.error("Error fetching filter values: ",e)}})().catch(e=>console.error("Error fetching filter values: ",e))},[N,t]),J(()=>{T&&t.fetch(`{"displayed": *[schemeId == "${T}"][0]}`).then(e=>{e?.displayed&&(x(e),g(!1))}).catch(e=>console.warn(e))},[t,T]);const Z=Y(()=>{_(!0),H()},[H]),U=Y(()=>{_(!1)},[]),j=Y(e=>{if((a(e?._originalId)||d(e?._originalId))&&(e._strengthenOnPublish={type:"skosConcept",template:{id:"skosConcept"}},e._weak=!0),delete e._originalId,l?.map(e=>e._ref).includes(e._ref))return _(!1),void D.push({status:"warning",title:"Taxonomy Term Not Added",description:"The selected concept is already included in this field.",duration:5e3,closable:!0});m||h?t.patch(r).setIfMissing({[o]:[]}).append(o,[e]).commit({autoGenerateArrayKeys:!0}).then(()=>_(!1)).catch(e=>console.error(e)):t.fetch(`*[_id == "${r}"][0]`).then(e=>{e._id=`drafts.${e._id}`,t.create(e).catch(e=>console.error("Error creating draft: ",e))}).then(()=>{t.patch(`drafts.${r}`).setIfMissing({[o]:[]}).append(o,[e]).commit({autoGenerateArrayKeys:!0}).then(()=>_(!1)).catch(e=>console.error(e))}).catch(e=>console.error(e))},[l,m,h,t,r,D,o]);if(!n.schemaType.of[0].options?.filter)/* @__PURE__ */return w(L,{space:3,children:[n.renderDefault(n),
104
- /* @__PURE__ */v(A,{padding:4,children:/* @__PURE__ */v(M,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */w(O,{size:1,children:["The ",
105
- /* @__PURE__ */v("code",{children:"ArrayHierarchyInput()"})," component must be used with an accompanying"," ",
106
- /* @__PURE__ */v("code",{children:"schemeFilter()"})," or ",
107
- /* @__PURE__ */v("code",{children:"branchFilter()"}),". Please add an appropriate filter to the configuration for the ",c," field."]})})})]});if(0===n.schemaType.of[0].options?.filter?.length)/* @__PURE__ */
108
- return w(L,{space:3,children:[n.renderDefault(n),
109
- /* @__PURE__ */v(A,{padding:4,children:/* @__PURE__ */v(M,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */w(O,{size:1,children:["There was a problem loading your filter settings. Please check the"," ",
110
- /* @__PURE__ */v("code",{children:"schemeFilter()"})," or ",
111
- /* @__PURE__ */v("code",{children:"branchFilter()"})," configuration for the"," ",c," field."]})})})]});if(n.schemaType.of.length>1)/* @__PURE__ */
112
- return w(L,{space:3,children:[n.renderDefault(n),
113
- /* @__PURE__ */v(M,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */v(L,{space:4,children:/* @__PURE__ */w(L,{space:2,children:[
114
- /* @__PURE__ */v(F,{size:2,children:"Input Component Not Supported for Multi-Schema Arrays"}),
115
- /* @__PURE__ */w(O,{size:1,children:["The Sanity Taxonomy Manager Hierarchy Input Component is not designed to support array inputs with more than one schema type. Please see the"," ",
116
- /* @__PURE__ */v("a",{href:"https://sanitytaxonomymanager.com",children:"Taxonomy Manager docs"})," for more information."]})]})})})]});if(f||y)/* @__PURE__ */
117
- return v(A,{padding:5,children:/* @__PURE__ */w(R,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[
118
- /* @__PURE__ */v(K,{muted:!0}),
119
- /* @__PURE__ */v(O,{muted:!0,size:1,children:"Loading input component…"})]})});const q="published"===u;/* @__PURE__ */
120
- return w(L,{space:3,children:[k?.browseOnly?l.length>0?n.renderDefault(n):/* @__PURE__ */w(L,{space:2,children:[
121
- /* @__PURE__ */v(A,{paddingY:3,children:/* @__PURE__ */v(O,{size:1,weight:"medium",children:c})}),
122
- /* @__PURE__ */v(M,{padding:3,radius:2,border:!0,children:/* @__PURE__ */v(O,{muted:!0,align:"center",size:1,children:"No items"})})]}):n.renderDefault(n),
123
- /* @__PURE__ */v(W,{columns:1,gap:3,children:/* @__PURE__ */v(P,{disabled:q,icon:yn,text:"Browse taxonomy tree",mode:"ghost",onClick:Z})}),C&&/* @__PURE__ */v(B,{header:c,id:"concept-select-dialog",onClose:U,zOffset:900,width:1,children:/* @__PURE__ */v(A,{children:/* @__PURE__ */v(Cn,{document:I,branchId:S,inputComponent:!0,selectConcept:j,expanded:k?.expanded,conceptRecs:z,recsError:E})})})]})}const _n=e=>{const{onChange:n}=e,t=$(),i=Y(()=>{n(l()),t.push({status:"success",title:"Value removed.",duration:2500,closable:!0})},[n,t]);/* @__PURE__ */
124
- return v(L,{space:2,children:/* @__PURE__ */w(U,{space:[3,3,4],children:[e.renderDefault(e),
125
- /* @__PURE__ */v(P,{tone:"primary",fontSize:2,onClick:i,text:"Remove Value"})]})})},In=e=>{const{schemeId:n}=e||{};if(!n||"string"!=typeof n)throw new Error("Invalid or missing schemeId: scheme Id must be a string");return async t=>{const i=t?.getClient({apiVersion:"2025-02-19"});if(!i)throw new Error("Client not available");const{concepts:r,topConcepts:o}=await i.fetch(`{\n "concepts": *[_type=="skosConceptScheme" && schemeId == "${n}"].concepts[]._ref,\n "topConcepts": *[_type=="skosConceptScheme" && schemeId == "${n}"].topConcepts[]._ref\n }`);return{filter:"(_id in $concepts\n || _id in $topConcepts)",params:{concepts:r,topConcepts:o,schemeId:n},expanded:e?.expanded,browseOnly:e?.browseOnly}}},xn=e=>{const{schemeId:n,branchId:t=null}=e||{};if(!n||"string"!=typeof n)throw new Error("Invalid or missing schemeId: scheme Id must be a string");if(!t||"string"!=typeof t)throw new Error("Invalid or missing branchId: branch Id must be a string");return async i=>{const r=i?.getClient({apiVersion:"2023-01-01"});if(!r)throw new Error("Client not available");const{concepts:o}=await r.fetch('{ \n "concepts": *[\n _id in *[_type=="skosConceptScheme" && schemeId == $schemeId].concepts[]._ref\n && ($branchId in broader[]->conceptId\n || $branchId in broader[]->broader[]->conceptId\n || $branchId in broader[]->broader[]->broader[]->conceptId\n || $branchId in broader[]->broader[]->broader[]->broader[]->conceptId\n || $branchId in broader[]->broader[]->broader[]->broader[]->broader[]->conceptId)\n ]._id\n }',{schemeId:n,branchId:t});return{filter:"_id in $concepts",params:{concepts:o,schemeId:n,branchId:t},expanded:e?.expanded,browseOnly:e?.browseOnly}}};sn("details.baseIriField-module_description__Ac-QT summary {\n cursor: pointer;\n}\ndetails.baseIriField-module_description__Ac-QT div {\n margin-top: 0.5rem;\n margin-left: 0.75rem;\n}\ndetails.baseIriField-module_description__Ac-QT div svg {\n padding-right: 0.25rem;\n}\n");var kn=[p({name:"baseIri",title:"Base URI",type:"url",validation:e=>e.required().error("Please supply a base URI in the format 'http://example.com/'"),description:/* @__PURE__ */w("details",{className:"baseIriField-module_description__Ac-QT",children:[
126
- /* @__PURE__ */v("summary",{children:"The root URI (Uniform Resource Identifier) used to create unique concept identifiers."}),
127
- /* @__PURE__ */w("div",{children:["Unique identifiers allow for the clear an unambiguous identification of concepts across namespaces, for example between ",
128
- /* @__PURE__ */v("code",{children:"https://shipparts.com/vocab#Bow"})," and ",
129
- /* @__PURE__ */v("code",{children:"https://wrappingsupplies.com/vocab#Bow"}),"."]}),
130
- /* @__PURE__ */v("div",{children:"In most cases, it makes sense for your base URI to be the root or a subdirectory of your website. In all cases, the URI you choose should be in a domain that you control."}),
131
- /* @__PURE__ */v("div",{children:"For new Concepts and Concept Schemes, the Base URI field is pre-populated based on the most recently used Base URI value."})]}),components:{input:function(n){const t=e(["conceptId"]),i=e(["schemeId"]);/* @__PURE__ */
132
- return w(L,{space:2,children:[n.renderDefault(n),
133
- /* @__PURE__ */v(O,{muted:!0,size:1,children:/* @__PURE__ */w(_,{children:[
134
- /* @__PURE__ */v("strong",{children:"RDF URI: "}),n.value?n.value:"[base URI not defined] ",t||i||" [identifier not assigned]"]})})]})}}})],Vn="skosConcept-module_description__B9ciz";sn("details.skosConcept-module_description__B9ciz summary {\n cursor: pointer;\n}\ndetails.skosConcept-module_description__B9ciz div {\n margin-top: 0.5rem;\n margin-left: 0.75rem;\n}\ndetails.skosConcept-module_description__B9ciz div svg {\n padding-right: 0.25rem;\n}\n");const Tn=({document:e})=>({filter:"!(_id in $broader || _id in $related || _id == $self)",params:{self:le(ae(e._id)),broader:Array.isArray(e?.broader)?e.broader.map(({_ref:e})=>e):[],related:Array.isArray(e?.related)?e.related.map(({_ref:e})=>e):[]}});function Sn(e,n=[],t){return h({name:"skosConcept",title:"Concept",type:"document",icon:ye,initialValue:async(n,t)=>{if(e)return{baseIri:e,broader:[],related:[]};const{getClient:i}=t;return{baseIri:await i({apiVersion:"2021-03-25"}).fetch("\n *[(_type == 'skosConcept' || _type == 'skosConceptScheme') && defined(baseIri)]| order(_createdAt desc)[0].baseIri\n ")??void 0,broader:[],related:[]}},fields:[p({name:"prefLabel",title:"Preferred Label",type:"string",description:"The preferred lexical label for this concept.",validation:e=>e.required().custom((e,n)=>{const{getClient:t}=n;return t({apiVersion:"2025-06-10"}).withConfig({perspective:"raw"}).fetch(`*[_type == "skosConcept" && prefLabel == "${e}" && !(_id in path("drafts.**") || _id in path("versions.**"))][0]._id`).then(e=>!(e&&!n.document?._id.includes(e))||"Preferred Label must be unique.")})}),p({name:"definition",title:"Definition",type:"text",description:/* @__PURE__ */w("details",{className:Vn,children:[
135
- /* @__PURE__ */v("summary",{children:"A complete explanation of the intended meaning of the concept."}),
136
- /* @__PURE__ */w("div",{children:[
137
- /* @__PURE__ */w("kbd",{children:["Example: documentation",
138
- /* @__PURE__ */v("br",{}),'Definition: "The process of storing and retrieving information in all fields of knowledge."']}),
139
- /* @__PURE__ */w("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",
140
- /* @__PURE__ */w("a",{href:"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation",target:"_blank",rel:"noreferrer",children:[" ","W3C SKOS Primer: 2.4 Documentary Notes"]})]})]})]}),rows:3}),p({name:"example",title:"Examples",type:"text",description:/* @__PURE__ */w("details",{className:Vn,children:[
141
- /* @__PURE__ */v("summary",{children:"An example of the use of the concept."}),
142
- /* @__PURE__ */w("div",{children:[
143
- /* @__PURE__ */w("kbd",{children:["Example: organizations of science and culture",
144
- /* @__PURE__ */v("br",{}),'Example: "academies of science, general museums, world fairs"']}),
145
- /* @__PURE__ */w("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",
146
- /* @__PURE__ */w("a",{href:"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation",target:"_blank",rel:"noreferrer",children:[" ","W3C SKOS Primer: 2.4 Documentary Notes"]})]})]})]}),rows:3}),p({name:"scopeNote",title:"Scope Note",type:"text",description:/* @__PURE__ */w("details",{className:Vn,children:[
147
- /* @__PURE__ */v("summary",{children:"A brief statement on the intended meaning of this concept, especially as an indication of how the use of the concept is limited in indexing practice."}),
148
- /* @__PURE__ */w("div",{children:[
149
- /* @__PURE__ */w("kbd",{children:["Example: microwave frequencies",
150
- /* @__PURE__ */v("br",{}),'Scope Note: "Used for frequencies between 1Ghz and 300Ghz"']}),
151
- /* @__PURE__ */w("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",
152
- /* @__PURE__ */w("a",{href:"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation",target:"_blank",rel:"noreferrer",children:[" ","W3C SKOS Primer: 2.4 Documentary Notes"]})]})]})]}),rows:3}),p({name:"altLabel",title:"Alternate Label(s)",type:"array",description:/* @__PURE__ */w("details",{className:Vn,children:[
153
- /* @__PURE__ */v("summary",{children:"Synonyms, near-synonyms, abbreviations, and acronyms to a concept."}),
154
- /* @__PURE__ */v("div",{children:/* @__PURE__ */w("p",{children:[
155
- /* @__PURE__ */v(z,{})," Preferred, alternative, and hidden label sets must not overlap."]})})]}),of:[{type:"string"}],validation:e=>e.unique()}),p({name:"hiddenLabel",title:"Hidden Label(s)",type:"array",description:/* @__PURE__ */w("details",{className:Vn,children:[
156
- /* @__PURE__ */v("summary",{children:"Character strings that need to be accessible to applications performing text-based indexing and search operations, but which should not be displayed to end users."}),
157
- /* @__PURE__ */w("div",{children:[
158
- /* @__PURE__ */v("p",{children:"Hidden labels may for instance be used to include misspelled variants of other lexical labels."}),
159
- /* @__PURE__ */w("p",{children:[
160
- /* @__PURE__ */v(z,{})," Preferred, alternative, and hidden label sets must not overlap."]})]})]}),of:[{type:"string"}],validation:e=>e.unique()}),...kn,p({name:"conceptId",title:"Identifier",description:"Generate or re-generate the identifier for this concept according to parameters set in Taxonomy Manager plugin options. Note that this changes the concept's URI, which is not advisable if the concept is already in use in production. Use with caution.",type:"string",initialValue:Ce(t),hidden:({document:e})=>!!e?.conceptId&&!t?.regenUi,readOnly:({document:e})=>!!e?.conceptId,components:{input:e=>/* @__PURE__ */v(we,{...e,ident:t})}}),p({name:"broader",title:"Broader Concept(s)",description:/* @__PURE__ */w("details",{className:Vn,children:[
161
- /* @__PURE__ */v("summary",{children:"Create hierarchy between concepts, for example to create category/subcategory, part/whole, or class/instance relationships."}),
162
- /* @__PURE__ */v("div",{children:/* @__PURE__ */v("p",{children:"Broader and Associated relationships are mutually exclusive."})})]}),type:"array",of:[{type:"reference",to:{type:"skosConcept"},options:{filter:Tn}}]}),p({name:"related",title:"Related Concept(s)",description:/* @__PURE__ */w("details",{className:Vn,children:[
163
- /* @__PURE__ */v("summary",{children:'Indicate that two concepts are inherently "related", but that one is not in any way more general than the other.'}),
164
- /* @__PURE__ */v("div",{children:/* @__PURE__ */v("p",{children:"Broader and Associated relationships are mutually exclusive."})})]}),type:"array",of:[{type:"reference",to:[{type:"skosConcept"}],options:{filter:Tn}}]}),...n,p({name:"historyNote",title:"History Notes",type:"text",description:/* @__PURE__ */w("details",{className:Vn,children:[
165
- /* @__PURE__ */v("summary",{children:"Significant changes to the meaning or the form of this concept."}),
166
- /* @__PURE__ */w("div",{children:[
167
- /* @__PURE__ */w("kbd",{children:["Example: person with disabilities",
168
- /* @__PURE__ */v("br",{}),'History Note: "Estab. 1992; heading was: handicapped [1884 - 1992]."']}),
169
- /* @__PURE__ */w("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",
170
- /* @__PURE__ */w("a",{href:"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation",target:"_blank",rel:"noreferrer",children:[" ","W3C SKOS Primer: 2.4 Documentary Notes"]})]})]})]}),rows:3}),p({name:"editorialNote",title:"Editorial Notes",type:"text",description:/* @__PURE__ */w("details",{className:Vn,children:[
171
- /* @__PURE__ */v("summary",{children:"Information to aid in administrative housekeeping, such as reminders of editorial work still to be done, or warnings in the event that future editorial changes might be made."}),
172
- /* @__PURE__ */w("div",{children:[
173
- /* @__PURE__ */w("kbd",{children:["Example: doubleclick",
174
- /* @__PURE__ */v("br",{}),'Editorial Note: "Review this term after the company merger is complete."']}),
175
- /* @__PURE__ */w("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",
176
- /* @__PURE__ */w("a",{href:"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation",target:"_blank",rel:"noreferrer",children:[" ","W3C SKOS Primer: 2.4 Documentary Notes"]})]})]})]}),rows:3}),p({name:"changeNote",title:"Change Notes",type:"text",description:/* @__PURE__ */w("details",{className:Vn,children:[
177
- /* @__PURE__ */v("summary",{children:"Fine-grained changes to a concept, for the purposes of administration and maintenance."}),
178
- /* @__PURE__ */w("div",{children:[
179
- /* @__PURE__ */w("kbd",{children:["Example: tomato",
180
- /* @__PURE__ */v("br",{}),"Change Note: \"Moved from under 'fruits' to under 'vegetables' by Horace Gray\""]}),
181
- /* @__PURE__ */w("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",
182
- /* @__PURE__ */w("a",{href:"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation",target:"_blank",rel:"noreferrer",children:[" ","W3C SKOS Primer: 2.4 Documentary Notes"]})]})]})]}),rows:3})],orderings:[{title:"Top Concepts",name:"topConcept",by:[{field:"topConcept",direction:"desc"},{field:"prefLabel",direction:"asc"}]},{title:"Preferred Label",name:"prefLabel",by:[{field:"prefLabel",direction:"asc"}]}],preview:{select:{title:"prefLabel"},prepare:({title:e})=>({title:e,media:be})}})}function Nn(e,n=[],t){return h({name:"skosConceptScheme",title:"Concept Scheme",type:"document",icon:yn,initialValue:async(n,t)=>{if(e)return{baseIri:e};const{getClient:i}=t;return{baseIri:await i({apiVersion:"2021-03-25"}).fetch("\n *[(_type == 'skosConcept' || _type == 'skosConceptScheme') && defined(baseIri)]| order(_createdAt desc)[0].baseIri\n ")??void 0}},fields:[p({name:"title",title:"Title",type:"string",description:"Taxonomy schemes group concepts into defined sets, such as thesauri, classification schemes, or facets. Concepts may belong to many (or no) concept schemes, and you may create as many (or few) concept schemes as you like"}),p({name:"description",title:"Description",type:"text",rows:5,description:"Describe the intended use of this scheme."}),p({name:"controls",title:"Concept Management Controls",deprecated:{reason:"This field was used for a previous version of the plugin and is no longer needed. Remove the value to hide this field."},type:"boolean",readOnly:!0,hidden:({document:e})=>void 0===e?.controls,components:{input:_n}}),...kn,p({name:"schemeId",title:"Identifier",description:"Generate or re-generate the identifier for this scheme according to parameters set in Taxonomy Manager plugin options. Note that this changes the scheme's URI, which is not advisable if the scheme already is use in production. Use with caution.",type:"string",initialValue:Ce(t),hidden:({document:e})=>!!e?.schemeId&&!t?.regenUi,readOnly:({document:e})=>!!e?.schemeId,components:{input:e=>/* @__PURE__ */v(we,{...e,ident:t})}}),p({name:"topConcepts",title:"Top Concepts",type:"array",validation:e=>e.unique(),of:[m({type:"reference",to:[{type:"skosConcept"}]})],options:{sortable:!1}}),p({name:"concepts",title:"Concepts",type:"array",validation:e=>e.unique(),of:[m({type:"reference",to:[{type:"skosConcept"}]})],options:{sortable:!1}}),...n],preview:{select:{title:"title"},prepare:({title:e})=>({title:e,media:yn})}})}const zn=/_key\s*==\s*['"](.*)['"]/,En=/^\d*:\d*$/,Hn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ln=/_key\s*==\s*['"](.*)['"]/;function On(e){if("string"!=typeof e)throw new Error("Path is not a string");const n=e.match(Hn);if(!n)throw new Error("Invalid path string");return n.map($n)}function $n(e){return function(e){return"number"==typeof e||"string"==typeof e&&/^\[\d+\]$/.test(e)}(e)?function(e){return Number(e.replace(/[^\d]/g,""))}(e):function(e){return"string"==typeof e?zn.test(e.trim()):"object"==typeof e&&"_key"in e}(e)?function(e){return{_key:e.match(Ln)[1]}}(e):function(e){if("string"==typeof e&&En.test(e))return!0;if(!Array.isArray(e)||2!==e.length)return!1;const[n,t]=e;return!("number"!=typeof n&&""!==n||"number"!=typeof t&&""!==t)}(e)?function(e){const[n,t]=e.split(":").map(e=>""===e?e:Number(e));return[n,t]}(e):e}const Pn=({document:e})=>{const{selectedPerspectiveName:n}=s(),{routerPanesState:t,groupIndex:i,handleEditReference:r}=b(),o=u(),c=f(e.displayed?._id??""),a=Y((e,n)=>{const o=t[i+1]?.[0].params||{},{parentRefPath:c}=o;r({id:e,type:n,parentRefPath:c?On(c):[""],template:{id:e}})},[t,i,r]),{data:d,loading:l,error:p}=Re('*[!(_type in ["skosConcept","skosConceptScheme"]) && references($refId)]{_id,_type,title}',{params:{refId:c},options:{perspective:n?[n]:"drafts"}});return l?/* @__PURE__ */v(A,{padding:5,children:/* @__PURE__ */w(R,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[
183
- /* @__PURE__ */v(K,{muted:!0}),
184
- /* @__PURE__ */v(O,{muted:!0,size:1,children:"Loading usage…"})]})}):p?/* @__PURE__ */v(L,{padding:4,space:5,children:/* @__PURE__ */v(Se,{tone:"caution",children:"There was en error fetching use data"})}):d?.length?/* @__PURE__ */v(A,{padding:4,paddingTop:4,children:/* @__PURE__ */w(L,{space:2,children:[
185
- /* @__PURE__ */v(M,{borderBottom:!0,paddingTop:3,paddingBottom:3,children:/* @__PURE__ */v(U,{paddingTop:1,children:/* @__PURE__ */w(O,{weight:"semibold",muted:!0,size:1,children:["Resource count (all schemes): ",d.length]})})}),
186
- /* @__PURE__ */v(L,{space:1,children:d?.map(e=>{const n=o.get(e._type);return n&&/* @__PURE__ */v(P,{onClick:()=>a(e._id,e._type),padding:2,mode:"bleed",children:/* @__PURE__ */v(g,{value:e,schemaType:n,layout:"block"})},e._id)})})]})}):/* @__PURE__ */v(L,{padding:4,space:5,children:/* @__PURE__ */v(Se,{children:"This concept is not currently in use"})})},Mn=e=>e.list().title("Taxonomy Manager").items([e.documentTypeListItem("skosConceptScheme").title("Concept Schemes"),e.documentTypeListItem("skosConcept").title("Concepts")]),Rn=(e,{schemaType:n})=>{switch(n){case"skosConceptScheme":return e.document().views([e.view.component(Cn).title("Tree View").icon(yn),e.view.form().icon(E)]);case"skosConcept":return e.document().views([e.view.form().icon(E),e.view.component(Pn).title("Tagged Resources").icon(H)]);default:return e.document().views([e.view.form().icon(E)])}},An=y(e=>{const{baseUri:n,customConceptFields:t,customSchemeFields:i,ident:r}=e||{};return Ye=e,{name:"taxonomyManager",options:e,schema:{types:[Sn(n,t,r),Nn(n,i,r)]},plugins:[C({name:"taxonomy",title:"Taxonomy",structure:Mn,defaultDocumentNode:Rn,icon:yn})]}});export{vn as ArrayHierarchyInput,wn as ReferenceHierarchyInput,Cn as TreeView,xn as branchFilter,In as schemeFilter,An as taxonomyManager};//# sourceMappingURL=index.esm.esm.js.map
24
+ `);const Pe={},Me={apiVersion:"v2023-05-01"};function Re(e){const t=te(()=>JSON.stringify(e||{}),[e]);return te(()=>JSON.parse(t),[t])}function Ae(e,{params:t=Pe,options:i=Me,initialValue:r=null}){const[o,c]=X(!0),[s,a]=X(!1),[d,l]=X(r),p=Re(t),h=Re(i),m=J(null),u=n();return ee(()=>{if(e&&!s&&!m.current)try{m.current=u.listenQuery(e,p,h).pipe(fe(ue),ge(e=>(console.error(e),a(e),c(!1),l(null),e))).subscribe(e=>{l(t=>ue(t,e)?t:e),c(!1),a(!1)})}catch(e){console.error(e),c(!1),a(e)}return s&&m.current&&m.current.unsubscribe(),()=>{var e;m.current&&(null==(e=m?.current)||e.unsubscribe(),m.current=null)}},[e,s,p,h,u]),{data:d,loading:o,error:s}}const De=ne(null),Be=ne({editControls:!1}),Fe=ne(void 0),Ze=(e=1)=>{let t="^.^.concepts[]._ref",n=1;for(;e>n;)t=`^.${t}`,n++;return e>6?"":`"childConcepts": *[_id in ${t} && ^._id in broader[]._ref]|order(prefLabel)\n {\n "id": _id,\n "level": ${e},\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${Ze(e+1)||""}\n }`};var Ue,je=new Uint8Array(16);function qe(){if(!Ue&&!(Ue=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ue(je)}for(var Ke=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,Ge=[],We=0;We<256;++We)Ge.push((We+256).toString(16).substr(1));function Qe(e,t,n){var i=(e=e||{}).random||(e.rng||qe)();return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(Ge[e[t+0]]+Ge[e[t+1]]+Ge[e[t+2]]+Ge[e[t+3]]+"-"+Ge[e[t+4]]+Ge[e[t+5]]+"-"+Ge[e[t+6]]+Ge[e[t+7]]+"-"+Ge[e[t+8]]+Ge[e[t+9]]+"-"+Ge[e[t+10]]+Ge[e[t+11]]+Ge[e[t+12]]+Ge[e[t+13]]+Ge[e[t+14]]+Ge[e[t+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&Ke.test(e)}(n))throw TypeError("Stringified UUID is invalid");return n}(i)}let Ye;function Xe(e){const t=P(),n=i({apiVersion:"2025-02-19"}),o=function(){const e=ie(ye),{routerPanesState:t,groupIndex:n}=C();return Y(i=>{if(!e||!i)return;const r=[...t];r.splice(n+1,n+1,[{id:i,params:{type:"skosConcept"}}]);const o=e.resolvePathFromState({panes:r});e.navigateUrl({path:o})},[e,t,n])}(),c=Ye?.ident,s=e.displayed.baseIri;return Y((i,a)=>{const{id:d,_originalId:l=""}=a||{},p=ce(e.displayed._id),h=p?se(e.displayed._id):void 0,m=p?ae(de(e.displayed._id),h):le(de(e.displayed._id)),u=p?ae(de(Qe()),h):le(de(Qe())),f={_id:u,_type:"skosConcept",conceptId:we(c),prefLabel:"",baseIri:s,broader:[],related:[]};if(d){const e=r(de(l));f.broader=[{_key:Qe(),_ref:pe(de(d)),_type:"reference",_weak:!e,_strengthenOnPublish:e?void 0:{type:"skosConcept",template:{id:"skosConcept"}}}]}const g={_ref:pe(u),_type:"reference",_key:Qe(),_strengthenOnPublish:{type:"skosConcept",template:{id:"skosConcept"}},_weak:!0};n.transaction().createIfNotExists({...e.displayed,_id:m}).create(f).patch(m,e=>"topConcept"===i?e.setIfMissing({topConcepts:[]}).append("topConcepts",[g]):e.setIfMissing({concepts:[]}).append("concepts",[g])).commit({autoGenerateArrayKeys:!0}).then(e=>{t.push({closable:!0,status:"success",title:"Created new concept"}),o(u)}).catch(e=>{t.push({closable:!0,status:"error",title:"Error creating concept",description:e instanceof Error?e.message:"Unknown error occurred"})})},[e.displayed,c,s,n,t,o])}function Je(e){const t=P(),n=i({apiVersion:"2025-02-19"});return Y((i,r,o)=>{const c="topConcept"==r?"topConcepts":"concepts",s=ce(e.displayed._id),a=s?se(e.displayed._id):void 0,d=s?ae(de(e.displayed._id),a):le(de(e.displayed._id));n.transaction().createIfNotExists({...e.displayed,_id:d}).patch(d,e=>e.unset([`${c}[_ref=="${i}"]`])).commit().then(e=>{t.push({closable:!0,status:"success",title:(o?`"${o}"`:"Concept")+" removed from scheme"})}).catch(e=>{t.push({closable:!0,status:"error",title:"Error removing concept",description:e instanceof Error?e.message:"Unknown error occurred"})})},[n,e.displayed,t])}function et(e){const t=i({apiVersion:"vX"}),n=o(),r=c(),[s,a]=X([]),[d,l]=X(null),p=Y(e=>{const t=[],n=e.map(e=>{const n=r([e]);return"string"==typeof n&&""!==n.trim()?n:(t.push(e),"")});if(1===t.length)throw new Error(`Please fill out the ${t[0]} field to enable match scores.`);if(t.length>1)throw new Error(`The following fields must be filled out to enable match scores: ${t.join(", ")}`);return n.filter(Boolean).join(" ")},[r]),h=Y(async(e,i,r)=>{const o=await t.request({url:`/embeddings-index/query/${n}/${i}`,method:"POST",body:{query:e,maxResults:r}});a(o)},[t,n]);return{conceptRecs:s,recsError:d,triggerEmbeddingsSearch:Y(()=>{if(l(null),!e)return;const{indexName:t,fieldReferences:n,maxResults:i=3}=e;try{const e=p(n);h(e,t,i).catch(e=>console.error("Error with embeddings index fetch: ",e))}catch(e){const t=e instanceof Error?e.message:"One or more required fields are empty";l(t)}},[p,e,h])}}const tt=({title:e,message:t})=>/* @__PURE__ */v(O,{space:2,children:[
25
+ /* @__PURE__ */_(Z,{size:1,children:e}),
26
+ /* @__PURE__ */_($,{size:2,muted:!0,style:{whiteSpace:"pre-wrap"},children:t})]}),nt=({concept:e})=>{const[t,n]=X(!1),i=Y(()=>n(!1),[]),r=Y(()=>n(!0),[]);return e&&(e.definition||e.example||e.scopeNote)?/* @__PURE__ */v(I,{children:[
27
+ /* @__PURE__ */_(B,{delay:{open:750},content:/* @__PURE__ */_(D,{padding:1,sizing:"content",children:/* @__PURE__ */_($,{muted:!0,size:1,children:"View concept details"})}),fallbackPlacements:["right","left"],placement:"top",portal:!0,children:/* @__PURE__ */_(M,{icon:k,mode:"bleed",onClick:r,tone:"default"})}),t&&/* @__PURE__ */_(F,{header:e.prefLabel,id:"dialog-example",onClose:i,zOffset:1e3,width:1,children:/* @__PURE__ */_(D,{padding:4,paddingTop:2,paddingBottom:5,children:/* @__PURE__ */v(O,{space:4,children:[e.definition&&/* @__PURE__ */_(tt,{title:"Definition",message:e.definition}),e.example&&/* @__PURE__ */_(tt,{title:"Examples",message:e.example}),e.scopeNote&&/* @__PURE__ */_(tt,{title:"Scope Notes",message:e.scopeNote})]})})})]}):null};function it({concept:e,topConcept:t=!1,orphan:n=!1}){const i=ie(ye),{routerPanesState:r,groupIndex:o}=C(),{id:c,prefLabel:s}=e??{},a=s||"[new concept]",d=Y(()=>{if(!i||!c)return;const e=[...r];e.splice(o+1,o+1,[{id:c,params:{type:"skosConcept"}}]);const t=i.resolvePathFromState({panes:e});i.navigateUrl({path:t})},[c,i,r,o]);/* @__PURE__ */
28
+ return _(B,{delay:{open:750},content:/* @__PURE__ */_(D,{padding:1,sizing:"content",children:/* @__PURE__ */_($,{muted:!0,size:1,children:`View "${s}"`})}),fallbackPlacements:["right","left"],placement:"top",children:/* @__PURE__ */_(M,{mode:"bleed",paddingLeft:0,onClick:d,width:"fill",justify:"flex-start",children:/* @__PURE__ */v($,{size:2,weight:t?"bold":"regular",textOverflow:"ellipsis",children:[a,(t||n)&&/* @__PURE__ */_(U,{fontSize:0,marginLeft:3,style:{verticalAlign:"middle"},children:t?"top concept":"orphan"})]})})})}const rt=({action:e,handler:t})=>{const n={add:{message:"Add a child concept below this concept",icon:T,tone:"positive"},remove:{message:"Remove this concept from this scheme",icon:V,tone:"critical"}};/* @__PURE__ */
29
+ return _(B,{delay:{open:750},content:/* @__PURE__ */_(D,{padding:1,sizing:"content",children:/* @__PURE__ */_($,{muted:!0,size:1,children:n[e].message})}),fallbackPlacements:["right","left"],placement:"top",children:/* @__PURE__ */_(M,{icon:n[e].icon,mode:"bleed",onClick:t,tone:n[e].tone,"aria-label":"Remove this concept from this scheme"})})};function ot({concept:e,topConcept:t=!1,orphan:n=!1,selectConcept:i}){const{prefLabel:r,id:o,_originalId:c,score:s}=e??{},a=r||"[new concept]",d=Y(()=>{i&&i({_ref:o,_type:"reference",_originalId:c})},[o,c,i]);/* @__PURE__ */
30
+ return _(I,{children:i&&/* @__PURE__ */_(B,{delay:{open:750},content:/* @__PURE__ */_(D,{padding:1,sizing:"content",children:/* @__PURE__ */v($,{muted:!0,size:1,children:[`Select "${r}"`,s&&` (${(100*s).toFixed(1)}% resource match)`]})}),fallbackPlacements:["right","left","bottom"],placement:"top",portal:!0,children:/* @__PURE__ */_(M,{mode:"bleed",paddingLeft:0,onClick:d,width:"fill",justify:"flex-start",children:/* @__PURE__ */v($,{size:2,weight:t?"bold":"regular",textOverflow:"ellipsis",children:[a,(t||n)&&/* @__PURE__ */_(U,{fontSize:0,marginLeft:3,style:{verticalAlign:"middle"},children:t?"top concept":"orphan"}),s&&/* @__PURE__ */_(U,{fontSize:0,marginLeft:3,style:{verticalAlign:"middle"},children:`${(100*s).toFixed(1)}%`})]})})})})}const ct=({message:e,title:t,type:n})=>{const[i,r]=X(!1),o=Y(()=>r(!1),[]),c=Y(()=>r(!0),[]);/* @__PURE__ */
31
+ return v(I,{children:[
32
+ /* @__PURE__ */_(B,{delay:{open:750},content:/* @__PURE__ */_(D,{padding:1,sizing:"content",children:/* @__PURE__ */_($,{muted:!0,size:1,children:t})}),fallbackPlacements:["right","left"],placement:"top",portal:!0,children:/* @__PURE__ */_(M,{icon:"error"==n?S:k,mode:"bleed",onClick:c,tone:{info:"default",warn:"caution",error:"critical"}[n]})}),i&&/* @__PURE__ */_(F,{header:t,id:"dialog-example",onClose:o,zOffset:1e3,width:1,children:/* @__PURE__ */_(D,{padding:4,paddingBottom:5,children:/* @__PURE__ */_($,{children:e})})})]})};function st(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&!(typeof document>"u")){var i=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===n&&i.firstChild?i.insertBefore(r,i.firstChild):i.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}function at({handler:e,visibility:t}){/* @__PURE__ */
33
+ return _(M,{icon:N,mode:"bleed","aria-expanded":"open"==t,onClick:e,className:"ToggleButton-module_toggleButton__4X-Gs"})}st(".ToggleButton-module_toggleButton__4X-Gs[aria-expanded='true'] svg {\n rotate: 90deg;\n}\n");const dt=({concept:e,selectConcept:t,inputComponent:n=!1})=>{const i=ie(De)||{},r=ie(Fe),{globalVisibility:{treeVisibility:o}={treeVisibility:"open"}}=ie(Be)||{},c=Xe(i),s=Je(i),a=Y(()=>{c("concept",e)},[e,c]),d=Y(()=>{s(e.id,"concept",e?.prefLabel)},[e.id,e?.prefLabel,s]),[l,p]=X("closed"===o&&e.hasMatchingDescendant?"open":o||"open"),h=Y(()=>{"open"==l?p("closed"):"closed"==l&&p("open")},[l]);/* @__PURE__ */
34
+ return v(D,{className:l,children:[
35
+ /* @__PURE__ */v(A,{align:"center",justify:"space-between",wrap:"nowrap",children:[
36
+ /* @__PURE__ */v(A,{align:"center",gap:0,flex:1,style:{minWidth:0},children:[e?.childConcepts&&e.childConcepts.length>0&&/* @__PURE__ */_(at,{handler:h,visibility:l}),!e?.prefLabel&&/* @__PURE__ */_(D,{flex:1,marginLeft:e?.childConcepts&&0!=e.childConcepts.length?0:5,children:/* @__PURE__ */_(it,{concept:e})}),e?.prefLabel&&/* @__PURE__ */_(D,{flex:1,marginLeft:e?.childConcepts&&0!=e.childConcepts.length?0:5,children:n?/* @__PURE__ */_(ot,{concept:e,selectConcept:t}):/* @__PURE__ */_(it,{concept:e})})]}),n&&/* @__PURE__ */_(nt,{concept:e}),!n&&"published"!==r&&e?.level&&e.level<5&&/* @__PURE__ */v(j,{children:[
37
+ /* @__PURE__ */_(rt,{action:"add",handler:a}),
38
+ /* @__PURE__ */_(rt,{action:"remove",handler:d})]}),!n&&"published"!==r&&0==e.childConcepts?.length&&5==e.level&&/* @__PURE__ */v(j,{children:[
39
+ /* @__PURE__ */_(ct,{type:"warn",title:"Taxonomy Manager structure notice",message:"This concept is at the maximum Taxonomy Manager hierarchy depth of 5 levels. Additional child terms are not shown in the hierarchy tree."}),
40
+ /* @__PURE__ */_(rt,{action:"remove",handler:d})]}),e?.childConcepts&&e?.childConcepts?.length>0&&5==e.level&&/* @__PURE__ */v(j,{children:[
41
+ /* @__PURE__ */_(ct,{type:"error",title:"Taxonomy Manager structure warning",message:"This concept has unlisted child concepts. The maximum validated hierarchy depth is 5 levels."}),!n&&"published"!==r&&/* @__PURE__ */_(rt,{action:"remove",handler:d})]})]}),e?.childConcepts&&e.childConcepts.length>0&&e?.level&&e.level<5&&/* @__PURE__ */_(lt,{concepts:e.childConcepts,selectConcept:t,inputComponent:n,childVisibility:l})]})},lt=({concepts:e,inputComponent:t=!1,selectConcept:n,childVisibility:i})=>
42
+ /* @__PURE__ */_(D,{marginLeft:4,marginTop:2,display:"closed"==i?"none":"block",children:/* @__PURE__ */_(O,{space:3,children:e.map(e=>/* @__PURE__ */_(dt,{concept:e,selectConcept:n,inputComponent:t},e.id))})}),pt=({concept:e,treeVisibility:t,inputComponent:n,selectConcept:i})=>{const r=ie(De)||{},o=ie(Fe),c=!!r.displayed?.topConcepts?.length&&!n,s=Xe(r),a=Je(r),[d,l]=X("closed"===t&&e.hasMatchingDescendant?"open":t),p=Y(()=>{"open"==d?l("closed"):"closed"==d&&l("open")},[d]),h=Y(()=>{s("concept",e)},[e,s]),m=Y(()=>{a(e.id,"concept",e?.prefLabel)},[e.id,e?.prefLabel,a]);/* @__PURE__ */
43
+ return v(D,{className:d,children:[
44
+ /* @__PURE__ */v(A,{align:"center",justify:"space-between",wrap:"nowrap",children:[
45
+ /* @__PURE__ */v(A,{align:"center",gap:0,flex:1,style:{minWidth:0},children:[e?.childConcepts&&e.childConcepts.length>0&&/* @__PURE__ */_(at,{handler:p,visibility:d}),!e?.prefLabel&&/* @__PURE__ */_(D,{flex:1,marginLeft:e?.childConcepts&&0!=e.childConcepts.length?0:5,children:/* @__PURE__ */_(it,{concept:e,orphan:c})}),e?.prefLabel&&/* @__PURE__ */_(D,{flex:1,marginLeft:e?.childConcepts&&0!=e.childConcepts.length?0:5,children:n?/* @__PURE__ */_(ot,{concept:e,selectConcept:i,orphan:c}):/* @__PURE__ */_(it,{concept:e,orphan:c})})]}),n&&/* @__PURE__ */_(nt,{concept:e}),!n&&"published"!==o&&/* @__PURE__ */v(j,{children:[
46
+ /* @__PURE__ */_(rt,{action:"add",handler:h}),
47
+ /* @__PURE__ */_(rt,{action:"remove",handler:m})]})]}),e?.childConcepts&&e.childConcepts.length>0&&/* @__PURE__ */_(lt,{concepts:e.childConcepts,selectConcept:i,inputComponent:n,childVisibility:d})]})},ht=({document:e})=>{const[t,n]=X(!1),[r,o]=X(""),[c,s]=X(""),a=Y(()=>n(!1),[]),d=Y(()=>n(!0),[]),l=Y(e=>{o(e.currentTarget.value)},[]),p=Y(e=>{s(e.currentTarget.value)},[]),h=function(){const e=P(),t=i({apiVersion:"2021-10-21"});return Y((n,i,r)=>{const o=n.displayed?._id,c=n.displayed?.baseIri,s=n.displayed?.schemeId,a={_id:`drafts.${o}`,_type:"skosConceptScheme",schemeId:s,baseIri:c,title:i,description:r||""};t.createIfNotExists(a).then(t=>r?e.push({closable:!0,status:"success",title:"Title and Description added."}):e.push({closable:!0,status:"success",title:"Title added."})).catch(t=>{e.push({closable:!0,status:"error",title:"There has been an error",description:t.message})})},[t,e])}(),m=Y(()=>{h(e,r,c)},[h,c,e,r]);/* @__PURE__ */
48
+ return v("div",{style:{marginTop:"2rem"},children:[
49
+ /* @__PURE__ */_(R,{padding:[3,3,4],radius:2,shadow:1,tone:"primary",children:/* @__PURE__ */v(O,{space:6,children:[
50
+ /* @__PURE__ */v(O,{space:4,children:[
51
+ /* @__PURE__ */_(Z,{size:4,children:"New Concept Scheme"}),
52
+ /* @__PURE__ */_($,{size:2,children:'To start using hierarchy view taxonomy builder, first give your concept scheme a name and optional description. You can also use the "Editor" tab to add concepts to the tree manually.'})]}),
53
+ /* @__PURE__ */_(M,{tone:"primary",fontSize:2,icon:z,onClick:d,text:"Add Title"})]})}),t&&/* @__PURE__ */_(F,{header:"Title & Description",id:"title-description",onClose:a,zOffset:1e3,width:1,children:/* @__PURE__ */_(D,{padding:4,children:/* @__PURE__ */v(O,{space:4,children:[
54
+ /* @__PURE__ */v(O,{space:2,children:[
55
+ /* @__PURE__ */_(Z,{size:1,children:"Title"}),
56
+ /* @__PURE__ */_($,{size:1,muted:!0,children:"Describe the concept scheme in one or two words."})]}),
57
+ /* @__PURE__ */_(q,{fontSize:2,onChange:l,padding:3,placeholder:"",value:r}),
58
+ /* @__PURE__ */v(O,{space:2,children:[
59
+ /* @__PURE__ */_(Z,{size:1,children:"Description (optional)"}),
60
+ /* @__PURE__ */_($,{size:1,muted:!0,children:"Describe the intended use of this concept scheme."})]}),
61
+ /* @__PURE__ */_(K,{fontSize:2,onChange:p,padding:3,placeholder:"",value:c,rows:3}),
62
+ /* @__PURE__ */_(M,{tone:"primary",fontSize:2,onClick:m,text:"Save"})]})})})]})},mt=()=>/* @__PURE__ */_("div",{style:{marginTop:"2rem"},children:/* @__PURE__ */_(R,{padding:[3,3,4],radius:2,shadow:1,tone:"primary",children:/* @__PURE__ */v(O,{space:4,children:[
63
+ /* @__PURE__ */_(Z,{size:4,children:"No Concepts"}),
64
+ /* @__PURE__ */_($,{size:2,children:"There are not yet any concepts assigned to this scheme. To create a multi-level hierarchy with specific entry points, create Top Concepts first, then add child concepts to them. To create a flat list of concepts, create Concepts directly."})]})})}),ut=({concept:e,treeVisibility:t,inputComponent:n,selectConcept:i})=>{const r=ie(De)||{},o=ie(Fe),c=Xe(r),s=Je(r),[a,d]=X("closed"===t&&e.hasMatchingDescendant?"open":t),l=Y(()=>{"open"==a?d("closed"):"closed"==a&&d("open")},[a]),p=Y(()=>{c("concept",e)},[e,c]),h=Y(()=>{s(e?.id,"topConcept",e?.prefLabel)},[e?.id,e?.prefLabel,s]);/* @__PURE__ */
65
+ return v(D,{className:a,children:[
66
+ /* @__PURE__ */v(A,{align:"center",justify:"space-between",wrap:"nowrap",children:[
67
+ /* @__PURE__ */v(A,{align:"center",gap:0,flex:1,style:{minWidth:0},children:[e?.childConcepts&&e.childConcepts.length>0&&/* @__PURE__ */_(at,{handler:l,visibility:a}),!e?.prefLabel&&/* @__PURE__ */_(D,{flex:1,marginLeft:e?.childConcepts&&0!=e.childConcepts.length?0:5,children:/* @__PURE__ */_(it,{concept:e,topConcept:!0})}),e?.prefLabel&&/* @__PURE__ */_(D,{flex:1,marginLeft:e?.childConcepts&&0!=e.childConcepts.length?0:5,children:n?/* @__PURE__ */_(ot,{concept:e,selectConcept:i,topConcept:!0}):/* @__PURE__ */_(it,{concept:e,topConcept:!0})})]}),n&&/* @__PURE__ */_(nt,{concept:e}),!n&&"published"!==o&&/* @__PURE__ */v(j,{children:[
68
+ /* @__PURE__ */_(rt,{action:"add",handler:p}),
69
+ /* @__PURE__ */_(rt,{action:"remove",handler:h})]})]}),e?.childConcepts&&e.childConcepts.length>0&&/* @__PURE__ */_(lt,{concepts:e.childConcepts,selectConcept:i,inputComponent:n,childVisibility:a})]})},ft=({concepts:e,inputComponent:t,selectConcept:n})=>{const{globalVisibility:{treeId:i,treeVisibility:r}={treeId:"default",treeVisibility:"open"}}=ie(Be)||{};return e?.topConcepts?.length||e?.concepts?.length?/* @__PURE__ */_(D,{paddingTop:4,children:/* @__PURE__ */v(O,{space:3,style:{listStyle:"none",paddingLeft:"0",marginBlockStart:"0"},children:[e.topConcepts?.map(e=>/* @__PURE__ */_(ut,{concept:e,treeVisibility:r,inputComponent:t,selectConcept:n},`${e?.id}+${i}`)),e.concepts?.filter(e=>e?.isOrphan).map(e=>/* @__PURE__ */_(pt,{concept:e,treeVisibility:r,inputComponent:t,selectConcept:n},`${e.id}+${i}`))]})}):/* @__PURE__ */_(mt,{})},gt=({branchId:e="",selectConcept:t,inputComponent:n,expanded:i,conceptRecs:r,recsError:o})=>{const c=ie(De)||{},s=pe(c.displayed?._id),a=ie(Fe),d=i?"open":"closed",{data:l,loading:p,error:h}=Ae({fetch:`\n select($branchId != null => \n *[_id == $id][0] {\n _updatedAt,\n "concepts": concepts[$branchId in @->broader[]->.conceptId]->|order(prefLabel) {\n "id": _id,\n "level": 0,\n "isOrphan": true,\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${Ze()||""}\n }\n },\n *[_id == $id][0] {\n _updatedAt,\n "topConcepts":topConcepts[]->|order(prefLabel){\n "id": _id,\n "level": 0,\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${Ze()||""}\n }, \n "concepts": concepts[]->|order(prefLabel){\n "id": _id,\n "level": 0,\n "isOrphan": \n coalesce(\n !array::intersects(\n broader[]._ref, (\n coalesce(^.concepts[]._ref, []) + coalesce(^.topConcepts[]._ref, [])\n )\n ), \n true),\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${Ze()||""}\n }\n }\n )`,listen:'*[_type == "skosConcept" || _id == $id]'},{params:{id:s,branchId:e},options:{perspective:void 0===a?"drafts":[a]}}),m=te(()=>{const e=/* @__PURE__ */new Map;if(Array.isArray(r))for(const t of r)e.set(t.value.documentId,t.score);return e},[r]),u=te(()=>oe(6),[m]),f=Y(function e(t,n){const i=pe(t.id),r=n.get(i),o=t.childConcepts?.map(t=>e(t,n)),c=o?.some(e=>void 0!==e.score||e.hasMatchingDescendant)??!1;return{...t,...void 0===r?{}:{score:r},...c?{hasMatchingDescendant:!0}:{},...o?{childConcepts:o}:{}}},[]),g=te(()=>!l||0===m.size||o?l:{topConcepts:l.topConcepts?.map(e=>f(e,m)),concepts:l.concepts?.map(e=>f(e,m))},[f,l,m,o]);return p?/* @__PURE__ */_(D,{padding:5,children:/* @__PURE__ */v(A,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[
70
+ /* @__PURE__ */_(G,{muted:!0}),
71
+ /* @__PURE__ */_($,{muted:!0,size:1,children:"Loading hierarchy…"})]})}):h?(console.warn(h),/* @__PURE__ */_(D,{padding:4,children:/* @__PURE__ */_(R,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */_($,{size:1,children:"There was a problem loading terms. Please check the scheme configuration and try again."})})})):l?/* @__PURE__ */_(Be.Provider,{value:{globalVisibility:{treeId:u,treeVisibility:d}},children:/* @__PURE__ */v(D,{padding:4,paddingTop:0,children:[o&&/* @__PURE__ */_(R,{marginTop:2,padding:3,radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */_($,{size:2,children:o})}),
72
+ /* @__PURE__ */_(ft,{concepts:g,inputComponent:n||!1,selectConcept:t||(()=>{})})]})}):/* @__PURE__ */_(D,{padding:4,children:/* @__PURE__ */_(R,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */_($,{size:1,children:"This configuration does not have any terms associated with it. Please check the scheme and branch supplied and try again."})})})};function yt(){/* @__PURE__ */
73
+ return _("svg",{"data-sanity-icon":!0,width:"25",height:"25",viewBox:"0 0 25 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:/* @__PURE__ */_("path",{d:"M5.5 6.5V5.9H4.9V6.5H5.5ZM11.5 6.5H12.1V5.9H11.5V6.5ZM5.5 9H4.9V9.6H5.5V9ZM11.5 9V9.6H12.1V9H11.5ZM13.5 11V10.4H12.9V11H13.5ZM19.5 11H20.1V10.4H19.5V11ZM13.5 13.5H12.9V14.1H13.5V13.5ZM19.5 13.5V14.1H20.1V13.5H19.5ZM13.5 16V15.4H12.9V16H13.5ZM19.5 16H20.1V15.4H19.5V16ZM13.5 18.5H12.9V19.1H13.5V18.5ZM19.5 18.5V19.1H20.1V18.5H19.5ZM5.5 7.1H11.5V5.9H5.5V7.1ZM6.1 9V6.5H4.9V9H6.1ZM11.5 8.4H5.5V9.6H11.5V8.4ZM10.9 6.5V9H12.1V6.5H10.9ZM13.5 11.6H19.5V10.4H13.5V11.6ZM14.1 13.5V11H12.9V13.5H14.1ZM19.5 12.9H13.5V14.1H19.5V12.9ZM18.9 11V13.5H20.1V11H18.9ZM13.5 16.6H19.5V15.4H13.5V16.6ZM14.1 18.5V16H12.9V18.5H14.1ZM19.5 17.9H13.5V19.1H19.5V17.9ZM18.9 16V18.5H20.1V16H18.9ZM8 17.85H13.5V16.65H8V17.85ZM8 12.85H13.5V11.65H8V12.85ZM7.9 9.5V17.85H9.1V9.5H7.9Z",fill:"currentColor"})})}const bt=({inputComponent:e=!1,selectConcept:t})=>{const n=ie(De)||{},i=pe(n.displayed?._id),r=ie(Fe),o=Xe(n),c=Y(()=>{o("topConcept")},[o]),s=Y(()=>{o("concept")},[o]),[a,d]=X({treeId:oe(6),treeVisibility:"open"}),l=Y(()=>{d({treeId:oe(6),treeVisibility:"open"})},[]),p=Y(()=>{d({treeId:oe(6),treeVisibility:"closed"})},[]),{data:h,loading:m,error:u}=Ae({fetch:`*[_id == $id][0] {\n _updatedAt,\n "topConcepts": topConcepts[]->|order(prefLabel) {\n "id": _id,\n "level": 0,\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${Ze()||""}\n },\n "concepts": concepts[]->|order(prefLabel) {\n "id": _id,\n "level": 0,\n "isOrphan": \n coalesce(\n !array::intersects(\n broader[]._ref, (\n coalesce(^.concepts[]._ref, []) + coalesce(^.topConcepts[]._ref, [])\n )\n ),\n true),\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${Ze()||""}\n }\n }`,listen:'*[_type == "skosConcept" || _type == "skosConceptScheme" ]'},{params:{id:i},options:{perspective:void 0===r?"drafts":[r]}});return m?/* @__PURE__ */_(D,{padding:4,paddingTop:6,children:/* @__PURE__ */v(A,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",children:[
74
+ /* @__PURE__ */_(G,{muted:!0}),
75
+ /* @__PURE__ */_($,{muted:!0,size:1,children:"Loading hierarchy…"})]})}):u?(console.error(u),/* @__PURE__ */_("div",{children:"Error here"})):h?/* @__PURE__ */_(Be.Provider,{value:{globalVisibility:a},children:/* @__PURE__ */_(D,{padding:4,children:/* @__PURE__ */v(I,{children:[
76
+ /* @__PURE__ */_(O,{space:4,children:/* @__PURE__ */_(R,{borderBottom:!0,paddingBottom:1,display:"flex",flex:1,children:/* @__PURE__ */v(A,{justify:"space-between",flex:1,children:[
77
+ /* @__PURE__ */_(R,{children:(h.topConcepts?.filter(e=>(e?.childConcepts?.length??0)>0).length>0||h.concepts?.filter(e=>(e?.childConcepts?.length??0)>0).length>0)&&/* @__PURE__ */v(j,{space:1,children:[
78
+ /* @__PURE__ */_(M,{text:"Collapse",paddingY:2,mode:"bleed",onClick:p}),
79
+ /* @__PURE__ */_($,{weight:"semibold",muted:!0,size:1,children:"|"}),
80
+ /* @__PURE__ */_(M,{text:"Expand",paddingY:2,mode:"bleed",onClick:l})]})}),
81
+ /* @__PURE__ */_(R,{children:"published"!==r&&/* @__PURE__ */v(j,{space:1,children:[
82
+ /* @__PURE__ */_(M,{text:"Add Top Concept",icon:T,mode:"bleed",tone:"positive",paddingY:2,onClick:c}),
83
+ /* @__PURE__ */_(M,{text:"Add Concept",icon:T,mode:"bleed",tone:"positive",paddingY:2,onClick:s})]})})]})})}),
84
+ /* @__PURE__ */_(ft,{concepts:h,inputComponent:e,selectConcept:t||(()=>{})})]})})}):/* @__PURE__ */_(ht,{document:n})},Ct=({document:e,branchId:t,inputComponent:n=!1,selectConcept:i,expanded:r,conceptRecs:o,recsError:c})=>{const{selectedPerspectiveName:a}=s();/* @__PURE__ */
85
+ return _(De.Provider,{value:e||{},children:/* @__PURE__ */_(Fe.Provider,{value:a,children:n?/* @__PURE__ */_(gt,{inputComponent:n,branchId:t,selectConcept:i,expanded:r,conceptRecs:o,recsError:c}):/* @__PURE__ */v(W,{width:1,children:[e?.displayed?.description&&/* @__PURE__ */_(D,{padding:4,paddingTop:6,children:/* @__PURE__ */_(O,{space:4,children:/* @__PURE__ */v(O,{space:2,children:[
86
+ /* @__PURE__ */_($,{size:1,weight:"semibold",children:"Description"}),
87
+ /* @__PURE__ */_($,{size:2,muted:!0,children:e?.displayed.description})]})})}),
88
+ /* @__PURE__ */_(bt,{inputComponent:n,branchId:t})]})})})};function wt(t){const n=i({apiVersion:"vX"}),r=e(["_id"]),{name:o,title:c,value:l,embeddingsIndex:p}=t,{conceptRecs:h,recsError:m,triggerEmbeddingsSearch:u}=et(p),f=ce(r),g=a(r),{selectedPerspectiveName:y}=s(),[b,C]=X(!0),[w,I]=X(!0),[x,k]=X(!1),[V,T]=X(void 0),[S,N]=X(),{schemeId:z,branchId:E=null}=S?.params||{},{filter:H}=t.schemaType.options;ee(()=>{(async function(){try{const e=await H({getClient:()=>n});N(e),I(!1)}catch(e){console.error("Error fetching filter values: ",e)}})().catch(e=>console.error("Error fetching filter values: ",e))},[H,n]),ee(()=>{z&&n.fetch('{"displayed": *[schemeId == $schemeId][0]}',{schemeId:z}).then(e=>{e?.displayed&&(T(e),C(!1))}).catch(e=>console.warn(e))},[n,z]);const L=Y(()=>{k(!0),u()},[u]),P=Y(()=>{k(!1)},[]),B=Y(e=>{(a(e?._originalId)||ce(e?._originalId))&&(e._strengthenOnPublish={type:"skosConcept",template:{id:"skosConcept"}},e._weak=!0),delete e._originalId,g||f?n.patch(r).set({[o]:e}).commit().then(()=>k(!1)).catch(e=>console.error(e)):n.fetch("*[_id == $id][0]",{id:r}).then(t=>{t._id=`drafts.${t._id}`,t[o]=e,n.create(t).catch(e=>console.error("Error creating draft: ",e))}).then(()=>k(!1)).catch(e=>console.error(e))},[n,r,g,f,o]);if(!t.schemaType.options?.filter)/* @__PURE__ */return v(O,{space:3,children:[t.renderDefault(t),
89
+ /* @__PURE__ */_(D,{padding:4,children:/* @__PURE__ */_(R,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */v($,{size:1,children:["The ",
90
+ /* @__PURE__ */_("code",{children:"ReferenceHierarchyInput()"})," component must be used with an accompanying"," ",
91
+ /* @__PURE__ */_("code",{children:"schemeFilter()"})," or ",
92
+ /* @__PURE__ */_("code",{children:"branchFilter()"}),". Please add an appropriate filter to the configuration for the ",c," field."]})})})]});if(0===t.schemaType.options?.filter.length)/* @__PURE__ */
93
+ return v(O,{space:3,children:[t.renderDefault(t),
94
+ /* @__PURE__ */_(D,{padding:4,children:/* @__PURE__ */_(R,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */v($,{size:1,children:["There was a problem loading your filter settings. Please check the"," ",
95
+ /* @__PURE__ */_("code",{children:"schemeFilter()"})," or ",
96
+ /* @__PURE__ */_("code",{children:"branchFilter()"})," configuration for the"," ",c," field."]})})})]});if(b||w)/* @__PURE__ */
97
+ return _(D,{padding:5,children:/* @__PURE__ */v(A,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[
98
+ /* @__PURE__ */_(G,{muted:!0}),
99
+ /* @__PURE__ */_($,{muted:!0,size:1,children:"Loading input component…"})]})});const Z="published"===y;/* @__PURE__ */
100
+ return v(O,{space:4,children:[S?.browseOnly?l?t.renderDefault(t):/* @__PURE__ */_(d,{title:c,description:t.description,level:t.level,validation:t.validation,__unstable_presence:t.presence,children:/* @__PURE__ */_(R,{padding:3,radius:2,border:!0,children:/* @__PURE__ */_($,{muted:!0,align:"center",size:1,children:"No items"})})}):t.renderDefault(t),
101
+ /* @__PURE__ */_(Q,{columns:1,gap:3,children:/* @__PURE__ */_(M,{disabled:Z,icon:yt,text:"Browse taxonomy tree",mode:"ghost",onClick:L})}),x&&V&&/* @__PURE__ */_(F,{header:c,id:"concept-select-dialog",onClose:P,zOffset:900,width:1,children:/* @__PURE__ */_(D,{padding:10,children:/* @__PURE__ */_(Ct,{document:V,branchId:E,inputComponent:!0,selectConcept:B,expanded:S?.expanded,conceptRecs:h,recsError:m})})})]})}function vt(t){const n=i({apiVersion:"2025-02-19"}),r=e(["_id"]),{name:o,title:c,value:p=[],embeddingsIndex:h}=t,m=l(r),u=a(r),{selectedPerspectiveName:f}=s(),[g,y]=X(!0),[b,C]=X(!0),[w,I]=X(!1),[x,k]=X({}),[V,T]=X(),{schemeId:S,branchId:N=null}=V?.params||{},{filter:z}=t.schemaType.of[0].options,{conceptRecs:E,recsError:H,triggerEmbeddingsSearch:L}=et(h),B=P();ee(()=>{(async function(){try{const e=await z({getClient:()=>n});T(e),C(!1)}catch(e){console.error("Error fetching filter values: ",e)}})().catch(e=>console.error("Error fetching filter values: ",e))},[z,n]),ee(()=>{S&&n.fetch(`{"displayed": *[schemeId == "${S}"][0]}`).then(e=>{e?.displayed&&(k(e),y(!1))}).catch(e=>console.warn(e))},[n,S]);const U=Y(()=>{I(!0),L()},[L]),j=Y(()=>{I(!1)},[]),q=Y(e=>{if((a(e?._originalId)||l(e?._originalId))&&(e._strengthenOnPublish={type:"skosConcept",template:{id:"skosConcept"}},e._weak=!0),delete e._originalId,p?.map(e=>e._ref).includes(e._ref))return I(!1),void B.push({status:"warning",title:"Taxonomy Term Not Added",description:"The selected concept is already included in this field.",duration:5e3,closable:!0});u||m?n.patch(r).setIfMissing({[o]:[]}).append(o,[e]).commit({autoGenerateArrayKeys:!0}).then(()=>I(!1)).catch(e=>console.error(e)):n.fetch(`*[_id == "${r}"][0]`).then(e=>{e._id=`drafts.${e._id}`,n.create(e).catch(e=>console.error("Error creating draft: ",e))}).then(()=>{n.patch(`drafts.${r}`).setIfMissing({[o]:[]}).append(o,[e]).commit({autoGenerateArrayKeys:!0}).then(()=>I(!1)).catch(e=>console.error(e))}).catch(e=>console.error(e))},[p,u,m,n,r,B,o]);if(!t.schemaType.of[0].options?.filter)/* @__PURE__ */return v(O,{space:3,children:[t.renderDefault(t),
102
+ /* @__PURE__ */_(D,{padding:4,children:/* @__PURE__ */_(R,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */v($,{size:1,children:["The ",
103
+ /* @__PURE__ */_("code",{children:"ArrayHierarchyInput()"})," component must be used with an accompanying"," ",
104
+ /* @__PURE__ */_("code",{children:"schemeFilter()"})," or ",
105
+ /* @__PURE__ */_("code",{children:"branchFilter()"}),". Please add an appropriate filter to the configuration for the ",c," field."]})})})]});if(0===t.schemaType.of[0].options?.filter?.length)/* @__PURE__ */
106
+ return v(O,{space:3,children:[t.renderDefault(t),
107
+ /* @__PURE__ */_(D,{padding:4,children:/* @__PURE__ */_(R,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */v($,{size:1,children:["There was a problem loading your filter settings. Please check the"," ",
108
+ /* @__PURE__ */_("code",{children:"schemeFilter()"})," or ",
109
+ /* @__PURE__ */_("code",{children:"branchFilter()"})," configuration for the"," ",c," field."]})})})]});if(t.schemaType.of.length>1)/* @__PURE__ */
110
+ return v(O,{space:3,children:[t.renderDefault(t),
111
+ /* @__PURE__ */_(R,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */_(O,{space:4,children:/* @__PURE__ */v(O,{space:2,children:[
112
+ /* @__PURE__ */_(Z,{size:2,children:"Input Component Not Supported for Multi-Schema Arrays"}),
113
+ /* @__PURE__ */v($,{size:1,children:["The Sanity Taxonomy Manager Hierarchy Input Component is not designed to support array inputs with more than one schema type. Please see the"," ",
114
+ /* @__PURE__ */_("a",{href:"https://sanitytaxonomymanager.com",children:"Taxonomy Manager docs"})," for more information."]})]})})})]});if(g||b)/* @__PURE__ */
115
+ return _(D,{padding:5,children:/* @__PURE__ */v(A,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[
116
+ /* @__PURE__ */_(G,{muted:!0}),
117
+ /* @__PURE__ */_($,{muted:!0,size:1,children:"Loading input component…"})]})});const K="published"===f;/* @__PURE__ */
118
+ return v(O,{space:3,children:[V?.browseOnly?p.length>0?t.renderDefault(t):/* @__PURE__ */_(d,{title:c,description:t.description,level:t.level,validation:t.validation,__unstable_presence:t.presence,children:/* @__PURE__ */_(R,{padding:3,radius:2,border:!0,children:/* @__PURE__ */_($,{muted:!0,align:"center",size:1,children:"No items"})})}):t.renderDefault(t),
119
+ /* @__PURE__ */_(Q,{columns:1,gap:3,children:/* @__PURE__ */_(M,{disabled:K,icon:yt,text:"Browse taxonomy tree",mode:"ghost",onClick:U})}),w&&/* @__PURE__ */_(F,{header:c,id:"concept-select-dialog",onClose:j,zOffset:900,width:1,children:/* @__PURE__ */_(D,{children:/* @__PURE__ */_(Ct,{document:x,branchId:N,inputComponent:!0,selectConcept:q,expanded:V?.expanded,conceptRecs:E,recsError:H})})})]})}const _t=e=>{const{onChange:t}=e,n=P(),i=Y(()=>{t(p()),n.push({status:"success",title:"Value removed.",duration:2500,closable:!0})},[t,n]);/* @__PURE__ */
120
+ return _(O,{space:2,children:/* @__PURE__ */v(j,{space:[3,3,4],children:[e.renderDefault(e),
121
+ /* @__PURE__ */_(M,{tone:"primary",fontSize:2,onClick:i,text:"Remove Value"})]})})},It=e=>{const{schemeId:t}=e||{};if(!t||"string"!=typeof t)throw new Error("Invalid or missing schemeId: scheme Id must be a string");return async n=>{const i=n?.getClient({apiVersion:"2025-02-19"});if(!i)throw new Error("Client not available");const{concepts:r,topConcepts:o}=await i.fetch(`{\n "concepts": *[_type=="skosConceptScheme" && schemeId == "${t}"].concepts[]._ref,\n "topConcepts": *[_type=="skosConceptScheme" && schemeId == "${t}"].topConcepts[]._ref\n }`);return{filter:"(_id in $concepts\n || _id in $topConcepts)",params:{concepts:r,topConcepts:o,schemeId:t},expanded:e?.expanded,browseOnly:e?.browseOnly}}},xt=e=>{const{schemeId:t,branchId:n=null}=e||{};if(!t||"string"!=typeof t)throw new Error("Invalid or missing schemeId: scheme Id must be a string");if(!n||"string"!=typeof n)throw new Error("Invalid or missing branchId: branch Id must be a string");return async i=>{const r=i?.getClient({apiVersion:"2023-01-01"});if(!r)throw new Error("Client not available");const{concepts:o}=await r.fetch('{ \n "concepts": *[\n _id in *[_type=="skosConceptScheme" && schemeId == $schemeId].concepts[]._ref\n && ($branchId in broader[]->conceptId\n || $branchId in broader[]->broader[]->conceptId\n || $branchId in broader[]->broader[]->broader[]->conceptId\n || $branchId in broader[]->broader[]->broader[]->broader[]->conceptId\n || $branchId in broader[]->broader[]->broader[]->broader[]->broader[]->conceptId)\n ]._id\n }',{schemeId:t,branchId:n});return{filter:"_id in $concepts",params:{concepts:o,schemeId:t,branchId:n},expanded:e?.expanded,browseOnly:e?.browseOnly}}};st("details.baseIriField-module_description__Ac-QT summary {\n cursor: pointer;\n}\ndetails.baseIriField-module_description__Ac-QT div {\n margin-top: 0.5rem;\n margin-left: 0.75rem;\n}\ndetails.baseIriField-module_description__Ac-QT div svg {\n padding-right: 0.25rem;\n}\n");var kt=[h({name:"baseIri",title:"Base URI",type:"url",validation:e=>e.required().error("Please supply a base URI in the format 'http://example.com/'"),description:/* @__PURE__ */v("details",{className:"baseIriField-module_description__Ac-QT",children:[
122
+ /* @__PURE__ */_("summary",{children:"The root URI (Uniform Resource Identifier) used to create unique concept identifiers."}),
123
+ /* @__PURE__ */v("div",{children:["Unique identifiers allow for the clear an unambiguous identification of concepts across namespaces, for example between ",
124
+ /* @__PURE__ */_("code",{children:"https://shipparts.com/vocab#Bow"})," and ",
125
+ /* @__PURE__ */_("code",{children:"https://wrappingsupplies.com/vocab#Bow"}),"."]}),
126
+ /* @__PURE__ */_("div",{children:"In most cases, it makes sense for your base URI to be the root or a subdirectory of your website. In all cases, the URI you choose should be in a domain that you control."}),
127
+ /* @__PURE__ */_("div",{children:"For new Concepts and Concept Schemes, the Base URI field is pre-populated based on the most recently used Base URI value."})]}),components:{input:function(t){const n=e(["conceptId"]),i=e(["schemeId"]);/* @__PURE__ */
128
+ return v(O,{space:2,children:[t.renderDefault(t),
129
+ /* @__PURE__ */_($,{muted:!0,size:1,children:/* @__PURE__ */v(I,{children:[
130
+ /* @__PURE__ */_("strong",{children:"RDF URI: "}),t.value?t.value:"[base URI not defined] ",n||i||" [identifier not assigned]"]})})]})}}})],Vt="skosConcept-module_description__B9ciz";st("details.skosConcept-module_description__B9ciz summary {\n cursor: pointer;\n}\ndetails.skosConcept-module_description__B9ciz div {\n margin-top: 0.5rem;\n margin-left: 0.75rem;\n}\ndetails.skosConcept-module_description__B9ciz div svg {\n padding-right: 0.25rem;\n}\n");const Tt=({document:e})=>({filter:"!(_id in $broader || _id in $related || _id == $self)",params:{self:pe(de(e._id)),broader:Array.isArray(e?.broader)?e.broader.map(({_ref:e})=>e):[],related:Array.isArray(e?.related)?e.related.map(({_ref:e})=>e):[]}});function St(e,t=[],n){return m({name:"skosConcept",title:"Concept",type:"document",icon:be,initialValue:async(t,n)=>{if(e)return{baseIri:e,broader:[],related:[]};const{getClient:i}=n;return{baseIri:await i({apiVersion:"2021-03-25"}).fetch("\n *[(_type == 'skosConcept' || _type == 'skosConceptScheme') && defined(baseIri)]| order(_createdAt desc)[0].baseIri\n ")??void 0,broader:[],related:[]}},fields:[h({name:"prefLabel",title:"Preferred Label",type:"string",description:"The preferred lexical label for this concept.",validation:e=>e.required().custom((e,t)=>{const{getClient:n}=t;return n({apiVersion:"2025-06-10"}).withConfig({perspective:"raw"}).fetch(`*[_type == "skosConcept" && prefLabel == "${e}" && !(_id in path("drafts.**") || _id in path("versions.**"))][0]._id`).then(e=>!(e&&!t.document?._id.includes(e))||"Preferred Label must be unique.")})}),h({name:"definition",title:"Definition",type:"text",description:/* @__PURE__ */v("details",{className:Vt,children:[
131
+ /* @__PURE__ */_("summary",{children:"A complete explanation of the intended meaning of the concept."}),
132
+ /* @__PURE__ */v("div",{children:[
133
+ /* @__PURE__ */v("kbd",{children:["Example: documentation",
134
+ /* @__PURE__ */_("br",{}),'Definition: "The process of storing and retrieving information in all fields of knowledge."']}),
135
+ /* @__PURE__ */v("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",
136
+ /* @__PURE__ */v("a",{href:"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation",target:"_blank",rel:"noreferrer",children:[" ","W3C SKOS Primer: 2.4 Documentary Notes"]})]})]})]}),rows:3}),h({name:"example",title:"Examples",type:"text",description:/* @__PURE__ */v("details",{className:Vt,children:[
137
+ /* @__PURE__ */_("summary",{children:"An example of the use of the concept."}),
138
+ /* @__PURE__ */v("div",{children:[
139
+ /* @__PURE__ */v("kbd",{children:["Example: organizations of science and culture",
140
+ /* @__PURE__ */_("br",{}),'Example: "academies of science, general museums, world fairs"']}),
141
+ /* @__PURE__ */v("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",
142
+ /* @__PURE__ */v("a",{href:"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation",target:"_blank",rel:"noreferrer",children:[" ","W3C SKOS Primer: 2.4 Documentary Notes"]})]})]})]}),rows:3}),h({name:"scopeNote",title:"Scope Note",type:"text",description:/* @__PURE__ */v("details",{className:Vt,children:[
143
+ /* @__PURE__ */_("summary",{children:"A brief statement on the intended meaning of this concept, especially as an indication of how the use of the concept is limited in indexing practice."}),
144
+ /* @__PURE__ */v("div",{children:[
145
+ /* @__PURE__ */v("kbd",{children:["Example: microwave frequencies",
146
+ /* @__PURE__ */_("br",{}),'Scope Note: "Used for frequencies between 1Ghz and 300Ghz"']}),
147
+ /* @__PURE__ */v("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",
148
+ /* @__PURE__ */v("a",{href:"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation",target:"_blank",rel:"noreferrer",children:[" ","W3C SKOS Primer: 2.4 Documentary Notes"]})]})]})]}),rows:3}),h({name:"altLabel",title:"Alternate Label(s)",type:"array",description:/* @__PURE__ */v("details",{className:Vt,children:[
149
+ /* @__PURE__ */_("summary",{children:"Synonyms, near-synonyms, abbreviations, and acronyms to a concept."}),
150
+ /* @__PURE__ */_("div",{children:/* @__PURE__ */v("p",{children:[
151
+ /* @__PURE__ */_(E,{})," Preferred, alternative, and hidden label sets must not overlap."]})})]}),of:[{type:"string"}],validation:e=>e.unique()}),h({name:"hiddenLabel",title:"Hidden Label(s)",type:"array",description:/* @__PURE__ */v("details",{className:Vt,children:[
152
+ /* @__PURE__ */_("summary",{children:"Character strings that need to be accessible to applications performing text-based indexing and search operations, but which should not be displayed to end users."}),
153
+ /* @__PURE__ */v("div",{children:[
154
+ /* @__PURE__ */_("p",{children:"Hidden labels may for instance be used to include misspelled variants of other lexical labels."}),
155
+ /* @__PURE__ */v("p",{children:[
156
+ /* @__PURE__ */_(E,{})," Preferred, alternative, and hidden label sets must not overlap."]})]})]}),of:[{type:"string"}],validation:e=>e.unique()}),...kt,h({name:"conceptId",title:"Identifier",description:"Generate or re-generate the identifier for this concept according to parameters set in Taxonomy Manager plugin options. Note that this changes the concept's URI, which is not advisable if the concept is already in use in production. Use with caution.",type:"string",initialValue:we(n),hidden:({document:e})=>!!e?.conceptId&&!n?.regenUi,readOnly:({document:e})=>!!e?.conceptId,components:{input:e=>/* @__PURE__ */_(ve,{...e,ident:n})}}),h({name:"broader",title:"Broader Concept(s)",description:/* @__PURE__ */v("details",{className:Vt,children:[
157
+ /* @__PURE__ */_("summary",{children:"Create hierarchy between concepts, for example to create category/subcategory, part/whole, or class/instance relationships."}),
158
+ /* @__PURE__ */_("div",{children:/* @__PURE__ */_("p",{children:"Broader and Associated relationships are mutually exclusive."})})]}),type:"array",of:[{type:"reference",to:{type:"skosConcept"},options:{filter:Tt}}]}),h({name:"related",title:"Related Concept(s)",description:/* @__PURE__ */v("details",{className:Vt,children:[
159
+ /* @__PURE__ */_("summary",{children:'Indicate that two concepts are inherently "related", but that one is not in any way more general than the other.'}),
160
+ /* @__PURE__ */_("div",{children:/* @__PURE__ */_("p",{children:"Broader and Associated relationships are mutually exclusive."})})]}),type:"array",of:[{type:"reference",to:[{type:"skosConcept"}],options:{filter:Tt}}]}),...t,h({name:"historyNote",title:"History Notes",type:"text",description:/* @__PURE__ */v("details",{className:Vt,children:[
161
+ /* @__PURE__ */_("summary",{children:"Significant changes to the meaning or the form of this concept."}),
162
+ /* @__PURE__ */v("div",{children:[
163
+ /* @__PURE__ */v("kbd",{children:["Example: person with disabilities",
164
+ /* @__PURE__ */_("br",{}),'History Note: "Estab. 1992; heading was: handicapped [1884 - 1992]."']}),
165
+ /* @__PURE__ */v("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",
166
+ /* @__PURE__ */v("a",{href:"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation",target:"_blank",rel:"noreferrer",children:[" ","W3C SKOS Primer: 2.4 Documentary Notes"]})]})]})]}),rows:3}),h({name:"editorialNote",title:"Editorial Notes",type:"text",description:/* @__PURE__ */v("details",{className:Vt,children:[
167
+ /* @__PURE__ */_("summary",{children:"Information to aid in administrative housekeeping, such as reminders of editorial work still to be done, or warnings in the event that future editorial changes might be made."}),
168
+ /* @__PURE__ */v("div",{children:[
169
+ /* @__PURE__ */v("kbd",{children:["Example: doubleclick",
170
+ /* @__PURE__ */_("br",{}),'Editorial Note: "Review this term after the company merger is complete."']}),
171
+ /* @__PURE__ */v("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",
172
+ /* @__PURE__ */v("a",{href:"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation",target:"_blank",rel:"noreferrer",children:[" ","W3C SKOS Primer: 2.4 Documentary Notes"]})]})]})]}),rows:3}),h({name:"changeNote",title:"Change Notes",type:"text",description:/* @__PURE__ */v("details",{className:Vt,children:[
173
+ /* @__PURE__ */_("summary",{children:"Fine-grained changes to a concept, for the purposes of administration and maintenance."}),
174
+ /* @__PURE__ */v("div",{children:[
175
+ /* @__PURE__ */v("kbd",{children:["Example: tomato",
176
+ /* @__PURE__ */_("br",{}),"Change Note: \"Moved from under 'fruits' to under 'vegetables' by Horace Gray\""]}),
177
+ /* @__PURE__ */v("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",
178
+ /* @__PURE__ */v("a",{href:"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation",target:"_blank",rel:"noreferrer",children:[" ","W3C SKOS Primer: 2.4 Documentary Notes"]})]})]})]}),rows:3})],orderings:[{title:"Top Concepts",name:"topConcept",by:[{field:"topConcept",direction:"desc"},{field:"prefLabel",direction:"asc"}]},{title:"Preferred Label",name:"prefLabel",by:[{field:"prefLabel",direction:"asc"}]}],preview:{select:{title:"prefLabel"},prepare:({title:e})=>({title:e,media:Ce})}})}function Nt(e,t=[],n){return m({name:"skosConceptScheme",title:"Concept Scheme",type:"document",icon:yt,initialValue:async(t,n)=>{if(e)return{baseIri:e};const{getClient:i}=n;return{baseIri:await i({apiVersion:"2021-03-25"}).fetch("\n *[(_type == 'skosConcept' || _type == 'skosConceptScheme') && defined(baseIri)]| order(_createdAt desc)[0].baseIri\n ")??void 0}},fields:[h({name:"title",title:"Title",type:"string",description:"Taxonomy schemes group concepts into defined sets, such as thesauri, classification schemes, or facets. Concepts may belong to many (or no) concept schemes, and you may create as many (or few) concept schemes as you like"}),h({name:"description",title:"Description",type:"text",rows:5,description:"Describe the intended use of this scheme."}),h({name:"controls",title:"Concept Management Controls",deprecated:{reason:"This field was used for a previous version of the plugin and is no longer needed. Remove the value to hide this field."},type:"boolean",readOnly:!0,hidden:({document:e})=>void 0===e?.controls,components:{input:_t}}),...kt,h({name:"schemeId",title:"Identifier",description:"Generate or re-generate the identifier for this scheme according to parameters set in Taxonomy Manager plugin options. Note that this changes the scheme's URI, which is not advisable if the scheme already is use in production. Use with caution.",type:"string",initialValue:we(n),hidden:({document:e})=>!!e?.schemeId&&!n?.regenUi,readOnly:({document:e})=>!!e?.schemeId,components:{input:e=>/* @__PURE__ */_(ve,{...e,ident:n})}}),h({name:"topConcepts",title:"Top Concepts",type:"array",validation:e=>e.unique(),of:[u({type:"reference",to:[{type:"skosConcept"}]})],options:{sortable:!1}}),h({name:"concepts",title:"Concepts",type:"array",validation:e=>e.unique(),of:[u({type:"reference",to:[{type:"skosConcept"}]})],options:{sortable:!1}}),...t],preview:{select:{title:"title"},prepare:({title:e})=>({title:e,media:yt})}})}const zt=/_key\s*==\s*['"](.*)['"]/,Et=/^\d*:\d*$/,Ht=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Lt=/_key\s*==\s*['"](.*)['"]/;function Ot(e){if("string"!=typeof e)throw new Error("Path is not a string");const t=e.match(Ht);if(!t)throw new Error("Invalid path string");return t.map($t)}function $t(e){return function(e){return"number"==typeof e||"string"==typeof e&&/^\[\d+\]$/.test(e)}(e)?function(e){return Number(e.replace(/[^\d]/g,""))}(e):function(e){return"string"==typeof e?zt.test(e.trim()):"object"==typeof e&&"_key"in e}(e)?function(e){return{_key:e.match(Lt)[1]}}(e):function(e){if("string"==typeof e&&Et.test(e))return!0;if(!Array.isArray(e)||2!==e.length)return!1;const[t,n]=e;return!("number"!=typeof t&&""!==t||"number"!=typeof n&&""!==n)}(e)?function(e){const[t,n]=e.split(":").map(e=>""===e?e:Number(e));return[t,n]}(e):e}const Pt=({document:e})=>{const{selectedPerspectiveName:t}=s(),{routerPanesState:n,groupIndex:i,handleEditReference:r}=C(),o=f(),c=g(e.displayed?._id??""),a=Y((e,t)=>{const o=n[i+1]?.[0].params||{},{parentRefPath:c}=o;r({id:e,type:t,parentRefPath:c?Ot(c):[""],template:{id:e}})},[n,i,r]),{data:d,loading:l,error:p}=Ae('*[!(_type in ["skosConcept","skosConceptScheme"]) && references($refId)]{_id,_type,title}',{params:{refId:c},options:{perspective:t?[t]:"drafts"}});return l?/* @__PURE__ */_(D,{padding:5,children:/* @__PURE__ */v(A,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[
179
+ /* @__PURE__ */_(G,{muted:!0}),
180
+ /* @__PURE__ */_($,{muted:!0,size:1,children:"Loading usage…"})]})}):p?/* @__PURE__ */_(O,{padding:4,space:5,children:/* @__PURE__ */_(Ne,{tone:"caution",children:"There was en error fetching use data"})}):d?.length?/* @__PURE__ */_(D,{padding:4,paddingTop:4,children:/* @__PURE__ */v(O,{space:2,children:[
181
+ /* @__PURE__ */_(R,{borderBottom:!0,paddingTop:3,paddingBottom:3,children:/* @__PURE__ */_(j,{paddingTop:1,children:/* @__PURE__ */v($,{weight:"semibold",muted:!0,size:1,children:["Resource count (all schemes): ",d.length]})})}),
182
+ /* @__PURE__ */_(O,{space:1,children:d?.map(e=>{const t=o.get(e._type);return t&&/* @__PURE__ */_(M,{onClick:()=>a(e._id,e._type),padding:2,mode:"bleed",children:/* @__PURE__ */_(y,{value:e,schemaType:t,layout:"block"})},e._id)})})]})}):/* @__PURE__ */_(O,{padding:4,space:5,children:/* @__PURE__ */_(Ne,{children:"This concept is not currently in use"})})},Mt=e=>e.list().title("Taxonomy Manager").items([e.documentTypeListItem("skosConceptScheme").title("Concept Schemes"),e.documentTypeListItem("skosConcept").title("Concepts")]),Rt=(e,{schemaType:t})=>{switch(t){case"skosConceptScheme":return e.document().views([e.view.component(Ct).title("Tree View").icon(yt),e.view.form().icon(H)]);case"skosConcept":return e.document().views([e.view.form().icon(H),e.view.component(Pt).title("Tagged Resources").icon(L)]);default:return e.document().views([e.view.form().icon(H)])}},At=b(e=>{const{baseUri:t,customConceptFields:n,customSchemeFields:i,ident:r}=e||{};return Ye=e,{name:"taxonomyManager",options:e,schema:{types:[St(t,n,r),Nt(t,i,r)]},plugins:[w({name:"taxonomy",title:"Taxonomy",structure:Mt,defaultDocumentNode:Rt,icon:yt})]}});export{vt as ArrayHierarchyInput,wt as ReferenceHierarchyInput,Ct as TreeView,xt as branchFilter,It as schemeFilter,At as taxonomyManager};//# sourceMappingURL=index.esm.esm.js.map