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