sanity-plugin-taxonomy-manager
Version:
Create and manage SKOS compliant taxonomies, thesauri, and classification schemes in Sanity Studio.
311 lines (308 loc) • 50.1 kB
JavaScript
import{useFormValue as e,set as n,useDocumentStore as t,useClient as i,isPublishedId as o,useColorSchemeValue as r,usePerspective as c,isDraftId as a,isVersionId as s,unset as d,defineField as l,defineType as p,defineArrayMember as h,definePlugin as m}from"sanity";import{usePaneRouter as u,structureTool as f}from"sanity/structure";import{useCallback as g,useState as y,useRef as b,useEffect as C,useMemo as v,createContext as w,useContext as I}from"react";import{hues as _}from"@sanity/color";import k,{styled as x,css as V}from"styled-components";import{jsxs as N,jsx as T,Fragment as z}from"react/jsx-runtime";import{isVersionId as S,getVersionNameFromId as $,getVersionId as H,DocumentId as P,getDraftId as L,getPublishedId as E}from"@sanity/id-utils";import{Stack as O,Text as M,useToast as R,Inline as A,Button as D,Card as Z,Dialog as F,Box as U,Label as K,Tooltip as B,TextInput as q,TextArea as j,Flex as G,Spinner as W,Container as J,Grid as Q}from"@sanity/ui";import{InfoOutlineIcon as Y,ToggleArrowRightIcon as X,SquareIcon as ee,AddCircleIcon as ne,TrashIcon as te,ErrorOutlineIcon as ie,AddIcon as oe,WarningOutlineIcon as re,EditIcon as ce}from"@sanity/icons";import{nanoid as ae}from"nanoid";import se from"react-fast-compare";import{distinctUntilChanged as de,catchError as le}from"rxjs/operators";import{RouterContext as pe}from"sanity/router";import{AiOutlineTags as he,AiOutlineTag as me}from"react-icons/ai";const ue=e=>{const{onChange:t}=e,i=R(),o=g(()=>{t(n(ae(6))),i.push({status:"success",title:"Identifier created.",closable:!0})},[t,i]);/* @__PURE__ */
return T(O,{space:2,children:/* @__PURE__ */T(A,{space:[3,3,4],children:/* @__PURE__ */T(D,{tone:"primary",fontSize:2,onClick:o,text:"Generate Identifier"})})})};var fe=Object.defineProperty,ge=Object.getOwnPropertySymbols,ye=Object.prototype.hasOwnProperty,be=Object.prototype.propertyIsEnumerable,Ce=(e,n,t)=>n in e?fe(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,ve=(e,n)=>{for(var t in n||(n={}))ye.call(n,t)&&Ce(e,t,n[t]);if(ge)for(var t of ge(n))be.call(n,t)&&Ce(e,t,n[t]);return e};x((e={})=>/* @__PURE__ */T(Z,ve({as:"table"},e)))(()=>V`
display: table;
width: 100%;
border-collapse: collapse;
&:not([hidden]) {
display: table;
border-collapse: collapse;
}
`),x((e={})=>/* @__PURE__ */T(Z,ve({as:"tr"},e)))(()=>V`
display: table-row;
&:not([hidden]) {
display: table-row;
}
`),x((e={})=>/* @__PURE__ */T(Z,ve({as:"td"},e)))(()=>V`
display: table-cell;
&:not([hidden]) {
display: table-cell;
}
`);const we={},Ie={apiVersion:"v2023-05-01"};function _e(e){const n=v(()=>JSON.stringify(e||{}),[e]);return v(()=>JSON.parse(n),[n])}function ke(e,{params:n=we,options:i=Ie,initialValue:o=null}){const[r,c]=y(!0),[a,s]=y(!1),[d,l]=y(o),p=_e(n),h=_e(i),m=b(null),u=t();return C(()=>{if(e&&!a&&!m.current)try{m.current=u.listenQuery(e,p,h).pipe(de(se),le(e=>(console.error(e),s(e),c(!1),l(null),e))).subscribe(e=>{l(n=>se(n,e)?n:e),c(!1),s(!1)})}catch(e){console.error(e),c(!1),s(e)}return a&&m.current&&m.current.unsubscribe(),()=>{var e;m.current&&(null==(e=m?.current)||e.unsubscribe(),m.current=null)}},[e,a,p,h,u]),{data:d,loading:r,error:a}}const xe=w(null),Ve=w({editControls:!1}),Ne=w(void 0),Te=(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 ${Te(e+1)||""}\n }`},ze=k.details`
summary {
cursor: pointer;
}
div {
margin-top: 0.5rem;
margin-left: 0.75rem;
svg {
padding-right: 0.25rem;
}
}
`,Se=k.div`
margin-top: 2rem;
`,$e=k.ul`
list-style: none;
padding-left: 0;
margin-block-start: 0;
li svg.info {
height: 1.2rem;
width: 1.2rem;
color: ${_.gray[800].hex};
border-radius: 3px;
transition: all 0.1s ease-in-out;
&.warning:hover {
color: ${_.gray[100].hex};
background-color: ${_.yellow[500].hex};
}
&.error {
color: ${_.red[500].hex};
&:hover {
color: ${_.gray[100].hex};
background-color: ${_.red[500].hex};
}
}
}
li svg.spacer {
height: 1.5rem;
width: 1.5rem;
visibility: hidden;
}
`,He=k.button`
background: none;
border: none;
padding: 0.5rem;
border-radius: 3px;
cursor: pointer;
svg {
padding-right: 0.25rem;
}
&:hover {
background-color: ${_.gray[50].hex};
}
&.add:hover {
background-color: ${_.green[500].hex};
span,
svg {
color: white;
}
}
`,Pe=k.button`
background: none;
border: none;
padding: 0.2rem 0 0;
cursor: pointer;
svg {
border-radius: 3px;
transition: all 0.1s ease-in-out;
}
&.toggle svg {
height: 1.5rem;
width: 1.5rem;
}
&.action svg {
height: 1.2rem;
height: 1.2rem;
width: 1.2rem;
&:hover {
color: ${_.gray[100].hex} !important;
}
&.info:hover {
background-color: ${_.blue[500].hex};
}
&.add:hover {
background-color: ${_.green[500].hex};
}
&.remove:hover {
background-color: ${_.red[500].hex};
}
}
`,Le=k.button`
background: none;
border: none;
padding: 0.2rem 0 0;
cursor: pointer;
svg {
height: 1.5rem;
width: 1.5rem;
}
`,Ee=k.li`
font-weight: bold;
margin-top: 1rem;
.untitled {
color: ${_.gray[400].hex};
font-weight: normal;
}
button[aria-expanded='true'] svg {
rotate: 90deg;
}
&.closed ul {
display: none;
}
`,Oe=k.li`
padding-top: 0.5rem;
font-weight: normal;
margin-top: 1rem;
.untitled {
color: ${_.gray[400].hex};
}
button[aria-expanded='true'] svg {
rotate: 90deg;
}
&.closed ul {
display: none;
}
`,Me=k.ul`
list-style: none;
`,Re=k.li`
font-weight: normal;
margin-top: 1rem;
button[aria-expanded='true'] svg {
rotate: 90deg;
}
&.closed ul {
display: none;
}
`,Ae=k.a`
text-decoration: none;
&:hover {
text-decoration: underline;
}
`,De=k.p``;var Ze,Fe=new Uint8Array(16);function Ue(){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(Fe)}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,Be=[],qe=0;qe<256;++qe)Be.push((qe+256).toString(16).substr(1));function je(e,n,t){var i=(e=e||{}).random||(e.rng||Ue)();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=(Be[e[n+0]]+Be[e[n+1]]+Be[e[n+2]]+Be[e[n+3]]+"-"+Be[e[n+4]]+Be[e[n+5]]+"-"+Be[e[n+6]]+Be[e[n+7]]+"-"+Be[e[n+8]]+Be[e[n+9]]+"-"+Be[e[n+10]]+Be[e[n+11]]+Be[e[n+12]]+Be[e[n+13]]+Be[e[n+14]]+Be[e[n+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&Ke.test(e)}(t))throw TypeError("Stringified UUID is invalid");return t}(i)}function Ge(e){const n=R(),t=i({apiVersion:"2025-02-19"}),r=function(){const e=I(pe),{routerPanesState:n,groupIndex:t}=u();return g(i=>{if(!e||!i)return;const o=[...n];o.splice(t+1,t+1,[{id:i,params:{type:"skosConcept"}}]);const r=e.resolvePathFromState({panes:o});e.navigateUrl({path:r})},[e,n,t])}(),c=e.displayed.baseIri;return g((i,a)=>{const{id:s,_originalId:d=""}=a||{},l=S(e.displayed._id),p=l?$(e.displayed._id):void 0,h=l?H(P(e.displayed._id),p):L(P(e.displayed._id)),m=l?H(P(je()),p):L(P(je())),u={_id:m,_type:"skosConcept",conceptId:`${ae(6)}`,prefLabel:"",baseIri:c,broader:[],related:[]};if(s){const e=o(P(d));u.broader=[{_key:je(),_ref:E(P(s)),_type:"reference",_weak:!e,_strengthenOnPublish:e?void 0:{type:"skosConcept",template:{id:"skosConcept"}}}]}const f={_ref:E(m),_type:"reference",_key:je(),_strengthenOnPublish:{type:"skosConcept",template:{id:"skosConcept"}},_weak:!0};t.transaction().createIfNotExists({...e.displayed,_id:h}).create(u).patch(h,e=>"topConcept"===i?e.setIfMissing({topConcepts:[]}).append("topConcepts",[f]):e.setIfMissing({concepts:[]}).append("concepts",[f])).commit({autoGenerateArrayKeys:!0}).then(e=>{n.push({closable:!0,status:"success",title:"Created new concept"}),r(m)}).catch(e=>{n.push({closable:!0,status:"error",title:"Error creating concept",description:e instanceof Error?e.message:"Unknown error occurred"})})},[e.displayed,t,c,n,r])}function We(e){const n=R(),t=i({apiVersion:"2025-02-19"});return g((i,o,r)=>{const c="topConcept"==o?"topConcepts":"concepts",a=S(e.displayed._id),s=a?$(e.displayed._id):void 0,d=a?H(P(e.displayed._id),s):L(P(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:(r?`"${r}"`:"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(){return"dark"==r()?_.gray[50].hex:_.gray[800].hex}const Qe=({concept:e})=>{const[n,t]=y(!1),i=g(()=>t(!1),[]),o=g(()=>t(!0),[]),r=Je();return e&&(e.definition||e.example||e.scopeNote)?/* @__PURE__ */N(z,{children:[
/* @__PURE__ */T(Pe,{className:"action","aria-label":"info",onClick:o,type:"button",children:/* @__PURE__ */T(Y,{className:"info",style:{color:r}})}),n&&/* @__PURE__ */T(F,{header:e.prefLabel,id:"dialog-example",onClose:i,zOffset:1e3,width:1,children:/* @__PURE__ */T(U,{padding:4,paddingBottom:5,children:/* @__PURE__ */N(O,{space:4,children:[e.definition&&/* @__PURE__ */N(O,{space:2,children:[
/* @__PURE__ */T(K,{size:1,children:"Definition"}),
/* @__PURE__ */T(M,{size:2,muted:!0,style:{whiteSpace:"pre-wrap"},children:e.definition})]}),e.example&&/* @__PURE__ */N(O,{space:2,children:[
/* @__PURE__ */T(K,{size:1,children:"Example"}),
/* @__PURE__ */T(M,{size:2,muted:!0,style:{whiteSpace:"pre-wrap"},children:e.example})]}),e.scopeNote&&/* @__PURE__ */N(O,{space:2,children:[
/* @__PURE__ */T(K,{size:1,children:"Scope Note"}),
/* @__PURE__ */T(M,{size:2,muted:!0,style:{whiteSpace:"pre-wrap"},children:e.scopeNote})]})]})})})]}):null};function Ye({concept:e}){const n=I(pe),{routerPanesState:t,groupIndex:i}=u(),o=Je(),{id:r,prefLabel:c}=e??{},a=g(()=>{if(!n||!r)return;const e=[...t];e.splice(i+1,i+1,[{id:r,params:{type:"skosConcept"}}]);const o=n.resolvePathFromState({panes:e});n.navigateUrl({path:o})},[r,n,t,i]);/* @__PURE__ */
return T(Ae,{href:"#",onClick:a,style:{color:o},children:c})}function Xe({concept:e,selectConcept:n}){const{prefLabel:t,id:i,_originalId:o}=e??{},r=Je(),c=g(()=>{n({_ref:i,_type:"reference",_originalId:o})},[i,o,n]);/* @__PURE__ */
return T(z,{children:n?/* @__PURE__ */T(Ae,{href:"#",onClick:c,style:{color:r},children:t}):/* @__PURE__ */T(De,{children:t})})}const en=({concept:e,selectConcept:n,inputComponent:t=!1})=>{const i=I(xe)||{},o=I(Ne),{globalVisibility:{treeVisibility:r}}=I(Ve)||{},c=Ge(i),a=We(i),s=g(()=>{c("concept",e)},[e,c]),d=g(()=>{a(e.id,"concept",e?.prefLabel)},[e.id,e?.prefLabel,a]),[l,p]=y(r),h=g(()=>{"open"==l?p("closed"):"closed"==l&&p("open")},[l]);/* @__PURE__ */
return N(Re,{className:l,children:[
/* @__PURE__ */N(A,{space:2,children:[
/* @__PURE__ */N(A,{space:1,children:[
/* @__PURE__ */N(A,{space:1,children:[e?.childConcepts&&e.childConcepts.length>0&&/* @__PURE__ */T(Le,{onClick:h,type:"button","aria-expanded":"open"==l,children:/* @__PURE__ */T(X,{})}),e?.childConcepts&&0==e.childConcepts.length&&/* @__PURE__ */T(ee,{className:"spacer"}),!e?.prefLabel&&/* @__PURE__ */T("span",{className:"untitled",children:"[new concept]"}),t?/* @__PURE__ */T(Xe,{concept:e,selectConcept:n}):/* @__PURE__ */T(Ye,{concept:e})]}),t&&/* @__PURE__ */T(Qe,{concept:e})]}),!t&&"published"!==o&&e?.level&&e.level<5&&/* @__PURE__ */N(A,{space:2,children:[
/* @__PURE__ */T(B,{delay:{open:750},content:/* @__PURE__ */T(U,{padding:1,sizing:"content",children:/* @__PURE__ */T(M,{muted:!0,size:1,children:"Add a child concept below this concept"})}),fallbackPlacements:["right","left"],placement:"top",children:/* @__PURE__ */T(Pe,{onClick:s,type:"button",className:"action","aria-label":"Add a child concept below this concept",children:/* @__PURE__ */T(ne,{className:"add"})})}),
/* @__PURE__ */T(B,{delay:{open:750},content:/* @__PURE__ */T(U,{padding:1,sizing:"content",children:/* @__PURE__ */T(M,{muted:!0,size:1,children:"Remove this concept from this scheme"})}),fallbackPlacements:["right","left"],placement:"top",children:/* @__PURE__ */T(Pe,{onClick:d,type:"button",className:"action","aria-label":"Remove this concept from this scheme",children:/* @__PURE__ */T(te,{className:"remove"})})})]}),!t&&"published"!==o&&0==e.childConcepts?.length&&5==e.level&&/* @__PURE__ */N(A,{space:2,children:[
/* @__PURE__ */T(B,{delay:{open:750},content:/* @__PURE__ */T(U,{padding:1,sizing:"content",children:/* @__PURE__ */T(M,{muted:!0,size:1,children:"This concept is at the maximum Taxonomy Manager hierarchy depth of 5 levels."})}),fallbackPlacements:["right","left"],placement:"top",children:/* @__PURE__ */T(Y,{className:"info warning"})}),
/* @__PURE__ */T(B,{delay:{open:750},content:/* @__PURE__ */T(U,{padding:1,sizing:"content",children:/* @__PURE__ */T(M,{muted:!0,size:1,children:"Remove this concept from this scheme"})}),fallbackPlacements:["right","left"],placement:"top",children:/* @__PURE__ */T(Pe,{onClick:d,type:"button",className:"action","aria-label":"Remove concept from scheme",children:/* @__PURE__ */T(te,{className:"remove"})})})]}),e?.childConcepts&&e?.childConcepts?.length>0&&5==e.level&&/* @__PURE__ */N(A,{space:1,children:[
/* @__PURE__ */T(B,{delay:{open:750},content:/* @__PURE__ */T(U,{padding:1,sizing:"content",children:/* @__PURE__ */T(M,{muted:!0,size:1,children:"This concept has unlisted child concepts. The maximum validated hierarchy depth is 5 levels."})}),fallbackPlacements:["right","left"],placement:"top",children:/* @__PURE__ */T(ie,{className:"info error"})}),!t&&"published"!==o&&/* @__PURE__ */T(B,{delay:{open:750},content:/* @__PURE__ */T(U,{padding:1,sizing:"content",children:/* @__PURE__ */T(M,{muted:!0,size:1,children:"Remove this concept from this scheme"})}),fallbackPlacements:["right","left"],placement:"top",children:/* @__PURE__ */T(Pe,{onClick:d,type:"button",className:"action","aria-label":"Remove concept from scheme",children:/* @__PURE__ */T(te,{className:"remove"})})})]})]}),e?.childConcepts&&e.childConcepts.length>0&&e?.level&&e.level<5&&/* @__PURE__ */T(nn,{concepts:e.childConcepts,selectConcept:n,inputComponent:t})]})},nn=({concepts:e,inputComponent:n=!1,selectConcept:t})=>/* @__PURE__ */T(Me,{children:e.map(e=>/* @__PURE__ */T(en,{concept:e,selectConcept:t,inputComponent:n},e.id))}),tn=({concept:e,treeVisibility:n,inputComponent:t,selectConcept:i})=>{const o=I(xe)||{},r=I(Ne),c=Ge(o),a=We(o),[s,d]=y(n),l=g(()=>{"open"==s?d("closed"):"closed"==s&&d("open")},[s]),p=g(()=>{c("concept",e)},[e,c]),h=g(()=>{a(e.id,"concept",e?.prefLabel)},[e.id,e?.prefLabel,a]);/* @__PURE__ */
return N(Oe,{className:s,children:[
/* @__PURE__ */N(A,{space:2,children:[e?.childConcepts&&e.childConcepts.length>0&&/* @__PURE__ */T(Le,{onClick:l,type:"button","aria-expanded":"open"==s,children:/* @__PURE__ */T(X,{})}),e?.childConcepts&&0==e.childConcepts.length&&/* @__PURE__ */T(ee,{className:"spacer"}),!e?.prefLabel&&/* @__PURE__ */T("span",{className:"untitled",children:"[new concept]"}),t?/* @__PURE__ */T(Xe,{concept:e,selectConcept:i}):/* @__PURE__ */T(Ye,{concept:e}),o.displayed?.topConcepts?.length&&/* @__PURE__ */T(M,{size:1,muted:!0,children:"orphan"}),t&&/* @__PURE__ */T(Qe,{concept:e}),!t&&"published"!==r&&/* @__PURE__ */N(A,{space:2,children:[
/* @__PURE__ */T(B,{delay:{open:750},content:/* @__PURE__ */T(U,{padding:1,sizing:"content",children:/* @__PURE__ */T(M,{muted:!0,size:1,children:"Add a child concept below this concept"})}),fallbackPlacements:["right","left"],placement:"top",children:/* @__PURE__ */T(Pe,{onClick:p,type:"button",className:"action","aria-label":"Add a child concept below this concept",children:/* @__PURE__ */T(ne,{className:"add"})})}),
/* @__PURE__ */T(B,{delay:{open:750},content:/* @__PURE__ */T(U,{padding:1,sizing:"content",children:/* @__PURE__ */T(M,{muted:!0,size:1,children:"Remove this concept from this scheme"})}),fallbackPlacements:["right","left"],placement:"top",children:/* @__PURE__ */T(Pe,{onClick:h,type:"button",className:"action","aria-label":"Remove this concept from this scheme",children:/* @__PURE__ */T(te,{className:"remove"})})})]})]}),e?.childConcepts&&e.childConcepts.length>0&&/* @__PURE__ */T(nn,{concepts:e.childConcepts,selectConcept:i,inputComponent:t})]})},on=({document:e})=>{const[n,t]=y(!1),[o,r]=y(""),[c,a]=y(""),s=g(()=>t(!1),[]),d=g(()=>t(!0),[]),l=g(e=>{r(e.currentTarget.value)},[]),p=g(e=>{a(e.currentTarget.value)},[]),h=function(){const e=R(),n=i({apiVersion:"2021-10-21"});return g((t,i,o)=>{const r=t.displayed?._id,c=t.displayed?.baseIri,a=t.displayed?.schemeId,s={_id:`drafts.${r}`,_type:"skosConceptScheme",schemeId:a,baseIri:c,title:i,description:o||""};n.createIfNotExists(s).then(n=>o?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=g(()=>{h(e,o,c)},[h,c,e,o]);/* @__PURE__ */
return N(Se,{children:[
/* @__PURE__ */T(Z,{padding:[3,3,4],radius:2,shadow:1,tone:"primary",children:/* @__PURE__ */N(O,{space:6,children:[
/* @__PURE__ */N(O,{space:4,children:[
/* @__PURE__ */T(K,{size:4,children:"New Concept Scheme"}),
/* @__PURE__ */T(M,{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.'})]}),
/* @__PURE__ */T(D,{tone:"primary",fontSize:2,icon:oe,onClick:d,text:"Add Title"})]})}),n&&/* @__PURE__ */T(F,{header:"Title & Description",id:"title-description",onClose:s,zOffset:1e3,width:1,children:/* @__PURE__ */T(U,{padding:4,children:/* @__PURE__ */N(O,{space:4,children:[
/* @__PURE__ */N(O,{space:2,children:[
/* @__PURE__ */T(K,{size:1,children:"Title"}),
/* @__PURE__ */T(M,{size:1,muted:!0,children:"Describe the concept scheme in one or two words."})]}),
/* @__PURE__ */T(q,{fontSize:2,onChange:l,padding:3,placeholder:"",value:o}),
/* @__PURE__ */N(O,{space:2,children:[
/* @__PURE__ */T(K,{size:1,children:"Description (optional)"}),
/* @__PURE__ */T(M,{size:1,muted:!0,children:"Describe the intended use of this concept scheme."})]}),
/* @__PURE__ */T(j,{fontSize:2,onChange:p,padding:3,placeholder:"",value:c,rows:3}),
/* @__PURE__ */T(D,{tone:"primary",fontSize:2,onClick:m,text:"Save"})]})})})]})},rn=()=>/* @__PURE__ */T(Se,{children:/* @__PURE__ */T(Z,{padding:[3,3,4],radius:2,shadow:1,tone:"primary",children:/* @__PURE__ */N(O,{space:4,children:[
/* @__PURE__ */T(K,{size:4,children:"No Concepts"}),
/* @__PURE__ */T(M,{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."})]})})}),cn=({concept:e,treeVisibility:n,inputComponent:t,selectConcept:i})=>{const o=I(xe)||{},r=I(Ne),c=Ge(o),a=We(o),[s,d]=y(n),l=g(()=>{"open"==s?d("closed"):"closed"==s&&d("open")},[s]),p=g(()=>{c("concept",e)},[e,c]),h=g(()=>{a(e?.id,"topConcept",e?.prefLabel)},[e?.id,e?.prefLabel,a]);/* @__PURE__ */
return N(Ee,{className:s,children:[
/* @__PURE__ */N(A,{space:2,children:[
/* @__PURE__ */N(A,{space:0,children:[e?.childConcepts&&e.childConcepts.length>0&&/* @__PURE__ */T(Le,{onClick:l,type:"button","aria-expanded":"open"==s,children:/* @__PURE__ */T(X,{})}),e?.childConcepts&&0==e.childConcepts.length&&/* @__PURE__ */T(ee,{className:"spacer"}),!e?.prefLabel&&/* @__PURE__ */T("span",{className:"untitled",children:"[new concept]"}),t?/* @__PURE__ */T(Xe,{concept:e,selectConcept:i}):/* @__PURE__ */T(Ye,{concept:e})]}),
/* @__PURE__ */T(M,{size:1,muted:!0,children:"top concept"}),t&&/* @__PURE__ */T(Qe,{concept:e}),!t&&"published"!==r&&/* @__PURE__ */N(A,{space:2,children:[
/* @__PURE__ */T(B,{delay:{open:750},content:/* @__PURE__ */T(U,{padding:1,sizing:"content",children:/* @__PURE__ */T(M,{muted:!0,size:1,children:"Add a child concept below this concept"})}),fallbackPlacements:["right","left"],placement:"top",children:/* @__PURE__ */T(Pe,{onClick:p,type:"button",className:"action","aria-label":"Add child a child concept",children:/* @__PURE__ */T(ne,{className:"add"})})}),
/* @__PURE__ */T(B,{delay:{open:750},content:/* @__PURE__ */T(U,{padding:1,sizing:"content",children:/* @__PURE__ */T(M,{muted:!0,size:1,children:"Remove this concept from this scheme"})}),fallbackPlacements:["right","left"],placement:"top",children:/* @__PURE__ */T(Pe,{onClick:h,type:"button",className:"action","aria-label":"Remove concept from scheme",children:/* @__PURE__ */T(te,{className:"remove"})})})]})]}),e?.childConcepts&&e.childConcepts.length>0&&/* @__PURE__ */T(nn,{concepts:e.childConcepts,selectConcept:i,inputComponent:t})]})},an=({concepts:e,inputComponent:n,selectConcept:t})=>{const{globalVisibility:{treeId:i,treeVisibility:o}={treeId:123,treeVisibility:"open"}}=I(Ve)||{};return e?.topConcepts?.length||e?.concepts?.length?/* @__PURE__ */N($e,{children:[e.topConcepts?.map(e=>/* @__PURE__ */T(cn,{concept:e,treeVisibility:o,inputComponent:n,selectConcept:t},`${e?.id}+${i}`)),e.concepts?.filter(e=>e?.isOrphan).map(e=>/* @__PURE__ */T(tn,{concept:e,treeVisibility:o,inputComponent:n,selectConcept:t},`${e.id}+${i}`))]}):/* @__PURE__ */T(rn,{})},sn=({branchId:e="",selectConcept:n,inputComponent:t})=>{const i=I(xe)||{},o=E(i.displayed?._id),r=I(Ne),{data:c,loading:a,error:s}=ke({fetch:`\n select($branchId != null => \n *[_id == $id][0] {\n _updatedAt,\n "topConcepts":*[_type == "skosConcept" && conceptId == $branchId]{\n "id": _id,\n "level": 0,\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${Te()||""} \n }, \n "concepts": []\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 ${Te()||""}\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 ${Te()||""}\n }\n }\n )`,listen:'*[_type == "skosConcept" || _id == $id]'},{params:{id:o,branchId:e},options:{perspective:void 0===r?"drafts":[r]}});return a?/* @__PURE__ */T(U,{padding:5,children:/* @__PURE__ */N(G,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[
/* @__PURE__ */T(W,{muted:!0}),
/* @__PURE__ */T(M,{muted:!0,size:1,children:"Loading hierarchy…"})]})}):s?(console.warn(s),/* @__PURE__ */T(U,{padding:4,children:/* @__PURE__ */T(Z,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */T(M,{size:1,children:"There was a problem loading terms. Please check the scheme configuration and try again."})})})):c?/* @__PURE__ */T(Ve.Provider,{value:{globalVisibility:{treeId:"123",treeVisibility:"open"}},children:/* @__PURE__ */T(U,{padding:4,children:/* @__PURE__ */T(an,{concepts:c,inputComponent:t||!1,selectConcept:n||(()=>{})})})}):/* @__PURE__ */T(U,{padding:4,children:/* @__PURE__ */T(Z,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */T(M,{size:1,children:"This configuration does not have any terms associated with it. Please check the scheme and branch supplied and try again."})})})},dn=({inputComponent:e=!1,branchId:n="",selectConcept:t})=>{const i=I(xe)||{},o=E(i.displayed?._id),r=I(Ne),c=Ge(i),a=g(()=>{c("topConcept")},[c]),s=g(()=>{c("concept")},[c]),[d,l]=y({treeId:ae(6),treeVisibility:"open"}),p=g(()=>{l({treeId:ae(6),treeVisibility:"open"})},[]),h=g(()=>{l({treeId:ae(6),treeVisibility:"closed"})},[]),{data:m,loading:u,error:f}=ke({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 ${Te()||""}\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 ${Te()||""}\n }\n }`,listen:'*[_type == "skosConcept" || _type == "skosConceptScheme" ]'},{params:{id:o,branchId:n},options:{perspective:void 0===r?"drafts":[r]}});return u?/* @__PURE__ */T(U,{padding:5,children:/* @__PURE__ */N(G,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[
/* @__PURE__ */T(W,{muted:!0}),
/* @__PURE__ */T(M,{muted:!0,size:1,children:"Loading hierarchy…"})]})}):f?(console.error(f),/* @__PURE__ */T("div",{children:"Error here"})):m?/* @__PURE__ */T(Ve.Provider,{value:{globalVisibility:d},children:/* @__PURE__ */T(U,{padding:4,paddingTop:2,children:/* @__PURE__ */N(z,{children:[
/* @__PURE__ */T(O,{space:4,children:/* @__PURE__ */T(Z,{borderBottom:!0,paddingBottom:1,display:"flex",flex:1,children:/* @__PURE__ */N(G,{justify:"space-between",flex:1,children:[
/* @__PURE__ */T(Z,{children:(m.topConcepts?.filter(e=>(e?.childConcepts?.length??0)>0).length>0||m.concepts?.filter(e=>(e?.childConcepts?.length??0)>0).length>0)&&/* @__PURE__ */N(A,{space:1,children:[
/* @__PURE__ */T(He,{type:"button",onClick:h,children:/* @__PURE__ */T(M,{weight:"semibold",muted:!0,size:1,children:"Collapse"})}),
/* @__PURE__ */T(M,{weight:"semibold",muted:!0,size:1,children:"|"}),
/* @__PURE__ */T(He,{type:"button",onClick:p,children:/* @__PURE__ */T(M,{weight:"semibold",muted:!0,size:1,children:"Expand"})})]})}),
/* @__PURE__ */T(Z,{children:"published"!==r&&/* @__PURE__ */N(A,{space:1,children:[
/* @__PURE__ */T(He,{type:"button",className:"add",onClick:a,children:/* @__PURE__ */N(M,{weight:"semibold",muted:!0,size:1,children:[
/* @__PURE__ */T(ne,{})," Add Top Concept"]})}),
/* @__PURE__ */T(He,{type:"button",className:"add",onClick:s,children:/* @__PURE__ */N(M,{weight:"semibold",muted:!0,size:1,children:[
/* @__PURE__ */T(ne,{})," Add Concept"]})})]})})]})})}),
/* @__PURE__ */T(an,{concepts:m,inputComponent:e,selectConcept:t||(()=>{})})]})})}):/* @__PURE__ */T(on,{document:i})},ln=({document:e,branchId:n,inputComponent:t=!1,selectConcept:i})=>{const{selectedPerspectiveName:o}=c();/* @__PURE__ */
return T(xe.Provider,{value:e||{},children:/* @__PURE__ */T(Ne.Provider,{value:o,children:t?/* @__PURE__ */T(sn,{inputComponent:t,branchId:n,selectConcept:i}):/* @__PURE__ */N(J,{width:1,style:{paddingTop:"1.25rem"},children:[e?.displayed?.description&&/* @__PURE__ */T(U,{padding:4,children:/* @__PURE__ */T(O,{space:4,children:/* @__PURE__ */N(O,{space:2,children:[
/* @__PURE__ */T(M,{size:1,weight:"semibold",children:"Description"}),
/* @__PURE__ */T(M,{size:2,muted:!0,style:{whiteSpace:"pre-wrap"},children:e?.displayed.description})]})})}),
/* @__PURE__ */T(dn,{inputComponent:t,branchId:n})]})})})};function pn(n){const t=i({apiVersion:"2025-02-19"}),o=e(["_id"]),{name:r,title:s}=n,d=S(o),l=a(o),{selectedPerspectiveName:p}=c(),[h,m]=y(!0),[u,f]=y(!0),[b,v]=y(!1),[w,I]=y({}),[_,k]=y(),{schemeId:x,branchId:V=null}=_?.params||{},{filter:z}=n.schemaType.options;C(()=>{(async function(){try{const e=await z({getClient:()=>t});k(e),f(!1)}catch(e){console.error("Error fetching filter values: ",e)}})().catch(e=>console.error("Error fetching filter values: ",e))},[z,t]),C(()=>{x&&t.fetch(`{"displayed": *[schemeId == "${x}"][0]}`).then(e=>{e?.displayed&&(I(e),m(!1))}).catch(e=>console.warn(e))},[t,x]);const $=g(()=>{v(!0)},[]),H=g(()=>{v(!1)},[]),P=g(e=>{(a(e?._originalId)||S(e?._originalId))&&(e._strengthenOnPublish={type:"skosConcept",template:{id:"skosConcept"}},e._weak=!0),delete e._originalId,l||d?t.patch(o).set({[r]:e}).commit().then(()=>v(!1)).catch(e=>console.error(e)):t.fetch(`*[_id == "${o}"][0]`).then(n=>{n._id=`drafts.${n._id}`,n[r]=e,t.create(n).catch(e=>console.error("Error creating draft: ",e))}).then(()=>v(!1)).catch(e=>console.error(e))},[t,o,l,d,r]);return n.schemaType.options?.filter?0===n.schemaType.options?.filter.length?/* @__PURE__ */N(O,{space:3,children:[n.renderDefault(n),
/* @__PURE__ */T(U,{padding:4,children:/* @__PURE__ */T(Z,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */N(M,{size:1,children:["There was a problem loading your filter settings. Please check the"," ",
/* @__PURE__ */T("code",{children:"schemeFilter()"})," or ",
/* @__PURE__ */T("code",{children:"branchFilter()"})," configuration for the"," ",s," field."]})})})]}):h||u?/* @__PURE__ */T(U,{padding:5,children:/* @__PURE__ */N(G,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[
/* @__PURE__ */T(W,{muted:!0}),
/* @__PURE__ */T(M,{muted:!0,size:1,children:"Loading input component…"})]})}):/* @__PURE__ */N(O,{space:3,children:[n.renderDefault(n),
/* @__PURE__ */T(Q,{columns:1,gap:3,children:/* @__PURE__ */T(D,{disabled:"published"===p,text:"Browse Taxonomy Tree",mode:"ghost",onClick:$})}),b&&/* @__PURE__ */T(F,{header:s,id:"concept-select-dialog",onClose:H,zOffset:900,width:1,children:/* @__PURE__ */T(U,{padding:10,children:/* @__PURE__ */T(ln,{document:w,branchId:V,inputComponent:!0,selectConcept:P})})})]}):/* @__PURE__ */N(O,{space:3,children:[n.renderDefault(n),
/* @__PURE__ */T(U,{padding:4,children:/* @__PURE__ */T(Z,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */N(M,{size:1,children:["The ",
/* @__PURE__ */T("code",{children:"ReferenceHierarchyInput()"})," component must be used with an accompanying"," ",
/* @__PURE__ */T("code",{children:"schemeFilter()"})," or ",
/* @__PURE__ */T("code",{children:"branchFilter()"}),". Please add an appropriate filter to the configuration for the ",s," field."]})})})]})}function hn(n){const t=i({apiVersion:"2025-02-19"}),o=e(["_id"]),{name:r,title:d,value:l=[]}=n,p=s(o),h=a(o),{selectedPerspectiveName:m}=c(),[u,f]=y(!0),[b,v]=y(!0),[w,I]=y(!1),[_,k]=y({}),[x,V]=y(),{schemeId:z,branchId:S=null}=x?.params||{},{filter:$}=n.schemaType.of[0].options,H=R();C(()=>{(async function(){try{const e=await $({getClient:()=>t});V(e),v(!1)}catch(e){console.error("Error fetching filter values: ",e)}})().catch(e=>console.error("Error fetching filter values: ",e))},[$,t]),C(()=>{z&&t.fetch(`{"displayed": *[schemeId == "${z}"][0]}`).then(e=>{e?.displayed&&(k(e),f(!1))}).catch(e=>console.warn(e))},[t,z]);const P=g(()=>{I(!0)},[]),L=g(()=>{I(!1)},[]),E=g(e=>{if((a(e?._originalId)||s(e?._originalId))&&(e._strengthenOnPublish={type:"skosConcept",template:{id:"skosConcept"}},e._weak=!0),delete e._originalId,l?.map(e=>e._ref).includes(e._ref))return I(!1),void H.push({status:"warning",title:"Taxonomy Term Not Added",description:"The selected concept is already included in this field.",duration:5e3,closable:!0});h||p?t.patch(o).setIfMissing({[r]:[]}).append(r,[e]).commit({autoGenerateArrayKeys:!0}).then(()=>I(!1)).catch(e=>console.error(e)):t.fetch(`*[_id == "${o}"][0]`).then(e=>{e._id=`drafts.${e._id}`,t.create(e).catch(e=>console.error("Error creating draft: ",e))}).then(()=>{t.patch(`drafts.${o}`).setIfMissing({[r]:[]}).append(r,[e]).commit({autoGenerateArrayKeys:!0}).then(()=>I(!1)).catch(e=>console.error(e))}).catch(e=>console.error(e))},[l,h,p,t,o,H,r]);return n.schemaType.of[0].options?.filter?0===n.schemaType.of[0].options?.filter?.length?/* @__PURE__ */N(O,{space:3,children:[n.renderDefault(n),
/* @__PURE__ */T(U,{padding:4,children:/* @__PURE__ */T(Z,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */N(M,{size:1,children:["There was a problem loading your filter settings. Please check the"," ",
/* @__PURE__ */T("code",{children:"schemeFilter()"})," or ",
/* @__PURE__ */T("code",{children:"branchFilter()"})," configuration for the"," ",d," field."]})})})]}):n.schemaType.of.length>1?/* @__PURE__ */N(O,{space:3,children:[n.renderDefault(n),
/* @__PURE__ */T(Z,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */T(O,{space:4,children:/* @__PURE__ */N(O,{space:2,children:[
/* @__PURE__ */T(K,{size:2,children:"Input Component Not Supported for Multi-Schema Arrays"}),
/* @__PURE__ */N(M,{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"," ",
/* @__PURE__ */T("a",{href:"https://sanitytaxonomymanager.com",children:"Taxonomy Manager docs"})," for more information."]})]})})})]}):u||b?/* @__PURE__ */T(U,{padding:5,children:/* @__PURE__ */N(G,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[
/* @__PURE__ */T(W,{muted:!0}),
/* @__PURE__ */T(M,{muted:!0,size:1,children:"Loading input component…"})]})}):/* @__PURE__ */N(O,{space:3,children:[n.renderDefault(n),
/* @__PURE__ */T(Q,{columns:1,gap:3,children:/* @__PURE__ */T(D,{disabled:"published"===m,text:"Browse Taxonomy Tree",mode:"ghost",onClick:P})}),w&&/* @__PURE__ */T(F,{header:d,id:"concept-select-dialog",onClose:L,zOffset:900,width:1,children:/* @__PURE__ */T(U,{padding:10,children:/* @__PURE__ */T(ln,{document:_,branchId:S,inputComponent:!0,selectConcept:E})})})]}):/* @__PURE__ */N(O,{space:3,children:[n.renderDefault(n),
/* @__PURE__ */T(U,{padding:4,children:/* @__PURE__ */T(Z,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */N(M,{size:1,children:["The ",
/* @__PURE__ */T("code",{children:"ArrayHierarchyInput()"})," component must be used with an accompanying"," ",
/* @__PURE__ */T("code",{children:"schemeFilter()"})," or ",
/* @__PURE__ */T("code",{children:"branchFilter()"}),". Please add an appropriate filter to the configuration for the ",d," field."]})})})]})}const mn=e=>{const{onChange:n}=e,t=R(),i=g(()=>{n(d()),t.push({status:"success",title:"Value removed.",duration:2500,closable:!0})},[n,t]);/* @__PURE__ */
return T(O,{space:2,children:/* @__PURE__ */N(A,{space:[3,3,4],children:[e.renderDefault(e),
/* @__PURE__ */T(D,{tone:"primary",fontSize:2,onClick:i,text:"Remove Value"})]})})};function un(){/* @__PURE__ */
return T("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__ */T("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 fn=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 e=>{const t=e?.getClient({apiVersion:"2025-02-19"});if(!t)throw new Error("Client not available");const{concepts:i,topConcepts:o}=await t.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:i,topConcepts:o,schemeId:n}}}},gn=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 e=>{const i=e?.getClient({apiVersion:"2023-01-01"});if(!i)throw new Error("Client not available");const{concepts:o}=await i.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}}}};var yn=[l({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__ */N(ze,{children:[
/* @__PURE__ */T("summary",{children:"The root URI (Uniform Resource Identifier) used to create unique concept identifiers."}),
/* @__PURE__ */N("div",{children:["Unique identifiers allow for the clear an unambiguous identification of concepts across namespaces, for example between ",
/* @__PURE__ */T("code",{children:"https://shipparts.com/vocab#Bow"})," and ",
/* @__PURE__ */T("code",{children:"https://wrappingsupplies.com/vocab#Bow"}),"."]}),
/* @__PURE__ */T("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."}),
/* @__PURE__ */T("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__ */
return N(O,{space:2,children:[n.renderDefault(n),
/* @__PURE__ */T(M,{muted:!0,size:1,children:/* @__PURE__ */N(z,{children:[
/* @__PURE__ */T("strong",{children:"RDF URI: "}),n.value?n.value:"[base URI not defined] ",t||i||" [identifier not assigned]"]})})]})}}})];const bn=({document:e})=>({filter:"!(_id in $broader || _id in $related || _id == $self)",params:{self:E(P(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 Cn(e,n=[]){return p({name:"skosConcept",title:"Concept",type:"document",icon:he,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:[l({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.")})}),l({name:"definition",title:"Definition",type:"text",description:/* @__PURE__ */N(ze,{children:[
/* @__PURE__ */T("summary",{children:"A complete explanation of the intended meaning of the concept."}),
/* @__PURE__ */N("div",{children:[
/* @__PURE__ */N("kbd",{children:["Example: documentation",
/* @__PURE__ */T("br",{}),'Definition: "The process of storing and retrieving information in all fields of knowledge."']}),
/* @__PURE__ */N("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",
/* @__PURE__ */N("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}),l({name:"example",title:"Examples",type:"text",description:/* @__PURE__ */N(ze,{children:[
/* @__PURE__ */T("summary",{children:"An example of the use of the concept."}),
/* @__PURE__ */N("div",{children:[
/* @__PURE__ */N("kbd",{children:["Example: organizations of science and culture",
/* @__PURE__ */T("br",{}),'Example: "academies of science, general museums, world fairs"']}),
/* @__PURE__ */N("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",
/* @__PURE__ */N("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}),l({name:"scopeNote",title:"Scope Note",type:"text",description:/* @__PURE__ */N(ze,{children:[
/* @__PURE__ */T("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."}),
/* @__PURE__ */N("div",{children:[
/* @__PURE__ */N("kbd",{children:["Example: microwave frequencies",
/* @__PURE__ */T("br",{}),'Scope Note: "Used for frequencies between 1Ghz and 300Ghz"']}),
/* @__PURE__ */N("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",
/* @__PURE__ */N("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}),l({name:"altLabel",title:"Alternate Label(s)",type:"array",description:/* @__PURE__ */N(ze,{children:[
/* @__PURE__ */T("summary",{children:"Synonyms, near-synonyms, abbreviations, and acronyms to a concept."}),
/* @__PURE__ */T("div",{children:/* @__PURE__ */N("p",{children:[
/* @__PURE__ */T(re,{})," Preferred, alternative, and hidden label sets must not overlap."]})})]}),of:[{type:"string"}],validation:e=>e.unique()}),l({name:"hiddenLabel",title:"Hidden Label(s)",type:"array",description:/* @__PURE__ */N(ze,{children:[
/* @__PURE__ */T("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."}),
/* @__PURE__ */N("div",{children:[
/* @__PURE__ */T("p",{children:"Hidden labels may for instance be used to include misspelled variants of other lexical labels."}),
/* @__PURE__ */N("p",{children:[
/* @__PURE__ */T(re,{})," Preferred, alternative, and hidden label sets must not overlap."]})]})]}),of:[{type:"string"}],validation:e=>e.unique()}),...yn,l({name:"conceptId",title:"Identifier",description:"This concept does not yet have a unique identifier.",type:"string",initialValue:()=>`${ae(6)}`,hidden:({document:e})=>!!e?.conceptId,readOnly:({document:e})=>!!e?.conceptId,components:{input:ue}}),l({name:"broader",title:"Broader Concept(s)",description:/* @__PURE__ */N(ze,{children:[
/* @__PURE__ */T("summary",{children:"Create hierarchy between concepts, for example to create category/subcategory, part/whole, or class/instance relationships."}),
/* @__PURE__ */T("div",{children:/* @__PURE__ */T("p",{children:"Broader and Associated relationships are mutually exclusive."})})]}),type:"array",of:[{type:"reference",to:{type:"skosConcept"},options:{filter:bn}}]}),l({name:"related",title:"Related Concept(s)",description:/* @__PURE__ */N(ze,{children:[
/* @__PURE__ */T("summary",{children:'Indicate that two concepts are inherently "related", but that one is not in any way more general than the other.'}),
/* @__PURE__ */T("div",{children:/* @__PURE__ */T("p",{children:"Broader and Associated relationships are mutually exclusive."})})]}),type:"array",of:[{type:"reference",to:[{type:"skosConcept"}],options:{filter:bn}}]}),...n,l({name:"historyNote",title:"History Notes",type:"text",description:/* @__PURE__ */N(ze,{children:[
/* @__PURE__ */T("summary",{children:"Significant changes to the meaning or the form of this concept."}),
/* @__PURE__ */N("div",{children:[
/* @__PURE__ */N("kbd",{children:["Example: person with disabilities",
/* @__PURE__ */T("br",{}),'History Note: "Estab. 1992; heading was: handicapped [1884 - 1992]."']}),
/* @__PURE__ */N("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",
/* @__PURE__ */N("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}),l({name:"editorialNote",title:"Editorial Notes",type:"text",description:/* @__PURE__ */N(ze,{children:[
/* @__PURE__ */T("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."}),
/* @__PURE__ */N("div",{children:[
/* @__PURE__ */N("kbd",{children:["Example: doubleclick",
/* @__PURE__ */T("br",{}),'Editorial Note: "Review this term after the company merger is complete."']}),
/* @__PURE__ */N("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",
/* @__PURE__ */N("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}),l({name:"changeNote",title:"Change Notes",type:"text",description:/* @__PURE__ */N(ze,{children:[
/* @__PURE__ */T("summary",{children:"Fine-grained changes to a concept, for the purposes of administration and maintenance."}),
/* @__PURE__ */N("div",{children:[
/* @__PURE__ */N("kbd",{children:["Example: tomato",
/* @__PURE__ */T("br",{}),"Change Note: \"Moved from under 'fruits' to under 'vegetables' by Horace Gray\""]}),
/* @__PURE__ */N("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",
/* @__PURE__ */N("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:me})}})}function vn(e,n=[]){return p({name:"skosConceptScheme",title:"Concept Scheme",type:"document",icon:un,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:[l({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"}),l({name:"description",title:"Description",type:"text",rows:5,description:"Describe the intended use of this scheme."}),l({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:mn}}),...yn,l({name:"schemeId",title:"Identifier",description:"This scheme does not yet have a unique identifier.",type:"string",initialValue:()=>`${ae(6)}`,hidden:({document:e})=>!!e?.schemeId,readOnly:({document:e})=>!!e?.schemeId,components:{input:ue}}),l({name:"topConcepts",title:"Top Concepts",type:"array",validation:e=>e.unique(),of:[h({type:"reference",to:[{type:"skosConcept"}]})],options:{sortable:!1}}),l({name:"concepts",title:"Concepts",type:"array",validation:e=>e.unique(),of:[h({type:"reference",to:[{type:"skosConcept"}]})],options:{sortable:!1}}),...n],preview:{select:{title:"title"},prepare:({title:e})=>({title:e,media:un})}})}const wn=e=>e.list().title("Taxonomy Manager").items([e.documentTypeListItem("skosConceptScheme").title("Concept Schemes"),e.documentTypeListItem("skosConcept").title("Concepts")]),In=(e,{schemaType:n})=>{switch(n){case"skosConceptScheme":return e.document().views([e.view.component(ln).title("Tree View").icon(un),e.view.form().icon(ce)]);case"skosConcept":return e.document().views([e.view.form().icon(ce)]);default:e.view.form()}},_n=m(e=>{const{baseUri:n,customConceptFields:t,customSchemeFields:i}=e||{};return{name:"taxonomyManager",options:e,schema:{types:[Cn(n,t),vn(n,i)]},plugins:[f({name:"taxonomy",title:"Taxonomy",structure:wn,defaultDocumentNode:In,icon:un})]}});export{hn as ArrayHierarchyInput,pn as ReferenceHierarchyInput,ln